@salla.sa/twilight-components 2.14.518 → 2.14.519

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 (329) hide show
  1. package/dist/cjs/{filepond-9vuLCcek.js → filepond-grdxPADi.js} +1 -1
  2. package/dist/cjs/{filepond-plugin-file-poster-CEj7iH7g.js → filepond-plugin-file-poster-C7tZqOSx.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-validate-size-CyiZTXc-.js → filepond-plugin-file-validate-size-DNi0XRBm.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-type-DeJCL4Yd.js → filepond-plugin-file-validate-type-kEnQ70ry.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-image-edit-B1x3Y_zU.js → filepond-plugin-image-edit-Chsaae3B.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-exif-orientation-BJaXZ40E.js → filepond-plugin-image-exif-orientation-B2pjelL2.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-preview-Di3BZCqQ.js → filepond-plugin-image-preview-8lFNetuF.js} +1 -1
  8. package/dist/cjs/{functions-DMnGNEY0.js → functions-OwcMLDeG.js} +1 -1
  9. package/dist/cjs/{index-BlM04jZj.js → index-ChyTlrBD.js} +2 -2
  10. package/dist/cjs/{index-DpgcSE84.js → index-DbAu7DoU.js} +1 -1
  11. package/dist/cjs/loader.cjs.js +1 -1
  12. package/dist/cjs/salla-accordion-body_2.cjs.entry.js +1 -1
  13. package/dist/cjs/salla-accordion_6.cjs.entry.js +1 -1
  14. package/dist/cjs/salla-add-product-button_5.cjs.entry.js +1 -1
  15. package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
  16. package/dist/cjs/salla-alert_2.cjs.entry.js +1 -1
  17. package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
  18. package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
  19. package/dist/cjs/salla-badge.cjs.entry.js +1 -1
  20. package/dist/cjs/salla-basket-gap.cjs.entry.js +1 -1
  21. package/dist/cjs/salla-booking-field_7.cjs.entry.js +10 -10
  22. package/dist/cjs/salla-bullet-delivery_2.cjs.entry.js +1 -1
  23. package/dist/cjs/salla-cart-coupons.cjs.entry.js +1 -1
  24. package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +1 -1
  25. package/dist/cjs/salla-cart-summary-card.cjs.entry.js +1 -1
  26. package/dist/cjs/salla-cashback-banner.cjs.entry.js +1 -1
  27. package/dist/cjs/salla-comment-factors.cjs.entry.js +1 -1
  28. package/dist/cjs/salla-comment-form_8.cjs.entry.js +1 -1
  29. package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
  30. package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
  31. package/dist/cjs/salla-cookies-bar.cjs.entry.js +1 -1
  32. package/dist/cjs/salla-count-down_2.cjs.entry.js +1 -1
  33. package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
  34. package/dist/cjs/salla-delivery-promise.cjs.entry.js +1 -1
  35. package/dist/cjs/salla-edit-order-button.cjs.entry.js +1 -1
  36. package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
  37. package/dist/cjs/salla-filters.cjs.entry.js +1 -1
  38. package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +1 -1
  39. package/dist/cjs/salla-gifting.cjs.entry.js +1 -1
  40. package/dist/cjs/salla-hook.cjs.entry.js +1 -1
  41. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
  42. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  43. package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
  44. package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
  45. package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
  46. package/dist/cjs/salla-loyalty-banner.cjs.entry.js +2 -2
  47. package/dist/cjs/salla-loyalty-exchange-product-card_5.cjs.entry.js +3 -3
  48. package/dist/cjs/salla-loyalty-hero_2.cjs.entry.js +2 -2
  49. package/dist/cjs/salla-loyalty-panel.cjs.entry.js +3 -3
  50. package/dist/cjs/salla-loyalty-points-banner.cjs.entry.js +1 -1
  51. package/dist/cjs/salla-loyalty-points-history.cjs.entry.js +1 -1
  52. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
  53. package/dist/cjs/salla-loyalty-program.cjs.entry.js +3 -3
  54. package/dist/cjs/salla-loyalty-reward.cjs.entry.js +2 -2
  55. package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
  56. package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
  57. package/dist/cjs/salla-map_2.cjs.entry.js +1 -1
  58. package/dist/cjs/salla-menu.cjs.entry.js +1 -1
  59. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  60. package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
  61. package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
  62. package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
  63. package/dist/cjs/salla-next-order-coupon.cjs.entry.js +1 -1
  64. package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
  65. package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
  66. package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
  67. package/dist/cjs/salla-offer.cjs.entry.js +1 -1
  68. package/dist/cjs/salla-order-branch.cjs.entry.js +1 -1
  69. package/dist/cjs/salla-order-cancel.cjs.entry.js +1 -1
  70. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
  71. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  72. package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
  73. package/dist/cjs/salla-order-edit-item.cjs.entry.js +1 -1
  74. package/dist/cjs/salla-order-edit-product-card.cjs.entry.js +1 -1
  75. package/dist/cjs/salla-order-edit.cjs.entry.js +1 -1
  76. package/dist/cjs/salla-order-shipments.cjs.entry.js +1 -1
  77. package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
  78. package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
  79. package/dist/cjs/salla-orders.cjs.entry.js +1 -1
  80. package/dist/cjs/salla-payments.cjs.entry.js +1 -1
  81. package/dist/cjs/salla-placeholder.cjs.entry.js +1 -1
  82. package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
  83. package/dist/cjs/salla-product-card-embed.cjs.entry.js +1 -1
  84. package/dist/cjs/salla-product-card_2.cjs.entry.js +1 -1
  85. package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
  86. package/dist/cjs/salla-products-list.cjs.entry.js +1 -1
  87. package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
  88. package/dist/cjs/salla-rating-modal-v2.cjs.entry.js +1 -1
  89. package/dist/cjs/salla-rating-modal.cjs.entry.js +1 -1
  90. package/dist/cjs/salla-review-factors-tags.cjs.entry.js +1 -1
  91. package/dist/cjs/salla-scopes.cjs.entry.js +1 -1
  92. package/dist/cjs/salla-search.cjs.entry.js +1 -1
  93. package/dist/cjs/salla-skeleton.cjs.entry.js +1 -1
  94. package/dist/cjs/salla-slider.cjs.entry.js +1 -1
  95. package/dist/cjs/salla-social-share.cjs.entry.js +1 -1
  96. package/dist/cjs/salla-social.cjs.entry.js +1 -1
  97. package/dist/cjs/salla-tab-content_3.cjs.entry.js +1 -1
  98. package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
  99. package/dist/cjs/salla-tooltip.cjs.entry.js +1 -1
  100. package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
  101. package/dist/cjs/salla-user-menu.cjs.entry.js +1 -1
  102. package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
  103. package/dist/cjs/salla-user-settings.cjs.entry.js +1 -1
  104. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  105. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  106. package/dist/cjs/salla-wishlist-actions.cjs.entry.js +1 -1
  107. package/dist/cjs/{tracked-promise-Dzrn1HHw.js → tracked-promise-reejw0LE.js} +1 -1
  108. package/dist/cjs/twilight.cjs.js +1 -1
  109. package/dist/cjs/{vanilla-picker-DxM-y1YM.js → vanilla-picker-QVVFqisl.js} +1 -1
  110. package/dist/components/index.js +2 -2
  111. package/dist/esm/{filepond-DFcndQrC.js → filepond-CWJ6O9os.js} +1 -1
  112. package/dist/esm/{filepond-plugin-file-poster-D_PB-IZU.js → filepond-plugin-file-poster-OCSeKguT.js} +1 -1
  113. package/dist/esm/{filepond-plugin-file-validate-size-BDNeMPPZ.js → filepond-plugin-file-validate-size-DRTAEs79.js} +1 -1
  114. package/dist/esm/{filepond-plugin-file-validate-type-BVlfa6XH.js → filepond-plugin-file-validate-type-BSqbfVxk.js} +1 -1
  115. package/dist/esm/{filepond-plugin-image-edit-B4N_DIO8.js → filepond-plugin-image-edit-0wlcB2GA.js} +1 -1
  116. package/dist/esm/{filepond-plugin-image-exif-orientation-DltZqUg4.js → filepond-plugin-image-exif-orientation-CguYd9S5.js} +1 -1
  117. package/dist/esm/{filepond-plugin-image-preview-BaTVWxTU.js → filepond-plugin-image-preview-Btr_uH7E.js} +1 -1
  118. package/dist/esm/{functions-Bs_j7WYO.js → functions-BP3rRd_d.js} +1 -1
  119. package/dist/esm/{index-C2RHZyoj.js → index-CcbWxP-e.js} +2 -2
  120. package/dist/esm/{index-CDmdUxH2.js → index-ZJTtsd6Y.js} +1 -1
  121. package/dist/esm/loader.js +2 -2
  122. package/dist/esm/salla-accordion-body_2.entry.js +1 -1
  123. package/dist/esm/salla-accordion_6.entry.js +1 -1
  124. package/dist/esm/salla-add-product-button_5.entry.js +1 -1
  125. package/dist/esm/salla-advertisement.entry.js +1 -1
  126. package/dist/esm/salla-alert_2.entry.js +1 -1
  127. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  128. package/dist/esm/salla-apps-icons.entry.js +1 -1
  129. package/dist/esm/salla-badge.entry.js +1 -1
  130. package/dist/esm/salla-basket-gap.entry.js +1 -1
  131. package/dist/esm/salla-booking-field_7.entry.js +10 -10
  132. package/dist/esm/salla-bullet-delivery_2.entry.js +1 -1
  133. package/dist/esm/salla-cart-coupons.entry.js +1 -1
  134. package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
  135. package/dist/esm/salla-cart-summary-card.entry.js +1 -1
  136. package/dist/esm/salla-cashback-banner.entry.js +1 -1
  137. package/dist/esm/salla-comment-factors.entry.js +1 -1
  138. package/dist/esm/salla-comment-form_8.entry.js +1 -1
  139. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  140. package/dist/esm/salla-contacts.entry.js +1 -1
  141. package/dist/esm/salla-cookies-bar.entry.js +1 -1
  142. package/dist/esm/salla-count-down_2.entry.js +1 -1
  143. package/dist/esm/salla-custom-fields.entry.js +1 -1
  144. package/dist/esm/salla-delivery-promise.entry.js +1 -1
  145. package/dist/esm/salla-edit-order-button.entry.js +1 -1
  146. package/dist/esm/salla-filters-widget.entry.js +1 -1
  147. package/dist/esm/salla-filters.entry.js +1 -1
  148. package/dist/esm/salla-fulfillment-methods.entry.js +1 -1
  149. package/dist/esm/salla-gifting.entry.js +1 -1
  150. package/dist/esm/salla-hook.entry.js +1 -1
  151. package/dist/esm/salla-infinite-scroll.entry.js +1 -1
  152. package/dist/esm/salla-installment.entry.js +1 -1
  153. package/dist/esm/salla-list-tile.entry.js +1 -1
  154. package/dist/esm/salla-localization-modal.entry.js +1 -1
  155. package/dist/esm/salla-login-modal.entry.js +1 -1
  156. package/dist/esm/salla-loyalty-banner.entry.js +2 -2
  157. package/dist/esm/salla-loyalty-exchange-product-card_5.entry.js +3 -3
  158. package/dist/esm/salla-loyalty-hero_2.entry.js +2 -2
  159. package/dist/esm/salla-loyalty-panel.entry.js +3 -3
  160. package/dist/esm/salla-loyalty-points-banner.entry.js +1 -1
  161. package/dist/esm/salla-loyalty-points-history.entry.js +1 -1
  162. package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
  163. package/dist/esm/salla-loyalty-program.entry.js +3 -3
  164. package/dist/esm/salla-loyalty-reward.entry.js +2 -2
  165. package/dist/esm/salla-loyalty.entry.js +1 -1
  166. package/dist/esm/salla-maintenance-alert.entry.js +1 -1
  167. package/dist/esm/salla-map_2.entry.js +1 -1
  168. package/dist/esm/salla-menu.entry.js +1 -1
  169. package/dist/esm/salla-metadata.entry.js +1 -1
  170. package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
  171. package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
  172. package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
  173. package/dist/esm/salla-next-order-coupon.entry.js +1 -1
  174. package/dist/esm/salla-notification-item.entry.js +1 -1
  175. package/dist/esm/salla-notifications.entry.js +1 -1
  176. package/dist/esm/salla-offer-modal.entry.js +1 -1
  177. package/dist/esm/salla-offer.entry.js +1 -1
  178. package/dist/esm/salla-order-branch.entry.js +1 -1
  179. package/dist/esm/salla-order-cancel.entry.js +1 -1
  180. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  181. package/dist/esm/salla-order-details-options.entry.js +1 -1
  182. package/dist/esm/salla-order-details.entry.js +1 -1
  183. package/dist/esm/salla-order-edit-item.entry.js +1 -1
  184. package/dist/esm/salla-order-edit-product-card.entry.js +1 -1
  185. package/dist/esm/salla-order-edit.entry.js +1 -1
  186. package/dist/esm/salla-order-shipments.entry.js +1 -1
  187. package/dist/esm/salla-order-summary.entry.js +1 -1
  188. package/dist/esm/salla-order-totals-card.entry.js +1 -1
  189. package/dist/esm/salla-orders.entry.js +1 -1
  190. package/dist/esm/salla-payments.entry.js +1 -1
  191. package/dist/esm/salla-placeholder.entry.js +1 -1
  192. package/dist/esm/salla-price-range.entry.js +1 -1
  193. package/dist/esm/salla-product-card-embed.entry.js +1 -1
  194. package/dist/esm/salla-product-card_2.entry.js +1 -1
  195. package/dist/esm/salla-product-size-guide.entry.js +1 -1
  196. package/dist/esm/salla-products-list.entry.js +1 -1
  197. package/dist/esm/salla-quick-order.entry.js +1 -1
  198. package/dist/esm/salla-rating-modal-v2.entry.js +1 -1
  199. package/dist/esm/salla-rating-modal.entry.js +1 -1
  200. package/dist/esm/salla-review-factors-tags.entry.js +1 -1
  201. package/dist/esm/salla-scopes.entry.js +1 -1
  202. package/dist/esm/salla-search.entry.js +1 -1
  203. package/dist/esm/salla-skeleton.entry.js +1 -1
  204. package/dist/esm/salla-slider.entry.js +1 -1
  205. package/dist/esm/salla-social-share.entry.js +1 -1
  206. package/dist/esm/salla-social.entry.js +1 -1
  207. package/dist/esm/salla-tab-content_3.entry.js +1 -1
  208. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  209. package/dist/esm/salla-tooltip.entry.js +1 -1
  210. package/dist/esm/salla-trust-badges.entry.js +1 -1
  211. package/dist/esm/salla-user-menu.entry.js +1 -1
  212. package/dist/esm/salla-user-profile.entry.js +1 -1
  213. package/dist/esm/salla-user-settings.entry.js +1 -1
  214. package/dist/esm/salla-verify.entry.js +1 -1
  215. package/dist/esm/salla-wallet.entry.js +1 -1
  216. package/dist/esm/salla-wishlist-actions.entry.js +1 -1
  217. package/dist/esm/{tracked-promise-Bac1d5rP.js → tracked-promise-BzFzvxTX.js} +1 -1
  218. package/dist/esm/twilight.js +2 -2
  219. package/dist/esm/{vanilla-picker-DkDn1mCy.js → vanilla-picker-0mAMe32b.js} +1 -1
  220. package/dist/twilight/{p-fcfa3759.entry.js → p-01fd7b56.entry.js} +1 -1
  221. package/dist/twilight/{p-d70dcd98.entry.js → p-0b130c59.entry.js} +1 -1
  222. package/dist/twilight/{p-19da2b5f.entry.js → p-0ced5ad7.entry.js} +1 -1
  223. package/dist/twilight/{p-a0e1c93b.entry.js → p-10d3b653.entry.js} +1 -1
  224. package/dist/twilight/{p-38daf7e5.entry.js → p-1510ebf1.entry.js} +1 -1
  225. package/dist/twilight/{p-d0e105b6.entry.js → p-1694fbaf.entry.js} +1 -1
  226. package/dist/twilight/{p-a23e9a84.entry.js → p-1750749a.entry.js} +1 -1
  227. package/dist/twilight/{p-BajcFLeO.js → p-18Fzo9o1.js} +1 -1
  228. package/dist/twilight/{p-413ed3a8.entry.js → p-1cfeb5d1.entry.js} +1 -1
  229. package/dist/twilight/{p-52e08fdf.entry.js → p-1fc23c39.entry.js} +1 -1
  230. package/dist/twilight/{p-f1aee1ed.entry.js → p-1fd46adb.entry.js} +1 -1
  231. package/dist/twilight/{p-6efbd4c4.entry.js → p-20b54ef9.entry.js} +1 -1
  232. package/dist/twilight/{p-6e50105e.entry.js → p-22f4729e.entry.js} +1 -1
  233. package/dist/twilight/{p-b9ca0260.entry.js → p-26be0f87.entry.js} +1 -1
  234. package/dist/twilight/{p-1dc1808d.entry.js → p-2864c9e4.entry.js} +1 -1
  235. package/dist/twilight/{p-bdc4cf8a.entry.js → p-28d13418.entry.js} +1 -1
  236. package/dist/twilight/{p-f6964426.entry.js → p-2c85977d.entry.js} +1 -1
  237. package/dist/twilight/{p-8a4ca0ae.entry.js → p-2ebb0b3f.entry.js} +1 -1
  238. package/dist/twilight/{p-850ee472.entry.js → p-30880b89.entry.js} +1 -1
  239. package/dist/twilight/{p-79b8068e.entry.js → p-31112636.entry.js} +1 -1
  240. package/dist/twilight/{p-4f1b21ae.entry.js → p-3283dd03.entry.js} +1 -1
  241. package/dist/twilight/{p-b09b6eac.entry.js → p-34d91ea2.entry.js} +1 -1
  242. package/dist/twilight/{p-bf8dc054.entry.js → p-362bcfa8.entry.js} +1 -1
  243. package/dist/twilight/{p-5516c00f.entry.js → p-39b9862e.entry.js} +1 -1
  244. package/dist/twilight/{p-beb10a19.entry.js → p-3b450ea6.entry.js} +1 -1
  245. package/dist/twilight/{p-0f46096a.entry.js → p-41d685b2.entry.js} +1 -1
  246. package/dist/twilight/{p-2461d714.entry.js → p-42e42ca7.entry.js} +1 -1
  247. package/dist/twilight/{p-2c562480.entry.js → p-43a75783.entry.js} +1 -1
  248. package/dist/twilight/{p-0c0b0f17.entry.js → p-49c0da0c.entry.js} +1 -1
  249. package/dist/twilight/{p-Bq836xP-.js → p-4Nsd7RFj.js} +1 -1
  250. package/dist/twilight/{p-73b94072.entry.js → p-4ae977b2.entry.js} +1 -1
  251. package/dist/twilight/{p-d7292a7d.entry.js → p-4b3533c6.entry.js} +1 -1
  252. package/dist/twilight/{p-6adfa24a.entry.js → p-4f69bee0.entry.js} +1 -1
  253. package/dist/twilight/{p-ffb7f5e3.entry.js → p-51ed3ac0.entry.js} +1 -1
  254. package/dist/twilight/{p-d4f95050.entry.js → p-522e17cc.entry.js} +1 -1
  255. package/dist/twilight/{p-d6595f08.entry.js → p-5343715c.entry.js} +1 -1
  256. package/dist/twilight/{p-899202da.entry.js → p-53d13f8e.entry.js} +1 -1
  257. package/dist/twilight/{p-6383c0c9.entry.js → p-55b2c1d5.entry.js} +1 -1
  258. package/dist/twilight/{p-e7ce766b.entry.js → p-5a974d31.entry.js} +1 -1
  259. package/dist/twilight/{p-abaac4b2.entry.js → p-5c67a2a6.entry.js} +1 -1
  260. package/dist/twilight/{p-5ffe3f2d.entry.js → p-6925f40c.entry.js} +1 -1
  261. package/dist/twilight/{p-fb79c232.entry.js → p-70f03670.entry.js} +1 -1
  262. package/dist/twilight/{p-1a35503d.entry.js → p-71b011ec.entry.js} +1 -1
  263. package/dist/twilight/{p-e707b1b3.entry.js → p-797afedc.entry.js} +1 -1
  264. package/dist/twilight/{p-816fa850.entry.js → p-7a3ba493.entry.js} +1 -1
  265. package/dist/twilight/{p-ca767303.entry.js → p-804cca75.entry.js} +1 -1
  266. package/dist/twilight/{p-85bf6531.entry.js → p-80798554.entry.js} +1 -1
  267. package/dist/twilight/{p-e9d45abb.entry.js → p-84141087.entry.js} +1 -1
  268. package/dist/twilight/{p-0562b11a.entry.js → p-87ce9c5e.entry.js} +1 -1
  269. package/dist/twilight/{p-eb1f64cd.entry.js → p-8939747c.entry.js} +1 -1
  270. package/dist/twilight/{p-07172f87.entry.js → p-89c9b870.entry.js} +1 -1
  271. package/dist/twilight/{p-170b0b20.entry.js → p-89f17e06.entry.js} +1 -1
  272. package/dist/twilight/{p-affa8fba.entry.js → p-8a093d83.entry.js} +1 -1
  273. package/dist/twilight/{p-9248fdf2.entry.js → p-8af93055.entry.js} +1 -1
  274. package/dist/twilight/{p-17f6d5e9.entry.js → p-94404a40.entry.js} +1 -1
  275. package/dist/twilight/{p-d3f1c168.entry.js → p-96007143.entry.js} +1 -1
  276. package/dist/twilight/{p-e5a53d38.entry.js → p-966f9328.entry.js} +1 -1
  277. package/dist/twilight/{p-35ec17e1.entry.js → p-99f37d59.entry.js} +1 -1
  278. package/dist/twilight/{p-7b774173.entry.js → p-9c54c52c.entry.js} +1 -1
  279. package/dist/twilight/{p-IiKvzpNh.js → p-BiGKmK4Q.js} +1 -1
  280. package/dist/twilight/{p-QQHVhk5Y.js → p-Bxe6p8M5.js} +1 -1
  281. package/dist/twilight/p-C0QyCxRz.js +4 -0
  282. package/dist/twilight/{p-C2RHZyoj.js → p-CcbWxP-e.js} +1 -1
  283. package/dist/twilight/{p-D3223Swj.js → p-CzDOsWjJ.js} +1 -1
  284. package/dist/twilight/{p-8pvTyiJe.js → p-D2LTHOFb.js} +1 -1
  285. package/dist/twilight/{p-DP7_3WjR.js → p-DVUa3NxN.js} +1 -1
  286. package/dist/twilight/{p-rMqhG07q.js → p-Dtr3h2nR.js} +1 -1
  287. package/dist/twilight/{p-DPxh47LR.js → p-StF-IMl9.js} +1 -1
  288. package/dist/twilight/{p-25e4db15.entry.js → p-a2fc72d4.entry.js} +1 -1
  289. package/dist/twilight/{p-e6c22a1d.entry.js → p-a49e707c.entry.js} +1 -1
  290. package/dist/twilight/{p-2093e47a.entry.js → p-a51806a5.entry.js} +1 -1
  291. package/dist/twilight/{p-1fbf48e4.entry.js → p-a5494f96.entry.js} +1 -1
  292. package/dist/twilight/{p-edd24a95.entry.js → p-a7204c5d.entry.js} +1 -1
  293. package/dist/twilight/{p-8b673e8d.entry.js → p-a8b4186c.entry.js} +1 -1
  294. package/dist/twilight/{p-f806661c.entry.js → p-ac41ccc7.entry.js} +1 -1
  295. package/dist/twilight/{p-d3341f15.entry.js → p-b02c1726.entry.js} +1 -1
  296. package/dist/twilight/{p-e066ba8a.entry.js → p-b1d35d3e.entry.js} +1 -1
  297. package/dist/twilight/{p-31b4d58b.entry.js → p-b498d865.entry.js} +1 -1
  298. package/dist/twilight/{p-5d90d656.entry.js → p-b5519c93.entry.js} +1 -1
  299. package/dist/twilight/{p-ebadf5db.entry.js → p-c324f437.entry.js} +1 -1
  300. package/dist/twilight/{p-810d4d3c.entry.js → p-c3ff1098.entry.js} +1 -1
  301. package/dist/twilight/{p-7c8f7654.entry.js → p-c5ce4cee.entry.js} +1 -1
  302. package/dist/twilight/{p-1e264b7b.entry.js → p-c8978f6e.entry.js} +1 -1
  303. package/dist/twilight/{p-e7a63e62.entry.js → p-c97fd594.entry.js} +1 -1
  304. package/dist/twilight/{p-d341d13d.entry.js → p-cb477c8a.entry.js} +1 -1
  305. package/dist/twilight/{p-93f3e882.entry.js → p-ce9f36a2.entry.js} +1 -1
  306. package/dist/twilight/{p-tywMY7wu.js → p-crHVPCNG.js} +1 -1
  307. package/dist/twilight/{p-bd432397.entry.js → p-d2fd5400.entry.js} +1 -1
  308. package/dist/twilight/{p-f9c442ef.entry.js → p-d41e67ee.entry.js} +1 -1
  309. package/dist/twilight/{p-75f96daa.entry.js → p-d43438ea.entry.js} +1 -1
  310. package/dist/twilight/{p-8ac8ae79.entry.js → p-d48afadb.entry.js} +1 -1
  311. package/dist/twilight/{p-fe686d0e.entry.js → p-d5c5c9b8.entry.js} +1 -1
  312. package/dist/twilight/{p-e0a7907c.entry.js → p-d5e536da.entry.js} +1 -1
  313. package/dist/twilight/{p-4f40c588.entry.js → p-d834f96e.entry.js} +1 -1
  314. package/dist/twilight/{p-365bc069.entry.js → p-de6cec69.entry.js} +1 -1
  315. package/dist/twilight/{p-767d8982.entry.js → p-e0c34fae.entry.js} +1 -1
  316. package/dist/twilight/{p-0bf8b901.entry.js → p-e28a2242.entry.js} +1 -1
  317. package/dist/twilight/{p-27c7a2c9.entry.js → p-e2b14ff6.entry.js} +1 -1
  318. package/dist/twilight/{p-6106b77f.entry.js → p-e59e5b7f.entry.js} +1 -1
  319. package/dist/twilight/{p-14e4d573.entry.js → p-e814251c.entry.js} +1 -1
  320. package/dist/twilight/{p-c410c308.entry.js → p-e95975d1.entry.js} +1 -1
  321. package/dist/twilight/{p-5ccf3db9.entry.js → p-ea0dd06f.entry.js} +1 -1
  322. package/dist/twilight/{p-709e6928.entry.js → p-eb2b6e3e.entry.js} +1 -1
  323. package/dist/twilight/{p-828d9df1.entry.js → p-f5682f90.entry.js} +1 -1
  324. package/dist/twilight/{p-2c7ecbda.entry.js → p-f615e7cb.entry.js} +1 -1
  325. package/dist/twilight/{p-dc62af21.entry.js → p-f808301e.entry.js} +1 -1
  326. package/dist/twilight/{p-7f4d38c3.entry.js → p-fe59f4c1.entry.js} +1 -1
  327. package/dist/twilight/twilight.esm.js +1 -1
  328. package/package.json +5 -5
  329. package/dist/twilight/p-CAX4v4uY.js +0 -4
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{h as a,r as l}from"./p-C2RHZyoj.js";import{n as t,c as s}from"./p-tywMY7wu.js";import{S as r}from"./p-D4oPi1Ov.js";import{S as i}from"./p-8Tsmrwno.js";import{S as e,a as o}from"./p-Bs6JxDkg.js";import{S as d}from"./p-CZRcMGA9.js";import{S as n}from"./p-D1s2kXqL.js";import{T as p}from"./p-CAX4v4uY.js";var c=function(a,l,t,s){var r,i=arguments.length,e=i<3?l:null===s?s=Object.getOwnPropertyDescriptor(l,t):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)e=Reflect.decorate(a,l,t,s);else for(var o=a.length-1;o>=0;o--)(r=a[o])&&(e=(i<3?r(e):i>3?r(l,t,e):r(l,t))||e);return i>3&&e&&Object.defineProperty(l,t,e),e};const h={all:a("span",{class:"s-loyalty-program-rewards-tab-icon",innerHTML:o}),free_shipping:a("span",{class:"s-loyalty-program-rewards-tab-icon",innerHTML:d}),coupon_discount:a("span",{class:"s-loyalty-program-rewards-tab-icon",innerHTML:e}),free_product:a("span",{class:"s-loyalty-program-rewards-tab-icon",innerHTML:n})},m=class{constructor(a){l(this,a),this.currentPrize=null,this.currentProductId=null,this.handleExchangeSucceeded=()=>window.location.reload(),this.handleResetSucceeded=()=>window.location.reload()}componentWillLoad(){return salla.onReady().then((()=>salla.lang.onLoaded())).then((()=>{salla.event.on("loyalty::exchange.succeeded",this.handleExchangeSucceeded),salla.event.on("loyalty::exchange-reset.succeeded",this.handleResetSucceeded),salla.config.isGuest()||this.points()})).catch((a=>salla.logger.error(a)))}disconnectedCallback(){salla.event.off("loyalty::exchange.succeeded",this.handleExchangeSucceeded),salla.event.off("loyalty::exchange-reset.succeeded",this.handleResetSucceeded)}render(){const l=this.program.data.prizes,t=this.program.data.prizes_count,e=this.points.data??this.customerPoints??0;return this.prizeTitle&&null!=this.prizePoints&&""!==this.prizePoints?a("div",{class:"s-loyalty-program-panel-exchange-wrapper"},a("salla-list-tile",{class:"s-loyalty-program-after-exchange"},a("div",{slot:"title",class:"s-loyalty-program-after-exchange-title"},this.prizeTitle,"   -   ",this.prizePoints," ",salla.lang.get("pages.loyalty_program.point")),a("div",{slot:"action",class:"s-loyalty-program-after-exchange-action"},a("salla-button",{class:"s-loyalty-program-after-exchange-reset",shape:"icon",fill:"outline",color:"danger",size:"small",onClick:()=>salla.loyalty.reset()},a("span",{innerHTML:i}))))):e&&0!==e?a("div",{class:""},a("div",{class:"s-loyalty-program-panel-exchange-wrapper"},a("salla-list-tile",{class:"s-loyalty-program-panel-widget"},a("div",{slot:"icon",class:"s-loyalty-program-panel-widget-icon",innerHTML:r}),a("div",{slot:"subtitle"},salla.lang.get("pages.loyalty_program.cart_total_point_summary",{balance:e}),a("salla-button",{shape:"link",color:"primary",onClick:()=>{["error","idle"].includes(this.program.status)&&this.program(),this.rewardsModal.open()}},salla.lang.get("pages.loyalty_program.cart_point_exchange_now"))))),a("salla-modal",{id:"loyalty-rewards-modal",isLoading:"pending"===this.program.status,ref:a=>this.rewardsModal=a,class:"s-loyalty-program-rewards-cart s-loyalty-program-modal",width:"lg",noPadding:!0},a("div",{slot:"loading"},a("salla-loading",null)),"success"===this.program.status?a("div",{class:"s-loyalty-program-rewards-container-cart"},a("div",{class:"s-loyalty-program-rewards-cart-header"},a("div",{innerHTML:'<svg xmlns="http://www.w3.org/2000/svg" width="77" height="77" fill="none" viewBox="0 0 57 57"><rect width="56.3" height="55.9" x=".4" y=".2" fill="#FFF5E5" rx="27.9"/><g clip-path="url(#a)"><path fill="#EE9D0D" d="M16.7 27.5h17.5v12.2a1 1 0 0 1-1 1H17.7a1 1 0 0 1-1-1V27.5Z"/><path fill="#C7830B" d="M34.2 27.8v6l-6.8-6.3H34l.3.3Z"/><path fill="#C7830B" d="M34.2 32.3v1.5l-1.6-1.5h1.6Z"/><path fill="#EA2B2D" d="m29.9 15.8-.3.1a2.4 2.4 0 0 0-1.4 1.5l-.2.8-.4.2a2.4 2.4 0 0 0-1.1 1.4l4.2 3.9L33 21l.2-2.9a2.4 2.4 0 0 0-3.3-2.4ZM41.1 26.3v.2a2.4 2.4 0 0 1-1.5 1.6l-.7.3-.2.3a2.4 2.4 0 0 1-1.3 1.3l-4.2-4 2.4-2.5 2.9-.3a2.4 2.4 0 0 1 2.6 3.1Z"/><path fill="#CB2527" d="M23.7 27.5h3.5v13.1h-3.5V27.5Z"/><path fill="#EA2B2D" d="M16.7 32.3h17.5v3.5H16.7v-3.5Z"/><path fill="#CB2527" d="M34.2 32.3v1.5l-1.6-1.5h1.6Z"/><path fill="#EE9D0D" d="M25.3 18.7 38.6 31a1 1 0 0 1 0 1.4l-2.3 2.4-14.7-13.7 2.3-2.5a1 1 0 0 1 1.4 0Z"/><path fill="#CB2527" d="m30.3 23.4 3.2 3-3 3.2-3.2-3 3-3.2ZM31.8 22.8a.4.4 0 0 1-.3-.1l-.3-.4A5.9 5.9 0 0 1 30 18a.4.4 0 0 1 .9 0 5 5 0 0 0 1 3.7l.3.3a.4.4 0 0 1-.4.7Z"/><path fill="#EA2B2D" d="M30.7 23.7c-1.9.7-3.8 1-5.7.9h-1.1l1.9 1.7-.6 1.9 1.8-.6c1.7-.5 3.2-1.4 4.6-2.5l.3-.2-1.2-1.2Z"/><path fill="#CB2527" d="M37.8 26.4c-1.1 0-2.3-.3-3.2-1l-.4-.2a.4.4 0 0 1 0-.8.4.4 0 0 1 .5 0l.3.3a5 5 0 0 0 3.7.7.4.4 0 1 1 .2 1 6 6 0 0 1-1 0Z"/><path fill="#EA2B2D" d="M33.2 26c-.5 2-.7 3.9-.5 5.8l.1 1.1-1.9-1.8-1.8.7.4-1.8c.4-1.7 1.2-3.3 2.2-4.8l.2-.3 1.3 1.2Z"/><path fill="#6699CE" d="M21.5 17.4a.9.9 0 1 0 0-1.7.9.9 0 0 0 0 1.7Z"/><path fill="#FAA6B2" d="M16.7 27.5a.9.9 0 1 0 0-1.8.9.9 0 0 0 0 1.8Z"/><path fill="#A6DEFF" d="M18.4 17.9a.4.4 0 0 1-.4-.3v-.1a1.4 1.4 0 0 0-1.3-1 .4.4 0 0 1-.2-.8h.2a2.3 2.3 0 0 1 2.1 1.5.4.4 0 0 1-.4.7ZM20.6 25.6h-.2v-.1a1 1 0 0 0-1.1 0 .4.4 0 0 1-.5-.8 1.8 1.8 0 0 1 2 0 .4.4 0 0 1-.2.9Z"/><path fill="#EEB436" d="m17.6 18.6 1.3 1.2 1.8-.4-.7 1.7.9 1.6-1.8-.2-1.2 1.3-.4-1.8-1.7-.7 1.6-.9.2-1.8ZM23 26.6l-.5 1.8 1.2 1.3-1.8.2-1 1.5-.6-1.7-1.8-.4 1.4-1.1-.2-1.9 1.6 1 1.6-.7Z"/><path fill="#F72D2F" d="m33.2 26-2.5-2.3L33 21a4 4 0 0 1 2.6 2.4l-2.4 2.6Z"/></g><defs><clipPath id="a"><path fill="#fff" d="M15.8 15.7h25.4v25H15.8z"/></clipPath></defs></svg>'}),a("div",{class:"s-loyalty-program-panel-content"},a("h1",null,this.program.data.prize_promotion_title),a("p",null,this.program.data.prize_promotion_description))),a("div",{class:{"s-loyalty-program-slider-arrows":!0,"s-loyalty-program-tabs-hider":l.length<2||t<2}},a("salla-tabs",null,l.map((l=>a("salla-tab-header",{slot:"header",name:l.type},h[l.type],a("span",null,l.title)))),l.map((l=>a("salla-tab-content",{slot:"content",name:l.type},a("salla-slider",{id:l.type,type:"default","slider-config":'{"loop":false,"slidesPerView":"auto","freeMode":true,"spaceBetween":12,"breakpoints":{"768":{"slidesPerView":3,"spaceBetween":24,"freeMode":false,"speed":300}}}'},a("div",{slot:"items"},l.items.map((l=>a("salla-reward-card",{prize:l,onAreaClick:()=>{this.currentPrize=l,s((()=>this.detailsModal.open()))},onActionClick:()=>{this.currentPrize=l,s((()=>this.detailsModal.open()))}}))))))))))):""),a("salla-modal",{ref:a=>this.detailsModal=a,class:"s-loyalty-program-modal",width:"md",noPadding:!0},this.currentPrize?a("salla-reward-details",{onActionClick:()=>{this.currentProductId=null,s((()=>this.exchangeModal.open()))},onProductActionClick:a=>{this.currentProductId=a.detail.productId,s((()=>this.exchangeModal.open()))},prize:this.currentPrize}):""),a("salla-modal",{ref:a=>this.exchangeModal=a,class:"s-loyalty-program-modal",width:"sm"},this.currentPrize?a("salla-reward-exchange",{prize:this.currentPrize,productId:this.currentProductId}):"")):null}};c([p((async()=>{const{data:a}=await salla.loyalty.getProgram();return t(a)}),{initialData:{prizes:[],prizes_count:0}})],m.prototype,"program",void 0),c([p((async()=>{const{data:a}=await salla.loyalty.getPoints();return a.points}),{initialData:null})],m.prototype,"points",void 0),m.style="@media (max-width: 639px){.s-loyalty-program-modal .s-modal-body{position:relative !important;left:unset !important;bottom:unset !important;max-height:100dvh;overflow-y:auto !important}}.s-loyalty-exchange-card salla-product-card .s-product-card-image,.s-loyalty-exchange-card custom-salla-product-card .s-product-card-image{flex:none;aspect-ratio:1;overflow:hidden}.s-loyalty-exchange-card-btn{padding:0 1.25rem 1.25rem;margin-top:0.75rem}.s-loyalty-program-reward-details-products-grid{display:flex;flex-wrap:wrap;gap:1rem;margin-top:0.75rem}.s-loyalty-program-reward-details-products-grid>*{flex:1 1 100%;min-width:0;touch-action:pan-y}@media (min-width: 640px){.s-loyalty-program-reward-details-products-grid>*{flex-basis:calc((100% - 1rem) / 2)}}@media (min-width: 768px){.s-loyalty-program-reward-details-products-grid>*{flex-basis:calc((100% - 2rem) / 3)}}.s-loyalty-program-reward-details-products-grid>*:only-child{max-width:320px;margin-inline:auto}.s-loyalty-program-reward-details-products-grid:has(>*:nth-child(3))>*{flex-grow:0}";export{m as salla_loyalty_panel}
4
+ import{h as a,r as l}from"./p-CcbWxP-e.js";import{n as s,c as t}from"./p-crHVPCNG.js";import{S as r}from"./p-D4oPi1Ov.js";import{S as i}from"./p-8Tsmrwno.js";import{S as e,a as o}from"./p-Bs6JxDkg.js";import{S as d}from"./p-CZRcMGA9.js";import{S as n}from"./p-D1s2kXqL.js";import{T as p}from"./p-C0QyCxRz.js";var c=function(a,l,s,t){var r,i=arguments.length,e=i<3?l:null===t?t=Object.getOwnPropertyDescriptor(l,s):t;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)e=Reflect.decorate(a,l,s,t);else for(var o=a.length-1;o>=0;o--)(r=a[o])&&(e=(i<3?r(e):i>3?r(l,s,e):r(l,s))||e);return i>3&&e&&Object.defineProperty(l,s,e),e};const h={all:a("span",{class:"s-loyalty-program-rewards-tab-icon",innerHTML:o}),free_shipping:a("span",{class:"s-loyalty-program-rewards-tab-icon",innerHTML:d}),coupon_discount:a("span",{class:"s-loyalty-program-rewards-tab-icon",innerHTML:e}),free_product:a("span",{class:"s-loyalty-program-rewards-tab-icon",innerHTML:n})},m=class{constructor(a){l(this,a),this.currentPrize=null,this.currentProductId=null,this.handleExchangeSucceeded=()=>window.location.reload(),this.handleResetSucceeded=()=>window.location.reload()}componentWillLoad(){return salla.onReady().then((()=>salla.lang.onLoaded())).then((()=>{salla.event.on("loyalty::exchange.succeeded",this.handleExchangeSucceeded),salla.event.on("loyalty::exchange-reset.succeeded",this.handleResetSucceeded),salla.config.isGuest()||this.points()})).catch((a=>salla.logger.error(a)))}disconnectedCallback(){salla.event.off("loyalty::exchange.succeeded",this.handleExchangeSucceeded),salla.event.off("loyalty::exchange-reset.succeeded",this.handleResetSucceeded)}render(){const l=this.program.data.prizes,s=this.program.data.prizes_count,e=this.points.data??this.customerPoints??0;return this.prizeTitle&&null!=this.prizePoints&&""!==this.prizePoints?a("div",{class:"s-loyalty-program-panel-exchange-wrapper"},a("salla-list-tile",{class:"s-loyalty-program-after-exchange"},a("div",{slot:"title",class:"s-loyalty-program-after-exchange-title"},this.prizeTitle,"   -   ",this.prizePoints," ",salla.lang.get("pages.loyalty_program.point")),a("div",{slot:"action",class:"s-loyalty-program-after-exchange-action"},a("salla-button",{class:"s-loyalty-program-after-exchange-reset",shape:"icon",fill:"outline",color:"danger",size:"small",onClick:()=>salla.loyalty.reset()},a("span",{innerHTML:i}))))):e&&0!==e?a("div",{class:""},a("div",{class:"s-loyalty-program-panel-exchange-wrapper"},a("salla-list-tile",{class:"s-loyalty-program-panel-widget"},a("div",{slot:"icon",class:"s-loyalty-program-panel-widget-icon",innerHTML:r}),a("div",{slot:"subtitle"},salla.lang.get("pages.loyalty_program.cart_total_point_summary",{balance:e}),a("salla-button",{shape:"link",color:"primary",onClick:()=>{["error","idle"].includes(this.program.status)&&this.program(),this.rewardsModal.open()}},salla.lang.get("pages.loyalty_program.cart_point_exchange_now"))))),a("salla-modal",{id:"loyalty-rewards-modal",isLoading:"pending"===this.program.status,ref:a=>this.rewardsModal=a,class:"s-loyalty-program-rewards-cart s-loyalty-program-modal",width:"lg",noPadding:!0},a("div",{slot:"loading"},a("salla-loading",null)),"success"===this.program.status?a("div",{class:"s-loyalty-program-rewards-container-cart"},a("div",{class:"s-loyalty-program-rewards-cart-header"},a("div",{innerHTML:'<svg xmlns="http://www.w3.org/2000/svg" width="77" height="77" fill="none" viewBox="0 0 57 57"><rect width="56.3" height="55.9" x=".4" y=".2" fill="#FFF5E5" rx="27.9"/><g clip-path="url(#a)"><path fill="#EE9D0D" d="M16.7 27.5h17.5v12.2a1 1 0 0 1-1 1H17.7a1 1 0 0 1-1-1V27.5Z"/><path fill="#C7830B" d="M34.2 27.8v6l-6.8-6.3H34l.3.3Z"/><path fill="#C7830B" d="M34.2 32.3v1.5l-1.6-1.5h1.6Z"/><path fill="#EA2B2D" d="m29.9 15.8-.3.1a2.4 2.4 0 0 0-1.4 1.5l-.2.8-.4.2a2.4 2.4 0 0 0-1.1 1.4l4.2 3.9L33 21l.2-2.9a2.4 2.4 0 0 0-3.3-2.4ZM41.1 26.3v.2a2.4 2.4 0 0 1-1.5 1.6l-.7.3-.2.3a2.4 2.4 0 0 1-1.3 1.3l-4.2-4 2.4-2.5 2.9-.3a2.4 2.4 0 0 1 2.6 3.1Z"/><path fill="#CB2527" d="M23.7 27.5h3.5v13.1h-3.5V27.5Z"/><path fill="#EA2B2D" d="M16.7 32.3h17.5v3.5H16.7v-3.5Z"/><path fill="#CB2527" d="M34.2 32.3v1.5l-1.6-1.5h1.6Z"/><path fill="#EE9D0D" d="M25.3 18.7 38.6 31a1 1 0 0 1 0 1.4l-2.3 2.4-14.7-13.7 2.3-2.5a1 1 0 0 1 1.4 0Z"/><path fill="#CB2527" d="m30.3 23.4 3.2 3-3 3.2-3.2-3 3-3.2ZM31.8 22.8a.4.4 0 0 1-.3-.1l-.3-.4A5.9 5.9 0 0 1 30 18a.4.4 0 0 1 .9 0 5 5 0 0 0 1 3.7l.3.3a.4.4 0 0 1-.4.7Z"/><path fill="#EA2B2D" d="M30.7 23.7c-1.9.7-3.8 1-5.7.9h-1.1l1.9 1.7-.6 1.9 1.8-.6c1.7-.5 3.2-1.4 4.6-2.5l.3-.2-1.2-1.2Z"/><path fill="#CB2527" d="M37.8 26.4c-1.1 0-2.3-.3-3.2-1l-.4-.2a.4.4 0 0 1 0-.8.4.4 0 0 1 .5 0l.3.3a5 5 0 0 0 3.7.7.4.4 0 1 1 .2 1 6 6 0 0 1-1 0Z"/><path fill="#EA2B2D" d="M33.2 26c-.5 2-.7 3.9-.5 5.8l.1 1.1-1.9-1.8-1.8.7.4-1.8c.4-1.7 1.2-3.3 2.2-4.8l.2-.3 1.3 1.2Z"/><path fill="#6699CE" d="M21.5 17.4a.9.9 0 1 0 0-1.7.9.9 0 0 0 0 1.7Z"/><path fill="#FAA6B2" d="M16.7 27.5a.9.9 0 1 0 0-1.8.9.9 0 0 0 0 1.8Z"/><path fill="#A6DEFF" d="M18.4 17.9a.4.4 0 0 1-.4-.3v-.1a1.4 1.4 0 0 0-1.3-1 .4.4 0 0 1-.2-.8h.2a2.3 2.3 0 0 1 2.1 1.5.4.4 0 0 1-.4.7ZM20.6 25.6h-.2v-.1a1 1 0 0 0-1.1 0 .4.4 0 0 1-.5-.8 1.8 1.8 0 0 1 2 0 .4.4 0 0 1-.2.9Z"/><path fill="#EEB436" d="m17.6 18.6 1.3 1.2 1.8-.4-.7 1.7.9 1.6-1.8-.2-1.2 1.3-.4-1.8-1.7-.7 1.6-.9.2-1.8ZM23 26.6l-.5 1.8 1.2 1.3-1.8.2-1 1.5-.6-1.7-1.8-.4 1.4-1.1-.2-1.9 1.6 1 1.6-.7Z"/><path fill="#F72D2F" d="m33.2 26-2.5-2.3L33 21a4 4 0 0 1 2.6 2.4l-2.4 2.6Z"/></g><defs><clipPath id="a"><path fill="#fff" d="M15.8 15.7h25.4v25H15.8z"/></clipPath></defs></svg>'}),a("div",{class:"s-loyalty-program-panel-content"},a("h1",null,this.program.data.prize_promotion_title),a("p",null,this.program.data.prize_promotion_description))),a("div",{class:{"s-loyalty-program-slider-arrows":!0,"s-loyalty-program-tabs-hider":l.length<2||s<2}},a("salla-tabs",null,l.map((l=>a("salla-tab-header",{slot:"header",name:l.type},h[l.type],a("span",null,l.title)))),l.map((l=>a("salla-tab-content",{slot:"content",name:l.type},a("salla-slider",{id:l.type,type:"default","slider-config":'{"loop":false,"slidesPerView":"auto","freeMode":true,"spaceBetween":12,"breakpoints":{"768":{"slidesPerView":3,"spaceBetween":24,"freeMode":false,"speed":300}}}'},a("div",{slot:"items"},l.items.map((l=>a("salla-reward-card",{prize:l,onAreaClick:()=>{this.currentPrize=l,t((()=>this.detailsModal.open()))},onActionClick:()=>{this.currentPrize=l,t((()=>this.detailsModal.open()))}}))))))))))):""),a("salla-modal",{ref:a=>this.detailsModal=a,class:"s-loyalty-program-modal",width:"md",noPadding:!0},this.currentPrize?a("salla-reward-details",{onActionClick:()=>{this.currentProductId=null,t((()=>this.exchangeModal.open()))},onProductActionClick:a=>{this.currentProductId=a.detail.productId,t((()=>this.exchangeModal.open()))},prize:this.currentPrize}):""),a("salla-modal",{ref:a=>this.exchangeModal=a,class:"s-loyalty-program-modal",width:"sm"},this.currentPrize?a("salla-reward-exchange",{prize:this.currentPrize,productId:this.currentProductId}):"")):null}};c([p((async()=>{const{data:a}=await salla.loyalty.getProgram();return s(a)}),{initialData:{prizes:[],prizes_count:0}})],m.prototype,"program",void 0),c([p((async()=>{const{data:a}=await salla.loyalty.getPoints();return a.points}),{initialData:null})],m.prototype,"points",void 0),m.style="@media (max-width: 639px){.s-loyalty-program-modal .s-modal-body{position:relative !important;left:unset !important;bottom:unset !important;max-height:100dvh;overflow-y:auto !important}}.s-loyalty-exchange-card salla-product-card .s-product-card-image,.s-loyalty-exchange-card custom-salla-product-card .s-product-card-image{flex:none;aspect-ratio:1;overflow:hidden}.s-loyalty-exchange-card-btn{padding:0 1.25rem 1.25rem;margin-top:0.75rem}.s-loyalty-program-reward-details-products-grid{display:flex;flex-wrap:wrap;gap:1rem;margin-top:0.75rem}.s-loyalty-program-reward-details-products-grid>*{flex:1 1 100%;min-width:0;touch-action:pan-y}@media (min-width: 640px){.s-loyalty-program-reward-details-products-grid>*{flex-basis:calc((100% - 1rem) / 2)}}@media (min-width: 768px){.s-loyalty-program-reward-details-products-grid>*{flex-basis:calc((100% - 2rem) / 3)}}.s-loyalty-program-reward-details-products-grid>*:only-child{max-width:320px;margin-inline:auto}.s-loyalty-program-reward-details-products-grid:has(>*:nth-child(3))>*{flex-grow:0}";export{m as salla_loyalty_panel}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as e,c as t,h as s,H as i,a as l}from"./p-C2RHZyoj.js";import{L as a}from"./p-BO5AoBAP.js";var r={light:[{featureType:"water",elementType:"geometry",stylers:[{color:"#e9e9e9"},{lightness:17}]},{featureType:"landscape",elementType:"geometry",stylers:[{color:"#f5f5f5"},{lightness:20}]},{featureType:"road.highway",elementType:"geometry.fill",stylers:[{color:"#ffffff"},{lightness:17}]},{featureType:"road.highway",elementType:"geometry.stroke",stylers:[{color:"#ffffff"},{lightness:29},{weight:.2}]},{featureType:"road.arterial",elementType:"geometry",stylers:[{color:"#ffffff"},{lightness:18}]},{featureType:"road.local",elementType:"geometry",stylers:[{color:"#ffffff"},{lightness:16}]},{featureType:"poi",elementType:"geometry",stylers:[{color:"#f5f5f5"},{lightness:21}]},{featureType:"poi.park",elementType:"geometry",stylers:[{color:"#dedede"},{lightness:21}]},{elementType:"labels.text.stroke",stylers:[{visibility:"on"},{color:"#ffffff"},{lightness:16}]},{elementType:"labels.text.fill",stylers:[{saturation:36},{color:"#333333"},{lightness:40}]},{elementType:"labels.icon",stylers:[{visibility:"off"}]},{featureType:"transit",elementType:"geometry",stylers:[{color:"#f2f2f2"},{lightness:19}]},{featureType:"administrative",elementType:"geometry.fill",stylers:[{color:"#fefefe"},{lightness:20}]},{featureType:"administrative",elementType:"geometry.stroke",stylers:[{color:"#fefefe"},{lightness:17},{weight:1.2}]}],dark:[{elementType:"geometry",stylers:[{color:"#242f3e"}]},{elementType:"labels.text.fill",stylers:[{color:"#746855"}]},{elementType:"labels.text.stroke",stylers:[{color:"#242f3e"}]},{featureType:"administrative.locality",elementType:"labels.text.fill",stylers:[{color:"#d59563"}]},{featureType:"poi",elementType:"labels.text.fill",stylers:[{color:"#d59563"}]},{featureType:"poi.park",elementType:"geometry",stylers:[{color:"#263c3f"}]},{featureType:"poi.park",elementType:"labels.text.fill",stylers:[{color:"#6b9a76"}]},{featureType:"road",elementType:"geometry",stylers:[{color:"#38414e"}]},{featureType:"road",elementType:"geometry.stroke",stylers:[{color:"#212a37"}]},{featureType:"road",elementType:"labels.text.fill",stylers:[{color:"#9ca5b3"}]},{featureType:"road.highway",elementType:"geometry",stylers:[{color:"#746855"}]},{featureType:"road.highway",elementType:"geometry.stroke",stylers:[{color:"#1f2835"}]},{featureType:"road.highway",elementType:"labels.text.fill",stylers:[{color:"#f3d19c"}]},{featureType:"transit",elementType:"geometry",stylers:[{color:"#2f3948"}]},{featureType:"transit.station",elementType:"labels.text.fill",stylers:[{color:"#d59563"}]},{featureType:"water",elementType:"geometry",stylers:[{color:"#17263c"}]},{featureType:"water",elementType:"labels.text.fill",stylers:[{color:"#515c6d"}]},{featureType:"water",elementType:"labels.text.stroke",stylers:[{color:"#17263c"}]}]};class o{constructor(e=null,t={}){if(this.apiKey=e,this.options=t,"undefined"==typeof window)throw new Error("google-maps is supported only in browser environment")}load(){return void 0!==this.api?Promise.resolve(this.api):void 0!==this.loader?this.loader:(window[o.CALLBACK_NAME]=()=>{if(this.api=window.google,void 0===this.resolve)throw new Error("Should not happen");this.resolve(this.api)},window.gm_authFailure=()=>{if(void 0===this.reject)throw new Error("Should not happen");this.reject(new Error("google-maps: authentication error"))},this.loader=new Promise(((e,t)=>{this.resolve=e,this.reject=t;const s=document.createElement("script");s.src=this.createUrl(),s.async=!0,s.onerror=e=>t(e),document.head.appendChild(s)})))}createUrl(){const e=[`callback=${o.CALLBACK_NAME}`];this.apiKey&&e.push(`key=${this.apiKey}`);for(let t in this.options)if(this.options.hasOwnProperty(t)){let s=this.options[t];"version"===t&&(t="v"),"libraries"===t&&(s=s.join(",")),e.push(`${t}=${s}`)}return`https://maps.googleapis.com/maps/api/js?${e.join("&")}`}}o.CALLBACK_NAME="_dk_google_maps_loader_cb";const h=class{constructor(s){e(this,s),this.selected=t(this,"selected"),this.mapClicked=t(this,"mapClicked"),this.currentLocationChanged=t(this,"currentLocationChanged"),this.invalidInput=t(this,"invalidInput"),this.defaultLat=21.419421,this.defaultLng=39.82553,this.modalActivityTitle=salla.lang.get("pages.checkout.select_your_address_from_map"),this.confirmButtonTitle=salla.lang.get("pages.checkout.confirm_address"),this.locateButtonTitle=salla.lang.get("pages.cart.detect_location"),this.locateButtonEdit=salla.lang.get("common.elements.edit"),this.searchPlaceholder=salla.lang.get("pages.checkout.search_for_address"),this.searchInputValue=null,this.formattedAddress="",this.geolocationError=!1,this.name="location",this.required=!1,this.readonly=!1,this.searchable=!1,this.zoom=10,this.theme="light",salla.lang.onLoaded((()=>{this.modalActivityTitle=salla.lang.get("pages.checkout.select_your_address_from_map"),this.confirmButtonTitle=salla.lang.get("pages.checkout.confirm_address"),this.locateButtonTitle=salla.lang.get("pages.cart.detect_location"),this.locateButtonEdit=salla.lang.get("common.elements.edit"),this.searchPlaceholder=salla.lang.get("pages.checkout.search_for_address")})),salla.onReady((()=>{this.apiKey=salla.config.get("store.settings.keys.maps")}))}formatAddress(e){return e.length>25?e.substring(0,25)+"...":e}getLatLng(){return this.selectedLat&&this.selectedLng?`${this.selectedLat}, ${this.selectedLng}`:null}getPositionAddress(e,t=!1){(new google.maps.Geocoder).geocode({location:e},((e,s)=>{s===google.maps.GeocoderStatus.OK&&(this.searchable&&(this.searchInputValue=e[0].formatted_address,this.searchInput.value=e[0].formatted_address),t&&(this.formattedAddress=e[0].formatted_address))}))}initGoogleMaps(e,t){new o(this.apiKey,e).load().then((e=>{if(this.map=new e.maps.Map(t,{center:this.lat||this.lng?{lat:this.lat,lng:this.lng}:{lat:this.defaultLat,lng:this.defaultLng},zoom:this.zoom,zoomControl:!0,mapTypeControl:!1,scaleControl:!1,streetViewControl:!1,rotateControl:!1,fullscreenControl:!1,disableDefaultUI:!1}),this.map.setOptions({styles:"light"===this.theme?r.light:r.dark}),this.marker=new e.maps.Marker({position:this.map.getCenter(),map:this.map,icon:{url:"data:image/svg+xml;utf8,"+encodeURIComponent('<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">\n<rect width="36" height="36" rx="18" fill="#5CD5C4"/>\n<path d="M18 10C17.0104 10 16.1458 10.1771 15.4062 10.5312C14.6562 10.8854 14.026 11.3542 13.5156 11.9375C13.0156 12.5104 12.6406 13.1667 12.3906 13.9062C12.1302 14.6458 12 15.401 12 16.1719C12 16.8906 12.2604 17.7656 12.7812 18.7969C13.3021 19.8281 13.8854 20.8333 14.5312 21.8125C15.1875 22.7812 15.8073 23.6406 16.3906 24.3906C16.9844 25.1302 17.349 25.5885 17.4844 25.7656C17.5469 25.8385 17.625 25.8958 17.7188 25.9375C17.8125 25.9792 17.9062 26 18 26C18.1042 26 18.1979 25.9792 18.2812 25.9375C18.375 25.8958 18.4531 25.8385 18.5156 25.7656C18.651 25.5885 19.0156 25.1302 19.6094 24.3906C20.1927 23.6406 20.8073 22.7812 21.4531 21.8125C22.1094 20.8333 22.6979 19.8281 23.2188 18.7969C23.7396 17.7656 24 16.8906 24 16.1719C24 15.401 23.8698 14.6458 23.6094 13.9062C23.3594 13.1667 22.9792 12.5104 22.4688 11.9375C21.9688 11.3542 21.3438 10.8854 20.5938 10.5312C19.8542 10.1771 18.9896 10 18 10ZM18 24.2812C17.5833 23.75 17.1094 23.1198 16.5781 22.3906C16.0365 21.651 15.526 20.901 15.0469 20.1406C14.5677 19.3698 14.1615 18.6302 13.8281 17.9219C13.4948 17.2135 13.3281 16.6302 13.3281 16.1719C13.3281 15.5885 13.4219 15.0052 13.6094 14.4219C13.7969 13.849 14.0781 13.3333 14.4531 12.875C14.8385 12.4167 15.3281 12.0469 15.9219 11.7656C16.5052 11.474 17.1979 11.3281 18 11.3281C18.8021 11.3281 19.4948 11.474 20.0781 11.7656C20.6719 12.0469 21.1562 12.4167 21.5312 12.875C21.9167 13.3333 22.2031 13.849 22.3906 14.4219C22.5781 15.0052 22.6719 15.5885 22.6719 16.1719C22.6719 16.6302 22.5052 17.2135 22.1719 17.9219C21.8385 18.6302 21.4323 19.3698 20.9531 20.1406C20.474 20.901 19.9688 21.651 19.4375 22.3906C18.8958 23.1198 18.4167 23.75 18 24.2812ZM18 13.3281C17.2604 13.3281 16.6302 13.5885 16.1094 14.1094C15.5885 14.6302 15.3281 15.2604 15.3281 16C15.3281 16.7396 15.5885 17.3698 16.1094 17.8906C16.6302 18.4115 17.2604 18.6719 18 18.6719C18.7396 18.6719 19.3698 18.4115 19.8906 17.8906C20.4115 17.3698 20.6719 16.7396 20.6719 16C20.6719 15.2604 20.4115 14.6302 19.8906 14.1094C19.3698 13.5885 18.7396 13.3281 18 13.3281ZM18 17.3281C17.6354 17.3281 17.3229 17.1979 17.0625 16.9375C16.8021 16.6771 16.6719 16.3646 16.6719 16C16.6719 15.6354 16.8021 15.3229 17.0625 15.0625C17.3229 14.8021 17.6354 14.6719 18 14.6719C18.3646 14.6719 18.6771 14.8021 18.9375 15.0625C19.1979 15.3229 19.3281 15.6354 19.3281 16C19.3281 16.3646 19.1979 16.6771 18.9375 16.9375C18.6771 17.1979 18.3646 17.3281 18 17.3281Z" fill="white"/>\n</svg>\n'),scaledSize:new e.maps.Size(30,30)}}),this.searchable){const t=new e.maps.places.SearchBox(this.searchInput);e.maps.event.addListener(t,"places_changed",(()=>{const e=t.getPlaces();e.length>0&&this.map&&(this.map.setCenter(e[0].geometry.location),this.lat=e[0].geometry.location.lat(),this.lng=e[0].geometry.location.lng(),this.marker.setPosition(e[0].geometry.location),this.searchInputValue=e[0].formatted_address,this.formattedAddress=e[0].formatted_address)}))}e.maps.event.addListener(this.map,"click",(e=>{this.readonly||(this.marker.setPosition(e.latLng),this.lat=e.latLng.lat(),this.lng=e.latLng.lng(),this.getPositionAddress(e.latLng),this.mapClicked.emit({lat:e.latLng.lat(),lng:e.latLng.lng(),address:this.formattedAddress?this.formattedAddress:null}))})),this.lat||this.lng||(this.getCurrentLocation(),this.geolocationError&&(this.map.setCenter({lat:this.lat,lng:this.lng}),this.marker.setPosition({lat:this.lat,lng:this.lng})))}))}getCurrentLocation(){navigator.geolocation&&this.map?navigator.geolocation.getCurrentPosition((e=>{const t={center:new google.maps.LatLng(e.coords.latitude,e.coords.longitude),zoom:15};this.map.setOptions(t),this.marker.setPosition(t.center),this.getPositionAddress(t.center),this.lat=e.coords.latitude,this.lng=e.coords.longitude,this.currentLocationChanged.emit({lat:e.coords.latitude,lng:e.coords.longitude,address:this.formattedAddress?this.formattedAddress:null})}),this.handleLocationError.bind(this)):(salla.log("Geolocation is not supported by this browser."),this.geolocationError=!0)}handleLocationError(e){switch(this.geolocationError=!0,e.code){case e.PERMISSION_DENIED:salla.log("User denied the request for Geolocation.");break;case e.POSITION_UNAVAILABLE:salla.log("Location information is unavailable.");break;case e.TIMEOUT:salla.log("The request to get user location timed out.");break;case e.UNKNOWN_ERROR:salla.log("An unknown error occurred.")}}componentDidLoad(){this.lat&&this.lng&&fetch(`https://maps.googleapis.com/maps/api/geocode/json?latlng=${this.lat},${this.lng}&key=${this.apiKey}&language=${salla.config.get("user.language_code")||document.documentElement.lang||"ar"}`).then((e=>e.json())).then((e=>{"OK"===e.status&&(this.formattedAddress=e.results[0].formatted_address,this.searchInputValue=e.results[0].formatted_address,this.searchInput.value=e.results[0].formatted_address,this.selectedLng=this.lng,this.selectedLat=this.lat)})),this.mapInput.addEventListener("invalid",(e=>{this.invalidInput.emit(e)})),this.mapInput.addEventListener("input",(()=>{this.mapInput.setCustomValidity(""),this.mapInput.reportValidity()}))}async open(){return this.map||this.initGoogleMaps({libraries:this.searchable?["places","search"]:[],language:salla.config.get("user.language_code")||document.documentElement.lang||"ar"},this.mapElement),await this.locationModal.open()}getLocationModal(){return s("div",null,s("div",{class:"s-map-modal-title"},this.modalTitle?this.modalTitle:this.modalActivityTitle),s("div",{class:"s-map-modal-body"},s("div",{class:"s-map-element",ref:e=>this.mapElement=e}),this.readonly?"":[this.searchable&&s("div",{class:"s-map-search-wrapper"},s("input",{class:"s-map-search-input",ref:e=>this.searchInput=e,placeholder:this.searchPlaceholder})),s("salla-button",{class:"s-map-my-location-button",onClick:()=>{this.getCurrentLocation()},shape:"icon",color:"primary"},s("span",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>location-target</title>\n<path d="M16 9.333c-3.676 0-6.667 2.991-6.667 6.667s2.991 6.667 6.667 6.667 6.667-2.991 6.667-6.667-2.991-6.667-6.667-6.667zM16 20c-2.205 0-4-1.795-4-4s1.795-4 4-4 4 1.795 4 4-1.795 4-4 4zM30.667 14.667h-1.401c-0.627-6.289-5.643-11.305-11.932-11.932v-1.401c0-0.736-0.597-1.333-1.333-1.333s-1.333 0.597-1.333 1.333v1.401c-6.289 0.627-11.305 5.643-11.932 11.932h-1.401c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333h1.401c0.628 6.289 5.643 11.305 11.932 11.932v1.401c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-1.401c6.289-0.628 11.305-5.643 11.932-11.932h1.401c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333zM16 26.667c-5.881 0-10.667-4.785-10.667-10.667s4.785-10.667 10.667-10.667 10.667 4.785 10.667 10.667-4.785 10.667-10.667 10.667z"></path>\n</svg>\n'})),s("salla-button",{class:"s-map-submit-button",color:"primary",width:"wide",onClick:()=>{let e={lat:this.lat,lng:this.lng,address:this.formattedAddress?this.formattedAddress:null};salla.event.emit("salla-map::selected",e),this.selected.emit(e),this.selectedLat=e.lat,this.selectedLng=e.lng,this.getPositionAddress(new google.maps.LatLng(e.lat,e.lng),!0),this.mapInput.value=this.selectedLat&&this.selectedLng?`${this.selectedLat}, ${this.selectedLng}`:null,this.mapInput.dispatchEvent(new window.Event("change",{bubbles:!0})),this.locationModal.close()}},this.confirmButtonTitle)]))}render(){return s(i,{key:"47e8a611d43d82613c87b8fce6742f318add9b74",class:"s-map-wrapper"},s("salla-modal",{key:"f21d703131da061ba0d5a991a9d73a42062e293b",class:"s-map-modal-wrapper",noPadding:!0,ref:e=>{this.locationModal=e}},this.getLocationModal()),s("slot",{key:"21754ee3e232c0ea2a0b0d89fd43fe136eca19dd",name:"button"},s("salla-button",{key:"dffc15443da0a75f9cc216edb86b58e0f661bef9",onClick:()=>{this.open()},color:"primary",class:"s-map-location-button"},s("span",{key:"868ac864b392c39cf1314ecfd3d1e45365daad30",class:"s-map-location-icon",innerHTML:this.formattedAddress?'\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>edit</title>\n<path d="M30.583 1.417c-1.828-1.829-5.019-1.829-6.847 0l-13.396 13.396c-0.161 0.161-0.279 0.361-0.341 0.581l-1.949 6.911c-0.131 0.464 0 0.964 0.341 1.305 0.253 0.252 0.593 0.389 0.943 0.389 0.121 0 0.243-0.016 0.361-0.051l6.911-1.949c0.22-0.061 0.419-0.179 0.581-0.34l10.455-10.453s0 0 0 0l2.941-2.941c1.887-1.888 1.887-4.96 0-6.848zM15.547 19.528l-4.284 1.208 1.208-4.284 9.265-9.265 3.076 3.076zM28.696 6.38l-1.999 1.999-3.076-3.076 1.999-1.999c0.849-0.848 2.227-0.848 3.076 0 0.848 0.848 0.848 2.227 0 3.076zM24 20c-0.737 0-1.333 0.597-1.333 1.333v4c0 2.205-1.795 4-4 4h-12c-2.205 0-4-1.795-4-4v-12c0-2.205 1.795-4 4-4h4c0.737 0 1.333-0.597 1.333-1.333s-0.596-1.333-1.333-1.333h-4c-3.676 0-6.667 2.991-6.667 6.667v12c0 3.676 2.991 6.667 6.667 6.667h12c3.676 0 6.667-2.991 6.667-6.667v-4c0-0.736-0.596-1.333-1.333-1.333z"></path>\n</svg>\n':a}),this.formattedAddress?s("div",null,this.locateButtonEdit," | ",this.formatAddress(this.formattedAddress)):this.locateButtonTitle)),s("input",{key:"db8f6bbbe9a89debc626402983a98efc34b2130c",class:"s-hidden",name:this.name,required:this.required,value:this.getLatLng(),ref:e=>this.mapInput=e}))}get host(){return l(this)}};h.style="";const n=class{constructor(t){e(this,t),this.height="10px";try{if(this.donation){let e="string"==typeof this.donation?JSON.parse(this.donation):this.donation;e.can_donate&&e.target_amount?(e.target_end_date="0000-00-00"==e.target_end_date?null:e.target_end_date,this.value=e.collected_amount,this.target=e.target_amount,this.header=salla.lang.get("pages.products.target"),this.message=e.target_end_date?salla.lang.get("pages.products.donation_target_date")+" "+e.target_end_date:""):this.message=e.target_amount?e.target_message:""}}catch(e){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?s("div",{class:"s-progress-bar-container"},this.header?s("div",{class:"s-progress-bar-header"},this.header):"",this.getProgressBar(),this.message?s("span",{class:"s-progress-bar-message"},this.message):""):""}getProgressBar(){return this.target?[this.hideUnits?null:s("div",{class:"s-progress-bar-target-section"},s("span",{innerHTML:`${salla.helpers.number(this.value)} ${this.unit}`}),s("span",{innerHTML:`${salla.helpers.number(this.target)} ${this.unit}`})),s("div",{class:"s-progress-bar-wrapper",style:{height:this.height}},s("div",{class:{"s-progress-bar-progress":!0,"s-progress-bar-progress-stripped":this.stripped},style:{width:`${this.getPercentage()}%`,backgroundColor:this.color}}))]:null}};n.style="";export{h as salla_map,n as salla_progress_bar}
4
+ import{r as e,c as t,h as s,H as i,a as l}from"./p-CcbWxP-e.js";import{L as a}from"./p-BO5AoBAP.js";var r={light:[{featureType:"water",elementType:"geometry",stylers:[{color:"#e9e9e9"},{lightness:17}]},{featureType:"landscape",elementType:"geometry",stylers:[{color:"#f5f5f5"},{lightness:20}]},{featureType:"road.highway",elementType:"geometry.fill",stylers:[{color:"#ffffff"},{lightness:17}]},{featureType:"road.highway",elementType:"geometry.stroke",stylers:[{color:"#ffffff"},{lightness:29},{weight:.2}]},{featureType:"road.arterial",elementType:"geometry",stylers:[{color:"#ffffff"},{lightness:18}]},{featureType:"road.local",elementType:"geometry",stylers:[{color:"#ffffff"},{lightness:16}]},{featureType:"poi",elementType:"geometry",stylers:[{color:"#f5f5f5"},{lightness:21}]},{featureType:"poi.park",elementType:"geometry",stylers:[{color:"#dedede"},{lightness:21}]},{elementType:"labels.text.stroke",stylers:[{visibility:"on"},{color:"#ffffff"},{lightness:16}]},{elementType:"labels.text.fill",stylers:[{saturation:36},{color:"#333333"},{lightness:40}]},{elementType:"labels.icon",stylers:[{visibility:"off"}]},{featureType:"transit",elementType:"geometry",stylers:[{color:"#f2f2f2"},{lightness:19}]},{featureType:"administrative",elementType:"geometry.fill",stylers:[{color:"#fefefe"},{lightness:20}]},{featureType:"administrative",elementType:"geometry.stroke",stylers:[{color:"#fefefe"},{lightness:17},{weight:1.2}]}],dark:[{elementType:"geometry",stylers:[{color:"#242f3e"}]},{elementType:"labels.text.fill",stylers:[{color:"#746855"}]},{elementType:"labels.text.stroke",stylers:[{color:"#242f3e"}]},{featureType:"administrative.locality",elementType:"labels.text.fill",stylers:[{color:"#d59563"}]},{featureType:"poi",elementType:"labels.text.fill",stylers:[{color:"#d59563"}]},{featureType:"poi.park",elementType:"geometry",stylers:[{color:"#263c3f"}]},{featureType:"poi.park",elementType:"labels.text.fill",stylers:[{color:"#6b9a76"}]},{featureType:"road",elementType:"geometry",stylers:[{color:"#38414e"}]},{featureType:"road",elementType:"geometry.stroke",stylers:[{color:"#212a37"}]},{featureType:"road",elementType:"labels.text.fill",stylers:[{color:"#9ca5b3"}]},{featureType:"road.highway",elementType:"geometry",stylers:[{color:"#746855"}]},{featureType:"road.highway",elementType:"geometry.stroke",stylers:[{color:"#1f2835"}]},{featureType:"road.highway",elementType:"labels.text.fill",stylers:[{color:"#f3d19c"}]},{featureType:"transit",elementType:"geometry",stylers:[{color:"#2f3948"}]},{featureType:"transit.station",elementType:"labels.text.fill",stylers:[{color:"#d59563"}]},{featureType:"water",elementType:"geometry",stylers:[{color:"#17263c"}]},{featureType:"water",elementType:"labels.text.fill",stylers:[{color:"#515c6d"}]},{featureType:"water",elementType:"labels.text.stroke",stylers:[{color:"#17263c"}]}]};class o{constructor(e=null,t={}){if(this.apiKey=e,this.options=t,"undefined"==typeof window)throw new Error("google-maps is supported only in browser environment")}load(){return void 0!==this.api?Promise.resolve(this.api):void 0!==this.loader?this.loader:(window[o.CALLBACK_NAME]=()=>{if(this.api=window.google,void 0===this.resolve)throw new Error("Should not happen");this.resolve(this.api)},window.gm_authFailure=()=>{if(void 0===this.reject)throw new Error("Should not happen");this.reject(new Error("google-maps: authentication error"))},this.loader=new Promise(((e,t)=>{this.resolve=e,this.reject=t;const s=document.createElement("script");s.src=this.createUrl(),s.async=!0,s.onerror=e=>t(e),document.head.appendChild(s)})))}createUrl(){const e=[`callback=${o.CALLBACK_NAME}`];this.apiKey&&e.push(`key=${this.apiKey}`);for(let t in this.options)if(this.options.hasOwnProperty(t)){let s=this.options[t];"version"===t&&(t="v"),"libraries"===t&&(s=s.join(",")),e.push(`${t}=${s}`)}return`https://maps.googleapis.com/maps/api/js?${e.join("&")}`}}o.CALLBACK_NAME="_dk_google_maps_loader_cb";const h=class{constructor(s){e(this,s),this.selected=t(this,"selected"),this.mapClicked=t(this,"mapClicked"),this.currentLocationChanged=t(this,"currentLocationChanged"),this.invalidInput=t(this,"invalidInput"),this.defaultLat=21.419421,this.defaultLng=39.82553,this.modalActivityTitle=salla.lang.get("pages.checkout.select_your_address_from_map"),this.confirmButtonTitle=salla.lang.get("pages.checkout.confirm_address"),this.locateButtonTitle=salla.lang.get("pages.cart.detect_location"),this.locateButtonEdit=salla.lang.get("common.elements.edit"),this.searchPlaceholder=salla.lang.get("pages.checkout.search_for_address"),this.searchInputValue=null,this.formattedAddress="",this.geolocationError=!1,this.name="location",this.required=!1,this.readonly=!1,this.searchable=!1,this.zoom=10,this.theme="light",salla.lang.onLoaded((()=>{this.modalActivityTitle=salla.lang.get("pages.checkout.select_your_address_from_map"),this.confirmButtonTitle=salla.lang.get("pages.checkout.confirm_address"),this.locateButtonTitle=salla.lang.get("pages.cart.detect_location"),this.locateButtonEdit=salla.lang.get("common.elements.edit"),this.searchPlaceholder=salla.lang.get("pages.checkout.search_for_address")})),salla.onReady((()=>{this.apiKey=salla.config.get("store.settings.keys.maps")}))}formatAddress(e){return e.length>25?e.substring(0,25)+"...":e}getLatLng(){return this.selectedLat&&this.selectedLng?`${this.selectedLat}, ${this.selectedLng}`:null}getPositionAddress(e,t=!1){(new google.maps.Geocoder).geocode({location:e},((e,s)=>{s===google.maps.GeocoderStatus.OK&&(this.searchable&&(this.searchInputValue=e[0].formatted_address,this.searchInput.value=e[0].formatted_address),t&&(this.formattedAddress=e[0].formatted_address))}))}initGoogleMaps(e,t){new o(this.apiKey,e).load().then((e=>{if(this.map=new e.maps.Map(t,{center:this.lat||this.lng?{lat:this.lat,lng:this.lng}:{lat:this.defaultLat,lng:this.defaultLng},zoom:this.zoom,zoomControl:!0,mapTypeControl:!1,scaleControl:!1,streetViewControl:!1,rotateControl:!1,fullscreenControl:!1,disableDefaultUI:!1}),this.map.setOptions({styles:"light"===this.theme?r.light:r.dark}),this.marker=new e.maps.Marker({position:this.map.getCenter(),map:this.map,icon:{url:"data:image/svg+xml;utf8,"+encodeURIComponent('<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">\n<rect width="36" height="36" rx="18" fill="#5CD5C4"/>\n<path d="M18 10C17.0104 10 16.1458 10.1771 15.4062 10.5312C14.6562 10.8854 14.026 11.3542 13.5156 11.9375C13.0156 12.5104 12.6406 13.1667 12.3906 13.9062C12.1302 14.6458 12 15.401 12 16.1719C12 16.8906 12.2604 17.7656 12.7812 18.7969C13.3021 19.8281 13.8854 20.8333 14.5312 21.8125C15.1875 22.7812 15.8073 23.6406 16.3906 24.3906C16.9844 25.1302 17.349 25.5885 17.4844 25.7656C17.5469 25.8385 17.625 25.8958 17.7188 25.9375C17.8125 25.9792 17.9062 26 18 26C18.1042 26 18.1979 25.9792 18.2812 25.9375C18.375 25.8958 18.4531 25.8385 18.5156 25.7656C18.651 25.5885 19.0156 25.1302 19.6094 24.3906C20.1927 23.6406 20.8073 22.7812 21.4531 21.8125C22.1094 20.8333 22.6979 19.8281 23.2188 18.7969C23.7396 17.7656 24 16.8906 24 16.1719C24 15.401 23.8698 14.6458 23.6094 13.9062C23.3594 13.1667 22.9792 12.5104 22.4688 11.9375C21.9688 11.3542 21.3438 10.8854 20.5938 10.5312C19.8542 10.1771 18.9896 10 18 10ZM18 24.2812C17.5833 23.75 17.1094 23.1198 16.5781 22.3906C16.0365 21.651 15.526 20.901 15.0469 20.1406C14.5677 19.3698 14.1615 18.6302 13.8281 17.9219C13.4948 17.2135 13.3281 16.6302 13.3281 16.1719C13.3281 15.5885 13.4219 15.0052 13.6094 14.4219C13.7969 13.849 14.0781 13.3333 14.4531 12.875C14.8385 12.4167 15.3281 12.0469 15.9219 11.7656C16.5052 11.474 17.1979 11.3281 18 11.3281C18.8021 11.3281 19.4948 11.474 20.0781 11.7656C20.6719 12.0469 21.1562 12.4167 21.5312 12.875C21.9167 13.3333 22.2031 13.849 22.3906 14.4219C22.5781 15.0052 22.6719 15.5885 22.6719 16.1719C22.6719 16.6302 22.5052 17.2135 22.1719 17.9219C21.8385 18.6302 21.4323 19.3698 20.9531 20.1406C20.474 20.901 19.9688 21.651 19.4375 22.3906C18.8958 23.1198 18.4167 23.75 18 24.2812ZM18 13.3281C17.2604 13.3281 16.6302 13.5885 16.1094 14.1094C15.5885 14.6302 15.3281 15.2604 15.3281 16C15.3281 16.7396 15.5885 17.3698 16.1094 17.8906C16.6302 18.4115 17.2604 18.6719 18 18.6719C18.7396 18.6719 19.3698 18.4115 19.8906 17.8906C20.4115 17.3698 20.6719 16.7396 20.6719 16C20.6719 15.2604 20.4115 14.6302 19.8906 14.1094C19.3698 13.5885 18.7396 13.3281 18 13.3281ZM18 17.3281C17.6354 17.3281 17.3229 17.1979 17.0625 16.9375C16.8021 16.6771 16.6719 16.3646 16.6719 16C16.6719 15.6354 16.8021 15.3229 17.0625 15.0625C17.3229 14.8021 17.6354 14.6719 18 14.6719C18.3646 14.6719 18.6771 14.8021 18.9375 15.0625C19.1979 15.3229 19.3281 15.6354 19.3281 16C19.3281 16.3646 19.1979 16.6771 18.9375 16.9375C18.6771 17.1979 18.3646 17.3281 18 17.3281Z" fill="white"/>\n</svg>\n'),scaledSize:new e.maps.Size(30,30)}}),this.searchable){const t=new e.maps.places.SearchBox(this.searchInput);e.maps.event.addListener(t,"places_changed",(()=>{const e=t.getPlaces();e.length>0&&this.map&&(this.map.setCenter(e[0].geometry.location),this.lat=e[0].geometry.location.lat(),this.lng=e[0].geometry.location.lng(),this.marker.setPosition(e[0].geometry.location),this.searchInputValue=e[0].formatted_address,this.formattedAddress=e[0].formatted_address)}))}e.maps.event.addListener(this.map,"click",(e=>{this.readonly||(this.marker.setPosition(e.latLng),this.lat=e.latLng.lat(),this.lng=e.latLng.lng(),this.getPositionAddress(e.latLng),this.mapClicked.emit({lat:e.latLng.lat(),lng:e.latLng.lng(),address:this.formattedAddress?this.formattedAddress:null}))})),this.lat||this.lng||(this.getCurrentLocation(),this.geolocationError&&(this.map.setCenter({lat:this.lat,lng:this.lng}),this.marker.setPosition({lat:this.lat,lng:this.lng})))}))}getCurrentLocation(){navigator.geolocation&&this.map?navigator.geolocation.getCurrentPosition((e=>{const t={center:new google.maps.LatLng(e.coords.latitude,e.coords.longitude),zoom:15};this.map.setOptions(t),this.marker.setPosition(t.center),this.getPositionAddress(t.center),this.lat=e.coords.latitude,this.lng=e.coords.longitude,this.currentLocationChanged.emit({lat:e.coords.latitude,lng:e.coords.longitude,address:this.formattedAddress?this.formattedAddress:null})}),this.handleLocationError.bind(this)):(salla.log("Geolocation is not supported by this browser."),this.geolocationError=!0)}handleLocationError(e){switch(this.geolocationError=!0,e.code){case e.PERMISSION_DENIED:salla.log("User denied the request for Geolocation.");break;case e.POSITION_UNAVAILABLE:salla.log("Location information is unavailable.");break;case e.TIMEOUT:salla.log("The request to get user location timed out.");break;case e.UNKNOWN_ERROR:salla.log("An unknown error occurred.")}}componentDidLoad(){this.lat&&this.lng&&fetch(`https://maps.googleapis.com/maps/api/geocode/json?latlng=${this.lat},${this.lng}&key=${this.apiKey}&language=${salla.config.get("user.language_code")||document.documentElement.lang||"ar"}`).then((e=>e.json())).then((e=>{"OK"===e.status&&(this.formattedAddress=e.results[0].formatted_address,this.searchInputValue=e.results[0].formatted_address,this.searchInput.value=e.results[0].formatted_address,this.selectedLng=this.lng,this.selectedLat=this.lat)})),this.mapInput.addEventListener("invalid",(e=>{this.invalidInput.emit(e)})),this.mapInput.addEventListener("input",(()=>{this.mapInput.setCustomValidity(""),this.mapInput.reportValidity()}))}async open(){return this.map||this.initGoogleMaps({libraries:this.searchable?["places","search"]:[],language:salla.config.get("user.language_code")||document.documentElement.lang||"ar"},this.mapElement),await this.locationModal.open()}getLocationModal(){return s("div",null,s("div",{class:"s-map-modal-title"},this.modalTitle?this.modalTitle:this.modalActivityTitle),s("div",{class:"s-map-modal-body"},s("div",{class:"s-map-element",ref:e=>this.mapElement=e}),this.readonly?"":[this.searchable&&s("div",{class:"s-map-search-wrapper"},s("input",{class:"s-map-search-input",ref:e=>this.searchInput=e,placeholder:this.searchPlaceholder})),s("salla-button",{class:"s-map-my-location-button",onClick:()=>{this.getCurrentLocation()},shape:"icon",color:"primary"},s("span",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>location-target</title>\n<path d="M16 9.333c-3.676 0-6.667 2.991-6.667 6.667s2.991 6.667 6.667 6.667 6.667-2.991 6.667-6.667-2.991-6.667-6.667-6.667zM16 20c-2.205 0-4-1.795-4-4s1.795-4 4-4 4 1.795 4 4-1.795 4-4 4zM30.667 14.667h-1.401c-0.627-6.289-5.643-11.305-11.932-11.932v-1.401c0-0.736-0.597-1.333-1.333-1.333s-1.333 0.597-1.333 1.333v1.401c-6.289 0.627-11.305 5.643-11.932 11.932h-1.401c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333h1.401c0.628 6.289 5.643 11.305 11.932 11.932v1.401c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-1.401c6.289-0.628 11.305-5.643 11.932-11.932h1.401c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333zM16 26.667c-5.881 0-10.667-4.785-10.667-10.667s4.785-10.667 10.667-10.667 10.667 4.785 10.667 10.667-4.785 10.667-10.667 10.667z"></path>\n</svg>\n'})),s("salla-button",{class:"s-map-submit-button",color:"primary",width:"wide",onClick:()=>{let e={lat:this.lat,lng:this.lng,address:this.formattedAddress?this.formattedAddress:null};salla.event.emit("salla-map::selected",e),this.selected.emit(e),this.selectedLat=e.lat,this.selectedLng=e.lng,this.getPositionAddress(new google.maps.LatLng(e.lat,e.lng),!0),this.mapInput.value=this.selectedLat&&this.selectedLng?`${this.selectedLat}, ${this.selectedLng}`:null,this.mapInput.dispatchEvent(new window.Event("change",{bubbles:!0})),this.locationModal.close()}},this.confirmButtonTitle)]))}render(){return s(i,{key:"47e8a611d43d82613c87b8fce6742f318add9b74",class:"s-map-wrapper"},s("salla-modal",{key:"f21d703131da061ba0d5a991a9d73a42062e293b",class:"s-map-modal-wrapper",noPadding:!0,ref:e=>{this.locationModal=e}},this.getLocationModal()),s("slot",{key:"21754ee3e232c0ea2a0b0d89fd43fe136eca19dd",name:"button"},s("salla-button",{key:"dffc15443da0a75f9cc216edb86b58e0f661bef9",onClick:()=>{this.open()},color:"primary",class:"s-map-location-button"},s("span",{key:"868ac864b392c39cf1314ecfd3d1e45365daad30",class:"s-map-location-icon",innerHTML:this.formattedAddress?'\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>edit</title>\n<path d="M30.583 1.417c-1.828-1.829-5.019-1.829-6.847 0l-13.396 13.396c-0.161 0.161-0.279 0.361-0.341 0.581l-1.949 6.911c-0.131 0.464 0 0.964 0.341 1.305 0.253 0.252 0.593 0.389 0.943 0.389 0.121 0 0.243-0.016 0.361-0.051l6.911-1.949c0.22-0.061 0.419-0.179 0.581-0.34l10.455-10.453s0 0 0 0l2.941-2.941c1.887-1.888 1.887-4.96 0-6.848zM15.547 19.528l-4.284 1.208 1.208-4.284 9.265-9.265 3.076 3.076zM28.696 6.38l-1.999 1.999-3.076-3.076 1.999-1.999c0.849-0.848 2.227-0.848 3.076 0 0.848 0.848 0.848 2.227 0 3.076zM24 20c-0.737 0-1.333 0.597-1.333 1.333v4c0 2.205-1.795 4-4 4h-12c-2.205 0-4-1.795-4-4v-12c0-2.205 1.795-4 4-4h4c0.737 0 1.333-0.597 1.333-1.333s-0.596-1.333-1.333-1.333h-4c-3.676 0-6.667 2.991-6.667 6.667v12c0 3.676 2.991 6.667 6.667 6.667h12c3.676 0 6.667-2.991 6.667-6.667v-4c0-0.736-0.596-1.333-1.333-1.333z"></path>\n</svg>\n':a}),this.formattedAddress?s("div",null,this.locateButtonEdit," | ",this.formatAddress(this.formattedAddress)):this.locateButtonTitle)),s("input",{key:"db8f6bbbe9a89debc626402983a98efc34b2130c",class:"s-hidden",name:this.name,required:this.required,value:this.getLatLng(),ref:e=>this.mapInput=e}))}get host(){return l(this)}};h.style="";const n=class{constructor(t){e(this,t),this.height="10px";try{if(this.donation){let e="string"==typeof this.donation?JSON.parse(this.donation):this.donation;e.can_donate&&e.target_amount?(e.target_end_date="0000-00-00"==e.target_end_date?null:e.target_end_date,this.value=e.collected_amount,this.target=e.target_amount,this.header=salla.lang.get("pages.products.target"),this.message=e.target_end_date?salla.lang.get("pages.products.donation_target_date")+" "+e.target_end_date:""):this.message=e.target_amount?e.target_message:""}}catch(e){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?s("div",{class:"s-progress-bar-container"},this.header?s("div",{class:"s-progress-bar-header"},this.header):"",this.getProgressBar(),this.message?s("span",{class:"s-progress-bar-message"},this.message):""):""}getProgressBar(){return this.target?[this.hideUnits?null:s("div",{class:"s-progress-bar-target-section"},s("span",{innerHTML:`${salla.helpers.number(this.value)} ${this.unit}`}),s("span",{innerHTML:`${salla.helpers.number(this.target)} ${this.unit}`})),s("div",{class:"s-progress-bar-wrapper",style:{height:this.height}},s("div",{class:{"s-progress-bar-progress":!0,"s-progress-bar-progress-stripped":this.stripped},style:{width:`${this.getPercentage()}%`,backgroundColor:this.color}}))]:null}};n.style="";export{h as salla_map,n as salla_progress_bar}
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import{r as t,c as s,h as i,H as a,a as e,e as o}from"./p-C2RHZyoj.js";import{P as n}from"./p-DY4LZmNP.js";import{H as l}from"./p-XnA1YTjA.js";import{a as r}from"./p-CL7OPpYS.js";import{B as c}from"./p-D3mWkc-3.js";import{D as d}from"./p-CoQJOPRz.js";import{S as h}from"./p-BZp0rKEO.js";import{C as p}from"./p-C6jIkM-X.js";import"./p-CgtvEd63.js";class u{constructor(t,s){this.host=t,this.productId=s,this.collected=!1,this.livePrice=0}static attach(t,s){const i=t.querySelector("salla-mini-checkout-widget");if(!i)return!1;const a=new u(t,String(s));return salla.product?.event?.onPriceUpdated?.((t=>{a.livePrice=Number(t?.data?.price)||a.livePrice})),i.addEventListener("click",(t=>a.handleWidgetClick(t,i)),!0),!0}getSelectedQuantity(){try{const t=document.querySelector("form.product-form"),s=t?.getElementSallaData?.(),i=Number(s instanceof FormData?s.get("quantity"):s?.quantity);if(Number.isFinite(i)&&i>0)return i}catch{}return Number(this.host.getAttribute("quantity"))||1}async handleWidgetClick(t,s){if(this.collected)return void(this.collected=!1);if(t.preventDefault(),t.stopImmediatePropagation(),!await this.validatePdpOptions())return;if(salla.config.isGuest())return void salla.api.auth.requireLoginThen("salla-add-product-button::oo.after-login",(()=>this.handleWidgetClick(t,s)));let i;s.classList.add("s-add-product-button-busy");try{i=await salla.api.withoutNotifier((()=>salla.product.api.getOrderOptions([{id:this.productId,quantity:this.getSelectedQuantity()}])))}catch(t){return salla?.logger?.warn?.("order-options: fetch failed",t),s.classList.remove("s-add-product-button-busy"),void this.resumeWidget(s)}s.classList.remove("s-add-product-button-busy");const a=i?.data?.order_options||[];if(!a.length)return void this.resumeWidget(s);const e=this.livePrice>0?this.livePrice:Number(i?.data?.products?.[0]?.price?.amount)||0,o=this.ensureModal();try{const t=await o.open({orderOptions:a,basePrice:e});this.injectIntoMini(t?.orderOptions||[]),this.resumeWidget(s)}catch{}}async validatePdpOptions(){const t=document.querySelector(`salla-product-options[product-id="${this.productId}"]`);return!t||("function"==typeof t.validateAndScroll?await t.validateAndScroll():"function"!=typeof t.reportValidity||await t.reportValidity())}injectIntoMini(t){if(!t.length)return;const s=this.productId,i=a=>{if(String(a?.id)===String(s))try{a?.payload?.set?.("order_options",t)}finally{salla.event.off("cart::before.add.item",i)}};salla.event.on("cart::before.add.item",i)}ensureModal(){let t=document.querySelector("salla-order-options-modal");return t||(t=document.createElement("salla-order-options-modal"),document.body.appendChild(t)),t}resumeWidget(t){this.collected=!0;const s=t.shadowRoot?.querySelector?.(".s-fast-checkout-button");s?s.click():"function"==typeof t.click&&t.click()}}const m=class{constructor(i){t(this,i),this.success=s(this,"success"),this.failed=s(this,"failed"),this.hostAttributes={},this.hasPreOrder=!1,this.productStatus="sale",this.productType="product",this.selectedOptions=[],this.buyNowText=salla.lang.get("pages.products.buy_now"),this.isDesktopViewport="undefined"==typeof window||window.matchMedia("(min-width: 768px)").matches,this.viewportMediaQuery=null,this.orderOptionsGateAttached=!1,this.onViewportChange=t=>{this.isDesktopViewport=t.matches,this.btn?.setText(t.matches&&this.passedLabel?this.passedLabel:this.getLabel())},salla.lang.onLoaded((()=>{this.buyNowText=salla.lang.get("pages.products.buy_now")}))}getLabel(){return"sale"===this.productStatus&&this.supportStickyBar&&!this.isDesktopViewport&&this.showQuickBuy&&this.isApplePayActive?n:this.hasPreOrder?salla.lang.get("pages.products.pre_order_now"):"sale"===this.productStatus&&"booking"===this.productType?salla.lang.get("pages.cart.book_now"):"sale"===this.productStatus?salla.lang.get("pages.cart.add_to_cart"):"donating"!==this.productType?salla.lang.get("pages.products.out_of_stock"):salla.lang.get("pages.products.donation_exceed")}addProductToCart(t){if("booking"===this.productType)return t.preventDefault(),this.addBookingProduct();if("submit"===this.hostAttributes.type)return!1;t.preventDefault(),this.btn?.disable();const s=document.querySelector(`salla-product-options[product-id="${this.productId}"]`);return s&&"function"==typeof s.validateAndScroll?s.validateAndScroll().then((async t=>{const s={isValid:t,component:this};if(await salla.hooks.call("salla-add-product-button","validate",s),s.isValid)return this._proceedAddToCart();this.btn?.enable()})).catch((()=>{this.btn?.enable()})):this._proceedAddToCart()}async _proceedAddToCart(){const t=this.host.closest("salla-products-list, salla-products-slider")??this.host.closest("salla-product-card, custom-salla-product-card"),s=Object.entries({id:this.productId,donation_amount:this.donatingAmount,quantity:this.quantity,endpoint:"quickAdd",source:l.getProductsSource(t?.getAttribute("source"))}).reduce(((t,[s,i])=>i?(t[s]=i,t):t),{});return salla.cart.addItem(s).then((async t=>(this.selectedOptions=[],this.btn?.enable(),this.success.emit(t),t))).catch((t=>{this.failed.emit(t),this.btn?.enable()}))}addBookingProduct(){return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("booking::add",this.productId),void salla.event.dispatch("login::open")):salla.booking.add(this.productId).then((t=>this.success.emit(t))).catch((t=>this.failed.emit(t)))}getBtnAttributes(){for(let t=0;t<this.host.attributes.length;t++)["id","class"].includes(this.host.attributes[t].name)||(this.hostAttributes[this.host.attributes[t].name]=this.host.attributes[t].value);return this.hostAttributes}get notifyChannels(){return this.channels||salla.api.product.getAvailabilityChannels?.()||l.availabilityChannels()}getQuickBuyBtnAttributes(){return{...this.getBtnAttributes(),type:this.supportStickyBar&&!this.isDesktopViewport?"plain":"donating"==this.productType?"donate":"buy"}}miniCheckoutWidget(){let t=salla.config.get("store.id");if(t)return i("salla-mini-checkout-widget",{language:salla.lang.locale,"store-id":t,config:{user:salla.config.get("user"),failure_url:window.location.href},products:[this.productId],api:salla.config.get("store.api"),outline:!0,"form-selector":"form.product-form",class:"s-add-product-button-mini-checkout"},i("div",{slot:"widget-label",class:"s-add-product-button-mini-checkout-content"},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>full-wallet</title>\n<path d="M29 12h-26c-0.668-0.008-1.284-0.226-1.787-0.59l0.009 0.006c-0.744-0.552-1.222-1.428-1.222-2.416 0-1.657 1.343-3 2.999-3h6c0.552 0 1 0.448 1 1s-0.448 1-1 1v0h-6c-0.552 0-1 0.448-1 1 0 0.326 0.156 0.616 0.397 0.798l0.002 0.002c0.167 0.12 0.374 0.194 0.599 0.2l0.001 0h26c0.552 0 1 0.448 1 1s-0.448 1-1 1v0zM27 12c-0.552 0-1-0.448-1-1v0-3h-3c-0.552 0-1-0.448-1-1s0.448-1 1-1v0h4c0.552 0 1 0.448 1 1v0 4c0 0.552-0.448 1-1 1v0zM29 30h-26c-1.657 0-3-1.343-3-3v0-18c0-0.552 0.448-1 1-1s1 0.448 1 1v0 18c0 0.552 0.448 1 1 1v0h25v-5c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM29 18c-0.552 0-1-0.448-1-1v0-6c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM31 24h-7c-2.209 0-4-1.791-4-4s1.791-4 4-4v0h7c0.552 0 1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM24 18c-1.105 0-2 0.895-2 2s0.895 2 2 2v0h6v-4zM25 12c-0.001 0-0.001 0-0.002 0-0.389 0-0.726-0.222-0.891-0.546l-0.003-0.006-3.552-7.106-2.306 1.152c-0.13 0.066-0.284 0.105-0.447 0.105-0.552 0-1-0.448-1-1 0-0.39 0.223-0.727 0.548-0.892l0.006-0.003 3.2-1.6c0.13-0.067 0.284-0.106 0.447-0.106 0.39 0 0.727 0.223 0.892 0.548l0.003 0.006 4 8c0.067 0.13 0.106 0.285 0.106 0.448 0 0.552-0.448 1-1 1v0zM21 12c-0.001 0-0.001 0-0.002 0-0.389 0-0.726-0.222-0.891-0.546l-0.003-0.006-3.552-7.106-15.104 7.552c-0.13 0.066-0.284 0.105-0.447 0.105-0.552 0-1-0.448-1-1 0-0.39 0.223-0.727 0.548-0.892l0.006-0.003 16-8c0.13-0.067 0.284-0.106 0.447-0.106 0.39 0 0.727 0.223 0.892 0.548l0.003 0.006 4 8c0.067 0.13 0.106 0.285 0.106 0.448 0 0.552-0.448 1-1 1-0.001 0-0.001 0-0.002 0h0z"></path>\n</svg>\n'}),this.buyNowText))}componentWillLoad(){return salla.onReady().then((()=>{if(document.documentElement.classList.add("hydrated"),this.showQuickBuy=this.quickBuy&&salla.config.get("store.settings.buy_now")&&"sale"==this.productStatus&&"booking"!==this.productType,this.isApplePayActive=window.ApplePaySession?.canMakePayments()&&salla.config.get("store.settings.payments")?.includes("apple_pay")&&salla.config.get("store.settings.is_salla_gateway",!1),this.passedLabel=this.host.innerHTML.replace("\x3c!----\x3e","").trim(),this.passedLabel&&this.isDesktopViewport)return this.btn?.setText(this.passedLabel);"submit"===this.host.getAttribute("type")&&this.supportStickyBar&&(this.viewportMediaQuery=window.matchMedia("(min-width: 768px)"),this.viewportMediaQuery.addEventListener("change",this.onViewportChange))}))}render(){return this.host.closest(".swiper-slide")?.classList.contains("swiper-slide-duplicate")?"":this.hasSubscribedOptions?i(a,null,i("salla-product-availability",{...this.getBtnAttributes(),"is-subscribed":!0},i("span",{class:"s-hidden"},i("slot",null)))):"out-and-notify"===this.productStatus&&this.notifyChannels||this.hasOutOfStockOption?i(a,null,i("salla-product-availability",{...this.getBtnAttributes()},i("span",{class:"s-hidden"},i("slot",null)))):i(a,{class:{"s-add-product-button-with-quick-buy":this.showQuickBuy,"s-add-product-button-with-sticky-bar":this.supportStickyBar,"s-add-product-button-with-apple-pay":this.showQuickBuy&&this.isApplePayActive}},i("div",{class:{"s-add-product-button-main":this.showQuickBuy,"w-full":!document.getElementById("fast-checkout-js")||["financial_support","donating"].includes(this.productType)}},i("salla-button",{color:"sale"===this.productStatus?"primary":"light",type:"button",fill:"sale"===this.productStatus?"solid":"outline",ref:t=>this.btn=t,onClick:t=>this.addProductToCart(t),disabled:"sale"!==this.productStatus,...this.getBtnAttributes(),"loader-position":"center"},i("slot",null)),this.showQuickBuy&&document.getElementById("fast-checkout-js")&&!["financial_support","donating"].includes(this.productType)?this.miniCheckoutWidget():""),this.showQuickBuy&&this.isApplePayActive?i("salla-quick-buy",{...this.getQuickBuyBtnAttributes()}):"")}async componentDidLoad(){await Salla.hooks.registerComponent("salla-add-product-button",this),this.notifyOptionsAvailability&&salla.event.on("product-options::change",(async t=>{if(!["thumbnail","color","single-option"].includes(t.option.type))return;this.hasSubscribedOptions=!1,this.selectedOptions=await(document.querySelector(`salla-product-options[product-id="${this.productId}"]`)?.getSelectedOptions()),this.hasOutOfStockOption=await(document.querySelector(`salla-product-options[product-id="${this.productId}"]`)?.hasOutOfStockOption());let s=salla.storage.get(`product-${this.productId}-subscribed-options`);if((s||this.subscribedOptions)&&this.hasOutOfStockOption)if(salla.config.isGuest()){const t=s?s.map((t=>t.split(",").map((t=>parseInt(t))))):[];this.hasSubscribedOptions=t.length>0&&t.some((t=>t.every((t=>this.selectedOptions.some((s=>s.id===t))))))}else this.hasSubscribedOptions=!(!this.subscribedOptions||"null"===this.subscribedOptions||"[]"===this.subscribedOptions)&&JSON.parse(this.subscribedOptions).some((t=>t.every((t=>this.selectedOptions.some((s=>s.id===t))))))}))}componentDidRender(){!this.orderOptionsGateAttached&&this.productId&&salla.config.get("store.settings.order_options.mandatory",!1)&&u.attach(this.host,this.productId)&&(this.orderOptionsGateAttached=!0),!this.passedLabel||this.supportStickyBar&&!this.isDesktopViewport?(this.btn?.setText(this.getLabel()),salla.lang.onLoaded((()=>this.btn?.setText(this.getLabel())))):this.btn?.setText(this.passedLabel)}disconnectedCallback(){this.viewportMediaQuery?.removeEventListener("change",this.onViewportChange)}get host(){return e(this)}};m.style=":host{display:block}salla-add-product-button[width=wide]{width:100%}";const y=class{constructor(s){t(this,s),this.limit=3,this.recommendations=[],this.selectedIds=new Set,this.isLoading=!0,this.canRender=!0,this.isAdding=!1,this.title=salla.lang.get("pages.products.bought_together_title"),this.subtitle=salla.lang.get("pages.products.bought_together_subtitle"),this.buyTogetherFor=salla.lang.get("pages.products.buy_together_for"),this.resolvedProductId=0,this.listViewTracked=!1,salla.lang.onLoaded((()=>{this.title=salla.lang.get("pages.products.bought_together_title"),this.subtitle=salla.lang.get("pages.products.bought_together_subtitle"),this.buyTogetherFor=salla.lang.get("pages.products.buy_together_for")}))}componentWillLoad(){salla.onReady().then((()=>{if(!salla.config.get("store.settings.product.bought_together"))return void(this.canRender=!1);const t=salla.config.get("page.id");if(t)return this.resolvedProductId=t,r(String(t));this.canRender=!1})).then((t=>{if(!t?.length)return void(this.canRender=!1);const s=[String(this.resolvedProductId),...t.slice(0,this.limit)];return salla.product.fetch({source:"selected",source_value:s})})).then((t=>{if(!t)return;const s=t?.data??[];if(!s.length)return void(this.canRender=!1);const i=s.find((t=>String(t.id)===String(this.resolvedProductId))),a=s.filter((t=>String(t.id)!==String(this.resolvedProductId)));a.length?(this.recommendations=i?[i,...a]:a,this.selectedIds=new Set(this.recommendations.map((t=>t.id)))):this.canRender=!1})).catch((()=>{this.canRender=!1})).finally((()=>{this.isLoading=!1}))}componentDidRender(){!this.recommendations.length||this.listViewTracked||this.intersectionObserver||(this.intersectionObserver=new IntersectionObserver((t=>{t.some((t=>t.isIntersecting))&&(this.listViewTracked=!0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.emitListViewed())}),{threshold:.1}),this.intersectionObserver.observe(this.el))}disconnectedCallback(){this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0}emitListViewed(){const t=this.recommendations.filter((t=>!this.isMainProduct(t.id)));salla.event.emit("salla-bought-together::list.viewed",{products:t})}isMainProduct(t){return String(t)===String(this.resolvedProductId)}recommendedPosition(t){const s=this.recommendations.filter((t=>!this.isMainProduct(t.id))).findIndex((s=>String(s.id)===String(t)));return-1===s?-1:s+1}emitProductClicked(t,s){salla.event.emit("salla-bought-together::product.clicked",[{product:t,position:s}])}toggleProduct(t){const s=new Set(this.selectedIds);s.has(t)?s.delete(t):s.add(t),this.selectedIds=s}get totalPrice(){const t=this.recommendations.filter((t=>this.selectedIds.has(t.id))).reduce(((t,s)=>t+(s.price??0)),0),s=salla.config.get("store.currency.decimals")??2,i=Math.pow(10,s);return salla.money(Math.round(t*i)/i)}async addSelectedToCart(){if(this.isAdding||!this.selectedIds.size)return;this.isAdding=!0;let t=!1;try{for(const s of Array.from(this.selectedIds))try{salla.cart?.api&&(salla.cart.api.addToCartSource="pdp_fbt");const t=await salla.cart.addItem({id:s,endpoint:"quickAdd",source:"pdp_fbt"}),i=this.recommendations.find((t=>t.id===s));if(i){const a=this.isMainProduct(s)?0:this.recommendedPosition(s),e=t?.data?.items?.find((t=>String(t.product_id)===String(i.id)))??t?.data?.items?.slice(-1)[0];salla.event.emit("salla-bought-together::product.added",[{product:i,position:a,cartItem:e,cartId:t?.data?.id}])}}catch(s){salla.log(s),t=!0}t&&salla.error(salla.lang.get("common.messages.error"))}finally{this.isAdding=!1}}getSkeletonView(){return i(a,{class:"s-bought-together-entry"},i("div",{class:"s-bought-together-skeleton"},i("div",{class:"s-bought-together-skeleton-header"},i("salla-skeleton",{height:"16px",width:"35%"}),i("salla-skeleton",{height:"10px",width:"60%"})),Array(4).fill(null).map(((t,s)=>i("div",{key:s,class:"s-bought-together-skeleton-item"},i("salla-skeleton",{height:"22px",width:"22px"}),i("salla-skeleton",{height:"48px",width:"48px"}),i("div",{class:"s-bought-together-skeleton-info"},i("salla-skeleton",{height:"12px",width:"55%",style:{marginBottom:"3px"}}),i("salla-skeleton",{height:"10px",width:"25%"}))))),i("salla-skeleton",{height:"44px",width:"100%"})))}render(){return this.canRender?this.isLoading?this.getSkeletonView():this.recommendations.length?i(a,{class:"s-bought-together-entry"},i("div",{class:"s-bought-together-header"},i("h3",{class:"s-bought-together-title"},this.title),i("p",{class:"s-bought-together-subtitle"},this.subtitle)),i("div",{class:"s-bought-together-list"},this.recommendations.map((t=>i("div",{key:t.id,class:"s-bought-together-item"+(this.selectedIds.has(t.id)?"":" s-bought-together-item--unchecked")},i("label",{class:"s-bought-together-checkbox-label"},i("input",{type:"checkbox",class:"s-bought-together-checkbox",checked:this.selectedIds.has(t.id),onChange:()=>this.toggleProduct(t.id)}),i("span",{class:"s-bought-together-checkmark"})),i("a",{class:"s-bought-together-item-link",href:t.url,onClick:()=>!this.isMainProduct(t.id)&&this.emitProductClicked(t,this.recommendedPosition(t.id))},i("img",{class:"s-bought-together-item-img",src:t.image?.url||salla.url.cdn("images/s-empty.png"),alt:t.image?.alt||t.name,loading:"lazy",decoding:"async",onError:t=>{t.currentTarget.onerror=null,t.currentTarget.src=salla.url.cdn("images/s-empty.png")}}),i("span",{class:"s-bought-together-item-name"},t.name)),i("span",{class:"s-bought-together-item-price",innerHTML:null!=t.price?salla.money(t.price):""}))))),i("salla-button",{class:"s-bought-together-btn",disabled:!this.selectedIds.size||this.isAdding,loading:this.isAdding,onClick:()=>this.addSelectedToCart()},i("span",{innerHTML:`${this.buyTogetherFor} ${this.totalPrice}`}))):null:null}get el(){return e(this)}};y.style=':host{display:block}.s-bought-together-checkbox:checked~.s-bought-together-checkmark{background-color:var(--color-primary, #2ECC71);border-color:var(--color-primary, #2ECC71)}.s-bought-together-checkbox:checked~.s-bought-together-checkmark::after{content:"";display:block;width:5px;height:9px;border:solid #fff;border-width:0 2px 2px 0;transform:rotate(45deg);margin-top:-2px}';const g=class{constructor(s){t(this,s),this.isUser=salla.config.isUser(),this.translationLoaded=!1,this.notifyOptionsAvailability=!1,this.isSubscribed=!1,this.handleSubmitOptions=async()=>{let t={id:this.productId};if(!this.notifyOptionsAvailability)return t;let s=document.querySelector(`salla-product-options[product-id="${this.productId}"]`),i=Object.values(await(s?.getSelectedOptionsData())||{});if(i.length&&!await(s?.reportValidity())){let t=salla.lang.get("common.messages.required_fields");throw salla.error(t),t}return t.options=[],i.forEach((s=>{s&&!isNaN(s)&&t.options.push(Number(s))})),t},this.typing=t=>{const s=t.target.nextElementSibling;t.target.classList.remove("s-has-error"),s?.classList.contains("s-product-availability-error-msg")&&(s.innerText=""),13===t.keyCode&&this.submit()},salla.lang.onLoaded((()=>{this.translationLoaded=!0,this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),this.modal?.setTitle(this.title_)})),this.productId||(this.productId=salla.config.get("page.id")),this.isUser||(this.channelsWatcher(this.channels),this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),this.host.removeAttribute("title"))}channelsWatcher(t){let s=t||salla.api.product.getAvailabilityChannels?.()||l.availabilityChannels();this.channels_=s?s.split(","):[]}get isSubscribedToProduct(){return this.isSubscribed||!this.notifyOptionsAvailability&&(!!salla.api.product.isSubscribedToAvailability?.(this.productId)||!!salla.storage.get(`product-${this.productId}-subscribed`))}openModel(){this.handleSubmitOptions().then((t=>t?this.modal.open():null))}async submit(){let t=await this.handleSubmitOptions();if(this.isUser)return salla.api.product.availabilitySubscribe(t).then((()=>this.isSubscribed=!0));if(this.channels_.includes("sms")||this.channels_.includes("whatsapp")){let{phone:s,countryCode:i}=await this.mobileInput.getValues();t.country_code=i,t.phone=s}return this.channels_.includes("email")&&""!==this.email.value&&(t.email=this.email.value),await this.validateform(),this.btn.load().then((()=>this.btn.disable())).then((()=>salla.api.product.availabilitySubscribe(t))).then((()=>{if(this.notifyOptionsAvailability){if(t.options.length){let s=salla.storage.get(`product-${this.productId}-subscribed-options`)||[],i=t.options.join(",");s.includes(i)?salla.log("already subscribed to this options"):(s.push(i),salla.storage.set(`product-${this.productId}-subscribed-options`,s),this.isSubscribed=!0)}}else this.isSubscribed=!0})).then((()=>this.btn.stop())).then((()=>this.modal.close())).catch((()=>this.btn.stop()&&this.btn.enable()))}async validateform(){try{if(this.channels_.includes("email")){const t=l.isValidEmail(this.email.value);if(t)return;!t&&this.validateField(this.email,salla.lang.get("common.elements.email_is_valid"))}if((this.channels_.includes("sms")||this.channels_.includes("whatsapp"))&&await this.mobileInput.isValid())return}catch(t){throw"Please insert required fields"}}validateField(t,s){t.classList.add("s-has-error"),t.nextElementSibling.innerText="* "+s}render(){return i(a,{key:"ccb098126e7809a6386ff38c74dfa0f00f64deeb",class:"s-product-availability-wrap"},this.isSubscribedToProduct?i("div",{class:"s-product-availability-subscribed"},i("span",{innerHTML:c,class:"s-product-availability-subs-icon"}),salla.lang.get("pages.products.notify_availability_success")):i("salla-button",{width:"wide",onClick:()=>this.isUser?this.submit():this.openModel()},salla.lang.get("pages.products.notify_availability")),this.isUser||this.isSubscribedToProduct?"":this.renderModal())}renderModal(){return i("salla-modal",{ref:t=>this.modal=t,"modal-title":this.title_,subTitle:salla.lang.get("pages.products.notify_availability_subtitle"),width:"sm"},i("span",{slot:"icon",class:"s-product-availability-header-icon",innerHTML:c}),i("div",{class:"s-product-availability-body"},this.channels_.includes("email")?[i("label",{class:"s-product-availability-label"},salla.lang.get("common.elements.email")),i("input",{class:"s-product-availability-input",onKeyDown:t=>this.typing(t),placeholder:salla.lang.get("common.elements.email_placeholder")||"your@email.com",ref:t=>this.email=t,type:"email"}),i("span",{class:"s-product-availability-error-msg"})]:"",this.channels_.includes("sms")||this.channels_.includes("whatsapp")?[i("label",{class:"s-product-availability-label"},salla.lang.get("common.elements.mobile")),i("salla-tel-input",{ref:t=>this.mobileInput=t,onKeyDown:t=>this.typing(t)})]:""),i("div",{slot:"footer",class:"s-product-availability-footer"},i("salla-button",{class:"modal-cancel-btn",width:"wide",color:"light",fill:"outline",onClick:()=>this.modal.close()},salla.lang.get("common.elements.cancel")),i("salla-button",{class:"submit-btn","loader-position":"center",width:"wide",ref:t=>this.btn=t,onClick:()=>this.submit()},salla.lang.get("common.elements.submit"))))}get host(){return e(this)}static get watchers(){return{channels:["channelsWatcher"]}}};var f,b,w;g.style="",function(t){t[t.INIT=1]="INIT",t[t.IDLE=2]="IDLE",t[t.PROCESSING_QUEUED=9]="PROCESSING_QUEUED",t[t.PROCESSING=3]="PROCESSING",t[t.PROCESSING_COMPLETE=5]="PROCESSING_COMPLETE",t[t.PROCESSING_ERROR=6]="PROCESSING_ERROR",t[t.PROCESSING_REVERT_ERROR=10]="PROCESSING_REVERT_ERROR",t[t.LOADING=7]="LOADING",t[t.LOAD_ERROR=8]="LOAD_ERROR"}(f||(f={})),function(t){t[t.EMPTY=0]="EMPTY",t[t.IDLE=1]="IDLE",t[t.ERROR=2]="ERROR",t[t.BUSY=3]="BUSY",t[t.READY=4]="READY"}(b||(b={})),function(t){t[t.INPUT=1]="INPUT",t[t.LIMBO=2]="LIMBO",t[t.LOCAL=3]="LOCAL"}(w||(w={}));const v=class{constructor(a){if(t(this,a),this.changed=s(this,"changed"),this.fileTypes={pdf:"application/pdf",png:"image/png",jpg:"image/jpeg",word:"application/doc,application/ms-doc,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",exl:"application/excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",txt:"text/plain"},this.outOfStockText="",this.donationAmount=salla.lang.get("pages.products.donation_amount"),this.selectDonationAmount=salla.lang.getWithDefault("pages.products.select_donation_amount","تحديد مبلغ التبرع"),this.selectAmount=salla.lang.getWithDefault("pages.products.select_amount","اختر المبلغ"),this.isCustomDonation=!1,this.selectedOptions=[],this.canDisabled=!1,this.disableCardValue=!0,this.availableDigitalCardValues=[],this.userInitiatedValidation=!1,this.isCartMode=!1,this.availabilityMap={},this.productAvailable=!1,this.outSkus=[],this.ignoreDefaultCardValue=!1,this.productId=salla.config.get("page.id"),this.noPadding=!1,this.handleDonationOptions=(t,s,i)=>{if("custom"===s&&"input"===i){const s=t.target;return salla.helpers.inputDigitsOnly(s),salla.event.emit("product-options::donation-changed",{id:this.productId,price:s.value}),void s.dispatchEvent(new window.Event("change",{bubbles:!0}))}const a="option"===i?String(t.target?.value??""):"";if("option"===i&&"custom"===s&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()),this.isCustomDonation="custom"===a,this.donationInput){if("custom"===a?(this.donationInput.value="",this.donationInput.focus()):this.donationInput.value=a,"custom"===s)return;salla.event.emit("product-options::donation-changed",{id:this.productId,price:a})}},this.hideLabel=t=>!(t.type!==d.DONATION||!t.donation||t.donation.can_donate),this.getExpireDonationMessage=t=>{if(!t.donation)return;const s=t.donation.target_amount<=t.donation.collected_amount;return i("div",{class:{"s-product-options-donation-message":!0,"s-product-options-donation-completed":s,"s-product-options-donation-expired":!s}},i("p",null,t.donation.target_message),i("span",{innerHTML:s?salla.money(t.donation.target_amount):""}))},salla.lang.onLoaded((()=>{this.outOfStockText=salla.lang.get("pages.products.out_of_stock"),this.donationAmount=salla.lang.get("pages.products.donation_amount"),this.selectDonationAmount=salla.lang.getWithDefault("pages.products.select_donation_amount","تحديد مبلغ التبرع"),this.selectAmount=salla.lang.getWithDefault("pages.products.select_amount","اختر المبلغ")})),this.options)try{return void this.setOptionsData(Array.isArray(this.options)?this.options:JSON.parse(this.options))}catch(t){salla.log("Bad json passed via options prop")}Array.isArray(this.optionsData)||(salla.log("Options is not an array[] ---\x3e ",this.optionsData),this.setOptionsData([])),this.productId&&!salla.url.is_page("cart")&&salla.api.product.getDetails(this.productId,["options"]).then((t=>{this.productAvailable=!t.data.is_out_of_stock,this.setOptionsData(t.data.options)}))}async setOptionsData(t){this.optionsData=t,this.outSkus=[],this.optionsData[0]?.details?.forEach((t=>{Object.entries(t.skus_availability||{}).filter((([,t])=>!t)).forEach((([t])=>this.outSkus.push(Number(t))))})),this.fillSelectedOptions(),this.computeAvailability()}async getOptionsData(){return this.optionsData}async getSelectedOptionsData(){const t={},s=this.host.getElementSallaData(),i=void 0!==this.bundleContext?this.bundleContext:null;return s.forEach(((s,a)=>{if(i){if(a.startsWith("bundle[")&&a.includes("[options][")){const i=a.split("[options][")[1].replace("]","");t[i]=s}}else a.startsWith("options[")&&(t[a.replace("options[","").replace("]","")]=s)})),t}async reportValidity(){const t=this.host.querySelectorAll("[required]");let s=!0;for(let i=0;i<t.length;i++){const a=t[i];a.disabled||a.closest(".hidden")||"reportValidity"in a&&!a.reportValidity()&&(s=!1)}return s}async hasOutOfStockOption(){return this.selectedOptions.some((t=>t.is_out))||this.selectedSkus?.length&&this.selectedSkus?.every((t=>this.outSkus.includes(t)))}async getSelectedOptions(){return this.selectedOptions}async getOption(t){return this.optionsData.find((s=>s.id===t))}invalidHandler(t,s){const i=t.target.closest(".s-product-options-option");i.classList.contains("s-product-options-option-error")||i.classList.add("s-product-options-option-error"),!this.userInitiatedValidation&&!salla.helpers.isIOSDevice()||salla.url.is_page("cart")||this.host.querySelector(".s-product-options-option-error")===i&&this.scrollToElement(i)}scrollToElement(t){t&&t.scrollIntoView({behavior:"smooth",block:"center"})}changedHandler(t,s,i=!0){const a={event:t,option:s,detail:null,productId:this.productId};if(s.details){const i=s.details.find((s=>Number(s.id)===Number(t.target.value)));a.detail=i}"country"===s.type&&this.handleCountryOptionChange(t,a.detail);const e=t.target.closest(".s-product-options-option");(t.target.value||(s.type===d.FILE||s.type===d.IMAGE)&&"added"===t.type||s.type===d.MAP&&"selected"===t.type&&t.target.lat&&t.target.lng)&&setTimeout((()=>{e.classList.remove("s-product-options-option-error")}),200),s.type===d.DONATION&&salla.event.emit("product-options::donation-changed",{id:this.productId,price:t.target.value}),this.setSelectedSkus(),this.handleRequiredMultipleOptions(s);const o=this.selectedOptions.findIndex((t=>t.option_id===a.option.id));if(a.option.type===d.MULTIPLE_OPTIONS){const t=this.selectedOptions.findIndex((t=>t.option_id===a.option.id&&t?.id===a.detail?.id));t>-1?this.selectedOptions.splice(t,1):this.selectedOptions.push({...a.detail,option_id:a.option.id})}else a.detail&&0!==Object.keys(a.detail).length?o>-1?this.selectedOptions[o]={...a.detail,option_id:a.option.id}:this.selectedOptions.push({...a.detail,option_id:a.option.id}):o>-1&&this.selectedOptions.splice(o,1);this.optionsData=this.optionsData.map((t=>t.id===a.option.id?{...t,details:t.details.map((t=>({...t,is_selected:a.option.type===d.MULTIPLE_OPTIONS?this.selectedOptions.some((s=>s.id===t.id)):Number(t.id)===Number(a.detail?.id),value:a.detail?.value})))}:t)),this.pruneInvisibleConditionalSelections(),this.setSelectedSkus(),requestAnimationFrame((()=>{this.optionsData?.filter((t=>t.type===d.MULTIPLE_OPTIONS&&t.required)).forEach((t=>this.handleRequiredMultipleOptions(t)))})),i&&(this.changed.emit(a),salla.event.emit("product-options::change",a))}setSelectedSkus(){this.selectedSkus=this.selectedOptions.map((t=>Object.keys(t.skus_availability||{}))).reduce(((t,s)=>t.filter((t=>s.includes(t)))),[]).map((t=>Number(t))),this.computeAvailability()}handleRequiredMultipleOptions(t){if(t.type!==d.MULTIPLE_OPTIONS||!t.required)return;const s=this.host.querySelector(`[data-option-id="${t.id}"]`);if(!s)return;const i=s.querySelectorAll("input:checked").length;s.querySelectorAll("input").forEach((t=>t.toggleAttribute("required",!i)))}pruneInvisibleConditionalSelections(){const t=Math.max(1,this.optionsData.length);for(let s=0;s<t;s++){let t=!1;for(const s of this.optionsData){const i=s.visibility_condition;if(!i)continue;const a=this.selectedOptions.filter((t=>t.option_id===i.option)).map((t=>String(t.id))).includes(String(i.value));("="===i.operator?a:!a)||this.clearStaleOption(s.id)&&(t=!0)}if(!t)break}}clearStaleOption(t){const s=this.optionsData.find((s=>s.id===t));if(!s)return!1;const i=this.selectedOptions.length;this.selectedOptions=this.selectedOptions.filter((s=>s.option_id!==t));const a=this.selectedOptions.length!==i,e=null!=s.value&&String(s.value).length>0,o=s.details?.some((t=>t.is_selected))??!1;return!!(a||e||o)&&(this.optionsData=this.optionsData.map((s=>s.id!==t?s:{...s,value:void 0,details:s.details?.map((t=>({...t,is_selected:!1})))??s.details})),!0)}getLatLng(t,s){return t?t.split(",")["lat"===s?0:1]:""}getDisplayForType(t){return this[`${t.type}Option`]?this[`${t.type}Option`](t):t.type===d.COLOR_PICKER?this.colorPickerOption(t):t.type===d.MULTIPLE_OPTIONS?this.multipleOptions(t):t.type===d.SINGLE_OPTION?this.singleOption(t):t.type===d.RADIO?this.radioOption(t):t.type===d.DIGITAL_CARD_VALUE?this.digitalCardValuesOption(t):t.type===d.COUNTRY?this.countryOption(t):t.type===d.BOOKING&&salla.url.is_page("cart")?i("salla-booking-field",{onInvalidInput:s=>this.invalidHandler(s,t),option:t,productId:t.value}):(salla.log(`Couldn't find options type(${t.type})😢`),"")}getOptionShownWhen(t){return t.visibility_condition?{"data-show-when":`options[${t.visibility_condition.option}] ${t.visibility_condition.operator} ${t.visibility_condition.value}`}:{}}getAvailableDigitalCardSKUs(t){const s=this.optionsData.find((({type:t})=>"digital-code-value"===t));if(!s)throw new Error("product-options:: No digital card options found");const i=Object.keys(t.skus_availability).filter((s=>!1===t.skus_availability[s]));this.availableDigitalCardValues=s.details.filter((t=>!Object.keys(t.skus_availability).filter((t=>i.includes(t))).length))}handleCountryOptionChange(t,s){t.stopImmediatePropagation(),this.ignoreDefaultCardValue=!0;const i=this.host.querySelector("input[data-code-value]:checked");if(i&&(i.checked=!1),!this.optionsData.find((({type:t})=>"digital-code-value"===t)))throw new Error("product-options:: No digital card options found");this.getAvailableDigitalCardSKUs(s)}getSelectedDigitalCardOptions(t){const s=t.details.find((t=>t.is_selected)),i=t.details.find((t=>!!t.is_default))||t.details[0];if(["digital-code-value","country"].includes(t.type))return s||i}async componentWillLoad(){if(salla.url.is_page("cart")&&(this.disableCardValue=!1,this.fillSelectedOptions()),this.config)try{this.optionConfig="string"==typeof this.config?JSON.parse(this.config):this.config}catch(t){console.error("Failed to parse JSON in config prop:",t)}if(this.optionsData.filter((({type:t})=>["country","digital-card-value"].includes(t))).length>0&&salla.url.is_page("cart")){const t=this.optionsData.find((t=>"country"===t.type)),s=t&&this.getSelectedDigitalCardOptions(t);s&&this.getAvailableDigitalCardSKUs(s)}return this.outOfStockText=salla.lang.get("pages.products.out_of_stock"),this.computeAvailability(),await salla.onReady(),this.canDisabled=!salla.config.get("store.settings.product.notify_options_availability")||salla.url.is_page("cart"),this.pasteHandler=this.handlePaste.bind(this),document.addEventListener("paste",this.pasteHandler),!salla.storage.get("cart.id")&&this.optionsData.some((t=>["file","image"].includes(t.type)))?salla.api.cart.getCurrentCartId(!1,"salla-product-options"):null}disconnectedCallback(){this.pasteHandler&&document.removeEventListener("paste",this.pasteHandler)}handlePaste(t){const s=t.target;if(!(Salla.helpers.isAppleDevice()&&(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement)&&s.classList.contains("s-form-control")&&this.host.contains(s)))return;t.preventDefault();const i=t.clipboardData?.getData("text")||"",a=s.selectionStart,e=s.selectionEnd,o=s.value.slice(0,a)+i+s.value.slice(e);s.value=o,s.setSelectionRange(a+i.length,a+i.length);try{s.dispatchEvent(new window.Event("change",{bubbles:!0}))}catch(t){Salla.log("Error on change")}}hideDigitalCardsOptions(t){return this.disableCardValue&&t.type===d.DIGITAL_CARD_VALUE&&!salla.url.is_page("cart")}render(){if(0!==this.optionsData?.length)return i(a,{class:{"s-product-options-wrapper":!0,"s-product-options-no-padding":this.noPadding}},i("salla-conditional-fields",null,this.optionsData.map((t=>i("div",{key:t.id,class:"s-product-options-option-container"+(t.visibility_condition||this.hideDigitalCardsOptions(t)?" hidden":""),"data-option-id":t.id,...this.getOptionShownWhen(t)},"splitter"===t.name?this.splitterOption():i("div",{class:{"s-product-options-option":!0,"s-product-options-option-booking":t.type===d.BOOKING&&salla.url.is_page("cart")},"data-option-type":t.type,"data-option-required":`${t.required}`},i("label",{htmlFor:this.generateInputId(t.id),class:"s-product-options-option-label "+(this.hideLabel(t)?"s-product-options-option-label-hidden":"")},i("b",null,t.name,t.required&&i("span",null," * ")," "),i("small",null,t.placeholder)),i("div",{class:"s-product-options-option-content "+(this.hideLabel(t)||t.type===d.BOOKING&&salla.url.is_page("cart")?"s-product-options-option-content-full-width":"")},this.getDisplayForType(t))))))))}generateUniqueKey(t){const s=this.bundleContext;let i=this.uniqueKey?`${t}-${this.uniqueKey}`:t;if(s)try{const t="string"==typeof s?JSON.parse(s):s,{sectionId:a,productId:e}=t;i=`${i}-bundle-${a}-${e}`}catch(t){}return i}generateInputId(t){return this.generateUniqueKey(`option-${t}`)}generateInputName(t){const s=this.bundleContext,i=t.toString();if(s)try{const t="string"==typeof s?JSON.parse(s):s,{sectionId:a,productId:e}=t;return`bundle[${a}][${e}][options][${i}]`}catch(t){return`options[${i}]`}return`options[${i}]`}fillSelectedOptions(){this.selectedOptions=this.optionsData.reduce(((t,s)=>{const i=(s.details??[]).filter((t=>t.is_selected)).map((t=>({...t,option_id:s.id})));return t.concat(i)}),[])}async seedSelectedOptions(){this.fillSelectedOptions(),requestAnimationFrame((()=>{this.optionsData?.filter((t=>t.type===d.MULTIPLE_OPTIONS&&t.required)).forEach((t=>this.handleRequiredMultipleOptions(t)))}))}async componentDidLoad(){if(!this.optionsData?.length)return;await Salla.hooks.registerComponent("salla-product-options",this);const t=this.optionsData.find((t=>t.type===d.DONATION))?.details?.find((t=>t.is_selected));if(t&&setTimeout((()=>{salla.event.emit("product-options::donation-changed",{id:this.productId,price:t.additional_price})}),1e3),!salla.url.is_page("cart")&&!this.isCartMode){const t=[d.SINGLE_OPTION,d.MULTIPLE_OPTIONS,d.COLOR,d.THUMBNAIL,d.DONATION,d.DIGITAL_CARD_VALUE,d.COUNTRY];this.optionsData.some((s=>t.includes(s.type)&&s.details?.some((t=>t.is_selected))))&&requestAnimationFrame((()=>{try{const t=this.host.closest("form");if(!t)return;const s=new FormData(t),i=s.get("id")||s.get("product_id");if(i&&String(i)!==String(this.productId))return;salla.product.getPrice(s)}catch(t){salla.log("Error updating price for pre-selected options:",t)}}))}}async enterCartMode(){this.isCartMode=!0,this.disableCardValue=!1,this.canDisabled=!0,this.fillSelectedOptions(),this.computeAvailability()}async enableUserInitiatedValidation(){this.userInitiatedValidation=!0}async validateAndScroll(){return await this.enableUserInitiatedValidation(),this.reportValidity()}donationOption(t,s){return i("div",{class:"s-product-options-donation-wrapper"},t.donation?.can_donate?[t.donation?i("div",{key:t.id,class:"s-product-options-donation-progress"},i("salla-progress-bar",{donation:t.donation})):"",t.details.length?[i("h4",{key:t.id},this.selectAmount),i("div",{key:t.id,class:"s-product-options-donation-options"},t.details.map(((s,a)=>i("div",{key:t.id,class:"s-product-options-donation-options-item"},i("input",{id:this.generateUniqueKey(`donation-option-${a}`),type:"radio",name:"donating_option",checked:s.is_selected,value:s.additional_price,onChange:i=>this.handleDonationOptions(i,s,"option",t)}),i("label",{htmlFor:this.generateUniqueKey(`donation-option-${a}`)},i("span",{innerHTML:salla.money(s.name)}))))),t.donation?.custom_amount_enabled?i("div",{class:"s-product-options-donation-options-item"},i("input",{id:this.generateUniqueKey("donation-option-custom"),type:"radio",name:"donating_option",value:"custom",onChange:s=>this.handleDonationOptions(s,"custom","option",t)}),i("label",{htmlFor:this.generateUniqueKey("donation-option-custom")},i("span",null," ",this.selectDonationAmount," "))):"")]:"",i("div",{key:t.id,class:{"s-product-options-donation-input-group":!0,shown:!t.details.length||t.details.length&&this.isCustomDonation}},i("input",{type:"text",id:"donating-amount",name:"donation_amount",class:"s-form-control",ref:t=>{this.donationInput=t},value:t.details.length&&t.details.some((t=>t.is_selected))?t.details.find((t=>t.is_selected)).additional_price:t.value,placeholder:t.placeholder,onInput:s=>this.handleDonationOptions(s,"custom","input",t),onBlur:s=>this.changedHandler(s,t),onInvalid:s=>this.invalidHandler(s,t)}),i("span",{class:"s-product-options-donation-amount-currency"},salla.config.currency(salla.config.get("user.currency_code")).symbol))]:this.getExpireDonationMessage(t))}fileUploader(t,s=null){return i("salla-file-upload",{...s||{},"payload-name":"file",value:t.value,"instant-upload":!0,name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,height:"120px",onAdded:s=>{this.changedHandler(s,t,!(s.detail?.file?.origin===w.LOCAL))},url:salla.cart.api.getUploadImageEndpoint(),"form-data":{cart_item_id:this.productId,product_id:this.productId},onInvalidInput:s=>this.invalidHandler(s,t),class:{"s-product-options-image-input":!0,required:t.required}},i("div",{class:"s-product-options-filepond-placeholder"},i("span",{class:"s-product-options-filepond-placeholder-icon",innerHTML:s.accept?.split(",").every((t=>t.includes("image")))?p:'\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>file-upload</title>\n<path d="M21.333 24c0.341 0 0.683-0.131 0.943-0.391 0.521-0.521 0.521-1.364 0-1.885l-5.333-5.333c-0.123-0.123-0.271-0.22-0.433-0.288-0.327-0.135-0.693-0.135-1.019 0-0.163 0.068-0.311 0.165-0.433 0.288l-5.333 5.333c-0.521 0.521-0.521 1.364 0 1.885s1.364 0.521 1.885 0l3.057-3.057v10.115c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-10.115l3.057 3.057c0.26 0.26 0.601 0.391 0.943 0.391zM28.943 9.724l-9.333-9.333c-0.249-0.251-0.589-0.391-0.943-0.391h-12c-2.205 0-4 1.795-4 4v24c0 2.205 1.795 4 4 4h4c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333h-4c-0.735 0-1.333-0.599-1.333-1.333v-24c0-0.735 0.599-1.333 1.333-1.333h11.448l8.552 8.552v16.781c0 0.735-0.599 1.333-1.333 1.333h-4c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333h4c2.205 0 4-1.795 4-4v-17.333c0-0.353-0.14-0.693-0.391-0.943z"></path>\n</svg>\n'}),i("p",{class:"s-product-options-filepond-placeholder-text"},salla.lang.get("common.uploader.drag_and_drop")),i("span",{class:"filepond--label-action"},salla.lang.get("common.uploader.browse"))))}imageOption(t){return this.fileUploader(t,{accept:"image/png,image/jpeg,image/jpg,image/gif"})}fileOption(t){const s=t.details.map((t=>this.fileTypes[t.name])).filter(Boolean);return s?.length?this.fileUploader(t,{accept:s.join(",")}):"File types not selected."}numberOption(t){return i("input",{type:"text",value:t.value,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onBlur:s=>this.changedHandler(s,t),onInvalid:s=>this.invalidHandler(s,t),onInput:t=>salla.helpers.inputDigitsOnly(t.target)})}splitterOption(){return i("div",{class:"s-product-options-splitter"})}textOption(t){return i("div",{class:"s-product-options-text"},i("input",{type:"text",value:t.value,maxLength:t?.length,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)}))}textareaOption(t){return i("div",{class:"s-product-options-textarea"},i("div",{class:"mt-1"},i("textarea",{rows:4,value:t.value,maxLength:t?.length,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)})))}mapOption(t){return i("salla-map",{zoom:15,lat:this.getLatLng(t.value,"lat"),lng:this.getLatLng(t.value,"lng"),name:this.generateInputName(t.id),searchable:!0,required:t.required,onInvalidInput:s=>this.invalidHandler(s,t),onSelected:s=>this.changedHandler(s,t)})}colorPickerOption(t){return i("salla-color-picker",{onSubmitted:s=>this.changedHandler(s,t),name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,onInvalidInput:s=>this.invalidHandler(s,t),color:t.value})}timeOption(t){return i("salla-datetime-picker",{noCalendar:!0,enableTime:!0,dateFormat:"h:i K",value:t.value,placeholder:t.name,required:!t.visibility_condition&&t.required,name:this.generateInputName(t.id),class:"s-product-options-time-element",onInvalidInput:s=>this.invalidHandler(s,t),onPicked:s=>this.changedHandler(s,t)})}dateOption(t){return i("div",{class:"s-product-options-date-element"},i("salla-datetime-picker",{value:t.value,placeholder:t.name,required:!t.visibility_condition&&t.required,minDate:new Date,name:this.generateInputName(t.id),onInvalidInput:s=>this.invalidHandler(s,t),onPicked:s=>this.changedHandler(s,t)}))}datetimeOption(t){return i("div",{class:"s-product-options-datetime-element"},i("salla-datetime-picker",{enableTime:!0,value:t.value,dateFormat:"Y-m-d G:i:K",placeholder:t.name,required:!t.visibility_condition&&t.required,name:this.generateInputName(t.id),maxDate:t.to_date_time,minDate:t.from_date_time,onInvalidInput:s=>this.invalidHandler(s,t),onPicked:s=>this.changedHandler(s,t)}))}getOptionDetailName(t,s=!0,i,a){let e;if(i&&i===d.COLOR&&(e=t.name+(s&&this.isOptionDetailOut(t)&&!salla.url.is_page("cart")&&!this.hideOutLabel?` <br/> <p> ${this.outOfStockText} </p>`:"")+(t.additional_price?` <p> (${salla.money(t.additional_price,!1)}) </p>`:"")),!e){const i=(s&&this.isOptionDetailOut(t)&&!salla.url.is_page("cart")&&!this.hideOutLabel?` - ${this.outOfStockText}`:"")+(t.additional_price?` (${salla.money(t.additional_price,!1)})`:"");if("price"===a){const s=salla.helpers.digitsOnly(t.name),a=Number(s);return s&&Number.isFinite(a)?salla.money(a,!0)+i:i}e=t.name+i}return e.replace("<i class=sicon-sar></i>",salla.config.currency()?.symbol||"ر.س")}computeAvailability(){this.availabilityMap=function(t,s,i=!0){const a={};if(!t?.length)return a;const e=t.filter((t=>t.details?.some((t=>t.skus_availability&&Object.keys(t.skus_availability).length>0)))),o=e.length<=1,n=new Set(t.filter((t=>!1===t.is_advance)).map((t=>t.id)));if(0===e.length){for(const s of t)for(const t of s.details)a[t.id]=t.is_out?"out_of_stock":"available";return a}const l=e.some((t=>t.details?.some((t=>t.skus_availability&&Object.values(t.skus_availability).some(Boolean))))),r=i&&!l;for(const t of e){const i=s.filter((s=>s.option_id!==t.id));for(const s of t.details){const t=s.skus_availability;if(!t||!Object.keys(t).length){a[s.id]=s.is_out?"out_of_stock":"available";continue}const e=Object.keys(t).map(Number),l=e.some((s=>t[s]));if(o||0===i.length){a[s.id]=!l&&r||l?"available":"out_of_stock";continue}let c=e;for(const t of i){if(n.has(t.option_id))continue;const s=new Set(Object.keys(t.skus_availability||{}).map(Number));c=c.filter((t=>s.has(t)))}if(!c.length){a[s.id]=r?"available":"impossible";continue}const d=c.some((s=>t[s]));a[s.id]=!d&&r||d?"available":"out_of_stock"}}return a}(this.optionsData||[],this.selectedOptions||[],this.productAvailable)}isOptionDetailOut(t){const s=this.availabilityMap[t.id];return void 0!==s?"available"!==s:!!t.is_out}renderInput(t,s,a,e,o,n){const l=this.generateUniqueKey(`${t}-${a.id}-${s.id}`),r=this.isOptionDetailOut(s),c=this.getOptionDetailName(s,!0,a.type,a.format),d={"s-product-options-grid-mode-span":n,"s-product-options-disabled":this.canDisabled&&r};return i("label",{class:{"s-product-options-disabled":this.canDisabled&&r,"s-product-options-option-stock-out":r}},i("input",{id:l,type:t,name:o,value:s.id,disabled:this.canDisabled&&r,required:e,checked:s.is_selected,onInvalid:t=>this.invalidHandler(t,a),onChange:t=>this.changedHandler(t,a)}),"price"===a.format?i("div",{class:d,innerHTML:c}):i("div",{class:d},c))}renderOptionDetails(t,s,i,a=!1){const e=this.generateInputName(s.id),o="radio"===t?e:`${e}[]`;return s?.details.map((e=>this.renderInput(t,e,s,i,o,a)))}renderSelect(t){return i("div",null,i("select",{id:this.generateInputId(t.id),name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,class:"s-form-control",onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)},i("option",{value:""},t.placeholder),t?.details.map((t=>i("option",{key:t.id,value:t.id,disabled:this.canDisabled&&this.isOptionDetailOut(t),selected:t.is_selected},this.getOptionDetailName(t))))))}renderButtonStyle(t,s,a){return i("div",{class:"s-product-options-grid-mode"},this.renderOptionDetails(t,s,a,!0))}singleOption(t){return"button"===this.optionConfig?.["single-option"]?.type||t.type===d.SINGLE_OPTION&&"price"===t.format?this.renderButtonStyle("radio",t,!t.visibility_condition&&t.required):this.renderSelect(t)}multipleOptions(t){const s="button"===this.optionConfig?.["multiple-option"]?.type,a=t.required&&!t.details.some((t=>t.is_selected))&&!t.visibility_condition;return s?this.renderButtonStyle("checkbox",t,a):i("div",{class:{"s-product-options-multiple-options-wrapper":!0,required:t.required}},this.renderOptionDetails("checkbox",t,a))}radioOption(t){return this.singleOption(t)}colorOption(t){return i("fieldset",{class:"s-product-options-colors-wrapper"},t?.details.map((s=>{const a=this.isOptionDetailOut(s);return i("div",{class:{"s-product-options-colors-item":!0,"s-product-options-option-stock-out":a},key:s.id},i("input",{type:"radio",value:s.id,required:!t.visibility_condition&&t.required,checked:s.is_selected,name:this.generateInputName(t.id),disabled:this.canDisabled&&a,id:this.generateUniqueKey(`color-${this.productId}-${t.id}-${s.id}`),onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t),"data-img-id":s.option_value}),i("label",{htmlFor:this.generateUniqueKey(`color-${this.productId}-${t.id}-${s.id}`),"data-img-id":s.option_value},i("span",{style:{backgroundColor:s.color}}),i("div",{innerHTML:this.getOptionDetailName(s,!0,t.type)})))})))}thumbnailOption(t){return i("div",{class:"s-product-options-thumbnails-wrapper"},t.details.map((s=>{const a=this.isOptionDetailOut(s);return i("div",{key:s.id,class:{"s-product-options-option-stock-out":a}},i("input",{type:"radio",value:s.id,"data-itemid":s.id,required:!t.visibility_condition&&t.required,checked:s.is_selected,name:this.generateInputName(t.id),"data-img-id":s.option_value,disabled:this.canDisabled&&a,id:this.generateUniqueKey(`option_${this.productId}-${t.id}_${s.id}`),onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)}),i("label",{htmlFor:this.generateUniqueKey(`option_${this.productId}-${t.id}_${s.id}`),"data-img-id":s.option_value,class:"go-to-slide"},i("img",{"data-src":s.image,src:s.image,title:s.name,alt:s.name}),i("span",{innerHTML:h,class:"s-product-options-thumbnails-icon"}),a?[i("small",{key:`badge-${s.id}`,class:"s-product-options-thumbnails-stock-badge"},this.outOfStockText),this.canDisabled?i("div",{key:`overlay-${s.id}`,class:"s-product-options-thumbnails-badge-overlay"}):""]:""),i("p",null,this.getOptionDetailName(s,!1)," "))})))}digitalCardValuesOption(t){return i("div",{class:"s-product-options-digital-card-wrapper"},this.availableDigitalCardValues.length>0?this.availableDigitalCardValues.map((s=>{const a=String(s.id);return i("label",{htmlFor:this.generateUniqueKey(a.toString()),key:a,class:"s-product-options-digital-card-option"},i("input",{type:"radio","data-code-value":!0,class:"s-form-control s-product-options-digital-card-input",value:s.id,name:this.generateInputName(t.id),id:this.generateUniqueKey(a.toString()),required:!t.visibility_condition&&t.required,onInvalid:s=>this.invalidHandler(s,t),...this.ignoreDefaultCardValue?{}:{defaultChecked:this.getSelectedDigitalCardOptions(t)?.id===s.id}}),i("span",null,s.name," ",salla.config?.currency()?.symbol))})):i("div",{class:"s-product-options-digital-card-out-of-stock"}))}countryOption(t){return i("div",{class:"s-product-options-digital-card-wrapper"},t.details.map((s=>{const a=this.isOptionDetailOut(s);return i("label",{htmlFor:this.generateUniqueKey(s.id.toString()),key:s.id,class:{"s-product-options-digital-card-option":!0,"s-product-options-digital-card-option-stock-out":a,"s-product-options-option-stock-out":a}},i("input",{id:this.generateUniqueKey(s.id.toString()),type:"radio",class:"s-form-control s-product-options-digital-card-input",value:s.id,name:this.generateInputName(t.id),disabled:this.canDisabled&&a,required:!t.visibility_condition&&t.required,onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t),onClick:()=>{this.disableCardValue=!1},...salla.url.is_page("cart")?{defaultChecked:this.getSelectedDigitalCardOptions(t)?.id===s.id}:{}}),i("img",{loading:"lazy",alt:s.code,height:24,width:24,class:"s-product-options-country-flag",src:`https://cdn.assets.salla.network/prod/admin/cp/assets/flags/1x1/${String(s.code).toLocaleLowerCase()}.svg`,onError:t=>{t.currentTarget.onerror=null,t.currentTarget.src=salla.url.cdn("images/globe.svg")}}),i("span",null,s.name))})))}get host(){return e(this)}};function k(){o.defaults.headers.common.currency=salla?.config?.get?.("user.currency_code")}v.style="";var _={request:(t,s,i,a=null,e=null)=>(k(),o.request({url:s,data:i,method:t.toLowerCase(),responseType:"json"}).then(a).catch(e)),get:(t,s=null,i=null,a)=>(k(),o.get(t,{params:a}).then(s).catch(i)),post(t,s,i=null,a=null){return this.request("post",t,s,i,a)},put(t,s,i=null,a=null){return this.request("put",t,s,i,a)},delete(t,s,i=null,a=null){return this.request("delete",t,s,i,a)},requestWithSupportAjax(t,s,i="post"){return new Promise(((a,e)=>{if(!window?.isLegacyTheme)return this.request(i,t,s,(({data:t})=>a(t)),(({response:t})=>e(t)));k(),$.ajax({url:t,method:i.toUpperCase(),data:s,headers:{currency:o.defaults.headers.common.currency},async:!1,success:function({data:t}){return a(t)},error:function({response:t}){return e(t)}})}))}},S={options:[],header:"undefined"!=typeof navigator&&"undefined"!=typeof window?[navigator.platform,navigator.userAgent,navigator.appVersion,navigator.vendor,window.opera]:[],dataos:[{name:"Windows Phone",value:"Windows Phone",version:"OS"},{name:"Windows",value:"Win",version:"NT"},{name:"iPhone",value:"iPhone",version:"OS"},{name:"iPad",value:"iPad",version:"OS"},{name:"Kindle",value:"Silk",version:"Silk"},{name:"Android",value:"Android",version:"Android"},{name:"PlayBook",value:"PlayBook",version:"OS"},{name:"BlackBerry",value:"BlackBerry",version:"/"},{name:"Macintosh",value:"Mac",version:"OS X"},{name:"Linux",value:"Linux",version:"rv"},{name:"Palm",value:"Palm",version:"PalmOS"}],databrowser:[{name:"Chrome",value:"Chrome",version:"Chrome"},{name:"Firefox",value:"Firefox",version:"Firefox"},{name:"Safari",value:"Safari",version:"Version"},{name:"Internet Explorer",value:"MSIE",version:"MSIE"},{name:"Opera",value:"Opera",version:"Opera"},{name:"BlackBerry",value:"CLDC",version:"CLDC"},{name:"Mozilla",value:"Mozilla",version:"Mozilla"}],init:function(){var t=this.header.join(" ");return{os:this.matchItem(t,this.dataos),browser:this.matchItem(t,this.databrowser)}},matchItem:function(t,s){var i,a,e,o=0,n=0;for(o=0;o<s.length;o+=1)if(new RegExp(s[o].value,"i").test(t)){if(i=new RegExp(s[o].version+"[- /:;]([\\d._]+)","i"),e="",(a=t.match(i))&&a[1]&&(a=a[1]),a)for(a=a.split(/[._]+/),n=0;n<a.length;n+=1)e+=0===n?a[n]+".":a[n];else e="0";return{name:s[o].name,version:parseFloat(e)}}return{name:"unknown",version:0}}};async function C(t,s,i=!1){if(salla.logger.log("🍏 Pay: mutateShippingContact called",s,i),t.detail.requiredShippingContactFields&&0!=t.detail.requiredShippingContactFields.length)if(i){if(salla.config.isGuest()&&salla.config.get("store.features").includes("guest-checkout")){if(!(s.emailAddress&&s.givenName&&s.familyName&&s.phoneNumber)){salla.logger.warn("🍏 Pay: Guest contact fields are required",s);const i=[];return s.emailAddress||i.push(new window.ApplePayError("shippingContactInvalid","emailAddress","Email address is required")),s.phoneNumber||i.push(new window.ApplePayError("shippingContactInvalid","phoneNumber","Phone number is required")),s.givenName&&s.familyName||i.push(new window.ApplePayError("shippingContactInvalid","name","Name is required")),void t.session.completePayment({status:t.session.STATUS_INVALID_SHIPPING_CONTACT,errors:i})}await async function(t,s){return salla.logger.log("🍏 Pay: Updating guest contact",s),new Promise(((i,a)=>{_.post(t.detail.guestContactSelected.url.replace("{id}",t.id),{email:s.emailAddress||null,first_name:s.givenName||null,last_name:s.familyName||null,phone_number:s.phoneNumber||null,country_code:s.countryCode||null},(async({data:s})=>{"function"==typeof t.detail.guestContactSelected?.onSuccess&&t.detail.guestContactSelected.onSuccess(s),i(s)}),(({response:s})=>{salla.logger.warn("🍏 Pay: Failed to update guest contact via api",s),"function"==typeof t.detail.guestContactSelected?.onFailed&&t.detail.guestContactSelected.onFailed(s),a({response:s})}))}))}(t,s)}}else if(t.detail.requiredShippingContactFields.includes("postalAddress"))return _.post(t.detail.shippingContactSelected.url.replace("{id}",t.id),{country:s.country,city:s.locality,local:s.subLocality||s.administrativeArea||s.locality,description:s.subAdministrativeArea,street:s.addressLines?.join(", ")||s.administrativeArea,country_code:s.countryCode,postal_code:s.postalCode},(async({data:s})=>{if("function"==typeof t.detail.shippingContactSelected.onSuccess&&t.detail.shippingContactSelected.onSuccess(s),t.address_id=s.data.address_id,t.shipping_methods=s.data.shipping_methods,!t.shipping_methods||t.shipping_methods&&!t.shipping_methods.length)return salla.logger.warn("🍏 Pay: We dont found any supported methods",s),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]});try{await t.selectApplePayShippingMethod(t.shipping_methods[0])}catch(s){return salla.logger.warn("Failed set the shipping details to api",s),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}try{await t.recalculateTotal()}catch(s){return salla.logger.warn("🍏 Pay: Failed recalculate total",s),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}const i={newTotal:t.prepareTotal(),newLineItems:t.prepareLineItems(),newShippingMethods:t.mappingShippingMethods(t.shipping_methods)};salla.logger.log("🍏 Pay: completeShippingContactSelection",i),t.session.completeShippingContactSelection(i)}),(({response:s})=>{salla.logger.warn("🍏 Pay: Failed add address via api",s),"function"==typeof t.detail.shippingContactSelected.onFailed&&t.detail.shippingContactSelected.onFailed(s);let i=s?.data?.error?.fields,a=function(t){return Object.entries(t).filter((([t,s])=>s&&s.length>0)).map((([t,s])=>new window.ApplePayError("shippingContactInvalid",t,s[0])))}({countryCode:i?.country_code&&i.country_code.length>0?i.country_code[0]:null,locality:i?.city&&i.city.length>0?i.city[0]:null,country:i?.country&&i.country.length>0?i.country[0]:null});0===a.length&&s?.data?.error?.message&&a.push(new window.ApplePayError("shippingContactInvalid","locality",s?.data?.error?.message)),t.session.completeShippingContactSelection({newTotal:t.prepareTotal(),newLineItems:t.prepareLineItems(),status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:a})}))}"undefined"!=typeof window&&(window.Salla=window.Salla||{},window.Salla.Payments=window.Salla.Payments||{});const P="undefined"!=typeof window?{session:null,detail:null,address_id:null,shipping_methods:[],total:void 0,request:void 0,id:void 0,countryCode:null,totals:[],shippingCompany:null,init:function(){document.removeEventListener("payments::apple-pay.start-transaction",P.startSession),Salla.event.addEventListener("payments::apple-pay.start-transaction",P.startSession)},initDefault:function(){P.detail.onError||(P.detail.onError=function(t){salla.notify.error(t)}),P.detail.authorized.onFailed||(P.detail.authorized.onFailed=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleErrorResponse(t),P.onCancel({},t.data.error.message)}),P.detail.validateMerchant.onFailed||(P.detail.validateMerchant.onFailed=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleErrorResponse({response:t}),P.onCancel({},t.data.error.message)}),P.detail.authorized.onSuccess||(P.detail.authorized.onSuccess=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleAfterResponseActions(t)})},prepareLineItems:function(){return P.detail?.items?.length||(P.detail.items=[{label:salla.lang.get("pages.cart.items_total"),amount:parseFloat(P.detail.amount).toString()}]),P.detail.items},prepareTotal:function(){return{label:window.location.hostname||"Salla",amount:parseFloat(P.detail.amount).toString()}},isPhysical:()=>P.detail?.requiredShippingContactFields?.includes("postalAddress"),startSession:async function(t){P.detail=t.detail||t,salla.log("🍏 Pay: payments::apple-pay.start-transaction",P.detail),P.initDefault();let s,i=P.getApplePaySessionVersion(),a=P.detail.supportedNetworks,e=Array.isArray(a)?[...a]:Object.values(a||{});e.length||(e=["masterCard","visa"]),5!==i||e.includes("mada")||e.push("mada"),P.request={countryCode:P.detail.countryCode||"SA",supportsCouponCode:!0,couponCode:"",currencyCode:P.detail.currency||"SAR",requiredShippingContactFields:P.detail.requiredShippingContactFields?P.detail.requiredShippingContactFields:[],merchantCapabilities:["supports3DS"],supportedNetworks:e,supportedCountries:P.detail.supportedCountries||["SA"],total:P.prepareTotal(),shippingContact:P.detail.shippingContact?P.detail.shippingContact:{},shippingMethods:P.detail.shippingMethods&&P.detail.shippingMethods.length?P.mappingShippingMethods(t.detail.shippingMethods):[],lineItems:P.prepareLineItems()},salla.log("🍏 Pay: init ",P.request),P.session=new ApplePaySession(i,P.request),P.session.onshippingcontactselected=P.onShippingContactSelected,P.session.onshippingmethodselected=P.onShippingMethodSelected,P.session.onvalidatemerchant=P.onValidateMerchant,P.session.onpaymentauthorized=P.onPaymentAuthorized,P.session.oncancel=P.onCancel,P.session.oncouponcodechanged=P.onCouponCodeChanged,P.session.onpaymentmethodselected=P.onPaymentMethodSelected,"function"==typeof P.detail.onStartedSession&&(s=P.detail.onStartedSession(P.session)),s||P.session.begin()},onPaymentMethodSelected:async t=>{if(salla.logger.log("🍏 Pay: onPaymentMethodSelected",t),P.isPhysical())salla.logger.log("🍏 Pay: completePaymentMethodSelection",{newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()}),P.session.completePaymentMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()});else try{await P.recalculateTotal();const t={newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()};salla.logger.log("🍏 Pay: completePaymentMethodSelection",t),P.session.completePaymentMethodSelection(t)}catch(t){salla.logger.warn("🍏 Pay: Failed recalculate total",t),P.session.completePaymentMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems(),status:P.session.STATUS_FAILURE,errors:[new window.ApplePayError("unknown",void 0,t?.response?.data?.error?.message||t?.response?.data?.error?.code||"Failed to recalculate total")]})}},onCouponCodeChanged:t=>(Salla.event.dispatch("payments::apple-pay.coupon.change",t),_.post(P.detail.onCouponCodeChanged.url.replace("{id}",P.id),{coupon:t.couponCode,payment_method:"apple_pay"},(async({data:t})=>{"function"==typeof P.detail.onCouponCodeChanged.onSuccess&&P.detail.onCouponCodeChanged.onSuccess(t),salla.log("🍏 Pay: Coupon applied success"),await P.recalculateTotal(),P.session.completeCouponCodeChange({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()})}),(async t=>{let s=t?.response;Salla.event.dispatch("payments::apple-pay.coupon.failed",s),"function"==typeof P.detail.onCouponCodeChanged.onFailed&&P.detail.onCouponCodeChanged.onFailed(s),await P.recalculateTotal(),P.session.completeCouponCodeChange({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems(),errors:[new window.ApplePayError("couponCodeInvalid")]})}))),onCancel:(t={},s=null)=>{P.detail.onError(s||salla.lang.get("pages.checkout.payment_failed")),Salla.event.createAndDispatch("payments::apple-pay.canceled",t)},onPaymentAuthorized:async t=>{salla.logger.log("🍏 Pay: onPaymentAuthorized",t.payment);try{await C(P,t.payment.shippingContact,!0)}catch(t){salla.logger.error("🍏 Pay: Failed to update guest contact details",t);const s=t?.response||t,i=s?.data?.error?.fields||{},a=[];return i?.email&&i.email.length>0&&a.push(new window.ApplePayError("shippingContactInvalid","emailAddress",i.email[0])),i?.phone&&i.phone.length>0&&a.push(new window.ApplePayError("shippingContactInvalid","phoneNumber",i.phone[0])),i?.first_name&&i.first_name.length>0?a.push(new window.ApplePayError("shippingContactInvalid","name",i.first_name[0])):i?.last_name&&i.last_name.length>0&&a.push(new window.ApplePayError("shippingContactInvalid","name",i.last_name[0])),0===a.length&&a.push(new window.ApplePayError("shippingContactInvalid","name",s?.data?.error?.message||s?.data?.error?.code||"Invalid shipping contact details")),Salla.event.dispatch("payments::apple-pay.authorized.failed",s),"function"==typeof P.detail.authorized.onFailed&&P.detail.authorized.onFailed(s),void P.session.completePayment({status:ApplePaySession.STATUS_INVALID_SHIPPING_CONTACT,errors:a})}Salla.event.dispatch("payments::apple-pay.authorized.init",t),_.post(P.detail.authorized.url.replace("{id}",P.id),{payment_method:"apple_pay",applepay_token:JSON.stringify(t.payment)},(({data:t})=>{Salla.event.dispatch("payments::apple-pay.authorized.success",t),"function"==typeof P.detail.authorized.onSuccess&&P.detail.authorized.onSuccess(t),P.session.completePayment(ApplePaySession.STATUS_SUCCESS)}),(t=>{let s=t?.response;Salla.event.dispatch("payments::apple-pay.authorized.failed",s),"function"==typeof P.detail.authorized.onFailed&&P.detail.authorized.onFailed(s),P.session.completePayment({status:ApplePaySession.STATUS_FAILURE,errors:[new window.ApplePayError("unknown",void 0,s?.data?.error?.message||s?.data?.error?.code||"Failed to parse authorized response")]})}))},onValidateMerchant:async t=>{try{Salla.event.dispatch("payments::apple-pay.validate-merchant.init",t);const{data:s}=await _.post(P.detail.validateMerchant.url.replace("{id}",P.id),{validation_url:t.validationURL});Salla.event.dispatch("payments::apple-pay.validate-merchant.success",s);const i=t=>{P.session.completeMerchantValidation(t)};if("function"==typeof P.detail.validateMerchant.onSuccess){const t=await P.detail.validateMerchant.onSuccess(s);if(t?.redirect)return window.location=t.redirect,P.abortValidateMerchant(t)}i(s.data)}catch(t){console.error(t),P.abortValidateMerchant(t?.response)}},abortValidateMerchant:(t=null)=>{P.abortSession(),Salla.event.dispatch("payments::apple-pay.validate-merchant.failed",t),"function"==typeof P.detail.validateMerchant.onFailed&&P.detail.validateMerchant.onFailed(t)},onShippingContactSelected:async t=>{salla.logger.log("🍏 Pay: onShippingContactSelected",t.shippingContact),await C(P,t.shippingContact)},onShippingMethodSelected:async t=>{let s=t.shippingMethod.identifier.split(","),i={ship_id:s[0],private_ship_id:void 0===s[1]?null:s[1],type:void 0===s[2]?null:s[2],route_id:void 0===s[3]?null:s[3]};if(salla.logger.log("🍏 Pay: onShippingMethodSelected",{event:t,previous:P.shippingCompany,current:i}),P.shouldUpdateShippingCompany(i))try{await P.selectApplePayShippingMethod(i),await P.recalculateTotal()}catch(t){return salla.logger.warn("🍏 Pay: Failed set the shipping details to api",t),void P.session.completeShippingMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems(),status:P.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}salla.logger.log("🍏 Pay: completeShippingMethodSelection",{newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()}),P.session.completeShippingMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()})},abortSession:()=>{P.session&&P.session.abort()},shouldUpdateShippingCompany:t=>P.shippingCompany?.ship_id!=t?.ship_id||P.shippingCompany?.private_ship_id!=t?.private_ship_id,getApplePaySessionVersion:()=>{if("sallapp"===(navigator.userAgent||navigator.vendor||window.opera))return 5;let t=S.init(),s=parseFloat(t.os.version);if("Macintosh"===t.os.name){if(s<10.142)return 1}else if(s<12.11)return 1;return 5},recalculateTotal:()=>(salla.logger.log("🍏 Pay: recalculate total"),_.get(P.detail.recalculateTotal.url.replace("{id}",P.id),(({data:t})=>{salla.logger.log("🍏 Pay: recalculate total success",t);let s=t.data.initial_data?.cart||t.data.cart,i=t.data.initial_data?.payments||t.data.payments;salla.logger.log("🍏 Pay: recalculate total success",{cart:s,payments:i}),null!=i?.gateways?.applePay?.amount?(P.detail.amount=i.gateways.applePay.amount,P.detail.currency=i.gateways.applePay.currency??P.detail.currency):P.detail.amount=i?.gateways?.applePay?.supportedMultiCurrency?s.total_in_customer_currency:s.total,P.detail.items=(s.totals||s.items).map((t=>({label:t.title,amount:"مجاني"===t.amount||"Free"===t.amount?0:t.amount.toString().replace("+","")}))),P.detail.items.pop(),P.totals=P.detail.items}),(t=>(salla.logger.warn("🍏 Pay: recalculate total failed",t),t?.response?.data?.message)))),selectApplePayShippingMethod:t=>{salla.logger.log("🍏 Pay: select shipping method ",t),P.shippingCompany=t;const s={address_id:P.address_id,company_id:t.ship_id,private_company_id:t.private_ship_id,type:t.type||void 0,route_id:t.route_id||void 0,payment_method:"apple_pay"};return _.post(P.detail.shippingMethodSelected.url.replace("{id}",P.id),s,(({data:t})=>("function"==typeof P.detail.shippingMethodSelected.onSuccess&&P.detail.shippingMethodSelected.onSuccess(t),!0)),(t=>{salla.logger.warn("🍏 Pay: Set shipping method failed",t),"function"==typeof P.detail.shippingMethodSelected.onFailed&&P.detail.shippingMethodSelected.onFailed(t);let s=t?.response?.data?.error;return s?.data?.fields?.address_id?s?.data?.fields?.address_id[0]:s?.data?.message}))},mappingShippingMethods:t=>t.map((t=>({label:t.shipping_title,amount:t.enable_free_shipping?0:t.ship_cost,detail:"",identifier:t.ship_id.toString()+(t.private_ship_id?","+t.private_ship_id.toString():"")+(t.type?","+t.type:"")+(t.route_id?","+t.route_id:"")})))}:{};"undefined"!=typeof window&&(window.SallaApplePay=P),"undefined"!=typeof window&&window.ApplePaySession?.canMakePayments()?P.init():"undefined"!=typeof document&&document.querySelectorAll("data-show-if-apple-pay-supported").forEach((t=>t.style.display="none"));const O=class{constructor(i){t(this,i),this.validationFailed=s(this,"validationFailed"),this.requireLogin=s(this,"requireLogin"),this.type="buy",this.productType="product",this.options={},this.collectedOrderOptions=[],this.optionsResolved=!1,this.applePayAmount=0,this.pendingApplePaySession=null,this.quickBuy=salla.lang.get("pages.products.buy_now"),this.handleApplePaySessionStarted=t=>!!salla.config.get("store.settings.order_options.mandatory",!1)&&!this.optionsResolved&&(this.optionsResolved=!0,this.pendingApplePaySession=t,async function(t){let s;try{s=await salla.api.withoutNotifier((()=>salla.product.api.getOrderOptions([{id:t.productId,quantity:t.quantity}])))}catch(s){return salla?.logger?.warn?.("order-options: fetch failed",s),void t.beginPendingSession()}const i=s?.data?.order_options||[];if(!i.length)return void t.beginPendingSession();t.discardPendingSession();const a=Number(t.amount)>0?Number(t.amount):Number(s?.data?.products?.[0]?.price?.amount)||0,e=function(){let t=document.querySelector("salla-order-options-modal");return t||(t=document.createElement("salla-order-options-modal"),document.body.appendChild(t)),t}();try{await e.open({orderOptions:i,basePrice:a,paymentMode:"apple-pay",onSubmit:t.onSubmit})}catch{}}({productId:this.productId,amount:Number(this.amount),quantity:this.getSelectedQuantity(),beginPendingSession:()=>{this.pendingApplePaySession?.begin(),this.pendingApplePaySession=null},discardPendingSession:()=>{this.pendingApplePaySession=null},onSubmit:(t,s)=>{this.collectedOrderOptions=t,this.applePayAmount=s,this.settlePayment()}}),!0),salla.lang.onLoaded((()=>{this.quickBuy=salla.lang.get("pages.products.buy_now")}))}quickBuyHandler(){if(salla.config.isGuest()&&!this.isGuestCheckout())return this.requireLogin.emit({productId:this.productId}),void salla.api.auth.requireLoginThen("salla-quick-buy::user.logged-in",(()=>this.quickBuyHandler()));this.validatePdpOptionsSync()&&(this.optionsResolved=!1,this.collectedOrderOptions=[],this.applePayAmount=0,this.settlePayment())}validatePdpOptionsSync(){return!!function(t){const s=document.querySelector(`salla-product-options[product-id="${t}"]`);if(!s)return!0;const i=s.querySelectorAll("[required]");let a=!0;return i.forEach((t=>{t.disabled||t.closest(".hidden")||"reportValidity"in t&&!t.reportValidity()&&(a=!1)})),a}(this.productId)||(this.validationFailed.emit({productId:this.productId}),salla.error(salla.lang.get("common.messages.required_fields")),!1)}getSelectedQuantity(){try{const t=this.host.getElementSallaData?.(),s=Number(t instanceof FormData?t.get("quantity"):t?.quantity);return Number.isFinite(s)&&s>0?s:1}catch{return 1}}async settlePayment(){let t=this.host.getElementSallaData();if(function(t,s){s.length&&(t&&"function"==typeof t.append?s.forEach(((s,i)=>{t.append(`order_options[${i}][id]`,String(s.id)),t.append(`order_options[${i}][value]`,String(s.value))})):t&&"object"==typeof t&&(t.order_options=s))}(t,this.collectedOrderOptions),!this.isApplePayActive)return salla.api.request("checkout/quick-purchase/"+this.productId,t,"post").then((t=>(t.data.redirect&&(window.location.href=t.data.redirect),t)));t.is_applepay=!0,"append"in t&&t.append("is_applepay",!0),salla.event.dispatch("payments::apple-pay.start-transaction",{amount:this.applePayAmount>0?this.applePayAmount:this.amount,currency:this.currency||salla.config.get("store.settings.buy_now.currency")||"SAR",requiredShippingContactFields:this.getRequiredShippingContactFields(),shippingMethods:this.isRequireShipping?[]:void 0,supportedNetworks:this.isLegacyBuyNowBE()?salla.config.get("store.settings.buy_now.networks"):Array.isArray(this.supportedNetworks)&&this.supportedNetworks.length?this.supportedNetworks:salla.config.get("store.settings.buy_now.supportedNetworks"),supportedCountries:this.isLegacyBuyNowBE()?salla.config.get("store.settings.buy_now.countries"):Array.isArray(this.supportedCountries)&&this.supportedCountries.length?this.supportedCountries:salla.config.get("store.settings.buy_now.supportedCountries"),countryCode:salla.config.get("store.store_country")||"SA",onStartedSession:this.handleApplePaySessionStarted,validateMerchant:{url:this.validateHost?`${this.validateHost}/checkout/applepay/validate`:salla.url.get("checkout/applepay/validate"),onSuccess:s=>this.applePayOnly&&!this.productId?this.cartId?(window.SallaApplePay.id=this.cartId,salla.log("🍏 Pay: create checkout success: with id #"+this.cartId),Promise.resolve(s)):(salla.logger.warn("🍏 Pay: trying to create applePay transaction without cartId/ProductId !"),Promise.resolve(s)):salla.api.request("checkout/quick-purchase/"+this.productId,"object"==typeof t?t:void 0,"post",{}).then((t=>t?.data?.redirect?(salla.log("🍏 Pay: create checkout success: redirect exits, go to checkout page"),window.location.href=t.data.redirect.url,t):t?.data?.id?(window.SallaApplePay.id=t.data.id,void salla.log("🍏 Pay: create checkout success: with id #"+window.SallaApplePay.id)):(salla.logger.warn("🍏 Pay: create checkout success: No id, or redirect"),t)))},authorized:{url:salla.url.get("checkout/{id}/payments/submit"),onFailed:t=>{window.SallaApplePay.onCancel({},t?.data?.error?.message||t?.data?.error?.code||salla.lang.get("pages.checkout.payment_failed"))},onSuccess:t=>{window.location.href=t.redirect.url,salla.log("🍏 Pay: authorized Success:: redirect to thank you page, order placed")}},shippingMethodSelected:this.isRequireShipping?{url:salla.url.get("checkout/{id}/shipping/details")}:void 0,shippingContactSelected:this.isRequireShipping?{url:salla.url.get("checkout/{id}/address/add")}:void 0,guestContactSelected:this.isGuestCheckout()?{url:salla.url.get("checkout/{id}/customer")}:void 0,onCouponCodeChanged:{url:salla.url.get("checkout/{id}/coupons")},recalculateTotal:{url:salla.url.get("checkout/{id}/payments/recalculate?payment_method=apple_pay")},onError:function(t){salla.log(t),salla.notify.error(t)}})}isGuestCheckout(){return salla.config.isGuest()&&salla.config.get("store.features").includes("guest-checkout")&&this.isPhysicalProduct()}getRequiredShippingContactFields(){let t=[];return this.isRequireShipping&&t.push("postalAddress"),this.isGuestCheckout()&&t.push("email","phone","name"),t}isLegacyBuyNowBE(){return null!=salla?.config?.get?.("store.settings.buy_now.multi_currency")}applyBaseCurrencyPrice(t){if(this.isLegacyBuyNowBE())return void(null!=t?.price&&(this.amount=t.price));const s=t?.base_currency_price;null!=s?.amount?(this.amount=s.amount,s?.currency&&(this.currency=s.currency)):null!=t?.price&&(this.amount=t.price,this.currency=salla.config.get("user.currency_code")||this.currency||"SAR")}componentWillLoad(){console.log("🍏 Pay: Quick Buy Component Loaded");const t="undefined"!=typeof window&&!!window.ApplePaySession?.canMakePayments?.(),s=salla?.config?.get?.("store.settings.payments")?.includes?.("apple_pay")??!0,i=salla?.config?.get?.("store.settings.is_salla_gateway",!1)??!0;this.isApplePayActive=t&&s&&i;const a=async()=>{if(this.isLegacyBuyNowBE()&&!this.currency&&salla?.config?.get&&(this.currency=salla.config.get("store.settings.buy_now.multi_currency")?salla.config.get("user.currency_code"):salla.config.get("store.settings.buy_now.currency")||"SAR"),!this.productId&&salla?.config?.get&&salla.url?.is_page&&(this.productId=salla.config.get("page.id")),this.applePayOnly||this.productId){if(this.amount&&this.isRequireShipping||!this.productId||!salla?.product?.getDetails||await salla.product.getDetails(this.productId,[]).then((t=>{this.applyBaseCurrencyPrice(t?.data),this.isRequireShipping=t?.data?.is_require_shipping||!1})).catch((t=>{salla?.logger?.warn?.("🍏 Pay: Failed load the quick buy, get the product details failed: ",t)})),"donate"===this.type&&salla?.event?.on?salla.event.on("product-options::donation-changed",(t=>{String(t.id)===String(this.productId)&&this.applyBaseCurrencyPrice(t)})):salla?.url?.is_page?.("product.single")&&salla?.product?.event?.onPriceUpdated&&salla.product.event.onPriceUpdated((t=>{this.applyBaseCurrencyPrice(t?.data)})),this.isApplePayActive=(salla?.helpers?.hasApplePay?.()??t)&&(salla?.config?.get?.("store.settings.payments")?.includes?.("apple_pay")??s)&&(salla?.config?.get?.("store.settings.is_salla_gateway",!1)??i),!document.getElementById("apple-pay-sdk")&&this.isApplePayActive){const t=document.createElement("script");t.src="https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",t.setAttribute("id","apple-pay-sdk"),t.async=!0,document.body.appendChild(t)}}else salla?.logger?.warn?.("🍏 Pay: Failed load the quick buy, the product id is missing")};return new Promise((t=>{"function"==typeof salla?.onReady?salla.onReady((()=>a().then((()=>t(!0))))):a().then((()=>t(!0)))}))}render(){return i(a,{key:"c2ba63eb4fad49f80977d6f1adc836f655524933"},this.quickBuyButton())}quickBuyButton(){return i("apple-pay-button",{locale:salla?.config?.get?.("user.language_code")||"ar",onClick:()=>this.quickBuyHandler(),"data-quick-purchase":"applepay",class:"s-quick-buy-apple-pay","data-is-applepay":"1",buttonstyle:"black",type:this.type})}isPhysicalProduct(){return"product"===this.productType||"group_products"===this.productType||"food"===this.productType}get host(){return e(this)}};O.style=".s-quick-buy-button .s-button-text{display:flex}apple-pay-button{--apple-pay-button-width:100%;--apple-pay-button-height:40px;--apple-pay-button-border-radius:.75rem;--apple-pay-button-box-sizing:content-box}";export{m as salla_add_product_button,y as salla_bought_together,g as salla_product_availability,v as salla_product_options,O as salla_quick_buy}
4
+ import{r as t,c as s,h as i,H as a,a as e,e as o}from"./p-CcbWxP-e.js";import{P as n}from"./p-DY4LZmNP.js";import{H as l}from"./p-XnA1YTjA.js";import{a as r}from"./p-CL7OPpYS.js";import{B as c}from"./p-D3mWkc-3.js";import{D as d}from"./p-CoQJOPRz.js";import{S as h}from"./p-BZp0rKEO.js";import{C as p}from"./p-C6jIkM-X.js";import"./p-CgtvEd63.js";class u{constructor(t,s){this.host=t,this.productId=s,this.collected=!1,this.livePrice=0}static attach(t,s){const i=t.querySelector("salla-mini-checkout-widget");if(!i)return!1;const a=new u(t,String(s));return salla.product?.event?.onPriceUpdated?.((t=>{a.livePrice=Number(t?.data?.price)||a.livePrice})),i.addEventListener("click",(t=>a.handleWidgetClick(t,i)),!0),!0}getSelectedQuantity(){try{const t=document.querySelector("form.product-form"),s=t?.getElementSallaData?.(),i=Number(s instanceof FormData?s.get("quantity"):s?.quantity);if(Number.isFinite(i)&&i>0)return i}catch{}return Number(this.host.getAttribute("quantity"))||1}async handleWidgetClick(t,s){if(this.collected)return void(this.collected=!1);if(t.preventDefault(),t.stopImmediatePropagation(),!await this.validatePdpOptions())return;if(salla.config.isGuest())return void salla.api.auth.requireLoginThen("salla-add-product-button::oo.after-login",(()=>this.handleWidgetClick(t,s)));let i;s.classList.add("s-add-product-button-busy");try{i=await salla.api.withoutNotifier((()=>salla.product.api.getOrderOptions([{id:this.productId,quantity:this.getSelectedQuantity()}])))}catch(t){return salla?.logger?.warn?.("order-options: fetch failed",t),s.classList.remove("s-add-product-button-busy"),void this.resumeWidget(s)}s.classList.remove("s-add-product-button-busy");const a=i?.data?.order_options||[];if(!a.length)return void this.resumeWidget(s);const e=this.livePrice>0?this.livePrice:Number(i?.data?.products?.[0]?.price?.amount)||0,o=this.ensureModal();try{const t=await o.open({orderOptions:a,basePrice:e});this.injectIntoMini(t?.orderOptions||[]),this.resumeWidget(s)}catch{}}async validatePdpOptions(){const t=document.querySelector(`salla-product-options[product-id="${this.productId}"]`);return!t||("function"==typeof t.validateAndScroll?await t.validateAndScroll():"function"!=typeof t.reportValidity||await t.reportValidity())}injectIntoMini(t){if(!t.length)return;const s=this.productId,i=a=>{if(String(a?.id)===String(s))try{a?.payload?.set?.("order_options",t)}finally{salla.event.off("cart::before.add.item",i)}};salla.event.on("cart::before.add.item",i)}ensureModal(){let t=document.querySelector("salla-order-options-modal");return t||(t=document.createElement("salla-order-options-modal"),document.body.appendChild(t)),t}resumeWidget(t){this.collected=!0;const s=t.shadowRoot?.querySelector?.(".s-fast-checkout-button");s?s.click():"function"==typeof t.click&&t.click()}}const m=class{constructor(i){t(this,i),this.success=s(this,"success"),this.failed=s(this,"failed"),this.hostAttributes={},this.hasPreOrder=!1,this.productStatus="sale",this.productType="product",this.selectedOptions=[],this.buyNowText=salla.lang.get("pages.products.buy_now"),this.isDesktopViewport="undefined"==typeof window||window.matchMedia("(min-width: 768px)").matches,this.viewportMediaQuery=null,this.orderOptionsGateAttached=!1,this.onViewportChange=t=>{this.isDesktopViewport=t.matches,this.btn?.setText(t.matches&&this.passedLabel?this.passedLabel:this.getLabel())},salla.lang.onLoaded((()=>{this.buyNowText=salla.lang.get("pages.products.buy_now")}))}getLabel(){return"sale"===this.productStatus&&this.supportStickyBar&&!this.isDesktopViewport&&this.showQuickBuy&&this.isApplePayActive?n:this.hasPreOrder?salla.lang.get("pages.products.pre_order_now"):"sale"===this.productStatus&&"booking"===this.productType?salla.lang.get("pages.cart.book_now"):"sale"===this.productStatus?salla.lang.get("pages.cart.add_to_cart"):"donating"!==this.productType?salla.lang.get("pages.products.out_of_stock"):salla.lang.get("pages.products.donation_exceed")}addProductToCart(t){if("booking"===this.productType)return t.preventDefault(),this.addBookingProduct();if("submit"===this.hostAttributes.type)return!1;t.preventDefault(),this.btn?.disable();const s=document.querySelector(`salla-product-options[product-id="${this.productId}"]`);return s&&"function"==typeof s.validateAndScroll?s.validateAndScroll().then((async t=>{const s={isValid:t,component:this};if(await salla.hooks.call("salla-add-product-button","validate",s),s.isValid)return this._proceedAddToCart();this.btn?.enable()})).catch((()=>{this.btn?.enable()})):this._proceedAddToCart()}async _proceedAddToCart(){const t=this.host.closest("salla-products-list, salla-products-slider")??this.host.closest("salla-product-card, custom-salla-product-card"),s=Object.entries({id:this.productId,donation_amount:this.donatingAmount,quantity:this.quantity,endpoint:"quickAdd",source:l.getProductsSource(t?.getAttribute("source"))}).reduce(((t,[s,i])=>i?(t[s]=i,t):t),{});return salla.cart.addItem(s).then((async t=>(this.selectedOptions=[],this.btn?.enable(),this.success.emit(t),t))).catch((t=>{this.failed.emit(t),this.btn?.enable()}))}addBookingProduct(){return salla.config.isGuest()?(salla.auth.api.setAfterLoginEvent("booking::add",this.productId),void salla.event.dispatch("login::open")):salla.booking.add(this.productId).then((t=>this.success.emit(t))).catch((t=>this.failed.emit(t)))}getBtnAttributes(){for(let t=0;t<this.host.attributes.length;t++)["id","class"].includes(this.host.attributes[t].name)||(this.hostAttributes[this.host.attributes[t].name]=this.host.attributes[t].value);return this.hostAttributes}get notifyChannels(){return this.channels||salla.api.product.getAvailabilityChannels?.()||l.availabilityChannels()}getQuickBuyBtnAttributes(){return{...this.getBtnAttributes(),type:this.supportStickyBar&&!this.isDesktopViewport?"plain":"donating"==this.productType?"donate":"buy"}}miniCheckoutWidget(){let t=salla.config.get("store.id");if(t)return i("salla-mini-checkout-widget",{language:salla.lang.locale,"store-id":t,config:{user:salla.config.get("user"),failure_url:window.location.href},products:[this.productId],api:salla.config.get("store.api"),outline:!0,"form-selector":"form.product-form",class:"s-add-product-button-mini-checkout"},i("div",{slot:"widget-label",class:"s-add-product-button-mini-checkout-content"},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>full-wallet</title>\n<path d="M29 12h-26c-0.668-0.008-1.284-0.226-1.787-0.59l0.009 0.006c-0.744-0.552-1.222-1.428-1.222-2.416 0-1.657 1.343-3 2.999-3h6c0.552 0 1 0.448 1 1s-0.448 1-1 1v0h-6c-0.552 0-1 0.448-1 1 0 0.326 0.156 0.616 0.397 0.798l0.002 0.002c0.167 0.12 0.374 0.194 0.599 0.2l0.001 0h26c0.552 0 1 0.448 1 1s-0.448 1-1 1v0zM27 12c-0.552 0-1-0.448-1-1v0-3h-3c-0.552 0-1-0.448-1-1s0.448-1 1-1v0h4c0.552 0 1 0.448 1 1v0 4c0 0.552-0.448 1-1 1v0zM29 30h-26c-1.657 0-3-1.343-3-3v0-18c0-0.552 0.448-1 1-1s1 0.448 1 1v0 18c0 0.552 0.448 1 1 1v0h25v-5c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM29 18c-0.552 0-1-0.448-1-1v0-6c0-0.552 0.448-1 1-1s1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM31 24h-7c-2.209 0-4-1.791-4-4s1.791-4 4-4v0h7c0.552 0 1 0.448 1 1v0 6c0 0.552-0.448 1-1 1v0zM24 18c-1.105 0-2 0.895-2 2s0.895 2 2 2v0h6v-4zM25 12c-0.001 0-0.001 0-0.002 0-0.389 0-0.726-0.222-0.891-0.546l-0.003-0.006-3.552-7.106-2.306 1.152c-0.13 0.066-0.284 0.105-0.447 0.105-0.552 0-1-0.448-1-1 0-0.39 0.223-0.727 0.548-0.892l0.006-0.003 3.2-1.6c0.13-0.067 0.284-0.106 0.447-0.106 0.39 0 0.727 0.223 0.892 0.548l0.003 0.006 4 8c0.067 0.13 0.106 0.285 0.106 0.448 0 0.552-0.448 1-1 1v0zM21 12c-0.001 0-0.001 0-0.002 0-0.389 0-0.726-0.222-0.891-0.546l-0.003-0.006-3.552-7.106-15.104 7.552c-0.13 0.066-0.284 0.105-0.447 0.105-0.552 0-1-0.448-1-1 0-0.39 0.223-0.727 0.548-0.892l0.006-0.003 16-8c0.13-0.067 0.284-0.106 0.447-0.106 0.39 0 0.727 0.223 0.892 0.548l0.003 0.006 4 8c0.067 0.13 0.106 0.285 0.106 0.448 0 0.552-0.448 1-1 1-0.001 0-0.001 0-0.002 0h0z"></path>\n</svg>\n'}),this.buyNowText))}componentWillLoad(){return salla.onReady().then((()=>{if(document.documentElement.classList.add("hydrated"),this.showQuickBuy=this.quickBuy&&salla.config.get("store.settings.buy_now")&&"sale"==this.productStatus&&"booking"!==this.productType,this.isApplePayActive=window.ApplePaySession?.canMakePayments()&&salla.config.get("store.settings.payments")?.includes("apple_pay")&&salla.config.get("store.settings.is_salla_gateway",!1),this.passedLabel=this.host.innerHTML.replace("\x3c!----\x3e","").trim(),this.passedLabel&&this.isDesktopViewport)return this.btn?.setText(this.passedLabel);"submit"===this.host.getAttribute("type")&&this.supportStickyBar&&(this.viewportMediaQuery=window.matchMedia("(min-width: 768px)"),this.viewportMediaQuery.addEventListener("change",this.onViewportChange))}))}render(){return this.host.closest(".swiper-slide")?.classList.contains("swiper-slide-duplicate")?"":this.hasSubscribedOptions?i(a,null,i("salla-product-availability",{...this.getBtnAttributes(),"is-subscribed":!0},i("span",{class:"s-hidden"},i("slot",null)))):"out-and-notify"===this.productStatus&&this.notifyChannels||this.hasOutOfStockOption?i(a,null,i("salla-product-availability",{...this.getBtnAttributes()},i("span",{class:"s-hidden"},i("slot",null)))):i(a,{class:{"s-add-product-button-with-quick-buy":this.showQuickBuy,"s-add-product-button-with-sticky-bar":this.supportStickyBar,"s-add-product-button-with-apple-pay":this.showQuickBuy&&this.isApplePayActive}},i("div",{class:{"s-add-product-button-main":this.showQuickBuy,"w-full":!document.getElementById("fast-checkout-js")||["financial_support","donating"].includes(this.productType)}},i("salla-button",{color:"sale"===this.productStatus?"primary":"light",type:"button",fill:"sale"===this.productStatus?"solid":"outline",ref:t=>this.btn=t,onClick:t=>this.addProductToCart(t),disabled:"sale"!==this.productStatus,...this.getBtnAttributes(),"loader-position":"center"},i("slot",null)),this.showQuickBuy&&document.getElementById("fast-checkout-js")&&!["financial_support","donating"].includes(this.productType)?this.miniCheckoutWidget():""),this.showQuickBuy&&this.isApplePayActive?i("salla-quick-buy",{...this.getQuickBuyBtnAttributes()}):"")}async componentDidLoad(){await Salla.hooks.registerComponent("salla-add-product-button",this),this.notifyOptionsAvailability&&salla.event.on("product-options::change",(async t=>{if(!["thumbnail","color","single-option"].includes(t.option.type))return;this.hasSubscribedOptions=!1,this.selectedOptions=await(document.querySelector(`salla-product-options[product-id="${this.productId}"]`)?.getSelectedOptions()),this.hasOutOfStockOption=await(document.querySelector(`salla-product-options[product-id="${this.productId}"]`)?.hasOutOfStockOption());let s=salla.storage.get(`product-${this.productId}-subscribed-options`);if((s||this.subscribedOptions)&&this.hasOutOfStockOption)if(salla.config.isGuest()){const t=s?s.map((t=>t.split(",").map((t=>parseInt(t))))):[];this.hasSubscribedOptions=t.length>0&&t.some((t=>t.every((t=>this.selectedOptions.some((s=>s.id===t))))))}else this.hasSubscribedOptions=!(!this.subscribedOptions||"null"===this.subscribedOptions||"[]"===this.subscribedOptions)&&JSON.parse(this.subscribedOptions).some((t=>t.every((t=>this.selectedOptions.some((s=>s.id===t))))))}))}componentDidRender(){!this.orderOptionsGateAttached&&this.productId&&salla.config.get("store.settings.order_options.mandatory",!1)&&u.attach(this.host,this.productId)&&(this.orderOptionsGateAttached=!0),!this.passedLabel||this.supportStickyBar&&!this.isDesktopViewport?(this.btn?.setText(this.getLabel()),salla.lang.onLoaded((()=>this.btn?.setText(this.getLabel())))):this.btn?.setText(this.passedLabel)}disconnectedCallback(){this.viewportMediaQuery?.removeEventListener("change",this.onViewportChange)}get host(){return e(this)}};m.style=":host{display:block}salla-add-product-button[width=wide]{width:100%}";const y=class{constructor(s){t(this,s),this.limit=3,this.recommendations=[],this.selectedIds=new Set,this.isLoading=!0,this.canRender=!0,this.isAdding=!1,this.title=salla.lang.get("pages.products.bought_together_title"),this.subtitle=salla.lang.get("pages.products.bought_together_subtitle"),this.buyTogetherFor=salla.lang.get("pages.products.buy_together_for"),this.resolvedProductId=0,this.listViewTracked=!1,salla.lang.onLoaded((()=>{this.title=salla.lang.get("pages.products.bought_together_title"),this.subtitle=salla.lang.get("pages.products.bought_together_subtitle"),this.buyTogetherFor=salla.lang.get("pages.products.buy_together_for")}))}componentWillLoad(){salla.onReady().then((()=>{if(!salla.config.get("store.settings.product.bought_together"))return void(this.canRender=!1);const t=salla.config.get("page.id");if(t)return this.resolvedProductId=t,r(String(t));this.canRender=!1})).then((t=>{if(!t?.length)return void(this.canRender=!1);const s=[String(this.resolvedProductId),...t.slice(0,this.limit)];return salla.product.fetch({source:"selected",source_value:s})})).then((t=>{if(!t)return;const s=t?.data??[];if(!s.length)return void(this.canRender=!1);const i=s.find((t=>String(t.id)===String(this.resolvedProductId))),a=s.filter((t=>String(t.id)!==String(this.resolvedProductId)));a.length?(this.recommendations=i?[i,...a]:a,this.selectedIds=new Set(this.recommendations.map((t=>t.id)))):this.canRender=!1})).catch((()=>{this.canRender=!1})).finally((()=>{this.isLoading=!1}))}componentDidRender(){!this.recommendations.length||this.listViewTracked||this.intersectionObserver||(this.intersectionObserver=new IntersectionObserver((t=>{t.some((t=>t.isIntersecting))&&(this.listViewTracked=!0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.emitListViewed())}),{threshold:.1}),this.intersectionObserver.observe(this.el))}disconnectedCallback(){this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0}emitListViewed(){const t=this.recommendations.filter((t=>!this.isMainProduct(t.id)));salla.event.emit("salla-bought-together::list.viewed",{products:t})}isMainProduct(t){return String(t)===String(this.resolvedProductId)}recommendedPosition(t){const s=this.recommendations.filter((t=>!this.isMainProduct(t.id))).findIndex((s=>String(s.id)===String(t)));return-1===s?-1:s+1}emitProductClicked(t,s){salla.event.emit("salla-bought-together::product.clicked",[{product:t,position:s}])}toggleProduct(t){const s=new Set(this.selectedIds);s.has(t)?s.delete(t):s.add(t),this.selectedIds=s}get totalPrice(){const t=this.recommendations.filter((t=>this.selectedIds.has(t.id))).reduce(((t,s)=>t+(s.price??0)),0),s=salla.config.get("store.currency.decimals")??2,i=Math.pow(10,s);return salla.money(Math.round(t*i)/i)}async addSelectedToCart(){if(this.isAdding||!this.selectedIds.size)return;this.isAdding=!0;let t=!1;try{for(const s of Array.from(this.selectedIds))try{salla.cart?.api&&(salla.cart.api.addToCartSource="pdp_fbt");const t=await salla.cart.addItem({id:s,endpoint:"quickAdd",source:"pdp_fbt"}),i=this.recommendations.find((t=>t.id===s));if(i){const a=this.isMainProduct(s)?0:this.recommendedPosition(s),e=t?.data?.items?.find((t=>String(t.product_id)===String(i.id)))??t?.data?.items?.slice(-1)[0];salla.event.emit("salla-bought-together::product.added",[{product:i,position:a,cartItem:e,cartId:t?.data?.id}])}}catch(s){salla.log(s),t=!0}t&&salla.error(salla.lang.get("common.messages.error"))}finally{this.isAdding=!1}}getSkeletonView(){return i(a,{class:"s-bought-together-entry"},i("div",{class:"s-bought-together-skeleton"},i("div",{class:"s-bought-together-skeleton-header"},i("salla-skeleton",{height:"16px",width:"35%"}),i("salla-skeleton",{height:"10px",width:"60%"})),Array(4).fill(null).map(((t,s)=>i("div",{key:s,class:"s-bought-together-skeleton-item"},i("salla-skeleton",{height:"22px",width:"22px"}),i("salla-skeleton",{height:"48px",width:"48px"}),i("div",{class:"s-bought-together-skeleton-info"},i("salla-skeleton",{height:"12px",width:"55%",style:{marginBottom:"3px"}}),i("salla-skeleton",{height:"10px",width:"25%"}))))),i("salla-skeleton",{height:"44px",width:"100%"})))}render(){return this.canRender?this.isLoading?this.getSkeletonView():this.recommendations.length?i(a,{class:"s-bought-together-entry"},i("div",{class:"s-bought-together-header"},i("h3",{class:"s-bought-together-title"},this.title),i("p",{class:"s-bought-together-subtitle"},this.subtitle)),i("div",{class:"s-bought-together-list"},this.recommendations.map((t=>i("div",{key:t.id,class:"s-bought-together-item"+(this.selectedIds.has(t.id)?"":" s-bought-together-item--unchecked")},i("label",{class:"s-bought-together-checkbox-label"},i("input",{type:"checkbox",class:"s-bought-together-checkbox",checked:this.selectedIds.has(t.id),onChange:()=>this.toggleProduct(t.id)}),i("span",{class:"s-bought-together-checkmark"})),i("a",{class:"s-bought-together-item-link",href:t.url,onClick:()=>!this.isMainProduct(t.id)&&this.emitProductClicked(t,this.recommendedPosition(t.id))},i("img",{class:"s-bought-together-item-img",src:t.image?.url||salla.url.cdn("images/s-empty.png"),alt:t.image?.alt||t.name,loading:"lazy",decoding:"async",onError:t=>{t.currentTarget.onerror=null,t.currentTarget.src=salla.url.cdn("images/s-empty.png")}}),i("span",{class:"s-bought-together-item-name"},t.name)),i("span",{class:"s-bought-together-item-price",innerHTML:null!=t.price?salla.money(t.price):""}))))),i("salla-button",{class:"s-bought-together-btn",disabled:!this.selectedIds.size||this.isAdding,loading:this.isAdding,onClick:()=>this.addSelectedToCart()},i("span",{innerHTML:`${this.buyTogetherFor} ${this.totalPrice}`}))):null:null}get el(){return e(this)}};y.style=':host{display:block}.s-bought-together-checkbox:checked~.s-bought-together-checkmark{background-color:var(--color-primary, #2ECC71);border-color:var(--color-primary, #2ECC71)}.s-bought-together-checkbox:checked~.s-bought-together-checkmark::after{content:"";display:block;width:5px;height:9px;border:solid #fff;border-width:0 2px 2px 0;transform:rotate(45deg);margin-top:-2px}';const g=class{constructor(s){t(this,s),this.isUser=salla.config.isUser(),this.translationLoaded=!1,this.notifyOptionsAvailability=!1,this.isSubscribed=!1,this.handleSubmitOptions=async()=>{let t={id:this.productId};if(!this.notifyOptionsAvailability)return t;let s=document.querySelector(`salla-product-options[product-id="${this.productId}"]`),i=Object.values(await(s?.getSelectedOptionsData())||{});if(i.length&&!await(s?.reportValidity())){let t=salla.lang.get("common.messages.required_fields");throw salla.error(t),t}return t.options=[],i.forEach((s=>{s&&!isNaN(s)&&t.options.push(Number(s))})),t},this.typing=t=>{const s=t.target.nextElementSibling;t.target.classList.remove("s-has-error"),s?.classList.contains("s-product-availability-error-msg")&&(s.innerText=""),13===t.keyCode&&this.submit()},salla.lang.onLoaded((()=>{this.translationLoaded=!0,this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),this.modal?.setTitle(this.title_)})),this.productId||(this.productId=salla.config.get("page.id")),this.isUser||(this.channelsWatcher(this.channels),this.title_=this.host.title||salla.lang.get("pages.products.notify_availability_title"),this.host.removeAttribute("title"))}channelsWatcher(t){let s=t||salla.api.product.getAvailabilityChannels?.()||l.availabilityChannels();this.channels_=s?s.split(","):[]}get isSubscribedToProduct(){return this.isSubscribed||!this.notifyOptionsAvailability&&(!!salla.api.product.isSubscribedToAvailability?.(this.productId)||!!salla.storage.get(`product-${this.productId}-subscribed`))}openModel(){this.handleSubmitOptions().then((t=>t?this.modal.open():null))}async submit(){let t=await this.handleSubmitOptions();if(this.isUser)return salla.api.product.availabilitySubscribe(t).then((()=>this.isSubscribed=!0));if(this.channels_.includes("sms")||this.channels_.includes("whatsapp")){let{phone:s,countryCode:i}=await this.mobileInput.getValues();t.country_code=i,t.phone=s}return this.channels_.includes("email")&&""!==this.email.value&&(t.email=this.email.value),await this.validateform(),this.btn.load().then((()=>this.btn.disable())).then((()=>salla.api.product.availabilitySubscribe(t))).then((()=>{if(this.notifyOptionsAvailability){if(t.options.length){let s=salla.storage.get(`product-${this.productId}-subscribed-options`)||[],i=t.options.join(",");s.includes(i)?salla.log("already subscribed to this options"):(s.push(i),salla.storage.set(`product-${this.productId}-subscribed-options`,s),this.isSubscribed=!0)}}else this.isSubscribed=!0})).then((()=>this.btn.stop())).then((()=>this.modal.close())).catch((()=>this.btn.stop()&&this.btn.enable()))}async validateform(){try{if(this.channels_.includes("email")){const t=l.isValidEmail(this.email.value);if(t)return;!t&&this.validateField(this.email,salla.lang.get("common.elements.email_is_valid"))}if((this.channels_.includes("sms")||this.channels_.includes("whatsapp"))&&await this.mobileInput.isValid())return}catch(t){throw"Please insert required fields"}}validateField(t,s){t.classList.add("s-has-error"),t.nextElementSibling.innerText="* "+s}render(){return i(a,{key:"ccb098126e7809a6386ff38c74dfa0f00f64deeb",class:"s-product-availability-wrap"},this.isSubscribedToProduct?i("div",{class:"s-product-availability-subscribed"},i("span",{innerHTML:c,class:"s-product-availability-subs-icon"}),salla.lang.get("pages.products.notify_availability_success")):i("salla-button",{width:"wide",onClick:()=>this.isUser?this.submit():this.openModel()},salla.lang.get("pages.products.notify_availability")),this.isUser||this.isSubscribedToProduct?"":this.renderModal())}renderModal(){return i("salla-modal",{ref:t=>this.modal=t,"modal-title":this.title_,subTitle:salla.lang.get("pages.products.notify_availability_subtitle"),width:"sm"},i("span",{slot:"icon",class:"s-product-availability-header-icon",innerHTML:c}),i("div",{class:"s-product-availability-body"},this.channels_.includes("email")?[i("label",{class:"s-product-availability-label"},salla.lang.get("common.elements.email")),i("input",{class:"s-product-availability-input",onKeyDown:t=>this.typing(t),placeholder:salla.lang.get("common.elements.email_placeholder")||"your@email.com",ref:t=>this.email=t,type:"email"}),i("span",{class:"s-product-availability-error-msg"})]:"",this.channels_.includes("sms")||this.channels_.includes("whatsapp")?[i("label",{class:"s-product-availability-label"},salla.lang.get("common.elements.mobile")),i("salla-tel-input",{ref:t=>this.mobileInput=t,onKeyDown:t=>this.typing(t)})]:""),i("div",{slot:"footer",class:"s-product-availability-footer"},i("salla-button",{class:"modal-cancel-btn",width:"wide",color:"light",fill:"outline",onClick:()=>this.modal.close()},salla.lang.get("common.elements.cancel")),i("salla-button",{class:"submit-btn","loader-position":"center",width:"wide",ref:t=>this.btn=t,onClick:()=>this.submit()},salla.lang.get("common.elements.submit"))))}get host(){return e(this)}static get watchers(){return{channels:["channelsWatcher"]}}};var f,b,w;g.style="",function(t){t[t.INIT=1]="INIT",t[t.IDLE=2]="IDLE",t[t.PROCESSING_QUEUED=9]="PROCESSING_QUEUED",t[t.PROCESSING=3]="PROCESSING",t[t.PROCESSING_COMPLETE=5]="PROCESSING_COMPLETE",t[t.PROCESSING_ERROR=6]="PROCESSING_ERROR",t[t.PROCESSING_REVERT_ERROR=10]="PROCESSING_REVERT_ERROR",t[t.LOADING=7]="LOADING",t[t.LOAD_ERROR=8]="LOAD_ERROR"}(f||(f={})),function(t){t[t.EMPTY=0]="EMPTY",t[t.IDLE=1]="IDLE",t[t.ERROR=2]="ERROR",t[t.BUSY=3]="BUSY",t[t.READY=4]="READY"}(b||(b={})),function(t){t[t.INPUT=1]="INPUT",t[t.LIMBO=2]="LIMBO",t[t.LOCAL=3]="LOCAL"}(w||(w={}));const v=class{constructor(a){if(t(this,a),this.changed=s(this,"changed"),this.fileTypes={pdf:"application/pdf",png:"image/png",jpg:"image/jpeg",word:"application/doc,application/ms-doc,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",exl:"application/excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",txt:"text/plain"},this.outOfStockText="",this.donationAmount=salla.lang.get("pages.products.donation_amount"),this.selectDonationAmount=salla.lang.getWithDefault("pages.products.select_donation_amount","تحديد مبلغ التبرع"),this.selectAmount=salla.lang.getWithDefault("pages.products.select_amount","اختر المبلغ"),this.isCustomDonation=!1,this.selectedOptions=[],this.canDisabled=!1,this.disableCardValue=!0,this.availableDigitalCardValues=[],this.userInitiatedValidation=!1,this.isCartMode=!1,this.availabilityMap={},this.productAvailable=!1,this.outSkus=[],this.ignoreDefaultCardValue=!1,this.productId=salla.config.get("page.id"),this.noPadding=!1,this.handleDonationOptions=(t,s,i)=>{if("custom"===s&&"input"===i){const s=t.target;return salla.helpers.inputDigitsOnly(s),salla.event.emit("product-options::donation-changed",{id:this.productId,price:s.value}),void s.dispatchEvent(new window.Event("change",{bubbles:!0}))}const a="option"===i?String(t.target?.value??""):"";if("option"===i&&"custom"===s&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()),this.isCustomDonation="custom"===a,this.donationInput){if("custom"===a?(this.donationInput.value="",this.donationInput.focus()):this.donationInput.value=a,"custom"===s)return;salla.event.emit("product-options::donation-changed",{id:this.productId,price:a})}},this.hideLabel=t=>!(t.type!==d.DONATION||!t.donation||t.donation.can_donate),this.getExpireDonationMessage=t=>{if(!t.donation)return;const s=t.donation.target_amount<=t.donation.collected_amount;return i("div",{class:{"s-product-options-donation-message":!0,"s-product-options-donation-completed":s,"s-product-options-donation-expired":!s}},i("p",null,t.donation.target_message),i("span",{innerHTML:s?salla.money(t.donation.target_amount):""}))},salla.lang.onLoaded((()=>{this.outOfStockText=salla.lang.get("pages.products.out_of_stock"),this.donationAmount=salla.lang.get("pages.products.donation_amount"),this.selectDonationAmount=salla.lang.getWithDefault("pages.products.select_donation_amount","تحديد مبلغ التبرع"),this.selectAmount=salla.lang.getWithDefault("pages.products.select_amount","اختر المبلغ")})),this.options)try{return void this.setOptionsData(Array.isArray(this.options)?this.options:JSON.parse(this.options))}catch(t){salla.log("Bad json passed via options prop")}Array.isArray(this.optionsData)||(salla.log("Options is not an array[] ---\x3e ",this.optionsData),this.setOptionsData([])),this.productId&&!salla.url.is_page("cart")&&salla.api.product.getDetails(this.productId,["options"]).then((t=>{this.productAvailable=!t.data.is_out_of_stock,this.setOptionsData(t.data.options)}))}async setOptionsData(t){this.optionsData=t,this.outSkus=[],this.optionsData[0]?.details?.forEach((t=>{Object.entries(t.skus_availability||{}).filter((([,t])=>!t)).forEach((([t])=>this.outSkus.push(Number(t))))})),this.fillSelectedOptions(),this.computeAvailability()}async getOptionsData(){return this.optionsData}async getSelectedOptionsData(){const t={},s=this.host.getElementSallaData(),i=void 0!==this.bundleContext?this.bundleContext:null;return s.forEach(((s,a)=>{if(i){if(a.startsWith("bundle[")&&a.includes("[options][")){const i=a.split("[options][")[1].replace("]","");t[i]=s}}else a.startsWith("options[")&&(t[a.replace("options[","").replace("]","")]=s)})),t}async reportValidity(){const t=this.host.querySelectorAll("[required]");let s=!0;for(let i=0;i<t.length;i++){const a=t[i];a.disabled||a.closest(".hidden")||"reportValidity"in a&&!a.reportValidity()&&(s=!1)}return s}async hasOutOfStockOption(){return this.selectedOptions.some((t=>t.is_out))||this.selectedSkus?.length&&this.selectedSkus?.every((t=>this.outSkus.includes(t)))}async getSelectedOptions(){return this.selectedOptions}async getOption(t){return this.optionsData.find((s=>s.id===t))}invalidHandler(t,s){const i=t.target.closest(".s-product-options-option");i.classList.contains("s-product-options-option-error")||i.classList.add("s-product-options-option-error"),!this.userInitiatedValidation&&!salla.helpers.isIOSDevice()||salla.url.is_page("cart")||this.host.querySelector(".s-product-options-option-error")===i&&this.scrollToElement(i)}scrollToElement(t){t&&t.scrollIntoView({behavior:"smooth",block:"center"})}changedHandler(t,s,i=!0){const a={event:t,option:s,detail:null,productId:this.productId};if(s.details){const i=s.details.find((s=>Number(s.id)===Number(t.target.value)));a.detail=i}"country"===s.type&&this.handleCountryOptionChange(t,a.detail);const e=t.target.closest(".s-product-options-option");(t.target.value||(s.type===d.FILE||s.type===d.IMAGE)&&"added"===t.type||s.type===d.MAP&&"selected"===t.type&&t.target.lat&&t.target.lng)&&setTimeout((()=>{e.classList.remove("s-product-options-option-error")}),200),s.type===d.DONATION&&salla.event.emit("product-options::donation-changed",{id:this.productId,price:t.target.value}),this.setSelectedSkus(),this.handleRequiredMultipleOptions(s);const o=this.selectedOptions.findIndex((t=>t.option_id===a.option.id));if(a.option.type===d.MULTIPLE_OPTIONS){const t=this.selectedOptions.findIndex((t=>t.option_id===a.option.id&&t?.id===a.detail?.id));t>-1?this.selectedOptions.splice(t,1):this.selectedOptions.push({...a.detail,option_id:a.option.id})}else a.detail&&0!==Object.keys(a.detail).length?o>-1?this.selectedOptions[o]={...a.detail,option_id:a.option.id}:this.selectedOptions.push({...a.detail,option_id:a.option.id}):o>-1&&this.selectedOptions.splice(o,1);this.optionsData=this.optionsData.map((t=>t.id===a.option.id?{...t,details:t.details.map((t=>({...t,is_selected:a.option.type===d.MULTIPLE_OPTIONS?this.selectedOptions.some((s=>s.id===t.id)):Number(t.id)===Number(a.detail?.id),value:a.detail?.value})))}:t)),this.pruneInvisibleConditionalSelections(),this.setSelectedSkus(),requestAnimationFrame((()=>{this.optionsData?.filter((t=>t.type===d.MULTIPLE_OPTIONS&&t.required)).forEach((t=>this.handleRequiredMultipleOptions(t)))})),i&&(this.changed.emit(a),salla.event.emit("product-options::change",a))}setSelectedSkus(){this.selectedSkus=this.selectedOptions.map((t=>Object.keys(t.skus_availability||{}))).reduce(((t,s)=>t.filter((t=>s.includes(t)))),[]).map((t=>Number(t))),this.computeAvailability()}handleRequiredMultipleOptions(t){if(t.type!==d.MULTIPLE_OPTIONS||!t.required)return;const s=this.host.querySelector(`[data-option-id="${t.id}"]`);if(!s)return;const i=s.querySelectorAll("input:checked").length;s.querySelectorAll("input").forEach((t=>t.toggleAttribute("required",!i)))}pruneInvisibleConditionalSelections(){const t=Math.max(1,this.optionsData.length);for(let s=0;s<t;s++){let t=!1;for(const s of this.optionsData){const i=s.visibility_condition;if(!i)continue;const a=this.selectedOptions.filter((t=>t.option_id===i.option)).map((t=>String(t.id))).includes(String(i.value));("="===i.operator?a:!a)||this.clearStaleOption(s.id)&&(t=!0)}if(!t)break}}clearStaleOption(t){const s=this.optionsData.find((s=>s.id===t));if(!s)return!1;const i=this.selectedOptions.length;this.selectedOptions=this.selectedOptions.filter((s=>s.option_id!==t));const a=this.selectedOptions.length!==i,e=null!=s.value&&String(s.value).length>0,o=s.details?.some((t=>t.is_selected))??!1;return!!(a||e||o)&&(this.optionsData=this.optionsData.map((s=>s.id!==t?s:{...s,value:void 0,details:s.details?.map((t=>({...t,is_selected:!1})))??s.details})),!0)}getLatLng(t,s){return t?t.split(",")["lat"===s?0:1]:""}getDisplayForType(t){return this[`${t.type}Option`]?this[`${t.type}Option`](t):t.type===d.COLOR_PICKER?this.colorPickerOption(t):t.type===d.MULTIPLE_OPTIONS?this.multipleOptions(t):t.type===d.SINGLE_OPTION?this.singleOption(t):t.type===d.RADIO?this.radioOption(t):t.type===d.DIGITAL_CARD_VALUE?this.digitalCardValuesOption(t):t.type===d.COUNTRY?this.countryOption(t):t.type===d.BOOKING&&salla.url.is_page("cart")?i("salla-booking-field",{onInvalidInput:s=>this.invalidHandler(s,t),option:t,productId:t.value}):(salla.log(`Couldn't find options type(${t.type})😢`),"")}getOptionShownWhen(t){return t.visibility_condition?{"data-show-when":`options[${t.visibility_condition.option}] ${t.visibility_condition.operator} ${t.visibility_condition.value}`}:{}}getAvailableDigitalCardSKUs(t){const s=this.optionsData.find((({type:t})=>"digital-code-value"===t));if(!s)throw new Error("product-options:: No digital card options found");const i=Object.keys(t.skus_availability).filter((s=>!1===t.skus_availability[s]));this.availableDigitalCardValues=s.details.filter((t=>!Object.keys(t.skus_availability).filter((t=>i.includes(t))).length))}handleCountryOptionChange(t,s){t.stopImmediatePropagation(),this.ignoreDefaultCardValue=!0;const i=this.host.querySelector("input[data-code-value]:checked");if(i&&(i.checked=!1),!this.optionsData.find((({type:t})=>"digital-code-value"===t)))throw new Error("product-options:: No digital card options found");this.getAvailableDigitalCardSKUs(s)}getSelectedDigitalCardOptions(t){const s=t.details.find((t=>t.is_selected)),i=t.details.find((t=>!!t.is_default))||t.details[0];if(["digital-code-value","country"].includes(t.type))return s||i}async componentWillLoad(){if(salla.url.is_page("cart")&&(this.disableCardValue=!1,this.fillSelectedOptions()),this.config)try{this.optionConfig="string"==typeof this.config?JSON.parse(this.config):this.config}catch(t){console.error("Failed to parse JSON in config prop:",t)}if(this.optionsData.filter((({type:t})=>["country","digital-card-value"].includes(t))).length>0&&salla.url.is_page("cart")){const t=this.optionsData.find((t=>"country"===t.type)),s=t&&this.getSelectedDigitalCardOptions(t);s&&this.getAvailableDigitalCardSKUs(s)}return this.outOfStockText=salla.lang.get("pages.products.out_of_stock"),this.computeAvailability(),await salla.onReady(),this.canDisabled=!salla.config.get("store.settings.product.notify_options_availability")||salla.url.is_page("cart"),this.pasteHandler=this.handlePaste.bind(this),document.addEventListener("paste",this.pasteHandler),!salla.storage.get("cart.id")&&this.optionsData.some((t=>["file","image"].includes(t.type)))?salla.api.cart.getCurrentCartId(!1,"salla-product-options"):null}disconnectedCallback(){this.pasteHandler&&document.removeEventListener("paste",this.pasteHandler)}handlePaste(t){const s=t.target;if(!(Salla.helpers.isAppleDevice()&&(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement)&&s.classList.contains("s-form-control")&&this.host.contains(s)))return;t.preventDefault();const i=t.clipboardData?.getData("text")||"",a=s.selectionStart,e=s.selectionEnd,o=s.value.slice(0,a)+i+s.value.slice(e);s.value=o,s.setSelectionRange(a+i.length,a+i.length);try{s.dispatchEvent(new window.Event("change",{bubbles:!0}))}catch(t){Salla.log("Error on change")}}hideDigitalCardsOptions(t){return this.disableCardValue&&t.type===d.DIGITAL_CARD_VALUE&&!salla.url.is_page("cart")}render(){if(0!==this.optionsData?.length)return i(a,{class:{"s-product-options-wrapper":!0,"s-product-options-no-padding":this.noPadding}},i("salla-conditional-fields",null,this.optionsData.map((t=>i("div",{key:t.id,class:"s-product-options-option-container"+(t.visibility_condition||this.hideDigitalCardsOptions(t)?" hidden":""),"data-option-id":t.id,...this.getOptionShownWhen(t)},"splitter"===t.name?this.splitterOption():i("div",{class:{"s-product-options-option":!0,"s-product-options-option-booking":t.type===d.BOOKING&&salla.url.is_page("cart")},"data-option-type":t.type,"data-option-required":`${t.required}`},i("label",{htmlFor:this.generateInputId(t.id),class:"s-product-options-option-label "+(this.hideLabel(t)?"s-product-options-option-label-hidden":"")},i("b",null,t.name,t.required&&i("span",null," * ")," "),i("small",null,t.placeholder)),i("div",{class:"s-product-options-option-content "+(this.hideLabel(t)||t.type===d.BOOKING&&salla.url.is_page("cart")?"s-product-options-option-content-full-width":"")},this.getDisplayForType(t))))))))}generateUniqueKey(t){const s=this.bundleContext;let i=this.uniqueKey?`${t}-${this.uniqueKey}`:t;if(s)try{const t="string"==typeof s?JSON.parse(s):s,{sectionId:a,productId:e}=t;i=`${i}-bundle-${a}-${e}`}catch(t){}return i}generateInputId(t){return this.generateUniqueKey(`option-${t}`)}generateInputName(t){const s=this.bundleContext,i=t.toString();if(s)try{const t="string"==typeof s?JSON.parse(s):s,{sectionId:a,productId:e}=t;return`bundle[${a}][${e}][options][${i}]`}catch(t){return`options[${i}]`}return`options[${i}]`}fillSelectedOptions(){this.selectedOptions=this.optionsData.reduce(((t,s)=>{const i=(s.details??[]).filter((t=>t.is_selected)).map((t=>({...t,option_id:s.id})));return t.concat(i)}),[])}async seedSelectedOptions(){this.fillSelectedOptions(),requestAnimationFrame((()=>{this.optionsData?.filter((t=>t.type===d.MULTIPLE_OPTIONS&&t.required)).forEach((t=>this.handleRequiredMultipleOptions(t)))}))}async componentDidLoad(){if(!this.optionsData?.length)return;await Salla.hooks.registerComponent("salla-product-options",this);const t=this.optionsData.find((t=>t.type===d.DONATION))?.details?.find((t=>t.is_selected));if(t&&setTimeout((()=>{salla.event.emit("product-options::donation-changed",{id:this.productId,price:t.additional_price})}),1e3),!salla.url.is_page("cart")&&!this.isCartMode){const t=[d.SINGLE_OPTION,d.MULTIPLE_OPTIONS,d.COLOR,d.THUMBNAIL,d.DONATION,d.DIGITAL_CARD_VALUE,d.COUNTRY];this.optionsData.some((s=>t.includes(s.type)&&s.details?.some((t=>t.is_selected))))&&requestAnimationFrame((()=>{try{const t=this.host.closest("form");if(!t)return;const s=new FormData(t),i=s.get("id")||s.get("product_id");if(i&&String(i)!==String(this.productId))return;salla.product.getPrice(s)}catch(t){salla.log("Error updating price for pre-selected options:",t)}}))}}async enterCartMode(){this.isCartMode=!0,this.disableCardValue=!1,this.canDisabled=!0,this.fillSelectedOptions(),this.computeAvailability()}async enableUserInitiatedValidation(){this.userInitiatedValidation=!0}async validateAndScroll(){return await this.enableUserInitiatedValidation(),this.reportValidity()}donationOption(t,s){return i("div",{class:"s-product-options-donation-wrapper"},t.donation?.can_donate?[t.donation?i("div",{key:t.id,class:"s-product-options-donation-progress"},i("salla-progress-bar",{donation:t.donation})):"",t.details.length?[i("h4",{key:t.id},this.selectAmount),i("div",{key:t.id,class:"s-product-options-donation-options"},t.details.map(((s,a)=>i("div",{key:t.id,class:"s-product-options-donation-options-item"},i("input",{id:this.generateUniqueKey(`donation-option-${a}`),type:"radio",name:"donating_option",checked:s.is_selected,value:s.additional_price,onChange:i=>this.handleDonationOptions(i,s,"option",t)}),i("label",{htmlFor:this.generateUniqueKey(`donation-option-${a}`)},i("span",{innerHTML:salla.money(s.name)}))))),t.donation?.custom_amount_enabled?i("div",{class:"s-product-options-donation-options-item"},i("input",{id:this.generateUniqueKey("donation-option-custom"),type:"radio",name:"donating_option",value:"custom",onChange:s=>this.handleDonationOptions(s,"custom","option",t)}),i("label",{htmlFor:this.generateUniqueKey("donation-option-custom")},i("span",null," ",this.selectDonationAmount," "))):"")]:"",i("div",{key:t.id,class:{"s-product-options-donation-input-group":!0,shown:!t.details.length||t.details.length&&this.isCustomDonation}},i("input",{type:"text",id:"donating-amount",name:"donation_amount",class:"s-form-control",ref:t=>{this.donationInput=t},value:t.details.length&&t.details.some((t=>t.is_selected))?t.details.find((t=>t.is_selected)).additional_price:t.value,placeholder:t.placeholder,onInput:s=>this.handleDonationOptions(s,"custom","input",t),onBlur:s=>this.changedHandler(s,t),onInvalid:s=>this.invalidHandler(s,t)}),i("span",{class:"s-product-options-donation-amount-currency"},salla.config.currency(salla.config.get("user.currency_code")).symbol))]:this.getExpireDonationMessage(t))}fileUploader(t,s=null){return i("salla-file-upload",{...s||{},"payload-name":"file",value:t.value,"instant-upload":!0,name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,height:"120px",onAdded:s=>{this.changedHandler(s,t,!(s.detail?.file?.origin===w.LOCAL))},url:salla.cart.api.getUploadImageEndpoint(),"form-data":{cart_item_id:this.productId,product_id:this.productId},onInvalidInput:s=>this.invalidHandler(s,t),class:{"s-product-options-image-input":!0,required:t.required}},i("div",{class:"s-product-options-filepond-placeholder"},i("span",{class:"s-product-options-filepond-placeholder-icon",innerHTML:s.accept?.split(",").every((t=>t.includes("image")))?p:'\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>file-upload</title>\n<path d="M21.333 24c0.341 0 0.683-0.131 0.943-0.391 0.521-0.521 0.521-1.364 0-1.885l-5.333-5.333c-0.123-0.123-0.271-0.22-0.433-0.288-0.327-0.135-0.693-0.135-1.019 0-0.163 0.068-0.311 0.165-0.433 0.288l-5.333 5.333c-0.521 0.521-0.521 1.364 0 1.885s1.364 0.521 1.885 0l3.057-3.057v10.115c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-10.115l3.057 3.057c0.26 0.26 0.601 0.391 0.943 0.391zM28.943 9.724l-9.333-9.333c-0.249-0.251-0.589-0.391-0.943-0.391h-12c-2.205 0-4 1.795-4 4v24c0 2.205 1.795 4 4 4h4c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333h-4c-0.735 0-1.333-0.599-1.333-1.333v-24c0-0.735 0.599-1.333 1.333-1.333h11.448l8.552 8.552v16.781c0 0.735-0.599 1.333-1.333 1.333h-4c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333h4c2.205 0 4-1.795 4-4v-17.333c0-0.353-0.14-0.693-0.391-0.943z"></path>\n</svg>\n'}),i("p",{class:"s-product-options-filepond-placeholder-text"},salla.lang.get("common.uploader.drag_and_drop")),i("span",{class:"filepond--label-action"},salla.lang.get("common.uploader.browse"))))}imageOption(t){return this.fileUploader(t,{accept:"image/png,image/jpeg,image/jpg,image/gif"})}fileOption(t){const s=t.details.map((t=>this.fileTypes[t.name])).filter(Boolean);return s?.length?this.fileUploader(t,{accept:s.join(",")}):"File types not selected."}numberOption(t){return i("input",{type:"text",value:t.value,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onBlur:s=>this.changedHandler(s,t),onInvalid:s=>this.invalidHandler(s,t),onInput:t=>salla.helpers.inputDigitsOnly(t.target)})}splitterOption(){return i("div",{class:"s-product-options-splitter"})}textOption(t){return i("div",{class:"s-product-options-text"},i("input",{type:"text",value:t.value,maxLength:t?.length,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)}))}textareaOption(t){return i("div",{class:"s-product-options-textarea"},i("div",{class:"mt-1"},i("textarea",{rows:4,value:t.value,maxLength:t?.length,class:"s-form-control",required:!t.visibility_condition&&t.required,id:this.generateInputId(t.id),name:this.generateInputName(t.id),placeholder:t.placeholder,onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)})))}mapOption(t){return i("salla-map",{zoom:15,lat:this.getLatLng(t.value,"lat"),lng:this.getLatLng(t.value,"lng"),name:this.generateInputName(t.id),searchable:!0,required:t.required,onInvalidInput:s=>this.invalidHandler(s,t),onSelected:s=>this.changedHandler(s,t)})}colorPickerOption(t){return i("salla-color-picker",{onSubmitted:s=>this.changedHandler(s,t),name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,onInvalidInput:s=>this.invalidHandler(s,t),color:t.value})}timeOption(t){return i("salla-datetime-picker",{noCalendar:!0,enableTime:!0,dateFormat:"h:i K",value:t.value,placeholder:t.name,required:!t.visibility_condition&&t.required,name:this.generateInputName(t.id),class:"s-product-options-time-element",onInvalidInput:s=>this.invalidHandler(s,t),onPicked:s=>this.changedHandler(s,t)})}dateOption(t){return i("div",{class:"s-product-options-date-element"},i("salla-datetime-picker",{value:t.value,placeholder:t.name,required:!t.visibility_condition&&t.required,minDate:new Date,name:this.generateInputName(t.id),onInvalidInput:s=>this.invalidHandler(s,t),onPicked:s=>this.changedHandler(s,t)}))}datetimeOption(t){return i("div",{class:"s-product-options-datetime-element"},i("salla-datetime-picker",{enableTime:!0,value:t.value,dateFormat:"Y-m-d G:i:K",placeholder:t.name,required:!t.visibility_condition&&t.required,name:this.generateInputName(t.id),maxDate:t.to_date_time,minDate:t.from_date_time,onInvalidInput:s=>this.invalidHandler(s,t),onPicked:s=>this.changedHandler(s,t)}))}getOptionDetailName(t,s=!0,i,a){let e;if(i&&i===d.COLOR&&(e=t.name+(s&&this.isOptionDetailOut(t)&&!salla.url.is_page("cart")&&!this.hideOutLabel?` <br/> <p> ${this.outOfStockText} </p>`:"")+(t.additional_price?` <p> (${salla.money(t.additional_price,!1)}) </p>`:"")),!e){const i=(s&&this.isOptionDetailOut(t)&&!salla.url.is_page("cart")&&!this.hideOutLabel?` - ${this.outOfStockText}`:"")+(t.additional_price?` (${salla.money(t.additional_price,!1)})`:"");if("price"===a){const s=salla.helpers.digitsOnly(t.name),a=Number(s);return s&&Number.isFinite(a)?salla.money(a,!0)+i:i}e=t.name+i}return e.replace("<i class=sicon-sar></i>",salla.config.currency()?.symbol||"ر.س")}computeAvailability(){this.availabilityMap=function(t,s,i=!0){const a={};if(!t?.length)return a;const e=t.filter((t=>t.details?.some((t=>t.skus_availability&&Object.keys(t.skus_availability).length>0)))),o=e.length<=1,n=new Set(t.filter((t=>!1===t.is_advance)).map((t=>t.id)));if(0===e.length){for(const s of t)for(const t of s.details)a[t.id]=t.is_out?"out_of_stock":"available";return a}const l=e.some((t=>t.details?.some((t=>t.skus_availability&&Object.values(t.skus_availability).some(Boolean))))),r=i&&!l;for(const t of e){const i=s.filter((s=>s.option_id!==t.id));for(const s of t.details){const t=s.skus_availability;if(!t||!Object.keys(t).length){a[s.id]=s.is_out?"out_of_stock":"available";continue}const e=Object.keys(t).map(Number),l=e.some((s=>t[s]));if(o||0===i.length){a[s.id]=!l&&r||l?"available":"out_of_stock";continue}let c=e;for(const t of i){if(n.has(t.option_id))continue;const s=new Set(Object.keys(t.skus_availability||{}).map(Number));c=c.filter((t=>s.has(t)))}if(!c.length){a[s.id]=r?"available":"impossible";continue}const d=c.some((s=>t[s]));a[s.id]=!d&&r||d?"available":"out_of_stock"}}return a}(this.optionsData||[],this.selectedOptions||[],this.productAvailable)}isOptionDetailOut(t){const s=this.availabilityMap[t.id];return void 0!==s?"available"!==s:!!t.is_out}renderInput(t,s,a,e,o,n){const l=this.generateUniqueKey(`${t}-${a.id}-${s.id}`),r=this.isOptionDetailOut(s),c=this.getOptionDetailName(s,!0,a.type,a.format),d={"s-product-options-grid-mode-span":n,"s-product-options-disabled":this.canDisabled&&r};return i("label",{class:{"s-product-options-disabled":this.canDisabled&&r,"s-product-options-option-stock-out":r}},i("input",{id:l,type:t,name:o,value:s.id,disabled:this.canDisabled&&r,required:e,checked:s.is_selected,onInvalid:t=>this.invalidHandler(t,a),onChange:t=>this.changedHandler(t,a)}),"price"===a.format?i("div",{class:d,innerHTML:c}):i("div",{class:d},c))}renderOptionDetails(t,s,i,a=!1){const e=this.generateInputName(s.id),o="radio"===t?e:`${e}[]`;return s?.details.map((e=>this.renderInput(t,e,s,i,o,a)))}renderSelect(t){return i("div",null,i("select",{id:this.generateInputId(t.id),name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,class:"s-form-control",onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)},i("option",{value:""},t.placeholder),t?.details.map((t=>i("option",{key:t.id,value:t.id,disabled:this.canDisabled&&this.isOptionDetailOut(t),selected:t.is_selected},this.getOptionDetailName(t))))))}renderButtonStyle(t,s,a){return i("div",{class:"s-product-options-grid-mode"},this.renderOptionDetails(t,s,a,!0))}singleOption(t){return"button"===this.optionConfig?.["single-option"]?.type||t.type===d.SINGLE_OPTION&&"price"===t.format?this.renderButtonStyle("radio",t,!t.visibility_condition&&t.required):this.renderSelect(t)}multipleOptions(t){const s="button"===this.optionConfig?.["multiple-option"]?.type,a=t.required&&!t.details.some((t=>t.is_selected))&&!t.visibility_condition;return s?this.renderButtonStyle("checkbox",t,a):i("div",{class:{"s-product-options-multiple-options-wrapper":!0,required:t.required}},this.renderOptionDetails("checkbox",t,a))}radioOption(t){return this.singleOption(t)}colorOption(t){return i("fieldset",{class:"s-product-options-colors-wrapper"},t?.details.map((s=>{const a=this.isOptionDetailOut(s);return i("div",{class:{"s-product-options-colors-item":!0,"s-product-options-option-stock-out":a},key:s.id},i("input",{type:"radio",value:s.id,required:!t.visibility_condition&&t.required,checked:s.is_selected,name:this.generateInputName(t.id),disabled:this.canDisabled&&a,id:this.generateUniqueKey(`color-${this.productId}-${t.id}-${s.id}`),onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t),"data-img-id":s.option_value}),i("label",{htmlFor:this.generateUniqueKey(`color-${this.productId}-${t.id}-${s.id}`),"data-img-id":s.option_value},i("span",{style:{backgroundColor:s.color}}),i("div",{innerHTML:this.getOptionDetailName(s,!0,t.type)})))})))}thumbnailOption(t){return i("div",{class:"s-product-options-thumbnails-wrapper"},t.details.map((s=>{const a=this.isOptionDetailOut(s);return i("div",{key:s.id,class:{"s-product-options-option-stock-out":a}},i("input",{type:"radio",value:s.id,"data-itemid":s.id,required:!t.visibility_condition&&t.required,checked:s.is_selected,name:this.generateInputName(t.id),"data-img-id":s.option_value,disabled:this.canDisabled&&a,id:this.generateUniqueKey(`option_${this.productId}-${t.id}_${s.id}`),onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t)}),i("label",{htmlFor:this.generateUniqueKey(`option_${this.productId}-${t.id}_${s.id}`),"data-img-id":s.option_value,class:"go-to-slide"},i("img",{"data-src":s.image,src:s.image,title:s.name,alt:s.name}),i("span",{innerHTML:h,class:"s-product-options-thumbnails-icon"}),a?[i("small",{key:`badge-${s.id}`,class:"s-product-options-thumbnails-stock-badge"},this.outOfStockText),this.canDisabled?i("div",{key:`overlay-${s.id}`,class:"s-product-options-thumbnails-badge-overlay"}):""]:""),i("p",null,this.getOptionDetailName(s,!1)," "))})))}digitalCardValuesOption(t){return i("div",{class:"s-product-options-digital-card-wrapper"},this.availableDigitalCardValues.length>0?this.availableDigitalCardValues.map((s=>{const a=String(s.id);return i("label",{htmlFor:this.generateUniqueKey(a.toString()),key:a,class:"s-product-options-digital-card-option"},i("input",{type:"radio","data-code-value":!0,class:"s-form-control s-product-options-digital-card-input",value:s.id,name:this.generateInputName(t.id),id:this.generateUniqueKey(a.toString()),required:!t.visibility_condition&&t.required,onInvalid:s=>this.invalidHandler(s,t),...this.ignoreDefaultCardValue?{}:{defaultChecked:this.getSelectedDigitalCardOptions(t)?.id===s.id}}),i("span",null,s.name," ",salla.config?.currency()?.symbol))})):i("div",{class:"s-product-options-digital-card-out-of-stock"}))}countryOption(t){return i("div",{class:"s-product-options-digital-card-wrapper"},t.details.map((s=>{const a=this.isOptionDetailOut(s);return i("label",{htmlFor:this.generateUniqueKey(s.id.toString()),key:s.id,class:{"s-product-options-digital-card-option":!0,"s-product-options-digital-card-option-stock-out":a,"s-product-options-option-stock-out":a}},i("input",{id:this.generateUniqueKey(s.id.toString()),type:"radio",class:"s-form-control s-product-options-digital-card-input",value:s.id,name:this.generateInputName(t.id),disabled:this.canDisabled&&a,required:!t.visibility_condition&&t.required,onInvalid:s=>this.invalidHandler(s,t),onChange:s=>this.changedHandler(s,t),onClick:()=>{this.disableCardValue=!1},...salla.url.is_page("cart")?{defaultChecked:this.getSelectedDigitalCardOptions(t)?.id===s.id}:{}}),i("img",{loading:"lazy",alt:s.code,height:24,width:24,class:"s-product-options-country-flag",src:`https://cdn.assets.salla.network/prod/admin/cp/assets/flags/1x1/${String(s.code).toLocaleLowerCase()}.svg`,onError:t=>{t.currentTarget.onerror=null,t.currentTarget.src=salla.url.cdn("images/globe.svg")}}),i("span",null,s.name))})))}get host(){return e(this)}};function k(){o.defaults.headers.common.currency=salla?.config?.get?.("user.currency_code")}v.style="";var _={request:(t,s,i,a=null,e=null)=>(k(),o.request({url:s,data:i,method:t.toLowerCase(),responseType:"json"}).then(a).catch(e)),get:(t,s=null,i=null,a)=>(k(),o.get(t,{params:a}).then(s).catch(i)),post(t,s,i=null,a=null){return this.request("post",t,s,i,a)},put(t,s,i=null,a=null){return this.request("put",t,s,i,a)},delete(t,s,i=null,a=null){return this.request("delete",t,s,i,a)},requestWithSupportAjax(t,s,i="post"){return new Promise(((a,e)=>{if(!window?.isLegacyTheme)return this.request(i,t,s,(({data:t})=>a(t)),(({response:t})=>e(t)));k(),$.ajax({url:t,method:i.toUpperCase(),data:s,headers:{currency:o.defaults.headers.common.currency},async:!1,success:function({data:t}){return a(t)},error:function({response:t}){return e(t)}})}))}},S={options:[],header:"undefined"!=typeof navigator&&"undefined"!=typeof window?[navigator.platform,navigator.userAgent,navigator.appVersion,navigator.vendor,window.opera]:[],dataos:[{name:"Windows Phone",value:"Windows Phone",version:"OS"},{name:"Windows",value:"Win",version:"NT"},{name:"iPhone",value:"iPhone",version:"OS"},{name:"iPad",value:"iPad",version:"OS"},{name:"Kindle",value:"Silk",version:"Silk"},{name:"Android",value:"Android",version:"Android"},{name:"PlayBook",value:"PlayBook",version:"OS"},{name:"BlackBerry",value:"BlackBerry",version:"/"},{name:"Macintosh",value:"Mac",version:"OS X"},{name:"Linux",value:"Linux",version:"rv"},{name:"Palm",value:"Palm",version:"PalmOS"}],databrowser:[{name:"Chrome",value:"Chrome",version:"Chrome"},{name:"Firefox",value:"Firefox",version:"Firefox"},{name:"Safari",value:"Safari",version:"Version"},{name:"Internet Explorer",value:"MSIE",version:"MSIE"},{name:"Opera",value:"Opera",version:"Opera"},{name:"BlackBerry",value:"CLDC",version:"CLDC"},{name:"Mozilla",value:"Mozilla",version:"Mozilla"}],init:function(){var t=this.header.join(" ");return{os:this.matchItem(t,this.dataos),browser:this.matchItem(t,this.databrowser)}},matchItem:function(t,s){var i,a,e,o=0,n=0;for(o=0;o<s.length;o+=1)if(new RegExp(s[o].value,"i").test(t)){if(i=new RegExp(s[o].version+"[- /:;]([\\d._]+)","i"),e="",(a=t.match(i))&&a[1]&&(a=a[1]),a)for(a=a.split(/[._]+/),n=0;n<a.length;n+=1)e+=0===n?a[n]+".":a[n];else e="0";return{name:s[o].name,version:parseFloat(e)}}return{name:"unknown",version:0}}};async function C(t,s,i=!1){if(salla.logger.log("🍏 Pay: mutateShippingContact called",s,i),t.detail.requiredShippingContactFields&&0!=t.detail.requiredShippingContactFields.length)if(i){if(salla.config.isGuest()&&salla.config.get("store.features").includes("guest-checkout")){if(!(s.emailAddress&&s.givenName&&s.familyName&&s.phoneNumber)){salla.logger.warn("🍏 Pay: Guest contact fields are required",s);const i=[];return s.emailAddress||i.push(new window.ApplePayError("shippingContactInvalid","emailAddress","Email address is required")),s.phoneNumber||i.push(new window.ApplePayError("shippingContactInvalid","phoneNumber","Phone number is required")),s.givenName&&s.familyName||i.push(new window.ApplePayError("shippingContactInvalid","name","Name is required")),void t.session.completePayment({status:t.session.STATUS_INVALID_SHIPPING_CONTACT,errors:i})}await async function(t,s){return salla.logger.log("🍏 Pay: Updating guest contact",s),new Promise(((i,a)=>{_.post(t.detail.guestContactSelected.url.replace("{id}",t.id),{email:s.emailAddress||null,first_name:s.givenName||null,last_name:s.familyName||null,phone_number:s.phoneNumber||null,country_code:s.countryCode||null},(async({data:s})=>{"function"==typeof t.detail.guestContactSelected?.onSuccess&&t.detail.guestContactSelected.onSuccess(s),i(s)}),(({response:s})=>{salla.logger.warn("🍏 Pay: Failed to update guest contact via api",s),"function"==typeof t.detail.guestContactSelected?.onFailed&&t.detail.guestContactSelected.onFailed(s),a({response:s})}))}))}(t,s)}}else if(t.detail.requiredShippingContactFields.includes("postalAddress"))return _.post(t.detail.shippingContactSelected.url.replace("{id}",t.id),{country:s.country,city:s.locality,local:s.subLocality||s.administrativeArea||s.locality,description:s.subAdministrativeArea,street:s.addressLines?.join(", ")||s.administrativeArea,country_code:s.countryCode,postal_code:s.postalCode},(async({data:s})=>{if("function"==typeof t.detail.shippingContactSelected.onSuccess&&t.detail.shippingContactSelected.onSuccess(s),t.address_id=s.data.address_id,t.shipping_methods=s.data.shipping_methods,!t.shipping_methods||t.shipping_methods&&!t.shipping_methods.length)return salla.logger.warn("🍏 Pay: We dont found any supported methods",s),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]});try{await t.selectApplePayShippingMethod(t.shipping_methods[0])}catch(s){return salla.logger.warn("Failed set the shipping details to api",s),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}try{await t.recalculateTotal()}catch(s){return salla.logger.warn("🍏 Pay: Failed recalculate total",s),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}const i={newTotal:t.prepareTotal(),newLineItems:t.prepareLineItems(),newShippingMethods:t.mappingShippingMethods(t.shipping_methods)};salla.logger.log("🍏 Pay: completeShippingContactSelection",i),t.session.completeShippingContactSelection(i)}),(({response:s})=>{salla.logger.warn("🍏 Pay: Failed add address via api",s),"function"==typeof t.detail.shippingContactSelected.onFailed&&t.detail.shippingContactSelected.onFailed(s);let i=s?.data?.error?.fields,a=function(t){return Object.entries(t).filter((([t,s])=>s&&s.length>0)).map((([t,s])=>new window.ApplePayError("shippingContactInvalid",t,s[0])))}({countryCode:i?.country_code&&i.country_code.length>0?i.country_code[0]:null,locality:i?.city&&i.city.length>0?i.city[0]:null,country:i?.country&&i.country.length>0?i.country[0]:null});0===a.length&&s?.data?.error?.message&&a.push(new window.ApplePayError("shippingContactInvalid","locality",s?.data?.error?.message)),t.session.completeShippingContactSelection({newTotal:t.prepareTotal(),newLineItems:t.prepareLineItems(),status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:a})}))}"undefined"!=typeof window&&(window.Salla=window.Salla||{},window.Salla.Payments=window.Salla.Payments||{});const P="undefined"!=typeof window?{session:null,detail:null,address_id:null,shipping_methods:[],total:void 0,request:void 0,id:void 0,countryCode:null,totals:[],shippingCompany:null,init:function(){document.removeEventListener("payments::apple-pay.start-transaction",P.startSession),Salla.event.addEventListener("payments::apple-pay.start-transaction",P.startSession)},initDefault:function(){P.detail.onError||(P.detail.onError=function(t){salla.notify.error(t)}),P.detail.authorized.onFailed||(P.detail.authorized.onFailed=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleErrorResponse(t),P.onCancel({},t.data.error.message)}),P.detail.validateMerchant.onFailed||(P.detail.validateMerchant.onFailed=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleErrorResponse({response:t}),P.onCancel({},t.data.error.message)}),P.detail.authorized.onSuccess||(P.detail.authorized.onSuccess=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleAfterResponseActions(t)})},prepareLineItems:function(){return P.detail?.items?.length||(P.detail.items=[{label:salla.lang.get("pages.cart.items_total"),amount:parseFloat(P.detail.amount).toString()}]),P.detail.items},prepareTotal:function(){return{label:window.location.hostname||"Salla",amount:parseFloat(P.detail.amount).toString()}},isPhysical:()=>P.detail?.requiredShippingContactFields?.includes("postalAddress"),startSession:async function(t){P.detail=t.detail||t,salla.log("🍏 Pay: payments::apple-pay.start-transaction",P.detail),P.initDefault();let s,i=P.getApplePaySessionVersion(),a=P.detail.supportedNetworks,e=Array.isArray(a)?[...a]:Object.values(a||{});e.length||(e=["masterCard","visa"]),5!==i||e.includes("mada")||e.push("mada"),P.request={countryCode:P.detail.countryCode||"SA",supportsCouponCode:!0,couponCode:"",currencyCode:P.detail.currency||"SAR",requiredShippingContactFields:P.detail.requiredShippingContactFields?P.detail.requiredShippingContactFields:[],merchantCapabilities:["supports3DS"],supportedNetworks:e,supportedCountries:P.detail.supportedCountries||["SA"],total:P.prepareTotal(),shippingContact:P.detail.shippingContact?P.detail.shippingContact:{},shippingMethods:P.detail.shippingMethods&&P.detail.shippingMethods.length?P.mappingShippingMethods(t.detail.shippingMethods):[],lineItems:P.prepareLineItems()},salla.log("🍏 Pay: init ",P.request),P.session=new ApplePaySession(i,P.request),P.session.onshippingcontactselected=P.onShippingContactSelected,P.session.onshippingmethodselected=P.onShippingMethodSelected,P.session.onvalidatemerchant=P.onValidateMerchant,P.session.onpaymentauthorized=P.onPaymentAuthorized,P.session.oncancel=P.onCancel,P.session.oncouponcodechanged=P.onCouponCodeChanged,P.session.onpaymentmethodselected=P.onPaymentMethodSelected,"function"==typeof P.detail.onStartedSession&&(s=P.detail.onStartedSession(P.session)),s||P.session.begin()},onPaymentMethodSelected:async t=>{if(salla.logger.log("🍏 Pay: onPaymentMethodSelected",t),P.isPhysical())salla.logger.log("🍏 Pay: completePaymentMethodSelection",{newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()}),P.session.completePaymentMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()});else try{await P.recalculateTotal();const t={newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()};salla.logger.log("🍏 Pay: completePaymentMethodSelection",t),P.session.completePaymentMethodSelection(t)}catch(t){salla.logger.warn("🍏 Pay: Failed recalculate total",t),P.session.completePaymentMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems(),status:P.session.STATUS_FAILURE,errors:[new window.ApplePayError("unknown",void 0,t?.response?.data?.error?.message||t?.response?.data?.error?.code||"Failed to recalculate total")]})}},onCouponCodeChanged:t=>(Salla.event.dispatch("payments::apple-pay.coupon.change",t),_.post(P.detail.onCouponCodeChanged.url.replace("{id}",P.id),{coupon:t.couponCode,payment_method:"apple_pay"},(async({data:t})=>{"function"==typeof P.detail.onCouponCodeChanged.onSuccess&&P.detail.onCouponCodeChanged.onSuccess(t),salla.log("🍏 Pay: Coupon applied success"),await P.recalculateTotal(),P.session.completeCouponCodeChange({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()})}),(async t=>{let s=t?.response;Salla.event.dispatch("payments::apple-pay.coupon.failed",s),"function"==typeof P.detail.onCouponCodeChanged.onFailed&&P.detail.onCouponCodeChanged.onFailed(s),await P.recalculateTotal(),P.session.completeCouponCodeChange({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems(),errors:[new window.ApplePayError("couponCodeInvalid")]})}))),onCancel:(t={},s=null)=>{P.detail.onError(s||salla.lang.get("pages.checkout.payment_failed")),Salla.event.createAndDispatch("payments::apple-pay.canceled",t)},onPaymentAuthorized:async t=>{salla.logger.log("🍏 Pay: onPaymentAuthorized",t.payment);try{await C(P,t.payment.shippingContact,!0)}catch(t){salla.logger.error("🍏 Pay: Failed to update guest contact details",t);const s=t?.response||t,i=s?.data?.error?.fields||{},a=[];return i?.email&&i.email.length>0&&a.push(new window.ApplePayError("shippingContactInvalid","emailAddress",i.email[0])),i?.phone&&i.phone.length>0&&a.push(new window.ApplePayError("shippingContactInvalid","phoneNumber",i.phone[0])),i?.first_name&&i.first_name.length>0?a.push(new window.ApplePayError("shippingContactInvalid","name",i.first_name[0])):i?.last_name&&i.last_name.length>0&&a.push(new window.ApplePayError("shippingContactInvalid","name",i.last_name[0])),0===a.length&&a.push(new window.ApplePayError("shippingContactInvalid","name",s?.data?.error?.message||s?.data?.error?.code||"Invalid shipping contact details")),Salla.event.dispatch("payments::apple-pay.authorized.failed",s),"function"==typeof P.detail.authorized.onFailed&&P.detail.authorized.onFailed(s),void P.session.completePayment({status:ApplePaySession.STATUS_INVALID_SHIPPING_CONTACT,errors:a})}Salla.event.dispatch("payments::apple-pay.authorized.init",t),_.post(P.detail.authorized.url.replace("{id}",P.id),{payment_method:"apple_pay",applepay_token:JSON.stringify(t.payment)},(({data:t})=>{Salla.event.dispatch("payments::apple-pay.authorized.success",t),"function"==typeof P.detail.authorized.onSuccess&&P.detail.authorized.onSuccess(t),P.session.completePayment(ApplePaySession.STATUS_SUCCESS)}),(t=>{let s=t?.response;Salla.event.dispatch("payments::apple-pay.authorized.failed",s),"function"==typeof P.detail.authorized.onFailed&&P.detail.authorized.onFailed(s),P.session.completePayment({status:ApplePaySession.STATUS_FAILURE,errors:[new window.ApplePayError("unknown",void 0,s?.data?.error?.message||s?.data?.error?.code||"Failed to parse authorized response")]})}))},onValidateMerchant:async t=>{try{Salla.event.dispatch("payments::apple-pay.validate-merchant.init",t);const{data:s}=await _.post(P.detail.validateMerchant.url.replace("{id}",P.id),{validation_url:t.validationURL});Salla.event.dispatch("payments::apple-pay.validate-merchant.success",s);const i=t=>{P.session.completeMerchantValidation(t)};if("function"==typeof P.detail.validateMerchant.onSuccess){const t=await P.detail.validateMerchant.onSuccess(s);if(t?.redirect)return window.location=t.redirect,P.abortValidateMerchant(t)}i(s.data)}catch(t){console.error(t),P.abortValidateMerchant(t?.response)}},abortValidateMerchant:(t=null)=>{P.abortSession(),Salla.event.dispatch("payments::apple-pay.validate-merchant.failed",t),"function"==typeof P.detail.validateMerchant.onFailed&&P.detail.validateMerchant.onFailed(t)},onShippingContactSelected:async t=>{salla.logger.log("🍏 Pay: onShippingContactSelected",t.shippingContact),await C(P,t.shippingContact)},onShippingMethodSelected:async t=>{let s=t.shippingMethod.identifier.split(","),i={ship_id:s[0],private_ship_id:void 0===s[1]?null:s[1],type:void 0===s[2]?null:s[2],route_id:void 0===s[3]?null:s[3]};if(salla.logger.log("🍏 Pay: onShippingMethodSelected",{event:t,previous:P.shippingCompany,current:i}),P.shouldUpdateShippingCompany(i))try{await P.selectApplePayShippingMethod(i),await P.recalculateTotal()}catch(t){return salla.logger.warn("🍏 Pay: Failed set the shipping details to api",t),void P.session.completeShippingMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems(),status:P.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}salla.logger.log("🍏 Pay: completeShippingMethodSelection",{newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()}),P.session.completeShippingMethodSelection({newTotal:P.prepareTotal(),newLineItems:P.prepareLineItems()})},abortSession:()=>{P.session&&P.session.abort()},shouldUpdateShippingCompany:t=>P.shippingCompany?.ship_id!=t?.ship_id||P.shippingCompany?.private_ship_id!=t?.private_ship_id,getApplePaySessionVersion:()=>{if("sallapp"===(navigator.userAgent||navigator.vendor||window.opera))return 5;let t=S.init(),s=parseFloat(t.os.version);if("Macintosh"===t.os.name){if(s<10.142)return 1}else if(s<12.11)return 1;return 5},recalculateTotal:()=>(salla.logger.log("🍏 Pay: recalculate total"),_.get(P.detail.recalculateTotal.url.replace("{id}",P.id),(({data:t})=>{salla.logger.log("🍏 Pay: recalculate total success",t);let s=t.data.initial_data?.cart||t.data.cart,i=t.data.initial_data?.payments||t.data.payments;salla.logger.log("🍏 Pay: recalculate total success",{cart:s,payments:i}),null!=i?.gateways?.applePay?.amount?(P.detail.amount=i.gateways.applePay.amount,P.detail.currency=i.gateways.applePay.currency??P.detail.currency):P.detail.amount=i?.gateways?.applePay?.supportedMultiCurrency?s.total_in_customer_currency:s.total,P.detail.items=(s.totals||s.items).map((t=>({label:t.title,amount:"مجاني"===t.amount||"Free"===t.amount?0:t.amount.toString().replace("+","")}))),P.detail.items.pop(),P.totals=P.detail.items}),(t=>(salla.logger.warn("🍏 Pay: recalculate total failed",t),t?.response?.data?.message)))),selectApplePayShippingMethod:t=>{salla.logger.log("🍏 Pay: select shipping method ",t),P.shippingCompany=t;const s={address_id:P.address_id,company_id:t.ship_id,private_company_id:t.private_ship_id,type:t.type||void 0,route_id:t.route_id||void 0,payment_method:"apple_pay"};return _.post(P.detail.shippingMethodSelected.url.replace("{id}",P.id),s,(({data:t})=>("function"==typeof P.detail.shippingMethodSelected.onSuccess&&P.detail.shippingMethodSelected.onSuccess(t),!0)),(t=>{salla.logger.warn("🍏 Pay: Set shipping method failed",t),"function"==typeof P.detail.shippingMethodSelected.onFailed&&P.detail.shippingMethodSelected.onFailed(t);let s=t?.response?.data?.error;return s?.data?.fields?.address_id?s?.data?.fields?.address_id[0]:s?.data?.message}))},mappingShippingMethods:t=>t.map((t=>({label:t.shipping_title,amount:t.enable_free_shipping?0:t.ship_cost,detail:"",identifier:t.ship_id.toString()+(t.private_ship_id?","+t.private_ship_id.toString():"")+(t.type?","+t.type:"")+(t.route_id?","+t.route_id:"")})))}:{};"undefined"!=typeof window&&(window.SallaApplePay=P),"undefined"!=typeof window&&window.ApplePaySession?.canMakePayments()?P.init():"undefined"!=typeof document&&document.querySelectorAll("data-show-if-apple-pay-supported").forEach((t=>t.style.display="none"));const O=class{constructor(i){t(this,i),this.validationFailed=s(this,"validationFailed"),this.requireLogin=s(this,"requireLogin"),this.type="buy",this.productType="product",this.options={},this.collectedOrderOptions=[],this.optionsResolved=!1,this.applePayAmount=0,this.pendingApplePaySession=null,this.quickBuy=salla.lang.get("pages.products.buy_now"),this.handleApplePaySessionStarted=t=>!!salla.config.get("store.settings.order_options.mandatory",!1)&&!this.optionsResolved&&(this.optionsResolved=!0,this.pendingApplePaySession=t,async function(t){let s;try{s=await salla.api.withoutNotifier((()=>salla.product.api.getOrderOptions([{id:t.productId,quantity:t.quantity}])))}catch(s){return salla?.logger?.warn?.("order-options: fetch failed",s),void t.beginPendingSession()}const i=s?.data?.order_options||[];if(!i.length)return void t.beginPendingSession();t.discardPendingSession();const a=Number(t.amount)>0?Number(t.amount):Number(s?.data?.products?.[0]?.price?.amount)||0,e=function(){let t=document.querySelector("salla-order-options-modal");return t||(t=document.createElement("salla-order-options-modal"),document.body.appendChild(t)),t}();try{await e.open({orderOptions:i,basePrice:a,paymentMode:"apple-pay",onSubmit:t.onSubmit})}catch{}}({productId:this.productId,amount:Number(this.amount),quantity:this.getSelectedQuantity(),beginPendingSession:()=>{this.pendingApplePaySession?.begin(),this.pendingApplePaySession=null},discardPendingSession:()=>{this.pendingApplePaySession=null},onSubmit:(t,s)=>{this.collectedOrderOptions=t,this.applePayAmount=s,this.settlePayment()}}),!0),salla.lang.onLoaded((()=>{this.quickBuy=salla.lang.get("pages.products.buy_now")}))}quickBuyHandler(){if(salla.config.isGuest()&&!this.isGuestCheckout())return this.requireLogin.emit({productId:this.productId}),void salla.api.auth.requireLoginThen("salla-quick-buy::user.logged-in",(()=>this.quickBuyHandler()));this.validatePdpOptionsSync()&&(this.optionsResolved=!1,this.collectedOrderOptions=[],this.applePayAmount=0,this.settlePayment())}validatePdpOptionsSync(){return!!function(t){const s=document.querySelector(`salla-product-options[product-id="${t}"]`);if(!s)return!0;const i=s.querySelectorAll("[required]");let a=!0;return i.forEach((t=>{t.disabled||t.closest(".hidden")||"reportValidity"in t&&!t.reportValidity()&&(a=!1)})),a}(this.productId)||(this.validationFailed.emit({productId:this.productId}),salla.error(salla.lang.get("common.messages.required_fields")),!1)}getSelectedQuantity(){try{const t=this.host.getElementSallaData?.(),s=Number(t instanceof FormData?t.get("quantity"):t?.quantity);return Number.isFinite(s)&&s>0?s:1}catch{return 1}}async settlePayment(){let t=this.host.getElementSallaData();if(function(t,s){s.length&&(t&&"function"==typeof t.append?s.forEach(((s,i)=>{t.append(`order_options[${i}][id]`,String(s.id)),t.append(`order_options[${i}][value]`,String(s.value))})):t&&"object"==typeof t&&(t.order_options=s))}(t,this.collectedOrderOptions),!this.isApplePayActive)return salla.api.request("checkout/quick-purchase/"+this.productId,t,"post").then((t=>(t.data.redirect&&(window.location.href=t.data.redirect),t)));t.is_applepay=!0,"append"in t&&t.append("is_applepay",!0),salla.event.dispatch("payments::apple-pay.start-transaction",{amount:this.applePayAmount>0?this.applePayAmount:this.amount,currency:this.currency||salla.config.get("store.settings.buy_now.currency")||"SAR",requiredShippingContactFields:this.getRequiredShippingContactFields(),shippingMethods:this.isRequireShipping?[]:void 0,supportedNetworks:this.isLegacyBuyNowBE()?salla.config.get("store.settings.buy_now.networks"):Array.isArray(this.supportedNetworks)&&this.supportedNetworks.length?this.supportedNetworks:salla.config.get("store.settings.buy_now.supportedNetworks"),supportedCountries:this.isLegacyBuyNowBE()?salla.config.get("store.settings.buy_now.countries"):Array.isArray(this.supportedCountries)&&this.supportedCountries.length?this.supportedCountries:salla.config.get("store.settings.buy_now.supportedCountries"),countryCode:salla.config.get("store.store_country")||"SA",onStartedSession:this.handleApplePaySessionStarted,validateMerchant:{url:this.validateHost?`${this.validateHost}/checkout/applepay/validate`:salla.url.get("checkout/applepay/validate"),onSuccess:s=>this.applePayOnly&&!this.productId?this.cartId?(window.SallaApplePay.id=this.cartId,salla.log("🍏 Pay: create checkout success: with id #"+this.cartId),Promise.resolve(s)):(salla.logger.warn("🍏 Pay: trying to create applePay transaction without cartId/ProductId !"),Promise.resolve(s)):salla.api.request("checkout/quick-purchase/"+this.productId,"object"==typeof t?t:void 0,"post",{}).then((t=>t?.data?.redirect?(salla.log("🍏 Pay: create checkout success: redirect exits, go to checkout page"),window.location.href=t.data.redirect.url,t):t?.data?.id?(window.SallaApplePay.id=t.data.id,void salla.log("🍏 Pay: create checkout success: with id #"+window.SallaApplePay.id)):(salla.logger.warn("🍏 Pay: create checkout success: No id, or redirect"),t)))},authorized:{url:salla.url.get("checkout/{id}/payments/submit"),onFailed:t=>{window.SallaApplePay.onCancel({},t?.data?.error?.message||t?.data?.error?.code||salla.lang.get("pages.checkout.payment_failed"))},onSuccess:t=>{window.location.href=t.redirect.url,salla.log("🍏 Pay: authorized Success:: redirect to thank you page, order placed")}},shippingMethodSelected:this.isRequireShipping?{url:salla.url.get("checkout/{id}/shipping/details")}:void 0,shippingContactSelected:this.isRequireShipping?{url:salla.url.get("checkout/{id}/address/add")}:void 0,guestContactSelected:this.isGuestCheckout()?{url:salla.url.get("checkout/{id}/customer")}:void 0,onCouponCodeChanged:{url:salla.url.get("checkout/{id}/coupons")},recalculateTotal:{url:salla.url.get("checkout/{id}/payments/recalculate?payment_method=apple_pay")},onError:function(t){salla.log(t),salla.notify.error(t)}})}isGuestCheckout(){return salla.config.isGuest()&&salla.config.get("store.features").includes("guest-checkout")&&this.isPhysicalProduct()}getRequiredShippingContactFields(){let t=[];return this.isRequireShipping&&t.push("postalAddress"),this.isGuestCheckout()&&t.push("email","phone","name"),t}isLegacyBuyNowBE(){return null!=salla?.config?.get?.("store.settings.buy_now.multi_currency")}applyBaseCurrencyPrice(t){if(this.isLegacyBuyNowBE())return void(null!=t?.price&&(this.amount=t.price));const s=t?.base_currency_price;null!=s?.amount?(this.amount=s.amount,s?.currency&&(this.currency=s.currency)):null!=t?.price&&(this.amount=t.price,this.currency=salla.config.get("user.currency_code")||this.currency||"SAR")}componentWillLoad(){console.log("🍏 Pay: Quick Buy Component Loaded");const t="undefined"!=typeof window&&!!window.ApplePaySession?.canMakePayments?.(),s=salla?.config?.get?.("store.settings.payments")?.includes?.("apple_pay")??!0,i=salla?.config?.get?.("store.settings.is_salla_gateway",!1)??!0;this.isApplePayActive=t&&s&&i;const a=async()=>{if(this.isLegacyBuyNowBE()&&!this.currency&&salla?.config?.get&&(this.currency=salla.config.get("store.settings.buy_now.multi_currency")?salla.config.get("user.currency_code"):salla.config.get("store.settings.buy_now.currency")||"SAR"),!this.productId&&salla?.config?.get&&salla.url?.is_page&&(this.productId=salla.config.get("page.id")),this.applePayOnly||this.productId){if(this.amount&&this.isRequireShipping||!this.productId||!salla?.product?.getDetails||await salla.product.getDetails(this.productId,[]).then((t=>{this.applyBaseCurrencyPrice(t?.data),this.isRequireShipping=t?.data?.is_require_shipping||!1})).catch((t=>{salla?.logger?.warn?.("🍏 Pay: Failed load the quick buy, get the product details failed: ",t)})),"donate"===this.type&&salla?.event?.on?salla.event.on("product-options::donation-changed",(t=>{String(t.id)===String(this.productId)&&this.applyBaseCurrencyPrice(t)})):salla?.url?.is_page?.("product.single")&&salla?.product?.event?.onPriceUpdated&&salla.product.event.onPriceUpdated((t=>{this.applyBaseCurrencyPrice(t?.data)})),this.isApplePayActive=(salla?.helpers?.hasApplePay?.()??t)&&(salla?.config?.get?.("store.settings.payments")?.includes?.("apple_pay")??s)&&(salla?.config?.get?.("store.settings.is_salla_gateway",!1)??i),!document.getElementById("apple-pay-sdk")&&this.isApplePayActive){const t=document.createElement("script");t.src="https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js",t.setAttribute("id","apple-pay-sdk"),t.async=!0,document.body.appendChild(t)}}else salla?.logger?.warn?.("🍏 Pay: Failed load the quick buy, the product id is missing")};return new Promise((t=>{"function"==typeof salla?.onReady?salla.onReady((()=>a().then((()=>t(!0))))):a().then((()=>t(!0)))}))}render(){return i(a,{key:"c2ba63eb4fad49f80977d6f1adc836f655524933"},this.quickBuyButton())}quickBuyButton(){return i("apple-pay-button",{locale:salla?.config?.get?.("user.language_code")||"ar",onClick:()=>this.quickBuyHandler(),"data-quick-purchase":"applepay",class:"s-quick-buy-apple-pay","data-is-applepay":"1",buttonstyle:"black",type:this.type})}isPhysicalProduct(){return"product"===this.productType||"group_products"===this.productType||"food"===this.productType}get host(){return e(this)}};O.style=".s-quick-buy-button .s-button-text{display:flex}apple-pay-button{--apple-pay-button-width:100%;--apple-pay-button-height:40px;--apple-pay-button-border-radius:.75rem;--apple-pay-button-box-sizing:content-box}";export{m as salla_add_product_button,y as salla_bought_together,g as salla_product_availability,v as salla_product_options,O as salla_quick_buy}