Blame view

api/public/js/chunk-ad9746d8.9562ee9e.js.map 26.8 KB
fa297f23d   Chris Bellas   Added config fetc...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
  {"version":3,"sources":["webpack:///./src/pages/login.vue?716b","webpack:///./node_modules/@babel/runtime/helpers/esm/typeof.js","webpack:///./node_modules/@babel/runtime/helpers/esm/classCallCheck.js","webpack:///./node_modules/@babel/runtime/helpers/esm/createClass.js","webpack:///./src/utils/functions.js","webpack:///./src/utils/form.js","webpack:///src/pages/login.vue","webpack:///./src/pages/login.vue?c5a4","webpack:///./src/pages/login.vue?f516","webpack:///./src/pages/login.vue?296c"],"names":["render","_vm","this","_h","$createElement","_c","_self","staticClass","attrs","on","$event","preventDefault","login","_v","class","form","invalid","feedback","state","model","value","callback","$$v","$set","expression","domProps","_s","busy","_e","staticRenderFns","_typeof","obj","Symbol","iterator","constructor","prototype","_classCallCheck","instance","Constructor","TypeError","_defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","key","_createClass","protoProps","staticProps","deepCopy","copy","Array","isArray","keys","forEach","arrayWrap","Errors","errors","field","messages","set","hasOwnProperty","fields","some","has","getAll","message","get","push","values","reduce","a","b","concat","Form","data","successful","originalData","assign","filter","ignore","includes","clear","url","config","submit","method","startProcessing","params","Promise","resolve","reject","axios","request","route","then","response","finishProcessing","catch","error","extractErrors","errorMessage","name","parameters","routes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O,IAAIsC,GAClB,OAAO1G,KAAK6D,OAAOU,IAAImC,K,4BAIpBA,GACL,QAAI1G,KAAK6D,OAAOoD,QAASjH,KAAK6D,OAAOO,IAAIsC,KAGlC,O,8BAGAA,GACP,IAAMQ,EAAMlH,KAAKgB,MAAM0F,GACvB,OAAY,OAARQ,M,KAKRpC,EAAK8B,OAAS,GACd9B,EAAK2B,aAAe,0CACpB3B,EAAKM,OAAS,CAAC,OAAQ,aAAc,SAAU,gBAEhCN,QC9Uf,GACE4B,KAAM,QACNS,OAAQ,SACRC,WAAY,QACZrC,KAAM,WAAR,OACMlE,KAAM,IAAI,EAAhB,CACQ,MAAR,GACQ,SAAR,OAIEwG,QAAS,CACP,MADJ,WACA,yLAKA,sBALA,OAKA,EALA,OAMA,SANA,4FAYA,oCACA,cACA,sBAdA,UAkBA,oCAlBA,QAqBA,yCArBA,8DCnE+U,I,wBCQ3UC,EAAY,eACd,EACAxH,EACA6B,GACA,EACA,KACA,WACA,MAIa,aAAA2F,E,2CCnBf,yBAAkiB,EAAG","file":"js/chunk-ad9746d8.9562ee9e.js","sourcesContent":["var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('b-container',[_c('b-col',{staticClass:\"mx-auto\",attrs:{\"sm\":\"8\",\"md\":\"6\",\"lg\":\"4\"}},[_c('b-card',{staticClass:\"login-card\"},[_c('form',{on:{\"submit\":function($event){$event.preventDefault();return _vm.login($event)}}},[_c('h1',{staticClass:\"title text-muted pb-3\"},[_vm._v(\" KEA \")]),_c('b-form-group',[_c('b-input-group',{staticClass:\"input-group-seamless no-border\",class:{ 'is-invalid': _vm.form.invalid('email') }},[_c('b-input-group-prepend',[_c('span',{staticClass:\"input-group-text\"},[_c('fa',{class:{ 'text-danger': _vm.form.feedback('email') },attrs:{\"icon\":\"envelope\"}})],1)]),_c('b-form-input',{attrs:{\"type\":\"email\",\"name\":\"email\",\"required\":\"\",\"state\":_vm.form.state('email'),\"placeholder\":\"Email\"},model:{value:(_vm.form.email),callback:function ($$v) {_vm.$set(_vm.form, \"email\", $$v)},expression:\"form.email\"}})],1),_c('b-form-invalid-feedback',{attrs:{\"state\":_vm.form.state('email')}},[_c('div',{domProps:{\"innerHTML\":_vm._s(_vm.form.feedback('email'))}})])],1),_c('b-form-group',[_c('b-input-group',{staticClass:\"input-group-seamless no-border\",class:{ 'is-invalid': _vm.form.invalid('password') }},[_c('b-input-group-prepend',[_c('span',{staticClass:\"input-group-text\"},[_c('fa',{class:{ 'text-danger': _vm.form.feedback('password') },attrs:{\"icon\":\"lock\"}})],1)]),_c('b-form-input',{attrs:{\"type\":\"password\",\"name\":\"password\",\"required\":\"\",\"state\":_vm.form.state('password'),\"placeholder\":\"Password\"},model:{value:(_vm.form.password),callback:function ($$v) {_vm.$set(_vm.form, \"password\", $$v)},expression:\"form.password\"}})],1)],1),_c('b-button',{staticClass:\"w-100\",attrs:{\"type\":\"submit\",\"block\":\"\",\"variant\":\"primary\",\"disabled\":_vm.form.busy}},[(_vm.form.busy)?_c('b-spinner',{staticClass:\"spinner-center\",attrs:{\"small\":\"\"}}):_vm._e(),_vm._v(\" Login \")],1)],1)])],1)],1)}
  var staticRenderFns = []
  
  export { render, staticRenderFns }","export default function _typeof(obj) {
    \"@babel/helpers - typeof\";
  
    if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {
      _typeof = function _typeof(obj) {
        return typeof obj;
      };
    } else {
      _typeof = function _typeof(obj) {
        return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;
      };
    }
  
    return _typeof(obj);
  }","export default function _classCallCheck(instance, Constructor) {
    if (!(instance instanceof Constructor)) {
      throw new TypeError(\"Cannot call a class as a function\");
    }
  }","function _defineProperties(target, props) {
    for (var i = 0; i < props.length; i++) {
      var descriptor = props[i];
      descriptor.enumerable = descriptor.enumerable || false;
      descriptor.configurable = true;
      if (\"value\" in descriptor) descriptor.writable = true;
      Object.defineProperty(target, descriptor.key, descriptor);
    }
  }
  
  export default function _createClass(Constructor, protoProps, staticProps) {
    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
    if (staticProps) _defineProperties(Constructor, staticProps);
    return Constructor;
  }","/**
   * Get cookie from request.
   *
   * @param  {Object} req
   * @param  {String} key
   * @return {String|undefined}
   */
  export function cookieFromRequest (req, key) {
    if (!req.headers.cookie) {
      return
    }
  
    const cookie = req.headers.cookie.split(';').find(
      c => c.trim().startsWith(`${key}=`)
    )
  
    if (cookie) {
      return cookie.split('=')[1]
    }
  }
  
  /**
   * https://router.vuejs.org/en/advanced/scroll-behavior.html
   */
  export function scrollBehavior (to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    }
  
    let position = {}
  
    if (to.matched.length < 2) {
      position = { x: 0, y: 0 }
    } else if (to.matched.some(r => r.components.default.options.scrollToTop)) {
      position = { x: 0, y: 0 }
    } if (to.hash) {
      position = { selector: to.hash }
    }
  
    return position
  }
  
  /**
   * Deep copy the given object.
   *
   * @param  {Object} obj
   * @return {Object}
   */
  export function deepCopy (obj) {
    if (obj === null || typeof obj !== 'object') {
      return obj
    }
  
    const copy = Array.isArray(obj) ? [] : {}
  
    Object.keys(obj).forEach((key) => {
      copy[key] = deepCopy(obj[key])
    })
  
    return copy
  }
  
  /**
   * If the given value is not an array, wrap it in one.
   *
   * @param  {Any} value
   * @return {Array}
   */
  export function arrayWrap (value) {
    return Array.isArray(value) ? value : [value]
  }
  
  export function passwordChecker () {
    return {
      strong: new RegExp('^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*])(?=.{8,})'),
      medium: new RegExp('^(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,})')
    }
  }
  
  export function formatDateISO8601 (date) {
    if (Object.prototype.toString.call(date) === '[object Date]') {
      return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()
    }
    return null
  }
  
  export function formatDate (date) {
    if (Object.prototype.toString.call(date) === '[object Date]') {
      return date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear()
    }
    return null
  }
  
  export function localeArray2Assoc (arr, keyArg = 'value', valueArg = 'text') {
    const ret = []
    if (arr) {
      for (const key in arr) {
        ret.push({
          [keyArg]: key,
          [valueArg]: arr[key]
        })
      }
    }
    return ret
  }
  
  export function debounce (fn, time) {
    let timeout
  
    return function () {
      const functionCall = () => fn.apply(this, arguments)
  
      clearTimeout(timeout)
      timeout = setTimeout(functionCall, time)
    }
  }
  
  export function getAge (birthDate) {
    const ageDifMs = Date.now() - new Date(birthDate).getTime()
    const ageDate = new Date(ageDifMs) // milliseconds from epoch
    return Math.abs(ageDate.getUTCFullYear() - 1970)
  }
  ","import axios from 'axios'
  import { deepCopy, arrayWrap } from './functions'
  
  class Errors {
    /**
     * Create a new error bag instance.
     */
    constructor () {
      this.errors = {}
    }
  
    /**
     * Set the errors object or field error messages.
     *
     * @param {Object|String} field
     * @param {Array|String|undefined} messages
     */
    set (field, messages) {
      if (typeof field === 'object') {
        this.errors = field
      } else {
        this.set({ ...this.errors, [field]: arrayWrap(messages) })
      }
    }
  
    /**
     * Get all the errors.
     *
     * @return {Object}
     */
    all () {
      return this.errors
    }
  
    /**
     * Determine if there is an error for the given field.
     *
     * @param  {String} field
     * @return {Boolean}
     */
    has (field) {
      // eslint-disable-next-line no-prototype-builtins
      return this.errors.hasOwnProperty(field)
    }
  
    /**
     * Determine if there are any errors for the given fields.
     *
     * @param  {...String} fields
     * @return {Boolean}
     */
    hasAny (...fields) {
      return fields.some(field => this.has(field))
    }
  
    /**
     * Determine if there are any errors.
     *
     * @return {Boolean}
     */
    any () {
      return Object.keys(this.errors).length > 0
    }
  
    /**
     * Get the first error message for the given field.
     *
     * @param  String} field
     * @return {String|undefined}
     */
    get (field) {
      if (this.has(field)) {
        return this.getAll(field)[0]
      }
    }
  
    /**
     * Get all the error messages for the given field.
     *
     * @param  {String} field
     * @return {Array}
     */
    getAll (field) {
      return arrayWrap(this.errors[field] || [])
    }
  
    /**
     * Get the error message for the given fields.
     *
     * @param  {...String} fields
     * @return {Array}
     */
    only (...fields) {
      const messages = []
  
      fields.forEach((field) => {
        const message = this.get(field)
  
        if (message) {
          messages.push(message)
        }
      })
  
      return messages
    }
  
    /**
     * Get all the errors in a flat array.
     *
     * @return {Array}
     */
    flatten () {
      return Object.values(this.errors).reduce((a, b) => a.concat(b), [])
    }
  
    /**
     * Clear one or all error fields.
     *
     * @param {String|undefined} field
     */
    clear (field) {
      const errors = {}
  
      if (field) {
        Object.keys(this.errors).forEach((key) => {
          if (key !== field) {
            errors[key] = this.errors[key]
          }
        })
      }
  
      this.set(errors)
    }
  }
  class Form {
    /**
     * Create a new form instance.
     *
     * @param {Object} data
     */
    constructor (data = {}) {
      this.busy = false
      this.successful = false
      this.errors = new Errors()
      this.originalData = deepCopy(data)
  
      Object.assign(this, data)
    }
  
    /**
     * Fill form data.
     *
     * @param {Object} data
     */
    fill (data) {
      this.keys().forEach((key) => {
        this[key] = data[key]
      })
    }
  
    /**
     * Get the form data.
     *
     * @return {Object}
     */
    data () {
      return this.keys().reduce((data, key) => (
        { ...data, [key]: this[key] }
      ), {})
    }
  
    /**
     * Get the form data keys.
     *
     * @return {Array}
     */
    keys () {
      return Object.keys(this)
        .filter(key => !Form.ignore.includes(key))
    }
  
    /**
     * Start processing the form.
     */
    startProcessing () {
      this.errors.clear()
      this.busy = true
      this.successful = false
    }
  
    /**
     * Finish processing the form.
     */
    finishProcessing () {
      this.busy = false
      this.successful = true
    }
  
    /**
     * Clear the form errors.
     */
    clear () {
      this.errors.clear()
      this.successful = false
    }
  
    /**
     * Reset the form fields.
     */
    reset () {
      Object.keys(this)
        .filter(key => !Form.ignore.includes(key))
        .forEach((key) => {
          this[key] = deepCopy(this.originalData[key])
        })
    }
  
    /**
     * Submit the form via a GET request.
     *
     * @param  {String} url
     * @param  {Object} config (axios config)
     * @return {Promise}
     */
    get (url, config = {}) {
      return this.submit('get', url, config)
    }
  
    /**
     * Submit the form via a POST request.
     *
     * @param  {String} url
     * @param  {Object} config (axios config)
     * @return {Promise}
     */
    post (url, config = {}) {
      return this.submit('post', url, config)
    }
  
    /**
     * Submit the form via a PATCH request.
     *
     * @param  {String} url
     * @param  {Object} config (axios config)
     * @return {Promise}
     */
    patch (url, config = {}) {
      return this.submit('patch', url, config)
    }
  
    /**
     * Submit the form via a PUT request.
     *
     * @param  {String} url
     * @param  {Object} config (axios config)
     * @return {Promise}
     */
    put (url, config = {}) {
      return this.submit('put', url, config)
    }
  
    /**
     * Submit the form via a DELETE request.
     *
     * @param  {String} url
     * @param  {Object} config (axios config)
     * @return {Promise}
     */
    delete (url, config = {}) {
      return this.submit('delete', url, config)
    }
  
    /**
     * Submit the form data via an HTTP request.
     *
     * @param  {String} method (get, post, patch, put)
     * @param  {String} url
     * @param  {Object} config (axios config)
     * @return {Promise}
     */
    submit (method, url, config = {}) {
      this.startProcessing()
  
      const data = method === 'get'
        ? { params: this.data() }
        : this.data()
  
      return new Promise((resolve, reject) => {
        (Form.axios || axios).request({ url: this.route(url), method, data, ...config })
          .then((response) => {
            this.finishProcessing()
  
            resolve(response)
          })
          .catch((error) => {
            this.busy = false
  
            if (error.response) {
              this.errors.set(this.extractErrors(error.response))
            }
  
            reject(error)
          })
      })
    }
  
    /**
     * Extract the errors from the response object.
     *
     * @param  {Object} response
     * @return {Object}
     */
    extractErrors (response) {
      if (!response.data || typeof response.data !== 'object') {
        return { error: Form.errorMessage }
      }
  
      if (response.data.errors) {
        return { ...response.data.errors }
      }
  
      if (response.data.message) {
        return { error: response.data.message }
      }
  
      return { ...response.data }
    }
  
    /**
     * Get a named route.
     *
     * @param  {String} name
     * @return {Object} parameters
     * @return {String}
     */
    route (name, parameters = {}) {
      let url = name
  
      // eslint-disable-next-line no-prototype-builtins
      if (Form.routes.hasOwnProperty(name)) {
        url = decodeURI(Form.routes[name])
      }
  
      if (typeof parameters !== 'object') {
        parameters = { id: parameters }
      }
  
      Object.keys(parameters).forEach((key) => {
        url = url.replace(`{${key}}`, parameters[key])
      })
  
      return url
    }
  
    /**
     * Clear errors on keydown.
     *
     * @param {KeyboardEvent} event
     */
    onKeydown (event) {
      if (event.target.name) {
        this.errors.clear(event.target.name)
      }
    }
  
    feedback (name) {
      if (this.errors.has(name)) {
        return this.errors.get(name)
      }
    }
  
    state (name) {
      if (this.errors.any() && this.errors.has(name)) {
        return false
      }
      return null
    }
  
    invalid (name) {
      const ret = this.state(name)
      if (ret === null) { return false }
      return true
    }
  }
  
  Form.routes = {}
  Form.errorMessage = 'Something went wrong. Please try again.'
  Form.ignore = ['busy', 'successful', 'errors', 'originalData']
  
  export default Form
  ","<template>
    <b-container>
      <b-col sm=\"8\" md=\"6\" lg=\"4\" class=\"mx-auto\">
        <b-card class=\"login-card\">
          <form @submit.prevent=\"login\">
            <h1 class=\"title text-muted pb-3\">
              KEA
            </h1>
            <b-form-group>
              <b-input-group class=\"input-group-seamless no-border\" :class=\"{ 'is-invalid': form.invalid('email') }\">
                <b-input-group-prepend>
                  <span class=\"input-group-text\">
                    <fa icon=\"envelope\" :class=\"{ 'text-danger': form.feedback('email') }\" />
                  </span>
                </b-input-group-prepend>
                <b-form-input v-model=\"form.email\"
                              type=\"email\"
                              name=\"email\"
                              required
                              :state=\"form.state('email')\"
                              placeholder=\"Email\"
                />
              </b-input-group>
              <b-form-invalid-feedback :state=\"form.state('email')\">
                <div v-html=\"form.feedback('email')\" />
              </b-form-invalid-feedback>
            </b-form-group>
            <b-form-group>
              <b-input-group class=\"input-group-seamless no-border\" :class=\"{ 'is-invalid': form.invalid('password') }\">
                <b-input-group-prepend>
                  <span class=\"input-group-text\">
                    <fa icon=\"lock\" :class=\"{ 'text-danger': form.feedback('password') }\" />
                  </span>
                </b-input-group-prepend>
                <b-form-input v-model=\"form.password\"
                              type=\"password\"
                              name=\"password\"
                              required
                              :state=\"form.state('password')\"
                              placeholder=\"Password\"
                />
              </b-input-group>
            </b-form-group>
            <b-button type=\"submit\" block variant=\"primary\" class=\"w-100\" :disabled=\"form.busy\">
              <b-spinner v-if=\"form.busy\" class=\"spinner-center\" small />
              Login
            </b-button>
          </form>
        </b-card>
      </b-col>
    </b-container>
  </template>
  
  <script>
  import Form from '~/utils/form'
  export default {
    name: 'Login',
    layout: 'public',
    middleware: 'guest',
    data: () => ({
        form: new Form({
            email: '',
            password: ''
        })
    }),
  
    methods: {
      async login () {
        let data
  
        // Submit the form.
        try {
            const response = await this.form.post('/login')
            data = response.data
        } catch (e) {
            return
        }
  
        // Save the token.
        this.$store.dispatch('auth/saveToken', {
            token: data.token,
            remember: this.remember
        })
  
        // Fetch the user.
        await this.$store.dispatch('auth/fetchUser')
  
        // Redirect home.
        this.$router.push({ name: 'panel.dashboard' })
      }
    }
  }
  </script>
  
  <style lang=\"scss\" scoped>
    .login-card {
      width: 390px;
      background: #fff;
      border-radius: 10px;
      overflow: hidden;
      padding: 10px 25px 10px 25px;
      box-shadow: 0 5px 10px 0px rgba(0, 0, 0, 0.1);
      -moz-box-shadow: 0 5px 10px 0px rgba(0, 0, 0, 0.1);
      -webkit-box-shadow: 0 5px 10px 0px rgba(0, 0, 0, 0.1);
      -o-box-shadow: 0 5px 10px 0px rgba(0, 0, 0, 0.1);
      -ms-box-shadow: 0 5px 10px 0px rgba(0, 0, 0, 0.1);
    }
    .title {
        display: block;
        line-height: 1.2;
        text-align: center;
    }
  </style>
  ","import mod from \"-!../../node_modules/cache-loader/dist/cjs.js??ref--12-0!../../node_modules/thread-loader/dist/cjs.js!../../node_modules/babel-loader/lib/index.js!../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../node_modules/vue-loader/lib/index.js??vue-loader-options!./login.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../node_modules/cache-loader/dist/cjs.js??ref--12-0!../../node_modules/thread-loader/dist/cjs.js!../../node_modules/babel-loader/lib/index.js!../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../node_modules/vue-loader/lib/index.js??vue-loader-options!./login.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./login.vue?vue&type=template&id=844266b8&scoped=true&\"
  import script from \"./login.vue?vue&type=script&lang=js&\"
  export * from \"./login.vue?vue&type=script&lang=js&\"
  import style0 from \"./login.vue?vue&type=style&index=0&id=844266b8&lang=scss&scoped=true&\"
  
  
  /* normalize component */
  import normalizer from \"!../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"
  var component = normalizer(
    script,
    render,
    staticRenderFns,
    false,
    null,
    \"844266b8\",
    null
    
  )
  
  export default component.exports","import mod from \"-!../../node_modules/mini-css-extract-plugin/dist/loader.js??ref--8-oneOf-1-0!../../node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!../../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../../node_modules/postcss-loader/src/index.js??ref--8-oneOf-1-2!../../node_modules/sass-loader/dist/cjs.js??ref--8-oneOf-1-3!../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../node_modules/vue-loader/lib/index.js??vue-loader-options!./login.vue?vue&type=style&index=0&id=844266b8&lang=scss&scoped=true&\"; export default mod; export * from \"-!../../node_modules/mini-css-extract-plugin/dist/loader.js??ref--8-oneOf-1-0!../../node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!../../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../../node_modules/postcss-loader/src/index.js??ref--8-oneOf-1-2!../../node_modules/sass-loader/dist/cjs.js??ref--8-oneOf-1-3!../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../node_modules/vue-loader/lib/index.js??vue-loader-options!./login.vue?vue&type=style&index=0&id=844266b8&lang=scss&scoped=true&\""],"sourceRoot":""}