@beamimpact/web-sdk 1.39.2 → 1.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/chunks/_share-dialog-dependencies-1vD2dmjh.esm.js +2 -0
  2. package/dist/chunks/_share-dialog-dependencies-1vD2dmjh.esm.js.map +1 -0
  3. package/dist/chunks/_share-dialog-dependencies-jvbBs-cC.esm.js +2 -0
  4. package/dist/chunks/_share-dialog-dependencies-jvbBs-cC.esm.js.map +1 -0
  5. package/dist/chunks/index-FIfx75-P.esm.js +2 -0
  6. package/dist/chunks/index-FIfx75-P.esm.js.map +1 -0
  7. package/dist/chunks/index-GocMPeWn.esm.js +2 -0
  8. package/dist/chunks/index-GocMPeWn.esm.js.map +1 -0
  9. package/dist/chunks/index-HyzTMHYl.esm.js +2 -0
  10. package/dist/chunks/index-HyzTMHYl.esm.js.map +1 -0
  11. package/dist/chunks/index-LmCqzg5B.esm.js +2 -0
  12. package/dist/chunks/index-LmCqzg5B.esm.js.map +1 -0
  13. package/dist/chunks/index-bUooCSdc.esm.js +2 -0
  14. package/dist/chunks/index-bUooCSdc.esm.js.map +1 -0
  15. package/dist/chunks/{index-XlnH7ARQ.esm.js → index-fINTvZVX.esm.js} +2 -2
  16. package/dist/chunks/{index-XlnH7ARQ.esm.js.map → index-fINTvZVX.esm.js.map} +1 -1
  17. package/dist/chunks/index-iMRMlkF3.esm.js +2 -0
  18. package/dist/chunks/index-iMRMlkF3.esm.js.map +1 -0
  19. package/dist/chunks/{index-dsJIs5Sr.esm.js → index-kxMe_AX1.esm.js} +2 -2
  20. package/dist/chunks/{index-dsJIs5Sr.esm.js.map → index-kxMe_AX1.esm.js.map} +1 -1
  21. package/dist/chunks/{order-page-6Q-6CHug.esm.js → order-page-0azkW5QD.esm.js} +2 -2
  22. package/dist/chunks/{order-page-6Q-6CHug.esm.js.map → order-page-0azkW5QD.esm.js.map} +1 -1
  23. package/dist/chunks/{order-page-mYYXHDVr.esm.js → order-page-n12hvsCN.esm.js} +2 -2
  24. package/dist/chunks/{order-page-mYYXHDVr.esm.js.map → order-page-n12hvsCN.esm.js.map} +1 -1
  25. package/dist/chunks/{routes-b8sncPq8.esm.js → routes-31m626dW.esm.js} +2 -2
  26. package/dist/chunks/{routes-b8sncPq8.esm.js.map → routes-31m626dW.esm.js.map} +1 -1
  27. package/dist/chunks/{routes-3jKReDai.esm.js → routes-sbqL3QFm.esm.js} +2 -2
  28. package/dist/chunks/{routes-3jKReDai.esm.js.map → routes-sbqL3QFm.esm.js.map} +1 -1
  29. package/dist/chunks/{update-cart-GaVMWI6J.esm.js → update-cart-NEt4A8dB.esm.js} +2 -2
  30. package/dist/chunks/{update-cart-GaVMWI6J.esm.js.map → update-cart-NEt4A8dB.esm.js.map} +1 -1
  31. package/dist/chunks/{update-cart-xW6a5_bz.esm.js → update-cart-XAwwFxhS.esm.js} +2 -2
  32. package/dist/chunks/{update-cart-xW6a5_bz.esm.js.map → update-cart-XAwwFxhS.esm.js.map} +1 -1
  33. package/dist/components/community-impact.esm.js +1 -1
  34. package/dist/components/community-impact.js +1 -1
  35. package/dist/components/cumulative-impact.esm.js +1 -1
  36. package/dist/components/cumulative-impact.esm.js.map +1 -1
  37. package/dist/components/cumulative-impact.js +1 -1
  38. package/dist/components/cumulative-impact.js.map +1 -1
  39. package/dist/components/impact-overview.esm.js +7 -7
  40. package/dist/components/impact-overview.esm.js.map +1 -1
  41. package/dist/components/impact-overview.js +7 -7
  42. package/dist/components/impact-overview.js.map +1 -1
  43. package/dist/components/index.esm.js +1 -1
  44. package/dist/components/index.js +1 -1
  45. package/dist/components/post-purchase.d.ts +1 -1
  46. package/dist/components/post-purchase.esm.js +1 -1
  47. package/dist/components/post-purchase.esm.js.map +1 -1
  48. package/dist/components/post-purchase.js +1 -1
  49. package/dist/components/post-purchase.js.map +1 -1
  50. package/dist/components/product-details-page.d.ts +2 -2
  51. package/dist/components/product-details-page.esm.js +66 -18
  52. package/dist/components/product-details-page.esm.js.map +1 -1
  53. package/dist/components/product-details-page.js +66 -18
  54. package/dist/components/product-details-page.js.map +1 -1
  55. package/dist/components/redeem-transaction.d.ts +1 -1
  56. package/dist/components/redeem-transaction.esm.js +1 -1
  57. package/dist/components/redeem-transaction.js +1 -1
  58. package/dist/components/select-nonprofit.d.ts +1 -1
  59. package/dist/components/select-nonprofit.esm.js +1 -1
  60. package/dist/components/select-nonprofit.js +1 -1
  61. package/dist/components/shopify.esm.js +1 -1
  62. package/dist/components/shopify.esm.js.map +1 -1
  63. package/dist/components/shopify.js +1 -1
  64. package/dist/components/shopify.js.map +1 -1
  65. package/dist/components/subscription-management.d.ts +1 -1
  66. package/dist/components/subscription-management.esm.js +1 -1
  67. package/dist/components/subscription-management.esm.js.map +1 -1
  68. package/dist/components/subscription-management.js +1 -1
  69. package/dist/components/subscription-management.js.map +1 -1
  70. package/dist/index.esm.js +1 -1
  71. package/dist/index.js +1 -1
  72. package/dist/integrations/beam.esm.js +1 -1
  73. package/dist/integrations/beam.js +1 -1
  74. package/dist/integrations/cart.esm.js +1 -1
  75. package/dist/integrations/cart.js +1 -1
  76. package/dist/integrations/index.esm.js +1 -1
  77. package/dist/integrations/index.js +1 -1
  78. package/dist/integrations/logs.esm.js +1 -1
  79. package/dist/integrations/logs.js +1 -1
  80. package/dist/integrations/shopify.esm.js +1 -1
  81. package/dist/integrations/shopify.js +1 -1
  82. package/dist/integrations/statsig.esm.js +1 -1
  83. package/dist/integrations/statsig.js +1 -1
  84. package/dist/react/community-impact.esm.js +1 -1
  85. package/dist/react/community-impact.js +1 -1
  86. package/dist/react/cumulative-impact.esm.js +1 -1
  87. package/dist/react/cumulative-impact.js +1 -1
  88. package/dist/react/impact-overview.esm.js +1 -1
  89. package/dist/react/impact-overview.esm.js.map +1 -1
  90. package/dist/react/impact-overview.js +1 -1
  91. package/dist/react/impact-overview.js.map +1 -1
  92. package/dist/react/index.esm.js +1 -1
  93. package/dist/react/index.js +1 -1
  94. package/dist/react/post-purchase.esm.js +1 -1
  95. package/dist/react/post-purchase.esm.js.map +1 -1
  96. package/dist/react/post-purchase.js +1 -1
  97. package/dist/react/post-purchase.js.map +1 -1
  98. package/dist/react/product-details-page.esm.js +1 -1
  99. package/dist/react/product-details-page.esm.js.map +1 -1
  100. package/dist/react/product-details-page.js +1 -1
  101. package/dist/react/product-details-page.js.map +1 -1
  102. package/dist/react/redeem-transaction.esm.js +1 -1
  103. package/dist/react/redeem-transaction.js +1 -1
  104. package/dist/react/select-nonprofit.esm.js +1 -1
  105. package/dist/react/select-nonprofit.js +1 -1
  106. package/dist/react/subscription-management.esm.js +1 -1
  107. package/dist/react/subscription-management.esm.js.map +1 -1
  108. package/dist/react/subscription-management.js +1 -1
  109. package/dist/react/subscription-management.js.map +1 -1
  110. package/package.json +1 -1
  111. package/dist/chunks/_share-dialog-dependencies-K7WZWxUL.esm.js +0 -2
  112. package/dist/chunks/_share-dialog-dependencies-K7WZWxUL.esm.js.map +0 -1
  113. package/dist/chunks/_share-dialog-dependencies-VjhRF4_b.esm.js +0 -2
  114. package/dist/chunks/_share-dialog-dependencies-VjhRF4_b.esm.js.map +0 -1
  115. package/dist/chunks/index-EUMlzqI-.esm.js +0 -2
  116. package/dist/chunks/index-EUMlzqI-.esm.js.map +0 -1
  117. package/dist/chunks/index-U5URUABu.esm.js +0 -2
  118. package/dist/chunks/index-U5URUABu.esm.js.map +0 -1
  119. package/dist/chunks/index-VELk9_yH.esm.js +0 -2
  120. package/dist/chunks/index-VELk9_yH.esm.js.map +0 -1
  121. package/dist/chunks/index-q_XLkvqc.esm.js +0 -2
  122. package/dist/chunks/index-q_XLkvqc.esm.js.map +0 -1
  123. package/dist/chunks/index-xR738adx.esm.js +0 -2
  124. package/dist/chunks/index-xR738adx.esm.js.map +0 -1
  125. package/dist/chunks/index-xfPSpbUV.esm.js +0 -2
  126. package/dist/chunks/index-xfPSpbUV.esm.js.map +0 -1
  127. package/dist/chunks/shoelace-components-7XWYNn-Z.esm.js +0 -2
  128. package/dist/chunks/shoelace-components-7XWYNn-Z.esm.js.map +0 -1
  129. package/dist/chunks/shoelace-components-paAsUPkU.esm.js +0 -2
  130. package/dist/chunks/shoelace-components-paAsUPkU.esm.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"update-cart-xW6a5_bz.esm.js","sources":["../../src/integrations/cart/update-cart.ts"],"sourcesContent":["import isEqual from \"lodash-es/isEqual\";\nimport { DEFAULT_BASE_URL } from \"../../api-sdk/constants\";\nimport { BeamBaseAPIConfig } from \"../../api-sdk/types\";\nimport { postCart } from \"../../api-sdk/v3/routes\";\nimport { debounce, memoizeLast } from \"../../utils\";\nimport { BeamError } from \"../../utils/beam-errors\";\nimport { BEAM_CART_COOKIE_NAME, TBeamCartLocalStorage, TCartApi } from \"../../shared/cart-contents\";\nimport { getCookieValue, setCookieValue } from \"../../utils/cookies\";\nimport { BeamCartChangeEvent, BeamCartCreatedEvent } from \"../../utils/events\";\nimport { createScopedLocalStorage } from \"../../utils/local-storage\";\nimport { getRemoteSession } from \"../../utils/remote-session\";\n\nexport type BeamCartAPIConfig = BeamBaseAPIConfig & {\n storeId: number;\n domain?: string; // Domain to set cookies on\n};\n\nexport type BeamCartValues = {\n cartId?: string; // External (partner) cart ID\n itemCount?: number;\n subtotal?: number;\n currencyCode?: string;\n} & Partial<TCartApi>;\n\n/**\n * The debounce time in milliseconds for updating the cart - updateCart will delay until it hasn't been called for\n * this long before handling the last call.\n */\nconst UPDATE_CART_DEBOUNCE_MS = 50;\n\n/**\n * Sends cart information to Beam\n * Memoized based on previous arguments - if the objects are deep-equal, no update is made.\n * @side-effects Sets beam_cart cookie, set cart data in localstorage\n * @example\n * const BeamConfig = { apiKey: 'abc-123' }\n * const { beamCartId } = await updateCart(BeamConfig, { beamCartId, itemCount, subtotal, currencyCode })\n * */\nconst updateCart = debounce(\n memoizeLast(async function updateCart(config: BeamCartAPIConfig, cartValues: BeamCartValues) {\n try {\n const localStorage = createScopedLocalStorage({ apiKey: config.apiKey });\n const baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;\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 = (await getCookieValue(BEAM_CART_COOKIE_NAME)) ?? null;\n // Remote session ID (ie, device ID from an A/B testing tool) will be linked to the cart\n const remoteSessionId: string | undefined = getRemoteSession(config) ?? undefined;\n\n const {\n cartId,\n subtotal,\n itemCount,\n currencyCode,\n content: { items = [] } = {},\n schema = { source: \"generic\" },\n } = cartValues;\n\n const cartWithDefaults = {\n cartId,\n subtotal,\n itemCount,\n currencyCode,\n content: { items },\n schema,\n beamCartId,\n };\n\n // Early return conditions. Skip sending cart to Beam if any apply:\n // 1. The cart has not changed\n // 2. Cart is empty, unless the cart was not empty before\n if (\n isEqual(cartWithDefaults, {\n ...cachedCart,\n cartId: cachedCart?.cartId /* make sure optional key is defined even if empty */,\n }) || // cart has not\n // changed, OR\n (cartValues.itemCount === 0 && // nothing in current cart, AND\n (!beamCartId || cachedCart?.itemCount === 0)) // no/expired prev cart or prev cart was empty\n ) {\n return;\n }\n\n const response = await postCart({\n baseUrl,\n headers: {\n authorization: `Api-Key ${config.apiKey}`,\n },\n requestBody: {\n beamCartId, // backwards compat: explicitly sending null here is required to get initial beamCartId\n storeId: config.storeId,\n remoteSessionId,\n cartId,\n subtotal,\n itemCount,\n currencyCode,\n },\n });\n\n // Response will contain a new beamCartId if one was not provided, or old one expired\n const { beamCartId: newBeamCartId, expiresAt, beamCartCreated } = response;\n\n if (newBeamCartId && expiresAt) {\n await setCookieValue({\n name: BEAM_CART_COOKIE_NAME,\n domain: config.domain,\n value: newBeamCartId,\n path: \"/\",\n // If we don't set an expiration, the cookie will be cleared when the tab is closed\n expires: new Date(expiresAt).getTime(),\n });\n }\n\n localStorage.setItemJson(\"cart\", {\n ...cartWithDefaults,\n beamCartId: newBeamCartId,\n });\n\n const eventDetail = {\n schema: schema as any, // TS union type can't figure out what variant applies here\n content: {\n items: items as any,\n },\n subtotal,\n itemCount,\n currencyCode,\n cartId,\n };\n\n // emit change event on any create/update/delete of cart items\n window.dispatchEvent(new BeamCartChangeEvent(eventDetail));\n\n // emit created event only when the cart is new according to Beam\n if (beamCartCreated) {\n window.dispatchEvent(new BeamCartCreatedEvent(eventDetail));\n }\n } catch (err) {\n throw new BeamError(\"Could not update cart in Beam\", { cause: err });\n }\n }),\n UPDATE_CART_DEBOUNCE_MS,\n { leading: true } // handle first call immediately but delay for more calls within debounce window\n);\n\nexport { updateCart };\n"],"names":["UPDATE_CART_DEBOUNCE_MS","updateCart","debounce","memoizeLast","config","cartValues","localStorage","createScopedLocalStorage","baseUrl","DEFAULT_BASE_URL","cachedCart","beamCartId","getCookieValue","BEAM_CART_COOKIE_NAME","remoteSessionId","getRemoteSession","cartId","subtotal","itemCount","currencyCode","items","schema","cartWithDefaults","isEqual","response","postCart","newBeamCartId","expiresAt","beamCartCreated","setCookieValue","eventDetail","BeamCartChangeEvent","BeamCartCreatedEvent","err","BeamError"],"mappings":"+jBA4BA,MAAMA,EAA0B,GAU1BC,EAAaC,EACjBC,EAAY,eAA0BC,EAA2BC,EAA4B,CAC3F,GAAI,CACF,MAAMC,EAAeC,EAAyB,CAAE,OAAQH,EAAO,MAAO,CAAC,EACjEI,EAAUJ,EAAO,SAAWK,EAG5BC,EAA2CJ,EAAa,YAAY,MAAM,EAG1EK,EAA6B,MAAMC,EAAeC,CAAqB,GAAM,KAE7EC,EAAsCC,EAAiBX,CAAM,GAAK,OAElE,CACJ,OAAAY,EACA,SAAAC,EACA,UAAAC,EACA,aAAAC,EACA,QAAS,CAAE,MAAAC,EAAQ,CAAA,CAAG,EAAI,CAAC,EAC3B,OAAAC,EAAS,CAAE,OAAQ,SAAU,CAC/B,EAAIhB,EAEEiB,EAAmB,CACvB,OAAAN,EACA,SAAAC,EACA,UAAAC,EACA,aAAAC,EACA,QAAS,CAAE,MAAAC,CAAM,EACjB,OAAAC,EACA,WAAAV,CACF,EAKA,GACEY,EAAQD,EAAkB,CACxB,GAAGZ,EACH,OAAQA,GAAY,MACtB,CAAC,GAEAL,EAAW,YAAc,IACvB,CAACM,GAAcD,GAAY,YAAc,GAE5C,OAGF,MAAMc,EAAW,MAAMC,EAAS,CAC9B,QAAAjB,EACA,QAAS,CACP,cAAe,WAAWJ,EAAO,MAAM,EACzC,EACA,YAAa,CACX,WAAAO,EACA,QAASP,EAAO,QAChB,gBAAAU,EACA,OAAAE,EACA,SAAAC,EACA,UAAAC,EACA,aAAAC,CACF,CACF,CAAC,EAGK,CAAE,WAAYO,EAAe,UAAAC,EAAW,gBAAAC,CAAgB,EAAIJ,EAE9DE,GAAiBC,GACnB,MAAME,EAAe,CACnB,KAAMhB,EACN,OAAQT,EAAO,OACf,MAAOsB,EACP,KAAM,IAEN,QAAS,IAAI,KAAKC,CAAS,EAAE,QAAQ,CACvC,CAAC,EAGHrB,EAAa,YAAY,OAAQ,CAC/B,GAAGgB,EACH,WAAYI,CACd,CAAC,EAED,MAAMI,EAAc,CAClB,OAAQT,EACR,QAAS,CACP,MAAOD,CACT,EACA,SAAAH,EACA,UAAAC,EACA,aAAAC,EACA,OAAAH,CACF,EAGA,OAAO,cAAc,IAAIe,EAAoBD,CAAW,CAAC,EAGrDF,GACF,OAAO,cAAc,IAAII,EAAqBF,CAAW,CAAC,CAE9D,OAASG,EAAK,CACZ,MAAM,IAAIC,EAAU,gCAAiC,CAAE,MAAOD,CAAI,CAAC,CACrE,CACF,CAAC,EACDjC,EACA,CAAE,QAAS,EAAK,CAClB"}
