(function framework7ComponentLoader(a,e){void 0===e&&(e=!0);var t=a.$,r=(a.Template7,a.utils),s=(a.getDevice,a.getSupport),o=(a.Class,a.Modal,a.ConstructorMethods,a.ModalMethods,r.bindMethods),n={destroy:function(a){var e=t(a).closest(".page");e.length&&e[0].f7LazyDestroy&&e[0].f7LazyDestroy()},create:function(a){var e=this,r=s(),o=t(a).closest(".page").eq(0),n=o.find(".lazy");if(0!==n.length||o.hasClass("lazy")){var l=e.params.lazy.placeholder;!1!==l&&n.each((function(a){t(a).attr("data-src")&&!t(a).attr("src")&&t(a).attr("src",l)}));var i=[],d=!1;if(e.params.lazy.observer&&r.intersectionObserver){var y=o[0].f7LazyObserver;return y||(y=new window.IntersectionObserver((function(a,t){a.forEach((function(a){if(a.isIntersecting){if(e.params.lazy.sequential&&d)return void(i.indexOf(a.target)<0&&i.push(a.target));d=!0,e.lazy.loadImage(a.target,c),t.unobserve(a.target)}}))}),{root:o[0]})),n.each((function(a){a.f7LazyObserverAdded||(a.f7LazyObserverAdded=!0,y.observe(a))})),void(o[0].f7LazyDestroy||(o[0].f7LazyDestroy=function(){y.disconnect(),delete o[0].f7LazyDestroy,delete o[0].f7LazyObserver}))}o[0].f7LazyDestroy||(o[0].f7LazyDestroy=function(){o[0].f7LazyAttached=!1,delete o[0].f7LazyAttached,o.off("lazy",f),o.off("scroll",f,!0),o.find(".tab").off("tab:mounted tab:show",f),e.off("resize",f)}),o[0].f7LazyAttached||(o[0].f7LazyAttached=!0,o.on("lazy",f),o.on("scroll",f,!0),o.find(".tab").on("tab:mounted tab:show",f),e.on("resize",f)),f()}function c(a){i.indexOf(a)>=0&&i.splice(i.indexOf(a),1),d=!1,e.params.lazy.sequential&&i.length>0&&(d=!0,e.lazy.loadImage(i[0],c))}function f(){e.lazy.load(o,(function(a){e.params.lazy.sequential&&d?i.indexOf(a)<0&&i.push(a):(d=!0,e.lazy.loadImage(a,c))}))}},isInViewport:function(a){var e=a.getBoundingClientRect(),t=this.params.lazy.threshold||0;return e.top>=0-t&&e.left>=0-t&&e.top<=this.height+t&&e.left<=this.width+t},loadImage:function(a,e){var r=this,s=t(a),o=s.attr("data-background"),n=o||s.attr("data-src");function l(){s.removeClass("lazy").addClass("lazy-loaded"),o?s.css("background-image","url("+n+")"):n&&s.attr("src",n),e&&e(a),s.trigger("lazy:loaded"),r.emit("lazyLoaded",s[0])}if(!n)return s.trigger("lazy:load"),r.emit("lazyLoad",s[0]),void l();var i=new window.Image;i.onload=l,i.onerror=function(){s.removeClass("lazy").addClass("lazy-loaded"),o?s.css("background-image","url("+(r.params.lazy.placeholder||"")+")"):s.attr("src",r.params.lazy.placeholder||""),e&&e(a),s.trigger("lazy:error"),r.emit("lazyError",s[0])},i.src=n,s.removeAttr("data-src").removeAttr("data-background"),s.trigger("lazy:load"),r.emit("lazyLoad",s[0])},load:function(a,e){var r=this,s=t(a);s.hasClass("page")||(s=s.parents(".page").eq(0)),0!==s.length&&s.find(".lazy").each((function(a){t(a).parents(".tab:not(.tab-active)").length>0||r.lazy.isInViewport(a)&&(e?e(a):r.lazy.loadImage(a))}))}},l={name:"lazy",params:{lazy:{placeholder:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEXCwsK592mkAAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==",threshold:0,sequential:!0,observer:!0}},create:function(){o(this,{lazy:n})},on:{pageInit:function(a){(a.$el.find(".lazy").length>0||a.$el.hasClass("lazy"))&&this.lazy.create(a.$el)},pageAfterIn:function(a){var e=s();this.params.lazy.observer&&e.intersectionObserver||(a.$el.find(".lazy").length>0||a.$el.hasClass("lazy"))&&this.lazy.create(a.$el)},pageBeforeRemove:function(a){(a.$el.find(".lazy").length>0||a.$el.hasClass("lazy"))&&this.lazy.destroy(a.$el)},tabMounted:function(a){var e=t(a);(e.find(".lazy").length>0||e.hasClass("lazy"))&&this.lazy.create(e)},tabBeforeRemove:function(a){var e=s();if(!this.params.lazy.observer||!e.intersectionObserver){var r=t(a);(r.find(".lazy").length>0||r.hasClass("lazy"))&&this.lazy.destroy(r)}}}};if(e){if(a.prototype.modules&&a.prototype.modules[l.name])return;a.use(l),a.instance&&(a.instance.useModuleParams(l,a.instance.params),a.instance.useModule(l))}return l}(Framework7, typeof Framework7AutoInstallComponent === 'undefined' ? undefined : Framework7AutoInstallComponent))
