',showToast(e.copied,2500),setTimeout((()=>{t.innerHTML=n}),1500)}function R(){u&&u.classList.remove("hide")}function O(){u&&u.classList.add("hide")}function D(e){if(!E||!f)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left,r=e.clientY-n.top;(function(e,t,n){if(!h)return;const o=120,r=120;let a=e-o/2,i=t-r/2;an.right&&(a=n.right-o),i+r>n.bottom&&(i=n.bottom-r),h.style.left=a-n.left+"px",h.style.top=i-n.top+"px"})(e.clientX,e.clientY,n),function(e,n,o){if(!h||!m||!f)return;const r=f.naturalWidth/o.width,a=f.naturalHeight/o.height,i=Math.floor(e*r),l=Math.floor(n*a),c=3,d=-i*c+60,s=-l*c+60;h.style.backgroundImage=`url(${t.src})`,h.style.backgroundPosition=`${d}px ${s}px`,h.style.backgroundSize=`${f.naturalWidth*c}px ${f.naturalHeight*c}px`;try{const e=v.getImageData(i,l,1,1).data,t=e[0],n=e[1],o=e[2];m.style.backgroundColor=`rgb(${t}, ${n}, ${o})`}catch(e){console.error("Unable to get pixel color:",e)}}(o,r,n)}function U(){E&&h&&(h.style.display="block")}function S(){h&&(h.style.display="none")}n&&n.addEventListener("change",w),r&&o&&(r.addEventListener("click",I),o.addEventListener("keypress",(e=>{"Enter"===e.key&&I()}))),a&&a.addEventListener("click",(()=>{navigator.clipboard&&navigator.clipboard.read?navigator.clipboard.read().then((e=>{for(const t of e)if(t.types.includes("image/png")||t.types.includes("image/jpeg")||t.types.includes("image/gif")){t.getType("image/png").then((e=>{x(e)}));break}})).catch((t=>{showToast(e.clipboardReadError,2500),console.error("Failed to read clipboard:",t)})):showToast(e.browserNotSupportClipboard,2500)})),document.addEventListener("paste",(e=>{const t=e.clipboardData.items;for(const e of t)if(0===e.type.indexOf("image")){x(e.getAsFile());break}})),d&&i&&d.addEventListener("click",(()=>T(i.textContent,d))),s&&l&&s.addEventListener("click",(()=>T(l.textContent,s))),t&&(t.addEventListener("click",C),t.addEventListener("mousemove",D),t.addEventListener("mouseenter",U),t.addEventListener("mouseleave",S)),e.previewImageUrl&&function(e){const t=new Image;t.onload=()=>{f=t,b.width=t.naturalWidth,b.height=t.naturalHeight,v.drawImage(t,0,0),E=!0,M(t)},t.onerror=()=>{console.error("Default image loading failed")},t.crossOrigin="Anonymous",t.src=e}(e.previewImageUrl),k(y.r,y.g,y.b)}))