@salla.sa/twilight-components 2.14.364 → 2.14.366

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 (263) hide show
  1. package/dist/cjs/{Helper-DHRnzcFm.js → Helper-CU4Xuiki.js} +9 -3
  2. package/dist/cjs/{filepond-C6YjB4Pc.js → filepond-iKAI8_Ua.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-poster-CtNn5Jla.js → filepond-plugin-file-poster-DBOuyuqE.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-size-PCygUua9.js → filepond-plugin-file-validate-size-3OjivJWc.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-file-validate-type-MZSqUcaj.js → filepond-plugin-file-validate-type-C4wPNa1h.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-edit-ZmpgJTIn.js → filepond-plugin-image-edit-D06RnDWS.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-exif-orientation-DxPDvRXB.js → filepond-plugin-image-exif-orientation-CbwYrnuw.js} +1 -1
  8. package/dist/cjs/{filepond-plugin-image-preview-93G9gp9A.js → filepond-plugin-image-preview-mOmpKkFJ.js} +1 -1
  9. package/dist/cjs/{index-DrduZhCQ.js → index-DL9nqubd.js} +6 -6
  10. package/dist/cjs/{index-DrtTVEw4.js → index-TmWujwmX.js} +1 -1
  11. package/dist/cjs/loader.cjs.js +2 -2
  12. package/dist/cjs/salla-accordion-body_3.cjs.entry.js +1 -1
  13. package/dist/cjs/salla-accordion_6.cjs.entry.js +2 -2
  14. package/dist/cjs/salla-add-product-button_4.cjs.entry.js +2 -2
  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-booking-field_7.cjs.entry.js +11 -11
  20. package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +1 -1
  21. package/dist/cjs/salla-comment-form_8.cjs.entry.js +2 -2
  22. package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
  23. package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
  24. package/dist/cjs/salla-cookies-bar.cjs.entry.js +1 -1
  25. package/dist/cjs/salla-count-down_2.cjs.entry.js +11 -8
  26. package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
  27. package/dist/cjs/salla-filters-widget.cjs.entry.js +2 -2
  28. package/dist/cjs/salla-filters.cjs.entry.js +2 -2
  29. package/dist/cjs/salla-gifting.cjs.entry.js +1 -1
  30. package/dist/cjs/salla-hook.cjs.entry.js +1 -1
  31. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +2 -2
  32. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  33. package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
  34. package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
  35. package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
  36. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  37. package/dist/cjs/salla-loyalty-program.cjs.entry.js +1 -1
  38. package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
  39. package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
  40. package/dist/cjs/salla-menu.cjs.entry.js +1 -1
  41. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  42. package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
  43. package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
  44. package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
  45. package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
  46. package/dist/cjs/salla-notifications.cjs.entry.js +2 -2
  47. package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
  48. package/dist/cjs/salla-offer.cjs.entry.js +248 -177
  49. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
  50. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  51. package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
  52. package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
  53. package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
  54. package/dist/cjs/salla-orders.cjs.entry.js +2 -2
  55. package/dist/cjs/salla-payments.cjs.entry.js +1 -1
  56. package/dist/cjs/salla-placeholder.cjs.entry.js +1 -1
  57. package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
  58. package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
  59. package/dist/cjs/salla-products-list.cjs.entry.js +15 -4
  60. package/dist/cjs/salla-products-slider.cjs.entry.js +11 -3
  61. package/dist/cjs/salla-progress-bar.cjs.entry.js +1 -1
  62. package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
  63. package/dist/cjs/salla-rating-modal.cjs.entry.js +2 -2
  64. package/dist/cjs/salla-scopes.cjs.entry.js +1 -1
  65. package/dist/cjs/salla-search.cjs.entry.js +2 -2
  66. package/dist/cjs/salla-skeleton.cjs.entry.js +1 -1
  67. package/dist/cjs/salla-slider.cjs.entry.js +1 -1
  68. package/dist/cjs/salla-social-share.cjs.entry.js +1 -1
  69. package/dist/cjs/salla-social.cjs.entry.js +1 -1
  70. package/dist/cjs/salla-tab-content_3.cjs.entry.js +1 -1
  71. package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
  72. package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
  73. package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
  74. package/dist/cjs/salla-user-menu.cjs.entry.js +1 -1
  75. package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
  76. package/dist/cjs/salla-user-settings.cjs.entry.js +1 -1
  77. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  78. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  79. package/dist/cjs/twilight.cjs.js +2 -2
  80. package/dist/cjs/{vanilla-picker-BKkfVwL1.js → vanilla-picker-DPu_Z0gW.js} +1 -1
  81. package/dist/collection/Helpers/Helper.js +9 -3
  82. package/dist/collection/components/salla-offer/interfaces.js +2 -0
  83. package/dist/collection/components/salla-offer/salla-offer.css +2 -25
  84. package/dist/collection/components/salla-offer/salla-offer.js +256 -181
  85. package/dist/collection/components/salla-product-card/salla-product-card.js +29 -7
  86. package/dist/collection/components/salla-products-list/salla-products-list.js +32 -2
  87. package/dist/collection/components/salla-products-slider/salla-products-slider.js +9 -1
  88. package/dist/components/Helper.js +9 -3
  89. package/dist/components/index.js +2 -2
  90. package/dist/components/salla-offer.js +273 -220
  91. package/dist/components/salla-product-card2.js +11 -7
  92. package/dist/components/salla-products-list2.js +14 -2
  93. package/dist/components/salla-products-slider2.js +9 -1
  94. package/dist/esm/{Helper-B5RLi6Xo.js → Helper-DFMXF2_h.js} +9 -3
  95. package/dist/esm/{filepond-DKDl5gHI.js → filepond-OIAu6i0O.js} +1 -1
  96. package/dist/esm/{filepond-plugin-file-poster-D93Cfru7.js → filepond-plugin-file-poster-BMvjO1cc.js} +1 -1
  97. package/dist/esm/{filepond-plugin-file-validate-size-B9y0A-_Z.js → filepond-plugin-file-validate-size-CMCs88HU.js} +1 -1
  98. package/dist/esm/{filepond-plugin-file-validate-type-DJLrAmDa.js → filepond-plugin-file-validate-type-Bjpeuqen.js} +1 -1
  99. package/dist/esm/{filepond-plugin-image-edit-5SrR8khF.js → filepond-plugin-image-edit-Fpoh6xBj.js} +1 -1
  100. package/dist/esm/{filepond-plugin-image-exif-orientation-CzhglWtb.js → filepond-plugin-image-exif-orientation-CPChwYPW.js} +1 -1
  101. package/dist/esm/{filepond-plugin-image-preview-DBxJhkxb.js → filepond-plugin-image-preview-pLwEytag.js} +1 -1
  102. package/dist/esm/{index-CgYN55XK.js → index-CV1rqKQz.js} +6 -6
  103. package/dist/esm/{index-BrjMW-AZ.js → index-Cs4XvAmW.js} +1 -1
  104. package/dist/esm/loader.js +3 -3
  105. package/dist/esm/salla-accordion-body_3.entry.js +1 -1
  106. package/dist/esm/salla-accordion_6.entry.js +2 -2
  107. package/dist/esm/salla-add-product-button_4.entry.js +2 -2
  108. package/dist/esm/salla-advertisement.entry.js +1 -1
  109. package/dist/esm/salla-alert_2.entry.js +1 -1
  110. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  111. package/dist/esm/salla-apps-icons.entry.js +1 -1
  112. package/dist/esm/salla-booking-field_7.entry.js +11 -11
  113. package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
  114. package/dist/esm/salla-comment-form_8.entry.js +2 -2
  115. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  116. package/dist/esm/salla-contacts.entry.js +1 -1
  117. package/dist/esm/salla-cookies-bar.entry.js +1 -1
  118. package/dist/esm/salla-count-down_2.entry.js +11 -8
  119. package/dist/esm/salla-custom-fields.entry.js +1 -1
  120. package/dist/esm/salla-filters-widget.entry.js +2 -2
  121. package/dist/esm/salla-filters.entry.js +2 -2
  122. package/dist/esm/salla-gifting.entry.js +1 -1
  123. package/dist/esm/salla-hook.entry.js +1 -1
  124. package/dist/esm/salla-infinite-scroll.entry.js +2 -2
  125. package/dist/esm/salla-installment.entry.js +1 -1
  126. package/dist/esm/salla-list-tile.entry.js +1 -1
  127. package/dist/esm/salla-localization-modal.entry.js +1 -1
  128. package/dist/esm/salla-login-modal.entry.js +1 -1
  129. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  130. package/dist/esm/salla-loyalty-program.entry.js +1 -1
  131. package/dist/esm/salla-loyalty.entry.js +1 -1
  132. package/dist/esm/salla-maintenance-alert.entry.js +1 -1
  133. package/dist/esm/salla-menu.entry.js +1 -1
  134. package/dist/esm/salla-metadata.entry.js +1 -1
  135. package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
  136. package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
  137. package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
  138. package/dist/esm/salla-notification-item.entry.js +1 -1
  139. package/dist/esm/salla-notifications.entry.js +2 -2
  140. package/dist/esm/salla-offer-modal.entry.js +1 -1
  141. package/dist/esm/salla-offer.entry.js +248 -177
  142. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  143. package/dist/esm/salla-order-details-options.entry.js +1 -1
  144. package/dist/esm/salla-order-details.entry.js +1 -1
  145. package/dist/esm/salla-order-summary.entry.js +1 -1
  146. package/dist/esm/salla-order-totals-card.entry.js +1 -1
  147. package/dist/esm/salla-orders.entry.js +2 -2
  148. package/dist/esm/salla-payments.entry.js +1 -1
  149. package/dist/esm/salla-placeholder.entry.js +1 -1
  150. package/dist/esm/salla-price-range.entry.js +1 -1
  151. package/dist/esm/salla-product-size-guide.entry.js +1 -1
  152. package/dist/esm/salla-products-list.entry.js +15 -4
  153. package/dist/esm/salla-products-slider.entry.js +11 -3
  154. package/dist/esm/salla-progress-bar.entry.js +1 -1
  155. package/dist/esm/salla-quick-order.entry.js +1 -1
  156. package/dist/esm/salla-rating-modal.entry.js +2 -2
  157. package/dist/esm/salla-scopes.entry.js +1 -1
  158. package/dist/esm/salla-search.entry.js +2 -2
  159. package/dist/esm/salla-skeleton.entry.js +1 -1
  160. package/dist/esm/salla-slider.entry.js +1 -1
  161. package/dist/esm/salla-social-share.entry.js +1 -1
  162. package/dist/esm/salla-social.entry.js +1 -1
  163. package/dist/esm/salla-tab-content_3.entry.js +1 -1
  164. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  165. package/dist/esm/salla-tooltip.entry.js +1 -1
  166. package/dist/esm/salla-trust-badges.entry.js +1 -1
  167. package/dist/esm/salla-user-menu.entry.js +1 -1
  168. package/dist/esm/salla-user-profile.entry.js +1 -1
  169. package/dist/esm/salla-user-settings.entry.js +1 -1
  170. package/dist/esm/salla-verify.entry.js +1 -1
  171. package/dist/esm/salla-wallet.entry.js +1 -1
  172. package/dist/esm/twilight.js +3 -3
  173. package/dist/esm/{vanilla-picker-Btl47fnu.js → vanilla-picker-BASTfXcg.js} +1 -1
  174. package/dist/twilight/{p-7cf68887.entry.js → p-04664fcb.entry.js} +1 -1
  175. package/dist/twilight/{p-489556db.entry.js → p-0c385d73.entry.js} +1 -1
  176. package/dist/twilight/{p-45f6a85e.entry.js → p-0ede455c.entry.js} +1 -1
  177. package/dist/twilight/{p-1b90e0b0.entry.js → p-0f1d7449.entry.js} +1 -1
  178. package/dist/twilight/{p-1a7eb8b5.entry.js → p-134c9d22.entry.js} +1 -1
  179. package/dist/twilight/{p-a8e65234.entry.js → p-15242c87.entry.js} +1 -1
  180. package/dist/twilight/{p-e129ac60.entry.js → p-1aead6d3.entry.js} +1 -1
  181. package/dist/twilight/{p-80cbf7bc.entry.js → p-1f6ead7d.entry.js} +1 -1
  182. package/dist/twilight/{p-72a0eba4.entry.js → p-215ed586.entry.js} +1 -1
  183. package/dist/twilight/{p-fbe030f2.entry.js → p-22b1bd15.entry.js} +1 -1
  184. package/dist/twilight/{p-12b86d33.entry.js → p-233b89ad.entry.js} +1 -1
  185. package/dist/twilight/{p-7cd6ff80.entry.js → p-2405c0f7.entry.js} +1 -1
  186. package/dist/twilight/{p-ce7ec4bc.entry.js → p-2c787ba0.entry.js} +1 -1
  187. package/dist/twilight/{p-034a9829.entry.js → p-2dd98664.entry.js} +1 -1
  188. package/dist/twilight/{p-c6145ba2.entry.js → p-3c09b198.entry.js} +1 -1
  189. package/dist/twilight/{p-08b2c445.entry.js → p-3c418ff7.entry.js} +1 -1
  190. package/dist/twilight/{p-50090848.entry.js → p-3c6f9112.entry.js} +1 -1
  191. package/dist/twilight/{p-b6611b65.entry.js → p-3f8b06b3.entry.js} +1 -1
  192. package/dist/twilight/{p-92c2eb1d.entry.js → p-40ec7a33.entry.js} +1 -1
  193. package/dist/twilight/{p-31ad6ddc.entry.js → p-4d35a32b.entry.js} +1 -1
  194. package/dist/twilight/{p-5d42ca23.entry.js → p-50f5e38d.entry.js} +1 -1
  195. package/dist/twilight/{p-0d88be23.entry.js → p-5485978c.entry.js} +1 -1
  196. package/dist/twilight/{p-3aef87fa.entry.js → p-585a349f.entry.js} +1 -1
  197. package/dist/twilight/{p-c1ee3573.entry.js → p-58f562df.entry.js} +1 -1
  198. package/dist/twilight/{p-3a910561.entry.js → p-594d219c.entry.js} +1 -1
  199. package/dist/twilight/{p-BPzrIneD.js → p-5mQqqwMU.js} +1 -1
  200. package/dist/twilight/{p-cb974a04.entry.js → p-64ac4c0c.entry.js} +1 -1
  201. package/dist/twilight/{p-d7dafe1d.entry.js → p-6aecc925.entry.js} +1 -1
  202. package/dist/twilight/{p-737bf5ea.entry.js → p-6b6e2a52.entry.js} +1 -1
  203. package/dist/twilight/{p-860f725d.entry.js → p-6daa8bd8.entry.js} +1 -1
  204. package/dist/twilight/{p-3aab356e.entry.js → p-6dbcd99e.entry.js} +1 -1
  205. package/dist/twilight/{p-10551ac8.entry.js → p-6f09b53e.entry.js} +1 -1
  206. package/dist/twilight/{p-20beefaf.entry.js → p-721bb258.entry.js} +1 -1
  207. package/dist/twilight/{p-d018e945.entry.js → p-75ab49a3.entry.js} +1 -1
  208. package/dist/twilight/{p-31b13945.entry.js → p-7bfb9d71.entry.js} +1 -1
  209. package/dist/twilight/p-7c8c6c47.entry.js +4 -0
  210. package/dist/twilight/{p-c2f9ea90.entry.js → p-8c2b148a.entry.js} +1 -1
  211. package/dist/twilight/{p-235eb6bb.entry.js → p-907b40cd.entry.js} +1 -1
  212. package/dist/twilight/{p-257b5507.entry.js → p-90eea1a9.entry.js} +1 -1
  213. package/dist/twilight/{p-7b94d098.entry.js → p-95db0124.entry.js} +1 -1
  214. package/dist/twilight/{p-048110b6.entry.js → p-965fe2b3.entry.js} +1 -1
  215. package/dist/twilight/{p-2a461d47.entry.js → p-9797a552.entry.js} +1 -1
  216. package/dist/twilight/{p-9fe2c98c.entry.js → p-9d937a82.entry.js} +1 -1
  217. package/dist/twilight/{p-CnDmcHhx.js → p-BGB1zYFQ.js} +1 -1
  218. package/dist/twilight/{p-BX85PU_v.js → p-BLbGjdAU.js} +1 -1
  219. package/dist/twilight/p-CHf8XdiS.js +4 -0
  220. package/dist/twilight/{p-CgYN55XK.js → p-CV1rqKQz.js} +1 -1
  221. package/dist/twilight/{p-B3GTMJbg.js → p-CofhuO2Z.js} +1 -1
  222. package/dist/twilight/{p-Dk3aAnUR.js → p-CvLPGpFQ.js} +1 -1
  223. package/dist/twilight/{p-DOwnqQpN.js → p-D5AsuzfF.js} +1 -1
  224. package/dist/twilight/{p-BIoGLthd.js → p-DbzHZVd1.js} +1 -1
  225. package/dist/twilight/p-a08f5eae.entry.js +4 -0
  226. package/dist/twilight/{p-05233dda.entry.js → p-a0a6a255.entry.js} +1 -1
  227. package/dist/twilight/{p-89ce22bc.entry.js → p-a386b02a.entry.js} +1 -1
  228. package/dist/twilight/{p-22bafc5e.entry.js → p-a5df57f9.entry.js} +1 -1
  229. package/dist/twilight/{p-0d2d4bf1.entry.js → p-ac7f094e.entry.js} +1 -1
  230. package/dist/twilight/{p-1ec20122.entry.js → p-af3d4d0d.entry.js} +1 -1
  231. package/dist/twilight/{p-9cd55815.entry.js → p-bb0585cc.entry.js} +1 -1
  232. package/dist/twilight/{p-b701e858.entry.js → p-c0ab0fc6.entry.js} +1 -1
  233. package/dist/twilight/{p-d5e24adc.entry.js → p-c3f515ae.entry.js} +1 -1
  234. package/dist/twilight/{p-c86e684b.entry.js → p-c7719ce9.entry.js} +1 -1
  235. package/dist/twilight/{p-924ee352.entry.js → p-c90a6440.entry.js} +1 -1
  236. package/dist/twilight/{p-fd59d4f2.entry.js → p-cf64bb24.entry.js} +1 -1
  237. package/dist/twilight/{p-296039d7.entry.js → p-d64027b9.entry.js} +1 -1
  238. package/dist/twilight/{p-48ac6a0a.entry.js → p-db4f5b38.entry.js} +1 -1
  239. package/dist/twilight/p-de42ef8c.entry.js +4 -0
  240. package/dist/twilight/{p-a2249582.entry.js → p-dfc75ce2.entry.js} +1 -1
  241. package/dist/twilight/{p-c72f3795.entry.js → p-e0ce2c0d.entry.js} +1 -1
  242. package/dist/twilight/{p-98cacd53.entry.js → p-e0e61f73.entry.js} +1 -1
  243. package/dist/twilight/{p-2594518e.entry.js → p-e1bf6d23.entry.js} +1 -1
  244. package/dist/twilight/{p-5593e4a3.entry.js → p-e2c6ed54.entry.js} +1 -1
  245. package/dist/twilight/{p-57bc544c.entry.js → p-f1156ab8.entry.js} +1 -1
  246. package/dist/twilight/{p-f477fb8e.entry.js → p-f1be81ba.entry.js} +1 -1
  247. package/dist/twilight/{p-CBnUMxpk.js → p-f2v0udIe.js} +1 -1
  248. package/dist/twilight/{p-4afaba5f.entry.js → p-f8fb3130.entry.js} +1 -1
  249. package/dist/twilight/{p-18b2b205.entry.js → p-f9fcf183.entry.js} +1 -1
  250. package/dist/twilight/{p-b97da3f0.entry.js → p-fc6ddedc.entry.js} +1 -1
  251. package/dist/twilight/{p-CK0rWcfw.js → p-tacIS_Xg.js} +1 -1
  252. package/dist/twilight/twilight.esm.js +1 -1
  253. package/dist/types/Helpers/Helper.d.ts +2 -0
  254. package/dist/types/components/salla-offer/interfaces.d.ts +9 -7
  255. package/dist/types/components/salla-offer/salla-offer.d.ts +35 -36
  256. package/dist/types/components/salla-product-card/salla-product-card.d.ts +4 -0
  257. package/dist/types/components/salla-products-list/salla-products-list.d.ts +4 -0
  258. package/dist/types/components.d.ts +18 -2
  259. package/package.json +5 -5
  260. package/dist/twilight/p-838d98d5.entry.js +0 -4
  261. package/dist/twilight/p-DgNC8L6e.js +0 -4
  262. package/dist/twilight/p-e0d8ec2f.entry.js +0 -4
  263. package/dist/twilight/p-fcd32f66.entry.js +0 -4
