@salla.sa/twilight-components 2.14.540 → 2.14.542

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 (399) hide show
  1. package/dist/cjs/{filepond-U8F_iDbp.js → filepond-B0aAvhFd.js} +1 -1
  2. package/dist/cjs/{filepond-plugin-file-poster-CAJAmCHU.js → filepond-plugin-file-poster-BFqqCNYU.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-validate-size-Dxgl8Gdz.js → filepond-plugin-file-validate-size-BNcTcX1x.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-type-BPhw8zXs.js → filepond-plugin-file-validate-type-DAWd81u4.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-image-edit-DNKfSuCy.js → filepond-plugin-image-edit-CIg9FEsX.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-exif-orientation-NCmUtKOd.js → filepond-plugin-image-exif-orientation--VivPhX_.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-preview-jRCd9jSG.js → filepond-plugin-image-preview-apJ7tv7p.js} +1 -1
  8. package/dist/cjs/helpers-ClOJIAG8.js +89 -0
  9. package/dist/cjs/{index-F_FURF-0.js → index-ufJ3UmgO.js} +18 -14
  10. package/dist/cjs/{intlTelInput-yt9noy9U.js → intlTelInput-1mNNQjMC.js} +1 -1
  11. package/dist/cjs/loader.cjs.js +2 -2
  12. package/dist/cjs/salla-accordion-body_2.cjs.entry.js +1 -1
  13. package/dist/cjs/salla-accordion_6.cjs.entry.js +1 -1
  14. package/dist/cjs/salla-add-product-button_5.cjs.entry.js +8 -2
  15. package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
  16. package/dist/cjs/salla-alert_2.cjs.entry.js +1 -1
  17. package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
  18. package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
  19. package/dist/cjs/{salla-booking-field_7.cjs.entry.js → salla-attachment-view_9.cjs.entry.js} +1003 -40
  20. package/dist/cjs/salla-badge.cjs.entry.js +1 -1
  21. package/dist/cjs/salla-basket-gap.cjs.entry.js +1 -1
  22. package/dist/cjs/salla-bullet-delivery_2.cjs.entry.js +1 -1
  23. package/dist/cjs/salla-cart-coupons.cjs.entry.js +1 -1
  24. package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +1 -1
  25. package/dist/cjs/salla-cart-summary-card.cjs.entry.js +1 -1
  26. package/dist/cjs/salla-cashback-banner.cjs.entry.js +1 -1
  27. package/dist/cjs/salla-comment-factors.cjs.entry.js +2 -2
  28. package/dist/cjs/salla-comment-form_8.cjs.entry.js +14 -5
  29. package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
  30. package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
  31. package/dist/cjs/salla-cookies-bar.cjs.entry.js +1 -1
  32. package/dist/cjs/salla-count-down.cjs.entry.js +1 -1
  33. package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
  34. package/dist/cjs/salla-delivery-promise.cjs.entry.js +1 -1
  35. package/dist/cjs/salla-edit-order-button.cjs.entry.js +1 -1
  36. package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
  37. package/dist/cjs/salla-filters.cjs.entry.js +1 -1
  38. package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +1 -1
  39. package/dist/cjs/salla-gifting.cjs.entry.js +1 -1
  40. package/dist/cjs/salla-hook.cjs.entry.js +1 -1
  41. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
  42. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  43. package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
  44. package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
  45. package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
  46. package/dist/cjs/salla-loyalty-banner_10.cjs.entry.js +1 -1
  47. package/dist/cjs/salla-loyalty-exchange-product-card.cjs.entry.js +1 -1
  48. package/dist/cjs/salla-loyalty-points-banner.cjs.entry.js +1 -1
  49. package/dist/cjs/salla-loyalty-points-history.cjs.entry.js +1 -1
  50. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  51. package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
  52. package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
  53. package/dist/cjs/salla-map_2.cjs.entry.js +1 -1
  54. package/dist/cjs/salla-menu.cjs.entry.js +1 -1
  55. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  56. package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
  57. package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
  58. package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
  59. package/dist/cjs/salla-next-order-coupon.cjs.entry.js +1 -1
  60. package/dist/cjs/salla-notification-item_2.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-branch.cjs.entry.js +1 -1
  64. package/dist/cjs/salla-order-cancel.cjs.entry.js +1 -1
  65. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
  66. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  67. package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
  68. package/dist/cjs/salla-order-edit-item.cjs.entry.js +1 -1
  69. package/dist/cjs/salla-order-edit-product-card.cjs.entry.js +1 -1
  70. package/dist/cjs/salla-order-edit.cjs.entry.js +1 -1
  71. package/dist/cjs/salla-order-options-modal_2.cjs.entry.js +1 -1
  72. package/dist/cjs/salla-order-shipments.cjs.entry.js +1 -1
  73. package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
  74. package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
  75. package/dist/cjs/salla-orders.cjs.entry.js +1 -1
  76. package/dist/cjs/salla-payments.cjs.entry.js +1 -1
  77. package/dist/cjs/salla-placeholder.cjs.entry.js +1 -1
  78. package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
  79. package/dist/cjs/salla-product-card-embed.cjs.entry.js +1 -1
  80. package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
  81. package/dist/cjs/salla-products-list.cjs.entry.js +1 -1
  82. package/dist/cjs/salla-products-slider.cjs.entry.js +1 -1
  83. package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
  84. package/dist/cjs/salla-rating-modal-v2.cjs.entry.js +420 -84
  85. package/dist/cjs/salla-rating-modal.cjs.entry.js +3 -5
  86. package/dist/cjs/salla-review-factors-tags.cjs.entry.js +4 -83
  87. package/dist/cjs/salla-review-order-item.cjs.entry.js +125 -0
  88. package/dist/cjs/salla-scopes.cjs.entry.js +1 -1
  89. package/dist/cjs/salla-search.cjs.entry.js +1 -1
  90. package/dist/cjs/salla-skeleton.cjs.entry.js +1 -1
  91. package/dist/cjs/salla-slider.cjs.entry.js +1 -1
  92. package/dist/cjs/salla-social-share.cjs.entry.js +1 -1
  93. package/dist/cjs/salla-social.cjs.entry.js +1 -1
  94. package/dist/cjs/salla-tab-content_3.cjs.entry.js +1 -1
  95. package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
  96. package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
  97. package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
  98. package/dist/cjs/salla-user-menu.cjs.entry.js +1 -1
  99. package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
  100. package/dist/cjs/salla-user-settings.cjs.entry.js +1 -1
  101. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  102. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  103. package/dist/cjs/salla-wishlist-actions.cjs.entry.js +1 -1
  104. package/dist/cjs/twilight.cjs.js +2 -2
  105. package/dist/cjs/upload-limits-C3RarAPN.js +136 -0
  106. package/dist/cjs/{vanilla-picker-DXgSpklI.js → vanilla-picker-DvN9odkn.js} +1 -1
  107. package/dist/collection/collection-manifest.json +16 -11
  108. package/dist/collection/components/salla-attachment-view/salla-attachment-view.css +164 -0
  109. package/dist/collection/components/salla-attachment-view/salla-attachment-view.js +250 -0
  110. package/dist/collection/components/salla-attachments/salla-attachments.css +69 -0
  111. package/dist/collection/components/salla-attachments/salla-attachments.js +375 -0
  112. package/dist/collection/components/salla-comments/salla-comment-item.js +13 -3
  113. package/dist/collection/components/salla-comments/salla-comments.css +7 -0
  114. package/dist/collection/components/salla-datetime-picker/salla-datetime-picker.js +1 -1
  115. package/dist/collection/components/salla-file-upload/salla-file-upload.css +149 -0
  116. package/dist/collection/components/salla-file-upload/salla-file-upload.js +784 -42
  117. package/dist/collection/components/salla-file-upload/upload-limits.js +127 -0
  118. package/dist/collection/components/salla-product-options/salla-product-options.js +7 -1
  119. package/dist/collection/components/salla-products-slider/salla-products-slider.js +1 -1
  120. package/dist/collection/components/salla-rating-modal/rating-modal-media.js +85 -0
  121. package/dist/collection/components/salla-rating-modal/salla-rating-modal-v2.js +348 -85
  122. package/dist/collection/components/salla-rating-modal/salla-rating-modal.css +17 -7
  123. package/dist/collection/components/salla-rating-modal/salla-rating-modal.js +1 -3
  124. package/dist/collection/components/salla-review-factors-tags/helpers.js +8 -7
  125. package/dist/collection/components/salla-review-order-item/interfaces.js +1 -0
  126. package/dist/collection/components/salla-review-order-item/salla-review-order-item.js +154 -0
  127. package/dist/components/index.js +2 -2
  128. package/dist/components/salla-add-product-button2.js +40 -28
  129. package/dist/components/salla-attachment-view.d.ts +11 -0
  130. package/dist/components/salla-attachment-view.js +9 -0
  131. package/dist/components/salla-attachment-view2.js +323 -0
  132. package/dist/components/salla-attachments.d.ts +11 -0
  133. package/dist/components/salla-attachments.js +9 -0
  134. package/dist/components/salla-attachments2.js +232 -0
  135. package/dist/components/salla-basket-gap.js +46 -34
  136. package/dist/components/salla-breadcrumb.js +1 -1
  137. package/dist/components/salla-comment-factors2.js +1 -1
  138. package/dist/components/salla-comment-item2.js +26 -4
  139. package/dist/components/salla-comments.js +14 -2
  140. package/dist/components/salla-custom-fields.js +28 -4
  141. package/dist/components/salla-file-upload2.js +703 -31
  142. package/dist/components/salla-gifting.js +7 -1
  143. package/dist/components/salla-loyalty-exchange-product-card2.js +46 -34
  144. package/dist/components/salla-loyalty-panel.js +8 -2
  145. package/dist/components/salla-loyalty-program.js +8 -2
  146. package/dist/components/salla-multiple-bundle-product-cart2.js +40 -28
  147. package/dist/components/salla-multiple-bundle-product-details2.js +12 -6
  148. package/dist/components/salla-multiple-bundle-product-options-modal2.js +7 -1
  149. package/dist/components/salla-multiple-bundle-product-slider2.js +1 -1
  150. package/dist/components/salla-multiple-bundle-product.js +12 -6
  151. package/dist/components/salla-offer-modal.js +8 -2
  152. package/dist/components/salla-order-edit-item2.js +36 -24
  153. package/dist/components/salla-order-edit.js +42 -30
  154. package/dist/components/salla-order-options-modal2.js +34 -22
  155. package/dist/components/salla-product-card2.js +44 -32
  156. package/dist/components/salla-product-options2.js +39 -21
  157. package/dist/components/salla-products-slider2.js +8 -2
  158. package/dist/components/salla-quick-buy2.js +36 -24
  159. package/dist/components/salla-rating-modal-v22.js +449 -97
  160. package/dist/components/salla-rating-modal.js +30 -20
  161. package/dist/components/salla-review-factors-tags2.js +9 -8
  162. package/dist/components/salla-review-order-item.d.ts +11 -0
  163. package/dist/components/salla-review-order-item.js +196 -0
  164. package/dist/components/salla-reward-details2.js +8 -2
  165. package/dist/components/salla-slider2.js +1 -1
  166. package/dist/esm/{filepond-Bxzb6RRZ.js → filepond-BJvckaDn.js} +1 -1
  167. package/dist/esm/{filepond-plugin-file-poster-CZfrjnEX.js → filepond-plugin-file-poster-BJGjo9nD.js} +1 -1
  168. package/dist/esm/{filepond-plugin-file-validate-size-Dqa69lX7.js → filepond-plugin-file-validate-size-DLFBVAw5.js} +1 -1
  169. package/dist/esm/{filepond-plugin-file-validate-type-C_76nxDb.js → filepond-plugin-file-validate-type-Cl7gFtPR.js} +1 -1
  170. package/dist/esm/{filepond-plugin-image-edit-BvzVMeMY.js → filepond-plugin-image-edit-P-yC8gQP.js} +1 -1
  171. package/dist/esm/{filepond-plugin-image-exif-orientation-Br4ANTi7.js → filepond-plugin-image-exif-orientation-Ck7hEAD_.js} +1 -1
  172. package/dist/esm/{filepond-plugin-image-preview-e54xZ08P.js → filepond-plugin-image-preview-BSCNg5pC.js} +1 -1
  173. package/dist/esm/helpers-DqXpn47Z.js +85 -0
  174. package/dist/esm/{index-5UtJVEzd.js → index-DaGqpYdk.js} +18 -14
  175. package/dist/esm/{intlTelInput-BQXch__5.js → intlTelInput-CFalf-QE.js} +1 -1
  176. package/dist/esm/loader.js +3 -3
  177. package/dist/esm/salla-accordion-body_2.entry.js +1 -1
  178. package/dist/esm/salla-accordion_6.entry.js +1 -1
  179. package/dist/esm/salla-add-product-button_5.entry.js +8 -2
  180. package/dist/esm/salla-advertisement.entry.js +1 -1
  181. package/dist/esm/salla-alert_2.entry.js +1 -1
  182. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  183. package/dist/esm/salla-apps-icons.entry.js +1 -1
  184. package/dist/esm/{salla-booking-field_7.entry.js → salla-attachment-view_9.entry.js} +1002 -41
  185. package/dist/esm/salla-badge.entry.js +1 -1
  186. package/dist/esm/salla-basket-gap.entry.js +1 -1
  187. package/dist/esm/salla-bullet-delivery_2.entry.js +1 -1
  188. package/dist/esm/salla-cart-coupons.entry.js +1 -1
  189. package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
  190. package/dist/esm/salla-cart-summary-card.entry.js +1 -1
  191. package/dist/esm/salla-cashback-banner.entry.js +1 -1
  192. package/dist/esm/salla-comment-factors.entry.js +2 -2
  193. package/dist/esm/salla-comment-form_8.entry.js +14 -5
  194. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  195. package/dist/esm/salla-contacts.entry.js +1 -1
  196. package/dist/esm/salla-cookies-bar.entry.js +1 -1
  197. package/dist/esm/salla-count-down.entry.js +1 -1
  198. package/dist/esm/salla-custom-fields.entry.js +1 -1
  199. package/dist/esm/salla-delivery-promise.entry.js +1 -1
  200. package/dist/esm/salla-edit-order-button.entry.js +1 -1
  201. package/dist/esm/salla-filters-widget.entry.js +1 -1
  202. package/dist/esm/salla-filters.entry.js +1 -1
  203. package/dist/esm/salla-fulfillment-methods.entry.js +1 -1
  204. package/dist/esm/salla-gifting.entry.js +1 -1
  205. package/dist/esm/salla-hook.entry.js +1 -1
  206. package/dist/esm/salla-infinite-scroll.entry.js +1 -1
  207. package/dist/esm/salla-installment.entry.js +1 -1
  208. package/dist/esm/salla-list-tile.entry.js +1 -1
  209. package/dist/esm/salla-localization-modal.entry.js +1 -1
  210. package/dist/esm/salla-login-modal.entry.js +1 -1
  211. package/dist/esm/salla-loyalty-banner_10.entry.js +1 -1
  212. package/dist/esm/salla-loyalty-exchange-product-card.entry.js +1 -1
  213. package/dist/esm/salla-loyalty-points-banner.entry.js +1 -1
  214. package/dist/esm/salla-loyalty-points-history.entry.js +1 -1
  215. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  216. package/dist/esm/salla-loyalty.entry.js +1 -1
  217. package/dist/esm/salla-maintenance-alert.entry.js +1 -1
  218. package/dist/esm/salla-map_2.entry.js +1 -1
  219. package/dist/esm/salla-menu.entry.js +1 -1
  220. package/dist/esm/salla-metadata.entry.js +1 -1
  221. package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
  222. package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
  223. package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
  224. package/dist/esm/salla-next-order-coupon.entry.js +1 -1
  225. package/dist/esm/salla-notification-item_2.entry.js +1 -1
  226. package/dist/esm/salla-offer-modal.entry.js +1 -1
  227. package/dist/esm/salla-offer.entry.js +1 -1
  228. package/dist/esm/salla-order-branch.entry.js +1 -1
  229. package/dist/esm/salla-order-cancel.entry.js +1 -1
  230. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  231. package/dist/esm/salla-order-details-options.entry.js +1 -1
  232. package/dist/esm/salla-order-details.entry.js +1 -1
  233. package/dist/esm/salla-order-edit-item.entry.js +1 -1
  234. package/dist/esm/salla-order-edit-product-card.entry.js +1 -1
  235. package/dist/esm/salla-order-edit.entry.js +1 -1
  236. package/dist/esm/salla-order-options-modal_2.entry.js +1 -1
  237. package/dist/esm/salla-order-shipments.entry.js +1 -1
  238. package/dist/esm/salla-order-summary.entry.js +1 -1
  239. package/dist/esm/salla-order-totals-card.entry.js +1 -1
  240. package/dist/esm/salla-orders.entry.js +1 -1
  241. package/dist/esm/salla-payments.entry.js +1 -1
  242. package/dist/esm/salla-placeholder.entry.js +1 -1
  243. package/dist/esm/salla-price-range.entry.js +1 -1
  244. package/dist/esm/salla-product-card-embed.entry.js +1 -1
  245. package/dist/esm/salla-product-size-guide.entry.js +1 -1
  246. package/dist/esm/salla-products-list.entry.js +1 -1
  247. package/dist/esm/salla-products-slider.entry.js +1 -1
  248. package/dist/esm/salla-quick-order.entry.js +1 -1
  249. package/dist/esm/salla-rating-modal-v2.entry.js +420 -84
  250. package/dist/esm/salla-rating-modal.entry.js +3 -5
  251. package/dist/esm/salla-review-factors-tags.entry.js +2 -81
  252. package/dist/esm/salla-review-order-item.entry.js +123 -0
  253. package/dist/esm/salla-scopes.entry.js +1 -1
  254. package/dist/esm/salla-search.entry.js +1 -1
  255. package/dist/esm/salla-skeleton.entry.js +1 -1
  256. package/dist/esm/salla-slider.entry.js +1 -1
  257. package/dist/esm/salla-social-share.entry.js +1 -1
  258. package/dist/esm/salla-social.entry.js +1 -1
  259. package/dist/esm/salla-tab-content_3.entry.js +1 -1
  260. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  261. package/dist/esm/salla-tooltip.entry.js +1 -1
  262. package/dist/esm/salla-trust-badges.entry.js +1 -1
  263. package/dist/esm/salla-user-menu.entry.js +1 -1
  264. package/dist/esm/salla-user-profile.entry.js +1 -1
  265. package/dist/esm/salla-user-settings.entry.js +1 -1
  266. package/dist/esm/salla-verify.entry.js +1 -1
  267. package/dist/esm/salla-wallet.entry.js +1 -1
  268. package/dist/esm/salla-wishlist-actions.entry.js +1 -1
  269. package/dist/esm/twilight.js +3 -3
  270. package/dist/esm/upload-limits-DrXX8XG8.js +121 -0
  271. package/dist/esm/{vanilla-picker-lLULIehu.js → vanilla-picker-BPvYmRRu.js} +1 -1
  272. package/dist/twilight/{p-1ee008c3.entry.js → p-06558ec3.entry.js} +1 -1
  273. package/dist/twilight/{p-18d7763b.entry.js → p-096b05e7.entry.js} +1 -1
  274. package/dist/twilight/p-09848b04.entry.js +4 -0
  275. package/dist/twilight/{p-f5747d3c.entry.js → p-0df4b2e1.entry.js} +1 -1
  276. package/dist/twilight/p-11347c90.entry.js +4 -0
  277. package/dist/twilight/{p-693d012f.entry.js → p-16c80467.entry.js} +1 -1
  278. package/dist/twilight/{p-3b0032e4.entry.js → p-17d19645.entry.js} +1 -1
  279. package/dist/twilight/{p-200a9c11.entry.js → p-1cfd78ce.entry.js} +1 -1
  280. package/dist/twilight/{p-582247b3.entry.js → p-1f63a8a3.entry.js} +1 -1
  281. package/dist/twilight/{p-3af52c82.entry.js → p-21ca76cd.entry.js} +1 -1
  282. package/dist/twilight/{p-d6b6f984.entry.js → p-243dc280.entry.js} +1 -1
  283. package/dist/twilight/{p-e6007706.entry.js → p-25b45505.entry.js} +1 -1
  284. package/dist/twilight/{p-900ee42a.entry.js → p-268a3562.entry.js} +1 -1
  285. package/dist/twilight/{p-ce941081.entry.js → p-26a4ab4b.entry.js} +1 -1
  286. package/dist/twilight/p-2996d4b7.entry.js +4 -0
  287. package/dist/twilight/{p-95224232.entry.js → p-29cddb02.entry.js} +1 -1
  288. package/dist/twilight/{p-088c1ab3.entry.js → p-30201fb9.entry.js} +1 -1
  289. package/dist/twilight/{p-66448f0f.entry.js → p-3282b3a6.entry.js} +1 -1
  290. package/dist/twilight/p-32ceb30c.entry.js +4 -0
  291. package/dist/twilight/{p-b9b32feb.entry.js → p-33a9c78a.entry.js} +1 -1
  292. package/dist/twilight/{p-49c2e935.entry.js → p-390d4d73.entry.js} +1 -1
  293. package/dist/twilight/{p-71731e63.entry.js → p-42dccb9d.entry.js} +1 -1
  294. package/dist/twilight/{p-4e2e4e92.entry.js → p-46e413e3.entry.js} +1 -1
  295. package/dist/twilight/p-4860edc2.entry.js +4 -0
  296. package/dist/twilight/{p-6c4cef7a.entry.js → p-494948d0.entry.js} +1 -1
  297. package/dist/twilight/{p-3136d942.entry.js → p-495b632f.entry.js} +1 -1
  298. package/dist/twilight/{p-fe222cbe.entry.js → p-4c30313e.entry.js} +1 -1
  299. package/dist/twilight/{p-66313db6.entry.js → p-4f59ac12.entry.js} +1 -1
  300. package/dist/twilight/{p-b16c1eac.entry.js → p-505ff5ef.entry.js} +1 -1
  301. package/dist/twilight/{p-21e9a475.entry.js → p-53735832.entry.js} +1 -1
  302. package/dist/twilight/{p-6e766b2a.entry.js → p-58d25433.entry.js} +1 -1
  303. package/dist/twilight/{p-ad54610c.entry.js → p-59c4876b.entry.js} +1 -1
  304. package/dist/twilight/{p-c224fa3a.entry.js → p-5c51b1a6.entry.js} +1 -1
  305. package/dist/twilight/p-61eeadbb.entry.js +4 -0
  306. package/dist/twilight/{p-497cc3a6.entry.js → p-6413aff2.entry.js} +1 -1
  307. package/dist/twilight/{p-4cff8533.entry.js → p-6794c97c.entry.js} +1 -1
  308. package/dist/twilight/{p-f27472f4.entry.js → p-684d6eb1.entry.js} +1 -1
  309. package/dist/twilight/{p-5f1b8510.entry.js → p-6972d948.entry.js} +1 -1
  310. package/dist/twilight/p-71ced4b7.entry.js +4 -0
  311. package/dist/twilight/{p-73607393.entry.js → p-72000ddb.entry.js} +1 -1
  312. package/dist/twilight/{p-891009e2.entry.js → p-72ae244c.entry.js} +1 -1
  313. package/dist/twilight/{p-ac9a54cc.entry.js → p-73edafaa.entry.js} +1 -1
  314. package/dist/twilight/{p-5cbbf472.entry.js → p-77391513.entry.js} +1 -1
  315. package/dist/twilight/p-7763e0be.entry.js +4 -0
  316. package/dist/twilight/{p-bb7bc52f.entry.js → p-77ba1fda.entry.js} +1 -1
  317. package/dist/twilight/{p-b639f062.entry.js → p-7a321b1c.entry.js} +1 -1
  318. package/dist/twilight/{p-acd1a9d8.entry.js → p-7bb14e7b.entry.js} +1 -1
  319. package/dist/twilight/{p-575b3b4c.entry.js → p-7bcd6e69.entry.js} +1 -1
  320. package/dist/twilight/{p-1c66fdb3.entry.js → p-7c61baf1.entry.js} +1 -1
  321. package/dist/twilight/{p-9af31040.entry.js → p-7d24fc33.entry.js} +1 -1
  322. package/dist/twilight/{p-524aabd2.entry.js → p-82fb654b.entry.js} +1 -1
  323. package/dist/twilight/{p-46d2375b.entry.js → p-8a12cb3e.entry.js} +1 -1
  324. package/dist/twilight/{p-ed9899c0.entry.js → p-8d4fe636.entry.js} +1 -1
  325. package/dist/twilight/{p-d8a69feb.entry.js → p-8d8fe545.entry.js} +1 -1
  326. package/dist/twilight/{p-4c34e1fd.entry.js → p-8e288b57.entry.js} +1 -1
  327. package/dist/twilight/{p-02e821a0.entry.js → p-930f7101.entry.js} +1 -1
  328. package/dist/twilight/{p-271a2d55.entry.js → p-96f7014a.entry.js} +1 -1
  329. package/dist/twilight/p-97ce9cb0.entry.js +4 -0
  330. package/dist/twilight/{p-1YJa6YaH.js → p-B-gnDFoe.js} +1 -1
  331. package/dist/twilight/{p-5njrWPq2.js → p-B0zeNMnk.js} +2 -2
  332. package/dist/twilight/{p-Dke2dnYe.js → p-BG6uSDFf.js} +1 -1
  333. package/dist/twilight/{p-CXv4fDWa.js → p-BQK0M8C7.js} +1 -1
  334. package/dist/twilight/{p-WDLGvEaR.js → p-BimR7cIN.js} +1 -1
  335. package/dist/twilight/{p-Cf5WZwC9.js → p-BqpEp7-e.js} +1 -1
  336. package/dist/twilight/{p-Dso9PQdO.js → p-Cv-hXjUb.js} +1 -1
  337. package/dist/twilight/{p-yEKxvrPt.js → p-DXvNz88d.js} +1 -1
  338. package/dist/twilight/{p-5UtJVEzd.js → p-DaGqpYdk.js} +1 -1
  339. package/dist/twilight/p-DqXpn47Z.js +4 -0
  340. package/dist/twilight/p-DrXX8XG8.js +4 -0
  341. package/dist/twilight/{p-CkJpLPBM.js → p-WLC9KdSz.js} +1 -1
  342. package/dist/twilight/{p-fb2c863d.entry.js → p-a08fb92b.entry.js} +1 -1
  343. package/dist/twilight/{p-5a26fb06.entry.js → p-a49c78f0.entry.js} +1 -1
  344. package/dist/twilight/{p-7a17138f.entry.js → p-a77540ee.entry.js} +1 -1
  345. package/dist/twilight/{p-2a9a4e12.entry.js → p-a89ae474.entry.js} +1 -1
  346. package/dist/twilight/{p-f3771ebc.entry.js → p-a9db1142.entry.js} +1 -1
  347. package/dist/twilight/{p-1bc7ab28.entry.js → p-ac7422d5.entry.js} +1 -1
  348. package/dist/twilight/{p-d4e1a8f7.entry.js → p-b13f73f7.entry.js} +1 -1
  349. package/dist/twilight/{p-b9477568.entry.js → p-b4db2812.entry.js} +1 -1
  350. package/dist/twilight/{p-e4cb5ee8.entry.js → p-b948c4e7.entry.js} +1 -1
  351. package/dist/twilight/{p-02df1c31.entry.js → p-c21a156c.entry.js} +1 -1
  352. package/dist/twilight/{p-8dab94d8.entry.js → p-c2b80e5c.entry.js} +1 -1
  353. package/dist/twilight/{p-b7f1bad9.entry.js → p-c34bf692.entry.js} +1 -1
  354. package/dist/twilight/{p-6757a647.entry.js → p-c55ce57e.entry.js} +1 -1
  355. package/dist/twilight/{p-64ee420e.entry.js → p-c7f384ba.entry.js} +1 -1
  356. package/dist/twilight/{p-1578cbe5.entry.js → p-ca56bdf4.entry.js} +1 -1
  357. package/dist/twilight/{p-40a0baa7.entry.js → p-cc80d691.entry.js} +1 -1
  358. package/dist/twilight/{p-913d4965.entry.js → p-cdaafc9b.entry.js} +1 -1
  359. package/dist/twilight/{p-c138132c.entry.js → p-ce868465.entry.js} +1 -1
  360. package/dist/twilight/{p-7e9d67f2.entry.js → p-d16998b0.entry.js} +1 -1
  361. package/dist/twilight/{p-397acd73.entry.js → p-d3ab94f2.entry.js} +1 -1
  362. package/dist/twilight/{p-963d34af.entry.js → p-d4ba3882.entry.js} +1 -1
  363. package/dist/twilight/{p-2d62c356.entry.js → p-d9ff0ef8.entry.js} +1 -1
  364. package/dist/twilight/{p-1c049149.entry.js → p-dd2f9c7d.entry.js} +1 -1
  365. package/dist/twilight/{p-a5afb821.entry.js → p-de002b09.entry.js} +1 -1
  366. package/dist/twilight/{p-a9e276fa.entry.js → p-e088823b.entry.js} +1 -1
  367. package/dist/twilight/{p-b5c90151.entry.js → p-e50e92d4.entry.js} +1 -1
  368. package/dist/twilight/{p-538a1642.entry.js → p-e5f6f36a.entry.js} +1 -1
  369. package/dist/twilight/{p-0ecbe43b.entry.js → p-e6090253.entry.js} +1 -1
  370. package/dist/twilight/{p-c8c36233.entry.js → p-e6e778d0.entry.js} +1 -1
  371. package/dist/twilight/{p-4e71dacc.entry.js → p-ea05a3b9.entry.js} +1 -1
  372. package/dist/twilight/{p-fbb156e8.entry.js → p-ec0d05d5.entry.js} +9 -9
  373. package/dist/twilight/{p-d505caaf.entry.js → p-ed7597fe.entry.js} +1 -1
  374. package/dist/twilight/{p-c05513ae.entry.js → p-f1077a6e.entry.js} +1 -1
  375. package/dist/twilight/{p-0895958b.entry.js → p-f1d5bc83.entry.js} +1 -1
  376. package/dist/twilight/twilight.esm.js +1 -1
  377. package/dist/types/components/salla-attachment-view/salla-attachment-view.d.ts +47 -0
  378. package/dist/types/components/salla-attachments/salla-attachments.d.ts +73 -0
  379. package/dist/types/components/salla-comments/interfaces.d.ts +1 -0
  380. package/dist/types/components/salla-comments/salla-comment-item.d.ts +3 -1
  381. package/dist/types/components/salla-file-upload/salla-file-upload.d.ts +127 -4
  382. package/dist/types/components/salla-file-upload/upload-limits.d.ts +49 -0
  383. package/dist/types/components/salla-rating-modal/rating-modal-media.d.ts +38 -0
  384. package/dist/types/components/salla-rating-modal/salla-rating-modal-v2.d.ts +30 -7
  385. package/dist/types/components/salla-review-factors-tags/helpers.d.ts +1 -1
  386. package/dist/types/components/salla-review-factors-tags/interfaces.d.ts +7 -0
  387. package/dist/types/components/salla-review-order-item/interfaces.d.ts +30 -0
  388. package/dist/types/components/salla-review-order-item/salla-review-order-item.d.ts +30 -0
  389. package/dist/types/components.d.ts +282 -7
  390. package/package.json +5 -5
  391. package/dist/twilight/p-0bc1c246.entry.js +0 -4
  392. package/dist/twilight/p-16c09de9.entry.js +0 -4
  393. package/dist/twilight/p-3024f859.entry.js +0 -4
  394. package/dist/twilight/p-3b821dc9.entry.js +0 -4
  395. package/dist/twilight/p-4dabd999.entry.js +0 -4
  396. package/dist/twilight/p-aaa37ca1.entry.js +0 -4
  397. package/dist/twilight/p-dcf53c45.entry.js +0 -4
  398. package/dist/twilight/p-f17fa83f.entry.js +0 -4
  399. package/dist/components/{keyboard_arrow_right.js → keyboard_arrow_left.js} +6 -6
