text: !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("rxjs"),require("rxjs/operators"),require("@angular/common")):"function"==typeof define&&define.amd?define("ng-lazyload-image",["exports","@angular/core","rxjs","rxjs/operators","@angular/common"],e):e((t=t||self)["ng-lazyload-image"]={},t.ng.core,t.rxjs,t.rxjs.operators,t.ng.common)}(this,(function(t,e,n,r,o){"use strict";var i=new e.InjectionToken("LazyLoadImageHooks");function s(t){return Boolean(t.parentElement&&"picture"===t.parentElement.nodeName.toLowerCase())}function a(t){return"img"===t.nodeName.toLowerCase()}function u(t,e,n){return a(t)?n&&"srcset"in t?t.srcset=e:t.src=e:t.style.backgroundImage="url('"+e+"')",t}function c(t){return function(e){for(var n=e.parentElement.getElementsByTagName("source"),r=0;r<n.length;r++){var o=n[r].getAttribute(t);o&&("srcset"in n[r]?n[r].srcset=o:n[r].src=o)}}}var l=c("defaultImage"),p=c("lazyLoad"),f=c("errorImage");function h(t){return function(e,n,r){a(e)&&s(e)&&t(e),n&&u(e,n,r)}}var g=h(l),d=h(p),m=h(f),b=function(){function t(){this.navigator="undefined"!=typeof window?window.navigator:void 0}return t.prototype.setPlatformId=function(t){this.platformId=t},t.prototype.onDestroy=function(t){},t.prototype.onAttributeChange=function(t){},t}(),y=function(){function t(t,r,o,i){this.onStateChange=new e.EventEmitter,this.elementRef=t,this.ngZone=r,this.propertyChanges$=new n.ReplaySubject,this.hooks=i,this.hooks.setPlatformId(o),this.uid=Math.random().toString(36).substr(2,9)}return t.prototype.ngOnChanges=function(){!0!==this.debug||this.debugSubscription||(this.debugSubscription=this.onStateChange.subscribe((function(t){return console.log(t)}))),this.propertyChanges$.next({element:this.elementRef.nativeElement,imagePath:this.lazyImage,defaultImagePath:this.defaultImage,errorImagePath:this.errorImage,useSrcset:this.useSrcset,offset:this.offset?0|this.offset:0,scrollContainer:this.scrollTarget,customObservable:this.customObservable,decode:this.decode,onStateChange:this.onStateChange,id:this.uid})},t.prototype.ngAfterContentInit=function(){var t=this;if(this.hooks.isDisabled())return null;this.ngZone.runOutsideAngular((function(){t.loadSubscription=t.propertyChanges$.pipe(r.tap((function(e){return t.hooks.onAttributeChange(e)})),r.tap((function(t){return t.onStateChange.emit({reason:"setup"})})),r.tap((function(e){return t.hooks.setup(e)})),r.switchMap((function(e){return e.imagePath?t.hooks.getObservable(e).pipe(function(t,e){return function(o){return o.pipe(r.tap((function(t){return e.onStateChange.emit({reason:"observer-emit",data:t})})),r.filter((function(n){return t.isVisible(n,e)})),r.take(1),r.tap((function(){return e.onStateChange.emit({reason:"start-loading"})})),r.mergeMap((function(){return t.loadImage(e)})),r.tap((function(){return e.onStateChange.emit({reason:"mount-image"})})),r.tap((function(n){return t.setLoadedImage(n,e)})),r.tap((function(){return e.onStateChange.emit({reason:"loading-succeeded"})})),r.map((function(){return!0})),r.catchError((function(r){return e.onStateChange.emit({reason:"loading-failed",data:r}),t.setErrorImage(r,e),n.of(!1)})),r.tap((function(){e.onStateChange.emit({reason:"finally"}),t.finally(e)})))}}(t.hooks,e)):n.never()}))).subscribe({next:function(){return null}})}))},t.prototype.ngOnDestroy=function(){var t,e,n=this;this.propertyChanges$.pipe(r.take(1)).subscribe({next:function(t){return n.hooks.onDestroy(t)}}).unsubscribe(),null===(t=this.loadSubscription)||void 0===t||t.unsubscribe(),null===(e=this.debugSubscription)||void 0===e||e.unsubscribe()},t}();y.decorators=[{type:e.Directive,args:[{selector:"[lazyLoad]"}]}],y.ctorParameters=function(){return[{type:e.ElementRef},{type:e.NgZone},{type:Object,decorators:[{type:e.Inject,args:[e.PLATFORM_ID]}]},{type:b,decorators:[{type:e.Inject,args:[i]}]}]},y.propDecorators={lazyImage:[{type:e.Input,args:["lazyLoad"]}],defaultImage:[{type:e.Input}],errorImage:[{type:e.Input}],scrollTarget:[{type:e.Input}],customObservable:[{type:e.Input}],offset:[{type:e.Input}],useSrcset:[{type:e.Input}],decode:[{type:e.Input}],debug:[{type:e.Input}],onStateChange:[{type:e.Output}]};
  /*! *****************************************************************************
      Copyright (c) Microsoft Corporation.
  
      Permission to use, copy, modify, and/or distribute this software for any
      purpose with or without fee is hereby granted.
  
      THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
      REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
      AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
      INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
      LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
      OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
      PERFORMANCE OF THIS SOFTWARE.
      ***************************************************************************** */
  var v=function(t,e){return(v=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function I(t,e){function n(){this.constructor=t}v(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}Object.create;function S(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}function w(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(S(arguments[e]));return t}Object.create;var C="ng-lazyloaded",k="ng-lazyloading",L="ng-failed-lazyloaded";function O(t,e){t.className=t.className.replace(e,"")}function j(t,e){t.className.includes(e)||(t.className+=" "+e)}var x=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return I(e,t),e.prototype.setup=function(t){var e,n;g(t.element,t.defaultImagePath,t.useSrcset),j(t.element,k),e=t.element,n=C,e.className&&e.className.includes(n)&&O(t.element,C)},e.prototype.finally=function(t){j(t.element,C),O(t.element,k)},e.prototype.loadImage=function(t){if(this.skipLazyLoading())return[t.imagePath];var e,n=t.element,r=t.useSrcset,o=t.imagePath,i=t.decode;if(a(n)&&s(n)){var c=n.parentNode.cloneNode(!0);e=c.getElementsByTagName("img")[0],p(e),u(e,o,r)}else e=new Image,a(n)&&n.referrerPolicy&&(e.referrerPolicy=n.referrerPolicy),a(n)&&n.sizes&&(e.sizes=n.sizes),r&&"srcset"in e?e.srcset=o:e.src=o;return i&&e.decode?e.decode().then((function(){return o})):new Promise((function(t,n){e.onload=function(){return t(o)},e.onerror=function(){return n(null)}}))},e.prototype.setErrorImage=function(t,e){var n=e.element,r=e.useSrcset,o=e.errorImagePath;m(n,o,r),j(n,L)},e.prototype.setLoadedImage=function(t,e){var n=e.element,r=e.useSrcset;d(n,t,r)},e.prototype.isDisabled=function(){return o.isPlatformServer(this.platformId)&&!this.isBot()},e.prototype.skipLazyLoading=function(){return this.isBot()},e.prototype.isBot=function(){var t;return!!(null===(t=this.navigator)||void 0===t?void 0:t.userAgent)&&/googlebot|bingbot|yandex|baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest\/0\.|pinterestbot|slackbot|vkShare|W3C_Validator|whatsapp|duckduckbot/i.test(this.navigator.userAgent)},e}(b),E=function(t){function e(){var e=t.apply(this,w(arguments))||this;return e.observers=new WeakMap,e.intersectionSubject=new n.Subject,e.uniqKey={},e}return I(e,t),e.prototype.getObservable=function(t){var e=this;if(this.skipLazyLoading())return n.of({isIntersecting:!0});if(t.customObservable)return t.customObservable;var o=t.scrollContainer||this.uniqKey,i={root:t.scrollContainer||null};t.offset&&(i.rootMargin=t.offset+"px");var s=this.observers.get(o);return s||(s=new IntersectionObserver((function(t){return e.loadingCallback(t)}),i),this.observers.set(o,s)),s.observe(t.element),n.Observable.create((function(n){var o=e.intersectionSubject.pipe(r.filter((function(e){return e.target===t.element}))).subscribe(n);return function(){o.unsubscribe(),s.unobserve(t.element)}}))},e.prototype.isVisible=function(t){return t.isIntersecting},e.prototype.loadingCallback=function(t){var e=this;t.forEach((function(t){return e.intersectionSubject.next(t)}))},e}(x),P=function(){};P.decorators=[{type:e.NgModule,args:[{declarations:[y],exports:[y],providers:[{provide:i,useClass:E}]}]}];var z=function(){function t(t,e,n,r){this.left=t,this.top=e,this.right=n,this.bottom=r}return t.fromElement=function(e){var n=e.getBoundingClientRect(),r=n.left,o=n.top,i=n.right,s=n.bottom;return 0===r&&0===o&&0===i&&0===s?t.empty:new t(r,o,i,s)},t.fromWindow=function(e){return new t(0,0,e.innerWidth,e.innerHeight)},t.prototype.inflate=function(t){this.left-=t,this.top-=t,this.right+=t,this.bottom+=t},t.prototype.intersectsWith=function(t){return t.left<this.right&&this.left<t.right&&t.top<this.bottom&&this.top<t.bottom},t.prototype.getIntersectionWith=function(e){var n=Math.max(this.left,e.left),r=Math.max(this.top,e.top),o=Math.min(this.right,e.right),i=Math.min(this.bottom,e.bottom);return o>=n&&i>=r?new t(n,r,o,i):t.empty},t}();z.empty=new z(0,0,0,0);var W=function(t){function e(e){void 0===e&&(e=function(){return window});var r=t.call(this)||this;return r.scrollListeners=new WeakMap,r.getScrollListener=function(t){if(!t||"function"!=typeof t.addEventListener)return console.warn("`addEventListener` on "+t+" (scrollTarget) is not a function. Skipping this target"),n.empty();var e=r.scrollListeners.get(t);if(e)return e;var o=n.Observable.create((function(e){var n=function(t){return e.next(t)},r={passive:!0,capture:!1};return t.addEventListener("scroll",n,r),function(){return t.removeEventListener("scroll",n,r)}})),i=r.sampleObservable(o);return r.scrollListeners.set(t,i),i},r.getWindow=e,r}return I(e,t),e.prototype.getObservable=function(t){return this.skipLazyLoading()?n.of("load"):t.customObservable?t.customObservable.pipe(r.startWith("")):t.scrollContainer?this.getScrollListener(t.scrollContainer):this.getScrollListener(this.getWindow())},e.prototype.isVisible=function(t,e){var n=z.fromElement(e.element);if(n===z.empty)return!1;var r=z.fromWindow(this.getWindow());if(n.inflate(e.offset),e.scrollContainer){var o=z.fromElement(e.scrollContainer).getIntersectionWith(r);return n.intersectsWith(o)}return n.intersectsWith(r)},e.prototype.sampleObservable=function(t,e){return t.pipe(r.sampleTime(100,e),r.share(),r.startWith(""))},e}(x);t.Hooks=b,t.IntersectionObserverHooks=E,t.LAZYLOAD_IMAGE_HOOKS=i,t.LazyLoadImageModule=P,t.ScrollHooks=W,t.SharedHooks=x,t.ɵa=y,Object.defineProperty(t,"__esModule",{value:!0})}));
  //# sourceMappingURL=ng-lazyload-image.umd.min.js.map