!function(o){const t=function(){o(document).on("change",'[name="zip-urls"]',this.handleDownloadCheckbox),o(document).on("init.dt",".posts-data-table",this.addButtonToTable),o(document).on("click",".dlp-multiple-download-btn",this.handleDownloadButton)};t.downloadUrls={},t.downloadIds={},t.prototype.addButtonToTable=function(d,l){const a=o(l.nTable).data("config");if(!1===a.multiDownloadButton)return;const n=t.getButtonContainerClass(a.multiDownloadPosition);o(this).siblings(n).append(`<div class="dlp-multi-download-wrap">\n\t\t\t\t<button class="dlp-multiple-download-btn" disabled>${a.multiDownloadText}</button>\n\t\t\t</div>`)},t.prototype.handleDownloadCheckbox=function(d){const l=o(this).parents(".posts-data-table").first(),a=o(this).parents(".posts-table-wrapper").first().find(".dlp-multiple-download-btn"),n=l.prop("id");t.downloadUrls.hasOwnProperty(n)||(t.downloadUrls[n]=[]),t.downloadIds.hasOwnProperty(n)||(t.downloadIds[n]=[]),d.target.checked?(t.downloadUrls[n].push(d.target.dataset.downloadUrl),t.downloadIds[n].push(d.target.dataset.downloadId)):(t.downloadUrls[n]=t.downloadUrls[n].filter((o=>o!==d.target.dataset.downloadUrl)),t.downloadIds[n]=t.downloadIds[n].filter((o=>o!==d.target.dataset.downloadId))),0===t.downloadUrls[n].length?a.prop("disabled",!0):a.prop("disabled",!1)},t.prototype.handleDownloadButton=function(d){const l=o(this),a=l.parents(".posts-table-wrapper").first().children(".posts-data-table").first().prop("id");o(".dlp-multiple-download-error").remove(),l.block({message:null,overlayCSS:{background:"#fff",opacity:.7}}),getZipFile(t.downloadUrls[a],"downloads.zip").then((d=>{l.unblock();const n=t.downloadIds[a];console.log(n),o(document).trigger("dlp_multi_download",{downloadIds:n})})).catch((o=>{l.parents(".posts-table-controls").first().append(`<div class="dlp-multiple-download-error"><p>${dlp_multi_download_params.zip_failed_error}</p></div>`),l.unblock()}))},t.getButtonContainerClass=function(o){let t;switch(["above","below","both"].includes(o)||(o="above"),o){case"above":t=".posts-table-above";break;case"below":t=".posts-table-below";break;case"both":t=".posts-table-controls"}return t},new t}(jQuery,window);