@salla.sa/twilight-components 2.14.392 → 2.14.393
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/app-globals-oehrC7QI.js +39 -0
- package/dist/cjs/{filepond-D-ur1GA-.js → filepond-D7RVR_w_.js} +10 -5
- package/dist/cjs/{filepond-plugin-file-poster-DigEeKId.js → filepond-plugin-file-poster-DTuZK2ot.js} +11 -7
- package/dist/cjs/{filepond-plugin-file-validate-size-R9el3Yro.js → filepond-plugin-file-validate-size-DHc6pF_j.js} +1 -1
- package/dist/cjs/filepond-plugin-file-validate-type-DnkcvJVc.js +271 -0
- package/dist/cjs/{filepond-plugin-image-edit-bhI8kqN_.js → filepond-plugin-image-edit-vrZ1s7kw.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-COXZUVRV.js → filepond-plugin-image-exif-orientation-Bn5JSzQK.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview-COP8QJBf.js → filepond-plugin-image-preview-8qWUFe9n.js} +1 -1
- package/dist/cjs/{index-CGnPURjZ.js → index-C5VeFDQ0.js} +1966 -1344
- package/dist/cjs/{index-BILBEE9f.js → index-CwD81m7i.js} +1 -1
- package/dist/cjs/loader.cjs.js +4 -3
- package/dist/cjs/salla-accordion-body_2.cjs.entry.js +5 -5
- package/dist/cjs/salla-accordion_6.cjs.entry.js +19 -15
- package/dist/cjs/salla-add-product-button_4.cjs.entry.js +12 -10
- package/dist/cjs/salla-advertisement.cjs.entry.js +3 -3
- package/dist/cjs/salla-alert_2.cjs.entry.js +5 -5
- package/dist/cjs/salla-app-install-alert.cjs.entry.js +3 -3
- package/dist/cjs/salla-apps-icons.cjs.entry.js +3 -3
- package/dist/cjs/salla-booking-field_7.cjs.entry.js +25 -23
- package/dist/cjs/salla-bullet-delivery.cjs.entry.js +3 -3
- package/dist/cjs/salla-cart-coupons.cjs.entry.js +3 -3
- package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +5 -5
- package/dist/cjs/salla-comment-form_8.cjs.entry.js +17 -17
- package/dist/cjs/salla-conditional-offer.cjs.entry.js +3 -3
- package/dist/cjs/salla-contacts.cjs.entry.js +3 -3
- package/dist/cjs/salla-cookies-bar.cjs.entry.js +3 -3
- package/dist/cjs/salla-count-down.cjs.entry.js +35 -11
- package/dist/cjs/salla-custom-fields.cjs.entry.js +3 -3
- package/dist/cjs/salla-delivery-promise.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters-widget.cjs.entry.js +3 -3
- package/dist/cjs/salla-filters.cjs.entry.js +3 -3
- package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +1 -1
- package/dist/cjs/salla-gifting.cjs.entry.js +3 -3
- package/dist/cjs/salla-hook.cjs.entry.js +5 -2
- package/dist/cjs/salla-infinite-scroll.cjs.entry.js +3 -3
- package/dist/cjs/salla-installment.cjs.entry.js +3 -3
- package/dist/cjs/salla-list-tile.cjs.entry.js +3 -3
- package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-login-modal.cjs.entry.js +3 -3
- package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +3 -3
- package/dist/cjs/salla-loyalty-program.cjs.entry.js +3 -3
- package/dist/cjs/salla-loyalty.cjs.entry.js +3 -3
- package/dist/cjs/salla-maintenance-alert.cjs.entry.js +3 -3
- package/dist/cjs/salla-map.cjs.entry.js +3 -3
- package/dist/cjs/salla-menu.cjs.entry.js +3 -3
- package/dist/cjs/salla-metadata.cjs.entry.js +3 -3
- package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +5 -5
- package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +8 -6
- package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +6 -4
- package/dist/cjs/salla-notification-item.cjs.entry.js +3 -3
- package/dist/cjs/salla-notifications.cjs.entry.js +50 -5
- package/dist/cjs/salla-offer-modal.cjs.entry.js +3 -3
- package/dist/cjs/salla-offer.cjs.entry.js +3 -3
- package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +3 -3
- package/dist/cjs/salla-order-details-options.cjs.entry.js +3 -3
- package/dist/cjs/salla-order-details.cjs.entry.js +6 -4
- package/dist/cjs/salla-order-edit-item.cjs.entry.js +3 -3
- package/dist/cjs/salla-order-edit.cjs.entry.js +3 -3
- package/dist/cjs/salla-order-summary.cjs.entry.js +3 -3
- package/dist/cjs/salla-order-totals-card.cjs.entry.js +6 -4
- package/dist/cjs/salla-orders.cjs.entry.js +3 -3
- package/dist/cjs/salla-payments.cjs.entry.js +3 -3
- package/dist/cjs/salla-placeholder.cjs.entry.js +3 -3
- package/dist/cjs/salla-price-range.cjs.entry.js +3 -3
- package/dist/cjs/salla-product-card.cjs.entry.js +3 -3
- package/dist/cjs/salla-product-size-guide.cjs.entry.js +3 -3
- package/dist/cjs/salla-products-list.cjs.entry.js +3 -3
- package/dist/cjs/salla-products-slider.cjs.entry.js +3 -3
- package/dist/cjs/salla-progress-bar.cjs.entry.js +3 -3
- package/dist/cjs/salla-quick-order.cjs.entry.js +3 -3
- package/dist/cjs/salla-rating-modal.cjs.entry.js +3 -3
- package/dist/cjs/salla-scopes.cjs.entry.js +3 -3
- package/dist/cjs/salla-search.cjs.entry.js +6 -4
- package/dist/cjs/salla-skeleton.cjs.entry.js +3 -3
- package/dist/cjs/salla-slider.cjs.entry.js +20 -14
- package/dist/cjs/salla-social-share.cjs.entry.js +3 -3
- package/dist/cjs/salla-social.cjs.entry.js +3 -3
- package/dist/cjs/salla-tab-content_3.cjs.entry.js +7 -7
- package/dist/cjs/salla-tiered-offer.cjs.entry.js +3 -3
- package/dist/cjs/salla-tooltip.cjs.entry.js +3 -3
- package/dist/cjs/salla-trust-badges.cjs.entry.js +3 -3
- package/dist/cjs/salla-user-menu.cjs.entry.js +3 -3
- package/dist/cjs/salla-user-profile.cjs.entry.js +3 -3
- package/dist/cjs/salla-user-settings.cjs.entry.js +3 -3
- package/dist/cjs/salla-verify.cjs.entry.js +3 -3
- package/dist/cjs/salla-wallet.cjs.entry.js +3 -3
- package/dist/cjs/twilight.cjs.js +5 -4
- package/dist/cjs/{vanilla-picker-DI3TImGd.js → vanilla-picker-yKERbLpx.js} +1 -1
- package/dist/collection/collection-manifest.json +3 -2
- package/dist/collection/components/salla-accordion/salla-accordion-head.js +2 -2
- package/dist/collection/components/salla-accordion/salla-accordion.js +4 -4
- package/dist/collection/components/salla-add-product-button/salla-add-product-button.js +19 -19
- package/dist/collection/components/salla-alert/salla-alert.js +5 -5
- package/dist/collection/components/salla-apps-icons/salla-apps-icons.js +6 -6
- package/dist/collection/components/salla-booking-field/salla-booking-field.js +4 -4
- package/dist/collection/components/salla-bottom-alert/salla-bottom-alert.js +9 -9
- package/dist/collection/components/salla-bullet-delivery/salla-bullet-delivery.js +6 -3
- package/dist/collection/components/salla-button/salla-button.js +11 -11
- package/dist/collection/components/salla-cart-coupons/salla-cart-coupons.js +2 -1
- package/dist/collection/components/salla-cart-item-offers/salla-cart-item-offers.js +8 -8
- package/dist/collection/components/salla-cart-summary/salla-cart-summary.js +2 -2
- package/dist/collection/components/salla-color-picker/salla-color-picker.js +20 -14
- package/dist/collection/components/salla-comment-form/salla-comment-form.js +6 -6
- package/dist/collection/components/salla-comments/salla-comment-item.js +2 -3
- package/dist/collection/components/salla-comments/salla-comments.js +18 -17
- package/dist/collection/components/salla-contacts/salla-contacts.js +10 -10
- package/dist/collection/components/salla-count-down/salla-count-down.js +66 -42
- package/dist/collection/components/salla-custom-fields/salla-custom-fields.js +9 -7
- package/dist/collection/components/salla-datetime-picker/salla-datetime-picker.js +69 -65
- package/dist/collection/components/salla-drawer/salla-drawer.js +11 -11
- package/dist/collection/components/salla-file-upload/salla-file-upload.css +1 -1
- package/dist/collection/components/salla-file-upload/salla-file-upload.js +85 -84
- package/dist/collection/components/salla-filters/salla-filters.js +2 -2
- package/dist/collection/components/salla-filters-widget/salla-filters-widget.js +4 -5
- package/dist/collection/components/salla-gifting/salla-gifting.js +11 -11
- package/dist/collection/components/salla-hook/salla-hook.js +2 -2
- package/dist/collection/components/salla-infinite-scroll/salla-infinite-scroll.js +6 -6
- package/dist/collection/components/salla-installment/salla-installment.js +5 -5
- package/dist/collection/components/salla-list-tile/salla-list-tile.js +2 -2
- package/dist/collection/components/salla-loading/salla-loading.js +4 -4
- package/dist/collection/components/salla-localization-modal/salla-localization-modal.js +5 -5
- package/dist/collection/components/salla-login-modal/salla-login-modal.js +14 -14
- package/dist/collection/components/salla-loyalty/salla-loyalty-prize-item.js +4 -3
- package/dist/collection/components/salla-loyalty/salla-loyalty.js +13 -12
- package/dist/collection/components/salla-map/salla-map.js +14 -14
- package/dist/collection/components/salla-menu/salla-menu.js +10 -9
- package/dist/collection/components/salla-metadata/salla-metadata.js +3 -3
- package/dist/collection/components/salla-modal/salla-modal.js +11 -11
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-cart.js +2 -2
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-details.js +2 -2
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-options-modal.js +4 -2
- package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-slider.js +8 -7
- package/dist/collection/components/salla-multiple-bundle-product/salla-multiple-bundle-product.js +2 -2
- package/dist/collection/components/salla-notifications/salla-notification-item.js +2 -2
- package/dist/collection/components/salla-notifications/salla-notifications.js +50 -5
- package/dist/collection/components/salla-offer/salla-offer.js +1 -1
- package/dist/collection/components/salla-order-details/salla-order-details-multiple-bundle-product.js +5 -5
- package/dist/collection/components/salla-order-details/salla-order-details-options.js +6 -5
- package/dist/collection/components/salla-order-details/salla-order-details.js +4 -3
- package/dist/collection/components/salla-order-edit/salla-order-edit-item.js +4 -4
- package/dist/collection/components/salla-order-edit/salla-order-edit.js +4 -4
- package/dist/collection/components/salla-order-summary/salla-order-summary.js +2 -2
- package/dist/collection/components/salla-order-totals-card/salla-order-totals-card.js +4 -3
- package/dist/collection/components/salla-orders/salla-orders.js +4 -4
- package/dist/collection/components/salla-payments/salla-payments.js +0 -1
- package/dist/collection/components/salla-placeholder/salla-placeholder.js +3 -3
- package/dist/collection/components/salla-price-range/salla-price-range.js +8 -8
- package/dist/collection/components/salla-product-availability/salla-product-availability.js +6 -6
- package/dist/collection/components/salla-product-card/salla-product-card.js +18 -18
- package/dist/collection/components/salla-product-options/salla-product-options.js +15 -13
- package/dist/collection/components/salla-products-list/salla-products-list.js +20 -21
- package/dist/collection/components/salla-products-slider/salla-products-slider.js +22 -23
- package/dist/collection/components/salla-progress-bar/salla-progress-bar.js +21 -20
- package/dist/collection/components/salla-quantity-input/salla-quantity-input.js +2 -2
- package/dist/collection/components/salla-quick-buy/salla-quick-buy.js +16 -17
- package/dist/collection/components/salla-quick-order/salla-quick-order.js +11 -11
- package/dist/collection/components/salla-rating-modal/salla-rating-modal.js +2 -2
- package/dist/collection/components/salla-rating-stars/salla-rating-stars.js +8 -8
- package/dist/collection/components/salla-review-card/salla-review-card.js +3 -3
- package/dist/collection/components/salla-reviews/salla-reviews.js +16 -13
- package/dist/collection/components/salla-reviews-summary/salla-reviews-summary.js +2 -2
- package/dist/collection/components/salla-scopes/salla-scopes.js +2 -2
- package/dist/collection/components/salla-search/salla-search.js +6 -6
- package/dist/collection/components/salla-skeleton/salla-skeleton.js +3 -3
- package/dist/collection/components/salla-slider/salla-slider.css +9 -2
- package/dist/collection/components/salla-slider/salla-slider.js +25 -25
- package/dist/collection/components/salla-social-share/salla-social-share.js +3 -3
- package/dist/collection/components/salla-tabs/salla-tab-content.js +2 -2
- package/dist/collection/components/salla-tabs/salla-tab-header.js +5 -5
- package/dist/collection/components/salla-tabs/salla-tabs.js +2 -2
- package/dist/collection/components/salla-tel-input/salla-tel-input.js +9 -8
- package/dist/collection/components/salla-tooltip/salla-tooltip.js +5 -5
- package/dist/collection/components/salla-trust-badges/salla-trust-badges.js +1 -1
- package/dist/collection/components/salla-user-menu/salla-user-menu.js +5 -5
- package/dist/collection/components/salla-user-profile/salla-user-profile.js +1 -1
- package/dist/collection/components/salla-verify/salla-verify.js +4 -4
- package/dist/components/Helper.js +1 -432
- package/dist/components/_commonjsHelpers.js +1 -7
- package/dist/components/anime.es.js +1 -1310
- package/dist/components/arrow-left.js +1 -8
- package/dist/components/axios.js +2 -3908
- package/dist/components/bell-ring.js +1 -8
- package/dist/components/camera.js +1 -8
- package/dist/components/cancel.js +1 -8
- package/dist/components/cart.js +1 -8
- package/dist/components/check-circle2.js +1 -15
- package/dist/components/check.js +1 -8
- package/dist/components/facebook.js +1 -10
- package/dist/components/filepond-plugin-file-poster.js +3 -659
- package/dist/components/filepond-plugin-file-validate-size.js +2 -204
- package/dist/components/filepond-plugin-file-validate-type.js +3 -279
- package/dist/components/filepond-plugin-image-edit.js +2 -487
- package/dist/components/filepond-plugin-image-exif-orientation.js +2 -214
- package/dist/components/filepond-plugin-image-preview.js +2 -2237
- package/dist/components/filepond.js +3 -11282
- package/dist/components/gift.js +1 -8
- package/dist/components/image.js +1 -8
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +1 -8163
- package/dist/components/index2.js +1 -1709
- package/dist/components/index3.js +1 -2550
- package/dist/components/interfaces.js +1 -12
- package/dist/components/isObject.js +1 -292
- package/dist/components/keyboard_arrow_down.js +1 -8
- package/dist/components/keyboard_arrow_right.js +1 -15
- package/dist/components/location.js +1 -11
- package/dist/components/mail.js +1 -8
- package/dist/components/minus.js +1 -15
- package/dist/components/salla-accordion-body.js +1 -6
- package/dist/components/salla-accordion-body2.js +1 -30
- package/dist/components/salla-accordion-head.js +1 -6
- package/dist/components/salla-accordion-head2.js +1 -63
- package/dist/components/salla-accordion.js +1 -6
- package/dist/components/salla-accordion2.js +1 -68
- package/dist/components/salla-add-product-button.js +1 -6
- package/dist/components/salla-add-product-button2.js +1 -306
- package/dist/components/salla-advertisement.js +1 -155
- package/dist/components/salla-alert.js +1 -59
- package/dist/components/salla-app-install-alert.js +1 -91
- package/dist/components/salla-apps-icons.js +1 -63
- package/dist/components/salla-booking-field.js +1 -6
- package/dist/components/salla-booking-field2.js +1 -221
- package/dist/components/salla-bottom-alert.js +1 -214
- package/dist/components/salla-breadcrumb.js +1 -226
- package/dist/components/salla-bullet-delivery.js +1 -2114
- package/dist/components/salla-button.js +1 -6
- package/dist/components/salla-button2.js +1 -174
- package/dist/components/salla-cart-coupons.js +1 -284
- package/dist/components/salla-cart-item-offers.js +1 -143
- package/dist/components/salla-cart-summary.js +1 -136
- package/dist/components/salla-color-picker.js +1 -6
- package/dist/components/salla-color-picker2.js +1 -260
- package/dist/components/salla-comment-form.js +1 -6
- package/dist/components/salla-comment-form2.js +1 -64
- package/dist/components/salla-comment-item.js +1 -6
- package/dist/components/salla-comment-item2.js +1 -217
- package/dist/components/salla-comments.js +1 -395
- package/dist/components/salla-conditional-fields.js +1 -6
- package/dist/components/salla-conditional-fields2.js +1 -137
- package/dist/components/salla-conditional-offer.js +1 -194
- package/dist/components/salla-contacts.js +1 -125
- package/dist/components/salla-cookies-bar.js +1 -107
- package/dist/components/salla-count-down.js +1 -6
- package/dist/components/salla-count-down2.js +1 -247
- package/dist/components/salla-custom-fields.js +1 -175
- package/dist/components/salla-datetime-picker.js +1 -6
- package/dist/components/salla-datetime-picker2.js +1 -342
- package/dist/components/salla-delivery-promise.js +1 -263
- package/dist/components/salla-drawer.js +1 -6
- package/dist/components/salla-drawer2.js +1 -214
- package/dist/components/salla-file-upload.js +1 -6
- package/dist/components/salla-file-upload2.js +1 -583
- package/dist/components/salla-filters-widget.js +1 -6
- package/dist/components/salla-filters-widget2.js +1 -245
- package/dist/components/salla-filters.js +1 -253
- package/dist/components/salla-fulfillment-methods.js +1 -61
- package/dist/components/salla-gifting.js +1 -732
- package/dist/components/salla-hook.js +1 -47
- package/dist/components/salla-infinite-scroll.js +1 -112
- package/dist/components/salla-installment.js +1 -306
- package/dist/components/salla-list-tile.js +1 -6
- package/dist/components/salla-list-tile2.js +1 -47
- package/dist/components/salla-loading.js +1 -6
- package/dist/components/salla-loading2.js +1 -51
- package/dist/components/salla-localization-modal.js +1 -296
- package/dist/components/salla-login-modal.js +1 -6
- package/dist/components/salla-login-modal2.js +1 -359
- package/dist/components/salla-loyalty-prize-item.js +1 -39
- package/dist/components/salla-loyalty-program.js +1 -115
- package/dist/components/salla-loyalty.js +1 -304
- package/dist/components/salla-maintenance-alert.js +1 -57
- package/dist/components/salla-map.js +1 -6
- package/dist/components/salla-map2.js +1 -766
- package/dist/components/salla-menu.js +1 -165
- package/dist/components/salla-metadata.js +1 -97
- package/dist/components/salla-modal.js +1 -6
- package/dist/components/salla-modal2.js +1 -215
- package/dist/components/salla-multiple-bundle-product-cart.js +1 -6
- package/dist/components/salla-multiple-bundle-product-cart2.js +1 -151
- package/dist/components/salla-multiple-bundle-product-details.js +1 -6
- package/dist/components/salla-multiple-bundle-product-details2.js +1 -296
- package/dist/components/salla-multiple-bundle-product-options-modal.js +1 -6
- package/dist/components/salla-multiple-bundle-product-options-modal2.js +1 -598
- package/dist/components/salla-multiple-bundle-product-slider.js +1 -6
- package/dist/components/salla-multiple-bundle-product-slider2.js +1 -136
- package/dist/components/salla-multiple-bundle-product.js +1 -207
- package/dist/components/salla-notification-item.js +1 -6
- package/dist/components/salla-notification-item2.js +1 -32
- package/dist/components/salla-notifications.js +1 -145
- package/dist/components/salla-offer-modal.js +1 -328
- package/dist/components/salla-offer.js +1 -478
- package/dist/components/salla-order-details-multiple-bundle-product.js +1 -6
- package/dist/components/salla-order-details-multiple-bundle-product2.js +1 -122
- package/dist/components/salla-order-details-options.js +1 -6
- package/dist/components/salla-order-details-options2.js +1 -140
- package/dist/components/salla-order-details.js +1 -122
- package/dist/components/salla-order-edit-item.js +1 -6
- package/dist/components/salla-order-edit-item2.js +1 -181
- package/dist/components/salla-order-edit.js +1 -288
- package/dist/components/salla-order-summary.js +1 -132
- package/dist/components/salla-order-totals-card.js +1 -87
- package/dist/components/salla-orders.js +1 -271
- package/dist/components/salla-payments.js +1 -76
- package/dist/components/salla-placeholder.js +1 -6
- package/dist/components/salla-placeholder2.js +1 -66
- package/dist/components/salla-price-range.js +1 -6
- package/dist/components/salla-price-range2.js +1 -204
- package/dist/components/salla-product-availability.js +1 -6
- package/dist/components/salla-product-availability2.js +1 -206
- package/dist/components/salla-product-card.js +1 -6
- package/dist/components/salla-product-card2.js +1 -241
- package/dist/components/salla-product-options.js +1 -6
- package/dist/components/salla-product-options2.js +1 -962
- package/dist/components/salla-product-size-guide.js +1 -130
- package/dist/components/salla-products-list.js +1 -6
- package/dist/components/salla-products-list2.js +1 -812
- package/dist/components/salla-products-slider.js +1 -6
- package/dist/components/salla-products-slider2.js +1 -215
- package/dist/components/salla-progress-bar.js +1 -6
- package/dist/components/salla-progress-bar2.js +1 -94
- package/dist/components/salla-quantity-input.js +1 -6
- package/dist/components/salla-quantity-input2.js +1 -127
- package/dist/components/salla-quick-buy.js +1 -6
- package/dist/components/salla-quick-buy2.js +1 -1181
- package/dist/components/salla-quick-order.js +1 -299
- package/dist/components/salla-rating-modal.js +1 -530
- package/dist/components/salla-rating-stars.js +1 -6
- package/dist/components/salla-rating-stars2.js +1 -162
- package/dist/components/salla-review-card.js +1 -6
- package/dist/components/salla-review-card2.js +1 -198
- package/dist/components/salla-reviews-page.js +1 -726
- package/dist/components/salla-reviews-summary.js +1 -6
- package/dist/components/salla-reviews-summary2.js +1 -132
- package/dist/components/salla-reviews.js +1 -143
- package/dist/components/salla-scopes.js +1 -249
- package/dist/components/salla-search.js +1 -213
- package/dist/components/salla-skeleton.js +1 -6
- package/dist/components/salla-skeleton2.js +1 -50
- package/dist/components/salla-slider.js +1 -6
- package/dist/components/salla-slider2.js +1 -10483
- package/dist/components/salla-social-share.js +1 -194
- package/dist/components/salla-social.js +1 -89
- package/dist/components/salla-tab-content.js +1 -6
- package/dist/components/salla-tab-content2.js +1 -55
- package/dist/components/salla-tab-header.js +1 -6
- package/dist/components/salla-tab-header2.js +1 -85
- package/dist/components/salla-tabs.js +1 -6
- package/dist/components/salla-tabs2.js +1 -75
- package/dist/components/salla-tel-input.js +1 -6
- package/dist/components/salla-tel-input2.js +1 -168
- package/dist/components/salla-tiered-offer.js +1 -366
- package/dist/components/salla-tooltip.js +1 -6
- package/dist/components/salla-tooltip2.js +1 -57
- package/dist/components/salla-trust-badges.js +1 -90
- package/dist/components/salla-user-menu.js +1 -344
- package/dist/components/salla-user-profile.js +1 -203
- package/dist/components/salla-user-settings.js +1 -139
- package/dist/components/salla-verify.js +1 -303
- package/dist/components/salla-wallet.js +1 -114
- package/dist/components/search.js +1 -8
- package/dist/components/shopping-bag.js +1 -8
- package/dist/components/special-discount.js +1 -8
- package/dist/components/star.js +1 -8
- package/dist/components/star2.js +1 -8
- package/dist/components/vanilla-picker.js +2 -1034
- package/dist/components/whatsapp2.js +1 -8
- package/dist/esm/app-globals-BFryt7-C.js +37 -0
- package/dist/esm/{filepond-kTbl0kuh.js → filepond-DlGaLh8N.js} +10 -5
- package/dist/esm/{filepond-plugin-file-poster-CyywnjKv.js → filepond-plugin-file-poster-BTVFYcQx.js} +11 -7
- package/dist/esm/{filepond-plugin-file-validate-size-DgteZhje.js → filepond-plugin-file-validate-size-DGryLmWv.js} +1 -1
- package/dist/esm/filepond-plugin-file-validate-type-DxKfCD0V.js +269 -0
- package/dist/esm/{filepond-plugin-image-edit-pZ_mETE7.js → filepond-plugin-image-edit-2W7pu9hn.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-CjKYl7HL.js → filepond-plugin-image-exif-orientation-OQu-IvPH.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-BzJTl_2A.js → filepond-plugin-image-preview-DEW_tSNR.js} +1 -1
- package/dist/esm/{index-3Kis_Ivk.js → index-BDqMkCqE.js} +1 -1
- package/dist/esm/{index-C23tPnnH.js → index-DYB20YqN.js} +1966 -1344
- package/dist/esm/loader.js +4 -3
- package/dist/esm/salla-accordion-body_2.entry.js +5 -5
- package/dist/esm/salla-accordion_6.entry.js +19 -15
- package/dist/esm/salla-add-product-button_4.entry.js +12 -10
- package/dist/esm/salla-advertisement.entry.js +3 -3
- package/dist/esm/salla-alert_2.entry.js +5 -5
- package/dist/esm/salla-app-install-alert.entry.js +3 -3
- package/dist/esm/salla-apps-icons.entry.js +3 -3
- package/dist/esm/salla-booking-field_7.entry.js +25 -23
- package/dist/esm/salla-bullet-delivery.entry.js +3 -3
- package/dist/esm/salla-cart-coupons.entry.js +3 -3
- package/dist/esm/salla-cart-item-offers_2.entry.js +5 -5
- package/dist/esm/salla-comment-form_8.entry.js +17 -17
- package/dist/esm/salla-conditional-offer.entry.js +3 -3
- package/dist/esm/salla-contacts.entry.js +3 -3
- package/dist/esm/salla-cookies-bar.entry.js +3 -3
- package/dist/esm/salla-count-down.entry.js +35 -11
- package/dist/esm/salla-custom-fields.entry.js +3 -3
- package/dist/esm/salla-delivery-promise.entry.js +1 -1
- package/dist/esm/salla-filters-widget.entry.js +3 -3
- package/dist/esm/salla-filters.entry.js +3 -3
- package/dist/esm/salla-fulfillment-methods.entry.js +1 -1
- package/dist/esm/salla-gifting.entry.js +3 -3
- package/dist/esm/salla-hook.entry.js +5 -2
- package/dist/esm/salla-infinite-scroll.entry.js +3 -3
- package/dist/esm/salla-installment.entry.js +3 -3
- package/dist/esm/salla-list-tile.entry.js +3 -3
- package/dist/esm/salla-localization-modal.entry.js +1 -1
- package/dist/esm/salla-login-modal.entry.js +3 -3
- package/dist/esm/salla-loyalty-prize-item.entry.js +3 -3
- package/dist/esm/salla-loyalty-program.entry.js +3 -3
- package/dist/esm/salla-loyalty.entry.js +3 -3
- package/dist/esm/salla-maintenance-alert.entry.js +3 -3
- package/dist/esm/salla-map.entry.js +3 -3
- package/dist/esm/salla-menu.entry.js +3 -3
- package/dist/esm/salla-metadata.entry.js +3 -3
- package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +5 -5
- package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +8 -6
- package/dist/esm/salla-multiple-bundle-product.entry.js +6 -4
- package/dist/esm/salla-notification-item.entry.js +3 -3
- package/dist/esm/salla-notifications.entry.js +50 -5
- package/dist/esm/salla-offer-modal.entry.js +3 -3
- package/dist/esm/salla-offer.entry.js +3 -3
- package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +3 -3
- package/dist/esm/salla-order-details-options.entry.js +3 -3
- package/dist/esm/salla-order-details.entry.js +6 -4
- package/dist/esm/salla-order-edit-item.entry.js +3 -3
- package/dist/esm/salla-order-edit.entry.js +3 -3
- package/dist/esm/salla-order-summary.entry.js +3 -3
- package/dist/esm/salla-order-totals-card.entry.js +6 -4
- package/dist/esm/salla-orders.entry.js +3 -3
- package/dist/esm/salla-payments.entry.js +3 -3
- package/dist/esm/salla-placeholder.entry.js +3 -3
- package/dist/esm/salla-price-range.entry.js +3 -3
- package/dist/esm/salla-product-card.entry.js +3 -3
- package/dist/esm/salla-product-size-guide.entry.js +3 -3
- package/dist/esm/salla-products-list.entry.js +3 -3
- package/dist/esm/salla-products-slider.entry.js +3 -3
- package/dist/esm/salla-progress-bar.entry.js +3 -3
- package/dist/esm/salla-quick-order.entry.js +3 -3
- package/dist/esm/salla-rating-modal.entry.js +3 -3
- package/dist/esm/salla-scopes.entry.js +3 -3
- package/dist/esm/salla-search.entry.js +6 -4
- package/dist/esm/salla-skeleton.entry.js +3 -3
- package/dist/esm/salla-slider.entry.js +20 -14
- package/dist/esm/salla-social-share.entry.js +3 -3
- package/dist/esm/salla-social.entry.js +3 -3
- package/dist/esm/salla-tab-content_3.entry.js +7 -7
- package/dist/esm/salla-tiered-offer.entry.js +3 -3
- package/dist/esm/salla-tooltip.entry.js +3 -3
- package/dist/esm/salla-trust-badges.entry.js +3 -3
- package/dist/esm/salla-user-menu.entry.js +3 -3
- package/dist/esm/salla-user-profile.entry.js +3 -3
- package/dist/esm/salla-user-settings.entry.js +3 -3
- package/dist/esm/salla-verify.entry.js +3 -3
- package/dist/esm/salla-wallet.entry.js +3 -3
- package/dist/esm/twilight.js +5 -4
- package/dist/esm/{vanilla-picker-CEy5x8Cf.js → vanilla-picker-Dt9vZPZF.js} +1 -1
- package/dist/twilight/{p-651fe6e4.entry.js → p-06fa7327.entry.js} +1 -1
- package/dist/twilight/{p-a50f7f70.entry.js → p-09d39785.entry.js} +1 -1
- package/dist/twilight/{p-744d6394.entry.js → p-0add06f9.entry.js} +1 -1
- package/dist/twilight/{p-f251e744.entry.js → p-105b1dab.entry.js} +1 -1
- package/dist/twilight/{p-407828e4.entry.js → p-108d8c8b.entry.js} +1 -1
- package/dist/twilight/{p-2a1871c2.entry.js → p-1875537e.entry.js} +1 -1
- package/dist/twilight/{p-ff6f769c.entry.js → p-18bb0181.entry.js} +1 -1
- package/dist/twilight/p-1daeed6e.entry.js +4 -0
- package/dist/twilight/{p-2aa48902.entry.js → p-1ef2602d.entry.js} +1 -1
- package/dist/twilight/{p-27f34c85.entry.js → p-2881bb33.entry.js} +1 -1
- package/dist/twilight/{p-c3d0c062.entry.js → p-293c6cf3.entry.js} +1 -1
- package/dist/twilight/{p-866b297b.entry.js → p-296d2dd0.entry.js} +1 -1
- package/dist/twilight/{p-3a5aaa20.entry.js → p-2abaa633.entry.js} +1 -1
- package/dist/twilight/p-2ddb3fce.entry.js +4 -0
- package/dist/twilight/{p-81f648a2.entry.js → p-2fe01e44.entry.js} +1 -1
- package/dist/twilight/p-33779828.entry.js +4 -0
- package/dist/twilight/p-34968e31.entry.js +4 -0
- package/dist/twilight/{p-3745a7d0.entry.js → p-34b670fc.entry.js} +1 -1
- package/dist/twilight/{p-9f23dd30.entry.js → p-3ccc532d.entry.js} +1 -1
- package/dist/twilight/{p-f2ee9ceb.entry.js → p-41c733c2.entry.js} +1 -1
- package/dist/twilight/{p-67fe5680.entry.js → p-44fa7521.entry.js} +1 -1
- package/dist/twilight/{p-b4f07395.entry.js → p-4932857d.entry.js} +1 -1
- package/dist/twilight/{p-81f6638f.entry.js → p-4fa4547a.entry.js} +1 -1
- package/dist/twilight/{p-ba4b672c.entry.js → p-542d3277.entry.js} +1 -1
- package/dist/twilight/{p-a00e249b.entry.js → p-57ff1f25.entry.js} +1 -1
- package/dist/twilight/{p-827edf95.entry.js → p-59ae82bd.entry.js} +1 -1
- package/dist/twilight/{p-82e3c734.entry.js → p-647b6d76.entry.js} +1 -1
- package/dist/twilight/p-665189b4.entry.js +4 -0
- package/dist/twilight/{p-b55da21d.entry.js → p-6f36541a.entry.js} +1 -1
- package/dist/twilight/{p-c8aa5377.entry.js → p-7093a427.entry.js} +1 -1
- package/dist/twilight/{p-f201122a.entry.js → p-748df7e6.entry.js} +1 -1
- package/dist/twilight/p-776c9d33.entry.js +4 -0
- package/dist/twilight/{p-ce9fee6d.entry.js → p-7abddca8.entry.js} +1 -1
- package/dist/twilight/p-7b8313ef.entry.js +4 -0
- package/dist/twilight/p-7bd0ede5.entry.js +4 -0
- package/dist/twilight/p-817b8ba5.entry.js +4 -0
- package/dist/twilight/{p-5ef1b170.entry.js → p-87c0ca91.entry.js} +1 -1
- package/dist/twilight/p-8e8d9d7d.entry.js +4 -0
- package/dist/twilight/{p-BHjlzmYy.js → p-8r0S6BcZ.js} +1 -1
- package/dist/twilight/{p-face0448.entry.js → p-94dbc1e9.entry.js} +1 -1
- package/dist/twilight/{p-4e00f827.entry.js → p-96a20515.entry.js} +1 -1
- package/dist/twilight/{p-81f76d49.entry.js → p-96d03a28.entry.js} +1 -1
- package/dist/twilight/{p-97df32eb.entry.js → p-96e78428.entry.js} +1 -1
- package/dist/twilight/{p-CU-HtXWh.js → p-BZnoSB1s.js} +1 -1
- package/dist/twilight/p-BkClxrC4.js +9 -0
- package/dist/twilight/p-Ck4zxCil.js +9 -0
- package/dist/twilight/{p-IoI86ovS.js → p-Cw3UBzjl.js} +1 -1
- package/dist/twilight/p-D1vqXXNX.js +9 -0
- package/dist/twilight/p-DYB20YqN.js +5 -0
- package/dist/twilight/p-Vl6qpttb.js +4 -0
- package/dist/twilight/{p-BgG5eq1x.js → p-X6Yi3bYP.js} +1 -1
- package/dist/twilight/{p-d022b6ec.entry.js → p-a01f1992.entry.js} +1 -1
- package/dist/twilight/{p-5d37cc33.entry.js → p-aa7c5de0.entry.js} +1 -1
- package/dist/twilight/{p-b6ded196.entry.js → p-aaa0c743.entry.js} +1 -1
- package/dist/twilight/{p-713590e2.entry.js → p-ad041ab5.entry.js} +1 -1
- package/dist/twilight/{p-d1dd1db6.entry.js → p-ad07f67a.entry.js} +1 -1
- package/dist/twilight/{p-f1f74b41.entry.js → p-af3c74f4.entry.js} +1 -1
- package/dist/twilight/p-af60e72a.entry.js +4 -0
- package/dist/twilight/{p-bdcf3926.entry.js → p-b17d055d.entry.js} +1 -1
- package/dist/twilight/{p-c68f3054.entry.js → p-b598c0f7.entry.js} +1 -1
- package/dist/twilight/{p-8c6db6d7.entry.js → p-b64f3155.entry.js} +1 -1
- package/dist/twilight/p-bNzv71Xl.js +9 -0
- package/dist/twilight/{p-BqCmPfAo.js → p-bScl0xMh.js} +2 -2
- package/dist/twilight/{p-344c1910.entry.js → p-bff4c7b3.entry.js} +1 -1
- package/dist/twilight/{p-1b1f9f71.entry.js → p-c091e2dc.entry.js} +1 -1
- package/dist/twilight/{p-775b42ec.entry.js → p-c1fd45b1.entry.js} +1 -1
- package/dist/twilight/{p-1c215c8c.entry.js → p-c3ffb88a.entry.js} +1 -1
- package/dist/twilight/{p-9deae4f4.entry.js → p-c87951a2.entry.js} +1 -1
- package/dist/twilight/{p-1899f283.entry.js → p-ccfe5308.entry.js} +1 -1
- package/dist/twilight/{p-98eb495e.entry.js → p-d337c399.entry.js} +1 -1
- package/dist/twilight/{p-7b717899.entry.js → p-d371d450.entry.js} +1 -1
- package/dist/twilight/{p-f8b6967f.entry.js → p-d4a242f8.entry.js} +1 -1
- package/dist/twilight/{p-194d87c6.entry.js → p-d9f5a8cd.entry.js} +1 -1
- package/dist/twilight/{p-ff9b33bb.entry.js → p-dd2bd5dc.entry.js} +1 -1
- package/dist/twilight/{p-e89812d8.entry.js → p-df6853b5.entry.js} +1 -1
- package/dist/twilight/{p-05663bb1.entry.js → p-e28c0773.entry.js} +1 -1
- package/dist/twilight/{p-a76b3dba.entry.js → p-e3b8e0e1.entry.js} +1 -1
- package/dist/twilight/p-e679884a.entry.js +4 -0
- package/dist/twilight/{p-11767786.entry.js → p-e6bbf50d.entry.js} +1 -1
- package/dist/twilight/{p-1ca75c99.entry.js → p-e94f217b.entry.js} +1 -1
- package/dist/twilight/{p-d81ad2c3.entry.js → p-eac718cd.entry.js} +1 -1
- package/dist/twilight/{p-85ceef78.entry.js → p-ede67a08.entry.js} +1 -1
- package/dist/twilight/p-efab88c5.entry.js +4 -0
- package/dist/twilight/{p-1dbaefb8.entry.js → p-f176d41d.entry.js} +1 -1
- package/dist/twilight/p-f5d15e71.entry.js +4 -0
- package/dist/twilight/{p-50621375.entry.js → p-f7999a6d.entry.js} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components/salla-count-down/salla-count-down.d.ts +6 -0
- package/dist/types/components/salla-notifications/interfaces.d.ts +20 -0
- package/dist/types/components/salla-notifications/salla-notifications.d.ts +17 -0
- package/dist/types/components.d.ts +763 -177
- package/dist/types/stencil-public-runtime.d.ts +169 -11
- package/package.json +5 -5
- package/dist/cjs/filepond-plugin-file-validate-type-Dfy66STE.js +0 -287
- package/dist/esm/filepond-plugin-file-validate-type-BYs_scJr.js +0 -285
- package/dist/twilight/p-0652987b.entry.js +0 -4
- package/dist/twilight/p-14529fd6.entry.js +0 -4
- package/dist/twilight/p-1c8394db.entry.js +0 -4
- package/dist/twilight/p-346b55d6.entry.js +0 -4
- package/dist/twilight/p-3962c34c.entry.js +0 -4
- package/dist/twilight/p-4e9e3ab1.entry.js +0 -4
- package/dist/twilight/p-549f59ed.entry.js +0 -4
- package/dist/twilight/p-54f65187.entry.js +0 -4
- package/dist/twilight/p-726513f8.entry.js +0 -4
- package/dist/twilight/p-753464fd.entry.js +0 -4
- package/dist/twilight/p-AfW2b46_.js +0 -9
- package/dist/twilight/p-C23tPnnH.js +0 -5
- package/dist/twilight/p-CrYUKEsF.js +0 -9
- package/dist/twilight/p-HWjjIZ9_.js +0 -9
- package/dist/twilight/p-Ig1Tafsp.js +0 -9
- package/dist/twilight/p-c9001d7f.entry.js +0 -4
- package/dist/twilight/p-cf9573fd.entry.js +0 -4
- package/dist/twilight/p-e6124fab.entry.js +0 -4
- package/dist/twilight/p-eb5a8329.entry.js +0 -4
|
@@ -1,2244 +1,9 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Crafted with ❤ by Salla
|
|
3
3
|
*/
|
|
4
|
-
import { g as getDefaultExportFromCjs } from './_commonjsHelpers.js';
|
|
5
|
-
|
|
6
|
-
function _mergeNamespaces(n, m) {
|
|
7
|
-
m.forEach(function (e) {
|
|
8
|
-
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
9
|
-
if (k !== 'default' && !(k in n)) {
|
|
10
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function () { return e[k]; }
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
return Object.freeze(n);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
var filepondPluginImagePreview$3 = {exports: {}};
|
|
22
|
-
|
|
4
|
+
import{g as t}from"./_commonjsHelpers.js";function n(t,n){return n.forEach((function(n){n&&"string"!=typeof n&&!Array.isArray(n)&&Object.keys(n).forEach((function(i){if("default"!==i&&!(i in t)){var r=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return n[i]}})}}))})),Object.freeze(t)}var i,r={exports:{}},e=(i||(i=1,r.exports=function(){function t(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){var i=[],r=!0,e=!1,a=void 0;try{for(var o,u=t[Symbol.iterator]();!(r=(o=u.next()).done)&&(i.push(o.value),i.length!==n);r=!0);}catch(t){e=!0,a=t}finally{try{r||null==u.return||u.return()}finally{if(e)throw a}}return i}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var n=function(t,n){return e(t.x*n,t.y*n)},i=function(t,n){return e(t.x+n.x,t.y+n.y)},r=function(t,n,i){var r=Math.cos(n),a=Math.sin(n),o=e(t.x-i.x,t.y-i.y);return e(i.x+r*o.x-a*o.y,i.y+a*o.x+r*o.y)},e=function(){return{x:arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,y:arguments.length>1&&void 0!==arguments[1]?arguments[1]:0}},a=function(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3?arguments[3]:void 0;return"string"==typeof t?parseFloat(t)*i:"number"==typeof t?t*(r?n[r]:Math.min(n.width,n.height)):void 0},o=function(t){return null!=t},u=function(t,n){return Object.keys(n).forEach((function(i){return t.setAttribute(i,n[i])}))},c=function(t,n){var i=document.createElementNS("http://www.w3.org/2000/svg",t);return n&&u(i,n),i},f={contain:"xMidYMid meet",cover:"xMidYMid slice"},E={left:"start",center:"middle",right:"end"},_=function(t){return function(n){return c(t,{id:n.id})}},s={image:function(t){var n=c("image",{id:t.id,"stroke-linecap":"round","stroke-linejoin":"round",opacity:"0"});return n.onload=function(){n.setAttribute("opacity",t.opacity||1)},n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t.src),n},rect:_("rect"),ellipse:_("ellipse"),text:_("text"),path:_("path"),line:function(t){var n=c("g",{id:t.id,"stroke-linecap":"round","stroke-linejoin":"round"}),i=c("line");n.appendChild(i);var r=c("path");n.appendChild(r);var e=c("path");return n.appendChild(e),n}},l={rect:function(t){return u(t,Object.assign({},t.rect,t.styles))},ellipse:function(t){return u(t,Object.assign({cx:t.rect.x+.5*t.rect.width,cy:t.rect.y+.5*t.rect.height,rx:.5*t.rect.width,ry:.5*t.rect.height},t.styles))},image:function(t,n){u(t,Object.assign({},t.rect,t.styles,{preserveAspectRatio:f[n.fit]||"none"}))},text:function(t,n,i,r){var e=a(n.fontSize,i,r);u(t,Object.assign({},t.rect,t.styles,{"stroke-width":0,"font-weight":n.fontWeight||"normal","font-size":e,"font-family":n.fontFamily||"sans-serif","text-anchor":E[n.textAlign]||"start"})),t.text!==n.text&&(t.text=n.text,t.textContent=n.text.length?n.text:" ")},path:function(t,n,i,r){var e;u(t,Object.assign({},t.styles,{fill:"none",d:(e=n.points.map((function(t){return{x:a(t.x,i,r,"width"),y:a(t.y,i,r,"height")}})),e.map((function(t,n){return"".concat(0===n?"M":"L"," ").concat(t.x," ").concat(t.y)})).join(" "))}))},line:function(t,o,c,f){u(t,Object.assign({},t.rect,t.styles,{fill:"none"}));var E=t.childNodes[1],_=t.childNodes[2],s=t.rect,l={x:t.rect.x+t.rect.width,y:t.rect.y+t.rect.height};if(u(t.childNodes[0],{x1:s.x,y1:s.y,x2:l.x,y2:l.y}),o.lineDecoration){E.style.display="none",_.style.display="none";var v=function(t){var n=Math.sqrt(t.x*t.x+t.y*t.y);return 0===n?{x:0,y:0}:e(t.x/n,t.y/n)}({x:l.x-s.x,y:l.y-s.y}),h=a(.05,c,f);if(-1!==o.lineDecoration.indexOf("arrow-begin")){var I=n(v,h),d=i(s,I),p=r(s,2,d),M=r(s,-2,d);u(E,{style:"display:block;",d:"M".concat(p.x,",").concat(p.y," L").concat(s.x,",").concat(s.y," L").concat(M.x,",").concat(M.y)})}if(-1!==o.lineDecoration.indexOf("arrow-end")){var g=n(v,-h),m=i(l,g),T=r(l,2,m),A=r(l,-2,m);u(_,{style:"display:block;",d:"M".concat(T.x,",").concat(T.y," L").concat(l.x,",").concat(l.y," L").concat(A.x,",").concat(A.y)})}}}},v=function(t,n,i,r,e){"path"!==n&&(t.rect=function(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=a(t.x,n,i,"width")||a(t.left,n,i,"width"),e=a(t.y,n,i,"height")||a(t.top,n,i,"height"),u=a(t.width,n,i,"width"),c=a(t.height,n,i,"height"),f=a(t.right,n,i,"width"),E=a(t.bottom,n,i,"height");return o(e)||(e=o(c)&&o(E)?n.height-c-E:E),o(r)||(r=o(u)&&o(f)?n.width-u-f:f),o(u)||(u=o(r)&&o(f)?n.width-r-f:0),o(c)||(c=o(e)&&o(E)?n.height-e-E:0),{x:r||0,y:e||0,width:u||0,height:c||0}}(i,r,e)),t.styles=function(t,n,i){var r=t.borderStyle||t.lineStyle||"solid",e=t.backgroundColor||t.fontColor||"transparent",o=t.borderColor||t.lineColor||"transparent",u=a(t.borderWidth||t.lineWidth,n,i);return{"stroke-linecap":t.lineCap||"round","stroke-linejoin":t.lineJoin||"round","stroke-width":u||0,"stroke-dasharray":"string"==typeof r?"":r.map((function(t){return a(t,n,i)})).join(","),stroke:o,fill:e,opacity:t.opacity||1}}(i,r,e),l[n](t,i,r,e)},h=["x","y","left","top","right","bottom","width","height"],I=function(n){var i=t(n,2),r=i[0],e=i[1],a=e.points?{}:h.reduce((function(t,n){return t[n]="string"==typeof(i=e[n])&&/%/.test(i)?parseFloat(i)/100:i,t;var i}),{});return[r,Object.assign({zIndex:0},e,a)]},d=function(t,n){return t[1].zIndex>n[1].zIndex?1:t[1].zIndex<n[1].zIndex?-1:0},p=function(n){return n.utils.createView({name:"image-preview-markup",tag:"svg",ignoreRect:!0,mixins:{apis:["width","height","crop","markup","resize","dirty"]},write:function(n){var i=n.root,r=n.props;if(r.dirty){var e=r.crop,a=r.resize,o=r.markup,u=r.width,c=r.height,f=e.width,E=e.height;if(a){var _=a.size,l=_&&_.width,h=_&&_.height,p=a.mode;l&&!h&&(h=l),h&&!l&&(l=h);var M=f<l&&E<h;if(!M||M&&a.upscale){var g,m=l/f,T=h/E;"force"===p?(f=l,E=h):("cover"===p?g=Math.max(m,T):"contain"===p&&(g=Math.min(m,T)),f*=g,E*=g)}}var A={width:u,height:c};i.element.setAttribute("width",A.width),i.element.setAttribute("height",A.height);var w=Math.min(u/f,c/E);i.element.innerHTML="";var R=i.query("GET_IMAGE_PREVIEW_MARKUP_FILTER");o.filter(R).map(I).sort(d).forEach((function(n){var r=t(n,2),e=r[0],a=r[1],o=function(t,n){return s[t](n)}(e,a);v(o,e,a,A,w),i.element.appendChild(o)}))}}})},M=function(t,n){return{x:t,y:n}},g=function(t,n){return M(t.x-n.x,t.y-n.y)},m=function(t,n){return Math.sqrt(function(t,n){return function(t,n){return t.x*n.x+t.y*n.y}(g(t,n),g(t,n))}(t,n))},T=function(t,n){var i=t,r=n,e=1.5707963267948966-n,a=Math.sin(1.5707963267948966),o=Math.sin(r),u=Math.sin(e),c=Math.cos(e),f=i/a;return M(c*(f*o),c*(f*u))},A=function(t,n,i,r){var e=2*(r.x>.5?1-r.x:r.x)*t.width,a=2*(r.y>.5?1-r.y:r.y)*t.height,o=function(t,n){var i=t.height,r=T(t.width,n),e=T(i,n),a=M(t.x+Math.abs(r.x),t.y-Math.abs(r.y)),o=M(t.x+t.width+Math.abs(e.y),t.y+Math.abs(e.x)),u=M(t.x-Math.abs(e.y),t.y+t.height-Math.abs(e.x));return{width:m(a,o),height:m(a,u)}}(n,i);return Math.max(o.width/e,o.height/a)},w=function(t,n){var i=t.width,r=i*n;return r>t.height&&(i=(r=t.height)/n),{x:.5*(t.width-i),y:.5*(t.height-r),width:i,height:r}},R=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.zoom,r=n.rotation,e=n.center,a=n.aspectRatio;a||(a=t.height/t.width);var o=function(t,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=t.height/t.width,e=1,a=r;a>n&&(e=(a=n)/r);var o=Math.max(1/e,n/a),u=t.width/(i*o*e);return{width:u,height:u*n}}(t,a,i),u=void 0===n.scaleToFit||n.scaleToFit,c=i*A(t,w({width:o.width,height:o.height},a),r,u?e:{x:.5,y:.5});return{widthFloat:o.width/c,heightFloat:o.height/c,width:Math.round(o.width/c),height:Math.round(o.height/c)}},y={type:"spring",stiffness:.5,damping:.45,mass:10},G=function(t){return t.utils.createView({name:"image-clip",tag:"div",ignoreRect:!0,mixins:{apis:["crop","markup","resize","width","height","dirty","background"],styles:["width","height","opacity"],animations:{opacity:{type:"tween",duration:250}}},didWriteView:function(t){var n=t.props;n.background&&(t.root.element.style.backgroundColor=n.background)},create:function(n){var i=n.root,r=n.props;i.ref.image=i.appendChildView(i.createChildView(function(t){return t.utils.createView({name:"image-canvas-wrapper",tag:"div",ignoreRect:!0,mixins:{apis:["crop","width","height"],styles:["originX","originY","translateX","translateY","scaleX","scaleY","rotateZ"],animations:{originX:y,originY:y,scaleX:y,scaleY:y,translateX:y,translateY:y,rotateZ:y}},create:function(n){var i=n.root,r=n.props;r.width=r.image.width,r.height=r.image.height,i.ref.bitmap=i.appendChildView(i.createChildView(function(t){return t.utils.createView({name:"image-bitmap",ignoreRect:!0,mixins:{styles:["scaleX","scaleY"]},create:function(t){t.root.appendChild(t.props.image)}})}(t),{image:r.image}))},write:function(t){var n=t.props.crop.flip,i=t.root.ref.bitmap;i.scaleX=n.horizontal?-1:1,i.scaleY=n.vertical?-1:1}})}(t),Object.assign({},r))),i.ref.createMarkup=function(){i.ref.markup||(i.ref.markup=i.appendChildView(i.createChildView(p(t),Object.assign({},r))))},i.ref.destroyMarkup=function(){i.ref.markup&&(i.removeChildView(i.ref.markup),i.ref.markup=null)};var e=i.query("GET_IMAGE_PREVIEW_TRANSPARENCY_INDICATOR");null!==e&&(i.element.dataset.transparencyIndicator="grid"===e?e:"color")},write:function(t){var n=t.root,i=t.props,r=t.shouldOptimize,e=i.crop,a=i.markup,o=i.resize,u=i.dirty,c=i.width,f=i.height;n.ref.image.crop=e;var E={width:c,height:f,center:{x:.5*c,y:.5*f}},_={width:n.ref.image.width,height:n.ref.image.height},s={x:e.center.x*_.width,y:e.center.y*_.height},l={x:E.center.x-_.width*e.center.x,y:E.center.y-_.height*e.center.y},v=2*Math.PI+e.rotation%(2*Math.PI),h=void 0===e.scaleToFit||e.scaleToFit,I=A(_,w(E,e.aspectRatio||_.height/_.width),v,h?e.center:{x:.5,y:.5}),d=e.zoom*I;a&&a.length?(n.ref.createMarkup(),n.ref.markup.width=c,n.ref.markup.height=f,n.ref.markup.resize=o,n.ref.markup.dirty=u,n.ref.markup.markup=a,n.ref.markup.crop=R(_,e)):n.ref.markup&&n.ref.destroyMarkup();var p=n.ref.image;if(r)return p.originX=null,p.originY=null,p.translateX=null,p.translateY=null,p.rotateZ=null,p.scaleX=null,void(p.scaleY=null);p.originX=s.x,p.originY=s.y,p.translateX=l.x,p.translateY=l.y,p.rotateZ=v,p.scaleX=d,p.scaleY=d}})},P=0,D=function(){self.onmessage=function(t){createImageBitmap(t.data.message.file).then((function(n){self.postMessage({id:t.data.id,message:n},[n])}))}},O=function(){self.onmessage=function(t){for(var n=t.data.message.imageData,i=t.data.message.colorMatrix,r=n.data,e=r.length,a=i[0],o=i[1],u=i[2],c=i[3],f=i[4],E=i[5],_=i[6],s=i[7],l=i[8],v=i[9],h=i[10],I=i[11],d=i[12],p=i[13],M=i[14],g=i[15],m=i[16],T=i[17],A=i[18],w=i[19],R=0,y=0,G=0,P=0,D=0;R<e;R+=4)y=r[R]/255,G=r[R+1]/255,P=r[R+2]/255,D=r[R+3]/255,r[R]=Math.max(0,Math.min(255*(y*a+G*o+P*u+D*c+f),255)),r[R+1]=Math.max(0,Math.min(255*(y*E+G*_+P*s+D*l+v),255)),r[R+2]=Math.max(0,Math.min(255*(y*h+G*I+P*d+D*p+M),255)),r[R+3]=Math.max(0,Math.min(255*(y*g+G*m+P*T+D*A+w),255));self.postMessage({id:t.data.id,message:n},[n.data.buffer])}},x={1:function(){return[1,0,0,1,0,0]},2:function(t){return[-1,0,0,1,t,0]},3:function(t,n){return[-1,0,0,-1,t,n]},4:function(t,n){return[1,0,0,-1,0,n]},5:function(){return[0,1,1,0,0,0]},6:function(t,n){return[0,1,-1,0,n,0]},7:function(t,n){return[0,-1,-1,0,n,t]},8:function(t){return[0,-1,1,0,0,t]}},L=function(t,n,i,r){n=Math.round(n),i=Math.round(i);var e=document.createElement("canvas");e.width=n,e.height=i;var a=e.getContext("2d");if(r>=5&&r<=8){var o=[i,n];n=o[0],i=o[1]}return function(t,n,i,r){-1!==r&&t.transform.apply(t,x[r](n,i))}(a,n,i,r),a.drawImage(t,0,0,n,i),e},C=function(t){return/^image/.test(t.type)&&!/svg/.test(t.type)},W=function(t){var n=Math.min(10/t.width,10/t.height),i=document.createElement("canvas"),r=i.getContext("2d"),e=i.width=Math.ceil(t.width*n),a=i.height=Math.ceil(t.height*n);r.drawImage(t,0,0,e,a);var o=null;try{o=r.getImageData(0,0,e,a).data}catch(t){return null}for(var u=o.length,c=0,f=0,E=0,_=0;_<u;_+=4)c+=o[_]*o[_],f+=o[_+1]*o[_+1],E+=o[_+2]*o[_+2];return{r:c=S(c,u),g:f=S(f,u),b:E=S(E,u)}},S=function(t,n){return Math.floor(Math.sqrt(t/(n/4)))},k=function(t){var n=t.utils.createView({name:"image-preview-overlay",tag:"div",ignoreRect:!0,create:function(t){var n=t.root,i=t.props,r='<svg width="500" height="200" viewBox="0 0 500 200" preserveAspectRatio="none">\n <defs>\n <radialGradient id="gradient-__UID__" cx=".5" cy="1.25" r="1.15">\n <stop offset=\'50%\' stop-color=\'#000000\'/>\n <stop offset=\'56%\' stop-color=\'#0a0a0a\'/>\n <stop offset=\'63%\' stop-color=\'#262626\'/>\n <stop offset=\'69%\' stop-color=\'#4f4f4f\'/>\n <stop offset=\'75%\' stop-color=\'#808080\'/>\n <stop offset=\'81%\' stop-color=\'#b1b1b1\'/>\n <stop offset=\'88%\' stop-color=\'#dadada\'/>\n <stop offset=\'94%\' stop-color=\'#f6f6f6\'/>\n <stop offset=\'100%\' stop-color=\'#ffffff\'/>\n </radialGradient>\n <mask id="mask-__UID__">\n <rect x="0" y="0" width="500" height="200" fill="url(#gradient-__UID__)"></rect>\n </mask>\n </defs>\n <rect x="0" width="500" height="200" fill="currentColor" mask="url(#mask-__UID__)"></rect>\n</svg>';if(document.querySelector("base")){var e=new URL(window.location.href.replace(window.location.hash,"")).href;r=r.replace(/url\(\#/g,"url("+e+"#")}P++,n.element.classList.add("filepond--image-preview-overlay-".concat(i.status)),n.element.innerHTML=r.replace(/__UID__/g,P)},mixins:{styles:["opacity"],animations:{opacity:{type:"spring",mass:25}}}}),i=function(t){return t.utils.createView({name:"image-preview",tag:"div",ignoreRect:!0,mixins:{apis:["image","crop","markup","resize","dirty","background"],styles:["translateY","scaleX","scaleY","opacity"],animations:{scaleX:y,scaleY:y,translateY:y,opacity:{type:"tween",duration:400}}},create:function(n){var i=n.root,r=n.props;i.ref.clip=i.appendChildView(i.createChildView(G(t),{id:r.id,image:r.image,crop:r.crop,markup:r.markup,resize:r.resize,dirty:r.dirty,background:r.background}))},write:function(t){var n=t.root,i=t.props,r=t.shouldOptimize,e=n.ref.clip,a=i.image,o=i.crop,u=i.markup,c=i.resize,f=i.dirty;if(e.crop=o,e.markup=u,e.resize=c,e.dirty=f,e.opacity=r?0:1,!r&&!n.rect.element.hidden){var E=o.aspectRatio||a.height/a.width,_=n.rect.inner.width,s=n.rect.inner.height,l=n.query("GET_IMAGE_PREVIEW_HEIGHT"),v=n.query("GET_IMAGE_PREVIEW_MIN_HEIGHT"),h=n.query("GET_IMAGE_PREVIEW_MAX_HEIGHT"),I=n.query("GET_PANEL_ASPECT_RATIO"),d=n.query("GET_ALLOW_MULTIPLE");I&&!d&&(l=_*I,E=I);var p=null!==l?l:Math.max(v,Math.min(_*E,h)),M=p/E;M>_&&(p=(M=_)*E),p>s&&(p=s,M=s/E),e.width=M,e.height=p}}})}(t),r=t.utils.createWorker,e=function(t,n,i){return new Promise((function(e){t.ref.imageData||(t.ref.imageData=i.getContext("2d").getImageData(0,0,i.width,i.height));var a=function(t){var n;try{n=new ImageData(t.width,t.height)}catch(i){n=document.createElement("canvas").getContext("2d").createImageData(t.width,t.height)}return n.data.set(new Uint8ClampedArray(t.data)),n}(t.ref.imageData);if(!n||20!==n.length)return i.getContext("2d").putImageData(a,0,0),e();var o=r(O);o.post({imageData:a,colorMatrix:n},(function(t){i.getContext("2d").putImageData(t,0,0),o.terminate(),e()}),[a.data.buffer])}))},a=function(t){var n=t.root,r=t.image,e=t.props.id,a=n.query("GET_ITEM",{id:e});if(a){var o,u,c=a.getMetadata("crop")||{center:{x:.5,y:.5},flip:{horizontal:!1,vertical:!1},zoom:1,rotation:0,aspectRatio:null},f=n.query("GET_IMAGE_TRANSFORM_CANVAS_BACKGROUND_COLOR"),E=!1;n.query("GET_IMAGE_PREVIEW_MARKUP_SHOW")&&(o=a.getMetadata("markup")||[],u=a.getMetadata("resize"),E=!0);var _=n.appendChildView(n.createChildView(i,{id:e,image:r,crop:c,resize:u,markup:o,dirty:E,background:f,opacity:0,scaleX:1.15,scaleY:1.15,translateY:15}),n.childViews.length);n.ref.images.push(_),_.opacity=1,_.scaleX=1,_.scaleY=1,_.translateY=0,setTimeout((function(){n.dispatch("DID_IMAGE_PREVIEW_SHOW",{id:e})}),250)}},o=function(t){var n=t.root;n.ref.overlayShadow.opacity=1,n.ref.overlayError.opacity=0,n.ref.overlaySuccess.opacity=0},u=function(t){var n=t.root;n.ref.overlayShadow.opacity=.25,n.ref.overlayError.opacity=1};return t.utils.createView({name:"image-preview-wrapper",create:function(t){var i=t.root;i.ref.images=[],i.ref.imageData=null,i.ref.imageViewBin=[],i.ref.overlayShadow=i.appendChildView(i.createChildView(n,{opacity:0,status:"idle"})),i.ref.overlaySuccess=i.appendChildView(i.createChildView(n,{opacity:0,status:"success"})),i.ref.overlayError=i.appendChildView(i.createChildView(n,{opacity:0,status:"failure"}))},styles:["height"],apis:["height"],destroy:function(t){t.root.ref.images.forEach((function(t){t.image.width=1,t.image.height=1}))},didWriteView:function(t){t.root.ref.images.forEach((function(t){t.dirty=!1}))},write:t.utils.createRoute({DID_IMAGE_PREVIEW_DRAW:function(t){var n=t.root,i=n.ref.images[n.ref.images.length-1];i.translateY=0,i.scaleX=1,i.scaleY=1,i.opacity=1},DID_IMAGE_PREVIEW_CONTAINER_CREATE:function(t){var n,i,r,e=t.root,a=t.props.id,o=e.query("GET_ITEM",a);if(o){var u=URL.createObjectURL(o.file);n=u,i=function(t,n){e.dispatch("DID_IMAGE_PREVIEW_CALCULATE_SIZE",{id:a,width:t,height:n})},(r=new Image).onload=function(){var t=r.naturalWidth,n=r.naturalHeight;r=null,i(t,n)},r.src=n}},DID_FINISH_CALCULATE_PREVIEWSIZE:function(t){var n,i,o,u=t.root,c=t.props,f=u.query("GET_ITEM",c.id);if(f){var E=URL.createObjectURL(f.file),_=function(){var t;(t=E,new Promise((function(n,i){var r=new Image;r.crossOrigin="Anonymous",r.onload=function(){n(r)},r.onerror=function(t){i(t)},r.src=t}))).then(s)},s=function(t){URL.revokeObjectURL(E);var n=(f.getMetadata("exif")||{}).orientation||-1,i=t.width,r=t.height;if(i&&r){if(n>=5&&n<=8){var o=[r,i];i=o[0],r=o[1]}var _=Math.max(1,.75*window.devicePixelRatio),s=u.query("GET_IMAGE_PREVIEW_ZOOM_FACTOR")*_,l=r/i,v=u.rect.element.width,h=u.rect.element.height,I=v,d=I*l;l>1?d=(I=Math.min(i,v*s))*l:I=(d=Math.min(r,h*s))/l;var p=L(t,I,d,n),M=function(){var n=u.query("GET_IMAGE_PREVIEW_CALCULATE_AVERAGE_IMAGE_COLOR")?W(data):null;f.setMetadata("color",n,!0),"close"in t&&t.close(),u.ref.overlayShadow.opacity=1,a({root:u,props:c,image:p})},g=f.getMetadata("filter");g?e(u,g,p).then(M):M()}};if(n=f.file,i=window.navigator.userAgent.match(/Firefox\/([0-9]+)\./),null!==(o=i?parseInt(i[1]):null)&&o<=58||!("createImageBitmap"in window)||!C(n))_();else{var l=r(D);l.post({file:f.file},(function(t){l.terminate(),t?s(t):_()}))}}},DID_UPDATE_ITEM_METADATA:function(t){var n,i,r=t.root,o=t.props,u=t.action;if(/crop|filter|markup|resize/.test(u.change.key)&&r.ref.images.length){var c=r.query("GET_ITEM",{id:o.id});if(c)if(/filter/.test(u.change.key))e(r,u.change.value,r.ref.images[r.ref.images.length-1].image);else if(/crop|markup|resize/.test(u.change.key)){var f=c.getMetadata("crop"),E=r.ref.images[r.ref.images.length-1];if(f&&f.aspectRatio&&E.crop&&E.crop.aspectRatio&&Math.abs(f.aspectRatio-E.crop.aspectRatio)>1e-5){var _=function(t){var n=t.root,i=n.ref.images.shift();return i.opacity=0,i.translateY=-15,n.ref.imageViewBin.push(i),i}({root:r});a({root:r,props:o,image:(n=_.image,(i=i||document.createElement("canvas")).width=n.width,i.height=n.height,i.getContext("2d").drawImage(n,0,0),i)})}else!function(t){var n=t.root,i=n.query("GET_ITEM",{id:t.props.id});if(i){var r=n.ref.images[n.ref.images.length-1];r.crop=i.getMetadata("crop"),r.background=n.query("GET_IMAGE_TRANSFORM_CANVAS_BACKGROUND_COLOR"),n.query("GET_IMAGE_PREVIEW_MARKUP_SHOW")&&(r.dirty=!0,r.resize=i.getMetadata("resize"),r.markup=i.getMetadata("markup"))}}({root:r,props:o})}}},DID_THROW_ITEM_LOAD_ERROR:u,DID_THROW_ITEM_PROCESSING_ERROR:u,DID_THROW_ITEM_INVALID:u,DID_COMPLETE_ITEM_PROCESSING:function(t){var n=t.root;n.ref.overlayShadow.opacity=.25,n.ref.overlaySuccess.opacity=1},DID_START_ITEM_PROCESSING:o,DID_REVERT_ITEM_PROCESSING:o},(function(t){var n=t.root,i=n.ref.imageViewBin.filter((function(t){return 0===t.opacity}));n.ref.imageViewBin=n.ref.imageViewBin.filter((function(t){return t.opacity>0})),i.forEach((function(t){return function(t,n){t.removeChildView(n),n.image.width=1,n.image.height=1,n._destroy()}(n,t)})),i.length=0}))})},V=function(t){var n=t.addFilter,i=t.utils,r=i.Type,e=i.createRoute,a=i.isFile,o=k(t);return n("CREATE_VIEW",(function(t){var n=t.view,i=t.query;if((0,t.is)("file")&&i("GET_ALLOW_IMAGE_PREVIEW")){var r=function(t){t.root.ref.shouldRescale=!0};n.registerWriter(e({DID_RESIZE_ROOT:r,DID_STOP_RESIZE:r,DID_LOAD_ITEM:function(t){var r=t.root,e=t.props.id,u=i("GET_ITEM",e);if(u&&a(u.file)&&!u.archived){var c=u.file;if(function(t){return/^image/.test(t.type)}(c)&&i("GET_IMAGE_PREVIEW_FILTER_ITEM")(u)){var f="createImageBitmap"in(window||{}),E=i("GET_IMAGE_PREVIEW_MAX_FILE_SIZE");if(!(!f&&E&&c.size>E)){r.ref.imagePreview=n.appendChildView(n.createChildView(o,{id:e}));var _=r.query("GET_IMAGE_PREVIEW_HEIGHT");_&&r.dispatch("DID_UPDATE_PANEL_HEIGHT",{id:u.id,height:_});var s=!f&&c.size>i("GET_IMAGE_PREVIEW_MAX_INSTANT_PREVIEW_FILE_SIZE");r.dispatch("DID_IMAGE_PREVIEW_CONTAINER_CREATE",{id:e},s)}}}},DID_IMAGE_PREVIEW_CALCULATE_SIZE:function(t){var n=t.root,i=t.action;n.ref.imageWidth=i.width,n.ref.imageHeight=i.height,n.ref.shouldRescale=!0,n.ref.shouldDrawPreview=!0,n.dispatch("KICK")},DID_UPDATE_ITEM_METADATA:function(t){"crop"===t.action.change.key&&(t.root.ref.shouldRescale=!0)}},(function(t){var n=t.root,i=t.props;n.ref.imagePreview&&(n.rect.element.hidden||(n.ref.shouldRescale&&(function(t,n){if(t.ref.imagePreview){var i=t.query("GET_ITEM",{id:n.id});if(i){var r=t.query("GET_PANEL_ASPECT_RATIO"),e=t.query("GET_ITEM_PANEL_ASPECT_RATIO"),a=t.query("GET_IMAGE_PREVIEW_HEIGHT");if(!(r||e||a)){var o=t.ref,u=o.imageWidth,c=o.imageHeight;if(u&&c){var f=t.query("GET_IMAGE_PREVIEW_MIN_HEIGHT"),E=t.query("GET_IMAGE_PREVIEW_MAX_HEIGHT"),_=(i.getMetadata("exif")||{}).orientation||-1;if(_>=5&&_<=8){var s=[c,u];u=s[0],c=s[1]}if(!C(i.file)||t.query("GET_IMAGE_PREVIEW_UPSCALE")){var l=2048/u;u*=l,c*=l}var v=c/u,h=(i.getMetadata("crop")||{}).aspectRatio||v,I=Math.max(f,Math.min(c,E)),d=Math.min(t.rect.element.width*h,I);t.dispatch("DID_UPDATE_PANEL_HEIGHT",{id:i.id,height:d})}}}}}(n,i),n.ref.shouldRescale=!1),n.ref.shouldDrawPreview&&(requestAnimationFrame((function(){requestAnimationFrame((function(){n.dispatch("DID_FINISH_CALCULATE_PREVIEWSIZE",{id:i.id})}))})),n.ref.shouldDrawPreview=!1)))})))}})),{options:{allowImagePreview:[!0,r.BOOLEAN],imagePreviewFilterItem:[function(){return!0},r.FUNCTION],imagePreviewHeight:[null,r.INT],imagePreviewMinHeight:[44,r.INT],imagePreviewMaxHeight:[256,r.INT],imagePreviewMaxFileSize:[null,r.INT],imagePreviewZoomFactor:[2,r.INT],imagePreviewUpscale:[!1,r.BOOLEAN],imagePreviewMaxInstantPreviewFileSize:[1e6,r.INT],imagePreviewTransparencyIndicator:[null,r.STRING],imagePreviewCalculateAverageImageColor:[!1,r.BOOLEAN],imagePreviewMarkupShow:[!0,r.BOOLEAN],imagePreviewMarkupFilter:[function(){return!0},r.FUNCTION]}}};return"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:V})),V}()),r.exports),a=n({__proto__:null,default:t(e)},[e]);
|
|
23
5
|
/*!
|
|
24
6
|
* FilePondPluginImagePreview 4.6.12
|
|
25
7
|
* Licensed under MIT, https://opensource.org/licenses/MIT/
|
|
26
8
|
* Please visit https://pqina.nl/filepond/ for details.
|
|
27
|
-
*/
|
|
28
|
-
var filepondPluginImagePreview$2 = filepondPluginImagePreview$3.exports;
|
|
29
|
-
|
|
30
|
-
var hasRequiredFilepondPluginImagePreview;
|
|
31
|
-
|
|
32
|
-
function requireFilepondPluginImagePreview () {
|
|
33
|
-
if (hasRequiredFilepondPluginImagePreview) return filepondPluginImagePreview$3.exports;
|
|
34
|
-
hasRequiredFilepondPluginImagePreview = 1;
|
|
35
|
-
(function (module, exports) {
|
|
36
|
-
/* eslint-disable */
|
|
37
|
-
|
|
38
|
-
(function(global, factory) {
|
|
39
|
-
(module.exports = factory())
|
|
40
|
-
;
|
|
41
|
-
})(filepondPluginImagePreview$2, function() {
|
|
42
|
-
|
|
43
|
-
// test if file is of type image and can be viewed in canvas
|
|
44
|
-
var isPreviewableImage = function isPreviewableImage(file) {
|
|
45
|
-
return /^image/.test(file.type);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
function _slicedToArray(arr, i) {
|
|
49
|
-
return (
|
|
50
|
-
_arrayWithHoles(arr) ||
|
|
51
|
-
_iterableToArrayLimit(arr, i) ||
|
|
52
|
-
_nonIterableRest()
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function _arrayWithHoles(arr) {
|
|
57
|
-
if (Array.isArray(arr)) return arr;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function _iterableToArrayLimit(arr, i) {
|
|
61
|
-
var _arr = [];
|
|
62
|
-
var _n = true;
|
|
63
|
-
var _d = false;
|
|
64
|
-
var _e = undefined;
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
for (
|
|
68
|
-
var _i = arr[Symbol.iterator](), _s;
|
|
69
|
-
!(_n = (_s = _i.next()).done);
|
|
70
|
-
_n = true
|
|
71
|
-
) {
|
|
72
|
-
_arr.push(_s.value);
|
|
73
|
-
|
|
74
|
-
if (_arr.length === i) break;
|
|
75
|
-
}
|
|
76
|
-
} catch (err) {
|
|
77
|
-
_d = true;
|
|
78
|
-
_e = err;
|
|
79
|
-
} finally {
|
|
80
|
-
try {
|
|
81
|
-
if (!_n && _i['return'] != null) _i['return']();
|
|
82
|
-
} finally {
|
|
83
|
-
if (_d) throw _e;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return _arr;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function _nonIterableRest() {
|
|
91
|
-
throw new TypeError('Invalid attempt to destructure non-iterable instance');
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
var vectorMultiply = function vectorMultiply(v, amount) {
|
|
95
|
-
return createVector(v.x * amount, v.y * amount);
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
var vectorAdd = function vectorAdd(a, b) {
|
|
99
|
-
return createVector(a.x + b.x, a.y + b.y);
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
var vectorNormalize = function vectorNormalize(v) {
|
|
103
|
-
var l = Math.sqrt(v.x * v.x + v.y * v.y);
|
|
104
|
-
if (l === 0) {
|
|
105
|
-
return {
|
|
106
|
-
x: 0,
|
|
107
|
-
y: 0
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
return createVector(v.x / l, v.y / l);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
var vectorRotate = function vectorRotate(v, radians, origin) {
|
|
114
|
-
var cos = Math.cos(radians);
|
|
115
|
-
var sin = Math.sin(radians);
|
|
116
|
-
var t = createVector(v.x - origin.x, v.y - origin.y);
|
|
117
|
-
return createVector(
|
|
118
|
-
origin.x + cos * t.x - sin * t.y,
|
|
119
|
-
origin.y + sin * t.x + cos * t.y
|
|
120
|
-
);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
var createVector = function createVector() {
|
|
124
|
-
var x =
|
|
125
|
-
arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
126
|
-
var y =
|
|
127
|
-
arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
128
|
-
return { x: x, y: y };
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
var getMarkupValue = function getMarkupValue(value, size) {
|
|
132
|
-
var scalar =
|
|
133
|
-
arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
134
|
-
var axis = arguments.length > 3 ? arguments[3] : undefined;
|
|
135
|
-
if (typeof value === 'string') {
|
|
136
|
-
return parseFloat(value) * scalar;
|
|
137
|
-
}
|
|
138
|
-
if (typeof value === 'number') {
|
|
139
|
-
return value * (axis ? size[axis] : Math.min(size.width, size.height));
|
|
140
|
-
}
|
|
141
|
-
return;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
var getMarkupStyles = function getMarkupStyles(markup, size, scale) {
|
|
145
|
-
var lineStyle = markup.borderStyle || markup.lineStyle || 'solid';
|
|
146
|
-
var fill = markup.backgroundColor || markup.fontColor || 'transparent';
|
|
147
|
-
var stroke = markup.borderColor || markup.lineColor || 'transparent';
|
|
148
|
-
var strokeWidth = getMarkupValue(
|
|
149
|
-
markup.borderWidth || markup.lineWidth,
|
|
150
|
-
size,
|
|
151
|
-
scale
|
|
152
|
-
);
|
|
153
|
-
var lineCap = markup.lineCap || 'round';
|
|
154
|
-
var lineJoin = markup.lineJoin || 'round';
|
|
155
|
-
var dashes =
|
|
156
|
-
typeof lineStyle === 'string'
|
|
157
|
-
? ''
|
|
158
|
-
: lineStyle
|
|
159
|
-
.map(function(v) {
|
|
160
|
-
return getMarkupValue(v, size, scale);
|
|
161
|
-
})
|
|
162
|
-
.join(',');
|
|
163
|
-
var opacity = markup.opacity || 1;
|
|
164
|
-
return {
|
|
165
|
-
'stroke-linecap': lineCap,
|
|
166
|
-
'stroke-linejoin': lineJoin,
|
|
167
|
-
'stroke-width': strokeWidth || 0,
|
|
168
|
-
'stroke-dasharray': dashes,
|
|
169
|
-
stroke: stroke,
|
|
170
|
-
fill: fill,
|
|
171
|
-
opacity: opacity
|
|
172
|
-
};
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
var isDefined = function isDefined(value) {
|
|
176
|
-
return value != null;
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
var getMarkupRect = function getMarkupRect(rect, size) {
|
|
180
|
-
var scalar =
|
|
181
|
-
arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
182
|
-
|
|
183
|
-
var left =
|
|
184
|
-
getMarkupValue(rect.x, size, scalar, 'width') ||
|
|
185
|
-
getMarkupValue(rect.left, size, scalar, 'width');
|
|
186
|
-
var top =
|
|
187
|
-
getMarkupValue(rect.y, size, scalar, 'height') ||
|
|
188
|
-
getMarkupValue(rect.top, size, scalar, 'height');
|
|
189
|
-
var width = getMarkupValue(rect.width, size, scalar, 'width');
|
|
190
|
-
var height = getMarkupValue(rect.height, size, scalar, 'height');
|
|
191
|
-
var right = getMarkupValue(rect.right, size, scalar, 'width');
|
|
192
|
-
var bottom = getMarkupValue(rect.bottom, size, scalar, 'height');
|
|
193
|
-
|
|
194
|
-
if (!isDefined(top)) {
|
|
195
|
-
if (isDefined(height) && isDefined(bottom)) {
|
|
196
|
-
top = size.height - height - bottom;
|
|
197
|
-
} else {
|
|
198
|
-
top = bottom;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (!isDefined(left)) {
|
|
203
|
-
if (isDefined(width) && isDefined(right)) {
|
|
204
|
-
left = size.width - width - right;
|
|
205
|
-
} else {
|
|
206
|
-
left = right;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if (!isDefined(width)) {
|
|
211
|
-
if (isDefined(left) && isDefined(right)) {
|
|
212
|
-
width = size.width - left - right;
|
|
213
|
-
} else {
|
|
214
|
-
width = 0;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if (!isDefined(height)) {
|
|
219
|
-
if (isDefined(top) && isDefined(bottom)) {
|
|
220
|
-
height = size.height - top - bottom;
|
|
221
|
-
} else {
|
|
222
|
-
height = 0;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
return {
|
|
227
|
-
x: left || 0,
|
|
228
|
-
y: top || 0,
|
|
229
|
-
width: width || 0,
|
|
230
|
-
height: height || 0
|
|
231
|
-
};
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
var pointsToPathShape = function pointsToPathShape(points) {
|
|
235
|
-
return points
|
|
236
|
-
.map(function(point, index) {
|
|
237
|
-
return ''
|
|
238
|
-
.concat(index === 0 ? 'M' : 'L', ' ')
|
|
239
|
-
.concat(point.x, ' ')
|
|
240
|
-
.concat(point.y);
|
|
241
|
-
})
|
|
242
|
-
.join(' ');
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
var setAttributes = function setAttributes(element, attr) {
|
|
246
|
-
return Object.keys(attr).forEach(function(key) {
|
|
247
|
-
return element.setAttribute(key, attr[key]);
|
|
248
|
-
});
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
var ns = 'http://www.w3.org/2000/svg';
|
|
252
|
-
var svg = function svg(tag, attr) {
|
|
253
|
-
var element = document.createElementNS(ns, tag);
|
|
254
|
-
if (attr) {
|
|
255
|
-
setAttributes(element, attr);
|
|
256
|
-
}
|
|
257
|
-
return element;
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
var updateRect = function updateRect(element) {
|
|
261
|
-
return setAttributes(
|
|
262
|
-
element,
|
|
263
|
-
Object.assign({}, element.rect, element.styles)
|
|
264
|
-
);
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
var updateEllipse = function updateEllipse(element) {
|
|
268
|
-
var cx = element.rect.x + element.rect.width * 0.5;
|
|
269
|
-
var cy = element.rect.y + element.rect.height * 0.5;
|
|
270
|
-
var rx = element.rect.width * 0.5;
|
|
271
|
-
var ry = element.rect.height * 0.5;
|
|
272
|
-
return setAttributes(
|
|
273
|
-
element,
|
|
274
|
-
Object.assign(
|
|
275
|
-
{
|
|
276
|
-
cx: cx,
|
|
277
|
-
cy: cy,
|
|
278
|
-
rx: rx,
|
|
279
|
-
ry: ry
|
|
280
|
-
},
|
|
281
|
-
element.styles
|
|
282
|
-
)
|
|
283
|
-
);
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
var IMAGE_FIT_STYLE = {
|
|
287
|
-
contain: 'xMidYMid meet',
|
|
288
|
-
cover: 'xMidYMid slice'
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
var updateImage = function updateImage(element, markup) {
|
|
292
|
-
setAttributes(
|
|
293
|
-
element,
|
|
294
|
-
Object.assign({}, element.rect, element.styles, {
|
|
295
|
-
preserveAspectRatio: IMAGE_FIT_STYLE[markup.fit] || 'none'
|
|
296
|
-
})
|
|
297
|
-
);
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
var TEXT_ANCHOR = {
|
|
301
|
-
left: 'start',
|
|
302
|
-
center: 'middle',
|
|
303
|
-
right: 'end'
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
var updateText = function updateText(element, markup, size, scale) {
|
|
307
|
-
var fontSize = getMarkupValue(markup.fontSize, size, scale);
|
|
308
|
-
var fontFamily = markup.fontFamily || 'sans-serif';
|
|
309
|
-
var fontWeight = markup.fontWeight || 'normal';
|
|
310
|
-
var textAlign = TEXT_ANCHOR[markup.textAlign] || 'start';
|
|
311
|
-
|
|
312
|
-
setAttributes(
|
|
313
|
-
element,
|
|
314
|
-
Object.assign({}, element.rect, element.styles, {
|
|
315
|
-
'stroke-width': 0,
|
|
316
|
-
'font-weight': fontWeight,
|
|
317
|
-
'font-size': fontSize,
|
|
318
|
-
'font-family': fontFamily,
|
|
319
|
-
'text-anchor': textAlign
|
|
320
|
-
})
|
|
321
|
-
);
|
|
322
|
-
|
|
323
|
-
// update text
|
|
324
|
-
if (element.text !== markup.text) {
|
|
325
|
-
element.text = markup.text;
|
|
326
|
-
element.textContent = markup.text.length ? markup.text : ' ';
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
var updateLine = function updateLine(element, markup, size, scale) {
|
|
331
|
-
setAttributes(
|
|
332
|
-
element,
|
|
333
|
-
Object.assign({}, element.rect, element.styles, {
|
|
334
|
-
fill: 'none'
|
|
335
|
-
})
|
|
336
|
-
);
|
|
337
|
-
|
|
338
|
-
var line = element.childNodes[0];
|
|
339
|
-
var begin = element.childNodes[1];
|
|
340
|
-
var end = element.childNodes[2];
|
|
341
|
-
|
|
342
|
-
var origin = element.rect;
|
|
343
|
-
|
|
344
|
-
var target = {
|
|
345
|
-
x: element.rect.x + element.rect.width,
|
|
346
|
-
y: element.rect.y + element.rect.height
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
setAttributes(line, {
|
|
350
|
-
x1: origin.x,
|
|
351
|
-
y1: origin.y,
|
|
352
|
-
x2: target.x,
|
|
353
|
-
y2: target.y
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
if (!markup.lineDecoration) return;
|
|
357
|
-
|
|
358
|
-
begin.style.display = 'none';
|
|
359
|
-
end.style.display = 'none';
|
|
360
|
-
|
|
361
|
-
var v = vectorNormalize({
|
|
362
|
-
x: target.x - origin.x,
|
|
363
|
-
y: target.y - origin.y
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
var l = getMarkupValue(0.05, size, scale);
|
|
367
|
-
|
|
368
|
-
if (markup.lineDecoration.indexOf('arrow-begin') !== -1) {
|
|
369
|
-
var arrowBeginRotationPoint = vectorMultiply(v, l);
|
|
370
|
-
var arrowBeginCenter = vectorAdd(origin, arrowBeginRotationPoint);
|
|
371
|
-
var arrowBeginA = vectorRotate(origin, 2, arrowBeginCenter);
|
|
372
|
-
var arrowBeginB = vectorRotate(origin, -2, arrowBeginCenter);
|
|
373
|
-
|
|
374
|
-
setAttributes(begin, {
|
|
375
|
-
style: 'display:block;',
|
|
376
|
-
d: 'M'
|
|
377
|
-
.concat(arrowBeginA.x, ',')
|
|
378
|
-
.concat(arrowBeginA.y, ' L')
|
|
379
|
-
.concat(origin.x, ',')
|
|
380
|
-
.concat(origin.y, ' L')
|
|
381
|
-
.concat(arrowBeginB.x, ',')
|
|
382
|
-
.concat(arrowBeginB.y)
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
if (markup.lineDecoration.indexOf('arrow-end') !== -1) {
|
|
387
|
-
var arrowEndRotationPoint = vectorMultiply(v, -l);
|
|
388
|
-
var arrowEndCenter = vectorAdd(target, arrowEndRotationPoint);
|
|
389
|
-
var arrowEndA = vectorRotate(target, 2, arrowEndCenter);
|
|
390
|
-
var arrowEndB = vectorRotate(target, -2, arrowEndCenter);
|
|
391
|
-
|
|
392
|
-
setAttributes(end, {
|
|
393
|
-
style: 'display:block;',
|
|
394
|
-
d: 'M'
|
|
395
|
-
.concat(arrowEndA.x, ',')
|
|
396
|
-
.concat(arrowEndA.y, ' L')
|
|
397
|
-
.concat(target.x, ',')
|
|
398
|
-
.concat(target.y, ' L')
|
|
399
|
-
.concat(arrowEndB.x, ',')
|
|
400
|
-
.concat(arrowEndB.y)
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
};
|
|
404
|
-
|
|
405
|
-
var updatePath = function updatePath(element, markup, size, scale) {
|
|
406
|
-
setAttributes(
|
|
407
|
-
element,
|
|
408
|
-
Object.assign({}, element.styles, {
|
|
409
|
-
fill: 'none',
|
|
410
|
-
d: pointsToPathShape(
|
|
411
|
-
markup.points.map(function(point) {
|
|
412
|
-
return {
|
|
413
|
-
x: getMarkupValue(point.x, size, scale, 'width'),
|
|
414
|
-
y: getMarkupValue(point.y, size, scale, 'height')
|
|
415
|
-
};
|
|
416
|
-
})
|
|
417
|
-
)
|
|
418
|
-
})
|
|
419
|
-
);
|
|
420
|
-
};
|
|
421
|
-
|
|
422
|
-
var createShape = function createShape(node) {
|
|
423
|
-
return function(markup) {
|
|
424
|
-
return svg(node, { id: markup.id });
|
|
425
|
-
};
|
|
426
|
-
};
|
|
427
|
-
|
|
428
|
-
var createImage = function createImage(markup) {
|
|
429
|
-
var shape = svg('image', {
|
|
430
|
-
id: markup.id,
|
|
431
|
-
'stroke-linecap': 'round',
|
|
432
|
-
'stroke-linejoin': 'round',
|
|
433
|
-
opacity: '0'
|
|
434
|
-
});
|
|
435
|
-
|
|
436
|
-
shape.onload = function() {
|
|
437
|
-
shape.setAttribute('opacity', markup.opacity || 1);
|
|
438
|
-
};
|
|
439
|
-
shape.setAttributeNS(
|
|
440
|
-
'http://www.w3.org/1999/xlink',
|
|
441
|
-
'xlink:href',
|
|
442
|
-
markup.src
|
|
443
|
-
);
|
|
444
|
-
return shape;
|
|
445
|
-
};
|
|
446
|
-
|
|
447
|
-
var createLine = function createLine(markup) {
|
|
448
|
-
var shape = svg('g', {
|
|
449
|
-
id: markup.id,
|
|
450
|
-
'stroke-linecap': 'round',
|
|
451
|
-
'stroke-linejoin': 'round'
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
var line = svg('line');
|
|
455
|
-
shape.appendChild(line);
|
|
456
|
-
|
|
457
|
-
var begin = svg('path');
|
|
458
|
-
shape.appendChild(begin);
|
|
459
|
-
|
|
460
|
-
var end = svg('path');
|
|
461
|
-
shape.appendChild(end);
|
|
462
|
-
|
|
463
|
-
return shape;
|
|
464
|
-
};
|
|
465
|
-
|
|
466
|
-
var CREATE_TYPE_ROUTES = {
|
|
467
|
-
image: createImage,
|
|
468
|
-
rect: createShape('rect'),
|
|
469
|
-
ellipse: createShape('ellipse'),
|
|
470
|
-
text: createShape('text'),
|
|
471
|
-
path: createShape('path'),
|
|
472
|
-
line: createLine
|
|
473
|
-
};
|
|
474
|
-
|
|
475
|
-
var UPDATE_TYPE_ROUTES = {
|
|
476
|
-
rect: updateRect,
|
|
477
|
-
ellipse: updateEllipse,
|
|
478
|
-
image: updateImage,
|
|
479
|
-
text: updateText,
|
|
480
|
-
path: updatePath,
|
|
481
|
-
line: updateLine
|
|
482
|
-
};
|
|
483
|
-
|
|
484
|
-
var createMarkupByType = function createMarkupByType(type, markup) {
|
|
485
|
-
return CREATE_TYPE_ROUTES[type](markup);
|
|
486
|
-
};
|
|
487
|
-
|
|
488
|
-
var updateMarkupByType = function updateMarkupByType(
|
|
489
|
-
element,
|
|
490
|
-
type,
|
|
491
|
-
markup,
|
|
492
|
-
size,
|
|
493
|
-
scale
|
|
494
|
-
) {
|
|
495
|
-
if (type !== 'path') {
|
|
496
|
-
element.rect = getMarkupRect(markup, size, scale);
|
|
497
|
-
}
|
|
498
|
-
element.styles = getMarkupStyles(markup, size, scale);
|
|
499
|
-
UPDATE_TYPE_ROUTES[type](element, markup, size, scale);
|
|
500
|
-
};
|
|
501
|
-
|
|
502
|
-
var MARKUP_RECT = [
|
|
503
|
-
'x',
|
|
504
|
-
'y',
|
|
505
|
-
'left',
|
|
506
|
-
'top',
|
|
507
|
-
'right',
|
|
508
|
-
'bottom',
|
|
509
|
-
'width',
|
|
510
|
-
'height'
|
|
511
|
-
];
|
|
512
|
-
|
|
513
|
-
var toOptionalFraction = function toOptionalFraction(value) {
|
|
514
|
-
return typeof value === 'string' && /%/.test(value)
|
|
515
|
-
? parseFloat(value) / 100
|
|
516
|
-
: value;
|
|
517
|
-
};
|
|
518
|
-
|
|
519
|
-
// adds default markup properties, clones markup
|
|
520
|
-
var prepareMarkup = function prepareMarkup(markup) {
|
|
521
|
-
var _markup = _slicedToArray(markup, 2),
|
|
522
|
-
type = _markup[0],
|
|
523
|
-
props = _markup[1];
|
|
524
|
-
|
|
525
|
-
var rect = props.points
|
|
526
|
-
? {}
|
|
527
|
-
: MARKUP_RECT.reduce(function(prev, curr) {
|
|
528
|
-
prev[curr] = toOptionalFraction(props[curr]);
|
|
529
|
-
return prev;
|
|
530
|
-
}, {});
|
|
531
|
-
|
|
532
|
-
return [
|
|
533
|
-
type,
|
|
534
|
-
Object.assign(
|
|
535
|
-
{
|
|
536
|
-
zIndex: 0
|
|
537
|
-
},
|
|
538
|
-
props,
|
|
539
|
-
rect
|
|
540
|
-
)
|
|
541
|
-
];
|
|
542
|
-
};
|
|
543
|
-
|
|
544
|
-
var sortMarkupByZIndex = function sortMarkupByZIndex(a, b) {
|
|
545
|
-
if (a[1].zIndex > b[1].zIndex) {
|
|
546
|
-
return 1;
|
|
547
|
-
}
|
|
548
|
-
if (a[1].zIndex < b[1].zIndex) {
|
|
549
|
-
return -1;
|
|
550
|
-
}
|
|
551
|
-
return 0;
|
|
552
|
-
};
|
|
553
|
-
|
|
554
|
-
var createMarkupView = function createMarkupView(_) {
|
|
555
|
-
return _.utils.createView({
|
|
556
|
-
name: 'image-preview-markup',
|
|
557
|
-
tag: 'svg',
|
|
558
|
-
ignoreRect: true,
|
|
559
|
-
mixins: {
|
|
560
|
-
apis: ['width', 'height', 'crop', 'markup', 'resize', 'dirty']
|
|
561
|
-
},
|
|
562
|
-
|
|
563
|
-
write: function write(_ref) {
|
|
564
|
-
var root = _ref.root,
|
|
565
|
-
props = _ref.props;
|
|
566
|
-
|
|
567
|
-
if (!props.dirty) return;
|
|
568
|
-
var crop = props.crop,
|
|
569
|
-
resize = props.resize,
|
|
570
|
-
markup = props.markup;
|
|
571
|
-
|
|
572
|
-
var viewWidth = props.width;
|
|
573
|
-
var viewHeight = props.height;
|
|
574
|
-
|
|
575
|
-
var cropWidth = crop.width;
|
|
576
|
-
var cropHeight = crop.height;
|
|
577
|
-
|
|
578
|
-
if (resize) {
|
|
579
|
-
var _size = resize.size;
|
|
580
|
-
|
|
581
|
-
var outputWidth = _size && _size.width;
|
|
582
|
-
var outputHeight = _size && _size.height;
|
|
583
|
-
var outputFit = resize.mode;
|
|
584
|
-
var outputUpscale = resize.upscale;
|
|
585
|
-
|
|
586
|
-
if (outputWidth && !outputHeight) outputHeight = outputWidth;
|
|
587
|
-
if (outputHeight && !outputWidth) outputWidth = outputHeight;
|
|
588
|
-
|
|
589
|
-
var shouldUpscale =
|
|
590
|
-
cropWidth < outputWidth && cropHeight < outputHeight;
|
|
591
|
-
|
|
592
|
-
if (!shouldUpscale || (shouldUpscale && outputUpscale)) {
|
|
593
|
-
var scalarWidth = outputWidth / cropWidth;
|
|
594
|
-
var scalarHeight = outputHeight / cropHeight;
|
|
595
|
-
|
|
596
|
-
if (outputFit === 'force') {
|
|
597
|
-
cropWidth = outputWidth;
|
|
598
|
-
cropHeight = outputHeight;
|
|
599
|
-
} else {
|
|
600
|
-
var scalar;
|
|
601
|
-
if (outputFit === 'cover') {
|
|
602
|
-
scalar = Math.max(scalarWidth, scalarHeight);
|
|
603
|
-
} else if (outputFit === 'contain') {
|
|
604
|
-
scalar = Math.min(scalarWidth, scalarHeight);
|
|
605
|
-
}
|
|
606
|
-
cropWidth = cropWidth * scalar;
|
|
607
|
-
cropHeight = cropHeight * scalar;
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
var size = {
|
|
613
|
-
width: viewWidth,
|
|
614
|
-
height: viewHeight
|
|
615
|
-
};
|
|
616
|
-
|
|
617
|
-
root.element.setAttribute('width', size.width);
|
|
618
|
-
root.element.setAttribute('height', size.height);
|
|
619
|
-
|
|
620
|
-
var scale = Math.min(viewWidth / cropWidth, viewHeight / cropHeight);
|
|
621
|
-
|
|
622
|
-
// clear
|
|
623
|
-
root.element.innerHTML = '';
|
|
624
|
-
|
|
625
|
-
// get filter
|
|
626
|
-
var markupFilter = root.query('GET_IMAGE_PREVIEW_MARKUP_FILTER');
|
|
627
|
-
|
|
628
|
-
// draw new
|
|
629
|
-
markup
|
|
630
|
-
.filter(markupFilter)
|
|
631
|
-
.map(prepareMarkup)
|
|
632
|
-
.sort(sortMarkupByZIndex)
|
|
633
|
-
.forEach(function(markup) {
|
|
634
|
-
var _markup = _slicedToArray(markup, 2),
|
|
635
|
-
type = _markup[0],
|
|
636
|
-
settings = _markup[1];
|
|
637
|
-
|
|
638
|
-
// create
|
|
639
|
-
var element = createMarkupByType(type, settings);
|
|
640
|
-
|
|
641
|
-
// update
|
|
642
|
-
updateMarkupByType(element, type, settings, size, scale);
|
|
643
|
-
|
|
644
|
-
// add
|
|
645
|
-
root.element.appendChild(element);
|
|
646
|
-
});
|
|
647
|
-
}
|
|
648
|
-
});
|
|
649
|
-
};
|
|
650
|
-
|
|
651
|
-
var createVector$1 = function createVector(x, y) {
|
|
652
|
-
return { x: x, y: y };
|
|
653
|
-
};
|
|
654
|
-
|
|
655
|
-
var vectorDot = function vectorDot(a, b) {
|
|
656
|
-
return a.x * b.x + a.y * b.y;
|
|
657
|
-
};
|
|
658
|
-
|
|
659
|
-
var vectorSubtract = function vectorSubtract(a, b) {
|
|
660
|
-
return createVector$1(a.x - b.x, a.y - b.y);
|
|
661
|
-
};
|
|
662
|
-
|
|
663
|
-
var vectorDistanceSquared = function vectorDistanceSquared(a, b) {
|
|
664
|
-
return vectorDot(vectorSubtract(a, b), vectorSubtract(a, b));
|
|
665
|
-
};
|
|
666
|
-
|
|
667
|
-
var vectorDistance = function vectorDistance(a, b) {
|
|
668
|
-
return Math.sqrt(vectorDistanceSquared(a, b));
|
|
669
|
-
};
|
|
670
|
-
|
|
671
|
-
var getOffsetPointOnEdge = function getOffsetPointOnEdge(length, rotation) {
|
|
672
|
-
var a = length;
|
|
673
|
-
|
|
674
|
-
var A = 1.5707963267948966;
|
|
675
|
-
var B = rotation;
|
|
676
|
-
var C = 1.5707963267948966 - rotation;
|
|
677
|
-
|
|
678
|
-
var sinA = Math.sin(A);
|
|
679
|
-
var sinB = Math.sin(B);
|
|
680
|
-
var sinC = Math.sin(C);
|
|
681
|
-
var cosC = Math.cos(C);
|
|
682
|
-
var ratio = a / sinA;
|
|
683
|
-
var b = ratio * sinB;
|
|
684
|
-
var c = ratio * sinC;
|
|
685
|
-
|
|
686
|
-
return createVector$1(cosC * b, cosC * c);
|
|
687
|
-
};
|
|
688
|
-
|
|
689
|
-
var getRotatedRectSize = function getRotatedRectSize(rect, rotation) {
|
|
690
|
-
var w = rect.width;
|
|
691
|
-
var h = rect.height;
|
|
692
|
-
|
|
693
|
-
var hor = getOffsetPointOnEdge(w, rotation);
|
|
694
|
-
var ver = getOffsetPointOnEdge(h, rotation);
|
|
695
|
-
|
|
696
|
-
var tl = createVector$1(rect.x + Math.abs(hor.x), rect.y - Math.abs(hor.y));
|
|
697
|
-
|
|
698
|
-
var tr = createVector$1(
|
|
699
|
-
rect.x + rect.width + Math.abs(ver.y),
|
|
700
|
-
rect.y + Math.abs(ver.x)
|
|
701
|
-
);
|
|
702
|
-
|
|
703
|
-
var bl = createVector$1(
|
|
704
|
-
rect.x - Math.abs(ver.y),
|
|
705
|
-
rect.y + rect.height - Math.abs(ver.x)
|
|
706
|
-
);
|
|
707
|
-
|
|
708
|
-
return {
|
|
709
|
-
width: vectorDistance(tl, tr),
|
|
710
|
-
height: vectorDistance(tl, bl)
|
|
711
|
-
};
|
|
712
|
-
};
|
|
713
|
-
|
|
714
|
-
var calculateCanvasSize = function calculateCanvasSize(
|
|
715
|
-
image,
|
|
716
|
-
canvasAspectRatio
|
|
717
|
-
) {
|
|
718
|
-
var zoom =
|
|
719
|
-
arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
720
|
-
|
|
721
|
-
var imageAspectRatio = image.height / image.width;
|
|
722
|
-
|
|
723
|
-
// determine actual pixels on x and y axis
|
|
724
|
-
var canvasWidth = 1;
|
|
725
|
-
var canvasHeight = canvasAspectRatio;
|
|
726
|
-
var imgWidth = 1;
|
|
727
|
-
var imgHeight = imageAspectRatio;
|
|
728
|
-
if (imgHeight > canvasHeight) {
|
|
729
|
-
imgHeight = canvasHeight;
|
|
730
|
-
imgWidth = imgHeight / imageAspectRatio;
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
var scalar = Math.max(canvasWidth / imgWidth, canvasHeight / imgHeight);
|
|
734
|
-
var width = image.width / (zoom * scalar * imgWidth);
|
|
735
|
-
var height = width * canvasAspectRatio;
|
|
736
|
-
|
|
737
|
-
return {
|
|
738
|
-
width: width,
|
|
739
|
-
height: height
|
|
740
|
-
};
|
|
741
|
-
};
|
|
742
|
-
|
|
743
|
-
var getImageRectZoomFactor = function getImageRectZoomFactor(
|
|
744
|
-
imageRect,
|
|
745
|
-
cropRect,
|
|
746
|
-
rotation,
|
|
747
|
-
center
|
|
748
|
-
) {
|
|
749
|
-
// calculate available space round image center position
|
|
750
|
-
var cx = center.x > 0.5 ? 1 - center.x : center.x;
|
|
751
|
-
var cy = center.y > 0.5 ? 1 - center.y : center.y;
|
|
752
|
-
var imageWidth = cx * 2 * imageRect.width;
|
|
753
|
-
var imageHeight = cy * 2 * imageRect.height;
|
|
754
|
-
|
|
755
|
-
// calculate rotated crop rectangle size
|
|
756
|
-
var rotatedCropSize = getRotatedRectSize(cropRect, rotation);
|
|
757
|
-
|
|
758
|
-
// calculate scalar required to fit image
|
|
759
|
-
return Math.max(
|
|
760
|
-
rotatedCropSize.width / imageWidth,
|
|
761
|
-
rotatedCropSize.height / imageHeight
|
|
762
|
-
);
|
|
763
|
-
};
|
|
764
|
-
|
|
765
|
-
var getCenteredCropRect = function getCenteredCropRect(
|
|
766
|
-
container,
|
|
767
|
-
aspectRatio
|
|
768
|
-
) {
|
|
769
|
-
var width = container.width;
|
|
770
|
-
var height = width * aspectRatio;
|
|
771
|
-
if (height > container.height) {
|
|
772
|
-
height = container.height;
|
|
773
|
-
width = height / aspectRatio;
|
|
774
|
-
}
|
|
775
|
-
var x = (container.width - width) * 0.5;
|
|
776
|
-
var y = (container.height - height) * 0.5;
|
|
777
|
-
|
|
778
|
-
return {
|
|
779
|
-
x: x,
|
|
780
|
-
y: y,
|
|
781
|
-
width: width,
|
|
782
|
-
height: height
|
|
783
|
-
};
|
|
784
|
-
};
|
|
785
|
-
|
|
786
|
-
var getCurrentCropSize = function getCurrentCropSize(imageSize) {
|
|
787
|
-
var crop =
|
|
788
|
-
arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
789
|
-
var zoom = crop.zoom,
|
|
790
|
-
rotation = crop.rotation,
|
|
791
|
-
center = crop.center,
|
|
792
|
-
aspectRatio = crop.aspectRatio;
|
|
793
|
-
|
|
794
|
-
if (!aspectRatio) aspectRatio = imageSize.height / imageSize.width;
|
|
795
|
-
|
|
796
|
-
var canvasSize = calculateCanvasSize(imageSize, aspectRatio, zoom);
|
|
797
|
-
|
|
798
|
-
var stage = {
|
|
799
|
-
width: canvasSize.width,
|
|
800
|
-
height: canvasSize.height};
|
|
801
|
-
|
|
802
|
-
var shouldLimit = typeof crop.scaleToFit === 'undefined' || crop.scaleToFit;
|
|
803
|
-
|
|
804
|
-
var stageZoomFactor = getImageRectZoomFactor(
|
|
805
|
-
imageSize,
|
|
806
|
-
getCenteredCropRect(stage, aspectRatio),
|
|
807
|
-
rotation,
|
|
808
|
-
shouldLimit ? center : { x: 0.5, y: 0.5 }
|
|
809
|
-
);
|
|
810
|
-
|
|
811
|
-
var scale = zoom * stageZoomFactor;
|
|
812
|
-
|
|
813
|
-
// start drawing
|
|
814
|
-
return {
|
|
815
|
-
widthFloat: canvasSize.width / scale,
|
|
816
|
-
heightFloat: canvasSize.height / scale,
|
|
817
|
-
width: Math.round(canvasSize.width / scale),
|
|
818
|
-
height: Math.round(canvasSize.height / scale)
|
|
819
|
-
};
|
|
820
|
-
};
|
|
821
|
-
|
|
822
|
-
var IMAGE_SCALE_SPRING_PROPS = {
|
|
823
|
-
type: 'spring',
|
|
824
|
-
stiffness: 0.5,
|
|
825
|
-
damping: 0.45,
|
|
826
|
-
mass: 10
|
|
827
|
-
};
|
|
828
|
-
|
|
829
|
-
// does horizontal and vertical flipping
|
|
830
|
-
var createBitmapView = function createBitmapView(_) {
|
|
831
|
-
return _.utils.createView({
|
|
832
|
-
name: 'image-bitmap',
|
|
833
|
-
ignoreRect: true,
|
|
834
|
-
mixins: { styles: ['scaleX', 'scaleY'] },
|
|
835
|
-
create: function create(_ref) {
|
|
836
|
-
var root = _ref.root,
|
|
837
|
-
props = _ref.props;
|
|
838
|
-
root.appendChild(props.image);
|
|
839
|
-
}
|
|
840
|
-
});
|
|
841
|
-
};
|
|
842
|
-
|
|
843
|
-
// shifts and rotates image
|
|
844
|
-
var createImageCanvasWrapper = function createImageCanvasWrapper(_) {
|
|
845
|
-
return _.utils.createView({
|
|
846
|
-
name: 'image-canvas-wrapper',
|
|
847
|
-
tag: 'div',
|
|
848
|
-
ignoreRect: true,
|
|
849
|
-
mixins: {
|
|
850
|
-
apis: ['crop', 'width', 'height'],
|
|
851
|
-
|
|
852
|
-
styles: [
|
|
853
|
-
'originX',
|
|
854
|
-
'originY',
|
|
855
|
-
'translateX',
|
|
856
|
-
'translateY',
|
|
857
|
-
'scaleX',
|
|
858
|
-
'scaleY',
|
|
859
|
-
'rotateZ'
|
|
860
|
-
],
|
|
861
|
-
|
|
862
|
-
animations: {
|
|
863
|
-
originX: IMAGE_SCALE_SPRING_PROPS,
|
|
864
|
-
originY: IMAGE_SCALE_SPRING_PROPS,
|
|
865
|
-
scaleX: IMAGE_SCALE_SPRING_PROPS,
|
|
866
|
-
scaleY: IMAGE_SCALE_SPRING_PROPS,
|
|
867
|
-
translateX: IMAGE_SCALE_SPRING_PROPS,
|
|
868
|
-
translateY: IMAGE_SCALE_SPRING_PROPS,
|
|
869
|
-
rotateZ: IMAGE_SCALE_SPRING_PROPS
|
|
870
|
-
}
|
|
871
|
-
},
|
|
872
|
-
|
|
873
|
-
create: function create(_ref2) {
|
|
874
|
-
var root = _ref2.root,
|
|
875
|
-
props = _ref2.props;
|
|
876
|
-
props.width = props.image.width;
|
|
877
|
-
props.height = props.image.height;
|
|
878
|
-
root.ref.bitmap = root.appendChildView(
|
|
879
|
-
root.createChildView(createBitmapView(_), { image: props.image })
|
|
880
|
-
);
|
|
881
|
-
},
|
|
882
|
-
write: function write(_ref3) {
|
|
883
|
-
var root = _ref3.root,
|
|
884
|
-
props = _ref3.props;
|
|
885
|
-
var flip = props.crop.flip;
|
|
886
|
-
var bitmap = root.ref.bitmap;
|
|
887
|
-
bitmap.scaleX = flip.horizontal ? -1 : 1;
|
|
888
|
-
bitmap.scaleY = flip.vertical ? -1 : 1;
|
|
889
|
-
}
|
|
890
|
-
});
|
|
891
|
-
};
|
|
892
|
-
|
|
893
|
-
// clips canvas to correct aspect ratio
|
|
894
|
-
var createClipView = function createClipView(_) {
|
|
895
|
-
return _.utils.createView({
|
|
896
|
-
name: 'image-clip',
|
|
897
|
-
tag: 'div',
|
|
898
|
-
ignoreRect: true,
|
|
899
|
-
mixins: {
|
|
900
|
-
apis: [
|
|
901
|
-
'crop',
|
|
902
|
-
'markup',
|
|
903
|
-
'resize',
|
|
904
|
-
'width',
|
|
905
|
-
'height',
|
|
906
|
-
'dirty',
|
|
907
|
-
'background'
|
|
908
|
-
],
|
|
909
|
-
|
|
910
|
-
styles: ['width', 'height', 'opacity'],
|
|
911
|
-
animations: {
|
|
912
|
-
opacity: { type: 'tween', duration: 250 }
|
|
913
|
-
}
|
|
914
|
-
},
|
|
915
|
-
|
|
916
|
-
didWriteView: function didWriteView(_ref4) {
|
|
917
|
-
var root = _ref4.root,
|
|
918
|
-
props = _ref4.props;
|
|
919
|
-
if (!props.background) return;
|
|
920
|
-
root.element.style.backgroundColor = props.background;
|
|
921
|
-
},
|
|
922
|
-
create: function create(_ref5) {
|
|
923
|
-
var root = _ref5.root,
|
|
924
|
-
props = _ref5.props;
|
|
925
|
-
|
|
926
|
-
root.ref.image = root.appendChildView(
|
|
927
|
-
root.createChildView(
|
|
928
|
-
createImageCanvasWrapper(_),
|
|
929
|
-
Object.assign({}, props)
|
|
930
|
-
)
|
|
931
|
-
);
|
|
932
|
-
|
|
933
|
-
root.ref.createMarkup = function() {
|
|
934
|
-
if (root.ref.markup) return;
|
|
935
|
-
root.ref.markup = root.appendChildView(
|
|
936
|
-
root.createChildView(createMarkupView(_), Object.assign({}, props))
|
|
937
|
-
);
|
|
938
|
-
};
|
|
939
|
-
|
|
940
|
-
root.ref.destroyMarkup = function() {
|
|
941
|
-
if (!root.ref.markup) return;
|
|
942
|
-
root.removeChildView(root.ref.markup);
|
|
943
|
-
root.ref.markup = null;
|
|
944
|
-
};
|
|
945
|
-
|
|
946
|
-
// set up transparency grid
|
|
947
|
-
var transparencyIndicator = root.query(
|
|
948
|
-
'GET_IMAGE_PREVIEW_TRANSPARENCY_INDICATOR'
|
|
949
|
-
);
|
|
950
|
-
if (transparencyIndicator === null) return;
|
|
951
|
-
|
|
952
|
-
// grid pattern
|
|
953
|
-
if (transparencyIndicator === 'grid') {
|
|
954
|
-
root.element.dataset.transparencyIndicator = transparencyIndicator;
|
|
955
|
-
}
|
|
956
|
-
// basic color
|
|
957
|
-
else {
|
|
958
|
-
root.element.dataset.transparencyIndicator = 'color';
|
|
959
|
-
}
|
|
960
|
-
},
|
|
961
|
-
write: function write(_ref6) {
|
|
962
|
-
var root = _ref6.root,
|
|
963
|
-
props = _ref6.props,
|
|
964
|
-
shouldOptimize = _ref6.shouldOptimize;
|
|
965
|
-
var crop = props.crop,
|
|
966
|
-
markup = props.markup,
|
|
967
|
-
resize = props.resize,
|
|
968
|
-
dirty = props.dirty,
|
|
969
|
-
width = props.width,
|
|
970
|
-
height = props.height;
|
|
971
|
-
|
|
972
|
-
root.ref.image.crop = crop;
|
|
973
|
-
|
|
974
|
-
var stage = {
|
|
975
|
-
width: width,
|
|
976
|
-
height: height,
|
|
977
|
-
center: {
|
|
978
|
-
x: width * 0.5,
|
|
979
|
-
y: height * 0.5
|
|
980
|
-
}
|
|
981
|
-
};
|
|
982
|
-
|
|
983
|
-
var image = {
|
|
984
|
-
width: root.ref.image.width,
|
|
985
|
-
height: root.ref.image.height
|
|
986
|
-
};
|
|
987
|
-
|
|
988
|
-
var origin = {
|
|
989
|
-
x: crop.center.x * image.width,
|
|
990
|
-
y: crop.center.y * image.height
|
|
991
|
-
};
|
|
992
|
-
|
|
993
|
-
var translation = {
|
|
994
|
-
x: stage.center.x - image.width * crop.center.x,
|
|
995
|
-
y: stage.center.y - image.height * crop.center.y
|
|
996
|
-
};
|
|
997
|
-
|
|
998
|
-
var rotation = Math.PI * 2 + (crop.rotation % (Math.PI * 2));
|
|
999
|
-
|
|
1000
|
-
var cropAspectRatio = crop.aspectRatio || image.height / image.width;
|
|
1001
|
-
|
|
1002
|
-
var shouldLimit =
|
|
1003
|
-
typeof crop.scaleToFit === 'undefined' || crop.scaleToFit;
|
|
1004
|
-
|
|
1005
|
-
var stageZoomFactor = getImageRectZoomFactor(
|
|
1006
|
-
image,
|
|
1007
|
-
getCenteredCropRect(stage, cropAspectRatio),
|
|
1008
|
-
|
|
1009
|
-
rotation,
|
|
1010
|
-
shouldLimit ? crop.center : { x: 0.5, y: 0.5 }
|
|
1011
|
-
);
|
|
1012
|
-
|
|
1013
|
-
var scale = crop.zoom * stageZoomFactor;
|
|
1014
|
-
|
|
1015
|
-
// update markup view
|
|
1016
|
-
if (markup && markup.length) {
|
|
1017
|
-
root.ref.createMarkup();
|
|
1018
|
-
root.ref.markup.width = width;
|
|
1019
|
-
root.ref.markup.height = height;
|
|
1020
|
-
root.ref.markup.resize = resize;
|
|
1021
|
-
root.ref.markup.dirty = dirty;
|
|
1022
|
-
root.ref.markup.markup = markup;
|
|
1023
|
-
root.ref.markup.crop = getCurrentCropSize(image, crop);
|
|
1024
|
-
} else if (root.ref.markup) {
|
|
1025
|
-
root.ref.destroyMarkup();
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
// update image view
|
|
1029
|
-
var imageView = root.ref.image;
|
|
1030
|
-
|
|
1031
|
-
// don't update clip layout
|
|
1032
|
-
if (shouldOptimize) {
|
|
1033
|
-
imageView.originX = null;
|
|
1034
|
-
imageView.originY = null;
|
|
1035
|
-
imageView.translateX = null;
|
|
1036
|
-
imageView.translateY = null;
|
|
1037
|
-
imageView.rotateZ = null;
|
|
1038
|
-
imageView.scaleX = null;
|
|
1039
|
-
imageView.scaleY = null;
|
|
1040
|
-
return;
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
imageView.originX = origin.x;
|
|
1044
|
-
imageView.originY = origin.y;
|
|
1045
|
-
imageView.translateX = translation.x;
|
|
1046
|
-
imageView.translateY = translation.y;
|
|
1047
|
-
imageView.rotateZ = rotation;
|
|
1048
|
-
imageView.scaleX = scale;
|
|
1049
|
-
imageView.scaleY = scale;
|
|
1050
|
-
}
|
|
1051
|
-
});
|
|
1052
|
-
};
|
|
1053
|
-
|
|
1054
|
-
var createImageView = function createImageView(_) {
|
|
1055
|
-
return _.utils.createView({
|
|
1056
|
-
name: 'image-preview',
|
|
1057
|
-
tag: 'div',
|
|
1058
|
-
ignoreRect: true,
|
|
1059
|
-
mixins: {
|
|
1060
|
-
apis: ['image', 'crop', 'markup', 'resize', 'dirty', 'background'],
|
|
1061
|
-
|
|
1062
|
-
styles: ['translateY', 'scaleX', 'scaleY', 'opacity'],
|
|
1063
|
-
|
|
1064
|
-
animations: {
|
|
1065
|
-
scaleX: IMAGE_SCALE_SPRING_PROPS,
|
|
1066
|
-
scaleY: IMAGE_SCALE_SPRING_PROPS,
|
|
1067
|
-
translateY: IMAGE_SCALE_SPRING_PROPS,
|
|
1068
|
-
opacity: { type: 'tween', duration: 400 }
|
|
1069
|
-
}
|
|
1070
|
-
},
|
|
1071
|
-
|
|
1072
|
-
create: function create(_ref7) {
|
|
1073
|
-
var root = _ref7.root,
|
|
1074
|
-
props = _ref7.props;
|
|
1075
|
-
root.ref.clip = root.appendChildView(
|
|
1076
|
-
root.createChildView(createClipView(_), {
|
|
1077
|
-
id: props.id,
|
|
1078
|
-
image: props.image,
|
|
1079
|
-
crop: props.crop,
|
|
1080
|
-
markup: props.markup,
|
|
1081
|
-
resize: props.resize,
|
|
1082
|
-
dirty: props.dirty,
|
|
1083
|
-
background: props.background
|
|
1084
|
-
})
|
|
1085
|
-
);
|
|
1086
|
-
},
|
|
1087
|
-
write: function write(_ref8) {
|
|
1088
|
-
var root = _ref8.root,
|
|
1089
|
-
props = _ref8.props,
|
|
1090
|
-
shouldOptimize = _ref8.shouldOptimize;
|
|
1091
|
-
var clip = root.ref.clip;
|
|
1092
|
-
var image = props.image,
|
|
1093
|
-
crop = props.crop,
|
|
1094
|
-
markup = props.markup,
|
|
1095
|
-
resize = props.resize,
|
|
1096
|
-
dirty = props.dirty;
|
|
1097
|
-
|
|
1098
|
-
clip.crop = crop;
|
|
1099
|
-
clip.markup = markup;
|
|
1100
|
-
clip.resize = resize;
|
|
1101
|
-
clip.dirty = dirty;
|
|
1102
|
-
|
|
1103
|
-
// don't update clip layout
|
|
1104
|
-
clip.opacity = shouldOptimize ? 0 : 1;
|
|
1105
|
-
|
|
1106
|
-
// don't re-render if optimizing or hidden (width will be zero resulting in weird animations)
|
|
1107
|
-
if (shouldOptimize || root.rect.element.hidden) return;
|
|
1108
|
-
|
|
1109
|
-
// calculate scaled preview image size
|
|
1110
|
-
var imageAspectRatio = image.height / image.width;
|
|
1111
|
-
var aspectRatio = crop.aspectRatio || imageAspectRatio;
|
|
1112
|
-
|
|
1113
|
-
// calculate container size
|
|
1114
|
-
var containerWidth = root.rect.inner.width;
|
|
1115
|
-
var containerHeight = root.rect.inner.height;
|
|
1116
|
-
|
|
1117
|
-
var fixedPreviewHeight = root.query('GET_IMAGE_PREVIEW_HEIGHT');
|
|
1118
|
-
var minPreviewHeight = root.query('GET_IMAGE_PREVIEW_MIN_HEIGHT');
|
|
1119
|
-
var maxPreviewHeight = root.query('GET_IMAGE_PREVIEW_MAX_HEIGHT');
|
|
1120
|
-
|
|
1121
|
-
var panelAspectRatio = root.query('GET_PANEL_ASPECT_RATIO');
|
|
1122
|
-
var allowMultiple = root.query('GET_ALLOW_MULTIPLE');
|
|
1123
|
-
|
|
1124
|
-
if (panelAspectRatio && !allowMultiple) {
|
|
1125
|
-
fixedPreviewHeight = containerWidth * panelAspectRatio;
|
|
1126
|
-
aspectRatio = panelAspectRatio;
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
// determine clip width and height
|
|
1130
|
-
var clipHeight =
|
|
1131
|
-
fixedPreviewHeight !== null
|
|
1132
|
-
? fixedPreviewHeight
|
|
1133
|
-
: Math.max(
|
|
1134
|
-
minPreviewHeight,
|
|
1135
|
-
Math.min(containerWidth * aspectRatio, maxPreviewHeight)
|
|
1136
|
-
);
|
|
1137
|
-
|
|
1138
|
-
var clipWidth = clipHeight / aspectRatio;
|
|
1139
|
-
if (clipWidth > containerWidth) {
|
|
1140
|
-
clipWidth = containerWidth;
|
|
1141
|
-
clipHeight = clipWidth * aspectRatio;
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
|
-
if (clipHeight > containerHeight) {
|
|
1145
|
-
clipHeight = containerHeight;
|
|
1146
|
-
clipWidth = containerHeight / aspectRatio;
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1149
|
-
clip.width = clipWidth;
|
|
1150
|
-
clip.height = clipHeight;
|
|
1151
|
-
}
|
|
1152
|
-
});
|
|
1153
|
-
};
|
|
1154
|
-
|
|
1155
|
-
var SVG_MASK =
|
|
1156
|
-
'<svg width="500" height="200" viewBox="0 0 500 200" preserveAspectRatio="none">\n <defs>\n <radialGradient id="gradient-__UID__" cx=".5" cy="1.25" r="1.15">\n <stop offset=\'50%\' stop-color=\'#000000\'/>\n <stop offset=\'56%\' stop-color=\'#0a0a0a\'/>\n <stop offset=\'63%\' stop-color=\'#262626\'/>\n <stop offset=\'69%\' stop-color=\'#4f4f4f\'/>\n <stop offset=\'75%\' stop-color=\'#808080\'/>\n <stop offset=\'81%\' stop-color=\'#b1b1b1\'/>\n <stop offset=\'88%\' stop-color=\'#dadada\'/>\n <stop offset=\'94%\' stop-color=\'#f6f6f6\'/>\n <stop offset=\'100%\' stop-color=\'#ffffff\'/>\n </radialGradient>\n <mask id="mask-__UID__">\n <rect x="0" y="0" width="500" height="200" fill="url(#gradient-__UID__)"></rect>\n </mask>\n </defs>\n <rect x="0" width="500" height="200" fill="currentColor" mask="url(#mask-__UID__)"></rect>\n</svg>';
|
|
1157
|
-
|
|
1158
|
-
var SVGMaskUniqueId = 0;
|
|
1159
|
-
|
|
1160
|
-
var createImageOverlayView = function createImageOverlayView(fpAPI) {
|
|
1161
|
-
return fpAPI.utils.createView({
|
|
1162
|
-
name: 'image-preview-overlay',
|
|
1163
|
-
tag: 'div',
|
|
1164
|
-
ignoreRect: true,
|
|
1165
|
-
create: function create(_ref) {
|
|
1166
|
-
var root = _ref.root,
|
|
1167
|
-
props = _ref.props;
|
|
1168
|
-
var mask = SVG_MASK;
|
|
1169
|
-
if (document.querySelector('base')) {
|
|
1170
|
-
var url = new URL(
|
|
1171
|
-
window.location.href.replace(window.location.hash, '')
|
|
1172
|
-
).href;
|
|
1173
|
-
mask = mask.replace(/url\(\#/g, 'url(' + url + '#');
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
SVGMaskUniqueId++;
|
|
1177
|
-
root.element.classList.add(
|
|
1178
|
-
'filepond--image-preview-overlay-'.concat(props.status)
|
|
1179
|
-
);
|
|
1180
|
-
|
|
1181
|
-
root.element.innerHTML = mask.replace(/__UID__/g, SVGMaskUniqueId);
|
|
1182
|
-
},
|
|
1183
|
-
mixins: {
|
|
1184
|
-
styles: ['opacity'],
|
|
1185
|
-
animations: {
|
|
1186
|
-
opacity: { type: 'spring', mass: 25 }
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
});
|
|
1190
|
-
};
|
|
1191
|
-
|
|
1192
|
-
/**
|
|
1193
|
-
* Bitmap Worker
|
|
1194
|
-
*/
|
|
1195
|
-
var BitmapWorker = function BitmapWorker() {
|
|
1196
|
-
self.onmessage = function(e) {
|
|
1197
|
-
createImageBitmap(e.data.message.file).then(function(bitmap) {
|
|
1198
|
-
self.postMessage({ id: e.data.id, message: bitmap }, [bitmap]);
|
|
1199
|
-
});
|
|
1200
|
-
};
|
|
1201
|
-
};
|
|
1202
|
-
|
|
1203
|
-
/**
|
|
1204
|
-
* ColorMatrix Worker
|
|
1205
|
-
*/
|
|
1206
|
-
var ColorMatrixWorker = function ColorMatrixWorker() {
|
|
1207
|
-
self.onmessage = function(e) {
|
|
1208
|
-
var imageData = e.data.message.imageData;
|
|
1209
|
-
var matrix = e.data.message.colorMatrix;
|
|
1210
|
-
|
|
1211
|
-
var data = imageData.data;
|
|
1212
|
-
var l = data.length;
|
|
1213
|
-
|
|
1214
|
-
var m11 = matrix[0];
|
|
1215
|
-
var m12 = matrix[1];
|
|
1216
|
-
var m13 = matrix[2];
|
|
1217
|
-
var m14 = matrix[3];
|
|
1218
|
-
var m15 = matrix[4];
|
|
1219
|
-
|
|
1220
|
-
var m21 = matrix[5];
|
|
1221
|
-
var m22 = matrix[6];
|
|
1222
|
-
var m23 = matrix[7];
|
|
1223
|
-
var m24 = matrix[8];
|
|
1224
|
-
var m25 = matrix[9];
|
|
1225
|
-
|
|
1226
|
-
var m31 = matrix[10];
|
|
1227
|
-
var m32 = matrix[11];
|
|
1228
|
-
var m33 = matrix[12];
|
|
1229
|
-
var m34 = matrix[13];
|
|
1230
|
-
var m35 = matrix[14];
|
|
1231
|
-
|
|
1232
|
-
var m41 = matrix[15];
|
|
1233
|
-
var m42 = matrix[16];
|
|
1234
|
-
var m43 = matrix[17];
|
|
1235
|
-
var m44 = matrix[18];
|
|
1236
|
-
var m45 = matrix[19];
|
|
1237
|
-
|
|
1238
|
-
var index = 0,
|
|
1239
|
-
r = 0.0,
|
|
1240
|
-
g = 0.0,
|
|
1241
|
-
b = 0.0,
|
|
1242
|
-
a = 0.0;
|
|
1243
|
-
|
|
1244
|
-
for (; index < l; index += 4) {
|
|
1245
|
-
r = data[index] / 255;
|
|
1246
|
-
g = data[index + 1] / 255;
|
|
1247
|
-
b = data[index + 2] / 255;
|
|
1248
|
-
a = data[index + 3] / 255;
|
|
1249
|
-
data[index] = Math.max(
|
|
1250
|
-
0,
|
|
1251
|
-
Math.min((r * m11 + g * m12 + b * m13 + a * m14 + m15) * 255, 255)
|
|
1252
|
-
);
|
|
1253
|
-
data[index + 1] = Math.max(
|
|
1254
|
-
0,
|
|
1255
|
-
Math.min((r * m21 + g * m22 + b * m23 + a * m24 + m25) * 255, 255)
|
|
1256
|
-
);
|
|
1257
|
-
data[index + 2] = Math.max(
|
|
1258
|
-
0,
|
|
1259
|
-
Math.min((r * m31 + g * m32 + b * m33 + a * m34 + m35) * 255, 255)
|
|
1260
|
-
);
|
|
1261
|
-
data[index + 3] = Math.max(
|
|
1262
|
-
0,
|
|
1263
|
-
Math.min((r * m41 + g * m42 + b * m43 + a * m44 + m45) * 255, 255)
|
|
1264
|
-
);
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
self.postMessage({ id: e.data.id, message: imageData }, [
|
|
1268
|
-
imageData.data.buffer
|
|
1269
|
-
]);
|
|
1270
|
-
};
|
|
1271
|
-
};
|
|
1272
|
-
|
|
1273
|
-
var getImageSize = function getImageSize(url, cb) {
|
|
1274
|
-
var image = new Image();
|
|
1275
|
-
image.onload = function() {
|
|
1276
|
-
var width = image.naturalWidth;
|
|
1277
|
-
var height = image.naturalHeight;
|
|
1278
|
-
image = null;
|
|
1279
|
-
cb(width, height);
|
|
1280
|
-
};
|
|
1281
|
-
image.src = url;
|
|
1282
|
-
};
|
|
1283
|
-
|
|
1284
|
-
var transforms = {
|
|
1285
|
-
1: function _() {
|
|
1286
|
-
return [1, 0, 0, 1, 0, 0];
|
|
1287
|
-
},
|
|
1288
|
-
2: function _(width) {
|
|
1289
|
-
return [-1, 0, 0, 1, width, 0];
|
|
1290
|
-
},
|
|
1291
|
-
3: function _(width, height) {
|
|
1292
|
-
return [-1, 0, 0, -1, width, height];
|
|
1293
|
-
},
|
|
1294
|
-
4: function _(width, height) {
|
|
1295
|
-
return [1, 0, 0, -1, 0, height];
|
|
1296
|
-
},
|
|
1297
|
-
5: function _() {
|
|
1298
|
-
return [0, 1, 1, 0, 0, 0];
|
|
1299
|
-
},
|
|
1300
|
-
6: function _(width, height) {
|
|
1301
|
-
return [0, 1, -1, 0, height, 0];
|
|
1302
|
-
},
|
|
1303
|
-
7: function _(width, height) {
|
|
1304
|
-
return [0, -1, -1, 0, height, width];
|
|
1305
|
-
},
|
|
1306
|
-
8: function _(width) {
|
|
1307
|
-
return [0, -1, 1, 0, 0, width];
|
|
1308
|
-
}
|
|
1309
|
-
};
|
|
1310
|
-
|
|
1311
|
-
var fixImageOrientation = function fixImageOrientation(
|
|
1312
|
-
ctx,
|
|
1313
|
-
width,
|
|
1314
|
-
height,
|
|
1315
|
-
orientation
|
|
1316
|
-
) {
|
|
1317
|
-
// no orientation supplied
|
|
1318
|
-
if (orientation === -1) {
|
|
1319
|
-
return;
|
|
1320
|
-
}
|
|
1321
|
-
|
|
1322
|
-
ctx.transform.apply(ctx, transforms[orientation](width, height));
|
|
1323
|
-
};
|
|
1324
|
-
|
|
1325
|
-
// draws the preview image to canvas
|
|
1326
|
-
var createPreviewImage = function createPreviewImage(
|
|
1327
|
-
data,
|
|
1328
|
-
width,
|
|
1329
|
-
height,
|
|
1330
|
-
orientation
|
|
1331
|
-
) {
|
|
1332
|
-
// can't draw on half pixels
|
|
1333
|
-
width = Math.round(width);
|
|
1334
|
-
height = Math.round(height);
|
|
1335
|
-
|
|
1336
|
-
// draw image
|
|
1337
|
-
var canvas = document.createElement('canvas');
|
|
1338
|
-
canvas.width = width;
|
|
1339
|
-
canvas.height = height;
|
|
1340
|
-
var ctx = canvas.getContext('2d');
|
|
1341
|
-
|
|
1342
|
-
// if is rotated incorrectly swap width and height
|
|
1343
|
-
if (orientation >= 5 && orientation <= 8) {
|
|
1344
|
-
var _ref = [height, width];
|
|
1345
|
-
width = _ref[0];
|
|
1346
|
-
height = _ref[1];
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
|
-
// correct image orientation
|
|
1350
|
-
fixImageOrientation(ctx, width, height, orientation);
|
|
1351
|
-
|
|
1352
|
-
// draw the image
|
|
1353
|
-
ctx.drawImage(data, 0, 0, width, height);
|
|
1354
|
-
|
|
1355
|
-
return canvas;
|
|
1356
|
-
};
|
|
1357
|
-
|
|
1358
|
-
var isBitmap = function isBitmap(file) {
|
|
1359
|
-
return /^image/.test(file.type) && !/svg/.test(file.type);
|
|
1360
|
-
};
|
|
1361
|
-
|
|
1362
|
-
var MAX_WIDTH = 10;
|
|
1363
|
-
var MAX_HEIGHT = 10;
|
|
1364
|
-
|
|
1365
|
-
var calculateAverageColor = function calculateAverageColor(image) {
|
|
1366
|
-
var scalar = Math.min(MAX_WIDTH / image.width, MAX_HEIGHT / image.height);
|
|
1367
|
-
|
|
1368
|
-
var canvas = document.createElement('canvas');
|
|
1369
|
-
var ctx = canvas.getContext('2d');
|
|
1370
|
-
var width = (canvas.width = Math.ceil(image.width * scalar));
|
|
1371
|
-
var height = (canvas.height = Math.ceil(image.height * scalar));
|
|
1372
|
-
ctx.drawImage(image, 0, 0, width, height);
|
|
1373
|
-
var data = null;
|
|
1374
|
-
try {
|
|
1375
|
-
data = ctx.getImageData(0, 0, width, height).data;
|
|
1376
|
-
} catch (e) {
|
|
1377
|
-
return null;
|
|
1378
|
-
}
|
|
1379
|
-
var l = data.length;
|
|
1380
|
-
|
|
1381
|
-
var r = 0;
|
|
1382
|
-
var g = 0;
|
|
1383
|
-
var b = 0;
|
|
1384
|
-
var i = 0;
|
|
1385
|
-
|
|
1386
|
-
for (; i < l; i += 4) {
|
|
1387
|
-
r += data[i] * data[i];
|
|
1388
|
-
g += data[i + 1] * data[i + 1];
|
|
1389
|
-
b += data[i + 2] * data[i + 2];
|
|
1390
|
-
}
|
|
1391
|
-
|
|
1392
|
-
r = averageColor(r, l);
|
|
1393
|
-
g = averageColor(g, l);
|
|
1394
|
-
b = averageColor(b, l);
|
|
1395
|
-
|
|
1396
|
-
return { r: r, g: g, b: b };
|
|
1397
|
-
};
|
|
1398
|
-
|
|
1399
|
-
var averageColor = function averageColor(c, l) {
|
|
1400
|
-
return Math.floor(Math.sqrt(c / (l / 4)));
|
|
1401
|
-
};
|
|
1402
|
-
|
|
1403
|
-
var cloneCanvas = function cloneCanvas(origin, target) {
|
|
1404
|
-
target = target || document.createElement('canvas');
|
|
1405
|
-
target.width = origin.width;
|
|
1406
|
-
target.height = origin.height;
|
|
1407
|
-
var ctx = target.getContext('2d');
|
|
1408
|
-
ctx.drawImage(origin, 0, 0);
|
|
1409
|
-
return target;
|
|
1410
|
-
};
|
|
1411
|
-
|
|
1412
|
-
var cloneImageData = function cloneImageData(imageData) {
|
|
1413
|
-
var id;
|
|
1414
|
-
try {
|
|
1415
|
-
id = new ImageData(imageData.width, imageData.height);
|
|
1416
|
-
} catch (e) {
|
|
1417
|
-
var canvas = document.createElement('canvas');
|
|
1418
|
-
var ctx = canvas.getContext('2d');
|
|
1419
|
-
id = ctx.createImageData(imageData.width, imageData.height);
|
|
1420
|
-
}
|
|
1421
|
-
id.data.set(new Uint8ClampedArray(imageData.data));
|
|
1422
|
-
return id;
|
|
1423
|
-
};
|
|
1424
|
-
|
|
1425
|
-
var loadImage = function loadImage(url) {
|
|
1426
|
-
return new Promise(function(resolve, reject) {
|
|
1427
|
-
var img = new Image();
|
|
1428
|
-
img.crossOrigin = 'Anonymous';
|
|
1429
|
-
img.onload = function() {
|
|
1430
|
-
resolve(img);
|
|
1431
|
-
};
|
|
1432
|
-
img.onerror = function(e) {
|
|
1433
|
-
reject(e);
|
|
1434
|
-
};
|
|
1435
|
-
img.src = url;
|
|
1436
|
-
});
|
|
1437
|
-
};
|
|
1438
|
-
|
|
1439
|
-
var createImageWrapperView = function createImageWrapperView(_) {
|
|
1440
|
-
// create overlay view
|
|
1441
|
-
var OverlayView = createImageOverlayView(_);
|
|
1442
|
-
|
|
1443
|
-
var ImageView = createImageView(_);
|
|
1444
|
-
var createWorker = _.utils.createWorker;
|
|
1445
|
-
|
|
1446
|
-
var applyFilter = function applyFilter(root, filter, target) {
|
|
1447
|
-
return new Promise(function(resolve) {
|
|
1448
|
-
// will store image data for future filter updates
|
|
1449
|
-
if (!root.ref.imageData) {
|
|
1450
|
-
root.ref.imageData = target
|
|
1451
|
-
.getContext('2d')
|
|
1452
|
-
.getImageData(0, 0, target.width, target.height);
|
|
1453
|
-
}
|
|
1454
|
-
|
|
1455
|
-
// get image data reference
|
|
1456
|
-
var imageData = cloneImageData(root.ref.imageData);
|
|
1457
|
-
|
|
1458
|
-
if (!filter || filter.length !== 20) {
|
|
1459
|
-
target.getContext('2d').putImageData(imageData, 0, 0);
|
|
1460
|
-
return resolve();
|
|
1461
|
-
}
|
|
1462
|
-
|
|
1463
|
-
var worker = createWorker(ColorMatrixWorker);
|
|
1464
|
-
worker.post(
|
|
1465
|
-
{
|
|
1466
|
-
imageData: imageData,
|
|
1467
|
-
colorMatrix: filter
|
|
1468
|
-
},
|
|
1469
|
-
|
|
1470
|
-
function(response) {
|
|
1471
|
-
// apply filtered colors
|
|
1472
|
-
target.getContext('2d').putImageData(response, 0, 0);
|
|
1473
|
-
|
|
1474
|
-
// stop worker
|
|
1475
|
-
worker.terminate();
|
|
1476
|
-
|
|
1477
|
-
// done!
|
|
1478
|
-
resolve();
|
|
1479
|
-
},
|
|
1480
|
-
[imageData.data.buffer]
|
|
1481
|
-
);
|
|
1482
|
-
});
|
|
1483
|
-
};
|
|
1484
|
-
|
|
1485
|
-
var removeImageView = function removeImageView(root, imageView) {
|
|
1486
|
-
root.removeChildView(imageView);
|
|
1487
|
-
imageView.image.width = 1;
|
|
1488
|
-
imageView.image.height = 1;
|
|
1489
|
-
imageView._destroy();
|
|
1490
|
-
};
|
|
1491
|
-
|
|
1492
|
-
// remove an image
|
|
1493
|
-
var shiftImage = function shiftImage(_ref) {
|
|
1494
|
-
var root = _ref.root;
|
|
1495
|
-
var imageView = root.ref.images.shift();
|
|
1496
|
-
imageView.opacity = 0;
|
|
1497
|
-
imageView.translateY = -15;
|
|
1498
|
-
root.ref.imageViewBin.push(imageView);
|
|
1499
|
-
return imageView;
|
|
1500
|
-
};
|
|
1501
|
-
|
|
1502
|
-
// add new image
|
|
1503
|
-
var pushImage = function pushImage(_ref2) {
|
|
1504
|
-
var root = _ref2.root,
|
|
1505
|
-
props = _ref2.props,
|
|
1506
|
-
image = _ref2.image;
|
|
1507
|
-
var id = props.id;
|
|
1508
|
-
var item = root.query('GET_ITEM', { id: id });
|
|
1509
|
-
if (!item) return;
|
|
1510
|
-
|
|
1511
|
-
var crop = item.getMetadata('crop') || {
|
|
1512
|
-
center: {
|
|
1513
|
-
x: 0.5,
|
|
1514
|
-
y: 0.5
|
|
1515
|
-
},
|
|
1516
|
-
|
|
1517
|
-
flip: {
|
|
1518
|
-
horizontal: false,
|
|
1519
|
-
vertical: false
|
|
1520
|
-
},
|
|
1521
|
-
|
|
1522
|
-
zoom: 1,
|
|
1523
|
-
rotation: 0,
|
|
1524
|
-
aspectRatio: null
|
|
1525
|
-
};
|
|
1526
|
-
|
|
1527
|
-
var background = root.query(
|
|
1528
|
-
'GET_IMAGE_TRANSFORM_CANVAS_BACKGROUND_COLOR'
|
|
1529
|
-
);
|
|
1530
|
-
|
|
1531
|
-
var markup;
|
|
1532
|
-
var resize;
|
|
1533
|
-
var dirty = false;
|
|
1534
|
-
if (root.query('GET_IMAGE_PREVIEW_MARKUP_SHOW')) {
|
|
1535
|
-
markup = item.getMetadata('markup') || [];
|
|
1536
|
-
resize = item.getMetadata('resize');
|
|
1537
|
-
dirty = true;
|
|
1538
|
-
}
|
|
1539
|
-
|
|
1540
|
-
// append image presenter
|
|
1541
|
-
var imageView = root.appendChildView(
|
|
1542
|
-
root.createChildView(ImageView, {
|
|
1543
|
-
id: id,
|
|
1544
|
-
image: image,
|
|
1545
|
-
crop: crop,
|
|
1546
|
-
resize: resize,
|
|
1547
|
-
markup: markup,
|
|
1548
|
-
dirty: dirty,
|
|
1549
|
-
background: background,
|
|
1550
|
-
opacity: 0,
|
|
1551
|
-
scaleX: 1.15,
|
|
1552
|
-
scaleY: 1.15,
|
|
1553
|
-
translateY: 15
|
|
1554
|
-
}),
|
|
1555
|
-
|
|
1556
|
-
root.childViews.length
|
|
1557
|
-
);
|
|
1558
|
-
|
|
1559
|
-
root.ref.images.push(imageView);
|
|
1560
|
-
|
|
1561
|
-
// reveal the preview image
|
|
1562
|
-
imageView.opacity = 1;
|
|
1563
|
-
imageView.scaleX = 1;
|
|
1564
|
-
imageView.scaleY = 1;
|
|
1565
|
-
imageView.translateY = 0;
|
|
1566
|
-
|
|
1567
|
-
// the preview is now ready to be drawn
|
|
1568
|
-
setTimeout(function() {
|
|
1569
|
-
root.dispatch('DID_IMAGE_PREVIEW_SHOW', { id: id });
|
|
1570
|
-
}, 250);
|
|
1571
|
-
};
|
|
1572
|
-
|
|
1573
|
-
var updateImage = function updateImage(_ref3) {
|
|
1574
|
-
var root = _ref3.root,
|
|
1575
|
-
props = _ref3.props;
|
|
1576
|
-
var item = root.query('GET_ITEM', { id: props.id });
|
|
1577
|
-
if (!item) return;
|
|
1578
|
-
var imageView = root.ref.images[root.ref.images.length - 1];
|
|
1579
|
-
imageView.crop = item.getMetadata('crop');
|
|
1580
|
-
imageView.background = root.query(
|
|
1581
|
-
'GET_IMAGE_TRANSFORM_CANVAS_BACKGROUND_COLOR'
|
|
1582
|
-
);
|
|
1583
|
-
|
|
1584
|
-
if (root.query('GET_IMAGE_PREVIEW_MARKUP_SHOW')) {
|
|
1585
|
-
imageView.dirty = true;
|
|
1586
|
-
imageView.resize = item.getMetadata('resize');
|
|
1587
|
-
imageView.markup = item.getMetadata('markup');
|
|
1588
|
-
}
|
|
1589
|
-
};
|
|
1590
|
-
|
|
1591
|
-
// replace image preview
|
|
1592
|
-
var didUpdateItemMetadata = function didUpdateItemMetadata(_ref4) {
|
|
1593
|
-
var root = _ref4.root,
|
|
1594
|
-
props = _ref4.props,
|
|
1595
|
-
action = _ref4.action;
|
|
1596
|
-
// only filter and crop trigger redraw
|
|
1597
|
-
if (!/crop|filter|markup|resize/.test(action.change.key)) return;
|
|
1598
|
-
|
|
1599
|
-
// no images to update, exit
|
|
1600
|
-
if (!root.ref.images.length) return;
|
|
1601
|
-
|
|
1602
|
-
// no item found, exit
|
|
1603
|
-
var item = root.query('GET_ITEM', { id: props.id });
|
|
1604
|
-
if (!item) return;
|
|
1605
|
-
|
|
1606
|
-
// for now, update existing image when filtering
|
|
1607
|
-
if (/filter/.test(action.change.key)) {
|
|
1608
|
-
var imageView = root.ref.images[root.ref.images.length - 1];
|
|
1609
|
-
applyFilter(root, action.change.value, imageView.image);
|
|
1610
|
-
return;
|
|
1611
|
-
}
|
|
1612
|
-
|
|
1613
|
-
if (/crop|markup|resize/.test(action.change.key)) {
|
|
1614
|
-
var crop = item.getMetadata('crop');
|
|
1615
|
-
var image = root.ref.images[root.ref.images.length - 1];
|
|
1616
|
-
|
|
1617
|
-
// if aspect ratio has changed, we need to create a new image
|
|
1618
|
-
if (
|
|
1619
|
-
crop &&
|
|
1620
|
-
crop.aspectRatio &&
|
|
1621
|
-
image.crop &&
|
|
1622
|
-
image.crop.aspectRatio &&
|
|
1623
|
-
Math.abs(crop.aspectRatio - image.crop.aspectRatio) > 0.00001
|
|
1624
|
-
) {
|
|
1625
|
-
var _imageView = shiftImage({ root: root });
|
|
1626
|
-
pushImage({
|
|
1627
|
-
root: root,
|
|
1628
|
-
props: props,
|
|
1629
|
-
image: cloneCanvas(_imageView.image)
|
|
1630
|
-
});
|
|
1631
|
-
}
|
|
1632
|
-
// if not, we can update the current image
|
|
1633
|
-
else {
|
|
1634
|
-
updateImage({ root: root, props: props });
|
|
1635
|
-
}
|
|
1636
|
-
}
|
|
1637
|
-
};
|
|
1638
|
-
|
|
1639
|
-
var canCreateImageBitmap = function canCreateImageBitmap(file) {
|
|
1640
|
-
// Firefox versions before 58 will freeze when running createImageBitmap
|
|
1641
|
-
// in a Web Worker so we detect those versions and return false for support
|
|
1642
|
-
var userAgent = window.navigator.userAgent;
|
|
1643
|
-
var isFirefox = userAgent.match(/Firefox\/([0-9]+)\./);
|
|
1644
|
-
var firefoxVersion = isFirefox ? parseInt(isFirefox[1]) : null;
|
|
1645
|
-
if (firefoxVersion !== null && firefoxVersion <= 58) return false;
|
|
1646
|
-
|
|
1647
|
-
return 'createImageBitmap' in window && isBitmap(file);
|
|
1648
|
-
};
|
|
1649
|
-
|
|
1650
|
-
/**
|
|
1651
|
-
* Write handler for when preview container has been created
|
|
1652
|
-
*/
|
|
1653
|
-
var didCreatePreviewContainer = function didCreatePreviewContainer(_ref5) {
|
|
1654
|
-
var root = _ref5.root,
|
|
1655
|
-
props = _ref5.props;
|
|
1656
|
-
var id = props.id;
|
|
1657
|
-
|
|
1658
|
-
// we need to get the file data to determine the eventual image size
|
|
1659
|
-
var item = root.query('GET_ITEM', id);
|
|
1660
|
-
if (!item) return;
|
|
1661
|
-
|
|
1662
|
-
// get url to file (we'll revoke it later on when done)
|
|
1663
|
-
var fileURL = URL.createObjectURL(item.file);
|
|
1664
|
-
|
|
1665
|
-
// determine image size of this item
|
|
1666
|
-
getImageSize(fileURL, function(width, height) {
|
|
1667
|
-
// we can now scale the panel to the final size
|
|
1668
|
-
root.dispatch('DID_IMAGE_PREVIEW_CALCULATE_SIZE', {
|
|
1669
|
-
id: id,
|
|
1670
|
-
width: width,
|
|
1671
|
-
height: height
|
|
1672
|
-
});
|
|
1673
|
-
});
|
|
1674
|
-
};
|
|
1675
|
-
|
|
1676
|
-
var drawPreview = function drawPreview(_ref6) {
|
|
1677
|
-
var root = _ref6.root,
|
|
1678
|
-
props = _ref6.props;
|
|
1679
|
-
var id = props.id;
|
|
1680
|
-
|
|
1681
|
-
// we need to get the file data to determine the eventual image size
|
|
1682
|
-
var item = root.query('GET_ITEM', id);
|
|
1683
|
-
if (!item) return;
|
|
1684
|
-
|
|
1685
|
-
// get url to file (we'll revoke it later on when done)
|
|
1686
|
-
var fileURL = URL.createObjectURL(item.file);
|
|
1687
|
-
|
|
1688
|
-
// fallback
|
|
1689
|
-
var loadPreviewFallback = function loadPreviewFallback() {
|
|
1690
|
-
// let's scale the image in the main thread :(
|
|
1691
|
-
loadImage(fileURL).then(previewImageLoaded);
|
|
1692
|
-
};
|
|
1693
|
-
|
|
1694
|
-
// image is now ready
|
|
1695
|
-
var previewImageLoaded = function previewImageLoaded(imageData) {
|
|
1696
|
-
// the file url is no longer needed
|
|
1697
|
-
URL.revokeObjectURL(fileURL);
|
|
1698
|
-
|
|
1699
|
-
// draw the scaled down version here and use that as source so bitmapdata can be closed
|
|
1700
|
-
// orientation info
|
|
1701
|
-
var exif = item.getMetadata('exif') || {};
|
|
1702
|
-
var orientation = exif.orientation || -1;
|
|
1703
|
-
|
|
1704
|
-
// get width and height from action, and swap if orientation is incorrect
|
|
1705
|
-
var width = imageData.width,
|
|
1706
|
-
height = imageData.height;
|
|
1707
|
-
|
|
1708
|
-
// if no width or height, just return early.
|
|
1709
|
-
if (!width || !height) return;
|
|
1710
|
-
|
|
1711
|
-
if (orientation >= 5 && orientation <= 8) {
|
|
1712
|
-
var _ref7 = [height, width];
|
|
1713
|
-
width = _ref7[0];
|
|
1714
|
-
height = _ref7[1];
|
|
1715
|
-
}
|
|
1716
|
-
|
|
1717
|
-
// scale canvas based on pixel density
|
|
1718
|
-
// we multiply by .75 as that creates smaller but still clear images on screens with high res displays
|
|
1719
|
-
var pixelDensityFactor = Math.max(1, window.devicePixelRatio * 0.75);
|
|
1720
|
-
|
|
1721
|
-
// we want as much pixels to work with as possible,
|
|
1722
|
-
// this multiplies the minimum image resolution,
|
|
1723
|
-
// so when zooming in it doesn't get too blurry
|
|
1724
|
-
var zoomFactor = root.query('GET_IMAGE_PREVIEW_ZOOM_FACTOR');
|
|
1725
|
-
|
|
1726
|
-
// imaeg scale factor
|
|
1727
|
-
var scaleFactor = zoomFactor * pixelDensityFactor;
|
|
1728
|
-
|
|
1729
|
-
// calculate scaled preview image size
|
|
1730
|
-
var previewImageRatio = height / width;
|
|
1731
|
-
|
|
1732
|
-
// calculate image preview height and width
|
|
1733
|
-
var previewContainerWidth = root.rect.element.width;
|
|
1734
|
-
var previewContainerHeight = root.rect.element.height;
|
|
1735
|
-
|
|
1736
|
-
var imageWidth = previewContainerWidth;
|
|
1737
|
-
var imageHeight = imageWidth * previewImageRatio;
|
|
1738
|
-
|
|
1739
|
-
if (previewImageRatio > 1) {
|
|
1740
|
-
imageWidth = Math.min(width, previewContainerWidth * scaleFactor);
|
|
1741
|
-
imageHeight = imageWidth * previewImageRatio;
|
|
1742
|
-
} else {
|
|
1743
|
-
imageHeight = Math.min(height, previewContainerHeight * scaleFactor);
|
|
1744
|
-
imageWidth = imageHeight / previewImageRatio;
|
|
1745
|
-
}
|
|
1746
|
-
|
|
1747
|
-
// transfer to image tag so no canvas memory wasted on iOS
|
|
1748
|
-
var previewImage = createPreviewImage(
|
|
1749
|
-
imageData,
|
|
1750
|
-
imageWidth,
|
|
1751
|
-
imageHeight,
|
|
1752
|
-
orientation
|
|
1753
|
-
);
|
|
1754
|
-
|
|
1755
|
-
// done
|
|
1756
|
-
var done = function done() {
|
|
1757
|
-
// calculate average image color, disabled for now
|
|
1758
|
-
var averageColor = root.query(
|
|
1759
|
-
'GET_IMAGE_PREVIEW_CALCULATE_AVERAGE_IMAGE_COLOR'
|
|
1760
|
-
)
|
|
1761
|
-
? calculateAverageColor(data)
|
|
1762
|
-
: null;
|
|
1763
|
-
item.setMetadata('color', averageColor, true);
|
|
1764
|
-
|
|
1765
|
-
// data has been transferred to canvas ( if was ImageBitmap )
|
|
1766
|
-
if ('close' in imageData) {
|
|
1767
|
-
imageData.close();
|
|
1768
|
-
}
|
|
1769
|
-
|
|
1770
|
-
// show the overlay
|
|
1771
|
-
root.ref.overlayShadow.opacity = 1;
|
|
1772
|
-
|
|
1773
|
-
// create the first image
|
|
1774
|
-
pushImage({ root: root, props: props, image: previewImage });
|
|
1775
|
-
};
|
|
1776
|
-
|
|
1777
|
-
// apply filter
|
|
1778
|
-
var filter = item.getMetadata('filter');
|
|
1779
|
-
if (filter) {
|
|
1780
|
-
applyFilter(root, filter, previewImage).then(done);
|
|
1781
|
-
} else {
|
|
1782
|
-
done();
|
|
1783
|
-
}
|
|
1784
|
-
};
|
|
1785
|
-
|
|
1786
|
-
// if we support scaling using createImageBitmap we use a worker
|
|
1787
|
-
if (canCreateImageBitmap(item.file)) {
|
|
1788
|
-
// let's scale the image in a worker
|
|
1789
|
-
var worker = createWorker(BitmapWorker);
|
|
1790
|
-
|
|
1791
|
-
worker.post(
|
|
1792
|
-
{
|
|
1793
|
-
file: item.file
|
|
1794
|
-
},
|
|
1795
|
-
|
|
1796
|
-
function(imageBitmap) {
|
|
1797
|
-
// destroy worker
|
|
1798
|
-
worker.terminate();
|
|
1799
|
-
|
|
1800
|
-
// no bitmap returned, must be something wrong,
|
|
1801
|
-
// try the oldschool way
|
|
1802
|
-
if (!imageBitmap) {
|
|
1803
|
-
loadPreviewFallback();
|
|
1804
|
-
return;
|
|
1805
|
-
}
|
|
1806
|
-
|
|
1807
|
-
// yay we got our bitmap, let's continue showing the preview
|
|
1808
|
-
previewImageLoaded(imageBitmap);
|
|
1809
|
-
}
|
|
1810
|
-
);
|
|
1811
|
-
} else {
|
|
1812
|
-
// create fallback preview
|
|
1813
|
-
loadPreviewFallback();
|
|
1814
|
-
}
|
|
1815
|
-
};
|
|
1816
|
-
|
|
1817
|
-
/**
|
|
1818
|
-
* Write handler for when the preview image is ready to be animated
|
|
1819
|
-
*/
|
|
1820
|
-
var didDrawPreview = function didDrawPreview(_ref8) {
|
|
1821
|
-
var root = _ref8.root;
|
|
1822
|
-
// get last added image
|
|
1823
|
-
var image = root.ref.images[root.ref.images.length - 1];
|
|
1824
|
-
image.translateY = 0;
|
|
1825
|
-
image.scaleX = 1.0;
|
|
1826
|
-
image.scaleY = 1.0;
|
|
1827
|
-
image.opacity = 1;
|
|
1828
|
-
};
|
|
1829
|
-
|
|
1830
|
-
/**
|
|
1831
|
-
* Write handler for when the preview has been loaded
|
|
1832
|
-
*/
|
|
1833
|
-
var restoreOverlay = function restoreOverlay(_ref9) {
|
|
1834
|
-
var root = _ref9.root;
|
|
1835
|
-
root.ref.overlayShadow.opacity = 1;
|
|
1836
|
-
root.ref.overlayError.opacity = 0;
|
|
1837
|
-
root.ref.overlaySuccess.opacity = 0;
|
|
1838
|
-
};
|
|
1839
|
-
|
|
1840
|
-
var didThrowError = function didThrowError(_ref10) {
|
|
1841
|
-
var root = _ref10.root;
|
|
1842
|
-
root.ref.overlayShadow.opacity = 0.25;
|
|
1843
|
-
root.ref.overlayError.opacity = 1;
|
|
1844
|
-
};
|
|
1845
|
-
|
|
1846
|
-
var didCompleteProcessing = function didCompleteProcessing(_ref11) {
|
|
1847
|
-
var root = _ref11.root;
|
|
1848
|
-
root.ref.overlayShadow.opacity = 0.25;
|
|
1849
|
-
root.ref.overlaySuccess.opacity = 1;
|
|
1850
|
-
};
|
|
1851
|
-
|
|
1852
|
-
/**
|
|
1853
|
-
* Constructor
|
|
1854
|
-
*/
|
|
1855
|
-
var create = function create(_ref12) {
|
|
1856
|
-
var root = _ref12.root;
|
|
1857
|
-
// image view
|
|
1858
|
-
root.ref.images = [];
|
|
1859
|
-
|
|
1860
|
-
// the preview image data (we need this to filter the image)
|
|
1861
|
-
root.ref.imageData = null;
|
|
1862
|
-
|
|
1863
|
-
// image bin
|
|
1864
|
-
root.ref.imageViewBin = [];
|
|
1865
|
-
|
|
1866
|
-
// image overlays
|
|
1867
|
-
root.ref.overlayShadow = root.appendChildView(
|
|
1868
|
-
root.createChildView(OverlayView, {
|
|
1869
|
-
opacity: 0,
|
|
1870
|
-
status: 'idle'
|
|
1871
|
-
})
|
|
1872
|
-
);
|
|
1873
|
-
|
|
1874
|
-
root.ref.overlaySuccess = root.appendChildView(
|
|
1875
|
-
root.createChildView(OverlayView, {
|
|
1876
|
-
opacity: 0,
|
|
1877
|
-
status: 'success'
|
|
1878
|
-
})
|
|
1879
|
-
);
|
|
1880
|
-
|
|
1881
|
-
root.ref.overlayError = root.appendChildView(
|
|
1882
|
-
root.createChildView(OverlayView, {
|
|
1883
|
-
opacity: 0,
|
|
1884
|
-
status: 'failure'
|
|
1885
|
-
})
|
|
1886
|
-
);
|
|
1887
|
-
};
|
|
1888
|
-
|
|
1889
|
-
return _.utils.createView({
|
|
1890
|
-
name: 'image-preview-wrapper',
|
|
1891
|
-
create: create,
|
|
1892
|
-
styles: ['height'],
|
|
1893
|
-
apis: ['height'],
|
|
1894
|
-
destroy: function destroy(_ref13) {
|
|
1895
|
-
var root = _ref13.root;
|
|
1896
|
-
// we resize the image so memory on iOS 12 is released more quickly (it seems)
|
|
1897
|
-
root.ref.images.forEach(function(imageView) {
|
|
1898
|
-
imageView.image.width = 1;
|
|
1899
|
-
imageView.image.height = 1;
|
|
1900
|
-
});
|
|
1901
|
-
},
|
|
1902
|
-
didWriteView: function didWriteView(_ref14) {
|
|
1903
|
-
var root = _ref14.root;
|
|
1904
|
-
root.ref.images.forEach(function(imageView) {
|
|
1905
|
-
imageView.dirty = false;
|
|
1906
|
-
});
|
|
1907
|
-
},
|
|
1908
|
-
write: _.utils.createRoute(
|
|
1909
|
-
{
|
|
1910
|
-
// image preview stated
|
|
1911
|
-
DID_IMAGE_PREVIEW_DRAW: didDrawPreview,
|
|
1912
|
-
DID_IMAGE_PREVIEW_CONTAINER_CREATE: didCreatePreviewContainer,
|
|
1913
|
-
DID_FINISH_CALCULATE_PREVIEWSIZE: drawPreview,
|
|
1914
|
-
DID_UPDATE_ITEM_METADATA: didUpdateItemMetadata,
|
|
1915
|
-
|
|
1916
|
-
// file states
|
|
1917
|
-
DID_THROW_ITEM_LOAD_ERROR: didThrowError,
|
|
1918
|
-
DID_THROW_ITEM_PROCESSING_ERROR: didThrowError,
|
|
1919
|
-
DID_THROW_ITEM_INVALID: didThrowError,
|
|
1920
|
-
DID_COMPLETE_ITEM_PROCESSING: didCompleteProcessing,
|
|
1921
|
-
DID_START_ITEM_PROCESSING: restoreOverlay,
|
|
1922
|
-
DID_REVERT_ITEM_PROCESSING: restoreOverlay
|
|
1923
|
-
},
|
|
1924
|
-
|
|
1925
|
-
function(_ref15) {
|
|
1926
|
-
var root = _ref15.root;
|
|
1927
|
-
// views on death row
|
|
1928
|
-
var viewsToRemove = root.ref.imageViewBin.filter(function(imageView) {
|
|
1929
|
-
return imageView.opacity === 0;
|
|
1930
|
-
});
|
|
1931
|
-
|
|
1932
|
-
// views to retain
|
|
1933
|
-
root.ref.imageViewBin = root.ref.imageViewBin.filter(function(
|
|
1934
|
-
imageView
|
|
1935
|
-
) {
|
|
1936
|
-
return imageView.opacity > 0;
|
|
1937
|
-
});
|
|
1938
|
-
|
|
1939
|
-
// remove these views
|
|
1940
|
-
viewsToRemove.forEach(function(imageView) {
|
|
1941
|
-
return removeImageView(root, imageView);
|
|
1942
|
-
});
|
|
1943
|
-
viewsToRemove.length = 0;
|
|
1944
|
-
}
|
|
1945
|
-
)
|
|
1946
|
-
});
|
|
1947
|
-
};
|
|
1948
|
-
|
|
1949
|
-
/**
|
|
1950
|
-
* Image Preview Plugin
|
|
1951
|
-
*/
|
|
1952
|
-
var plugin = function plugin(fpAPI) {
|
|
1953
|
-
var addFilter = fpAPI.addFilter,
|
|
1954
|
-
utils = fpAPI.utils;
|
|
1955
|
-
var Type = utils.Type,
|
|
1956
|
-
createRoute = utils.createRoute,
|
|
1957
|
-
isFile = utils.isFile;
|
|
1958
|
-
|
|
1959
|
-
// imagePreviewView
|
|
1960
|
-
var imagePreviewView = createImageWrapperView(fpAPI);
|
|
1961
|
-
|
|
1962
|
-
// called for each view that is created right after the 'create' method
|
|
1963
|
-
addFilter('CREATE_VIEW', function(viewAPI) {
|
|
1964
|
-
// get reference to created view
|
|
1965
|
-
var is = viewAPI.is,
|
|
1966
|
-
view = viewAPI.view,
|
|
1967
|
-
query = viewAPI.query;
|
|
1968
|
-
|
|
1969
|
-
// only hook up to item view and only if is enabled for this cropper
|
|
1970
|
-
if (!is('file') || !query('GET_ALLOW_IMAGE_PREVIEW')) return;
|
|
1971
|
-
|
|
1972
|
-
// create the image preview plugin, but only do so if the item is an image
|
|
1973
|
-
var didLoadItem = function didLoadItem(_ref) {
|
|
1974
|
-
var root = _ref.root,
|
|
1975
|
-
props = _ref.props;
|
|
1976
|
-
var id = props.id;
|
|
1977
|
-
var item = query('GET_ITEM', id);
|
|
1978
|
-
|
|
1979
|
-
// item could theoretically have been removed in the mean time
|
|
1980
|
-
if (!item || !isFile(item.file) || item.archived) return;
|
|
1981
|
-
|
|
1982
|
-
// get the file object
|
|
1983
|
-
var file = item.file;
|
|
1984
|
-
|
|
1985
|
-
// exit if this is not an image
|
|
1986
|
-
if (!isPreviewableImage(file)) return;
|
|
1987
|
-
|
|
1988
|
-
// test if is filtered
|
|
1989
|
-
if (!query('GET_IMAGE_PREVIEW_FILTER_ITEM')(item)) return;
|
|
1990
|
-
|
|
1991
|
-
// exit if image size is too high and no createImageBitmap support
|
|
1992
|
-
// this would simply bring the browser to its knees and that is not what we want
|
|
1993
|
-
var supportsCreateImageBitmap = 'createImageBitmap' in (window || {});
|
|
1994
|
-
var maxPreviewFileSize = query('GET_IMAGE_PREVIEW_MAX_FILE_SIZE');
|
|
1995
|
-
if (
|
|
1996
|
-
!supportsCreateImageBitmap &&
|
|
1997
|
-
maxPreviewFileSize &&
|
|
1998
|
-
file.size > maxPreviewFileSize
|
|
1999
|
-
)
|
|
2000
|
-
return;
|
|
2001
|
-
|
|
2002
|
-
// set preview view
|
|
2003
|
-
root.ref.imagePreview = view.appendChildView(
|
|
2004
|
-
view.createChildView(imagePreviewView, { id: id })
|
|
2005
|
-
);
|
|
2006
|
-
|
|
2007
|
-
// update height if is fixed
|
|
2008
|
-
var fixedPreviewHeight = root.query('GET_IMAGE_PREVIEW_HEIGHT');
|
|
2009
|
-
if (fixedPreviewHeight) {
|
|
2010
|
-
root.dispatch('DID_UPDATE_PANEL_HEIGHT', {
|
|
2011
|
-
id: item.id,
|
|
2012
|
-
height: fixedPreviewHeight
|
|
2013
|
-
});
|
|
2014
|
-
}
|
|
2015
|
-
|
|
2016
|
-
// now ready
|
|
2017
|
-
var queue =
|
|
2018
|
-
!supportsCreateImageBitmap &&
|
|
2019
|
-
file.size > query('GET_IMAGE_PREVIEW_MAX_INSTANT_PREVIEW_FILE_SIZE');
|
|
2020
|
-
root.dispatch('DID_IMAGE_PREVIEW_CONTAINER_CREATE', { id: id }, queue);
|
|
2021
|
-
};
|
|
2022
|
-
|
|
2023
|
-
var rescaleItem = function rescaleItem(root, props) {
|
|
2024
|
-
if (!root.ref.imagePreview) return;
|
|
2025
|
-
var id = props.id;
|
|
2026
|
-
|
|
2027
|
-
// get item
|
|
2028
|
-
var item = root.query('GET_ITEM', { id: id });
|
|
2029
|
-
if (!item) return;
|
|
2030
|
-
|
|
2031
|
-
// if is fixed height or panel has aspect ratio, exit here, height has already been defined
|
|
2032
|
-
var panelAspectRatio = root.query('GET_PANEL_ASPECT_RATIO');
|
|
2033
|
-
var itemPanelAspectRatio = root.query('GET_ITEM_PANEL_ASPECT_RATIO');
|
|
2034
|
-
var fixedHeight = root.query('GET_IMAGE_PREVIEW_HEIGHT');
|
|
2035
|
-
if (panelAspectRatio || itemPanelAspectRatio || fixedHeight) return;
|
|
2036
|
-
|
|
2037
|
-
// no data!
|
|
2038
|
-
var _root$ref = root.ref,
|
|
2039
|
-
imageWidth = _root$ref.imageWidth,
|
|
2040
|
-
imageHeight = _root$ref.imageHeight;
|
|
2041
|
-
if (!imageWidth || !imageHeight) return;
|
|
2042
|
-
|
|
2043
|
-
// get height min and max
|
|
2044
|
-
var minPreviewHeight = root.query('GET_IMAGE_PREVIEW_MIN_HEIGHT');
|
|
2045
|
-
var maxPreviewHeight = root.query('GET_IMAGE_PREVIEW_MAX_HEIGHT');
|
|
2046
|
-
|
|
2047
|
-
// orientation info
|
|
2048
|
-
var exif = item.getMetadata('exif') || {};
|
|
2049
|
-
var orientation = exif.orientation || -1;
|
|
2050
|
-
|
|
2051
|
-
// get width and height from action, and swap of orientation is incorrect
|
|
2052
|
-
if (orientation >= 5 && orientation <= 8) {
|
|
2053
|
-
var _ref2 = [imageHeight, imageWidth];
|
|
2054
|
-
imageWidth = _ref2[0];
|
|
2055
|
-
imageHeight = _ref2[1];
|
|
2056
|
-
}
|
|
2057
|
-
|
|
2058
|
-
// scale up width and height when we're dealing with an SVG
|
|
2059
|
-
if (!isBitmap(item.file) || root.query('GET_IMAGE_PREVIEW_UPSCALE')) {
|
|
2060
|
-
var scalar = 2048 / imageWidth;
|
|
2061
|
-
imageWidth *= scalar;
|
|
2062
|
-
imageHeight *= scalar;
|
|
2063
|
-
}
|
|
2064
|
-
|
|
2065
|
-
// image aspect ratio
|
|
2066
|
-
var imageAspectRatio = imageHeight / imageWidth;
|
|
2067
|
-
|
|
2068
|
-
// we need the item to get to the crop size
|
|
2069
|
-
var previewAspectRatio =
|
|
2070
|
-
(item.getMetadata('crop') || {}).aspectRatio || imageAspectRatio;
|
|
2071
|
-
|
|
2072
|
-
// preview height range
|
|
2073
|
-
var previewHeightMax = Math.max(
|
|
2074
|
-
minPreviewHeight,
|
|
2075
|
-
Math.min(imageHeight, maxPreviewHeight)
|
|
2076
|
-
);
|
|
2077
|
-
|
|
2078
|
-
var itemWidth = root.rect.element.width;
|
|
2079
|
-
var previewHeight = Math.min(
|
|
2080
|
-
itemWidth * previewAspectRatio,
|
|
2081
|
-
previewHeightMax
|
|
2082
|
-
);
|
|
2083
|
-
|
|
2084
|
-
// request update to panel height
|
|
2085
|
-
root.dispatch('DID_UPDATE_PANEL_HEIGHT', {
|
|
2086
|
-
id: item.id,
|
|
2087
|
-
height: previewHeight
|
|
2088
|
-
});
|
|
2089
|
-
};
|
|
2090
|
-
|
|
2091
|
-
var didResizeView = function didResizeView(_ref3) {
|
|
2092
|
-
var root = _ref3.root;
|
|
2093
|
-
// actions in next write operation
|
|
2094
|
-
root.ref.shouldRescale = true;
|
|
2095
|
-
};
|
|
2096
|
-
|
|
2097
|
-
var didUpdateItemMetadata = function didUpdateItemMetadata(_ref4) {
|
|
2098
|
-
var root = _ref4.root,
|
|
2099
|
-
action = _ref4.action;
|
|
2100
|
-
if (action.change.key !== 'crop') return;
|
|
2101
|
-
|
|
2102
|
-
// actions in next write operation
|
|
2103
|
-
root.ref.shouldRescale = true;
|
|
2104
|
-
};
|
|
2105
|
-
|
|
2106
|
-
var didCalculatePreviewSize = function didCalculatePreviewSize(_ref5) {
|
|
2107
|
-
var root = _ref5.root,
|
|
2108
|
-
action = _ref5.action;
|
|
2109
|
-
// remember dimensions
|
|
2110
|
-
root.ref.imageWidth = action.width;
|
|
2111
|
-
root.ref.imageHeight = action.height;
|
|
2112
|
-
|
|
2113
|
-
// actions in next write operation
|
|
2114
|
-
root.ref.shouldRescale = true;
|
|
2115
|
-
root.ref.shouldDrawPreview = true;
|
|
2116
|
-
|
|
2117
|
-
// as image load could take a while and fire when draw loop is resting we need to give it a kick
|
|
2118
|
-
root.dispatch('KICK');
|
|
2119
|
-
};
|
|
2120
|
-
|
|
2121
|
-
// start writing
|
|
2122
|
-
view.registerWriter(
|
|
2123
|
-
createRoute(
|
|
2124
|
-
{
|
|
2125
|
-
DID_RESIZE_ROOT: didResizeView,
|
|
2126
|
-
DID_STOP_RESIZE: didResizeView,
|
|
2127
|
-
DID_LOAD_ITEM: didLoadItem,
|
|
2128
|
-
DID_IMAGE_PREVIEW_CALCULATE_SIZE: didCalculatePreviewSize,
|
|
2129
|
-
DID_UPDATE_ITEM_METADATA: didUpdateItemMetadata
|
|
2130
|
-
},
|
|
2131
|
-
|
|
2132
|
-
function(_ref6) {
|
|
2133
|
-
var root = _ref6.root,
|
|
2134
|
-
props = _ref6.props;
|
|
2135
|
-
// no preview view attached
|
|
2136
|
-
if (!root.ref.imagePreview) return;
|
|
2137
|
-
|
|
2138
|
-
// don't do anything while hidden
|
|
2139
|
-
if (root.rect.element.hidden) return;
|
|
2140
|
-
|
|
2141
|
-
// resize the item panel
|
|
2142
|
-
if (root.ref.shouldRescale) {
|
|
2143
|
-
rescaleItem(root, props);
|
|
2144
|
-
root.ref.shouldRescale = false;
|
|
2145
|
-
}
|
|
2146
|
-
|
|
2147
|
-
if (root.ref.shouldDrawPreview) {
|
|
2148
|
-
// queue till next frame so we're sure the height has been applied this forces the draw image call inside the wrapper view to use the correct height
|
|
2149
|
-
requestAnimationFrame(function() {
|
|
2150
|
-
// this requestAnimationFrame nesting is horrible but it fixes an issue with 100hz displays on Chrome
|
|
2151
|
-
// https://github.com/pqina/filepond-plugin-image-preview/issues/57
|
|
2152
|
-
requestAnimationFrame(function() {
|
|
2153
|
-
root.dispatch('DID_FINISH_CALCULATE_PREVIEWSIZE', {
|
|
2154
|
-
id: props.id
|
|
2155
|
-
});
|
|
2156
|
-
});
|
|
2157
|
-
});
|
|
2158
|
-
|
|
2159
|
-
root.ref.shouldDrawPreview = false;
|
|
2160
|
-
}
|
|
2161
|
-
}
|
|
2162
|
-
)
|
|
2163
|
-
);
|
|
2164
|
-
});
|
|
2165
|
-
|
|
2166
|
-
// expose plugin
|
|
2167
|
-
return {
|
|
2168
|
-
options: {
|
|
2169
|
-
// Enable or disable image preview
|
|
2170
|
-
allowImagePreview: [true, Type.BOOLEAN],
|
|
2171
|
-
|
|
2172
|
-
// filters file items to determine which are shown as preview
|
|
2173
|
-
imagePreviewFilterItem: [
|
|
2174
|
-
function() {
|
|
2175
|
-
return true;
|
|
2176
|
-
},
|
|
2177
|
-
Type.FUNCTION
|
|
2178
|
-
],
|
|
2179
|
-
|
|
2180
|
-
// Fixed preview height
|
|
2181
|
-
imagePreviewHeight: [null, Type.INT],
|
|
2182
|
-
|
|
2183
|
-
// Min image height
|
|
2184
|
-
imagePreviewMinHeight: [44, Type.INT],
|
|
2185
|
-
|
|
2186
|
-
// Max image height
|
|
2187
|
-
imagePreviewMaxHeight: [256, Type.INT],
|
|
2188
|
-
|
|
2189
|
-
// Max size of preview file for when createImageBitmap is not supported
|
|
2190
|
-
imagePreviewMaxFileSize: [null, Type.INT],
|
|
2191
|
-
|
|
2192
|
-
// The amount of extra pixels added to the image preview to allow comfortable zooming
|
|
2193
|
-
imagePreviewZoomFactor: [2, Type.INT],
|
|
2194
|
-
|
|
2195
|
-
// Should we upscale small images to fit the max bounding box of the preview area
|
|
2196
|
-
imagePreviewUpscale: [false, Type.BOOLEAN],
|
|
2197
|
-
|
|
2198
|
-
// Max size of preview file that we allow to try to instant preview if createImageBitmap is not supported, else image is queued for loading
|
|
2199
|
-
imagePreviewMaxInstantPreviewFileSize: [1000000, Type.INT],
|
|
2200
|
-
|
|
2201
|
-
// Style of the transparancy indicator used behind images
|
|
2202
|
-
imagePreviewTransparencyIndicator: [null, Type.STRING],
|
|
2203
|
-
|
|
2204
|
-
// Enables or disables reading average image color
|
|
2205
|
-
imagePreviewCalculateAverageImageColor: [false, Type.BOOLEAN],
|
|
2206
|
-
|
|
2207
|
-
// Enables or disables the previewing of markup
|
|
2208
|
-
imagePreviewMarkupShow: [true, Type.BOOLEAN],
|
|
2209
|
-
|
|
2210
|
-
// Allows filtering of markup to only show certain shapes
|
|
2211
|
-
imagePreviewMarkupFilter: [
|
|
2212
|
-
function() {
|
|
2213
|
-
return true;
|
|
2214
|
-
},
|
|
2215
|
-
Type.FUNCTION
|
|
2216
|
-
]
|
|
2217
|
-
}
|
|
2218
|
-
};
|
|
2219
|
-
};
|
|
2220
|
-
|
|
2221
|
-
// fire pluginloaded event if running in browser, this allows registering the plugin when using async script tags
|
|
2222
|
-
var isBrowser =
|
|
2223
|
-
typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
2224
|
-
if (isBrowser) {
|
|
2225
|
-
document.dispatchEvent(
|
|
2226
|
-
new CustomEvent('FilePond:pluginloaded', { detail: plugin })
|
|
2227
|
-
);
|
|
2228
|
-
}
|
|
2229
|
-
|
|
2230
|
-
return plugin;
|
|
2231
|
-
});
|
|
2232
|
-
} (filepondPluginImagePreview$3));
|
|
2233
|
-
return filepondPluginImagePreview$3.exports;
|
|
2234
|
-
}
|
|
2235
|
-
|
|
2236
|
-
var filepondPluginImagePreviewExports = requireFilepondPluginImagePreview();
|
|
2237
|
-
var filepondPluginImagePreview = /*@__PURE__*/getDefaultExportFromCjs(filepondPluginImagePreviewExports);
|
|
2238
|
-
|
|
2239
|
-
var filepondPluginImagePreview$1 = /*#__PURE__*/_mergeNamespaces({
|
|
2240
|
-
__proto__: null,
|
|
2241
|
-
default: filepondPluginImagePreview
|
|
2242
|
-
}, [filepondPluginImagePreviewExports]);
|
|
2243
|
-
|
|
2244
|
-
export { filepondPluginImagePreview$1 as f };
|
|
9
|
+
*/export{a as f}
|