import Express from"../express.mjs";import sessions from"../../sessions.mjs";import*as util from"../../../common/utils/helpers.mjs";import{Module}from"../../packages/_module.mjs";import View from"./view.mjs";export default class AuthView extends View{route="/auth";socket="getAuthData";_template="auth";_methods=["get","post"];async handleGet(e,s){try{this.constructor.assertDocumentDestination(e)}catch(e){return s.status(401).send(e.message)}if(config.license.needsSignature)return s.redirect(`${e.baseUrl}/license`);if(global.game.world)return s.redirect(`${e.baseUrl}/join`);const t=View._getStaticContent({setup:!0}),o={bodyClass:`auth flexcol theme-${config.options.cssTheme}`,messages:sessions.getMessages(e,{clear:!1}),layout:"setup",scripts:t.scripts,styles:t.styles};s.render(this._template,o)}async handlePost(e,s){const{game:t}=global,o=sessions.authenticateAdmin(e,s),a=!t.world&&o.success;return s.redirect(e.baseUrl+util.getRoute(a?"setup":"auth"))}async handleSocket(e,s){return s({release:global.release,worlds:[],systems:[],modules:Module.getPackages({coreTranslation:!0}).map((e=>e.vend())),options:{language:global.config.options.language}})}}