1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[160],{1627:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/electron-auth",function(){return n(2149)}])},2149:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return w}});var r=n(1215),a=n(1241),o=n(2379),i=n(1031),u=n.n(i),s=n(1351),l=n.n(s),c=n(6458),f=n(3522),d=n(4174),p=n(2822),h=function(){return(h=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)},g=function(e){return{loading:null==e,value:e}},m=function(e){var t=e?e():void 0,n=(0,o.useReducer)(function(e,t){switch(t.type){case"error":return h(h({},e),{error:t.error,loading:!1,value:void 0});case"reset":return g(t.defaultValue);case"value":return h(h({},e),{error:void 0,loading:!1,value:t.value});default:return e}},g(t)),r=n[0],a=n[1],i=(0,o.useCallback)(function(){a({type:"reset",defaultValue:e?e():void 0})},[e]),u=(0,o.useCallback)(function(e){a({type:"error",error:e})},[]),s=(0,o.useCallback)(function(e){a({type:"value",value:e})},[]);return(0,o.useMemo)(function(){return{error:r.error,loading:r.loading,reset:i,setError:u,setValue:s,value:r.value}},[r.error,r.loading,i,u,s,r.value])},b=function(e,t){var n=m(function(){return e.currentUser}),r=n.error,a=n.loading,i=n.setError,u=n.setValue,s=n.value;return(0,o.useEffect)(function(){var n=(0,p.Aj)(e,function(e){var n,r,a,o;return n=void 0,r=void 0,a=void 0,o=function(){return function(e,t){var n,r,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,r=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(a=(a=i.trys).length>0&&a[a.length-1])&&(6===o[0]||2===o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){i.label=o[1];break}if(6===o[0]&&i.label<a[1]){i.label=a[1],a=o;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(o);break}a[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}(this,function(n){switch(n.label){case 0:if(!(null==t?void 0:t.onUserChanged))return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.onUserChanged(e)];case 2:return n.sent(),[3,4];case 3:return i(n.sent()),[3,4];case 4:return u(e),[2]}})},new(a||(a=Promise))(function(e,t){function i(e){try{s(o.next(e))}catch(e){t(e)}}function u(e){try{s(o.throw(e))}catch(e){t(e)}}function s(t){var n;t.done?e(t.value):((n=t.value)instanceof a?n:new a(function(e){e(n)})).then(i,u)}s((o=o.apply(n,r||[])).next())})},i);return function(){n()}},[e]),[s,a,r]},y=o.createElement,v="hippo://auth/callback";function w(){var e=(0,c.useRouter)(),t=b(f.I8),n=(0,a.Z)(t,2),i=n[0],s=n[1],p=(0,o.useState)("idle"),h=p[0],g=p[1],m=(0,o.useState)(null),w=m[0],x=m[1],k=(0,o.useState)(null),N=k[0],S=k[1],C=(0,o.useState)(null),E=C[0],O=C[1],j=(0,o.useState)(null),_=j[0],R=j[1],T=(0,o.useRef)(!1);(0,o.useEffect)(function(){if(e.isReady){var t=e.query.state;if("string"!=typeof t||0===t.length){g("missing-state"),x("We couldnât continue because the login state is missing.");return}O(t),g("awaiting-user");var n="https://api.gethipposcribe.com/api/v1";if(!n){g("error"),x("API base URL is not configured.");return}R(n)}},[e.isReady,e.query.state]);var U=(0,o.useCallback)((0,r.Z)(u().mark(function e(){return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return x(null),g("authenticating"),e.prev=2,e.next=5,d.b.loginWithGoogle();case 5:e.next=12;break;case 7:e.prev=7,e.t0=e.catch(2),x(e.t0 instanceof Error&&e.t0.message||"We couldnât open Google sign-in. Please try again."),g("error");case 12:case"end":return e.stop()}},e,null,[[2,7]])})),[]);(0,o.useEffect)(function(){if(E&&_&&!T.current&&!s){if(!i){g(function(e){return"authenticating"===e?e:"awaiting-user"});return}T.current=!0,(0,r.Z)(u().mark(function t(){var n,r,a,o,s,l,c,f,d;return u().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,g("minting"),x(null),t.next=5,i.getIdToken(!0);case 5:return o={state:E,idToken:t.sent,email:null!==(n=i.email)&&void 0!==n?n:null,displayName:null!==(r=i.displayName)&&void 0!==r?r:null,photoURL:null!==(a=i.photoURL)&&void 0!==a?a:null},t.next=9,fetch("".concat(_,"/auth/electron-auth/token"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});case 9:if((s=t.sent).ok){t.next=16;break}return t.next=13,s.json().catch(function(){return null});case 13:throw Error((null==(l=t.sent)?void 0:l.error)||"We couldnât prepare the login. (Status ".concat(s.status,")"));case 16:return t.next=18,s.json();case 18:if(!(!(c=t.sent.token)||"string"!=typeof c)){t.next=22;break}
1throw Error("The server returned an invalid token.");case 22:f=function(e){if(!e)return v;try{var t=new URL(e);if("hippo:"!==t.protocol.toLowerCase()||"auth"!==t.hostname)return v;return t.toString()}catch(e){return v}}("string"==typeof e.query.return?e.query.return:void 0),S(d="".concat(f,"?state=").concat(encodeURIComponent(E),"&token=").concat(encodeURIComponent(c))),g("launching"),window.location.href=d,setTimeout(function(){try{window.history.replaceState({},"","/electron-auth/done")}catch(e){}g("done")},1500),t.next=36;break;case 30:t.prev=30,t.t0=t.catch(0),T.current=!1,x(t.t0 instanceof Error&&t.t0.message||"We couldnât finish signing you in. Please try again."),g("error");case 36:case"end":return t.stop()}},t,null,[[0,30]])}))()}},[_,e.query.return,E,i,s]);var A=(0,o.useMemo)(function(){switch(h){case"idle":return"Preparing sign-inâ¦";case"missing-state":return w;case"awaiting-user":case"authenticating":return y("div",{className:"space-y-4"},y("p",{className:"text-lg font-semibold text-slate-800"},"Sign in with Google to continue in the desktop app."),y("button",{className:"rounded-md bg-sky-600 px-4 py-2 font-medium text-white transition hover:bg-sky-700 disabled:cursor-not-allowed disabled:bg-sky-400",onClick:U,disabled:"authenticating"===h},"authenticating"===h?"Opening Googleâ¦":"Continue with Google"),w&&y("p",{className:"text-sm text-red-600"},w));case"minting":return"Finishing sign-inâ¦";case"launching":case"done":return y("div",{className:"space-y-4"},y("p",{className:"text-lg font-semibold text-slate-800"},"All set! Switch back to Hippo Scribe to finish logging in."),y("p",{className:"text-sm text-slate-600"},"If Hippo Scribe didnât open automatically, click the button below to try again."),N&&y("button",{className:"rounded-md border border-slate-200 px-3 py-2 text-sm font-medium text-slate-700 transition hover:bg-slate-100",onClick:function(){window.location.href=N}},"Open Hippo Scribe again"));case"error":return y("div",{className:"space-y-4"},y("p",{className:"text-lg font-semibold text-red-600"},"Something went wrong."),w&&y("p",{className:"text-sm text-red-600"},w),y("button",{className:"rounded-md border border-slate-200 px-3 py-2 text-sm font-medium text-slate-700 transition hover:bg-slate-100",onClick:function(){T.current=!1,x(null),g(i?"minting":"awaiting-user")}},"Try again"));default:return null}},[w,U,N,h,i]);return y(o.Fragment,null,y(l(),null,y("title",null,"Hippo Scribe \xb7 Continue with Google")),y("main",{className:"flex min-h-screen flex-col items-center justify-center bg-slate-50 px-4"},y("div",{className:"w-full max-w-md rounded-xl bg-white p-6 shadow-md"},y("div",{className:"mb-6 text-center"},y("h1",{className:"text-xl font-semibold text-slate-900"},"Connecting to Hippo Scribe"),y("p",{className:"mt-2 text-sm text-slate-600"},"Follow the prompts in your browser. Weâll return you to the desktop app automatically.")),y("div",{className:"text-center text-base text-slate-700"},A))))}},1351:function(e,t,n){e.exports=n(917)},6458:function(e,t,n){e.exports=n(2244)},2682:function(e,t,n){"use strict";function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}n.d(t,{Z:function(){return r}})},1241:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(8455);function a(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,u=[],s=!0,l=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=o.call(n)).done)&&(u.push(r.value),u.length!==t);s=!0);}catch(e){l=!0,a=e}finally{try{if(!s&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(l)throw a}}return u}}(e,t)||(0,r.Z)(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}},8455:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(2682);function a(e,t){if(e){if("string"==typeof e)return(0,r.Z)(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return(0,r.Z)(e,t)}}}},function(e){e.O(0,[888,774,179],function(){return e(e.s=1627)}),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.