1
+ {"version":3,"file":"update-cart-XAwwFxhS.esm.js","sources":["../../src/integrations/cart/update-cart.ts"],"sourcesContent":["import isEqual from \"lodash-es/isEqual\";\nimport { DEFAULT_BASE_URL } from \"../../api-sdk/constants\";\nimport { BeamBaseAPIConfig } from \"../../api-sdk/types\";\nimport { postCart } from \"../../api-sdk/v3/routes\";\nimport { debounce, memoizeLast } from \"../../utils\";\nimport { BeamError } from \"../../utils/beam-errors\";\nimport { BEAM_CART_COOKIE_NAME, TBeamCartLocalStorage, TCartApi } from \"../../shared/cart-contents\";\nimport { getCookieValue, setCookieValue } from \"../../utils/cookies\";\nimport { BeamCartChangeEvent, BeamCartCreatedEvent } from \"../../utils/events\";\nimport { createScopedLocalStorage } from \"../../utils/local-storage\";\nimport { getRemoteSession } from \"../../utils/remote-session\";\n\nexport type BeamCartAPIConfig = BeamBaseAPIConfig & {\n storeId: number;\n domain?: string; // Domain to set cookies on\n};\n\nexport type BeamCartValues = {\n cartId?: string; // External (partner) cart ID\n itemCount?: number;\n subtotal?: number;\n currencyCode?: string;\n} & Partial<TCartApi>;\n\n/**\n * The debounce time in milliseconds for updating the cart - updateCart will delay until it hasn't been called for\n * this long before handling the last call.\n */\nconst UPDATE_CART_DEBOUNCE_MS = 50;\n\n/**\n * Sends cart information to Beam\n * Memoized based on previous arguments - if the objects are deep-equal, no update is made.\n * @side-effects Sets beam_cart cookie, set cart data in localstorage\n * @example\n * const BeamConfig = { apiKey: 'abc-123' }\n * const { beamCartId } = await updateCart(BeamConfig, { beamCartId, itemCount, subtotal, currencyCode })\n * */\nconst updateCart = debounce(\n memoizeLast(async function updateCart(config: BeamCartAPIConfig, cartValues: BeamCartValues) {\n try {\n const localStorage = createScopedLocalStorage({ apiKey: config.apiKey });\n const baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;\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 = (await getCookieValue(BEAM_CART_COOKIE_NAME)) ?? null;\n // Remote session ID (ie, device ID from an A/B testing tool) will be linked to the cart\n const remoteSessionId: string | undefined = getRemoteSession(config) ?? undefined;\n\n const {\n cartId,\n subtotal,\n itemCount,\n currencyCode,\n content: { items = [] } = {},\n schema = { source: \"generic\" },\n } = cartValues;\n\n const cartWithDefaults = {\n cartId,\n subtotal,\n itemCount,\n currencyCode,\n content: { items },\n schema,\n beamCartId,\n };\n\n // Early return conditions. Skip sending cart to Beam if any apply:\n // 1. The cart has not changed\n // 2. Cart is empty, unless the cart was not empty before\n if (\n isEqual(cartWithDefaults, {\n ...cachedCart,\n cartId: cachedCart?.cartId /* make sure optional key is defined even if empty */,\n }) || // cart has not\n // changed, OR\n (cartValues.itemCount === 0 && // nothing in current cart, AND\n (!beamCartId || cachedCart?.itemCount === 0)) // no/expired prev cart or prev cart was empty\n ) {\n return;\n }\n\n const response = await postCart({\n baseUrl,\n headers: {\n authorization: `Api-Key ${config.apiKey}`,\n },\n requestBody: {\n beamCartId, // backwards compat: explicitly sending null here is required to get initial beamCartId\n storeId: config.storeId,\n remoteSessionId,\n cartId,\n subtotal,\n itemCount,\n currencyCode,\n },\n });\n\n // Response will contain a new beamCartId if one was not provided, or old one expired\n const { beamCartId: newBeamCartId, expiresAt, beamCartCreated } = response;\n\n if (newBeamCartId && expiresAt) {\n await setCookieValue({\n name: BEAM_CART_COOKIE_NAME,\n domain: config.domain,\n value: newBeamCartId,\n path: \"/\",\n // If we don't set an expiration, the cookie will be cleared when the tab is closed\n expires: new Date(expiresAt).getTime(),\n });\n }\n\n localStorage.setItemJson(\"cart\", {\n ...cartWithDefaults,\n beamCartId: newBeamCartId,\n });\n\n const eventDetail = {\n schema: schema as any, // TS union type can't figure out what variant applies here\n content: {\n items: items as any,\n },\n subtotal,\n itemCount,\n currencyCode,\n cartId,\n };\n\n // emit change event on any create/update/delete of cart items\n window.dispatchEvent(new BeamCartChangeEvent(eventDetail));\n\n // emit created event only when the cart is new according to Beam\n if (beamCartCreated) {\n window.dispatchEvent(new BeamCartCreatedEvent(eventDetail));\n }\n } catch (err) {\n throw new BeamError(\"Could not update cart in Beam\", { cause: err });\n }\n }),\n UPDATE_CART_DEBOUNCE_MS,\n { leading: true } // handle first call immediately but delay for more calls within debounce window\n);\n\nexport { updateCart };\n"],"names":["UPDATE_CART_DEBOUNCE_MS","updateCart","debounce","memoizeLast","config","cartValues","localStorage","createScopedLocalStorage","baseUrl","DEFAULT_BASE_URL","cachedCart","beamCartId","getCookieValue","BEAM_CART_COOKIE_NAME","remoteSessionId","getRemoteSession","cartId","subtotal","itemCount","currencyCode","items","schema","cartWithDefaults","isEqual","response","postCart","newBeamCartId","expiresAt","beamCartCreated","setCookieValue","eventDetail","BeamCartChangeEvent","BeamCartCreatedEvent","err","BeamError"],"mappings":"+jBA4BA,MAAMA,EAA0B,GAU1BC,EAAaC,EACjBC,EAAY,eAA0BC,EAA2BC,EAA4B,CAC3F,GAAI,CACF,MAAMC,EAAeC,EAAyB,CAAE,OAAQH,EAAO,MAAO,CAAC,EACjEI,EAAUJ,EAAO,SAAWK,EAG5BC,EAA2CJ,EAAa,YAAY,MAAM,EAG1EK,EAA6B,MAAMC,EAAeC,CAAqB,GAAM,KAE7EC,EAAsCC,EAAiBX,CAAM,GAAK,OAElE,CACJ,OAAAY,EACA,SAAAC,EACA,UAAAC,EACA,aAAAC,EACA,QAAS,CAAE,MAAAC,EAAQ,CAAA,CAAG,EAAI,CAAC,EAC3B,OAAAC,EAAS,CAAE,OAAQ,SAAU,CAC/B,EAAIhB,EAEEiB,EAAmB,CACvB,OAAAN,EACA,SAAAC,EACA,UAAAC,EACA,aAAAC,EACA,QAAS,CAAE,MAAAC,CAAM,EACjB,OAAAC,EACA,WAAAV,CACF,EAKA,GACEY,EAAQD,EAAkB,CACxB,GAAGZ,EACH,OAAQA,GAAY,MACtB,CAAC,GAEAL,EAAW,YAAc,IACvB,CAACM,GAAcD,GAAY,YAAc,GAE5C,OAGF,MAAMc,EAAW,MAAMC,EAAS,CAC9B,QAAAjB,EACA,QAAS,CACP,cAAe,WAAWJ,EAAO,MAAM,EACzC,EACA,YAAa,CACX,WAAAO,EACA,QAASP,EAAO,QAChB,gBAAAU,EACA,OAAAE,EACA,SAAAC,EACA,UAAAC,EACA,aAAAC,CACF,CACF,CAAC,EAGK,CAAE,WAAYO,EAAe,UAAAC,EAAW,gBAAAC,CAAgB,EAAIJ,EAE9DE,GAAiBC,GACnB,MAAME,EAAe,CACnB,KAAMhB,EACN,OAAQT,EAAO,OACf,MAAOsB,EACP,KAAM,IAEN,QAAS,IAAI,KAAKC,CAAS,EAAE,QAAQ,CACvC,CAAC,EAGHrB,EAAa,YAAY,OAAQ,CAC/B,GAAGgB,EACH,WAAYI,CACd,CAAC,EAED,MAAMI,EAAc,CAClB,OAAQT,EACR,QAAS,CACP,MAAOD,CACT,EACA,SAAAH,EACA,UAAAC,EACA,aAAAC,EACA,OAAAH,CACF,EAGA,OAAO,cAAc,IAAIe,EAAoBD,CAAW,CAAC,EAGrDF,GACF,OAAO,cAAc,IAAII,EAAqBF,CAAW,CAAC,CAE9D,OAASG,EAAK,CACZ,MAAM,IAAIC,EAAU,gCAAiC,CAAE,MAAOD,CAAI,CAAC,CACrE,CACF,CAAC,EACDjC,EACA,CAAE,QAAS,EAAK,CAClB"}
@@ -1,4 +1,4 @@
1
- import{f as x,g,t as I,h as v,y as p,k as b,m as u}from"../chunks/lit-qtGbjGnK.esm.js";import{p as $}from"../chunks/progress-bar-Sn2QspHy.esm.js";import{partnerLogosConfigDefaults as T}from"./beam-partner-logos.esm.js";import{c as k,u as n,d as w,e as S,A,i as c,_ as C,a as m,b as L}from"../chunks/localize-F31ae3j6.esm.js";import{D as z,g as F,W as D,S as M}from"../chunks/routes-b8sncPq8.esm.js";import{_ as U}from"../chunks/loading-template-Av0IUyKF.esm.js";import{B as E}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{c as f}from"../chunks/css-card-grid-7tObtoJx.esm.js";import"../utils/logger.esm.js";const y={en:{fundedTimes:({times:i=0})=>`Funded <b>${i}</b> ${i>1?"times":"time"} so far`,learnMore:()=>"Learn more",seeAll:()=>"See All"},fr:{fundedTimes:({times:i=0})=>`Financ\xE9 <b>${i}</b> fois pour l'instant`,learnMore:()=>"En savoir plus",seeAll:()=>"Voir tout"},de:{fundedTimes:({times:i=0})=>`<b>${i}</b> Mal finanziert`,learnMore:()=>"Mehr erfahren",seeAll:()=>"Alle anzeigen"},es:{fundedTimes:({times:i=0})=>`Financiado <b>${i}</b> ${i>1?"vez":"veces"}`,learnMore:()=>"Saber m\xE1s",seeAll:()=>"Ver Todo"},it:{fundedTimes:({times:i=0})=>`Finanziato <b>${i}</b> ${i>1?"volta":"volte"}`,learnMore:()=>"Scopri di pi\xF9",seeAll:()=>"Vedi Tutto"},pl:{fundedTimes:({times:i=0})=>`Udzielono wsparcia <b>${i}</b> ${i>1?"razy":"raz"}`,learnMore:()=>"Dowiedz si\u0119 wi\u0119cej",seeAll:()=>"Zobacz wszystko"}};var _=Object.defineProperty,P=Object.getOwnPropertyDescriptor,d=(i,a,t,r)=>{for(var o=r>1?void 0:r?P(a,t):a,e=i.length-1,l;e>=0;e--)(l=i[e])&&(o=(r?l(a,t,o):l(o))||o);return r&&o&&_(a,t,o),o};class s extends v{constructor(){super(...arguments),this.baseUrl=z,this.cardStyle="image",this.lang="en",this.debug=!1,this.selectedFilter=null,this.getImpactData=async()=>(S(["apiKey","chainId"],this),F({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},queryParams:{chainId:this.chainId,personalImpactLimit:0,widgetName:D.community_impact,version:"1.0.0",lang:this.configLang}})),this.impactDataController=new A(this,this.getImpactData),this.renderImageCard=a=>p`
1
+ import{f as x,g,t as I,h as v,y as p,k as b,m as u}from"../chunks/lit-qtGbjGnK.esm.js";import{p as $}from"../chunks/progress-bar-Sn2QspHy.esm.js";import{partnerLogosConfigDefaults as T}from"./beam-partner-logos.esm.js";import{c as k,u as n,d as w,e as S,A,i as c,_ as C,a as m,b as L}from"../chunks/localize-F31ae3j6.esm.js";import{D as z,g as F,W as D,S as M}from"../chunks/routes-31m626dW.esm.js";import{_ as U}from"../chunks/loading-template-Av0IUyKF.esm.js";import{B as E}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{c as f}from"../chunks/css-card-grid-7tObtoJx.esm.js";import"../utils/logger.esm.js";const y={en:{fundedTimes:({times:i=0})=>`Funded <b>${i}</b> ${i>1?"times":"time"} so far`,learnMore:()=>"Learn more",seeAll:()=>"See All"},fr:{fundedTimes:({times:i=0})=>`Financ\xE9 <b>${i}</b> fois pour l'instant`,learnMore:()=>"En savoir plus",seeAll:()=>"Voir tout"},de:{fundedTimes:({times:i=0})=>`<b>${i}</b> Mal finanziert`,learnMore:()=>"Mehr erfahren",seeAll:()=>"Alle anzeigen"},es:{fundedTimes:({times:i=0})=>`Financiado <b>${i}</b> ${i>1?"vez":"veces"}`,learnMore:()=>"Saber m\xE1s",seeAll:()=>"Ver Todo"},it:{fundedTimes:({times:i=0})=>`Finanziato <b>${i}</b> ${i>1?"volta":"volte"}`,learnMore:()=>"Scopri di pi\xF9",seeAll:()=>"Vedi Tutto"},pl:{fundedTimes:({times:i=0})=>`Udzielono wsparcia <b>${i}</b> ${i>1?"razy":"raz"}`,learnMore:()=>"Dowiedz si\u0119 wi\u0119cej",seeAll:()=>"Zobacz wszystko"}};var _=Object.defineProperty,P=Object.getOwnPropertyDescriptor,d=(i,a,t,r)=>{for(var o=r>1?void 0:r?P(a,t):a,e=i.length-1,l;e>=0;e--)(l=i[e])&&(o=(r?l(a,t,o):l(o))||o);return r&&o&&_(a,t,o),o};class s extends v{constructor(){super(...arguments),this.baseUrl=z,this.cardStyle="image",this.lang="en",this.debug=!1,this.selectedFilter=null,this.getImpactData=async()=>(S(["apiKey","chainId"],this),F({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},queryParams:{chainId:this.chainId,personalImpactLimit:0,widgetName:D.community_impact,version:"1.0.0",lang:this.configLang}})),this.impactDataController=new A(this,this.getImpactData),this.renderImageCard=a=>p`
2
2
  <div class="image-card" part="nonprofit-card" style="display: flex; flex-direction: column;">
3
3
  <div class="image-card-image-box" style="background-image: url('${a.imageUrl}');">
4
4
  <p class="image-card-cause">${c(this.configLang,a.nonprofit?.cause||"")}</p>
@@ -1,4 +1,4 @@
1
- import{f as x,g,t as I,h as v,y as p,k as b,m as u}from"../chunks/lit-qtGbjGnK.esm.js";import{p as $}from"../chunks/progress-bar-Sn2QspHy.esm.js";import{partnerLogosConfigDefaults as T}from"./beam-partner-logos.js";import{c as k,u as n,d as w,e as S,A,i as c,_ as C,a as m,b as L}from"../chunks/localize-fH8KOrMi.esm.js";import{D as z,g as F,W as D,S as M}from"../chunks/routes-3jKReDai.esm.js";import{_ as U}from"../chunks/loading-template-Av0IUyKF.esm.js";import{B as E}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{c as f}from"../chunks/css-card-grid-7tObtoJx.esm.js";import"../utils/logger.js";const y={en:{fundedTimes:({times:i=0})=>`Funded <b>${i}</b> ${i>1?"times":"time"} so far`,learnMore:()=>"Learn more",seeAll:()=>"See All"},fr:{fundedTimes:({times:i=0})=>`Financ\xE9 <b>${i}</b> fois pour l'instant`,learnMore:()=>"En savoir plus",seeAll:()=>"Voir tout"},de:{fundedTimes:({times:i=0})=>`<b>${i}</b> Mal finanziert`,learnMore:()=>"Mehr erfahren",seeAll:()=>"Alle anzeigen"},es:{fundedTimes:({times:i=0})=>`Financiado <b>${i}</b> ${i>1?"vez":"veces"}`,learnMore:()=>"Saber m\xE1s",seeAll:()=>"Ver Todo"},it:{fundedTimes:({times:i=0})=>`Finanziato <b>${i}</b> ${i>1?"volta":"volte"}`,learnMore:()=>"Scopri di pi\xF9",seeAll:()=>"Vedi Tutto"},pl:{fundedTimes:({times:i=0})=>`Udzielono wsparcia <b>${i}</b> ${i>1?"razy":"raz"}`,learnMore:()=>"Dowiedz si\u0119 wi\u0119cej",seeAll:()=>"Zobacz wszystko"}};var _=Object.defineProperty,P=Object.getOwnPropertyDescriptor,d=(i,a,t,r)=>{for(var o=r>1?void 0:r?P(a,t):a,e=i.length-1,l;e>=0;e--)(l=i[e])&&(o=(r?l(a,t,o):l(o))||o);return r&&o&&_(a,t,o),o};class s extends v{constructor(){super(...arguments),this.baseUrl=z,this.cardStyle="image",this.lang="en",this.debug=!1,this.selectedFilter=null,this.getImpactData=async()=>(S(["apiKey","chainId"],this),F({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},queryParams:{chainId:this.chainId,personalImpactLimit:0,widgetName:D.community_impact,version:"1.0.0",lang:this.configLang}})),this.impactDataController=new A(this,this.getImpactData),this.renderImageCard=a=>p`
1
+ import{f as x,g,t as I,h as v,y as p,k as b,m as u}from"../chunks/lit-qtGbjGnK.esm.js";import{p as $}from"../chunks/progress-bar-Sn2QspHy.esm.js";import{partnerLogosConfigDefaults as T}from"./beam-partner-logos.js";import{c as k,u as n,d as w,e as S,A,i as c,_ as C,a as m,b as L}from"../chunks/localize-fH8KOrMi.esm.js";import{D as z,g as F,W as D,S as M}from"../chunks/routes-sbqL3QFm.esm.js";import{_ as U}from"../chunks/loading-template-Av0IUyKF.esm.js";import{B as E}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{c as f}from"../chunks/css-card-grid-7tObtoJx.esm.js";import"../utils/logger.js";const y={en:{fundedTimes:({times:i=0})=>`Funded <b>${i}</b> ${i>1?"times":"time"} so far`,learnMore:()=>"Learn more",seeAll:()=>"See All"},fr:{fundedTimes:({times:i=0})=>`Financ\xE9 <b>${i}</b> fois pour l'instant`,learnMore:()=>"En savoir plus",seeAll:()=>"Voir tout"},de:{fundedTimes:({times:i=0})=>`<b>${i}</b> Mal finanziert`,learnMore:()=>"Mehr erfahren",seeAll:()=>"Alle anzeigen"},es:{fundedTimes:({times:i=0})=>`Financiado <b>${i}</b> ${i>1?"vez":"veces"}`,learnMore:()=>"Saber m\xE1s",seeAll:()=>"Ver Todo"},it:{fundedTimes:({times:i=0})=>`Finanziato <b>${i}</b> ${i>1?"volta":"volte"}`,learnMore:()=>"Scopri di pi\xF9",seeAll:()=>"Vedi Tutto"},pl:{fundedTimes:({times:i=0})=>`Udzielono wsparcia <b>${i}</b> ${i>1?"razy":"raz"}`,learnMore:()=>"Dowiedz si\u0119 wi\u0119cej",seeAll:()=>"Zobacz wszystko"}};var _=Object.defineProperty,P=Object.getOwnPropertyDescriptor,d=(i,a,t,r)=>{for(var o=r>1?void 0:r?P(a,t):a,e=i.length-1,l;e>=0;e--)(l=i[e])&&(o=(r?l(a,t,o):l(o))||o);return r&&o&&_(a,t,o),o};class s extends v{constructor(){super(...arguments),this.baseUrl=z,this.cardStyle="image",this.lang="en",this.debug=!1,this.selectedFilter=null,this.getImpactData=async()=>(S(["apiKey","chainId"],this),F({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},queryParams:{chainId:this.chainId,personalImpactLimit:0,widgetName:D.community_impact,version:"1.0.0",lang:this.configLang}})),this.impactDataController=new A(this,this.getImpactData),this.renderImageCard=a=>p`
2
2
  <div class="image-card" part="nonprofit-card" style="display: flex; flex-direction: column;">
3
3
  <div class="image-card-image-box" style="background-image: url('${a.imageUrl}');">
4
4
  <p class="image-card-cause">${c(this.configLang,a.nonprofit?.cause||"")}</p>
@@ -1,4 +1,4 @@
1
- import{t as y,h as b,y as u,g as c,f as C,u as I}from"../chunks/lit-qtGbjGnK.esm.js";import{d as x}from"../chunks/lodash-P8OIs-at.esm.js";import{c as T,u as p,d as S,e as E,A as z,_ as f,i as d,a as v,b as B}from"../chunks/localize-F31ae3j6.esm.js";import{D,l as k,S as L}from"../chunks/routes-b8sncPq8.esm.js";import{B as $}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{_ as V}from"../chunks/loading-template-Av0IUyKF.esm.js";import{i as A}from"../chunks/is-all-html-elements-SdSkxirh.esm.js";import"../utils/logger.esm.js";var j=Object.defineProperty,R=Object.getOwnPropertyDescriptor,h=(n,e,t,a)=>{for(var i=a>1?void 0:a?R(e,t):e,o=n.length-1,r;o>=0;o--)(r=n[o])&&(i=(a?r(e,t,i):r(i))||i);return a&&i&&j(e,t,i),i};class m extends b{constructor(){super(...arguments),this.finalValue=0,this.duration=1500,this.counter=0,this.intervalId=0,this.handleCounterAnimateIfInView=e=>{e.some(t=>t.isIntersecting)&&(this.animateCounter(),this.unobserveScrollTarget())},this.animateCounter=()=>{const e=41.666666666666664,t=e/this.duration*this.finalValue;this.intervalId=setInterval(()=>{const a=this.counter+t;if(a>=this.finalValue){this.counter=this.finalValue,clearInterval(this.intervalId);return}else this.counter=a},e)},this.observer=new IntersectionObserver(this.handleCounterAnimateIfInView,{threshold:.1}),this.observeScrollTarget=()=>{const e=this.scrollTargetElement;e&&this.observer.observe(e)},this.unobserveScrollTarget=()=>{const e=this.scrollTargetElement;e&&this.observer.unobserve(e)}}connectedCallback(){super.connectedCallback();const e=window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.duration===0||e?this.counter=this.finalValue:this.observeScrollTarget()}disconnectedCallback(){super.disconnectedCallback(),this.unobserveScrollTarget(),clearInterval(this.intervalId)}get scrollTargetElement(){return this.scrollTarget?document.querySelector(this.scrollTarget):this}render(){return u`${Math.ceil(this.counter).toLocaleString()}`}}h([c({type:Number})],m.prototype,"finalValue",2),h([c({type:Number})],m.prototype,"duration",2),h([c({type:String})],m.prototype,"scrollTarget",2),h([y()],m.prototype,"counter",2),customElements.get("animated-counter")||customElements.define("animated-counter",m);const O=n=>{const e=n instanceof NodeList?Array.from(n):n;if(e.length===0||!A(e))return;const t=e.sort((i,o)=>{const r=getComputedStyle(i).getPropertyValue("width").replace("px",""),g=getComputedStyle(o).getPropertyValue("width").replace("px","");return parseInt(g)-parseInt(r)})[0],a=getComputedStyle(t).getPropertyValue("width");for(const i of e)getComputedStyle(i).getPropertyValue("width")!==a&&(i.style.width=a)},w={en:{cumulativeImpactTitle:()=>"What we've funded",cumulativeImpactDescription:()=>"Here's the impact that our community has made so far in partnership with Beam. Our impact is growing every day\u2014 scroll to check out the goals we're working toward together right now."},fr:{cumulativeImpactTitle:()=>"Ce que nous avons financ\xE9",cumulativeImpactDescription:()=>"Voici l'impact que notre communaut\xE9 a eu jusqu'\xE0 pr\xE9sent en partenariat avec Beam. Notre impact grandit chaque jour : faites d\xE9filer pour d\xE9couvrir les objectifs vers lesquels nous travaillons ensemble en ce moment."},de:{cumulativeImpactTitle:()=>"Was wir finanziert haben",cumulativeImpactDescription:()=>"Hier ist die Wirkung, die unsere Community bisher in Zusammenarbeit mit Beam erzielt hat. Unsere Wirkung w\xE4chst von Tag zu Tag - scrollen Sie, um einen Blick auf die Ziele zu werfen, auf die wir derzeit gemeinsam hinarbeiten."},es:{cumulativeImpactTitle:()=>"Lo que hemos financiado",cumulativeImpactDescription:()=>"Este es el impacto que nuestra comunidad ha tenido hasta ahora en asociaci\xF3n con Beam. Nuestro impacto crece cada d\xEDa; despl\xE1cese para ver los objetivos por los que estamos trabajando juntos en este momento."},it:{cumulativeImpactTitle:()=>"Cosa abbiamo finanziato",cumulativeImpactDescription:()=>"Ecco l'impatto che la nostra comunit\xE0 ha avuto finora in collaborazione con Beam. Il nostro impatto cresce ogni giorno: scorri per scoprire gli obiettivi a cui stiamo lavorando insieme in questo momento."},pl:{cumulativeImpactTitle:()=>"Co sfinansowali\u015Bmy",cumulativeImpactDescription:()=>"Oto wp\u0142yw, jaki nasza spo\u0142eczno\u015B\u0107 wywar\u0142a dotychczas we wsp\xF3\u0142pracy z Beam. Nasz wp\u0142yw ro\u015Bnie z ka\u017Cdym dniem \u2014 przewi\u0144, aby sprawdzi\u0107 cele, nad kt\xF3rymi obecnie wsp\xF3lnie pracujemy."}};var P=Object.defineProperty,q=Object.getOwnPropertyDescriptor,l=(n,e,t,a)=>{for(var i=a>1?void 0:a?q(e,t):e,o=n.length-1,r;o>=0;o--)(r=n[o])&&(i=(a?r(e,t,i):r(i))||i);return a&&i&&P(e,t,i),i};const U=1.5*1e3;class s extends b{constructor(){super(...arguments),this.baseUrl=D,this.lang="en",this.disableAnimation=!1,this.debug=!1,this.getCumulativeImpactData=async()=>(E(["apiKey","chainId"],this),await k({baseUrl:this.baseUrl,pathParams:{chainId:this.chainId},headers:{authorization:`Api-Key ${this.apiKey}`},queryParams:{version:"1.0.0",lang:this.configLang}})),this.cumulativeImpactDataController=new z(this,this.getCumulativeImpactData),this.resizeElements=x(()=>{O(this.impactRowRefs)},50,{maxWait:50,leading:!0})}get configLang(){return L[this.lang]||"en"}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.resizeElements)}async updated(e){const t=["chainId","baseUrl","lang"];for(const a of t)if(e.has(a)){await this.cumulativeImpactDataController.exec();break}this.resizeElements()}render(){const{data:e,error:t,loading:a}=this.cumulativeImpactDataController;return a?V():t?this.debug?f({error:t}):"":e==null?this.debug?f({error:new $("Missing data")}):"":u`
1
+ import{t as y,h as b,y as u,g as c,f as C,u as I}from"../chunks/lit-qtGbjGnK.esm.js";import{d as x}from"../chunks/lodash-P8OIs-at.esm.js";import{c as T,u as p,d as S,e as E,A as z,_ as f,i as d,a as v,b as B}from"../chunks/localize-F31ae3j6.esm.js";import{D,k,S as L}from"../chunks/routes-31m626dW.esm.js";import{B as $}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{_ as V}from"../chunks/loading-template-Av0IUyKF.esm.js";import{i as A}from"../chunks/is-all-html-elements-SdSkxirh.esm.js";import"../utils/logger.esm.js";var j=Object.defineProperty,R=Object.getOwnPropertyDescriptor,h=(n,e,t,a)=>{for(var i=a>1?void 0:a?R(e,t):e,o=n.length-1,r;o>=0;o--)(r=n[o])&&(i=(a?r(e,t,i):r(i))||i);return a&&i&&j(e,t,i),i};class m extends b{constructor(){super(...arguments),this.finalValue=0,this.duration=1500,this.counter=0,this.intervalId=0,this.handleCounterAnimateIfInView=e=>{e.some(t=>t.isIntersecting)&&(this.animateCounter(),this.unobserveScrollTarget())},this.animateCounter=()=>{const e=41.666666666666664,t=e/this.duration*this.finalValue;this.intervalId=setInterval(()=>{const a=this.counter+t;if(a>=this.finalValue){this.counter=this.finalValue,clearInterval(this.intervalId);return}else this.counter=a},e)},this.observer=new IntersectionObserver(this.handleCounterAnimateIfInView,{threshold:.1}),this.observeScrollTarget=()=>{const e=this.scrollTargetElement;e&&this.observer.observe(e)},this.unobserveScrollTarget=()=>{const e=this.scrollTargetElement;e&&this.observer.unobserve(e)}}connectedCallback(){super.connectedCallback();const e=window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.duration===0||e?this.counter=this.finalValue:this.observeScrollTarget()}disconnectedCallback(){super.disconnectedCallback(),this.unobserveScrollTarget(),clearInterval(this.intervalId)}get scrollTargetElement(){return this.scrollTarget?document.querySelector(this.scrollTarget):this}render(){return u`${Math.ceil(this.counter).toLocaleString()}`}}h([c({type:Number})],m.prototype,"finalValue",2),h([c({type:Number})],m.prototype,"duration",2),h([c({type:String})],m.prototype,"scrollTarget",2),h([y()],m.prototype,"counter",2),customElements.get("animated-counter")||customElements.define("animated-counter",m);const O=n=>{const e=n instanceof NodeList?Array.from(n):n;if(e.length===0||!A(e))return;const t=e.sort((i,o)=>{const r=getComputedStyle(i).getPropertyValue("width").replace("px",""),g=getComputedStyle(o).getPropertyValue("width").replace("px","");return parseInt(g)-parseInt(r)})[0],a=getComputedStyle(t).getPropertyValue("width");for(const i of e)getComputedStyle(i).getPropertyValue("width")!==a&&(i.style.width=a)},w={en:{cumulativeImpactTitle:()=>"What we've funded",cumulativeImpactDescription:()=>"Here's the impact that our community has made so far in partnership with Beam. Our impact is growing every day\u2014 scroll to check out the goals we're working toward together right now."},fr:{cumulativeImpactTitle:()=>"Ce que nous avons financ\xE9",cumulativeImpactDescription:()=>"Voici l'impact que notre communaut\xE9 a eu jusqu'\xE0 pr\xE9sent en partenariat avec Beam. Notre impact grandit chaque jour : faites d\xE9filer pour d\xE9couvrir les objectifs vers lesquels nous travaillons ensemble en ce moment."},de:{cumulativeImpactTitle:()=>"Was wir finanziert haben",cumulativeImpactDescription:()=>"Hier ist die Wirkung, die unsere Community bisher in Zusammenarbeit mit Beam erzielt hat. Unsere Wirkung w\xE4chst von Tag zu Tag - scrollen Sie, um einen Blick auf die Ziele zu werfen, auf die wir derzeit gemeinsam hinarbeiten."},es:{cumulativeImpactTitle:()=>"Lo que hemos financiado",cumulativeImpactDescription:()=>"Este es el impacto que nuestra comunidad ha tenido hasta ahora en asociaci\xF3n con Beam. Nuestro impacto crece cada d\xEDa; despl\xE1cese para ver los objetivos por los que estamos trabajando juntos en este momento."},it:{cumulativeImpactTitle:()=>"Cosa abbiamo finanziato",cumulativeImpactDescription:()=>"Ecco l'impatto che la nostra comunit\xE0 ha avuto finora in collaborazione con Beam. Il nostro impatto cresce ogni giorno: scorri per scoprire gli obiettivi a cui stiamo lavorando insieme in questo momento."},pl:{cumulativeImpactTitle:()=>"Co sfinansowali\u015Bmy",cumulativeImpactDescription:()=>"Oto wp\u0142yw, jaki nasza spo\u0142eczno\u015B\u0107 wywar\u0142a dotychczas we wsp\xF3\u0142pracy z Beam. Nasz wp\u0142yw ro\u015Bnie z ka\u017Cdym dniem \u2014 przewi\u0144, aby sprawdzi\u0107 cele, nad kt\xF3rymi obecnie wsp\xF3lnie pracujemy."}};var P=Object.defineProperty,q=Object.getOwnPropertyDescriptor,l=(n,e,t,a)=>{for(var i=a>1?void 0:a?q(e,t):e,o=n.length-1,r;o>=0;o--)(r=n[o])&&(i=(a?r(e,t,i):r(i))||i);return a&&i&&P(e,t,i),i};const U=1.5*1e3;class s extends b{constructor(){super(...arguments),this.baseUrl=D,this.lang="en",this.disableAnimation=!1,this.debug=!1,this.getCumulativeImpactData=async()=>(E(["apiKey","chainId"],this),await k({baseUrl:this.baseUrl,pathParams:{chainId:this.chainId},headers:{authorization:`Api-Key ${this.apiKey}`},queryParams:{version:"1.0.0",lang:this.configLang}})),this.cumulativeImpactDataController=new z(this,this.getCumulativeImpactData),this.resizeElements=x(()=>{O(this.impactRowRefs)},50,{maxWait:50,leading:!0})}get configLang(){return L[this.lang]||"en"}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.resizeElements)}async updated(e){const t=["chainId","baseUrl","lang"];for(const a of t)if(e.has(a)){await this.cumulativeImpactDataController.exec();break}this.resizeElements()}render(){const{data:e,error:t,loading:a}=this.cumulativeImpactDataController;return a?V():t?this.debug?f({error:t}):"":e==null?this.debug?f({error:new $("Missing data")}):"":u`
2
2
  <style>
3
3
  :host {
4
4
  ${this.cssVariables.toCSS()}
@@ -1 +1 @@
1
- {"version":3,"file":"cumulative-impact.esm.js","sources":["../../src/shared/components/animated-counter/index.ts","../../src/shared/sync-element-widths.ts","../../src/components/cumulative-impact/strings.ts","../../src/components/cumulative-impact/index.ts"],"sourcesContent":["import { html, LitElement } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { state } from \"lit/decorators.js\";\n\nexport class AnimatedCounter extends LitElement {\n @property({ type: Number }) finalValue = 0;\n @property({ type: Number }) duration = 1500;\n @property({ type: String }) scrollTarget?: string;\n\n @state() protected counter = 0;\n private intervalId = 0;\n\n connectedCallback() {\n super.connectedCallback();\n const userPrefersReducedMotion = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n if (this.duration === 0 || userPrefersReducedMotion) {\n this.counter = this.finalValue;\n } else {\n this.observeScrollTarget();\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.unobserveScrollTarget();\n clearInterval(this.intervalId);\n }\n\n private handleCounterAnimateIfInView: IntersectionObserverCallback = (entries) => {\n if (entries.some((entry) => entry.isIntersecting)) {\n this.animateCounter();\n this.unobserveScrollTarget();\n }\n };\n\n private animateCounter = () => {\n const ANIMATION_FRAME_RATE = 24;\n const MS_PER_FRAME = 1000 / ANIMATION_FRAME_RATE;\n const INCREMENT_RATE_PER_FRAME = MS_PER_FRAME / this.duration;\n const COUNTER_INCREMENT_PER_FRAME = INCREMENT_RATE_PER_FRAME * this.finalValue;\n\n this.intervalId = setInterval(() => {\n const result = this.counter + COUNTER_INCREMENT_PER_FRAME;\n if (result >= this.finalValue) {\n this.counter = this.finalValue;\n clearInterval(this.intervalId);\n return;\n } else {\n this.counter = result;\n }\n }, MS_PER_FRAME);\n };\n\n private observer = new IntersectionObserver(this.handleCounterAnimateIfInView, {\n threshold: 0.1,\n });\n\n private observeScrollTarget = () => {\n const target = this.scrollTargetElement;\n target && this.observer.observe(target);\n };\n\n private unobserveScrollTarget = () => {\n const target = this.scrollTargetElement;\n target && this.observer.unobserve(target);\n };\n\n get scrollTargetElement(): this | Element | null {\n if (this.scrollTarget) {\n return document.querySelector(this.scrollTarget);\n } else {\n return this;\n }\n }\n\n render() {\n return html`${Math.ceil(this.counter).toLocaleString()}`;\n }\n}\n\ncustomElements.get(\"animated-counter\") || customElements.define(\"animated-counter\", AnimatedCounter);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"animated-counter\": AnimatedCounter;\n }\n}\n","import { isAllHtmlElements } from \"./is-all-html-elements\";\n\n/**\n * Synchronize widths of elements\n * @param {Array<HTMLElement|null>} elements - Elements to synchronize\n */\nexport const syncElementWidths = (elements: Array<HTMLElement | null> | NodeList) => {\n const els = elements instanceof NodeList ? Array.from(elements) : elements;\n\n if (els.length === 0 || !isAllHtmlElements(els)) {\n return;\n }\n\n const widthSource = els.sort((a, b) => {\n const widthA = getComputedStyle(a).getPropertyValue(\"width\").replace(\"px\", \"\");\n const widthB = getComputedStyle(b).getPropertyValue(\"width\").replace(\"px\", \"\");\n return parseInt(widthB) - parseInt(widthA);\n })[0];\n\n const syncedWidth = getComputedStyle(widthSource).getPropertyValue(\"width\");\n\n for (const el of els) {\n if (getComputedStyle(el).getPropertyValue(\"width\") !== syncedWidth) {\n el.style[\"width\"] = syncedWidth;\n }\n }\n};\n","export const strings = {\n en: {\n cumulativeImpactTitle: () => `What we've funded`,\n cumulativeImpactDescription: () =>\n \"Here's the impact that our community has made so far in partnership with Beam. Our impact is growing every day— scroll to check out the goals we're working toward together right now.\",\n },\n fr: {\n cumulativeImpactTitle: () => `Ce que nous avons financé`,\n cumulativeImpactDescription: () =>\n \"Voici l'impact que notre communauté a eu jusqu'à présent en partenariat avec Beam. Notre impact grandit chaque jour : faites défiler pour découvrir les objectifs vers lesquels nous travaillons ensemble en ce moment.\",\n },\n de: {\n cumulativeImpactTitle: () => `Was wir finanziert haben`,\n cumulativeImpactDescription: () =>\n \"Hier ist die Wirkung, die unsere Community bisher in Zusammenarbeit mit Beam erzielt hat. Unsere Wirkung wächst von Tag zu Tag - scrollen Sie, um einen Blick auf die Ziele zu werfen, auf die wir derzeit gemeinsam hinarbeiten.\",\n },\n es: {\n cumulativeImpactTitle: () => `Lo que hemos financiado`,\n cumulativeImpactDescription: () =>\n \"Este es el impacto que nuestra comunidad ha tenido hasta ahora en asociación con Beam. Nuestro impacto crece cada día; desplácese para ver los objetivos por los que estamos trabajando juntos en este momento.\",\n },\n it: {\n cumulativeImpactTitle: () => `Cosa abbiamo finanziato`,\n cumulativeImpactDescription: () =>\n \"Ecco l'impatto che la nostra comunità ha avuto finora in collaborazione con Beam. Il nostro impatto cresce ogni giorno: scorri per scoprire gli obiettivi a cui stiamo lavorando insieme in questo momento.\",\n },\n pl: {\n cumulativeImpactTitle: () => `Co sfinansowaliśmy`,\n cumulativeImpactDescription: () =>\n \"Oto wpływ, jaki nasza społeczność wywarła dotychczas we współpracy z Beam. Nasz wpływ rośnie z każdym dniem — przewiń, aby sprawdzić cele, nad którymi obecnie wspólnie pracujemy.\",\n },\n};\n","import { css, html, LitElement } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { queryAll } from \"lit/decorators/query-all.js\";\nimport debounce from \"lodash-es/debounce\";\nimport \"../../shared/components/animated-counter\";\nimport { cssReset } from \"../../shared/css-reset\";\nimport { defineCustomElement } from \"../../shared/defineCustomElement\";\nimport { _cssVariableMap } from \"../../shared/fragments/css-variable-map\";\nimport { DEFAULT_BASE_URL, SUPPORTED_LANGUAGES } from \"../../api-sdk/constants\";\nimport { TNumericId } from \"../../shared/types\";\nimport { LANGUAGES } from \"../../api-sdk/types\";\nimport { getCumulativeImpact } from \"../../api-sdk/v3/routes\";\nimport { enforceConfig } from \"../../shared/enforce-config\";\nimport { BeamError, MissingConfig } from \"../../utils/beam-errors\";\nimport { AsyncController } from \"../../shared/controllers/async-controller\";\nimport { _errorMessage } from \"../../shared/fragments/error-message-template\";\nimport { _loading } from \"../../shared/fragments/loading-template\";\nimport { syncElementWidths } from \"../../shared/sync-element-widths\";\nimport { localizeUserString } from \"../../shared/localize\";\nimport { defineCustomText, useCustomText } from \"../../shared/fragments/custom-text\";\nimport { strings } from \"./strings\";\n\ntype RequiredConfig = {\n apiKey: string;\n chainId: TNumericId;\n};\n\ntype IAPIV3CumulativeImpact = Awaited<ReturnType<typeof getCumulativeImpact>>;\n\nconst MAX_COUNTER_ANIMATION_DURATION = 1.5 * 1000;\n\nexport class BeamCumulativeImpact extends LitElement {\n static tagName = \"beam-cumulative-impact\";\n\n @property({ type: String }) public apiKey?: RequiredConfig[\"apiKey\"];\n\n @property({ type: Number }) public chainId?: RequiredConfig[\"chainId\"];\n\n @property({ type: String }) public baseUrl = DEFAULT_BASE_URL;\n\n @property({ type: String }) public lang: LANGUAGES = \"en\";\n\n @property({ type: Boolean }) public disableAnimation = false;\n\n @property({ type: Boolean }) public debug = false;\n\n get configLang() {\n return SUPPORTED_LANGUAGES[this.lang] || \"en\";\n }\n\n private getCumulativeImpactData = async () => {\n if (!enforceConfig<RequiredConfig>([\"apiKey\", \"chainId\"], this)) {\n throw new MissingConfig();\n }\n const res = await getCumulativeImpact({\n baseUrl: this.baseUrl,\n pathParams: {\n chainId: this.chainId,\n },\n headers: {\n authorization: `Api-Key ${this.apiKey}`,\n },\n queryParams: {\n version: \"1.0.0\",\n lang: this.configLang,\n },\n });\n\n return res;\n };\n\n private cumulativeImpactDataController = new AsyncController<typeof this.getCumulativeImpactData>(\n this,\n this.getCumulativeImpactData\n );\n\n @queryAll(\".impact-row-value-container\")\n impactRowRefs!: HTMLElement[];\n resizeElements = debounce(\n () => {\n syncElementWidths(this.impactRowRefs);\n },\n 50,\n { maxWait: 50, leading: true }\n );\n\n connectedCallback() {\n super.connectedCallback();\n window.addEventListener(\"resize\", this.resizeElements);\n }\n\n async updated(changedProperties: Map<string, unknown>) {\n // Reload nonprofit list on change of any of these props:\n // Also fires on first load as props go from undefined => value\n const requireNewDataProps = [\"chainId\", \"baseUrl\", \"lang\"];\n for (const prop of requireNewDataProps) {\n if (changedProperties.has(prop)) {\n await this.cumulativeImpactDataController.exec();\n break;\n }\n }\n\n this.resizeElements();\n }\n\n render() {\n const { data, error, loading } = this.cumulativeImpactDataController;\n if (loading) {\n return _loading();\n }\n if (error) {\n if (this.debug) {\n return _errorMessage({ error });\n }\n return \"\";\n }\n if (data == null) {\n if (this.debug) {\n return _errorMessage({ error: new BeamError(\"Missing data\") });\n }\n return \"\";\n }\n\n return html`\n <style>\n :host {\n ${this.cssVariables.toCSS()}\n }\n </style>\n <div style=\"display: flex; flex-direction: column;\" class=\"root\">\n <div\n style=\"margin: 10px 0 0 0;\"\n tabindex=\"-1\"\n class=\"options\"\n part=\"options\"\n aria-labelledby=\"beam-RedeemTransaction-title\"\n >\n ${this.renderCumulativeImpact(data)}\n </div>\n </div>\n `;\n }\n\n private renderCumulativeImpact(data: IAPIV3CumulativeImpact) {\n const rawValues = data.impacts ? data.impacts?.map((impact) => impact.value || 0) : [];\n const maxRawValue = Math.max(...rawValues);\n const durations = rawValues.map(\n (val) => (MAX_COUNTER_ANIMATION_DURATION * Math.log(Math.max(val, 1))) / Math.log(maxRawValue)\n );\n return html`\n <div class=\"main\">\n <div class=\"title\" role=\"heading\">\n ${localizeUserString(this.configLang, data?.config?.web?.title || \"\") ||\n strings[this.configLang].cumulativeImpactTitle()}\n </div>\n <p class=\"description\">\n ${localizeUserString(this.configLang, data?.config?.web?.description || \"\") ||\n strings[this.configLang].cumulativeImpactDescription()}\n </p>\n <div class=\"impact-list\">\n ${data.impacts?.map((impact: any, idx: number) => {\n return this.renderCumulativeImpactRow({ impact, animationDuration: durations[idx] });\n })}\n </div>\n </div>\n `;\n }\n\n private renderCumulativeImpactRow({ impact, animationDuration }: { impact: any; animationDuration: number }) {\n const disableAnimation = this.cumulativeImpactDataController.data?.config?.web.disableAnimation;\n const floatingCounterClass = \"impact-row-value-counter impact-row-value-floating-counter\";\n const duration = disableAnimation ? 0 : animationDuration;\n\n const unitDisplay = localizeUserString(this.configLang, impact.unit || \"\");\n const summaryDisplay = localizeUserString(this.configLang, impact.summary || \"\");\n\n /**\n * because we set the width using JavaScript by forcing all impact-row-value-container elements\n * to match the width of the widest sibling, we use a hidden span with the total preloaded to\n * ensure that impact-row-value-container widths do not change as the animation runs.\n */\n return html`\n <div class=\"impact-row\">\n <div class=\"impact-row-value-container\">\n <span class=\"impact-row-value-counter\" style=\"visibility: hidden;\" aria-hidden=\"true\">\n ${impact.value.toLocaleString()}\n </span>\n <animated-counter\n class=\"${floatingCounterClass}\"\n finalValue=${impact.value}\n duration=${duration}\n ></animated-counter>\n </span>\n </div>\n <div class=\"impact-row-description\">${unitDisplay} ${summaryDisplay}</div>\n </div>\n `;\n }\n\n public get cssVariables() {\n const defaults: Record<string, string> = {\n \"--beam-fontFamily\": \"inherit\",\n \"--beam-fontStyle\": \"inherit\",\n \"--beam-fontSize\": \"16px\",\n \"--beam-lineHeight\": \"1\",\n \"--beam-textColor\": \"inherit\",\n // main\n ...defineCustomText(\"--beam-CumulativeImpact-title\", {\n fontSize: \"32px\",\n }),\n ...defineCustomText(\"--beam-CumulativeImpact-description\", {\n marginTop: \"16px\",\n lineHeight: \"1.3\",\n }),\n \"--beam-CumulativeImpact-impact-list-marginTop\": \"24px\",\n \"--beam-CumulativeImpact-row-marginTop\": \"24px\",\n // row value container\n \"--beam-CumulativeImpact-row-value-container-borderBottomWidth\": \"4px\",\n \"--beam-CumulativeImpact-row-value-container-borderBottomColor\": \"currentColor\",\n \"--beam-CumulativeImpact-row-value-container-paddingTop\": \"0\",\n \"--beam-CumulativeImpact-row-value-container-paddingRight\": \"20px\",\n \"--beam-CumulativeImpact-row-value-container-paddingBottom\": \"4px\",\n \"--beam-CumulativeImpact-row-value-container-paddingLeft\": \"20px\",\n // row value counter\n ...defineCustomText(\"--beam-CumulativeImpact-row-value-counter\", {\n color: \"currentColor\",\n fontSize: \"24px\",\n fontWeight: \"normal\",\n }),\n // row description\n ...defineCustomText(\"--beam-CumulativeImpact-row-description\", {\n color: \"currentColor\",\n fontSize: \"16px\",\n fontWeight: \"normal\",\n lineHeight: \"1.3\",\n }),\n \"--beam-CumulativeImpact-row-description-paddingLeft\": \"24px\",\n \"--beam-CumulativeImpact-row-description-paddingRight\": \"24px\",\n \"--beam-CumulativeImpact-row-description-mobile-marginTop\": \"12px\",\n };\n\n const remoteConfig = this.cumulativeImpactDataController.data?.config?.web?.theme || {};\n\n const config = { ...defaults, ...remoteConfig };\n\n const serializable = Object.create({\n toCSS() {\n return _cssVariableMap(this as Record<string, string>);\n },\n });\n\n return Object.assign(serializable, config);\n }\n\n static styles = [\n cssReset,\n css`\n :host {\n display: block;\n font-family: var(--beam-fontFamily, inherit);\n font-style: var(--beam-fontStyle, inherit);\n font-size: var(--beam-fontSize, inherit);\n color: var(--beam-textColor, inherit);\n background-color: var(--beam-backgroundColor, inherit);\n line-height: var(--beam-lineHeight, 1);\n word-break: normal;\n }\n .main {\n text-align: left;\n }\n .title {\n ${useCustomText(\"--beam-CumulativeImpact-title\")}\n text-align: inherit;\n }\n .description {\n ${useCustomText(\"--beam-CumulativeImpact-description\")}\n text-align: inherit;\n }\n .impact-list {\n display: flex;\n flex-direction: column;\n margin-top: var(--beam-CumulativeImpact-impact-list-marginTop);\n }\n .impact-row {\n display: flex;\n align-items: center;\n margin-top: var(--beam-CumulativeImpact-row-marginTop);\n }\n .impact-row-value-container {\n position: relative;\n border-bottom-width: var(--beam-CumulativeImpact-row-value-container-borderBottomWidth);\n border-bottom-color: var(--beam-CumulativeImpact-row-value-container-borderBottomColor);\n border-bottom-style: solid;\n padding-top: var(--beam-CumulativeImpact-row-value-container-paddingTop);\n padding-right: var(--beam-CumulativeImpact-row-value-container-paddingRight);\n padding-bottom: var(--beam-CumulativeImpact-row-value-container-paddingBottom);\n padding-left: var(--beam-CumulativeImpact-row-value-container-paddingLeft);\n text-align: center;\n flex-shrink: 0;\n }\n .impact-row-value-counter {\n ${useCustomText(\"--beam-CumulativeImpact-row-value-counter\")}\n }\n .impact-row-value-floating-counter {\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n }\n .impact-row-description {\n ${useCustomText(\"--beam-CumulativeImpact-row-description\")}\n padding-left: var(--beam-CumulativeImpact-row-description-paddingLeft);\n padding-right: var(--beam-CumulativeImpact-row-description-paddingRight);\n /* match padding of value of counter for proper centering */\n padding-bottom: var(--beam-CumulativeImpact-row-value-paddingBottom);\n text-align: inherit;\n flex-grow: 1;\n }\n @media (max-width: 500px) {\n .main {\n text-align: center;\n }\n .impact-row {\n flex-direction: column;\n }\n .impact-row-description {\n margin-top: var(--beam-CumulativeImpact-row-description-mobile-marginTop);\n padding-bottom: 0;\n }\n }\n `,\n ];\n}\n\ndefineCustomElement(BeamCumulativeImpact);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"beam-cumulative-impact\": BeamCumulativeImpact;\n }\n}\n"],"names":["AnimatedCounter","LitElement","entries","entry","MS_PER_FRAME","COUNTER_INCREMENT_PER_FRAME","result","target","userPrefersReducedMotion","html","__decorateClass","property","state","syncElementWidths","elements","els","isAllHtmlElements","widthSource","a","b","widthA","widthB","syncedWidth","el","strings","f","h","o","s","m","i","e","r","MAX_COUNTER_ANIMATION_DURATION","BeamCumulativeImpact","DEFAULT_BASE_URL","enforceConfig","getCumulativeImpact","AsyncController","debounce","SUPPORTED_LANGUAGES","changedProperties","requireNewDataProps","prop","data","error","loading","_loading","_errorMessage","BeamError","rawValues","impact","maxRawValue","durations","val","localizeUserString","idx","animationDuration","disableAnimation","floatingCounterClass","duration","unitDisplay","summaryDisplay","defaults","defineCustomText","remoteConfig","config","_cssVariableMap","cssReset","css","useCustomText","queryAll","defineCustomElement"],"mappings":"wtBAIaA,UAAwBC,CAAW,CAAzC,a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BAAAA,CAAAA,EAAAA,EAAA,CAAnCC,EAAS,CAAE,KAAM,OAAQ,CAAC,GAbhBuB,EAayB,UAAA,QAAA,CAAA,EAiCpCxB,EAAA,CADC6D,EAAS,6BAA6B,CAAA,EA7C5BrC,EA8CX,UAAA,gBAAA,CAAA,EAkQFsC,EAAoBtC,CAAoB"}
1
+ {"version":3,"file":"cumulative-impact.esm.js","sources":["../../src/shared/components/animated-counter/index.ts","../../src/shared/sync-element-widths.ts","../../src/components/cumulative-impact/strings.ts","../../src/components/cumulative-impact/index.ts"],"sourcesContent":["import { html, LitElement } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { state } from \"lit/decorators.js\";\n\nexport class AnimatedCounter extends LitElement {\n @property({ type: Number }) finalValue = 0;\n @property({ type: Number }) duration = 1500;\n @property({ type: String }) scrollTarget?: string;\n\n @state() protected counter = 0;\n private intervalId = 0;\n\n connectedCallback() {\n super.connectedCallback();\n const userPrefersReducedMotion = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n if (this.duration === 0 || userPrefersReducedMotion) {\n this.counter = this.finalValue;\n } else {\n this.observeScrollTarget();\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.unobserveScrollTarget();\n clearInterval(this.intervalId);\n }\n\n private handleCounterAnimateIfInView: IntersectionObserverCallback = (entries) => {\n if (entries.some((entry) => entry.isIntersecting)) {\n this.animateCounter();\n this.unobserveScrollTarget();\n }\n };\n\n private animateCounter = () => {\n const ANIMATION_FRAME_RATE = 24;\n const MS_PER_FRAME = 1000 / ANIMATION_FRAME_RATE;\n const INCREMENT_RATE_PER_FRAME = MS_PER_FRAME / this.duration;\n const COUNTER_INCREMENT_PER_FRAME = INCREMENT_RATE_PER_FRAME * this.finalValue;\n\n this.intervalId = setInterval(() => {\n const result = this.counter + COUNTER_INCREMENT_PER_FRAME;\n if (result >= this.finalValue) {\n this.counter = this.finalValue;\n clearInterval(this.intervalId);\n return;\n } else {\n this.counter = result;\n }\n }, MS_PER_FRAME);\n };\n\n private observer = new IntersectionObserver(this.handleCounterAnimateIfInView, {\n threshold: 0.1,\n });\n\n private observeScrollTarget = () => {\n const target = this.scrollTargetElement;\n target && this.observer.observe(target);\n };\n\n private unobserveScrollTarget = () => {\n const target = this.scrollTargetElement;\n target && this.observer.unobserve(target);\n };\n\n get scrollTargetElement(): this | Element | null {\n if (this.scrollTarget) {\n return document.querySelector(this.scrollTarget);\n } else {\n return this;\n }\n }\n\n render() {\n return html`${Math.ceil(this.counter).toLocaleString()}`;\n }\n}\n\ncustomElements.get(\"animated-counter\") || customElements.define(\"animated-counter\", AnimatedCounter);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"animated-counter\": AnimatedCounter;\n }\n}\n","import { isAllHtmlElements } from \"./is-all-html-elements\";\n\n/**\n * Synchronize widths of elements\n * @param {Array<HTMLElement|null>} elements - Elements to synchronize\n */\nexport const syncElementWidths = (elements: Array<HTMLElement | null> | NodeList) => {\n const els = elements instanceof NodeList ? Array.from(elements) : elements;\n\n if (els.length === 0 || !isAllHtmlElements(els)) {\n return;\n }\n\n const widthSource = els.sort((a, b) => {\n const widthA = getComputedStyle(a).getPropertyValue(\"width\").replace(\"px\", \"\");\n const widthB = getComputedStyle(b).getPropertyValue(\"width\").replace(\"px\", \"\");\n return parseInt(widthB) - parseInt(widthA);\n })[0];\n\n const syncedWidth = getComputedStyle(widthSource).getPropertyValue(\"width\");\n\n for (const el of els) {\n if (getComputedStyle(el).getPropertyValue(\"width\") !== syncedWidth) {\n el.style[\"width\"] = syncedWidth;\n }\n }\n};\n","export const strings = {\n en: {\n cumulativeImpactTitle: () => `What we've funded`,\n cumulativeImpactDescription: () =>\n \"Here's the impact that our community has made so far in partnership with Beam. Our impact is growing every day— scroll to check out the goals we're working toward together right now.\",\n },\n fr: {\n cumulativeImpactTitle: () => `Ce que nous avons financé`,\n cumulativeImpactDescription: () =>\n \"Voici l'impact que notre communauté a eu jusqu'à présent en partenariat avec Beam. Notre impact grandit chaque jour : faites défiler pour découvrir les objectifs vers lesquels nous travaillons ensemble en ce moment.\",\n },\n de: {\n cumulativeImpactTitle: () => `Was wir finanziert haben`,\n cumulativeImpactDescription: () =>\n \"Hier ist die Wirkung, die unsere Community bisher in Zusammenarbeit mit Beam erzielt hat. Unsere Wirkung wächst von Tag zu Tag - scrollen Sie, um einen Blick auf die Ziele zu werfen, auf die wir derzeit gemeinsam hinarbeiten.\",\n },\n es: {\n cumulativeImpactTitle: () => `Lo que hemos financiado`,\n cumulativeImpactDescription: () =>\n \"Este es el impacto que nuestra comunidad ha tenido hasta ahora en asociación con Beam. Nuestro impacto crece cada día; desplácese para ver los objetivos por los que estamos trabajando juntos en este momento.\",\n },\n it: {\n cumulativeImpactTitle: () => `Cosa abbiamo finanziato`,\n cumulativeImpactDescription: () =>\n \"Ecco l'impatto che la nostra comunità ha avuto finora in collaborazione con Beam. Il nostro impatto cresce ogni giorno: scorri per scoprire gli obiettivi a cui stiamo lavorando insieme in questo momento.\",\n },\n pl: {\n cumulativeImpactTitle: () => `Co sfinansowaliśmy`,\n cumulativeImpactDescription: () =>\n \"Oto wpływ, jaki nasza społeczność wywarła dotychczas we współpracy z Beam. Nasz wpływ rośnie z każdym dniem — przewiń, aby sprawdzić cele, nad którymi obecnie wspólnie pracujemy.\",\n },\n};\n","import { css, html, LitElement } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { queryAll } from \"lit/decorators/query-all.js\";\nimport debounce from \"lodash-es/debounce\";\nimport \"../../shared/components/animated-counter\";\nimport { cssReset } from \"../../shared/css-reset\";\nimport { defineCustomElement } from \"../../shared/defineCustomElement\";\nimport { _cssVariableMap } from \"../../shared/fragments/css-variable-map\";\nimport { DEFAULT_BASE_URL, SUPPORTED_LANGUAGES } from \"../../api-sdk/constants\";\nimport { TNumericId } from \"../../shared/types\";\nimport { LANGUAGES } from \"../../api-sdk/types\";\nimport { getCumulativeImpact } from \"../../api-sdk/v3/routes\";\nimport { enforceConfig } from \"../../shared/enforce-config\";\nimport { BeamError, MissingConfig } from \"../../utils/beam-errors\";\nimport { AsyncController } from \"../../shared/controllers/async-controller\";\nimport { _errorMessage } from \"../../shared/fragments/error-message-template\";\nimport { _loading } from \"../../shared/fragments/loading-template\";\nimport { syncElementWidths } from \"../../shared/sync-element-widths\";\nimport { localizeUserString } from \"../../shared/localize\";\nimport { defineCustomText, useCustomText } from \"../../shared/fragments/custom-text\";\nimport { strings } from \"./strings\";\n\ntype RequiredConfig = {\n apiKey: string;\n chainId: TNumericId;\n};\n\ntype IAPIV3CumulativeImpact = Awaited<ReturnType<typeof getCumulativeImpact>>;\n\nconst MAX_COUNTER_ANIMATION_DURATION = 1.5 * 1000;\n\nexport class BeamCumulativeImpact extends LitElement {\n static tagName = \"beam-cumulative-impact\";\n\n @property({ type: String }) public apiKey?: RequiredConfig[\"apiKey\"];\n\n @property({ type: Number }) public chainId?: RequiredConfig[\"chainId\"];\n\n @property({ type: String }) public baseUrl = DEFAULT_BASE_URL;\n\n @property({ type: String }) public lang: LANGUAGES = \"en\";\n\n @property({ type: Boolean }) public disableAnimation = false;\n\n @property({ type: Boolean }) public debug = false;\n\n get configLang() {\n return SUPPORTED_LANGUAGES[this.lang] || \"en\";\n }\n\n private getCumulativeImpactData = async () => {\n if (!enforceConfig<RequiredConfig>([\"apiKey\", \"chainId\"], this)) {\n throw new MissingConfig();\n }\n const res = await getCumulativeImpact({\n baseUrl: this.baseUrl,\n pathParams: {\n chainId: this.chainId,\n },\n headers: {\n authorization: `Api-Key ${this.apiKey}`,\n },\n queryParams: {\n version: \"1.0.0\",\n lang: this.configLang,\n },\n });\n\n return res;\n };\n\n private cumulativeImpactDataController = new AsyncController<typeof this.getCumulativeImpactData>(\n this,\n this.getCumulativeImpactData\n );\n\n @queryAll(\".impact-row-value-container\")\n impactRowRefs!: HTMLElement[];\n resizeElements = debounce(\n () => {\n syncElementWidths(this.impactRowRefs);\n },\n 50,\n { maxWait: 50, leading: true }\n );\n\n connectedCallback() {\n super.connectedCallback();\n window.addEventListener(\"resize\", this.resizeElements);\n }\n\n async updated(changedProperties: Map<string, unknown>) {\n // Reload nonprofit list on change of any of these props:\n // Also fires on first load as props go from undefined => value\n const requireNewDataProps = [\"chainId\", \"baseUrl\", \"lang\"];\n for (const prop of requireNewDataProps) {\n if (changedProperties.has(prop)) {\n await this.cumulativeImpactDataController.exec();\n break;\n }\n }\n\n this.resizeElements();\n }\n\n render() {\n const { data, error, loading } = this.cumulativeImpactDataController;\n if (loading) {\n return _loading();\n }\n if (error) {\n if (this.debug) {\n return _errorMessage({ error });\n }\n return \"\";\n }\n if (data == null) {\n if (this.debug) {\n return _errorMessage({ error: new BeamError(\"Missing data\") });\n }\n return \"\";\n }\n\n return html`\n <style>\n :host {\n ${this.cssVariables.toCSS()}\n }\n </style>\n <div style=\"display: flex; flex-direction: column;\" class=\"root\">\n <div\n style=\"margin: 10px 0 0 0;\"\n tabindex=\"-1\"\n class=\"options\"\n part=\"options\"\n aria-labelledby=\"beam-RedeemTransaction-title\"\n >\n ${this.renderCumulativeImpact(data)}\n </div>\n </div>\n `;\n }\n\n private renderCumulativeImpact(data: IAPIV3CumulativeImpact) {\n const rawValues = data.impacts ? data.impacts?.map((impact) => impact.value || 0) : [];\n const maxRawValue = Math.max(...rawValues);\n const durations = rawValues.map(\n (val) => (MAX_COUNTER_ANIMATION_DURATION * Math.log(Math.max(val, 1))) / Math.log(maxRawValue)\n );\n return html`\n <div class=\"main\">\n <div class=\"title\" role=\"heading\">\n ${localizeUserString(this.configLang, data?.config?.web?.title || \"\") ||\n strings[this.configLang].cumulativeImpactTitle()}\n </div>\n <p class=\"description\">\n ${localizeUserString(this.configLang, data?.config?.web?.description || \"\") ||\n strings[this.configLang].cumulativeImpactDescription()}\n </p>\n <div class=\"impact-list\">\n ${data.impacts?.map((impact: any, idx: number) => {\n return this.renderCumulativeImpactRow({ impact, animationDuration: durations[idx] });\n })}\n </div>\n </div>\n `;\n }\n\n private renderCumulativeImpactRow({ impact, animationDuration }: { impact: any; animationDuration: number }) {\n const disableAnimation = this.cumulativeImpactDataController.data?.config?.web.disableAnimation;\n const floatingCounterClass = \"impact-row-value-counter impact-row-value-floating-counter\";\n const duration = disableAnimation ? 0 : animationDuration;\n\n const unitDisplay = localizeUserString(this.configLang, impact.unit || \"\");\n const summaryDisplay = localizeUserString(this.configLang, impact.summary || \"\");\n\n /**\n * because we set the width using JavaScript by forcing all impact-row-value-container elements\n * to match the width of the widest sibling, we use a hidden span with the total preloaded to\n * ensure that impact-row-value-container widths do not change as the animation runs.\n */\n return html`\n <div class=\"impact-row\">\n <div class=\"impact-row-value-container\">\n <span class=\"impact-row-value-counter\" style=\"visibility: hidden;\" aria-hidden=\"true\">\n ${impact.value.toLocaleString()}\n </span>\n <animated-counter\n class=\"${floatingCounterClass}\"\n finalValue=${impact.value}\n duration=${duration}\n ></animated-counter>\n </span>\n </div>\n <div class=\"impact-row-description\">${unitDisplay} ${summaryDisplay}</div>\n </div>\n `;\n }\n\n public get cssVariables() {\n const defaults: Record<string, string> = {\n \"--beam-fontFamily\": \"inherit\",\n \"--beam-fontStyle\": \"inherit\",\n \"--beam-fontSize\": \"16px\",\n \"--beam-lineHeight\": \"1\",\n \"--beam-textColor\": \"inherit\",\n // main\n ...defineCustomText(\"--beam-CumulativeImpact-title\", {\n fontSize: \"32px\",\n }),\n ...defineCustomText(\"--beam-CumulativeImpact-description\", {\n marginTop: \"16px\",\n lineHeight: \"1.3\",\n }),\n \"--beam-CumulativeImpact-impact-list-marginTop\": \"24px\",\n \"--beam-CumulativeImpact-row-marginTop\": \"24px\",\n // row value container\n \"--beam-CumulativeImpact-row-value-container-borderBottomWidth\": \"4px\",\n \"--beam-CumulativeImpact-row-value-container-borderBottomColor\": \"currentColor\",\n \"--beam-CumulativeImpact-row-value-container-paddingTop\": \"0\",\n \"--beam-CumulativeImpact-row-value-container-paddingRight\": \"20px\",\n \"--beam-CumulativeImpact-row-value-container-paddingBottom\": \"4px\",\n \"--beam-CumulativeImpact-row-value-container-paddingLeft\": \"20px\",\n // row value counter\n ...defineCustomText(\"--beam-CumulativeImpact-row-value-counter\", {\n color: \"currentColor\",\n fontSize: \"24px\",\n fontWeight: \"normal\",\n }),\n // row description\n ...defineCustomText(\"--beam-CumulativeImpact-row-description\", {\n color: \"currentColor\",\n fontSize: \"16px\",\n fontWeight: \"normal\",\n lineHeight: \"1.3\",\n }),\n \"--beam-CumulativeImpact-row-description-paddingLeft\": \"24px\",\n \"--beam-CumulativeImpact-row-description-paddingRight\": \"24px\",\n \"--beam-CumulativeImpact-row-description-mobile-marginTop\": \"12px\",\n };\n\n const remoteConfig = this.cumulativeImpactDataController.data?.config?.web?.theme || {};\n\n const config = { ...defaults, ...remoteConfig };\n\n const serializable = Object.create({\n toCSS() {\n return _cssVariableMap(this as Record<string, string>);\n },\n });\n\n return Object.assign(serializable, config);\n }\n\n static styles = [\n cssReset,\n css`\n :host {\n display: block;\n font-family: var(--beam-fontFamily, inherit);\n font-style: var(--beam-fontStyle, inherit);\n font-size: var(--beam-fontSize, inherit);\n color: var(--beam-textColor, inherit);\n background-color: var(--beam-backgroundColor, inherit);\n line-height: var(--beam-lineHeight, 1);\n word-break: normal;\n }\n .main {\n text-align: left;\n }\n .title {\n ${useCustomText(\"--beam-CumulativeImpact-title\")}\n text-align: inherit;\n }\n .description {\n ${useCustomText(\"--beam-CumulativeImpact-description\")}\n text-align: inherit;\n }\n .impact-list {\n display: flex;\n flex-direction: column;\n margin-top: var(--beam-CumulativeImpact-impact-list-marginTop);\n }\n .impact-row {\n display: flex;\n align-items: center;\n margin-top: var(--beam-CumulativeImpact-row-marginTop);\n }\n .impact-row-value-container {\n position: relative;\n border-bottom-width: var(--beam-CumulativeImpact-row-value-container-borderBottomWidth);\n border-bottom-color: var(--beam-CumulativeImpact-row-value-container-borderBottomColor);\n border-bottom-style: solid;\n padding-top: var(--beam-CumulativeImpact-row-value-container-paddingTop);\n padding-right: var(--beam-CumulativeImpact-row-value-container-paddingRight);\n padding-bottom: var(--beam-CumulativeImpact-row-value-container-paddingBottom);\n padding-left: var(--beam-CumulativeImpact-row-value-container-paddingLeft);\n text-align: center;\n flex-shrink: 0;\n }\n .impact-row-value-counter {\n ${useCustomText(\"--beam-CumulativeImpact-row-value-counter\")}\n }\n .impact-row-value-floating-counter {\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n }\n .impact-row-description {\n ${useCustomText(\"--beam-CumulativeImpact-row-description\")}\n padding-left: var(--beam-CumulativeImpact-row-description-paddingLeft);\n padding-right: var(--beam-CumulativeImpact-row-description-paddingRight);\n /* match padding of value of counter for proper centering */\n padding-bottom: var(--beam-CumulativeImpact-row-value-paddingBottom);\n text-align: inherit;\n flex-grow: 1;\n }\n @media (max-width: 500px) {\n .main {\n text-align: center;\n }\n .impact-row {\n flex-direction: column;\n }\n .impact-row-description {\n margin-top: var(--beam-CumulativeImpact-row-description-mobile-marginTop);\n padding-bottom: 0;\n }\n }\n `,\n ];\n}\n\ndefineCustomElement(BeamCumulativeImpact);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"beam-cumulative-impact\": BeamCumulativeImpact;\n }\n}\n"],"names":["AnimatedCounter","LitElement","entries","entry","MS_PER_FRAME","COUNTER_INCREMENT_PER_FRAME","result","target","userPrefersReducedMotion","html","__decorateClass","property","state","syncElementWidths","elements","els","isAllHtmlElements","widthSource","a","b","widthA","widthB","syncedWidth","el","strings","f","h","o","s","m","i","e","r","MAX_COUNTER_ANIMATION_DURATION","BeamCumulativeImpact","DEFAULT_BASE_URL","enforceConfig","getCumulativeImpact","AsyncController","debounce","SUPPORTED_LANGUAGES","changedProperties","requireNewDataProps","prop","data","error","loading","_loading","_errorMessage","BeamError","rawValues","impact","maxRawValue","durations","val","localizeUserString","idx","animationDuration","disableAnimation","floatingCounterClass","duration","unitDisplay","summaryDisplay","defaults","defineCustomText","remoteConfig","config","_cssVariableMap","cssReset","css","useCustomText","queryAll","defineCustomElement"],"mappings":"mtBAIaA,UAAwB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EAWyB,UAEAxB,mBAAAA,CAAAA,EAAAA,EAAA,CAAnCC,EAAS,CAAE,KAAM,OAAQ,CAAC,GAbhBuB,EAayB,UAAA,QAAA,CAAA,EAiCpCxB,EAAA,CADC6D,EAAS,6BAA6B,CAAA,EA7C5BrC,EA8CX,UAAA,gBAAA,CAAA,EAkQFsC,EAAoBtC,CAAoB"}
@@ -1,4 +1,4 @@
1
- import{t as y,h as b,y as u,g as c,f as C,u as I}from"../chunks/lit-qtGbjGnK.esm.js";import{d as x}from"../chunks/lodash-P8OIs-at.esm.js";import{c as T,u as p,d as S,e as E,A as z,_ as f,i as d,a as v,b as B}from"../chunks/localize-fH8KOrMi.esm.js";import{D,l as k,S as L}from"../chunks/routes-3jKReDai.esm.js";import{B as $}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{_ as V}from"../chunks/loading-template-Av0IUyKF.esm.js";import{i as A}from"../chunks/is-all-html-elements-SdSkxirh.esm.js";import"../utils/logger.js";var j=Object.defineProperty,R=Object.getOwnPropertyDescriptor,h=(n,e,t,a)=>{for(var i=a>1?void 0:a?R(e,t):e,o=n.length-1,r;o>=0;o--)(r=n[o])&&(i=(a?r(e,t,i):r(i))||i);return a&&i&&j(e,t,i),i};class m extends b{constructor(){super(...arguments),this.finalValue=0,this.duration=1500,this.counter=0,this.intervalId=0,this.handleCounterAnimateIfInView=e=>{e.some(t=>t.isIntersecting)&&(this.animateCounter(),this.unobserveScrollTarget())},this.animateCounter=()=>{const e=41.666666666666664,t=e/this.duration*this.finalValue;this.intervalId=setInterval(()=>{const a=this.counter+t;if(a>=this.finalValue){this.counter=this.finalValue,clearInterval(this.intervalId);return}else this.counter=a},e)},this.observer=new IntersectionObserver(this.handleCounterAnimateIfInView,{threshold:.1}),this.observeScrollTarget=()=>{const e=this.scrollTargetElement;e&&this.observer.observe(e)},this.unobserveScrollTarget=()=>{const e=this.scrollTargetElement;e&&this.observer.unobserve(e)}}connectedCallback(){super.connectedCallback();const e=window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.duration===0||e?this.counter=this.finalValue:this.observeScrollTarget()}disconnectedCallback(){super.disconnectedCallback(),this.unobserveScrollTarget(),clearInterval(this.intervalId)}get scrollTargetElement(){return this.scrollTarget?document.querySelector(this.scrollTarget):this}render(){return u`${Math.ceil(this.counter).toLocaleString()}`}}h([c({type:Number})],m.prototype,"finalValue",2),h([c({type:Number})],m.prototype,"duration",2),h([c({type:String})],m.prototype,"scrollTarget",2),h([y()],m.prototype,"counter",2),customElements.get("animated-counter")||customElements.define("animated-counter",m);const O=n=>{const e=n instanceof NodeList?Array.from(n):n;if(e.length===0||!A(e))return;const t=e.sort((i,o)=>{const r=getComputedStyle(i).getPropertyValue("width").replace("px",""),g=getComputedStyle(o).getPropertyValue("width").replace("px","");return parseInt(g)-parseInt(r)})[0],a=getComputedStyle(t).getPropertyValue("width");for(const i of e)getComputedStyle(i).getPropertyValue("width")!==a&&(i.style.width=a)},w={en:{cumulativeImpactTitle:()=>"What we've funded",cumulativeImpactDescription:()=>"Here's the impact that our community has made so far in partnership with Beam. Our impact is growing every day\u2014 scroll to check out the goals we're working toward together right now."},fr:{cumulativeImpactTitle:()=>"Ce que nous avons financ\xE9",cumulativeImpactDescription:()=>"Voici l'impact que notre communaut\xE9 a eu jusqu'\xE0 pr\xE9sent en partenariat avec Beam. Notre impact grandit chaque jour : faites d\xE9filer pour d\xE9couvrir les objectifs vers lesquels nous travaillons ensemble en ce moment."},de:{cumulativeImpactTitle:()=>"Was wir finanziert haben",cumulativeImpactDescription:()=>"Hier ist die Wirkung, die unsere Community bisher in Zusammenarbeit mit Beam erzielt hat. Unsere Wirkung w\xE4chst von Tag zu Tag - scrollen Sie, um einen Blick auf die Ziele zu werfen, auf die wir derzeit gemeinsam hinarbeiten."},es:{cumulativeImpactTitle:()=>"Lo que hemos financiado",cumulativeImpactDescription:()=>"Este es el impacto que nuestra comunidad ha tenido hasta ahora en asociaci\xF3n con Beam. Nuestro impacto crece cada d\xEDa; despl\xE1cese para ver los objetivos por los que estamos trabajando juntos en este momento."},it:{cumulativeImpactTitle:()=>"Cosa abbiamo finanziato",cumulativeImpactDescription:()=>"Ecco l'impatto che la nostra comunit\xE0 ha avuto finora in collaborazione con Beam. Il nostro impatto cresce ogni giorno: scorri per scoprire gli obiettivi a cui stiamo lavorando insieme in questo momento."},pl:{cumulativeImpactTitle:()=>"Co sfinansowali\u015Bmy",cumulativeImpactDescription:()=>"Oto wp\u0142yw, jaki nasza spo\u0142eczno\u015B\u0107 wywar\u0142a dotychczas we wsp\xF3\u0142pracy z Beam. Nasz wp\u0142yw ro\u015Bnie z ka\u017Cdym dniem \u2014 przewi\u0144, aby sprawdzi\u0107 cele, nad kt\xF3rymi obecnie wsp\xF3lnie pracujemy."}};var P=Object.defineProperty,q=Object.getOwnPropertyDescriptor,l=(n,e,t,a)=>{for(var i=a>1?void 0:a?q(e,t):e,o=n.length-1,r;o>=0;o--)(r=n[o])&&(i=(a?r(e,t,i):r(i))||i);return a&&i&&P(e,t,i),i};const U=1.5*1e3;class s extends b{constructor(){super(...arguments),this.baseUrl=D,this.lang="en",this.disableAnimation=!1,this.debug=!1,this.getCumulativeImpactData=async()=>(E(["apiKey","chainId"],this),await k({baseUrl:this.baseUrl,pathParams:{chainId:this.chainId},headers:{authorization:`Api-Key ${this.apiKey}`},queryParams:{version:"1.0.0",lang:this.configLang}})),this.cumulativeImpactDataController=new z(this,this.getCumulativeImpactData),this.resizeElements=x(()=>{O(this.impactRowRefs)},50,{maxWait:50,leading:!0})}get configLang(){return L[this.lang]||"en"}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.resizeElements)}async updated(e){const t=["chainId","baseUrl","lang"];for(const a of t)if(e.has(a)){await this.cumulativeImpactDataController.exec();break}this.resizeElements()}render(){const{data:e,error:t,loading:a}=this.cumulativeImpactDataController;return a?V():t?this.debug?f({error:t}):"":e==null?this.debug?f({error:new $("Missing data")}):"":u`
1
+ import{t as y,h as b,y as u,g as c,f as C,u as I}from"../chunks/lit-qtGbjGnK.esm.js";import{d as x}from"../chunks/lodash-P8OIs-at.esm.js";import{c as T,u as p,d as S,e as E,A as z,_ as f,i as d,a as v,b as B}from"../chunks/localize-fH8KOrMi.esm.js";import{D,k,S as L}from"../chunks/routes-sbqL3QFm.esm.js";import{B as $}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{_ as V}from"../chunks/loading-template-Av0IUyKF.esm.js";import{i as A}from"../chunks/is-all-html-elements-SdSkxirh.esm.js";import"../utils/logger.js";var j=Object.defineProperty,R=Object.getOwnPropertyDescriptor,h=(n,e,t,a)=>{for(var i=a>1?void 0:a?R(e,t):e,o=n.length-1,r;o>=0;o--)(r=n[o])&&(i=(a?r(e,t,i):r(i))||i);return a&&i&&j(e,t,i),i};class m extends b{constructor(){super(...arguments),this.finalValue=0,this.duration=1500,this.counter=0,this.intervalId=0,this.handleCounterAnimateIfInView=e=>{e.some(t=>t.isIntersecting)&&(this.animateCounter(),this.unobserveScrollTarget())},this.animateCounter=()=>{const e=41.666666666666664,t=e/this.duration*this.finalValue;this.intervalId=setInterval(()=>{const a=this.counter+t;if(a>=this.finalValue){this.counter=this.finalValue,clearInterval(this.intervalId);return}else this.counter=a},e)},this.observer=new IntersectionObserver(this.handleCounterAnimateIfInView,{threshold:.1}),this.observeScrollTarget=()=>{const e=this.scrollTargetElement;e&&this.observer.observe(e)},this.unobserveScrollTarget=()=>{const e=this.scrollTargetElement;e&&this.observer.unobserve(e)}}connectedCallback(){super.connectedCallback();const e=window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.duration===0||e?this.counter=this.finalValue:this.observeScrollTarget()}disconnectedCallback(){super.disconnectedCallback(),this.unobserveScrollTarget(),clearInterval(this.intervalId)}get scrollTargetElement(){return this.scrollTarget?document.querySelector(this.scrollTarget):this}render(){return u`${Math.ceil(this.counter).toLocaleString()}`}}h([c({type:Number})],m.prototype,"finalValue",2),h([c({type:Number})],m.prototype,"duration",2),h([c({type:String})],m.prototype,"scrollTarget",2),h([y()],m.prototype,"counter",2),customElements.get("animated-counter")||customElements.define("animated-counter",m);const O=n=>{const e=n instanceof NodeList?Array.from(n):n;if(e.length===0||!A(e))return;const t=e.sort((i,o)=>{const r=getComputedStyle(i).getPropertyValue("width").replace("px",""),g=getComputedStyle(o).getPropertyValue("width").replace("px","");return parseInt(g)-parseInt(r)})[0],a=getComputedStyle(t).getPropertyValue("width");for(const i of e)getComputedStyle(i).getPropertyValue("width")!==a&&(i.style.width=a)},w={en:{cumulativeImpactTitle:()=>"What we've funded",cumulativeImpactDescription:()=>"Here's the impact that our community has made so far in partnership with Beam. Our impact is growing every day\u2014 scroll to check out the goals we're working toward together right now."},fr:{cumulativeImpactTitle:()=>"Ce que nous avons financ\xE9",cumulativeImpactDescription:()=>"Voici l'impact que notre communaut\xE9 a eu jusqu'\xE0 pr\xE9sent en partenariat avec Beam. Notre impact grandit chaque jour : faites d\xE9filer pour d\xE9couvrir les objectifs vers lesquels nous travaillons ensemble en ce moment."},de:{cumulativeImpactTitle:()=>"Was wir finanziert haben",cumulativeImpactDescription:()=>"Hier ist die Wirkung, die unsere Community bisher in Zusammenarbeit mit Beam erzielt hat. Unsere Wirkung w\xE4chst von Tag zu Tag - scrollen Sie, um einen Blick auf die Ziele zu werfen, auf die wir derzeit gemeinsam hinarbeiten."},es:{cumulativeImpactTitle:()=>"Lo que hemos financiado",cumulativeImpactDescription:()=>"Este es el impacto que nuestra comunidad ha tenido hasta ahora en asociaci\xF3n con Beam. Nuestro impacto crece cada d\xEDa; despl\xE1cese para ver los objetivos por los que estamos trabajando juntos en este momento."},it:{cumulativeImpactTitle:()=>"Cosa abbiamo finanziato",cumulativeImpactDescription:()=>"Ecco l'impatto che la nostra comunit\xE0 ha avuto finora in collaborazione con Beam. Il nostro impatto cresce ogni giorno: scorri per scoprire gli obiettivi a cui stiamo lavorando insieme in questo momento."},pl:{cumulativeImpactTitle:()=>"Co sfinansowali\u015Bmy",cumulativeImpactDescription:()=>"Oto wp\u0142yw, jaki nasza spo\u0142eczno\u015B\u0107 wywar\u0142a dotychczas we wsp\xF3\u0142pracy z Beam. Nasz wp\u0142yw ro\u015Bnie z ka\u017Cdym dniem \u2014 przewi\u0144, aby sprawdzi\u0107 cele, nad kt\xF3rymi obecnie wsp\xF3lnie pracujemy."}};var P=Object.defineProperty,q=Object.getOwnPropertyDescriptor,l=(n,e,t,a)=>{for(var i=a>1?void 0:a?q(e,t):e,o=n.length-1,r;o>=0;o--)(r=n[o])&&(i=(a?r(e,t,i):r(i))||i);return a&&i&&P(e,t,i),i};const U=1.5*1e3;class s extends b{constructor(){super(...arguments),this.baseUrl=D,this.lang="en",this.disableAnimation=!1,this.debug=!1,this.getCumulativeImpactData=async()=>(E(["apiKey","chainId"],this),await k({baseUrl:this.baseUrl,pathParams:{chainId:this.chainId},headers:{authorization:`Api-Key ${this.apiKey}`},queryParams:{version:"1.0.0",lang:this.configLang}})),this.cumulativeImpactDataController=new z(this,this.getCumulativeImpactData),this.resizeElements=x(()=>{O(this.impactRowRefs)},50,{maxWait:50,leading:!0})}get configLang(){return L[this.lang]||"en"}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.resizeElements)}async updated(e){const t=["chainId","baseUrl","lang"];for(const a of t)if(e.has(a)){await this.cumulativeImpactDataController.exec();break}this.resizeElements()}render(){const{data:e,error:t,loading:a}=this.cumulativeImpactDataController;return a?V():t?this.debug?f({error:t}):"":e==null?this.debug?f({error:new $("Missing data")}):"":u`
2
2
  <style>
3
3
  :host {
4
4
  ${this.cssVariables.toCSS()}
@@ -1 +1 @@
1
- {"version":3,"file":"cumulative-impact.js","sources":["../../src/shared/components/animated-counter/index.ts","../../src/shared/sync-element-widths.ts","../../src/components/cumulative-impact/strings.ts","../../src/components/cumulative-impact/index.ts"],"sourcesContent":["import { html, LitElement } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { state } from \"lit/decorators.js\";\n\nexport class AnimatedCounter extends LitElement {\n @property({ type: Number }) finalValue = 0;\n @property({ type: Number }) duration = 1500;\n @property({ type: String }) scrollTarget?: string;\n\n @state() protected counter = 0;\n private intervalId = 0;\n\n connectedCallback() {\n super.connectedCallback();\n const userPrefersReducedMotion = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n if (this.duration === 0 || userPrefersReducedMotion) {\n this.counter = this.finalValue;\n } else {\n this.observeScrollTarget();\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.unobserveScrollTarget();\n clearInterval(this.intervalId);\n }\n\n private handleCounterAnimateIfInView: IntersectionObserverCallback = (entries) => {\n if (entries.some((entry) => entry.isIntersecting)) {\n this.animateCounter();\n this.unobserveScrollTarget();\n }\n };\n\n private animateCounter = () => {\n const ANIMATION_FRAME_RATE = 24;\n const MS_PER_FRAME = 1000 / ANIMATION_FRAME_RATE;\n const INCREMENT_RATE_PER_FRAME = MS_PER_FRAME / this.duration;\n const COUNTER_INCREMENT_PER_FRAME = INCREMENT_RATE_PER_FRAME * this.finalValue;\n\n this.intervalId = setInterval(() => {\n const result = this.counter + COUNTER_INCREMENT_PER_FRAME;\n if (result >= this.finalValue) {\n this.counter = this.finalValue;\n clearInterval(this.intervalId);\n return;\n } else {\n this.counter = result;\n }\n }, MS_PER_FRAME);\n };\n\n private observer = new IntersectionObserver(this.handleCounterAnimateIfInView, {\n threshold: 0.1,\n });\n\n private observeScrollTarget = () => {\n const target = this.scrollTargetElement;\n target && this.observer.observe(target);\n };\n\n private unobserveScrollTarget = () => {\n const target = this.scrollTargetElement;\n target && this.observer.unobserve(target);\n };\n\n get scrollTargetElement(): this | Element | null {\n if (this.scrollTarget) {\n return document.querySelector(this.scrollTarget);\n } else {\n return this;\n }\n }\n\n render() {\n return html`${Math.ceil(this.counter).toLocaleString()}`;\n }\n}\n\ncustomElements.get(\"animated-counter\") || customElements.define(\"animated-counter\", AnimatedCounter);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"animated-counter\": AnimatedCounter;\n }\n}\n","import { isAllHtmlElements } from \"./is-all-html-elements\";\n\n/**\n * Synchronize widths of elements\n * @param {Array<HTMLElement|null>} elements - Elements to synchronize\n */\nexport const syncElementWidths = (elements: Array<HTMLElement | null> | NodeList) => {\n const els = elements instanceof NodeList ? Array.from(elements) : elements;\n\n if (els.length === 0 || !isAllHtmlElements(els)) {\n return;\n }\n\n const widthSource = els.sort((a, b) => {\n const widthA = getComputedStyle(a).getPropertyValue(\"width\").replace(\"px\", \"\");\n const widthB = getComputedStyle(b).getPropertyValue(\"width\").replace(\"px\", \"\");\n return parseInt(widthB) - parseInt(widthA);\n })[0];\n\n const syncedWidth = getComputedStyle(widthSource).getPropertyValue(\"width\");\n\n for (const el of els) {\n if (getComputedStyle(el).getPropertyValue(\"width\") !== syncedWidth) {\n el.style[\"width\"] = syncedWidth;\n }\n }\n};\n","export const strings = {\n en: {\n cumulativeImpactTitle: () => `What we've funded`,\n cumulativeImpactDescription: () =>\n \"Here's the impact that our community has made so far in partnership with Beam. Our impact is growing every day— scroll to check out the goals we're working toward together right now.\",\n },\n fr: {\n cumulativeImpactTitle: () => `Ce que nous avons financé`,\n cumulativeImpactDescription: () =>\n \"Voici l'impact que notre communauté a eu jusqu'à présent en partenariat avec Beam. Notre impact grandit chaque jour : faites défiler pour découvrir les objectifs vers lesquels nous travaillons ensemble en ce moment.\",\n },\n de: {\n cumulativeImpactTitle: () => `Was wir finanziert haben`,\n cumulativeImpactDescription: () =>\n \"Hier ist die Wirkung, die unsere Community bisher in Zusammenarbeit mit Beam erzielt hat. Unsere Wirkung wächst von Tag zu Tag - scrollen Sie, um einen Blick auf die Ziele zu werfen, auf die wir derzeit gemeinsam hinarbeiten.\",\n },\n es: {\n cumulativeImpactTitle: () => `Lo que hemos financiado`,\n cumulativeImpactDescription: () =>\n \"Este es el impacto que nuestra comunidad ha tenido hasta ahora en asociación con Beam. Nuestro impacto crece cada día; desplácese para ver los objetivos por los que estamos trabajando juntos en este momento.\",\n },\n it: {\n cumulativeImpactTitle: () => `Cosa abbiamo finanziato`,\n cumulativeImpactDescription: () =>\n \"Ecco l'impatto che la nostra comunità ha avuto finora in collaborazione con Beam. Il nostro impatto cresce ogni giorno: scorri per scoprire gli obiettivi a cui stiamo lavorando insieme in questo momento.\",\n },\n pl: {\n cumulativeImpactTitle: () => `Co sfinansowaliśmy`,\n cumulativeImpactDescription: () =>\n \"Oto wpływ, jaki nasza społeczność wywarła dotychczas we współpracy z Beam. Nasz wpływ rośnie z każdym dniem — przewiń, aby sprawdzić cele, nad którymi obecnie wspólnie pracujemy.\",\n },\n};\n","import { css, html, LitElement } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { queryAll } from \"lit/decorators/query-all.js\";\nimport debounce from \"lodash-es/debounce\";\nimport \"../../shared/components/animated-counter\";\nimport { cssReset } from \"../../shared/css-reset\";\nimport { defineCustomElement } from \"../../shared/defineCustomElement\";\nimport { _cssVariableMap } from \"../../shared/fragments/css-variable-map\";\nimport { DEFAULT_BASE_URL, SUPPORTED_LANGUAGES } from \"../../api-sdk/constants\";\nimport { TNumericId } from \"../../shared/types\";\nimport { LANGUAGES } from \"../../api-sdk/types\";\nimport { getCumulativeImpact } from \"../../api-sdk/v3/routes\";\nimport { enforceConfig } from \"../../shared/enforce-config\";\nimport { BeamError, MissingConfig } from \"../../utils/beam-errors\";\nimport { AsyncController } from \"../../shared/controllers/async-controller\";\nimport { _errorMessage } from \"../../shared/fragments/error-message-template\";\nimport { _loading } from \"../../shared/fragments/loading-template\";\nimport { syncElementWidths } from \"../../shared/sync-element-widths\";\nimport { localizeUserString } from \"../../shared/localize\";\nimport { defineCustomText, useCustomText } from \"../../shared/fragments/custom-text\";\nimport { strings } from \"./strings\";\n\ntype RequiredConfig = {\n apiKey: string;\n chainId: TNumericId;\n};\n\ntype IAPIV3CumulativeImpact = Awaited<ReturnType<typeof getCumulativeImpact>>;\n\nconst MAX_COUNTER_ANIMATION_DURATION = 1.5 * 1000;\n\nexport class BeamCumulativeImpact extends LitElement {\n static tagName = \"beam-cumulative-impact\";\n\n @property({ type: String }) public apiKey?: RequiredConfig[\"apiKey\"];\n\n @property({ type: Number }) public chainId?: RequiredConfig[\"chainId\"];\n\n @property({ type: String }) public baseUrl = DEFAULT_BASE_URL;\n\n @property({ type: String }) public lang: LANGUAGES = \"en\";\n\n @property({ type: Boolean }) public disableAnimation = false;\n\n @property({ type: Boolean }) public debug = false;\n\n get configLang() {\n return SUPPORTED_LANGUAGES[this.lang] || \"en\";\n }\n\n private getCumulativeImpactData = async () => {\n if (!enforceConfig<RequiredConfig>([\"apiKey\", \"chainId\"], this)) {\n throw new MissingConfig();\n }\n const res = await getCumulativeImpact({\n baseUrl: this.baseUrl,\n pathParams: {\n chainId: this.chainId,\n },\n headers: {\n authorization: `Api-Key ${this.apiKey}`,\n },\n queryParams: {\n version: \"1.0.0\",\n lang: this.configLang,\n },\n });\n\n return res;\n };\n\n private cumulativeImpactDataController = new AsyncController<typeof this.getCumulativeImpactData>(\n this,\n this.getCumulativeImpactData\n );\n\n @queryAll(\".impact-row-value-container\")\n impactRowRefs!: HTMLElement[];\n resizeElements = debounce(\n () => {\n syncElementWidths(this.impactRowRefs);\n },\n 50,\n { maxWait: 50, leading: true }\n );\n\n connectedCallback() {\n super.connectedCallback();\n window.addEventListener(\"resize\", this.resizeElements);\n }\n\n async updated(changedProperties: Map<string, unknown>) {\n // Reload nonprofit list on change of any of these props:\n // Also fires on first load as props go from undefined => value\n const requireNewDataProps = [\"chainId\", \"baseUrl\", \"lang\"];\n for (const prop of requireNewDataProps) {\n if (changedProperties.has(prop)) {\n await this.cumulativeImpactDataController.exec();\n break;\n }\n }\n\n this.resizeElements();\n }\n\n render() {\n const { data, error, loading } = this.cumulativeImpactDataController;\n if (loading) {\n return _loading();\n }\n if (error) {\n if (this.debug) {\n return _errorMessage({ error });\n }\n return \"\";\n }\n if (data == null) {\n if (this.debug) {\n return _errorMessage({ error: new BeamError(\"Missing data\") });\n }\n return \"\";\n }\n\n return html`\n <style>\n :host {\n ${this.cssVariables.toCSS()}\n }\n </style>\n <div style=\"display: flex; flex-direction: column;\" class=\"root\">\n <div\n style=\"margin: 10px 0 0 0;\"\n tabindex=\"-1\"\n class=\"options\"\n part=\"options\"\n aria-labelledby=\"beam-RedeemTransaction-title\"\n >\n ${this.renderCumulativeImpact(data)}\n </div>\n </div>\n `;\n }\n\n private renderCumulativeImpact(data: IAPIV3CumulativeImpact) {\n const rawValues = data.impacts ? data.impacts?.map((impact) => impact.value || 0) : [];\n const maxRawValue = Math.max(...rawValues);\n const durations = rawValues.map(\n (val) => (MAX_COUNTER_ANIMATION_DURATION * Math.log(Math.max(val, 1))) / Math.log(maxRawValue)\n );\n return html`\n <div class=\"main\">\n <div class=\"title\" role=\"heading\">\n ${localizeUserString(this.configLang, data?.config?.web?.title || \"\") ||\n strings[this.configLang].cumulativeImpactTitle()}\n </div>\n <p class=\"description\">\n ${localizeUserString(this.configLang, data?.config?.web?.description || \"\") ||\n strings[this.configLang].cumulativeImpactDescription()}\n </p>\n <div class=\"impact-list\">\n ${data.impacts?.map((impact: any, idx: number) => {\n return this.renderCumulativeImpactRow({ impact, animationDuration: durations[idx] });\n })}\n </div>\n </div>\n `;\n }\n\n private renderCumulativeImpactRow({ impact, animationDuration }: { impact: any; animationDuration: number }) {\n const disableAnimation = this.cumulativeImpactDataController.data?.config?.web.disableAnimation;\n const floatingCounterClass = \"impact-row-value-counter impact-row-value-floating-counter\";\n const duration = disableAnimation ? 0 : animationDuration;\n\n const unitDisplay = localizeUserString(this.configLang, impact.unit || \"\");\n const summaryDisplay = localizeUserString(this.configLang, impact.summary || \"\");\n\n /**\n * because we set the width using JavaScript by forcing all impact-row-value-container elements\n * to match the width of the widest sibling, we use a hidden span with the total preloaded to\n * ensure that impact-row-value-container widths do not change as the animation runs.\n */\n return html`\n <div class=\"impact-row\">\n <div class=\"impact-row-value-container\">\n <span class=\"impact-row-value-counter\" style=\"visibility: hidden;\" aria-hidden=\"true\">\n ${impact.value.toLocaleString()}\n </span>\n <animated-counter\n class=\"${floatingCounterClass}\"\n finalValue=${impact.value}\n duration=${duration}\n ></animated-counter>\n </span>\n </div>\n <div class=\"impact-row-description\">${unitDisplay} ${summaryDisplay}</div>\n </div>\n `;\n }\n\n public get cssVariables() {\n const defaults: Record<string, string> = {\n \"--beam-fontFamily\": \"inherit\",\n \"--beam-fontStyle\": \"inherit\",\n \"--beam-fontSize\": \"16px\",\n \"--beam-lineHeight\": \"1\",\n \"--beam-textColor\": \"inherit\",\n // main\n ...defineCustomText(\"--beam-CumulativeImpact-title\", {\n fontSize: \"32px\",\n }),\n ...defineCustomText(\"--beam-CumulativeImpact-description\", {\n marginTop: \"16px\",\n lineHeight: \"1.3\",\n }),\n \"--beam-CumulativeImpact-impact-list-marginTop\": \"24px\",\n \"--beam-CumulativeImpact-row-marginTop\": \"24px\",\n // row value container\n \"--beam-CumulativeImpact-row-value-container-borderBottomWidth\": \"4px\",\n \"--beam-CumulativeImpact-row-value-container-borderBottomColor\": \"currentColor\",\n \"--beam-CumulativeImpact-row-value-container-paddingTop\": \"0\",\n \"--beam-CumulativeImpact-row-value-container-paddingRight\": \"20px\",\n \"--beam-CumulativeImpact-row-value-container-paddingBottom\": \"4px\",\n \"--beam-CumulativeImpact-row-value-container-paddingLeft\": \"20px\",\n // row value counter\n ...defineCustomText(\"--beam-CumulativeImpact-row-value-counter\", {\n color: \"currentColor\",\n fontSize: \"24px\",\n fontWeight: \"normal\",\n }),\n // row description\n ...defineCustomText(\"--beam-CumulativeImpact-row-description\", {\n color: \"currentColor\",\n fontSize: \"16px\",\n fontWeight: \"normal\",\n lineHeight: \"1.3\",\n }),\n \"--beam-CumulativeImpact-row-description-paddingLeft\": \"24px\",\n \"--beam-CumulativeImpact-row-description-paddingRight\": \"24px\",\n \"--beam-CumulativeImpact-row-description-mobile-marginTop\": \"12px\",\n };\n\n const remoteConfig = this.cumulativeImpactDataController.data?.config?.web?.theme || {};\n\n const config = { ...defaults, ...remoteConfig };\n\n const serializable = Object.create({\n toCSS() {\n return _cssVariableMap(this as Record<string, string>);\n },\n });\n\n return Object.assign(serializable, config);\n }\n\n static styles = [\n cssReset,\n css`\n :host {\n display: block;\n font-family: var(--beam-fontFamily, inherit);\n font-style: var(--beam-fontStyle, inherit);\n font-size: var(--beam-fontSize, inherit);\n color: var(--beam-textColor, inherit);\n background-color: var(--beam-backgroundColor, inherit);\n line-height: var(--beam-lineHeight, 1);\n word-break: normal;\n }\n .main {\n text-align: left;\n }\n .title {\n ${useCustomText(\"--beam-CumulativeImpact-title\")}\n text-align: inherit;\n }\n .description {\n ${useCustomText(\"--beam-CumulativeImpact-description\")}\n text-align: inherit;\n }\n .impact-list {\n display: flex;\n flex-direction: column;\n margin-top: var(--beam-CumulativeImpact-impact-list-marginTop);\n }\n .impact-row {\n display: flex;\n align-items: center;\n margin-top: var(--beam-CumulativeImpact-row-marginTop);\n }\n .impact-row-value-container {\n position: relative;\n border-bottom-width: var(--beam-CumulativeImpact-row-value-container-borderBottomWidth);\n border-bottom-color: var(--beam-CumulativeImpact-row-value-container-borderBottomColor);\n border-bottom-style: solid;\n padding-top: var(--beam-CumulativeImpact-row-value-container-paddingTop);\n padding-right: var(--beam-CumulativeImpact-row-value-container-paddingRight);\n padding-bottom: var(--beam-CumulativeImpact-row-value-container-paddingBottom);\n padding-left: var(--beam-CumulativeImpact-row-value-container-paddingLeft);\n text-align: center;\n flex-shrink: 0;\n }\n .impact-row-value-counter {\n ${useCustomText(\"--beam-CumulativeImpact-row-value-counter\")}\n }\n .impact-row-value-floating-counter {\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n }\n .impact-row-description {\n ${useCustomText(\"--beam-CumulativeImpact-row-description\")}\n padding-left: var(--beam-CumulativeImpact-row-description-paddingLeft);\n padding-right: var(--beam-CumulativeImpact-row-description-paddingRight);\n /* match padding of value of counter for proper centering */\n padding-bottom: var(--beam-CumulativeImpact-row-value-paddingBottom);\n text-align: inherit;\n flex-grow: 1;\n }\n @media (max-width: 500px) {\n .main {\n text-align: center;\n }\n .impact-row {\n flex-direction: column;\n }\n .impact-row-description {\n margin-top: var(--beam-CumulativeImpact-row-description-mobile-marginTop);\n padding-bottom: 0;\n }\n }\n `,\n ];\n}\n\ndefineCustomElement(BeamCumulativeImpact);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"beam-cumulative-impact\": BeamCumulativeImpact;\n }\n}\n"],"names":["AnimatedCounter","LitElement","entries","entry","MS_PER_FRAME","COUNTER_INCREMENT_PER_FRAME","result","target","userPrefersReducedMotion","html","__decorateClass","property","state","syncElementWidths","elements","els","isAllHtmlElements","widthSource","a","b","widthA","widthB","syncedWidth","el","strings","f","h","o","s","m","i","e","r","MAX_COUNTER_ANIMATION_DURATION","BeamCumulativeImpact","DEFAULT_BASE_URL","enforceConfig","getCumulativeImpact","AsyncController","debounce","SUPPORTED_LANGUAGES","changedProperties","requireNewDataProps","prop","data","error","loading","_loading","_errorMessage","BeamError","rawValues","impact","maxRawValue","durations","val","localizeUserString","idx","animationDuration","disableAnimation","floatingCounterClass","duration","unitDisplay","summaryDisplay","defaults","defineCustomText","remoteConfig","config","_cssVariableMap","cssReset","css","useCustomText","queryAll","defineCustomElement"],"mappings":"otBAIaA,UAAwBC,CAAW,CAAzC,aAAA,CAAA,MAAA,GAAA,SAAA,EACuB,KAAa,WAAA,EACb,KAAW,SAAA,KAG9B,KAAU,QAAU,EAC7B,KAAQ,WAAa,EAkBrB,KAAQ,6BAA8DC,GAAY,CAC5EA,EAAQ,KAAMC,GAAUA,EAAM,cAAc,IAC9C,KAAK,eAAe,EACpB,KAAK,sBAAA,EAET,EAEA,KAAQ,eAAiB,IAAM,CAE7B,MAAMC,EAAe,mBAEfC,EAD2BD,EAAe,KAAK,SACU,KAAK,WAEpE,KAAK,WAAa,YAAY,IAAM,CAClC,MAAME,EAAS,KAAK,QAAUD,EAC9B,GAAIC,GAAU,KAAK,WAAY,CAC7B,KAAK,QAAU,KAAK,WACpB,cAAc,KAAK,UAAU,EAC7B,MACF,MACE,KAA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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UA0BpDA,EAAc,2CAA2C,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAU1DA,EAAc,yCAAyC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAqBhE,EA1SmC5D,EAAA,CAAlCC,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAHfuB,EAGwB,UAAA,SAAA,CAAA,EAEAxB,EAAA,CAAlCC,EAAS,CAAE,KAAM,MAAO,CAAC,CALf,EAAAuB,EAKwB,UAEAxB,UAAAA,CAAAA,EAAAA,EAAA,CAAlCC,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAPfuB,EAOwB,UAAA,UAAA,CAAA,EAEAxB,EAAA,CAAlCC,EAAS,CAAE,KAAM,MAAO,CAAC,CATf,EAAAuB,EASwB,oBAECxB,EAAA,CAAnCC,EAAS,CAAE,KAAM,OAAQ,CAAC,CAAA,EAXhBuB,EAWyB,UAEAxB,mBAAAA,CAAAA,EAAAA,EAAA,CAAnCC,EAAS,CAAE,KAAM,OAAQ,CAAC,GAbhBuB,EAayB,UAAA,QAAA,CAAA,EAiCpCxB,EAAA,CADC6D,EAAS,6BAA6B,CAAA,EA7C5BrC,EA8CX,UAAA,gBAAA,CAAA,EAkQFsC,EAAoBtC,CAAoB"}
1
+ {"version":3,"file":"cumulative-impact.js","sources":["../../src/shared/components/animated-counter/index.ts","../../src/shared/sync-element-widths.ts","../../src/components/cumulative-impact/strings.ts","../../src/components/cumulative-impact/index.ts"],"sourcesContent":["import { html, LitElement } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { state } from \"lit/decorators.js\";\n\nexport class AnimatedCounter extends LitElement {\n @property({ type: Number }) finalValue = 0;\n @property({ type: Number }) duration = 1500;\n @property({ type: String }) scrollTarget?: string;\n\n @state() protected counter = 0;\n private intervalId = 0;\n\n connectedCallback() {\n super.connectedCallback();\n const userPrefersReducedMotion = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n if (this.duration === 0 || userPrefersReducedMotion) {\n this.counter = this.finalValue;\n } else {\n this.observeScrollTarget();\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.unobserveScrollTarget();\n clearInterval(this.intervalId);\n }\n\n private handleCounterAnimateIfInView: IntersectionObserverCallback = (entries) => {\n if (entries.some((entry) => entry.isIntersecting)) {\n this.animateCounter();\n this.unobserveScrollTarget();\n }\n };\n\n private animateCounter = () => {\n const ANIMATION_FRAME_RATE = 24;\n const MS_PER_FRAME = 1000 / ANIMATION_FRAME_RATE;\n const INCREMENT_RATE_PER_FRAME = MS_PER_FRAME / this.duration;\n const COUNTER_INCREMENT_PER_FRAME = INCREMENT_RATE_PER_FRAME * this.finalValue;\n\n this.intervalId = setInterval(() => {\n const result = this.counter + COUNTER_INCREMENT_PER_FRAME;\n if (result >= this.finalValue) {\n this.counter = this.finalValue;\n clearInterval(this.intervalId);\n return;\n } else {\n this.counter = result;\n }\n }, MS_PER_FRAME);\n };\n\n private observer = new IntersectionObserver(this.handleCounterAnimateIfInView, {\n threshold: 0.1,\n });\n\n private observeScrollTarget = () => {\n const target = this.scrollTargetElement;\n target && this.observer.observe(target);\n };\n\n private unobserveScrollTarget = () => {\n const target = this.scrollTargetElement;\n target && this.observer.unobserve(target);\n };\n\n get scrollTargetElement(): this | Element | null {\n if (this.scrollTarget) {\n return document.querySelector(this.scrollTarget);\n } else {\n return this;\n }\n }\n\n render() {\n return html`${Math.ceil(this.counter).toLocaleString()}`;\n }\n}\n\ncustomElements.get(\"animated-counter\") || customElements.define(\"animated-counter\", AnimatedCounter);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"animated-counter\": AnimatedCounter;\n }\n}\n","import { isAllHtmlElements } from \"./is-all-html-elements\";\n\n/**\n * Synchronize widths of elements\n * @param {Array<HTMLElement|null>} elements - Elements to synchronize\n */\nexport const syncElementWidths = (elements: Array<HTMLElement | null> | NodeList) => {\n const els = elements instanceof NodeList ? Array.from(elements) : elements;\n\n if (els.length === 0 || !isAllHtmlElements(els)) {\n return;\n }\n\n const widthSource = els.sort((a, b) => {\n const widthA = getComputedStyle(a).getPropertyValue(\"width\").replace(\"px\", \"\");\n const widthB = getComputedStyle(b).getPropertyValue(\"width\").replace(\"px\", \"\");\n return parseInt(widthB) - parseInt(widthA);\n })[0];\n\n const syncedWidth = getComputedStyle(widthSource).getPropertyValue(\"width\");\n\n for (const el of els) {\n if (getComputedStyle(el).getPropertyValue(\"width\") !== syncedWidth) {\n el.style[\"width\"] = syncedWidth;\n }\n }\n};\n","export const strings = {\n en: {\n cumulativeImpactTitle: () => `What we've funded`,\n cumulativeImpactDescription: () =>\n \"Here's the impact that our community has made so far in partnership with Beam. Our impact is growing every day— scroll to check out the goals we're working toward together right now.\",\n },\n fr: {\n cumulativeImpactTitle: () => `Ce que nous avons financé`,\n cumulativeImpactDescription: () =>\n \"Voici l'impact que notre communauté a eu jusqu'à présent en partenariat avec Beam. Notre impact grandit chaque jour : faites défiler pour découvrir les objectifs vers lesquels nous travaillons ensemble en ce moment.\",\n },\n de: {\n cumulativeImpactTitle: () => `Was wir finanziert haben`,\n cumulativeImpactDescription: () =>\n \"Hier ist die Wirkung, die unsere Community bisher in Zusammenarbeit mit Beam erzielt hat. Unsere Wirkung wächst von Tag zu Tag - scrollen Sie, um einen Blick auf die Ziele zu werfen, auf die wir derzeit gemeinsam hinarbeiten.\",\n },\n es: {\n cumulativeImpactTitle: () => `Lo que hemos financiado`,\n cumulativeImpactDescription: () =>\n \"Este es el impacto que nuestra comunidad ha tenido hasta ahora en asociación con Beam. Nuestro impacto crece cada día; desplácese para ver los objetivos por los que estamos trabajando juntos en este momento.\",\n },\n it: {\n cumulativeImpactTitle: () => `Cosa abbiamo finanziato`,\n cumulativeImpactDescription: () =>\n \"Ecco l'impatto che la nostra comunità ha avuto finora in collaborazione con Beam. Il nostro impatto cresce ogni giorno: scorri per scoprire gli obiettivi a cui stiamo lavorando insieme in questo momento.\",\n },\n pl: {\n cumulativeImpactTitle: () => `Co sfinansowaliśmy`,\n cumulativeImpactDescription: () =>\n \"Oto wpływ, jaki nasza społeczność wywarła dotychczas we współpracy z Beam. Nasz wpływ rośnie z każdym dniem — przewiń, aby sprawdzić cele, nad którymi obecnie wspólnie pracujemy.\",\n },\n};\n","import { css, html, LitElement } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { queryAll } from \"lit/decorators/query-all.js\";\nimport debounce from \"lodash-es/debounce\";\nimport \"../../shared/components/animated-counter\";\nimport { cssReset } from \"../../shared/css-reset\";\nimport { defineCustomElement } from \"../../shared/defineCustomElement\";\nimport { _cssVariableMap } from \"../../shared/fragments/css-variable-map\";\nimport { DEFAULT_BASE_URL, SUPPORTED_LANGUAGES } from \"../../api-sdk/constants\";\nimport { TNumericId } from \"../../shared/types\";\nimport { LANGUAGES } from \"../../api-sdk/types\";\nimport { getCumulativeImpact } from \"../../api-sdk/v3/routes\";\nimport { enforceConfig } from \"../../shared/enforce-config\";\nimport { BeamError, MissingConfig } from \"../../utils/beam-errors\";\nimport { AsyncController } from \"../../shared/controllers/async-controller\";\nimport { _errorMessage } from \"../../shared/fragments/error-message-template\";\nimport { _loading } from \"../../shared/fragments/loading-template\";\nimport { syncElementWidths } from \"../../shared/sync-element-widths\";\nimport { localizeUserString } from \"../../shared/localize\";\nimport { defineCustomText, useCustomText } from \"../../shared/fragments/custom-text\";\nimport { strings } from \"./strings\";\n\ntype RequiredConfig = {\n apiKey: string;\n chainId: TNumericId;\n};\n\ntype IAPIV3CumulativeImpact = Awaited<ReturnType<typeof getCumulativeImpact>>;\n\nconst MAX_COUNTER_ANIMATION_DURATION = 1.5 * 1000;\n\nexport class BeamCumulativeImpact extends LitElement {\n static tagName = \"beam-cumulative-impact\";\n\n @property({ type: String }) public apiKey?: RequiredConfig[\"apiKey\"];\n\n @property({ type: Number }) public chainId?: RequiredConfig[\"chainId\"];\n\n @property({ type: String }) public baseUrl = DEFAULT_BASE_URL;\n\n @property({ type: String }) public lang: LANGUAGES = \"en\";\n\n @property({ type: Boolean }) public disableAnimation = false;\n\n @property({ type: Boolean }) public debug = false;\n\n get configLang() {\n return SUPPORTED_LANGUAGES[this.lang] || \"en\";\n }\n\n private getCumulativeImpactData = async () => {\n if (!enforceConfig<RequiredConfig>([\"apiKey\", \"chainId\"], this)) {\n throw new MissingConfig();\n }\n const res = await getCumulativeImpact({\n baseUrl: this.baseUrl,\n pathParams: {\n chainId: this.chainId,\n },\n headers: {\n authorization: `Api-Key ${this.apiKey}`,\n },\n queryParams: {\n version: \"1.0.0\",\n lang: this.configLang,\n },\n });\n\n return res;\n };\n\n private cumulativeImpactDataController = new AsyncController<typeof this.getCumulativeImpactData>(\n this,\n this.getCumulativeImpactData\n );\n\n @queryAll(\".impact-row-value-container\")\n impactRowRefs!: HTMLElement[];\n resizeElements = debounce(\n () => {\n syncElementWidths(this.impactRowRefs);\n },\n 50,\n { maxWait: 50, leading: true }\n );\n\n connectedCallback() {\n super.connectedCallback();\n window.addEventListener(\"resize\", this.resizeElements);\n }\n\n async updated(changedProperties: Map<string, unknown>) {\n // Reload nonprofit list on change of any of these props:\n // Also fires on first load as props go from undefined => value\n const requireNewDataProps = [\"chainId\", \"baseUrl\", \"lang\"];\n for (const prop of requireNewDataProps) {\n if (changedProperties.has(prop)) {\n await this.cumulativeImpactDataController.exec();\n break;\n }\n }\n\n this.resizeElements();\n }\n\n render() {\n const { data, error, loading } = this.cumulativeImpactDataController;\n if (loading) {\n return _loading();\n }\n if (error) {\n if (this.debug) {\n return _errorMessage({ error });\n }\n return \"\";\n }\n if (data == null) {\n if (this.debug) {\n return _errorMessage({ error: new BeamError(\"Missing data\") });\n }\n return \"\";\n }\n\n return html`\n <style>\n :host {\n ${this.cssVariables.toCSS()}\n }\n </style>\n <div style=\"display: flex; flex-direction: column;\" class=\"root\">\n <div\n style=\"margin: 10px 0 0 0;\"\n tabindex=\"-1\"\n class=\"options\"\n part=\"options\"\n aria-labelledby=\"beam-RedeemTransaction-title\"\n >\n ${this.renderCumulativeImpact(data)}\n </div>\n </div>\n `;\n }\n\n private renderCumulativeImpact(data: IAPIV3CumulativeImpact) {\n const rawValues = data.impacts ? data.impacts?.map((impact) => impact.value || 0) : [];\n const maxRawValue = Math.max(...rawValues);\n const durations = rawValues.map(\n (val) => (MAX_COUNTER_ANIMATION_DURATION * Math.log(Math.max(val, 1))) / Math.log(maxRawValue)\n );\n return html`\n <div class=\"main\">\n <div class=\"title\" role=\"heading\">\n ${localizeUserString(this.configLang, data?.config?.web?.title || \"\") ||\n strings[this.configLang].cumulativeImpactTitle()}\n </div>\n <p class=\"description\">\n ${localizeUserString(this.configLang, data?.config?.web?.description || \"\") ||\n strings[this.configLang].cumulativeImpactDescription()}\n </p>\n <div class=\"impact-list\">\n ${data.impacts?.map((impact: any, idx: number) => {\n return this.renderCumulativeImpactRow({ impact, animationDuration: durations[idx] });\n })}\n </div>\n </div>\n `;\n }\n\n private renderCumulativeImpactRow({ impact, animationDuration }: { impact: any; animationDuration: number }) {\n const disableAnimation = this.cumulativeImpactDataController.data?.config?.web.disableAnimation;\n const floatingCounterClass = \"impact-row-value-counter impact-row-value-floating-counter\";\n const duration = disableAnimation ? 0 : animationDuration;\n\n const unitDisplay = localizeUserString(this.configLang, impact.unit || \"\");\n const summaryDisplay = localizeUserString(this.configLang, impact.summary || \"\");\n\n /**\n * because we set the width using JavaScript by forcing all impact-row-value-container elements\n * to match the width of the widest sibling, we use a hidden span with the total preloaded to\n * ensure that impact-row-value-container widths do not change as the animation runs.\n */\n return html`\n <div class=\"impact-row\">\n <div class=\"impact-row-value-container\">\n <span class=\"impact-row-value-counter\" style=\"visibility: hidden;\" aria-hidden=\"true\">\n ${impact.value.toLocaleString()}\n </span>\n <animated-counter\n class=\"${floatingCounterClass}\"\n finalValue=${impact.value}\n duration=${duration}\n ></animated-counter>\n </span>\n </div>\n <div class=\"impact-row-description\">${unitDisplay} ${summaryDisplay}</div>\n </div>\n `;\n }\n\n public get cssVariables() {\n const defaults: Record<string, string> = {\n \"--beam-fontFamily\": \"inherit\",\n \"--beam-fontStyle\": \"inherit\",\n \"--beam-fontSize\": \"16px\",\n \"--beam-lineHeight\": \"1\",\n \"--beam-textColor\": \"inherit\",\n // main\n ...defineCustomText(\"--beam-CumulativeImpact-title\", {\n fontSize: \"32px\",\n }),\n ...defineCustomText(\"--beam-CumulativeImpact-description\", {\n marginTop: \"16px\",\n lineHeight: \"1.3\",\n }),\n \"--beam-CumulativeImpact-impact-list-marginTop\": \"24px\",\n \"--beam-CumulativeImpact-row-marginTop\": \"24px\",\n // row value container\n \"--beam-CumulativeImpact-row-value-container-borderBottomWidth\": \"4px\",\n \"--beam-CumulativeImpact-row-value-container-borderBottomColor\": \"currentColor\",\n \"--beam-CumulativeImpact-row-value-container-paddingTop\": \"0\",\n \"--beam-CumulativeImpact-row-value-container-paddingRight\": \"20px\",\n \"--beam-CumulativeImpact-row-value-container-paddingBottom\": \"4px\",\n \"--beam-CumulativeImpact-row-value-container-paddingLeft\": \"20px\",\n // row value counter\n ...defineCustomText(\"--beam-CumulativeImpact-row-value-counter\", {\n color: \"currentColor\",\n fontSize: \"24px\",\n fontWeight: \"normal\",\n }),\n // row description\n ...defineCustomText(\"--beam-CumulativeImpact-row-description\", {\n color: \"currentColor\",\n fontSize: \"16px\",\n fontWeight: \"normal\",\n lineHeight: \"1.3\",\n }),\n \"--beam-CumulativeImpact-row-description-paddingLeft\": \"24px\",\n \"--beam-CumulativeImpact-row-description-paddingRight\": \"24px\",\n \"--beam-CumulativeImpact-row-description-mobile-marginTop\": \"12px\",\n };\n\n const remoteConfig = this.cumulativeImpactDataController.data?.config?.web?.theme || {};\n\n const config = { ...defaults, ...remoteConfig };\n\n const serializable = Object.create({\n toCSS() {\n return _cssVariableMap(this as Record<string, string>);\n },\n });\n\n return Object.assign(serializable, config);\n }\n\n static styles = [\n cssReset,\n css`\n :host {\n display: block;\n font-family: var(--beam-fontFamily, inherit);\n font-style: var(--beam-fontStyle, inherit);\n font-size: var(--beam-fontSize, inherit);\n color: var(--beam-textColor, inherit);\n background-color: var(--beam-backgroundColor, inherit);\n line-height: var(--beam-lineHeight, 1);\n word-break: normal;\n }\n .main {\n text-align: left;\n }\n .title {\n ${useCustomText(\"--beam-CumulativeImpact-title\")}\n text-align: inherit;\n }\n .description {\n ${useCustomText(\"--beam-CumulativeImpact-description\")}\n text-align: inherit;\n }\n .impact-list {\n display: flex;\n flex-direction: column;\n margin-top: var(--beam-CumulativeImpact-impact-list-marginTop);\n }\n .impact-row {\n display: flex;\n align-items: center;\n margin-top: var(--beam-CumulativeImpact-row-marginTop);\n }\n .impact-row-value-container {\n position: relative;\n border-bottom-width: var(--beam-CumulativeImpact-row-value-container-borderBottomWidth);\n border-bottom-color: var(--beam-CumulativeImpact-row-value-container-borderBottomColor);\n border-bottom-style: solid;\n padding-top: var(--beam-CumulativeImpact-row-value-container-paddingTop);\n padding-right: var(--beam-CumulativeImpact-row-value-container-paddingRight);\n padding-bottom: var(--beam-CumulativeImpact-row-value-container-paddingBottom);\n padding-left: var(--beam-CumulativeImpact-row-value-container-paddingLeft);\n text-align: center;\n flex-shrink: 0;\n }\n .impact-row-value-counter {\n ${useCustomText(\"--beam-CumulativeImpact-row-value-counter\")}\n }\n .impact-row-value-floating-counter {\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n }\n .impact-row-description {\n ${useCustomText(\"--beam-CumulativeImpact-row-description\")}\n padding-left: var(--beam-CumulativeImpact-row-description-paddingLeft);\n padding-right: var(--beam-CumulativeImpact-row-description-paddingRight);\n /* match padding of value of counter for proper centering */\n padding-bottom: var(--beam-CumulativeImpact-row-value-paddingBottom);\n text-align: inherit;\n flex-grow: 1;\n }\n @media (max-width: 500px) {\n .main {\n text-align: center;\n }\n .impact-row {\n flex-direction: column;\n }\n .impact-row-description {\n margin-top: var(--beam-CumulativeImpact-row-description-mobile-marginTop);\n padding-bottom: 0;\n }\n }\n `,\n ];\n}\n\ndefineCustomElement(BeamCumulativeImpact);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"beam-cumulative-impact\": BeamCumulativeImpact;\n }\n}\n"],"names":["AnimatedCounter","LitElement","entries","entry","MS_PER_FRAME","COUNTER_INCREMENT_PER_FRAME","result","target","userPrefersReducedMotion","html","__decorateClass","property","state","syncElementWidths","elements","els","isAllHtmlElements","widthSource","a","b","widthA","widthB","syncedWidth","el","strings","f","h","o","s","m","i","e","r","MAX_COUNTER_ANIMATION_DURATION","BeamCumulativeImpact","DEFAULT_BASE_URL","enforceConfig","getCumulativeImpact","AsyncController","debounce","SUPPORTED_LANGUAGES","changedProperties","requireNewDataProps","prop","data","error","loading","_loading","_errorMessage","BeamError","rawValues","impact","maxRawValue","durations","val","localizeUserString","idx","animationDuration","disableAnimation","floatingCounterClass","duration","unitDisplay","summaryDisplay","defaults","defineCustomText","remoteConfig","config","_cssVariableMap","cssReset","css","useCustomText","queryAll","defineCustomElement"],"mappings":"+sBAIaA,UAAwBC,CAAW,CAAzC,aAAA,CAAA,MAAA,GAAA,SAAA,EACuB,KAAa,WAAA,EACb,KAAW,SAAA,KAG9B,KAAU,QAAU,EAC7B,KAAQ,WAAa,EAkBrB,KAAQ,6BAA8DC,GAAY,CAC5EA,EAAQ,KAAMC,GAAUA,EAAM,cAAc,IAC9C,KAAK,eAAe,EACpB,KAAK,sBAAA,EAET,EAEA,KAAQ,eAAiB,IAAM,CAE7B,MAAMC,EAAe,mBAEfC,EAD2BD,EAAe,KAAK,SACU,KAAK,WAEpE,KAAK,WAAa,YAAY,IAAM,CAClC,MAAME,EAAS,KAAK,QAAUD,EAC9B,GAAIC,GAAU,KAAK,WAAY,CAC7B,KAAK,QAAU,KAAK,WACpB,cAAc,KAAK,UAAU,EAC7B,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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UA0BpDA,EAAc,2CAA2C,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAU1DA,EAAc,yCAAyC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAqBhE,EA1SmC5D,EAAA,CAAlCC,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAHfuB,EAGwB,UAAA,SAAA,CAAA,EAEAxB,EAAA,CAAlCC,EAAS,CAAE,KAAM,MAAO,CAAC,CALf,EAAAuB,EAKwB,UAEAxB,UAAAA,CAAAA,EAAAA,EAAA,CAAlCC,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAPfuB,EAOwB,UAAA,UAAA,CAAA,EAEAxB,EAAA,CAAlCC,EAAS,CAAE,KAAM,MAAO,CAAC,CATf,EAAAuB,EASwB,oBAECxB,EAAA,CAAnCC,EAAS,CAAE,KAAM,OAAQ,CAAC,CAAA,EAXhBuB,EAWyB,UAEAxB,mBAAAA,CAAAA,EAAAA,EAAA,CAAnCC,EAAS,CAAE,KAAM,OAAQ,CAAC,GAbhBuB,EAayB,UAAA,QAAA,CAAA,EAiCpCxB,EAAA,CADC6D,EAAS,6BAA6B,CAAA,EA7C5BrC,EA8CX,UAAA,gBAAA,CAAA,EAkQFsC,EAAoBtC,CAAoB"}
@@ -1,4 +1,4 @@
1
- import{f as v,g as d,u as g,h as O,Z as S,y as f,k as $}from"../chunks/lit-qtGbjGnK.esm.js";import{d as T}from"../chunks/lodash-P8OIs-at.esm.js";import{D as k,g as z,W as L,S as N}from"../chunks/routes-b8sncPq8.esm.js";import{B as D}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{p as E}from"../chunks/progress-bar-Sn2QspHy.esm.js";import{c as R,u as s,d as B,e as j,A as U,_ as y,i as u,a as p,b as A}from"../chunks/localize-F31ae3j6.esm.js";import{_ as F}from"../chunks/loading-template-Av0IUyKF.esm.js";import{logger as w}from"../utils/logger.esm.js";import"../chunks/shoelace-components-7XWYNn-Z.esm.js";import{i as W}from"../chunks/is-all-html-elements-SdSkxirh.esm.js";import{partnerLogosConfigDefaults as M}from"./beam-partner-logos.esm.js";import{c as P}from"../chunks/responsive-aWj_7ZN_.esm.js";import"../chunks/vendor-jQ8cxMpw.esm.js";function _(){return/Android|iPhone/i.test(navigator.userAgent)}const I=async e=>fetch(e).then(async a=>{const t=new URL(e),i=await a.blob();return new File([i],t.pathname,{type:i.type})}),x=(e,{source:a="contentLength"}={})=>{const t=e instanceof NodeList?Array.from(e):e;if(t.length===0||!W(t))return;const i=(a==="contentLength"?t.sort((r,c)=>c.innerText.length-r.innerText.length)[0]:t.sort((r,c)=>c.clientHeight-r.clientHeight)[0])?.clientHeight||0;for(const r of t)r.clientHeight!==i&&(r.style.height=i+"px")},o={en:{descriptionTitle:({nonprofitName:e="a nonprofit"})=>`You just made an impact for ${e}`,descriptionSubtitle:({brandName:e=""})=>`Check out the impact your ${e} purchase made below`,learnMore:({name:e=""})=>`Learn more about ${e}`,seeAllImpact:({brandName:e=""})=>`See all of the impact by the ${e} community`,percentRaised:({percent:e=0})=>`${e}%`,yourImpactTitle:()=>"Your Impact",communityImpactTitle:({brandName:e=""})=>`The ${e} Community's Impact`,impactShareButton:()=>"Share to Grow Our Impact",impactShareText:({brandName:e=""})=>`Help ${e} reach their giving goal by sharing this cause on social media`,impactShareTitle:()=>"Share on Social Media",impactShareCopy:()=>"Copy",impactShareDownload:()=>"Download",impactShareClose:()=>"Close"},fr:{descriptionTitle:({nonprofitName:e=""})=>`Vous avez eu un impact positif sur ${e}`,descriptionSubtitle:({brandName:e=""})=>`D\xE9couvrez quel est l'impact de votre achat chez ${e} ci-dessous.`,learnMore:({name:e=""})=>`En savoir plus sur ${e}`,seeAllImpact:({brandName:e=""})=>`Voir toutes les contributions de la communaut\xE9 de ${e}`,percentRaised:({percent:e=0})=>`${e}%`,yourImpactTitle:()=>"Votre contribution personnelle",communityImpactTitle:({brandName:e=""})=>`La contribution de la communaut\xE9 de ${e}`,impactShareButton:()=>"Partagez pour augmentez notre cause",impactShareText:({brandName:e=""})=>`Aidez ${e} a atteindre leur objectif en partageant cette cause sur votre r\xE9seaux sociaux`,impactShareTitle:()=>"Partager sur votre r\xE9seaux sociaux",impactShareCopy:()=>"Copier",impactShareDownload:()=>"T\xE9l\xE9charger",impactShareClose:()=>"Fermer"},de:{descriptionTitle:({nonprofitName:e=""})=>`Du hast soeben einen Beitrag geleistet f\xFCr ${e}`,descriptionSubtitle:({brandName:e=""})=>`Erfahre mehr \xFCber den Beitrag, den du mit deinem ${e} Kauf geleistet hast`,learnMore:({name:e=""})=>`Mehr \xFCber ${e} erfahren`,seeAllImpact:({brandName:e=""})=>`Informiere dich \xFCber den bisher geleisteten Beitrag der ${e} community`,percentRaised:({percent:e=0})=>`${e}%`,yourImpactTitle:()=>"Dein Beitrag",communityImpactTitle:({brandName:e=""})=>`Der Beitrag der ${e} community`,impactShareButton:()=>"Teil, um unserem Beitrag zu erh\xF6hen",impactShareText:({brandName:e=""})=>`Hilf ${e} ihre Spendenziel zu erreichen`,impactShareTitle:()=>"In den sozialen Medien teilen",impactShareCopy:()=>"Kopieren",impactShareDownload:()=>"Herunterladen",impactShareClose:()=>"Schlie\xDFen"},es:{descriptionTitle:({nonprofitName:e=""})=>`Acabas de contribuir con ${e}`,descriptionSubtitle:({brandName:e=""})=>`Comprueba la contribuci\xF3n que has hecho con tu compra ${e} a continuaci\xF3n`,learnMore:({name:e=""})=>`Saber m\xE1s de ${e}`,seeAllImpact:({brandName:e=""})=>`Mira lo que ha conseguido la comunidad ${e}`,percentRaised:({percent:e=0})=>`${e}%`,yourImpactTitle:()=>"Tu contribuci\xF3n",communityImpactTitle:({brandName:e=""})=>`Tu contribuci\xF3n con la comunidad ${e}`,impactShareButton:()=>"Comparte para aumentar nuestro impacto",impactShareText:({brandName:e=""})=>`Comparte en las redes sociales para ayudar a ${e} a alcanzar su objetivo.`,impactShareTitle:()=>"Compartir en redes sociales",impactShareCopy:()=>"Copiar",impactShareDownload:()=>"Descargar",impactShareClose:()=>"Cerrar"},it:{descriptionTitle:({nonprofitName:e=""})=>`Hai appena fatto la differenza per ${e}`,descriptionSubtitle:({brandName:e=""})=>`Guarda qui sotto l'impatto del tuo acquisto ${e}`,learnMore:({name:e=""})=>`Scopri di pi\xF9 su ${e}`,seeAllImpact:({brandName:e=""})=>`Guarda come la comunit\xE0 di ${e} fa la differenza`,percentRaised:({percent:e=0})=>`${e}%`,yourImpactTitle:()=>"Il tuo impatto",communityImpactTitle:({brandName:e=""})=>`L\u2019impatto della comunit\xE0 di ${e} `,impactShareButton:()=>"Condividi, aiutaci a fare la differenza",impactShareText:({brandName:e=""})=>`Aiuta ${e} a raggiungere il suo obiettivo di donazione condividendo questa causa sui social media.`,impactShareTitle:()=>"Condividi, aiutaci a fare la differenza",impactShareCopy:()=>"Copia",impactShareDownload:()=>"Scarica",impactShareClose:()=>"Chiudi"},pl:{descriptionTitle:({nonprofitName:e=""})=>`W\u0142a\u015Bnie wspar\u0142a\u015B_e\u015B ${e}!`,descriptionSubtitle:({brandName:e=""})=>`Sprawd\u017A ni\u017Cej, jakiego wsparcia udzieli\u0142a\u015B_e\u015B kupuj\u0105c w ${e} `,learnMore:({name:e=""})=>`Dowiedz si\u0119 wi\u0119cej o ${e}`,seeAllImpact:({brandName:e=""})=>`Zobacz, ile dobrego zrobi\u0142a do tej pory spo\u0142eczno\u015B\u0107 ${e}`,percentRaised:({percent:e=0})=>`${e}%`,yourImpactTitle:()=>"Twoje wsparcie",communityImpactTitle:({brandName:e=""})=>`Wsparcie udzielone przez spo\u0142eczno\u015B\u0107 ${e}`,impactShareButton:()=>"Udost\u0119pnij, by szerzy\u0107 nasz\u0105 misj\u0119",impactShareText:({brandName:e=""})=>`Pom\xF3\u017C ${e} osi\u0105gn\u0105\u0107 cel i podziel si\u0119 t\u0105 inicjatyw\u0105 na swoim profilu`,impactShareTitle:()=>"Udost\u0119pnij na swoim profilu",impactShareCopy:()=>"Kopiuj",impactShareDownload:()=>"Pobierz",impactShareClose:()=>"Zamknij"}};var q=Object.defineProperty,H=Object.getOwnPropertyDescriptor,m=(e,a,t,i)=>{for(var r=i>1?void 0:i?H(a,t):a,c=e.length-1,l;c>=0;c--)(l=e[c])&&(r=(i?l(a,t,r):l(r))||r);return i&&r&&q(a,t,r),r};class n extends O{constructor(){super(...arguments),this.baseUrl=k,this.lang="en",this.debug=!1,this.getImpactData=async()=>(j(["apiKey","userId","nonprofitId"],this),await z({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},queryParams:{nonprofitId:this.nonprofitId,beamUserId:this.userId,personalImpactLimit:1,communityImpactLimit:1,storeId:this.storeId,widgetName:L.impact_overview,version:"1.0.0",lang:this.configLang}})),this.impactDataController=new U(this,this.getImpactData),this.resizeElements=T(()=>{x(this.impactTitleRefs),x(this.impactDescriptionRefs),x(this.impactLinkRefs)},50,{maxWait:50,leading:!0}),this.handleShareClick=async()=>{try{_()?await this.openSystemShareSheet():await this.openShareDialog()}catch(a){w.error(new D("Error sharing impact")),w.error(a)}},this.openSystemShareSheet=async()=>{const a=this.impactDataController.data?.personal[0]?.share?.imageUrl;if(!a)return;const t=await I(a);navigator.share&&await navigator.share({files:[t]})},this.openShareDialog=async()=>{const a=this.impactDataController.data?.chain.name,t=this.impactDataController.data?.personal[0]?.share?.imageUrl;if(!t)return;const i=this.renderRoot.querySelector("sl-dialog");if(i){i.show();return}await import("../chunks/_share-dialog-dependencies-K7WZWxUL.esm.js");const r=this.renderRoot.querySelector("#modal-root"),c=await I(t),l=URL.createObjectURL(c),h=()=>{this.renderRoot.querySelector("sl-dialog")?.hide()},b=()=>{navigator.clipboard.write([new ClipboardItem({"image/png":c})]).then(()=>{setTimeout(h,250)})},C=()=>{setTimeout(h,250)};S(f`
1
+ import{f as v,g as d,u as g,h as T,Z as k,y as f,k as z}from"../chunks/lit-qtGbjGnK.esm.js";import{d as L}from"../chunks/lodash-P8OIs-at.esm.js";import{l as y,D as N,g as D,W as E,S as R}from"../chunks/routes-31m626dW.esm.js";import{B}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{p as j}from"../chunks/progress-bar-Sn2QspHy.esm.js";import{c as A,u as s,d as U,e as F,A as W,_ as I,i as u,a as m,b as M}from"../chunks/localize-F31ae3j6.esm.js";import{_ as P}from"../chunks/loading-template-Av0IUyKF.esm.js";import{logger as w}from"../utils/logger.esm.js";import{r as _,s as q}from"../chunks/vendor-jQ8cxMpw.esm.js";import{i as H}from"../chunks/is-all-html-elements-SdSkxirh.esm.js";import{partnerLogosConfigDefaults as V}from"./beam-partner-logos.esm.js";import{c as K}from"../chunks/responsive-aWj_7ZN_.esm.js";function G(){return/Android|iPhone/i.test(navigator.userAgent)}const C=async e=>fetch(e).then(async a=>{const t=new URL(e),i=await a.blob();return new File([i],t.pathname,{type:i.type})}),O="https://sdk.beamimpact.com",S=`${O}/lib/shoelace/v${y["@shoelace-style/shoelace"]}`,J=`${O}/lib/lucide-static/v${y["lucide-static"]}`;if(_("lucide",{resolver:e=>`${J}/icons/${e}.svg`}),q(S),document&&!document.querySelector("link[data-beam-impact]")){const e=document.createElement("link");e.href=`${S}/themes/light.css`,e.rel="stylesheet",e.setAttribute("data-beam-impact","true"),document.head.appendChild(e)}const x=(e,{source:a="contentLength"}={})=>{const t=e instanceof NodeList?Array.from(e):e;if(t.length===0||!H(t))return;const i=(a==="contentLength"?t.sort((r,c)=>c.innerText.length-r.innerText.length)[0]:t.sort((r,c)=>c.clientHeight-r.clientHeight)[0])?.clientHeight||0;for(const r of t)r.clientHeight!==i&&(r.style.height=i+"px")},o={en:{descriptionTitle:({nonprofitName:e="a nonprofit"})=>`You just made an impact for ${e}`,descriptionSubtitle:({brandName:e=""})=>`Check out the impact your ${e} purchase made below`,learnMore:({name:e=""})=>`Learn more about ${e}`,seeAllImpact:({brandName:e=""})=>`See all of the impact by the ${e} community`,percentRaised:({percent:e=0})=>`${e}%`,yourImpactTitle:()=>"Your Impact",communityImpactTitle:({brandName:e=""})=>`The ${e} Community's Impact`,impactShareButton:()=>"Share to Grow Our Impact",impactShareText:({brandName:e=""})=>`Help ${e} reach their giving goal by sharing this cause on social media`,impactShareTitle:()=>"Share on Social Media",impactShareCopy:()=>"Copy",impactShareDownload:()=>"Download",impactShareClose:()=>"Close"},fr:{descriptionTitle:({nonprofitName:e=""})=>`Vous avez eu un impact positif sur ${e}`,descriptionSubtitle:({brandName:e=""})=>`D\xE9couvrez quel est l'impact de votre achat chez ${e} ci-dessous.`,learnMore:({name:e=""})=>`En savoir plus sur ${e}`,seeAllImpact:({brandName:e=""})=>`Voir toutes les contributions de la communaut\xE9 de ${e}`,percentRaised:({percent:e=0})=>`${e}%`,yourImpactTitle:()=>"Votre contribution personnelle",communityImpactTitle:({brandName:e=""})=>`La contribution de la communaut\xE9 de ${e}`,impactShareButton:()=>"Partagez pour augmentez notre cause",impactShareText:({brandName:e=""})=>`Aidez ${e} a atteindre leur objectif en partageant cette cause sur votre r\xE9seaux sociaux`,impactShareTitle:()=>"Partager sur votre r\xE9seaux sociaux",impactShareCopy:()=>"Copier",impactShareDownload:()=>"T\xE9l\xE9charger",impactShareClose:()=>"Fermer"},de:{descriptionTitle:({nonprofitName:e=""})=>`Du hast soeben einen Beitrag geleistet f\xFCr ${e}`,descriptionSubtitle:({brandName:e=""})=>`Erfahre mehr \xFCber den Beitrag, den du mit deinem ${e} Kauf geleistet hast`,learnMore:({name:e=""})=>`Mehr \xFCber ${e} erfahren`,seeAllImpact:({brandName:e=""})=>`Informiere dich \xFCber den bisher geleisteten Beitrag der ${e} community`,percentRaised:({percent:e=0})=>`${e}%`,yourImpactTitle:()=>"Dein Beitrag",communityImpactTitle:({brandName:e=""})=>`Der Beitrag der ${e} community`,impactShareButton:()=>"Teil, um unserem Beitrag zu erh\xF6hen",impactShareText:({brandName:e=""})=>`Hilf ${e} ihre Spendenziel zu erreichen`,impactShareTitle:()=>"In den sozialen Medien teilen",impactShareCopy:()=>"Kopieren",impactShareDownload:()=>"Herunterladen",impactShareClose:()=>"Schlie\xDFen"},es:{descriptionTitle:({nonprofitName:e=""})=>`Acabas de contribuir con ${e}`,descriptionSubtitle:({brandName:e=""})=>`Comprueba la contribuci\xF3n que has hecho con tu compra ${e} a continuaci\xF3n`,learnMore:({name:e=""})=>`Saber m\xE1s de ${e}`,seeAllImpact:({brandName:e=""})=>`Mira lo que ha conseguido la comunidad ${e}`,percentRaised:({percent:e=0})=>`${e}%`,yourImpactTitle:()=>"Tu contribuci\xF3n",communityImpactTitle:({brandName:e=""})=>`Tu contribuci\xF3n con la comunidad ${e}`,impactShareButton:()=>"Comparte para aumentar nuestro impacto",impactShareText:({brandName:e=""})=>`Comparte en las redes sociales para ayudar a ${e} a alcanzar su objetivo.`,impactShareTitle:()=>"Compartir en redes sociales",impactShareCopy:()=>"Copiar",impactShareDownload:()=>"Descargar",impactShareClose:()=>"Cerrar"},it:{descriptionTitle:({nonprofitName:e=""})=>`Hai appena fatto la differenza per ${e}`,descriptionSubtitle:({brandName:e=""})=>`Guarda qui sotto l'impatto del tuo acquisto ${e}`,learnMore:({name:e=""})=>`Scopri di pi\xF9 su ${e}`,seeAllImpact:({brandName:e=""})=>`Guarda come la comunit\xE0 di ${e} fa la differenza`,percentRaised:({percent:e=0})=>`${e}%`,yourImpactTitle:()=>"Il tuo impatto",communityImpactTitle:({brandName:e=""})=>`L\u2019impatto della comunit\xE0 di ${e} `,impactShareButton:()=>"Condividi, aiutaci a fare la differenza",impactShareText:({brandName:e=""})=>`Aiuta ${e} a raggiungere il suo obiettivo di donazione condividendo questa causa sui social media.`,impactShareTitle:()=>"Condividi, aiutaci a fare la differenza",impactShareCopy:()=>"Copia",impactShareDownload:()=>"Scarica",impactShareClose:()=>"Chiudi"},pl:{descriptionTitle:({nonprofitName:e=""})=>`W\u0142a\u015Bnie wspar\u0142a\u015B_e\u015B ${e}!`,descriptionSubtitle:({brandName:e=""})=>`Sprawd\u017A ni\u017Cej, jakiego wsparcia udzieli\u0142a\u015B_e\u015B kupuj\u0105c w ${e} `,learnMore:({name:e=""})=>`Dowiedz si\u0119 wi\u0119cej o ${e}`,seeAllImpact:({brandName:e=""})=>`Zobacz, ile dobrego zrobi\u0142a do tej pory spo\u0142eczno\u015B\u0107 ${e}`,percentRaised:({percent:e=0})=>`${e}%`,yourImpactTitle:()=>"Twoje wsparcie",communityImpactTitle:({brandName:e=""})=>`Wsparcie udzielone przez spo\u0142eczno\u015B\u0107 ${e}`,impactShareButton:()=>"Udost\u0119pnij, by szerzy\u0107 nasz\u0105 misj\u0119",impactShareText:({brandName:e=""})=>`Pom\xF3\u017C ${e} osi\u0105gn\u0105\u0107 cel i podziel si\u0119 t\u0105 inicjatyw\u0105 na swoim profilu`,impactShareTitle:()=>"Udost\u0119pnij na swoim profilu",impactShareCopy:()=>"Kopiuj",impactShareDownload:()=>"Pobierz",impactShareClose:()=>"Zamknij"}};var Z=Object.defineProperty,Y=Object.getOwnPropertyDescriptor,p=(e,a,t,i)=>{for(var r=i>1?void 0:i?Y(a,t):a,c=e.length-1,l;c>=0;c--)(l=e[c])&&(r=(i?l(a,t,r):l(r))||r);return i&&r&&Z(a,t,r),r};class n extends T{constructor(){super(...arguments),this.baseUrl=N,this.lang="en",this.debug=!1,this.getImpactData=async()=>(F(["apiKey","userId","nonprofitId"],this),await D({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},queryParams:{nonprofitId:this.nonprofitId,beamUserId:this.userId,personalImpactLimit:1,communityImpactLimit:1,storeId:this.storeId,widgetName:E.impact_overview,version:"1.0.0",lang:this.configLang}})),this.impactDataController=new W(this,this.getImpactData),this.resizeElements=L(()=>{x(this.impactTitleRefs),x(this.impactDescriptionRefs),x(this.impactLinkRefs)},50,{maxWait:50,leading:!0}),this.handleShareClick=async()=>{try{G()?await this.openSystemShareSheet():await this.openShareDialog()}catch(a){w.error(new B("Error sharing impact")),w.error(a)}},this.openSystemShareSheet=async()=>{const a=this.impactDataController.data?.personal[0]?.share?.imageUrl;if(!a)return;const t=await C(a);navigator.share&&await navigator.share({files:[t]})},this.openShareDialog=async()=>{const a=this.impactDataController.data?.chain.name,t=this.impactDataController.data?.personal[0]?.share?.imageUrl;if(!t)return;const i=this.renderRoot.querySelector("sl-dialog");if(i){i.show();return}await import("../chunks/_share-dialog-dependencies-jvbBs-cC.esm.js");const r=this.renderRoot.querySelector("#modal-root"),c=await C(t),l=URL.createObjectURL(c),h=()=>{this.renderRoot.querySelector("sl-dialog")?.hide()},b=()=>{navigator.clipboard.write([new ClipboardItem({"image/png":c})]).then(()=>{setTimeout(h,250)})},$=()=>{setTimeout(h,250)};k(f`
2
2
  <sl-dialog open label="${o[this.configLang].impactShareTitle()}" no-header class="share-dialog">
3
3
  <h2 class="share-title">${o[this.configLang].impactShareTitle()}</h2>
4
4
  <p class="share-text">${o[this.configLang].impactShareText({brandName:a})}</p>
@@ -20,7 +20,7 @@ import{f as v,g as d,u as g,h as O,Z as S,y as f,k as $}from"../chunks/lit-qtGbj
20
20
  class="plain-button button share-action-button plain-link"
21
21
  download="${o[this.configLang].impactShareTitle()}"
22
22
  href="${l}"
23
- @click="${C}"
23
+ @click="${$}"
24
24
  >
25
25
  <sl-icon
26
26
  library="lucide"
@@ -36,7 +36,7 @@ import{f as v,g as d,u as g,h as O,Z as S,y as f,k as $}from"../chunks/lit-qtGbj
36
36
  ${o[this.configLang].impactShareClose()}
37
37
  </button>
38
38
  </sl-dialog>
39
- `,r)}}get configLang(){return N[this.lang]||"en"}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.resizeElements)}async updated(a){const t=["baseUrl","storeId","apiKey","userId","lang"];for(const i of t)if(a.has(i)){await this.impactDataController.exec();break}this.resizeElements(),await this.handleFontLoad(this.resizeElements)}disconnectedCallback(){window.removeEventListener("resize",this.resizeElements),document.fonts.removeEventListener("loadingdone",this.resizeElements),super.disconnectedCallback()}async handleFontLoad(a){if(document.fonts.status==="loading")return await document.fonts.ready.catch(t=>w.error(t)),a()}renderCard({imageUrl:a,title:t,percentFunded:i,description:r}){return f`
39
+ `,r)}}get configLang(){return R[this.lang]||"en"}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.resizeElements)}async updated(a){const t=["baseUrl","storeId","apiKey","userId","lang"];for(const i of t)if(a.has(i)){await this.impactDataController.exec();break}this.resizeElements(),await this.handleFontLoad(this.resizeElements)}disconnectedCallback(){window.removeEventListener("resize",this.resizeElements),document.fonts.removeEventListener("loadingdone",this.resizeElements),super.disconnectedCallback()}async handleFontLoad(a){if(document.fonts.status==="loading")return await document.fonts.ready.catch(t=>w.error(t)),a()}renderCard({imageUrl:a,title:t,percentFunded:i,description:r}){return f`
40
40
  <div class="impact-card" part="impact-card">
41
41
  <img src="${a}" alt="${t}" class="impact-card-image" />
42
42
  <div class="impact-card-content" style="margin: 15px;">
@@ -51,10 +51,10 @@ import{f as v,g as d,u as g,h as O,Z as S,y as f,k as $}from"../chunks/lit-qtGbj
51
51
  >${o[this.configLang].percentRaised({percent:i})}</span
52
52
  >
53
53
  </div>
54
- <p class="impact-card-description">${$(r)}</p>
54
+ <p class="impact-card-description">${z(r)}</p>
55
55
  </div>
56
56
  </div>
57
- `}render(){const{data:a,loading:t,error:i}=this.impactDataController;if(t)return F();if(i)return this.debug?y({error:i}):"";if(a==null)return this.debug?y({error:new Error("No data")}):"";const r=this.cssVariables["--beam-ImpactOverview-share-button-display"]!=="none",c=r&&this.cssVariables["--beam-ImpactOverview-share-button-display-mobile"]!=="none",l=r&&this.cssVariables["--beam-ImpactOverview-share-button-display-desktop"]!=="none",h=this.cssVariables["--beam-ImpactOverview-share-button-icon-name"]||"share-2";let b="d-none";return c?b=l?"d-block":"d-lg-none":b=l?"d-none d-lg-block":"d-none",f`
57
+ `}render(){const{data:a,loading:t,error:i}=this.impactDataController;if(t)return P();if(i)return this.debug?I({error:i}):"";if(a==null)return this.debug?I({error:new Error("No data")}):"";const r=this.cssVariables["--beam-ImpactOverview-share-button-display"]!=="none",c=r&&this.cssVariables["--beam-ImpactOverview-share-button-display-mobile"]!=="none",l=r&&this.cssVariables["--beam-ImpactOverview-share-button-display-desktop"]!=="none",h=this.cssVariables["--beam-ImpactOverview-share-button-icon-name"]||"share-2";let b="d-none";return c?b=l?"d-block":"d-lg-none":b=l?"d-none d-lg-block":"d-none",f`
58
58
  <style>
59
59
  :host {
60
60
  ${this.cssVariables.toCSS()}
@@ -117,7 +117,7 @@ import{f as v,g as d,u as g,h as O,Z as S,y as f,k as $}from"../chunks/lit-qtGbj
117
117
  </div>
118
118
 
119
119
  <div id="modal-root"></div>
120
- `}get cssVariables(){const a={"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit",...M,...E,...p("--beam-ImpactOverview-title",{fontSize:"16px",fontWeight:"bold",marginTop:"10px"}),...p("--beam-ImpactOverview-subtitle",{marginTop:"5px"}),"--beam-ImpactOverview-impactCards-maxWidth":"800px","--beam-ImpactOverview-impactCard-backgroundColor":"inherit","--beam-ImpactOverview-impactCard-foregroundColor":"currentColor","--beam-ImpactOverview-impactCard-borderColor":"currentColor","--beam-ImpactOverview-impactCard-borderRadius":"0px","--beam-ImpactOverview-impactCard-marginTop":"10px",...p("--beam-ImpactOverview-impactCard-title",{fontSize:"15px",fontWeight:"bold"}),"--beam-ImpactOverview-impactCard-progress-marginTop":"15px",...p("--beam-ImpactOverview-impactCard-progressText"),...p("--beam-ImpactOverview-impactCard-description",{marginTop:"10px"}),"--beam-ImpactOverview-impactCard-linkArrow-display":"inline","--beam-ImpactOverview-impactCard-link-color":"inherit",...p("--beam-ImpactOverview-impactCard-link",{marginTop:"10px"}),"--beam-ImpactOverview-share-button-display":"none","--beam-ImpactOverview-share-button-display-mobile":"inherit","--beam-ImpactOverview-share-button-display-desktop":"inherit","--beam-ImpactOverview-share-button-textDecoration":"underline","--beam-ImpactOverview-share-button-icon-size":"16px",...p("--beam-ImpactOverview-share-button",{fontSize:"14px",fontWeight:"bold",marginTop:"12px"}),"--beam-ImpactOverview-share-button-backgroundColor":"#c2dcff","--beam-ImpactOverview-share-button-color":"inherit","--beam-ImpactOverview-share-button-borderRadius":"16px","--beam-ImpactOverview-share-button-borderColor":"transparent","--beam-ImpactOverview-share-button-borderWidth":"2px","--beam-ImpactOverview-share-button-padding":"12px 18px 12px 16px","--beam-ImpactOverview-share-button-width":"auto","--beam-ImpactOverview-share-button-hover-color":"inherit","--beam-ImpactOverview-share-button-hover-borderColor":"transparent","--beam-ImpactOverview-share-button-hover-backgroundColor":"#c2dcff","--beam-ImpactOverview-share-dialog-padding":"30px 60px",...p("--beam-ImpactOverview-share-title",{fontSize:"30px",fontWeight:"bold"}),"--beam-ImpactOverview-share-button-icon-name":"share-2","--beam-ImpactOverview-share-image-width":"200px","--beam-ImpactOverview-share-image-borderRadius":"4px","--beam-ImpactOverview-share-image-margin":"20px",...p("--beam-ImpactOverview-share-text",{fontSize:"16px",lineHeight:"1.3",marginTop:"10px"}),"--beam-ImpactOverview-share-actions-margin":"30px 60px","--beam-ImpactOverview-share-action-icon-size":"32px",...p("--beam-ImpactOverview-share-action-text",{fontSize:"16px",marginTop:"5px"}),...p("--beam-ImpactOverview-share-close",{fontSize:"16px",fontWeight:"bold"}),"--beam-ImpactOverview-share-close-padding":"12px","--beam-ImpactOverview-share-close-backgroundColor":"#ffd522","--beam-ImpactOverview-share-close-text-color":"currentColor","--beam-ImpactOverview-share-close-borderRadius":"4px","--beam-ImpactOverview-image-display":"block"},t=this.impactDataController?.data?.config?.web?.theme||{},i={...a,...t};return Object.assign(Object.create({toCSS(){return A(this)}}),i)}}n.tagName="beam-impact-overview",n.styles=[R,P,v`
120
+ `}get cssVariables(){const a={"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit",...V,...j,...m("--beam-ImpactOverview-title",{fontSize:"16px",fontWeight:"bold",marginTop:"10px"}),...m("--beam-ImpactOverview-subtitle",{marginTop:"5px"}),"--beam-ImpactOverview-impactCards-maxWidth":"800px","--beam-ImpactOverview-impactCard-backgroundColor":"inherit","--beam-ImpactOverview-impactCard-foregroundColor":"currentColor","--beam-ImpactOverview-impactCard-borderColor":"currentColor","--beam-ImpactOverview-impactCard-borderRadius":"0px","--beam-ImpactOverview-impactCard-marginTop":"10px",...m("--beam-ImpactOverview-impactCard-title",{fontSize:"15px",fontWeight:"bold"}),"--beam-ImpactOverview-impactCard-progress-marginTop":"15px",...m("--beam-ImpactOverview-impactCard-progressText"),...m("--beam-ImpactOverview-impactCard-description",{marginTop:"10px"}),"--beam-ImpactOverview-impactCard-linkArrow-display":"inline","--beam-ImpactOverview-impactCard-link-color":"inherit",...m("--beam-ImpactOverview-impactCard-link",{marginTop:"10px"}),"--beam-ImpactOverview-share-button-display":"none","--beam-ImpactOverview-share-button-display-mobile":"inherit","--beam-ImpactOverview-share-button-display-desktop":"inherit","--beam-ImpactOverview-share-button-textDecoration":"underline","--beam-ImpactOverview-share-button-icon-size":"16px",...m("--beam-ImpactOverview-share-button",{fontSize:"14px",fontWeight:"bold",marginTop:"12px"}),"--beam-ImpactOverview-share-button-backgroundColor":"#c2dcff","--beam-ImpactOverview-share-button-color":"inherit","--beam-ImpactOverview-share-button-borderRadius":"16px","--beam-ImpactOverview-share-button-borderColor":"transparent","--beam-ImpactOverview-share-button-borderWidth":"2px","--beam-ImpactOverview-share-button-padding":"12px 18px 12px 16px","--beam-ImpactOverview-share-button-width":"auto","--beam-ImpactOverview-share-button-hover-color":"inherit","--beam-ImpactOverview-share-button-hover-borderColor":"transparent","--beam-ImpactOverview-share-button-hover-backgroundColor":"#c2dcff","--beam-ImpactOverview-share-dialog-padding":"30px 60px",...m("--beam-ImpactOverview-share-title",{fontSize:"30px",fontWeight:"bold"}),"--beam-ImpactOverview-share-button-icon-name":"share-2","--beam-ImpactOverview-share-image-width":"200px","--beam-ImpactOverview-share-image-borderRadius":"4px","--beam-ImpactOverview-share-image-margin":"20px",...m("--beam-ImpactOverview-share-text",{fontSize:"16px",lineHeight:"1.3",marginTop:"10px"}),"--beam-ImpactOverview-share-actions-margin":"30px 60px","--beam-ImpactOverview-share-action-icon-size":"32px",...m("--beam-ImpactOverview-share-action-text",{fontSize:"16px",marginTop:"5px"}),...m("--beam-ImpactOverview-share-close",{fontSize:"16px",fontWeight:"bold"}),"--beam-ImpactOverview-share-close-padding":"12px","--beam-ImpactOverview-share-close-backgroundColor":"#ffd522","--beam-ImpactOverview-share-close-text-color":"currentColor","--beam-ImpactOverview-share-close-borderRadius":"4px","--beam-ImpactOverview-image-display":"block"},t=this.impactDataController?.data?.config?.web?.theme||{},i={...a,...t};return Object.assign(Object.create({toCSS(){return M(this)}}),i)}}n.tagName="beam-impact-overview",n.styles=[A,K,v`
121
121
  :host {
122
122
  display: block;
123
123
  font-family: var(--beam-fontFamily);
@@ -294,5 +294,5 @@ import{f as v,g as d,u as g,h as O,Z as S,y as f,k as $}from"../chunks/lit-qtGbj
294
294
  .share-close:hover {
295
295
  outline: 2px solid var(--beam-ImpactOverview-share-close-focus-borderColor, currentColor);
296
296
  }
297
- `],m([d({type:String,reflect:!0})],n.prototype,"baseUrl",2),m([d({type:String,reflect:!1})],n.prototype,"apiKey",2),m([d({type:Number})],n.prototype,"storeId",2),m([d({type:String,reflect:!0})],n.prototype,"nonprofitId",2),m([d({type:String,reflect:!0})],n.prototype,"userId",2),m([d({type:String})],n.prototype,"lang",2),m([d({type:Boolean})],n.prototype,"debug",2),m([g(".impact-card-title")],n.prototype,"impactTitleRefs",2),m([g(".impact-card-description")],n.prototype,"impactDescriptionRefs",2),m([g(".impact-link")],n.prototype,"impactLinkRefs",2),B(n);export{n as BeamImpactOverview};
297
+ `],p([d({type:String,reflect:!0})],n.prototype,"baseUrl",2),p([d({type:String,reflect:!1})],n.prototype,"apiKey",2),p([d({type:Number})],n.prototype,"storeId",2),p([d({type:String,reflect:!0})],n.prototype,"nonprofitId",2),p([d({type:String,reflect:!0})],n.prototype,"userId",2),p([d({type:String})],n.prototype,"lang",2),p([d({type:Boolean})],n.prototype,"debug",2),p([g(".impact-card-title")],n.prototype,"impactTitleRefs",2),p([g(".impact-card-description")],n.prototype,"impactDescriptionRefs",2),p([g(".impact-link")],n.prototype,"impactLinkRefs",2),U(n);export{n as BeamImpactOverview};
298
298
  //# sourceMappingURL=impact-overview.esm.js.map