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ACd,KAAK,aADS,EAEd,KAAK,aAFS,EAGd,KAAK,gBAAL,EAHc,EAId,KAAK,UAAL,EAJc,CAAhB;AAOA,eAAO,EAAE,KAAK,GAAP,EAAY,KAAK,IAAjB,EAAuB,KAAK,QAA5B,CAAP;AACD;AAzM+B,CAAnB,C;AAZf","sourcesContent":["import '../../stylus/components/_images.styl'\n\n// Types\nimport { VNode } from 'vue'\nimport { PropValidator } from 'vue/types/options'\n\n// Components\nimport VResponsive from '../VResponsive'\n\n// Utils\nimport { consoleError, consoleWarn } from '../../util/console'\n\n// not intended for public use, this is passed in by vuetify-loader\nexport interface srcObject {\n src: string\n srcset?: string\n lazySrc: string\n aspect: number\n}\n\n/* @vue/component */\nexport default VResponsive.extend({\n name: 'v-img',\n\n props: {\n alt: String,\n contain: Boolean,\n src: {\n type: [String, Object],\n default: ''\n } as PropValidator,\n gradient: String,\n lazySrc: String,\n srcset: String,\n sizes: String,\n position: {\n type: String,\n default: 'center center'\n },\n transition: {\n type: [Boolean, String],\n default: 'fade-transition'\n }\n },\n\n data () {\n return {\n currentSrc: '', // Set from srcset\n image: null as HTMLImageElement | null,\n isLoading: true,\n calculatedAspectRatio: undefined as number | undefined\n }\n },\n\n computed: {\n computedAspectRatio (): number {\n return this.normalisedSrc.aspect\n },\n normalisedSrc (): srcObject {\n return typeof this.src === 'string'\n ? {\n src: this.src,\n srcset: this.srcset,\n lazySrc: this.lazySrc,\n aspect: Number(this.aspectRatio || this.calculatedAspectRatio)\n }\n : {\n src: this.src.src,\n srcset: this.srcset || this.src.srcset,\n lazySrc: this.lazySrc || this.src.lazySrc,\n aspect: Number(this.aspectRatio || this.src.aspect || this.calculatedAspectRatio)\n }\n },\n __cachedImage (): VNode | [] {\n if (!(this.normalisedSrc.src || this.normalisedSrc.lazySrc)) return []\n\n const backgroundImage: string[] = []\n const src = this.isLoading ? this.normalisedSrc.lazySrc : this.currentSrc\n\n if (this.gradient) backgroundImage.push(`linear-gradient(${this.gradient})`)\n if (src) backgroundImage.push(`url(\"${src}\")`)\n\n const image = this.$createElement('div', {\n staticClass: 'v-image__image',\n class: {\n 'v-image__image--preload': this.isLoading,\n 'v-image__image--contain': this.contain,\n 'v-image__image--cover': !this.contain\n },\n style: {\n backgroundImage: backgroundImage.join(', '),\n backgroundPosition: this.position\n },\n key: +this.isLoading\n })\n\n if (!this.transition) return image\n\n return this.$createElement('transition', {\n attrs: {\n name: this.transition,\n mode: 'in-out'\n }\n }, [image])\n }\n },\n\n watch: {\n src () {\n if (!this.isLoading) this.init()\n else this.loadImage()\n },\n '$vuetify.breakpoint.width': 'getSrc'\n },\n\n mounted () {\n this.init()\n },\n\n methods: {\n init () {\n if (this.normalisedSrc.lazySrc) {\n const lazyImg = new Image()\n lazyImg.src = this.normalisedSrc.lazySrc\n this.pollForSize(lazyImg, null)\n }\n /* istanbul ignore else */\n if (this.normalisedSrc.src) this.loadImage()\n },\n onLoad () {\n this.getSrc()\n this.isLoading = false\n this.$emit('load', this.src)\n },\n onError () {\n consoleError(\n `Image load failed\\n\\n` +\n `src: ${this.normalisedSrc.src}`,\n this\n )\n this.$emit('error', this.src)\n },\n getSrc () {\n /* istanbul ignore else */\n if (this.image) this.currentSrc = this.image.currentSrc || this.image.src\n },\n loadImage () {\n const image = new Image()\n this.image = image\n\n image.onload = () => {\n /* istanbul ignore if */\n if (image.decode) {\n image.decode().catch((err: DOMException) => {\n consoleWarn(\n `Failed to decode image, trying to render anyway\\n\\n` +\n `src: ${this.normalisedSrc.src}` +\n (err.message ? `\\nOriginal error: ${err.message}` : ''),\n this\n )\n }).then(this.onLoad)\n } else {\n this.onLoad()\n }\n }\n image.onerror = this.onError\n\n image.src = this.normalisedSrc.src\n this.sizes && (image.sizes = this.sizes)\n this.normalisedSrc.srcset && (image.srcset = this.normalisedSrc.srcset)\n\n this.aspectRatio || this.pollForSize(image)\n this.getSrc()\n },\n pollForSize (img: HTMLImageElement, timeout: number | null = 100) {\n const poll = () => {\n const { naturalHeight, naturalWidth } = img\n\n if (naturalHeight || naturalWidth) {\n this.calculatedAspectRatio = naturalWidth / naturalHeight\n } else {\n timeout != null && setTimeout(poll, timeout)\n }\n }\n\n poll()\n },\n __genPlaceholder (): VNode | void {\n if (this.$slots.placeholder) {\n const placeholder = this.isLoading\n ? [this.$createElement('div', {\n staticClass: 'v-image__placeholder'\n }, this.$slots.placeholder)]\n : []\n\n if (!this.transition) return placeholder[0]\n\n return this.$createElement('transition', {\n attrs: { name: this.transition }\n }, placeholder)\n }\n }\n },\n\n render (h): VNode {\n const node = VResponsive.options.render.call(this, h)\n\n node.data!.staticClass += ' v-image'\n\n node.data!.attrs = {\n role: this.alt ? 'img' : undefined,\n 'aria-label': this.alt\n }\n\n node.children = [\n this.__cachedSizer,\n this.__cachedImage,\n this.__genPlaceholder(),\n this.genContent()\n ] as VNode[]\n\n return h(node.tag, node.data, node.children)\n }\n})\n"],"sourceRoot":""}