@salla.sa/twilight-components 2.14.593 → 2.14.595

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 (352) hide show
  1. package/dist/cjs/{filepond-Dh9Ih7bu.js → filepond-BmX7bEQk.js} +1 -1
  2. package/dist/cjs/{filepond-plugin-file-poster-C6Sx5vF0.js → filepond-plugin-file-poster-Cs6e85Vn.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-validate-size-DdzdetN6.js → filepond-plugin-file-validate-size-CSk66JAo.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-type-DRWFKOpQ.js → filepond-plugin-file-validate-type-Piu3p2Um.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-image-edit-B4vaf2kZ.js → filepond-plugin-image-edit-Ba9FBal4.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-exif-orientation-BXfm40Ut.js → filepond-plugin-image-exif-orientation-zwtgHyrT.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-preview-DQLCCOAs.js → filepond-plugin-image-preview-BmGjui8n.js} +1 -1
  8. package/dist/cjs/{index-CLrjVXN1.js → index-DkrDtx6i.js} +21 -7
  9. package/dist/cjs/{intlTelInput-o62W18dw.js → intlTelInput-Bty1-N7J.js} +1 -1
  10. package/dist/cjs/loader.cjs.js +2 -2
  11. package/dist/cjs/salla-accordion-body_2.cjs.entry.js +1 -1
  12. package/dist/cjs/salla-accordion_6.cjs.entry.js +1 -1
  13. package/dist/cjs/salla-add-product-button_5.cjs.entry.js +1 -1
  14. package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
  15. package/dist/cjs/salla-alert_2.cjs.entry.js +1 -1
  16. package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
  17. package/dist/cjs/salla-applied-filters.cjs.entry.js +1 -1
  18. package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
  19. package/dist/cjs/salla-attachment-view_9.cjs.entry.js +10 -10
  20. package/dist/cjs/salla-badge.cjs.entry.js +1 -1
  21. package/dist/cjs/salla-basket-gap.cjs.entry.js +1 -1
  22. package/dist/cjs/salla-bullet-delivery_3.cjs.entry.js +286 -20
  23. package/dist/cjs/salla-cart-coupons.cjs.entry.js +68 -15
  24. package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +1 -1
  25. package/dist/cjs/salla-cart-summary-card.cjs.entry.js +29 -4
  26. package/dist/cjs/salla-cashback-banner.cjs.entry.js +1 -1
  27. package/dist/cjs/salla-comment-factors.cjs.entry.js +1 -1
  28. package/dist/cjs/salla-comment-form_9.cjs.entry.js +1 -1
  29. package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
  30. package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
  31. package/dist/cjs/salla-cookies-bar.cjs.entry.js +1 -1
  32. package/dist/cjs/salla-count-down.cjs.entry.js +1 -1
  33. package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
  34. package/dist/cjs/salla-delivery-promise.cjs.entry.js +1 -1
  35. package/dist/cjs/salla-edit-order-button.cjs.entry.js +1 -1
  36. package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
  37. package/dist/cjs/salla-filters.cjs.entry.js +1 -1
  38. package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +1 -1
  39. package/dist/cjs/salla-gift-card-redeem_2.cjs.entry.js +1 -1
  40. package/dist/cjs/salla-gifting.cjs.entry.js +1 -1
  41. package/dist/cjs/salla-hook.cjs.entry.js +1 -1
  42. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
  43. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  44. package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
  45. package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
  46. package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
  47. package/dist/cjs/salla-loyalty-banner_10.cjs.entry.js +1 -1
  48. package/dist/cjs/salla-loyalty-exchange-product-card.cjs.entry.js +1 -1
  49. package/dist/cjs/salla-loyalty-points-banner.cjs.entry.js +1 -1
  50. package/dist/cjs/salla-loyalty-points-history.cjs.entry.js +1 -1
  51. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  52. package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
  53. package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
  54. package/dist/cjs/salla-map_3.cjs.entry.js +1 -1
  55. package/dist/cjs/salla-menu.cjs.entry.js +1 -1
  56. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  57. package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
  58. package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
  59. package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
  60. package/dist/cjs/salla-next-order-coupon.cjs.entry.js +1 -1
  61. package/dist/cjs/salla-notification-item_2.cjs.entry.js +1 -1
  62. package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
  63. package/dist/cjs/salla-offer.cjs.entry.js +1 -1
  64. package/dist/cjs/salla-order-branch.cjs.entry.js +1 -1
  65. package/dist/cjs/salla-order-cancel.cjs.entry.js +1 -1
  66. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
  67. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  68. package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
  69. package/dist/cjs/salla-order-edit-item.cjs.entry.js +1 -1
  70. package/dist/cjs/salla-order-edit-product-card.cjs.entry.js +1 -1
  71. package/dist/cjs/salla-order-edit.cjs.entry.js +1 -1
  72. package/dist/cjs/salla-order-options-modal.cjs.entry.js +1 -1
  73. package/dist/cjs/salla-order-shipments.cjs.entry.js +1 -1
  74. package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
  75. package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
  76. package/dist/cjs/salla-orders.cjs.entry.js +1 -1
  77. package/dist/cjs/salla-payments.cjs.entry.js +1 -1
  78. package/dist/cjs/salla-placeholder.cjs.entry.js +1 -1
  79. package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
  80. package/dist/cjs/salla-product-card-embed.cjs.entry.js +1 -1
  81. package/dist/cjs/salla-product-card.cjs.entry.js +1 -1
  82. package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
  83. package/dist/cjs/salla-products-list.cjs.entry.js +1 -1
  84. package/dist/cjs/salla-products-slider.cjs.entry.js +1 -1
  85. package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
  86. package/dist/cjs/salla-rating-modal-v2.cjs.entry.js +1 -1
  87. package/dist/cjs/salla-rating-modal.cjs.entry.js +1 -1
  88. package/dist/cjs/salla-review-factors-tags.cjs.entry.js +1 -1
  89. package/dist/cjs/salla-review-order-item.cjs.entry.js +1 -1
  90. package/dist/cjs/salla-scopes.cjs.entry.js +1 -1
  91. package/dist/cjs/salla-search-product-card.cjs.entry.js +1 -1
  92. package/dist/cjs/salla-search.cjs.entry.js +1 -1
  93. package/dist/cjs/salla-skeleton.cjs.entry.js +1 -1
  94. package/dist/cjs/salla-social-share.cjs.entry.js +1 -1
  95. package/dist/cjs/salla-social.cjs.entry.js +1 -1
  96. package/dist/cjs/salla-tab-content_3.cjs.entry.js +1 -1
  97. package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
  98. package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
  99. package/dist/cjs/salla-user-menu.cjs.entry.js +1 -1
  100. package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
  101. package/dist/cjs/salla-user-settings.cjs.entry.js +1 -1
  102. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  103. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  104. package/dist/cjs/salla-wishlist-actions.cjs.entry.js +1 -1
  105. package/dist/cjs/salla-wishlist-summary.cjs.entry.js +1 -1
  106. package/dist/cjs/twilight.cjs.js +2 -2
  107. package/dist/cjs/{vanilla-picker-FCNrUTtN.js → vanilla-picker-DgPfWupN.js} +1 -1
  108. package/dist/collection/components/salla-bullet-delivery/location-distance-warning.js +28 -0
  109. package/dist/collection/components/salla-bullet-delivery/location-icon.svg +26 -0
  110. package/dist/collection/components/salla-bullet-delivery/location-permission-notice.js +103 -0
  111. package/dist/collection/components/salla-bullet-delivery/salla-bullet-delivery.css +136 -0
  112. package/dist/collection/components/salla-bullet-delivery/salla-bullet-delivery.js +133 -19
  113. package/dist/collection/components/salla-cart-coupons/salla-cart-coupons.js +69 -15
  114. package/dist/collection/components/salla-cart-summary-card/salla-cart-summary-card.js +30 -3
  115. package/dist/collection/global/app.js +2 -0
  116. package/dist/collection/global/app.spec.ts +33 -0
  117. package/dist/collection/global/app.ts +2 -0
  118. package/dist/collection/global/chunk-errors.js +14 -0
  119. package/dist/collection/global/chunk-errors.spec.ts +47 -0
  120. package/dist/collection/global/chunk-errors.ts +13 -0
  121. package/dist/components/index.js +15 -2
  122. package/dist/components/salla-bullet-delivery.js +288 -20
  123. package/dist/components/salla-cart-coupons.js +68 -14
  124. package/dist/components/salla-cart-summary-card.js +30 -3
  125. package/dist/docs.json +1 -1
  126. package/dist/esm/{filepond-DTcw03Zq.js → filepond-DF26o67L.js} +1 -1
  127. package/dist/esm/{filepond-plugin-file-poster-Csk5cMw9.js → filepond-plugin-file-poster-B4epzDDH.js} +1 -1
  128. package/dist/esm/{filepond-plugin-file-validate-size-FFrf5LrW.js → filepond-plugin-file-validate-size-DILJc03j.js} +1 -1
  129. package/dist/esm/{filepond-plugin-file-validate-type-DeZP4xXd.js → filepond-plugin-file-validate-type-Bic7dGts.js} +1 -1
  130. package/dist/esm/{filepond-plugin-image-edit-DRKyd_1I.js → filepond-plugin-image-edit-DHfCLKK0.js} +1 -1
  131. package/dist/esm/{filepond-plugin-image-exif-orientation-CxVz7OAy.js → filepond-plugin-image-exif-orientation-C7y59Hrn.js} +1 -1
  132. package/dist/esm/{filepond-plugin-image-preview-CsKN7em3.js → filepond-plugin-image-preview-C-ZqWLeC.js} +1 -1
  133. package/dist/esm/{index-0Tl_yZW8.js → index-HRJpfiBN.js} +21 -7
  134. package/dist/esm/{intlTelInput-CBN9egFg.js → intlTelInput-DOVRUqFb.js} +1 -1
  135. package/dist/esm/loader.js +3 -3
  136. package/dist/esm/salla-accordion-body_2.entry.js +1 -1
  137. package/dist/esm/salla-accordion_6.entry.js +1 -1
  138. package/dist/esm/salla-add-product-button_5.entry.js +1 -1
  139. package/dist/esm/salla-advertisement.entry.js +1 -1
  140. package/dist/esm/salla-alert_2.entry.js +1 -1
  141. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  142. package/dist/esm/salla-applied-filters.entry.js +1 -1
  143. package/dist/esm/salla-apps-icons.entry.js +1 -1
  144. package/dist/esm/salla-attachment-view_9.entry.js +10 -10
  145. package/dist/esm/salla-badge.entry.js +1 -1
  146. package/dist/esm/salla-basket-gap.entry.js +1 -1
  147. package/dist/esm/salla-bullet-delivery_3.entry.js +286 -20
  148. package/dist/esm/salla-cart-coupons.entry.js +68 -15
  149. package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
  150. package/dist/esm/salla-cart-summary-card.entry.js +29 -4
  151. package/dist/esm/salla-cashback-banner.entry.js +1 -1
  152. package/dist/esm/salla-comment-factors.entry.js +1 -1
  153. package/dist/esm/salla-comment-form_9.entry.js +1 -1
  154. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  155. package/dist/esm/salla-contacts.entry.js +1 -1
  156. package/dist/esm/salla-cookies-bar.entry.js +1 -1
  157. package/dist/esm/salla-count-down.entry.js +1 -1
  158. package/dist/esm/salla-custom-fields.entry.js +1 -1
  159. package/dist/esm/salla-delivery-promise.entry.js +1 -1
  160. package/dist/esm/salla-edit-order-button.entry.js +1 -1
  161. package/dist/esm/salla-filters-widget.entry.js +1 -1
  162. package/dist/esm/salla-filters.entry.js +1 -1
  163. package/dist/esm/salla-fulfillment-methods.entry.js +1 -1
  164. package/dist/esm/salla-gift-card-redeem_2.entry.js +1 -1
  165. package/dist/esm/salla-gifting.entry.js +1 -1
  166. package/dist/esm/salla-hook.entry.js +1 -1
  167. package/dist/esm/salla-infinite-scroll.entry.js +1 -1
  168. package/dist/esm/salla-installment.entry.js +1 -1
  169. package/dist/esm/salla-list-tile.entry.js +1 -1
  170. package/dist/esm/salla-localization-modal.entry.js +1 -1
  171. package/dist/esm/salla-login-modal.entry.js +1 -1
  172. package/dist/esm/salla-loyalty-banner_10.entry.js +1 -1
  173. package/dist/esm/salla-loyalty-exchange-product-card.entry.js +1 -1
  174. package/dist/esm/salla-loyalty-points-banner.entry.js +1 -1
  175. package/dist/esm/salla-loyalty-points-history.entry.js +1 -1
  176. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  177. package/dist/esm/salla-loyalty.entry.js +1 -1
  178. package/dist/esm/salla-maintenance-alert.entry.js +1 -1
  179. package/dist/esm/salla-map_3.entry.js +1 -1
  180. package/dist/esm/salla-menu.entry.js +1 -1
  181. package/dist/esm/salla-metadata.entry.js +1 -1
  182. package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
  183. package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
  184. package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
  185. package/dist/esm/salla-next-order-coupon.entry.js +1 -1
  186. package/dist/esm/salla-notification-item_2.entry.js +1 -1
  187. package/dist/esm/salla-offer-modal.entry.js +1 -1
  188. package/dist/esm/salla-offer.entry.js +1 -1
  189. package/dist/esm/salla-order-branch.entry.js +1 -1
  190. package/dist/esm/salla-order-cancel.entry.js +1 -1
  191. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  192. package/dist/esm/salla-order-details-options.entry.js +1 -1
  193. package/dist/esm/salla-order-details.entry.js +1 -1
  194. package/dist/esm/salla-order-edit-item.entry.js +1 -1
  195. package/dist/esm/salla-order-edit-product-card.entry.js +1 -1
  196. package/dist/esm/salla-order-edit.entry.js +1 -1
  197. package/dist/esm/salla-order-options-modal.entry.js +1 -1
  198. package/dist/esm/salla-order-shipments.entry.js +1 -1
  199. package/dist/esm/salla-order-summary.entry.js +1 -1
  200. package/dist/esm/salla-order-totals-card.entry.js +1 -1
  201. package/dist/esm/salla-orders.entry.js +1 -1
  202. package/dist/esm/salla-payments.entry.js +1 -1
  203. package/dist/esm/salla-placeholder.entry.js +1 -1
  204. package/dist/esm/salla-price-range.entry.js +1 -1
  205. package/dist/esm/salla-product-card-embed.entry.js +1 -1
  206. package/dist/esm/salla-product-card.entry.js +1 -1
  207. package/dist/esm/salla-product-size-guide.entry.js +1 -1
  208. package/dist/esm/salla-products-list.entry.js +1 -1
  209. package/dist/esm/salla-products-slider.entry.js +1 -1
  210. package/dist/esm/salla-quick-order.entry.js +1 -1
  211. package/dist/esm/salla-rating-modal-v2.entry.js +1 -1
  212. package/dist/esm/salla-rating-modal.entry.js +1 -1
  213. package/dist/esm/salla-review-factors-tags.entry.js +1 -1
  214. package/dist/esm/salla-review-order-item.entry.js +1 -1
  215. package/dist/esm/salla-scopes.entry.js +1 -1
  216. package/dist/esm/salla-search-product-card.entry.js +1 -1
  217. package/dist/esm/salla-search.entry.js +1 -1
  218. package/dist/esm/salla-skeleton.entry.js +1 -1
  219. package/dist/esm/salla-social-share.entry.js +1 -1
  220. package/dist/esm/salla-social.entry.js +1 -1
  221. package/dist/esm/salla-tab-content_3.entry.js +1 -1
  222. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  223. package/dist/esm/salla-trust-badges.entry.js +1 -1
  224. package/dist/esm/salla-user-menu.entry.js +1 -1
  225. package/dist/esm/salla-user-profile.entry.js +1 -1
  226. package/dist/esm/salla-user-settings.entry.js +1 -1
  227. package/dist/esm/salla-verify.entry.js +1 -1
  228. package/dist/esm/salla-wallet.entry.js +1 -1
  229. package/dist/esm/salla-wishlist-actions.entry.js +1 -1
  230. package/dist/esm/salla-wishlist-summary.entry.js +1 -1
  231. package/dist/esm/twilight.js +3 -3
  232. package/dist/esm/{vanilla-picker-CiLp9ysz.js → vanilla-picker-DQKehCLa.js} +1 -1
  233. package/dist/twilight/global/app.spec.ts +33 -0
  234. package/dist/twilight/global/app.ts +2 -0
  235. package/dist/twilight/global/chunk-errors.spec.ts +47 -0
  236. package/dist/twilight/global/chunk-errors.ts +13 -0
  237. package/dist/twilight/{p-b566bc10.entry.js → p-02d79968.entry.js} +1 -1
  238. package/dist/twilight/{p-f445e7a3.entry.js → p-078e5ef8.entry.js} +1 -1
  239. package/dist/twilight/{p-40be8baa.entry.js → p-07e1822a.entry.js} +1 -1
  240. package/dist/twilight/{p-d744234e.entry.js → p-0e430b25.entry.js} +1 -1
  241. package/dist/twilight/{p-9a818822.entry.js → p-100260a2.entry.js} +1 -1
  242. package/dist/twilight/{p-1892ea42.entry.js → p-117c8823.entry.js} +1 -1
  243. package/dist/twilight/{p-449eae1d.entry.js → p-119aa7c1.entry.js} +1 -1
  244. package/dist/twilight/{p-e8cb4cd9.entry.js → p-14b78c6e.entry.js} +1 -1
  245. package/dist/twilight/{p-bc3ad6d2.entry.js → p-155f1fed.entry.js} +1 -1
  246. package/dist/twilight/{p-1abcc81d.entry.js → p-16b45c19.entry.js} +1 -1
  247. package/dist/twilight/{p-7c06ad6a.entry.js → p-1a684490.entry.js} +1 -1
  248. package/dist/twilight/{p-b0d66765.entry.js → p-1b0da3b9.entry.js} +1 -1
  249. package/dist/twilight/{p-fe27963f.entry.js → p-20d5665b.entry.js} +1 -1
  250. package/dist/twilight/{p-2cbed601.entry.js → p-231d4bf2.entry.js} +1 -1
  251. package/dist/twilight/{p-5cc28510.entry.js → p-235f40b0.entry.js} +1 -1
  252. package/dist/twilight/{p-7bee2390.entry.js → p-2413d450.entry.js} +1 -1
  253. package/dist/twilight/{p-6561d5d3.entry.js → p-25ea21a6.entry.js} +1 -1
  254. package/dist/twilight/{p-fea37c8c.entry.js → p-2c13b5e8.entry.js} +1 -1
  255. package/dist/twilight/{p-e8fa4bd0.entry.js → p-2f96a72f.entry.js} +1 -1
  256. package/dist/twilight/{p-fb527b4d.entry.js → p-312d231b.entry.js} +1 -1
  257. package/dist/twilight/{p-52e7b4f6.entry.js → p-313dbe67.entry.js} +1 -1
  258. package/dist/twilight/{p-636ffc46.entry.js → p-334fc442.entry.js} +1 -1
  259. package/dist/twilight/{p-c394f30a.entry.js → p-33a64882.entry.js} +1 -1
  260. package/dist/twilight/{p-fef5c118.entry.js → p-3c0be6b1.entry.js} +1 -1
  261. package/dist/twilight/{p-14c9ed90.entry.js → p-3e232b09.entry.js} +1 -1
  262. package/dist/twilight/{p-933807d7.entry.js → p-3f376a9d.entry.js} +1 -1
  263. package/dist/twilight/{p-7f59893d.entry.js → p-46ad2b0e.entry.js} +1 -1
  264. package/dist/twilight/{p-a764bfe7.entry.js → p-49d6d82e.entry.js} +1 -1
  265. package/dist/twilight/{p-cc7c4469.entry.js → p-49e2f73d.entry.js} +1 -1
  266. package/dist/twilight/{p-75fc9b99.entry.js → p-4cee6b43.entry.js} +1 -1
  267. package/dist/twilight/{p-e9372ca0.entry.js → p-4e0dcb5c.entry.js} +1 -1
  268. package/dist/twilight/{p-4701a008.entry.js → p-4e3a3c55.entry.js} +1 -1
  269. package/dist/twilight/{p-42426756.entry.js → p-4e74c79f.entry.js} +1 -1
  270. package/dist/twilight/{p-2ac1eac9.entry.js → p-4f9da81b.entry.js} +1 -1
  271. package/dist/twilight/{p-0fe961e0.entry.js → p-5134faef.entry.js} +1 -1
  272. package/dist/twilight/p-5b617110.entry.js +4 -0
  273. package/dist/twilight/{p-01b4b05f.entry.js → p-5bc3f956.entry.js} +1 -1
  274. package/dist/twilight/{p-299e7413.entry.js → p-5f0eca54.entry.js} +1 -1
  275. package/dist/twilight/{p-918fa44a.entry.js → p-5fae444a.entry.js} +1 -1
  276. package/dist/twilight/{p-65665ee3.entry.js → p-61c8e3c6.entry.js} +1 -1
  277. package/dist/twilight/{p-2d2db627.entry.js → p-6e8cb8fb.entry.js} +1 -1
  278. package/dist/twilight/{p-99e615a1.entry.js → p-6feb378a.entry.js} +1 -1
  279. package/dist/twilight/{p-1bf7cce7.entry.js → p-70c45a90.entry.js} +1 -1
  280. package/dist/twilight/{p-deb1139c.entry.js → p-73b8ed51.entry.js} +1 -1
  281. package/dist/twilight/p-75ed7d4e.entry.js +4 -0
  282. package/dist/twilight/{p-ddc61bff.entry.js → p-761e273c.entry.js} +1 -1
  283. package/dist/twilight/{p-253a352c.entry.js → p-768f5c26.entry.js} +1 -1
  284. package/dist/twilight/{p-288627a2.entry.js → p-76f49fd8.entry.js} +1 -1
  285. package/dist/twilight/{p-775f9b02.entry.js → p-7960e489.entry.js} +1 -1
  286. package/dist/twilight/{p-aec2d723.entry.js → p-7f38cf0c.entry.js} +1 -1
  287. package/dist/twilight/{p-179595d9.entry.js → p-7f58cf36.entry.js} +1 -1
  288. package/dist/twilight/{p-44afcd79.entry.js → p-83edd1a1.entry.js} +1 -1
  289. package/dist/twilight/{p-dc129d7a.entry.js → p-845e4790.entry.js} +1 -1
  290. package/dist/twilight/{p-31253c2d.entry.js → p-84c56f4d.entry.js} +1 -1
  291. package/dist/twilight/{p-4432411c.entry.js → p-8688c21f.entry.js} +1 -1
  292. package/dist/twilight/{p-821e9049.entry.js → p-87d34b7c.entry.js} +1 -1
  293. package/dist/twilight/{p-b01764d0.entry.js → p-8be3fa1c.entry.js} +1 -1
  294. package/dist/twilight/{p-f92d1971.entry.js → p-8dc7ae26.entry.js} +1 -1
  295. package/dist/twilight/{p-4d879cd3.entry.js → p-8e0a33dd.entry.js} +1 -1
  296. package/dist/twilight/{p-183e02ac.entry.js → p-8eabd62f.entry.js} +1 -1
  297. package/dist/twilight/{p-85ab4182.entry.js → p-8f0b6a64.entry.js} +1 -1
  298. package/dist/twilight/{p-d05e1bfd.entry.js → p-8fc42a50.entry.js} +1 -1
  299. package/dist/twilight/{p-ce9b6ac6.entry.js → p-943f3e5a.entry.js} +1 -1
  300. package/dist/twilight/{p-f176c43e.entry.js → p-96317fc8.entry.js} +1 -1
  301. package/dist/twilight/{p-0cc42e36.entry.js → p-96560ca2.entry.js} +1 -1
  302. package/dist/twilight/{p-3d533d87.entry.js → p-97b51153.entry.js} +1 -1
  303. package/dist/twilight/p-9a4a84b8.entry.js +4 -0
  304. package/dist/twilight/{p-e429b1e5.entry.js → p-9a723216.entry.js} +1 -1
  305. package/dist/twilight/{p-7c038d9d.entry.js → p-9c1bf3fb.entry.js} +1 -1
  306. package/dist/twilight/{p-Cbnu3aaI.js → p-BCFB-lfz.js} +1 -1
  307. package/dist/twilight/{p-CZkK9lyS.js → p-BFMu9w68.js} +1 -1
  308. package/dist/twilight/{p-YTWgVZ0u.js → p-BGUXYEQf.js} +2 -2
  309. package/dist/twilight/{p-BABHygiN.js → p-BdaR2plD.js} +1 -1
  310. package/dist/twilight/{p-CxpHph5p.js → p-CSRWBUvd.js} +1 -1
  311. package/dist/twilight/{p-BDO2BBmv.js → p-CliIfO7G.js} +1 -1
  312. package/dist/twilight/{p-BZHrTB2v.js → p-D1oXS6KY.js} +1 -1
  313. package/dist/twilight/{p-fP9RBas5.js → p-DlxVucku.js} +1 -1
  314. package/dist/twilight/{p-0Tl_yZW8.js → p-HRJpfiBN.js} +2 -2
  315. package/dist/twilight/{p-MugjBhYh.js → p-O5jKs1Zb.js} +1 -1
  316. package/dist/twilight/{p-0c26bedf.entry.js → p-a2cbbc56.entry.js} +1 -1
  317. package/dist/twilight/{p-ad9dcb47.entry.js → p-a3009d00.entry.js} +1 -1
  318. package/dist/twilight/{p-ae22bfeb.entry.js → p-b202c2d3.entry.js} +1 -1
  319. package/dist/twilight/{p-95b89c32.entry.js → p-b2b896d1.entry.js} +1 -1
  320. package/dist/twilight/{p-35d5e339.entry.js → p-b66c664b.entry.js} +1 -1
  321. package/dist/twilight/{p-9434c23f.entry.js → p-c327bc95.entry.js} +1 -1
  322. package/dist/twilight/{p-8e013db1.entry.js → p-c3afee2f.entry.js} +1 -1
  323. package/dist/twilight/{p-8d369871.entry.js → p-c699207a.entry.js} +1 -1
  324. package/dist/twilight/{p-aee17b8b.entry.js → p-c89d7291.entry.js} +1 -1
  325. package/dist/twilight/{p-eb590773.entry.js → p-c8d4b211.entry.js} +1 -1
  326. package/dist/twilight/{p-f828fefc.entry.js → p-c919171b.entry.js} +1 -1
  327. package/dist/twilight/{p-f4cff5cf.entry.js → p-d565b168.entry.js} +1 -1
  328. package/dist/twilight/{p-0433773a.entry.js → p-d7a70a29.entry.js} +1 -1
  329. package/dist/twilight/{p-af12fce1.entry.js → p-d8181149.entry.js} +1 -1
  330. package/dist/twilight/{p-a263bdbb.entry.js → p-d8a5198b.entry.js} +1 -1
  331. package/dist/twilight/{p-26adf02d.entry.js → p-db27df13.entry.js} +1 -1
  332. package/dist/twilight/{p-80f27669.entry.js → p-df8c51c2.entry.js} +1 -1
  333. package/dist/twilight/{p-220338b4.entry.js → p-e4d76bce.entry.js} +1 -1
  334. package/dist/twilight/{p-2da1eb61.entry.js → p-eb6f86fb.entry.js} +1 -1
  335. package/dist/twilight/{p-b9d2ae8a.entry.js → p-ee23fbba.entry.js} +1 -1
  336. package/dist/twilight/{p-6db61be2.entry.js → p-ee8d13fd.entry.js} +1 -1
  337. package/dist/twilight/{p-a735c70e.entry.js → p-ef09a761.entry.js} +1 -1
  338. package/dist/twilight/{p-e955b287.entry.js → p-f5e46494.entry.js} +1 -1
  339. package/dist/twilight/{p-bf3fdf6d.entry.js → p-f9abcf4f.entry.js} +1 -1
  340. package/dist/twilight/{p-3b5fe2ef.entry.js → p-fd0d136d.entry.js} +1 -1
  341. package/dist/twilight/{p-4d852a57.entry.js → p-fe72290f.entry.js} +1 -1
  342. package/dist/twilight/twilight.esm.js +1 -1
  343. package/dist/types/components/salla-bullet-delivery/location-distance-warning.d.ts +12 -0
  344. package/dist/types/components/salla-bullet-delivery/location-permission-notice.d.ts +39 -0
  345. package/dist/types/components/salla-bullet-delivery/salla-bullet-delivery.d.ts +31 -0
  346. package/dist/types/components/salla-cart-coupons/salla-cart-coupons.d.ts +14 -0
  347. package/dist/types/components/salla-cart-summary-card/salla-cart-summary-card.d.ts +3 -0
  348. package/dist/types/global/chunk-errors.d.ts +2 -0
  349. package/package.json +5 -5
  350. package/dist/twilight/p-17f2114f.entry.js +0 -4
  351. package/dist/twilight/p-b81474c4.entry.js +0 -4
  352. package/dist/twilight/p-d851751c.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 a,H as e,a as r}from"./p-0Tl_yZW8.js";import{f as i}from"./p-DIAyA5MP.js";const s=class{constructor(a){t(this,a),this.limit=10,this.products=[],this.isLoading=!0,this.canRender=!0,this.title="",this.addToCartLabel="",this.weightLabel="",this.discountLabel="",this.placeholder="",this.fetchGeneration=0,this.isSyncingCart=!1,this.requestId=null,this.listViewTracked=!1,this.lastListViewedKey="",this.cartItemChangedHandler=t=>{const a=t?.data?.cart?.items??[],e=a.map((t=>String(t.product_id))).filter(Boolean);this.syncCartItemsDom(a),this.fetchRecommendations(e)},this.beforeAddItemHandler=t=>{const a=String(t?.id??"");a&&this.products.some((t=>String(t.id)===a))&&salla.cart?.api&&(salla.cart.api.addToCartSource="basket_gap")},this.addButtonSuccessHandler=t=>{const a=t?.target?.getAttribute?.("product-id");if(!a)return;const e=this.products.find((t=>String(t.id)===String(a)));if(!e)return;const r=t?.detail?.data?.items??[],i=r.find((t=>String(t.product_id)===String(e.id)))??r.slice(-1)[0];salla.event.emit("salla-basket-gap::product.added",[{product:e,position:this.products.indexOf(e)+1,cartItem:i,cartId:t?.detail?.data?.id,source:"basket_gap",request_id:this.requestId}])},salla.lang.onLoaded((()=>{this.title=salla.lang.get("pages.cart.basket_gap_title"),this.addToCartLabel=salla.lang.get("pages.cart.add_to_cart"),this.weightLabel=salla.lang.get("pages.products.weight"),this.discountLabel=salla.lang.get("pages.products.discount")}))}componentWillLoad(){salla.onReady().then((()=>{if(!salla.config.get("store.settings.cart.basket_gap"))return this.canRender=!1,void(this.isLoading=!1);this.title=salla.lang.get("pages.cart.basket_gap_title"),this.addToCartLabel=salla.lang.get("pages.cart.add_to_cart"),this.weightLabel=salla.lang.get("pages.products.weight"),this.discountLabel=salla.lang.get("pages.products.discount"),this.placeholder=salla.url.asset(salla.config.get("theme.settings.placeholder"));const t=salla.storage.get("cart"),a=(t?.items??[]).map((t=>String(t.product_id))).filter(Boolean);return a.length?this.fetchRecommendations(a):salla.api.cart.details().then((({data:{cart:t}})=>{const a=(t?.items??[]).map((t=>String(t.product_id))).filter(Boolean);return this.fetchRecommendations(a)})).catch((()=>{this.canRender=!1,this.isLoading=!1}))}))}componentDidLoad(){this.positionUnderCartItems()}componentDidUpdate(){document.lazyLoadInstance?.update(this.host.querySelectorAll(".lazy")),this.positionUnderCartItems()}componentDidRender(){if(!this.products.length||this.listViewTracked||this.intersectionObserver)return;const t=new IntersectionObserver((a=>{this.intersectionObserver===t&&a.some((t=>t.isIntersecting))&&(this.listViewTracked=!0,t.disconnect(),this.intersectionObserver=void 0,this.emitListViewed())}),{threshold:.1});this.intersectionObserver=t,t.observe(this.host)}emitListViewed(){const t=this.products.map((t=>t.id)).join(",");t!==this.lastListViewedKey&&(this.lastListViewedKey=t,salla.event.emit("salla-basket-gap::list.viewed",{products:this.products,source:"basket_gap",request_id:this.requestId}))}handleCardClick(t,a){const e=t.target;"function"==typeof e?.closest&&e.closest("a[href]")&&this.emitProductClicked(a)}emitProductClicked(t){salla.event.emit("salla-basket-gap::product.clicked",[{product:t,position:this.products.indexOf(t)+1,source:"basket_gap",request_id:this.requestId}])}getCartItemForms(t=document){return Array.from(t.querySelectorAll('form[id^="item-"]')).filter((t=>!t.closest(".cart-options")))}positionUnderCartItems(){const t=this.getCartItemForms(),a=t[t.length-1];a&&a.nextElementSibling!==this.host&&a.after(this.host)}syncCartItemsDom(t){t?.length&&!this.isSyncingCart&&t.filter((t=>!document.getElementById("item-"+t.id))).length&&(this.isSyncingCart=!0,fetch(window.location.href,{headers:{"X-Requested-With":"XMLHttpRequest"},credentials:"same-origin"}).then((t=>t.text())).then((t=>{const a=(new DOMParser).parseFromString(t,"text/html"),e=this.getCartItemForms(a),r=this.getCartItemForms();if(!e.length||!r.length)return;const i=r[0],s=i.parentElement;s&&(e.forEach((t=>{s.insertBefore(document.importNode(t,!0),i)})),r.forEach((t=>t.remove())),document.lazyLoadInstance?.update?.(),this.positionUnderCartItems())})).catch((()=>{})).finally((()=>{this.isSyncingCart=!1})))}connectedCallback(){salla.event.on("cart::item.added",this.cartItemChangedHandler),salla.event.on("cart::item.deleted",this.cartItemChangedHandler),salla.event.on("cart::before.add.item",this.beforeAddItemHandler),this.host.addEventListener("success",this.addButtonSuccessHandler)}disconnectedCallback(){this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,salla.event.off("cart::item.added",this.cartItemChangedHandler),salla.event.off("cart::item.deleted",this.cartItemChangedHandler),salla.event.off("cart::before.add.item",this.beforeAddItemHandler),this.host.removeEventListener("success",this.addButtonSuccessHandler)}getCartProductIds(t){if(t?.length)return new Set(t);const a=salla.storage.get("cart");return new Set((a?.items??[]).map((t=>String(t.product_id))).filter(Boolean))}fetchRecommendations(t){if(!t.length)return this.canRender=!1,this.isLoading=!1,Promise.resolve();const a=++this.fetchGeneration;return i(t).then((e=>{if(a!==this.fetchGeneration)return;const r=e._requestId||null,i=this.getCartProductIds(t),s=e.filter((t=>!i.has(t)));if(s.length)return this.fetchProducts(s.slice(0,this.limit),a,r);this.canRender=!1})).catch((()=>{a===this.fetchGeneration&&(this.canRender=!1)})).finally((()=>{a===this.fetchGeneration&&(this.isLoading=!1)}))}fetchProducts(t,a,e=null){return salla.api.withoutNotifier((()=>salla.product.api.fetch({source:"selected",source_value:t,limit:this.limit}))).then((t=>{a===this.fetchGeneration&&(this.products=t?.data??[],this.requestId=e,this.listViewTracked=!1,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.canRender=this.products.length>0)})).catch((()=>{a===this.fetchGeneration&&(this.canRender=!1)}))}getDiscountLabel(t){if(t.promotion_title)return t.promotion_title;if(t.is_on_sale&&t.regular_price>0&&t.sale_price>0){const a=Math.round(100*(1-t.sale_price/t.regular_price));return a>0?`${this.discountLabel} ${a}%`:null}return null}formatDate(t){const a=new Date(1e3*t),e=String(a.getMonth()+1).padStart(2,"0"),r=String(a.getDate()).padStart(2,"0");return`${a.getFullYear()}-${e}-${r}`}getSkeletonView(){return a(e,{class:"s-basket-gap-entry"},a("div",{class:"s-basket-gap-skeleton"},a("salla-skeleton",{height:"16px",width:"40%",style:{marginBottom:"16px"}}),Array(3).fill(null).map(((t,e)=>a("div",{key:e,class:"s-basket-gap-skeleton-card"},a("salla-skeleton",{height:"64px",width:"64px",style:{borderRadius:"8px",flexShrink:"0"}}),a("div",{class:"s-basket-gap-skeleton-info"},a("salla-skeleton",{height:"14px",width:"50%"}),a("salla-skeleton",{height:"12px",width:"25%",style:{marginTop:"6px"}}),a("salla-skeleton",{height:"10px",width:"35%",style:{marginTop:"4px"}})),a("salla-skeleton",{height:"36px",width:"100px",style:{borderRadius:"6px",flexShrink:"0",marginInlineStart:"auto"}}))))))}getProductCard(t){const e=this.getDiscountLabel(t);return a("div",{key:t.id,class:"s-basket-gap-card",onClick:a=>this.handleCardClick(a,t)},a("a",{href:t.url,class:"s-basket-gap-card-image"},a("img",{class:"lazy",src:this.placeholder,"data-src":t.image?.url,alt:t.image?.alt||t.name})),a("div",{class:"s-basket-gap-card-info"},a("h3",{class:"s-basket-gap-card-name"},a("a",{href:t.url},t.name)),t.is_on_sale?a("div",{class:"s-basket-gap-card-sale-price"},a("span",{innerHTML:salla.money(t.sale_price)}),a("del",{innerHTML:salla.money(t.regular_price)})):a("span",{class:"s-basket-gap-card-price",innerHTML:salla.money(t.price)}),t.weight_label&&a("span",{class:"s-basket-gap-card-weight"},this.weightLabel," ",t.weight_label)),a("div",{class:"s-basket-gap-card-actions"},(t.promotion_title||t.discount_ends||t.is_on_sale)&&a("div",{class:"s-basket-gap-card-offer"},a("i",{class:"sicon-gift"}),e&&a("span",null,e),t.discount_ends&&[a("salla-count-down",{date:this.formatDate(t.discount_ends),"end-of-day":!0,digits:"en","auto-segments":!0}),a("i",{class:"sicon-alarm"})]),a("salla-add-product-button",{class:"s-basket-gap-card-btn","product-id":t.id,"product-status":t.status,"product-type":t.type},this.addToCartLabel)))}render(){return this.canRender?this.isLoading?this.getSkeletonView():this.products.length?a(e,{class:"s-basket-gap-entry"},this.title&&a("h2",{class:"s-basket-gap-title"},this.title),a("div",{class:"s-basket-gap-list"},this.products.map((t=>this.getProductCard(t))))):null:null}get host(){return r(this)}};s.style='/*!twlt*/:host{display:block}.block{display:block}.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-basket-gap-entry{margin-top:1.25rem;margin-bottom:1.25rem;display:block;border-radius:0.375rem;--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1.25rem}.s-basket-gap-title{margin-bottom:1rem;font-size:1.125rem;line-height:1.75rem;font-weight:700}.s-basket-gap-list{display:flex;flex-direction:column}.s-basket-gap-list>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px * var(--tw-divide-y-reverse));--tw-divide-opacity:1;border-color:rgb(243 244 246 / var(--tw-divide-opacity, 1))}.s-basket-gap-card{display:flex;flex-wrap:wrap;align-items:center;column-gap:0.75rem;row-gap:0.625rem;padding-top:1rem;padding-bottom:1rem}.s-basket-gap-card-image{height:4rem;width:4rem;flex-shrink:0;overflow:hidden;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.s-basket-gap-card-image img{height:100%;width:100%;object-fit:cover}.s-basket-gap-card-info{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.25rem}.s-basket-gap-card-actions{display:flex;width:100%;align-items:center;justify-content:flex-end;gap:0.5rem}@media (min-width: 640px){.s-basket-gap-card-actions{width:auto}}.s-basket-gap-card-name{font-size:0.875rem;line-height:1.25rem;font-weight:600;line-height:1.25;--tw-text-opacity:1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.s-basket-gap-card-name a:hover{color:var(--color-primary)}.s-basket-gap-card-price{font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-basket-gap-card-sale-price{display:flex;align-items:center;gap:0.5rem}.s-basket-gap-card-sale-price span{font-size:0.875rem;line-height:1.25rem;font-weight:700;--tw-text-opacity:1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.s-basket-gap-card-sale-price del{font-size:0.75rem;line-height:1rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1));text-decoration-line:line-through}.s-basket-gap-card-weight{font-size:0.75rem;line-height:1rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-basket-gap-card-offer{display:flex;flex-shrink:0;align-items:center;gap:0.25rem;border-radius:0.375rem;--tw-bg-opacity:1;background-color:rgb(240 253 244 / var(--tw-bg-opacity, 1));padding-left:9px;padding-right:9px;padding-top:3px;padding-bottom:3px;font-size:11px;font-weight:500;--tw-text-opacity:1;color:rgb(21 128 61 / var(--tw-text-opacity, 1))}.s-basket-gap-card-offer i{font-size:0.75rem;line-height:1rem}.s-basket-gap-card-offer span{font-weight:700;--tw-text-opacity:1 !important;color:rgb(31 41 55 / var(--tw-text-opacity, 1)) !important}.s-basket-gap-card-offer salla-count-down{flex-shrink:0}.s-basket-gap-card-offer salla-count-down:where([dir="ltr"],[dir="ltr"] *){margin-inline-start:0.25rem}.s-basket-gap-card-offer salla-count-down:where([dir="rtl"],[dir="rtl"] *){margin-inline-end:0.25rem}.s-basket-gap-card-offer .s-count-down-list{margin-left:-0px !important;margin-right:-0px !important;margin-bottom:0px !important;margin-top:0px !important;display:inline-flex;flex-wrap:nowrap;align-items:center;justify-content:flex-start !important;column-gap:0px;--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.s-basket-gap-card-offer .s-count-down-list:where([dir="ltr"],[dir="ltr"] *){flex-direction:row-reverse !important}.s-basket-gap-card-offer .s-count-down-list:where([dir="rtl"],[dir="rtl"] *){flex-direction:row !important}.s-basket-gap-card-offer .s-count-down-item{position:relative !important;margin-left:0px !important;margin-right:0px !important;display:inline-flex !important;width:auto !important;flex:none !important;flex-grow:0 !important;flex-direction:row !important;align-items:center !important;justify-content:center !important;padding-top:0px !important;padding-bottom:0px !important;padding-left:0px !important;padding-right:0px !important;font-size:12px !important;font-weight:700 !important;line-height:1 !important;--tw-text-opacity:1 !important;color:rgb(21 128 61 / var(--tw-text-opacity, 1)) !important}.s-basket-gap-card-offer .s-count-down-item-value{display:inline-block !important;width:2ch !important;min-width:2ch !important;text-align:center;--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction);line-height:1}.s-basket-gap-card-offer .s-count-down-item-label{display:none}.s-basket-gap-entry .s-basket-gap-card-offer.s-basket-gap-card-offer .s-count-down-item::before{content:none !important}.s-basket-gap-entry .s-basket-gap-card-offer.s-basket-gap-card-offer .s-count-down-item::after{content:none !important;position:static;left:auto;right:auto;transform:none}[dir=\'rtl\'] .s-basket-gap-entry .s-basket-gap-card-offer.s-basket-gap-card-offer .s-count-down-item:not(:last-child)::after{content:\':\' !important;position:static;left:auto;right:auto;transform:none;margin-left:0.15rem;margin-right:0.15rem;color:#15803d;font-size:12px;font-weight:700;line-height:1}[dir=\'ltr\'] .s-basket-gap-entry .s-basket-gap-card-offer.s-basket-gap-card-offer .s-count-down-item:not(:first-child)::after{content:\':\' !important;position:static;left:auto;right:auto;transform:none;margin-left:0.15rem;margin-right:0.15rem;color:#15803d;font-size:12px;font-weight:700;line-height:1}.s-basket-gap-card-btn{flex-shrink:0}.s-basket-gap-card-btn salla-button .s-button-btn{border-radius:var(--s-radius, 0.25rem);border-width:1px !important;border-color:var(--color-primary) !important;background-color:transparent !important;color:var(--color-primary) !important}.s-basket-gap-card-btn salla-button .s-button-btn:hover{background-color:var(--color-primary) !important;--tw-text-opacity:1 !important;color:rgb(255 255 255 / var(--tw-text-opacity, 1)) !important}.s-basket-gap-card-btn salla-button .s-button-loader:before{border-top-color:var(--color-primary) !important;border-left-color:var(--color-primary) !important;border-bottom-color:rgb(243 244 246 / var(--tw-border-opacity, 1)) !important;--tw-border-opacity:1 !important;border-right-color:rgb(243 244 246 / var(--tw-border-opacity, 1)) !important}.s-basket-gap-skeleton{display:flex;flex-direction:column;gap:0.75rem}.s-basket-gap-skeleton-card{display:flex;align-items:center;gap:0.75rem;padding-top:0.75rem;padding-bottom:0.75rem}.s-basket-gap-skeleton-info{display:flex;flex:1 1 0%;flex-direction:column;gap:0.5rem}';export{s as salla_basket_gap}
