@salla.sa/twilight-components 2.14.411 → 2.14.412

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 (299) hide show
  1. package/dist/cjs/{filepond-DmIUNeKc.js → filepond-BO-XBD1i.js} +1 -1
  2. package/dist/cjs/{filepond-plugin-file-poster-C8AOgqzV.js → filepond-plugin-file-poster-DJIG7vOj.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-validate-size-C1uEA-N4.js → filepond-plugin-file-validate-size-Bhtuy-Ar.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-type-CAYEi5xZ.js → filepond-plugin-file-validate-type-BQhRvZvr.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-image-edit-DeGtwB2d.js → filepond-plugin-image-edit-C4unOPfE.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-exif-orientation-BL0bCUVQ.js → filepond-plugin-image-exif-orientation-QreJIoqS.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-preview-Dih1Wn_X.js → filepond-plugin-image-preview-aiURUVDo.js} +1 -1
  8. package/dist/cjs/{functions-CcFdqlpK.js → functions-qbO9xyMC.js} +1 -1
  9. package/dist/cjs/{index-BBXwu2T_.js → index-BtHm_lmK.js} +1 -1
  10. package/dist/cjs/{index-PZNCZxVn.js → index-DR2nrv6V.js} +6 -6
  11. package/dist/cjs/loader.cjs.js +2 -2
  12. package/dist/cjs/salla-accordion-body_2.cjs.entry.js +1 -1
  13. package/dist/cjs/salla-accordion_6.cjs.entry.js +1 -1
  14. package/dist/cjs/{salla-add-product-button_4.cjs.entry.js → salla-add-product-button_5.cjs.entry.js} +130 -1
  15. package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
  16. package/dist/cjs/salla-alert_2.cjs.entry.js +1 -1
  17. package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
  18. package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
  19. package/dist/cjs/salla-badge.cjs.entry.js +1 -1
  20. package/dist/cjs/salla-booking-field_7.cjs.entry.js +10 -10
  21. package/dist/cjs/salla-bullet-delivery.cjs.entry.js +1 -1
  22. package/dist/cjs/salla-cart-coupons.cjs.entry.js +1 -1
  23. package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +1 -1
  24. package/dist/cjs/salla-comment-form_8.cjs.entry.js +1 -1
  25. package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
  26. package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
  27. package/dist/cjs/salla-cookies-bar.cjs.entry.js +1 -1
  28. package/dist/cjs/salla-count-down.cjs.entry.js +1 -1
  29. package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
  30. package/dist/cjs/salla-delivery-promise.cjs.entry.js +1 -1
  31. package/dist/cjs/salla-edit-order-button.cjs.entry.js +1 -1
  32. package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
  33. package/dist/cjs/salla-filters.cjs.entry.js +1 -1
  34. package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +1 -1
  35. package/dist/cjs/salla-gifting.cjs.entry.js +1 -1
  36. package/dist/cjs/salla-hook.cjs.entry.js +1 -1
  37. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
  38. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  39. package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
  40. package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
  41. package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
  42. package/dist/cjs/salla-loyalty-banner.cjs.entry.js +2 -2
  43. package/dist/cjs/salla-loyalty-hero_2.cjs.entry.js +2 -2
  44. package/dist/cjs/salla-loyalty-panel.cjs.entry.js +3 -3
  45. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  46. package/dist/cjs/salla-loyalty-program.cjs.entry.js +3 -3
  47. package/dist/cjs/salla-loyalty-reward.cjs.entry.js +2 -2
  48. package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
  49. package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
  50. package/dist/cjs/salla-map.cjs.entry.js +1 -1
  51. package/dist/cjs/salla-menu.cjs.entry.js +1 -1
  52. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  53. package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
  54. package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
  55. package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
  56. package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
  57. package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
  58. package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
  59. package/dist/cjs/salla-offer.cjs.entry.js +1 -1
  60. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
  61. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  62. package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
  63. package/dist/cjs/salla-order-edit-item.cjs.entry.js +1 -1
  64. package/dist/cjs/salla-order-edit.cjs.entry.js +1 -1
  65. package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
  66. package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
  67. package/dist/cjs/salla-orders.cjs.entry.js +1 -1
  68. package/dist/cjs/salla-payments.cjs.entry.js +1 -1
  69. package/dist/cjs/salla-placeholder.cjs.entry.js +1 -1
  70. package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
  71. package/dist/cjs/salla-product-card_2.cjs.entry.js +1 -1
  72. package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
  73. package/dist/cjs/salla-products-list.cjs.entry.js +1 -1
  74. package/dist/cjs/salla-progress-bar.cjs.entry.js +1 -1
  75. package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
  76. package/dist/cjs/salla-rating-modal.cjs.entry.js +1 -1
  77. package/dist/cjs/salla-reward-action_4.cjs.entry.js +3 -3
  78. package/dist/cjs/salla-scopes.cjs.entry.js +1 -1
  79. package/dist/cjs/salla-search.cjs.entry.js +1 -1
  80. package/dist/cjs/salla-skeleton.cjs.entry.js +1 -1
  81. package/dist/cjs/salla-slider.cjs.entry.js +1 -1
  82. package/dist/cjs/salla-social-share.cjs.entry.js +1 -1
  83. package/dist/cjs/salla-social.cjs.entry.js +1 -1
  84. package/dist/cjs/salla-tab-content_3.cjs.entry.js +1 -1
  85. package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
  86. package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
  87. package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
  88. package/dist/cjs/salla-user-menu.cjs.entry.js +1 -1
  89. package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
  90. package/dist/cjs/salla-user-settings.cjs.entry.js +1 -1
  91. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  92. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  93. package/dist/cjs/{tracked-promise-DDi0ylD7.js → tracked-promise-Dlrrx6bS.js} +1 -1
  94. package/dist/cjs/twilight.cjs.js +2 -2
  95. package/dist/cjs/{vanilla-picker-OPSqChB9.js → vanilla-picker-BgvVWFWW.js} +1 -1
  96. package/dist/collection/collection-manifest.json +2 -0
  97. package/dist/collection/components/salla-bought-together/interfaces.js +1 -0
  98. package/dist/collection/components/salla-bought-together/salla-bought-together.css +18 -0
  99. package/dist/collection/components/salla-bought-together/salla-bought-together.js +174 -0
  100. package/dist/components/index.js +2 -2
  101. package/dist/components/salla-bought-together.d.ts +11 -0
  102. package/dist/components/salla-bought-together.js +174 -0
  103. package/dist/esm/{filepond-905U04xY.js → filepond-BdAJ1Q3U.js} +1 -1
  104. package/dist/esm/{filepond-plugin-file-poster-BWkARu_j.js → filepond-plugin-file-poster-_P46glp3.js} +1 -1
  105. package/dist/esm/{filepond-plugin-file-validate-size-C0PJYzhi.js → filepond-plugin-file-validate-size-Cs7iDcpm.js} +1 -1
  106. package/dist/esm/{filepond-plugin-file-validate-type-Bglz2iC6.js → filepond-plugin-file-validate-type-BokfkNG5.js} +1 -1
  107. package/dist/esm/{filepond-plugin-image-edit-3aH_4pIL.js → filepond-plugin-image-edit-DqujritR.js} +1 -1
  108. package/dist/esm/{filepond-plugin-image-exif-orientation-B1h3s1nQ.js → filepond-plugin-image-exif-orientation-CTqsgDyW.js} +1 -1
  109. package/dist/esm/{filepond-plugin-image-preview-CAiiia6W.js → filepond-plugin-image-preview-zoBFIa44.js} +1 -1
  110. package/dist/esm/{functions-GzuwX5HS.js → functions-CEdm6lBq.js} +1 -1
  111. package/dist/esm/{index-xT-Vt0D7.js → index-DXkuZzsm.js} +1 -1
  112. package/dist/esm/{index-rIbWLXjW.js → index-eYsXdqjv.js} +6 -6
  113. package/dist/esm/loader.js +3 -3
  114. package/dist/esm/salla-accordion-body_2.entry.js +1 -1
  115. package/dist/esm/salla-accordion_6.entry.js +1 -1
  116. package/dist/esm/{salla-add-product-button_4.entry.js → salla-add-product-button_5.entry.js} +130 -2
  117. package/dist/esm/salla-advertisement.entry.js +1 -1
  118. package/dist/esm/salla-alert_2.entry.js +1 -1
  119. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  120. package/dist/esm/salla-apps-icons.entry.js +1 -1
  121. package/dist/esm/salla-badge.entry.js +1 -1
  122. package/dist/esm/salla-booking-field_7.entry.js +10 -10
  123. package/dist/esm/salla-bullet-delivery.entry.js +1 -1
  124. package/dist/esm/salla-cart-coupons.entry.js +1 -1
  125. package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
  126. package/dist/esm/salla-comment-form_8.entry.js +1 -1
  127. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  128. package/dist/esm/salla-contacts.entry.js +1 -1
  129. package/dist/esm/salla-cookies-bar.entry.js +1 -1
  130. package/dist/esm/salla-count-down.entry.js +1 -1
  131. package/dist/esm/salla-custom-fields.entry.js +1 -1
  132. package/dist/esm/salla-delivery-promise.entry.js +1 -1
  133. package/dist/esm/salla-edit-order-button.entry.js +1 -1
  134. package/dist/esm/salla-filters-widget.entry.js +1 -1
  135. package/dist/esm/salla-filters.entry.js +1 -1
  136. package/dist/esm/salla-fulfillment-methods.entry.js +1 -1
  137. package/dist/esm/salla-gifting.entry.js +1 -1
  138. package/dist/esm/salla-hook.entry.js +1 -1
  139. package/dist/esm/salla-infinite-scroll.entry.js +1 -1
  140. package/dist/esm/salla-installment.entry.js +1 -1
  141. package/dist/esm/salla-list-tile.entry.js +1 -1
  142. package/dist/esm/salla-localization-modal.entry.js +1 -1
  143. package/dist/esm/salla-login-modal.entry.js +1 -1
  144. package/dist/esm/salla-loyalty-banner.entry.js +2 -2
  145. package/dist/esm/salla-loyalty-hero_2.entry.js +2 -2
  146. package/dist/esm/salla-loyalty-panel.entry.js +3 -3
  147. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  148. package/dist/esm/salla-loyalty-program.entry.js +3 -3
  149. package/dist/esm/salla-loyalty-reward.entry.js +2 -2
  150. package/dist/esm/salla-loyalty.entry.js +1 -1
  151. package/dist/esm/salla-maintenance-alert.entry.js +1 -1
  152. package/dist/esm/salla-map.entry.js +1 -1
  153. package/dist/esm/salla-menu.entry.js +1 -1
  154. package/dist/esm/salla-metadata.entry.js +1 -1
  155. package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
  156. package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
  157. package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
  158. package/dist/esm/salla-notification-item.entry.js +1 -1
  159. package/dist/esm/salla-notifications.entry.js +1 -1
  160. package/dist/esm/salla-offer-modal.entry.js +1 -1
  161. package/dist/esm/salla-offer.entry.js +1 -1
  162. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  163. package/dist/esm/salla-order-details-options.entry.js +1 -1
  164. package/dist/esm/salla-order-details.entry.js +1 -1
  165. package/dist/esm/salla-order-edit-item.entry.js +1 -1
  166. package/dist/esm/salla-order-edit.entry.js +1 -1
  167. package/dist/esm/salla-order-summary.entry.js +1 -1
  168. package/dist/esm/salla-order-totals-card.entry.js +1 -1
  169. package/dist/esm/salla-orders.entry.js +1 -1
  170. package/dist/esm/salla-payments.entry.js +1 -1
  171. package/dist/esm/salla-placeholder.entry.js +1 -1
  172. package/dist/esm/salla-price-range.entry.js +1 -1
  173. package/dist/esm/salla-product-card_2.entry.js +1 -1
  174. package/dist/esm/salla-product-size-guide.entry.js +1 -1
  175. package/dist/esm/salla-products-list.entry.js +1 -1
  176. package/dist/esm/salla-progress-bar.entry.js +1 -1
  177. package/dist/esm/salla-quick-order.entry.js +1 -1
  178. package/dist/esm/salla-rating-modal.entry.js +1 -1
  179. package/dist/esm/salla-reward-action_4.entry.js +3 -3
  180. package/dist/esm/salla-scopes.entry.js +1 -1
  181. package/dist/esm/salla-search.entry.js +1 -1
  182. package/dist/esm/salla-skeleton.entry.js +1 -1
  183. package/dist/esm/salla-slider.entry.js +1 -1
  184. package/dist/esm/salla-social-share.entry.js +1 -1
  185. package/dist/esm/salla-social.entry.js +1 -1
  186. package/dist/esm/salla-tab-content_3.entry.js +1 -1
  187. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  188. package/dist/esm/salla-tooltip.entry.js +1 -1
  189. package/dist/esm/salla-trust-badges.entry.js +1 -1
  190. package/dist/esm/salla-user-menu.entry.js +1 -1
  191. package/dist/esm/salla-user-profile.entry.js +1 -1
  192. package/dist/esm/salla-user-settings.entry.js +1 -1
  193. package/dist/esm/salla-verify.entry.js +1 -1
  194. package/dist/esm/salla-wallet.entry.js +1 -1
  195. package/dist/esm/{tracked-promise-BQ3oDpFo.js → tracked-promise-DC9Saija.js} +1 -1
  196. package/dist/esm/twilight.js +3 -3
  197. package/dist/esm/{vanilla-picker-Cv_dc6oT.js → vanilla-picker-DdyyxtyV.js} +1 -1
  198. package/dist/twilight/{p-98862c7d.entry.js → p-040057c7.entry.js} +1 -1
  199. package/dist/twilight/{p-f2203ac6.entry.js → p-046ef0cf.entry.js} +1 -1
  200. package/dist/twilight/{p-80adbd86.entry.js → p-04a3bd3a.entry.js} +1 -1
  201. package/dist/twilight/{p-c3087e4b.entry.js → p-083bfceb.entry.js} +1 -1
  202. package/dist/twilight/{p-b003a630.entry.js → p-0b6cfdc6.entry.js} +1 -1
  203. package/dist/twilight/{p-9faa8a9e.entry.js → p-0c773a98.entry.js} +1 -1
  204. package/dist/twilight/{p-4aacfcb8.entry.js → p-0fee8df2.entry.js} +1 -1
  205. package/dist/twilight/p-12e78aef.entry.js +4 -0
  206. package/dist/twilight/{p-7dd1b438.entry.js → p-18046a80.entry.js} +1 -1
  207. package/dist/twilight/{p-fda57a16.entry.js → p-18428cad.entry.js} +1 -1
  208. package/dist/twilight/{p-62a8bf31.entry.js → p-18e4e822.entry.js} +1 -1
  209. package/dist/twilight/{p-15a53fe6.entry.js → p-1c2c212f.entry.js} +1 -1
  210. package/dist/twilight/{p-d6b4621a.entry.js → p-1d9e9e5e.entry.js} +1 -1
  211. package/dist/twilight/{p-0ad7c855.entry.js → p-1f18bb8c.entry.js} +1 -1
  212. package/dist/twilight/{p-c2c428e7.entry.js → p-24121404.entry.js} +1 -1
  213. package/dist/twilight/{p-24216a35.entry.js → p-28a276b7.entry.js} +1 -1
  214. package/dist/twilight/{p-6c84e2a0.entry.js → p-2beb780e.entry.js} +1 -1
  215. package/dist/twilight/{p-78bcabea.entry.js → p-2d29eae4.entry.js} +1 -1
  216. package/dist/twilight/{p-18b593a9.entry.js → p-2ea91f4d.entry.js} +1 -1
  217. package/dist/twilight/{p-dfa1ddc1.entry.js → p-371ea2ac.entry.js} +1 -1
  218. package/dist/twilight/{p-56f8e93f.entry.js → p-38df842f.entry.js} +1 -1
  219. package/dist/twilight/{p-a9f516c8.entry.js → p-3a0482aa.entry.js} +1 -1
  220. package/dist/twilight/{p-2a45676f.entry.js → p-3dd609ff.entry.js} +1 -1
  221. package/dist/twilight/{p-57a1bd5e.entry.js → p-473e829b.entry.js} +1 -1
  222. package/dist/twilight/{p-49457497.entry.js → p-4c7e5ca7.entry.js} +1 -1
  223. package/dist/twilight/{p-D-wDhUx5.js → p-4rGFyB1b.js} +1 -1
  224. package/dist/twilight/{p-ca62e17c.entry.js → p-543482d0.entry.js} +1 -1
  225. package/dist/twilight/{p-38b0d747.entry.js → p-569db60a.entry.js} +1 -1
  226. package/dist/twilight/{p-9adacf19.entry.js → p-63b091c3.entry.js} +1 -1
  227. package/dist/twilight/{p-cc551a73.entry.js → p-67b3a063.entry.js} +1 -1
  228. package/dist/twilight/{p-92863280.entry.js → p-6a50e4ab.entry.js} +1 -1
  229. package/dist/twilight/{p-5c3711fb.entry.js → p-6ffe96cf.entry.js} +1 -1
  230. package/dist/twilight/{p-d680ef32.entry.js → p-70e26072.entry.js} +1 -1
  231. package/dist/twilight/{p-c9e78561.entry.js → p-78b27b6f.entry.js} +1 -1
  232. package/dist/twilight/{p-1da1f13f.entry.js → p-809d8765.entry.js} +1 -1
  233. package/dist/twilight/{p-31a5bd84.entry.js → p-82d315dc.entry.js} +1 -1
  234. package/dist/twilight/{p-9b289072.entry.js → p-82fc9f8a.entry.js} +1 -1
  235. package/dist/twilight/{p-dcbd52a9.entry.js → p-86494434.entry.js} +1 -1
  236. package/dist/twilight/{p-09de8e38.entry.js → p-880974c0.entry.js} +1 -1
  237. package/dist/twilight/{p-d218c2ff.entry.js → p-914ef875.entry.js} +1 -1
  238. package/dist/twilight/{p-70e21348.entry.js → p-92c3525a.entry.js} +1 -1
  239. package/dist/twilight/{p-8afeb013.entry.js → p-92ee979a.entry.js} +1 -1
  240. package/dist/twilight/{p-a5a4a9c4.entry.js → p-98dfc58c.entry.js} +1 -1
  241. package/dist/twilight/{p-0c751ad3.entry.js → p-9da33e90.entry.js} +1 -1
  242. package/dist/twilight/p-9f51245d.entry.js +4 -0
  243. package/dist/twilight/{p-4c527044.entry.js → p-9fea03ff.entry.js} +1 -1
  244. package/dist/twilight/{p-BEG98TtY.js → p-B-gehnpX.js} +1 -1
  245. package/dist/twilight/{p-l3RnLhEs.js → p-BrL7ZFF-.js} +1 -1
  246. package/dist/twilight/{p-_9i6OtFf.js → p-Bt5MNLrr.js} +1 -1
  247. package/dist/twilight/{p-B6nHsUmY.js → p-C4iKSe6r.js} +1 -1
  248. package/dist/twilight/{p-_uYeO1XY.js → p-CZP8nF-D.js} +1 -1
  249. package/dist/twilight/{p-CTLj8xU3.js → p-CdKOsdhF.js} +1 -1
  250. package/dist/twilight/{p-B5aVfdOq.js → p-CdQPD_4N.js} +1 -1
  251. package/dist/twilight/{p-D0khSRlI.js → p-CkMgy4QX.js} +1 -1
  252. package/dist/twilight/{p-ba7hQHgb.js → p-DgUXy-oM.js} +1 -1
  253. package/dist/twilight/{p-8oz_tYCT.js → p-VP7525fx.js} +1 -1
  254. package/dist/twilight/{p-0362115c.entry.js → p-a0792c90.entry.js} +1 -1
  255. package/dist/twilight/{p-7179b561.entry.js → p-a74e2625.entry.js} +1 -1
  256. package/dist/twilight/{p-8b5ab33f.entry.js → p-a97da8bc.entry.js} +1 -1
  257. package/dist/twilight/p-aced00e2.entry.js +4 -0
  258. package/dist/twilight/{p-5f08ca5c.entry.js → p-b04f3b37.entry.js} +1 -1
  259. package/dist/twilight/{p-a492282a.entry.js → p-b258ef5c.entry.js} +1 -1
  260. package/dist/twilight/{p-c8dedc2d.entry.js → p-ba81b8d6.entry.js} +1 -1
  261. package/dist/twilight/{p-0d04fb8c.entry.js → p-bab9b1ad.entry.js} +1 -1
  262. package/dist/twilight/{p-dde28f2e.entry.js → p-c00c26f4.entry.js} +1 -1
  263. package/dist/twilight/{p-9f597738.entry.js → p-c0ea9ff2.entry.js} +1 -1
  264. package/dist/twilight/{p-a0c775b0.entry.js → p-c11f0af9.entry.js} +1 -1
  265. package/dist/twilight/{p-dfeeb15e.entry.js → p-c38311a2.entry.js} +1 -1
  266. package/dist/twilight/{p-cb77c16b.entry.js → p-c6a56a0c.entry.js} +1 -1
  267. package/dist/twilight/{p-1716e7bf.entry.js → p-c8821c21.entry.js} +1 -1
  268. package/dist/twilight/{p-9020d179.entry.js → p-c8b8ea5c.entry.js} +1 -1
  269. package/dist/twilight/{p-0a39c576.entry.js → p-c8f6bc81.entry.js} +1 -1
  270. package/dist/twilight/{p-78647833.entry.js → p-cb5fbe10.entry.js} +1 -1
  271. package/dist/twilight/{p-67ec0369.entry.js → p-cf4c9420.entry.js} +1 -1
  272. package/dist/twilight/{p-df55b402.entry.js → p-d400841e.entry.js} +1 -1
  273. package/dist/twilight/{p-aad3c860.entry.js → p-d49fd79d.entry.js} +1 -1
  274. package/dist/twilight/{p-ffeb8d66.entry.js → p-d6a5df0d.entry.js} +1 -1
  275. package/dist/twilight/{p-3134ec55.entry.js → p-d6a86efa.entry.js} +1 -1
  276. package/dist/twilight/{p-70b821e0.entry.js → p-dbe6cc9c.entry.js} +1 -1
  277. package/dist/twilight/{p-7ac1d258.entry.js → p-e2cec9f6.entry.js} +1 -1
  278. package/dist/twilight/{p-17bc3083.entry.js → p-e5e1574f.entry.js} +1 -1
  279. package/dist/twilight/{p-c39c381b.entry.js → p-e89e8a20.entry.js} +1 -1
  280. package/dist/twilight/{p-rIbWLXjW.js → p-eYsXdqjv.js} +1 -1
  281. package/dist/twilight/{p-03327bdb.entry.js → p-eadaf058.entry.js} +1 -1
  282. package/dist/twilight/{p-746b703c.entry.js → p-eae4b2c9.entry.js} +1 -1
  283. package/dist/twilight/p-ed6e8053.entry.js +4 -0
  284. package/dist/twilight/{p-464ebb66.entry.js → p-f267b033.entry.js} +1 -1
  285. package/dist/twilight/{p-d950df54.entry.js → p-f3105e54.entry.js} +1 -1
  286. package/dist/twilight/{p-6477aa16.entry.js → p-f3d76113.entry.js} +1 -1
  287. package/dist/twilight/{p-fb9806d9.entry.js → p-f91399b4.entry.js} +1 -1
  288. package/dist/twilight/{p-4597e9a0.entry.js → p-faae4443.entry.js} +1 -1
  289. package/dist/twilight/{p-941e5a4a.entry.js → p-fea8186b.entry.js} +1 -1
  290. package/dist/twilight/{p-05618953.entry.js → p-ff972c8b.entry.js} +1 -1
  291. package/dist/twilight/twilight.esm.js +1 -1
  292. package/dist/types/components/salla-bought-together/interfaces.d.ts +15 -0
  293. package/dist/types/components/salla-bought-together/salla-bought-together.d.ts +23 -0
  294. package/dist/types/components.d.ts +23 -0
  295. package/package.json +5 -5
  296. package/dist/twilight/p-4a549dd4.entry.js +0 -4
  297. package/dist/twilight/p-7ea9101c.entry.js +0 -4
  298. package/dist/twilight/p-d29c6154.entry.js +0 -4
  299. package/dist/twilight/p-e37fe440.entry.js +0 -4
