@salla.sa/twilight-components 2.14.418 → 2.14.419
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.
- package/dist/cjs/{filepond-C1_8U7ht.js → filepond-BiRMqsJc.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-poster-C2QZkcu0.js → filepond-plugin-file-poster-LU25G59n.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-size-CbVRd24w.js → filepond-plugin-file-validate-size-J3-riOvN.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-type-63RP4vcL.js → filepond-plugin-file-validate-type-DMawm6j5.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-edit-CjWMhhkZ.js → filepond-plugin-image-edit-QXtHYcEz.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-CJxStqYG.js → filepond-plugin-image-exif-orientation-C0VBHQjd.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview--RTa59Q8.js → filepond-plugin-image-preview-xG9m-vgD.js} +1 -1
- package/dist/cjs/{functions-T48FHZw8.js → functions-CZrHAX2r.js} +1 -1
- package/dist/cjs/helpers-BJ2rnhxz.js +197 -0
- package/dist/cjs/{index-DO_QXaSt.js → index-Ce-Twd7-.js} +10 -6
- package/dist/cjs/{index-CQ4zjhzH.js → index-DE1iYzD2.js} +1 -1
- package/dist/cjs/interfaces-Bh7W0bEU.js +33 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/salla-accordion-body_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-accordion_6.cjs.entry.js +1 -1
- package/dist/cjs/salla-add-product-button_5.cjs.entry.js +36 -58
- package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
- package/dist/cjs/salla-alert_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
- package/dist/cjs/salla-badge.cjs.entry.js +1 -1
- package/dist/cjs/salla-booking-field_7.cjs.entry.js +12 -12
- package/dist/cjs/salla-bullet-delivery.cjs.entry.js +1 -1
- package/dist/cjs/salla-cart-coupons.cjs.entry.js +1 -1
- package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-comment-form_8.cjs.entry.js +4 -4
- package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
- package/dist/cjs/salla-cookies-bar.cjs.entry.js +1 -1
- package/dist/cjs/salla-count-down.cjs.entry.js +1 -1
- package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
- package/dist/cjs/salla-delivery-promise.cjs.entry.js +1 -1
- package/dist/cjs/salla-edit-order-button.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters.cjs.entry.js +1 -1
- package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +1 -1
- package/dist/cjs/salla-gifting.cjs.entry.js +1 -1
- package/dist/cjs/salla-hook.cjs.entry.js +1 -1
- package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
- package/dist/cjs/salla-installment.cjs.entry.js +1 -1
- package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
- package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-banner.cjs.entry.js +2 -2
- package/dist/cjs/salla-loyalty-hero_2.cjs.entry.js +2 -2
- package/dist/cjs/salla-loyalty-panel.cjs.entry.js +3 -3
- package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-program.cjs.entry.js +3 -3
- package/dist/cjs/salla-loyalty-reward.cjs.entry.js +2 -2
- package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
- package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-map.cjs.entry.js +1 -1
- package/dist/cjs/salla-menu.cjs.entry.js +1 -1
- package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-edit-item.cjs.entry.js +28 -29
- package/dist/cjs/salla-order-edit-product-card.cjs.entry.js +41 -0
- package/dist/cjs/salla-order-edit.cjs.entry.js +339 -40
- package/dist/cjs/salla-order-summary.cjs.entry.js +2 -2
- package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-orders.cjs.entry.js +1 -1
- package/dist/cjs/salla-payments.cjs.entry.js +3 -3
- package/dist/cjs/salla-placeholder.cjs.entry.js +2 -2
- package/dist/cjs/salla-price-range.cjs.entry.js +3 -3
- package/dist/cjs/salla-product-card_2.cjs.entry.js +6 -6
- package/dist/cjs/salla-product-size-guide.cjs.entry.js +3 -3
- package/dist/cjs/salla-products-list.cjs.entry.js +38 -15
- package/dist/cjs/salla-progress-bar.cjs.entry.js +1 -1
- package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
- package/dist/cjs/salla-rating-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-reward-action_4.cjs.entry.js +3 -3
- package/dist/cjs/salla-scopes.cjs.entry.js +2 -2
- package/dist/cjs/salla-search.cjs.entry.js +6 -6
- package/dist/cjs/salla-skeleton.cjs.entry.js +2 -2
- package/dist/cjs/salla-slider.cjs.entry.js +1 -1
- package/dist/cjs/salla-social-share.cjs.entry.js +2 -2
- package/dist/cjs/salla-social.cjs.entry.js +2 -2
- package/dist/cjs/salla-tab-content_3.cjs.entry.js +4 -4
- package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-tooltip.cjs.entry.js +2 -2
- package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
- package/dist/cjs/salla-user-menu.cjs.entry.js +1 -1
- package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
- package/dist/cjs/salla-user-settings.cjs.entry.js +2 -2
- package/dist/cjs/salla-verify.cjs.entry.js +1 -1
- package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
- package/dist/cjs/{tracked-promise-BnNAgCN_.js → tracked-promise-DChUtH5B.js} +1 -1
- package/dist/cjs/twilight.cjs.js +2 -2
- package/dist/cjs/{vanilla-picker-wbE79zwn.js → vanilla-picker-ivACsPLJ.js} +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/salla-order-edit/helpers.js +181 -0
- package/dist/collection/components/salla-order-edit/salla-order-edit-item.css +3 -0
- package/dist/collection/components/salla-order-edit/salla-order-edit-item.js +42 -30
- package/dist/collection/components/salla-order-edit/salla-order-edit-product-card.css +4 -0
- package/dist/collection/components/salla-order-edit/salla-order-edit-product-card.js +93 -0
- package/dist/collection/components/salla-order-edit/salla-order-edit.css +3 -0
- package/dist/collection/components/salla-order-edit/salla-order-edit.js +353 -39
- package/dist/collection/components/salla-order-summary/salla-order-summary.js +1 -1
- package/dist/collection/components/salla-payments/salla-payments.js +2 -2
- package/dist/collection/components/salla-placeholder/salla-placeholder.js +1 -1
- package/dist/collection/components/salla-price-range/salla-price-range.js +2 -2
- package/dist/collection/components/salla-product-availability/salla-product-availability.js +1 -1
- package/dist/collection/components/salla-product-card/salla-product-card.js +5 -5
- package/dist/collection/components/salla-product-options/salla-product-options.js +28 -0
- package/dist/collection/components/salla-product-size-guide/salla-product-size-guide.js +2 -2
- package/dist/collection/components/salla-products-list/salla-products-list.js +54 -14
- package/dist/collection/components/salla-quantity-input/salla-quantity-input.js +1 -1
- package/dist/collection/components/salla-quick-buy/salla-quick-buy.js +1 -1
- package/dist/collection/components/salla-review-card/salla-review-card.js +1 -1
- package/dist/collection/components/salla-reviews/salla-reviews.js +1 -1
- package/dist/collection/components/salla-reviews-page/salla-reviews-page.js +1 -1
- package/dist/collection/components/salla-scopes/salla-scopes.js +1 -1
- package/dist/collection/components/salla-search/salla-search.js +5 -5
- package/dist/collection/components/salla-skeleton/salla-skeleton.js +1 -1
- package/dist/collection/components/salla-social/salla-social.js +1 -1
- package/dist/collection/components/salla-social-share/salla-social-share.js +1 -1
- package/dist/collection/components/salla-tabs/salla-tab-content.js +1 -1
- package/dist/collection/components/salla-tabs/salla-tab-header.js +1 -1
- package/dist/collection/components/salla-tabs/salla-tabs.js +1 -1
- package/dist/collection/components/salla-tel-input/salla-tel-input.js +1 -1
- package/dist/collection/components/salla-tooltip/salla-tooltip.js +1 -1
- package/dist/collection/components/salla-user-settings/salla-user-settings.js +1 -1
- package/dist/components/index.js +2 -2
- package/dist/components/salla-order-edit-item2.js +207 -30
- package/dist/components/salla-order-edit-product-card.d.ts +11 -0
- package/dist/components/salla-order-edit-product-card.js +59 -0
- package/dist/components/salla-order-edit.js +378 -65
- package/dist/components/salla-order-summary.js +1 -1
- package/dist/components/salla-payments.js +2 -2
- package/dist/components/salla-placeholder2.js +1 -1
- package/dist/components/salla-price-range2.js +2 -2
- package/dist/components/salla-product-availability2.js +1 -1
- package/dist/components/salla-product-card2.js +5 -5
- package/dist/components/salla-product-options2.js +8 -1
- package/dist/components/salla-product-size-guide.js +2 -2
- package/dist/components/salla-products-list2.js +39 -15
- package/dist/components/salla-quantity-input2.js +1 -1
- package/dist/components/salla-quick-buy2.js +1 -1
- package/dist/components/salla-review-card2.js +1 -1
- package/dist/components/salla-reviews-page.js +1 -1
- package/dist/components/salla-reviews.js +1 -1
- package/dist/components/salla-scopes.js +1 -1
- package/dist/components/salla-search.js +5 -5
- package/dist/components/salla-skeleton2.js +1 -1
- package/dist/components/salla-social-share.js +1 -1
- package/dist/components/salla-social.js +1 -1
- package/dist/components/salla-tab-content2.js +1 -1
- package/dist/components/salla-tab-header2.js +1 -1
- package/dist/components/salla-tabs2.js +1 -1
- package/dist/components/salla-tel-input2.js +1 -1
- package/dist/components/salla-tooltip2.js +1 -1
- package/dist/components/salla-user-settings.js +1 -1
- package/dist/esm/{filepond-BaqNYv3C.js → filepond-0Pvy36B6.js} +1 -1
- package/dist/esm/{filepond-plugin-file-poster-nENZqIRv.js → filepond-plugin-file-poster-DV7OW1XJ.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-size-DGOq4RG8.js → filepond-plugin-file-validate-size-DEya24r_.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-type-DwM-3UO7.js → filepond-plugin-file-validate-type-DiFvVzC6.js} +1 -1
- package/dist/esm/{filepond-plugin-image-edit-BCqDiFWK.js → filepond-plugin-image-edit-DGBw5KRt.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-DiuxhjrQ.js → filepond-plugin-image-exif-orientation-BbpZAlI-.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-DbFvPPQQ.js → filepond-plugin-image-preview-CjRkn0jY.js} +1 -1
- package/dist/esm/{functions-JPNAXx4d.js → functions-BcJ4xDKw.js} +1 -1
- package/dist/esm/helpers-DR_vlSvU.js +184 -0
- package/dist/esm/{index-DElBWCVR.js → index-313k5SuU.js} +1 -1
- package/dist/esm/{index-BwsreBbG.js → index-CfaNNoM2.js} +10 -6
- package/dist/esm/interfaces-CoQJOPRz.js +33 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/salla-accordion-body_2.entry.js +1 -1
- package/dist/esm/salla-accordion_6.entry.js +1 -1
- package/dist/esm/salla-add-product-button_5.entry.js +10 -32
- package/dist/esm/salla-advertisement.entry.js +1 -1
- package/dist/esm/salla-alert_2.entry.js +1 -1
- package/dist/esm/salla-app-install-alert.entry.js +1 -1
- package/dist/esm/salla-apps-icons.entry.js +1 -1
- package/dist/esm/salla-badge.entry.js +1 -1
- package/dist/esm/salla-booking-field_7.entry.js +12 -12
- package/dist/esm/salla-bullet-delivery.entry.js +1 -1
- package/dist/esm/salla-cart-coupons.entry.js +1 -1
- package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
- package/dist/esm/salla-comment-form_8.entry.js +4 -4
- package/dist/esm/salla-conditional-offer.entry.js +1 -1
- package/dist/esm/salla-contacts.entry.js +1 -1
- package/dist/esm/salla-cookies-bar.entry.js +1 -1
- package/dist/esm/salla-count-down.entry.js +1 -1
- package/dist/esm/salla-custom-fields.entry.js +1 -1
- package/dist/esm/salla-delivery-promise.entry.js +1 -1
- package/dist/esm/salla-edit-order-button.entry.js +1 -1
- package/dist/esm/salla-filters-widget.entry.js +1 -1
- package/dist/esm/salla-filters.entry.js +1 -1
- package/dist/esm/salla-fulfillment-methods.entry.js +1 -1
- package/dist/esm/salla-gifting.entry.js +1 -1
- package/dist/esm/salla-hook.entry.js +1 -1
- package/dist/esm/salla-infinite-scroll.entry.js +1 -1
- package/dist/esm/salla-installment.entry.js +1 -1
- package/dist/esm/salla-list-tile.entry.js +1 -1
- package/dist/esm/salla-localization-modal.entry.js +1 -1
- package/dist/esm/salla-login-modal.entry.js +1 -1
- package/dist/esm/salla-loyalty-banner.entry.js +2 -2
- package/dist/esm/salla-loyalty-hero_2.entry.js +2 -2
- package/dist/esm/salla-loyalty-panel.entry.js +3 -3
- package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
- package/dist/esm/salla-loyalty-program.entry.js +3 -3
- package/dist/esm/salla-loyalty-reward.entry.js +2 -2
- package/dist/esm/salla-loyalty.entry.js +1 -1
- package/dist/esm/salla-maintenance-alert.entry.js +1 -1
- package/dist/esm/salla-map.entry.js +1 -1
- package/dist/esm/salla-menu.entry.js +1 -1
- package/dist/esm/salla-metadata.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-notification-item.entry.js +1 -1
- package/dist/esm/salla-notifications.entry.js +1 -1
- package/dist/esm/salla-offer-modal.entry.js +1 -1
- package/dist/esm/salla-offer.entry.js +1 -1
- package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-order-details-options.entry.js +1 -1
- package/dist/esm/salla-order-details.entry.js +1 -1
- package/dist/esm/salla-order-edit-item.entry.js +28 -29
- package/dist/esm/salla-order-edit-product-card.entry.js +39 -0
- package/dist/esm/salla-order-edit.entry.js +339 -40
- package/dist/esm/salla-order-summary.entry.js +2 -2
- package/dist/esm/salla-order-totals-card.entry.js +1 -1
- package/dist/esm/salla-orders.entry.js +1 -1
- package/dist/esm/salla-payments.entry.js +3 -3
- package/dist/esm/salla-placeholder.entry.js +2 -2
- package/dist/esm/salla-price-range.entry.js +3 -3
- package/dist/esm/salla-product-card_2.entry.js +6 -6
- package/dist/esm/salla-product-size-guide.entry.js +3 -3
- package/dist/esm/salla-products-list.entry.js +38 -15
- package/dist/esm/salla-progress-bar.entry.js +1 -1
- package/dist/esm/salla-quick-order.entry.js +1 -1
- package/dist/esm/salla-rating-modal.entry.js +1 -1
- package/dist/esm/salla-reward-action_4.entry.js +3 -3
- package/dist/esm/salla-scopes.entry.js +2 -2
- package/dist/esm/salla-search.entry.js +6 -6
- package/dist/esm/salla-skeleton.entry.js +2 -2
- package/dist/esm/salla-slider.entry.js +1 -1
- package/dist/esm/salla-social-share.entry.js +2 -2
- package/dist/esm/salla-social.entry.js +2 -2
- package/dist/esm/salla-tab-content_3.entry.js +4 -4
- package/dist/esm/salla-tiered-offer.entry.js +1 -1
- package/dist/esm/salla-tooltip.entry.js +2 -2
- package/dist/esm/salla-trust-badges.entry.js +1 -1
- package/dist/esm/salla-user-menu.entry.js +1 -1
- package/dist/esm/salla-user-profile.entry.js +1 -1
- package/dist/esm/salla-user-settings.entry.js +2 -2
- package/dist/esm/salla-verify.entry.js +1 -1
- package/dist/esm/salla-wallet.entry.js +1 -1
- package/dist/esm/{tracked-promise-BD-FZk2P.js → tracked-promise-xD-AZOwt.js} +1 -1
- package/dist/esm/twilight.js +3 -3
- package/dist/esm/{vanilla-picker-CqoFxJJE.js → vanilla-picker-Bu8PG2Le.js} +1 -1
- package/dist/twilight/{p-ce588635.entry.js → p-02600ee1.entry.js} +1 -1
- package/dist/twilight/{p-c5e18341.entry.js → p-02608fcd.entry.js} +1 -1
- package/dist/twilight/{p-f73c7b43.entry.js → p-029f9bfd.entry.js} +1 -1
- package/dist/twilight/p-073536c3.entry.js +4 -0
- package/dist/twilight/{p-ceb9458e.entry.js → p-0d4afc4b.entry.js} +1 -1
- package/dist/twilight/{p-edaba475.entry.js → p-11da9c5a.entry.js} +1 -1
- package/dist/twilight/{p-7d3722ad.entry.js → p-13b1dae0.entry.js} +1 -1
- package/dist/twilight/{p-ab5e0aef.entry.js → p-13f019f5.entry.js} +1 -1
- package/dist/twilight/{p-069485ec.entry.js → p-15be9e7a.entry.js} +1 -1
- package/dist/twilight/{p-d9c4d2ed.entry.js → p-1bce06bf.entry.js} +1 -1
- package/dist/twilight/{p-0bf11f89.entry.js → p-1fe827c7.entry.js} +1 -1
- package/dist/twilight/{p-fec6b08b.entry.js → p-22d12f28.entry.js} +1 -1
- package/dist/twilight/{p-b737dbcb.entry.js → p-2afe64d1.entry.js} +1 -1
- package/dist/twilight/{p-3f50a52d.entry.js → p-2bb796b3.entry.js} +1 -1
- package/dist/twilight/{p-f653f2bb.entry.js → p-2f1cb6da.entry.js} +1 -1
- package/dist/twilight/{p-f88806d7.entry.js → p-3252277a.entry.js} +1 -1
- package/dist/twilight/{p-4110e600.entry.js → p-3539d2a1.entry.js} +1 -1
- package/dist/twilight/{p-167f5262.entry.js → p-3bda095b.entry.js} +1 -1
- package/dist/twilight/{p-61215f22.entry.js → p-3d286589.entry.js} +1 -1
- package/dist/twilight/{p-5ac81ffe.entry.js → p-410f0149.entry.js} +1 -1
- package/dist/twilight/{p-57451f00.entry.js → p-42bf8cc1.entry.js} +1 -1
- package/dist/twilight/p-43c4c857.entry.js +4 -0
- package/dist/twilight/{p-ff90dbf0.entry.js → p-4550de2d.entry.js} +1 -1
- package/dist/twilight/{p-fbe07d2d.entry.js → p-4752dc2c.entry.js} +1 -1
- package/dist/twilight/{p-9d8e4e7c.entry.js → p-48aba4cd.entry.js} +1 -1
- package/dist/twilight/p-49e28ca2.entry.js +4 -0
- package/dist/twilight/{p-10884e6e.entry.js → p-4a7cbe49.entry.js} +1 -1
- package/dist/twilight/{p-46088f51.entry.js → p-51252013.entry.js} +1 -1
- package/dist/twilight/{p-29fc145b.entry.js → p-53e63007.entry.js} +1 -1
- package/dist/twilight/{p-dcc65eb2.entry.js → p-57a4f3d2.entry.js} +1 -1
- package/dist/twilight/{p-a96ec635.entry.js → p-5dbb89d5.entry.js} +1 -1
- package/dist/twilight/p-5dd07559.entry.js +4 -0
- package/dist/twilight/{p-ac008da7.entry.js → p-5dd75357.entry.js} +1 -1
- package/dist/twilight/p-5e4e45be.entry.js +4 -0
- package/dist/twilight/{p-d0cf9b68.entry.js → p-5f174a3e.entry.js} +1 -1
- package/dist/twilight/{p-695e3211.entry.js → p-625218f7.entry.js} +1 -1
- package/dist/twilight/{p-03c39b2d.entry.js → p-654a0990.entry.js} +1 -1
- package/dist/twilight/{p-d739ae41.entry.js → p-654b9857.entry.js} +1 -1
- package/dist/twilight/{p-60878c2e.entry.js → p-65ff0bf4.entry.js} +1 -1
- package/dist/twilight/{p-aaff5603.entry.js → p-665aa4d1.entry.js} +1 -1
- package/dist/twilight/{p-5b371b1f.entry.js → p-69bec0e3.entry.js} +1 -1
- package/dist/twilight/{p-2bd83486.entry.js → p-6b02b118.entry.js} +1 -1
- package/dist/twilight/{p-44db7163.entry.js → p-72d4121c.entry.js} +1 -1
- package/dist/twilight/{p-993bdcbe.entry.js → p-74cd506d.entry.js} +1 -1
- package/dist/twilight/{p-b6ac7a22.entry.js → p-75f26291.entry.js} +1 -1
- package/dist/twilight/{p-1c3e0dbc.entry.js → p-7ce1dff1.entry.js} +1 -1
- package/dist/twilight/{p-7d492d3c.entry.js → p-7d08def1.entry.js} +1 -1
- package/dist/twilight/{p-ad762138.entry.js → p-7f6c6d8a.entry.js} +1 -1
- package/dist/twilight/{p-0a786447.entry.js → p-82d776ae.entry.js} +1 -1
- package/dist/twilight/{p-d469525b.entry.js → p-87e78adc.entry.js} +1 -1
- package/dist/twilight/{p-b6dce61a.entry.js → p-891e4b61.entry.js} +1 -1
- package/dist/twilight/{p-91d74168.entry.js → p-8bdd9c9b.entry.js} +1 -1
- package/dist/twilight/{p-19e82de2.entry.js → p-8d0b4049.entry.js} +1 -1
- package/dist/twilight/{p-9134d94d.entry.js → p-8dbff2c8.entry.js} +1 -1
- package/dist/twilight/{p-9c73e42a.entry.js → p-944b02ec.entry.js} +1 -1
- package/dist/twilight/{p-af1474dd.entry.js → p-9693310b.entry.js} +1 -1
- package/dist/twilight/{p-c1d4db6f.entry.js → p-9dcc291b.entry.js} +1 -1
- package/dist/twilight/{p-Dw7mGaHj.js → p-B6bkY5-l.js} +1 -1
- package/dist/twilight/{p-BuNOvMeU.js → p-BCWPIsso.js} +1 -1
- package/dist/twilight/p-BLehGhpL.js +4 -0
- package/dist/twilight/{p-CTyl0UJE.js → p-BN2EOPT0.js} +1 -1
- package/dist/twilight/{p-DlGhggDp.js → p-BeZ-z3uX.js} +1 -1
- package/dist/twilight/{p-GgHo6Cr_.js → p-Bu7ZSFM5.js} +1 -1
- package/dist/twilight/{p-CEuTw3-D.js → p-C0UBM1r0.js} +1 -1
- package/dist/twilight/{p-Cw0Ky-u0.js → p-C1ReTfKT.js} +1 -1
- package/dist/twilight/p-C8xwacGT.js +4 -0
- package/dist/twilight/{p-DPgASjJ8.js → p-CX1cQxmm.js} +1 -1
- package/dist/twilight/{p-BwsreBbG.js → p-CfaNNoM2.js} +1 -1
- package/dist/twilight/p-CoQJOPRz.js +4 -0
- package/dist/twilight/{p-LWKLIOwS.js → p-P9Uquv6J.js} +1 -1
- package/dist/twilight/p-a132e9dc.entry.js +4 -0
- package/dist/twilight/{p-a3a0bafa.entry.js → p-a22ab12e.entry.js} +1 -1
- package/dist/twilight/{p-4807586a.entry.js → p-a5093858.entry.js} +1 -1
- package/dist/twilight/{p-4edf67be.entry.js → p-a5483eab.entry.js} +1 -1
- package/dist/twilight/{p-57e0b11b.entry.js → p-ab922196.entry.js} +1 -1
- package/dist/twilight/{p-2f833767.entry.js → p-adf1ff1f.entry.js} +1 -1
- package/dist/twilight/{p-4c57de7b.entry.js → p-b075bdd3.entry.js} +1 -1
- package/dist/twilight/{p-b9062150.entry.js → p-b6446ed0.entry.js} +1 -1
- package/dist/twilight/{p-25104b13.entry.js → p-bd29fa58.entry.js} +1 -1
- package/dist/twilight/{p-b4fd50ef.entry.js → p-c0a96a41.entry.js} +1 -1
- package/dist/twilight/{p-b9c9c487.entry.js → p-c0da03a4.entry.js} +1 -1
- package/dist/twilight/{p-1c1ac203.entry.js → p-ce4823e8.entry.js} +1 -1
- package/dist/twilight/{p-af84c7b8.entry.js → p-cef8dfa8.entry.js} +1 -1
- package/dist/twilight/p-d737a90e.entry.js +4 -0
- package/dist/twilight/p-d7e404d1.entry.js +4 -0
- package/dist/twilight/{p-a00015ec.entry.js → p-d95fad47.entry.js} +1 -1
- package/dist/twilight/{p-201926a3.entry.js → p-dacc7681.entry.js} +1 -1
- package/dist/twilight/{p-580441f5.entry.js → p-e15ceaae.entry.js} +1 -1
- package/dist/twilight/p-e692fd88.entry.js +4 -0
- package/dist/twilight/{p-59657a19.entry.js → p-ee5afe29.entry.js} +1 -1
- package/dist/twilight/{p-681953ef.entry.js → p-f248ce38.entry.js} +1 -1
- package/dist/twilight/{p-c968dab0.entry.js → p-f6468e0f.entry.js} +1 -1
- package/dist/twilight/{p-cd6fc43c.entry.js → p-f9e89a30.entry.js} +1 -1
- package/dist/twilight/{p-e5325563.entry.js → p-fdd2d95e.entry.js} +1 -1
- package/dist/twilight/{p-0654ccca.entry.js → p-ff0d8f2b.entry.js} +1 -1
- package/dist/twilight/{p-CbukOCNI.js → p-nj3fF7xi.js} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components/salla-order-edit/helpers.d.ts +25 -0
- package/dist/types/components/salla-order-edit/interfaces.d.ts +22 -25
- package/dist/types/components/salla-order-edit/salla-order-edit-item.d.ts +7 -5
- package/dist/types/components/salla-order-edit/salla-order-edit-product-card.d.ts +11 -0
- package/dist/types/components/salla-order-edit/salla-order-edit.d.ts +56 -4
- package/dist/types/components/salla-product-options/salla-product-options.d.ts +4 -0
- package/dist/types/components/salla-products-list/salla-products-list.d.ts +5 -0
- package/dist/types/components.d.ts +51 -4
- package/package.json +5 -5
- package/dist/twilight/p-36048354.entry.js +0 -4
- package/dist/twilight/p-60d875cc.entry.js +0 -4
- package/dist/twilight/p-7a33e83b.entry.js +0 -4
- package/dist/twilight/p-86cfa253.entry.js +0 -4
- package/dist/twilight/p-c0b690b2.entry.js +0 -4
- package/dist/twilight/p-e07f938a.entry.js +0 -4
- package/dist/twilight/p-f-qXMnue.js +0 -4
- package/dist/twilight/p-f2815da9.entry.js +0 -4
- package/dist/twilight/p-f7b21078.entry.js +0 -4
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Crafted with ❤ by Salla
|
|
3
|
-
*/
|
|
4
|
-
import{r as t,c as a,h as e,H as s,a as i,e as l}from"./p-BwsreBbG.js";import{P as o}from"./p-DY4LZmNP.js";import{H as n}from"./p-CHf8XdiS.js";import{B as r}from"./p-D3mWkc-3.js";import{S as p}from"./p-BZp0rKEO.js";import{C as c}from"./p-C6jIkM-X.js";import"./p-CgtvEd63.js";const d=class{constructor(e){t(this,e),this.success=a(this,"success"),this.failed=a(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.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?o: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 a=document.querySelector(`salla-product-options[product-id="${this.productId}"]`);return a&&"function"==typeof a.validateAndScroll?a.validateAndScroll().then((async t=>{const a={isValid:t,component:this};if(await salla.hooks.call("salla-add-product-button","validate",a),a.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"),a=Object.entries({id:this.productId,donation_amount:this.donatingAmount,quantity:this.quantity,endpoint:"quickAdd",source:n.getProductsSource(t?.getAttribute("source"))}).reduce(((t,[a,e])=>e?(t[a]=e,t):t),{});return salla.cart.addItem(a).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}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 e("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"},e("div",{slot:"widget-label",class:"s-add-product-button-mini-checkout-content"},e("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?e(s,null,e("salla-product-availability",{...this.getBtnAttributes(),"is-subscribed":!0},e("span",{class:"s-hidden"},e("slot",null)))):"out-and-notify"===this.productStatus&&this.channels||this.hasOutOfStockOption?e(s,null,e("salla-product-availability",{...this.getBtnAttributes()},e("span",{class:"s-hidden"},e("slot",null)))):e(s,{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}},e("div",{class:{"s-add-product-button-main":this.showQuickBuy,"w-full":!document.getElementById("fast-checkout-js")||["financial_support","donating"].includes(this.productType)}},e("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"},e("slot",null)),this.showQuickBuy&&document.getElementById("fast-checkout-js")&&!["financial_support","donating"].includes(this.productType)?this.miniCheckoutWidget():""),this.showQuickBuy&&this.isApplePayActive?e("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 a=salla.storage.get(`product-${this.productId}-subscribed-options`);if((a||this.subscribedOptions)&&this.hasOutOfStockOption)if(salla.config.isGuest()){const t=a?a.map((t=>t.split(",").map((t=>parseInt(t))))):[];this.hasSubscribedOptions=t.length>0&&t.some((t=>t.every((t=>this.selectedOptions.some((a=>a.id===t))))))}else this.hasSubscribedOptions=!(!this.subscribedOptions||"null"===this.subscribedOptions||"[]"===this.subscribedOptions)&&JSON.parse(this.subscribedOptions).some((t=>t.every((t=>this.selectedOptions.some((a=>a.id===t))))))}))}componentDidRender(){!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 i(this)}};d.style=":host{display:block}salla-add-product-button[width=wide]{width:100%}";const h=class{constructor(a){t(this,a),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,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,salla.api.request("https://api.salla.dev/1/indexes/*/recommendations",{requests:[{indexName:"products",model:"xsell-v1",priceThreshold:2,objectID:String(t),maxRecommendations:this.limit}]},"post",{headers:{"X-Algolia-Api-Key":"VOL5WaZu2YROp0RplCZAr1RplhL9FFGQ","X-Query-Enrichment":"false","X-source":"store"}});this.canRender=!1})).then((t=>{if(!t)return;const a=t?.results?.[0]?.hits??[];if(!a.length)return void(this.canRender=!1);const e=[String(this.resolvedProductId),...a.map((t=>t.objectID))];return salla.product.fetch({source:"selected",source_value:e})})).then((t=>{if(!t)return;const a=t?.data??[];if(!a.length)return void(this.canRender=!1);const e=a.find((t=>String(t.id)===String(this.resolvedProductId))),s=a.filter((t=>String(t.id)!==String(this.resolvedProductId)));s.length?(this.recommendations=e?[e,...s]:s,this.selectedIds=new Set(this.recommendations.map((t=>t.id)))):this.canRender=!1})).catch((()=>{this.canRender=!1})).finally((()=>{this.isLoading=!1}))}toggleProduct(t){const a=new Set(this.selectedIds);a.has(t)?a.delete(t):a.add(t),this.selectedIds=a}get totalPrice(){const t=this.recommendations.filter((t=>this.selectedIds.has(t.id))).reduce(((t,a)=>t+(a.price??0)),0);return salla.money(t)}async addSelectedToCart(){if(!this.isAdding&&this.selectedIds.size){this.isAdding=!0;try{(await Promise.allSettled(Array.from(this.selectedIds).map((t=>salla.cart.quickAdd(t))))).some((t=>"rejected"===t.status))&&salla.error(salla.lang.get("common.messages.error"))}finally{this.isAdding=!1}}}getSkeletonView(){return e(s,{class:"s-bought-together-entry"},e("div",{class:"s-bought-together-skeleton"},e("div",{class:"s-bought-together-skeleton-header"},e("salla-skeleton",{height:"16px",width:"35%"}),e("salla-skeleton",{height:"10px",width:"60%"})),Array(4).fill(null).map(((t,a)=>e("div",{key:a,class:"s-bought-together-skeleton-item"},e("salla-skeleton",{height:"22px",width:"22px"}),e("salla-skeleton",{height:"48px",width:"48px"}),e("div",{class:"s-bought-together-skeleton-info"},e("salla-skeleton",{height:"12px",width:"55%",style:{marginBottom:"3px"}}),e("salla-skeleton",{height:"10px",width:"25%"}))))),e("salla-skeleton",{height:"44px",width:"100%"})))}render(){return this.canRender?this.isLoading?this.getSkeletonView():this.recommendations.length?e(s,{class:"s-bought-together-entry"},e("div",{class:"s-bought-together-header"},e("h3",{class:"s-bought-together-title"},this.title),e("p",{class:"s-bought-together-subtitle"},this.subtitle)),e("div",{class:"s-bought-together-list"},this.recommendations.map((t=>e("div",{key:t.id,class:"s-bought-together-item"+(this.selectedIds.has(t.id)?"":" s-bought-together-item--unchecked")},e("label",{class:"s-bought-together-checkbox-label"},e("input",{type:"checkbox",class:"s-bought-together-checkbox",checked:this.selectedIds.has(t.id),onChange:()=>this.toggleProduct(t.id)}),e("span",{class:"s-bought-together-checkmark"})),e("a",{class:"s-bought-together-item-link",href:t.url},e("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")}}),e("span",{class:"s-bought-together-item-name"},t.name)),e("span",{class:"s-bought-together-item-price",innerHTML:salla.money(t.price)}))))),e("salla-button",{class:"s-bought-together-btn",disabled:!this.selectedIds.size||this.isAdding,loading:this.isAdding,onClick:()=>this.addSelectedToCart()},e("span",{innerHTML:`${this.buyTogetherFor} ${this.totalPrice}`}))):null:null}};h.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}.s-bought-together-entry{display:block;background-color:#fff;padding:1.25rem;border-radius:0.375rem;margin-top:1.25rem;margin-bottom:1.25rem}.s-bought-together-header{margin-bottom:1rem}.s-bought-together-title{font-size:1.125rem;line-height:1.75rem;font-weight:700;margin-bottom:0.25rem;color:#111827}.s-bought-together-subtitle{font-size:0.875rem;line-height:1.25rem;color:#6b7280;margin:0}.s-bought-together-list{display:flex;flex-direction:column;margin-bottom:1rem}.s-bought-together-list>*+*{border-top:1px solid #f3f4f6}.s-bought-together-item{display:flex;align-items:center;gap:0.75rem;padding-top:0.75rem;padding-bottom:0.75rem;transition:opacity 200ms}.s-bought-together-item--unchecked{opacity:0.4}.s-bought-together-checkbox-label{position:relative;display:flex;align-items:center;cursor:pointer;flex-shrink:0}.s-bought-together-checkbox{position:absolute;opacity:0;width:0;height:0}.s-bought-together-checkmark{width:22px;height:22px;border:2px solid #d1d5db;border-radius:0.375rem;background-color:#fff;display:flex;align-items:center;justify-content:center;transition:all 150ms;flex-shrink:0}.s-bought-together-item-link{display:contents;color:inherit;text-decoration:none}.s-bought-together-item-img{width:3rem;height:3rem;object-fit:cover;border-radius:0.375rem;flex-shrink:0}.s-bought-together-item-name{flex:1;font-size:0.875rem;line-height:1.375}.s-bought-together-item-price{font-size:0.875rem;font-weight:600;white-space:nowrap;flex-shrink:0}.s-bought-together-btn{width:100%}.s-bought-together-skeleton{display:flex;flex-direction:column;gap:0.75rem}.s-bought-together-skeleton-header{display:flex;flex-direction:column;gap:0.5rem;margin-bottom:0.5rem}.s-bought-together-skeleton-item{display:flex;align-items:center;gap:0.75rem;padding-top:0.5rem;padding-bottom:0.5rem}.s-bought-together-skeleton-info{flex:1;display:flex;flex-direction:column;gap:0.25rem}';const u=class{constructor(a){t(this,a),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 a=document.querySelector(`salla-product-options[product-id="${this.productId}"]`),e=Object.values(await(a?.getSelectedOptionsData())||{});if(e.length&&!await(a?.reportValidity())){let t=salla.lang.get("common.messages.required_fields");throw salla.error(t),t}return t.options=[],e.forEach((a=>{a&&!isNaN(a)&&t.options.push(Number(a))})),t},this.typing=t=>{const a=t.target.nextElementSibling;t.target.classList.remove("s-has-error"),a?.classList.contains("s-product-availability-error-msg")&&(a.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"),this.isVisitorSubscribed=this.notifyOptionsAvailability?"":salla.storage.get(`product-${this.productId}-subscribed`))}channelsWatcher(t){this.channels_=t?t.split(","):[]}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")){let{phone:a,countryCode:e}=await this.mobileInput.getValues();t.country_code=e,t.phone=a}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)return salla.storage.set(`product-${this.productId}-subscribed`,!0),void(this.isSubscribed=!0);if(t.options.length){let a=salla.storage.get(`product-${this.productId}-subscribed-options`)||[],e=t.options.join(",");a.includes(e)?salla.log("already subscribed to this options"):(a.push(e),salla.storage.set(`product-${this.productId}-subscribed-options`,a),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=n.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")&&await this.mobileInput.isValid())return}catch(t){throw"Please insert required fields"}}validateField(t,a){t.classList.add("s-has-error"),t.nextElementSibling.innerText="* "+a}render(){return e(s,{key:"65f3dc76d08ee3ba1745b6bbf885fdd9c4f6bae6",class:"s-product-availability-wrap"},this.isSubscribed||this.isVisitorSubscribed?e("div",{class:"s-product-availability-subscribed"},e("span",{innerHTML:r,class:"s-product-availability-subs-icon"}),salla.lang.get("pages.products.notify_availability_success")):e("salla-button",{width:"wide",onClick:()=>this.isUser?this.submit():this.openModel()},salla.lang.get("pages.products.notify_availability")),this.isUser||this.isSubscribed||this.isVisitorSubscribed?"":this.renderModal())}renderModal(){return e("salla-modal",{ref:t=>this.modal=t,"modal-title":this.title_,subTitle:salla.lang.get("pages.products.notify_availability_subtitle"),width:"sm"},e("span",{slot:"icon",class:"s-product-availability-header-icon",innerHTML:r}),e("div",{class:"s-product-availability-body"},this.channels_.includes("email")?[e("label",{class:"s-product-availability-label"},salla.lang.get("common.elements.email")),e("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"}),e("span",{class:"s-product-availability-error-msg"})]:"",this.channels_.includes("sms")?[e("label",{class:"s-product-availability-label"},salla.lang.get("common.elements.mobile")),e("salla-tel-input",{ref:t=>this.mobileInput=t,onKeyDown:t=>this.typing(t)})]:""),e("div",{slot:"footer",class:"s-product-availability-footer"},e("salla-button",{class:"modal-cancel-btn",width:"wide",color:"light",fill:"outline",onClick:()=>this.modal.close()},salla.lang.get("common.elements.cancel")),e("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 i(this)}static get watchers(){return{channels:["channelsWatcher"]}}};var y,m;u.style="",function(t){t.COLOR="color",t.DATE="date",t.DATETIME="datetime",t.DONATION="donation",t.IMAGE="image",t.MULTIPLE_OPTIONS="multiple-options",t.NUMBER="number",t.SINGLE_OPTION="single-option",t.DIGITAL_CARD_VALUE="digital-code-value",t.COUNTRY="country",t.SPLITTER="splitter",t.TEXT="text",t.TEXTAREA="textarea",t.THUMBNAIL="thumbnail",t.TIME="time",t.RADIO="radio",t.CHECKBOX="checkbox",t.MAP="map",t.FILE="file",t.COLOR_PICKER="color_picker",t.BOOKING="booking"}(y||(y={})),function(t){t.Sar="SAR"}(m||(m={}));const g=class{constructor(s){if(t(this,s),this.changed=a(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.outSkus=[],this.ignoreDefaultCardValue=!1,this.productId=salla.config.get("page.id"),this.handleDonationOptions=(t,a,e)=>{if("custom"===a&&"input"===e){const a=t.target;return salla.helpers.inputDigitsOnly(a),salla.event.emit("product-options::donation-changed",{id:this.productId,price:a.value}),void a.dispatchEvent(new window.Event("change",{bubbles:!0}))}const s="option"===e?String(t.target?.value??""):"";if("option"===e&&"custom"===a&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()),this.isCustomDonation="custom"===s,this.donationInput){if("custom"===s?(this.donationInput.value="",this.donationInput.focus()):this.donationInput.value=s,"custom"===a)return;salla.event.emit("product-options::donation-changed",{id:this.productId,price:s})}},this.hideLabel=t=>!(t.type!==y.DONATION||!t.donation||t.donation.can_donate),this.getExpireDonationMessage=t=>{if(!t.donation)return;const a=t.donation.target_amount<=t.donation.collected_amount;return e("div",{class:{"s-product-options-donation-message":!0,"s-product-options-donation-completed":a,"s-product-options-donation-expired":!a}},e("p",null,t.donation.target_message),e("span",{innerHTML:a?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.setOptionsData(t.data.options)))}async setOptionsData(t){this.optionsData=t;const a=this;this.optionsData[0]?.details?.forEach((function(t){Object.entries(t.skus_availability||{}).filter((t=>!t[1])).map((t=>a.outSkus.push(Number(t[0]))))}))}async getSelectedOptionsData(){const t={},a=this.host.getElementSallaData(),e=void 0!==this.bundleContext?this.bundleContext:null;return a.forEach(((a,s)=>{if(e){if(s.startsWith("bundle[")&&s.includes("[options][")){const e=s.split("[options][")[1].replace("]","");t[e]=a}}else s.startsWith("options[")&&(t[s.replace("options[","").replace("]","")]=a)})),t}async reportValidity(){const t=this.host.querySelectorAll("[required]");let a=!0;for(let e=0;e<t.length;e++){const s=t[e];s.disabled||s.closest(".hidden")||"reportValidity"in s&&!s.reportValidity()&&(a=!1)}return a}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((a=>a.id===t))}invalidHandler(t,a){const e=t.target.closest(".s-product-options-option");e.classList.contains("s-product-options-option-error")||e.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")===e&&this.scrollToElement(e)}scrollToElement(t){t&&t.scrollIntoView({behavior:"smooth",block:"center"})}changedHandler(t,a,e=!0){const s={event:t,option:a,detail:null,productId:this.productId};if(a.details){const e=a.details.find((a=>Number(a.id)===Number(t.target.value)));s.detail=e}"country"===a.type&&this.handleCountryOptionChange(t,s.detail);const i=t.target.closest(".s-product-options-option");(t.target.value||(a.type===y.FILE||a.type===y.IMAGE)&&"added"===t.type||a.type===y.MAP&&"selected"===t.type&&t.target.lat&&t.target.lng)&&setTimeout((()=>{i.classList.remove("s-product-options-option-error")}),200),a.type===y.DONATION&&salla.event.emit("product-options::donation-changed",{id:this.productId,price:t.target.value}),this.setSelectedSkus(),this.handleRequiredMultipleOptions(a);const l=this.selectedOptions.findIndex((t=>t.option_id===s.option.id));if(s.option.type===y.MULTIPLE_OPTIONS){const t=this.selectedOptions.findIndex((t=>t.option_id===s.option.id&&t?.id===s.detail?.id));t>-1?this.selectedOptions.splice(t,1):this.selectedOptions.push({...s.detail,option_id:s.option.id})}else s.detail&&0!==Object.keys(s.detail).length?l>-1?this.selectedOptions[l]={...s.detail,option_id:s.option.id}:this.selectedOptions.push({...s.detail,option_id:s.option.id}):l>-1&&this.selectedOptions.splice(l,1);this.optionsData=this.optionsData.map((t=>t.id===s.option.id?{...t,details:t.details.map((t=>({...t,is_selected:s.option.type===y.MULTIPLE_OPTIONS?this.selectedOptions.some((a=>a.id===t.id)):Number(t.id)===Number(s.detail?.id),value:s.detail?.value})))}:t)),this.pruneInvisibleConditionalSelections(),this.setSelectedSkus(),requestAnimationFrame((()=>{this.optionsData?.filter((t=>t.type===y.MULTIPLE_OPTIONS&&t.required)).forEach((t=>this.handleRequiredMultipleOptions(t)))})),e&&(this.changed.emit(s),salla.event.emit("product-options::change",s))}setSelectedSkus(){this.selectedSkus=this.selectedOptions.map((t=>Object.keys(t.skus_availability||{}))).reduce(((t,a)=>t.filter((t=>a.includes(t)))),[]).map((t=>Number(t)))}handleRequiredMultipleOptions(t){if(t.type!==y.MULTIPLE_OPTIONS||!t.required)return;const a=this.host.querySelector(`[data-option-id="${t.id}"]`);if(!a)return;const e=a.querySelectorAll("input:checked").length;a.querySelectorAll("input").forEach((t=>t.toggleAttribute("required",!e)))}pruneInvisibleConditionalSelections(){const t=Math.max(1,this.optionsData.length);for(let a=0;a<t;a++){let t=!1;for(const a of this.optionsData){const e=a.visibility_condition;if(!e)continue;const s=this.selectedOptions.filter((t=>t.option_id===e.option)).map((t=>String(t.id))).includes(String(e.value));("="===e.operator?s:!s)||this.clearStaleOption(a.id)&&(t=!0)}if(!t)break}}clearStaleOption(t){const a=this.optionsData.find((a=>a.id===t));if(!a)return!1;const e=this.selectedOptions.length;this.selectedOptions=this.selectedOptions.filter((a=>a.option_id!==t));const s=this.selectedOptions.length!==e,i=null!=a.value&&String(a.value).length>0,l=a.details?.some((t=>t.is_selected))??!1;return!!(s||i||l)&&(this.optionsData=this.optionsData.map((a=>a.id!==t?a:{...a,value:void 0,details:a.details?.map((t=>({...t,is_selected:!1})))??a.details})),!0)}getLatLng(t,a){return t?t.split(",")["lat"===a?0:1]:""}getDisplayForType(t){return this[`${t.type}Option`]?this[`${t.type}Option`](t):t.type===y.COLOR_PICKER?this.colorPickerOption(t):t.type===y.MULTIPLE_OPTIONS?this.multipleOptions(t):t.type===y.SINGLE_OPTION?this.singleOption(t):t.type===y.RADIO?this.radioOption(t):t.type===y.DIGITAL_CARD_VALUE?this.digitalCardValuesOption(t):t.type===y.COUNTRY?this.countryOption(t):t.type===y.BOOKING&&salla.url.is_page("cart")?e("salla-booking-field",{onInvalidInput:a=>this.invalidHandler(a,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 a=this.optionsData.find((({type:t})=>"digital-code-value"===t));if(!a)throw new Error("product-options:: No digital card options found");const e=Object.keys(t.skus_availability).filter((a=>!1===t.skus_availability[a]));this.availableDigitalCardValues=a.details.filter((t=>!Object.keys(t.skus_availability).filter((t=>e.includes(t))).length))}handleCountryOptionChange(t,a){t.stopImmediatePropagation(),this.ignoreDefaultCardValue=!0;const e=this.host.querySelector("input[data-code-value]:checked");if(e&&(e.checked=!1),!this.optionsData.find((({type:t})=>"digital-code-value"===t)))throw new Error("product-options:: No digital card options found");this.getAvailableDigitalCardSKUs(a)}getSelectedDigitalCardOptions(t){const a=t.details.find((t=>t.is_selected)),e=t.details.find((t=>!!t.is_default))||t.details[0];if(["digital-code-value","country"].includes(t.type))return a||e}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)),a=t&&this.getSelectedDigitalCardOptions(t);a&&this.getAvailableDigitalCardSKUs(a)}return this.outOfStockText=salla.lang.get("pages.products.out_of_stock"),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 a=t.target;if(!(Salla.helpers.isAppleDevice()&&(a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement)&&a.classList.contains("s-form-control")&&this.host.contains(a)))return;t.preventDefault();const e=t.clipboardData?.getData("text")||"",s=a.selectionStart,i=a.selectionEnd,l=a.value.slice(0,s)+e+a.value.slice(i);a.value=l,a.setSelectionRange(s+e.length,s+e.length);try{a.dispatchEvent(new window.Event("change",{bubbles:!0}))}catch(t){Salla.log("Error on change")}}hideDigitalCardsOptions(t){return this.disableCardValue&&t.type===y.DIGITAL_CARD_VALUE&&!salla.url.is_page("cart")}render(){if(0!==this.optionsData?.length)return e(s,{class:"s-product-options-wrapper"},e("salla-conditional-fields",null,this.optionsData.map((t=>e("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():e("div",{class:{"s-product-options-option":!0,"s-product-options-option-booking":t.type===y.BOOKING&&salla.url.is_page("cart")},"data-option-type":t.type,"data-option-required":`${t.required}`},e("label",{htmlFor:this.generateInputId(t.id),class:"s-product-options-option-label "+(this.hideLabel(t)?"s-product-options-option-label-hidden":"")},e("b",null,t.name,t.required&&e("span",null," * ")," "),e("small",null,t.placeholder)),e("div",{class:"s-product-options-option-content "+(this.hideLabel(t)||t.type===y.BOOKING&&salla.url.is_page("cart")?"s-product-options-option-content-full-width":"")},this.getDisplayForType(t))))))))}generateUniqueKey(t){const a=this.bundleContext;let e=this.uniqueKey?`${t}-${this.uniqueKey}`:t;if(a)try{const t="string"==typeof a?JSON.parse(a):a,{sectionId:s,productId:i}=t;e=`${e}-bundle-${s}-${i}`}catch(t){}return e}generateInputId(t){return this.generateUniqueKey(`option-${t}`)}generateInputName(t){const a=this.bundleContext,e=t.toString();if(a)try{const t="string"==typeof a?JSON.parse(a):a,{sectionId:s,productId:i}=t;return`bundle[${s}][${i}][options][${e}]`}catch(t){return`options[${e}]`}return`options[${e}]`}fillSelectedOptions(){this.selectedOptions=this.optionsData.reduce(((t,a)=>{const e=a.details.filter((t=>t.is_selected)).map((t=>({...t,option_id:a.id})));return t.concat(e)}),[])}async componentDidLoad(){if(!this.optionsData?.length)return;await Salla.hooks.registerComponent("salla-product-options",this);const t=this.optionsData.find((t=>t.type===y.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=[y.SINGLE_OPTION,y.MULTIPLE_OPTIONS,y.COLOR,y.THUMBNAIL,y.DONATION,y.DIGITAL_CARD_VALUE,y.COUNTRY];this.optionsData.some((a=>t.includes(a.type)&&a.details?.some((t=>t.is_selected))))&&requestAnimationFrame((()=>{try{const t=this.host.closest("form");if(!t)return;const a=new FormData(t),e=a.get("id")||a.get("product_id");if(e&&String(e)!==String(this.productId))return;salla.product.getPrice(a)}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()}async enableUserInitiatedValidation(){this.userInitiatedValidation=!0}async validateAndScroll(){return await this.enableUserInitiatedValidation(),this.reportValidity()}donationOption(t,a){return e("div",{class:"s-product-options-donation-wrapper"},t.donation?.can_donate?[t.donation?e("div",{key:t.id,class:"s-product-options-donation-progress"},e("salla-progress-bar",{donation:t.donation})):"",t.details.length?[e("h4",{key:t.id},this.selectAmount),e("div",{key:t.id,class:"s-product-options-donation-options"},t.details.map(((a,s)=>e("div",{key:t.id,class:"s-product-options-donation-options-item"},e("input",{id:this.generateUniqueKey(`donation-option-${s}`),type:"radio",name:"donating_option",checked:a.is_selected,value:a.additional_price,onChange:e=>this.handleDonationOptions(e,a,"option",t)}),e("label",{htmlFor:this.generateUniqueKey(`donation-option-${s}`)},e("span",{innerHTML:salla.money(a.name)}))))),t.donation?.custom_amount_enabled?e("div",{class:"s-product-options-donation-options-item"},e("input",{id:this.generateUniqueKey("donation-option-custom"),type:"radio",name:"donating_option",value:"custom",onChange:a=>this.handleDonationOptions(a,"custom","option",t)}),e("label",{htmlFor:this.generateUniqueKey("donation-option-custom")},e("span",null," ",this.selectDonationAmount," "))):"")]:"",e("div",{key:t.id,class:{"s-product-options-donation-input-group":!0,shown:!t.details.length||t.details.length&&this.isCustomDonation}},e("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:a=>this.handleDonationOptions(a,"custom","input",t),onBlur:a=>this.changedHandler(a,t),onInvalid:a=>this.invalidHandler(a,t)}),e("span",{class:"s-product-options-donation-amount-currency"},salla.config.currency(salla.config.get("user.currency_code")).symbol))]:this.getExpireDonationMessage(t))}fileUploader(t,a=null){return e("salla-file-upload",{...a||{},"payload-name":"file",value:t.value,"instant-upload":!0,name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,height:"120px",onAdded:a=>this.changedHandler(a,t),url:salla.cart.api.getUploadImageEndpoint(),"form-data":{cart_item_id:this.productId,product_id:this.productId},onInvalidInput:a=>this.invalidHandler(a,t),class:{"s-product-options-image-input":!0,required:t.required}},e("div",{class:"s-product-options-filepond-placeholder"},e("span",{class:"s-product-options-filepond-placeholder-icon",innerHTML:a.accept?.split(",").every((t=>t.includes("image")))?c:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>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'}),e("p",{class:"s-product-options-filepond-placeholder-text"},salla.lang.get("common.uploader.drag_and_drop")),e("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 a=t.details.map((t=>this.fileTypes[t.name])).filter(Boolean);return a?.length?this.fileUploader(t,{accept:a.join(",")}):"File types not selected."}numberOption(t){return e("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:a=>this.changedHandler(a,t),onInvalid:a=>this.invalidHandler(a,t),onInput:t=>salla.helpers.inputDigitsOnly(t.target)})}splitterOption(){return e("div",{class:"s-product-options-splitter"})}textOption(t){return e("div",{class:"s-product-options-text"},e("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:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t)}))}textareaOption(t){return e("div",{class:"s-product-options-textarea"},e("div",{class:"mt-1"},e("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:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t)})))}mapOption(t){return e("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:a=>this.invalidHandler(a,t),onSelected:a=>this.changedHandler(a,t)})}colorPickerOption(t){return e("salla-color-picker",{onSubmitted:a=>this.changedHandler(a,t),name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,onInvalidInput:a=>this.invalidHandler(a,t),color:t.value})}timeOption(t){return e("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:a=>this.invalidHandler(a,t),onPicked:a=>this.changedHandler(a,t)})}dateOption(t){return e("div",{class:"s-product-options-date-element"},e("salla-datetime-picker",{value:t.value,placeholder:t.name,required:!t.visibility_condition&&t.required,minDate:new Date,name:this.generateInputName(t.id),onInvalidInput:a=>this.invalidHandler(a,t),onPicked:a=>this.changedHandler(a,t)}))}datetimeOption(t){return e("div",{class:"s-product-options-datetime-element"},e("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:a=>this.invalidHandler(a,t),onPicked:a=>this.changedHandler(a,t)}))}getOptionDetailName(t,a=!0,e){let s;return e&&e===y.COLOR&&(s=t.name+(a&&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>`:"")),s||(s=t.name+(a&&this.isOptionDetailOut(t)&&!salla.url.is_page("cart")&&!this.hideOutLabel?` - ${this.outOfStockText}`:"")+(t.additional_price?` (${salla.money(t.additional_price,!1)})`:"")),s.replace("<i class=sicon-sar></i>",salla.config.currency()?.symbol||"ر.س")}isOptionDetailOut(t){if(t.is_out||!t.skus_availability||!this.selectedSkus?.length)return t.is_out;const a=this.selectedOptions.filter((a=>a.id===t.id)).length;if(a&&1===this.selectedOptions.length)return!1;if(a){const a=this.selectedSkus.filter((t=>this.outSkus.includes(t)));return Object.keys(t.skus_availability).some((t=>a.includes(Number(t))))}return this.selectedOptions.some((a=>a.is_out&&a.option_id!==t.option_id))}renderInput(t,a,s,i,l,o){const n=this.generateUniqueKey(`${t}-${s.id}-${a.id}`),r=this.isOptionDetailOut(a);return e("label",{class:{"s-product-options-disabled":r}},e("input",{id:n,type:t,name:l,value:a.id,disabled:r,required:i,checked:a.is_selected,onInvalid:t=>this.invalidHandler(t,s),onChange:t=>this.changedHandler(t,s)}),e("div",{class:{"s-product-options-grid-mode-span":o,"s-product-options-disabled":r}},this.getOptionDetailName(a)))}renderOptionDetails(t,a,e,s=!1){const i=this.generateInputName(a.id),l="radio"===t?i:`${i}[]`;return a?.details.map((i=>this.renderInput(t,i,a,e,l,s)))}renderSelect(t){return e("div",null,e("select",{id:this.generateInputId(t.id),name:this.generateInputName(t.id),required:!t.visibility_condition&&t.required,class:"s-form-control",onInvalid:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t)},e("option",{value:""},t.placeholder),t?.details.map((t=>e("option",{key:t.id,value:t.id,disabled:this.canDisabled&&this.isOptionDetailOut(t),selected:t.is_selected},this.getOptionDetailName(t))))))}renderButtonStyle(t,a,s){return e("div",{class:"s-product-options-grid-mode"},this.renderOptionDetails(t,a,s,!0))}singleOption(t){return"button"===this.optionConfig?.["single-option"]?.type?this.renderButtonStyle("radio",t,!t.visibility_condition&&t.required):this.renderSelect(t)}multipleOptions(t){const a="button"===this.optionConfig?.["multiple-option"]?.type,s=t.required&&!t.details.some((t=>t.is_selected))&&!t.visibility_condition;return a?this.renderButtonStyle("checkbox",t,s):e("div",{class:{"s-product-options-multiple-options-wrapper":!0,required:t.required}},this.renderOptionDetails("checkbox",t,s))}radioOption(t){return this.singleOption(t)}colorOption(t){return e("fieldset",{class:"s-product-options-colors-wrapper"},t?.details.map((a=>e("div",{class:"s-product-options-colors-item",key:a.id},e("input",{type:"radio",value:a.id,required:!t.visibility_condition&&t.required,checked:a.is_selected,name:this.generateInputName(t.id),disabled:this.canDisabled&&this.isOptionDetailOut(a),id:this.generateUniqueKey(`color-${this.productId}-${t.id}-${a.id}`),onInvalid:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t),"data-img-id":a.option_value}),e("label",{htmlFor:this.generateUniqueKey(`color-${this.productId}-${t.id}-${a.id}`),"data-img-id":a.option_value},e("span",{style:{backgroundColor:a.color}}),e("div",{innerHTML:this.getOptionDetailName(a,!0,t.type)}))))))}thumbnailOption(t){return e("div",{class:"s-product-options-thumbnails-wrapper"},t.details.map((a=>e("div",{key:a.id},e("input",{type:"radio",value:a.id,"data-itemid":a.id,required:!t.visibility_condition&&t.required,checked:a.is_selected,name:this.generateInputName(t.id),"data-img-id":a.option_value,disabled:this.canDisabled&&this.isOptionDetailOut(a),id:this.generateUniqueKey(`option_${this.productId}-${t.id}_${a.id}`),onInvalid:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t)}),e("label",{htmlFor:this.generateUniqueKey(`option_${this.productId}-${t.id}_${a.id}`),"data-img-id":a.option_value,class:"go-to-slide"},e("img",{"data-src":a.image,src:a.image,title:a.name,alt:a.name}),e("span",{innerHTML:p,class:"s-product-options-thumbnails-icon"}),this.isOptionDetailOut(a)?[e("small",{key:a.id,class:"s-product-options-thumbnails-stock-badge"},this.outOfStockText),this.canDisabled?e("div",{key:a.id,class:"s-product-options-thumbnails-badge-overlay"}):""]:""),e("p",null,this.getOptionDetailName(a,!1)," ")))))}digitalCardValuesOption(t){return e("div",{class:"s-product-options-digital-card-wrapper"},this.availableDigitalCardValues.length>0?this.availableDigitalCardValues.map((a=>{const s=String(a.id);return e("label",{htmlFor:this.generateUniqueKey(s.toString()),key:s,class:"s-product-options-digital-card-option"},e("input",{type:"radio","data-code-value":!0,class:"s-form-control s-product-options-digital-card-input",value:a.id,name:this.generateInputName(t.id),id:this.generateUniqueKey(s.toString()),required:!t.visibility_condition&&t.required,onInvalid:a=>this.invalidHandler(a,t),...this.ignoreDefaultCardValue?{}:{defaultChecked:this.getSelectedDigitalCardOptions(t)?.id===a.id}}),e("span",null,a.name," ",salla.config?.currency()?.symbol))})):e("div",{class:"s-product-options-digital-card-out-of-stock"}))}countryOption(t){return e("div",{class:"s-product-options-digital-card-wrapper"},t.details.map((a=>e("label",{htmlFor:this.generateUniqueKey(a.id.toString()),key:a.id,class:{"s-product-options-digital-card-option":!0,"s-product-options-digital-card-option-stock-out":a.is_out}},e("input",{id:this.generateUniqueKey(a.id.toString()),type:"radio",class:"s-form-control s-product-options-digital-card-input",value:a.id,name:this.generateInputName(t.id),disabled:a.is_out,required:!t.visibility_condition&&t.required,onInvalid:a=>this.invalidHandler(a,t),onChange:a=>this.changedHandler(a,t),onClick:()=>{this.disableCardValue=!1},...salla.url.is_page("cart")?{defaultChecked:this.getSelectedDigitalCardOptions(t)?.id===a.id}:{}}),e("img",{loading:"lazy",alt:a.code,height:24,width:24,class:"s-product-options-country-flag",src:`https://cdn.assets.salla.network/prod/admin/cp/assets/flags/1x1/${String(a.code).toLocaleLowerCase()}.svg`,onError:t=>{t.currentTarget.onerror=null,t.currentTarget.src=salla.url.cdn("images/globe.svg")}}),e("span",null,a.name)))))}get host(){return i(this)}};g.style="";var b={request:(t,a,e,s=null,i=null)=>l.request({url:a,data:e,method:t.toLowerCase(),responseType:"json"}).then(s).catch(i),get:(t,a=null,e=null,s)=>l.get(t,{params:s}).then(a).catch(e),post(t,a,e=null,s=null){return this.request("post",t,a,e,s)},put(t,a,e=null,s=null){return this.request("put",t,a,e,s)},delete(t,a,e=null,s=null){return this.request("delete",t,a,e,s)},requestWithSupportAjax(t,a,e="post"){return new Promise(((s,i)=>{if(!window?.isLegacyTheme)return this.request(e,t,a,(({data:t})=>s(t)),(({response:t})=>i(t)));$.ajax({url:t,method:e.toUpperCase(),data:a,async:!1,success:function({data:t}){return s(t)},error:function({response:t}){return i(t)}})}))}},f={options:[],header:[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,a){var e,s,i,l=0,o=0;for(l=0;l<a.length;l+=1)if(new RegExp(a[l].value,"i").test(t)){if(e=new RegExp(a[l].version+"[- /:;]([\\d._]+)","i"),i="",(s=t.match(e))&&s[1]&&(s=s[1]),s)for(s=s.split(/[._]+/),o=0;o<s.length;o+=1)i+=0===o?s[o]+".":s[o];else i="0";return{name:a[l].name,version:parseFloat(i)}}return{name:"unknown",version:0}}};async function w(t,a,e=!1){if(salla.logger.log("🍏 Pay: mutateShippingContact called",a,e),t.detail.requiredShippingContactFields&&0!=t.detail.requiredShippingContactFields.length)if(e){if(salla.config.isGuest()&&salla.config.get("store.features").includes("guest-checkout")){if(!(a.emailAddress&&a.givenName&&a.familyName&&a.phoneNumber)){salla.logger.warn("🍏 Pay: Guest contact fields are required",a);const e=[];return a.emailAddress||e.push(new window.ApplePayError("shippingContactInvalid","emailAddress","Email address is required")),a.phoneNumber||e.push(new window.ApplePayError("shippingContactInvalid","phoneNumber","Phone number is required")),a.givenName&&a.familyName||e.push(new window.ApplePayError("shippingContactInvalid","name","Name is required")),void t.session.completePayment({status:t.session.STATUS_INVALID_SHIPPING_CONTACT,errors:e})}await async function(t,a){return salla.logger.log("🍏 Pay: Updating guest contact",a),new Promise(((e,s)=>{b.post(t.detail.guestContactSelected.url.replace("{id}",t.id),{email:a.emailAddress||null,first_name:a.givenName||null,last_name:a.familyName||null,phone_number:a.phoneNumber||null,country_code:a.countryCode||null},(async({data:a})=>{"function"==typeof t.detail.guestContactSelected?.onSuccess&&t.detail.guestContactSelected.onSuccess(a),e(a)}),(({response:a})=>{salla.logger.warn("🍏 Pay: Failed to update guest contact via api",a),"function"==typeof t.detail.guestContactSelected?.onFailed&&t.detail.guestContactSelected.onFailed(a),s({response:a})}))}))}(t,a)}}else if(t.detail.requiredShippingContactFields.includes("postalAddress"))return b.post(t.detail.shippingContactSelected.url.replace("{id}",t.id),{country:a.country,city:a.locality,local:a.subLocality||a.administrativeArea||a.locality,description:a.subAdministrativeArea,street:a.addressLines?.join(", ")||a.administrativeArea,country_code:a.countryCode,postal_code:a.postalCode},(async({data:a})=>{if("function"==typeof t.detail.shippingContactSelected.onSuccess&&t.detail.shippingContactSelected.onSuccess(a),t.address_id=a.data.address_id,t.shipping_methods=a.data.shipping_methods,!t.shipping_methods||t.shipping_methods&&!t.shipping_methods.length)return salla.logger.warn("🍏 Pay: We dont found any supported methods",a),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(a){return salla.logger.warn("Failed set the shipping details to api",a),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}try{await t.recalculateTotal()}catch(a){return salla.logger.warn("🍏 Pay: Failed recalculate total",a),void t.session.completeShippingContactSelection({status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}const e={newTotal:t.prepareTotal(),newLineItems:t.prepareLineItems(),newShippingMethods:t.mappingShippingMethods(t.shipping_methods)};salla.logger.log("🍏 Pay: completeShippingContactSelection",e),t.session.completeShippingContactSelection(e)}),(({response:a})=>{salla.logger.warn("🍏 Pay: Failed add address via api",a),"function"==typeof t.detail.shippingContactSelected.onFailed&&t.detail.shippingContactSelected.onFailed(a);let e=a?.data?.error?.fields,s=function(t){return Object.entries(t).filter((([t,a])=>a&&a.length>0)).map((([t,a])=>new window.ApplePayError("shippingContactInvalid",t,a[0])))}({countryCode:e?.country_code&&e.country_code.length>0?e.country_code[0]:null,locality:e?.city&&e.city.length>0?e.city[0]:null,country:e?.country&&e.country.length>0?e.country[0]:null});0===s.length&&a?.data?.error?.message&&s.push(new window.ApplePayError("shippingContactInvalid","locality",a?.data?.error?.message)),t.session.completeShippingContactSelection({newTotal:t.prepareTotal(),newLineItems:t.prepareLineItems(),status:t.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:s})}))}window.Salla=window.Salla||{},window.Salla.Payments=window.Salla.Payments||{},window.SallaApplePay={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",SallaApplePay.startSession),Salla.event.addEventListener("payments::apple-pay.start-transaction",SallaApplePay.startSession)},initDefault:function(){SallaApplePay.detail.onError||(SallaApplePay.detail.onError=function(t){salla.notify.error(t)}),SallaApplePay.detail.authorized.onFailed||(SallaApplePay.detail.authorized.onFailed=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleErrorResponse(t),SallaApplePay.onCancel({},t.data.error.message)}),SallaApplePay.detail.validateMerchant.onFailed||(SallaApplePay.detail.validateMerchant.onFailed=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleErrorResponse({response:t}),SallaApplePay.onCancel({},t.data.error.message)}),SallaApplePay.detail.authorized.onSuccess||(SallaApplePay.detail.authorized.onSuccess=t=>{salla.logger.log(JSON.stringify(t)),salla.api.handleAfterResponseActions(t)})},prepareLineItems:function(){return SallaApplePay.detail?.items?.length||(SallaApplePay.detail.items=[{label:salla.lang.get("pages.cart.items_total"),amount:parseFloat(SallaApplePay.detail.amount).toString()}]),SallaApplePay.detail.items},prepareTotal:function(){return{label:window.location.hostname||"Salla",amount:parseFloat(SallaApplePay.detail.amount).toString()}},isPhysical:()=>SallaApplePay.detail?.requiredShippingContactFields?.includes("postalAddress"),startSession:async function(t){SallaApplePay.detail=t.detail||t,salla.log("🍏 Pay: payments::apple-pay.start-transaction",SallaApplePay.detail),SallaApplePay.initDefault();let a=SallaApplePay.getApplePaySessionVersion(),e=SallaApplePay.detail.supportedNetworks||["masterCard","visa"];5===a&&e.push("mada"),SallaApplePay.request={countryCode:SallaApplePay.detail.countryCode||"SA",supportsCouponCode:!0,couponCode:"",currencyCode:SallaApplePay.detail.currency||"SAR",requiredShippingContactFields:SallaApplePay.detail.requiredShippingContactFields?SallaApplePay.detail.requiredShippingContactFields:[],merchantCapabilities:["supports3DS"],supportedNetworks:e,supportedCountries:SallaApplePay.detail.supportedCountries||["SA"],total:SallaApplePay.prepareTotal(),shippingContact:SallaApplePay.detail.shippingContact?SallaApplePay.detail.shippingContact:{},shippingMethods:SallaApplePay.detail.shippingMethods&&SallaApplePay.detail.shippingMethods.length?SallaApplePay.mappingShippingMethods(t.detail.shippingMethods):[],lineItems:SallaApplePay.prepareLineItems()},salla.log("🍏 Pay: init ",SallaApplePay.request),SallaApplePay.session=new ApplePaySession(a,SallaApplePay.request),SallaApplePay.session.onshippingcontactselected=SallaApplePay.onShippingContactSelected,SallaApplePay.session.onshippingmethodselected=SallaApplePay.onShippingMethodSelected,SallaApplePay.session.onvalidatemerchant=SallaApplePay.onValidateMerchant,SallaApplePay.session.onpaymentauthorized=SallaApplePay.onPaymentAuthorized,SallaApplePay.session.oncancel=SallaApplePay.onCancel,SallaApplePay.session.oncouponcodechanged=SallaApplePay.onCouponCodeChanged,SallaApplePay.session.onpaymentmethodselected=SallaApplePay.onPaymentMethodSelected,SallaApplePay.session.begin()},onPaymentMethodSelected:async t=>{if(salla.logger.log("🍏 Pay: onPaymentMethodSelected",t),SallaApplePay.isPhysical())salla.logger.log("🍏 Pay: completePaymentMethodSelection",{newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()}),SallaApplePay.session.completePaymentMethodSelection({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()});else try{await SallaApplePay.recalculateTotal();const t={newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()};salla.logger.log("🍏 Pay: completePaymentMethodSelection",t),SallaApplePay.session.completePaymentMethodSelection(t)}catch(t){salla.logger.warn("🍏 Pay: Failed recalculate total",t),SallaApplePay.session.completePaymentMethodSelection({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems(),status:SallaApplePay.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),b.post(SallaApplePay.detail.onCouponCodeChanged.url.replace("{id}",SallaApplePay.id),{coupon:t.couponCode,payment_method:"apple_pay"},(async({data:t})=>{"function"==typeof SallaApplePay.detail.onCouponCodeChanged.onSuccess&&SallaApplePay.detail.onCouponCodeChanged.onSuccess(t),salla.log("🍏 Pay: Coupon applied success"),await SallaApplePay.recalculateTotal(),SallaApplePay.session.completeCouponCodeChange({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()})}),(async t=>{let a=t?.response;Salla.event.dispatch("payments::apple-pay.coupon.failed",a),"function"==typeof SallaApplePay.detail.onCouponCodeChanged.onFailed&&SallaApplePay.detail.onCouponCodeChanged.onFailed(a),await SallaApplePay.recalculateTotal(),SallaApplePay.session.completeCouponCodeChange({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems(),errors:[new window.ApplePayError("couponCodeInvalid")]})}))),onCancel:(t={},a=null)=>{SallaApplePay.detail.onError(a||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 w(SallaApplePay,t.payment.shippingContact,!0)}catch(t){salla.logger.error("🍏 Pay: Failed to update guest contact details",t);const a=t?.response||t,e=a?.data?.error?.fields||{},s=[];return e?.email&&e.email.length>0&&s.push(new window.ApplePayError("shippingContactInvalid","emailAddress",e.email[0])),e?.phone&&e.phone.length>0&&s.push(new window.ApplePayError("shippingContactInvalid","phoneNumber",e.phone[0])),e?.first_name&&e.first_name.length>0?s.push(new window.ApplePayError("shippingContactInvalid","name",e.first_name[0])):e?.last_name&&e.last_name.length>0&&s.push(new window.ApplePayError("shippingContactInvalid","name",e.last_name[0])),0===s.length&&s.push(new window.ApplePayError("shippingContactInvalid","name",a?.data?.error?.message||a?.data?.error?.code||"Invalid shipping contact details")),Salla.event.dispatch("payments::apple-pay.authorized.failed",a),"function"==typeof SallaApplePay.detail.authorized.onFailed&&SallaApplePay.detail.authorized.onFailed(a),void SallaApplePay.session.completePayment({status:ApplePaySession.STATUS_INVALID_SHIPPING_CONTACT,errors:s})}Salla.event.dispatch("payments::apple-pay.authorized.init",t),b.post(SallaApplePay.detail.authorized.url.replace("{id}",SallaApplePay.id),{payment_method:"apple_pay",applepay_token:JSON.stringify(t.payment)},(({data:t})=>{Salla.event.dispatch("payments::apple-pay.authorized.success",t),"function"==typeof SallaApplePay.detail.authorized.onSuccess&&SallaApplePay.detail.authorized.onSuccess(t),SallaApplePay.session.completePayment(ApplePaySession.STATUS_SUCCESS)}),(t=>{let a=t?.response;Salla.event.dispatch("payments::apple-pay.authorized.failed",a),"function"==typeof SallaApplePay.detail.authorized.onFailed&&SallaApplePay.detail.authorized.onFailed(a),SallaApplePay.session.completePayment({status:ApplePaySession.STATUS_FAILURE,errors:[new window.ApplePayError("unknown",void 0,a?.data?.error?.message||a?.data?.error?.code||"Failed to parse authorized response")]})}))},onValidateMerchant:async t=>{try{Salla.event.dispatch("payments::apple-pay.validate-merchant.init",t);const{data:a}=await b.post(SallaApplePay.detail.validateMerchant.url.replace("{id}",SallaApplePay.id),{validation_url:t.validationURL});Salla.event.dispatch("payments::apple-pay.validate-merchant.success",a);const e=t=>{SallaApplePay.session.completeMerchantValidation(t)};if("function"==typeof SallaApplePay.detail.validateMerchant.onSuccess){const t=await SallaApplePay.detail.validateMerchant.onSuccess(a);if(t?.redirect)return window.location=t.redirect,SallaApplePay.abortValidateMerchant(t)}e(a.data)}catch(t){console.error(t),SallaApplePay.abortValidateMerchant(t?.response)}},abortValidateMerchant:(t=null)=>{SallaApplePay.abortSession(),Salla.event.dispatch("payments::apple-pay.validate-merchant.failed",t),"function"==typeof SallaApplePay.detail.validateMerchant.onFailed&&SallaApplePay.detail.validateMerchant.onFailed(t)},onShippingContactSelected:async t=>{salla.logger.log("🍏 Pay: onShippingContactSelected",t.shippingContact),await w(SallaApplePay,t.shippingContact)},onShippingMethodSelected:async t=>{let a=t.shippingMethod.identifier.split(","),e={ship_id:a[0],private_ship_id:void 0===a[1]?null:a[1],type:void 0===a[2]?null:a[2],route_id:void 0===a[3]?null:a[3]};if(salla.logger.log("🍏 Pay: onShippingMethodSelected",{event:t,previous:SallaApplePay.shippingCompany,current:e}),SallaApplePay.shouldUpdateShippingCompany(e))try{await SallaApplePay.selectApplePayShippingMethod(e),await SallaApplePay.recalculateTotal()}catch(t){return salla.logger.warn("🍏 Pay: Failed set the shipping details to api",t),void SallaApplePay.session.completeShippingMethodSelection({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems(),status:SallaApplePay.session.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,errors:[new window.ApplePayError("addressUnserviceable")]})}salla.logger.log("🍏 Pay: completeShippingMethodSelection",{newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()}),SallaApplePay.session.completeShippingMethodSelection({newTotal:SallaApplePay.prepareTotal(),newLineItems:SallaApplePay.prepareLineItems()})},abortSession:()=>{SallaApplePay.session&&SallaApplePay.session.abort()},shouldUpdateShippingCompany:t=>SallaApplePay.shippingCompany?.ship_id!=t?.ship_id||SallaApplePay.shippingCompany?.private_ship_id!=t?.private_ship_id,getApplePaySessionVersion:()=>{if("sallapp"===(navigator.userAgent||navigator.vendor||window.opera))return 5;let t=f.init(),a=parseFloat(t.os.version);if("Macintosh"===t.os.name){if(a<10.142)return 1}else if(a<12.11)return 1;return 5},recalculateTotal:()=>(salla.logger.log("🍏 Pay: recalculate total"),b.get(SallaApplePay.detail.recalculateTotal.url.replace("{id}",SallaApplePay.id),(({data:t})=>{salla.logger.log("🍏 Pay: recalculate total success",t);let a=t.data.initial_data?.cart||t.data.cart,e=t.data.initial_data?.payments||t.data.payments;salla.logger.log("🍏 Pay: recalculate total success",{cart:a,payments:e}),SallaApplePay.detail.amount=e?.gateways?.applePay?.supportedMultiCurrency?a.total_in_customer_currency:a.total,SallaApplePay.detail.items=(a.totals||a.items).map((t=>({label:t.title,amount:"مجاني"===t.amount||"Free"===t.amount?0:t.amount.toString().replace("+","")}))),SallaApplePay.detail.items.pop(),SallaApplePay.totals=SallaApplePay.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),SallaApplePay.shippingCompany=t;const a={address_id:SallaApplePay.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 b.post(SallaApplePay.detail.shippingMethodSelected.url.replace("{id}",SallaApplePay.id),a,(({data:t})=>("function"==typeof SallaApplePay.detail.shippingMethodSelected.onSuccess&&SallaApplePay.detail.shippingMethodSelected.onSuccess(t),!0)),(t=>{salla.logger.warn("🍏 Pay: Set shipping method failed",t),"function"==typeof SallaApplePay.detail.shippingMethodSelected.onFailed&&SallaApplePay.detail.shippingMethodSelected.onFailed(t);let a=t?.response?.data?.error;return a?.data?.fields?.address_id?a?.data?.fields?.address_id[0]:a?.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:"")})))},window.ApplePaySession?.canMakePayments()?SallaApplePay.init():document.querySelectorAll("data-show-if-apple-pay-supported").forEach((t=>t.style.display="none"));const v=class{constructor(e){t(this,e),this.validationFailed=a(this,"validationFailed"),this.requireLogin=a(this,"requireLogin"),this.type="buy",this.productType="product",this.options={},this.quickBuy=salla.lang.get("pages.products.buy_now"),salla.lang.onLoaded((()=>{this.quickBuy=salla.lang.get("pages.products.buy_now")}))}async quickBuyHandler(){if(salla.config.isGuest()&&!this.isGuestCheckout()){this.requireLogin.emit({productId:this.productId});let t="salla-quick-buy::user.logged-in";return salla.event.on(t,(()=>this.settlePayment())),salla.api.auth.setAfterLoginEvent(t),salla.auth.event.dispatch("login::open",{withoutReload:!0})}await this.settlePayment()}async settlePayment(){let t=document.querySelector(`salla-product-options[product-id="${this.productId}"]`);if(t&&!await t.reportValidity())return this.validationFailed.emit({productId:this.productId}),salla.error(salla.lang.get("common.messages.required_fields"));let a=this.host.getElementSallaData();if(!this.isApplePayActive)return salla.api.request("checkout/quick-purchase/"+this.productId,a,"post").then((t=>(t.data.redirect&&(window.location.href=t.data.redirect),t)));a.is_applepay=!0,"append"in a&&a.append("is_applepay",!0),salla.event.dispatch("payments::apple-pay.start-transaction",{amount:this.amount,currency:this.currency||"SAR",requiredShippingContactFields:this.getRequiredShippingContactFields(),shippingMethods:this.isRequireShipping?[]:void 0,supportedNetworks:salla.config.get("store.settings.buy_now.networks"),supportedCountries:salla.config.get("store.settings.buy_now.countries"),countryCode:salla.config.get("store.store_country")||"SA",validateMerchant:{url:this.validateHost?`${this.validateHost}/checkout/applepay/validate`:salla.url.get("checkout/applepay/validate"),onSuccess:t=>this.applePayOnly&&!this.productId?this.cartId?(window.SallaApplePay.id=this.cartId,salla.log("🍏 Pay: create checkout success: with id #"+this.cartId),Promise.resolve(t)):(salla.logger.warn("🍏 Pay: trying to create applePay transaction without cartId/ProductId !"),Promise.resolve(t)):salla.api.request("checkout/quick-purchase/"+this.productId,"object"==typeof a?a: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}componentWillLoad(){console.log("🍏 Pay: Quick Buy Component Loaded");const t="undefined"!=typeof window&&!!window.ApplePaySession?.canMakePayments?.(),a=salla?.config?.get?.("store.settings.payments")?.includes?.("apple_pay")??!0,e=salla?.config?.get?.("store.settings.is_salla_gateway",!1)??!0;this.isApplePayActive=t&&a&&e;const s=async()=>{if(!this.currency&&salla?.config?.get&&(this.currency=salla.config.get("store.settings.buy_now.multi_currency")?salla.config.get("user.currency_code"):"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.amount=t.data.price,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.amount=t.price)})):salla?.url?.is_page?.("product.single")&&salla?.product?.event?.onPriceUpdated&&salla.product.event.onPriceUpdated((t=>{this.amount=t.data.price})),this.isApplePayActive=(salla?.helpers?.hasApplePay?.()??t)&&(salla?.config?.get?.("store.settings.payments")?.includes?.("apple_pay")??a)&&(salla?.config?.get?.("store.settings.is_salla_gateway",!1)??e),!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((()=>s().then((()=>t(!0))))):s().then((()=>t(!0)))}))}render(){return e(s,{key:"7c5e3ce5d5a6fdd01565cf0f96c56aad11b8f4ba"},this.quickBuyButton())}quickBuyButton(){return e("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 i(this)}};v.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{d as salla_add_product_button,h as salla_bought_together,u as salla_product_availability,g as salla_product_options,v as salla_quick_buy}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Crafted with ❤ by Salla
|
|
3
|
-
*/
|
|
4
|
-
import{r as s,h as e,H as t}from"./p-BwsreBbG.js";const c=class{constructor(e){s(this,e),this.type="normal",this.width="100%",this.height="100%"}render(){return e(t,{key:"8f574f21608fb5177c8a5d7e0d84d1c1065e49a4",class:"s-skeleton-wrapper",style:{width:this.width,height:this.height}},e("div",{key:"6c86b14ec10c5ccea8f336ab87fb433c49104149",class:{"s-skeleton-item":!0,"s-skeleton-item-circular":"circle"==this.type}}," "))}};c.style=":host{display:block}";export{c as salla_skeleton}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Crafted with ❤ by Salla
|
|
3
|
-
*/
|
|
4
|
-
import{r as e,c as t,h as s,H as i}from"./p-BwsreBbG.js";import{a}from"./p-BedNk7k1.js";const l=class{constructor(s){e(this,s),this.changed=t(this,"changed"),this.min=0,this.max=1e4,this.moreThanLabel="أكثر من",this.lessThanLabel="أقل من",this.toLabel="الى",this.fromLabel="من",this.typing=!1,this.isMin=!1,this.isRTL=salla.config.get("theme.is_rtl",!0),this.filterValues=[]}connectedCallback(){if(this.filtersData&&this.filtersData?.price&&(this.minPrice=this.filtersData.price.min,this.maxPrice=this.filtersData.price.max),salla.lang.onLoaded((()=>{this.moreThanLabel=salla.lang.getWithDefault("common.elements.more_than",this.moreThanLabel),this.lessThanLabel=salla.lang.getWithDefault("common.elements.less_than",this.lessThanLabel),this.toLabel=salla.lang.getWithDefault("common.elements.to",this.toLabel),this.fromLabel=salla.lang.getWithDefault("common.elements.from",this.fromLabel)})),1==this.option.values.length)return;if(this.option.values.length<=5)return void(this.filterValues=this.option.values);const e=Math.ceil(this.option.values.length/5);for(let t=0;t<this.option.values.length;t+=e)this.filterValues.push(this.option.values.slice(t,t+e).reduce(((e,t)=>(e.to=t.to,e.count+=t.count,e))))}async reset(){this.minInput.value=null,this.maxInput.value=null,this.minPrice=null,this.maxPrice=null}getPriceLabel(e){return isNaN(e.from)||e.from<1?`${this.lessThanLabel} ${salla.money(e.to)}`:isNaN(e.to)||e.to<1?`${this.moreThanLabel} ${salla.money(e.from)}`:`${salla.money(e.from)} ${this.toLabel} ${salla.money(e.to)}`}minInputValidation(e){e&&(e>this.max||this.maxPrice&&e>this.maxPrice)||(e<this.min?this.minPrice=this.min:e&&(this.minPrice=e))}maxInputValidation(e){e&&(e<this.min||this.minPrice&&e<this.minPrice)||e>this.max&&(this.maxPrice=this.max)}async changedEventHandler(e){salla.helpers.inputDigitsOnly(this.minInput),salla.helpers.inputDigitsOnly(this.maxInput);const t=this.minPrice?1*+this.minPrice:null,s=this.maxPrice?1*+this.maxPrice:null;this.maxPrice||(this.maxPrice=""),this.isMin?this.minInputValidation(t):(this.minPrice||(this.minPrice=0),this.maxInputValidation(s)),this.isReady&&this.changed.emit({event:e,option:this.option,value:{max:this.maxPrice,min:this.minPrice}})}handleMinMaxPrice(e,t){this.minPrice=t.from,this.maxPrice="*"!==t.to?t.to:"",this.changedEventHandler(e)}isChecked(e){return!(!this.minPrice&&!this.maxPrice)&&(((e.from<1||"*"==e.from)&&0==this.minPrice||e.from==this.minPrice)&&("*"==e.to||!e.to||e.to==this.maxPrice))}handleMinPrice(e){this.isMin=!0;const t=e.target.value;this.minPrice=""===t?0:t}handleMaxPrice(e){this.isMin=!1;const t=e.target.value;this.maxPrice=void 0===t?"":t}render(){return s(i,{key:"996f527f5a36ea273b0d8c195e35dc3efbdf62f2"},this.filterValues.map(((e,t)=>s("label",{class:"s-filters-label",htmlFor:`${this.option.key}-${t}`,key:t},s("input",{id:`${this.option.key}-${t}`,name:"price",type:"radio",checked:this.isChecked(e),class:"s-filters-radio",onChange:t=>this.handleMinMaxPrice(t,e)}),s("span",{innerHTML:this.getPriceLabel(e)})))),s("div",{key:"bfa8f970eb1e9c5d2b9678e5271aa04208b39289",class:"flex justify-center items-center"},s("div",{key:"59cd51f388f36a38e2bd036d27b7abe001fed9d0",class:"relative max-w-xl w-full"},s("div",{key:"226bd18705572502c7da11022a8ce02dc08d4d21",class:"s-price-range-inputs"},s("div",{key:"0ebfdced114308e82075cd153bef0020daa15bf6",class:"s-price-range-relative"},s("div",{key:"c3dacef6133e2b05eca8d643d1c8ce3f5b991548",class:"s-price-range-currency"}," ",salla.config.currency().symbol),s("input",{key:"b2451e091d93f85f268fc80e30e24f5f71c2628c",type:"number",maxlength:"5",ref:e=>this.minInput=e,onBlur:e=>this.handleMinPrice(e),value:this.minPrice,placeholder:this.fromLabel,class:"s-price-range-number-input"})),s("div",{key:"00c07380972b65eac5fac5688b99d21277f65d39",class:"s-price-range-gray-text"}," -"),s("div",{key:"403e98ad682f08946ccd191715ff37401a376722",class:"s-price-range-relative"},s("div",{key:"a1b0729fc40c17b9be68dd2c76a3afa1e99d8a62",class:"s-price-range-currency"}," ",salla.config.currency().symbol),s("input",{key:"5f5e5a202f4b11cde88ae954fa352b71886fe30e",type:"number",maxlength:"5",ref:e=>this.maxInput=e,onBlur:e=>this.handleMaxPrice(e),value:this.maxPrice,placeholder:this.toLabel,class:"s-price-range-number-input","aria-describedby":"price-currency"})),s("salla-button",{key:"dd4899512e03f10c18e74f4d2434406dc6922a50",color:"gray",shape:"icon",size:"small",fill:"outline",onClick:e=>this.changedEventHandler(e)},s("span",{key:"98d023ccfe7e26278259bf690a1d7a4323a704fc",innerHTML:this.isRTL?a:'\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>arrow-right</title>\n<path d="M29.217 15.465c-0.019-0.044-0.056-0.077-0.080-0.119-0.067-0.116-0.139-0.227-0.236-0.317-0.011-0.009-0.013-0.024-0.024-0.033l-10.667-9.333c-0.553-0.484-1.396-0.429-1.881 0.125-0.484 0.555-0.428 1.396 0.127 1.881l7.996 6.997h-20.452c-0.737 0-1.333 0.597-1.333 1.333s0.596 1.333 1.333 1.333h20.452l-7.996 6.997c-0.555 0.485-0.611 1.327-0.127 1.881 0.264 0.3 0.633 0.455 1.004 0.455 0.312 0 0.625-0.109 0.877-0.331l10.667-9.333c0.011-0.009 0.015-0.024 0.024-0.033 0.097-0.091 0.169-0.201 0.236-0.317 0.024-0.041 0.060-0.075 0.080-0.119 0.073-0.163 0.116-0.343 0.116-0.533s-0.043-0.371-0.116-0.535z"></path>\n</svg>\n'}))))))}componentDidLoad(){this.isReady=!0}};l.style=":host{display:block}.rtl .rtl-range-slider,[dir=rtl] .rtl-range-slider{transform:rotateY(180deg)}.rtl .rtl-range-numbers,[dir=rtl] .rtl-range-numbers{flex-direction:row-reverse}.rtl .form-select,.rtl select,[dir=rtl] .form-select,[dir=rtl] select{background-position:left 0.5rem center;padding-right:12px}.rtl .menu-divide li:not(:last-child):after,[dir=rtl] .menu-divide li:not(:last-child):after{left:0;right:auto}input[type=range]::-webkit-slider-thumb{pointer-events:all;width:24px;height:24px;-webkit-appearance:none}[type=checkbox]:checked{background-size:80%}";export{l as salla_price_range}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Crafted with ❤ by Salla
|
|
3
|
-
*/
|
|
4
|
-
import{r as s,h as t,H as e,a}from"./p-BwsreBbG.js";const i=class{constructor(t){s(this,t),this.loading=!0,this.saveLoading=!1,this.payload={items:{update:[],remove:[]}},this.expired=!1,this.editPreview=null,this.confirming=!1}async componentWillLoad(){await salla.onReady(),this.loadFromProp(),this.startExpiryCheck()}disconnectedCallback(){clearInterval(this.expiryInterval)}startExpiryCheck(){const s=this.order?.customer_editing_session?.ends_at;if(!s)return;const t=()=>new Date(`${s.replace(" ","T")}+03:00`).getTime()<=Date.now();t()?this.expired=!0:this.expiryInterval=setInterval((()=>{t()&&(this.expired=!0,clearInterval(this.expiryInterval))}),1e3)}loadFromProp(){try{if(!this.orderData)return void(this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود"));const s="string"==typeof this.orderData?JSON.parse(this.orderData):this.orderData;this.order=s}catch(s){this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود")}finally{this.loading=!1}}handleItemUpdated(s){if(!this.order)return;const{itemId:t,quantity:e,options:a}=s.detail,i=this.payload.items.update.filter((s=>s.id!==t));i.push({id:t,quantity:e,options:a??[]}),this.payload={...this.payload,items:{...this.payload.items,update:i}},this.order={...this.order,items:this.order.items.map((s=>s.id===t?{...s,quantity:e}:s))}}handleItemRemoved(s){if(!this.order)return;if(this.order.items.length<=1)return void salla.notify.error(salla.lang.getWithDefault("pages.orders.order_cannot_be_empty","لا يمكن إزالة جميع المنتجات من الطلب"));const{itemId:t}=s.detail;this.payload={...this.payload,items:{update:this.payload.items.update.filter((s=>s.id!==t)),remove:[...this.payload.items.remove,t]}},this.order={...this.order,items:this.order.items.filter((s=>s.id!==t))}}get hasChanges(){return this.payload.items.update.length>0||this.payload.items.remove.length>0}async saveOrder(){if(this.hasChanges){this.saveLoading=!0;try{const s=await salla.order.api.editOrder(this.orderId,this.payload);this.editPreview=s?.data?.data||s?.data,await(this.saveModal?.open())}catch(s){const t=s?.response?.data?.error?.message||s?.response?.data?.message;t&&salla.notify.error(t)}finally{this.saveLoading=!1}}}navigateToOrder(){const s=new URL(window.location.href);s.pathname=s.pathname.replace(/\/edit\/?$/,""),s.search="",window.location.href=s.href}handleConfirm(){this.confirming=!0,this.editPreview?.payment?.required&&this.editPreview.payment.payment_url?window.location.href=this.editPreview.payment.payment_url:this.navigateToOrder()}async cancelEditSession(){try{await salla.order.api.cancelEditSession(this.orderId),this.navigateToOrder()}catch(s){const t=s?.response?.data?.error?.message||s?.response?.data?.message;t&&salla.notify.error(t)}}renderSaveModal(){const s=this.editPreview,e=s?.totals?.remaining_amount?.amount>0,a=s?.totals?.refund_amount?.amount>0,i=s?.totals?.tax?.amount?.amount;return t("salla-modal",{ref:s=>this.saveModal=s,width:"md",onModalVisibilityChanged:async s=>{s.detail||(this.editPreview=null,this.confirming||await this.cancelEditSession(),this.confirming=!1)}},t("div",{class:"s-order-edit-modal"},t("h2",{class:"s-order-edit-modal-title"},salla.lang.getWithDefault("pages.orders.edit_summary_title","ملخص الطلب بعد التعديل")),s?.items?.length>0&&t("div",{class:"s-order-edit-modal-items"},s.items.map((s=>{const e=this.order?.items?.find((t=>t.id==s.id)),a=e?.product?.image?.url,i=s.options?.join("/ ");return t("div",{class:"s-order-edit-modal-item"},t("div",{class:"s-order-edit-modal-item-start"},a&&t("img",{src:a,alt:s.name,class:"s-order-edit-modal-item-image"}),t("div",null,t("p",{class:"s-order-edit-modal-item-name"},s.name),i&&t("span",{class:"s-order-edit-modal-item-options"},i))),t("div",{class:"s-order-edit-modal-item-end"},t("span",{class:"s-order-edit-modal-item-price",innerHTML:salla.money(s.price.amount)})))}))),s?.totals?.updated_products_total&&t("div",{class:"s-order-edit-modal-row"},t("span",{class:"s-order-edit-modal-row-label"},salla.lang.getWithDefault("pages.orders.modified_products_total","مجموع المنتجات المعدلة")),t("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(s.totals.updated_products_total.amount)})),i>0&&t("div",{class:"s-order-edit-modal-row"},t("span",{class:"s-order-edit-modal-tax-label"},t("i",{class:"sicon-info-circle s-order-edit-modal-tax-icon"}),salla.lang.getWithDefault("pages.orders.vat","ضريبة القيمة المضافة")),t("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(i)})),s?.totals?.total&&t("div",{class:"s-order-edit-modal-total"},t("span",{class:"s-order-edit-modal-total-label"},salla.lang.getWithDefault("pages.orders.order_total","اجمالي الطلب")),t("span",{class:"s-order-edit-modal-total-value",innerHTML:salla.money(s.totals.total.amount)})),a&&t("div",{class:"s-order-edit-modal-refund"},t("i",{class:"sicon-info-circle s-order-edit-modal-refund-icon"}),t("p",{class:"s-order-edit-modal-refund-text"},salla.lang.getWithDefault("pages.orders.refund_message","سيتم تحويل فارق المبلغ على نفس وسيلة الدفع"))),t("div",{class:"s-order-edit-modal-btn-wrapper"},t("salla-button",{onClick:()=>this.handleConfirm()},e?salla.lang.getWithDefault("pages.orders.pay_difference","دفع فارق المبلغ"):a?salla.lang.getWithDefault("pages.orders.confirm_and_receive_difference","تأكيد واستلام فارق المبلغ"):salla.lang.getWithDefault("pages.orders.confirm_changes","تأكيد التعديلات"),t("i",{class:"sicon-keyboard_arrow_left s-order-edit-modal-btn-icon"})))))}render(){if(this.loading)return t(e,null,t("salla-loading",null));if(this.expired)return t(e,null,t("div",{class:"s-order-edit-expired"},t("p",null,salla.lang.getWithDefault("pages.orders.edit_session_expired","انتهت مدة التعديل المتاحة")),t("salla-button",{onClick:()=>this.navigateToOrder()},salla.lang.getWithDefault("pages.orders.back_to_order","العودة إلى تفاصيل الطلب"))));if(this.error||!this.order)return t(e,null,t("div",{class:"no-content-placeholder"},t("i",{class:"sicon-shopping-bag icon"}),t("p",null,this.error)));const s=this.order.items&&this.order.items.length>0,a=this.order.customer_editing_session?.ends_at;return t(e,null,a&&t("div",{class:"s-order-edit-timer-wrapper"},t("salla-count-down",{prefixText:salla.lang.getWithDefault("pages.orders.edit_within","يمكنك التعديل خلال"),date:a,horizontal:!0,withButton:!0,autoSegments:!0,labeled:!1,size:"sm",color:"primary"})),t("div",{class:"s-order-edit-items-wrapper"},t("h2",{class:"s-order-edit-items-title"},salla.lang.getWithDefault("pages.orders.order_products","منتجات الطلب")),s?this.order.items.map(((s,e)=>[t("salla-order-edit-item",{key:s.id,item:s,orderId:this.orderId}),e<this.order.items.length-1?t("div",{class:"s-order-edit-items-divider"}):null])):t("div",{class:"no-content-placeholder"},t("i",{class:"sicon-shopping-bag icon"}),t("p",null,salla.lang.getWithDefault("common.elements.no_items","لا توجد عناصر")))),t("div",{class:"s-order-edit-actions"},t("salla-button",{onClick:()=>this.saveOrder(),loading:this.saveLoading,disabled:!this.hasChanges},salla.lang.getWithDefault("pages.orders.save_changes","حفظ التعديلات")),t("salla-button",{color:"gray",fill:"outline",onClick:()=>this.cancelEditSession()},salla.lang.getWithDefault("common.elements.cancel","الغاء"))),this.renderSaveModal())}get host(){return a(this)}};i.style="";export{i as salla_order_edit}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Crafted with ❤ by Salla
|
|
3
|
-
*/
|
|
4
|
-
import{f as t}from"./p-BwsreBbG.js";function r(r,s={}){return s=Object.assign({initialData:void 0,initialStatus:"idle"},s),(i,e)=>{const o=Object.assign((function(...s){const i=r=>{Object.assign(this[e],r),t(this)};return i({status:"pending",error:void 0}),r.call(this,...s).then((t=>(i({status:"success",data:t,error:void 0}),t)),(t=>(i({status:"error",error:t}),Promise.reject(t))))}),{status:s.initialStatus,data:s.initialData,error:void 0});Object.defineProperty(i,e,{value:o})}}export{r as T}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Crafted with ❤ by Salla
|
|
3
|
-
*/
|
|
4
|
-
import{r as t,c as s,h as i,H as e,a}from"./p-BwsreBbG.js";const o=class{constructor(i){t(this,i),this.orderItemUpdated=s(this,"orderItemUpdated"),this.orderItemRemoved=s(this,"orderItemRemoved"),this.handleQuantityChange=t=>{const s=t.detail,i=s?.quantity??parseInt(t.target.value,10);isNaN(i)||i<1||i!==this.quantity&&(this.quantity=i,this.emitUpdate(i))},this.handleOptionsChange=()=>{this.emitUpdate(this.quantity)}}componentWillLoad(){this.quantity=this.item?.quantity||1}componentDidLoad(){const t=this.host.querySelector("salla-quantity-input");t&&t.addEventListener("change",this.handleQuantityChange);const s=this.host.querySelector("salla-product-options");s&&s.addEventListener("change",this.handleOptionsChange)}disconnectedCallback(){const t=this.host.querySelector("salla-quantity-input");t&&t.removeEventListener("change",this.handleQuantityChange);const s=this.host.querySelector("salla-product-options");s&&s.removeEventListener("change",this.handleOptionsChange)}get hasOptions(){const t=this.item.product?.options;return t&&t.length>0}async getSelectedOptions(){const t=this.host.querySelector(`salla-product-options[product-id="${this.item.product?.id}"]`);return await(t?.getSelectedOptionsData())||{}}async emitUpdate(t){const s={itemId:this.item?.id,quantity:t};this.hasOptions&&(s.options=await this.getSelectedOptions()),this.orderItemUpdated.emit(s)}removeItem(){const t=this.item?.id;null!=t&&this.orderItemRemoved.emit({itemId:t})}render(){if(!this.item)return null;const t=this.item.product,s=this.item.name||t?.name||"",a=t?.image?.url||"",o=t?.image?.alt||s,n=t?.url||"#",l=t?.price,r=t?.max_quantity,d=t?.weight_label,c=this.item.product?.options,h={value:this.quantity};return r&&(h.max=r),i(e,null,i("div",null,i("div",{class:"s-order-edit-item-header"},i("div",{class:"s-order-edit-item-media"},a&&i("a",{href:n},i("img",{src:a,alt:o,class:"s-order-edit-item-image"})),i("div",{class:"s-order-edit-item-details"},i("h2",{class:"s-order-edit-item-name"},i("a",{href:n,class:"s-order-edit-item-link"},s)),null!=l&&i("span",{class:"s-order-edit-item-price",innerHTML:salla.money(l)}),d&&i("p",{class:"s-order-edit-item-weight"},salla.lang.getWithDefault("pages.products.weight","الوزن")," ",d))),i("salla-button",{type:"button",shape:"icon",size:"small",color:"danger","aria-label":salla.lang.getWithDefault("common.elements.delete","حذف"),onClick:()=>this.removeItem()},i("i",{class:"sicon-cancel"}))),i("div",{class:"s-order-edit-item-quantity"},i("h3",{class:"s-order-edit-item-quantity-label"},salla.lang.getWithDefault("common.elements.quantity","الكمية")),i("div",{class:"s-order-edit-item-quantity-input"},i("salla-quantity-input",{...h}))),this.hasOptions&&i("form",{onSubmit:t=>t.preventDefault()},i("salla-product-options",{"product-id":t.id,options:JSON.stringify(c),key:`${t.id}-order-edit-item-options`}))))}get host(){return a(this)}};o.style="";export{o as salla_order_edit_item}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Crafted with ❤ by Salla
|
|
3
|
-
*/
|
|
4
|
-
import{r as t,c as s,h as i,H as e,a}from"./p-BwsreBbG.js";import{a as o}from"./p-CgtvEd63.js";import{S as r}from"./p-DiKTtDW5.js";import{H as h}from"./p-CHf8XdiS.js";const l=class{constructor(i){t(this,i),this.productsFetched=s(this,"productsFetched"),this.autoload=!1,this.productCardComponent="custom-salla-product-card",this.page=1,this.placeholderText=salla.lang.get("pages.categories.no_products"),this.endOfText=salla.lang.get("common.elements.end_of_content"),this.failedLoadMore=salla.lang.get("common.elements.failed_to_load_more"),this.currentPage=salla.config.get("page"),this.filtersSnapshot=[],this.lastViewedProductKey="lastViewedProductId",this.filtersKey="filters",this.infiniteScrollStateKey="infiniteScrollState",this.prevCategoryIdKey="prevCategoryId",this.isProcessing=!1,this.scrollTimeout=null,this.boundScrollToLastViewedProduct=()=>this.scrollToLastViewedProduct(),this.boundHandleScroll=()=>this.handleScroll(),this.specialPagesWithoutIds={"product.index.latest":"latest","product.index.offers":"offers","product.index.search":"search","product.index.sales":"sales"},this.includes=h.parseJson(this.includes||this.host.getAttribute("includes")),Array.isArray(this.includes)||(this.includes=null),h.setIncludes(this.includes),salla.lang.onLoaded((()=>{this.placeholderText=salla.lang.get("pages.categories.no_products"),this.endOfText=salla.lang.get("common.elements.end_of_content"),this.failedLoadMore=salla.lang.get("common.elements.failed_to_load_more"),this.currentPage=salla.config.get("page")}))}connectedCallback(){"scrollRestoration"in history&&(history.scrollRestoration="manual"),window.addEventListener("DOMContentLoaded",this.boundScrollToLastViewedProduct),salla.event.on("salla-filters::changed",(t=>this.setFilters(t)))}disconnectedCallback(){window.removeEventListener("DOMContentLoaded",this.boundScrollToLastViewedProduct),window.removeEventListener("scroll",this.boundHandleScroll)}async setFilters(t){if(t&&JSON.stringify(t)!==JSON.stringify(this.parsedFilters))return window.scrollTo({top:0,behavior:"smooth"}),this.parsedFilters=JSON.parse(JSON.stringify(t)),this.filtersSnapshot=this.parsedFilters,"product.index"==this.currentPage?.slug&&this.parsedFilters&&this.parsedFilters.category_id&&(this.currentCategoryIdFilter=[this.parsedFilters.category_id]),this.reload()}async reload(){!this.autoload&&this.loadMoreWrapper&&(this.loadMoreWrapper.style.display="none"),this.hasInfiniteScroll&&salla.infiniteScroll.destroy(this.infiniteScroll),this.buildNextPageUrl(),this.wrapper.innerHTML="",this.hasInfiniteScroll?this.init():this.getInitialData(),this.showPlaceholder&&(this.showPlaceholder=!1,this.placeholderLoader=document.createElement("div"),this.placeholderLoader.classList.add("s-products-list-loading-wrapper"),this.placeholderLoader.style.display="inherit",this.placeholderLoader.innerHTML='<span class="s-button-loader s-button-loader-center s-infinite-scroll-btn-loader"></span>',this.host.insertAdjacentElement("afterend",this.placeholderLoader))}isFilterable(){return salla.config.get("store.settings.product.filters")&&this.filtersResults}isSourceWithoutValue(){return["offers","latest","sales","wishlist","top-rated","reorder"].includes(this.getSource())}animateItems(){o({targets:"salla-products-list salla-product-card",opacity:[0,1],duration:1200,translateY:[20,0],delay:function(t,s){return 100*s}})}initBaseNextPageUrl(t){this.nextPage=salla.url.api(`products?source=${t}`),this.includes?.length&&(this.nextPage+=`&includes[]=${this.includes.join("&includes[]=")}`),this.limit&&(this.nextPage+=`&per_page=${this.limit>32?32:this.limit}`),this.sortBy&&(this.nextPage+=`&sort=${this.sortBy}`),"preview"===salla.config.get("theme.mode")&&(this.nextPage+="&use_username_url=1"),this.nextPage+="&filterable=1";for(const[t,s]of Object.entries(this.parsedFilters||{}))if(["string","number"].includes(typeof s))this.nextPage+=`&filters[${encodeURIComponent(t)}]=${encodeURIComponent(s)}`;else if(Array.isArray(s))s.forEach((s=>this.nextPage+=`&filters[${encodeURIComponent(t)}][]=${encodeURIComponent(s)}`));else if("object"==typeof s)for(const[i,e]of Object.entries(s))this.nextPage+=`&filters[${encodeURIComponent(t)}][${encodeURIComponent(i)}]=${encodeURIComponent(e)}`}buildNextPageUrl(){let t=this.getSource();if("json"===t)return;const s=sessionStorage.getItem(this.infiniteScrollStateKey);if(s){const{nextPage:t}=JSON.parse(s);if(!t)return}if(this.initBaseNextPageUrl(t),!this.isSourceWithoutValue())if(["search","related","landing-page"].includes(t))this.nextPage+=`&source_value=${this.getSourceValue()}`;else try{this.nextPage+=`&source_value[]=${this.getSourceValue().join("&source_value[]=")}`}catch(s){salla.logger.warn(`source-value prop should be array of ids ex source-value="[1,2,3]" for the source [${t}]`),this.sourceValueIsValid=!1}}loading(t=!0,s=!1){if(t){let t=s&&!this.autoload?this.btnLoader:this.loader;t&&(t.style.display="inherit")}else this.autoload||this.btnLoader&&(this.btnLoader.style.display="none"),this.loader&&(this.loader.style.display="none")}getItemHTML(t){"landing-page"===this.getSource()&&(t.url="");const s=document.createElement(this.hasCustomComponent?this.productCardComponent:"salla-product-card");return s.product=t,this.compactCards&&(s.compact=!0,s.toggleAttribute("compact",!0)),this.applyLandingPageStyles(s),this.applyHorizontalCardStyles(s),s.addEventListener("click",(s=>{s.target.closest("a")&&(h.saveProductSource(this.getSource()),this.hasInfiniteScroll&&(this.takeStateSnapshot(),sessionStorage.setItem(this.lastViewedProductKey,t.id)))})),s}applyLandingPageStyles(t){"landing-page"!==this.getSource()||this.hasCustomComponent||(t.toggleAttribute("hide-add-btn",!0),t.classList.add("s-product-card-fit-height"))}applyHorizontalCardStyles(t){this.horizontalCards&&(t.toggleAttribute("horizontal",!0),this.hasCustomComponent||t.toggleAttribute("shadow-on-hover",!0))}waitForResizing(t){let s=null;return new Promise((i=>{const e=new ResizeObserver((()=>{clearTimeout(s),s=setTimeout((()=>{e.disconnect(),i(null)}),160)}));e.observe(t)}))}waitForLayoutStable(t){let s=null;return new Promise((i=>{const e=new MutationObserver((()=>{clearTimeout(s),s=setTimeout((()=>{e.disconnect(),i(null)}),160)}));e.observe(t,{childList:!0,subtree:!0,attributes:!0})}))}async waitForStableLayout(t){return await Promise.allSettled([this.waitForResizing(t),this.waitForLayoutStable(t)])}scrollToLastViewedProduct(){const t=sessionStorage.getItem(this.lastViewedProductKey);t&&!salla.url.is_page("product.single")&&this.isElementLoaded(`[id*="${t}"]`).then((()=>{const s=this.wrapper?.querySelector(`[id*="${t}"]`);if(!s)return;const i=()=>{const t=()=>{s.scrollIntoView({block:"start",behavior:"instant"});const t=matchMedia("(max-width: 1024px)").matches?"header .inner":"ul.main-menu",i=window?.header_is_sticky?document.querySelector(t)?.getBoundingClientRect()?.height??56:0,e=parseInt(getComputedStyle(this.wrapper).rowGap)??16;scrollBy({top:-1*(i+e),behavior:"instant"})};requestAnimationFrame(t),s.querySelectorAll("img.lazy").forEach((s=>{const i=s,e=()=>{requestAnimationFrame(t),i.onload=i.onerror=null};i.onload=e,i.onerror=e})),this.removeScrollRestorationSession()};this.waitForStableLayout(this.host).then((()=>requestAnimationFrame(i)))}))}isElementLoaded(t){return new Promise((s=>{const i=setInterval((()=>{if(document.querySelector(t))return clearInterval(i),s(document.querySelector(t))}),50)}))}takeStateSnapshot(){const t=[];for(let s=0;s<this.wrapper.children.length;s++){const i=this.wrapper.children?.[s];t.push(i.product)}const s={pageIndex:Math.max((this.infiniteScroll?.pageIndex??1)-1,1),nextPage:this.nextPage,currentPageData:t};if(this.isFilterable()){const t=sessionStorage.getItem(this.filtersKey);sessionStorage.setItem(this.filtersKey,t||JSON.stringify(this.filtersSnapshot))}sessionStorage.setItem(this.infiniteScrollStateKey,JSON.stringify(s));let i=salla.config.get("page.id");const e=Object.keys(this.specialPagesWithoutIds).find((t=>salla.url.is_page(t)));e?i=this.specialPagesWithoutIds[e]:null!==i&&(i=String(i)),sessionStorage.setItem(this.prevCategoryIdKey,i)}removeScrollRestorationSession(){this.isFilterable()||sessionStorage.removeItem(this.filtersKey),sessionStorage.removeItem(this.infiniteScrollStateKey),sessionStorage.removeItem(this.lastViewedProductKey),sessionStorage.removeItem(this.prevCategoryIdKey)}loadStoredScrollState(){const t=sessionStorage.getItem(this.infiniteScrollStateKey),s=sessionStorage.getItem(this.filtersKey),i=sessionStorage.getItem(this.prevCategoryIdKey),e=this.specialPagesWithoutIds[salla.config.get("page.slug")]||null,a=salla.config.get("page.id"),o=salla.url.is_page("index"),r=salla.url.is_page("product.single"),h=e?i!==e:i!==String(a);if(i&&h&&!o&&!r||o&&!this.hasInfiniteScroll)return this.removeScrollRestorationSession(),this.switchToNormalBehavior=!0,!1;if(r)return this.switchToNormalBehavior=!0,!1;if(t)try{const{pageIndex:i,nextPage:e,currentPageData:a}=JSON.parse(t);if("undefined"!==s){const t=JSON.parse(s);salla.event.emit("filters::fetched",{filters:t})}this.page=i,this.nextPage=e;for(let t=0;t<a.length;t++)this.wrapper.append(this.getItemHTML(a?.[t]));return!0}catch(t){console.error("Failed to load stored scroll state:",t),this.removeScrollRestorationSession()}return!1}getSource(){return h.getProductsSource(this.source)}getSourceValue(){return this.currentCategoryIdFilter?this.currentCategoryIdFilter:h.getProductsSourceValue(this.source,this.sourceValue)}appendDataLayer(t){"object"==typeof dataLayer&&Array.isArray(dataLayer)&&dataLayer.push({event:"impressions",ecommerce:{currencyCode:salla.config.currency().code,impressions:t.map(((t,s)=>({id:t.id,name:t.name,price:t.price,brand:t.brand?.name||"",quantity:t.quantity,categories:[{name:t.category?.name||salla.config.get("page.title"),id:salla.config.get("page.id")}],category:t.category?.name||salla.config.get("page.title"),position:s+1})))}})}initiateInfiniteScroll(){if(!this.hasInfiniteScroll)return;const t=this.autoload&&this.includes&&this.includes.length>0;this.infiniteScroll=salla.infiniteScroll.initiate(this.wrapper,this.wrapper,{path:()=>this.nextPage,history:!1,nextPage:this.nextPage,scrollThreshold:!t&&!!this.autoload&&100,loadOnScroll:!t&&this.autoload},!0),this.infiniteScroll.pageIndex=this.page,this.infiniteScroll?.on("request",(()=>{this.loading(!0,!this.autoload)})),t&&window.addEventListener("scroll",this.boundHandleScroll),this.infiniteScroll?.on("load",(async t=>{if(!this.isProcessing){this.isProcessing=!0;try{if(!t.data?.length&&2===this.infiniteScroll.pageIndex)return this.showPlaceholder=!0,salla.infiniteScroll.destroy(this.infiniteScroll),this.loading(!1),void(this.placeholderLoader&&this.placeholderLoader.remove());this.includes&&await this.injectAndProcessData(t);const s=this.handleResponse(t);this.infiniteScroll.appendItems(s),2===this.infiniteScroll.pageIndex&&(!this.autoload&&this.nextPage&&(this.loadMoreWrapper.style.display="block"),this.animateItems())}catch(t){console.error("Error during load:",t)}finally{this.isProcessing=!1}}})),this.infiniteScroll?.on("error",(()=>{console.log("Error occurred during request"),this.status.querySelector(".s-infinite-scroll-error").classList.remove("s-hidden"),this.placeholderLoader&&this.placeholderLoader.remove(),this.loading(!1),this.isProcessing=!1})),salla.onReady((()=>{sessionStorage.getItem(this.infiniteScrollStateKey)||this.manualLoadNextPage()}))}handleScroll(){this.isProcessing||this.scrollTimeout||(this.scrollTimeout=setTimeout((()=>{this.scrollTimeout=null,requestAnimationFrame((()=>{const t=this.wrapper.getBoundingClientRect(),s=window.innerHeight;t.bottom-s<=200&&!this.isProcessing&&this.nextPage&&this.manualLoadNextPage()}))}),200))}manualLoadNextPage(){this.nextPage&&this.infiniteScroll.loadNextPage()}async injectAndProcessData(t){try{await h.injectExtraFieldsToResponse(t)}catch(t){console.error("Error injecting data:",t)}}getInitialData(){return this.loading(),salla.api.withoutNotifier((()=>salla.product.api.fetch({source:h.getApiSource(this.getSource()),source_value:this.getSourceValue(),limit:this.limit}).then((async t=>t.data.length?(await h.injectExtraFieldsToResponse(t),this.firstPageResponse?void this.handleResponse(t).forEach((t=>this.wrapper.append(t))):(this.firstPageResponse=t,void(this.nextPage=t.cursor?t.cursor.next:this.nextPage))):(this.showPlaceholder=!0,this.placeholderLoader&&this.placeholderLoader.remove(),void this.loading(!1))))))}async loadMore(){this.infiniteScroll?.loadNextPage()}componentWillLoad(){return salla.onReady().then((()=>{this.hasCustomComponent=!!customElements.get(this.productCardComponent),this.sourceValueIsValid=!(!this.getSourceValue()&&!this.isSourceWithoutValue()),this.hasInfiniteScroll=!["json","selected","related","landing-page","recently"].includes(this.getSource())&&!this.limit;let t=new URLSearchParams(window.location.search);try{this.sortBy=this.sortBy||t.get("sort")||t.get("by"),this.parsedFilters=h.extractFiltersFromUrl(t),this.parsedFilters&&this.parsedFilters.category_id&&(this.currentCategoryIdFilter=[this.parsedFilters.category_id])}catch(t){salla.logger.warn("failed to get filters from url",t.message)}if(this.buildNextPageUrl(),this.isReady=!0,!sessionStorage.getItem(this.infiniteScrollStateKey))if(this.sourceValueIsValid){if(!this.hasInfiniteScroll){if("json"===this.getSource())return this.getSourceValue().length?void setTimeout((()=>{this.getSourceValue().map((t=>this.wrapper.append(this.getItemHTML(t))))})):void(this.showPlaceholder=!0);if("selected"!==this.getSource()||this.getSourceValue().length)return this.getInitialData();this.showPlaceholder=!0}}else salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`)}))}async componentDidLoad(){this.hasInfiniteScroll&&this.init(),await Salla.hooks.registerComponent("salla-products-list",this),this.loadStoredScrollState()?(this.autoload?!this.nextPage&&this.loading(!1):this.nextPage?this.loadMoreWrapper&&(this.loadMoreWrapper.style.display="block"):(this.loadMoreWrapper&&(this.loadMoreWrapper.style.display="none"),this.status.querySelector(".s-infinite-scroll-last").classList.remove("s-hidden")),this.scrollToLastViewedProduct()):!this.firstPageResponse&&this.switchToNormalBehavior?this.getInitialData().then((()=>{this.firstPageResponse?(this.handleResponse(this.firstPageResponse,!1).forEach((t=>{this.wrapper.append(t)})),setTimeout((()=>{if(!this.autoload&&this.nextPage&&1==this.infiniteScroll.pageIndex){const t=this.host.querySelector(".s-infinite-scroll-wrapper");t&&(t.style.display="block")}}))):console.error("No response received after getInitialData.")})).catch((t=>{console.error("Error during initial data fetch:",t)})):this.firstPageResponse&&this.handleResponse(this.firstPageResponse,!1).forEach((t=>this.wrapper.append(t)))}canRender(){return this.sourceValueIsValid&&this.isReady}render(){return this.canRender()?this.showPlaceholder?i("div",{class:"s-products-list-placeholder"},i("span",{innerHTML:r}),i("p",null,this.placeholderText)):i(e,{class:"s-products-list"},i("div",{class:{"s-products-list-wrapper":!0,"s-products-list-horizontal-cards":this.horizontalCards&&!this.filtersResults,"s-products-list-vertical-cards":!this.horizontalCards&&!this.rowCards&&!this.filtersResults,"s-products-list-row-cards":this.rowCards,"s-products-list-compact-cards":this.compactCards,"s-products-list-filters-results":this.filtersResults},ref:t=>this.wrapper=t}),i("div",{class:"s-infinite-scroll-status",ref:t=>this.status=t},i("p",{class:"s-infinite-scroll-last infinite-scroll-last s-hidden"},this.endOfText),i("p",{class:"s-infinite-scroll-error infinite-scroll-error s-hidden"},this.failedLoadMore)),this.autoload&&i("div",{class:"s-products-list-loading-wrapper",style:{display:"none"},ref:t=>this.loader=t},i("span",{class:"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader"})),this.hasInfiniteScroll&&this.nextPage&&!this.autoload?i("div",{class:"s-infinite-scroll-wrapper",style:{display:"none"},ref:t=>this.loadMoreWrapper=t},i("button",{onClick:()=>this.loadMore(),class:"s-infinite-scroll-btn s-button-btn s-button-primary"},i("span",{class:"s-button-text s-infinite-scroll-btn-text"},this.loadMoreText?this.loadMoreText:salla.lang.get("common.elements.load_more")),i("span",{class:"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader",ref:t=>this.btnLoader=t,style:{display:"none"}}))):""):""}init(){this.initiateInfiniteScroll(),this.loading()}handleResponse(t,s=!0){if(!t)return[];let i=this.getSource(),e="";if(1===t.cursor?.current){e=h.getPageTitleForSource(i);try{if("search"===this.getSource())e=salla.lang.get("common.elements.search_about",{word:this.getSourceValue()});else if(!e){let s=this.parsedFilters.category_id||this.getSourceValue()[0];e=t.filters?.find((t=>"category_id"===t.key))?.values?.find((t=>t.key===s))?.value??"",this.filtersSnapshot=t.filters}e+=(e?" - ":"")+salla.lang.choice("blocks.header.products_count",t.data?.length),15===t.data.length&&(e=e.replace(t.data.length,salla.lang.get("common.elements.more_than")+" "+t.data.length)),t.title=e}catch(t){salla.logger.error("Error::falid to handle response",t)}h.generateProductSchema(t.data)}this.appendDataLayer(t.data),t.nextPage=this.nextPage,t.source=this.getSource(),t.sourceValue=this.getSourceValue(),salla.event.emit("salla-products-list::products.fetched",t),this.productsFetched.emit(t),t.filters&&this.isFilterable()?(this.filtersResults=!0,this.filtersSnapshot=JSON.parse(JSON.stringify(t.filters)),salla.event.emit("filters::fetched",{filters:t.filters})):this.isFilterable()&&salla.event.emit("filters::hidden"),s&&(this.nextPage=t.cursor?t.cursor.next:this.nextPage),this.loading(!1),this.placeholderLoader&&this.placeholderLoader.remove(),this.hasInfiniteScroll&&!this.nextPage&&(this.infiniteScroll.option({scrollThreshold:!1,loadOnScroll:!1}),this.status.querySelector(".s-infinite-scroll-last").classList.remove("s-hidden"));const a=[];for(let s=0;s<t.data.length;s++)a.push(this.getItemHTML(t.data?.[s]));return a}get host(){return a(this)}};l.style="";export{l as salla_products_list}
|