1import{ax as ne,a8 as oe,D as le,aq as de,ay as ce,E as me,F as xe,r as x,s as R,av as he,az as ue,aw as pe,au as ve,j as e,J as m,L as j,S as je,aA as T,aB as V,C as y,a as b,f as P,g as o,m as E,aC as d,aD as h,A as D,aE as K,aF as $,aG as fe,aH as A,aI as Ne,aJ as ge}from"./index-DtWc3ksa.js";import{C as Z}from"./checkbox-BA4VcER5.js";import{isValidPsc as ye,normalizePsc as be,buyerSchema as ke,zodErrorsToFieldMap as ze}from"./validation-BfMvabl3.js";import{u as Ce}from"./useEmailDomainCheck-ChgGrvIs.js";import{S as J}from"./shield-check-DBsavTlQ.js";import"./check-DOUVeXqJ.js";import"./types-Cmz3OaHG.js";const G=["VaÅ¡e údaje","Rekapitulace","PotvrzenÃ"],_e={firstName:"",lastName:"",email:"",phone:"",street:"",city:"",zip:"",ico:""},Oe=()=>{const{id:I}=ne(),[L]=oe(),U=le(),{toast:f}=de(),{property:s,loading:q}=ce(I),{properties:H}=me(),M=H.filter(t=>t.type==="pozemek"&&t.status==="volne"&&!xe.has(t.id)),S=L.get("plot"),i=S?M.find(t=>t.id===S):null,[v,k]=x.useState(0),[a,W]=x.useState(_e),[z,Q]=x.useState(!1),[C,X]=x.useState(!1),[F,B]=x.useState(!1),[u,Y]=x.useState(null),[r,ee]=x.useState({}),l=Ce(),se=x.useCallback(async()=>{if(s){if(!s.dbId){f({title:"Chyba",description:"Nemovitost nelze rezervovat online.",variant:"destructive"});return}B(!0);try{const{data:t,error:n}=await R.functions.invoke("create-reservation",{body:{property_id:s.dbId,plot_id:(i==null?void 0:i.dbId)||null,buyer:{firstName:a.firstName.trim(),lastName:a.lastName.trim(),email:a.email.trim(),phone:a.phone.trim(),street:a.street.trim(),city:a.city.trim(),zip:a.zip.trim(),ico:a.ico.trim()},consent:{terms_agreed:z,early_performance_1837a:C,timestamp:new Date().toISOString(),user_agent:typeof navigator<"u"?navigator.userAgent.
1slice(0,200):null}}});if(n||!(t!=null&&t.success))throw new Error((t==null?void 0:t.error)||(n==null?void 0:n.message)||"Rezervaci se nepodarilo dokoncit");Y({contract_url:t.contract_url,invoice_url:t.invoice_url});const p=a.email.trim(),N=a.phone.trim(),O=N.replace(/[\s().\-/]/g,""),w={contact_method:p&&N?"email_phone":p?"email_only":N?"phone_only":"none",has_email:!!p,has_phone:!!N,email_domain:p.includes("@")?p.split("@")[1].toLowerCase():"",phone_prefix:O.startsWith("+")?O.slice(0,4):"local",is_company:!!a.ico.trim()};he("reservation",{lead_type:"prebooking",property_id:s.dbId,property_type:s.type,value:s.price??0,...w}),ue({propertyId:s.dbId,propertyType:s.type,propertyName:s.name,plotId:i==null?void 0:i.dbId,value:s.price??0,extra:w}),pe("prebooking_complete",{property_id:s.dbId,property_type:s.type,plot_id:(i==null?void 0:i.dbId)??"",value:s.price??0,currency:"CZK",...w});try{const{data:g}=await R.from("leads").select("id").eq("email",a.email.trim()).order("created_at",{ascending:!1}).limit(1).maybeSingle();g!=null&&g.id&&await ve(g.id,`${a.firstName} ${a.lastName}`.trim(),s.dbId||void 0)}catch{}k(2)}catch(t){f({title:"Rezervaci se nepodarilo dokoncit",description:t.message||"Zkuste to prosim znovu.",variant:"destructive"})}finally{B(!1)}}},[s,i,a,f]);if(q)return e.jsx("div",{className:"min-h-screen page-top flex items-center justify-center",children:e.jsx("div",{className:"animate-pulse text-muted-foreground",children:"NaÄÃtánÃ..."})});if(!s||s.status!=="volne")return e.jsx("div",{className:"min-h-screen page-top flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"font-serif text-2xl font-bold mb-4",children:"Nemovitost nenà dostupná"}),e.jsx(m,{asChild:!0,children:e.jsx(j,{to:"/nabidka/pozemky",children:"ZpÄt na nabÃdku"})})]})});if(s.requiresPlotSelection&&!i)return e.jsx("div",{className:"min-h-screen page-top flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"font-serif text-2xl font-bold mb-4",children:"Nejprve vyberte pozemek"}),e.jsx(m,{asChild:!0,children:e.jsx(j,{to:`/nemovitost/${s.id}`,children:"ZpÄt na výbÄr pozemku"})})]})});const _=i?s.price+i.price:s.price,c=(t,n)=>W(p=>({...p,[t]:n})),te=()=>{const t=ke.safeParse(a),n=t.success?{}:ze(t.error);return l.hardError&&(n.email=l.hardError),n},ae=a.firstName&&a.lastName&&a.email&&a.phone&&!l.hardError,re=()=>{const t=te();ee(t),Object.keys(t).length===0&&(fe({step:1,stepName:"buyer_details",propertyId:s.dbId??void 0,propertyType:s.type,propertyName:s.name,plotId:(i==null?void 0:i.dbId)??void 0,value:_}),k(1))},ie=()=>{f({title:"Objednávka odeslána!",description:"Budeme vás kontaktovat do 24 hodin."}),U(`/dekujeme?property=${s.id}&name=${encodeURIComponent(a.firstName)}`)};return e.jsxs("div",{className:"min-h-screen page-top pb-40 md:pb-56",children:[e.jsx(je,{title:"Objednávka | Resort KvÄtnová",description:"DokonÄete objednávku nemovitosti v Resortu KvÄtnová.",path:`/objednavka/${I}`,noindex:!0}),e.jsxs("div",{className:"container max-w-3xl",children:[e.jsx("h1",{className:"sr-only",children:"DokonÄenà rezervace nemovitosti"}),e.jsxs(j,{to:`/nemovitost/${s.id}`,className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-primary mb-6",children:[e.jsx(T,{className:"h-4 w-4"})," ZpÄt na detail"]}),e.jsx("div",{className:"flex items-center justify-center gap-2 mb-10",children:G.map((t,n)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:` 2 flex items-center justify-center w-8 h-8 rounded-full text-sm font-bold 3 ${n<=v?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"} 4 `,children:n<v?e.jsx(V,{className:"h-5 w-5"}):n+1}),e.jsx("span",{className:`text-sm hidden sm:inline ${n<=v?"font-medium":"text-muted-foreground"}`,children:t}),n<G.length-1&&e.jsx("div",{className:"w-8 h-px bg-border"})]},t))}),e.jsx(y,{className:"mb-8 bg-card",children:e.jsx(b,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("img",{src:s.image,alt:"",className:"w-16 h-12 object-cover rounded",loading:"lazy",decoding:"async"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-serif font-bold",children:s.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[P(s.area)," m²"]})]})]}),e.jsx("div",{className:"text-right",children:i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Dům: ",o(s.price)]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[i.name,": ",o(i.price)]}),e.jsxs("div",{className:"font-serif text-xl font-bold text-primary",children:["Celkem: ",o(_)]})]}):e.jsx("div",{className:"font-serif text-xl font-bold text-primary",children:o(s.price)})})]})})}),v===0&&e.jsxs(E.div,{initial:{opacity:0,x:20}
4,animate:{opacity:1,x:0},children:[e.jsx("h2",{className:"font-serif text-2xl font-bold mb-6",children:"Krok 1: VaÅ¡e údaje"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(d,{htmlFor:"firstName",children:"Jméno *"}),e.jsx(h,{id:"firstName",value:a.firstName,onChange:t=>c("firstName",t.target.value),placeholder:"Jan","aria-invalid":!!r.firstName}),r.firstName&&e.jsx("p",{className:"text-destructive text-xs mt-1",children:r.firstName})]}),e.jsxs("div",{children:[e.jsx(d,{htmlFor:"lastName",children:"PÅÃjmenà *"}),e.jsx(h,{id:"lastName",value:a.lastName,onChange:t=>c("lastName",t.target.value),placeholder:"Novák","aria-invalid":!!r.lastName}),r.lastName&&e.jsx("p",{className:"text-destructive text-xs mt-1",children:r.lastName})]}),e.jsxs("div",{children:[e.jsx(d,{htmlFor:"email",children:"E-mail *"}),e.jsx(h,{id:"email",type:"email",value:a.email,onChange:t=>c("email",t.target.value),onBlur:t=>l.check(t.target.value),placeholder:"[email protected]","aria-invalid":!!(r.email||l.hardError)}),r.email&&e.jsx("p",{className:"text-destructive text-xs mt-1",children:r.email}),!r.email&&l.hardError&&e.jsx("p",{className:"text-destructive text-xs mt-1",children:l.hardError}),!r.email&&!l.hardError&&l.warning&&e.jsx("p",{className:"text-amber-600 text-xs mt-1",children:l.warning})]}),e.jsxs("div",{children:[e.jsx(d,{htmlFor:"phone",children:"Telefon *"}),e.jsx(h,{id:"phone",type:"tel",value:a.phone,onChange:t=>c("phone",t.target.value),placeholder:"+420 ...","aria-invalid":!!r.phone}
4),r.phone&&e.jsx("p",{className:"text-destructive text-xs mt-1",children:r.phone})]}),e.jsxs("div",{children:[e.jsx(d,{htmlFor:"street",children:"Ulice a Ä.p."}),e.jsx(h,{id:"street",value:a.street,onChange:t=>c("street",t.target.value),"aria-invalid":!!r.street}),r.street&&e.jsx("p",{className:"text-destructive text-xs mt-1",children:r.street})]}),e.jsxs("div",{children:[e.jsx(d,{htmlFor:"city",children:"MÄsto"}),e.jsx(h,{id:"city",value:a.city,onChange:t=>c("city",t.target.value),"aria-invalid":!!r.city}),r.city&&e.jsx("p",{className:"text-destructive text-xs mt-1",children:r.city})]}),e.jsxs("div",{children:[e.jsx(d,{htmlFor:"zip",children:"PSÄ"}),e.jsx(h,{id:"zip",value:a.zip,onChange:t=>c("zip",t.target.value),onBlur:t=>c("zip",ye(t.target.value)?be(t.target.value):t.target.value),placeholder:"36301","aria-invalid":!!r.zip}),r.zip&&e.jsx("p",{className:"text-destructive text-xs mt-1",children:r.zip})]}),e.jsxs("div",{children:[e.jsx(d,{htmlFor:"ico",children:"IÄO (volitelné)"}),e.jsx(h,{id:"ico",value:a.ico,onChange:t=>c("ico",t.target.value),placeholder:"27074358","aria-invalid":!!r.ico}),r.ico&&e.jsx("p",{className:"text-destructive text-xs mt-1",children:r.ico})]})]}),e.jsx("div",{className:"flex justify-end mt-8",children:e.jsxs(m,{onClick:re,disabled:!ae,size:"lg",children:["PokraÄovat ",e.jsx(D,{className:"ml-2 h-4 w-4"})]})})]}),v===1&&e.jsxs(E.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},children:[e.jsx("h2",{className:"font-serif text-2xl font-bold mb-6",children:"Krok 2: Rekapitulace objednávky"}),e.jsx(y,{className:"mb-6",children:e.jsxs(b,{className:"p-6 space-y-4",children:[e.jsx("h3",{className:"font-serif font-semibold text-lg",children:"Nemovitost"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsx("div",{className:"text-muted-foreground",children:"Název:"}),e.jsx("div",{className:"font-medium",children:s.name}),e.jsx("div",{className:"text-muted-foreground",children:"VýmÄra:"}),e.jsxs("div",{className:"font-medium",children:[P(s.area)," m²"]}),e.jsx("div",{className:"text-muted-foreground",children:"Cena:"}),e.jsx("div",{className:"font-medium text-primary",children:o(s.price)}),i&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-muted-foreground",children:"Pozemek:"}),e.jsxs("div",{className:"font-medium",children:[i.name," (",P(i.area)," m²)"]}),e.jsx("div",{className:"text-muted-foreground",children:"Cena pozemku:"}),e.jsx("div",{className:"font-medium",children:o(i.price)}),e.jsx("div",{className:"text-muted-foreground font-semibold",children:"Celkem:"}),e.jsx("div",{className:"font-bold text-primary",children:o(_)})]}),e.jsx("div",{className:"text-muted-foreground",children:"PÅedrezervaÄnà poplatek:"}),e.jsx("div",{className:"font-medium",children:o(A)})]}),e.jsxs("div",{className:"rounded-md bg-muted/40 border border-border/50 p-3 text-xs text-muted-foreground space-y-1",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Služby spojené s pÅedrezervacÃ"}),e.jsx("span",{className:"font-medium",children:o(Ne)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"UmÃstÄnà domu na pozemek od projektanta"}),e.jsx("span",{className:"font-medium",children:o(ge)})]}),e.jsxs("div",{className:"pt-1 border-t border-border/40 leading-snug space-y-1",children:[e.jsx("div",{children:"Splatnost 14 dnů, fakturu vám zaÅ¡leme e-mailem. PÅi uzavÅenà kupnà smlouvy se poplatek plnÄ zapoÄÃtává do kupnà ceny."}),e.jsxs("div",{children:[e.jsx("strong",{children:"Poplatek je nevratný."})," PÅedrezervace vás ",e.jsx("strong",{children:"nezavazuje ke koupi"})," â pozemek pro vás blokujeme na ",e.jsx("strong",{children:"3 mÄsÃce"}),", abyste stihli vyÅÃdit financovánà (hypotéka, odhad) a dalšà záležitosti."]})]})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h3",{className:"font-serif font-semibold text-lg mb-2",children:"KupujÃcÃ"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsx("div",{className:"text-muted-foreground",children:"Jméno:"}),e.jsxs("div",{className:"font-medium",children:[a.firstName," ",a.lastName]}),e.jsx("div",{className:"text-muted-foreground",children:"E-mail:"}),e.jsx("div",{className:"font-medium",children:a.email}),e.jsx("div",{className:"text-muted-foreground",children:"Telefon:"}),e.jsx("div",{className:"font-medium",children:a.phone}),a.street&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-muted-foreground",children:"Adresa:"}),e.jsxs("div",{className:"font-medium",children:[a.street,", ",a.city," ",a.zip]})]})]})]})]})}),e.jsxs("div",{className:"space-y-3 mb-6",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Z,{id:"agree",checked:z,onCheckedChange:t=>Q(t)}),e.jsxs(d,{htmlFor:"agree",className:"text-sm text-muted-foreground leading-relaxed",children:["PÅeÄetl/a jsem si ",e.jsx(j,{to:"/obchodni-podminky",target:"_blank",className:"underline text-gold",onClick:()=>K({documentType:"terms_and_conditions",documentName:"VÅ¡eobecné obchodnà podmÃnky",placement:"checkout-consent",propertyId:s==null?void 0:s.dbId,propertyType:s==null?void 0:s.type}),children:"VÅ¡eobecné obchodnà podmÃnky"})," a"," ",e.jsx(j,{to:"/gdpr",target:"_blank",className:"underline text-gold",onClick:()=>K({documentType:"privacy_policy",documentName:"Informace o zpracovánà osobnÃch údajů",placement:"checkout-consent",propertyId:s==null?void 0:s.dbId,propertyType:s==null?void 0:s.type}),children:"informace o zpracovánà osobnÃch údajů"})," a souhlasÃm s nimi. Beru na vÄdomÃ, že obchodnà zástupce ProdávajÃcÃho mÄ bude následnÄ kontaktovat."]})]}),e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-line bg-muted/30 p-3",children:[e.jsx(Z,{id:"early-perf",checked:C,onCheckedChange:t=>X(t)}),e.jsxs(d,{htmlFor:"early-perf",className:"text-sm text-muted-foreground leading-relaxed",children:[e.jsx("strong",{className:"text-foreground",children:"Výslovná žádost o zahájenà plnÄnà pÅed uplynutÃm lhůty pro odstoupenà (§ 1837 pÃsm. a) OZ):"})," žádám ProdávajÃcÃho, aby s poskytovánÃm sjednané služby (blokace nemovitosti, administrace rezervace a zpracovánà umÃstÄnà domu na pozemek) zahájil ihned po potvrzenà objednávky, tedy pÅed uplynutÃm 14dennà lhůty pro odstoupenÃ. Beru na vÄdomÃ, že"," ",e.jsx("strong",{className:"text-foreground",children:"úplným splnÄnÃm této služby ztrácÃm právo od smlouvy odstoupit"})," ","a pÅedrezervaÄnà poplatek 30 000 KÄ se v tomto rozsahu stává nevratným. Postup je podrobnÄ popsán v Äl. VI VOP."]}
4)]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(m,{variant:"outline",onClick:()=>k(0),children:[e.jsx(T,{className:"mr-2 h-4 w-4"})," ZpÄt"]}),e.jsxs(m,{onClick:se,disabled:!z||!C||F,size:"lg",className:"bg-green-600 hover:bg-green-700 text-white",children:[F?"OdesÃlám...":"ZávaznÄ objednat a zahájit rezervaci"," ",e.jsx(D,{className:"ml-2 h-4 w-4"})]})]})]}),v===2&&e.jsxs(E.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:"text-center",children:[e.jsx("div",{className:"w-20 h-20 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-6",children:e.jsx(V,{className:"h-10 w-10 text-green-600"})}),e.jsx("h2",{className:"font-serif text-3xl font-bold mb-4",children:"Gratulujeme k vaÅ¡emu rozhodnutÃ!"}),e.jsx("p",{className:"text-muted-foreground text-lg max-w-lg mx-auto mb-8",children:"Jsme rádi, že jste se rozhodli vybudovat svou budoucnost s námi. DÄláme vÅ¡e pro vaÅ¡i spokojenost a tÄÅ¡Ãme se na spoleÄnou cestu k vaÅ¡emu novému domovu."}),u&&(u.contract_url||u.invoice_url)&&e.jsx(y,{className:"max-w-md mx-auto mb-6",children:e.jsxs(b,{className:"p-6 text-left",children:[e.jsxs("h3",{className:"font-serif font-semibold mb-4 flex items-center gap-2",children:[e.jsx(J,{className:"h-5 w-5 text-primary"})," VaÅ¡e dokumenty"]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"RezervaÄnà smlouva a zálohová faktura jsou pÅipraveny ke staženÃ. Kopii zasÃláme i emailem."}),e.jsxs("div",{className:"flex flex-col gap-2",children:[u.contract_url&&e.jsx(m,{asChild:!0,variant:"outline",size:"sm",children:e.jsx("a",{href:u.contract_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>$({documentType:"reservation_contract",propertyId:s==null?void 0:s.id,propertyType:s==null?void 0:s.type,propertyName:s==null?void 0:s.name}),children:"Stáhnout rezervaÄnà smlouvu (PDF)"})}),u.invoice_url&&e.jsx(m,{asChild:!0,variant:"outline",size:"sm",children:e.jsx("a",{href:u.invoice_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>$({documentType:"proforma_invoice",propertyId:s==null?void 0:s.id,propertyType:s==null?void 0:s.type,propertyName:s==null?void 0:s.name}),children:"Stáhnout zálohovou fakturu (PDF)"})})]})]})}),e.jsx(y,{className:"max-w-md mx-auto mb-8",children:e.jsxs(b,{className:"p-6 text-left",children:[e.jsxs("h3",{className:"font-serif font-semibold mb-4 flex items-center gap-2",children:[e.jsx(J,{className:"h-5 w-5 text-primary"})," Co bude následovat"]}),e.jsx("div",{className:"space-y-4",children:[{time:"Do 24 hodin",text:"Budeme vás kontaktovat pro domluvenà schůzky"},{time:"Ãhrada zálohy",text:`UhraÄte pÅedrezervaÄnà poplatek ${o(A)} (5 000 KÄ služby + 25 000 KÄ umÃstÄnà domu od projektanta) do 14 dnů. Poplatek je nevratný, ale rezervuje pro vás pozemek na 3 mÄsÃce â bez závazku ke koupi. Fakturu vám zaÅ¡leme e-mailem.`},{time:"Podpis smlouvy",text:"Osobnà setkánà a podpis dohody o pÅedrezervaci"},...s.type==="dum"?[{time:"Stavebnà povolenÃ",text:"VyÅÃzenà povolenà â cca 2 mÄsÃce"},{time:"Výstavba",text:"Realizace domu â cca 12 mÄsÃců"}]:[],{time:"PÅedánÃ",text:"PÅedánà nemovitosti a zahájenà vašà nové kapitoly"}].map((t,n)=>e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-accent mt-2 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:t.time}),e.jsx("div",{className:"text-sm text-muted-foreground",children:t.text})]})]},n))})]})}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 justify-center",children:[e.jsx(m,{onClick:ie,size:"lg",className:"bg-green-600 hover:bg-green-700 text-white",children:"DokonÄit"}),e.jsx(m,{asChild:!0,variant:"outline",size:"lg",children:e.jsx(j,{to:"/",children:"ZpÄt na hlavnà stránku"})})]})]})]})]})};export{Oe as default};
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.