@salla.sa/twilight-components 3.0.25 → 3.0.27

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 (368) hide show
  1. package/dist/cjs/{Helper-BSFw7uVh.js → Helper-CFeUiEPn.js} +1 -1
  2. package/dist/cjs/{filepond-DzJcpvBM.js → filepond-Cn3JTrL1.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-poster-BILkbyw_.js → filepond-plugin-file-poster-BOIM6p80.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-size-DIJUAZji.js → filepond-plugin-file-validate-size-YTjl_kR1.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-file-validate-type-4lpOf3hf.js → filepond-plugin-file-validate-type-ByB9Nk2o.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-edit-DtE3Wj_4.js → filepond-plugin-image-edit-DT7UG1he.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-exif-orientation-Dc_jwifJ.js → filepond-plugin-image-exif-orientation-CNqCjRvG.js} +1 -1
  8. package/dist/cjs/{filepond-plugin-image-preview-D_8qt0dd.js → filepond-plugin-image-preview-dsQXwutz.js} +1 -1
  9. package/dist/cjs/{index-D0d25H-r.js → index-DF5Yp06H.js} +6 -6
  10. package/dist/cjs/info-Do5bVPmK.js +13 -0
  11. package/dist/cjs/{intlTelInput-DqmuleM6.js → intlTelInput-CRlVjvSW.js} +1 -1
  12. package/dist/cjs/loader.cjs.js +2 -2
  13. package/dist/cjs/salla-accordion-body_2.cjs.entry.js +1 -1
  14. package/dist/cjs/salla-accordion_6.cjs.entry.js +2 -2
  15. package/dist/cjs/salla-add-product-button_5.cjs.entry.js +2 -2
  16. package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
  17. package/dist/cjs/salla-alert_2.cjs.entry.js +3 -9
  18. package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
  19. package/dist/cjs/salla-applied-filters.cjs.entry.js +2 -2
  20. package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
  21. package/dist/cjs/salla-attachment-view_9.cjs.entry.js +11 -11
  22. package/dist/cjs/salla-badge.cjs.entry.js +1 -1
  23. package/dist/cjs/salla-basket-gap.cjs.entry.js +1 -1
  24. package/dist/cjs/salla-bullet-delivery_3.cjs.entry.js +1 -1
  25. package/dist/cjs/salla-cart-coupons.cjs.entry.js +1 -1
  26. package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +1 -1
  27. package/dist/cjs/salla-cart-summary-card.cjs.entry.js +120 -5
  28. package/dist/cjs/salla-cashback-banner.cjs.entry.js +1 -1
  29. package/dist/cjs/salla-comment-factors.cjs.entry.js +1 -1
  30. package/dist/cjs/salla-comment-form_9.cjs.entry.js +2 -2
  31. package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
  32. package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
  33. package/dist/cjs/salla-cookies-bar.cjs.entry.js +1 -1
  34. package/dist/cjs/salla-count-down.cjs.entry.js +1 -1
  35. package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
  36. package/dist/cjs/salla-delivery-promise.cjs.entry.js +1 -1
  37. package/dist/cjs/salla-edit-order-button.cjs.entry.js +1 -1
  38. package/dist/cjs/salla-filters-widget.cjs.entry.js +2 -2
  39. package/dist/cjs/salla-filters.cjs.entry.js +2 -2
  40. package/dist/cjs/salla-free-shipping-banner.cjs.entry.js +1 -1
  41. package/dist/cjs/salla-free-shipping-tag.cjs.entry.js +1 -1
  42. package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +1 -1
  43. package/dist/cjs/salla-gift-card-redeem_2.cjs.entry.js +1 -1
  44. package/dist/cjs/salla-gifting.cjs.entry.js +1 -1
  45. package/dist/cjs/salla-hook.cjs.entry.js +1 -1
  46. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +2 -2
  47. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  48. package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
  49. package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
  50. package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
  51. package/dist/cjs/salla-loyalty-banner_10.cjs.entry.js +1 -1
  52. package/dist/cjs/salla-loyalty-exchange-product-card.cjs.entry.js +1 -1
  53. package/dist/cjs/salla-loyalty-points-banner.cjs.entry.js +1 -1
  54. package/dist/cjs/salla-loyalty-points-history.cjs.entry.js +1 -1
  55. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  56. package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
  57. package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
  58. package/dist/cjs/salla-map_3.cjs.entry.js +1 -1
  59. package/dist/cjs/salla-menu.cjs.entry.js +1 -1
  60. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  61. package/dist/cjs/salla-mobile-update-modal.cjs.entry.js +1 -1
  62. package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
  63. package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
  64. package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
  65. package/dist/cjs/salla-next-order-coupon.cjs.entry.js +1 -1
  66. package/dist/cjs/salla-notification-item_2.cjs.entry.js +2 -2
  67. package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
  68. package/dist/cjs/salla-offer.cjs.entry.js +1 -1
  69. package/dist/cjs/salla-order-branch.cjs.entry.js +1 -1
  70. package/dist/cjs/salla-order-cancel.cjs.entry.js +1 -1
  71. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
  72. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  73. package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
  74. package/dist/cjs/salla-order-edit-item.cjs.entry.js +1 -1
  75. package/dist/cjs/salla-order-edit-product-card.cjs.entry.js +1 -1
  76. package/dist/cjs/salla-order-edit.cjs.entry.js +1 -1
  77. package/dist/cjs/salla-order-items.cjs.entry.js +1 -1
  78. package/dist/cjs/salla-order-options-modal.cjs.entry.js +1 -1
  79. package/dist/cjs/salla-order-payment.cjs.entry.js +1 -1
  80. package/dist/cjs/salla-order-rewards.cjs.entry.js +1 -1
  81. package/dist/cjs/salla-order-shipments.cjs.entry.js +1 -1
  82. package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
  83. package/dist/cjs/salla-order-totals-card.cjs.entry.js +27 -6
  84. package/dist/cjs/salla-orders.cjs.entry.js +2 -2
  85. package/dist/cjs/salla-payments.cjs.entry.js +1 -1
  86. package/dist/cjs/salla-placeholder.cjs.entry.js +1 -1
  87. package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
  88. package/dist/cjs/salla-product-card-embed.cjs.entry.js +1 -1
  89. package/dist/cjs/salla-product-card.cjs.entry.js +1 -1
  90. package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
  91. package/dist/cjs/salla-products-list.cjs.entry.js +2 -2
  92. package/dist/cjs/salla-products-slider.cjs.entry.js +2 -2
  93. package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
  94. package/dist/cjs/salla-rating-modal-v2.cjs.entry.js +2 -2
  95. package/dist/cjs/salla-rating-modal.cjs.entry.js +2 -2
  96. package/dist/cjs/salla-review-factors-tags.cjs.entry.js +1 -1
  97. package/dist/cjs/salla-review-order-item.cjs.entry.js +1 -1
  98. package/dist/cjs/salla-scopes.cjs.entry.js +1 -1
  99. package/dist/cjs/salla-search-product-card.cjs.entry.js +1 -1
  100. package/dist/cjs/salla-search.cjs.entry.js +2 -2
  101. package/dist/cjs/salla-skeleton.cjs.entry.js +1 -1
  102. package/dist/cjs/salla-social-share.cjs.entry.js +1 -1
  103. package/dist/cjs/salla-social.cjs.entry.js +1 -1
  104. package/dist/cjs/salla-tab-content_3.cjs.entry.js +1 -1
  105. package/dist/cjs/salla-thank-you-header.cjs.entry.js +1 -1
  106. package/dist/cjs/salla-thank-you-page.cjs.entry.js +1 -1
  107. package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
  108. package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
  109. package/dist/cjs/salla-user-menu.cjs.entry.js +1 -1
  110. package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
  111. package/dist/cjs/salla-user-settings.cjs.entry.js +1 -1
  112. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  113. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  114. package/dist/cjs/salla-wishlist-actions.cjs.entry.js +1 -1
  115. package/dist/cjs/salla-wishlist-summary.cjs.entry.js +2 -2
  116. package/dist/cjs/twilight.cjs.js +2 -2
  117. package/dist/cjs/{vanilla-picker-DP9Hy8IR.js → vanilla-picker-qYmOs8Yb.js} +1 -1
  118. package/dist/collection/components/salla-cart-summary-card/salla-cart-summary-card.css +152 -59
  119. package/dist/collection/components/salla-cart-summary-card/salla-cart-summary-card.js +123 -4
  120. package/dist/collection/components/salla-order-totals-card/salla-order-totals-card.css +3 -0
  121. package/dist/collection/components/salla-order-totals-card/salla-order-totals-card.js +25 -4
  122. package/dist/components/index.js +2 -2
  123. package/dist/components/info.js +11 -0
  124. package/dist/components/salla-bottom-alert.js +2 -8
  125. package/dist/components/salla-cart-summary-card.js +124 -5
  126. package/dist/components/salla-order-totals-card.js +26 -5
  127. package/dist/docs.json +3 -3
  128. package/dist/esm/{Helper-DmnUAusv.js → Helper-DE5KHY4U.js} +1 -1
  129. package/dist/esm/{filepond-DZbzdjkK.js → filepond-DbayHaoA.js} +1 -1
  130. package/dist/esm/{filepond-plugin-file-poster-D9cjvoj-.js → filepond-plugin-file-poster-Dy8NIhDv.js} +1 -1
  131. package/dist/esm/{filepond-plugin-file-validate-size-D-kjllC-.js → filepond-plugin-file-validate-size-Bn4zxXDf.js} +1 -1
  132. package/dist/esm/{filepond-plugin-file-validate-type-D9hsNaJl.js → filepond-plugin-file-validate-type-DmygkxtH.js} +1 -1
  133. package/dist/esm/{filepond-plugin-image-edit-CDHAxJY8.js → filepond-plugin-image-edit-BuO-l19h.js} +1 -1
  134. package/dist/esm/{filepond-plugin-image-exif-orientation-BGKiclwK.js → filepond-plugin-image-exif-orientation-COCmniWP.js} +1 -1
  135. package/dist/esm/{filepond-plugin-image-preview-BUjvnt8G.js → filepond-plugin-image-preview-D1i9Fj6F.js} +1 -1
  136. package/dist/esm/{index-ze9e0dxM.js → index-DvJClBwJ.js} +6 -6
  137. package/dist/esm/info-OdOOjQZO.js +11 -0
  138. package/dist/esm/{intlTelInput-BkYRB6km.js → intlTelInput-WsfvuLBW.js} +1 -1
  139. package/dist/esm/loader.js +3 -3
  140. package/dist/esm/salla-accordion-body_2.entry.js +1 -1
  141. package/dist/esm/salla-accordion_6.entry.js +2 -2
  142. package/dist/esm/salla-add-product-button_5.entry.js +2 -2
  143. package/dist/esm/salla-advertisement.entry.js +1 -1
  144. package/dist/esm/salla-alert_2.entry.js +3 -9
  145. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  146. package/dist/esm/salla-applied-filters.entry.js +2 -2
  147. package/dist/esm/salla-apps-icons.entry.js +1 -1
  148. package/dist/esm/salla-attachment-view_9.entry.js +11 -11
  149. package/dist/esm/salla-badge.entry.js +1 -1
  150. package/dist/esm/salla-basket-gap.entry.js +1 -1
  151. package/dist/esm/salla-bullet-delivery_3.entry.js +1 -1
  152. package/dist/esm/salla-cart-coupons.entry.js +1 -1
  153. package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
  154. package/dist/esm/salla-cart-summary-card.entry.js +120 -5
  155. package/dist/esm/salla-cashback-banner.entry.js +1 -1
  156. package/dist/esm/salla-comment-factors.entry.js +1 -1
  157. package/dist/esm/salla-comment-form_9.entry.js +2 -2
  158. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  159. package/dist/esm/salla-contacts.entry.js +1 -1
  160. package/dist/esm/salla-cookies-bar.entry.js +1 -1
  161. package/dist/esm/salla-count-down.entry.js +1 -1
  162. package/dist/esm/salla-custom-fields.entry.js +1 -1
  163. package/dist/esm/salla-delivery-promise.entry.js +1 -1
  164. package/dist/esm/salla-edit-order-button.entry.js +1 -1
  165. package/dist/esm/salla-filters-widget.entry.js +2 -2
  166. package/dist/esm/salla-filters.entry.js +2 -2
  167. package/dist/esm/salla-free-shipping-banner.entry.js +1 -1
  168. package/dist/esm/salla-free-shipping-tag.entry.js +1 -1
  169. package/dist/esm/salla-fulfillment-methods.entry.js +1 -1
  170. package/dist/esm/salla-gift-card-redeem_2.entry.js +1 -1
  171. package/dist/esm/salla-gifting.entry.js +1 -1
  172. package/dist/esm/salla-hook.entry.js +1 -1
  173. package/dist/esm/salla-infinite-scroll.entry.js +2 -2
  174. package/dist/esm/salla-installment.entry.js +1 -1
  175. package/dist/esm/salla-list-tile.entry.js +1 -1
  176. package/dist/esm/salla-localization-modal.entry.js +1 -1
  177. package/dist/esm/salla-login-modal.entry.js +1 -1
  178. package/dist/esm/salla-loyalty-banner_10.entry.js +1 -1
  179. package/dist/esm/salla-loyalty-exchange-product-card.entry.js +1 -1
  180. package/dist/esm/salla-loyalty-points-banner.entry.js +1 -1
  181. package/dist/esm/salla-loyalty-points-history.entry.js +1 -1
  182. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  183. package/dist/esm/salla-loyalty.entry.js +1 -1
  184. package/dist/esm/salla-maintenance-alert.entry.js +1 -1
  185. package/dist/esm/salla-map_3.entry.js +1 -1
  186. package/dist/esm/salla-menu.entry.js +1 -1
  187. package/dist/esm/salla-metadata.entry.js +1 -1
  188. package/dist/esm/salla-mobile-update-modal.entry.js +1 -1
  189. package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
  190. package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
  191. package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
  192. package/dist/esm/salla-next-order-coupon.entry.js +1 -1
  193. package/dist/esm/salla-notification-item_2.entry.js +2 -2
  194. package/dist/esm/salla-offer-modal.entry.js +1 -1
  195. package/dist/esm/salla-offer.entry.js +1 -1
  196. package/dist/esm/salla-order-branch.entry.js +1 -1
  197. package/dist/esm/salla-order-cancel.entry.js +1 -1
  198. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  199. package/dist/esm/salla-order-details-options.entry.js +1 -1
  200. package/dist/esm/salla-order-details.entry.js +1 -1
  201. package/dist/esm/salla-order-edit-item.entry.js +1 -1
  202. package/dist/esm/salla-order-edit-product-card.entry.js +1 -1
  203. package/dist/esm/salla-order-edit.entry.js +1 -1
  204. package/dist/esm/salla-order-items.entry.js +1 -1
  205. package/dist/esm/salla-order-options-modal.entry.js +1 -1
  206. package/dist/esm/salla-order-payment.entry.js +1 -1
  207. package/dist/esm/salla-order-rewards.entry.js +1 -1
  208. package/dist/esm/salla-order-shipments.entry.js +1 -1
  209. package/dist/esm/salla-order-summary.entry.js +1 -1
  210. package/dist/esm/salla-order-totals-card.entry.js +27 -6
  211. package/dist/esm/salla-orders.entry.js +2 -2
  212. package/dist/esm/salla-payments.entry.js +1 -1
  213. package/dist/esm/salla-placeholder.entry.js +1 -1
  214. package/dist/esm/salla-price-range.entry.js +1 -1
  215. package/dist/esm/salla-product-card-embed.entry.js +1 -1
  216. package/dist/esm/salla-product-card.entry.js +1 -1
  217. package/dist/esm/salla-product-size-guide.entry.js +1 -1
  218. package/dist/esm/salla-products-list.entry.js +2 -2
  219. package/dist/esm/salla-products-slider.entry.js +2 -2
  220. package/dist/esm/salla-quick-order.entry.js +1 -1
  221. package/dist/esm/salla-rating-modal-v2.entry.js +2 -2
  222. package/dist/esm/salla-rating-modal.entry.js +2 -2
  223. package/dist/esm/salla-review-factors-tags.entry.js +1 -1
  224. package/dist/esm/salla-review-order-item.entry.js +1 -1
  225. package/dist/esm/salla-scopes.entry.js +1 -1
  226. package/dist/esm/salla-search-product-card.entry.js +1 -1
  227. package/dist/esm/salla-search.entry.js +2 -2
  228. package/dist/esm/salla-skeleton.entry.js +1 -1
  229. package/dist/esm/salla-social-share.entry.js +1 -1
  230. package/dist/esm/salla-social.entry.js +1 -1
  231. package/dist/esm/salla-tab-content_3.entry.js +1 -1
  232. package/dist/esm/salla-thank-you-header.entry.js +1 -1
  233. package/dist/esm/salla-thank-you-page.entry.js +1 -1
  234. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  235. package/dist/esm/salla-trust-badges.entry.js +1 -1
  236. package/dist/esm/salla-user-menu.entry.js +1 -1
  237. package/dist/esm/salla-user-profile.entry.js +1 -1
  238. package/dist/esm/salla-user-settings.entry.js +1 -1
  239. package/dist/esm/salla-verify.entry.js +1 -1
  240. package/dist/esm/salla-wallet.entry.js +1 -1
  241. package/dist/esm/salla-wishlist-actions.entry.js +1 -1
  242. package/dist/esm/salla-wishlist-summary.entry.js +2 -2
  243. package/dist/esm/twilight.js +3 -3
  244. package/dist/esm/{vanilla-picker-CxhuwWDi.js → vanilla-picker-DdilrJ6c.js} +1 -1
  245. package/dist/twilight/{p-bd06c200.entry.js → p-00c35c9f.entry.js} +1 -1
  246. package/dist/twilight/{p-67cf7454.entry.js → p-00f9aefc.entry.js} +1 -1
  247. package/dist/twilight/{p-da60995f.entry.js → p-029f809b.entry.js} +1 -1
  248. package/dist/twilight/{p-dceb3725.entry.js → p-02a06dcb.entry.js} +1 -1
  249. package/dist/twilight/{p-3ec3e9fb.entry.js → p-03dc3837.entry.js} +1 -1
  250. package/dist/twilight/{p-024ecda2.entry.js → p-054f32c4.entry.js} +1 -1
  251. package/dist/twilight/{p-78c04993.entry.js → p-069df650.entry.js} +1 -1
  252. package/dist/twilight/p-0a1a172d.entry.js +4 -0
  253. package/dist/twilight/{p-de10d0c3.entry.js → p-0ac5f79f.entry.js} +1 -1
  254. package/dist/twilight/{p-331003bc.entry.js → p-0c1bbd55.entry.js} +1 -1
  255. package/dist/twilight/{p-d89328d7.entry.js → p-0c4e99b4.entry.js} +1 -1
  256. package/dist/twilight/{p-fb955257.entry.js → p-0c65d35a.entry.js} +1 -1
  257. package/dist/twilight/{p-b297fe2e.entry.js → p-0d357ae2.entry.js} +1 -1
  258. package/dist/twilight/{p-11eb8675.entry.js → p-0ded0dc1.entry.js} +1 -1
  259. package/dist/twilight/p-13309e4e.entry.js +4 -0
  260. package/dist/twilight/{p-bf5b5f52.entry.js → p-16d49b35.entry.js} +1 -1
  261. package/dist/twilight/{p-f9dd6b3e.entry.js → p-19896b94.entry.js} +1 -1
  262. package/dist/twilight/{p-dbb4db25.entry.js → p-1b6b5a3c.entry.js} +1 -1
  263. package/dist/twilight/{p-d2396143.entry.js → p-1ce1b6dc.entry.js} +1 -1
  264. package/dist/twilight/{p-3a2ff4d6.entry.js → p-1d1bef93.entry.js} +1 -1
  265. package/dist/twilight/{p-4cf81a44.entry.js → p-1fce7e50.entry.js} +1 -1
  266. package/dist/twilight/{p-c122e9c1.entry.js → p-1ff27daa.entry.js} +1 -1
  267. package/dist/twilight/{p-97c5b11d.entry.js → p-22db0366.entry.js} +1 -1
  268. package/dist/twilight/p-24abaa09.entry.js +4 -0
  269. package/dist/twilight/{p-37b64e36.entry.js → p-29349910.entry.js} +1 -1
  270. package/dist/twilight/{p-d300a117.entry.js → p-29e3685e.entry.js} +1 -1
  271. package/dist/twilight/{p-71ce8e4f.entry.js → p-301a42aa.entry.js} +1 -1
  272. package/dist/twilight/{p-e849f5ef.entry.js → p-30919203.entry.js} +1 -1
  273. package/dist/twilight/{p-4c191ab4.entry.js → p-309edef2.entry.js} +1 -1
  274. package/dist/twilight/{p-7731e280.entry.js → p-3356b015.entry.js} +1 -1
  275. package/dist/twilight/{p-8d3c5d1f.entry.js → p-366403da.entry.js} +1 -1
  276. package/dist/twilight/{p-446e3f38.entry.js → p-36ee91e5.entry.js} +1 -1
  277. package/dist/twilight/{p-ed96c703.entry.js → p-388e49fe.entry.js} +1 -1
  278. package/dist/twilight/p-3a5604b1.entry.js +4 -0
  279. package/dist/twilight/{p-2dcd24fe.entry.js → p-3eae2216.entry.js} +1 -1
  280. package/dist/twilight/{p-5ceda3d5.entry.js → p-41b57414.entry.js} +1 -1
  281. package/dist/twilight/{p-776f9492.entry.js → p-43eb35a7.entry.js} +1 -1
  282. package/dist/twilight/{p-0c022fbd.entry.js → p-44621e3a.entry.js} +1 -1
  283. package/dist/twilight/{p-ffc7f526.entry.js → p-450cdcc4.entry.js} +1 -1
  284. package/dist/twilight/{p-5d8937c5.entry.js → p-46ae40a3.entry.js} +1 -1
  285. package/dist/twilight/{p-6d6b99fe.entry.js → p-4d5abe91.entry.js} +1 -1
  286. package/dist/twilight/{p-519cf4c2.entry.js → p-4e9c9419.entry.js} +1 -1
  287. package/dist/twilight/{p-5f9d87ec.entry.js → p-50898992.entry.js} +1 -1
  288. package/dist/twilight/{p-8b0b6bca.entry.js → p-52011986.entry.js} +1 -1
  289. package/dist/twilight/{p-cbd056ba.entry.js → p-52e24b0f.entry.js} +1 -1
  290. package/dist/twilight/{p-b6098938.entry.js → p-536a1841.entry.js} +1 -1
  291. package/dist/twilight/{p-47c79c49.entry.js → p-5865e825.entry.js} +1 -1
  292. package/dist/twilight/{p-20949dfb.entry.js → p-591694a7.entry.js} +1 -1
  293. package/dist/twilight/{p-474d882c.entry.js → p-60cd3462.entry.js} +1 -1
  294. package/dist/twilight/{p-9acfe389.entry.js → p-628ef86c.entry.js} +1 -1
  295. package/dist/twilight/{p-dfde387f.entry.js → p-630cce26.entry.js} +1 -1
  296. package/dist/twilight/{p-a7566af2.entry.js → p-6569bfee.entry.js} +1 -1
  297. package/dist/twilight/{p-57fafaba.entry.js → p-66f02fad.entry.js} +1 -1
  298. package/dist/twilight/{p-cdeaf60b.entry.js → p-6936e0a4.entry.js} +1 -1
  299. package/dist/twilight/{p-7fffa509.entry.js → p-6c5bd5ad.entry.js} +1 -1
  300. package/dist/twilight/{p-93571975.entry.js → p-6d0ad265.entry.js} +1 -1
  301. package/dist/twilight/{p-9fe5c0f5.entry.js → p-6e79128e.entry.js} +1 -1
  302. package/dist/twilight/{p-07e581af.entry.js → p-6ff4df6b.entry.js} +1 -1
  303. package/dist/twilight/{p-bb137dbb.entry.js → p-73f1697f.entry.js} +1 -1
  304. package/dist/twilight/{p-008740fe.entry.js → p-741cc4a4.entry.js} +1 -1
  305. package/dist/twilight/{p-c6f09614.entry.js → p-74e3b033.entry.js} +1 -1
  306. package/dist/twilight/{p-02b7dfcc.entry.js → p-7e421e8a.entry.js} +1 -1
  307. package/dist/twilight/{p-08be494e.entry.js → p-8056b437.entry.js} +1 -1
  308. package/dist/twilight/{p-89598ad3.entry.js → p-84b35a50.entry.js} +1 -1
  309. package/dist/twilight/{p-2aa9147c.entry.js → p-85bf4c43.entry.js} +1 -1
  310. package/dist/twilight/{p-0fd15433.entry.js → p-85e43124.entry.js} +1 -1
  311. package/dist/twilight/{p-1ca39f1c.entry.js → p-8a614038.entry.js} +1 -1
  312. package/dist/twilight/{p-BjUh9YCs.js → p-8iHhuUVM.js} +1 -1
  313. package/dist/twilight/{p-455a4702.entry.js → p-93439ac4.entry.js} +1 -1
  314. package/dist/twilight/{p-cb961f05.entry.js → p-963eb26d.entry.js} +1 -1
  315. package/dist/twilight/{p-bf65d2fa.entry.js → p-989e3cd6.entry.js} +1 -1
  316. package/dist/twilight/{p-4ec15515.entry.js → p-98cf67a5.entry.js} +1 -1
  317. package/dist/twilight/{p-16e2a110.entry.js → p-9ec3124c.entry.js} +1 -1
  318. package/dist/twilight/{p-9dd7cf71.entry.js → p-9ed41657.entry.js} +1 -1
  319. package/dist/twilight/{p-CICtuB_u.js → p-B1r6DqQZ.js} +1 -1
  320. package/dist/twilight/{p-DOUAavek.js → p-B8bJ6Bp4.js} +1 -1
  321. package/dist/twilight/{p-BpJsOjKP.js → p-BAfdlulm.js} +1 -1
  322. package/dist/twilight/{p-cykIAOlk.js → p-BHVWJBhN.js} +1 -1
  323. package/dist/twilight/{p-BlPdaFn2.js → p-BddjrRgx.js} +1 -1
  324. package/dist/twilight/{p-wYYV5ykR.js → p-CeKF1bL-.js} +1 -1
  325. package/dist/twilight/{p-ze9e0dxM.js → p-DvJClBwJ.js} +1 -1
  326. package/dist/twilight/{p-B8nGVDvQ.js → p-FYANWJHV.js} +1 -1
  327. package/dist/twilight/p-OdOOjQZO.js +4 -0
  328. package/dist/twilight/{p-C9ldyQUq.js → p-UebnA4Q1.js} +1 -1
  329. package/dist/twilight/{p-830abcc1.entry.js → p-a460c4be.entry.js} +1 -1
  330. package/dist/twilight/{p-792494c8.entry.js → p-a7297a33.entry.js} +1 -1
  331. package/dist/twilight/{p-f23ada45.entry.js → p-ac4b8722.entry.js} +1 -1
  332. package/dist/twilight/{p-5b118b5b.entry.js → p-accfd79c.entry.js} +1 -1
  333. package/dist/twilight/{p-e23b84bf.entry.js → p-adfdfe9d.entry.js} +1 -1
  334. package/dist/twilight/{p-73649c81.entry.js → p-ae1c28e0.entry.js} +1 -1
  335. package/dist/twilight/{p-f7c06bee.entry.js → p-b06cad39.entry.js} +1 -1
  336. package/dist/twilight/{p-59694c45.entry.js → p-b47ffe8e.entry.js} +1 -1
  337. package/dist/twilight/{p-75ad7f14.entry.js → p-be357093.entry.js} +1 -1
  338. package/dist/twilight/{p-8077d8b6.entry.js → p-c1b6d4ba.entry.js} +1 -1
  339. package/dist/twilight/{p-5e0f85ae.entry.js → p-c9e04a12.entry.js} +1 -1
  340. package/dist/twilight/{p-b71673ee.entry.js → p-ca20c66e.entry.js} +1 -1
  341. package/dist/twilight/{p-97fa91db.entry.js → p-cc84061b.entry.js} +1 -1
  342. package/dist/twilight/{p-d089ac6d.entry.js → p-cefd664d.entry.js} +1 -1
  343. package/dist/twilight/{p-a7849674.entry.js → p-d1fac437.entry.js} +1 -1
  344. package/dist/twilight/{p-7a985fe3.entry.js → p-d6015b0c.entry.js} +1 -1
  345. package/dist/twilight/{p-a865995d.entry.js → p-d6728c04.entry.js} +1 -1
  346. package/dist/twilight/{p-e3dd9502.entry.js → p-d7537ab1.entry.js} +1 -1
  347. package/dist/twilight/{p-9a2567e2.entry.js → p-d81a6a32.entry.js} +1 -1
  348. package/dist/twilight/{p-12a52f1b.entry.js → p-d8856c7b.entry.js} +1 -1
  349. package/dist/twilight/{p-45a7d444.entry.js → p-da3c7ee3.entry.js} +1 -1
  350. package/dist/twilight/{p-75f7f1d8.entry.js → p-e276cb82.entry.js} +1 -1
  351. package/dist/twilight/{p-c0301e00.entry.js → p-e73bc00f.entry.js} +1 -1
  352. package/dist/twilight/{p-03b2df97.entry.js → p-e785df2d.entry.js} +1 -1
  353. package/dist/twilight/{p-da0349f9.entry.js → p-e81d544a.entry.js} +1 -1
  354. package/dist/twilight/{p-7790a9a1.entry.js → p-e8414134.entry.js} +1 -1
  355. package/dist/twilight/{p-d61298f8.entry.js → p-ea0de552.entry.js} +1 -1
  356. package/dist/twilight/{p-a1a650ab.entry.js → p-ea58a665.entry.js} +1 -1
  357. package/dist/twilight/{p-770142fe.entry.js → p-f6b86d47.entry.js} +1 -1
  358. package/dist/twilight/{p-f054cf8e.entry.js → p-fbd7def8.entry.js} +1 -1
  359. package/dist/twilight/{p-CNQaYCUJ.js → p-zPvqMpJX.js} +1 -1
  360. package/dist/twilight/twilight.esm.js +1 -1
  361. package/dist/types/components/salla-cart-summary-card/salla-cart-summary-card.d.ts +26 -0
  362. package/dist/types/components/salla-order-totals-card/interfaces.d.ts +8 -3
  363. package/dist/types/components/salla-order-totals-card/salla-order-totals-card.d.ts +2 -1
  364. package/package.json +5 -5
  365. package/dist/twilight/p-0c0b2b36.entry.js +0 -4
  366. package/dist/twilight/p-61b98119.entry.js +0 -4
  367. package/dist/twilight/p-8d096f95.entry.js +0 -4
  368. package/dist/twilight/p-be8c42f1.entry.js +0 -4
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,h as i,H as e,a as r}from"./p-ze9e0dxM.js";var o,n;!function(t){t.PERCENTAGE="percentage",t.FIXED="fixed",t.FREE_PRODUCT="free_product",t.FREE_SHIPPING="free_shipping"}(o||(o={})),function(t){t.PRODUCT_COUNT="products_count",t.PRODUCT_PURCHASE="order_amount"}(n||(n={}));const s=Object.freeze([]),a=Object.freeze([]);let l,c=null,d=null,h=null,f=!1,u=null,p=null,g=0;function m(t){return"CartNotCreated"===t?.name}function b(){try{const t=salla.api?.cart?.getStoredCartId?salla.api.cart.getStoredCartId():salla.storage?.get?.("cart.id");return null==t||""===t?null:String(t)}catch(t){return null}}function w(){const t=b();void 0!==l&&l!==t&&(g++,d=null,c=null,h=null,f=!1,u=null),l=t}function y(t){return null==t?0:"number"==typeof t?isFinite(t)?t:0:"string"==typeof t&&parseFloat(t)||0}function x(t){if(null==t||""===t)return null;const i=y(t);return isFinite(i)?i:null}function v(t,i){if(null!==i)return i.length;const e=x(t?.data?.cart?.count??t?.data?.count??t?.cart?.count??t?.count);return null!==e&&e>=0?e:null}function k(t){for(const i of[t?.original_price,t?.product_price,t?.price]){const t=x(i&&"object"==typeof i?i.amount:i);if(null!==t&&t>0)return t}return null}function _(t,i){const e=t?.free_gift_quantity;return null!=e&&""!==e?y(e):i>0?i:0}function C(t){const i=[];for(const e of t){if(null==e?.id)continue;if(!e.added_by_offer)continue;const t=y(e.quantity),r=_(e,t);r<=0||i.push({id:String(e.id),offerId:x(e.offer_id),quantity:r,freeQuantity:r,lineQuantity:t,name:String(e.product_name??e.name??""),imageUrl:String(e.product_image?.url??e.product_image??e.image?.url??""),imageAlt:String(e.product_image?.alt??e.image?.alt??e.product_name??""),url:String(e.url??""),originalPrice:k(e)})}return i}function M(t){const i=[];for(const e of t){if(null==e?.id)continue;const t=y(e.quantity);i.push({id:String(e.id),productId:x(e.product_id),quantity:t,freeQuantity:e.added_by_offer?Math.max(0,_(e,t)):0,offerId:e.added_by_offer?x(e.offer_id):null})}return i}function P(){if(u)return u;const t=g,i=Promise.resolve().then((()=>salla.api?.cart?.details?.())).then((t=>{const i=function(t){const i=t?.data?.cart?.items??t?.data?.items??t?.cart?.items??t?.items;return Array.isArray(i)?i:null}(t),e=i??[];return{gifts:C(e),lines:M(e),count:v(t,i),ok:!0}})).catch((t=>({gifts:d??[],lines:c??[],count:m(t)?0:h,ok:!1}))).then((({gifts:i,lines:e,count:r,ok:o})=>{t===g&&(d=i,c=e,h=r,f=o)})).finally((()=>{u===i&&(u=null)}));return u=i,i}function S(){return w(),f}function T(){if(p)return p;g++,d=null,c=null,h=null,f=!1,l=b();const t=()=>(p===i&&(p=null),P()),i=(u??Promise.resolve()).then(t,t).finally((()=>{p===i&&(p=null)}));return p=i,i}const z=-1;var L,$;function F(t){const i="number"==typeof t?t:parseFloat(t);return Number.isFinite(i)?i:null}function I(t){return"boolean"==typeof t?t:1===t||0===t?1===t:"true"===t||"1"===t||"false"!==t&&"0"!==t&&void 0}function N(t){return F(t)??0}function R(t,i,e){return Math.max(i,Math.min(t,e))}function j(t){const i="number"==typeof t?t:parseFloat(t);if(!Number.isFinite(i))return null;const e=Math.trunc(i);return e>=0&&e<=4?e:null}!function(t){t.LOCKED="locked",t.CURRENT="current",t.COMPLETED="completed"}(L||(L={})),function(t){t.CURRENCY="currency",t.COUNT="count"}($||($={}));const V=[1e3,2e3,4e3],A='[data-testid^="store-cart-item-"], form[id^="item-"]',H="salla-conditional-offer:reloaded-for",O='form[id^="item-"]:not(.cart-options form)';let q=0;const B={badges_summary:":completed of :total offers unlocked",congrats:"Congratulations! You’ve unlocked all rewards in this promotion",details_title:"Offer details",free_gift:"Free Gift",free_products_title:"Free products selected from the offer",free_products_unavailable:"The free products are currently unavailable",free_products_choose:"Choose :count free products",free_products_choose_two:"Choose 2 free products",free_product_choose_one:"Choose your free product",free_product_got_one:"You got a free product",free_product_got_pick_one:"You got a free product! Choose it now",free_products_got:"You got :count free products",free_products_got_pick:"You got :count free products! Choose them now",free_products_got_pick_two:"You got 2 free products! Choose them now",free_products_got_two:"You got 2 free products",free_product_reward_one:"a free product",free_products_reward:":count free products",free_products_reward_two:"2 free products",guidance_conditions_unmet:"Your cart doesn’t meet the conditions for the next reward yet",guidance_next:"Add :remaining and get :reward",guidance_next_generic:"Add :remaining to unlock the next reward",manage_offer:"Manage offer",offer_toggle:"Offer",tier_requirement:"Spend :threshold and get :reward",tier_requirement_count:"Buy :threshold and get :reward",tier_requirement_count_generic:"Buy :threshold to unlock this offer",tier_requirement_generic:"Spend :threshold to unlock this offer",tier_title:"Offer (:number)"},D="pages.checkout.free_charge";function G(t){const i=document.createElement("div");return i.textContent=t??"",i.innerHTML}const Y=(t={})=>i("svg",{class:t.class,viewBox:"0 0 10 10",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false"},i("path",{d:"M5.00016 9.16634C2.69898 9.16634 0.833496 7.30084 0.833496 4.99967C0.833496 2.69849 2.69898 0.833008 5.00016 0.833008C7.30133 0.833008 9.16683 2.69849 9.16683 4.99967C9.16683 7.30084 7.30133 9.16634 5.00016 9.16634ZM4.58458 6.66634L7.53087 3.72006L6.94162 3.13081L4.58458 5.48784L3.40608 4.3093L2.81683 4.89859L4.58458 6.66634Z",fill:"currentColor"})),E=(t={})=>i("svg",{class:t.class,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false"},i("path",{d:"M12.6667 6.66683H13.3333C13.7015 6.66683 14 6.9653 14 7.3335V14.0002C14 14.3684 13.7015 14.6668 13.3333 14.6668H2.66667C2.29848 14.6668 2 14.3684 2 14.0002V7.3335C2 6.9653 2.29848 6.66683 2.66667 6.66683H3.33333V6.00016C3.33333 3.42284 5.42267 1.3335 8 1.3335C10.5773 1.3335 12.6667 3.42284 12.6667 6.00016V6.66683ZM11.3333 6.66683V6.00016C11.3333 4.15922 9.84093 2.66683 8 2.66683C6.15905 2.66683 4.66667 4.15922 4.66667 6.00016V6.66683H11.3333ZM7.33333 9.3335V12.0002H8.66667V9.3335H7.33333Z",fill:"currentColor"})),W=(t={})=>i("svg",{class:t.class,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false"},i("path",{d:"M7.00033 12.8337C3.77866 12.8337 1.16699 10.222 1.16699 7.00033C1.16699 3.77866 3.77866 1.16699 7.00033 1.16699C10.222 1.16699 12.8337 3.77866 12.8337 7.00033C12.8337 10.222 10.222 12.8337 7.00033 12.8337ZM6.41699 6.41699V9.91699H7.58366V6.41699H6.41699ZM6.41699 4.08366V5.25033H7.58366V4.08366H6.41699Z",fill:"currentColor"})),Z=class{constructor(i){t(this,i),this.offer=null,this.isLoading=!1,this.canRender=!0,this.gifts=[],this.cartLines=[],this.cartLinesLoaded=!1,this.freeProductCards={},this.pendingFreeProduct=null,this.pendingFreeProductSettledAt=null,this.pendingFreeProductTimer=null,this.cartPageCheckAfter=null,this.insertingCartLines=!1,this.pendingCartPageLines=null,this.pickerLookupRetries=0,this.pickerLookupTimer=null,this.cartItemCount=null,this.isTooltipHovered=!1,this.isTooltipPinned=!1,this.isGiftsOpen=!0,this.instanceId=++q,this.refreshGeneration=0,this.giftsGeneration=0,this.cartRefreshTimer=null,this.cartRefreshPending=!1,this.wantsCartUpdates=!1,this.isListeningToCartUpdates=!1,this.cartLookupRetryTimer=null,this.cartLookupRetries=0,this.cartLookupRetryPending=!1,this.deferredByEmptyCart=!1,this.isDisconnected=!1,this.skeletonWatchdog=null,this.skeletonDeadline=0,this.hasRelocated=!1,this.hasLoaded=!1,this.relocationObserver=null,this.relocationWatchTimer=null,this.relocationWatchExpired=!1,this.relocationLogged=!1,this.cartUpdatedHandler=t=>{this.readCartCountFromEvent(t),this.clearCartLookupRetry(),this.scheduleCartRefresh()}}componentWillLoad(){this.ensureSkeletonIsWatched();try{this.isEnabled()&&this.startLoading(),this.load().catch((t=>{this.stopLoading(),this.safeLog("load() failed",t)}))}catch(t){this.stopLoading(),this.safeLog("componentWillLoad threw synchronously",t)}}safeLog(t,i){try{salla.logger.warn("salla-conditional-offer::",t,i)}catch(t){}}connectedCallback(){this.isDisconnected=!1,this.ensureSkeletonIsWatched(),this.wantsCartUpdates&&!this.isListeningToCartUpdates&&this.subscribeToCartUpdates()&&(this.cartRefreshPending=!0),this.cartRefreshPending&&this.scheduleCartRefresh(),this.cartLookupRetryPending&&this.scheduleCartLookupRetry()}disconnectedCallback(){this.isDisconnected=!0,null!==this.cartRefreshTimer&&(clearTimeout(this.cartRefreshTimer),this.cartRefreshTimer=null),this.unlockFreeProduct(),this.clearPickerLookupRetry(),null!==this.cartLookupRetryTimer&&(clearTimeout(this.cartLookupRetryTimer),this.cartLookupRetryTimer=null),Promise.resolve().then((()=>{this.isDisconnected&&this.unsubscribeFromCartUpdates()})),null!==this.skeletonWatchdog&&(clearTimeout(this.skeletonWatchdog),this.skeletonWatchdog=null),this.stopWatchingForItemsColumn()}componentDidLoad(){this.hasLoaded=!0,this.relocateIntoItemsColumn()}isShowingSomething(){return this.canRender&&this.hasCartItems()}componentDidRender(){this.hasLoaded&&this.relocateIntoItemsColumn(),this.positionTooltip(),this.ensureSkeletonIsWatched()}relocateIntoItemsColumn(){if(!this.hasRelocated&&this.isShowingSomething())try{const t=this.hostEl;if(!t?.parentElement)return;const i=this.findItemsColumn(t);if(!i)return void this.watchForItemsColumn();if(this.hasRelocated=!0,this.stopWatchingForItemsColumn(),i===t.parentElement&&i.firstElementChild===t)return;i.insertBefore(t,i.firstChild)}catch(t){this.hasRelocated=!0,this.stopWatchingForItemsColumn(),this.safeLog("relocating the banner into the cart items column failed",t)}}findItemsColumn(t){let i=t;for(let e=0;i&&e<=3;e++){for(const e of this.getFollowingSiblings(i)){if(i===t&&this.matches(e,A))return t.parentElement;const r=this.findColumnWithin(e,t);if(r)return r}if(i=i.parentElement,!i||i===document.body||i===document.documentElement)break}return null}getFollowingSiblings(t){const i=[];for(let e=t.nextElementSibling;e;e=e.nextElementSibling)i.push(e);return i}findColumnWithin(t,i){const e=t.querySelector(A),r=(e?this.climbToChildOf(e,t):null)??t.querySelector(".main-content, [data-cart-items]");return!r||r===i||r.contains(i)?null:r}climbToChildOf(t,i){let e=t;for(;e&&e.parentElement&&e.parentElement!==i;)e=e.parentElement;return e?.parentElement===i?e:null}matches(t,i){return"function"==typeof t.matches&&t.matches(i)}watchForItemsColumn(){this.hasRelocated||this.relocationWatchExpired||this.relocationObserver||("undefined"!=typeof MutationObserver?(this.relocationObserver=new MutationObserver((()=>this.relocateIntoItemsColumn())),this.relocationObserver.observe(document.documentElement,{childList:!0,subtree:!0}),this.relocationWatchTimer=setTimeout((()=>{this.relocationWatchTimer=null,this.relocationWatchExpired=!0,this.stopWatchingForItemsColumn(),this.logNoItemsColumn()}),5e3)):this.logNoItemsColumn())}stopWatchingForItemsColumn(){if(this.relocationObserver){try{this.relocationObserver.disconnect()}catch(t){}this.relocationObserver=null}null!==this.relocationWatchTimer&&(clearTimeout(this.relocationWatchTimer),this.relocationWatchTimer=null)}logNoItemsColumn(){this.relocationLogged||(this.relocationLogged=!0,this.safeLog("no cart items column found — leaving the banner at full page width"))}ensureSkeletonIsWatched(){if(!this.isLoading)return;if(null!==this.skeletonWatchdog)return;const t=Date.now();0===this.skeletonDeadline&&(this.skeletonDeadline=t+8e3);const i=Math.max(0,this.skeletonDeadline-t);this.skeletonWatchdog=setTimeout((()=>{this.skeletonWatchdog=null,this.isLoading&&(Date.now()<this.skeletonDeadline?this.ensureSkeletonIsWatched():(this.isLoading=!1,this.skeletonDeadline=0,this.safeLog("still loading after 8000ms — dropping the skeleton")))}),i)}clearSkeletonWatchdog(){this.skeletonDeadline=0,null!==this.skeletonWatchdog&&(clearTimeout(this.skeletonWatchdog),this.skeletonWatchdog=null)}startLoading(){this.isLoading=!0,this.ensureSkeletonIsWatched()}stopLoading(){this.isLoading=!1,this.clearSkeletonWatchdog()}async load(){this.wantsCartUpdates=!0,this.subscribeToCartUpdates()||this.subscribeWhenSdkIsReady(),this.loadCart(),await this.waitForSdk(),await this.refresh()}waitForSdk(){let t,i;try{t=Promise.resolve(salla.onReady?.())}catch(t){return this.safeLog("salla.onReady() threw",t),Promise.resolve()}const e=new Promise((t=>{i=setTimeout(t,3e3)}));return Promise.race([t.catch((t=>this.safeLog("salla.onReady() rejected",t))),e]).then((()=>{clearTimeout(i)}))}subscribeToCartUpdates(){if(this.isListeningToCartUpdates)return!0;try{salla.event.on("cart::updated",this.cartUpdatedHandler),this.isListeningToCartUpdates=!0}catch(t){this.safeLog("cart::updated subscription failed",t)}return this.isListeningToCartUpdates}unsubscribeFromCartUpdates(){if(this.isListeningToCartUpdates){this.isListeningToCartUpdates=!1;try{salla.event.off("cart::updated",this.cartUpdatedHandler)}catch(t){this.safeLog("cart::updated unsubscription failed",t)}}}subscribeWhenSdkIsReady(){let t;try{t=Promise.resolve(salla.onReady?.())}catch(t){return}const i=()=>{this.isDisconnected||this.subscribeToCartUpdates()};t.then(i,i)}scheduleCartRefresh(){this.cartRefreshPending=!0,null!==this.cartRefreshTimer&&clearTimeout(this.cartRefreshTimer),this.cartRefreshTimer=null,this.isDisconnected||(this.cartRefreshTimer=setTimeout((()=>{this.cartRefreshTimer=null,this.runCartRefresh()}),200))}runCartRefresh(){this.isDisconnected||(this.cartRefreshPending=!1,this.refresh(),this.clearPickerLookupRetry(),T().then((()=>this.loadCart()),(()=>this.loadCart())))}readCartCountFromEvent(t){const i=this.toCartCount(t?.count)??this.readCartCountFromStorage();null!==i&&(this.cartItemCount=i)}readCartCountFromStorage(){try{return this.toCartCount(salla.storage?.get?.("cart.summary.count"))}catch(t){return null}}toCartCount(t){return"number"==typeof t&&Number.isFinite(t)&&t>=0?t:null}getFreeLabel(){const t=salla.lang.get(D);return t&&t!==D?t:"Free"}getAddLabel(){return this.sharedLabel("common.elements.add","Add")}sharedLabel(t,i){const e=salla.lang.get(t);return e&&e!==t?e:i}trans(t,i){const e=`blocks.cart_offer.${t}`,r=salla.lang.get(e,i);return r&&r!==e?r:Object.entries(i??{}).reduce(((t,[i,e])=>t.split(`:${i}`).join(e)),B[t])}isEnabled(){try{return!!salla.config.get("store.features")?.includes("conditional-offer")}catch(t){return!1}}async fetchOffer(){const{data:t}=await salla.api.cart.offers(),i=(t||[]).find((t=>"conditional"===t.type));return i?.details?.discounts?.length?i:null}async refresh(){const t=++this.refreshGeneration;if(!this.isEnabled())return this.stopLoading(),void(this.canRender=!1);if(0===this.cartItemCount)return this.stopLoading(),void(S()||(this.deferredByEmptyCart=!0,this.loadCart()));this.deferredByEmptyCart=!1,this.offer?this.stopLoading():this.startLoading();try{const i=await this.fetchOffer();if(this.isSuperseded(t))return;if(!i)return this.offer=null,void(this.canRender=!1);this.offer=i,this.canRender=!0,this.loadCart(),this.loadFreeProductCards()}catch(i){if(this.isSuperseded(t))return;this.safeLog("offers() failed",i)}finally{t===this.refreshGeneration&&this.stopLoading()}}hasCartItems(){return"number"==typeof this.cartItemCount&&this.cartItemCount>=1}isSuperseded(t){return t!==this.refreshGeneration||this.isDisconnected}loadCart(){const t=++this.giftsGeneration;return Promise.all([(w(),f&&d?Promise.resolve(d):P().then((()=>d??s))),(w(),f&&d?Promise.resolve(h):P().then((()=>h))),(w(),f&&d?Promise.resolve(c??a):P().then((()=>c??a)))]).then((([i,e,r])=>{if(t!==this.giftsGeneration||this.isDisconnected)return;if(this.cartRefreshPending)return;const o=S();null!==e&&(this.cartItemCount=e),null!==e?this.clearCartLookupRetry():null===this.cartItemCount&&this.scheduleCartLookupRetry(),this.deferredByEmptyCart&&this.hasCartItems()&&(this.deferredByEmptyCart=!1,this.refresh());const n=null!==this.getPickerStage(this.getStages()),s=null!==this.pendingFreeProductSettledAt||null!==this.cartPageCheckAfter;o||!n&&!s?(this.clearPickerLookupRetry(),this.gifts=this.offer?this.selectOwnGifts(i):[],this.cartLines=this.offer?r:[],this.cartLinesLoaded=!!this.offer,null!==this.pendingFreeProductSettledAt&&t>this.pendingFreeProductSettledAt&&this.unlockFreeProduct(),null!==this.cartPageCheckAfter&&t>this.cartPageCheckAfter&&(this.cartPageCheckAfter=null,this.showMissingCartLines(r))):(s||!this.cartLinesLoaded&&this.hasCartItems())&&this.retryPickerCartLookup()})).catch((t=>{this.safeLog("cart lookup failed",t)}))}scheduleCartLookupRetry(){this.cartLookupRetries>=V.length||(this.cartLookupRetryPending=!0,null!==this.cartLookupRetryTimer||this.isDisconnected||(this.cartLookupRetryTimer=setTimeout((()=>{this.cartLookupRetryTimer=null,this.cartLookupRetryPending=!1,this.canRender&&(this.cartLookupRetries++,this.loadCart())}),V[this.cartLookupRetries])))}retryPickerCartLookup(){null!==this.pickerLookupTimer||this.pickerLookupRetries>=V.length||(this.pickerLookupTimer=setTimeout((()=>{this.pickerLookupTimer=null,this.pickerLookupRetries++,this.loadCart()}),V[this.pickerLookupRetries]))}clearPickerLookupRetry(){this.pickerLookupRetries=0,null!==this.pickerLookupTimer&&(clearTimeout(this.pickerLookupTimer),this.pickerLookupTimer=null)}clearCartLookupRetry(){this.cartLookupRetries=0,this.cartLookupRetryPending=!1,null!==this.cartLookupRetryTimer&&(clearTimeout(this.cartLookupRetryTimer),this.cartLookupRetryTimer=null)}selectOwnGifts(t){const i=Number(this.offer?.id);if(!Number.isFinite(i))return t;const e=t.filter((t=>null!==t.offerId&&Number(t.offerId)===i));return e.length?e:t.filter((t=>null===t.offerId))}getStages(){const t=(this.offer?.details?.discounts??[]).filter((({min_spend:t})=>null!==F(t)));return i=({min_spend:t})=>t,e=({id:t})=>t,(t??[]).map(((t,r)=>({item:t,index:r,threshold:N(i(t)),identity:e?F(e(t)):null}))).sort(((t,i)=>t.threshold!==i.threshold?t.threshold-i.threshold:null!==t.identity&&null!==i.identity&&t.identity!==i.identity?t.identity-i.identity:t.index-i.index)).map((({item:t})=>t));var i,e}getProgress(t){return function(t,i,e=0,r=[],o=[],n=[]){const s=(i??[]).map(((t,i)=>({index:i,threshold:F(t),applied:I(r?.[i]),tierValue:F(o?.[i]),canAddFree:"boolean"==typeof n?.[i]?n[i]:void 0}))).filter((t=>null!==t.threshold)).sort(((t,i)=>t.threshold-i.threshold||t.index-i.index)),a=s.map((t=>t.threshold)),l=s.map((t=>t.applied)),c=l.some((t=>void 0!==t)),d=N(e);if(!a.length)return{thresholds:a,met:[],applied:l,appliedIndex:z,hasEngineVerdict:c,metCount:0,nextUnmetIndex:z,allMet:!1,lastReachedIndex:z,currentIndex:z,isComplete:!1,value:Math.max(0,N(t)),values:[],startValue:d,fills:[],overallPercentage:0};const h=a[a.length-1],f=R(N(t),0,Math.max(0,h)),u=s.map((({tierValue:t})=>null===t?f:R(t,0,Math.max(0,h))));let p=z;for(let t=0;t<a.length;t++)u[t]>=a[t]&&(p=t);const g=p===a.length-1,m=g?z:p+1,b=a.map(((t,i)=>function(t,i,e){return e<=i?t>=e?100:0:R((t-i)/(e-i)*100,0,100)}(u[i],0===i?d:a[i-1],t))),w=g?100:R((p+1+(b[m]??0)/100)/a.length*100,0,100);let y=z;for(let t=0;t<l.length;t++)!0===l[t]&&(y=t);let x=z;for(let t=0;t<a.length;t++){const i=s[t].canAddFree;(void 0===i?u[t]>=a[t]:i)&&(x=t)}const v=a.map(c?(t,i)=>i<=y:(t,i)=>i<=x),k=v.filter(Boolean).length,_=v.findIndex((t=>!t));return{thresholds:a,met:v,applied:l,appliedIndex:y,hasEngineVerdict:c,metCount:k,nextUnmetIndex:_,allMet:_===z,lastReachedIndex:p,currentIndex:m,isComplete:g,value:f,values:u,startValue:d,fills:b,overallPercentage:w}}(this.offer?.details?.current_value,t.map((({min_spend:t})=>t)),this.offer?.details?.start_value,t.map((({is_applied:t})=>t)),t.map((({current_value:t})=>t)),t.map((({can_add_free:t})=>t)))}tierKey(t,i){const e=Number(t?.id);return Number.isFinite(e)?`tier-${e}`:`pos-${i}`}stageMeasure(){return this.offer?.details?.based_on===n.PRODUCT_COUNT?$.COUNT:$.CURRENCY}formatRequirement(t){const i=this.offer?.details?.based_on;if(i===n.PRODUCT_COUNT)try{return salla.lang.choice("blocks.header.products_count",t)}catch(i){return this.safeLog("invalid products_count interval",i),`${t}`}return i===n.PRODUCT_PURCHASE?salla.money(t):(this.safeLog(`unexpected offer detail's based_on value: ${i}`),`${t}`)}getRewardText(t){if(this.isPickerTier(t)){const i=Math.max(1,Math.floor(Number(t.max_free_products)||1));return 1===i?this.trans("free_product_reward_one"):2===i?this.trans("free_products_reward_two"):this.trans("free_products_reward",{count:`${i}`})}return(t?.reward_label??"").trim()}getGuidanceMessage(t,i){if(i.nextUnmetIndex===z)return"";const e=Number(t[i.nextUnmetIndex]?.amount_needed),r=this.isPickerTier(t[i.nextUnmetIndex])&&Number.isFinite(e)&&e>0?e:function(t,i,e=$.CURRENCY){const r=i.thresholds[t];if(void 0===r)return 0;const o=Math.max(0,r-(i.values?.[t]??i.value));if(0===o)return 0;const n=e===$.COUNT?0:function(){try{const t="undefined"!=typeof salla?salla:void 0,i=j(t?.config?.currency?.()?.decimals);if(null!==i)return i;const e=j(t?.config?.get?.("store.currency.decimals"));if(null!==e)return e}catch(t){}return 2}(),s=Math.pow(10,n),a=Math.ceil(o*s-1e-6)/s;return a>0?a:1/s}(i.nextUnmetIndex,i,this.stageMeasure());if(r<=0)return this.trans("guidance_conditions_unmet");const o=this.formatRequirement(r),n=this.getRewardText(t[i.nextUnmetIndex]);return n?this.trans("guidance_next",{remaining:o,reward:G(n)}):this.trans("guidance_next_generic",{remaining:o})}getTierSentence(t,i,e){const r=this.formatRequirement(e.thresholds[i]),o=this.getRewardText(t),n=this.stageMeasure()===$.COUNT;return o?this.trans(n?"tier_requirement_count":"tier_requirement",{threshold:r,reward:G(o)}):this.trans(n?"tier_requirement_count_generic":"tier_requirement_generic",{threshold:r})}getRewardIcon(t){switch(t?.type){case o.PERCENTAGE:return"sicon-percentage";case o.FREE_PRODUCT:return"sicon-gift";case o.FIXED:return this.usesSarSymbol()?"sicon-sar":"sicon-banknote";default:return"sicon-tag"}}usesSarSymbol(){try{const t=salla.config.currency?.()?.symbol;return["SAR","ر.س"].includes(t)&&!!salla.config.get("store.settings.use_sar_symbol")}catch(t){return!1}}get isTooltipOpen(){return this.isTooltipHovered||this.isTooltipPinned}toggleTooltip(){this.isTooltipPinned=!this.isTooltipPinned}closeTooltip(t=!1){this.isTooltipOpen&&(this.isTooltipPinned=!1,this.isTooltipHovered=!1,t&&this.infoTriggerEl?.focus?.())}positionTooltip(){const t=this.tooltipEl,i=this.infoTriggerEl;if(this.isTooltipOpen&&t&&i)try{this.setTooltipOffsets(t,0,0);const e=window.innerWidth||document.documentElement?.clientWidth||0,r=t.getBoundingClientRect(),o=i.getBoundingClientRect(),n=r?.width||0;if(n<=0||e<=0)return;const s=o.left+o.width/2-n/2,a=8,l=Math.min(Math.max(s,a),Math.max(a,e-a-n))-s,c=Math.max(0,n/2-16),d=Math.min(Math.max(-l,-c),c);this.setTooltipOffsets(t,l,d)}catch(t){this.safeLog("positioning the offer details popover failed",t)}}setTooltipOffsets(t,i,e){t.style?.setProperty?.("--s-conditional-offer-tooltip-shift",`${Math.round(i)}px`),t.style?.setProperty?.("--s-conditional-offer-tooltip-caret",`${Math.round(e)}px`)}handleWindowResize(){this.positionTooltip()}handleDocumentKeydown(t){"Escape"!==t.key&&"Esc"!==t.key||this.closeTooltip(!0)}handleDocumentClick(t){if(!this.isTooltipPinned||!this.infoAnchorEl)return;const i="function"==typeof t.composedPath?t.composedPath():[];(i.length?i.includes(this.infoAnchorEl):this.infoAnchorEl.contains(t.target))||this.closeTooltip()}elementId(t){return`s-conditional-offer-${t}-${this.instanceId}`}renderBadges(t,e){return i("div",{class:"s-conditional-offer-badges",role:"img","aria-label":this.trans("badges_summary",{completed:`${e.metCount}`,total:`${t.length}`})},t.map(((t,r)=>{const o=e.met[r],n=this.tierKey(t,r);return[r>0?i("span",{key:`${n}-link`,class:{"s-conditional-offer-badge-link":!0,"s-conditional-offer-badge-link-met":o,"s-conditional-offer-badge-link-unmet":!o},"aria-hidden":"true"}):null,i("span",{key:n,class:{"s-conditional-offer-badge":!0,"s-conditional-offer-badge-met":o,"s-conditional-offer-badge-unmet":!o},"data-tier-state":o?"met":"unmet","data-tier-id":t?.id??void 0},i(o?Y:E,{class:"s-conditional-offer-badge-icon"}))]})))}renderTooltip(t,e){const r=function(t){const i=t?.details?.rules;if("string"==typeof i){const t=i.trim();return""===t?null:t}if(Array.isArray(i)){const t=i.filter((t=>"string"==typeof t)).map((t=>t.trim())).filter((t=>""!==t)).join(" ");return""===t?null:t}return null}(this.offer);return i("div",{class:"s-conditional-offer-tooltip",id:this.elementId("tooltip"),role:"tooltip",ref:t=>this.tooltipEl=t},i("div",{class:"s-conditional-offer-tooltip-title"},this.offer?.title),r?i("div",{class:"s-conditional-offer-tooltip-description"},r):null,i("ul",{class:"s-conditional-offer-tooltip-list"},t.map(((t,r)=>{const o=e.met[r];return i("li",{key:this.tierKey(t,r),class:"s-conditional-offer-tier","data-tier-state":o?"met":"unmet","data-tier-id":t?.id??void 0},i("span",{class:{"s-conditional-offer-tier-icon":!0,"s-conditional-offer-tier-icon-met":o,"s-conditional-offer-tier-icon-unmet":!o}},i("i",{class:this.getRewardIcon(t),"aria-hidden":"true"}),i("span",{class:{"s-conditional-offer-tier-status":!0,"s-conditional-offer-tier-status-met":o,"s-conditional-offer-tier-status-unmet":!o},"aria-hidden":"true"},o?i(Y,{class:"s-conditional-offer-tier-status-check"}):i(E,{class:"s-conditional-offer-tier-status-lock"}))),i("div",{class:"s-conditional-offer-tier-body"},i("div",{class:"s-conditional-offer-tier-title"},this.trans("tier_title",{number:`${r+1}`})),i("div",{class:{"s-conditional-offer-tier-text":!0,"s-conditional-offer-tier-text-met":o},innerHTML:this.getTierSentence(t,r,e)})))}))))}getPickerStage(t){return t.find((t=>this.isPickerTier(t)))??null}isPickerTier(t){return t?.type===o.FREE_PRODUCT&&Array.isArray(t.free_products)&&t.free_products.length>0}areGiftsUnavailable(t,i){const e=t[i.lastReachedIndex];return e?.type===o.FREE_PRODUCT&&Array.isArray(e.free_products)&&0===e.free_products.length&&0===this.gifts.length}loadFreeProductCards(){const t=this.getPickerStage(this.getStages()),i=(t?.free_products??[]).map((t=>String(t.id))).filter((t=>t&&!this.freeProductCards[t]));if(!i.length)return Promise.resolve();const e=new Set((t.free_products??[]).map((t=>String(t.id))));return Promise.resolve().then((()=>salla.product.fetch({source:"selected",source_value:i}))).then((t=>{if(this.isDisconnected)return;const i={...this.freeProductCards};(Array.isArray(t?.data)?t.data:[]).forEach((t=>{const r=String(t?.id??"");r&&e.has(r)&&(i[r]={id:r,name:String(t.name??""),imageUrl:String(t.image?.url??""),imageAlt:String(t.image?.alt??t.name??""),price:Number.isFinite(Number(t.price))?Number(t.price):null})})),this.freeProductCards=i})).catch((t=>this.safeLog("free product lookup failed",t)))}getPickerState(t){const i=this.cartLines.filter((t=>t.freeQuantity>0)),e=this.selectOwnFreeLines(i),r=new Set(e.map((t=>t.productId)).filter((t=>null!==t))),o=Math.max(1,Math.floor(Number(t.max_free_products)||1)),n=Number(t.current_value??this.offer?.details?.current_value??0);return{limit:o,reached:"boolean"==typeof t.can_add_free?t.can_add_free:Number.isFinite(n)&&n>=Number(t.min_spend),freeCount:r.size}}selectOwnFreeLines(t){const i=Number(this.offer?.id);if(!Number.isFinite(i))return t;const e=t.filter((t=>null!==t.offerId&&Number(t.offerId)===i));return e.length?e:t.filter((t=>null===t.offerId))}addFreeProduct(t){this.pendingFreeProduct||(this.pendingFreeProduct=t.id,this.runFreeProductChange((()=>Promise.resolve(salla.cart.addItem(t.id)).then((()=>{this.cartPageCheckAfter=this.giftsGeneration}))),"free product add failed"))}reloadPage(){window.location.reload()}fetchCartPageHtml(){const t=new AbortController,i=setTimeout((()=>t.abort()),8e3);return fetch(window.location.href,{cache:"no-store",credentials:"same-origin",headers:{Accept:"text/html"},signal:t.signal}).then((t=>t.ok?t.text():Promise.reject(new Error(`cart page ${t.status}`)))).finally((()=>clearTimeout(i)))}showMissingCartLines(t){this.insertingCartLines?this.pendingCartPageLines=t:this.missingCartLineIds(t).length&&(this.insertingCartLines=!0,Promise.resolve().then((()=>this.fetchCartPageHtml())).then((t=>{if(this.isDisconnected||this.cartChangedDuringPageFetch())return;const i=this.missingCartLineIds(this.cartLines);i.length&&!this.insertCartLineForms(t,i)&&this.reloadForMissingCartLines(i)})).catch((t=>{this.safeLog("cart page fetch for the new lines failed, reloading",t),this.isDisconnected||this.cartChangedDuringPageFetch()||this.reloadForMissingCartLines(this.missingCartLineIds(this.cartLines))})).finally((()=>{this.insertingCartLines=!1;const t=this.pendingCartPageLines;this.pendingCartPageLines=null,t&&!this.isDisconnected&&this.showMissingCartLines(t)})))}cartChangedDuringPageFetch(){return!(null===this.pendingFreeProduct&&this.cartLinesLoaded||(null===this.cartPageCheckAfter&&(this.cartPageCheckAfter=this.giftsGeneration),0))}missingCartLineIds(t){try{return document.querySelector(O)?t.map((t=>t.id)).filter((t=>!document.getElementById(`item-${t}`))).sort():[]}catch(t){return this.safeLog("cart page check after a free product add failed",t),[]}}insertCartLineForms(t,i){try{const e=Array.from((new DOMParser).parseFromString(t,"text/html").querySelectorAll(O)),r=e.map((t=>t.getAttribute("id")));return!i.some((t=>!r.includes(`item-${t}`)))&&(e.forEach(((t,e)=>{const o=r[e];if(!i.includes(o.slice(5))||document.getElementById(o))return;const n=r.slice(e+1).map((t=>document.getElementById(t))).find(Boolean);if(n)n.parentNode.insertBefore(t,n);else{const i=document.querySelectorAll(O),e=i[i.length-1];e.parentNode.insertBefore(t,e.nextSibling)}})),i.every((t=>document.getElementById(`item-${t}`))))}catch(t){return this.safeLog("cart line insert failed",t),!1}}reloadForMissingCartLines(t){if(!t.length)return;const i=t.join(","),e=this.readReloadGuard();e!==i&&(void 0===e&&this.pageWasReloaded()||(this.writeReloadGuard(i),this.reloadPage()))}readReloadGuard(){try{return window.sessionStorage.getItem(H)}catch{return}}writeReloadGuard(t){try{window.sessionStorage.setItem(H,t)}catch{}}pageWasReloaded(){try{const t=window.performance?.getEntriesByType?.("navigation")?.[0];return"reload"===t?.type}catch{return!1}}runFreeProductChange(t,i){Promise.resolve().then(t).then((()=>{if(this.isDisconnected)return this.unlockFreeProduct();this.pendingFreeProductSettledAt=this.giftsGeneration,this.pendingFreeProductTimer=setTimeout((()=>this.unlockOnStaleLines()),5e3)})).catch((t=>{this.safeLog(i,t),this.unlockFreeProduct(),null!==this.cartPageCheckAfter&&this.loadCart()}))}unlockOnStaleLines(){this.unlockFreeProduct(),this.cartLinesLoaded=!1,this.clearPickerLookupRetry(),T().then((()=>this.loadCart()),(()=>this.loadCart()))}unlockFreeProduct(){null!==this.pendingFreeProductTimer&&clearTimeout(this.pendingFreeProductTimer),this.pendingFreeProductTimer=null,this.pendingFreeProductSettledAt=null,this.pendingFreeProduct=null}pickerGotMessage(t,i){return 1===t?this.trans(i?"free_product_got_pick_one":"free_product_got_one"):2===t?this.trans(i?"free_products_got_pick_two":"free_products_got_two"):this.trans(i?"free_products_got_pick":"free_products_got",{count:`${t}`})}getPickerCards(t){return(t.free_products??[]).map((t=>this.freeProductCards[String(t.id)])).filter(Boolean)}renderPicker(t){const e=this.getPickerState(t),r=this.getPickerCards(t);return r.length?i("div",{class:"s-conditional-offer-picker","data-picker-reached":e.reached?"true":"false"},i("div",{class:"s-conditional-offer-picker-header"},i("span",{class:"s-conditional-offer-picker-counter","aria-label":`${e.freeCount}/${e.limit}`},`${e.freeCount}/${e.limit}`),i("span",{class:"s-conditional-offer-picker-title"},1===e.limit?this.trans("free_product_choose_one"):2===e.limit?this.trans("free_products_choose_two"):this.trans("free_products_choose",{count:`${e.limit}`}))),i("ul",{class:"s-conditional-offer-picker-list"},r.map((t=>this.renderPickerCard(t))))):null}renderPickerCard(t){return i("li",{class:"s-conditional-offer-picker-card","data-product-id":t.id},i("span",{class:"s-conditional-offer-picker-thumb"},t.imageUrl?i("img",{class:"s-conditional-offer-picker-image",src:t.imageUrl,alt:t.imageAlt||t.name,loading:"lazy",decoding:"async"}):i("i",{class:"sicon-gift","aria-hidden":"true"})),i("span",{class:"s-conditional-offer-picker-name"},t.name),null!==t.price?i("span",{class:"s-conditional-offer-picker-prices"},i("span",{class:"s-conditional-offer-picker-price-regular",innerHTML:salla.money(t.price)})):null,i("span",{class:"s-conditional-offer-picker-actions"},i("button",{type:"button",class:"s-conditional-offer-picker-add",onClick:()=>this.addFreeProduct(t)},this.getAddLabel())))}renderGiftsToggle(t,e){return i("button",{type:"button",id:this.elementId(`toggle-${t}`),class:{"s-conditional-offer-toggle":!0,"s-conditional-offer-toggle-inline":"inline"===t,"s-conditional-offer-toggle-bar":"bar"===t},"aria-expanded":this.isGiftsOpen?"true":"false","aria-controls":this.elementId("gifts"),onClick:()=>this.isGiftsOpen=!this.isGiftsOpen},i("span",null,this.trans(e?"offer_toggle":"manage_offer")),i("i",{class:{"sicon-keyboard_arrow_down":!0,"s-conditional-offer-toggle-icon":!0,"s-conditional-offer-toggle-icon-open":this.isGiftsOpen},"aria-hidden":"true"}))}renderGiftsCard(t=null){if(!t)return i("div",{class:"s-conditional-offer-panel",id:this.elementId("gifts")},i("div",{class:"s-conditional-offer-gifts-header"},i("span",{class:"s-conditional-offer-gifts-icon"},i("i",{class:"sicon-gift","aria-hidden":"true"})),i("span",{class:"s-conditional-offer-gifts-title"},this.trans("free_products_title"))),i("ul",{class:"s-conditional-offer-gifts-list"},this.gifts.map((t=>this.renderGiftRow(t)))));const e=this.getPickerState(t);return i("div",{class:"s-conditional-offer-panel",id:this.elementId("gifts")},e.reached?this.renderPicker(t):null,this.gifts.length?i("div",{class:"s-conditional-offer-gifts"},i("div",{class:"s-conditional-offer-gifts-header"},i("span",{class:"s-conditional-offer-gifts-icon"},i("i",{class:"sicon-gift","aria-hidden":"true"})),i("span",{class:"s-conditional-offer-gifts-title"},this.sharedLabel("pages.loyalty_program.free_product_title","Free products"))),i("ul",{class:"s-conditional-offer-gifts-list"},this.gifts.map((t=>this.renderGiftRow(t))))):null)}renderGiftRow(t){return i("li",{class:"s-conditional-offer-gift","data-item-id":t.id},i("span",{class:"s-conditional-offer-gift-thumb"},t.imageUrl?i("img",{class:"s-conditional-offer-gift-image",src:t.imageUrl,alt:t.imageAlt||t.name,loading:"lazy",decoding:"async"}):i("i",{class:"sicon-gift","aria-hidden":"true"})),i("div",{class:"s-conditional-offer-gift-body"},i("span",{class:"s-conditional-offer-gift-name"},t.name||this.trans("free_gift")),i("span",{class:"s-conditional-offer-gift-prices"},i("span",{class:"s-conditional-offer-gift-free"},this.getFreeLabel()),null!==t.originalPrice?i("span",{class:"s-conditional-offer-gift-price",innerHTML:salla.money(t.originalPrice)}):null)))}getLoadingSkeletonView(){return i(e,{class:"s-conditional-offer-root"},i("div",{class:"s-conditional-offer-banner"},i("div",{class:"s-conditional-offer-lead"},i("salla-skeleton",{height:"24px",width:"80px"}),i("div",{class:"s-conditional-offer-skeleton-text"},i("salla-skeleton",{height:"12px",width:"35%"}),i("salla-skeleton",{height:"16px",width:"60%"})))))}render(){if(!this.canRender)return null;if(!this.hasCartItems())return null;if(this.isLoading)return this.getLoadingSkeletonView();if(!this.offer)return null;const t=this.getStages(),r=this.getProgress(t),o=this.getGuidanceMessage(t,r),n=this.trans("details_title"),s=this.getPickerStage(t),a=null!==s?this.getPickerState(s):null,l=a?.reached??!1,c=this.gifts.length>0||l&&this.getPickerCards(s).length>0,d=l&&this.cartLinesLoaded&&0===a.freeCount,h=r.allMet&&l&&a.freeCount>0&&t[t.length-1]===s;return i(e,{class:"s-conditional-offer-root"},i("div",{class:"s-conditional-offer-banner"},i("div",{class:"s-conditional-offer-lead"},this.renderBadges(t,r),i("div",{class:"s-conditional-offer-text"},i("div",{class:"s-conditional-offer-heading",onMouseEnter:()=>this.isTooltipHovered=!0,onMouseLeave:()=>this.isTooltipHovered=!1},i("span",{class:"s-conditional-offer-name"},this.offer.title),i("span",{class:"s-conditional-offer-info",ref:t=>this.infoAnchorEl=t},i("button",{type:"button",class:"s-conditional-offer-info-trigger",ref:t=>this.infoTriggerEl=t,"aria-label":n,title:n,"aria-expanded":this.isTooltipOpen?"true":"false","aria-describedby":this.elementId("tooltip"),onClick:()=>this.toggleTooltip()},i(W,{class:"s-conditional-offer-info-icon"})),this.isTooltipOpen?this.renderTooltip(t,r):null)),d||h?i("div",{class:"s-conditional-offer-message",role:"status"},this.pickerGotMessage(a.limit,d)):this.areGiftsUnavailable(t,r)?i("div",{class:"s-conditional-offer-message",role:"status"},this.trans("free_products_unavailable")):r.allMet?i("div",{class:"s-conditional-offer-message",role:"status"},this.trans("congrats")):o?i("div",{class:"s-conditional-offer-message",innerHTML:o}):null)),c?this.renderGiftsToggle("inline",!!s):null),c&&this.isGiftsOpen?this.renderGiftsCard(s):null,c?this.renderGiftsToggle("bar",!!s):null)}get hostEl(){return r(this)}};Z.style='/*!twlt*/:host{display:block}.s-conditional-offer-root{background-color:rgba(0, 137, 123, 0.06);background-color:color-mix(in srgb, var(--color-primary, #00897b) 7%, transparent)}.s-conditional-offer-badges::-webkit-scrollbar{height:3px}.s-conditional-offer-badges::-webkit-scrollbar-thumb{border-radius:9999px;background-color:rgba(0, 0, 0, 0.15)}.s-conditional-offer-badges::-webkit-scrollbar-track{background-color:transparent}.s-conditional-offer-tooltip{--s-conditional-offer-tooltip-shift:0px;--s-conditional-offer-tooltip-caret:0px;transform:translateX(calc(-50% + var(--s-conditional-offer-tooltip-shift)))}.s-conditional-offer-tooltip::before{content:"";position:absolute;bottom:100%;left:50%;transform:translateX(calc(-50% + var(--s-conditional-offer-tooltip-caret)));border:8px solid transparent;border-bottom-color:#fff}.s-conditional-offer-tier-icon-met,.s-conditional-offer-tier-icon-unmet{color:var(--color-primary-dark, #00695c);background-color:rgba(0, 137, 123, 0.12);background-color:color-mix(in srgb, var(--color-primary, #00897b) 14%, transparent)}.s-conditional-offer-tier:not(:last-child)::before{content:"";position:absolute;top:2.5rem;bottom:-1rem;inset-inline-start:1.125rem;width:1px;background-color:#d1d5db}.visible{visibility:visible}.invisible{visibility:hidden}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.block{display:block}.inline{display:inline}.flex{display:flex}.hidden{display:none}.w-6{width:1.5rem}.resize{resize:both}.gap-1{gap:0.25rem}.rounded{border-radius:var(--s-radius, 0.25rem)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.s-conditional-offer-root{margin-bottom:1.25rem;display:block;width:100%;min-width:0px;max-width:100%;border-radius:0.375rem;padding:0.75rem}@media (min-width: 768px){.s-conditional-offer-root{padding:1rem}}.s-conditional-offer-banner{display:flex;width:100%;min-width:0px;align-items:center;justify-content:space-between;gap:0.75rem}@media (min-width: 768px){.s-conditional-offer-banner{gap:1rem}}.s-conditional-offer-lead{display:flex;min-width:0px;flex:1 1 0%;align-items:center;gap:0.5rem}@media (min-width: 768px){.s-conditional-offer-lead{gap:0.75rem}}.s-conditional-offer-badges{display:flex;max-width:45%;flex-shrink:0;flex-wrap:nowrap;align-items:center;gap:0.25rem;overflow-x:auto;overscroll-behavior-x:contain;scroll-behavior:smooth;scrollbar-width:thin}.s-conditional-offer-badge{display:inline-flex;height:1.5rem;width:1.5rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;font-size:11px;line-height:1;--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.s-conditional-offer-badge-met{background-color:var(--color-primary)}.s-conditional-offer-badge-unmet{--tw-bg-opacity:1;background-color:rgb(156 163 175 / var(--tw-bg-opacity, 1))}.s-conditional-offer-badge-link{width:0.5rem;flex-shrink:0;border-top-width:1px}.s-conditional-offer-badge-link-met{border-color:var(--color-primary)}.s-conditional-offer-badge-link-unmet{border-style:dashed;--tw-border-opacity:1;border-color:rgb(82 82 82 / var(--tw-border-opacity, 1))}.s-conditional-offer-badge-icon{height:0.75rem;width:0.75rem;flex-shrink:0}.s-conditional-offer-text{display:flex;min-width:0px;flex-direction:column;gap:0.125rem;text-align:start}.s-conditional-offer-heading{display:flex;min-width:0px;align-items:center;gap:0.375rem}.s-conditional-offer-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:0.75rem;line-height:1rem;--tw-text-opacity:1;color:rgb(82 82 82 / var(--tw-text-opacity, 1))}.s-conditional-offer-info{position:relative;display:inline-flex;flex-shrink:0;align-items:center}.s-conditional-offer-info-trigger{display:inline-flex;height:1rem;width:1rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;--tw-text-opacity:1;color:rgb(115 115 115 / var(--tw-text-opacity, 1));transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-conditional-offer-info-trigger:hover{color:var(--color-primary-dark)}.s-conditional-offer-info-icon{height:0.875rem;width:0.875rem;flex-shrink:0}.s-conditional-offer-message{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark)}@media (min-width: 768px){.s-conditional-offer-message{font-size:1rem;line-height:1.5rem}}.s-conditional-offer-toggle{align-items:center;justify-content:center;gap:0.375rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(38 38 38 / var(--tw-text-opacity, 1));transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-conditional-offer-toggle:hover{color:var(--color-primary-dark)}.s-conditional-offer-toggle-inline{display:none;flex-shrink:0}@media (min-width: 768px){.s-conditional-offer-toggle-inline{display:inline-flex}}.s-conditional-offer-toggle-bar{margin-top:0.5rem;display:inline-flex;width:100%;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding-left:0.75rem;padding-right:0.75rem;padding-top:0.625rem;padding-bottom:0.625rem}@media (min-width: 768px){.s-conditional-offer-toggle-bar{display:none}}.s-conditional-offer-toggle-icon{font-size:1rem;line-height:1.5rem;line-height:1;transition-property:transform;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-conditional-offer-toggle-icon-open{--tw-rotate:180deg;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.s-conditional-offer-panel{margin-top:0.75rem;width:100%;min-width:0px;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:0.75rem}.s-conditional-offer-gifts-header{margin-bottom:0.75rem;display:flex;align-items:center;gap:0.5rem}.s-conditional-offer-gifts-icon{display:inline-flex;height:2rem;width:2rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;border-width:1px;border-color:var(--color-primary);font-size:1rem;line-height:1.5rem;line-height:1;color:var(--color-primary)}.s-conditional-offer-gifts-title{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-gifts-list{margin:0px;display:flex;list-style-type:none;flex-direction:column;gap:0.5rem;padding:0px}.s-conditional-offer-gift{display:flex;align-items:center;gap:0.75rem;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));padding:0.5rem}.s-conditional-offer-gift-thumb{display:inline-flex;height:3.5rem;width:3.5rem;flex-shrink:0;align-items:center;justify-content:center;overflow:hidden;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.s-conditional-offer-gift-image{height:100%;width:100%;object-fit:contain}.s-conditional-offer-gift-body{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.125rem;text-align:start}.s-conditional-offer-gift-name{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;font-size:0.875rem;line-height:1.25rem;font-weight:700;--tw-text-opacity:1;color:rgb(38 38 38 / var(--tw-text-opacity, 1))}.s-conditional-offer-gift-prices{display:flex;align-items:center;gap:0.5rem;font-size:0.75rem;line-height:1rem}.s-conditional-offer-gift-free{font-weight:700;--tw-text-opacity:1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.s-conditional-offer-gift-price{--tw-text-opacity:1;color:rgb(115 115 115 / var(--tw-text-opacity, 1));text-decoration-line:line-through}.s-conditional-offer-gifts{margin-top:0.75rem;width:100%;min-width:0px;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding:0.75rem}.s-conditional-offer-picker{display:flex;width:100%;min-width:0px;flex-direction:column;gap:0.75rem}.s-conditional-offer-picker-header{display:flex;align-items:center;gap:0.5rem}.s-conditional-offer-picker-counter{display:inline-flex;height:2.25rem;width:2.25rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;border-width:2px;border-color:var(--color-primary);font-size:0.75rem;line-height:1rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-picker-title{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-picker-list{margin:0px;display:flex;list-style-type:none;gap:0.75rem;overflow-x:auto;overscroll-behavior-x:contain;scroll-behavior:smooth;padding:0px;padding-bottom:0.25rem;scrollbar-width:thin}.s-conditional-offer-picker-card{display:flex;width:9rem;flex-shrink:0;flex-direction:column;gap:0.375rem;text-align:start}.s-conditional-offer-picker-thumb{display:inline-flex;height:7rem;width:100%;align-items:center;justify-content:center;overflow:hidden;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));font-size:1.5rem;line-height:2rem;--tw-text-opacity:1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.s-conditional-offer-picker-image{height:100%;width:100%;object-fit:contain}.s-conditional-offer-picker-name{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(38 38 38 / var(--tw-text-opacity, 1))}.s-conditional-offer-picker-prices{display:flex;align-items:center;gap:0.5rem;font-size:0.75rem;line-height:1rem}.s-conditional-offer-picker-price-regular{font-weight:700;--tw-text-opacity:1;color:rgb(23 23 23 / var(--tw-text-opacity, 1))}.s-conditional-offer-picker-actions{margin-top:auto;display:flex;width:100%;align-items:center;gap:0.375rem}.s-conditional-offer-picker-add{display:inline-flex;height:2.25rem;flex:1 1 0%;align-items:center;justify-content:center;border-radius:0.375rem;border-width:1px;border-color:var(--color-primary);font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark);transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-conditional-offer-picker-add:hover{background-color:var(--color-primary);--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.s-conditional-offer-tooltip{position:absolute;top:calc(100% + 0.75rem);left:50%;z-index:10;width:min(22rem, calc(100vw - 2rem));border-radius:0.5rem;--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1rem;text-align:start;--tw-shadow:5px 10px 30px #2B2D340D;--tw-shadow-colored:5px 10px 30px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.s-conditional-offer-tooltip-title{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-tooltip-description{margin-top:0.25rem;font-size:0.75rem;line-height:1rem;line-height:1.625;--tw-text-opacity:1;color:rgb(82 82 82 / var(--tw-text-opacity, 1))}.s-conditional-offer-tooltip-list{margin:0px;margin-top:0.75rem;display:flex;list-style-type:none;flex-direction:column;gap:1rem;padding:0px}.s-conditional-offer-tier{position:relative;display:flex;align-items:flex-start;gap:0.75rem}.s-conditional-offer-tier-icon{position:relative;display:inline-flex;height:2.25rem;width:2.25rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;font-size:1rem;line-height:1.5rem;line-height:1}.s-conditional-offer-tier-icon-unmet{color:var(--color-primary-dark)}.s-conditional-offer-tier-status{position:absolute;bottom:-0.125rem;display:inline-flex;height:1rem;width:1rem;align-items:center;justify-content:center;border-radius:9999px;border-width:2px;--tw-border-opacity:1;border-color:rgb(255 255 255 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));inset-inline-start:-2px}.s-conditional-offer-tier-status-met{color:var(--color-primary-dark)}.s-conditional-offer-tier-status-unmet{--tw-text-opacity:1;color:rgb(163 163 163 / var(--tw-text-opacity, 1))}.s-conditional-offer-tier-status-check{height:0.75rem;width:0.75rem;flex-shrink:0}.s-conditional-offer-tier-status-lock{height:0.625rem;width:0.625rem;flex-shrink:0}.s-conditional-offer-tier-body{display:flex;min-width:0px;flex-direction:column;gap:0.125rem}.s-conditional-offer-tier-title{font-size:0.75rem;line-height:1rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-tier-text{font-size:0.75rem;line-height:1rem;line-height:1.625;--tw-text-opacity:1;color:rgb(82 82 82 / var(--tw-text-opacity, 1))}.s-conditional-offer-tier-text-met{text-decoration-line:line-through}.s-conditional-offer-skeleton-text{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.375rem}';export{Z as salla_conditional_offer}
4
+ import{r as t,h as i,H as e,a as r}from"./p-DvJClBwJ.js";var o,n;!function(t){t.PERCENTAGE="percentage",t.FIXED="fixed",t.FREE_PRODUCT="free_product",t.FREE_SHIPPING="free_shipping"}(o||(o={})),function(t){t.PRODUCT_COUNT="products_count",t.PRODUCT_PURCHASE="order_amount"}(n||(n={}));const s=Object.freeze([]),a=Object.freeze([]);let l,c=null,d=null,h=null,f=!1,u=null,p=null,g=0;function m(t){return"CartNotCreated"===t?.name}function b(){try{const t=salla.api?.cart?.getStoredCartId?salla.api.cart.getStoredCartId():salla.storage?.get?.("cart.id");return null==t||""===t?null:String(t)}catch(t){return null}}function w(){const t=b();void 0!==l&&l!==t&&(g++,d=null,c=null,h=null,f=!1,u=null),l=t}function y(t){return null==t?0:"number"==typeof t?isFinite(t)?t:0:"string"==typeof t&&parseFloat(t)||0}function x(t){if(null==t||""===t)return null;const i=y(t);return isFinite(i)?i:null}function v(t,i){if(null!==i)return i.length;const e=x(t?.data?.cart?.count??t?.data?.count??t?.cart?.count??t?.count);return null!==e&&e>=0?e:null}function k(t){for(const i of[t?.original_price,t?.product_price,t?.price]){const t=x(i&&"object"==typeof i?i.amount:i);if(null!==t&&t>0)return t}return null}function _(t,i){const e=t?.free_gift_quantity;return null!=e&&""!==e?y(e):i>0?i:0}function C(t){const i=[];for(const e of t){if(null==e?.id)continue;if(!e.added_by_offer)continue;const t=y(e.quantity),r=_(e,t);r<=0||i.push({id:String(e.id),offerId:x(e.offer_id),quantity:r,freeQuantity:r,lineQuantity:t,name:String(e.product_name??e.name??""),imageUrl:String(e.product_image?.url??e.product_image??e.image?.url??""),imageAlt:String(e.product_image?.alt??e.image?.alt??e.product_name??""),url:String(e.url??""),originalPrice:k(e)})}return i}function M(t){const i=[];for(const e of t){if(null==e?.id)continue;const t=y(e.quantity);i.push({id:String(e.id),productId:x(e.product_id),quantity:t,freeQuantity:e.added_by_offer?Math.max(0,_(e,t)):0,offerId:e.added_by_offer?x(e.offer_id):null})}return i}function P(){if(u)return u;const t=g,i=Promise.resolve().then((()=>salla.api?.cart?.details?.())).then((t=>{const i=function(t){const i=t?.data?.cart?.items??t?.data?.items??t?.cart?.items??t?.items;return Array.isArray(i)?i:null}(t),e=i??[];return{gifts:C(e),lines:M(e),count:v(t,i),ok:!0}})).catch((t=>({gifts:d??[],lines:c??[],count:m(t)?0:h,ok:!1}))).then((({gifts:i,lines:e,count:r,ok:o})=>{t===g&&(d=i,c=e,h=r,f=o)})).finally((()=>{u===i&&(u=null)}));return u=i,i}function S(){return w(),f}function T(){if(p)return p;g++,d=null,c=null,h=null,f=!1,l=b();const t=()=>(p===i&&(p=null),P()),i=(u??Promise.resolve()).then(t,t).finally((()=>{p===i&&(p=null)}));return p=i,i}const z=-1;var L,$;function F(t){const i="number"==typeof t?t:parseFloat(t);return Number.isFinite(i)?i:null}function I(t){return"boolean"==typeof t?t:1===t||0===t?1===t:"true"===t||"1"===t||"false"!==t&&"0"!==t&&void 0}function N(t){return F(t)??0}function R(t,i,e){return Math.max(i,Math.min(t,e))}function j(t){const i="number"==typeof t?t:parseFloat(t);if(!Number.isFinite(i))return null;const e=Math.trunc(i);return e>=0&&e<=4?e:null}!function(t){t.LOCKED="locked",t.CURRENT="current",t.COMPLETED="completed"}(L||(L={})),function(t){t.CURRENCY="currency",t.COUNT="count"}($||($={}));const V=[1e3,2e3,4e3],A='[data-testid^="store-cart-item-"], form[id^="item-"]',H="salla-conditional-offer:reloaded-for",O='form[id^="item-"]:not(.cart-options form)';let q=0;const B={badges_summary:":completed of :total offers unlocked",congrats:"Congratulations! You’ve unlocked all rewards in this promotion",details_title:"Offer details",free_gift:"Free Gift",free_products_title:"Free products selected from the offer",free_products_unavailable:"The free products are currently unavailable",free_products_choose:"Choose :count free products",free_products_choose_two:"Choose 2 free products",free_product_choose_one:"Choose your free product",free_product_got_one:"You got a free product",free_product_got_pick_one:"You got a free product! Choose it now",free_products_got:"You got :count free products",free_products_got_pick:"You got :count free products! Choose them now",free_products_got_pick_two:"You got 2 free products! Choose them now",free_products_got_two:"You got 2 free products",free_product_reward_one:"a free product",free_products_reward:":count free products",free_products_reward_two:"2 free products",guidance_conditions_unmet:"Your cart doesn’t meet the conditions for the next reward yet",guidance_next:"Add :remaining and get :reward",guidance_next_generic:"Add :remaining to unlock the next reward",manage_offer:"Manage offer",offer_toggle:"Offer",tier_requirement:"Spend :threshold and get :reward",tier_requirement_count:"Buy :threshold and get :reward",tier_requirement_count_generic:"Buy :threshold to unlock this offer",tier_requirement_generic:"Spend :threshold to unlock this offer",tier_title:"Offer (:number)"},D="pages.checkout.free_charge";function G(t){const i=document.createElement("div");return i.textContent=t??"",i.innerHTML}const Y=(t={})=>i("svg",{class:t.class,viewBox:"0 0 10 10",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false"},i("path",{d:"M5.00016 9.16634C2.69898 9.16634 0.833496 7.30084 0.833496 4.99967C0.833496 2.69849 2.69898 0.833008 5.00016 0.833008C7.30133 0.833008 9.16683 2.69849 9.16683 4.99967C9.16683 7.30084 7.30133 9.16634 5.00016 9.16634ZM4.58458 6.66634L7.53087 3.72006L6.94162 3.13081L4.58458 5.48784L3.40608 4.3093L2.81683 4.89859L4.58458 6.66634Z",fill:"currentColor"})),E=(t={})=>i("svg",{class:t.class,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false"},i("path",{d:"M12.6667 6.66683H13.3333C13.7015 6.66683 14 6.9653 14 7.3335V14.0002C14 14.3684 13.7015 14.6668 13.3333 14.6668H2.66667C2.29848 14.6668 2 14.3684 2 14.0002V7.3335C2 6.9653 2.29848 6.66683 2.66667 6.66683H3.33333V6.00016C3.33333 3.42284 5.42267 1.3335 8 1.3335C10.5773 1.3335 12.6667 3.42284 12.6667 6.00016V6.66683ZM11.3333 6.66683V6.00016C11.3333 4.15922 9.84093 2.66683 8 2.66683C6.15905 2.66683 4.66667 4.15922 4.66667 6.00016V6.66683H11.3333ZM7.33333 9.3335V12.0002H8.66667V9.3335H7.33333Z",fill:"currentColor"})),W=(t={})=>i("svg",{class:t.class,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false"},i("path",{d:"M7.00033 12.8337C3.77866 12.8337 1.16699 10.222 1.16699 7.00033C1.16699 3.77866 3.77866 1.16699 7.00033 1.16699C10.222 1.16699 12.8337 3.77866 12.8337 7.00033C12.8337 10.222 10.222 12.8337 7.00033 12.8337ZM6.41699 6.41699V9.91699H7.58366V6.41699H6.41699ZM6.41699 4.08366V5.25033H7.58366V4.08366H6.41699Z",fill:"currentColor"})),Z=class{constructor(i){t(this,i),this.offer=null,this.isLoading=!1,this.canRender=!0,this.gifts=[],this.cartLines=[],this.cartLinesLoaded=!1,this.freeProductCards={},this.pendingFreeProduct=null,this.pendingFreeProductSettledAt=null,this.pendingFreeProductTimer=null,this.cartPageCheckAfter=null,this.insertingCartLines=!1,this.pendingCartPageLines=null,this.pickerLookupRetries=0,this.pickerLookupTimer=null,this.cartItemCount=null,this.isTooltipHovered=!1,this.isTooltipPinned=!1,this.isGiftsOpen=!0,this.instanceId=++q,this.refreshGeneration=0,this.giftsGeneration=0,this.cartRefreshTimer=null,this.cartRefreshPending=!1,this.wantsCartUpdates=!1,this.isListeningToCartUpdates=!1,this.cartLookupRetryTimer=null,this.cartLookupRetries=0,this.cartLookupRetryPending=!1,this.deferredByEmptyCart=!1,this.isDisconnected=!1,this.skeletonWatchdog=null,this.skeletonDeadline=0,this.hasRelocated=!1,this.hasLoaded=!1,this.relocationObserver=null,this.relocationWatchTimer=null,this.relocationWatchExpired=!1,this.relocationLogged=!1,this.cartUpdatedHandler=t=>{this.readCartCountFromEvent(t),this.clearCartLookupRetry(),this.scheduleCartRefresh()}}componentWillLoad(){this.ensureSkeletonIsWatched();try{this.isEnabled()&&this.startLoading(),this.load().catch((t=>{this.stopLoading(),this.safeLog("load() failed",t)}))}catch(t){this.stopLoading(),this.safeLog("componentWillLoad threw synchronously",t)}}safeLog(t,i){try{salla.logger.warn("salla-conditional-offer::",t,i)}catch(t){}}connectedCallback(){this.isDisconnected=!1,this.ensureSkeletonIsWatched(),this.wantsCartUpdates&&!this.isListeningToCartUpdates&&this.subscribeToCartUpdates()&&(this.cartRefreshPending=!0),this.cartRefreshPending&&this.scheduleCartRefresh(),this.cartLookupRetryPending&&this.scheduleCartLookupRetry()}disconnectedCallback(){this.isDisconnected=!0,null!==this.cartRefreshTimer&&(clearTimeout(this.cartRefreshTimer),this.cartRefreshTimer=null),this.unlockFreeProduct(),this.clearPickerLookupRetry(),null!==this.cartLookupRetryTimer&&(clearTimeout(this.cartLookupRetryTimer),this.cartLookupRetryTimer=null),Promise.resolve().then((()=>{this.isDisconnected&&this.unsubscribeFromCartUpdates()})),null!==this.skeletonWatchdog&&(clearTimeout(this.skeletonWatchdog),this.skeletonWatchdog=null),this.stopWatchingForItemsColumn()}componentDidLoad(){this.hasLoaded=!0,this.relocateIntoItemsColumn()}isShowingSomething(){return this.canRender&&this.hasCartItems()}componentDidRender(){this.hasLoaded&&this.relocateIntoItemsColumn(),this.positionTooltip(),this.ensureSkeletonIsWatched()}relocateIntoItemsColumn(){if(!this.hasRelocated&&this.isShowingSomething())try{const t=this.hostEl;if(!t?.parentElement)return;const i=this.findItemsColumn(t);if(!i)return void this.watchForItemsColumn();if(this.hasRelocated=!0,this.stopWatchingForItemsColumn(),i===t.parentElement&&i.firstElementChild===t)return;i.insertBefore(t,i.firstChild)}catch(t){this.hasRelocated=!0,this.stopWatchingForItemsColumn(),this.safeLog("relocating the banner into the cart items column failed",t)}}findItemsColumn(t){let i=t;for(let e=0;i&&e<=3;e++){for(const e of this.getFollowingSiblings(i)){if(i===t&&this.matches(e,A))return t.parentElement;const r=this.findColumnWithin(e,t);if(r)return r}if(i=i.parentElement,!i||i===document.body||i===document.documentElement)break}return null}getFollowingSiblings(t){const i=[];for(let e=t.nextElementSibling;e;e=e.nextElementSibling)i.push(e);return i}findColumnWithin(t,i){const e=t.querySelector(A),r=(e?this.climbToChildOf(e,t):null)??t.querySelector(".main-content, [data-cart-items]");return!r||r===i||r.contains(i)?null:r}climbToChildOf(t,i){let e=t;for(;e&&e.parentElement&&e.parentElement!==i;)e=e.parentElement;return e?.parentElement===i?e:null}matches(t,i){return"function"==typeof t.matches&&t.matches(i)}watchForItemsColumn(){this.hasRelocated||this.relocationWatchExpired||this.relocationObserver||("undefined"!=typeof MutationObserver?(this.relocationObserver=new MutationObserver((()=>this.relocateIntoItemsColumn())),this.relocationObserver.observe(document.documentElement,{childList:!0,subtree:!0}),this.relocationWatchTimer=setTimeout((()=>{this.relocationWatchTimer=null,this.relocationWatchExpired=!0,this.stopWatchingForItemsColumn(),this.logNoItemsColumn()}),5e3)):this.logNoItemsColumn())}stopWatchingForItemsColumn(){if(this.relocationObserver){try{this.relocationObserver.disconnect()}catch(t){}this.relocationObserver=null}null!==this.relocationWatchTimer&&(clearTimeout(this.relocationWatchTimer),this.relocationWatchTimer=null)}logNoItemsColumn(){this.relocationLogged||(this.relocationLogged=!0,this.safeLog("no cart items column found — leaving the banner at full page width"))}ensureSkeletonIsWatched(){if(!this.isLoading)return;if(null!==this.skeletonWatchdog)return;const t=Date.now();0===this.skeletonDeadline&&(this.skeletonDeadline=t+8e3);const i=Math.max(0,this.skeletonDeadline-t);this.skeletonWatchdog=setTimeout((()=>{this.skeletonWatchdog=null,this.isLoading&&(Date.now()<this.skeletonDeadline?this.ensureSkeletonIsWatched():(this.isLoading=!1,this.skeletonDeadline=0,this.safeLog("still loading after 8000ms — dropping the skeleton")))}),i)}clearSkeletonWatchdog(){this.skeletonDeadline=0,null!==this.skeletonWatchdog&&(clearTimeout(this.skeletonWatchdog),this.skeletonWatchdog=null)}startLoading(){this.isLoading=!0,this.ensureSkeletonIsWatched()}stopLoading(){this.isLoading=!1,this.clearSkeletonWatchdog()}async load(){this.wantsCartUpdates=!0,this.subscribeToCartUpdates()||this.subscribeWhenSdkIsReady(),this.loadCart(),await this.waitForSdk(),await this.refresh()}waitForSdk(){let t,i;try{t=Promise.resolve(salla.onReady?.())}catch(t){return this.safeLog("salla.onReady() threw",t),Promise.resolve()}const e=new Promise((t=>{i=setTimeout(t,3e3)}));return Promise.race([t.catch((t=>this.safeLog("salla.onReady() rejected",t))),e]).then((()=>{clearTimeout(i)}))}subscribeToCartUpdates(){if(this.isListeningToCartUpdates)return!0;try{salla.event.on("cart::updated",this.cartUpdatedHandler),this.isListeningToCartUpdates=!0}catch(t){this.safeLog("cart::updated subscription failed",t)}return this.isListeningToCartUpdates}unsubscribeFromCartUpdates(){if(this.isListeningToCartUpdates){this.isListeningToCartUpdates=!1;try{salla.event.off("cart::updated",this.cartUpdatedHandler)}catch(t){this.safeLog("cart::updated unsubscription failed",t)}}}subscribeWhenSdkIsReady(){let t;try{t=Promise.resolve(salla.onReady?.())}catch(t){return}const i=()=>{this.isDisconnected||this.subscribeToCartUpdates()};t.then(i,i)}scheduleCartRefresh(){this.cartRefreshPending=!0,null!==this.cartRefreshTimer&&clearTimeout(this.cartRefreshTimer),this.cartRefreshTimer=null,this.isDisconnected||(this.cartRefreshTimer=setTimeout((()=>{this.cartRefreshTimer=null,this.runCartRefresh()}),200))}runCartRefresh(){this.isDisconnected||(this.cartRefreshPending=!1,this.refresh(),this.clearPickerLookupRetry(),T().then((()=>this.loadCart()),(()=>this.loadCart())))}readCartCountFromEvent(t){const i=this.toCartCount(t?.count)??this.readCartCountFromStorage();null!==i&&(this.cartItemCount=i)}readCartCountFromStorage(){try{return this.toCartCount(salla.storage?.get?.("cart.summary.count"))}catch(t){return null}}toCartCount(t){return"number"==typeof t&&Number.isFinite(t)&&t>=0?t:null}getFreeLabel(){const t=salla.lang.get(D);return t&&t!==D?t:"Free"}getAddLabel(){return this.sharedLabel("common.elements.add","Add")}sharedLabel(t,i){const e=salla.lang.get(t);return e&&e!==t?e:i}trans(t,i){const e=`blocks.cart_offer.${t}`,r=salla.lang.get(e,i);return r&&r!==e?r:Object.entries(i??{}).reduce(((t,[i,e])=>t.split(`:${i}`).join(e)),B[t])}isEnabled(){try{return!!salla.config.get("store.features")?.includes("conditional-offer")}catch(t){return!1}}async fetchOffer(){const{data:t}=await salla.api.cart.offers(),i=(t||[]).find((t=>"conditional"===t.type));return i?.details?.discounts?.length?i:null}async refresh(){const t=++this.refreshGeneration;if(!this.isEnabled())return this.stopLoading(),void(this.canRender=!1);if(0===this.cartItemCount)return this.stopLoading(),void(S()||(this.deferredByEmptyCart=!0,this.loadCart()));this.deferredByEmptyCart=!1,this.offer?this.stopLoading():this.startLoading();try{const i=await this.fetchOffer();if(this.isSuperseded(t))return;if(!i)return this.offer=null,void(this.canRender=!1);this.offer=i,this.canRender=!0,this.loadCart(),this.loadFreeProductCards()}catch(i){if(this.isSuperseded(t))return;this.safeLog("offers() failed",i)}finally{t===this.refreshGeneration&&this.stopLoading()}}hasCartItems(){return"number"==typeof this.cartItemCount&&this.cartItemCount>=1}isSuperseded(t){return t!==this.refreshGeneration||this.isDisconnected}loadCart(){const t=++this.giftsGeneration;return Promise.all([(w(),f&&d?Promise.resolve(d):P().then((()=>d??s))),(w(),f&&d?Promise.resolve(h):P().then((()=>h))),(w(),f&&d?Promise.resolve(c??a):P().then((()=>c??a)))]).then((([i,e,r])=>{if(t!==this.giftsGeneration||this.isDisconnected)return;if(this.cartRefreshPending)return;const o=S();null!==e&&(this.cartItemCount=e),null!==e?this.clearCartLookupRetry():null===this.cartItemCount&&this.scheduleCartLookupRetry(),this.deferredByEmptyCart&&this.hasCartItems()&&(this.deferredByEmptyCart=!1,this.refresh());const n=null!==this.getPickerStage(this.getStages()),s=null!==this.pendingFreeProductSettledAt||null!==this.cartPageCheckAfter;o||!n&&!s?(this.clearPickerLookupRetry(),this.gifts=this.offer?this.selectOwnGifts(i):[],this.cartLines=this.offer?r:[],this.cartLinesLoaded=!!this.offer,null!==this.pendingFreeProductSettledAt&&t>this.pendingFreeProductSettledAt&&this.unlockFreeProduct(),null!==this.cartPageCheckAfter&&t>this.cartPageCheckAfter&&(this.cartPageCheckAfter=null,this.showMissingCartLines(r))):(s||!this.cartLinesLoaded&&this.hasCartItems())&&this.retryPickerCartLookup()})).catch((t=>{this.safeLog("cart lookup failed",t)}))}scheduleCartLookupRetry(){this.cartLookupRetries>=V.length||(this.cartLookupRetryPending=!0,null!==this.cartLookupRetryTimer||this.isDisconnected||(this.cartLookupRetryTimer=setTimeout((()=>{this.cartLookupRetryTimer=null,this.cartLookupRetryPending=!1,this.canRender&&(this.cartLookupRetries++,this.loadCart())}),V[this.cartLookupRetries])))}retryPickerCartLookup(){null!==this.pickerLookupTimer||this.pickerLookupRetries>=V.length||(this.pickerLookupTimer=setTimeout((()=>{this.pickerLookupTimer=null,this.pickerLookupRetries++,this.loadCart()}),V[this.pickerLookupRetries]))}clearPickerLookupRetry(){this.pickerLookupRetries=0,null!==this.pickerLookupTimer&&(clearTimeout(this.pickerLookupTimer),this.pickerLookupTimer=null)}clearCartLookupRetry(){this.cartLookupRetries=0,this.cartLookupRetryPending=!1,null!==this.cartLookupRetryTimer&&(clearTimeout(this.cartLookupRetryTimer),this.cartLookupRetryTimer=null)}selectOwnGifts(t){const i=Number(this.offer?.id);if(!Number.isFinite(i))return t;const e=t.filter((t=>null!==t.offerId&&Number(t.offerId)===i));return e.length?e:t.filter((t=>null===t.offerId))}getStages(){const t=(this.offer?.details?.discounts??[]).filter((({min_spend:t})=>null!==F(t)));return i=({min_spend:t})=>t,e=({id:t})=>t,(t??[]).map(((t,r)=>({item:t,index:r,threshold:N(i(t)),identity:e?F(e(t)):null}))).sort(((t,i)=>t.threshold!==i.threshold?t.threshold-i.threshold:null!==t.identity&&null!==i.identity&&t.identity!==i.identity?t.identity-i.identity:t.index-i.index)).map((({item:t})=>t));var i,e}getProgress(t){return function(t,i,e=0,r=[],o=[],n=[]){const s=(i??[]).map(((t,i)=>({index:i,threshold:F(t),applied:I(r?.[i]),tierValue:F(o?.[i]),canAddFree:"boolean"==typeof n?.[i]?n[i]:void 0}))).filter((t=>null!==t.threshold)).sort(((t,i)=>t.threshold-i.threshold||t.index-i.index)),a=s.map((t=>t.threshold)),l=s.map((t=>t.applied)),c=l.some((t=>void 0!==t)),d=N(e);if(!a.length)return{thresholds:a,met:[],applied:l,appliedIndex:z,hasEngineVerdict:c,metCount:0,nextUnmetIndex:z,allMet:!1,lastReachedIndex:z,currentIndex:z,isComplete:!1,value:Math.max(0,N(t)),values:[],startValue:d,fills:[],overallPercentage:0};const h=a[a.length-1],f=R(N(t),0,Math.max(0,h)),u=s.map((({tierValue:t})=>null===t?f:R(t,0,Math.max(0,h))));let p=z;for(let t=0;t<a.length;t++)u[t]>=a[t]&&(p=t);const g=p===a.length-1,m=g?z:p+1,b=a.map(((t,i)=>function(t,i,e){return e<=i?t>=e?100:0:R((t-i)/(e-i)*100,0,100)}(u[i],0===i?d:a[i-1],t))),w=g?100:R((p+1+(b[m]??0)/100)/a.length*100,0,100);let y=z;for(let t=0;t<l.length;t++)!0===l[t]&&(y=t);let x=z;for(let t=0;t<a.length;t++){const i=s[t].canAddFree;(void 0===i?u[t]>=a[t]:i)&&(x=t)}const v=a.map(c?(t,i)=>i<=y:(t,i)=>i<=x),k=v.filter(Boolean).length,_=v.findIndex((t=>!t));return{thresholds:a,met:v,applied:l,appliedIndex:y,hasEngineVerdict:c,metCount:k,nextUnmetIndex:_,allMet:_===z,lastReachedIndex:p,currentIndex:m,isComplete:g,value:f,values:u,startValue:d,fills:b,overallPercentage:w}}(this.offer?.details?.current_value,t.map((({min_spend:t})=>t)),this.offer?.details?.start_value,t.map((({is_applied:t})=>t)),t.map((({current_value:t})=>t)),t.map((({can_add_free:t})=>t)))}tierKey(t,i){const e=Number(t?.id);return Number.isFinite(e)?`tier-${e}`:`pos-${i}`}stageMeasure(){return this.offer?.details?.based_on===n.PRODUCT_COUNT?$.COUNT:$.CURRENCY}formatRequirement(t){const i=this.offer?.details?.based_on;if(i===n.PRODUCT_COUNT)try{return salla.lang.choice("blocks.header.products_count",t)}catch(i){return this.safeLog("invalid products_count interval",i),`${t}`}return i===n.PRODUCT_PURCHASE?salla.money(t):(this.safeLog(`unexpected offer detail's based_on value: ${i}`),`${t}`)}getRewardText(t){if(this.isPickerTier(t)){const i=Math.max(1,Math.floor(Number(t.max_free_products)||1));return 1===i?this.trans("free_product_reward_one"):2===i?this.trans("free_products_reward_two"):this.trans("free_products_reward",{count:`${i}`})}return(t?.reward_label??"").trim()}getGuidanceMessage(t,i){if(i.nextUnmetIndex===z)return"";const e=Number(t[i.nextUnmetIndex]?.amount_needed),r=this.isPickerTier(t[i.nextUnmetIndex])&&Number.isFinite(e)&&e>0?e:function(t,i,e=$.CURRENCY){const r=i.thresholds[t];if(void 0===r)return 0;const o=Math.max(0,r-(i.values?.[t]??i.value));if(0===o)return 0;const n=e===$.COUNT?0:function(){try{const t="undefined"!=typeof salla?salla:void 0,i=j(t?.config?.currency?.()?.decimals);if(null!==i)return i;const e=j(t?.config?.get?.("store.currency.decimals"));if(null!==e)return e}catch(t){}return 2}(),s=Math.pow(10,n),a=Math.ceil(o*s-1e-6)/s;return a>0?a:1/s}(i.nextUnmetIndex,i,this.stageMeasure());if(r<=0)return this.trans("guidance_conditions_unmet");const o=this.formatRequirement(r),n=this.getRewardText(t[i.nextUnmetIndex]);return n?this.trans("guidance_next",{remaining:o,reward:G(n)}):this.trans("guidance_next_generic",{remaining:o})}getTierSentence(t,i,e){const r=this.formatRequirement(e.thresholds[i]),o=this.getRewardText(t),n=this.stageMeasure()===$.COUNT;return o?this.trans(n?"tier_requirement_count":"tier_requirement",{threshold:r,reward:G(o)}):this.trans(n?"tier_requirement_count_generic":"tier_requirement_generic",{threshold:r})}getRewardIcon(t){switch(t?.type){case o.PERCENTAGE:return"sicon-percentage";case o.FREE_PRODUCT:return"sicon-gift";case o.FIXED:return this.usesSarSymbol()?"sicon-sar":"sicon-banknote";default:return"sicon-tag"}}usesSarSymbol(){try{const t=salla.config.currency?.()?.symbol;return["SAR","ر.س"].includes(t)&&!!salla.config.get("store.settings.use_sar_symbol")}catch(t){return!1}}get isTooltipOpen(){return this.isTooltipHovered||this.isTooltipPinned}toggleTooltip(){this.isTooltipPinned=!this.isTooltipPinned}closeTooltip(t=!1){this.isTooltipOpen&&(this.isTooltipPinned=!1,this.isTooltipHovered=!1,t&&this.infoTriggerEl?.focus?.())}positionTooltip(){const t=this.tooltipEl,i=this.infoTriggerEl;if(this.isTooltipOpen&&t&&i)try{this.setTooltipOffsets(t,0,0);const e=window.innerWidth||document.documentElement?.clientWidth||0,r=t.getBoundingClientRect(),o=i.getBoundingClientRect(),n=r?.width||0;if(n<=0||e<=0)return;const s=o.left+o.width/2-n/2,a=8,l=Math.min(Math.max(s,a),Math.max(a,e-a-n))-s,c=Math.max(0,n/2-16),d=Math.min(Math.max(-l,-c),c);this.setTooltipOffsets(t,l,d)}catch(t){this.safeLog("positioning the offer details popover failed",t)}}setTooltipOffsets(t,i,e){t.style?.setProperty?.("--s-conditional-offer-tooltip-shift",`${Math.round(i)}px`),t.style?.setProperty?.("--s-conditional-offer-tooltip-caret",`${Math.round(e)}px`)}handleWindowResize(){this.positionTooltip()}handleDocumentKeydown(t){"Escape"!==t.key&&"Esc"!==t.key||this.closeTooltip(!0)}handleDocumentClick(t){if(!this.isTooltipPinned||!this.infoAnchorEl)return;const i="function"==typeof t.composedPath?t.composedPath():[];(i.length?i.includes(this.infoAnchorEl):this.infoAnchorEl.contains(t.target))||this.closeTooltip()}elementId(t){return`s-conditional-offer-${t}-${this.instanceId}`}renderBadges(t,e){return i("div",{class:"s-conditional-offer-badges",role:"img","aria-label":this.trans("badges_summary",{completed:`${e.metCount}`,total:`${t.length}`})},t.map(((t,r)=>{const o=e.met[r],n=this.tierKey(t,r);return[r>0?i("span",{key:`${n}-link`,class:{"s-conditional-offer-badge-link":!0,"s-conditional-offer-badge-link-met":o,"s-conditional-offer-badge-link-unmet":!o},"aria-hidden":"true"}):null,i("span",{key:n,class:{"s-conditional-offer-badge":!0,"s-conditional-offer-badge-met":o,"s-conditional-offer-badge-unmet":!o},"data-tier-state":o?"met":"unmet","data-tier-id":t?.id??void 0},i(o?Y:E,{class:"s-conditional-offer-badge-icon"}))]})))}renderTooltip(t,e){const r=function(t){const i=t?.details?.rules;if("string"==typeof i){const t=i.trim();return""===t?null:t}if(Array.isArray(i)){const t=i.filter((t=>"string"==typeof t)).map((t=>t.trim())).filter((t=>""!==t)).join(" ");return""===t?null:t}return null}(this.offer);return i("div",{class:"s-conditional-offer-tooltip",id:this.elementId("tooltip"),role:"tooltip",ref:t=>this.tooltipEl=t},i("div",{class:"s-conditional-offer-tooltip-title"},this.offer?.title),r?i("div",{class:"s-conditional-offer-tooltip-description"},r):null,i("ul",{class:"s-conditional-offer-tooltip-list"},t.map(((t,r)=>{const o=e.met[r];return i("li",{key:this.tierKey(t,r),class:"s-conditional-offer-tier","data-tier-state":o?"met":"unmet","data-tier-id":t?.id??void 0},i("span",{class:{"s-conditional-offer-tier-icon":!0,"s-conditional-offer-tier-icon-met":o,"s-conditional-offer-tier-icon-unmet":!o}},i("i",{class:this.getRewardIcon(t),"aria-hidden":"true"}),i("span",{class:{"s-conditional-offer-tier-status":!0,"s-conditional-offer-tier-status-met":o,"s-conditional-offer-tier-status-unmet":!o},"aria-hidden":"true"},o?i(Y,{class:"s-conditional-offer-tier-status-check"}):i(E,{class:"s-conditional-offer-tier-status-lock"}))),i("div",{class:"s-conditional-offer-tier-body"},i("div",{class:"s-conditional-offer-tier-title"},this.trans("tier_title",{number:`${r+1}`})),i("div",{class:{"s-conditional-offer-tier-text":!0,"s-conditional-offer-tier-text-met":o},innerHTML:this.getTierSentence(t,r,e)})))}))))}getPickerStage(t){return t.find((t=>this.isPickerTier(t)))??null}isPickerTier(t){return t?.type===o.FREE_PRODUCT&&Array.isArray(t.free_products)&&t.free_products.length>0}areGiftsUnavailable(t,i){const e=t[i.lastReachedIndex];return e?.type===o.FREE_PRODUCT&&Array.isArray(e.free_products)&&0===e.free_products.length&&0===this.gifts.length}loadFreeProductCards(){const t=this.getPickerStage(this.getStages()),i=(t?.free_products??[]).map((t=>String(t.id))).filter((t=>t&&!this.freeProductCards[t]));if(!i.length)return Promise.resolve();const e=new Set((t.free_products??[]).map((t=>String(t.id))));return Promise.resolve().then((()=>salla.product.fetch({source:"selected",source_value:i}))).then((t=>{if(this.isDisconnected)return;const i={...this.freeProductCards};(Array.isArray(t?.data)?t.data:[]).forEach((t=>{const r=String(t?.id??"");r&&e.has(r)&&(i[r]={id:r,name:String(t.name??""),imageUrl:String(t.image?.url??""),imageAlt:String(t.image?.alt??t.name??""),price:Number.isFinite(Number(t.price))?Number(t.price):null})})),this.freeProductCards=i})).catch((t=>this.safeLog("free product lookup failed",t)))}getPickerState(t){const i=this.cartLines.filter((t=>t.freeQuantity>0)),e=this.selectOwnFreeLines(i),r=new Set(e.map((t=>t.productId)).filter((t=>null!==t))),o=Math.max(1,Math.floor(Number(t.max_free_products)||1)),n=Number(t.current_value??this.offer?.details?.current_value??0);return{limit:o,reached:"boolean"==typeof t.can_add_free?t.can_add_free:Number.isFinite(n)&&n>=Number(t.min_spend),freeCount:r.size}}selectOwnFreeLines(t){const i=Number(this.offer?.id);if(!Number.isFinite(i))return t;const e=t.filter((t=>null!==t.offerId&&Number(t.offerId)===i));return e.length?e:t.filter((t=>null===t.offerId))}addFreeProduct(t){this.pendingFreeProduct||(this.pendingFreeProduct=t.id,this.runFreeProductChange((()=>Promise.resolve(salla.cart.addItem(t.id)).then((()=>{this.cartPageCheckAfter=this.giftsGeneration}))),"free product add failed"))}reloadPage(){window.location.reload()}fetchCartPageHtml(){const t=new AbortController,i=setTimeout((()=>t.abort()),8e3);return fetch(window.location.href,{cache:"no-store",credentials:"same-origin",headers:{Accept:"text/html"},signal:t.signal}).then((t=>t.ok?t.text():Promise.reject(new Error(`cart page ${t.status}`)))).finally((()=>clearTimeout(i)))}showMissingCartLines(t){this.insertingCartLines?this.pendingCartPageLines=t:this.missingCartLineIds(t).length&&(this.insertingCartLines=!0,Promise.resolve().then((()=>this.fetchCartPageHtml())).then((t=>{if(this.isDisconnected||this.cartChangedDuringPageFetch())return;const i=this.missingCartLineIds(this.cartLines);i.length&&!this.insertCartLineForms(t,i)&&this.reloadForMissingCartLines(i)})).catch((t=>{this.safeLog("cart page fetch for the new lines failed, reloading",t),this.isDisconnected||this.cartChangedDuringPageFetch()||this.reloadForMissingCartLines(this.missingCartLineIds(this.cartLines))})).finally((()=>{this.insertingCartLines=!1;const t=this.pendingCartPageLines;this.pendingCartPageLines=null,t&&!this.isDisconnected&&this.showMissingCartLines(t)})))}cartChangedDuringPageFetch(){return!(null===this.pendingFreeProduct&&this.cartLinesLoaded||(null===this.cartPageCheckAfter&&(this.cartPageCheckAfter=this.giftsGeneration),0))}missingCartLineIds(t){try{return document.querySelector(O)?t.map((t=>t.id)).filter((t=>!document.getElementById(`item-${t}`))).sort():[]}catch(t){return this.safeLog("cart page check after a free product add failed",t),[]}}insertCartLineForms(t,i){try{const e=Array.from((new DOMParser).parseFromString(t,"text/html").querySelectorAll(O)),r=e.map((t=>t.getAttribute("id")));return!i.some((t=>!r.includes(`item-${t}`)))&&(e.forEach(((t,e)=>{const o=r[e];if(!i.includes(o.slice(5))||document.getElementById(o))return;const n=r.slice(e+1).map((t=>document.getElementById(t))).find(Boolean);if(n)n.parentNode.insertBefore(t,n);else{const i=document.querySelectorAll(O),e=i[i.length-1];e.parentNode.insertBefore(t,e.nextSibling)}})),i.every((t=>document.getElementById(`item-${t}`))))}catch(t){return this.safeLog("cart line insert failed",t),!1}}reloadForMissingCartLines(t){if(!t.length)return;const i=t.join(","),e=this.readReloadGuard();e!==i&&(void 0===e&&this.pageWasReloaded()||(this.writeReloadGuard(i),this.reloadPage()))}readReloadGuard(){try{return window.sessionStorage.getItem(H)}catch{return}}writeReloadGuard(t){try{window.sessionStorage.setItem(H,t)}catch{}}pageWasReloaded(){try{const t=window.performance?.getEntriesByType?.("navigation")?.[0];return"reload"===t?.type}catch{return!1}}runFreeProductChange(t,i){Promise.resolve().then(t).then((()=>{if(this.isDisconnected)return this.unlockFreeProduct();this.pendingFreeProductSettledAt=this.giftsGeneration,this.pendingFreeProductTimer=setTimeout((()=>this.unlockOnStaleLines()),5e3)})).catch((t=>{this.safeLog(i,t),this.unlockFreeProduct(),null!==this.cartPageCheckAfter&&this.loadCart()}))}unlockOnStaleLines(){this.unlockFreeProduct(),this.cartLinesLoaded=!1,this.clearPickerLookupRetry(),T().then((()=>this.loadCart()),(()=>this.loadCart()))}unlockFreeProduct(){null!==this.pendingFreeProductTimer&&clearTimeout(this.pendingFreeProductTimer),this.pendingFreeProductTimer=null,this.pendingFreeProductSettledAt=null,this.pendingFreeProduct=null}pickerGotMessage(t,i){return 1===t?this.trans(i?"free_product_got_pick_one":"free_product_got_one"):2===t?this.trans(i?"free_products_got_pick_two":"free_products_got_two"):this.trans(i?"free_products_got_pick":"free_products_got",{count:`${t}`})}getPickerCards(t){return(t.free_products??[]).map((t=>this.freeProductCards[String(t.id)])).filter(Boolean)}renderPicker(t){const e=this.getPickerState(t),r=this.getPickerCards(t);return r.length?i("div",{class:"s-conditional-offer-picker","data-picker-reached":e.reached?"true":"false"},i("div",{class:"s-conditional-offer-picker-header"},i("span",{class:"s-conditional-offer-picker-counter","aria-label":`${e.freeCount}/${e.limit}`},`${e.freeCount}/${e.limit}`),i("span",{class:"s-conditional-offer-picker-title"},1===e.limit?this.trans("free_product_choose_one"):2===e.limit?this.trans("free_products_choose_two"):this.trans("free_products_choose",{count:`${e.limit}`}))),i("ul",{class:"s-conditional-offer-picker-list"},r.map((t=>this.renderPickerCard(t))))):null}renderPickerCard(t){return i("li",{class:"s-conditional-offer-picker-card","data-product-id":t.id},i("span",{class:"s-conditional-offer-picker-thumb"},t.imageUrl?i("img",{class:"s-conditional-offer-picker-image",src:t.imageUrl,alt:t.imageAlt||t.name,loading:"lazy",decoding:"async"}):i("i",{class:"sicon-gift","aria-hidden":"true"})),i("span",{class:"s-conditional-offer-picker-name"},t.name),null!==t.price?i("span",{class:"s-conditional-offer-picker-prices"},i("span",{class:"s-conditional-offer-picker-price-regular",innerHTML:salla.money(t.price)})):null,i("span",{class:"s-conditional-offer-picker-actions"},i("button",{type:"button",class:"s-conditional-offer-picker-add",onClick:()=>this.addFreeProduct(t)},this.getAddLabel())))}renderGiftsToggle(t,e){return i("button",{type:"button",id:this.elementId(`toggle-${t}`),class:{"s-conditional-offer-toggle":!0,"s-conditional-offer-toggle-inline":"inline"===t,"s-conditional-offer-toggle-bar":"bar"===t},"aria-expanded":this.isGiftsOpen?"true":"false","aria-controls":this.elementId("gifts"),onClick:()=>this.isGiftsOpen=!this.isGiftsOpen},i("span",null,this.trans(e?"offer_toggle":"manage_offer")),i("i",{class:{"sicon-keyboard_arrow_down":!0,"s-conditional-offer-toggle-icon":!0,"s-conditional-offer-toggle-icon-open":this.isGiftsOpen},"aria-hidden":"true"}))}renderGiftsCard(t=null){if(!t)return i("div",{class:"s-conditional-offer-panel",id:this.elementId("gifts")},i("div",{class:"s-conditional-offer-gifts-header"},i("span",{class:"s-conditional-offer-gifts-icon"},i("i",{class:"sicon-gift","aria-hidden":"true"})),i("span",{class:"s-conditional-offer-gifts-title"},this.trans("free_products_title"))),i("ul",{class:"s-conditional-offer-gifts-list"},this.gifts.map((t=>this.renderGiftRow(t)))));const e=this.getPickerState(t);return i("div",{class:"s-conditional-offer-panel",id:this.elementId("gifts")},e.reached?this.renderPicker(t):null,this.gifts.length?i("div",{class:"s-conditional-offer-gifts"},i("div",{class:"s-conditional-offer-gifts-header"},i("span",{class:"s-conditional-offer-gifts-icon"},i("i",{class:"sicon-gift","aria-hidden":"true"})),i("span",{class:"s-conditional-offer-gifts-title"},this.sharedLabel("pages.loyalty_program.free_product_title","Free products"))),i("ul",{class:"s-conditional-offer-gifts-list"},this.gifts.map((t=>this.renderGiftRow(t))))):null)}renderGiftRow(t){return i("li",{class:"s-conditional-offer-gift","data-item-id":t.id},i("span",{class:"s-conditional-offer-gift-thumb"},t.imageUrl?i("img",{class:"s-conditional-offer-gift-image",src:t.imageUrl,alt:t.imageAlt||t.name,loading:"lazy",decoding:"async"}):i("i",{class:"sicon-gift","aria-hidden":"true"})),i("div",{class:"s-conditional-offer-gift-body"},i("span",{class:"s-conditional-offer-gift-name"},t.name||this.trans("free_gift")),i("span",{class:"s-conditional-offer-gift-prices"},i("span",{class:"s-conditional-offer-gift-free"},this.getFreeLabel()),null!==t.originalPrice?i("span",{class:"s-conditional-offer-gift-price",innerHTML:salla.money(t.originalPrice)}):null)))}getLoadingSkeletonView(){return i(e,{class:"s-conditional-offer-root"},i("div",{class:"s-conditional-offer-banner"},i("div",{class:"s-conditional-offer-lead"},i("salla-skeleton",{height:"24px",width:"80px"}),i("div",{class:"s-conditional-offer-skeleton-text"},i("salla-skeleton",{height:"12px",width:"35%"}),i("salla-skeleton",{height:"16px",width:"60%"})))))}render(){if(!this.canRender)return null;if(!this.hasCartItems())return null;if(this.isLoading)return this.getLoadingSkeletonView();if(!this.offer)return null;const t=this.getStages(),r=this.getProgress(t),o=this.getGuidanceMessage(t,r),n=this.trans("details_title"),s=this.getPickerStage(t),a=null!==s?this.getPickerState(s):null,l=a?.reached??!1,c=this.gifts.length>0||l&&this.getPickerCards(s).length>0,d=l&&this.cartLinesLoaded&&0===a.freeCount,h=r.allMet&&l&&a.freeCount>0&&t[t.length-1]===s;return i(e,{class:"s-conditional-offer-root"},i("div",{class:"s-conditional-offer-banner"},i("div",{class:"s-conditional-offer-lead"},this.renderBadges(t,r),i("div",{class:"s-conditional-offer-text"},i("div",{class:"s-conditional-offer-heading",onMouseEnter:()=>this.isTooltipHovered=!0,onMouseLeave:()=>this.isTooltipHovered=!1},i("span",{class:"s-conditional-offer-name"},this.offer.title),i("span",{class:"s-conditional-offer-info",ref:t=>this.infoAnchorEl=t},i("button",{type:"button",class:"s-conditional-offer-info-trigger",ref:t=>this.infoTriggerEl=t,"aria-label":n,title:n,"aria-expanded":this.isTooltipOpen?"true":"false","aria-describedby":this.elementId("tooltip"),onClick:()=>this.toggleTooltip()},i(W,{class:"s-conditional-offer-info-icon"})),this.isTooltipOpen?this.renderTooltip(t,r):null)),d||h?i("div",{class:"s-conditional-offer-message",role:"status"},this.pickerGotMessage(a.limit,d)):this.areGiftsUnavailable(t,r)?i("div",{class:"s-conditional-offer-message",role:"status"},this.trans("free_products_unavailable")):r.allMet?i("div",{class:"s-conditional-offer-message",role:"status"},this.trans("congrats")):o?i("div",{class:"s-conditional-offer-message",innerHTML:o}):null)),c?this.renderGiftsToggle("inline",!!s):null),c&&this.isGiftsOpen?this.renderGiftsCard(s):null,c?this.renderGiftsToggle("bar",!!s):null)}get hostEl(){return r(this)}};Z.style='/*!twlt*/:host{display:block}.s-conditional-offer-root{background-color:rgba(0, 137, 123, 0.06);background-color:color-mix(in srgb, var(--color-primary, #00897b) 7%, transparent)}.s-conditional-offer-badges::-webkit-scrollbar{height:3px}.s-conditional-offer-badges::-webkit-scrollbar-thumb{border-radius:9999px;background-color:rgba(0, 0, 0, 0.15)}.s-conditional-offer-badges::-webkit-scrollbar-track{background-color:transparent}.s-conditional-offer-tooltip{--s-conditional-offer-tooltip-shift:0px;--s-conditional-offer-tooltip-caret:0px;transform:translateX(calc(-50% + var(--s-conditional-offer-tooltip-shift)))}.s-conditional-offer-tooltip::before{content:"";position:absolute;bottom:100%;left:50%;transform:translateX(calc(-50% + var(--s-conditional-offer-tooltip-caret)));border:8px solid transparent;border-bottom-color:#fff}.s-conditional-offer-tier-icon-met,.s-conditional-offer-tier-icon-unmet{color:var(--color-primary-dark, #00695c);background-color:rgba(0, 137, 123, 0.12);background-color:color-mix(in srgb, var(--color-primary, #00897b) 14%, transparent)}.s-conditional-offer-tier:not(:last-child)::before{content:"";position:absolute;top:2.5rem;bottom:-1rem;inset-inline-start:1.125rem;width:1px;background-color:#d1d5db}.visible{visibility:visible}.invisible{visibility:hidden}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.block{display:block}.inline{display:inline}.flex{display:flex}.hidden{display:none}.w-6{width:1.5rem}.resize{resize:both}.gap-1{gap:0.25rem}.rounded{border-radius:var(--s-radius, 0.25rem)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.s-conditional-offer-root{margin-bottom:1.25rem;display:block;width:100%;min-width:0px;max-width:100%;border-radius:0.375rem;padding:0.75rem}@media (min-width: 768px){.s-conditional-offer-root{padding:1rem}}.s-conditional-offer-banner{display:flex;width:100%;min-width:0px;align-items:center;justify-content:space-between;gap:0.75rem}@media (min-width: 768px){.s-conditional-offer-banner{gap:1rem}}.s-conditional-offer-lead{display:flex;min-width:0px;flex:1 1 0%;align-items:center;gap:0.5rem}@media (min-width: 768px){.s-conditional-offer-lead{gap:0.75rem}}.s-conditional-offer-badges{display:flex;max-width:45%;flex-shrink:0;flex-wrap:nowrap;align-items:center;gap:0.25rem;overflow-x:auto;overscroll-behavior-x:contain;scroll-behavior:smooth;scrollbar-width:thin}.s-conditional-offer-badge{display:inline-flex;height:1.5rem;width:1.5rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;font-size:11px;line-height:1;--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.s-conditional-offer-badge-met{background-color:var(--color-primary)}.s-conditional-offer-badge-unmet{--tw-bg-opacity:1;background-color:rgb(156 163 175 / var(--tw-bg-opacity, 1))}.s-conditional-offer-badge-link{width:0.5rem;flex-shrink:0;border-top-width:1px}.s-conditional-offer-badge-link-met{border-color:var(--color-primary)}.s-conditional-offer-badge-link-unmet{border-style:dashed;--tw-border-opacity:1;border-color:rgb(82 82 82 / var(--tw-border-opacity, 1))}.s-conditional-offer-badge-icon{height:0.75rem;width:0.75rem;flex-shrink:0}.s-conditional-offer-text{display:flex;min-width:0px;flex-direction:column;gap:0.125rem;text-align:start}.s-conditional-offer-heading{display:flex;min-width:0px;align-items:center;gap:0.375rem}.s-conditional-offer-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:0.75rem;line-height:1rem;--tw-text-opacity:1;color:rgb(82 82 82 / var(--tw-text-opacity, 1))}.s-conditional-offer-info{position:relative;display:inline-flex;flex-shrink:0;align-items:center}.s-conditional-offer-info-trigger{display:inline-flex;height:1rem;width:1rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;--tw-text-opacity:1;color:rgb(115 115 115 / var(--tw-text-opacity, 1));transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-conditional-offer-info-trigger:hover{color:var(--color-primary-dark)}.s-conditional-offer-info-icon{height:0.875rem;width:0.875rem;flex-shrink:0}.s-conditional-offer-message{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark)}@media (min-width: 768px){.s-conditional-offer-message{font-size:1rem;line-height:1.5rem}}.s-conditional-offer-toggle{align-items:center;justify-content:center;gap:0.375rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(38 38 38 / var(--tw-text-opacity, 1));transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-conditional-offer-toggle:hover{color:var(--color-primary-dark)}.s-conditional-offer-toggle-inline{display:none;flex-shrink:0}@media (min-width: 768px){.s-conditional-offer-toggle-inline{display:inline-flex}}.s-conditional-offer-toggle-bar{margin-top:0.5rem;display:inline-flex;width:100%;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding-left:0.75rem;padding-right:0.75rem;padding-top:0.625rem;padding-bottom:0.625rem}@media (min-width: 768px){.s-conditional-offer-toggle-bar{display:none}}.s-conditional-offer-toggle-icon{font-size:1rem;line-height:1.5rem;line-height:1;transition-property:transform;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-conditional-offer-toggle-icon-open{--tw-rotate:180deg;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.s-conditional-offer-panel{margin-top:0.75rem;width:100%;min-width:0px;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:0.75rem}.s-conditional-offer-gifts-header{margin-bottom:0.75rem;display:flex;align-items:center;gap:0.5rem}.s-conditional-offer-gifts-icon{display:inline-flex;height:2rem;width:2rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;border-width:1px;border-color:var(--color-primary);font-size:1rem;line-height:1.5rem;line-height:1;color:var(--color-primary)}.s-conditional-offer-gifts-title{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-gifts-list{margin:0px;display:flex;list-style-type:none;flex-direction:column;gap:0.5rem;padding:0px}.s-conditional-offer-gift{display:flex;align-items:center;gap:0.75rem;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));padding:0.5rem}.s-conditional-offer-gift-thumb{display:inline-flex;height:3.5rem;width:3.5rem;flex-shrink:0;align-items:center;justify-content:center;overflow:hidden;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.s-conditional-offer-gift-image{height:100%;width:100%;object-fit:contain}.s-conditional-offer-gift-body{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.125rem;text-align:start}.s-conditional-offer-gift-name{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;font-size:0.875rem;line-height:1.25rem;font-weight:700;--tw-text-opacity:1;color:rgb(38 38 38 / var(--tw-text-opacity, 1))}.s-conditional-offer-gift-prices{display:flex;align-items:center;gap:0.5rem;font-size:0.75rem;line-height:1rem}.s-conditional-offer-gift-free{font-weight:700;--tw-text-opacity:1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.s-conditional-offer-gift-price{--tw-text-opacity:1;color:rgb(115 115 115 / var(--tw-text-opacity, 1));text-decoration-line:line-through}.s-conditional-offer-gifts{margin-top:0.75rem;width:100%;min-width:0px;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding:0.75rem}.s-conditional-offer-picker{display:flex;width:100%;min-width:0px;flex-direction:column;gap:0.75rem}.s-conditional-offer-picker-header{display:flex;align-items:center;gap:0.5rem}.s-conditional-offer-picker-counter{display:inline-flex;height:2.25rem;width:2.25rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;border-width:2px;border-color:var(--color-primary);font-size:0.75rem;line-height:1rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-picker-title{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-picker-list{margin:0px;display:flex;list-style-type:none;gap:0.75rem;overflow-x:auto;overscroll-behavior-x:contain;scroll-behavior:smooth;padding:0px;padding-bottom:0.25rem;scrollbar-width:thin}.s-conditional-offer-picker-card{display:flex;width:9rem;flex-shrink:0;flex-direction:column;gap:0.375rem;text-align:start}.s-conditional-offer-picker-thumb{display:inline-flex;height:7rem;width:100%;align-items:center;justify-content:center;overflow:hidden;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));font-size:1.5rem;line-height:2rem;--tw-text-opacity:1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.s-conditional-offer-picker-image{height:100%;width:100%;object-fit:contain}.s-conditional-offer-picker-name{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(38 38 38 / var(--tw-text-opacity, 1))}.s-conditional-offer-picker-prices{display:flex;align-items:center;gap:0.5rem;font-size:0.75rem;line-height:1rem}.s-conditional-offer-picker-price-regular{font-weight:700;--tw-text-opacity:1;color:rgb(23 23 23 / var(--tw-text-opacity, 1))}.s-conditional-offer-picker-actions{margin-top:auto;display:flex;width:100%;align-items:center;gap:0.375rem}.s-conditional-offer-picker-add{display:inline-flex;height:2.25rem;flex:1 1 0%;align-items:center;justify-content:center;border-radius:0.375rem;border-width:1px;border-color:var(--color-primary);font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark);transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-conditional-offer-picker-add:hover{background-color:var(--color-primary);--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.s-conditional-offer-tooltip{position:absolute;top:calc(100% + 0.75rem);left:50%;z-index:10;width:min(22rem, calc(100vw - 2rem));border-radius:0.5rem;--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1rem;text-align:start;--tw-shadow:5px 10px 30px #2B2D340D;--tw-shadow-colored:5px 10px 30px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.s-conditional-offer-tooltip-title{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-tooltip-description{margin-top:0.25rem;font-size:0.75rem;line-height:1rem;line-height:1.625;--tw-text-opacity:1;color:rgb(82 82 82 / var(--tw-text-opacity, 1))}.s-conditional-offer-tooltip-list{margin:0px;margin-top:0.75rem;display:flex;list-style-type:none;flex-direction:column;gap:1rem;padding:0px}.s-conditional-offer-tier{position:relative;display:flex;align-items:flex-start;gap:0.75rem}.s-conditional-offer-tier-icon{position:relative;display:inline-flex;height:2.25rem;width:2.25rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;font-size:1rem;line-height:1.5rem;line-height:1}.s-conditional-offer-tier-icon-unmet{color:var(--color-primary-dark)}.s-conditional-offer-tier-status{position:absolute;bottom:-0.125rem;display:inline-flex;height:1rem;width:1rem;align-items:center;justify-content:center;border-radius:9999px;border-width:2px;--tw-border-opacity:1;border-color:rgb(255 255 255 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));inset-inline-start:-2px}.s-conditional-offer-tier-status-met{color:var(--color-primary-dark)}.s-conditional-offer-tier-status-unmet{--tw-text-opacity:1;color:rgb(163 163 163 / var(--tw-text-opacity, 1))}.s-conditional-offer-tier-status-check{height:0.75rem;width:0.75rem;flex-shrink:0}.s-conditional-offer-tier-status-lock{height:0.625rem;width:0.625rem;flex-shrink:0}.s-conditional-offer-tier-body{display:flex;min-width:0px;flex-direction:column;gap:0.125rem}.s-conditional-offer-tier-title{font-size:0.75rem;line-height:1rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-tier-text{font-size:0.75rem;line-height:1rem;line-height:1.625;--tw-text-opacity:1;color:rgb(82 82 82 / var(--tw-text-opacity, 1))}.s-conditional-offer-tier-text-met{text-decoration-line:line-through}.s-conditional-offer-skeleton-text{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.375rem}';export{Z as salla_conditional_offer}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,c as i,f as r,h as e,H as s,a as o}from"./p-ze9e0dxM.js";import{M as a}from"./p-DmgxDvXL.js";const n=class{constructor(r){t(this,r),this.verified=i(this,"verified"),this.translationLoaded=!1,this.display="modal",this.type="mobile",this.autoReload=!0,this.supportWebAuth=!0,this.resendAfter=30,this.isProfileVerify=!1,"inline"!=this.display?(this.profileVerificationListener=t=>{let i=Array.isArray(t)?t[0]:t;"delete_account"===i?.request_type||document.getElementById("salla-user-settings-delete-modal")?.hasAttribute("visible")||(this.isProfileVerify=!0,this.open(i),this.title=salla.lang.get("pages.profile.verify_title")+salla.lang.get("common.elements."+i.type),this.modal?.setTitle(this.title))},this.modalClosedListener=()=>{this.resendAfter=0,this.timer.innerHTML="30 : 00"}):this.modal={open:()=>"",close:()=>"",setTitle:()=>""}}connectedCallback(){this.profileVerificationListener&&(salla.event.on("profile::verification",this.profileVerificationListener),salla.event.on("modalClosed",this.modalClosedListener)),this.langUnsubscribe=salla.lang.subscribe((()=>{this.translationLoaded=!0,this.title=salla.lang.get("pages.profile.verify_title")+salla.lang.get("common.elements."+this.type),this.modal?.setTitle(this.title),r(this)}))}disconnectedCallback(){this.profileVerificationListener&&(salla.event.off("profile::verification",this.profileVerificationListener),salla.event.off("modalClosed",this.modalClosedListener)),this.langUnsubscribe?.()}splitNumber(t){this.resetError();let i=t.data||t.target.value;i&&1!==i.length&&this.modifyNext(t.target,i)}modifyNext(t,i){t.value=i[0],i=i.substring(1),t.nextElementSibling&&i.length?this.modifyNext(t.nextElementSibling,i):t.nextElementSibling||0!==i.length?t.nextElementSibling&&0===i.length&&t.nextElementSibling.focus():t.focus()}checkAllInputs(){let t=!0;for(let i=0;i<this.otpInputs.length;i++)""===this.otpInputs[i].value&&(t=!1);return t}handleKeyUp(t){if(this.resetError(),["Alt","Shift","Control","AltGraph","Ctrl"].includes(t.key))return;let i=t.keyCode||t.charCode;t.target.value?(t.target.nextElementSibling?.focus(),t.target.nextElementSibling?.select()):[8,46].includes(i)&&(t.target.previousElementSibling?.focus(),t.target.previousElementSibling?.select()),t.target.value.length>1&&this.splitNumber(t)}handlePaste(t){this.resetError();let i=(salla.helpers.number(t.clipboardData.getData("text"))||"").replace(/[^0-9]/g,"");i=i.substring(0,this.otpInputs.length),this.otpInputs.forEach((t=>t.value="")),this.modifyNext(this.otpInputs[0],i)}handleInput(t){this.resetError(),salla.helpers.inputDigitsOnly(t.target),this.checkAllInputs()&&setTimeout((()=>{this.toggleOTPSubmit()}),100)}resetError(){this.hasError=!1,this.errorMessage=""}handleFocus(t){t.target!==this.firstOtpInput&&(""==this.firstOtpInput?.value&&this.firstOtpInput.focus(),""==t.target.previousElementSibling.value&&t.target.previousElementSibling.focus())}async getCode(){return this.code.value}async open(t){this.data=t,this.data.type=this.data.type||this.type,this.type=this.data.type,this.resendTimer(),this.otpInputs=this.body.querySelectorAll(".s-verify-input"),this.firstOtpInput=this.body.querySelector("#otp-1"),this.reset(),this.resetError(),"modal"==this.display&&this.modal?.setTitle(this.title),this.modal.open(),this.firstOtpInput?.addEventListener("input",(t=>this.splitNumber(t))),setTimeout((()=>this.otpInputs[0].focus()),100)}toggleOTPSubmit(){let t=[];if(this.otpInputs.forEach((i=>i.value&&t.push(i.value))),this.code.value=t.join(""),4===t.length)return this.btn.disable(),void this.btn.click();this.btn.enable()}reset(){this.otpInputs.forEach((t=>t.value="")),this.code.value="",this.otpInputs[0].focus()}resendTimer(){this.resendMessage.style.display="block",this.resend.style.display="none",this.resendAfter=30;let t=setInterval((()=>{this.resendAfter<=0?(clearInterval(t),this.resend.style.display="block",this.resendMessage.style.display="none"):(this.timer.innerHTML=`${this.resendAfter>=10?this.resendAfter:"0"+this.resendAfter} : 00`,this.resendAfter--)}),1e3)}resendCode(){return this.btn.stop().then((()=>this.btn.disable())).then((()=>{this.otpInputs.forEach((t=>t.value="")),this.otpInputs[0].focus()})).then((()=>this.resendHandler?this.resendHandler(this.data):salla.api.auth.resend(this.data))).finally((()=>this.resendTimer()))}submit(){if(this.code.value.length<4)return this.otpInputs[this.code.value.length].focus(),void salla.log("Trying to submit without 4 digits!");let t={code:this.code.value,...this.data};return this.btn.load().then((()=>this.btn.disable())).then((()=>this.verifyHandler?this.verifyHandler(t):this.isProfileVerify?salla.profile.verify(t):salla.auth.verify(t,this.supportWebAuth))).then((t=>this.verified.emit(t))).then((()=>this.btn.stop()&&this.btn.disable())).then((()=>this.modal.close())).then((()=>this.autoReload&&window.location.reload())).catch((t=>{this.hasError=!0,this.errorMessage=t.response?.data?.error?.message||salla.lang.get("common.errors.error_occurred"),t.response?salla.logger.error(t):console.log("Unexpected error",t),this.btn.stop()&&this.btn.enable()&&this.reset()}))}render(){return"inline"==this.display?e(s,null,this.myBody()):e("salla-modal",{width:"xs",class:"s-verify",ref:t=>this.modal=t,"modal-title":this.title},e("span",{slot:"icon",class:"s-verify-header-icon",innerHTML:"mobile"==this.type?'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>android-phone</title>\n<path d="M22.667 0h-13.333c-2.941 0-5.333 2.392-5.333 5.333v21.333c0 2.941 2.392 5.333 5.333 5.333h13.333c2.941 0 5.333-2.392 5.333-5.333v-21.333c0-2.941-2.392-5.333-5.333-5.333zM25.333 26.667c0 1.471-1.196 2.667-2.667 2.667h-13.333c-1.471 0-2.667-1.196-2.667-2.667v-2.667h18.667zM25.333 21.333h-18.667v-16c0-1.471 1.196-2.667 2.667-2.667h13.333c1.471 0 2.667 1.196 2.667 2.667zM13.333 28h5.333c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333h-5.333c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333z"></path>\n</svg>\n':a}),this.myBody())}myBody(){return e("div",{class:"s-verify-body",ref:t=>this.body=t},e("div",{class:"s-verify-message",innerHTML:salla.lang.get("pages.profile.verify_message")}),e("slot",{name:"mobile"}),e("slot",{name:"email"}),e("input",{type:"hidden",name:"code",maxlength:"4",required:!0,ref:t=>this.code=t}),e("div",{class:{"s-verify-codes":!0,"has-error":this.hasError},dir:"ltr"},[1,2,3,4].map((t=>e("input",{type:"number",autocomplete:"one-time-code",pattern:"[0-9]*",inputmode:"numeric",maxlength:"1",value:"",id:`otp-${t}`,class:{"s-verify-input":!0,"s-has-error":this.hasError},onInput:t=>this.handleInput(t),onPaste:t=>this.handlePaste(t),onKeyUp:t=>this.handleKeyUp(t),onFocus:t=>this.handleFocus(t),required:!0})))),this.hasError&&this.errorMessage?e("span",{class:"s-verify-error-message"},this.errorMessage):"",e("div",{slot:"footer",class:"s-verify-footer"},e("salla-button",{class:"s-verify-submit","loader-position":"center",disabled:!0,onClick:()=>this.submit(),ref:t=>this.btn=t},salla.lang.get("pages.profile.verify")),e("p",{class:"s-verify-resend-message",ref:t=>this.resendMessage=t},salla.lang.get("blocks.header.resend_after"),e("b",{class:"s-verify-timer",ref:t=>this.timer=t})),e("a",{href:"#",class:"s-verify-resend",onClick:()=>this.resendCode(),ref:t=>this.resend=t},salla.lang.get("blocks.comments.submit"))),e("slot",{name:"after-footer"}))}get host(){return o(this)}};n.style='/*!twlt*/salla-verify{display:block}.s-verify-input{}.s-verify-input::-webkit-outer-spin-button,.s-verify-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.s-verify-input[type=number]{-moz-appearance:textfield}.visible{visibility:visible}.block{display:block}.inline{display:inline}.hidden{display:none}.s-has-error{--tw-border-opacity:1;border-color:rgb(248 113 113 / var(--tw-border-opacity, 1))}.s-has-error:focus{--tw-border-opacity:1;border-color:rgb(239 68 68 / var(--tw-border-opacity, 1))}.btn{display:inline-flex;flex:1 1 0%;align-items:center;justify-content:center;white-space:nowrap;border-radius:0.375rem;padding-left:1.5rem;padding-right:1.5rem;padding-bottom:0.625rem;padding-top:0.5rem;font-size:0.875rem;line-height:1.25rem;font-weight:700;transition-property:color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.btn:hover{opacity:0.8}.has-error .s-form-label{color:#ff443a}.has-error .s-form-control,.has-error .s-tel-input-control,.has-error .s-datetime-picker-input{border-color:#ff443a;color:#ff443a}.s-has-error{--tw-border-opacity:1 !important;border-color:rgb(239 68 68 / var(--tw-border-opacity, 1)) !important;--tw-text-opacity:1 !important;color:rgb(239 68 68 / var(--tw-text-opacity, 1)) !important}.s-verify-message{text-align:center;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-verify-label{margin-bottom:1rem;display:block;text-align:center;font-size:0.875rem;line-height:1.25rem}.s-verify-codes{margin-left:-0.25rem;margin-right:-0.25rem;margin-bottom:1.25rem;display:flex;justify-content:space-between}.s-verify-codes.has-error{margin-bottom:0px}.s-verify-input{margin-left:0.25rem;margin-right:0.25rem;height:2.5rem;width:100%;border-radius:var(--s-radius, 0.25rem);border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));padding-left:0.5rem;padding-right:0.5rem;text-align:center;font-size:1.125rem;line-height:1.75rem;font-weight:700;transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms}.s-verify-input:focus{border-color:var(--color-primary)}.s-verify-input:is(.dark *){--tw-border-opacity:1;border-color:rgb(75 85 99 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(75 85 99 / var(--tw-bg-opacity, 1))}.s-verify-footer{text-align:center}.s-verify-submit{margin-bottom:1.25rem;width:100%}.s-verify-header-icon{display:inline-flex;height:3rem;width:3rem;align-items:center;justify-content:center;border-radius:9999px;border-width:1px;border-style:solid;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}@media (min-width: 640px){.s-verify-header-icon{margin-left:auto;margin-right:auto;margin-bottom:1rem;height:5rem;width:5rem}}.s-verify-header-icon:where([dir="ltr"],[dir="ltr"] *){margin-right:0.5rem}@media (min-width: 640px){.s-verify-header-icon:where([dir="ltr"],[dir="ltr"] *){margin-right:0px}}.s-verify-header-icon:where([dir="rtl"],[dir="rtl"] *){margin-left:0.5rem}@media (min-width: 640px){.s-verify-header-icon:where([dir="rtl"],[dir="rtl"] *){margin-left:0px}}.s-verify-resend-message{font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-verify-error-message{margin-bottom:1.25rem;display:block;height:1.75rem;padding-top:0.75rem;text-align:center;font-size:0.75rem;line-height:1rem;--tw-border-opacity:1;border-color:rgb(248 113 113 / var(--tw-border-opacity, 1))}.s-verify-error-message:focus{--tw-border-opacity:1;border-color:rgb(239 68 68 / var(--tw-border-opacity, 1))}.s-verify-error-message{--tw-border-opacity:1 !important;border-color:rgb(239 68 68 / var(--tw-border-opacity, 1)) !important;--tw-text-opacity:1 !important;color:rgb(239 68 68 / var(--tw-text-opacity, 1)) !important}.s-verify-timer{margin-left:0.25rem;margin-right:0.25rem;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-verify-resend{text-align:center;font-size:0.875rem;line-height:1.25rem;color:var(--color-primary)}.s-verify-back{position:absolute;left:10px;top:10px;display:flex;height:2rem;width:2rem;align-items:center;justify-content:center;border-radius:9999px;--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));font-size:1.125rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(75 85 99 / var(--tw-text-opacity, 1));transition-property:color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms}.s-verify-back:hover{--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.s-verify-back:where([dir="rtl"],[dir="rtl"] *){left:unset;right:10px}.s-verify-back svg{height:18px;width:18px}[dir=\'ltr\'] .s-verify-back{transform:scale(-1)}';export{n as salla_verify}
4
+ import{r as t,c as i,f as r,h as e,H as s,a as o}from"./p-DvJClBwJ.js";import{M as a}from"./p-DmgxDvXL.js";const n=class{constructor(r){t(this,r),this.verified=i(this,"verified"),this.translationLoaded=!1,this.display="modal",this.type="mobile",this.autoReload=!0,this.supportWebAuth=!0,this.resendAfter=30,this.isProfileVerify=!1,"inline"!=this.display?(this.profileVerificationListener=t=>{let i=Array.isArray(t)?t[0]:t;"delete_account"===i?.request_type||document.getElementById("salla-user-settings-delete-modal")?.hasAttribute("visible")||(this.isProfileVerify=!0,this.open(i),this.title=salla.lang.get("pages.profile.verify_title")+salla.lang.get("common.elements."+i.type),this.modal?.setTitle(this.title))},this.modalClosedListener=()=>{this.resendAfter=0,this.timer.innerHTML="30 : 00"}):this.modal={open:()=>"",close:()=>"",setTitle:()=>""}}connectedCallback(){this.profileVerificationListener&&(salla.event.on("profile::verification",this.profileVerificationListener),salla.event.on("modalClosed",this.modalClosedListener)),this.langUnsubscribe=salla.lang.subscribe((()=>{this.translationLoaded=!0,this.title=salla.lang.get("pages.profile.verify_title")+salla.lang.get("common.elements."+this.type),this.modal?.setTitle(this.title),r(this)}))}disconnectedCallback(){this.profileVerificationListener&&(salla.event.off("profile::verification",this.profileVerificationListener),salla.event.off("modalClosed",this.modalClosedListener)),this.langUnsubscribe?.()}splitNumber(t){this.resetError();let i=t.data||t.target.value;i&&1!==i.length&&this.modifyNext(t.target,i)}modifyNext(t,i){t.value=i[0],i=i.substring(1),t.nextElementSibling&&i.length?this.modifyNext(t.nextElementSibling,i):t.nextElementSibling||0!==i.length?t.nextElementSibling&&0===i.length&&t.nextElementSibling.focus():t.focus()}checkAllInputs(){let t=!0;for(let i=0;i<this.otpInputs.length;i++)""===this.otpInputs[i].value&&(t=!1);return t}handleKeyUp(t){if(this.resetError(),["Alt","Shift","Control","AltGraph","Ctrl"].includes(t.key))return;let i=t.keyCode||t.charCode;t.target.value?(t.target.nextElementSibling?.focus(),t.target.nextElementSibling?.select()):[8,46].includes(i)&&(t.target.previousElementSibling?.focus(),t.target.previousElementSibling?.select()),t.target.value.length>1&&this.splitNumber(t)}handlePaste(t){this.resetError();let i=(salla.helpers.number(t.clipboardData.getData("text"))||"").replace(/[^0-9]/g,"");i=i.substring(0,this.otpInputs.length),this.otpInputs.forEach((t=>t.value="")),this.modifyNext(this.otpInputs[0],i)}handleInput(t){this.resetError(),salla.helpers.inputDigitsOnly(t.target),this.checkAllInputs()&&setTimeout((()=>{this.toggleOTPSubmit()}),100)}resetError(){this.hasError=!1,this.errorMessage=""}handleFocus(t){t.target!==this.firstOtpInput&&(""==this.firstOtpInput?.value&&this.firstOtpInput.focus(),""==t.target.previousElementSibling.value&&t.target.previousElementSibling.focus())}async getCode(){return this.code.value}async open(t){this.data=t,this.data.type=this.data.type||this.type,this.type=this.data.type,this.resendTimer(),this.otpInputs=this.body.querySelectorAll(".s-verify-input"),this.firstOtpInput=this.body.querySelector("#otp-1"),this.reset(),this.resetError(),"modal"==this.display&&this.modal?.setTitle(this.title),this.modal.open(),this.firstOtpInput?.addEventListener("input",(t=>this.splitNumber(t))),setTimeout((()=>this.otpInputs[0].focus()),100)}toggleOTPSubmit(){let t=[];if(this.otpInputs.forEach((i=>i.value&&t.push(i.value))),this.code.value=t.join(""),4===t.length)return this.btn.disable(),void this.btn.click();this.btn.enable()}reset(){this.otpInputs.forEach((t=>t.value="")),this.code.value="",this.otpInputs[0].focus()}resendTimer(){this.resendMessage.style.display="block",this.resend.style.display="none",this.resendAfter=30;let t=setInterval((()=>{this.resendAfter<=0?(clearInterval(t),this.resend.style.display="block",this.resendMessage.style.display="none"):(this.timer.innerHTML=`${this.resendAfter>=10?this.resendAfter:"0"+this.resendAfter} : 00`,this.resendAfter--)}),1e3)}resendCode(){return this.btn.stop().then((()=>this.btn.disable())).then((()=>{this.otpInputs.forEach((t=>t.value="")),this.otpInputs[0].focus()})).then((()=>this.resendHandler?this.resendHandler(this.data):salla.api.auth.resend(this.data))).finally((()=>this.resendTimer()))}submit(){if(this.code.value.length<4)return this.otpInputs[this.code.value.length].focus(),void salla.log("Trying to submit without 4 digits!");let t={code:this.code.value,...this.data};return this.btn.load().then((()=>this.btn.disable())).then((()=>this.verifyHandler?this.verifyHandler(t):this.isProfileVerify?salla.profile.verify(t):salla.auth.verify(t,this.supportWebAuth))).then((t=>this.verified.emit(t))).then((()=>this.btn.stop()&&this.btn.disable())).then((()=>this.modal.close())).then((()=>this.autoReload&&window.location.reload())).catch((t=>{this.hasError=!0,this.errorMessage=t.response?.data?.error?.message||salla.lang.get("common.errors.error_occurred"),t.response?salla.logger.error(t):console.log("Unexpected error",t),this.btn.stop()&&this.btn.enable()&&this.reset()}))}render(){return"inline"==this.display?e(s,null,this.myBody()):e("salla-modal",{width:"xs",class:"s-verify",ref:t=>this.modal=t,"modal-title":this.title},e("span",{slot:"icon",class:"s-verify-header-icon",innerHTML:"mobile"==this.type?'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>android-phone</title>\n<path d="M22.667 0h-13.333c-2.941 0-5.333 2.392-5.333 5.333v21.333c0 2.941 2.392 5.333 5.333 5.333h13.333c2.941 0 5.333-2.392 5.333-5.333v-21.333c0-2.941-2.392-5.333-5.333-5.333zM25.333 26.667c0 1.471-1.196 2.667-2.667 2.667h-13.333c-1.471 0-2.667-1.196-2.667-2.667v-2.667h18.667zM25.333 21.333h-18.667v-16c0-1.471 1.196-2.667 2.667-2.667h13.333c1.471 0 2.667 1.196 2.667 2.667zM13.333 28h5.333c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333h-5.333c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333z"></path>\n</svg>\n':a}),this.myBody())}myBody(){return e("div",{class:"s-verify-body",ref:t=>this.body=t},e("div",{class:"s-verify-message",innerHTML:salla.lang.get("pages.profile.verify_message")}),e("slot",{name:"mobile"}),e("slot",{name:"email"}),e("input",{type:"hidden",name:"code",maxlength:"4",required:!0,ref:t=>this.code=t}),e("div",{class:{"s-verify-codes":!0,"has-error":this.hasError},dir:"ltr"},[1,2,3,4].map((t=>e("input",{type:"number",autocomplete:"one-time-code",pattern:"[0-9]*",inputmode:"numeric",maxlength:"1",value:"",id:`otp-${t}`,class:{"s-verify-input":!0,"s-has-error":this.hasError},onInput:t=>this.handleInput(t),onPaste:t=>this.handlePaste(t),onKeyUp:t=>this.handleKeyUp(t),onFocus:t=>this.handleFocus(t),required:!0})))),this.hasError&&this.errorMessage?e("span",{class:"s-verify-error-message"},this.errorMessage):"",e("div",{slot:"footer",class:"s-verify-footer"},e("salla-button",{class:"s-verify-submit","loader-position":"center",disabled:!0,onClick:()=>this.submit(),ref:t=>this.btn=t},salla.lang.get("pages.profile.verify")),e("p",{class:"s-verify-resend-message",ref:t=>this.resendMessage=t},salla.lang.get("blocks.header.resend_after"),e("b",{class:"s-verify-timer",ref:t=>this.timer=t})),e("a",{href:"#",class:"s-verify-resend",onClick:()=>this.resendCode(),ref:t=>this.resend=t},salla.lang.get("blocks.comments.submit"))),e("slot",{name:"after-footer"}))}get host(){return o(this)}};n.style='/*!twlt*/salla-verify{display:block}.s-verify-input{}.s-verify-input::-webkit-outer-spin-button,.s-verify-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.s-verify-input[type=number]{-moz-appearance:textfield}.visible{visibility:visible}.block{display:block}.inline{display:inline}.hidden{display:none}.s-has-error{--tw-border-opacity:1;border-color:rgb(248 113 113 / var(--tw-border-opacity, 1))}.s-has-error:focus{--tw-border-opacity:1;border-color:rgb(239 68 68 / var(--tw-border-opacity, 1))}.btn{display:inline-flex;flex:1 1 0%;align-items:center;justify-content:center;white-space:nowrap;border-radius:0.375rem;padding-left:1.5rem;padding-right:1.5rem;padding-bottom:0.625rem;padding-top:0.5rem;font-size:0.875rem;line-height:1.25rem;font-weight:700;transition-property:color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.btn:hover{opacity:0.8}.has-error .s-form-label{color:#ff443a}.has-error .s-form-control,.has-error .s-tel-input-control,.has-error .s-datetime-picker-input{border-color:#ff443a;color:#ff443a}.s-has-error{--tw-border-opacity:1 !important;border-color:rgb(239 68 68 / var(--tw-border-opacity, 1)) !important;--tw-text-opacity:1 !important;color:rgb(239 68 68 / var(--tw-text-opacity, 1)) !important}.s-verify-message{text-align:center;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-verify-label{margin-bottom:1rem;display:block;text-align:center;font-size:0.875rem;line-height:1.25rem}.s-verify-codes{margin-left:-0.25rem;margin-right:-0.25rem;margin-bottom:1.25rem;display:flex;justify-content:space-between}.s-verify-codes.has-error{margin-bottom:0px}.s-verify-input{margin-left:0.25rem;margin-right:0.25rem;height:2.5rem;width:100%;border-radius:var(--s-radius, 0.25rem);border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));padding-left:0.5rem;padding-right:0.5rem;text-align:center;font-size:1.125rem;line-height:1.75rem;font-weight:700;transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms}.s-verify-input:focus{border-color:var(--color-primary)}.s-verify-input:is(.dark *){--tw-border-opacity:1;border-color:rgb(75 85 99 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(75 85 99 / var(--tw-bg-opacity, 1))}.s-verify-footer{text-align:center}.s-verify-submit{margin-bottom:1.25rem;width:100%}.s-verify-header-icon{display:inline-flex;height:3rem;width:3rem;align-items:center;justify-content:center;border-radius:9999px;border-width:1px;border-style:solid;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}@media (min-width: 640px){.s-verify-header-icon{margin-left:auto;margin-right:auto;margin-bottom:1rem;height:5rem;width:5rem}}.s-verify-header-icon:where([dir="ltr"],[dir="ltr"] *){margin-right:0.5rem}@media (min-width: 640px){.s-verify-header-icon:where([dir="ltr"],[dir="ltr"] *){margin-right:0px}}.s-verify-header-icon:where([dir="rtl"],[dir="rtl"] *){margin-left:0.5rem}@media (min-width: 640px){.s-verify-header-icon:where([dir="rtl"],[dir="rtl"] *){margin-left:0px}}.s-verify-resend-message{font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-verify-error-message{margin-bottom:1.25rem;display:block;height:1.75rem;padding-top:0.75rem;text-align:center;font-size:0.75rem;line-height:1rem;--tw-border-opacity:1;border-color:rgb(248 113 113 / var(--tw-border-opacity, 1))}.s-verify-error-message:focus{--tw-border-opacity:1;border-color:rgb(239 68 68 / var(--tw-border-opacity, 1))}.s-verify-error-message{--tw-border-opacity:1 !important;border-color:rgb(239 68 68 / var(--tw-border-opacity, 1)) !important;--tw-text-opacity:1 !important;color:rgb(239 68 68 / var(--tw-text-opacity, 1)) !important}.s-verify-timer{margin-left:0.25rem;margin-right:0.25rem;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-verify-resend{text-align:center;font-size:0.875rem;line-height:1.25rem;color:var(--color-primary)}.s-verify-back{position:absolute;left:10px;top:10px;display:flex;height:2rem;width:2rem;align-items:center;justify-content:center;border-radius:9999px;--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));font-size:1.125rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(75 85 99 / var(--tw-text-opacity, 1));transition-property:color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms}.s-verify-back:hover{--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.s-verify-back:where([dir="rtl"],[dir="rtl"] *){left:unset;right:10px}.s-verify-back svg{height:18px;width:18px}[dir=\'ltr\'] .s-verify-back{transform:scale(-1)}';export{n as salla_verify}