{"version":3,"file":"index.js","sources":["../../../../src/packages/media/imaging/components/imaging-thumbnail.element.ts","../../../../src/packages/media/imaging/components/media-image.element.ts"],"sourcesContent":["import { UmbImagingCropMode } from '../types.js';\r\nimport { UmbImagingRepository } from '../imaging.repository.js';\r\nimport { css, customElement, html, nothing, property, state, when } from '@umbraco-cms/backoffice/external/lit';\r\nimport { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';\r\nimport { UmbTextStyles } from '@umbraco-cms/backoffice/style';\r\n\r\n@customElement('umb-imaging-thumbnail')\r\nexport class UmbImagingThumbnailElement extends UmbLitElement {\r\n\t/**\r\n\t * The unique identifier for the media item.\r\n\t * @description This is also known as the media key and is used to fetch the resource.\r\n\t */\r\n\t@property()\r\n\tunique = '';\r\n\r\n\t/**\r\n\t * The width of the thumbnail in pixels.\r\n\t * @default 300\r\n\t */\r\n\t@property({ type: Number })\r\n\twidth = 300;\r\n\r\n\t/**\r\n\t * The height of the thumbnail in pixels.\r\n\t * @default 300\r\n\t */\r\n\t@property({ type: Number })\r\n\theight = 300;\r\n\r\n\t/**\r\n\t * The mode of the thumbnail.\r\n\t * @description The mode determines how the image is cropped.\r\n\t * @enum {UmbImagingCropMode}\r\n\t */\r\n\t@property()\r\n\tmode: UmbImagingCropMode = UmbImagingCropMode.MIN;\r\n\r\n\t/**\r\n\t * The alt text for the thumbnail.\r\n\t */\r\n\t@property()\r\n\talt = '';\r\n\r\n\t/**\r\n\t * The fallback icon for the thumbnail.\r\n\t */\r\n\t@property()\r\n\ticon = 'icon-picture';\r\n\r\n\t/**\r\n\t * The `loading` state of the thumbnail.\r\n\t * @enum {'lazy' | 'eager'}\r\n\t * @default 'lazy'\r\n\t */\r\n\t@property()\r\n\tloading: (typeof HTMLImageElement)['prototype']['loading'] = 'lazy';\r\n\r\n\t@state()\r\n\tprivate _isLoading = true;\r\n\r\n\t@state()\r\n\tprivate _thumbnailUrl = '';\r\n\r\n\t#imagingRepository = new UmbImagingRepository(this);\r\n\r\n\t#intersectionObserver?: IntersectionObserver;\r\n\r\n\toverride render() {\r\n\t\treturn html` ${this.#renderThumbnail()} ${when(this._isLoading, () => this.#renderLoading())} `;\r\n\t}\r\n\r\n\toverride connectedCallback() {\r\n\t\tsuper.connectedCallback();\r\n\r\n\t\tif (this.loading === 'lazy') {\r\n\t\t\tthis.#intersectionObserver = new IntersectionObserver((entries) => {\r\n\t\t\t\tif (entries[0].isIntersecting) {\r\n\t\t\t\t\tthis.#generateThumbnailUrl();\r\n\t\t\t\t\tthis.#intersectionObserver?.disconnect();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\tthis.#intersectionObserver.observe(this);\r\n\t\t} else {\r\n\t\t\tthis.#generateThumbnailUrl();\r\n\t\t}\r\n\t}\r\n\r\n\toverride disconnectedCallback() {\r\n\t\tsuper.disconnectedCallback();\r\n\t\tthis.#intersectionObserver?.disconnect();\r\n\t}\r\n\r\n\t#renderLoading() {\r\n\t\treturn html`