(()=>{var a={3:function(a){a.exports=function(){"use strict";var a,t,e=1e3,n=6e4,r=36e5,s=864e5,i=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,o=31536e6,c=2592e6,l=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,u={years:o,months:c,days:s,hours:r,minutes:n,seconds:e,milliseconds:1,weeks:6048e5},m=function(a){return a instanceof v},d=function(a,t,e){return new v(a,e,t.$l)},p=function(a){return t.p(a)+"s"},g=function(a){return a<0},f=function(a){return g(a)?Math.ceil(a):Math.floor(a)},h=function(a){return Math.abs(a)},k=function(a,t){return a?g(a)?{negative:!0,format:""+h(a)+t}:{negative:!1,format:""+a+t}:{negative:!1,format:""}},v=function(){function g(a,t,e){var n=this;if(this.$d={},this.$l=e,void 0===a&&(this.$ms=0,this.parseFromMilliseconds()),t)return d(a*u[p(t)],this);if("number"==typeof a)return this.$ms=a,this.parseFromMilliseconds(),this;if("object"==typeof a)return Object.keys(a).forEach((function(t){n.$d[p(t)]=a[t]})),this.calMilliseconds(),this;if("string"==typeof a){var r=a.match(l);if(r){var s=r.slice(2).map((function(a){return null!=a?Number(a):0}));return this.$d.years=s[0],this.$d.months=s[1],this.$d.weeks=s[2],this.$d.days=s[3],this.$d.hours=s[4],this.$d.minutes=s[5],this.$d.seconds=s[6],this.calMilliseconds(),this}}return this}var h=g.prototype;return h.calMilliseconds=function(){var a=this;this.$ms=Object.keys(this.$d).reduce((function(t,e){return t+(a.$d[e]||0)*u[e]}),0)},h.parseFromMilliseconds=function(){var a=this.$ms;this.$d.years=f(a/o),a%=o,this.$d.months=f(a/c),a%=c,this.$d.days=f(a/s),a%=s,this.$d.hours=f(a/r),a%=r,this.$d.minutes=f(a/n),a%=n,this.$d.seconds=f(a/e),a%=e,this.$d.milliseconds=a},h.toISOString=function(){var a=k(this.$d.years,"Y"),t=k(this.$d.months,"M"),e=+this.$d.days||0;this.$d.weeks&&(e+=7*this.$d.weeks);var n=k(e,"D"),r=k(this.$d.hours,"H"),s=k(this.$d.minutes,"M"),i=this.$d.seconds||0;this.$d.milliseconds&&(i+=this.$d.milliseconds/1e3);var o=k(i,"S"),c=a.negative||t.negative||n.negative||r.negative||s.negative||o.negative,l=r.format||s.format||o.format?"T":"",u=(c?"-":"")+"P"+a.format+t.format+n.format+l+r.format+s.format+o.format;return"P"===u||"-P"===u?"P0D":u},h.toJSON=function(){return this.toISOString()},h.format=function(a){var e=a||"YYYY-MM-DDTHH:mm:ss",n={Y:this.$d.years,YY:t.s(this.$d.years,2,"0"),YYYY:t.s(this.$d.years,4,"0"),M:this.$d.months,MM:t.s(this.$d.months,2,"0"),D:this.$d.days,DD:t.s(this.$d.days,2,"0"),H:this.$d.hours,HH:t.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:t.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:t.s(this.$d.seconds,2,"0"),SSS:t.s(this.$d.milliseconds,3,"0")};return e.replace(i,(function(a,t){return t||String(n[a])}))},h.as=function(a){return this.$ms/u[p(a)]},h.get=function(a){var t=this.$ms,e=p(a);return"milliseconds"===e?t%=1e3:t="weeks"===e?f(t/u[e]):this.$d[e],0===t?0:t},h.add=function(a,t,e){var n;return n=t?a*u[p(t)]:m(a)?a.$ms:d(a,this).$ms,d(this.$ms+n*(e?-1:1),this)},h.subtract=function(a,t){return this.add(a,t,!0)},h.locale=function(a){var t=this.clone();return t.$l=a,t},h.clone=function(){return d(this.$ms,this)},h.humanize=function(t){return a().add(this.$ms,"ms").locale(this.$l).fromNow(!t)},h.milliseconds=function(){return this.get("milliseconds")},h.asMilliseconds=function(){return this.as("milliseconds")},h.seconds=function(){return this.get("seconds")},h.asSeconds=function(){return this.as("seconds")},h.minutes=function(){return this.get("minutes")},h.asMinutes=function(){return this.as("minutes")},h.hours=function(){return this.get("hours")},h.asHours=function(){return this.as("hours")},h.days=function(){return this.get("days")},h.asDays=function(){return this.as("days")},h.weeks=function(){return this.get("weeks")},h.asWeeks=function(){return this.as("weeks")},h.months=function(){return this.get("months")},h.asMonths=function(){return this.as("months")},h.years=function(){return this.get("years")},h.asYears=function(){return this.as("years")},g}();return function(e,n,r){a=r,t=r().$utils(),r.duration=function(a,t){var e=r.locale();return d(a,{$l:e},t)},r.isDuration=m;var s=n.prototype.add,i=n.prototype.subtract;n.prototype.add=function(a,t){return m(a)&&(a=a.asMilliseconds()),s.bind(this)(a,t)},n.prototype.subtract=function(a,t){return m(a)&&(a=a.asMilliseconds()),i.bind(this)(a,t)}}}()}},t={};function e(n){var r=t[n];if(void 0!==r)return r.exports;var s=t[n]={exports:{}};return a[n].call(s.exports,s,s.exports,e),s.exports}e.n=a=>{var t=a&&a.__esModule?()=>a.default:()=>a;return e.d(t,{a:t}),t},e.d=(a,t)=>{for(var n in t)e.o(t,n)&&!e.o(a,n)&&Object.defineProperty(a,n,{enumerable:!0,get:t[n]})},e.o=(a,t)=>Object.prototype.hasOwnProperty.call(a,t),e.r=a=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})};var n={};(()=>{"use strict";e.r(n);const a=flarum.core.compat["common/extend"],t=flarum.core.compat["admin/app"];var r=e.n(t);const s=flarum.core.compat["admin/components/ExtensionPage"];var i=e.n(s);const o=flarum.core.compat["common/components/Button"];var c=e.n(o);const l=flarum.core.compat["admin/components/LoadingModal"];var u=e.n(l);const d=flarum.core.compat["admin/utils/isExtensionEnabled"];var p=e.n(d);const g=flarum.core.compat["common/components/Alert"];var f=e.n(g);function h(a,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,t){return a.__proto__=t,a},h(a,t)}function k(a,t){a.prototype=Object.create(t.prototype),a.prototype.constructor=a,h(a,t)}function v(a,t){if(null==a)return{};var e,n,r={},s=Object.keys(a);for(n=0;n=0||(r[e]=a[e]);return r}const y=flarum.core.compat["common/Component"];var b=e.n(y);const x=flarum.core.compat["common/components/LoadingIndicator"];var _=e.n(x);const M=flarum.core.compat["common/components/Tooltip"];var w=e.n(M);const N=flarum.core.compat["common/helpers/icon"];var P=e.n(N);const U=flarum.core.compat["common/utils/ItemList"];var j=e.n(U);const $=flarum.core.compat["common/utils/extractText"];var q=e.n($);const T=flarum.core.compat["common/utils/classList"];var O=e.n(T),S=["className","type"],B=function(a){function t(){return a.apply(this,arguments)||this}return k(t,a),t.prototype.view=function(a){var t=this.attrs,e=t.className,n=(t.type,v(t,S));return m("span",Object.assign({className:O()(["Label","Label--"+this.attrs.type,e])},n),a.children)},t}(b());const L=flarum.core.compat["common/components/Modal"];var E=e.n(L),C=function(a){function t(){return a.apply(this,arguments)||this}k(t,a);var e=t.prototype;return e.className=function(){return"Modal--large QuickModal"},e.title=function(){return r().translator.trans("flarum-package-manager.admin.sections.queue.operations."+this.attrs.task.operation())},e.content=function(){return m("div",{className:"Modal-body"},m("div",{className:"TaskOutputModal-data"},m("div",{className:"Form-group"},m("label",null,r().translator.trans("flarum-package-manager.admin.sections.queue.output_modal.command")),m("div",{className:"FormControl TaskOutputModal-data-command"},m("code",null,"$ composer ",this.attrs.task.command()))),m("div",{className:"Form-group"},m("label",null,r().translator.trans("flarum-package-manager.admin.sections.queue.output_modal.output")),m("div",{className:"FormControl TaskOutputModal-data-output"},m("code",null,m("pre",null,this.attrs.task.output()))))))},t}(E()),A=e(3),F=e.n(A),D=function(a){function t(){return a.apply(this,arguments)||this}return k(t,a),t.prototype.view=function(){var a=this;return m("nav",{class:"Pagination UserListPage-gridPagination"},m(c(),{disabled:!this.attrs.list.hasPrev(),title:r().translator.trans("core.admin.users.pagination.back_button"),onclick:function(){return a.attrs.list.prev()},icon:"fas fa-chevron-left",className:"Button Button--icon UserListPage-backBtn"}),m("span",{class:"UserListPage-pageNumber"},r().translator.trans("core.admin.users.pagination.page_counter",{current:this.attrs.list.pageNumber()+1,total:this.attrs.list.getTotalPages()})),m(c(),{disabled:!this.attrs.list.hasNext(),title:r().translator.trans("core.admin.users.pagination.next_button"),onclick:function(){return a.attrs.list.next()},icon:"fas fa-chevron-right",className:"Button Button--icon UserListPage-nextBtn"}))},t}(b()),I=["label","content"],Y=function(a){function t(){return a.apply(this,arguments)||this}k(t,a);var e=t.prototype;return e.oninit=function(t){a.prototype.oninit.call(this,t),r().packageManager.queue.load()},e.view=function(){return m("section",{id:"PackageManager-queueSection",className:"ExtensionPage-permissions PackageManager-queueSection"},m("div",{className:"ExtensionPage-permissions-header PackageManager-queueSection-header"},m("div",{className:"container"},m("h2",{className:"ExtensionTitle"},r().translator.trans("flarum-package-manager.admin.sections.queue.title")),m(c(),{className:"Button Button--icon",icon:"fas fa-sync-alt",onclick:function(){return r().packageManager.queue.load()},"aria-label":r().translator.trans("flarum-package-manager.admin.sections.queue.refresh")}))),m("div",{className:"container"},this.queueTable()))},e.columns=function(){var a=this,t=new(j());return t.add("operation",{label:q()(r().translator.trans("flarum-package-manager.admin.sections.queue.columns.operation")),content:function(t){return m("div",{className:"PackageManager-queueTable-operation"},m("span",{className:"PackageManager-queueTable-operation-icon"},a.operationIcon(t.operation())),m("span",{className:"PackageManager-queueTable-operation-name"},r().translator.trans("flarum-package-manager.admin.sections.queue.operations."+t.operation())))}},80),t.add("package",{label:q()(r().translator.trans("flarum-package-manager.admin.sections.queue.columns.package")),content:function(a){var t,e=r().data.extensions[null==(t=a.package())?void 0:t.replace(/(\/flarum-|\/flarum-ext-|\/)/g,"-")];return e?m("div",{className:"PackageManager-queueTable-package"},m("div",{className:"PackageManager-queueTable-package-icon ExtensionIcon",style:e.icon},e.icon?P()(e.icon.name):""),m("div",{className:"PackageManager-queueTable-package-details"},m("span",{className:"PackageManager-queueTable-package-title"},e.extra["flarum-extension"].title),m("span",{className:"PackageManager-queueTable-package-name"},a.package()))):a.package()}},75),t.add("status",{label:q()(r().translator.trans("flarum-package-manager.admin.sections.queue.columns.status")),content:function(a){return m(B,{className:"PackageManager-queueTable-status",type:{running:"neutral",failure:"error",pending:"warning",success:"success"}[a.status()]},r().translator.trans("flarum-package-manager.admin.sections.queue.statuses."+a.status()))}},70),t.add("elapsedTime",{label:q()(r().translator.trans("flarum-package-manager.admin.sections.queue.columns.elapsed_time")),content:function(a){return a.startedAt()?m(w(),{text:dayjs(a.startedAt()).format("LL LTS")+" "+dayjs(a.finishedAt()).format("LL LTS")},m("span",null,function(a,t){dayjs.extend(F());var e=dayjs(t).diff(a);return dayjs.duration(e).humanize()}(a.startedAt(),a.finishedAt()))):r().translator.trans("flarum-package-manager.admin.sections.queue.task_just_started")}},65),t.add("memoryUsed",{label:q()(r().translator.trans("flarum-package-manager.admin.sections.queue.columns.peak_memory_used")),content:function(a){return m("span",null,a.peakMemoryUsed())}},60),t.add("details",{label:q()(r().translator.trans("flarum-package-manager.admin.sections.queue.columns.details")),content:function(a){return m(c(),{className:"Button Button--icon Table-controls-item",icon:"fas fa-file-alt","aria-label":r().translator.trans("flarum-package-manager.admin.sections.queue.columns.details"),onclick:function(){return r().modal.show(C,{task:a})}})},className:"Table-controls"},55),t},e.queueTable=function(){var a=r().packageManager.queue.getItems();if(!a)return m(_(),null);if(a&&!a.length)return m("h3",{className:"ExtensionPage-subHeader"},r().translator.trans("flarum-package-manager.admin.sections.queue.none"));var t=this.columns();return m("[",null,m("table",{className:"Table PackageManager-queueTable"},m("thead",null,m("tr",null,t.toArray().map((function(a,t){return m("th",{key:t},a.label)})))),m("tbody",null,a.map((function(a,e){return m("tr",{key:e},t.toArray().map((function(t,e){t.label;var n=t.content,r=v(t,I);return m("td",Object.assign({key:e},r),n(a))})))})))),m(D,{list:r().packageManager.queue}))},e.operationIcon=function(a){return P()({update_check:"fas fa-sync-alt",update_major:"fas fa-play",update_minor:"fas fa-play",update_global:"fas fa-play",extension_install:"fas fa-download",extension_remove:"fas fa-times",extension_update:"fas fa-arrow-alt-circle-up",why_not:"fas fa-exclamation-circle"}[a])},t}(b());const H=flarum.core.compat["common/utils/Stream"];var W=e.n(H);function R(a){var t=a.response.errors[0];if(!["composer_command_failure","extension_already_installed","extension_not_installed"].includes(t.code))throw a;switch(t.code){case"composer_command_failure":t.guessed_cause?(r().alerts.show({type:"error"},r().translator.trans("flarum-package-manager.admin.exceptions.guessed_cause."+t.guessed_cause)),r().modal.close()):r().alerts.show({type:"error"},r().translator.trans("flarum-package-manager.admin.exceptions.composer_command_failure"));break;case"extension_already_installed":r().alerts.show({type:"error"},r().translator.trans("flarum-package-manager.admin.exceptions.extension_already_installed")),r().modal.close();break;case"extension_not_installed":r().alerts.show({type:"error"},r().translator.trans("flarum-package-manager.admin.exceptions.extension_not_installed")),r().modal.close()}}function G(){r().modal.close(),m.route.set(r().route("extension",{id:"flarum-package-manager"})),r().packageManager.queue.load(),setTimeout((function(){var a;null==(a=document.getElementById("PackageManager-queueSection"))||a.scrollIntoView({block:"nearest"})}),200)}window.jumpToQueue=G;var V=function(a){function t(){for(var t,e=arguments.length,n=new Array(e),r=0;r"+t.data.phpVersion+"",folder_perms_link:"https://docs.flarum.org/install#folder-ownership"}))),default:!1,type:"boolean",disabled:t.data["flarum-package-manager.using_sync_queue"]}).registerPage(oa),(0,a.extend)(i().prototype,"topItems",(function(a){var e=this;"flarum-package-manager"===this.extension.id||p()(this.extension.id)||a.add("remove",m(c(),{className:"Button Button--danger",icon:"fas fa-times",onclick:function(){t.modal.show(u()),t.request({url:t.forum.attribute("apiUrl")+"/package-manager/extensions/"+e.extension.id,method:"DELETE"}).then((function(a){null!=a&&a.processing?G():(t.alerts.show({type:"success"},t.translator.trans("flarum-package-manager.admin.extensions.successful_remove")),window.location=t.forum.attribute("adminUrl"))})).finally((function(){t.modal.close()}))}},"Remove"))}))}))})(),module.exports=n})(); //# sourceMappingURL=admin.js.map