WP_Optimize_Images_View=function(e){function t(e,t,i){var a,o,n,c=e,_=!1;if(t&&e)for(a=x(T).index(x("#"+e)),o=x(T).index(x("#"+t)),-1==a&&(a=o),-1==o&&(o=a),a').text(j.no_images_found_message)),x(".wpo-images-view-empty",S).show()):x(".wpo-images-view-empty",S).hide(),x.each(j.hide_when_empty,function(t,s){e>0?s.show():s.hide()})}}function a(){p()&&(i(),s(0==r().length))}function o(){S.scrollTop()+S.height()+100>S[0].scrollHeight&&"function"==typeof j.load_next_page_callback&&j.load_next_page_callback()}function n(e,t,s,i,a,o){var n,c="image_"+(65536*(1+Math.random())|0).toString(16).substring(1),_="";if(j.row_action_buttons)for(n in j.row_action_buttons)j.row_action_buttons.hasOwnProperty(n)&&(_+=['"].join(""));N.hasOwnProperty(e)||(N[e]=0),N[e]++,S.append(['\t\t\t
\t\t\t\t
',j.view_image_btn_text,"",'
\t\t\t\t\t\t\t\t\t
\t\t\t\t
\t\t\t\t
\t\t\t\t
',_,'
\t\t\t\t
\t\t\t
'].join("")),x("img:not(.error-event-attached)",S).each(function(){x(this).on("error",function(){x(this).attr("src","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMCAyMCI+PHJlY3QgeD0iMCIgZmlsbD0ibm9uZSIgd2lkdGg9IjIwIiBoZWlnaHQ9IjIwIi8+PGc+PHBhdGggZmlsbD0iI0FBQUFBQSIgZD0iTTIuMjUgMWgxNS41Yy42OSAwIDEuMjUuNTYgMS4yNSAxLjI1djE1LjVjMCAuNjktLjU2IDEuMjUtMS4yNSAxLjI1SDIuMjVDMS41NiAxOSAxIDE4LjQ0IDEgMTcuNzVWMi4yNUMxIDEuNTYgMS41NiAxIDIuMjUgMXpNMTcgMTdWM0gzdjE0aDE0ek0xMCA2YzAtMS4xLS45LTItMi0ycy0yIC45LTIgMiAuOSAyIDIgMiAyLS45IDItMnptMyA1czAtNiAzLTZ2MTBjMCAuNTUtLjQ1IDEtMSAxSDVjLS41NSAwLTEtLjQ1LTEtMVY4YzIgMCAzIDQgMyA0czEtMyAzLTMgMyAyIDMgMnoiLz48L2c+PC9zdmc+")}).addClass("error-event-attached")})}function c(e){x(L,S).hide(),x([".",j.image_container_blog_class_prefix,e].join(""),S).show(),a()}function _(e){return N.hasOwnProperty(e)?N[e]:0}function l(e){return x([".",j.image_container_blog_class_prefix,e].join(""),S).length}function d(e){e!==D&&(D=e,e===C.GRID&&S.removeClass(j.list_mode_class),e===C.LIST&&S.addClass(j.list_mode_class))}function r(){var e=[];return 0==x('input[type="checkbox"]',S).length?e:(x([".",j.image_container_class,":visible input:checked"].join(""),S).each(function(){e.push(x(this).val())}),e)}function u(){var e=[".",j.image_container_class].join("");x([e,":visible input:checked"].join(""),S).each(function(){x(this).closest(e).remove()})}function g(){S.show(),x(j.related_elements).each(function(){x(this).show()}),a(),o()}function h(){S.hide(),x(j.related_elements).each(function(){x(this).hide()})}function p(){return S.is(":visible")}function m(){w(wpoptimize.loading_data,"",j.loader_additional_html)}function w(e,t,s){t=t?t:"",s=s?s:"",S.css({"min-height":"220px"}),S.append(['"].join("")),A()}function f(){S.css("min-height","initial"),x(".wpo_shade",S).remove()}function A(){x(".wpo_shade",S).css("top",S.scrollTop()+"px")}function b(e){x(".wpo-shade-progress-message",S).html(e)}function v(){x(".wpo_unused_image__input").each(function(){x(this).prop("checked")||(x(this).closest(".wpo_unused_image").addClass("selected"),x(this).prop("checked",!0),z=null,s(0==r().length))})}function M(){x(".wpo_unused_image__input").each(function(){x(this).prop("checked")&&(x(this).closest(".wpo_unused_image").removeClass("selected"),x(this).prop("checked",!1),z=null,s(0==r().length))})}function y(){x([".",j.image_container_class].join(""),S).remove(),N={},s(!0),"function"==typeof j.onclear&&j.onclear()}function I(){y(),o()}var x=jQuery,k={container:"",image_container_class:"wpo_unused_image",image_container_custom_classes:"wpo_unused_image_row",image_container_blog_class_prefix:"wpo_unused_image_site_",view_image_btn_link_class:"wpo_unused_image_view_link",view_image_btn_text:wpoptimize.view_image_link_text,row_selector:".wpo_unused_image_row",row_id_class:"wpo_unused_images_row_id",row_thumb_class:"wpo_unused_images_row_thumb",row_file_class:"wpo_unused_images_row_file",row_action_class:"wpo_unused_images_row_action",row_action_buttons:[],label_class:"wpo_unused_image_thumb_label",loader_additional_html:"",action_btn_text:"Remove",action_btn_class:"button button-primary wpo_unused_images_remove_single",checkbox_class:"wpo_unused_image__input",list_mode_class:"wpo_unused_image_list_view",no_images_found_message:"No images found",related_elements:[],action_buttons:[],hide_when_empty:[],load_next_page_callback:null,onclear:null},j=jQuery.extend({},k,e),C={GRID:"grid",LIST:"list"},D=C.GRID,S=j.container,L="."+j.image_container_class,T="."+j.checkbox_class,z="",N={};S.on("scroll mousewheel",function(){o(),A()});var Q=!1;return S.on("mousedown",j.row_selector,function(e){Q=e.shiftKey||e.ctrlKey}),S.on("mouseup",j.row_selector,function(e){Q=e.shiftKey||e.ctrlKey}),S.on("click","."+j.image_container_class,function(e){var i=x(this).find("."+j.checkbox_class),a=i.attr("id");!0===i.prop("checked")?x(this).addClass("selected"):x(this).removeClass("selected"),Q&&(!0===i.prop("checked")?(x(this).removeClass("selected"),i.prop("checked",!1)):(x(this).addClass("selected"),i.prop("checked",!0)),1<=r().length&&!0===x("#"+z).prop("checked")&&t(z,a,!0===i.prop("checked"))),z=a,s(0==r().length)}),{show:g,hide:h,clear:y,reload:I,show_loader:m,show_custom_loader:w,hide_loader:f,loader_message:b,append_image:n,get_selected_images:r,remove_selected_images:u,get_images_count:_,get_visible_images_count:l,load_next_page_if_need:o,filter_by_site:c,switch_view_mode:d,select_all:v,select_none:M,is_visible:p,update_view:a}};