4
+ import{r as t,h as a,H as e,a as r}from"./p-HRJpfiBN.js";import{f as i}from"./p-DIAyA5MP.js";const s=class{constructor(a){t(this,a),this.limit=10,this.products=[],this.isLoading=!0,this.canRender=!0,this.title="",this.addToCartLabel="",this.weightLabel="",this.discountLabel="",this.placeholder="",this.fetchGeneration=0,this.isSyncingCart=!1,this.requestId=null,this.listViewTracked=!1,this.lastListViewedKey="",this.cartItemChangedHandler=t=>{const a=t?.data?.cart?.items??[],e=a.map((t=>String(t.product_id))).filter(Boolean);this.syncCartItemsDom(a),this.fetchRecommendations(e)},this.beforeAddItemHandler=t=>{const a=String(t?.id??"");a&&this.products.some((t=>String(t.id)===a))&&salla.cart?.api&&(salla.cart.api.addToCartSource="basket_gap")},this.addButtonSuccessHandler=t=>{const a=t?.target?.getAttribute?.("product-id");if(!a)return;const e=this.products.find((t=>String(t.id)===String(a)));if(!e)return;const r=t?.detail?.data?.items??[],i=r.find((t=>String(t.product_id)===String(e.id)))??r.slice(-1)[0];salla.event.emit("salla-basket-gap::product.added",[{product:e,position:this.products.indexOf(e)+1,cartItem:i,cartId:t?.detail?.data?.id,source:"basket_gap",request_id:this.requestId}])},salla.lang.onLoaded((()=>{this.title=salla.lang.get("pages.cart.basket_gap_title"),this.addToCartLabel=salla.lang.get("pages.cart.add_to_cart"),this.weightLabel=salla.lang.get("pages.products.weight"),this.discountLabel=salla.lang.get("pages.products.discount")}))}componentWillLoad(){salla.onReady().then((()=>{if(!salla.config.get("store.settings.cart.basket_gap"))return this.canRender=!1,void(this.isLoading=!1);this.title=salla.lang.get("pages.cart.basket_gap_title"),this.addToCartLabel=salla.lang.get("pages.cart.add_to_cart"),this.weightLabel=salla.lang.get("pages.products.weight"),this.discountLabel=salla.lang.get("pages.products.discount"),this.placeholder=salla.url.asset(salla.config.get("theme.settings.placeholder"));const t=salla.storage.get("cart"),a=(t?.items??[]).map((t=>String(t.product_id))).filter(Boolean);return a.length?this.fetchRecommendations(a):salla.api.cart.details().then((({data:{cart:t}})=>{const a=(t?.items??[]).map((t=>String(t.product_id))).filter(Boolean);return this.fetchRecommendations(a)})).catch((()=>{this.canRender=!1,this.isLoading=!1}))}))}componentDidLoad(){this.positionUnderCartItems()}componentDidUpdate(){document.lazyLoadInstance?.update(this.host.querySelectorAll(".lazy")),this.positionUnderCartItems()}componentDidRender(){if(!this.products.length||this.listViewTracked||this.intersectionObserver)return;const t=new IntersectionObserver((a=>{this.intersectionObserver===t&&a.some((t=>t.isIntersecting))&&(this.listViewTracked=!0,t.disconnect(),this.intersectionObserver=void 0,this.emitListViewed())}),{threshold:.1});this.intersectionObserver=t,t.observe(this.host)}emitListViewed(){const t=this.products.map((t=>t.id)).join(",");t!==this.lastListViewedKey&&(this.lastListViewedKey=t,salla.event.emit("salla-basket-gap::list.viewed",{products:this.products,source:"basket_gap",request_id:this.requestId}))}handleCardClick(t,a){const e=t.target;"function"==typeof e?.closest&&e.closest("a[href]")&&this.emitProductClicked(a)}emitProductClicked(t){salla.event.emit("salla-basket-gap::product.clicked",[{product:t,position:this.products.indexOf(t)+1,source:"basket_gap",request_id:this.requestId}])}getCartItemForms(t=document){return Array.from(t.querySelectorAll('form[id^="item-"]')).filter((t=>!t.closest(".cart-options")))}positionUnderCartItems(){const t=this.getCartItemForms(),a=t[t.length-1];a&&a.nextElementSibling!==this.host&&a.after(this.host)}syncCartItemsDom(t){t?.length&&!this.isSyncingCart&&t.filter((t=>!document.getElementById("item-"+t.id))).length&&(this.isSyncingCart=!0,fetch(window.location.href,{headers:{"X-Requested-With":"XMLHttpRequest"},credentials:"same-origin"}).then((t=>t.text())).then((t=>{const a=(new DOMParser).parseFromString(t,"text/html"),e=this.getCartItemForms(a),r=this.getCartItemForms();if(!e.length||!r.length)return;const i=r[0],s=i.parentElement;s&&(e.forEach((t=>{s.insertBefore(document.importNode(t,!0),i)})),r.forEach((t=>t.remove())),document.lazyLoadInstance?.update?.(),this.positionUnderCartItems())})).catch((()=>{})).finally((()=>{this.isSyncingCart=!1})))}connectedCallback(){salla.event.on("cart::item.added",this.cartItemChangedHandler),salla.event.on("cart::item.deleted",this.cartItemChangedHandler),salla.event.on("cart::before.add.item",this.beforeAddItemHandler),this.host.addEventListener("success",this.addButtonSuccessHandler)}disconnectedCallback(){this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,salla.event.off("cart::item.added",this.cartItemChangedHandler),salla.event.off("cart::item.deleted",this.cartItemChangedHandler),salla.event.off("cart::before.add.item",this.beforeAddItemHandler),this.host.removeEventListener("success",this.addButtonSuccessHandler)}getCartProductIds(t){if(t?.length)return new Set(t);const a=salla.storage.get("cart");return new Set((a?.items??[]).map((t=>String(t.product_id))).filter(Boolean))}fetchRecommendations(t){if(!t.length)return this.canRender=!1,this.isLoading=!1,Promise.resolve();const a=++this.fetchGeneration;return i(t).then((e=>{if(a!==this.fetchGeneration)return;const r=e._requestId||null,i=this.getCartProductIds(t),s=e.filter((t=>!i.has(t)));if(s.length)return this.fetchProducts(s.slice(0,this.limit),a,r);this.canRender=!1})).catch((()=>{a===this.fetchGeneration&&(this.canRender=!1)})).finally((()=>{a===this.fetchGeneration&&(this.isLoading=!1)}))}fetchProducts(t,a,e=null){return salla.api.withoutNotifier((()=>salla.product.api.fetch({source:"selected",source_value:t,limit:this.limit}))).then((t=>{a===this.fetchGeneration&&(this.products=t?.data??[],this.requestId=e,this.listViewTracked=!1,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.canRender=this.products.length>0)})).catch((()=>{a===this.fetchGeneration&&(this.canRender=!1)}))}getDiscountLabel(t){if(t.promotion_title)return t.promotion_title;if(t.is_on_sale&&t.regular_price>0&&t.sale_price>0){const a=Math.round(100*(1-t.sale_price/t.regular_price));return a>0?`${this.discountLabel} ${a}%`:null}return null}formatDate(t){const a=new Date(1e3*t),e=String(a.getMonth()+1).padStart(2,"0"),r=String(a.getDate()).padStart(2,"0");return`${a.getFullYear()}-${e}-${r}`}getSkeletonView(){return a(e,{class:"s-basket-gap-entry"},a("div",{class:"s-basket-gap-skeleton"},a("salla-skeleton",{height:"16px",width:"40%",style:{marginBottom:"16px"}}),Array(3).fill(null).map(((t,e)=>a("div",{key:e,class:"s-basket-gap-skeleton-card"},a("salla-skeleton",{height:"64px",width:"64px",style:{borderRadius:"8px",flexShrink:"0"}}),a("div",{class:"s-basket-gap-skeleton-info"},a("salla-skeleton",{height:"14px",width:"50%"}),a("salla-skeleton",{height:"12px",width:"25%",style:{marginTop:"6px"}}),a("salla-skeleton",{height:"10px",width:"35%",style:{marginTop:"4px"}})),a("salla-skeleton",{height:"36px",width:"100px",style:{borderRadius:"6px",flexShrink:"0",marginInlineStart:"auto"}}))))))}getProductCard(t){const e=this.getDiscountLabel(t);return a("div",{key:t.id,class:"s-basket-gap-card",onClick:a=>this.handleCardClick(a,t)},a("a",{href:t.url,class:"s-basket-gap-card-image"},a("img",{class:"lazy",src:this.placeholder,"data-src":t.image?.url,alt:t.image?.alt||t.name})),a("div",{class:"s-basket-gap-card-info"},a("h3",{class:"s-basket-gap-card-name"},a("a",{href:t.url},t.name)),t.is_on_sale?a("div",{class:"s-basket-gap-card-sale-price"},a("span",{innerHTML:salla.money(t.sale_price)}),a("del",{innerHTML:salla.money(t.regular_price)})):a("span",{class:"s-basket-gap-card-price",innerHTML:salla.money(t.price)}),t.weight_label&&a("span",{class:"s-basket-gap-card-weight"},this.weightLabel," ",t.weight_label)),a("div",{class:"s-basket-gap-card-actions"},(t.promotion_title||t.discount_ends||t.is_on_sale)&&a("div",{class:"s-basket-gap-card-offer"},a("i",{class:"sicon-gift"}),e&&a("span",null,e),t.discount_ends&&[a("salla-count-down",{date:this.formatDate(t.discount_ends),"end-of-day":!0,digits:"en","auto-segments":!0}),a("i",{class:"sicon-alarm"})]),a("salla-add-product-button",{class:"s-basket-gap-card-btn","product-id":t.id,"product-status":t.status,"product-type":t.type},this.addToCartLabel)))}render(){return this.canRender?this.isLoading?this.getSkeletonView():this.products.length?a(e,{class:"s-basket-gap-entry"},this.title&&a("h2",{class:"s-basket-gap-title"},this.title),a("div",{class:"s-basket-gap-list"},this.products.map((t=>this.getProductCard(t))))):null:null}get host(){return r(this)}};s.style='/*!twlt*/:host{display:block}.block{display:block}.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-basket-gap-entry{margin-top:1.25rem;margin-bottom:1.25rem;display:block;border-radius:0.375rem;--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1.25rem}.s-basket-gap-title{margin-bottom:1rem;font-size:1.125rem;line-height:1.75rem;font-weight:700}.s-basket-gap-list{display:flex;flex-direction:column}.s-basket-gap-list>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px * var(--tw-divide-y-reverse));--tw-divide-opacity:1;border-color:rgb(243 244 246 / var(--tw-divide-opacity, 1))}.s-basket-gap-card{display:flex;flex-wrap:wrap;align-items:center;column-gap:0.75rem;row-gap:0.625rem;padding-top:1rem;padding-bottom:1rem}.s-basket-gap-card-image{height:4rem;width:4rem;flex-shrink:0;overflow:hidden;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.s-basket-gap-card-image img{height:100%;width:100%;object-fit:cover}.s-basket-gap-card-info{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.25rem}.s-basket-gap-card-actions{display:flex;width:100%;align-items:center;justify-content:flex-end;gap:0.5rem}@media (min-width: 640px){.s-basket-gap-card-actions{width:auto}}.s-basket-gap-card-name{font-size:0.875rem;line-height:1.25rem;font-weight:600;line-height:1.25;--tw-text-opacity:1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.s-basket-gap-card-name a:hover{color:var(--color-primary)}.s-basket-gap-card-price{font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-basket-gap-card-sale-price{display:flex;align-items:center;gap:0.5rem}.s-basket-gap-card-sale-price span{font-size:0.875rem;line-height:1.25rem;font-weight:700;--tw-text-opacity:1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.s-basket-gap-card-sale-price del{font-size:0.75rem;line-height:1rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1));text-decoration-line:line-through}.s-basket-gap-card-weight{font-size:0.75rem;line-height:1rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-basket-gap-card-offer{display:flex;flex-shrink:0;align-items:center;gap:0.25rem;border-radius:0.375rem;--tw-bg-opacity:1;background-color:rgb(240 253 244 / var(--tw-bg-opacity, 1));padding-left:9px;padding-right:9px;padding-top:3px;padding-bottom:3px;font-size:11px;font-weight:500;--tw-text-opacity:1;color:rgb(21 128 61 / var(--tw-text-opacity, 1))}.s-basket-gap-card-offer i{font-size:0.75rem;line-height:1rem}.s-basket-gap-card-offer span{font-weight:700;--tw-text-opacity:1 !important;color:rgb(31 41 55 / var(--tw-text-opacity, 1)) !important}.s-basket-gap-card-offer salla-count-down{flex-shrink:0}.s-basket-gap-card-offer salla-count-down:where([dir="ltr"],[dir="ltr"] *){margin-inline-start:0.25rem}.s-basket-gap-card-offer salla-count-down:where([dir="rtl"],[dir="rtl"] *){margin-inline-end:0.25rem}.s-basket-gap-card-offer .s-count-down-list{margin-left:-0px !important;margin-right:-0px !important;margin-bottom:0px !important;margin-top:0px !important;display:inline-flex;flex-wrap:nowrap;align-items:center;justify-content:flex-start !important;column-gap:0px;--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.s-basket-gap-card-offer .s-count-down-list:where([dir="ltr"],[dir="ltr"] *){flex-direction:row-reverse !important}.s-basket-gap-card-offer .s-count-down-list:where([dir="rtl"],[dir="rtl"] *){flex-direction:row !important}.s-basket-gap-card-offer .s-count-down-item{position:relative !important;margin-left:0px !important;margin-right:0px !important;display:inline-flex !important;width:auto !important;flex:none !important;flex-grow:0 !important;flex-direction:row !important;align-items:center !important;justify-content:center !important;padding-top:0px !important;padding-bottom:0px !important;padding-left:0px !important;padding-right:0px !important;font-size:12px !important;font-weight:700 !important;line-height:1 !important;--tw-text-opacity:1 !important;color:rgb(21 128 61 / var(--tw-text-opacity, 1)) !important}.s-basket-gap-card-offer .s-count-down-item-value{display:inline-block !important;width:2ch !important;min-width:2ch !important;text-align:center;--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction);line-height:1}.s-basket-gap-card-offer .s-count-down-item-label{display:none}.s-basket-gap-entry .s-basket-gap-card-offer.s-basket-gap-card-offer .s-count-down-item::before{content:none !important}.s-basket-gap-entry .s-basket-gap-card-offer.s-basket-gap-card-offer .s-count-down-item::after{content:none !important;position:static;left:auto;right:auto;transform:none}[dir=\'rtl\'] .s-basket-gap-entry .s-basket-gap-card-offer.s-basket-gap-card-offer .s-count-down-item:not(:last-child)::after{content:\':\' !important;position:static;left:auto;right:auto;transform:none;margin-left:0.15rem;margin-right:0.15rem;color:#15803d;font-size:12px;font-weight:700;line-height:1}[dir=\'ltr\'] .s-basket-gap-entry .s-basket-gap-card-offer.s-basket-gap-card-offer .s-count-down-item:not(:first-child)::after{content:\':\' !important;position:static;left:auto;right:auto;transform:none;margin-left:0.15rem;margin-right:0.15rem;color:#15803d;font-size:12px;font-weight:700;line-height:1}.s-basket-gap-card-btn{flex-shrink:0}.s-basket-gap-card-btn salla-button .s-button-btn{border-radius:var(--s-radius, 0.25rem);border-width:1px !important;border-color:var(--color-primary) !important;background-color:transparent !important;color:var(--color-primary) !important}.s-basket-gap-card-btn salla-button .s-button-btn:hover{background-color:var(--color-primary) !important;--tw-text-opacity:1 !important;color:rgb(255 255 255 / var(--tw-text-opacity, 1)) !important}.s-basket-gap-card-btn salla-button .s-button-loader:before{border-top-color:var(--color-primary) !important;border-left-color:var(--color-primary) !important;border-bottom-color:rgb(243 244 246 / var(--tw-border-opacity, 1)) !important;--tw-border-opacity:1 !important;border-right-color:rgb(243 244 246 / var(--tw-border-opacity, 1)) !important}.s-basket-gap-skeleton{display:flex;flex-direction:column;gap:0.75rem}.s-basket-gap-skeleton-card{display:flex;align-items:center;gap:0.75rem;padding-top:0.75rem;padding-bottom:0.75rem}.s-basket-gap-skeleton-info{display:flex;flex:1 1 0%;flex-direction:column;gap:0.5rem}';export{s as salla_basket_gap}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as e,h as r,H as i,a as o}from"./p-0Tl_yZW8.js";import{i as t}from"./p-DgRxTSyJ.js";function s(e,r){localStorage.getItem("salla-delivery-promise-debug")&&(void 0!==r?console.log(e,r):console.log(e))}async function l(e,r){s("fetchCities start",{productId:e,keyword:r});const i=null!=r?`?keyword=${encodeURIComponent(r)}`:"",o=await salla.api.request(salla.url.api(`products/${e}/delivery-promises/cities${i}`));return o.success&&Array.isArray(o.data)&&0!==o.data.length?(s("fetchCities success",{count:o.data.length}),{cities:o.data}):(s("fetchCities: no data",{response:o}),{cities:[]})}function a(){const e=(Boolean(salla.config.get("store.settings.bullet_delivery.settings.remember_last_session"))?salla.storage.store:salla.storage.session).get("bullet_delivery_intent");return e&&"object"==typeof e?e:null}const d={deliveryTo:"توصيل إلى",pickupFromBranch:"الاستلام من فرع",noResults:"لا توجد نتائج",selectCity:"اختر المدينة",changeCityTitle:"تغيير المدينة",changeCitySubtitle:"",cityFieldLabel:"المدينة",modalSearchPlaceholder:"ابحث عن مدينة",confirmAddress:"تأكيد العنوان",errorDeliveryPromise:"لا يتوفر وعد تسليم لهذه المدينة",errorPickupPromise:"لا يتوفر وعد تسليم لهذا الفرع"},n="salla-bullet-delivery-override-ip",c=class{constructor(r){e(this,r),this.isDeliveryPromiseEnabled=!1,this.isLoginCycleEnabled=!1,this.canRender=!1,this.labels=d,this.selectedLabel=null,this.deliveryMessage=null,this.hasError=!1,this.errorMessage="",this.isLoadingPromises=!1,this.selectedCityLoginCycle=null,this.selectedBranchLoginCycle=null,this.cities=[],this.selectedCity=null,this.isLoadingCities=!1,this.cityPendingSelection=null,this.modalCities=[],this.isSearchingCities=!1,this.citySearchCounter=0,this.onBulletDeliveryConfirmed=()=>{this.applyBulletIntent()},this.handleCitySearch=e=>{if(clearTimeout(this.citySearchTimer),!e.trim())return this.modalCities=[...this.cities],void(this.isSearchingCities=!1);this.citySearchTimer=setTimeout((()=>this.searchCitiesRemote(e)),300)},this.handleHeaderClick=e=>{e.stopPropagation(),this.isLoginCycleEnabled?this.openBulletDeliveryModal():this.openCityChangeModal()}}async componentDidLoad(){await salla.onReady(),await salla.lang.onLoaded(),this.labels={deliveryTo:salla.lang.getWithDefault("pages.products.promise_deliver_to",d.deliveryTo),pickupFromBranch:salla.lang.getWithDefault("pages.products.promise_pickup_from_branch",d.pickupFromBranch),noResults:salla.lang.getWithDefault("common.elements.no_options",d.noResults),selectCity:salla.lang.getWithDefault("common.elements.select_city",d.selectCity),changeCityTitle:salla.lang.getWithDefault("pages.products.promise_change_city_title",d.changeCityTitle),changeCitySubtitle:salla.lang.getWithDefault("pages.products.promise_change_city_subtitle","قد تتغيّر مدة التوصيل حسب المدينة."),cityFieldLabel:salla.lang.getWithDefault("pages.products.promise_city_field",d.cityFieldLabel),modalSearchPlaceholder:salla.lang.getWithDefault("pages.products.promise_search_city",d.modalSearchPlaceholder),confirmAddress:salla.lang.getWithDefault("pages.checkout.confirm_address",d.confirmAddress),errorDeliveryPromise:salla.lang.getWithDefault("pages.products.promise_delivery_not_available",d.errorDeliveryPromise),errorPickupPromise:salla.lang.getWithDefault("pages.products.promise_pickup_not_available",d.errorPickupPromise)},this.isDeliveryPromiseEnabled=salla.config.get("store.features",[]).includes("delivery-promises"),this.isLoginCycleEnabled=salla.config.get("store.features",[]).includes("bullet-delivery-v2")&&Salla.config.get("store.settings.bullet_delivery.enabled"),this.productId=salla.config.get("page.id"),this.isDeliveryPromiseEnabled?this.isLoginCycleEnabled?await this.initLoginCycleFlow():(this.selectedLabel=`${this.labels.deliveryTo} ${this.labels.selectCity}`,await this.loadCities()):this.canRender=!1}disconnectedCallback(){window.removeEventListener("bulletDeliveryConfirmed",this.onBulletDeliveryConfirmed)}getIPDeliveryLocation(){const e="store.shipping.delivery_location",r={cityId:salla.config.get(`${e}.city_id`),cityName:salla.config.get(`${e}.city_name`)};return localStorage.getItem(n)?JSON.parse(localStorage.getItem(n)):r}async initLoginCycleFlow(){const e=this.applyBulletIntent(),{cityId:r,cityName:i}=this.getIPDeliveryLocation();s("delivery promise login cycle flow getIPDeliveryLocation",this.getIPDeliveryLocation()),r&&i&&!e&&(this.selectedLabel=`${this.labels.deliveryTo} ${i}`,await this.loadDeliveryMessage(r,"city")),this.canRender=!0,window.addEventListener("bulletDeliveryConfirmed",this.onBulletDeliveryConfirmed)}applyBulletIntent(){const e=function(){const e=a();if(!e)return null;if("address"===e.type){const r=e.address_details?.city,i=null!=r?.id?Number(r.id):null!=e.city_id?Number(e.city_id):null,o=r?.name?.trim()||"";return null!=i?{type:"address",option:{id:i,name:o}}:t(e)&&e.address_details?.formatted_address?{type:"address",option:{name:e.address_details.formatted_address}}:null}if("branch"===e.type){const r=null!=e.branch_id?Number(e.branch_id):null!=e.branch_details?.id?Number(e.branch_details.id):null,i=e.branch_details?.name?.trim()||"";return null!=r?{type:"branch",option:{id:r,name:i}}:null}return null}();return e?("address"===e.type?(this.selectedCityLoginCycle=e.option,this.selectedBranchLoginCycle=null,this.selectedLabel=`${this.labels.deliveryTo} ${e.option.name||this.labels.selectCity}`,null!=e.option.id?this.loadDeliveryMessage(e.option.id,"city"):this.deliveryMessage=null):(this.selectedBranchLoginCycle=e.option,this.selectedCityLoginCycle=null,this.selectedLabel=`${this.labels.pickupFromBranch} ${e.option.name}`,this.loadDeliveryMessage(e.option.id,"branch")),!0):(this.selectedLabel=`${this.labels.deliveryTo} ${this.labels.selectCity}`,this.selectedCityLoginCycle=null,this.selectedBranchLoginCycle=null,this.deliveryMessage=null,!1)}openBulletDeliveryModal(){salla.event.emit("salla::bullet-delivery.modal.open.requested",function(){const e=a(),r={};if("address"===e?.type&&null!=e.address_id&&(r.preselected_address_id=Number(e.address_id)),"branch"===e?.type){const i=e.branch_id??e.branch_details?.id;null!=i&&(r.preselected_branch_id=Number(i))}return r}())}async loadCities(){this.isLoadingCities=!0,this.hasError=!1;const{cityId:e,cityName:r}=this.getIPDeliveryLocation();s("delivery promise standard flow getIPDeliveryLocation",this.getIPDeliveryLocation());try{const{cities:i}=await l(this.productId);if(!i.length)return void(this.canRender=!1);if(this.cities=i,this.canRender=!0,e&&r){this.selectedLabel=`${this.labels.deliveryTo} ${r}`;const i=this.cities.find((r=>String(r.id)===String(e)));i&&(s("delivery promise standard flow autoCity found",i),this.selectedCity=i),await this.loadDeliveryMessage(e,"city")}}catch(e){this.hasError=!0,this.errorMessage=e.message||"Failed to load cities",this.canRender=!1}finally{this.isLoadingCities=!1}}async loadDeliveryMessage(e,r){this.isLoadingPromises=!0,this.hasError=!1,this.deliveryMessage=null;try{this.deliveryMessage=await async function(e,r,i,o){s("fetchDeliveryMessage start",{productId:e,id:r,optionType:i});let t="";t="city"!==i||o?`?reference_id=${r}&reference_type=${i}`:`?reference_id=${r}`;const l=await salla.api.withoutNotifier((()=>salla.api.request(salla.url.api(`products/${e}/delivery-promises${t}`))));if(!l.success)return s("fetchDeliveryMessage error",{response:l}),null;const a=l.data?.message?.trim();return s("fetchDeliveryMessage success",{message:a}),a||null}(this.productId,e,r,this.isLoginCycleEnabled)}catch(i){s("loadDeliveryMessage failed",{id:e,optionType:r,error:i}),this.deliveryMessage=null}finally{this.isLoadingPromises=!1}}async openCityChangeModal(){this.cityModalRef&&(this.cityPendingSelection=null,this.modalCities=[...this.cities],await this.cityModalRef.setTitle(this.labels.changeCityTitle),await this.cityModalRef.open())}async searchCitiesRemote(e){const r=++this.citySearchCounter;this.isSearchingCities=!0;try{const{cities:i}=await l(this.productId,e);if(r!==this.citySearchCounter)return;this.modalCities=i}catch{if(r!==this.citySearchCounter)return;this.modalCities=[]}finally{r===this.citySearchCounter&&(this.isSearchingCities=!1)}}async handleConfirmCityModal(){if(!this.cityPendingSelection)return void await(this.cityModalRef?.close());const e=this.cityPendingSelection;this.selectedCity=e,this.selectedLabel=`${this.labels.deliveryTo} ${function(e){const r=salla.config.get("user.language_code");return r&&"ar"!==r&&e.name_en?.trim()?e.name_en.trim():e.name}(e)}`,await this.loadDeliveryMessage(e.id,"city"),await(this.cityModalRef?.close())}renderLoadingSkeleton(){return r(i,{class:"s-delivery-promise-wrapper s-delivery-promise-skeleton"},r("div",{class:"s-delivery-promise-container"},r("div",{class:"s-delivery-promise-header s-delivery-promise-header-skeleton"},r("div",{class:"s-delivery-promise-location"},r("salla-skeleton",{height:"14px",width:"180px"})),r("salla-skeleton",{height:"18px",width:"18px"})),r("div",{class:"s-delivery-promise-loading"},r("salla-skeleton",{height:"20px",width:"80%"}))))}renderDeliveryMessage(){return this.isLoadingPromises?r("div",{class:"s-delivery-promise-loading"},r("salla-skeleton",{height:"20px",width:"80%"})):this.deliveryMessage?r("div",{class:"s-delivery-promise-message"},this.deliveryMessage):null}renderCityModalBody(){return r("div",{class:"s-delivery-promise-modal-body"},r("salla-searchable-dropdown",{label:this.labels.cityFieldLabel,placeholder:this.labels.modalSearchPlaceholder,items:this.modalCities,selectedItem:this.cityPendingSelection,searching:this.isSearchingCities,required:!0,noResultsText:this.labels.noResults,inputId:"s-delivery-promise-modal-search",onItemSelected:e=>{this.cityPendingSelection=e.detail},onSearchInput:e=>{this.handleCitySearch(e.detail)}}))}renderCityChangeModal(){return this.isLoginCycleEnabled?null:r("salla-modal",{id:"s-delivery-promise-city-modal",ref:e=>{this.cityModalRef=e},class:"s-delivery-promise-city-modal",isClosable:!0,width:"md","modal-title":this.labels.changeCityTitle,subTitle:this.labels.changeCitySubtitle},this.renderCityModalBody(),r("salla-button",{slot:"footer",width:"wide",disabled:!this.cityPendingSelection,onClick:()=>this.handleConfirmCityModal()},!this.isLoadingPromises&&this.labels.confirmAddress))}render(){return this.isDeliveryPromiseEnabled?this.isLoadingCities?this.renderLoadingSkeleton():this.canRender?r(i,{class:"s-delivery-promise-wrapper"},r("div",{class:"s-delivery-promise-container"},r("div",{class:"s-delivery-promise-header",onClick:this.handleHeaderClick},r("div",{class:"s-delivery-promise-location"},r("span",{class:"s-delivery-promise-title"},this.selectedLabel)),r("i",{class:"sicon-keyboard_arrow_down s-delivery-promise-arrow"})),this.hasError&&r("div",{class:"s-delivery-promise-error"},this.errorMessage),!this.hasError&&this.renderDeliveryMessage()),this.renderCityChangeModal()):null:null}get host(){return o(this)}};c.style='/*!twlt*/@charset "UTF-8";:host{display:block}.s-delivery-promise-wrapper{font-family:inherit}.s-delivery-promise-container{position:relative;background:var(--color-surface, #fff);border:1px solid var(--color-border, #e5e7eb);border-radius:8px;padding:12px 16px;margin-bottom:12px}.s-delivery-promise-header{display:flex;align-items:center;cursor:pointer;padding:4px 0}.s-delivery-promise-skeleton .s-delivery-promise-header-skeleton{cursor:default;pointer-events:none}.s-delivery-promise-skeleton .s-delivery-promise-location salla-skeleton{display:block;flex-shrink:0}.s-delivery-promise-location{display:flex;align-items:center;gap:8px}.s-delivery-promise-title{color:var(--color-text-primary, #2b2d34);font-size:14px;font-weight:bold}.s-delivery-promise-arrow{color:var(--color-text-secondary, #666);font-size:18px;transition:transform 0.2s ease}.s-delivery-promise-arrow.open{transform:rotate(180deg)}.s-delivery-promise-city-modal{}.s-delivery-promise-city-modal .s-modal-title{color:var(--color-primary, #00897b);font-weight:700}.s-delivery-promise-city-modal .s-modal-sub-title{color:var(--color-text-secondary, #5c6c7c);font-size:14px;line-height:1.45}.s-delivery-promise-city-modal .s-modal-body{overflow:visible !important}.s-delivery-promise-city-modal .s-modal-body>salla-button{position:relative;z-index:0;margin-top:16px}.s-delivery-promise-modal-body{position:relative;z-index:10;display:flex;flex-direction:column;gap:12px;text-align:start;margin-bottom:16px}.s-delivery-promise-modal-combobox{position:relative;isolation:isolate}.s-delivery-promise-modal-field-label{display:block;font-size:14px;font-weight:500;color:var(--color-text-primary, #2b2d34)}.s-delivery-promise-required{color:var(--color-danger, #dc3545)}.s-delivery-promise-modal-search{display:flex;align-items:center;gap:8px;padding:10px 12px;border:1px solid var(--color-border, #e5e7eb);border-radius:8px;background:var(--color-surface, #fff)}.s-delivery-promise-modal-search .sicon-search{flex-shrink:0;color:var(--color-text-secondary, #999);font-size:16px}.s-delivery-promise-modal-search input{flex:1;border:none;outline:none;font-size:14px;background:transparent;color:var(--color-text-primary, #333)}.s-delivery-promise-modal-search input::placeholder{color:var(--color-text-secondary, #999)}.s-delivery-promise-modal-popover{position:absolute;top:calc(100% + 4px);left:0;right:0;z-index:1;border-radius:8px;border:1px solid var(--color-border, #e5e7eb);background:var(--color-surface, #fff);box-shadow:0 8px 24px rgba(0, 0, 0, 0.12);animation:s-delivery-promise-popover-in 0.2s ease}@keyframes s-delivery-promise-popover-in{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}.s-delivery-promise-modal-list{max-height:min(40vh, 260px);overflow-y:auto;background:var(--color-surface, #fff)}.s-delivery-promise-modal-item{display:flex;width:100%;align-items:center;justify-content:space-between;gap:8px;padding:12px 16px;margin:0;border:none;border-bottom:1px solid var(--color-border, #eee);cursor:pointer;font:inherit;text-align:inherit;background:transparent;color:var(--color-text-primary, #2b2d34);transition:background 0.15s ease}.s-delivery-promise-modal-item:last-child{border-bottom:none}.s-delivery-promise-modal-item:hover{background:var(--color-hover, #f5f5f5)}.s-delivery-promise-modal-item--selected{background:var(--color-primary-light, rgba(0, 137, 123, 0.08))}.s-delivery-promise-modal-item--selected .s-delivery-promise-modal-item-name{color:var(--color-primary, #00897b);font-weight:600}.s-delivery-promise-modal-item .sicon-check{flex-shrink:0;color:var(--color-primary, #00897b);font-size:14px}.s-delivery-promise-modal-empty{padding:24px 16px;text-align:center;color:var(--color-text-secondary, #999);font-size:14px}.s-delivery-promise-message{margin-top:8px;font-size:13px;line-height:1.5;color:var(--color-text-secondary, #2b2d34)}.s-delivery-promise-loading{margin-top:12px;padding-top:12px}.s-delivery-promise-error{margin-top:12px;padding-top:12px;font-size:14px;color:var(--color-danger, #dc3545)}.shadow{--tw-shadow:0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.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-delivery-promise-wrapper{display:block;font-family:inherit}.s-delivery-promise-container{position:relative;margin-bottom:0.75rem;border-radius:0.5rem;border-width:1px;border-color:var(--color-border,#e5e7eb);background-color:var(--color-surface,#fff);padding-left:1rem;padding-right:1rem;padding-top:0.75rem;padding-bottom:0.75rem}.s-delivery-promise-header{display:flex;cursor:pointer;align-items:center;padding-top:0.25rem;padding-bottom:0.25rem}.s-delivery-promise-skeleton .s-delivery-promise-header-skeleton{pointer-events:none;cursor:default}.s-delivery-promise-skeleton .s-delivery-promise-location salla-skeleton{display:block;flex-shrink:0}.s-delivery-promise-location{display:flex;align-items:center;gap:0.5rem}.s-delivery-promise-title{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-text-primary,#2b2d34)}.s-delivery-promise-arrow{font-size:1.125rem;line-height:1.75rem;color:var(--color-text-secondary,#666);transition-property:transform;transition-duration:200ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}.s-delivery-promise-arrow.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-delivery-promise-message{margin-top:0.5rem;font-size:13px;line-height:1.5;color:var(--color-text-secondary,#2b2d34)}.s-delivery-promise-loading{margin-top:0.75rem;padding-top:0.75rem}.s-delivery-promise-error{margin-top:0.75rem;padding-top:0.75rem;font-size:0.875rem;line-height:1.25rem;color:var(--color-danger,#dc3545)}.s-delivery-promise-city-modal .s-modal-title{font-weight:700;color:var(--color-primary,#00897b)}.s-delivery-promise-city-modal .s-modal-sub-title{font-size:0.875rem;line-height:1.25rem;line-height:1.45;color:var(--color-text-secondary,#5c6c7c)}.s-delivery-promise-city-modal .s-modal-body{overflow:visible !important}.s-delivery-promise-city-modal .s-modal-body>salla-button{position:relative;z-index:0;margin-top:1rem}.s-delivery-promise-modal-body{position:relative;z-index:10;margin-bottom:1rem;display:flex;flex-direction:column;gap:0.75rem;text-align:start}.s-delivery-promise-modal-combobox{position:relative;isolation:isolate}.s-delivery-promise-modal-field-label{display:block;font-size:0.875rem;line-height:1.25rem;font-weight:500;color:var(--color-text-primary,#2b2d34)}.s-delivery-promise-modal-required{color:var(--color-danger,#dc3545)}.s-delivery-promise-modal-search{display:flex;align-items:center;gap:0.5rem;border-radius:0.5rem;border-width:1px;border-color:var(--color-border,#e5e7eb);background-color:var(--color-surface,#fff);padding-left:0.75rem;padding-right:0.75rem;padding-top:0.625rem;padding-bottom:0.625rem}.s-delivery-promise-modal-search .sicon-search{flex-shrink:0;font-size:1rem;line-height:1.5rem;color:var(--color-text-secondary,#999)}.s-delivery-promise-modal-search input{min-width:0px;flex:1 1 0%;border-width:0px;background-color:transparent;font-size:0.875rem;line-height:1.25rem;color:var(--color-text-primary,#333);outline:2px solid transparent;outline-offset:2px}.s-delivery-promise-modal-search input::placeholder{color:var(--color-text-secondary,#999)}.s-delivery-promise-modal-popover{position:absolute;left:0px;right:0px;top:calc(100% + 4px);z-index:1;border-radius:0.5rem;border-width:1px;border-color:var(--color-border,#e5e7eb);background-color:var(--color-surface,#fff);--tw-shadow:0 8px 24px rgba(0,0,0,0.12);--tw-shadow-colored:0 8px 24px 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-delivery-promise-modal-list{max-height:min(40vh, 260px);overflow-y:auto;background-color:var(--color-surface,#fff)}.s-delivery-promise-modal-item{margin:0px;display:flex;width:100%;cursor:pointer;align-items:center;justify-content:space-between;gap:0.5rem;border-width:0px;border-bottom-width:1px;border-color:var(--color-border,#eee);background-color:transparent;padding-left:1rem;padding-right:1rem;padding-top:0.75rem;padding-bottom:0.75rem;text-align:start;color:var(--color-text-primary,#2b2d34);transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-duration:150ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}.s-delivery-promise-modal-item:last-child{border-bottom-width:0px}.s-delivery-promise-modal-item--selected{background-color:var(--color-primary-light,rgba(0,137,123,0.08))}.s-delivery-promise-modal-item--selected .s-delivery-promise-modal-item-name{font-weight:600;color:var(--color-primary,#00897b)}.s-delivery-promise-modal-item .sicon-check{flex-shrink:0;font-size:0.875rem;line-height:1.25rem;color:var(--color-primary,#00897b)}.s-delivery-promise-modal-empty{padding-left:1rem;padding-right:1rem;padding-top:1.5rem;padding-bottom:1.5rem;text-align:center;font-size:0.875rem;line-height:1.25rem;color:var(--color-text-secondary,#999)}';export{c as salla_delivery_promise}
4
+ import{r as e,h as r,H as i,a as o}from"./p-HRJpfiBN.js";import{i as t}from"./p-DgRxTSyJ.js";function s(e,r){localStorage.getItem("salla-delivery-promise-debug")&&(void 0!==r?console.log(e,r):console.log(e))}async function l(e,r){s("fetchCities start",{productId:e,keyword:r});const i=null!=r?`?keyword=${encodeURIComponent(r)}`:"",o=await salla.api.request(salla.url.api(`products/${e}/delivery-promises/cities${i}`));return o.success&&Array.isArray(o.data)&&0!==o.data.length?(s("fetchCities success",{count:o.data.length}),{cities:o.data}):(s("fetchCities: no data",{response:o}),{cities:[]})}function a(){const e=(Boolean(salla.config.get("store.settings.bullet_delivery.settings.remember_last_session"))?salla.storage.store:salla.storage.session).get("bullet_delivery_intent");return e&&"object"==typeof e?e:null}const d={deliveryTo:"توصيل إلى",pickupFromBranch:"الاستلام من فرع",noResults:"لا توجد نتائج",selectCity:"اختر المدينة",changeCityTitle:"تغيير المدينة",changeCitySubtitle:"",cityFieldLabel:"المدينة",modalSearchPlaceholder:"ابحث عن مدينة",confirmAddress:"تأكيد العنوان",errorDeliveryPromise:"لا يتوفر وعد تسليم لهذه المدينة",errorPickupPromise:"لا يتوفر وعد تسليم لهذا الفرع"},n="salla-bullet-delivery-override-ip",c=class{constructor(r){e(this,r),this.isDeliveryPromiseEnabled=!1,this.isLoginCycleEnabled=!1,this.canRender=!1,this.labels=d,this.selectedLabel=null,this.deliveryMessage=null,this.hasError=!1,this.errorMessage="",this.isLoadingPromises=!1,this.selectedCityLoginCycle=null,this.selectedBranchLoginCycle=null,this.cities=[],this.selectedCity=null,this.isLoadingCities=!1,this.cityPendingSelection=null,this.modalCities=[],this.isSearchingCities=!1,this.citySearchCounter=0,this.onBulletDeliveryConfirmed=()=>{this.applyBulletIntent()},this.handleCitySearch=e=>{if(clearTimeout(this.citySearchTimer),!e.trim())return this.modalCities=[...this.cities],void(this.isSearchingCities=!1);this.citySearchTimer=setTimeout((()=>this.searchCitiesRemote(e)),300)},this.handleHeaderClick=e=>{e.stopPropagation(),this.isLoginCycleEnabled?this.openBulletDeliveryModal():this.openCityChangeModal()}}async componentDidLoad(){await salla.onReady(),await salla.lang.onLoaded(),this.labels={deliveryTo:salla.lang.getWithDefault("pages.products.promise_deliver_to",d.deliveryTo),pickupFromBranch:salla.lang.getWithDefault("pages.products.promise_pickup_from_branch",d.pickupFromBranch),noResults:salla.lang.getWithDefault("common.elements.no_options",d.noResults),selectCity:salla.lang.getWithDefault("common.elements.select_city",d.selectCity),changeCityTitle:salla.lang.getWithDefault("pages.products.promise_change_city_title",d.changeCityTitle),changeCitySubtitle:salla.lang.getWithDefault("pages.products.promise_change_city_subtitle","قد تتغيّر مدة التوصيل حسب المدينة."),cityFieldLabel:salla.lang.getWithDefault("pages.products.promise_city_field",d.cityFieldLabel),modalSearchPlaceholder:salla.lang.getWithDefault("pages.products.promise_search_city",d.modalSearchPlaceholder),confirmAddress:salla.lang.getWithDefault("pages.checkout.confirm_address",d.confirmAddress),errorDeliveryPromise:salla.lang.getWithDefault("pages.products.promise_delivery_not_available",d.errorDeliveryPromise),errorPickupPromise:salla.lang.getWithDefault("pages.products.promise_pickup_not_available",d.errorPickupPromise)},this.isDeliveryPromiseEnabled=salla.config.get("store.features",[]).includes("delivery-promises"),this.isLoginCycleEnabled=salla.config.get("store.features",[]).includes("bullet-delivery-v2")&&Salla.config.get("store.settings.bullet_delivery.enabled"),this.productId=salla.config.get("page.id"),this.isDeliveryPromiseEnabled?this.isLoginCycleEnabled?await this.initLoginCycleFlow():(this.selectedLabel=`${this.labels.deliveryTo} ${this.labels.selectCity}`,await this.loadCities()):this.canRender=!1}disconnectedCallback(){window.removeEventListener("bulletDeliveryConfirmed",this.onBulletDeliveryConfirmed)}getIPDeliveryLocation(){const e="store.shipping.delivery_location",r={cityId:salla.config.get(`${e}.city_id`),cityName:salla.config.get(`${e}.city_name`)};return localStorage.getItem(n)?JSON.parse(localStorage.getItem(n)):r}async initLoginCycleFlow(){const e=this.applyBulletIntent(),{cityId:r,cityName:i}=this.getIPDeliveryLocation();s("delivery promise login cycle flow getIPDeliveryLocation",this.getIPDeliveryLocation()),r&&i&&!e&&(this.selectedLabel=`${this.labels.deliveryTo} ${i}`,await this.loadDeliveryMessage(r,"city")),this.canRender=!0,window.addEventListener("bulletDeliveryConfirmed",this.onBulletDeliveryConfirmed)}applyBulletIntent(){const e=function(){const e=a();if(!e)return null;if("address"===e.type){const r=e.address_details?.city,i=null!=r?.id?Number(r.id):null!=e.city_id?Number(e.city_id):null,o=r?.name?.trim()||"";return null!=i?{type:"address",option:{id:i,name:o}}:t(e)&&e.address_details?.formatted_address?{type:"address",option:{name:e.address_details.formatted_address}}:null}if("branch"===e.type){const r=null!=e.branch_id?Number(e.branch_id):null!=e.branch_details?.id?Number(e.branch_details.id):null,i=e.branch_details?.name?.trim()||"";return null!=r?{type:"branch",option:{id:r,name:i}}:null}return null}();return e?("address"===e.type?(this.selectedCityLoginCycle=e.option,this.selectedBranchLoginCycle=null,this.selectedLabel=`${this.labels.deliveryTo} ${e.option.name||this.labels.selectCity}`,null!=e.option.id?this.loadDeliveryMessage(e.option.id,"city"):this.deliveryMessage=null):(this.selectedBranchLoginCycle=e.option,this.selectedCityLoginCycle=null,this.selectedLabel=`${this.labels.pickupFromBranch} ${e.option.name}`,this.loadDeliveryMessage(e.option.id,"branch")),!0):(this.selectedLabel=`${this.labels.deliveryTo} ${this.labels.selectCity}`,this.selectedCityLoginCycle=null,this.selectedBranchLoginCycle=null,this.deliveryMessage=null,!1)}openBulletDeliveryModal(){salla.event.emit("salla::bullet-delivery.modal.open.requested",function(){const e=a(),r={};if("address"===e?.type&&null!=e.address_id&&(r.preselected_address_id=Number(e.address_id)),"branch"===e?.type){const i=e.branch_id??e.branch_details?.id;null!=i&&(r.preselected_branch_id=Number(i))}return r}())}async loadCities(){this.isLoadingCities=!0,this.hasError=!1;const{cityId:e,cityName:r}=this.getIPDeliveryLocation();s("delivery promise standard flow getIPDeliveryLocation",this.getIPDeliveryLocation());try{const{cities:i}=await l(this.productId);if(!i.length)return void(this.canRender=!1);if(this.cities=i,this.canRender=!0,e&&r){this.selectedLabel=`${this.labels.deliveryTo} ${r}`;const i=this.cities.find((r=>String(r.id)===String(e)));i&&(s("delivery promise standard flow autoCity found",i),this.selectedCity=i),await this.loadDeliveryMessage(e,"city")}}catch(e){this.hasError=!0,this.errorMessage=e.message||"Failed to load cities",this.canRender=!1}finally{this.isLoadingCities=!1}}async loadDeliveryMessage(e,r){this.isLoadingPromises=!0,this.hasError=!1,this.deliveryMessage=null;try{this.deliveryMessage=await async function(e,r,i,o){s("fetchDeliveryMessage start",{productId:e,id:r,optionType:i});let t="";t="city"!==i||o?`?reference_id=${r}&reference_type=${i}`:`?reference_id=${r}`;const l=await salla.api.withoutNotifier((()=>salla.api.request(salla.url.api(`products/${e}/delivery-promises${t}`))));if(!l.success)return s("fetchDeliveryMessage error",{response:l}),null;const a=l.data?.message?.trim();return s("fetchDeliveryMessage success",{message:a}),a||null}(this.productId,e,r,this.isLoginCycleEnabled)}catch(i){s("loadDeliveryMessage failed",{id:e,optionType:r,error:i}),this.deliveryMessage=null}finally{this.isLoadingPromises=!1}}async openCityChangeModal(){this.cityModalRef&&(this.cityPendingSelection=null,this.modalCities=[...this.cities],await this.cityModalRef.setTitle(this.labels.changeCityTitle),await this.cityModalRef.open())}async searchCitiesRemote(e){const r=++this.citySearchCounter;this.isSearchingCities=!0;try{const{cities:i}=await l(this.productId,e);if(r!==this.citySearchCounter)return;this.modalCities=i}catch{if(r!==this.citySearchCounter)return;this.modalCities=[]}finally{r===this.citySearchCounter&&(this.isSearchingCities=!1)}}async handleConfirmCityModal(){if(!this.cityPendingSelection)return void await(this.cityModalRef?.close());const e=this.cityPendingSelection;this.selectedCity=e,this.selectedLabel=`${this.labels.deliveryTo} ${function(e){const r=salla.config.get("user.language_code");return r&&"ar"!==r&&e.name_en?.trim()?e.name_en.trim():e.name}(e)}`,await this.loadDeliveryMessage(e.id,"city"),await(this.cityModalRef?.close())}renderLoadingSkeleton(){return r(i,{class:"s-delivery-promise-wrapper s-delivery-promise-skeleton"},r("div",{class:"s-delivery-promise-container"},r("div",{class:"s-delivery-promise-header s-delivery-promise-header-skeleton"},r("div",{class:"s-delivery-promise-location"},r("salla-skeleton",{height:"14px",width:"180px"})),r("salla-skeleton",{height:"18px",width:"18px"})),r("div",{class:"s-delivery-promise-loading"},r("salla-skeleton",{height:"20px",width:"80%"}))))}renderDeliveryMessage(){return this.isLoadingPromises?r("div",{class:"s-delivery-promise-loading"},r("salla-skeleton",{height:"20px",width:"80%"})):this.deliveryMessage?r("div",{class:"s-delivery-promise-message"},this.deliveryMessage):null}renderCityModalBody(){return r("div",{class:"s-delivery-promise-modal-body"},r("salla-searchable-dropdown",{label:this.labels.cityFieldLabel,placeholder:this.labels.modalSearchPlaceholder,items:this.modalCities,selectedItem:this.cityPendingSelection,searching:this.isSearchingCities,required:!0,noResultsText:this.labels.noResults,inputId:"s-delivery-promise-modal-search",onItemSelected:e=>{this.cityPendingSelection=e.detail},onSearchInput:e=>{this.handleCitySearch(e.detail)}}))}renderCityChangeModal(){return this.isLoginCycleEnabled?null:r("salla-modal",{id:"s-delivery-promise-city-modal",ref:e=>{this.cityModalRef=e},class:"s-delivery-promise-city-modal",isClosable:!0,width:"md","modal-title":this.labels.changeCityTitle,subTitle:this.labels.changeCitySubtitle},this.renderCityModalBody(),r("salla-button",{slot:"footer",width:"wide",disabled:!this.cityPendingSelection,onClick:()=>this.handleConfirmCityModal()},!this.isLoadingPromises&&this.labels.confirmAddress))}render(){return this.isDeliveryPromiseEnabled?this.isLoadingCities?this.renderLoadingSkeleton():this.canRender?r(i,{class:"s-delivery-promise-wrapper"},r("div",{class:"s-delivery-promise-container"},r("div",{class:"s-delivery-promise-header",onClick:this.handleHeaderClick},r("div",{class:"s-delivery-promise-location"},r("span",{class:"s-delivery-promise-title"},this.selectedLabel)),r("i",{class:"sicon-keyboard_arrow_down s-delivery-promise-arrow"})),this.hasError&&r("div",{class:"s-delivery-promise-error"},this.errorMessage),!this.hasError&&this.renderDeliveryMessage()),this.renderCityChangeModal()):null:null}get host(){return o(this)}};c.style='/*!twlt*/@charset "UTF-8";:host{display:block}.s-delivery-promise-wrapper{font-family:inherit}.s-delivery-promise-container{position:relative;background:var(--color-surface, #fff);border:1px solid var(--color-border, #e5e7eb);border-radius:8px;padding:12px 16px;margin-bottom:12px}.s-delivery-promise-header{display:flex;align-items:center;cursor:pointer;padding:4px 0}.s-delivery-promise-skeleton .s-delivery-promise-header-skeleton{cursor:default;pointer-events:none}.s-delivery-promise-skeleton .s-delivery-promise-location salla-skeleton{display:block;flex-shrink:0}.s-delivery-promise-location{display:flex;align-items:center;gap:8px}.s-delivery-promise-title{color:var(--color-text-primary, #2b2d34);font-size:14px;font-weight:bold}.s-delivery-promise-arrow{color:var(--color-text-secondary, #666);font-size:18px;transition:transform 0.2s ease}.s-delivery-promise-arrow.open{transform:rotate(180deg)}.s-delivery-promise-city-modal{}.s-delivery-promise-city-modal .s-modal-title{color:var(--color-primary, #00897b);font-weight:700}.s-delivery-promise-city-modal .s-modal-sub-title{color:var(--color-text-secondary, #5c6c7c);font-size:14px;line-height:1.45}.s-delivery-promise-city-modal .s-modal-body{overflow:visible !important}.s-delivery-promise-city-modal .s-modal-body>salla-button{position:relative;z-index:0;margin-top:16px}.s-delivery-promise-modal-body{position:relative;z-index:10;display:flex;flex-direction:column;gap:12px;text-align:start;margin-bottom:16px}.s-delivery-promise-modal-combobox{position:relative;isolation:isolate}.s-delivery-promise-modal-field-label{display:block;font-size:14px;font-weight:500;color:var(--color-text-primary, #2b2d34)}.s-delivery-promise-required{color:var(--color-danger, #dc3545)}.s-delivery-promise-modal-search{display:flex;align-items:center;gap:8px;padding:10px 12px;border:1px solid var(--color-border, #e5e7eb);border-radius:8px;background:var(--color-surface, #fff)}.s-delivery-promise-modal-search .sicon-search{flex-shrink:0;color:var(--color-text-secondary, #999);font-size:16px}.s-delivery-promise-modal-search input{flex:1;border:none;outline:none;font-size:14px;background:transparent;color:var(--color-text-primary, #333)}.s-delivery-promise-modal-search input::placeholder{color:var(--color-text-secondary, #999)}.s-delivery-promise-modal-popover{position:absolute;top:calc(100% + 4px);left:0;right:0;z-index:1;border-radius:8px;border:1px solid var(--color-border, #e5e7eb);background:var(--color-surface, #fff);box-shadow:0 8px 24px rgba(0, 0, 0, 0.12);animation:s-delivery-promise-popover-in 0.2s ease}@keyframes s-delivery-promise-popover-in{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}.s-delivery-promise-modal-list{max-height:min(40vh, 260px);overflow-y:auto;background:var(--color-surface, #fff)}.s-delivery-promise-modal-item{display:flex;width:100%;align-items:center;justify-content:space-between;gap:8px;padding:12px 16px;margin:0;border:none;border-bottom:1px solid var(--color-border, #eee);cursor:pointer;font:inherit;text-align:inherit;background:transparent;color:var(--color-text-primary, #2b2d34);transition:background 0.15s ease}.s-delivery-promise-modal-item:last-child{border-bottom:none}.s-delivery-promise-modal-item:hover{background:var(--color-hover, #f5f5f5)}.s-delivery-promise-modal-item--selected{background:var(--color-primary-light, rgba(0, 137, 123, 0.08))}.s-delivery-promise-modal-item--selected .s-delivery-promise-modal-item-name{color:var(--color-primary, #00897b);font-weight:600}.s-delivery-promise-modal-item .sicon-check{flex-shrink:0;color:var(--color-primary, #00897b);font-size:14px}.s-delivery-promise-modal-empty{padding:24px 16px;text-align:center;color:var(--color-text-secondary, #999);font-size:14px}.s-delivery-promise-message{margin-top:8px;font-size:13px;line-height:1.5;color:var(--color-text-secondary, #2b2d34)}.s-delivery-promise-loading{margin-top:12px;padding-top:12px}.s-delivery-promise-error{margin-top:12px;padding-top:12px;font-size:14px;color:var(--color-danger, #dc3545)}.shadow{--tw-shadow:0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.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-delivery-promise-wrapper{display:block;font-family:inherit}.s-delivery-promise-container{position:relative;margin-bottom:0.75rem;border-radius:0.5rem;border-width:1px;border-color:var(--color-border,#e5e7eb);background-color:var(--color-surface,#fff);padding-left:1rem;padding-right:1rem;padding-top:0.75rem;padding-bottom:0.75rem}.s-delivery-promise-header{display:flex;cursor:pointer;align-items:center;padding-top:0.25rem;padding-bottom:0.25rem}.s-delivery-promise-skeleton .s-delivery-promise-header-skeleton{pointer-events:none;cursor:default}.s-delivery-promise-skeleton .s-delivery-promise-location salla-skeleton{display:block;flex-shrink:0}.s-delivery-promise-location{display:flex;align-items:center;gap:0.5rem}.s-delivery-promise-title{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-text-primary,#2b2d34)}.s-delivery-promise-arrow{font-size:1.125rem;line-height:1.75rem;color:var(--color-text-secondary,#666);transition-property:transform;transition-duration:200ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}.s-delivery-promise-arrow.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-delivery-promise-message{margin-top:0.5rem;font-size:13px;line-height:1.5;color:var(--color-text-secondary,#2b2d34)}.s-delivery-promise-loading{margin-top:0.75rem;padding-top:0.75rem}.s-delivery-promise-error{margin-top:0.75rem;padding-top:0.75rem;font-size:0.875rem;line-height:1.25rem;color:var(--color-danger,#dc3545)}.s-delivery-promise-city-modal .s-modal-title{font-weight:700;color:var(--color-primary,#00897b)}.s-delivery-promise-city-modal .s-modal-sub-title{font-size:0.875rem;line-height:1.25rem;line-height:1.45;color:var(--color-text-secondary,#5c6c7c)}.s-delivery-promise-city-modal .s-modal-body{overflow:visible !important}.s-delivery-promise-city-modal .s-modal-body>salla-button{position:relative;z-index:0;margin-top:1rem}.s-delivery-promise-modal-body{position:relative;z-index:10;margin-bottom:1rem;display:flex;flex-direction:column;gap:0.75rem;text-align:start}.s-delivery-promise-modal-combobox{position:relative;isolation:isolate}.s-delivery-promise-modal-field-label{display:block;font-size:0.875rem;line-height:1.25rem;font-weight:500;color:var(--color-text-primary,#2b2d34)}.s-delivery-promise-modal-required{color:var(--color-danger,#dc3545)}.s-delivery-promise-modal-search{display:flex;align-items:center;gap:0.5rem;border-radius:0.5rem;border-width:1px;border-color:var(--color-border,#e5e7eb);background-color:var(--color-surface,#fff);padding-left:0.75rem;padding-right:0.75rem;padding-top:0.625rem;padding-bottom:0.625rem}.s-delivery-promise-modal-search .sicon-search{flex-shrink:0;font-size:1rem;line-height:1.5rem;color:var(--color-text-secondary,#999)}.s-delivery-promise-modal-search input{min-width:0px;flex:1 1 0%;border-width:0px;background-color:transparent;font-size:0.875rem;line-height:1.25rem;color:var(--color-text-primary,#333);outline:2px solid transparent;outline-offset:2px}.s-delivery-promise-modal-search input::placeholder{color:var(--color-text-secondary,#999)}.s-delivery-promise-modal-popover{position:absolute;left:0px;right:0px;top:calc(100% + 4px);z-index:1;border-radius:0.5rem;border-width:1px;border-color:var(--color-border,#e5e7eb);background-color:var(--color-surface,#fff);--tw-shadow:0 8px 24px rgba(0,0,0,0.12);--tw-shadow-colored:0 8px 24px 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-delivery-promise-modal-list{max-height:min(40vh, 260px);overflow-y:auto;background-color:var(--color-surface,#fff)}.s-delivery-promise-modal-item{margin:0px;display:flex;width:100%;cursor:pointer;align-items:center;justify-content:space-between;gap:0.5rem;border-width:0px;border-bottom-width:1px;border-color:var(--color-border,#eee);background-color:transparent;padding-left:1rem;padding-right:1rem;padding-top:0.75rem;padding-bottom:0.75rem;text-align:start;color:var(--color-text-primary,#2b2d34);transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-duration:150ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}.s-delivery-promise-modal-item:last-child{border-bottom-width:0px}.s-delivery-promise-modal-item--selected{background-color:var(--color-primary-light,rgba(0,137,123,0.08))}.s-delivery-promise-modal-item--selected .s-delivery-promise-modal-item-name{font-weight:600;color:var(--color-primary,#00897b)}.s-delivery-promise-modal-item .sicon-check{flex-shrink:0;font-size:0.875rem;line-height:1.25rem;color:var(--color-primary,#00897b)}.s-delivery-promise-modal-empty{padding-left:1rem;padding-right:1rem;padding-top:1.5rem;padding-bottom:1.5rem;text-align:center;font-size:0.875rem;line-height:1.25rem;color:var(--color-text-secondary,#999)}';export{c as salla_delivery_promise}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as e,h as s,H as r}from"./p-0Tl_yZW8.js";const t=class{constructor(s){e(this,s),this.dark=!1,this.commercialRegisterLabel="",this.freelanceLabel=""}componentWillLoad(){this.initializeTranslations()}isVisibilityEnforced(){return"SA"===salla.config.get("store.store_country")}initializeTranslations(){salla.lang.onLoaded((()=>{const e=(e,s,r)=>{salla.helpers.setNested(salla.lang.messages[e],s,r)};e("ar.trans","blocks.footer.commercial_register","السجل التجاري"),e("en.trans","blocks.footer.commercial_register","Commercial Register"),e("ar.trans","blocks.footer.freelance","وثيقة العمل الحر"),e("en.trans","blocks.footer.freelance","Freelance Certificate"),this.commercialRegisterLabel=salla.lang.getWithDefault("blocks.footer.commercial_register","السجل التجاري"),this.freelanceLabel=salla.lang.getWithDefault("blocks.footer.freelance","وثيقة العمل الحر")}))}getBadgeData(){const e=salla.config.get("store.settings.commercial_number"),s=salla.config.get("store.settings.freelance_number");return e?{number:e,label:this.commercialRegisterLabel||"السجل التجاري",imageUrl:salla.url.cdn("images/commercial-register.png",70,70),type:"commercial"}:s?{number:s,label:this.freelanceLabel||"وثيقة العمل الحر",imageUrl:this.dark?salla.url.cdn("images/freelance-white.png"):salla.url.cdn("images/freelance.png"),type:"freelance"}:null}render(){const e=this.getBadgeData();return e?s(r,{class:"s-trust-badges-wrapper "+(this.dark?"dark":"")},this.isVisibilityEnforced()?s("img",{class:"s-trust-badges-image",width:"55",height:"55",src:e.imageUrl,alt:e.label}):null,s("div",{class:"s-trust-badges-content"},s("p",{class:"s-trust-badges-label"},e.label),s("b",{class:"s-trust-badges-number"},e.number))):null}};t.style='/*!twlt*/.s-trust-badges-wrapper{display:flex;align-items:center}.s-trust-badges-wrapper>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(0.5rem * var(--tw-space-x-reverse));margin-left:calc(0.5rem * calc(1 - var(--tw-space-x-reverse)))}.s-trust-badges-wrapper:where([dir="rtl"],[dir="rtl"] *)>:not([hidden])~:not([hidden]){--tw-space-x-reverse:1}.s-trust-badges-label{margin-bottom:0.25rem;font-size:0.875rem;line-height:1.25rem}.s-trust-badges-number{font-size:0.875rem;line-height:1.25rem}';export{t as salla_trust_badges}
4
+ import{r as e,h as s,H as r}from"./p-HRJpfiBN.js";const t=class{constructor(s){e(this,s),this.dark=!1,this.commercialRegisterLabel="",this.freelanceLabel=""}componentWillLoad(){this.initializeTranslations()}isVisibilityEnforced(){return"SA"===salla.config.get("store.store_country")}initializeTranslations(){salla.lang.onLoaded((()=>{const e=(e,s,r)=>{salla.helpers.setNested(salla.lang.messages[e],s,r)};e("ar.trans","blocks.footer.commercial_register","السجل التجاري"),e("en.trans","blocks.footer.commercial_register","Commercial Register"),e("ar.trans","blocks.footer.freelance","وثيقة العمل الحر"),e("en.trans","blocks.footer.freelance","Freelance Certificate"),this.commercialRegisterLabel=salla.lang.getWithDefault("blocks.footer.commercial_register","السجل التجاري"),this.freelanceLabel=salla.lang.getWithDefault("blocks.footer.freelance","وثيقة العمل الحر")}))}getBadgeData(){const e=salla.config.get("store.settings.commercial_number"),s=salla.config.get("store.settings.freelance_number");return e?{number:e,label:this.commercialRegisterLabel||"السجل التجاري",imageUrl:salla.url.cdn("images/commercial-register.png",70,70),type:"commercial"}:s?{number:s,label:this.freelanceLabel||"وثيقة العمل الحر",imageUrl:this.dark?salla.url.cdn("images/freelance-white.png"):salla.url.cdn("images/freelance.png"),type:"freelance"}:null}render(){const e=this.getBadgeData();return e?s(r,{class:"s-trust-badges-wrapper "+(this.dark?"dark":"")},this.isVisibilityEnforced()?s("img",{class:"s-trust-badges-image",width:"55",height:"55",src:e.imageUrl,alt:e.label}):null,s("div",{class:"s-trust-badges-content"},s("p",{class:"s-trust-badges-label"},e.label),s("b",{class:"s-trust-badges-number"},e.number))):null}};t.style='/*!twlt*/.s-trust-badges-wrapper{display:flex;align-items:center}.s-trust-badges-wrapper>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(0.5rem * var(--tw-space-x-reverse));margin-left:calc(0.5rem * calc(1 - var(--tw-space-x-reverse)))}.s-trust-badges-wrapper:where([dir="rtl"],[dir="rtl"] *)>:not([hidden])~:not([hidden]){--tw-space-x-reverse:1}.s-trust-badges-label{margin-bottom:0.25rem;font-size:0.875rem;line-height:1.25rem}.s-trust-badges-number{font-size:0.875rem;line-height:1.25rem}';export{t as salla_trust_badges}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,h as a,H as e,a as r}from"./p-0Tl_yZW8.js";const s=class{constructor(a){if(t(this,a),this.entity="product",this.specs=[],this.download=salla.lang.get("pages.thank_you.download"),this.entityId)try{return void(this.entityId=Array.isArray(this.entityId)?this.entityId:JSON.parse(this.entityId))}catch(t){salla.log("Bad json passed via entityId prop")}}getValue(t){if("file"===t.type)return`<a href="${t.value}" class="text-primary" target="_blank"><span class="sicon-download"></span> ${this.download}</a>`;if("url"===t.type)return`<a href="${t.value}" class="text-blue-700 underline" target="_blank">${t.value}</a>`;if("date"===t.type){const a=new Date(t.value);return`${String(a.getDate()).padStart(2,"0")}/${String(a.getMonth()+1).padStart(2,"0")}/${a.getFullYear()}`}return t.value}async componentWillLoad(){if(await salla.onReady(),!salla.config.get("store.features")?.includes("custom-fields"))return salla.logger.error("feature custom-fields is not activated");if(this.entityId||!salla.url.is_page("product.single")&&!salla.url.is_page("product.showNewUrls")||(this.entityId=salla.config.get("page.id")),!this.entityId)return salla.logger.error("can't render salla-metadata without enity-id prop!");await salla.lang.onLoaded(),this.download=salla.lang.get("pages.thank_you.download");const t=await Salla.api.metadata.fetchValues(this.entity,this.entityId);this.specs=t.data[0]?.sections}render(){if(this.specs.length)return a(e,{class:"s-metadata-wrapper"},this.specs.map((t=>a("div",{class:"s-metadata-box"},a("div",{class:"s-metadata-box-header"},a("i",{class:"sicon-list"}),t.name),t.fields.map((t=>a("div",{class:"s-metadata-row"},a("p",{class:"s-metadata-row-name"},t.name),a("p",{class:"s-metadata-row-value",innerHTML:this.getValue(t)}))))))))}get host(){return r(this)}};s.style="/*!twlt*/.text-blue-700{--tw-text-opacity:1;color:rgb(29 78 216 / var(--tw-text-opacity, 1))}.text-primary{color:var(--color-primary)}.underline{text-decoration-line:underline}.s-metadata-box{margin-bottom:1.25rem;display:block;border-radius:0.375rem;--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1.25rem}.s-metadata-box-header{margin-bottom:0.75rem;display:flex;align-items:center;column-gap:0.5rem;border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));padding-bottom:0.75rem;font-size:1rem;line-height:1.5rem;font-weight:700}.s-metadata-row{margin-bottom:0.75rem;display:flex;flex-direction:row;justify-content:space-between;gap:0.5rem;line-height:1.25rem}.s-metadata-row:last-child{margin-bottom:0px}.s-metadata-row-name{font-size:0.875rem;line-height:1.25rem;font-weight:700;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}";export{s as salla_metadata}
4
+ import{r as t,h as a,H as e,a as r}from"./p-HRJpfiBN.js";const s=class{constructor(a){if(t(this,a),this.entity="product",this.specs=[],this.download=salla.lang.get("pages.thank_you.download"),this.entityId)try{return void(this.entityId=Array.isArray(this.entityId)?this.entityId:JSON.parse(this.entityId))}catch(t){salla.log("Bad json passed via entityId prop")}}getValue(t){if("file"===t.type)return`<a href="${t.value}" class="text-primary" target="_blank"><span class="sicon-download"></span> ${this.download}</a>`;if("url"===t.type)return`<a href="${t.value}" class="text-blue-700 underline" target="_blank">${t.value}</a>`;if("date"===t.type){const a=new Date(t.value);return`${String(a.getDate()).padStart(2,"0")}/${String(a.getMonth()+1).padStart(2,"0")}/${a.getFullYear()}`}return t.value}async componentWillLoad(){if(await salla.onReady(),!salla.config.get("store.features")?.includes("custom-fields"))return salla.logger.error("feature custom-fields is not activated");if(this.entityId||!salla.url.is_page("product.single")&&!salla.url.is_page("product.showNewUrls")||(this.entityId=salla.config.get("page.id")),!this.entityId)return salla.logger.error("can't render salla-metadata without enity-id prop!");await salla.lang.onLoaded(),this.download=salla.lang.get("pages.thank_you.download");const t=await Salla.api.metadata.fetchValues(this.entity,this.entityId);this.specs=t.data[0]?.sections}render(){if(this.specs.length)return a(e,{class:"s-metadata-wrapper"},this.specs.map((t=>a("div",{class:"s-metadata-box"},a("div",{class:"s-metadata-box-header"},a("i",{class:"sicon-list"}),t.name),t.fields.map((t=>a("div",{class:"s-metadata-row"},a("p",{class:"s-metadata-row-name"},t.name),a("p",{class:"s-metadata-row-value",innerHTML:this.getValue(t)}))))))))}get host(){return r(this)}};s.style="/*!twlt*/.text-blue-700{--tw-text-opacity:1;color:rgb(29 78 216 / var(--tw-text-opacity, 1))}.text-primary{color:var(--color-primary)}.underline{text-decoration-line:underline}.s-metadata-box{margin-bottom:1.25rem;display:block;border-radius:0.375rem;--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1.25rem}.s-metadata-box-header{margin-bottom:0.75rem;display:flex;align-items:center;column-gap:0.5rem;border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));padding-bottom:0.75rem;font-size:1rem;line-height:1.5rem;font-weight:700}.s-metadata-row{margin-bottom:0.75rem;display:flex;flex-direction:row;justify-content:space-between;gap:0.5rem;line-height:1.25rem}.s-metadata-row:last-child{margin-bottom:0px}.s-metadata-row-name{font-size:0.875rem;line-height:1.25rem;font-weight:700;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}";export{s as salla_metadata}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,h as r,H as e,a as o}from"./p-0Tl_yZW8.js";import{H as i}from"./p-Brgf4SAC.js";import"./p-CgtvEd63.js";const n=class{constructor(r){t(this,r),this.nextPage="",this.autoload=!1,this.container="salla-infinite-scroll",this.item="salla-infinite-scroll > *",this.status=document.createElement("div"),this.status.className="s-infinite-scroll-wrapper",this.status.innerHTML=`<div class="s-infinite-scroll-status" style="display:none">\n <p class="s-infinite-scroll-last infinite-scroll-last"></p>\n <p class="s-infinite-scroll-error infinite-scroll-error"></p>\n </div>\n <a href="${this.nextPage}" class="s-infinite-scroll-btn s-button-btn s-button-primary">\n <span class="s-button-text s-infinite-scroll-btn-text">${this.loadMoreText?this.loadMoreText:salla.lang.get("common.elements.load_more")}</span>\n <span class="s-button-loader s-button-loader-center s-infinite-scroll-btn-loader" style="display: none"></span>\n </a>`,this.btnLoader=this.status.querySelector(".s-button-loader"),salla.lang.onLoaded((()=>{this.status.querySelector(".s-button-text").innerHTML=this.loadMoreText?this.loadMoreText:salla.lang.get("common.elements.load_more"),this.status.querySelector(".s-infinite-scroll-last").innerHTML=salla.lang.get("common.elements.end_of_content"),this.status.querySelector(".s-infinite-scroll-error").innerHTML=salla.lang.get("common.elements.failed_to_load_more")}))}loading(t=!0){let r=this.status.querySelector(".s-button-text");i.toggleElementClassIf(r,"s-button-hide","s-button-show",(()=>t)),this.btnLoader.style.display=t?"inherit":"none"}render(){return this.nextPage.length>1?r(e,{class:"s-infinite-scroll-container"},r("slot",null)):""}componentDidLoad(){if(0===this.nextPage.length)return;this.host.insertAdjacentElement("afterend",this.status);let t=this,r=salla.infiniteScroll.initiate(this.container,{history:!!this.autoload&&"push",scrollThreshold:!!this.autoload&&400,nextPage:this.nextPage,checkLastPage:'salla-infinite-scroll[next-page*=":"],salla-infinite-scroll[next-page*="."]',status:".s-infinite-scroll-status",button:this.status.querySelector(".s-button-btn"),append:this.item,path:function(){return t.nextPage.replace(/page\=(\d)/g,"page="+(this.loadCount+2))}}).on("request",(()=>this.loading())).on("load",(()=>{this.loading(!1),2==r.pageIndex&&r.option({loadOnScroll:!1}),3==r.pageIndex&&r.option({loadOnScroll:!0})})).on("error",(()=>this.loading(!1)))}get host(){return o(this)}};n.style="/*!twlt*/.s-button-btn{position:relative;display:inline-flex;flex:1 1 0%;user-select:none;flex-direction:row-reverse;align-items:center;justify-content:center;white-space:nowrap;border-radius:var(--s-radius, 0.25rem);border-style:solid;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}.s-button-btn:hover{opacity:0.8}.s-button-primary{border-width:1px;border-color:var(--color-primary);background-color:var(--color-primary);color:var(--color-primary-reverse)}.s-button-primary:hover{background-color:var(--color-primary-dark)}.s-button-text{pointer-events:none;align-items:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;transition-property:opacity;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-button-loader{margin-left:0.5rem;margin-right:0.5rem;display:flex;align-items:center;justify-content:center;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-button-loader::before{display:inline-block;height:1rem;content:var(--tw-content);width:1rem}@keyframes spin{to{content:var(--tw-content);transform:rotate(360deg)}}.s-button-loader::before{animation:spin 1s linear infinite;border-radius:9999px;border-width:2px;border-style:solid;border-top-color:var(--color-primary);border-left-color:var(--color-primary);border-bottom-color:rgb(243 244 246 / var(--tw-border-opacity, 1));--tw-border-opacity:1;border-right-color:rgb(243 244 246 / var(--tw-border-opacity, 1));--tw-content:'';content:var(--tw-content)}.s-button-loader-center .s-button-loader{position:absolute;top:50%;left:50%;margin:0px !important;--tw-translate-y:-50%;--tw-translate-x:-50%;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-comments-item-like-btn .s-button-text{display:flex;flex-direction:row-reverse;gap:0.5rem}.s-infinite-scroll-wrapper{margin-top:1rem;text-align:center}.s-infinite-scroll-last{margin:0px;text-align:center}.s-infinite-scroll-error{margin:0px;text-align:center}";export{n as salla_infinite_scroll}
4
+ import{r as t,h as r,H as e,a as o}from"./p-HRJpfiBN.js";import{H as i}from"./p-Brgf4SAC.js";import"./p-CgtvEd63.js";const n=class{constructor(r){t(this,r),this.nextPage="",this.autoload=!1,this.container="salla-infinite-scroll",this.item="salla-infinite-scroll > *",this.status=document.createElement("div"),this.status.className="s-infinite-scroll-wrapper",this.status.innerHTML=`<div class="s-infinite-scroll-status" style="display:none">\n <p class="s-infinite-scroll-last infinite-scroll-last"></p>\n <p class="s-infinite-scroll-error infinite-scroll-error"></p>\n </div>\n <a href="${this.nextPage}" class="s-infinite-scroll-btn s-button-btn s-button-primary">\n <span class="s-button-text s-infinite-scroll-btn-text">${this.loadMoreText?this.loadMoreText:salla.lang.get("common.elements.load_more")}</span>\n <span class="s-button-loader s-button-loader-center s-infinite-scroll-btn-loader" style="display: none"></span>\n </a>`,this.btnLoader=this.status.querySelector(".s-button-loader"),salla.lang.onLoaded((()=>{this.status.querySelector(".s-button-text").innerHTML=this.loadMoreText?this.loadMoreText:salla.lang.get("common.elements.load_more"),this.status.querySelector(".s-infinite-scroll-last").innerHTML=salla.lang.get("common.elements.end_of_content"),this.status.querySelector(".s-infinite-scroll-error").innerHTML=salla.lang.get("common.elements.failed_to_load_more")}))}loading(t=!0){let r=this.status.querySelector(".s-button-text");i.toggleElementClassIf(r,"s-button-hide","s-button-show",(()=>t)),this.btnLoader.style.display=t?"inherit":"none"}render(){return this.nextPage.length>1?r(e,{class:"s-infinite-scroll-container"},r("slot",null)):""}componentDidLoad(){if(0===this.nextPage.length)return;this.host.insertAdjacentElement("afterend",this.status);let t=this,r=salla.infiniteScroll.initiate(this.container,{history:!!this.autoload&&"push",scrollThreshold:!!this.autoload&&400,nextPage:this.nextPage,checkLastPage:'salla-infinite-scroll[next-page*=":"],salla-infinite-scroll[next-page*="."]',status:".s-infinite-scroll-status",button:this.status.querySelector(".s-button-btn"),append:this.item,path:function(){return t.nextPage.replace(/page\=(\d)/g,"page="+(this.loadCount+2))}}).on("request",(()=>this.loading())).on("load",(()=>{this.loading(!1),2==r.pageIndex&&r.option({loadOnScroll:!1}),3==r.pageIndex&&r.option({loadOnScroll:!0})})).on("error",(()=>this.loading(!1)))}get host(){return o(this)}};n.style="/*!twlt*/.s-button-btn{position:relative;display:inline-flex;flex:1 1 0%;user-select:none;flex-direction:row-reverse;align-items:center;justify-content:center;white-space:nowrap;border-radius:var(--s-radius, 0.25rem);border-style:solid;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}.s-button-btn:hover{opacity:0.8}.s-button-primary{border-width:1px;border-color:var(--color-primary);background-color:var(--color-primary);color:var(--color-primary-reverse)}.s-button-primary:hover{background-color:var(--color-primary-dark)}.s-button-text{pointer-events:none;align-items:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;transition-property:opacity;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-button-loader{margin-left:0.5rem;margin-right:0.5rem;display:flex;align-items:center;justify-content:center;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-button-loader::before{display:inline-block;height:1rem;content:var(--tw-content);width:1rem}@keyframes spin{to{content:var(--tw-content);transform:rotate(360deg)}}.s-button-loader::before{animation:spin 1s linear infinite;border-radius:9999px;border-width:2px;border-style:solid;border-top-color:var(--color-primary);border-left-color:var(--color-primary);border-bottom-color:rgb(243 244 246 / var(--tw-border-opacity, 1));--tw-border-opacity:1;border-right-color:rgb(243 244 246 / var(--tw-border-opacity, 1));--tw-content:'';content:var(--tw-content)}.s-button-loader-center .s-button-loader{position:absolute;top:50%;left:50%;margin:0px !important;--tw-translate-y:-50%;--tw-translate-x:-50%;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-comments-item-like-btn .s-button-text{display:flex;flex-direction:row-reverse;gap:0.5rem}.s-infinite-scroll-wrapper{margin-top:1rem;text-align:center}.s-infinite-scroll-last{margin:0px;text-align:center}.s-infinite-scroll-error{margin:0px;text-align:center}";export{n as salla_infinite_scroll}
@@ -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 o}from"./p-0Tl_yZW8.js";var r,n;!function(t){t.PERCENTAGE="percentage",t.FIXED="fixed",t.FREE_PRODUCT="free_product",t.FREE_SHIPPING="free_shipping"}(r||(r={})),function(t){t.PRODUCT_COUNT="products_count",t.PRODUCT_PURCHASE="order_amount"}(n||(n={}));const s=Object.freeze([]);let a,l=null,c=null,d=!1,f=null,h=null,u=0;function g(t){return"CartNotCreated"===t?.name}function m(){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 p(){const t=m();void 0!==a&&a!==t&&(u++,l=null,c=null,d=!1,f=null),a=t}function b(t){return null==t?0:"number"==typeof t?isFinite(t)?t:0:"string"==typeof t&&parseFloat(t)||0}function w(t){if(null==t||""===t)return null;const i=b(t);return isFinite(i)?i:null}function y(t,i){if(null!==i)return i.length;const e=w(t?.data?.cart?.count??t?.data?.count??t?.cart?.count??t?.count);return null!==e&&e>=0?e:null}function x(t){for(const i of[t?.original_price,t?.product_price,t?.price]){const t=w(i&&"object"==typeof i?i.amount:i);if(null!==t&&t>0)return t}return null}function v(t,i){const e=t?.free_gift_quantity;return null!=e&&""!==e?b(e):i>0?i:0}function k(t){const i=[];for(const e of t){if(null==e?.id)continue;if(!e.added_by_offer)continue;const t=b(e.quantity),o=v(e,t);o<=0||i.push({id:String(e.id),offerId:w(e.offer_id),quantity:o,freeQuantity:o,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:x(e)})}return i}function _(){if(f)return f;const t=u,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);return{gifts:k(i??[]),count:y(t,i),ok:!0}})).catch((t=>({gifts:l??[],count:g(t)?0:c,ok:!1}))).then((({gifts:i,count:e,ok:o})=>{t===u&&(l=i,c=e,d=o)})).finally((()=>{f===i&&(f=null)}));return f=i,i}const C=-1;var M,T;function z(t){const i="number"==typeof t?t:parseFloat(t);return Number.isFinite(i)?i:null}function S(t){return"boolean"==typeof t?t:1===t||0===t?1===t:"true"===t||"1"===t||"false"!==t&&"0"!==t&&void 0}function L(t){return z(t)??0}function I(t,i,e){return Math.max(i,Math.min(t,e))}function V(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"}(M||(M={})),function(t){t.CURRENCY="currency",t.COUNT="count"}(T||(T={}));const F=[1e3,2e3,4e3],R='[data-testid^="store-cart-item-"], form[id^="item-"]';let $=0;const P={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",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",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)"},j="pages.checkout.free_charge";function H(t){const i=document.createElement("div");return i.textContent=t??"",i.innerHTML}const O=(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"})),q=(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"})),N=(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"})),W=class{constructor(i){t(this,i),this.offer=null,this.isLoading=!1,this.canRender=!0,this.gifts=[],this.cartItemCount=null,this.isTooltipHovered=!1,this.isTooltipPinned=!1,this.isGiftsOpen=!0,this.instanceId=++$,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),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,R))return t.parentElement;const o=this.findColumnWithin(e,t);if(o)return o}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(R),o=(e?this.climbToChildOf(e,t):null)??t.querySelector(".main-content, [data-cart-items]");return!o||o===i||o.contains(i)?null:o}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(),function(){if(h)return h;u++,l=null,c=null,d=!1,a=m();const t=()=>(h===i&&(h=null),_()),i=(f??Promise.resolve()).then(t,t).finally((()=>{h===i&&(h=null)}));return h=i,i}().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(j);return t&&t!==j?t:"Free"}trans(t,i){const e=`blocks.cart_offer.${t}`,o=salla.lang.get(e,i);return o&&o!==e?o:Object.entries(i??{}).reduce(((t,[i,e])=>t.split(`:${i}`).join(e)),P[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(),p(),void(d||(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()}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([(p(),d&&l?Promise.resolve(l):_().then((()=>l??s))),(p(),d&&l?Promise.resolve(c):_().then((()=>c)))]).then((([i,e])=>{t!==this.giftsGeneration||this.isDisconnected||this.cartRefreshPending||(null!==e&&(this.cartItemCount=e),null!==e?this.clearCartLookupRetry():null===this.cartItemCount&&this.scheduleCartLookupRetry(),this.deferredByEmptyCart&&this.hasCartItems()&&(this.deferredByEmptyCart=!1,this.refresh()),this.gifts=this.offer?this.selectOwnGifts(i):[])})).catch((t=>{this.safeLog("cart lookup failed",t)}))}scheduleCartLookupRetry(){this.cartLookupRetries>=F.length||(this.cartLookupRetryPending=!0,null!==this.cartLookupRetryTimer||this.isDisconnected||(this.cartLookupRetryTimer=setTimeout((()=>{this.cartLookupRetryTimer=null,this.cartLookupRetryPending=!1,this.canRender&&(this.cartLookupRetries++,this.loadCart())}),F[this.cartLookupRetries])))}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!==z(t)));return i=({min_spend:t})=>t,e=({id:t})=>t,(t??[]).map(((t,o)=>({item:t,index:o,threshold:L(i(t)),identity:e?z(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,o=[],r=[]){const n=(i??[]).map(((t,i)=>({index:i,threshold:z(t),applied:S(o?.[i]),tierValue:z(r?.[i])}))).filter((t=>null!==t.threshold)).sort(((t,i)=>t.threshold-i.threshold||t.index-i.index)),s=n.map((t=>t.threshold)),a=n.map((t=>t.applied)),l=a.some((t=>void 0!==t)),c=L(e);if(!s.length)return{thresholds:s,met:[],applied:a,appliedIndex:C,hasEngineVerdict:l,metCount:0,nextUnmetIndex:C,allMet:!1,lastReachedIndex:C,currentIndex:C,isComplete:!1,value:Math.max(0,L(t)),values:[],startValue:c,fills:[],overallPercentage:0};const d=s[s.length-1],f=I(L(t),0,Math.max(0,d)),h=n.map((({tierValue:t})=>null===t?f:I(t,0,Math.max(0,d))));let u=C;for(let t=0;t<s.length;t++)h[t]>=s[t]&&(u=t);const g=u===s.length-1,m=g?C:u+1,p=s.map(((t,i)=>function(t,i,e){return e<=i?t>=e?100:0:I((t-i)/(e-i)*100,0,100)}(h[i],0===i?c:s[i-1],t))),b=g?100:I((u+1+(p[m]??0)/100)/s.length*100,0,100);let w=C;for(let t=0;t<a.length;t++)!0===a[t]&&(w=t);const y=s.map(l?(t,i)=>i<=w:(t,i)=>i<=u),x=y.filter(Boolean).length,v=y.findIndex((t=>!t));return{thresholds:s,met:y,applied:a,appliedIndex:w,hasEngineVerdict:l,metCount:x,nextUnmetIndex:v,allMet:v===C,lastReachedIndex:u,currentIndex:m,isComplete:g,value:f,values:h,startValue:c,fills:p,overallPercentage:b}}(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)))}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?T.COUNT:T.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){return(t?.reward_label??"").trim()}getGuidanceMessage(t,i){if(i.nextUnmetIndex===C)return"";const e=function(t,i,e=T.CURRENCY){const o=i.thresholds[t];if(void 0===o)return 0;const r=Math.max(0,o-(i.values?.[t]??i.value));if(0===r)return 0;const n=e===T.COUNT?0:function(){try{const t="undefined"!=typeof salla?salla:void 0,i=V(t?.config?.currency?.()?.decimals);if(null!==i)return i;const e=V(t?.config?.get?.("store.currency.decimals"));if(null!==e)return e}catch(t){}return 2}(),s=Math.pow(10,n),a=Math.ceil(r*s-1e-6)/s;return a>0?a:1/s}(i.nextUnmetIndex,i,this.stageMeasure());if(e<=0)return this.trans("guidance_conditions_unmet");const o=this.formatRequirement(e),r=this.getRewardText(t[i.nextUnmetIndex]);return r?this.trans("guidance_next",{remaining:o,reward:H(r)}):this.trans("guidance_next_generic",{remaining:o})}getTierSentence(t,i,e){const o=this.formatRequirement(e.thresholds[i]),r=this.getRewardText(t),n=this.stageMeasure()===T.COUNT;return r?this.trans(n?"tier_requirement_count":"tier_requirement",{threshold:o,reward:H(r)}):this.trans(n?"tier_requirement_count_generic":"tier_requirement_generic",{threshold:o})}getRewardIcon(t){switch(t?.type){case r.PERCENTAGE:return"sicon-percentage";case r.FREE_PRODUCT:return"sicon-gift";case r.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,o=t.getBoundingClientRect(),r=i.getBoundingClientRect(),n=o?.width||0;if(n<=0||e<=0)return;const s=r.left+r.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,o)=>{const r=e.met[o],n=this.tierKey(t,o);return[o>0?i("span",{key:`${n}-link`,class:{"s-conditional-offer-badge-link":!0,"s-conditional-offer-badge-link-met":r,"s-conditional-offer-badge-link-unmet":!r},"aria-hidden":"true"}):null,i("span",{key:n,class:{"s-conditional-offer-badge":!0,"s-conditional-offer-badge-met":r,"s-conditional-offer-badge-unmet":!r},"data-tier-state":r?"met":"unmet","data-tier-id":t?.id??void 0},i(r?O:q,{class:"s-conditional-offer-badge-icon"}))]})))}renderTooltip(t,e){const o=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),o?i("div",{class:"s-conditional-offer-tooltip-description"},o):null,i("ul",{class:"s-conditional-offer-tooltip-list"},t.map(((t,o)=>{const r=e.met[o];return i("li",{key:this.tierKey(t,o),class:"s-conditional-offer-tier","data-tier-state":r?"met":"unmet","data-tier-id":t?.id??void 0},i("span",{class:{"s-conditional-offer-tier-icon":!0,"s-conditional-offer-tier-icon-met":r,"s-conditional-offer-tier-icon-unmet":!r}},i("i",{class:this.getRewardIcon(t),"aria-hidden":"true"}),i("span",{class:{"s-conditional-offer-tier-status":!0,"s-conditional-offer-tier-status-met":r,"s-conditional-offer-tier-status-unmet":!r},"aria-hidden":"true"},r?i(O,{class:"s-conditional-offer-tier-status-check"}):i(q,{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:`${o+1}`})),i("div",{class:{"s-conditional-offer-tier-text":!0,"s-conditional-offer-tier-text-met":r},innerHTML:this.getTierSentence(t,o,e)})))}))))}renderGiftsToggle(t){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("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(){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)))))}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(),o=this.getProgress(t),r=this.getGuidanceMessage(t,o),n=this.trans("details_title"),s=this.gifts.length>0;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,o),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(N,{class:"s-conditional-offer-info-icon"})),this.isTooltipOpen?this.renderTooltip(t,o):null)),o.allMet?i("div",{class:"s-conditional-offer-message",role:"status"},this.trans("congrats")):r?i("div",{class:"s-conditional-offer-message",innerHTML:r}):null)),s?this.renderGiftsToggle("inline"):null),s&&this.isGiftsOpen?this.renderGiftsCard():null,s?this.renderGiftsToggle("bar"):null)}get hostEl(){return o(this)}};W.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-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{W as salla_conditional_offer}
4
+ import{r as t,h as i,H as e,a as o}from"./p-HRJpfiBN.js";var r,n;!function(t){t.PERCENTAGE="percentage",t.FIXED="fixed",t.FREE_PRODUCT="free_product",t.FREE_SHIPPING="free_shipping"}(r||(r={})),function(t){t.PRODUCT_COUNT="products_count",t.PRODUCT_PURCHASE="order_amount"}(n||(n={}));const s=Object.freeze([]);let a,l=null,c=null,d=!1,f=null,h=null,u=0;function g(t){return"CartNotCreated"===t?.name}function m(){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 p(){const t=m();void 0!==a&&a!==t&&(u++,l=null,c=null,d=!1,f=null),a=t}function b(t){return null==t?0:"number"==typeof t?isFinite(t)?t:0:"string"==typeof t&&parseFloat(t)||0}function w(t){if(null==t||""===t)return null;const i=b(t);return isFinite(i)?i:null}function y(t,i){if(null!==i)return i.length;const e=w(t?.data?.cart?.count??t?.data?.count??t?.cart?.count??t?.count);return null!==e&&e>=0?e:null}function x(t){for(const i of[t?.original_price,t?.product_price,t?.price]){const t=w(i&&"object"==typeof i?i.amount:i);if(null!==t&&t>0)return t}return null}function v(t,i){const e=t?.free_gift_quantity;return null!=e&&""!==e?b(e):i>0?i:0}function k(t){const i=[];for(const e of t){if(null==e?.id)continue;if(!e.added_by_offer)continue;const t=b(e.quantity),o=v(e,t);o<=0||i.push({id:String(e.id),offerId:w(e.offer_id),quantity:o,freeQuantity:o,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:x(e)})}return i}function _(){if(f)return f;const t=u,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);return{gifts:k(i??[]),count:y(t,i),ok:!0}})).catch((t=>({gifts:l??[],count:g(t)?0:c,ok:!1}))).then((({gifts:i,count:e,ok:o})=>{t===u&&(l=i,c=e,d=o)})).finally((()=>{f===i&&(f=null)}));return f=i,i}const C=-1;var M,T;function z(t){const i="number"==typeof t?t:parseFloat(t);return Number.isFinite(i)?i:null}function S(t){return"boolean"==typeof t?t:1===t||0===t?1===t:"true"===t||"1"===t||"false"!==t&&"0"!==t&&void 0}function L(t){return z(t)??0}function I(t,i,e){return Math.max(i,Math.min(t,e))}function V(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"}(M||(M={})),function(t){t.CURRENCY="currency",t.COUNT="count"}(T||(T={}));const R=[1e3,2e3,4e3],F='[data-testid^="store-cart-item-"], form[id^="item-"]';let $=0;const H={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",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",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)"},P="pages.checkout.free_charge";function j(t){const i=document.createElement("div");return i.textContent=t??"",i.innerHTML}const N=(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"})),O=(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"})),q=(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"})),B=class{constructor(i){t(this,i),this.offer=null,this.isLoading=!1,this.canRender=!0,this.gifts=[],this.cartItemCount=null,this.isTooltipHovered=!1,this.isTooltipPinned=!1,this.isGiftsOpen=!0,this.instanceId=++$,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),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,F))return t.parentElement;const o=this.findColumnWithin(e,t);if(o)return o}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(F),o=(e?this.climbToChildOf(e,t):null)??t.querySelector(".main-content, [data-cart-items]");return!o||o===i||o.contains(i)?null:o}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(),function(){if(h)return h;u++,l=null,c=null,d=!1,a=m();const t=()=>(h===i&&(h=null),_()),i=(f??Promise.resolve()).then(t,t).finally((()=>{h===i&&(h=null)}));return h=i,i}().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(P);return t&&t!==P?t:"Free"}trans(t,i){const e=`blocks.cart_offer.${t}`,o=salla.lang.get(e,i);return o&&o!==e?o:Object.entries(i??{}).reduce(((t,[i,e])=>t.split(`:${i}`).join(e)),H[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(),p(),void(d||(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()}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([(p(),d&&l?Promise.resolve(l):_().then((()=>l??s))),(p(),d&&l?Promise.resolve(c):_().then((()=>c)))]).then((([i,e])=>{t!==this.giftsGeneration||this.isDisconnected||this.cartRefreshPending||(null!==e&&(this.cartItemCount=e),null!==e?this.clearCartLookupRetry():null===this.cartItemCount&&this.scheduleCartLookupRetry(),this.deferredByEmptyCart&&this.hasCartItems()&&(this.deferredByEmptyCart=!1,this.refresh()),this.gifts=this.offer?this.selectOwnGifts(i):[])})).catch((t=>{this.safeLog("cart lookup failed",t)}))}scheduleCartLookupRetry(){this.cartLookupRetries>=R.length||(this.cartLookupRetryPending=!0,null!==this.cartLookupRetryTimer||this.isDisconnected||(this.cartLookupRetryTimer=setTimeout((()=>{this.cartLookupRetryTimer=null,this.cartLookupRetryPending=!1,this.canRender&&(this.cartLookupRetries++,this.loadCart())}),R[this.cartLookupRetries])))}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!==z(t)));return i=({min_spend:t})=>t,e=({id:t})=>t,(t??[]).map(((t,o)=>({item:t,index:o,threshold:L(i(t)),identity:e?z(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,o=[],r=[]){const n=(i??[]).map(((t,i)=>({index:i,threshold:z(t),applied:S(o?.[i]),tierValue:z(r?.[i])}))).filter((t=>null!==t.threshold)).sort(((t,i)=>t.threshold-i.threshold||t.index-i.index)),s=n.map((t=>t.threshold)),a=n.map((t=>t.applied)),l=a.some((t=>void 0!==t)),c=L(e);if(!s.length)return{thresholds:s,met:[],applied:a,appliedIndex:C,hasEngineVerdict:l,metCount:0,nextUnmetIndex:C,allMet:!1,lastReachedIndex:C,currentIndex:C,isComplete:!1,value:Math.max(0,L(t)),values:[],startValue:c,fills:[],overallPercentage:0};const d=s[s.length-1],f=I(L(t),0,Math.max(0,d)),h=n.map((({tierValue:t})=>null===t?f:I(t,0,Math.max(0,d))));let u=C;for(let t=0;t<s.length;t++)h[t]>=s[t]&&(u=t);const g=u===s.length-1,m=g?C:u+1,p=s.map(((t,i)=>function(t,i,e){return e<=i?t>=e?100:0:I((t-i)/(e-i)*100,0,100)}(h[i],0===i?c:s[i-1],t))),b=g?100:I((u+1+(p[m]??0)/100)/s.length*100,0,100);let w=C;for(let t=0;t<a.length;t++)!0===a[t]&&(w=t);const y=s.map(l?(t,i)=>i<=w:(t,i)=>i<=u),x=y.filter(Boolean).length,v=y.findIndex((t=>!t));return{thresholds:s,met:y,applied:a,appliedIndex:w,hasEngineVerdict:l,metCount:x,nextUnmetIndex:v,allMet:v===C,lastReachedIndex:u,currentIndex:m,isComplete:g,value:f,values:h,startValue:c,fills:p,overallPercentage:b}}(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)))}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?T.COUNT:T.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){return(t?.reward_label??"").trim()}getGuidanceMessage(t,i){if(i.nextUnmetIndex===C)return"";const e=function(t,i,e=T.CURRENCY){const o=i.thresholds[t];if(void 0===o)return 0;const r=Math.max(0,o-(i.values?.[t]??i.value));if(0===r)return 0;const n=e===T.COUNT?0:function(){try{const t="undefined"!=typeof salla?salla:void 0,i=V(t?.config?.currency?.()?.decimals);if(null!==i)return i;const e=V(t?.config?.get?.("store.currency.decimals"));if(null!==e)return e}catch(t){}return 2}(),s=Math.pow(10,n),a=Math.ceil(r*s-1e-6)/s;return a>0?a:1/s}(i.nextUnmetIndex,i,this.stageMeasure());if(e<=0)return this.trans("guidance_conditions_unmet");const o=this.formatRequirement(e),r=this.getRewardText(t[i.nextUnmetIndex]);return r?this.trans("guidance_next",{remaining:o,reward:j(r)}):this.trans("guidance_next_generic",{remaining:o})}getTierSentence(t,i,e){const o=this.formatRequirement(e.thresholds[i]),r=this.getRewardText(t),n=this.stageMeasure()===T.COUNT;return r?this.trans(n?"tier_requirement_count":"tier_requirement",{threshold:o,reward:j(r)}):this.trans(n?"tier_requirement_count_generic":"tier_requirement_generic",{threshold:o})}getRewardIcon(t){switch(t?.type){case r.PERCENTAGE:return"sicon-percentage";case r.FREE_PRODUCT:return"sicon-gift";case r.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,o=t.getBoundingClientRect(),r=i.getBoundingClientRect(),n=o?.width||0;if(n<=0||e<=0)return;const s=r.left+r.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,o)=>{const r=e.met[o],n=this.tierKey(t,o);return[o>0?i("span",{key:`${n}-link`,class:{"s-conditional-offer-badge-link":!0,"s-conditional-offer-badge-link-met":r,"s-conditional-offer-badge-link-unmet":!r},"aria-hidden":"true"}):null,i("span",{key:n,class:{"s-conditional-offer-badge":!0,"s-conditional-offer-badge-met":r,"s-conditional-offer-badge-unmet":!r},"data-tier-state":r?"met":"unmet","data-tier-id":t?.id??void 0},i(r?N:O,{class:"s-conditional-offer-badge-icon"}))]})))}renderTooltip(t,e){const o=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),o?i("div",{class:"s-conditional-offer-tooltip-description"},o):null,i("ul",{class:"s-conditional-offer-tooltip-list"},t.map(((t,o)=>{const r=e.met[o];return i("li",{key:this.tierKey(t,o),class:"s-conditional-offer-tier","data-tier-state":r?"met":"unmet","data-tier-id":t?.id??void 0},i("span",{class:{"s-conditional-offer-tier-icon":!0,"s-conditional-offer-tier-icon-met":r,"s-conditional-offer-tier-icon-unmet":!r}},i("i",{class:this.getRewardIcon(t),"aria-hidden":"true"}),i("span",{class:{"s-conditional-offer-tier-status":!0,"s-conditional-offer-tier-status-met":r,"s-conditional-offer-tier-status-unmet":!r},"aria-hidden":"true"},r?i(N,{class:"s-conditional-offer-tier-status-check"}):i(O,{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:`${o+1}`})),i("div",{class:{"s-conditional-offer-tier-text":!0,"s-conditional-offer-tier-text-met":r},innerHTML:this.getTierSentence(t,o,e)})))}))))}renderGiftsToggle(t){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("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(){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)))))}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(),o=this.getProgress(t),r=this.getGuidanceMessage(t,o),n=this.trans("details_title"),s=this.gifts.length>0;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,o),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(q,{class:"s-conditional-offer-info-icon"})),this.isTooltipOpen?this.renderTooltip(t,o):null)),o.allMet?i("div",{class:"s-conditional-offer-message",role:"status"},this.trans("congrats")):r?i("div",{class:"s-conditional-offer-message",innerHTML:r}):null)),s?this.renderGiftsToggle("inline"):null),s&&this.isGiftsOpen?this.renderGiftsCard():null,s?this.renderGiftsToggle("bar"):null)}get hostEl(){return o(this)}};B.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-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{B as salla_conditional_offer}
@@ -0,0 +1,4 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ import{r as t,h as o,H as r,a}from"./p-HRJpfiBN.js";const s=class{constructor(o){t(this,o),this.availableCoupons=[],this.cartTotal=0,this.cartTotalReady=!1,this.currentCoupon="",this.couponInputValue="",this.couponError="",this.isApplying=!1,this.appliedCoupons=[],this.mergedCoupons=[],this.appliedCouponCards=[],this.orderLocked=!1,this.multiCoupon=!1,this.isHandlingInternalError=!1,this.cartUpdatedHandler=t=>{this.syncCartTotal(t),(this.multiCoupon?Array.isArray(t?.coupons):t&&("coupon"in t||"cashback_code"in t))?this.syncAppliedFromCart(t):this.multiCoupon&&t&&"cashback_code"in t&&this.mergeCashbackCodeChip(t.cashback_code),this.couponError=""},this.couponAddedHandler=()=>{this.isApplying||this.isHandlingInternalError||this.refreshFromServer()},this.couponAdditionFailedHandler=t=>{this.isApplying||this.isHandlingInternalError||this.showCouponError(t?.message||salla.lang.get("pages.cart.coupon_application_error"))},this.couponDeletedHandler=()=>{this.isApplying||this.isHandlingInternalError||this.refreshFromServer()},this.onKeyUp=t=>{"Enter"===t.key&&this.couponButtonRef?.click(),this.couponError=""},this.onInput=t=>{this.couponInputValue=t.target.value},this.mergedCashbackCode=""}async componentWillLoad(){await Salla.onReady(),await Salla.lang.onLoaded(),this.multiCoupon=!!salla.config.get("store.settings.cart.multi_coupon"),this.loadCouponsData(),this.seedFromStorage(),this.loadCartTotal(),this.setupCartEventListeners()}setupCartEventListeners(){salla.event.on("cart::updated",this.cartUpdatedHandler),salla.event.on("cart::coupon.added",this.couponAddedHandler),salla.event.on("cart::coupon.addition.failed",this.couponAdditionFailedHandler),salla.event.on("cart::coupon.deleted",this.couponDeletedHandler)}disconnectedCallback(){salla.event.off("cart::updated",this.cartUpdatedHandler),salla.event.off("cart::coupon.added",this.couponAddedHandler),salla.event.off("cart::coupon.addition.failed",this.couponAdditionFailedHandler),salla.event.off("cart::coupon.deleted",this.couponDeletedHandler)}async selectCoupon(t){const o=this.availableCoupons.find((o=>o.code===t));if(o){if(!this.isEligible(o))throw new Error("Coupon not eligible: minimum cart amount not met");try{await this.applyCoupon(t),this.host.dispatchEvent(new CustomEvent("salla::cart-coupons.coupon.selected",{detail:o,bubbles:!0}))}catch(t){throw t}}return o}async loadCouponsData(){try{const t=await salla.api.request("coupons"),o=t?.data,r=Array.isArray(o)?o:Array.isArray(o?.data)?o.data:[];this.availableCoupons=r}catch(t){console.warn("Failed to load coupons:",t),this.availableCoupons=[]}this.buildMergedCoupons()}async loadCartTotal(){await this.refreshFromServer()}seedFromStorage(){if(this.multiCoupon)return;const t=salla.storage.get("cart");t&&"object"==typeof t&&"coupon"in t&&this.applyCart(t),this.seedTotalsFromSummaryStorage()}seedTotalsFromSummaryStorage(){const t=salla.storage.get("cart.summary");t&&"object"==typeof t&&null!=t.sub_total&&(this.cartTotal=Number(t.sub_total),this.cartTotalReady=!0)}syncCartTotal(t){const o=t?.summary?.sub_total??t?.sub_total??t?.total;null!=o&&(this.cartTotal=Number(o),this.cartTotalReady=!0)}async refreshFromServer(){try{const t=await salla.cart.details(),o=t?.data?.cart??t?.data??t;if(o&&"object"==typeof o&&(Array.isArray(o.coupons)||"coupon"in o||"cashback_code"in o))return void this.applyCart(o)}catch(t){}const t=salla.storage.get("cart");t&&this.applyCart(t),this.seedTotalsFromSummaryStorage()}applyCart(t){this.syncCartTotal(t),this.syncAppliedFromCart(t)}mergeCashbackCodeChip(t){const o=(t||"").trim(),r=(this.mergedCashbackCode||"").trim();if(o.toLowerCase()===r.toLowerCase())return;const a=r?this.appliedCoupons.filter((t=>(t||"").toLowerCase()!==r.toLowerCase())):[...this.appliedCoupons],s=a.some((t=>(t||"").toLowerCase()===o.toLowerCase()));this.appliedCoupons=o&&!s?[...a,o]:a,this.mergedCashbackCode=o,r&&this.currentCoupon.toLowerCase()===r.toLowerCase()?this.currentCoupon=o:o&&(this.currentCoupon=this.currentCoupon||o),this.buildMergedCoupons()}syncAppliedFromCart(t){if(this.currentCoupon=t?.coupon||t?.cashback_code||"",this.mergedCashbackCode=(t?.cashback_code||"").trim(),this.multiCoupon){const o=Array.isArray(t?.coupons)?t.coupons:[t?.coupon];this.appliedCoupons=[...o,t?.cashback_code].filter(Boolean);const r=t?.applied_coupons;return this.appliedCouponCards=Array.isArray(r)?r.filter(Boolean):r&&"object"==typeof r?Object.values(r).filter(Boolean):[],void this.buildMergedCoupons()}this.couponInputValue=this.currentCoupon,this.appliedCoupons=this.currentCoupon?[this.currentCoupon]:[],this.buildMergedCoupons()}buildMergedCoupons(){if(!this.multiCoupon)return void(this.mergedCoupons=[]);const t=this.appliedCoupons.filter(Boolean),o=new Set(t),r=new Map(this.availableCoupons.map((t=>[t.code,t]))),a=new Map(r);this.appliedCouponCards.forEach((t=>{t?.code&&!a.has(t.code)&&a.set(t.code,t)}));const s=this.orderLocked?this.mergeIntoLockedOrder(t,r,(t=>o.has(t)||r.has(t))):[...t,...this.availableCoupons.map((t=>t.code)).filter((t=>!o.has(t)))];this.mergedCoupons=s.map((t=>({code:t,coupon:a.get(t)??null,applied:o.has(t)})))}mergeIntoLockedOrder(t,o,r){const a=this.mergedCoupons.map((t=>t.code)).filter(r),s=new Set(a),i=t.filter((t=>!s.has(t)));i.forEach((t=>s.add(t)));const e=[...o.keys()].filter((t=>!s.has(t)));return[...i,...a,...e]}lockOrder(){this.orderLocked=!0}async handleApplyClick(){if(this.isApplying)return;const t=this.couponInputValue.trim();if(t){this.lockOrder(),this.isApplying=!0,this.isHandlingInternalError=!0;try{await salla.cart.addCoupon(t),await this.refreshFromServer(),this.couponInputValue=""}catch(t){this.showCouponError(t.response?.data?.error?.message||salla.lang.get("pages.cart.coupon_application_error"))}finally{this.isApplying=!1,setTimeout((()=>{this.isHandlingInternalError=!1}),100)}}else this.showCouponError(salla.lang.get("pages.cart.enter_coupon_code"))}async handleCouponButtonClick(){if(this.isApplying)return;const t=!!this.currentCoupon;if(t||this.couponInputValue.trim()){this.isApplying=!0,this.isHandlingInternalError=!0;try{t?await salla.cart.deleteCoupon():await salla.cart.addCoupon(this.couponInputValue.trim()),await this.refreshFromServer()}catch(t){this.showCouponError(t.response?.data?.error?.message||salla.lang.get("pages.cart.coupon_application_error"))}finally{this.isApplying=!1,setTimeout((()=>{this.isHandlingInternalError=!1}),100)}}else this.showCouponError(salla.lang.get("pages.cart.enter_coupon_code"))}async removeCoupon(t){if(!this.isApplying){this.lockOrder(),this.isApplying=!0,this.isHandlingInternalError=!0;try{this.multiCoupon?await salla.cart.deleteCoupon(t):await salla.cart.deleteCoupon(),await this.refreshFromServer()}catch(t){this.showCouponError(t.response?.data?.error?.message||salla.lang.get("pages.cart.coupon_application_error"))}finally{this.isApplying=!1,setTimeout((()=>{this.isHandlingInternalError=!1}),100)}}}showCouponError(t){this.couponError=t}handleCouponClick(t){this.applyCoupon(t.code,!1).catch((()=>{}))}async applyCoupon(t,o=!0){if(this.isApplying){if(o)throw new Error("Coupon application already in progress")}else{this.lockOrder(),this.couponInputValue=t,this.couponError="",this.isApplying=!0,this.isHandlingInternalError=!0;try{await salla.cart.addCoupon(t.trim()),await this.refreshFromServer(),this.multiCoupon&&(this.couponInputValue="")}catch(t){if(this.showCouponError(t.response?.data?.error?.message||salla.lang.get("pages.cart.coupon_application_error")),o)throw t}finally{this.isApplying=!1,setTimeout((()=>{this.isHandlingInternalError=!1}),100)}}}formatMainAmount(t){if("percentage"===t.type)return`${salla.helpers.number("object"==typeof t.amount?t.amount.amount:t.amount)}%`;{const r="object"==typeof t.amount?t.amount:{amount:t.amount,currency:t.minimum_amount?.currency||salla.config.get("store.currency.code","SAR")};return o("span",{innerHTML:salla.money(r.amount,r.currency)})}}isEligible(t){return!this.cartTotalReady||!t.minimum_amount||this.cartTotal>=parseFloat(t.minimum_amount.amount)}renderCouponCard(t){const{coupon:r,applied:a,code:s}=t;if(!r)return this.renderMinimalCard(s);const i=this.isEligible(r);return o("div",{class:"s-cart-coupons-slide-one-fourth swiper-slide"},o("div",{class:`s-cart-coupons-card ${a?"s-cart-coupons-card--applied":""} ${a||i&&!this.isApplying?"":"s-cart-coupons-disabled"}`,onClick:()=>!a&&i&&!this.isApplying&&this.handleCouponClick(r)},o("div",{class:"s-cart-coupons-top-section"},o("div",{class:"s-cart-coupons-discount-values"},o("div",{class:"s-cart-coupons-main-amount"},this.formatMainAmount(r)),r.free_shipping?o("div",{class:"s-cart-coupons-secondary-info"},"+ ",salla.lang.get("pages.cart.free_shipping")):r.maximum_amount&&o("div",{class:"s-cart-coupons-secondary-info"},salla.lang.get("pages.cart.up_to")," ",o("span",{innerHTML:salla.money(r.maximum_amount.amount,r.maximum_amount.currency)}))),o("div",{class:"s-cart-coupons-code"},r.code)),o("div",{class:"s-cart-coupons-divider"}),o("div",{class:"s-cart-coupons-bottom-section"},o("div",{class:"s-cart-coupons-terms"},null!=r.remaining_days&&o("div",{class:"s-cart-coupons-expiry "+(r.remaining_days<=3?"s-cart-coupons-expiry-warning":"")},0===r.remaining_days?salla.lang.get("pages.cart.expires_today"):`${salla.lang.get("pages.cart.expires_after")} ${r.remaining_days} ${salla.lang.get("pages.cart.day")}`),r.minimum_amount&&parseFloat(r.minimum_amount.amount)>0&&o("div",{class:"s-cart-coupons-minimum"},salla.lang.get("pages.cart.minimum")," ",o("span",{innerHTML:salla.money(r.minimum_amount.amount,r.minimum_amount.currency)}))),o("div",{class:"s-cart-coupons-action"},a?this.renderAppliedAction(s):i?salla.lang.get("pages.cart.save_coupon"):salla.lang.get("pages.cart.coupon_not_compatible")))))}renderAppliedAction(t){return[o("span",{class:"s-cart-coupons-card-applied-label"},salla.lang.get("pages.cart.coupon_applied")),o("button",{type:"button",class:"s-cart-coupons-card-remove","aria-label":`${salla.lang.get("pages.cart.delete_coupon")} ${t}`,disabled:this.isApplying,onClick:o=>{o.stopPropagation(),this.removeCoupon(t)}},salla.lang.get("pages.cart.cancel"))]}renderMinimalCard(t){return o("div",{class:"s-cart-coupons-slide-one-fourth swiper-slide"},o("div",{class:"s-cart-coupons-card s-cart-coupons-card--applied s-cart-coupons-card--minimal"},o("div",{class:"s-cart-coupons-top-section"},o("div",{class:"s-cart-coupons-code s-cart-coupons-code--only"},t)),o("div",{class:"s-cart-coupons-divider"}),o("div",{class:"s-cart-coupons-bottom-section"},o("div",{class:"s-cart-coupons-action"},this.renderAppliedAction(t)))))}couponRow(){return this.multiCoupon?this.mergedCoupons:(this.availableCoupons||[]).map((t=>({code:t.code,coupon:t,applied:!1})))}render(){const t=this.couponRow();return o(r,{key:"79d820f5931ca33571e6897f4e5a09413e02cf96"},o("div",{key:"7c55aa93e8f4bc44c76606e1af4cb593cab0e7b2",class:"s-cart-coupons-wrapper"},o("div",{key:"7deee9dc280b91008c9f29eab2c7dbb42fb4d586",class:"s-cart-coupons-input-section"},o("label",{key:"f4362e77c3031c8bdacdbd0bd126f7df3c973583",htmlFor:"coupon-input",class:"s-cart-coupons-coupon-label"},salla.lang.get("pages.cart.have_coupon")),o("div",{key:"631dce1aeb71c6bfc80d00869c0974ffedb3f932",class:"s-cart-coupons-coupon-input-container"},this.multiCoupon?[o("input",{type:"text",id:"coupon-input",name:"coupon",class:"form-input "+(this.couponError?"s-coupon-input-error":""),placeholder:salla.lang.get("pages.cart.coupon_placeholder"),value:this.couponInputValue,disabled:this.isApplying,onInput:this.onInput,onKeyUp:this.onKeyUp,"aria-label":salla.lang.get("pages.cart.apply_coupon"),key:"coupon-input"}),o("salla-button",{ref:t=>this.couponButtonRef=t,class:"s-cart-coupons-coupon-button s-cart-coupons-coupon-button-apply",color:"primary",loading:this.isApplying,"loader-position":"center",onClick:()=>this.handleApplyClick(),key:"apply-button"},o("span",null,salla.lang.get("pages.cart.save_coupon")))]:[o("input",{type:"text",id:"coupon-input",name:"coupon",class:"form-input "+(this.couponError?"s-coupon-input-error":""),placeholder:salla.lang.get("pages.cart.coupon_placeholder"),value:this.couponInputValue,disabled:!!this.currentCoupon||this.isApplying,onInput:this.onInput,onKeyUp:this.onKeyUp,"aria-label":salla.lang.get("pages.cart.apply_coupon"),key:"coupon-input"}),o("salla-button",{ref:t=>this.couponButtonRef=t,class:"s-cart-coupons-coupon-button "+(this.currentCoupon?"s-cart-coupons-coupon-button-remove":"s-cart-coupons-coupon-button-apply"),color:this.currentCoupon?"danger":"primary",loading:this.isApplying,"loader-position":"center",onClick:()=>this.handleCouponButtonClick(),key:"apply-button"},this.currentCoupon?o("i",{class:"sicon-cancel"}):o("span",null,salla.lang.get("pages.cart.save_coupon")))]),this.couponError&&o("span",{key:"9713718d67c8c4ff4daeffc47572ac3cabea6905",class:"s-cart-coupons-coupon-error"},this.couponError)),t.length>0&&o("salla-slider",{type:"carousel",showControls:!1,class:"s-cart-coupons-slider",key:t.map((t=>t.code)).join("|")},o("div",{key:"4b96603ef79b45b312a87755850b3c81cc51deea",slot:"items"},t.map((t=>this.renderCouponCard(t)))))))}get host(){return a(this)}};s.style='/*!twlt*/@charset "UTF-8";.s-cart-coupons-card--applied{cursor:default}.s-cart-coupons-card--applied:hover{transform:none}.s-cart-coupons-card--applied .s-cart-coupons-top-section,.s-cart-coupons-card--applied .s-cart-coupons-bottom-section,.s-cart-coupons-card--applied .s-cart-coupons-divider{border-color:#d1d5db;border-color:color-mix(in srgb, var(--color-primary, #004d5a) 40%, transparent)}.s-cart-coupons-card--applied .s-cart-coupons-bottom-section{background:rgba(0, 0, 0, 0.04);background:color-mix(in srgb, var(--color-primary, #004d5a) 8%, transparent)}.s-cart-coupons-card--applied::before,.s-cart-coupons-card--applied::after{border-color:#d1d5db;border-color:color-mix(in srgb, var(--color-primary, #004d5a) 40%, transparent)}.s-cart-coupons-card--applied .s-cart-coupons-action{display:inline-flex;align-items:center;gap:10px}.s-cart-coupons-card--applied .s-cart-coupons-action{font-size:10px;font-weight:600;color:#4b5563}.s-cart-coupons-card-applied-label{color:#4b5563;color:var(--color-primary-dark, var(--color-primary, #4b5563))}.s-cart-coupons-card--applied .s-cart-coupons-action{min-width:0;max-width:100%}.s-cart-coupons-card-applied-label,.s-cart-coupons-card-remove{overflow:hidden;text-overflow:ellipsis}.s-cart-coupons-card--applied .s-cart-coupons-action,.s-cart-coupons-card--applied .s-cart-coupons-card-remove{pointer-events:auto}.s-cart-coupons-card-remove{flex:none;font-size:inherit;font-weight:inherit;color:#6b7280;background:transparent;border:0;padding:0;cursor:pointer;transition:color 0.15s ease}.s-cart-coupons-card-remove:hover{color:var(--color-danger, #ef4444)}.s-cart-coupons-card-remove:disabled{opacity:0.5;cursor:not-allowed}.s-cart-coupons-card--minimal .s-cart-coupons-bottom-section{justify-content:flex-end}.visible{visibility:visible}.fixed{position:fixed}.shrink{flex-shrink:1}.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)}.form-input{height:2.5rem;width:100%;border-radius:0.375rem;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-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}.form-input:focus{border-color:var(--color-primary);--tw-ring-color:transparent}.form-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))}.form-input:focus:is(.dark *){border-color:var(--color-primary)}@media (min-width: 640px){.form-input{font-size:0.875rem;line-height:1.25rem}}.s-cart-coupons-wrapper{display:block;width:100%;padding-top:1.25rem;padding-bottom:1.25rem}.s-cart-coupons-input-section{margin-bottom:0.625rem}.s-cart-coupons-coupon-label{margin-bottom:0.625rem;display:block;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-cart-coupons-coupon-input-container{position:relative;display:flex;align-items:stretch}.s-cart-coupons-coupon-input-container .form-input{height:auto;flex:1 1 0%}.s-cart-coupons-coupon-input-container .form-input:where([dir="ltr"],[dir="ltr"] *){border-top-left-radius:0.5rem;border-bottom-left-radius:0.5rem;border-top-right-radius:0px !important;border-bottom-right-radius:0px !important;border-right-width:0px}.s-cart-coupons-coupon-input-container .form-input:where([dir="rtl"],[dir="rtl"] *){border-top-right-radius:0.5rem;border-bottom-right-radius:0.5rem;border-top-left-radius:0px !important;border-bottom-left-radius:0px !important;border-left-width:0px}.s-cart-coupons-coupon-input-container .form-input:focus{position:relative;z-index:10}.s-cart-coupons-coupon-button:where([dir="ltr"],[dir="ltr"] *){border-top-right-radius:0.5rem;border-bottom-right-radius:0.5rem;border-top-left-radius:0px;border-bottom-left-radius:0px}.s-cart-coupons-coupon-button:where([dir="rtl"],[dir="rtl"] *){border-top-left-radius:0.5rem;border-bottom-left-radius:0.5rem;border-top-right-radius:0px;border-bottom-right-radius:0px}.s-cart-coupons-coupon-button-remove:where([dir="ltr"],[dir="ltr"] *){border-top-right-radius:0.5rem;border-bottom-right-radius:0.5rem;border-top-left-radius:0px !important;border-bottom-left-radius:0px !important}.s-cart-coupons-coupon-button-remove:where([dir="rtl"],[dir="rtl"] *){border-top-left-radius:0.5rem;border-bottom-left-radius:0.5rem;border-top-right-radius:0px !important;border-bottom-right-radius:0px !important}.s-cart-coupons-coupon-button-apply:where([dir="ltr"],[dir="ltr"] *){border-top-right-radius:0.5rem !important;border-bottom-right-radius:0.5rem !important;border-top-left-radius:0px !important;border-bottom-left-radius:0px !important}.s-cart-coupons-coupon-button-apply:where([dir="rtl"],[dir="rtl"] *){border-top-left-radius:0.5rem !important;border-bottom-left-radius:0.5rem !important;border-top-right-radius:0px !important;border-bottom-right-radius:0px !important}.s-cart-coupons-coupon-error{margin-top:0.5rem;display:block;font-size:10px;line-height:1rem;--tw-text-opacity:1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.s-cart-coupons-slider{width:100%;overflow:hidden;padding-left:0.375rem;padding-right:0.375rem}.s-cart-coupons-card{position:relative;cursor:pointer;overflow:hidden;--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-cart-coupons-card:is(.dark *){--tw-bg-opacity:1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.s-cart-coupons-card:hover{--tw-translate-y:-0.125rem;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-cart-coupons-disabled{cursor:not-allowed;opacity:0.5}.s-cart-coupons-disabled:hover{transform:none;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.s-cart-coupons-top-section{display:flex;height:60px;flex-direction:row;align-items:center;justify-content:space-between;border-top-left-radius:0.75rem;border-top-right-radius:0.75rem;border-width:1px;border-bottom-width:0px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));padding-top:1rem;padding-bottom:1rem;padding-left:0.75rem;padding-right:0.75rem}.s-cart-coupons-discount-values{display:flex;flex-direction:column;align-items:flex-start}.s-cart-coupons-discount-values .s-cart-coupons-main-amount{display:flex;align-items:center;gap:0.25rem;white-space:nowrap;font-size:1.25rem;line-height:1.75rem;font-weight:900;line-height:1;--tw-text-opacity:1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.s-cart-coupons-discount-values .s-cart-coupons-secondary-info{margin:0px;font-size:10px;line-height:1rem}.s-cart-coupons-code{font-size:10px;font-weight:700;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-cart-coupons-divider{position:relative;z-index:10;margin:0px;border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.s-cart-coupons-bottom-section{display:flex;min-height:44px;flex-direction:row;align-items:center;justify-content:space-between;border-bottom-right-radius:0.75rem;border-bottom-left-radius:0.75rem;border-width:1px;border-top-width:0px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding-top:0.25rem;padding-bottom:0.25rem;padding-left:0.75rem;padding-right:0.75rem}.s-cart-coupons-terms{display:flex;flex-direction:column;align-items:flex-start}.s-cart-coupons-terms .s-cart-coupons-expiry{margin:0px;font-size:10px;line-height:16px;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-cart-coupons-terms .s-cart-coupons-minimum{margin:0px;font-size:10px;line-height:16px;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-cart-coupons-terms .s-cart-coupons-expiry.s-cart-coupons-expiry-warning{font-weight:500;--tw-text-opacity:1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.s-cart-coupons-action{cursor:pointer;white-space:nowrap;border-width:0px;background-color:transparent;padding:0px;font-size:9px;font-weight:700;--tw-text-opacity:1;color:rgb(17 24 39 / 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:150ms}.s-cart-coupons-action:hover{--tw-text-opacity:1;color:rgb(59 130 246 / var(--tw-text-opacity, 1))}.s-cart-coupons-slide-one-fourth{width:calc(75% - 10px);min-width:200px !important;padding-left:5px !important;padding-right:5px !important;padding-top:2px !important}@media (min-width: 1024px){.s-cart-coupons-slide-one-fourth{width:calc(40% - 10px) !important}}.s-cart-coupons-card:before{pointer-events:none;position:absolute;right:-10px;top:60px;z-index:20;height:1.25rem;width:1.25rem;--tw-translate-y:-50%;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));border-radius:9999px;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));--tw-content:\'\';content:var(--tw-content)}.s-cart-coupons-card:is(.dark *):before{--tw-bg-opacity:1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.s-cart-coupons-card:after{pointer-events:none;position:absolute;left:-10px;top:60px;z-index:20;height:1.25rem;width:1.25rem;--tw-translate-y:-50%;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));border-radius:9999px;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));--tw-content:\'\';content:var(--tw-content)}.s-cart-coupons-card:is(.dark *):after{--tw-bg-opacity:1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.s-cart-coupons-coupon-input-container .form-input.s-coupon-input-error{--tw-shadow:0 0 0 3px rgba(239,68,68,0.1) !important;--tw-shadow-colored:0 0 0 3px var(--tw-shadow-color) !important;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important}';export{s as salla_cart_coupons}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r,h as e,H as n,F as t}from"./p-0Tl_yZW8.js";function i(r,e){if("string"!=typeof r)return r??e;const n=r.trim();if(!n)return e;try{return JSON.parse(n)}catch{return e}}function o(r){if(r)return"string"==typeof r?i(r,void 0):r}function a(r,e="ar"){const[n,t]=String(r).trim().split(":").map(Number);if(!Number.isFinite(n)||!Number.isFinite(t))return r;const i=new Date(2e3,0,1,n,t),o={hour:"numeric",minute:"2-digit",hour12:!0};try{return i.toLocaleTimeString(e,o)}catch{return i.toLocaleTimeString("ar",o)}}const s=class{constructor(e){r(this,e),this.stackCards=!1,this.isLoading=!1}componentWillLoad(){return this.getBranchData()}async getBranchData(){const r=salla.config.get("page.id");if(r){this.isLoading=!0;try{const e=await salla.order.api.getBranchDetails(r);this.branchData=this.parseBranchResponse(e)}catch(r){this.notifyApiError(r)}finally{this.isLoading=!1}}}parseBranchResponse(r){const e=r?.data?.data||r?.data||r;return e&&"object"==typeof e&&Object.prototype.hasOwnProperty.call(e,"branch")?e.branch?o(e.branch):void 0:o(e)}getApiErrorMessage(r){return r?.response?.data?.error?.message||r?.response?.data?.message}notifyApiError(r){const e=this.getApiErrorMessage(r);e&&salla.notify.error(e)}label(r,e){return salla.lang.getWithDefault(r,e)}get preparationText(){const r=this.branchData?.preparation_time_range;if(!r?.from||!r?.to)return"";const e=salla.helpers.number(r.from.value),n=salla.helpers.number(r.to.value),t=this.unitLabel(r.to.unit),i=e===n?e:`⁦${e}-${n}⁩`;return this.label("pages.orders.pickup_ready_after","جاهز للاستلام بعد :time").replace(":time",`${i} ${t}`)}unitLabel(r){const e=function(r){const e=String(r||"hour").toLowerCase();return e.startsWith("min")?"minute":e.startsWith("day")?"day":"hour"}(r);return"minute"===e?this.label("pages.checkout.minute","دقيقة"):"day"===e?this.label("pages.checkout.day","يوم"):this.label("pages.checkout.hour","ساعة")}get workingHoursItems(){const r=this.branchData;if(!r)return[];if(!0===r.always_open||1===r.always_open||"1"===r.always_open)return[this.label("pages.orders.branch_always_open","مفتوح على مدار الساعة")];const e=salla.lang.locale||"ar";return(r.working_hours||[]).filter((r=>r?.name&&r.times?.length)).map((r=>{const n=r.times[0];return`${r.name}: ${a(n.from,e)} - ${a(n.to,e)}`}))}get branchAddress(){return this.branchData?.address||""}get mapUrl(){const r=this.branchData?.location;if(null!=r?.lat&&null!=r?.lng)return`https://www.google.com/maps?q=${r.lat},${r.lng}`}get phone(){return function(r){const e=i(r,null),n=e&&"object"==typeof e?e.phone:"";return"string"==typeof n?n.trim():""}(this.branchData?.contacts)}renderDetailsColumn(){const r=this.phone;return r?e("div",{class:"s-order-branch-details"},e("div",{class:"s-order-branch-info-card"},e("span",{class:"s-order-branch-info-icon",innerHTML:'\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>phone-talking</title>\n<path d="M18.667 8c2.941 0 5.333 2.392 5.333 5.333 0 0.737 0.596 1.333 1.333 1.333s1.333-0.596 1.333-1.333c0-4.412-3.588-8-8-8-0.737 0-1.333 0.596-1.333 1.333s0.596 1.333 1.333 1.333zM18.667 2.667c5.881 0 10.667 4.785 10.667 10.667 0 0.737 0.596 1.333 1.333 1.333s1.333-0.596 1.333-1.333c0-7.352-5.981-13.333-13.333-13.333-0.737 0-1.333 0.596-1.333 1.333s0.596 1.333 1.333 1.333zM26.939 17.831c-1.568-1.568-4.119-1.568-5.689 0l-2.567 2.568c-3.064-1.499-5.584-4.019-7.083-7.083l2.569-2.567c1.567-1.569 1.567-4.121-0.001-5.689l-3.88-3.881c-1.521-1.521-4.169-1.521-5.691 0l-1.847 1.847c-2.22 2.22-3.183 5.408-2.573 8.527 1.979 10.144 10.127 18.292 20.271 20.271 0.617 0.121 1.236 0.18 1.851 0.18 2.491 0 4.895-0.972 6.676-2.752l1.847-1.847c1.569-1.569 1.569-4.12 0-5.689zM28.936 25.517l-1.847 1.847c-1.591 1.591-3.876 2.281-6.131 1.841-9.089-1.776-16.388-9.075-18.163-18.165-0.439-2.247 0.249-4.539 1.841-6.129l1.847-1.847c0.256-0.257 0.597-0.397 0.959-0.397s0.701 0.14 0.959 0.397l3.883 3.883c0.528 0.528 0.528 1.389 0 1.917l-3.22 3.219c-0.383 0.384-0.496 0.959-0.288 1.457 1.815 4.34 5.344 7.868 9.684 9.684 0.5 0.205 1.075 0.095 1.457-0.288l3.219-3.219c0.528-0.531 1.389-0.529 1.917-0.001l3.883 3.883c0.529 0.529 0.529 1.389 0 1.919z"></path>\n</svg>\n'}),e("div",{class:"s-order-branch-info-text"},e("span",{class:"s-order-branch-info-label"},this.label("pages.orders.branch_contacts","ارقام التواصل")),e("span",{class:"s-order-branch-info-value",dir:"ltr"},r)))):null}renderWorkingHoursCard(){const r=this.workingHoursItems;return r.length?e("div",{class:"s-order-branch-info-card s-order-branch-hours-card"},e("span",{class:"s-order-branch-info-icon","aria-hidden":"true"},e("i",{class:"sicon-calendar-alt"})),e("div",{class:"s-order-branch-info-text"},e("span",{class:"s-order-branch-info-label"},this.label("pages.checkout.working_hours","ساعات العمل")),e("div",{class:"s-order-branch-hours-list"},r.map((r=>e("span",{class:"s-order-branch-hours-item"},r)))))):null}renderBranchIdentityCard(){const r=this.branchData,n=this.branchAddress,t=this.preparationText;return e("section",{class:"s-order-branch-card"},e("div",{class:"s-order-branch-location"},e("div",{class:"s-order-branch-identity"},e("span",{class:"s-order-branch-store-icon"},e("i",{class:"sicon-store","aria-hidden":"true"})),e("div",{class:"s-order-branch-text"},e("div",{class:"s-order-branch-name-row"},r?.name?e("span",{class:"s-order-branch-name"},r.name):null,t?e("span",{class:"s-order-branch-ready"},t):null),n?e("span",{class:"s-order-branch-address"},n):null)),this.mapUrl?e("div",{class:"s-order-branch-actions"},e("a",{href:this.mapUrl,target:"_blank",rel:"noopener noreferrer",class:"s-order-branch-map-link"},e("span",null,this.label("pages.orders.branch_map","موقع الفرع علي الخريطة")),e("span",{class:"s-order-branch-action-icon",innerHTML:'<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M6.95448 2.79419C9.7395 1.84477 11.132 1.37005 11.881 2.11902C12.6299 2.86799 12.1552 4.2605 11.2058 7.04551L10.5593 8.94203C9.83014 11.0809 9.46556 12.1503 8.8646 12.2388C8.70303 12.2626 8.53577 12.2483 8.37592 12.197C7.78135 12.0061 7.46705 10.8785 6.83846 8.62339C6.69903 8.12319 6.62932 7.87308 6.47057 7.68206C6.4245 7.62662 6.37338 7.5755 6.31794 7.52943C6.12692 7.37068 5.87681 7.30097 5.37661 7.16154C3.12148 6.53295 1.99391 6.21865 1.80302 5.62408C1.7517 5.46423 1.73738 5.29698 1.76117 5.1354C1.84968 4.53444 2.91911 4.16986 5.05797 3.44072L6.95448 2.79419Z" stroke="currentColor" stroke-width="1.5"/>\n</svg>\n'}))):null))}render(){return this.isLoading||!this.branchData?e(n,{class:"s-order-branch-wrapper"}):e(n,{class:"s-order-branch-wrapper"},this.stackCards?e(t,null,this.renderBranchIdentityCard(),this.renderDetailsColumn()):e("div",{class:"s-order-branch-container"},this.renderBranchIdentityCard(),this.renderDetailsColumn()),this.renderWorkingHoursCard())}};s.style="/*!twlt*/:host{display:block}.s-order-branch-ready{background-color:color-mix(in srgb, var(--color-primary) 30%, transparent)}.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-order-branch-wrapper{margin-bottom:1.5rem;display:flex;flex-direction:column;gap:1rem;font-family:inherit}.s-order-branch-container{display:grid;grid-template-columns:repeat(1, minmax(0, 1fr));align-items:stretch;gap:1rem}@media (min-width: 768px){.s-order-branch-container{grid-template-columns:repeat(2, minmax(0, 1fr))}}.s-order-branch-details{display:grid;align-content:stretch;gap:1rem}.s-order-branch-info-card{display:flex;min-height:68px;align-items:center;justify-content:space-between;gap:0.75rem;border-radius:0.5rem;border-width:1px;border-color:var(--color-border,#eee);background-color:var(--color-surface,#fff);padding:0.75rem}.s-order-branch-info-text{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:3px;text-align:start}.s-order-branch-info-label{font-size:0.75rem;line-height:1rem;line-height:1.35;color:var(--color-text-secondary,#666)}.s-order-branch-info-value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:0.875rem;line-height:1.25rem;font-weight:500;line-height:1.45;color:var(--color-text-primary,#1d1d1d)}.s-order-branch-hours-card .s-order-branch-info-text{gap:0.5rem}.s-order-branch-hours-list{display:flex;flex-wrap:wrap;align-items:center;gap:0.5rem}.s-order-branch-hours-item{display:inline-flex;align-items:center;white-space:nowrap;border-radius:0.375rem;border-width:1px;border-color:var(--color-border,#eee);padding-left:0.625rem;padding-right:0.625rem;padding-top:0.25rem;padding-bottom:0.25rem;font-size:0.75rem;line-height:1rem;font-weight:500;line-height:1.45;color:var(--color-text-primary,#1d1d1d)}.s-order-branch-info-action{display:inline-flex;height:3rem;width:3rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:0.5rem;background-color:var(--color-surface-secondary,#f6f6f6);color:var(--color-text-primary,#2b2d34);text-decoration-line:none}.s-order-branch-info-icon{display:inline-flex;height:3rem;width:3rem;align-items:center;justify-content:center;border-radius:0.375rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));font-size:22px;color:currentColor}.s-order-branch-info-icon svg{height:1.5rem;width:1.5rem;fill:currentColor}.s-order-branch-card{display:flex;flex-direction:column;gap:0.75rem;border-radius:0.5rem;border-width:1px;border-color:var(--color-border,#eee);background-color:var(--color-surface,#fff);padding:1rem}@media (min-width: 768px){.s-order-branch-card{padding:1.25rem}}.s-order-branch-ready{display:inline-flex;flex-shrink:0;align-items:center;white-space:nowrap;border-radius:9999px;border-width:1px;border-color:var(--color-primary,#236e4c);padding-left:0.75rem;padding-right:0.75rem;padding-top:0.25rem;padding-bottom:0.25rem;font-size:0.75rem;line-height:1rem;font-weight:500;color:var(--color-primary-dark,#0c2519)}.s-order-branch-location{display:flex;min-height:52px;flex-direction:column;align-items:stretch;justify-content:space-between;gap:1.5rem}@media (min-width: 768px){.s-order-branch-location{flex-direction:row;align-items:center}}.s-order-branch-identity{display:flex;min-width:0px;flex:1 1 0%;align-items:center;gap:0.75rem}.s-order-branch-store-icon{display:inline-flex;height:3rem;width:3rem;flex-shrink:0;align-items:center;justify-content:center;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));font-size:1.5rem;line-height:2rem;color:var(--color-text-primary,#2b2d34)}.s-order-branch-store-icon svg{height:1em;width:1em;fill:currentColor}.s-order-branch-text{display:flex;min-width:0px;flex-direction:column;gap:0.25rem;text-align:start}.s-order-branch-name-row{display:flex;flex-wrap:wrap;align-items:center;gap:0.5rem}.s-order-branch-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:1rem;line-height:1.5rem;font-weight:500;line-height:1.45;color:var(--color-text-primary,#2b2d34)}.s-order-branch-address{overflow-wrap:break-word;font-size:0.75rem;line-height:1rem;line-height:1.45;color:var(--color-text-secondary,#666)}.s-order-branch-actions{display:flex;flex-shrink:0;flex-wrap:wrap;align-items:center;gap:0.75rem}@media (min-width: 768px){.s-order-branch-actions{flex-wrap:nowrap}}.s-order-branch-map-link{display:inline-flex;min-height:2.25rem;align-items:center;justify-content:center;gap:0.5rem;white-space:nowrap;border-radius:0.375rem;border-width:1px;border-color:var(--color-primary,#236e4c);padding-left:0.875rem;padding-right:0.875rem;padding-top:0.5rem;padding-bottom:0.5rem;font-size:0.875rem;line-height:1.25rem;font-weight:700;line-height:1.2;color:var(--color-primary,#236e4c);text-decoration-line:none}.s-order-branch-action-icon{display:inline-flex;align-items:center;justify-content:center;font-size:0.875rem;line-height:1.25rem;color:currentColor}.s-order-branch-action-icon svg{height:1em;width:1em}";export{s as salla_order_branch}
4
+ import{r,h as e,H as n,F as t}from"./p-HRJpfiBN.js";function i(r,e){if("string"!=typeof r)return r??e;const n=r.trim();if(!n)return e;try{return JSON.parse(n)}catch{return e}}function o(r){if(r)return"string"==typeof r?i(r,void 0):r}function a(r,e="ar"){const[n,t]=String(r).trim().split(":").map(Number);if(!Number.isFinite(n)||!Number.isFinite(t))return r;const i=new Date(2e3,0,1,n,t),o={hour:"numeric",minute:"2-digit",hour12:!0};try{return i.toLocaleTimeString(e,o)}catch{return i.toLocaleTimeString("ar",o)}}const s=class{constructor(e){r(this,e),this.stackCards=!1,this.isLoading=!1}componentWillLoad(){return this.getBranchData()}async getBranchData(){const r=salla.config.get("page.id");if(r){this.isLoading=!0;try{const e=await salla.order.api.getBranchDetails(r);this.branchData=this.parseBranchResponse(e)}catch(r){this.notifyApiError(r)}finally{this.isLoading=!1}}}parseBranchResponse(r){const e=r?.data?.data||r?.data||r;return e&&"object"==typeof e&&Object.prototype.hasOwnProperty.call(e,"branch")?e.branch?o(e.branch):void 0:o(e)}getApiErrorMessage(r){return r?.response?.data?.error?.message||r?.response?.data?.message}notifyApiError(r){const e=this.getApiErrorMessage(r);e&&salla.notify.error(e)}label(r,e){return salla.lang.getWithDefault(r,e)}get preparationText(){const r=this.branchData?.preparation_time_range;if(!r?.from||!r?.to)return"";const e=salla.helpers.number(r.from.value),n=salla.helpers.number(r.to.value),t=this.unitLabel(r.to.unit),i=e===n?e:`⁦${e}-${n}⁩`;return this.label("pages.orders.pickup_ready_after","جاهز للاستلام بعد :time").replace(":time",`${i} ${t}`)}unitLabel(r){const e=function(r){const e=String(r||"hour").toLowerCase();return e.startsWith("min")?"minute":e.startsWith("day")?"day":"hour"}(r);return"minute"===e?this.label("pages.checkout.minute","دقيقة"):"day"===e?this.label("pages.checkout.day","يوم"):this.label("pages.checkout.hour","ساعة")}get workingHoursItems(){const r=this.branchData;if(!r)return[];if(!0===r.always_open||1===r.always_open||"1"===r.always_open)return[this.label("pages.orders.branch_always_open","مفتوح على مدار الساعة")];const e=salla.lang.locale||"ar";return(r.working_hours||[]).filter((r=>r?.name&&r.times?.length)).map((r=>{const n=r.times[0];return`${r.name}: ${a(n.from,e)} - ${a(n.to,e)}`}))}get branchAddress(){return this.branchData?.address||""}get mapUrl(){const r=this.branchData?.location;if(null!=r?.lat&&null!=r?.lng)return`https://www.google.com/maps?q=${r.lat},${r.lng}`}get phone(){return function(r){const e=i(r,null),n=e&&"object"==typeof e?e.phone:"";return"string"==typeof n?n.trim():""}(this.branchData?.contacts)}renderDetailsColumn(){const r=this.phone;return r?e("div",{class:"s-order-branch-details"},e("div",{class:"s-order-branch-info-card"},e("span",{class:"s-order-branch-info-icon",innerHTML:'\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>phone-talking</title>\n<path d="M18.667 8c2.941 0 5.333 2.392 5.333 5.333 0 0.737 0.596 1.333 1.333 1.333s1.333-0.596 1.333-1.333c0-4.412-3.588-8-8-8-0.737 0-1.333 0.596-1.333 1.333s0.596 1.333 1.333 1.333zM18.667 2.667c5.881 0 10.667 4.785 10.667 10.667 0 0.737 0.596 1.333 1.333 1.333s1.333-0.596 1.333-1.333c0-7.352-5.981-13.333-13.333-13.333-0.737 0-1.333 0.596-1.333 1.333s0.596 1.333 1.333 1.333zM26.939 17.831c-1.568-1.568-4.119-1.568-5.689 0l-2.567 2.568c-3.064-1.499-5.584-4.019-7.083-7.083l2.569-2.567c1.567-1.569 1.567-4.121-0.001-5.689l-3.88-3.881c-1.521-1.521-4.169-1.521-5.691 0l-1.847 1.847c-2.22 2.22-3.183 5.408-2.573 8.527 1.979 10.144 10.127 18.292 20.271 20.271 0.617 0.121 1.236 0.18 1.851 0.18 2.491 0 4.895-0.972 6.676-2.752l1.847-1.847c1.569-1.569 1.569-4.12 0-5.689zM28.936 25.517l-1.847 1.847c-1.591 1.591-3.876 2.281-6.131 1.841-9.089-1.776-16.388-9.075-18.163-18.165-0.439-2.247 0.249-4.539 1.841-6.129l1.847-1.847c0.256-0.257 0.597-0.397 0.959-0.397s0.701 0.14 0.959 0.397l3.883 3.883c0.528 0.528 0.528 1.389 0 1.917l-3.22 3.219c-0.383 0.384-0.496 0.959-0.288 1.457 1.815 4.34 5.344 7.868 9.684 9.684 0.5 0.205 1.075 0.095 1.457-0.288l3.219-3.219c0.528-0.531 1.389-0.529 1.917-0.001l3.883 3.883c0.529 0.529 0.529 1.389 0 1.919z"></path>\n</svg>\n'}),e("div",{class:"s-order-branch-info-text"},e("span",{class:"s-order-branch-info-label"},this.label("pages.orders.branch_contacts","ارقام التواصل")),e("span",{class:"s-order-branch-info-value",dir:"ltr"},r)))):null}renderWorkingHoursCard(){const r=this.workingHoursItems;return r.length?e("div",{class:"s-order-branch-info-card s-order-branch-hours-card"},e("span",{class:"s-order-branch-info-icon","aria-hidden":"true"},e("i",{class:"sicon-calendar-alt"})),e("div",{class:"s-order-branch-info-text"},e("span",{class:"s-order-branch-info-label"},this.label("pages.checkout.working_hours","ساعات العمل")),e("div",{class:"s-order-branch-hours-list"},r.map((r=>e("span",{class:"s-order-branch-hours-item"},r)))))):null}renderBranchIdentityCard(){const r=this.branchData,n=this.branchAddress,t=this.preparationText;return e("section",{class:"s-order-branch-card"},e("div",{class:"s-order-branch-location"},e("div",{class:"s-order-branch-identity"},e("span",{class:"s-order-branch-store-icon"},e("i",{class:"sicon-store","aria-hidden":"true"})),e("div",{class:"s-order-branch-text"},e("div",{class:"s-order-branch-name-row"},r?.name?e("span",{class:"s-order-branch-name"},r.name):null,t?e("span",{class:"s-order-branch-ready"},t):null),n?e("span",{class:"s-order-branch-address"},n):null)),this.mapUrl?e("div",{class:"s-order-branch-actions"},e("a",{href:this.mapUrl,target:"_blank",rel:"noopener noreferrer",class:"s-order-branch-map-link"},e("span",null,this.label("pages.orders.branch_map","موقع الفرع علي الخريطة")),e("span",{class:"s-order-branch-action-icon",innerHTML:'<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M6.95448 2.79419C9.7395 1.84477 11.132 1.37005 11.881 2.11902C12.6299 2.86799 12.1552 4.2605 11.2058 7.04551L10.5593 8.94203C9.83014 11.0809 9.46556 12.1503 8.8646 12.2388C8.70303 12.2626 8.53577 12.2483 8.37592 12.197C7.78135 12.0061 7.46705 10.8785 6.83846 8.62339C6.69903 8.12319 6.62932 7.87308 6.47057 7.68206C6.4245 7.62662 6.37338 7.5755 6.31794 7.52943C6.12692 7.37068 5.87681 7.30097 5.37661 7.16154C3.12148 6.53295 1.99391 6.21865 1.80302 5.62408C1.7517 5.46423 1.73738 5.29698 1.76117 5.1354C1.84968 4.53444 2.91911 4.16986 5.05797 3.44072L6.95448 2.79419Z" stroke="currentColor" stroke-width="1.5"/>\n</svg>\n'}))):null))}render(){return this.isLoading||!this.branchData?e(n,{class:"s-order-branch-wrapper"}):e(n,{class:"s-order-branch-wrapper"},this.stackCards?e(t,null,this.renderBranchIdentityCard(),this.renderDetailsColumn()):e("div",{class:"s-order-branch-container"},this.renderBranchIdentityCard(),this.renderDetailsColumn()),this.renderWorkingHoursCard())}};s.style="/*!twlt*/:host{display:block}.s-order-branch-ready{background-color:color-mix(in srgb, var(--color-primary) 30%, transparent)}.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-order-branch-wrapper{margin-bottom:1.5rem;display:flex;flex-direction:column;gap:1rem;font-family:inherit}.s-order-branch-container{display:grid;grid-template-columns:repeat(1, minmax(0, 1fr));align-items:stretch;gap:1rem}@media (min-width: 768px){.s-order-branch-container{grid-template-columns:repeat(2, minmax(0, 1fr))}}.s-order-branch-details{display:grid;align-content:stretch;gap:1rem}.s-order-branch-info-card{display:flex;min-height:68px;align-items:center;justify-content:space-between;gap:0.75rem;border-radius:0.5rem;border-width:1px;border-color:var(--color-border,#eee);background-color:var(--color-surface,#fff);padding:0.75rem}.s-order-branch-info-text{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:3px;text-align:start}.s-order-branch-info-label{font-size:0.75rem;line-height:1rem;line-height:1.35;color:var(--color-text-secondary,#666)}.s-order-branch-info-value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:0.875rem;line-height:1.25rem;font-weight:500;line-height:1.45;color:var(--color-text-primary,#1d1d1d)}.s-order-branch-hours-card .s-order-branch-info-text{gap:0.5rem}.s-order-branch-hours-list{display:flex;flex-wrap:wrap;align-items:center;gap:0.5rem}.s-order-branch-hours-item{display:inline-flex;align-items:center;white-space:nowrap;border-radius:0.375rem;border-width:1px;border-color:var(--color-border,#eee);padding-left:0.625rem;padding-right:0.625rem;padding-top:0.25rem;padding-bottom:0.25rem;font-size:0.75rem;line-height:1rem;font-weight:500;line-height:1.45;color:var(--color-text-primary,#1d1d1d)}.s-order-branch-info-action{display:inline-flex;height:3rem;width:3rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:0.5rem;background-color:var(--color-surface-secondary,#f6f6f6);color:var(--color-text-primary,#2b2d34);text-decoration-line:none}.s-order-branch-info-icon{display:inline-flex;height:3rem;width:3rem;align-items:center;justify-content:center;border-radius:0.375rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));font-size:22px;color:currentColor}.s-order-branch-info-icon svg{height:1.5rem;width:1.5rem;fill:currentColor}.s-order-branch-card{display:flex;flex-direction:column;gap:0.75rem;border-radius:0.5rem;border-width:1px;border-color:var(--color-border,#eee);background-color:var(--color-surface,#fff);padding:1rem}@media (min-width: 768px){.s-order-branch-card{padding:1.25rem}}.s-order-branch-ready{display:inline-flex;flex-shrink:0;align-items:center;white-space:nowrap;border-radius:9999px;border-width:1px;border-color:var(--color-primary,#236e4c);padding-left:0.75rem;padding-right:0.75rem;padding-top:0.25rem;padding-bottom:0.25rem;font-size:0.75rem;line-height:1rem;font-weight:500;color:var(--color-primary-dark,#0c2519)}.s-order-branch-location{display:flex;min-height:52px;flex-direction:column;align-items:stretch;justify-content:space-between;gap:1.5rem}@media (min-width: 768px){.s-order-branch-location{flex-direction:row;align-items:center}}.s-order-branch-identity{display:flex;min-width:0px;flex:1 1 0%;align-items:center;gap:0.75rem}.s-order-branch-store-icon{display:inline-flex;height:3rem;width:3rem;flex-shrink:0;align-items:center;justify-content:center;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));font-size:1.5rem;line-height:2rem;color:var(--color-text-primary,#2b2d34)}.s-order-branch-store-icon svg{height:1em;width:1em;fill:currentColor}.s-order-branch-text{display:flex;min-width:0px;flex-direction:column;gap:0.25rem;text-align:start}.s-order-branch-name-row{display:flex;flex-wrap:wrap;align-items:center;gap:0.5rem}.s-order-branch-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:1rem;line-height:1.5rem;font-weight:500;line-height:1.45;color:var(--color-text-primary,#2b2d34)}.s-order-branch-address{overflow-wrap:break-word;font-size:0.75rem;line-height:1rem;line-height:1.45;color:var(--color-text-secondary,#666)}.s-order-branch-actions{display:flex;flex-shrink:0;flex-wrap:wrap;align-items:center;gap:0.75rem}@media (min-width: 768px){.s-order-branch-actions{flex-wrap:nowrap}}.s-order-branch-map-link{display:inline-flex;min-height:2.25rem;align-items:center;justify-content:center;gap:0.5rem;white-space:nowrap;border-radius:0.375rem;border-width:1px;border-color:var(--color-primary,#236e4c);padding-left:0.875rem;padding-right:0.875rem;padding-top:0.5rem;padding-bottom:0.5rem;font-size:0.875rem;line-height:1.25rem;font-weight:700;line-height:1.2;color:var(--color-primary,#236e4c);text-decoration-line:none}.s-order-branch-action-icon{display:inline-flex;align-items:center;justify-content:center;font-size:0.875rem;line-height:1.25rem;color:currentColor}.s-order-branch-action-icon svg{height:1em;width:1em}";export{s as salla_order_branch}