@salla.sa/twilight-components 2.14.592 → 2.14.594
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/{apple-pay-order-options-B036Wu4O.js → apple-pay-order-options-CA8IYRTb.js} +1 -0
- package/dist/cjs/{filepond-YeXzkn77.js → filepond-DtGoIKEP.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-poster-BEU99tEc.js → filepond-plugin-file-poster-DMejMF1-.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-size-BSsf6VIk.js → filepond-plugin-file-validate-size-J_fE6OBS.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-type-BkxQQF1Y.js → filepond-plugin-file-validate-type-BpewyAzF.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-edit-h9C4LxoR.js → filepond-plugin-image-edit-DPNUTWCK.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-nDfSwZEM.js → filepond-plugin-image-exif-orientation-CZ6YRu70.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview-C-FDU_4k.js → filepond-plugin-image-preview-CgV-oWXK.js} +1 -1
- package/dist/cjs/{index-DI5yx1uj.js → index-BziKkkwT.js} +21 -7
- package/dist/cjs/{intlTelInput-AgidDx18.js → intlTelInput-BLuZALMt.js} +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/salla-accordion-body_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-accordion_6.cjs.entry.js +1 -1
- package/dist/cjs/salla-add-product-button_5.cjs.entry.js +116 -4
- 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 +1 -1
- package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
- package/dist/cjs/salla-attachment-view_9.cjs.entry.js +10 -10
- 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 +286 -20
- 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 +1 -1
- package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
- package/dist/cjs/salla-cookies-bar.cjs.entry.js +1 -1
- package/dist/cjs/salla-count-down.cjs.entry.js +1 -1
- package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
- package/dist/cjs/salla-delivery-promise.cjs.entry.js +1 -1
- package/dist/cjs/salla-edit-order-button.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters.cjs.entry.js +1 -1
- package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +1 -1
- package/dist/cjs/salla-gift-card-redeem_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-gifting.cjs.entry.js +2 -2
- package/dist/cjs/salla-hook.cjs.entry.js +1 -1
- package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
- package/dist/cjs/salla-installment.cjs.entry.js +1 -1
- package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
- package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-banner_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-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 +1 -1
- package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-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-options-modal.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 +1 -1
- 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 +1 -1
- package/dist/cjs/salla-products-slider.cjs.entry.js +1 -1
- package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
- package/dist/cjs/salla-rating-modal-v2.cjs.entry.js +1 -1
- package/dist/cjs/salla-rating-modal.cjs.entry.js +1 -1
- 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 +1 -1
- 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-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 +1 -1
- package/dist/cjs/twilight.cjs.js +2 -2
- package/dist/cjs/{vanilla-picker-DLfPr_3c.js → vanilla-picker-36O-wrIX.js} +1 -1
- package/dist/collection/components/salla-add-product-button/salla-add-product-button.css +58 -36
- package/dist/collection/components/salla-add-product-button/salla-add-product-button.js +116 -1
- package/dist/collection/components/salla-bullet-delivery/location-distance-warning.js +28 -0
- package/dist/collection/components/salla-bullet-delivery/location-icon.svg +26 -0
- package/dist/collection/components/salla-bullet-delivery/location-permission-notice.js +103 -0
- package/dist/collection/components/salla-bullet-delivery/salla-bullet-delivery.css +136 -0
- package/dist/collection/components/salla-bullet-delivery/salla-bullet-delivery.js +133 -19
- package/dist/collection/components/salla-order-options-modal/apple-pay-order-options.js +1 -1
- package/dist/collection/global/app.js +2 -0
- package/dist/collection/global/app.spec.ts +33 -0
- package/dist/collection/global/app.ts +2 -0
- package/dist/collection/global/chunk-errors.js +14 -0
- package/dist/collection/global/chunk-errors.spec.ts +47 -0
- package/dist/collection/global/chunk-errors.ts +13 -0
- package/dist/components/apple-pay-order-options.js +1 -1
- package/dist/components/index.js +15 -2
- package/dist/components/salla-add-product-button2.js +116 -2
- package/dist/components/salla-bullet-delivery.js +288 -20
- package/dist/components/salla-gifting.js +1 -1
- package/dist/components/salla-quick-buy2.js +1 -1
- package/dist/docs.json +29 -13
- package/dist/esm/{apple-pay-order-options-s0kn7yr8.js → apple-pay-order-options-BS2iQKah.js} +1 -1
- package/dist/esm/{filepond-C3uLKJlo.js → filepond-DZJO0NDO.js} +1 -1
- package/dist/esm/{filepond-plugin-file-poster-BNO8nuwN.js → filepond-plugin-file-poster-BGjhc2cd.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-size-CMMYF-rL.js → filepond-plugin-file-validate-size-s9w1K7Bl.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-type-DSYhKJ7B.js → filepond-plugin-file-validate-type-OfI6GFgP.js} +1 -1
- package/dist/esm/{filepond-plugin-image-edit-lJgRMQAo.js → filepond-plugin-image-edit-Cfselyr4.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-B0tYK1GE.js → filepond-plugin-image-exif-orientation-ConUo4eP.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-kWmnxhXu.js → filepond-plugin-image-preview-BJ4T10Ty.js} +1 -1
- package/dist/esm/{index-Bk24FlDL.js → index-Bxge4xib.js} +21 -7
- package/dist/esm/{intlTelInput-nODQyuq0.js → intlTelInput-B-IoM3ox.js} +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/salla-accordion-body_2.entry.js +1 -1
- package/dist/esm/salla-accordion_6.entry.js +1 -1
- package/dist/esm/salla-add-product-button_5.entry.js +116 -4
- 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 +1 -1
- package/dist/esm/salla-apps-icons.entry.js +1 -1
- package/dist/esm/salla-attachment-view_9.entry.js +10 -10
- 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 +286 -20
- 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 +1 -1
- package/dist/esm/salla-conditional-offer.entry.js +1 -1
- package/dist/esm/salla-contacts.entry.js +1 -1
- package/dist/esm/salla-cookies-bar.entry.js +1 -1
- package/dist/esm/salla-count-down.entry.js +1 -1
- package/dist/esm/salla-custom-fields.entry.js +1 -1
- package/dist/esm/salla-delivery-promise.entry.js +1 -1
- package/dist/esm/salla-edit-order-button.entry.js +1 -1
- package/dist/esm/salla-filters-widget.entry.js +1 -1
- package/dist/esm/salla-filters.entry.js +1 -1
- package/dist/esm/salla-fulfillment-methods.entry.js +1 -1
- package/dist/esm/salla-gift-card-redeem_2.entry.js +1 -1
- package/dist/esm/salla-gifting.entry.js +2 -2
- package/dist/esm/salla-hook.entry.js +1 -1
- package/dist/esm/salla-infinite-scroll.entry.js +1 -1
- package/dist/esm/salla-installment.entry.js +1 -1
- package/dist/esm/salla-list-tile.entry.js +1 -1
- package/dist/esm/salla-localization-modal.entry.js +1 -1
- package/dist/esm/salla-login-modal.entry.js +1 -1
- package/dist/esm/salla-loyalty-banner_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-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 +1 -1
- package/dist/esm/salla-offer-modal.entry.js +1 -1
- package/dist/esm/salla-offer.entry.js +1 -1
- package/dist/esm/salla-order-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-options-modal.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 +1 -1
- 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 +1 -1
- package/dist/esm/salla-products-slider.entry.js +1 -1
- package/dist/esm/salla-quick-order.entry.js +1 -1
- package/dist/esm/salla-rating-modal-v2.entry.js +1 -1
- package/dist/esm/salla-rating-modal.entry.js +1 -1
- 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 +1 -1
- 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-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 +1 -1
- package/dist/esm/twilight.js +3 -3
- package/dist/esm/{vanilla-picker-B1bTUgHP.js → vanilla-picker-D1RSTlum.js} +1 -1
- package/dist/twilight/global/app.spec.ts +33 -0
- package/dist/twilight/global/app.ts +2 -0
- package/dist/twilight/global/chunk-errors.spec.ts +47 -0
- package/dist/twilight/global/chunk-errors.ts +13 -0
- package/dist/twilight/{p-68411931.entry.js → p-00cb1c25.entry.js} +1 -1
- package/dist/twilight/{p-be729ca2.entry.js → p-0835d9ab.entry.js} +1 -1
- package/dist/twilight/{p-5435dbcd.entry.js → p-09e56514.entry.js} +1 -1
- package/dist/twilight/{p-b6dc3e12.entry.js → p-0bbd0d06.entry.js} +1 -1
- package/dist/twilight/{p-2191d792.entry.js → p-0d464350.entry.js} +1 -1
- package/dist/twilight/{p-e7127704.entry.js → p-0e1a454b.entry.js} +1 -1
- package/dist/twilight/{p-0dc90c55.entry.js → p-106ea7ed.entry.js} +1 -1
- package/dist/twilight/{p-b1b096d7.entry.js → p-125482ce.entry.js} +1 -1
- package/dist/twilight/{p-9048520b.entry.js → p-15824030.entry.js} +1 -1
- package/dist/twilight/{p-612b6d87.entry.js → p-1769ead6.entry.js} +1 -1
- package/dist/twilight/{p-7b4a8237.entry.js → p-1b56374e.entry.js} +1 -1
- package/dist/twilight/{p-658de43b.entry.js → p-1d551b52.entry.js} +1 -1
- package/dist/twilight/{p-f5c9e513.entry.js → p-21d1a687.entry.js} +1 -1
- package/dist/twilight/{p-bb152b39.entry.js → p-22f21c95.entry.js} +1 -1
- package/dist/twilight/{p-4f76e9e2.entry.js → p-2510973e.entry.js} +1 -1
- package/dist/twilight/{p-6760ec19.entry.js → p-2c2f0608.entry.js} +1 -1
- package/dist/twilight/{p-7ff0c546.entry.js → p-2c8b8935.entry.js} +1 -1
- package/dist/twilight/{p-06643011.entry.js → p-2e5bace8.entry.js} +1 -1
- package/dist/twilight/{p-5f6a5a4b.entry.js → p-2ef59b30.entry.js} +1 -1
- package/dist/twilight/{p-f4f7ed38.entry.js → p-30b7383a.entry.js} +1 -1
- package/dist/twilight/{p-ce6c709b.entry.js → p-30f24d97.entry.js} +1 -1
- package/dist/twilight/{p-e2aa0e72.entry.js → p-3162901e.entry.js} +1 -1
- package/dist/twilight/{p-45035389.entry.js → p-34454493.entry.js} +1 -1
- package/dist/twilight/{p-f8f9c563.entry.js → p-35bc566f.entry.js} +1 -1
- package/dist/twilight/{p-b1b345d6.entry.js → p-35c0ca9a.entry.js} +1 -1
- package/dist/twilight/{p-c313bd11.entry.js → p-3e02b792.entry.js} +1 -1
- package/dist/twilight/{p-c3a2696b.entry.js → p-42162de9.entry.js} +1 -1
- package/dist/twilight/{p-c1d18b73.entry.js → p-4362756f.entry.js} +1 -1
- package/dist/twilight/{p-2fc68bfd.entry.js → p-4457a289.entry.js} +1 -1
- package/dist/twilight/{p-d9ccdd8f.entry.js → p-4543b3b3.entry.js} +1 -1
- package/dist/twilight/{p-3bf37615.entry.js → p-4cedf139.entry.js} +1 -1
- package/dist/twilight/{p-75f32b91.entry.js → p-51243641.entry.js} +1 -1
- package/dist/twilight/{p-f263bba9.entry.js → p-51e8c2b2.entry.js} +1 -1
- package/dist/twilight/{p-a0f1b867.entry.js → p-52012794.entry.js} +1 -1
- package/dist/twilight/{p-3e6f2bf8.entry.js → p-530b513d.entry.js} +1 -1
- package/dist/twilight/{p-e7ca6d06.entry.js → p-57097563.entry.js} +1 -1
- package/dist/twilight/{p-b95a6e20.entry.js → p-572a1f84.entry.js} +1 -1
- package/dist/twilight/{p-872d6d68.entry.js → p-59256d82.entry.js} +1 -1
- package/dist/twilight/{p-9e6f4ec4.entry.js → p-5b3a04cd.entry.js} +1 -1
- package/dist/twilight/p-614b7b61.entry.js +4 -0
- package/dist/twilight/{p-a057f532.entry.js → p-64c76ad9.entry.js} +1 -1
- package/dist/twilight/{p-dfd212d5.entry.js → p-66131771.entry.js} +1 -1
- package/dist/twilight/{p-6673a16f.entry.js → p-6b90f160.entry.js} +1 -1
- package/dist/twilight/{p-b5e774db.entry.js → p-6bfcdb38.entry.js} +1 -1
- package/dist/twilight/{p-c1d815c9.entry.js → p-6d3d5a0b.entry.js} +1 -1
- package/dist/twilight/{p-377642ea.entry.js → p-6e42d70f.entry.js} +1 -1
- package/dist/twilight/{p-6a76acd8.entry.js → p-6e57ff9f.entry.js} +1 -1
- package/dist/twilight/{p-91a1baf1.entry.js → p-751ff32d.entry.js} +1 -1
- package/dist/twilight/{p-42e02411.entry.js → p-78963d5d.entry.js} +1 -1
- package/dist/twilight/{p-a75680ae.entry.js → p-790ea507.entry.js} +1 -1
- package/dist/twilight/{p-eaae379c.entry.js → p-79bb0c41.entry.js} +1 -1
- package/dist/twilight/{p-1b1bebf6.entry.js → p-7ed0db2e.entry.js} +1 -1
- package/dist/twilight/{p-c9ebe466.entry.js → p-84308a79.entry.js} +1 -1
- package/dist/twilight/{p-43ca88d0.entry.js → p-8c229520.entry.js} +1 -1
- package/dist/twilight/{p-e58b7ef9.entry.js → p-94970458.entry.js} +1 -1
- package/dist/twilight/{p-ad52dcf7.entry.js → p-94e85b3c.entry.js} +1 -1
- package/dist/twilight/{p-f7ee4910.entry.js → p-988f6193.entry.js} +1 -1
- package/dist/twilight/{p-540029a5.entry.js → p-9f0459ec.entry.js} +1 -1
- package/dist/twilight/{p-BnmP7F4y.js → p-B5twlAuI.js} +1 -1
- package/dist/twilight/p-BS2iQKah.js +4 -0
- package/dist/twilight/{p-Ct18qgaq.js → p-BXAODWDa.js} +1 -1
- package/dist/twilight/{p-DvlAEiaH.js → p-BkWctmFE.js} +1 -1
- package/dist/twilight/{p-Bk24FlDL.js → p-Bxge4xib.js} +2 -2
- package/dist/twilight/{p-BvUmZYa9.js → p-CINox5XU.js} +1 -1
- package/dist/twilight/{p-B-LS1xDz.js → p-CWLJmpv-.js} +1 -1
- package/dist/twilight/{p-CHqh7vb6.js → p-DKEu8h4M.js} +1 -1
- package/dist/twilight/{p-CXo-IH2o.js → p-DnoH14HK.js} +1 -1
- package/dist/twilight/{p-CcGfWKIx.js → p-EiLe0Yi_.js} +1 -1
- package/dist/twilight/{p-DBjpz_eG.js → p-W-AkIawg.js} +1 -1
- package/dist/twilight/{p-b37ae926.entry.js → p-a37bc663.entry.js} +1 -1
- package/dist/twilight/{p-ced74b88.entry.js → p-a3a69984.entry.js} +1 -1
- package/dist/twilight/{p-42150f97.entry.js → p-a912d6a3.entry.js} +1 -1
- package/dist/twilight/{p-ed6ea140.entry.js → p-aa96807e.entry.js} +1 -1
- package/dist/twilight/{p-5fc75260.entry.js → p-aafa69d6.entry.js} +1 -1
- package/dist/twilight/{p-08256e67.entry.js → p-abfbba72.entry.js} +1 -1
- package/dist/twilight/{p-cd432c49.entry.js → p-b1dc78db.entry.js} +1 -1
- package/dist/twilight/{p-79676f24.entry.js → p-b2322278.entry.js} +1 -1
- package/dist/twilight/{p-21b3877b.entry.js → p-b3213fee.entry.js} +1 -1
- package/dist/twilight/{p-dc51993c.entry.js → p-b6918b2b.entry.js} +1 -1
- package/dist/twilight/{p-1d05ff72.entry.js → p-b8661b67.entry.js} +1 -1
- package/dist/twilight/{p-83ccddd5.entry.js → p-be3f6dbe.entry.js} +1 -1
- package/dist/twilight/{p-7038e1af.entry.js → p-bff2400f.entry.js} +1 -1
- package/dist/twilight/{p-b2c41e36.entry.js → p-c0274022.entry.js} +1 -1
- package/dist/twilight/{p-03dffb99.entry.js → p-c16b9f4a.entry.js} +1 -1
- package/dist/twilight/{p-38418821.entry.js → p-c476eaab.entry.js} +1 -1
- package/dist/twilight/{p-f9f0a5ee.entry.js → p-c4bf8d24.entry.js} +1 -1
- package/dist/twilight/p-c903b6bb.entry.js +4 -0
- package/dist/twilight/{p-0e122915.entry.js → p-d1e4e15e.entry.js} +1 -1
- package/dist/twilight/{p-523f9816.entry.js → p-d2e929bd.entry.js} +1 -1
- package/dist/twilight/{p-43c5ec34.entry.js → p-d38b5aaa.entry.js} +1 -1
- package/dist/twilight/{p-22135b7c.entry.js → p-d6d7c6a1.entry.js} +1 -1
- package/dist/twilight/{p-7750be26.entry.js → p-d9188e76.entry.js} +1 -1
- package/dist/twilight/{p-320d6b04.entry.js → p-db53740d.entry.js} +1 -1
- package/dist/twilight/{p-21802082.entry.js → p-df313b00.entry.js} +1 -1
- package/dist/twilight/{p-46721e68.entry.js → p-df407f01.entry.js} +1 -1
- package/dist/twilight/{p-4fd73440.entry.js → p-e19a980b.entry.js} +1 -1
- package/dist/twilight/{p-813a40cc.entry.js → p-e1b0dafc.entry.js} +1 -1
- package/dist/twilight/{p-d73307c7.entry.js → p-e7e52491.entry.js} +1 -1
- package/dist/twilight/{p-f74ccae4.entry.js → p-ebbb25fc.entry.js} +1 -1
- package/dist/twilight/{p-becb6580.entry.js → p-f046edd3.entry.js} +1 -1
- package/dist/twilight/{p-250262a9.entry.js → p-f22ec479.entry.js} +1 -1
- package/dist/twilight/{p-fbee9e50.entry.js → p-f4c94e30.entry.js} +1 -1
- package/dist/twilight/{p-02202feb.entry.js → p-fae38591.entry.js} +1 -1
- package/dist/twilight/{p-d601977e.entry.js → p-fb119c27.entry.js} +1 -1
- package/dist/twilight/{p-cc74d38b.entry.js → p-fd615606.entry.js} +1 -1
- package/dist/twilight/{p-b009d316.entry.js → p-fd6fc043.entry.js} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components/salla-add-product-button/salla-add-product-button.d.ts +16 -0
- package/dist/types/components/salla-bullet-delivery/location-distance-warning.d.ts +12 -0
- package/dist/types/components/salla-bullet-delivery/location-permission-notice.d.ts +39 -0
- package/dist/types/components/salla-bullet-delivery/salla-bullet-delivery.d.ts +31 -0
- package/dist/types/components/salla-order-options-modal/apple-pay-order-options.d.ts +2 -0
- package/dist/types/global/chunk-errors.d.ts +2 -0
- package/package.json +5 -5
- package/dist/twilight/p-07174244.entry.js +0 -4
- package/dist/twilight/p-f3ffe84f.entry.js +0 -4
- package/dist/twilight/p-s0kn7yr8.js +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r,h as a,H as t}from"./p-
|
|
4
|
+
import{r,h as a,H as t}from"./p-Bxge4xib.js";import{S as s}from"./p-D4oPi1Ov.js";import{f as e,r as i}from"./p-DqXpn47Z.js";const o=class{constructor(a){r(this,a),this.loadedFactors=[]}async componentWillLoad(){await salla.onReady(),await this.loadFactors()}async onPropsChange(){await this.loadFactors()}getDisplayFactors(){return this.factors?.length?this.factors:this.loadedFactors}async loadFactors(){if(this.factors?.length)this.loadedFactors=[];else if(this.orderId)try{const r=await e(this.orderId);this.loadedFactors=i(r,this.ratingId,this.productId,this.itemId)}catch(r){console.error("[salla-review-factors-tags] failed to load order rating factors",r),this.loadedFactors=[]}else this.loadedFactors=[]}renderFactorTags(){const r=this.getDisplayFactors();return r.length?a("div",{class:"s-review-factors-tags-factors"},r.map((r=>a("div",{class:"s-review-factors-tags-factor-tag"},a("span",{class:"s-review-factors-tags-factor-name"},r.name),a("span",{class:"s-review-factors-tags-factor-star",innerHTML:s}),a("span",{class:"s-review-factors-tags-factor-rating"},r.rating||""))))):null}render(){return a(t,{key:"f4347eb019e8af95cfa053389887afaa73300f40",class:"s-review-factors-tags-wrapper"},this.renderFactorTags())}static get watchers(){return{factors:["onPropsChange"],orderId:["onPropsChange"],ratingId:["onPropsChange"],productId:["onPropsChange"],itemId:["onPropsChange"]}}};o.style="/*!twlt*/:host{display:inline-flex}.s-review-factors-tags-factors{display:flex;flex-wrap:wrap;gap:0.5rem;justify-content:flex-start;margin-bottom:0.6rem}.s-review-factors-tags-factor-tag{display:inline-flex;align-items:center;gap:0.25rem;border-radius:999px;border:1px solid #e8e8e8;background:rgba(255, 255, 255, 0.3);font-size:0.85rem;line-height:1;padding:0.4rem 0.65rem}.s-review-factors-tags-factor-rating{font-weight:600;color:var(--color-primary) !important}.s-review-factors-tags-factor-star{display:inline-flex;width:0.8rem;height:0.8rem;fill:var(--color-primary) !important}.s-review-factors-tags-factor-star svg{width:100%;height:100%}.s-review-factors-tags-factor-name{color:var(--main-text-color) !important;font-weight:unset !important}.s-review-factors-tags-wrapper{display:inline-flex}.s-review-factors-tags-factors{display:flex;flex-direction:row;flex-wrap:wrap;gap:0.5rem}.s-review-factors-tags-factor-tag{display:inline-flex;align-items:center;gap:0.25rem;border-radius:9999px;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));background-color:rgb(255 255 255 / 0.3);padding-top:0.25rem;padding-bottom:0.25rem;padding-left:0.625rem;padding-right:0.625rem;font-size:0.875rem;line-height:1.25rem}.s-review-factors-tags-factor-name{font-weight:600;color:var(--color-primary-dark)}.s-review-factors-tags-factor-rating{font-weight:600;color:var(--color-primary-dark)}.s-review-factors-tags-factor-star{display:inline-flex;height:0.75rem;width:0.75rem;fill:var(--color-primary-dark)}.s-review-factors-tags-factor-star svg{height:100%;width:100%}";export{o as salla_review_factors_tags}
|
|
@@ -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-Bk24FlDL.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-Bxge4xib.js";import{g as i,a as o,c as a,u as d,r as s,m as l,b as n,f as c,d as p,e as h,h as m,i as g}from"./p-C8xwacGT.js";import"./p-CoQJOPRz.js";const w=class{constructor(e){t(this,e),this.loading=!0,this.saveLoading=!1,this.payload={items:{update:[],remove:[],add:[]}},this.expired=!1,this.editPreview=null,this.productSearchQuery="",this.productsListKey=0,this.productsListSource="latest",this.productsListSourceValue="",this.selectedProductToAdd=null,this.addProductQuantity=1,this.addProductLoading=!1,this.addProductConfirmLoading=!1,this.mobileProductsModalMounted=!1,this.isMobileViewport=!1,this.isRTL=!0,this.mobileProductsListLoading=!1,this.confirming=!1,this.handleMobileProductSelected=t=>{t.stopPropagation(),this.handleProductSelected(t)},this.productsPanelMobileQuery="(max-width: 768px)",this.handleProductsPanelViewportChange=t=>{this.isMobileViewport=t.matches},this.hasProductTypeFilter=t=>{const e=t.indexOf("?"),r=(e>=0?t.slice(e+1):t).split("#")[0];return Array.from(new URLSearchParams(r)).some((([t,e])=>"product"===e&&/^filters\[types\](?:\[(?:\d*)\])?$/.test(t)))},this.hasExcludedCategoriesFilter=t=>{const e=t.indexOf("?"),r=(e>=0?t.slice(e+1):t).split("#")[0];return Array.from(new URLSearchParams(r)).some((([t])=>/^filters(?:\[|%5B)excluded_categories(?:\]|%5D)(?:\[|%5B)(?:\d*)(?:\]|%5D)$/.test(t)))},this.normalizeProductsListArrayParams=t=>t.replace(/(^|[?&])(includes|source_value|filters(?:\[|%5B)[^&=\]%]+?(?:\]|%5D))(\[|%5B)\d+(\]|%5D)(?==)/gi,((t,e,r,i,o)=>`${e}${r}${i}${o}`)),this.handleBeforeBuildListUrl=t=>{if("salla-order-edit-product-card"!==t.component?.productCardComponent||"string"!=typeof t.url)return;t.url=this.normalizeProductsListArrayParams(t.url),this.hasProductTypeFilter(t.url)||(t.url+=(t.url.includes("?")?"&":"?")+"filters[types][]=product");const e=this.getParsedExcludedCategories();if(e.length>0&&!this.hasExcludedCategoriesFilter(t.url)){const r=e.map((t=>`filters[excluded_categories][]=${encodeURIComponent(t)}`)).join("&");t.url+=`${t.url.includes("?")?"&":"?"}${r}`}},this.defaultProductsListSource="latest",this.debouncedProductSearch=salla.helpers.debounce((t=>this.applyProductSearch(t)),500),salla.onReady((()=>{this.isRTL=salla.config.get("theme.is_rtl",!0)}))}getParsedExcludedCategories(){if(!this.excludedCategories)return[];try{const t="string"==typeof this.excludedCategories?JSON.parse(this.excludedCategories):this.excludedCategories;return Array.isArray(t)?t.filter((t=>Number.isInteger(t)&&t>0)):[]}catch{return[]}}async componentWillLoad(){this.setupProductsPanelViewportQuery(),await salla.onReady(),this.unregisterBeforeBuildListUrlHook=salla.hooks.registerHook("salla-products-list","beforeBuildListUrl",this.handleBeforeBuildListUrl),this.loadFromProp(),this.startExpiryCheck()}disconnectedCallback(){clearInterval(this.expiryInterval),this.unregisterBeforeBuildListUrlHook?.(),this.productsPanelViewportQuery?.removeEventListener("change",this.handleProductsPanelViewportChange),this.mobileProductsModal?.removeEventListener("orderEditProductSelected",this.handleMobileProductSelected)}setupProductsPanelViewportQuery(){"undefined"!=typeof window&&"function"==typeof window.matchMedia&&(this.productsPanelViewportQuery=window.matchMedia(this.productsPanelMobileQuery),this.isMobileViewport=this.productsPanelViewportQuery.matches,this.productsPanelViewportQuery.addEventListener("change",this.handleProductsPanelViewportChange))}startExpiryCheck(){const t=this.order?.customer_editing_session?.ends_at;if(!t)return;const e=()=>new Date(`${t.replace(" ","T")}+03:00`).getTime()<=Date.now();e()?this.expired=!0:this.expiryInterval=setInterval((()=>{e()&&(this.expired=!0,clearInterval(this.expiryInterval))}),1e3)}loadFromProp(){try{if(!this.orderData)return void(this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود"));const t="string"==typeof this.orderData?JSON.parse(this.orderData):this.orderData;this.order={...t,items:t.items.map((t=>({...t,selectedOptions:i(t)})))}}catch(t){this.error=salla.lang.getWithDefault("pages.orders.order_not_found","الطلب غير موجود")}finally{this.loading=!1}}applyProductSearch(t){const e=t?.trim()||"",r=e?"search":this.defaultProductsListSource,i="search"===r?JSON.stringify(e):"";this.productsListSource===r&&this.productsListSourceValue===i||(this.productsListSource=r,this.productsListSourceValue=i,this.productsListKey+=1)}handleProductSearch(t){const e=t.target?.value||"";this.productSearchQuery=e,this.debouncedProductSearch(e)}getProductsListKey(t){return`${t}-${this.productsListSource}-${this.productsListSourceValue}-${this.productsListKey}`}handleMobileProductsScroll(t){const e=t.currentTarget;if(e.scrollHeight-e.scrollTop-e.clientHeight>200||this.mobileProductsListLoading)return;const r=e.querySelector("salla-products-list");r&&(this.mobileProductsListLoading=!0,r.loadMore().finally((()=>{this.mobileProductsListLoading=!1})))}waitForNextFrame(){return new Promise((t=>requestAnimationFrame((()=>t(void 0)))))}async openMobileProductsModal(){this.mobileProductsModalMounted||(this.mobileProductsModalMounted=!0,await this.waitForNextFrame()),await(this.mobileProductsModal?.open?.())}setMobileProductsModal(t){this.mobileProductsModal!==t&&(this.mobileProductsModal?.removeEventListener("orderEditProductSelected",this.handleMobileProductSelected),this.mobileProductsModal=t,this.mobileProductsModal?.addEventListener("orderEditProductSelected",this.handleMobileProductSelected))}resetAddProductDrawer(){this.selectedProductToAdd=null,this.addProductQuantity=1,this.addProductLoading=!1,this.addProductConfirmLoading=!1,this.addProductOptions=null}getAddProductMaxQuantity(t=this.selectedProductToAdd){return o(t)}clampAddProductQuantity(t,e=this.selectedProductToAdd){return a(t,this.getAddProductMaxQuantity(e))}getApiErrorMessage(t){return t?.response?.data?.error?.message||t?.response?.data?.message}notifyApiError(t){const e=this.getApiErrorMessage(t);e&&salla.notify.error(e)}async validateAddProductOptions(){return!this.selectedProductToAdd?.options?.length||!!this.addProductOptions&&(await(this.addProductOptions.validateAndScroll?.())??await(this.addProductOptions.reportValidity?.())??!1)}updateLocalOrderItem(t,e,r,i){this.order={...this.order,items:d(this.order.items,t,e,r,i)}}removeLocalOrderItem(t){this.order={...this.order,items:s(this.order.items,t)}}setPayloadItems(t){this.payload={...this.payload,items:l(this.payload.items,t)}}handleAddProductQuantityChange(t){const e=t.detail,r=e?.quantity??parseInt(t.target?.value,10);isNaN(r)||r<1||(this.addProductQuantity=this.clampAddProductQuantity(r))}async handleProductSelected(t){const e=t.detail?.product;if(e?.id&&!this.addProductLoading){this.addProductLoading=!0;try{this.selectedProductToAdd=n(e),this.addProductQuantity=1,await(this.mobileProductsModal?.close?.()),await this.waitForNextFrame(),await(this.addProductDrawer?.open?.())}catch(t){this.notifyApiError(t)}finally{this.addProductLoading=!1}}}async confirmAddProduct(){if(this.selectedProductToAdd?.id&&!this.addProductConfirmLoading){this.addProductConfirmLoading=!0;try{const t=this.getAddProductMaxQuantity(),e=this.clampAddProductQuantity(this.addProductQuantity);e!==this.addProductQuantity&&(this.addProductQuantity=e);const r=this.addProductOptions;if(!await this.validateAddProductOptions())return void salla.notify.error(salla.lang.getWithDefault("common.messages.required_fields","يرجى تعبئة الحقول المطلوبة"));const i=await(r?.getSelectedOptionsData?.())||{},o=await(r?.getOptionsData?.())||this.selectedProductToAdd.options||[],d=c(this.order?.items,this.selectedProductToAdd.id,i);if(d){const r=a(d.quantity+e,t);return this.updateLocalOrderItem(d.id,r,o,i),this.setPayloadItems(d.isNew?{add:p(this.payload.items.add,d.id,r,i)}:{update:h(this.payload.items.update,d.id,r,i)}),void await(this.addProductDrawer?.close?.())}const s=m(this.selectedProductToAdd,e,o,i),l={itemId:s.id,product_id:this.selectedProductToAdd.id,quantity:e,options:i};this.order={...this.order,items:[...this.order.items,s]},this.setPayloadItems({add:[...this.payload.items.add,l]}),await(this.addProductDrawer?.close?.())}catch(t){this.notifyApiError(t)}finally{this.addProductConfirmLoading=!1}}}handleItemUpdated(t){if(!this.order)return;const{itemId:e,quantity:r,options:i,optionDefinitions:d}=t.detail,s=this.order.items.find((t=>t.id===e));if(!s)return;const l=a(r,o(s.product));if(s.isNew)return this.setPayloadItems({add:p(this.payload.items.add,e,l,i)}),void this.updateLocalOrderItem(e,l,d,i);this.setPayloadItems({update:h(this.payload.items.update,e,l,i??{})}),this.updateLocalOrderItem(e,l,d,i)}handleItemRemoved(t){if(!this.order)return;if(this.order.items.length<=1)return void salla.notify.error(salla.lang.getWithDefault("pages.orders.order_cannot_be_empty","لا يمكن إزالة جميع المنتجات من الطلب"));const{itemId:e}=t.detail,r=this.order.items.find((t=>t.id===e));if(r){if(r.isNew)return this.setPayloadItems({add:this.payload.items.add.filter((t=>t.itemId!==e))}),void this.removeLocalOrderItem(e);this.setPayloadItems({update:this.payload.items.update.filter((t=>t.id!==e)),remove:[...this.payload.items.remove,e]}),this.removeLocalOrderItem(e)}}get hasChanges(){return this.payload.items.update.length>0||this.payload.items.remove.length>0||this.payload.items.add.length>0}async saveOrder(){if(this.hasChanges){this.saveLoading=!0;try{const t=await salla.order.api.editOrder(this.orderId,g(this.payload));this.editPreview=t?.data?.data||t?.data,await(this.saveModal?.open?.())}catch(t){this.notifyApiError(t)}finally{this.saveLoading=!1}}}navigateToOrder(){const t=new URL(window.location.href);t.pathname=t.pathname.replace(/\/edit\/?$/,""),t.search="",window.location.href=t.href}handleConfirm(){this.confirming=!0,this.editPreview?.payment?.required&&this.editPreview.payment.payment_url?window.location.href=this.editPreview.payment.payment_url:this.navigateToOrder()}returnToOrderDetails(){this.confirming=!0,this.navigateToOrder()}getConfirmButtonIconClass(){return this.isRTL?"sicon-keyboard_arrow_left":"sicon-keyboard_arrow_right"}async cancelEditSession(){try{await salla.order.api.cancelEditSession(this.orderId),this.navigateToOrder()}catch(t){this.notifyApiError(t)}}renderProductsPanel(){const t=salla.lang.getWithDefault("pages.orders.add_product_to_order","أضف منتج للطلب");return e("section",{class:"s-order-edit-products-panel"},e("div",{class:"s-order-edit-products-header"},e("h2",{class:"s-order-edit-products-title"},t)),this.renderProductsPickerContent("panel"))}renderProductsPickerContent(t){return e("div",{class:{"s-order-edit-products-picker":!0,"s-order-edit-products-modal-content":"modal"===t}},e("label",{class:"s-order-edit-products-search"},e("i",{class:"sicon-search"}),e("input",{type:"search",class:"s-order-edit-products-search-input",placeholder:salla.lang.getWithDefault("pages.products.search_for_product","ابحث عن منتج"),value:this.productSearchQuery,onInput:t=>this.handleProductSearch(t)})),e("div",{class:"s-order-edit-products-list",onScroll:"modal"===t?t=>this.handleMobileProductsScroll(t):void 0},e("salla-products-list",{key:this.getProductsListKey(t),includes:["options"],source:this.productsListSource,"source-value":this.productsListSourceValue,autoload:!0,"product-card-component":"salla-order-edit-product-card"})))}renderMobileProductsModal(){return e("salla-modal",{ref:t=>this.setMobileProductsModal(t),width:"md",class:"s-order-edit-mobile-products-modal","modal-title":salla.lang.getWithDefault("pages.orders.add_product_to_order","أضف منتج للطلب"),onModalVisibilityChanged:t=>{t.detail||(this.mobileProductsModalMounted=!1)}},this.mobileProductsModalMounted?this.renderProductsPickerContent("modal"):null)}renderAddProductDrawer(){const t=this.selectedProductToAdd,r=t?.name||salla.lang.getWithDefault("common.elements.product","منتج"),i=t?.price,o=this.getAddProductMaxQuantity(t),a=t?`order-edit-add-${t.id}`:"order-edit-add",d={value:this.clampAddProductQuantity(this.addProductQuantity,t)};return o&&(d.max=o),e("salla-modal",{ref:t=>this.addProductDrawer=t,width:"md","modal-title":salla.lang.getWithDefault("pages.orders.add_product_to_order","أضف منتج للطلب"),onModalVisibilityChanged:t=>{t.detail||this.resetAddProductDrawer()}},e("div",{class:"s-order-edit-add-modal"},this.addProductLoading?e("div",{class:"s-order-edit-add-modal-loading"},e("salla-loading",null)):t?e("div",{class:"s-order-edit-add-modal-content"},e("div",{class:"s-order-edit-add-modal-header"},e("div",{class:"s-order-edit-add-modal-media"},t.image?.url&&e("img",{src:t.image.url,alt:t.image.alt||r,class:"s-order-edit-add-modal-image"}),e("div",{class:"s-order-edit-add-modal-details"},e("h3",{class:"s-order-edit-add-modal-name"},r),null!=i&&e("span",{class:"s-order-edit-add-modal-price",innerHTML:salla.money(i)})))),e("div",{class:"s-order-edit-add-modal-quantity"},e("h3",{class:"s-order-edit-add-modal-section-title"},salla.lang.getWithDefault("common.elements.quantity","الكمية")),e("div",{class:"s-order-edit-add-modal-quantity-input"},e("salla-quantity-input",{...d,onChange:t=>this.handleAddProductQuantityChange(t)}))),t.options?.length>0&&e("form",{onSubmit:t=>t.preventDefault()},e("salla-product-options",{ref:t=>this.addProductOptions=t,"product-id":t.id,"unique-key":a,options:JSON.stringify(t.options),key:`${a}-options`})),e("div",{class:"s-order-edit-add-modal-actions"},e("salla-button",{onClick:()=>this.confirmAddProduct(),loading:this.addProductConfirmLoading},salla.lang.getWithDefault("common.elements.confirm","تأكيد")),e("salla-button",{color:"gray",fill:"outline",onClick:()=>this.addProductDrawer?.close?.()},salla.lang.getWithDefault("common.elements.cancel","الغاء")))):null))}renderSaveModal(){const t=this.editPreview,r=t?.totals?.remaining_amount?.amount>0,i=t?.totals?.refund_amount?.amount>0,o=t?.totals?.tax?.amount?.amount;return e("salla-modal",{ref:t=>this.saveModal=t,width:"md",isClosable:!1,onModalVisibilityChanged:async t=>{t.detail||(this.editPreview=null,this.confirming||await this.cancelEditSession(),this.confirming=!1)}},e("div",{class:"s-order-edit-modal"},e("h2",{class:"s-order-edit-modal-title"},salla.lang.getWithDefault("pages.orders.edit_summary_title","ملخص الطلب بعد التعديل")),e("p",{class:"s-order-edit-modal-subtitle"},salla.lang.getWithDefault("pages.orders.cart_edits_saved","Your cart edits have been saved")),t?.items?.length>0&&e("div",{class:"s-order-edit-modal-items"},t.items.map((t=>{const r=this.order?.items?.find((e=>e.id==t.id)),i=r?.product?.image?.url,o=t.options?.join("/ ");return e("div",{class:"s-order-edit-modal-item"},e("div",{class:"s-order-edit-modal-item-start"},i&&e("img",{src:i,alt:t.name,class:"s-order-edit-modal-item-image"}),e("div",null,e("p",{class:"s-order-edit-modal-item-name"},t.name),o&&e("span",{class:"s-order-edit-modal-item-options"},o))),e("div",{class:"s-order-edit-modal-item-end"},e("span",{class:"s-order-edit-modal-item-quantity",dir:"ltr",innerHTML:t.quantity+" x "+t.price.amount}),e("span",{class:"s-order-edit-modal-item-price",innerHTML:salla.money(t.price.amount*t.quantity)})))}))),t?.totals?.updated_products_total&&e("div",{class:"s-order-edit-modal-row"},e("span",{class:"s-order-edit-modal-row-label"},salla.lang.getWithDefault("pages.orders.modified_products_total","مجموع المنتجات المعدلة")),e("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(t.totals.updated_products_total.amount)})),o>0&&e("div",{class:"s-order-edit-modal-row"},e("span",{class:"s-order-edit-modal-tax-label"},e("i",{class:"sicon-info-circle s-order-edit-modal-tax-icon"}),salla.lang.getWithDefault("pages.orders.vat","ضريبة القيمة المضافة")),e("span",{class:"s-order-edit-modal-row-value",innerHTML:salla.money(o)})),t?.totals?.total&&e("div",{class:"s-order-edit-modal-total"},e("span",{class:"s-order-edit-modal-total-label"},salla.lang.getWithDefault("pages.orders.order_total","اجمالي الطلب")),e("span",{class:"s-order-edit-modal-total-value",innerHTML:salla.money(t.totals.total.amount)})),i&&e("div",{class:"s-order-edit-modal-refund"},e("i",{class:"sicon-info-circle s-order-edit-modal-refund-icon"}),e("p",{class:"s-order-edit-modal-refund-text"},salla.lang.getWithDefault("pages.orders.refund_message","سيتم تحويل فارق المبلغ على نفس وسيلة الدفع"))),e("div",{class:"s-order-edit-modal-btn-wrapper"},e("salla-button",{onClick:()=>this.handleConfirm()},r?salla.lang.getWithDefault("pages.orders.pay_difference","دفع فارق المبلغ"):i?salla.lang.getWithDefault("pages.orders.confirm_and_receive_difference","تأكيد واستلام فارق المبلغ"):salla.lang.getWithDefault("pages.orders.confirm_changes","تأكيد التعديلات"),e("i",{class:`${this.getConfirmButtonIconClass()} s-order-edit-modal-btn-icon`})),e("salla-button",{color:"gray",fill:"outline",onClick:()=>this.returnToOrderDetails()},salla.lang.getWithDefault("pages.orders.back_to_order_details","العودة إلى تفاصيل الطلب")))))}render(){if(this.loading)return e(r,null,e("salla-loading",null));if(this.expired)return e(r,null,e("div",{class:"s-order-edit-expired"},e("p",null,salla.lang.getWithDefault("pages.orders.edit_session_expired","انتهت مدة التعديل المتاحة")),e("salla-button",{onClick:()=>this.navigateToOrder()},salla.lang.getWithDefault("pages.orders.back_to_order","العودة إلى تفاصيل الطلب"))));if(this.error||!this.order)return e(r,null,e("div",{class:"s-order-edit-no-content-placeholder"},e("i",{class:"sicon-shopping-bag icon"}),e("p",null,this.error)));const t=this.order.items&&this.order.items.length>0,i=this.order.customer_editing_session?.ends_at;return e(r,null,i&&e("div",{class:"s-order-edit-timer-wrapper"},e("salla-count-down",{prefixText:salla.lang.getWithDefault("pages.orders.edit_within","يمكنك التعديل خلال"),date:i,horizontal:!0,withButton:!0,autoSegments:!0,labeled:!1,size:"sm",color:"primary"})),e("div",{class:"s-order-edit-layout"},this.isMobileViewport?null:this.renderProductsPanel(),e("section",{class:"s-order-edit-order-panel"},e("div",{class:"s-order-edit-items-wrapper"},e("h2",{class:"s-order-edit-items-title"},salla.lang.getWithDefault("pages.orders.order_products","منتجات الطلب")),t?this.order.items.map(((t,r)=>[e("salla-order-edit-item",{key:t.id,item:t,orderId:this.orderId}),r<this.order.items.length-1?e("div",{class:"s-order-edit-items-divider"}):null])):e("div",{class:"s-order-edit-no-content-placeholder"},e("i",{class:"sicon-shopping-bag icon"}),e("p",null,salla.lang.getWithDefault("common.elements.no_items","لا توجد عناصر")))),e("div",{class:"s-order-edit-actions"},e("salla-button",{class:"s-order-edit-mobile-products-trigger",color:"gray",size:"small",fill:"outline",onClick:()=>this.openMobileProductsModal()},e("i",{class:"sicon-add s-order-edit-mobile-products-trigger-icon"}),salla.lang.getWithDefault("pages.orders.add_product","إضافة منتج")),e("salla-button",{onClick:()=>this.saveOrder(),loading:this.saveLoading,size:"small",disabled:!this.hasChanges},salla.lang.getWithDefault("pages.orders.save_changes","حفظ التعديلات")),e("salla-button",{size:"small",color:"gray",fill:"outline",onClick:()=>this.cancelEditSession()},salla.lang.getWithDefault("common.elements.cancel","الغاء"))))),this.renderMobileProductsModal(),this.renderAddProductDrawer(),this.renderSaveModal())}};w.style='/*!twlt*/:host{display:block}.outline{outline-style:solid}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.s-order-edit-timer-wrapper{margin-bottom:1rem;display:flex;justify-content:center}.s-order-edit-layout{display:grid;align-items:flex-start;gap:1.5rem;grid-template-columns:minmax(0,1.35fr) minmax(20rem,1fr)}@media (max-width: 1080px){.s-order-edit-layout{grid-template-columns:minmax(0, 1fr)}}.s-order-edit-products-panel{border-radius:1rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1.5rem}@media (max-width: 768px){.s-order-edit-products-panel{display:none}}.s-order-edit-order-panel{display:flex;flex-direction:column;gap:1.5rem;border-radius:1rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1.5rem}.s-order-edit-products-header{margin-bottom:1rem}.s-order-edit-products-title{margin:0px;font-size:1.125rem;line-height:1.75rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-items-wrapper{display:flex;flex-direction:column;gap:1.25rem}.s-order-edit-items-title{margin:0px;font-size:1.125rem;line-height:1.75rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-items-divider{height:1px;width:100%;--tw-bg-opacity:1;background-color:rgb(238 242 247 / var(--tw-bg-opacity, 1))}.s-order-edit-products-picker{display:flex;min-height:0px;flex-direction:column;gap:1rem}.s-order-edit-products-modal-content{display:flex;min-height:0px;flex-direction:column;gap:1rem;padding:1rem}.s-order-edit-products-search{position:relative;margin-bottom:1.25rem;display:block}.s-order-edit-products-search i{pointer-events:none;position:absolute;top:50%;--tw-translate-y:-50%;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));font-size:1rem;line-height:1.5rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-products-search i:where([dir="ltr"],[dir="ltr"] *){left:1rem}.s-order-edit-products-search i:where([dir="rtl"],[dir="rtl"] *){right:1rem}.s-order-edit-products-search-input{min-height:3rem;width:100%;border-radius:0.875rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding-left:1rem;padding-right:1rem;padding-top:0.875rem;padding-bottom:0.875rem;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1));transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:200ms}.s-order-edit-products-search-input:where([dir="ltr"],[dir="ltr"] *){padding-left:2.75rem;padding-right:1rem}.s-order-edit-products-search-input:where([dir="rtl"],[dir="rtl"] *){padding-right:2.75rem;padding-left:1rem}.s-order-edit-products-search-input:focus{--tw-border-opacity:1;border-color:rgb(17 24 39 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));--tw-shadow:0 0 0 3px rgba(17,24,39,0.08);--tw-shadow-colored:0 0 0 3px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}.s-order-edit-products-list{min-height:20rem}.s-order-edit-products-list .s-products-list-wrapper{gap:1rem;grid-template-columns:repeat(2,minmax(0,1fr))}@media (min-width: 769px){.s-order-edit-products-list .s-products-list-wrapper{grid-template-columns:repeat(3, minmax(0, 1fr))}}.s-order-edit-no-content-placeholder{display:flex;min-height:14rem;flex-direction:column;align-items:center;justify-content:center;gap:0.75rem;border-radius:0.875rem;border-width:1px;border-style:dashed;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding:2rem;text-align:center;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-no-content-placeholder .icon{font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-actions{position:sticky;bottom:1.5rem;display:flex;align-items:center;justify-content:space-between;gap:0.75rem;border-radius:0.875rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));background-color:rgba(255,255,255,0.94);padding:1rem;--tw-shadow:0 12px 30px rgba(15,23,42,0.08);--tw-shadow-colored:0 12px 30px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);--tw-backdrop-blur:blur(10px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}@media (max-width: 768px){.s-order-edit-actions{position:static;align-items:center;gap:0.5rem}}.s-order-edit-actions salla-button{flex:0 0 auto}@media (max-width: 768px){.s-order-edit-actions salla-button{display:block;flex:1 1 0;min-width:0}}.s-order-edit-mobile-products-trigger{display:none}@media (max-width: 768px){.s-order-edit-mobile-products-trigger{display:block}}.s-order-edit-mobile-products-trigger-icon:where([dir="ltr"],[dir="ltr"] *){margin-right:0.35rem}.s-order-edit-mobile-products-trigger-icon:where([dir="rtl"],[dir="rtl"] *){margin-left:0.35rem}.s-order-edit-mobile-products-modal .s-order-edit-products-list{max-height:min(24rem, calc(100vh - 11rem));min-height:22rem;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}@media (max-width: 480px){.s-order-edit-mobile-products-modal .s-order-edit-products-list{min-height:20rem;max-height:min(22rem, calc(100vh - 10rem))}}.s-order-edit-mobile-products-modal .products-list .s-products-list-wrapper{gap:0.625rem;grid-template-columns:repeat(2,minmax(0,1fr))}.s-order-edit-modal{display:flex;flex-direction:column;gap:1rem}.s-order-edit-modal-title{margin:0px;text-align:start;font-size:1.125rem;line-height:1.75rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-subtitle{margin:0px;margin-top:-0.75rem;text-align:start;font-size:0.875rem;line-height:1.25rem;line-height:1.5;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-items{display:flex;flex-direction:column;gap:0.75rem}.s-order-edit-modal-item{display:flex;align-items:center;justify-content:space-between;gap:1rem;border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-bottom:0.75rem}.s-order-edit-modal-item-start{display:flex;align-items:center;gap:0.75rem}.s-order-edit-modal-item-image{height:3rem;width:3rem;border-radius:0.75rem;object-fit:cover}.s-order-edit-modal-item-name{margin:0px;font-size:0.875rem;line-height:1.25rem;font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-item-options{font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-item-end{display:flex;align-items:center;gap:0.75rem}.s-order-edit-modal-item-price{font-size:0.875rem;line-height:1.25rem;font-weight:500}.s-order-edit-modal-item-quantity{font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-row{display:flex;align-items:center;justify-content:space-between;gap:1rem}.s-order-edit-modal-row-label{font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-row-value{font-weight:700}.s-order-edit-modal-tax-label{display:flex;align-items:center;gap:0.5rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-tax-icon{--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-modal-total{display:flex;align-items:center;justify-content:space-between;gap:1rem;border-top-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-top:0.75rem;font-weight:700;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-total-label{font-weight:500;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-modal-total-value{font-size:1.25rem;line-height:1.75rem;font-weight:500}.s-order-edit-modal-refund{display:flex;align-items:flex-start;gap:1rem;border-radius:0.875rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));padding-left:1rem;padding-right:1rem;padding-top:0.875rem;padding-bottom:0.875rem;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-order-edit-modal-refund-icon{flex-shrink:0;font-size:1.125rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-modal-refund-text{margin:0px;flex:1 1 0%;font-size:0.875rem;line-height:1.25rem}.s-order-edit-modal-btn-wrapper{margin-top:0.5rem;display:flex;justify-content:space-between}.s-order-edit-modal-btn-wrapper salla-button{width:100%}@media (min-width: 640px){.s-order-edit-modal-btn-wrapper salla-button{width:auto}}.s-order-edit-modal-btn-icon{vertical-align:middle;font-size:1.125rem;line-height:1.75rem}.s-order-edit-expired{display:flex;min-height:14rem;flex-direction:column;align-items:center;justify-content:center;gap:0.75rem;border-radius:0.875rem;border-width:1px;border-style:dashed;--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1));padding:2rem;text-align:center;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-expired .icon{font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal{display:flex;min-height:0px;flex:1 1 auto;flex-direction:column;gap:1rem}.s-order-edit-add-modal-content{display:flex;min-height:0px;flex:1 1 auto;flex-direction:column;gap:1rem}.s-order-edit-add-modal-loading{display:flex;min-height:12rem;flex:1 1 auto;align-items:center;justify-content:center}.s-order-edit-add-modal-header{border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-bottom:1rem}.s-order-edit-add-modal-media{display:flex;align-items:flex-start;gap:1rem}.s-order-edit-add-modal-image{height:5.5rem;width:5.5rem;border-radius:0.875rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));object-fit:cover}.s-order-edit-add-modal-details{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.35rem}.s-order-edit-add-modal-name{margin:0px;font-size:1rem;line-height:1.5rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal-price{font-size:0.95rem;font-weight:700;--tw-text-opacity:1;color:rgb(15 118 110 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal-quantity{display:flex;align-items:center;justify-content:space-between;gap:1rem}.s-order-edit-add-modal-section-title{margin:0px;font-size:0.9375rem;font-weight:600;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-order-edit-add-modal-quantity-input{flex-shrink:0}.s-order-edit-add-modal-actions{margin-top:auto;display:flex;align-items:center;justify-content:space-between;gap:0.75rem;border-top-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding-top:1rem}.s-order-edit-add-modal-actions salla-button{min-width:4.75rem;flex:0 0 auto}.s-order-edit-item-header{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem}.s-order-edit-item-media{display:flex;min-width:0px;flex:1 1 0%;gap:1rem}@media (max-width: 640px){.s-order-edit-item-media{width:100%}}.s-order-edit-item-image{height:5.5rem;width:5.5rem;border-radius:0.875rem;--tw-bg-opacity:1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1));object-fit:cover}.s-order-edit-item-details{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.35rem}.s-order-edit-item-name{margin:0px;font-size:1rem;line-height:1.5rem;font-weight:700;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.s-order-edit-item-link{color:inherit;text-decoration-line:none}.s-order-edit-item-price{font-size:0.95rem;font-weight:700;--tw-text-opacity:1;color:rgb(15 118 110 / var(--tw-text-opacity, 1))}.s-order-edit-item-weight{margin:0px;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.s-order-edit-item-quantity{margin-top:1.25rem;display:flex;align-items:center;justify-content:space-between;gap:1rem;border-top-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));padding-top:1rem}.s-order-edit-item-quantity-label{margin:0px;font-size:0.9375rem;font-weight:600;--tw-text-opacity:1;color:rgb(55 65 81 / var(--tw-text-opacity, 1))}.s-order-edit-item-quantity-input{flex-shrink:0}.s-order-edit-item-options{margin-top:1rem;display:block}.s-order-edit-product-card{display:flex;min-height:100%;width:100%;cursor:pointer;appearance:none;flex-direction:column;overflow:hidden;border-radius:0.875rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(238 242 247 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));text-align:start;--tw-shadow:0 10px 24px rgba(15,23,42,0.04);--tw-shadow-colored:0 10px 24px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:200ms}.s-order-edit-product-card:hover{--tw-translate-y:-2px;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));--tw-border-opacity:1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1));--tw-shadow:0 16px 30px rgba(15,23,42,0.08);--tw-shadow-colored:0 16px 30px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.s-order-edit-product-card:focus-visible{--tw-border-opacity:1;border-color:rgb(17 24 39 / var(--tw-border-opacity, 1));--tw-shadow:0 0 0 3px rgba(17,24,39,0.12);--tw-shadow-colored:0 0 0 3px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}@media (max-width: 768px){.s-order-edit-product-card{border-radius:0.75rem;box-shadow:0 6px 18px rgba(15, 23, 42, 0.05)}}.s-order-edit-product-card-media{display:flex;aspect-ratio:1 / 1;width:100%;flex-shrink:0;align-items:center;justify-content:center;overflow:hidden;background:linear-gradient(180deg,#f8fafc 0%,#f1f5f9 100%)}.s-order-edit-product-card-image{display:block;height:100%;width:100%;object-fit:cover}.s-order-edit-product-card-placeholder{display:flex;height:100%;width:100%;align-items:center;justify-content:center;font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.s-order-edit-product-card-content{display:flex;flex:1 1 0%;flex-direction:column;gap:0.5rem;padding:1rem}@media (max-width: 768px){.s-order-edit-product-card-content{gap:0.25rem;padding:0.625rem}}.s-order-edit-product-card-title{margin:0px;font-size:0.95rem;font-weight:600;line-height:1.6;--tw-text-opacity:1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}@media (max-width: 768px){.s-order-edit-product-card-title{display:-webkit-box;overflow:hidden;min-height:2.35rem;font-size:0.8125rem;line-height:1.45;-webkit-box-orient:vertical;-webkit-line-clamp:2}}.s-order-edit-product-card-price{margin:0px;font-size:1rem;line-height:1.5rem;font-weight:700;--tw-text-opacity:1;color:rgb(15 118 110 / var(--tw-text-opacity, 1))}@media (max-width: 768px){.s-order-edit-product-card-price{font-size:0.875rem}.s-order-edit-products-panel,.s-order-edit-order-panel{padding:1rem}.s-order-edit-actions salla-button .s-button-element{width:100%;min-width:0;padding-inline:0.5rem}.s-order-edit-mobile-products-modal .s-order-edit-products-modal-content{gap:0.75rem;padding:0.875rem}.s-order-edit-add-modal-media,.s-order-edit-add-modal-quantity{flex-direction:column;align-items:stretch}}';export{w as salla_order_edit}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as t,h as e,F as i}from"./p-
|
|
4
|
+
import{r as t,h as e,F as i}from"./p-Bxge4xib.js";const r=class{constructor(e){t(this,e),this.source="header",this.useReactLink=!1,this.menus=[],this.displayAllText=""}async componentWillLoad(){return salla.onReady((()=>{if(this.displayAllText=salla.lang.get("blocks.home.display_all"),!this.sourceValue||"json"!==this.source)return this.getMenuItems();this.menus="string"==typeof this.sourceValue?JSON.parse(this.sourceValue):this.sourceValue||[]}))}getMenuItems(){return salla.api.component.getMenus(this.source).then((async({data:t})=>{this.menus=t,await salla.hooks.call("salla-menu","afterFetchMenuItems",this)})).catch((t=>{salla.logger.error("salla-menu::Error fetching menus",t)}))}hasChildren(t){return t?.children?.length>0}hasProducts(t){return t?.products?.length>0}getDesktopClasses(t,e){return`!hidden lg:!block ${e?"root-level lg:!inline-block":"relative"} ${t.products?" mega-menu":""}\n ${this.hasChildren(t)?"has-children":""}`}getAttributes(t){return t.trim().split(" ").reduce(((t,e)=>{let[i,r]=e.split("=");return t[i]=r.replace(/"/g,""),t}),{})}getMobileMenu(t,r){const l=t.image?e("img",{src:t.image,class:"rounded-full",width:"48",height:"48",alt:t.title}):null;return e("li",{class:"lg:hidden text-sm font-bold",...this.getAttributes(t.attrs)},this.hasChildren(t)?e(i,null,e("span",{class:t.image?"!py-3":""},l,t.title),e("ul",null,e("li",{class:"text-sm font-bold"},e("a",{href:t.url,class:"text-gray-500"},r)),t.children.map((t=>this.getMobileMenu(t,r))))):e("a",{href:t.url,"aria-label":t.title||"category",class:"text-gray-500 "+(t.image?"!py-3":""),...this.getAttributes(t.link_attrs)},l,e("span",null,t.title||"")))}getDesktopMenu(t,i){return e("li",{class:this.getDesktopClasses(t,i),...this.getAttributes(t.attrs)},e("a",{href:t.url,"aria-label":t.title||"category",...this.getAttributes(t.link_attrs)},e("span",null,t.title)),this.hasChildren(t)?e("div",{class:"sub-menu shadow-default "+(this.hasProducts(t)?"w-full left-0 flex":"w-56")},e("ul",{class:this.hasProducts(t)?"w-56 shrink-0 m-8 rtl:ml-0 ltr:mr-0":""},t.children.map((t=>this.getDesktopMenu(t,!1)))),this.hasProducts(t)?e("salla-products-list",{source:"selected","shadow-on-hover":!0,"source-value":`[${t.products}]`}):null):null)}getFooterMenu(t){const i=this.topnav||this.limit?t.slice(0,this.limit||3):t;return e("div",null,e("div",{class:{"s-menu-footer-list":!this.topnav,"s-menu-topnav-list":this.topnav}},i.map((t=>e("a",{key:t.id,href:t.url,target:t.target,class:{"s-menu-footer-item":!this.topnav,"s-menu-topnav-item topnav-link-item right-side":this.topnav},...t.callback?{onClick:t.callback}:{}},t.title)))))}getHeaderMenu(t){return t.map((t=>[this.getMobileMenu(t,this.displayAllText),this.getDesktopMenu(t,!0)]))}render(){return"footer"===this.source?this.getFooterMenu(this.menus):[e("nav",{key:"main-nav",id:"mobile-menu",class:"mobile-menu"},e("ul",{class:"main-menu"},this.getHeaderMenu(this.menus)),e("button",{class:"btn--close close-mobile-menu sicon-cancel lg:hidden"})),e("button",{key:"close-btn",class:"btn--close-sm close-mobile-menu sicon-cancel hidden"})]}};r.style='/*!twlt*/:host{display:block}.relative{position:relative}.left-0{left:0px}.m-8{margin:2rem}.flex{display:flex}.\\!hidden{display:none !important}.hidden{display:none}.w-56{width:14rem}.w-full{width:100%}.shrink-0{flex-shrink:0}.rounded-full{border-radius:9999px}.\\!py-3{padding-top:0.75rem !important;padding-bottom:0.75rem !important}.text-sm{font-size:0.875rem;line-height:1.25rem}.font-bold{font-weight:700}.text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.shadow-default{--tw-shadow:5px 10px 30px #2B2D340D;--tw-shadow-colored:5px 10px 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-menu-item{display:none !important}@media (min-width: 1024px){.s-menu-item{display:block !important}.s-menu-root-level{display:inline-block !important}}.s-menu-non-root-level{position:relative}.s-menu-products-wrapper{flex-grow:1;padding:2rem}.s-menu-products-container{display:grid;grid-template-columns:repeat(4, minmax(0, 1fr));gap:1rem}.s-menu-submenu-unordered-list{margin:2rem;width:14rem;flex-shrink:0}.s-menu-submenu-unordered-list:where([dir="ltr"],[dir="ltr"] *){margin-right:0px}.s-menu-submenu-unordered-list:where([dir="rtl"],[dir="rtl"] *){margin-left:0px}.s-menu-submenu-with-product{left:0px;display:flex;width:100%}.s-menu-submenu-without-product{width:14rem}.s-menu-footer-item{margin-bottom:1.25rem;display:block;font-size:0.875rem;line-height:1.25rem;line-height:1}.s-menu-footer-item:last-child{margin-bottom:0px}.s-menu-topnav-list{display:none;align-items:center;white-space:nowrap}@media (min-width: 1024px){.s-menu-topnav-list{display:flex}}.s-menu-topnav-list:where([dir="ltr"],[dir="ltr"] *){padding-right:1rem}.s-menu-topnav-list:where([dir="rtl"],[dir="rtl"] *){padding-left:1rem}.s-menu-topnav-item{display:inline-block;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));padding-left:1rem;padding-right:1rem;padding-top:1px;padding-bottom:1px;font-size:0.875rem;line-height:1.25rem;line-height:1;transition-property:color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-menu-topnav-item:hover{opacity:0.8}.s-menu-topnav-item:where([dir="ltr"],[dir="ltr"] *){border-right-width:1px}.s-menu-topnav-item:first-child:where([dir="ltr"],[dir="ltr"] *){padding-left:0px}.s-menu-topnav-item:last-child:where([dir="ltr"],[dir="ltr"] *){border-width:0px;padding-right:0px}.s-menu-topnav-item:where([dir="rtl"],[dir="rtl"] *){border-left-width:1px}.s-menu-topnav-item:first-child:where([dir="rtl"],[dir="rtl"] *){padding-right:0px}.s-menu-topnav-item:last-child:where([dir="rtl"],[dir="rtl"] *){border-width:0px;padding-left:0px}@media (min-width: 1024px){.lg\\:\\!block{display:block !important}.lg\\:\\!inline-block{display:inline-block !important}.lg\\:hidden{display:none}}.ltr\\:mr-0:where([dir="ltr"],[dir="ltr"] *){margin-right:0px}.rtl\\:ml-0:where([dir="rtl"],[dir="rtl"] *){margin-left:0px}';export{r as salla_menu}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as t,h as i,H as e,a as o}from"./p-Bk24FlDL.js";var r,n;!function(t){t.PERCENTAGE="percentage",t.FIXED="fixed",t.FREE_PRODUCT="free_product",t.FREE_SHIPPING="free_shipping"}(r||(r={})),function(t){t.PRODUCT_COUNT="products_count",t.PRODUCT_PURCHASE="order_amount"}(n||(n={}));const s=Object.freeze([]);let a,l=null,c=null,d=!1,f=null,h=null,u=0;function g(t){return"CartNotCreated"===t?.name}function m(){try{const t=salla.api?.cart?.getStoredCartId?salla.api.cart.getStoredCartId():salla.storage?.get?.("cart.id");return null==t||""===t?null:String(t)}catch(t){return null}}function p(){const t=m();void 0!==a&&a!==t&&(u++,l=null,c=null,d=!1,f=null),a=t}function b(t){return null==t?0:"number"==typeof t?isFinite(t)?t:0:"string"==typeof t&&parseFloat(t)||0}function w(t){if(null==t||""===t)return null;const i=b(t);return isFinite(i)?i:null}function y(t,i){if(null!==i)return i.length;const e=w(t?.data?.cart?.count??t?.data?.count??t?.cart?.count??t?.count);return null!==e&&e>=0?e:null}function x(t){for(const i of[t?.original_price,t?.product_price,t?.price]){const t=w(i&&"object"==typeof i?i.amount:i);if(null!==t&&t>0)return t}return null}function v(t,i){const e=t?.free_gift_quantity;return null!=e&&""!==e?b(e):i>0?i:0}function k(t){const i=[];for(const e of t){if(null==e?.id)continue;if(!e.added_by_offer)continue;const t=b(e.quantity),o=v(e,t);o<=0||i.push({id:String(e.id),offerId:w(e.offer_id),quantity:o,freeQuantity:o,lineQuantity:t,name:String(e.product_name??e.name??""),imageUrl:String(e.product_image?.url??e.product_image??e.image?.url??""),imageAlt:String(e.product_image?.alt??e.image?.alt??e.product_name??""),url:String(e.url??""),originalPrice:x(e)})}return i}function _(){if(f)return f;const t=u,i=Promise.resolve().then((()=>salla.api?.cart?.details?.())).then((t=>{const i=function(t){const i=t?.data?.cart?.items??t?.data?.items??t?.cart?.items??t?.items;return Array.isArray(i)?i:null}(t);return{gifts:k(i??[]),count:y(t,i),ok:!0}})).catch((t=>({gifts:l??[],count:g(t)?0:c,ok:!1}))).then((({gifts:i,count:e,ok:o})=>{t===u&&(l=i,c=e,d=o)})).finally((()=>{f===i&&(f=null)}));return f=i,i}const C=-1;var M,T;function z(t){const i="number"==typeof t?t:parseFloat(t);return Number.isFinite(i)?i:null}function S(t){return"boolean"==typeof t?t:1===t||0===t?1===t:"true"===t||"1"===t||"false"!==t&&"0"!==t&&void 0}function L(t){return z(t)??0}function I(t,i,e){return Math.max(i,Math.min(t,e))}function V(t){const i="number"==typeof t?t:parseFloat(t);if(!Number.isFinite(i))return null;const e=Math.trunc(i);return e>=0&&e<=4?e:null}!function(t){t.LOCKED="locked",t.CURRENT="current",t.COMPLETED="completed"}(M||(M={})),function(t){t.CURRENCY="currency",t.COUNT="count"}(T||(T={}));const F=[1e3,2e3,4e3],R='[data-testid^="store-cart-item-"], form[id^="item-"]';let $=0;const P={badges_summary:":completed of :total offers unlocked",congrats:"Congratulations! You’ve unlocked all rewards in this promotion",details_title:"Offer details",free_gift:"Free Gift",free_products_title:"Free products selected from the offer",guidance_conditions_unmet:"Your cart doesn’t meet the conditions for the next reward yet",guidance_next:"Add :remaining and get :reward",guidance_next_generic:"Add :remaining to unlock the next reward",manage_offer:"Manage offer",tier_requirement:"Spend :threshold and get :reward",tier_requirement_count:"Buy :threshold and get :reward",tier_requirement_count_generic:"Buy :threshold to unlock this offer",tier_requirement_generic:"Spend :threshold to unlock this offer",tier_title:"Offer (:number)"},j="pages.checkout.free_charge";function H(t){const i=document.createElement("div");return i.textContent=t??"",i.innerHTML}const O=(t={})=>i("svg",{class:t.class,viewBox:"0 0 10 10",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false"},i("path",{d:"M5.00016 9.16634C2.69898 9.16634 0.833496 7.30084 0.833496 4.99967C0.833496 2.69849 2.69898 0.833008 5.00016 0.833008C7.30133 0.833008 9.16683 2.69849 9.16683 4.99967C9.16683 7.30084 7.30133 9.16634 5.00016 9.16634ZM4.58458 6.66634L7.53087 3.72006L6.94162 3.13081L4.58458 5.48784L3.40608 4.3093L2.81683 4.89859L4.58458 6.66634Z",fill:"currentColor"})),q=(t={})=>i("svg",{class:t.class,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false"},i("path",{d:"M12.6667 6.66683H13.3333C13.7015 6.66683 14 6.9653 14 7.3335V14.0002C14 14.3684 13.7015 14.6668 13.3333 14.6668H2.66667C2.29848 14.6668 2 14.3684 2 14.0002V7.3335C2 6.9653 2.29848 6.66683 2.66667 6.66683H3.33333V6.00016C3.33333 3.42284 5.42267 1.3335 8 1.3335C10.5773 1.3335 12.6667 3.42284 12.6667 6.00016V6.66683ZM11.3333 6.66683V6.00016C11.3333 4.15922 9.84093 2.66683 8 2.66683C6.15905 2.66683 4.66667 4.15922 4.66667 6.00016V6.66683H11.3333ZM7.33333 9.3335V12.0002H8.66667V9.3335H7.33333Z",fill:"currentColor"})),N=(t={})=>i("svg",{class:t.class,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false"},i("path",{d:"M7.00033 12.8337C3.77866 12.8337 1.16699 10.222 1.16699 7.00033C1.16699 3.77866 3.77866 1.16699 7.00033 1.16699C10.222 1.16699 12.8337 3.77866 12.8337 7.00033C12.8337 10.222 10.222 12.8337 7.00033 12.8337ZM6.41699 6.41699V9.91699H7.58366V6.41699H6.41699ZM6.41699 4.08366V5.25033H7.58366V4.08366H6.41699Z",fill:"currentColor"})),B=class{constructor(i){t(this,i),this.offer=null,this.isLoading=!1,this.canRender=!0,this.gifts=[],this.cartItemCount=null,this.isTooltipHovered=!1,this.isTooltipPinned=!1,this.isGiftsOpen=!0,this.instanceId=++$,this.refreshGeneration=0,this.giftsGeneration=0,this.cartRefreshTimer=null,this.cartRefreshPending=!1,this.wantsCartUpdates=!1,this.isListeningToCartUpdates=!1,this.cartLookupRetryTimer=null,this.cartLookupRetries=0,this.cartLookupRetryPending=!1,this.deferredByEmptyCart=!1,this.isDisconnected=!1,this.skeletonWatchdog=null,this.skeletonDeadline=0,this.hasRelocated=!1,this.hasLoaded=!1,this.relocationObserver=null,this.relocationWatchTimer=null,this.relocationWatchExpired=!1,this.relocationLogged=!1,this.cartUpdatedHandler=t=>{this.readCartCountFromEvent(t),this.clearCartLookupRetry(),this.scheduleCartRefresh()}}componentWillLoad(){this.ensureSkeletonIsWatched();try{this.isEnabled()&&this.startLoading(),this.load().catch((t=>{this.stopLoading(),this.safeLog("load() failed",t)}))}catch(t){this.stopLoading(),this.safeLog("componentWillLoad threw synchronously",t)}}safeLog(t,i){try{salla.logger.warn("salla-conditional-offer::",t,i)}catch(t){}}connectedCallback(){this.isDisconnected=!1,this.ensureSkeletonIsWatched(),this.wantsCartUpdates&&!this.isListeningToCartUpdates&&this.subscribeToCartUpdates()&&(this.cartRefreshPending=!0),this.cartRefreshPending&&this.scheduleCartRefresh(),this.cartLookupRetryPending&&this.scheduleCartLookupRetry()}disconnectedCallback(){this.isDisconnected=!0,null!==this.cartRefreshTimer&&(clearTimeout(this.cartRefreshTimer),this.cartRefreshTimer=null),null!==this.cartLookupRetryTimer&&(clearTimeout(this.cartLookupRetryTimer),this.cartLookupRetryTimer=null),Promise.resolve().then((()=>{this.isDisconnected&&this.unsubscribeFromCartUpdates()})),null!==this.skeletonWatchdog&&(clearTimeout(this.skeletonWatchdog),this.skeletonWatchdog=null),this.stopWatchingForItemsColumn()}componentDidLoad(){this.hasLoaded=!0,this.relocateIntoItemsColumn()}isShowingSomething(){return this.canRender&&this.hasCartItems()}componentDidRender(){this.hasLoaded&&this.relocateIntoItemsColumn(),this.positionTooltip(),this.ensureSkeletonIsWatched()}relocateIntoItemsColumn(){if(!this.hasRelocated&&this.isShowingSomething())try{const t=this.hostEl;if(!t?.parentElement)return;const i=this.findItemsColumn(t);if(!i)return void this.watchForItemsColumn();if(this.hasRelocated=!0,this.stopWatchingForItemsColumn(),i===t.parentElement&&i.firstElementChild===t)return;i.insertBefore(t,i.firstChild)}catch(t){this.hasRelocated=!0,this.stopWatchingForItemsColumn(),this.safeLog("relocating the banner into the cart items column failed",t)}}findItemsColumn(t){let i=t;for(let e=0;i&&e<=3;e++){for(const e of this.getFollowingSiblings(i)){if(i===t&&this.matches(e,R))return t.parentElement;const o=this.findColumnWithin(e,t);if(o)return o}if(i=i.parentElement,!i||i===document.body||i===document.documentElement)break}return null}getFollowingSiblings(t){const i=[];for(let e=t.nextElementSibling;e;e=e.nextElementSibling)i.push(e);return i}findColumnWithin(t,i){const e=t.querySelector(R),o=(e?this.climbToChildOf(e,t):null)??t.querySelector(".main-content, [data-cart-items]");return!o||o===i||o.contains(i)?null:o}climbToChildOf(t,i){let e=t;for(;e&&e.parentElement&&e.parentElement!==i;)e=e.parentElement;return e?.parentElement===i?e:null}matches(t,i){return"function"==typeof t.matches&&t.matches(i)}watchForItemsColumn(){this.hasRelocated||this.relocationWatchExpired||this.relocationObserver||("undefined"!=typeof MutationObserver?(this.relocationObserver=new MutationObserver((()=>this.relocateIntoItemsColumn())),this.relocationObserver.observe(document.documentElement,{childList:!0,subtree:!0}),this.relocationWatchTimer=setTimeout((()=>{this.relocationWatchTimer=null,this.relocationWatchExpired=!0,this.stopWatchingForItemsColumn(),this.logNoItemsColumn()}),5e3)):this.logNoItemsColumn())}stopWatchingForItemsColumn(){if(this.relocationObserver){try{this.relocationObserver.disconnect()}catch(t){}this.relocationObserver=null}null!==this.relocationWatchTimer&&(clearTimeout(this.relocationWatchTimer),this.relocationWatchTimer=null)}logNoItemsColumn(){this.relocationLogged||(this.relocationLogged=!0,this.safeLog("no cart items column found — leaving the banner at full page width"))}ensureSkeletonIsWatched(){if(!this.isLoading)return;if(null!==this.skeletonWatchdog)return;const t=Date.now();0===this.skeletonDeadline&&(this.skeletonDeadline=t+8e3);const i=Math.max(0,this.skeletonDeadline-t);this.skeletonWatchdog=setTimeout((()=>{this.skeletonWatchdog=null,this.isLoading&&(Date.now()<this.skeletonDeadline?this.ensureSkeletonIsWatched():(this.isLoading=!1,this.skeletonDeadline=0,this.safeLog("still loading after 8000ms — dropping the skeleton")))}),i)}clearSkeletonWatchdog(){this.skeletonDeadline=0,null!==this.skeletonWatchdog&&(clearTimeout(this.skeletonWatchdog),this.skeletonWatchdog=null)}startLoading(){this.isLoading=!0,this.ensureSkeletonIsWatched()}stopLoading(){this.isLoading=!1,this.clearSkeletonWatchdog()}async load(){this.wantsCartUpdates=!0,this.subscribeToCartUpdates()||this.subscribeWhenSdkIsReady(),this.loadCart(),await this.waitForSdk(),await this.refresh()}waitForSdk(){let t,i;try{t=Promise.resolve(salla.onReady?.())}catch(t){return this.safeLog("salla.onReady() threw",t),Promise.resolve()}const e=new Promise((t=>{i=setTimeout(t,3e3)}));return Promise.race([t.catch((t=>this.safeLog("salla.onReady() rejected",t))),e]).then((()=>{clearTimeout(i)}))}subscribeToCartUpdates(){if(this.isListeningToCartUpdates)return!0;try{salla.event.on("cart::updated",this.cartUpdatedHandler),this.isListeningToCartUpdates=!0}catch(t){this.safeLog("cart::updated subscription failed",t)}return this.isListeningToCartUpdates}unsubscribeFromCartUpdates(){if(this.isListeningToCartUpdates){this.isListeningToCartUpdates=!1;try{salla.event.off("cart::updated",this.cartUpdatedHandler)}catch(t){this.safeLog("cart::updated unsubscription failed",t)}}}subscribeWhenSdkIsReady(){let t;try{t=Promise.resolve(salla.onReady?.())}catch(t){return}const i=()=>{this.isDisconnected||this.subscribeToCartUpdates()};t.then(i,i)}scheduleCartRefresh(){this.cartRefreshPending=!0,null!==this.cartRefreshTimer&&clearTimeout(this.cartRefreshTimer),this.cartRefreshTimer=null,this.isDisconnected||(this.cartRefreshTimer=setTimeout((()=>{this.cartRefreshTimer=null,this.runCartRefresh()}),200))}runCartRefresh(){this.isDisconnected||(this.cartRefreshPending=!1,this.refresh(),function(){if(h)return h;u++,l=null,c=null,d=!1,a=m();const t=()=>(h===i&&(h=null),_()),i=(f??Promise.resolve()).then(t,t).finally((()=>{h===i&&(h=null)}));return h=i,i}().then((()=>this.loadCart()),(()=>this.loadCart())))}readCartCountFromEvent(t){const i=this.toCartCount(t?.count)??this.readCartCountFromStorage();null!==i&&(this.cartItemCount=i)}readCartCountFromStorage(){try{return this.toCartCount(salla.storage?.get?.("cart.summary.count"))}catch(t){return null}}toCartCount(t){return"number"==typeof t&&Number.isFinite(t)&&t>=0?t:null}getFreeLabel(){const t=salla.lang.get(j);return t&&t!==j?t:"Free"}trans(t,i){const e=`blocks.cart_offer.${t}`,o=salla.lang.get(e,i);return o&&o!==e?o:Object.entries(i??{}).reduce(((t,[i,e])=>t.split(`:${i}`).join(e)),P[t])}isEnabled(){try{return!!salla.config.get("store.features")?.includes("conditional-offer")}catch(t){return!1}}async fetchOffer(){const{data:t}=await salla.api.cart.offers(),i=(t||[]).find((t=>"conditional"===t.type));return i?.details?.discounts?.length?i:null}async refresh(){const t=++this.refreshGeneration;if(!this.isEnabled())return this.stopLoading(),void(this.canRender=!1);if(0===this.cartItemCount)return this.stopLoading(),p(),void(d||(this.deferredByEmptyCart=!0,this.loadCart()));this.deferredByEmptyCart=!1,this.offer?this.stopLoading():this.startLoading();try{const i=await this.fetchOffer();if(this.isSuperseded(t))return;if(!i)return this.offer=null,void(this.canRender=!1);this.offer=i,this.canRender=!0,this.loadCart()}catch(i){if(this.isSuperseded(t))return;this.safeLog("offers() failed",i)}finally{t===this.refreshGeneration&&this.stopLoading()}}hasCartItems(){return"number"==typeof this.cartItemCount&&this.cartItemCount>=1}isSuperseded(t){return t!==this.refreshGeneration||this.isDisconnected}loadCart(){const t=++this.giftsGeneration;return Promise.all([(p(),d&&l?Promise.resolve(l):_().then((()=>l??s))),(p(),d&&l?Promise.resolve(c):_().then((()=>c)))]).then((([i,e])=>{t!==this.giftsGeneration||this.isDisconnected||this.cartRefreshPending||(null!==e&&(this.cartItemCount=e),null!==e?this.clearCartLookupRetry():null===this.cartItemCount&&this.scheduleCartLookupRetry(),this.deferredByEmptyCart&&this.hasCartItems()&&(this.deferredByEmptyCart=!1,this.refresh()),this.gifts=this.offer?this.selectOwnGifts(i):[])})).catch((t=>{this.safeLog("cart lookup failed",t)}))}scheduleCartLookupRetry(){this.cartLookupRetries>=F.length||(this.cartLookupRetryPending=!0,null!==this.cartLookupRetryTimer||this.isDisconnected||(this.cartLookupRetryTimer=setTimeout((()=>{this.cartLookupRetryTimer=null,this.cartLookupRetryPending=!1,this.canRender&&(this.cartLookupRetries++,this.loadCart())}),F[this.cartLookupRetries])))}clearCartLookupRetry(){this.cartLookupRetries=0,this.cartLookupRetryPending=!1,null!==this.cartLookupRetryTimer&&(clearTimeout(this.cartLookupRetryTimer),this.cartLookupRetryTimer=null)}selectOwnGifts(t){const i=Number(this.offer?.id);if(!Number.isFinite(i))return t;const e=t.filter((t=>null!==t.offerId&&Number(t.offerId)===i));return e.length?e:t.filter((t=>null===t.offerId))}getStages(){const t=(this.offer?.details?.discounts??[]).filter((({min_spend:t})=>null!==z(t)));return i=({min_spend:t})=>t,e=({id:t})=>t,(t??[]).map(((t,o)=>({item:t,index:o,threshold:L(i(t)),identity:e?z(e(t)):null}))).sort(((t,i)=>t.threshold!==i.threshold?t.threshold-i.threshold:null!==t.identity&&null!==i.identity&&t.identity!==i.identity?t.identity-i.identity:t.index-i.index)).map((({item:t})=>t));var i,e}getProgress(t){return function(t,i,e=0,o=[],r=[]){const n=(i??[]).map(((t,i)=>({index:i,threshold:z(t),applied:S(o?.[i]),tierValue:z(r?.[i])}))).filter((t=>null!==t.threshold)).sort(((t,i)=>t.threshold-i.threshold||t.index-i.index)),s=n.map((t=>t.threshold)),a=n.map((t=>t.applied)),l=a.some((t=>void 0!==t)),c=L(e);if(!s.length)return{thresholds:s,met:[],applied:a,appliedIndex:C,hasEngineVerdict:l,metCount:0,nextUnmetIndex:C,allMet:!1,lastReachedIndex:C,currentIndex:C,isComplete:!1,value:Math.max(0,L(t)),values:[],startValue:c,fills:[],overallPercentage:0};const d=s[s.length-1],f=I(L(t),0,Math.max(0,d)),h=n.map((({tierValue:t})=>null===t?f:I(t,0,Math.max(0,d))));let u=C;for(let t=0;t<s.length;t++)h[t]>=s[t]&&(u=t);const g=u===s.length-1,m=g?C:u+1,p=s.map(((t,i)=>function(t,i,e){return e<=i?t>=e?100:0:I((t-i)/(e-i)*100,0,100)}(h[i],0===i?c:s[i-1],t))),b=g?100:I((u+1+(p[m]??0)/100)/s.length*100,0,100);let w=C;for(let t=0;t<a.length;t++)!0===a[t]&&(w=t);const y=s.map(l?(t,i)=>i<=w:(t,i)=>i<=u),x=y.filter(Boolean).length,v=y.findIndex((t=>!t));return{thresholds:s,met:y,applied:a,appliedIndex:w,hasEngineVerdict:l,metCount:x,nextUnmetIndex:v,allMet:v===C,lastReachedIndex:u,currentIndex:m,isComplete:g,value:f,values:h,startValue:c,fills:p,overallPercentage:b}}(this.offer?.details?.current_value,t.map((({min_spend:t})=>t)),this.offer?.details?.start_value,t.map((({is_applied:t})=>t)),t.map((({current_value:t})=>t)))}tierKey(t,i){const e=Number(t?.id);return Number.isFinite(e)?`tier-${e}`:`pos-${i}`}stageMeasure(){return this.offer?.details?.based_on===n.PRODUCT_COUNT?T.COUNT:T.CURRENCY}formatRequirement(t){const i=this.offer?.details?.based_on;if(i===n.PRODUCT_COUNT)try{return salla.lang.choice("blocks.header.products_count",t)}catch(i){return this.safeLog("invalid products_count interval",i),`${t}`}return i===n.PRODUCT_PURCHASE?salla.money(t):(this.safeLog(`unexpected offer detail's based_on value: ${i}`),`${t}`)}getRewardText(t){return(t?.reward_label??"").trim()}getGuidanceMessage(t,i){if(i.nextUnmetIndex===C)return"";const e=function(t,i,e=T.CURRENCY){const o=i.thresholds[t];if(void 0===o)return 0;const r=Math.max(0,o-(i.values?.[t]??i.value));if(0===r)return 0;const n=e===T.COUNT?0:function(){try{const t="undefined"!=typeof salla?salla:void 0,i=V(t?.config?.currency?.()?.decimals);if(null!==i)return i;const e=V(t?.config?.get?.("store.currency.decimals"));if(null!==e)return e}catch(t){}return 2}(),s=Math.pow(10,n),a=Math.ceil(r*s-1e-6)/s;return a>0?a:1/s}(i.nextUnmetIndex,i,this.stageMeasure());if(e<=0)return this.trans("guidance_conditions_unmet");const o=this.formatRequirement(e),r=this.getRewardText(t[i.nextUnmetIndex]);return r?this.trans("guidance_next",{remaining:o,reward:H(r)}):this.trans("guidance_next_generic",{remaining:o})}getTierSentence(t,i,e){const o=this.formatRequirement(e.thresholds[i]),r=this.getRewardText(t),n=this.stageMeasure()===T.COUNT;return r?this.trans(n?"tier_requirement_count":"tier_requirement",{threshold:o,reward:H(r)}):this.trans(n?"tier_requirement_count_generic":"tier_requirement_generic",{threshold:o})}getRewardIcon(t){switch(t?.type){case r.PERCENTAGE:return"sicon-percentage";case r.FREE_PRODUCT:return"sicon-gift";case r.FIXED:return this.usesSarSymbol()?"sicon-sar":"sicon-banknote";default:return"sicon-tag"}}usesSarSymbol(){try{const t=salla.config.currency?.()?.symbol;return["SAR","ر.س"].includes(t)&&!!salla.config.get("store.settings.use_sar_symbol")}catch(t){return!1}}get isTooltipOpen(){return this.isTooltipHovered||this.isTooltipPinned}toggleTooltip(){this.isTooltipPinned=!this.isTooltipPinned}closeTooltip(t=!1){this.isTooltipOpen&&(this.isTooltipPinned=!1,this.isTooltipHovered=!1,t&&this.infoTriggerEl?.focus?.())}positionTooltip(){const t=this.tooltipEl,i=this.infoTriggerEl;if(this.isTooltipOpen&&t&&i)try{this.setTooltipOffsets(t,0,0);const e=window.innerWidth||document.documentElement?.clientWidth||0,o=t.getBoundingClientRect(),r=i.getBoundingClientRect(),n=o?.width||0;if(n<=0||e<=0)return;const s=r.left+r.width/2-n/2,a=8,l=Math.min(Math.max(s,a),Math.max(a,e-a-n))-s,c=Math.max(0,n/2-16),d=Math.min(Math.max(-l,-c),c);this.setTooltipOffsets(t,l,d)}catch(t){this.safeLog("positioning the offer details popover failed",t)}}setTooltipOffsets(t,i,e){t.style?.setProperty?.("--s-conditional-offer-tooltip-shift",`${Math.round(i)}px`),t.style?.setProperty?.("--s-conditional-offer-tooltip-caret",`${Math.round(e)}px`)}handleWindowResize(){this.positionTooltip()}handleDocumentKeydown(t){"Escape"!==t.key&&"Esc"!==t.key||this.closeTooltip(!0)}handleDocumentClick(t){if(!this.isTooltipPinned||!this.infoAnchorEl)return;const i="function"==typeof t.composedPath?t.composedPath():[];(i.length?i.includes(this.infoAnchorEl):this.infoAnchorEl.contains(t.target))||this.closeTooltip()}elementId(t){return`s-conditional-offer-${t}-${this.instanceId}`}renderBadges(t,e){return i("div",{class:"s-conditional-offer-badges",role:"img","aria-label":this.trans("badges_summary",{completed:`${e.metCount}`,total:`${t.length}`})},t.map(((t,o)=>{const r=e.met[o],n=this.tierKey(t,o);return[o>0?i("span",{key:`${n}-link`,class:{"s-conditional-offer-badge-link":!0,"s-conditional-offer-badge-link-met":r,"s-conditional-offer-badge-link-unmet":!r},"aria-hidden":"true"}):null,i("span",{key:n,class:{"s-conditional-offer-badge":!0,"s-conditional-offer-badge-met":r,"s-conditional-offer-badge-unmet":!r},"data-tier-state":r?"met":"unmet","data-tier-id":t?.id??void 0},i(r?O:q,{class:"s-conditional-offer-badge-icon"}))]})))}renderTooltip(t,e){const o=function(t){const i=t?.details?.rules;if("string"==typeof i){const t=i.trim();return""===t?null:t}if(Array.isArray(i)){const t=i.filter((t=>"string"==typeof t)).map((t=>t.trim())).filter((t=>""!==t)).join(" ");return""===t?null:t}return null}(this.offer);return i("div",{class:"s-conditional-offer-tooltip",id:this.elementId("tooltip"),role:"tooltip",ref:t=>this.tooltipEl=t},i("div",{class:"s-conditional-offer-tooltip-title"},this.offer?.title),o?i("div",{class:"s-conditional-offer-tooltip-description"},o):null,i("ul",{class:"s-conditional-offer-tooltip-list"},t.map(((t,o)=>{const r=e.met[o];return i("li",{key:this.tierKey(t,o),class:"s-conditional-offer-tier","data-tier-state":r?"met":"unmet","data-tier-id":t?.id??void 0},i("span",{class:{"s-conditional-offer-tier-icon":!0,"s-conditional-offer-tier-icon-met":r,"s-conditional-offer-tier-icon-unmet":!r}},i("i",{class:this.getRewardIcon(t),"aria-hidden":"true"}),i("span",{class:{"s-conditional-offer-tier-status":!0,"s-conditional-offer-tier-status-met":r,"s-conditional-offer-tier-status-unmet":!r},"aria-hidden":"true"},r?i(O,{class:"s-conditional-offer-tier-status-check"}):i(q,{class:"s-conditional-offer-tier-status-lock"}))),i("div",{class:"s-conditional-offer-tier-body"},i("div",{class:"s-conditional-offer-tier-title"},this.trans("tier_title",{number:`${o+1}`})),i("div",{class:{"s-conditional-offer-tier-text":!0,"s-conditional-offer-tier-text-met":r},innerHTML:this.getTierSentence(t,o,e)})))}))))}renderGiftsToggle(t){return i("button",{type:"button",id:this.elementId(`toggle-${t}`),class:{"s-conditional-offer-toggle":!0,"s-conditional-offer-toggle-inline":"inline"===t,"s-conditional-offer-toggle-bar":"bar"===t},"aria-expanded":this.isGiftsOpen?"true":"false","aria-controls":this.elementId("gifts"),onClick:()=>this.isGiftsOpen=!this.isGiftsOpen},i("span",null,this.trans("manage_offer")),i("i",{class:{"sicon-keyboard_arrow_down":!0,"s-conditional-offer-toggle-icon":!0,"s-conditional-offer-toggle-icon-open":this.isGiftsOpen},"aria-hidden":"true"}))}renderGiftsCard(){return i("div",{class:"s-conditional-offer-panel",id:this.elementId("gifts")},i("div",{class:"s-conditional-offer-gifts-header"},i("span",{class:"s-conditional-offer-gifts-icon"},i("i",{class:"sicon-gift","aria-hidden":"true"})),i("span",{class:"s-conditional-offer-gifts-title"},this.trans("free_products_title"))),i("ul",{class:"s-conditional-offer-gifts-list"},this.gifts.map((t=>this.renderGiftRow(t)))))}renderGiftRow(t){return i("li",{class:"s-conditional-offer-gift","data-item-id":t.id},i("span",{class:"s-conditional-offer-gift-thumb"},t.imageUrl?i("img",{class:"s-conditional-offer-gift-image",src:t.imageUrl,alt:t.imageAlt||t.name,loading:"lazy",decoding:"async"}):i("i",{class:"sicon-gift","aria-hidden":"true"})),i("div",{class:"s-conditional-offer-gift-body"},i("span",{class:"s-conditional-offer-gift-name"},t.name||this.trans("free_gift")),i("span",{class:"s-conditional-offer-gift-prices"},i("span",{class:"s-conditional-offer-gift-free"},this.getFreeLabel()),null!==t.originalPrice?i("span",{class:"s-conditional-offer-gift-price",innerHTML:salla.money(t.originalPrice)}):null)))}getLoadingSkeletonView(){return i(e,{class:"s-conditional-offer-root"},i("div",{class:"s-conditional-offer-banner"},i("div",{class:"s-conditional-offer-lead"},i("salla-skeleton",{height:"24px",width:"80px"}),i("div",{class:"s-conditional-offer-skeleton-text"},i("salla-skeleton",{height:"12px",width:"35%"}),i("salla-skeleton",{height:"16px",width:"60%"})))))}render(){if(!this.canRender)return null;if(!this.hasCartItems())return null;if(this.isLoading)return this.getLoadingSkeletonView();if(!this.offer)return null;const t=this.getStages(),o=this.getProgress(t),r=this.getGuidanceMessage(t,o),n=this.trans("details_title"),s=this.gifts.length>0;return i(e,{class:"s-conditional-offer-root"},i("div",{class:"s-conditional-offer-banner"},i("div",{class:"s-conditional-offer-lead"},this.renderBadges(t,o),i("div",{class:"s-conditional-offer-text"},i("div",{class:"s-conditional-offer-heading",onMouseEnter:()=>this.isTooltipHovered=!0,onMouseLeave:()=>this.isTooltipHovered=!1},i("span",{class:"s-conditional-offer-name"},this.offer.title),i("span",{class:"s-conditional-offer-info",ref:t=>this.infoAnchorEl=t},i("button",{type:"button",class:"s-conditional-offer-info-trigger",ref:t=>this.infoTriggerEl=t,"aria-label":n,title:n,"aria-expanded":this.isTooltipOpen?"true":"false","aria-describedby":this.elementId("tooltip"),onClick:()=>this.toggleTooltip()},i(N,{class:"s-conditional-offer-info-icon"})),this.isTooltipOpen?this.renderTooltip(t,o):null)),o.allMet?i("div",{class:"s-conditional-offer-message",role:"status"},this.trans("congrats")):r?i("div",{class:"s-conditional-offer-message",innerHTML:r}):null)),s?this.renderGiftsToggle("inline"):null),s&&this.isGiftsOpen?this.renderGiftsCard():null,s?this.renderGiftsToggle("bar"):null)}get hostEl(){return o(this)}};B.style='/*!twlt*/:host{display:block}.s-conditional-offer-root{background-color:rgba(0, 137, 123, 0.06);background-color:color-mix(in srgb, var(--color-primary, #00897b) 7%, transparent)}.s-conditional-offer-badges::-webkit-scrollbar{height:3px}.s-conditional-offer-badges::-webkit-scrollbar-thumb{border-radius:9999px;background-color:rgba(0, 0, 0, 0.15)}.s-conditional-offer-badges::-webkit-scrollbar-track{background-color:transparent}.s-conditional-offer-tooltip{--s-conditional-offer-tooltip-shift:0px;--s-conditional-offer-tooltip-caret:0px;transform:translateX(calc(-50% + var(--s-conditional-offer-tooltip-shift)))}.s-conditional-offer-tooltip::before{content:"";position:absolute;bottom:100%;left:50%;transform:translateX(calc(-50% + var(--s-conditional-offer-tooltip-caret)));border:8px solid transparent;border-bottom-color:#fff}.s-conditional-offer-tier-icon-met,.s-conditional-offer-tier-icon-unmet{color:var(--color-primary-dark, #00695c);background-color:rgba(0, 137, 123, 0.12);background-color:color-mix(in srgb, var(--color-primary, #00897b) 14%, transparent)}.s-conditional-offer-tier:not(:last-child)::before{content:"";position:absolute;top:2.5rem;bottom:-1rem;inset-inline-start:1.125rem;width:1px;background-color:#d1d5db}.visible{visibility:visible}.invisible{visibility:hidden}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.block{display:block}.inline{display:inline}.flex{display:flex}.hidden{display:none}.w-6{width:1.5rem}.resize{resize:both}.gap-1{gap:0.25rem}.rounded{border-radius:var(--s-radius, 0.25rem)}.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-conditional-offer-root{margin-bottom:1.25rem;display:block;width:100%;min-width:0px;max-width:100%;border-radius:0.375rem;padding:0.75rem}@media (min-width: 768px){.s-conditional-offer-root{padding:1rem}}.s-conditional-offer-banner{display:flex;width:100%;min-width:0px;align-items:center;justify-content:space-between;gap:0.75rem}@media (min-width: 768px){.s-conditional-offer-banner{gap:1rem}}.s-conditional-offer-lead{display:flex;min-width:0px;flex:1 1 0%;align-items:center;gap:0.5rem}@media (min-width: 768px){.s-conditional-offer-lead{gap:0.75rem}}.s-conditional-offer-badges{display:flex;max-width:45%;flex-shrink:0;flex-wrap:nowrap;align-items:center;gap:0.25rem;overflow-x:auto;overscroll-behavior-x:contain;scroll-behavior:smooth;scrollbar-width:thin}.s-conditional-offer-badge{display:inline-flex;height:1.5rem;width:1.5rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;font-size:11px;line-height:1;--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.s-conditional-offer-badge-met{background-color:var(--color-primary)}.s-conditional-offer-badge-unmet{--tw-bg-opacity:1;background-color:rgb(156 163 175 / var(--tw-bg-opacity, 1))}.s-conditional-offer-badge-link{width:0.5rem;flex-shrink:0;border-top-width:1px}.s-conditional-offer-badge-link-met{border-color:var(--color-primary)}.s-conditional-offer-badge-link-unmet{border-style:dashed;--tw-border-opacity:1;border-color:rgb(82 82 82 / var(--tw-border-opacity, 1))}.s-conditional-offer-badge-icon{height:0.75rem;width:0.75rem;flex-shrink:0}.s-conditional-offer-text{display:flex;min-width:0px;flex-direction:column;gap:0.125rem;text-align:start}.s-conditional-offer-heading{display:flex;min-width:0px;align-items:center;gap:0.375rem}.s-conditional-offer-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:0.75rem;line-height:1rem;--tw-text-opacity:1;color:rgb(82 82 82 / var(--tw-text-opacity, 1))}.s-conditional-offer-info{position:relative;display:inline-flex;flex-shrink:0;align-items:center}.s-conditional-offer-info-trigger{display:inline-flex;height:1rem;width:1rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;--tw-text-opacity:1;color:rgb(115 115 115 / 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:300ms}.s-conditional-offer-info-trigger:hover{color:var(--color-primary-dark)}.s-conditional-offer-info-icon{height:0.875rem;width:0.875rem;flex-shrink:0}.s-conditional-offer-message{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark)}@media (min-width: 768px){.s-conditional-offer-message{font-size:1rem;line-height:1.5rem}}.s-conditional-offer-toggle{align-items:center;justify-content:center;gap:0.375rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(38 38 38 / 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:300ms}.s-conditional-offer-toggle:hover{color:var(--color-primary-dark)}.s-conditional-offer-toggle-inline{display:none;flex-shrink:0}@media (min-width: 768px){.s-conditional-offer-toggle-inline{display:inline-flex}}.s-conditional-offer-toggle-bar{margin-top:0.5rem;display:inline-flex;width:100%;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding-left:0.75rem;padding-right:0.75rem;padding-top:0.625rem;padding-bottom:0.625rem}@media (min-width: 768px){.s-conditional-offer-toggle-bar{display:none}}.s-conditional-offer-toggle-icon{font-size:1rem;line-height:1.5rem;line-height:1;transition-property:transform;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-conditional-offer-toggle-icon-open{--tw-rotate:180deg;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-conditional-offer-panel{margin-top:0.75rem;width:100%;min-width:0px;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:0.75rem}.s-conditional-offer-gifts-header{margin-bottom:0.75rem;display:flex;align-items:center;gap:0.5rem}.s-conditional-offer-gifts-icon{display:inline-flex;height:2rem;width:2rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;border-width:1px;border-color:var(--color-primary);font-size:1rem;line-height:1.5rem;line-height:1;color:var(--color-primary)}.s-conditional-offer-gifts-title{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-gifts-list{margin:0px;display:flex;list-style-type:none;flex-direction:column;gap:0.5rem;padding:0px}.s-conditional-offer-gift{display:flex;align-items:center;gap:0.75rem;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));padding:0.5rem}.s-conditional-offer-gift-thumb{display:inline-flex;height:3.5rem;width:3.5rem;flex-shrink:0;align-items:center;justify-content:center;overflow:hidden;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.s-conditional-offer-gift-image{height:100%;width:100%;object-fit:contain}.s-conditional-offer-gift-body{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.125rem;text-align:start}.s-conditional-offer-gift-name{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;font-size:0.875rem;line-height:1.25rem;font-weight:700;--tw-text-opacity:1;color:rgb(38 38 38 / var(--tw-text-opacity, 1))}.s-conditional-offer-gift-prices{display:flex;align-items:center;gap:0.5rem;font-size:0.75rem;line-height:1rem}.s-conditional-offer-gift-free{font-weight:700;--tw-text-opacity:1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.s-conditional-offer-gift-price{--tw-text-opacity:1;color:rgb(115 115 115 / var(--tw-text-opacity, 1));text-decoration-line:line-through}.s-conditional-offer-tooltip{position:absolute;top:calc(100% + 0.75rem);left:50%;z-index:10;width:min(22rem, calc(100vw - 2rem));border-radius:0.5rem;--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1rem;text-align:start;--tw-shadow:5px 10px 30px #2B2D340D;--tw-shadow-colored:5px 10px 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-conditional-offer-tooltip-title{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-tooltip-description{margin-top:0.25rem;font-size:0.75rem;line-height:1rem;line-height:1.625;--tw-text-opacity:1;color:rgb(82 82 82 / var(--tw-text-opacity, 1))}.s-conditional-offer-tooltip-list{margin:0px;margin-top:0.75rem;display:flex;list-style-type:none;flex-direction:column;gap:1rem;padding:0px}.s-conditional-offer-tier{position:relative;display:flex;align-items:flex-start;gap:0.75rem}.s-conditional-offer-tier-icon{position:relative;display:inline-flex;height:2.25rem;width:2.25rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;font-size:1rem;line-height:1.5rem;line-height:1}.s-conditional-offer-tier-icon-unmet{color:var(--color-primary-dark)}.s-conditional-offer-tier-status{position:absolute;bottom:-0.125rem;display:inline-flex;height:1rem;width:1rem;align-items:center;justify-content:center;border-radius:9999px;border-width:2px;--tw-border-opacity:1;border-color:rgb(255 255 255 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));inset-inline-start:-2px}.s-conditional-offer-tier-status-met{color:var(--color-primary-dark)}.s-conditional-offer-tier-status-unmet{--tw-text-opacity:1;color:rgb(163 163 163 / var(--tw-text-opacity, 1))}.s-conditional-offer-tier-status-check{height:0.75rem;width:0.75rem;flex-shrink:0}.s-conditional-offer-tier-status-lock{height:0.625rem;width:0.625rem;flex-shrink:0}.s-conditional-offer-tier-body{display:flex;min-width:0px;flex-direction:column;gap:0.125rem}.s-conditional-offer-tier-title{font-size:0.75rem;line-height:1rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-tier-text{font-size:0.75rem;line-height:1rem;line-height:1.625;--tw-text-opacity:1;color:rgb(82 82 82 / var(--tw-text-opacity, 1))}.s-conditional-offer-tier-text-met{text-decoration-line:line-through}.s-conditional-offer-skeleton-text{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.375rem}';export{B as salla_conditional_offer}
|
|
4
|
+
import{r as t,h as i,H as e,a as o}from"./p-Bxge4xib.js";var r,n;!function(t){t.PERCENTAGE="percentage",t.FIXED="fixed",t.FREE_PRODUCT="free_product",t.FREE_SHIPPING="free_shipping"}(r||(r={})),function(t){t.PRODUCT_COUNT="products_count",t.PRODUCT_PURCHASE="order_amount"}(n||(n={}));const s=Object.freeze([]);let a,l=null,c=null,d=!1,f=null,h=null,u=0;function g(t){return"CartNotCreated"===t?.name}function m(){try{const t=salla.api?.cart?.getStoredCartId?salla.api.cart.getStoredCartId():salla.storage?.get?.("cart.id");return null==t||""===t?null:String(t)}catch(t){return null}}function p(){const t=m();void 0!==a&&a!==t&&(u++,l=null,c=null,d=!1,f=null),a=t}function b(t){return null==t?0:"number"==typeof t?isFinite(t)?t:0:"string"==typeof t&&parseFloat(t)||0}function w(t){if(null==t||""===t)return null;const i=b(t);return isFinite(i)?i:null}function y(t,i){if(null!==i)return i.length;const e=w(t?.data?.cart?.count??t?.data?.count??t?.cart?.count??t?.count);return null!==e&&e>=0?e:null}function x(t){for(const i of[t?.original_price,t?.product_price,t?.price]){const t=w(i&&"object"==typeof i?i.amount:i);if(null!==t&&t>0)return t}return null}function v(t,i){const e=t?.free_gift_quantity;return null!=e&&""!==e?b(e):i>0?i:0}function k(t){const i=[];for(const e of t){if(null==e?.id)continue;if(!e.added_by_offer)continue;const t=b(e.quantity),o=v(e,t);o<=0||i.push({id:String(e.id),offerId:w(e.offer_id),quantity:o,freeQuantity:o,lineQuantity:t,name:String(e.product_name??e.name??""),imageUrl:String(e.product_image?.url??e.product_image??e.image?.url??""),imageAlt:String(e.product_image?.alt??e.image?.alt??e.product_name??""),url:String(e.url??""),originalPrice:x(e)})}return i}function _(){if(f)return f;const t=u,i=Promise.resolve().then((()=>salla.api?.cart?.details?.())).then((t=>{const i=function(t){const i=t?.data?.cart?.items??t?.data?.items??t?.cart?.items??t?.items;return Array.isArray(i)?i:null}(t);return{gifts:k(i??[]),count:y(t,i),ok:!0}})).catch((t=>({gifts:l??[],count:g(t)?0:c,ok:!1}))).then((({gifts:i,count:e,ok:o})=>{t===u&&(l=i,c=e,d=o)})).finally((()=>{f===i&&(f=null)}));return f=i,i}const C=-1;var M,T;function z(t){const i="number"==typeof t?t:parseFloat(t);return Number.isFinite(i)?i:null}function S(t){return"boolean"==typeof t?t:1===t||0===t?1===t:"true"===t||"1"===t||"false"!==t&&"0"!==t&&void 0}function L(t){return z(t)??0}function I(t,i,e){return Math.max(i,Math.min(t,e))}function V(t){const i="number"==typeof t?t:parseFloat(t);if(!Number.isFinite(i))return null;const e=Math.trunc(i);return e>=0&&e<=4?e:null}!function(t){t.LOCKED="locked",t.CURRENT="current",t.COMPLETED="completed"}(M||(M={})),function(t){t.CURRENCY="currency",t.COUNT="count"}(T||(T={}));const F=[1e3,2e3,4e3],R='[data-testid^="store-cart-item-"], form[id^="item-"]';let $=0;const P={badges_summary:":completed of :total offers unlocked",congrats:"Congratulations! You’ve unlocked all rewards in this promotion",details_title:"Offer details",free_gift:"Free Gift",free_products_title:"Free products selected from the offer",guidance_conditions_unmet:"Your cart doesn’t meet the conditions for the next reward yet",guidance_next:"Add :remaining and get :reward",guidance_next_generic:"Add :remaining to unlock the next reward",manage_offer:"Manage offer",tier_requirement:"Spend :threshold and get :reward",tier_requirement_count:"Buy :threshold and get :reward",tier_requirement_count_generic:"Buy :threshold to unlock this offer",tier_requirement_generic:"Spend :threshold to unlock this offer",tier_title:"Offer (:number)"},j="pages.checkout.free_charge";function H(t){const i=document.createElement("div");return i.textContent=t??"",i.innerHTML}const O=(t={})=>i("svg",{class:t.class,viewBox:"0 0 10 10",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false"},i("path",{d:"M5.00016 9.16634C2.69898 9.16634 0.833496 7.30084 0.833496 4.99967C0.833496 2.69849 2.69898 0.833008 5.00016 0.833008C7.30133 0.833008 9.16683 2.69849 9.16683 4.99967C9.16683 7.30084 7.30133 9.16634 5.00016 9.16634ZM4.58458 6.66634L7.53087 3.72006L6.94162 3.13081L4.58458 5.48784L3.40608 4.3093L2.81683 4.89859L4.58458 6.66634Z",fill:"currentColor"})),q=(t={})=>i("svg",{class:t.class,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false"},i("path",{d:"M12.6667 6.66683H13.3333C13.7015 6.66683 14 6.9653 14 7.3335V14.0002C14 14.3684 13.7015 14.6668 13.3333 14.6668H2.66667C2.29848 14.6668 2 14.3684 2 14.0002V7.3335C2 6.9653 2.29848 6.66683 2.66667 6.66683H3.33333V6.00016C3.33333 3.42284 5.42267 1.3335 8 1.3335C10.5773 1.3335 12.6667 3.42284 12.6667 6.00016V6.66683ZM11.3333 6.66683V6.00016C11.3333 4.15922 9.84093 2.66683 8 2.66683C6.15905 2.66683 4.66667 4.15922 4.66667 6.00016V6.66683H11.3333ZM7.33333 9.3335V12.0002H8.66667V9.3335H7.33333Z",fill:"currentColor"})),N=(t={})=>i("svg",{class:t.class,viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false"},i("path",{d:"M7.00033 12.8337C3.77866 12.8337 1.16699 10.222 1.16699 7.00033C1.16699 3.77866 3.77866 1.16699 7.00033 1.16699C10.222 1.16699 12.8337 3.77866 12.8337 7.00033C12.8337 10.222 10.222 12.8337 7.00033 12.8337ZM6.41699 6.41699V9.91699H7.58366V6.41699H6.41699ZM6.41699 4.08366V5.25033H7.58366V4.08366H6.41699Z",fill:"currentColor"})),B=class{constructor(i){t(this,i),this.offer=null,this.isLoading=!1,this.canRender=!0,this.gifts=[],this.cartItemCount=null,this.isTooltipHovered=!1,this.isTooltipPinned=!1,this.isGiftsOpen=!0,this.instanceId=++$,this.refreshGeneration=0,this.giftsGeneration=0,this.cartRefreshTimer=null,this.cartRefreshPending=!1,this.wantsCartUpdates=!1,this.isListeningToCartUpdates=!1,this.cartLookupRetryTimer=null,this.cartLookupRetries=0,this.cartLookupRetryPending=!1,this.deferredByEmptyCart=!1,this.isDisconnected=!1,this.skeletonWatchdog=null,this.skeletonDeadline=0,this.hasRelocated=!1,this.hasLoaded=!1,this.relocationObserver=null,this.relocationWatchTimer=null,this.relocationWatchExpired=!1,this.relocationLogged=!1,this.cartUpdatedHandler=t=>{this.readCartCountFromEvent(t),this.clearCartLookupRetry(),this.scheduleCartRefresh()}}componentWillLoad(){this.ensureSkeletonIsWatched();try{this.isEnabled()&&this.startLoading(),this.load().catch((t=>{this.stopLoading(),this.safeLog("load() failed",t)}))}catch(t){this.stopLoading(),this.safeLog("componentWillLoad threw synchronously",t)}}safeLog(t,i){try{salla.logger.warn("salla-conditional-offer::",t,i)}catch(t){}}connectedCallback(){this.isDisconnected=!1,this.ensureSkeletonIsWatched(),this.wantsCartUpdates&&!this.isListeningToCartUpdates&&this.subscribeToCartUpdates()&&(this.cartRefreshPending=!0),this.cartRefreshPending&&this.scheduleCartRefresh(),this.cartLookupRetryPending&&this.scheduleCartLookupRetry()}disconnectedCallback(){this.isDisconnected=!0,null!==this.cartRefreshTimer&&(clearTimeout(this.cartRefreshTimer),this.cartRefreshTimer=null),null!==this.cartLookupRetryTimer&&(clearTimeout(this.cartLookupRetryTimer),this.cartLookupRetryTimer=null),Promise.resolve().then((()=>{this.isDisconnected&&this.unsubscribeFromCartUpdates()})),null!==this.skeletonWatchdog&&(clearTimeout(this.skeletonWatchdog),this.skeletonWatchdog=null),this.stopWatchingForItemsColumn()}componentDidLoad(){this.hasLoaded=!0,this.relocateIntoItemsColumn()}isShowingSomething(){return this.canRender&&this.hasCartItems()}componentDidRender(){this.hasLoaded&&this.relocateIntoItemsColumn(),this.positionTooltip(),this.ensureSkeletonIsWatched()}relocateIntoItemsColumn(){if(!this.hasRelocated&&this.isShowingSomething())try{const t=this.hostEl;if(!t?.parentElement)return;const i=this.findItemsColumn(t);if(!i)return void this.watchForItemsColumn();if(this.hasRelocated=!0,this.stopWatchingForItemsColumn(),i===t.parentElement&&i.firstElementChild===t)return;i.insertBefore(t,i.firstChild)}catch(t){this.hasRelocated=!0,this.stopWatchingForItemsColumn(),this.safeLog("relocating the banner into the cart items column failed",t)}}findItemsColumn(t){let i=t;for(let e=0;i&&e<=3;e++){for(const e of this.getFollowingSiblings(i)){if(i===t&&this.matches(e,R))return t.parentElement;const o=this.findColumnWithin(e,t);if(o)return o}if(i=i.parentElement,!i||i===document.body||i===document.documentElement)break}return null}getFollowingSiblings(t){const i=[];for(let e=t.nextElementSibling;e;e=e.nextElementSibling)i.push(e);return i}findColumnWithin(t,i){const e=t.querySelector(R),o=(e?this.climbToChildOf(e,t):null)??t.querySelector(".main-content, [data-cart-items]");return!o||o===i||o.contains(i)?null:o}climbToChildOf(t,i){let e=t;for(;e&&e.parentElement&&e.parentElement!==i;)e=e.parentElement;return e?.parentElement===i?e:null}matches(t,i){return"function"==typeof t.matches&&t.matches(i)}watchForItemsColumn(){this.hasRelocated||this.relocationWatchExpired||this.relocationObserver||("undefined"!=typeof MutationObserver?(this.relocationObserver=new MutationObserver((()=>this.relocateIntoItemsColumn())),this.relocationObserver.observe(document.documentElement,{childList:!0,subtree:!0}),this.relocationWatchTimer=setTimeout((()=>{this.relocationWatchTimer=null,this.relocationWatchExpired=!0,this.stopWatchingForItemsColumn(),this.logNoItemsColumn()}),5e3)):this.logNoItemsColumn())}stopWatchingForItemsColumn(){if(this.relocationObserver){try{this.relocationObserver.disconnect()}catch(t){}this.relocationObserver=null}null!==this.relocationWatchTimer&&(clearTimeout(this.relocationWatchTimer),this.relocationWatchTimer=null)}logNoItemsColumn(){this.relocationLogged||(this.relocationLogged=!0,this.safeLog("no cart items column found — leaving the banner at full page width"))}ensureSkeletonIsWatched(){if(!this.isLoading)return;if(null!==this.skeletonWatchdog)return;const t=Date.now();0===this.skeletonDeadline&&(this.skeletonDeadline=t+8e3);const i=Math.max(0,this.skeletonDeadline-t);this.skeletonWatchdog=setTimeout((()=>{this.skeletonWatchdog=null,this.isLoading&&(Date.now()<this.skeletonDeadline?this.ensureSkeletonIsWatched():(this.isLoading=!1,this.skeletonDeadline=0,this.safeLog("still loading after 8000ms — dropping the skeleton")))}),i)}clearSkeletonWatchdog(){this.skeletonDeadline=0,null!==this.skeletonWatchdog&&(clearTimeout(this.skeletonWatchdog),this.skeletonWatchdog=null)}startLoading(){this.isLoading=!0,this.ensureSkeletonIsWatched()}stopLoading(){this.isLoading=!1,this.clearSkeletonWatchdog()}async load(){this.wantsCartUpdates=!0,this.subscribeToCartUpdates()||this.subscribeWhenSdkIsReady(),this.loadCart(),await this.waitForSdk(),await this.refresh()}waitForSdk(){let t,i;try{t=Promise.resolve(salla.onReady?.())}catch(t){return this.safeLog("salla.onReady() threw",t),Promise.resolve()}const e=new Promise((t=>{i=setTimeout(t,3e3)}));return Promise.race([t.catch((t=>this.safeLog("salla.onReady() rejected",t))),e]).then((()=>{clearTimeout(i)}))}subscribeToCartUpdates(){if(this.isListeningToCartUpdates)return!0;try{salla.event.on("cart::updated",this.cartUpdatedHandler),this.isListeningToCartUpdates=!0}catch(t){this.safeLog("cart::updated subscription failed",t)}return this.isListeningToCartUpdates}unsubscribeFromCartUpdates(){if(this.isListeningToCartUpdates){this.isListeningToCartUpdates=!1;try{salla.event.off("cart::updated",this.cartUpdatedHandler)}catch(t){this.safeLog("cart::updated unsubscription failed",t)}}}subscribeWhenSdkIsReady(){let t;try{t=Promise.resolve(salla.onReady?.())}catch(t){return}const i=()=>{this.isDisconnected||this.subscribeToCartUpdates()};t.then(i,i)}scheduleCartRefresh(){this.cartRefreshPending=!0,null!==this.cartRefreshTimer&&clearTimeout(this.cartRefreshTimer),this.cartRefreshTimer=null,this.isDisconnected||(this.cartRefreshTimer=setTimeout((()=>{this.cartRefreshTimer=null,this.runCartRefresh()}),200))}runCartRefresh(){this.isDisconnected||(this.cartRefreshPending=!1,this.refresh(),function(){if(h)return h;u++,l=null,c=null,d=!1,a=m();const t=()=>(h===i&&(h=null),_()),i=(f??Promise.resolve()).then(t,t).finally((()=>{h===i&&(h=null)}));return h=i,i}().then((()=>this.loadCart()),(()=>this.loadCart())))}readCartCountFromEvent(t){const i=this.toCartCount(t?.count)??this.readCartCountFromStorage();null!==i&&(this.cartItemCount=i)}readCartCountFromStorage(){try{return this.toCartCount(salla.storage?.get?.("cart.summary.count"))}catch(t){return null}}toCartCount(t){return"number"==typeof t&&Number.isFinite(t)&&t>=0?t:null}getFreeLabel(){const t=salla.lang.get(j);return t&&t!==j?t:"Free"}trans(t,i){const e=`blocks.cart_offer.${t}`,o=salla.lang.get(e,i);return o&&o!==e?o:Object.entries(i??{}).reduce(((t,[i,e])=>t.split(`:${i}`).join(e)),P[t])}isEnabled(){try{return!!salla.config.get("store.features")?.includes("conditional-offer")}catch(t){return!1}}async fetchOffer(){const{data:t}=await salla.api.cart.offers(),i=(t||[]).find((t=>"conditional"===t.type));return i?.details?.discounts?.length?i:null}async refresh(){const t=++this.refreshGeneration;if(!this.isEnabled())return this.stopLoading(),void(this.canRender=!1);if(0===this.cartItemCount)return this.stopLoading(),p(),void(d||(this.deferredByEmptyCart=!0,this.loadCart()));this.deferredByEmptyCart=!1,this.offer?this.stopLoading():this.startLoading();try{const i=await this.fetchOffer();if(this.isSuperseded(t))return;if(!i)return this.offer=null,void(this.canRender=!1);this.offer=i,this.canRender=!0,this.loadCart()}catch(i){if(this.isSuperseded(t))return;this.safeLog("offers() failed",i)}finally{t===this.refreshGeneration&&this.stopLoading()}}hasCartItems(){return"number"==typeof this.cartItemCount&&this.cartItemCount>=1}isSuperseded(t){return t!==this.refreshGeneration||this.isDisconnected}loadCart(){const t=++this.giftsGeneration;return Promise.all([(p(),d&&l?Promise.resolve(l):_().then((()=>l??s))),(p(),d&&l?Promise.resolve(c):_().then((()=>c)))]).then((([i,e])=>{t!==this.giftsGeneration||this.isDisconnected||this.cartRefreshPending||(null!==e&&(this.cartItemCount=e),null!==e?this.clearCartLookupRetry():null===this.cartItemCount&&this.scheduleCartLookupRetry(),this.deferredByEmptyCart&&this.hasCartItems()&&(this.deferredByEmptyCart=!1,this.refresh()),this.gifts=this.offer?this.selectOwnGifts(i):[])})).catch((t=>{this.safeLog("cart lookup failed",t)}))}scheduleCartLookupRetry(){this.cartLookupRetries>=F.length||(this.cartLookupRetryPending=!0,null!==this.cartLookupRetryTimer||this.isDisconnected||(this.cartLookupRetryTimer=setTimeout((()=>{this.cartLookupRetryTimer=null,this.cartLookupRetryPending=!1,this.canRender&&(this.cartLookupRetries++,this.loadCart())}),F[this.cartLookupRetries])))}clearCartLookupRetry(){this.cartLookupRetries=0,this.cartLookupRetryPending=!1,null!==this.cartLookupRetryTimer&&(clearTimeout(this.cartLookupRetryTimer),this.cartLookupRetryTimer=null)}selectOwnGifts(t){const i=Number(this.offer?.id);if(!Number.isFinite(i))return t;const e=t.filter((t=>null!==t.offerId&&Number(t.offerId)===i));return e.length?e:t.filter((t=>null===t.offerId))}getStages(){const t=(this.offer?.details?.discounts??[]).filter((({min_spend:t})=>null!==z(t)));return i=({min_spend:t})=>t,e=({id:t})=>t,(t??[]).map(((t,o)=>({item:t,index:o,threshold:L(i(t)),identity:e?z(e(t)):null}))).sort(((t,i)=>t.threshold!==i.threshold?t.threshold-i.threshold:null!==t.identity&&null!==i.identity&&t.identity!==i.identity?t.identity-i.identity:t.index-i.index)).map((({item:t})=>t));var i,e}getProgress(t){return function(t,i,e=0,o=[],r=[]){const n=(i??[]).map(((t,i)=>({index:i,threshold:z(t),applied:S(o?.[i]),tierValue:z(r?.[i])}))).filter((t=>null!==t.threshold)).sort(((t,i)=>t.threshold-i.threshold||t.index-i.index)),s=n.map((t=>t.threshold)),a=n.map((t=>t.applied)),l=a.some((t=>void 0!==t)),c=L(e);if(!s.length)return{thresholds:s,met:[],applied:a,appliedIndex:C,hasEngineVerdict:l,metCount:0,nextUnmetIndex:C,allMet:!1,lastReachedIndex:C,currentIndex:C,isComplete:!1,value:Math.max(0,L(t)),values:[],startValue:c,fills:[],overallPercentage:0};const d=s[s.length-1],f=I(L(t),0,Math.max(0,d)),h=n.map((({tierValue:t})=>null===t?f:I(t,0,Math.max(0,d))));let u=C;for(let t=0;t<s.length;t++)h[t]>=s[t]&&(u=t);const g=u===s.length-1,m=g?C:u+1,p=s.map(((t,i)=>function(t,i,e){return e<=i?t>=e?100:0:I((t-i)/(e-i)*100,0,100)}(h[i],0===i?c:s[i-1],t))),b=g?100:I((u+1+(p[m]??0)/100)/s.length*100,0,100);let w=C;for(let t=0;t<a.length;t++)!0===a[t]&&(w=t);const y=s.map(l?(t,i)=>i<=w:(t,i)=>i<=u),x=y.filter(Boolean).length,v=y.findIndex((t=>!t));return{thresholds:s,met:y,applied:a,appliedIndex:w,hasEngineVerdict:l,metCount:x,nextUnmetIndex:v,allMet:v===C,lastReachedIndex:u,currentIndex:m,isComplete:g,value:f,values:h,startValue:c,fills:p,overallPercentage:b}}(this.offer?.details?.current_value,t.map((({min_spend:t})=>t)),this.offer?.details?.start_value,t.map((({is_applied:t})=>t)),t.map((({current_value:t})=>t)))}tierKey(t,i){const e=Number(t?.id);return Number.isFinite(e)?`tier-${e}`:`pos-${i}`}stageMeasure(){return this.offer?.details?.based_on===n.PRODUCT_COUNT?T.COUNT:T.CURRENCY}formatRequirement(t){const i=this.offer?.details?.based_on;if(i===n.PRODUCT_COUNT)try{return salla.lang.choice("blocks.header.products_count",t)}catch(i){return this.safeLog("invalid products_count interval",i),`${t}`}return i===n.PRODUCT_PURCHASE?salla.money(t):(this.safeLog(`unexpected offer detail's based_on value: ${i}`),`${t}`)}getRewardText(t){return(t?.reward_label??"").trim()}getGuidanceMessage(t,i){if(i.nextUnmetIndex===C)return"";const e=function(t,i,e=T.CURRENCY){const o=i.thresholds[t];if(void 0===o)return 0;const r=Math.max(0,o-(i.values?.[t]??i.value));if(0===r)return 0;const n=e===T.COUNT?0:function(){try{const t="undefined"!=typeof salla?salla:void 0,i=V(t?.config?.currency?.()?.decimals);if(null!==i)return i;const e=V(t?.config?.get?.("store.currency.decimals"));if(null!==e)return e}catch(t){}return 2}(),s=Math.pow(10,n),a=Math.ceil(r*s-1e-6)/s;return a>0?a:1/s}(i.nextUnmetIndex,i,this.stageMeasure());if(e<=0)return this.trans("guidance_conditions_unmet");const o=this.formatRequirement(e),r=this.getRewardText(t[i.nextUnmetIndex]);return r?this.trans("guidance_next",{remaining:o,reward:H(r)}):this.trans("guidance_next_generic",{remaining:o})}getTierSentence(t,i,e){const o=this.formatRequirement(e.thresholds[i]),r=this.getRewardText(t),n=this.stageMeasure()===T.COUNT;return r?this.trans(n?"tier_requirement_count":"tier_requirement",{threshold:o,reward:H(r)}):this.trans(n?"tier_requirement_count_generic":"tier_requirement_generic",{threshold:o})}getRewardIcon(t){switch(t?.type){case r.PERCENTAGE:return"sicon-percentage";case r.FREE_PRODUCT:return"sicon-gift";case r.FIXED:return this.usesSarSymbol()?"sicon-sar":"sicon-banknote";default:return"sicon-tag"}}usesSarSymbol(){try{const t=salla.config.currency?.()?.symbol;return["SAR","ر.س"].includes(t)&&!!salla.config.get("store.settings.use_sar_symbol")}catch(t){return!1}}get isTooltipOpen(){return this.isTooltipHovered||this.isTooltipPinned}toggleTooltip(){this.isTooltipPinned=!this.isTooltipPinned}closeTooltip(t=!1){this.isTooltipOpen&&(this.isTooltipPinned=!1,this.isTooltipHovered=!1,t&&this.infoTriggerEl?.focus?.())}positionTooltip(){const t=this.tooltipEl,i=this.infoTriggerEl;if(this.isTooltipOpen&&t&&i)try{this.setTooltipOffsets(t,0,0);const e=window.innerWidth||document.documentElement?.clientWidth||0,o=t.getBoundingClientRect(),r=i.getBoundingClientRect(),n=o?.width||0;if(n<=0||e<=0)return;const s=r.left+r.width/2-n/2,a=8,l=Math.min(Math.max(s,a),Math.max(a,e-a-n))-s,c=Math.max(0,n/2-16),d=Math.min(Math.max(-l,-c),c);this.setTooltipOffsets(t,l,d)}catch(t){this.safeLog("positioning the offer details popover failed",t)}}setTooltipOffsets(t,i,e){t.style?.setProperty?.("--s-conditional-offer-tooltip-shift",`${Math.round(i)}px`),t.style?.setProperty?.("--s-conditional-offer-tooltip-caret",`${Math.round(e)}px`)}handleWindowResize(){this.positionTooltip()}handleDocumentKeydown(t){"Escape"!==t.key&&"Esc"!==t.key||this.closeTooltip(!0)}handleDocumentClick(t){if(!this.isTooltipPinned||!this.infoAnchorEl)return;const i="function"==typeof t.composedPath?t.composedPath():[];(i.length?i.includes(this.infoAnchorEl):this.infoAnchorEl.contains(t.target))||this.closeTooltip()}elementId(t){return`s-conditional-offer-${t}-${this.instanceId}`}renderBadges(t,e){return i("div",{class:"s-conditional-offer-badges",role:"img","aria-label":this.trans("badges_summary",{completed:`${e.metCount}`,total:`${t.length}`})},t.map(((t,o)=>{const r=e.met[o],n=this.tierKey(t,o);return[o>0?i("span",{key:`${n}-link`,class:{"s-conditional-offer-badge-link":!0,"s-conditional-offer-badge-link-met":r,"s-conditional-offer-badge-link-unmet":!r},"aria-hidden":"true"}):null,i("span",{key:n,class:{"s-conditional-offer-badge":!0,"s-conditional-offer-badge-met":r,"s-conditional-offer-badge-unmet":!r},"data-tier-state":r?"met":"unmet","data-tier-id":t?.id??void 0},i(r?O:q,{class:"s-conditional-offer-badge-icon"}))]})))}renderTooltip(t,e){const o=function(t){const i=t?.details?.rules;if("string"==typeof i){const t=i.trim();return""===t?null:t}if(Array.isArray(i)){const t=i.filter((t=>"string"==typeof t)).map((t=>t.trim())).filter((t=>""!==t)).join(" ");return""===t?null:t}return null}(this.offer);return i("div",{class:"s-conditional-offer-tooltip",id:this.elementId("tooltip"),role:"tooltip",ref:t=>this.tooltipEl=t},i("div",{class:"s-conditional-offer-tooltip-title"},this.offer?.title),o?i("div",{class:"s-conditional-offer-tooltip-description"},o):null,i("ul",{class:"s-conditional-offer-tooltip-list"},t.map(((t,o)=>{const r=e.met[o];return i("li",{key:this.tierKey(t,o),class:"s-conditional-offer-tier","data-tier-state":r?"met":"unmet","data-tier-id":t?.id??void 0},i("span",{class:{"s-conditional-offer-tier-icon":!0,"s-conditional-offer-tier-icon-met":r,"s-conditional-offer-tier-icon-unmet":!r}},i("i",{class:this.getRewardIcon(t),"aria-hidden":"true"}),i("span",{class:{"s-conditional-offer-tier-status":!0,"s-conditional-offer-tier-status-met":r,"s-conditional-offer-tier-status-unmet":!r},"aria-hidden":"true"},r?i(O,{class:"s-conditional-offer-tier-status-check"}):i(q,{class:"s-conditional-offer-tier-status-lock"}))),i("div",{class:"s-conditional-offer-tier-body"},i("div",{class:"s-conditional-offer-tier-title"},this.trans("tier_title",{number:`${o+1}`})),i("div",{class:{"s-conditional-offer-tier-text":!0,"s-conditional-offer-tier-text-met":r},innerHTML:this.getTierSentence(t,o,e)})))}))))}renderGiftsToggle(t){return i("button",{type:"button",id:this.elementId(`toggle-${t}`),class:{"s-conditional-offer-toggle":!0,"s-conditional-offer-toggle-inline":"inline"===t,"s-conditional-offer-toggle-bar":"bar"===t},"aria-expanded":this.isGiftsOpen?"true":"false","aria-controls":this.elementId("gifts"),onClick:()=>this.isGiftsOpen=!this.isGiftsOpen},i("span",null,this.trans("manage_offer")),i("i",{class:{"sicon-keyboard_arrow_down":!0,"s-conditional-offer-toggle-icon":!0,"s-conditional-offer-toggle-icon-open":this.isGiftsOpen},"aria-hidden":"true"}))}renderGiftsCard(){return i("div",{class:"s-conditional-offer-panel",id:this.elementId("gifts")},i("div",{class:"s-conditional-offer-gifts-header"},i("span",{class:"s-conditional-offer-gifts-icon"},i("i",{class:"sicon-gift","aria-hidden":"true"})),i("span",{class:"s-conditional-offer-gifts-title"},this.trans("free_products_title"))),i("ul",{class:"s-conditional-offer-gifts-list"},this.gifts.map((t=>this.renderGiftRow(t)))))}renderGiftRow(t){return i("li",{class:"s-conditional-offer-gift","data-item-id":t.id},i("span",{class:"s-conditional-offer-gift-thumb"},t.imageUrl?i("img",{class:"s-conditional-offer-gift-image",src:t.imageUrl,alt:t.imageAlt||t.name,loading:"lazy",decoding:"async"}):i("i",{class:"sicon-gift","aria-hidden":"true"})),i("div",{class:"s-conditional-offer-gift-body"},i("span",{class:"s-conditional-offer-gift-name"},t.name||this.trans("free_gift")),i("span",{class:"s-conditional-offer-gift-prices"},i("span",{class:"s-conditional-offer-gift-free"},this.getFreeLabel()),null!==t.originalPrice?i("span",{class:"s-conditional-offer-gift-price",innerHTML:salla.money(t.originalPrice)}):null)))}getLoadingSkeletonView(){return i(e,{class:"s-conditional-offer-root"},i("div",{class:"s-conditional-offer-banner"},i("div",{class:"s-conditional-offer-lead"},i("salla-skeleton",{height:"24px",width:"80px"}),i("div",{class:"s-conditional-offer-skeleton-text"},i("salla-skeleton",{height:"12px",width:"35%"}),i("salla-skeleton",{height:"16px",width:"60%"})))))}render(){if(!this.canRender)return null;if(!this.hasCartItems())return null;if(this.isLoading)return this.getLoadingSkeletonView();if(!this.offer)return null;const t=this.getStages(),o=this.getProgress(t),r=this.getGuidanceMessage(t,o),n=this.trans("details_title"),s=this.gifts.length>0;return i(e,{class:"s-conditional-offer-root"},i("div",{class:"s-conditional-offer-banner"},i("div",{class:"s-conditional-offer-lead"},this.renderBadges(t,o),i("div",{class:"s-conditional-offer-text"},i("div",{class:"s-conditional-offer-heading",onMouseEnter:()=>this.isTooltipHovered=!0,onMouseLeave:()=>this.isTooltipHovered=!1},i("span",{class:"s-conditional-offer-name"},this.offer.title),i("span",{class:"s-conditional-offer-info",ref:t=>this.infoAnchorEl=t},i("button",{type:"button",class:"s-conditional-offer-info-trigger",ref:t=>this.infoTriggerEl=t,"aria-label":n,title:n,"aria-expanded":this.isTooltipOpen?"true":"false","aria-describedby":this.elementId("tooltip"),onClick:()=>this.toggleTooltip()},i(N,{class:"s-conditional-offer-info-icon"})),this.isTooltipOpen?this.renderTooltip(t,o):null)),o.allMet?i("div",{class:"s-conditional-offer-message",role:"status"},this.trans("congrats")):r?i("div",{class:"s-conditional-offer-message",innerHTML:r}):null)),s?this.renderGiftsToggle("inline"):null),s&&this.isGiftsOpen?this.renderGiftsCard():null,s?this.renderGiftsToggle("bar"):null)}get hostEl(){return o(this)}};B.style='/*!twlt*/:host{display:block}.s-conditional-offer-root{background-color:rgba(0, 137, 123, 0.06);background-color:color-mix(in srgb, var(--color-primary, #00897b) 7%, transparent)}.s-conditional-offer-badges::-webkit-scrollbar{height:3px}.s-conditional-offer-badges::-webkit-scrollbar-thumb{border-radius:9999px;background-color:rgba(0, 0, 0, 0.15)}.s-conditional-offer-badges::-webkit-scrollbar-track{background-color:transparent}.s-conditional-offer-tooltip{--s-conditional-offer-tooltip-shift:0px;--s-conditional-offer-tooltip-caret:0px;transform:translateX(calc(-50% + var(--s-conditional-offer-tooltip-shift)))}.s-conditional-offer-tooltip::before{content:"";position:absolute;bottom:100%;left:50%;transform:translateX(calc(-50% + var(--s-conditional-offer-tooltip-caret)));border:8px solid transparent;border-bottom-color:#fff}.s-conditional-offer-tier-icon-met,.s-conditional-offer-tier-icon-unmet{color:var(--color-primary-dark, #00695c);background-color:rgba(0, 137, 123, 0.12);background-color:color-mix(in srgb, var(--color-primary, #00897b) 14%, transparent)}.s-conditional-offer-tier:not(:last-child)::before{content:"";position:absolute;top:2.5rem;bottom:-1rem;inset-inline-start:1.125rem;width:1px;background-color:#d1d5db}.visible{visibility:visible}.invisible{visibility:hidden}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.block{display:block}.inline{display:inline}.flex{display:flex}.hidden{display:none}.w-6{width:1.5rem}.resize{resize:both}.gap-1{gap:0.25rem}.rounded{border-radius:var(--s-radius, 0.25rem)}.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-conditional-offer-root{margin-bottom:1.25rem;display:block;width:100%;min-width:0px;max-width:100%;border-radius:0.375rem;padding:0.75rem}@media (min-width: 768px){.s-conditional-offer-root{padding:1rem}}.s-conditional-offer-banner{display:flex;width:100%;min-width:0px;align-items:center;justify-content:space-between;gap:0.75rem}@media (min-width: 768px){.s-conditional-offer-banner{gap:1rem}}.s-conditional-offer-lead{display:flex;min-width:0px;flex:1 1 0%;align-items:center;gap:0.5rem}@media (min-width: 768px){.s-conditional-offer-lead{gap:0.75rem}}.s-conditional-offer-badges{display:flex;max-width:45%;flex-shrink:0;flex-wrap:nowrap;align-items:center;gap:0.25rem;overflow-x:auto;overscroll-behavior-x:contain;scroll-behavior:smooth;scrollbar-width:thin}.s-conditional-offer-badge{display:inline-flex;height:1.5rem;width:1.5rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;font-size:11px;line-height:1;--tw-text-opacity:1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.s-conditional-offer-badge-met{background-color:var(--color-primary)}.s-conditional-offer-badge-unmet{--tw-bg-opacity:1;background-color:rgb(156 163 175 / var(--tw-bg-opacity, 1))}.s-conditional-offer-badge-link{width:0.5rem;flex-shrink:0;border-top-width:1px}.s-conditional-offer-badge-link-met{border-color:var(--color-primary)}.s-conditional-offer-badge-link-unmet{border-style:dashed;--tw-border-opacity:1;border-color:rgb(82 82 82 / var(--tw-border-opacity, 1))}.s-conditional-offer-badge-icon{height:0.75rem;width:0.75rem;flex-shrink:0}.s-conditional-offer-text{display:flex;min-width:0px;flex-direction:column;gap:0.125rem;text-align:start}.s-conditional-offer-heading{display:flex;min-width:0px;align-items:center;gap:0.375rem}.s-conditional-offer-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:0.75rem;line-height:1rem;--tw-text-opacity:1;color:rgb(82 82 82 / var(--tw-text-opacity, 1))}.s-conditional-offer-info{position:relative;display:inline-flex;flex-shrink:0;align-items:center}.s-conditional-offer-info-trigger{display:inline-flex;height:1rem;width:1rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;--tw-text-opacity:1;color:rgb(115 115 115 / 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:300ms}.s-conditional-offer-info-trigger:hover{color:var(--color-primary-dark)}.s-conditional-offer-info-icon{height:0.875rem;width:0.875rem;flex-shrink:0}.s-conditional-offer-message{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark)}@media (min-width: 768px){.s-conditional-offer-message{font-size:1rem;line-height:1.5rem}}.s-conditional-offer-toggle{align-items:center;justify-content:center;gap:0.375rem;font-size:0.875rem;line-height:1.25rem;--tw-text-opacity:1;color:rgb(38 38 38 / 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:300ms}.s-conditional-offer-toggle:hover{color:var(--color-primary-dark)}.s-conditional-offer-toggle-inline{display:none;flex-shrink:0}@media (min-width: 768px){.s-conditional-offer-toggle-inline{display:inline-flex}}.s-conditional-offer-toggle-bar{margin-top:0.5rem;display:inline-flex;width:100%;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding-left:0.75rem;padding-right:0.75rem;padding-top:0.625rem;padding-bottom:0.625rem}@media (min-width: 768px){.s-conditional-offer-toggle-bar{display:none}}.s-conditional-offer-toggle-icon{font-size:1rem;line-height:1.5rem;line-height:1;transition-property:transform;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms}.s-conditional-offer-toggle-icon-open{--tw-rotate:180deg;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-conditional-offer-panel{margin-top:0.75rem;width:100%;min-width:0px;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:0.75rem}.s-conditional-offer-gifts-header{margin-bottom:0.75rem;display:flex;align-items:center;gap:0.5rem}.s-conditional-offer-gifts-icon{display:inline-flex;height:2rem;width:2rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;border-width:1px;border-color:var(--color-primary);font-size:1rem;line-height:1.5rem;line-height:1;color:var(--color-primary)}.s-conditional-offer-gifts-title{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-gifts-list{margin:0px;display:flex;list-style-type:none;flex-direction:column;gap:0.5rem;padding:0px}.s-conditional-offer-gift{display:flex;align-items:center;gap:0.75rem;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));padding:0.5rem}.s-conditional-offer-gift-thumb{display:inline-flex;height:3.5rem;width:3.5rem;flex-shrink:0;align-items:center;justify-content:center;overflow:hidden;border-radius:0.375rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(243 244 246 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));font-size:1.25rem;line-height:1.75rem;--tw-text-opacity:1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.s-conditional-offer-gift-image{height:100%;width:100%;object-fit:contain}.s-conditional-offer-gift-body{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.125rem;text-align:start}.s-conditional-offer-gift-name{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;font-size:0.875rem;line-height:1.25rem;font-weight:700;--tw-text-opacity:1;color:rgb(38 38 38 / var(--tw-text-opacity, 1))}.s-conditional-offer-gift-prices{display:flex;align-items:center;gap:0.5rem;font-size:0.75rem;line-height:1rem}.s-conditional-offer-gift-free{font-weight:700;--tw-text-opacity:1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.s-conditional-offer-gift-price{--tw-text-opacity:1;color:rgb(115 115 115 / var(--tw-text-opacity, 1));text-decoration-line:line-through}.s-conditional-offer-tooltip{position:absolute;top:calc(100% + 0.75rem);left:50%;z-index:10;width:min(22rem, calc(100vw - 2rem));border-radius:0.5rem;--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:1rem;text-align:start;--tw-shadow:5px 10px 30px #2B2D340D;--tw-shadow-colored:5px 10px 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-conditional-offer-tooltip-title{font-size:0.875rem;line-height:1.25rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-tooltip-description{margin-top:0.25rem;font-size:0.75rem;line-height:1rem;line-height:1.625;--tw-text-opacity:1;color:rgb(82 82 82 / var(--tw-text-opacity, 1))}.s-conditional-offer-tooltip-list{margin:0px;margin-top:0.75rem;display:flex;list-style-type:none;flex-direction:column;gap:1rem;padding:0px}.s-conditional-offer-tier{position:relative;display:flex;align-items:flex-start;gap:0.75rem}.s-conditional-offer-tier-icon{position:relative;display:inline-flex;height:2.25rem;width:2.25rem;flex-shrink:0;align-items:center;justify-content:center;border-radius:9999px;font-size:1rem;line-height:1.5rem;line-height:1}.s-conditional-offer-tier-icon-unmet{color:var(--color-primary-dark)}.s-conditional-offer-tier-status{position:absolute;bottom:-0.125rem;display:inline-flex;height:1rem;width:1rem;align-items:center;justify-content:center;border-radius:9999px;border-width:2px;--tw-border-opacity:1;border-color:rgb(255 255 255 / var(--tw-border-opacity, 1));--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));inset-inline-start:-2px}.s-conditional-offer-tier-status-met{color:var(--color-primary-dark)}.s-conditional-offer-tier-status-unmet{--tw-text-opacity:1;color:rgb(163 163 163 / var(--tw-text-opacity, 1))}.s-conditional-offer-tier-status-check{height:0.75rem;width:0.75rem;flex-shrink:0}.s-conditional-offer-tier-status-lock{height:0.625rem;width:0.625rem;flex-shrink:0}.s-conditional-offer-tier-body{display:flex;min-width:0px;flex-direction:column;gap:0.125rem}.s-conditional-offer-tier-title{font-size:0.75rem;line-height:1rem;font-weight:700;color:var(--color-primary-dark)}.s-conditional-offer-tier-text{font-size:0.75rem;line-height:1rem;line-height:1.625;--tw-text-opacity:1;color:rgb(82 82 82 / var(--tw-text-opacity, 1))}.s-conditional-offer-tier-text-met{text-decoration-line:line-through}.s-conditional-offer-skeleton-text{display:flex;min-width:0px;flex:1 1 0%;flex-direction:column;gap:0.375rem}';export{B as salla_conditional_offer}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as a,h as s,a as e}from"./p-Bk24FlDL.js";import{a as t}from"./p-CgtvEd63.js";import{f as i,t as o}from"./p-CO-PeZ27.js";import{M as l}from"./p-DmgxDvXL.js";import{C as r}from"./p-BsLF_HK7.js";var c,n='\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>link</title>\n<path d="M19.247 23.019l-4.189 4.189c-2.831 2.831-7.435 2.831-10.265 0-1.371-1.372-2.125-3.193-2.125-5.132s0.755-3.761 2.125-5.133l4.189-4.191c0.521-0.521 0.521-1.364 0-1.885s-1.364-0.521-1.885 0l-4.189 4.191c-1.875 1.875-2.907 4.367-2.907 7.019s1.032 5.143 2.907 7.017 4.368 2.907 7.019 2.907 5.143-1.032 7.017-2.908l4.189-4.189c0.521-0.521 0.521-1.364 0-1.885s-1.364-0.52-1.885 0.001zM22.276 9.724c-0.521-0.521-1.364-0.521-1.885 0l-10.667 10.667c-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391l10.667-10.667c0.521-0.521 0.521-1.364 0-1.885zM29.093 2.908c-1.875-1.876-4.368-2.908-7.019-2.908s-5.143 1.032-7.017 2.908l-4.189 4.188c-0.521 0.521-0.521 1.364 0 1.885s1.364 0.521 1.885 0l4.189-4.189c2.831-2.831 7.435-2.831 10.265 0 1.371 1.372 2.125 3.193 2.125 5.132s-0.755 3.761-2.125 5.133l-4.189 4.191c-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391l4.189-4.191c1.875-1.875 2.907-4.367 2.907-7.019s-1.032-5.143-2.907-7.016z"></path>\n</svg>\n',h='\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>whatsapp</title>\n<path d="M16 32c-0.008 0-0.018 0-0.028 0-3.1 0-5.993-0.887-8.439-2.421l0.066 0.039-7.2 2.3 2.336-6.964c-1.713-2.492-2.736-5.575-2.736-8.897 0-0.020 0-0.040 0-0.060v0.003c0.009-8.833 7.167-15.991 15.999-16h0.001c8.837 0 16 7.163 16 16s-7.163 16-16 16v0zM7.906 27.424l0.4 0.264c2.169 1.449 4.837 2.312 7.707 2.312 7.732 0 14-6.268 14-14s-6.268-14-14-14c-0.004 0-0.009 0-0.013 0h0.001c-7.729 0.008-13.992 6.271-14 13.999v0.001c-0 0.010-0 0.021-0 0.032 0 3.072 1 5.909 2.693 8.206l-0.027-0.038 0.304 0.416-1.4 4.2zM20.716 24.958c-1.684-0.131-3.237-0.574-4.641-1.271l0.073 0.033c-3.098-1.456-5.634-3.668-7.438-6.405l-0.042-0.067c-1.102-1.357-1.819-3.067-1.962-4.938l-0.002-0.030c-0.001-0.036-0.001-0.078-0.001-0.12 0-1.575 0.66-2.995 1.719-4l0.002-0.002c0.547-0.52 1.289-0.839 2.105-0.839 0.033 0 0.066 0.001 0.099 0.002l-0.005-0c0.2 0 0.378 0 0.542 0.018 0.016-0.001 0.035-0.001 0.054-0.001 0.815 0 1.502 0.549 1.711 1.298l0.003 0.012 0.324 0.782c0.376 0.906 0.858 2.068 0.942 2.244 0.144 0.251 0.23 0.552 0.23 0.873 0 0.286-0.068 0.557-0.188 0.797l0.005-0.010c-0.149 0.307-0.332 0.57-0.55 0.802l0.002-0.002c-0.148 0.168-0.248 0.274-0.346 0.378s-0.172 0.18-0.26 0.284c0.575 0.92 1.237 1.713 1.992 2.406l0.008 0.008c0.829 0.758 1.802 1.373 2.872 1.8l0.064 0.022c0.369-0.266 0.672-0.6 0.896-0.985l0.008-0.015 0.174-0.232c0.328-0.484 0.875-0.798 1.495-0.798 0.249 0 0.487 0.051 0.703 0.142l-0.012-0.004c0.492 0.168 2.922 1.372 2.946 1.384l0.228 0.11c0.415 0.149 0.758 0.417 0.996 0.763l0.004 0.007c0.107 0.349 0.169 0.75 0.169 1.166 0 0.591-0.125 1.153-0.349 1.661l0.010-0.026c-0.702 1.368-1.983 2.353-3.511 2.637l-0.031 0.005c-0.309 0.071-0.663 0.112-1.028 0.112-0.004 0-0.007 0-0.011 0h0.001zM10.632 9.318c-0.028-0.002-0.062-0.004-0.095-0.004-0.245 0-0.472 0.076-0.659 0.206l0.004-0.002c-0.726 0.651-1.18 1.591-1.18 2.638 0 0.044 0.001 0.087 0.002 0.13l-0-0.006c0.122 1.404 0.662 2.662 1.495 3.671l-0.009-0.011 0.12 0.168c1.627 2.491 3.865 4.46 6.504 5.723l0.096 0.041c3.136 1.288 3.916 1.124 4.426 1.014 0.87-0.159 1.601-0.656 2.067-1.347l0.007-0.011c0.12-0.316 0.204-0.682 0.237-1.063l0.001-0.015-0.040-0.018-0.256-0.124c-0.8-0.4-2.46-1.2-2.734-1.292l-0.058 0.184c-0.346 0.501-0.684 0.934-1.045 1.347l0.015-0.017c-0.344 0.349-0.821 0.565-1.349 0.565-0.28 0-0.546-0.061-0.785-0.17l0.012 0.005c-1.403-0.547-2.609-1.301-3.646-2.239l0.010 0.009c-0.975-0.891-1.81-1.912-2.486-3.039l-0.034-0.061c-0.152-0.244-0.242-0.54-0.242-0.857 0-0.463 0.191-0.88 0.499-1.178l0-0c0.13-0.162 0.264-0.302 0.4-0.444l0.236-0.256c0.091-0.096 0.177-0.201 0.254-0.311l0.006-0.009c-0.158-0.36-0.622-1.472-0.988-2.352l-0.322-0.772-0.038-0.086c-0.188-0.010-0.302-0.016-0.426-0.016zM12.462 12.442v0.012z"></path>\n</svg>\n';!function(a){a.FACEBOOK="facebook",a.TWITTER="twitter",a.WHATSAPP="whatsapp",a.EMAIL="email",a.COPY_LINK="copy_link"}(c||(c={}));const d=class{constructor(s){a(this,s),this.ignoreOutsideClick=!1,this.translationDefaults={"common.social.share":{ar:"مشاركة",en:"Share"},"common.social.email":{ar:"إيميل",en:"Email"},"common.social.whatsapp":{ar:"واتساب",en:"WhatsApp"},"common.social.twitter":{ar:"أكس",en:"X"},"common.social.facebook":{ar:"فيسبوك",en:"Facebook"},"common.social.copy":{ar:"نسخ",en:"Copy"},"common.social.copied":{ar:"تم النسخ",en:"Copied"}},this.onDocumentClick=a=>{this.ignoreOutsideClick||!this.opened||this.host.contains(a.target)||this.close()},this.opened=!1,this.copied=!1,this.allPlatforms=[c.WHATSAPP,c.FACEBOOK,c.TWITTER,c.EMAIL,c.COPY_LINK],this.platformIcons=[{icon:h,name:c.WHATSAPP},{icon:i,name:c.FACEBOOK},{icon:o,name:c.TWITTER},{icon:l,name:c.EMAIL},{icon:n,name:c.COPY_LINK}],this.convertedPlatforms=[],this.url="",this.urlName="",this.platforms="facebook,twitter,whatsapp,email,copy_link",this.mode="default",this.modalTitle=""}componentWillLoad(){if(this.registerTranslationDefaults(),this.host.hasAttribute("aria-label")&&this.host.removeAttribute("aria-label"),this.supportsNativeShare()||document.getElementById("a2a-script"))return;const a=document.createElement("script");a.src="https://static.addtoany.com/menu/page.js",a.setAttribute("id","a2a-script"),a.async=!0,a.onload=function(){window.a2a_config.locale=salla.config.get("user.language_code",salla.lang.getLocale()),window.a2a_config.callbacks=window.a2a_config.callbacks||[],window.a2a_config.callbacks.push({share:a=>{const s={share_via:a.service.toLowerCase(),url:a.url,title:a.title};salla.event.emit("share-element",s)}})},document.body.appendChild(a)}componentDidLoad(){document.addEventListener("click",this.onDocumentClick)}disconnectedCallback(){document.removeEventListener("click",this.onDocumentClick),this.copiedResetTimeout&&window.clearTimeout(this.copiedResetTimeout),this.setBodyScrollLocked(!1)}registerTranslationDefaults(){if(!salla?.lang?.addBulk)return;const a=Object.entries(this.translationDefaults).reduce(((a,[s,e])=>(salla.lang.get(s)===s&&(a[s]=e),a)),{});Object.keys(a).length&&salla.lang.addBulk(a)}resolveShareKit(){return this.host.querySelector(".a2a_kit")}deferOutsideClickGuard(){this.ignoreOutsideClick=!0,requestAnimationFrame((()=>{this.ignoreOutsideClick=!1}))}async open(){if(this.opened)return;if(this.opened=!0,this.deferOutsideClickGuard(),"modal"===this.mode&&this.setBodyScrollLocked(!0),await new Promise((a=>requestAnimationFrame((()=>a())))),!this.opened)return;if(await this.refresh(),"modal"===this.mode)return;const a=this.resolveShareKit();a?(this.openAnimation=(new t.timeline).add({targets:a,translateY:[-50,0],opacity:[0,1],duration:300,podding:"0",easing:"easeInOutSine"}),this.openAnimation.add({targets:a.children,translateZ:0,translateY:[-30,0],scaleY:[0,1],opacity:[0,1],duration:1400,delay:t.stagger(100)},"-=200")):this.opened=!1}async close(){this.opened&&(this.openAnimation?.pause(),this.openAnimation?.seek(0),this.opened=!1,"modal"===this.mode&&this.setBodyScrollLocked(!1))}setBodyScrollLocked(a){document.body.classList.toggle("s-social-share-modal-is-open",a)}toggle(){return this.opened?this.close():(this.deferOutsideClickGuard(),this.open())}supportsNativeShare(){return!!salla.mobile?.isSpaWebview?.()}handleShareClick(){this.supportsNativeShare()?salla.event.dispatch("mobile::share.open",{url:this.getShareUrl()}):this.toggle()}onUrlChanged(a,s){a!==s&&this.refresh()}getShareUrl(){return this.url||window.location.href}getModalTitle(){return this.modalTitle||salla.lang.get("common.social.share")}syncShareAttributes(){const a=this.resolveShareKit();a&&(a.setAttribute("data-a2a-url",this.getShareUrl()),a.setAttribute("data-a2a-title",this.urlName||document.title))}async refresh(){this.syncShareAttributes(),"function"!=typeof window.a2a?.init_all?window.a2a?.init("page"):window.a2a.init_all()}async copyLink(){const a=this.getShareUrl();try{await navigator.clipboard.writeText(a)}catch{const s=document.createElement("textarea");s.value=a,s.style.position="fixed",s.style.opacity="0",document.body.appendChild(s),s.select();try{document.execCommand("copy")}catch{}s.remove()}salla.event.emit("share-element",{share_via:"copy_link",url:a,title:this.urlName||document.title}),this.copied=!0,this.copiedResetTimeout&&window.clearTimeout(this.copiedResetTimeout),this.copiedResetTimeout=window.setTimeout((()=>this.copied=!1),2e3)}modalPlatformMeta(a){switch(a){case c.WHATSAPP:return{icon:h,color:"#25D366",label:salla.lang.get("common.social.whatsapp")};case c.FACEBOOK:return{icon:i,color:"#1877F2",label:salla.lang.get("common.social.facebook")};case c.TWITTER:return{icon:o,color:"#000000",label:salla.lang.get("common.social.twitter")};case c.EMAIL:return{icon:l,color:"#2BA6FF",label:salla.lang.get("common.social.email")};default:return{icon:n,color:"#6b7280",label:a}}}renderModalCard(a){const e=this.modalPlatformMeta(a);return s("a",{class:`s-social-share-modal-card a2a_button_${a}`,"aria-label":`Share Via ${a}`},s("span",{class:"s-social-share-modal-icon",style:{backgroundColor:e.color},innerHTML:e.icon}),s("span",{class:"s-social-share-modal-card-label"},e.label))}renderModal(){if(!this.opened)return null;const a=this.platforms.split(",").map((a=>a.trim())),e=[c.EMAIL,c.WHATSAPP,c.TWITTER,c.FACEBOOK].filter((s=>a.includes(s))),t=a.includes(c.COPY_LINK);return s("div",{class:"s-social-share-modal",onClick:a=>{a.target===a.currentTarget&&this.close()}},s("div",{class:"s-social-share-modal-dialog",role:"dialog","aria-modal":"true"},s("div",{class:"s-social-share-modal-handle","aria-hidden":"true"}),s("div",{class:"s-social-share-modal-header"},s("span",{class:"s-social-share-modal-title"},this.getModalTitle()),s("button",{type:"button",class:"s-social-share-modal-close","aria-label":salla.lang.get("common.elements.close"),onClick:()=>this.close()},s("span",{class:"s-social-share-modal-close-icon",innerHTML:r}))),s("div",{class:"s-social-share-modal-platforms a2a_kit","data-a2a-url":this.getShareUrl(),"data-a2a-title":this.urlName?this.urlName:document.title},e.map((a=>this.renderModalCard(a)))),t&&s("div",{class:"s-social-share-modal-copy-row"},s("span",{class:"s-social-share-modal-url",dir:"ltr"},this.getShareUrl()),s("salla-button",{type:"button",fill:"outline",onClick:()=>this.copyLink()},this.copied?salla.lang.get("common.social.copied"):salla.lang.get("common.social.copy")))))}renderPopupList(){return s("ul",{class:{"s-social-share-list":!0,a2a_kit:!0,share:!0,opened:this.opened},"data-a2a-url":this.getShareUrl(),"data-a2a-title":this.urlName?this.urlName:document.title},this.platforms.split(",").map((a=>s("li",null,s("a",{class:`a2a_button_${a}`,"aria-label":`Share Via ${a}`},this.platformIcons.map((e=>{if(e.name===a)return s("span",{class:"s-social-share-icon",innerHTML:e.icon})})))))))}render(){return s("div",{key:"e54e51701050bfe02aa33824a5870294618ca22c",class:"s-social-share-wrapper"},s("slot",{key:"692691792083ae58a23c4a273019e09c74366805",name:"widget"},s("salla-button",{key:"a27f7bfd1d2fde734f1d89aa5dc83a59b3803b23","aria-label":"Share",onClick:()=>this.handleShareClick(),class:"s-social-share-btn",shape:"icon",fill:"outline",color:"light"},s("span",{key:"30cde6555a83a7362c2739e018fe994ee6dc25cf",innerHTML:this.opened?r:'\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>share-alt</title>\n<path d="M26.667 21.333c-1.699 0-3.196 0.812-4.173 2.052l-11.912-5.211c0.044-0.276 0.085-0.553 0.085-0.841 0-0.472-0.081-0.923-0.197-1.359l12.361-6.952c0.971 1.009 2.328 1.644 3.836 1.644 2.941 0 5.333-2.392 5.333-5.333s-2.392-5.333-5.333-5.333-5.333 2.392-5.333 5.333c0 0.472 0.081 0.923 0.197 1.359l-12.361 6.952c-0.971-1.009-2.328-1.644-3.836-1.644-2.941 0-5.333 2.392-5.333 5.333s2.392 5.333 5.333 5.333c1.699 0 3.196-0.812 4.173-2.052l11.912 5.211c-0.044 0.276-0.085 0.553-0.085 0.841 0 2.941 2.392 5.333 5.333 5.333s5.333-2.392 5.333-5.333-2.392-5.333-5.333-5.333zM26.667 2.667c1.471 0 2.667 1.196 2.667 2.667s-1.196 2.667-2.667 2.667-2.667-1.196-2.667-2.667 1.196-2.667 2.667-2.667zM5.333 20c-1.471 0-2.667-1.196-2.667-2.667s1.196-2.667 2.667-2.667 2.667 1.196 2.667 2.667-1.196 2.667-2.667 2.667zM26.667 29.333c-1.471 0-2.667-1.196-2.667-2.667s1.196-2.667 2.667-2.667 2.667 1.196 2.667 2.667-1.196 2.667-2.667 2.667z"></path>\n</svg>\n'}))),"modal"===this.mode?this.renderModal():this.renderPopupList())}get host(){return e(this)}static get watchers(){return{url:["onUrlChanged"]}}};d.style="/*!twlt*/:global(body.s-social-share-modal-is-open){overflow:hidden}.s-social-share-modal{position:fixed;inset:0;z-index:60;display:flex;align-items:center;justify-content:center;padding:1rem;background-color:rgba(17, 24, 39, 0.5)}.s-social-share-modal-dialog{position:relative;width:100%;max-width:32rem;padding:1.5rem;background-color:#fff;border-radius:1rem;box-shadow:0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)}.s-social-share-modal-handle{display:none}.s-social-share-modal-header{display:flex;align-items:center;justify-content:space-between;gap:1rem;margin-bottom:1.25rem}.s-social-share-modal-title{font-size:1.125rem;font-weight:700;color:#1f2937}.s-social-share-modal-close{display:inline-flex;align-items:center;justify-content:center;padding:0.25rem;line-height:0;background:transparent;border:0;cursor:pointer}.s-social-share-modal-close-icon svg{width:1.25rem;height:1.25rem;fill:#ef4444}.s-social-share-modal-platforms{display:grid;grid-template-columns:repeat(4, minmax(0, 1fr));gap:0.75rem}.s-social-share-modal-card{display:flex;flex-direction:column;align-items:center;gap:0.5rem;padding:0.75rem;border:1px solid #e5e7eb;border-radius:0.75rem;text-decoration:none;cursor:pointer;transition:border-color 0.15s ease, box-shadow 0.15s ease}.s-social-share-modal-card:hover{border-color:#d1d5db;box-shadow:0 1px 3px rgba(0, 0, 0, 0.08)}.s-social-share-modal-icon{display:flex;align-items:center;justify-content:center;width:3rem;height:3rem;border-radius:9999px}.s-social-share-modal-icon svg{width:1.25rem;height:1.25rem;fill:#fff}.s-social-share-modal-card-label{font-size:0.875rem;color:#4b5563}.s-social-share-modal-copy-row{display:flex;align-items:center;gap:0.75rem;margin-top:1rem;padding:0.5rem;background-color:#f3f4f6;border-radius:0.75rem}.s-social-share-modal-url{flex:1 1 auto;min-width:0;padding:0 0.5rem;font-size:0.875rem;color:#6b7280;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}@keyframes s-social-share-sheet-in{from{transform:translateY(100%)}to{transform:translateY(0)}}@media (max-width: 640px){.s-social-share-modal{align-items:flex-end;justify-content:center;padding:0}.s-social-share-modal-dialog{max-width:none;padding:0.75rem 1rem calc(1.25rem + env(safe-area-inset-bottom, 0px));border-radius:1rem 1rem 0 0;box-shadow:0 -4px 24px rgba(0, 0, 0, 0.12);animation:s-social-share-sheet-in 0.28s ease-out}.s-social-share-modal-handle{display:block;width:2.5rem;height:0.25rem;margin:0 auto 0.75rem;background-color:#d1d5db;border-radius:9999px}.s-social-share-modal-header{margin-bottom:1rem}.s-social-share-modal-platforms{grid-template-columns:repeat(2, minmax(0, 1fr))}}.static{position:static}.fixed{position:fixed}.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-social-share-wrapper{position:relative}.s-social-share-btn span{pointer-events:none}.s-social-share-btn span svg{height:1rem;width:1rem}.s-social-share-list{position:absolute;top:3rem;left:2.5px;z-index:10;display:flex;height:0px;flex-direction:column;align-items:center;overflow:hidden;border-radius:1.5rem;--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));opacity:0;--tw-shadow:0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.s-social-share-list.opened{height:auto}.s-social-share-list a{display:block;padding:0.75rem}.s-social-share-list a:hover svg{fill:var(--color-primary)}.s-social-share-icon svg{height:1rem;width:1rem}";export{d as salla_social_share}
|
|
4
|
+
import{r as a,h as s,a as e}from"./p-Bxge4xib.js";import{a as t}from"./p-CgtvEd63.js";import{f as i,t as o}from"./p-CO-PeZ27.js";import{M as l}from"./p-DmgxDvXL.js";import{C as r}from"./p-BsLF_HK7.js";var c,n='\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>link</title>\n<path d="M19.247 23.019l-4.189 4.189c-2.831 2.831-7.435 2.831-10.265 0-1.371-1.372-2.125-3.193-2.125-5.132s0.755-3.761 2.125-5.133l4.189-4.191c0.521-0.521 0.521-1.364 0-1.885s-1.364-0.521-1.885 0l-4.189 4.191c-1.875 1.875-2.907 4.367-2.907 7.019s1.032 5.143 2.907 7.017 4.368 2.907 7.019 2.907 5.143-1.032 7.017-2.908l4.189-4.189c0.521-0.521 0.521-1.364 0-1.885s-1.364-0.52-1.885 0.001zM22.276 9.724c-0.521-0.521-1.364-0.521-1.885 0l-10.667 10.667c-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391l10.667-10.667c0.521-0.521 0.521-1.364 0-1.885zM29.093 2.908c-1.875-1.876-4.368-2.908-7.019-2.908s-5.143 1.032-7.017 2.908l-4.189 4.188c-0.521 0.521-0.521 1.364 0 1.885s1.364 0.521 1.885 0l4.189-4.189c2.831-2.831 7.435-2.831 10.265 0 1.371 1.372 2.125 3.193 2.125 5.132s-0.755 3.761-2.125 5.133l-4.189 4.191c-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391l4.189-4.191c1.875-1.875 2.907-4.367 2.907-7.019s-1.032-5.143-2.907-7.016z"></path>\n</svg>\n',h='\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>whatsapp</title>\n<path d="M16 32c-0.008 0-0.018 0-0.028 0-3.1 0-5.993-0.887-8.439-2.421l0.066 0.039-7.2 2.3 2.336-6.964c-1.713-2.492-2.736-5.575-2.736-8.897 0-0.020 0-0.040 0-0.060v0.003c0.009-8.833 7.167-15.991 15.999-16h0.001c8.837 0 16 7.163 16 16s-7.163 16-16 16v0zM7.906 27.424l0.4 0.264c2.169 1.449 4.837 2.312 7.707 2.312 7.732 0 14-6.268 14-14s-6.268-14-14-14c-0.004 0-0.009 0-0.013 0h0.001c-7.729 0.008-13.992 6.271-14 13.999v0.001c-0 0.010-0 0.021-0 0.032 0 3.072 1 5.909 2.693 8.206l-0.027-0.038 0.304 0.416-1.4 4.2zM20.716 24.958c-1.684-0.131-3.237-0.574-4.641-1.271l0.073 0.033c-3.098-1.456-5.634-3.668-7.438-6.405l-0.042-0.067c-1.102-1.357-1.819-3.067-1.962-4.938l-0.002-0.030c-0.001-0.036-0.001-0.078-0.001-0.12 0-1.575 0.66-2.995 1.719-4l0.002-0.002c0.547-0.52 1.289-0.839 2.105-0.839 0.033 0 0.066 0.001 0.099 0.002l-0.005-0c0.2 0 0.378 0 0.542 0.018 0.016-0.001 0.035-0.001 0.054-0.001 0.815 0 1.502 0.549 1.711 1.298l0.003 0.012 0.324 0.782c0.376 0.906 0.858 2.068 0.942 2.244 0.144 0.251 0.23 0.552 0.23 0.873 0 0.286-0.068 0.557-0.188 0.797l0.005-0.010c-0.149 0.307-0.332 0.57-0.55 0.802l0.002-0.002c-0.148 0.168-0.248 0.274-0.346 0.378s-0.172 0.18-0.26 0.284c0.575 0.92 1.237 1.713 1.992 2.406l0.008 0.008c0.829 0.758 1.802 1.373 2.872 1.8l0.064 0.022c0.369-0.266 0.672-0.6 0.896-0.985l0.008-0.015 0.174-0.232c0.328-0.484 0.875-0.798 1.495-0.798 0.249 0 0.487 0.051 0.703 0.142l-0.012-0.004c0.492 0.168 2.922 1.372 2.946 1.384l0.228 0.11c0.415 0.149 0.758 0.417 0.996 0.763l0.004 0.007c0.107 0.349 0.169 0.75 0.169 1.166 0 0.591-0.125 1.153-0.349 1.661l0.010-0.026c-0.702 1.368-1.983 2.353-3.511 2.637l-0.031 0.005c-0.309 0.071-0.663 0.112-1.028 0.112-0.004 0-0.007 0-0.011 0h0.001zM10.632 9.318c-0.028-0.002-0.062-0.004-0.095-0.004-0.245 0-0.472 0.076-0.659 0.206l0.004-0.002c-0.726 0.651-1.18 1.591-1.18 2.638 0 0.044 0.001 0.087 0.002 0.13l-0-0.006c0.122 1.404 0.662 2.662 1.495 3.671l-0.009-0.011 0.12 0.168c1.627 2.491 3.865 4.46 6.504 5.723l0.096 0.041c3.136 1.288 3.916 1.124 4.426 1.014 0.87-0.159 1.601-0.656 2.067-1.347l0.007-0.011c0.12-0.316 0.204-0.682 0.237-1.063l0.001-0.015-0.040-0.018-0.256-0.124c-0.8-0.4-2.46-1.2-2.734-1.292l-0.058 0.184c-0.346 0.501-0.684 0.934-1.045 1.347l0.015-0.017c-0.344 0.349-0.821 0.565-1.349 0.565-0.28 0-0.546-0.061-0.785-0.17l0.012 0.005c-1.403-0.547-2.609-1.301-3.646-2.239l0.010 0.009c-0.975-0.891-1.81-1.912-2.486-3.039l-0.034-0.061c-0.152-0.244-0.242-0.54-0.242-0.857 0-0.463 0.191-0.88 0.499-1.178l0-0c0.13-0.162 0.264-0.302 0.4-0.444l0.236-0.256c0.091-0.096 0.177-0.201 0.254-0.311l0.006-0.009c-0.158-0.36-0.622-1.472-0.988-2.352l-0.322-0.772-0.038-0.086c-0.188-0.010-0.302-0.016-0.426-0.016zM12.462 12.442v0.012z"></path>\n</svg>\n';!function(a){a.FACEBOOK="facebook",a.TWITTER="twitter",a.WHATSAPP="whatsapp",a.EMAIL="email",a.COPY_LINK="copy_link"}(c||(c={}));const d=class{constructor(s){a(this,s),this.ignoreOutsideClick=!1,this.translationDefaults={"common.social.share":{ar:"مشاركة",en:"Share"},"common.social.email":{ar:"إيميل",en:"Email"},"common.social.whatsapp":{ar:"واتساب",en:"WhatsApp"},"common.social.twitter":{ar:"أكس",en:"X"},"common.social.facebook":{ar:"فيسبوك",en:"Facebook"},"common.social.copy":{ar:"نسخ",en:"Copy"},"common.social.copied":{ar:"تم النسخ",en:"Copied"}},this.onDocumentClick=a=>{this.ignoreOutsideClick||!this.opened||this.host.contains(a.target)||this.close()},this.opened=!1,this.copied=!1,this.allPlatforms=[c.WHATSAPP,c.FACEBOOK,c.TWITTER,c.EMAIL,c.COPY_LINK],this.platformIcons=[{icon:h,name:c.WHATSAPP},{icon:i,name:c.FACEBOOK},{icon:o,name:c.TWITTER},{icon:l,name:c.EMAIL},{icon:n,name:c.COPY_LINK}],this.convertedPlatforms=[],this.url="",this.urlName="",this.platforms="facebook,twitter,whatsapp,email,copy_link",this.mode="default",this.modalTitle=""}componentWillLoad(){if(this.registerTranslationDefaults(),this.host.hasAttribute("aria-label")&&this.host.removeAttribute("aria-label"),this.supportsNativeShare()||document.getElementById("a2a-script"))return;const a=document.createElement("script");a.src="https://static.addtoany.com/menu/page.js",a.setAttribute("id","a2a-script"),a.async=!0,a.onload=function(){window.a2a_config.locale=salla.config.get("user.language_code",salla.lang.getLocale()),window.a2a_config.callbacks=window.a2a_config.callbacks||[],window.a2a_config.callbacks.push({share:a=>{const s={share_via:a.service.toLowerCase(),url:a.url,title:a.title};salla.event.emit("share-element",s)}})},document.body.appendChild(a)}componentDidLoad(){document.addEventListener("click",this.onDocumentClick)}disconnectedCallback(){document.removeEventListener("click",this.onDocumentClick),this.copiedResetTimeout&&window.clearTimeout(this.copiedResetTimeout),this.setBodyScrollLocked(!1)}registerTranslationDefaults(){if(!salla?.lang?.addBulk)return;const a=Object.entries(this.translationDefaults).reduce(((a,[s,e])=>(salla.lang.get(s)===s&&(a[s]=e),a)),{});Object.keys(a).length&&salla.lang.addBulk(a)}resolveShareKit(){return this.host.querySelector(".a2a_kit")}deferOutsideClickGuard(){this.ignoreOutsideClick=!0,requestAnimationFrame((()=>{this.ignoreOutsideClick=!1}))}async open(){if(this.opened)return;if(this.opened=!0,this.deferOutsideClickGuard(),"modal"===this.mode&&this.setBodyScrollLocked(!0),await new Promise((a=>requestAnimationFrame((()=>a())))),!this.opened)return;if(await this.refresh(),"modal"===this.mode)return;const a=this.resolveShareKit();a?(this.openAnimation=(new t.timeline).add({targets:a,translateY:[-50,0],opacity:[0,1],duration:300,podding:"0",easing:"easeInOutSine"}),this.openAnimation.add({targets:a.children,translateZ:0,translateY:[-30,0],scaleY:[0,1],opacity:[0,1],duration:1400,delay:t.stagger(100)},"-=200")):this.opened=!1}async close(){this.opened&&(this.openAnimation?.pause(),this.openAnimation?.seek(0),this.opened=!1,"modal"===this.mode&&this.setBodyScrollLocked(!1))}setBodyScrollLocked(a){document.body.classList.toggle("s-social-share-modal-is-open",a)}toggle(){return this.opened?this.close():(this.deferOutsideClickGuard(),this.open())}supportsNativeShare(){return!!salla.mobile?.isSpaWebview?.()}handleShareClick(){this.supportsNativeShare()?salla.event.dispatch("mobile::share.open",{url:this.getShareUrl()}):this.toggle()}onUrlChanged(a,s){a!==s&&this.refresh()}getShareUrl(){return this.url||window.location.href}getModalTitle(){return this.modalTitle||salla.lang.get("common.social.share")}syncShareAttributes(){const a=this.resolveShareKit();a&&(a.setAttribute("data-a2a-url",this.getShareUrl()),a.setAttribute("data-a2a-title",this.urlName||document.title))}async refresh(){this.syncShareAttributes(),"function"!=typeof window.a2a?.init_all?window.a2a?.init("page"):window.a2a.init_all()}async copyLink(){const a=this.getShareUrl();try{await navigator.clipboard.writeText(a)}catch{const s=document.createElement("textarea");s.value=a,s.style.position="fixed",s.style.opacity="0",document.body.appendChild(s),s.select();try{document.execCommand("copy")}catch{}s.remove()}salla.event.emit("share-element",{share_via:"copy_link",url:a,title:this.urlName||document.title}),this.copied=!0,this.copiedResetTimeout&&window.clearTimeout(this.copiedResetTimeout),this.copiedResetTimeout=window.setTimeout((()=>this.copied=!1),2e3)}modalPlatformMeta(a){switch(a){case c.WHATSAPP:return{icon:h,color:"#25D366",label:salla.lang.get("common.social.whatsapp")};case c.FACEBOOK:return{icon:i,color:"#1877F2",label:salla.lang.get("common.social.facebook")};case c.TWITTER:return{icon:o,color:"#000000",label:salla.lang.get("common.social.twitter")};case c.EMAIL:return{icon:l,color:"#2BA6FF",label:salla.lang.get("common.social.email")};default:return{icon:n,color:"#6b7280",label:a}}}renderModalCard(a){const e=this.modalPlatformMeta(a);return s("a",{class:`s-social-share-modal-card a2a_button_${a}`,"aria-label":`Share Via ${a}`},s("span",{class:"s-social-share-modal-icon",style:{backgroundColor:e.color},innerHTML:e.icon}),s("span",{class:"s-social-share-modal-card-label"},e.label))}renderModal(){if(!this.opened)return null;const a=this.platforms.split(",").map((a=>a.trim())),e=[c.EMAIL,c.WHATSAPP,c.TWITTER,c.FACEBOOK].filter((s=>a.includes(s))),t=a.includes(c.COPY_LINK);return s("div",{class:"s-social-share-modal",onClick:a=>{a.target===a.currentTarget&&this.close()}},s("div",{class:"s-social-share-modal-dialog",role:"dialog","aria-modal":"true"},s("div",{class:"s-social-share-modal-handle","aria-hidden":"true"}),s("div",{class:"s-social-share-modal-header"},s("span",{class:"s-social-share-modal-title"},this.getModalTitle()),s("button",{type:"button",class:"s-social-share-modal-close","aria-label":salla.lang.get("common.elements.close"),onClick:()=>this.close()},s("span",{class:"s-social-share-modal-close-icon",innerHTML:r}))),s("div",{class:"s-social-share-modal-platforms a2a_kit","data-a2a-url":this.getShareUrl(),"data-a2a-title":this.urlName?this.urlName:document.title},e.map((a=>this.renderModalCard(a)))),t&&s("div",{class:"s-social-share-modal-copy-row"},s("span",{class:"s-social-share-modal-url",dir:"ltr"},this.getShareUrl()),s("salla-button",{type:"button",fill:"outline",onClick:()=>this.copyLink()},this.copied?salla.lang.get("common.social.copied"):salla.lang.get("common.social.copy")))))}renderPopupList(){return s("ul",{class:{"s-social-share-list":!0,a2a_kit:!0,share:!0,opened:this.opened},"data-a2a-url":this.getShareUrl(),"data-a2a-title":this.urlName?this.urlName:document.title},this.platforms.split(",").map((a=>s("li",null,s("a",{class:`a2a_button_${a}`,"aria-label":`Share Via ${a}`},this.platformIcons.map((e=>{if(e.name===a)return s("span",{class:"s-social-share-icon",innerHTML:e.icon})})))))))}render(){return s("div",{key:"e54e51701050bfe02aa33824a5870294618ca22c",class:"s-social-share-wrapper"},s("slot",{key:"692691792083ae58a23c4a273019e09c74366805",name:"widget"},s("salla-button",{key:"a27f7bfd1d2fde734f1d89aa5dc83a59b3803b23","aria-label":"Share",onClick:()=>this.handleShareClick(),class:"s-social-share-btn",shape:"icon",fill:"outline",color:"light"},s("span",{key:"30cde6555a83a7362c2739e018fe994ee6dc25cf",innerHTML:this.opened?r:'\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>share-alt</title>\n<path d="M26.667 21.333c-1.699 0-3.196 0.812-4.173 2.052l-11.912-5.211c0.044-0.276 0.085-0.553 0.085-0.841 0-0.472-0.081-0.923-0.197-1.359l12.361-6.952c0.971 1.009 2.328 1.644 3.836 1.644 2.941 0 5.333-2.392 5.333-5.333s-2.392-5.333-5.333-5.333-5.333 2.392-5.333 5.333c0 0.472 0.081 0.923 0.197 1.359l-12.361 6.952c-0.971-1.009-2.328-1.644-3.836-1.644-2.941 0-5.333 2.392-5.333 5.333s2.392 5.333 5.333 5.333c1.699 0 3.196-0.812 4.173-2.052l11.912 5.211c-0.044 0.276-0.085 0.553-0.085 0.841 0 2.941 2.392 5.333 5.333 5.333s5.333-2.392 5.333-5.333-2.392-5.333-5.333-5.333zM26.667 2.667c1.471 0 2.667 1.196 2.667 2.667s-1.196 2.667-2.667 2.667-2.667-1.196-2.667-2.667 1.196-2.667 2.667-2.667zM5.333 20c-1.471 0-2.667-1.196-2.667-2.667s1.196-2.667 2.667-2.667 2.667 1.196 2.667 2.667-1.196 2.667-2.667 2.667zM26.667 29.333c-1.471 0-2.667-1.196-2.667-2.667s1.196-2.667 2.667-2.667 2.667 1.196 2.667 2.667-1.196 2.667-2.667 2.667z"></path>\n</svg>\n'}))),"modal"===this.mode?this.renderModal():this.renderPopupList())}get host(){return e(this)}static get watchers(){return{url:["onUrlChanged"]}}};d.style="/*!twlt*/:global(body.s-social-share-modal-is-open){overflow:hidden}.s-social-share-modal{position:fixed;inset:0;z-index:60;display:flex;align-items:center;justify-content:center;padding:1rem;background-color:rgba(17, 24, 39, 0.5)}.s-social-share-modal-dialog{position:relative;width:100%;max-width:32rem;padding:1.5rem;background-color:#fff;border-radius:1rem;box-shadow:0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)}.s-social-share-modal-handle{display:none}.s-social-share-modal-header{display:flex;align-items:center;justify-content:space-between;gap:1rem;margin-bottom:1.25rem}.s-social-share-modal-title{font-size:1.125rem;font-weight:700;color:#1f2937}.s-social-share-modal-close{display:inline-flex;align-items:center;justify-content:center;padding:0.25rem;line-height:0;background:transparent;border:0;cursor:pointer}.s-social-share-modal-close-icon svg{width:1.25rem;height:1.25rem;fill:#ef4444}.s-social-share-modal-platforms{display:grid;grid-template-columns:repeat(4, minmax(0, 1fr));gap:0.75rem}.s-social-share-modal-card{display:flex;flex-direction:column;align-items:center;gap:0.5rem;padding:0.75rem;border:1px solid #e5e7eb;border-radius:0.75rem;text-decoration:none;cursor:pointer;transition:border-color 0.15s ease, box-shadow 0.15s ease}.s-social-share-modal-card:hover{border-color:#d1d5db;box-shadow:0 1px 3px rgba(0, 0, 0, 0.08)}.s-social-share-modal-icon{display:flex;align-items:center;justify-content:center;width:3rem;height:3rem;border-radius:9999px}.s-social-share-modal-icon svg{width:1.25rem;height:1.25rem;fill:#fff}.s-social-share-modal-card-label{font-size:0.875rem;color:#4b5563}.s-social-share-modal-copy-row{display:flex;align-items:center;gap:0.75rem;margin-top:1rem;padding:0.5rem;background-color:#f3f4f6;border-radius:0.75rem}.s-social-share-modal-url{flex:1 1 auto;min-width:0;padding:0 0.5rem;font-size:0.875rem;color:#6b7280;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}@keyframes s-social-share-sheet-in{from{transform:translateY(100%)}to{transform:translateY(0)}}@media (max-width: 640px){.s-social-share-modal{align-items:flex-end;justify-content:center;padding:0}.s-social-share-modal-dialog{max-width:none;padding:0.75rem 1rem calc(1.25rem + env(safe-area-inset-bottom, 0px));border-radius:1rem 1rem 0 0;box-shadow:0 -4px 24px rgba(0, 0, 0, 0.12);animation:s-social-share-sheet-in 0.28s ease-out}.s-social-share-modal-handle{display:block;width:2.5rem;height:0.25rem;margin:0 auto 0.75rem;background-color:#d1d5db;border-radius:9999px}.s-social-share-modal-header{margin-bottom:1rem}.s-social-share-modal-platforms{grid-template-columns:repeat(2, minmax(0, 1fr))}}.static{position:static}.fixed{position:fixed}.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-social-share-wrapper{position:relative}.s-social-share-btn span{pointer-events:none}.s-social-share-btn span svg{height:1rem;width:1rem}.s-social-share-list{position:absolute;top:3rem;left:2.5px;z-index:10;display:flex;height:0px;flex-direction:column;align-items:center;overflow:hidden;border-radius:1.5rem;--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));opacity:0;--tw-shadow:0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.s-social-share-list.opened{height:auto}.s-social-share-list a{display:block;padding:0.75rem}.s-social-share-list a:hover svg{fill:var(--color-primary)}.s-social-share-icon svg{height:1rem;width:1rem}";export{d as salla_social_share}
|