(()=>{var a;(a=jQuery)(document).ready((function(){let t=a(".document-library-table");const e=a("#wpadminbar"),r=["doc_categories"],i=data_table_params.language||{};i.processing||(i.processing='<div class="dots-loader"><div class="dot"></div><div class="dot"></div><div class="dot"></div></div>'),t.each((function(){let t=a(this);this.id=t.attr("id");let l=document_library_params.columns||[];"object"!=typeof l||Array.isArray(l)||(l=Object.values(l));let o=[];l.forEach((a=>{o.push({className:"col-"+a.trimStart(),data:a.trimStart()})}));const s=document_library_params.args||document_library_params.args,n=s.sort_by||"title",d=s.sort_order||"asc";let c=o.findIndex((a=>a.data===n)),m={responsive:!0,processing:!0,serverSide:document_library_params.lazy_load,language:i,initComplete:function(a,t){-1!==c&&this.api().order([c,d]).draw()}};document_library_params.lazy_load&&(m.ajax={url:document_library_params.ajax_url,type:"POST",data:{table_id:this.id,action:document_library_params.ajax_action,category:a(".category-search-"+this.id.replace("document-library-","")).val(),args:document_library_params.args,_ajax_nonce:document_library_params.ajax_nonce}}),m.columns=o;let u=t.DataTable(m);t.on("page.dt",(function(){if(!1!==a(this).data("scroll-offset")){let t=a(this).parent().offset().top-a(this).data("scroll-offset");if(e.length){t-=e.outerHeight()||32}a("html,body").animate({scrollTop:t},300)}})),t.on("processing.dt",(function(a,e,r){r?t.find("tbody").addClass("loading"):t.find("tbody").removeClass("loading")})),u.on("preXhr.dt",(function(t,e,r){r.category=a(".category-search-"+this.id.replace("document-library-","")).val()})),t.data("click-filter")&&t.on("click","a",(function(){if(a(this).hasClass("dlw-lightbox"))return;let t,e=a(this);if(u.cell(e.closest("td").get(0)).index()&&(t=u.cell(e.closest("td").get(0)).index().column),e.closest("td").hasClass("child")){let r=e.closest("li").attr("class").split(" ")[0];t=u.cell(a("td."+r)).index().column}let i=u.column(t).header(),l=a(i).data("name");return-1===r.indexOf(l)||(document_library_params.lazy_load?(a(".category-search-"+m.ajax.data.table_id.replace("document-library-","")).val(e.text()),u.draw()):u.search(e.text()).draw(),!1)}))})),a(document).on("click",".document-library-table a.dlw-lightbox",(function(t){t.preventDefault(),t.stopPropagation();const e=a(".pswp")[0],r=a(this).find("img");if(r.length<1)return;const i=[{src:r.attr("data-large_image"),w:r.attr("data-large_image_width"),h:r.attr("data-large_image_height"),title:r.attr("data-caption")&&r.attr("data-caption").length?r.attr("data-caption"):r.attr("title")}];return new PhotoSwipe(e,PhotoSwipeUI_Default,i,{index:0,shareEl:!1,closeOnScroll:!1,history:!1,hideAnimationDuration:0,showAnimationDuration:0}).init(),!1}))}))})();