(()=>{"use strict";var e={};function t(){const e=document.querySelectorAll(".upload_image_button");e.length>0&&e.forEach((function(e){o(e)}));const t=document.querySelectorAll(".remove_image_button");t.length>0&&t.forEach((function(e){n(e)}))}function o(e){e&&e.addEventListener("click",(function(e){e.preventDefault();const t=this.dataset.direction,o=wp.media({title:"Select Asset",button:{text:"Use This Asset"},multiple:!1});o.on("select",(function(){const n=o.state().get("selection").first().toJSON();let l=document.getElementById(`explore-character-images[${t}]`);if(l&&"image"===n.type){l.value=n.url;const e=l.closest(".explore-image-field");if(e){const t=e.querySelector("img");t&&(t.src=n.url)}}else{const t=e.target.closest(".explore-image-field");t&&(l=t.querySelector(".explore-upload-field"))}if(l){l.value=n.url;const e=l.closest(".explore-image-field");if(e){const t=e.querySelector("img");t&&(t.src=n.url)}}const i=document.getElementById("_product_video_url");i&&"video"===n.type&&(i.value=n.url);const c=document.getElementById("_product_video_url_thumbnail");c&&"image"===n.type&&(c.value=n.url)})),o.open()}))}function n(e){e&&e.addEventListener("click",(function(e){e.preventDefault();const t=this.dataset.direction;let o=document.getElementById(`explore-character-images[${t}]`);if(o);else{const t=e.target.closest(".explore-image-field");t&&(o=t.querySelector(".explore-upload-field"))}o&&(o.value="")}))}e.d=(t,o)=>{for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:o[n]})},e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),document.addEventListener("DOMContentLoaded",(function(){t()})),window.initExploreUploadButton=o,window.initExploreRemoveButton=n,window.initImageUpload=t})();