@salla.sa/twilight-components 2.14.448 → 2.14.449

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 (305) hide show
  1. package/dist/cjs/{filepond-xdMsJQmk.js → filepond-f9KbKIYn.js} +1 -1
  2. package/dist/cjs/{filepond-plugin-file-poster-eC1dn4xl.js → filepond-plugin-file-poster-BSdUMAjs.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-validate-size-_2IuCCff.js → filepond-plugin-file-validate-size-YLL5nfmo.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-type-BL0DbAnh.js → filepond-plugin-file-validate-type-DnRb2szA.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-image-edit-CgKir2xD.js → filepond-plugin-image-edit-BDCQgpe-.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-exif-orientation-syoj1Juw.js → filepond-plugin-image-exif-orientation-CDJWoL6I.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-preview-B3kAVSrA.js → filepond-plugin-image-preview-1OlWyiTm.js} +1 -1
  8. package/dist/cjs/{functions-B2luUM6v.js → functions-BZosuGw4.js} +1 -1
  9. package/dist/cjs/{index-uoA36zqH.js → index-C7gO-zm5.js} +2 -2
  10. package/dist/cjs/{index-BMR8pPXK.js → index-Dj3X-WjA.js} +1 -1
  11. package/dist/cjs/loader.cjs.js +1 -1
  12. package/dist/cjs/salla-accordion-body_2.cjs.entry.js +1 -1
  13. package/dist/cjs/salla-accordion_6.cjs.entry.js +51 -14
  14. package/dist/cjs/salla-add-product-button_5.cjs.entry.js +1 -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_2.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-cashback-banner.cjs.entry.js +1 -1
  25. package/dist/cjs/salla-comment-form_8.cjs.entry.js +1 -1
  26. package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
  27. package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
  28. package/dist/cjs/salla-cookies-bar.cjs.entry.js +1 -1
  29. package/dist/cjs/salla-count-down.cjs.entry.js +1 -1
  30. package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
  31. package/dist/cjs/salla-delivery-promise.cjs.entry.js +1 -1
  32. package/dist/cjs/salla-edit-order-button.cjs.entry.js +1 -1
  33. package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
  34. package/dist/cjs/salla-filters.cjs.entry.js +1 -1
  35. package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +1 -1
  36. package/dist/cjs/salla-gifting.cjs.entry.js +1 -1
  37. package/dist/cjs/salla-hook.cjs.entry.js +1 -1
  38. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
  39. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  40. package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
  41. package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
  42. package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
  43. package/dist/cjs/salla-loyalty-banner.cjs.entry.js +2 -2
  44. package/dist/cjs/salla-loyalty-hero_2.cjs.entry.js +2 -2
  45. package/dist/cjs/salla-loyalty-panel.cjs.entry.js +3 -3
  46. package/dist/cjs/salla-loyalty-points-banner.cjs.entry.js +1 -1
  47. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  48. package/dist/cjs/salla-loyalty-program.cjs.entry.js +3 -3
  49. package/dist/cjs/salla-loyalty-reward.cjs.entry.js +2 -2
  50. package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
  51. package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
  52. package/dist/cjs/salla-map.cjs.entry.js +1 -1
  53. package/dist/cjs/salla-menu.cjs.entry.js +1 -1
  54. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  55. package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
  56. package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
  57. package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
  58. package/dist/cjs/salla-next-order-coupon.cjs.entry.js +1 -1
  59. package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
  60. package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
  61. package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
  62. package/dist/cjs/salla-offer.cjs.entry.js +1 -1
  63. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
  64. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  65. package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
  66. package/dist/cjs/salla-order-edit-item.cjs.entry.js +1 -1
  67. package/dist/cjs/salla-order-edit-product-card.cjs.entry.js +1 -1
  68. package/dist/cjs/salla-order-edit.cjs.entry.js +1 -1
  69. package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
  70. package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
  71. package/dist/cjs/salla-orders.cjs.entry.js +1 -1
  72. package/dist/cjs/salla-payments.cjs.entry.js +1 -1
  73. package/dist/cjs/salla-placeholder.cjs.entry.js +1 -1
  74. package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
  75. package/dist/cjs/salla-product-card-embed.cjs.entry.js +1 -1
  76. package/dist/cjs/salla-product-card_2.cjs.entry.js +1 -1
  77. package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
  78. package/dist/cjs/salla-products-list.cjs.entry.js +1 -1
  79. package/dist/cjs/salla-progress-bar.cjs.entry.js +1 -1
  80. package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
  81. package/dist/cjs/salla-rating-modal.cjs.entry.js +1 -1
  82. package/dist/cjs/salla-reward-action_4.cjs.entry.js +3 -3
  83. package/dist/cjs/salla-scopes.cjs.entry.js +1 -1
  84. package/dist/cjs/salla-search.cjs.entry.js +1 -1
  85. package/dist/cjs/salla-skeleton.cjs.entry.js +1 -1
  86. package/dist/cjs/salla-slider.cjs.entry.js +1 -1
  87. package/dist/cjs/salla-social-share.cjs.entry.js +1 -1
  88. package/dist/cjs/salla-social.cjs.entry.js +1 -1
  89. package/dist/cjs/salla-tab-content_3.cjs.entry.js +1 -1
  90. package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
  91. package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
  92. package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
  93. package/dist/cjs/salla-user-menu.cjs.entry.js +1 -1
  94. package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
  95. package/dist/cjs/salla-user-settings.cjs.entry.js +1 -1
  96. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  97. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  98. package/dist/cjs/{tracked-promise-CVeKKQ0b.js → tracked-promise-CMALwoa6.js} +1 -1
  99. package/dist/cjs/twilight.cjs.js +1 -1
  100. package/dist/cjs/{vanilla-picker-jTWa07cO.js → vanilla-picker-BEliYBNM.js} +1 -1
  101. package/dist/collection/components/salla-breadcrumb/salla-breadcrumb.js +50 -13
  102. package/dist/components/index.js +2 -2
  103. package/dist/components/salla-breadcrumb.js +50 -13
  104. package/dist/esm/{filepond-BbuLIuP0.js → filepond-CDpPHT7z.js} +1 -1
  105. package/dist/esm/{filepond-plugin-file-poster-DlDdJpXD.js → filepond-plugin-file-poster-BOtfCgt6.js} +1 -1
  106. package/dist/esm/{filepond-plugin-file-validate-size-BYkUUSGJ.js → filepond-plugin-file-validate-size--uO_3T9g.js} +1 -1
  107. package/dist/esm/{filepond-plugin-file-validate-type-Cz9XrV5V.js → filepond-plugin-file-validate-type-DnJbL2zb.js} +1 -1
  108. package/dist/esm/{filepond-plugin-image-edit-CpEK0C8_.js → filepond-plugin-image-edit-CjUUwl1o.js} +1 -1
  109. package/dist/esm/{filepond-plugin-image-exif-orientation-D6RHOJuD.js → filepond-plugin-image-exif-orientation-DkjfYMVD.js} +1 -1
  110. package/dist/esm/{filepond-plugin-image-preview-D6ZgXCUp.js → filepond-plugin-image-preview-3LlHu8_B.js} +1 -1
  111. package/dist/esm/{functions-BwIeBNND.js → functions-BQD6jHG4.js} +1 -1
  112. package/dist/esm/{index-CETV5IHH.js → index-B5mrC7UX.js} +1 -1
  113. package/dist/esm/{index-BHYtfMwX.js → index-CFtXUFT2.js} +2 -2
  114. package/dist/esm/loader.js +2 -2
  115. package/dist/esm/salla-accordion-body_2.entry.js +1 -1
  116. package/dist/esm/salla-accordion_6.entry.js +51 -14
  117. package/dist/esm/salla-add-product-button_5.entry.js +1 -1
  118. package/dist/esm/salla-advertisement.entry.js +1 -1
  119. package/dist/esm/salla-alert_2.entry.js +1 -1
  120. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  121. package/dist/esm/salla-apps-icons.entry.js +1 -1
  122. package/dist/esm/salla-badge.entry.js +1 -1
  123. package/dist/esm/salla-booking-field_7.entry.js +10 -10
  124. package/dist/esm/salla-bullet-delivery_2.entry.js +1 -1
  125. package/dist/esm/salla-cart-coupons.entry.js +1 -1
  126. package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
  127. package/dist/esm/salla-cashback-banner.entry.js +1 -1
  128. package/dist/esm/salla-comment-form_8.entry.js +1 -1
  129. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  130. package/dist/esm/salla-contacts.entry.js +1 -1
  131. package/dist/esm/salla-cookies-bar.entry.js +1 -1
  132. package/dist/esm/salla-count-down.entry.js +1 -1
  133. package/dist/esm/salla-custom-fields.entry.js +1 -1
  134. package/dist/esm/salla-delivery-promise.entry.js +1 -1
  135. package/dist/esm/salla-edit-order-button.entry.js +1 -1
  136. package/dist/esm/salla-filters-widget.entry.js +1 -1
  137. package/dist/esm/salla-filters.entry.js +1 -1
  138. package/dist/esm/salla-fulfillment-methods.entry.js +1 -1
  139. package/dist/esm/salla-gifting.entry.js +1 -1
  140. package/dist/esm/salla-hook.entry.js +1 -1
  141. package/dist/esm/salla-infinite-scroll.entry.js +1 -1
  142. package/dist/esm/salla-installment.entry.js +1 -1
  143. package/dist/esm/salla-list-tile.entry.js +1 -1
  144. package/dist/esm/salla-localization-modal.entry.js +1 -1
  145. package/dist/esm/salla-login-modal.entry.js +1 -1
  146. package/dist/esm/salla-loyalty-banner.entry.js +2 -2
  147. package/dist/esm/salla-loyalty-hero_2.entry.js +2 -2
  148. package/dist/esm/salla-loyalty-panel.entry.js +3 -3
  149. package/dist/esm/salla-loyalty-points-banner.entry.js +1 -1
  150. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  151. package/dist/esm/salla-loyalty-program.entry.js +3 -3
  152. package/dist/esm/salla-loyalty-reward.entry.js +2 -2
  153. package/dist/esm/salla-loyalty.entry.js +1 -1
  154. package/dist/esm/salla-maintenance-alert.entry.js +1 -1
  155. package/dist/esm/salla-map.entry.js +1 -1
  156. package/dist/esm/salla-menu.entry.js +1 -1
  157. package/dist/esm/salla-metadata.entry.js +1 -1
  158. package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
  159. package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
  160. package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
  161. package/dist/esm/salla-next-order-coupon.entry.js +1 -1
  162. package/dist/esm/salla-notification-item.entry.js +1 -1
  163. package/dist/esm/salla-notifications.entry.js +1 -1
  164. package/dist/esm/salla-offer-modal.entry.js +1 -1
  165. package/dist/esm/salla-offer.entry.js +1 -1
  166. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  167. package/dist/esm/salla-order-details-options.entry.js +1 -1
  168. package/dist/esm/salla-order-details.entry.js +1 -1
  169. package/dist/esm/salla-order-edit-item.entry.js +1 -1
  170. package/dist/esm/salla-order-edit-product-card.entry.js +1 -1
  171. package/dist/esm/salla-order-edit.entry.js +1 -1
  172. package/dist/esm/salla-order-summary.entry.js +1 -1
  173. package/dist/esm/salla-order-totals-card.entry.js +1 -1
  174. package/dist/esm/salla-orders.entry.js +1 -1
  175. package/dist/esm/salla-payments.entry.js +1 -1
  176. package/dist/esm/salla-placeholder.entry.js +1 -1
  177. package/dist/esm/salla-price-range.entry.js +1 -1
  178. package/dist/esm/salla-product-card-embed.entry.js +1 -1
  179. package/dist/esm/salla-product-card_2.entry.js +1 -1
  180. package/dist/esm/salla-product-size-guide.entry.js +1 -1
  181. package/dist/esm/salla-products-list.entry.js +1 -1
  182. package/dist/esm/salla-progress-bar.entry.js +1 -1
  183. package/dist/esm/salla-quick-order.entry.js +1 -1
  184. package/dist/esm/salla-rating-modal.entry.js +1 -1
  185. package/dist/esm/salla-reward-action_4.entry.js +3 -3
  186. package/dist/esm/salla-scopes.entry.js +1 -1
  187. package/dist/esm/salla-search.entry.js +1 -1
  188. package/dist/esm/salla-skeleton.entry.js +1 -1
  189. package/dist/esm/salla-slider.entry.js +1 -1
  190. package/dist/esm/salla-social-share.entry.js +1 -1
  191. package/dist/esm/salla-social.entry.js +1 -1
  192. package/dist/esm/salla-tab-content_3.entry.js +1 -1
  193. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  194. package/dist/esm/salla-tooltip.entry.js +1 -1
  195. package/dist/esm/salla-trust-badges.entry.js +1 -1
  196. package/dist/esm/salla-user-menu.entry.js +1 -1
  197. package/dist/esm/salla-user-profile.entry.js +1 -1
  198. package/dist/esm/salla-user-settings.entry.js +1 -1
  199. package/dist/esm/salla-verify.entry.js +1 -1
  200. package/dist/esm/salla-wallet.entry.js +1 -1
  201. package/dist/esm/{tracked-promise-p8K_AJAQ.js → tracked-promise-7zOvv3M6.js} +1 -1
  202. package/dist/esm/twilight.js +2 -2
  203. package/dist/esm/{vanilla-picker-CwN-g5m_.js → vanilla-picker-yptjYbav.js} +1 -1
  204. package/dist/twilight/{p-6d000a1b.entry.js → p-00c80ce0.entry.js} +1 -1
  205. package/dist/twilight/{p-7c348484.entry.js → p-03aed385.entry.js} +1 -1
  206. package/dist/twilight/{p-c651f264.entry.js → p-0f7f0c9a.entry.js} +1 -1
  207. package/dist/twilight/{p-b9126729.entry.js → p-10adfec3.entry.js} +1 -1
  208. package/dist/twilight/{p-c3703ca3.entry.js → p-10f3641c.entry.js} +1 -1
  209. package/dist/twilight/{p-64cc4267.entry.js → p-121ca1bf.entry.js} +1 -1
  210. package/dist/twilight/{p-5031ae92.entry.js → p-187ddba3.entry.js} +1 -1
  211. package/dist/twilight/{p-1d5459db.entry.js → p-210b5cd5.entry.js} +1 -1
  212. package/dist/twilight/{p-ed91eae0.entry.js → p-2174a8e6.entry.js} +1 -1
  213. package/dist/twilight/{p-06642c76.entry.js → p-237ae017.entry.js} +1 -1
  214. package/dist/twilight/{p-9fc822b7.entry.js → p-26a0fdd4.entry.js} +1 -1
  215. package/dist/twilight/{p-c3466964.entry.js → p-2a3b2509.entry.js} +1 -1
  216. package/dist/twilight/{p-0ad04ca2.entry.js → p-2b3e3ca7.entry.js} +1 -1
  217. package/dist/twilight/{p-c1fa4ddb.entry.js → p-2bb0e5c5.entry.js} +1 -1
  218. package/dist/twilight/{p-56916095.entry.js → p-31d281ab.entry.js} +1 -1
  219. package/dist/twilight/{p-f06bd0b0.entry.js → p-3a067383.entry.js} +1 -1
  220. package/dist/twilight/{p-734ff28a.entry.js → p-3c328960.entry.js} +1 -1
  221. package/dist/twilight/{p-be8ac1a3.entry.js → p-3c479c07.entry.js} +1 -1
  222. package/dist/twilight/{p-3ce5738a.entry.js → p-3db06266.entry.js} +1 -1
  223. package/dist/twilight/{p-131ffbcc.entry.js → p-400ecb0a.entry.js} +1 -1
  224. package/dist/twilight/{p-788d2dea.entry.js → p-469c8350.entry.js} +1 -1
  225. package/dist/twilight/{p-BNaQSz6t.js → p-4HuZkmYv.js} +1 -1
  226. package/dist/twilight/{p-d25cd2ed.entry.js → p-52dada7c.entry.js} +1 -1
  227. package/dist/twilight/{p-cd48d7aa.entry.js → p-536d29ce.entry.js} +1 -1
  228. package/dist/twilight/{p-7cfef393.entry.js → p-54d8c2ca.entry.js} +1 -1
  229. package/dist/twilight/{p-86dd66bc.entry.js → p-564d8c45.entry.js} +1 -1
  230. package/dist/twilight/{p-1276ce95.entry.js → p-58face3f.entry.js} +1 -1
  231. package/dist/twilight/{p-2503c3ac.entry.js → p-59337a84.entry.js} +1 -1
  232. package/dist/twilight/{p-3c19f975.entry.js → p-5e1b51dd.entry.js} +1 -1
  233. package/dist/twilight/{p-96c5dcd0.entry.js → p-5e30b0bd.entry.js} +1 -1
  234. package/dist/twilight/{p-e4d102f5.entry.js → p-61269cd6.entry.js} +1 -1
  235. package/dist/twilight/{p-8ece10ce.entry.js → p-6ba1c14e.entry.js} +1 -1
  236. package/dist/twilight/{p-76cf66ad.entry.js → p-6ccdae0e.entry.js} +1 -1
  237. package/dist/twilight/{p-ba28e996.entry.js → p-764f3053.entry.js} +1 -1
  238. package/dist/twilight/{p-8eaa609b.entry.js → p-76bbabcb.entry.js} +1 -1
  239. package/dist/twilight/{p-bcab43fc.entry.js → p-7d3b048e.entry.js} +1 -1
  240. package/dist/twilight/{p-3eab400d.entry.js → p-7fcbc3ef.entry.js} +1 -1
  241. package/dist/twilight/p-8b578d2c.entry.js +4 -0
  242. package/dist/twilight/{p-10b11447.entry.js → p-918178f5.entry.js} +1 -1
  243. package/dist/twilight/{p-b678e909.entry.js → p-947aea47.entry.js} +1 -1
  244. package/dist/twilight/{p-aeaad4b5.entry.js → p-967fbc9c.entry.js} +1 -1
  245. package/dist/twilight/{p-404ac2a7.entry.js → p-97b47164.entry.js} +1 -1
  246. package/dist/twilight/{p-be186489.entry.js → p-99fa8ba6.entry.js} +1 -1
  247. package/dist/twilight/{p-DZivnLbg.js → p-B9HPqa9u.js} +1 -1
  248. package/dist/twilight/{p-2x5YwExe.js → p-BmPGKoL7.js} +1 -1
  249. package/dist/twilight/{p-BHYtfMwX.js → p-CFtXUFT2.js} +1 -1
  250. package/dist/twilight/{p-Cl7SIRPD.js → p-CUBlD0Kt.js} +1 -1
  251. package/dist/twilight/{p-BvqPxWPn.js → p-CsCwHOvQ.js} +2 -2
  252. package/dist/twilight/{p-Bvw0Axx9.js → p-CxOW9p-m.js} +1 -1
  253. package/dist/twilight/{p-lbjqzRH2.js → p-Cz2LJSD1.js} +1 -1
  254. package/dist/twilight/{p-D8Vw7Lrc.js → p-DRqWSUhZ.js} +1 -1
  255. package/dist/twilight/{p-BW6_yrjl.js → p-DVY4bWKx.js} +1 -1
  256. package/dist/twilight/{p-CTAPbMR3.js → p-DZLwjHmr.js} +1 -1
  257. package/dist/twilight/{p-Dvaa0hYf.js → p-Dw1i2i3R.js} +1 -1
  258. package/dist/twilight/{p-adebf2ac.entry.js → p-a19b9fcd.entry.js} +1 -1
  259. package/dist/twilight/{p-8581c249.entry.js → p-a22f93c7.entry.js} +1 -1
  260. package/dist/twilight/{p-2ccb281b.entry.js → p-a2b9f075.entry.js} +1 -1
  261. package/dist/twilight/{p-d03f8ab0.entry.js → p-a4de6d64.entry.js} +1 -1
  262. package/dist/twilight/{p-7b448d5b.entry.js → p-a5f6b737.entry.js} +1 -1
  263. package/dist/twilight/{p-acc76fc8.entry.js → p-a709602c.entry.js} +1 -1
  264. package/dist/twilight/{p-5c009bd1.entry.js → p-a832d2f6.entry.js} +1 -1
  265. package/dist/twilight/{p-13168745.entry.js → p-af8f9d9d.entry.js} +1 -1
  266. package/dist/twilight/{p-c6fe271a.entry.js → p-b04933fd.entry.js} +1 -1
  267. package/dist/twilight/{p-79371f48.entry.js → p-b3123f77.entry.js} +1 -1
  268. package/dist/twilight/{p-a52dd6b4.entry.js → p-b4108a9a.entry.js} +1 -1
  269. package/dist/twilight/{p-1d25ae1c.entry.js → p-b5184ea5.entry.js} +1 -1
  270. package/dist/twilight/{p-a1c7f1b1.entry.js → p-b57b8cae.entry.js} +1 -1
  271. package/dist/twilight/{p-d26e0eae.entry.js → p-b5bf31c8.entry.js} +1 -1
  272. package/dist/twilight/{p-b6f3083c.entry.js → p-b96744fc.entry.js} +1 -1
  273. package/dist/twilight/{p-47b4f13c.entry.js → p-bcbb8488.entry.js} +1 -1
  274. package/dist/twilight/{p-cc618f38.entry.js → p-bf4257bb.entry.js} +1 -1
  275. package/dist/twilight/{p-0f70ef8d.entry.js → p-bf76d88f.entry.js} +1 -1
  276. package/dist/twilight/{p-20e1f5b9.entry.js → p-c0491160.entry.js} +1 -1
  277. package/dist/twilight/{p-f67dd591.entry.js → p-c24749d7.entry.js} +1 -1
  278. package/dist/twilight/{p-0b271cf4.entry.js → p-c2fa334e.entry.js} +1 -1
  279. package/dist/twilight/{p-017e3198.entry.js → p-c4f9029a.entry.js} +1 -1
  280. package/dist/twilight/{p-202fcfc6.entry.js → p-c6ed7a7f.entry.js} +1 -1
  281. package/dist/twilight/{p-23aabd1c.entry.js → p-c79ac487.entry.js} +1 -1
  282. package/dist/twilight/{p-4bca0fab.entry.js → p-c987e5c4.entry.js} +1 -1
  283. package/dist/twilight/{p-f8369073.entry.js → p-ca38de68.entry.js} +1 -1
  284. package/dist/twilight/{p-0b8706e7.entry.js → p-cc06234d.entry.js} +1 -1
  285. package/dist/twilight/{p-cd2c961c.entry.js → p-d4db02e7.entry.js} +1 -1
  286. package/dist/twilight/{p-1786ed83.entry.js → p-d69b9a02.entry.js} +1 -1
  287. package/dist/twilight/{p-87063cf0.entry.js → p-d8cb14bd.entry.js} +1 -1
  288. package/dist/twilight/{p-d2a76aa4.entry.js → p-d8d6f688.entry.js} +1 -1
  289. package/dist/twilight/{p-a8ce09a0.entry.js → p-dad1b803.entry.js} +1 -1
  290. package/dist/twilight/{p-44215d1e.entry.js → p-dfd0bf16.entry.js} +1 -1
  291. package/dist/twilight/{p-df48debf.entry.js → p-e1b2f1cd.entry.js} +1 -1
  292. package/dist/twilight/{p-002505b9.entry.js → p-e89bfadd.entry.js} +1 -1
  293. package/dist/twilight/{p-6346f1bd.entry.js → p-eabd1eef.entry.js} +1 -1
  294. package/dist/twilight/{p-0a1a41e9.entry.js → p-eb2e5d15.entry.js} +1 -1
  295. package/dist/twilight/{p-0b3ca129.entry.js → p-effe5301.entry.js} +1 -1
  296. package/dist/twilight/{p-02af1d80.entry.js → p-f31595be.entry.js} +1 -1
  297. package/dist/twilight/{p-4cf98844.entry.js → p-f92040a1.entry.js} +1 -1
  298. package/dist/twilight/{p-02de8869.entry.js → p-fab8d485.entry.js} +1 -1
  299. package/dist/twilight/{p-fb6fea7a.entry.js → p-fbdf7bc2.entry.js} +1 -1
  300. package/dist/twilight/{p-752a8211.entry.js → p-fc49d9c6.entry.js} +1 -1
  301. package/dist/twilight/{p-6f3cce79.entry.js → p-fe8417b0.entry.js} +1 -1
  302. package/dist/twilight/twilight.esm.js +1 -1
  303. package/dist/types/components/salla-breadcrumb/salla-breadcrumb.d.ts +7 -1
  304. package/package.json +5 -5
  305. package/dist/twilight/p-727b2a97.entry.js +0 -4
