O:41:"Symfony\Component\AssetMapper\MappedAsset":12:{s:10:"sourcePath";s:85:"/home/assotax/www/vendor/ehyiah/ux-quill/assets/dist/modules/gallery/gallery-modal.js";s:10:"publicPath";s:70:"/assets/@ehyiah/ux-quill/dist/modules/gallery/gallery-modal-TAc4zks.js";s:23:"publicPathWithoutDigest";s:62:"/assets/@ehyiah/ux-quill/dist/modules/gallery/gallery-modal.js";s:15:"publicExtension";s:2:"js";s:7:"content";s:7541:"import { uploadStrategies, handleUploadResponse } from "../../upload-utils.js"; export default class GalleryModal { constructor(module) { this.module = void 0; this.container = void 0; this.nextUrl = void 0; this.prevUrl = void 0; this.images = void 0; this.module = module; this.container = null; this.images = []; this.nextUrl = null; this.prevUrl = null; } async open() { this.renderModal(); this.dispatch('gallery:open', { modal: this.container }); await this.loadImages(); } close() { if (this.container) { this.dispatch('gallery:close', { modal: this.container }); this.container.remove(); this.container = null; } } renderModal() { this.container = document.createElement('div'); this.container.classList.add('quill-media-modal'); const uploadButtonHtml = this.module.options.uploadEndpoint ? "" : ''; const searchInputHtml = this.module.options.searchEndpoint ? "
\n \n
" : ''; this.container.innerHTML = "\n
\n
\n

" + this.module.options.messageTitleOption + "

\n \n
\n " + searchInputHtml + "\n
\n

" + this.module.options.messageLoadingOption + "

\n
\n
\n \n " + uploadButtonHtml + "\n \n
\n
\n "; document.body.appendChild(this.container); this.container.querySelector('.close-btn').addEventListener('click', () => this.close()); this.container.addEventListener('click', e => { if (e.target === this.container) this.close(); }); this.container.querySelector('.prev-btn').addEventListener('click', () => { if (this.prevUrl) this.loadImages(this.prevUrl); }); this.container.querySelector('.next-btn').addEventListener('click', () => { if (this.nextUrl) this.loadImages(this.nextUrl); }); if (this.module.options.searchEndpoint) { const searchInput = this.container.querySelector('.search-input'); let timeout = null; searchInput.addEventListener('input', e => { const target = e.target; clearTimeout(timeout); timeout = setTimeout(() => { if (target.value.trim() === '') { this.loadImages(); } else { this.searchImages(target.value); } }, 300); }); } if (this.module.options.uploadEndpoint) { const fileInput = this.container.querySelector('.upload-btn input[type="file"]'); fileInput.addEventListener('change', async event => { const file = event.target.files[0]; if (!file) return; fileInput.disabled = true; try { const strategy = this.module.options.uploadStrategy || 'form'; const response = await uploadStrategies[strategy](this.module.options.uploadEndpoint, file, this.module.options.authConfig); const res = await handleUploadResponse(response, this.module.options.jsonResponseFilePath); this.dispatch('gallery:upload-success', { response: res, file }); await this.loadImages(); } catch (e) { console.error('Error upload :', e); alert('Upload error'); } finally { fileInput.disabled = false; fileInput.value = ''; } }); } } async loadImages(url) { if (url === void 0) { url = null; } if (!this.container) { return; } const grid = this.container.querySelector('#media-grid'); if (!grid) { return; } grid.innerHTML = "

" + this.module.options.messageLoadingOption + "

"; try { var _data$links, _data$links2; const data = await this.module.list(url); this.images = data.data || []; this.nextUrl = ((_data$links = data.links) == null ? void 0 : _data$links.next) || null; this.prevUrl = ((_data$links2 = data.links) == null ? void 0 : _data$links2.prev) || null; this.renderGrid(); this.updatePaginationButtons(); } catch (e) { console.error(e); grid.innerHTML = "

" + this.module.options.messageErrorOption + "

"; } } async searchImages(query) { if (!this.container) return; const grid = this.container.querySelector('#media-grid'); if (!grid) return; grid.innerHTML = "

" + this.module.options.messageLoadingOption + "

"; try { var _data$links3, _data$links4; const data = await this.module.search(query); this.images = data.data || []; this.nextUrl = ((_data$links3 = data.links) == null ? void 0 : _data$links3.next) || null; this.prevUrl = ((_data$links4 = data.links) == null ? void 0 : _data$links4.prev) || null; this.renderGrid(); this.updatePaginationButtons(); } catch (e) { console.error(e); grid.innerHTML = "

" + this.module.options.messageErrorOption + "

"; } } renderGrid() { const grid = this.container.querySelector('#media-grid'); grid.innerHTML = ''; if (this.images.length === 0) { grid.innerHTML = "

" + this.module.options.messageNoImageOption + "

"; return; } this.images.forEach(img => { const image = document.createElement('img'); image.src = img.thumbnail || img.url; image.alt = img.title || ''; image.classList.add('quill-media-item', 'fade-in'); image.addEventListener('click', () => { this.module.insertImage(img.url); this.dispatch('gallery:image-inserted', { image: img }); this.close(); }); grid.appendChild(image); }); } updatePaginationButtons() { const prev = this.container.querySelector('.prev-btn'); const next = this.container.querySelector('.next-btn'); prev.disabled = !this.prevUrl; next.disabled = !this.nextUrl; } dispatch(name, detail) { this.module.quill.container.dispatchEvent(new CustomEvent("quill:" + name, { bubbles: true, cancelable: true, detail: detail })); } }";s:6:"digest";s:32:"4c0738ce4b15cd0831d21f3a7b415d43";s:13:"isPredigested";b:0;s:11:"logicalPath";s:54:"@ehyiah/ux-quill/dist/modules/gallery/gallery-modal.js";s:8:"isVendor";b:0;s:55:"Symfony\Component\AssetMapper\MappedAssetdependencies";a:0:{}s:59:"Symfony\Component\AssetMapper\MappedAssetfileDependencies";a:0:{}s:60:"Symfony\Component\AssetMapper\MappedAssetjavaScriptImports";a:1:{i:0;O:56:"Symfony\Component\AssetMapper\ImportMap\JavaScriptImport":5:{s:10:"importName";s:45:"/assets/@ehyiah/ux-quill/dist/upload-utils.js";s:16:"assetLogicalPath";s:37:"@ehyiah/ux-quill/dist/upload-utils.js";s:15:"assetSourcePath";s:68:"/home/assotax/www/vendor/ehyiah/ux-quill/assets/dist/upload-utils.js";s:6:"isLazy";b:0;s:24:"addImplicitlyToImportMap";b:1;}}}