{"version":3,"file":"app-e6266db0.47e839c4edc29ae0ca22.bundle.js","mappings":";;;;;;;;;;;;;AAAA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AAUA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAZA;AAkBA;AALA;AACA;AACA;AACA;AAdA;AAAA;AACA;AACA;;;AAAA;AAeA;AAAA;AAEA;AACA;AACA;AAAA;AACA;AACA;AACA;;;AAAA;AAEA;AAAA;AAEA;AACA;;;AAAA;AACA;AAAA;AAEA;AACA;;;AAAA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAAA;AACA;AACA;;;AAAA;AAEA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAhEA;AAAA;;;AAOA;AAEA;AAAA;;;AAGA;AACA;AAAA;;;AAGA;AAtCA;AADA;AAWA;AACA;AACA;AACA;AACA;AACA;AAfA;AAuFA;AAAA;AAvFA;AAyFA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;;;;;;AACA;AACA;AACA;AAEA;AACA;;AAAA;AACA;AACA;;AAAA;AACA;;AAAA;AACA;;AAAA;;;AAEA;AACA;;;;AAEA;AACA;;AAAA;AACA;;AAAA;;AAEA;;AAAA;;AAIA;;;;AACA;AACA;AAAA;AAGA;AACA;AAAA;AAAA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAGA;AACA;AAAA;AAAA;AACA;AACA;AAGA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA","sources":["webpack://client-app/./src/app.html","webpack://client-app/./src/app.ts"],"sourcesContent":["// Module\nvar code = \"\\r\\n\\r\\n\";\n// Exports\nexport default code;","import { PLATFORM } from \"aurelia-pal\";\r\nimport environment from './environment';\r\nimport { Router, RouteConfig, PipelineStep, RouterConfiguration, activationStrategy, Redirect, NavigationInstruction, Next, RouterEvent } from 'aurelia-router';\r\nimport { autoinject, computedFrom } from 'aurelia-framework';\r\nimport { EventAggregator } from \"aurelia-event-aggregator\";\r\nimport { CurrentUser } from \"./user\";\r\nimport { ViewPort, ViewPorts } from \"./viewPort\";\r\nimport { DialogService } from \"aurelia-dialog\";\r\nimport { TokenService } from \"./services/tokenService\";\r\nimport { HttpClient, json } from \"aurelia-fetch-client\";\r\nrequire('./style/app.BRAND.scss')\r\n\r\n@autoinject()\r\nexport class App {\r\n\r\n public router: Router;\r\n routerStack: Router[] = [];\r\n\r\n public get brand() {\r\n return environment.brand;\r\n }\r\n\r\n\r\n constructor(public currentUser: CurrentUser,\r\n public viewPort: ViewPort,\r\n private eventAgg: EventAggregator,\r\n private dialogs: DialogService,\r\n private tokenService: TokenService,\r\n private client: HttpClient) {\r\n eventAgg.subscribe(RouterEvent.Processing, () => {\r\n this.menuOpen = false;\r\n })\r\n }\r\n\r\n private menuOpen = false;\r\n @computedFrom(\"menuHidable\", \"menuOpen\")\r\n public get menuVisible() {\r\n if (this.menuHidable) {\r\n return this.menuOpen;\r\n } else {\r\n return true;\r\n }\r\n }\r\n\r\n @computedFrom(\"viewPort.deviceSize\")\r\n public get menuHidable() {\r\n return this.viewPort.deviceSize < ViewPorts.laptop;\r\n }\r\n @computedFrom(\"viewPort.deviceSize\")\r\n public get moveProfile() {\r\n return this.viewPort.deviceSize < ViewPorts.tablet;\r\n }\r\n\r\n showMenu() {\r\n this.menuOpen = true;\r\n }\r\n\r\n hideMenu() {\r\n this.menuOpen = false;\r\n }\r\n\r\n get showMyClaimsButton() {\r\n return this.currentUser.isFullyAuthenticated && this.router.currentInstruction.config.name !== 'home' && !this.currentUser.isAdmin;\r\n }\r\n\r\n goToHomePage() {\r\n // Reload page here so we're prompted if unsaved changes\r\n window.location.href = '/';\r\n }\r\n\r\n configureRouter(config: RouterConfiguration, router: Router) {\r\n this.router = router;\r\n this.routerStack.push(router);\r\n\r\n config.title = 'Claimant Portal';\r\n config.options.pushState = true;\r\n config.options.root = '/';\r\n\r\n config.addAuthorizeStep(new GetTokenStep(this.currentUser, this.tokenService, this.client, this.router));\r\n config.addAuthorizeStep(new AuthorizeStep(this.currentUser));\r\n config.addPreActivateStep(new DialogStep(this.dialogs));\r\n config.map([\r\n // { route: 'login', name: 'login', moduleId: PLATFORM.moduleName('login/index'), settings: { auth: false } },\r\n // { route: 'forgotten-password', name: 'forgotten-password', moduleId: PLATFORM.moduleName('login/index'), settings: { auth: false } },\r\n\r\n { route: '', name: 'home', moduleId: PLATFORM.moduleName('home/index', 'home'), settings: { auth: false }, nav: true, title: 'Home' },\r\n { route: 'policy', name: 'policy', moduleId: PLATFORM.moduleName('application/policy', 'policy'), settings: { auth: false }, nav: true, title: 'Policy Information' },\r\n { route: 'application-form', name: 'application-form', moduleId: PLATFORM.moduleName('application/application-form', 'application-form'), settings: { auth: false }, nav: true, title: 'Application Form' },\r\n { route: 'submitted', name: 'submitted', moduleId: PLATFORM.moduleName('application/submitted', 'submitted'), settings: { auth: false }, nav: true, title: 'Submitted' },\r\n { route: 'close-application', name: 'close-application', moduleId: PLATFORM.moduleName('application/close-application', 'close-application'), settings: { auth: false }, nav: true, title: 'Close Application' },\r\n { route: 'application-closed', name: 'application-closed', moduleId: PLATFORM.moduleName('application/application-closed', 'application-closed'), settings: { auth: false }, nav: true, title: 'Application Closed' },\r\n { route: 'files', name: 'files', moduleId: PLATFORM.moduleName('files/files', 'files'), settings: { auth: false }, nav: true, title: 'File Download' },\r\n { route: 'auth', name: 'auth', moduleId: PLATFORM.moduleName('auth/auth', 'auth'), settings: { auth: false }, nav: true, title: 'Please Provide Email Address' }\r\n ].map((c: RouteConfig) => {\r\n if (c.settings.auth) {\r\n // c.layoutViewModel = PLATFORM.moduleName('layouts/logged-in')\r\n }\r\n return c;\r\n }));\r\n }\r\n}\r\n\r\nclass GetTokenStep implements PipelineStep {\r\n constructor(private currentUser: CurrentUser, private tokenService: TokenService, private client: HttpClient, private router: Router) { }\r\n async run(instruction: NavigationInstruction, next: Next) {\r\n if (instruction.queryParams.shared) {\r\n this.tokenService.setSharedComputer(instruction.queryParams.shared === 'true');\r\n }\r\n\r\n if (instruction.queryParams.code) {\r\n let response = await this.client.post(\"api/token\", json(instruction.queryParams.code));\r\n if (response.ok) {\r\n let token = await response.text();\r\n await this.tokenService.setToken(token);\r\n await this.currentUser.ReloadUser();\r\n } else {\r\n let params = { expired: true, documentId: instruction.queryParams.documentId };\r\n this.router.navigateToRoute(\"auth\", params);\r\n }\r\n } else if (instruction.queryParams.token) {\r\n await this.tokenService.setToken(instruction.queryParams.token);\r\n await this.currentUser.ReloadUser()\r\n } else {\r\n await this.currentUser.LoadUser();\r\n }\r\n\r\n\r\n return next();\r\n }\r\n}\r\n\r\n\r\nclass DialogStep implements PipelineStep {\r\n constructor(private dialogs: DialogService) { }\r\n run(instruction: NavigationInstruction, next: Next) {\r\n // TODO add logic here to know if logged in or not\r\n\r\n if (this.dialogs.controllers.length > 0) {\r\n return next.reject();\r\n }\r\n\r\n return next();\r\n }\r\n}\r\n\r\n\r\nclass AuthorizeStep {\r\n constructor(private currentUser: CurrentUser) { }\r\n run(navigationInstruction, next) {\r\n if (navigationInstruction.getAllInstructions().some(i => i.config.settings.auth)) {\r\n\r\n // TODO add logic here to know if logged in or not\r\n var isLoggedIn = this.currentUser.isLoggedIn;\r\n\r\n if (!isLoggedIn) {\r\n return next.cancel(new Redirect('login'));\r\n }\r\n }\r\n\r\n return next();\r\n }\r\n}\r\n\r\n"],"names":[],"sourceRoot":""}