framework/extensions/package-manager/js/dist/admin.js
flarum-bot d818e83235 Bundled output for commit 257be2b9db
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-28 14:51:19 +00:00

2 lines
47 KiB
JavaScript
Executable File
Generated

(()=>{var t={151:function(t){t.exports=function(){"use strict";var t,e,a=1e3,n=6e4,s=36e5,r=864e5,o=/\[([^\]]+)]|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,i=31536e6,l=2628e6,m=/^(-|\+)?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:i,months:l,days:r,hours:s,minutes:n,seconds:a,milliseconds:1,weeks:6048e5},c=function(t){return t instanceof b},d=function(t,e,a){return new b(t,a,e.$l)},g=function(t){return e.p(t)+"s"},p=function(t){return t<0},h=function(t){return p(t)?Math.ceil(t):Math.floor(t)},f=function(t){return Math.abs(t)},x=function(t,e){return t?p(t)?{negative:!0,format:""+f(t)+e}:{negative:!1,format:""+t+e}:{negative:!1,format:""}},b=function(){function p(t,e,a){var n=this;if(this.$d={},this.$l=a,void 0===t&&(this.$ms=0,this.parseFromMilliseconds()),e)return d(t*u[g(e)],this);if("number"==typeof t)return this.$ms=t,this.parseFromMilliseconds(),this;if("object"==typeof t)return Object.keys(t).forEach((function(e){n.$d[g(e)]=t[e]})),this.calMilliseconds(),this;if("string"==typeof t){var s=t.match(m);if(s){var r=s.slice(2).map((function(t){return null!=t?Number(t):0}));return this.$d.years=r[0],this.$d.months=r[1],this.$d.weeks=r[2],this.$d.days=r[3],this.$d.hours=r[4],this.$d.minutes=r[5],this.$d.seconds=r[6],this.calMilliseconds(),this}}return this}var f=p.prototype;return f.calMilliseconds=function(){var t=this;this.$ms=Object.keys(this.$d).reduce((function(e,a){return e+(t.$d[a]||0)*u[a]}),0)},f.parseFromMilliseconds=function(){var t=this.$ms;this.$d.years=h(t/i),t%=i,this.$d.months=h(t/l),t%=l,this.$d.days=h(t/r),t%=r,this.$d.hours=h(t/s),t%=s,this.$d.minutes=h(t/n),t%=n,this.$d.seconds=h(t/a),t%=a,this.$d.milliseconds=t},f.toISOString=function(){var t=x(this.$d.years,"Y"),e=x(this.$d.months,"M"),a=+this.$d.days||0;this.$d.weeks&&(a+=7*this.$d.weeks);var n=x(a,"D"),s=x(this.$d.hours,"H"),r=x(this.$d.minutes,"M"),o=this.$d.seconds||0;this.$d.milliseconds&&(o+=this.$d.milliseconds/1e3,o=Math.round(1e3*o)/1e3);var i=x(o,"S"),l=t.negative||e.negative||n.negative||s.negative||r.negative||i.negative,m=s.format||r.format||i.format?"T":"",u=(l?"-":"")+"P"+t.format+e.format+n.format+m+s.format+r.format+i.format;return"P"===u||"-P"===u?"P0D":u},f.toJSON=function(){return this.toISOString()},f.format=function(t){var a=t||"YYYY-MM-DDTHH:mm:ss",n={Y:this.$d.years,YY:e.s(this.$d.years,2,"0"),YYYY:e.s(this.$d.years,4,"0"),M:this.$d.months,MM:e.s(this.$d.months,2,"0"),D:this.$d.days,DD:e.s(this.$d.days,2,"0"),H:this.$d.hours,HH:e.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:e.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:e.s(this.$d.seconds,2,"0"),SSS:e.s(this.$d.milliseconds,3,"0")};return a.replace(o,(function(t,e){return e||String(n[t])}))},f.as=function(t){return this.$ms/u[g(t)]},f.get=function(t){var e=this.$ms,a=g(t);return"milliseconds"===a?e%=1e3:e="weeks"===a?h(e/u[a]):this.$d[a],e||0},f.add=function(t,e,a){var n;return n=e?t*u[g(e)]:c(t)?t.$ms:d(t,this).$ms,d(this.$ms+n*(a?-1:1),this)},f.subtract=function(t,e){return this.add(t,e,!0)},f.locale=function(t){var e=this.clone();return e.$l=t,e},f.clone=function(){return d(this.$ms,this)},f.humanize=function(e){return t().add(this.$ms,"ms").locale(this.$l).fromNow(!e)},f.valueOf=function(){return this.asMilliseconds()},f.milliseconds=function(){return this.get("milliseconds")},f.asMilliseconds=function(){return this.as("milliseconds")},f.seconds=function(){return this.get("seconds")},f.asSeconds=function(){return this.as("seconds")},f.minutes=function(){return this.get("minutes")},f.asMinutes=function(){return this.as("minutes")},f.hours=function(){return this.get("hours")},f.asHours=function(){return this.as("hours")},f.days=function(){return this.get("days")},f.asDays=function(){return this.as("days")},f.weeks=function(){return this.get("weeks")},f.asWeeks=function(){return this.as("weeks")},f.months=function(){return this.get("months")},f.asMonths=function(){return this.as("months")},f.years=function(){return this.get("years")},f.asYears=function(){return this.as("years")},p}(),y=function(t,e,a){return t.add(e.years()*a,"y").add(e.months()*a,"M").add(e.days()*a,"d").add(e.hours()*a,"h").add(e.minutes()*a,"m").add(e.seconds()*a,"s").add(e.milliseconds()*a,"ms")};return function(a,n,s){t=s,e=s().$utils(),s.duration=function(t,e){var a=s.locale();return d(t,{$l:a},e)},s.isDuration=c;var r=n.prototype.add,o=n.prototype.subtract;n.prototype.add=function(t,e){return c(t)?y(this,t,1):r.bind(this)(t,e)},n.prototype.subtract=function(t,e){return c(t)?y(this,t,-1):o.bind(this)(t,e)}}}()}},e={};function a(n){var s=e[n];if(void 0!==s)return s.exports;var r=e[n]={exports:{}};return t[n].call(r.exports,r,r.exports,a),r.exports}a.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return a.d(e,{a:e}),e},a.d=(t,e)=>{for(var n in e)a.o(e,n)&&!a.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),a.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{"use strict";a.r(n),a.d(n,{extend:()=>qt});const t=flarum.reg.get("core","common/extend"),e=flarum.reg.get("core","admin/app");var s=a.n(e);const r=flarum.reg.get("core","admin/components/ExtensionPage");var o=a.n(r);const i=flarum.reg.get("core","common/components/Button");var l=a.n(i);const u=flarum.reg.get("core","admin/components/LoadingModal");var c=a.n(u);const d=flarum.reg.get("core","admin/utils/isExtensionEnabled");var g=a.n(d);const p=flarum.reg.get("core","common/Model");var h=a.n(p);const f=["B","kB","MB","GB","TB","PB","EB","ZB","YB"],x=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],b=["b","kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],y=["b","kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],v=(t,e,a)=>{let n=t;return"string"==typeof e||Array.isArray(e)?n=t.toLocaleString(e,a):!0!==e&&void 0===a||(n=t.toLocaleString(void 0,a)),n};class _ extends(h()){status(){return h().attribute("status").call(this)}operation(){return h().attribute("operation").call(this)}command(){return h().attribute("command").call(this)}package(){return h().attribute("package").call(this)}output(){return h().attribute("output").call(this)}guessedCause(){return h().attribute("guessedCause").call(this)}createdAt(){return h().attribute("createdAt",h().transformDate).call(this)}startedAt(){return h().attribute("startedAt",h().transformDate).call(this)}finishedAt(){return h().attribute("finishedAt",h().transformDate).call(this)}peakMemoryUsed(){return function(t,e){if(!Number.isFinite(t))throw new TypeError("Expected a finite number, got ".concat(typeof t,": ").concat(t));const a=(e={bits:!1,binary:!1,space:!0,...e}).bits?e.binary?y:b:e.binary?x:f,n=e.space?" ":"";if(e.signed&&0===t)return" 0".concat(n).concat(a[0]);const s=t<0,r=s?"-":e.signed?"+":"";let o;if(s&&(t=-t),void 0!==e.minimumFractionDigits&&(o={minimumFractionDigits:e.minimumFractionDigits}),void 0!==e.maximumFractionDigits&&(o={maximumFractionDigits:e.maximumFractionDigits,...o}),t<1)return r+v(t,e.locale,o)+n+a[0];const i=Math.min(Math.floor(e.binary?Math.log(t)/Math.log(1024):Math.log10(t)/3),a.length-1);return t/=(e.binary?1024:1e3)**i,o||(t=t.toPrecision(3)),r+v(Number(t),e.locale,o)+n+a[i]}(1024*h().attribute("peakMemoryUsed").call(this))}}function k(){s().modal.close(),m.route.set(s().route("extension",{id:"flarum-extension-manager"})),s().extensionManager.queue.load({},!0),setTimeout((()=>{var t;null==(t=document.getElementById("ExtensionManager-queueSection"))||t.scrollIntoView({block:"nearest"})}),200)}function N(t){return N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},N(t)}function M(t,e,a){return n=function(t,e){if("object"!=N(t)||!t)return t;var a=t[Symbol.toPrimitive];if(void 0!==a){var n=a.call(t,"string");if("object"!=N(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(e),(e="symbol"==N(n)?n:n+"")in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t;var n}flarum.reg.add("flarum-extension-manager","admin/models/Task",_),window.jumpToQueue=k,flarum.reg.add("flarum-extension-manager","admin/utils/jumpToQueue",k);class w{constructor(){M(this,"polling",null),M(this,"tasks",null),M(this,"limit",20),M(this,"offset",0),M(this,"total",0)}load(t,e){var a;return void 0===e&&(e=!1),this.tasks=null,t={page:{limit:this.limit,offset:this.offset,...null==(a=t)?void 0:a.page},...t},s().store.find("extension-manager-tasks",t||{}).then((t=>{var a;return this.tasks=t,this.total=(null==(a=t.payload.meta)?void 0:a.total)||0,m.redraw(),(null==t?void 0:t.find((t=>"pending"===t.status()||"running"===t.status())))?this.pollQueue(e):e?(s().extensionManager.control.setLoading(null),window.location.reload()):s().extensionManager.control.isLoading()&&s().extensionManager.control.setLoading(null),t}))}getItems(){return this.tasks}getTotalPages(){return Math.ceil(this.total/this.limit)}pageNumber(){return Math.ceil(this.offset/this.limit)}hasPrev(){return 0!==this.pageNumber()}hasNext(){return this.offset+this.limit<this.total}prev(){this.hasPrev()&&(this.offset-=this.limit,this.load())}next(){this.hasNext()&&(this.offset+=this.limit,this.load())}pollQueue(t){void 0===t&&(t=!1),this.polling&&clearTimeout(this.polling),this.polling=setTimeout((()=>{this.load({},t)}),6e3)}hasPending(){var t;return!(null==(t=this.tasks)||!t.find((t=>"pending"===t.status()||"running"===t.status())))}}function E(t){s().extensionManager.control.setLoading(null);const e=t.response.errors[0];if(!["composer_command_failure","extension_already_installed","extension_not_installed"].includes(e.code))throw t;switch(s().alerts.clear(),e.code){case"composer_command_failure":e.guessed_cause?(s().alerts.show({type:"error"},s().translator.trans("flarum-extension-manager.admin.exceptions.guessed_cause.".concat(e.guessed_cause))),s().modal.close()):s().alerts.show({type:"error"},s().translator.trans("flarum-extension-manager.admin.exceptions.composer_command_failure"));break;case"extension_already_installed":s().alerts.show({type:"error"},s().translator.trans("flarum-extension-manager.admin.exceptions.extension_already_installed")),s().modal.close();break;case"extension_not_installed":s().alerts.show({type:"error"},s().translator.trans("flarum-extension-manager.admin.exceptions.extension_not_installed")),s().modal.close()}}flarum.reg.add("flarum-extension-manager","admin/states/QueueState",w);const U=flarum.reg.get("core","common/utils/extractText");var S=a.n(U);class B{get lastUpdateRun(){const t=JSON.parse(s().data.settings["flarum-extension-manager.last_update_run"]);return t.limitedPackages=()=>[...t.major.limitedPackages,...t.minor.limitedPackages,...t.global.limitedPackages],t}constructor(){M(this,"loading",null),M(this,"packageUpdates",{}),M(this,"lastUpdateCheck",void 0),M(this,"extensionUpdates",void 0),M(this,"coreUpdate",null),this.lastUpdateCheck=JSON.parse(s().data.settings["flarum-extension-manager.last_update_check"]),this.extensionUpdates=this.formatExtensionUpdates(this.lastUpdateCheck),this.coreUpdate=this.formatCoreUpdate(this.lastUpdateCheck)}isLoading(t){return void 0===t&&(t=null),t&&this.loading===t||!t&&null!==this.loading}hasOperationRunning(){return this.isLoading()||s().extensionManager.queue.hasPending()}setLoading(t){this.loading=t}requirePackage(t){s().extensionManager.control.setLoading("extension-install"),s().modal.show(c()),s().request({method:"POST",url:"".concat(s().forum.attribute("apiUrl"),"/extension-manager/extensions"),body:{data:t}}).then((t=>{if(t.processing)k();else{const e=t.id;s().alerts.show({type:"success"},s().translator.trans("flarum-extension-manager.admin.extensions.successful_install",{extension:e})),window.location.href="".concat(s().forum.attribute("adminUrl"),"#/extension/").concat(e),window.location.reload()}})).catch(E).finally((()=>{s().modal.close(),m.redraw()}))}checkForUpdates(){this.setLoading("check"),s().request({method:"POST",url:"".concat(s().forum.attribute("apiUrl"),"/extension-manager/check-for-updates")}).then((t=>{t.processing?k():(this.lastUpdateCheck=t,this.extensionUpdates=this.formatExtensionUpdates(t),this.coreUpdate=this.formatCoreUpdate(t),this.setLoading(null),m.redraw())})).catch(E).finally((()=>{m.redraw()}))}updateCoreMinor(){confirm(S()(s().translator.trans("flarum-extension-manager.admin.minor_update_confirmation.content")))&&(s().modal.show(c()),this.setLoading("minor-update"),s().request({method:"POST",url:"".concat(s().forum.attribute("apiUrl"),"/extension-manager/minor-update")}).then((t=>{null!=t&&t.processing?k():(s().alerts.show({type:"success"},s().translator.trans("flarum-extension-manager.admin.update_successful")),window.location.reload())})).catch(E).finally((()=>{s().modal.close(),m.redraw()})))}updateExtension(t,e){s().modal.show(c()),this.setLoading("extension-update"),s().request({method:"PATCH",url:"".concat(s().forum.attribute("apiUrl"),"/extension-manager/extensions/").concat(t.id),body:{data:{updateMode:e}}}).then((e=>{null!=e&&e.processing?k():(s().alerts.show({type:"success"},s().translator.trans("flarum-extension-manager.admin.extensions.successful_update",{extension:t.extra["flarum-extension"].title})),window.location.reload())})).catch(E).finally((()=>{s().modal.close(),m.redraw()}))}updateGlobally(){s().modal.show(c()),this.setLoading("global-update"),s().request({method:"POST",url:"".concat(s().forum.attribute("apiUrl"),"/extension-manager/global-update")}).then((t=>{null!=t&&t.processing?k():(s().alerts.show({type:"success"},s().translator.trans("flarum-extension-manager.admin.updater.global_update_successful")),window.location.reload())})).catch(E).finally((()=>{s().modal.close(),m.redraw()}))}formatExtensionUpdates(t){var e;return this.packageUpdates={},null==t||null==(e=t.updates)||null==(e=e.installed)||e.filter((t=>{const e=t.name.replace("/","-").replace(/(flarum-ext-)|(flarum-)/,""),a=s().data.extensions[e],n=["semver-safe-update","update-possible"].includes(t["latest-status"]);return a&&n&&(this.packageUpdates[a.id]=t),a&&n})),Object.values(s().data.extensions).filter((t=>this.packageUpdates[t.id]))}formatCoreUpdate(t){var e;const a=null==t||null==(e=t.updates)||null==(e=e.installed)?void 0:e.filter((t=>"flarum/core"===t.name)).pop();return a?{package:a,extension:{id:"flarum-core",name:"flarum/core",version:s().data.settings.version,icon:{backgroundImage:"url(".concat(s().data.resources[0].attributes.baseUrl,"/assets/extensions/flarum-extension-manager/flarum.svg")},extra:{"flarum-extension":{title:S()(s().translator.trans("flarum-extension-manager.admin.updater.flarum"))}}}}:null}majorUpdate(t){let{dryRun:e}=t;s().extensionManager.control.setLoading(e?"major-update-dry-run":"major-update"),s().modal.show(c());const a=this.lastUpdateRun.major;s().request({method:"POST",url:"".concat(s().forum.attribute("apiUrl"),"/extension-manager/major-update"),body:{data:{dryRun:e}}}).then((t=>{null!=t&&t.processing?k():(s().alerts.show({type:"success"},s().translator.trans("flarum-extension-manager.admin.update_successful")),window.location.reload())})).catch(E).catch((t=>{var e;s().modal.close(),a.status="failure",a.incompatibleExtensions=null==(e=t.response)||null==(e=e.errors)||null==(e=e.pop())?void 0:e.incompatible_extensions})).finally((()=>{m.redraw()}))}}flarum.reg.add("flarum-extension-manager","admin/states/ControlSectionState",B);class q{constructor(){M(this,"queue",new w),M(this,"control",new B)}}flarum.reg.add("flarum-extension-manager","admin/states/ExtensionManagerState",q);const j=flarum.reg.get("core","common/extenders");var T=a.n(j);const $=flarum.reg.get("core","common/Component");var C=a.n($);const P=flarum.reg.get("core","common/components/LoadingIndicator");var F=a.n(P);const O=flarum.reg.get("core","common/components/Tooltip");var L=a.n(O);const A=flarum.reg.get("core","common/components/Icon");var D=a.n(A);const I=flarum.reg.get("core","common/utils/ItemList");var Y=a.n(I);const R=flarum.reg.get("core","common/components/Link");var G=a.n(R);const W=flarum.reg.get("core","common/utils/classList");var H=a.n(W);class Q extends(C()){view(t){const{className:e,type:a,...n}=this.attrs;return m("span",Object.assign({className:H()(["Label","Label--".concat(this.attrs.type),e])},n),t.children)}}flarum.reg.add("flarum-extension-manager","admin/components/Label",Q);const J=flarum.reg.get("core","common/components/Modal");var V=a.n(J);class Z extends(V()){className(){return"Modal--large QuickModal"}title(){return s().translator.trans("flarum-extension-manager.admin.sections.queue.operations.".concat(this.attrs.task.operation()))}content(){return m("div",{className:"Modal-body"},m("div",{className:"TaskOutputModal-data"},"failure"===this.attrs.task.status()&&m("div",{className:"Form-group"},m("label",null,s().translator.trans("flarum-extension-manager.admin.sections.queue.output_modal.guessed_cause")),m("div",{className:"FormControl TaskOutputModal-data-guessed-cause"},this.attrs.task.guessedCause()&&s().translator.trans("flarum-extension-manager.admin.exceptions.guessed_cause."+this.attrs.task.guessedCause())||s().translator.trans("flarum-extension-manager.admin.sections.queue.output_modal.cause_unknown"))),m("div",{className:"Form-group"},m("label",null,s().translator.trans("flarum-extension-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,s().translator.trans("flarum-extension-manager.admin.sections.queue.output_modal.output")),m("div",{className:"FormControl TaskOutputModal-data-output"},m("code",null,m("pre",null,this.attrs.task.output()))))))}}flarum.reg.add("flarum-extension-manager","admin/components/TaskOutputModal",Z);var z=a(151),K=a.n(z);function X(t,e){dayjs.extend(K());const a=dayjs(e).diff(t);return dayjs.duration(a).humanize()}flarum.reg.add("flarum-extension-manager","admin/utils/humanDuration",X);class tt extends(C()){view(){return m("nav",{className:"Pagination UserListPage-gridPagination"},m(l(),{disabled:!this.attrs.list.hasPrev()||s().extensionManager.control.isLoading(),title:s().translator.trans("core.admin.users.pagination.back_button"),onclick:()=>this.attrs.list.prev(),icon:"fas fa-chevron-left",className:"Button Button--icon UserListPage-backBtn"}),m("span",{className:"UserListPage-pageNumber"},s().translator.trans("core.admin.users.pagination.page_counter",{current:this.attrs.list.pageNumber()+1,total:this.attrs.list.getTotalPages()})),m(l(),{disabled:!this.attrs.list.hasNext()||s().extensionManager.control.isLoading(),title:s().translator.trans("core.admin.users.pagination.next_button"),onclick:()=>this.attrs.list.next(),icon:"fas fa-chevron-right",className:"Button Button--icon UserListPage-nextBtn"}))}}flarum.reg.add("flarum-extension-manager","admin/components/Pagination",tt);class et extends(C()){oninit(t){super.oninit(t),s().extensionManager.queue.load()}view(){return m("section",{id:"ExtensionManager-queueSection",className:"ExtensionPage-permissions ExtensionManager-queueSection"},m("div",{className:"ExtensionPage-permissions-header ExtensionManager-queueSection-header"},m("div",{className:"container"},m("h2",{className:"ExtensionTitle"},s().translator.trans("flarum-extension-manager.admin.sections.queue.title")),m(l(),{className:"Button Button--icon",icon:"fas fa-sync-alt",onclick:()=>s().extensionManager.queue.load(),"aria-label":s().translator.trans("flarum-extension-manager.admin.sections.queue.refresh"),disabled:s().extensionManager.control.isLoading()}))),m("div",{className:"container"},this.queueTable()))}columns(){const t=new(Y());return t.add("operation",{label:S()(s().translator.trans("flarum-extension-manager.admin.sections.queue.columns.operation")),content:t=>m("div",{className:"ExtensionManager-queueTable-operation"},m("span",{className:"ExtensionManager-queueTable-operation-icon"},this.operationIcon(t.operation())),m("span",{className:"ExtensionManager-queueTable-operation-name"},s().translator.trans("flarum-extension-manager.admin.sections.queue.operations.".concat(t.operation()))))},80),t.add("package",{label:S()(s().translator.trans("flarum-extension-manager.admin.sections.queue.columns.package")),content:t=>{var e;const a=s().data.extensions[null==(e=t.package())?void 0:e.replace(/(\/flarum-|\/flarum-ext-|\/)/g,"-")];return a?m(G(),{className:"ExtensionManager-queueTable-package",href:s().route("extension",{id:a.id})},m("div",{className:"ExtensionManager-queueTable-package-icon ExtensionIcon",style:a.icon},!!a.icon&&m(D(),{name:a.icon.name})),m("div",{className:"ExtensionManager-queueTable-package-details"},m("span",{className:"ExtensionManager-queueTable-package-title"},a.extra["flarum-extension"].title),m("span",{className:"ExtensionManager-queueTable-package-name"},t.package()))):t.package()}},75),t.add("status",{label:S()(s().translator.trans("flarum-extension-manager.admin.sections.queue.columns.status")),content:t=>m("[",null,m(Q,{className:"ExtensionManager-queueTable-status",type:{running:"neutral",failure:"error",pending:"warning",success:"success"}[t.status()]},s().translator.trans("flarum-extension-manager.admin.sections.queue.statuses.".concat(t.status()))),["pending","running"].includes(t.status())&&m(F(),{size:"small",display:"inline"}))},70),t.add("elapsedTime",{label:S()(s().translator.trans("flarum-extension-manager.admin.sections.queue.columns.elapsed_time")),content:t=>t.startedAt()&&t.finishedAt()?m(L(),{text:"".concat(dayjs(t.startedAt()).format("LL LTS")," ").concat(dayjs(t.finishedAt()).format("LL LTS"))},m("span",null,X(t.startedAt(),t.finishedAt()))):s().translator.trans("flarum-extension-manager.admin.sections.queue.task_just_started")},65),t.add("memoryUsed",{label:S()(s().translator.trans("flarum-extension-manager.admin.sections.queue.columns.peak_memory_used")),content:t=>m("span",null,t.peakMemoryUsed())},60),t.add("details",{label:S()(s().translator.trans("flarum-extension-manager.admin.sections.queue.columns.details")),content:t=>m(l(),{className:"Button Button--icon Table-controls-item",icon:"fas fa-file-alt","aria-label":s().translator.trans("flarum-extension-manager.admin.sections.queue.columns.details"),onclick:()=>s().modal.show(Z,{task:t}),disabled:["pending","running"].includes(t.status())}),className:"Table-controls"},55),t}queueTable(){const t=s().extensionManager.queue.getItems();if(!t)return m(F(),null);if(t&&!t.length)return m("h3",{className:"ExtensionPage-subHeader"},s().translator.trans("flarum-extension-manager.admin.sections.queue.none"));const e=this.columns();return m("[",null,m("table",{className:"Table ExtensionManager-queueTable"},m("thead",null,m("tr",null,e.toArray().map(((t,e)=>m("th",{key:e},t.label))))),m("tbody",null,t.map(((t,a)=>m("tr",{key:a},e.toArray().map(((e,a)=>{const{label:n,content:s,...r}=e;return m("td",Object.assign({key:a},r),s(t))}))))))),m(tt,{list:s().extensionManager.queue}))}operationIcon(t){return m(D(),{name:{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"}[t]})}}flarum.reg.add("flarum-extension-manager","admin/components/QueueSection",et);const at=flarum.reg.get("core","common/components/Alert");var nt=a.n(at);const st=flarum.reg.get("core","common/utils/Stream");var rt=a.n(st);class ot extends(C()){constructor(){super(...arguments),M(this,"packageName",void 0)}oninit(t){super.oninit(t),this.packageName=rt()("")}view(){return m("div",{className:"Form-group ExtensionManager-installer"},m("label",{htmlFor:"install-extension"},s().translator.trans("flarum-extension-manager.admin.extensions.install")),m("div",{className:"helpText"},s().translator.trans("flarum-extension-manager.admin.extensions.install_help",{extiverse:m("a",{href:"https://extiverse.com"},"extiverse.com"),semantic_link:m("a",{href:"https://devhints.io/semver"}),code:m("code",null)})),m("div",{className:"FormControl-container"},m("input",{className:"FormControl",id:"install-extension",placeholder:"vendor/package-name",bidi:this.packageName}),m(l(),{className:"Button",icon:"fas fa-download",onclick:this.onsubmit.bind(this),loading:s().extensionManager.control.isLoading("extension-install"),disabled:s().extensionManager.control.hasOperationRunning()},s().translator.trans("flarum-extension-manager.admin.extensions.proceed"))))}data(){return{package:this.packageName()}}onsubmit(){s().extensionManager.control.requirePackage(this.data())}}flarum.reg.add("flarum-extension-manager","admin/components/Installer",ot);const it=flarum.reg.get("core","common/helpers/humanTime");var lt=a.n(it);class mt extends(V()){constructor(){super(...arguments),M(this,"loading",!0),M(this,"whyNot",null)}className(){return"Modal--large WhyNotModal"}title(){return s().translator.trans("flarum-extension-manager.admin.why_not_modal.title")}oncreate(t){super.oncreate(t),this.requestWhyNot()}content(){return m("div",{className:"Modal-body"},this.loading?m(F(),null):m("pre",{className:"WhyNotModal-contents"},this.whyNot))}requestWhyNot(){s().request({method:"POST",url:"".concat(s().forum.attribute("apiUrl"),"/extension-manager/why-not"),body:{data:{package:this.attrs.package}}}).then((t=>{this.loading=!1,this.whyNot=t.data.reason,m.redraw()})).catch(E)}}flarum.reg.add("flarum-extension-manager","admin/components/WhyNotModal",mt);const ut=flarum.reg.get("core","common/components/Dropdown");var ct=a.n(ut);class dt extends(C()){view(t){var e;const{extension:a,updates:n,onClickUpdate:r,whyNotWarning:o,isCore:i,isDanger:u}=this.attrs,c=null!=(e=n["latest-minor"])?e:n["latest-major"]&&!i?n["latest-major"]:null;return m("div",{className:H()({"ExtensionManager-extension":!0,"ExtensionManager-extension--core":i,"ExtensionManager-extension--danger":u})},m("div",{className:"ExtensionManager-extension-icon ExtensionIcon",style:a.icon},a.icon?m(D(),{name:a.icon.name}):""),m("div",{className:"ExtensionManager-extension-info"},m("div",{className:"ExtensionManager-extension-name"},a.extra["flarum-extension"].title),m("div",{className:"ExtensionManager-extension-version"},m("span",{className:"ExtensionManager-extension-version-current"},this.version(n.version)),c?m(Q,{className:"ExtensionManager-extension-version-latest",type:n["latest-minor"]?"success":"warning"},this.version(c)):null)),m("div",{className:"ExtensionManager-extension-controls"},r&&"function"==typeof r?m(L(),{text:s().translator.trans("flarum-extension-manager.admin.extensions.update")},m(l(),{icon:"fas fa-arrow-alt-circle-up",className:"Button Button--icon Button--flat",onclick:r,"aria-label":s().translator.trans("flarum-extension-manager.admin.extensions.update")})):r?m(ct(),{buttonClassName:"Button Button--icon Button--flat",icon:"fas fa-arrow-alt-circle-up",label:s().translator.trans("flarum-extension-manager.admin.extensions.update")},m(l(),{icon:"fas fa-arrow-alt-circle-up",className:"Button",onclick:r.soft},s().translator.trans("flarum-extension-manager.admin.extensions.update_soft_label")),m(l(),{icon:"fas fa-arrow-alt-circle-up",className:"Button",onclick:r.hard,disabled:!n["direct-dependency"]},s().translator.trans("flarum-extension-manager.admin.extensions.update_hard_label"))):null,o?m(L(),{text:s().translator.trans("flarum-extension-manager.admin.extensions.check_why_it_failed_updating")},m(l(),{icon:"fas fa-exclamation-circle",className:"Button Button--icon Button--flat Button--danger",onclick:()=>s().modal.show(mt,{package:a.name}),"aria-label":s().translator.trans("flarum-extension-manager.admin.extensions.check_why_it_failed_updating")})):null))}version(t){return"v"===t.charAt(0)?t.substring(1):t}}flarum.reg.add("flarum-extension-manager","admin/components/ExtensionItem",dt);class gt extends(C()){constructor(){super(...arguments),M(this,"updateState",void 0)}oninit(t){super.oninit(t),this.updateState=this.attrs.updateState}view(){return m("div",{className:H()("Form-group Form-group--danger ExtensionManager-majorUpdate",{"ExtensionManager-majorUpdate--failed":"failure"===this.updateState.status,"ExtensionManager-majorUpdate--incompatibleExtensions":this.updateState.incompatibleExtensions.length})},m("img",{alt:"flarum logo",src:s().forum.attribute("baseUrl")+"/assets/extensions/flarum-extension-manager/flarum.svg"}),m("label",null,s().translator.trans("flarum-extension-manager.admin.major_updater.title",{version:this.attrs.coreUpdate["latest-major"]})),m("p",{className:"helpText"},s().translator.trans("flarum-extension-manager.admin.major_updater.description")),m("div",{className:"ExtensionManager-updaterControls"},m(L(),{text:s().translator.trans("flarum-extension-manager.admin.major_updater.dry_run_help")},m(l(),{className:"Button",icon:"fas fa-vial",onclick:this.update.bind(this,!0),disabled:s().extensionManager.control.hasOperationRunning()},s().translator.trans("flarum-extension-manager.admin.major_updater.dry_run"))),m(l(),{className:"Button Button--danger",icon:"fas fa-play",onclick:this.update.bind(this,!1),disabled:s().extensionManager.control.hasOperationRunning()},s().translator.trans("flarum-extension-manager.admin.major_updater.update"))),this.updateState.incompatibleExtensions.length?m("div",{className:"ExtensionManager-majorUpdate-incompatibleExtensions ExtensionManager-extensions-grid"},this.updateState.incompatibleExtensions.map((t=>m(dt,{extension:s().data.extensions[t.replace("flarum-","").replace("flarum-ext-","").replace("/","-")],updates:{},onClickUpdate:null,isDanger:!0})))):null,"failure"===this.updateState.status?m(nt(),{type:"error",className:"ExtensionManager-majorUpdate-failure",dismissible:!1,controls:[m(l(),{className:"Button Button--text ExtensionManager-majorUpdate-failure-details",icon:"fas fa-question-circle",onclick:()=>s().modal.show(mt,{package:"flarum/core"})},s().translator.trans("flarum-extension-manager.admin.major_updater.failure.why"))]},m("p",{className:"ExtensionManager-majorUpdate-failure-desc"},s().translator.trans("flarum-extension-manager.admin.major_updater.failure.desc"))):null)}update(t){s().extensionManager.control.majorUpdate({dryRun:t})}}flarum.reg.add("flarum-extension-manager","admin/components/MajorUpdater",gt);class pt extends(C()){view(){const t=s().extensionManager.control.coreUpdate;return[m("div",{className:"Form-group"},m("label",null,s().translator.trans("flarum-extension-manager.admin.updater.updater_title")),m("div",{className:"helpText"},s().translator.trans("flarum-extension-manager.admin.updater.updater_help")),this.lastUpdateCheckView(),m("div",{className:"ExtensionManager-updaterControls"},this.controlItems().toArray()),this.availableUpdatesView()),t&&t.package["latest-major"]?m(gt,{coreUpdate:t.package,updateState:s().extensionManager.control.lastUpdateRun.major}):null]}lastUpdateCheckView(){var t;return(null==(t=s().extensionManager.control.lastUpdateCheck)?void 0:t.checkedAt)&&m("p",{className:"ExtensionManager-lastUpdatedAt"},m("span",{className:"ExtensionManager-lastUpdatedAt-label"},s().translator.trans("flarum-extension-manager.admin.updater.last_update_checked_at")),m("span",{className:"ExtensionManager-lastUpdatedAt-value"},lt()(s().extensionManager.control.lastUpdateCheck.checkedAt)))||null}availableUpdatesView(){const t=s().extensionManager.control;if(s().extensionManager.control.isLoading("check")||s().extensionManager.control.isLoading("global-update"))return m("div",{className:"ExtensionManager-extensions"},m(F(),null));const e=t.coreUpdate&&t.coreUpdate.package["latest-minor"];return t.extensionUpdates.length||e?m("div",{className:"ExtensionManager-extensions"},m("div",{className:"ExtensionManager-extensions-grid"},e?m(dt,{extension:t.coreUpdate.extension,updates:t.coreUpdate.package,isCore:!0,onClickUpdate:()=>t.updateCoreMinor(),whyNotWarning:t.lastUpdateRun.limitedPackages().includes("flarum/core")}):null,t.extensionUpdates.map((e=>m(dt,{extension:e,updates:t.packageUpdates[e.id],onClickUpdate:{soft:()=>t.updateExtension(e,"soft"),hard:()=>t.updateExtension(e,"hard")},whyNotWarning:t.lastUpdateRun.limitedPackages().includes(e.name)}))))):m("div",{className:"ExtensionManager-extensions"},m("span",{className:"helpText"},s().translator.trans("flarum-extension-manager.admin.updater.up_to_date")))}controlItems(){const t=new(Y());return t.add("updateCheck",m(l(),{className:"Button",icon:"fas fa-sync-alt",onclick:()=>s().extensionManager.control.checkForUpdates(),loading:s().extensionManager.control.isLoading("check"),disabled:s().extensionManager.control.hasOperationRunning()},s().translator.trans("flarum-extension-manager.admin.updater.check_for_updates")),100),t.add("globalUpdate",m(l(),{className:"Button",icon:"fas fa-play",onclick:()=>s().extensionManager.control.updateGlobally(),loading:s().extensionManager.control.isLoading("global-update"),disabled:s().extensionManager.control.hasOperationRunning()},s().translator.trans("flarum-extension-manager.admin.updater.run_global_update"))),t}}flarum.reg.add("flarum-extension-manager","admin/components/Updater",pt);const ht=flarum.reg.get("core","common/components/Form");var ft=a.n(ht);class xt extends(C()){oninit(t){super.oninit(t)}view(){return m("div",{className:"ExtensionPage-permissions ExtensionManager-controlSection"},m("div",{className:"ExtensionPage-permissions-header"},m("div",{className:"container"},m("h2",{className:"ExtensionTitle"},s().translator.trans("flarum-extension-manager.admin.sections.control.title")))),m("div",{className:"container"},s().data["flarum-extension-manager.writable_dirs"]?m(ft(),null,m(ot,null),m(pt,null)):m("div",{className:"Form-group"},m(nt(),{type:"warning",dismissible:!1},s().translator.trans("flarum-extension-manager.admin.file_permissions")))))}}flarum.reg.add("flarum-extension-manager","admin/components/ControlSection",xt);const bt=flarum.reg.get("core","common/components/FormGroup");var yt=a.n(bt);class vt extends(C()){constructor(){super(...arguments),M(this,"settings",{}),M(this,"initialSettings",null),M(this,"loading",!1),M(this,"type",void 0)}oninit(t){super.oninit(t),this.submit(!0)}className(){return""}view(){return m("div",{className:H()("FormSection",this.className())},m("label",null,this.title()),this.content(),m("div",{className:"Form-group Form-controls"},this.submitButton()))}submitButton(){return[m(l(),{className:"Button Button--primary",loading:this.loading,onclick:()=>this.submit(!1),disabled:!this.isDirty()},s().translator.trans("core.admin.settings.submit_button"))]}customSettingComponents(){return yt().prototype.customFieldComponents()}setting(t){var e;return null!=(e=this.settings[t])?e:this.settings[t]=rt()()}submit(t){this.loading=!0;const e={};Object.keys(this.settings).forEach((t=>{e[t]=this.settings[t]()})),s().request({method:"POST",url:s().forum.attribute("apiUrl")+"/extension-manager/composer",body:{type:this.type,data:t?null:e}}).then((t=>{let{data:e}=t;Object.keys(e).forEach((t=>{this.settings[t]=rt()(e[t])})),this.initialSettings=Array.isArray(e)?{}:e})).finally((()=>{this.loading=!1,m.redraw()}))}isDirty(){return JSON.stringify(this.initialSettings)!==JSON.stringify(this.settings)}}flarum.reg.add("flarum-extension-manager","admin/components/ConfigureJson",vt);const _t=flarum.reg.get("core","common/components/Select");var kt=a.n(_t);class Nt extends(V()){constructor(){super(...arguments),M(this,"name",void 0),M(this,"repository",void 0)}oninit(t){super.oninit(t),this.name=rt()(this.attrs.name||""),this.repository=rt()(this.attrs.repository||{type:"composer",url:""})}className(){return"RepositoryModal Modal--small"}title(){const t=this.attrs.repository?"edit":"add";return s().translator.trans("flarum-extension-manager.admin.composer.".concat(t,"_repository_label"))}content(){const t={composer:s().translator.trans("flarum-extension-manager.admin.composer.repositories.types.composer"),vcs:s().translator.trans("flarum-extension-manager.admin.composer.repositories.types.vcs"),path:s().translator.trans("flarum-extension-manager.admin.composer.repositories.types.path")};return m("div",{className:"Modal-body"},m("div",{className:"Form-group"},m("label",null,s().translator.trans("flarum-extension-manager.admin.composer.repositories.add_modal.name_label")),m("input",{className:"FormControl",bidi:this.name})),m("div",{className:"Form-group"},m("label",null,s().translator.trans("flarum-extension-manager.admin.composer.repositories.add_modal.type_label")),m(kt(),{options:t,value:this.repository().type,onchange:t=>this.repository({...this.repository(),type:t})})),m("div",{className:"Form-group"},m("label",null,s().translator.trans("flarum-extension-manager.admin.composer.repositories.add_modal.url")),m("input",{className:"FormControl",onchange:t=>this.repository({...this.repository(),url:t.target.value}),value:this.repository().url})),m("div",{className:"Form-group"},m(l(),{className:"Button Button--primary",onclick:this.submit.bind(this)},s().translator.trans("flarum-extension-manager.admin.composer.repositories.add_modal.submit_button"))))}submit(){this.attrs.onsubmit(this.repository(),this.name()),this.hide()}}flarum.reg.add("flarum-extension-manager","admin/components/RepositoryModal",Nt);class Mt extends vt{constructor(){super(...arguments),M(this,"type","composer")}title(){return s().translator.trans("flarum-extension-manager.admin.composer.title")}className(){return"ConfigureComposer"}content(){return m("div",{className:"Form ExtensionManager-SettingsGroups-content"},this.attrs.buildSettingComponent.call(this,{setting:"minimum-stability",label:s().translator.trans("flarum-extension-manager.admin.composer.minimum_stability.label"),help:s().translator.trans("flarum-extension-manager.admin.composer.minimum_stability.help"),type:"select",options:{stable:s().translator.trans("flarum-extension-manager.admin.composer.minimum_stability.options.stable"),RC:s().translator.trans("flarum-extension-manager.admin.composer.minimum_stability.options.rc"),beta:s().translator.trans("flarum-extension-manager.admin.composer.minimum_stability.options.beta"),alpha:s().translator.trans("flarum-extension-manager.admin.composer.minimum_stability.options.alpha"),dev:s().translator.trans("flarum-extension-manager.admin.composer.minimum_stability.options.dev")}}),m("div",{className:"Form-group"},m("label",null,s().translator.trans("flarum-extension-manager.admin.composer.repositories.label")),m("div",{className:"helpText"},s().translator.trans("flarum-extension-manager.admin.composer.repositories.help")),m("div",{className:"ConfigureComposer-repositories"},Object.keys(this.setting("repositories")()||{}).map((t=>{const e=this.setting("repositories")()[t];return m("div",{className:"ButtonGroup ButtonGroup--full"},m(l(),{className:"Button",icon:{composer:"fas fa-cubes",vcs:"fas fa-code-branch",path:"fas fa-folder"}[e.type],onclick:()=>s().modal.show(Nt,{name:t,repository:e,onsubmit:(e,a)=>{const n=this.setting("repositories")();delete n[t],this.setting("repositories")(n),this.onchange(e,a)}})},t," (",e.type,")"),m(l(),{className:"Button Button--icon",icon:"fas fa-trash","aria-label":s().translator.trans("flarum-extension-manager.admin.composer.delete_repository_label"),onclick:()=>{if(confirm(S()(s().translator.trans("flarum-extension-manager.admin.composer.delete_repository_confirmation")))){const e={...this.setting("repositories")()};delete e[t],this.setting("repositories")(e)}}}))})))))}submitButton(){const t=super.submitButton();return t.push(m(l(),{className:"Button",onclick:()=>s().modal.show(Nt,{onsubmit:this.onchange.bind(this)})},s().translator.trans("flarum-extension-manager.admin.composer.add_repository_label"))),t}onchange(t,e){this.setting("repositories")({...this.setting("repositories")(),[e]:t})}}flarum.reg.add("flarum-extension-manager","admin/components/ConfigureComposer",Mt);const wt=flarum.reg.get("core","common/helpers/listItems");var Et=a.n(wt);class Ut extends(V()){constructor(){super(...arguments),M(this,"type",void 0),M(this,"host",void 0),M(this,"token",void 0)}oninit(t){super.oninit(t),this.type=rt()(this.attrs.type||"bearer"),this.host=rt()(this.attrs.host||""),this.token=rt()(this.attrs.token||"")}className(){return"AuthMethodModal Modal--small"}title(){const t=this.attrs.host?"edit":"add";return s().translator.trans("flarum-extension-manager.admin.auth_config.".concat(t,"_label"))}content(){const t={"github-oauth":s().translator.trans("flarum-extension-manager.admin.auth_config.types.github-oauth"),"gitlab-oauth":s().translator.trans("flarum-extension-manager.admin.auth_config.types.gitlab-oauth"),"gitlab-token":s().translator.trans("flarum-extension-manager.admin.auth_config.types.gitlab-token"),bearer:s().translator.trans("flarum-extension-manager.admin.auth_config.types.bearer")};return m("div",{className:"Modal-body"},m("div",{className:"Form-group"},m("label",null,s().translator.trans("flarum-extension-manager.admin.auth_config.add_modal.type_label")),m(kt(),{options:t,value:this.type(),onchange:this.type})),m("div",{className:"Form-group"},m("label",null,s().translator.trans("flarum-extension-manager.admin.auth_config.add_modal.host_label")),m("input",{className:"FormControl",bidi:this.host,placeholder:s().translator.trans("flarum-extension-manager.admin.auth_config.add_modal.host_placeholder")})),m("div",{className:"Form-group"},m("label",null,s().translator.trans("flarum-extension-manager.admin.auth_config.add_modal.token_label")),m("textarea",{className:"FormControl",oninput:t=>this.token(t.target.value),rows:"6",placeholder:this.token().startsWith("unchanged:")?S()(s().translator.trans("flarum-extension-manager.admin.auth_config.add_modal.unchanged_token_placeholder")):""},this.token().startsWith("unchanged:")?"":this.token())),m("div",{className:"Form-group"},m(l(),{className:"Button Button--primary",onclick:this.submit.bind(this)},s().translator.trans("flarum-extension-manager.admin.auth_config.add_modal.submit_button"))))}submit(){this.attrs.onsubmit(this.type(),this.host(),this.token()),this.hide()}}flarum.reg.add("flarum-extension-manager","admin/components/AuthMethodModal",Ut);class St extends vt{constructor(){super(...arguments),M(this,"type","auth")}title(){return s().translator.trans("flarum-extension-manager.admin.auth_config.title")}className(){return"ConfigureAuth"}content(){const t=Object.keys(this.settings),e=t.length&&t.every((t=>{const e=this.settings[t]();return Array.isArray(e)?e.length:Object.keys(e).length}));return m("div",{className:"ExtensionManager-SettingsGroups-content"},e?t.map((t=>{const e=this.settings[t]();return m("div",{className:"Form-group"},m("label",null,s().translator.trans("flarum-extension-manager.admin.auth_config.types.".concat(t))),m("div",{className:"ConfigureAuth-hosts"},Object.keys(e).map((a=>{const n=e[a];return m("div",{className:"ButtonGroup ButtonGroup--full"},m(l(),{className:"Button",icon:"fas fa-key",onclick:()=>s().modal.show(Ut,{type:t,host:a,token:n,onsubmit:this.onchange.bind(this,a)})},a),m(l(),{className:"Button Button--icon",icon:"fas fa-trash","aria-label":s().translator.trans("flarum-extension-manager.admin.auth_config.delete_label"),onclick:()=>{if(confirm(S()(s().translator.trans("flarum-extension-manager.admin.auth_config.delete_confirmation")))){const e={...this.setting(t)()};delete e[a],Object.keys(e).length?this.setting(t)(e):delete this.settings[t]}}}))}))))})):m("span",{className:"helpText"},s().translator.trans("flarum-extension-manager.admin.auth_config.no_auth_methods_configured")))}submitButton(){const t=super.submitButton();return t.push(m(l(),{className:"Button",loading:this.loading,onclick:()=>s().modal.show(Ut,{onsubmit:this.onchange.bind(this,null)})},s().translator.trans("flarum-extension-manager.admin.auth_config.add_label"))),t}onchange(t,e,a,n){const s={...this.setting(e)()};t&&delete s[t],s[a]=n,this.setting(e)(s)}}flarum.reg.add("flarum-extension-manager","admin/components/ConfigureAuth",St);class Bt extends(o()){content(){const t=s().registry.getSettings(this.extension.id),e=[s().translator.trans("flarum-extension-manager.admin.settings.access_warning")];return s().data.debugEnabled&&e.push(s().translator.trans("flarum-extension-manager.admin.settings.debug_mode_warning")),m("div",{className:"ExtensionPage-settings"},m("div",{className:"container"},m("div",{className:"ExtensionManager-warnings Form-group"},m(nt(),{className:"ExtensionManager-primaryWarning",type:"warning",dismissible:!1},m("ul",null,Et()(e)))),t?m("div",{className:"FormSectionGroup ExtensionManager-SettingsGroups"},m("div",{className:"FormSection"},m("label",null,s().translator.trans("flarum-extension-manager.admin.settings.title")),m("div",{className:"Form"},t.map(this.buildSettingComponent.bind(this))),m("div",{className:"Form-group Form--controls"},this.submitButton())),m(Mt,{buildSettingComponent:this.buildSettingComponent}),m(St,{buildSettingComponent:this.buildSettingComponent})):m("h3",{className:"ExtensionPage-subHeader"},s().translator.trans("core.admin.extension.no_settings"))))}sections(t){const e=super.sections(t);return e.setPriority("content",10),e.add("control",m(xt,null),8),"0"!==s().data.settings["flarum-extension-manager.queue_jobs"]&&s().data.settings["flarum-extension-manager.queue_jobs"]&&e.add("queue",m(et,null),5),e.remove("permissions"),e}onsaved(){super.onsaved(),m.redraw()}}flarum.reg.add("flarum-extension-manager","admin/components/SettingsPage",Bt);const qt=[(new(T().Admin)).setting((()=>({setting:"flarum-extension-manager.queue_jobs",label:s().translator.trans("flarum-extension-manager.admin.settings.queue_jobs"),help:m.trust(S()(s().translator.trans("flarum-extension-manager.admin.settings.queue_jobs_help",{basic_impl_link:"https://discuss.flarum.org/d/28151-database-queue-the-simplest-queue-even-for-shared-hosting",adv_impl_link:"https://discuss.flarum.org/d/21873-redis-sessions-cache-queues",php_version:"<strong>".concat(s().data.phpVersion,"</strong>"),folder_perms_link:"https://docs.flarum.org/install#folder-ownership"}))),type:"boolean",disabled:s().data["flarum-extension-manager.using_sync_queue"]}))).setting((()=>({setting:"flarum-extension-manager.task_retention_days",label:s().translator.trans("flarum-extension-manager.admin.settings.task_retention_days"),help:s().translator.trans("flarum-extension-manager.admin.settings.task_retention_days_help"),type:"number"}))).page(Bt)];s().initializers.add("flarum-extension-manager",(e=>{e.store.models["extension-manager-tasks"]=_,e.extensionManager=new q,e.data["flarum-extension-manager.using_sync_queue"]&&(e.data.settings["flarum-extension-manager.queue_jobs"]="0"),(0,t.extend)(o().prototype,"topItems",(function(t){"flarum-extension-manager"===this.extension.id||g()(this.extension.id)||t.add("remove",m(l(),{className:"Button Button--danger",icon:"fas fa-times",onclick:()=>{e.modal.show(c()),e.request({url:"".concat(e.forum.attribute("apiUrl"),"/extension-manager/extensions/").concat(this.extension.id),method:"DELETE"}).then((t=>{null!=t&&t.processing?k():(e.alerts.show({type:"success"},e.translator.trans("flarum-extension-manager.admin.extensions.successful_remove")),window.location=e.forum.attribute("adminUrl"))})).finally((()=>{e.modal.close()}))}},e.translator.trans("flarum-extension-manager.admin.extensions.remove")))}))}))})(),module.exports=n})();
//# sourceMappingURL=admin.js.map