@@ -0,0 +1,4 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ import{h as s,r as a}from"./p-eYsXdqjv.js";import{s as l}from"./p-B-Rj6b9M.js";import{n as o,a as t,c as r}from"./p-Bt5MNLrr.js";import{S as e,a as i}from"./p-Bs6JxDkg.js";import{S as p}from"./p-CZRcMGA9.js";import{S as n}from"./p-D1s2kXqL.js";import{S as c}from"./p-QpH8MU22.js";import{S as y}from"./p-0-eTJXSD.js";import{S as m}from"./p-CXRKXFgT.js";import{T as g}from"./p-4rGFyB1b.js";import{a as d}from"./p-CgtvEd63.js";var h=function(s,a,l,o){var t,r=arguments.length,e=r<3?a:null===o?o=Object.getOwnPropertyDescriptor(a,l):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)e=Reflect.decorate(s,a,l,o);else for(var i=s.length-1;i>=0;i--)(t=s[i])&&(e=(r<3?t(e):r>3?t(a,l,e):t(a,l))||e);return r>3&&e&&Object.defineProperty(a,l,e),e};const u={all:s("span",{class:"s-loyalty-program-rewards-tab-icon",innerHTML:i}),free_shipping:s("span",{class:"s-loyalty-program-rewards-tab-icon",innerHTML:p}),coupon_discount:s("span",{class:"s-loyalty-program-rewards-tab-icon",innerHTML:e}),free_product:s("span",{class:"s-loyalty-program-rewards-tab-icon",innerHTML:n})},f=class{constructor(s){a(this,s),this.currentPrize=null,this.collapsed=!0,this.animatedPoints=0,this.handleExchangeSucceeded=()=>{this.points(),this.program()}}componentWillLoad(){return salla.onReady().then((()=>salla.lang.onLoaded())).then((()=>l())).then((()=>{this.program(),this.points(),salla.event.on("loyalty::exchange.succeeded",this.handleExchangeSucceeded)})).catch((s=>salla.logger.error(s)))}disconnectedCallback(){salla.event.off("loyalty::exchange.succeeded",this.handleExchangeSucceeded)}getOutlineItem(a,l,o){const t={1:s("span",{innerHTML:c}),2:s("span",{innerHTML:y}),3:s("span",{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>cart-upload</title>\n<path d="M14.545 7.669l3.121-2.732v9.729c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-9.728l3.121 2.732c0.253 0.22 0.567 0.329 0.879 0.329 0.371 0 0.74-0.155 1.004-0.455 0.485-0.555 0.429-1.396-0.125-1.881l-5.333-4.667c-0.503-0.44-1.253-0.44-1.756 0l-5.333 4.667c-0.555 0.484-0.611 1.327-0.125 1.881 0.484 0.552 1.325 0.609 1.881 0.124zM30.647 5.371c-0.713-0.171-1.436 0.267-1.609 0.983l-2.744 11.363c-0.171 0.568-0.684 0.951-1.277 0.951h-12.136c-0.563 0-1.067-0.356-1.256-0.885l-6.035-16.896c-0.189-0.531-0.692-0.885-1.256-0.885h-2.667c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333h1.727l5.719 16.012c0.567 1.588 2.081 2.655 3.768 2.655h12.136c1.78 0 3.32-1.145 3.851-2.92l2.763-11.433c0.173-0.716-0.267-1.436-0.983-1.609zM13.667 24c-2.205 0-4 1.795-4 4s1.795 4 4 4 4-1.795 4-4-1.795-4-4-4zM13.667 29.333c-0.735 0-1.333-0.599-1.333-1.333s0.599-1.333 1.333-1.333 1.333 0.599 1.333 1.333-0.599 1.333-1.333 1.333zM24.333 24c-2.205 0-4 1.795-4 4s1.795 4 4 4 4-1.795 4-4-1.795-4-4-4zM24.333 29.333c-0.735 0-1.333-0.599-1.333-1.333s0.599-1.333 1.333-1.333 1.333 0.599 1.333 1.333-0.599 1.333-1.333 1.333z"></path>\n</svg>\n'})};return s("li",{class:"s-loyalty-program-item"},s("div",{class:"s-loyalty-program-content"},s("span",{class:"s-loyalty-program-icon-container"},s("span",{class:"s-loyalty-program-text-gradient"},a),s("span",{class:"s-loyalty-program-icon"},t[a])),s("div",{class:"s-loyalty-program-title"},l),s("div",{class:"s-loyalty-program-description"},o)))}render(){if("error"===this.program.status)return s("p",null,salla.lang.get("common.errors.error_occured"));const a=this.program.data.points.slice(0,this.collapsed?t(this.program.data.points.length):this.program.data.points.length),l=this.program.data.prizes,o=this.program.data.prizes_count;return s("div",{class:"s-loyalty-program-container"},s("salla-loyalty-hero",{name:this.program.data.name,description:this.program.data.description,image:this.program.data.image},salla.config.isUser()?s("div",{slot:"crosspoint",class:"s-loyalty-program-profile-wrapper"},s("div",{class:"s-loyalty-program-profile-container"},s("div",{class:"s-loyalty-program-profile-points-section"},s("h2",{class:"s-loyalty-program-profile-label"},salla.lang.get("pages.loyalty_program.your_points")),s("p",{class:"s-loyalty-program-profile-points"},s("span",{class:"s-loyalty-program-profile-points-value"},this.animatedPoints?this.animatedPoints:this.points.data)," ",salla.lang.get("pages.loyalty_program.point"))),s("div",{class:"s-loyalty-program-profile-icon"},s("span",{innerHTML:m})))):s("button",{slot:"action",onClick:()=>salla.event.dispatch("login::open"),class:{"s-loyalty-program-login-action":!0,"s-loyalty-program-login-action-dark":!this.program.data.image,"s-loyalty-program-login-action-light":!!this.program.data.image}},salla.lang.get("blocks.header.login"))),s("div",{class:"s-loyalty-program-outline-section"},s("section",{class:"s-loyalty-program-section"},s("header",{class:"s-loyalty-program-header"},s("h1",{class:"s-loyalty-program-main-title"},salla.lang.get("pages.loyalty_program.how_to_start")),s("p",{class:"s-loyalty-program-subtitle"},salla.lang.get("pages.loyalty_program.three_simple_steps"))),s("ol",{class:"s-loyalty-program-list"},this.getOutlineItem(1,salla.lang.get("pages.loyalty_program.register"),salla.lang.get("pages.loyalty_program.create_account")),this.getOutlineItem(2,salla.lang.get("pages.loyalty_program.earn_points"),salla.lang.get("pages.loyalty_program.complete_tasks")),this.getOutlineItem(3,salla.lang.get("pages.loyalty_program.redeem_rewards"),salla.lang.get("pages.loyalty_program.enjoy_rewards"))))),s("div",{class:"s-loyalty-program-points-wrapper"},s("section",{class:"s-loyalty-program-points-section"},s("header",{class:"s-loyalty-program-points-header"},s("h1",{class:"s-loyalty-program-points-title"},this.program.data.promotion_title),s("p",{class:"s-loyalty-program-points-description"},this.program.data.promotion_description)),s("div",{class:"s-loyalty-program-points-spacer"}),s("ul",{class:{"s-loyalty-program-points-list-one":1===this.program.data.points.length,"s-loyalty-program-points-list-two":2===this.program.data.points.length,"s-loyalty-program-points-list-multi":this.program.data.points.length>2}},a.map((a=>s("li",null,s("salla-loyalty-point",{point:a}))))),s("div",{class:"s-loyalty-program-points-spacer"}),t(this.program.data.points.length)!==this.program.data.points.length&&s("button",{class:"s-loyalty-program-points-more-button",onClick:()=>this.collapsed=!this.collapsed},this.collapsed?s("span",null,salla.lang.get("pages.loyalty_program.show_more"),"  ",s("span",{style:{fontSize:"1.2rem",fontWeight:"300"}},"+")):s("span",null,salla.lang.get("pages.loyalty_program.show_less"),"  ",s("span",{style:{fontSize:"1.2rem",fontWeight:"300"}},"-"))))),"success"!==this.program.status?"":s("div",{class:"s-loyalty-program-rewards-container s-loyalty-program-slider-arrows-edges"},s("section",{class:{"s-loyalty-program-tabs-hider":l.length<=2||o<=4}},s("h1",{class:"s-loyalty-program-rewards-heading-mobile"},salla.lang.get("pages.loyalty_program.rewards")),s("salla-tabs",null,s("div",{slot:"header",class:"s-loyalty-program-rewards-tab-items"},l.map((a=>s("salla-tab-header",{slot:"header",name:a.type},u[a.type],s("span",null,a.title))))),s("h1",{slot:"header",class:"s-loyalty-program-rewards-heading-desktop"},salla.lang.get("pages.loyalty_program.rewards")),l.map((a=>s("salla-tab-content",{slot:"content",name:a.type},s("salla-slider",{id:a.type,type:"default","slider-config":'{"loop":false,"slidesPerView":"auto","freeMode":true,"spaceBetween":12,"breakpoints":{"768":{"slidesPerView":4,"spaceBetween":24,"freeMode":false,"speed":300}}}'},s("div",{slot:"items"},a.items.map((a=>s("salla-reward-card",{prize:a,onAreaClick:()=>{this.currentPrize=a,r((()=>this.detailsModal.open()))},onActionClick:()=>{this.currentPrize=a,r((()=>this.detailsModal.open()))}}))))))))),s("salla-modal",{ref:s=>this.detailsModal=s,class:"s-loyalty-program-modal",width:"md",noPadding:!0},this.currentPrize?s("salla-reward-details",{onActionClick:()=>r((()=>this.exchangeModal.open())),prize:this.currentPrize}):""),s("salla-modal",{ref:s=>this.exchangeModal=s,class:"s-loyalty-program-modal",width:"sm"},this.currentPrize?s("salla-reward-exchange",{prize:this.currentPrize}):""))))}};h([g((async function(){const{data:s}=await salla.loyalty.getProgram();return o(s)}),{initialData:{points:[],prizes:[],prizes_count:0}})],f.prototype,"program",void 0),h([g((async function(){const{data:s}=await salla.loyalty.getPoints();return d({targets:{value:0},value:s.points??0,round:1,easing:"easeOutQuad",duration:2e3,update:s=>{this.animatedPoints=s.animations[0].currentValue}}),s.points}))],f.prototype,"points",void 0),f.style="";export{f as salla_loyalty_program}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as t,H as e,a}from"./p-rIbWLXjW.js";const i=class{constructor(t){s(this,t),this.loading=!0,this.saveLoading=!1,this.payload={items:{update:[],remove:[]}},this.expired=!1,this.editPreview=null,this.confirming=!1}async componentWillLoad(){await salla.onReady(),this.loadFromProp(),this.startExpiryCheck()}disconnectedCallback(){clearInterval(this.expiryInterval)}startExpiryCheck(){const s=this.order?.customer_editing_session?.ends_at;if(!s)return;const t=()=>new Date(`${s.replace(" ","T")}+03:00`).getTime()<=Date.now();t()?this.expired=!0:this.expiryInterval=setInterval((()=>{t()&&(this.expired=!0,clearInterval(this.expiryInterval))}),1e3)}loadFromProp(){try{if(!this.orderData)return void(this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود"));const s="string"==typeof this.orderData?JSON.parse(this.orderData):this.orderData;this.order=s}catch(s){this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود")}finally{this.loading=!1}}handleItemUpdated(s){if(!this.order)return;const{itemId:t,quantity:e,options:a}=s.detail,i=this.payload.items.update.filter((s=>s.id!==t));i.push({id:t,quantity:e,options:a??[]}),this.payload={...this.payload,items:{...this.payload.items,update:i}},this.order={...this.order,items:this.order.items.map((s=>s.id===t?{...s,quantity:e}:s))}}handleItemRemoved(s){if(!this.order)return;if(this.order.items.length<=1)return void salla.notify.error(salla.lang.getWithDefault("pages.orders.order_cannot_be_empty","لا يمكن إزالة جميع المنتجات من الطلب"));const{itemId:t}=s.detail;this.payload={...this.payload,items:{update:this.payload.items.update.filter((s=>s.id!==t)),remove:[...this.payload.items.remove,t]}},this.order={...this.order,items:this.order.items.filter((s=>s.id!==t))}}get hasChanges(){return this.payload.items.update.length>0||this.payload.items.remove.length>0}async saveOrder(){if(this.hasChanges){this.saveLoading=!0;try{const s=await salla.order.api.editOrder(this.orderId,this.payload);this.editPreview=s?.data?.data||s?.data,await(this.saveModal?.open())}catch(s){const t=s?.response?.data?.error?.message||s?.response?.data?.message;t&&salla.notify.error(t)}finally{this.saveLoading=!1}}}navigateToOrder(){const s=new URL(window.location.href);s.pathname=s.pathname.replace(/\/edit\/?$/,""),s.search="",window.location.href=s.href}handleConfirm(){this.confirming=!0,this.editPreview?.payment?.required&&this.editPreview.payment.payment_url?window.location.href=this.editPreview.payment.payment_url:this.navigateToOrder()}async cancelEditSession(){try{await salla.order.api.cancelEditSession(this.orderId),this.navigateToOrder()}catch(s){const t=s?.response?.data?.error?.message||s?.response?.data?.message;t&&salla.notify.error(t)}}renderSaveModal(){const s=this.editPreview,e=s?.totals?.remaining_amount?.amount>0,a=s?.totals?.refund_amount?.amount>0,i=s?.totals?.tax?.amount?.amount;return t("salla-modal",{ref:s=>this.saveModal=s,width:"md",onModalVisibilityChanged:async s=>{s.detail||(this.editPreview=null,this.confirming||await this.cancelEditSession(),this.confirming=!1)}},t("div",{class:"s-order-edit-modal"},t("h2",{class:"s-order-edit-modal-title"},salla.lang.getWithDefault("pages.orders.edit_summary_title","ملخص الطلب بعد التعديل")),s?.items?.length>0&&t("div",{class:"s-order-edit-modal-items"},s.items.map((s=>{const e=this.order?.items?.find((t=>t.id==s.id)),a=e?.product?.image?.url,i=s.options?.join("/ ");return t("div",{class:"s-order-edit-modal-item"},t("div",{class:"s-order-edit-modal-item-start"},a&&t("img",{src:a,alt:s.name,class:"s-order-edit-modal-item-image"}),t("div",null,t("p",{class:"s-order-edit-modal-item-name"},s.name),i&&t("span",{class:"s-order-edit-modal-item-options"},i))),t("div",{class:"s-order-edit-modal-item-end"},t("span",{class:"s-order-edit-modal-item-price",innerHTML:salla.money(s.price.amount)})))}))),s?.totals?.updated_products_total&&t("div",{class:"s-order-edit-modal-row"},t("span",{class:"s-order-edit-modal-row-label"},salla.lang.getWithDefault("pages.orders.modified_products_total","مجموع المنتجات المعدلة")),t("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(s.totals.updated_products_total.amount)})),i>0&&t("div",{class:"s-order-edit-modal-row"},t("span",{class:"s-order-edit-modal-tax-label"},t("i",{class:"sicon-info-circle s-order-edit-modal-tax-icon"}),salla.lang.getWithDefault("pages.orders.vat","ضريبة القيمة المضافة")),t("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(i)})),s?.totals?.total&&t("div",{class:"s-order-edit-modal-total"},t("span",{class:"s-order-edit-modal-total-label"},salla.lang.getWithDefault("pages.orders.order_total","اجمالي الطلب")),t("span",{class:"s-order-edit-modal-total-value",innerHTML:salla.money(s.totals.total.amount)})),a&&t("div",{class:"s-order-edit-modal-refund"},t("i",{class:"sicon-info-circle s-order-edit-modal-refund-icon"}),t("p",{class:"s-order-edit-modal-refund-text"},salla.lang.getWithDefault("pages.orders.refund_message","سيتم تحويل فارق المبلغ على نفس وسيلة الدفع"))),t("div",{class:"s-order-edit-modal-btn-wrapper"},t("salla-button",{onClick:()=>this.handleConfirm()},e?salla.lang.getWithDefault("pages.orders.pay_difference","دفع فارق المبلغ"):a?salla.lang.getWithDefault("pages.orders.confirm_and_receive_difference","تأكيد واستلام فارق المبلغ"):salla.lang.getWithDefault("pages.orders.confirm_changes","تأكيد التعديلات"),t("i",{class:"sicon-keyboard_arrow_left s-order-edit-modal-btn-icon"})))))}render(){if(this.loading)return t(e,null,t("salla-loading",null));if(this.expired)return t(e,null,t("div",{class:"s-order-edit-expired"},t("p",null,salla.lang.getWithDefault("pages.orders.edit_session_expired","انتهت مدة التعديل المتاحة")),t("salla-button",{onClick:()=>this.navigateToOrder()},salla.lang.getWithDefault("pages.orders.back_to_order","العودة إلى تفاصيل الطلب"))));if(this.error||!this.order)return t(e,null,t("div",{class:"no-content-placeholder"},t("i",{class:"sicon-shopping-bag icon"}),t("p",null,this.error)));const s=this.order.items&&this.order.items.length>0,a=this.order.customer_editing_session?.ends_at;return t(e,null,a&&t("div",{class:"s-order-edit-timer-wrapper"},t("salla-count-down",{prefixText:salla.lang.getWithDefault("pages.orders.edit_within","يمكنك التعديل خلال"),date:a,horizontal:!0,withButton:!0,autoSegments:!0,labeled:!1,size:"sm",color:"primary"})),t("div",{class:"s-order-edit-items-wrapper"},t("h2",{class:"s-order-edit-items-title"},salla.lang.getWithDefault("pages.orders.order_products","منتجات الطلب")),s?this.order.items.map(((s,e)=>[t("salla-order-edit-item",{key:s.id,item:s,orderId:this.orderId}),e<this.order.items.length-1?t("div",{class:"s-order-edit-items-divider"}):null])):t("div",{class:"no-content-placeholder"},t("i",{class:"sicon-shopping-bag icon"}),t("p",null,salla.lang.getWithDefault("common.elements.no_items","لا توجد عناصر")))),t("div",{class:"s-order-edit-actions"},t("salla-button",{onClick:()=>this.saveOrder(),loading:this.saveLoading,disabled:!this.hasChanges},salla.lang.getWithDefault("pages.orders.save_changes","حفظ التعديلات")),t("salla-button",{color:"gray",fill:"outline",onClick:()=>this.cancelEditSession()},salla.lang.getWithDefault("common.elements.cancel","الغاء"))),this.renderSaveModal())}get host(){return a(this)}};i.style="";export{i as salla_order_edit}
4
+ import{r as s,h as t,H as e,a}from"./p-eYsXdqjv.js";const i=class{constructor(t){s(this,t),this.loading=!0,this.saveLoading=!1,this.payload={items:{update:[],remove:[]}},this.expired=!1,this.editPreview=null,this.confirming=!1}async componentWillLoad(){await salla.onReady(),this.loadFromProp(),this.startExpiryCheck()}disconnectedCallback(){clearInterval(this.expiryInterval)}startExpiryCheck(){const s=this.order?.customer_editing_session?.ends_at;if(!s)return;const t=()=>new Date(`${s.replace(" ","T")}+03:00`).getTime()<=Date.now();t()?this.expired=!0:this.expiryInterval=setInterval((()=>{t()&&(this.expired=!0,clearInterval(this.expiryInterval))}),1e3)}loadFromProp(){try{if(!this.orderData)return void(this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود"));const s="string"==typeof this.orderData?JSON.parse(this.orderData):this.orderData;this.order=s}catch(s){this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود")}finally{this.loading=!1}}handleItemUpdated(s){if(!this.order)return;const{itemId:t,quantity:e,options:a}=s.detail,i=this.payload.items.update.filter((s=>s.id!==t));i.push({id:t,quantity:e,options:a??[]}),this.payload={...this.payload,items:{...this.payload.items,update:i}},this.order={...this.order,items:this.order.items.map((s=>s.id===t?{...s,quantity:e}:s))}}handleItemRemoved(s){if(!this.order)return;if(this.order.items.length<=1)return void salla.notify.error(salla.lang.getWithDefault("pages.orders.order_cannot_be_empty","لا يمكن إزالة جميع المنتجات من الطلب"));const{itemId:t}=s.detail;this.payload={...this.payload,items:{update:this.payload.items.update.filter((s=>s.id!==t)),remove:[...this.payload.items.remove,t]}},this.order={...this.order,items:this.order.items.filter((s=>s.id!==t))}}get hasChanges(){return this.payload.items.update.length>0||this.payload.items.remove.length>0}async saveOrder(){if(this.hasChanges){this.saveLoading=!0;try{const s=await salla.order.api.editOrder(this.orderId,this.payload);this.editPreview=s?.data?.data||s?.data,await(this.saveModal?.open())}catch(s){const t=s?.response?.data?.error?.message||s?.response?.data?.message;t&&salla.notify.error(t)}finally{this.saveLoading=!1}}}navigateToOrder(){const s=new URL(window.location.href);s.pathname=s.pathname.replace(/\/edit\/?$/,""),s.search="",window.location.href=s.href}handleConfirm(){this.confirming=!0,this.editPreview?.payment?.required&&this.editPreview.payment.payment_url?window.location.href=this.editPreview.payment.payment_url:this.navigateToOrder()}async cancelEditSession(){try{await salla.order.api.cancelEditSession(this.orderId),this.navigateToOrder()}catch(s){const t=s?.response?.data?.error?.message||s?.response?.data?.message;t&&salla.notify.error(t)}}renderSaveModal(){const s=this.editPreview,e=s?.totals?.remaining_amount?.amount>0,a=s?.totals?.refund_amount?.amount>0,i=s?.totals?.tax?.amount?.amount;return t("salla-modal",{ref:s=>this.saveModal=s,width:"md",onModalVisibilityChanged:async s=>{s.detail||(this.editPreview=null,this.confirming||await this.cancelEditSession(),this.confirming=!1)}},t("div",{class:"s-order-edit-modal"},t("h2",{class:"s-order-edit-modal-title"},salla.lang.getWithDefault("pages.orders.edit_summary_title","ملخص الطلب بعد التعديل")),s?.items?.length>0&&t("div",{class:"s-order-edit-modal-items"},s.items.map((s=>{const e=this.order?.items?.find((t=>t.id==s.id)),a=e?.product?.image?.url,i=s.options?.join("/ ");return t("div",{class:"s-order-edit-modal-item"},t("div",{class:"s-order-edit-modal-item-start"},a&&t("img",{src:a,alt:s.name,class:"s-order-edit-modal-item-image"}),t("div",null,t("p",{class:"s-order-edit-modal-item-name"},s.name),i&&t("span",{class:"s-order-edit-modal-item-options"},i))),t("div",{class:"s-order-edit-modal-item-end"},t("span",{class:"s-order-edit-modal-item-price",innerHTML:salla.money(s.price.amount)})))}))),s?.totals?.updated_products_total&&t("div",{class:"s-order-edit-modal-row"},t("span",{class:"s-order-edit-modal-row-label"},salla.lang.getWithDefault("pages.orders.modified_products_total","مجموع المنتجات المعدلة")),t("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(s.totals.updated_products_total.amount)})),i>0&&t("div",{class:"s-order-edit-modal-row"},t("span",{class:"s-order-edit-modal-tax-label"},t("i",{class:"sicon-info-circle s-order-edit-modal-tax-icon"}),salla.lang.getWithDefault("pages.orders.vat","ضريبة القيمة المضافة")),t("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(i)})),s?.totals?.total&&t("div",{class:"s-order-edit-modal-total"},t("span",{class:"s-order-edit-modal-total-label"},salla.lang.getWithDefault("pages.orders.order_total","اجمالي الطلب")),t("span",{class:"s-order-edit-modal-total-value",innerHTML:salla.money(s.totals.total.amount)})),a&&t("div",{class:"s-order-edit-modal-refund"},t("i",{class:"sicon-info-circle s-order-edit-modal-refund-icon"}),t("p",{class:"s-order-edit-modal-refund-text"},salla.lang.getWithDefault("pages.orders.refund_message","سيتم تحويل فارق المبلغ على نفس وسيلة الدفع"))),t("div",{class:"s-order-edit-modal-btn-wrapper"},t("salla-button",{onClick:()=>this.handleConfirm()},e?salla.lang.getWithDefault("pages.orders.pay_difference","دفع فارق المبلغ"):a?salla.lang.getWithDefault("pages.orders.confirm_and_receive_difference","تأكيد واستلام فارق المبلغ"):salla.lang.getWithDefault("pages.orders.confirm_changes","تأكيد التعديلات"),t("i",{class:"sicon-keyboard_arrow_left s-order-edit-modal-btn-icon"})))))}render(){if(this.loading)return t(e,null,t("salla-loading",null));if(this.expired)return t(e,null,t("div",{class:"s-order-edit-expired"},t("p",null,salla.lang.getWithDefault("pages.orders.edit_session_expired","انتهت مدة التعديل المتاحة")),t("salla-button",{onClick:()=>this.navigateToOrder()},salla.lang.getWithDefault("pages.orders.back_to_order","العودة إلى تفاصيل الطلب"))));if(this.error||!this.order)return t(e,null,t("div",{class:"no-content-placeholder"},t("i",{class:"sicon-shopping-bag icon"}),t("p",null,this.error)));const s=this.order.items&&this.order.items.length>0,a=this.order.customer_editing_session?.ends_at;return t(e,null,a&&t("div",{class:"s-order-edit-timer-wrapper"},t("salla-count-down",{prefixText:salla.lang.getWithDefault("pages.orders.edit_within","يمكنك التعديل خلال"),date:a,horizontal:!0,withButton:!0,autoSegments:!0,labeled:!1,size:"sm",color:"primary"})),t("div",{class:"s-order-edit-items-wrapper"},t("h2",{class:"s-order-edit-items-title"},salla.lang.getWithDefault("pages.orders.order_products","منتجات الطلب")),s?this.order.items.map(((s,e)=>[t("salla-order-edit-item",{key:s.id,item:s,orderId:this.orderId}),e<this.order.items.length-1?t("div",{class:"s-order-edit-items-divider"}):null])):t("div",{class:"no-content-placeholder"},t("i",{class:"sicon-shopping-bag icon"}),t("p",null,salla.lang.getWithDefault("common.elements.no_items","لا توجد عناصر")))),t("div",{class:"s-order-edit-actions"},t("salla-button",{onClick:()=>this.saveOrder(),loading:this.saveLoading,disabled:!this.hasChanges},salla.lang.getWithDefault("pages.orders.save_changes","حفظ التعديلات")),t("salla-button",{color:"gray",fill:"outline",onClick:()=>this.cancelEditSession()},salla.lang.getWithDefault("common.elements.cancel","الغاء"))),this.renderSaveModal())}get host(){return a(this)}};i.style="";export{i as salla_order_edit}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,c as s,h as i,H as e,a}from"./p-rIbWLXjW.js";import{a as o}from"./p-CgtvEd63.js";import{S as r}from"./p-DiKTtDW5.js";import{H as h}from"./p-CHf8XdiS.js";const l=class{constructor(i){t(this,i),this.productsFetched=s(this,"productsFetched"),this.autoload=!1,this.productCardComponent="custom-salla-product-card",this.page=1,this.placeholderText=salla.lang.get("pages.categories.no_products"),this.endOfText=salla.lang.get("common.elements.end_of_content"),this.failedLoadMore=salla.lang.get("common.elements.failed_to_load_more"),this.currentPage=salla.config.get("page"),this.filtersSnapshot=[],this.lastViewedProductKey="lastViewedProductId",this.filtersKey="filters",this.infiniteScrollStateKey="infiniteScrollState",this.prevCategoryIdKey="prevCategoryId",this.isProcessing=!1,this.scrollTimeout=null,this.boundScrollToLastViewedProduct=()=>this.scrollToLastViewedProduct(),this.boundHandleScroll=()=>this.handleScroll(),this.specialPagesWithoutIds={"product.index.latest":"latest","product.index.offers":"offers","product.index.search":"search","product.index.sales":"sales"},this.includes=h.parseJson(this.includes||this.host.getAttribute("includes")),Array.isArray(this.includes)||(this.includes=null),h.setIncludes(this.includes),salla.lang.onLoaded((()=>{this.placeholderText=salla.lang.get("pages.categories.no_products"),this.endOfText=salla.lang.get("common.elements.end_of_content"),this.failedLoadMore=salla.lang.get("common.elements.failed_to_load_more"),this.currentPage=salla.config.get("page")}))}connectedCallback(){"scrollRestoration"in history&&(history.scrollRestoration="manual"),window.addEventListener("DOMContentLoaded",this.boundScrollToLastViewedProduct),salla.event.on("salla-filters::changed",(t=>this.setFilters(t)))}disconnectedCallback(){window.removeEventListener("DOMContentLoaded",this.boundScrollToLastViewedProduct),window.removeEventListener("scroll",this.boundHandleScroll)}async setFilters(t){if(t&&JSON.stringify(t)!==JSON.stringify(this.parsedFilters))return window.scrollTo({top:0,behavior:"smooth"}),this.parsedFilters=JSON.parse(JSON.stringify(t)),this.filtersSnapshot=this.parsedFilters,"product.index"==this.currentPage?.slug&&this.parsedFilters&&this.parsedFilters.category_id&&(this.currentCategoryIdFilter=[this.parsedFilters.category_id]),this.reload()}async reload(){!this.autoload&&this.loadMoreWrapper&&(this.loadMoreWrapper.style.display="none"),this.hasInfiniteScroll&&salla.infiniteScroll.destroy(this.infiniteScroll),this.buildNextPageUrl(),this.wrapper.innerHTML="",this.hasInfiniteScroll?this.init():this.getInitialData(),this.showPlaceholder&&(this.showPlaceholder=!1,this.placeholderLoader=document.createElement("div"),this.placeholderLoader.classList.add("s-products-list-loading-wrapper"),this.placeholderLoader.style.display="inherit",this.placeholderLoader.innerHTML='<span class="s-button-loader s-button-loader-center s-infinite-scroll-btn-loader"></span>',this.host.insertAdjacentElement("afterend",this.placeholderLoader))}isFilterable(){return salla.config.get("store.settings.product.filters")&&this.filtersResults}isSourceWithoutValue(){return["offers","latest","sales","wishlist","top-rated","reorder"].includes(this.getSource())}animateItems(){o({targets:"salla-products-list salla-product-card",opacity:[0,1],duration:1200,translateY:[20,0],delay:function(t,s){return 100*s}})}initBaseNextPageUrl(t){this.nextPage=salla.url.api(`products?source=${t}`),this.includes?.length&&(this.nextPage+=`&includes[]=${this.includes.join("&includes[]=")}`),this.limit&&(this.nextPage+=`&per_page=${this.limit>32?32:this.limit}`),this.sortBy&&(this.nextPage+=`&sort=${this.sortBy}`),"preview"===salla.config.get("theme.mode")&&(this.nextPage+="&use_username_url=1"),this.nextPage+="&filterable=1";for(const[t,s]of Object.entries(this.parsedFilters||{}))if(["string","number"].includes(typeof s))this.nextPage+=`&filters[${encodeURIComponent(t)}]=${encodeURIComponent(s)}`;else if(Array.isArray(s))s.forEach((s=>this.nextPage+=`&filters[${encodeURIComponent(t)}][]=${encodeURIComponent(s)}`));else if("object"==typeof s)for(const[i,e]of Object.entries(s))this.nextPage+=`&filters[${encodeURIComponent(t)}][${encodeURIComponent(i)}]=${encodeURIComponent(e)}`}buildNextPageUrl(){let t=this.getSource();if("json"===t)return;const s=sessionStorage.getItem(this.infiniteScrollStateKey);if(s){const{nextPage:t}=JSON.parse(s);if(!t)return}if(this.initBaseNextPageUrl(t),!this.isSourceWithoutValue())if(["search","related","landing-page"].includes(t))this.nextPage+=`&source_value=${this.getSourceValue()}`;else try{this.nextPage+=`&source_value[]=${this.getSourceValue().join("&source_value[]=")}`}catch(s){salla.logger.warn(`source-value prop should be array of ids ex source-value="[1,2,3]" for the source [${t}]`),this.sourceValueIsValid=!1}}loading(t=!0,s=!1){if(t){let t=s&&!this.autoload?this.btnLoader:this.loader;t&&(t.style.display="inherit")}else this.autoload||this.btnLoader&&(this.btnLoader.style.display="none"),this.loader&&(this.loader.style.display="none")}getItemHTML(t){"landing-page"===this.getSource()&&(t.url="");const s=document.createElement(this.hasCustomComponent?this.productCardComponent:"salla-product-card");return s.product=t,this.compactCards&&(s.compact=!0,s.toggleAttribute("compact",!0)),this.applyLandingPageStyles(s),this.applyHorizontalCardStyles(s),s.addEventListener("click",(s=>{s.target.closest("a")&&(h.saveProductSource(this.getSource()),this.hasInfiniteScroll&&(this.takeStateSnapshot(),sessionStorage.setItem(this.lastViewedProductKey,t.id)))})),s}applyLandingPageStyles(t){"landing-page"!==this.getSource()||this.hasCustomComponent||(t.toggleAttribute("hide-add-btn",!0),t.classList.add("s-product-card-fit-height"))}applyHorizontalCardStyles(t){this.horizontalCards&&(t.toggleAttribute("horizontal",!0),this.hasCustomComponent||t.toggleAttribute("shadow-on-hover",!0))}waitForResizing(t){let s=null;return new Promise((i=>{const e=new ResizeObserver((()=>{clearTimeout(s),s=setTimeout((()=>{e.disconnect(),i(null)}),160)}));e.observe(t)}))}waitForLayoutStable(t){let s=null;return new Promise((i=>{const e=new MutationObserver((()=>{clearTimeout(s),s=setTimeout((()=>{e.disconnect(),i(null)}),160)}));e.observe(t,{childList:!0,subtree:!0,attributes:!0})}))}async waitForStableLayout(t){return await Promise.allSettled([this.waitForResizing(t),this.waitForLayoutStable(t)])}scrollToLastViewedProduct(){const t=sessionStorage.getItem(this.lastViewedProductKey);t&&!salla.url.is_page("product.single")&&this.isElementLoaded(`[id*="${t}"]`).then((()=>{const s=this.wrapper?.querySelector(`[id*="${t}"]`);if(!s)return;const i=()=>{const t=()=>{s.scrollIntoView({block:"start",behavior:"instant"});const t=matchMedia("(max-width: 1024px)").matches?"header .inner":"ul.main-menu",i=window?.header_is_sticky?document.querySelector(t)?.getBoundingClientRect()?.height??56:0,e=parseInt(getComputedStyle(this.wrapper).rowGap)??16;scrollBy({top:-1*(i+e),behavior:"instant"})};requestAnimationFrame(t),s.querySelectorAll("img.lazy").forEach((s=>{const i=s,e=()=>{requestAnimationFrame(t),i.onload=i.onerror=null};i.onload=e,i.onerror=e})),this.removeScrollRestorationSession()};this.waitForStableLayout(this.host).then((()=>requestAnimationFrame(i)))}))}isElementLoaded(t){return new Promise((s=>{const i=setInterval((()=>{if(document.querySelector(t))return clearInterval(i),s(document.querySelector(t))}),50)}))}takeStateSnapshot(){const t=[];for(let s=0;s<this.wrapper.children.length;s++){const i=this.wrapper.children?.[s];t.push(i.product)}const s={pageIndex:Math.max((this.infiniteScroll?.pageIndex??1)-1,1),nextPage:this.nextPage,currentPageData:t};if(this.isFilterable()){const t=sessionStorage.getItem(this.filtersKey);sessionStorage.setItem(this.filtersKey,t||JSON.stringify(this.filtersSnapshot))}sessionStorage.setItem(this.infiniteScrollStateKey,JSON.stringify(s));let i=salla.config.get("page.id");const e=Object.keys(this.specialPagesWithoutIds).find((t=>salla.url.is_page(t)));e?i=this.specialPagesWithoutIds[e]:null!==i&&(i=String(i)),sessionStorage.setItem(this.prevCategoryIdKey,i)}removeScrollRestorationSession(){this.isFilterable()||sessionStorage.removeItem(this.filtersKey),sessionStorage.removeItem(this.infiniteScrollStateKey),sessionStorage.removeItem(this.lastViewedProductKey),sessionStorage.removeItem(this.prevCategoryIdKey)}loadStoredScrollState(){const t=sessionStorage.getItem(this.infiniteScrollStateKey),s=sessionStorage.getItem(this.filtersKey),i=sessionStorage.getItem(this.prevCategoryIdKey),e=this.specialPagesWithoutIds[salla.config.get("page.slug")]||null,a=salla.config.get("page.id"),o=salla.url.is_page("index"),r=salla.url.is_page("product.single"),h=e?i!==e:i!==String(a);if(i&&h&&!o&&!r||o&&!this.hasInfiniteScroll)return this.removeScrollRestorationSession(),this.switchToNormalBehavior=!0,!1;if(r)return this.switchToNormalBehavior=!0,!1;if(t)try{const{pageIndex:i,nextPage:e,currentPageData:a}=JSON.parse(t);if("undefined"!==s){const t=JSON.parse(s);salla.event.emit("filters::fetched",{filters:t})}this.page=i,this.nextPage=e;for(let t=0;t<a.length;t++)this.wrapper.append(this.getItemHTML(a?.[t]));return!0}catch(t){console.error("Failed to load stored scroll state:",t),this.removeScrollRestorationSession()}return!1}getSource(){return h.getProductsSource(this.source)}getSourceValue(){return this.currentCategoryIdFilter?this.currentCategoryIdFilter:h.getProductsSourceValue(this.source,this.sourceValue)}appendDataLayer(t){"object"==typeof dataLayer&&Array.isArray(dataLayer)&&dataLayer.push({event:"impressions",ecommerce:{currencyCode:salla.config.currency().code,impressions:t.map(((t,s)=>({id:t.id,name:t.name,price:t.price,brand:t.brand?.name||"",quantity:t.quantity,categories:[{name:t.category?.name||salla.config.get("page.title"),id:salla.config.get("page.id")}],category:t.category?.name||salla.config.get("page.title"),position:s+1})))}})}initiateInfiniteScroll(){if(!this.hasInfiniteScroll)return;const t=this.autoload&&this.includes&&this.includes.length>0;this.infiniteScroll=salla.infiniteScroll.initiate(this.wrapper,this.wrapper,{path:()=>this.nextPage,history:!1,nextPage:this.nextPage,scrollThreshold:!t&&!!this.autoload&&100,loadOnScroll:!t&&this.autoload},!0),this.infiniteScroll.pageIndex=this.page,this.infiniteScroll?.on("request",(()=>{this.loading(!0,!this.autoload)})),t&&window.addEventListener("scroll",this.boundHandleScroll),this.infiniteScroll?.on("load",(async t=>{if(!this.isProcessing){this.isProcessing=!0;try{if(!t.data?.length&&2===this.infiniteScroll.pageIndex)return this.showPlaceholder=!0,salla.infiniteScroll.destroy(this.infiniteScroll),this.loading(!1),void(this.placeholderLoader&&this.placeholderLoader.remove());this.includes&&await this.injectAndProcessData(t);const s=this.handleResponse(t);this.infiniteScroll.appendItems(s),2===this.infiniteScroll.pageIndex&&(!this.autoload&&this.nextPage&&(this.loadMoreWrapper.style.display="block"),this.animateItems())}catch(t){console.error("Error during load:",t)}finally{this.isProcessing=!1}}})),this.infiniteScroll?.on("error",(()=>{console.log("Error occurred during request"),this.status.querySelector(".s-infinite-scroll-error").classList.remove("s-hidden"),this.placeholderLoader&&this.placeholderLoader.remove(),this.loading(!1),this.isProcessing=!1})),salla.onReady((()=>{sessionStorage.getItem(this.infiniteScrollStateKey)||this.manualLoadNextPage()}))}handleScroll(){this.isProcessing||this.scrollTimeout||(this.scrollTimeout=setTimeout((()=>{this.scrollTimeout=null,requestAnimationFrame((()=>{const t=this.wrapper.getBoundingClientRect(),s=window.innerHeight;t.bottom-s<=200&&!this.isProcessing&&this.nextPage&&this.manualLoadNextPage()}))}),200))}manualLoadNextPage(){this.nextPage&&this.infiniteScroll.loadNextPage()}async injectAndProcessData(t){try{await h.injectExtraFieldsToResponse(t)}catch(t){console.error("Error injecting data:",t)}}getInitialData(){return this.loading(),salla.api.withoutNotifier((()=>salla.product.api.fetch({source:h.getApiSource(this.getSource()),source_value:this.getSourceValue(),limit:this.limit}).then((async t=>t.data.length?(await h.injectExtraFieldsToResponse(t),this.firstPageResponse?void this.handleResponse(t).forEach((t=>this.wrapper.append(t))):(this.firstPageResponse=t,void(this.nextPage=t.cursor?t.cursor.next:this.nextPage))):(this.showPlaceholder=!0,this.placeholderLoader&&this.placeholderLoader.remove(),void this.loading(!1))))))}async loadMore(){this.infiniteScroll?.loadNextPage()}componentWillLoad(){return salla.onReady().then((()=>{this.hasCustomComponent=!!customElements.get(this.productCardComponent),this.sourceValueIsValid=!(!this.getSourceValue()&&!this.isSourceWithoutValue()),this.hasInfiniteScroll=!["json","selected","related","landing-page","recently"].includes(this.getSource())&&!this.limit;let t=new URLSearchParams(window.location.search);try{this.sortBy=this.sortBy||t.get("sort")||t.get("by"),this.parsedFilters=h.extractFiltersFromUrl(t),this.parsedFilters&&this.parsedFilters.category_id&&(this.currentCategoryIdFilter=[this.parsedFilters.category_id])}catch(t){salla.logger.warn("failed to get filters from url",t.message)}if(this.buildNextPageUrl(),this.isReady=!0,!sessionStorage.getItem(this.infiniteScrollStateKey))if(this.sourceValueIsValid){if(!this.hasInfiniteScroll){if("json"===this.getSource())return this.getSourceValue().length?void setTimeout((()=>{this.getSourceValue().map((t=>this.wrapper.append(this.getItemHTML(t))))})):void(this.showPlaceholder=!0);if("selected"!==this.getSource()||this.getSourceValue().length)return this.getInitialData();this.showPlaceholder=!0}}else salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`)}))}async componentDidLoad(){this.hasInfiniteScroll&&this.init(),await Salla.hooks.registerComponent("salla-products-list",this),this.loadStoredScrollState()?(this.autoload?!this.nextPage&&this.loading(!1):this.nextPage?this.loadMoreWrapper&&(this.loadMoreWrapper.style.display="block"):(this.loadMoreWrapper&&(this.loadMoreWrapper.style.display="none"),this.status.querySelector(".s-infinite-scroll-last").classList.remove("s-hidden")),this.scrollToLastViewedProduct()):!this.firstPageResponse&&this.switchToNormalBehavior?this.getInitialData().then((()=>{this.firstPageResponse?(this.handleResponse(this.firstPageResponse,!1).forEach((t=>{this.wrapper.append(t)})),setTimeout((()=>{if(!this.autoload&&this.nextPage&&1==this.infiniteScroll.pageIndex){const t=this.host.querySelector(".s-infinite-scroll-wrapper");t&&(t.style.display="block")}}))):console.error("No response received after getInitialData.")})).catch((t=>{console.error("Error during initial data fetch:",t)})):this.firstPageResponse&&this.handleResponse(this.firstPageResponse,!1).forEach((t=>this.wrapper.append(t)))}canRender(){return this.sourceValueIsValid&&this.isReady}render(){return this.canRender()?this.showPlaceholder?i("div",{class:"s-products-list-placeholder"},i("span",{innerHTML:r}),i("p",null,this.placeholderText)):i(e,{class:"s-products-list"},i("div",{class:{"s-products-list-wrapper":!0,"s-products-list-horizontal-cards":this.horizontalCards&&!this.filtersResults,"s-products-list-vertical-cards":!this.horizontalCards&&!this.rowCards&&!this.filtersResults,"s-products-list-row-cards":this.rowCards,"s-products-list-compact-cards":this.compactCards,"s-products-list-filters-results":this.filtersResults},ref:t=>this.wrapper=t}),i("div",{class:"s-infinite-scroll-status",ref:t=>this.status=t},i("p",{class:"s-infinite-scroll-last infinite-scroll-last s-hidden"},this.endOfText),i("p",{class:"s-infinite-scroll-error infinite-scroll-error s-hidden"},this.failedLoadMore)),this.autoload&&i("div",{class:"s-products-list-loading-wrapper",style:{display:"none"},ref:t=>this.loader=t},i("span",{class:"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader"})),this.hasInfiniteScroll&&this.nextPage&&!this.autoload?i("div",{class:"s-infinite-scroll-wrapper",style:{display:"none"},ref:t=>this.loadMoreWrapper=t},i("button",{onClick:()=>this.loadMore(),class:"s-infinite-scroll-btn s-button-btn s-button-primary"},i("span",{class:"s-button-text s-infinite-scroll-btn-text"},this.loadMoreText?this.loadMoreText:salla.lang.get("common.elements.load_more")),i("span",{class:"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader",ref:t=>this.btnLoader=t,style:{display:"none"}}))):""):""}init(){this.initiateInfiniteScroll(),this.loading()}handleResponse(t,s=!0){if(!t)return[];let i=this.getSource(),e="";if(1===t.cursor?.current){e=h.getPageTitleForSource(i);try{if("search"===this.getSource())e=salla.lang.get("common.elements.search_about",{word:this.getSourceValue()});else if(!e){let s=this.parsedFilters.category_id||this.getSourceValue()[0];e=t.filters?.find((t=>"category_id"===t.key))?.values?.find((t=>t.key===s))?.value??"",this.filtersSnapshot=t.filters}e+=(e?" - ":"")+salla.lang.choice("blocks.header.products_count",t.data?.length),15===t.data.length&&(e=e.replace(t.data.length,salla.lang.get("common.elements.more_than")+" "+t.data.length)),t.title=e}catch(t){salla.logger.error("Error::falid to handle response",t)}h.generateProductSchema(t.data)}this.appendDataLayer(t.data),t.nextPage=this.nextPage,t.source=this.getSource(),t.sourceValue=this.getSourceValue(),salla.event.emit("salla-products-list::products.fetched",t),this.productsFetched.emit(t),t.filters&&this.isFilterable()?(this.filtersResults=!0,this.filtersSnapshot=JSON.parse(JSON.stringify(t.filters)),salla.event.emit("filters::fetched",{filters:t.filters})):this.isFilterable()&&salla.event.emit("filters::hidden"),s&&(this.nextPage=t.cursor?t.cursor.next:this.nextPage),this.loading(!1),this.placeholderLoader&&this.placeholderLoader.remove(),this.hasInfiniteScroll&&!this.nextPage&&(this.infiniteScroll.option({scrollThreshold:!1,loadOnScroll:!1}),this.status.querySelector(".s-infinite-scroll-last").classList.remove("s-hidden"));const a=[];for(let s=0;s<t.data.length;s++)a.push(this.getItemHTML(t.data?.[s]));return a}get host(){return a(this)}};l.style="";export{l as salla_products_list}
4
+ import{r as t,c as s,h as i,H as e,a}from"./p-eYsXdqjv.js";import{a as o}from"./p-CgtvEd63.js";import{S as r}from"./p-DiKTtDW5.js";import{H as h}from"./p-CHf8XdiS.js";const l=class{constructor(i){t(this,i),this.productsFetched=s(this,"productsFetched"),this.autoload=!1,this.productCardComponent="custom-salla-product-card",this.page=1,this.placeholderText=salla.lang.get("pages.categories.no_products"),this.endOfText=salla.lang.get("common.elements.end_of_content"),this.failedLoadMore=salla.lang.get("common.elements.failed_to_load_more"),this.currentPage=salla.config.get("page"),this.filtersSnapshot=[],this.lastViewedProductKey="lastViewedProductId",this.filtersKey="filters",this.infiniteScrollStateKey="infiniteScrollState",this.prevCategoryIdKey="prevCategoryId",this.isProcessing=!1,this.scrollTimeout=null,this.boundScrollToLastViewedProduct=()=>this.scrollToLastViewedProduct(),this.boundHandleScroll=()=>this.handleScroll(),this.specialPagesWithoutIds={"product.index.latest":"latest","product.index.offers":"offers","product.index.search":"search","product.index.sales":"sales"},this.includes=h.parseJson(this.includes||this.host.getAttribute("includes")),Array.isArray(this.includes)||(this.includes=null),h.setIncludes(this.includes),salla.lang.onLoaded((()=>{this.placeholderText=salla.lang.get("pages.categories.no_products"),this.endOfText=salla.lang.get("common.elements.end_of_content"),this.failedLoadMore=salla.lang.get("common.elements.failed_to_load_more"),this.currentPage=salla.config.get("page")}))}connectedCallback(){"scrollRestoration"in history&&(history.scrollRestoration="manual"),window.addEventListener("DOMContentLoaded",this.boundScrollToLastViewedProduct),salla.event.on("salla-filters::changed",(t=>this.setFilters(t)))}disconnectedCallback(){window.removeEventListener("DOMContentLoaded",this.boundScrollToLastViewedProduct),window.removeEventListener("scroll",this.boundHandleScroll)}async setFilters(t){if(t&&JSON.stringify(t)!==JSON.stringify(this.parsedFilters))return window.scrollTo({top:0,behavior:"smooth"}),this.parsedFilters=JSON.parse(JSON.stringify(t)),this.filtersSnapshot=this.parsedFilters,"product.index"==this.currentPage?.slug&&this.parsedFilters&&this.parsedFilters.category_id&&(this.currentCategoryIdFilter=[this.parsedFilters.category_id]),this.reload()}async reload(){!this.autoload&&this.loadMoreWrapper&&(this.loadMoreWrapper.style.display="none"),this.hasInfiniteScroll&&salla.infiniteScroll.destroy(this.infiniteScroll),this.buildNextPageUrl(),this.wrapper.innerHTML="",this.hasInfiniteScroll?this.init():this.getInitialData(),this.showPlaceholder&&(this.showPlaceholder=!1,this.placeholderLoader=document.createElement("div"),this.placeholderLoader.classList.add("s-products-list-loading-wrapper"),this.placeholderLoader.style.display="inherit",this.placeholderLoader.innerHTML='<span class="s-button-loader s-button-loader-center s-infinite-scroll-btn-loader"></span>',this.host.insertAdjacentElement("afterend",this.placeholderLoader))}isFilterable(){return salla.config.get("store.settings.product.filters")&&this.filtersResults}isSourceWithoutValue(){return["offers","latest","sales","wishlist","top-rated","reorder"].includes(this.getSource())}animateItems(){o({targets:"salla-products-list salla-product-card",opacity:[0,1],duration:1200,translateY:[20,0],delay:function(t,s){return 100*s}})}initBaseNextPageUrl(t){this.nextPage=salla.url.api(`products?source=${t}`),this.includes?.length&&(this.nextPage+=`&includes[]=${this.includes.join("&includes[]=")}`),this.limit&&(this.nextPage+=`&per_page=${this.limit>32?32:this.limit}`),this.sortBy&&(this.nextPage+=`&sort=${this.sortBy}`),"preview"===salla.config.get("theme.mode")&&(this.nextPage+="&use_username_url=1"),this.nextPage+="&filterable=1";for(const[t,s]of Object.entries(this.parsedFilters||{}))if(["string","number"].includes(typeof s))this.nextPage+=`&filters[${encodeURIComponent(t)}]=${encodeURIComponent(s)}`;else if(Array.isArray(s))s.forEach((s=>this.nextPage+=`&filters[${encodeURIComponent(t)}][]=${encodeURIComponent(s)}`));else if("object"==typeof s)for(const[i,e]of Object.entries(s))this.nextPage+=`&filters[${encodeURIComponent(t)}][${encodeURIComponent(i)}]=${encodeURIComponent(e)}`}buildNextPageUrl(){let t=this.getSource();if("json"===t)return;const s=sessionStorage.getItem(this.infiniteScrollStateKey);if(s){const{nextPage:t}=JSON.parse(s);if(!t)return}if(this.initBaseNextPageUrl(t),!this.isSourceWithoutValue())if(["search","related","landing-page"].includes(t))this.nextPage+=`&source_value=${this.getSourceValue()}`;else try{this.nextPage+=`&source_value[]=${this.getSourceValue().join("&source_value[]=")}`}catch(s){salla.logger.warn(`source-value prop should be array of ids ex source-value="[1,2,3]" for the source [${t}]`),this.sourceValueIsValid=!1}}loading(t=!0,s=!1){if(t){let t=s&&!this.autoload?this.btnLoader:this.loader;t&&(t.style.display="inherit")}else this.autoload||this.btnLoader&&(this.btnLoader.style.display="none"),this.loader&&(this.loader.style.display="none")}getItemHTML(t){"landing-page"===this.getSource()&&(t.url="");const s=document.createElement(this.hasCustomComponent?this.productCardComponent:"salla-product-card");return s.product=t,this.compactCards&&(s.compact=!0,s.toggleAttribute("compact",!0)),this.applyLandingPageStyles(s),this.applyHorizontalCardStyles(s),s.addEventListener("click",(s=>{s.target.closest("a")&&(h.saveProductSource(this.getSource()),this.hasInfiniteScroll&&(this.takeStateSnapshot(),sessionStorage.setItem(this.lastViewedProductKey,t.id)))})),s}applyLandingPageStyles(t){"landing-page"!==this.getSource()||this.hasCustomComponent||(t.toggleAttribute("hide-add-btn",!0),t.classList.add("s-product-card-fit-height"))}applyHorizontalCardStyles(t){this.horizontalCards&&(t.toggleAttribute("horizontal",!0),this.hasCustomComponent||t.toggleAttribute("shadow-on-hover",!0))}waitForResizing(t){let s=null;return new Promise((i=>{const e=new ResizeObserver((()=>{clearTimeout(s),s=setTimeout((()=>{e.disconnect(),i(null)}),160)}));e.observe(t)}))}waitForLayoutStable(t){let s=null;return new Promise((i=>{const e=new MutationObserver((()=>{clearTimeout(s),s=setTimeout((()=>{e.disconnect(),i(null)}),160)}));e.observe(t,{childList:!0,subtree:!0,attributes:!0})}))}async waitForStableLayout(t){return await Promise.allSettled([this.waitForResizing(t),this.waitForLayoutStable(t)])}scrollToLastViewedProduct(){const t=sessionStorage.getItem(this.lastViewedProductKey);t&&!salla.url.is_page("product.single")&&this.isElementLoaded(`[id*="${t}"]`).then((()=>{const s=this.wrapper?.querySelector(`[id*="${t}"]`);if(!s)return;const i=()=>{const t=()=>{s.scrollIntoView({block:"start",behavior:"instant"});const t=matchMedia("(max-width: 1024px)").matches?"header .inner":"ul.main-menu",i=window?.header_is_sticky?document.querySelector(t)?.getBoundingClientRect()?.height??56:0,e=parseInt(getComputedStyle(this.wrapper).rowGap)??16;scrollBy({top:-1*(i+e),behavior:"instant"})};requestAnimationFrame(t),s.querySelectorAll("img.lazy").forEach((s=>{const i=s,e=()=>{requestAnimationFrame(t),i.onload=i.onerror=null};i.onload=e,i.onerror=e})),this.removeScrollRestorationSession()};this.waitForStableLayout(this.host).then((()=>requestAnimationFrame(i)))}))}isElementLoaded(t){return new Promise((s=>{const i=setInterval((()=>{if(document.querySelector(t))return clearInterval(i),s(document.querySelector(t))}),50)}))}takeStateSnapshot(){const t=[];for(let s=0;s<this.wrapper.children.length;s++){const i=this.wrapper.children?.[s];t.push(i.product)}const s={pageIndex:Math.max((this.infiniteScroll?.pageIndex??1)-1,1),nextPage:this.nextPage,currentPageData:t};if(this.isFilterable()){const t=sessionStorage.getItem(this.filtersKey);sessionStorage.setItem(this.filtersKey,t||JSON.stringify(this.filtersSnapshot))}sessionStorage.setItem(this.infiniteScrollStateKey,JSON.stringify(s));let i=salla.config.get("page.id");const e=Object.keys(this.specialPagesWithoutIds).find((t=>salla.url.is_page(t)));e?i=this.specialPagesWithoutIds[e]:null!==i&&(i=String(i)),sessionStorage.setItem(this.prevCategoryIdKey,i)}removeScrollRestorationSession(){this.isFilterable()||sessionStorage.removeItem(this.filtersKey),sessionStorage.removeItem(this.infiniteScrollStateKey),sessionStorage.removeItem(this.lastViewedProductKey),sessionStorage.removeItem(this.prevCategoryIdKey)}loadStoredScrollState(){const t=sessionStorage.getItem(this.infiniteScrollStateKey),s=sessionStorage.getItem(this.filtersKey),i=sessionStorage.getItem(this.prevCategoryIdKey),e=this.specialPagesWithoutIds[salla.config.get("page.slug")]||null,a=salla.config.get("page.id"),o=salla.url.is_page("index"),r=salla.url.is_page("product.single"),h=e?i!==e:i!==String(a);if(i&&h&&!o&&!r||o&&!this.hasInfiniteScroll)return this.removeScrollRestorationSession(),this.switchToNormalBehavior=!0,!1;if(r)return this.switchToNormalBehavior=!0,!1;if(t)try{const{pageIndex:i,nextPage:e,currentPageData:a}=JSON.parse(t);if("undefined"!==s){const t=JSON.parse(s);salla.event.emit("filters::fetched",{filters:t})}this.page=i,this.nextPage=e;for(let t=0;t<a.length;t++)this.wrapper.append(this.getItemHTML(a?.[t]));return!0}catch(t){console.error("Failed to load stored scroll state:",t),this.removeScrollRestorationSession()}return!1}getSource(){return h.getProductsSource(this.source)}getSourceValue(){return this.currentCategoryIdFilter?this.currentCategoryIdFilter:h.getProductsSourceValue(this.source,this.sourceValue)}appendDataLayer(t){"object"==typeof dataLayer&&Array.isArray(dataLayer)&&dataLayer.push({event:"impressions",ecommerce:{currencyCode:salla.config.currency().code,impressions:t.map(((t,s)=>({id:t.id,name:t.name,price:t.price,brand:t.brand?.name||"",quantity:t.quantity,categories:[{name:t.category?.name||salla.config.get("page.title"),id:salla.config.get("page.id")}],category:t.category?.name||salla.config.get("page.title"),position:s+1})))}})}initiateInfiniteScroll(){if(!this.hasInfiniteScroll)return;const t=this.autoload&&this.includes&&this.includes.length>0;this.infiniteScroll=salla.infiniteScroll.initiate(this.wrapper,this.wrapper,{path:()=>this.nextPage,history:!1,nextPage:this.nextPage,scrollThreshold:!t&&!!this.autoload&&100,loadOnScroll:!t&&this.autoload},!0),this.infiniteScroll.pageIndex=this.page,this.infiniteScroll?.on("request",(()=>{this.loading(!0,!this.autoload)})),t&&window.addEventListener("scroll",this.boundHandleScroll),this.infiniteScroll?.on("load",(async t=>{if(!this.isProcessing){this.isProcessing=!0;try{if(!t.data?.length&&2===this.infiniteScroll.pageIndex)return this.showPlaceholder=!0,salla.infiniteScroll.destroy(this.infiniteScroll),this.loading(!1),void(this.placeholderLoader&&this.placeholderLoader.remove());this.includes&&await this.injectAndProcessData(t);const s=this.handleResponse(t);this.infiniteScroll.appendItems(s),2===this.infiniteScroll.pageIndex&&(!this.autoload&&this.nextPage&&(this.loadMoreWrapper.style.display="block"),this.animateItems())}catch(t){console.error("Error during load:",t)}finally{this.isProcessing=!1}}})),this.infiniteScroll?.on("error",(()=>{console.log("Error occurred during request"),this.status.querySelector(".s-infinite-scroll-error").classList.remove("s-hidden"),this.placeholderLoader&&this.placeholderLoader.remove(),this.loading(!1),this.isProcessing=!1})),salla.onReady((()=>{sessionStorage.getItem(this.infiniteScrollStateKey)||this.manualLoadNextPage()}))}handleScroll(){this.isProcessing||this.scrollTimeout||(this.scrollTimeout=setTimeout((()=>{this.scrollTimeout=null,requestAnimationFrame((()=>{const t=this.wrapper.getBoundingClientRect(),s=window.innerHeight;t.bottom-s<=200&&!this.isProcessing&&this.nextPage&&this.manualLoadNextPage()}))}),200))}manualLoadNextPage(){this.nextPage&&this.infiniteScroll.loadNextPage()}async injectAndProcessData(t){try{await h.injectExtraFieldsToResponse(t)}catch(t){console.error("Error injecting data:",t)}}getInitialData(){return this.loading(),salla.api.withoutNotifier((()=>salla.product.api.fetch({source:h.getApiSource(this.getSource()),source_value:this.getSourceValue(),limit:this.limit}).then((async t=>t.data.length?(await h.injectExtraFieldsToResponse(t),this.firstPageResponse?void this.handleResponse(t).forEach((t=>this.wrapper.append(t))):(this.firstPageResponse=t,void(this.nextPage=t.cursor?t.cursor.next:this.nextPage))):(this.showPlaceholder=!0,this.placeholderLoader&&this.placeholderLoader.remove(),void this.loading(!1))))))}async loadMore(){this.infiniteScroll?.loadNextPage()}componentWillLoad(){return salla.onReady().then((()=>{this.hasCustomComponent=!!customElements.get(this.productCardComponent),this.sourceValueIsValid=!(!this.getSourceValue()&&!this.isSourceWithoutValue()),this.hasInfiniteScroll=!["json","selected","related","landing-page","recently"].includes(this.getSource())&&!this.limit;let t=new URLSearchParams(window.location.search);try{this.sortBy=this.sortBy||t.get("sort")||t.get("by"),this.parsedFilters=h.extractFiltersFromUrl(t),this.parsedFilters&&this.parsedFilters.category_id&&(this.currentCategoryIdFilter=[this.parsedFilters.category_id])}catch(t){salla.logger.warn("failed to get filters from url",t.message)}if(this.buildNextPageUrl(),this.isReady=!0,!sessionStorage.getItem(this.infiniteScrollStateKey))if(this.sourceValueIsValid){if(!this.hasInfiniteScroll){if("json"===this.getSource())return this.getSourceValue().length?void setTimeout((()=>{this.getSourceValue().map((t=>this.wrapper.append(this.getItemHTML(t))))})):void(this.showPlaceholder=!0);if("selected"!==this.getSource()||this.getSourceValue().length)return this.getInitialData();this.showPlaceholder=!0}}else salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`)}))}async componentDidLoad(){this.hasInfiniteScroll&&this.init(),await Salla.hooks.registerComponent("salla-products-list",this),this.loadStoredScrollState()?(this.autoload?!this.nextPage&&this.loading(!1):this.nextPage?this.loadMoreWrapper&&(this.loadMoreWrapper.style.display="block"):(this.loadMoreWrapper&&(this.loadMoreWrapper.style.display="none"),this.status.querySelector(".s-infinite-scroll-last").classList.remove("s-hidden")),this.scrollToLastViewedProduct()):!this.firstPageResponse&&this.switchToNormalBehavior?this.getInitialData().then((()=>{this.firstPageResponse?(this.handleResponse(this.firstPageResponse,!1).forEach((t=>{this.wrapper.append(t)})),setTimeout((()=>{if(!this.autoload&&this.nextPage&&1==this.infiniteScroll.pageIndex){const t=this.host.querySelector(".s-infinite-scroll-wrapper");t&&(t.style.display="block")}}))):console.error("No response received after getInitialData.")})).catch((t=>{console.error("Error during initial data fetch:",t)})):this.firstPageResponse&&this.handleResponse(this.firstPageResponse,!1).forEach((t=>this.wrapper.append(t)))}canRender(){return this.sourceValueIsValid&&this.isReady}render(){return this.canRender()?this.showPlaceholder?i("div",{class:"s-products-list-placeholder"},i("span",{innerHTML:r}),i("p",null,this.placeholderText)):i(e,{class:"s-products-list"},i("div",{class:{"s-products-list-wrapper":!0,"s-products-list-horizontal-cards":this.horizontalCards&&!this.filtersResults,"s-products-list-vertical-cards":!this.horizontalCards&&!this.rowCards&&!this.filtersResults,"s-products-list-row-cards":this.rowCards,"s-products-list-compact-cards":this.compactCards,"s-products-list-filters-results":this.filtersResults},ref:t=>this.wrapper=t}),i("div",{class:"s-infinite-scroll-status",ref:t=>this.status=t},i("p",{class:"s-infinite-scroll-last infinite-scroll-last s-hidden"},this.endOfText),i("p",{class:"s-infinite-scroll-error infinite-scroll-error s-hidden"},this.failedLoadMore)),this.autoload&&i("div",{class:"s-products-list-loading-wrapper",style:{display:"none"},ref:t=>this.loader=t},i("span",{class:"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader"})),this.hasInfiniteScroll&&this.nextPage&&!this.autoload?i("div",{class:"s-infinite-scroll-wrapper",style:{display:"none"},ref:t=>this.loadMoreWrapper=t},i("button",{onClick:()=>this.loadMore(),class:"s-infinite-scroll-btn s-button-btn s-button-primary"},i("span",{class:"s-button-text s-infinite-scroll-btn-text"},this.loadMoreText?this.loadMoreText:salla.lang.get("common.elements.load_more")),i("span",{class:"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader",ref:t=>this.btnLoader=t,style:{display:"none"}}))):""):""}init(){this.initiateInfiniteScroll(),this.loading()}handleResponse(t,s=!0){if(!t)return[];let i=this.getSource(),e="";if(1===t.cursor?.current){e=h.getPageTitleForSource(i);try{if("search"===this.getSource())e=salla.lang.get("common.elements.search_about",{word:this.getSourceValue()});else if(!e){let s=this.parsedFilters.category_id||this.getSourceValue()[0];e=t.filters?.find((t=>"category_id"===t.key))?.values?.find((t=>t.key===s))?.value??"",this.filtersSnapshot=t.filters}e+=(e?" - ":"")+salla.lang.choice("blocks.header.products_count",t.data?.length),15===t.data.length&&(e=e.replace(t.data.length,salla.lang.get("common.elements.more_than")+" "+t.data.length)),t.title=e}catch(t){salla.logger.error("Error::falid to handle response",t)}h.generateProductSchema(t.data)}this.appendDataLayer(t.data),t.nextPage=this.nextPage,t.source=this.getSource(),t.sourceValue=this.getSourceValue(),salla.event.emit("salla-products-list::products.fetched",t),this.productsFetched.emit(t),t.filters&&this.isFilterable()?(this.filtersResults=!0,this.filtersSnapshot=JSON.parse(JSON.stringify(t.filters)),salla.event.emit("filters::fetched",{filters:t.filters})):this.isFilterable()&&salla.event.emit("filters::hidden"),s&&(this.nextPage=t.cursor?t.cursor.next:this.nextPage),this.loading(!1),this.placeholderLoader&&this.placeholderLoader.remove(),this.hasInfiniteScroll&&!this.nextPage&&(this.infiniteScroll.option({scrollThreshold:!1,loadOnScroll:!1}),this.status.querySelector(".s-infinite-scroll-last").classList.remove("s-hidden"));const a=[];for(let s=0;s<t.data.length;s++)a.push(this.getItemHTML(t.data?.[s]));return a}get host(){return a(this)}};l.style="";export{l as salla_products_list}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as a,h as t,H as s,a as e}from"./p-rIbWLXjW.js";const i=class{constructor(t){if(a(this,t),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(a){salla.log("Bad json passed via entityId prop")}}getValue(a){if("file"===a.type)return`<a href="${a.value}" class="text-primary" target="_blank"><span class="sicon-download"></span> ${this.download}</a>`;if("url"===a.type)return`<a href="${a.value}" class="text-blue-700 underline" target="_blank">${a.value}</a>`;if("date"===a.type){const t=new Date(a.value);return`${String(t.getDate()).padStart(2,"0")}/${String(t.getMonth()+1).padStart(2,"0")}/${t.getFullYear()}`}return a.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 a=await Salla.api.metadata.fetchValues(this.entity,this.entityId);this.specs=a.data[0]?.sections}render(){if(this.specs.length)return t(s,{class:"s-metadata-wrapper"},this.specs.map((a=>t("div",{class:"s-metadata-box"},t("div",{class:"s-metadata-box-header"},t("i",{class:"sicon-list"}),a.name),a.fields.map((a=>t("div",{class:"s-metadata-row"},t("p",{class:"s-metadata-row-name"},a.name),t("p",{class:"s-metadata-row-value",innerHTML:this.getValue(a)}))))))))}get host(){return e(this)}};i.style="";export{i as salla_metadata}
4
+ import{r as a,h as s,H as t,a as e}from"./p-eYsXdqjv.js";const i=class{constructor(s){if(a(this,s),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(a){salla.log("Bad json passed via entityId prop")}}getValue(a){if("file"===a.type)return`<a href="${a.value}" class="text-primary" target="_blank"><span class="sicon-download"></span> ${this.download}</a>`;if("url"===a.type)return`<a href="${a.value}" class="text-blue-700 underline" target="_blank">${a.value}</a>`;if("date"===a.type){const s=new Date(a.value);return`${String(s.getDate()).padStart(2,"0")}/${String(s.getMonth()+1).padStart(2,"0")}/${s.getFullYear()}`}return a.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 a=await Salla.api.metadata.fetchValues(this.entity,this.entityId);this.specs=a.data[0]?.sections}render(){if(this.specs.length)return s(t,{class:"s-metadata-wrapper"},this.specs.map((a=>s("div",{class:"s-metadata-box"},s("div",{class:"s-metadata-box-header"},s("i",{class:"sicon-list"}),a.name),a.fields.map((a=>s("div",{class:"s-metadata-row"},s("p",{class:"s-metadata-row-name"},a.name),s("p",{class:"s-metadata-row-value",innerHTML:this.getValue(a)}))))))))}get host(){return e(this)}};i.style="";export{i as salla_metadata}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as t,a as e}from"./p-rIbWLXjW.js";var o,i;!function(s){s.ProductDetail="product.single",s.Cart="cart"}(o||(o={})),function(s){s.Conditional="conditional",s.PercentageOrFixed="fixed",s.DiscountsTable="discounts_table",s.Bank="bank",s.BuyXGetY="buy_x_get_y",s.SpecialPrice="special_price",s.Percentage="percentage",s.FixedAmount="fixed_amount"}(i||(i={}));const r=class{constructor(t){s(this,t),this.productCardComponent="salla-product-card",this.offersList=[],this.canRender=!1,this.showOffer=salla.config.get("store.settings.product.show_special_offers"),this.showAllOffersModal=!1,this.showProductsModal=!1,this.selectedOfferProducts=[],this.collapsedOffers={},this.expandedCategories={},this.productsLoaded=!1,this.offer_with_price_text=salla.lang.get("pages.offer.with_price",{price:""}),this.with_discount_text=salla.lang.get("pages.products.with_a_discount"),this.product_discount_text=salla.lang.get("pages.products.discount"),this.special_offer_text=salla.lang.get("pages.products.special_offer"),this.buy_quantity_text=s=>salla.lang.get("pages.offer.buy_quantity",{quantity:s}),this.products_link_text=salla.lang.get("pages.offer.included_products","المنتجات المشمولة"),this.min_spend_text=(s,t)=>salla.lang.get("pages.offer.min_spend_amount",{amount:s,currency:t},`بحد أدنى ${s} ${t} من مبلغ الشراء`),this.min_items_text=s=>salla.lang.get("pages.offer.min_items",{items:s},`بحد أدنى ${s} منتجات`),this.product_text=salla.lang.get("common.elements.product","منتج"),salla.lang.onLoaded((()=>{this.offer_with_price_text=salla.lang.get("pages.offer.with_price"),this.with_discount_text=salla.lang.get("pages.products.with_a_discount"),this.product_discount_text=salla.lang.get("pages.products.discount"),this.special_offer_text=salla.lang.get("pages.products.special_offer"),this.buy_quantity_text(0),this.products_link_text=salla.lang.get("pages.offer.included_products","المنتجات المشمولة"),this.min_spend_text=(s,t)=>salla.lang.get("pages.offer.min_spend_amount",{amount:s,currency:t},`بحد أدنى ${s} ${t} من مبلغ الشراء`),this.min_items_text=s=>salla.lang.get("pages.offer.min_items",{items:s},`بحد أدنى ${s} منتجات`),this.product_text=salla.lang.get("common.elements.product","منتج")})),salla.onReady((()=>{this.currentPage=salla.config.get("page.slug");const s=salla.config.get("currencies")||{},t=salla.config.get("user.currency_code");this.userCurrency=s[t]||{symbol:"",code:t||"SAR",name:""}}))}async getEndpointByPageName(){return this.currentPage==o.Cart?`offers/cart/${await Salla.cart.getCurrentCartId()}`:this.currentPage==o.ProductDetail?`offers/product/${salla.config.get("page.id")}`:"offers"}emitPromotionViewed(){if(!(this.offersList.length&&this.canRender&&this.showOffer))return;const s=this.offersList.slice(0,5).map(((s,t)=>({id:s.id,name:s.title,creative:s.description||"",position:t+1})));salla.event.emit("salla::offer.promotion.viewed",s)}emitPromotionClicked(s,t=1){if(!(this.offersList.length&&this.canRender&&this.showOffer))return;const e=s||this.offersList[0];salla.event.emit("salla::offer.promotion.clicked",[{id:e.id,name:e.title,creative:e.description||"",position:t}])}componentWillLoad(){return this.hasCustomComponent=!!customElements.get(this.productCardComponent),new Promise((s=>salla.onReady(s))).then((()=>{if(this.showOffer=!salla.url.is_page("product.single")||salla.config.get("store.settings.product.show_special_offers"),!this.showOffer)throw new Error("Merchant disabled showing the offers on product page")})).then((async()=>salla.api.request(await this.getEndpointByPageName()))).then((async s=>{if(!(this.offersList=s.data).length)throw new Error("salla-offers:: There is no offers!");if(this.offersList=this.offersList.filter((s=>[i.SpecialPrice,i.Bank,i.BuyXGetY,i.DiscountsTable,i.PercentageOrFixed,i.Percentage,i.FixedAmount].includes(s.type))),!this.offersList.length)throw new Error("salla-offers:: No supported offer types found!");let t=null;this.offersList.some((s=>{const t=s.details;return"category"===t.apply_to&&t.targets||"categories"===t.apply_to&&t.targets||s.type===i.BuyXGetY&&("categories"===t.get?.source||"category"===t.get?.source)}))&&(t=(await salla.product.api.categories()).data);const e=new Set;for(const s of this.offersList){const t=s.details;"product"!==t.apply_to&&"products"!==t.apply_to||!t.targets||t.targets.forEach((s=>e.add(s))),s.type===i.BuyXGetY&&"products"===t.get?.source&&t.get?.source_value&&t.get.source_value.forEach((s=>e.add(s))),s.type!==i.BuyXGetY||"products"!==t.buy?.source&&"product"!==t.buy?.source||!t.buy?.source_value||t.buy.source_value.forEach((s=>e.add(s)))}let o={};if(e.size>0)try{const s=await salla.product.api.fetch({source:"selected",source_value:Array.from(e)});o=Object.fromEntries(s.data.map((s=>[s.id,s])))}catch(s){o={}}for(const s of this.offersList){const e=s.details;if(("category"===e.apply_to&&e.targets||"categories"===e.apply_to&&e.targets)&&t&&(e.categories=this.findCategories(t,e.targets)),"product"!==e.apply_to&&"products"!==e.apply_to||!e.targets||(e.products=e.targets.map((s=>o[s])).filter(Boolean)),"brand"===e.apply_to&&e.targets&&(e.brands=e.targets),s.type===i.BuyXGetY&&e.get){const s=e.get;"products"===s.source&&s.source_value?s.products=s.source_value.map((s=>o[s])).filter(Boolean):("categories"===s.source||"category"===s.source)&&t&&s.source_value&&(s.categories=this.findCategories(t,s.source_value),e.categories=s.categories)}if(s.type===i.BuyXGetY&&e.buy){const s=e.buy;"products"!==s.source&&"product"!==s.source||!s.source_value||(s.products=s.source_value.map((s=>o[s])).filter(Boolean))}}return this.offersList})).then((()=>{this.canRender=!0})).catch((s=>{salla.logger.warn(s)}))}componentDidLoad(){let s=this.host.querySelector(".s-slider-block__title-nav");s?.classList.add("s-offer-bank-payment-nav"),this.emitPromotionViewed()}findCategories(s,t){let e=[];for(const o of s)t.includes(o.id_||o.id)&&e.push(o),o.sub_categories?.length>0&&(e=e.concat(this.findCategories(o.sub_categories,t)));return e}render(){if(!this.offersList.length||!this.canRender||!this.showOffer)return null;const s=salla.lang.get("pages.offer.offers_title","عروض المنتج"),e=salla.lang.get("pages.offer.offers_subtitle","احصل على المنتج بسعر مخفض مع أفضل العروض");return[t("div",{class:"s-offer-wrapper"},t("salla-slider",{type:"carousel",id:"offers-slider","block-title":s,"block-subTitle":e,"show-controls":this.offersList.length>1},t("div",{slot:"items"},this.offersList.slice(0,5).map(((s,t)=>this.renderOfferCard(s,t+1))),this.offersList.length>5&&this.renderShowMoreCard()))),this.renderAllOffersModal(),this.renderProductsModal()]}renderShowMoreCard(){return t("div",{class:"s-offer-slide-one-fourth swiper-slide",onClick:s=>{s.preventDefault(),s.stopPropagation(),this.openAllOffersModal()}},t("div",{class:"s-offer-card s-offer-show-more-card"},t("i",{class:"sicon-add s-offer-show-more-icon"}),t("h3",{class:"s-offer-show-more-title"},salla.lang.get("pages.offer.show_more_offers","عرض المزيد من العروض"))))}openAllOffersModal(){this.showAllOffersModal=!0}closeAllOffersModal(){this.showAllOffersModal=!1}closeProductsModal(){this.showProductsModal=!1,this.selectedOfferProducts=[],this.productsLoaded=!1}handleAccordionToggle(s,t){this.collapsedOffers={...this.collapsedOffers,[s]:t}}getOfferProducts(s){const t=s.details;return t.products&&t.products.length>0?t.products:s.type===i.BuyXGetY&&t.get?.products?t.get.products:[]}renderProductsLinkForModalCard(s,e){const o=this.getOfferProducts(s);return o&&0!==o.length?t("div",{class:"s-offer-products-link",onClick:s=>{s.stopPropagation(),this.selectedOfferProducts=o,this.showProductsModal=!0}},t("span",{class:"s-offer-products-link-text"},this.products_link_text),e&&t("i",{class:"sicon-keyboard_arrow_down s-offer-products-link-icon"})):null}renderAllOffersModal(){return t("salla-drawer",{visible:this.showAllOffersModal,position:"right",width:"md","no-padding":!0,"drawer-title":salla.lang.get("pages.offer.all_offers_title","جميع العروض"),onDrawerVisibilityChanged:s=>!s.detail&&this.closeAllOffersModal()},t("div",{class:"s-offer-drawer-content"},this.offersList.map(((s,t)=>this.renderModalOfferCard(s,t+1)))))}renderProductsModal(){return t("salla-drawer",{visible:this.showProductsModal,width:"md",position:"right","no-padding":!0,"drawer-title":this.products_link_text,onDrawerVisibilityChanged:s=>!s.detail&&this.closeProductsModal()},t("div",{class:"s-offer-products-drawer-content"},this.selectedOfferProducts?.length>0?t("div",null,!this.productsLoaded&&t("div",{class:"flex items-center justify-center p-8"},t("salla-loading",{size:"24"})),t("salla-products-list",{source:"selected","source-value":JSON.stringify(this.selectedOfferProducts.map((s=>s.id))),"product-card-component":this.productCardComponent,"horizontal-cards":!0,"compact-cards":!0,includes:["images"],onProductsFetched:()=>this.productsLoaded=!0})):t("div",{class:"p-4 text-center text-gray-500"},salla.lang.get("blocks.products.no_products_found","لا توجد منتجات"))))}renderModalOfferCard(s,e=1){const o=this.getOfferProducts(s),r=o&&o.length>0,a=!1!==this.collapsedOffers[s.id];return t("div",{class:"s-offer-drawer-card"},t("div",{class:"s-offer-card-main",onClick:()=>this.emitPromotionClicked(s,e)},t("div",{class:"s-offer-card-icon"},this.getOfferIcon(s.type)),t("div",{class:"s-offer-card-content"},t("h3",{class:"s-offer-card-title",title:s.title},s.title),s.description&&t("p",{class:"s-offer-card-description"},s.description),s.type===i.DiscountsTable?t("div",{class:"s-offer-card-details"},this.renderDiscountTableOfferContent(s)):s.type===i.PercentageOrFixed||s.type===i.Percentage||s.type===i.FixedAmount?t("div",{class:"s-offer-card-details"},this.renderPercentageOrFixedOfferContent(s),this.renderOfferCategories(s),this.renderOfferBrands(s)):t("div",{class:"s-offer-card-details"},this.renderOfferCategories(s),this.renderOfferBrands(s)))),r&&t("salla-accordion",{collapsed:a,collapsible:!0,size:"sm",onClick:s=>s.stopPropagation(),onAccordionToggle:t=>this.handleAccordionToggle(s.id,t.detail.payload.collapsed)},t("salla-accordion-head",{collapsible:!0,collapsed:a},t("div",{slot:"title",class:"s-offer-products-thumbnails"},t("span",{class:"s-offer-products-title"},this.products_link_text,t("i",{class:`sicon-keyboard_arrow_${a?"down":"up"} s-offer-products-link-icon`})),t("div",{class:"s-offer-products-thumbnails-stack"},o.slice(0,3).map(((s,e)=>t("div",{class:"s-offer-product-thumbnail",style:{zIndex:`${e+1}`}},t("img",{src:s.thumbnail||s.image?.url||salla.url.cdn("images/s-empty.png"),alt:s.name})))),o.length>3&&t("div",{class:"s-offer-products-more-count",style:{zIndex:"7"}},"+",o.length-3)))),t("salla-accordion-body",null,t("div",{class:"s-offer-products-content"},t("salla-products-list",{source:"selected","source-value":JSON.stringify(o.map((s=>s.id))),"product-card-component":this.productCardComponent,"horizontal-cards":!0,"compact-cards":!0,includes:["images"]})))))}renderOfferCard(s,e=1){return t("div",{class:"s-offer-slide-one-fourth swiper-slide",onClick:()=>this.emitPromotionClicked(s,e)},t("div",{class:"s-offer-card"},t("div",{class:"s-offer-card-icon"},this.getOfferIcon(s.type)),t("div",{class:"s-offer-card-content"},t("h3",{class:"s-offer-card-title",title:s.title},s.title),s.description&&t("p",{class:"s-offer-card-description"},s.description),t("div",{class:"s-offer-card-details"},s.type===i.DiscountsTable?this.renderDiscountTableOfferContent(s):s.type===i.PercentageOrFixed||s.type===i.Percentage||s.type===i.FixedAmount?[this.renderPercentageOrFixedOfferContent(s),this.renderOfferCategories(s),this.renderOfferBrands(s)]:[this.renderOfferCategories(s),this.renderOfferBrands(s)],this.renderProductsLinkForModalCard(s,!1)))))}getOfferIcon(s){return t("i",{class:{[i.DiscountsTable]:"sicon-discount-calculator",[i.Bank]:"sicon-bank",[i.SpecialPrice]:"sicon-fire",[i.BuyXGetY]:"sicon-gift",[i.PercentageOrFixed]:"sicon-special-discount",[i.Percentage]:"sicon-special-discount",[i.FixedAmount]:"sicon-special-discount"}[s]||"sicon-discount"})}renderDiscountTableOfferContent(s){const e=s.details.discounts||[];return e.length?t("div",null,t("div",{class:"s-offer-card-description"},salla.lang.get("pages.offer.discount_table_subtitle","وفر اكتر بشراء منتجات أكثر")),t("table",{class:"s-offer-discount-table"},t("tbody",null,this.groupDiscountsByRows(e,3).map(((s,e)=>t("tr",{key:e},s.map(((s,e)=>t("td",{key:e},t("div",{class:"s-offer-discount-percentage"},s.percentage,"%"),t("div",{class:"s-offer-discount-condition"},this.formatDiscountCondition(s))))))))))):null}renderPercentageOrFixedOfferContent(s){const e=s.details;return e.discount_value||e.min_spend>0||e.min_items>0?t("div",{class:"s-offer-percentage-fixed-content"},e.min_spend>0&&t("div",{class:"s-offer-min-spend"},this.min_spend_text(e.min_spend,this.userCurrency?.symbol||"")),e.min_items>0&&t("div",{class:"s-offer-min-items"},this.min_items_text(e.min_items))):null}groupDiscountsByRows(s,t){const e=[];for(let o=0;o<s.length;o+=t)e.push(s.slice(o,o+t));return e}formatDiscountCondition(s){return s.discounted_amount?`${s.discounted_amount} ${this.userCurrency?.symbol||""}`:null!=s.quantity?this.buy_quantity_text(s.quantity):`1 ${this.product_text}`}renderOfferCategories(s){const e=s.details;let o=e.categories||[];if(s.type===i.BuyXGetY&&e.get?.categories&&(o=e.get.categories),!o.length)return null;const r=this.expandedCategories[s.id],a=o.length>3,l=r?o:o.slice(0,3);return t("div",{class:"s-offer-categories"},t("div",{class:"s-offer-categories-list"},l.map(((s,e)=>t("a",{key:e,class:"s-offer-category-item",href:s.url||salla.url.create("categories",s.id||s.id_)},s.name))),a&&t("span",{class:"s-offer-categories-toggle",onClick:t=>{t.preventDefault(),t.stopPropagation(),this.toggleCategoryExpansion(s.id)}},r?t("span",null,t("i",{class:"sicon-keyboard_arrow_up"})," ",salla.lang.get("common.elements.hide","إخفاء")):t("span",null,salla.lang.get("common.elements.show","عرض")," ","+"+(o.length-3)," ",t("i",{class:"sicon-keyboard_arrow_down"})))))}renderOfferBrands(s){const e=s.details.brands||[];if(!e.length)return null;const o=this.expandedCategories[s.id],i=e.length>3,r=o?e:e.slice(0,3);return t("div",{class:"s-offer-categories"},t("div",{class:"s-offer-categories-list"},r.map(((s,e)=>t("a",{key:e,class:"s-offer-category-item",href:s.url},s.name))),i&&t("span",{class:"s-offer-categories-toggle",onClick:t=>{t.preventDefault(),t.stopPropagation(),this.toggleCategoryExpansion(s.id)}},o?t("span",null,t("i",{class:"sicon-keyboard_arrow_up"})," ",salla.lang.get("common.elements.hide","إخفاء")):t("span",null,salla.lang.get("common.elements.show","عرض")," ","+"+(e.length-3)," ",t("i",{class:"sicon-keyboard_arrow_down"})))))}toggleCategoryExpansion(s){this.expandedCategories={...this.expandedCategories,[s]:!this.expandedCategories[s]}}get host(){return e(this)}};r.style=":host .s-drawer-close:where([dir=rtl],[dir=rtl] *){left:0}";export{r as salla_offer}
4
+ import{r as s,h as t,a as e}from"./p-eYsXdqjv.js";var o,i;!function(s){s.ProductDetail="product.single",s.Cart="cart"}(o||(o={})),function(s){s.Conditional="conditional",s.PercentageOrFixed="fixed",s.DiscountsTable="discounts_table",s.Bank="bank",s.BuyXGetY="buy_x_get_y",s.SpecialPrice="special_price",s.Percentage="percentage",s.FixedAmount="fixed_amount"}(i||(i={}));const r=class{constructor(t){s(this,t),this.productCardComponent="salla-product-card",this.offersList=[],this.canRender=!1,this.showOffer=salla.config.get("store.settings.product.show_special_offers"),this.showAllOffersModal=!1,this.showProductsModal=!1,this.selectedOfferProducts=[],this.collapsedOffers={},this.expandedCategories={},this.productsLoaded=!1,this.offer_with_price_text=salla.lang.get("pages.offer.with_price",{price:""}),this.with_discount_text=salla.lang.get("pages.products.with_a_discount"),this.product_discount_text=salla.lang.get("pages.products.discount"),this.special_offer_text=salla.lang.get("pages.products.special_offer"),this.buy_quantity_text=s=>salla.lang.get("pages.offer.buy_quantity",{quantity:s}),this.products_link_text=salla.lang.get("pages.offer.included_products","المنتجات المشمولة"),this.min_spend_text=(s,t)=>salla.lang.get("pages.offer.min_spend_amount",{amount:s,currency:t},`بحد أدنى ${s} ${t} من مبلغ الشراء`),this.min_items_text=s=>salla.lang.get("pages.offer.min_items",{items:s},`بحد أدنى ${s} منتجات`),this.product_text=salla.lang.get("common.elements.product","منتج"),salla.lang.onLoaded((()=>{this.offer_with_price_text=salla.lang.get("pages.offer.with_price"),this.with_discount_text=salla.lang.get("pages.products.with_a_discount"),this.product_discount_text=salla.lang.get("pages.products.discount"),this.special_offer_text=salla.lang.get("pages.products.special_offer"),this.buy_quantity_text(0),this.products_link_text=salla.lang.get("pages.offer.included_products","المنتجات المشمولة"),this.min_spend_text=(s,t)=>salla.lang.get("pages.offer.min_spend_amount",{amount:s,currency:t},`بحد أدنى ${s} ${t} من مبلغ الشراء`),this.min_items_text=s=>salla.lang.get("pages.offer.min_items",{items:s},`بحد أدنى ${s} منتجات`),this.product_text=salla.lang.get("common.elements.product","منتج")})),salla.onReady((()=>{this.currentPage=salla.config.get("page.slug");const s=salla.config.get("currencies")||{},t=salla.config.get("user.currency_code");this.userCurrency=s[t]||{symbol:"",code:t||"SAR",name:""}}))}async getEndpointByPageName(){return this.currentPage==o.Cart?`offers/cart/${await Salla.cart.getCurrentCartId()}`:this.currentPage==o.ProductDetail?`offers/product/${salla.config.get("page.id")}`:"offers"}emitPromotionViewed(){if(!(this.offersList.length&&this.canRender&&this.showOffer))return;const s=this.offersList.slice(0,5).map(((s,t)=>({id:s.id,name:s.title,creative:s.description||"",position:t+1})));salla.event.emit("salla::offer.promotion.viewed",s)}emitPromotionClicked(s,t=1){if(!(this.offersList.length&&this.canRender&&this.showOffer))return;const e=s||this.offersList[0];salla.event.emit("salla::offer.promotion.clicked",[{id:e.id,name:e.title,creative:e.description||"",position:t}])}componentWillLoad(){return this.hasCustomComponent=!!customElements.get(this.productCardComponent),new Promise((s=>salla.onReady(s))).then((()=>{if(this.showOffer=!salla.url.is_page("product.single")||salla.config.get("store.settings.product.show_special_offers"),!this.showOffer)throw new Error("Merchant disabled showing the offers on product page")})).then((async()=>salla.api.request(await this.getEndpointByPageName()))).then((async s=>{if(!(this.offersList=s.data).length)throw new Error("salla-offers:: There is no offers!");if(this.offersList=this.offersList.filter((s=>[i.SpecialPrice,i.Bank,i.BuyXGetY,i.DiscountsTable,i.PercentageOrFixed,i.Percentage,i.FixedAmount].includes(s.type))),!this.offersList.length)throw new Error("salla-offers:: No supported offer types found!");let t=null;this.offersList.some((s=>{const t=s.details;return"category"===t.apply_to&&t.targets||"categories"===t.apply_to&&t.targets||s.type===i.BuyXGetY&&("categories"===t.get?.source||"category"===t.get?.source)}))&&(t=(await salla.product.api.categories()).data);const e=new Set;for(const s of this.offersList){const t=s.details;"product"!==t.apply_to&&"products"!==t.apply_to||!t.targets||t.targets.forEach((s=>e.add(s))),s.type===i.BuyXGetY&&"products"===t.get?.source&&t.get?.source_value&&t.get.source_value.forEach((s=>e.add(s))),s.type!==i.BuyXGetY||"products"!==t.buy?.source&&"product"!==t.buy?.source||!t.buy?.source_value||t.buy.source_value.forEach((s=>e.add(s)))}let o={};if(e.size>0)try{const s=await salla.product.api.fetch({source:"selected",source_value:Array.from(e)});o=Object.fromEntries(s.data.map((s=>[s.id,s])))}catch(s){o={}}for(const s of this.offersList){const e=s.details;if(("category"===e.apply_to&&e.targets||"categories"===e.apply_to&&e.targets)&&t&&(e.categories=this.findCategories(t,e.targets)),"product"!==e.apply_to&&"products"!==e.apply_to||!e.targets||(e.products=e.targets.map((s=>o[s])).filter(Boolean)),"brand"===e.apply_to&&e.targets&&(e.brands=e.targets),s.type===i.BuyXGetY&&e.get){const s=e.get;"products"===s.source&&s.source_value?s.products=s.source_value.map((s=>o[s])).filter(Boolean):("categories"===s.source||"category"===s.source)&&t&&s.source_value&&(s.categories=this.findCategories(t,s.source_value),e.categories=s.categories)}if(s.type===i.BuyXGetY&&e.buy){const s=e.buy;"products"!==s.source&&"product"!==s.source||!s.source_value||(s.products=s.source_value.map((s=>o[s])).filter(Boolean))}}return this.offersList})).then((()=>{this.canRender=!0})).catch((s=>{salla.logger.warn(s)}))}componentDidLoad(){let s=this.host.querySelector(".s-slider-block__title-nav");s?.classList.add("s-offer-bank-payment-nav"),this.emitPromotionViewed()}findCategories(s,t){let e=[];for(const o of s)t.includes(o.id_||o.id)&&e.push(o),o.sub_categories?.length>0&&(e=e.concat(this.findCategories(o.sub_categories,t)));return e}render(){if(!this.offersList.length||!this.canRender||!this.showOffer)return null;const s=salla.lang.get("pages.offer.offers_title","عروض المنتج"),e=salla.lang.get("pages.offer.offers_subtitle","احصل على المنتج بسعر مخفض مع أفضل العروض");return[t("div",{class:"s-offer-wrapper"},t("salla-slider",{type:"carousel",id:"offers-slider","block-title":s,"block-subTitle":e,"show-controls":this.offersList.length>1},t("div",{slot:"items"},this.offersList.slice(0,5).map(((s,t)=>this.renderOfferCard(s,t+1))),this.offersList.length>5&&this.renderShowMoreCard()))),this.renderAllOffersModal(),this.renderProductsModal()]}renderShowMoreCard(){return t("div",{class:"s-offer-slide-one-fourth swiper-slide",onClick:s=>{s.preventDefault(),s.stopPropagation(),this.openAllOffersModal()}},t("div",{class:"s-offer-card s-offer-show-more-card"},t("i",{class:"sicon-add s-offer-show-more-icon"}),t("h3",{class:"s-offer-show-more-title"},salla.lang.get("pages.offer.show_more_offers","عرض المزيد من العروض"))))}openAllOffersModal(){this.showAllOffersModal=!0}closeAllOffersModal(){this.showAllOffersModal=!1}closeProductsModal(){this.showProductsModal=!1,this.selectedOfferProducts=[],this.productsLoaded=!1}handleAccordionToggle(s,t){this.collapsedOffers={...this.collapsedOffers,[s]:t}}getOfferProducts(s){const t=s.details;return t.products&&t.products.length>0?t.products:s.type===i.BuyXGetY&&t.get?.products?t.get.products:[]}renderProductsLinkForModalCard(s,e){const o=this.getOfferProducts(s);return o&&0!==o.length?t("div",{class:"s-offer-products-link",onClick:s=>{s.stopPropagation(),this.selectedOfferProducts=o,this.showProductsModal=!0}},t("span",{class:"s-offer-products-link-text"},this.products_link_text),e&&t("i",{class:"sicon-keyboard_arrow_down s-offer-products-link-icon"})):null}renderAllOffersModal(){return t("salla-drawer",{visible:this.showAllOffersModal,position:"right",width:"md","no-padding":!0,"drawer-title":salla.lang.get("pages.offer.all_offers_title","جميع العروض"),onDrawerVisibilityChanged:s=>!s.detail&&this.closeAllOffersModal()},t("div",{class:"s-offer-drawer-content"},this.offersList.map(((s,t)=>this.renderModalOfferCard(s,t+1)))))}renderProductsModal(){return t("salla-drawer",{visible:this.showProductsModal,width:"md",position:"right","no-padding":!0,"drawer-title":this.products_link_text,onDrawerVisibilityChanged:s=>!s.detail&&this.closeProductsModal()},t("div",{class:"s-offer-products-drawer-content"},this.selectedOfferProducts?.length>0?t("div",null,!this.productsLoaded&&t("div",{class:"flex items-center justify-center p-8"},t("salla-loading",{size:"24"})),t("salla-products-list",{source:"selected","source-value":JSON.stringify(this.selectedOfferProducts.map((s=>s.id))),"product-card-component":this.productCardComponent,"horizontal-cards":!0,"compact-cards":!0,includes:["images"],onProductsFetched:()=>this.productsLoaded=!0})):t("div",{class:"p-4 text-center text-gray-500"},salla.lang.get("blocks.products.no_products_found","لا توجد منتجات"))))}renderModalOfferCard(s,e=1){const o=this.getOfferProducts(s),r=o&&o.length>0,a=!1!==this.collapsedOffers[s.id];return t("div",{class:"s-offer-drawer-card"},t("div",{class:"s-offer-card-main",onClick:()=>this.emitPromotionClicked(s,e)},t("div",{class:"s-offer-card-icon"},this.getOfferIcon(s.type)),t("div",{class:"s-offer-card-content"},t("h3",{class:"s-offer-card-title",title:s.title},s.title),s.description&&t("p",{class:"s-offer-card-description"},s.description),s.type===i.DiscountsTable?t("div",{class:"s-offer-card-details"},this.renderDiscountTableOfferContent(s)):s.type===i.PercentageOrFixed||s.type===i.Percentage||s.type===i.FixedAmount?t("div",{class:"s-offer-card-details"},this.renderPercentageOrFixedOfferContent(s),this.renderOfferCategories(s),this.renderOfferBrands(s)):t("div",{class:"s-offer-card-details"},this.renderOfferCategories(s),this.renderOfferBrands(s)))),r&&t("salla-accordion",{collapsed:a,collapsible:!0,size:"sm",onClick:s=>s.stopPropagation(),onAccordionToggle:t=>this.handleAccordionToggle(s.id,t.detail.payload.collapsed)},t("salla-accordion-head",{collapsible:!0,collapsed:a},t("div",{slot:"title",class:"s-offer-products-thumbnails"},t("span",{class:"s-offer-products-title"},this.products_link_text,t("i",{class:`sicon-keyboard_arrow_${a?"down":"up"} s-offer-products-link-icon`})),t("div",{class:"s-offer-products-thumbnails-stack"},o.slice(0,3).map(((s,e)=>t("div",{class:"s-offer-product-thumbnail",style:{zIndex:`${e+1}`}},t("img",{src:s.thumbnail||s.image?.url||salla.url.cdn("images/s-empty.png"),alt:s.name})))),o.length>3&&t("div",{class:"s-offer-products-more-count",style:{zIndex:"7"}},"+",o.length-3)))),t("salla-accordion-body",null,t("div",{class:"s-offer-products-content"},t("salla-products-list",{source:"selected","source-value":JSON.stringify(o.map((s=>s.id))),"product-card-component":this.productCardComponent,"horizontal-cards":!0,"compact-cards":!0,includes:["images"]})))))}renderOfferCard(s,e=1){return t("div",{class:"s-offer-slide-one-fourth swiper-slide",onClick:()=>this.emitPromotionClicked(s,e)},t("div",{class:"s-offer-card"},t("div",{class:"s-offer-card-icon"},this.getOfferIcon(s.type)),t("div",{class:"s-offer-card-content"},t("h3",{class:"s-offer-card-title",title:s.title},s.title),s.description&&t("p",{class:"s-offer-card-description"},s.description),t("div",{class:"s-offer-card-details"},s.type===i.DiscountsTable?this.renderDiscountTableOfferContent(s):s.type===i.PercentageOrFixed||s.type===i.Percentage||s.type===i.FixedAmount?[this.renderPercentageOrFixedOfferContent(s),this.renderOfferCategories(s),this.renderOfferBrands(s)]:[this.renderOfferCategories(s),this.renderOfferBrands(s)],this.renderProductsLinkForModalCard(s,!1)))))}getOfferIcon(s){return t("i",{class:{[i.DiscountsTable]:"sicon-discount-calculator",[i.Bank]:"sicon-bank",[i.SpecialPrice]:"sicon-fire",[i.BuyXGetY]:"sicon-gift",[i.PercentageOrFixed]:"sicon-special-discount",[i.Percentage]:"sicon-special-discount",[i.FixedAmount]:"sicon-special-discount"}[s]||"sicon-discount"})}renderDiscountTableOfferContent(s){const e=s.details.discounts||[];return e.length?t("div",null,t("div",{class:"s-offer-card-description"},salla.lang.get("pages.offer.discount_table_subtitle","وفر اكتر بشراء منتجات أكثر")),t("table",{class:"s-offer-discount-table"},t("tbody",null,this.groupDiscountsByRows(e,3).map(((s,e)=>t("tr",{key:e},s.map(((s,e)=>t("td",{key:e},t("div",{class:"s-offer-discount-percentage"},s.percentage,"%"),t("div",{class:"s-offer-discount-condition"},this.formatDiscountCondition(s))))))))))):null}renderPercentageOrFixedOfferContent(s){const e=s.details;return e.discount_value||e.min_spend>0||e.min_items>0?t("div",{class:"s-offer-percentage-fixed-content"},e.min_spend>0&&t("div",{class:"s-offer-min-spend"},this.min_spend_text(e.min_spend,this.userCurrency?.symbol||"")),e.min_items>0&&t("div",{class:"s-offer-min-items"},this.min_items_text(e.min_items))):null}groupDiscountsByRows(s,t){const e=[];for(let o=0;o<s.length;o+=t)e.push(s.slice(o,o+t));return e}formatDiscountCondition(s){return s.discounted_amount?`${s.discounted_amount} ${this.userCurrency?.symbol||""}`:null!=s.quantity?this.buy_quantity_text(s.quantity):`1 ${this.product_text}`}renderOfferCategories(s){const e=s.details;let o=e.categories||[];if(s.type===i.BuyXGetY&&e.get?.categories&&(o=e.get.categories),!o.length)return null;const r=this.expandedCategories[s.id],a=o.length>3,l=r?o:o.slice(0,3);return t("div",{class:"s-offer-categories"},t("div",{class:"s-offer-categories-list"},l.map(((s,e)=>t("a",{key:e,class:"s-offer-category-item",href:s.url||salla.url.create("categories",s.id||s.id_)},s.name))),a&&t("span",{class:"s-offer-categories-toggle",onClick:t=>{t.preventDefault(),t.stopPropagation(),this.toggleCategoryExpansion(s.id)}},r?t("span",null,t("i",{class:"sicon-keyboard_arrow_up"})," ",salla.lang.get("common.elements.hide","إخفاء")):t("span",null,salla.lang.get("common.elements.show","عرض")," ","+"+(o.length-3)," ",t("i",{class:"sicon-keyboard_arrow_down"})))))}renderOfferBrands(s){const e=s.details.brands||[];if(!e.length)return null;const o=this.expandedCategories[s.id],i=e.length>3,r=o?e:e.slice(0,3);return t("div",{class:"s-offer-categories"},t("div",{class:"s-offer-categories-list"},r.map(((s,e)=>t("a",{key:e,class:"s-offer-category-item",href:s.url},s.name))),i&&t("span",{class:"s-offer-categories-toggle",onClick:t=>{t.preventDefault(),t.stopPropagation(),this.toggleCategoryExpansion(s.id)}},o?t("span",null,t("i",{class:"sicon-keyboard_arrow_up"})," ",salla.lang.get("common.elements.hide","إخفاء")):t("span",null,salla.lang.get("common.elements.show","عرض")," ","+"+(e.length-3)," ",t("i",{class:"sicon-keyboard_arrow_down"})))))}toggleCategoryExpansion(s){this.expandedCategories={...this.expandedCategories,[s]:!this.expandedCategories[s]}}get host(){return e(this)}};r.style=":host .s-drawer-close:where([dir=rtl],[dir=rtl] *){left:0}";export{r as salla_offer}