jQuery(document).ready(function(c){c(".importfile").each(function(){var e=c(this),n=e.next("label"),o=n.html();e.on("change",function(e){var t="";this.files&&1<this.files.length?t=(this.getAttribute("data-multiple-caption")||"").replace("{count}",this.files.length):e.target.value&&(t=e.target.value.split("\\").pop()),t?n.find("span").html(t):n.html(o)}),e.on("focus",function(){e.addClass("has-focus")}).on("blur",function(){e.removeClass("has-focus")})}),c("#screen-meta-links").prependTo("#envira-header-temp"),c("#screen-meta").prependTo("#envira-header-temp"),c("#screen-meta-links").css("display","block"),"undefined"!=typeof Clipboard&&c(document).on("click",".envira-clipboard",function(e){new Clipboard(".envira-clipboard");e.preventDefault()}),0<c("#envira-permissions-create").length&&new Choices("#envira-permissions-create",{searchChoices:!1,searchEnabled:!1,itemSelectText:"",addItemText:"",shouldSort:!1,shouldSortItems:!1,classNames:{containerInner:"choices__inner sort_inner",containerOuter:"choices sort_inner"}}),0<c("#envira-config-image-sort").length&&new Choices("#envira-config-image-sort",{searchChoices:!1,searchEnabled:!1,itemSelectText:"",addItemText:"",shouldSort:!1,shouldSortItems:!1,classNames:{containerInner:"choices__inner sort_inner",containerOuter:"choices sort_inner"}}),0<c("#envira-config-image-sort-dir").length&&new Choices("#envira-config-image-sort-dir",{searchChoices:!1,searchEnabled:!1,itemSelectText:"",addItemText:"",classNames:{containerInner:"choices__inner sort_dir",containerOuter:"choices sort_dir"}}),c(".widgets-sortables").on("click","div.widget-top",function(e,t){var n,o,i,r=c(this).parent().attr("id"),a=(o=-1!==r.indexOf("envira-album")?(n="envira_widget_get_albums","album"):(n="envira_widget_get_galleries","gallery"),c("#"+r+" select.form-control").val());c("#"+r+" select.form-control option:selected").text();c("#"+r+" select.form-control").find("option").remove(),0<c("#"+r+" select.form-control").length&&(i=new Choices("#"+r+" select.form-control",{searchPlaceholderValue:"Search for an "+o,loadingText:"",itemSelectText:""})).ajax(function(t){fetch(ajaxurl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:"action="+n,credentials:"same-origin"}).then(function(e){e.json().then(function(e){t(e.galleries,"gallery_id","gallery_title"),void 0!==a&&i.setValueByChoice(a)})}).catch(function(e){console.log(e)})})}),c(document).on("widget-updated",function(e,t){var n,o,i,t=c(t).attr("id"),r=(o=-1!==t.indexOf("album")?(n="envira_widget_get_albums","album"):(n="envira_widget_get_galleries","gallery"),c("#"+t+" select.form-control").val());c("#"+t+" select.form-control option:selected").text();c("#"+t+" select.form-control").find("option").remove(),0<c("#"+t+" select.form-control").length&&(i=new Choices("#"+t+" select.form-control",{searchPlaceholderValue:"Search for an "+o,loadingText:"",itemSelectText:""})).ajax(function(t){fetch(ajaxurl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:"action="+n,credentials:"same-origin"}).then(function(e){e.json().then(function(e){t(e.galleries,"gallery_id","gallery_title"),void 0!==r&&i.setValueByChoice(r)})}).catch(function(e){console.log(e)})})}),c(document).on("widget-added",function(e,t){c(t).attr("id")})});