@@ -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 as n}from"./p-BHYtfMwX.js";import{A as o,a as l}from"./p-Vqpj4CWE.js";const d=class{constructor(i){t(this,i),this.optionsSaved=s(this,"optionsSaved"),this.productSelected=s(this,"productSelected"),this.product=null,this.sectionId=null,this.sectionIndex=0,this.productIndex=0,this.selectedOptions={},this.optionsResetTokens={},this.isLoading=!1,this.hasUnsavedChanges=!1,this.validationErrors=[],this.isProductAlreadySelected=!1}generateCacheKey(t,s,i){return`${t||"unknown"}-${s||0}-${i||"unknown"}`}handleProductChange(t){setTimeout((()=>{this.modal&&t&&this.modal.setTitle(t.name||"")}),100),this.validationErrors=[],this.hasUnsavedChanges=!1}async open(){this.modal?(this.isLoading=!0,this.product?.name&&this.modal.setTitle(this.product.name),this.modal.open(),setTimeout((async()=>{this.product?.id&&await this.initializeSelectedOptions(),this.product?.name&&this.modal.setTitle(this.product.name),this.modal.stopLoading(),this.isLoading=!1}),300)):requestAnimationFrame((()=>this.open()))}async close(){this.modal&&this.modal.close()}async refreshOptionsState(){this.selectedOptions={...this.selectedOptions}}componentDidLoad(){this.modalOpenListener=t=>{this.product=t.product,this.sectionId=t.sectionId||null,this.sectionIndex=t.sectionIndex||0,this.productIndex=t.productIndex||0,this.isProductAlreadySelected=!!t.isProductAlreadySelected,this.open()},salla.event.on("multiple-bundle-product-modal::open",this.modalOpenListener),this.clearOptionsListener=t=>{t&&t.productId&&this.clearProductOptions(t.productId,t.sectionId,t.productIndex)},salla.event.on("multiple-bundle-product-modal::clear-options",this.clearOptionsListener),this.optionChangeListener=t=>{const s=t.detail||t,{option:i,detail:e}=s,n=i||s.option_id&&this.product?.options?.find((t=>t.id===s.option_id||String(t.id)===String(s.option_id))),o=e||(s.id?s:null);this.product?.id&&n&&this.handleOptionChange(Number(this.product.id),n,o)},salla.event.on("product-options::change",this.optionChangeListener),this.checkboxChangeListener=t=>{const s=t.target;if(s&&"checkbox"===s.type&&s.name&&s.name.includes("bundle[")&&s.name.includes("][id]")){const t=s.name.match(/^bundle\[([^\]]+)\]\[([^\]]+)\]\[id\]$/);if(t&&!s.checked){if("true"===s.getAttribute("data-selection-locked"))return void(s.checked=!0);const[,i,e]=t,n=s.value,o=this.host.closest("form");this.cleanupProductDeselection({sectionId:i,productIndex:parseInt(e,10),productId:n,form:o,uncheckedInput:s})}}},document.addEventListener("change",this.checkboxChangeListener)}disconnectedCallback(){this.checkboxChangeListener&&document.removeEventListener("change",this.checkboxChangeListener),this.optionChangeListener&&salla.event.off("product-options::change",this.optionChangeListener),this.modalOpenListener&&salla.event.off("multiple-bundle-product-modal::open",this.modalOpenListener),this.clearOptionsListener&&salla.event.off("multiple-bundle-product-modal::clear-options",this.clearOptionsListener)}cleanupProductDeselection(t){const{sectionId:s,productIndex:i,productId:e,form:n,uncheckedInput:o}=t;if(this.clearProductOptions(e,s,i),n){const t=`bundle[${s}][${i}]`;Array.from(n.querySelectorAll(`input[name^="${t}"]`)).forEach((s=>{if(s===o)return;const i="hidden"===s.type,n=s.getAttribute("data-product-id")===String(e)&&s.name?.startsWith(t);(i||n)&&s.remove()})),requestAnimationFrame((()=>{const t=new window.Event("change",{bubbles:!0});n.dispatchEvent(t)}))}}generateFormInputName(t,s,i){return`bundle[${t}][${s}][options][${i}]`}async initializeSelectedOptions(){if(!this.product?.id)return;const t=this.product.id,s=this.generateCacheKey(this.sectionId,this.productIndex,t),i=document.querySelector(`salla-product-options[product-id="${t}"]`);if(i)try{const t=await i.getSelectedOptions();t&&t.length>0&&(this.selectedOptions={...this.selectedOptions,[s]:t})}catch(t){console.warn("Could not initialize selected options:",t)}}clearProductOptions(t,s,i){const e={...this.selectedOptions};if(null==s||null==i||Number.isNaN(i)){const s=`-${String(t)}`,i=[];Object.keys(e).forEach((t=>{t.endsWith(s)&&(delete e[t],i.push(t))})),i.forEach((t=>this.bumpOptionsResetToken(t)))}else{const n=this.generateCacheKey(s,i,t);delete e[n],this.bumpOptionsResetToken(n)}this.selectedOptions=e,this.validationErrors=[],this.hasUnsavedChanges=!1}bumpOptionsResetToken(t){t&&(this.optionsResetTokens={...this.optionsResetTokens,[t]:(this.optionsResetTokens[t]||0)+1})}async handleOptionChange(t,s,i){const e=this.generateCacheKey(this.sectionId,this.productIndex,t),n=document.querySelector(`salla-product-options[product-id="${t}"]`);let o=[];if(n)try{o=await n.getSelectedOptions()||[]}catch(t){console.warn("Could not get current selections from component:",t)}if(o.length>0)this.selectedOptions={...this.selectedOptions,[e]:o};else if(this.selectedOptions[e]&&this.selectedOptions[e].length>0){const t=[...this.selectedOptions[e]||[]],n=t.findIndex((t=>t.option_id===s.id));n>-1?i&&null!=i.id?t[n]={...i,option_id:s.id}:t.splice(n,1):i&&null!=i.id&&t.push({...i,option_id:s.id}),this.selectedOptions={...this.selectedOptions,[e]:t}}else i&&null!=i.id&&(this.selectedOptions={...this.selectedOptions,[e]:[{...i,option_id:s.id}]});this.hasUnsavedChanges=!0,this.validationErrors=[]}async validateOptions(){if(!this.product?.options)return!0;const t=[],s=this.product.id,i=this.generateCacheKey(this.sectionId,this.productIndex,s),e=document.querySelector(`salla-product-options[product-id="${s}"]`);let n=[];if(e)try{n=await e.getSelectedOptions()||[];const t=this.selectedOptions[i]||[];(t.length>n.length||0===n.length&&t.length>0)&&(n=t)}catch(t){n=this.selectedOptions[i]||[]}else n=this.selectedOptions[i]||[];return 0===n.length&&t.push(salla.lang.get("pages.products.no_options_selected")),this.product.options.forEach((s=>{s.required&&(n.some((t=>t.option_id==s.id))||t.push(salla.lang.get("pages.products.required_option_missing",{option:s.name})))})),this.validationErrors=t,0===t.length}async onSave(t){t.preventDefault();const s=this.product?.id;if(!s)return;const i=this.generateCacheKey(this.sectionId,this.productIndex,s);if(await new Promise((t=>setTimeout(t,100))),await this.validateOptions()){if(!this.isProductAlreadySelected&&null!=this.sectionId){const t=this.host.closest("salla-multiple-bundle-product-details");if(!await(t?.canSelectBundleProduct(this.sectionId,s)))return void salla.notify.error(salla.lang.getWithDefault("pages.products.bundle_selection_limit_reached","لا يمكنك اختيار المزيد من المنتجات في هذا القسم"))}this.isLoading=!0;try{const t=document.querySelector(`salla-product-options[product-id="${s}"]`);let e=await(t?.getSelectedOptions());if((!e||0===e.length)&&this.selectedOptions[i]?.length>0&&(e=this.selectedOptions[i]),!e||0===e.length)return void(this.isLoading=!1);this.selectedOptions={...this.selectedOptions,[i]:e};const n=this.host.closest("form");if(!n)return void(this.isLoading=!1);const o=`bundle[${this.sectionId}][${this.productIndex}]`;Array.from(n.querySelectorAll(`input[name^="${o}"][type="hidden"]`)).forEach((t=>t.remove())),Array.from(n.querySelectorAll(`[data-product-id="${s}"][name^="${o}"]`)).forEach((t=>t.remove()));const l=`bundle[${this.sectionId}][${this.productIndex}][id]`,d=document.getElementById(l);if(d)d.checked=!0;else{const t=document.createElement("input");t.type="hidden",t.name=`bundle[${this.sectionId}][${this.productIndex}][id]`,t.value=String(s),t.dataset.productId=String(s),n.appendChild(t)}e.forEach((t=>{const i=t.option_id,e=document.createElement("input");e.type="hidden",e.name=this.generateFormInputName(this.sectionId,this.productIndex??0,i),e.value=String(t.id),e.dataset.productId=String(s),n.appendChild(e)}));const a=new window.Event("change",{bubbles:!0});n.dispatchEvent(a),this.optionsSaved.emit({productId:Number(s),selectedOptions:e,sectionId:this.sectionId,productIndex:this.productIndex}),this.sectionId&&this.productSelected.emit({productId:Number(s),sectionId:this.sectionId,product:this.product,fromModal:!0}),salla.notify.success(salla.lang.get("pages.products.options_saved")),this.hasUnsavedChanges=!1,this.validationErrors=[],this.modal.close()}catch(t){salla.notify.error(salla.lang.get("pages.products.options_save_error"))}finally{this.isLoading=!1}}else salla.notify.error(this.validationErrors.join(", "))}getOptionsWithSelectedState(){if(!this.product?.options)return[];const t=this.generateCacheKey(this.sectionId,this.productIndex,this.product.id),s=this.selectedOptions[t]||[];return this.product.options.map((t=>({...t,details:t.details.map((t=>{const i=s.some((s=>s.id===t.id));return{...t,is_selected:i}}))})))}render(){const t=this.product?.id,s=this.getOptionsWithSelectedState(),n=this.generateCacheKey(this.sectionId,this.productIndex,t),o=this.optionsResetTokens[n]||0,l=this.isLoading||s.some((t=>t.details.some((t=>t.is_selected&&!0===t.is_out))));return i(e,{key:"6c1d1d3911867e30240676f3e2b7353e9ecf76c3"},i("salla-modal",{key:"b02110d80cd422d64962d78812ae0b0637c56237",isLoading:this.isLoading,ref:t=>this.modal=t,width:"md",centered:!1,id:`s-multiple-bundle-product-options-modal-options-${t}`,class:"s-multiple-bundle-product-options-modal-wrapper"},i("div",{key:"20a52bbc732c6edfffde86577e99bbe300a1a4c8",slot:"loading"},i("salla-skeleton",{key:"3a69fc75939d8b8f8639983d0f2f8dd8bf961152",height:"100%",width:"100%"})),this.product?.images&&this.product?.images.length>0&&i("salla-slider",{key:"185639c54f79188093df98ac1cece1958879f71d",id:`details-slider-${this.product?.id}`,type:"thumbs",loop:!1,"auto-height":!0,"listen-to-thumbnails-option":!0,showThumbsControls:!1,controlsOuter:!1,showControls:!1,class:"s-multiple-bundle-product-options-modal-slider",verticalThumbs:!0,thumbsConfig:{centeredSlides:!0,centeredSlidesBounds:!0,slidesPerView:Math.min(5,Math.max(1,this.product?.images.length)),watchOverflow:!0,watchSlidesProgress:!0,direction:"vertical",spaceBetween:10}},i("div",{key:"3b6a88fe3862870d674dadc31967df6cc8fac365",slot:"items"},this.product?.images&&this.product?.images.map(((t,s)=>i("div",{key:s,class:"swiper-slide"},i("img",{src:t.url,alt:t.alt||`${this.product?.name} - Image ${s+1}`,loading:"lazy",onError:t=>{t.target.style.display="none"}}))))),this.product?.images&&this.product?.images.length>1&&i("div",{key:"6fce48b5b035cc61866aaf6c339866fa2314be87",slot:"thumbs"},this.product?.images&&this.product?.images.map(((t,s)=>i("div",{key:s,"data-caption":`${this.product?.name} - Image ${s+1}`},i("img",{src:t.url,loading:"eager",class:"s-multiple-bundle-product-options-modal-slider-thumb",title:`${this.product?.name} - ${s+1}`,alt:t.alt||`${this.product?.name} - ${s+1}`,onError:t=>{t.target.style.display="none"}})))))),i("salla-product-options",{options:JSON.stringify(s),key:`${n}-reset-${o}`,"product-id":t,"unique-key":`${n}-reset-${o}`}),i("div",{key:"3d555ea40fe5d9f3685fc6dafa4b6fad16732091",slot:"footer"},i("div",{key:"1b4c6834899efbd09f3ea1db251999f50ec655b2",class:"s-multiple-bundle-product-options-modal-footer"},i("salla-button",{key:"0818a75a444cca510c7f0cfea2ec53414c12db53",onClick:t=>this.onSave(t),loading:this.isLoading,disabled:l},this.isLoading?salla.lang.get("common.elements.saving"):salla.lang.get("common.elements.save"))))))}get host(){return n(this)}static get watchers(){return{product:["handleProductChange"]}}};d.style=":host{display:block}";const a=class{constructor(i){t(this,i),this.productSelected=s(this,"productSelected"),this.productOptionsSelected=s(this,"productOptionsSelected"),this.selectedProducts={},this.isSelectionLocked=!1,this.selectionLimit=0,this.savedOptionsByInstance={},this.handleProductClick=(t,s)=>{const i=this.selectedProducts[this.section.id]?.has(t.id)||!1,e=this.getCheckbox(this.section.id,s);if(i&&this.isSelectionLocked)return void(e&&(e.checked=!0));if(!i&&this.isMaxSelectionReached()&&1!==this.selectionLimit)return;if(1===this.selectionLimit&&!i)return void this.productSelected.emit({product:t,sectionId:this.section.id});if(!e)return;const n=!e.checked;n||(this.dispatchClearOptionsEvent(t,s),this.clearSavedOptionsState(this.section.id,s)),e.checked=n,requestAnimationFrame((()=>{const t=new window.Event("change",{bubbles:!0});e.dispatchEvent(t)})),this.productSelected.emit({product:t,sectionId:this.section.id})},this.handleOptionsClick=t=>{!this.selectedProducts[this.section.id]?.has(t.id)&&this.isMaxSelectionReached()&&1!==this.selectionLimit||this.productOptionsSelected.emit({product:t,sectionId:this.section.id})}}getSelectedCount(){return this.selectedProducts[this.section?.id]?.size??0}isMaxSelectionReached(){return this.selectionLimit>1&&this.getSelectedCount()>=this.selectionLimit}isProductSelectionDisabled(t,s){return 0===t.quantity||!s&&this.isMaxSelectionReached()}getProductInstanceKey(t,s){return`${t}::${s}`}dispatchClearOptionsEvent(t,s){salla.event.dispatch("multiple-bundle-product-modal::clear-options",{productId:t.id,sectionId:this.section.id,sectionIndex:this.sectionIndex,productIndex:s})}handleOptionsSaved(t){const s=t.detail;if(!s)return;const{sectionId:i,productIndex:e,selectedOptions:n}=s;if(null==i||i!==this.section?.id)return;if(null==e||Number.isNaN(e))return;const o=this.getProductInstanceKey(i,e);if(n?.length)this.savedOptionsByInstance={...this.savedOptionsByInstance,[o]:!0};else if(this.savedOptionsByInstance[o]){const t={...this.savedOptionsByInstance};delete t[o],this.savedOptionsByInstance=t}}clearSavedOptionsState(t,s){const i=this.getProductInstanceKey(t,s);if(!this.savedOptionsByInstance[i])return;const e={...this.savedOptionsByInstance};delete e[i],this.savedOptionsByInstance=e}generateEventName(t,s){return`bundle[${t}][${s}][id]`}getCheckbox(t,s){const i=this.generateEventName(t,s);return this.host.querySelector(`input.s-multiple-bundle-product-checkbox[name="${i}"]`)}preventLockedDeselect(t,s){if(!this.isSelectionLocked||!s)return;t.preventDefault(),t.stopPropagation();const i=t.target;"checkbox"===i?.type&&(i.checked=!0)}render(){return i(e,{key:"d52eb26454606df2526fa4c086110a54f7466644"},i("salla-slider",{key:"1aa1fce5943c3721a8e4f762171c864d9097bb28",type:"carousel",controlsOuter:!1,showControls:!1,id:`accordion-multiple-bundle-product-${this.section.id}`,pagination:!0,class:"s-multiple-bundle-product-wrapper-slider",sliderConfig:{spaceBetween:0}},i("div",{key:"9342381bc43389bae48b906a1ab23a4f3cf8d00a",slot:"items"},this?.section?.products?.map(((t,s)=>{const e=this.selectedProducts[this.section.id]?.has(t.id)||!1,n=e&&this.isSelectionLocked,d=this.isProductSelectionDisabled(t,e),a=this.savedOptionsByInstance[this.getProductInstanceKey(this.section.id,s)]?salla.lang.getWithDefault("pages.products.edit_selected_options","تعديل الخيارات"):salla.lang.get("pages.products.choose_from_options");let c=salla.config.get("theme.is_rtl",!0)?o:l;return i("div",{class:"s-multiple-bundle-product-slide-one-third"+(d?" s-multiple-bundle-product-slide-one-third-disabled":""),key:t.id},i("div",{class:"s-multiple-bundle-product-card"},i("div",{class:"s-multiple-bundle-product-image-wrapper",onClick:()=>this.handleProductClick(t,s)},i("input",{id:this.generateEventName(this.section.id,s),type:"checkbox",class:"s-multiple-bundle-product-checkbox",checked:e,"data-selection-locked":n?"true":void 0,name:this.generateEventName(this.section.id,s),value:t.id,onClick:t=>this.preventLockedDeselect(t,e),onChange:t=>this.preventLockedDeselect(t,e)}),i("img",{src:t.image.url||salla.url.cdn("images/s-empty.png"),loading:"lazy",alt:t.image.alt||t.name,class:"s-multiple-bundle-product-image"})),i("div",{class:"s-multiple-bundle-product-content-wrapper"},i("div",{class:"s-multiple-bundle-product-content"},i("div",{class:"s-multiple-bundle-product-details"},i("div",{class:"s-multiple-bundle-product-title-wrapper"},i("h2",{class:"s-multiple-bundle-product-title"},i("a",{href:t?.url||"#",target:"_blank",rel:"noopener noreferrer"},t.name))),i("div",{class:"s-multiple-bundle-product-price-wrapper"},i("span",{class:"s-multiple-bundle-product-price"},i("span",{innerHTML:salla.money(t.price)})),t.sale_price>0&&i("span",{class:"s-multiple-bundle-product-price-discount"},i("span",{innerHTML:salla.money(t.regular_price)})))),t.quantity_in_group>0&&0!==t.quantity&&i("span",{class:"s-multiple-bundle-product-badge"},salla.lang.get("pages.products.pieces"),i("span",null,t.quantity_in_group)),0===t.quantity&&i("span",{class:"s-multiple-bundle-product-badge"},salla.lang.get("pages.products.quantity_in_group_finished"))),t.options?.length>0&&i("button",{class:"s-multiple-bundle-product-button",onClick:()=>this.handleOptionsClick(t),type:"button"},a,i("span",{class:"s-multiple-bundle-product-button-icon",innerHTML:c})))))})))))}get host(){return n(this)}};a.style="";export{d as salla_multiple_bundle_product_options_modal,a as salla_multiple_bundle_product_slider}
4
+ import{r as t,c as s,h as i,H as e,a as n}from"./p-CFtXUFT2.js";import{A as o,a as l}from"./p-Vqpj4CWE.js";const d=class{constructor(i){t(this,i),this.optionsSaved=s(this,"optionsSaved"),this.productSelected=s(this,"productSelected"),this.product=null,this.sectionId=null,this.sectionIndex=0,this.productIndex=0,this.selectedOptions={},this.optionsResetTokens={},this.isLoading=!1,this.hasUnsavedChanges=!1,this.validationErrors=[],this.isProductAlreadySelected=!1}generateCacheKey(t,s,i){return`${t||"unknown"}-${s||0}-${i||"unknown"}`}handleProductChange(t){setTimeout((()=>{this.modal&&t&&this.modal.setTitle(t.name||"")}),100),this.validationErrors=[],this.hasUnsavedChanges=!1}async open(){this.modal?(this.isLoading=!0,this.product?.name&&this.modal.setTitle(this.product.name),this.modal.open(),setTimeout((async()=>{this.product?.id&&await this.initializeSelectedOptions(),this.product?.name&&this.modal.setTitle(this.product.name),this.modal.stopLoading(),this.isLoading=!1}),300)):requestAnimationFrame((()=>this.open()))}async close(){this.modal&&this.modal.close()}async refreshOptionsState(){this.selectedOptions={...this.selectedOptions}}componentDidLoad(){this.modalOpenListener=t=>{this.product=t.product,this.sectionId=t.sectionId||null,this.sectionIndex=t.sectionIndex||0,this.productIndex=t.productIndex||0,this.isProductAlreadySelected=!!t.isProductAlreadySelected,this.open()},salla.event.on("multiple-bundle-product-modal::open",this.modalOpenListener),this.clearOptionsListener=t=>{t&&t.productId&&this.clearProductOptions(t.productId,t.sectionId,t.productIndex)},salla.event.on("multiple-bundle-product-modal::clear-options",this.clearOptionsListener),this.optionChangeListener=t=>{const s=t.detail||t,{option:i,detail:e}=s,n=i||s.option_id&&this.product?.options?.find((t=>t.id===s.option_id||String(t.id)===String(s.option_id))),o=e||(s.id?s:null);this.product?.id&&n&&this.handleOptionChange(Number(this.product.id),n,o)},salla.event.on("product-options::change",this.optionChangeListener),this.checkboxChangeListener=t=>{const s=t.target;if(s&&"checkbox"===s.type&&s.name&&s.name.includes("bundle[")&&s.name.includes("][id]")){const t=s.name.match(/^bundle\[([^\]]+)\]\[([^\]]+)\]\[id\]$/);if(t&&!s.checked){if("true"===s.getAttribute("data-selection-locked"))return void(s.checked=!0);const[,i,e]=t,n=s.value,o=this.host.closest("form");this.cleanupProductDeselection({sectionId:i,productIndex:parseInt(e,10),productId:n,form:o,uncheckedInput:s})}}},document.addEventListener("change",this.checkboxChangeListener)}disconnectedCallback(){this.checkboxChangeListener&&document.removeEventListener("change",this.checkboxChangeListener),this.optionChangeListener&&salla.event.off("product-options::change",this.optionChangeListener),this.modalOpenListener&&salla.event.off("multiple-bundle-product-modal::open",this.modalOpenListener),this.clearOptionsListener&&salla.event.off("multiple-bundle-product-modal::clear-options",this.clearOptionsListener)}cleanupProductDeselection(t){const{sectionId:s,productIndex:i,productId:e,form:n,uncheckedInput:o}=t;if(this.clearProductOptions(e,s,i),n){const t=`bundle[${s}][${i}]`;Array.from(n.querySelectorAll(`input[name^="${t}"]`)).forEach((s=>{if(s===o)return;const i="hidden"===s.type,n=s.getAttribute("data-product-id")===String(e)&&s.name?.startsWith(t);(i||n)&&s.remove()})),requestAnimationFrame((()=>{const t=new window.Event("change",{bubbles:!0});n.dispatchEvent(t)}))}}generateFormInputName(t,s,i){return`bundle[${t}][${s}][options][${i}]`}async initializeSelectedOptions(){if(!this.product?.id)return;const t=this.product.id,s=this.generateCacheKey(this.sectionId,this.productIndex,t),i=document.querySelector(`salla-product-options[product-id="${t}"]`);if(i)try{const t=await i.getSelectedOptions();t&&t.length>0&&(this.selectedOptions={...this.selectedOptions,[s]:t})}catch(t){console.warn("Could not initialize selected options:",t)}}clearProductOptions(t,s,i){const e={...this.selectedOptions};if(null==s||null==i||Number.isNaN(i)){const s=`-${String(t)}`,i=[];Object.keys(e).forEach((t=>{t.endsWith(s)&&(delete e[t],i.push(t))})),i.forEach((t=>this.bumpOptionsResetToken(t)))}else{const n=this.generateCacheKey(s,i,t);delete e[n],this.bumpOptionsResetToken(n)}this.selectedOptions=e,this.validationErrors=[],this.hasUnsavedChanges=!1}bumpOptionsResetToken(t){t&&(this.optionsResetTokens={...this.optionsResetTokens,[t]:(this.optionsResetTokens[t]||0)+1})}async handleOptionChange(t,s,i){const e=this.generateCacheKey(this.sectionId,this.productIndex,t),n=document.querySelector(`salla-product-options[product-id="${t}"]`);let o=[];if(n)try{o=await n.getSelectedOptions()||[]}catch(t){console.warn("Could not get current selections from component:",t)}if(o.length>0)this.selectedOptions={...this.selectedOptions,[e]:o};else if(this.selectedOptions[e]&&this.selectedOptions[e].length>0){const t=[...this.selectedOptions[e]||[]],n=t.findIndex((t=>t.option_id===s.id));n>-1?i&&null!=i.id?t[n]={...i,option_id:s.id}:t.splice(n,1):i&&null!=i.id&&t.push({...i,option_id:s.id}),this.selectedOptions={...this.selectedOptions,[e]:t}}else i&&null!=i.id&&(this.selectedOptions={...this.selectedOptions,[e]:[{...i,option_id:s.id}]});this.hasUnsavedChanges=!0,this.validationErrors=[]}async validateOptions(){if(!this.product?.options)return!0;const t=[],s=this.product.id,i=this.generateCacheKey(this.sectionId,this.productIndex,s),e=document.querySelector(`salla-product-options[product-id="${s}"]`);let n=[];if(e)try{n=await e.getSelectedOptions()||[];const t=this.selectedOptions[i]||[];(t.length>n.length||0===n.length&&t.length>0)&&(n=t)}catch(t){n=this.selectedOptions[i]||[]}else n=this.selectedOptions[i]||[];return 0===n.length&&t.push(salla.lang.get("pages.products.no_options_selected")),this.product.options.forEach((s=>{s.required&&(n.some((t=>t.option_id==s.id))||t.push(salla.lang.get("pages.products.required_option_missing",{option:s.name})))})),this.validationErrors=t,0===t.length}async onSave(t){t.preventDefault();const s=this.product?.id;if(!s)return;const i=this.generateCacheKey(this.sectionId,this.productIndex,s);if(await new Promise((t=>setTimeout(t,100))),await this.validateOptions()){if(!this.isProductAlreadySelected&&null!=this.sectionId){const t=this.host.closest("salla-multiple-bundle-product-details");if(!await(t?.canSelectBundleProduct(this.sectionId,s)))return void salla.notify.error(salla.lang.getWithDefault("pages.products.bundle_selection_limit_reached","لا يمكنك اختيار المزيد من المنتجات في هذا القسم"))}this.isLoading=!0;try{const t=document.querySelector(`salla-product-options[product-id="${s}"]`);let e=await(t?.getSelectedOptions());if((!e||0===e.length)&&this.selectedOptions[i]?.length>0&&(e=this.selectedOptions[i]),!e||0===e.length)return void(this.isLoading=!1);this.selectedOptions={...this.selectedOptions,[i]:e};const n=this.host.closest("form");if(!n)return void(this.isLoading=!1);const o=`bundle[${this.sectionId}][${this.productIndex}]`;Array.from(n.querySelectorAll(`input[name^="${o}"][type="hidden"]`)).forEach((t=>t.remove())),Array.from(n.querySelectorAll(`[data-product-id="${s}"][name^="${o}"]`)).forEach((t=>t.remove()));const l=`bundle[${this.sectionId}][${this.productIndex}][id]`,d=document.getElementById(l);if(d)d.checked=!0;else{const t=document.createElement("input");t.type="hidden",t.name=`bundle[${this.sectionId}][${this.productIndex}][id]`,t.value=String(s),t.dataset.productId=String(s),n.appendChild(t)}e.forEach((t=>{const i=t.option_id,e=document.createElement("input");e.type="hidden",e.name=this.generateFormInputName(this.sectionId,this.productIndex??0,i),e.value=String(t.id),e.dataset.productId=String(s),n.appendChild(e)}));const a=new window.Event("change",{bubbles:!0});n.dispatchEvent(a),this.optionsSaved.emit({productId:Number(s),selectedOptions:e,sectionId:this.sectionId,productIndex:this.productIndex}),this.sectionId&&this.productSelected.emit({productId:Number(s),sectionId:this.sectionId,product:this.product,fromModal:!0}),salla.notify.success(salla.lang.get("pages.products.options_saved")),this.hasUnsavedChanges=!1,this.validationErrors=[],this.modal.close()}catch(t){salla.notify.error(salla.lang.get("pages.products.options_save_error"))}finally{this.isLoading=!1}}else salla.notify.error(this.validationErrors.join(", "))}getOptionsWithSelectedState(){if(!this.product?.options)return[];const t=this.generateCacheKey(this.sectionId,this.productIndex,this.product.id),s=this.selectedOptions[t]||[];return this.product.options.map((t=>({...t,details:t.details.map((t=>{const i=s.some((s=>s.id===t.id));return{...t,is_selected:i}}))})))}render(){const t=this.product?.id,s=this.getOptionsWithSelectedState(),n=this.generateCacheKey(this.sectionId,this.productIndex,t),o=this.optionsResetTokens[n]||0,l=this.isLoading||s.some((t=>t.details.some((t=>t.is_selected&&!0===t.is_out))));return i(e,{key:"6c1d1d3911867e30240676f3e2b7353e9ecf76c3"},i("salla-modal",{key:"b02110d80cd422d64962d78812ae0b0637c56237",isLoading:this.isLoading,ref:t=>this.modal=t,width:"md",centered:!1,id:`s-multiple-bundle-product-options-modal-options-${t}`,class:"s-multiple-bundle-product-options-modal-wrapper"},i("div",{key:"20a52bbc732c6edfffde86577e99bbe300a1a4c8",slot:"loading"},i("salla-skeleton",{key:"3a69fc75939d8b8f8639983d0f2f8dd8bf961152",height:"100%",width:"100%"})),this.product?.images&&this.product?.images.length>0&&i("salla-slider",{key:"185639c54f79188093df98ac1cece1958879f71d",id:`details-slider-${this.product?.id}`,type:"thumbs",loop:!1,"auto-height":!0,"listen-to-thumbnails-option":!0,showThumbsControls:!1,controlsOuter:!1,showControls:!1,class:"s-multiple-bundle-product-options-modal-slider",verticalThumbs:!0,thumbsConfig:{centeredSlides:!0,centeredSlidesBounds:!0,slidesPerView:Math.min(5,Math.max(1,this.product?.images.length)),watchOverflow:!0,watchSlidesProgress:!0,direction:"vertical",spaceBetween:10}},i("div",{key:"3b6a88fe3862870d674dadc31967df6cc8fac365",slot:"items"},this.product?.images&&this.product?.images.map(((t,s)=>i("div",{key:s,class:"swiper-slide"},i("img",{src:t.url,alt:t.alt||`${this.product?.name} - Image ${s+1}`,loading:"lazy",onError:t=>{t.target.style.display="none"}}))))),this.product?.images&&this.product?.images.length>1&&i("div",{key:"6fce48b5b035cc61866aaf6c339866fa2314be87",slot:"thumbs"},this.product?.images&&this.product?.images.map(((t,s)=>i("div",{key:s,"data-caption":`${this.product?.name} - Image ${s+1}`},i("img",{src:t.url,loading:"eager",class:"s-multiple-bundle-product-options-modal-slider-thumb",title:`${this.product?.name} - ${s+1}`,alt:t.alt||`${this.product?.name} - ${s+1}`,onError:t=>{t.target.style.display="none"}})))))),i("salla-product-options",{options:JSON.stringify(s),key:`${n}-reset-${o}`,"product-id":t,"unique-key":`${n}-reset-${o}`}),i("div",{key:"3d555ea40fe5d9f3685fc6dafa4b6fad16732091",slot:"footer"},i("div",{key:"1b4c6834899efbd09f3ea1db251999f50ec655b2",class:"s-multiple-bundle-product-options-modal-footer"},i("salla-button",{key:"0818a75a444cca510c7f0cfea2ec53414c12db53",onClick:t=>this.onSave(t),loading:this.isLoading,disabled:l},this.isLoading?salla.lang.get("common.elements.saving"):salla.lang.get("common.elements.save"))))))}get host(){return n(this)}static get watchers(){return{product:["handleProductChange"]}}};d.style=":host{display:block}";const a=class{constructor(i){t(this,i),this.productSelected=s(this,"productSelected"),this.productOptionsSelected=s(this,"productOptionsSelected"),this.selectedProducts={},this.isSelectionLocked=!1,this.selectionLimit=0,this.savedOptionsByInstance={},this.handleProductClick=(t,s)=>{const i=this.selectedProducts[this.section.id]?.has(t.id)||!1,e=this.getCheckbox(this.section.id,s);if(i&&this.isSelectionLocked)return void(e&&(e.checked=!0));if(!i&&this.isMaxSelectionReached()&&1!==this.selectionLimit)return;if(1===this.selectionLimit&&!i)return void this.productSelected.emit({product:t,sectionId:this.section.id});if(!e)return;const n=!e.checked;n||(this.dispatchClearOptionsEvent(t,s),this.clearSavedOptionsState(this.section.id,s)),e.checked=n,requestAnimationFrame((()=>{const t=new window.Event("change",{bubbles:!0});e.dispatchEvent(t)})),this.productSelected.emit({product:t,sectionId:this.section.id})},this.handleOptionsClick=t=>{!this.selectedProducts[this.section.id]?.has(t.id)&&this.isMaxSelectionReached()&&1!==this.selectionLimit||this.productOptionsSelected.emit({product:t,sectionId:this.section.id})}}getSelectedCount(){return this.selectedProducts[this.section?.id]?.size??0}isMaxSelectionReached(){return this.selectionLimit>1&&this.getSelectedCount()>=this.selectionLimit}isProductSelectionDisabled(t,s){return 0===t.quantity||!s&&this.isMaxSelectionReached()}getProductInstanceKey(t,s){return`${t}::${s}`}dispatchClearOptionsEvent(t,s){salla.event.dispatch("multiple-bundle-product-modal::clear-options",{productId:t.id,sectionId:this.section.id,sectionIndex:this.sectionIndex,productIndex:s})}handleOptionsSaved(t){const s=t.detail;if(!s)return;const{sectionId:i,productIndex:e,selectedOptions:n}=s;if(null==i||i!==this.section?.id)return;if(null==e||Number.isNaN(e))return;const o=this.getProductInstanceKey(i,e);if(n?.length)this.savedOptionsByInstance={...this.savedOptionsByInstance,[o]:!0};else if(this.savedOptionsByInstance[o]){const t={...this.savedOptionsByInstance};delete t[o],this.savedOptionsByInstance=t}}clearSavedOptionsState(t,s){const i=this.getProductInstanceKey(t,s);if(!this.savedOptionsByInstance[i])return;const e={...this.savedOptionsByInstance};delete e[i],this.savedOptionsByInstance=e}generateEventName(t,s){return`bundle[${t}][${s}][id]`}getCheckbox(t,s){const i=this.generateEventName(t,s);return this.host.querySelector(`input.s-multiple-bundle-product-checkbox[name="${i}"]`)}preventLockedDeselect(t,s){if(!this.isSelectionLocked||!s)return;t.preventDefault(),t.stopPropagation();const i=t.target;"checkbox"===i?.type&&(i.checked=!0)}render(){return i(e,{key:"d52eb26454606df2526fa4c086110a54f7466644"},i("salla-slider",{key:"1aa1fce5943c3721a8e4f762171c864d9097bb28",type:"carousel",controlsOuter:!1,showControls:!1,id:`accordion-multiple-bundle-product-${this.section.id}`,pagination:!0,class:"s-multiple-bundle-product-wrapper-slider",sliderConfig:{spaceBetween:0}},i("div",{key:"9342381bc43389bae48b906a1ab23a4f3cf8d00a",slot:"items"},this?.section?.products?.map(((t,s)=>{const e=this.selectedProducts[this.section.id]?.has(t.id)||!1,n=e&&this.isSelectionLocked,d=this.isProductSelectionDisabled(t,e),a=this.savedOptionsByInstance[this.getProductInstanceKey(this.section.id,s)]?salla.lang.getWithDefault("pages.products.edit_selected_options","تعديل الخيارات"):salla.lang.get("pages.products.choose_from_options");let c=salla.config.get("theme.is_rtl",!0)?o:l;return i("div",{class:"s-multiple-bundle-product-slide-one-third"+(d?" s-multiple-bundle-product-slide-one-third-disabled":""),key:t.id},i("div",{class:"s-multiple-bundle-product-card"},i("div",{class:"s-multiple-bundle-product-image-wrapper",onClick:()=>this.handleProductClick(t,s)},i("input",{id:this.generateEventName(this.section.id,s),type:"checkbox",class:"s-multiple-bundle-product-checkbox",checked:e,"data-selection-locked":n?"true":void 0,name:this.generateEventName(this.section.id,s),value:t.id,onClick:t=>this.preventLockedDeselect(t,e),onChange:t=>this.preventLockedDeselect(t,e)}),i("img",{src:t.image.url||salla.url.cdn("images/s-empty.png"),loading:"lazy",alt:t.image.alt||t.name,class:"s-multiple-bundle-product-image"})),i("div",{class:"s-multiple-bundle-product-content-wrapper"},i("div",{class:"s-multiple-bundle-product-content"},i("div",{class:"s-multiple-bundle-product-details"},i("div",{class:"s-multiple-bundle-product-title-wrapper"},i("h2",{class:"s-multiple-bundle-product-title"},i("a",{href:t?.url||"#",target:"_blank",rel:"noopener noreferrer"},t.name))),i("div",{class:"s-multiple-bundle-product-price-wrapper"},i("span",{class:"s-multiple-bundle-product-price"},i("span",{innerHTML:salla.money(t.price)})),t.sale_price>0&&i("span",{class:"s-multiple-bundle-product-price-discount"},i("span",{innerHTML:salla.money(t.regular_price)})))),t.quantity_in_group>0&&0!==t.quantity&&i("span",{class:"s-multiple-bundle-product-badge"},salla.lang.get("pages.products.pieces"),i("span",null,t.quantity_in_group)),0===t.quantity&&i("span",{class:"s-multiple-bundle-product-badge"},salla.lang.get("pages.products.quantity_in_group_finished"))),t.options?.length>0&&i("button",{class:"s-multiple-bundle-product-button",onClick:()=>this.handleOptionsClick(t),type:"button"},a,i("span",{class:"s-multiple-bundle-product-button-icon",innerHTML:c})))))})))))}get host(){return n(this)}};a.style="";export{d as salla_multiple_bundle_product_options_modal,a as salla_multiple_bundle_product_slider}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{h as a,r as s}from"./p-BHYtfMwX.js";import{s as l}from"./p-B-Rj6b9M.js";import{n as o,a as t,c as r}from"./p-Dvaa0hYf.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-D8Vw7Lrc.js";import{a as d}from"./p-CgtvEd63.js";var h=function(a,s,l,o){var t,r=arguments.length,e=r<3?s:null===o?o=Object.getOwnPropertyDescriptor(s,l):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)e=Reflect.decorate(a,s,l,o);else for(var i=a.length-1;i>=0;i--)(t=a[i])&&(e=(r<3?t(e):r>3?t(s,l,e):t(s,l))||e);return r>3&&e&&Object.defineProperty(s,l,e),e};const u={all:a("span",{class:"s-loyalty-program-rewards-tab-icon",innerHTML:i}),free_shipping:a("span",{class:"s-loyalty-program-rewards-tab-icon",innerHTML:p}),coupon_discount:a("span",{class:"s-loyalty-program-rewards-tab-icon",innerHTML:e}),free_product:a("span",{class:"s-loyalty-program-rewards-tab-icon",innerHTML:n})},f=class{constructor(a){s(this,a),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((a=>salla.logger.error(a)))}disconnectedCallback(){salla.event.off("loyalty::exchange.succeeded",this.handleExchangeSucceeded)}getOutlineItem(s,l,o){const t={1:a("span",{innerHTML:c}),2:a("span",{innerHTML:y}),3:a("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 a("li",{class:"s-loyalty-program-item"},a("div",{class:"s-loyalty-program-content"},a("span",{class:"s-loyalty-program-icon-container"},a("span",{class:"s-loyalty-program-text-gradient"},s),a("span",{class:"s-loyalty-program-icon"},t[s])),a("div",{class:"s-loyalty-program-title"},l),a("div",{class:"s-loyalty-program-description"},o)))}render(){if("error"===this.program.status)return a("p",null,salla.lang.get("common.errors.error_occured"));const s=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 a("div",{class:"s-loyalty-program-container"},a("salla-loyalty-hero",{name:this.program.data.name,description:this.program.data.description,image:this.program.data.image},salla.config.isUser()?a("div",{slot:"crosspoint",class:"s-loyalty-program-profile-wrapper"},a("div",{class:"s-loyalty-program-profile-container"},a("div",{class:"s-loyalty-program-profile-points-section"},a("h2",{class:"s-loyalty-program-profile-label"},salla.lang.get("pages.loyalty_program.your_points")),a("p",{class:"s-loyalty-program-profile-points"},a("span",{class:"s-loyalty-program-profile-points-value"},this.animatedPoints?this.animatedPoints:this.points.data)," ",salla.lang.get("pages.loyalty_program.point"))),a("div",{class:"s-loyalty-program-profile-icon"},a("span",{innerHTML:m})))):a("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"))),a("div",{class:"s-loyalty-program-outline-section"},a("section",{class:"s-loyalty-program-section"},a("header",{class:"s-loyalty-program-header"},a("h1",{class:"s-loyalty-program-main-title"},salla.lang.get("pages.loyalty_program.how_to_start")),a("p",{class:"s-loyalty-program-subtitle"},salla.lang.get("pages.loyalty_program.three_simple_steps"))),a("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"))))),a("div",{class:"s-loyalty-program-points-wrapper"},a("section",{class:"s-loyalty-program-points-section"},a("header",{class:"s-loyalty-program-points-header"},a("h1",{class:"s-loyalty-program-points-title"},this.program.data.promotion_title),a("p",{class:"s-loyalty-program-points-description"},this.program.data.promotion_description)),a("div",{class:"s-loyalty-program-points-spacer"}),a("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}},s.map((s=>a("li",null,a("salla-loyalty-point",{point:s}))))),a("div",{class:"s-loyalty-program-points-spacer"}),t(this.program.data.points.length)!==this.program.data.points.length&&a("button",{class:"s-loyalty-program-points-more-button",onClick:()=>this.collapsed=!this.collapsed},this.collapsed?a("span",null,salla.lang.get("pages.loyalty_program.show_more"),"  ",a("span",{style:{fontSize:"1.2rem",fontWeight:"300"}},"+")):a("span",null,salla.lang.get("pages.loyalty_program.show_less"),"  ",a("span",{style:{fontSize:"1.2rem",fontWeight:"300"}},"-"))))),"success"!==this.program.status?"":a("div",{class:"s-loyalty-program-rewards-container s-loyalty-program-slider-arrows-edges"},a("section",{class:{"s-loyalty-program-tabs-hider":l.length<=2||o<=4}},a("h1",{class:"s-loyalty-program-rewards-heading-mobile"},salla.lang.get("pages.loyalty_program.rewards")),a("salla-tabs",null,a("div",{slot:"header",class:"s-loyalty-program-rewards-tab-items"},l.map((s=>a("salla-tab-header",{slot:"header",name:s.type},u[s.type],a("span",null,s.title))))),a("h1",{slot:"header",class:"s-loyalty-program-rewards-heading-desktop"},salla.lang.get("pages.loyalty_program.rewards")),l.map((s=>a("salla-tab-content",{slot:"content",name:s.type},a("salla-slider",{id:s.type,type:"default","slider-config":'{"loop":false,"slidesPerView":"auto","freeMode":true,"spaceBetween":12,"breakpoints":{"768":{"slidesPerView":4,"spaceBetween":24,"freeMode":false,"speed":300}}}'},a("div",{slot:"items"},s.items.map((s=>a("salla-reward-card",{prize:s,onAreaClick:()=>{this.currentPrize=s,r((()=>this.detailsModal.open()))},onActionClick:()=>{this.currentPrize=s,r((()=>this.detailsModal.open()))}}))))))))),a("salla-modal",{ref:a=>this.detailsModal=a,class:"s-loyalty-program-modal",width:"md",noPadding:!0},this.currentPrize?a("salla-reward-details",{onActionClick:()=>r((()=>this.exchangeModal.open())),prize:this.currentPrize}):""),a("salla-modal",{ref:a=>this.exchangeModal=a,class:"s-loyalty-program-modal",width:"sm"},this.currentPrize?a("salla-reward-exchange",{prize:this.currentPrize}):""))))}};h([g((async function(){const{data:a}=await salla.loyalty.getProgram();return o(a)}),{initialData:{points:[],prizes:[],prizes_count:0}})],f.prototype,"program",void 0),h([g((async function(){const{data:a}=await salla.loyalty.getPoints();return d({targets:{value:0},value:a.points??0,round:1,easing:"easeOutQuad",duration:2e3,update:a=>{this.animatedPoints=a.animations[0].currentValue}}),a.points}))],f.prototype,"points",void 0),f.style="";export{f as salla_loyalty_program}
4
+ import{h as a,r as s}from"./p-CFtXUFT2.js";import{s as l}from"./p-B-Rj6b9M.js";import{n as o,a as t,c as r}from"./p-Dw1i2i3R.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-DRqWSUhZ.js";import{a as d}from"./p-CgtvEd63.js";var h=function(a,s,l,o){var t,r=arguments.length,e=r<3?s:null===o?o=Object.getOwnPropertyDescriptor(s,l):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)e=Reflect.decorate(a,s,l,o);else for(var i=a.length-1;i>=0;i--)(t=a[i])&&(e=(r<3?t(e):r>3?t(s,l,e):t(s,l))||e);return r>3&&e&&Object.defineProperty(s,l,e),e};const u={all:a("span",{class:"s-loyalty-program-rewards-tab-icon",innerHTML:i}),free_shipping:a("span",{class:"s-loyalty-program-rewards-tab-icon",innerHTML:p}),coupon_discount:a("span",{class:"s-loyalty-program-rewards-tab-icon",innerHTML:e}),free_product:a("span",{class:"s-loyalty-program-rewards-tab-icon",innerHTML:n})},f=class{constructor(a){s(this,a),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((a=>salla.logger.error(a)))}disconnectedCallback(){salla.event.off("loyalty::exchange.succeeded",this.handleExchangeSucceeded)}getOutlineItem(s,l,o){const t={1:a("span",{innerHTML:c}),2:a("span",{innerHTML:y}),3:a("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 a("li",{class:"s-loyalty-program-item"},a("div",{class:"s-loyalty-program-content"},a("span",{class:"s-loyalty-program-icon-container"},a("span",{class:"s-loyalty-program-text-gradient"},s),a("span",{class:"s-loyalty-program-icon"},t[s])),a("div",{class:"s-loyalty-program-title"},l),a("div",{class:"s-loyalty-program-description"},o)))}render(){if("error"===this.program.status)return a("p",null,salla.lang.get("common.errors.error_occured"));const s=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 a("div",{class:"s-loyalty-program-container"},a("salla-loyalty-hero",{name:this.program.data.name,description:this.program.data.description,image:this.program.data.image},salla.config.isUser()?a("div",{slot:"crosspoint",class:"s-loyalty-program-profile-wrapper"},a("div",{class:"s-loyalty-program-profile-container"},a("div",{class:"s-loyalty-program-profile-points-section"},a("h2",{class:"s-loyalty-program-profile-label"},salla.lang.get("pages.loyalty_program.your_points")),a("p",{class:"s-loyalty-program-profile-points"},a("span",{class:"s-loyalty-program-profile-points-value"},this.animatedPoints?this.animatedPoints:this.points.data)," ",salla.lang.get("pages.loyalty_program.point"))),a("div",{class:"s-loyalty-program-profile-icon"},a("span",{innerHTML:m})))):a("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"))),a("div",{class:"s-loyalty-program-outline-section"},a("section",{class:"s-loyalty-program-section"},a("header",{class:"s-loyalty-program-header"},a("h1",{class:"s-loyalty-program-main-title"},salla.lang.get("pages.loyalty_program.how_to_start")),a("p",{class:"s-loyalty-program-subtitle"},salla.lang.get("pages.loyalty_program.three_simple_steps"))),a("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"))))),a("div",{class:"s-loyalty-program-points-wrapper"},a("section",{class:"s-loyalty-program-points-section"},a("header",{class:"s-loyalty-program-points-header"},a("h1",{class:"s-loyalty-program-points-title"},this.program.data.promotion_title),a("p",{class:"s-loyalty-program-points-description"},this.program.data.promotion_description)),a("div",{class:"s-loyalty-program-points-spacer"}),a("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}},s.map((s=>a("li",null,a("salla-loyalty-point",{point:s}))))),a("div",{class:"s-loyalty-program-points-spacer"}),t(this.program.data.points.length)!==this.program.data.points.length&&a("button",{class:"s-loyalty-program-points-more-button",onClick:()=>this.collapsed=!this.collapsed},this.collapsed?a("span",null,salla.lang.get("pages.loyalty_program.show_more"),"  ",a("span",{style:{fontSize:"1.2rem",fontWeight:"300"}},"+")):a("span",null,salla.lang.get("pages.loyalty_program.show_less"),"  ",a("span",{style:{fontSize:"1.2rem",fontWeight:"300"}},"-"))))),"success"!==this.program.status?"":a("div",{class:"s-loyalty-program-rewards-container s-loyalty-program-slider-arrows-edges"},a("section",{class:{"s-loyalty-program-tabs-hider":l.length<=2||o<=4}},a("h1",{class:"s-loyalty-program-rewards-heading-mobile"},salla.lang.get("pages.loyalty_program.rewards")),a("salla-tabs",null,a("div",{slot:"header",class:"s-loyalty-program-rewards-tab-items"},l.map((s=>a("salla-tab-header",{slot:"header",name:s.type},u[s.type],a("span",null,s.title))))),a("h1",{slot:"header",class:"s-loyalty-program-rewards-heading-desktop"},salla.lang.get("pages.loyalty_program.rewards")),l.map((s=>a("salla-tab-content",{slot:"content",name:s.type},a("salla-slider",{id:s.type,type:"default","slider-config":'{"loop":false,"slidesPerView":"auto","freeMode":true,"spaceBetween":12,"breakpoints":{"768":{"slidesPerView":4,"spaceBetween":24,"freeMode":false,"speed":300}}}'},a("div",{slot:"items"},s.items.map((s=>a("salla-reward-card",{prize:s,onAreaClick:()=>{this.currentPrize=s,r((()=>this.detailsModal.open()))},onActionClick:()=>{this.currentPrize=s,r((()=>this.detailsModal.open()))}}))))))))),a("salla-modal",{ref:a=>this.detailsModal=a,class:"s-loyalty-program-modal",width:"md",noPadding:!0},this.currentPrize?a("salla-reward-details",{onActionClick:()=>r((()=>this.exchangeModal.open())),prize:this.currentPrize}):""),a("salla-modal",{ref:a=>this.exchangeModal=a,class:"s-loyalty-program-modal",width:"sm"},this.currentPrize?a("salla-reward-exchange",{prize:this.currentPrize}):""))))}};h([g((async function(){const{data:a}=await salla.loyalty.getProgram();return o(a)}),{initialData:{points:[],prizes:[],prizes_count:0}})],f.prototype,"program",void 0),h([g((async function(){const{data:a}=await salla.loyalty.getPoints();return d({targets:{value:0},value:a.points??0,round:1,easing:"easeOutQuad",duration:2e3,update:a=>{this.animatedPoints=a.animations[0].currentValue}}),a.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 t,h as e,H as s,a as l,F as i}from"./p-BHYtfMwX.js";const n=class{constructor(e){t(this,e),this.sections=[],this.itemNumber=""}deleteItem(t,e){const s=this.host.closest("form");if(s){const l=s.getAttribute("id");if(l&&"string"==typeof l){const s=l.match(/item-(\d+)/)?.[1];this.itemNumber=s||"";const i=this.host.querySelector(`#accordion-${e.id}`);salla.cart.deleteItem(`${this.itemNumber}?product_id=${e.id}&section_id=${t}`).then((()=>i?.remove()))}}}renderRemoveButton(t,s,l=!1){return e("salla-button",{type:"button",shape:l?"btn":"icon",fill:l?"outline":"solid",size:"small",color:"danger","aria-label":"Remove from the cart",onClick:()=>this.deleteItem(t,s)},l?salla.lang.get("common.elements.delete"):e("i",{class:"sicon-cancel"}))}renderAccordionHeader(t,s){const l=s?.options&&s?.options?.length>0;return e("div",{slot:"html",class:"s-multiple-bundle-product-cart-header-wrapper"},e("div",{class:"s-multiple-bundle-product-cart-header "+(l?"":"s-multiple-bundle-product-cart-header-no-options")},e("div",{class:"s-multiple-bundle-product-cart-header-content"},e("a",{href:s?.url,class:"s-multiple-bundle-product-cart-header-image-wrapper"},e("img",{src:s?.image?.url,alt:s?.image?.alt||s?.name,class:"s-multiple-bundle-product-cart-header-image"})),e("div",{class:"s-multiple-bundle-product-cart-header-content-details"},e("h2",{class:"s-multiple-bundle-product-cart-header-content-details-title"},e("a",{href:s?.url,class:"s-multiple-bundle-product-cart-header-content-details-title-link"},s?.name)),e("div",{class:"s-multiple-bundle-product-cart-header-content-details-price"},e("span",{class:"s-multiple-bundle-product-cart-header-content-details-price-regular"},e("span",{innerHTML:s?.price?salla.money(s?.price):""})),s?.sale_price>0&&e("span",{class:"s-multiple-bundle-product-cart-header-content-details-price-sale"},e("span",{innerHTML:salla.money(s?.sale_price)}))),s?.quantity_in_group>0&&0!==s?.quantity&&e("p",{class:"s-multiple-bundle-product-cart-header-content-details-quantity"},e("span",null,salla.lang.get("pages.products.number_of_pieces")),e("span",null,s?.quantity_in_group)))),!l&&e("div",{class:"s-multiple-bundle-product-cart-header-remove-button"},this.renderRemoveButton(t,s,!1))))}render(){return e(s,{key:"d11f8075e15cd1379d6754b5ce13c81fa7cf9f03",class:"s-multiple-bundle-product-wrapper"},e("div",{key:"293351d69f5e12039ecab876832c6164b1235dab",class:"s-multiple-bundle-product-wrapper-sections"},this.sections.map(((t,s)=>t.products.map((l=>{const i={sectionId:t.id,sectionIndex:s,productId:l.id};return e("salla-accordion",{key:l.id,collapsed:!1,bordered:!0,collapsible:!!(l.options&&l.options.length>0),size:"sm",id:`accordion-${l.id}`},e("salla-accordion-head",null,this.renderAccordionHeader(String(t.id),l)),l.options&&l.options.length>0&&e("salla-accordion-body",null,e("salla-product-options",{options:JSON.stringify(l.options),key:`${l.id}-persistent`,"product-id":l.id,"bundle-context":JSON.stringify(i)}),e("div",{class:"s-multiple-bundle-product-cart-body-remove-button"},this.renderRemoveButton(String(t.id),l,!0))))}))))))}get host(){return l(this)}};n.style="";const c=class{constructor(e){t(this,e),this.sections=[],this.selectedProducts={},this.productSelectedHandler=null,this.onSelectProduct=(t,e)=>{const s=e.id,l=this.selectedProducts[t]?.has(s)??!1,i=this.sections.find((e=>e.id==t));if(!(l&&i&&this.isProductSelectionLocked(i))){if(!l){if(!i)return;if(1!==this.getEffectiveMax(i)&&this.isAtSelectionLimit(i))return}this.selectedProducts={...this.selectedProducts,[t]:new Set(this.selectedProducts[t]||[])},l?(this.selectedProducts[t].delete(s),this.clearProductFormData(s,t),this.clearProductModalOptions(s,t)):1===this.getEffectiveMax(i)?this.syncSectionSelection(t,s):this.selectedProducts[t].add(s),this.selectedProducts={...this.selectedProducts},salla.event.dispatch("on-bundle-product-selected",{id:e.id,name:e.name,options:e.options,wasSelected:l,isSelected:!l})}},this.ensureProductSelected=(t,e)=>{this.selectedProducts={...this.selectedProducts,[t]:new Set(this.selectedProducts[t]||[])};const s=e.id;if(this.selectedProducts[t].has(s))return;const l=this.sections.find((e=>e.id==t));if(!l)return;const i=this.getEffectiveMax(l);if(1===i)this.syncSectionSelection(t,s);else{if(i>1&&this.isAtSelectionLimit(l))return;this.selectedProducts[t].add(s)}this.selectedProducts={...this.selectedProducts},salla.event.dispatch("on-bundle-product-selected",{id:e.id,name:e.name,options:e.options})},this.onSelectProductOptions=(t,e)=>{const s=this.sections.find((t=>t.id==e));if(!s||!this.canSelectProductInSection(s,t.id))return;const l=this.sections.findIndex((t=>t.id==e)),i=s.products?.findIndex((e=>e.id==t.id))??0,n=this.selectedProducts[e]?.has(t.id)??!1;salla.event.dispatch("multiple-bundle-product-modal::open",{product:t,sectionId:e,sectionIndex:l,productIndex:i,isProductAlreadySelected:n})},this.handleBundleSliderProductSelected=t=>{const{product:e,sectionId:s}=t.detail;this.onSelectProduct(s,e)},this.handleBundleSliderProductOptionsSelected=t=>{const{product:e,sectionId:s}=t.detail;this.onSelectProductOptions(e,s)}}isSingleProductSection(t){return 1===(t.products?.length??0)}getObligatoryMin(t){const e=t.obligatory_products;if(null==e)return 0;const s=Number(e);return Number.isNaN(s)?0:s}isProductSelectionLocked(t){return this.isSingleProductSection(t)&&1===this.getObligatoryMin(t)}getEffectiveMax(t){const e=t.products?.length??0,s=t.max_obligatory_products;return null!=s&&s>0?Math.min(s,e):e}getSelectedCount(t){return this.selectedProducts[t]?.size??0}isAtSelectionLimit(t){return this.getSelectedCount(t.id)>=this.getEffectiveMax(t)}canSelectProductInSection(t,e){return!!this.selectedProducts[t.id]?.has(e)||1===this.getEffectiveMax(t)||!this.isAtSelectionLimit(t)}async canSelectBundleProduct(t,e){const s=this.sections.find((e=>e.id==t));return!!s&&this.canSelectProductInSection(s,e)}queryProductCheckbox(t,e){const s=`input.s-multiple-bundle-product-checkbox[name="bundle[${t}][${e}][id]"]`,l=this.host.closest("form"),i=l?.querySelector(s);if(i)return i;for(const t of this.host.querySelectorAll("salla-multiple-bundle-product-slider")){const e=(t.shadowRoot??t).querySelector(s);if(e)return e}return null}dispatchBubblingChange(t){requestAnimationFrame((()=>{t.dispatchEvent(new window.Event("change",{bubbles:!0}))}))}clearSectionProductSlot(t,e,s){const l=this.queryProductCheckbox(t,s);l&&(l.checked=!1);const i=this.host.closest("form");if(i){const e=`bundle[${t}][${s}]`;Array.from(i.querySelectorAll("input")).forEach((t=>{t.name?.startsWith(e)&&("checkbox"===t.type&&t.name?.endsWith("][id]")?t.checked=!1:t.remove())}))}this.clearProductModalOptions(e,t)}syncSectionSelection(t,e){const s=this.sections.find((e=>e.id==t));s?.products?.forEach(((s,l)=>{s.id!=e&&this.clearSectionProductSlot(t,s.id,l)})),this.selectedProducts[t]=new Set([e]);const l=s?.products?.findIndex((t=>t.id==e))??-1,i=l>=0?this.queryProductCheckbox(t,l):null;i&&(i.checked=!0,this.dispatchBubblingChange(i))}autoSelectSingleProductSections(){if(!this.sections?.length)return;const t={...this.selectedProducts};let e=!1;const s=[];for(const l of this.sections){if(!this.isProductSelectionLocked(l))continue;const i=l.products?.[0];if(!i||!i.unlimited_quantity&&(i.quantity??0)<=0)continue;const n=l.id,c=new Set(t[n]||[]);c.has(i.id)||(c.add(i.id),t[n]=c,e=!0,s.push({product:i}))}e&&(this.selectedProducts=t,s.forEach((({product:t})=>{salla.event.dispatch("on-bundle-product-selected",{id:t.id,name:t.name,options:t.options})})))}clearProductFormData(t,e){if(null!=e){const s=this.sections.find((t=>t.id==e)),l=s?.products?.findIndex((e=>e.id==t))??-1;if(l>=0)return void this.clearSectionProductSlot(e,t,l)}const s=this.host.closest("form");s&&s.querySelectorAll(`[data-product-id="${t}"]`).forEach((t=>t.remove()))}clearProductModalOptions(t,e){let s=null,l=null;if(null!=e&&(s=this.sections.findIndex((t=>t.id==e)),s>-1)){const e=this.sections[s];if(e){const s=e.products?.findIndex((e=>e.id==t));l="number"==typeof s&&s>-1?s:null}}salla.event.dispatch("multiple-bundle-product-modal::clear-options",{productId:t,sectionId:e,sectionIndex:s,productIndex:l})}getProgressStatus(t){const e=this.getSelectedCount(t.id),s=this.getEffectiveMax(t);return s>0?`${e}/${s}`:"0"}getSectionSelectionNote(t){const e=this.getObligatoryMin(t),s=Number(t.max_obligatory_products)||0,l=e>0,i=s>0;return l||i?l&&i?e===s?salla.lang.getWithDefault("pages.products.bundle_select_exact",`اختر ${e} منتجات`,{count:e}):salla.lang.getWithDefault("pages.products.bundle_select_range",`اختر من ${e} إلى ${s} منتجات`,{min:e,max:s}):l?salla.lang.getWithDefault("pages.products.bundle_select_min",`اختر على الأقل ${e} منتجات`,{min:e}):salla.lang.getWithDefault("pages.products.bundle_select_max",`اختر حتى ${s} منتجات`,{max:s}):null}handleSectionsChange(){this.autoSelectSingleProductSections()}componentWillLoad(){this.autoSelectSingleProductSections()}renderAccordionHeader(t){const s=this.getSectionSelectionNote(t);return e(i,null,e("h2",{slot:"title"},t?.name),s?e("span",{slot:"note"},s):null,e("span",{slot:"progress"},this.getProgressStatus(t)))}componentDidLoad(){const t=this.host.querySelector("salla-multiple-bundle-product-options-modal");t&&(this.productSelectedHandler=t=>{const{productId:e,sectionId:s,product:l,fromModal:i}=t.detail;i?this.ensureProductSelected(s,l||{id:e}):this.onSelectProduct(s,l||{id:e})},t.addEventListener("productSelected",this.productSelectedHandler))}disconnectedCallback(){if(this.productSelectedHandler){const t=this.host.querySelector("salla-multiple-bundle-product-options-modal");t&&t.removeEventListener("productSelected",this.productSelectedHandler),this.productSelectedHandler=null}}render(){return e(s,{key:"74b123c432e77263cf0ddcf20ab742885c54d5f4",class:"s-multiple-bundle-product-wrapper"},e("div",{key:"24bef0958a2a7d29bb4485eac08c7e6b8614a00d",class:"s-multiple-bundle-product-wrapper-sections"},this.sections.map(((t,s)=>e("salla-accordion",{key:t.id,collapsed:0!==s},e("salla-accordion-head",null,this.renderAccordionHeader(t)),e("salla-accordion-body",null,e("salla-multiple-bundle-product-slider",{section:t,sectionIndex:s,selectedProducts:this.selectedProducts,selectionLimit:this.getEffectiveMax(t),isSelectionLocked:this.isProductSelectionLocked(t),onProductSelected:this.handleBundleSliderProductSelected,onProductOptionsSelected:this.handleBundleSliderProductOptionsSelected})))))),e("salla-multiple-bundle-product-options-modal",{key:"556b4e51a4b79dfc00371a07296556fb74111524"}))}get host(){return l(this)}static get watchers(){return{sections:["handleSectionsChange"]}}};c.style="";export{n as salla_multiple_bundle_product_cart,c as salla_multiple_bundle_product_details}
4
+ import{r as t,h as e,H as s,a as l,F as i}from"./p-CFtXUFT2.js";const n=class{constructor(e){t(this,e),this.sections=[],this.itemNumber=""}deleteItem(t,e){const s=this.host.closest("form");if(s){const l=s.getAttribute("id");if(l&&"string"==typeof l){const s=l.match(/item-(\d+)/)?.[1];this.itemNumber=s||"";const i=this.host.querySelector(`#accordion-${e.id}`);salla.cart.deleteItem(`${this.itemNumber}?product_id=${e.id}&section_id=${t}`).then((()=>i?.remove()))}}}renderRemoveButton(t,s,l=!1){return e("salla-button",{type:"button",shape:l?"btn":"icon",fill:l?"outline":"solid",size:"small",color:"danger","aria-label":"Remove from the cart",onClick:()=>this.deleteItem(t,s)},l?salla.lang.get("common.elements.delete"):e("i",{class:"sicon-cancel"}))}renderAccordionHeader(t,s){const l=s?.options&&s?.options?.length>0;return e("div",{slot:"html",class:"s-multiple-bundle-product-cart-header-wrapper"},e("div",{class:"s-multiple-bundle-product-cart-header "+(l?"":"s-multiple-bundle-product-cart-header-no-options")},e("div",{class:"s-multiple-bundle-product-cart-header-content"},e("a",{href:s?.url,class:"s-multiple-bundle-product-cart-header-image-wrapper"},e("img",{src:s?.image?.url,alt:s?.image?.alt||s?.name,class:"s-multiple-bundle-product-cart-header-image"})),e("div",{class:"s-multiple-bundle-product-cart-header-content-details"},e("h2",{class:"s-multiple-bundle-product-cart-header-content-details-title"},e("a",{href:s?.url,class:"s-multiple-bundle-product-cart-header-content-details-title-link"},s?.name)),e("div",{class:"s-multiple-bundle-product-cart-header-content-details-price"},e("span",{class:"s-multiple-bundle-product-cart-header-content-details-price-regular"},e("span",{innerHTML:s?.price?salla.money(s?.price):""})),s?.sale_price>0&&e("span",{class:"s-multiple-bundle-product-cart-header-content-details-price-sale"},e("span",{innerHTML:salla.money(s?.sale_price)}))),s?.quantity_in_group>0&&0!==s?.quantity&&e("p",{class:"s-multiple-bundle-product-cart-header-content-details-quantity"},e("span",null,salla.lang.get("pages.products.number_of_pieces")),e("span",null,s?.quantity_in_group)))),!l&&e("div",{class:"s-multiple-bundle-product-cart-header-remove-button"},this.renderRemoveButton(t,s,!1))))}render(){return e(s,{key:"d11f8075e15cd1379d6754b5ce13c81fa7cf9f03",class:"s-multiple-bundle-product-wrapper"},e("div",{key:"293351d69f5e12039ecab876832c6164b1235dab",class:"s-multiple-bundle-product-wrapper-sections"},this.sections.map(((t,s)=>t.products.map((l=>{const i={sectionId:t.id,sectionIndex:s,productId:l.id};return e("salla-accordion",{key:l.id,collapsed:!1,bordered:!0,collapsible:!!(l.options&&l.options.length>0),size:"sm",id:`accordion-${l.id}`},e("salla-accordion-head",null,this.renderAccordionHeader(String(t.id),l)),l.options&&l.options.length>0&&e("salla-accordion-body",null,e("salla-product-options",{options:JSON.stringify(l.options),key:`${l.id}-persistent`,"product-id":l.id,"bundle-context":JSON.stringify(i)}),e("div",{class:"s-multiple-bundle-product-cart-body-remove-button"},this.renderRemoveButton(String(t.id),l,!0))))}))))))}get host(){return l(this)}};n.style="";const c=class{constructor(e){t(this,e),this.sections=[],this.selectedProducts={},this.productSelectedHandler=null,this.onSelectProduct=(t,e)=>{const s=e.id,l=this.selectedProducts[t]?.has(s)??!1,i=this.sections.find((e=>e.id==t));if(!(l&&i&&this.isProductSelectionLocked(i))){if(!l){if(!i)return;if(1!==this.getEffectiveMax(i)&&this.isAtSelectionLimit(i))return}this.selectedProducts={...this.selectedProducts,[t]:new Set(this.selectedProducts[t]||[])},l?(this.selectedProducts[t].delete(s),this.clearProductFormData(s,t),this.clearProductModalOptions(s,t)):1===this.getEffectiveMax(i)?this.syncSectionSelection(t,s):this.selectedProducts[t].add(s),this.selectedProducts={...this.selectedProducts},salla.event.dispatch("on-bundle-product-selected",{id:e.id,name:e.name,options:e.options,wasSelected:l,isSelected:!l})}},this.ensureProductSelected=(t,e)=>{this.selectedProducts={...this.selectedProducts,[t]:new Set(this.selectedProducts[t]||[])};const s=e.id;if(this.selectedProducts[t].has(s))return;const l=this.sections.find((e=>e.id==t));if(!l)return;const i=this.getEffectiveMax(l);if(1===i)this.syncSectionSelection(t,s);else{if(i>1&&this.isAtSelectionLimit(l))return;this.selectedProducts[t].add(s)}this.selectedProducts={...this.selectedProducts},salla.event.dispatch("on-bundle-product-selected",{id:e.id,name:e.name,options:e.options})},this.onSelectProductOptions=(t,e)=>{const s=this.sections.find((t=>t.id==e));if(!s||!this.canSelectProductInSection(s,t.id))return;const l=this.sections.findIndex((t=>t.id==e)),i=s.products?.findIndex((e=>e.id==t.id))??0,n=this.selectedProducts[e]?.has(t.id)??!1;salla.event.dispatch("multiple-bundle-product-modal::open",{product:t,sectionId:e,sectionIndex:l,productIndex:i,isProductAlreadySelected:n})},this.handleBundleSliderProductSelected=t=>{const{product:e,sectionId:s}=t.detail;this.onSelectProduct(s,e)},this.handleBundleSliderProductOptionsSelected=t=>{const{product:e,sectionId:s}=t.detail;this.onSelectProductOptions(e,s)}}isSingleProductSection(t){return 1===(t.products?.length??0)}getObligatoryMin(t){const e=t.obligatory_products;if(null==e)return 0;const s=Number(e);return Number.isNaN(s)?0:s}isProductSelectionLocked(t){return this.isSingleProductSection(t)&&1===this.getObligatoryMin(t)}getEffectiveMax(t){const e=t.products?.length??0,s=t.max_obligatory_products;return null!=s&&s>0?Math.min(s,e):e}getSelectedCount(t){return this.selectedProducts[t]?.size??0}isAtSelectionLimit(t){return this.getSelectedCount(t.id)>=this.getEffectiveMax(t)}canSelectProductInSection(t,e){return!!this.selectedProducts[t.id]?.has(e)||1===this.getEffectiveMax(t)||!this.isAtSelectionLimit(t)}async canSelectBundleProduct(t,e){const s=this.sections.find((e=>e.id==t));return!!s&&this.canSelectProductInSection(s,e)}queryProductCheckbox(t,e){const s=`input.s-multiple-bundle-product-checkbox[name="bundle[${t}][${e}][id]"]`,l=this.host.closest("form"),i=l?.querySelector(s);if(i)return i;for(const t of this.host.querySelectorAll("salla-multiple-bundle-product-slider")){const e=(t.shadowRoot??t).querySelector(s);if(e)return e}return null}dispatchBubblingChange(t){requestAnimationFrame((()=>{t.dispatchEvent(new window.Event("change",{bubbles:!0}))}))}clearSectionProductSlot(t,e,s){const l=this.queryProductCheckbox(t,s);l&&(l.checked=!1);const i=this.host.closest("form");if(i){const e=`bundle[${t}][${s}]`;Array.from(i.querySelectorAll("input")).forEach((t=>{t.name?.startsWith(e)&&("checkbox"===t.type&&t.name?.endsWith("][id]")?t.checked=!1:t.remove())}))}this.clearProductModalOptions(e,t)}syncSectionSelection(t,e){const s=this.sections.find((e=>e.id==t));s?.products?.forEach(((s,l)=>{s.id!=e&&this.clearSectionProductSlot(t,s.id,l)})),this.selectedProducts[t]=new Set([e]);const l=s?.products?.findIndex((t=>t.id==e))??-1,i=l>=0?this.queryProductCheckbox(t,l):null;i&&(i.checked=!0,this.dispatchBubblingChange(i))}autoSelectSingleProductSections(){if(!this.sections?.length)return;const t={...this.selectedProducts};let e=!1;const s=[];for(const l of this.sections){if(!this.isProductSelectionLocked(l))continue;const i=l.products?.[0];if(!i||!i.unlimited_quantity&&(i.quantity??0)<=0)continue;const n=l.id,c=new Set(t[n]||[]);c.has(i.id)||(c.add(i.id),t[n]=c,e=!0,s.push({product:i}))}e&&(this.selectedProducts=t,s.forEach((({product:t})=>{salla.event.dispatch("on-bundle-product-selected",{id:t.id,name:t.name,options:t.options})})))}clearProductFormData(t,e){if(null!=e){const s=this.sections.find((t=>t.id==e)),l=s?.products?.findIndex((e=>e.id==t))??-1;if(l>=0)return void this.clearSectionProductSlot(e,t,l)}const s=this.host.closest("form");s&&s.querySelectorAll(`[data-product-id="${t}"]`).forEach((t=>t.remove()))}clearProductModalOptions(t,e){let s=null,l=null;if(null!=e&&(s=this.sections.findIndex((t=>t.id==e)),s>-1)){const e=this.sections[s];if(e){const s=e.products?.findIndex((e=>e.id==t));l="number"==typeof s&&s>-1?s:null}}salla.event.dispatch("multiple-bundle-product-modal::clear-options",{productId:t,sectionId:e,sectionIndex:s,productIndex:l})}getProgressStatus(t){const e=this.getSelectedCount(t.id),s=this.getEffectiveMax(t);return s>0?`${e}/${s}`:"0"}getSectionSelectionNote(t){const e=this.getObligatoryMin(t),s=Number(t.max_obligatory_products)||0,l=e>0,i=s>0;return l||i?l&&i?e===s?salla.lang.getWithDefault("pages.products.bundle_select_exact",`اختر ${e} منتجات`,{count:e}):salla.lang.getWithDefault("pages.products.bundle_select_range",`اختر من ${e} إلى ${s} منتجات`,{min:e,max:s}):l?salla.lang.getWithDefault("pages.products.bundle_select_min",`اختر على الأقل ${e} منتجات`,{min:e}):salla.lang.getWithDefault("pages.products.bundle_select_max",`اختر حتى ${s} منتجات`,{max:s}):null}handleSectionsChange(){this.autoSelectSingleProductSections()}componentWillLoad(){this.autoSelectSingleProductSections()}renderAccordionHeader(t){const s=this.getSectionSelectionNote(t);return e(i,null,e("h2",{slot:"title"},t?.name),s?e("span",{slot:"note"},s):null,e("span",{slot:"progress"},this.getProgressStatus(t)))}componentDidLoad(){const t=this.host.querySelector("salla-multiple-bundle-product-options-modal");t&&(this.productSelectedHandler=t=>{const{productId:e,sectionId:s,product:l,fromModal:i}=t.detail;i?this.ensureProductSelected(s,l||{id:e}):this.onSelectProduct(s,l||{id:e})},t.addEventListener("productSelected",this.productSelectedHandler))}disconnectedCallback(){if(this.productSelectedHandler){const t=this.host.querySelector("salla-multiple-bundle-product-options-modal");t&&t.removeEventListener("productSelected",this.productSelectedHandler),this.productSelectedHandler=null}}render(){return e(s,{key:"74b123c432e77263cf0ddcf20ab742885c54d5f4",class:"s-multiple-bundle-product-wrapper"},e("div",{key:"24bef0958a2a7d29bb4485eac08c7e6b8614a00d",class:"s-multiple-bundle-product-wrapper-sections"},this.sections.map(((t,s)=>e("salla-accordion",{key:t.id,collapsed:0!==s},e("salla-accordion-head",null,this.renderAccordionHeader(t)),e("salla-accordion-body",null,e("salla-multiple-bundle-product-slider",{section:t,sectionIndex:s,selectedProducts:this.selectedProducts,selectionLimit:this.getEffectiveMax(t),isSelectionLocked:this.isProductSelectionLocked(t),onProductSelected:this.handleBundleSliderProductSelected,onProductOptionsSelected:this.handleBundleSliderProductOptionsSelected})))))),e("salla-multiple-bundle-product-options-modal",{key:"556b4e51a4b79dfc00371a07296556fb74111524"}))}get host(){return l(this)}static get watchers(){return{sections:["handleSectionsChange"]}}};c.style="";export{n as salla_multiple_bundle_product_cart,c as salla_multiple_bundle_product_details}