@salla.sa/twilight-components 2.14.383 → 2.14.385
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{filepond-FfrhyKz_.js → filepond-CH0EhqTR.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-poster-Ds_gerir.js → filepond-plugin-file-poster-DB_nSU5H.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-size-DsGfgBE-.js → filepond-plugin-file-validate-size-DhmLgwAd.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-type-BvW9_zdt.js → filepond-plugin-file-validate-type-BP6pXR9l.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-edit-C0wUJzTN.js → filepond-plugin-image-edit-H28z0oor.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-Dd4ENZCp.js → filepond-plugin-image-exif-orientation-B3aPmsvW.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview-ax_Wpscv.js → filepond-plugin-image-preview-2UoG7SNa.js} +1 -1
- package/dist/cjs/{index-CDeKQ2em.js → index-0Q56lC1x.js} +1 -1
- package/dist/cjs/{index-CedylOEg.js → index-C0Kew27I.js} +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/salla-accordion-body_3.cjs.entry.js +1 -1
- package/dist/cjs/salla-accordion_6.cjs.entry.js +1 -1
- package/dist/cjs/salla-add-product-button_4.cjs.entry.js +1 -1
- package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
- package/dist/cjs/salla-alert_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
- package/dist/cjs/salla-booking-field_7.cjs.entry.js +10 -10
- package/dist/cjs/salla-bullet-delivery.cjs.entry.js +1 -1
- package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-comment-form_8.cjs.entry.js +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_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-custom-fields.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-gifting.cjs.entry.js +1 -1
- package/dist/cjs/salla-hook.cjs.entry.js +1 -1
- package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
- package/dist/cjs/salla-installment.cjs.entry.js +1 -1
- package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
- package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-program.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-menu.cjs.entry.js +1 -1
- package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-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-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-progress-bar.cjs.entry.js +1 -1
- package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
- package/dist/cjs/salla-rating-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-scopes.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-slider.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-tooltip.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/twilight.cjs.js +1 -1
- package/dist/cjs/{vanilla-picker-Ccjmisjh.js → vanilla-picker-D_FRjdtf.js} +1 -1
- package/dist/components/index.js +2 -2
- package/dist/esm/{filepond-DzmjApmA.js → filepond-C6DmvP0k.js} +1 -1
- package/dist/esm/{filepond-plugin-file-poster-C6mmnK9N.js → filepond-plugin-file-poster-aflPfdvq.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-size-CECuuLxY.js → filepond-plugin-file-validate-size-2ysTkym4.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-type-Bhy9JvJz.js → filepond-plugin-file-validate-type-CvlSQE9k.js} +1 -1
- package/dist/esm/{filepond-plugin-image-edit-D9txY4YW.js → filepond-plugin-image-edit-CPNOb0bn.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-Pv0Z-3au.js → filepond-plugin-image-exif-orientation-DSOEX9W9.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-CjTCnM-N.js → filepond-plugin-image-preview-ZVPoyaGu.js} +1 -1
- package/dist/esm/{index-CJLoNZ6n.js → index-Dt1F_uJO.js} +1 -1
- package/dist/esm/{index-BQQ2x3w_.js → index-DygKr0gG.js} +2 -2
- package/dist/esm/loader.js +2 -2
- package/dist/esm/salla-accordion-body_3.entry.js +1 -1
- package/dist/esm/salla-accordion_6.entry.js +1 -1
- package/dist/esm/salla-add-product-button_4.entry.js +1 -1
- package/dist/esm/salla-advertisement.entry.js +1 -1
- package/dist/esm/salla-alert_2.entry.js +1 -1
- package/dist/esm/salla-app-install-alert.entry.js +1 -1
- package/dist/esm/salla-apps-icons.entry.js +1 -1
- package/dist/esm/salla-booking-field_7.entry.js +10 -10
- package/dist/esm/salla-bullet-delivery.entry.js +1 -1
- package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
- package/dist/esm/salla-comment-form_8.entry.js +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_2.entry.js +1 -1
- package/dist/esm/salla-custom-fields.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-gifting.entry.js +1 -1
- package/dist/esm/salla-hook.entry.js +1 -1
- package/dist/esm/salla-infinite-scroll.entry.js +1 -1
- package/dist/esm/salla-installment.entry.js +1 -1
- package/dist/esm/salla-list-tile.entry.js +1 -1
- package/dist/esm/salla-localization-modal.entry.js +1 -1
- package/dist/esm/salla-login-modal.entry.js +1 -1
- package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
- package/dist/esm/salla-loyalty-program.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-menu.entry.js +1 -1
- package/dist/esm/salla-metadata.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-notification-item.entry.js +1 -1
- package/dist/esm/salla-notifications.entry.js +1 -1
- package/dist/esm/salla-offer-modal.entry.js +1 -1
- package/dist/esm/salla-offer.entry.js +1 -1
- package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-order-details-options.entry.js +1 -1
- package/dist/esm/salla-order-details.entry.js +1 -1
- package/dist/esm/salla-order-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-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-progress-bar.entry.js +1 -1
- package/dist/esm/salla-quick-order.entry.js +1 -1
- package/dist/esm/salla-rating-modal.entry.js +1 -1
- package/dist/esm/salla-scopes.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-slider.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-tooltip.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/twilight.js +2 -2
- package/dist/esm/{vanilla-picker-Dnbg5fH8.js → vanilla-picker-vpLzwiOX.js} +1 -1
- package/dist/twilight/{p-51532d01.entry.js → p-01cd6efd.entry.js} +1 -1
- package/dist/twilight/{p-5992e9a6.entry.js → p-04b0d99d.entry.js} +1 -1
- package/dist/twilight/{p-c6043101.entry.js → p-069a93a0.entry.js} +1 -1
- package/dist/twilight/{p-2fcdf975.entry.js → p-07aaf6fb.entry.js} +1 -1
- package/dist/twilight/{p-e325b57f.entry.js → p-0ac97966.entry.js} +1 -1
- package/dist/twilight/{p-6aa32a4f.entry.js → p-0e06763b.entry.js} +1 -1
- package/dist/twilight/{p-ffa6704b.entry.js → p-11d1af5a.entry.js} +1 -1
- package/dist/twilight/{p-3934af60.entry.js → p-1570c69c.entry.js} +1 -1
- package/dist/twilight/{p-16a00a6b.entry.js → p-15ad8b57.entry.js} +1 -1
- package/dist/twilight/{p-741cfe08.entry.js → p-16956de8.entry.js} +1 -1
- package/dist/twilight/{p-7ad0d904.entry.js → p-1dac71bd.entry.js} +1 -1
- package/dist/twilight/{p-08e1e144.entry.js → p-26dbba19.entry.js} +1 -1
- package/dist/twilight/{p-6babac82.entry.js → p-28c10ffc.entry.js} +1 -1
- package/dist/twilight/{p-c5d3b500.entry.js → p-2f1dc423.entry.js} +1 -1
- package/dist/twilight/{p-714c347a.entry.js → p-313de30b.entry.js} +1 -1
- package/dist/twilight/{p-add6050e.entry.js → p-3174a7da.entry.js} +1 -1
- package/dist/twilight/{p-69505c2b.entry.js → p-31feb28e.entry.js} +1 -1
- package/dist/twilight/{p-b23cb9fa.entry.js → p-3306e240.entry.js} +1 -1
- package/dist/twilight/{p-488e6ec3.entry.js → p-42a88fbe.entry.js} +1 -1
- package/dist/twilight/{p-f5c3c72c.entry.js → p-4329e96a.entry.js} +1 -1
- package/dist/twilight/{p-695fb13a.entry.js → p-4c8d6286.entry.js} +1 -1
- package/dist/twilight/{p-52d7a6ab.entry.js → p-4f0da42e.entry.js} +1 -1
- package/dist/twilight/{p-a3d3d7b4.entry.js → p-5609c0a2.entry.js} +1 -1
- package/dist/twilight/{p-aa6353d4.entry.js → p-590aa84f.entry.js} +1 -1
- package/dist/twilight/{p-3714fe15.entry.js → p-61891d9d.entry.js} +1 -1
- package/dist/twilight/{p-51472946.entry.js → p-64aaf5d1.entry.js} +1 -1
- package/dist/twilight/{p-1922b518.entry.js → p-64da3ca2.entry.js} +1 -1
- package/dist/twilight/{p-2763bc0d.entry.js → p-6a9c0acd.entry.js} +1 -1
- package/dist/twilight/{p-af3d9d91.entry.js → p-717f98a9.entry.js} +1 -1
- package/dist/twilight/{p-b2bb75f9.entry.js → p-72dfb078.entry.js} +1 -1
- package/dist/twilight/{p-11e9f5e2.entry.js → p-7725e637.entry.js} +1 -1
- package/dist/twilight/{p-986815d4.entry.js → p-7c05380e.entry.js} +1 -1
- package/dist/twilight/{p-026d34dc.entry.js → p-7e6ac5b6.entry.js} +1 -1
- package/dist/twilight/{p-2e411fb3.entry.js → p-7e6cc902.entry.js} +1 -1
- package/dist/twilight/{p-e8d5477f.entry.js → p-7f5da469.entry.js} +1 -1
- package/dist/twilight/{p-303f893d.entry.js → p-7ff1a66d.entry.js} +1 -1
- package/dist/twilight/{p-f0b433fb.entry.js → p-8d40cb2a.entry.js} +1 -1
- package/dist/twilight/{p-6f2d0ee6.entry.js → p-91c7b197.entry.js} +1 -1
- package/dist/twilight/{p-46380ac9.entry.js → p-93fafdb9.entry.js} +1 -1
- package/dist/twilight/{p-d5eb6bbc.entry.js → p-97e204bf.entry.js} +1 -1
- package/dist/twilight/{p-3a1fad8e.entry.js → p-9f92c538.entry.js} +1 -1
- package/dist/twilight/{p-D0EHTnBd.js → p-BlNhJOfK.js} +1 -1
- package/dist/twilight/{p-DGMGmLqn.js → p-BqgMCU7i.js} +1 -1
- package/dist/twilight/{p-CGeDKEEL.js → p-CU9SaqqL.js} +1 -1
- package/dist/twilight/{p-DmSAMmdd.js → p-CckfqYjO.js} +1 -1
- package/dist/twilight/{p-D9xD5aYE.js → p-CiQozo5Q.js} +1 -1
- package/dist/twilight/{p-Bq-bTOp9.js → p-DBSxANjD.js} +2 -2
- package/dist/twilight/{p-CDH24E1K.js → p-DxwvrO7V.js} +1 -1
- package/dist/twilight/{p-BQQ2x3w_.js → p-DygKr0gG.js} +1 -1
- package/dist/twilight/{p-BLq2GB4G.js → p-PRDr-VhL.js} +1 -1
- package/dist/twilight/{p-befb1156.entry.js → p-a265395a.entry.js} +1 -1
- package/dist/twilight/{p-64a8792e.entry.js → p-a5a159b8.entry.js} +1 -1
- package/dist/twilight/{p-79cdc71a.entry.js → p-abda287b.entry.js} +1 -1
- package/dist/twilight/{p-daa3701c.entry.js → p-b17de694.entry.js} +1 -1
- package/dist/twilight/{p-60f32b80.entry.js → p-b503ed92.entry.js} +1 -1
- package/dist/twilight/{p-3ee0f66c.entry.js → p-b64af3e6.entry.js} +1 -1
- package/dist/twilight/{p-8546238c.entry.js → p-b667c2d4.entry.js} +1 -1
- package/dist/twilight/{p-4f6054f9.entry.js → p-b8f61fb6.entry.js} +1 -1
- package/dist/twilight/{p-fb904cfe.entry.js → p-b900e4bf.entry.js} +1 -1
- package/dist/twilight/{p-117bd566.entry.js → p-ba2754b0.entry.js} +1 -1
- package/dist/twilight/{p-26bb80de.entry.js → p-ba9ea832.entry.js} +1 -1
- package/dist/twilight/{p-66192c3b.entry.js → p-bf5c3fb6.entry.js} +1 -1
- package/dist/twilight/{p-8514a131.entry.js → p-c18afdd4.entry.js} +1 -1
- package/dist/twilight/{p-cef3c4e3.entry.js → p-c1d5778e.entry.js} +1 -1
- package/dist/twilight/{p-4c1cd8c8.entry.js → p-d1c0eb72.entry.js} +1 -1
- package/dist/twilight/{p-0552060d.entry.js → p-d46b9b12.entry.js} +1 -1
- package/dist/twilight/{p-729d862b.entry.js → p-d7440521.entry.js} +1 -1
- package/dist/twilight/{p-1fddcdc4.entry.js → p-d87a6578.entry.js} +1 -1
- package/dist/twilight/{p-24b0f393.entry.js → p-db8f128a.entry.js} +1 -1
- package/dist/twilight/{p-6bc162f4.entry.js → p-e294f075.entry.js} +1 -1
- package/dist/twilight/{p-72b78981.entry.js → p-e3725374.entry.js} +1 -1
- package/dist/twilight/{p-623c4f93.entry.js → p-e6909519.entry.js} +1 -1
- package/dist/twilight/{p-d8f0d47a.entry.js → p-e8562b9e.entry.js} +1 -1
- package/dist/twilight/{p-6c30dd6a.entry.js → p-ee30137a.entry.js} +1 -1
- package/dist/twilight/{p-245b38fc.entry.js → p-f001a716.entry.js} +1 -1
- package/dist/twilight/{p-4879ffb5.entry.js → p-fa071bdf.entry.js} +1 -1
- package/dist/twilight/{p-01e10e8a.entry.js → p-fdd668a8.entry.js} +1 -1
- package/dist/twilight/{p-D4QfuoE4.js → p-kltSiNjL.js} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as a,h as s,a as t}from"./p-
|
|
4
|
+
import{r as a,h as s,a as t}from"./p-DygKr0gG.js";import{a as c}from"./p-CgtvEd63.js";import{f as e,t as l}from"./p-CO-PeZ27.js";import{M as i}from"./p-DmgxDvXL.js";import{C as n}from"./p-BsLF_HK7.js";var o;!function(a){a.FACEBOOK="facebook",a.TWITTER="twitter",a.WHATSAPP="whatsapp",a.EMAIL="email",a.COPY_LINK="copy_link"}(o||(o={}));const r=class{constructor(s){a(this,s),this.opened=!1,this.allPlatforms=[o.WHATSAPP,o.FACEBOOK,o.TWITTER,o.EMAIL,o.COPY_LINK],this.platformIcons=[{icon:'\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',name:o.WHATSAPP},{icon:e,name:o.FACEBOOK},{icon:l,name:o.TWITTER},{icon:i,name:o.EMAIL},{icon:'\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',name:o.COPY_LINK}],this.convertedPlatforms=[],this.url="",this.urlName="",this.platforms="facebook,twitter,whatsapp,email,copy_link"}componentWillLoad(){if(this.host.hasAttribute("aria-label")&&this.host.removeAttribute("aria-label"),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)}async open(){const a=(new c.timeline).add({targets:this.shareMenu,translateY:[-50,0],opacity:[0,1],duration:300,podding:"0",easing:"easeInOutSine"});a.add({targets:this.shareMenu.children,translateZ:0,translateY:[-30,0],scaleY:[0,1],opacity:[0,1],duration:1400,delay:c.stagger(100)},"-=200"),this.opened=!this.opened,this.opened?this.shareMenu.classList.add("opened"):(a.pause(),a.seek(0),this.shareMenu.classList.remove("opened"))}async refresh(){window.a2a?.init("page")}render(){return s("div",{key:"ce2897e4cac7940407f6466a0eb4b2ff9fab3236",class:"s-social-share-wrapper"},s("slot",{key:"a0d4beebb29febd203d619845223c4e62b6b9c21",name:"widget"},s("salla-button",{key:"8615149ec0475bafc2f94d4b0bacfd49048d112f","aria-label":"Share",onClick:()=>this.open(),class:"s-social-share-btn",shape:"icon",fill:"outline",color:"light"},s("span",{key:"187e9aa3194eedafd1355fc3e79db1118e21050f",innerHTML:this.opened?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>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'}))),s("ul",{key:"7a1192bbf8e39d7fa101deae229949cc730aff0b",ref:a=>this.shareMenu=a,class:"s-social-share-list a2a_kit share","data-a2a-url":this.url?this.url:window.location.href,"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((t=>{if(t.name===a)return s("span",{class:"s-social-share-icon",innerHTML:t.icon})}))))))))}get host(){return t(this)}};r.style="";export{r as salla_social_share}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as s,c as t,h as i,H as e,a as h}from"./p-
|
|
4
|
+
import{r as s,c as t,h as i,H as e,a as h}from"./p-DygKr0gG.js";import{M as r}from"./p-DmgxDvXL.js";const l=class{constructor(i){s(this,i),this.verified=t(this,"verified"),this.translationLoaded=!1,this.display="modal",this.type="mobile",this.autoReload=!0,this.supportWebAuth=!0,this.resendAfter=30,this.isProfileVerify=!1,salla.lang.onLoaded((()=>{this.translationLoaded=!0,this.title=salla.lang.get("pages.profile.verify_title")+salla.lang.get("common.elements."+this.type),this.modal?.setTitle(this.title)})),"inline"!=this.display?(salla.event.on("profile::verification",(s=>{let t=Array.isArray(s)?s[0]:s;this.isProfileVerify=!0,this.open(t),this.title=salla.lang.get("pages.profile.verify_title")+salla.lang.get("common.elements."+t.type),this.modal?.setTitle(this.title)})),salla.event.on("modalClosed",(()=>{this.resendAfter=0,this.timer.innerHTML="30 : 00"}))):this.modal={open:()=>"",close:()=>"",setTitle:()=>""}}splitNumber(s){this.resetError();let t=s.data||s.target.value;t&&1!==t.length&&this.modifyNext(s.target,t)}modifyNext(s,t){s.value=t[0],t=t.substring(1),s.nextElementSibling&&t.length?this.modifyNext(s.nextElementSibling,t):s.nextElementSibling||0!==t.length?s.nextElementSibling&&0===t.length&&s.nextElementSibling.focus():s.focus()}checkAllInputs(){let s=!0;for(let t=0;t<this.otpInputs.length;t++)""===this.otpInputs[t].value&&(s=!1);return s}handleKeyUp(s){if(this.resetError(),["Alt","Shift","Control","AltGraph","Ctrl"].includes(s.key))return;let t=s.keyCode||s.charCode;s.target.value?(s.target.nextElementSibling?.focus(),s.target.nextElementSibling?.select()):[8,46].includes(t)&&(s.target.previousElementSibling?.focus(),s.target.previousElementSibling?.select()),s.target.value.length>1&&this.splitNumber(s)}handlePaste(s){this.resetError();let t=(salla.helpers.number(s.clipboardData.getData("text"))||"").replace(/[^0-9]/g,"");t=t.substring(0,this.otpInputs.length),this.otpInputs.forEach((s=>s.value="")),this.modifyNext(this.otpInputs[0],t)}handleInput(s){this.resetError(),salla.helpers.inputDigitsOnly(s.target),this.checkAllInputs()&&setTimeout((()=>{this.toggleOTPSubmit()}),100)}resetError(){this.hasError=!1,this.errorMessage=""}handleFocus(s){s.target!==this.firstOtpInput&&(""==this.firstOtpInput?.value&&this.firstOtpInput.focus(),""==s.target.previousElementSibling.value&&s.target.previousElementSibling.focus())}async getCode(){return this.code.value}async open(s){this.data=s,this.data.type=this.data.type||this.type,this.type=this.data.type,this.resendTimer(),this.otpInputs=this.body.querySelectorAll(".s-verify-input"),this.firstOtpInput=this.body.querySelector("#otp-1"),this.reset(),this.resetError(),"modal"==this.display&&this.modal?.setTitle(this.title),this.modal.open(),this.firstOtpInput?.addEventListener("input",(s=>this.splitNumber(s))),setTimeout((()=>this.otpInputs[0].focus()),100)}toggleOTPSubmit(){let s=[];if(this.otpInputs.forEach((t=>t.value&&s.push(t.value))),this.code.value=s.join(""),4===s.length)return this.btn.disable(),void this.btn.click();this.btn.enable()}reset(){this.otpInputs.forEach((s=>s.value="")),this.code.value="",this.otpInputs[0].focus()}resendTimer(){this.resendMessage.style.display="block",this.resend.style.display="none",this.resendAfter=30;let s=setInterval((()=>{this.resendAfter<=0?(clearInterval(s),this.resend.style.display="block",this.resendMessage.style.display="none"):(this.timer.innerHTML=`${this.resendAfter>=10?this.resendAfter:"0"+this.resendAfter} : 00`,this.resendAfter--)}),1e3)}resendCode(){return this.btn.stop().then((()=>this.btn.disable())).then((()=>{this.otpInputs.forEach((s=>s.value="")),this.otpInputs[0].focus()})).then((()=>salla.api.auth.resend(this.data))).finally((()=>this.resendTimer()))}submit(){if(this.code.value.length<4)return this.otpInputs[this.code.value.length].focus(),void salla.log("Trying to submit without 4 digits!");let s={code:this.code.value,...this.data};return this.btn.load().then((()=>this.btn.disable())).then((()=>this.isProfileVerify?salla.profile.verify(s):salla.auth.verify(s,this.supportWebAuth))).then((s=>this.verified.emit(s))).then((()=>this.btn.stop()&&this.btn.disable())).then((()=>this.modal.close())).then((()=>this.autoReload&&window.location.reload())).catch((s=>{this.hasError=!0,this.errorMessage=s.response?.data?.error?.message||salla.lang.get("common.errors.error_occurred"),s.response?salla.logger.error(s):console.log("Unexpected error",s),this.btn.stop()&&this.btn.enable()&&this.reset()}))}render(){return"inline"==this.display?i(e,null,this.myBody()):i("salla-modal",{width:"xs",class:"s-verify",ref:s=>this.modal=s,"modal-title":this.title},i("span",{slot:"icon",class:"s-verify-header-icon",innerHTML:"mobile"==this.type?'\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>android-phone</title>\n<path d="M22.667 0h-13.333c-2.941 0-5.333 2.392-5.333 5.333v21.333c0 2.941 2.392 5.333 5.333 5.333h13.333c2.941 0 5.333-2.392 5.333-5.333v-21.333c0-2.941-2.392-5.333-5.333-5.333zM25.333 26.667c0 1.471-1.196 2.667-2.667 2.667h-13.333c-1.471 0-2.667-1.196-2.667-2.667v-2.667h18.667zM25.333 21.333h-18.667v-16c0-1.471 1.196-2.667 2.667-2.667h13.333c1.471 0 2.667 1.196 2.667 2.667zM13.333 28h5.333c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333h-5.333c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333z"></path>\n</svg>\n':r}),this.myBody())}myBody(){return i("div",{class:"s-verify-body",ref:s=>this.body=s},i("div",{class:"s-verify-message",innerHTML:salla.lang.get("pages.profile.verify_message")}),i("slot",{name:"mobile"}),i("slot",{name:"email"}),i("input",{type:"hidden",name:"code",maxlength:"4",required:!0,ref:s=>this.code=s}),i("div",{class:{"s-verify-codes":!0,"has-error":this.hasError},dir:"ltr"},[1,2,3,4].map((s=>i("input",{type:"number",autocomplete:"one-time-code",pattern:"[0-9]*",inputmode:"numeric",maxlength:"1",value:"",id:`otp-${s}`,class:{"s-verify-input":!0,"s-has-error":this.hasError},onInput:s=>this.handleInput(s),onPaste:s=>this.handlePaste(s),onKeyUp:s=>this.handleKeyUp(s),onFocus:s=>this.handleFocus(s),required:!0})))),this.hasError&&this.errorMessage?i("span",{class:"s-verify-error-message"},this.errorMessage):"",i("div",{slot:"footer",class:"s-verify-footer"},i("salla-button",{class:"s-verify-submit","loader-position":"center",disabled:!0,onClick:()=>this.submit(),ref:s=>this.btn=s},salla.lang.get("pages.profile.verify")),i("p",{class:"s-verify-resend-message",ref:s=>this.resendMessage=s},salla.lang.get("blocks.header.resend_after"),i("b",{class:"s-verify-timer",ref:s=>this.timer=s})),i("a",{href:"#",class:"s-verify-resend",onClick:()=>this.resendCode(),ref:s=>this.resend=s},salla.lang.get("blocks.comments.submit"))),i("slot",{name:"after-footer"}))}get host(){return h(this)}};l.style="salla-verify{display:block}.s-verify-input{}.s-verify-input::-webkit-outer-spin-button,.s-verify-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.s-verify-input[type=number]{-moz-appearance:textfield}";export{l as salla_verify}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as e,h as s,a as t}from"./p-
|
|
4
|
+
import{r as e,h as s,a as t}from"./p-DygKr0gG.js";import{S as a}from"./p-Ctkfc4K-.js";const l=class{constructor(s){e(this,s),this.offer=null,this.hasError=!1,this.translationLoaded=!1,this.addToCartLabel=salla.lang.get("pages.cart.add_to_cart"),salla.event.on("offer-modal::open",(e=>this.open(e))),salla.lang.onLoaded((()=>{this.addToCartLabel=salla.lang.get("pages.cart.add_to_cart"),this.translationLoaded=!0})),this.categorySlot=this.host.querySelector('[slot="category"]')?.innerHTML||'<span class="s-offer-modal-badge-icon">{tagIcon}</span><span class="s-offer-modal-badge-text">{name}</span>',salla.event.on("offer-modal::open",(e=>this.open(e))),salla.product.event.onOfferExisted((e=>{salla.storage.get("remember-offer-"+e.id)?salla.log("User selected to don't show this offer again."):this.open(e.product_id)}))}emitPromotionViewed(e){e&&salla.event.emit("promotion::viewed",[{id:e.id?.toString(),creative:e.message,name:e.name,position:`${this.offer_type}_offer_modal`}])}emitPromotionClicked(e){e&&salla.event.emit("promotion::clicked",[{id:e.id?.toString(),creative:e.message,name:e.name,position:`${this.offer_type}_offer_modal`}])}async open(e){return this.productID=e,this.hasError=!1,this.modal.loading(),await salla.api.withoutNotifier((()=>salla.product.offers(e))).then((e=>{e.data&&e.data.length&&(this.modal.open(),this.showOffer(e.data[0]))})).catch((e=>{this.hasError=!0,this.errorMessage=e.response?.data?.error?.message||e.response?.data,this.modal.open()})).finally((()=>{this.modal.visible&&setTimeout((()=>this.modal.stopLoading()),1e3)}))}async showOffer(e){this.offer=e,this.offer_name=e.name,this.offer_message=e.message,this.offer.get.discounts_table?this.offer_type="discounts-table":this.offer.get.products?.length?this.offer_type="products":this.offer.get.categories?.length&&(this.offer_type="categories"),this.modal.setTitle(this.offer_name),this.emitPromotionViewed(this.offer)}rememberMe(e){salla.storage.set("remember-offer-"+this.offer.id,e.target.checked)}addToCart(e){this.emitPromotionClicked(this.offer),salla.api.withoutNotifier((()=>salla.cart.quickAdd(this.productID,e,this.offer_type))).then((()=>this.modal.close()))}getOfferContent(){if(this.offer.get.discounts_table)return s("div",{class:"s-offer-modal-discount-table"},s("table",null,s("tbody",null,this.offer.get.discounts_table?.map((e=>s("tr",null,s("td",null,e.text),s("td",{class:"s-offer-modal-discount-table-cell"},s("salla-button",{fill:"outline",shape:"btn",color:"primary",size:"medium",width:"normal",onClick:()=>this.addToCart(e.quantity)},this.addToCartLabel))))))));if(this.offer.get.products?.length){const e=this.offer.get.products?.length||0,t={slidesPerView:"auto",spaceBetween:16,breakpoints:{768:{slidesPerView:Math.min(2,e),spaceBetween:16},1024:{slidesPerView:Math.min(3,e),spaceBetween:16}}};return s("salla-products-slider",{key:(this.offer.get.products?.map((e=>e.id))||[]).join(","),source:"selected","source-value":`[${(this.offer.get.products?.map((e=>e.id))||[]).join(",")}]`,"slider-config":JSON.stringify(t)})}return this.offer.get.categories?.length?s("salla-slider",{type:"carousel",class:{"s-offer-modal-slider-centered":this.offer.get.categories?.length<=2,"s-offer-modal-slider":!0},id:"offer-modal-slider","controls-outer":!0,"show-controls":this.offer.get.categories?.length<=2?"false":"true"},s("div",{slot:"items"},this.offer.get.categories.map((e=>s("a",{href:e.urls.customer,class:"s-offer-modal-badge s-offer-modal-slider-item s-offer-modal-cat-item",innerHTML:this.categorySlot.replace(/\{tagIcon\}/g,'<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>tag</title>\n<path d="M28 0h-9.344c-1.059 0-2.056 0.411-2.809 1.153l-14.673 14.456c-1.56 1.56-1.561 4.097-0.001 5.657l9.56 9.56c0.755 0.755 1.76 1.172 2.828 1.173h0.003c1.068 0 2.072-0.416 2.833-1.179l14.451-14.668c0.743-0.753 1.153-1.751 1.153-2.809v-9.344c0-2.205-1.795-4-4-4zM29.333 13.344c0 0.353-0.137 0.685-0.385 0.937l-14.444 14.661c-0.252 0.252-0.587 0.391-0.941 0.391-0.001 0-0.001 0-0.001 0-0.356-0.001-0.691-0.139-0.943-0.392l-9.561-9.56c-0.52-0.52-0.52-1.365-0.005-1.88l14.667-14.449c0.253-0.248 0.585-0.385 0.937-0.385h9.344c0.736 0 1.333 0.597 1.333 1.333zM24 6.673c-0.737 0-1.333 0.604-1.333 1.341s0.596 1.333 1.333 1.333 1.333-0.596 1.333-1.333v-0.015c0-0.737-0.596-1.327-1.333-1.327z"></path>\n</svg>\n').replace(/\{name\}/g,e.name).replace(/\{url\}/g,e.urls.customer)}))))):void 0}render(){return s("salla-modal",{key:"bf6b6ebffa1fff9faf744913029ae4eb6f5ce499","has-skeleton":!0,"sub-title":this.offer_message,ref:e=>this.modal=e,isLoading:!0,class:`s-offer-modal-type-${this.offer_type?this.offer_type:""}`},s("div",{key:"4198a24f336464f9d17170385e4f2e07c66821de",slot:"loading"},s("div",{key:"7d59e8a5f9ee1bd4467d2b463c5901b1f01a11c2",class:"s-offer-modal-skeleton"},s("div",{key:"8139ef78f0d1f5dfe3ca4e00018f27ec7918944b",class:"s-offer-modal-skeleton-header"},s("salla-skeleton",{key:"173e58027399d3b3f73dadc2d7a0e7373de62e75",type:"circle",height:"80px",width:"80px"}),s("salla-skeleton",{key:"77b033d9834f5e9a35f94bd050a5fcb2147419a1",height:"15px",width:"50%"}),s("salla-skeleton",{key:"cdce462a5437dfc804582b115a1464ebfc6026dc",height:"10px",width:"30%"})),s("div",{key:"d9add56d0af01e12636f3bbf048a9b143c2874d0",class:"s-offer-modal-skeleton-items"},[...Array(3)].map((()=>s("div",{class:"s-offer-modal-skeleton-item"},s("salla-skeleton",{height:"9rem"}),s("div",{class:"s-offer-modal-skeleton-item-title"},s("salla-skeleton",{height:"15px",width:"100%"})),s("div",{class:"s-offer-modal-skeleton-item-subtitle"},s("salla-skeleton",{height:"9px",width:"50%"}),s("div",{innerHTML:'\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>cart2</title>\n<path d="M6.845 5.333l-1.905-5.333h-3.607c-0.736 0-1.333 0.597-1.333 1.333s0.597 1.333 1.333 1.333v0h1.727l5.72 16.012c0.569 1.56 2.039 2.654 3.765 2.655h12.133c0.001 0 0.002 0 0.003 0 1.825 0 3.364-1.222 3.845-2.892l0.007-0.028 3.161-13.080zM25.96 17.716c-0.167 0.554-0.672 0.951-1.27 0.951-0.002 0-0.005 0-0.007-0h-12.133c-0.575-0-1.065-0.364-1.252-0.875l-0.003-0.009-3.497-9.783h20.508zM13.333 24c-2.209 0-4 1.791-4 4s1.791 4 4 4c2.209 0 4-1.791 4-4v0c0-2.209-1.791-4-4-4v0zM13.333 29.333c-0.736 0-1.333-0.597-1.333-1.333s0.597-1.333 1.333-1.333c0.736 0 1.333 0.597 1.333 1.333v0c0 0.736-0.597 1.333-1.333 1.333v0zM24 24c-2.209 0-4 1.791-4 4s1.791 4 4 4c2.209 0 4-1.791 4-4v0c0-2.209-1.791-4-4-4v0zM24 29.333c-0.736 0-1.333-0.597-1.333-1.333s0.597-1.333 1.333-1.333c0.736 0 1.333 0.597 1.333 1.333v0c0 0.736-0.597 1.333-1.333 1.333v0z"></path>\n</svg>\n'})))))),s("div",{key:"d146a40cd8eedf5243fc40f713f19247fa7c7bbc",class:"s-offer-modal-skeleton-footer"},s("salla-skeleton",{key:"bcfd8d24a7a920f1a47751b1520f717fcbc954c4",height:"15px",width:"50%"}),s("salla-skeleton",{key:"04abbbe40c1c0fcafe3d3a287d556ea9258cfbd4",height:"15px",width:"30%"})))),this.hasError||null===this.offer?s("salla-placeholder",{class:"s-loyalty-placeholder",alignment:"center"},this.errorMessage?s("span",{slot:"description"},this.errorMessage):""):[s("span",{slot:"icon",class:"s-offer-modal-header-icon",innerHTML:a}),this.getOfferContent(),s("div",{class:"s-offer-modal-footer",slot:"footer"},this.offer.formatted_date?s("p",{class:"s-offer-modal-expiry"},salla.lang.get("pages.products.offer_expires_in")," ",this.offer.formatted_date):"",s("label",{class:"s-offer-modal-remember-label"},s("input",{type:"checkbox",onChange:e=>this.rememberMe(e),class:"s-offer-modal-remember-input"})," ",salla.lang.get("common.elements.remember_my_choice")))])}get host(){return t(this)}};l.style=".s-offer-modal-type-products .s-modal-body{min-height:690px;position:relative}";export{l as salla_offer_modal}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as e,h as t,H as r}from"./p-BQQ2x3w_.js";var s;!function(e){e.PERCENTAGE="percentage",e.FIXED="fixed"}(s||(s={}));const i={staticIcons:['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="40" height="40" color="#000000" fill="none">\n <path d="M13.7276 3.44418L15.4874 6.99288C15.7274 7.48687 16.3673 7.9607 16.9073 8.05143L20.0969 8.58575C22.1367 8.92853 22.6167 10.4206 21.1468 11.8925L18.6671 14.3927C18.2471 14.8161 18.0172 15.6327 18.1471 16.2175L18.8571 19.3125C19.417 21.7623 18.1271 22.71 15.9774 21.4296L12.9877 19.6452C12.4478 19.3226 11.5579 19.3226 11.0079 19.6452L8.01827 21.4296C5.8785 22.71 4.57865 21.7522 5.13859 19.3125L5.84851 16.2175C5.97849 15.6327 5.74852 14.8161 5.32856 14.3927L2.84884 11.8925C1.389 10.4206 1.85895 8.92853 3.89872 8.58575L7.08837 8.05143C7.61831 7.9607 8.25824 7.48687 8.49821 6.99288L10.258 3.44418C11.2179 1.51861 12.7777 1.51861 13.7276 3.44418Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>\n</svg>','<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" color="#000000" fill="none">\n <path d="M3 12C7.5 12 12 7.5 12 3C12 7.5 16.5 12 21 12C16.5 12 12 16.5 12 21C12 16.5 7.5 12 3 12Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"></path>\n <path d="M2 19.5C2.83333 19.5 4.5 17.8333 4.5 17C4.5 17.8333 6.16667 19.5 7 19.5C6.16667 19.5 4.5 21.1667 4.5 22C4.5 21.1667 2.83333 19.5 2 19.5Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"></path>\n <path d="M16 5C17 5 19 3 19 2C19 3 21 5 22 5C21 5 19 7 19 8C19 7 17 5 16 5Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"></path>\n</svg>','<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="40" height="40" color="#000000" fill="none">\n <path d="M14.2644 18.3717C14.5806 17.407 14.7387 16.9247 15.0616 16.593C15.215 16.4354 15.3932 16.3048 15.5887 16.2066C16.0003 16 16.5003 16 17.5002 16C18.5001 16 19.0001 16 19.4116 16.2066C19.6072 16.3048 19.7853 16.4354 19.9388 16.593C20.2617 16.9247 20.4198 17.407 20.736 18.3717L21.0624 19.3675C21.4561 20.5688 21.653 21.1694 21.3587 21.5847C21.0643 22 20.4418 22 19.1966 22H15.8038C14.5586 22 13.936 22 13.6417 21.5847C13.3473 21.1694 13.5442 20.5688 13.938 19.3675L14.2644 18.3717Z" stroke="currentColor" stroke-width="1.5"></path>\n <path d="M8.76421 10.3717C9.08041 9.40705 9.23851 8.92471 9.56143 8.59298C9.71485 8.43537 9.89299 8.3048 10.0885 8.20663C10.5001 8 11.0001 8 12 8C12.9999 8 13.4999 8 13.9115 8.20663C14.107 8.3048 14.2851 8.43537 14.4386 8.59298C14.7615 8.92471 14.9196 9.40705 15.2358 10.3717L15.5622 11.3675C15.956 12.5688 16.1528 13.1694 15.8585 13.5847C15.5642 14 14.9416 14 13.6964 14H10.3036C9.05842 14 8.43585 14 8.1415 13.5847C7.84716 13.1694 8.04404 12.5688 8.43779 11.3675L8.76421 10.3717Z" stroke="currentColor" stroke-width="1.5"></path>\n <path d="M3.26439 18.3717C3.58059 17.407 3.73869 16.9247 4.06162 16.593C4.21504 16.4354 4.39317 16.3048 4.58872 16.2066C5.00031 16 5.50027 16 6.50018 16C7.5001 16 8.00006 16 8.41165 16.2066C8.6072 16.3048 8.78533 16.4354 8.93875 16.593C9.26167 16.9247 9.41977 17.407 9.73597 18.3717L10.0624 19.3675C10.4561 20.5688 10.653 21.1694 10.3587 21.5847C10.0643 22 9.44176 22 8.19661 22H4.80375C3.5586 22 2.93603 22 2.64169 21.5847C2.34735 21.1694 2.54422 20.5688 2.93797 19.3675L3.26439 18.3717Z" stroke="currentColor" stroke-width="1.5"></path>\n <path d="M12 2V4M7.5 3.5L9 5M16.5 3.5L15 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path>\n</svg>','<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" color="#000000" fill="none">\n <path d="M5.78223 4.18192C6.43007 3.68319 6.754 3.43383 7.12788 3.27323C7.29741 3.20041 7.47367 3.14158 7.65459 3.09741C8.0536 3 8.4767 3 9.32289 3H14.6771C15.5233 3 15.9464 3 16.3454 3.09741C16.5263 3.14158 16.7026 3.20041 16.8721 3.27323C17.246 3.43383 17.5699 3.68319 18.2178 4.18192C20.3644 5.83448 21.4378 6.66077 21.8057 7.73078C21.9694 8.20673 22.0305 8.70728 21.9858 9.20461C21.8852 10.3227 21.0379 11.346 19.3433 13.3925L15.3498 18.2153C13.8126 20.0718 13.044 21 12 21C10.956 21 10.1874 20.0718 8.65018 18.2153L4.65671 13.3925C2.96208 11.346 2.11476 10.3227 2.0142 9.20461C1.96947 8.70728 2.03064 8.20673 2.1943 7.73078C2.56224 6.66077 3.63557 5.83448 5.78223 4.18192Z" stroke="currentColor" stroke-width="1.5"></path>\n <path d="M10 8.5H14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>\n</svg>'],staticColors:["#993018","#444444","#D18F36","#315F9C"]};class o{static findTierByIndex(e,t){return e.find((e=>e.index===t))||null}static findTierByName(e,t){return e.find((e=>e.tier_name===t))||null}static getTierNameByIndex(e,t){return this.findTierByIndex(e,t)?.tier_name}static findCurrentTierIndex(e,t){if(!t)return 0;for(let r=t.length-1;r>=0;r--)if(e>=t[r].threshold)return t[r].index;return 0}}const n=class{constructor(t){e(this,t),this.currentTierIndex=0,this.canRender=!1,this.isLoading=!1,this.handleTabClick=e=>{this.activeTabTier=e},salla.lang.onLoaded((()=>{this.loyaltyProgramText=salla.lang.get("blocks.tiered_offer.program_title"),this.currentTierText=salla.lang.get("blocks.tiered_offer.current_tier"),this.discountText=salla.lang.get("blocks.tiered_offer.discount"),this.benefitText=salla.lang.get("blocks.tiered_offer.tier_description")}))}async componentWillLoad(){try{if(await salla.onReady(),!this.checkFeatureEnabled())return;if(!this.checkCartExists())return;this.isLoading=!0;const e=await this.fetchTieredOfferData();if(!e)return;this.initializeComponent(e)}catch(e){this.canRender=!1,salla.logger.warn("salla-tiered-offer:: ",e)}finally{this.isLoading=!1}}checkFeatureEnabled(){return salla.config.get("store.features")?.includes("tiered-offer")}checkCartExists(){return!!salla.storage.get("cart")?.summary?.count}validateCouponCompatibility(e,t){return!(t&&!e.details?.applied_with_coupon)}async fetchTieredOfferData(){try{const{data:e}=await salla.api.cart.offers(),t=e.find((e=>"tiered_offer"===e.type));return t?this.validateCouponCompatibility(t,salla.storage.get("cart")?.coupon)?t:(this.canRender=!1,null):null}catch(e){throw e}}initializeComponent(e){this.apiOfferData=e,this.tieredOfferData=this.mapApiDataToTiers(this.apiOfferData),this.loyaltyProgramText=this.apiOfferData.title||this.loyaltyProgramText;const t=this.findCurrentTierIndex(this.apiOfferData.details?.current_value||0);0!==t?(this.currentTierIndex=t,this.currentTier=o.getTierNameByIndex(this.tieredOfferData.tiers,t),this.activeTabTier=this.currentTier,this.canRender=!0):this.canRender=!1}componentDidLoad(){salla.event.on("cart::updated",(async e=>{const t=await this.fetchTieredOfferData();t&&this.updateOfferValues(e,t)}))}mapApiDataToTiers(e){const t=[...e.details.discounts].sort(((e,t)=>e.min_spend-t.min_spend)).map(((e,t)=>({name:e.name,tier_name:e.name,discount:e.type===s.PERCENTAGE?`${salla.helpers.number(e.value)}%`:salla.money(e.value),icon:i.staticIcons[t]||i.staticIcons[0],threshold:e.min_spend,text_color:i.staticColors[t],index:t+1})));return{current_tier:o.getTierNameByIndex(t,this.findCurrentTierIndex(e.details.current_value,t)),tiers:t}}findCurrentTierIndex(e,t=this.tieredOfferData?.tiers){return o.findCurrentTierIndex(e,t||[])}updateOfferValues(e,t){if(!t||!this.tieredOfferData)return;if(!this.validateCouponCompatibility(t,e.coupon))return void(this.canRender=!1);if(this.canRender=!0,!1===t.details?.with_current_cart)return;const r=t.details?.current_value||0;this.apiOfferData=t;const s=this.findCurrentTierIndex(r);0!==s?(this.canRender=!0,this.currentTierIndex=s,this.currentTier=o.getTierNameByIndex(this.tieredOfferData.tiers,s),this.activeTabTier!==this.currentTier&&(this.activeTabTier=this.currentTier)):this.canRender=!1}getLoadingSkeletonView(){return t(r,null,t("div",{class:"s-tiered-offer-container"},t("div",{class:"s-tiered-offer-skeleton-wrapper"},t("div",{class:"s-tiered-offer-skeleton-title"},t("salla-skeleton",{height:"16px",width:"40%"})),t("div",{class:"s-tiered-offer-skeleton-subtitle"},t("salla-skeleton",{height:"20px",width:"60%"})),t("div",{class:"s-tiered-offer-skeleton-progress"},t("salla-skeleton",{height:"16px",width:"100%"})),t("div",{class:"s-tiered-offer-skeleton-tabs"},t("salla-skeleton",{height:"50px",width:"100%"})))))}getCurrentTierData(){return o.findTierByIndex(this.tieredOfferData.tiers,this.currentTierIndex)||this.tieredOfferData.tiers[0]}getProgressWidth(){const e=this.tieredOfferData.tiers.length;return this.findCurrentTierIndex(this.apiOfferData.details?.current_value||0)/e*100}calculateMilestonePosition(e,t){return 1===t?"calc(100% - 18px)":`${Math.max(2,Math.min(95,(e+1)/t*100-8/t))}%`}getMilestoneStyles(e,t,r){const s="rtl"===document.documentElement.dir,i=this.calculateMilestonePosition(t,r),o=e.name.length>6?"flex-end":"center";return{[s?"right":"left"]:i,alignItems:o,position:"absolute",transform:s?"translateX(50%)":"translateX(-50%)"}}getMilestoneIconStyles(e,t,r){return t?{color:e.text_color}:r?{color:"var(--color-primary)"}:{}}renderProgressBarBackground(e){return[t("div",{class:"s-tiered-offer-progress-bg"}),t("div",{class:"s-tiered-offer-progress-fill",style:{width:`${e}%`}})]}renderMilestoneIcon(e,r,s){const i=["s-tiered-offer-milestone-icon",r?"s-tiered-offer-milestone-active":"",s?"s-tiered-offer-milestone-completed":""].filter(Boolean).join(" ");return t("div",{class:i,style:this.getMilestoneIconStyles(e,r,s)},t("span",{innerHTML:e.icon}))}renderMilestoneName(e,r){return t("div",{class:"s-tiered-offer-milestone-name"},r&&t("span",{style:{color:e.text_color}},e.name))}renderMilestones(e,r){return t("div",{class:"s-tiered-offer-milestones-wrapper"},t("div",{class:1===r?"s-tiered-offer-single-milestone-justify-end":"s-tiered-offer-milestones"},this.tieredOfferData.tiers.map(((s,i)=>{const o=e>=s.threshold,n=s.tier_name===this.currentTier;return t("div",{class:"s-tiered-offer-milestone",style:this.getMilestoneStyles(s,i,r)},this.renderMilestoneIcon(s,n,o),this.renderMilestoneName(s,n))}))))}renderProgressBar(){const e=this.getProgressWidth(),r=this.tieredOfferData.tiers.length,s=this.apiOfferData.details?.current_value||0;return t("div",{class:"s-tiered-offer-progress-container"},t("div",{class:"s-tiered-offer-progress-wrapper"},this.renderProgressBarBackground(e),this.renderMilestones(s,r)))}renderTabs(){return t("div",{class:"s-tiered-offer-tabs-container"},t("div",{class:"s-tiered-offer-tab-headers"},this.tieredOfferData.tiers.map((e=>t("button",{class:"s-tiered-offer-tab-header "+(e.tier_name===this.activeTabTier?"s-tiered-offer-tab-active":""),onClick:()=>this.handleTabClick(e.tier_name)},t("span",null,e.name))))),t("div",{class:"s-tiered-offer-tab-content-wrapper"},(()=>{const e=o.findTierByName(this.tieredOfferData.tiers,this.activeTabTier);return e?t("div",{class:"s-tiered-offer-tab-content"},t("div",{class:"s-tiered-offer-tab-content-inner"},t("div",{class:"s-tiered-offer-discount-section"},t("p",{class:"s-tiered-offer-discount-title"},this.discountText," ",t("span",{innerHTML:e.discount})),t("p",{class:"s-tiered-offer-benefit-description"},this.benefitText," ",e.name)))):null})()))}render(){if(this.isLoading)return this.getLoadingSkeletonView();if(!this.canRender||!this.tieredOfferData)return null;const e=this.getCurrentTierData();return t(r,null,t("div",{class:"s-tiered-offer-container"},t("div",{class:"s-tiered-offer-header"},t("div",{class:"s-tiered-offer-header-content"},t("p",{class:"s-tiered-offer-program-title"},this.loyaltyProgramText),t("div",{class:"s-tiered-offer-current-tier-name-wrapper"},t("h2",{class:"s-tiered-offer-current-tier"},this.currentTierText," ",t("span",{class:"s-tiered-offer-tier-name"},e.name)),t("span",{innerHTML:e.icon})))),this.renderProgressBar(),this.renderTabs()))}};n.style=".s-tiered-offer-milestone-icon svg{color:currentColor}.s-tiered-offer-milestone-icon svg path{stroke:currentColor;fill:none}.s-tiered-offer-milestone-icon.s-tiered-offer-milestone-active svg path,.s-tiered-offer-milestone-icon.s-tiered-offer-milestone-completed svg path{fill:currentColor;stroke:none}.s-tiered-offer-milestone-icon.s-tiered-offer-milestone-active svg[fill=none] path,.s-tiered-offer-milestone-icon.s-tiered-offer-milestone-completed svg[fill=none] path{fill:none;stroke:currentColor}[dir=rtl] .s-tiered-offer-progress-wrapper .s-tiered-offer-progress-bg{transform:scaleX(-1)}[dir=rtl] .s-tiered-offer-progress-wrapper .s-tiered-offer-progress-fill{transform:scaleX(-1);left:auto}[dir=rtl] .flip-x{transform:scaleX(-1)}";export{n as salla_tiered_offer}
|
|
4
|
+
import{r as e,h as t,H as r}from"./p-DygKr0gG.js";var s;!function(e){e.PERCENTAGE="percentage",e.FIXED="fixed"}(s||(s={}));const i={staticIcons:['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="40" height="40" color="#000000" fill="none">\n <path d="M13.7276 3.44418L15.4874 6.99288C15.7274 7.48687 16.3673 7.9607 16.9073 8.05143L20.0969 8.58575C22.1367 8.92853 22.6167 10.4206 21.1468 11.8925L18.6671 14.3927C18.2471 14.8161 18.0172 15.6327 18.1471 16.2175L18.8571 19.3125C19.417 21.7623 18.1271 22.71 15.9774 21.4296L12.9877 19.6452C12.4478 19.3226 11.5579 19.3226 11.0079 19.6452L8.01827 21.4296C5.8785 22.71 4.57865 21.7522 5.13859 19.3125L5.84851 16.2175C5.97849 15.6327 5.74852 14.8161 5.32856 14.3927L2.84884 11.8925C1.389 10.4206 1.85895 8.92853 3.89872 8.58575L7.08837 8.05143C7.61831 7.9607 8.25824 7.48687 8.49821 6.99288L10.258 3.44418C11.2179 1.51861 12.7777 1.51861 13.7276 3.44418Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>\n</svg>','<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" color="#000000" fill="none">\n <path d="M3 12C7.5 12 12 7.5 12 3C12 7.5 16.5 12 21 12C16.5 12 12 16.5 12 21C12 16.5 7.5 12 3 12Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"></path>\n <path d="M2 19.5C2.83333 19.5 4.5 17.8333 4.5 17C4.5 17.8333 6.16667 19.5 7 19.5C6.16667 19.5 4.5 21.1667 4.5 22C4.5 21.1667 2.83333 19.5 2 19.5Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"></path>\n <path d="M16 5C17 5 19 3 19 2C19 3 21 5 22 5C21 5 19 7 19 8C19 7 17 5 16 5Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"></path>\n</svg>','<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="40" height="40" color="#000000" fill="none">\n <path d="M14.2644 18.3717C14.5806 17.407 14.7387 16.9247 15.0616 16.593C15.215 16.4354 15.3932 16.3048 15.5887 16.2066C16.0003 16 16.5003 16 17.5002 16C18.5001 16 19.0001 16 19.4116 16.2066C19.6072 16.3048 19.7853 16.4354 19.9388 16.593C20.2617 16.9247 20.4198 17.407 20.736 18.3717L21.0624 19.3675C21.4561 20.5688 21.653 21.1694 21.3587 21.5847C21.0643 22 20.4418 22 19.1966 22H15.8038C14.5586 22 13.936 22 13.6417 21.5847C13.3473 21.1694 13.5442 20.5688 13.938 19.3675L14.2644 18.3717Z" stroke="currentColor" stroke-width="1.5"></path>\n <path d="M8.76421 10.3717C9.08041 9.40705 9.23851 8.92471 9.56143 8.59298C9.71485 8.43537 9.89299 8.3048 10.0885 8.20663C10.5001 8 11.0001 8 12 8C12.9999 8 13.4999 8 13.9115 8.20663C14.107 8.3048 14.2851 8.43537 14.4386 8.59298C14.7615 8.92471 14.9196 9.40705 15.2358 10.3717L15.5622 11.3675C15.956 12.5688 16.1528 13.1694 15.8585 13.5847C15.5642 14 14.9416 14 13.6964 14H10.3036C9.05842 14 8.43585 14 8.1415 13.5847C7.84716 13.1694 8.04404 12.5688 8.43779 11.3675L8.76421 10.3717Z" stroke="currentColor" stroke-width="1.5"></path>\n <path d="M3.26439 18.3717C3.58059 17.407 3.73869 16.9247 4.06162 16.593C4.21504 16.4354 4.39317 16.3048 4.58872 16.2066C5.00031 16 5.50027 16 6.50018 16C7.5001 16 8.00006 16 8.41165 16.2066C8.6072 16.3048 8.78533 16.4354 8.93875 16.593C9.26167 16.9247 9.41977 17.407 9.73597 18.3717L10.0624 19.3675C10.4561 20.5688 10.653 21.1694 10.3587 21.5847C10.0643 22 9.44176 22 8.19661 22H4.80375C3.5586 22 2.93603 22 2.64169 21.5847C2.34735 21.1694 2.54422 20.5688 2.93797 19.3675L3.26439 18.3717Z" stroke="currentColor" stroke-width="1.5"></path>\n <path d="M12 2V4M7.5 3.5L9 5M16.5 3.5L15 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path>\n</svg>','<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" color="#000000" fill="none">\n <path d="M5.78223 4.18192C6.43007 3.68319 6.754 3.43383 7.12788 3.27323C7.29741 3.20041 7.47367 3.14158 7.65459 3.09741C8.0536 3 8.4767 3 9.32289 3H14.6771C15.5233 3 15.9464 3 16.3454 3.09741C16.5263 3.14158 16.7026 3.20041 16.8721 3.27323C17.246 3.43383 17.5699 3.68319 18.2178 4.18192C20.3644 5.83448 21.4378 6.66077 21.8057 7.73078C21.9694 8.20673 22.0305 8.70728 21.9858 9.20461C21.8852 10.3227 21.0379 11.346 19.3433 13.3925L15.3498 18.2153C13.8126 20.0718 13.044 21 12 21C10.956 21 10.1874 20.0718 8.65018 18.2153L4.65671 13.3925C2.96208 11.346 2.11476 10.3227 2.0142 9.20461C1.96947 8.70728 2.03064 8.20673 2.1943 7.73078C2.56224 6.66077 3.63557 5.83448 5.78223 4.18192Z" stroke="currentColor" stroke-width="1.5"></path>\n <path d="M10 8.5H14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>\n</svg>'],staticColors:["#993018","#444444","#D18F36","#315F9C"]};class o{static findTierByIndex(e,t){return e.find((e=>e.index===t))||null}static findTierByName(e,t){return e.find((e=>e.tier_name===t))||null}static getTierNameByIndex(e,t){return this.findTierByIndex(e,t)?.tier_name}static findCurrentTierIndex(e,t){if(!t)return 0;for(let r=t.length-1;r>=0;r--)if(e>=t[r].threshold)return t[r].index;return 0}}const n=class{constructor(t){e(this,t),this.currentTierIndex=0,this.canRender=!1,this.isLoading=!1,this.handleTabClick=e=>{this.activeTabTier=e},salla.lang.onLoaded((()=>{this.loyaltyProgramText=salla.lang.get("blocks.tiered_offer.program_title"),this.currentTierText=salla.lang.get("blocks.tiered_offer.current_tier"),this.discountText=salla.lang.get("blocks.tiered_offer.discount"),this.benefitText=salla.lang.get("blocks.tiered_offer.tier_description")}))}async componentWillLoad(){try{if(await salla.onReady(),!this.checkFeatureEnabled())return;if(!this.checkCartExists())return;this.isLoading=!0;const e=await this.fetchTieredOfferData();if(!e)return;this.initializeComponent(e)}catch(e){this.canRender=!1,salla.logger.warn("salla-tiered-offer:: ",e)}finally{this.isLoading=!1}}checkFeatureEnabled(){return salla.config.get("store.features")?.includes("tiered-offer")}checkCartExists(){return!!salla.storage.get("cart")?.summary?.count}validateCouponCompatibility(e,t){return!(t&&!e.details?.applied_with_coupon)}async fetchTieredOfferData(){try{const{data:e}=await salla.api.cart.offers(),t=e.find((e=>"tiered_offer"===e.type));return t?this.validateCouponCompatibility(t,salla.storage.get("cart")?.coupon)?t:(this.canRender=!1,null):null}catch(e){throw e}}initializeComponent(e){this.apiOfferData=e,this.tieredOfferData=this.mapApiDataToTiers(this.apiOfferData),this.loyaltyProgramText=this.apiOfferData.title||this.loyaltyProgramText;const t=this.findCurrentTierIndex(this.apiOfferData.details?.current_value||0);0!==t?(this.currentTierIndex=t,this.currentTier=o.getTierNameByIndex(this.tieredOfferData.tiers,t),this.activeTabTier=this.currentTier,this.canRender=!0):this.canRender=!1}componentDidLoad(){salla.event.on("cart::updated",(async e=>{const t=await this.fetchTieredOfferData();t&&this.updateOfferValues(e,t)}))}mapApiDataToTiers(e){const t=[...e.details.discounts].sort(((e,t)=>e.min_spend-t.min_spend)).map(((e,t)=>({name:e.name,tier_name:e.name,discount:e.type===s.PERCENTAGE?`${salla.helpers.number(e.value)}%`:salla.money(e.value),icon:i.staticIcons[t]||i.staticIcons[0],threshold:e.min_spend,text_color:i.staticColors[t],index:t+1})));return{current_tier:o.getTierNameByIndex(t,this.findCurrentTierIndex(e.details.current_value,t)),tiers:t}}findCurrentTierIndex(e,t=this.tieredOfferData?.tiers){return o.findCurrentTierIndex(e,t||[])}updateOfferValues(e,t){if(!t||!this.tieredOfferData)return;if(!this.validateCouponCompatibility(t,e.coupon))return void(this.canRender=!1);if(this.canRender=!0,!1===t.details?.with_current_cart)return;const r=t.details?.current_value||0;this.apiOfferData=t;const s=this.findCurrentTierIndex(r);0!==s?(this.canRender=!0,this.currentTierIndex=s,this.currentTier=o.getTierNameByIndex(this.tieredOfferData.tiers,s),this.activeTabTier!==this.currentTier&&(this.activeTabTier=this.currentTier)):this.canRender=!1}getLoadingSkeletonView(){return t(r,null,t("div",{class:"s-tiered-offer-container"},t("div",{class:"s-tiered-offer-skeleton-wrapper"},t("div",{class:"s-tiered-offer-skeleton-title"},t("salla-skeleton",{height:"16px",width:"40%"})),t("div",{class:"s-tiered-offer-skeleton-subtitle"},t("salla-skeleton",{height:"20px",width:"60%"})),t("div",{class:"s-tiered-offer-skeleton-progress"},t("salla-skeleton",{height:"16px",width:"100%"})),t("div",{class:"s-tiered-offer-skeleton-tabs"},t("salla-skeleton",{height:"50px",width:"100%"})))))}getCurrentTierData(){return o.findTierByIndex(this.tieredOfferData.tiers,this.currentTierIndex)||this.tieredOfferData.tiers[0]}getProgressWidth(){const e=this.tieredOfferData.tiers.length;return this.findCurrentTierIndex(this.apiOfferData.details?.current_value||0)/e*100}calculateMilestonePosition(e,t){return 1===t?"calc(100% - 18px)":`${Math.max(2,Math.min(95,(e+1)/t*100-8/t))}%`}getMilestoneStyles(e,t,r){const s="rtl"===document.documentElement.dir,i=this.calculateMilestonePosition(t,r),o=e.name.length>6?"flex-end":"center";return{[s?"right":"left"]:i,alignItems:o,position:"absolute",transform:s?"translateX(50%)":"translateX(-50%)"}}getMilestoneIconStyles(e,t,r){return t?{color:e.text_color}:r?{color:"var(--color-primary)"}:{}}renderProgressBarBackground(e){return[t("div",{class:"s-tiered-offer-progress-bg"}),t("div",{class:"s-tiered-offer-progress-fill",style:{width:`${e}%`}})]}renderMilestoneIcon(e,r,s){const i=["s-tiered-offer-milestone-icon",r?"s-tiered-offer-milestone-active":"",s?"s-tiered-offer-milestone-completed":""].filter(Boolean).join(" ");return t("div",{class:i,style:this.getMilestoneIconStyles(e,r,s)},t("span",{innerHTML:e.icon}))}renderMilestoneName(e,r){return t("div",{class:"s-tiered-offer-milestone-name"},r&&t("span",{style:{color:e.text_color}},e.name))}renderMilestones(e,r){return t("div",{class:"s-tiered-offer-milestones-wrapper"},t("div",{class:1===r?"s-tiered-offer-single-milestone-justify-end":"s-tiered-offer-milestones"},this.tieredOfferData.tiers.map(((s,i)=>{const o=e>=s.threshold,n=s.tier_name===this.currentTier;return t("div",{class:"s-tiered-offer-milestone",style:this.getMilestoneStyles(s,i,r)},this.renderMilestoneIcon(s,n,o),this.renderMilestoneName(s,n))}))))}renderProgressBar(){const e=this.getProgressWidth(),r=this.tieredOfferData.tiers.length,s=this.apiOfferData.details?.current_value||0;return t("div",{class:"s-tiered-offer-progress-container"},t("div",{class:"s-tiered-offer-progress-wrapper"},this.renderProgressBarBackground(e),this.renderMilestones(s,r)))}renderTabs(){return t("div",{class:"s-tiered-offer-tabs-container"},t("div",{class:"s-tiered-offer-tab-headers"},this.tieredOfferData.tiers.map((e=>t("button",{class:"s-tiered-offer-tab-header "+(e.tier_name===this.activeTabTier?"s-tiered-offer-tab-active":""),onClick:()=>this.handleTabClick(e.tier_name)},t("span",null,e.name))))),t("div",{class:"s-tiered-offer-tab-content-wrapper"},(()=>{const e=o.findTierByName(this.tieredOfferData.tiers,this.activeTabTier);return e?t("div",{class:"s-tiered-offer-tab-content"},t("div",{class:"s-tiered-offer-tab-content-inner"},t("div",{class:"s-tiered-offer-discount-section"},t("p",{class:"s-tiered-offer-discount-title"},this.discountText," ",t("span",{innerHTML:e.discount})),t("p",{class:"s-tiered-offer-benefit-description"},this.benefitText," ",e.name)))):null})()))}render(){if(this.isLoading)return this.getLoadingSkeletonView();if(!this.canRender||!this.tieredOfferData)return null;const e=this.getCurrentTierData();return t(r,null,t("div",{class:"s-tiered-offer-container"},t("div",{class:"s-tiered-offer-header"},t("div",{class:"s-tiered-offer-header-content"},t("p",{class:"s-tiered-offer-program-title"},this.loyaltyProgramText),t("div",{class:"s-tiered-offer-current-tier-name-wrapper"},t("h2",{class:"s-tiered-offer-current-tier"},this.currentTierText," ",t("span",{class:"s-tiered-offer-tier-name"},e.name)),t("span",{innerHTML:e.icon})))),this.renderProgressBar(),this.renderTabs()))}};n.style=".s-tiered-offer-milestone-icon svg{color:currentColor}.s-tiered-offer-milestone-icon svg path{stroke:currentColor;fill:none}.s-tiered-offer-milestone-icon.s-tiered-offer-milestone-active svg path,.s-tiered-offer-milestone-icon.s-tiered-offer-milestone-completed svg path{fill:currentColor;stroke:none}.s-tiered-offer-milestone-icon.s-tiered-offer-milestone-active svg[fill=none] path,.s-tiered-offer-milestone-icon.s-tiered-offer-milestone-completed svg[fill=none] path{fill:none;stroke:currentColor}[dir=rtl] .s-tiered-offer-progress-wrapper .s-tiered-offer-progress-bg{transform:scaleX(-1)}[dir=rtl] .s-tiered-offer-progress-wrapper .s-tiered-offer-progress-fill{transform:scaleX(-1);left:auto}[dir=rtl] .flip-x{transform:scaleX(-1)}";export{n as salla_tiered_offer}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as t,c as s,h as e,H as i,a as n}from"./p-BQQ2x3w_.js";import{A as o,a as l}from"./p-Vqpj4CWE.js";const a=class{constructor(e){t(this,e),this.optionsSaved=s(this,"optionsSaved"),this.productSelected=s(this,"productSelected"),this.product=null,this.sectionId=null,this.sectionIndex=0,this.productIndex=0,this.selectedOptions={},this.optionsResetTokens={},this.isLoading=!1,this.hasUnsavedChanges=!1,this.validationErrors=[]}generateCacheKey(t,s,e){return`${t||"unknown"}-${s||0}-${e||"unknown"}`}handleProductChange(t){setTimeout((()=>{this.modal&&t&&this.modal.setTitle(t.name||"")}),100),this.validationErrors=[],this.hasUnsavedChanges=!1}async open(){this.modal?(this.isLoading=!0,this.product?.name&&this.modal.setTitle(this.product.name),this.modal.open(),setTimeout((async()=>{this.product?.id&&await this.initializeSelectedOptions(),this.product?.name&&this.modal.setTitle(this.product.name),this.modal.stopLoading(),this.isLoading=!1}),300)):requestAnimationFrame((()=>this.open()))}async close(){this.modal&&this.modal.close()}async refreshOptionsState(){this.selectedOptions={...this.selectedOptions}}componentDidLoad(){this.modalOpenListener=t=>{this.product=t.product,this.sectionId=t.sectionId||null,this.sectionIndex=t.sectionIndex||0,this.productIndex=t.productIndex||0,this.open()},salla.event.on("multiple-bundle-product-modal::open",this.modalOpenListener),this.clearOptionsListener=t=>{t&&t.productId&&this.clearProductOptions(t.productId,t.sectionId,t.productIndex)},salla.event.on("multiple-bundle-product-modal::clear-options",this.clearOptionsListener),this.optionChangeListener=t=>{const s=t.detail||t,{option:e,detail:i}=s,n=e||s.option_id&&this.product?.options?.find((t=>t.id===s.option_id||String(t.id)===String(s.option_id))),o=i||(s.id?s:null);this.product?.id&&n&&this.handleOptionChange(Number(this.product.id),n,o)},salla.event.on("product-options::change",this.optionChangeListener),this.checkboxChangeListener=t=>{const s=t.target;if(s&&"checkbox"===s.type&&s.name&&s.name.includes("bundle[")&&s.name.includes("][id]")){const t=s.name.match(/^bundle\[([^\]]+)\]\[([^\]]+)\]\[id\]$/);if(t&&!s.checked){const[,e,i]=t,n=s.value,o=this.host.closest("form");this.cleanupProductDeselection({sectionId:e,productIndex:parseInt(i,10),productId:n,form:o,uncheckedInput:s})}}},document.addEventListener("change",this.checkboxChangeListener)}disconnectedCallback(){this.checkboxChangeListener&&document.removeEventListener("change",this.checkboxChangeListener),this.optionChangeListener&&salla.event.off("product-options::change",this.optionChangeListener),this.modalOpenListener&&salla.event.off("multiple-bundle-product-modal::open",this.modalOpenListener),this.clearOptionsListener&&salla.event.off("multiple-bundle-product-modal::clear-options",this.clearOptionsListener)}cleanupProductDeselection(t){const{sectionId:s,productIndex:e,productId:i,form:n,uncheckedInput:o}=t;if(this.clearProductOptions(i,s,e),n){const t=`bundle[${s}][${e}]`;Array.from(n.querySelectorAll(`input[name^="${t}"]`)).forEach((s=>{if(s===o)return;const e="hidden"===s.type,n=s.getAttribute("data-product-id")===String(i)&&s.name?.startsWith(t);(e||n)&&s.remove()})),requestAnimationFrame((()=>{const t=new window.Event("change",{bubbles:!0});n.dispatchEvent(t)}))}}generateFormInputName(t,s,e){return`bundle[${t}][${s}][options][${e}]`}async initializeSelectedOptions(){if(!this.product?.id)return;const t=this.product.id,s=this.generateCacheKey(this.sectionId,this.productIndex,t),e=document.querySelector(`salla-product-options[product-id="${t}"]`);if(e)try{const t=await e.getSelectedOptions();t&&t.length>0&&(this.selectedOptions={...this.selectedOptions,[s]:t})}catch(t){console.warn("Could not initialize selected options:",t)}}clearProductOptions(t,s,e){const i={...this.selectedOptions};if(null==s||null==e||Number.isNaN(e)){const s=`-${String(t)}`,e=[];Object.keys(i).forEach((t=>{t.endsWith(s)&&(delete i[t],e.push(t))})),e.forEach((t=>this.bumpOptionsResetToken(t)))}else{const n=this.generateCacheKey(s,e,t);delete i[n],this.bumpOptionsResetToken(n)}this.selectedOptions=i,this.validationErrors=[],this.hasUnsavedChanges=!1}bumpOptionsResetToken(t){t&&(this.optionsResetTokens={...this.optionsResetTokens,[t]:(this.optionsResetTokens[t]||0)+1})}async handleOptionChange(t,s,e){const i=this.generateCacheKey(this.sectionId,this.productIndex,t),n=document.querySelector(`salla-product-options[product-id="${t}"]`);let o=[];if(n)try{o=await n.getSelectedOptions()||[]}catch(t){console.warn("Could not get current selections from component:",t)}if(o.length>0)this.selectedOptions={...this.selectedOptions,[i]:o};else if(this.selectedOptions[i]&&this.selectedOptions[i].length>0){const t=[...this.selectedOptions[i]||[]],n=t.findIndex((t=>t.option_id===s.id));n>-1?e&&null!=e.id?t[n]={...e,option_id:s.id}:t.splice(n,1):e&&null!=e.id&&t.push({...e,option_id:s.id}),this.selectedOptions={...this.selectedOptions,[i]:t}}else e&&null!=e.id&&(this.selectedOptions={...this.selectedOptions,[i]:[{...e,option_id:s.id}]});this.hasUnsavedChanges=!0,this.validationErrors=[]}async validateOptions(){if(!this.product?.options)return!0;const t=[],s=this.product.id,e=this.generateCacheKey(this.sectionId,this.productIndex,s),i=document.querySelector(`salla-product-options[product-id="${s}"]`);let n=[];if(i)try{n=await i.getSelectedOptions()||[];const t=this.selectedOptions[e]||[];(t.length>n.length||0===n.length&&t.length>0)&&(n=t)}catch(t){n=this.selectedOptions[e]||[]}else n=this.selectedOptions[e]||[];return 0===n.length&&t.push(salla.lang.get("pages.products.no_options_selected")),this.product.options.forEach((s=>{s.required&&(n.some((t=>t.option_id==s.id))||t.push(salla.lang.get("pages.products.required_option_missing",{option:s.name})))})),this.validationErrors=t,0===t.length}async onSave(t){t.preventDefault();const s=this.product?.id;if(!s)return;const e=this.generateCacheKey(this.sectionId,this.productIndex,s);if(await new Promise((t=>setTimeout(t,100))),await this.validateOptions()){this.isLoading=!0;try{const t=document.querySelector(`salla-product-options[product-id="${s}"]`);let i=await(t?.getSelectedOptions());if((!i||0===i.length)&&this.selectedOptions[e]?.length>0&&(i=this.selectedOptions[e]),!i||0===i.length)return void(this.isLoading=!1);this.selectedOptions={...this.selectedOptions,[e]:i};const n=this.host.closest("form");if(!n)return void(this.isLoading=!1);const o=`bundle[${this.sectionId}][${this.productIndex}]`;Array.from(n.querySelectorAll(`input[name^="${o}"][type="hidden"]`)).forEach((t=>t.remove())),Array.from(n.querySelectorAll(`[data-product-id="${s}"][name^="${o}"]`)).forEach((t=>t.remove()));const l=`bundle[${this.sectionId}][${this.productIndex}][id]`,a=document.getElementById(l);if(a)a.checked=!0;else{const t=document.createElement("input");t.type="hidden",t.name=`bundle[${this.sectionId}][${this.productIndex}][id]`,t.value=String(s),t.dataset.productId=String(s),n.appendChild(t)}i.forEach((t=>{const e=t.option_id,i=document.createElement("input");i.type="hidden",i.name=this.generateFormInputName(this.sectionId,this.productIndex??0,e),i.value=String(t.id),i.dataset.productId=String(s),n.appendChild(i)}));const d=new window.Event("change",{bubbles:!0});n.dispatchEvent(d),this.optionsSaved.emit({productId:Number(s),selectedOptions:i,sectionId:this.sectionId,productIndex:this.productIndex}),this.sectionId&&this.productSelected.emit({productId:Number(s),sectionId:this.sectionId,product:this.product,fromModal:!0}),salla.notify.success(salla.lang.get("pages.products.options_saved")),this.hasUnsavedChanges=!1,this.validationErrors=[],this.modal.close()}catch(t){salla.notify.error(salla.lang.get("pages.products.options_save_error"))}finally{this.isLoading=!1}}else salla.notify.error(this.validationErrors.join(", "))}getOptionsWithSelectedState(){if(!this.product?.options)return[];const t=this.generateCacheKey(this.sectionId,this.productIndex,this.product.id),s=this.selectedOptions[t]||[];return this.product.options.map((t=>({...t,details:t.details.map((t=>{const e=s.some((s=>s.id===t.id));return{...t,is_selected:e}}))})))}render(){const t=this.product?.id,s=this.getOptionsWithSelectedState(),n=this.generateCacheKey(this.sectionId,this.productIndex,t),o=this.optionsResetTokens[n]||0,l=this.isLoading||s.some((t=>t.details.some((t=>t.is_selected&&!0===t.is_out))));return e(i,{key:"357005ce9302183eeeec3238ebde74b99c5f7d88"},e("salla-modal",{key:"95e4f37061229e8359a269b031942d507a43ea25",isLoading:this.isLoading,ref:t=>this.modal=t,width:"md",centered:!1,id:`s-multiple-bundle-product-options-modal-options-${t}`,class:"s-multiple-bundle-product-options-modal-wrapper"},e("div",{key:"b1525824f938c5af85a9ca043d2acf86e8773e6a",slot:"loading"},e("salla-skeleton",{key:"7e71698646e7ec119afbed2fca9dab79c4fe2991",height:"100%",width:"100%"})),this.product?.images&&this.product?.images.length>0&&e("salla-slider",{key:"cd9042d00b0a237afd8dfe7ad4ed7032e298eb39",id:`details-slider-${this.product?.id}`,type:"thumbs",loop:!1,"auto-height":!0,"listen-to-thumbnails-option":!0,showThumbsControls:!1,controlsOuter:!1,showControls:!1,class:"s-multiple-bundle-product-options-modal-slider",verticalThumbs:!0,thumbsConfig:{centeredSlides:!0,centeredSlidesBounds:!0,slidesPerView:Math.min(5,Math.max(1,this.product?.images.length)),watchOverflow:!0,watchSlidesProgress:!0,direction:"vertical",spaceBetween:10}},e("div",{key:"81773392ee6167f0daf780637e15bef9b7b2f2c7",slot:"items"},this.product?.images&&this.product?.images.map(((t,s)=>e("div",{key:s,class:"swiper-slide"},e("img",{src:t.url,alt:t.alt||`${this.product?.name} - Image ${s+1}`,loading:"lazy",onError:t=>{t.target.style.display="none"}}))))),this.product?.images&&this.product?.images.length>1&&e("div",{key:"2942ab32e0e28e6213b2a1d177e36c84136beaef",slot:"thumbs"},this.product?.images&&this.product?.images.map(((t,s)=>e("div",{key:s,"data-caption":`${this.product?.name} - Image ${s+1}`},e("img",{src:t.url,loading:"eager",class:"s-multiple-bundle-product-options-modal-slider-thumb",title:`${this.product?.name} - ${s+1}`,alt:t.alt||`${this.product?.name} - ${s+1}`,onError:t=>{t.target.style.display="none"}})))))),e("salla-product-options",{options:JSON.stringify(s),key:`${n}-reset-${o}`,"product-id":t,"unique-key":`${n}-reset-${o}`}),e("div",{key:"e3658d39d7462e1ba8c2099625d9a659541f6b2a",slot:"footer"},e("div",{key:"8e03e9230c55b9ac6143e37629946e66daf47835",class:"s-multiple-bundle-product-options-modal-footer"},e("salla-button",{key:"feca5790f828f7b29de3cba4e3a54d772a7a94c5",onClick:t=>this.onSave(t),loading:this.isLoading,disabled:l},this.isLoading?salla.lang.get("common.elements.saving"):salla.lang.get("common.elements.save"))))))}get host(){return n(this)}static get watchers(){return{product:["handleProductChange"]}}};a.style=":host{display:block}";const d=class{constructor(e){t(this,e),this.productSelected=s(this,"productSelected"),this.productOptionsSelected=s(this,"productOptionsSelected"),this.selectedProducts={},this.savedOptionsByInstance={},this.handleProductClick=(t,s)=>{const e=this.generateEventName(this.section.id,s),i=document.getElementById(e);if(i){if(i){const e=!i.checked;e||(this.dispatchClearOptionsEvent(t,s),this.clearSavedOptionsState(this.section.id,s)),i.checked=e,requestAnimationFrame((()=>{const t=new window.Event("change",{bubbles:!0});i.dispatchEvent(t)}))}this.productSelected.emit({product:t,sectionId:this.section.id})}},this.handleOptionsClick=t=>{this.productOptionsSelected.emit({product:t,sectionId:this.section.id})}}getProductInstanceKey(t,s){return`${t}::${s}`}dispatchClearOptionsEvent(t,s){salla.event.dispatch("multiple-bundle-product-modal::clear-options",{productId:t.id,sectionId:this.section.id,sectionIndex:this.sectionIndex,productIndex:s})}handleOptionsSaved(t){const s=t.detail;if(!s)return;const{sectionId:e,productIndex:i,selectedOptions:n}=s;if(null==e||e!==this.section?.id)return;if(null==i||Number.isNaN(i))return;const o=this.getProductInstanceKey(e,i);if(n?.length)this.savedOptionsByInstance={...this.savedOptionsByInstance,[o]:!0};else if(this.savedOptionsByInstance[o]){const t={...this.savedOptionsByInstance};delete t[o],this.savedOptionsByInstance=t}}clearSavedOptionsState(t,s){const e=this.getProductInstanceKey(t,s);if(!this.savedOptionsByInstance[e])return;const i={...this.savedOptionsByInstance};delete i[e],this.savedOptionsByInstance=i}generateEventName(t,s){return`bundle[${t}][${s}][id]`}render(){return e(i,{key:"336a3bcf504a178ee207b40b3b7fac5d26e00f91"},e("salla-slider",{key:"004d1c3f644bfd015efe2ffc21a78e912c5d0647",type:"carousel",controlsOuter:!1,showControls:!1,id:`accordion-multiple-bundle-product-${this.section.id}`,pagination:!0,class:"s-multiple-bundle-product-wrapper-slider",sliderConfig:{spaceBetween:0}},e("div",{key:"fda4544764b9bf2eb95d408179c1abc252f50243",slot:"items"},this?.section?.products?.map(((t,s)=>{const i=this.selectedProducts[this.section.id]?.has(t.id)||!1,n=this.savedOptionsByInstance[this.getProductInstanceKey(this.section.id,s)]?salla.lang.getWithDefault("pages.products.edit_selected_options","تعديل الخيارات"):salla.lang.get("pages.products.choose_from_options");let a=salla.config.get("theme.is_rtl",!0)?o:l;return e("div",{class:"s-multiple-bundle-product-slide-one-third "+(0==t.quantity?"s-multiple-bundle-product-slide-one-third-disabled":""),key:t.id},e("div",{class:"s-multiple-bundle-product-card"},e("div",{class:"s-multiple-bundle-product-image-wrapper",onClick:()=>this.handleProductClick(t,s)},e("input",{id:this.generateEventName(this.section.id,s),type:"checkbox",class:"s-multiple-bundle-product-checkbox",checked:i,name:this.generateEventName(this.section.id,s),value:t.id}),e("img",{src:t.image.url||salla.url.cdn("images/s-empty.png"),loading:"lazy",alt:t.image.alt||t.name,class:"s-multiple-bundle-product-image"})),e("div",{class:"s-multiple-bundle-product-content-wrapper"},e("div",{class:"s-multiple-bundle-product-content"},e("div",{class:"s-multiple-bundle-product-details"},e("div",{class:"s-multiple-bundle-product-title-wrapper"},e("h2",{class:"s-multiple-bundle-product-title"},e("a",{href:t?.url||"#",target:"_blank",rel:"noopener noreferrer"},t.name))),e("div",{class:"s-multiple-bundle-product-price-wrapper"},e("span",{class:"s-multiple-bundle-product-price"},e("span",{innerHTML:salla.money(t.price)})),t.sale_price>0&&e("span",{class:"s-multiple-bundle-product-price-discount"},e("span",{innerHTML:salla.money(t.regular_price)})))),t.quantity_in_group>0&&0!==t.quantity&&e("span",{class:"s-multiple-bundle-product-badge"},salla.lang.get("pages.products.pieces"),e("span",null,t.quantity_in_group)),0===t.quantity&&e("span",{class:"s-multiple-bundle-product-badge"},salla.lang.get("pages.products.quantity_in_group_finished"))),t.options?.length>0&&e("button",{class:"s-multiple-bundle-product-button",onClick:()=>this.handleOptionsClick(t),type:"button"},n,e("span",{class:"s-multiple-bundle-product-button-icon",innerHTML:a})))))})))))}get host(){return n(this)}};d.style="";export{a as salla_multiple_bundle_product_options_modal,d as salla_multiple_bundle_product_slider}
|
|
4
|
+
import{r as t,c as s,h as e,H as i,a as n}from"./p-DygKr0gG.js";import{A as o,a as l}from"./p-Vqpj4CWE.js";const a=class{constructor(e){t(this,e),this.optionsSaved=s(this,"optionsSaved"),this.productSelected=s(this,"productSelected"),this.product=null,this.sectionId=null,this.sectionIndex=0,this.productIndex=0,this.selectedOptions={},this.optionsResetTokens={},this.isLoading=!1,this.hasUnsavedChanges=!1,this.validationErrors=[]}generateCacheKey(t,s,e){return`${t||"unknown"}-${s||0}-${e||"unknown"}`}handleProductChange(t){setTimeout((()=>{this.modal&&t&&this.modal.setTitle(t.name||"")}),100),this.validationErrors=[],this.hasUnsavedChanges=!1}async open(){this.modal?(this.isLoading=!0,this.product?.name&&this.modal.setTitle(this.product.name),this.modal.open(),setTimeout((async()=>{this.product?.id&&await this.initializeSelectedOptions(),this.product?.name&&this.modal.setTitle(this.product.name),this.modal.stopLoading(),this.isLoading=!1}),300)):requestAnimationFrame((()=>this.open()))}async close(){this.modal&&this.modal.close()}async refreshOptionsState(){this.selectedOptions={...this.selectedOptions}}componentDidLoad(){this.modalOpenListener=t=>{this.product=t.product,this.sectionId=t.sectionId||null,this.sectionIndex=t.sectionIndex||0,this.productIndex=t.productIndex||0,this.open()},salla.event.on("multiple-bundle-product-modal::open",this.modalOpenListener),this.clearOptionsListener=t=>{t&&t.productId&&this.clearProductOptions(t.productId,t.sectionId,t.productIndex)},salla.event.on("multiple-bundle-product-modal::clear-options",this.clearOptionsListener),this.optionChangeListener=t=>{const s=t.detail||t,{option:e,detail:i}=s,n=e||s.option_id&&this.product?.options?.find((t=>t.id===s.option_id||String(t.id)===String(s.option_id))),o=i||(s.id?s:null);this.product?.id&&n&&this.handleOptionChange(Number(this.product.id),n,o)},salla.event.on("product-options::change",this.optionChangeListener),this.checkboxChangeListener=t=>{const s=t.target;if(s&&"checkbox"===s.type&&s.name&&s.name.includes("bundle[")&&s.name.includes("][id]")){const t=s.name.match(/^bundle\[([^\]]+)\]\[([^\]]+)\]\[id\]$/);if(t&&!s.checked){const[,e,i]=t,n=s.value,o=this.host.closest("form");this.cleanupProductDeselection({sectionId:e,productIndex:parseInt(i,10),productId:n,form:o,uncheckedInput:s})}}},document.addEventListener("change",this.checkboxChangeListener)}disconnectedCallback(){this.checkboxChangeListener&&document.removeEventListener("change",this.checkboxChangeListener),this.optionChangeListener&&salla.event.off("product-options::change",this.optionChangeListener),this.modalOpenListener&&salla.event.off("multiple-bundle-product-modal::open",this.modalOpenListener),this.clearOptionsListener&&salla.event.off("multiple-bundle-product-modal::clear-options",this.clearOptionsListener)}cleanupProductDeselection(t){const{sectionId:s,productIndex:e,productId:i,form:n,uncheckedInput:o}=t;if(this.clearProductOptions(i,s,e),n){const t=`bundle[${s}][${e}]`;Array.from(n.querySelectorAll(`input[name^="${t}"]`)).forEach((s=>{if(s===o)return;const e="hidden"===s.type,n=s.getAttribute("data-product-id")===String(i)&&s.name?.startsWith(t);(e||n)&&s.remove()})),requestAnimationFrame((()=>{const t=new window.Event("change",{bubbles:!0});n.dispatchEvent(t)}))}}generateFormInputName(t,s,e){return`bundle[${t}][${s}][options][${e}]`}async initializeSelectedOptions(){if(!this.product?.id)return;const t=this.product.id,s=this.generateCacheKey(this.sectionId,this.productIndex,t),e=document.querySelector(`salla-product-options[product-id="${t}"]`);if(e)try{const t=await e.getSelectedOptions();t&&t.length>0&&(this.selectedOptions={...this.selectedOptions,[s]:t})}catch(t){console.warn("Could not initialize selected options:",t)}}clearProductOptions(t,s,e){const i={...this.selectedOptions};if(null==s||null==e||Number.isNaN(e)){const s=`-${String(t)}`,e=[];Object.keys(i).forEach((t=>{t.endsWith(s)&&(delete i[t],e.push(t))})),e.forEach((t=>this.bumpOptionsResetToken(t)))}else{const n=this.generateCacheKey(s,e,t);delete i[n],this.bumpOptionsResetToken(n)}this.selectedOptions=i,this.validationErrors=[],this.hasUnsavedChanges=!1}bumpOptionsResetToken(t){t&&(this.optionsResetTokens={...this.optionsResetTokens,[t]:(this.optionsResetTokens[t]||0)+1})}async handleOptionChange(t,s,e){const i=this.generateCacheKey(this.sectionId,this.productIndex,t),n=document.querySelector(`salla-product-options[product-id="${t}"]`);let o=[];if(n)try{o=await n.getSelectedOptions()||[]}catch(t){console.warn("Could not get current selections from component:",t)}if(o.length>0)this.selectedOptions={...this.selectedOptions,[i]:o};else if(this.selectedOptions[i]&&this.selectedOptions[i].length>0){const t=[...this.selectedOptions[i]||[]],n=t.findIndex((t=>t.option_id===s.id));n>-1?e&&null!=e.id?t[n]={...e,option_id:s.id}:t.splice(n,1):e&&null!=e.id&&t.push({...e,option_id:s.id}),this.selectedOptions={...this.selectedOptions,[i]:t}}else e&&null!=e.id&&(this.selectedOptions={...this.selectedOptions,[i]:[{...e,option_id:s.id}]});this.hasUnsavedChanges=!0,this.validationErrors=[]}async validateOptions(){if(!this.product?.options)return!0;const t=[],s=this.product.id,e=this.generateCacheKey(this.sectionId,this.productIndex,s),i=document.querySelector(`salla-product-options[product-id="${s}"]`);let n=[];if(i)try{n=await i.getSelectedOptions()||[];const t=this.selectedOptions[e]||[];(t.length>n.length||0===n.length&&t.length>0)&&(n=t)}catch(t){n=this.selectedOptions[e]||[]}else n=this.selectedOptions[e]||[];return 0===n.length&&t.push(salla.lang.get("pages.products.no_options_selected")),this.product.options.forEach((s=>{s.required&&(n.some((t=>t.option_id==s.id))||t.push(salla.lang.get("pages.products.required_option_missing",{option:s.name})))})),this.validationErrors=t,0===t.length}async onSave(t){t.preventDefault();const s=this.product?.id;if(!s)return;const e=this.generateCacheKey(this.sectionId,this.productIndex,s);if(await new Promise((t=>setTimeout(t,100))),await this.validateOptions()){this.isLoading=!0;try{const t=document.querySelector(`salla-product-options[product-id="${s}"]`);let i=await(t?.getSelectedOptions());if((!i||0===i.length)&&this.selectedOptions[e]?.length>0&&(i=this.selectedOptions[e]),!i||0===i.length)return void(this.isLoading=!1);this.selectedOptions={...this.selectedOptions,[e]:i};const n=this.host.closest("form");if(!n)return void(this.isLoading=!1);const o=`bundle[${this.sectionId}][${this.productIndex}]`;Array.from(n.querySelectorAll(`input[name^="${o}"][type="hidden"]`)).forEach((t=>t.remove())),Array.from(n.querySelectorAll(`[data-product-id="${s}"][name^="${o}"]`)).forEach((t=>t.remove()));const l=`bundle[${this.sectionId}][${this.productIndex}][id]`,a=document.getElementById(l);if(a)a.checked=!0;else{const t=document.createElement("input");t.type="hidden",t.name=`bundle[${this.sectionId}][${this.productIndex}][id]`,t.value=String(s),t.dataset.productId=String(s),n.appendChild(t)}i.forEach((t=>{const e=t.option_id,i=document.createElement("input");i.type="hidden",i.name=this.generateFormInputName(this.sectionId,this.productIndex??0,e),i.value=String(t.id),i.dataset.productId=String(s),n.appendChild(i)}));const d=new window.Event("change",{bubbles:!0});n.dispatchEvent(d),this.optionsSaved.emit({productId:Number(s),selectedOptions:i,sectionId:this.sectionId,productIndex:this.productIndex}),this.sectionId&&this.productSelected.emit({productId:Number(s),sectionId:this.sectionId,product:this.product,fromModal:!0}),salla.notify.success(salla.lang.get("pages.products.options_saved")),this.hasUnsavedChanges=!1,this.validationErrors=[],this.modal.close()}catch(t){salla.notify.error(salla.lang.get("pages.products.options_save_error"))}finally{this.isLoading=!1}}else salla.notify.error(this.validationErrors.join(", "))}getOptionsWithSelectedState(){if(!this.product?.options)return[];const t=this.generateCacheKey(this.sectionId,this.productIndex,this.product.id),s=this.selectedOptions[t]||[];return this.product.options.map((t=>({...t,details:t.details.map((t=>{const e=s.some((s=>s.id===t.id));return{...t,is_selected:e}}))})))}render(){const t=this.product?.id,s=this.getOptionsWithSelectedState(),n=this.generateCacheKey(this.sectionId,this.productIndex,t),o=this.optionsResetTokens[n]||0,l=this.isLoading||s.some((t=>t.details.some((t=>t.is_selected&&!0===t.is_out))));return e(i,{key:"357005ce9302183eeeec3238ebde74b99c5f7d88"},e("salla-modal",{key:"95e4f37061229e8359a269b031942d507a43ea25",isLoading:this.isLoading,ref:t=>this.modal=t,width:"md",centered:!1,id:`s-multiple-bundle-product-options-modal-options-${t}`,class:"s-multiple-bundle-product-options-modal-wrapper"},e("div",{key:"b1525824f938c5af85a9ca043d2acf86e8773e6a",slot:"loading"},e("salla-skeleton",{key:"7e71698646e7ec119afbed2fca9dab79c4fe2991",height:"100%",width:"100%"})),this.product?.images&&this.product?.images.length>0&&e("salla-slider",{key:"cd9042d00b0a237afd8dfe7ad4ed7032e298eb39",id:`details-slider-${this.product?.id}`,type:"thumbs",loop:!1,"auto-height":!0,"listen-to-thumbnails-option":!0,showThumbsControls:!1,controlsOuter:!1,showControls:!1,class:"s-multiple-bundle-product-options-modal-slider",verticalThumbs:!0,thumbsConfig:{centeredSlides:!0,centeredSlidesBounds:!0,slidesPerView:Math.min(5,Math.max(1,this.product?.images.length)),watchOverflow:!0,watchSlidesProgress:!0,direction:"vertical",spaceBetween:10}},e("div",{key:"81773392ee6167f0daf780637e15bef9b7b2f2c7",slot:"items"},this.product?.images&&this.product?.images.map(((t,s)=>e("div",{key:s,class:"swiper-slide"},e("img",{src:t.url,alt:t.alt||`${this.product?.name} - Image ${s+1}`,loading:"lazy",onError:t=>{t.target.style.display="none"}}))))),this.product?.images&&this.product?.images.length>1&&e("div",{key:"2942ab32e0e28e6213b2a1d177e36c84136beaef",slot:"thumbs"},this.product?.images&&this.product?.images.map(((t,s)=>e("div",{key:s,"data-caption":`${this.product?.name} - Image ${s+1}`},e("img",{src:t.url,loading:"eager",class:"s-multiple-bundle-product-options-modal-slider-thumb",title:`${this.product?.name} - ${s+1}`,alt:t.alt||`${this.product?.name} - ${s+1}`,onError:t=>{t.target.style.display="none"}})))))),e("salla-product-options",{options:JSON.stringify(s),key:`${n}-reset-${o}`,"product-id":t,"unique-key":`${n}-reset-${o}`}),e("div",{key:"e3658d39d7462e1ba8c2099625d9a659541f6b2a",slot:"footer"},e("div",{key:"8e03e9230c55b9ac6143e37629946e66daf47835",class:"s-multiple-bundle-product-options-modal-footer"},e("salla-button",{key:"feca5790f828f7b29de3cba4e3a54d772a7a94c5",onClick:t=>this.onSave(t),loading:this.isLoading,disabled:l},this.isLoading?salla.lang.get("common.elements.saving"):salla.lang.get("common.elements.save"))))))}get host(){return n(this)}static get watchers(){return{product:["handleProductChange"]}}};a.style=":host{display:block}";const d=class{constructor(e){t(this,e),this.productSelected=s(this,"productSelected"),this.productOptionsSelected=s(this,"productOptionsSelected"),this.selectedProducts={},this.savedOptionsByInstance={},this.handleProductClick=(t,s)=>{const e=this.generateEventName(this.section.id,s),i=document.getElementById(e);if(i){if(i){const e=!i.checked;e||(this.dispatchClearOptionsEvent(t,s),this.clearSavedOptionsState(this.section.id,s)),i.checked=e,requestAnimationFrame((()=>{const t=new window.Event("change",{bubbles:!0});i.dispatchEvent(t)}))}this.productSelected.emit({product:t,sectionId:this.section.id})}},this.handleOptionsClick=t=>{this.productOptionsSelected.emit({product:t,sectionId:this.section.id})}}getProductInstanceKey(t,s){return`${t}::${s}`}dispatchClearOptionsEvent(t,s){salla.event.dispatch("multiple-bundle-product-modal::clear-options",{productId:t.id,sectionId:this.section.id,sectionIndex:this.sectionIndex,productIndex:s})}handleOptionsSaved(t){const s=t.detail;if(!s)return;const{sectionId:e,productIndex:i,selectedOptions:n}=s;if(null==e||e!==this.section?.id)return;if(null==i||Number.isNaN(i))return;const o=this.getProductInstanceKey(e,i);if(n?.length)this.savedOptionsByInstance={...this.savedOptionsByInstance,[o]:!0};else if(this.savedOptionsByInstance[o]){const t={...this.savedOptionsByInstance};delete t[o],this.savedOptionsByInstance=t}}clearSavedOptionsState(t,s){const e=this.getProductInstanceKey(t,s);if(!this.savedOptionsByInstance[e])return;const i={...this.savedOptionsByInstance};delete i[e],this.savedOptionsByInstance=i}generateEventName(t,s){return`bundle[${t}][${s}][id]`}render(){return e(i,{key:"336a3bcf504a178ee207b40b3b7fac5d26e00f91"},e("salla-slider",{key:"004d1c3f644bfd015efe2ffc21a78e912c5d0647",type:"carousel",controlsOuter:!1,showControls:!1,id:`accordion-multiple-bundle-product-${this.section.id}`,pagination:!0,class:"s-multiple-bundle-product-wrapper-slider",sliderConfig:{spaceBetween:0}},e("div",{key:"fda4544764b9bf2eb95d408179c1abc252f50243",slot:"items"},this?.section?.products?.map(((t,s)=>{const i=this.selectedProducts[this.section.id]?.has(t.id)||!1,n=this.savedOptionsByInstance[this.getProductInstanceKey(this.section.id,s)]?salla.lang.getWithDefault("pages.products.edit_selected_options","تعديل الخيارات"):salla.lang.get("pages.products.choose_from_options");let a=salla.config.get("theme.is_rtl",!0)?o:l;return e("div",{class:"s-multiple-bundle-product-slide-one-third "+(0==t.quantity?"s-multiple-bundle-product-slide-one-third-disabled":""),key:t.id},e("div",{class:"s-multiple-bundle-product-card"},e("div",{class:"s-multiple-bundle-product-image-wrapper",onClick:()=>this.handleProductClick(t,s)},e("input",{id:this.generateEventName(this.section.id,s),type:"checkbox",class:"s-multiple-bundle-product-checkbox",checked:i,name:this.generateEventName(this.section.id,s),value:t.id}),e("img",{src:t.image.url||salla.url.cdn("images/s-empty.png"),loading:"lazy",alt:t.image.alt||t.name,class:"s-multiple-bundle-product-image"})),e("div",{class:"s-multiple-bundle-product-content-wrapper"},e("div",{class:"s-multiple-bundle-product-content"},e("div",{class:"s-multiple-bundle-product-details"},e("div",{class:"s-multiple-bundle-product-title-wrapper"},e("h2",{class:"s-multiple-bundle-product-title"},e("a",{href:t?.url||"#",target:"_blank",rel:"noopener noreferrer"},t.name))),e("div",{class:"s-multiple-bundle-product-price-wrapper"},e("span",{class:"s-multiple-bundle-product-price"},e("span",{innerHTML:salla.money(t.price)})),t.sale_price>0&&e("span",{class:"s-multiple-bundle-product-price-discount"},e("span",{innerHTML:salla.money(t.regular_price)})))),t.quantity_in_group>0&&0!==t.quantity&&e("span",{class:"s-multiple-bundle-product-badge"},salla.lang.get("pages.products.pieces"),e("span",null,t.quantity_in_group)),0===t.quantity&&e("span",{class:"s-multiple-bundle-product-badge"},salla.lang.get("pages.products.quantity_in_group_finished"))),t.options?.length>0&&e("button",{class:"s-multiple-bundle-product-button",onClick:()=>this.handleOptionsClick(t),type:"button"},n,e("span",{class:"s-multiple-bundle-product-button-icon",innerHTML:a})))))})))))}get host(){return n(this)}};d.style="";export{a as salla_multiple_bundle_product_options_modal,d as salla_multiple_bundle_product_slider}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as a,h as s,H as t,a as i}from"./p-BQQ2x3w_.js";import{W as e}from"./p-ZT7ehBBk.js";import{C as l}from"./p-BV4kqbdL.js";import{H as n}from"./p-CHf8XdiS.js";import{I as r}from"./p-C-tzSDxw.js";import{W as o}from"./p-CgR-T_ZS.js";import{M as d}from"./p-DmgxDvXL.js";import{a as h}from"./p-CgtvEd63.js";var g='\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>shipping-fast</title>\n<path d="M10.667 14.667c0-0.737-0.597-1.333-1.333-1.333h-8c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333h8c0.736 0 1.333-0.596 1.333-1.333zM9.333 18.667c-2.941 0-5.333 2.392-5.333 5.333s2.392 5.333 5.333 5.333 5.333-2.392 5.333-5.333-2.392-5.333-5.333-5.333zM9.333 26.667c-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.667zM1.333 10.667h5.333c0.736 0 1.333-0.596 1.333-1.333s-0.597-1.333-1.333-1.333h-5.333c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333zM31.123 13.103l-3.147-3.935c-1.273-1.589-3.171-2.501-5.205-2.501h-1.437c0-2.205-1.795-4-4-4h-13.333c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333h13.333c0.735 0 1.333 0.597 1.333 1.333v1.333c0 0.248 0.087 0.468 0.204 0.667-0.117 0.199-0.204 0.419-0.204 0.667v5.333c0 0.737 0.597 1.333 1.333 1.333h9.333v6.667h-1.333c-0.063 0-0.117 0.028-0.179 0.036-0.583-2.313-2.664-4.036-5.155-4.036-2.941 0-5.333 2.392-5.333 5.333s2.392 5.333 5.333 5.333c2.491 0 4.572-1.723 5.155-4.036 0.061 0.008 0.116 0.036 0.179 0.036h2.667c0.736 0 1.333-0.596 1.333-1.333v-8.399c0-0.905-0.311-1.792-0.877-2.499zM21.333 13.333v-4h1.437c1.221 0 2.36 0.547 3.124 1.501l1.997 2.499zM22.667 26.667c-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';const m=class{constructor(s){a(this,s),this.hasError=!1,this.showContactWidget=!0,this.images=[],this.productImages={},this.editItemImages=[],this.contact_body=(a,s,t)=>salla.lang.get("pages.rating.contact_subject",{store:a,id:s,customer:t}),this.editMode=!1,this.defaultMode=!1,this.deleteMode=!1,this.shouldOpenDeleteModal=!1,this.editItem=null,this.dragAndDropFilesLabel=salla.lang.get("common.uploader.drag_and_drop_files"),this.contactSubjectLabel=salla.lang.get("pages.rating.contact_subject"),this.editReviewLabel=salla.lang.get("pages.rating.edit_review"),this.allowedImagesTypesLabel=salla.lang.get("common.uploader.allowed_images_types"),this.addImagesLabel=salla.lang.get("pages.rating.add_images"),this.editImagesLabel=salla.lang.get("pages.rating.edit_images"),this.threeImagesMax=salla.lang.get("common.uploader.max_three_images"),this.areYouSureLabel=salla.lang.get("pages.rating.are_you_sure_you_want_to_delete_review"),this.confirmDeletionLabel=salla.lang.get("pages.rating.confirm_deletion"),this.cancelLabel=salla.lang.get("common.elements.cancel"),this.confirmDeleteBtn=salla.lang.get("common.elements.confirm_delete"),this.updatedSuccessfullyLabel=salla.lang.get("pages.rating.review_updated_successfully"),this.deletedSuccessfullyLabel=salla.lang.get("pages.rating.review_deleted_successfully"),this.contactUsLabel=salla.lang.get("blocks.footer.social"),this.allowAttachImages=salla.config.get("store.settings.rating.allow_attach_images"),this.allowContactSupport=salla.config.get("store.settings.rating.allow_contact_support"),this.contentRefs=[],this.hiddenInputs=[],this.isOpen=[],this.stepsCount=0,this.currentIndex=0,this.submitted=[],this.MAX_UPLOAD_LIMIT=3,this.onOpen=a=>new Promise((s=>{h({targets:this.contentRefs[a],duration:100,height:this.contentRefs[a].scrollHeight,opacity:[0,1],easing:"easeOutQuart",complete:()=>s()})})),this.onClose=a=>new Promise((s=>{h({targets:this.contentRefs[a],duration:100,height:0,opacity:[1,0],easing:"easeOutQuart",complete:()=>s()})})),this.toggleUploader=async a=>{this.isOpen[a]=!this.isOpen[a],n.toggleElementClassIf(this.contentRefs[a],"is-closed","is-opened",(()=>!this.isOpen[a])),await(this.isOpen[a]?this.onOpen(a):this.onClose(a)),await new Promise((a=>setTimeout(a,101))),this.body&&this.currentTab&&setTimeout((()=>this.body.setAttribute("style",`height:${this.currentTab.offsetHeight+(this.editMode?60:0)}px`)))},salla.onReady((()=>{this.orderId=salla.config.get("page.id")})),salla.lang.onLoaded((()=>{this.contactUsLabel=salla.lang.get("blocks.footer.social");const a=(a,s,t)=>new Promise((i=>{salla.helpers.setNested(salla.lang.messages[a],s,t),i(!0)}));(async()=>{await a("ar.trans","common.uploader.drag_and_drop_files","اسحب الملفات وأفلتها هنا"),await a("en.trans","common.uploader.drag_and_drop_files","Drag and drop files here"),await a("ar.trans","common.uploader.allowed_images_types"," .jpg أو jpeg أو png يُسمح بإضافة صور بصيغة"),await a("en.trans","common.uploader.allowed_images_types","Images in jpg, jpeg, or png format are allowed."),await a("ar.trans","pages.rating.add_images","اضافة صور"),await a("en.trans","pages.rating.add_images","Add Images"),await a("ar.trans","pages.rating.edit_images","تعديل الصور"),await a("en.trans","pages.rating.edit_images","Edit Images"),await a("ar.trans","pages.rating.edit_review","تعديل التقييم"),await a("en.trans","pages.rating.edit_review","Edit review"),await a("ar.trans","pages.rating.confirm_deletion","تأكيد حذف التقييم"),await a("en.trans","pages.rating.confirm_deletion","Confirm review deletion"),await a("ar.trans","pages.rating.are_you_sure_you_want_to_delete_review","هل أنت متأكد من حذف تقييمك؟"),await a("en.trans","pages.rating.are_you_sure_you_want_to_delete_review","Are you sure you want to delete your review?"),await a("ar.trans","pages.rating.review_updated_successfully","تم تعديل التقييم بنجاح"),await a("en.trans","pages.rating.review_updated_successfully","The review has been successfully updated."),await a("ar.trans","pages.rating.review_deleted_successfully","تم حذف التقييم بنجاح"),await a("en.trans","pages.rating.review_deleted_successfully","The review has been successfully deleted."),await a("ar.trans","pages.rating.images_count","الصور ( :current من أصل :total )"),await a("en.trans","pages.rating.images_count","Images ( :current of :total )"),await a("ar.trans","common.uploader.max_three_images",`.أضف ${this.MAX_UPLOAD_LIMIT} صور كحد أقصى`),await a("en.trans","common.uploader.max_three_images",`Add up to ${this.MAX_UPLOAD_LIMIT} images maximum.`),await a("ar.trans","common.elements.confirm_delete","تأكيد الحذف"),await a("en.trans","common.elements.confirm_delete","Confirm deletion"),this.dragAndDropFilesLabel=salla.lang.get("common.uploader.drag_and_drop_files"),this.allowedImagesTypesLabel=salla.lang.get("common.uploader.allowed_images_types"),this.addImagesLabel=salla.lang.get("pages.rating.add_images"),this.threeImagesMax=salla.lang.get("common.uploader.max_three_images"),this.contactSubjectLabel=salla.lang.get("pages.rating.contact_subject"),this.editReviewLabel=salla.lang.get("pages.rating.edit_review"),this.editImagesLabel=salla.lang.get("pages.rating.edit_images"),this.areYouSureLabel=salla.lang.get("pages.rating.are_you_sure_you_want_to_delete_review"),this.confirmDeletionLabel=salla.lang.get("pages.rating.confirm_deletion"),this.cancelLabel=salla.lang.get("common.elements.cancel"),this.updatedSuccessfullyLabel=salla.lang.get("pages.rating.review_updated_successfully"),this.deletedSuccessfullyLabel=salla.lang.get("pages.rating.review_deleted_successfully"),this.confirmDeleteBtn=salla.lang.get("common.elements.confirm_delete"),this.contact_body=(a,s,t)=>salla.lang.get("pages.rating.contact_body",{store:a,id:s,customer:t})})()}))}async open(){return this.defaultMode=!0,new Promise((a=>{setTimeout((()=>{this.modal.open().then((()=>this.order||salla.api.withoutNotifier((()=>salla.rating.api.order(this.orderId?this.orderId:salla.config.get("page.id")))).then((a=>this.order=a.data)))).then((()=>this.modal.setTitle(`${salla.lang.get("pages.rating.rate_order")} <span class="unicode">(#${this.order.id})</span>`))).then((()=>{const a={};if(this.order?.products)for(const s of this.order.products)a[s.product.id]=[];this.productImages=a})).then((()=>this.modal.stopLoading())).then((()=>this.stepsCount=[this.order.testimonials_enabled,this.order.products_enabled,this.order.shipping_enabled].filter((a=>a)).length)).then((()=>setTimeout((()=>this.handleWizard()),100))).catch((s=>{a(!1),this.hasError=!0,this.errorMessage=s.response?.data?.error?.message||s.response?.data,this.modal.stopLoading()})),a(!0)}),50)}))}async openEditModal(a){this.defaultMode=!1,this.editMode=!0,this.editType=a.type,this.editFeedbackId=a.feedback_id;try{await this.fetchEditItem(a.feedback_id),this.editModal.open()}catch(a){this.hasError=!0,this.errorMessage=a.response?.data?.error?.message||a.response?.data}}async fetchEditItem(a){const s=`rating/${a}/show`,t=await salla.api.request(s);this.editItem=t.data,this.allowAttachImages&&"product"==this.editType&&this.editItem.images.length&&(this.editItemImages=this.editItem.images.map((a=>({id:`${Math.floor(100+900*Math.random())}`,url:a}))))}async editReview(){const a={};this.editModal.querySelectorAll("[name]").forEach((s=>{const t=salla.helpers.inputData(s.name,s.value,a);a[t.name]=t.value})),a.images&&(a.images=a.images.split(","));const s=`rating/${this.editFeedbackId}`;await salla.api.request(s,a,"put").then((a=>{this.editModal.close(),salla.notify.success(a.message||this.updatedSuccessfullyLabel),setTimeout((()=>{window.location.reload()}),500)}))}async openDeleteModal(a){return this.defaultMode=!1,this.deleteMode=!0,this.deleteFeedbackId=a.feedback_id,this.shouldOpenDeleteModal=!0,new Promise((a=>{setTimeout((()=>{this.deleteModal.open().then((()=>a(!0)))}),50)}))}async deleteReview(){const a=`rating/${this.deleteFeedbackId}`;await salla.api.request(a,null,"delete").then((()=>{this.deleteModal.close(),salla.notify.success(this.deletedSuccessfullyLabel),setTimeout((()=>{window.location.reload()}),500)}))}async close(){return this.modal.close()}handleWizard(){this.steps=this.modal.querySelectorAll(".s-rating-modal-step"),this.dots=this.modal.querySelectorAll(".s-rating-modal-step-dot"),this.showActiveStep()}showActiveStep(a=null){this.currentTab=a||this.steps[this.currentIndex],n.toggleClassIf(".s-rating-modal-step-dot","s-rating-modal-bg-gray","s-rating-modal-bg-primary",(a=>a!=this.dots[this.currentIndex])).toggleClassIf(".s-rating-modal-step","s-rating-modal-active","s-rating-modal-hidden",(a=>a==this.currentTab)),0!==this.currentIndex&&(n.toggleElementClassIf(this.currentTab,"s-rating-modal-unactive","s-rating-modal-hidden",(()=>!0)),setTimeout((()=>n.toggleElementClassIf(this.currentTab,"s-rating-modal-active","s-rating-modal-unactive",(()=>!0))),300));const s=this.steps[this.currentIndex+1]?.dataset.type;this.nextBtn?.setText(s?`${salla.lang.get("pages.rating.rate")} ${salla.lang.get(`pages.rating.${s}`)}`:salla.lang.get("pages.rating.send_ratings")),setTimeout((()=>this.body?.setAttribute("style",`height:${this.currentTab?.offsetHeight}px`)))}previousTab(){this.currentIndex>0&&this.currentIndex--,n.toggleElementClassIf(this.backBtn,"s-rating-modal-unvisiable","block",(()=>0==this.currentIndex)),this.showActiveStep()}submit(){this.submittedBefore()||this.validate(),salla.config.canLeave=!1,this.nextBtn.load().then((()=>this.submittedBefore()||this.sendFeedback())).then((()=>this.currentTab.querySelectorAll("[name],.s-rating-modal-btn-star").forEach((a=>a.setAttribute("disabled",""))))).then((()=>this.currentIndex<this.stepsCount&&this.currentIndex++)).then((()=>this.showActiveStep())).then((()=>n.toggleClassIf("#prev-btn","block","s-rating-modal-unvisiable",(()=>!0)))).finally((()=>{this.nextBtn.stop(),salla.config.canLeave=!0,this.currentIndex==this.stepsCount&&(this.showThankYou(),this.showContactWidget=!1)}))}submittedBefore(){return this.submitted.includes(this.currentIndex)}validate(a=null,s=null){if(!a&&"products"===this.currentTab.dataset.type)return void this.currentTab.querySelectorAll(".rating-outer-form").forEach((a=>this.validate(a,"product")));const t=(a=a||this.currentTab).querySelector(".rating_hidden_input").value,i=a.querySelector(".s-rating-modal-validation-msg");if(s=s||a.dataset.type,!t)throw i.innerHTML=salla.lang.get(`pages.rating.rate_${s}_stars`).replace(" (:item)",""),new Error(i.innerHTML);i.innerHTML=""}sendFeedback(){const a={};if(this.currentTab.querySelectorAll("[name]").forEach((s=>{const t=salla.helpers.inputData(s.name,s.value,a);a[t.name]=t.value})),this.allowAttachImages&&a.products)for(let s in a.products)a.products[s].images&&(a.products[s].images=a.products[s].images.split(","));if(0!=Object.keys(a).length)return a.order_id=this.orderId,a.type=this.currentTab.dataset.type,salla.rating.api[this.currentTab.dataset.type](a).then((a=>(this.submitted.push(this.currentIndex),a)))}showThankYou(){let a=10,s=setInterval((()=>{this.thanksTime.innerHTML="00:0"+a--,a>0||(clearInterval(s),this.thanksTime.remove(),this.close().then((()=>window.location.reload())))}),1e3);this.modal.querySelector(".s-rating-modal-footer").classList.add("s-rating-modal-unvisiable"),this.showActiveStep(this.thanksTab)}getFilepondPlaceholder(){return`<div class="s-rating-modal-filepond-placeholder"><span class="s-rating-modal-filepond-placeholder-icon">${r}</span><p class="s-rating-modal-filepond-placeholder-text">${this.dragAndDropFilesLabel}<br>\n <span> ${this.allowedImagesTypesLabel} <br> ${this.threeImagesMax} </span></p></div>`}getCustomerName(){return`${salla.config.get("user.first_name")||salla.storage.get("user.first_name")||""} ${salla.config.get("user.last_name")||salla.storage.get("user.last_name")||""}`}handleSendEmail(){const a=`${this.contactSubjectLabel} #${this.order.id}`,s=this.contact_body(salla.config.get("store.name"),this.order.id,this.getCustomerName()),t=`mailto:${salla.config.get("store.contacts.email")}?subject=${encodeURIComponent(a)}&body=${encodeURIComponent(s)}`;window.open(t,"_blank")}handleSendWhatsApp(){const a=this.contact_body(salla.config.get("store.name"),this.order.id,this.getCustomerName()),s=`https://wa.me/${salla.config.get("store.contacts.whatsapp")}?text=${encodeURIComponent(a)}`;window.open(s,"_blank")}resetData(a){a.detail||(this.modal?.close(),this.editItem=null,this.editItemImages=[],this.hiddenInputs[1]&&(this.hiddenInputs[1].value=""),this.deleteFeedbackId=null,this.editFeedbackId=null,this.shouldOpenDeleteModal=!1,this.editMode=!1,this.deleteMode=!1,this.defaultMode=!1)}getDeleteModal(){return s("salla-modal",{ref:a=>this.deleteModal=a,width:"xs",onModalVisibilityChanged:a=>this.resetData(a)},s("div",{class:"s-rating-modal-delete-wrapper",ref:a=>this.body=a},s("h3",null,this.confirmDeletionLabel),s("p",null,this.areYouSureLabel),s("div",{class:"s-rating-modal-delete-actions"},s("salla-button",{loaderPosition:"center",onClick:()=>this.deleteReview()},this.confirmDeleteBtn),s("salla-button",{color:"danger",fill:"outline",onClick:()=>this.deleteModal.close()},this.cancelLabel))))}renderUploadedImagesCount(a){const t=this.editMode?this.editItemImages.length:(this.productImages[a]||[]).length;return s("span",{class:"s-rating-modal-upload-count"},salla.lang.choice("pages.rating.images_count",t,{current:t,total:this.MAX_UPLOAD_LIMIT}))}getEditModal(){return s("salla-modal",{ref:a=>this.editModal=a,width:"md",onModalVisibilityChanged:a=>this.resetData(a)},s("div",{class:"s-rating-modal-edit-wrapper",ref:a=>this.body=a},"store"===this.editType&&this.editItem?s("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step","data-type":"store",ref:a=>this.currentTab=a},s("div",{class:"s-rating-modal-rounded-icon"},s("img",{src:salla.config.get("store.logo","https://assets.salla.sa/cp/assets/images/logo-new.png"),alt:"store name",class:"s-rating-modal-store-logo"})),s("h2",{class:"s-rating-modal-title"},salla.lang.get("pages.rating.rate_the_store")),s("div",{class:"s-rating-modal-stars-company"},s("salla-rating-stars",{withLabel:!0,size:"large",editable:!0,value:this.editItem.stars})),s("textarea",{name:"content",value:this.editItem.content,class:"s-rating-modal-comment",placeholder:salla.lang.get("pages.rating.write_store_rate")}),s("small",{class:"s-rating-modal-validation-msg"})):null,"shipping"===this.editType&&this.editItem?s("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step","data-type":"shipping",ref:a=>this.currentTab=a},this.editItem.shipping.logo?s("div",{class:"s-rating-modal-rounded-icon"},s("img",{src:this.editItem.shipping.logo,class:"s-rating-modal-shipping-logo",alt:this.editItem.shipping.name})):s("span",{class:"s-rating-modal-icon",innerHTML:g}),s("div",{class:"s-rating-modal-title"}," ",`${salla.lang.get("pages.rating.rate_shipping")} ${this.editItem.shipping.name}`),s("div",{class:"s-rating-modal-stars-company"},s("salla-rating-stars",{withLabel:!0,size:"large",editable:!0,value:this.editItem.stars})),s("textarea",{name:"content",class:"s-rating-modal-comment",value:this.editItem.content,placeholder:salla.lang.get("pages.rating.write_shipping_rate")}),s("small",{class:"s-rating-modal-validation-msg"})):null,"product"==this.editType&&this.editItem?s("section",{class:"s-rating-modal-step","data-type":"products",ref:a=>this.currentTab=a},s("div",{class:"s-rating-modal-product"},s("div",{class:"rating-outer-form","data-stars-error":salla.lang.get("pages.rating.rate_product_stars")},s("div",{class:"s-rating-modal-product-img-wrap"},s("img",{src:this.editItem.product.image.url,alt:this.editItem.product.name,class:"s-rating-modal-product-img"})),s("div",{class:"s-rating-modal-product-details"},s("div",{class:"s-rating-modal-product-details-main"},s("div",null,s("h3",{class:"s-rating-modal-product-title"}," ",this.editItem.product.name),s("div",{class:"s-rating-modal-stars-product"},s("salla-rating-stars",{withLabel:!0,size:"small",editable:!0,value:this.editItem.stars}))),this.allowAttachImages&&s("salla-button",{class:"s-comments-item-like-btn mt-0",loaderPosition:"center",fill:"outline",size:"small",onClick:()=>this.toggleUploader(1)},s("span",null,this.editItemImages.length?this.editImagesLabel:this.addImagesLabel),s("span",{innerHTML:r}))),s("textarea",{value:this.editItem.content,placeholder:salla.lang.get("pages.rating.write_product_rate"),name:"content",class:"s-rating-modal-comment"}),s("small",{class:"s-rating-modal-validation-msg"}))),this.allowAttachImages&&s("div",{class:"s-rating-modal-uploader is-closed",ref:a=>this.contentRefs[1]=a},s("salla-file-upload",{name:"images",allowMultiple:!0,maxFilesCount:this.MAX_UPLOAD_LIMIT,imagePreviewHeight:117,filePosterHeight:117,"instant-upload":!0,type:"feedback",files:JSON.stringify(this.editItemImages),payloadName:"files[]",id:`file-${this.editItem.product.id}`,title:this.editItem.product.name,instantUpload:!0,accept:"image/png, image/jpeg, image/jpg",url:salla.url.api("upload"),onUploaded:a=>{this.editItemImages=[...this.editItemImages,a.detail],this.hiddenInputs[1].value=this.editItemImages.map((a=>a.url)).join()},onRemoved:a=>{const s=a.detail;s&&(this.editItemImages=this.editItemImages.filter((a=>a.id!==s)),this.hiddenInputs[1].value=this.editItemImages.map((a=>a.url)).join())},labelIdle:this.getFilepondPlaceholder()}),s("input",{type:"hidden",name:"images",value:this.editItem.images.join(","),ref:a=>this.hiddenInputs[1]=a}),this.renderUploadedImagesCount(this.editItem.product.id)))):null,s("div",{class:"s-rating-modal-footer s-rating-modal-footer-end"},s("salla-button",{"loader-position":"center",onClick:()=>this.editReview()},this.editReviewLabel))))}render(){return this.deleteMode?s(t,{class:"s-rating-modal"},this.getDeleteModal()):this.editMode?s(t,{class:"s-rating-modal"},this.getEditModal()):this.defaultMode?s(t,{class:"s-rating-modal"},s("salla-modal",{class:"s-rating-modal-wrap",onModalVisibilityChanged:a=>this.resetData(a),isLoading:!0,width:"md",ref:a=>this.modal=a},s("div",{slot:"loading"},s("div",{class:"s-rating-modal-skeleton"},s("salla-skeleton",{type:"circle",height:"80px",width:"80px"}),s("salla-skeleton",{height:"15px",width:"60%"}),s("salla-skeleton",{height:"10px",width:"30%"}),s("div",{class:"s-rating-modal-skeleton-stars"},[...Array(5)].map((a=>s("div",{key:a,innerHTML:e})))),s("salla-skeleton",{height:"100px",width:"100%"}),s("div",{class:"s-rating-modal-skeleton-footer"},s("salla-skeleton",{height:"40px",width:"30%"})))),!this.hasError&&this.order?[s("div",{class:"s-rating-modal-wrapper",ref:a=>this.body=a},this.order?.testimonials_enabled?s("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"store"},s("div",{class:"s-rating-modal-rounded-icon"},s("img",{src:salla.config.get("store.logo","https://assets.salla.sa/cp/assets/images/logo-new.png"),alt:"store name",class:"s-rating-modal-store-logo"})),s("h2",{class:"s-rating-modal-title"},salla.lang.get("pages.rating.rate_the_store")),s("div",{class:"s-rating-modal-stars-company"},s("salla-rating-stars",{withLabel:!0,size:"large"})),s("textarea",{name:"comment",class:"s-rating-modal-comment",placeholder:salla.lang.get("pages.rating.write_store_rate")}),s("small",{class:"s-rating-modal-validation-msg"})):"",this.order.products_enabled?s("section",{class:"s-rating-modal-step s-rating-modal-hidden","data-type":"products"},this.order.products.map(((a,t)=>s("div",{class:"s-rating-modal-product",key:t},s("div",{class:"rating-outer-form","data-stars-error":salla.lang.get("pages.rating.rate_product_stars")},s("div",{class:"s-rating-modal-product-img-wrap"},s("img",{src:a.product.thumbnail,alt:a.product.name,class:"s-rating-modal-product-img"})),s("div",{class:"s-rating-modal-product-details"},s("div",{class:"s-rating-modal-product-details-main"},s("div",null,s("h3",{class:"s-rating-modal-product-title"}," ",a.product.name),s("div",{class:"s-rating-modal-stars-product"},s("salla-rating-stars",{withLabel:!0,size:"small",name:`products[${t}][rating]`}))),this.allowAttachImages&&s("salla-button",{class:"s-comments-item-like-btn mt-0",loaderPosition:"center",fill:"outline",size:"small",onClick:()=>this.toggleUploader(t)},s("span",null,this.addImagesLabel),s("span",{innerHTML:r}))),s("input",{type:"hidden",name:`products[${t}][product_id]`,value:a.product.id}),s("textarea",{placeholder:salla.lang.get("pages.rating.write_product_rate"),name:`products[${t}][comment]`,class:"s-rating-modal-comment"}),s("small",{class:"s-rating-modal-validation-msg"}))),this.allowAttachImages&&s("div",{class:"s-rating-modal-uploader is-closed",ref:a=>this.contentRefs[t]=a},s("salla-file-upload",{name:"image",maxFilesCount:this.MAX_UPLOAD_LIMIT,imagePreviewHeight:117,"instant-upload":!0,type:"feedback",payloadName:"files[]",id:`file-${a.product.id}`,title:a.product.name,allowMultiple:!0,instantUpload:!0,accept:"image/png, image/jpeg, image/jpg",url:salla.url.api("upload"),onUploaded:s=>{this.productImages={...this.productImages,[a.product.id]:[...this.productImages[a.product.id]||[],s.detail]},this.hiddenInputs[t].value=this.productImages[a.product.id].map((a=>a.url)).join(",")},onRemoved:s=>{const i=s.detail;i&&this.productImages[a.product.id]&&(this.productImages={...this.productImages,[a.product.id]:this.productImages[a.product.id].filter((a=>a.id!==i))},this.hiddenInputs[t].value=this.productImages[a.product.id].map((a=>a.url)).join(","))},labelIdle:this.getFilepondPlaceholder()}),s("input",{type:"hidden",name:`products[${t}][images]`,value:(this.productImages[a.product.id]||[]).map((a=>a.url)).join(","),ref:a=>this.hiddenInputs[t]=a}),this.renderUploadedImagesCount(a.product.id)))))):"",this.order.shipping_enabled&&this.order.shipping?.company?s("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"shipping"},s("input",{type:"hidden",name:"shipping_company_id",value:this.order.shipping.company.id}),this.order.shipping.company.logo?s("div",{class:"s-rating-modal-rounded-icon"},s("img",{src:this.order.shipping.company.logo,class:"s-rating-modal-shipping-logo",alt:this.order.shipping.company.name})):s("span",{class:"s-rating-modal-icon",innerHTML:g}),s("div",{class:"s-rating-modal-title"}," ",`${salla.lang.get("pages.rating.rate_shipping")} ${this.order.shipping.company.name}`),s("div",{class:"s-rating-modal-stars-company"},s("salla-rating-stars",{withLabel:!0,size:"large"})),s("textarea",{name:"comment",class:"s-rating-modal-comment",placeholder:salla.lang.get("pages.rating.write_shipping_rate")}),s("small",{class:"s-rating-modal-validation-msg"})):"",s("div",{class:"s-rating-modal-thanks s-rating-modal-hidden",ref:a=>this.thanksTab=a},s("span",{class:"s-rating-modal-icon",innerHTML:l}),s("h3",{class:"s-rating-modal-thanks-title"},salla.lang.get("pages.rating.thanks")),s("div",{class:"s-rating-modal-thanks-msg",innerHTML:this.order.thanks_message}),s("time",{class:"s-rating-modal-thanks-time",ref:a=>this.thanksTime=a}))),this.allowContactSupport&&this.showContactWidget&&(salla.config.get("store.contacts.whatsapp")||salla.config.get("store.contacts.email"))?s("div",{class:"s-rating-modal-contact"},s("p",null,this.contactUsLabel),s("div",{class:"s-rating-modal-contact-icons"},salla.config.get("store.contacts.whatsapp")&&s("span",{onClick:()=>this.handleSendWhatsApp(),innerHTML:o}),salla.config.get("store.contacts.email")&&s("span",{onClick:()=>this.handleSendEmail(),innerHTML:d}))):"",s("div",{class:"s-rating-modal-footer"},s("button",{ref:a=>this.backBtn=a,onClick:()=>this.previousTab(),class:"s-rating-modal-btn s-rating-modal-unvisiable"},salla.lang.get("common.elements.back")),this.stepsCount>1?s("ul",{class:"s-rating-modal-dots"},[0,1,2].slice(0,this.stepsCount).map((a=>s("li",{key:a,class:"s-rating-modal-bg-gray s-rating-modal-step-dot"})))):"",s("salla-button",{"loader-position":"center",ref:a=>this.nextBtn=a,onClick:()=>this.submit()},salla.lang.get("common.elements.next")))]:s("salla-placeholder",{alignment:"center"}))):void 0}componentWillLoad(){salla.event.on("rating::open",(()=>this.open())),salla.event.on("rating::edit",(a=>this.openEditModal(a))),salla.event.on("rating::delete",(a=>this.openDeleteModal(a)))}componentDidLoad(){salla.event.dispatch("rating::ready",this)}get host(){return i(this)}};m.style="";export{m as salla_rating_modal}
|
|
4
|
+
import{r as a,h as s,H as t,a as i}from"./p-DygKr0gG.js";import{W as e}from"./p-ZT7ehBBk.js";import{C as l}from"./p-BV4kqbdL.js";import{H as n}from"./p-CHf8XdiS.js";import{I as r}from"./p-C-tzSDxw.js";import{W as o}from"./p-CgR-T_ZS.js";import{M as d}from"./p-DmgxDvXL.js";import{a as h}from"./p-CgtvEd63.js";var g='\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>shipping-fast</title>\n<path d="M10.667 14.667c0-0.737-0.597-1.333-1.333-1.333h-8c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333h8c0.736 0 1.333-0.596 1.333-1.333zM9.333 18.667c-2.941 0-5.333 2.392-5.333 5.333s2.392 5.333 5.333 5.333 5.333-2.392 5.333-5.333-2.392-5.333-5.333-5.333zM9.333 26.667c-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.667zM1.333 10.667h5.333c0.736 0 1.333-0.596 1.333-1.333s-0.597-1.333-1.333-1.333h-5.333c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333zM31.123 13.103l-3.147-3.935c-1.273-1.589-3.171-2.501-5.205-2.501h-1.437c0-2.205-1.795-4-4-4h-13.333c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333h13.333c0.735 0 1.333 0.597 1.333 1.333v1.333c0 0.248 0.087 0.468 0.204 0.667-0.117 0.199-0.204 0.419-0.204 0.667v5.333c0 0.737 0.597 1.333 1.333 1.333h9.333v6.667h-1.333c-0.063 0-0.117 0.028-0.179 0.036-0.583-2.313-2.664-4.036-5.155-4.036-2.941 0-5.333 2.392-5.333 5.333s2.392 5.333 5.333 5.333c2.491 0 4.572-1.723 5.155-4.036 0.061 0.008 0.116 0.036 0.179 0.036h2.667c0.736 0 1.333-0.596 1.333-1.333v-8.399c0-0.905-0.311-1.792-0.877-2.499zM21.333 13.333v-4h1.437c1.221 0 2.36 0.547 3.124 1.501l1.997 2.499zM22.667 26.667c-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';const m=class{constructor(s){a(this,s),this.hasError=!1,this.showContactWidget=!0,this.images=[],this.productImages={},this.editItemImages=[],this.contact_body=(a,s,t)=>salla.lang.get("pages.rating.contact_subject",{store:a,id:s,customer:t}),this.editMode=!1,this.defaultMode=!1,this.deleteMode=!1,this.shouldOpenDeleteModal=!1,this.editItem=null,this.dragAndDropFilesLabel=salla.lang.get("common.uploader.drag_and_drop_files"),this.contactSubjectLabel=salla.lang.get("pages.rating.contact_subject"),this.editReviewLabel=salla.lang.get("pages.rating.edit_review"),this.allowedImagesTypesLabel=salla.lang.get("common.uploader.allowed_images_types"),this.addImagesLabel=salla.lang.get("pages.rating.add_images"),this.editImagesLabel=salla.lang.get("pages.rating.edit_images"),this.threeImagesMax=salla.lang.get("common.uploader.max_three_images"),this.areYouSureLabel=salla.lang.get("pages.rating.are_you_sure_you_want_to_delete_review"),this.confirmDeletionLabel=salla.lang.get("pages.rating.confirm_deletion"),this.cancelLabel=salla.lang.get("common.elements.cancel"),this.confirmDeleteBtn=salla.lang.get("common.elements.confirm_delete"),this.updatedSuccessfullyLabel=salla.lang.get("pages.rating.review_updated_successfully"),this.deletedSuccessfullyLabel=salla.lang.get("pages.rating.review_deleted_successfully"),this.contactUsLabel=salla.lang.get("blocks.footer.social"),this.allowAttachImages=salla.config.get("store.settings.rating.allow_attach_images"),this.allowContactSupport=salla.config.get("store.settings.rating.allow_contact_support"),this.contentRefs=[],this.hiddenInputs=[],this.isOpen=[],this.stepsCount=0,this.currentIndex=0,this.submitted=[],this.MAX_UPLOAD_LIMIT=3,this.onOpen=a=>new Promise((s=>{h({targets:this.contentRefs[a],duration:100,height:this.contentRefs[a].scrollHeight,opacity:[0,1],easing:"easeOutQuart",complete:()=>s()})})),this.onClose=a=>new Promise((s=>{h({targets:this.contentRefs[a],duration:100,height:0,opacity:[1,0],easing:"easeOutQuart",complete:()=>s()})})),this.toggleUploader=async a=>{this.isOpen[a]=!this.isOpen[a],n.toggleElementClassIf(this.contentRefs[a],"is-closed","is-opened",(()=>!this.isOpen[a])),await(this.isOpen[a]?this.onOpen(a):this.onClose(a)),await new Promise((a=>setTimeout(a,101))),this.body&&this.currentTab&&setTimeout((()=>this.body.setAttribute("style",`height:${this.currentTab.offsetHeight+(this.editMode?60:0)}px`)))},salla.onReady((()=>{this.orderId=salla.config.get("page.id")})),salla.lang.onLoaded((()=>{this.contactUsLabel=salla.lang.get("blocks.footer.social");const a=(a,s,t)=>new Promise((i=>{salla.helpers.setNested(salla.lang.messages[a],s,t),i(!0)}));(async()=>{await a("ar.trans","common.uploader.drag_and_drop_files","اسحب الملفات وأفلتها هنا"),await a("en.trans","common.uploader.drag_and_drop_files","Drag and drop files here"),await a("ar.trans","common.uploader.allowed_images_types"," .jpg أو jpeg أو png يُسمح بإضافة صور بصيغة"),await a("en.trans","common.uploader.allowed_images_types","Images in jpg, jpeg, or png format are allowed."),await a("ar.trans","pages.rating.add_images","اضافة صور"),await a("en.trans","pages.rating.add_images","Add Images"),await a("ar.trans","pages.rating.edit_images","تعديل الصور"),await a("en.trans","pages.rating.edit_images","Edit Images"),await a("ar.trans","pages.rating.edit_review","تعديل التقييم"),await a("en.trans","pages.rating.edit_review","Edit review"),await a("ar.trans","pages.rating.confirm_deletion","تأكيد حذف التقييم"),await a("en.trans","pages.rating.confirm_deletion","Confirm review deletion"),await a("ar.trans","pages.rating.are_you_sure_you_want_to_delete_review","هل أنت متأكد من حذف تقييمك؟"),await a("en.trans","pages.rating.are_you_sure_you_want_to_delete_review","Are you sure you want to delete your review?"),await a("ar.trans","pages.rating.review_updated_successfully","تم تعديل التقييم بنجاح"),await a("en.trans","pages.rating.review_updated_successfully","The review has been successfully updated."),await a("ar.trans","pages.rating.review_deleted_successfully","تم حذف التقييم بنجاح"),await a("en.trans","pages.rating.review_deleted_successfully","The review has been successfully deleted."),await a("ar.trans","pages.rating.images_count","الصور ( :current من أصل :total )"),await a("en.trans","pages.rating.images_count","Images ( :current of :total )"),await a("ar.trans","common.uploader.max_three_images",`.أضف ${this.MAX_UPLOAD_LIMIT} صور كحد أقصى`),await a("en.trans","common.uploader.max_three_images",`Add up to ${this.MAX_UPLOAD_LIMIT} images maximum.`),await a("ar.trans","common.elements.confirm_delete","تأكيد الحذف"),await a("en.trans","common.elements.confirm_delete","Confirm deletion"),this.dragAndDropFilesLabel=salla.lang.get("common.uploader.drag_and_drop_files"),this.allowedImagesTypesLabel=salla.lang.get("common.uploader.allowed_images_types"),this.addImagesLabel=salla.lang.get("pages.rating.add_images"),this.threeImagesMax=salla.lang.get("common.uploader.max_three_images"),this.contactSubjectLabel=salla.lang.get("pages.rating.contact_subject"),this.editReviewLabel=salla.lang.get("pages.rating.edit_review"),this.editImagesLabel=salla.lang.get("pages.rating.edit_images"),this.areYouSureLabel=salla.lang.get("pages.rating.are_you_sure_you_want_to_delete_review"),this.confirmDeletionLabel=salla.lang.get("pages.rating.confirm_deletion"),this.cancelLabel=salla.lang.get("common.elements.cancel"),this.updatedSuccessfullyLabel=salla.lang.get("pages.rating.review_updated_successfully"),this.deletedSuccessfullyLabel=salla.lang.get("pages.rating.review_deleted_successfully"),this.confirmDeleteBtn=salla.lang.get("common.elements.confirm_delete"),this.contact_body=(a,s,t)=>salla.lang.get("pages.rating.contact_body",{store:a,id:s,customer:t})})()}))}async open(){return this.defaultMode=!0,new Promise((a=>{setTimeout((()=>{this.modal.open().then((()=>this.order||salla.api.withoutNotifier((()=>salla.rating.api.order(this.orderId?this.orderId:salla.config.get("page.id")))).then((a=>this.order=a.data)))).then((()=>this.modal.setTitle(`${salla.lang.get("pages.rating.rate_order")} <span class="unicode">(#${this.order.id})</span>`))).then((()=>{const a={};if(this.order?.products)for(const s of this.order.products)a[s.product.id]=[];this.productImages=a})).then((()=>this.modal.stopLoading())).then((()=>this.stepsCount=[this.order.testimonials_enabled,this.order.products_enabled,this.order.shipping_enabled].filter((a=>a)).length)).then((()=>setTimeout((()=>this.handleWizard()),100))).catch((s=>{a(!1),this.hasError=!0,this.errorMessage=s.response?.data?.error?.message||s.response?.data,this.modal.stopLoading()})),a(!0)}),50)}))}async openEditModal(a){this.defaultMode=!1,this.editMode=!0,this.editType=a.type,this.editFeedbackId=a.feedback_id;try{await this.fetchEditItem(a.feedback_id),this.editModal.open()}catch(a){this.hasError=!0,this.errorMessage=a.response?.data?.error?.message||a.response?.data}}async fetchEditItem(a){const s=`rating/${a}/show`,t=await salla.api.request(s);this.editItem=t.data,this.allowAttachImages&&"product"==this.editType&&this.editItem.images.length&&(this.editItemImages=this.editItem.images.map((a=>({id:`${Math.floor(100+900*Math.random())}`,url:a}))))}async editReview(){const a={};this.editModal.querySelectorAll("[name]").forEach((s=>{const t=salla.helpers.inputData(s.name,s.value,a);a[t.name]=t.value})),a.images&&(a.images=a.images.split(","));const s=`rating/${this.editFeedbackId}`;await salla.api.request(s,a,"put").then((a=>{this.editModal.close(),salla.notify.success(a.message||this.updatedSuccessfullyLabel),setTimeout((()=>{window.location.reload()}),500)}))}async openDeleteModal(a){return this.defaultMode=!1,this.deleteMode=!0,this.deleteFeedbackId=a.feedback_id,this.shouldOpenDeleteModal=!0,new Promise((a=>{setTimeout((()=>{this.deleteModal.open().then((()=>a(!0)))}),50)}))}async deleteReview(){const a=`rating/${this.deleteFeedbackId}`;await salla.api.request(a,null,"delete").then((()=>{this.deleteModal.close(),salla.notify.success(this.deletedSuccessfullyLabel),setTimeout((()=>{window.location.reload()}),500)}))}async close(){return this.modal.close()}handleWizard(){this.steps=this.modal.querySelectorAll(".s-rating-modal-step"),this.dots=this.modal.querySelectorAll(".s-rating-modal-step-dot"),this.showActiveStep()}showActiveStep(a=null){this.currentTab=a||this.steps[this.currentIndex],n.toggleClassIf(".s-rating-modal-step-dot","s-rating-modal-bg-gray","s-rating-modal-bg-primary",(a=>a!=this.dots[this.currentIndex])).toggleClassIf(".s-rating-modal-step","s-rating-modal-active","s-rating-modal-hidden",(a=>a==this.currentTab)),0!==this.currentIndex&&(n.toggleElementClassIf(this.currentTab,"s-rating-modal-unactive","s-rating-modal-hidden",(()=>!0)),setTimeout((()=>n.toggleElementClassIf(this.currentTab,"s-rating-modal-active","s-rating-modal-unactive",(()=>!0))),300));const s=this.steps[this.currentIndex+1]?.dataset.type;this.nextBtn?.setText(s?`${salla.lang.get("pages.rating.rate")} ${salla.lang.get(`pages.rating.${s}`)}`:salla.lang.get("pages.rating.send_ratings")),setTimeout((()=>this.body?.setAttribute("style",`height:${this.currentTab?.offsetHeight}px`)))}previousTab(){this.currentIndex>0&&this.currentIndex--,n.toggleElementClassIf(this.backBtn,"s-rating-modal-unvisiable","block",(()=>0==this.currentIndex)),this.showActiveStep()}submit(){this.submittedBefore()||this.validate(),salla.config.canLeave=!1,this.nextBtn.load().then((()=>this.submittedBefore()||this.sendFeedback())).then((()=>this.currentTab.querySelectorAll("[name],.s-rating-modal-btn-star").forEach((a=>a.setAttribute("disabled",""))))).then((()=>this.currentIndex<this.stepsCount&&this.currentIndex++)).then((()=>this.showActiveStep())).then((()=>n.toggleClassIf("#prev-btn","block","s-rating-modal-unvisiable",(()=>!0)))).finally((()=>{this.nextBtn.stop(),salla.config.canLeave=!0,this.currentIndex==this.stepsCount&&(this.showThankYou(),this.showContactWidget=!1)}))}submittedBefore(){return this.submitted.includes(this.currentIndex)}validate(a=null,s=null){if(!a&&"products"===this.currentTab.dataset.type)return void this.currentTab.querySelectorAll(".rating-outer-form").forEach((a=>this.validate(a,"product")));const t=(a=a||this.currentTab).querySelector(".rating_hidden_input").value,i=a.querySelector(".s-rating-modal-validation-msg");if(s=s||a.dataset.type,!t)throw i.innerHTML=salla.lang.get(`pages.rating.rate_${s}_stars`).replace(" (:item)",""),new Error(i.innerHTML);i.innerHTML=""}sendFeedback(){const a={};if(this.currentTab.querySelectorAll("[name]").forEach((s=>{const t=salla.helpers.inputData(s.name,s.value,a);a[t.name]=t.value})),this.allowAttachImages&&a.products)for(let s in a.products)a.products[s].images&&(a.products[s].images=a.products[s].images.split(","));if(0!=Object.keys(a).length)return a.order_id=this.orderId,a.type=this.currentTab.dataset.type,salla.rating.api[this.currentTab.dataset.type](a).then((a=>(this.submitted.push(this.currentIndex),a)))}showThankYou(){let a=10,s=setInterval((()=>{this.thanksTime.innerHTML="00:0"+a--,a>0||(clearInterval(s),this.thanksTime.remove(),this.close().then((()=>window.location.reload())))}),1e3);this.modal.querySelector(".s-rating-modal-footer").classList.add("s-rating-modal-unvisiable"),this.showActiveStep(this.thanksTab)}getFilepondPlaceholder(){return`<div class="s-rating-modal-filepond-placeholder"><span class="s-rating-modal-filepond-placeholder-icon">${r}</span><p class="s-rating-modal-filepond-placeholder-text">${this.dragAndDropFilesLabel}<br>\n <span> ${this.allowedImagesTypesLabel} <br> ${this.threeImagesMax} </span></p></div>`}getCustomerName(){return`${salla.config.get("user.first_name")||salla.storage.get("user.first_name")||""} ${salla.config.get("user.last_name")||salla.storage.get("user.last_name")||""}`}handleSendEmail(){const a=`${this.contactSubjectLabel} #${this.order.id}`,s=this.contact_body(salla.config.get("store.name"),this.order.id,this.getCustomerName()),t=`mailto:${salla.config.get("store.contacts.email")}?subject=${encodeURIComponent(a)}&body=${encodeURIComponent(s)}`;window.open(t,"_blank")}handleSendWhatsApp(){const a=this.contact_body(salla.config.get("store.name"),this.order.id,this.getCustomerName()),s=`https://wa.me/${salla.config.get("store.contacts.whatsapp")}?text=${encodeURIComponent(a)}`;window.open(s,"_blank")}resetData(a){a.detail||(this.modal?.close(),this.editItem=null,this.editItemImages=[],this.hiddenInputs[1]&&(this.hiddenInputs[1].value=""),this.deleteFeedbackId=null,this.editFeedbackId=null,this.shouldOpenDeleteModal=!1,this.editMode=!1,this.deleteMode=!1,this.defaultMode=!1)}getDeleteModal(){return s("salla-modal",{ref:a=>this.deleteModal=a,width:"xs",onModalVisibilityChanged:a=>this.resetData(a)},s("div",{class:"s-rating-modal-delete-wrapper",ref:a=>this.body=a},s("h3",null,this.confirmDeletionLabel),s("p",null,this.areYouSureLabel),s("div",{class:"s-rating-modal-delete-actions"},s("salla-button",{loaderPosition:"center",onClick:()=>this.deleteReview()},this.confirmDeleteBtn),s("salla-button",{color:"danger",fill:"outline",onClick:()=>this.deleteModal.close()},this.cancelLabel))))}renderUploadedImagesCount(a){const t=this.editMode?this.editItemImages.length:(this.productImages[a]||[]).length;return s("span",{class:"s-rating-modal-upload-count"},salla.lang.choice("pages.rating.images_count",t,{current:t,total:this.MAX_UPLOAD_LIMIT}))}getEditModal(){return s("salla-modal",{ref:a=>this.editModal=a,width:"md",onModalVisibilityChanged:a=>this.resetData(a)},s("div",{class:"s-rating-modal-edit-wrapper",ref:a=>this.body=a},"store"===this.editType&&this.editItem?s("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step","data-type":"store",ref:a=>this.currentTab=a},s("div",{class:"s-rating-modal-rounded-icon"},s("img",{src:salla.config.get("store.logo","https://assets.salla.sa/cp/assets/images/logo-new.png"),alt:"store name",class:"s-rating-modal-store-logo"})),s("h2",{class:"s-rating-modal-title"},salla.lang.get("pages.rating.rate_the_store")),s("div",{class:"s-rating-modal-stars-company"},s("salla-rating-stars",{withLabel:!0,size:"large",editable:!0,value:this.editItem.stars})),s("textarea",{name:"content",value:this.editItem.content,class:"s-rating-modal-comment",placeholder:salla.lang.get("pages.rating.write_store_rate")}),s("small",{class:"s-rating-modal-validation-msg"})):null,"shipping"===this.editType&&this.editItem?s("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step","data-type":"shipping",ref:a=>this.currentTab=a},this.editItem.shipping.logo?s("div",{class:"s-rating-modal-rounded-icon"},s("img",{src:this.editItem.shipping.logo,class:"s-rating-modal-shipping-logo",alt:this.editItem.shipping.name})):s("span",{class:"s-rating-modal-icon",innerHTML:g}),s("div",{class:"s-rating-modal-title"}," ",`${salla.lang.get("pages.rating.rate_shipping")} ${this.editItem.shipping.name}`),s("div",{class:"s-rating-modal-stars-company"},s("salla-rating-stars",{withLabel:!0,size:"large",editable:!0,value:this.editItem.stars})),s("textarea",{name:"content",class:"s-rating-modal-comment",value:this.editItem.content,placeholder:salla.lang.get("pages.rating.write_shipping_rate")}),s("small",{class:"s-rating-modal-validation-msg"})):null,"product"==this.editType&&this.editItem?s("section",{class:"s-rating-modal-step","data-type":"products",ref:a=>this.currentTab=a},s("div",{class:"s-rating-modal-product"},s("div",{class:"rating-outer-form","data-stars-error":salla.lang.get("pages.rating.rate_product_stars")},s("div",{class:"s-rating-modal-product-img-wrap"},s("img",{src:this.editItem.product.image.url,alt:this.editItem.product.name,class:"s-rating-modal-product-img"})),s("div",{class:"s-rating-modal-product-details"},s("div",{class:"s-rating-modal-product-details-main"},s("div",null,s("h3",{class:"s-rating-modal-product-title"}," ",this.editItem.product.name),s("div",{class:"s-rating-modal-stars-product"},s("salla-rating-stars",{withLabel:!0,size:"small",editable:!0,value:this.editItem.stars}))),this.allowAttachImages&&s("salla-button",{class:"s-comments-item-like-btn mt-0",loaderPosition:"center",fill:"outline",size:"small",onClick:()=>this.toggleUploader(1)},s("span",null,this.editItemImages.length?this.editImagesLabel:this.addImagesLabel),s("span",{innerHTML:r}))),s("textarea",{value:this.editItem.content,placeholder:salla.lang.get("pages.rating.write_product_rate"),name:"content",class:"s-rating-modal-comment"}),s("small",{class:"s-rating-modal-validation-msg"}))),this.allowAttachImages&&s("div",{class:"s-rating-modal-uploader is-closed",ref:a=>this.contentRefs[1]=a},s("salla-file-upload",{name:"images",allowMultiple:!0,maxFilesCount:this.MAX_UPLOAD_LIMIT,imagePreviewHeight:117,filePosterHeight:117,"instant-upload":!0,type:"feedback",files:JSON.stringify(this.editItemImages),payloadName:"files[]",id:`file-${this.editItem.product.id}`,title:this.editItem.product.name,instantUpload:!0,accept:"image/png, image/jpeg, image/jpg",url:salla.url.api("upload"),onUploaded:a=>{this.editItemImages=[...this.editItemImages,a.detail],this.hiddenInputs[1].value=this.editItemImages.map((a=>a.url)).join()},onRemoved:a=>{const s=a.detail;s&&(this.editItemImages=this.editItemImages.filter((a=>a.id!==s)),this.hiddenInputs[1].value=this.editItemImages.map((a=>a.url)).join())},labelIdle:this.getFilepondPlaceholder()}),s("input",{type:"hidden",name:"images",value:this.editItem.images.join(","),ref:a=>this.hiddenInputs[1]=a}),this.renderUploadedImagesCount(this.editItem.product.id)))):null,s("div",{class:"s-rating-modal-footer s-rating-modal-footer-end"},s("salla-button",{"loader-position":"center",onClick:()=>this.editReview()},this.editReviewLabel))))}render(){return this.deleteMode?s(t,{class:"s-rating-modal"},this.getDeleteModal()):this.editMode?s(t,{class:"s-rating-modal"},this.getEditModal()):this.defaultMode?s(t,{class:"s-rating-modal"},s("salla-modal",{class:"s-rating-modal-wrap",onModalVisibilityChanged:a=>this.resetData(a),isLoading:!0,width:"md",ref:a=>this.modal=a},s("div",{slot:"loading"},s("div",{class:"s-rating-modal-skeleton"},s("salla-skeleton",{type:"circle",height:"80px",width:"80px"}),s("salla-skeleton",{height:"15px",width:"60%"}),s("salla-skeleton",{height:"10px",width:"30%"}),s("div",{class:"s-rating-modal-skeleton-stars"},[...Array(5)].map((a=>s("div",{key:a,innerHTML:e})))),s("salla-skeleton",{height:"100px",width:"100%"}),s("div",{class:"s-rating-modal-skeleton-footer"},s("salla-skeleton",{height:"40px",width:"30%"})))),!this.hasError&&this.order?[s("div",{class:"s-rating-modal-wrapper",ref:a=>this.body=a},this.order?.testimonials_enabled?s("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"store"},s("div",{class:"s-rating-modal-rounded-icon"},s("img",{src:salla.config.get("store.logo","https://assets.salla.sa/cp/assets/images/logo-new.png"),alt:"store name",class:"s-rating-modal-store-logo"})),s("h2",{class:"s-rating-modal-title"},salla.lang.get("pages.rating.rate_the_store")),s("div",{class:"s-rating-modal-stars-company"},s("salla-rating-stars",{withLabel:!0,size:"large"})),s("textarea",{name:"comment",class:"s-rating-modal-comment",placeholder:salla.lang.get("pages.rating.write_store_rate")}),s("small",{class:"s-rating-modal-validation-msg"})):"",this.order.products_enabled?s("section",{class:"s-rating-modal-step s-rating-modal-hidden","data-type":"products"},this.order.products.map(((a,t)=>s("div",{class:"s-rating-modal-product",key:t},s("div",{class:"rating-outer-form","data-stars-error":salla.lang.get("pages.rating.rate_product_stars")},s("div",{class:"s-rating-modal-product-img-wrap"},s("img",{src:a.product.thumbnail,alt:a.product.name,class:"s-rating-modal-product-img"})),s("div",{class:"s-rating-modal-product-details"},s("div",{class:"s-rating-modal-product-details-main"},s("div",null,s("h3",{class:"s-rating-modal-product-title"}," ",a.product.name),s("div",{class:"s-rating-modal-stars-product"},s("salla-rating-stars",{withLabel:!0,size:"small",name:`products[${t}][rating]`}))),this.allowAttachImages&&s("salla-button",{class:"s-comments-item-like-btn mt-0",loaderPosition:"center",fill:"outline",size:"small",onClick:()=>this.toggleUploader(t)},s("span",null,this.addImagesLabel),s("span",{innerHTML:r}))),s("input",{type:"hidden",name:`products[${t}][product_id]`,value:a.product.id}),s("textarea",{placeholder:salla.lang.get("pages.rating.write_product_rate"),name:`products[${t}][comment]`,class:"s-rating-modal-comment"}),s("small",{class:"s-rating-modal-validation-msg"}))),this.allowAttachImages&&s("div",{class:"s-rating-modal-uploader is-closed",ref:a=>this.contentRefs[t]=a},s("salla-file-upload",{name:"image",maxFilesCount:this.MAX_UPLOAD_LIMIT,imagePreviewHeight:117,"instant-upload":!0,type:"feedback",payloadName:"files[]",id:`file-${a.product.id}`,title:a.product.name,allowMultiple:!0,instantUpload:!0,accept:"image/png, image/jpeg, image/jpg",url:salla.url.api("upload"),onUploaded:s=>{this.productImages={...this.productImages,[a.product.id]:[...this.productImages[a.product.id]||[],s.detail]},this.hiddenInputs[t].value=this.productImages[a.product.id].map((a=>a.url)).join(",")},onRemoved:s=>{const i=s.detail;i&&this.productImages[a.product.id]&&(this.productImages={...this.productImages,[a.product.id]:this.productImages[a.product.id].filter((a=>a.id!==i))},this.hiddenInputs[t].value=this.productImages[a.product.id].map((a=>a.url)).join(","))},labelIdle:this.getFilepondPlaceholder()}),s("input",{type:"hidden",name:`products[${t}][images]`,value:(this.productImages[a.product.id]||[]).map((a=>a.url)).join(","),ref:a=>this.hiddenInputs[t]=a}),this.renderUploadedImagesCount(a.product.id)))))):"",this.order.shipping_enabled&&this.order.shipping?.company?s("div",{class:"rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden","data-type":"shipping"},s("input",{type:"hidden",name:"shipping_company_id",value:this.order.shipping.company.id}),this.order.shipping.company.logo?s("div",{class:"s-rating-modal-rounded-icon"},s("img",{src:this.order.shipping.company.logo,class:"s-rating-modal-shipping-logo",alt:this.order.shipping.company.name})):s("span",{class:"s-rating-modal-icon",innerHTML:g}),s("div",{class:"s-rating-modal-title"}," ",`${salla.lang.get("pages.rating.rate_shipping")} ${this.order.shipping.company.name}`),s("div",{class:"s-rating-modal-stars-company"},s("salla-rating-stars",{withLabel:!0,size:"large"})),s("textarea",{name:"comment",class:"s-rating-modal-comment",placeholder:salla.lang.get("pages.rating.write_shipping_rate")}),s("small",{class:"s-rating-modal-validation-msg"})):"",s("div",{class:"s-rating-modal-thanks s-rating-modal-hidden",ref:a=>this.thanksTab=a},s("span",{class:"s-rating-modal-icon",innerHTML:l}),s("h3",{class:"s-rating-modal-thanks-title"},salla.lang.get("pages.rating.thanks")),s("div",{class:"s-rating-modal-thanks-msg",innerHTML:this.order.thanks_message}),s("time",{class:"s-rating-modal-thanks-time",ref:a=>this.thanksTime=a}))),this.allowContactSupport&&this.showContactWidget&&(salla.config.get("store.contacts.whatsapp")||salla.config.get("store.contacts.email"))?s("div",{class:"s-rating-modal-contact"},s("p",null,this.contactUsLabel),s("div",{class:"s-rating-modal-contact-icons"},salla.config.get("store.contacts.whatsapp")&&s("span",{onClick:()=>this.handleSendWhatsApp(),innerHTML:o}),salla.config.get("store.contacts.email")&&s("span",{onClick:()=>this.handleSendEmail(),innerHTML:d}))):"",s("div",{class:"s-rating-modal-footer"},s("button",{ref:a=>this.backBtn=a,onClick:()=>this.previousTab(),class:"s-rating-modal-btn s-rating-modal-unvisiable"},salla.lang.get("common.elements.back")),this.stepsCount>1?s("ul",{class:"s-rating-modal-dots"},[0,1,2].slice(0,this.stepsCount).map((a=>s("li",{key:a,class:"s-rating-modal-bg-gray s-rating-modal-step-dot"})))):"",s("salla-button",{"loader-position":"center",ref:a=>this.nextBtn=a,onClick:()=>this.submit()},salla.lang.get("common.elements.next")))]:s("salla-placeholder",{alignment:"center"}))):void 0}componentWillLoad(){salla.event.on("rating::open",(()=>this.open())),salla.event.on("rating::edit",(a=>this.openEditModal(a))),salla.event.on("rating::delete",(a=>this.openDeleteModal(a)))}componentDidLoad(){salla.event.dispatch("rating::ready",this)}get host(){return i(this)}};m.style="";export{m as salla_rating_modal}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as s,h as t,a}from"./p-
|
|
4
|
+
import{r as s,h as t,a}from"./p-DygKr0gG.js";import{a as i}from"./p-CgtvEd63.js";const e=class{constructor(t){s(this,t),this.currentSlug=salla.config.get("page.slug"),salla.onReady((()=>{this.currentSlug=salla.config.get("page.slug")})),this.advSlot=this.host.querySelector('[slot="adv"]')?.innerHTML||'<div class="s-advertisement-content"><span class="s-advertisement-content-main">{iconElem}{urlElem}</span>{closeElem}</div>\n '}isNotVisible(s){return!(salla.config.isDebug()||salla.helpers.isPreview()||!salla.storage.get(`statusAd-${s.id}`))}setCanDisplayFlag(s,t){t||(salla.storage.set(`statusAd-${s.id}`,"dismissed"),i({targets:this.host,opacity:[1,0],duration:300,height:[this.host.clientHeight,0],easing:"easeInOutQuad"}))}render(){if((!Array.isArray(this.advertisements)||this.advertisements.length)&&this.advertisements)return this.advertisements.map((s=>t("div",{class:{"s-hidden":this.isNotVisible(s),"s-advertisement":!0},"data-id":s.id,style:{"background-color":s.colors.bg,color:s.colors.text}},t("div",{id:"adv-slot",innerHTML:this.advSlot.replace("{iconElem}",`<i class="s-advertisement-content-icon ${s.icon}"></i>`).replace("{urlElem}",s.url?`<a href="${s.url}" target="${s.target}">${s.description}</a>`:s.description).replace("{closeElem}",'<button class="s-advertisement-action" aria-label="close-alert"><i class="sicon-cancel"></i></button>').replace("{icon}",s.icon).replace("{url}",s.url).replace("{target}",s.target).replace("{description}",s.description).replace("{bg_color}",s.colors.bg).replace("{text_color}",s.colors.text)}))))}componentWillLoad(){return(async()=>{if(salla.config.isMobileApp())return[];const s=salla.config.isDebug()||salla.helpers.isPreview();await new Promise((s=>salla.onReady(s)));const t=s?null:this.currentSlug,a=await salla.api.advertisement.fetch(t);if(Array.isArray(a.data)){const t=a.data;this.advertisements=s?t:t.filter((s=>!salla.storage.get(`statusAd-${s.id}`)))}else this.advertisements=[];return this.advertisements})()}componentDidRender(){Array.isArray(this.advertisements)&&!this.advertisements.length||!this.advertisements||(setTimeout((()=>{let s=this.host.querySelector(".s-advertisement-action");s&&s.addEventListener("click",(()=>this.setCanDisplayFlag(this.advertisements[0],!1)))})),this.host.querySelectorAll("#adv-slot").forEach((s=>s?.replaceWith(s?.firstChild))),this.host.querySelector('[slot="adv"]')?.remove(),i({targets:this.host,opacity:[0,1],duration:300,height:[0,this.host.clientHeight],easing:"easeInOutQuad"}))}get host(){return a(this)}};e.style=":host{display:block}";export{e as salla_advertisement}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import{r as s,h as t,H as i,a as e,c as a}from"./p-BQQ2x3w_.js";import{A as r,a as l}from"./p-Vqpj4CWE.js";import{C as o}from"./p-BsLF_HK7.js";import{C as n}from"./p-BV4kqbdL.js";import{H as d}from"./p-CHf8XdiS.js";import"./p-CgtvEd63.js";const h=class{constructor(t){s(this,t),this.collapsible=!0,this.bordered=!1,this.size="md",this.collapsed=!0,this.dir=document.dir||"rtl"}directionChangedHandler(s){this.dir=s.detail.dir}handleCollapse(s){this.collapsed=s.detail.payload.collapsed}setcollapsibleProp(){const s=this.host.querySelector("salla-accordion-head");this.collapsible&&s&&(s.setAttribute("collapsible","true"),s.setAttribute("collapsed",this.collapsed.toString()))}componentDidRender(){this.setcollapsibleProp();const s=this.host.querySelector("salla-accordion-body");this.collapsible&&(this.host.setAttribute("data-collapsed",this.collapsed.toString()),s?.setAttribute("data-collapsed",this.collapsed.toString()))}render(){return t(i,{key:"fb12197f13d8836304bfebb14400c79c8c4d31f0",class:`s-accordion-wrapper ${this.dir} ${this.bordered?"s-accordion-wrapper-bordered":""} ${this.size?`size-${this.size}`:""}`,"data-collapsed":this.collapsed.toString()},t("slot",{key:"460e8d7238bf9f014fe0bbb6c0da592c8cb3e15e"}))}get host(){return e(this)}};h.style="";const c=class{constructor(t){s(this,t),this.sessionStorageKey="breadcrumb_snapshot",this.itemSlot=this.host.querySelector('[slot="item"]')?.outerHTML||'<li class="s-breadcrumb-item"><a href={url}>{title}</a></li>',this.iconSlot=this.host.querySelector('[slot="icon"]')?.outerHTML}componentWillLoad(){return new Promise((s=>salla.onReady((()=>salla.lang.onLoaded(s))))).then((()=>{if(salla.url.is_page("index"))throw new Error("salla-breadcrumb:: breadcrumb not supported on home page")})).then((()=>{if(!salla.config.get("theme.settings.is_breadcrumbs_enabled",!0))throw new Error("salla-breadcrumb:: merchant disabled the feature")})).then((()=>{const s=salla.config.get("page");if(!s||!s.slug)return salla.logger.error('salla-breadcrumbs:: page object not existed on salla.config.get("page")!'),void(this.breadcrumbs=[]);let t=this.getSessionBreadcrumbs(),i=t[t.length-1];return"product.single"===s.slug&&t&&t.length>0&&i?.url&&s.parent?.url&&i.url===s.parent.url?(t.push({title:s.title,url:s.url}),this.breadcrumbs=this.setBreadcrumbsFromArray(t),this.storeBreadcrumbSnapshot()):t&&t.length>0?this.isNewPage(s,t)?(this.breadcrumbs=this.generateBreadcrumbs(s),this.storeBreadcrumbSnapshot()):this.breadcrumbs=this.setBreadcrumbsFromArray(t):(this.breadcrumbs=this.generateBreadcrumbs(s),this.storeBreadcrumbSnapshot()),this.breadcrumbs?.length&&(this.breadcrumbs[this.breadcrumbs.length-1].is_last=!0),this.breadcrumbs})).catch((s=>{salla.logger.error("salla-breadcrumb:: unexpected error!",s),this.breadcrumbs=[]}))}getSessionBreadcrumbs(){return"search-bar"===new URLSearchParams(window.location.search).get("from")?[]:JSON.parse(sessionStorage.getItem(this.sessionStorageKey)||"[]")}isNewPage(s,t){const i=t[t.length-1];return i?.url!==s.url}setBreadcrumbsFromArray(s){return s.map(((t,i)=>({...t,is_last:i===s.length-1})))}sanitizeBreadcrumbTitle(s,t=1){return s.includes("|")?s.split("|").map((s=>s.trim()))[t]:s.trim()}generateBreadcrumbs(s){let t=[];if("product.single"===s.slug){const t=this.getSessionBreadcrumbs(),i=t[t.length-1];if(t.length>0&&i?.url&&s.parent?.url&&i.url===s.parent.url)return this.setBreadcrumbsFromArray([...t,{title:s.title,url:s.url}])}let i=s;for(;i;)i.title&&t.unshift({title:i.title,url:i.url}),i=i.parent;return s.slug.includes("customer")&&"customer.profile"!==s.slug&&t.unshift({title:salla.lang.get("common.titles.profile"),url:salla.url.get("profile")}),s.slug.includes("blog")&&t.unshift({title:salla.lang.get("blocks.footer.blog"),url:salla.url.get("blog")}),"brands.single"===s.slug&&t.unshift({title:salla.lang.get("common.titles.brands"),url:salla.url.get("brands")}),s.title||"loyalty"!==s.slug||t.unshift({title:salla.lang.get("common.titles.loyalty_program"),url:salla.url.get("loyalty")}),t.unshift({title:salla.lang.get("common.titles.home"),url:salla.url.get("")}),t}storeBreadcrumbSnapshot(){try{const s=salla.config.get("page");if("product.single"===s?.slug)return;const t=[...this.breadcrumbs],i=t.length-1;i>=0&&(t[i].url=window.location.href);const e=JSON.stringify(t);sessionStorage.setItem(this.sessionStorageKey,e)}catch(s){salla.logger.error("salla-breadcrumb:: Failed to store breadcrumb snapshot in sessionStorage.",s)}}render(){return this.breadcrumbs.length<=1?(salla.log("salla-breadcrumb:: There is no breadcrumbs!"),null):t("ol",{class:{"s-breadcrumb-wrapper":!0,"s-breadcrumb-dark":salla.url.is_page("loyalty"),"s-breadcrumb-primary-reverse":salla.config.get("page.slug").includes("customer")}},this.breadcrumbs.map((s=>{const i="product.single"===salla.config.get("page.slug")&&s.is_last?s.title:this.sanitizeBreadcrumbTitle(s.title),e=this.itemSlot.replace(/\{url\}/g,s.url).replace(/\{title\}/g,i);return[t("div",{class:"s-breadcrumb-slot",innerHTML:e}),this.getArrowDomForItem(s)]})))}getArrowDomForItem(s){if(s.is_last)return"";let i=this.iconSlot||(salla.config.get("theme.is_rtl",!0)?r:l);return t("li",{class:"s-breadcrumb-arrow"},t("div",{class:{"s-breadcrumb-icon-slot":!0,"s-breadcrumb-default-icon":!this.iconSlot},innerHTML:i}))}componentDidRender(){this.host.querySelectorAll(".s-breadcrumb-slot").forEach((s=>s.replaceWith(s.firstChild))),this.host.querySelectorAll(".s-breadcrumb-icon-slot.s-breadcrumb-default-icon").forEach((s=>s.replaceWith(s.querySelector("svg")))),this.host.querySelector('[slot="item"]')?.remove(),this.host.querySelector('[slot="icon"]')?.remove();let s=this.host.querySelectorAll(".s-breadcrumb-item")[this.breadcrumbs.length-1]?.querySelector("a");s&&s.replaceWith(s.firstChild)}get host(){return e(this)}};c.style=":host{display:block}";const u=class{constructor(t){s(this,t),this.shape="btn",this.color="primary",this.fill="solid",this.size="medium",this.width="normal",this.loading=!1,this.disabled=!1,this.loaderPosition="after",this.type="button"}async load(){return"center"==this.loaderPosition&&this.text.classList.add("s-button-hide"),this.host.setAttribute("loading",""),this.host}async stop(){return this.host.removeAttribute("loading"),this.host.querySelector("button").removeAttribute("loading"),"center"==this.loaderPosition&&this.text.classList.remove("s-button-hide"),this.host}async setText(s){return this.text.innerHTML=s,this.host}async disable(){return this.host.setAttribute("disabled",""),this.host}async enable(){return this.host.removeAttribute("disabled"),this.host}getBtnAttributes(){const s={};for(let t=0;t<this.host.attributes.length;t++)["color","fill","size","width","id"].includes(this.host.attributes[t].name)||(s[this.host.attributes[t].name]=this.host.attributes[t].value);s.type=s.type||this.type;const t=s.class||"";return s.class=t+" s-button-element s-button-"+this.shape+" s-button-"+("none"==this.fill?"fill-none":this.fill)+("medium"!=this.size?" s-button-"+this.size:"")+("normal"!=this.width?" s-button-"+this.width:"")+("link"==this.shape?" s-button-"+this.color+"-link":"")+("link"!=this.shape&&"outline"!=this.fill?" s-button-"+this.color:"")+("outline"==this.fill?" s-button-"+this.color+"-outline":"")+(this.disabled?" s-button-disabled ":"")+("icon"==this.shape?" s-button-loader-center":" s-button-loader-"+this.loaderPosition),s["aria-label"]||s["aria-labelledby"]||(this.host.textContent||"").trim()||(t.includes("btn--wishlist")||t.includes("wishlist")?s["aria-label"]=salla.lang.getWithDefault("pages.products.add_to_wishlist","Add or remove to wishlist"):"icon"===this.shape&&console.warn("Icon button is missing aria-label attribute")),s}button(){return t("button",{...this.getBtnAttributes(),disabled:this.disabled},t("span",{class:"s-button-text",ref:s=>this.text=s},t("slot",null)),this.loading?t("span",{class:"s-button-loader"}):"")}render(){return this.host.closest(".swiper-slide")?.classList.contains("swiper-slide-duplicate")?"":t(i,{class:"s-button-wrap"},this.href?t("a",{href:this.href},this.button()):this.button())}get host(){return e(this)}};u.style="";var m='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>alert-engine</title>\n<path d="M16 18.673c-0.736 0-1.333 0.604-1.333 1.34s0.597 1.333 1.333 1.333 1.333-0.597 1.333-1.333v-0.013c0-0.736-0.597-1.327-1.333-1.327zM2.667 16c0-3.092 1.083-6.105 3.047-8.484 0.469-0.568 0.389-1.408-0.179-1.877-0.568-0.468-1.408-0.388-1.877 0.179-2.359 2.857-3.657 6.473-3.657 10.183s1.299 7.325 3.657 10.183c0.264 0.319 0.645 0.484 1.029 0.484 0.299 0 0.6-0.1 0.848-0.305 0.568-0.469 0.648-1.309 0.179-1.877-1.964-2.379-3.047-5.392-3.047-8.484zM16 10.667c-0.736 0-1.333 0.597-1.333 1.333v4c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-4c0-0.736-0.597-1.333-1.333-1.333zM16 5.333c-5.881 0-10.667 4.785-10.667 10.667s4.785 10.667 10.667 10.667 10.667-4.785 10.667-10.667-4.785-10.667-10.667-10.667zM16 24c-4.412 0-8-3.588-8-8s3.588-8 8-8 8 3.588 8 8-3.588 8-8 8zM28.343 5.817c-0.469-0.567-1.307-0.647-1.877-0.179-0.568 0.469-0.648 1.309-0.179 1.877 1.964 2.379 3.047 5.392 3.047 8.484s-1.083 6.105-3.047 8.484c-0.469 0.568-0.389 1.408 0.179 1.877 0.249 0.205 0.549 0.305 0.848 0.305 0.384 0 0.765-0.165 1.028-0.484 2.36-2.857 3.659-6.473 3.659-10.183s-1.299-7.325-3.657-10.183z"></path>\n</svg>\n';const b=class{constructor(t){s(this,t),this.drawerVisibilityChanged=a(this,"drawerVisibilityChanged"),this.isClosable=!0,this.width="md",this.position="right",this.visible=!1,this.hasSkeleton=!1,this.isLoading=!1,this.subTitleFirst=!1,this.noPadding=!1,this.subTitle="",this.centered=!1,this.iconStyle=void 0,salla.event.on("drawer::open",(s=>s==this.host.id&&this.open())),salla.event.on("drawer::close",(s=>s==this.host.id&&this.close())),this.drawerTitle=this.host.getAttribute("drawer-title")}handleVisible(s){if(!s)return this.drawerVisibilityChanged.emit(!1),void this.toggleDrawer(!1);this.drawerVisibilityChanged.emit(!0),this.host.classList.remove("s-hidden"),setTimeout((()=>this.toggleDrawer(!0)))}handleKeyUp(s){"Escape"===s.key&&this.closeDrawer()}async open(){return this.host.setAttribute("visible",""),this.handleAutoFocus(),this.host}async close(){return this.host.removeAttribute("visible"),this.host}async setTitle(s){return this.drawerTitle=s,this.host}async loading(){return this.isLoading=!0,this.host}async stopLoading(){return this.isLoading=!1,this.host}handleAutoFocus(){const s=this.host.querySelector("input, textarea, select");s&&setTimeout((()=>{s.focus()}),100)}toggleDrawer(s){const t=this.host.querySelector(".s-drawer-body");d.toggleElementClassIf(t,"s-drawer-entering","s-drawer-leaving",(()=>s)).toggleElementClassIf(this.overlay,"s-drawer-entering","s-drawer-overlay-leaving",(()=>s)).toggleElementClassIf(document.body,"drawer-is-open","drawer-is-closed",(()=>s)),s||setTimeout((()=>this.host.classList.add("s-hidden")),350)}closeDrawer(s){this.isClosable&&(salla.event.dispatch("drawer::close",{reason:s}),this.host.removeAttribute("visible"))}iconBlockClasses(){return{"s-drawer-icon":!0,"s-drawer-bg-error":"error"==this.iconStyle,"s-drawer-bg-success":"success"==this.iconStyle,"s-drawer-bg-normal":!this.iconStyle,"s-drawer-bg-primary":"primary"==this.iconStyle}}getWidth(){return this.isLoading?this.hasSkeleton?"md":"xs":this.width}render(){return this.host.id=this.host.id||"salla-drawer",this.isLoading?t(i,{class:"salla-drawer s-drawer s-drawer-container s-hidden","aria-modal":"true",role:"dialog",onKeyUp:s=>this.handleKeyUp(s)},t("div",{class:"s-drawer-overlay s-drawer-overlay-leaving",ref:s=>this.overlay=s,onClick:()=>this.closeDrawer("backdropClick")}),t("div",{class:"s-drawer-wrapper s-drawer-wrapper-"+this.position},t("div",{class:"s-drawer-body flex justify-center s-drawer-leaving s-drawer-"+this.position+" s-drawer-"+this.getWidth()+(this.noPadding?" s-drawer-nopadding":" s-drawer-padding")},t("slot",{name:"loading"},t("salla-loading",null)),t("div",{class:"s-hidden"},t("slot",null))))):t(i,{class:"salla-drawer s-drawer s-drawer-container s-hidden","aria-modal":"true",role:"dialog"},t("div",{class:"s-drawer-overlay s-drawer-overlay-leaving",ref:s=>this.overlay=s,onClick:()=>this.closeDrawer("backdropClick")}),t("div",{class:"s-drawer-wrapper s-drawer-wrapper-"+this.position},t("div",{class:"s-drawer-body s-drawer-leaving s-drawer-"+this.position+" s-drawer-"+this.getWidth()+(this.noPadding?" s-drawer-nopadding":" s-drawer-padding")},t("div",{class:{"s-drawer-header":!0,"s-drawer-is-center":this.centered}},this.isClosable?t("button",{class:"s-drawer-close",onClick:()=>this.closeDrawer("closeButtonClick"),type:"button"},t("span",{innerHTML:o})):"",this.drawerTitle||this.subTitle?t("div",{class:"s-drawer-header-inner"},t("slot",{name:"icon"},this.iconStyle?t("div",{class:this.iconBlockClasses(),innerHTML:"error"==this.iconStyle?m:n}):""),t("div",{class:"s-drawer-header-content"},this.drawerTitle?t("div",{class:{"s-drawer-title":!0,"s-drawer-title-below":this.subTitleFirst},innerHTML:this.drawerTitle}):"",this.subTitle?t("p",{class:{"s-drawer-sub-title":!0},innerHTML:this.subTitle}):"")):""),t("slot",null),t("slot",{name:"footer"}))))}componentDidLoad(){document.body.append(this.host)}get host(){return e(this)}static get watchers(){return{visible:["handleVisible"]}}};b.style="";const p=class{constructor(t){s(this,t),this.size=32,this.width=2,this.color=void 0,this.bgColor="#e5e7eb"}render(){return t(i,{key:"4e2a9d729f0b716566b0d5c71aef6aae23e7fc4b",class:"s-loading-container"},t("svg",{key:"87f13687b423e1e07489a2c97da5a9ba06baf370","aria-hidden":"true",style:{width:`${this.size}px`,height:`${this.size}px`,fill:this.color,color:this.bgColor},class:"s-loading",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t("path",{key:"695143716aa79350944941eda892618ae5e0565a",d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),t("path",{key:"7a37e9b42f4d9f7ee7848f9af78b50307d7dcd79",d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})))}};p.style=".s-loading{animation:spin 1s linear infinite;fill:var(--color-primary)}.s-loading-container{display:flex;justify-content:center;align-items:center}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";const g=class{constructor(t){s(this,t),this.modalVisibilityChanged=a(this,"modalVisibilityChanged"),this.isClosable=!0,this.width="md",this.position="middle",this.visible=!1,this.hasSkeleton=!1,this.isLoading=!1,this.subTitleFirst=!1,this.noPadding=!1,this.subTitle="",this.centered=!1,this.iconStyle=void 0,salla.event.on("modal::open",(s=>s==this.host.id&&this.open())),salla.event.on("modal::close",(s=>s==this.host.id&&this.close())),this.modalTitle=this.host.getAttribute("modal-title")}handleVisible(s){if(!s)return this.modalVisibilityChanged.emit(!1),void this.toggleModal(!1);this.modalVisibilityChanged.emit(!0),this.host.classList.remove("s-hidden"),setTimeout((()=>this.toggleModal(!0)))}handleKeyUp(s){"KeyUp"===s.key&&this.closeModal()}async open(){return this.host.setAttribute("visible",""),this.handleAutoFocus(),this.host}async close(){return this.host.removeAttribute("visible"),this.host}async setTitle(s){return this.modalTitle=s,this.host}async loading(){return this.isLoading=!0,this.host}async stopLoading(){return this.isLoading=!1,this.host}handleAutoFocus(){const s=this.host.querySelector("input, textarea, select");s&&setTimeout((()=>{s.focus()}),100)}toggleModal(s){const t=this.host.querySelector(".s-modal-body");d.toggleElementClassIf(t,"s-modal-entering","s-modal-leaving",(()=>s)).toggleElementClassIf(this.overlay,"s-modal-entering","s-modal-overlay-leaving",(()=>s)).toggleElementClassIf(document.body,"modal-is-open","modal-is-closed",(()=>s)),s||setTimeout((()=>this.host.classList.add("s-hidden")),350)}closeModal(s){this.isClosable&&(salla.event.dispatch("modal::close",{reason:s}),this.host.removeAttribute("visible"))}iconBlockClasses(){return{"s-modal-icon":!0,"s-modal-bg-error":"error"==this.iconStyle,"s-modal-bg-success":"success"==this.iconStyle,"s-modal-bg-normal":!this.iconStyle,"s-modal-bg-primary":"primary"==this.iconStyle}}getWidth(){return this.isLoading?this.hasSkeleton?"md":"xs":this.width}render(){return this.host.id=this.host.id||"salla-modal",this.isLoading?t(i,{class:"salla-modal s-modal s-modal-container s-hidden","aria-modal":"true",role:"dialog",onKeyUp:s=>this.handleKeyUp(s)},t("div",{class:"s-modal-overlay",ref:s=>this.overlay=s,onClick:()=>this.closeModal("backdropClick")}),t("div",{class:"s-modal-wrapper"},t("span",{class:"s-modal-spacer s-modal-align-"+this.position},""),t("div",{class:"s-modal-body s-modal-align-"+this.position+" s-modal-"+this.getWidth()+(this.noPadding?" s-modal-nopadding":" s-modal-padding")},t("slot",{name:"loading"},t("salla-loading",null)),t("div",{class:"s-hidden"},t("slot",null))))):t(i,{class:"salla-modal s-modal s-modal-container s-hidden","aria-modal":"true",role:"dialog"},t("div",{class:"s-modal-overlay",ref:s=>this.overlay=s,onClick:()=>this.closeModal("backdropClick")}),t("div",{class:"s-modal-wrapper"},t("span",{class:"s-modal-spacer s-modal-align-"+this.position},""),t("div",{class:"s-modal-body s-modal-align-"+this.position+" s-modal-"+this.getWidth()+(this.noPadding?" s-modal-nopadding":" s-modal-padding")},t("div",{class:{"s-modal-header":!0,"s-modal-is-center":this.centered}},this.isClosable?t("button",{class:"s-modal-close",onClick:()=>this.closeModal("closeButtonClick"),type:"button"},t("span",{innerHTML:o})):"",this.modalTitle||this.subTitle?t("div",{class:"s-modal-header-inner"},t("slot",{name:"icon"},this.iconStyle?t("div",{class:this.iconBlockClasses(),innerHTML:"error"==this.iconStyle?m:n}):""),t("div",{class:"s-modal-header-content"},this.modalTitle?t("div",{class:{"s-modal-title":!0,"s-modal-title-below":this.subTitleFirst},innerHTML:this.modalTitle}):"",this.subTitle?t("p",{class:{"s-modal-sub-title":!0},innerHTML:this.subTitle}):"")):""),t("slot",null),t("slot",{name:"footer"}))))}componentDidLoad(){document.body.append(this.host)}get host(){return e(this)}static get watchers(){return{visible:["handleVisible"]}}};g.style="@media screen and (max-width: 470px){.modal-is-open{position:fixed;width:100%}}";export{h as salla_accordion,c as salla_breadcrumb,u as salla_button,b as salla_drawer,p as salla_loading,g as salla_modal}
|
|
4
|
+
import{r as s,h as t,H as i,a as e,c as a}from"./p-DygKr0gG.js";import{A as r,a as l}from"./p-Vqpj4CWE.js";import{C as o}from"./p-BsLF_HK7.js";import{C as n}from"./p-BV4kqbdL.js";import{H as d}from"./p-CHf8XdiS.js";import"./p-CgtvEd63.js";const h=class{constructor(t){s(this,t),this.collapsible=!0,this.bordered=!1,this.size="md",this.collapsed=!0,this.dir=document.dir||"rtl"}directionChangedHandler(s){this.dir=s.detail.dir}handleCollapse(s){this.collapsed=s.detail.payload.collapsed}setcollapsibleProp(){const s=this.host.querySelector("salla-accordion-head");this.collapsible&&s&&(s.setAttribute("collapsible","true"),s.setAttribute("collapsed",this.collapsed.toString()))}componentDidRender(){this.setcollapsibleProp();const s=this.host.querySelector("salla-accordion-body");this.collapsible&&(this.host.setAttribute("data-collapsed",this.collapsed.toString()),s?.setAttribute("data-collapsed",this.collapsed.toString()))}render(){return t(i,{key:"fb12197f13d8836304bfebb14400c79c8c4d31f0",class:`s-accordion-wrapper ${this.dir} ${this.bordered?"s-accordion-wrapper-bordered":""} ${this.size?`size-${this.size}`:""}`,"data-collapsed":this.collapsed.toString()},t("slot",{key:"460e8d7238bf9f014fe0bbb6c0da592c8cb3e15e"}))}get host(){return e(this)}};h.style="";const c=class{constructor(t){s(this,t),this.sessionStorageKey="breadcrumb_snapshot",this.itemSlot=this.host.querySelector('[slot="item"]')?.outerHTML||'<li class="s-breadcrumb-item"><a href={url}>{title}</a></li>',this.iconSlot=this.host.querySelector('[slot="icon"]')?.outerHTML}componentWillLoad(){return new Promise((s=>salla.onReady((()=>salla.lang.onLoaded(s))))).then((()=>{if(salla.url.is_page("index"))throw new Error("salla-breadcrumb:: breadcrumb not supported on home page")})).then((()=>{if(!salla.config.get("theme.settings.is_breadcrumbs_enabled",!0))throw new Error("salla-breadcrumb:: merchant disabled the feature")})).then((()=>{const s=salla.config.get("page");if(!s||!s.slug)return salla.logger.error('salla-breadcrumbs:: page object not existed on salla.config.get("page")!'),void(this.breadcrumbs=[]);let t=this.getSessionBreadcrumbs(),i=t[t.length-1];return"product.single"===s.slug&&t&&t.length>0&&i?.url&&s.parent?.url&&i.url===s.parent.url?(t.push({title:s.title,url:s.url}),this.breadcrumbs=this.setBreadcrumbsFromArray(t),this.storeBreadcrumbSnapshot()):t&&t.length>0?this.isNewPage(s,t)?(this.breadcrumbs=this.generateBreadcrumbs(s),this.storeBreadcrumbSnapshot()):this.breadcrumbs=this.setBreadcrumbsFromArray(t):(this.breadcrumbs=this.generateBreadcrumbs(s),this.storeBreadcrumbSnapshot()),this.breadcrumbs?.length&&(this.breadcrumbs[this.breadcrumbs.length-1].is_last=!0),this.breadcrumbs})).catch((s=>{salla.logger.error("salla-breadcrumb:: unexpected error!",s),this.breadcrumbs=[]}))}getSessionBreadcrumbs(){return"search-bar"===new URLSearchParams(window.location.search).get("from")?[]:JSON.parse(sessionStorage.getItem(this.sessionStorageKey)||"[]")}isNewPage(s,t){const i=t[t.length-1];return i?.url!==s.url}setBreadcrumbsFromArray(s){return s.map(((t,i)=>({...t,is_last:i===s.length-1})))}sanitizeBreadcrumbTitle(s,t=1){return s.includes("|")?s.split("|").map((s=>s.trim()))[t]:s.trim()}generateBreadcrumbs(s){let t=[];if("product.single"===s.slug){const t=this.getSessionBreadcrumbs(),i=t[t.length-1];if(t.length>0&&i?.url&&s.parent?.url&&i.url===s.parent.url)return this.setBreadcrumbsFromArray([...t,{title:s.title,url:s.url}])}let i=s;for(;i;)i.title&&t.unshift({title:i.title,url:i.url}),i=i.parent;return s.slug.includes("customer")&&"customer.profile"!==s.slug&&t.unshift({title:salla.lang.get("common.titles.profile"),url:salla.url.get("profile")}),s.slug.includes("blog")&&t.unshift({title:salla.lang.get("blocks.footer.blog"),url:salla.url.get("blog")}),"brands.single"===s.slug&&t.unshift({title:salla.lang.get("common.titles.brands"),url:salla.url.get("brands")}),s.title||"loyalty"!==s.slug||t.unshift({title:salla.lang.get("common.titles.loyalty_program"),url:salla.url.get("loyalty")}),t.unshift({title:salla.lang.get("common.titles.home"),url:salla.url.get("")}),t}storeBreadcrumbSnapshot(){try{const s=salla.config.get("page");if("product.single"===s?.slug)return;const t=[...this.breadcrumbs],i=t.length-1;i>=0&&(t[i].url=window.location.href);const e=JSON.stringify(t);sessionStorage.setItem(this.sessionStorageKey,e)}catch(s){salla.logger.error("salla-breadcrumb:: Failed to store breadcrumb snapshot in sessionStorage.",s)}}render(){return this.breadcrumbs.length<=1?(salla.log("salla-breadcrumb:: There is no breadcrumbs!"),null):t("ol",{class:{"s-breadcrumb-wrapper":!0,"s-breadcrumb-dark":salla.url.is_page("loyalty"),"s-breadcrumb-primary-reverse":salla.config.get("page.slug").includes("customer")}},this.breadcrumbs.map((s=>{const i="product.single"===salla.config.get("page.slug")&&s.is_last?s.title:this.sanitizeBreadcrumbTitle(s.title),e=this.itemSlot.replace(/\{url\}/g,s.url).replace(/\{title\}/g,i);return[t("div",{class:"s-breadcrumb-slot",innerHTML:e}),this.getArrowDomForItem(s)]})))}getArrowDomForItem(s){if(s.is_last)return"";let i=this.iconSlot||(salla.config.get("theme.is_rtl",!0)?r:l);return t("li",{class:"s-breadcrumb-arrow"},t("div",{class:{"s-breadcrumb-icon-slot":!0,"s-breadcrumb-default-icon":!this.iconSlot},innerHTML:i}))}componentDidRender(){this.host.querySelectorAll(".s-breadcrumb-slot").forEach((s=>s.replaceWith(s.firstChild))),this.host.querySelectorAll(".s-breadcrumb-icon-slot.s-breadcrumb-default-icon").forEach((s=>s.replaceWith(s.querySelector("svg")))),this.host.querySelector('[slot="item"]')?.remove(),this.host.querySelector('[slot="icon"]')?.remove();let s=this.host.querySelectorAll(".s-breadcrumb-item")[this.breadcrumbs.length-1]?.querySelector("a");s&&s.replaceWith(s.firstChild)}get host(){return e(this)}};c.style=":host{display:block}";const u=class{constructor(t){s(this,t),this.shape="btn",this.color="primary",this.fill="solid",this.size="medium",this.width="normal",this.loading=!1,this.disabled=!1,this.loaderPosition="after",this.type="button"}async load(){return"center"==this.loaderPosition&&this.text.classList.add("s-button-hide"),this.host.setAttribute("loading",""),this.host}async stop(){return this.host.removeAttribute("loading"),this.host.querySelector("button").removeAttribute("loading"),"center"==this.loaderPosition&&this.text.classList.remove("s-button-hide"),this.host}async setText(s){return this.text.innerHTML=s,this.host}async disable(){return this.host.setAttribute("disabled",""),this.host}async enable(){return this.host.removeAttribute("disabled"),this.host}getBtnAttributes(){const s={};for(let t=0;t<this.host.attributes.length;t++)["color","fill","size","width","id"].includes(this.host.attributes[t].name)||(s[this.host.attributes[t].name]=this.host.attributes[t].value);s.type=s.type||this.type;const t=s.class||"";return s.class=t+" s-button-element s-button-"+this.shape+" s-button-"+("none"==this.fill?"fill-none":this.fill)+("medium"!=this.size?" s-button-"+this.size:"")+("normal"!=this.width?" s-button-"+this.width:"")+("link"==this.shape?" s-button-"+this.color+"-link":"")+("link"!=this.shape&&"outline"!=this.fill?" s-button-"+this.color:"")+("outline"==this.fill?" s-button-"+this.color+"-outline":"")+(this.disabled?" s-button-disabled ":"")+("icon"==this.shape?" s-button-loader-center":" s-button-loader-"+this.loaderPosition),s["aria-label"]||s["aria-labelledby"]||(this.host.textContent||"").trim()||(t.includes("btn--wishlist")||t.includes("wishlist")?s["aria-label"]=salla.lang.getWithDefault("pages.products.add_to_wishlist","Add or remove to wishlist"):"icon"===this.shape&&console.warn("Icon button is missing aria-label attribute")),s}button(){return t("button",{...this.getBtnAttributes(),disabled:this.disabled},t("span",{class:"s-button-text",ref:s=>this.text=s},t("slot",null)),this.loading?t("span",{class:"s-button-loader"}):"")}render(){return this.host.closest(".swiper-slide")?.classList.contains("swiper-slide-duplicate")?"":t(i,{class:"s-button-wrap"},this.href?t("a",{href:this.href},this.button()):this.button())}get host(){return e(this)}};u.style="";var m='\x3c!-- Generated by IcoMoon.io --\x3e\n<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">\n<title>alert-engine</title>\n<path d="M16 18.673c-0.736 0-1.333 0.604-1.333 1.34s0.597 1.333 1.333 1.333 1.333-0.597 1.333-1.333v-0.013c0-0.736-0.597-1.327-1.333-1.327zM2.667 16c0-3.092 1.083-6.105 3.047-8.484 0.469-0.568 0.389-1.408-0.179-1.877-0.568-0.468-1.408-0.388-1.877 0.179-2.359 2.857-3.657 6.473-3.657 10.183s1.299 7.325 3.657 10.183c0.264 0.319 0.645 0.484 1.029 0.484 0.299 0 0.6-0.1 0.848-0.305 0.568-0.469 0.648-1.309 0.179-1.877-1.964-2.379-3.047-5.392-3.047-8.484zM16 10.667c-0.736 0-1.333 0.597-1.333 1.333v4c0 0.736 0.597 1.333 1.333 1.333s1.333-0.597 1.333-1.333v-4c0-0.736-0.597-1.333-1.333-1.333zM16 5.333c-5.881 0-10.667 4.785-10.667 10.667s4.785 10.667 10.667 10.667 10.667-4.785 10.667-10.667-4.785-10.667-10.667-10.667zM16 24c-4.412 0-8-3.588-8-8s3.588-8 8-8 8 3.588 8 8-3.588 8-8 8zM28.343 5.817c-0.469-0.567-1.307-0.647-1.877-0.179-0.568 0.469-0.648 1.309-0.179 1.877 1.964 2.379 3.047 5.392 3.047 8.484s-1.083 6.105-3.047 8.484c-0.469 0.568-0.389 1.408 0.179 1.877 0.249 0.205 0.549 0.305 0.848 0.305 0.384 0 0.765-0.165 1.028-0.484 2.36-2.857 3.659-6.473 3.659-10.183s-1.299-7.325-3.657-10.183z"></path>\n</svg>\n';const b=class{constructor(t){s(this,t),this.drawerVisibilityChanged=a(this,"drawerVisibilityChanged"),this.isClosable=!0,this.width="md",this.position="right",this.visible=!1,this.hasSkeleton=!1,this.isLoading=!1,this.subTitleFirst=!1,this.noPadding=!1,this.subTitle="",this.centered=!1,this.iconStyle=void 0,salla.event.on("drawer::open",(s=>s==this.host.id&&this.open())),salla.event.on("drawer::close",(s=>s==this.host.id&&this.close())),this.drawerTitle=this.host.getAttribute("drawer-title")}handleVisible(s){if(!s)return this.drawerVisibilityChanged.emit(!1),void this.toggleDrawer(!1);this.drawerVisibilityChanged.emit(!0),this.host.classList.remove("s-hidden"),setTimeout((()=>this.toggleDrawer(!0)))}handleKeyUp(s){"Escape"===s.key&&this.closeDrawer()}async open(){return this.host.setAttribute("visible",""),this.handleAutoFocus(),this.host}async close(){return this.host.removeAttribute("visible"),this.host}async setTitle(s){return this.drawerTitle=s,this.host}async loading(){return this.isLoading=!0,this.host}async stopLoading(){return this.isLoading=!1,this.host}handleAutoFocus(){const s=this.host.querySelector("input, textarea, select");s&&setTimeout((()=>{s.focus()}),100)}toggleDrawer(s){const t=this.host.querySelector(".s-drawer-body");d.toggleElementClassIf(t,"s-drawer-entering","s-drawer-leaving",(()=>s)).toggleElementClassIf(this.overlay,"s-drawer-entering","s-drawer-overlay-leaving",(()=>s)).toggleElementClassIf(document.body,"drawer-is-open","drawer-is-closed",(()=>s)),s||setTimeout((()=>this.host.classList.add("s-hidden")),350)}closeDrawer(s){this.isClosable&&(salla.event.dispatch("drawer::close",{reason:s}),this.host.removeAttribute("visible"))}iconBlockClasses(){return{"s-drawer-icon":!0,"s-drawer-bg-error":"error"==this.iconStyle,"s-drawer-bg-success":"success"==this.iconStyle,"s-drawer-bg-normal":!this.iconStyle,"s-drawer-bg-primary":"primary"==this.iconStyle}}getWidth(){return this.isLoading?this.hasSkeleton?"md":"xs":this.width}render(){return this.host.id=this.host.id||"salla-drawer",this.isLoading?t(i,{class:"salla-drawer s-drawer s-drawer-container s-hidden","aria-modal":"true",role:"dialog",onKeyUp:s=>this.handleKeyUp(s)},t("div",{class:"s-drawer-overlay s-drawer-overlay-leaving",ref:s=>this.overlay=s,onClick:()=>this.closeDrawer("backdropClick")}),t("div",{class:"s-drawer-wrapper s-drawer-wrapper-"+this.position},t("div",{class:"s-drawer-body flex justify-center s-drawer-leaving s-drawer-"+this.position+" s-drawer-"+this.getWidth()+(this.noPadding?" s-drawer-nopadding":" s-drawer-padding")},t("slot",{name:"loading"},t("salla-loading",null)),t("div",{class:"s-hidden"},t("slot",null))))):t(i,{class:"salla-drawer s-drawer s-drawer-container s-hidden","aria-modal":"true",role:"dialog"},t("div",{class:"s-drawer-overlay s-drawer-overlay-leaving",ref:s=>this.overlay=s,onClick:()=>this.closeDrawer("backdropClick")}),t("div",{class:"s-drawer-wrapper s-drawer-wrapper-"+this.position},t("div",{class:"s-drawer-body s-drawer-leaving s-drawer-"+this.position+" s-drawer-"+this.getWidth()+(this.noPadding?" s-drawer-nopadding":" s-drawer-padding")},t("div",{class:{"s-drawer-header":!0,"s-drawer-is-center":this.centered}},this.isClosable?t("button",{class:"s-drawer-close",onClick:()=>this.closeDrawer("closeButtonClick"),type:"button"},t("span",{innerHTML:o})):"",this.drawerTitle||this.subTitle?t("div",{class:"s-drawer-header-inner"},t("slot",{name:"icon"},this.iconStyle?t("div",{class:this.iconBlockClasses(),innerHTML:"error"==this.iconStyle?m:n}):""),t("div",{class:"s-drawer-header-content"},this.drawerTitle?t("div",{class:{"s-drawer-title":!0,"s-drawer-title-below":this.subTitleFirst},innerHTML:this.drawerTitle}):"",this.subTitle?t("p",{class:{"s-drawer-sub-title":!0},innerHTML:this.subTitle}):"")):""),t("slot",null),t("slot",{name:"footer"}))))}componentDidLoad(){document.body.append(this.host)}get host(){return e(this)}static get watchers(){return{visible:["handleVisible"]}}};b.style="";const p=class{constructor(t){s(this,t),this.size=32,this.width=2,this.color=void 0,this.bgColor="#e5e7eb"}render(){return t(i,{key:"4e2a9d729f0b716566b0d5c71aef6aae23e7fc4b",class:"s-loading-container"},t("svg",{key:"87f13687b423e1e07489a2c97da5a9ba06baf370","aria-hidden":"true",style:{width:`${this.size}px`,height:`${this.size}px`,fill:this.color,color:this.bgColor},class:"s-loading",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t("path",{key:"695143716aa79350944941eda892618ae5e0565a",d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),t("path",{key:"7a37e9b42f4d9f7ee7848f9af78b50307d7dcd79",d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})))}};p.style=".s-loading{animation:spin 1s linear infinite;fill:var(--color-primary)}.s-loading-container{display:flex;justify-content:center;align-items:center}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";const g=class{constructor(t){s(this,t),this.modalVisibilityChanged=a(this,"modalVisibilityChanged"),this.isClosable=!0,this.width="md",this.position="middle",this.visible=!1,this.hasSkeleton=!1,this.isLoading=!1,this.subTitleFirst=!1,this.noPadding=!1,this.subTitle="",this.centered=!1,this.iconStyle=void 0,salla.event.on("modal::open",(s=>s==this.host.id&&this.open())),salla.event.on("modal::close",(s=>s==this.host.id&&this.close())),this.modalTitle=this.host.getAttribute("modal-title")}handleVisible(s){if(!s)return this.modalVisibilityChanged.emit(!1),void this.toggleModal(!1);this.modalVisibilityChanged.emit(!0),this.host.classList.remove("s-hidden"),setTimeout((()=>this.toggleModal(!0)))}handleKeyUp(s){"KeyUp"===s.key&&this.closeModal()}async open(){return this.host.setAttribute("visible",""),this.handleAutoFocus(),this.host}async close(){return this.host.removeAttribute("visible"),this.host}async setTitle(s){return this.modalTitle=s,this.host}async loading(){return this.isLoading=!0,this.host}async stopLoading(){return this.isLoading=!1,this.host}handleAutoFocus(){const s=this.host.querySelector("input, textarea, select");s&&setTimeout((()=>{s.focus()}),100)}toggleModal(s){const t=this.host.querySelector(".s-modal-body");d.toggleElementClassIf(t,"s-modal-entering","s-modal-leaving",(()=>s)).toggleElementClassIf(this.overlay,"s-modal-entering","s-modal-overlay-leaving",(()=>s)).toggleElementClassIf(document.body,"modal-is-open","modal-is-closed",(()=>s)),s||setTimeout((()=>this.host.classList.add("s-hidden")),350)}closeModal(s){this.isClosable&&(salla.event.dispatch("modal::close",{reason:s}),this.host.removeAttribute("visible"))}iconBlockClasses(){return{"s-modal-icon":!0,"s-modal-bg-error":"error"==this.iconStyle,"s-modal-bg-success":"success"==this.iconStyle,"s-modal-bg-normal":!this.iconStyle,"s-modal-bg-primary":"primary"==this.iconStyle}}getWidth(){return this.isLoading?this.hasSkeleton?"md":"xs":this.width}render(){return this.host.id=this.host.id||"salla-modal",this.isLoading?t(i,{class:"salla-modal s-modal s-modal-container s-hidden","aria-modal":"true",role:"dialog",onKeyUp:s=>this.handleKeyUp(s)},t("div",{class:"s-modal-overlay",ref:s=>this.overlay=s,onClick:()=>this.closeModal("backdropClick")}),t("div",{class:"s-modal-wrapper"},t("span",{class:"s-modal-spacer s-modal-align-"+this.position},""),t("div",{class:"s-modal-body s-modal-align-"+this.position+" s-modal-"+this.getWidth()+(this.noPadding?" s-modal-nopadding":" s-modal-padding")},t("slot",{name:"loading"},t("salla-loading",null)),t("div",{class:"s-hidden"},t("slot",null))))):t(i,{class:"salla-modal s-modal s-modal-container s-hidden","aria-modal":"true",role:"dialog"},t("div",{class:"s-modal-overlay",ref:s=>this.overlay=s,onClick:()=>this.closeModal("backdropClick")}),t("div",{class:"s-modal-wrapper"},t("span",{class:"s-modal-spacer s-modal-align-"+this.position},""),t("div",{class:"s-modal-body s-modal-align-"+this.position+" s-modal-"+this.getWidth()+(this.noPadding?" s-modal-nopadding":" s-modal-padding")},t("div",{class:{"s-modal-header":!0,"s-modal-is-center":this.centered}},this.isClosable?t("button",{class:"s-modal-close",onClick:()=>this.closeModal("closeButtonClick"),type:"button"},t("span",{innerHTML:o})):"",this.modalTitle||this.subTitle?t("div",{class:"s-modal-header-inner"},t("slot",{name:"icon"},this.iconStyle?t("div",{class:this.iconBlockClasses(),innerHTML:"error"==this.iconStyle?m:n}):""),t("div",{class:"s-modal-header-content"},this.modalTitle?t("div",{class:{"s-modal-title":!0,"s-modal-title-below":this.subTitleFirst},innerHTML:this.modalTitle}):"",this.subTitle?t("p",{class:{"s-modal-sub-title":!0},innerHTML:this.subTitle}):"")):""),t("slot",null),t("slot",{name:"footer"}))))}componentDidLoad(){document.body.append(this.host)}get host(){return e(this)}static get watchers(){return{visible:["handleVisible"]}}};g.style="@media screen and (max-width: 470px){.modal-is-open{position:fixed;width:100%}}";export{h as salla_accordion,c as salla_breadcrumb,u as salla_button,b as salla_drawer,p as salla_loading,g as salla_modal}
|