@salla.sa/twilight-components 3.0.21 → 3.0.22
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/{Helper-8GCn2Wfh.js → Helper-CAuzGdeJ.js} +1 -1
- package/dist/cjs/{filepond-DyDRgSW7.js → filepond-DV6O0i7Z.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-poster-BbEyrQ24.js → filepond-plugin-file-poster-DV6-NSU_.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-size-dIjgIAJz.js → filepond-plugin-file-validate-size-Db166u1S.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-type-MITfI2m0.js → filepond-plugin-file-validate-type-BYB3PzOs.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-edit-B0vevlWn.js → filepond-plugin-image-edit-B6QXk344.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-C8fbY4tU.js → filepond-plugin-image-exif-orientation-Ca5k1F5m.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview-pu-ILH6g.js → filepond-plugin-image-preview-C4j2Udlc.js} +1 -1
- package/dist/cjs/{index-DjzCGoSW.js → index-CHCpMa_m.js} +2 -2
- package/dist/cjs/{intlTelInput-mRDdvd3r.js → intlTelInput-BNBzSLpY.js} +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/salla-accordion-body_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-accordion_6.cjs.entry.js +2 -2
- package/dist/cjs/salla-add-product-button_5.cjs.entry.js +2 -2
- 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-applied-filters.cjs.entry.js +2 -2
- package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
- package/dist/cjs/salla-attachment-view_9.cjs.entry.js +11 -11
- package/dist/cjs/salla-badge.cjs.entry.js +1 -1
- package/dist/cjs/salla-basket-gap.cjs.entry.js +1 -1
- package/dist/cjs/salla-bullet-delivery_3.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-cart-summary-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-cashback-banner.cjs.entry.js +1 -1
- package/dist/cjs/salla-comment-factors.cjs.entry.js +1 -1
- package/dist/cjs/salla-comment-form_9.cjs.entry.js +2 -2
- 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 +2 -2
- package/dist/cjs/salla-filters.cjs.entry.js +2 -2
- package/dist/cjs/salla-free-shipping-banner.cjs.entry.js +1 -1
- package/dist/cjs/salla-free-shipping-tag.cjs.entry.js +1 -1
- package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +1 -1
- package/dist/cjs/salla-gift-card-redeem_2.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 +2 -2
- 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_10.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-exchange-product-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-points-banner.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-points-history.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
- 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_3.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-mobile-update-modal.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-next-order-coupon.cjs.entry.js +1 -1
- package/dist/cjs/salla-notification-item_2.cjs.entry.js +2 -2
- 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-branch.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-cancel.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 +1 -1
- package/dist/cjs/salla-order-edit-product-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-edit.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-items.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-options-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-payment.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-rewards.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-shipments.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-orders.cjs.entry.js +2 -2
- package/dist/cjs/salla-payments.cjs.entry.js +1 -1
- package/dist/cjs/salla-placeholder.cjs.entry.js +1 -1
- package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
- package/dist/cjs/salla-product-card-embed.cjs.entry.js +1 -1
- package/dist/cjs/salla-product-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
- package/dist/cjs/salla-products-list.cjs.entry.js +2 -2
- package/dist/cjs/salla-products-slider.cjs.entry.js +2 -2
- package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
- package/dist/cjs/salla-rating-modal-v2.cjs.entry.js +2 -2
- package/dist/cjs/salla-rating-modal.cjs.entry.js +2 -2
- package/dist/cjs/salla-review-factors-tags.cjs.entry.js +1 -1
- package/dist/cjs/salla-review-order-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-scopes.cjs.entry.js +1 -1
- package/dist/cjs/salla-search-product-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-search.cjs.entry.js +2 -2
- package/dist/cjs/salla-skeleton.cjs.entry.js +1 -1
- package/dist/cjs/salla-social-share.cjs.entry.js +1 -1
- package/dist/cjs/salla-social.cjs.entry.js +1 -1
- package/dist/cjs/salla-tab-content_3.cjs.entry.js +1 -1
- package/dist/cjs/salla-thank-you-header.cjs.entry.js +1 -1
- package/dist/cjs/salla-thank-you-page.cjs.entry.js +1 -1
- package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
- 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 +1 -1
- package/dist/cjs/salla-verify.cjs.entry.js +1 -1
- package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
- package/dist/cjs/salla-wishlist-actions.cjs.entry.js +1 -1
- package/dist/cjs/salla-wishlist-summary.cjs.entry.js +2 -2
- package/dist/cjs/twilight.cjs.js +1 -1
- package/dist/cjs/{vanilla-picker-DTt0qsPz.js → vanilla-picker-Chebtfev.js} +1 -1
- package/dist/components/index.js +2 -2
- package/dist/docs.json +1 -1
- package/dist/esm/{Helper-DZKYnNWb.js → Helper-DfW8RE8Z.js} +1 -1
- package/dist/esm/{filepond-Th5h_x_y.js → filepond-Bc6CLtnG.js} +1 -1
- package/dist/esm/{filepond-plugin-file-poster-CH6jw-Ue.js → filepond-plugin-file-poster-Bl_fLsTQ.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-size-Q-NzkoIy.js → filepond-plugin-file-validate-size-IuRpnxuB.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-type-CbY5K7RZ.js → filepond-plugin-file-validate-type-Bo7Ab1TY.js} +1 -1
- package/dist/esm/{filepond-plugin-image-edit-JietW24Z.js → filepond-plugin-image-edit-DgnQoIV9.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-FoYRnhuB.js → filepond-plugin-image-exif-orientation-DsTifPGw.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-DVAxXbSQ.js → filepond-plugin-image-preview-cv3hlMNi.js} +1 -1
- package/dist/esm/{index-C9GauqTa.js → index-BNekvDFW.js} +2 -2
- package/dist/esm/{intlTelInput-BVoDutQ9.js → intlTelInput-Dz8xcV83.js} +1 -1
- package/dist/esm/loader.js +2 -2
- package/dist/esm/salla-accordion-body_2.entry.js +1 -1
- package/dist/esm/salla-accordion_6.entry.js +2 -2
- package/dist/esm/salla-add-product-button_5.entry.js +2 -2
- 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-applied-filters.entry.js +2 -2
- package/dist/esm/salla-apps-icons.entry.js +1 -1
- package/dist/esm/salla-attachment-view_9.entry.js +11 -11
- package/dist/esm/salla-badge.entry.js +1 -1
- package/dist/esm/salla-basket-gap.entry.js +1 -1
- package/dist/esm/salla-bullet-delivery_3.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-cart-summary-card.entry.js +1 -1
- package/dist/esm/salla-cashback-banner.entry.js +1 -1
- package/dist/esm/salla-comment-factors.entry.js +1 -1
- package/dist/esm/salla-comment-form_9.entry.js +2 -2
- 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 +2 -2
- package/dist/esm/salla-filters.entry.js +2 -2
- package/dist/esm/salla-free-shipping-banner.entry.js +1 -1
- package/dist/esm/salla-free-shipping-tag.entry.js +1 -1
- package/dist/esm/salla-fulfillment-methods.entry.js +1 -1
- package/dist/esm/salla-gift-card-redeem_2.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 +2 -2
- 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_10.entry.js +1 -1
- package/dist/esm/salla-loyalty-exchange-product-card.entry.js +1 -1
- package/dist/esm/salla-loyalty-points-banner.entry.js +1 -1
- package/dist/esm/salla-loyalty-points-history.entry.js +1 -1
- package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
- package/dist/esm/salla-loyalty.entry.js +1 -1
- package/dist/esm/salla-maintenance-alert.entry.js +1 -1
- package/dist/esm/salla-map_3.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-mobile-update-modal.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-next-order-coupon.entry.js +1 -1
- package/dist/esm/salla-notification-item_2.entry.js +2 -2
- package/dist/esm/salla-offer-modal.entry.js +1 -1
- package/dist/esm/salla-offer.entry.js +1 -1
- package/dist/esm/salla-order-branch.entry.js +1 -1
- package/dist/esm/salla-order-cancel.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 +1 -1
- package/dist/esm/salla-order-edit-product-card.entry.js +1 -1
- package/dist/esm/salla-order-edit.entry.js +1 -1
- package/dist/esm/salla-order-items.entry.js +1 -1
- package/dist/esm/salla-order-options-modal.entry.js +1 -1
- package/dist/esm/salla-order-payment.entry.js +1 -1
- package/dist/esm/salla-order-rewards.entry.js +1 -1
- package/dist/esm/salla-order-shipments.entry.js +1 -1
- package/dist/esm/salla-order-summary.entry.js +1 -1
- package/dist/esm/salla-order-totals-card.entry.js +1 -1
- package/dist/esm/salla-orders.entry.js +2 -2
- package/dist/esm/salla-payments.entry.js +1 -1
- package/dist/esm/salla-placeholder.entry.js +1 -1
- package/dist/esm/salla-price-range.entry.js +1 -1
- package/dist/esm/salla-product-card-embed.entry.js +1 -1
- package/dist/esm/salla-product-card.entry.js +1 -1
- package/dist/esm/salla-product-size-guide.entry.js +1 -1
- package/dist/esm/salla-products-list.entry.js +2 -2
- package/dist/esm/salla-products-slider.entry.js +2 -2
- package/dist/esm/salla-quick-order.entry.js +1 -1
- package/dist/esm/salla-rating-modal-v2.entry.js +2 -2
- package/dist/esm/salla-rating-modal.entry.js +2 -2
- package/dist/esm/salla-review-factors-tags.entry.js +1 -1
- package/dist/esm/salla-review-order-item.entry.js +1 -1
- package/dist/esm/salla-scopes.entry.js +1 -1
- package/dist/esm/salla-search-product-card.entry.js +1 -1
- package/dist/esm/salla-search.entry.js +2 -2
- package/dist/esm/salla-skeleton.entry.js +1 -1
- package/dist/esm/salla-social-share.entry.js +1 -1
- package/dist/esm/salla-social.entry.js +1 -1
- package/dist/esm/salla-tab-content_3.entry.js +1 -1
- package/dist/esm/salla-thank-you-header.entry.js +1 -1
- package/dist/esm/salla-thank-you-page.entry.js +1 -1
- package/dist/esm/salla-tiered-offer.entry.js +1 -1
- 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 +1 -1
- package/dist/esm/salla-verify.entry.js +1 -1
- package/dist/esm/salla-wallet.entry.js +1 -1
- package/dist/esm/salla-wishlist-actions.entry.js +1 -1
- package/dist/esm/salla-wishlist-summary.entry.js +2 -2
- package/dist/esm/twilight.js +2 -2
- package/dist/esm/{vanilla-picker-DF1Nq4hd.js → vanilla-picker-Cjh-Ze_A.js} +1 -1
- package/dist/twilight/{p-fa881be4.entry.js → p-00d667e8.entry.js} +1 -1
- package/dist/twilight/{p-7117fe09.entry.js → p-049dea32.entry.js} +1 -1
- package/dist/twilight/{p-970e99cd.entry.js → p-04e6af9e.entry.js} +1 -1
- package/dist/twilight/{p-a91ddfb4.entry.js → p-06b6f446.entry.js} +1 -1
- package/dist/twilight/{p-ed1ab1ad.entry.js → p-0b56e95f.entry.js} +1 -1
- package/dist/twilight/{p-bb05be17.entry.js → p-0b5d1aa5.entry.js} +1 -1
- package/dist/twilight/{p-8ef15ba6.entry.js → p-0bbcc35f.entry.js} +1 -1
- package/dist/twilight/{p-91473544.entry.js → p-0dff2fee.entry.js} +1 -1
- package/dist/twilight/{p-1ad63304.entry.js → p-0ee1dadf.entry.js} +1 -1
- package/dist/twilight/{p-fad39687.entry.js → p-104bca40.entry.js} +1 -1
- package/dist/twilight/{p-35ec8259.entry.js → p-125f2ee0.entry.js} +1 -1
- package/dist/twilight/{p-0166f79c.entry.js → p-1bf191eb.entry.js} +1 -1
- package/dist/twilight/{p-ea7218bf.entry.js → p-1c2e5260.entry.js} +1 -1
- package/dist/twilight/{p-e233642f.entry.js → p-1d2102ad.entry.js} +1 -1
- package/dist/twilight/{p-aa5d0b21.entry.js → p-1e6fa8b3.entry.js} +1 -1
- package/dist/twilight/{p-466b7d90.entry.js → p-201104da.entry.js} +1 -1
- package/dist/twilight/{p-062fc545.entry.js → p-2bab06c3.entry.js} +1 -1
- package/dist/twilight/{p-d6d86cb3.entry.js → p-2e24994d.entry.js} +1 -1
- package/dist/twilight/{p-eae77b32.entry.js → p-33fba2cf.entry.js} +1 -1
- package/dist/twilight/{p-bddfcbc8.entry.js → p-377cdf1f.entry.js} +1 -1
- package/dist/twilight/{p-0532a824.entry.js → p-38f2bd9b.entry.js} +1 -1
- package/dist/twilight/{p-1c820b97.entry.js → p-3c03d14a.entry.js} +1 -1
- package/dist/twilight/{p-709b4ab5.entry.js → p-41202dbb.entry.js} +1 -1
- package/dist/twilight/{p-62bf84fd.entry.js → p-418ad88e.entry.js} +1 -1
- package/dist/twilight/{p-33c586a7.entry.js → p-4468ac98.entry.js} +1 -1
- package/dist/twilight/{p-54a0fabd.entry.js → p-45fe04fd.entry.js} +1 -1
- package/dist/twilight/{p-115e4d6f.entry.js → p-46fa33ae.entry.js} +1 -1
- package/dist/twilight/{p-638e0139.entry.js → p-4b88f596.entry.js} +1 -1
- package/dist/twilight/{p-979d0918.entry.js → p-4c5bd7c1.entry.js} +1 -1
- package/dist/twilight/{p-12486655.entry.js → p-4f098545.entry.js} +1 -1
- package/dist/twilight/{p-63247bfb.entry.js → p-5764788d.entry.js} +1 -1
- package/dist/twilight/{p-4514bfbc.entry.js → p-57f318e8.entry.js} +1 -1
- package/dist/twilight/{p-4f323370.entry.js → p-586d675b.entry.js} +1 -1
- package/dist/twilight/{p-6c4555b2.entry.js → p-5c976451.entry.js} +1 -1
- package/dist/twilight/{p-043d73d9.entry.js → p-6149030c.entry.js} +1 -1
- package/dist/twilight/{p-173677bd.entry.js → p-625bdbb6.entry.js} +1 -1
- package/dist/twilight/{p-70ce472b.entry.js → p-62fcec73.entry.js} +1 -1
- package/dist/twilight/{p-116ba74d.entry.js → p-671ac08f.entry.js} +1 -1
- package/dist/twilight/{p-5ed309ee.entry.js → p-7838a5fd.entry.js} +1 -1
- package/dist/twilight/{p-95f7c99b.entry.js → p-7908a58c.entry.js} +1 -1
- package/dist/twilight/{p-628ae902.entry.js → p-7bf85dae.entry.js} +1 -1
- package/dist/twilight/p-7f6f9d0e.entry.js +4 -0
- package/dist/twilight/{p-89c62a00.entry.js → p-81d878de.entry.js} +1 -1
- package/dist/twilight/{p-0e68d32e.entry.js → p-8429392a.entry.js} +1 -1
- package/dist/twilight/{p-8722a50c.entry.js → p-86ab1578.entry.js} +1 -1
- package/dist/twilight/{p-882d7c08.entry.js → p-8cf35d34.entry.js} +1 -1
- package/dist/twilight/{p-e5741ee6.entry.js → p-8d0fb329.entry.js} +1 -1
- package/dist/twilight/{p-ca329334.entry.js → p-91ad0bac.entry.js} +1 -1
- package/dist/twilight/{p-7d97513e.entry.js → p-94f85fa6.entry.js} +1 -1
- package/dist/twilight/{p-e54ad603.entry.js → p-9638738f.entry.js} +1 -1
- package/dist/twilight/{p-405a0719.entry.js → p-9914bb99.entry.js} +1 -1
- package/dist/twilight/{p-018826eb.entry.js → p-9a73ca9e.entry.js} +1 -1
- package/dist/twilight/{p-77c477bd.entry.js → p-9c9379e6.entry.js} +1 -1
- package/dist/twilight/{p-7a1cdcc7.entry.js → p-9f50ac84.entry.js} +1 -1
- package/dist/twilight/{p-C9GauqTa.js → p-BNekvDFW.js} +1 -1
- package/dist/twilight/{p-C0zPqHmm.js → p-BXKSGzKV.js} +1 -1
- package/dist/twilight/{p-BTPANJIN.js → p-CCPdEfoe.js} +1 -1
- package/dist/twilight/{p-Cc1dNnp_.js → p-COwkTkvn.js} +1 -1
- package/dist/twilight/{p-CFzrPKbi.js → p-Co_-mXfS.js} +1 -1
- package/dist/twilight/{p-DuCmj2_U.js → p-D5FQ0WRe.js} +1 -1
- package/dist/twilight/{p-DibVuHKp.js → p-DR0WZviU.js} +1 -1
- package/dist/twilight/{p-CSsOnp68.js → p-LtS3HRdN.js} +1 -1
- package/dist/twilight/{p-tNwFaykp.js → p-MZn39yer.js} +1 -1
- package/dist/twilight/{p-172f2a77.entry.js → p-a19a5611.entry.js} +1 -1
- package/dist/twilight/{p-2e805b61.entry.js → p-a209a2e4.entry.js} +1 -1
- package/dist/twilight/{p-46848a79.entry.js → p-a2488682.entry.js} +1 -1
- package/dist/twilight/{p-283d55a9.entry.js → p-a89e40aa.entry.js} +1 -1
- package/dist/twilight/{p-e353ad86.entry.js → p-a8fd0442.entry.js} +1 -1
- package/dist/twilight/{p-175aa116.entry.js → p-a956472d.entry.js} +1 -1
- package/dist/twilight/{p-2bf7cbe6.entry.js → p-a95c0a09.entry.js} +1 -1
- package/dist/twilight/{p-39cf245a.entry.js → p-b02baa8a.entry.js} +1 -1
- package/dist/twilight/{p-931cc451.entry.js → p-b36fe22d.entry.js} +1 -1
- package/dist/twilight/{p-f72cbb2e.entry.js → p-b43ef0e9.entry.js} +1 -1
- package/dist/twilight/{p-2ac25f71.entry.js → p-b4972389.entry.js} +1 -1
- package/dist/twilight/{p-1e675e56.entry.js → p-ba2c5b59.entry.js} +1 -1
- package/dist/twilight/{p-d0691020.entry.js → p-bbf58048.entry.js} +1 -1
- package/dist/twilight/{p-df317844.entry.js → p-bc1f5fe2.entry.js} +1 -1
- package/dist/twilight/{p-149eb28d.entry.js → p-bc842250.entry.js} +1 -1
- package/dist/twilight/{p-28a3838d.entry.js → p-beab90d6.entry.js} +1 -1
- package/dist/twilight/{p-0d0f83be.entry.js → p-beec9469.entry.js} +1 -1
- package/dist/twilight/{p-cf211a8c.entry.js → p-c11c6c01.entry.js} +1 -1
- package/dist/twilight/{p-45b91895.entry.js → p-c44f5313.entry.js} +1 -1
- package/dist/twilight/{p-08369cba.entry.js → p-c5efb28f.entry.js} +1 -1
- package/dist/twilight/{p-95758bdd.entry.js → p-cd2174f2.entry.js} +1 -1
- package/dist/twilight/{p-eb60fbbe.entry.js → p-ce2bf246.entry.js} +1 -1
- package/dist/twilight/{p-da4b0896.entry.js → p-cf8ecf55.entry.js} +1 -1
- package/dist/twilight/{p-da548ddf.entry.js → p-d25b4ee3.entry.js} +1 -1
- package/dist/twilight/{p-76141be4.entry.js → p-d5dad2cb.entry.js} +1 -1
- package/dist/twilight/{p-624c2b99.entry.js → p-d6b354e5.entry.js} +1 -1
- package/dist/twilight/{p-dff32c76.entry.js → p-da315a25.entry.js} +1 -1
- package/dist/twilight/{p-d9b6090b.entry.js → p-deae85d1.entry.js} +1 -1
- package/dist/twilight/{p-39e19e3e.entry.js → p-e0435187.entry.js} +1 -1
- package/dist/twilight/{p-1c878907.entry.js → p-e07aaa9a.entry.js} +1 -1
- package/dist/twilight/{p-05918c61.entry.js → p-e54ae4d1.entry.js} +1 -1
- package/dist/twilight/{p-9e73b459.entry.js → p-e56faeba.entry.js} +1 -1
- package/dist/twilight/{p-9b6f559e.entry.js → p-e6fad08f.entry.js} +1 -1
- package/dist/twilight/{p-7f30e00b.entry.js → p-e6fcad0c.entry.js} +1 -1
- package/dist/twilight/{p-7618a6df.entry.js → p-ec6496db.entry.js} +1 -1
- package/dist/twilight/{p-93a088e7.entry.js → p-ee9aeeac.entry.js} +1 -1
- package/dist/twilight/{p-b8238390.entry.js → p-ee9de13c.entry.js} +1 -1
- package/dist/twilight/{p-2e5c4855.entry.js → p-f0399559.entry.js} +1 -1
- package/dist/twilight/{p-aff0942e.entry.js → p-f07810d9.entry.js} +1 -1
- package/dist/twilight/{p-99765200.entry.js → p-f0d42626.entry.js} +1 -1
- package/dist/twilight/{p-ee344577.entry.js → p-f1400765.entry.js} +1 -1
- package/dist/twilight/{p-e6d4feeb.entry.js → p-f2d56ad1.entry.js} +1 -1
- package/dist/twilight/{p-4a1d812a.entry.js → p-f3e1b753.entry.js} +1 -1
- package/dist/twilight/{p-1344006a.entry.js → p-f6b30072.entry.js} +1 -1
- package/dist/twilight/{p-99b6d180.entry.js → p-f7886e77.entry.js} +1 -1
- package/dist/twilight/{p-45d6ae74.entry.js → p-f8fb6c94.entry.js} +1 -1
- package/dist/twilight/{p-de273a21.entry.js → p-fb60a276.entry.js} +1 -1
- package/dist/twilight/{p-ea175728.entry.js → p-fdae9cfe.entry.js} +1 -1
- package/dist/twilight/{p-04aa3b60.entry.js → p-fe4ff3bd.entry.js} +1 -1
- package/dist/twilight/{p-DRtbu0JQ.js → p-lTAe1vb6.js} +1 -1
- package/dist/twilight/{p-Y0yMZUbe.js → p-lxIDn6jP.js} +2 -2
- package/dist/twilight/twilight.esm.js +1 -1
- package/package.json +5 -5
- package/dist/twilight/p-ea31904b.entry.js +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as t,h as e,H as r}from"./p-C9GauqTa.js";import{g as i,a as o,c as a,u as d,r as s,m as l,b as n,f as c,d as p,e as h,h as m,i as g}from"./p-C8xwacGT.js";import"./p-CoQJOPRz.js";const w=class{constructor(e){t(this,e),this.loading=!0,this.saveLoading=!1,this.payload={items:{update:[],remove:[],add:[]}},this.expired=!1,this.editPreview=null,this.productSearchQuery="",this.productsListKey=0,this.productsListSource="latest",this.productsListSourceValue="",this.selectedProductToAdd=null,this.addProductQuantity=1,this.addProductLoading=!1,this.addProductConfirmLoading=!1,this.mobileProductsModalMounted=!1,this.isMobileViewport=!1,this.isRTL=!0,this.mobileProductsListLoading=!1,this.confirming=!1,this.handleMobileProductSelected=t=>{t.stopPropagation(),this.handleProductSelected(t)},this.productsPanelMobileQuery="(max-width: 768px)",this.handleProductsPanelViewportChange=t=>{this.isMobileViewport=t.matches},this.hasProductTypeFilter=t=>{const e=t.indexOf("?"),r=(e>=0?t.slice(e+1):t).split("#")[0];return Array.from(new URLSearchParams(r)).some((([t,e])=>"product"===e&&/^filters\[types\](?:\[(?:\d*)\])?$/.test(t)))},this.hasExcludedCategoriesFilter=t=>{const e=t.indexOf("?"),r=(e>=0?t.slice(e+1):t).split("#")[0];return Array.from(new URLSearchParams(r)).some((([t])=>/^filters(?:\[|%5B)excluded_categories(?:\]|%5D)(?:\[|%5B)(?:\d*)(?:\]|%5D)$/.test(t)))},this.normalizeProductsListArrayParams=t=>t.replace(/(^|[?&])(includes|source_value|filters(?:\[|%5B)[^&=\]%]+?(?:\]|%5D))(\[|%5B)\d+(\]|%5D)(?==)/gi,((t,e,r,i,o)=>`${e}${r}${i}${o}`)),this.handleBeforeBuildListUrl=t=>{if("salla-order-edit-product-card"!==t.component?.productCardComponent||"string"!=typeof t.url)return;t.url=this.normalizeProductsListArrayParams(t.url),this.hasProductTypeFilter(t.url)||(t.url+=(t.url.includes("?")?"&":"?")+"filters[types][]=product");const e=this.getParsedExcludedCategories();if(e.length>0&&!this.hasExcludedCategoriesFilter(t.url)){const r=e.map((t=>`filters[excluded_categories][]=${encodeURIComponent(t)}`)).join("&");t.url+=`${t.url.includes("?")?"&":"?"}${r}`}},this.defaultProductsListSource="latest",this.debouncedProductSearch=salla.helpers.debounce((t=>this.applyProductSearch(t)),500),salla.onReady((()=>{this.isRTL=salla.config.get("theme.is_rtl",!0)}))}getParsedExcludedCategories(){if(!this.excludedCategories)return[];try{const t="string"==typeof this.excludedCategories?JSON.parse(this.excludedCategories):this.excludedCategories;return Array.isArray(t)?t.filter((t=>Number.isInteger(t)&&t>0)):[]}catch{return[]}}async componentWillLoad(){this.setupProductsPanelViewportQuery(),await salla.onReady(),this.unregisterBeforeBuildListUrlHook=salla.hooks.registerHook("salla-products-list","beforeBuildListUrl",this.handleBeforeBuildListUrl),this.loadFromProp(),this.startExpiryCheck()}disconnectedCallback(){clearInterval(this.expiryInterval),this.unregisterBeforeBuildListUrlHook?.(),this.productsPanelViewportQuery?.removeEventListener("change",this.handleProductsPanelViewportChange),this.mobileProductsModal?.removeEventListener("orderEditProductSelected",this.handleMobileProductSelected)}setupProductsPanelViewportQuery(){"undefined"!=typeof window&&"function"==typeof window.matchMedia&&(this.productsPanelViewportQuery=window.matchMedia(this.productsPanelMobileQuery),this.isMobileViewport=this.productsPanelViewportQuery.matches,this.productsPanelViewportQuery.addEventListener("change",this.handleProductsPanelViewportChange))}startExpiryCheck(){const t=this.order?.customer_editing_session?.ends_at;if(!t)return;const e=()=>new Date(`${t.replace(" ","T")}+03:00`).getTime()<=Date.now();e()?this.expired=!0:this.expiryInterval=setInterval((()=>{e()&&(this.expired=!0,clearInterval(this.expiryInterval))}),1e3)}loadFromProp(){try{if(!this.orderData)return void(this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود"));const t="string"==typeof this.orderData?JSON.parse(this.orderData):this.orderData;this.order={...t,items:t.items.map((t=>({...t,selectedOptions:i(t)})))}}catch(t){this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود")}finally{this.loading=!1}}applyProductSearch(t){const e=t?.trim()||"",r=e?"search":this.defaultProductsListSource,i="search"===r?JSON.stringify(e):"";this.productsListSource===r&&this.productsListSourceValue===i||(this.productsListSource=r,this.productsListSourceValue=i,this.productsListKey+=1)}handleProductSearch(t){const e=t.target?.value||"";this.productSearchQuery=e,this.debouncedProductSearch(e)}getProductsListKey(t){return`${t}-${this.productsListSource}-${this.productsListSourceValue}-${this.productsListKey}`}handleMobileProductsScroll(t){const e=t.currentTarget;if(e.scrollHeight-e.scrollTop-e.clientHeight>200||this.mobileProductsListLoading)return;const r=e.querySelector("salla-products-list");r&&(this.mobileProductsListLoading=!0,r.loadMore().finally((()=>{this.mobileProductsListLoading=!1})))}waitForNextFrame(){return new Promise((t=>requestAnimationFrame((()=>t(void 0)))))}async openMobileProductsModal(){this.mobileProductsModalMounted||(this.mobileProductsModalMounted=!0,await this.waitForNextFrame()),await(this.mobileProductsModal?.open?.())}setMobileProductsModal(t){this.mobileProductsModal!==t&&(this.mobileProductsModal?.removeEventListener("orderEditProductSelected",this.handleMobileProductSelected),this.mobileProductsModal=t,this.mobileProductsModal?.addEventListener("orderEditProductSelected",this.handleMobileProductSelected))}resetAddProductDrawer(){this.selectedProductToAdd=null,this.addProductQuantity=1,this.addProductLoading=!1,this.addProductConfirmLoading=!1,this.addProductOptions=null}getAddProductMaxQuantity(t=this.selectedProductToAdd){return o(t)}clampAddProductQuantity(t,e=this.selectedProductToAdd){return a(t,this.getAddProductMaxQuantity(e))}getApiErrorMessage(t){return t?.response?.data?.error?.message||t?.response?.data?.message}notifyApiError(t){const e=this.getApiErrorMessage(t);e&&salla.notify.error(e)}async validateAddProductOptions(){return!this.selectedProductToAdd?.options?.length||!!this.addProductOptions&&(await(this.addProductOptions.validateAndScroll?.())??await(this.addProductOptions.reportValidity?.())??!1)}updateLocalOrderItem(t,e,r,i){this.order={...this.order,items:d(this.order.items,t,e,r,i)}}removeLocalOrderItem(t){this.order={...this.order,items:s(this.order.items,t)}}setPayloadItems(t){this.payload={...this.payload,items:l(this.payload.items,t)}}handleAddProductQuantityChange(t){const e=t.detail,r=e?.quantity??parseInt(t.target?.value,10);isNaN(r)||r<1||(this.addProductQuantity=this.clampAddProductQuantity(r))}async handleProductSelected(t){const e=t.detail?.product;if(e?.id&&!this.addProductLoading){this.addProductLoading=!0;try{this.selectedProductToAdd=n(e),this.addProductQuantity=1,await(this.mobileProductsModal?.close?.()),await this.waitForNextFrame(),await(this.addProductDrawer?.open?.())}catch(t){this.notifyApiError(t)}finally{this.addProductLoading=!1}}}async confirmAddProduct(){if(this.selectedProductToAdd?.id&&!this.addProductConfirmLoading){this.addProductConfirmLoading=!0;try{const t=this.getAddProductMaxQuantity(),e=this.clampAddProductQuantity(this.addProductQuantity);e!==this.addProductQuantity&&(this.addProductQuantity=e);const r=this.addProductOptions;if(!await this.validateAddProductOptions())return void salla.notify.error(salla.lang.getWithDefault("common.messages.required_fields","يرجى تعبئة الحقول المطلوبة"));const i=await(r?.getSelectedOptionsData?.())||{},o=await(r?.getOptionsData?.())||this.selectedProductToAdd.options||[],d=c(this.order?.items,this.selectedProductToAdd.id,i);if(d){const r=a(d.quantity+e,t);return this.updateLocalOrderItem(d.id,r,o,i),this.setPayloadItems(d.isNew?{add:p(this.payload.items.add,d.id,r,i)}:{update:h(this.payload.items.update,d.id,r,i)}),void await(this.addProductDrawer?.close?.())}const s=m(this.selectedProductToAdd,e,o,i),l={itemId:s.id,product_id:this.selectedProductToAdd.id,quantity:e,options:i};this.order={...this.order,items:[...this.order.items,s]},this.setPayloadItems({add:[...this.payload.items.add,l]}),await(this.addProductDrawer?.close?.())}catch(t){this.notifyApiError(t)}finally{this.addProductConfirmLoading=!1}}}handleItemUpdated(t){if(!this.order)return;const{itemId:e,quantity:r,options:i,optionDefinitions:d}=t.detail,s=this.order.items.find((t=>t.id===e));if(!s)return;const l=a(r,o(s.product));if(s.isNew)return this.setPayloadItems({add:p(this.payload.items.add,e,l,i)}),void this.updateLocalOrderItem(e,l,d,i);this.setPayloadItems({update:h(this.payload.items.update,e,l,i??{})}),this.updateLocalOrderItem(e,l,d,i)}handleItemRemoved(t){if(!this.order)return;if(this.order.items.length<=1)return void salla.notify.error(salla.lang.getWithDefault("pages.orders.order_cannot_be_empty","لا يمكن إزالة جميع المنتجات من الطلب"));const{itemId:e}=t.detail,r=this.order.items.find((t=>t.id===e));if(r){if(r.isNew)return this.setPayloadItems({add:this.payload.items.add.filter((t=>t.itemId!==e))}),void this.removeLocalOrderItem(e);this.setPayloadItems({update:this.payload.items.update.filter((t=>t.id!==e)),remove:[...this.payload.items.remove,e]}),this.removeLocalOrderItem(e)}}get hasChanges(){return this.payload.items.update.length>0||this.payload.items.remove.length>0||this.payload.items.add.length>0}async saveOrder(){if(this.hasChanges){this.saveLoading=!0;try{const t=await salla.order.api.editOrder(this.orderId,g(this.payload));this.editPreview=t?.data?.data||t?.data,await(this.saveModal?.open?.())}catch(t){this.notifyApiError(t)}finally{this.saveLoading=!1}}}navigateToOrder(){const t=new URL(window.location.href);t.pathname=t.pathname.replace(/\/edit\/?$/,""),t.search="",window.location.href=t.href}handleConfirm(){this.confirming=!0,this.editPreview?.payment?.required&&this.editPreview.payment.payment_url?window.location.href=this.editPreview.payment.payment_url:this.navigateToOrder()}returnToOrderDetails(){this.confirming=!0,this.navigateToOrder()}getConfirmButtonIconClass(){return this.isRTL?"sicon-keyboard_arrow_left":"sicon-keyboard_arrow_right"}async cancelEditSession(){try{await salla.order.api.cancelEditSession(this.orderId),this.navigateToOrder()}catch(t){this.notifyApiError(t)}}renderProductsPanel(){const t=salla.lang.getWithDefault("pages.orders.add_product_to_order","أضف منتج للطلب");return e("section",{class:"s-order-edit-products-panel"},e("div",{class:"s-order-edit-products-header"},e("h2",{class:"s-order-edit-products-title"},t)),this.renderProductsPickerContent("panel"))}renderProductsPickerContent(t){return e("div",{class:{"s-order-edit-products-picker":!0,"s-order-edit-products-modal-content":"modal"===t}},e("label",{class:"s-order-edit-products-search"},e("i",{class:"sicon-search"}),e("input",{type:"search",class:"s-order-edit-products-search-input",placeholder:salla.lang.getWithDefault("pages.products.search_for_product","ابحث عن منتج"),value:this.productSearchQuery,onInput:t=>this.handleProductSearch(t)})),e("div",{class:"s-order-edit-products-list",onScroll:"modal"===t?t=>this.handleMobileProductsScroll(t):void 0},e("salla-products-list",{key:this.getProductsListKey(t),includes:["options"],source:this.productsListSource,"source-value":this.productsListSourceValue,autoload:!0,"product-card-component":"salla-order-edit-product-card"})))}renderMobileProductsModal(){return e("salla-modal",{ref:t=>this.setMobileProductsModal(t),width:"md",class:"s-order-edit-mobile-products-modal","modal-title":salla.lang.getWithDefault("pages.orders.add_product_to_order","أضف منتج للطلب"),onModalVisibilityChanged:t=>{t.detail||(this.mobileProductsModalMounted=!1)}},this.mobileProductsModalMounted?this.renderProductsPickerContent("modal"):null)}renderAddProductDrawer(){const t=this.selectedProductToAdd,r=t?.name||salla.lang.getWithDefault("common.elements.product","منتج"),i=t?.price,o=this.getAddProductMaxQuantity(t),a=t?`order-edit-add-${t.id}`:"order-edit-add",d={value:this.clampAddProductQuantity(this.addProductQuantity,t)};return o&&(d.max=o),e("salla-modal",{ref:t=>this.addProductDrawer=t,width:"md","modal-title":salla.lang.getWithDefault("pages.orders.add_product_to_order","أضف منتج للطلب"),onModalVisibilityChanged:t=>{t.detail||this.resetAddProductDrawer()}},e("div",{class:"s-order-edit-add-modal"},this.addProductLoading?e("div",{class:"s-order-edit-add-modal-loading"},e("salla-loading",null)):t?e("div",{class:"s-order-edit-add-modal-content"},e("div",{class:"s-order-edit-add-modal-header"},e("div",{class:"s-order-edit-add-modal-media"},t.image?.url&&e("img",{src:t.image.url,alt:t.image.alt||r,class:"s-order-edit-add-modal-image"}),e("div",{class:"s-order-edit-add-modal-details"},e("h3",{class:"s-order-edit-add-modal-name"},r),null!=i&&e("span",{class:"s-order-edit-add-modal-price",innerHTML:salla.money(i)})))),e("div",{class:"s-order-edit-add-modal-quantity"},e("h3",{class:"s-order-edit-add-modal-section-title"},salla.lang.getWithDefault("common.elements.quantity","الكمية")),e("div",{class:"s-order-edit-add-modal-quantity-input"},e("salla-quantity-input",{...d,onChange:t=>this.handleAddProductQuantityChange(t)}))),t.options?.length>0&&e("form",{onSubmit:t=>t.preventDefault()},e("salla-product-options",{ref:t=>this.addProductOptions=t,"product-id":t.id,"unique-key":a,options:JSON.stringify(t.options),key:`${a}-options`})),e("div",{class:"s-order-edit-add-modal-actions"},e("salla-button",{onClick:()=>this.confirmAddProduct(),loading:this.addProductConfirmLoading},salla.lang.getWithDefault("common.elements.confirm","تأكيد")),e("salla-button",{color:"gray",fill:"outline",onClick:()=>this.addProductDrawer?.close?.()},salla.lang.getWithDefault("common.elements.cancel","الغاء")))):null))}renderSaveModal(){const t=this.editPreview,r=t?.totals?.remaining_amount?.amount>0,i=t?.totals?.refund_amount?.amount>0,o=t?.totals?.tax?.amount?.amount;return e("salla-modal",{ref:t=>this.saveModal=t,width:"md",isClosable:!1,onModalVisibilityChanged:async t=>{t.detail||(this.editPreview=null,this.confirming||await this.cancelEditSession(),this.confirming=!1)}},e("div",{class:"s-order-edit-modal"},e("h2",{class:"s-order-edit-modal-title"},salla.lang.getWithDefault("pages.orders.edit_summary_title","ملخص الطلب بعد التعديل")),e("p",{class:"s-order-edit-modal-subtitle"},salla.lang.getWithDefault("pages.orders.cart_edits_saved","Your cart edits have been saved")),t?.items?.length>0&&e("div",{class:"s-order-edit-modal-items"},t.items.map((t=>{const r=this.order?.items?.find((e=>e.id==t.id)),i=r?.product?.image?.url,o=t.options?.join("/ ");return e("div",{class:"s-order-edit-modal-item"},e("div",{class:"s-order-edit-modal-item-start"},i&&e("img",{src:i,alt:t.name,class:"s-order-edit-modal-item-image"}),e("div",null,e("p",{class:"s-order-edit-modal-item-name"},t.name),o&&e("span",{class:"s-order-edit-modal-item-options"},o))),e("div",{class:"s-order-edit-modal-item-end"},e("span",{class:"s-order-edit-modal-item-quantity",dir:"ltr",innerHTML:t.quantity+" x "+t.price.amount}),e("span",{class:"s-order-edit-modal-item-price",innerHTML:salla.money(t.price.amount*t.quantity)})))}))),t?.totals?.updated_products_total&&e("div",{class:"s-order-edit-modal-row"},e("span",{class:"s-order-edit-modal-row-label"},salla.lang.getWithDefault("pages.orders.modified_products_total","مجموع المنتجات المعدلة")),e("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(t.totals.updated_products_total.amount)})),o>0&&e("div",{class:"s-order-edit-modal-row"},e("span",{class:"s-order-edit-modal-tax-label"},e("i",{class:"sicon-info-circle s-order-edit-modal-tax-icon"}),salla.lang.getWithDefault("pages.orders.vat","ضريبة القيمة المضافة")),e("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(o)})),t?.totals?.total&&e("div",{class:"s-order-edit-modal-total"},e("span",{class:"s-order-edit-modal-total-label"},salla.lang.getWithDefault("pages.orders.order_total","اجمالي الطلب")),e("span",{class:"s-order-edit-modal-total-value",innerHTML:salla.money(t.totals.total.amount)})),i&&e("div",{class:"s-order-edit-modal-refund"},e("i",{class:"sicon-info-circle s-order-edit-modal-refund-icon"}),e("p",{class:"s-order-edit-modal-refund-text"},salla.lang.getWithDefault("pages.orders.refund_message","سيتم تحويل فارق المبلغ على نفس وسيلة الدفع"))),e("div",{class:"s-order-edit-modal-btn-wrapper"},e("salla-button",{onClick:()=>this.handleConfirm()},r?salla.lang.getWithDefault("pages.orders.pay_difference","دفع فارق المبلغ"):i?salla.lang.getWithDefault("pages.orders.confirm_and_receive_difference","تأكيد واستلام فارق المبلغ"):salla.lang.getWithDefault("pages.orders.confirm_changes","تأكيد التعديلات"),e("i",{class:`${this.getConfirmButtonIconClass()} s-order-edit-modal-btn-icon`})),e("salla-button",{color:"gray",fill:"outline",onClick:()=>this.returnToOrderDetails()},salla.lang.getWithDefault("pages.orders.back_to_order_details","العودة إلى تفاصيل الطلب")))))}render(){if(this.loading)return e(r,null,e("salla-loading",null));if(this.expired)return e(r,null,e("div",{class:"s-order-edit-expired"},e("p",null,salla.lang.getWithDefault("pages.orders.edit_session_expired","انتهت مدة التعديل المتاحة")),e("salla-button",{onClick:()=>this.navigateToOrder()},salla.lang.getWithDefault("pages.orders.back_to_order","العودة إلى تفاصيل الطلب"))));if(this.error||!this.order)return e(r,null,e("div",{class:"s-order-edit-no-content-placeholder"},e("i",{class:"sicon-shopping-bag icon"}),e("p",null,this.error)));const t=this.order.items&&this.order.items.length>0,i=this.order.customer_editing_session?.ends_at;return e(r,null,i&&e("div",{class:"s-order-edit-timer-wrapper"},e("salla-count-down",{prefixText:salla.lang.getWithDefault("pages.orders.edit_within","يمكنك التعديل خلال"),date:i,horizontal:!0,withButton:!0,autoSegments:!0,labeled:!1,size:"sm",color:"primary"})),e("div",{class:"s-order-edit-layout"},this.isMobileViewport?null:this.renderProductsPanel(),e("section",{class:"s-order-edit-order-panel"},e("div",{class:"s-order-edit-items-wrapper"},e("h2",{class:"s-order-edit-items-title"},salla.lang.getWithDefault("pages.orders.order_products","منتجات الطلب")),t?this.order.items.map(((t,r)=>[e("salla-order-edit-item",{key:t.id,item:t,orderId:this.orderId}),r<this.order.items.length-1?e("div",{class:"s-order-edit-items-divider"}):null])):e("div",{class:"s-order-edit-no-content-placeholder"},e("i",{class:"sicon-shopping-bag icon"}),e("p",null,salla.lang.getWithDefault("common.elements.no_items","لا توجد عناصر")))),e("div",{class:"s-order-edit-actions"},e("salla-button",{class:"s-order-edit-mobile-products-trigger",color:"gray",size:"small",fill:"outline",onClick:()=>this.openMobileProductsModal()},e("i",{class:"sicon-add s-order-edit-mobile-products-trigger-icon"}),salla.lang.getWithDefault("pages.orders.add_product","إضافة منتج")),e("salla-button",{onClick:()=>this.saveOrder(),loading:this.saveLoading,size:"small",disabled:!this.hasChanges},salla.lang.getWithDefault("pages.orders.save_changes","حفظ التعديلات")),e("salla-button",{size:"small",color:"gray",fill:"outline",onClick:()=>this.cancelEditSession()},salla.lang.getWithDefault("common.elements.cancel","الغاء"))))),this.renderMobileProductsModal(),this.renderAddProductDrawer(),this.renderSaveModal())}};w.style='/*!twlt*/:host{display:block}.outline{outline-style:solid}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.s-order-edit-timer-wrapper{margin-bottom:1rem;display:flex;justify-content:center}.s-order-edit-layout{display:grid;align-items:flex-start;gap:1.5rem;grid-template-columns:minmax(0,1.35fr) minmax(20rem,1fr)}@media (max-width: 1080px){.s-order-edit-layout{grid-template-columns:minmax(0, 1fr)}}.s-order-edit-products-panel{border-radius:1rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1.5rem}@media (max-width: 768px){.s-order-edit-products-panel{display:none}}.s-order-edit-order-panel{display:flex;flex-direction:column;gap:1.5rem;border-radius:1rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1.5rem}.s-order-edit-products-header{margin-bottom:1rem}.s-order-edit-products-title{margin:0px;font-size:1.125rem;line-height:1.75rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-items-wrapper{display:flex;flex-direction:column;gap:1.25rem}.s-order-edit-items-title{margin:0px;font-size:1.125rem;line-height:1.75rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-items-divider{height:1px;width:100%;--tw-bg-opacity:1;background-color:rgb(238 242 247 / var(--tw-bg-opacity, 1))}.s-order-edit-products-picker{display:flex;min-height:0px;flex-direction:column;gap:1rem}.s-order-edit-products-modal-content{display:flex;min-height:0px;flex-direction:column;gap:1rem;padding:1rem}.s-order-edit-products-search{position:relative;margin-bottom:1.25rem;display:block}.s-order-edit-products-search i{pointer-events:none;position:absolute;top:50%;--tw-translate-y:-50%;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));font-size:1rem;line-height:1.5rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-products-search i:where([dir="ltr"],[dir="ltr"] *){left:1rem}.s-order-edit-products-search i:where([dir="rtl"],[dir="rtl"] *){right:1rem}.s-order-edit-products-search-input{min-height:3rem;width:100%;border-radius:0.875rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding-left:1rem;padding-right:1rem;padding-top:0.875rem;padding-bottom:0.875rem;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1));transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:200ms}.s-order-edit-products-search-input:where([dir="ltr"],[dir="ltr"] *){padding-left:2.75rem;padding-right:1rem}.s-order-edit-products-search-input:where([dir="rtl"],[dir="rtl"] *){padding-right:2.75rem;padding-left:1rem}.s-order-edit-products-search-input:focus{--tw-border-opacity:1;border-color:rgb(17 24 39 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));--tw-shadow:0 0 0 3px rgba(17,24,39,0.08);--tw-shadow-colored:0 0 0 3px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}.s-order-edit-products-list{min-height:20rem}.s-order-edit-products-list .s-products-list-wrapper{gap:1rem;grid-template-columns:repeat(2,minmax(0,1fr))}@media (min-width: 769px){.s-order-edit-products-list .s-products-list-wrapper{grid-template-columns:repeat(3, minmax(0, 1fr))}}.s-order-edit-no-content-placeholder{display:flex;min-height:14rem;flex-direction:column;align-items:center;justify-content:center;gap:0.75rem;border-radius:0.875rem;border-width:1px;border-style:dashed;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding:2rem;text-align:center;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-no-content-placeholder .icon{font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-actions{position:sticky;bottom:1.5rem;display:flex;align-items:center;justify-content:space-between;gap:0.75rem;border-radius:0.875rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));background-color:rgba(255,255,255,0.94);padding:1rem;--tw-shadow:0 12px 30px rgba(15,23,42,0.08);--tw-shadow-colored:0 12px 30px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);--tw-backdrop-blur:blur(10px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}@media (max-width: 768px){.s-order-edit-actions{position:static;align-items:center;gap:0.5rem}}.s-order-edit-actions salla-button{flex:0 0 auto}@media (max-width: 768px){.s-order-edit-actions salla-button{display:block;flex:1 1 0;min-width:0}}.s-order-edit-mobile-products-trigger{display:none}@media (max-width: 768px){.s-order-edit-mobile-products-trigger{display:block}}.s-order-edit-mobile-products-trigger-icon:where([dir="ltr"],[dir="ltr"] *){margin-right:0.35rem}.s-order-edit-mobile-products-trigger-icon:where([dir="rtl"],[dir="rtl"] *){margin-left:0.35rem}.s-order-edit-mobile-products-modal .s-order-edit-products-list{max-height:min(24rem, calc(100vh - 11rem));min-height:22rem;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}@media (max-width: 480px){.s-order-edit-mobile-products-modal .s-order-edit-products-list{min-height:20rem;max-height:min(22rem, calc(100vh - 10rem))}}.s-order-edit-mobile-products-modal .products-list .s-products-list-wrapper{gap:0.625rem;grid-template-columns:repeat(2,minmax(0,1fr))}.s-order-edit-modal{display:flex;flex-direction:column;gap:1rem}.s-order-edit-modal-title{margin:0px;text-align:start;font-size:1.125rem;line-height:1.75rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-subtitle{margin:0px;margin-top:-0.75rem;text-align:start;font-size:0.875rem;line-height:1.25rem;line-height:1.5;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-items{display:flex;flex-direction:column;gap:0.75rem}.s-order-edit-modal-item{display:flex;align-items:center;justify-content:space-between;gap:1rem;border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-bottom:0.75rem}.s-order-edit-modal-item-start{display:flex;align-items:center;gap:0.75rem}.s-order-edit-modal-item-image{height:3rem;width:3rem;border-radius:0.75rem;object-fit:cover}.s-order-edit-modal-item-name{margin:0px;font-size:0.875rem;line-height:1.25rem;font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-item-options{font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-item-end{display:flex;align-items:center;gap:0.75rem}.s-order-edit-modal-item-price{font-size:0.875rem;line-height:1.25rem;font-weight:500}.s-order-edit-modal-item-quantity{font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-row{display:flex;align-items:center;justify-content:space-between;gap:1rem}.s-order-edit-modal-row-label{font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-row-value{font-weight:700}.s-order-edit-modal-tax-label{display:flex;align-items:center;gap:0.5rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-tax-icon{--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-modal-total{display:flex;align-items:center;justify-content:space-between;gap:1rem;border-top-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-top:0.75rem;font-weight:700;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-total-label{font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-total-value{font-size:1.25rem;line-height:1.75rem;font-weight:500}.s-order-edit-modal-refund{display:flex;align-items:flex-start;gap:1rem;border-radius:0.875rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));padding-left:1rem;padding-right:1rem;padding-top:0.875rem;padding-bottom:0.875rem;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-order-edit-modal-refund-icon{flex-shrink:0;font-size:1.125rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-refund-text{margin:0px;flex:1 1 0%;font-size:0.875rem;line-height:1.25rem}.s-order-edit-modal-btn-wrapper{margin-top:0.5rem;display:flex;justify-content:space-between}.s-order-edit-modal-btn-wrapper salla-button{width:100%}@media (min-width: 640px){.s-order-edit-modal-btn-wrapper salla-button{width:auto}}.s-order-edit-modal-btn-icon{vertical-align:middle;font-size:1.125rem;line-height:1.75rem}.s-order-edit-expired{display:flex;min-height:14rem;flex-direction:column;align-items:center;justify-content:center;gap:0.75rem;border-radius:0.875rem;border-width:1px;border-style:dashed;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding:2rem;text-align:center;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-expired .icon{font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal{display:flex;min-height:0px;flex:1 1 auto;flex-direction:column;gap:1rem}.s-order-edit-add-modal-content{display:flex;min-height:0px;flex:1 1 auto;flex-direction:column;gap:1rem}.s-order-edit-add-modal-loading{display:flex;min-height:12rem;flex:1 1 auto;align-items:center;justify-content:center}.s-order-edit-add-modal-header{border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-bottom:1rem}.s-order-edit-add-modal-media{display:flex;align-items:flex-start;gap:1rem}.s-order-edit-add-modal-image{height:5.5rem;width:5.5rem;border-radius:0.875rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));object-fit:cover}.s-order-edit-add-modal-details{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.35rem}.s-order-edit-add-modal-name{margin:0px;font-size:1rem;line-height:1.5rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal-price{font-size:0.95rem;font-weight:700;--tw-text-opacity:1;color:rgb(15 118 110 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal-quantity{display:flex;align-items:center;justify-content:space-between;gap:1rem}.s-order-edit-add-modal-section-title{margin:0px;font-size:0.9375rem;font-weight:600;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal-quantity-input{flex-shrink:0}.s-order-edit-add-modal-actions{margin-top:auto;display:flex;align-items:center;justify-content:space-between;gap:0.75rem;border-top-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding-top:1rem}.s-order-edit-add-modal-actions salla-button{min-width:4.75rem;flex:0 0 auto}.s-order-edit-item-header{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem}.s-order-edit-item-media{display:flex;min-width:0px;flex:1 1 0%;gap:1rem}@media (max-width: 640px){.s-order-edit-item-media{width:100%}}.s-order-edit-item-image{height:5.5rem;width:5.5rem;border-radius:0.875rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));object-fit:cover}.s-order-edit-item-details{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.35rem}.s-order-edit-item-name{margin:0px;font-size:1rem;line-height:1.5rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-item-link{color:inherit;text-decoration-line:none}.s-order-edit-item-price{font-size:0.95rem;font-weight:700;--tw-text-opacity:1;color:rgb(15 118 110 / var(--tw-text-opacity, 1))}.s-order-edit-item-weight{margin:0px;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-item-quantity{margin-top:1.25rem;display:flex;align-items:center;justify-content:space-between;gap:1rem;border-top-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-top:1rem}.s-order-edit-item-quantity-label{margin:0px;font-size:0.9375rem;font-weight:600;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-order-edit-item-quantity-input{flex-shrink:0}.s-order-edit-item-options{margin-top:1rem;display:block}.s-order-edit-product-card{display:flex;min-height:100%;width:100%;cursor:pointer;appearance:none;flex-direction:column;overflow:hidden;border-radius:0.875rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));text-align:start;--tw-shadow:0 10px 24px rgba(15,23,42,0.04);--tw-shadow-colored:0 10px 24px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:200ms}.s-order-edit-product-card:hover{--tw-translate-y:-2px;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-shadow:0 16px 30px rgba(15,23,42,0.08);--tw-shadow-colored:0 16px 30px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.s-order-edit-product-card:focus-visible{--tw-border-opacity:1;border-color:rgb(17 24 39 / var(--tw-border-opacity, 1));--tw-shadow:0 0 0 3px rgba(17,24,39,0.12);--tw-shadow-colored:0 0 0 3px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}@media (max-width: 768px){.s-order-edit-product-card{border-radius:0.75rem;box-shadow:0 6px 18px rgba(15, 23, 42, 0.05)}}.s-order-edit-product-card-media{display:flex;aspect-ratio:1 / 1;width:100%;flex-shrink:0;align-items:center;justify-content:center;overflow:hidden;background:linear-gradient(180deg,#f8fafc 0%,#f1f5f9 100%)}.s-order-edit-product-card-image{display:block;height:100%;width:100%;object-fit:cover}.s-order-edit-product-card-placeholder{display:flex;height:100%;width:100%;align-items:center;justify-content:center;font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-product-card-content{display:flex;flex:1 1 0%;flex-direction:column;gap:0.5rem;padding:1rem}@media (max-width: 768px){.s-order-edit-product-card-content{gap:0.25rem;padding:0.625rem}}.s-order-edit-product-card-title{margin:0px;font-size:0.95rem;font-weight:600;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}@media (max-width: 768px){.s-order-edit-product-card-title{display:-webkit-box;overflow:hidden;min-height:2.35rem;font-size:0.8125rem;line-height:1.45;-webkit-box-orient:vertical;-webkit-line-clamp:2}}.s-order-edit-product-card-price{margin:0px;font-size:1rem;line-height:1.5rem;font-weight:700;--tw-text-opacity:1;color:rgb(15 118 110 / var(--tw-text-opacity, 1))}@media (max-width: 768px){.s-order-edit-product-card-price{font-size:0.875rem}.s-order-edit-products-panel,.s-order-edit-order-panel{padding:1rem}.s-order-edit-actions salla-button .s-button-element{width:100%;min-width:0;padding-inline:0.5rem}.s-order-edit-mobile-products-modal .s-order-edit-products-modal-content{gap:0.75rem;padding:0.875rem}.s-order-edit-add-modal-media,.s-order-edit-add-modal-quantity{flex-direction:column;align-items:stretch}}';export{w as salla_order_edit}
|
|
4
|
+
import{r as t,h as e,H as r}from"./p-BNekvDFW.js";import{g as i,a as o,c as a,u as d,r as s,m as l,b as n,f as c,d as p,e as h,h as m,i as g}from"./p-C8xwacGT.js";import"./p-CoQJOPRz.js";const w=class{constructor(e){t(this,e),this.loading=!0,this.saveLoading=!1,this.payload={items:{update:[],remove:[],add:[]}},this.expired=!1,this.editPreview=null,this.productSearchQuery="",this.productsListKey=0,this.productsListSource="latest",this.productsListSourceValue="",this.selectedProductToAdd=null,this.addProductQuantity=1,this.addProductLoading=!1,this.addProductConfirmLoading=!1,this.mobileProductsModalMounted=!1,this.isMobileViewport=!1,this.isRTL=!0,this.mobileProductsListLoading=!1,this.confirming=!1,this.handleMobileProductSelected=t=>{t.stopPropagation(),this.handleProductSelected(t)},this.productsPanelMobileQuery="(max-width: 768px)",this.handleProductsPanelViewportChange=t=>{this.isMobileViewport=t.matches},this.hasProductTypeFilter=t=>{const e=t.indexOf("?"),r=(e>=0?t.slice(e+1):t).split("#")[0];return Array.from(new URLSearchParams(r)).some((([t,e])=>"product"===e&&/^filters\[types\](?:\[(?:\d*)\])?$/.test(t)))},this.hasExcludedCategoriesFilter=t=>{const e=t.indexOf("?"),r=(e>=0?t.slice(e+1):t).split("#")[0];return Array.from(new URLSearchParams(r)).some((([t])=>/^filters(?:\[|%5B)excluded_categories(?:\]|%5D)(?:\[|%5B)(?:\d*)(?:\]|%5D)$/.test(t)))},this.normalizeProductsListArrayParams=t=>t.replace(/(^|[?&])(includes|source_value|filters(?:\[|%5B)[^&=\]%]+?(?:\]|%5D))(\[|%5B)\d+(\]|%5D)(?==)/gi,((t,e,r,i,o)=>`${e}${r}${i}${o}`)),this.handleBeforeBuildListUrl=t=>{if("salla-order-edit-product-card"!==t.component?.productCardComponent||"string"!=typeof t.url)return;t.url=this.normalizeProductsListArrayParams(t.url),this.hasProductTypeFilter(t.url)||(t.url+=(t.url.includes("?")?"&":"?")+"filters[types][]=product");const e=this.getParsedExcludedCategories();if(e.length>0&&!this.hasExcludedCategoriesFilter(t.url)){const r=e.map((t=>`filters[excluded_categories][]=${encodeURIComponent(t)}`)).join("&");t.url+=`${t.url.includes("?")?"&":"?"}${r}`}},this.defaultProductsListSource="latest",this.debouncedProductSearch=salla.helpers.debounce((t=>this.applyProductSearch(t)),500),salla.onReady((()=>{this.isRTL=salla.config.get("theme.is_rtl",!0)}))}getParsedExcludedCategories(){if(!this.excludedCategories)return[];try{const t="string"==typeof this.excludedCategories?JSON.parse(this.excludedCategories):this.excludedCategories;return Array.isArray(t)?t.filter((t=>Number.isInteger(t)&&t>0)):[]}catch{return[]}}async componentWillLoad(){this.setupProductsPanelViewportQuery(),await salla.onReady(),this.unregisterBeforeBuildListUrlHook=salla.hooks.registerHook("salla-products-list","beforeBuildListUrl",this.handleBeforeBuildListUrl),this.loadFromProp(),this.startExpiryCheck()}disconnectedCallback(){clearInterval(this.expiryInterval),this.unregisterBeforeBuildListUrlHook?.(),this.productsPanelViewportQuery?.removeEventListener("change",this.handleProductsPanelViewportChange),this.mobileProductsModal?.removeEventListener("orderEditProductSelected",this.handleMobileProductSelected)}setupProductsPanelViewportQuery(){"undefined"!=typeof window&&"function"==typeof window.matchMedia&&(this.productsPanelViewportQuery=window.matchMedia(this.productsPanelMobileQuery),this.isMobileViewport=this.productsPanelViewportQuery.matches,this.productsPanelViewportQuery.addEventListener("change",this.handleProductsPanelViewportChange))}startExpiryCheck(){const t=this.order?.customer_editing_session?.ends_at;if(!t)return;const e=()=>new Date(`${t.replace(" ","T")}+03:00`).getTime()<=Date.now();e()?this.expired=!0:this.expiryInterval=setInterval((()=>{e()&&(this.expired=!0,clearInterval(this.expiryInterval))}),1e3)}loadFromProp(){try{if(!this.orderData)return void(this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود"));const t="string"==typeof this.orderData?JSON.parse(this.orderData):this.orderData;this.order={...t,items:t.items.map((t=>({...t,selectedOptions:i(t)})))}}catch(t){this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود")}finally{this.loading=!1}}applyProductSearch(t){const e=t?.trim()||"",r=e?"search":this.defaultProductsListSource,i="search"===r?JSON.stringify(e):"";this.productsListSource===r&&this.productsListSourceValue===i||(this.productsListSource=r,this.productsListSourceValue=i,this.productsListKey+=1)}handleProductSearch(t){const e=t.target?.value||"";this.productSearchQuery=e,this.debouncedProductSearch(e)}getProductsListKey(t){return`${t}-${this.productsListSource}-${this.productsListSourceValue}-${this.productsListKey}`}handleMobileProductsScroll(t){const e=t.currentTarget;if(e.scrollHeight-e.scrollTop-e.clientHeight>200||this.mobileProductsListLoading)return;const r=e.querySelector("salla-products-list");r&&(this.mobileProductsListLoading=!0,r.loadMore().finally((()=>{this.mobileProductsListLoading=!1})))}waitForNextFrame(){return new Promise((t=>requestAnimationFrame((()=>t(void 0)))))}async openMobileProductsModal(){this.mobileProductsModalMounted||(this.mobileProductsModalMounted=!0,await this.waitForNextFrame()),await(this.mobileProductsModal?.open?.())}setMobileProductsModal(t){this.mobileProductsModal!==t&&(this.mobileProductsModal?.removeEventListener("orderEditProductSelected",this.handleMobileProductSelected),this.mobileProductsModal=t,this.mobileProductsModal?.addEventListener("orderEditProductSelected",this.handleMobileProductSelected))}resetAddProductDrawer(){this.selectedProductToAdd=null,this.addProductQuantity=1,this.addProductLoading=!1,this.addProductConfirmLoading=!1,this.addProductOptions=null}getAddProductMaxQuantity(t=this.selectedProductToAdd){return o(t)}clampAddProductQuantity(t,e=this.selectedProductToAdd){return a(t,this.getAddProductMaxQuantity(e))}getApiErrorMessage(t){return t?.response?.data?.error?.message||t?.response?.data?.message}notifyApiError(t){const e=this.getApiErrorMessage(t);e&&salla.notify.error(e)}async validateAddProductOptions(){return!this.selectedProductToAdd?.options?.length||!!this.addProductOptions&&(await(this.addProductOptions.validateAndScroll?.())??await(this.addProductOptions.reportValidity?.())??!1)}updateLocalOrderItem(t,e,r,i){this.order={...this.order,items:d(this.order.items,t,e,r,i)}}removeLocalOrderItem(t){this.order={...this.order,items:s(this.order.items,t)}}setPayloadItems(t){this.payload={...this.payload,items:l(this.payload.items,t)}}handleAddProductQuantityChange(t){const e=t.detail,r=e?.quantity??parseInt(t.target?.value,10);isNaN(r)||r<1||(this.addProductQuantity=this.clampAddProductQuantity(r))}async handleProductSelected(t){const e=t.detail?.product;if(e?.id&&!this.addProductLoading){this.addProductLoading=!0;try{this.selectedProductToAdd=n(e),this.addProductQuantity=1,await(this.mobileProductsModal?.close?.()),await this.waitForNextFrame(),await(this.addProductDrawer?.open?.())}catch(t){this.notifyApiError(t)}finally{this.addProductLoading=!1}}}async confirmAddProduct(){if(this.selectedProductToAdd?.id&&!this.addProductConfirmLoading){this.addProductConfirmLoading=!0;try{const t=this.getAddProductMaxQuantity(),e=this.clampAddProductQuantity(this.addProductQuantity);e!==this.addProductQuantity&&(this.addProductQuantity=e);const r=this.addProductOptions;if(!await this.validateAddProductOptions())return void salla.notify.error(salla.lang.getWithDefault("common.messages.required_fields","يرجى تعبئة الحقول المطلوبة"));const i=await(r?.getSelectedOptionsData?.())||{},o=await(r?.getOptionsData?.())||this.selectedProductToAdd.options||[],d=c(this.order?.items,this.selectedProductToAdd.id,i);if(d){const r=a(d.quantity+e,t);return this.updateLocalOrderItem(d.id,r,o,i),this.setPayloadItems(d.isNew?{add:p(this.payload.items.add,d.id,r,i)}:{update:h(this.payload.items.update,d.id,r,i)}),void await(this.addProductDrawer?.close?.())}const s=m(this.selectedProductToAdd,e,o,i),l={itemId:s.id,product_id:this.selectedProductToAdd.id,quantity:e,options:i};this.order={...this.order,items:[...this.order.items,s]},this.setPayloadItems({add:[...this.payload.items.add,l]}),await(this.addProductDrawer?.close?.())}catch(t){this.notifyApiError(t)}finally{this.addProductConfirmLoading=!1}}}handleItemUpdated(t){if(!this.order)return;const{itemId:e,quantity:r,options:i,optionDefinitions:d}=t.detail,s=this.order.items.find((t=>t.id===e));if(!s)return;const l=a(r,o(s.product));if(s.isNew)return this.setPayloadItems({add:p(this.payload.items.add,e,l,i)}),void this.updateLocalOrderItem(e,l,d,i);this.setPayloadItems({update:h(this.payload.items.update,e,l,i??{})}),this.updateLocalOrderItem(e,l,d,i)}handleItemRemoved(t){if(!this.order)return;if(this.order.items.length<=1)return void salla.notify.error(salla.lang.getWithDefault("pages.orders.order_cannot_be_empty","لا يمكن إزالة جميع المنتجات من الطلب"));const{itemId:e}=t.detail,r=this.order.items.find((t=>t.id===e));if(r){if(r.isNew)return this.setPayloadItems({add:this.payload.items.add.filter((t=>t.itemId!==e))}),void this.removeLocalOrderItem(e);this.setPayloadItems({update:this.payload.items.update.filter((t=>t.id!==e)),remove:[...this.payload.items.remove,e]}),this.removeLocalOrderItem(e)}}get hasChanges(){return this.payload.items.update.length>0||this.payload.items.remove.length>0||this.payload.items.add.length>0}async saveOrder(){if(this.hasChanges){this.saveLoading=!0;try{const t=await salla.order.api.editOrder(this.orderId,g(this.payload));this.editPreview=t?.data?.data||t?.data,await(this.saveModal?.open?.())}catch(t){this.notifyApiError(t)}finally{this.saveLoading=!1}}}navigateToOrder(){const t=new URL(window.location.href);t.pathname=t.pathname.replace(/\/edit\/?$/,""),t.search="",window.location.href=t.href}handleConfirm(){this.confirming=!0,this.editPreview?.payment?.required&&this.editPreview.payment.payment_url?window.location.href=this.editPreview.payment.payment_url:this.navigateToOrder()}returnToOrderDetails(){this.confirming=!0,this.navigateToOrder()}getConfirmButtonIconClass(){return this.isRTL?"sicon-keyboard_arrow_left":"sicon-keyboard_arrow_right"}async cancelEditSession(){try{await salla.order.api.cancelEditSession(this.orderId),this.navigateToOrder()}catch(t){this.notifyApiError(t)}}renderProductsPanel(){const t=salla.lang.getWithDefault("pages.orders.add_product_to_order","أضف منتج للطلب");return e("section",{class:"s-order-edit-products-panel"},e("div",{class:"s-order-edit-products-header"},e("h2",{class:"s-order-edit-products-title"},t)),this.renderProductsPickerContent("panel"))}renderProductsPickerContent(t){return e("div",{class:{"s-order-edit-products-picker":!0,"s-order-edit-products-modal-content":"modal"===t}},e("label",{class:"s-order-edit-products-search"},e("i",{class:"sicon-search"}),e("input",{type:"search",class:"s-order-edit-products-search-input",placeholder:salla.lang.getWithDefault("pages.products.search_for_product","ابحث عن منتج"),value:this.productSearchQuery,onInput:t=>this.handleProductSearch(t)})),e("div",{class:"s-order-edit-products-list",onScroll:"modal"===t?t=>this.handleMobileProductsScroll(t):void 0},e("salla-products-list",{key:this.getProductsListKey(t),includes:["options"],source:this.productsListSource,"source-value":this.productsListSourceValue,autoload:!0,"product-card-component":"salla-order-edit-product-card"})))}renderMobileProductsModal(){return e("salla-modal",{ref:t=>this.setMobileProductsModal(t),width:"md",class:"s-order-edit-mobile-products-modal","modal-title":salla.lang.getWithDefault("pages.orders.add_product_to_order","أضف منتج للطلب"),onModalVisibilityChanged:t=>{t.detail||(this.mobileProductsModalMounted=!1)}},this.mobileProductsModalMounted?this.renderProductsPickerContent("modal"):null)}renderAddProductDrawer(){const t=this.selectedProductToAdd,r=t?.name||salla.lang.getWithDefault("common.elements.product","منتج"),i=t?.price,o=this.getAddProductMaxQuantity(t),a=t?`order-edit-add-${t.id}`:"order-edit-add",d={value:this.clampAddProductQuantity(this.addProductQuantity,t)};return o&&(d.max=o),e("salla-modal",{ref:t=>this.addProductDrawer=t,width:"md","modal-title":salla.lang.getWithDefault("pages.orders.add_product_to_order","أضف منتج للطلب"),onModalVisibilityChanged:t=>{t.detail||this.resetAddProductDrawer()}},e("div",{class:"s-order-edit-add-modal"},this.addProductLoading?e("div",{class:"s-order-edit-add-modal-loading"},e("salla-loading",null)):t?e("div",{class:"s-order-edit-add-modal-content"},e("div",{class:"s-order-edit-add-modal-header"},e("div",{class:"s-order-edit-add-modal-media"},t.image?.url&&e("img",{src:t.image.url,alt:t.image.alt||r,class:"s-order-edit-add-modal-image"}),e("div",{class:"s-order-edit-add-modal-details"},e("h3",{class:"s-order-edit-add-modal-name"},r),null!=i&&e("span",{class:"s-order-edit-add-modal-price",innerHTML:salla.money(i)})))),e("div",{class:"s-order-edit-add-modal-quantity"},e("h3",{class:"s-order-edit-add-modal-section-title"},salla.lang.getWithDefault("common.elements.quantity","الكمية")),e("div",{class:"s-order-edit-add-modal-quantity-input"},e("salla-quantity-input",{...d,onChange:t=>this.handleAddProductQuantityChange(t)}))),t.options?.length>0&&e("form",{onSubmit:t=>t.preventDefault()},e("salla-product-options",{ref:t=>this.addProductOptions=t,"product-id":t.id,"unique-key":a,options:JSON.stringify(t.options),key:`${a}-options`})),e("div",{class:"s-order-edit-add-modal-actions"},e("salla-button",{onClick:()=>this.confirmAddProduct(),loading:this.addProductConfirmLoading},salla.lang.getWithDefault("common.elements.confirm","تأكيد")),e("salla-button",{color:"gray",fill:"outline",onClick:()=>this.addProductDrawer?.close?.()},salla.lang.getWithDefault("common.elements.cancel","الغاء")))):null))}renderSaveModal(){const t=this.editPreview,r=t?.totals?.remaining_amount?.amount>0,i=t?.totals?.refund_amount?.amount>0,o=t?.totals?.tax?.amount?.amount;return e("salla-modal",{ref:t=>this.saveModal=t,width:"md",isClosable:!1,onModalVisibilityChanged:async t=>{t.detail||(this.editPreview=null,this.confirming||await this.cancelEditSession(),this.confirming=!1)}},e("div",{class:"s-order-edit-modal"},e("h2",{class:"s-order-edit-modal-title"},salla.lang.getWithDefault("pages.orders.edit_summary_title","ملخص الطلب بعد التعديل")),e("p",{class:"s-order-edit-modal-subtitle"},salla.lang.getWithDefault("pages.orders.cart_edits_saved","Your cart edits have been saved")),t?.items?.length>0&&e("div",{class:"s-order-edit-modal-items"},t.items.map((t=>{const r=this.order?.items?.find((e=>e.id==t.id)),i=r?.product?.image?.url,o=t.options?.join("/ ");return e("div",{class:"s-order-edit-modal-item"},e("div",{class:"s-order-edit-modal-item-start"},i&&e("img",{src:i,alt:t.name,class:"s-order-edit-modal-item-image"}),e("div",null,e("p",{class:"s-order-edit-modal-item-name"},t.name),o&&e("span",{class:"s-order-edit-modal-item-options"},o))),e("div",{class:"s-order-edit-modal-item-end"},e("span",{class:"s-order-edit-modal-item-quantity",dir:"ltr",innerHTML:t.quantity+" x "+t.price.amount}),e("span",{class:"s-order-edit-modal-item-price",innerHTML:salla.money(t.price.amount*t.quantity)})))}))),t?.totals?.updated_products_total&&e("div",{class:"s-order-edit-modal-row"},e("span",{class:"s-order-edit-modal-row-label"},salla.lang.getWithDefault("pages.orders.modified_products_total","مجموع المنتجات المعدلة")),e("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(t.totals.updated_products_total.amount)})),o>0&&e("div",{class:"s-order-edit-modal-row"},e("span",{class:"s-order-edit-modal-tax-label"},e("i",{class:"sicon-info-circle s-order-edit-modal-tax-icon"}),salla.lang.getWithDefault("pages.orders.vat","ضريبة القيمة المضافة")),e("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(o)})),t?.totals?.total&&e("div",{class:"s-order-edit-modal-total"},e("span",{class:"s-order-edit-modal-total-label"},salla.lang.getWithDefault("pages.orders.order_total","اجمالي الطلب")),e("span",{class:"s-order-edit-modal-total-value",innerHTML:salla.money(t.totals.total.amount)})),i&&e("div",{class:"s-order-edit-modal-refund"},e("i",{class:"sicon-info-circle s-order-edit-modal-refund-icon"}),e("p",{class:"s-order-edit-modal-refund-text"},salla.lang.getWithDefault("pages.orders.refund_message","سيتم تحويل فارق المبلغ على نفس وسيلة الدفع"))),e("div",{class:"s-order-edit-modal-btn-wrapper"},e("salla-button",{onClick:()=>this.handleConfirm()},r?salla.lang.getWithDefault("pages.orders.pay_difference","دفع فارق المبلغ"):i?salla.lang.getWithDefault("pages.orders.confirm_and_receive_difference","تأكيد واستلام فارق المبلغ"):salla.lang.getWithDefault("pages.orders.confirm_changes","تأكيد التعديلات"),e("i",{class:`${this.getConfirmButtonIconClass()} s-order-edit-modal-btn-icon`})),e("salla-button",{color:"gray",fill:"outline",onClick:()=>this.returnToOrderDetails()},salla.lang.getWithDefault("pages.orders.back_to_order_details","العودة إلى تفاصيل الطلب")))))}render(){if(this.loading)return e(r,null,e("salla-loading",null));if(this.expired)return e(r,null,e("div",{class:"s-order-edit-expired"},e("p",null,salla.lang.getWithDefault("pages.orders.edit_session_expired","انتهت مدة التعديل المتاحة")),e("salla-button",{onClick:()=>this.navigateToOrder()},salla.lang.getWithDefault("pages.orders.back_to_order","العودة إلى تفاصيل الطلب"))));if(this.error||!this.order)return e(r,null,e("div",{class:"s-order-edit-no-content-placeholder"},e("i",{class:"sicon-shopping-bag icon"}),e("p",null,this.error)));const t=this.order.items&&this.order.items.length>0,i=this.order.customer_editing_session?.ends_at;return e(r,null,i&&e("div",{class:"s-order-edit-timer-wrapper"},e("salla-count-down",{prefixText:salla.lang.getWithDefault("pages.orders.edit_within","يمكنك التعديل خلال"),date:i,horizontal:!0,withButton:!0,autoSegments:!0,labeled:!1,size:"sm",color:"primary"})),e("div",{class:"s-order-edit-layout"},this.isMobileViewport?null:this.renderProductsPanel(),e("section",{class:"s-order-edit-order-panel"},e("div",{class:"s-order-edit-items-wrapper"},e("h2",{class:"s-order-edit-items-title"},salla.lang.getWithDefault("pages.orders.order_products","منتجات الطلب")),t?this.order.items.map(((t,r)=>[e("salla-order-edit-item",{key:t.id,item:t,orderId:this.orderId}),r<this.order.items.length-1?e("div",{class:"s-order-edit-items-divider"}):null])):e("div",{class:"s-order-edit-no-content-placeholder"},e("i",{class:"sicon-shopping-bag icon"}),e("p",null,salla.lang.getWithDefault("common.elements.no_items","لا توجد عناصر")))),e("div",{class:"s-order-edit-actions"},e("salla-button",{class:"s-order-edit-mobile-products-trigger",color:"gray",size:"small",fill:"outline",onClick:()=>this.openMobileProductsModal()},e("i",{class:"sicon-add s-order-edit-mobile-products-trigger-icon"}),salla.lang.getWithDefault("pages.orders.add_product","إضافة منتج")),e("salla-button",{onClick:()=>this.saveOrder(),loading:this.saveLoading,size:"small",disabled:!this.hasChanges},salla.lang.getWithDefault("pages.orders.save_changes","حفظ التعديلات")),e("salla-button",{size:"small",color:"gray",fill:"outline",onClick:()=>this.cancelEditSession()},salla.lang.getWithDefault("common.elements.cancel","الغاء"))))),this.renderMobileProductsModal(),this.renderAddProductDrawer(),this.renderSaveModal())}};w.style='/*!twlt*/:host{display:block}.outline{outline-style:solid}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.s-order-edit-timer-wrapper{margin-bottom:1rem;display:flex;justify-content:center}.s-order-edit-layout{display:grid;align-items:flex-start;gap:1.5rem;grid-template-columns:minmax(0,1.35fr) minmax(20rem,1fr)}@media (max-width: 1080px){.s-order-edit-layout{grid-template-columns:minmax(0, 1fr)}}.s-order-edit-products-panel{border-radius:1rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1.5rem}@media (max-width: 768px){.s-order-edit-products-panel{display:none}}.s-order-edit-order-panel{display:flex;flex-direction:column;gap:1.5rem;border-radius:1rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1.5rem}.s-order-edit-products-header{margin-bottom:1rem}.s-order-edit-products-title{margin:0px;font-size:1.125rem;line-height:1.75rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-items-wrapper{display:flex;flex-direction:column;gap:1.25rem}.s-order-edit-items-title{margin:0px;font-size:1.125rem;line-height:1.75rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-items-divider{height:1px;width:100%;--tw-bg-opacity:1;background-color:rgb(238 242 247 / var(--tw-bg-opacity, 1))}.s-order-edit-products-picker{display:flex;min-height:0px;flex-direction:column;gap:1rem}.s-order-edit-products-modal-content{display:flex;min-height:0px;flex-direction:column;gap:1rem;padding:1rem}.s-order-edit-products-search{position:relative;margin-bottom:1.25rem;display:block}.s-order-edit-products-search i{pointer-events:none;position:absolute;top:50%;--tw-translate-y:-50%;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));font-size:1rem;line-height:1.5rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-products-search i:where([dir="ltr"],[dir="ltr"] *){left:1rem}.s-order-edit-products-search i:where([dir="rtl"],[dir="rtl"] *){right:1rem}.s-order-edit-products-search-input{min-height:3rem;width:100%;border-radius:0.875rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding-left:1rem;padding-right:1rem;padding-top:0.875rem;padding-bottom:0.875rem;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1));transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:200ms}.s-order-edit-products-search-input:where([dir="ltr"],[dir="ltr"] *){padding-left:2.75rem;padding-right:1rem}.s-order-edit-products-search-input:where([dir="rtl"],[dir="rtl"] *){padding-right:2.75rem;padding-left:1rem}.s-order-edit-products-search-input:focus{--tw-border-opacity:1;border-color:rgb(17 24 39 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));--tw-shadow:0 0 0 3px rgba(17,24,39,0.08);--tw-shadow-colored:0 0 0 3px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}.s-order-edit-products-list{min-height:20rem}.s-order-edit-products-list .s-products-list-wrapper{gap:1rem;grid-template-columns:repeat(2,minmax(0,1fr))}@media (min-width: 769px){.s-order-edit-products-list .s-products-list-wrapper{grid-template-columns:repeat(3, minmax(0, 1fr))}}.s-order-edit-no-content-placeholder{display:flex;min-height:14rem;flex-direction:column;align-items:center;justify-content:center;gap:0.75rem;border-radius:0.875rem;border-width:1px;border-style:dashed;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding:2rem;text-align:center;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-no-content-placeholder .icon{font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-actions{position:sticky;bottom:1.5rem;display:flex;align-items:center;justify-content:space-between;gap:0.75rem;border-radius:0.875rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));background-color:rgba(255,255,255,0.94);padding:1rem;--tw-shadow:0 12px 30px rgba(15,23,42,0.08);--tw-shadow-colored:0 12px 30px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);--tw-backdrop-blur:blur(10px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}@media (max-width: 768px){.s-order-edit-actions{position:static;align-items:center;gap:0.5rem}}.s-order-edit-actions salla-button{flex:0 0 auto}@media (max-width: 768px){.s-order-edit-actions salla-button{display:block;flex:1 1 0;min-width:0}}.s-order-edit-mobile-products-trigger{display:none}@media (max-width: 768px){.s-order-edit-mobile-products-trigger{display:block}}.s-order-edit-mobile-products-trigger-icon:where([dir="ltr"],[dir="ltr"] *){margin-right:0.35rem}.s-order-edit-mobile-products-trigger-icon:where([dir="rtl"],[dir="rtl"] *){margin-left:0.35rem}.s-order-edit-mobile-products-modal .s-order-edit-products-list{max-height:min(24rem, calc(100vh - 11rem));min-height:22rem;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}@media (max-width: 480px){.s-order-edit-mobile-products-modal .s-order-edit-products-list{min-height:20rem;max-height:min(22rem, calc(100vh - 10rem))}}.s-order-edit-mobile-products-modal .products-list .s-products-list-wrapper{gap:0.625rem;grid-template-columns:repeat(2,minmax(0,1fr))}.s-order-edit-modal{display:flex;flex-direction:column;gap:1rem}.s-order-edit-modal-title{margin:0px;text-align:start;font-size:1.125rem;line-height:1.75rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-subtitle{margin:0px;margin-top:-0.75rem;text-align:start;font-size:0.875rem;line-height:1.25rem;line-height:1.5;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-items{display:flex;flex-direction:column;gap:0.75rem}.s-order-edit-modal-item{display:flex;align-items:center;justify-content:space-between;gap:1rem;border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-bottom:0.75rem}.s-order-edit-modal-item-start{display:flex;align-items:center;gap:0.75rem}.s-order-edit-modal-item-image{height:3rem;width:3rem;border-radius:0.75rem;object-fit:cover}.s-order-edit-modal-item-name{margin:0px;font-size:0.875rem;line-height:1.25rem;font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-item-options{font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-item-end{display:flex;align-items:center;gap:0.75rem}.s-order-edit-modal-item-price{font-size:0.875rem;line-height:1.25rem;font-weight:500}.s-order-edit-modal-item-quantity{font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-row{display:flex;align-items:center;justify-content:space-between;gap:1rem}.s-order-edit-modal-row-label{font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-row-value{font-weight:700}.s-order-edit-modal-tax-label{display:flex;align-items:center;gap:0.5rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-tax-icon{--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-modal-total{display:flex;align-items:center;justify-content:space-between;gap:1rem;border-top-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-top:0.75rem;font-weight:700;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-total-label{font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-total-value{font-size:1.25rem;line-height:1.75rem;font-weight:500}.s-order-edit-modal-refund{display:flex;align-items:flex-start;gap:1rem;border-radius:0.875rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));padding-left:1rem;padding-right:1rem;padding-top:0.875rem;padding-bottom:0.875rem;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-order-edit-modal-refund-icon{flex-shrink:0;font-size:1.125rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-refund-text{margin:0px;flex:1 1 0%;font-size:0.875rem;line-height:1.25rem}.s-order-edit-modal-btn-wrapper{margin-top:0.5rem;display:flex;justify-content:space-between}.s-order-edit-modal-btn-wrapper salla-button{width:100%}@media (min-width: 640px){.s-order-edit-modal-btn-wrapper salla-button{width:auto}}.s-order-edit-modal-btn-icon{vertical-align:middle;font-size:1.125rem;line-height:1.75rem}.s-order-edit-expired{display:flex;min-height:14rem;flex-direction:column;align-items:center;justify-content:center;gap:0.75rem;border-radius:0.875rem;border-width:1px;border-style:dashed;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding:2rem;text-align:center;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-expired .icon{font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal{display:flex;min-height:0px;flex:1 1 auto;flex-direction:column;gap:1rem}.s-order-edit-add-modal-content{display:flex;min-height:0px;flex:1 1 auto;flex-direction:column;gap:1rem}.s-order-edit-add-modal-loading{display:flex;min-height:12rem;flex:1 1 auto;align-items:center;justify-content:center}.s-order-edit-add-modal-header{border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-bottom:1rem}.s-order-edit-add-modal-media{display:flex;align-items:flex-start;gap:1rem}.s-order-edit-add-modal-image{height:5.5rem;width:5.5rem;border-radius:0.875rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));object-fit:cover}.s-order-edit-add-modal-details{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.35rem}.s-order-edit-add-modal-name{margin:0px;font-size:1rem;line-height:1.5rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal-price{font-size:0.95rem;font-weight:700;--tw-text-opacity:1;color:rgb(15 118 110 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal-quantity{display:flex;align-items:center;justify-content:space-between;gap:1rem}.s-order-edit-add-modal-section-title{margin:0px;font-size:0.9375rem;font-weight:600;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal-quantity-input{flex-shrink:0}.s-order-edit-add-modal-actions{margin-top:auto;display:flex;align-items:center;justify-content:space-between;gap:0.75rem;border-top-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding-top:1rem}.s-order-edit-add-modal-actions salla-button{min-width:4.75rem;flex:0 0 auto}.s-order-edit-item-header{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem}.s-order-edit-item-media{display:flex;min-width:0px;flex:1 1 0%;gap:1rem}@media (max-width: 640px){.s-order-edit-item-media{width:100%}}.s-order-edit-item-image{height:5.5rem;width:5.5rem;border-radius:0.875rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));object-fit:cover}.s-order-edit-item-details{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.35rem}.s-order-edit-item-name{margin:0px;font-size:1rem;line-height:1.5rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-item-link{color:inherit;text-decoration-line:none}.s-order-edit-item-price{font-size:0.95rem;font-weight:700;--tw-text-opacity:1;color:rgb(15 118 110 / var(--tw-text-opacity, 1))}.s-order-edit-item-weight{margin:0px;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-item-quantity{margin-top:1.25rem;display:flex;align-items:center;justify-content:space-between;gap:1rem;border-top-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-top:1rem}.s-order-edit-item-quantity-label{margin:0px;font-size:0.9375rem;font-weight:600;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-order-edit-item-quantity-input{flex-shrink:0}.s-order-edit-item-options{margin-top:1rem;display:block}.s-order-edit-product-card{display:flex;min-height:100%;width:100%;cursor:pointer;appearance:none;flex-direction:column;overflow:hidden;border-radius:0.875rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));text-align:start;--tw-shadow:0 10px 24px rgba(15,23,42,0.04);--tw-shadow-colored:0 10px 24px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:200ms}.s-order-edit-product-card:hover{--tw-translate-y:-2px;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-shadow:0 16px 30px rgba(15,23,42,0.08);--tw-shadow-colored:0 16px 30px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.s-order-edit-product-card:focus-visible{--tw-border-opacity:1;border-color:rgb(17 24 39 / var(--tw-border-opacity, 1));--tw-shadow:0 0 0 3px rgba(17,24,39,0.12);--tw-shadow-colored:0 0 0 3px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}@media (max-width: 768px){.s-order-edit-product-card{border-radius:0.75rem;box-shadow:0 6px 18px rgba(15, 23, 42, 0.05)}}.s-order-edit-product-card-media{display:flex;aspect-ratio:1 / 1;width:100%;flex-shrink:0;align-items:center;justify-content:center;overflow:hidden;background:linear-gradient(180deg,#f8fafc 0%,#f1f5f9 100%)}.s-order-edit-product-card-image{display:block;height:100%;width:100%;object-fit:cover}.s-order-edit-product-card-placeholder{display:flex;height:100%;width:100%;align-items:center;justify-content:center;font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-product-card-content{display:flex;flex:1 1 0%;flex-direction:column;gap:0.5rem;padding:1rem}@media (max-width: 768px){.s-order-edit-product-card-content{gap:0.25rem;padding:0.625rem}}.s-order-edit-product-card-title{margin:0px;font-size:0.95rem;font-weight:600;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}@media (max-width: 768px){.s-order-edit-product-card-title{display:-webkit-box;overflow:hidden;min-height:2.35rem;font-size:0.8125rem;line-height:1.45;-webkit-box-orient:vertical;-webkit-line-clamp:2}}.s-order-edit-product-card-price{margin:0px;font-size:1rem;line-height:1.5rem;font-weight:700;--tw-text-opacity:1;color:rgb(15 118 110 / var(--tw-text-opacity, 1))}@media (max-width: 768px){.s-order-edit-product-card-price{font-size:0.875rem}.s-order-edit-products-panel,.s-order-edit-order-panel{padding:1rem}.s-order-edit-actions salla-button .s-button-element{width:100%;min-width:0;padding-inline:0.5rem}.s-order-edit-mobile-products-modal .s-order-edit-products-modal-content{gap:0.75rem;padding:0.875rem}.s-order-edit-add-modal-media,.s-order-edit-add-modal-quantity{flex-direction:column;align-items:stretch}}';export{w as salla_order_edit}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as e,h as a}from"./p-
|
|
4
|
+
import{r as e,h as a}from"./p-BNekvDFW.js";import{S as r}from"./p-BpzvJ73s.js";import{C as t}from"./p-CTtM5VoO.js";import{S as i}from"./p-CiNDuG4-.js";const n=class{constructor(a){e(this,a)}async componentWillLoad(){await salla.onReady(),await salla.lang.onLoaded()}dateLabel(){const e=new Date(this.createdAt);if(Number.isNaN(e.getTime()))return"";const a=/([+-])(\d{2}):?(\d{2})$/.exec(this.createdAt||""),r=a?("-"===a[1]?-1:1)*(60*Number(a[2])+Number(a[3])):0,t=!!a||/Z$/i.test(this.createdAt||"");return new Intl.DateTimeFormat(document.documentElement.lang||"ar",{calendar:"gregory",day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"2-digit",...t?{timeZone:"UTC"}:{}}).format(t?new Date(e.getTime()+6e4*r):e)}async copyReference(){try{await navigator.clipboard.writeText(this.referenceId),salla.notify.success(salla.lang.get("common.elements.copied"))}catch{}}render(){const e=this.dateLabel();return a("header",{key:"059ca864ef1b2688f3919e0d1afe312a6a26304b",class:"s-thank-you-header-wrapper"},a("div",{key:"7db61c7e59b0c648a863c8f273733a351d7ae7f6",class:"s-thank-you-header-intro"},a("span",{key:"fd6898fd919eb23123f0922504cd7fa27fd6d7cf",class:"s-thank-you-header-success"},a("span",{key:"f3e543dd2cdb8fd6ec766decf8733053f64a85b4",class:"s-thank-you-header-success-icon","aria-hidden":"true",innerHTML:r}),a("span",{key:"fe155c56cfa5b8c96f9ec0ab0212d0ecaa9b78e8",class:"s-thank-you-header-store"},this.storeLogo?a("img",{src:this.storeLogo,alt:this.storeName||""}):a("span",{"aria-hidden":"true",innerHTML:i}))),a("div",{key:"98df6b364ae471bc6d293b2bc2ef550f93ab1ded",class:"s-thank-you-header-copy"},a("h1",{key:"e0150e20cf220cb60612745341e0a243f5155f6a","data-testid":"store-thankyou-header-show-title",class:"s-thank-you-header-title"},this.heading),a("p",{key:"d4b592a4517434d7d21c24884bebc7a5d99128ab",class:"s-thank-you-header-subtitle"},this.subtitle||salla.lang.get("pages.thank_you.order_received")))),a("hr",{key:"98dcc158ecd2af0c6081959299164e4a004255ca",class:"s-thank-you-header-divider"}),a("div",{key:"1b40af524a983485f718aab6f52a13da56c11f69",class:"s-thank-you-header-meta"},this.referenceId?a("button",{type:"button",class:"s-thank-you-header-reference","data-testid":"store-thankyou-header-copy-reference","aria-label":`${salla.lang.get("common.elements.copy")} ${this.referenceId}`,onClick:()=>this.copyReference()},a("span",{"aria-hidden":"true",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>page-check</title>\n<path d="M13.629 21.113c-0.616-0.408-1.441-0.243-1.849 0.369-0.409 0.613-0.244 1.44 0.369 1.849l2.667 1.777c0.228 0.151 0.485 0.224 0.739 0.224 0.431 0 0.855-0.208 1.111-0.593l3.555-5.333c0.409-0.613 0.244-1.44-0.369-1.849-0.616-0.408-1.443-0.244-1.849 0.369l-2.815 4.224zM29.229 11.487c-0.068-0.163-0.167-0.309-0.289-0.431l-10.663-10.663c-0.123-0.123-0.269-0.221-0.431-0.289s-0.335-0.104-0.513-0.104h-10.667c-2.205 0-4 1.795-4 4v24c0 2.205 1.795 4 4 4h18.667c2.205 0 4-1.795 4-4v-16c0-0.179-0.036-0.352-0.104-0.513zM18.667 4.552l6.115 6.115h-6.115zM26.667 28c0 0.736-0.597 1.333-1.333 1.333h-18.667c-0.736 0-1.333-0.597-1.333-1.333v-24c0-0.736 0.597-1.333 1.333-1.333h9.333v9.333c0 0.737 0.596 1.333 1.333 1.333h9.333z"></path>\n</svg>\n'}),a("span",{dir:"ltr"},"#",this.referenceId),a("span",{"aria-hidden":"true",innerHTML:t})):null,e?a("span",{class:"s-thank-you-header-date"},a("span",{"aria-hidden":"true",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>clock</title>\n<path d="M16 10.667c-0.736 0-1.333 0.597-1.333 1.333v4h-2.667c-0.736 0-1.333 0.597-1.333 1.333 0 0.737 0.597 1.333 1.333 1.333h4c0.736 0 1.333-0.596 1.333-1.333v-5.333c0-0.736-0.597-1.333-1.333-1.333zM16 5.333c-5.881 0-10.667 4.785-10.667 10.667s4.785 10.667 10.667 10.667 10.667-4.785 10.667-10.667-4.785-10.667-10.667-10.667zM16 24c-4.412 0-8-3.588-8-8s3.588-8 8-8 8 3.588 8 8-3.588 8-8 8zM16 0c-8.823 0-16 7.177-16 16s7.177 16 16 16 16-7.177 16-16-7.177-16-16-16zM16 29.333c-7.352 0-13.333-5.981-13.333-13.333s5.981-13.333 13.333-13.333 13.333 5.981 13.333 13.333-5.981 13.333-13.333 13.333z"></path>\n</svg>\n'}),a("time",{dateTime:this.createdAt},e)):null),a("slot",{key:"1ec96de5ef0c5c44dc80742277ad6b4ee83354da"}))}};n.style="/*!twlt*/:host{display:block}.s-thank-you-header-wrapper{display:flex;width:100%;flex-direction:column;align-items:center;gap:1rem;text-align:center}@media (min-width: 640px){.s-thank-you-header-wrapper{gap:1.5rem}}.s-thank-you-header-intro{display:flex;width:100%;flex-direction:column;align-items:center;gap:0.75rem}.s-thank-you-header-success{position:relative;display:flex;height:4rem;width:4rem;align-items:center;justify-content:center;border-radius:9999px;background-color:var(--color-primary);color:var(--color-primary-reverse)}.s-thank-you-header-success-icon{display:inline-flex;align-items:center;justify-content:center}.s-thank-you-header-success-icon svg{height:2rem;width:2rem;fill:currentColor}.s-thank-you-header-store{position:absolute;bottom:1px;right:1px;display:flex;height:1.5rem;width:1.5rem;align-items:center;justify-content:center;overflow:hidden;border-radius:9999px;border-width:1px;border-color:var(--color-surface,#fff);background-color:var(--color-surface,#fff);padding:0.25rem;color:var(--color-primary)}.s-thank-you-header-store img,.s-thank-you-header-store svg{height:100%;width:100%;fill:currentColor;object-fit:contain}.s-thank-you-header-copy{display:flex;width:100%;flex-direction:column;gap:0.5rem}.s-thank-you-header-title{margin:0px;font-size:1.5rem;font-weight:700;line-height:1.75rem;color:var(--color-text-primary,#333)}.s-thank-you-header-subtitle{margin:0px;width:100%;font-size:1rem;line-height:1.5rem;color:var(--color-text-secondary,#666)}.s-thank-you-header-divider{margin:0px;width:100%;border-width:0px;border-top-width:1px;border-color:var(--color-border-light,#f4f4f4)}.s-thank-you-header-meta{display:flex;width:100%;flex-wrap:wrap;align-items:center;justify-content:center;column-gap:1.5rem;row-gap:0.5rem;font-size:0.875rem;line-height:1.25rem;color:var(--color-text-secondary,#666)}.s-thank-you-header-reference{display:inline-flex;cursor:pointer;align-items:center;gap:0.5rem;border-width:0px;background-color:transparent;padding:0px;color:inherit}.s-thank-you-header-date{display:inline-flex;align-items:center;gap:0.5rem}.s-thank-you-header-meta svg{height:1.25rem;width:1.25rem;fill:currentColor}";export{n as salla_thank_you_header}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as e,c as t,h as s,H as i}from"./p-
|
|
4
|
+
import{r as e,c as t,h as s,H as i}from"./p-BNekvDFW.js";const a=class{constructor(s){e(this,s),this.prizeItemSelected=t(this,"prizeItemSelected")}onPrizeItemClick(){this.prizeItemSelected.emit(this.item)}render(){return s(i,{key:"cb20ee6762c35447045c3b5c79091496d4d3b84e"},s("div",{key:"7f42534f123d21ee216bae7942b254885b3f0290",onClick:this.onPrizeItemClick.bind(this)},s("img",{key:"565140ba4d0b002db8f76f0d5fdb749d3bcfc081",class:"s-loyalty-prize-item-image",src:this.item.image,alt:this.item.name}),s("div",{key:"1b67b5d41558f92e5f2a8377cd75c32ce4dea587",class:"s-loyalty-prize-item-title"},this.item.name),s("div",{key:"f26f7e374f23e885256a6dd9fff9c8b1b8a9a858",class:"s-loyalty-prize-item-subtitle"},this.item.description),s("div",{key:"9fcb3765dddbdffddd770a46f21cc0389574e2c3",class:"s-loyalty-prize-item-points"},this.item.cost_points," ",salla.lang.get("pages.loyalty_program.point"))))}};a.style="salla-loyalty-prize-item:hover{box-shadow:0 5px 15px 1px rgba(0, 0, 0, 0.04) !important}";export{a as salla_loyalty_prize_item}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as t,h as e,H as s,a as l,F as n}from"./p-C9GauqTa.js";const i=class{constructor(e){t(this,e),this.sections=[],this.itemNumber=""}deleteItem(t,e){const s=this.host.closest("form");if(s){const l=s.getAttribute("id");if(l&&"string"==typeof l){const s=l.match(/item-(\d+)/)?.[1];this.itemNumber=s||"";const n=this.host.querySelector(`#accordion-${e.id}`);salla.cart.deleteItem(`${this.itemNumber}?product_id=${e.id}§ion_id=${t}`).then((()=>n?.remove()))}}}renderRemoveButton(t,s,l=!1){return e("salla-button",{type:"button",shape:l?"btn":"icon",fill:l?"outline":"solid",size:"small",color:"danger","aria-label":"Remove from the cart",onClick:()=>this.deleteItem(t,s)},l?salla.lang.get("common.elements.delete"):e("i",{class:"sicon-cancel"}))}renderAccordionHeader(t,s){const l=s?.options&&s?.options?.length>0;return e("div",{slot:"html",class:"s-multiple-bundle-product-cart-header-wrapper"},e("div",{class:"s-multiple-bundle-product-cart-header "+(l?"":"s-multiple-bundle-product-cart-header-no-options")},e("div",{class:"s-multiple-bundle-product-cart-header-content"},e("a",{href:s?.url,class:"s-multiple-bundle-product-cart-header-image-wrapper"},e("img",{src:s?.image?.url,alt:s?.image?.alt||s?.name,class:"s-multiple-bundle-product-cart-header-image"})),e("div",{class:"s-multiple-bundle-product-cart-header-content-details"},e("h2",{class:"s-multiple-bundle-product-cart-header-content-details-title"},e("a",{href:s?.url,class:"s-multiple-bundle-product-cart-header-content-details-title-link"},s?.name)),e("div",{class:"s-multiple-bundle-product-cart-header-content-details-price"},e("span",{class:"s-multiple-bundle-product-cart-header-content-details-price-regular"},e("span",{innerHTML:s?.price?salla.money(s?.price):""})),s?.sale_price>0&&e("span",{class:"s-multiple-bundle-product-cart-header-content-details-price-sale"},e("span",{innerHTML:salla.money(s?.sale_price)}))),s?.quantity_in_group>0&&0!==s?.quantity&&e("p",{class:"s-multiple-bundle-product-cart-header-content-details-quantity"},e("span",null,salla.lang.get("pages.products.number_of_pieces")),e("span",null,s?.quantity_in_group)))),!l&&e("div",{class:"s-multiple-bundle-product-cart-header-remove-button"},this.renderRemoveButton(t,s,!1))))}render(){return e(s,{key:"db441f645dc207f5864d3f4b89e67bb09ae2e622",class:"s-multiple-bundle-product-wrapper"},e("div",{key:"68bdd0512162e73bce90d1077d0d6d7f9f8da29b",class:"s-multiple-bundle-product-wrapper-sections"},this.sections.map(((t,s)=>t.products.map((l=>{const n={sectionId:t.id,sectionIndex:s,productId:l.id};return e("salla-accordion",{key:l.id,collapsed:!1,bordered:!0,collapsible:!!(l.options&&l.options.length>0),size:"sm",id:`accordion-${l.id}`},e("salla-accordion-head",null,this.renderAccordionHeader(String(t.id),l)),l.options&&l.options.length>0&&e("salla-accordion-body",null,e("salla-product-options",{options:JSON.stringify(l.options),key:`${l.id}-persistent`,"product-id":l.id,"bundle-context":JSON.stringify(n)}),e("div",{class:"s-multiple-bundle-product-cart-body-remove-button"},this.renderRemoveButton(String(t.id),l,!0))))}))))))}get host(){return l(this)}};i.style="";const o=class{constructor(e){t(this,e),this.sections=[],this.selectedProducts={},this.productSelectedHandler=null,this.onSelectProduct=(t,e)=>{const s=e.id,l=this.selectedProducts[t]?.has(s)??!1,n=this.sections.find((e=>e.id==t));if(!(l&&n&&this.isProductSelectionLocked(n))){if(!l){if(!n)return;if(1!==this.getEffectiveMax(n)&&this.isAtSelectionLimit(n))return}this.selectedProducts={...this.selectedProducts,[t]:new Set(this.selectedProducts[t]||[])},l?(this.selectedProducts[t].delete(s),this.clearProductFormData(s,t),this.clearProductModalOptions(s,t)):1===this.getEffectiveMax(n)?this.syncSectionSelection(t,s):this.selectedProducts[t].add(s),this.selectedProducts={...this.selectedProducts},salla.event.dispatch("on-bundle-product-selected",{id:e.id,name:e.name,options:e.options,wasSelected:l,isSelected:!l})}},this.ensureProductSelected=(t,e)=>{this.selectedProducts={...this.selectedProducts,[t]:new Set(this.selectedProducts[t]||[])};const s=e.id;if(this.selectedProducts[t].has(s))return;const l=this.sections.find((e=>e.id==t));if(!l)return;const n=this.getEffectiveMax(l);if(1===n)this.syncSectionSelection(t,s);else{if(n>1&&this.isAtSelectionLimit(l))return;this.selectedProducts[t].add(s)}this.selectedProducts={...this.selectedProducts},salla.event.dispatch("on-bundle-product-selected",{id:e.id,name:e.name,options:e.options})},this.onSelectProductOptions=(t,e)=>{const s=this.sections.find((t=>t.id==e));if(!s||!this.canSelectProductInSection(s,t.id))return;const l=this.sections.findIndex((t=>t.id==e)),n=s.products?.findIndex((e=>e.id==t.id))??0,i=this.selectedProducts[e]?.has(t.id)??!1;salla.event.dispatch("multiple-bundle-product-modal::open",{product:t,sectionId:e,sectionIndex:l,productIndex:n,isProductAlreadySelected:i})},this.handleBundleSliderProductSelected=t=>{const{product:e,sectionId:s}=t.detail;this.onSelectProduct(s,e)},this.handleBundleSliderProductOptionsSelected=t=>{const{product:e,sectionId:s}=t.detail;this.onSelectProductOptions(e,s)}}isSingleProductSection(t){return 1===(t.products?.length??0)}getObligatoryMin(t){const e=t.obligatory_products;if(null==e)return 0;const s=Number(e);return Number.isNaN(s)?0:s}isProductSelectionLocked(t){return this.isSingleProductSection(t)&&1===this.getObligatoryMin(t)}getEffectiveMax(t){const e=t.products?.length??0,s=t.max_obligatory_products;return null!=s&&s>0?Math.min(s,e):e}getSelectedCount(t){return this.selectedProducts[t]?.size??0}isAtSelectionLimit(t){return this.getSelectedCount(t.id)>=this.getEffectiveMax(t)}canSelectProductInSection(t,e){return!!this.selectedProducts[t.id]?.has(e)||1===this.getEffectiveMax(t)||!this.isAtSelectionLimit(t)}async canSelectBundleProduct(t,e){const s=this.sections.find((e=>e.id==t));return!!s&&this.canSelectProductInSection(s,e)}queryProductCheckbox(t,e){const s=`input.s-multiple-bundle-product-checkbox[name="bundle[${t}][${e}][id]"]`,l=this.host.closest("form"),n=l?.querySelector(s);if(n)return n;for(const t of this.host.querySelectorAll("salla-multiple-bundle-product-slider")){const e=(t.shadowRoot??t).querySelector(s);if(e)return e}return null}dispatchBubblingChange(t){requestAnimationFrame((()=>{t.dispatchEvent(new window.Event("change",{bubbles:!0}))}))}clearSectionProductSlot(t,e,s){const l=this.queryProductCheckbox(t,s);l&&(l.checked=!1);const n=this.host.closest("form");if(n){const e=`bundle[${t}][${s}]`;Array.from(n.querySelectorAll("input")).forEach((t=>{t.name?.startsWith(e)&&("checkbox"===t.type&&t.name?.endsWith("][id]")?t.checked=!1:t.remove())}))}this.clearProductModalOptions(e,t)}syncSectionSelection(t,e){const s=this.sections.find((e=>e.id==t));s?.products?.forEach(((s,l)=>{s.id!=e&&this.clearSectionProductSlot(t,s.id,l)})),this.selectedProducts[t]=new Set([e]);const l=s?.products?.findIndex((t=>t.id==e))??-1,n=l>=0?this.queryProductCheckbox(t,l):null;n&&(n.checked=!0,this.dispatchBubblingChange(n))}autoSelectSingleProductSections(){if(!this.sections?.length)return;const t={...this.selectedProducts};let e=!1;const s=[];for(const l of this.sections){if(!this.isProductSelectionLocked(l))continue;const n=l.products?.[0];if(!n||!n.unlimited_quantity&&(n.quantity??0)<=0)continue;const i=l.id,o=new Set(t[i]||[]);o.has(n.id)||(o.add(n.id),t[i]=o,e=!0,s.push({product:n}))}e&&(this.selectedProducts=t,s.forEach((({product:t})=>{salla.event.dispatch("on-bundle-product-selected",{id:t.id,name:t.name,options:t.options})})))}clearProductFormData(t,e){if(null!=e){const s=this.sections.find((t=>t.id==e)),l=s?.products?.findIndex((e=>e.id==t))??-1;if(l>=0)return void this.clearSectionProductSlot(e,t,l)}const s=this.host.closest("form");s&&s.querySelectorAll(`[data-product-id="${t}"]`).forEach((t=>t.remove()))}clearProductModalOptions(t,e){let s=null,l=null;if(null!=e&&(s=this.sections.findIndex((t=>t.id==e)),s>-1)){const e=this.sections[s];if(e){const s=e.products?.findIndex((e=>e.id==t));l="number"==typeof s&&s>-1?s:null}}salla.event.dispatch("multiple-bundle-product-modal::clear-options",{productId:t,sectionId:e,sectionIndex:s,productIndex:l})}getProgressStatus(t){const e=this.getSelectedCount(t.id),s=this.getEffectiveMax(t);return s>0?`${e}/${s}`:"0"}ensureProductCountLang(){o.productCountLangReady||(salla.lang.add("pages.products.bundle_product_count",{ar:"{1} منتج|{2} منتجان|[3,10] :count منتجات|[11,99] :count منتجًا|[0,*] :count منتج",en:"{1} :count product|[0,*] :count products"}),o.productCountLangReady=!0)}getSectionSelectionNote(t){const e=this.getObligatoryMin(t),s=Number(t.max_obligatory_products)||0;if(e<=0&&s<=0)return null;this.ensureProductCountLang();const l=t=>salla.lang.choice("pages.products.bundle_product_count",t),n=t=>salla.helpers.number(String(t)),i="ar"===(salla.lang.getLocale?.()||"ar");return e>0&&s>0?e===s?i?`اختر ${l(e)}`:`Select ${l(e)}`:i?`اختر من ${n(e)} إلى ${l(s)}`:`Select from ${n(e)} to ${l(s)}`:e>0?i?`اختر على الأقل ${l(e)}`:`Select at least ${l(e)}`:i?`اختر حتى ${l(s)}`:`Select up to ${l(s)}`}handleSectionsChange(){this.autoSelectSingleProductSections()}componentWillLoad(){this.ensureProductCountLang(),this.autoSelectSingleProductSections()}renderAccordionHeader(t){const s=this.getSectionSelectionNote(t);return e(n,null,e("h2",{slot:"title"},t?.name),s?e("span",{slot:"note"},s):null,e("span",{slot:"progress"},this.getProgressStatus(t)))}componentDidLoad(){const t=this.host.querySelector("salla-multiple-bundle-product-options-modal");t&&(this.productSelectedHandler=t=>{const{productId:e,sectionId:s,product:l,fromModal:n}=t.detail;n?this.ensureProductSelected(s,l||{id:e}):this.onSelectProduct(s,l||{id:e})},t.addEventListener("productSelected",this.productSelectedHandler))}disconnectedCallback(){if(this.productSelectedHandler){const t=this.host.querySelector("salla-multiple-bundle-product-options-modal");t&&t.removeEventListener("productSelected",this.productSelectedHandler),this.productSelectedHandler=null}}render(){return e(s,{key:"91b215bcdaa53e6888a07a6d3e4c3ac7c745f91e",class:"s-multiple-bundle-product-wrapper"},e("div",{key:"152614a163c9c788e2b5bc32f9a037cba9779046",class:"s-multiple-bundle-product-wrapper-sections"},this.sections.map(((t,s)=>e("salla-accordion",{key:t.id,collapsed:0!==s},e("salla-accordion-head",null,this.renderAccordionHeader(t)),e("salla-accordion-body",null,e("salla-multiple-bundle-product-slider",{section:t,sectionIndex:s,selectedProducts:this.selectedProducts,selectionLimit:this.getEffectiveMax(t),isSelectionLocked:this.isProductSelectionLocked(t),onProductSelected:this.handleBundleSliderProductSelected,onProductOptionsSelected:this.handleBundleSliderProductOptionsSelected})))))),e("salla-multiple-bundle-product-options-modal",{key:"2642221bd44ce9659dc90af568292587f071267c"}))}get host(){return l(this)}static get watchers(){return{sections:["handleSectionsChange"]}}};o.productCountLangReady=!1,o.style="";export{i as salla_multiple_bundle_product_cart,o as salla_multiple_bundle_product_details}
|
|
4
|
+
import{r as t,h as e,H as s,a as l,F as n}from"./p-BNekvDFW.js";const i=class{constructor(e){t(this,e),this.sections=[],this.itemNumber=""}deleteItem(t,e){const s=this.host.closest("form");if(s){const l=s.getAttribute("id");if(l&&"string"==typeof l){const s=l.match(/item-(\d+)/)?.[1];this.itemNumber=s||"";const n=this.host.querySelector(`#accordion-${e.id}`);salla.cart.deleteItem(`${this.itemNumber}?product_id=${e.id}§ion_id=${t}`).then((()=>n?.remove()))}}}renderRemoveButton(t,s,l=!1){return e("salla-button",{type:"button",shape:l?"btn":"icon",fill:l?"outline":"solid",size:"small",color:"danger","aria-label":"Remove from the cart",onClick:()=>this.deleteItem(t,s)},l?salla.lang.get("common.elements.delete"):e("i",{class:"sicon-cancel"}))}renderAccordionHeader(t,s){const l=s?.options&&s?.options?.length>0;return e("div",{slot:"html",class:"s-multiple-bundle-product-cart-header-wrapper"},e("div",{class:"s-multiple-bundle-product-cart-header "+(l?"":"s-multiple-bundle-product-cart-header-no-options")},e("div",{class:"s-multiple-bundle-product-cart-header-content"},e("a",{href:s?.url,class:"s-multiple-bundle-product-cart-header-image-wrapper"},e("img",{src:s?.image?.url,alt:s?.image?.alt||s?.name,class:"s-multiple-bundle-product-cart-header-image"})),e("div",{class:"s-multiple-bundle-product-cart-header-content-details"},e("h2",{class:"s-multiple-bundle-product-cart-header-content-details-title"},e("a",{href:s?.url,class:"s-multiple-bundle-product-cart-header-content-details-title-link"},s?.name)),e("div",{class:"s-multiple-bundle-product-cart-header-content-details-price"},e("span",{class:"s-multiple-bundle-product-cart-header-content-details-price-regular"},e("span",{innerHTML:s?.price?salla.money(s?.price):""})),s?.sale_price>0&&e("span",{class:"s-multiple-bundle-product-cart-header-content-details-price-sale"},e("span",{innerHTML:salla.money(s?.sale_price)}))),s?.quantity_in_group>0&&0!==s?.quantity&&e("p",{class:"s-multiple-bundle-product-cart-header-content-details-quantity"},e("span",null,salla.lang.get("pages.products.number_of_pieces")),e("span",null,s?.quantity_in_group)))),!l&&e("div",{class:"s-multiple-bundle-product-cart-header-remove-button"},this.renderRemoveButton(t,s,!1))))}render(){return e(s,{key:"db441f645dc207f5864d3f4b89e67bb09ae2e622",class:"s-multiple-bundle-product-wrapper"},e("div",{key:"68bdd0512162e73bce90d1077d0d6d7f9f8da29b",class:"s-multiple-bundle-product-wrapper-sections"},this.sections.map(((t,s)=>t.products.map((l=>{const n={sectionId:t.id,sectionIndex:s,productId:l.id};return e("salla-accordion",{key:l.id,collapsed:!1,bordered:!0,collapsible:!!(l.options&&l.options.length>0),size:"sm",id:`accordion-${l.id}`},e("salla-accordion-head",null,this.renderAccordionHeader(String(t.id),l)),l.options&&l.options.length>0&&e("salla-accordion-body",null,e("salla-product-options",{options:JSON.stringify(l.options),key:`${l.id}-persistent`,"product-id":l.id,"bundle-context":JSON.stringify(n)}),e("div",{class:"s-multiple-bundle-product-cart-body-remove-button"},this.renderRemoveButton(String(t.id),l,!0))))}))))))}get host(){return l(this)}};i.style="";const o=class{constructor(e){t(this,e),this.sections=[],this.selectedProducts={},this.productSelectedHandler=null,this.onSelectProduct=(t,e)=>{const s=e.id,l=this.selectedProducts[t]?.has(s)??!1,n=this.sections.find((e=>e.id==t));if(!(l&&n&&this.isProductSelectionLocked(n))){if(!l){if(!n)return;if(1!==this.getEffectiveMax(n)&&this.isAtSelectionLimit(n))return}this.selectedProducts={...this.selectedProducts,[t]:new Set(this.selectedProducts[t]||[])},l?(this.selectedProducts[t].delete(s),this.clearProductFormData(s,t),this.clearProductModalOptions(s,t)):1===this.getEffectiveMax(n)?this.syncSectionSelection(t,s):this.selectedProducts[t].add(s),this.selectedProducts={...this.selectedProducts},salla.event.dispatch("on-bundle-product-selected",{id:e.id,name:e.name,options:e.options,wasSelected:l,isSelected:!l})}},this.ensureProductSelected=(t,e)=>{this.selectedProducts={...this.selectedProducts,[t]:new Set(this.selectedProducts[t]||[])};const s=e.id;if(this.selectedProducts[t].has(s))return;const l=this.sections.find((e=>e.id==t));if(!l)return;const n=this.getEffectiveMax(l);if(1===n)this.syncSectionSelection(t,s);else{if(n>1&&this.isAtSelectionLimit(l))return;this.selectedProducts[t].add(s)}this.selectedProducts={...this.selectedProducts},salla.event.dispatch("on-bundle-product-selected",{id:e.id,name:e.name,options:e.options})},this.onSelectProductOptions=(t,e)=>{const s=this.sections.find((t=>t.id==e));if(!s||!this.canSelectProductInSection(s,t.id))return;const l=this.sections.findIndex((t=>t.id==e)),n=s.products?.findIndex((e=>e.id==t.id))??0,i=this.selectedProducts[e]?.has(t.id)??!1;salla.event.dispatch("multiple-bundle-product-modal::open",{product:t,sectionId:e,sectionIndex:l,productIndex:n,isProductAlreadySelected:i})},this.handleBundleSliderProductSelected=t=>{const{product:e,sectionId:s}=t.detail;this.onSelectProduct(s,e)},this.handleBundleSliderProductOptionsSelected=t=>{const{product:e,sectionId:s}=t.detail;this.onSelectProductOptions(e,s)}}isSingleProductSection(t){return 1===(t.products?.length??0)}getObligatoryMin(t){const e=t.obligatory_products;if(null==e)return 0;const s=Number(e);return Number.isNaN(s)?0:s}isProductSelectionLocked(t){return this.isSingleProductSection(t)&&1===this.getObligatoryMin(t)}getEffectiveMax(t){const e=t.products?.length??0,s=t.max_obligatory_products;return null!=s&&s>0?Math.min(s,e):e}getSelectedCount(t){return this.selectedProducts[t]?.size??0}isAtSelectionLimit(t){return this.getSelectedCount(t.id)>=this.getEffectiveMax(t)}canSelectProductInSection(t,e){return!!this.selectedProducts[t.id]?.has(e)||1===this.getEffectiveMax(t)||!this.isAtSelectionLimit(t)}async canSelectBundleProduct(t,e){const s=this.sections.find((e=>e.id==t));return!!s&&this.canSelectProductInSection(s,e)}queryProductCheckbox(t,e){const s=`input.s-multiple-bundle-product-checkbox[name="bundle[${t}][${e}][id]"]`,l=this.host.closest("form"),n=l?.querySelector(s);if(n)return n;for(const t of this.host.querySelectorAll("salla-multiple-bundle-product-slider")){const e=(t.shadowRoot??t).querySelector(s);if(e)return e}return null}dispatchBubblingChange(t){requestAnimationFrame((()=>{t.dispatchEvent(new window.Event("change",{bubbles:!0}))}))}clearSectionProductSlot(t,e,s){const l=this.queryProductCheckbox(t,s);l&&(l.checked=!1);const n=this.host.closest("form");if(n){const e=`bundle[${t}][${s}]`;Array.from(n.querySelectorAll("input")).forEach((t=>{t.name?.startsWith(e)&&("checkbox"===t.type&&t.name?.endsWith("][id]")?t.checked=!1:t.remove())}))}this.clearProductModalOptions(e,t)}syncSectionSelection(t,e){const s=this.sections.find((e=>e.id==t));s?.products?.forEach(((s,l)=>{s.id!=e&&this.clearSectionProductSlot(t,s.id,l)})),this.selectedProducts[t]=new Set([e]);const l=s?.products?.findIndex((t=>t.id==e))??-1,n=l>=0?this.queryProductCheckbox(t,l):null;n&&(n.checked=!0,this.dispatchBubblingChange(n))}autoSelectSingleProductSections(){if(!this.sections?.length)return;const t={...this.selectedProducts};let e=!1;const s=[];for(const l of this.sections){if(!this.isProductSelectionLocked(l))continue;const n=l.products?.[0];if(!n||!n.unlimited_quantity&&(n.quantity??0)<=0)continue;const i=l.id,o=new Set(t[i]||[]);o.has(n.id)||(o.add(n.id),t[i]=o,e=!0,s.push({product:n}))}e&&(this.selectedProducts=t,s.forEach((({product:t})=>{salla.event.dispatch("on-bundle-product-selected",{id:t.id,name:t.name,options:t.options})})))}clearProductFormData(t,e){if(null!=e){const s=this.sections.find((t=>t.id==e)),l=s?.products?.findIndex((e=>e.id==t))??-1;if(l>=0)return void this.clearSectionProductSlot(e,t,l)}const s=this.host.closest("form");s&&s.querySelectorAll(`[data-product-id="${t}"]`).forEach((t=>t.remove()))}clearProductModalOptions(t,e){let s=null,l=null;if(null!=e&&(s=this.sections.findIndex((t=>t.id==e)),s>-1)){const e=this.sections[s];if(e){const s=e.products?.findIndex((e=>e.id==t));l="number"==typeof s&&s>-1?s:null}}salla.event.dispatch("multiple-bundle-product-modal::clear-options",{productId:t,sectionId:e,sectionIndex:s,productIndex:l})}getProgressStatus(t){const e=this.getSelectedCount(t.id),s=this.getEffectiveMax(t);return s>0?`${e}/${s}`:"0"}ensureProductCountLang(){o.productCountLangReady||(salla.lang.add("pages.products.bundle_product_count",{ar:"{1} منتج|{2} منتجان|[3,10] :count منتجات|[11,99] :count منتجًا|[0,*] :count منتج",en:"{1} :count product|[0,*] :count products"}),o.productCountLangReady=!0)}getSectionSelectionNote(t){const e=this.getObligatoryMin(t),s=Number(t.max_obligatory_products)||0;if(e<=0&&s<=0)return null;this.ensureProductCountLang();const l=t=>salla.lang.choice("pages.products.bundle_product_count",t),n=t=>salla.helpers.number(String(t)),i="ar"===(salla.lang.getLocale?.()||"ar");return e>0&&s>0?e===s?i?`اختر ${l(e)}`:`Select ${l(e)}`:i?`اختر من ${n(e)} إلى ${l(s)}`:`Select from ${n(e)} to ${l(s)}`:e>0?i?`اختر على الأقل ${l(e)}`:`Select at least ${l(e)}`:i?`اختر حتى ${l(s)}`:`Select up to ${l(s)}`}handleSectionsChange(){this.autoSelectSingleProductSections()}componentWillLoad(){this.ensureProductCountLang(),this.autoSelectSingleProductSections()}renderAccordionHeader(t){const s=this.getSectionSelectionNote(t);return e(n,null,e("h2",{slot:"title"},t?.name),s?e("span",{slot:"note"},s):null,e("span",{slot:"progress"},this.getProgressStatus(t)))}componentDidLoad(){const t=this.host.querySelector("salla-multiple-bundle-product-options-modal");t&&(this.productSelectedHandler=t=>{const{productId:e,sectionId:s,product:l,fromModal:n}=t.detail;n?this.ensureProductSelected(s,l||{id:e}):this.onSelectProduct(s,l||{id:e})},t.addEventListener("productSelected",this.productSelectedHandler))}disconnectedCallback(){if(this.productSelectedHandler){const t=this.host.querySelector("salla-multiple-bundle-product-options-modal");t&&t.removeEventListener("productSelected",this.productSelectedHandler),this.productSelectedHandler=null}}render(){return e(s,{key:"91b215bcdaa53e6888a07a6d3e4c3ac7c745f91e",class:"s-multiple-bundle-product-wrapper"},e("div",{key:"152614a163c9c788e2b5bc32f9a037cba9779046",class:"s-multiple-bundle-product-wrapper-sections"},this.sections.map(((t,s)=>e("salla-accordion",{key:t.id,collapsed:0!==s},e("salla-accordion-head",null,this.renderAccordionHeader(t)),e("salla-accordion-body",null,e("salla-multiple-bundle-product-slider",{section:t,sectionIndex:s,selectedProducts:this.selectedProducts,selectionLimit:this.getEffectiveMax(t),isSelectionLocked:this.isProductSelectionLocked(t),onProductSelected:this.handleBundleSliderProductSelected,onProductOptionsSelected:this.handleBundleSliderProductOptionsSelected})))))),e("salla-multiple-bundle-product-options-modal",{key:"2642221bd44ce9659dc90af568292587f071267c"}))}get host(){return l(this)}static get watchers(){return{sections:["handleSectionsChange"]}}};o.productCountLangReady=!1,o.style="";export{i as salla_multiple_bundle_product_cart,o as salla_multiple_bundle_product_details}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as e,c as t,h as i}from"./p-
|
|
4
|
+
import{r as e,c as t,h as i}from"./p-BNekvDFW.js";import{C as s}from"./p-C6jIkM-X.js";import{F as r}from"./p-OF8QcbMM.js";const o=class{constructor(i){e(this,i),this.fieldChanged=t(this,"fieldChanged"),this.fileUploaded=t(this,"fileUploaded"),this.isEditable=!0,this.fieldErrors={},this.isSubmitting=!1}get dragAndDropText(){return salla.lang.get("common.uploader.drag_and_drop")}get browseText(){return salla.lang.get("common.uploader.browse")}get saveButtonText(){return salla.lang.get("common.elements.save")}async setFields(e){this.parsedFields=e}async getFieldValues(){return this.parsedFields?.reduce(((e,t)=>(e[`custom_fields[${t.id}]`]=t.value,e)),{})||{}}async validateFields(){if(!this.parsedFields)return!0;const e=this.parsedFields.reduce(((e,t)=>(!t.required||t.value&&""!==t.value||(e[t.id.toString()]=`${t.label} is required`),e)),{});return this.fieldErrors=e,0===Object.keys(e).length}handleFieldChange(e,t){const i=t.target.value;e.value=i,this.clearFieldError(e.id);const s=!(e.required&&!i);s||this.setFieldError(e.id,`${e.label} is required`),this.fieldChanged.emit({fieldId:e.id,value:i,isValid:s})}handleFileUpload(e,t){const{error:i,file:s}=t.detail,r=!i;this.clearFieldError(e.id),r?e.value=s:this.setFieldError(e.id,"File upload failed"),this.fileUploaded.emit({fieldId:e.id,file:s,isValid:r})}clearFieldError(e){this.fieldErrors={...this.fieldErrors},delete this.fieldErrors[e]}setFieldError(e,t){this.fieldErrors={...this.fieldErrors,[e]:t}}renderTextField(e){return i("input",{disabled:!this.isEditable,type:e.type,id:`custom-field-${e.id}`,value:e.value?.toString()||"",onChange:t=>this.handleFieldChange(e,t),name:`${e.id}`,class:"form-input",required:e.required})}renderFileField(e){return i("salla-file-upload",{url:salla.url.api("upload"),id:`custom-field-${e.id}`,name:`${e.id}`,type:"registration",value:e.value,height:"120px",onAdded:t=>this.handleFileUpload(e,t),required:e.required,disabled:!this.isEditable,onUploaded:e=>{e.target.value=e.target.value?.url},allowRemove:!0,onRemoved:t=>{t.preventDefault(),t.stopPropagation(),e.value="",t.target.value=""},payloadName:"files[]",payloadParams:{type:"registration"},"instant-upload":!0},i("div",{class:"s-custom-fields-filepond-placeholder"},i("span",{class:"s-custom-fields-filepond-placeholder-icon"},i("i",{innerHTML:s})),i("p",{class:"s-custom-fields-filepond-placeholder-text"},this.dragAndDropText),i("span",{class:"filepond--label-action"},this.browseText)))}renderField(e){return i("div",{class:"s-custom-fields-field",key:e.id},i("label",{class:"s-custom-fields-field-label",htmlFor:`custom-field-${e.id}`},e.label,!!e.required&&i("span",{class:"s-custom-fields-required"},"*")),i("div",null,e.type===r.Photo?this.renderFileField(e):this.renderTextField(e),this.fieldErrors[e.id]&&i("p",{class:"s-custom-fields-error"},this.fieldErrors[e.id])))}componentWillLoad(){this.parsedFields=this.parseFields(this.fields)}parseFields(e){return e?"string"==typeof e?JSON.parse(e):Array.isArray(e)?e:[]:[]}async handleSubmit(e){e.preventDefault(),this.isSubmitting=!0;try{const t={},i=e.target.elements;for(let e=0;e<i.length;e++){const s=i[e];s.name&&!s.name.startsWith("hidden")&&s.value&&(t[s.name]=s.value)}await salla.api.profile.updateCustomFields({id:salla.config.get("store.id"),fields:t})}finally{this.isSubmitting=!1}}render(){return this.parsedFields?.length?i("form",{class:"s-custom-fields-wrapper",onSubmit:this.handleSubmit},this.parsedFields.map((e=>this.renderField(e))),i("salla-button",{type:"submit",loading:this.isSubmitting,disabled:this.isSubmitting||!this.isEditable,"loader-position":"end",class:"s-custom-fields-submit-btn"},this.saveButtonText)):null}};o.style="/*!twlt*/:host{display:block}.hidden{display:none}.form-input{height:2.5rem;width:100%;border-radius:0.375rem;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.form-input:focus{border-color:var(--color-primary);--tw-ring-color:transparent}.form-input:is(.dark *){--tw-border-opacity:1;border-color:rgb(75 85 99 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(75 85 99 / var(--tw-bg-opacity, 1))}.form-input:focus:is(.dark *){border-color:var(--color-primary)}@media (min-width: 640px){.form-input{font-size:0.875rem;line-height:1.25rem}}.s-custom-fields-wrapper{display:grid;grid-template-columns:repeat(1, minmax(0, 1fr));gap:1.5rem}@media (min-width: 640px){.s-custom-fields-wrapper{grid-template-columns:repeat(2, minmax(0, 1fr));gap:2rem}}.s-custom-fields-required{--tw-text-opacity:1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.s-custom-fields-submit-btn{grid-column:1 / -1;width:100%}.s-custom-fields-field-error{--tw-text-opacity:1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.s-custom-fields-field-label{margin-bottom:0.5rem;display:block;font-size:0.875rem;line-height:1.25rem;font-weight:700;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-custom-fields-skeleton-wrapper{display:grid;grid-template-columns:repeat(2, minmax(0, 1fr));grid-template-rows:repeat(3, minmax(0, 1fr));gap:3rem}.s-custom-fields-filepond-placeholder{display:flex;flex-direction:column;align-items:center;justify-content:center}.s-custom-fields-filepond-placeholder-icon{margin-bottom:0.25rem}.s-custom-fields-filepond-placeholder-icon svg{height:1.5rem;width:1.5rem;fill:#7c8082}";export{o as salla_custom_fields}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as e,h as s,H as r}from"./p-
|
|
4
|
+
import{r as e,h as s,H as r}from"./p-BNekvDFW.js";import{s as t}from"./p-CxrJQ3Jf.js";const a=class{constructor(s){e(this,s),this.dark=!1,this.commercialRegisterLabel="",this.freelanceLabel=""}connectedCallback(){this.initializeTranslations()}disconnectedCallback(){this.langUnsubscribe?.()}isVisibilityEnforced(){return"SA"===salla.config.get("store.store_country")}initializeTranslations(){this.langUnsubscribe=salla.lang.subscribe((()=>{const e=(e,s,r)=>{t(e,s,r)};e("ar.trans","blocks.footer.commercial_register","السجل التجاري"),e("en.trans","blocks.footer.commercial_register","Commercial Register"),e("ar.trans","blocks.footer.freelance","وثيقة العمل الحر"),e("en.trans","blocks.footer.freelance","Freelance Certificate"),this.commercialRegisterLabel=salla.lang.getWithDefault("blocks.footer.commercial_register","السجل التجاري"),this.freelanceLabel=salla.lang.getWithDefault("blocks.footer.freelance","وثيقة العمل الحر")}))}getBadgeData(){const e=salla.config.get("store.settings.commercial_number"),s=salla.config.get("store.settings.freelance_number");return e?{number:e,label:this.commercialRegisterLabel||"السجل التجاري",imageUrl:salla.url.cdn("images/commercial-register.png",70,70),type:"commercial"}:s?{number:s,label:this.freelanceLabel||"وثيقة العمل الحر",imageUrl:this.dark?salla.url.cdn("images/freelance-white.png"):salla.url.cdn("images/freelance.png"),type:"freelance"}:null}render(){const e=this.getBadgeData();return e?s(r,{class:"s-trust-badges-wrapper "+(this.dark?"dark":"")},this.isVisibilityEnforced()?s("img",{class:"s-trust-badges-image",width:"55",height:"55",src:e.imageUrl,alt:e.label}):null,s("div",{class:"s-trust-badges-content"},s("p",{class:"s-trust-badges-label"},e.label),s("b",{class:"s-trust-badges-number"},e.number))):null}};a.style='/*!twlt*/.s-trust-badges-image{width:55px;height:55px;flex-shrink:0}.s-trust-badges-wrapper{display:flex;align-items:center}.s-trust-badges-wrapper>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(0.5rem * var(--tw-space-x-reverse));margin-left:calc(0.5rem * calc(1 - var(--tw-space-x-reverse)))}.s-trust-badges-wrapper:where([dir="rtl"],[dir="rtl"] *)>:not([hidden])~:not([hidden]){--tw-space-x-reverse:1}.s-trust-badges-label{margin-bottom:0.25rem;font-size:0.875rem;line-height:1.25rem}.s-trust-badges-number{font-size:0.875rem;line-height:1.25rem}';export{a as salla_trust_badges}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as t,h as o,H as r,a}from"./p-C9GauqTa.js";const s=class{constructor(o){t(this,o),this.availableCoupons=[],this.cartTotal=0,this.cartTotalReady=!1,this.currentCoupon="",this.couponInputValue="",this.couponError="",this.isApplying=!1,this.appliedCoupons=[],this.mergedCoupons=[],this.appliedCouponCards=[],this.orderLocked=!1,this.multiCoupon=!1,this.isHandlingInternalError=!1,this.cartUpdatedHandler=t=>{this.syncCartTotal(t),(this.multiCoupon?Array.isArray(t?.coupons):t&&("coupon"in t||"cashback_code"in t))?this.syncAppliedFromCart(t):this.multiCoupon&&t&&"cashback_code"in t&&this.mergeCashbackCodeChip(t.cashback_code),this.couponError=""},this.couponAddedHandler=()=>{this.isApplying||this.isHandlingInternalError||this.refreshFromServer()},this.couponAdditionFailedHandler=t=>{this.isApplying||this.isHandlingInternalError||this.showCouponError(t?.message||salla.lang.get("pages.cart.coupon_application_error"))},this.couponDeletedHandler=()=>{this.isApplying||this.isHandlingInternalError||this.refreshFromServer()},this.onKeyUp=t=>{"Enter"===t.key&&this.couponButtonRef?.click(),this.couponError=""},this.onInput=t=>{this.couponInputValue=t.target.value},this.mergedCashbackCode=""}async componentWillLoad(){await Salla.onReady(),await Salla.lang.onLoaded(),this.multiCoupon=!!salla.config.get("store.settings.cart.multi_coupon"),this.loadCouponsData(),this.seedFromStorage(),this.loadCartTotal(),this.setupCartEventListeners()}setupCartEventListeners(){salla.event.on("cart::updated",this.cartUpdatedHandler),salla.event.on("cart::coupon.added",this.couponAddedHandler),salla.event.on("cart::coupon.addition.failed",this.couponAdditionFailedHandler),salla.event.on("cart::coupon.deleted",this.couponDeletedHandler)}disconnectedCallback(){salla.event.off("cart::updated",this.cartUpdatedHandler),salla.event.off("cart::coupon.added",this.couponAddedHandler),salla.event.off("cart::coupon.addition.failed",this.couponAdditionFailedHandler),salla.event.off("cart::coupon.deleted",this.couponDeletedHandler)}async selectCoupon(t){const o=this.availableCoupons.find((o=>o.code===t));if(o){if(!this.isEligible(o))throw new Error("Coupon not eligible: minimum cart amount not met");try{await this.applyCoupon(t),this.host.dispatchEvent(new CustomEvent("salla::cart-coupons.coupon.selected",{detail:o,bubbles:!0}))}catch(t){throw t}}return o}async loadCouponsData(){try{const t=await salla.api.request("coupons"),o=t?.data,r=Array.isArray(o)?o:Array.isArray(o?.data)?o.data:[];this.availableCoupons=r}catch(t){console.warn("Failed to load coupons:",t),this.availableCoupons=[]}this.buildMergedCoupons()}async loadCartTotal(){await this.refreshFromServer()}seedFromStorage(){if(this.multiCoupon)return;const t=salla.storage.get("cart");t&&"object"==typeof t&&"coupon"in t&&this.applyCart(t),this.seedTotalsFromSummaryStorage()}seedTotalsFromSummaryStorage(){const t=salla.storage.get("cart.summary");t&&"object"==typeof t&&null!=t.sub_total&&(this.cartTotal=Number(t.sub_total),this.cartTotalReady=!0)}syncCartTotal(t){const o=t?.summary?.sub_total??t?.sub_total??t?.total;null!=o&&(this.cartTotal=Number(o),this.cartTotalReady=!0)}async refreshFromServer(){try{const t=await salla.cart.details(),o=t?.data?.cart??t?.data??t;if(o&&"object"==typeof o&&(Array.isArray(o.coupons)||"coupon"in o||"cashback_code"in o))return void this.applyCart(o)}catch(t){}const t=salla.storage.get("cart");t&&this.applyCart(t),this.seedTotalsFromSummaryStorage()}applyCart(t){this.syncCartTotal(t),this.syncAppliedFromCart(t)}mergeCashbackCodeChip(t){const o=(t||"").trim(),r=(this.mergedCashbackCode||"").trim();if(o.toLowerCase()===r.toLowerCase())return;const a=r?this.appliedCoupons.filter((t=>(t||"").toLowerCase()!==r.toLowerCase())):[...this.appliedCoupons],s=a.some((t=>(t||"").toLowerCase()===o.toLowerCase()));this.appliedCoupons=o&&!s?[...a,o]:a,this.mergedCashbackCode=o,r&&this.currentCoupon.toLowerCase()===r.toLowerCase()?this.currentCoupon=o:o&&(this.currentCoupon=this.currentCoupon||o),this.buildMergedCoupons()}syncAppliedFromCart(t){if(this.currentCoupon=t?.coupon||t?.cashback_code||"",this.mergedCashbackCode=(t?.cashback_code||"").trim(),this.multiCoupon){const o=Array.isArray(t?.coupons)?t.coupons:[t?.coupon];this.appliedCoupons=[...o,t?.cashback_code].filter(Boolean);const r=t?.applied_coupons;return this.appliedCouponCards=Array.isArray(r)?r.filter(Boolean):r&&"object"==typeof r?Object.values(r).filter(Boolean):[],void this.buildMergedCoupons()}this.couponInputValue=this.currentCoupon,this.appliedCoupons=this.currentCoupon?[this.currentCoupon]:[],this.buildMergedCoupons()}buildMergedCoupons(){if(!this.multiCoupon)return void(this.mergedCoupons=[]);const t=this.appliedCoupons.filter(Boolean),o=new Set(t),r=new Map(this.availableCoupons.map((t=>[t.code,t]))),a=new Map(r);this.appliedCouponCards.forEach((t=>{t?.code&&!a.has(t.code)&&a.set(t.code,t)}));const s=this.orderLocked?this.mergeIntoLockedOrder(t,r,(t=>o.has(t)||r.has(t))):[...t,...this.availableCoupons.map((t=>t.code)).filter((t=>!o.has(t)))];this.mergedCoupons=s.map((t=>({code:t,coupon:a.get(t)??null,applied:o.has(t)})))}mergeIntoLockedOrder(t,o,r){const a=this.mergedCoupons.map((t=>t.code)).filter(r),s=new Set(a),i=t.filter((t=>!s.has(t)));i.forEach((t=>s.add(t)));const e=[...o.keys()].filter((t=>!s.has(t)));return[...i,...a,...e]}lockOrder(){this.orderLocked=!0}async handleApplyClick(){if(this.isApplying)return;const t=this.couponInputValue.trim();if(t){this.lockOrder(),this.isApplying=!0,this.isHandlingInternalError=!0;try{await salla.cart.addCoupon(t),await this.refreshFromServer(),this.couponInputValue=""}catch(t){this.showCouponError(t.response?.data?.error?.message||salla.lang.get("pages.cart.coupon_application_error"))}finally{this.isApplying=!1,setTimeout((()=>{this.isHandlingInternalError=!1}),100)}}else this.showCouponError(salla.lang.get("pages.cart.enter_coupon_code"))}async handleCouponButtonClick(){if(this.isApplying)return;const t=!!this.currentCoupon;if(t||this.couponInputValue.trim()){this.isApplying=!0,this.isHandlingInternalError=!0;try{t?await salla.cart.deleteCoupon():await salla.cart.addCoupon(this.couponInputValue.trim()),await this.refreshFromServer()}catch(t){this.showCouponError(t.response?.data?.error?.message||salla.lang.get("pages.cart.coupon_application_error"))}finally{this.isApplying=!1,setTimeout((()=>{this.isHandlingInternalError=!1}),100)}}else this.showCouponError(salla.lang.get("pages.cart.enter_coupon_code"))}async removeCoupon(t){if(!this.isApplying){this.lockOrder(),this.isApplying=!0,this.isHandlingInternalError=!0;try{this.multiCoupon?await salla.cart.deleteCoupon(t):await salla.cart.deleteCoupon(),await this.refreshFromServer()}catch(t){this.showCouponError(t.response?.data?.error?.message||salla.lang.get("pages.cart.coupon_application_error"))}finally{this.isApplying=!1,setTimeout((()=>{this.isHandlingInternalError=!1}),100)}}}showCouponError(t){this.couponError=t}handleCouponClick(t){this.applyCoupon(t.code,!1).catch((()=>{}))}async applyCoupon(t,o=!0){if(this.isApplying){if(o)throw new Error("Coupon application already in progress")}else{this.lockOrder(),this.couponInputValue=t,this.couponError="",this.isApplying=!0,this.isHandlingInternalError=!0;try{await salla.cart.addCoupon(t.trim()),await this.refreshFromServer(),this.multiCoupon&&(this.couponInputValue="")}catch(t){if(this.showCouponError(t.response?.data?.error?.message||salla.lang.get("pages.cart.coupon_application_error")),o)throw t}finally{this.isApplying=!1,setTimeout((()=>{this.isHandlingInternalError=!1}),100)}}}formatMainAmount(t){if("percentage"===t.type)return`${salla.helpers.number("object"==typeof t.amount?t.amount.amount:t.amount)}%`;{const r="object"==typeof t.amount?t.amount:{amount:t.amount,currency:t.minimum_amount?.currency||salla.config.get("store.currency.code","SAR")};return o("span",{innerHTML:salla.money(r.amount,r.currency)})}}isEligible(t){return!this.cartTotalReady||!t.minimum_amount||this.cartTotal>=parseFloat(t.minimum_amount.amount)}renderCouponCard(t){const{coupon:r,applied:a,code:s}=t;if(!r)return this.renderMinimalCard(s);const i=this.isEligible(r);return o("div",{class:"s-cart-coupons-slide-one-fourth swiper-slide"},o("div",{class:`s-cart-coupons-card ${a?"s-cart-coupons-card--applied":""} ${a||i&&!this.isApplying?"":"s-cart-coupons-disabled"}`,onClick:()=>!a&&i&&!this.isApplying&&this.handleCouponClick(r)},o("div",{class:"s-cart-coupons-top-section"},o("div",{class:"s-cart-coupons-discount-values"},o("div",{class:"s-cart-coupons-main-amount"},this.formatMainAmount(r)),r.free_shipping?o("div",{class:"s-cart-coupons-secondary-info"},"+ ",salla.lang.get("pages.cart.free_shipping")):r.maximum_amount&&o("div",{class:"s-cart-coupons-secondary-info"},salla.lang.get("pages.cart.up_to")," ",o("span",{innerHTML:salla.money(r.maximum_amount.amount,r.maximum_amount.currency)}))),o("div",{class:"s-cart-coupons-code"},r.code)),o("div",{class:"s-cart-coupons-divider"}),o("div",{class:"s-cart-coupons-bottom-section"},o("div",{class:"s-cart-coupons-terms"},null!=r.remaining_days&&o("div",{class:"s-cart-coupons-expiry "+(r.remaining_days<=3?"s-cart-coupons-expiry-warning":"")},0===r.remaining_days?salla.lang.get("pages.cart.expires_today"):`${salla.lang.get("pages.cart.expires_after")} ${r.remaining_days} ${salla.lang.get("pages.cart.day")}`),r.minimum_amount&&parseFloat(r.minimum_amount.amount)>0&&o("div",{class:"s-cart-coupons-minimum"},salla.lang.get("pages.cart.minimum")," ",o("span",{innerHTML:salla.money(r.minimum_amount.amount,r.minimum_amount.currency)}))),o("div",{class:"s-cart-coupons-action"},a?this.renderAppliedAction(s):i?salla.lang.get("pages.cart.save_coupon"):salla.lang.get("pages.cart.coupon_not_compatible")))))}renderAppliedAction(t){return[o("span",{class:"s-cart-coupons-card-applied-label"},salla.lang.get("pages.cart.coupon_applied")),o("button",{type:"button",class:"s-cart-coupons-card-remove","aria-label":`${salla.lang.get("pages.cart.delete_coupon")} ${t}`,disabled:this.isApplying,onClick:o=>{o.stopPropagation(),this.removeCoupon(t)}},salla.lang.get("pages.cart.cancel"))]}renderMinimalCard(t){return o("div",{class:"s-cart-coupons-slide-one-fourth swiper-slide"},o("div",{class:"s-cart-coupons-card s-cart-coupons-card--applied s-cart-coupons-card--minimal"},o("div",{class:"s-cart-coupons-top-section"},o("div",{class:"s-cart-coupons-code s-cart-coupons-code--only"},t)),o("div",{class:"s-cart-coupons-divider"}),o("div",{class:"s-cart-coupons-bottom-section"},o("div",{class:"s-cart-coupons-action"},this.renderAppliedAction(t)))))}couponRow(){return this.multiCoupon?this.mergedCoupons:(this.availableCoupons||[]).map((t=>({code:t.code,coupon:t,applied:!1})))}render(){const t=this.couponRow();return o(r,{key:"edf77b08d11d50a1083e1b2c2970cc4af4163d80"},o("div",{key:"a5e3ed9302fe64136f572c9a89df529ac139cca4",class:"s-cart-coupons-wrapper"},o("div",{key:"f09279d5ccd96b1ffec3fa1a4fe280e322c624a8",class:"s-cart-coupons-input-section"},o("label",{key:"fa0b750c99686ad2e196f720de6f27c0f84eb41b",htmlFor:"coupon-input",class:"s-cart-coupons-coupon-label"},salla.lang.get("pages.cart.have_coupon")),o("div",{key:"96e892d3f6685dbd9fd901a6e5602a520eea7ecc",class:"s-cart-coupons-coupon-input-container"},this.multiCoupon?[o("input",{type:"text",id:"coupon-input",name:"coupon",class:"form-input "+(this.couponError?"s-coupon-input-error":""),placeholder:salla.lang.get("pages.cart.coupon_placeholder"),value:this.couponInputValue,disabled:this.isApplying,onInput:this.onInput,onKeyUp:this.onKeyUp,"aria-label":salla.lang.get("pages.cart.apply_coupon"),key:"coupon-input"}),o("salla-button",{ref:t=>this.couponButtonRef=t,class:"s-cart-coupons-coupon-button s-cart-coupons-coupon-button-apply",color:"primary",loading:this.isApplying,"loader-position":"center",onClick:()=>this.handleApplyClick(),key:"apply-button"},o("span",null,salla.lang.get("pages.cart.save_coupon")))]:[o("input",{type:"text",id:"coupon-input",name:"coupon",class:"form-input "+(this.couponError?"s-coupon-input-error":""),placeholder:salla.lang.get("pages.cart.coupon_placeholder"),value:this.couponInputValue,disabled:!!this.currentCoupon||this.isApplying,onInput:this.onInput,onKeyUp:this.onKeyUp,"aria-label":salla.lang.get("pages.cart.apply_coupon"),key:"coupon-input"}),o("salla-button",{ref:t=>this.couponButtonRef=t,class:"s-cart-coupons-coupon-button "+(this.currentCoupon?"s-cart-coupons-coupon-button-remove":"s-cart-coupons-coupon-button-apply"),color:this.currentCoupon?"danger":"primary",loading:this.isApplying,"loader-position":"center",onClick:()=>this.handleCouponButtonClick(),key:"apply-button"},this.currentCoupon?o("i",{class:"sicon-cancel"}):o("span",null,salla.lang.get("pages.cart.save_coupon")))]),this.couponError&&o("span",{key:"1e2bb51904486fe5e0cb3f842965a7b330ef7e91",class:"s-cart-coupons-coupon-error"},this.couponError)),t.length>0&&o("salla-slider",{type:"carousel",showControls:!1,class:"s-cart-coupons-slider",key:t.map((t=>t.code)).join("|")},o("div",{key:"c83306bce90ca9a62b13b39718d9941dcc6da498",slot:"items"},t.map((t=>this.renderCouponCard(t)))))))}get host(){return a(this)}};s.style='/*!twlt*/@charset "UTF-8";.s-cart-coupons-card--applied{cursor:default}.s-cart-coupons-card--applied:hover{transform:none}.s-cart-coupons-card--applied .s-cart-coupons-top-section,.s-cart-coupons-card--applied .s-cart-coupons-bottom-section,.s-cart-coupons-card--applied .s-cart-coupons-divider{border-color:#d1d5db;border-color:color-mix(in srgb, var(--color-primary, #004d5a) 40%, transparent)}.s-cart-coupons-card--applied .s-cart-coupons-bottom-section{background:rgba(0, 0, 0, 0.04);background:color-mix(in srgb, var(--color-primary, #004d5a) 8%, transparent)}.s-cart-coupons-card--applied::before,.s-cart-coupons-card--applied::after{border-color:#d1d5db;border-color:color-mix(in srgb, var(--color-primary, #004d5a) 40%, transparent)}.s-cart-coupons-card--applied .s-cart-coupons-action{display:inline-flex;align-items:center;gap:10px}.s-cart-coupons-card--applied .s-cart-coupons-action{font-size:10px;font-weight:600;color:#4b5563}.s-cart-coupons-card-applied-label{color:#4b5563;color:var(--color-primary-dark, var(--color-primary, #4b5563))}.s-cart-coupons-card--applied .s-cart-coupons-action{min-width:0;max-width:100%}.s-cart-coupons-card-applied-label,.s-cart-coupons-card-remove{overflow:hidden;text-overflow:ellipsis}.s-cart-coupons-card--applied .s-cart-coupons-action,.s-cart-coupons-card--applied .s-cart-coupons-card-remove{pointer-events:auto}.s-cart-coupons-card-remove{flex:none;font-size:inherit;font-weight:inherit;color:#6b7280;background:transparent;border:0;padding:0;cursor:pointer;transition:color 0.15s ease}.s-cart-coupons-card-remove:hover{color:var(--color-danger, #ef4444)}.s-cart-coupons-card-remove:disabled{opacity:0.5;cursor:not-allowed}.s-cart-coupons-card--minimal .s-cart-coupons-bottom-section{justify-content:flex-end}.visible{visibility:visible}.fixed{position:fixed}.shrink{flex-shrink:1}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.form-input{height:2.5rem;width:100%;border-radius:0.375rem;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.form-input:focus{border-color:var(--color-primary);--tw-ring-color:transparent}.form-input:is(.dark *){--tw-border-opacity:1;border-color:rgb(75 85 99 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(75 85 99 / var(--tw-bg-opacity, 1))}.form-input:focus:is(.dark *){border-color:var(--color-primary)}@media (min-width: 640px){.form-input{font-size:0.875rem;line-height:1.25rem}}.s-cart-coupons-wrapper{display:block;width:100%;padding-top:1.25rem;padding-bottom:1.25rem}.s-cart-coupons-input-section{margin-bottom:0.625rem}.s-cart-coupons-coupon-label{margin-bottom:0.625rem;display:block;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-cart-coupons-coupon-input-container{position:relative;display:flex;align-items:stretch}.s-cart-coupons-coupon-input-container .form-input{height:auto;flex:1 1 0%}.s-cart-coupons-coupon-input-container .form-input:where([dir="ltr"],[dir="ltr"] *){border-top-left-radius:0.5rem;border-bottom-left-radius:0.5rem;border-top-right-radius:0px !important;border-bottom-right-radius:0px !important;border-right-width:0px}.s-cart-coupons-coupon-input-container .form-input:where([dir="rtl"],[dir="rtl"] *){border-top-right-radius:0.5rem;border-bottom-right-radius:0.5rem;border-top-left-radius:0px !important;border-bottom-left-radius:0px !important;border-left-width:0px}.s-cart-coupons-coupon-input-container .form-input:focus{position:relative;z-index:10}.s-cart-coupons-coupon-button:where([dir="ltr"],[dir="ltr"] *){border-top-right-radius:0.5rem;border-bottom-right-radius:0.5rem;border-top-left-radius:0px;border-bottom-left-radius:0px}.s-cart-coupons-coupon-button:where([dir="rtl"],[dir="rtl"] *){border-top-left-radius:0.5rem;border-bottom-left-radius:0.5rem;border-top-right-radius:0px;border-bottom-right-radius:0px}.s-cart-coupons-coupon-button-remove:where([dir="ltr"],[dir="ltr"] *){border-top-right-radius:0.5rem;border-bottom-right-radius:0.5rem;border-top-left-radius:0px !important;border-bottom-left-radius:0px !important}.s-cart-coupons-coupon-button-remove:where([dir="rtl"],[dir="rtl"] *){border-top-left-radius:0.5rem;border-bottom-left-radius:0.5rem;border-top-right-radius:0px !important;border-bottom-right-radius:0px !important}.s-cart-coupons-coupon-button-apply:where([dir="ltr"],[dir="ltr"] *){border-top-right-radius:0.5rem !important;border-bottom-right-radius:0.5rem !important;border-top-left-radius:0px !important;border-bottom-left-radius:0px !important}.s-cart-coupons-coupon-button-apply:where([dir="rtl"],[dir="rtl"] *){border-top-left-radius:0.5rem !important;border-bottom-left-radius:0.5rem !important;border-top-right-radius:0px !important;border-bottom-right-radius:0px !important}.s-cart-coupons-coupon-error{margin-top:0.5rem;display:block;font-size:10px;line-height:1rem;--tw-text-opacity:1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.s-cart-coupons-slider{width:100%;overflow:hidden;padding-left:0.375rem;padding-right:0.375rem}.s-cart-coupons-card{position:relative;cursor:pointer;overflow:hidden;--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-cart-coupons-card:is(.dark *){--tw-bg-opacity:1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.s-cart-coupons-card:hover{--tw-translate-y:-0.125rem;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.s-cart-coupons-disabled{cursor:not-allowed;opacity:0.5}.s-cart-coupons-disabled:hover{transform:none;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.s-cart-coupons-top-section{display:flex;height:60px;flex-direction:row;align-items:center;justify-content:space-between;border-top-left-radius:0.75rem;border-top-right-radius:0.75rem;border-width:1px;border-bottom-width:0px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));padding-top:1rem;padding-bottom:1rem;padding-left:0.75rem;padding-right:0.75rem}.s-cart-coupons-discount-values{display:flex;flex-direction:column;align-items:flex-start}.s-cart-coupons-discount-values .s-cart-coupons-main-amount{display:flex;align-items:center;gap:0.25rem;white-space:nowrap;font-size:1.25rem;line-height:1.75rem;font-weight:900;line-height:1;--tw-text-opacity:1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.s-cart-coupons-discount-values .s-cart-coupons-secondary-info{margin:0px;font-size:10px;line-height:1rem}.s-cart-coupons-code{font-size:10px;font-weight:700;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-cart-coupons-divider{position:relative;z-index:10;margin:0px;border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.s-cart-coupons-bottom-section{display:flex;min-height:44px;flex-direction:row;align-items:center;justify-content:space-between;border-bottom-right-radius:0.75rem;border-bottom-left-radius:0.75rem;border-width:1px;border-top-width:0px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding-top:0.25rem;padding-bottom:0.25rem;padding-left:0.75rem;padding-right:0.75rem}.s-cart-coupons-terms{display:flex;flex-direction:column;align-items:flex-start}.s-cart-coupons-terms .s-cart-coupons-expiry{margin:0px;font-size:10px;line-height:16px;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-cart-coupons-terms .s-cart-coupons-minimum{margin:0px;font-size:10px;line-height:16px;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-cart-coupons-terms .s-cart-coupons-expiry.s-cart-coupons-expiry-warning{font-weight:500;--tw-text-opacity:1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.s-cart-coupons-action{cursor:pointer;white-space:nowrap;border-width:0px;background-color:transparent;padding:0px;font-size:9px;font-weight:700;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1));transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms}.s-cart-coupons-action:hover{--tw-text-opacity:1;color:rgb(59 130 246 / var(--tw-text-opacity, 1))}.s-cart-coupons-slide-one-fourth{width:calc(75% - 10px);min-width:200px !important;padding-left:5px !important;padding-right:5px !important;padding-top:2px !important}@media (min-width: 1024px){.s-cart-coupons-slide-one-fourth{width:calc(40% - 10px) !important}}.s-cart-coupons-card:before{pointer-events:none;position:absolute;right:-10px;top:60px;z-index:20;height:1.25rem;width:1.25rem;--tw-translate-y:-50%;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));border-radius:9999px;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));--tw-content:\'\';content:var(--tw-content)}.s-cart-coupons-card:is(.dark *):before{--tw-bg-opacity:1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.s-cart-coupons-card:after{pointer-events:none;position:absolute;left:-10px;top:60px;z-index:20;height:1.25rem;width:1.25rem;--tw-translate-y:-50%;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));border-radius:9999px;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));--tw-content:\'\';content:var(--tw-content)}.s-cart-coupons-card:is(.dark *):after{--tw-bg-opacity:1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.s-cart-coupons-coupon-input-container .form-input.s-coupon-input-error{--tw-shadow:0 0 0 3px rgba(239,68,68,0.1) !important;--tw-shadow-colored:0 0 0 3px var(--tw-shadow-color) !important;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important}';export{s as salla_cart_coupons}
|
|
4
|
+
import{r as t,h as o,H as r,a}from"./p-BNekvDFW.js";const s=class{constructor(o){t(this,o),this.availableCoupons=[],this.cartTotal=0,this.cartTotalReady=!1,this.currentCoupon="",this.couponInputValue="",this.couponError="",this.isApplying=!1,this.appliedCoupons=[],this.mergedCoupons=[],this.appliedCouponCards=[],this.orderLocked=!1,this.multiCoupon=!1,this.isHandlingInternalError=!1,this.cartUpdatedHandler=t=>{this.syncCartTotal(t),(this.multiCoupon?Array.isArray(t?.coupons):t&&("coupon"in t||"cashback_code"in t))?this.syncAppliedFromCart(t):this.multiCoupon&&t&&"cashback_code"in t&&this.mergeCashbackCodeChip(t.cashback_code),this.couponError=""},this.couponAddedHandler=()=>{this.isApplying||this.isHandlingInternalError||this.refreshFromServer()},this.couponAdditionFailedHandler=t=>{this.isApplying||this.isHandlingInternalError||this.showCouponError(t?.message||salla.lang.get("pages.cart.coupon_application_error"))},this.couponDeletedHandler=()=>{this.isApplying||this.isHandlingInternalError||this.refreshFromServer()},this.onKeyUp=t=>{"Enter"===t.key&&this.couponButtonRef?.click(),this.couponError=""},this.onInput=t=>{this.couponInputValue=t.target.value},this.mergedCashbackCode=""}async componentWillLoad(){await Salla.onReady(),await Salla.lang.onLoaded(),this.multiCoupon=!!salla.config.get("store.settings.cart.multi_coupon"),this.loadCouponsData(),this.seedFromStorage(),this.loadCartTotal(),this.setupCartEventListeners()}setupCartEventListeners(){salla.event.on("cart::updated",this.cartUpdatedHandler),salla.event.on("cart::coupon.added",this.couponAddedHandler),salla.event.on("cart::coupon.addition.failed",this.couponAdditionFailedHandler),salla.event.on("cart::coupon.deleted",this.couponDeletedHandler)}disconnectedCallback(){salla.event.off("cart::updated",this.cartUpdatedHandler),salla.event.off("cart::coupon.added",this.couponAddedHandler),salla.event.off("cart::coupon.addition.failed",this.couponAdditionFailedHandler),salla.event.off("cart::coupon.deleted",this.couponDeletedHandler)}async selectCoupon(t){const o=this.availableCoupons.find((o=>o.code===t));if(o){if(!this.isEligible(o))throw new Error("Coupon not eligible: minimum cart amount not met");try{await this.applyCoupon(t),this.host.dispatchEvent(new CustomEvent("salla::cart-coupons.coupon.selected",{detail:o,bubbles:!0}))}catch(t){throw t}}return o}async loadCouponsData(){try{const t=await salla.api.request("coupons"),o=t?.data,r=Array.isArray(o)?o:Array.isArray(o?.data)?o.data:[];this.availableCoupons=r}catch(t){console.warn("Failed to load coupons:",t),this.availableCoupons=[]}this.buildMergedCoupons()}async loadCartTotal(){await this.refreshFromServer()}seedFromStorage(){if(this.multiCoupon)return;const t=salla.storage.get("cart");t&&"object"==typeof t&&"coupon"in t&&this.applyCart(t),this.seedTotalsFromSummaryStorage()}seedTotalsFromSummaryStorage(){const t=salla.storage.get("cart.summary");t&&"object"==typeof t&&null!=t.sub_total&&(this.cartTotal=Number(t.sub_total),this.cartTotalReady=!0)}syncCartTotal(t){const o=t?.summary?.sub_total??t?.sub_total??t?.total;null!=o&&(this.cartTotal=Number(o),this.cartTotalReady=!0)}async refreshFromServer(){try{const t=await salla.cart.details(),o=t?.data?.cart??t?.data??t;if(o&&"object"==typeof o&&(Array.isArray(o.coupons)||"coupon"in o||"cashback_code"in o))return void this.applyCart(o)}catch(t){}const t=salla.storage.get("cart");t&&this.applyCart(t),this.seedTotalsFromSummaryStorage()}applyCart(t){this.syncCartTotal(t),this.syncAppliedFromCart(t)}mergeCashbackCodeChip(t){const o=(t||"").trim(),r=(this.mergedCashbackCode||"").trim();if(o.toLowerCase()===r.toLowerCase())return;const a=r?this.appliedCoupons.filter((t=>(t||"").toLowerCase()!==r.toLowerCase())):[...this.appliedCoupons],s=a.some((t=>(t||"").toLowerCase()===o.toLowerCase()));this.appliedCoupons=o&&!s?[...a,o]:a,this.mergedCashbackCode=o,r&&this.currentCoupon.toLowerCase()===r.toLowerCase()?this.currentCoupon=o:o&&(this.currentCoupon=this.currentCoupon||o),this.buildMergedCoupons()}syncAppliedFromCart(t){if(this.currentCoupon=t?.coupon||t?.cashback_code||"",this.mergedCashbackCode=(t?.cashback_code||"").trim(),this.multiCoupon){const o=Array.isArray(t?.coupons)?t.coupons:[t?.coupon];this.appliedCoupons=[...o,t?.cashback_code].filter(Boolean);const r=t?.applied_coupons;return this.appliedCouponCards=Array.isArray(r)?r.filter(Boolean):r&&"object"==typeof r?Object.values(r).filter(Boolean):[],void this.buildMergedCoupons()}this.couponInputValue=this.currentCoupon,this.appliedCoupons=this.currentCoupon?[this.currentCoupon]:[],this.buildMergedCoupons()}buildMergedCoupons(){if(!this.multiCoupon)return void(this.mergedCoupons=[]);const t=this.appliedCoupons.filter(Boolean),o=new Set(t),r=new Map(this.availableCoupons.map((t=>[t.code,t]))),a=new Map(r);this.appliedCouponCards.forEach((t=>{t?.code&&!a.has(t.code)&&a.set(t.code,t)}));const s=this.orderLocked?this.mergeIntoLockedOrder(t,r,(t=>o.has(t)||r.has(t))):[...t,...this.availableCoupons.map((t=>t.code)).filter((t=>!o.has(t)))];this.mergedCoupons=s.map((t=>({code:t,coupon:a.get(t)??null,applied:o.has(t)})))}mergeIntoLockedOrder(t,o,r){const a=this.mergedCoupons.map((t=>t.code)).filter(r),s=new Set(a),i=t.filter((t=>!s.has(t)));i.forEach((t=>s.add(t)));const e=[...o.keys()].filter((t=>!s.has(t)));return[...i,...a,...e]}lockOrder(){this.orderLocked=!0}async handleApplyClick(){if(this.isApplying)return;const t=this.couponInputValue.trim();if(t){this.lockOrder(),this.isApplying=!0,this.isHandlingInternalError=!0;try{await salla.cart.addCoupon(t),await this.refreshFromServer(),this.couponInputValue=""}catch(t){this.showCouponError(t.response?.data?.error?.message||salla.lang.get("pages.cart.coupon_application_error"))}finally{this.isApplying=!1,setTimeout((()=>{this.isHandlingInternalError=!1}),100)}}else this.showCouponError(salla.lang.get("pages.cart.enter_coupon_code"))}async handleCouponButtonClick(){if(this.isApplying)return;const t=!!this.currentCoupon;if(t||this.couponInputValue.trim()){this.isApplying=!0,this.isHandlingInternalError=!0;try{t?await salla.cart.deleteCoupon():await salla.cart.addCoupon(this.couponInputValue.trim()),await this.refreshFromServer()}catch(t){this.showCouponError(t.response?.data?.error?.message||salla.lang.get("pages.cart.coupon_application_error"))}finally{this.isApplying=!1,setTimeout((()=>{this.isHandlingInternalError=!1}),100)}}else this.showCouponError(salla.lang.get("pages.cart.enter_coupon_code"))}async removeCoupon(t){if(!this.isApplying){this.lockOrder(),this.isApplying=!0,this.isHandlingInternalError=!0;try{this.multiCoupon?await salla.cart.deleteCoupon(t):await salla.cart.deleteCoupon(),await this.refreshFromServer()}catch(t){this.showCouponError(t.response?.data?.error?.message||salla.lang.get("pages.cart.coupon_application_error"))}finally{this.isApplying=!1,setTimeout((()=>{this.isHandlingInternalError=!1}),100)}}}showCouponError(t){this.couponError=t}handleCouponClick(t){this.applyCoupon(t.code,!1).catch((()=>{}))}async applyCoupon(t,o=!0){if(this.isApplying){if(o)throw new Error("Coupon application already in progress")}else{this.lockOrder(),this.couponInputValue=t,this.couponError="",this.isApplying=!0,this.isHandlingInternalError=!0;try{await salla.cart.addCoupon(t.trim()),await this.refreshFromServer(),this.multiCoupon&&(this.couponInputValue="")}catch(t){if(this.showCouponError(t.response?.data?.error?.message||salla.lang.get("pages.cart.coupon_application_error")),o)throw t}finally{this.isApplying=!1,setTimeout((()=>{this.isHandlingInternalError=!1}),100)}}}formatMainAmount(t){if("percentage"===t.type)return`${salla.helpers.number("object"==typeof t.amount?t.amount.amount:t.amount)}%`;{const r="object"==typeof t.amount?t.amount:{amount:t.amount,currency:t.minimum_amount?.currency||salla.config.get("store.currency.code","SAR")};return o("span",{innerHTML:salla.money(r.amount,r.currency)})}}isEligible(t){return!this.cartTotalReady||!t.minimum_amount||this.cartTotal>=parseFloat(t.minimum_amount.amount)}renderCouponCard(t){const{coupon:r,applied:a,code:s}=t;if(!r)return this.renderMinimalCard(s);const i=this.isEligible(r);return o("div",{class:"s-cart-coupons-slide-one-fourth swiper-slide"},o("div",{class:`s-cart-coupons-card ${a?"s-cart-coupons-card--applied":""} ${a||i&&!this.isApplying?"":"s-cart-coupons-disabled"}`,onClick:()=>!a&&i&&!this.isApplying&&this.handleCouponClick(r)},o("div",{class:"s-cart-coupons-top-section"},o("div",{class:"s-cart-coupons-discount-values"},o("div",{class:"s-cart-coupons-main-amount"},this.formatMainAmount(r)),r.free_shipping?o("div",{class:"s-cart-coupons-secondary-info"},"+ ",salla.lang.get("pages.cart.free_shipping")):r.maximum_amount&&o("div",{class:"s-cart-coupons-secondary-info"},salla.lang.get("pages.cart.up_to")," ",o("span",{innerHTML:salla.money(r.maximum_amount.amount,r.maximum_amount.currency)}))),o("div",{class:"s-cart-coupons-code"},r.code)),o("div",{class:"s-cart-coupons-divider"}),o("div",{class:"s-cart-coupons-bottom-section"},o("div",{class:"s-cart-coupons-terms"},null!=r.remaining_days&&o("div",{class:"s-cart-coupons-expiry "+(r.remaining_days<=3?"s-cart-coupons-expiry-warning":"")},0===r.remaining_days?salla.lang.get("pages.cart.expires_today"):`${salla.lang.get("pages.cart.expires_after")} ${r.remaining_days} ${salla.lang.get("pages.cart.day")}`),r.minimum_amount&&parseFloat(r.minimum_amount.amount)>0&&o("div",{class:"s-cart-coupons-minimum"},salla.lang.get("pages.cart.minimum")," ",o("span",{innerHTML:salla.money(r.minimum_amount.amount,r.minimum_amount.currency)}))),o("div",{class:"s-cart-coupons-action"},a?this.renderAppliedAction(s):i?salla.lang.get("pages.cart.save_coupon"):salla.lang.get("pages.cart.coupon_not_compatible")))))}renderAppliedAction(t){return[o("span",{class:"s-cart-coupons-card-applied-label"},salla.lang.get("pages.cart.coupon_applied")),o("button",{type:"button",class:"s-cart-coupons-card-remove","aria-label":`${salla.lang.get("pages.cart.delete_coupon")} ${t}`,disabled:this.isApplying,onClick:o=>{o.stopPropagation(),this.removeCoupon(t)}},salla.lang.get("pages.cart.cancel"))]}renderMinimalCard(t){return o("div",{class:"s-cart-coupons-slide-one-fourth swiper-slide"},o("div",{class:"s-cart-coupons-card s-cart-coupons-card--applied s-cart-coupons-card--minimal"},o("div",{class:"s-cart-coupons-top-section"},o("div",{class:"s-cart-coupons-code s-cart-coupons-code--only"},t)),o("div",{class:"s-cart-coupons-divider"}),o("div",{class:"s-cart-coupons-bottom-section"},o("div",{class:"s-cart-coupons-action"},this.renderAppliedAction(t)))))}couponRow(){return this.multiCoupon?this.mergedCoupons:(this.availableCoupons||[]).map((t=>({code:t.code,coupon:t,applied:!1})))}render(){const t=this.couponRow();return o(r,{key:"edf77b08d11d50a1083e1b2c2970cc4af4163d80"},o("div",{key:"a5e3ed9302fe64136f572c9a89df529ac139cca4",class:"s-cart-coupons-wrapper"},o("div",{key:"f09279d5ccd96b1ffec3fa1a4fe280e322c624a8",class:"s-cart-coupons-input-section"},o("label",{key:"fa0b750c99686ad2e196f720de6f27c0f84eb41b",htmlFor:"coupon-input",class:"s-cart-coupons-coupon-label"},salla.lang.get("pages.cart.have_coupon")),o("div",{key:"96e892d3f6685dbd9fd901a6e5602a520eea7ecc",class:"s-cart-coupons-coupon-input-container"},this.multiCoupon?[o("input",{type:"text",id:"coupon-input",name:"coupon",class:"form-input "+(this.couponError?"s-coupon-input-error":""),placeholder:salla.lang.get("pages.cart.coupon_placeholder"),value:this.couponInputValue,disabled:this.isApplying,onInput:this.onInput,onKeyUp:this.onKeyUp,"aria-label":salla.lang.get("pages.cart.apply_coupon"),key:"coupon-input"}),o("salla-button",{ref:t=>this.couponButtonRef=t,class:"s-cart-coupons-coupon-button s-cart-coupons-coupon-button-apply",color:"primary",loading:this.isApplying,"loader-position":"center",onClick:()=>this.handleApplyClick(),key:"apply-button"},o("span",null,salla.lang.get("pages.cart.save_coupon")))]:[o("input",{type:"text",id:"coupon-input",name:"coupon",class:"form-input "+(this.couponError?"s-coupon-input-error":""),placeholder:salla.lang.get("pages.cart.coupon_placeholder"),value:this.couponInputValue,disabled:!!this.currentCoupon||this.isApplying,onInput:this.onInput,onKeyUp:this.onKeyUp,"aria-label":salla.lang.get("pages.cart.apply_coupon"),key:"coupon-input"}),o("salla-button",{ref:t=>this.couponButtonRef=t,class:"s-cart-coupons-coupon-button "+(this.currentCoupon?"s-cart-coupons-coupon-button-remove":"s-cart-coupons-coupon-button-apply"),color:this.currentCoupon?"danger":"primary",loading:this.isApplying,"loader-position":"center",onClick:()=>this.handleCouponButtonClick(),key:"apply-button"},this.currentCoupon?o("i",{class:"sicon-cancel"}):o("span",null,salla.lang.get("pages.cart.save_coupon")))]),this.couponError&&o("span",{key:"1e2bb51904486fe5e0cb3f842965a7b330ef7e91",class:"s-cart-coupons-coupon-error"},this.couponError)),t.length>0&&o("salla-slider",{type:"carousel",showControls:!1,class:"s-cart-coupons-slider",key:t.map((t=>t.code)).join("|")},o("div",{key:"c83306bce90ca9a62b13b39718d9941dcc6da498",slot:"items"},t.map((t=>this.renderCouponCard(t)))))))}get host(){return a(this)}};s.style='/*!twlt*/@charset "UTF-8";.s-cart-coupons-card--applied{cursor:default}.s-cart-coupons-card--applied:hover{transform:none}.s-cart-coupons-card--applied .s-cart-coupons-top-section,.s-cart-coupons-card--applied .s-cart-coupons-bottom-section,.s-cart-coupons-card--applied .s-cart-coupons-divider{border-color:#d1d5db;border-color:color-mix(in srgb, var(--color-primary, #004d5a) 40%, transparent)}.s-cart-coupons-card--applied .s-cart-coupons-bottom-section{background:rgba(0, 0, 0, 0.04);background:color-mix(in srgb, var(--color-primary, #004d5a) 8%, transparent)}.s-cart-coupons-card--applied::before,.s-cart-coupons-card--applied::after{border-color:#d1d5db;border-color:color-mix(in srgb, var(--color-primary, #004d5a) 40%, transparent)}.s-cart-coupons-card--applied .s-cart-coupons-action{display:inline-flex;align-items:center;gap:10px}.s-cart-coupons-card--applied .s-cart-coupons-action{font-size:10px;font-weight:600;color:#4b5563}.s-cart-coupons-card-applied-label{color:#4b5563;color:var(--color-primary-dark, var(--color-primary, #4b5563))}.s-cart-coupons-card--applied .s-cart-coupons-action{min-width:0;max-width:100%}.s-cart-coupons-card-applied-label,.s-cart-coupons-card-remove{overflow:hidden;text-overflow:ellipsis}.s-cart-coupons-card--applied .s-cart-coupons-action,.s-cart-coupons-card--applied .s-cart-coupons-card-remove{pointer-events:auto}.s-cart-coupons-card-remove{flex:none;font-size:inherit;font-weight:inherit;color:#6b7280;background:transparent;border:0;padding:0;cursor:pointer;transition:color 0.15s ease}.s-cart-coupons-card-remove:hover{color:var(--color-danger, #ef4444)}.s-cart-coupons-card-remove:disabled{opacity:0.5;cursor:not-allowed}.s-cart-coupons-card--minimal .s-cart-coupons-bottom-section{justify-content:flex-end}.visible{visibility:visible}.fixed{position:fixed}.shrink{flex-shrink:1}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.form-input{height:2.5rem;width:100%;border-radius:0.375rem;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.form-input:focus{border-color:var(--color-primary);--tw-ring-color:transparent}.form-input:is(.dark *){--tw-border-opacity:1;border-color:rgb(75 85 99 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(75 85 99 / var(--tw-bg-opacity, 1))}.form-input:focus:is(.dark *){border-color:var(--color-primary)}@media (min-width: 640px){.form-input{font-size:0.875rem;line-height:1.25rem}}.s-cart-coupons-wrapper{display:block;width:100%;padding-top:1.25rem;padding-bottom:1.25rem}.s-cart-coupons-input-section{margin-bottom:0.625rem}.s-cart-coupons-coupon-label{margin-bottom:0.625rem;display:block;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-cart-coupons-coupon-input-container{position:relative;display:flex;align-items:stretch}.s-cart-coupons-coupon-input-container .form-input{height:auto;flex:1 1 0%}.s-cart-coupons-coupon-input-container .form-input:where([dir="ltr"],[dir="ltr"] *){border-top-left-radius:0.5rem;border-bottom-left-radius:0.5rem;border-top-right-radius:0px !important;border-bottom-right-radius:0px !important;border-right-width:0px}.s-cart-coupons-coupon-input-container .form-input:where([dir="rtl"],[dir="rtl"] *){border-top-right-radius:0.5rem;border-bottom-right-radius:0.5rem;border-top-left-radius:0px !important;border-bottom-left-radius:0px !important;border-left-width:0px}.s-cart-coupons-coupon-input-container .form-input:focus{position:relative;z-index:10}.s-cart-coupons-coupon-button:where([dir="ltr"],[dir="ltr"] *){border-top-right-radius:0.5rem;border-bottom-right-radius:0.5rem;border-top-left-radius:0px;border-bottom-left-radius:0px}.s-cart-coupons-coupon-button:where([dir="rtl"],[dir="rtl"] *){border-top-left-radius:0.5rem;border-bottom-left-radius:0.5rem;border-top-right-radius:0px;border-bottom-right-radius:0px}.s-cart-coupons-coupon-button-remove:where([dir="ltr"],[dir="ltr"] *){border-top-right-radius:0.5rem;border-bottom-right-radius:0.5rem;border-top-left-radius:0px !important;border-bottom-left-radius:0px !important}.s-cart-coupons-coupon-button-remove:where([dir="rtl"],[dir="rtl"] *){border-top-left-radius:0.5rem;border-bottom-left-radius:0.5rem;border-top-right-radius:0px !important;border-bottom-right-radius:0px !important}.s-cart-coupons-coupon-button-apply:where([dir="ltr"],[dir="ltr"] *){border-top-right-radius:0.5rem !important;border-bottom-right-radius:0.5rem !important;border-top-left-radius:0px !important;border-bottom-left-radius:0px !important}.s-cart-coupons-coupon-button-apply:where([dir="rtl"],[dir="rtl"] *){border-top-left-radius:0.5rem !important;border-bottom-left-radius:0.5rem !important;border-top-right-radius:0px !important;border-bottom-right-radius:0px !important}.s-cart-coupons-coupon-error{margin-top:0.5rem;display:block;font-size:10px;line-height:1rem;--tw-text-opacity:1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.s-cart-coupons-slider{width:100%;overflow:hidden;padding-left:0.375rem;padding-right:0.375rem}.s-cart-coupons-card{position:relative;cursor:pointer;overflow:hidden;--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-cart-coupons-card:is(.dark *){--tw-bg-opacity:1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.s-cart-coupons-card:hover{--tw-translate-y:-0.125rem;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.s-cart-coupons-disabled{cursor:not-allowed;opacity:0.5}.s-cart-coupons-disabled:hover{transform:none;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.s-cart-coupons-top-section{display:flex;height:60px;flex-direction:row;align-items:center;justify-content:space-between;border-top-left-radius:0.75rem;border-top-right-radius:0.75rem;border-width:1px;border-bottom-width:0px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));padding-top:1rem;padding-bottom:1rem;padding-left:0.75rem;padding-right:0.75rem}.s-cart-coupons-discount-values{display:flex;flex-direction:column;align-items:flex-start}.s-cart-coupons-discount-values .s-cart-coupons-main-amount{display:flex;align-items:center;gap:0.25rem;white-space:nowrap;font-size:1.25rem;line-height:1.75rem;font-weight:900;line-height:1;--tw-text-opacity:1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.s-cart-coupons-discount-values .s-cart-coupons-secondary-info{margin:0px;font-size:10px;line-height:1rem}.s-cart-coupons-code{font-size:10px;font-weight:700;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-cart-coupons-divider{position:relative;z-index:10;margin:0px;border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.s-cart-coupons-bottom-section{display:flex;min-height:44px;flex-direction:row;align-items:center;justify-content:space-between;border-bottom-right-radius:0.75rem;border-bottom-left-radius:0.75rem;border-width:1px;border-top-width:0px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding-top:0.25rem;padding-bottom:0.25rem;padding-left:0.75rem;padding-right:0.75rem}.s-cart-coupons-terms{display:flex;flex-direction:column;align-items:flex-start}.s-cart-coupons-terms .s-cart-coupons-expiry{margin:0px;font-size:10px;line-height:16px;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-cart-coupons-terms .s-cart-coupons-minimum{margin:0px;font-size:10px;line-height:16px;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-cart-coupons-terms .s-cart-coupons-expiry.s-cart-coupons-expiry-warning{font-weight:500;--tw-text-opacity:1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.s-cart-coupons-action{cursor:pointer;white-space:nowrap;border-width:0px;background-color:transparent;padding:0px;font-size:9px;font-weight:700;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1));transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms}.s-cart-coupons-action:hover{--tw-text-opacity:1;color:rgb(59 130 246 / var(--tw-text-opacity, 1))}.s-cart-coupons-slide-one-fourth{width:calc(75% - 10px);min-width:200px !important;padding-left:5px !important;padding-right:5px !important;padding-top:2px !important}@media (min-width: 1024px){.s-cart-coupons-slide-one-fourth{width:calc(40% - 10px) !important}}.s-cart-coupons-card:before{pointer-events:none;position:absolute;right:-10px;top:60px;z-index:20;height:1.25rem;width:1.25rem;--tw-translate-y:-50%;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));border-radius:9999px;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));--tw-content:\'\';content:var(--tw-content)}.s-cart-coupons-card:is(.dark *):before{--tw-bg-opacity:1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.s-cart-coupons-card:after{pointer-events:none;position:absolute;left:-10px;top:60px;z-index:20;height:1.25rem;width:1.25rem;--tw-translate-y:-50%;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));border-radius:9999px;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));--tw-content:\'\';content:var(--tw-content)}.s-cart-coupons-card:is(.dark *):after{--tw-bg-opacity:1;background-color:rgb(31 41 55 / var(--tw-bg-opacity, 1))}.s-cart-coupons-coupon-input-container .form-input.s-coupon-input-error{--tw-shadow:0 0 0 3px rgba(239,68,68,0.1) !important;--tw-shadow-colored:0 0 0 3px var(--tw-shadow-color) !important;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow) !important}';export{s as salla_cart_coupons}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as t,c as s,h as i,H as e,a as n}from"./p-C9GauqTa.js";import{A as o}from"./p-BuGRUUN_.js";import{A as l}from"./p-CcEEx00d.js";const d=class{constructor(i){t(this,i),this.optionsSaved=s(this,"optionsSaved"),this.productSelected=s(this,"productSelected"),this.product=null,this.sectionId=null,this.sectionIndex=0,this.productIndex=0,this.selectedOptions={},this.optionsResetTokens={},this.isLoading=!1,this.hasUnsavedChanges=!1,this.validationErrors=[],this.isProductAlreadySelected=!1}generateCacheKey(t,s,i){return`${t||"unknown"}-${s||0}-${i||"unknown"}`}handleProductChange(t){setTimeout((()=>{this.modal&&t&&this.modal.setTitle(t.name||"")}),100),this.validationErrors=[],this.hasUnsavedChanges=!1}async open(){this.modal?(this.isLoading=!0,this.product?.name&&this.modal.setTitle(this.product.name),this.modal.open(),setTimeout((async()=>{this.product?.id&&await this.initializeSelectedOptions(),this.product?.name&&this.modal.setTitle(this.product.name),this.modal.stopLoading(),this.isLoading=!1}),300)):requestAnimationFrame((()=>this.open()))}async close(){this.modal&&this.modal.close()}async refreshOptionsState(){this.selectedOptions={...this.selectedOptions}}componentDidLoad(){this.modalOpenListener=t=>{this.product=t.product,this.sectionId=t.sectionId||null,this.sectionIndex=t.sectionIndex||0,this.productIndex=t.productIndex||0,this.isProductAlreadySelected=!!t.isProductAlreadySelected,this.open()},salla.event.on("multiple-bundle-product-modal::open",this.modalOpenListener),this.clearOptionsListener=t=>{t&&t.productId&&this.clearProductOptions(t.productId,t.sectionId,t.productIndex)},salla.event.on("multiple-bundle-product-modal::clear-options",this.clearOptionsListener),this.optionChangeListener=t=>{const s=t.detail||t,{option:i,detail:e}=s,n=i||s.option_id&&this.product?.options?.find((t=>t.id===s.option_id||String(t.id)===String(s.option_id))),o=e||(s.id?s:null);this.product?.id&&n&&this.handleOptionChange(Number(this.product.id),n,o)},salla.event.on("product-options::change",this.optionChangeListener),this.checkboxChangeListener=t=>{const s=t.target;if(s&&"checkbox"===s.type&&s.name&&s.name.includes("bundle[")&&s.name.includes("][id]")){const t=s.name.match(/^bundle\[([^\]]+)\]\[([^\]]+)\]\[id\]$/);if(t&&!s.checked){if("true"===s.getAttribute("data-selection-locked"))return void(s.checked=!0);const[,i,e]=t,n=s.value,o=this.host.closest("form");this.cleanupProductDeselection({sectionId:i,productIndex:parseInt(e,10),productId:n,form:o,uncheckedInput:s})}}},document.addEventListener("change",this.checkboxChangeListener)}disconnectedCallback(){this.checkboxChangeListener&&document.removeEventListener("change",this.checkboxChangeListener),this.optionChangeListener&&salla.event.off("product-options::change",this.optionChangeListener),this.modalOpenListener&&salla.event.off("multiple-bundle-product-modal::open",this.modalOpenListener),this.clearOptionsListener&&salla.event.off("multiple-bundle-product-modal::clear-options",this.clearOptionsListener)}cleanupProductDeselection(t){const{sectionId:s,productIndex:i,productId:e,form:n,uncheckedInput:o}=t;if(this.clearProductOptions(e,s,i),n){const t=`bundle[${s}][${i}]`;Array.from(n.querySelectorAll(`input[name^="${t}"]`)).forEach((s=>{if(s===o)return;const i="hidden"===s.type,n=s.getAttribute("data-product-id")===String(e)&&s.name?.startsWith(t);(i||n)&&s.remove()})),requestAnimationFrame((()=>{const t=new window.Event("change",{bubbles:!0});n.dispatchEvent(t)}))}}generateFormInputName(t,s,i){return`bundle[${t}][${s}][options][${i}]`}async initializeSelectedOptions(){if(!this.product?.id)return;const t=this.product.id,s=this.generateCacheKey(this.sectionId,this.productIndex,t),i=document.querySelector(`salla-product-options[product-id="${t}"]`);if(i)try{const t=await i.getSelectedOptions();t&&t.length>0&&(this.selectedOptions={...this.selectedOptions,[s]:t})}catch(t){console.warn("Could not initialize selected options:",t)}}clearProductOptions(t,s,i){const e={...this.selectedOptions};if(null==s||null==i||Number.isNaN(i)){const s=`-${String(t)}`,i=[];Object.keys(e).forEach((t=>{t.endsWith(s)&&(delete e[t],i.push(t))})),i.forEach((t=>this.bumpOptionsResetToken(t)))}else{const n=this.generateCacheKey(s,i,t);delete e[n],this.bumpOptionsResetToken(n)}this.selectedOptions=e,this.validationErrors=[],this.hasUnsavedChanges=!1}bumpOptionsResetToken(t){t&&(this.optionsResetTokens={...this.optionsResetTokens,[t]:(this.optionsResetTokens[t]||0)+1})}async handleOptionChange(t,s,i){const e=this.generateCacheKey(this.sectionId,this.productIndex,t),n=document.querySelector(`salla-product-options[product-id="${t}"]`);let o=[];if(n)try{o=await n.getSelectedOptions()||[]}catch(t){console.warn("Could not get current selections from component:",t)}if(o.length>0)this.selectedOptions={...this.selectedOptions,[e]:o};else if(this.selectedOptions[e]&&this.selectedOptions[e].length>0){const t=[...this.selectedOptions[e]||[]],n=t.findIndex((t=>t.option_id===s.id));n>-1?i&&null!=i.id?t[n]={...i,option_id:s.id}:t.splice(n,1):i&&null!=i.id&&t.push({...i,option_id:s.id}),this.selectedOptions={...this.selectedOptions,[e]:t}}else i&&null!=i.id&&(this.selectedOptions={...this.selectedOptions,[e]:[{...i,option_id:s.id}]});this.hasUnsavedChanges=!0,this.validationErrors=[]}async validateOptions(){if(!this.product?.options)return!0;const t=[],s=this.product.id,i=this.generateCacheKey(this.sectionId,this.productIndex,s),e=document.querySelector(`salla-product-options[product-id="${s}"]`);let n=[];if(e)try{n=await e.getSelectedOptions()||[];const t=this.selectedOptions[i]||[];(t.length>n.length||0===n.length&&t.length>0)&&(n=t)}catch(t){n=this.selectedOptions[i]||[]}else n=this.selectedOptions[i]||[];return 0===n.length&&t.push(salla.lang.get("pages.products.no_options_selected")),this.product.options.forEach((s=>{s.required&&(n.some((t=>t.option_id==s.id))||t.push(salla.lang.get("pages.products.required_option_missing",{option:s.name})))})),this.validationErrors=t,0===t.length}async onSave(t){t.preventDefault();const s=this.product?.id;if(!s)return;const i=this.generateCacheKey(this.sectionId,this.productIndex,s);if(await new Promise((t=>setTimeout(t,100))),await this.validateOptions()){if(!this.isProductAlreadySelected&&null!=this.sectionId){const t=this.host.closest("salla-multiple-bundle-product-details");if(!await(t?.canSelectBundleProduct(this.sectionId,s)))return void salla.notify.error(salla.lang.getWithDefault("pages.products.bundle_selection_limit_reached","لا يمكنك اختيار المزيد من المنتجات في هذا القسم"))}this.isLoading=!0;try{const t=document.querySelector(`salla-product-options[product-id="${s}"]`);let e=await(t?.getSelectedOptions());if((!e||0===e.length)&&this.selectedOptions[i]?.length>0&&(e=this.selectedOptions[i]),!e||0===e.length)return void(this.isLoading=!1);this.selectedOptions={...this.selectedOptions,[i]:e};const n=this.host.closest("form");if(!n)return void(this.isLoading=!1);const o=`bundle[${this.sectionId}][${this.productIndex}]`;Array.from(n.querySelectorAll(`input[name^="${o}"][type="hidden"]`)).forEach((t=>t.remove())),Array.from(n.querySelectorAll(`[data-product-id="${s}"][name^="${o}"]`)).forEach((t=>t.remove()));const l=`bundle[${this.sectionId}][${this.productIndex}][id]`,d=document.getElementById(l);if(d)d.checked=!0;else{const t=document.createElement("input");t.type="hidden",t.name=`bundle[${this.sectionId}][${this.productIndex}][id]`,t.value=String(s),t.dataset.productId=String(s),n.appendChild(t)}e.forEach((t=>{const i=t.option_id,e=document.createElement("input");e.type="hidden",e.name=this.generateFormInputName(this.sectionId,this.productIndex??0,i),e.value=String(t.id),e.dataset.productId=String(s),n.appendChild(e)}));const a=new window.Event("change",{bubbles:!0});n.dispatchEvent(a),this.optionsSaved.emit({productId:Number(s),selectedOptions:e,sectionId:this.sectionId,productIndex:this.productIndex}),this.sectionId&&this.productSelected.emit({productId:Number(s),sectionId:this.sectionId,product:this.product,fromModal:!0}),salla.notify.success(salla.lang.get("pages.products.options_saved")),this.hasUnsavedChanges=!1,this.validationErrors=[],this.modal.close()}catch(t){salla.notify.error(salla.lang.get("pages.products.options_save_error"))}finally{this.isLoading=!1}}else salla.notify.error(this.validationErrors.join(", "))}getOptionsWithSelectedState(){if(!this.product?.options)return[];const t=this.generateCacheKey(this.sectionId,this.productIndex,this.product.id),s=this.selectedOptions[t]||[];return this.product.options.map((t=>({...t,details:t.details.map((t=>{const i=s.some((s=>s.id===t.id));return{...t,is_selected:i}}))})))}render(){const t=this.product?.id,s=this.getOptionsWithSelectedState(),n=this.generateCacheKey(this.sectionId,this.productIndex,t),o=this.optionsResetTokens[n]||0,l=this.isLoading||s.some((t=>t.details.some((t=>t.is_selected&&!0===t.is_out))));return i(e,{key:"74f5fc9c02a5ea10a9d92d2427df05210740f3e4"},i("salla-modal",{key:"a00db7e88d2687ef106c3c384cd94b7d7b2ed443",isLoading:this.isLoading,ref:t=>this.modal=t,width:"md",centered:!1,id:`s-multiple-bundle-product-options-modal-options-${t}`,class:"s-multiple-bundle-product-options-modal-wrapper"},i("div",{key:"5ee1738c87ad75f7e812aefb3ea04b71f153673a",slot:"loading"},i("salla-skeleton",{key:"ebb0bf70a092958bd4241e4b7bc42922efed87dc",height:"100%",width:"100%"})),this.product?.images&&this.product?.images.length>0&&i("salla-slider",{key:"871db23f2811753e3f469a8e12483f4fd3166a40",id:`details-slider-${this.product?.id}`,type:"thumbs",loop:!1,"auto-height":!0,"listen-to-thumbnails-option":!0,showThumbsControls:!1,controlsOuter:!1,showControls:!1,class:"s-multiple-bundle-product-options-modal-slider",verticalThumbs:!0,thumbsConfig:{centeredSlides:!0,centeredSlidesBounds:!0,slidesPerView:Math.min(5,Math.max(1,this.product?.images.length)),watchOverflow:!0,watchSlidesProgress:!0,direction:"vertical",spaceBetween:10}},i("div",{key:"a80a29966c883094655558cdd861938f8c2c505f",slot:"items"},this.product?.images&&this.product?.images.map(((t,s)=>i("div",{key:s,class:"swiper-slide"},i("img",{src:t.url,alt:t.alt||`${this.product?.name} - Image ${s+1}`,loading:"lazy",onError:t=>{t.target.style.display="none"}}))))),this.product?.images&&this.product?.images.length>1&&i("div",{key:"bb38eec9d89c6fc1afbea740d23f21ea3b83892f",slot:"thumbs"},this.product?.images&&this.product?.images.map(((t,s)=>i("div",{key:s,"data-caption":`${this.product?.name} - Image ${s+1}`},i("img",{src:t.url,loading:"eager",class:"s-multiple-bundle-product-options-modal-slider-thumb",title:`${this.product?.name} - ${s+1}`,alt:t.alt||`${this.product?.name} - ${s+1}`,onError:t=>{t.target.style.display="none"}})))))),i("salla-product-options",{options:JSON.stringify(s),key:`${n}-reset-${o}`,"product-id":t,"unique-key":`${n}-reset-${o}`}),i("div",{key:"b18dbbdcbb37ff8fb61ec4be551c5d07cc04286e",slot:"footer"},i("div",{key:"1b71874c06aa379b515a1239fb9059da11e92609",class:"s-multiple-bundle-product-options-modal-footer"},i("salla-button",{key:"83db878dffdef845db6f904c9486d5c4cd003f31",onClick:t=>this.onSave(t),loading:this.isLoading,disabled:l},this.isLoading?salla.lang.get("common.elements.saving"):salla.lang.get("common.elements.save"))))))}get host(){return n(this)}static get watchers(){return{product:["handleProductChange"]}}};d.style=":host{display:block}";const a=class{constructor(i){t(this,i),this.productSelected=s(this,"productSelected"),this.productOptionsSelected=s(this,"productOptionsSelected"),this.selectedProducts={},this.isSelectionLocked=!1,this.selectionLimit=0,this.savedOptionsByInstance={},this.handleProductClick=(t,s)=>{const i=this.selectedProducts[this.section.id]?.has(t.id)||!1,e=this.getCheckbox(this.section.id,s);if(i&&this.isSelectionLocked)return void(e&&(e.checked=!0));if(!i&&this.isMaxSelectionReached()&&1!==this.selectionLimit)return;if(1===this.selectionLimit&&!i)return void this.productSelected.emit({product:t,sectionId:this.section.id});if(!e)return;const n=!e.checked;n||(this.dispatchClearOptionsEvent(t,s),this.clearSavedOptionsState(this.section.id,s)),e.checked=n,requestAnimationFrame((()=>{const t=new window.Event("change",{bubbles:!0});e.dispatchEvent(t)})),this.productSelected.emit({product:t,sectionId:this.section.id})},this.handleOptionsClick=t=>{!this.selectedProducts[this.section.id]?.has(t.id)&&this.isMaxSelectionReached()&&1!==this.selectionLimit||this.productOptionsSelected.emit({product:t,sectionId:this.section.id})}}getSelectedCount(){return this.selectedProducts[this.section?.id]?.size??0}isMaxSelectionReached(){return this.selectionLimit>1&&this.getSelectedCount()>=this.selectionLimit}isProductSelectionDisabled(t,s){return 0===t.quantity||!s&&this.isMaxSelectionReached()}getProductInstanceKey(t,s){return`${t}::${s}`}dispatchClearOptionsEvent(t,s){salla.event.dispatch("multiple-bundle-product-modal::clear-options",{productId:t.id,sectionId:this.section.id,sectionIndex:this.sectionIndex,productIndex:s})}handleOptionsSaved(t){const s=t.detail;if(!s)return;const{sectionId:i,productIndex:e,selectedOptions:n}=s;if(null==i||i!==this.section?.id)return;if(null==e||Number.isNaN(e))return;const o=this.getProductInstanceKey(i,e);if(n?.length)this.savedOptionsByInstance={...this.savedOptionsByInstance,[o]:!0};else if(this.savedOptionsByInstance[o]){const t={...this.savedOptionsByInstance};delete t[o],this.savedOptionsByInstance=t}}clearSavedOptionsState(t,s){const i=this.getProductInstanceKey(t,s);if(!this.savedOptionsByInstance[i])return;const e={...this.savedOptionsByInstance};delete e[i],this.savedOptionsByInstance=e}generateEventName(t,s){return`bundle[${t}][${s}][id]`}getCheckbox(t,s){const i=this.generateEventName(t,s);return this.host.querySelector(`input.s-multiple-bundle-product-checkbox[name="${i}"]`)}preventLockedDeselect(t,s){if(!this.isSelectionLocked||!s)return;t.preventDefault(),t.stopPropagation();const i=t.target;"checkbox"===i?.type&&(i.checked=!0)}render(){return i(e,{key:"17d96d9983fdb033c32d77228f52030ee408d856",class:"s-multiple-bundle-product-slider"},i("salla-slider",{key:"fe99a686cec9fe71728e651d1228564af1236483",type:"carousel",controlsOuter:!1,showControls:!1,id:`accordion-multiple-bundle-product-${this.section.id}`,pagination:!0,class:"s-multiple-bundle-product-wrapper-slider",sliderConfig:{spaceBetween:0}},i("div",{key:"2517a2b14ed787c32e1782fa7af04339660a0344",slot:"items"},this?.section?.products?.map(((t,s)=>{const e=this.selectedProducts[this.section.id]?.has(t.id)||!1,n=e&&this.isSelectionLocked,d=this.isProductSelectionDisabled(t,e),a=this.savedOptionsByInstance[this.getProductInstanceKey(this.section.id,s)]?salla.lang.getWithDefault("pages.products.edit_selected_options","تعديل الخيارات"):salla.lang.get("pages.products.choose_from_options");let c=salla.config.get("theme.is_rtl",!0)?o:l;return i("div",{class:"s-multiple-bundle-product-slide-one-third"+(d?" s-multiple-bundle-product-slide-one-third-disabled":""),key:t.id},i("div",{class:"s-multiple-bundle-product-card"},i("div",{class:"s-multiple-bundle-product-image-wrapper",onClick:()=>this.handleProductClick(t,s)},i("input",{id:this.generateEventName(this.section.id,s),type:"checkbox",class:"s-multiple-bundle-product-checkbox",checked:e,"data-selection-locked":n?"true":void 0,name:this.generateEventName(this.section.id,s),value:t.id,onClick:t=>this.preventLockedDeselect(t,e),onChange:t=>this.preventLockedDeselect(t,e)}),i("img",{src:t.image.url||salla.url.cdn("images/s-empty.png"),loading:"lazy",alt:t.image.alt||t.name,class:"s-multiple-bundle-product-image"})),i("div",{class:"s-multiple-bundle-product-content-wrapper"},i("div",{class:"s-multiple-bundle-product-content"},i("div",{class:"s-multiple-bundle-product-details"},i("div",{class:"s-multiple-bundle-product-title-wrapper"},i("h2",{class:"s-multiple-bundle-product-title"},i("a",{href:t?.url||"#",target:"_blank",rel:"noopener noreferrer"},t.name))),i("div",{class:"s-multiple-bundle-product-price-wrapper"},i("span",{class:"s-multiple-bundle-product-price"},i("span",{innerHTML:salla.money(t.price)})),t.sale_price>0&&i("span",{class:"s-multiple-bundle-product-price-discount"},i("span",{innerHTML:salla.money(t.regular_price)})))),t.quantity_in_group>0&&0!==t.quantity&&i("span",{class:"s-multiple-bundle-product-badge"},salla.lang.get("pages.products.pieces"),i("span",null,t.quantity_in_group)),0===t.quantity&&i("span",{class:"s-multiple-bundle-product-badge"},salla.lang.get("pages.products.quantity_in_group_finished"))),t.options?.length>0&&i("button",{class:"s-multiple-bundle-product-button",onClick:()=>this.handleOptionsClick(t),type:"button"},a,i("span",{class:"s-multiple-bundle-product-button-icon",innerHTML:c})))))})))))}get host(){return n(this)}};a.style="";export{d as salla_multiple_bundle_product_options_modal,a as salla_multiple_bundle_product_slider}
|
|
4
|
+
import{r as t,c as s,h as i,H as e,a as n}from"./p-BNekvDFW.js";import{A as o}from"./p-BuGRUUN_.js";import{A as l}from"./p-CcEEx00d.js";const d=class{constructor(i){t(this,i),this.optionsSaved=s(this,"optionsSaved"),this.productSelected=s(this,"productSelected"),this.product=null,this.sectionId=null,this.sectionIndex=0,this.productIndex=0,this.selectedOptions={},this.optionsResetTokens={},this.isLoading=!1,this.hasUnsavedChanges=!1,this.validationErrors=[],this.isProductAlreadySelected=!1}generateCacheKey(t,s,i){return`${t||"unknown"}-${s||0}-${i||"unknown"}`}handleProductChange(t){setTimeout((()=>{this.modal&&t&&this.modal.setTitle(t.name||"")}),100),this.validationErrors=[],this.hasUnsavedChanges=!1}async open(){this.modal?(this.isLoading=!0,this.product?.name&&this.modal.setTitle(this.product.name),this.modal.open(),setTimeout((async()=>{this.product?.id&&await this.initializeSelectedOptions(),this.product?.name&&this.modal.setTitle(this.product.name),this.modal.stopLoading(),this.isLoading=!1}),300)):requestAnimationFrame((()=>this.open()))}async close(){this.modal&&this.modal.close()}async refreshOptionsState(){this.selectedOptions={...this.selectedOptions}}componentDidLoad(){this.modalOpenListener=t=>{this.product=t.product,this.sectionId=t.sectionId||null,this.sectionIndex=t.sectionIndex||0,this.productIndex=t.productIndex||0,this.isProductAlreadySelected=!!t.isProductAlreadySelected,this.open()},salla.event.on("multiple-bundle-product-modal::open",this.modalOpenListener),this.clearOptionsListener=t=>{t&&t.productId&&this.clearProductOptions(t.productId,t.sectionId,t.productIndex)},salla.event.on("multiple-bundle-product-modal::clear-options",this.clearOptionsListener),this.optionChangeListener=t=>{const s=t.detail||t,{option:i,detail:e}=s,n=i||s.option_id&&this.product?.options?.find((t=>t.id===s.option_id||String(t.id)===String(s.option_id))),o=e||(s.id?s:null);this.product?.id&&n&&this.handleOptionChange(Number(this.product.id),n,o)},salla.event.on("product-options::change",this.optionChangeListener),this.checkboxChangeListener=t=>{const s=t.target;if(s&&"checkbox"===s.type&&s.name&&s.name.includes("bundle[")&&s.name.includes("][id]")){const t=s.name.match(/^bundle\[([^\]]+)\]\[([^\]]+)\]\[id\]$/);if(t&&!s.checked){if("true"===s.getAttribute("data-selection-locked"))return void(s.checked=!0);const[,i,e]=t,n=s.value,o=this.host.closest("form");this.cleanupProductDeselection({sectionId:i,productIndex:parseInt(e,10),productId:n,form:o,uncheckedInput:s})}}},document.addEventListener("change",this.checkboxChangeListener)}disconnectedCallback(){this.checkboxChangeListener&&document.removeEventListener("change",this.checkboxChangeListener),this.optionChangeListener&&salla.event.off("product-options::change",this.optionChangeListener),this.modalOpenListener&&salla.event.off("multiple-bundle-product-modal::open",this.modalOpenListener),this.clearOptionsListener&&salla.event.off("multiple-bundle-product-modal::clear-options",this.clearOptionsListener)}cleanupProductDeselection(t){const{sectionId:s,productIndex:i,productId:e,form:n,uncheckedInput:o}=t;if(this.clearProductOptions(e,s,i),n){const t=`bundle[${s}][${i}]`;Array.from(n.querySelectorAll(`input[name^="${t}"]`)).forEach((s=>{if(s===o)return;const i="hidden"===s.type,n=s.getAttribute("data-product-id")===String(e)&&s.name?.startsWith(t);(i||n)&&s.remove()})),requestAnimationFrame((()=>{const t=new window.Event("change",{bubbles:!0});n.dispatchEvent(t)}))}}generateFormInputName(t,s,i){return`bundle[${t}][${s}][options][${i}]`}async initializeSelectedOptions(){if(!this.product?.id)return;const t=this.product.id,s=this.generateCacheKey(this.sectionId,this.productIndex,t),i=document.querySelector(`salla-product-options[product-id="${t}"]`);if(i)try{const t=await i.getSelectedOptions();t&&t.length>0&&(this.selectedOptions={...this.selectedOptions,[s]:t})}catch(t){console.warn("Could not initialize selected options:",t)}}clearProductOptions(t,s,i){const e={...this.selectedOptions};if(null==s||null==i||Number.isNaN(i)){const s=`-${String(t)}`,i=[];Object.keys(e).forEach((t=>{t.endsWith(s)&&(delete e[t],i.push(t))})),i.forEach((t=>this.bumpOptionsResetToken(t)))}else{const n=this.generateCacheKey(s,i,t);delete e[n],this.bumpOptionsResetToken(n)}this.selectedOptions=e,this.validationErrors=[],this.hasUnsavedChanges=!1}bumpOptionsResetToken(t){t&&(this.optionsResetTokens={...this.optionsResetTokens,[t]:(this.optionsResetTokens[t]||0)+1})}async handleOptionChange(t,s,i){const e=this.generateCacheKey(this.sectionId,this.productIndex,t),n=document.querySelector(`salla-product-options[product-id="${t}"]`);let o=[];if(n)try{o=await n.getSelectedOptions()||[]}catch(t){console.warn("Could not get current selections from component:",t)}if(o.length>0)this.selectedOptions={...this.selectedOptions,[e]:o};else if(this.selectedOptions[e]&&this.selectedOptions[e].length>0){const t=[...this.selectedOptions[e]||[]],n=t.findIndex((t=>t.option_id===s.id));n>-1?i&&null!=i.id?t[n]={...i,option_id:s.id}:t.splice(n,1):i&&null!=i.id&&t.push({...i,option_id:s.id}),this.selectedOptions={...this.selectedOptions,[e]:t}}else i&&null!=i.id&&(this.selectedOptions={...this.selectedOptions,[e]:[{...i,option_id:s.id}]});this.hasUnsavedChanges=!0,this.validationErrors=[]}async validateOptions(){if(!this.product?.options)return!0;const t=[],s=this.product.id,i=this.generateCacheKey(this.sectionId,this.productIndex,s),e=document.querySelector(`salla-product-options[product-id="${s}"]`);let n=[];if(e)try{n=await e.getSelectedOptions()||[];const t=this.selectedOptions[i]||[];(t.length>n.length||0===n.length&&t.length>0)&&(n=t)}catch(t){n=this.selectedOptions[i]||[]}else n=this.selectedOptions[i]||[];return 0===n.length&&t.push(salla.lang.get("pages.products.no_options_selected")),this.product.options.forEach((s=>{s.required&&(n.some((t=>t.option_id==s.id))||t.push(salla.lang.get("pages.products.required_option_missing",{option:s.name})))})),this.validationErrors=t,0===t.length}async onSave(t){t.preventDefault();const s=this.product?.id;if(!s)return;const i=this.generateCacheKey(this.sectionId,this.productIndex,s);if(await new Promise((t=>setTimeout(t,100))),await this.validateOptions()){if(!this.isProductAlreadySelected&&null!=this.sectionId){const t=this.host.closest("salla-multiple-bundle-product-details");if(!await(t?.canSelectBundleProduct(this.sectionId,s)))return void salla.notify.error(salla.lang.getWithDefault("pages.products.bundle_selection_limit_reached","لا يمكنك اختيار المزيد من المنتجات في هذا القسم"))}this.isLoading=!0;try{const t=document.querySelector(`salla-product-options[product-id="${s}"]`);let e=await(t?.getSelectedOptions());if((!e||0===e.length)&&this.selectedOptions[i]?.length>0&&(e=this.selectedOptions[i]),!e||0===e.length)return void(this.isLoading=!1);this.selectedOptions={...this.selectedOptions,[i]:e};const n=this.host.closest("form");if(!n)return void(this.isLoading=!1);const o=`bundle[${this.sectionId}][${this.productIndex}]`;Array.from(n.querySelectorAll(`input[name^="${o}"][type="hidden"]`)).forEach((t=>t.remove())),Array.from(n.querySelectorAll(`[data-product-id="${s}"][name^="${o}"]`)).forEach((t=>t.remove()));const l=`bundle[${this.sectionId}][${this.productIndex}][id]`,d=document.getElementById(l);if(d)d.checked=!0;else{const t=document.createElement("input");t.type="hidden",t.name=`bundle[${this.sectionId}][${this.productIndex}][id]`,t.value=String(s),t.dataset.productId=String(s),n.appendChild(t)}e.forEach((t=>{const i=t.option_id,e=document.createElement("input");e.type="hidden",e.name=this.generateFormInputName(this.sectionId,this.productIndex??0,i),e.value=String(t.id),e.dataset.productId=String(s),n.appendChild(e)}));const a=new window.Event("change",{bubbles:!0});n.dispatchEvent(a),this.optionsSaved.emit({productId:Number(s),selectedOptions:e,sectionId:this.sectionId,productIndex:this.productIndex}),this.sectionId&&this.productSelected.emit({productId:Number(s),sectionId:this.sectionId,product:this.product,fromModal:!0}),salla.notify.success(salla.lang.get("pages.products.options_saved")),this.hasUnsavedChanges=!1,this.validationErrors=[],this.modal.close()}catch(t){salla.notify.error(salla.lang.get("pages.products.options_save_error"))}finally{this.isLoading=!1}}else salla.notify.error(this.validationErrors.join(", "))}getOptionsWithSelectedState(){if(!this.product?.options)return[];const t=this.generateCacheKey(this.sectionId,this.productIndex,this.product.id),s=this.selectedOptions[t]||[];return this.product.options.map((t=>({...t,details:t.details.map((t=>{const i=s.some((s=>s.id===t.id));return{...t,is_selected:i}}))})))}render(){const t=this.product?.id,s=this.getOptionsWithSelectedState(),n=this.generateCacheKey(this.sectionId,this.productIndex,t),o=this.optionsResetTokens[n]||0,l=this.isLoading||s.some((t=>t.details.some((t=>t.is_selected&&!0===t.is_out))));return i(e,{key:"74f5fc9c02a5ea10a9d92d2427df05210740f3e4"},i("salla-modal",{key:"a00db7e88d2687ef106c3c384cd94b7d7b2ed443",isLoading:this.isLoading,ref:t=>this.modal=t,width:"md",centered:!1,id:`s-multiple-bundle-product-options-modal-options-${t}`,class:"s-multiple-bundle-product-options-modal-wrapper"},i("div",{key:"5ee1738c87ad75f7e812aefb3ea04b71f153673a",slot:"loading"},i("salla-skeleton",{key:"ebb0bf70a092958bd4241e4b7bc42922efed87dc",height:"100%",width:"100%"})),this.product?.images&&this.product?.images.length>0&&i("salla-slider",{key:"871db23f2811753e3f469a8e12483f4fd3166a40",id:`details-slider-${this.product?.id}`,type:"thumbs",loop:!1,"auto-height":!0,"listen-to-thumbnails-option":!0,showThumbsControls:!1,controlsOuter:!1,showControls:!1,class:"s-multiple-bundle-product-options-modal-slider",verticalThumbs:!0,thumbsConfig:{centeredSlides:!0,centeredSlidesBounds:!0,slidesPerView:Math.min(5,Math.max(1,this.product?.images.length)),watchOverflow:!0,watchSlidesProgress:!0,direction:"vertical",spaceBetween:10}},i("div",{key:"a80a29966c883094655558cdd861938f8c2c505f",slot:"items"},this.product?.images&&this.product?.images.map(((t,s)=>i("div",{key:s,class:"swiper-slide"},i("img",{src:t.url,alt:t.alt||`${this.product?.name} - Image ${s+1}`,loading:"lazy",onError:t=>{t.target.style.display="none"}}))))),this.product?.images&&this.product?.images.length>1&&i("div",{key:"bb38eec9d89c6fc1afbea740d23f21ea3b83892f",slot:"thumbs"},this.product?.images&&this.product?.images.map(((t,s)=>i("div",{key:s,"data-caption":`${this.product?.name} - Image ${s+1}`},i("img",{src:t.url,loading:"eager",class:"s-multiple-bundle-product-options-modal-slider-thumb",title:`${this.product?.name} - ${s+1}`,alt:t.alt||`${this.product?.name} - ${s+1}`,onError:t=>{t.target.style.display="none"}})))))),i("salla-product-options",{options:JSON.stringify(s),key:`${n}-reset-${o}`,"product-id":t,"unique-key":`${n}-reset-${o}`}),i("div",{key:"b18dbbdcbb37ff8fb61ec4be551c5d07cc04286e",slot:"footer"},i("div",{key:"1b71874c06aa379b515a1239fb9059da11e92609",class:"s-multiple-bundle-product-options-modal-footer"},i("salla-button",{key:"83db878dffdef845db6f904c9486d5c4cd003f31",onClick:t=>this.onSave(t),loading:this.isLoading,disabled:l},this.isLoading?salla.lang.get("common.elements.saving"):salla.lang.get("common.elements.save"))))))}get host(){return n(this)}static get watchers(){return{product:["handleProductChange"]}}};d.style=":host{display:block}";const a=class{constructor(i){t(this,i),this.productSelected=s(this,"productSelected"),this.productOptionsSelected=s(this,"productOptionsSelected"),this.selectedProducts={},this.isSelectionLocked=!1,this.selectionLimit=0,this.savedOptionsByInstance={},this.handleProductClick=(t,s)=>{const i=this.selectedProducts[this.section.id]?.has(t.id)||!1,e=this.getCheckbox(this.section.id,s);if(i&&this.isSelectionLocked)return void(e&&(e.checked=!0));if(!i&&this.isMaxSelectionReached()&&1!==this.selectionLimit)return;if(1===this.selectionLimit&&!i)return void this.productSelected.emit({product:t,sectionId:this.section.id});if(!e)return;const n=!e.checked;n||(this.dispatchClearOptionsEvent(t,s),this.clearSavedOptionsState(this.section.id,s)),e.checked=n,requestAnimationFrame((()=>{const t=new window.Event("change",{bubbles:!0});e.dispatchEvent(t)})),this.productSelected.emit({product:t,sectionId:this.section.id})},this.handleOptionsClick=t=>{!this.selectedProducts[this.section.id]?.has(t.id)&&this.isMaxSelectionReached()&&1!==this.selectionLimit||this.productOptionsSelected.emit({product:t,sectionId:this.section.id})}}getSelectedCount(){return this.selectedProducts[this.section?.id]?.size??0}isMaxSelectionReached(){return this.selectionLimit>1&&this.getSelectedCount()>=this.selectionLimit}isProductSelectionDisabled(t,s){return 0===t.quantity||!s&&this.isMaxSelectionReached()}getProductInstanceKey(t,s){return`${t}::${s}`}dispatchClearOptionsEvent(t,s){salla.event.dispatch("multiple-bundle-product-modal::clear-options",{productId:t.id,sectionId:this.section.id,sectionIndex:this.sectionIndex,productIndex:s})}handleOptionsSaved(t){const s=t.detail;if(!s)return;const{sectionId:i,productIndex:e,selectedOptions:n}=s;if(null==i||i!==this.section?.id)return;if(null==e||Number.isNaN(e))return;const o=this.getProductInstanceKey(i,e);if(n?.length)this.savedOptionsByInstance={...this.savedOptionsByInstance,[o]:!0};else if(this.savedOptionsByInstance[o]){const t={...this.savedOptionsByInstance};delete t[o],this.savedOptionsByInstance=t}}clearSavedOptionsState(t,s){const i=this.getProductInstanceKey(t,s);if(!this.savedOptionsByInstance[i])return;const e={...this.savedOptionsByInstance};delete e[i],this.savedOptionsByInstance=e}generateEventName(t,s){return`bundle[${t}][${s}][id]`}getCheckbox(t,s){const i=this.generateEventName(t,s);return this.host.querySelector(`input.s-multiple-bundle-product-checkbox[name="${i}"]`)}preventLockedDeselect(t,s){if(!this.isSelectionLocked||!s)return;t.preventDefault(),t.stopPropagation();const i=t.target;"checkbox"===i?.type&&(i.checked=!0)}render(){return i(e,{key:"17d96d9983fdb033c32d77228f52030ee408d856",class:"s-multiple-bundle-product-slider"},i("salla-slider",{key:"fe99a686cec9fe71728e651d1228564af1236483",type:"carousel",controlsOuter:!1,showControls:!1,id:`accordion-multiple-bundle-product-${this.section.id}`,pagination:!0,class:"s-multiple-bundle-product-wrapper-slider",sliderConfig:{spaceBetween:0}},i("div",{key:"2517a2b14ed787c32e1782fa7af04339660a0344",slot:"items"},this?.section?.products?.map(((t,s)=>{const e=this.selectedProducts[this.section.id]?.has(t.id)||!1,n=e&&this.isSelectionLocked,d=this.isProductSelectionDisabled(t,e),a=this.savedOptionsByInstance[this.getProductInstanceKey(this.section.id,s)]?salla.lang.getWithDefault("pages.products.edit_selected_options","تعديل الخيارات"):salla.lang.get("pages.products.choose_from_options");let c=salla.config.get("theme.is_rtl",!0)?o:l;return i("div",{class:"s-multiple-bundle-product-slide-one-third"+(d?" s-multiple-bundle-product-slide-one-third-disabled":""),key:t.id},i("div",{class:"s-multiple-bundle-product-card"},i("div",{class:"s-multiple-bundle-product-image-wrapper",onClick:()=>this.handleProductClick(t,s)},i("input",{id:this.generateEventName(this.section.id,s),type:"checkbox",class:"s-multiple-bundle-product-checkbox",checked:e,"data-selection-locked":n?"true":void 0,name:this.generateEventName(this.section.id,s),value:t.id,onClick:t=>this.preventLockedDeselect(t,e),onChange:t=>this.preventLockedDeselect(t,e)}),i("img",{src:t.image.url||salla.url.cdn("images/s-empty.png"),loading:"lazy",alt:t.image.alt||t.name,class:"s-multiple-bundle-product-image"})),i("div",{class:"s-multiple-bundle-product-content-wrapper"},i("div",{class:"s-multiple-bundle-product-content"},i("div",{class:"s-multiple-bundle-product-details"},i("div",{class:"s-multiple-bundle-product-title-wrapper"},i("h2",{class:"s-multiple-bundle-product-title"},i("a",{href:t?.url||"#",target:"_blank",rel:"noopener noreferrer"},t.name))),i("div",{class:"s-multiple-bundle-product-price-wrapper"},i("span",{class:"s-multiple-bundle-product-price"},i("span",{innerHTML:salla.money(t.price)})),t.sale_price>0&&i("span",{class:"s-multiple-bundle-product-price-discount"},i("span",{innerHTML:salla.money(t.regular_price)})))),t.quantity_in_group>0&&0!==t.quantity&&i("span",{class:"s-multiple-bundle-product-badge"},salla.lang.get("pages.products.pieces"),i("span",null,t.quantity_in_group)),0===t.quantity&&i("span",{class:"s-multiple-bundle-product-badge"},salla.lang.get("pages.products.quantity_in_group_finished"))),t.options?.length>0&&i("button",{class:"s-multiple-bundle-product-button",onClick:()=>this.handleOptionsClick(t),type:"button"},a,i("span",{class:"s-multiple-bundle-product-button-icon",innerHTML:c})))))})))))}get host(){return n(this)}};a.style="";export{d as salla_multiple_bundle_product_options_modal,a as salla_multiple_bundle_product_slider}
|