import{j as e}from"./ui-vendor-ChZMp8UW.js";import{u as a}from"./useQuery-D0lkQCfK.js";import{B as s,t as i,s as t,S as o,H as r}from"./index-kLDukJJH.js";import{H as n}from"./Header-BhKe-yvd.js";import{F as l}from"./Footer-DENxtm0h.js";import{S as c}from"./SEOHead-4QDTPfQ2.js";import{p as d,T as m}from"./city-slug-parser-4W9YsBPA.js";import{r as h,h as u}from"./react-vendor-SJkaNtXX.js";import{I as v}from"./input-Cxi15lE5.js";import{L as p}from"./label-DNBxKrnC.js";import{T as x}from"./textarea-TiNaqBH-.js";import{f,v as j,a as g,b as y}from"./validators-B6ObMgjW.js";import{K as b,L as N,g as w,S as _,k as S}from"./icons-BXTKTZdO.js";import"./supabase-vendor-CkDt80Sz.js";import"./logo-oficial-BW9aD_Pb.js";import"./alert-CXdMUDXy.js";function C({citySlug:a,cityName:o,state:r,pickupLocation:n}){const[l,c]=h.useState(!1),[d,m]=h.useState({nome:"",email:"",telefone:"",vehicleInfo:"",observations:""});return e.jsxs("form",{onSubmit:async e=>{var s,l;e.preventDefault();const h=j(d.nome);if(!h.valid)return void i({title:"Erro no nome",description:h.message,variant:"destructive"});const u=g(d.email);if(!u.valid)return void i({title:"Erro no e-mail",description:u.message,variant:"destructive"});const v=y(d.telefone);if(!v.valid)return void i({title:"Erro no telefone",description:v.message,variant:"destructive"});if(!n)return void i({title:"Localização não selecionada",description:"Por favor, selecione sua localização no mapa acima.",variant:"destructive"});c(!0);let p=null,x=null,f=null;try{const{error:e}=await t.from("locksmith_requests").insert({city_slug:a,city_name:o,state:r,client_name:d.nome,client_email:d.email,client_phone:d.telefone,pickup_address:n.address,latitude:n.latitude,longitude:n.longitude,vehicle_info:d.vehicleInfo||null,observations:d.observations||null,status:"novo"});try{const e=await t.functions.invoke("call-locksmith-quotation",{body:{name:d.nome,email:d.email,phone:d.telefone,lat:n.latitude,lng:n.longitude,address:n.address,vehicleInfo:d.vehicleInfo,serviceType:"abertura_veiculo"}});e.error?f=e.error.message||"Erro ao chamar API de chaveiro":(p=(null==(s=e.data)?void 0:s.quotation_id)||null,x=(null==(l=e.data)?void 0:l.conversation_id)||null,(p||x)&&await t.from("locksmith_requests").update({external_quotation_id:p,external_conversation_id:x}).eq("client_email",d.email).eq("client_phone",d.telefone).order("created_at",{ascending:!1}).limit(1))}catch(b){f=b.message||"Erro de comunicação com API"}f&&await t.from("locksmith_requests").update({status:"pendente_externo",observations:`${d.observations||""}\n\n[ERRO API EXTERNA]: ${f}`.trim()}).eq("client_email",d.email).eq("client_phone",d.telefone).order("created_at",{ascending:!1}).limit(1),i({title:"Solicitação recebida com sucesso!",description:f?"Recebemos sua solicitação e nossa equipe entrará em contato em instantes.":"Você receberá uma mensagem no WhatsApp com um chaveiro disponível."}),m({nome:"",email:"",telefone:"",vehicleInfo:"",observations:""})}catch(N){i({title:"Erro ao enviar solicitação",description:N.message||"Tente novamente mais tarde.",variant:"destructive"})}finally{c(!1)}},className:"space-y-6 bg-card p-6 rounded-lg border border-border",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{className:"h-6 w-6 text-primary"}),e.jsx("h3",{className:"text-2xl font-bold",children:"Solicite um Chaveiro"})]}),e.jsx("p",{className:"text-muted-foreground",children:"Trancou a chave no carro? Preencha os dados e receba atendimento imediato"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"nome",children:"Nome *"}),e.jsx(v,{id:"nome",name:"nome",placeholder:"Seu nome",value:d.nome,onChange:e=>m({...d,nome:e.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"email",children:"E-mail *"}),e.jsx(v,{id:"email",name:"email",type:"email",placeholder:"seu@email.com",value:d.email,onChange:e=>m({...d,email:e.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"telefone",children:"Telefone *"}),e.jsx(v,{id:"telefone",name:"telefone",type:"tel",placeholder:"(00) 00000-0000",value:d.telefone,onChange:e=>m({...d,telefone:e.target.value}),onBlur:e=>m({...d,telefone:f(e.target.value)}),required:!0})]}),n&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{children:"Localização do veículo"}),e.jsx("div",{className:"p-3 bg-muted rounded-md text-sm",children:n.address})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"vehicleInfo",children:"Informações do veículo (opcional)"}),e.jsx(v,{id:"vehicleInfo",placeholder:"Ex: Gol Prata 2020, Placa ABC-1234",value:d.vehicleInfo,onChange:e=>m({...d,vehicleInfo:e.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Modelo, cor e placa ajudam o chaveiro a localizar seu veículo"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(p,{htmlFor:"observations",children:"Observações (opcional)"}),e.jsx(x,{id:"observations",placeholder:"Informações adicionais sobre a situação",value:d.observations,onChange:e=>m({...d,observations:e.target.value}),rows:3})]})]}),e.jsx(s,{type:"submit",className:"w-full",size:"lg",disabled:l,children:l?e.jsxs(e.Fragment,{children:[e.jsx(N,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):"Chamar Chaveiro Agora"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Ao enviar, você concorda com nossa política de privacidade"})]})}function q(){const{citySlug:s}=u(),[i,v]=h.useState("client"),[p,x]=h.useState(),f=d(s||""),{data:j,isLoading:g}=a({queryKey:["locksmith-city-page",s],queryFn:async()=>{const{data:e,error:a}=await t.from("locksmith_city_pages").select("*").eq("slug",s).eq("is_active",!0).maybeSingle();if(a)throw a;return e}});h.useEffect(()=>{(null==j?void 0:j.id)&&t.from("locksmith_city_pages").update({view_count:(j.view_count||0)+1}).eq("id",j.id).then(()=>{})},[null==j?void 0:j.id]);const y=(null==j?void 0:j.city_name)||f.cityName,N=(null==j?void 0:j.state_abbreviation)||f.stateAbbreviation,q=(null==j?void 0:j.state)||f.state,k=(null==j?void 0:j.hero_title)||`Chaveiro Automotivo 24h em ${y}`,L=(null==j?void 0:j.hero_subtitle)||`Serviço de chaveiro automotivo 24h em ${y} - ${N}. Abertura de veículos, cópia de chaves e suporte emergencial.`,A=(null==j?void 0:j.meta_title)||`Chaveiro em ${y} - ${N} | Atendimento 24h`,E=`Precisa de chaveiro automotivo em ${y}? Atendimento 24h para abertura de veículos, cópia de chaves e fechaduras. Ligue: 0800-111-8686.`,I=`/chaveiro/${s||""}`;if(g)return e.jsxs("div",{className:"min-h-screen",children:[e.jsx(c,{title:A,description:E,canonical:I}),e.jsx(n,{viewMode:i,onViewModeChange:v,showViewModeToggle:!1}),e.jsxs("div",{className:"container mx-auto px-4 py-16",children:[e.jsx(o,{className:"h-12 w-3/4 mb-4"}),e.jsx(o,{className:"h-6 w-1/2 mb-8"}),e.jsx(o,{className:"h-96 w-full"})]})]});const $={"@context":"https://schema.org","@type":"LocalBusiness",name:`Chaveiro Automotivo 24h em ${y}`,description:E,url:`https://semprecomigo.com.br/chaveiro/${s}`,telephone:"0800-111-8686",address:{"@type":"PostalAddress",addressLocality:y,addressRegion:N,addressCountry:"BR"},areaServed:{"@type":"City",name:y},parentOrganization:{"@type":"Organization",name:"Sempre Comigo"},openingHoursSpecification:{"@type":"OpeningHoursSpecification",dayOfWeek:["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],opens:"00:00",closes:"23:59"}},T={"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:[{"@type":"ListItem",position:1,name:"Home",item:"https://semprecomigo.com.br"},{"@type":"ListItem",position:2,name:"Chaveiro",item:"https://semprecomigo.com.br/assistencia-24h"},{"@type":"ListItem",position:3,name:y,item:`https://semprecomigo.com.br/chaveiro/${s}`}]};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(c,{title:A,description:E,canonical:I,keywords:`chaveiro ${y.toLowerCase()}, chaveiros em ${y.toLowerCase()}, chaveiro automotivo ${y.toLowerCase()}, chaveiro 24h ${y.toLowerCase()}, chaveiro veicular, abertura de veículo ${N}, chaveiro mais próximo`}),e.jsxs(r,{children:[e.jsx("script",{type:"application/ld+json",children:JSON.stringify($)}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify(T)})]}),e.jsx(n,{viewMode:i,onViewModeChange:v,showViewModeToggle:!1}),e.jsxs("section",{className:"relative h-[50vh] min-h-[400px] overflow-hidden bg-gradient-to-br from-primary via-primary/90 to-primary/70",children:[e.jsx("div",{className:"absolute inset-0 bg-black/30"}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",children:e.jsxs("div",{className:"text-center text-white px-4 max-w-4xl",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-20 h-20 bg-white/20 rounded-full mb-6",children:e.jsx(b,{className:"h-10 w-10 text-white"})}),e.jsx("h1",{className:"text-4xl md:text-5xl lg:text-6xl font-bold mb-4",children:k}),e.jsx("p",{className:"text-xl md:text-2xl mb-8",children:L}),e.jsx("a",{href:"#formulario",className:"inline-block",children:e.jsx("button",{className:"bg-white hover:bg-white/90 text-primary px-8 py-4 rounded-lg text-lg font-semibold transition-colors",children:"Chamar Chaveiro Agora"})})]})})]}),e.jsx("section",{className:"py-16 bg-muted/30",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"grid md:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(w,{className:"h-8 w-8 text-primary flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-lg mb-2",children:"Atendimento 24h"}),e.jsx("p",{className:"text-muted-foreground",children:"Estamos disponíveis todos os dias, a qualquer hora"})]})]}),e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(_,{className:"h-8 w-8 text-primary flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-lg mb-2",children:"Abertura Sem Danos"}),e.jsx("p",{className:"text-muted-foreground",children:"Técnicas profissionais que preservam seu veículo"})]})]}),e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(S,{className:"h-8 w-8 text-primary flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-lg mb-2",children:"Profissionais Especializados"}),e.jsx("p",{className:"text-muted-foreground",children:"Equipe treinada em abertura de veículos de todas as marcas"})]})]})]})})}),e.jsx("section",{id:"formulario",className:"py-16",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"grid lg:grid-cols-2 gap-8 items-start",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold mb-4",children:"Onde está seu veículo?"}),e.jsx("p",{className:"text-muted-foreground",children:"Detectamos automaticamente sua localização para enviar o chaveiro mais próximo"})]}),e.jsx(m,{onLocationSelect:x})]}),e.jsx("div",{className:"lg:sticky lg:top-4",children:e.jsx(C,{citySlug:s,cityName:y,state:q,pickupLocation:p})})]})})}),e.jsx(l,{})]})}export{q as default};