(()=>{"use strict";const e="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?Promise.resolve():new Promise((e=>"complete"===document.readyState||"interactive"===document.readyState?e():document.addEventListener("DOMContentLoaded",(()=>e())))),t=[];browser.runtime.onMessage.addListener(((e,n)=>{for(const a of t){const t=a(e,n);if(void 0!==t)return t}}));const{promise:n,resolve:a}=Promise.withResolvers();var o;o=t=>{if("getCreatedImage"===t.type)return(async t=>{await e;const n=document.getElementById("editor-download-btn"),a=document.createElement("div");a.textContent=t,a.style.fontWeight="bold",a.className="btn btn-outline-dark",a.onclick=()=>document.querySelector('.btn[data-type="svg"]').dispatchEvent(new Event("click"));const o=document.createElement("img");o.style.width="32px",o.style.margin="-6px 6px -6px -12px",o.src=browser.runtime.getURL("128.png"),a.insertAdjacentElement("afterbegin",o),n.insertAdjacentElement("afterbegin",a)})(t.downloadText),n},t.push(o),window.addEventListener("message",(async e=>{if("image.ready"===e.data.n){const{name:t,type:n,url:o,dataurl:r}=e.data.data[0];if("image/svg+xml"!==n)return;if(r)a(r);else{const e=await(await fetch(o)).blob();a(await(e=>(e=>new Promise(((t,n)=>{const a=new FileReader;a.onload=e=>t(a.result),a.onerror=a.onabort=n,a.readAsDataURL(e)})))(e))(e))}}}))})();