!function(a){var i={};function t(e){if(i[e])return i[e].exports;var o=i[e]={i:e,l:!1,exports:{}};return a[e].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=a,t.c=i,t.d=function(a,i,e){t.o(a,i)||Object.defineProperty(a,i,{enumerable:!0,get:e})},t.r=function(a){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},t.t=function(a,i){if(1&i&&(a=t(a)),8&i)return a;if(4&i&&"object"==typeof a&&a&&a.__esModule)return a;var e=Object.create(null);if(t.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:a}),2&i&&"string"!=typeof a)for(var o in a)t.d(e,o,function(i){return a[i]}.bind(null,o));return e},t.n=function(a){var i=a&&a.__esModule?function(){return a.default}:function(){return a};return t.d(i,"a",i),i},t.o=function(a,i){return Object.prototype.hasOwnProperty.call(a,i)},t.p="",t(t.s=5)}([function(a,i,t){t.p=window.flatsomeVars?window.flatsomeVars.assets_url:"/"},,,,,function(a,i,t){t(0),a.exports=t(6)},function(a,i){!function(a){function i(){t().length&&(a.post(flatsome_variation_images_admin.ajaxurl,{action:"flatsome_additional_variation_images_load_images_ajax",nonce:flatsome_variation_images_admin.nonce.load_images,variation_ids:t()},i=>{for(let t in i.images)if(i.images.hasOwnProperty(t)){const e='<span class="ux-additional-variation-images" data-variation-id="'.concat(t,'">\n\t\t             <h4 class="ux-additional-variation-images__title">Additional images</h4>\n\t\t             ').concat(i.images[t],'\n\t\t             <a href="#" class="ux-additional-variation-images__add">Add additional images</a>\n\t            </span>'),o=a('#variable_product_options .woocommerce_variation a.upload_image_button[rel="'.concat(t,'"]'));o.parents(".upload_image").find(".ux-additional-variation-images").length||o.after(e)}e()}),a("#variable_product_options .woocommerce_variation").on("click","a.ux-additional-variation-images__add",(function(i){i.preventDefault();const t=a(this).parents(".upload_image").find("a.upload_image_button").prop("rel"),n=a(this).parents(".upload_image").find("ul.ux-additional-variation-images__list"),r=wp.media.frames.mediaFrame=wp.media({library:{type:"image"},multiple:!0}).on("select",()=>{r.state().get("selection").map((function(a){if((a=a.toJSON()).id){const i=a.sizes.thumbnail?a.sizes.thumbnail.url:a.url,t='<li class="ux-additional-variation-images__thumbnail" data-attachment-id="'.concat(a.id,'">\n                   <img class="ux-additional-variation-images__thumbnail-img" src="').concat(i,'" alt="" width="64" height="64"/>\n                   <span class="actions"><a href="#" class="ux-additional-variation-images__delete"></a></span>\n                </li>');n.append(t)}})),wp.media.model.settings.post.id=t,e(),o(t)});r.open()})).on("click","a.ux-additional-variation-images__delete",(function(i){i.preventDefault();const t=a(this),e=t.parents(".upload_image").find("a.upload_image_button").prop("rel");t.closest(".ux-additional-variation-images__thumbnail").remove(),o(e)})))}function t(){let i=[];return a("#variable_product_options .woocommerce_variation").each((a,t)=>{i.push(jQuery(t).find(".upload_image .upload_image_button").prop("rel"))}),i}function e(){a("#variable_product_options .woocommerce_variation").each((a,i)=>{const t=jQuery(i),e=t.find("a.upload_image_button").prop("rel");t.find(".ux-additional-variation-images__list").sortable({update:function(){o(e)},opacity:.5,placeholder:"sortable-placeholder",tolerance:"pointer",cursor:"move"})})}function o(i){let t=[];const e=a('#variable_product_options .woocommerce_variation a.upload_image_button[rel="'.concat(i,'"]')).parent(".upload_image"),o=e.find("ul.ux-additional-variation-images__list li");o.length?(o.each((a,i)=>{t.push(i.dataset.attachmentId)}),e.find("input.ux-additional-variation-images-save").val(t.join(","))):e.find("input.ux-additional-variation-images-save").val(""),a("#variable_product_options").find("input").first().change(),e.parents(".woocommerce_variation").first().addClass("variation-needs-update")}a(document).ready(()=>{i()}),a("body").on("woocommerce_variations_added woocommerce_variations_loaded",()=>{i()})}(jQuery)}]);