1import{r as S,u as e,bz as pe,b5 as xe,bA as ye,bB as be}from"./vendor-DzWMmZj2.js";import{e as W,o as O,p as je,d as Se}from"./vendor-tanstack-D-s8FawA.js";import{u as Ce,b as H,d as Fe,w as U,a as h,F as Y,L as P,B as Z,p as L,l as V,x as _e,y as ve,z as Ne,G as ne,Q as Ae}from"./index-B-ZZKIlh.js";import{i as T,a as v,v as ee,b as Ve,s as Ie,A as Ee,c as ae}from"./validators-5Tgu1LNi.js";import{c as Me}from"./clipboard-HKDmjuhN.js";import{w as te,a as we,u as Te}from"./useForm-DkZRU2IA.js";import{u as R}from"./vendor-i18n-C7hD56hb.js";import{S as De}from"./StatusCard-BsnPiwJk.js";import"./vendor-socket-CdJ84v18.js";import"./vendor-phone-CDRp5aFf.js";import"./date-picker-Ci6ABAHb.js";const ke=p=>{const a=S.useRef(0);S.useEffect(()=>{const u=n=>{var c,o;Date.now()-a.current<100||(a.current=Date.now(),!((c=window.getSelection())!=null&&c.toString())&&(["INPUT","TEXTAREA","CONTENTEDITABLE"].includes((o=n.target)==null?void 0:o.tagName)||(p(),n.preventDefault())))};return document.addEventListener("copy",u),()=>document.removeEventListener("copy",u)},[p])},Le=p=>{const a=S.useRef(0);S.useEffect(()=>{const u=n=>{var o,m;if(Date.now()-a.current<100||(a.current=Date.now(),["INPUT","TEXTAREA","CONTENTEDITABLE"].includes((o=n.target)==null?void 0:o.tagName)))return;const c=(m=n.clipboardData)==null?void 0:m.getData("text/plain");c&&(p(c),n.preventDefault())};return document.addEventListener("paste",u),()=>document.removeEventListener("paste",u)},[p])},{settingsCityAutocomplete:Oe,settingsCountries:Pe,settingsChangeCountry:Re}=Fe(),X={select:["country","region","city","cityId"],create:["country","region","city"]},qe=te({props:{onSubmit:()=>{},setStepIsValid:(p=!1)=>{}},render:function({group:a,onSubmit:u,setStepIsValid:n}){const c=Ce("appStore"),{t:o}=R(["auth","common"]),{mode:m="select"}=W({strict:!1}),{data:j,mutateAsync:y}=H({mutationKey:["search_city"],mutationFn:({countryId:s,search:t})=>Oe({countryId:s,search:t}),successFn:s=>{var t;return((t=s==null?void 0:s.result)==null?void 0:t.map(l=>({...l,value:l.id,short:l.value})))||[]}}),{data:r,mutateAsync:f}=H({mutationKey:["countries"],mutationFn:()=>Pe({}),successFn:s=>{var t;return((t=s==null?void 0:s.result)==null?void 0:t.map(({id:l,code:b,name:C})=>({value:l,label:C,code:b})))||[]}}),{data:g,mutateAsync:F}=H({mutationKey:["regions"],mutationFn:({countryId:s})=>s?Re({countryId:s}):Promise.resolve(null),successFn:s=>{var t,l;return((l=(t=s==null?void 0:s.result)==null?void 0:t.regions)==null?void 0:l.map(({id:b,name:C})=>({value:b,label:C})))||[]}}),A=U(y,500),i=U(f,500),d=U(F,500),{isSubmitting:x,isValid:N,savedSearchCity:M,cityMode:_}=O(a.form.store,s=>{const t=s.values,l=t.cityMode||"select",b=l==="select"?X.select:X.create,C=T(s.fieldMeta,b);return{isSubmitting:s.isSubmitting,isValid:C,cityMode:l,savedSearchCity:t.savedSearchCity||""}}),D=_==="select"?X.select:X.create,{countryId:I,cityId:w,regionId:q,cityName:$}=O(a.form.store,s=>{const t=s.values;return{countryId:t==null?void 0:t.country,regionId:t==null?void 0:t.region,cityId:t==null?void 0:t.cityId,cityName:t==null?void 0:t.city}}),z=async()=>{await ee(a.form,D);const s=T(a.form.state.fieldMeta,D);n(s),s&&(u==null||u())},G=s=>{var b,C,k,re;const t=se=>se?parseInt("".concat(se)):null;a.setFieldValue("cityId",(s==null?void 0:s.value)||null),a.setFieldValue("city",(s==null?void 0:s.short)||null),a.setFieldValue("region",t((b=s==null?void 0:s.region)==null?void 0:b.id)),a.setFieldValue("country",t((C=s==null?void 0:s.country)==null?void 0:C.id));const l=((re=(k=s==null?void 0:s.country)==null?void 0:k.code)==null?void 0:re.toLowerCase())||null;a.setFieldValue("countryCode",l),c.setSelectedCountryCode(l)},fe=S.useEffectEvent(s=>{i(),s==="create"?d({countryId:I}):A({countryId:I,search:M})}),ge=S.useEffectEvent(s=>{var l,b;if(s==="create"||!w)return;const t=j==null?void 0:j.find(C=>C.value===w);t&&(((l=t.country)==null?void 0:l.id)===I&&((b=t.region)==null?void 0:b.id)===q&&t.short===$||a.setFieldValue("cityId",null))});return S.useLayoutEffect(()=>{a.form.setFieldValue("cityMode",m,{dontValidate:!0}),fe(m),ge(m)},[m]),e.jsxs(e.Fragment,{children:[e.jsx(a.AppField,{name:"country",listeners:{onChange:({value:s,fieldApi:t})=>{const l=s;d({countryId:l}),A({countryId:l,search:M})}},validators:{onChange:({value:s})=>{if(v(s))return o("common:common.errors.required")}},children:s=>e.jsx(s.FormSelect,{label:o("auth.register.create_city.country"),placeholder:o("auth.register.create_city.country.placeholder"),items:r,searchable:!0,onChange:t=>{var k;const l=t==null?void 0:t.value,b=s.state.value;if(l===b)return;s.setValue(l);const C=((k=t==null?void 0:t.code)==null?void 0:k.toLowerCase())||null;s.form.setFieldValue("countryCode",C),c.setSelectedCountryCode(C),s.form.setFieldValue("region",null),s.form.setFieldValue("cityId",null,{dontValidate:!0})},ItemSlot:({item:t})=>e.jsxs("div",{className:h("flex gap-1 items-center"),children:[e.jsx(Y,{code:t==null?void 0:t.code,size:12}),t==null?void 0:t.label]})})}),e.jsx(a.AppField,{name:"region",validators:{onChange:({value:s})=>{if(v(s))return o("common:common.errors.required")}},children:s=>e.jsx(s.FormSelect,{classNames:{wrapper:h(_==="select"&&"hidden")},label:o("auth.register.create_city.region"),placeholder:o("auth.register.create_city.region.placeholder"),items:g,searchable:!0,onChange:t=>s.setValue(t==null?void 0:t.value)})}),e.jsx(a.AppField,{name:"cityId",validators:{onChange:({value:s,fieldApi:t})=>{if((t.form.getFieldValue("cityMode")||"select")==="select"&&v(s))return o("common:common.errors.required")}},children:s=>e.jsx(s.FormSelect,{classNames:{wrapper:h(_!=="select"&&"hidden")},label:o("auth.register.city"),placeholder:o("auth.register.city.placeholder"),items:j,searchable:!0,onChange:t=>G(t),defaultSearchValue:M,onSearch:t=>(a.setFieldValue("savedSearchCity",t||""),A({countryId:I,search:t||void 0})),ItemSlot:({item:t})=>{var l,b;return e.jsxs("div",{className:h("flex flex-col gap-0"),children:[e.jsx("div",{children:t.label||t.value}),e.jsxs("div",{className:h("flex gap-1 items-center text-sm text-muted-foreground"),children:[e.jsx(Y,{code:(l=t==null?void 0:t.country)==null?void 0:l.code,size:12}),(b=t==null?void 0:t.country)==null?void 0:b.name]})]})},SelectedItemSlot:({item:t})=>{var l;return e.jsxs("div",{className:h("flex gap-1 items-center"),children:[e.jsx(Y,{code:(l=t==null?void 0:t.country)==null?void 0:l.code,size:12}),e.jsx("div",{children:(t==null?void 0:t.label)||(t==null?void 0:t.value)})]})}})}),_==="select"&&e.jsx(P,{to:".",search:s=>({...s,mode:"create"}),className:"text-conte-body-l justify-center",children:o("auth.register.create_city")}),e.jsx(a.AppField,{name:"city",validators:{onChange:({value:s,fieldApi:t})=>{if((t.form.getFieldValue("cityMode")||"select")==="create"&&v(s))return o("common:common.errors.required")}},children:s=>e.jsx(s.FormInput,{classNames:{wrapper:h(_==="select"&&"hidden")},autoComplete:"off",label:o("auth.register.create_city.city"),placeholder:o("auth.register.create_city.city.placeholder")})}),e.jsx("div",{className:h("flex flex-col items-center mt-4.5 gap-4.5"),children:e.jsxs(Z,{onClick:z,loading:!!x,disabled:!N,children:[o("auth.register.next"),e.jsx(pe,{})]})})]})}}),Q=je({defaultValues:{step:1,cityMode:"select",ref:void 0,country:null,countryCode:null,region:null,city:null,cityId:null,taxpayerNumber:null,companyName:null,companyAddress:null,lastName:null,firstName:null,position:null,email:null,phone:null,password:null,password2:null,personalDataPolicyAgreement:!1,savedSearchCity:""}}),E={1:["step","country","region","cityId","city","savedSearchCity","countryCode"],2:["step","ref","companyName","companyAddress","taxpayerNumber"],3:["step","lastName","firstName","position","email","phone","password","password2","countryCode","personalDataPolicyAgreement"]},J=E[2],oe=50,ie=255,le=255,$e=te({props:{onSubmit:()=>{},setStepIsValid:(p=!1)=>{}},render:function({group:a,onSubmit:u,setStepIsValid:n}){const{t:c}=R(["auth","common"]),{ref:o}=W({strict:!1});S.useLayoutEffect(()=>{o&&a.setFieldValue("ref",o)},[a,o]);const{isSubmitting:m,isValid:j}=O(a.form.store,r=>{const f=T(r.fieldMeta,J);return{isSubmitting:r.isSubmitting,isValid:f,isFieldsValidating:a.form.state.isFieldsValidating,fieldMeta:r.fieldMeta,errors:Object.values(r.fieldMeta).flatMap(g=>g.errors)}}),y=async()=>{await ee(a.form,J);const r=T(a.form.state.fieldMeta,J);n(r),r&&(u==null||u())};return e.jsxs(e.Fragment,{children:[e.jsx(a.AppField,{name:"companyName",validators:{onChange:({value:r})=>{if(v(r))return c("common:common.errors.required");if("".concat(r).length>ie)return c("auth.errors.max_length",{count:ie})}},children:r=>e.jsx(r.FormInput,{label:c("auth.register.company_name"),placeholder:c("auth.register.company_name.placeholder")})}),e.jsx(a.AppField,{name:"companyAddress",validators:{onChange:({value:r})=>{if(!v(r)&&"".concat(r).length>le)return c("auth.errors.max_length",{count:le})}},children:r=>e.jsx(r.FormInput,{label:c("auth.register.company_address"),placeholder:c("auth.register.company_address.placeholder")})}),e.jsx(a.AppField,{name:"taxpayerNumber",validators:{onChange:({value:r})=>{if(v(r))return c("common:common.errors.required");if("".concat(r).length>oe)return c("auth.errors.max_length",{count:oe})}},children:r=>e.jsx(r.FormInput,{label:c("auth.register.taxpayer_number"),placeholder:c("auth.register.taxpayer_number.placeholder")})}),e.jsx("div",{className:h("flex flex-col items-center mt-4.5 gap-4.5"),children:e.jsxs(Z,{onClick:y,loading:m,disabled:!j,children:[c("auth.register.next"),e.jsx(pe,{})]})})]})}}),Ge=we({...Q,props:{onBack:()=>{}},render:function({form:a,onBack:u}){const{t:n}=R("auth"),c=S.useMemo(()=>{const{lastName:o,firstName:m}=a.state.values;return[o,m].join(" ")},[a.state.values]);return e.jsxs(De,{title:n("auth.register.success.title"),icon:e.jsx(xe,{className:h("text-green")}),onBack:u,children:[e.jsx("div",{children:n("auth.register.success.thanks",{user:c})}),e.jsx("div",{children:n("auth.register.success.request")}),e.jsx("div",{children:n("auth.register.success.mail")})]})}}),B=E[3],ce=100,de=100,ue=255,me=60,Xe=te({props:{setStepIsValid:(p=!1)=>{}},render:function({group:a,setStepIsValid:u}){var y;const{t:n}=R(["auth","common"]),{isSubmitting:c,isValid:o,countryCode:m}=O(a.form.store,r=>{var g;const f=T(r.fieldMeta,B);return{isSubmitting:r.isSubmitting,isValid:f,isFieldsValidating:a.form.state.isFieldsValidating,fieldMeta:r.fieldMeta,errors:Object.values(r.fieldMeta).flatMap(F=>F==null?void 0:F.errors),countryCode:(g=r.values.countryCode)!=null?g:null}}),j=async()=>{V.debug("[reg] step3 onClick: start",{isSubmitting:c,isValid:o}),await ee(a.form,B);const r=T(a.form.state.fieldMeta,B),f=B.filter(g=>{var F,A;return!!((A=(F=a.form.getFieldMeta(g))==null?void 0:F.errors)!=null&&A.length)});V.debug("[reg] step3 validateFieldsOnSubmit done",{isStepValid:r,errFields:f}),u(r)};return e.jsxs(e.Fragment,{children:[e.jsx(a.AppField,{name:"lastName",validators:{onChange:({value:r})=>{if(v(r))return n("common:common.errors.required");if("".concat(r).length>ce)return n("auth.errors.max_length",{count:ce})}},children:r=>e.jsx(r.FormInput,{label:n("auth.register.last_name"),placeholder:n("auth.register.last_name.placeholder")})}),e.jsx(a.AppField,{name:"firstName",validators:{onChange:({value:r})=>{if(v(r))return n("common:common.errors.required");if("".concat(r).length>de)return n("auth.errors.max_length",{count:de})}},children:r=>e.jsx(r.FormInput,{label:n("auth.register.first_name"),placeholder:n("auth.register.first_name.placeholder")})}),e.jsx(a.AppField,{name:"position",validators:{onChange:({value:r})=>{if("".concat(r).length>ue)return n("auth.errors.max_length",{count:ue})}},children:r=>e.jsx(r.FormInput,{label:n("auth.register.position"),placeholder:n("auth.register.position.placeholder")})}),e.jsx(a.AppField,{name:"email",validators:{onChange:({value:r})=>{if(v(r))return n("common:common.errors.required");if("".concat(r).length>me)return n("auth.errors.max_length",{count:me})}},children:r=>e.jsx(r.FormInput,{label:n("auth.register.email"),placeholder:n("auth.register.email.placeholder"),autoComplete:"email"})}),e.jsx(a.AppField,{name:"phone",validators:{onChange:({value:r})=>{if(v(r))return n("auth.errors.phone_empty")}},children:r=>
1e.jsx(r.FormPhone,{label:n("auth.register.phone"),autoComplete:"tel",defaultCountryIso2:m!=null?m:void 0,onChange:(f,g)=>{V.debug("Phone:",g),a.setFieldValue("phone",g==null?void 0:g.phone)}})}),e.jsxs("div",{className:h("space-y-3"),children:[e.jsx(a.AppField,{name:"password",validators:{onChange:({value:r})=>{if(v(r))return n("common:common.errors.required");if(typeof r=="string"&&(r.length<6||r.length>20))return n("auth.errors.password_bad_strlen")}},children:r=>e.jsx(r.FormPassword,{label:n("auth.register.password"),placeholder:n("auth.reset_new_password.password.placeholder")})}),e.jsx(a.AppField,{name:"password2",validators:{onChangeListenTo:["password"],onChange:({value:r,fieldApi:f})=>{if(Ve(f))return;const g=f.form.getFieldValue("password");if(!(!g&&!r)&&r!==g)return n("auth.errors.password_mismatch")}},children:r=>e.jsx(r.FormPassword,{placeholder:n("auth.reset_new_password.password_confirm.placeholder")})})]}),((y=L.features.pdConsent)==null?void 0:y.registerCheckbox)&&(m==="ru"||L.id==="b2bcafe"&&m==="by")&&e.jsx(a.AppField,{name:"personalDataPolicyAgreement",validators:{onChange:({value:r})=>r?void 0:n("common:common.errors.required")},children:r=>{const f=r.state.meta.isTouched&&!r.state.meta.isValid,g=L.id==="b2bcafe";return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:h("flex items-start gap-3 cursor-pointer select-none text-conte-body-m text-foreground"),children:[e.jsx(_e,{checked:!!r.state.value,onCheckedChange:F=>r.handleChange(!!F),className:h("mt-0.5 shrink-0",f&&"border-destructive")}
1),e.jsxs("span",{children:[n("auth.register.pd_consent.prefix"),e.jsx(P,{to:"/conditions",search:{country:m!=null?m:void 0},hash:"agreement",target:"_blank",variant:"underline",className:"inline",children:n("auth.register.pd_consent.consent_link")}),n("auth.register.pd_consent.middle"),e.jsx(P,{to:"/conditions",search:{country:m!=null?m:void 0},hash:g?"confident":"personal_data_policy",target:"_blank",variant:"underline",className:"inline",children:n(g?"auth.register.pd_consent.policy_link_cafe":"auth.register.pd_consent.policy_link")}),n("auth.register.pd_consent.suffix")]})]}),e.jsx(ve,{errors:r.state.meta.errors})]})}}),e.jsx("div",{className:h("flex flex-col items-center mt-4.5 gap-4.5"),children:e.jsx(Z,{type:"submit",onClick:j,loading:c,disabled:!o,children:n("auth.register.submit")})})]})}}),K=p=>p!=null&&p.length?Object.fromEntries(p.map(a=>[a,a])):{},{securityRegister:Be}=Ne(),he=3,ze=[1,2,3];function He(){const p=Se({from:"/register"}),{t:a}=R(["auth","common"]),u=L.features.auth.defaultCity,n=Te({...Q,...u&&{defaultValues:{...Q.defaultValues,country:u.countryId,countryCode:u.countryCode,region:u.regionId,cityId:u.cityId,city:u.cityName,savedSearchCity:u.cityName}},validators:{onSubmit:()=>null},onSubmit:async({value:i})=>{var x,N;V.debug("[reg] form.onSubmit called",{value:i});const d={...i};delete d.cityId,delete d.cityMode,delete d.step,delete d.savedSearchCity;try{const M=await Be(d);V.debug("Success registration:",M),f(4)}catch(M){const _=M;Ie(n,_==null?void 0:_.data);const D=(N=(x=_==null?void 0:_.data)==null?void 0:x.result)==null?void 0:N.errors;if(D){let I=0;ze.forEach(w=>{var $;const q=!(($=E[String(w)])!=null&&$.some(z=>{var G;return!!((G=D[z])!=null&&G.length)}));j(w,q),!I&&!q&&(I=w)}),f(I||3)}}}}),{mode:c="select"}=W({strict:!1}),[o,m]=S.useState(()=>Object.fromEntries(Array.from({length:he},(i,d)=>[d,!1]))),j=(i,d=!1)=>{m(x=>({...x,[i]:d}))},{step:y,countryCode:r}=O(n.store,i=>{var d;return{step:i.values.step,countryCode:(d=i.values.countryCode)!=null?d:null}}),f=i=>{n.setFieldValue("step",i||1)},g=S.useCallback(()=>{if(!ne)return;const i=n.state.values;Me(JSON.stringify(i,null,2)),V.info("[reg] DEV copy: знаÑÐµÐ½Ð¸Ñ ÑоÑÐ¼Ñ ÑкопиÑÐ¾Ð²Ð°Ð½Ñ Ð² бÑÑеÑ",i)},[n]),F=S.useCallback(i=>{if(ne)try{const d=JSON.parse(i);if(typeof d!="object"||d===null)return;Object.entries(d).forEach(([x,N])=>{n.setFieldValue(x,N,{dontValidate:!0})}),typeof d.step=="number"&&f(d.step),d.cityMode&&d.cityMode!==c&&p({search:x=>({...x,mode:d.cityMode})}),V.info("[reg] DEV paste: ÑоÑма заполнена из бÑÑеÑа",d)}catch(d){}},[n,c]);ke(g),Le(F);const A=()=>y===4?p({to:"/"}):y===3?(ae(n,E[3]).then(i=>{j(3,i)}),f(2)):y===2?(ae(n,E[2]).then(i=>{j(2,i)}),f(1)):p(c==="create"?{to:"."}:{to:"/"});return y===4?e.jsx(Ge,{form:n,onBack:A}):e.jsx(Ee,{steps:he,step:y,stepIsValid:o,onChangeStep:f,title:a("auth.register.title"),countryCode:r,globalError:e.jsx(n.AppForm,{children:e.jsx(n.FormError,{})}),onBack:A,footer:e.jsxs("div",{className:h("flex flex-col gap-1 text-conte-body-l text-center text-foreground mt-10.5"),children:[e.jsxs("div",{className:h("text-center text-foreground"),children:[a("auth.register.sign_in_desktop.1"),a("auth.register.sign_in_desktop.2"),e.jsxs(P,{to:"/login",className:h("inline-flex items-center gap-1 text-primary hover:underline cursor-pointer"),children:[a("auth.register.sign_in_desktop.3"),e.jsx(ye,{className:h("size-4 inline-block")})]}),L.features.auth.showPhoneLogin&&e.jsxs(e.Fragment,{children:[a("auth.register.sign_in_desktop.4"),e.jsxs(P,{to:"/login_phone",className:h("inline-flex items-center gap-0.5 text-primary hover:underline cursor-pointer"),children:[a("auth.register.sign_in_desktop.5"),e.jsx(be,{className:h("size-4 inline-block")})]}),a("auth.register.sign_in_desktop.6")]})]}),e.jsx(Ae,{children:i=>e.jsx("div",{className:h("flex flex-col gap-1 text-conte-body-l text-center text-foreground"),children:e.jsxs("div",{className:h("text-center text-foreground"),children:[a("auth.register.have_questions")," â ",i]})})})]}),children:e.jsxs("form",{onSubmit:i=>{i.preventDefault();const d=Object.entries(n.state.fieldMeta).filter(([,x])=>{var N;return Object.values((N=x==null?void 0:x.errorMap)!=null?N:{}).some(Boolean)}).map(([x,N])=>({name:x,errors:N.errorMap}));V.debug("[reg] form.onSubmit (html) fired",{step:y,canSubmit:n.state.canSubmit,isSubmitting:n.state.isSubmitting,isValidating:n.state.isFieldsValidating,isValid:n.state.isValid,invalidFields:d}
1),V.debug("[reg] invalid field names:",d.map(x=>"".concat(x.name,": ").concat(JSON.stringify(x.errors)))),n.handleSubmit()},className:h("flex-1 flex flex-col gap-6"),children:[e.jsx(S.Activity,{mode:y===1?"visible":"hidden",children:e.jsx(qe,{form:n,fields:K(E[1]),onSubmit:()=>f(2),setStepIsValid:i=>j(1,i)})}),e.jsx(S.Activity,{mode:y===2?"visible":"hidden",children:e.jsx($e,{form:n,fields:K(E[2]),onSubmit:()=>f(3),setStepIsValid:i=>j(2,i)})}),e.jsx(S.Activity,{mode:y===3?"visible":"hidden",children:e.jsx(Xe,{form:n,fields:K(E[3]),setStepIsValid:i=>j(3,i)})})]})})}const nt=He;export{nt as component};
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.