@salla.sa/twilight-components 2.14.412 → 2.14.414

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 (298) hide show
  1. package/dist/cjs/{filepond-BO-XBD1i.js → filepond-Dp_H5r_e.js} +1 -1
  2. package/dist/cjs/{filepond-plugin-file-poster-DJIG7vOj.js → filepond-plugin-file-poster-BhLJq633.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-validate-size-Bhtuy-Ar.js → filepond-plugin-file-validate-size-Bzp5Z1pf.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-type-BQhRvZvr.js → filepond-plugin-file-validate-type-ClWX5bbr.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-image-edit-C4unOPfE.js → filepond-plugin-image-edit-CQZ3PQWR.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-exif-orientation-QreJIoqS.js → filepond-plugin-image-exif-orientation-NA--NS7o.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-preview-aiURUVDo.js → filepond-plugin-image-preview-C9HHOV4A.js} +1 -1
  8. package/dist/cjs/{functions-qbO9xyMC.js → functions-PtQY5Mwc.js} +1 -1
  9. package/dist/cjs/{index-BtHm_lmK.js → index-B-m5HL7n.js} +1 -1
  10. package/dist/cjs/{index-DR2nrv6V.js → index-BV8LF8_q.js} +2 -2
  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 +5 -2
  14. package/dist/cjs/salla-add-product-button_5.cjs.entry.js +2 -2
  15. package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
  16. package/dist/cjs/salla-alert_2.cjs.entry.js +1 -1
  17. package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
  18. package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
  19. package/dist/cjs/salla-badge.cjs.entry.js +1 -1
  20. package/dist/cjs/salla-booking-field_7.cjs.entry.js +10 -10
  21. package/dist/cjs/salla-bullet-delivery.cjs.entry.js +1 -1
  22. package/dist/cjs/salla-cart-coupons.cjs.entry.js +1 -1
  23. package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +10 -6
  24. package/dist/cjs/salla-comment-form_8.cjs.entry.js +1 -1
  25. package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
  26. package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
  27. package/dist/cjs/salla-cookies-bar.cjs.entry.js +1 -1
  28. package/dist/cjs/salla-count-down.cjs.entry.js +1 -1
  29. package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
  30. package/dist/cjs/salla-delivery-promise.cjs.entry.js +1 -1
  31. package/dist/cjs/salla-edit-order-button.cjs.entry.js +1 -1
  32. package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
  33. package/dist/cjs/salla-filters.cjs.entry.js +1 -1
  34. package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +1 -1
  35. package/dist/cjs/salla-gifting.cjs.entry.js +1 -1
  36. package/dist/cjs/salla-hook.cjs.entry.js +1 -1
  37. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
  38. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  39. package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
  40. package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
  41. package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
  42. package/dist/cjs/salla-loyalty-banner.cjs.entry.js +2 -2
  43. package/dist/cjs/salla-loyalty-hero_2.cjs.entry.js +2 -2
  44. package/dist/cjs/salla-loyalty-panel.cjs.entry.js +3 -3
  45. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  46. package/dist/cjs/salla-loyalty-program.cjs.entry.js +3 -3
  47. package/dist/cjs/salla-loyalty-reward.cjs.entry.js +2 -2
  48. package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
  49. package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
  50. package/dist/cjs/salla-map.cjs.entry.js +1 -1
  51. package/dist/cjs/salla-menu.cjs.entry.js +1 -1
  52. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  53. package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
  54. package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
  55. package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
  56. package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
  57. package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
  58. package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
  59. package/dist/cjs/salla-offer.cjs.entry.js +1 -1
  60. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
  61. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  62. package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
  63. package/dist/cjs/salla-order-edit-item.cjs.entry.js +1 -1
  64. package/dist/cjs/salla-order-edit.cjs.entry.js +1 -1
  65. package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
  66. package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
  67. package/dist/cjs/salla-orders.cjs.entry.js +1 -1
  68. package/dist/cjs/salla-payments.cjs.entry.js +1 -1
  69. package/dist/cjs/salla-placeholder.cjs.entry.js +1 -1
  70. package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
  71. package/dist/cjs/salla-product-card_2.cjs.entry.js +1 -1
  72. package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
  73. package/dist/cjs/salla-products-list.cjs.entry.js +1 -1
  74. package/dist/cjs/salla-progress-bar.cjs.entry.js +1 -1
  75. package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
  76. package/dist/cjs/salla-rating-modal.cjs.entry.js +1 -1
  77. package/dist/cjs/salla-reward-action_4.cjs.entry.js +3 -3
  78. package/dist/cjs/salla-scopes.cjs.entry.js +1 -1
  79. package/dist/cjs/salla-search.cjs.entry.js +1 -1
  80. package/dist/cjs/salla-skeleton.cjs.entry.js +1 -1
  81. package/dist/cjs/salla-slider.cjs.entry.js +1 -1
  82. package/dist/cjs/salla-social-share.cjs.entry.js +1 -1
  83. package/dist/cjs/salla-social.cjs.entry.js +1 -1
  84. package/dist/cjs/salla-tab-content_3.cjs.entry.js +1 -1
  85. package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
  86. package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
  87. package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
  88. package/dist/cjs/salla-user-menu.cjs.entry.js +1 -1
  89. package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
  90. package/dist/cjs/salla-user-settings.cjs.entry.js +1 -1
  91. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  92. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  93. package/dist/cjs/{tracked-promise-Dlrrx6bS.js → tracked-promise-D3TH8tBr.js} +1 -1
  94. package/dist/cjs/twilight.cjs.js +2 -2
  95. package/dist/cjs/{vanilla-picker-BgvVWFWW.js → vanilla-picker-BzsL3dA6.js} +1 -1
  96. package/dist/collection/components/salla-bought-together/salla-bought-together.css +136 -0
  97. package/dist/collection/components/salla-breadcrumb/salla-breadcrumb.js +4 -1
  98. package/dist/collection/components/salla-cart-item-offers/salla-cart-item-offers.js +12 -8
  99. package/dist/components/index.js +2 -2
  100. package/dist/components/salla-bought-together.js +1 -1
  101. package/dist/components/salla-breadcrumb.js +4 -1
  102. package/dist/components/salla-cart-item-offers.js +10 -6
  103. package/dist/esm/{filepond-BdAJ1Q3U.js → filepond-DePctYW6.js} +1 -1
  104. package/dist/esm/{filepond-plugin-file-poster-_P46glp3.js → filepond-plugin-file-poster-BLTrMyXv.js} +1 -1
  105. package/dist/esm/{filepond-plugin-file-validate-size-Cs7iDcpm.js → filepond-plugin-file-validate-size-DS-qwPwO.js} +1 -1
  106. package/dist/esm/{filepond-plugin-file-validate-type-BokfkNG5.js → filepond-plugin-file-validate-type-C5a7dkS0.js} +1 -1
  107. package/dist/esm/{filepond-plugin-image-edit-DqujritR.js → filepond-plugin-image-edit-Bn3oms-h.js} +1 -1
  108. package/dist/esm/{filepond-plugin-image-exif-orientation-CTqsgDyW.js → filepond-plugin-image-exif-orientation-C5xozSoC.js} +1 -1
  109. package/dist/esm/{filepond-plugin-image-preview-zoBFIa44.js → filepond-plugin-image-preview-e9o-BI5K.js} +1 -1
  110. package/dist/esm/{functions-CEdm6lBq.js → functions-avO3JHt1.js} +1 -1
  111. package/dist/esm/{index-eYsXdqjv.js → index-6ZT_-rrT.js} +2 -2
  112. package/dist/esm/{index-DXkuZzsm.js → index-DLd2oDnH.js} +1 -1
  113. package/dist/esm/loader.js +3 -3
  114. package/dist/esm/salla-accordion-body_2.entry.js +1 -1
  115. package/dist/esm/salla-accordion_6.entry.js +5 -2
  116. package/dist/esm/salla-add-product-button_5.entry.js +2 -2
  117. package/dist/esm/salla-advertisement.entry.js +1 -1
  118. package/dist/esm/salla-alert_2.entry.js +1 -1
  119. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  120. package/dist/esm/salla-apps-icons.entry.js +1 -1
  121. package/dist/esm/salla-badge.entry.js +1 -1
  122. package/dist/esm/salla-booking-field_7.entry.js +10 -10
  123. package/dist/esm/salla-bullet-delivery.entry.js +1 -1
  124. package/dist/esm/salla-cart-coupons.entry.js +1 -1
  125. package/dist/esm/salla-cart-item-offers_2.entry.js +10 -6
  126. package/dist/esm/salla-comment-form_8.entry.js +1 -1
  127. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  128. package/dist/esm/salla-contacts.entry.js +1 -1
  129. package/dist/esm/salla-cookies-bar.entry.js +1 -1
  130. package/dist/esm/salla-count-down.entry.js +1 -1
  131. package/dist/esm/salla-custom-fields.entry.js +1 -1
  132. package/dist/esm/salla-delivery-promise.entry.js +1 -1
  133. package/dist/esm/salla-edit-order-button.entry.js +1 -1
  134. package/dist/esm/salla-filters-widget.entry.js +1 -1
  135. package/dist/esm/salla-filters.entry.js +1 -1
  136. package/dist/esm/salla-fulfillment-methods.entry.js +1 -1
  137. package/dist/esm/salla-gifting.entry.js +1 -1
  138. package/dist/esm/salla-hook.entry.js +1 -1
  139. package/dist/esm/salla-infinite-scroll.entry.js +1 -1
  140. package/dist/esm/salla-installment.entry.js +1 -1
  141. package/dist/esm/salla-list-tile.entry.js +1 -1
  142. package/dist/esm/salla-localization-modal.entry.js +1 -1
  143. package/dist/esm/salla-login-modal.entry.js +1 -1
  144. package/dist/esm/salla-loyalty-banner.entry.js +2 -2
  145. package/dist/esm/salla-loyalty-hero_2.entry.js +2 -2
  146. package/dist/esm/salla-loyalty-panel.entry.js +3 -3
  147. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  148. package/dist/esm/salla-loyalty-program.entry.js +3 -3
  149. package/dist/esm/salla-loyalty-reward.entry.js +2 -2
  150. package/dist/esm/salla-loyalty.entry.js +1 -1
  151. package/dist/esm/salla-maintenance-alert.entry.js +1 -1
  152. package/dist/esm/salla-map.entry.js +1 -1
  153. package/dist/esm/salla-menu.entry.js +1 -1
  154. package/dist/esm/salla-metadata.entry.js +1 -1
  155. package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
  156. package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
  157. package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
  158. package/dist/esm/salla-notification-item.entry.js +1 -1
  159. package/dist/esm/salla-notifications.entry.js +1 -1
  160. package/dist/esm/salla-offer-modal.entry.js +1 -1
  161. package/dist/esm/salla-offer.entry.js +1 -1
  162. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  163. package/dist/esm/salla-order-details-options.entry.js +1 -1
  164. package/dist/esm/salla-order-details.entry.js +1 -1
  165. package/dist/esm/salla-order-edit-item.entry.js +1 -1
  166. package/dist/esm/salla-order-edit.entry.js +1 -1
  167. package/dist/esm/salla-order-summary.entry.js +1 -1
  168. package/dist/esm/salla-order-totals-card.entry.js +1 -1
  169. package/dist/esm/salla-orders.entry.js +1 -1
  170. package/dist/esm/salla-payments.entry.js +1 -1
  171. package/dist/esm/salla-placeholder.entry.js +1 -1
  172. package/dist/esm/salla-price-range.entry.js +1 -1
  173. package/dist/esm/salla-product-card_2.entry.js +1 -1
  174. package/dist/esm/salla-product-size-guide.entry.js +1 -1
  175. package/dist/esm/salla-products-list.entry.js +1 -1
  176. package/dist/esm/salla-progress-bar.entry.js +1 -1
  177. package/dist/esm/salla-quick-order.entry.js +1 -1
  178. package/dist/esm/salla-rating-modal.entry.js +1 -1
  179. package/dist/esm/salla-reward-action_4.entry.js +3 -3
  180. package/dist/esm/salla-scopes.entry.js +1 -1
  181. package/dist/esm/salla-search.entry.js +1 -1
  182. package/dist/esm/salla-skeleton.entry.js +1 -1
  183. package/dist/esm/salla-slider.entry.js +1 -1
  184. package/dist/esm/salla-social-share.entry.js +1 -1
  185. package/dist/esm/salla-social.entry.js +1 -1
  186. package/dist/esm/salla-tab-content_3.entry.js +1 -1
  187. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  188. package/dist/esm/salla-tooltip.entry.js +1 -1
  189. package/dist/esm/salla-trust-badges.entry.js +1 -1
  190. package/dist/esm/salla-user-menu.entry.js +1 -1
  191. package/dist/esm/salla-user-profile.entry.js +1 -1
  192. package/dist/esm/salla-user-settings.entry.js +1 -1
  193. package/dist/esm/salla-verify.entry.js +1 -1
  194. package/dist/esm/salla-wallet.entry.js +1 -1
  195. package/dist/esm/{tracked-promise-DC9Saija.js → tracked-promise-BCWK9qFO.js} +1 -1
  196. package/dist/esm/twilight.js +3 -3
  197. package/dist/esm/{vanilla-picker-DdyyxtyV.js → vanilla-picker-DWxX7cio.js} +1 -1
  198. package/dist/twilight/{p-12e78aef.entry.js → p-03ec20de.entry.js} +1 -1
  199. package/dist/twilight/{p-c6a56a0c.entry.js → p-083e1a33.entry.js} +1 -1
  200. package/dist/twilight/{p-98dfc58c.entry.js → p-09f2c951.entry.js} +1 -1
  201. package/dist/twilight/{p-9fea03ff.entry.js → p-0d2707d1.entry.js} +1 -1
  202. package/dist/twilight/{p-3dd609ff.entry.js → p-0ee39d71.entry.js} +1 -1
  203. package/dist/twilight/{p-0c773a98.entry.js → p-0efac7e2.entry.js} +1 -1
  204. package/dist/twilight/{p-809d8765.entry.js → p-11c9a417.entry.js} +1 -1
  205. package/dist/twilight/{p-82fc9f8a.entry.js → p-15e2e287.entry.js} +1 -1
  206. package/dist/twilight/{p-cf4c9420.entry.js → p-15f6bb69.entry.js} +1 -1
  207. package/dist/twilight/{p-6ffe96cf.entry.js → p-16c2826c.entry.js} +1 -1
  208. package/dist/twilight/{p-eadaf058.entry.js → p-19615f59.entry.js} +1 -1
  209. package/dist/twilight/p-19af24cd.entry.js +4 -0
  210. package/dist/twilight/{p-c8b8ea5c.entry.js → p-1affa2bf.entry.js} +1 -1
  211. package/dist/twilight/{p-9da33e90.entry.js → p-20764356.entry.js} +1 -1
  212. package/dist/twilight/{p-046ef0cf.entry.js → p-20cfe41f.entry.js} +1 -1
  213. package/dist/twilight/{p-d6a5df0d.entry.js → p-29463486.entry.js} +1 -1
  214. package/dist/twilight/{p-18428cad.entry.js → p-297cd58e.entry.js} +1 -1
  215. package/dist/twilight/{p-0b6cfdc6.entry.js → p-29ff944d.entry.js} +1 -1
  216. package/dist/twilight/{p-b258ef5c.entry.js → p-2caf7100.entry.js} +1 -1
  217. package/dist/twilight/{p-1f18bb8c.entry.js → p-2f1157d9.entry.js} +1 -1
  218. package/dist/twilight/{p-18e4e822.entry.js → p-33498ca4.entry.js} +1 -1
  219. package/dist/twilight/{p-28a276b7.entry.js → p-352a6706.entry.js} +1 -1
  220. package/dist/twilight/p-35449c67.entry.js +4 -0
  221. package/dist/twilight/{p-dbe6cc9c.entry.js → p-356df60b.entry.js} +1 -1
  222. package/dist/twilight/{p-92ee979a.entry.js → p-3763e5ac.entry.js} +1 -1
  223. package/dist/twilight/{p-70e26072.entry.js → p-3e5e5939.entry.js} +1 -1
  224. package/dist/twilight/{p-371ea2ac.entry.js → p-48f1953b.entry.js} +1 -1
  225. package/dist/twilight/{p-2beb780e.entry.js → p-4a654724.entry.js} +1 -1
  226. package/dist/twilight/{p-2d29eae4.entry.js → p-4ad1939b.entry.js} +1 -1
  227. package/dist/twilight/{p-083bfceb.entry.js → p-4b3cd6e7.entry.js} +1 -1
  228. package/dist/twilight/{p-ff972c8b.entry.js → p-4b55f671.entry.js} +1 -1
  229. package/dist/twilight/{p-3a0482aa.entry.js → p-4c9e53ef.entry.js} +1 -1
  230. package/dist/twilight/{p-fea8186b.entry.js → p-4cc69951.entry.js} +1 -1
  231. package/dist/twilight/{p-2ea91f4d.entry.js → p-4f4a9efe.entry.js} +1 -1
  232. package/dist/twilight/{p-880974c0.entry.js → p-4fccc704.entry.js} +1 -1
  233. package/dist/twilight/{p-0fee8df2.entry.js → p-515958ec.entry.js} +1 -1
  234. package/dist/twilight/{p-c0ea9ff2.entry.js → p-5333d535.entry.js} +1 -1
  235. package/dist/twilight/{p-cb5fbe10.entry.js → p-59e89ee3.entry.js} +1 -1
  236. package/dist/twilight/{p-38df842f.entry.js → p-603b88a8.entry.js} +1 -1
  237. package/dist/twilight/p-611b6487.entry.js +4 -0
  238. package/dist/twilight/{p-d400841e.entry.js → p-6673ee84.entry.js} +1 -1
  239. package/dist/twilight/{p-eYsXdqjv.js → p-6ZT_-rrT.js} +1 -1
  240. package/dist/twilight/{p-914ef875.entry.js → p-6d3fdd76.entry.js} +1 -1
  241. package/dist/twilight/{p-d6a86efa.entry.js → p-7060d38e.entry.js} +1 -1
  242. package/dist/twilight/{p-d49fd79d.entry.js → p-78e1c27b.entry.js} +1 -1
  243. package/dist/twilight/{p-c8821c21.entry.js → p-7f9cf58a.entry.js} +1 -1
  244. package/dist/twilight/{p-18046a80.entry.js → p-80f95744.entry.js} +1 -1
  245. package/dist/twilight/{p-78b27b6f.entry.js → p-861203e4.entry.js} +1 -1
  246. package/dist/twilight/{p-e89e8a20.entry.js → p-87ba43f4.entry.js} +1 -1
  247. package/dist/twilight/{p-c8f6bc81.entry.js → p-881a00c8.entry.js} +1 -1
  248. package/dist/twilight/{p-040057c7.entry.js → p-89409e62.entry.js} +1 -1
  249. package/dist/twilight/{p-67b3a063.entry.js → p-8ae540e2.entry.js} +1 -1
  250. package/dist/twilight/{p-1c2c212f.entry.js → p-8f8045fa.entry.js} +1 -1
  251. package/dist/twilight/{p-569db60a.entry.js → p-9436c499.entry.js} +1 -1
  252. package/dist/twilight/{p-e2cec9f6.entry.js → p-95ff5c23.entry.js} +1 -1
  253. package/dist/twilight/{p-92c3525a.entry.js → p-969c474d.entry.js} +1 -1
  254. package/dist/twilight/{p-ba81b8d6.entry.js → p-97277641.entry.js} +1 -1
  255. package/dist/twilight/{p-4rGFyB1b.js → p-BbupQHPq.js} +1 -1
  256. package/dist/twilight/{p-BrL7ZFF-.js → p-BwkVGCUs.js} +1 -1
  257. package/dist/twilight/{p-CdKOsdhF.js → p-C3wnAzO7.js} +1 -1
  258. package/dist/twilight/{p-CZP8nF-D.js → p-C4Sm8mDk.js} +1 -1
  259. package/dist/twilight/{p-Bt5MNLrr.js → p-C5kLhs7f.js} +1 -1
  260. package/dist/twilight/{p-DgUXy-oM.js → p-CZCe7gL1.js} +1 -1
  261. package/dist/twilight/{p-B-gehnpX.js → p-CaURqicX.js} +1 -1
  262. package/dist/twilight/{p-CdQPD_4N.js → p-Ce_mZAOv.js} +1 -1
  263. package/dist/twilight/{p-CkMgy4QX.js → p-DU8NQm6S.js} +1 -1
  264. package/dist/twilight/{p-C4iKSe6r.js → p-DZCJAoVw.js} +2 -2
  265. package/dist/twilight/{p-VP7525fx.js → p-RUoY6zEi.js} +1 -1
  266. package/dist/twilight/{p-86494434.entry.js → p-a0db4ef2.entry.js} +1 -1
  267. package/dist/twilight/{p-a97da8bc.entry.js → p-a326832f.entry.js} +1 -1
  268. package/dist/twilight/{p-e5e1574f.entry.js → p-a5c01307.entry.js} +1 -1
  269. package/dist/twilight/{p-c38311a2.entry.js → p-af2fb7b2.entry.js} +1 -1
  270. package/dist/twilight/{p-24121404.entry.js → p-af7a4f68.entry.js} +1 -1
  271. package/dist/twilight/{p-b04f3b37.entry.js → p-afdccf8a.entry.js} +1 -1
  272. package/dist/twilight/{p-1d9e9e5e.entry.js → p-b05422f7.entry.js} +1 -1
  273. package/dist/twilight/{p-f3d76113.entry.js → p-b1137d6a.entry.js} +1 -1
  274. package/dist/twilight/{p-a74e2625.entry.js → p-b30e4954.entry.js} +1 -1
  275. package/dist/twilight/{p-a0792c90.entry.js → p-b5cada55.entry.js} +1 -1
  276. package/dist/twilight/{p-f3105e54.entry.js → p-b6ee8954.entry.js} +1 -1
  277. package/dist/twilight/{p-f267b033.entry.js → p-c2eaa583.entry.js} +1 -1
  278. package/dist/twilight/{p-63b091c3.entry.js → p-c98464bd.entry.js} +1 -1
  279. package/dist/twilight/{p-82d315dc.entry.js → p-ccbc611f.entry.js} +1 -1
  280. package/dist/twilight/{p-faae4443.entry.js → p-d02e8b25.entry.js} +1 -1
  281. package/dist/twilight/{p-4c7e5ca7.entry.js → p-d75c4d8f.entry.js} +1 -1
  282. package/dist/twilight/{p-bab9b1ad.entry.js → p-de2d21e1.entry.js} +1 -1
  283. package/dist/twilight/{p-f91399b4.entry.js → p-e054c3b2.entry.js} +1 -1
  284. package/dist/twilight/{p-eae4b2c9.entry.js → p-e4ee1bb9.entry.js} +1 -1
  285. package/dist/twilight/{p-c00c26f4.entry.js → p-e513efab.entry.js} +1 -1
  286. package/dist/twilight/p-eb073d38.entry.js +4 -0
  287. package/dist/twilight/{p-473e829b.entry.js → p-ed39ea6e.entry.js} +1 -1
  288. package/dist/twilight/{p-6a50e4ab.entry.js → p-edba3e00.entry.js} +1 -1
  289. package/dist/twilight/{p-543482d0.entry.js → p-f72f19b4.entry.js} +1 -1
  290. package/dist/twilight/{p-04a3bd3a.entry.js → p-ffb2c726.entry.js} +1 -1
  291. package/dist/twilight/twilight.esm.js +1 -1
  292. package/dist/types/components/salla-cart-item-offers/salla-cart-item-offers.d.ts +1 -1
  293. package/dist/types/components.d.ts +2 -2
  294. package/package.json +5 -5
  295. package/dist/twilight/p-9f51245d.entry.js +0 -4
  296. package/dist/twilight/p-aced00e2.entry.js +0 -4
  297. package/dist/twilight/p-c11f0af9.entry.js +0 -4
  298. package/dist/twilight/p-ed6e8053.entry.js +0 -4
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as t,H as i,a as n}from"./p-eYsXdqjv.js";import{H as l}from"./p-CHf8XdiS.js";import"./p-CgtvEd63.js";const e=class{constructor(t){s(this,t),this.nextPage="",this.autoload=!1,this.container="salla-infinite-scroll",this.item="salla-infinite-scroll > *",this.status=document.createElement("div"),this.status.className="s-infinite-scroll-wrapper",this.status.innerHTML=`<div class="s-infinite-scroll-status" style="display:none">\n <p class="s-infinite-scroll-last infinite-scroll-last"></p>\n <p class="s-infinite-scroll-error infinite-scroll-error"></p>\n </div>\n <a href="${this.nextPage}" class="s-infinite-scroll-btn s-button-btn s-button-primary">\n <span class="s-button-text s-infinite-scroll-btn-text">${this.loadMoreText?this.loadMoreText:salla.lang.get("common.elements.load_more")}</span>\n <span class="s-button-loader s-button-loader-center s-infinite-scroll-btn-loader" style="display: none"></span>\n </a>`,this.btnLoader=this.status.querySelector(".s-button-loader"),salla.lang.onLoaded((()=>{this.status.querySelector(".s-button-text").innerHTML=this.loadMoreText?this.loadMoreText:salla.lang.get("common.elements.load_more"),this.status.querySelector(".s-infinite-scroll-last").innerHTML=salla.lang.get("common.elements.end_of_content"),this.status.querySelector(".s-infinite-scroll-error").innerHTML=salla.lang.get("common.elements.failed_to_load_more")}))}loading(s=!0){let t=this.status.querySelector(".s-button-text");l.toggleElementClassIf(t,"s-button-hide","s-button-show",(()=>s)),this.btnLoader.style.display=s?"inherit":"none"}render(){return this.nextPage.length>1?t(i,{class:"s-infinite-scroll-container"},t("slot",null)):""}componentDidLoad(){if(0===this.nextPage.length)return;this.host.insertAdjacentElement("afterend",this.status);let s=this,t=salla.infiniteScroll.initiate(this.container,{history:!!this.autoload&&"push",scrollThreshold:!!this.autoload&&400,nextPage:this.nextPage,checkLastPage:'salla-infinite-scroll[next-page*=":"],salla-infinite-scroll[next-page*="."]',status:".s-infinite-scroll-status",button:this.status.querySelector(".s-button-btn"),append:this.item,path:function(){return s.nextPage.replace(/page\=(\d)/g,"page="+(this.loadCount+2))}}).on("request",(()=>this.loading())).on("load",(()=>{this.loading(!1),2==t.pageIndex&&t.option({loadOnScroll:!1}),3==t.pageIndex&&t.option({loadOnScroll:!0})})).on("error",(()=>this.loading(!1)))}get host(){return n(this)}};e.style="";export{e as salla_infinite_scroll}
4
+ import{r as s,h as t,H as i,a as n}from"./p-6ZT_-rrT.js";import{H as l}from"./p-CHf8XdiS.js";import"./p-CgtvEd63.js";const e=class{constructor(t){s(this,t),this.nextPage="",this.autoload=!1,this.container="salla-infinite-scroll",this.item="salla-infinite-scroll > *",this.status=document.createElement("div"),this.status.className="s-infinite-scroll-wrapper",this.status.innerHTML=`<div class="s-infinite-scroll-status" style="display:none">\n <p class="s-infinite-scroll-last infinite-scroll-last"></p>\n <p class="s-infinite-scroll-error infinite-scroll-error"></p>\n </div>\n <a href="${this.nextPage}" class="s-infinite-scroll-btn s-button-btn s-button-primary">\n <span class="s-button-text s-infinite-scroll-btn-text">${this.loadMoreText?this.loadMoreText:salla.lang.get("common.elements.load_more")}</span>\n <span class="s-button-loader s-button-loader-center s-infinite-scroll-btn-loader" style="display: none"></span>\n </a>`,this.btnLoader=this.status.querySelector(".s-button-loader"),salla.lang.onLoaded((()=>{this.status.querySelector(".s-button-text").innerHTML=this.loadMoreText?this.loadMoreText:salla.lang.get("common.elements.load_more"),this.status.querySelector(".s-infinite-scroll-last").innerHTML=salla.lang.get("common.elements.end_of_content"),this.status.querySelector(".s-infinite-scroll-error").innerHTML=salla.lang.get("common.elements.failed_to_load_more")}))}loading(s=!0){let t=this.status.querySelector(".s-button-text");l.toggleElementClassIf(t,"s-button-hide","s-button-show",(()=>s)),this.btnLoader.style.display=s?"inherit":"none"}render(){return this.nextPage.length>1?t(i,{class:"s-infinite-scroll-container"},t("slot",null)):""}componentDidLoad(){if(0===this.nextPage.length)return;this.host.insertAdjacentElement("afterend",this.status);let s=this,t=salla.infiniteScroll.initiate(this.container,{history:!!this.autoload&&"push",scrollThreshold:!!this.autoload&&400,nextPage:this.nextPage,checkLastPage:'salla-infinite-scroll[next-page*=":"],salla-infinite-scroll[next-page*="."]',status:".s-infinite-scroll-status",button:this.status.querySelector(".s-button-btn"),append:this.item,path:function(){return s.nextPage.replace(/page\=(\d)/g,"page="+(this.loadCount+2))}}).on("request",(()=>this.loading())).on("load",(()=>{this.loading(!1),2==t.pageIndex&&t.option({loadOnScroll:!1}),3==t.pageIndex&&t.option({loadOnScroll:!0})})).on("error",(()=>this.loading(!1)))}get host(){return n(this)}};e.style="";export{e as salla_infinite_scroll}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,h as o,a as e}from"./p-eYsXdqjv.js";const i=class{constructor(o){t(this,o),this.theme="default",this.show=!1,this.targetElement=null}handleMouseOver(t){this.targetElement&&this.targetElement.contains(t.target)&&(this.show=!0)}handleMouseOut(t){this.targetElement&&this.targetElement.contains(t.target)&&(this.show=!1)}componentDidLoad(){this.targetElement=document.getElementById(this.targetId)}render(){const t=["default","dark"].includes(this.theme)?this.theme:"default";return o("div",{key:"e5e8f78265e0abb1d4130fd084573c6cff1ecb2c",class:"s-tooltip-container"},o("div",{key:"4dc98906dfd28c6e2d97b51329c07046eb15179c",class:`s-tooltip-item s-tooltip-item--${t}`,style:{display:this.show?"block":"none"}},this.text?o("span",null,this.text):o("slot",null)))}get el(){return e(this)}};i.style='.s-tooltip-container{position:relative;display:inline-block}.s-tooltip-item{position:absolute;transform:translateX(-39%);background-color:#baf3e6;color:#004d5a;bottom:100%;left:50%;text-align:center;border-radius:5px;z-index:1;white-space:nowrap;opacity:0;transition:opacity 0.3s;pointer-events:none;margin:0 0 16px 8px;padding:12px;max-width:150px;width:190px;white-space:normal;opacity:1}.s-tooltip-item::after{content:"";position:absolute;bottom:-10px;left:50%;margin-left:-5px;border-width:5px;border-style:solid;border-color:#baf3e6 transparent transparent transparent}.s-tooltip-item:dir(ltr){transform:translateX(-72%)}.s-tooltip-item--dark{background-color:#555555;color:white;padding:5px 15px;border-radius:8px;font-size:12px;font-weight:normal;max-width:330px;width:max-content}.s-tooltip-item--dark::after{border-color:#555555 transparent transparent transparent}';export{i as salla_tooltip}
4
+ import{r as t,h as o,a as e}from"./p-6ZT_-rrT.js";const i=class{constructor(o){t(this,o),this.theme="default",this.show=!1,this.targetElement=null}handleMouseOver(t){this.targetElement&&this.targetElement.contains(t.target)&&(this.show=!0)}handleMouseOut(t){this.targetElement&&this.targetElement.contains(t.target)&&(this.show=!1)}componentDidLoad(){this.targetElement=document.getElementById(this.targetId)}render(){const t=["default","dark"].includes(this.theme)?this.theme:"default";return o("div",{key:"e5e8f78265e0abb1d4130fd084573c6cff1ecb2c",class:"s-tooltip-container"},o("div",{key:"4dc98906dfd28c6e2d97b51329c07046eb15179c",class:`s-tooltip-item s-tooltip-item--${t}`,style:{display:this.show?"block":"none"}},this.text?o("span",null,this.text):o("slot",null)))}get el(){return e(this)}};i.style='.s-tooltip-container{position:relative;display:inline-block}.s-tooltip-item{position:absolute;transform:translateX(-39%);background-color:#baf3e6;color:#004d5a;bottom:100%;left:50%;text-align:center;border-radius:5px;z-index:1;white-space:nowrap;opacity:0;transition:opacity 0.3s;pointer-events:none;margin:0 0 16px 8px;padding:12px;max-width:150px;width:190px;white-space:normal;opacity:1}.s-tooltip-item::after{content:"";position:absolute;bottom:-10px;left:50%;margin-left:-5px;border-width:5px;border-style:solid;border-color:#baf3e6 transparent transparent transparent}.s-tooltip-item:dir(ltr){transform:translateX(-72%)}.s-tooltip-item--dark{background-color:#555555;color:white;padding:5px 15px;border-radius:8px;font-size:12px;font-weight:normal;max-width:330px;width:max-content}.s-tooltip-item--dark::after{border-color:#555555 transparent transparent transparent}';export{i as salla_tooltip}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as e,H as i,a as t}from"./p-eYsXdqjv.js";function l(s,e){localStorage.getItem("salla-delivery-promise-debug")&&(void 0!==e?console.log(s,e):console.log(s))}function r(){const s=(Boolean(salla.config.get("store.settings.bullet_delivery.settings.remember_last_session"))?salla.storage.store:salla.storage.session).get("bullet_delivery_intent");return s&&"object"==typeof s?s:null}const a={deliveryTo:"توصيل إلى",pickupFromBranch:"الاستلام من فرع",noResults:"لا توجد نتائج",selectCity:"اختر المدينة",changeCityTitle:"تغيير المدينة",changeCitySubtitle:"",cityFieldLabel:"المدينة",modalSearchPlaceholder:"ابحث عن مدينة",confirmAddress:"تأكيد العنوان",errorDeliveryPromise:"لا يتوفر وعد تسليم لهذه المدينة",errorPickupPromise:"لا يتوفر وعد تسليم لهذا الفرع"};function o(s){const e=salla.config.get("user.language_code");return e&&"ar"!==e&&s.name_en?.trim()?s.name_en.trim():s.name}const n=class{constructor(e){s(this,e),this.isDeliveryPromiseEnabled=!1,this.isLoginCycleEnabled=!1,this.canRender=!1,this.labels=a,this.selectedLabel=null,this.deliveryMessage=null,this.hasError=!1,this.errorMessage="",this.isLoadingPromises=!1,this.selectedCityLoginCycle=null,this.selectedBranchLoginCycle=null,this.cities=[],this.selectedCity=null,this.isLoadingCities=!1,this.modalSearchQuery="",this.cityPendingSelection=null,this.isCityPopoverOpen=!1,this.onBulletDeliveryConfirmed=()=>{this.applyBulletIntent()},this.handleModalSearchInput=s=>{this.modalSearchQuery=s.target.value,this.isCityPopoverOpen=!0},this.handleModalComboboxActivate=()=>{this.isCityPopoverOpen=!0},this.handleHeaderClick=s=>{s.stopPropagation(),this.isLoginCycleEnabled?this.openBulletDeliveryModal():this.openCityChangeModal()}}async componentDidLoad(){await salla.onReady(),await salla.lang.onLoaded(),this.labels={deliveryTo:salla.lang.getWithDefault("pages.products.promise_deliver_to",a.deliveryTo),pickupFromBranch:salla.lang.getWithDefault("pages.products.promise_pickup_from_branch",a.pickupFromBranch),noResults:salla.lang.getWithDefault("common.elements.no_options",a.noResults),selectCity:salla.lang.getWithDefault("common.elements.select_city",a.selectCity),changeCityTitle:salla.lang.getWithDefault("pages.products.promise_change_city_title",a.changeCityTitle),changeCitySubtitle:salla.lang.getWithDefault("pages.products.promise_change_city_subtitle","قد تتغيّر مدة التوصيل حسب المدينة."),cityFieldLabel:salla.lang.getWithDefault("pages.products.promise_city_field",a.cityFieldLabel),modalSearchPlaceholder:salla.lang.getWithDefault("pages.products.promise_search_city",a.modalSearchPlaceholder),confirmAddress:salla.lang.getWithDefault("pages.checkout.confirm_address",a.confirmAddress),errorDeliveryPromise:salla.lang.getWithDefault("pages.products.promise_delivery_not_available",a.errorDeliveryPromise),errorPickupPromise:salla.lang.getWithDefault("pages.products.promise_pickup_not_available",a.errorPickupPromise)},this.isDeliveryPromiseEnabled=salla.config.get("store.features",[]).includes("delivery-promises"),this.isLoginCycleEnabled=salla.config.get("store.features",[]).includes("bullet-delivery-v2"),this.productId=salla.config.get("page.id"),this.isDeliveryPromiseEnabled?this.isLoginCycleEnabled?(this.applyBulletIntent(),this.canRender=!0,window.addEventListener("bulletDeliveryConfirmed",this.onBulletDeliveryConfirmed)):(this.selectedLabel=`${this.labels.deliveryTo} ${this.labels.selectCity}`,await this.loadCities()):this.canRender=!1}disconnectedCallback(){window.removeEventListener("bulletDeliveryConfirmed",this.onBulletDeliveryConfirmed)}applyBulletIntent(){const s=function(){const s=r();if(!s)return null;if("address"===s.type){const e=s.address_details?.city,i=null!=e?.id?Number(e.id):null!=s.city_id?Number(s.city_id):null,t=e?.name?.trim()||"";return null!=i?{type:"address",option:{id:i,name:t}}:null}if("branch"===s.type){const e=null!=s.branch_id?Number(s.branch_id):null!=s.branch_details?.id?Number(s.branch_details.id):null,i=s.branch_details?.name?.trim()||"";return null!=e?{type:"branch",option:{id:e,name:i}}:null}return null}();if(!s)return this.selectedLabel=`${this.labels.deliveryTo} ${this.labels.selectCity}`,this.selectedCityLoginCycle=null,this.selectedBranchLoginCycle=null,void(this.deliveryMessage=null);"address"===s.type?(this.selectedCityLoginCycle=s.option,this.selectedBranchLoginCycle=null,this.selectedLabel=`${this.labels.deliveryTo} ${s.option.name||this.labels.selectCity}`,this.loadDeliveryMessage(s.option.id,"city")):(this.selectedBranchLoginCycle=s.option,this.selectedCityLoginCycle=null,this.selectedLabel=`${this.labels.pickupFromBranch} ${s.option.name}`,this.loadDeliveryMessage(s.option.id,"branch"))}openBulletDeliveryModal(){salla.event.emit("bullet-delivery::open",function(){const s=r(),e={};if("address"===s?.type&&null!=s.address_id&&(e.preselected_address_id=Number(s.address_id)),"branch"===s?.type){const i=s.branch_id??s.branch_details?.id;null!=i&&(e.preselected_branch_id=Number(i))}return e}())}async loadCities(){this.isLoadingCities=!0,this.hasError=!1;try{const{cities:s,preselected:e}=await async function(s){l("fetchCities start",{productId:s});const e=await salla.api.request(salla.url.api(`products/${s}/delivery-promises/cities`));if(!e.success||!Array.isArray(e.data)||0===e.data.length)return l("fetchCities: no data",{response:e}),{cities:[],preselected:void 0};const i=e.data.find((s=>s.is_selected));return l("fetchCities success",{count:e.data.length,preselected:i}),{cities:e.data,preselected:i}}(this.productId);if(0===s.length)return void(this.canRender=!1);this.cities=s,e&&(this.selectedCity=e,this.selectedLabel=`${this.labels.deliveryTo} ${o(e)}`,await this.loadDeliveryMessage(e.id,"city")),this.canRender=!0}catch(s){this.hasError=!0,this.errorMessage=s.message||"Failed to load cities",this.canRender=!1}finally{this.isLoadingCities=!1}}async loadDeliveryMessage(s,e){this.isLoadingPromises=!0,this.hasError=!1,this.deliveryMessage=null;try{this.deliveryMessage=await async function(s,e,i,t){l("fetchDeliveryMessage start",{productId:s,id:e,optionType:i});let r="";r="city"!==i||t?`?reference_id=${e}&reference_type=${i}`:`?reference_id=${e}`;const a=await salla.api.withoutNotifier((()=>salla.api.request(salla.url.api(`products/${s}/delivery-promises${r}`))));if(!a.success)throw l("fetchDeliveryMessage error",{response:a}),new Error(a.error?.message||"Failed to fetch delivery promise");const o=a.data?.message?.trim();return l("fetchDeliveryMessage success",{message:o}),o||null}(this.productId,s,e,this.isLoginCycleEnabled)}catch(s){this.hasError=!0,this.errorMessage="city"===e?this.labels.errorDeliveryPromise:this.labels.errorPickupPromise}finally{this.isLoadingPromises=!1}}async openCityChangeModal(){this.cityModalRef&&(this.cityPendingSelection=null,this.modalSearchQuery="",this.isCityPopoverOpen=!1,await this.cityModalRef.setTitle(this.labels.changeCityTitle),await this.cityModalRef.open())}handleModalSelectCity(s){this.cityPendingSelection=s,this.modalSearchQuery=o(s),this.isCityPopoverOpen=!1}async handleConfirmCityModal(){if(!this.cityPendingSelection)return void await(this.cityModalRef?.close());const s=this.cityPendingSelection;this.selectedCity=s,this.selectedLabel=`${this.labels.deliveryTo} ${o(s)}`,await this.loadDeliveryMessage(s.id,"city"),await(this.cityModalRef?.close())}renderLoadingSkeleton(){return e(i,{class:"s-delivery-promise-wrapper s-delivery-promise-skeleton"},e("div",{class:"s-delivery-promise-container"},e("div",{class:"s-delivery-promise-header s-delivery-promise-header-skeleton"},e("div",{class:"s-delivery-promise-location"},e("salla-skeleton",{height:"14px",width:"180px"})),e("salla-skeleton",{height:"18px",width:"18px"})),e("div",{class:"s-delivery-promise-loading"},e("salla-skeleton",{height:"20px",width:"80%"}))))}renderDeliveryMessage(){return this.isLoadingPromises?e("div",{class:"s-delivery-promise-loading"},e("salla-skeleton",{height:"20px",width:"80%"})):this.deliveryMessage?e("div",{class:"s-delivery-promise-message"},this.deliveryMessage):null}renderCityModalBody(){const s=function(s,e){const i=e.trim().toLowerCase();return i?s.filter((s=>s.name.toLowerCase().includes(i)||(s.name_en||"").toLowerCase().includes(i))):[...s]}(this.cities,this.modalSearchQuery);return e("div",{class:"s-delivery-promise-modal-body"},e("label",{class:"s-delivery-promise-modal-field-label",htmlFor:"s-delivery-promise-modal-search"},this.labels.cityFieldLabel,e("span",{class:"s-delivery-promise-required","aria-hidden":"true"}," *")),e("div",{class:"s-delivery-promise-modal-combobox"},e("div",{class:"s-delivery-promise-modal-search",onClick:this.handleModalComboboxActivate},e("i",{class:"sicon-search","aria-hidden":"true"}),e("input",{id:"s-delivery-promise-modal-search",type:"text",class:"form-input",placeholder:this.labels.modalSearchPlaceholder,value:this.modalSearchQuery,onInput:this.handleModalSearchInput,autocomplete:"off","aria-autocomplete":"list","aria-expanded":this.isCityPopoverOpen?"true":"false","aria-controls":"s-delivery-promise-modal-listbox"})),e("div",{id:"s-delivery-promise-modal-listbox",class:"s-delivery-promise-modal-popover",role:"listbox",hidden:!this.isCityPopoverOpen},e("div",{class:"s-delivery-promise-modal-list s-scrollbar"},0===s.length?e("div",{class:"s-delivery-promise-modal-empty"},this.labels.noResults):s.map((s=>e("button",{key:s.id,type:"button",role:"option",class:{"s-delivery-promise-modal-item":!0,"s-delivery-promise-modal-item--selected":this.cityPendingSelection?.id===s.id},"aria-selected":this.cityPendingSelection?.id===s.id?"true":"false",onClick:e=>{e.stopPropagation(),this.handleModalSelectCity(s)}},e("span",{class:"s-delivery-promise-modal-item-name"},s.name),this.cityPendingSelection?.id===s.id?e("i",{class:"sicon-check","aria-hidden":"true"}):null)))))))}renderCityChangeModal(){return this.isLoginCycleEnabled?null:e("salla-modal",{id:"s-delivery-promise-city-modal",ref:s=>{this.cityModalRef=s},class:"s-delivery-promise-city-modal",isClosable:!0,width:"md","modal-title":this.labels.changeCityTitle,subTitle:this.labels.changeCitySubtitle},this.renderCityModalBody(),e("salla-button",{slot:"footer",width:"wide",disabled:!this.cityPendingSelection,onClick:()=>this.handleConfirmCityModal()},!this.isLoadingPromises&&this.labels.confirmAddress))}render(){return this.isDeliveryPromiseEnabled?this.isLoadingCities?this.renderLoadingSkeleton():this.canRender?e(i,{class:"s-delivery-promise-wrapper"},e("div",{class:"s-delivery-promise-container"},e("div",{class:"s-delivery-promise-header",onClick:this.handleHeaderClick},e("div",{class:"s-delivery-promise-location"},e("span",{class:"s-delivery-promise-title"},this.selectedLabel)),e("i",{class:"sicon-keyboard_arrow_down s-delivery-promise-arrow"})),this.hasError&&e("div",{class:"s-delivery-promise-error"},this.errorMessage),!this.hasError&&this.renderDeliveryMessage()),this.renderCityChangeModal()):null:null}get host(){return t(this)}};export{n as salla_delivery_promise}
4
+ import{r as s,h as e,H as i,a as t}from"./p-6ZT_-rrT.js";function l(s,e){localStorage.getItem("salla-delivery-promise-debug")&&(void 0!==e?console.log(s,e):console.log(s))}function r(){const s=(Boolean(salla.config.get("store.settings.bullet_delivery.settings.remember_last_session"))?salla.storage.store:salla.storage.session).get("bullet_delivery_intent");return s&&"object"==typeof s?s:null}const a={deliveryTo:"توصيل إلى",pickupFromBranch:"الاستلام من فرع",noResults:"لا توجد نتائج",selectCity:"اختر المدينة",changeCityTitle:"تغيير المدينة",changeCitySubtitle:"",cityFieldLabel:"المدينة",modalSearchPlaceholder:"ابحث عن مدينة",confirmAddress:"تأكيد العنوان",errorDeliveryPromise:"لا يتوفر وعد تسليم لهذه المدينة",errorPickupPromise:"لا يتوفر وعد تسليم لهذا الفرع"};function o(s){const e=salla.config.get("user.language_code");return e&&"ar"!==e&&s.name_en?.trim()?s.name_en.trim():s.name}const n=class{constructor(e){s(this,e),this.isDeliveryPromiseEnabled=!1,this.isLoginCycleEnabled=!1,this.canRender=!1,this.labels=a,this.selectedLabel=null,this.deliveryMessage=null,this.hasError=!1,this.errorMessage="",this.isLoadingPromises=!1,this.selectedCityLoginCycle=null,this.selectedBranchLoginCycle=null,this.cities=[],this.selectedCity=null,this.isLoadingCities=!1,this.modalSearchQuery="",this.cityPendingSelection=null,this.isCityPopoverOpen=!1,this.onBulletDeliveryConfirmed=()=>{this.applyBulletIntent()},this.handleModalSearchInput=s=>{this.modalSearchQuery=s.target.value,this.isCityPopoverOpen=!0},this.handleModalComboboxActivate=()=>{this.isCityPopoverOpen=!0},this.handleHeaderClick=s=>{s.stopPropagation(),this.isLoginCycleEnabled?this.openBulletDeliveryModal():this.openCityChangeModal()}}async componentDidLoad(){await salla.onReady(),await salla.lang.onLoaded(),this.labels={deliveryTo:salla.lang.getWithDefault("pages.products.promise_deliver_to",a.deliveryTo),pickupFromBranch:salla.lang.getWithDefault("pages.products.promise_pickup_from_branch",a.pickupFromBranch),noResults:salla.lang.getWithDefault("common.elements.no_options",a.noResults),selectCity:salla.lang.getWithDefault("common.elements.select_city",a.selectCity),changeCityTitle:salla.lang.getWithDefault("pages.products.promise_change_city_title",a.changeCityTitle),changeCitySubtitle:salla.lang.getWithDefault("pages.products.promise_change_city_subtitle","قد تتغيّر مدة التوصيل حسب المدينة."),cityFieldLabel:salla.lang.getWithDefault("pages.products.promise_city_field",a.cityFieldLabel),modalSearchPlaceholder:salla.lang.getWithDefault("pages.products.promise_search_city",a.modalSearchPlaceholder),confirmAddress:salla.lang.getWithDefault("pages.checkout.confirm_address",a.confirmAddress),errorDeliveryPromise:salla.lang.getWithDefault("pages.products.promise_delivery_not_available",a.errorDeliveryPromise),errorPickupPromise:salla.lang.getWithDefault("pages.products.promise_pickup_not_available",a.errorPickupPromise)},this.isDeliveryPromiseEnabled=salla.config.get("store.features",[]).includes("delivery-promises"),this.isLoginCycleEnabled=salla.config.get("store.features",[]).includes("bullet-delivery-v2"),this.productId=salla.config.get("page.id"),this.isDeliveryPromiseEnabled?this.isLoginCycleEnabled?(this.applyBulletIntent(),this.canRender=!0,window.addEventListener("bulletDeliveryConfirmed",this.onBulletDeliveryConfirmed)):(this.selectedLabel=`${this.labels.deliveryTo} ${this.labels.selectCity}`,await this.loadCities()):this.canRender=!1}disconnectedCallback(){window.removeEventListener("bulletDeliveryConfirmed",this.onBulletDeliveryConfirmed)}applyBulletIntent(){const s=function(){const s=r();if(!s)return null;if("address"===s.type){const e=s.address_details?.city,i=null!=e?.id?Number(e.id):null!=s.city_id?Number(s.city_id):null,t=e?.name?.trim()||"";return null!=i?{type:"address",option:{id:i,name:t}}:null}if("branch"===s.type){const e=null!=s.branch_id?Number(s.branch_id):null!=s.branch_details?.id?Number(s.branch_details.id):null,i=s.branch_details?.name?.trim()||"";return null!=e?{type:"branch",option:{id:e,name:i}}:null}return null}();if(!s)return this.selectedLabel=`${this.labels.deliveryTo} ${this.labels.selectCity}`,this.selectedCityLoginCycle=null,this.selectedBranchLoginCycle=null,void(this.deliveryMessage=null);"address"===s.type?(this.selectedCityLoginCycle=s.option,this.selectedBranchLoginCycle=null,this.selectedLabel=`${this.labels.deliveryTo} ${s.option.name||this.labels.selectCity}`,this.loadDeliveryMessage(s.option.id,"city")):(this.selectedBranchLoginCycle=s.option,this.selectedCityLoginCycle=null,this.selectedLabel=`${this.labels.pickupFromBranch} ${s.option.name}`,this.loadDeliveryMessage(s.option.id,"branch"))}openBulletDeliveryModal(){salla.event.emit("bullet-delivery::open",function(){const s=r(),e={};if("address"===s?.type&&null!=s.address_id&&(e.preselected_address_id=Number(s.address_id)),"branch"===s?.type){const i=s.branch_id??s.branch_details?.id;null!=i&&(e.preselected_branch_id=Number(i))}return e}())}async loadCities(){this.isLoadingCities=!0,this.hasError=!1;try{const{cities:s,preselected:e}=await async function(s){l("fetchCities start",{productId:s});const e=await salla.api.request(salla.url.api(`products/${s}/delivery-promises/cities`));if(!e.success||!Array.isArray(e.data)||0===e.data.length)return l("fetchCities: no data",{response:e}),{cities:[],preselected:void 0};const i=e.data.find((s=>s.is_selected));return l("fetchCities success",{count:e.data.length,preselected:i}),{cities:e.data,preselected:i}}(this.productId);if(0===s.length)return void(this.canRender=!1);this.cities=s,e&&(this.selectedCity=e,this.selectedLabel=`${this.labels.deliveryTo} ${o(e)}`,await this.loadDeliveryMessage(e.id,"city")),this.canRender=!0}catch(s){this.hasError=!0,this.errorMessage=s.message||"Failed to load cities",this.canRender=!1}finally{this.isLoadingCities=!1}}async loadDeliveryMessage(s,e){this.isLoadingPromises=!0,this.hasError=!1,this.deliveryMessage=null;try{this.deliveryMessage=await async function(s,e,i,t){l("fetchDeliveryMessage start",{productId:s,id:e,optionType:i});let r="";r="city"!==i||t?`?reference_id=${e}&reference_type=${i}`:`?reference_id=${e}`;const a=await salla.api.withoutNotifier((()=>salla.api.request(salla.url.api(`products/${s}/delivery-promises${r}`))));if(!a.success)throw l("fetchDeliveryMessage error",{response:a}),new Error(a.error?.message||"Failed to fetch delivery promise");const o=a.data?.message?.trim();return l("fetchDeliveryMessage success",{message:o}),o||null}(this.productId,s,e,this.isLoginCycleEnabled)}catch(s){this.hasError=!0,this.errorMessage="city"===e?this.labels.errorDeliveryPromise:this.labels.errorPickupPromise}finally{this.isLoadingPromises=!1}}async openCityChangeModal(){this.cityModalRef&&(this.cityPendingSelection=null,this.modalSearchQuery="",this.isCityPopoverOpen=!1,await this.cityModalRef.setTitle(this.labels.changeCityTitle),await this.cityModalRef.open())}handleModalSelectCity(s){this.cityPendingSelection=s,this.modalSearchQuery=o(s),this.isCityPopoverOpen=!1}async handleConfirmCityModal(){if(!this.cityPendingSelection)return void await(this.cityModalRef?.close());const s=this.cityPendingSelection;this.selectedCity=s,this.selectedLabel=`${this.labels.deliveryTo} ${o(s)}`,await this.loadDeliveryMessage(s.id,"city"),await(this.cityModalRef?.close())}renderLoadingSkeleton(){return e(i,{class:"s-delivery-promise-wrapper s-delivery-promise-skeleton"},e("div",{class:"s-delivery-promise-container"},e("div",{class:"s-delivery-promise-header s-delivery-promise-header-skeleton"},e("div",{class:"s-delivery-promise-location"},e("salla-skeleton",{height:"14px",width:"180px"})),e("salla-skeleton",{height:"18px",width:"18px"})),e("div",{class:"s-delivery-promise-loading"},e("salla-skeleton",{height:"20px",width:"80%"}))))}renderDeliveryMessage(){return this.isLoadingPromises?e("div",{class:"s-delivery-promise-loading"},e("salla-skeleton",{height:"20px",width:"80%"})):this.deliveryMessage?e("div",{class:"s-delivery-promise-message"},this.deliveryMessage):null}renderCityModalBody(){const s=function(s,e){const i=e.trim().toLowerCase();return i?s.filter((s=>s.name.toLowerCase().includes(i)||(s.name_en||"").toLowerCase().includes(i))):[...s]}(this.cities,this.modalSearchQuery);return e("div",{class:"s-delivery-promise-modal-body"},e("label",{class:"s-delivery-promise-modal-field-label",htmlFor:"s-delivery-promise-modal-search"},this.labels.cityFieldLabel,e("span",{class:"s-delivery-promise-required","aria-hidden":"true"}," *")),e("div",{class:"s-delivery-promise-modal-combobox"},e("div",{class:"s-delivery-promise-modal-search",onClick:this.handleModalComboboxActivate},e("i",{class:"sicon-search","aria-hidden":"true"}),e("input",{id:"s-delivery-promise-modal-search",type:"text",class:"form-input",placeholder:this.labels.modalSearchPlaceholder,value:this.modalSearchQuery,onInput:this.handleModalSearchInput,autocomplete:"off","aria-autocomplete":"list","aria-expanded":this.isCityPopoverOpen?"true":"false","aria-controls":"s-delivery-promise-modal-listbox"})),e("div",{id:"s-delivery-promise-modal-listbox",class:"s-delivery-promise-modal-popover",role:"listbox",hidden:!this.isCityPopoverOpen},e("div",{class:"s-delivery-promise-modal-list s-scrollbar"},0===s.length?e("div",{class:"s-delivery-promise-modal-empty"},this.labels.noResults):s.map((s=>e("button",{key:s.id,type:"button",role:"option",class:{"s-delivery-promise-modal-item":!0,"s-delivery-promise-modal-item--selected":this.cityPendingSelection?.id===s.id},"aria-selected":this.cityPendingSelection?.id===s.id?"true":"false",onClick:e=>{e.stopPropagation(),this.handleModalSelectCity(s)}},e("span",{class:"s-delivery-promise-modal-item-name"},s.name),this.cityPendingSelection?.id===s.id?e("i",{class:"sicon-check","aria-hidden":"true"}):null)))))))}renderCityChangeModal(){return this.isLoginCycleEnabled?null:e("salla-modal",{id:"s-delivery-promise-city-modal",ref:s=>{this.cityModalRef=s},class:"s-delivery-promise-city-modal",isClosable:!0,width:"md","modal-title":this.labels.changeCityTitle,subTitle:this.labels.changeCitySubtitle},this.renderCityModalBody(),e("salla-button",{slot:"footer",width:"wide",disabled:!this.cityPendingSelection,onClick:()=>this.handleConfirmCityModal()},!this.isLoadingPromises&&this.labels.confirmAddress))}render(){return this.isDeliveryPromiseEnabled?this.isLoadingCities?this.renderLoadingSkeleton():this.canRender?e(i,{class:"s-delivery-promise-wrapper"},e("div",{class:"s-delivery-promise-container"},e("div",{class:"s-delivery-promise-header",onClick:this.handleHeaderClick},e("div",{class:"s-delivery-promise-location"},e("span",{class:"s-delivery-promise-title"},this.selectedLabel)),e("i",{class:"sicon-keyboard_arrow_down s-delivery-promise-arrow"})),this.hasError&&e("div",{class:"s-delivery-promise-error"},this.errorMessage),!this.hasError&&this.renderDeliveryMessage()),this.renderCityChangeModal()):null:null}get host(){return t(this)}};export{n as salla_delivery_promise}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,c as e,h as i}from"./p-eYsXdqjv.js";import{C as t}from"./p-C6jIkM-X.js";import{F as l}from"./p-OF8QcbMM.js";const a=class{constructor(i){s(this,i),this.fieldChanged=e(this,"fieldChanged"),this.fileUploaded=e(this,"fileUploaded"),this.isEditable=!0,this.fieldErrors={},this.isSubmitting=!1}get dragAndDropText(){return salla.lang.get("common.uploader.drag_and_drop")}get browseText(){return salla.lang.get("common.uploader.browse")}get saveButtonText(){return salla.lang.get("common.elements.save")}async setFields(s){this.parsedFields=s}async getFieldValues(){return this.parsedFields?.reduce(((s,e)=>(s[`custom_fields[${e.id}]`]=e.value,s)),{})||{}}async validateFields(){if(!this.parsedFields)return!0;const s=this.parsedFields.reduce(((s,e)=>(!e.required||e.value&&""!==e.value||(s[e.id.toString()]=`${e.label} is required`),s)),{});return this.fieldErrors=s,0===Object.keys(s).length}handleFieldChange(s,e){const i=e.target.value;s.value=i,this.clearFieldError(s.id);const t=!(s.required&&!i);t||this.setFieldError(s.id,`${s.label} is required`),this.fieldChanged.emit({fieldId:s.id,value:i,isValid:t})}handleFileUpload(s,e){const{error:i,file:t}=e.detail,l=!i;this.clearFieldError(s.id),l?s.value=t:this.setFieldError(s.id,"File upload failed"),this.fileUploaded.emit({fieldId:s.id,file:t,isValid:l})}clearFieldError(s){this.fieldErrors={...this.fieldErrors},delete this.fieldErrors[s]}setFieldError(s,e){this.fieldErrors={...this.fieldErrors,[s]:e}}renderTextField(s){return i("input",{disabled:!this.isEditable,type:s.type,id:`custom-field-${s.id}`,value:s.value?.toString()||"",onChange:e=>this.handleFieldChange(s,e),name:`${s.id}`,class:"form-input",required:s.required})}renderFileField(s){return i("salla-file-upload",{url:salla.url.api("upload"),id:`custom-field-${s.id}`,name:`${s.id}`,type:"registration",value:s.value,height:"120px",onAdded:e=>this.handleFileUpload(s,e),required:s.required,disabled:!this.isEditable,onUploaded:s=>{s.target.value=s.target.value?.url},allowRemove:!0,onRemoved:e=>{e.preventDefault(),e.stopPropagation(),s.value="",e.target.value=""},payloadName:"files[]",payloadParams:{type:"registration"},"instant-upload":!0},i("div",{class:"s-custom-fields-filepond-placeholder"},i("span",{class:"s-custom-fields-filepond-placeholder-icon"},i("i",{innerHTML:t})),i("p",{class:"s-custom-fields-filepond-placeholder-text"},this.dragAndDropText),i("span",{class:"filepond--label-action"},this.browseText)))}renderField(s){return i("div",{class:"s-custom-fields-field",key:s.id},i("label",{class:"s-custom-fields-field-label",htmlFor:`custom-field-${s.id}`},s.label,s.required&&i("span",{class:"s-custom-fields-required"},"*")),i("div",null,s.type===l.Photo?this.renderFileField(s):this.renderTextField(s),this.fieldErrors[s.id]&&i("p",{class:"s-custom-fields-error"},this.fieldErrors[s.id])))}componentWillLoad(){this.parsedFields=this.parseFields(this.fields)}parseFields(s){return s?"string"==typeof s?JSON.parse(s):Array.isArray(s)?s:[]:[]}async handleSubmit(s){s.preventDefault(),this.isSubmitting=!0;try{const e={},i=s.target.elements;for(let s=0;s<i.length;s++){const t=i[s];t.name&&!t.name.startsWith("hidden")&&t.value&&(e[t.name]=t.value)}await salla.api.profile.updateCustomFields({id:salla.config.get("store.id"),fields:e})}finally{this.isSubmitting=!1}}render(){return this.parsedFields?.length?i("form",{class:"s-custom-fields-wrapper",onSubmit:this.handleSubmit},this.parsedFields.map((s=>this.renderField(s))),i("salla-button",{type:"submit",loading:this.isSubmitting,disabled:this.isSubmitting||!this.isEditable,"loader-position":"end",class:"s-custom-fields-submit-btn"},this.saveButtonText)):null}};a.style=":host{display:block}";export{a as salla_custom_fields}
4
+ import{r as s,c as e,h as i}from"./p-6ZT_-rrT.js";import{C as t}from"./p-C6jIkM-X.js";import{F as l}from"./p-OF8QcbMM.js";const a=class{constructor(i){s(this,i),this.fieldChanged=e(this,"fieldChanged"),this.fileUploaded=e(this,"fileUploaded"),this.isEditable=!0,this.fieldErrors={},this.isSubmitting=!1}get dragAndDropText(){return salla.lang.get("common.uploader.drag_and_drop")}get browseText(){return salla.lang.get("common.uploader.browse")}get saveButtonText(){return salla.lang.get("common.elements.save")}async setFields(s){this.parsedFields=s}async getFieldValues(){return this.parsedFields?.reduce(((s,e)=>(s[`custom_fields[${e.id}]`]=e.value,s)),{})||{}}async validateFields(){if(!this.parsedFields)return!0;const s=this.parsedFields.reduce(((s,e)=>(!e.required||e.value&&""!==e.value||(s[e.id.toString()]=`${e.label} is required`),s)),{});return this.fieldErrors=s,0===Object.keys(s).length}handleFieldChange(s,e){const i=e.target.value;s.value=i,this.clearFieldError(s.id);const t=!(s.required&&!i);t||this.setFieldError(s.id,`${s.label} is required`),this.fieldChanged.emit({fieldId:s.id,value:i,isValid:t})}handleFileUpload(s,e){const{error:i,file:t}=e.detail,l=!i;this.clearFieldError(s.id),l?s.value=t:this.setFieldError(s.id,"File upload failed"),this.fileUploaded.emit({fieldId:s.id,file:t,isValid:l})}clearFieldError(s){this.fieldErrors={...this.fieldErrors},delete this.fieldErrors[s]}setFieldError(s,e){this.fieldErrors={...this.fieldErrors,[s]:e}}renderTextField(s){return i("input",{disabled:!this.isEditable,type:s.type,id:`custom-field-${s.id}`,value:s.value?.toString()||"",onChange:e=>this.handleFieldChange(s,e),name:`${s.id}`,class:"form-input",required:s.required})}renderFileField(s){return i("salla-file-upload",{url:salla.url.api("upload"),id:`custom-field-${s.id}`,name:`${s.id}`,type:"registration",value:s.value,height:"120px",onAdded:e=>this.handleFileUpload(s,e),required:s.required,disabled:!this.isEditable,onUploaded:s=>{s.target.value=s.target.value?.url},allowRemove:!0,onRemoved:e=>{e.preventDefault(),e.stopPropagation(),s.value="",e.target.value=""},payloadName:"files[]",payloadParams:{type:"registration"},"instant-upload":!0},i("div",{class:"s-custom-fields-filepond-placeholder"},i("span",{class:"s-custom-fields-filepond-placeholder-icon"},i("i",{innerHTML:t})),i("p",{class:"s-custom-fields-filepond-placeholder-text"},this.dragAndDropText),i("span",{class:"filepond--label-action"},this.browseText)))}renderField(s){return i("div",{class:"s-custom-fields-field",key:s.id},i("label",{class:"s-custom-fields-field-label",htmlFor:`custom-field-${s.id}`},s.label,s.required&&i("span",{class:"s-custom-fields-required"},"*")),i("div",null,s.type===l.Photo?this.renderFileField(s):this.renderTextField(s),this.fieldErrors[s.id]&&i("p",{class:"s-custom-fields-error"},this.fieldErrors[s.id])))}componentWillLoad(){this.parsedFields=this.parseFields(this.fields)}parseFields(s){return s?"string"==typeof s?JSON.parse(s):Array.isArray(s)?s:[]:[]}async handleSubmit(s){s.preventDefault(),this.isSubmitting=!0;try{const e={},i=s.target.elements;for(let s=0;s<i.length;s++){const t=i[s];t.name&&!t.name.startsWith("hidden")&&t.value&&(e[t.name]=t.value)}await salla.api.profile.updateCustomFields({id:salla.config.get("store.id"),fields:e})}finally{this.isSubmitting=!1}}render(){return this.parsedFields?.length?i("form",{class:"s-custom-fields-wrapper",onSubmit:this.handleSubmit},this.parsedFields.map((s=>this.renderField(s))),i("salla-button",{type:"submit",loading:this.isSubmitting,disabled:this.isSubmitting||!this.isEditable,"loader-position":"end",class:"s-custom-fields-submit-btn"},this.saveButtonText)):null}};a.style=":host{display:block}";export{a as salla_custom_fields}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as t,H as e,a}from"./p-eYsXdqjv.js";const i=class{constructor(t){s(this,t),this.loading=!0,this.saveLoading=!1,this.payload={items:{update:[],remove:[]}},this.expired=!1,this.editPreview=null,this.confirming=!1}async componentWillLoad(){await salla.onReady(),this.loadFromProp(),this.startExpiryCheck()}disconnectedCallback(){clearInterval(this.expiryInterval)}startExpiryCheck(){const s=this.order?.customer_editing_session?.ends_at;if(!s)return;const t=()=>new Date(`${s.replace(" ","T")}+03:00`).getTime()<=Date.now();t()?this.expired=!0:this.expiryInterval=setInterval((()=>{t()&&(this.expired=!0,clearInterval(this.expiryInterval))}),1e3)}loadFromProp(){try{if(!this.orderData)return void(this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود"));const s="string"==typeof this.orderData?JSON.parse(this.orderData):this.orderData;this.order=s}catch(s){this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود")}finally{this.loading=!1}}handleItemUpdated(s){if(!this.order)return;const{itemId:t,quantity:e,options:a}=s.detail,i=this.payload.items.update.filter((s=>s.id!==t));i.push({id:t,quantity:e,options:a??[]}),this.payload={...this.payload,items:{...this.payload.items,update:i}},this.order={...this.order,items:this.order.items.map((s=>s.id===t?{...s,quantity:e}:s))}}handleItemRemoved(s){if(!this.order)return;if(this.order.items.length<=1)return void salla.notify.error(salla.lang.getWithDefault("pages.orders.order_cannot_be_empty","لا يمكن إزالة جميع المنتجات من الطلب"));const{itemId:t}=s.detail;this.payload={...this.payload,items:{update:this.payload.items.update.filter((s=>s.id!==t)),remove:[...this.payload.items.remove,t]}},this.order={...this.order,items:this.order.items.filter((s=>s.id!==t))}}get hasChanges(){return this.payload.items.update.length>0||this.payload.items.remove.length>0}async saveOrder(){if(this.hasChanges){this.saveLoading=!0;try{const s=await salla.order.api.editOrder(this.orderId,this.payload);this.editPreview=s?.data?.data||s?.data,await(this.saveModal?.open())}catch(s){const t=s?.response?.data?.error?.message||s?.response?.data?.message;t&&salla.notify.error(t)}finally{this.saveLoading=!1}}}navigateToOrder(){const s=new URL(window.location.href);s.pathname=s.pathname.replace(/\/edit\/?$/,""),s.search="",window.location.href=s.href}handleConfirm(){this.confirming=!0,this.editPreview?.payment?.required&&this.editPreview.payment.payment_url?window.location.href=this.editPreview.payment.payment_url:this.navigateToOrder()}async cancelEditSession(){try{await salla.order.api.cancelEditSession(this.orderId),this.navigateToOrder()}catch(s){const t=s?.response?.data?.error?.message||s?.response?.data?.message;t&&salla.notify.error(t)}}renderSaveModal(){const s=this.editPreview,e=s?.totals?.remaining_amount?.amount>0,a=s?.totals?.refund_amount?.amount>0,i=s?.totals?.tax?.amount?.amount;return t("salla-modal",{ref:s=>this.saveModal=s,width:"md",onModalVisibilityChanged:async s=>{s.detail||(this.editPreview=null,this.confirming||await this.cancelEditSession(),this.confirming=!1)}},t("div",{class:"s-order-edit-modal"},t("h2",{class:"s-order-edit-modal-title"},salla.lang.getWithDefault("pages.orders.edit_summary_title","ملخص الطلب بعد التعديل")),s?.items?.length>0&&t("div",{class:"s-order-edit-modal-items"},s.items.map((s=>{const e=this.order?.items?.find((t=>t.id==s.id)),a=e?.product?.image?.url,i=s.options?.join("/ ");return t("div",{class:"s-order-edit-modal-item"},t("div",{class:"s-order-edit-modal-item-start"},a&&t("img",{src:a,alt:s.name,class:"s-order-edit-modal-item-image"}),t("div",null,t("p",{class:"s-order-edit-modal-item-name"},s.name),i&&t("span",{class:"s-order-edit-modal-item-options"},i))),t("div",{class:"s-order-edit-modal-item-end"},t("span",{class:"s-order-edit-modal-item-price",innerHTML:salla.money(s.price.amount)})))}))),s?.totals?.updated_products_total&&t("div",{class:"s-order-edit-modal-row"},t("span",{class:"s-order-edit-modal-row-label"},salla.lang.getWithDefault("pages.orders.modified_products_total","مجموع المنتجات المعدلة")),t("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(s.totals.updated_products_total.amount)})),i>0&&t("div",{class:"s-order-edit-modal-row"},t("span",{class:"s-order-edit-modal-tax-label"},t("i",{class:"sicon-info-circle s-order-edit-modal-tax-icon"}),salla.lang.getWithDefault("pages.orders.vat","ضريبة القيمة المضافة")),t("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(i)})),s?.totals?.total&&t("div",{class:"s-order-edit-modal-total"},t("span",{class:"s-order-edit-modal-total-label"},salla.lang.getWithDefault("pages.orders.order_total","اجمالي الطلب")),t("span",{class:"s-order-edit-modal-total-value",innerHTML:salla.money(s.totals.total.amount)})),a&&t("div",{class:"s-order-edit-modal-refund"},t("i",{class:"sicon-info-circle s-order-edit-modal-refund-icon"}),t("p",{class:"s-order-edit-modal-refund-text"},salla.lang.getWithDefault("pages.orders.refund_message","سيتم تحويل فارق المبلغ على نفس وسيلة الدفع"))),t("div",{class:"s-order-edit-modal-btn-wrapper"},t("salla-button",{onClick:()=>this.handleConfirm()},e?salla.lang.getWithDefault("pages.orders.pay_difference","دفع فارق المبلغ"):a?salla.lang.getWithDefault("pages.orders.confirm_and_receive_difference","تأكيد واستلام فارق المبلغ"):salla.lang.getWithDefault("pages.orders.confirm_changes","تأكيد التعديلات"),t("i",{class:"sicon-keyboard_arrow_left s-order-edit-modal-btn-icon"})))))}render(){if(this.loading)return t(e,null,t("salla-loading",null));if(this.expired)return t(e,null,t("div",{class:"s-order-edit-expired"},t("p",null,salla.lang.getWithDefault("pages.orders.edit_session_expired","انتهت مدة التعديل المتاحة")),t("salla-button",{onClick:()=>this.navigateToOrder()},salla.lang.getWithDefault("pages.orders.back_to_order","العودة إلى تفاصيل الطلب"))));if(this.error||!this.order)return t(e,null,t("div",{class:"no-content-placeholder"},t("i",{class:"sicon-shopping-bag icon"}),t("p",null,this.error)));const s=this.order.items&&this.order.items.length>0,a=this.order.customer_editing_session?.ends_at;return t(e,null,a&&t("div",{class:"s-order-edit-timer-wrapper"},t("salla-count-down",{prefixText:salla.lang.getWithDefault("pages.orders.edit_within","يمكنك التعديل خلال"),date:a,horizontal:!0,withButton:!0,autoSegments:!0,labeled:!1,size:"sm",color:"primary"})),t("div",{class:"s-order-edit-items-wrapper"},t("h2",{class:"s-order-edit-items-title"},salla.lang.getWithDefault("pages.orders.order_products","منتجات الطلب")),s?this.order.items.map(((s,e)=>[t("salla-order-edit-item",{key:s.id,item:s,orderId:this.orderId}),e<this.order.items.length-1?t("div",{class:"s-order-edit-items-divider"}):null])):t("div",{class:"no-content-placeholder"},t("i",{class:"sicon-shopping-bag icon"}),t("p",null,salla.lang.getWithDefault("common.elements.no_items","لا توجد عناصر")))),t("div",{class:"s-order-edit-actions"},t("salla-button",{onClick:()=>this.saveOrder(),loading:this.saveLoading,disabled:!this.hasChanges},salla.lang.getWithDefault("pages.orders.save_changes","حفظ التعديلات")),t("salla-button",{color:"gray",fill:"outline",onClick:()=>this.cancelEditSession()},salla.lang.getWithDefault("common.elements.cancel","الغاء"))),this.renderSaveModal())}get host(){return a(this)}};i.style="";export{i as salla_order_edit}
4
+ import{r as s,h as t,H as e,a}from"./p-6ZT_-rrT.js";const i=class{constructor(t){s(this,t),this.loading=!0,this.saveLoading=!1,this.payload={items:{update:[],remove:[]}},this.expired=!1,this.editPreview=null,this.confirming=!1}async componentWillLoad(){await salla.onReady(),this.loadFromProp(),this.startExpiryCheck()}disconnectedCallback(){clearInterval(this.expiryInterval)}startExpiryCheck(){const s=this.order?.customer_editing_session?.ends_at;if(!s)return;const t=()=>new Date(`${s.replace(" ","T")}+03:00`).getTime()<=Date.now();t()?this.expired=!0:this.expiryInterval=setInterval((()=>{t()&&(this.expired=!0,clearInterval(this.expiryInterval))}),1e3)}loadFromProp(){try{if(!this.orderData)return void(this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود"));const s="string"==typeof this.orderData?JSON.parse(this.orderData):this.orderData;this.order=s}catch(s){this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود")}finally{this.loading=!1}}handleItemUpdated(s){if(!this.order)return;const{itemId:t,quantity:e,options:a}=s.detail,i=this.payload.items.update.filter((s=>s.id!==t));i.push({id:t,quantity:e,options:a??[]}),this.payload={...this.payload,items:{...this.payload.items,update:i}},this.order={...this.order,items:this.order.items.map((s=>s.id===t?{...s,quantity:e}:s))}}handleItemRemoved(s){if(!this.order)return;if(this.order.items.length<=1)return void salla.notify.error(salla.lang.getWithDefault("pages.orders.order_cannot_be_empty","لا يمكن إزالة جميع المنتجات من الطلب"));const{itemId:t}=s.detail;this.payload={...this.payload,items:{update:this.payload.items.update.filter((s=>s.id!==t)),remove:[...this.payload.items.remove,t]}},this.order={...this.order,items:this.order.items.filter((s=>s.id!==t))}}get hasChanges(){return this.payload.items.update.length>0||this.payload.items.remove.length>0}async saveOrder(){if(this.hasChanges){this.saveLoading=!0;try{const s=await salla.order.api.editOrder(this.orderId,this.payload);this.editPreview=s?.data?.data||s?.data,await(this.saveModal?.open())}catch(s){const t=s?.response?.data?.error?.message||s?.response?.data?.message;t&&salla.notify.error(t)}finally{this.saveLoading=!1}}}navigateToOrder(){const s=new URL(window.location.href);s.pathname=s.pathname.replace(/\/edit\/?$/,""),s.search="",window.location.href=s.href}handleConfirm(){this.confirming=!0,this.editPreview?.payment?.required&&this.editPreview.payment.payment_url?window.location.href=this.editPreview.payment.payment_url:this.navigateToOrder()}async cancelEditSession(){try{await salla.order.api.cancelEditSession(this.orderId),this.navigateToOrder()}catch(s){const t=s?.response?.data?.error?.message||s?.response?.data?.message;t&&salla.notify.error(t)}}renderSaveModal(){const s=this.editPreview,e=s?.totals?.remaining_amount?.amount>0,a=s?.totals?.refund_amount?.amount>0,i=s?.totals?.tax?.amount?.amount;return t("salla-modal",{ref:s=>this.saveModal=s,width:"md",onModalVisibilityChanged:async s=>{s.detail||(this.editPreview=null,this.confirming||await this.cancelEditSession(),this.confirming=!1)}},t("div",{class:"s-order-edit-modal"},t("h2",{class:"s-order-edit-modal-title"},salla.lang.getWithDefault("pages.orders.edit_summary_title","ملخص الطلب بعد التعديل")),s?.items?.length>0&&t("div",{class:"s-order-edit-modal-items"},s.items.map((s=>{const e=this.order?.items?.find((t=>t.id==s.id)),a=e?.product?.image?.url,i=s.options?.join("/ ");return t("div",{class:"s-order-edit-modal-item"},t("div",{class:"s-order-edit-modal-item-start"},a&&t("img",{src:a,alt:s.name,class:"s-order-edit-modal-item-image"}),t("div",null,t("p",{class:"s-order-edit-modal-item-name"},s.name),i&&t("span",{class:"s-order-edit-modal-item-options"},i))),t("div",{class:"s-order-edit-modal-item-end"},t("span",{class:"s-order-edit-modal-item-price",innerHTML:salla.money(s.price.amount)})))}))),s?.totals?.updated_products_total&&t("div",{class:"s-order-edit-modal-row"},t("span",{class:"s-order-edit-modal-row-label"},salla.lang.getWithDefault("pages.orders.modified_products_total","مجموع المنتجات المعدلة")),t("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(s.totals.updated_products_total.amount)})),i>0&&t("div",{class:"s-order-edit-modal-row"},t("span",{class:"s-order-edit-modal-tax-label"},t("i",{class:"sicon-info-circle s-order-edit-modal-tax-icon"}),salla.lang.getWithDefault("pages.orders.vat","ضريبة القيمة المضافة")),t("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(i)})),s?.totals?.total&&t("div",{class:"s-order-edit-modal-total"},t("span",{class:"s-order-edit-modal-total-label"},salla.lang.getWithDefault("pages.orders.order_total","اجمالي الطلب")),t("span",{class:"s-order-edit-modal-total-value",innerHTML:salla.money(s.totals.total.amount)})),a&&t("div",{class:"s-order-edit-modal-refund"},t("i",{class:"sicon-info-circle s-order-edit-modal-refund-icon"}),t("p",{class:"s-order-edit-modal-refund-text"},salla.lang.getWithDefault("pages.orders.refund_message","سيتم تحويل فارق المبلغ على نفس وسيلة الدفع"))),t("div",{class:"s-order-edit-modal-btn-wrapper"},t("salla-button",{onClick:()=>this.handleConfirm()},e?salla.lang.getWithDefault("pages.orders.pay_difference","دفع فارق المبلغ"):a?salla.lang.getWithDefault("pages.orders.confirm_and_receive_difference","تأكيد واستلام فارق المبلغ"):salla.lang.getWithDefault("pages.orders.confirm_changes","تأكيد التعديلات"),t("i",{class:"sicon-keyboard_arrow_left s-order-edit-modal-btn-icon"})))))}render(){if(this.loading)return t(e,null,t("salla-loading",null));if(this.expired)return t(e,null,t("div",{class:"s-order-edit-expired"},t("p",null,salla.lang.getWithDefault("pages.orders.edit_session_expired","انتهت مدة التعديل المتاحة")),t("salla-button",{onClick:()=>this.navigateToOrder()},salla.lang.getWithDefault("pages.orders.back_to_order","العودة إلى تفاصيل الطلب"))));if(this.error||!this.order)return t(e,null,t("div",{class:"no-content-placeholder"},t("i",{class:"sicon-shopping-bag icon"}),t("p",null,this.error)));const s=this.order.items&&this.order.items.length>0,a=this.order.customer_editing_session?.ends_at;return t(e,null,a&&t("div",{class:"s-order-edit-timer-wrapper"},t("salla-count-down",{prefixText:salla.lang.getWithDefault("pages.orders.edit_within","يمكنك التعديل خلال"),date:a,horizontal:!0,withButton:!0,autoSegments:!0,labeled:!1,size:"sm",color:"primary"})),t("div",{class:"s-order-edit-items-wrapper"},t("h2",{class:"s-order-edit-items-title"},salla.lang.getWithDefault("pages.orders.order_products","منتجات الطلب")),s?this.order.items.map(((s,e)=>[t("salla-order-edit-item",{key:s.id,item:s,orderId:this.orderId}),e<this.order.items.length-1?t("div",{class:"s-order-edit-items-divider"}):null])):t("div",{class:"no-content-placeholder"},t("i",{class:"sicon-shopping-bag icon"}),t("p",null,salla.lang.getWithDefault("common.elements.no_items","لا توجد عناصر")))),t("div",{class:"s-order-edit-actions"},t("salla-button",{onClick:()=>this.saveOrder(),loading:this.saveLoading,disabled:!this.hasChanges},salla.lang.getWithDefault("pages.orders.save_changes","حفظ التعديلات")),t("salla-button",{color:"gray",fill:"outline",onClick:()=>this.cancelEditSession()},salla.lang.getWithDefault("common.elements.cancel","الغاء"))),this.renderSaveModal())}get host(){return a(this)}};i.style="";export{i as salla_order_edit}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,h as s,H as i,a}from"./p-eYsXdqjv.js";import{S as r}from"./p-D4oPi1Ov.js";import{H as e}from"./p-CHf8XdiS.js";import"./p-CgtvEd63.js";var c='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>heart</title>\n<path d="M23.333 2.267c-3.547 0-5.779 1.605-7.333 3.061-1.555-1.456-3.787-3.061-7.333-3.061-5.955 0-8.667 5.045-8.667 9.733 0 8.503 10.147 14.735 15.513 16.841 0.156 0.061 0.321 0.092 0.487 0.092s0.331-0.031 0.487-0.092c5.367-2.107 15.513-8.339 15.513-16.841 0-4.688-2.712-9.733-8.667-9.733zM16 26.161c-5.537-2.309-13.333-7.799-13.333-14.161 0-3.517 1.856-7.067 6-7.067 2.983 0 4.656 1.451 6.384 3.203 0.5 0.508 1.399 0.508 1.899 0 1.728-1.752 3.401-3.203 6.384-3.203 4.144 0 6 3.549 6 7.067 0 6.363-7.796 11.852-13.333 14.161z"></path>\n</svg>\n';const o=class{constructor(s){if(t(this,s),salla.onReady((()=>{this.fitImageHeight=salla.config.get("store.settings.product.fit_type"),salla.wishlist.event.onAdded(((t,s)=>this.toggleFavoriteIcon(!0,s))),salla.wishlist.event.onRemoved(((t,s)=>this.toggleFavoriteIcon(!1,s))),this.placeholder=salla.url.asset(salla.config.get("theme.settings.placeholder"))})),salla.lang.onLoaded((()=>{this.remained=salla.lang.get("pages.products.remained"),this.donationAmount=salla.lang.get("pages.products.donation_amount"),this.startingPrice=salla.lang.get("pages.products.starting_price"),this.addToCart=salla.lang.get("pages.cart.add_to_cart"),this.outOfStock=salla.lang.get("pages.products.out_of_stock")})),this.product)try{this.productData="object"==typeof this.product?this.product:JSON.parse(this.product)}catch(t){salla.log("Bad json passed via product prop")}}initCircleBar(){let t=this.productData.quantity/(this.productData.quantity>100?2*this.productData.quantity:100)*100;this.pie.querySelector(".s-product-card-content-pie-svg-bar").style.strokeDashoffset=100-t}toggleFavoriteIcon(t=!0,s=null){s&&s!==this.productData.id||this.wishlistBtn?.classList.toggle("s-product-card-wishlist-added",t)}isInWishlist(){return salla.storage.get("salla::wishlist",[]).includes(this.productData?.id)}async handleWishlistClick(){const t=this.isInWishlist();this.toggleFavoriteIcon(!t);try{await salla.wishlist.toggle(this.productData.id)}catch{this.toggleFavoriteIcon(t)}}formatDate(t){let s=new Date(t);return`${s.getFullYear()}-${s.getMonth()+1}-${s.getDate()}`}getProductBadge(){return this.productData.promotion_title?s("div",{class:"s-product-card-promotion-title"},this.productData.promotion_title):this.showQuantity&&this.productData?.quantity?s("div",{class:"s-product-card-quantity"},this.remained," ",salla.helpers.number(this.productData?.quantity)):this.showQuantity&&this.productData?.is_out_of_stock?s("div",{class:"s-product-card-out-badge"},this.outOfStock):""}getPriceFormat(t){return t&&0!=t?salla.money(t):salla.config.get("store.settings.product.show_price_as_dash")?"-":""}getProductPrice(){return this.productData.is_on_sale?s("div",{class:"s-product-card-sale-price"},s("h4",{innerHTML:this.getPriceFormat(this.productData.sale_price)}),s("span",{innerHTML:this.getPriceFormat(this.productData?.regular_price)})):this.productData.starting_price?s("div",{class:"s-product-card-starting-price"},s("p",null,this.startingPrice),s("h4",{innerHTML:this.getPriceFormat(this.productData?.starting_price)})):s("h4",{class:"s-product-card-price",innerHTML:this.getPriceFormat(this.productData?.price)})}render(){const t={"s-product-card-entry":!0,"s-product-card-vertical":!this.horizontal&&!this.fullImage&&!this.minimal,"s-product-card-horizontal":this.horizontal&&!this.fullImage&&!this.minimal,"s-product-card-fit-height":this.fitImageHeight&&!this.isSpecial&&!this.fullImage&&!this.minimal,"s-product-card-special":this.isSpecial,"s-product-card-full-image":this.fullImage,"s-product-card-minimal":this.minimal,"s-product-card-compact":this.compact,"s-product-card-donation":this.productData?.donation,"s-product-card-shadow":this.shadowOnHover,"s-product-card-out-of-stock":this.productData?.is_out_of_stock},a=this.productData?.url?{href:this.productData.url,title:`Learn more about ${this.productData?.name}`}:{};return s(i,{key:"e0981508ab81f2a0bed4b763829d25792e55a692",id:`product-${this.productData?.id}`,class:t},s("div",{key:"8ed3f18aa60f4c63fcd8a5603683f76c6ec247a8",class:this.fullImage?"s-product-card-image-full":"s-product-card-image"},s("a",{key:"e412236f624d180312a7361c0bb43f4af05ac868",...a},s("img",{key:"a8517f1f3c5c2d15489aa5509bb667fb3ce98ca6",class:`s-product-card-image-${salla.url.is_placeholder(this.productData?.image?.url)?"contain":this.fitImageHeight?this.fitImageHeight:"cover"} lazy`,src:this.placeholder,alt:this.productData?.image?.alt||this.productData?.name,"data-src":this.productData?.image?.url||this.productData?.thumbnail}),this.fullImage||this.minimal?"":this.getProductBadge()),this.fullImage&&s("a",{key:"9b0841267856eeaf8fd3f44df9e11a2e82ea2554",...a,class:"s-product-card-overlay"}),this.horizontal||this.fullImage?"":s("salla-button",{shape:"icon",fill:"none",color:"light",loading:!1,"aria-label":"Add or remove to wishlist",ref:t=>this.wishlistBtn=t,class:"s-product-card-wishlist-btn animated",onClick:()=>this.handleWishlistClick()},s("span",{innerHTML:c}))),s("div",{key:"f027bc5aa8d3e46eeff5e0c2f22c33f06298884c",class:"s-product-card-content"},this.isSpecial&&this.productData?.quantity?s("div",{class:"s-product-card-content-pie",ref:t=>this.pie=t},s("span",null,s("b",null,salla.helpers.number(this.productData?.quantity)),this.remained),s("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"-2 -1 36 34",class:"s-product-card-content-pie-svg"},s("circle",{cx:"16",cy:"16",r:"15.9155",class:"s-product-card-content-pie-svg-base"}),s("circle",{cx:"16",cy:"16",r:"15.9155",class:"s-product-card-content-pie-svg-bar"}))):"",s("div",{key:"942aed0114c9155a7b397261032ec3d5f3bbf983",class:{"s-product-card-content-main":!0,"s-product-card-content-extra-padding":this.isSpecial}},s("h3",{key:"82e874903e2391cbda7df6cdbb41422341f66476",class:"s-product-card-content-title"},s("a",{key:"be7e564d2341c97d8431fa49e6a176548183929c",...a},this.productData?.name)),this.productData?.subtitle&&!this.minimal?s("p",{class:"s-product-card-content-subtitle"},this.productData?.subtitle):""),!this.productData?.donation||this.minimal||this.fullImage?"":[s("salla-progress-bar",{donation:this.productData?.donation}),s("div",{class:"s-product-card-donation-input"},this.productData?.donation?.can_donate?[s("label",{htmlFor:"donation-amount"},this.donationAmount," ",s("span",null,"*")),s("input",{type:"text",onInput:t=>{salla.helpers.inputDigitsOnly(t.target),this.addBtn.donatingAmount=t.target.value},id:"donation-amount",name:"donating_amount",class:"s-form-control",placeholder:this.donationAmount})]:"")],s("div",{key:"f565ee76394a00c047cdf3abacacdc351565ba1d",class:{"s-product-card-content-sub":!0,"s-product-card-content-extra-padding":this.isSpecial}},this.getProductPrice(),this.productData?.rating?.stars&&!this.minimal?s("div",{class:"s-product-card-rating"},s("span",{innerHTML:r}),s("span",null,this.productData.rating.stars)):""),this.isSpecial&&this.productData.discount_ends?s("salla-count-down",{date:this.formatDate(this.productData.discount_ends),"end-of-day":!0,boxed:!0,labeled:!0}):"",this.hideAddBtn||this.compact?"":s("div",{class:"s-product-card-content-footer"},s("salla-add-product-button",{fill:"outline",width:"wide",ref:t=>this.addBtn=t,"product-id":this.productData.id,"product-status":this.productData.status,"product-type":this.productData.type},s("slot",{name:"add-to-cart-label"},this.productData.add_to_cart_label)),this.horizontal||this.fullImage?s("salla-button",{shape:"icon",fill:"none",color:"light",loading:!1,ref:t=>this.wishlistBtn=t,"aria-label":"Add or remove to wishlist",class:"s-product-card-wishlist-btn animated",onClick:()=>this.handleWishlistClick(),"data-id":"{{ product.id }}"},s("span",{class:"text-xl",innerHTML:c})):"")),!this.hideAddBtn&&this.compact?s("div",{class:"s-product-card-content-footer"},s("salla-add-product-button",{ref:t=>this.addBtn=t,"product-id":this.productData.id,"product-status":this.productData.status,"product-type":this.productData.type,class:"s-add-product-button-compact"},s("slot",{name:"add-to-cart-label"},this.productData.add_to_cart_label))):"")}componentDidLoad(){document.lazyLoadInstance?.update(this.host.querySelectorAll(".lazy")),this.productData?.quantity&&this.isSpecial&&this.initCircleBar(),!salla.config.isGuest()&&salla.storage.get("salla::wishlist",[]).includes(this.productData?.id)&&this.toggleFavoriteIcon()}static get assetsDirs(){return["assets"]}get host(){return a(this)}};o.style='.s-product-card-image::before{font-family:"sallaicons";content:"\\ec1f" !important}.s-product-card-content-pie-svg circle{transition:stroke-dashoffset 1s linear;-webkit-transition:stroke-dashoffset 1s linear;-moz-transition:stroke-dashoffset 1s linear;-ms-transition:stroke-dashoffset 1s linear;-o-transition:stroke-dashoffset 1s linear;stroke:#E8EDF2;stroke-width:2px;stroke-linecap:round;fill:none}.s-product-card-content-pie-svg-bar{stroke:var(--color-primary) !important;stroke-dasharray:100 100;stroke-dashoffset:100}';const d=class{constructor(s){t(this,s),this.productCardComponent="custom-salla-product-card",this.apiUrl=""}componentWillLoad(){return salla.onReady().then((()=>{if(this.includes=e.parseJson(this.includes||this.host.getAttribute("includes")),Array.isArray(this.includes)||(this.includes=null),e.setIncludes(this.includes),this.sourceValueIsValid=!(!this.getSourceValue()&&!this.isSourceWithoutValue()),this.sourceValueIsValid){if(this.hasCustomComponent=!!customElements.get(this.productCardComponent),"json"===this.source)return this.productsData=this.getSourceValue(),void(this.isReady=!0);if("related"!=this.getSource()||salla.config.get("store.settings.product.related_products_enabled"))return salla.api.withoutNotifier((()=>salla.product.api.fetch({source:e.getApiSource(this.getSource()),source_value:this.getSourceValue(),limit:this.limit}))).then((t=>e.injectExtraFieldsToResponse(t))).then((t=>{this.productsData=t.data,this.isReady=!0,t.source=this.getSource(),t.sourceValue=this.getSourceValue(),salla.event.emit("salla-products-slider::products.fetched",t.data)}));this.isReady=!1}else salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`)}))}componentDidRender(){let t=0;const s=setInterval((()=>{this.host.querySelectorAll('[loading="lazy"]')?.forEach((t=>t.removeAttribute("loading"))),t++,t>=10&&clearInterval(s)}),1e3)}async componentDidLoad(){await Salla.hooks.registerComponent("salla-products-slider",this)}isSourceWithoutValue(){return["offers","latest","sales","top-rated"].includes(this.getSource())}getItemHTML(t){const i="landing-page"===this.getSource();i&&(t.url="");const a=i?void 0:()=>{e.saveProductSource(this.getSource())};if(this.hasCustomComponent&&"custom-salla-product-card"==this.productCardComponent.toLowerCase())return s("div",{class:"s-products-slider-card",onClick:a},s("custom-salla-product-card",{product:t,source:this.getSource(),"source-value":this.getSourceValue()}));if(this.hasCustomComponent){const i=document.createElement(this.productCardComponent);return i.setAttribute("product",JSON.stringify(t)),i.setAttribute("source",this.getSource()),i.setAttribute("source-value",this.getSourceValue()),s("div",{class:"s-products-slider-card",onClick:a,innerHTML:i.outerHTML})}return s("div",{class:"s-products-slider-card",onClick:a},s("salla-product-card",{"show-quantity":i,"hide-add-btn":i,"shadow-on-hover":!0,product:t}))}canRender(){return this.sourceValueIsValid&&this.isReady}getSource(){return e.getProductsSource(this.source)}getSourceValue(){return e.getProductsSourceValue(this.source,this.sourceValue)}render(){if(this.canRender())return s(i,{class:"s-products-slider-wrapper"},s("salla-slider",{class:"s-products-slider-slider",id:this.sliderId||`s-products-slider-${Math.random().toString(36).substr(2,9)}`,...this.sliderProps||{},"auto-play":this.autoplay,type:"carousel","block-title":this.blockTitle,"block-subTitle":this.subTitle,"display-all-url":this.displayAllUrl,sliderConfig:this.sliderConfig?this.sliderConfig:null},s("div",{slot:"items"},this.productsData?.map((t=>this.getItemHTML(t))))))}get host(){return a(this)}};d.style="";export{o as salla_product_card,d as salla_products_slider}
4
+ import{r as t,h as s,H as i,a}from"./p-6ZT_-rrT.js";import{S as r}from"./p-D4oPi1Ov.js";import{H as e}from"./p-CHf8XdiS.js";import"./p-CgtvEd63.js";var c='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>heart</title>\n<path d="M23.333 2.267c-3.547 0-5.779 1.605-7.333 3.061-1.555-1.456-3.787-3.061-7.333-3.061-5.955 0-8.667 5.045-8.667 9.733 0 8.503 10.147 14.735 15.513 16.841 0.156 0.061 0.321 0.092 0.487 0.092s0.331-0.031 0.487-0.092c5.367-2.107 15.513-8.339 15.513-16.841 0-4.688-2.712-9.733-8.667-9.733zM16 26.161c-5.537-2.309-13.333-7.799-13.333-14.161 0-3.517 1.856-7.067 6-7.067 2.983 0 4.656 1.451 6.384 3.203 0.5 0.508 1.399 0.508 1.899 0 1.728-1.752 3.401-3.203 6.384-3.203 4.144 0 6 3.549 6 7.067 0 6.363-7.796 11.852-13.333 14.161z"></path>\n</svg>\n';const o=class{constructor(s){if(t(this,s),salla.onReady((()=>{this.fitImageHeight=salla.config.get("store.settings.product.fit_type"),salla.wishlist.event.onAdded(((t,s)=>this.toggleFavoriteIcon(!0,s))),salla.wishlist.event.onRemoved(((t,s)=>this.toggleFavoriteIcon(!1,s))),this.placeholder=salla.url.asset(salla.config.get("theme.settings.placeholder"))})),salla.lang.onLoaded((()=>{this.remained=salla.lang.get("pages.products.remained"),this.donationAmount=salla.lang.get("pages.products.donation_amount"),this.startingPrice=salla.lang.get("pages.products.starting_price"),this.addToCart=salla.lang.get("pages.cart.add_to_cart"),this.outOfStock=salla.lang.get("pages.products.out_of_stock")})),this.product)try{this.productData="object"==typeof this.product?this.product:JSON.parse(this.product)}catch(t){salla.log("Bad json passed via product prop")}}initCircleBar(){let t=this.productData.quantity/(this.productData.quantity>100?2*this.productData.quantity:100)*100;this.pie.querySelector(".s-product-card-content-pie-svg-bar").style.strokeDashoffset=100-t}toggleFavoriteIcon(t=!0,s=null){s&&s!==this.productData.id||this.wishlistBtn?.classList.toggle("s-product-card-wishlist-added",t)}isInWishlist(){return salla.storage.get("salla::wishlist",[]).includes(this.productData?.id)}async handleWishlistClick(){const t=this.isInWishlist();this.toggleFavoriteIcon(!t);try{await salla.wishlist.toggle(this.productData.id)}catch{this.toggleFavoriteIcon(t)}}formatDate(t){let s=new Date(t);return`${s.getFullYear()}-${s.getMonth()+1}-${s.getDate()}`}getProductBadge(){return this.productData.promotion_title?s("div",{class:"s-product-card-promotion-title"},this.productData.promotion_title):this.showQuantity&&this.productData?.quantity?s("div",{class:"s-product-card-quantity"},this.remained," ",salla.helpers.number(this.productData?.quantity)):this.showQuantity&&this.productData?.is_out_of_stock?s("div",{class:"s-product-card-out-badge"},this.outOfStock):""}getPriceFormat(t){return t&&0!=t?salla.money(t):salla.config.get("store.settings.product.show_price_as_dash")?"-":""}getProductPrice(){return this.productData.is_on_sale?s("div",{class:"s-product-card-sale-price"},s("h4",{innerHTML:this.getPriceFormat(this.productData.sale_price)}),s("span",{innerHTML:this.getPriceFormat(this.productData?.regular_price)})):this.productData.starting_price?s("div",{class:"s-product-card-starting-price"},s("p",null,this.startingPrice),s("h4",{innerHTML:this.getPriceFormat(this.productData?.starting_price)})):s("h4",{class:"s-product-card-price",innerHTML:this.getPriceFormat(this.productData?.price)})}render(){const t={"s-product-card-entry":!0,"s-product-card-vertical":!this.horizontal&&!this.fullImage&&!this.minimal,"s-product-card-horizontal":this.horizontal&&!this.fullImage&&!this.minimal,"s-product-card-fit-height":this.fitImageHeight&&!this.isSpecial&&!this.fullImage&&!this.minimal,"s-product-card-special":this.isSpecial,"s-product-card-full-image":this.fullImage,"s-product-card-minimal":this.minimal,"s-product-card-compact":this.compact,"s-product-card-donation":this.productData?.donation,"s-product-card-shadow":this.shadowOnHover,"s-product-card-out-of-stock":this.productData?.is_out_of_stock},a=this.productData?.url?{href:this.productData.url,title:`Learn more about ${this.productData?.name}`}:{};return s(i,{key:"e0981508ab81f2a0bed4b763829d25792e55a692",id:`product-${this.productData?.id}`,class:t},s("div",{key:"8ed3f18aa60f4c63fcd8a5603683f76c6ec247a8",class:this.fullImage?"s-product-card-image-full":"s-product-card-image"},s("a",{key:"e412236f624d180312a7361c0bb43f4af05ac868",...a},s("img",{key:"a8517f1f3c5c2d15489aa5509bb667fb3ce98ca6",class:`s-product-card-image-${salla.url.is_placeholder(this.productData?.image?.url)?"contain":this.fitImageHeight?this.fitImageHeight:"cover"} lazy`,src:this.placeholder,alt:this.productData?.image?.alt||this.productData?.name,"data-src":this.productData?.image?.url||this.productData?.thumbnail}),this.fullImage||this.minimal?"":this.getProductBadge()),this.fullImage&&s("a",{key:"9b0841267856eeaf8fd3f44df9e11a2e82ea2554",...a,class:"s-product-card-overlay"}),this.horizontal||this.fullImage?"":s("salla-button",{shape:"icon",fill:"none",color:"light",loading:!1,"aria-label":"Add or remove to wishlist",ref:t=>this.wishlistBtn=t,class:"s-product-card-wishlist-btn animated",onClick:()=>this.handleWishlistClick()},s("span",{innerHTML:c}))),s("div",{key:"f027bc5aa8d3e46eeff5e0c2f22c33f06298884c",class:"s-product-card-content"},this.isSpecial&&this.productData?.quantity?s("div",{class:"s-product-card-content-pie",ref:t=>this.pie=t},s("span",null,s("b",null,salla.helpers.number(this.productData?.quantity)),this.remained),s("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"-2 -1 36 34",class:"s-product-card-content-pie-svg"},s("circle",{cx:"16",cy:"16",r:"15.9155",class:"s-product-card-content-pie-svg-base"}),s("circle",{cx:"16",cy:"16",r:"15.9155",class:"s-product-card-content-pie-svg-bar"}))):"",s("div",{key:"942aed0114c9155a7b397261032ec3d5f3bbf983",class:{"s-product-card-content-main":!0,"s-product-card-content-extra-padding":this.isSpecial}},s("h3",{key:"82e874903e2391cbda7df6cdbb41422341f66476",class:"s-product-card-content-title"},s("a",{key:"be7e564d2341c97d8431fa49e6a176548183929c",...a},this.productData?.name)),this.productData?.subtitle&&!this.minimal?s("p",{class:"s-product-card-content-subtitle"},this.productData?.subtitle):""),!this.productData?.donation||this.minimal||this.fullImage?"":[s("salla-progress-bar",{donation:this.productData?.donation}),s("div",{class:"s-product-card-donation-input"},this.productData?.donation?.can_donate?[s("label",{htmlFor:"donation-amount"},this.donationAmount," ",s("span",null,"*")),s("input",{type:"text",onInput:t=>{salla.helpers.inputDigitsOnly(t.target),this.addBtn.donatingAmount=t.target.value},id:"donation-amount",name:"donating_amount",class:"s-form-control",placeholder:this.donationAmount})]:"")],s("div",{key:"f565ee76394a00c047cdf3abacacdc351565ba1d",class:{"s-product-card-content-sub":!0,"s-product-card-content-extra-padding":this.isSpecial}},this.getProductPrice(),this.productData?.rating?.stars&&!this.minimal?s("div",{class:"s-product-card-rating"},s("span",{innerHTML:r}),s("span",null,this.productData.rating.stars)):""),this.isSpecial&&this.productData.discount_ends?s("salla-count-down",{date:this.formatDate(this.productData.discount_ends),"end-of-day":!0,boxed:!0,labeled:!0}):"",this.hideAddBtn||this.compact?"":s("div",{class:"s-product-card-content-footer"},s("salla-add-product-button",{fill:"outline",width:"wide",ref:t=>this.addBtn=t,"product-id":this.productData.id,"product-status":this.productData.status,"product-type":this.productData.type},s("slot",{name:"add-to-cart-label"},this.productData.add_to_cart_label)),this.horizontal||this.fullImage?s("salla-button",{shape:"icon",fill:"none",color:"light",loading:!1,ref:t=>this.wishlistBtn=t,"aria-label":"Add or remove to wishlist",class:"s-product-card-wishlist-btn animated",onClick:()=>this.handleWishlistClick(),"data-id":"{{ product.id }}"},s("span",{class:"text-xl",innerHTML:c})):"")),!this.hideAddBtn&&this.compact?s("div",{class:"s-product-card-content-footer"},s("salla-add-product-button",{ref:t=>this.addBtn=t,"product-id":this.productData.id,"product-status":this.productData.status,"product-type":this.productData.type,class:"s-add-product-button-compact"},s("slot",{name:"add-to-cart-label"},this.productData.add_to_cart_label))):"")}componentDidLoad(){document.lazyLoadInstance?.update(this.host.querySelectorAll(".lazy")),this.productData?.quantity&&this.isSpecial&&this.initCircleBar(),!salla.config.isGuest()&&salla.storage.get("salla::wishlist",[]).includes(this.productData?.id)&&this.toggleFavoriteIcon()}static get assetsDirs(){return["assets"]}get host(){return a(this)}};o.style='.s-product-card-image::before{font-family:"sallaicons";content:"\\ec1f" !important}.s-product-card-content-pie-svg circle{transition:stroke-dashoffset 1s linear;-webkit-transition:stroke-dashoffset 1s linear;-moz-transition:stroke-dashoffset 1s linear;-ms-transition:stroke-dashoffset 1s linear;-o-transition:stroke-dashoffset 1s linear;stroke:#E8EDF2;stroke-width:2px;stroke-linecap:round;fill:none}.s-product-card-content-pie-svg-bar{stroke:var(--color-primary) !important;stroke-dasharray:100 100;stroke-dashoffset:100}';const d=class{constructor(s){t(this,s),this.productCardComponent="custom-salla-product-card",this.apiUrl=""}componentWillLoad(){return salla.onReady().then((()=>{if(this.includes=e.parseJson(this.includes||this.host.getAttribute("includes")),Array.isArray(this.includes)||(this.includes=null),e.setIncludes(this.includes),this.sourceValueIsValid=!(!this.getSourceValue()&&!this.isSourceWithoutValue()),this.sourceValueIsValid){if(this.hasCustomComponent=!!customElements.get(this.productCardComponent),"json"===this.source)return this.productsData=this.getSourceValue(),void(this.isReady=!0);if("related"!=this.getSource()||salla.config.get("store.settings.product.related_products_enabled"))return salla.api.withoutNotifier((()=>salla.product.api.fetch({source:e.getApiSource(this.getSource()),source_value:this.getSourceValue(),limit:this.limit}))).then((t=>e.injectExtraFieldsToResponse(t))).then((t=>{this.productsData=t.data,this.isReady=!0,t.source=this.getSource(),t.sourceValue=this.getSourceValue(),salla.event.emit("salla-products-slider::products.fetched",t.data)}));this.isReady=!1}else salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`)}))}componentDidRender(){let t=0;const s=setInterval((()=>{this.host.querySelectorAll('[loading="lazy"]')?.forEach((t=>t.removeAttribute("loading"))),t++,t>=10&&clearInterval(s)}),1e3)}async componentDidLoad(){await Salla.hooks.registerComponent("salla-products-slider",this)}isSourceWithoutValue(){return["offers","latest","sales","top-rated"].includes(this.getSource())}getItemHTML(t){const i="landing-page"===this.getSource();i&&(t.url="");const a=i?void 0:()=>{e.saveProductSource(this.getSource())};if(this.hasCustomComponent&&"custom-salla-product-card"==this.productCardComponent.toLowerCase())return s("div",{class:"s-products-slider-card",onClick:a},s("custom-salla-product-card",{product:t,source:this.getSource(),"source-value":this.getSourceValue()}));if(this.hasCustomComponent){const i=document.createElement(this.productCardComponent);return i.setAttribute("product",JSON.stringify(t)),i.setAttribute("source",this.getSource()),i.setAttribute("source-value",this.getSourceValue()),s("div",{class:"s-products-slider-card",onClick:a,innerHTML:i.outerHTML})}return s("div",{class:"s-products-slider-card",onClick:a},s("salla-product-card",{"show-quantity":i,"hide-add-btn":i,"shadow-on-hover":!0,product:t}))}canRender(){return this.sourceValueIsValid&&this.isReady}getSource(){return e.getProductsSource(this.source)}getSourceValue(){return e.getProductsSourceValue(this.source,this.sourceValue)}render(){if(this.canRender())return s(i,{class:"s-products-slider-wrapper"},s("salla-slider",{class:"s-products-slider-slider",id:this.sliderId||`s-products-slider-${Math.random().toString(36).substr(2,9)}`,...this.sliderProps||{},"auto-play":this.autoplay,type:"carousel","block-title":this.blockTitle,"block-subTitle":this.subTitle,"display-all-url":this.displayAllUrl,sliderConfig:this.sliderConfig?this.sliderConfig:null},s("div",{slot:"items"},this.productsData?.map((t=>this.getItemHTML(t))))))}get host(){return a(this)}};d.style="";export{o as salla_product_card,d as salla_products_slider}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as t}from"./p-eYsXdqjv.js";const r=class{constructor(t){s(this,t),this.height="10px";try{if(this.donation){let s="string"==typeof this.donation?JSON.parse(this.donation):this.donation;s.can_donate&&s.target_amount?(s.target_end_date="0000-00-00"==s.target_end_date?null:s.target_end_date,this.value=s.collected_amount,this.target=s.target_amount,this.header=salla.lang.get("pages.products.target"),this.message=s.target_end_date?salla.lang.get("pages.products.donation_target_date")+" "+s.target_end_date:""):this.message=s.target_amount?s.target_message:""}}catch(s){salla.log("Wrong donation json")}salla.lang.onLoaded((()=>{this.header=this.header?.replace("pages.products.target",salla.lang.get("pages.products.target")),this.message=this.message?.replace("pages.products.donation_target_date",salla.lang.get("pages.products.donation_target_date"))})),salla.onReady((()=>{this.color=this.color||salla.config.get("theme.color.primary","#ffd5c4"),this.unit||(this.unit=salla.config.currency().symbol)}))}getPercentage(){return this.value/this.target*100}render(){return this.target||this.message?t("div",{class:"s-progress-bar-container"},this.header?t("div",{class:"s-progress-bar-header"},this.header):"",this.getProgressBar(),this.message?t("span",{class:"s-progress-bar-message"},this.message):""):""}getProgressBar(){return this.target?[this.hideUnits?null:t("div",{class:"s-progress-bar-target-section"},t("span",{innerHTML:`${salla.helpers.number(this.value)} ${this.unit}`}),t("span",{innerHTML:`${salla.helpers.number(this.target)} ${this.unit}`})),t("div",{class:"s-progress-bar-wrapper",style:{height:this.height}},t("div",{class:{"s-progress-bar-progress":!0,"s-progress-bar-progress-stripped":this.stripped},style:{width:`${this.getPercentage()}%`,backgroundColor:this.color}}))]:null}};r.style="";export{r as salla_progress_bar}
4
+ import{r as s,h as t}from"./p-6ZT_-rrT.js";const r=class{constructor(t){s(this,t),this.height="10px";try{if(this.donation){let s="string"==typeof this.donation?JSON.parse(this.donation):this.donation;s.can_donate&&s.target_amount?(s.target_end_date="0000-00-00"==s.target_end_date?null:s.target_end_date,this.value=s.collected_amount,this.target=s.target_amount,this.header=salla.lang.get("pages.products.target"),this.message=s.target_end_date?salla.lang.get("pages.products.donation_target_date")+" "+s.target_end_date:""):this.message=s.target_amount?s.target_message:""}}catch(s){salla.log("Wrong donation json")}salla.lang.onLoaded((()=>{this.header=this.header?.replace("pages.products.target",salla.lang.get("pages.products.target")),this.message=this.message?.replace("pages.products.donation_target_date",salla.lang.get("pages.products.donation_target_date"))})),salla.onReady((()=>{this.color=this.color||salla.config.get("theme.color.primary","#ffd5c4"),this.unit||(this.unit=salla.config.currency().symbol)}))}getPercentage(){return this.value/this.target*100}render(){return this.target||this.message?t("div",{class:"s-progress-bar-container"},this.header?t("div",{class:"s-progress-bar-header"},this.header):"",this.getProgressBar(),this.message?t("span",{class:"s-progress-bar-message"},this.message):""):""}getProgressBar(){return this.target?[this.hideUnits?null:t("div",{class:"s-progress-bar-target-section"},t("span",{innerHTML:`${salla.helpers.number(this.value)} ${this.unit}`}),t("span",{innerHTML:`${salla.helpers.number(this.target)} ${this.unit}`})),t("div",{class:"s-progress-bar-wrapper",style:{height:this.height}},t("div",{class:{"s-progress-bar-progress":!0,"s-progress-bar-progress-stripped":this.stripped},style:{width:`${this.getPercentage()}%`,backgroundColor:this.color}}))]:null}};r.style="";export{r as salla_progress_bar}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as t}from"./p-eYsXdqjv.js";import{a as i}from"./p-CgtvEd63.js";import{a as e}from"./p-BedNk7k1.js";import{S as a}from"./p-8Tsmrwno.js";import{S as l}from"./p-0-eTJXSD.js";const o=class{constructor(t){s(this,t),this.defaultEvent="gifting:open",this.selectImageForYourGift=salla.lang.get("blocks.buy_as_gift.select_image_or_upload"),this.currentStep=1,this.showCalendar=!1,this.showGiftText=!1,this.currentLang="",this.parentClass="is-current-step-1",this.errors={},this.gift=void 0,this.selectedGiftTextOption=void 0,this.selectedCountryId=void 0,this.selectedCountryCode=void 0,this.loadingCities=!1,this.loadingRegions=!1,this.regions=[],this.selectedRegionId=void 0,this.isKSA=!1,this.step2Animated=!1,this.showTextArea=!1,this.selectedImage=void 0,this.uploadedImage=void 0,this.selectedText=void 0,this.hasError=!1,this.timeZone=null,this.receiverCountryCode=salla.config.get("store.scope.countries")?.[0]||salla.config.get("store.store_country")||"SA",this.hostId=`salla-gifting-${Math.random().toString(36).slice(2,10)}`,this.formSelector="form.product-form, form.form--product-options",salla.lang.onLoaded((()=>{this.selectImageOrUpload=salla.lang.get("blocks.buy_as_gift.select_image_or_upload"),this.selectImageForYourGift=salla.lang.get("blocks.buy_as_gift.select_image_for_your_gift"),this.sectionTitle=salla.lang.get("blocks.buy_as_gift.gift_the_one_you_love"),this.sectionSubtitle=salla.lang.get("blocks.buy_as_gift.gift_the_one_you_love_message"),this.sectionBtnText=salla.lang.get("blocks.buy_as_gift.send_as_a_gift"),this.giftDetails=salla.lang.get("blocks.buy_as_gift.gift_details"),this.selectGiftMessage=salla.lang.get("blocks.buy_as_gift.select_gift_message"),this.giftCustomText=salla.lang.get("blocks.buy_as_gift.gift_custom_text"),this.textId=salla.lang.get("blocks.buy_as_gift.text_id"),this.incorrectGiftText=salla.lang.get("blocks.buy_as_gift.incorrect_gift_text"),this.nextStep=salla.lang.get("blocks.buy_as_gift.next_step"),this.senderNameLabel=salla.lang.get("blocks.buy_as_gift.sender_name"),this.receiverNameFieldLabel=salla.lang.get("blocks.buy_as_gift.receiver_name"),this.receiverMobileFieldLabel=salla.lang.get("blocks.buy_as_gift.receiver_mobile"),this.receiverCountryFieldLabel=salla.lang.get("blocks.buy_as_gift.receiver_country"),this.ksa=salla.lang.get("pages.checkout.ksa"),this.selectCity=salla.lang.get("pages.checkout.select_city"),this.selectCountry=salla.lang.get("pages.checkout.select_country"),this.selectCityInfo=salla.lang.get("blocks.buy_as_gift.city_info"),this.receiverCityFieldLabel=salla.lang.get("blocks.buy_as_gift.receiver_city"),this.receiverRegionFieldLabel=salla.lang.get("blocks.buy_as_gift.receiver_region")||salla.lang.get("pages.checkout.region"),this.selectRegion=salla.lang.get("pages.checkout.select_region"),this.receiverEmailFieldLabel=salla.lang.get("blocks.buy_as_gift.receiver_email"),this.emailPlaceholder=salla.lang.get("common.elements.email_placeholder"),this.sendLater=salla.lang.get("blocks.buy_as_gift.send_later"),this.selectSendDateAndTime=salla.lang.get("blocks.buy_as_gift.select_send_date_and_time"),this.canNotEditOrderAfterSelectDate=salla.lang.get("blocks.buy_as_gift.can_not_edit_order_after_select_date"),this.sendGift=salla.lang.get("blocks.buy_as_gift.send_gift"),this.donationRequired=salla.lang.get("pages.products.donation_amount_required"),this.currentLang=salla.lang.locale})),salla.event.on(this.defaultEvent,(()=>{this.open()}))}isPhysical(){return this.physicalProducts||this.physical}componentDidLoad(){salla.event.product.onPriceUpdated((()=>{const s=document.querySelector(".s-quantity-input-input");this.quantity=s?.value}))}getFormDataFromForm(){if(!this.formSelector)return null;const s=document.querySelector(this.formSelector);return s?new FormData(s):null}mergeObjectToFormData(s,t,i){for(let e in s){if(!s.hasOwnProperty(e)||null==s[e])continue;const a=i?`${i}[${e}]`:e;"object"!=typeof s[e]||null===s[e]||s[e]instanceof File?t.set(a,s[e]):this.mergeObjectToFormData(s[e],t,a)}return t}async open(){if(salla.config.isGuest())return salla.api.auth.setAfterLoginEvent(this.defaultEvent),void salla.event.dispatch("login::open",{withoutReload:!0});await this.modal.open();const s=this.productId?()=>salla.product.getGiftProductDetails(this.productId):()=>salla.cart.getGiftCartDetails();return await salla.api.withoutNotifier(s).then((s=>{this.gift=s.data,this.senderName=this.gift.sender_name})).catch((s=>{this.hasError=!0,this.errorMessage=s.response?.data?.error?.message||s.response?.data})).finally((()=>this.modal.stopLoading()))}async close(){return this.modal.close()}async setWrapperHeight(s=1,t=250,i=0,e=0){let a=document.querySelector(`#${this.hostId} .gift-step-${s}`);const l=()=>{this.stepsWrapper.style.height=e?`${e}px`:a.offsetHeight+i+"px"};this.step2Animated&&2===s?requestAnimationFrame(l):setTimeout(l,t)}toggleCalendar(){this.showCalendar=!this.showCalendar,this.setWrapperHeight(2,150,0)}toggleGiftText(s){this.textSelect?.classList.remove("s-form-has-error");let t=s.target.children[s.target.selectedIndex].getAttribute("data-id"),i="custom"==t;this.showGiftText=i,t?(this.selectedGiftTextOption=t,this.selectedText=i?void 0:s.target.value,this.setWrapperHeight(1,150,5)):(this.textArea.value="",this.selectedText=void 0,this.selectedGiftTextOption=void 0,this.setWrapperHeight(1,150,-15))}async goToStep2(){return this.selectedGiftTextOption?"custom"!=this.selectedGiftTextOption||this.selectedText?(this.textSelect.classList.remove("s-form-has-error"),this.customTextArea.classList.remove("s-form-has-error"),this.setWrapperHeight(2,600,0),(new i.timeline).add({targets:this.step1Elems.querySelectorAll(`#${this.hostId} .anime-item`),opacity:[1,0],translateX:[0,50],delay:i.stagger(70),duration:1200}).add({targets:".gift-step-2",translateX:["-110%",0],opacity:[0,1]},"-=1800").add({targets:this.step2Elems.querySelectorAll(`#${this.hostId} .anime-item`),opacity:[0,1],translateX:[-50,0],delay:i.stagger(70),duration:1200,complete:()=>{this.step2Elems.querySelectorAll(`#${this.hostId} .anime-item`).forEach((s=>{s.classList.remove("opacity-0"),s.removeAttribute("style")})),this.step2Animated=!0}},"-=1200"),this.currentStep=2,void(this.parentClass=`is-current-step-${this.currentStep}`)):(this.textSelect.classList.remove("s-form-has-error"),void this.customTextArea.classList.add("s-form-has-error")):(this.textSelect.classList.add("s-form-has-error"),void this.customTextArea.classList.remove("s-form-has-error"))}goToStep1(s){s.preventDefault();let t=new i.timeline({autoplay:!1});t.add({targets:this.step2Elems.querySelectorAll(`#${this.hostId} .anime-item`),opacity:[1,0],translateX:[0,-50],delay:i.stagger(70),duration:1200}).add({targets:".gift-step-1",translateX:["110%",0],opacity:[0,1]},"-=1800").add({targets:this.step1Elems.querySelectorAll(`#${this.hostId} .anime-item`),opacity:[0,1],translateX:[50,0],delay:i.stagger(70),duration:1200,complete:()=>{this.step1Elems.querySelectorAll(`#${this.hostId} .anime-item`).forEach((s=>{s.classList.remove("opacity-0"),s.removeAttribute("style")}))}},"-=1200"),t.play(),this.step2Animated=!1,this.setWrapperHeight(1,600,0),this.currentStep=1,this.parentClass=`is-current-step-${this.currentStep}`}getFilepondPlaceholder(){return`<div class="s-gifting-filepond-placeholder"><span class="s-gifting-filepond-placeholder-icon"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>images</title>\n<path d="M22.667 29.333h-13.333c-3.676 0-6.667-2.991-6.667-6.667v-13.333c0-0.737-0.597-1.333-1.333-1.333s-1.333 0.596-1.333 1.333v13.333c0 5.145 4.187 9.333 9.333 9.333h13.333c0.736 0 1.333-0.596 1.333-1.333s-0.597-1.333-1.333-1.333zM22.667 5.333c-2.205 0-4 1.795-4 4s1.795 4 4 4 4-1.795 4-4-1.795-4-4-4zM22.667 10.667c-0.735 0-1.333-0.597-1.333-1.333s0.599-1.333 1.333-1.333 1.333 0.597 1.333 1.333-0.599 1.333-1.333 1.333zM25.333 0h-13.333c-3.676 0-6.667 2.991-6.667 6.667v13.333c0 1.055 0.268 2.040 0.707 2.927 0.039 0.099 0.088 0.188 0.151 0.277 1.137 2.053 3.301 3.463 5.809 3.463h13.333c3.676 0 6.667-2.991 6.667-6.667v-13.333c0-3.676-2.991-6.667-6.667-6.667zM12 24c-1.244 0-2.344-0.583-3.077-1.476l5.721-7.047 6.629 8.523zM29.333 20c0 2.205-1.795 4-4 4h-0.68l-8.933-11.485c-0.251-0.32-0.633-0.511-1.039-0.515h-0.015c-0.401 0-0.781 0.181-1.035 0.492l-5.632 6.935v-12.76c0-2.205 1.795-4 4-4h13.333c2.205 0 4 1.795 4 4z"></path>\n</svg>\n</span><p class="s-gifting-filepond-placeholder-text">${this.selectImageOrUpload?this.selectImageOrUpload:""}</p></div>`}setPreview(s){this.uploader?.classList.add("has-bg");var t=document.querySelector(`#${this.hostId}.filepond-bg`)?document.querySelector(`#${this.hostId} .filepond-bg`):document.createElement("div");t.classList.add("filepond-bg"),t.classList.remove("s-hidden"),t.style.backgroundImage="url('"+s.url+"')",this.uploader?.querySelector(".filepond--root")?.appendChild(t),this.uploadedImage=s.url,this.gift&&this.gift.gift_images.length&&this.setWrapperHeight(1,150,0)}removePreview(){this.uploader.classList.remove("has-bg");let s=document.querySelector(`#${this.hostId} .filepond-bg`);s.removeAttribute("style"),s.classList.add("s-hidden"),this.handleRemoveImage()}handleTextAreaChange(s){this.selectedText=s.target.value,this.customTextArea.classList.remove("s-form-has-error")}clearError(s){if(this.errors?.[s]){const{[s]:t,...i}=this.errors;this.errors=i}}handleSenderName(s){this.senderName=s.target.value,this.clearError("sender_name")}handleReceiverName(s){this.receiverName=s.target.value,this.clearError("receiver.name")}handleReceiverCity(s){this.receiverCity=s.target.value,this.clearError("receiver.city_id")}async handleCountryChange(s){const t=Number(s.target.value);this.selectedCountryId=t,this.clearError("receiver.country");const i=this.gift?.countries?.find((s=>s.id==t));if(this.selectedCountryCode=i?.country_code,this.isKSA="SA"===i?.country_code,this.regions=[],this.selectedRegionId=void 0,this.gift={...this.gift,cities:[]},this.receiverCity=void 0,!t||0===this.gift?.countries?.length)return this.selectedCountryCode=void 0,this.isKSA=!1,void this.setWrapperHeight(2,0,0);if(this.isKSA){this.loadingRegions=!0,this.setWrapperHeight(2,0,0);try{const s=await salla.api.request(`shipping/countries/${t}/regions`);s&&s.data&&(this.regions=s.data)}catch(s){console.error("Error fetching regions:",s)}finally{this.loadingRegions=!1,this.setWrapperHeight(2,0,0)}}else{this.loadingCities=!0,this.setWrapperHeight(2,0,0);try{const s=await salla.api.request(`shipping/cities?for_branch=0&country_id=${t}`);s&&s.data&&(this.gift={...this.gift,cities:s.data})}catch(s){console.error("Error fetching cities:",s)}finally{this.loadingCities=!1}}}async handleRegionChange(s){const t=Number(s.target.value);if(this.selectedRegionId=t,this.clearError("receiver.region"),this.gift={...this.gift,cities:[]},this.receiverCity=void 0,t){this.loadingCities=!0;try{const s=await salla.api.request(`shipping/cities?for_branch=0&country_id=${this.selectedCountryId}&region_id=${t}`);s&&s.data&&(this.gift={...this.gift,cities:s.data})}catch(s){console.error("Error fetching cities:",s)}finally{this.loadingCities=!1,this.setWrapperHeight(2,0,0)}}}handleUploadImage(s){this.uploadedImage=s,this.gift&&this.gift.gift_images.length&&this.setWrapperHeight(1,150,0)}handleRemoveImage(){this.uploadedImage="",this.gift&&this.gift.gift_images.length&&this.setWrapperHeight(1,150,0)}handlePhoneInputChange(s){let t=s.detail;this.receiverMobile=t.number,this.receiverCountryCode=t.country_code,this.clearError("receiver.mobile")}handleDateTimePicker(s){this.deliveryDate=s.detail}getCalendarClasses(){return{"s-form-group":!0,"anime-item":!0,"s-gifting-calendar":!0,shown:this.showCalendar,hide:!this.showCalendar,"s-form-has-error":!!this.errors&&this.errors.deliver_at}}async submitForm(){const s=document.querySelector("#donating-amount")?.value;if(this.calendarFormGroup.classList.remove("s-form-has-error"),this.errors&&(this.errors={},this.setWrapperHeight(2,150,0)),this.showCalendar&&!this.deliveryDate)return void this.calendarFormGroup.classList.add("s-form-has-error");const t=[{key:"sender_name",value:this.senderName,label:this.senderNameLabel},{key:"receiver.name",value:this.receiverName,label:this.receiverNameFieldLabel},{key:"receiver.mobile",value:this.receiverMobile,label:this.receiverMobileFieldLabel},...this.isPhysical()?[{key:"receiver.country",value:this.selectedCountryId,label:this.receiverCountryFieldLabel},...this.isKSA?[{key:"receiver.region",value:this.selectedRegionId,label:this.receiverRegionFieldLabel}]:[],{key:"receiver.city_id",value:this.receiverCity,label:this.receiverCityFieldLabel}]:[]],i={};if(t.forEach((({key:s,value:t,label:e})=>{t||(i[s]=salla.lang.get("common.errors.field_required",{attribute:e}))})),Object.keys(i).length)return this.errors=i,void this.setWrapperHeight(2,150,0);const e={text:this.selectedText,sender_name:this.senderName,quantity:this.quantity,deliver_at:this.showCalendar?this.deliveryDate:null,image_url:this.uploadedImage??this.selectedImage,donation_amount:s||null,receiver:{name:this.receiverName,mobile_country_code:this.receiverCountryCode,mobile:this.receiverMobile,...this.isPhysical()&&this.selectedCountryCode?{country_code:this.selectedCountryCode}:{},...this.isPhysical()&&this.selectedRegionId?{region_id:this.selectedRegionId}:{},...this.receiverCity&&this.isPhysical()?{city_id:this.receiverCity}:{}},has_apple_pay:salla.helpers.hasApplePay()};let a;this.productId&&this.formSelector&&(a=this.getFormDataFromForm()||new FormData,a=this.mergeObjectToFormData(e,a));const l=this.productId?()=>salla.product.addProductGiftToCart(this.productId,a,!0):()=>salla.cart.addCartGiftToCart(e,!0);return await l().then((()=>this.modal.close())).catch((s=>{s.response&&422==s.response.status?this.errors=s.response.data.error.fields:console.log(s),this.setWrapperHeight(2,150,0)}))}step2ItemClass(s=""){const t="anime-item"+(this.step2Animated?"":" opacity-0");return s?`${s} ${t}`:t}generateClass(){return{"s-gifting-widget":!0,"s-gifting-widget-vertical":!!this.vertical,"s-gifting-widget-horizontal":!this.vertical}}async handleGiftButtonClick(){if(this.productId&&this.formSelector){const s=document.querySelector(this.formSelector);if(!s)return void console.error("SallaGifting:: Form not found in the document!");if(!(s instanceof HTMLFormElement))return void console.error("SallaGifting:: The specified selector does not correspond to a form tag!");if(!s.reportValidity())return console.error("SallaGifting:: Form is not valid!"),void salla.error(salla.lang.get("common.messages.required_fields"))}const s=document.querySelector(`salla-product-options[product-id="${this.productId}"]`);!s||await s.reportValidity()?this.open():salla.error(salla.lang.get("common.messages.required_fields"))}render(){return[t("div",{key:"f20cc2c84e987b34bb862f72a8f639894ed4150e"},t("salla-list-tile",{key:"c52aa5e975f9ed1707c3175fa66109f447749ee7",class:this.generateClass()},t("div",{key:"2bf7065f32132dde95dacfdea44e34c08cc4e61c",slot:"title"},this.vertical?t("span",{innerHTML:l}):"",t("h3",{key:"7a9a70b6841a708c322f5bb729e940e4da823261"},this.widgetTitle?this.widgetTitle:this.sectionTitle)),t("div",{key:"c346f2baa8e6a1adf9b0f89e9b50d236e65116cb",slot:"subtitle"},t("div",{key:"26c908af9687b0c77554054212f5c8251dc45bf3"},this.widgetSubtitle?this.widgetSubtitle:this.sectionSubtitle)),t("div",{key:"f91bf3811c383773425af74941a2067e2f62dbb7",slot:"action"},t("salla-button",{key:"0639c4b9cc4d81f300f6b087e1c10815b1610c75",color:"primary",fill:"outline",width:"wide",class:"s-gifting-widget-action",onClick:()=>this.handleGiftButtonClick()},t("slot",{key:"06567fa7406ae6502e8f3211ecab6161c4a7e397",name:"widget-btn-content"},t("div",{key:"f895900d17947b006f6aef4695b855eba4737ed2",class:"s-gifting-widget-action-content"},t("span",{key:"bd3170b8efa2a0c95f61718afd69e5473adae20a",innerHTML:l}),"  ",t("span",{key:"cdc3d1df35ad0e7334bc289f9fff2d312d709724"},this.sectionBtnText)))))),t("salla-modal",{key:"a98b913100edfa92156baeee766f6141818ebd8b",id:this.hostId,isLoading:!0,class:"s-gifting-modal",width:"sm",ref:s=>this.modal=s},t("div",{key:"6b438c581e600cbcfeb5260bae8371a1fbefa29c",slot:"loading"},t("div",{key:"ada9e9bb0355755eade9ff7846334cb5ae093e6f",class:"s-gifting-skeleton"},t("div",{key:"11d2e41b6acb933f5b006cc9f0b0b46470892c6a",class:"s-gifting-modal-header"},t("salla-skeleton",{key:"141be7d6aa83fed682f8ab6a3708597dbb4dba11",type:"circle",height:"5rem",width:"5rem"}),t("h2",{key:"65eba6244b5507397c8e50ef40f695e7eebe0b96",class:"s-gifting-modal-title"},t("div",{key:"0f2488d19d2de0a728377b9f475b70073f6f196a",class:"s-gifting-modal-badge-wrapper"},t("salla-skeleton",{key:"b648340418099246c8b83b308f116412fdb6cbc9",height:"15px",width:"150px"})))),t("div",{key:"8255e53b49f572ef3c4485cf7e84540dac019f89",class:"s-gifting-skeleton-content"},t("salla-skeleton",{key:"0b05db8e76a9a53032b1643d8c4e223b8b641e30",height:"10px",width:"150px"}),t("salla-skeleton",{key:"c585bf04433e46ce8e89d9bfc3402faf4cfbb21a",height:"230px"}),t("salla-skeleton",{key:"0c09063b73e3aecb6a1879cdc93b60a6bcb9b2cc",height:"10px",width:"150px"}),t("salla-skeleton",{key:"88f55e5ffded2f784002b44e49f3ab2d22a7c067",height:"30px"}),t("salla-skeleton",{key:"6e1edd3b031f051ec24149ec690d2e4f04f9c557",height:"40px"})))),t("slot",{key:"bff6a067b10a31c39f22e18c6bdf5a60f56ef116",name:"header"}),this.hasError?t("salla-placeholder",{alignment:"center"},t("span",{slot:"title"},this.errorMessage||salla.lang.get("common.errors.empty_results")),t("span",{slot:"description"}," ")):[t("div",{class:"s-gifting-modal-header"},t("span",{class:"s-gifting-modal-icon"},t("span",{innerHTML:l})),t("h2",{class:"s-gifting-modal-title"},t("div",{class:"s-gifting-modal-badge-wrapper"},t("div",{class:"s-gifting-modal-badge"},t("span",null,t("span",null,this.currentStep),"/2")),t("span",null,this.giftDetails)))),t("div",{class:"s-gifting-steps-wrapper "+this.parentClass,ref:s=>this.stepsWrapper=s},t("div",{class:"s-gifting-step-one gift-step-1",ref:s=>this.step1Elems=s},t("div",{class:"s-gifting-modal-uploader-title anime-item"},this.selectImageForYourGift),t("div",{class:"s-gifting-modal-uploader anime-item",ref:s=>this.uploader=s},t("span",{class:"s-gifting-remove-preview",onClick:()=>this.removePreview(),innerHTML:a}),this.selectImageOrUpload&&t("salla-file-upload",{"instant-upload":!0,name:"image_url",url:salla.url.api(salla.product.api.getUrl("giftImage")),onUploaded:s=>this.handleUploadImage(s.detail),labelIdle:this.getFilepondPlaceholder(),onRemoved:()=>this.handleRemoveImage()})),t("div",{class:"anime-item"},!this.uploadedImage&&this.gift&&this.gift.gift_images&&this.gift.gift_images.length>0?t("salla-slider",{id:"gifting-slider",loop:!1,"controls-outer":!0,class:"s-gifting-slider",type:"carousel"},t("div",{slot:"items"},this.gift&&this.gift.gift_images?this.gift?.gift_images.map((s=>t("a",{class:"s-gifting-clickable s-gifting-image",onClick:()=>this.setPreview(s)},t("img",{style:{width:"120px"},src:s.url,alt:`${s.id}`})))):"")):""),t("div",{class:"anime-item"},t("div",{class:"s-form-group s-gifting-selectText",ref:s=>this.textSelect=s},t("select",{id:"gift-text-selection",name:"gift-text-selection",class:"s-form-control s-gifting-select",onChange:s=>this.toggleGiftText(s)},t("option",{"data-id":null,selected:!0},this.selectGiftMessage),this.gift&&this.gift.gift_texts?this.gift?.gift_texts.map((s=>t("option",{"data-id":s.id,value:s.text,key:s.id},s.text))):"",t("option",{"data-id":"custom"},this.giftCustomText))),t("div",{class:this.showGiftText?"s-form-group s-gifting-textarea shown":"s-form-group s-gifting-textarea hide",ref:s=>this.customTextArea=s},t("label",{htmlFor:"gift-custom-text",class:"s-form-label"},this.giftCustomText),t("div",{class:"mt-1"},t("textarea",{onInput:s=>this.handleTextAreaChange(s),rows:4,ref:s=>this.textArea=s,name:"gift-custom-text",id:"gift-custom-text",class:"s-form-control"})))),t("div",{class:"anime-item"},t("salla-button",{color:"primary",width:"wide",onClick:()=>this.goToStep2()},t("span",null,this.nextStep)))),t("div",{class:"s-gifting-step-two gift-step-2",ref:s=>this.step2Elems=s},t("div",{class:this.step2ItemClass(this.errors?.sender_name?"s-form-group s-form-has-error":"s-form-group")},t("label",{htmlFor:"sender_name",class:"s-form-label"},this.senderNameLabel),t("input",{type:"text",class:"s-form-control",name:"sender_name",id:"sender_name",value:this.senderName,onInput:s=>this.handleSenderName(s),placeholder:""}),this.errors&&this.errors.sender_name?t("span",{class:"s-gifting-error"},this.errors.sender_name):""),t("div",{class:this.step2ItemClass(this.errors?.["receiver.name"]?"s-form-group s-form-has-error":"s-form-group")},t("label",{htmlFor:"receiver_name",class:"s-form-label"},this.receiverNameFieldLabel),t("input",{type:"text",class:"s-form-control",name:"receiver_name",id:"receiver_name",value:"",onInput:s=>this.handleReceiverName(s),placeholder:""}),this.errors&&this.errors["receiver.name"]?t("span",{class:"s-gifting-error"},this.errors["receiver.name"]):""),t("div",{class:this.step2ItemClass(this.errors?.["receiver.mobile"]?"s-form-group s-form-has-error":"s-form-group")},t("label",{class:"s-form-label"},this.receiverMobileFieldLabel),t("salla-tel-input",{class:"s-gifting-tel-input",phone:this.receiverMobile,countryCode:this.receiverCountryCode,onPhoneEntered:s=>this.handlePhoneInputChange(s)}),this.errors&&this.errors["receiver.mobile"]?t("span",{class:"s-gifting-error"},this.errors["receiver.mobile"]):""),this.isPhysical()&&t("div",{class:this.step2ItemClass(this.errors?.["receiver.country"]?"s-form-group s-form-has-error":"s-form-group")},t("label",{class:"s-form-label"},this.receiverCountryFieldLabel),t("select",{name:"country",class:"s-form-control",onChange:s=>this.handleCountryChange(s),required:!0},t("option",{value:""},this.selectCountry),this.gift?.countries?.map((s=>t("option",{value:s.id},s.name)))),this.errors&&this.errors["receiver.country"]?t("span",{class:"s-gifting-error"},this.errors["receiver.country"]):""),this.isPhysical()&&this.isKSA&&t("div",{class:this.step2ItemClass(this.errors?.["receiver.region"]?"s-form-group s-form-has-error":"s-form-group")},t("label",{class:"s-form-label"},this.receiverRegionFieldLabel),t("select",{name:"region",class:"s-form-control",onChange:s=>this.handleRegionChange(s),disabled:this.loadingRegions},t("option",{value:"",selected:!0},this.loadingRegions?salla.lang.get("common.elements.loading"):this.selectRegion),this.regions?.map((s=>t("option",{value:s.id},s.name)))),this.errors&&this.errors["receiver.region"]?t("span",{class:"s-gifting-error"},this.errors["receiver.region"]):""),this.isPhysical()&&t("div",{class:this.step2ItemClass(this.errors?.["receiver.city_id"]?"s-form-group s-form-has-error":"s-form-group")},t("label",{class:"s-form-label"},this.receiverCityFieldLabel),t("select",{name:"city","aria-label":salla.lang.get("blocks.buy_as_gift.select_city"),class:"s-form-control",onChange:s=>this.handleReceiverCity(s),disabled:this.loadingCities||this.isKSA&&!this.selectedRegionId},t("option",{value:"",selected:!0},this.loadingCities?salla.lang.get("common.elements.loading"):this.selectCity),this.gift?.cities?.map((s=>t("option",{value:s.id},s.name)))),this.errors&&this.errors["receiver.city_id"]?t("span",{class:"s-gifting-error"},this.errors["receiver.city_id"]):""),this.isPhysical()&&t("div",{class:this.step2ItemClass("s-gifting-info")},t("span",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>alert</title>\n<path d="M16 13.333c-0.736 0-1.333 0.597-1.333 1.333v8c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-8c0-0.736-0.597-1.333-1.333-1.333zM16 9.327c-0.736 0-1.333 0.604-1.333 1.34s0.597 1.333 1.333 1.333 1.333-0.597 1.333-1.333v-0.013c0-0.736-0.597-1.327-1.333-1.327zM27.313 4.687c-6.237-6.237-16.389-6.239-22.628 0-6.237 6.239-6.237 16.389 0 22.628 3.119 3.119 7.216 4.679 11.313 4.679s8.195-1.559 11.313-4.679c6.24-6.239 6.24-16.391 0.001-22.628zM25.428 25.428c-5.199 5.197-13.657 5.197-18.857 0-5.197-5.199-5.197-13.659 0-18.857 5.199-5.197 13.659-5.197 18.857 0 5.199 5.2 5.199 13.659 0 18.857z"></path>\n</svg>\n'}),t("span",null,this.selectCityInfo)),!this.isPhysical()&&t("div",{class:this.step2ItemClass()},t("label",{class:"s-gifting-schedule s-gifting-clickable",htmlFor:`schedule-${this.hostId}`},t("input",{type:"checkbox",name:"schedule",id:`schedule-${this.hostId}`,onChange:()=>this.toggleCalendar(),class:"s-checkbox"}),t("span",{class:"s-form-label"}," ",this.sendLater," "))),t("div",{class:this.getCalendarClasses(),ref:s=>this.calendarFormGroup=s},t("label",{class:"s-form-label"},this.selectSendDateAndTime),t("salla-datetime-picker",{value:this.deliveryDate,placeholder:this.selectSendDateAndTime,"enable-time":!0,"date-format":"Y-m-d h:i K",onPicked:s=>this.handleDateTimePicker(s)}),t("span",{class:"s-gifting-calendar-hint"},this.canNotEditOrderAfterSelectDate)),t("div",{class:this.step2ItemClass("s-gifting-step-two-footer")},t("a",{href:"#!",innerHTML:e,onClick:s=>this.goToStep1(s)}),t("salla-button",{onClick:()=>this.submitForm(),color:"primary",width:"wide"},t("span",null,this.sendGift)))))],t("slot",{key:"4cad8b174ab427e6f75b77357efc20e54d791ba4",name:"footer"})))]}};o.style=".s-gifting-steps-wrapper{transition:0.2s cubic-bezier(0.55, 0, 0.1, 1) 0s}.s-gifting-select{background-image:url(\"data:image/svg+xml;utf8,<svg version='1.1' fill='gray' xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'><title>keyboard_arrow_down</title><path d='M9.875 11.104l6.125 6.125 6.125-6.125 1.875 1.875-8 8-8-8z'></path></svg>\");background-size:24px;background-repeat:no-repeat;background-position:99%;appearance:none}[dir=rtl] .s-gifting-select{background-position:5px}.s-gifting-widget-vertical .s-list-tile-item [slot=title]{display:flex;align-items:center;gap:1.5rem}.s-gifting-widget-vertical .s-list-tile-item-content{width:100%}";export{o as salla_gifting}
4
+ import{r as s,h as t}from"./p-6ZT_-rrT.js";import{a as i}from"./p-CgtvEd63.js";import{a as e}from"./p-BedNk7k1.js";import{S as a}from"./p-8Tsmrwno.js";import{S as l}from"./p-0-eTJXSD.js";const o=class{constructor(t){s(this,t),this.defaultEvent="gifting:open",this.selectImageForYourGift=salla.lang.get("blocks.buy_as_gift.select_image_or_upload"),this.currentStep=1,this.showCalendar=!1,this.showGiftText=!1,this.currentLang="",this.parentClass="is-current-step-1",this.errors={},this.gift=void 0,this.selectedGiftTextOption=void 0,this.selectedCountryId=void 0,this.selectedCountryCode=void 0,this.loadingCities=!1,this.loadingRegions=!1,this.regions=[],this.selectedRegionId=void 0,this.isKSA=!1,this.step2Animated=!1,this.showTextArea=!1,this.selectedImage=void 0,this.uploadedImage=void 0,this.selectedText=void 0,this.hasError=!1,this.timeZone=null,this.receiverCountryCode=salla.config.get("store.scope.countries")?.[0]||salla.config.get("store.store_country")||"SA",this.hostId=`salla-gifting-${Math.random().toString(36).slice(2,10)}`,this.formSelector="form.product-form, form.form--product-options",salla.lang.onLoaded((()=>{this.selectImageOrUpload=salla.lang.get("blocks.buy_as_gift.select_image_or_upload"),this.selectImageForYourGift=salla.lang.get("blocks.buy_as_gift.select_image_for_your_gift"),this.sectionTitle=salla.lang.get("blocks.buy_as_gift.gift_the_one_you_love"),this.sectionSubtitle=salla.lang.get("blocks.buy_as_gift.gift_the_one_you_love_message"),this.sectionBtnText=salla.lang.get("blocks.buy_as_gift.send_as_a_gift"),this.giftDetails=salla.lang.get("blocks.buy_as_gift.gift_details"),this.selectGiftMessage=salla.lang.get("blocks.buy_as_gift.select_gift_message"),this.giftCustomText=salla.lang.get("blocks.buy_as_gift.gift_custom_text"),this.textId=salla.lang.get("blocks.buy_as_gift.text_id"),this.incorrectGiftText=salla.lang.get("blocks.buy_as_gift.incorrect_gift_text"),this.nextStep=salla.lang.get("blocks.buy_as_gift.next_step"),this.senderNameLabel=salla.lang.get("blocks.buy_as_gift.sender_name"),this.receiverNameFieldLabel=salla.lang.get("blocks.buy_as_gift.receiver_name"),this.receiverMobileFieldLabel=salla.lang.get("blocks.buy_as_gift.receiver_mobile"),this.receiverCountryFieldLabel=salla.lang.get("blocks.buy_as_gift.receiver_country"),this.ksa=salla.lang.get("pages.checkout.ksa"),this.selectCity=salla.lang.get("pages.checkout.select_city"),this.selectCountry=salla.lang.get("pages.checkout.select_country"),this.selectCityInfo=salla.lang.get("blocks.buy_as_gift.city_info"),this.receiverCityFieldLabel=salla.lang.get("blocks.buy_as_gift.receiver_city"),this.receiverRegionFieldLabel=salla.lang.get("blocks.buy_as_gift.receiver_region")||salla.lang.get("pages.checkout.region"),this.selectRegion=salla.lang.get("pages.checkout.select_region"),this.receiverEmailFieldLabel=salla.lang.get("blocks.buy_as_gift.receiver_email"),this.emailPlaceholder=salla.lang.get("common.elements.email_placeholder"),this.sendLater=salla.lang.get("blocks.buy_as_gift.send_later"),this.selectSendDateAndTime=salla.lang.get("blocks.buy_as_gift.select_send_date_and_time"),this.canNotEditOrderAfterSelectDate=salla.lang.get("blocks.buy_as_gift.can_not_edit_order_after_select_date"),this.sendGift=salla.lang.get("blocks.buy_as_gift.send_gift"),this.donationRequired=salla.lang.get("pages.products.donation_amount_required"),this.currentLang=salla.lang.locale})),salla.event.on(this.defaultEvent,(()=>{this.open()}))}isPhysical(){return this.physicalProducts||this.physical}componentDidLoad(){salla.event.product.onPriceUpdated((()=>{const s=document.querySelector(".s-quantity-input-input");this.quantity=s?.value}))}getFormDataFromForm(){if(!this.formSelector)return null;const s=document.querySelector(this.formSelector);return s?new FormData(s):null}mergeObjectToFormData(s,t,i){for(let e in s){if(!s.hasOwnProperty(e)||null==s[e])continue;const a=i?`${i}[${e}]`:e;"object"!=typeof s[e]||null===s[e]||s[e]instanceof File?t.set(a,s[e]):this.mergeObjectToFormData(s[e],t,a)}return t}async open(){if(salla.config.isGuest())return salla.api.auth.setAfterLoginEvent(this.defaultEvent),void salla.event.dispatch("login::open",{withoutReload:!0});await this.modal.open();const s=this.productId?()=>salla.product.getGiftProductDetails(this.productId):()=>salla.cart.getGiftCartDetails();return await salla.api.withoutNotifier(s).then((s=>{this.gift=s.data,this.senderName=this.gift.sender_name})).catch((s=>{this.hasError=!0,this.errorMessage=s.response?.data?.error?.message||s.response?.data})).finally((()=>this.modal.stopLoading()))}async close(){return this.modal.close()}async setWrapperHeight(s=1,t=250,i=0,e=0){let a=document.querySelector(`#${this.hostId} .gift-step-${s}`);const l=()=>{this.stepsWrapper.style.height=e?`${e}px`:a.offsetHeight+i+"px"};this.step2Animated&&2===s?requestAnimationFrame(l):setTimeout(l,t)}toggleCalendar(){this.showCalendar=!this.showCalendar,this.setWrapperHeight(2,150,0)}toggleGiftText(s){this.textSelect?.classList.remove("s-form-has-error");let t=s.target.children[s.target.selectedIndex].getAttribute("data-id"),i="custom"==t;this.showGiftText=i,t?(this.selectedGiftTextOption=t,this.selectedText=i?void 0:s.target.value,this.setWrapperHeight(1,150,5)):(this.textArea.value="",this.selectedText=void 0,this.selectedGiftTextOption=void 0,this.setWrapperHeight(1,150,-15))}async goToStep2(){return this.selectedGiftTextOption?"custom"!=this.selectedGiftTextOption||this.selectedText?(this.textSelect.classList.remove("s-form-has-error"),this.customTextArea.classList.remove("s-form-has-error"),this.setWrapperHeight(2,600,0),(new i.timeline).add({targets:this.step1Elems.querySelectorAll(`#${this.hostId} .anime-item`),opacity:[1,0],translateX:[0,50],delay:i.stagger(70),duration:1200}).add({targets:".gift-step-2",translateX:["-110%",0],opacity:[0,1]},"-=1800").add({targets:this.step2Elems.querySelectorAll(`#${this.hostId} .anime-item`),opacity:[0,1],translateX:[-50,0],delay:i.stagger(70),duration:1200,complete:()=>{this.step2Elems.querySelectorAll(`#${this.hostId} .anime-item`).forEach((s=>{s.classList.remove("opacity-0"),s.removeAttribute("style")})),this.step2Animated=!0}},"-=1200"),this.currentStep=2,void(this.parentClass=`is-current-step-${this.currentStep}`)):(this.textSelect.classList.remove("s-form-has-error"),void this.customTextArea.classList.add("s-form-has-error")):(this.textSelect.classList.add("s-form-has-error"),void this.customTextArea.classList.remove("s-form-has-error"))}goToStep1(s){s.preventDefault();let t=new i.timeline({autoplay:!1});t.add({targets:this.step2Elems.querySelectorAll(`#${this.hostId} .anime-item`),opacity:[1,0],translateX:[0,-50],delay:i.stagger(70),duration:1200}).add({targets:".gift-step-1",translateX:["110%",0],opacity:[0,1]},"-=1800").add({targets:this.step1Elems.querySelectorAll(`#${this.hostId} .anime-item`),opacity:[0,1],translateX:[50,0],delay:i.stagger(70),duration:1200,complete:()=>{this.step1Elems.querySelectorAll(`#${this.hostId} .anime-item`).forEach((s=>{s.classList.remove("opacity-0"),s.removeAttribute("style")}))}},"-=1200"),t.play(),this.step2Animated=!1,this.setWrapperHeight(1,600,0),this.currentStep=1,this.parentClass=`is-current-step-${this.currentStep}`}getFilepondPlaceholder(){return`<div class="s-gifting-filepond-placeholder"><span class="s-gifting-filepond-placeholder-icon"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>images</title>\n<path d="M22.667 29.333h-13.333c-3.676 0-6.667-2.991-6.667-6.667v-13.333c0-0.737-0.597-1.333-1.333-1.333s-1.333 0.596-1.333 1.333v13.333c0 5.145 4.187 9.333 9.333 9.333h13.333c0.736 0 1.333-0.596 1.333-1.333s-0.597-1.333-1.333-1.333zM22.667 5.333c-2.205 0-4 1.795-4 4s1.795 4 4 4 4-1.795 4-4-1.795-4-4-4zM22.667 10.667c-0.735 0-1.333-0.597-1.333-1.333s0.599-1.333 1.333-1.333 1.333 0.597 1.333 1.333-0.599 1.333-1.333 1.333zM25.333 0h-13.333c-3.676 0-6.667 2.991-6.667 6.667v13.333c0 1.055 0.268 2.040 0.707 2.927 0.039 0.099 0.088 0.188 0.151 0.277 1.137 2.053 3.301 3.463 5.809 3.463h13.333c3.676 0 6.667-2.991 6.667-6.667v-13.333c0-3.676-2.991-6.667-6.667-6.667zM12 24c-1.244 0-2.344-0.583-3.077-1.476l5.721-7.047 6.629 8.523zM29.333 20c0 2.205-1.795 4-4 4h-0.68l-8.933-11.485c-0.251-0.32-0.633-0.511-1.039-0.515h-0.015c-0.401 0-0.781 0.181-1.035 0.492l-5.632 6.935v-12.76c0-2.205 1.795-4 4-4h13.333c2.205 0 4 1.795 4 4z"></path>\n</svg>\n</span><p class="s-gifting-filepond-placeholder-text">${this.selectImageOrUpload?this.selectImageOrUpload:""}</p></div>`}setPreview(s){this.uploader?.classList.add("has-bg");var t=document.querySelector(`#${this.hostId}.filepond-bg`)?document.querySelector(`#${this.hostId} .filepond-bg`):document.createElement("div");t.classList.add("filepond-bg"),t.classList.remove("s-hidden"),t.style.backgroundImage="url('"+s.url+"')",this.uploader?.querySelector(".filepond--root")?.appendChild(t),this.uploadedImage=s.url,this.gift&&this.gift.gift_images.length&&this.setWrapperHeight(1,150,0)}removePreview(){this.uploader.classList.remove("has-bg");let s=document.querySelector(`#${this.hostId} .filepond-bg`);s.removeAttribute("style"),s.classList.add("s-hidden"),this.handleRemoveImage()}handleTextAreaChange(s){this.selectedText=s.target.value,this.customTextArea.classList.remove("s-form-has-error")}clearError(s){if(this.errors?.[s]){const{[s]:t,...i}=this.errors;this.errors=i}}handleSenderName(s){this.senderName=s.target.value,this.clearError("sender_name")}handleReceiverName(s){this.receiverName=s.target.value,this.clearError("receiver.name")}handleReceiverCity(s){this.receiverCity=s.target.value,this.clearError("receiver.city_id")}async handleCountryChange(s){const t=Number(s.target.value);this.selectedCountryId=t,this.clearError("receiver.country");const i=this.gift?.countries?.find((s=>s.id==t));if(this.selectedCountryCode=i?.country_code,this.isKSA="SA"===i?.country_code,this.regions=[],this.selectedRegionId=void 0,this.gift={...this.gift,cities:[]},this.receiverCity=void 0,!t||0===this.gift?.countries?.length)return this.selectedCountryCode=void 0,this.isKSA=!1,void this.setWrapperHeight(2,0,0);if(this.isKSA){this.loadingRegions=!0,this.setWrapperHeight(2,0,0);try{const s=await salla.api.request(`shipping/countries/${t}/regions`);s&&s.data&&(this.regions=s.data)}catch(s){console.error("Error fetching regions:",s)}finally{this.loadingRegions=!1,this.setWrapperHeight(2,0,0)}}else{this.loadingCities=!0,this.setWrapperHeight(2,0,0);try{const s=await salla.api.request(`shipping/cities?for_branch=0&country_id=${t}`);s&&s.data&&(this.gift={...this.gift,cities:s.data})}catch(s){console.error("Error fetching cities:",s)}finally{this.loadingCities=!1}}}async handleRegionChange(s){const t=Number(s.target.value);if(this.selectedRegionId=t,this.clearError("receiver.region"),this.gift={...this.gift,cities:[]},this.receiverCity=void 0,t){this.loadingCities=!0;try{const s=await salla.api.request(`shipping/cities?for_branch=0&country_id=${this.selectedCountryId}&region_id=${t}`);s&&s.data&&(this.gift={...this.gift,cities:s.data})}catch(s){console.error("Error fetching cities:",s)}finally{this.loadingCities=!1,this.setWrapperHeight(2,0,0)}}}handleUploadImage(s){this.uploadedImage=s,this.gift&&this.gift.gift_images.length&&this.setWrapperHeight(1,150,0)}handleRemoveImage(){this.uploadedImage="",this.gift&&this.gift.gift_images.length&&this.setWrapperHeight(1,150,0)}handlePhoneInputChange(s){let t=s.detail;this.receiverMobile=t.number,this.receiverCountryCode=t.country_code,this.clearError("receiver.mobile")}handleDateTimePicker(s){this.deliveryDate=s.detail}getCalendarClasses(){return{"s-form-group":!0,"anime-item":!0,"s-gifting-calendar":!0,shown:this.showCalendar,hide:!this.showCalendar,"s-form-has-error":!!this.errors&&this.errors.deliver_at}}async submitForm(){const s=document.querySelector("#donating-amount")?.value;if(this.calendarFormGroup.classList.remove("s-form-has-error"),this.errors&&(this.errors={},this.setWrapperHeight(2,150,0)),this.showCalendar&&!this.deliveryDate)return void this.calendarFormGroup.classList.add("s-form-has-error");const t=[{key:"sender_name",value:this.senderName,label:this.senderNameLabel},{key:"receiver.name",value:this.receiverName,label:this.receiverNameFieldLabel},{key:"receiver.mobile",value:this.receiverMobile,label:this.receiverMobileFieldLabel},...this.isPhysical()?[{key:"receiver.country",value:this.selectedCountryId,label:this.receiverCountryFieldLabel},...this.isKSA?[{key:"receiver.region",value:this.selectedRegionId,label:this.receiverRegionFieldLabel}]:[],{key:"receiver.city_id",value:this.receiverCity,label:this.receiverCityFieldLabel}]:[]],i={};if(t.forEach((({key:s,value:t,label:e})=>{t||(i[s]=salla.lang.get("common.errors.field_required",{attribute:e}))})),Object.keys(i).length)return this.errors=i,void this.setWrapperHeight(2,150,0);const e={text:this.selectedText,sender_name:this.senderName,quantity:this.quantity,deliver_at:this.showCalendar?this.deliveryDate:null,image_url:this.uploadedImage??this.selectedImage,donation_amount:s||null,receiver:{name:this.receiverName,mobile_country_code:this.receiverCountryCode,mobile:this.receiverMobile,...this.isPhysical()&&this.selectedCountryCode?{country_code:this.selectedCountryCode}:{},...this.isPhysical()&&this.selectedRegionId?{region_id:this.selectedRegionId}:{},...this.receiverCity&&this.isPhysical()?{city_id:this.receiverCity}:{}},has_apple_pay:salla.helpers.hasApplePay()};let a;this.productId&&this.formSelector&&(a=this.getFormDataFromForm()||new FormData,a=this.mergeObjectToFormData(e,a));const l=this.productId?()=>salla.product.addProductGiftToCart(this.productId,a,!0):()=>salla.cart.addCartGiftToCart(e,!0);return await l().then((()=>this.modal.close())).catch((s=>{s.response&&422==s.response.status?this.errors=s.response.data.error.fields:console.log(s),this.setWrapperHeight(2,150,0)}))}step2ItemClass(s=""){const t="anime-item"+(this.step2Animated?"":" opacity-0");return s?`${s} ${t}`:t}generateClass(){return{"s-gifting-widget":!0,"s-gifting-widget-vertical":!!this.vertical,"s-gifting-widget-horizontal":!this.vertical}}async handleGiftButtonClick(){if(this.productId&&this.formSelector){const s=document.querySelector(this.formSelector);if(!s)return void console.error("SallaGifting:: Form not found in the document!");if(!(s instanceof HTMLFormElement))return void console.error("SallaGifting:: The specified selector does not correspond to a form tag!");if(!s.reportValidity())return console.error("SallaGifting:: Form is not valid!"),void salla.error(salla.lang.get("common.messages.required_fields"))}const s=document.querySelector(`salla-product-options[product-id="${this.productId}"]`);!s||await s.reportValidity()?this.open():salla.error(salla.lang.get("common.messages.required_fields"))}render(){return[t("div",{key:"f20cc2c84e987b34bb862f72a8f639894ed4150e"},t("salla-list-tile",{key:"c52aa5e975f9ed1707c3175fa66109f447749ee7",class:this.generateClass()},t("div",{key:"2bf7065f32132dde95dacfdea44e34c08cc4e61c",slot:"title"},this.vertical?t("span",{innerHTML:l}):"",t("h3",{key:"7a9a70b6841a708c322f5bb729e940e4da823261"},this.widgetTitle?this.widgetTitle:this.sectionTitle)),t("div",{key:"c346f2baa8e6a1adf9b0f89e9b50d236e65116cb",slot:"subtitle"},t("div",{key:"26c908af9687b0c77554054212f5c8251dc45bf3"},this.widgetSubtitle?this.widgetSubtitle:this.sectionSubtitle)),t("div",{key:"f91bf3811c383773425af74941a2067e2f62dbb7",slot:"action"},t("salla-button",{key:"0639c4b9cc4d81f300f6b087e1c10815b1610c75",color:"primary",fill:"outline",width:"wide",class:"s-gifting-widget-action",onClick:()=>this.handleGiftButtonClick()},t("slot",{key:"06567fa7406ae6502e8f3211ecab6161c4a7e397",name:"widget-btn-content"},t("div",{key:"f895900d17947b006f6aef4695b855eba4737ed2",class:"s-gifting-widget-action-content"},t("span",{key:"bd3170b8efa2a0c95f61718afd69e5473adae20a",innerHTML:l}),"  ",t("span",{key:"cdc3d1df35ad0e7334bc289f9fff2d312d709724"},this.sectionBtnText)))))),t("salla-modal",{key:"a98b913100edfa92156baeee766f6141818ebd8b",id:this.hostId,isLoading:!0,class:"s-gifting-modal",width:"sm",ref:s=>this.modal=s},t("div",{key:"6b438c581e600cbcfeb5260bae8371a1fbefa29c",slot:"loading"},t("div",{key:"ada9e9bb0355755eade9ff7846334cb5ae093e6f",class:"s-gifting-skeleton"},t("div",{key:"11d2e41b6acb933f5b006cc9f0b0b46470892c6a",class:"s-gifting-modal-header"},t("salla-skeleton",{key:"141be7d6aa83fed682f8ab6a3708597dbb4dba11",type:"circle",height:"5rem",width:"5rem"}),t("h2",{key:"65eba6244b5507397c8e50ef40f695e7eebe0b96",class:"s-gifting-modal-title"},t("div",{key:"0f2488d19d2de0a728377b9f475b70073f6f196a",class:"s-gifting-modal-badge-wrapper"},t("salla-skeleton",{key:"b648340418099246c8b83b308f116412fdb6cbc9",height:"15px",width:"150px"})))),t("div",{key:"8255e53b49f572ef3c4485cf7e84540dac019f89",class:"s-gifting-skeleton-content"},t("salla-skeleton",{key:"0b05db8e76a9a53032b1643d8c4e223b8b641e30",height:"10px",width:"150px"}),t("salla-skeleton",{key:"c585bf04433e46ce8e89d9bfc3402faf4cfbb21a",height:"230px"}),t("salla-skeleton",{key:"0c09063b73e3aecb6a1879cdc93b60a6bcb9b2cc",height:"10px",width:"150px"}),t("salla-skeleton",{key:"88f55e5ffded2f784002b44e49f3ab2d22a7c067",height:"30px"}),t("salla-skeleton",{key:"6e1edd3b031f051ec24149ec690d2e4f04f9c557",height:"40px"})))),t("slot",{key:"bff6a067b10a31c39f22e18c6bdf5a60f56ef116",name:"header"}),this.hasError?t("salla-placeholder",{alignment:"center"},t("span",{slot:"title"},this.errorMessage||salla.lang.get("common.errors.empty_results")),t("span",{slot:"description"}," ")):[t("div",{class:"s-gifting-modal-header"},t("span",{class:"s-gifting-modal-icon"},t("span",{innerHTML:l})),t("h2",{class:"s-gifting-modal-title"},t("div",{class:"s-gifting-modal-badge-wrapper"},t("div",{class:"s-gifting-modal-badge"},t("span",null,t("span",null,this.currentStep),"/2")),t("span",null,this.giftDetails)))),t("div",{class:"s-gifting-steps-wrapper "+this.parentClass,ref:s=>this.stepsWrapper=s},t("div",{class:"s-gifting-step-one gift-step-1",ref:s=>this.step1Elems=s},t("div",{class:"s-gifting-modal-uploader-title anime-item"},this.selectImageForYourGift),t("div",{class:"s-gifting-modal-uploader anime-item",ref:s=>this.uploader=s},t("span",{class:"s-gifting-remove-preview",onClick:()=>this.removePreview(),innerHTML:a}),this.selectImageOrUpload&&t("salla-file-upload",{"instant-upload":!0,name:"image_url",url:salla.url.api(salla.product.api.getUrl("giftImage")),onUploaded:s=>this.handleUploadImage(s.detail),labelIdle:this.getFilepondPlaceholder(),onRemoved:()=>this.handleRemoveImage()})),t("div",{class:"anime-item"},!this.uploadedImage&&this.gift&&this.gift.gift_images&&this.gift.gift_images.length>0?t("salla-slider",{id:"gifting-slider",loop:!1,"controls-outer":!0,class:"s-gifting-slider",type:"carousel"},t("div",{slot:"items"},this.gift&&this.gift.gift_images?this.gift?.gift_images.map((s=>t("a",{class:"s-gifting-clickable s-gifting-image",onClick:()=>this.setPreview(s)},t("img",{style:{width:"120px"},src:s.url,alt:`${s.id}`})))):"")):""),t("div",{class:"anime-item"},t("div",{class:"s-form-group s-gifting-selectText",ref:s=>this.textSelect=s},t("select",{id:"gift-text-selection",name:"gift-text-selection",class:"s-form-control s-gifting-select",onChange:s=>this.toggleGiftText(s)},t("option",{"data-id":null,selected:!0},this.selectGiftMessage),this.gift&&this.gift.gift_texts?this.gift?.gift_texts.map((s=>t("option",{"data-id":s.id,value:s.text,key:s.id},s.text))):"",t("option",{"data-id":"custom"},this.giftCustomText))),t("div",{class:this.showGiftText?"s-form-group s-gifting-textarea shown":"s-form-group s-gifting-textarea hide",ref:s=>this.customTextArea=s},t("label",{htmlFor:"gift-custom-text",class:"s-form-label"},this.giftCustomText),t("div",{class:"mt-1"},t("textarea",{onInput:s=>this.handleTextAreaChange(s),rows:4,ref:s=>this.textArea=s,name:"gift-custom-text",id:"gift-custom-text",class:"s-form-control"})))),t("div",{class:"anime-item"},t("salla-button",{color:"primary",width:"wide",onClick:()=>this.goToStep2()},t("span",null,this.nextStep)))),t("div",{class:"s-gifting-step-two gift-step-2",ref:s=>this.step2Elems=s},t("div",{class:this.step2ItemClass(this.errors?.sender_name?"s-form-group s-form-has-error":"s-form-group")},t("label",{htmlFor:"sender_name",class:"s-form-label"},this.senderNameLabel),t("input",{type:"text",class:"s-form-control",name:"sender_name",id:"sender_name",value:this.senderName,onInput:s=>this.handleSenderName(s),placeholder:""}),this.errors&&this.errors.sender_name?t("span",{class:"s-gifting-error"},this.errors.sender_name):""),t("div",{class:this.step2ItemClass(this.errors?.["receiver.name"]?"s-form-group s-form-has-error":"s-form-group")},t("label",{htmlFor:"receiver_name",class:"s-form-label"},this.receiverNameFieldLabel),t("input",{type:"text",class:"s-form-control",name:"receiver_name",id:"receiver_name",value:"",onInput:s=>this.handleReceiverName(s),placeholder:""}),this.errors&&this.errors["receiver.name"]?t("span",{class:"s-gifting-error"},this.errors["receiver.name"]):""),t("div",{class:this.step2ItemClass(this.errors?.["receiver.mobile"]?"s-form-group s-form-has-error":"s-form-group")},t("label",{class:"s-form-label"},this.receiverMobileFieldLabel),t("salla-tel-input",{class:"s-gifting-tel-input",phone:this.receiverMobile,countryCode:this.receiverCountryCode,onPhoneEntered:s=>this.handlePhoneInputChange(s)}),this.errors&&this.errors["receiver.mobile"]?t("span",{class:"s-gifting-error"},this.errors["receiver.mobile"]):""),this.isPhysical()&&t("div",{class:this.step2ItemClass(this.errors?.["receiver.country"]?"s-form-group s-form-has-error":"s-form-group")},t("label",{class:"s-form-label"},this.receiverCountryFieldLabel),t("select",{name:"country",class:"s-form-control",onChange:s=>this.handleCountryChange(s),required:!0},t("option",{value:""},this.selectCountry),this.gift?.countries?.map((s=>t("option",{value:s.id},s.name)))),this.errors&&this.errors["receiver.country"]?t("span",{class:"s-gifting-error"},this.errors["receiver.country"]):""),this.isPhysical()&&this.isKSA&&t("div",{class:this.step2ItemClass(this.errors?.["receiver.region"]?"s-form-group s-form-has-error":"s-form-group")},t("label",{class:"s-form-label"},this.receiverRegionFieldLabel),t("select",{name:"region",class:"s-form-control",onChange:s=>this.handleRegionChange(s),disabled:this.loadingRegions},t("option",{value:"",selected:!0},this.loadingRegions?salla.lang.get("common.elements.loading"):this.selectRegion),this.regions?.map((s=>t("option",{value:s.id},s.name)))),this.errors&&this.errors["receiver.region"]?t("span",{class:"s-gifting-error"},this.errors["receiver.region"]):""),this.isPhysical()&&t("div",{class:this.step2ItemClass(this.errors?.["receiver.city_id"]?"s-form-group s-form-has-error":"s-form-group")},t("label",{class:"s-form-label"},this.receiverCityFieldLabel),t("select",{name:"city","aria-label":salla.lang.get("blocks.buy_as_gift.select_city"),class:"s-form-control",onChange:s=>this.handleReceiverCity(s),disabled:this.loadingCities||this.isKSA&&!this.selectedRegionId},t("option",{value:"",selected:!0},this.loadingCities?salla.lang.get("common.elements.loading"):this.selectCity),this.gift?.cities?.map((s=>t("option",{value:s.id},s.name)))),this.errors&&this.errors["receiver.city_id"]?t("span",{class:"s-gifting-error"},this.errors["receiver.city_id"]):""),this.isPhysical()&&t("div",{class:this.step2ItemClass("s-gifting-info")},t("span",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>alert</title>\n<path d="M16 13.333c-0.736 0-1.333 0.597-1.333 1.333v8c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-8c0-0.736-0.597-1.333-1.333-1.333zM16 9.327c-0.736 0-1.333 0.604-1.333 1.34s0.597 1.333 1.333 1.333 1.333-0.597 1.333-1.333v-0.013c0-0.736-0.597-1.327-1.333-1.327zM27.313 4.687c-6.237-6.237-16.389-6.239-22.628 0-6.237 6.239-6.237 16.389 0 22.628 3.119 3.119 7.216 4.679 11.313 4.679s8.195-1.559 11.313-4.679c6.24-6.239 6.24-16.391 0.001-22.628zM25.428 25.428c-5.199 5.197-13.657 5.197-18.857 0-5.197-5.199-5.197-13.659 0-18.857 5.199-5.197 13.659-5.197 18.857 0 5.199 5.2 5.199 13.659 0 18.857z"></path>\n</svg>\n'}),t("span",null,this.selectCityInfo)),!this.isPhysical()&&t("div",{class:this.step2ItemClass()},t("label",{class:"s-gifting-schedule s-gifting-clickable",htmlFor:`schedule-${this.hostId}`},t("input",{type:"checkbox",name:"schedule",id:`schedule-${this.hostId}`,onChange:()=>this.toggleCalendar(),class:"s-checkbox"}),t("span",{class:"s-form-label"}," ",this.sendLater," "))),t("div",{class:this.getCalendarClasses(),ref:s=>this.calendarFormGroup=s},t("label",{class:"s-form-label"},this.selectSendDateAndTime),t("salla-datetime-picker",{value:this.deliveryDate,placeholder:this.selectSendDateAndTime,"enable-time":!0,"date-format":"Y-m-d h:i K",onPicked:s=>this.handleDateTimePicker(s)}),t("span",{class:"s-gifting-calendar-hint"},this.canNotEditOrderAfterSelectDate)),t("div",{class:this.step2ItemClass("s-gifting-step-two-footer")},t("a",{href:"#!",innerHTML:e,onClick:s=>this.goToStep1(s)}),t("salla-button",{onClick:()=>this.submitForm(),color:"primary",width:"wide"},t("span",null,this.sendGift)))))],t("slot",{key:"4cad8b174ab427e6f75b77357efc20e54d791ba4",name:"footer"})))]}};o.style=".s-gifting-steps-wrapper{transition:0.2s cubic-bezier(0.55, 0, 0.1, 1) 0s}.s-gifting-select{background-image:url(\"data:image/svg+xml;utf8,<svg version='1.1' fill='gray' xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'><title>keyboard_arrow_down</title><path d='M9.875 11.104l6.125 6.125 6.125-6.125 1.875 1.875-8 8-8-8z'></path></svg>\");background-size:24px;background-repeat:no-repeat;background-position:99%;appearance:none}[dir=rtl] .s-gifting-select{background-position:5px}.s-gifting-widget-vertical .s-list-tile-item [slot=title]{display:flex;align-items:center;gap:1.5rem}.s-gifting-widget-vertical .s-list-tile-item-content{width:100%}";export{o as salla_gifting}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,h as s,H as e}from"./p-eYsXdqjv.js";const r=class{constructor(s){t(this,s),this.parsedSections=[]}parseProducts(t){let s=[];if("string"==typeof t)try{const e=JSON.parse(t);s=this.extractSections(e)}catch(e){console.error("Invalid JSON passed to bundleSections prop:",t),s=[]}else t&&(s=this.extractSections(t));this.parsedSections=s}extractSections(t){return t.bundle&&t.bundle.sections&&Array.isArray(t.bundle.sections)?t.bundle.sections:Array.isArray(t)?t:t.sections&&Array.isArray(t.sections)?t.sections:(console.warn("No valid sections found in data:",t),[])}isCartPage(){return salla.url.is_page("cart")}renderCartPage(){return s("salla-multiple-bundle-product-cart",{sections:this.parsedSections})}renderDetailsPage(){return s("salla-multiple-bundle-product-details",{sections:this.parsedSections})}componentWillLoad(){this.parseProducts(this.bundleSections)}render(){return s(e,{key:"0c083bcf6f932c3db65e7c9c1871843594bc8604",class:"s-multiple-bundle-product-wrapper"},this.isCartPage()?this.renderCartPage():this.renderDetailsPage())}static get watchers(){return{bundleSections:["parseProducts"]}}};r.style=":host{display:block}";export{r as salla_multiple_bundle_product}
4
+ import{r as t,h as s,H as r}from"./p-6ZT_-rrT.js";const e=class{constructor(s){t(this,s),this.parsedSections=[]}parseProducts(t){let s=[];if("string"==typeof t)try{const r=JSON.parse(t);s=this.extractSections(r)}catch(r){console.error("Invalid JSON passed to bundleSections prop:",t),s=[]}else t&&(s=this.extractSections(t));this.parsedSections=s}extractSections(t){return t.bundle&&t.bundle.sections&&Array.isArray(t.bundle.sections)?t.bundle.sections:Array.isArray(t)?t:t.sections&&Array.isArray(t.sections)?t.sections:(console.warn("No valid sections found in data:",t),[])}isCartPage(){return salla.url.is_page("cart")}renderCartPage(){return s("salla-multiple-bundle-product-cart",{sections:this.parsedSections})}renderDetailsPage(){return s("salla-multiple-bundle-product-details",{sections:this.parsedSections})}componentWillLoad(){this.parseProducts(this.bundleSections)}render(){return s(r,{key:"0c083bcf6f932c3db65e7c9c1871843594bc8604",class:"s-multiple-bundle-product-wrapper"},this.isCartPage()?this.renderCartPage():this.renderDetailsPage())}static get watchers(){return{bundleSections:["parseProducts"]}}};e.style=":host{display:block}";export{e as salla_multiple_bundle_product}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,c as t,h as i,H as e,a as r}from"./p-eYsXdqjv.js";import{S as a}from"./p-CciN5Q_x.js";import{S as l}from"./p-DLNIOD9t.js";import{S as h}from"./p-8Tsmrwno.js";const o=class{constructor(i){s(this,i),this.quickOrderSubmited=t(this,"quickOrderSubmited"),this.quickOrderTitle="ليش تنتظر؟",this.subTitle="احصل على المنتج مباشرة الآن",this.payButtonTitle="اطلب المنتج",this.confirmPayButtonTitle="اشتر الآن",this.agreementText=salla.lang.get("pages.checkout.show_full_agreement"),this.isEmailRequired=!1,this.quickOrderStyle="default",this.isAvailable=!1,this.oneClick=!1,this.expanded=!1,this.isTermsRequired=!1,this.countryCode=salla.config.get("user.country_code","SA")||"SA",this.submitSucess=!1,this.placeHolderEmail=salla.lang.get("common.elements.email"),this.emailOptional=salla.lang.get("common.elements.optional"),this.agreementShowText=salla.lang.get("pages.checkout.show_full_agreement"),this.agreementModalHead=salla.lang.get("pages.checkout.full_agreement"),this.userNameLabel=salla.lang.get("pages.products.your_name"),this.termsChecked=!1,salla.onReady((()=>{this.productId=this.productId||salla.config.get("page.id")})),salla.lang.onLoaded((()=>{this.placeHolderEmail=salla.lang.get("common.elements.email"),this.emailOptional=salla.lang.get("common.elements.optional"),this.agreementShowText=salla.lang.get("pages.checkout.show_full_agreement"),this.agreementModalHead=salla.lang.get("pages.checkout.full_agreement"),this.userNameLabel=salla.lang.get("pages.products.your_name")}))}getBtnColor(){return"default"===this.quickOrderStyle?"light":"primary"}getErrorMessage(s,t){return"terms"==t?salla.lang.get("pages.checkout.check_agreement"):salla.lang.get(`common.errors.${s}`,{attribute:"name"==t?this.userNameLabel:this.placeHolderEmail})}handleInvalidInput(s){let t,i=s.target,e=i.validity;e.valueMissing?(t=this.getErrorMessage("field_required",i.name),console.log(this.getErrorMessage("field_required",i.name))):e.typeMismatch&&(t=this.getErrorMessage("invalid_value",i.name)),i.setCustomValidity(t)}async setWrapperHeight(){let s=this.host.querySelector(".s-quick-order-expandable");setTimeout((()=>{s.style.maxHeight=s.style.maxHeight||this.oneClick?null:s.scrollHeight+"px"}),50)}getDarkOrLight(){return"default"===this.quickOrderStyle&&salla.config.get("theme.color.is_dark")?"dark":"light"}getStyleColor(){return{gray:"#f3f3f3",white:"#ffffff",default:salla.config.get("theme.color.primary")}[this.quickOrderStyle]||"#f3f3f3"}async submit(s,t=!1){return s.preventDefault(),t&&!this.oneClick?(this.expanded=!this.expanded,void this.setWrapperHeight()):this.submitBtn.load().then((()=>this.getPayload())).then((s=>salla.api.cart.createQuickOrder(s))).then((()=>{setTimeout((()=>{this.submitBtn.stop(),this.submitSucess=!0,this.quickOrderSubmited.emit()}),200)})).catch((s=>s&&(console.error(s),this.submitBtn.stop())))}async getPayload(){return this.oneClick?{product_ids:[this.productId],agreement:!0}:{product_ids:[this.productId],email:this.emailInput?.value,phone:Number((await(this.phoneInput?.getValues()))?.phone),country_code:(await(this.phoneInput?.getValues()))?.countryCode||this.countryCode,name:this.nameInput?.value,agreement:this.termsChecked}}formatAgreementText(s,t=150){return s?s.length<=t?s:(new DOMParser).parseFromString(s,"text/html").documentElement.innerText.substring(0,t)+"...":""}loadQuickOrderSettings(){let s=salla.config.get("store.settings.quick_order");return s?(this.user=salla.config.get("user")||salla.storage.get("user")||{},this.countryCode=this.user?.country_code||this.countryCode,this.isEmailRequired=!this.user?.email&&this.isEmailRequired,this.oneClick=this.user?.email,this.initComponentData(s),Promise.resolve()):Promise.resolve()}initComponentData(s){this.quickOrderTitle=s.title,this.subTitle=s.sub_title,this.payButtonTitle=s.order_now_button,this.isEmailRequired=s.is_email_required,this.isTermsRequired=s.show_agreement,this.agreementText=s.agreement,this.confirmPayButtonTitle=s.confirm_button,this.thanksMessage=s.thanks_message,this.quickOrderStyle=s.style,this.isAvailable=!0,this.oneClick=this.oneClick&&!this.isTermsRequired}componentWillLoad(){return new Promise((s=>salla.onReady((()=>this.loadQuickOrderSettings().then(s)))))}render(){if(this.isAvailable)return this.submitSucess?i(e,{class:"s-quick-order"},i("div",{class:"s-quick-order-confirm",style:{backgroundColor:salla.config.get("theme.color.primary")+"10",borderColor:salla.config.get("theme.color.primary")+"10",color:salla.config.get("theme.color.primary")}},i("i",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>party-horn</title>\n<path fill="currentColor" d="M5.333 4.013c0.736 0 1.333-0.596 1.333-1.333v-0.013c0-0.737-0.597-1.327-1.333-1.327s-1.333 0.603-1.333 1.34 0.597 1.333 1.333 1.333zM11.333 10c0.341 0 0.683-0.131 0.943-0.391 1.541-1.54 2.391-3.589 2.391-5.771v-2.505c0-0.737-0.597-1.333-1.333-1.333s-1.333 0.596-1.333 1.333v2.505c0 1.468-0.572 2.848-1.609 3.885-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.601 0.391 0.943 0.391zM18.667 9.993c0.319 0 0.639-0.115 0.895-0.345 0.383-0.347 0.684-0.325 1.497-0.22 0.923 0.124 2.319 0.307 3.636-0.887 1.293-1.172 1.303-2.54 1.308-3.539 0.005-0.887 0.043-1.228 0.432-1.581 0.361-0.327 0.621-0.335 1.493-0.216 0.923 0.12 2.317 0.307 3.635-0.884 0.545-0.495 0.587-1.337 0.093-1.883-0.493-0.547-1.336-0.589-1.884-0.093-0.361 0.325-0.621 0.333-1.493 0.216-0.921-0.119-2.317-0.305-3.635 0.884-1.293 1.173-1.303 2.541-1.308 3.54-0.005 0.885-0.043 1.227-0.432 1.58-0.383 0.348-0.683 0.327-1.497 0.22-0.924-0.124-2.32-0.305-3.636 0.887-0.545 0.495-0.587 1.339-0.092 1.884 0.264 0.291 0.625 0.437 0.988 0.437zM18.667 16.013c0.736 0 1.333-0.596 1.333-1.333v-0.013c0-0.737-0.597-1.327-1.333-1.327s-1.333 0.603-1.333 1.34 0.597 1.333 1.333 1.333zM30.667 17.333h-2.505c-2.179 0-4.228 0.849-5.771 2.391-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.603 0.391 0.944 0.391s0.683-0.131 0.943-0.391c1.023-1.023 2.439-1.609 3.884-1.609h2.505c0.736 0 1.333-0.596 1.333-1.333s-0.597-1.333-1.333-1.333zM30.667 10.66c-0.736 0-1.333 0.603-1.333 1.34s0.597 1.333 1.333 1.333 1.333-0.596 1.333-1.333v-0.013c0-0.736-0.597-1.327-1.333-1.327zM29.333 26.66c-0.736 0-1.333 0.603-1.333 1.34s0.597 1.333 1.333 1.333 1.333-0.596 1.333-1.333v-0.013c0-0.736-0.597-1.327-1.333-1.327zM7.456 11.057c-0.327-0.327-0.799-0.46-1.249-0.356-0.449 0.107-0.812 0.439-0.959 0.876l-5.036 15.113c-0.487 1.457-0.113 3.037 0.973 4.125 0.772 0.771 1.792 1.183 2.84 1.183 0.428 0 0.861-0.068 1.284-0.209l15.112-5.037c0.439-0.145 0.769-0.508 0.876-0.959 0.107-0.449-0.028-0.921-0.355-1.249zM4.467 29.259c-0.503 0.163-1.023 0.043-1.395-0.329-0.373-0.373-0.497-0.896-0.329-1.396l4.355-13.065 10.436 10.435z"></path>\n</svg>\n'}),i("span",null,this.thanksMessage))):i(e,{class:`s-quick-order s-quick-order-${this.getDarkOrLight()}`},i("div",{class:`s-quick-order-container s-quick-order-${this.quickOrderStyle}`,style:{backgroundColor:this.getStyleColor()}},i("div",{class:"s-quick-order-button-cont"},i("div",null,i("h3",null,this.quickOrderTitle),i("p",null,this.subTitle)),i("salla-button",{class:this.expanded?"s-quick-order-btn-close":"",onClick:s=>this.submit(s,!0),color:this.getBtnColor()},this.oneClick?this.confirmPayButtonTitle:this.expanded?i("i",{innerHTML:h}):this.confirmPayButtonTitle)),i("form",{onSubmit:s=>this.submit(s),class:"s-quick-order-expandable "+(this.expanded?"s-quick-order-shown":"")},Salla.config.isGuest()&&[i("div",{class:"s-form-group"},i("span",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>portrait</title>\n<path d="M24 1.333h-16c-3.676 0-6.667 2.991-6.667 6.667v16c0 3.028 2.041 5.561 4.811 6.371 0.004 0.001 0.008 0.003 0.012 0.004 0.591 0.172 1.2 0.292 1.844 0.292h16c0.644 0 1.253-0.12 1.843-0.292 0.004-0.001 0.008-0.003 0.012-0.004 2.771-0.809 4.812-3.343 4.812-6.371v-16c0-3.676-2.991-6.667-6.667-6.667zM8.012 28c0.121-1.915 3.363-4 7.988-4s7.868 2.085 7.988 4zM28 24c0 1.24-0.579 2.335-1.467 3.069-0.768-3.288-5.112-5.736-10.533-5.736s-9.765 2.448-10.533 5.736c-0.888-0.735-1.467-1.829-1.467-3.069v-16c0-2.205 1.795-4 4-4h16c2.205 0 4 1.795 4 4zM16 6.667c-3.308 0-6 2.692-6 6s2.692 6 6 6 6-2.692 6-6-2.692-6-6-6zM16 16c-1.839 0-3.333-1.495-3.333-3.333s1.495-3.333 3.333-3.333 3.333 1.495 3.333 3.333-1.495 3.333-3.333 3.333z"></path>\n</svg>\n'}),i("input",{type:"text",required:!0,class:"s-form-control s-quick-order-phone-field",name:"name",placeholder:this.userNameLabel,ref:s=>this.nameInput=s})),i("div",{class:"s-quick-order-flex-input"},i("div",{class:"s-form-group"},i("span",{innerHTML:a}),i("salla-tel-input",{ref:s=>this.phoneInput=s})),i("div",{class:"s-form-group"},i("span",{innerHTML:l}),i("input",{type:"email",class:"s-form-control s-quick-order-email-field",name:"email",required:this.isEmailRequired,placeholder:this.placeHolderEmail+" "+(this.isEmailRequired?"":this.emailOptional),ref:s=>this.emailInput=s})))],this.isTermsRequired&&i("label",{htmlFor:"terms",class:"s-quick-order-terms"},i("input",{type:"checkbox",required:!0,name:"terms",id:"terms",ref:s=>this.termsInput=s,onChange:()=>this.termsChecked=this.termsInput.checked,class:"s-checkbox"}),i("span",{class:"s-form-label"}," ",i("div",{innerHTML:this.formatAgreementText(this.agreementText,150)},this.agreementText.length>150&&i("salla-button",{shape:"link",onClick:()=>this.agreementModal.open()},this.agreementShowText))," ")),i("salla-button",{type:"submit",color:this.getBtnColor(),width:"wide",ref:s=>this.submitBtn=s},this.payButtonTitle)),i("salla-modal",{"modal-title":this.agreementModalHead,ref:s=>this.agreementModal=s},i("article",{innerHTML:this.agreementText}))))}componentDidLoad(){this.host.querySelectorAll("input").forEach((s=>{s.addEventListener("invalid",(s=>{this.handleInvalidInput(s)})),s.addEventListener("input",(()=>{s.setCustomValidity(""),s.reportValidity()}))}))}get host(){return r(this)}};o.style=".s-quick-order-expandable:not(.s-quick-order-shown){overflow:hidden}";export{o as salla_quick_order}
4
+ import{r as s,c as t,h as i,H as e,a as r}from"./p-6ZT_-rrT.js";import{S as a}from"./p-CciN5Q_x.js";import{S as l}from"./p-DLNIOD9t.js";import{S as h}from"./p-8Tsmrwno.js";const o=class{constructor(i){s(this,i),this.quickOrderSubmited=t(this,"quickOrderSubmited"),this.quickOrderTitle="ليش تنتظر؟",this.subTitle="احصل على المنتج مباشرة الآن",this.payButtonTitle="اطلب المنتج",this.confirmPayButtonTitle="اشتر الآن",this.agreementText=salla.lang.get("pages.checkout.show_full_agreement"),this.isEmailRequired=!1,this.quickOrderStyle="default",this.isAvailable=!1,this.oneClick=!1,this.expanded=!1,this.isTermsRequired=!1,this.countryCode=salla.config.get("user.country_code","SA")||"SA",this.submitSucess=!1,this.placeHolderEmail=salla.lang.get("common.elements.email"),this.emailOptional=salla.lang.get("common.elements.optional"),this.agreementShowText=salla.lang.get("pages.checkout.show_full_agreement"),this.agreementModalHead=salla.lang.get("pages.checkout.full_agreement"),this.userNameLabel=salla.lang.get("pages.products.your_name"),this.termsChecked=!1,salla.onReady((()=>{this.productId=this.productId||salla.config.get("page.id")})),salla.lang.onLoaded((()=>{this.placeHolderEmail=salla.lang.get("common.elements.email"),this.emailOptional=salla.lang.get("common.elements.optional"),this.agreementShowText=salla.lang.get("pages.checkout.show_full_agreement"),this.agreementModalHead=salla.lang.get("pages.checkout.full_agreement"),this.userNameLabel=salla.lang.get("pages.products.your_name")}))}getBtnColor(){return"default"===this.quickOrderStyle?"light":"primary"}getErrorMessage(s,t){return"terms"==t?salla.lang.get("pages.checkout.check_agreement"):salla.lang.get(`common.errors.${s}`,{attribute:"name"==t?this.userNameLabel:this.placeHolderEmail})}handleInvalidInput(s){let t,i=s.target,e=i.validity;e.valueMissing?(t=this.getErrorMessage("field_required",i.name),console.log(this.getErrorMessage("field_required",i.name))):e.typeMismatch&&(t=this.getErrorMessage("invalid_value",i.name)),i.setCustomValidity(t)}async setWrapperHeight(){let s=this.host.querySelector(".s-quick-order-expandable");setTimeout((()=>{s.style.maxHeight=s.style.maxHeight||this.oneClick?null:s.scrollHeight+"px"}),50)}getDarkOrLight(){return"default"===this.quickOrderStyle&&salla.config.get("theme.color.is_dark")?"dark":"light"}getStyleColor(){return{gray:"#f3f3f3",white:"#ffffff",default:salla.config.get("theme.color.primary")}[this.quickOrderStyle]||"#f3f3f3"}async submit(s,t=!1){return s.preventDefault(),t&&!this.oneClick?(this.expanded=!this.expanded,void this.setWrapperHeight()):this.submitBtn.load().then((()=>this.getPayload())).then((s=>salla.api.cart.createQuickOrder(s))).then((()=>{setTimeout((()=>{this.submitBtn.stop(),this.submitSucess=!0,this.quickOrderSubmited.emit()}),200)})).catch((s=>s&&(console.error(s),this.submitBtn.stop())))}async getPayload(){return this.oneClick?{product_ids:[this.productId],agreement:!0}:{product_ids:[this.productId],email:this.emailInput?.value,phone:Number((await(this.phoneInput?.getValues()))?.phone),country_code:(await(this.phoneInput?.getValues()))?.countryCode||this.countryCode,name:this.nameInput?.value,agreement:this.termsChecked}}formatAgreementText(s,t=150){return s?s.length<=t?s:(new DOMParser).parseFromString(s,"text/html").documentElement.innerText.substring(0,t)+"...":""}loadQuickOrderSettings(){let s=salla.config.get("store.settings.quick_order");return s?(this.user=salla.config.get("user")||salla.storage.get("user")||{},this.countryCode=this.user?.country_code||this.countryCode,this.isEmailRequired=!this.user?.email&&this.isEmailRequired,this.oneClick=this.user?.email,this.initComponentData(s),Promise.resolve()):Promise.resolve()}initComponentData(s){this.quickOrderTitle=s.title,this.subTitle=s.sub_title,this.payButtonTitle=s.order_now_button,this.isEmailRequired=s.is_email_required,this.isTermsRequired=s.show_agreement,this.agreementText=s.agreement,this.confirmPayButtonTitle=s.confirm_button,this.thanksMessage=s.thanks_message,this.quickOrderStyle=s.style,this.isAvailable=!0,this.oneClick=this.oneClick&&!this.isTermsRequired}componentWillLoad(){return new Promise((s=>salla.onReady((()=>this.loadQuickOrderSettings().then(s)))))}render(){if(this.isAvailable)return this.submitSucess?i(e,{class:"s-quick-order"},i("div",{class:"s-quick-order-confirm",style:{backgroundColor:salla.config.get("theme.color.primary")+"10",borderColor:salla.config.get("theme.color.primary")+"10",color:salla.config.get("theme.color.primary")}},i("i",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>party-horn</title>\n<path fill="currentColor" d="M5.333 4.013c0.736 0 1.333-0.596 1.333-1.333v-0.013c0-0.737-0.597-1.327-1.333-1.327s-1.333 0.603-1.333 1.34 0.597 1.333 1.333 1.333zM11.333 10c0.341 0 0.683-0.131 0.943-0.391 1.541-1.54 2.391-3.589 2.391-5.771v-2.505c0-0.737-0.597-1.333-1.333-1.333s-1.333 0.596-1.333 1.333v2.505c0 1.468-0.572 2.848-1.609 3.885-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.601 0.391 0.943 0.391zM18.667 9.993c0.319 0 0.639-0.115 0.895-0.345 0.383-0.347 0.684-0.325 1.497-0.22 0.923 0.124 2.319 0.307 3.636-0.887 1.293-1.172 1.303-2.54 1.308-3.539 0.005-0.887 0.043-1.228 0.432-1.581 0.361-0.327 0.621-0.335 1.493-0.216 0.923 0.12 2.317 0.307 3.635-0.884 0.545-0.495 0.587-1.337 0.093-1.883-0.493-0.547-1.336-0.589-1.884-0.093-0.361 0.325-0.621 0.333-1.493 0.216-0.921-0.119-2.317-0.305-3.635 0.884-1.293 1.173-1.303 2.541-1.308 3.54-0.005 0.885-0.043 1.227-0.432 1.58-0.383 0.348-0.683 0.327-1.497 0.22-0.924-0.124-2.32-0.305-3.636 0.887-0.545 0.495-0.587 1.339-0.092 1.884 0.264 0.291 0.625 0.437 0.988 0.437zM18.667 16.013c0.736 0 1.333-0.596 1.333-1.333v-0.013c0-0.737-0.597-1.327-1.333-1.327s-1.333 0.603-1.333 1.34 0.597 1.333 1.333 1.333zM30.667 17.333h-2.505c-2.179 0-4.228 0.849-5.771 2.391-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.603 0.391 0.944 0.391s0.683-0.131 0.943-0.391c1.023-1.023 2.439-1.609 3.884-1.609h2.505c0.736 0 1.333-0.596 1.333-1.333s-0.597-1.333-1.333-1.333zM30.667 10.66c-0.736 0-1.333 0.603-1.333 1.34s0.597 1.333 1.333 1.333 1.333-0.596 1.333-1.333v-0.013c0-0.736-0.597-1.327-1.333-1.327zM29.333 26.66c-0.736 0-1.333 0.603-1.333 1.34s0.597 1.333 1.333 1.333 1.333-0.596 1.333-1.333v-0.013c0-0.736-0.597-1.327-1.333-1.327zM7.456 11.057c-0.327-0.327-0.799-0.46-1.249-0.356-0.449 0.107-0.812 0.439-0.959 0.876l-5.036 15.113c-0.487 1.457-0.113 3.037 0.973 4.125 0.772 0.771 1.792 1.183 2.84 1.183 0.428 0 0.861-0.068 1.284-0.209l15.112-5.037c0.439-0.145 0.769-0.508 0.876-0.959 0.107-0.449-0.028-0.921-0.355-1.249zM4.467 29.259c-0.503 0.163-1.023 0.043-1.395-0.329-0.373-0.373-0.497-0.896-0.329-1.396l4.355-13.065 10.436 10.435z"></path>\n</svg>\n'}),i("span",null,this.thanksMessage))):i(e,{class:`s-quick-order s-quick-order-${this.getDarkOrLight()}`},i("div",{class:`s-quick-order-container s-quick-order-${this.quickOrderStyle}`,style:{backgroundColor:this.getStyleColor()}},i("div",{class:"s-quick-order-button-cont"},i("div",null,i("h3",null,this.quickOrderTitle),i("p",null,this.subTitle)),i("salla-button",{class:this.expanded?"s-quick-order-btn-close":"",onClick:s=>this.submit(s,!0),color:this.getBtnColor()},this.oneClick?this.confirmPayButtonTitle:this.expanded?i("i",{innerHTML:h}):this.confirmPayButtonTitle)),i("form",{onSubmit:s=>this.submit(s),class:"s-quick-order-expandable "+(this.expanded?"s-quick-order-shown":"")},Salla.config.isGuest()&&[i("div",{class:"s-form-group"},i("span",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>portrait</title>\n<path d="M24 1.333h-16c-3.676 0-6.667 2.991-6.667 6.667v16c0 3.028 2.041 5.561 4.811 6.371 0.004 0.001 0.008 0.003 0.012 0.004 0.591 0.172 1.2 0.292 1.844 0.292h16c0.644 0 1.253-0.12 1.843-0.292 0.004-0.001 0.008-0.003 0.012-0.004 2.771-0.809 4.812-3.343 4.812-6.371v-16c0-3.676-2.991-6.667-6.667-6.667zM8.012 28c0.121-1.915 3.363-4 7.988-4s7.868 2.085 7.988 4zM28 24c0 1.24-0.579 2.335-1.467 3.069-0.768-3.288-5.112-5.736-10.533-5.736s-9.765 2.448-10.533 5.736c-0.888-0.735-1.467-1.829-1.467-3.069v-16c0-2.205 1.795-4 4-4h16c2.205 0 4 1.795 4 4zM16 6.667c-3.308 0-6 2.692-6 6s2.692 6 6 6 6-2.692 6-6-2.692-6-6-6zM16 16c-1.839 0-3.333-1.495-3.333-3.333s1.495-3.333 3.333-3.333 3.333 1.495 3.333 3.333-1.495 3.333-3.333 3.333z"></path>\n</svg>\n'}),i("input",{type:"text",required:!0,class:"s-form-control s-quick-order-phone-field",name:"name",placeholder:this.userNameLabel,ref:s=>this.nameInput=s})),i("div",{class:"s-quick-order-flex-input"},i("div",{class:"s-form-group"},i("span",{innerHTML:a}),i("salla-tel-input",{ref:s=>this.phoneInput=s})),i("div",{class:"s-form-group"},i("span",{innerHTML:l}),i("input",{type:"email",class:"s-form-control s-quick-order-email-field",name:"email",required:this.isEmailRequired,placeholder:this.placeHolderEmail+" "+(this.isEmailRequired?"":this.emailOptional),ref:s=>this.emailInput=s})))],this.isTermsRequired&&i("label",{htmlFor:"terms",class:"s-quick-order-terms"},i("input",{type:"checkbox",required:!0,name:"terms",id:"terms",ref:s=>this.termsInput=s,onChange:()=>this.termsChecked=this.termsInput.checked,class:"s-checkbox"}),i("span",{class:"s-form-label"}," ",i("div",{innerHTML:this.formatAgreementText(this.agreementText,150)},this.agreementText.length>150&&i("salla-button",{shape:"link",onClick:()=>this.agreementModal.open()},this.agreementShowText))," ")),i("salla-button",{type:"submit",color:this.getBtnColor(),width:"wide",ref:s=>this.submitBtn=s},this.payButtonTitle)),i("salla-modal",{"modal-title":this.agreementModalHead,ref:s=>this.agreementModal=s},i("article",{innerHTML:this.agreementText}))))}componentDidLoad(){this.host.querySelectorAll("input").forEach((s=>{s.addEventListener("invalid",(s=>{this.handleInvalidInput(s)})),s.addEventListener("input",(()=>{s.setCustomValidity(""),s.reportValidity()}))}))}get host(){return r(this)}};o.style=".s-quick-order-expandable:not(.s-quick-order-shown){overflow:hidden}";export{o as salla_quick_order}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as t,a as e}from"./p-eYsXdqjv.js";var o,i;!function(s){s.ProductDetail="product.single",s.Cart="cart"}(o||(o={})),function(s){s.Conditional="conditional",s.PercentageOrFixed="fixed",s.DiscountsTable="discounts_table",s.Bank="bank",s.BuyXGetY="buy_x_get_y",s.SpecialPrice="special_price",s.Percentage="percentage",s.FixedAmount="fixed_amount"}(i||(i={}));const r=class{constructor(t){s(this,t),this.productCardComponent="salla-product-card",this.offersList=[],this.canRender=!1,this.showOffer=salla.config.get("store.settings.product.show_special_offers"),this.showAllOffersModal=!1,this.showProductsModal=!1,this.selectedOfferProducts=[],this.collapsedOffers={},this.expandedCategories={},this.productsLoaded=!1,this.offer_with_price_text=salla.lang.get("pages.offer.with_price",{price:""}),this.with_discount_text=salla.lang.get("pages.products.with_a_discount"),this.product_discount_text=salla.lang.get("pages.products.discount"),this.special_offer_text=salla.lang.get("pages.products.special_offer"),this.buy_quantity_text=s=>salla.lang.get("pages.offer.buy_quantity",{quantity:s}),this.products_link_text=salla.lang.get("pages.offer.included_products","المنتجات المشمولة"),this.min_spend_text=(s,t)=>salla.lang.get("pages.offer.min_spend_amount",{amount:s,currency:t},`بحد أدنى ${s} ${t} من مبلغ الشراء`),this.min_items_text=s=>salla.lang.get("pages.offer.min_items",{items:s},`بحد أدنى ${s} منتجات`),this.product_text=salla.lang.get("common.elements.product","منتج"),salla.lang.onLoaded((()=>{this.offer_with_price_text=salla.lang.get("pages.offer.with_price"),this.with_discount_text=salla.lang.get("pages.products.with_a_discount"),this.product_discount_text=salla.lang.get("pages.products.discount"),this.special_offer_text=salla.lang.get("pages.products.special_offer"),this.buy_quantity_text(0),this.products_link_text=salla.lang.get("pages.offer.included_products","المنتجات المشمولة"),this.min_spend_text=(s,t)=>salla.lang.get("pages.offer.min_spend_amount",{amount:s,currency:t},`بحد أدنى ${s} ${t} من مبلغ الشراء`),this.min_items_text=s=>salla.lang.get("pages.offer.min_items",{items:s},`بحد أدنى ${s} منتجات`),this.product_text=salla.lang.get("common.elements.product","منتج")})),salla.onReady((()=>{this.currentPage=salla.config.get("page.slug");const s=salla.config.get("currencies")||{},t=salla.config.get("user.currency_code");this.userCurrency=s[t]||{symbol:"",code:t||"SAR",name:""}}))}async getEndpointByPageName(){return this.currentPage==o.Cart?`offers/cart/${await Salla.cart.getCurrentCartId()}`:this.currentPage==o.ProductDetail?`offers/product/${salla.config.get("page.id")}`:"offers"}emitPromotionViewed(){if(!(this.offersList.length&&this.canRender&&this.showOffer))return;const s=this.offersList.slice(0,5).map(((s,t)=>({id:s.id,name:s.title,creative:s.description||"",position:t+1})));salla.event.emit("salla::offer.promotion.viewed",s)}emitPromotionClicked(s,t=1){if(!(this.offersList.length&&this.canRender&&this.showOffer))return;const e=s||this.offersList[0];salla.event.emit("salla::offer.promotion.clicked",[{id:e.id,name:e.title,creative:e.description||"",position:t}])}componentWillLoad(){return this.hasCustomComponent=!!customElements.get(this.productCardComponent),new Promise((s=>salla.onReady(s))).then((()=>{if(this.showOffer=!salla.url.is_page("product.single")||salla.config.get("store.settings.product.show_special_offers"),!this.showOffer)throw new Error("Merchant disabled showing the offers on product page")})).then((async()=>salla.api.request(await this.getEndpointByPageName()))).then((async s=>{if(!(this.offersList=s.data).length)throw new Error("salla-offers:: There is no offers!");if(this.offersList=this.offersList.filter((s=>[i.SpecialPrice,i.Bank,i.BuyXGetY,i.DiscountsTable,i.PercentageOrFixed,i.Percentage,i.FixedAmount].includes(s.type))),!this.offersList.length)throw new Error("salla-offers:: No supported offer types found!");let t=null;this.offersList.some((s=>{const t=s.details;return"category"===t.apply_to&&t.targets||"categories"===t.apply_to&&t.targets||s.type===i.BuyXGetY&&("categories"===t.get?.source||"category"===t.get?.source)}))&&(t=(await salla.product.api.categories()).data);const e=new Set;for(const s of this.offersList){const t=s.details;"product"!==t.apply_to&&"products"!==t.apply_to||!t.targets||t.targets.forEach((s=>e.add(s))),s.type===i.BuyXGetY&&"products"===t.get?.source&&t.get?.source_value&&t.get.source_value.forEach((s=>e.add(s))),s.type!==i.BuyXGetY||"products"!==t.buy?.source&&"product"!==t.buy?.source||!t.buy?.source_value||t.buy.source_value.forEach((s=>e.add(s)))}let o={};if(e.size>0)try{const s=await salla.product.api.fetch({source:"selected",source_value:Array.from(e)});o=Object.fromEntries(s.data.map((s=>[s.id,s])))}catch(s){o={}}for(const s of this.offersList){const e=s.details;if(("category"===e.apply_to&&e.targets||"categories"===e.apply_to&&e.targets)&&t&&(e.categories=this.findCategories(t,e.targets)),"product"!==e.apply_to&&"products"!==e.apply_to||!e.targets||(e.products=e.targets.map((s=>o[s])).filter(Boolean)),"brand"===e.apply_to&&e.targets&&(e.brands=e.targets),s.type===i.BuyXGetY&&e.get){const s=e.get;"products"===s.source&&s.source_value?s.products=s.source_value.map((s=>o[s])).filter(Boolean):("categories"===s.source||"category"===s.source)&&t&&s.source_value&&(s.categories=this.findCategories(t,s.source_value),e.categories=s.categories)}if(s.type===i.BuyXGetY&&e.buy){const s=e.buy;"products"!==s.source&&"product"!==s.source||!s.source_value||(s.products=s.source_value.map((s=>o[s])).filter(Boolean))}}return this.offersList})).then((()=>{this.canRender=!0})).catch((s=>{salla.logger.warn(s)}))}componentDidLoad(){let s=this.host.querySelector(".s-slider-block__title-nav");s?.classList.add("s-offer-bank-payment-nav"),this.emitPromotionViewed()}findCategories(s,t){let e=[];for(const o of s)t.includes(o.id_||o.id)&&e.push(o),o.sub_categories?.length>0&&(e=e.concat(this.findCategories(o.sub_categories,t)));return e}render(){if(!this.offersList.length||!this.canRender||!this.showOffer)return null;const s=salla.lang.get("pages.offer.offers_title","عروض المنتج"),e=salla.lang.get("pages.offer.offers_subtitle","احصل على المنتج بسعر مخفض مع أفضل العروض");return[t("div",{class:"s-offer-wrapper"},t("salla-slider",{type:"carousel",id:"offers-slider","block-title":s,"block-subTitle":e,"show-controls":this.offersList.length>1},t("div",{slot:"items"},this.offersList.slice(0,5).map(((s,t)=>this.renderOfferCard(s,t+1))),this.offersList.length>5&&this.renderShowMoreCard()))),this.renderAllOffersModal(),this.renderProductsModal()]}renderShowMoreCard(){return t("div",{class:"s-offer-slide-one-fourth swiper-slide",onClick:s=>{s.preventDefault(),s.stopPropagation(),this.openAllOffersModal()}},t("div",{class:"s-offer-card s-offer-show-more-card"},t("i",{class:"sicon-add s-offer-show-more-icon"}),t("h3",{class:"s-offer-show-more-title"},salla.lang.get("pages.offer.show_more_offers","عرض المزيد من العروض"))))}openAllOffersModal(){this.showAllOffersModal=!0}closeAllOffersModal(){this.showAllOffersModal=!1}closeProductsModal(){this.showProductsModal=!1,this.selectedOfferProducts=[],this.productsLoaded=!1}handleAccordionToggle(s,t){this.collapsedOffers={...this.collapsedOffers,[s]:t}}getOfferProducts(s){const t=s.details;return t.products&&t.products.length>0?t.products:s.type===i.BuyXGetY&&t.get?.products?t.get.products:[]}renderProductsLinkForModalCard(s,e){const o=this.getOfferProducts(s);return o&&0!==o.length?t("div",{class:"s-offer-products-link",onClick:s=>{s.stopPropagation(),this.selectedOfferProducts=o,this.showProductsModal=!0}},t("span",{class:"s-offer-products-link-text"},this.products_link_text),e&&t("i",{class:"sicon-keyboard_arrow_down s-offer-products-link-icon"})):null}renderAllOffersModal(){return t("salla-drawer",{visible:this.showAllOffersModal,position:"right",width:"md","no-padding":!0,"drawer-title":salla.lang.get("pages.offer.all_offers_title","جميع العروض"),onDrawerVisibilityChanged:s=>!s.detail&&this.closeAllOffersModal()},t("div",{class:"s-offer-drawer-content"},this.offersList.map(((s,t)=>this.renderModalOfferCard(s,t+1)))))}renderProductsModal(){return t("salla-drawer",{visible:this.showProductsModal,width:"md",position:"right","no-padding":!0,"drawer-title":this.products_link_text,onDrawerVisibilityChanged:s=>!s.detail&&this.closeProductsModal()},t("div",{class:"s-offer-products-drawer-content"},this.selectedOfferProducts?.length>0?t("div",null,!this.productsLoaded&&t("div",{class:"flex items-center justify-center p-8"},t("salla-loading",{size:"24"})),t("salla-products-list",{source:"selected","source-value":JSON.stringify(this.selectedOfferProducts.map((s=>s.id))),"product-card-component":this.productCardComponent,"horizontal-cards":!0,"compact-cards":!0,includes:["images"],onProductsFetched:()=>this.productsLoaded=!0})):t("div",{class:"p-4 text-center text-gray-500"},salla.lang.get("blocks.products.no_products_found","لا توجد منتجات"))))}renderModalOfferCard(s,e=1){const o=this.getOfferProducts(s),r=o&&o.length>0,a=!1!==this.collapsedOffers[s.id];return t("div",{class:"s-offer-drawer-card"},t("div",{class:"s-offer-card-main",onClick:()=>this.emitPromotionClicked(s,e)},t("div",{class:"s-offer-card-icon"},this.getOfferIcon(s.type)),t("div",{class:"s-offer-card-content"},t("h3",{class:"s-offer-card-title",title:s.title},s.title),s.description&&t("p",{class:"s-offer-card-description"},s.description),s.type===i.DiscountsTable?t("div",{class:"s-offer-card-details"},this.renderDiscountTableOfferContent(s)):s.type===i.PercentageOrFixed||s.type===i.Percentage||s.type===i.FixedAmount?t("div",{class:"s-offer-card-details"},this.renderPercentageOrFixedOfferContent(s),this.renderOfferCategories(s),this.renderOfferBrands(s)):t("div",{class:"s-offer-card-details"},this.renderOfferCategories(s),this.renderOfferBrands(s)))),r&&t("salla-accordion",{collapsed:a,collapsible:!0,size:"sm",onClick:s=>s.stopPropagation(),onAccordionToggle:t=>this.handleAccordionToggle(s.id,t.detail.payload.collapsed)},t("salla-accordion-head",{collapsible:!0,collapsed:a},t("div",{slot:"title",class:"s-offer-products-thumbnails"},t("span",{class:"s-offer-products-title"},this.products_link_text,t("i",{class:`sicon-keyboard_arrow_${a?"down":"up"} s-offer-products-link-icon`})),t("div",{class:"s-offer-products-thumbnails-stack"},o.slice(0,3).map(((s,e)=>t("div",{class:"s-offer-product-thumbnail",style:{zIndex:`${e+1}`}},t("img",{src:s.thumbnail||s.image?.url||salla.url.cdn("images/s-empty.png"),alt:s.name})))),o.length>3&&t("div",{class:"s-offer-products-more-count",style:{zIndex:"7"}},"+",o.length-3)))),t("salla-accordion-body",null,t("div",{class:"s-offer-products-content"},t("salla-products-list",{source:"selected","source-value":JSON.stringify(o.map((s=>s.id))),"product-card-component":this.productCardComponent,"horizontal-cards":!0,"compact-cards":!0,includes:["images"]})))))}renderOfferCard(s,e=1){return t("div",{class:"s-offer-slide-one-fourth swiper-slide",onClick:()=>this.emitPromotionClicked(s,e)},t("div",{class:"s-offer-card"},t("div",{class:"s-offer-card-icon"},this.getOfferIcon(s.type)),t("div",{class:"s-offer-card-content"},t("h3",{class:"s-offer-card-title",title:s.title},s.title),s.description&&t("p",{class:"s-offer-card-description"},s.description),t("div",{class:"s-offer-card-details"},s.type===i.DiscountsTable?this.renderDiscountTableOfferContent(s):s.type===i.PercentageOrFixed||s.type===i.Percentage||s.type===i.FixedAmount?[this.renderPercentageOrFixedOfferContent(s),this.renderOfferCategories(s),this.renderOfferBrands(s)]:[this.renderOfferCategories(s),this.renderOfferBrands(s)],this.renderProductsLinkForModalCard(s,!1)))))}getOfferIcon(s){return t("i",{class:{[i.DiscountsTable]:"sicon-discount-calculator",[i.Bank]:"sicon-bank",[i.SpecialPrice]:"sicon-fire",[i.BuyXGetY]:"sicon-gift",[i.PercentageOrFixed]:"sicon-special-discount",[i.Percentage]:"sicon-special-discount",[i.FixedAmount]:"sicon-special-discount"}[s]||"sicon-discount"})}renderDiscountTableOfferContent(s){const e=s.details.discounts||[];return e.length?t("div",null,t("div",{class:"s-offer-card-description"},salla.lang.get("pages.offer.discount_table_subtitle","وفر اكتر بشراء منتجات أكثر")),t("table",{class:"s-offer-discount-table"},t("tbody",null,this.groupDiscountsByRows(e,3).map(((s,e)=>t("tr",{key:e},s.map(((s,e)=>t("td",{key:e},t("div",{class:"s-offer-discount-percentage"},s.percentage,"%"),t("div",{class:"s-offer-discount-condition"},this.formatDiscountCondition(s))))))))))):null}renderPercentageOrFixedOfferContent(s){const e=s.details;return e.discount_value||e.min_spend>0||e.min_items>0?t("div",{class:"s-offer-percentage-fixed-content"},e.min_spend>0&&t("div",{class:"s-offer-min-spend"},this.min_spend_text(e.min_spend,this.userCurrency?.symbol||"")),e.min_items>0&&t("div",{class:"s-offer-min-items"},this.min_items_text(e.min_items))):null}groupDiscountsByRows(s,t){const e=[];for(let o=0;o<s.length;o+=t)e.push(s.slice(o,o+t));return e}formatDiscountCondition(s){return s.discounted_amount?`${s.discounted_amount} ${this.userCurrency?.symbol||""}`:null!=s.quantity?this.buy_quantity_text(s.quantity):`1 ${this.product_text}`}renderOfferCategories(s){const e=s.details;let o=e.categories||[];if(s.type===i.BuyXGetY&&e.get?.categories&&(o=e.get.categories),!o.length)return null;const r=this.expandedCategories[s.id],a=o.length>3,l=r?o:o.slice(0,3);return t("div",{class:"s-offer-categories"},t("div",{class:"s-offer-categories-list"},l.map(((s,e)=>t("a",{key:e,class:"s-offer-category-item",href:s.url||salla.url.create("categories",s.id||s.id_)},s.name))),a&&t("span",{class:"s-offer-categories-toggle",onClick:t=>{t.preventDefault(),t.stopPropagation(),this.toggleCategoryExpansion(s.id)}},r?t("span",null,t("i",{class:"sicon-keyboard_arrow_up"})," ",salla.lang.get("common.elements.hide","إخفاء")):t("span",null,salla.lang.get("common.elements.show","عرض")," ","+"+(o.length-3)," ",t("i",{class:"sicon-keyboard_arrow_down"})))))}renderOfferBrands(s){const e=s.details.brands||[];if(!e.length)return null;const o=this.expandedCategories[s.id],i=e.length>3,r=o?e:e.slice(0,3);return t("div",{class:"s-offer-categories"},t("div",{class:"s-offer-categories-list"},r.map(((s,e)=>t("a",{key:e,class:"s-offer-category-item",href:s.url},s.name))),i&&t("span",{class:"s-offer-categories-toggle",onClick:t=>{t.preventDefault(),t.stopPropagation(),this.toggleCategoryExpansion(s.id)}},o?t("span",null,t("i",{class:"sicon-keyboard_arrow_up"})," ",salla.lang.get("common.elements.hide","إخفاء")):t("span",null,salla.lang.get("common.elements.show","عرض")," ","+"+(e.length-3)," ",t("i",{class:"sicon-keyboard_arrow_down"})))))}toggleCategoryExpansion(s){this.expandedCategories={...this.expandedCategories,[s]:!this.expandedCategories[s]}}get host(){return e(this)}};r.style=":host .s-drawer-close:where([dir=rtl],[dir=rtl] *){left:0}";export{r as salla_offer}
4
+ import{r as s,h as t,a as e}from"./p-6ZT_-rrT.js";var o,i;!function(s){s.ProductDetail="product.single",s.Cart="cart"}(o||(o={})),function(s){s.Conditional="conditional",s.PercentageOrFixed="fixed",s.DiscountsTable="discounts_table",s.Bank="bank",s.BuyXGetY="buy_x_get_y",s.SpecialPrice="special_price",s.Percentage="percentage",s.FixedAmount="fixed_amount"}(i||(i={}));const r=class{constructor(t){s(this,t),this.productCardComponent="salla-product-card",this.offersList=[],this.canRender=!1,this.showOffer=salla.config.get("store.settings.product.show_special_offers"),this.showAllOffersModal=!1,this.showProductsModal=!1,this.selectedOfferProducts=[],this.collapsedOffers={},this.expandedCategories={},this.productsLoaded=!1,this.offer_with_price_text=salla.lang.get("pages.offer.with_price",{price:""}),this.with_discount_text=salla.lang.get("pages.products.with_a_discount"),this.product_discount_text=salla.lang.get("pages.products.discount"),this.special_offer_text=salla.lang.get("pages.products.special_offer"),this.buy_quantity_text=s=>salla.lang.get("pages.offer.buy_quantity",{quantity:s}),this.products_link_text=salla.lang.get("pages.offer.included_products","المنتجات المشمولة"),this.min_spend_text=(s,t)=>salla.lang.get("pages.offer.min_spend_amount",{amount:s,currency:t},`بحد أدنى ${s} ${t} من مبلغ الشراء`),this.min_items_text=s=>salla.lang.get("pages.offer.min_items",{items:s},`بحد أدنى ${s} منتجات`),this.product_text=salla.lang.get("common.elements.product","منتج"),salla.lang.onLoaded((()=>{this.offer_with_price_text=salla.lang.get("pages.offer.with_price"),this.with_discount_text=salla.lang.get("pages.products.with_a_discount"),this.product_discount_text=salla.lang.get("pages.products.discount"),this.special_offer_text=salla.lang.get("pages.products.special_offer"),this.buy_quantity_text(0),this.products_link_text=salla.lang.get("pages.offer.included_products","المنتجات المشمولة"),this.min_spend_text=(s,t)=>salla.lang.get("pages.offer.min_spend_amount",{amount:s,currency:t},`بحد أدنى ${s} ${t} من مبلغ الشراء`),this.min_items_text=s=>salla.lang.get("pages.offer.min_items",{items:s},`بحد أدنى ${s} منتجات`),this.product_text=salla.lang.get("common.elements.product","منتج")})),salla.onReady((()=>{this.currentPage=salla.config.get("page.slug");const s=salla.config.get("currencies")||{},t=salla.config.get("user.currency_code");this.userCurrency=s[t]||{symbol:"",code:t||"SAR",name:""}}))}async getEndpointByPageName(){return this.currentPage==o.Cart?`offers/cart/${await Salla.cart.getCurrentCartId()}`:this.currentPage==o.ProductDetail?`offers/product/${salla.config.get("page.id")}`:"offers"}emitPromotionViewed(){if(!(this.offersList.length&&this.canRender&&this.showOffer))return;const s=this.offersList.slice(0,5).map(((s,t)=>({id:s.id,name:s.title,creative:s.description||"",position:t+1})));salla.event.emit("salla::offer.promotion.viewed",s)}emitPromotionClicked(s,t=1){if(!(this.offersList.length&&this.canRender&&this.showOffer))return;const e=s||this.offersList[0];salla.event.emit("salla::offer.promotion.clicked",[{id:e.id,name:e.title,creative:e.description||"",position:t}])}componentWillLoad(){return this.hasCustomComponent=!!customElements.get(this.productCardComponent),new Promise((s=>salla.onReady(s))).then((()=>{if(this.showOffer=!salla.url.is_page("product.single")||salla.config.get("store.settings.product.show_special_offers"),!this.showOffer)throw new Error("Merchant disabled showing the offers on product page")})).then((async()=>salla.api.request(await this.getEndpointByPageName()))).then((async s=>{if(!(this.offersList=s.data).length)throw new Error("salla-offers:: There is no offers!");if(this.offersList=this.offersList.filter((s=>[i.SpecialPrice,i.Bank,i.BuyXGetY,i.DiscountsTable,i.PercentageOrFixed,i.Percentage,i.FixedAmount].includes(s.type))),!this.offersList.length)throw new Error("salla-offers:: No supported offer types found!");let t=null;this.offersList.some((s=>{const t=s.details;return"category"===t.apply_to&&t.targets||"categories"===t.apply_to&&t.targets||s.type===i.BuyXGetY&&("categories"===t.get?.source||"category"===t.get?.source)}))&&(t=(await salla.product.api.categories()).data);const e=new Set;for(const s of this.offersList){const t=s.details;"product"!==t.apply_to&&"products"!==t.apply_to||!t.targets||t.targets.forEach((s=>e.add(s))),s.type===i.BuyXGetY&&"products"===t.get?.source&&t.get?.source_value&&t.get.source_value.forEach((s=>e.add(s))),s.type!==i.BuyXGetY||"products"!==t.buy?.source&&"product"!==t.buy?.source||!t.buy?.source_value||t.buy.source_value.forEach((s=>e.add(s)))}let o={};if(e.size>0)try{const s=await salla.product.api.fetch({source:"selected",source_value:Array.from(e)});o=Object.fromEntries(s.data.map((s=>[s.id,s])))}catch(s){o={}}for(const s of this.offersList){const e=s.details;if(("category"===e.apply_to&&e.targets||"categories"===e.apply_to&&e.targets)&&t&&(e.categories=this.findCategories(t,e.targets)),"product"!==e.apply_to&&"products"!==e.apply_to||!e.targets||(e.products=e.targets.map((s=>o[s])).filter(Boolean)),"brand"===e.apply_to&&e.targets&&(e.brands=e.targets),s.type===i.BuyXGetY&&e.get){const s=e.get;"products"===s.source&&s.source_value?s.products=s.source_value.map((s=>o[s])).filter(Boolean):("categories"===s.source||"category"===s.source)&&t&&s.source_value&&(s.categories=this.findCategories(t,s.source_value),e.categories=s.categories)}if(s.type===i.BuyXGetY&&e.buy){const s=e.buy;"products"!==s.source&&"product"!==s.source||!s.source_value||(s.products=s.source_value.map((s=>o[s])).filter(Boolean))}}return this.offersList})).then((()=>{this.canRender=!0})).catch((s=>{salla.logger.warn(s)}))}componentDidLoad(){let s=this.host.querySelector(".s-slider-block__title-nav");s?.classList.add("s-offer-bank-payment-nav"),this.emitPromotionViewed()}findCategories(s,t){let e=[];for(const o of s)t.includes(o.id_||o.id)&&e.push(o),o.sub_categories?.length>0&&(e=e.concat(this.findCategories(o.sub_categories,t)));return e}render(){if(!this.offersList.length||!this.canRender||!this.showOffer)return null;const s=salla.lang.get("pages.offer.offers_title","عروض المنتج"),e=salla.lang.get("pages.offer.offers_subtitle","احصل على المنتج بسعر مخفض مع أفضل العروض");return[t("div",{class:"s-offer-wrapper"},t("salla-slider",{type:"carousel",id:"offers-slider","block-title":s,"block-subTitle":e,"show-controls":this.offersList.length>1},t("div",{slot:"items"},this.offersList.slice(0,5).map(((s,t)=>this.renderOfferCard(s,t+1))),this.offersList.length>5&&this.renderShowMoreCard()))),this.renderAllOffersModal(),this.renderProductsModal()]}renderShowMoreCard(){return t("div",{class:"s-offer-slide-one-fourth swiper-slide",onClick:s=>{s.preventDefault(),s.stopPropagation(),this.openAllOffersModal()}},t("div",{class:"s-offer-card s-offer-show-more-card"},t("i",{class:"sicon-add s-offer-show-more-icon"}),t("h3",{class:"s-offer-show-more-title"},salla.lang.get("pages.offer.show_more_offers","عرض المزيد من العروض"))))}openAllOffersModal(){this.showAllOffersModal=!0}closeAllOffersModal(){this.showAllOffersModal=!1}closeProductsModal(){this.showProductsModal=!1,this.selectedOfferProducts=[],this.productsLoaded=!1}handleAccordionToggle(s,t){this.collapsedOffers={...this.collapsedOffers,[s]:t}}getOfferProducts(s){const t=s.details;return t.products&&t.products.length>0?t.products:s.type===i.BuyXGetY&&t.get?.products?t.get.products:[]}renderProductsLinkForModalCard(s,e){const o=this.getOfferProducts(s);return o&&0!==o.length?t("div",{class:"s-offer-products-link",onClick:s=>{s.stopPropagation(),this.selectedOfferProducts=o,this.showProductsModal=!0}},t("span",{class:"s-offer-products-link-text"},this.products_link_text),e&&t("i",{class:"sicon-keyboard_arrow_down s-offer-products-link-icon"})):null}renderAllOffersModal(){return t("salla-drawer",{visible:this.showAllOffersModal,position:"right",width:"md","no-padding":!0,"drawer-title":salla.lang.get("pages.offer.all_offers_title","جميع العروض"),onDrawerVisibilityChanged:s=>!s.detail&&this.closeAllOffersModal()},t("div",{class:"s-offer-drawer-content"},this.offersList.map(((s,t)=>this.renderModalOfferCard(s,t+1)))))}renderProductsModal(){return t("salla-drawer",{visible:this.showProductsModal,width:"md",position:"right","no-padding":!0,"drawer-title":this.products_link_text,onDrawerVisibilityChanged:s=>!s.detail&&this.closeProductsModal()},t("div",{class:"s-offer-products-drawer-content"},this.selectedOfferProducts?.length>0?t("div",null,!this.productsLoaded&&t("div",{class:"flex items-center justify-center p-8"},t("salla-loading",{size:"24"})),t("salla-products-list",{source:"selected","source-value":JSON.stringify(this.selectedOfferProducts.map((s=>s.id))),"product-card-component":this.productCardComponent,"horizontal-cards":!0,"compact-cards":!0,includes:["images"],onProductsFetched:()=>this.productsLoaded=!0})):t("div",{class:"p-4 text-center text-gray-500"},salla.lang.get("blocks.products.no_products_found","لا توجد منتجات"))))}renderModalOfferCard(s,e=1){const o=this.getOfferProducts(s),r=o&&o.length>0,a=!1!==this.collapsedOffers[s.id];return t("div",{class:"s-offer-drawer-card"},t("div",{class:"s-offer-card-main",onClick:()=>this.emitPromotionClicked(s,e)},t("div",{class:"s-offer-card-icon"},this.getOfferIcon(s.type)),t("div",{class:"s-offer-card-content"},t("h3",{class:"s-offer-card-title",title:s.title},s.title),s.description&&t("p",{class:"s-offer-card-description"},s.description),s.type===i.DiscountsTable?t("div",{class:"s-offer-card-details"},this.renderDiscountTableOfferContent(s)):s.type===i.PercentageOrFixed||s.type===i.Percentage||s.type===i.FixedAmount?t("div",{class:"s-offer-card-details"},this.renderPercentageOrFixedOfferContent(s),this.renderOfferCategories(s),this.renderOfferBrands(s)):t("div",{class:"s-offer-card-details"},this.renderOfferCategories(s),this.renderOfferBrands(s)))),r&&t("salla-accordion",{collapsed:a,collapsible:!0,size:"sm",onClick:s=>s.stopPropagation(),onAccordionToggle:t=>this.handleAccordionToggle(s.id,t.detail.payload.collapsed)},t("salla-accordion-head",{collapsible:!0,collapsed:a},t("div",{slot:"title",class:"s-offer-products-thumbnails"},t("span",{class:"s-offer-products-title"},this.products_link_text,t("i",{class:`sicon-keyboard_arrow_${a?"down":"up"} s-offer-products-link-icon`})),t("div",{class:"s-offer-products-thumbnails-stack"},o.slice(0,3).map(((s,e)=>t("div",{class:"s-offer-product-thumbnail",style:{zIndex:`${e+1}`}},t("img",{src:s.thumbnail||s.image?.url||salla.url.cdn("images/s-empty.png"),alt:s.name})))),o.length>3&&t("div",{class:"s-offer-products-more-count",style:{zIndex:"7"}},"+",o.length-3)))),t("salla-accordion-body",null,t("div",{class:"s-offer-products-content"},t("salla-products-list",{source:"selected","source-value":JSON.stringify(o.map((s=>s.id))),"product-card-component":this.productCardComponent,"horizontal-cards":!0,"compact-cards":!0,includes:["images"]})))))}renderOfferCard(s,e=1){return t("div",{class:"s-offer-slide-one-fourth swiper-slide",onClick:()=>this.emitPromotionClicked(s,e)},t("div",{class:"s-offer-card"},t("div",{class:"s-offer-card-icon"},this.getOfferIcon(s.type)),t("div",{class:"s-offer-card-content"},t("h3",{class:"s-offer-card-title",title:s.title},s.title),s.description&&t("p",{class:"s-offer-card-description"},s.description),t("div",{class:"s-offer-card-details"},s.type===i.DiscountsTable?this.renderDiscountTableOfferContent(s):s.type===i.PercentageOrFixed||s.type===i.Percentage||s.type===i.FixedAmount?[this.renderPercentageOrFixedOfferContent(s),this.renderOfferCategories(s),this.renderOfferBrands(s)]:[this.renderOfferCategories(s),this.renderOfferBrands(s)],this.renderProductsLinkForModalCard(s,!1)))))}getOfferIcon(s){return t("i",{class:{[i.DiscountsTable]:"sicon-discount-calculator",[i.Bank]:"sicon-bank",[i.SpecialPrice]:"sicon-fire",[i.BuyXGetY]:"sicon-gift",[i.PercentageOrFixed]:"sicon-special-discount",[i.Percentage]:"sicon-special-discount",[i.FixedAmount]:"sicon-special-discount"}[s]||"sicon-discount"})}renderDiscountTableOfferContent(s){const e=s.details.discounts||[];return e.length?t("div",null,t("div",{class:"s-offer-card-description"},salla.lang.get("pages.offer.discount_table_subtitle","وفر اكتر بشراء منتجات أكثر")),t("table",{class:"s-offer-discount-table"},t("tbody",null,this.groupDiscountsByRows(e,3).map(((s,e)=>t("tr",{key:e},s.map(((s,e)=>t("td",{key:e},t("div",{class:"s-offer-discount-percentage"},s.percentage,"%"),t("div",{class:"s-offer-discount-condition"},this.formatDiscountCondition(s))))))))))):null}renderPercentageOrFixedOfferContent(s){const e=s.details;return e.discount_value||e.min_spend>0||e.min_items>0?t("div",{class:"s-offer-percentage-fixed-content"},e.min_spend>0&&t("div",{class:"s-offer-min-spend"},this.min_spend_text(e.min_spend,this.userCurrency?.symbol||"")),e.min_items>0&&t("div",{class:"s-offer-min-items"},this.min_items_text(e.min_items))):null}groupDiscountsByRows(s,t){const e=[];for(let o=0;o<s.length;o+=t)e.push(s.slice(o,o+t));return e}formatDiscountCondition(s){return s.discounted_amount?`${s.discounted_amount} ${this.userCurrency?.symbol||""}`:null!=s.quantity?this.buy_quantity_text(s.quantity):`1 ${this.product_text}`}renderOfferCategories(s){const e=s.details;let o=e.categories||[];if(s.type===i.BuyXGetY&&e.get?.categories&&(o=e.get.categories),!o.length)return null;const r=this.expandedCategories[s.id],a=o.length>3,l=r?o:o.slice(0,3);return t("div",{class:"s-offer-categories"},t("div",{class:"s-offer-categories-list"},l.map(((s,e)=>t("a",{key:e,class:"s-offer-category-item",href:s.url||salla.url.create("categories",s.id||s.id_)},s.name))),a&&t("span",{class:"s-offer-categories-toggle",onClick:t=>{t.preventDefault(),t.stopPropagation(),this.toggleCategoryExpansion(s.id)}},r?t("span",null,t("i",{class:"sicon-keyboard_arrow_up"})," ",salla.lang.get("common.elements.hide","إخفاء")):t("span",null,salla.lang.get("common.elements.show","عرض")," ","+"+(o.length-3)," ",t("i",{class:"sicon-keyboard_arrow_down"})))))}renderOfferBrands(s){const e=s.details.brands||[];if(!e.length)return null;const o=this.expandedCategories[s.id],i=e.length>3,r=o?e:e.slice(0,3);return t("div",{class:"s-offer-categories"},t("div",{class:"s-offer-categories-list"},r.map(((s,e)=>t("a",{key:e,class:"s-offer-category-item",href:s.url},s.name))),i&&t("span",{class:"s-offer-categories-toggle",onClick:t=>{t.preventDefault(),t.stopPropagation(),this.toggleCategoryExpansion(s.id)}},o?t("span",null,t("i",{class:"sicon-keyboard_arrow_up"})," ",salla.lang.get("common.elements.hide","إخفاء")):t("span",null,salla.lang.get("common.elements.show","عرض")," ","+"+(e.length-3)," ",t("i",{class:"sicon-keyboard_arrow_down"})))))}toggleCategoryExpansion(s){this.expandedCategories={...this.expandedCategories,[s]:!this.expandedCategories[s]}}get host(){return e(this)}};r.style=":host .s-drawer-close:where([dir=rtl],[dir=rtl] *){left:0}";export{r as salla_offer}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as s,h as e,H as t}from"./p-eYsXdqjv.js";const c=class{constructor(e){s(this,e),this.type="normal",this.width="100%",this.height="100%"}render(){return e(t,{key:"8f574f21608fb5177c8a5d7e0d84d1c1065e49a4",class:"s-skeleton-wrapper",style:{width:this.width,height:this.height}},e("div",{key:"6c86b14ec10c5ccea8f336ab87fb433c49104149",class:{"s-skeleton-item":!0,"s-skeleton-item-circular":"circle"==this.type}}," "))}};c.style=":host{display:block}";export{c as salla_skeleton}
4
+ import{r as s,h as e,H as t}from"./p-6ZT_-rrT.js";const c=class{constructor(e){s(this,e),this.type="normal",this.width="100%",this.height="100%"}render(){return e(t,{key:"8f574f21608fb5177c8a5d7e0d84d1c1065e49a4",class:"s-skeleton-wrapper",style:{width:this.width,height:this.height}},e("div",{key:"6c86b14ec10c5ccea8f336ab87fb433c49104149",class:{"s-skeleton-item":!0,"s-skeleton-item-circular":"circle"==this.type}}," "))}};c.style=":host{display:block}";export{c as salla_skeleton}