var e,t=t||{};e=H5P.jQuery,t.init=function(){var e=H5P.jQuery(H5PAdminIntegration.containerSelector).html(""),i=H5PAdminIntegration.libraryList;i.notCached&&e.append(H5PUtils.getRebuildCache(i.notCached)),e.append(t.createLibraryList(H5PAdminIntegration.libraryList))},t.createLibraryList=function(i){var a=H5PAdminIntegration.l10n;if(void 0===i.listData||0===i.listData.length)return e("<div>"+a.NA+"</div>");var n=H5PUtils.createTable(i.listHeaders);return n.addClass("libraries"),e.each(i.listData,(function(r,d){var l=H5PUtils.createTableRow([d.title,'<input class="h5p-admin-restricted" type="checkbox"/>',{text:d.numContent,class:"h5p-admin-center"},{text:d.numContentDependencies,class:"h5p-admin-center"},{text:d.numLibraryDependencies,class:"h5p-admin-center"},'<div class="h5p-admin-buttons-wrapper"><button class="h5p-admin-upgrade-library"></button>'+(d.detailsUrl?'<button class="h5p-admin-view-library" title="'+a.viewLibrary+'"></button>':"")+(d.deleteUrl?'<button class="h5p-admin-delete-library"></button>':"")+"</div>"]);t.addRestricted(e(".h5p-admin-restricted",l),d.restrictedUrl,d.restricted);var c=!(""===d.numContent||0===d.numContent);null===d.upgradeUrl?e(".h5p-admin-upgrade-library",l).remove():!1!==d.upgradeUrl&&c?e(".h5p-admin-upgrade-library",l).attr("title",a.upgradeLibrary).click((function(){globalThis.location.href=d.upgradeUrl})):e(".h5p-admin-upgrade-library",l).attr("disabled",!0),e(".h5p-admin-view-library",l).on("click",(function(){globalThis.location.href=d.detailsUrl}));var s=e(".h5p-admin-delete-library",l);void 0!==i.notCached||c||""!==d.numContentDependencies&&0!==d.numContentDependencies||""!==d.numLibraryDependencies&&0!==d.numLibraryDependencies?s.attr("disabled",!0):s.attr("title",a.deleteLibrary).on("click",(function(){globalThis.location.href=d.deleteUrl})),n.append(l)})),n},t.addRestricted=function(t,i,a){null===a?t.remove():(t.change((function(){t.attr("disabled",!0),e.ajax({dataType:"json",url:i,cache:!1}).fail((function(){t.attr("disabled",!1),t.attr("checked",!t.is(":checked"))})).done((function(e){i=e.url,t.attr("disabled",!1)}))})),a&&t.attr("checked",!0))},e(document).ready((function(){t.initialized||(t.initialized=!0,t.init())}));