@@ -1,4 +0,0 @@
1
- /*!
2
- * Crafted with ❤ by Salla
3
- */
4
- import{a as e}from"./p-CgtvEd63.js";salla.event.setMaxListeners(100);var t=new class{setIncludes(e){return this.includes=e,this}toggleElementClassIf(e,t,r,a){t=Array.isArray(t)?t:t.split(" "),r=Array.isArray(r)?r:r.split(" ");let s=a(e);return e?.classList.remove(...s?r:t),e?.classList.add(...s?t:r),this}toggleClassIf(e,t,r,a){return document.querySelectorAll(e).forEach((e=>this.toggleElementClassIf(e,t,r,a))),this}isValidEmail(e){return/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(e).toLowerCase())}filterEmojies(e){return e.replace(/(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|\ud83c[\ude32-\ude3a]|\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])/g,"")}debounce(e,...t){return this.debounce_||(this.debounce_=salla.helpers.debounce(((e,...t)=>e(...t)),500)),this.debounce_(e,...t)}getProductsSource(e){return{"brands.single":"brands","product.index":"categories","product.index.latest":"latest","product.index.offers":"offers","product.index.search":"search","customer.wishlist":"wishlist","landing-page":"landing-page","product.index.tag":"tags","product.index.sales":"sales","components.most_sales_products":"sales"}[e||salla.config.get("page.slug")]||e||"latest"}getApiSource(e){return{recently:"selected"}[e]||e}getPageTitleForSource(e){return(e={brands:"common.titles.brands",latest:"blocks.home.latest_products",offers:"common.titles.discounts",reorder:"common.titles.products",sales:"common.titles.most_sales"}[e])?salla.lang.get(e):""}getProductsSourceValue(e,t){const r=this.getProductsSource(e);let a=null;if(t)try{a="string"==typeof t?JSON.parse(t):t}catch(e){console.error("Failed to parse JSON string in sourceValue:",e)}if(!["search","json","offers","latest","sales","related"].includes(r)){if(Array.isArray(a)&&a.length)return a;if(Array.isArray(a)&&!a.length)return"";if("number"==typeof a)return[a];if(!t&&["categories","tags","brands"].includes(e))return[salla.config.get("page.id")]}return a||t?a||t:"search"===r?new URLSearchParams(window.location.search).get("q")||"":salla.config.get("page.id")}extractFiltersFromUrl(e){let t={};return e.forEach(((e,r)=>{const a=r.match(/^filters\[(.*?)\](\[(.*?)\])?$/u);if(a){const r=a[1],s=a[3];s?(t[r]=t[r]||{},t[r][s]=e):t[r]=e}else{const a=r.match(/^(.*?)$/u);a&&(t[a[1]]=e)}})),t}async injectExtraFieldsToResponse(e){if(!e||!this.includes)return e;const t=e.data.map((e=>e.id));try{const{data:r}=await this.fetchImagesAndOptions(t);if(this.injectOptionsAndImages(e.data,r),!this.includes.includes("metadata"))return e;const a=await salla.api.metadata.fetchValues("product",t);return e.data.forEach((e=>{e.metadata=a.data.find((t=>parseInt(t.entity_id)===parseInt(e.id)))})),e}catch(e){throw console.error("Error in injectExtraFieldsToResponse:",e),e}}fetchImagesAndOptions(e){return this.productsIncludes().length?salla.api.product.fetchOptions(e,{with:this.productsIncludes()}):Promise.resolve({data:[]})}injectOptionsAndImages(e,t){return t.length?e.map((e=>(this.includes.filter((e=>"metadata"!==e)).forEach((r=>{const a=t.find((t=>parseInt(t.id)===parseInt(e.id)));e[r]=a?a[r]:null})),e))):null}productsIncludes(){return this.includes?.filter((e=>"metadata"!=e))}saveProductSource(e){if(e)try{sessionStorage.setItem("s-viewed-source",e)}catch(e){salla.logger.warn("Error saving product source to session storage")}}parseJson(e){if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(e){salla.logger.error("Failed to parse includes as JSON:",e)}return null}getProductSchemaMarkupScript(e){const t=document.createElement("script");return t.type="application/ld+json",t.text=JSON.stringify({"@context":"http://schema.org","@type":"Product",name:e?.name,image:e?.image?.url||e?.thumbnail,description:e?.description,brand:{"@type":"Brand",logo:e?.brand?.logo},offers:{"@type":"Offer",price:e?.price}}),t}createProductSchema(e,t){let r={productID:`${e.id}`,"@type":"Product",name:e.name,url:e.url,image:e.image.url||e.image,description:e.description||e.subtitle||e.name,...e.sku&&e.sku.length>0&&{sku:e.sku},offers:{"@type":"Offer",url:e.url,priceCurrency:e.currency,price:e.price,itemCondition:"NewCondition",availability:e.is_available?"InStock":"OutOfStock",priceValidUntil:e.discount_ends||new Date((new Date).setDate((new Date).getDate()+7)).toISOString().split("T")[0],priceSpecification:{"@type":"PriceSpecification",price:e.regular_price,priceCurrency:e.currency,valueAddedTaxIncluded:e.is_taxable},seller:{"@type":"Organization",name:salla.config.get("store.name")},shippingDetails:{"@type":"OfferShippingDetails",shippingRate:{"@type":"MonetaryAmount",value:"0",currency:e.currency||"SAR"},deliveryTime:{"@type":"ShippingDeliveryTime",businessDays:{"@type":"OpeningHoursSpecification",dayOfWeek:["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]},cutoffTime:"14:00"}},hasMerchantReturnPolicy:{"@type":"MerchantReturnPolicy",returnPolicyCategory:"https://schema.org/MerchantReturnFiniteReturnWindow",merchantReturnDays:30,returnMethod:"https://schema.org/ReturnByMail",returnFees:"https://schema.org/FreeReturn"}}};return e.rating?.stars&&(r.aggregateRating={"@type":"AggregateRating",ratingValue:e.rating.stars,reviewCount:e.rating.count}),{"@type":"ListItem",position:t,item:r}}generateProductSchema(e){const t="salla-product-schema-script";if(document.getElementById(t))return void salla.logger.warn(`already added schema-script with id (${t})!`);const r=document.createElement("script");r.type="application/ld+json",r.id=t;const a={"@context":"https://schema.org","@type":"ItemList",name:salla.config.get("page.title"),itemListElement:e.map(((e,t)=>this.createProductSchema(e,t+1)))};r.textContent=JSON.stringify(a),document.head.appendChild(r)}formatDateFromString(e,t,r="en"){const a={en:"Invalid Date",ar:"تاريخ غير صالح"};if(!e||"string"!=typeof e||""===e.trim())return a[r];let s;if(/^\d+$/.test(e)){const t=parseInt(e);s=new Date(t>1e12?t:1e3*t)}else s=new Date(e);return isNaN(s.getTime())?a[r]:`${{en:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ar:["الأحد","الاثنين","الثلاثاء","الأربعاء","الخميس","الجمعة","السبت"]}[r][s.getDay()]} ${t(s.getDate(),"en"===r)} ${{en:["January","February","March","April","May","June","July","August","September","October","November","December"],ar:["يناير","فبراير","مارس","أبريل","مايو","يونيو","يوليو","أغسطس","سبتمبر","أكتوبر","نوفمبر","ديسمبر"]}[r][s.getMonth()]} ${t(s.getFullYear(),"en"===r)}`}copyToClipboard(e){var t=e.target.innerText;navigator.clipboard.writeText(t).then((()=>{console.log("Text copied to clipboard: "+t)})).catch((e=>{console.error("Unable to copy text to clipboard",e)}))}animateItems(t){t&&e({targets:t,opacity:[0,1],duration:1200,translateY:[20,0],delay:function(e,t){return 100*t},easing:"easeOutExpo",complete:function(){t.forEach((e=>{e.classList.add("animated")}))}})}createReviewObject(e){return{"@type":"Review",author:{"@type":"Person",name:e.name},reviewBody:e.content,reviewRating:{"@type":"Rating",bestRating:"5",ratingValue:e.stars,worstRating:"1"}}}generateReviewSchema(e){const t=document.createElement("script");t.type="application/ld+json";const r={"@context":"http://schema.org/","@type":"Store",name:salla.config.get("store.name"),url:salla.config.get("store.url"),address:"الرياض",review:e.map((e=>this.createReviewObject(e))),aggregateRating:{"@type":"AggregateRating",ratingValue:e.reduce(((e,t)=>e+t.stars),0)/e.length,reviewCount:e.length}};t.textContent=JSON.stringify(r),document.head.appendChild(t)}};export{t as H}
@@ -1,4 +0,0 @@
1
- /*!
2
- * Crafted with ❤ by Salla
3
- */
4
- import{r as s,h as e,a as t}from"./p-CgYN55XK.js";var i,r;!function(s){s.ProductDetail="product.single",s.Cart="cart"}(i||(i={})),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"}(r||(r={}));const a=class{constructor(e){s(this,e),this.productCardComponent="custom-salla-product-card",this.offersList=[],this.isMultipleBank=!1,this.isBankOffer=!1,this.canRender=!1,this.showOffer=salla.config.get("store.settings.product.show_special_offers"),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.multipleBankOfferTitleText=salla.lang.get("pages.offer.multiple_bank_offers_title"),this.multipleBankOfferTitleDescription=salla.lang.get("pages.offer.multiple_bank_offers_message"),this.buy_quantity_text=s=>salla.lang.get("pages.offer.buy_quantity",{quantity:s}),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.multipleBankOfferTitleText=salla.lang.get("pages.offer.multiple_bank_offers_title"),this.multipleBankOfferTitleDescription=salla.lang.get("pages.offer.multiple_bank_offers_message"),this.buy_quantity_text(0)})),salla.onReady((()=>{this.currentPage=salla.config.get("page.slug"),this.userCurrency=salla.config.get("currencies")[salla.config.get("user.currency_code")].symbol})),this.categorySlot=this.host.querySelector('[slot="category"]')?.innerHTML||'<a href={url} class="s-offer-slide-cat-entry"><i class={icon}></i><h4>{name}</h4></a>'}async getEndpointByPageName(){return this.currentPage==i.Cart?`offers/cart/${await Salla.cart.getCurrentCartId()}`:this.currentPage==i.ProductDetail?`offers/product/${salla.config.get("page.id")}`:"offers"}emitPromotionViewed(){this.offersList.length&&this.canRender&&this.showOffer&&salla.event.emit("promotion::viewed",[{id:this.offersList[0].id,name:this.offersList[0].title,creative:this.offersList[0].description||"",position:1}])}emitPromotionClicked(s=1){this.offersList.length&&this.canRender&&this.showOffer&&salla.event.emit("promotion::clicked",[{id:this.offersList[0].id,name:this.offersList[0].title,creative:this.offersList[0].description||"",position:s}])}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((s=>{if(!(this.offersList=s.data).length)throw new Error("salla-offers:: There is no offers!");const e=this.offersList.find((s=>[r.SpecialPrice,r.Bank,r.BuyXGetY,r.DiscountsTable].includes(s.type)));if(!e)throw new Error("salla-offers:: Offer type not supported yet!");if(e.type===r.DiscountsTable)return this.offersList=[e];if(this.isBankOffer=e.type===r.Bank)return this.offersList=this.offersList.filter((s=>s.type===r.Bank)),this.isMultipleBank=this.offersList.length>1,this.offersList;if(e.type===r.SpecialPrice){const s=e.details;return"product"===s.apply_to?salla.product.api.fetch({source:"selected",source_value:s.targets}).then((s=>(e.details.products=s.data,this.offersList=[e]))):salla.product.api.categories().then((t=>{const i=this.findCategories(t.data,s.targets);return e.details.categories=i,this.offersList=[e]}))}const t=e.details.get;return"products"===t.source?salla.product.api.fetch({source:"selected",source_value:t.source_value}).then((s=>(t.products=s.data,e.details.get=t,this.offersList=[e]))):salla.product.api.categories().then((s=>(t.categories=this.findCategories(s.data,t.source_value),e.details.get=t,this.offersList=[e])))})).then((s=>{salla.storage.set(this.getStorageKey(),{offers:s,stored_at:(new Date).getTime()}),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,e){let t=[];for(const i of s)e.includes(i.id_||i.id)&&t.push(i),i.sub_categories?.length>0&&(t=t.concat(this.findCategories(i.sub_categories,e)));return t}getStorageKey(){try{const s=salla.config.get("page.slug").replace(".","_"),e=salla.lang.getLocale(),t=salla.config.currency().code;if(!s||!e||!t)throw new Error("Unable to get the storage key.");return`s-offers-${s}-${salla.config.get("page.id")}-${e}-${t}`}catch(s){return""}}getOffersFromStorage(){let s=salla.storage.get(this.getStorageKey());return!s||s.stored_at<(new Date).getTime()-6e5?(salla.storage.remove(this.getStorageKey()),null):(this.canRender=!0,Promise.resolve(s.offers))}render(){if(!this.offersList.length||!this.canRender||!this.showOffer)return null;const s=this.offersList[0],t={"block-title":this.isBankOffer?this.isMultipleBank?this.multipleBankOfferTitleText:null:s.title,"block-subTitle":this.isBankOffer?this.isMultipleBank?this.multipleBankOfferTitleDescription:null:s.description,"show-controls":this.isMultipleBank};return e("div",{class:"s-offer-wrapper",onClick:()=>this.emitPromotionClicked()},e("p",{class:"s-offer-corner-badge"},this.special_offer_text),e("salla-slider",{type:"carousel",id:"offer-slider",...t},e("div",{slot:"items"},this.renderSectionForOfferType(s.type))))}renderSectionForOfferType(s){return this.isBankOffer?this.renderBankSection():s==r.SpecialPrice?this.renderSpecialPriceSection():s==r.BuyXGetY?this.renderBuyXGetYSection():this.renderDiscountTableSection()}getCategoriesSection(s){return e("div",{class:"s-offer-slide-one-sixth swiper-slide",innerHTML:this.categorySlot.replace(/\{url\}/g,s.url).replace(/\{icon\}/g,s.icon||"sicon-store").replace(/\{name\}/g,s.name)})}renderBuyXGetYSection(){const s=this.offersList[0].details;return[s.get.products?.map((s=>e("div",{class:"s-offer-slide-one-fourth"},this.hasCustomComponent?e(this.productCardComponent,{product:s}):e("salla-product-card",{"shadow-on-hover":!0,product:s})))),s.get.categories?.map((s=>this.getCategoriesSection(s)))]}renderBankSection(){return this.offersList.map((s=>e("div",{class:{"s-offer-slide-one-sixth":this.isMultipleBank,"s-offer-bank-wrapper-sinlge-item":!this.isMultipleBank}},e("div",{class:{"s-offer-bank-wrapper":!0,"s-offer-slide-one-sixth":!this.isMultipleBank,"s-offer-bank-wrapper-multi-spacer":this.isMultipleBank}},e("div",{class:"s-offer-bank-logo"},e("img",{src:s.details.logo||salla.url.cdn("images/s-empty.png"),"data-src":s.details.logo,alt:s.title+" offer"})),e("ul",{class:"s-offer-bank-payment-wrapper"},s.details.payments.map((s=>e("li",{class:"s-offer-bank-payment-single"},e("img",{src:salla.url.cdn("images/payment/"+s+".png")||salla.url.cdn("images/s-empty.png"),"data-src":salla.url.cdn("images/payment/"+s+".png"),alt:"payment"}))))),this.isMultipleBank?e("p",{class:"s-offer-bank-payment-discount-percent"},`${this.product_discount_text} ${s.details.discount_value}${"percentage"===s.details.discount_type&&"%"}`):""),this.isMultipleBank?"":e("div",{class:"s-offer-bank-message s-offer-slide-one-fourth"},e("h2",null,this.offersList[0].title),e("p",{innerHTML:this.generateBankDescription(this.offersList[0].description,s.details.discount_value)})))))}generateBankDescription(s,e){return s.replace(new RegExp(`${e} %`),`<span class="s-offer-bank-message-amount">${e} %</span>`)}renderDiscountTableSection(){let s=this.offersList[0].details.show_price_after_discount;return this.offersList[0].details.discounts?.map((t=>e("div",{class:"s-offer-slide-one-fourth"},e("div",{class:"s-offer-slide-offer-entry"},e("div",{class:"s-offer-slide-offer-entry-price-quantity-container"},e("p",{class:"s-offer-slide-offer-entry-quantity"},this.buy_quantity_text(t.quantity)),s?e("div",{class:"s-offer-slide-offer-entry-price"},e("span",null,this.offer_with_price_text),e("span",{class:"s-offer-slide-offer-entry-price-amount"},t.discounted_amount)," ",e("span",null,this.userCurrency)):""),e("p",{class:"s-offer-slide-offer-entry-price-amount-percent"},this.with_discount_text,"(",e("span",null,t.percentage,!!t.percentage&&"%"),")")))))}renderSpecialPriceSection(){const s=this.offersList[0].details;return["product"===s.apply_to&&s.products?.map((s=>e("div",{class:"s-offer-slide-one-fourth"},this.hasCustomComponent?e(this.productCardComponent,{product:s}):e("salla-product-card",{"shadow-on-hover":!0,product:s})))),"category"===s.apply_to&&s.categories?.map((s=>this.getCategoriesSection(s)))]}get host(){return t(this)}};a.style='.s-offer-wrapper .s-slider-block__title h2{font-size:1.125rem;line-height:1.75rem;color:#f87171}.s-offer-wrapper .s-slider-block__title h2::before{font-family:"sallaicons";content:"\\ee30" !important;position:absolute;top:1rem;font-size:3rem;font-weight:400;line-height:1;color:#fef2f2}.s-offer-bank-wrapper-sinlge-item{display:flex;align-items:center !important;gap:14px}.s-offer-bank-wrapper{display:flex !important;width:100% !important}';export{a as salla_offer}
@@ -1,4 +0,0 @@
1
- /*!
2
- * Crafted with ❤ by Salla
3
- */
4
- import{r as t,c as s,h as i,H as e,a}from"./p-CgYN55XK.js";import{a as o}from"./p-CgtvEd63.js";import{S as r}from"./p-DiKTtDW5.js";import{H as h}from"./p-DgNC8L6e.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.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.setAttribute("horizontal",!0),this.hasCustomComponent||t.setAttribute("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.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-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}