{"components":{"platform.Login":{"name":"Login","scheme":"platform","head":{"attributes":[{"as":"title","default":"'Welcome back'"},{"as":"lede","default":"'Sign in to your Despia account.'"}],"apis":[],"expects":[],"events":[],"inputs":[],"tools":[],"variables":[{"as":"readError","body":"return false","computed":false},{"as":"resendIn","body":"return 0","computed":false},{"as":"sentCount","body":"return 0","computed":false},{"as":"settled","body":"return dsx.query.auth == null &amp;&amp; dsx.query.auth_error == null","computed":false},{"as":"step","body":"return 'email'","computed":false},{"as":"emailText","body":"return ''","computed":false},{"as":"codeText","body":"return ''","computed":false},{"as":"sentTo","body":"return ''","computed":false},{"as":"devInbox","body":"return ''","computed":false},{"as":"error","body":"return ''","computed":false},{"as":"notice","body":"return ''","computed":false},{"as":"errorAt","body":"return 'page'","computed":false},{"as":"ready","body":"return { google: true, github: true, passkeys: true }","computed":false,"persist":"device"},{"as":"onCode","body":"return dsx.variable.step == 'code'","computed":true},{"as":"hasError","body":"return dsx.variable.error != ''","computed":true},{"as":"pageError","body":"return dsx.variable.hasError &amp;&amp; dsx.variable.errorAt == 'page'","computed":true},{"as":"fieldError","body":"return dsx.variable.hasError &amp;&amp; dsx.variable.errorAt == 'field'","computed":true},{"as":"hasNotice","body":"return dsx.variable.notice != '' &amp;&amp; dsx.variable.error == ''","computed":true},{"as":"email","body":"return String(dsx.variable.emailText || '')","computed":true},{"as":"emailEmpty","body":"return dsx.variable.email.trim() == ''","computed":true},{"as":"code","body":"return String(dsx.variable.codeText || '')","computed":true},{"as":"codeIncomplete","body":"return dsx.variable.code.replace(/\\s/g, '').length != 6","computed":true},{"as":"busy","body":"return dsx.action.sendCode.pending || dsx.action.verify.pending || dsx.action.resend.pending || dsx.action.passkey.pending || dsx.action.provider.pending","computed":true},{"as":"continueLabel","body":"return dsx.action.sendCode.pending ? 'Sending code…' : 'Continue'","computed":true},{"as":"signInLabel","body":"return dsx.action.verify.pending ? 'Signing In…' : 'Sign In'","computed":true},{"as":"codeFooter","body":"return 'The code works for 10 minutes.'","computed":true},{"as":"others","body":"\n      const rows = []\n      if (dsx.variable.ready.google != false) { rows.push({ id: 'google', icon: 'google.logo', title: 'Google' }) }\n      if (dsx.variable.ready.github != false) { rows.push({ id: 'github', icon: 'github.logo', title: 'GitHub' }) }\n      rows.push({ id: 'passkey', icon: 'person.badge.key', title: 'Passkey' })\n      return rows\n    ","computed":true},{"as":"heading","body":"return dsx.variable.onCode ? 'Check your email' : dsx.attribute.title","computed":true},{"as":"subheading","body":"return dsx.variable.onCode ? 'We sent a 6-digit code to ' + dsx.variable.sentTo + '.' : dsx.attribute.lede","computed":true},{"as":"page","body":"return dsx.variable.onCode ? 2 : 1","computed":true},{"as":"canResend","body":"return dsx.variable.resendIn == 0 &amp;&amp; !dsx.variable.busy","computed":true},{"as":"resendLabel","body":"return dsx.variable.resendIn > 0 ? 'Resend (' + dsx.variable.resendIn + 's)' : 'Resend Code'","computed":true}],"formulas":[],"actions":[{"as":"start","inputs":{},"body":"\n      dsx.variable.readError = false\n      if (dsx.path != '/login') { dsx.variable.settled = true; return }\n      //  A guarded page names its destination with returnTo or next: kept as the return path\n      //  before anything else, so it survives the sign in, including a provider round trip. The adapter accepts only a path on this site.\n      const destination = dsx.query.returnTo == null ? dsx.query.next : dsx.query.returnTo\n      const next = destination == null ? '' : String(destination)\n      const keep = /^\\/(?!\\/)[^\\s\\\\]*$/.test(next) &amp;&amp; !/^\\/login(?:[/?#]|$)/.test(next)\n      //  The form is already drawn; the providers and the session question go out together, neither waiting on the other.\n      //  A provider round trip coming back asks the session itself (finishProvider), so it is not asked twice.\n      let offered = null\n      let s = null\n      if (!dsx.variable.settled) {\n        offered = await dsx.module.convertdata.providers()\n      } else if (keep) {\n        const both = await Promise.all([dsx.module.convertdata.providers(), dsx.module.convertdata.requireSession({ next: next })])\n        offered = both[0]\n        s = both[1]\n      } else {\n        const both = await Promise.all([dsx.module.convertdata.providers(), dsx.module.convertdata.session()])\n        offered = both[0]\n        s = both[1]\n      }\n      if (!offered.ok || (s != null &amp;&amp; !s.ok)) { dsx.variable.readError = true; return }\n      dsx.variable.ready = offered.data\n      //  ONLY A PROVIDER ROUND TRIP COMING BACK is finished (settled starts false only with ?auth= or ?auth_error=).\n      //  finishProvider resets every held read, which re-runs this load (a live reader): calling it on every run\n      //  looped providers + session for as long as the page was open.\n      if (!dsx.variable.settled) {\n        const back = await dsx.module.convertdata.finishProvider()\n        if (!back.ok) {\n          dsx.variable.error = messageOf(back)\n          dsx.variable.settled = true\n          return\n        }\n        if (back.data.signedIn &amp;&amp; dsx.path == '/login') {\n          dsx.module.route.reset({ path: back.data.next })\n          return\n        }\n        dsx.variable.settled = true\n        return\n      }\n      if (s.ok &amp;&amp; s.data.signedIn &amp;&amp; dsx.path == '/login') {\n        dsx.module.route.reset({ path: keep ? next : s.data.next })\n        return\n      }\n      if (s.ok &amp;&amp; s.data.signedOut) { dsx.variable.notice = 'You signed out.' }\n      dsx.variable.settled = true\n    "},{"as":"sendCode","inputs":{},"body":"\n      dsx.variable.errorAt = 'field'\n      if (dsx.variable.emailEmpty) { dsx.variable.error = 'Enter your email address.'; return }\n      const r = await dsx.module.convertdata.requestCode({ email: dsx.variable.email })\n      if (!r.ok) { dsx.variable.error = messageOf(r); return }\n      dsx.variable.sentTo = r.data.email\n      dsx.variable.devInbox = r.data.devInbox == null ? '' : r.data.devInbox\n      dsx.variable.codeText = ''\n      dsx.variable.error = ''\n      dsx.variable.notice = ''\n      dsx.variable.step = 'code'\n      dsx.variable.resendIn = 30\n      dsx.variable.sentCount = dsx.variable.sentCount + 1\n    "},{"as":"resend","inputs":{},"body":"\n      dsx.variable.errorAt = 'field'\n      const r = await dsx.module.convertdata.requestCode({ email: dsx.variable.sentTo })\n      if (!r.ok) { dsx.variable.error = messageOf(r); return }\n      dsx.variable.codeText = ''\n      dsx.variable.error = ''\n      dsx.variable.notice = 'We sent a new code.'\n      dsx.variable.resendIn = 30\n      dsx.variable.sentCount = dsx.variable.sentCount + 1\n    "},{"as":"cooldown","inputs":{},"body":"\n      while (dsx.variable.resendIn > 0 &amp;&amp; dsx.variable.step == 'code') {\n        await dsx.wait(1000)\n        dsx.variable.resendIn = dsx.variable.resendIn - 1\n      }\n    "},{"as":"verify","inputs":{},"body":"\n      dsx.variable.errorAt = 'field'\n      if (dsx.variable.codeIncomplete) { dsx.variable.error = 'Enter the 6-digit code from the email.'; return }\n      const r = await dsx.module.convertdata.verifyCode({ email: dsx.variable.sentTo, code: dsx.variable.code })\n      if (!r.ok) { dsx.variable.error = messageOf(r); return }\n      dsx.module.route.reset({ path: r.data.next })\n    "},{"as":"passkey","inputs":{},"body":"\n      dsx.variable.errorAt = 'page'\n      const r = await dsx.module.convertdata.passkey()\n      if (!r.ok) { dsx.variable.error = messageOf(r); return }\n      dsx.module.route.reset({ path: r.data.next })\n    "},{"as":"provider","inputs":{},"body":"\n      dsx.variable.errorAt = 'page'\n      if (dsx.variable.ready[dsx.this.name] == false) {\n        dsx.variable.error = (dsx.this.name == 'github' ? 'GitHub' : 'Google') + \" sign-in isn't set up yet. Use your email.\"\n        return\n      }\n      const r = await dsx.module.convertdata.startProvider({ provider: dsx.this.name })\n      if (!r.ok) { dsx.variable.error = messageOf(r) }\n    "},{"as":"other","inputs":{},"body":"\n      if (dsx.this.id == 'passkey') { await dsx.action.passkey(); return }\n      await dsx.action.provider({ name: dsx.this.id })\n    "},{"as":"changeEmail","inputs":{},"body":"\n      dsx.variable.step = 'email'\n      dsx.variable.codeText = ''\n      dsx.variable.error = ''\n      dsx.variable.notice = ''\n    "}],"watches":[{"value":"dsx.variable.sentCount","handler":"dsx.action.cooldown()"}],"scripts":["\n      function messageOf(r) {\n        if (r == null) { return 'Despia did not answer. Try again in a moment.' }\n        if (r.error != null &amp;&amp; typeof r.error == 'object' &amp;&amp; r.error.message) { return r.error.message }\n        if (r.message) { return r.message }\n        return 'Despia did not answer. Try again in a moment.'\n      }\n    "],"globalScripts":[]},"root":{"tag":"stack","attrs":{"on:appear":"dsx.action.start()"},"children":[{"tag":"AuthPage","attrs":{"logo":"/brand/despia-logo.svg","logo-dark":"/brand/despia-logo-dark.svg","logo-label":"Despia","title":"{{ dsx.variable.heading }}","subtitle":"{{ dsx.variable.settled ? dsx.variable.subheading : '' }}","footer":"By continuing, you agree to the Despia terms.","links":"{{ [{ label: 'Terms of Service', href: 'https://despia.com/terms' }, { label: 'Privacy Policy', href: '/privacy' }, { label: 'Need help?', href: 'mailto:support@despia.com' }] }}"},"children":[{"tag":"Callout","attrs":{"tone":"error","title":"Sign-in options did not load","message":"Despia did not answer. Check your connection and try again.","action":"Try Again","visible-if":"dsx.variable.readError","on:action":"dsx.action.start()"},"children":[],"text":"","reactive":true,"nid":2},{"tag":"spinner","attrs":{"visible-if":"!dsx.variable.settled"},"children":[],"text":"","reactive":true,"nid":3},{"tag":"ListGroup","attrs":{"visible-if":"dsx.variable.settled && dsx.variable.pageError"},"children":[{"tag":"SettingsRow","attrs":{"icon":"exclamationmark.triangle","title":"{{ dsx.variable.error }}"},"children":[],"text":"","reactive":true,"nid":5}],"text":"\n      \n    ","reactive":true,"nid":4},{"tag":"ListGroup","attrs":{"visible-if":"dsx.variable.settled && dsx.variable.hasNotice"},"children":[{"tag":"SettingsRow","attrs":{"icon":"checkmark.circle","title":"{{ dsx.variable.notice }}"},"children":[],"text":"","reactive":true,"nid":7}],"text":"\n      \n    ","reactive":true,"nid":6},{"tag":"StepPages","attrs":{"current":"{{ dsx.variable.page }}","visible-if":"dsx.variable.settled"},"children":[{"tag":"StepPage","attrs":{"step":"1"},"children":[{"tag":"ListGroup","attrs":{},"children":[{"tag":"SettingsRow","attrs":{"repeat":"dsx.variable.others","key":"id","icon":"{{ dsx.this.icon }}","title":"{{ dsx.this.title }}","tappable":"{{ dsx.variable.busy ? 'false' : 'true' }}","on:tap":"dsx.action.other({ id: dsx.this.id })"},"children":[],"text":"","reactive":true,"nid":11}],"text":"\n          \n        ","reactive":true,"nid":10},{"tag":"ListGroup","attrs":{"header":"Or continue with email","footer":"We'll email you a 6-digit code."},"children":[{"tag":"SettingsRow","attrs":{"icon":"envelope"},"children":[{"tag":"textfield","attrs":{"bind":"dsx.variable.emailText","keyboard":"email","content-type":"email","autocapitalize":"none","enterkeyhint":"go","placeholder":"name@example.com","aria-label":"Email","on:submit":"dsx.action.sendCode()"},"children":[],"text":"","reactive":true,"nid":14}],"text":"","reactive":true,"nid":13},{"tag":"SettingsRow","attrs":{"icon":"exclamationmark.triangle","title":"{{ dsx.variable.error }}","visible-if":"dsx.variable.fieldError"},"children":[],"text":"","reactive":true,"nid":15}],"text":"\n          \n          \n        ","reactive":true,"nid":12},{"tag":"button","attrs":{"variant":"prominent","control-size":"large","label":"{{ dsx.variable.continueLabel }}","disabled-if":"dsx.variable.busy","on:tap":"dsx.action.sendCode()"},"children":[],"text":"","reactive":true,"nid":16}],"text":"\n        \n        \n        \n      ","reactive":true,"nid":9},{"tag":"StepPage","attrs":{"step":"2"},"children":[{"tag":"ListGroup","attrs":{"footer":"{{ dsx.variable.codeFooter }}"},"children":[{"tag":"SettingsRow","attrs":{"icon":"number"},"children":[{"tag":"textfield","attrs":{"bind":"dsx.variable.codeText","keyboard":"number","content-type":"one-time-code","enterkeyhint":"go","placeholder":"6-digit code","aria-label":"6-digit code","on:submit":"dsx.action.verify()"},"children":[],"text":"","reactive":true,"nid":20}],"text":"","reactive":true,"nid":19},{"tag":"SettingsRow","attrs":{"icon":"exclamationmark.triangle","title":"{{ dsx.variable.error }}","visible-if":"dsx.variable.fieldError"},"children":[],"text":"","reactive":true,"nid":21}],"text":"\n          \n          \n        ","reactive":true,"nid":18},{"tag":"button","attrs":{"variant":"prominent","control-size":"large","label":"{{ dsx.variable.signInLabel }}","disabled-if":"dsx.variable.busy","on:tap":"dsx.action.verify()"},"children":[],"text":"","reactive":true,"nid":22},{"tag":"ListGroup","attrs":{},"children":[{"tag":"SettingsRow","attrs":{"icon":"envelope","title":"{{ dsx.variable.resendLabel }}","tone":"{{ dsx.variable.canResend ? 'accent' : '' }}","tappable":"{{ dsx.variable.canResend ? 'true' : 'false' }}","on:tap":"dsx.action.resend()"},"children":[],"text":"","reactive":true,"nid":24},{"tag":"SettingsRow","attrs":{"icon":"chevron.backward","title":"Use a Different Email","tone":"accent","tappable":"{{ dsx.variable.busy ? 'false' : 'true' }}","on:tap":"dsx.action.changeEmail()"},"children":[],"text":"","reactive":true,"nid":25}],"text":"\n          \n          \n        ","reactive":true,"nid":23},{"tag":"ListGroup","attrs":{"visible-if":"dsx.variable.devInbox != ''","footer":"This local run shows the code here instead of emailing it."},"children":[{"tag":"SettingsRow","attrs":{"icon":"tray","title":"Open the Local Inbox","href":"{{ dsx.variable.devInbox }}","chevron":"true","tappable":"true"},"children":[],"text":"","reactive":true,"nid":27}],"text":"\n          \n        ","reactive":true,"nid":26}],"text":"\n        \n        \n        \n        \n      ","reactive":true,"nid":17}],"text":"\n      \n      \n    ","reactive":true,"nid":8}],"text":"\n    \n\n    \n\n    \n    \n\n    \n  ","reactive":true,"nid":1}],"text":"\n  \n\n  \n","reactive":true,"nid":0},"reactive":true,"language":"1"}}}