@@ -0,0 +1,4 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ import{r as t,h as a,H as i,a as s}from"./p-DaGqpYdk.js";import{a as e}from"./p-CgtvEd63.js";import{C as r}from"./p-BV4kqbdL.js";import{I as o}from"./p-C-tzSDxw.js";import{e as n}from"./p-DzAIgzdz.js";import{S as l}from"./p-lMgMt31Q.js";import{S as d}from"./p-CeFAfcTv.js";import{W as m}from"./p-CgR-T_ZS.js";import{H as g}from"./p-DOBDDG4K.js";const c=class{constructor(a){t(this,a),this.hasError=!1,this.showContactWidget=!0,this.images=[],this.productImages={},this.editItemImages=[],this.contact_body=(t,a,i)=>salla.lang.get("pages.rating.contact_subject",{store:t,id:a,customer:i}),this.editMode=!1,this.defaultMode=!1,this.deleteMode=!1,this.shouldOpenDeleteModal=!1,this.editItem=null,this.loyaltyImageRatingPoints=0,this.enableNewPopUp=!1,this.dragAndDropFilesLabel=salla.lang.get("common.uploader.drag_and_drop_files"),this.contactSubjectLabel=salla.lang.get("pages.rating.contact_subject"),this.editReviewLabel=salla.lang.get("pages.rating.edit_review"),this.allowedImagesTypesLabel=salla.lang.get("common.uploader.allowed_images_types"),this.addImagesLabel=salla.lang.get("pages.rating.add_images"),this.editImagesLabel=salla.lang.get("pages.rating.edit_images"),this.threeImagesMax=salla.lang.get("common.uploader.max_three_images"),this.areYouSureLabel=salla.lang.get("pages.rating.are_you_sure_you_want_to_delete_review"),this.confirmDeletionLabel=salla.lang.get("pages.rating.confirm_deletion"),this.cancelLabel=salla.lang.get("common.elements.cancel"),this.confirmDeleteBtn=salla.lang.get("common.elements.confirm_delete"),this.updatedSuccessfullyLabel=salla.lang.get("pages.rating.review_updated_successfully"),this.deletedSuccessfullyLabel=salla.lang.get("pages.rating.review_deleted_successfully"),this.contactUsLabel=salla.lang.get("blocks.footer.social"),this.loyaltyPointsForImagesLabel=salla.lang.get("pages.rating.loyalty_points_for_images",{points:":points"}),this.allowAttachImages=salla.config.get("store.settings.rating.allow_attach_images"),this.allowContactSupport=salla.config.get("store.settings.rating.allow_contact_support"),this.contentRefs=[],this.hiddenInputs=[],this.isOpen=[],this.stepsCount=0,this.currentIndex=0,this.submitted=[],this.MAX_UPLOAD_LIMIT=3,this.onOpen=t=>new Promise((a=>{e({targets:this.contentRefs[t],duration:100,height:this.contentRefs[t].scrollHeight,opacity:[0,1],easing:"easeOutQuart",complete:()=>a()})})),this.onClose=t=>new Promise((a=>{e({targets:this.contentRefs[t],duration:100,height:0,opacity:[1,0],easing:"easeOutQuart",complete:()=>a()})})),this.toggleUploader=async t=>{this.isOpen[t]=!this.isOpen[t],g.toggleElementClassIf(this.contentRefs[t],"is-closed","is-opened",(()=>!this.isOpen[t])),await(this.isOpen[t]?this.onOpen(t):this.onClose(t)),await new Promise((t=>setTimeout(t,101))),this.body&&this.currentTab&&setTimeout((()=>this.body.setAttribute("style",`height:${this.currentTab.offsetHeight+(this.editMode?60:0)}px`)))},salla.onReady((()=>{this.orderId=salla.config.get("page.id")})),salla.lang.onLoaded((()=>{this.contactUsLabel=salla.lang.get("blocks.footer.social");const t=(t,a,i)=>new Promise((s=>{salla.helpers.setNested(salla.lang.messages[t],a,i),s(!0)}));(async()=>{await t("ar.trans","common.uploader.drag_and_drop_files","اسحب الملفات وأفلتها هنا"),await t("en.trans","common.uploader.drag_and_drop_files","Drag and drop files here"),await t("ar.trans","common.uploader.allowed_images_types"," .jpg أو jpeg أو png يُسمح بإضافة صور بصيغة"),await t("en.trans","common.uploader.allowed_images_types","Images in jpg, jpeg, or png format are allowed."),await t("ar.trans","pages.rating.add_images","اضافة صور"),await t("en.trans","pages.rating.add_images","Add Images"),await t("ar.trans","pages.rating.edit_images","تعديل الصور"),await t("en.trans","pages.rating.edit_images","Edit Images"),await t("ar.trans","pages.rating.edit_review","تعديل التقييم"),await t("en.trans","pages.rating.edit_review","Edit review"),await t("ar.trans","pages.rating.confirm_deletion","تأكيد حذف التقييم"),await t("en.trans","pages.rating.confirm_deletion","Confirm review deletion"),await t("ar.trans","pages.rating.are_you_sure_you_want_to_delete_review","هل أنت متأكد من حذف تقييمك؟"),await t("en.trans","pages.rating.are_you_sure_you_want_to_delete_review","Are you sure you want to delete your review?"),await t("ar.trans","pages.rating.review_updated_successfully","تم تعديل التقييم بنجاح"),await t("en.trans","pages.rating.review_updated_successfully","The review has been successfully updated."),await t("ar.trans","pages.rating.review_deleted_successfully","تم حذف التقييم بنجاح"),await t("en.trans","pages.rating.review_deleted_successfully","The review has been successfully deleted."),await t("ar.trans","pages.rating.images_count","الصور ( :current من أصل :total )"),await t("en.trans","pages.rating.images_count","Images ( :current of :total )"),await t("ar.trans","pages.rating.loyalty_points_for_images","اكسب :points نقطة ولاء عند إضافة صور لتقييمك!"),await t("en.trans","pages.rating.loyalty_points_for_images","Earn :points loyalty points when adding photos to your review!"),await t("ar.trans","common.uploader.max_three_images",`.أضف ${this.MAX_UPLOAD_LIMIT} صور كحد أقصى`),await t("en.trans","common.uploader.max_three_images",`Add up to ${this.MAX_UPLOAD_LIMIT} images maximum.`),await t("ar.trans","common.elements.confirm_delete","تأكيد الحذف"),await t("en.trans","common.elements.confirm_delete","Confirm deletion"),this.dragAndDropFilesLabel=salla.lang.get("common.uploader.drag_and_drop_files"),this.allowedImagesTypesLabel=salla.lang.get("common.uploader.allowed_images_types"),this.addImagesLabel=salla.lang.get("pages.rating.add_images"),this.threeImagesMax=salla.lang.get("common.uploader.max_three_images"),this.contactSubjectLabel=salla.lang.get("pages.rating.contact_subject"),this.editReviewLabel=salla.lang.get("pages.rating.edit_review"),this.editImagesLabel=salla.lang.get("pages.rating.edit_images"),this.areYouSureLabel=salla.lang.get("pages.rating.are_you_sure_you_want_to_delete_review"),this.confirmDeletionLabel=salla.lang.get("pages.rating.confirm_deletion"),this.cancelLabel=salla.lang.get("common.elements.cancel"),this.updatedSuccessfullyLabel=salla.lang.get("pages.rating.review_updated_successfully"),this.deletedSuccessfullyLabel=salla.lang.get("pages.rating.review_deleted_successfully"),this.confirmDeleteBtn=salla.lang.get("common.elements.confirm_delete"),this.loyaltyPointsForImagesLabel=salla.lang.get("pages.rating.loyalty_points_for_images",{points:":points"}),this.contact_body=(t,a,i)=>salla.lang.get("pages.rating.contact_body",{store:t,id:a,customer:i})})()}))}getV2Ref(){return this.v2Ref??this.host.querySelector("salla-rating-modal-v2")}syncNewPopUpFlag(){this.enableNewPopUp=!!salla.config.get("store.features")?.includes("new_popup_rating")}async open(){return await salla.onReady(),this.syncNewPopUpFlag(),this.enableNewPopUp?this.getV2Ref()?.open():(this.defaultMode=!0,new Promise((t=>{setTimeout((()=>{this.modal.open().then((()=>this.order||salla.api.withoutNotifier((()=>salla.rating.api.order(this.orderId?this.orderId:salla.config.get("page.id")))).then((t=>this.order=t.data)))).then((()=>this.readyUpLoyaltyPoints())).then((()=>this.modal.setTitle(`${salla.lang.get("pages.rating.rate_order")} <span class="unicode">(#${this.order.id})</span>`))).then((()=>{const t={};if(this.order?.products)for(const a of this.order.products)t[a.product.id]=[];this.productImages=t})).then((()=>this.modal.stopLoading())).then((()=>this.stepsCount=[this.order.testimonials_enabled,this.order.products_enabled,this.order.shipping_enabled].filter((t=>t)).length)).then((()=>setTimeout((()=>this.handleWizard()),100))).catch((a=>{t(!1),this.hasError=!0,this.errorMessage=a.response?.data?.error?.message||a.response?.data,this.modal.stopLoading()})),t(!0)}),50)})))}async openEditModal(t){if(await salla.onReady(),this.syncNewPopUpFlag(),this.enableNewPopUp)return this.getV2Ref()?.openEditModal(t);this.defaultMode=!1,this.editMode=!0,this.editType=t.type,this.editFeedbackId=t.feedback_id;try{await this.fetchEditItem(t.feedback_id),await this.readyUpLoyaltyPoints(),this.editModal.open()}catch(t){this.hasError=!0,this.errorMessage=t.response?.data?.error?.message||t.response?.data}}async fetchEditItem(t){const a=`rating/${t}/show`,i=await salla.api.request(a);this.editItem=i.data,this.allowAttachImages&&"product"==this.editType&&this.editItem.images.length&&(this.editItemImages=this.editItem.images.map((t=>({id:t,url:t}))))}async editReview(){const t={};this.editModal.querySelectorAll("[name]").forEach((a=>{const i=salla.helpers.inputData(a.name,a.value,t);t[i.name]=i.value})),t.images&&(t.images=t.images.split(","));const a=`rating/${this.editFeedbackId}`;await salla.api.request(a,t,"put").then((t=>{this.editModal.close(),salla.notify.success(t.message||this.updatedSuccessfullyLabel),setTimeout((()=>{window.location.reload()}),500)}))}async openDeleteModal(t){return await salla.onReady(),this.syncNewPopUpFlag(),this.enableNewPopUp?this.getV2Ref()?.openDeleteModal(t):(this.defaultMode=!1,this.deleteMode=!0,this.deleteFeedbackId=t.feedback_id,this.shouldOpenDeleteModal=!0,new Promise((t=>{setTimeout((()=>{this.deleteModal.open().then((()=>t(!0)))}),50)})))}async deleteReview(){const t=`rating/${this.deleteFeedbackId}`;await salla.api.request(t,null,"delete").then((()=>{this.deleteModal.close(),salla.notify.success(this.deletedSuccessfullyLabel),setTimeout((()=>{window.location.reload()}),500)}))}async close(){return this.enableNewPopUp?this.getV2Ref()?.close():this.modal.close()}handleWizard(){this.steps=this.modal.querySelectorAll(".s-rating-modal-step"),this.dots=this.modal.querySelectorAll(".s-rating-modal-step-dot"),this.showActiveStep()}showActiveStep(t=null){this.currentTab=t||this.steps[this.currentIndex],g.toggleClassIf(".s-rating-modal-step-dot","s-rating-modal-bg-gray","s-rating-modal-bg-primary",(t=>t!=this.dots[this.currentIndex])).toggleClassIf(".s-rating-modal-step","s-rating-modal-active","s-rating-modal-hidden",(t=>t==this.currentTab)),0!==this.currentIndex&&(g.toggleElementClassIf(this.currentTab,"s-rating-modal-unactive","s-rating-modal-hidden",(()=>!0)),setTimeout((()=>g.toggleElementClassIf(this.currentTab,"s-rating-modal-active","s-rating-modal-unactive",(()=>!0))),300));const a=this.steps[this.currentIndex+1]?.dataset.type;this.nextBtn?.setText(a?`${salla.lang.get("pages.rating.rate")} ${salla.lang.get(`pages.rating.${a}`)}`:salla.lang.get("pages.rating.send_ratings")),setTimeout((()=>this.body?.setAttribute("style",`height:${this.currentTab?.offsetHeight}px`)))}previousTab(){this.currentIndex>0&&this.currentIndex--,g.toggleElementClassIf(this.backBtn,"s-rating-modal-unvisiable","block",(()=>0==this.currentIndex)),this.showActiveStep()}submit(){this.submittedBefore()||this.validate(),salla.config.canLeave=!1,this.nextBtn.load().then((()=>this.submittedBefore()||this.sendFeedback())).then((()=>this.currentTab.querySelectorAll("[name],.s-rating-modal-btn-star").forEach((t=>t.setAttribute("disabled",""))))).then((()=>this.currentIndex<this.stepsCount&&this.currentIndex++)).then((()=>this.showActiveStep())).then((()=>g.toggleClassIf("#prev-btn","block","s-rating-modal-unvisiable",(()=>!0)))).finally((()=>{this.nextBtn.stop(),salla.config.canLeave=!0,this.currentIndex==this.stepsCount&&(this.showThankYou(),this.showContactWidget=!1)}))}submittedBefore(){return this.submitted.includes(this.currentIndex)}validate(t=null,a=null){if(!t&&"products"===this.currentTab.dataset.type)return void this.currentTab.querySelectorAll(".rating-outer-form").forEach((t=>this.validate(t,"product")));const i=(t=t||this.currentTab).querySelector(".rating_hidden_input").value,s=t.querySelector(".s-rating-modal-validation-msg");if(a=a||t.dataset.type,!i)throw s.innerHTML=salla.lang.get(`pages.rating.rate_${a}_stars`).replace(" (:item)",""),new Error(s.innerHTML);s.innerHTML=""}sendFeedback(){const t={};if(this.currentTab.querySelectorAll("[name]").forEach((a=>{const i=salla.helpers.inputData(a.name,a.value,t);t[i.name]=i.value})),this.allowAttachImages&&t.products)for(let a in t.products)t.products[a].images&&(t.products[a].images=t.products[a].images.split(","));if(0!=Object.keys(t).length)return t.order_id=this.orderId,t.type=this.currentTab.dataset.type,salla.rating.api[this.currentTab.dataset.type](t).then((t=>(this.submitted.push(this.currentIndex),t)))}showThankYou(){let t=10,a=setInterval((()=>{this.thanksTime.innerHTML="00:0"+t--,t>0||(clearInterval(a),this.thanksTime.remove(),this.close().then((()=>window.location.reload())))}),1e3);this.modal.querySelector(".s-rating-modal-footer").classList.add("s-rating-modal-unvisiable"),this.showActiveStep(this.thanksTab)}getFilepondPlaceholder(){return`<div class="s-rating-modal-filepond-placeholder"><span class="s-rating-modal-filepond-placeholder-icon">${o}</span><p class="s-rating-modal-filepond-placeholder-text">${this.dragAndDropFilesLabel}<br>\n <span> ${this.allowedImagesTypesLabel} <br> ${this.threeImagesMax} </span></p></div>`}getCustomerName(){return`${salla.config.get("user.first_name")||salla.storage.get("user.first_name")||""} ${salla.config.get("user.last_name")||salla.storage.get("user.last_name")||""}`}handleSendEmail(){const t=`${this.contactSubjectLabel} #${this.order.id}`,a=this.contact_body(salla.config.get("store.name"),this.order.id,this.getCustomerName()),i=`mailto:${salla.config.get("store.contacts.email")}?subject=${encodeURIComponent(t)}&body=${encodeURIComponent(a)}`;window.open(i,"_blank")}handleSendWhatsApp(){const t=this.contact_body(salla.config.get("store.name"),this.order.id,this.getCustomerName()),a=`https://wa.me/${salla.config.get("store.contacts.whatsapp")}?text=${encodeURIComponent(t)}`;window.open(a,"_blank")}resetData(t){t.detail||(this.modal?.close(),this.editItem=null,this.editItemImages=[],this.hiddenInputs[1]&&(this.hiddenInputs[1].value=""),this.deleteFeedbackId=null,this.editFeedbackId=null,this.shouldOpenDeleteModal=!1,this.editMode=!1,this.deleteMode=!1,this.defaultMode=!1,this.loyaltyImageRatingPoints=0)}async readyUpLoyaltyPoints(){const t=salla.loyalty?.isFeatureEnabled?.();if(!t)return void(this.loyaltyImageRatingPoints=0);const a=salla.config.get("store.settings.rating.rating_product_points")||0,i=salla.config.get("store.settings.rating.rating_product_with_image_points")||0;this.loyaltyImageRatingPoints=Number(i)+Number(a)}loyaltyPointsNote(){if(!this.loyaltyImageRatingPoints||!this.loyaltyPointsForImagesLabel)return null;const t=a("svg",{width:"17",height:"17",viewBox:"0 0 17 17",fill:"none",xmlns:"http://www.w3.org/2000/svg"},a("path",{d:"M10 0C13.6819 0 16.6667 2.98477 16.6667 6.66664C16.6667 9.37047 15.057 11.6984 12.7437 12.7444C11.6978 15.0575 9.3701 16.6666 6.66668 16.6666C2.98477 16.6666 0 13.6819 0 9.99998C0 7.29656 1.60918 4.96894 3.92195 3.92276C4.96827 1.60964 7.29618 0 10 0ZM6.66668 5C3.90524 5 1.66667 7.23856 1.66667 9.99998C1.66667 12.7614 3.90524 15 6.66668 15C9.4281 15 11.6667 12.7614 11.6667 9.99998C11.6667 7.23856 9.4281 5 6.66668 5ZM7.50002 5.83333V6.66664H9.16668V8.33331H5.83333C5.60322 8.33331 5.41667 8.51989 5.41667 8.74998C5.41667 8.95456 5.56407 9.12464 5.75844 9.15998L5.83333 9.16664H7.50002C8.6506 9.16664 9.58335 10.0994 9.58335 11.25C9.58335 12.4006 8.6506 13.3333 7.50002 13.3333V14.1666H5.83333V13.3333H4.16667V11.6666H7.50002C7.7301 11.6666 7.91668 11.4801 7.91668 11.25C7.91668 11.0455 7.76927 10.8753 7.57493 10.8401L7.50002 10.8333H5.83333C4.68274 10.8333 3.75 9.90056 3.75 8.74998C3.75 7.59939 4.68274 6.66664 5.83333 6.66664V5.83333H7.50002ZM10 1.66667C8.51377 1.66667 7.17893 2.31513 6.26313 3.34457C6.39704 3.33736 6.53138 3.33333 6.66668 3.33333C10.3486 3.33333 13.3333 6.3181 13.3333 9.99998C13.3333 10.1356 13.3293 10.2702 13.3213 10.4037C14.3513 9.48814 15 8.15314 15 6.66664C15 3.90524 12.7614 1.66667 10 1.66667Z",fill:"#008C56"}));return a("div",{class:"s-rating-modal-loyalty-points-note-container"},a("span",{class:"s-rating-modal-loyalty-points-note-icon"},t),a("p",{class:"s-rating-modal-loyalty-points-note-text"},this.loyaltyPointsForImagesLabel.replace(":points",String(this.loyaltyImageRatingPoints))))}getDeleteModal(){return a("salla-modal",{ref:t=>this.deleteModal=t,width:"xs",onModalVisibilityChanged:t=>this.resetData(t)},a("div",{class:"s-rating-modal-delete-wrapper",ref:t=>this.body=t},a("h3",null,this.confirmDeletionLabel),a("p",null,this.areYouSureLabel),a("div",{class:"s-rating-modal-delete-actions"},a("salla-button",{loaderPosition:"center",onClick:()=>this.deleteReview()},this.confirmDeleteBtn),a("salla-button",{color:"danger",fill:"outline",onClick:()=>this.deleteModal.close()},this.cancelLabel))))}renderUploadedImagesCount(t){const i=this.editMode?this.editItemImages.length:(this.productImages[t]||[]).length;return a("span",{class:"s-rating-modal-upload-count"},salla.lang.choice("pages.rating.images_count",i,{current:i,total:this.MAX_UPLOAD_LIMIT}))}getEditModal(){return a("salla-modal",{ref:t=>this.editModal=t,width:"md",onModalVisibilityChanged:t=>this.resetData(t)},a("div",{class:"s-rating-modal-edit-wrapper",ref:t=>this.body=t},"store"===this.editType&&this.editItem?a("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step","data-type":"store",ref:t=>this.currentTab=t},a("div",{class:"s-rating-modal-rounded-icon"},a("img",{src:salla.config.get("store.logo","https://assets.salla.sa/cp/assets/images/logo-new.png"),alt:"store name",class:"s-rating-modal-store-logo"})),a("h2",{class:"s-rating-modal-title"},salla.lang.get("pages.rating.rate_the_store")),a("div",{class:"s-rating-modal-stars-company"},a("salla-rating-stars",{withLabel:!0,size:"large",editable:!0,value:this.editItem.stars})),a("textarea",{name:"content",value:this.editItem.content,class:"s-rating-modal-comment",placeholder:salla.lang.get("pages.rating.write_store_rate")}),a("small",{class:"s-rating-modal-validation-msg"})):null,"shipping"===this.editType&&this.editItem?a("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step","data-type":"shipping",ref:t=>this.currentTab=t},this.editItem.shipping.logo?a("div",{class:"s-rating-modal-rounded-icon"},a("img",{src:this.editItem.shipping.logo,class:"s-rating-modal-shipping-logo",alt:this.editItem.shipping.name})):a("span",{class:"s-rating-modal-icon",innerHTML:l}),a("div",{class:"s-rating-modal-title"}," ",`${salla.lang.get("pages.rating.rate_shipping")} ${this.editItem.shipping.name}`),a("div",{class:"s-rating-modal-stars-company"},a("salla-rating-stars",{withLabel:!0,size:"large",editable:!0,value:this.editItem.stars})),a("textarea",{name:"content",class:"s-rating-modal-comment",value:this.editItem.content,placeholder:salla.lang.get("pages.rating.write_shipping_rate")}),a("small",{class:"s-rating-modal-validation-msg"})):null,"product"==this.editType&&this.editItem?a("section",{class:"s-rating-modal-step","data-type":"products",ref:t=>this.currentTab=t},a("div",{class:"s-rating-modal-product"},this.allowAttachImages&&this.loyaltyPointsNote(),a("div",{class:"rating-outer-form","data-stars-error":salla.lang.get("pages.rating.rate_product_stars")},a("div",{class:"s-rating-modal-product-img-wrap"},a("img",{src:this.editItem.product.image.url,alt:this.editItem.product.name,class:"s-rating-modal-product-img"})),a("div",{class:"s-rating-modal-product-details"},a("div",{class:"s-rating-modal-product-details-main"},a("div",null,a("h3",{class:"s-rating-modal-product-title"}," ",this.editItem.product.name),a("div",{class:"s-rating-modal-stars-product"},a("salla-rating-stars",{withLabel:!0,size:"small",editable:!0,value:this.editItem.stars}))),this.allowAttachImages&&a("salla-button",{class:"s-comments-item-like-btn mt-0",loaderPosition:"center",fill:"outline",size:"small",onClick:()=>this.toggleUploader(1)},a("span",null,this.editItemImages.length?this.editImagesLabel:this.addImagesLabel),a("span",{innerHTML:o}))),a("textarea",{value:this.editItem.content,placeholder:salla.lang.get("pages.rating.write_product_rate"),name:"content",class:"s-rating-modal-comment"}),a("small",{class:"s-rating-modal-validation-msg"}))),this.allowAttachImages&&a("div",{class:"s-rating-modal-uploader is-closed",ref:t=>this.contentRefs[1]=t},a("salla-file-upload",{name:"images",allowMultiple:!0,maxFilesCount:this.MAX_UPLOAD_LIMIT,imagePreviewHeight:117,filePosterHeight:117,"instant-upload":!0,type:"feedback",files:JSON.stringify(this.editItemImages),payloadName:"files[]",id:`file-${this.editItem.product.id}`,title:this.editItem.product.name,instantUpload:!0,accept:"image/png, image/jpeg, image/jpg",url:salla.url.api("upload"),onUploaded:t=>{this.editItemImages=[...this.editItemImages,t.detail],this.hiddenInputs[1].value=this.editItemImages.map((t=>t.url)).join()},onRemoved:t=>{const a=t.detail;a&&(this.editItemImages=this.editItemImages.filter((t=>t.id!==a)),this.hiddenInputs[1].value=this.editItemImages.map((t=>t.url)).join())},labelIdle:this.getFilepondPlaceholder()}),a("input",{type:"hidden",name:"images",value:this.editItem.images.join(","),ref:t=>this.hiddenInputs[1]=t}),this.renderUploadedImagesCount(this.editItem.product.id)))):null,a("div",{class:"s-rating-modal-footer s-rating-modal-footer-end"},a("salla-button",{"loader-position":"center",onClick:()=>this.editReview()},this.editReviewLabel))))}render(){return this.enableNewPopUp?a(i,{class:"s-rating-modal"},a("salla-rating-modal-v2",{ref:t=>this.v2Ref=t,orderId:this.orderId})):this.deleteMode?a(i,{class:"s-rating-modal"},this.getDeleteModal()):this.editMode?a(i,{class:"s-rating-modal"},this.getEditModal()):this.defaultMode?a(i,{class:"s-rating-modal"},a("salla-modal",{class:"s-rating-modal-wrap",onModalVisibilityChanged:t=>this.resetData(t),isLoading:!0,width:"md",ref:t=>this.modal=t},a("div",{slot:"loading"},a("div",{class:"s-rating-modal-skeleton"},a("salla-skeleton",{type:"circle",height:"80px",width:"80px"}),a("salla-skeleton",{height:"15px",width:"60%"}),a("salla-skeleton",{height:"10px",width:"30%"}),a("div",{class:"s-rating-modal-skeleton-stars"},[...Array(5)].map((t=>a("div",{key:t,innerHTML:d})))),a("salla-skeleton",{height:"100px",width:"100%"}),a("div",{class:"s-rating-modal-skeleton-footer"},a("salla-skeleton",{height:"40px",width:"30%"})))),!this.hasError&&this.order?[a("div",{class:"s-rating-modal-wrapper",ref:t=>this.body=t},this.order?.testimonials_enabled?a("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"store"},a("div",{class:"s-rating-modal-rounded-icon"},a("img",{src:salla.config.get("store.logo","https://assets.salla.sa/cp/assets/images/logo-new.png"),alt:"store name",class:"s-rating-modal-store-logo"})),a("h2",{class:"s-rating-modal-title"},salla.lang.get("pages.rating.rate_the_store")),a("div",{class:"s-rating-modal-stars-company"},a("salla-rating-stars",{withLabel:!0,size:"large"})),a("textarea",{name:"comment",class:"s-rating-modal-comment",placeholder:salla.lang.get("pages.rating.write_store_rate")}),a("small",{class:"s-rating-modal-validation-msg"})):"",this.order.products_enabled?a("section",{class:"s-rating-modal-step s-rating-modal-hidden","data-type":"products"},this.allowAttachImages&&this.loyaltyPointsNote(),this.order.products.map(((t,i)=>a("div",{class:"s-rating-modal-product",key:i},a("div",{class:"rating-outer-form","data-stars-error":salla.lang.get("pages.rating.rate_product_stars")},a("div",{class:"s-rating-modal-product-img-wrap"},a("img",{src:t.product.thumbnail,alt:t.product.name,class:"s-rating-modal-product-img"})),a("div",{class:"s-rating-modal-product-details"},a("div",{class:"s-rating-modal-product-details-main"},a("div",null,a("h3",{class:"s-rating-modal-product-title"}," ",t.product.name),a("div",{class:"s-rating-modal-stars-product"},a("salla-rating-stars",{withLabel:!0,size:"small",name:`products[${i}][rating]`}))),this.allowAttachImages&&a("salla-button",{class:"s-comments-item-like-btn mt-0",loaderPosition:"center",fill:"outline",size:"small",onClick:()=>this.toggleUploader(i)},a("span",null,this.addImagesLabel),a("span",{innerHTML:o}))),a("input",{type:"hidden",name:`products[${i}][product_id]`,value:t.product.id}),a("textarea",{placeholder:salla.lang.get("pages.rating.write_product_rate"),name:`products[${i}][comment]`,class:"s-rating-modal-comment"}),a("small",{class:"s-rating-modal-validation-msg"}))),this.allowAttachImages&&a("div",{class:"s-rating-modal-uploader is-closed",ref:t=>this.contentRefs[i]=t},a("salla-file-upload",{name:"image",maxFilesCount:this.MAX_UPLOAD_LIMIT,imagePreviewHeight:117,"instant-upload":!0,type:"feedback",payloadName:"files[]",id:`file-${t.product.id}`,title:t.product.name,allowMultiple:!0,instantUpload:!0,accept:"image/png, image/jpeg, image/jpg",url:salla.url.api("upload"),onUploaded:a=>{this.productImages={...this.productImages,[t.product.id]:[...this.productImages[t.product.id]||[],a.detail]},this.hiddenInputs[i].value=this.productImages[t.product.id].map((t=>t.url)).join(",")},onRemoved:a=>{const s=a.detail;s&&this.productImages[t.product.id]&&(this.productImages={...this.productImages,[t.product.id]:this.productImages[t.product.id].filter((t=>t.id!==s))},this.hiddenInputs[i].value=this.productImages[t.product.id].map((t=>t.url)).join(","))},labelIdle:this.getFilepondPlaceholder()}),a("input",{type:"hidden",name:`products[${i}][images]`,value:(this.productImages[t.product.id]||[]).map((t=>t.url)).join(","),ref:t=>this.hiddenInputs[i]=t}),this.renderUploadedImagesCount(t.product.id)))))):"",this.order.shipping_enabled&&this.order.shipping?.company?a("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"shipping"},a("input",{type:"hidden",name:"shipping_company_id",value:this.order.shipping.company.id}),this.order.shipping.company.logo?a("div",{class:"s-rating-modal-rounded-icon"},a("img",{src:this.order.shipping.company.logo,class:"s-rating-modal-shipping-logo",alt:this.order.shipping.company.name})):a("span",{class:"s-rating-modal-icon",innerHTML:l}),a("div",{class:"s-rating-modal-title"}," ",`${salla.lang.get("pages.rating.rate_shipping")} ${this.order.shipping.company.name}`),a("div",{class:"s-rating-modal-stars-company"},a("salla-rating-stars",{withLabel:!0,size:"large"})),a("textarea",{name:"comment",class:"s-rating-modal-comment",placeholder:salla.lang.get("pages.rating.write_shipping_rate")}),a("small",{class:"s-rating-modal-validation-msg"})):"",a("div",{class:"s-rating-modal-thanks s-rating-modal-hidden",ref:t=>this.thanksTab=t},a("span",{class:"s-rating-modal-icon",innerHTML:r}),a("h3",{class:"s-rating-modal-thanks-title"},salla.lang.get("pages.rating.thanks")),a("div",{class:"s-rating-modal-thanks-msg",innerHTML:this.order.thanks_message}),a("time",{class:"s-rating-modal-thanks-time",ref:t=>this.thanksTime=t}))),this.allowContactSupport&&this.showContactWidget&&(salla.config.get("store.contacts.whatsapp")||salla.config.get("store.contacts.email"))?a("div",{class:"s-rating-modal-contact"},a("p",null,this.contactUsLabel),a("div",{class:"s-rating-modal-contact-icons"},salla.config.get("store.contacts.whatsapp")&&a("span",{onClick:()=>this.handleSendWhatsApp(),innerHTML:m}),salla.config.get("store.contacts.email")&&a("span",{onClick:()=>this.handleSendEmail(),innerHTML:n}))):"",a("div",{class:"s-rating-modal-footer"},a("button",{ref:t=>this.backBtn=t,onClick:()=>this.previousTab(),class:"s-rating-modal-btn s-rating-modal-unvisiable"},salla.lang.get("common.elements.back")),this.stepsCount>1?a("ul",{class:"s-rating-modal-dots"},[0,1,2].slice(0,this.stepsCount).map((t=>a("li",{key:t,class:"s-rating-modal-bg-gray s-rating-modal-step-dot"})))):"",a("salla-button",{"loader-position":"center",ref:t=>this.nextBtn=t,onClick:()=>this.submit()},salla.lang.get("common.elements.next")))]:a("salla-placeholder",{alignment:"center"}))):void 0}async componentWillLoad(){salla.event.on("rating::open",(()=>this.open())),salla.event.on("rating::edit",(t=>this.openEditModal(t))),salla.event.on("rating::delete",(t=>this.openDeleteModal(t))),await salla.onReady(),this.syncNewPopUpFlag()}componentDidLoad(){salla.event.dispatch("rating::ready",this)}get host(){return s(this)}};c.style='/*!twlt*/.s-rating-modal-uploader{overflow:visible}.s-rating-modal-uploader.is-opened{height:auto !important;opacity:1 !important;overflow:visible;pointer-events:auto !important;margin-bottom:1rem}.s-rating-modal-uploader .s-file-upload-gallery{overflow:visible}.s-rating-modal-edit-wrapper,.s-rating-modal-wrapper{transition:height 0.15s ease}.s-rating-modal-product-details{padding-bottom:0.5rem}.s-rating-modal-comment{margin-top:0.35rem}.s-rating-modal-product{margin-bottom:1rem}.s-rating-modal-product-img{position:absolute !important;inset:0;display:block;width:100% !important;max-width:100% !important;height:100% !important;object-fit:cover}.s-rating-modal-product-title{font-size:0.95rem;font-weight:600;line-height:1.5;margin:0}.s-rating-modal-stars-product{margin-top:0.5rem}.s-rating-modal-loyalty-points-note-container{display:flex;align-items:center;gap:0.625rem;width:100%;margin-top:1.5rem;margin-bottom:0.75rem;padding:0.75rem;border-radius:0.5rem;background-color:#E6F4EA}.s-rating-modal-loyalty-points-note-icon{display:flex;flex-shrink:0;align-items:center;justify-content:center;width:1.25rem;height:1.25rem;color:#1B7F5C}.s-rating-modal-loyalty-points-note-icon svg{width:1.5rem;height:1.5rem;fill:currentColor}.s-rating-modal-loyalty-points-note-text{flex:1;margin:0;font-size:0.875rem;line-height:1.25rem;color:#1f2937}.s-rating-modal-product-details-main{display:flex;align-items:center;margin-bottom:0.5rem;padding-bottom:0;border-bottom:0}.s-rating-modal-product-info-row{display:flex;align-items:center;gap:0.6rem;margin-bottom:0.5rem;padding-bottom:0;border-bottom:0}.s-rating-modal-product-main-review{width:100%;text-align:right}.s-rating-modal-product-rating-rows{display:grid;gap:0.45rem;margin:0.2rem 0 0.7rem}.s-rating-modal-product-rating-row{display:flex;align-items:center;justify-content:space-between;gap:0.75rem;min-height:2rem}.s-rating-modal-product-rating-row salla-rating-stars{flex-shrink:0}.s-rating-modal-product-rating-row .s-rating-stars-wrapper{align-items:center;min-height:1.75rem}.s-rating-modal-product-rating-row .s-rating-stars-label,.s-rating-modal-product-rating-row .s-rating-stars-label-without-tag{min-width:auto;min-height:1.25rem;line-height:1.25rem;font-size:0.8rem;color:#5b6470;white-space:nowrap;text-align:end;transition:opacity 0.15s ease}.s-rating-modal-product-rating-row .s-rating-stars-label--empty,.s-rating-modal-product-rating-row .s-rating-stars-label-without-tag--empty{opacity:0}.s-rating-modal-product-rating-row-main{margin-bottom:0.35rem;padding:0.5rem 0.6rem;border:1px solid #d1d5db;border-radius:0.45rem;background:transparent}.s-rating-modal-product-factor-name{color:#5b6470;font-size:0.9rem;line-height:1.25}.s-rating-modal-product-rating-row-main .s-rating-modal-product-factor-name{font-size:1rem;color:#5b6470}.s-rating-modal-product-factor-required{color:#f87171;margin-inline-start:0.2rem}.s-rating-modal-product-img-wrap{position:relative;width:5rem !important;min-width:5rem !important;max-width:5rem !important;height:3.5rem !important;flex-shrink:0 !important;overflow:hidden;border-radius:0.375rem;background:#f3f4f6}.mt-0{margin-top:0px}.block{display:block}.hidden{display:none}.px-3{padding-left:0.75rem;padding-right:0.75rem}.shadow{--tw-shadow:0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.outline{outline-style:solid}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.s-comments-item-like-btn{margin-top:0.5rem}.s-comments-item-like-btn .s-button-text{display:flex;flex-direction:row-reverse;gap:0.5rem}.s-comments-item-like-btn span svg{height:0.75rem;width:0.75rem}.s-rating-modal-wrapper{margin-bottom:1.5rem;transition-property:all;transition-duration:100ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}.s-rating-modal-edit-wrapper{margin-top:0.625rem}.s-rating-modal-footer{position:relative;display:flex;align-items:center;justify-content:space-between}.s-rating-modal-footer salla-button button{padding-left:1rem !important;padding-right:1rem !important;font-size:0.75rem !important}.s-rating-modal-btn{height:2.5rem;padding-left:1rem;padding-right:1rem;font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary);transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-rating-modal-btn:hover{color:var(--color-primary-dark)}.s-rating-modal-dots{display:flex;flex-shrink:0;flex-grow:1;justify-content:center}.s-rating-modal-dots>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(0.375rem * var(--tw-space-x-reverse));margin-left:calc(0.375rem * calc(1 - var(--tw-space-x-reverse)))}.s-rating-modal-dots{text-align:center}.s-rating-modal-dots:where([dir="rtl"],[dir="rtl"] *)>:not([hidden])~:not([hidden]){--tw-space-x-reverse:1}.s-rating-modal-step-dot{height:0.625rem;width:0.625rem;border-radius:9999px;transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-rating-modal-step{transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:500ms}.s-rating-modal-active{--tw-translate-x:0px;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));opacity:1}.s-rating-modal-unactive{--tw-translate-x:0.75rem;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));opacity:0}.s-rating-modal-hidden{display:none !important}.s-rating-modal-unvisiable{pointer-events:none;opacity:0}.s-rating-modal-step-wrap{position:relative;display:flex;flex-direction:column;align-items:center;padding-bottom:1rem}.s-rating-modal-product-details{position:relative;display:flex;flex:1 1 0%;flex-direction:column;padding-bottom:1rem}.s-rating-modal-product-details-main{display:flex;align-items:flex-start;justify-content:space-between}.s-rating-modal-product-details-main .s-rating-stars-wrapper{margin-bottom:0.375rem;flex-direction:column;align-items:center}@media (min-width: 640px){.s-rating-modal-product-details-main .s-rating-stars-wrapper{margin-bottom:0px;flex-direction:row;gap:0px}}.s-rating-modal-rounded-icon{margin-bottom:1rem;display:flex;height:7rem;width:7rem;align-items:center;justify-content:center;overflow:hidden;border-radius:9999px;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.s-rating-modal-title{margin-bottom:1rem;font-size:1.125rem;line-height:1.75rem;font-weight:700}.s-rating-modal-store-logo{width:4rem;object-fit:contain}.s-rating-modal-shipping-logo{height:100%;width:100%;object-fit:contain}.s-rating-modal-shipping-icon{font-size:3rem;line-height:1;color:var(--color-primary)}.s-rating-modal-comment{margin-bottom:0.5rem;height:5rem !important;width:100%;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));padding:0.75rem;font-size:0.875rem;line-height:1.25rem;transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms}.s-rating-modal-comment:focus{border-color:var(--color-primary)}.s-rating-modal-comment:is(.dark *){--tw-border-opacity:1;border-color:rgb(75 85 99 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(75 85 99 / var(--tw-bg-opacity, 1))}.s-rating-modal-validation-msg{margin-top:-3px;line-height:1rem;--tw-text-opacity:1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.s-rating-modal-product{margin-bottom:1.5rem}.s-rating-modal-product:last-child{margin-bottom:0px}.s-rating-modal-product .rating-outer-form{display:flex}.s-rating-modal-product .rating-outer-form>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(0.5rem * var(--tw-space-x-reverse));margin-left:calc(0.5rem * calc(1 - var(--tw-space-x-reverse)))}@media (min-width: 640px){.s-rating-modal-product .rating-outer-form>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(1.25rem * var(--tw-space-x-reverse));margin-left:calc(1.25rem * calc(1 - var(--tw-space-x-reverse)))}}.s-rating-modal-product .rating-outer-form:where([dir="rtl"],[dir="rtl"] *)>:not([hidden])~:not([hidden]){--tw-space-x-reverse:1}.s-rating-modal-product-img-wrap{height:3.5rem;width:auto;overflow:hidden;border-radius:0.375rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}@media (min-width: 640px){.s-rating-modal-product-img-wrap{width:5rem}}.s-rating-modal-product-img{position:relative;height:100%;width:100%;object-fit:cover;font-size:0px}.s-rating-modal-product-img::before{position:absolute;top:0px;left:0px;height:100%;width:100%;--tw-bg-opacity:1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1));--tw-content:\'\';content:var(--tw-content)}.s-rating-modal-product-title{margin-bottom:0.375rem;font-size:0.875rem;font-weight:700;line-height:1.25rem}.s-rating-modal-thanks{padding-left:2rem;padding-right:2rem;text-align:center;transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:500ms}.s-rating-modal-icon{display:inline-flex;height:5rem;width:5rem;align-items:center;justify-content:center;border-radius:9999px;--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));color:var(--color-primary)}.s-rating-modal-icon svg{height:1.75rem;width:1.75rem;fill:var(--color-primary)}.s-rating-modal-thanks-title{margin-top:1rem;font-weight:700}.s-rating-modal-thanks-msg{margin-bottom:1.5rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-rating-modal-thanks-btn{height:2.5rem;flex:none;display:inline-flex;flex:1 1 0%;align-items:center;justify-content:center;white-space:nowrap;border-radius:0.375rem;padding-left:1.5rem;padding-right:1.5rem;padding-bottom:0.625rem;padding-top:0.5rem;font-size:0.875rem;line-height:1.25rem;font-weight:700;transition-property:color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-rating-modal-thanks-btn:hover{opacity:0.8}.s-rating-modal-thanks-btn{border-width:1px;border-color:var(--color-primary);background-color:var(--color-primary);color:var(--color-primary-reverse)}.s-rating-modal-thanks-time{margin-top:0.75rem;display:block;height:1.5rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-rating-modal-stars-company{margin-bottom:1.25rem}.s-rating-modal-stars-company .s-rating-stars-wrapper{flex-direction:column;align-items:center;justify-content:center;gap:0.5rem}.s-rating-modal-stars-product{margin-bottom:0.25rem}.s-rating-modal-upload-count{font-size:0.875rem;line-height:1.25rem;font-weight:500}.s-rating-modal-bg-gray{--tw-bg-opacity:1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.s-rating-modal-bg-primary{background-color:var(--color-primary)}unicode{unicode-bidi:plaintext}.s-rating-modal-wrap .s-modal-body{position:relative !important}.s-rating-modal-skeleton{display:flex;flex-direction:column;align-items:center;justify-content:center}.s-rating-modal-skeleton salla-skeleton:nth-child(1){margin-bottom:1.25rem}.s-rating-modal-skeleton salla-skeleton:nth-child(2){margin-bottom:0.75rem}.s-rating-modal-skeleton salla-skeleton:nth-child(3){margin-bottom:1.25rem}.s-rating-modal-skeleton salla-skeleton:nth-child(4){margin-bottom:2rem}.s-rating-modal-skeleton-footer{margin-top:1.5rem;display:flex;width:100%;justify-content:flex-end}.s-rating-modal-skeleton-footer salla-skeleton{margin-bottom:0px !important}.s-rating-modal-skeleton-stars{margin-bottom:0.75rem;display:flex;align-items:center}.s-rating-modal-skeleton-stars>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(0.5rem * var(--tw-space-x-reverse));margin-left:calc(0.5rem * calc(1 - var(--tw-space-x-reverse)))}.s-rating-modal-skeleton-stars:where([dir="rtl"],[dir="rtl"] *)>:not([hidden])~:not([hidden]){--tw-space-x-reverse:1}.s-rating-modal-skeleton-stars div svg{width:25px;fill:currentColor;--tw-text-opacity:1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.s-rating-modal-uploader{height:0px;opacity:0;transition-property:all;transition-duration:100ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}.s-rating-modal-uploader.is-opened{margin-bottom:1.5rem;overflow:visible}.s-rating-modal-uploader.is-closed{pointer-events:none;z-index:0}.s-rating-modal-uploader .filepond--drop-label{--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.s-rating-modal-uploader .filepond--file-status .filepond--file-status-main{font-size:11px}.s-rating-modal-uploader .filepond--file-info-main{font-size:11px}.s-rating-modal-uploader li[data-filepond-item-state=\'load-invalid\'] .filepond--file-info{display:none}.s-rating-modal-filepond-placeholder-text{font-size:0.75rem !important;line-height:1rem !important}.s-rating-modal-filepond-placeholder{display:flex;flex-direction:column;align-items:center;justify-content:center}.s-rating-modal-filepond-placeholder-icon{margin-bottom:0.25rem}.s-rating-modal-filepond-placeholder-icon svg{height:1.5rem;width:1.5rem;fill:#7c8082}.s-rating-modal-contact{margin-bottom:1rem;display:flex;align-items:center;justify-content:space-between;border-radius:0.375rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));padding:0.5rem}.s-rating-modal-contact p{font-size:1rem;line-height:1.5rem;--tw-text-opacity:1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.s-rating-modal-contact-icons{display:flex;align-items:center;gap:0.5rem}.s-rating-modal-contact-icons span{display:flex;cursor:pointer;align-items:center;justify-content:center;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:0.375rem}.s-rating-modal-contact-icons span svg{height:1rem;width:1rem;fill:var(--color-primary)}.s-rating-modal-footer-end{justify-content:flex-end}.s-rating-modal-delete-wrapper{text-align:center}.s-rating-modal-delete-wrapper h3{margin-top:1.25rem;font-size:1.125rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.s-rating-modal-delete-wrapper p{margin-top:1.25rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-rating-modal-delete-actions{margin-top:1.25rem;display:flex;align-items:center;gap:0.625rem}.s-rating-modal-delete-actions salla-button{width:100%}.s-rating-modal-delete-actions salla-button button{width:100%}';export{c as salla_rating_modal}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as e,h as t,H as r}from"./p-5UtJVEzd.js";var i;!function(e){e.PERCENTAGE="percentage",e.FIXED="fixed"}(i||(i={}));const o={staticIcons:['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="40" height="40" color="#000000" fill="none">\n <path d="M13.7276 3.44418L15.4874 6.99288C15.7274 7.48687 16.3673 7.9607 16.9073 8.05143L20.0969 8.58575C22.1367 8.92853 22.6167 10.4206 21.1468 11.8925L18.6671 14.3927C18.2471 14.8161 18.0172 15.6327 18.1471 16.2175L18.8571 19.3125C19.417 21.7623 18.1271 22.71 15.9774 21.4296L12.9877 19.6452C12.4478 19.3226 11.5579 19.3226 11.0079 19.6452L8.01827 21.4296C5.8785 22.71 4.57865 21.7522 5.13859 19.3125L5.84851 16.2175C5.97849 15.6327 5.74852 14.8161 5.32856 14.3927L2.84884 11.8925C1.389 10.4206 1.85895 8.92853 3.89872 8.58575L7.08837 8.05143C7.61831 7.9607 8.25824 7.48687 8.49821 6.99288L10.258 3.44418C11.2179 1.51861 12.7777 1.51861 13.7276 3.44418Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>\n</svg>','<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" color="#000000" fill="none">\n <path d="M3 12C7.5 12 12 7.5 12 3C12 7.5 16.5 12 21 12C16.5 12 12 16.5 12 21C12 16.5 7.5 12 3 12Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"></path>\n <path d="M2 19.5C2.83333 19.5 4.5 17.8333 4.5 17C4.5 17.8333 6.16667 19.5 7 19.5C6.16667 19.5 4.5 21.1667 4.5 22C4.5 21.1667 2.83333 19.5 2 19.5Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"></path>\n <path d="M16 5C17 5 19 3 19 2C19 3 21 5 22 5C21 5 19 7 19 8C19 7 17 5 16 5Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"></path>\n</svg>','<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="40" height="40" color="#000000" fill="none">\n <path d="M14.2644 18.3717C14.5806 17.407 14.7387 16.9247 15.0616 16.593C15.215 16.4354 15.3932 16.3048 15.5887 16.2066C16.0003 16 16.5003 16 17.5002 16C18.5001 16 19.0001 16 19.4116 16.2066C19.6072 16.3048 19.7853 16.4354 19.9388 16.593C20.2617 16.9247 20.4198 17.407 20.736 18.3717L21.0624 19.3675C21.4561 20.5688 21.653 21.1694 21.3587 21.5847C21.0643 22 20.4418 22 19.1966 22H15.8038C14.5586 22 13.936 22 13.6417 21.5847C13.3473 21.1694 13.5442 20.5688 13.938 19.3675L14.2644 18.3717Z" stroke="currentColor" stroke-width="1.5"></path>\n <path d="M8.76421 10.3717C9.08041 9.40705 9.23851 8.92471 9.56143 8.59298C9.71485 8.43537 9.89299 8.3048 10.0885 8.20663C10.5001 8 11.0001 8 12 8C12.9999 8 13.4999 8 13.9115 8.20663C14.107 8.3048 14.2851 8.43537 14.4386 8.59298C14.7615 8.92471 14.9196 9.40705 15.2358 10.3717L15.5622 11.3675C15.956 12.5688 16.1528 13.1694 15.8585 13.5847C15.5642 14 14.9416 14 13.6964 14H10.3036C9.05842 14 8.43585 14 8.1415 13.5847C7.84716 13.1694 8.04404 12.5688 8.43779 11.3675L8.76421 10.3717Z" stroke="currentColor" stroke-width="1.5"></path>\n <path d="M3.26439 18.3717C3.58059 17.407 3.73869 16.9247 4.06162 16.593C4.21504 16.4354 4.39317 16.3048 4.58872 16.2066C5.00031 16 5.50027 16 6.50018 16C7.5001 16 8.00006 16 8.41165 16.2066C8.6072 16.3048 8.78533 16.4354 8.93875 16.593C9.26167 16.9247 9.41977 17.407 9.73597 18.3717L10.0624 19.3675C10.4561 20.5688 10.653 21.1694 10.3587 21.5847C10.0643 22 9.44176 22 8.19661 22H4.80375C3.5586 22 2.93603 22 2.64169 21.5847C2.34735 21.1694 2.54422 20.5688 2.93797 19.3675L3.26439 18.3717Z" stroke="currentColor" stroke-width="1.5"></path>\n <path d="M12 2V4M7.5 3.5L9 5M16.5 3.5L15 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path>\n</svg>','<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" color="#000000" fill="none">\n <path d="M5.78223 4.18192C6.43007 3.68319 6.754 3.43383 7.12788 3.27323C7.29741 3.20041 7.47367 3.14158 7.65459 3.09741C8.0536 3 8.4767 3 9.32289 3H14.6771C15.5233 3 15.9464 3 16.3454 3.09741C16.5263 3.14158 16.7026 3.20041 16.8721 3.27323C17.246 3.43383 17.5699 3.68319 18.2178 4.18192C20.3644 5.83448 21.4378 6.66077 21.8057 7.73078C21.9694 8.20673 22.0305 8.70728 21.9858 9.20461C21.8852 10.3227 21.0379 11.346 19.3433 13.3925L15.3498 18.2153C13.8126 20.0718 13.044 21 12 21C10.956 21 10.1874 20.0718 8.65018 18.2153L4.65671 13.3925C2.96208 11.346 2.11476 10.3227 2.0142 9.20461C1.96947 8.70728 2.03064 8.20673 2.1943 7.73078C2.56224 6.66077 3.63557 5.83448 5.78223 4.18192Z" stroke="currentColor" stroke-width="1.5"></path>\n <path d="M10 8.5H14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>\n</svg>'],staticColors:["#993018","#444444","#D18F36","#315F9C"]};class s{static findTierByIndex(e,t){return e.find((e=>e.index===t))||null}static findTierByName(e,t){return e.find((e=>e.tier_name===t))||null}static getTierNameByIndex(e,t){return this.findTierByIndex(e,t)?.tier_name}static findCurrentTierIndex(e,t){if(!t)return 0;for(let r=t.length-1;r>=0;r--)if(e>=t[r].threshold)return t[r].index;return 0}}const n=class{constructor(t){e(this,t),this.currentTierIndex=0,this.canRender=!1,this.isLoading=!1,this.handleTabClick=e=>{this.activeTabTier=e},salla.lang.onLoaded((()=>{this.loyaltyProgramText=salla.lang.get("blocks.tiered_offer.program_title"),this.currentTierText=salla.lang.get("blocks.tiered_offer.current_tier"),this.discountText=salla.lang.get("blocks.tiered_offer.discount"),this.benefitText=salla.lang.get("blocks.tiered_offer.tier_description")}))}async componentWillLoad(){try{if(await salla.onReady(),!this.checkFeatureEnabled())return;if(!this.checkCartExists())return;this.isLoading=!0;const e=await this.fetchTieredOfferData();if(!e)return;this.initializeComponent(e)}catch(e){this.canRender=!1,salla.logger.warn("salla-tiered-offer:: ",e)}finally{this.isLoading=!1}}checkFeatureEnabled(){return salla.config.get("store.features")?.includes("tiered-offer")}checkCartExists(){return!!salla.storage.get("cart")?.summary?.count}validateCouponCompatibility(e,t){return!(t&&!e.details?.applied_with_coupon)}shouldHideForGuest(){return salla.config.isGuest()}shouldHideUntilThreshold(e,t){return!(!e?.hide_until_threshold||0!==t)}resolveTierName(e,t){return s.getTierNameByIndex(e,t)||""}async fetchTieredOfferData(){try{const{data:e}=await salla.api.cart.offers(),t=e.find((e=>"tiered_offer"===e.type));return t?this.validateCouponCompatibility(t,salla.storage.get("cart")?.coupon)?t:(this.canRender=!1,null):null}catch(e){throw e}}initializeComponent(e){this.apiOfferData=e,this.tieredOfferData=this.mapApiDataToTiers(this.apiOfferData),this.loyaltyProgramText=this.apiOfferData.title||this.loyaltyProgramText;const t=this.findCurrentTierIndex(this.apiOfferData.details?.current_value||0);this.shouldHideForGuest()||this.shouldHideUntilThreshold(this.apiOfferData.details,t)?this.canRender=!1:(this.currentTierIndex=t,this.currentTier=this.resolveTierName(this.tieredOfferData.tiers,t),this.activeTabTier=this.currentTier||this.tieredOfferData.tiers[0]?.tier_name,this.canRender=!0)}componentDidLoad(){salla.event.on("cart::updated",(async e=>{const t=await this.fetchTieredOfferData();t&&(this.tieredOfferData?this.updateOfferValues(e,t):this.initializeComponent(t))}))}mapApiDataToTiers(e){const t=[...e.details.discounts].sort(((e,t)=>e.min_spend-t.min_spend)).map(((e,t)=>({name:e.name,tier_name:e.name,discount:e.type===i.PERCENTAGE?`${salla.helpers.number(e.value)}%`:salla.money(e.value),icon:o.staticIcons[t]||o.staticIcons[0],threshold:e.min_spend,text_color:o.staticColors[t],index:t+1})));return{current_tier:s.getTierNameByIndex(t,this.findCurrentTierIndex(e.details.current_value,t)),tiers:t}}findCurrentTierIndex(e,t=this.tieredOfferData?.tiers){return s.findCurrentTierIndex(e,t||[])}updateOfferValues(e,t){if(!t||!this.tieredOfferData)return;if(!t.details?.discounts?.length)return void(this.canRender=!1);if(!this.validateCouponCompatibility(t,e.coupon))return void(this.canRender=!1);if(this.shouldHideForGuest())return void(this.canRender=!1);const r=this.mapApiDataToTiers(t),i=this.findCurrentTierIndex(t.details?.current_value||0,r.tiers);if(this.shouldHideUntilThreshold(t.details,i))return void(this.canRender=!1);if(!1===t.details?.with_current_cart)return void(this.canRender=!0);this.apiOfferData=t,this.tieredOfferData=r,this.canRender=!0,this.currentTierIndex=i,this.currentTier=this.resolveTierName(r.tiers,i);const o=this.currentTier||r.tiers[0]?.tier_name;this.activeTabTier!==o&&(this.activeTabTier=o)}getLoadingSkeletonView(){return t(r,null,t("div",{class:"s-tiered-offer-container"},t("div",{class:"s-tiered-offer-skeleton-wrapper"},t("div",{class:"s-tiered-offer-skeleton-title"},t("salla-skeleton",{height:"16px",width:"40%"})),t("div",{class:"s-tiered-offer-skeleton-subtitle"},t("salla-skeleton",{height:"20px",width:"60%"})),t("div",{class:"s-tiered-offer-skeleton-progress"},t("salla-skeleton",{height:"16px",width:"100%"})),t("div",{class:"s-tiered-offer-skeleton-tabs"},t("salla-skeleton",{height:"50px",width:"100%"})))))}getCurrentTierData(){return s.findTierByIndex(this.tieredOfferData.tiers,this.currentTierIndex)||this.tieredOfferData.tiers[0]}getProgressWidth(){const e=this.tieredOfferData.tiers.length;return this.findCurrentTierIndex(this.apiOfferData.details?.current_value||0)/e*100}calculateMilestonePosition(e,t){return 1===t?"calc(100% - 18px)":`${Math.max(2,Math.min(95,(e+1)/t*100-8/t))}%`}getMilestoneStyles(e,t,r){const i="rtl"===document.documentElement.dir,o=this.calculateMilestonePosition(t,r),s=e.name.length>6?"flex-end":"center";return{[i?"right":"left"]:o,alignItems:s,position:"absolute",transform:i?"translateX(50%)":"translateX(-50%)"}}getMilestoneIconStyles(e,t,r){return t?{color:e.text_color}:r?{color:"var(--color-primary)"}:{}}renderProgressBarBackground(e){return[t("div",{class:"s-tiered-offer-progress-bg"}),t("div",{class:"s-tiered-offer-progress-fill",style:{width:`${e}%`}})]}renderMilestoneIcon(e,r,i){const o=["s-tiered-offer-milestone-icon",r?"s-tiered-offer-milestone-active":"",i?"s-tiered-offer-milestone-completed":""].filter(Boolean).join(" ");return t("div",{class:o,style:this.getMilestoneIconStyles(e,r,i)},t("span",{innerHTML:e.icon}))}renderMilestoneName(e,r){return t("div",{class:"s-tiered-offer-milestone-name"},r&&t("span",{style:{color:e.text_color}},e.name))}renderMilestones(e,r){return t("div",{class:"s-tiered-offer-milestones-wrapper"},t("div",{class:1===r?"s-tiered-offer-single-milestone-justify-end":"s-tiered-offer-milestones"},this.tieredOfferData.tiers.map(((i,o)=>{const s=e>=i.threshold,n=i.tier_name===this.currentTier;return t("div",{class:"s-tiered-offer-milestone",style:this.getMilestoneStyles(i,o,r)},this.renderMilestoneIcon(i,n,s),this.renderMilestoneName(i,n))}))))}renderProgressBar(){const e=this.getProgressWidth(),r=this.tieredOfferData.tiers.length,i=this.apiOfferData.details?.current_value||0;return t("div",{class:"s-tiered-offer-progress-container"},t("div",{class:"s-tiered-offer-progress-wrapper"},this.renderProgressBarBackground(e),this.renderMilestones(i,r)))}renderTabs(){return t("div",{class:"s-tiered-offer-tabs-container"},t("div",{class:"s-tiered-offer-tab-headers"},this.tieredOfferData.tiers.map((e=>t("button",{class:"s-tiered-offer-tab-header "+(e.tier_name===this.activeTabTier?"s-tiered-offer-tab-active":""),onClick:()=>this.handleTabClick(e.tier_name)},t("span",null,e.name))))),t("div",{class:"s-tiered-offer-tab-content-wrapper"},(()=>{const e=s.findTierByName(this.tieredOfferData.tiers,this.activeTabTier);return e?t("div",{class:"s-tiered-offer-tab-content"},t("div",{class:"s-tiered-offer-tab-content-inner"},t("div",{class:"s-tiered-offer-discount-section"},t("p",{class:"s-tiered-offer-discount-title"},this.discountText," ",t("span",{innerHTML:e.discount})),t("p",{class:"s-tiered-offer-benefit-description"},this.benefitText," ",e.name)))):null})()))}render(){if(this.isLoading)return this.getLoadingSkeletonView();if(!this.canRender||!this.tieredOfferData)return null;const e=this.getCurrentTierData();return t(r,null,t("div",{class:"s-tiered-offer-container"},t("div",{class:"s-tiered-offer-header"},t("div",{class:"s-tiered-offer-header-content"},t("p",{class:"s-tiered-offer-program-title"},this.loyaltyProgramText),this.currentTier&&t("div",{class:"s-tiered-offer-current-tier-name-wrapper"},t("h2",{class:"s-tiered-offer-current-tier"},this.currentTierText," ",t("span",{class:"s-tiered-offer-tier-name"},e.name)),t("span",{innerHTML:e.icon})))),this.renderProgressBar(),this.renderTabs()))}};n.style="/*!twlt*/.s-tiered-offer-milestone-icon svg{color:currentColor}.s-tiered-offer-milestone-icon svg path{stroke:currentColor;fill:none}.s-tiered-offer-milestone-icon.s-tiered-offer-milestone-active svg path,.s-tiered-offer-milestone-icon.s-tiered-offer-milestone-completed svg path{fill:currentColor;stroke:none}.s-tiered-offer-milestone-icon.s-tiered-offer-milestone-active svg[fill=none] path,.s-tiered-offer-milestone-icon.s-tiered-offer-milestone-completed svg[fill=none] path{fill:none;stroke:currentColor}[dir=rtl] .s-tiered-offer-progress-wrapper .s-tiered-offer-progress-bg{transform:scaleX(-1)}[dir=rtl] .s-tiered-offer-progress-wrapper .s-tiered-offer-progress-fill{transform:scaleX(-1);left:auto}[dir=rtl] .flip-x{transform:scaleX(-1)}.visible{visibility:visible}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.hidden{display:none}.transform{transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.s-tiered-offer-container{position:relative;margin-bottom:1.25rem;width:100%;border-radius:0.5rem;--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1rem;--tw-shadow:0 1px 2px 0 rgb(0 0 0 / 0.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}@media (min-width: 640px){.s-tiered-offer-container{padding:1.25rem;padding-left:1.5rem;padding-right:1.5rem}}.s-tiered-offer-header{margin-bottom:1.5rem;display:flex;align-items:center;gap:0.75rem}.s-tiered-offer-header-content{flex:1 1 0%}.s-tiered-offer-current-tier-name-wrapper{display:flex;flex-direction:row;align-items:flex-start;gap:0.375rem}.s-tiered-offer-current-tier-name-wrapper h2{font-size:1.125rem;line-height:1.75rem}.s-tiered-offer-current-tier-name-wrapper svg{height:1.5rem;width:1.5rem}.s-tiered-offer-program-title{margin:0px;margin-bottom:0.5rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-tiered-offer-program-title h2{font-size:1.125rem;line-height:1.75rem}.s-tiered-offer-current-tier{margin:0px;margin-bottom:0.375rem;font-weight:700}.s-tiered-offer-tier-name{font-weight:600;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-tiered-offer-progress-container{margin-top:1.5rem;margin-bottom:1rem}.s-tiered-offer-progress-wrapper{position:relative}.s-tiered-offer-progress-bg{position:absolute;top:0.5rem;left:1rem;right:1rem;height:1rem;border-radius:9999px;--tw-bg-opacity:1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.s-tiered-offer-progress-fill{position:absolute;top:0.5rem;height:1rem;border-radius:9999px;background-color:var(--color-primary);transition-property:all;transition-duration:500ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}.s-tiered-offer-milestones-wrapper{display:flex;justify-content:flex-end}.s-tiered-offer-milestones{position:relative;display:flex;height:3rem;width:100%;align-items:center;justify-content:space-between}.s-tiered-offer-single-milestone-justify-end{position:relative;display:flex;height:3rem;width:100%;align-items:center;justify-content:flex-end}.s-tiered-offer-milestone{display:flex;flex-direction:column;align-items:center}.s-tiered-offer-milestone-icon{position:relative;z-index:10;margin-top:0px;display:flex;height:2.25rem;width:2.25rem;align-items:center;justify-content:center;border-radius:0.75rem;border-width:2px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:0.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1));--tw-shadow:0 1px 2px 0 rgb(0 0 0 / 0.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-tiered-offer-milestone-icon span{display:flex;align-items:center;justify-content:center}.s-tiered-offer-milestone-icon svg{height:1.25rem;width:1.25rem;color:currentColor}.s-tiered-offer-milestone-name{margin-top:0.5rem;display:flex;height:1rem;align-items:center;justify-content:center}.s-tiered-offer-milestone-name span{text-align:center;font-size:0.875rem;line-height:1.25rem;font-weight:500}@media (min-width: 640px){.s-tiered-offer-milestone-name span{font-size:0.75rem;line-height:1rem}}.s-tiered-offer-tabs-container{margin-top:1rem}.s-tiered-offer-tab-headers{display:flex;gap:0.25rem;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:0.25rem}.s-tiered-offer-tab-header{display:flex;flex:1 1 0%;cursor:pointer;align-items:center;justify-content:center;border-radius:0.125rem;border-style:none;background-color:transparent;padding-top:0.625rem;padding-bottom:0.625rem;padding-left:0.75rem;padding-right:0.75rem;font-size:0.875rem;line-height:1.25rem;font-weight:500;--tw-text-opacity:1;color:rgb(75 85 99 / var(--tw-text-opacity, 1));transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:200ms}@media (min-width: 640px){.s-tiered-offer-tab-header{padding-top:0.5rem;padding-bottom:0.5rem;font-size:0.75rem;line-height:1rem}}.s-tiered-offer-tab-active{border-radius:0.375rem;background-color:var(--color-primary);--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity, 1));--tw-shadow:0 1px 2px 0 rgb(0 0 0 / 0.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.s-tiered-offer-tab-active:hover{background-color:var(--color-primary-dark);opacity:0.8}.s-tiered-offer-tab-content-wrapper{border-bottom-right-radius:0.375rem;border-bottom-left-radius:0.375rem;border-width:1px;border-top-width:0px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.s-tiered-offer-tab-content{padding-left:1.5rem;padding-right:1.5rem}@media (min-width: 640px){.s-tiered-offer-tab-content{padding-left:1rem;padding-right:1rem}}.s-tiered-offer-tab-content.tab-hidden{display:none}.s-tiered-offer-tab-content-inner{padding-top:1rem}.s-tiered-offer-discount-section{margin-bottom:0.5rem}.s-tiered-offer-discount-title{margin:0px;margin-bottom:0.5rem;font-size:1rem;line-height:1.5rem;font-weight:700;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-tiered-offer-benefit-description{margin:0px;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-tiered-offer-skeleton-wrapper{padding:1.25rem}.s-tiered-offer-skeleton-title{margin-bottom:0.75rem}.s-tiered-offer-skeleton-subtitle{margin-bottom:1.5rem}.s-tiered-offer-skeleton-progress{margin-bottom:1.25rem}";export{n as salla_tiered_offer}
4
+ import{r as e,h as t,H as r}from"./p-DaGqpYdk.js";var i;!function(e){e.PERCENTAGE="percentage",e.FIXED="fixed"}(i||(i={}));const o={staticIcons:['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="40" height="40" color="#000000" fill="none">\n <path d="M13.7276 3.44418L15.4874 6.99288C15.7274 7.48687 16.3673 7.9607 16.9073 8.05143L20.0969 8.58575C22.1367 8.92853 22.6167 10.4206 21.1468 11.8925L18.6671 14.3927C18.2471 14.8161 18.0172 15.6327 18.1471 16.2175L18.8571 19.3125C19.417 21.7623 18.1271 22.71 15.9774 21.4296L12.9877 19.6452C12.4478 19.3226 11.5579 19.3226 11.0079 19.6452L8.01827 21.4296C5.8785 22.71 4.57865 21.7522 5.13859 19.3125L5.84851 16.2175C5.97849 15.6327 5.74852 14.8161 5.32856 14.3927L2.84884 11.8925C1.389 10.4206 1.85895 8.92853 3.89872 8.58575L7.08837 8.05143C7.61831 7.9607 8.25824 7.48687 8.49821 6.99288L10.258 3.44418C11.2179 1.51861 12.7777 1.51861 13.7276 3.44418Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>\n</svg>','<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" color="#000000" fill="none">\n <path d="M3 12C7.5 12 12 7.5 12 3C12 7.5 16.5 12 21 12C16.5 12 12 16.5 12 21C12 16.5 7.5 12 3 12Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"></path>\n <path d="M2 19.5C2.83333 19.5 4.5 17.8333 4.5 17C4.5 17.8333 6.16667 19.5 7 19.5C6.16667 19.5 4.5 21.1667 4.5 22C4.5 21.1667 2.83333 19.5 2 19.5Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"></path>\n <path d="M16 5C17 5 19 3 19 2C19 3 21 5 22 5C21 5 19 7 19 8C19 7 17 5 16 5Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"></path>\n</svg>','<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="40" height="40" color="#000000" fill="none">\n <path d="M14.2644 18.3717C14.5806 17.407 14.7387 16.9247 15.0616 16.593C15.215 16.4354 15.3932 16.3048 15.5887 16.2066C16.0003 16 16.5003 16 17.5002 16C18.5001 16 19.0001 16 19.4116 16.2066C19.6072 16.3048 19.7853 16.4354 19.9388 16.593C20.2617 16.9247 20.4198 17.407 20.736 18.3717L21.0624 19.3675C21.4561 20.5688 21.653 21.1694 21.3587 21.5847C21.0643 22 20.4418 22 19.1966 22H15.8038C14.5586 22 13.936 22 13.6417 21.5847C13.3473 21.1694 13.5442 20.5688 13.938 19.3675L14.2644 18.3717Z" stroke="currentColor" stroke-width="1.5"></path>\n <path d="M8.76421 10.3717C9.08041 9.40705 9.23851 8.92471 9.56143 8.59298C9.71485 8.43537 9.89299 8.3048 10.0885 8.20663C10.5001 8 11.0001 8 12 8C12.9999 8 13.4999 8 13.9115 8.20663C14.107 8.3048 14.2851 8.43537 14.4386 8.59298C14.7615 8.92471 14.9196 9.40705 15.2358 10.3717L15.5622 11.3675C15.956 12.5688 16.1528 13.1694 15.8585 13.5847C15.5642 14 14.9416 14 13.6964 14H10.3036C9.05842 14 8.43585 14 8.1415 13.5847C7.84716 13.1694 8.04404 12.5688 8.43779 11.3675L8.76421 10.3717Z" stroke="currentColor" stroke-width="1.5"></path>\n <path d="M3.26439 18.3717C3.58059 17.407 3.73869 16.9247 4.06162 16.593C4.21504 16.4354 4.39317 16.3048 4.58872 16.2066C5.00031 16 5.50027 16 6.50018 16C7.5001 16 8.00006 16 8.41165 16.2066C8.6072 16.3048 8.78533 16.4354 8.93875 16.593C9.26167 16.9247 9.41977 17.407 9.73597 18.3717L10.0624 19.3675C10.4561 20.5688 10.653 21.1694 10.3587 21.5847C10.0643 22 9.44176 22 8.19661 22H4.80375C3.5586 22 2.93603 22 2.64169 21.5847C2.34735 21.1694 2.54422 20.5688 2.93797 19.3675L3.26439 18.3717Z" stroke="currentColor" stroke-width="1.5"></path>\n <path d="M12 2V4M7.5 3.5L9 5M16.5 3.5L15 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path>\n</svg>','<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" color="#000000" fill="none">\n <path d="M5.78223 4.18192C6.43007 3.68319 6.754 3.43383 7.12788 3.27323C7.29741 3.20041 7.47367 3.14158 7.65459 3.09741C8.0536 3 8.4767 3 9.32289 3H14.6771C15.5233 3 15.9464 3 16.3454 3.09741C16.5263 3.14158 16.7026 3.20041 16.8721 3.27323C17.246 3.43383 17.5699 3.68319 18.2178 4.18192C20.3644 5.83448 21.4378 6.66077 21.8057 7.73078C21.9694 8.20673 22.0305 8.70728 21.9858 9.20461C21.8852 10.3227 21.0379 11.346 19.3433 13.3925L15.3498 18.2153C13.8126 20.0718 13.044 21 12 21C10.956 21 10.1874 20.0718 8.65018 18.2153L4.65671 13.3925C2.96208 11.346 2.11476 10.3227 2.0142 9.20461C1.96947 8.70728 2.03064 8.20673 2.1943 7.73078C2.56224 6.66077 3.63557 5.83448 5.78223 4.18192Z" stroke="currentColor" stroke-width="1.5"></path>\n <path d="M10 8.5H14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>\n</svg>'],staticColors:["#993018","#444444","#D18F36","#315F9C"]};class s{static findTierByIndex(e,t){return e.find((e=>e.index===t))||null}static findTierByName(e,t){return e.find((e=>e.tier_name===t))||null}static getTierNameByIndex(e,t){return this.findTierByIndex(e,t)?.tier_name}static findCurrentTierIndex(e,t){if(!t)return 0;for(let r=t.length-1;r>=0;r--)if(e>=t[r].threshold)return t[r].index;return 0}}const n=class{constructor(t){e(this,t),this.currentTierIndex=0,this.canRender=!1,this.isLoading=!1,this.handleTabClick=e=>{this.activeTabTier=e},salla.lang.onLoaded((()=>{this.loyaltyProgramText=salla.lang.get("blocks.tiered_offer.program_title"),this.currentTierText=salla.lang.get("blocks.tiered_offer.current_tier"),this.discountText=salla.lang.get("blocks.tiered_offer.discount"),this.benefitText=salla.lang.get("blocks.tiered_offer.tier_description")}))}async componentWillLoad(){try{if(await salla.onReady(),!this.checkFeatureEnabled())return;if(!this.checkCartExists())return;this.isLoading=!0;const e=await this.fetchTieredOfferData();if(!e)return;this.initializeComponent(e)}catch(e){this.canRender=!1,salla.logger.warn("salla-tiered-offer:: ",e)}finally{this.isLoading=!1}}checkFeatureEnabled(){return salla.config.get("store.features")?.includes("tiered-offer")}checkCartExists(){return!!salla.storage.get("cart")?.summary?.count}validateCouponCompatibility(e,t){return!(t&&!e.details?.applied_with_coupon)}shouldHideForGuest(){return salla.config.isGuest()}shouldHideUntilThreshold(e,t){return!(!e?.hide_until_threshold||0!==t)}resolveTierName(e,t){return s.getTierNameByIndex(e,t)||""}async fetchTieredOfferData(){try{const{data:e}=await salla.api.cart.offers(),t=e.find((e=>"tiered_offer"===e.type));return t?this.validateCouponCompatibility(t,salla.storage.get("cart")?.coupon)?t:(this.canRender=!1,null):null}catch(e){throw e}}initializeComponent(e){this.apiOfferData=e,this.tieredOfferData=this.mapApiDataToTiers(this.apiOfferData),this.loyaltyProgramText=this.apiOfferData.title||this.loyaltyProgramText;const t=this.findCurrentTierIndex(this.apiOfferData.details?.current_value||0);this.shouldHideForGuest()||this.shouldHideUntilThreshold(this.apiOfferData.details,t)?this.canRender=!1:(this.currentTierIndex=t,this.currentTier=this.resolveTierName(this.tieredOfferData.tiers,t),this.activeTabTier=this.currentTier||this.tieredOfferData.tiers[0]?.tier_name,this.canRender=!0)}componentDidLoad(){salla.event.on("cart::updated",(async e=>{const t=await this.fetchTieredOfferData();t&&(this.tieredOfferData?this.updateOfferValues(e,t):this.initializeComponent(t))}))}mapApiDataToTiers(e){const t=[...e.details.discounts].sort(((e,t)=>e.min_spend-t.min_spend)).map(((e,t)=>({name:e.name,tier_name:e.name,discount:e.type===i.PERCENTAGE?`${salla.helpers.number(e.value)}%`:salla.money(e.value),icon:o.staticIcons[t]||o.staticIcons[0],threshold:e.min_spend,text_color:o.staticColors[t],index:t+1})));return{current_tier:s.getTierNameByIndex(t,this.findCurrentTierIndex(e.details.current_value,t)),tiers:t}}findCurrentTierIndex(e,t=this.tieredOfferData?.tiers){return s.findCurrentTierIndex(e,t||[])}updateOfferValues(e,t){if(!t||!this.tieredOfferData)return;if(!t.details?.discounts?.length)return void(this.canRender=!1);if(!this.validateCouponCompatibility(t,e.coupon))return void(this.canRender=!1);if(this.shouldHideForGuest())return void(this.canRender=!1);const r=this.mapApiDataToTiers(t),i=this.findCurrentTierIndex(t.details?.current_value||0,r.tiers);if(this.shouldHideUntilThreshold(t.details,i))return void(this.canRender=!1);if(!1===t.details?.with_current_cart)return void(this.canRender=!0);this.apiOfferData=t,this.tieredOfferData=r,this.canRender=!0,this.currentTierIndex=i,this.currentTier=this.resolveTierName(r.tiers,i);const o=this.currentTier||r.tiers[0]?.tier_name;this.activeTabTier!==o&&(this.activeTabTier=o)}getLoadingSkeletonView(){return t(r,null,t("div",{class:"s-tiered-offer-container"},t("div",{class:"s-tiered-offer-skeleton-wrapper"},t("div",{class:"s-tiered-offer-skeleton-title"},t("salla-skeleton",{height:"16px",width:"40%"})),t("div",{class:"s-tiered-offer-skeleton-subtitle"},t("salla-skeleton",{height:"20px",width:"60%"})),t("div",{class:"s-tiered-offer-skeleton-progress"},t("salla-skeleton",{height:"16px",width:"100%"})),t("div",{class:"s-tiered-offer-skeleton-tabs"},t("salla-skeleton",{height:"50px",width:"100%"})))))}getCurrentTierData(){return s.findTierByIndex(this.tieredOfferData.tiers,this.currentTierIndex)||this.tieredOfferData.tiers[0]}getProgressWidth(){const e=this.tieredOfferData.tiers.length;return this.findCurrentTierIndex(this.apiOfferData.details?.current_value||0)/e*100}calculateMilestonePosition(e,t){return 1===t?"calc(100% - 18px)":`${Math.max(2,Math.min(95,(e+1)/t*100-8/t))}%`}getMilestoneStyles(e,t,r){const i="rtl"===document.documentElement.dir,o=this.calculateMilestonePosition(t,r),s=e.name.length>6?"flex-end":"center";return{[i?"right":"left"]:o,alignItems:s,position:"absolute",transform:i?"translateX(50%)":"translateX(-50%)"}}getMilestoneIconStyles(e,t,r){return t?{color:e.text_color}:r?{color:"var(--color-primary)"}:{}}renderProgressBarBackground(e){return[t("div",{class:"s-tiered-offer-progress-bg"}),t("div",{class:"s-tiered-offer-progress-fill",style:{width:`${e}%`}})]}renderMilestoneIcon(e,r,i){const o=["s-tiered-offer-milestone-icon",r?"s-tiered-offer-milestone-active":"",i?"s-tiered-offer-milestone-completed":""].filter(Boolean).join(" ");return t("div",{class:o,style:this.getMilestoneIconStyles(e,r,i)},t("span",{innerHTML:e.icon}))}renderMilestoneName(e,r){return t("div",{class:"s-tiered-offer-milestone-name"},r&&t("span",{style:{color:e.text_color}},e.name))}renderMilestones(e,r){return t("div",{class:"s-tiered-offer-milestones-wrapper"},t("div",{class:1===r?"s-tiered-offer-single-milestone-justify-end":"s-tiered-offer-milestones"},this.tieredOfferData.tiers.map(((i,o)=>{const s=e>=i.threshold,n=i.tier_name===this.currentTier;return t("div",{class:"s-tiered-offer-milestone",style:this.getMilestoneStyles(i,o,r)},this.renderMilestoneIcon(i,n,s),this.renderMilestoneName(i,n))}))))}renderProgressBar(){const e=this.getProgressWidth(),r=this.tieredOfferData.tiers.length,i=this.apiOfferData.details?.current_value||0;return t("div",{class:"s-tiered-offer-progress-container"},t("div",{class:"s-tiered-offer-progress-wrapper"},this.renderProgressBarBackground(e),this.renderMilestones(i,r)))}renderTabs(){return t("div",{class:"s-tiered-offer-tabs-container"},t("div",{class:"s-tiered-offer-tab-headers"},this.tieredOfferData.tiers.map((e=>t("button",{class:"s-tiered-offer-tab-header "+(e.tier_name===this.activeTabTier?"s-tiered-offer-tab-active":""),onClick:()=>this.handleTabClick(e.tier_name)},t("span",null,e.name))))),t("div",{class:"s-tiered-offer-tab-content-wrapper"},(()=>{const e=s.findTierByName(this.tieredOfferData.tiers,this.activeTabTier);return e?t("div",{class:"s-tiered-offer-tab-content"},t("div",{class:"s-tiered-offer-tab-content-inner"},t("div",{class:"s-tiered-offer-discount-section"},t("p",{class:"s-tiered-offer-discount-title"},this.discountText," ",t("span",{innerHTML:e.discount})),t("p",{class:"s-tiered-offer-benefit-description"},this.benefitText," ",e.name)))):null})()))}render(){if(this.isLoading)return this.getLoadingSkeletonView();if(!this.canRender||!this.tieredOfferData)return null;const e=this.getCurrentTierData();return t(r,null,t("div",{class:"s-tiered-offer-container"},t("div",{class:"s-tiered-offer-header"},t("div",{class:"s-tiered-offer-header-content"},t("p",{class:"s-tiered-offer-program-title"},this.loyaltyProgramText),this.currentTier&&t("div",{class:"s-tiered-offer-current-tier-name-wrapper"},t("h2",{class:"s-tiered-offer-current-tier"},this.currentTierText," ",t("span",{class:"s-tiered-offer-tier-name"},e.name)),t("span",{innerHTML:e.icon})))),this.renderProgressBar(),this.renderTabs()))}};n.style="/*!twlt*/.s-tiered-offer-milestone-icon svg{color:currentColor}.s-tiered-offer-milestone-icon svg path{stroke:currentColor;fill:none}.s-tiered-offer-milestone-icon.s-tiered-offer-milestone-active svg path,.s-tiered-offer-milestone-icon.s-tiered-offer-milestone-completed svg path{fill:currentColor;stroke:none}.s-tiered-offer-milestone-icon.s-tiered-offer-milestone-active svg[fill=none] path,.s-tiered-offer-milestone-icon.s-tiered-offer-milestone-completed svg[fill=none] path{fill:none;stroke:currentColor}[dir=rtl] .s-tiered-offer-progress-wrapper .s-tiered-offer-progress-bg{transform:scaleX(-1)}[dir=rtl] .s-tiered-offer-progress-wrapper .s-tiered-offer-progress-fill{transform:scaleX(-1);left:auto}[dir=rtl] .flip-x{transform:scaleX(-1)}.visible{visibility:visible}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.hidden{display:none}.transform{transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.s-tiered-offer-container{position:relative;margin-bottom:1.25rem;width:100%;border-radius:0.5rem;--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1rem;--tw-shadow:0 1px 2px 0 rgb(0 0 0 / 0.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}@media (min-width: 640px){.s-tiered-offer-container{padding:1.25rem;padding-left:1.5rem;padding-right:1.5rem}}.s-tiered-offer-header{margin-bottom:1.5rem;display:flex;align-items:center;gap:0.75rem}.s-tiered-offer-header-content{flex:1 1 0%}.s-tiered-offer-current-tier-name-wrapper{display:flex;flex-direction:row;align-items:flex-start;gap:0.375rem}.s-tiered-offer-current-tier-name-wrapper h2{font-size:1.125rem;line-height:1.75rem}.s-tiered-offer-current-tier-name-wrapper svg{height:1.5rem;width:1.5rem}.s-tiered-offer-program-title{margin:0px;margin-bottom:0.5rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-tiered-offer-program-title h2{font-size:1.125rem;line-height:1.75rem}.s-tiered-offer-current-tier{margin:0px;margin-bottom:0.375rem;font-weight:700}.s-tiered-offer-tier-name{font-weight:600;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-tiered-offer-progress-container{margin-top:1.5rem;margin-bottom:1rem}.s-tiered-offer-progress-wrapper{position:relative}.s-tiered-offer-progress-bg{position:absolute;top:0.5rem;left:1rem;right:1rem;height:1rem;border-radius:9999px;--tw-bg-opacity:1;background-color:rgb(229 231 235 / var(--tw-bg-opacity, 1))}.s-tiered-offer-progress-fill{position:absolute;top:0.5rem;height:1rem;border-radius:9999px;background-color:var(--color-primary);transition-property:all;transition-duration:500ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}.s-tiered-offer-milestones-wrapper{display:flex;justify-content:flex-end}.s-tiered-offer-milestones{position:relative;display:flex;height:3rem;width:100%;align-items:center;justify-content:space-between}.s-tiered-offer-single-milestone-justify-end{position:relative;display:flex;height:3rem;width:100%;align-items:center;justify-content:flex-end}.s-tiered-offer-milestone{display:flex;flex-direction:column;align-items:center}.s-tiered-offer-milestone-icon{position:relative;z-index:10;margin-top:0px;display:flex;height:2.25rem;width:2.25rem;align-items:center;justify-content:center;border-radius:0.75rem;border-width:2px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:0.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1));--tw-shadow:0 1px 2px 0 rgb(0 0 0 / 0.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-tiered-offer-milestone-icon span{display:flex;align-items:center;justify-content:center}.s-tiered-offer-milestone-icon svg{height:1.25rem;width:1.25rem;color:currentColor}.s-tiered-offer-milestone-name{margin-top:0.5rem;display:flex;height:1rem;align-items:center;justify-content:center}.s-tiered-offer-milestone-name span{text-align:center;font-size:0.875rem;line-height:1.25rem;font-weight:500}@media (min-width: 640px){.s-tiered-offer-milestone-name span{font-size:0.75rem;line-height:1rem}}.s-tiered-offer-tabs-container{margin-top:1rem}.s-tiered-offer-tab-headers{display:flex;gap:0.25rem;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:0.25rem}.s-tiered-offer-tab-header{display:flex;flex:1 1 0%;cursor:pointer;align-items:center;justify-content:center;border-radius:0.125rem;border-style:none;background-color:transparent;padding-top:0.625rem;padding-bottom:0.625rem;padding-left:0.75rem;padding-right:0.75rem;font-size:0.875rem;line-height:1.25rem;font-weight:500;--tw-text-opacity:1;color:rgb(75 85 99 / var(--tw-text-opacity, 1));transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:200ms}@media (min-width: 640px){.s-tiered-offer-tab-header{padding-top:0.5rem;padding-bottom:0.5rem;font-size:0.75rem;line-height:1rem}}.s-tiered-offer-tab-active{border-radius:0.375rem;background-color:var(--color-primary);--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity, 1));--tw-shadow:0 1px 2px 0 rgb(0 0 0 / 0.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.s-tiered-offer-tab-active:hover{background-color:var(--color-primary-dark);opacity:0.8}.s-tiered-offer-tab-content-wrapper{border-bottom-right-radius:0.375rem;border-bottom-left-radius:0.375rem;border-width:1px;border-top-width:0px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.s-tiered-offer-tab-content{padding-left:1.5rem;padding-right:1.5rem}@media (min-width: 640px){.s-tiered-offer-tab-content{padding-left:1rem;padding-right:1rem}}.s-tiered-offer-tab-content.tab-hidden{display:none}.s-tiered-offer-tab-content-inner{padding-top:1rem}.s-tiered-offer-discount-section{margin-bottom:0.5rem}.s-tiered-offer-discount-title{margin:0px;margin-bottom:0.5rem;font-size:1rem;line-height:1.5rem;font-weight:700;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-tiered-offer-benefit-description{margin:0px;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-tiered-offer-skeleton-wrapper{padding:1.25rem}.s-tiered-offer-skeleton-title{margin-bottom:0.75rem}.s-tiered-offer-skeleton-subtitle{margin-bottom:1.5rem}.s-tiered-offer-skeleton-progress{margin-bottom:1.25rem}";export{n as salla_tiered_offer}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r,h as t,H as a}from"./p-5UtJVEzd.js";const o=class{constructor(t){r(this,t)}handleOrderChange(r){r?this.setSummaryFromProp(r):this.summary=void 0}async componentWillLoad(){await Salla.onReady(),this.order&&this.setSummaryFromProp(this.order)}setSummaryFromProp(r){try{const t="string"==typeof r?JSON.parse(r):r;this.summary=t}catch(r){salla.logger.error("Failed to parse order summary data",r),this.summary=void 0}}renderTotalRow(r,a,o,s,e){return t("div",{class:"s-order-totals-card-row"},t("div",{class:"s-order-totals-card-row-inner"},t("dt",{class:o||"s-order-totals-card-label"},r),t("dd",{class:s||"s-order-totals-card-value"},t(e?"b":"span",{innerHTML:salla.money(a)}))))}renderDiscountRow(){return this.summary?.discounts?.map((r=>t("div",{class:"s-order-totals-card-row",key:r.name},t("div",{class:"s-order-totals-card-row-inner"},t("dt",{class:"s-order-totals-card-discount"},r.name),t("dd",{class:"s-order-totals-card-value"},r.discount)))))}renderRefundRow(r){return t("div",{class:"s-order-totals-card-row"},t("div",{class:"s-order-totals-card-row-inner"},t("dt",{class:"s-order-totals-card-refund-label"},t("span",{class:"s-order-totals-card-refund-icon"},t("i",{class:"sicon-info"})),t("span",null," ",salla.lang.get("pages.orders.refund_amount"))),t("dd",{class:"s-order-totals-card-refund-value"},t("b",{innerHTML:salla.money(r)}))))}render(){if(!this.summary)return t(a,{class:"s-order-totals-card-wrapper"});const{summary:r}=this,o=!!Array.isArray(r.options)&&r.options.length>0;return t(a,{class:"s-order-totals-card-wrapper"},t("div",{class:"s-order-totals-card-panel"},t("h2",{id:"summary-heading",class:"s-order-totals-card-heading"},salla.lang.get("pages.orders.summary")),t("div",{class:"s-order-totals-card-flow"},t("dl",{class:"s-order-totals-card-list"},this.renderTotalRow(salla.lang.get("pages.cart.items_total"),r.sub_total),o&&this.renderTotalRow(salla.lang.get("pages.cart.order_options_total"),r.options_total),r.discounts&&this.renderDiscountRow(),r.cod_cost&&this.renderTotalRow(salla.lang.get("pages.orders.cod_cost"),r.cod_cost,""),r.shipping_cost&&this.renderTotalRow(salla.lang.get("pages.orders.shipping_cost"),r.shipping_cost,"s-order-totals-card-shipping"),r.tax&&this.renderTotalRow(`${salla.lang.get("pages.cart.tax")} ${r.tax.percent}%`,r.tax.amount,""),r.paid_amount?this.renderTotalRow(salla.lang.get("pages.orders.partially_paid"),r.paid_amount,""):null,r.remaining_amount?this.renderTotalRow(salla.lang.get("pages.orders.remaining_amount"),r.remaining_amount,""):null,t("div",{class:"s-order-totals-card-total"},this.renderTotalRow(salla.lang.get("pages.orders.final_total"),r.total,"s-order-totals-card-total-label","s-order-totals-card-total-value",!0)),r.refund_amount?t("div",{class:"s-order-totals-card-refund"},this.renderRefundRow(r.refund_amount)):null))))}static get watchers(){return{order:["handleOrderChange"]}}};o.style='/*!twlt*/:host{display:block}.s-order-totals-card-wrapper{display:block}.s-order-totals-card-panel{border-radius:0.375rem;--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding-left:1.5rem;padding-right:1.5rem}.s-order-totals-card-heading{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}.s-order-totals-card-flow{display:flow-root}.s-order-totals-card-list{font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-totals-card-list>.s-order-totals-card-row{border-bottom-width:1px}.s-order-totals-card-list>.s-order-totals-card-row:last-child{border-bottom-width:0px}.s-order-totals-card-row{display:block}.s-order-totals-card-row-inner{display:flex;align-items:center;justify-content:space-between;gap:1rem;padding-top:1.25rem;padding-bottom:1.25rem}.s-order-totals-card-label{--tw-text-opacity:1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.s-order-totals-card-value{font-weight:500}.s-order-totals-card-discount{--tw-text-opacity:1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.s-order-totals-card-tax-value{font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-totals-card-total{margin-left:-1.5rem;margin-right:-1.5rem;border-radius:0.375rem;background-color:var(--color-border);padding-left:1.5rem;padding-right:1.5rem}.s-order-totals-card-total-label{font-size:1rem;line-height:1.5rem;font-weight:500}.s-order-totals-card-total-value{font-size:1rem;line-height:1.5rem;font-weight:500}.s-order-totals-card-refund{margin-left:-1.5rem;margin-right:-1.5rem;border-left-width:4px;--tw-border-opacity:1;border-color:rgb(254 202 202 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1));padding-left:1.5rem;padding-right:1.5rem}.s-order-totals-card-refund:where([dir="rtl"],[dir="rtl"] *){border-left-width:0px;border-right-width:4px}.s-order-totals-card-refund-label{display:flex;align-items:center;gap:0.5rem;--tw-text-opacity:1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.s-order-totals-card-refund-icon{font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.s-order-totals-card-refund-value{font-weight:500;--tw-text-opacity:1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}';export{o as salla_order_totals_card}
4
+ import{r,h as t,H as a}from"./p-DaGqpYdk.js";const o=class{constructor(t){r(this,t)}handleOrderChange(r){r?this.setSummaryFromProp(r):this.summary=void 0}async componentWillLoad(){await Salla.onReady(),this.order&&this.setSummaryFromProp(this.order)}setSummaryFromProp(r){try{const t="string"==typeof r?JSON.parse(r):r;this.summary=t}catch(r){salla.logger.error("Failed to parse order summary data",r),this.summary=void 0}}renderTotalRow(r,a,o,s,e){return t("div",{class:"s-order-totals-card-row"},t("div",{class:"s-order-totals-card-row-inner"},t("dt",{class:o||"s-order-totals-card-label"},r),t("dd",{class:s||"s-order-totals-card-value"},t(e?"b":"span",{innerHTML:salla.money(a)}))))}renderDiscountRow(){return this.summary?.discounts?.map((r=>t("div",{class:"s-order-totals-card-row",key:r.name},t("div",{class:"s-order-totals-card-row-inner"},t("dt",{class:"s-order-totals-card-discount"},r.name),t("dd",{class:"s-order-totals-card-value"},r.discount)))))}renderRefundRow(r){return t("div",{class:"s-order-totals-card-row"},t("div",{class:"s-order-totals-card-row-inner"},t("dt",{class:"s-order-totals-card-refund-label"},t("span",{class:"s-order-totals-card-refund-icon"},t("i",{class:"sicon-info"})),t("span",null," ",salla.lang.get("pages.orders.refund_amount"))),t("dd",{class:"s-order-totals-card-refund-value"},t("b",{innerHTML:salla.money(r)}))))}render(){if(!this.summary)return t(a,{class:"s-order-totals-card-wrapper"});const{summary:r}=this,o=!!Array.isArray(r.options)&&r.options.length>0;return t(a,{class:"s-order-totals-card-wrapper"},t("div",{class:"s-order-totals-card-panel"},t("h2",{id:"summary-heading",class:"s-order-totals-card-heading"},salla.lang.get("pages.orders.summary")),t("div",{class:"s-order-totals-card-flow"},t("dl",{class:"s-order-totals-card-list"},this.renderTotalRow(salla.lang.get("pages.cart.items_total"),r.sub_total),o&&this.renderTotalRow(salla.lang.get("pages.cart.order_options_total"),r.options_total),r.discounts&&this.renderDiscountRow(),r.cod_cost&&this.renderTotalRow(salla.lang.get("pages.orders.cod_cost"),r.cod_cost,""),r.shipping_cost&&this.renderTotalRow(salla.lang.get("pages.orders.shipping_cost"),r.shipping_cost,"s-order-totals-card-shipping"),r.tax&&this.renderTotalRow(`${salla.lang.get("pages.cart.tax")} ${r.tax.percent}%`,r.tax.amount,""),r.paid_amount?this.renderTotalRow(salla.lang.get("pages.orders.partially_paid"),r.paid_amount,""):null,r.remaining_amount?this.renderTotalRow(salla.lang.get("pages.orders.remaining_amount"),r.remaining_amount,""):null,t("div",{class:"s-order-totals-card-total"},this.renderTotalRow(salla.lang.get("pages.orders.final_total"),r.total,"s-order-totals-card-total-label","s-order-totals-card-total-value",!0)),r.refund_amount?t("div",{class:"s-order-totals-card-refund"},this.renderRefundRow(r.refund_amount)):null))))}static get watchers(){return{order:["handleOrderChange"]}}};o.style='/*!twlt*/:host{display:block}.s-order-totals-card-wrapper{display:block}.s-order-totals-card-panel{border-radius:0.375rem;--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding-left:1.5rem;padding-right:1.5rem}.s-order-totals-card-heading{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}.s-order-totals-card-flow{display:flow-root}.s-order-totals-card-list{font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-totals-card-list>.s-order-totals-card-row{border-bottom-width:1px}.s-order-totals-card-list>.s-order-totals-card-row:last-child{border-bottom-width:0px}.s-order-totals-card-row{display:block}.s-order-totals-card-row-inner{display:flex;align-items:center;justify-content:space-between;gap:1rem;padding-top:1.25rem;padding-bottom:1.25rem}.s-order-totals-card-label{--tw-text-opacity:1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.s-order-totals-card-value{font-weight:500}.s-order-totals-card-discount{--tw-text-opacity:1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.s-order-totals-card-tax-value{font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-totals-card-total{margin-left:-1.5rem;margin-right:-1.5rem;border-radius:0.375rem;background-color:var(--color-border);padding-left:1.5rem;padding-right:1.5rem}.s-order-totals-card-total-label{font-size:1rem;line-height:1.5rem;font-weight:500}.s-order-totals-card-total-value{font-size:1rem;line-height:1.5rem;font-weight:500}.s-order-totals-card-refund{margin-left:-1.5rem;margin-right:-1.5rem;border-left-width:4px;--tw-border-opacity:1;border-color:rgb(254 202 202 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1));padding-left:1.5rem;padding-right:1.5rem}.s-order-totals-card-refund:where([dir="rtl"],[dir="rtl"] *){border-left-width:0px;border-right-width:4px}.s-order-totals-card-refund-label{display:flex;align-items:center;gap:0.5rem;--tw-text-opacity:1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.s-order-totals-card-refund-icon{font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.s-order-totals-card-refund-value{font-weight:500;--tw-text-opacity:1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}';export{o as salla_order_totals_card}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,h as e,H as r}from"./p-5UtJVEzd.js";import{g as i,a as o,c as a,u as d,r as s,m as l,b as n,f as c,d as p,e as h,h as m,i as g}from"./p-C8xwacGT.js";import"./p-CoQJOPRz.js";const w=class{constructor(e){t(this,e),this.loading=!0,this.saveLoading=!1,this.payload={items:{update:[],remove:[],add:[]}},this.expired=!1,this.editPreview=null,this.productSearchQuery="",this.productsListKey=0,this.productsListSource="latest",this.productsListSourceValue="",this.selectedProductToAdd=null,this.addProductQuantity=1,this.addProductLoading=!1,this.addProductConfirmLoading=!1,this.mobileProductsModalMounted=!1,this.isMobileViewport=!1,this.isRTL=!0,this.mobileProductsListLoading=!1,this.confirming=!1,this.handleMobileProductSelected=t=>{t.stopPropagation(),this.handleProductSelected(t)},this.productsPanelMobileQuery="(max-width: 768px)",this.handleProductsPanelViewportChange=t=>{this.isMobileViewport=t.matches},this.hasProductTypeFilter=t=>{const e=t.indexOf("?"),r=(e>=0?t.slice(e+1):t).split("#")[0];return Array.from(new URLSearchParams(r)).some((([t,e])=>"product"===e&&/^filters\[types\](?:\[(?:\d*)\])?$/.test(t)))},this.hasExcludedCategoriesFilter=t=>{const e=t.indexOf("?"),r=(e>=0?t.slice(e+1):t).split("#")[0];return Array.from(new URLSearchParams(r)).some((([t])=>/^filters(?:\[|%5B)excluded_categories(?:\]|%5D)(?:\[|%5B)(?:\d*)(?:\]|%5D)$/.test(t)))},this.normalizeProductsListArrayParams=t=>t.replace(/(^|[?&])(includes|source_value|filters(?:\[|%5B)[^&=\]%]+?(?:\]|%5D))(\[|%5B)\d+(\]|%5D)(?==)/gi,((t,e,r,i,o)=>`${e}${r}${i}${o}`)),this.handleBeforeBuildListUrl=t=>{if("salla-order-edit-product-card"!==t.component?.productCardComponent||"string"!=typeof t.url)return;t.url=this.normalizeProductsListArrayParams(t.url),this.hasProductTypeFilter(t.url)||(t.url+=(t.url.includes("?")?"&":"?")+"filters[types][]=product");const e=this.getParsedExcludedCategories();if(e.length>0&&!this.hasExcludedCategoriesFilter(t.url)){const r=e.map((t=>`filters[excluded_categories][]=${encodeURIComponent(t)}`)).join("&");t.url+=`${t.url.includes("?")?"&":"?"}${r}`}},this.defaultProductsListSource="latest",this.debouncedProductSearch=salla.helpers.debounce((t=>this.applyProductSearch(t)),500),salla.onReady((()=>{this.isRTL=salla.config.get("theme.is_rtl",!0)}))}getParsedExcludedCategories(){if(!this.excludedCategories)return[];try{const t="string"==typeof this.excludedCategories?JSON.parse(this.excludedCategories):this.excludedCategories;return Array.isArray(t)?t.filter((t=>Number.isInteger(t)&&t>0)):[]}catch{return[]}}async componentWillLoad(){this.setupProductsPanelViewportQuery(),await salla.onReady(),this.unregisterBeforeBuildListUrlHook=salla.hooks.registerHook("salla-products-list","beforeBuildListUrl",this.handleBeforeBuildListUrl),this.loadFromProp(),this.startExpiryCheck()}disconnectedCallback(){clearInterval(this.expiryInterval),this.unregisterBeforeBuildListUrlHook?.(),this.productsPanelViewportQuery?.removeEventListener("change",this.handleProductsPanelViewportChange),this.mobileProductsModal?.removeEventListener("orderEditProductSelected",this.handleMobileProductSelected)}setupProductsPanelViewportQuery(){"undefined"!=typeof window&&"function"==typeof window.matchMedia&&(this.productsPanelViewportQuery=window.matchMedia(this.productsPanelMobileQuery),this.isMobileViewport=this.productsPanelViewportQuery.matches,this.productsPanelViewportQuery.addEventListener("change",this.handleProductsPanelViewportChange))}startExpiryCheck(){const t=this.order?.customer_editing_session?.ends_at;if(!t)return;const e=()=>new Date(`${t.replace(" ","T")}+03:00`).getTime()<=Date.now();e()?this.expired=!0:this.expiryInterval=setInterval((()=>{e()&&(this.expired=!0,clearInterval(this.expiryInterval))}),1e3)}loadFromProp(){try{if(!this.orderData)return void(this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود"));const t="string"==typeof this.orderData?JSON.parse(this.orderData):this.orderData;this.order={...t,items:t.items.map((t=>({...t,selectedOptions:i(t)})))}}catch(t){this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود")}finally{this.loading=!1}}applyProductSearch(t){const e=t?.trim()||"",r=e?"search":this.defaultProductsListSource,i="search"===r?JSON.stringify(e):"";this.productsListSource===r&&this.productsListSourceValue===i||(this.productsListSource=r,this.productsListSourceValue=i,this.productsListKey+=1)}handleProductSearch(t){const e=t.target?.value||"";this.productSearchQuery=e,this.debouncedProductSearch(e)}getProductsListKey(t){return`${t}-${this.productsListSource}-${this.productsListSourceValue}-${this.productsListKey}`}handleMobileProductsScroll(t){const e=t.currentTarget;if(e.scrollHeight-e.scrollTop-e.clientHeight>200||this.mobileProductsListLoading)return;const r=e.querySelector("salla-products-list");r&&(this.mobileProductsListLoading=!0,r.loadMore().finally((()=>{this.mobileProductsListLoading=!1})))}waitForNextFrame(){return new Promise((t=>requestAnimationFrame((()=>t(void 0)))))}async openMobileProductsModal(){this.mobileProductsModalMounted||(this.mobileProductsModalMounted=!0,await this.waitForNextFrame()),await(this.mobileProductsModal?.open?.())}setMobileProductsModal(t){this.mobileProductsModal!==t&&(this.mobileProductsModal?.removeEventListener("orderEditProductSelected",this.handleMobileProductSelected),this.mobileProductsModal=t,this.mobileProductsModal?.addEventListener("orderEditProductSelected",this.handleMobileProductSelected))}resetAddProductDrawer(){this.selectedProductToAdd=null,this.addProductQuantity=1,this.addProductLoading=!1,this.addProductConfirmLoading=!1,this.addProductOptions=null}getAddProductMaxQuantity(t=this.selectedProductToAdd){return o(t)}clampAddProductQuantity(t,e=this.selectedProductToAdd){return a(t,this.getAddProductMaxQuantity(e))}getApiErrorMessage(t){return t?.response?.data?.error?.message||t?.response?.data?.message}notifyApiError(t){const e=this.getApiErrorMessage(t);e&&salla.notify.error(e)}async validateAddProductOptions(){return!this.selectedProductToAdd?.options?.length||!!this.addProductOptions&&(await(this.addProductOptions.validateAndScroll?.())??await(this.addProductOptions.reportValidity?.())??!1)}updateLocalOrderItem(t,e,r,i){this.order={...this.order,items:d(this.order.items,t,e,r,i)}}removeLocalOrderItem(t){this.order={...this.order,items:s(this.order.items,t)}}setPayloadItems(t){this.payload={...this.payload,items:l(this.payload.items,t)}}handleAddProductQuantityChange(t){const e=t.detail,r=e?.quantity??parseInt(t.target?.value,10);isNaN(r)||r<1||(this.addProductQuantity=this.clampAddProductQuantity(r))}async handleProductSelected(t){const e=t.detail?.product;if(e?.id&&!this.addProductLoading){this.addProductLoading=!0;try{this.selectedProductToAdd=n(e),this.addProductQuantity=1,await(this.mobileProductsModal?.close?.()),await this.waitForNextFrame(),await(this.addProductDrawer?.open?.())}catch(t){this.notifyApiError(t)}finally{this.addProductLoading=!1}}}async confirmAddProduct(){if(this.selectedProductToAdd?.id&&!this.addProductConfirmLoading){this.addProductConfirmLoading=!0;try{const t=this.getAddProductMaxQuantity(),e=this.clampAddProductQuantity(this.addProductQuantity);e!==this.addProductQuantity&&(this.addProductQuantity=e);const r=this.addProductOptions;if(!await this.validateAddProductOptions())return void salla.notify.error(salla.lang.getWithDefault("common.messages.required_fields","يرجى تعبئة الحقول المطلوبة"));const i=await(r?.getSelectedOptionsData?.())||{},o=await(r?.getOptionsData?.())||this.selectedProductToAdd.options||[],d=c(this.order?.items,this.selectedProductToAdd.id,i);if(d){const r=a(d.quantity+e,t);return this.updateLocalOrderItem(d.id,r,o,i),this.setPayloadItems(d.isNew?{add:p(this.payload.items.add,d.id,r,i)}:{update:h(this.payload.items.update,d.id,r,i)}),void await(this.addProductDrawer?.close?.())}const s=m(this.selectedProductToAdd,e,o,i),l={itemId:s.id,product_id:this.selectedProductToAdd.id,quantity:e,options:i};this.order={...this.order,items:[...this.order.items,s]},this.setPayloadItems({add:[...this.payload.items.add,l]}),await(this.addProductDrawer?.close?.())}catch(t){this.notifyApiError(t)}finally{this.addProductConfirmLoading=!1}}}handleItemUpdated(t){if(!this.order)return;const{itemId:e,quantity:r,options:i,optionDefinitions:d}=t.detail,s=this.order.items.find((t=>t.id===e));if(!s)return;const l=a(r,o(s.product));if(s.isNew)return this.setPayloadItems({add:p(this.payload.items.add,e,l,i)}),void this.updateLocalOrderItem(e,l,d,i);this.setPayloadItems({update:h(this.payload.items.update,e,l,i??{})}),this.updateLocalOrderItem(e,l,d,i)}handleItemRemoved(t){if(!this.order)return;if(this.order.items.length<=1)return void salla.notify.error(salla.lang.getWithDefault("pages.orders.order_cannot_be_empty","لا يمكن إزالة جميع المنتجات من الطلب"));const{itemId:e}=t.detail,r=this.order.items.find((t=>t.id===e));if(r){if(r.isNew)return this.setPayloadItems({add:this.payload.items.add.filter((t=>t.itemId!==e))}),void this.removeLocalOrderItem(e);this.setPayloadItems({update:this.payload.items.update.filter((t=>t.id!==e)),remove:[...this.payload.items.remove,e]}),this.removeLocalOrderItem(e)}}get hasChanges(){return this.payload.items.update.length>0||this.payload.items.remove.length>0||this.payload.items.add.length>0}async saveOrder(){if(this.hasChanges){this.saveLoading=!0;try{const t=await salla.order.api.editOrder(this.orderId,g(this.payload));this.editPreview=t?.data?.data||t?.data,await(this.saveModal?.open?.())}catch(t){this.notifyApiError(t)}finally{this.saveLoading=!1}}}navigateToOrder(){const t=new URL(window.location.href);t.pathname=t.pathname.replace(/\/edit\/?$/,""),t.search="",window.location.href=t.href}handleConfirm(){this.confirming=!0,this.editPreview?.payment?.required&&this.editPreview.payment.payment_url?window.location.href=this.editPreview.payment.payment_url:this.navigateToOrder()}returnToOrderDetails(){this.confirming=!0,this.navigateToOrder()}getConfirmButtonIconClass(){return this.isRTL?"sicon-keyboard_arrow_left":"sicon-keyboard_arrow_right"}async cancelEditSession(){try{await salla.order.api.cancelEditSession(this.orderId),this.navigateToOrder()}catch(t){this.notifyApiError(t)}}renderProductsPanel(){const t=salla.lang.getWithDefault("pages.orders.add_product_to_order","أضف منتج للطلب");return e("section",{class:"s-order-edit-products-panel"},e("div",{class:"s-order-edit-products-header"},e("h2",{class:"s-order-edit-products-title"},t)),this.renderProductsPickerContent("panel"))}renderProductsPickerContent(t){return e("div",{class:{"s-order-edit-products-picker":!0,"s-order-edit-products-modal-content":"modal"===t}},e("label",{class:"s-order-edit-products-search"},e("i",{class:"sicon-search"}),e("input",{type:"search",class:"s-order-edit-products-search-input",placeholder:salla.lang.getWithDefault("pages.products.search_for_product","ابحث عن منتج"),value:this.productSearchQuery,onInput:t=>this.handleProductSearch(t)})),e("div",{class:"s-order-edit-products-list",onScroll:"modal"===t?t=>this.handleMobileProductsScroll(t):void 0},e("salla-products-list",{key:this.getProductsListKey(t),includes:["options"],source:this.productsListSource,"source-value":this.productsListSourceValue,autoload:!0,"product-card-component":"salla-order-edit-product-card"})))}renderMobileProductsModal(){return e("salla-modal",{ref:t=>this.setMobileProductsModal(t),width:"md",class:"s-order-edit-mobile-products-modal","modal-title":salla.lang.getWithDefault("pages.orders.add_product_to_order","أضف منتج للطلب"),onModalVisibilityChanged:t=>{t.detail||(this.mobileProductsModalMounted=!1)}},this.mobileProductsModalMounted?this.renderProductsPickerContent("modal"):null)}renderAddProductDrawer(){const t=this.selectedProductToAdd,r=t?.name||salla.lang.getWithDefault("common.elements.product","منتج"),i=t?.price,o=this.getAddProductMaxQuantity(t),a=t?`order-edit-add-${t.id}`:"order-edit-add",d={value:this.clampAddProductQuantity(this.addProductQuantity,t)};return o&&(d.max=o),e("salla-modal",{ref:t=>this.addProductDrawer=t,width:"md","modal-title":salla.lang.getWithDefault("pages.orders.add_product_to_order","أضف منتج للطلب"),onModalVisibilityChanged:t=>{t.detail||this.resetAddProductDrawer()}},e("div",{class:"s-order-edit-add-modal"},this.addProductLoading?e("div",{class:"s-order-edit-add-modal-loading"},e("salla-loading",null)):t?e("div",{class:"s-order-edit-add-modal-content"},e("div",{class:"s-order-edit-add-modal-header"},e("div",{class:"s-order-edit-add-modal-media"},t.image?.url&&e("img",{src:t.image.url,alt:t.image.alt||r,class:"s-order-edit-add-modal-image"}),e("div",{class:"s-order-edit-add-modal-details"},e("h3",{class:"s-order-edit-add-modal-name"},r),null!=i&&e("span",{class:"s-order-edit-add-modal-price",innerHTML:salla.money(i)})))),e("div",{class:"s-order-edit-add-modal-quantity"},e("h3",{class:"s-order-edit-add-modal-section-title"},salla.lang.getWithDefault("common.elements.quantity","الكمية")),e("div",{class:"s-order-edit-add-modal-quantity-input"},e("salla-quantity-input",{...d,onChange:t=>this.handleAddProductQuantityChange(t)}))),t.options?.length>0&&e("form",{onSubmit:t=>t.preventDefault()},e("salla-product-options",{ref:t=>this.addProductOptions=t,"product-id":t.id,"unique-key":a,options:JSON.stringify(t.options),key:`${a}-options`})),e("div",{class:"s-order-edit-add-modal-actions"},e("salla-button",{onClick:()=>this.confirmAddProduct(),loading:this.addProductConfirmLoading},salla.lang.getWithDefault("common.elements.confirm","تأكيد")),e("salla-button",{color:"gray",fill:"outline",onClick:()=>this.addProductDrawer?.close?.()},salla.lang.getWithDefault("common.elements.cancel","الغاء")))):null))}renderSaveModal(){const t=this.editPreview,r=t?.totals?.remaining_amount?.amount>0,i=t?.totals?.refund_amount?.amount>0,o=t?.totals?.tax?.amount?.amount;return e("salla-modal",{ref:t=>this.saveModal=t,width:"md",isClosable:!1,onModalVisibilityChanged:async t=>{t.detail||(this.editPreview=null,this.confirming||await this.cancelEditSession(),this.confirming=!1)}},e("div",{class:"s-order-edit-modal"},e("h2",{class:"s-order-edit-modal-title"},salla.lang.getWithDefault("pages.orders.edit_summary_title","ملخص الطلب بعد التعديل")),e("p",{class:"s-order-edit-modal-subtitle"},salla.lang.getWithDefault("pages.orders.cart_edits_saved","Your cart edits have been saved")),t?.items?.length>0&&e("div",{class:"s-order-edit-modal-items"},t.items.map((t=>{const r=this.order?.items?.find((e=>e.id==t.id)),i=r?.product?.image?.url,o=t.options?.join("/ ");return e("div",{class:"s-order-edit-modal-item"},e("div",{class:"s-order-edit-modal-item-start"},i&&e("img",{src:i,alt:t.name,class:"s-order-edit-modal-item-image"}),e("div",null,e("p",{class:"s-order-edit-modal-item-name"},t.name),o&&e("span",{class:"s-order-edit-modal-item-options"},o))),e("div",{class:"s-order-edit-modal-item-end"},e("span",{class:"s-order-edit-modal-item-quantity",dir:"ltr",innerHTML:t.quantity+" x "+t.price.amount}),e("span",{class:"s-order-edit-modal-item-price",innerHTML:salla.money(t.price.amount*t.quantity)})))}))),t?.totals?.updated_products_total&&e("div",{class:"s-order-edit-modal-row"},e("span",{class:"s-order-edit-modal-row-label"},salla.lang.getWithDefault("pages.orders.modified_products_total","مجموع المنتجات المعدلة")),e("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(t.totals.updated_products_total.amount)})),o>0&&e("div",{class:"s-order-edit-modal-row"},e("span",{class:"s-order-edit-modal-tax-label"},e("i",{class:"sicon-info-circle s-order-edit-modal-tax-icon"}),salla.lang.getWithDefault("pages.orders.vat","ضريبة القيمة المضافة")),e("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(o)})),t?.totals?.total&&e("div",{class:"s-order-edit-modal-total"},e("span",{class:"s-order-edit-modal-total-label"},salla.lang.getWithDefault("pages.orders.order_total","اجمالي الطلب")),e("span",{class:"s-order-edit-modal-total-value",innerHTML:salla.money(t.totals.total.amount)})),i&&e("div",{class:"s-order-edit-modal-refund"},e("i",{class:"sicon-info-circle s-order-edit-modal-refund-icon"}),e("p",{class:"s-order-edit-modal-refund-text"},salla.lang.getWithDefault("pages.orders.refund_message","سيتم تحويل فارق المبلغ على نفس وسيلة الدفع"))),e("div",{class:"s-order-edit-modal-btn-wrapper"},e("salla-button",{onClick:()=>this.handleConfirm()},r?salla.lang.getWithDefault("pages.orders.pay_difference","دفع فارق المبلغ"):i?salla.lang.getWithDefault("pages.orders.confirm_and_receive_difference","تأكيد واستلام فارق المبلغ"):salla.lang.getWithDefault("pages.orders.confirm_changes","تأكيد التعديلات"),e("i",{class:`${this.getConfirmButtonIconClass()} s-order-edit-modal-btn-icon`})),e("salla-button",{color:"gray",fill:"outline",onClick:()=>this.returnToOrderDetails()},salla.lang.getWithDefault("pages.orders.back_to_order_details","العودة إلى تفاصيل الطلب")))))}render(){if(this.loading)return e(r,null,e("salla-loading",null));if(this.expired)return e(r,null,e("div",{class:"s-order-edit-expired"},e("p",null,salla.lang.getWithDefault("pages.orders.edit_session_expired","انتهت مدة التعديل المتاحة")),e("salla-button",{onClick:()=>this.navigateToOrder()},salla.lang.getWithDefault("pages.orders.back_to_order","العودة إلى تفاصيل الطلب"))));if(this.error||!this.order)return e(r,null,e("div",{class:"s-order-edit-no-content-placeholder"},e("i",{class:"sicon-shopping-bag icon"}),e("p",null,this.error)));const t=this.order.items&&this.order.items.length>0,i=this.order.customer_editing_session?.ends_at;return e(r,null,i&&e("div",{class:"s-order-edit-timer-wrapper"},e("salla-count-down",{prefixText:salla.lang.getWithDefault("pages.orders.edit_within","يمكنك التعديل خلال"),date:i,horizontal:!0,withButton:!0,autoSegments:!0,labeled:!1,size:"sm",color:"primary"})),e("div",{class:"s-order-edit-layout"},this.isMobileViewport?null:this.renderProductsPanel(),e("section",{class:"s-order-edit-order-panel"},e("div",{class:"s-order-edit-items-wrapper"},e("h2",{class:"s-order-edit-items-title"},salla.lang.getWithDefault("pages.orders.order_products","منتجات الطلب")),t?this.order.items.map(((t,r)=>[e("salla-order-edit-item",{key:t.id,item:t,orderId:this.orderId}),r<this.order.items.length-1?e("div",{class:"s-order-edit-items-divider"}):null])):e("div",{class:"s-order-edit-no-content-placeholder"},e("i",{class:"sicon-shopping-bag icon"}),e("p",null,salla.lang.getWithDefault("common.elements.no_items","لا توجد عناصر")))),e("div",{class:"s-order-edit-actions"},e("salla-button",{class:"s-order-edit-mobile-products-trigger",color:"gray",size:"small",fill:"outline",onClick:()=>this.openMobileProductsModal()},e("i",{class:"sicon-add s-order-edit-mobile-products-trigger-icon"}),salla.lang.getWithDefault("pages.orders.add_product","إضافة منتج")),e("salla-button",{onClick:()=>this.saveOrder(),loading:this.saveLoading,size:"small",disabled:!this.hasChanges},salla.lang.getWithDefault("pages.orders.save_changes","حفظ التعديلات")),e("salla-button",{size:"small",color:"gray",fill:"outline",onClick:()=>this.cancelEditSession()},salla.lang.getWithDefault("common.elements.cancel","الغاء"))))),this.renderMobileProductsModal(),this.renderAddProductDrawer(),this.renderSaveModal())}};w.style='/*!twlt*/:host{display:block}.outline{outline-style:solid}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.s-order-edit-timer-wrapper{margin-bottom:1rem;display:flex;justify-content:center}.s-order-edit-layout{display:grid;align-items:flex-start;gap:1.5rem;grid-template-columns:minmax(0,1.35fr) minmax(20rem,1fr)}@media (max-width: 1080px){.s-order-edit-layout{grid-template-columns:minmax(0, 1fr)}}.s-order-edit-products-panel{border-radius:1rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1.5rem}@media (max-width: 768px){.s-order-edit-products-panel{display:none}}.s-order-edit-order-panel{display:flex;flex-direction:column;gap:1.5rem;border-radius:1rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1.5rem}.s-order-edit-products-header{margin-bottom:1rem}.s-order-edit-products-title{margin:0px;font-size:1.125rem;line-height:1.75rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-items-wrapper{display:flex;flex-direction:column;gap:1.25rem}.s-order-edit-items-title{margin:0px;font-size:1.125rem;line-height:1.75rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-items-divider{height:1px;width:100%;--tw-bg-opacity:1;background-color:rgb(238 242 247 / var(--tw-bg-opacity, 1))}.s-order-edit-products-picker{display:flex;min-height:0px;flex-direction:column;gap:1rem}.s-order-edit-products-modal-content{display:flex;min-height:0px;flex-direction:column;gap:1rem;padding:1rem}.s-order-edit-products-search{position:relative;margin-bottom:1.25rem;display:block}.s-order-edit-products-search i{pointer-events:none;position:absolute;top:50%;--tw-translate-y:-50%;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));font-size:1rem;line-height:1.5rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-products-search i:where([dir="ltr"],[dir="ltr"] *){left:1rem}.s-order-edit-products-search i:where([dir="rtl"],[dir="rtl"] *){right:1rem}.s-order-edit-products-search-input{min-height:3rem;width:100%;border-radius:0.875rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding-left:1rem;padding-right:1rem;padding-top:0.875rem;padding-bottom:0.875rem;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1));transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:200ms}.s-order-edit-products-search-input:where([dir="ltr"],[dir="ltr"] *){padding-left:2.75rem;padding-right:1rem}.s-order-edit-products-search-input:where([dir="rtl"],[dir="rtl"] *){padding-right:2.75rem;padding-left:1rem}.s-order-edit-products-search-input:focus{--tw-border-opacity:1;border-color:rgb(17 24 39 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));--tw-shadow:0 0 0 3px rgba(17,24,39,0.08);--tw-shadow-colored:0 0 0 3px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}.s-order-edit-products-list{min-height:20rem}.s-order-edit-products-list .s-products-list-wrapper{gap:1rem;grid-template-columns:repeat(2,minmax(0,1fr))}@media (min-width: 769px){.s-order-edit-products-list .s-products-list-wrapper{grid-template-columns:repeat(3, minmax(0, 1fr))}}.s-order-edit-no-content-placeholder{display:flex;min-height:14rem;flex-direction:column;align-items:center;justify-content:center;gap:0.75rem;border-radius:0.875rem;border-width:1px;border-style:dashed;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding:2rem;text-align:center;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-no-content-placeholder .icon{font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-actions{position:sticky;bottom:1.5rem;display:flex;align-items:center;justify-content:space-between;gap:0.75rem;border-radius:0.875rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));background-color:rgba(255,255,255,0.94);padding:1rem;--tw-shadow:0 12px 30px rgba(15,23,42,0.08);--tw-shadow-colored:0 12px 30px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);--tw-backdrop-blur:blur(10px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}@media (max-width: 768px){.s-order-edit-actions{position:static;align-items:center;gap:0.5rem}}.s-order-edit-actions salla-button{flex:0 0 auto}@media (max-width: 768px){.s-order-edit-actions salla-button{display:block;flex:1 1 0;min-width:0}}.s-order-edit-mobile-products-trigger{display:none}@media (max-width: 768px){.s-order-edit-mobile-products-trigger{display:block}}.s-order-edit-mobile-products-trigger-icon:where([dir="ltr"],[dir="ltr"] *){margin-right:0.35rem}.s-order-edit-mobile-products-trigger-icon:where([dir="rtl"],[dir="rtl"] *){margin-left:0.35rem}.s-order-edit-mobile-products-modal .s-order-edit-products-list{max-height:min(24rem, calc(100vh - 11rem));min-height:22rem;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}@media (max-width: 480px){.s-order-edit-mobile-products-modal .s-order-edit-products-list{min-height:20rem;max-height:min(22rem, calc(100vh - 10rem))}}.s-order-edit-mobile-products-modal .products-list .s-products-list-wrapper{gap:0.625rem;grid-template-columns:repeat(2,minmax(0,1fr))}.s-order-edit-modal{display:flex;flex-direction:column;gap:1rem}.s-order-edit-modal-title{margin:0px;text-align:start;font-size:1.125rem;line-height:1.75rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-subtitle{margin:0px;margin-top:-0.75rem;text-align:start;font-size:0.875rem;line-height:1.25rem;line-height:1.5;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-items{display:flex;flex-direction:column;gap:0.75rem}.s-order-edit-modal-item{display:flex;align-items:center;justify-content:space-between;gap:1rem;border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-bottom:0.75rem}.s-order-edit-modal-item-start{display:flex;align-items:center;gap:0.75rem}.s-order-edit-modal-item-image{height:3rem;width:3rem;border-radius:0.75rem;object-fit:cover}.s-order-edit-modal-item-name{margin:0px;font-size:0.875rem;line-height:1.25rem;font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-item-options{font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-item-end{display:flex;align-items:center;gap:0.75rem}.s-order-edit-modal-item-price{font-size:0.875rem;line-height:1.25rem;font-weight:500}.s-order-edit-modal-item-quantity{font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-row{display:flex;align-items:center;justify-content:space-between;gap:1rem}.s-order-edit-modal-row-label{font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-row-value{font-weight:700}.s-order-edit-modal-tax-label{display:flex;align-items:center;gap:0.5rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-tax-icon{--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-modal-total{display:flex;align-items:center;justify-content:space-between;gap:1rem;border-top-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-top:0.75rem;font-weight:700;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-total-label{font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-total-value{font-size:1.25rem;line-height:1.75rem;font-weight:500}.s-order-edit-modal-refund{display:flex;align-items:flex-start;gap:1rem;border-radius:0.875rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));padding-left:1rem;padding-right:1rem;padding-top:0.875rem;padding-bottom:0.875rem;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-order-edit-modal-refund-icon{flex-shrink:0;font-size:1.125rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-refund-text{margin:0px;flex:1 1 0%;font-size:0.875rem;line-height:1.25rem}.s-order-edit-modal-btn-wrapper{margin-top:0.5rem;display:flex;justify-content:space-between}.s-order-edit-modal-btn-wrapper salla-button{width:100%}@media (min-width: 640px){.s-order-edit-modal-btn-wrapper salla-button{width:auto}}.s-order-edit-modal-btn-icon{vertical-align:middle;font-size:1.125rem;line-height:1.75rem}.s-order-edit-expired{display:flex;min-height:14rem;flex-direction:column;align-items:center;justify-content:center;gap:0.75rem;border-radius:0.875rem;border-width:1px;border-style:dashed;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding:2rem;text-align:center;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-expired .icon{font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal{display:flex;min-height:0px;flex:1 1 auto;flex-direction:column;gap:1rem}.s-order-edit-add-modal-content{display:flex;min-height:0px;flex:1 1 auto;flex-direction:column;gap:1rem}.s-order-edit-add-modal-loading{display:flex;min-height:12rem;flex:1 1 auto;align-items:center;justify-content:center}.s-order-edit-add-modal-header{border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-bottom:1rem}.s-order-edit-add-modal-media{display:flex;align-items:flex-start;gap:1rem}.s-order-edit-add-modal-image{height:5.5rem;width:5.5rem;border-radius:0.875rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));object-fit:cover}.s-order-edit-add-modal-details{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.35rem}.s-order-edit-add-modal-name{margin:0px;font-size:1rem;line-height:1.5rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal-price{font-size:0.95rem;font-weight:700;--tw-text-opacity:1;color:rgb(15 118 110 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal-quantity{display:flex;align-items:center;justify-content:space-between;gap:1rem}.s-order-edit-add-modal-section-title{margin:0px;font-size:0.9375rem;font-weight:600;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal-quantity-input{flex-shrink:0}.s-order-edit-add-modal-actions{margin-top:auto;display:flex;align-items:center;justify-content:space-between;gap:0.75rem;border-top-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding-top:1rem}.s-order-edit-add-modal-actions salla-button{min-width:4.75rem;flex:0 0 auto}.s-order-edit-item-header{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem}.s-order-edit-item-media{display:flex;min-width:0px;flex:1 1 0%;gap:1rem}@media (max-width: 640px){.s-order-edit-item-media{width:100%}}.s-order-edit-item-image{height:5.5rem;width:5.5rem;border-radius:0.875rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));object-fit:cover}.s-order-edit-item-details{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.35rem}.s-order-edit-item-name{margin:0px;font-size:1rem;line-height:1.5rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-item-link{color:inherit;text-decoration-line:none}.s-order-edit-item-price{font-size:0.95rem;font-weight:700;--tw-text-opacity:1;color:rgb(15 118 110 / var(--tw-text-opacity, 1))}.s-order-edit-item-weight{margin:0px;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-item-quantity{margin-top:1.25rem;display:flex;align-items:center;justify-content:space-between;gap:1rem;border-top-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-top:1rem}.s-order-edit-item-quantity-label{margin:0px;font-size:0.9375rem;font-weight:600;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-order-edit-item-quantity-input{flex-shrink:0}.s-order-edit-item-options{margin-top:1rem;display:block}.s-order-edit-product-card{display:flex;min-height:100%;width:100%;cursor:pointer;appearance:none;flex-direction:column;overflow:hidden;border-radius:0.875rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));text-align:start;--tw-shadow:0 10px 24px rgba(15,23,42,0.04);--tw-shadow-colored:0 10px 24px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:200ms}.s-order-edit-product-card:hover{--tw-translate-y:-2px;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-shadow:0 16px 30px rgba(15,23,42,0.08);--tw-shadow-colored:0 16px 30px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.s-order-edit-product-card:focus-visible{--tw-border-opacity:1;border-color:rgb(17 24 39 / var(--tw-border-opacity, 1));--tw-shadow:0 0 0 3px rgba(17,24,39,0.12);--tw-shadow-colored:0 0 0 3px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}@media (max-width: 768px){.s-order-edit-product-card{border-radius:0.75rem;box-shadow:0 6px 18px rgba(15, 23, 42, 0.05)}}.s-order-edit-product-card-media{display:flex;aspect-ratio:1 / 1;width:100%;flex-shrink:0;align-items:center;justify-content:center;overflow:hidden;background:linear-gradient(180deg,#f8fafc 0%,#f1f5f9 100%)}.s-order-edit-product-card-image{display:block;height:100%;width:100%;object-fit:cover}.s-order-edit-product-card-placeholder{display:flex;height:100%;width:100%;align-items:center;justify-content:center;font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-product-card-content{display:flex;flex:1 1 0%;flex-direction:column;gap:0.5rem;padding:1rem}@media (max-width: 768px){.s-order-edit-product-card-content{gap:0.25rem;padding:0.625rem}}.s-order-edit-product-card-title{margin:0px;font-size:0.95rem;font-weight:600;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}@media (max-width: 768px){.s-order-edit-product-card-title{display:-webkit-box;overflow:hidden;min-height:2.35rem;font-size:0.8125rem;line-height:1.45;-webkit-box-orient:vertical;-webkit-line-clamp:2}}.s-order-edit-product-card-price{margin:0px;font-size:1rem;line-height:1.5rem;font-weight:700;--tw-text-opacity:1;color:rgb(15 118 110 / var(--tw-text-opacity, 1))}@media (max-width: 768px){.s-order-edit-product-card-price{font-size:0.875rem}.s-order-edit-products-panel,.s-order-edit-order-panel{padding:1rem}.s-order-edit-actions salla-button .s-button-element{width:100%;min-width:0;padding-inline:0.5rem}.s-order-edit-mobile-products-modal .s-order-edit-products-modal-content{gap:0.75rem;padding:0.875rem}.s-order-edit-add-modal-media,.s-order-edit-add-modal-quantity{flex-direction:column;align-items:stretch}}';export{w as salla_order_edit}
4
+ import{r as t,h as e,H as r}from"./p-DaGqpYdk.js";import{g as i,a as o,c as a,u as d,r as s,m as l,b as n,f as c,d as p,e as h,h as m,i as g}from"./p-C8xwacGT.js";import"./p-CoQJOPRz.js";const w=class{constructor(e){t(this,e),this.loading=!0,this.saveLoading=!1,this.payload={items:{update:[],remove:[],add:[]}},this.expired=!1,this.editPreview=null,this.productSearchQuery="",this.productsListKey=0,this.productsListSource="latest",this.productsListSourceValue="",this.selectedProductToAdd=null,this.addProductQuantity=1,this.addProductLoading=!1,this.addProductConfirmLoading=!1,this.mobileProductsModalMounted=!1,this.isMobileViewport=!1,this.isRTL=!0,this.mobileProductsListLoading=!1,this.confirming=!1,this.handleMobileProductSelected=t=>{t.stopPropagation(),this.handleProductSelected(t)},this.productsPanelMobileQuery="(max-width: 768px)",this.handleProductsPanelViewportChange=t=>{this.isMobileViewport=t.matches},this.hasProductTypeFilter=t=>{const e=t.indexOf("?"),r=(e>=0?t.slice(e+1):t).split("#")[0];return Array.from(new URLSearchParams(r)).some((([t,e])=>"product"===e&&/^filters\[types\](?:\[(?:\d*)\])?$/.test(t)))},this.hasExcludedCategoriesFilter=t=>{const e=t.indexOf("?"),r=(e>=0?t.slice(e+1):t).split("#")[0];return Array.from(new URLSearchParams(r)).some((([t])=>/^filters(?:\[|%5B)excluded_categories(?:\]|%5D)(?:\[|%5B)(?:\d*)(?:\]|%5D)$/.test(t)))},this.normalizeProductsListArrayParams=t=>t.replace(/(^|[?&])(includes|source_value|filters(?:\[|%5B)[^&=\]%]+?(?:\]|%5D))(\[|%5B)\d+(\]|%5D)(?==)/gi,((t,e,r,i,o)=>`${e}${r}${i}${o}`)),this.handleBeforeBuildListUrl=t=>{if("salla-order-edit-product-card"!==t.component?.productCardComponent||"string"!=typeof t.url)return;t.url=this.normalizeProductsListArrayParams(t.url),this.hasProductTypeFilter(t.url)||(t.url+=(t.url.includes("?")?"&":"?")+"filters[types][]=product");const e=this.getParsedExcludedCategories();if(e.length>0&&!this.hasExcludedCategoriesFilter(t.url)){const r=e.map((t=>`filters[excluded_categories][]=${encodeURIComponent(t)}`)).join("&");t.url+=`${t.url.includes("?")?"&":"?"}${r}`}},this.defaultProductsListSource="latest",this.debouncedProductSearch=salla.helpers.debounce((t=>this.applyProductSearch(t)),500),salla.onReady((()=>{this.isRTL=salla.config.get("theme.is_rtl",!0)}))}getParsedExcludedCategories(){if(!this.excludedCategories)return[];try{const t="string"==typeof this.excludedCategories?JSON.parse(this.excludedCategories):this.excludedCategories;return Array.isArray(t)?t.filter((t=>Number.isInteger(t)&&t>0)):[]}catch{return[]}}async componentWillLoad(){this.setupProductsPanelViewportQuery(),await salla.onReady(),this.unregisterBeforeBuildListUrlHook=salla.hooks.registerHook("salla-products-list","beforeBuildListUrl",this.handleBeforeBuildListUrl),this.loadFromProp(),this.startExpiryCheck()}disconnectedCallback(){clearInterval(this.expiryInterval),this.unregisterBeforeBuildListUrlHook?.(),this.productsPanelViewportQuery?.removeEventListener("change",this.handleProductsPanelViewportChange),this.mobileProductsModal?.removeEventListener("orderEditProductSelected",this.handleMobileProductSelected)}setupProductsPanelViewportQuery(){"undefined"!=typeof window&&"function"==typeof window.matchMedia&&(this.productsPanelViewportQuery=window.matchMedia(this.productsPanelMobileQuery),this.isMobileViewport=this.productsPanelViewportQuery.matches,this.productsPanelViewportQuery.addEventListener("change",this.handleProductsPanelViewportChange))}startExpiryCheck(){const t=this.order?.customer_editing_session?.ends_at;if(!t)return;const e=()=>new Date(`${t.replace(" ","T")}+03:00`).getTime()<=Date.now();e()?this.expired=!0:this.expiryInterval=setInterval((()=>{e()&&(this.expired=!0,clearInterval(this.expiryInterval))}),1e3)}loadFromProp(){try{if(!this.orderData)return void(this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود"));const t="string"==typeof this.orderData?JSON.parse(this.orderData):this.orderData;this.order={...t,items:t.items.map((t=>({...t,selectedOptions:i(t)})))}}catch(t){this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود")}finally{this.loading=!1}}applyProductSearch(t){const e=t?.trim()||"",r=e?"search":this.defaultProductsListSource,i="search"===r?JSON.stringify(e):"";this.productsListSource===r&&this.productsListSourceValue===i||(this.productsListSource=r,this.productsListSourceValue=i,this.productsListKey+=1)}handleProductSearch(t){const e=t.target?.value||"";this.productSearchQuery=e,this.debouncedProductSearch(e)}getProductsListKey(t){return`${t}-${this.productsListSource}-${this.productsListSourceValue}-${this.productsListKey}`}handleMobileProductsScroll(t){const e=t.currentTarget;if(e.scrollHeight-e.scrollTop-e.clientHeight>200||this.mobileProductsListLoading)return;const r=e.querySelector("salla-products-list");r&&(this.mobileProductsListLoading=!0,r.loadMore().finally((()=>{this.mobileProductsListLoading=!1})))}waitForNextFrame(){return new Promise((t=>requestAnimationFrame((()=>t(void 0)))))}async openMobileProductsModal(){this.mobileProductsModalMounted||(this.mobileProductsModalMounted=!0,await this.waitForNextFrame()),await(this.mobileProductsModal?.open?.())}setMobileProductsModal(t){this.mobileProductsModal!==t&&(this.mobileProductsModal?.removeEventListener("orderEditProductSelected",this.handleMobileProductSelected),this.mobileProductsModal=t,this.mobileProductsModal?.addEventListener("orderEditProductSelected",this.handleMobileProductSelected))}resetAddProductDrawer(){this.selectedProductToAdd=null,this.addProductQuantity=1,this.addProductLoading=!1,this.addProductConfirmLoading=!1,this.addProductOptions=null}getAddProductMaxQuantity(t=this.selectedProductToAdd){return o(t)}clampAddProductQuantity(t,e=this.selectedProductToAdd){return a(t,this.getAddProductMaxQuantity(e))}getApiErrorMessage(t){return t?.response?.data?.error?.message||t?.response?.data?.message}notifyApiError(t){const e=this.getApiErrorMessage(t);e&&salla.notify.error(e)}async validateAddProductOptions(){return!this.selectedProductToAdd?.options?.length||!!this.addProductOptions&&(await(this.addProductOptions.validateAndScroll?.())??await(this.addProductOptions.reportValidity?.())??!1)}updateLocalOrderItem(t,e,r,i){this.order={...this.order,items:d(this.order.items,t,e,r,i)}}removeLocalOrderItem(t){this.order={...this.order,items:s(this.order.items,t)}}setPayloadItems(t){this.payload={...this.payload,items:l(this.payload.items,t)}}handleAddProductQuantityChange(t){const e=t.detail,r=e?.quantity??parseInt(t.target?.value,10);isNaN(r)||r<1||(this.addProductQuantity=this.clampAddProductQuantity(r))}async handleProductSelected(t){const e=t.detail?.product;if(e?.id&&!this.addProductLoading){this.addProductLoading=!0;try{this.selectedProductToAdd=n(e),this.addProductQuantity=1,await(this.mobileProductsModal?.close?.()),await this.waitForNextFrame(),await(this.addProductDrawer?.open?.())}catch(t){this.notifyApiError(t)}finally{this.addProductLoading=!1}}}async confirmAddProduct(){if(this.selectedProductToAdd?.id&&!this.addProductConfirmLoading){this.addProductConfirmLoading=!0;try{const t=this.getAddProductMaxQuantity(),e=this.clampAddProductQuantity(this.addProductQuantity);e!==this.addProductQuantity&&(this.addProductQuantity=e);const r=this.addProductOptions;if(!await this.validateAddProductOptions())return void salla.notify.error(salla.lang.getWithDefault("common.messages.required_fields","يرجى تعبئة الحقول المطلوبة"));const i=await(r?.getSelectedOptionsData?.())||{},o=await(r?.getOptionsData?.())||this.selectedProductToAdd.options||[],d=c(this.order?.items,this.selectedProductToAdd.id,i);if(d){const r=a(d.quantity+e,t);return this.updateLocalOrderItem(d.id,r,o,i),this.setPayloadItems(d.isNew?{add:p(this.payload.items.add,d.id,r,i)}:{update:h(this.payload.items.update,d.id,r,i)}),void await(this.addProductDrawer?.close?.())}const s=m(this.selectedProductToAdd,e,o,i),l={itemId:s.id,product_id:this.selectedProductToAdd.id,quantity:e,options:i};this.order={...this.order,items:[...this.order.items,s]},this.setPayloadItems({add:[...this.payload.items.add,l]}),await(this.addProductDrawer?.close?.())}catch(t){this.notifyApiError(t)}finally{this.addProductConfirmLoading=!1}}}handleItemUpdated(t){if(!this.order)return;const{itemId:e,quantity:r,options:i,optionDefinitions:d}=t.detail,s=this.order.items.find((t=>t.id===e));if(!s)return;const l=a(r,o(s.product));if(s.isNew)return this.setPayloadItems({add:p(this.payload.items.add,e,l,i)}),void this.updateLocalOrderItem(e,l,d,i);this.setPayloadItems({update:h(this.payload.items.update,e,l,i??{})}),this.updateLocalOrderItem(e,l,d,i)}handleItemRemoved(t){if(!this.order)return;if(this.order.items.length<=1)return void salla.notify.error(salla.lang.getWithDefault("pages.orders.order_cannot_be_empty","لا يمكن إزالة جميع المنتجات من الطلب"));const{itemId:e}=t.detail,r=this.order.items.find((t=>t.id===e));if(r){if(r.isNew)return this.setPayloadItems({add:this.payload.items.add.filter((t=>t.itemId!==e))}),void this.removeLocalOrderItem(e);this.setPayloadItems({update:this.payload.items.update.filter((t=>t.id!==e)),remove:[...this.payload.items.remove,e]}),this.removeLocalOrderItem(e)}}get hasChanges(){return this.payload.items.update.length>0||this.payload.items.remove.length>0||this.payload.items.add.length>0}async saveOrder(){if(this.hasChanges){this.saveLoading=!0;try{const t=await salla.order.api.editOrder(this.orderId,g(this.payload));this.editPreview=t?.data?.data||t?.data,await(this.saveModal?.open?.())}catch(t){this.notifyApiError(t)}finally{this.saveLoading=!1}}}navigateToOrder(){const t=new URL(window.location.href);t.pathname=t.pathname.replace(/\/edit\/?$/,""),t.search="",window.location.href=t.href}handleConfirm(){this.confirming=!0,this.editPreview?.payment?.required&&this.editPreview.payment.payment_url?window.location.href=this.editPreview.payment.payment_url:this.navigateToOrder()}returnToOrderDetails(){this.confirming=!0,this.navigateToOrder()}getConfirmButtonIconClass(){return this.isRTL?"sicon-keyboard_arrow_left":"sicon-keyboard_arrow_right"}async cancelEditSession(){try{await salla.order.api.cancelEditSession(this.orderId),this.navigateToOrder()}catch(t){this.notifyApiError(t)}}renderProductsPanel(){const t=salla.lang.getWithDefault("pages.orders.add_product_to_order","أضف منتج للطلب");return e("section",{class:"s-order-edit-products-panel"},e("div",{class:"s-order-edit-products-header"},e("h2",{class:"s-order-edit-products-title"},t)),this.renderProductsPickerContent("panel"))}renderProductsPickerContent(t){return e("div",{class:{"s-order-edit-products-picker":!0,"s-order-edit-products-modal-content":"modal"===t}},e("label",{class:"s-order-edit-products-search"},e("i",{class:"sicon-search"}),e("input",{type:"search",class:"s-order-edit-products-search-input",placeholder:salla.lang.getWithDefault("pages.products.search_for_product","ابحث عن منتج"),value:this.productSearchQuery,onInput:t=>this.handleProductSearch(t)})),e("div",{class:"s-order-edit-products-list",onScroll:"modal"===t?t=>this.handleMobileProductsScroll(t):void 0},e("salla-products-list",{key:this.getProductsListKey(t),includes:["options"],source:this.productsListSource,"source-value":this.productsListSourceValue,autoload:!0,"product-card-component":"salla-order-edit-product-card"})))}renderMobileProductsModal(){return e("salla-modal",{ref:t=>this.setMobileProductsModal(t),width:"md",class:"s-order-edit-mobile-products-modal","modal-title":salla.lang.getWithDefault("pages.orders.add_product_to_order","أضف منتج للطلب"),onModalVisibilityChanged:t=>{t.detail||(this.mobileProductsModalMounted=!1)}},this.mobileProductsModalMounted?this.renderProductsPickerContent("modal"):null)}renderAddProductDrawer(){const t=this.selectedProductToAdd,r=t?.name||salla.lang.getWithDefault("common.elements.product","منتج"),i=t?.price,o=this.getAddProductMaxQuantity(t),a=t?`order-edit-add-${t.id}`:"order-edit-add",d={value:this.clampAddProductQuantity(this.addProductQuantity,t)};return o&&(d.max=o),e("salla-modal",{ref:t=>this.addProductDrawer=t,width:"md","modal-title":salla.lang.getWithDefault("pages.orders.add_product_to_order","أضف منتج للطلب"),onModalVisibilityChanged:t=>{t.detail||this.resetAddProductDrawer()}},e("div",{class:"s-order-edit-add-modal"},this.addProductLoading?e("div",{class:"s-order-edit-add-modal-loading"},e("salla-loading",null)):t?e("div",{class:"s-order-edit-add-modal-content"},e("div",{class:"s-order-edit-add-modal-header"},e("div",{class:"s-order-edit-add-modal-media"},t.image?.url&&e("img",{src:t.image.url,alt:t.image.alt||r,class:"s-order-edit-add-modal-image"}),e("div",{class:"s-order-edit-add-modal-details"},e("h3",{class:"s-order-edit-add-modal-name"},r),null!=i&&e("span",{class:"s-order-edit-add-modal-price",innerHTML:salla.money(i)})))),e("div",{class:"s-order-edit-add-modal-quantity"},e("h3",{class:"s-order-edit-add-modal-section-title"},salla.lang.getWithDefault("common.elements.quantity","الكمية")),e("div",{class:"s-order-edit-add-modal-quantity-input"},e("salla-quantity-input",{...d,onChange:t=>this.handleAddProductQuantityChange(t)}))),t.options?.length>0&&e("form",{onSubmit:t=>t.preventDefault()},e("salla-product-options",{ref:t=>this.addProductOptions=t,"product-id":t.id,"unique-key":a,options:JSON.stringify(t.options),key:`${a}-options`})),e("div",{class:"s-order-edit-add-modal-actions"},e("salla-button",{onClick:()=>this.confirmAddProduct(),loading:this.addProductConfirmLoading},salla.lang.getWithDefault("common.elements.confirm","تأكيد")),e("salla-button",{color:"gray",fill:"outline",onClick:()=>this.addProductDrawer?.close?.()},salla.lang.getWithDefault("common.elements.cancel","الغاء")))):null))}renderSaveModal(){const t=this.editPreview,r=t?.totals?.remaining_amount?.amount>0,i=t?.totals?.refund_amount?.amount>0,o=t?.totals?.tax?.amount?.amount;return e("salla-modal",{ref:t=>this.saveModal=t,width:"md",isClosable:!1,onModalVisibilityChanged:async t=>{t.detail||(this.editPreview=null,this.confirming||await this.cancelEditSession(),this.confirming=!1)}},e("div",{class:"s-order-edit-modal"},e("h2",{class:"s-order-edit-modal-title"},salla.lang.getWithDefault("pages.orders.edit_summary_title","ملخص الطلب بعد التعديل")),e("p",{class:"s-order-edit-modal-subtitle"},salla.lang.getWithDefault("pages.orders.cart_edits_saved","Your cart edits have been saved")),t?.items?.length>0&&e("div",{class:"s-order-edit-modal-items"},t.items.map((t=>{const r=this.order?.items?.find((e=>e.id==t.id)),i=r?.product?.image?.url,o=t.options?.join("/ ");return e("div",{class:"s-order-edit-modal-item"},e("div",{class:"s-order-edit-modal-item-start"},i&&e("img",{src:i,alt:t.name,class:"s-order-edit-modal-item-image"}),e("div",null,e("p",{class:"s-order-edit-modal-item-name"},t.name),o&&e("span",{class:"s-order-edit-modal-item-options"},o))),e("div",{class:"s-order-edit-modal-item-end"},e("span",{class:"s-order-edit-modal-item-quantity",dir:"ltr",innerHTML:t.quantity+" x "+t.price.amount}),e("span",{class:"s-order-edit-modal-item-price",innerHTML:salla.money(t.price.amount*t.quantity)})))}))),t?.totals?.updated_products_total&&e("div",{class:"s-order-edit-modal-row"},e("span",{class:"s-order-edit-modal-row-label"},salla.lang.getWithDefault("pages.orders.modified_products_total","مجموع المنتجات المعدلة")),e("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(t.totals.updated_products_total.amount)})),o>0&&e("div",{class:"s-order-edit-modal-row"},e("span",{class:"s-order-edit-modal-tax-label"},e("i",{class:"sicon-info-circle s-order-edit-modal-tax-icon"}),salla.lang.getWithDefault("pages.orders.vat","ضريبة القيمة المضافة")),e("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(o)})),t?.totals?.total&&e("div",{class:"s-order-edit-modal-total"},e("span",{class:"s-order-edit-modal-total-label"},salla.lang.getWithDefault("pages.orders.order_total","اجمالي الطلب")),e("span",{class:"s-order-edit-modal-total-value",innerHTML:salla.money(t.totals.total.amount)})),i&&e("div",{class:"s-order-edit-modal-refund"},e("i",{class:"sicon-info-circle s-order-edit-modal-refund-icon"}),e("p",{class:"s-order-edit-modal-refund-text"},salla.lang.getWithDefault("pages.orders.refund_message","سيتم تحويل فارق المبلغ على نفس وسيلة الدفع"))),e("div",{class:"s-order-edit-modal-btn-wrapper"},e("salla-button",{onClick:()=>this.handleConfirm()},r?salla.lang.getWithDefault("pages.orders.pay_difference","دفع فارق المبلغ"):i?salla.lang.getWithDefault("pages.orders.confirm_and_receive_difference","تأكيد واستلام فارق المبلغ"):salla.lang.getWithDefault("pages.orders.confirm_changes","تأكيد التعديلات"),e("i",{class:`${this.getConfirmButtonIconClass()} s-order-edit-modal-btn-icon`})),e("salla-button",{color:"gray",fill:"outline",onClick:()=>this.returnToOrderDetails()},salla.lang.getWithDefault("pages.orders.back_to_order_details","العودة إلى تفاصيل الطلب")))))}render(){if(this.loading)return e(r,null,e("salla-loading",null));if(this.expired)return e(r,null,e("div",{class:"s-order-edit-expired"},e("p",null,salla.lang.getWithDefault("pages.orders.edit_session_expired","انتهت مدة التعديل المتاحة")),e("salla-button",{onClick:()=>this.navigateToOrder()},salla.lang.getWithDefault("pages.orders.back_to_order","العودة إلى تفاصيل الطلب"))));if(this.error||!this.order)return e(r,null,e("div",{class:"s-order-edit-no-content-placeholder"},e("i",{class:"sicon-shopping-bag icon"}),e("p",null,this.error)));const t=this.order.items&&this.order.items.length>0,i=this.order.customer_editing_session?.ends_at;return e(r,null,i&&e("div",{class:"s-order-edit-timer-wrapper"},e("salla-count-down",{prefixText:salla.lang.getWithDefault("pages.orders.edit_within","يمكنك التعديل خلال"),date:i,horizontal:!0,withButton:!0,autoSegments:!0,labeled:!1,size:"sm",color:"primary"})),e("div",{class:"s-order-edit-layout"},this.isMobileViewport?null:this.renderProductsPanel(),e("section",{class:"s-order-edit-order-panel"},e("div",{class:"s-order-edit-items-wrapper"},e("h2",{class:"s-order-edit-items-title"},salla.lang.getWithDefault("pages.orders.order_products","منتجات الطلب")),t?this.order.items.map(((t,r)=>[e("salla-order-edit-item",{key:t.id,item:t,orderId:this.orderId}),r<this.order.items.length-1?e("div",{class:"s-order-edit-items-divider"}):null])):e("div",{class:"s-order-edit-no-content-placeholder"},e("i",{class:"sicon-shopping-bag icon"}),e("p",null,salla.lang.getWithDefault("common.elements.no_items","لا توجد عناصر")))),e("div",{class:"s-order-edit-actions"},e("salla-button",{class:"s-order-edit-mobile-products-trigger",color:"gray",size:"small",fill:"outline",onClick:()=>this.openMobileProductsModal()},e("i",{class:"sicon-add s-order-edit-mobile-products-trigger-icon"}),salla.lang.getWithDefault("pages.orders.add_product","إضافة منتج")),e("salla-button",{onClick:()=>this.saveOrder(),loading:this.saveLoading,size:"small",disabled:!this.hasChanges},salla.lang.getWithDefault("pages.orders.save_changes","حفظ التعديلات")),e("salla-button",{size:"small",color:"gray",fill:"outline",onClick:()=>this.cancelEditSession()},salla.lang.getWithDefault("common.elements.cancel","الغاء"))))),this.renderMobileProductsModal(),this.renderAddProductDrawer(),this.renderSaveModal())}};w.style='/*!twlt*/:host{display:block}.outline{outline-style:solid}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.s-order-edit-timer-wrapper{margin-bottom:1rem;display:flex;justify-content:center}.s-order-edit-layout{display:grid;align-items:flex-start;gap:1.5rem;grid-template-columns:minmax(0,1.35fr) minmax(20rem,1fr)}@media (max-width: 1080px){.s-order-edit-layout{grid-template-columns:minmax(0, 1fr)}}.s-order-edit-products-panel{border-radius:1rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1.5rem}@media (max-width: 768px){.s-order-edit-products-panel{display:none}}.s-order-edit-order-panel{display:flex;flex-direction:column;gap:1.5rem;border-radius:1rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1.5rem}.s-order-edit-products-header{margin-bottom:1rem}.s-order-edit-products-title{margin:0px;font-size:1.125rem;line-height:1.75rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-items-wrapper{display:flex;flex-direction:column;gap:1.25rem}.s-order-edit-items-title{margin:0px;font-size:1.125rem;line-height:1.75rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-items-divider{height:1px;width:100%;--tw-bg-opacity:1;background-color:rgb(238 242 247 / var(--tw-bg-opacity, 1))}.s-order-edit-products-picker{display:flex;min-height:0px;flex-direction:column;gap:1rem}.s-order-edit-products-modal-content{display:flex;min-height:0px;flex-direction:column;gap:1rem;padding:1rem}.s-order-edit-products-search{position:relative;margin-bottom:1.25rem;display:block}.s-order-edit-products-search i{pointer-events:none;position:absolute;top:50%;--tw-translate-y:-50%;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));font-size:1rem;line-height:1.5rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-products-search i:where([dir="ltr"],[dir="ltr"] *){left:1rem}.s-order-edit-products-search i:where([dir="rtl"],[dir="rtl"] *){right:1rem}.s-order-edit-products-search-input{min-height:3rem;width:100%;border-radius:0.875rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding-left:1rem;padding-right:1rem;padding-top:0.875rem;padding-bottom:0.875rem;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1));transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:200ms}.s-order-edit-products-search-input:where([dir="ltr"],[dir="ltr"] *){padding-left:2.75rem;padding-right:1rem}.s-order-edit-products-search-input:where([dir="rtl"],[dir="rtl"] *){padding-right:2.75rem;padding-left:1rem}.s-order-edit-products-search-input:focus{--tw-border-opacity:1;border-color:rgb(17 24 39 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));--tw-shadow:0 0 0 3px rgba(17,24,39,0.08);--tw-shadow-colored:0 0 0 3px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}.s-order-edit-products-list{min-height:20rem}.s-order-edit-products-list .s-products-list-wrapper{gap:1rem;grid-template-columns:repeat(2,minmax(0,1fr))}@media (min-width: 769px){.s-order-edit-products-list .s-products-list-wrapper{grid-template-columns:repeat(3, minmax(0, 1fr))}}.s-order-edit-no-content-placeholder{display:flex;min-height:14rem;flex-direction:column;align-items:center;justify-content:center;gap:0.75rem;border-radius:0.875rem;border-width:1px;border-style:dashed;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding:2rem;text-align:center;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-no-content-placeholder .icon{font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-actions{position:sticky;bottom:1.5rem;display:flex;align-items:center;justify-content:space-between;gap:0.75rem;border-radius:0.875rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));background-color:rgba(255,255,255,0.94);padding:1rem;--tw-shadow:0 12px 30px rgba(15,23,42,0.08);--tw-shadow-colored:0 12px 30px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);--tw-backdrop-blur:blur(10px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}@media (max-width: 768px){.s-order-edit-actions{position:static;align-items:center;gap:0.5rem}}.s-order-edit-actions salla-button{flex:0 0 auto}@media (max-width: 768px){.s-order-edit-actions salla-button{display:block;flex:1 1 0;min-width:0}}.s-order-edit-mobile-products-trigger{display:none}@media (max-width: 768px){.s-order-edit-mobile-products-trigger{display:block}}.s-order-edit-mobile-products-trigger-icon:where([dir="ltr"],[dir="ltr"] *){margin-right:0.35rem}.s-order-edit-mobile-products-trigger-icon:where([dir="rtl"],[dir="rtl"] *){margin-left:0.35rem}.s-order-edit-mobile-products-modal .s-order-edit-products-list{max-height:min(24rem, calc(100vh - 11rem));min-height:22rem;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}@media (max-width: 480px){.s-order-edit-mobile-products-modal .s-order-edit-products-list{min-height:20rem;max-height:min(22rem, calc(100vh - 10rem))}}.s-order-edit-mobile-products-modal .products-list .s-products-list-wrapper{gap:0.625rem;grid-template-columns:repeat(2,minmax(0,1fr))}.s-order-edit-modal{display:flex;flex-direction:column;gap:1rem}.s-order-edit-modal-title{margin:0px;text-align:start;font-size:1.125rem;line-height:1.75rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-subtitle{margin:0px;margin-top:-0.75rem;text-align:start;font-size:0.875rem;line-height:1.25rem;line-height:1.5;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-items{display:flex;flex-direction:column;gap:0.75rem}.s-order-edit-modal-item{display:flex;align-items:center;justify-content:space-between;gap:1rem;border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-bottom:0.75rem}.s-order-edit-modal-item-start{display:flex;align-items:center;gap:0.75rem}.s-order-edit-modal-item-image{height:3rem;width:3rem;border-radius:0.75rem;object-fit:cover}.s-order-edit-modal-item-name{margin:0px;font-size:0.875rem;line-height:1.25rem;font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-item-options{font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-item-end{display:flex;align-items:center;gap:0.75rem}.s-order-edit-modal-item-price{font-size:0.875rem;line-height:1.25rem;font-weight:500}.s-order-edit-modal-item-quantity{font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-row{display:flex;align-items:center;justify-content:space-between;gap:1rem}.s-order-edit-modal-row-label{font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-row-value{font-weight:700}.s-order-edit-modal-tax-label{display:flex;align-items:center;gap:0.5rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-tax-icon{--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-modal-total{display:flex;align-items:center;justify-content:space-between;gap:1rem;border-top-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-top:0.75rem;font-weight:700;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-total-label{font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-total-value{font-size:1.25rem;line-height:1.75rem;font-weight:500}.s-order-edit-modal-refund{display:flex;align-items:flex-start;gap:1rem;border-radius:0.875rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));padding-left:1rem;padding-right:1rem;padding-top:0.875rem;padding-bottom:0.875rem;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-order-edit-modal-refund-icon{flex-shrink:0;font-size:1.125rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-refund-text{margin:0px;flex:1 1 0%;font-size:0.875rem;line-height:1.25rem}.s-order-edit-modal-btn-wrapper{margin-top:0.5rem;display:flex;justify-content:space-between}.s-order-edit-modal-btn-wrapper salla-button{width:100%}@media (min-width: 640px){.s-order-edit-modal-btn-wrapper salla-button{width:auto}}.s-order-edit-modal-btn-icon{vertical-align:middle;font-size:1.125rem;line-height:1.75rem}.s-order-edit-expired{display:flex;min-height:14rem;flex-direction:column;align-items:center;justify-content:center;gap:0.75rem;border-radius:0.875rem;border-width:1px;border-style:dashed;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding:2rem;text-align:center;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-expired .icon{font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal{display:flex;min-height:0px;flex:1 1 auto;flex-direction:column;gap:1rem}.s-order-edit-add-modal-content{display:flex;min-height:0px;flex:1 1 auto;flex-direction:column;gap:1rem}.s-order-edit-add-modal-loading{display:flex;min-height:12rem;flex:1 1 auto;align-items:center;justify-content:center}.s-order-edit-add-modal-header{border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-bottom:1rem}.s-order-edit-add-modal-media{display:flex;align-items:flex-start;gap:1rem}.s-order-edit-add-modal-image{height:5.5rem;width:5.5rem;border-radius:0.875rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));object-fit:cover}.s-order-edit-add-modal-details{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.35rem}.s-order-edit-add-modal-name{margin:0px;font-size:1rem;line-height:1.5rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal-price{font-size:0.95rem;font-weight:700;--tw-text-opacity:1;color:rgb(15 118 110 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal-quantity{display:flex;align-items:center;justify-content:space-between;gap:1rem}.s-order-edit-add-modal-section-title{margin:0px;font-size:0.9375rem;font-weight:600;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal-quantity-input{flex-shrink:0}.s-order-edit-add-modal-actions{margin-top:auto;display:flex;align-items:center;justify-content:space-between;gap:0.75rem;border-top-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding-top:1rem}.s-order-edit-add-modal-actions salla-button{min-width:4.75rem;flex:0 0 auto}.s-order-edit-item-header{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem}.s-order-edit-item-media{display:flex;min-width:0px;flex:1 1 0%;gap:1rem}@media (max-width: 640px){.s-order-edit-item-media{width:100%}}.s-order-edit-item-image{height:5.5rem;width:5.5rem;border-radius:0.875rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));object-fit:cover}.s-order-edit-item-details{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.35rem}.s-order-edit-item-name{margin:0px;font-size:1rem;line-height:1.5rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-item-link{color:inherit;text-decoration-line:none}.s-order-edit-item-price{font-size:0.95rem;font-weight:700;--tw-text-opacity:1;color:rgb(15 118 110 / var(--tw-text-opacity, 1))}.s-order-edit-item-weight{margin:0px;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-item-quantity{margin-top:1.25rem;display:flex;align-items:center;justify-content:space-between;gap:1rem;border-top-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-top:1rem}.s-order-edit-item-quantity-label{margin:0px;font-size:0.9375rem;font-weight:600;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-order-edit-item-quantity-input{flex-shrink:0}.s-order-edit-item-options{margin-top:1rem;display:block}.s-order-edit-product-card{display:flex;min-height:100%;width:100%;cursor:pointer;appearance:none;flex-direction:column;overflow:hidden;border-radius:0.875rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));text-align:start;--tw-shadow:0 10px 24px rgba(15,23,42,0.04);--tw-shadow-colored:0 10px 24px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:200ms}.s-order-edit-product-card:hover{--tw-translate-y:-2px;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-shadow:0 16px 30px rgba(15,23,42,0.08);--tw-shadow-colored:0 16px 30px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.s-order-edit-product-card:focus-visible{--tw-border-opacity:1;border-color:rgb(17 24 39 / var(--tw-border-opacity, 1));--tw-shadow:0 0 0 3px rgba(17,24,39,0.12);--tw-shadow-colored:0 0 0 3px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}@media (max-width: 768px){.s-order-edit-product-card{border-radius:0.75rem;box-shadow:0 6px 18px rgba(15, 23, 42, 0.05)}}.s-order-edit-product-card-media{display:flex;aspect-ratio:1 / 1;width:100%;flex-shrink:0;align-items:center;justify-content:center;overflow:hidden;background:linear-gradient(180deg,#f8fafc 0%,#f1f5f9 100%)}.s-order-edit-product-card-image{display:block;height:100%;width:100%;object-fit:cover}.s-order-edit-product-card-placeholder{display:flex;height:100%;width:100%;align-items:center;justify-content:center;font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-product-card-content{display:flex;flex:1 1 0%;flex-direction:column;gap:0.5rem;padding:1rem}@media (max-width: 768px){.s-order-edit-product-card-content{gap:0.25rem;padding:0.625rem}}.s-order-edit-product-card-title{margin:0px;font-size:0.95rem;font-weight:600;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}@media (max-width: 768px){.s-order-edit-product-card-title{display:-webkit-box;overflow:hidden;min-height:2.35rem;font-size:0.8125rem;line-height:1.45;-webkit-box-orient:vertical;-webkit-line-clamp:2}}.s-order-edit-product-card-price{margin:0px;font-size:1rem;line-height:1.5rem;font-weight:700;--tw-text-opacity:1;color:rgb(15 118 110 / var(--tw-text-opacity, 1))}@media (max-width: 768px){.s-order-edit-product-card-price{font-size:0.875rem}.s-order-edit-products-panel,.s-order-edit-order-panel{padding:1rem}.s-order-edit-actions salla-button .s-button-element{width:100%;min-width:0;padding-inline:0.5rem}.s-order-edit-mobile-products-modal .s-order-edit-products-modal-content{gap:0.75rem;padding:0.875rem}.s-order-edit-add-modal-media,.s-order-edit-add-modal-quantity{flex-direction:column;align-items:stretch}}';export{w as salla_order_edit}
@@ -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-5UtJVEzd.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:"78be7c4a3be811adb01cb1437473fcd9f1c17b41",class:"s-multiple-bundle-product-wrapper"},e("div",{key:"9b0439dffc9a2dd8d31f56dacb5d835cde903e71",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:"1ba2cde8fad73b16cfc2ccdd5e68331a9e3fdb7a",class:"s-multiple-bundle-product-wrapper"},e("div",{key:"a72d9fc9f3df30616d3d0696c755db4e76c9a153",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:"1e2f996c2d995c62ae29dedc90826a1f1d0a1320"}))}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-DaGqpYdk.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:"78be7c4a3be811adb01cb1437473fcd9f1c17b41",class:"s-multiple-bundle-product-wrapper"},e("div",{key:"9b0439dffc9a2dd8d31f56dacb5d835cde903e71",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:"1ba2cde8fad73b16cfc2ccdd5e68331a9e3fdb7a",class:"s-multiple-bundle-product-wrapper"},e("div",{key:"a72d9fc9f3df30616d3d0696c755db4e76c9a153",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:"1e2f996c2d995c62ae29dedc90826a1f1d0a1320"}))}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}
@@ -0,0 +1,4 @@
1
+ /*!
2
+ * Crafted with ❤ by Salla
3
+ */
4
+ import{r as t,h as i,H as e}from"./p-DaGqpYdk.js";import{f as s,g as a}from"./p-DqXpn47Z.js";const l=class{constructor(i){t(this,i),this.productRatings=[],this.allowUpdate=!1}async componentWillLoad(){await salla.onReady(),await this.loadOrderItem()}async onProductIdChange(){this.orderItem=void 0,this.productRatings=[],await this.loadOrderItem()}resolveFetchOrderId(){return salla.config.get("page.id")}sameId(t,i){return null!=t&&null!=i&&String(t)===String(i)}label(t,i){return"function"==typeof salla?.lang?.getWithDefault?salla.lang.getWithDefault(t,i):salla?.lang?.get?.(t)||i}toOrderItemRating(t){return{id:t.id??t.feedback_id,stars:t.stars??t.rating,content:t.content||"",is_pending:t.is_pending,can_update:t.can_update,images:t.images||[],videos:t.videos||[],product:t.product}}resolveOrderItem(t,i){const e=Array.isArray(t?.items)?t.items:[],s=i.find((t=>this.sameId(t.product?.id,this.productId)));if(!s)return;const a=e.find((t=>this.sameId(t.product?.id,this.productId)))||{product:s.product||{id:this.productId}};return{...a,product:a.product||s.product||{id:this.productId},rating:this.toOrderItemRating(s)}}async loadOrderItem(){const t=this.resolveFetchOrderId();if(t&&null!=this.productId&&""!==this.productId){this.fetchOrderId=t,this.allowUpdate=!!salla.config.get("store.settings.rating.allow_update");try{const i=await s(t);this.productRatings=a(i?.rating),this.orderItem=this.resolveOrderItem(i,this.productRatings)}catch(t){console.error("[salla-review-order-item] failed to load order item review",t)}}}renderActions(t){const e=t.rating;return e&&this.allowUpdate?i("div",{class:"rating-actions"},i("div",{class:"tooltip-toggle tooltip-toggle--hover icon-trigger mobile-shifted"},e.can_update?null:i("div",{class:"tooltip-content shadow-md rounded"},i("small",null,this.label("pages.order.edit_period_ended","انتهت مدة التعديل"),".")),i("salla-button",{"loader-position":"center",disabled:!e.can_update,shape:"icon",fill:"outline",color:"dark",size:"medium",onClick:()=>e.can_update?salla.event.dispatch("rating::edit",{type:"product",feedback_id:e.id}):void 0},i("i",{class:"sicon-format-border-color text-xl"}))),i("div",{class:"tooltip-toggle tooltip-toggle--hover icon-trigger mobile-shifted"},e.can_update?null:i("div",{class:"tooltip-content shadow-md rounded"},i("small",null,this.label("pages.order.delete_period_ended","انتهت مدة الحذف"),".")),i("salla-button",{"loader-position":"center",disabled:!e.can_update,shape:"icon",color:"danger",fill:"outline",size:"medium",onClick:()=>e.can_update?salla.event.dispatch("rating::delete",{feedback_id:e.id}):void 0},i("i",{class:"sicon-trash-2 text-xl"})))):null}serializeRatingMedia(t){return JSON.stringify({images:t.images||[],videos:t.videos||[],product:t.product})}serializeProductRatings(){return JSON.stringify(this.productRatings)}render(){const t=this.orderItem,s=t?.rating;return t&&s&&this.fetchOrderId?i(e,null,i("section",{class:"flex justify-between items-start border-t mt-10 pt-8"},i("div",null,i("p",{innerHTML:s.content||""}),s.is_pending?i("span",null,this.label("pages.rating.pending","قيد المراجعة")):null,i("div",{class:"flex flex-row flex-wrap gap-2"},i("salla-rating-stars",{size:"large",value:s.stars}),i("salla-review-factors-tags",{"order-id":this.fetchOrderId,"rating-id":s.id,"product-id":t.product?.id})),i("div",{class:"mt-2"},i("salla-attachments",{rating:this.serializeRatingMedia(s),"product-ratings":this.serializeProductRatings(),"product-id":t.product?.id??null}))),this.renderActions(t))):i(e,null)}static get watchers(){return{productId:["onProductIdChange"]}}};export{l as salla_review_order_item}
@@ -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 i}from"./p-5UtJVEzd.js";const r=class{constructor(e){t(this,e),this.dark=!1,this.commercialRegisterLabel="",this.freelanceLabel="",this.cachedChain=[],this.enforceVisibility=()=>{const t=this.hostEl;if(t&&t.isConnected&&this.getBadgeData()&&!this.isHostVisible(t))for(const e of this.getAncestorChain(t)){const t=getComputedStyle(e);"none"===t.display&&e.style.setProperty("display","flex","important"),"hidden"!==t.visibility&&"collapse"!==t.visibility||e.style.setProperty("visibility","visible","important"),parseFloat(t.opacity)<r.OPACITY_THRESHOLD&&e.style.setProperty("opacity","1","important"),"hidden"===t.contentVisibility&&e.style.setProperty("content-visibility","visible","important")}},this.runEnforce=()=>{this.clearEnforceTimers(),this.enforceVisibility()}}componentWillLoad(){this.initializeTranslations()}async componentDidLoad(){await salla.onReady(),this.isVisibilityEnforced()&&(this.setupVisibilityGuard(),this.scheduleEnforce())}componentDidRender(){this.scheduleEnforce()}disconnectedCallback(){this.attrObserver?.disconnect(),this.attrObserver=void 0,this.moveObserver?.disconnect(),this.moveObserver=void 0,this.cachedChain=[],this.clearEnforceTimers()}isVisibilityEnforced(){return"SA"===salla.config.get("store.store_country")}getAncestorChain(t){const e=[];let s=t;for(;s&&(e.push(s),s!==document.documentElement);)s=s.parentElement;return e}didChainChange(t){const e=this.getAncestorChain(t);if(e.length!==this.cachedChain.length)return!0;for(let t=0;t<e.length;t++)if(e[t]!==this.cachedChain[t])return!0;return!1}isHostVisible(t){return"function"==typeof t.checkVisibility?t.checkVisibility({contentVisibilityAuto:!0,opacityProperty:!0,visibilityProperty:!0}):this.isVisibleFallback(t)}isVisibleFallback(t){let e=t;for(;e;){const t=getComputedStyle(e);if("none"===t.display)return!1;if("hidden"===t.visibility||"collapse"===t.visibility)return!1;if(parseFloat(t.opacity)<r.OPACITY_THRESHOLD)return!1;if("hidden"===t.contentVisibility)return!1;if(e===document.documentElement)break;e=e.parentElement}return!0}clearEnforceTimers(){void 0!==this.enforceTimer&&(clearTimeout(this.enforceTimer),this.enforceTimer=void 0),void 0!==this.maxWaitTimer&&(clearTimeout(this.maxWaitTimer),this.maxWaitTimer=void 0)}scheduleEnforce(){this.isVisibilityEnforced()&&(void 0!==this.enforceTimer&&clearTimeout(this.enforceTimer),this.enforceTimer=setTimeout(this.runEnforce,r.ENFORCE_DEBOUNCE_MS),void 0===this.maxWaitTimer&&(this.maxWaitTimer=setTimeout(this.runEnforce,r.ENFORCE_MAX_WAIT_MS)))}setupVisibilityGuard(){const t=this.hostEl;t&&"undefined"!=typeof MutationObserver&&(this.attrObserver?.disconnect(),this.moveObserver?.disconnect(),this.attrObserver=new MutationObserver((()=>{const t=this.hostEl;t&&t.isConnected&&(this.isHostVisible(t)||this.scheduleEnforce())})),this.attachAttrObserver(t),this.moveObserver=new MutationObserver((()=>{const t=this.hostEl;t&&t.isConnected&&this.didChainChange(t)&&(this.attachAttrObserver(t),this.scheduleEnforce())})),this.moveObserver.observe(document.documentElement,{childList:!0,subtree:!0}))}attachAttrObserver(t){if(this.attrObserver){this.attrObserver.disconnect(),this.cachedChain=this.getAncestorChain(t);for(const t of this.cachedChain)this.attrObserver.observe(t,{attributes:!0,attributeFilter:["style","class","hidden"]})}}initializeTranslations(){salla.lang.onLoaded((()=>{const t=(t,e,s)=>{salla.helpers.setNested(salla.lang.messages[t],e,s)};t("ar.trans","blocks.footer.commercial_register","السجل التجاري"),t("en.trans","blocks.footer.commercial_register","Commercial Register"),t("ar.trans","blocks.footer.freelance","وثيقة العمل الحر"),t("en.trans","blocks.footer.freelance","Freelance Certificate"),this.commercialRegisterLabel=salla.lang.getWithDefault("blocks.footer.commercial_register","السجل التجاري"),this.freelanceLabel=salla.lang.getWithDefault("blocks.footer.freelance","وثيقة العمل الحر")}))}getBadgeData(){const t=salla.config.get("store.settings.commercial_number"),e=salla.config.get("store.settings.freelance_number");return t?{number:t,label:this.commercialRegisterLabel||"السجل التجاري",imageUrl:salla.url.cdn("images/commercial-register.png",70,70),type:"commercial"}:e?{number:e,label:this.freelanceLabel||"وثيقة العمل الحر",imageUrl:this.dark?salla.url.cdn("images/freelance-white.png"):salla.url.cdn("images/freelance.png"),type:"freelance"}:null}render(){const t=this.getBadgeData();return t?e(s,{class:"s-trust-badges-wrapper "+(this.dark?"dark":"")},this.isVisibilityEnforced()?e("img",{class:"s-trust-badges-image",width:"55",height:"55",src:t.imageUrl,alt:t.label}):null,e("div",{class:"s-trust-badges-content"},e("p",{class:"s-trust-badges-label"},t.label),e("b",{class:"s-trust-badges-number"},t.number))):null}get hostEl(){return i(this)}};r.OPACITY_THRESHOLD=.1,r.ENFORCE_DEBOUNCE_MS=1500,r.ENFORCE_MAX_WAIT_MS=3e3,r.style='/*!twlt*/.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.flex{display:flex}.hidden{display:none}.s-trust-badges-wrapper{display:flex;align-items:center}.s-trust-badges-wrapper>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(0.5rem * var(--tw-space-x-reverse));margin-left:calc(0.5rem * calc(1 - var(--tw-space-x-reverse)))}.s-trust-badges-wrapper:where([dir="rtl"],[dir="rtl"] *)>:not([hidden])~:not([hidden]){--tw-space-x-reverse:1}.s-trust-badges-label{margin-bottom:0.25rem;font-size:0.875rem;line-height:1.25rem}.s-trust-badges-number{font-size:0.875rem;line-height:1.25rem}';export{r as salla_trust_badges}
4
+ import{r as t,h as e,H as s,a as i}from"./p-DaGqpYdk.js";const r=class{constructor(e){t(this,e),this.dark=!1,this.commercialRegisterLabel="",this.freelanceLabel="",this.cachedChain=[],this.enforceVisibility=()=>{const t=this.hostEl;if(t&&t.isConnected&&this.getBadgeData()&&!this.isHostVisible(t))for(const e of this.getAncestorChain(t)){const t=getComputedStyle(e);"none"===t.display&&e.style.setProperty("display","flex","important"),"hidden"!==t.visibility&&"collapse"!==t.visibility||e.style.setProperty("visibility","visible","important"),parseFloat(t.opacity)<r.OPACITY_THRESHOLD&&e.style.setProperty("opacity","1","important"),"hidden"===t.contentVisibility&&e.style.setProperty("content-visibility","visible","important")}},this.runEnforce=()=>{this.clearEnforceTimers(),this.enforceVisibility()}}componentWillLoad(){this.initializeTranslations()}async componentDidLoad(){await salla.onReady(),this.isVisibilityEnforced()&&(this.setupVisibilityGuard(),this.scheduleEnforce())}componentDidRender(){this.scheduleEnforce()}disconnectedCallback(){this.attrObserver?.disconnect(),this.attrObserver=void 0,this.moveObserver?.disconnect(),this.moveObserver=void 0,this.cachedChain=[],this.clearEnforceTimers()}isVisibilityEnforced(){return"SA"===salla.config.get("store.store_country")}getAncestorChain(t){const e=[];let s=t;for(;s&&(e.push(s),s!==document.documentElement);)s=s.parentElement;return e}didChainChange(t){const e=this.getAncestorChain(t);if(e.length!==this.cachedChain.length)return!0;for(let t=0;t<e.length;t++)if(e[t]!==this.cachedChain[t])return!0;return!1}isHostVisible(t){return"function"==typeof t.checkVisibility?t.checkVisibility({contentVisibilityAuto:!0,opacityProperty:!0,visibilityProperty:!0}):this.isVisibleFallback(t)}isVisibleFallback(t){let e=t;for(;e;){const t=getComputedStyle(e);if("none"===t.display)return!1;if("hidden"===t.visibility||"collapse"===t.visibility)return!1;if(parseFloat(t.opacity)<r.OPACITY_THRESHOLD)return!1;if("hidden"===t.contentVisibility)return!1;if(e===document.documentElement)break;e=e.parentElement}return!0}clearEnforceTimers(){void 0!==this.enforceTimer&&(clearTimeout(this.enforceTimer),this.enforceTimer=void 0),void 0!==this.maxWaitTimer&&(clearTimeout(this.maxWaitTimer),this.maxWaitTimer=void 0)}scheduleEnforce(){this.isVisibilityEnforced()&&(void 0!==this.enforceTimer&&clearTimeout(this.enforceTimer),this.enforceTimer=setTimeout(this.runEnforce,r.ENFORCE_DEBOUNCE_MS),void 0===this.maxWaitTimer&&(this.maxWaitTimer=setTimeout(this.runEnforce,r.ENFORCE_MAX_WAIT_MS)))}setupVisibilityGuard(){const t=this.hostEl;t&&"undefined"!=typeof MutationObserver&&(this.attrObserver?.disconnect(),this.moveObserver?.disconnect(),this.attrObserver=new MutationObserver((()=>{const t=this.hostEl;t&&t.isConnected&&(this.isHostVisible(t)||this.scheduleEnforce())})),this.attachAttrObserver(t),this.moveObserver=new MutationObserver((()=>{const t=this.hostEl;t&&t.isConnected&&this.didChainChange(t)&&(this.attachAttrObserver(t),this.scheduleEnforce())})),this.moveObserver.observe(document.documentElement,{childList:!0,subtree:!0}))}attachAttrObserver(t){if(this.attrObserver){this.attrObserver.disconnect(),this.cachedChain=this.getAncestorChain(t);for(const t of this.cachedChain)this.attrObserver.observe(t,{attributes:!0,attributeFilter:["style","class","hidden"]})}}initializeTranslations(){salla.lang.onLoaded((()=>{const t=(t,e,s)=>{salla.helpers.setNested(salla.lang.messages[t],e,s)};t("ar.trans","blocks.footer.commercial_register","السجل التجاري"),t("en.trans","blocks.footer.commercial_register","Commercial Register"),t("ar.trans","blocks.footer.freelance","وثيقة العمل الحر"),t("en.trans","blocks.footer.freelance","Freelance Certificate"),this.commercialRegisterLabel=salla.lang.getWithDefault("blocks.footer.commercial_register","السجل التجاري"),this.freelanceLabel=salla.lang.getWithDefault("blocks.footer.freelance","وثيقة العمل الحر")}))}getBadgeData(){const t=salla.config.get("store.settings.commercial_number"),e=salla.config.get("store.settings.freelance_number");return t?{number:t,label:this.commercialRegisterLabel||"السجل التجاري",imageUrl:salla.url.cdn("images/commercial-register.png",70,70),type:"commercial"}:e?{number:e,label:this.freelanceLabel||"وثيقة العمل الحر",imageUrl:this.dark?salla.url.cdn("images/freelance-white.png"):salla.url.cdn("images/freelance.png"),type:"freelance"}:null}render(){const t=this.getBadgeData();return t?e(s,{class:"s-trust-badges-wrapper "+(this.dark?"dark":"")},this.isVisibilityEnforced()?e("img",{class:"s-trust-badges-image",width:"55",height:"55",src:t.imageUrl,alt:t.label}):null,e("div",{class:"s-trust-badges-content"},e("p",{class:"s-trust-badges-label"},t.label),e("b",{class:"s-trust-badges-number"},t.number))):null}get hostEl(){return i(this)}};r.OPACITY_THRESHOLD=.1,r.ENFORCE_DEBOUNCE_MS=1500,r.ENFORCE_MAX_WAIT_MS=3e3,r.style='/*!twlt*/.visible{visibility:visible}.collapse{visibility:collapse}.static{position:static}.flex{display:flex}.hidden{display:none}.s-trust-badges-wrapper{display:flex;align-items:center}.s-trust-badges-wrapper>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(0.5rem * var(--tw-space-x-reverse));margin-left:calc(0.5rem * calc(1 - var(--tw-space-x-reverse)))}.s-trust-badges-wrapper:where([dir="rtl"],[dir="rtl"] *)>:not([hidden])~:not([hidden]){--tw-space-x-reverse:1}.s-trust-badges-label{margin-bottom:0.25rem;font-size:0.875rem;line-height:1.25rem}.s-trust-badges-number{font-size:0.875rem;line-height:1.25rem}';export{r as salla_trust_badges}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,h as s,H as a}from"./p-5UtJVEzd.js";const l=class{constructor(s){t(this,s),this.order=null,this.loading=!0}async componentWillLoad(){await salla.onReady(),await this.loadOrder()}async onOrderIdChange(){this.loading=!0,this.order=null,await this.loadOrder()}get paymentUrl(){return this.order?.customer_editing?.payment_url}async loadOrder(){const t=this.orderId||salla.config.get("page.id");if(t)try{const s=await salla.order.api.getDetails(t);this.order=s?.data??s??null}catch(t){salla.logger?.warn?.("[salla-edit-order-button] failed to fetch order details",t),this.order=null}finally{this.loading=!1}else this.loading=!1}renderEditButton(){return s("salla-count-down",{prefixText:salla.lang.getWithDefault("pages.orders.edit_within","يمكنك التعديل خلال"),buttonHref:this.order?.edit_url,buttonText:salla.lang.getWithDefault("pages.orders.edit_order","تعديل الطلب"),buttonIcon:"sicon-edit",date:this.order?.editable_until,horizontal:!0,autoSegments:!0,withButton:!0,labeled:!1,size:"sm",color:"primary"})}render(){return this.loading||!this.order?null:this.order?.is_editable?s(a,null,this.renderEditButton()):this.paymentUrl?s(a,null,s("salla-button",{href:this.paymentUrl,color:"primary",size:"small"},s("i",{class:"sicon-wallet"}),salla.lang.getWithDefault("pages.orders.pay_difference","دفع فارق المبلغ"))):null}static get watchers(){return{orderId:["onOrderIdChange"]}}};l.style="/*!twlt*/:host{display:block}";export{l as salla_edit_order_button}
4
+ import{r as t,h as s,H as a}from"./p-DaGqpYdk.js";const l=class{constructor(s){t(this,s),this.order=null,this.loading=!0}async componentWillLoad(){await salla.onReady(),await this.loadOrder()}async onOrderIdChange(){this.loading=!0,this.order=null,await this.loadOrder()}get paymentUrl(){return this.order?.customer_editing?.payment_url}async loadOrder(){const t=this.orderId||salla.config.get("page.id");if(t)try{const s=await salla.order.api.getDetails(t);this.order=s?.data??s??null}catch(t){salla.logger?.warn?.("[salla-edit-order-button] failed to fetch order details",t),this.order=null}finally{this.loading=!1}else this.loading=!1}renderEditButton(){return s("salla-count-down",{prefixText:salla.lang.getWithDefault("pages.orders.edit_within","يمكنك التعديل خلال"),buttonHref:this.order?.edit_url,buttonText:salla.lang.getWithDefault("pages.orders.edit_order","تعديل الطلب"),buttonIcon:"sicon-edit",date:this.order?.editable_until,horizontal:!0,autoSegments:!0,withButton:!0,labeled:!1,size:"sm",color:"primary"})}render(){return this.loading||!this.order?null:this.order?.is_editable?s(a,null,this.renderEditButton()):this.paymentUrl?s(a,null,s("salla-button",{href:this.paymentUrl,color:"primary",size:"small"},s("i",{class:"sicon-wallet"}),salla.lang.getWithDefault("pages.orders.pay_difference","دفع فارق المبلغ"))):null}static get watchers(){return{orderId:["onOrderIdChange"]}}};l.style="/*!twlt*/:host{display:block}";export{l as salla_edit_order_button}