_N_E=(window.webpackJsonp_N_E=window.webpackJsonp_N_E||[]).push([[107],{"8Q/q":function(e,r,t){"use strict";var n=t("q1tI");r.a=Object(n.createContext)({t:function(e){return Array.isArray(e)?e[0]:e},lang:""})},CKgc:function(e,r,t){"use strict";t.d(r,"a",(function(){return f}));var n=t("vJKn"),s=t.n(n),o=t("rg98"),a=t("LeJ0"),i=t("RC5v"),l=t("r8nI"),u=t("WED6");var c=function(e){if(!(null===e||void 0===e?void 0:e.GetUserInfoResult))return null;var r=[{type:u.a.residential,countryCode:l.a.BRA,areaCode:e.GetUserInfoResult.User.PhoneResidencialAreaCode,number:e.GetUserInfoResult.User.PhoneResidencialNumber},{type:u.a.mobile,countryCode:l.a.BRA,areaCode:e.GetUserInfoResult.User.PhoneCelularAreaCode,number:e.GetUserInfoResult.User.PhoneCelularNumber},{type:u.a.other,countryCode:l.a.BRA,areaCode:e.GetUserInfoResult.User.PhoneOtherAreaCode,number:e.GetUserInfoResult.User.PhoneOtherNumber}];return{id:e.GetUserInfoResult.User.UserId,firstName:e.GetUserInfoResult.User.FirstName,birthday:e.GetUserInfoResult.User.Birthday,document:e.GetUserInfoResult.User.Document,email:e.GetUserInfoResult.User.Email,gender:e.GetUserInfoResult.User.Gender,isSubscriber:e.GetUserInfoResult.User.IsSubscriber,lastName:e.GetUserInfoResult.User.LastName,phones:r,registerNotCompleted:e.GetUserInfoResult.User.RegisterNotCompleted,type:e.GetUserInfoResult.User.PersonType,userName:e.GetUserInfoResult.User.UserName,address:{street:e.GetUserInfoResult.User.Address,complement:e.GetUserInfoResult.User.AddressAdditionalNumber,city:e.GetUserInfoResult.User.AddressCity,countryCode:e.GetUserInfoResult.User.CountryCode,district:e.GetUserInfoResult.User.AddressDistrict,number:e.GetUserInfoResult.User.AddressNumber,state:e.GetUserInfoResult.User.AddressState,zip:e.GetUserInfoResult.User.ZIP}}};function f(){return m.apply(this,arguments)}function m(){return(m=Object(o.a)(s.a.mark((function e(){var r,t,n,o;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={AuthenticationTicket:a.a.api.secret},e.next=3,i.b.post("/GetUserInfo",r);case 3:return t=e.sent,n=t.data,o=c(n),e.abrupt("return",o);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}},LVMw:function(e,r,t){e.exports={formContainer:"styles_formContainer__3zuN9",formError:"styles_formError__7SQ_q",wrapper:"styles_wrapper__1lDti"}},OgpL:function(e,r,t){"use strict";t.d(r,"b",(function(){return n})),t.d(r,"a",(function(){return v})),t.d(r,"c",(function(){return h}));var n,s=t("cpVT"),o=t("vJKn"),a=t.n(o),i=t("rg98"),l=t("q1tI"),u=t.n(l),c=t("RC5v"),f=t("PFlM"),m=t("CKgc"),d=t("i73s"),p=u.a.createElement;function b(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}!function(e){e.Token="tk",e.RefreshToken="rtk",e.User="usr",e.Profile="prfl"}(n||(n={}));var g=Object(l.createContext)({}),v=function(e){var r=e.children;Object(l.useEffect)((function(){sessionStorage.getItem("initializedSection")||(sessionStorage.setItem("initializedSection","true"),h())}),[]);var t=Object(l.useState)((function(){if("undefined"!==typeof localStorage){var e=localStorage.getItem(n.Token),r=localStorage.getItem(n.RefreshToken),t=JSON.parse(localStorage.getItem(n.User)||"{}"),s=JSON.parse(localStorage.getItem(n.Profile)||"{}");if(e&&r&&t)return Object(c.c)(e,r),Object(d.b)({success:function(e){return k(e)},error:function(){return U()}}),{token:e,refreshToken:r,user:t,profiles:[s]}}return{}})),o=t[0],u=t[1],v=function(){var e=localStorage.getItem(n.Token);return{refreshToken:localStorage.getItem(n.RefreshToken),token:e,user:JSON.parse(localStorage.getItem(n.User)||"{}")}},h=function(){var e=Object(i.a)(a.a.mark((function e(){var r,t,n,s,o;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=v(),e.next=3,Object(f.a)({refreshToken:r.refreshToken});case 3:if(t=e.sent,n=t.token,s=t.refreshToken,0===t.result){e.next=10;break}return U(),e.abrupt("return");case 10:return Object(c.c)(n,s),Object(d.b)({success:function(e){return k(e)},error:function(){return U()}}),r.token=n,r.refreshToken=s,e.next=16,Object(m.a)();case 16:o=e.sent,r.user=o,w(r);case 19:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),O=Object(l.useCallback)((function(e){w(e)}),[]),R=Object(l.useCallback)((function(e){localStorage.setItem(n.Profile,JSON.stringify(e))}),[]),w=Object(l.useCallback)((function(e){localStorage.setItem(n.Token,e.token),localStorage.setItem(n.RefreshToken,e.refreshToken),localStorage.setItem(n.User,JSON.stringify(e.user)),u({refreshToken:e.token,token:e.refreshToken,user:e.user,profiles:e.profiles}),Object(c.c)(e.token,e.refreshToken),Object(d.b)({success:function(e){return k(e)},error:function(){return U()}})}),[]),U=Object(l.useCallback)((function(){localStorage.removeItem(n.Token),localStorage.removeItem(n.RefreshToken),localStorage.removeItem(n.User),localStorage.removeItem(n.Profile),Object(d.c)(),u({}),Object(c.d)()}),[]),k=Object(l.useCallback)((function(e){var r=e.token,t=e.refreshToken;localStorage.setItem(n.Token,r),localStorage.setItem(n.RefreshToken,t),u(function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?b(Object(t),!0).forEach((function(r){Object(s.a)(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):b(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}({refreshToken:t,token:r},o)),Object(c.c)(r,t)}),[]);return p(g.Provider,{value:{user:null===o||void 0===o?void 0:o.user,signIn:O,signInProfile:R,signOut:U,updateCredentials:w,renewToken:k,profiles:null===o||void 0===o?void 0:o.profiles}},r)},h=function(){var e=Object(l.useContext)(g);if(!e)throw new Error("using auth context without provider...");return e}},WED6:function(e,r,t){"use strict";var n;!function(e){e.mobile="mobile",e.residential="residential",e.other="other"}(n||(n={})),r.a=n},cqg5:function(e,r,t){"use strict";var n=t("q1tI"),s=t.n(n),o=t("YFqc"),a=t.n(o),i=t("n8CI"),l=t.n(i),u=s.a.createElement;r.a=function(e){var r=e.logo,t=e.title,n=e.isLink,s=void 0!==n&&n,o=e.url;return u("div",{className:l.a.formHeading},s?u(a.a,{href:o},u("a",null,"string"===typeof r?u("img",{src:r,alt:"netmovies-logo"}):r)):u("div",null,"string"===typeof r?u("img",{src:r,alt:"netmovies-logo"}):r),u("h2",null,t))}},eLG3:function(e,r,t){e.exports={formContent:"styles_formContent__25JSh",enabled:"styles_enabled__3vn8b",wrapper:"styles_wrapper__2aHu3",formGroup:"styles_formGroup__2-loV",otherOptions:"styles_otherOptions__1FPxG",loginButton:"styles_loginButton__2VogP"}},"h+bh":function(e,r,t){"use strict";t.r(r);var n=t("q1tI"),s=t.n(n),o=t("vJKn"),a=t.n(o),i=t("rg98"),l=t("nOHt"),u=t("nbPw"),c=t("OgpL"),f=t("LeJ0"),m=t("RC5v");var d=function(e){return{id:e.AddSimpleUserResult.UserId}};function p(e){return b.apply(this,arguments)}function b(){return(b=Object(i.a)(a.a.mark((function e(r){var t,n,s,o,i,l,u;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.firstName,n=r.email,s=r.password,o={Email:n,Password:s,FirstName:t,AuthenticationTicket:f.a.api.secret},e.next=4,m.b.post("/AddSimpleUser",o);case 4:if(i=e.sent,0===(l=i.data).AddSimpleUserResult.Result){e.next=8;break}throw new Error("Ocorreu um erro ao cadastraro usu\xe1rio. ".concat(l.AddSimpleUserResult.Message));case 8:return u=d(l),e.abrupt("return",u);case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var g=t("cqg5"),v=t("YFqc"),h=t.n(v),O=t("eLG3"),R=t.n(O),w=t("KYPV"),U=t("46wD"),k=t("UGp+"),y=function(){var e=Object(u.a)().t;return k.b().shape({firstName:k.d().min(3,e("simpleRegistration:form.errors.validFirstName")).required(e("simpleRegistration:form.errors.requiredFirstName")),email:k.d().email(e("simpleRegistration:form.errors.validEmail")).required(e("simpleRegistration:form.errors.requiredEmail")),password:k.d().min(6,e("simpleRegistration:form.errors.validPassword")).required(e("simpleRegistration:form.errors.requiredPassword")),passwordConfirmation:k.d().oneOf([k.c("password"),null],e("simpleRegistration:form.errors.validPasswordConfirmation")).required(e("simpleRegistration:form.errors.requiredPasswordConfirmation"))})},I=s.a.createElement,C=function(e){var r=e.loading,t=void 0!==r&&r,n=e.handleSubmit,s=Object(u.a)().t;return I(w.d,{initialValues:{firstName:"",email:"",password:"",passwordConfirmation:""},validationSchema:y(),onSubmit:n},(function(e){var r=e.isSubmitting;return I(w.c,{className:R.a.formContent,role:"form"},I("div",{className:R.a.formGroup},I(w.b,{type:"text",name:"firstName",placeholder:s("simpleRegistration:form.namePlaceholder")}),I(w.a,{name:"firstName",component:"div"})),I("div",{className:R.a.formGroup},I(w.b,{type:"text",name:"email",placeholder:s("simpleRegistration:form.emailPlaceholder")}),I(w.a,{name:"email",component:"div"})),I("div",{className:R.a.formDivider}),I("div",{className:R.a.formGroup},I(w.b,{type:"password",name:"password",placeholder:s("simpleRegistration:form.passwordPlaceholder")}),I(w.a,{name:"password",component:"div"})),I("div",{className:R.a.formGroup},I(w.b,{type:"password",name:"passwordConfirmation",placeholder:s("simpleRegistration:form.confirmPasswordPlaceholder")}),I(w.a,{name:"passwordConfirmation",component:"div"})),I("div",{className:R.a.formGroup},t&&I(U.a,{message:s("simpleRegistration:form.loading")}),!t&&I("input",{type:"submit",disabled:r,value:s("simpleRegistration:form.buttonRegister"),className:R.a.enabled})),!t&&I("div",{className:R.a.otherOptions},I("p",null,s("simpleRegistration:hasAccessTitle")),I(h.a,{href:"/session/login"},I("a",{className:R.a.loginButton},s("simpleRegistration:loginButton")))))}))},j=t("LVMw"),_=t.n(j),N=s.a.createElement,S=function(){var e=Object(n.useState)(!1),r=e[0],t=e[1],o=Object(n.useState)(""),f=o[0],m=o[1],d=Object(u.a)().t,b=Object(c.c)(),v=Object(l.useRouter)();Object(n.useEffect)((function(){b.user&&v.push("/")}),[]);var O=Object(n.useCallback)(function(){var e=Object(i.a)(a.a.mark((function e(r){var n,s,o;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.firstName,s=r.email,o=r.password,t(!0),e.prev=2,e.next=5,p({firstName:n,email:s,password:o});case 5:v.push("/session/login?username=".concat(s,"&password=").concat(o),"login",{shallow:!0}),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(2),m(e.t0.message);case 11:return e.prev=11,t(!1),e.finish(11);case 14:case"end":return e.stop()}}),e,null,[[2,8,11,14]])})));return function(r){return e.apply(this,arguments)}}(),[]);return N("div",{className:_.a.wrapper},N(h.a,{href:"/"},N("a",null,N("img",{src:"/assets/images/netmovies.webp",alt:"logo-netmovies"}))),N("div",{className:_.a.formContainer},N(g.a,{title:d("simpleRegistration:title"),url:"/",isLink:!0}),N("div",{className:_.a.formError},f&&N(s.a.Fragment,null,f)),N(C,{handleSubmit:O,loading:r})))},P=t("vXCt"),G=t.n(P),T=s.a.createElement,A=function(){return T("div",{id:G.a.simpleRegister},T(S,null))},x=s.a.createElement;r.default=function(){return x(A,null)}},n8CI:function(e,r,t){e.exports={formHeading:"styles_formHeading__1gr2z"}},nbPw:function(e,r,t){"use strict";t.d(r,"a",(function(){return i}));var n=t("q1tI");function s(e,r){if("string"!==typeof r)return e;return function(t,n,s){void 0===t&&(t="");var o=Array.isArray(t)?t[0]:t;if(o.includes(":")||(o=r+":"+o),null===s||void 0===s?void 0:s.fallback)if(Array.isArray(s.fallback))s.fallback=s.fallback.map((function(e){return e.includes(":")?e:r+":"+e}));else{var a=s.fallback;s.fallback=a.includes(":")?a:r+":"+a}return e(o,n,s)}}var o=t("8Q/q"),a=function(){return(a=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var s in r=arguments[t])Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s]);return e}).apply(this,arguments)};function i(e){var r=Object(n.useContext)(o.a);return a(a({},r),{t:s(r.t,e)})}},r8nI:function(e,r,t){"use strict";var n;!function(e){e[e.BRA=55]="BRA"}(n||(n={})),r.a=n},vXCt:function(e,r,t){e.exports={simpleRegister:"styles_simpleRegister__3MZxC",session:"styles_session__1GQpO"}},vxqa:function(e,r,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/session/simple-register",function(){return t("h+bh")}])}},[["vxqa",1,2,0,3,4]]]);