var __gh = require("react").createElement, __gf = require("react").Fragment; var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var stdin_exports={};__export(stdin_exports,{default:()=>stdin_default,featureConfig:()=>featureConfig});module.exports=__toCommonJS(stdin_exports);var dataSources=[{table:"tostadero__cafes",access:"public:read"}];var import_react=__toESM(require("react")),import_framer_motion=require("framer-motion"),import_lucide_react=require("lucide-react"),T={fondo:"#f6f1ea",papel:"#fffdf9",tinta:"#2b1a12",suave:"#7a6a5f",raya:"#e8dfd3",acento:"#2b1a12",serif:'"New York", "Iowan Old Style", Georgia, serif',sans:'-apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Inter, sans-serif'},EASE=[.22,1,.36,1],COLOR_BOLSA={1:"#b5562b",2:"#6b4a2f",3:"#c39a2e",4:"#3a2a20"},euros=n=>new Intl.NumberFormat("es-ES",{style:"currency",currency:"EUR",useGrouping:"always"}).format(n);function Bolsa({color,nombre,grande}){let w=grande?190:92;return __gh("svg",{width:w,height:w*1.28,viewBox:"0 0 100 128","aria-hidden":!0,style:{display:"block",filter:"drop-shadow(0 10px 14px rgba(43,26,18,0.18))"},"data-gufi-src":"page.tsx:23"},__gh("path",{d:"M14 14 L86 14 L92 120 Q92 126 86 126 L14 126 Q8 126 8 120 Z",fill:color,"data-gufi-src":"page.tsx:24"}),__gh("path",{d:"M14 14 L86 14 L84 24 L16 24 Z",fill:"rgba(0,0,0,0.18)","data-gufi-src":"page.tsx:25"}),__gh("rect",{x:"12",y:"4",width:"76",height:"12",rx:"2",fill:color,"data-gufi-src":"page.tsx:26"}),__gh("rect",{x:"22",y:"48",width:"56",height:"54",rx:"4",fill:"#f6efe3","data-gufi-src":"page.tsx:27"}),__gh("circle",{cx:"50",cy:"64",r:"9",fill:T.tinta,"data-gufi-src":"page.tsx:28"}),__gh("text",{x:"50",y:"68.5",textAnchor:"middle",fontFamily:T.serif,fontWeight:"700",fontSize:"13",fill:"#f2e4cf","data-gufi-src":"page.tsx:29"},"g"),__gh("text",{x:"50",y:"86",textAnchor:"middle",fontFamily:T.sans,fontWeight:"700",fontSize:nombre.length>14?5:6.4,fill:T.tinta,"data-gufi-src":"page.tsx:30"},nombre.toUpperCase()),__gh("text",{x:"50",y:"94",textAnchor:"middle",fontFamily:T.sans,fontSize:"4.6",fill:T.suave,"data-gufi-src":"page.tsx:31"},"en grano \xB7 1 kg"))}function Cabecera({onInicio}){return __gh("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 20px"},"data-gufi-src":"page.tsx:38"},__gh("button",{type:"button",onClick:onInicio,style:{display:"flex",alignItems:"center",gap:9,border:"none",background:"none",padding:0,cursor:"pointer",color:T.tinta},"data-gufi-src":"page.tsx:39"},__gh("span",{style:{width:30,height:30,borderRadius:99,background:T.tinta,color:"#f2e4cf",display:"grid",placeItems:"center",fontFamily:T.serif,fontWeight:700,fontSize:19,lineHeight:1,paddingBottom:3},"data-gufi-src":"page.tsx:40"},"g"),__gh("span",{style:{fontFamily:T.serif,fontSize:21,fontWeight:700,letterSpacing:"-0.4px"},"data-gufi-src":"page.tsx:41"},"Grano")),__gh("span",{style:{fontSize:12.5,color:T.suave},"data-gufi-src":"page.tsx:43"},"Tostado en Madrid"))}function Inicio({cafes,abrir}){return __gh(__gf,null,__gh("section",{style:{padding:"18px 20px 26px"},"data-gufi-src":"page.tsx:51"},__gh("h1",{style:{fontFamily:T.serif,fontSize:"clamp(32px, 9vw, 52px)",lineHeight:1.04,letterSpacing:"-1px",margin:0,fontWeight:700},"data-gufi-src":"page.tsx:52"},"Caf\xE9 reci\xE9n tostado, en tu barra ma\xF1ana."),__gh("p",{style:{fontSize:15,color:T.suave,margin:"12px 0 0",lineHeight:1.45},"data-gufi-src":"page.tsx:53"},"Tostamos cada pedido el d\xEDa que llega y te lo llevamos nosotros.")),__gh("section",{style:{padding:"0 14px 30px",display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(160px, 1fr))",gap:12},"data-gufi-src":"page.tsx:55"},cafes.map((c,k)=>__gh(import_framer_motion.motion.button,{key:c.id,type:"button",onClick:()=>abrir(c),initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.4,ease:EASE,delay:k*.04},style:{textAlign:"left",border:`1px solid ${T.raya}`,background:T.papel,borderRadius:18,padding:"18px 14px 14px",cursor:"pointer",fontFamily:T.sans,color:T.tinta}},__gh("div",{style:{display:"grid",placeItems:"center",height:132},"data-gufi-src":"page.tsx:59"},__gh(Bolsa,{color:COLOR_BOLSA[c.orden]??T.tinta,nombre:c.nombre})),__gh("div",{style:{fontWeight:650,fontSize:15,marginTop:12,letterSpacing:"-0.2px"},"data-gufi-src":"page.tsx:60"},c.nombre),__gh("div",{style:{fontSize:12.5,color:T.suave,marginTop:2},"data-gufi-src":"page.tsx:61"},c.notas),__gh("div",{style:{fontSize:14,fontWeight:600,marginTop:8,fontVariantNumeric:"tabular-nums"},"data-gufi-src":"page.tsx:62"},euros(Number(c.precio_kg))," ",__gh("span",{style:{fontWeight:400,color:T.suave,fontSize:12.5},"data-gufi-src":"page.tsx:62"},"el kilo"))))))}var campo={width:"100%",height:48,borderRadius:12,border:`1px solid ${T.raya}`,background:"#fff",padding:"0 14px",fontSize:16,color:T.tinta,fontFamily:T.sans,outline:"none",boxSizing:"border-box"},boton={width:"100%",height:52,borderRadius:14,border:"none",background:T.acento,color:"#fff",fontSize:16,fontWeight:650,fontFamily:T.sans,cursor:"pointer",fontVariantNumeric:"tabular-nums"};function Ficha({gufi,cafe,volver,hecho}){let[kg,setKg]=import_react.default.useState(1),[datos,setDatos]=import_react.default.useState(!1),[nombre,setNombre]=import_react.default.useState(""),[direccion,setDireccion]=import_react.default.useState(""),[enviando,setEnviando]=import_react.default.useState(!1),[error,setError]=import_react.default.useState(null),total=Math.round(Number(cafe.precio_kg)*kg*100)/100,pedir=async e=>{e.preventDefault(),setEnviando(!0),setError(null);try{let r=await gufi.publicAutomation("grano_pedido_web").run({cafeId:cafe.id,kg,nombre,direccion});hecho(r.numero)}catch(err){setError(err.message),setEnviando(!1)}};return __gh(import_framer_motion.motion.section,{initial:{opacity:0,x:18},animate:{opacity:1,x:0},transition:{duration:.35,ease:EASE},style:{padding:"4px 20px 32px"}},__gh("button",{type:"button",onClick:volver,"aria-label":"Volver",style:{display:"inline-flex",alignItems:"center",gap:6,border:"none",background:"none",padding:"6px 0",color:T.suave,fontSize:14,cursor:"pointer",fontFamily:T.sans},"data-gufi-src":"page.tsx:97"},__gh(import_lucide_react.ArrowLeft,{size:16})," Caf\xE9s"),__gh("div",{style:{display:"grid",placeItems:"center",padding:datos?"4px 0 10px":"14px 0 18px",transition:"padding 300ms ease"},"data-gufi-src":"page.tsx:100"},__gh(import_framer_motion.motion.div,{animate:{scale:datos?.62:1},transition:{duration:.4,ease:EASE},style:{transformOrigin:"center top",height:datos?160:"auto"}},__gh(Bolsa,{grande:!0,color:COLOR_BOLSA[cafe.orden]??T.tinta,nombre:cafe.nombre}))),__gh("h1",{style:{fontFamily:T.serif,fontSize:32,fontWeight:700,letterSpacing:"-0.6px",margin:0},"data-gufi-src":"page.tsx:105"},cafe.nombre),__gh("p",{style:{fontSize:14.5,color:T.suave,margin:"4px 0 0"},"data-gufi-src":"page.tsx:106"},cafe.origen," \xB7 ",cafe.notas),__gh("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:20,padding:"14px 0",borderTop:`1px solid ${T.raya}`,borderBottom:`1px solid ${T.raya}`},"data-gufi-src":"page.tsx:108"},__gh("span",{style:{fontSize:15,fontWeight:600},"data-gufi-src":"page.tsx:109"},"Kilos"),__gh("div",{style:{display:"flex",alignItems:"center",gap:14},"data-gufi-src":"page.tsx:110"},__gh("button",{type:"button","aria-label":"Menos",onClick:()=>setKg(Math.max(1,kg-1)),style:{width:38,height:38,borderRadius:99,border:`1px solid ${T.raya}`,background:"#fff",display:"grid",placeItems:"center",cursor:"pointer",color:T.tinta},"data-gufi-src":"page.tsx:111"},__gh(import_lucide_react.Minus,{size:16})),__gh("span",{style:{fontSize:20,fontWeight:650,minWidth:22,textAlign:"center",fontVariantNumeric:"tabular-nums"},"data-gufi-src":"page.tsx:112"},kg),__gh("button",{type:"button","aria-label":"M\xE1s",onClick:()=>setKg(Math.min(20,kg+1)),style:{width:38,height:38,borderRadius:99,border:`1px solid ${T.raya}`,background:"#fff",display:"grid",placeItems:"center",cursor:"pointer",color:T.tinta},"data-gufi-src":"page.tsx:113"},__gh(import_lucide_react.Plus,{size:16})))),__gh(import_framer_motion.AnimatePresence,{initial:!1},datos&&__gh(import_framer_motion.motion.form,{key:"datos",onSubmit:pedir,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.35,ease:EASE},style:{display:"flex",flexDirection:"column",gap:10,marginTop:18}},__gh("input",{"aria-label":"Nombre o bar",placeholder:"Nombre o bar",value:nombre,onChange:e=>setNombre(e.target.value),style:campo,autoComplete:"organization","data-gufi-src":"page.tsx:120"}),__gh("input",{"aria-label":"Direcci\xF3n de entrega",placeholder:"Direcci\xF3n de entrega",value:direccion,onChange:e=>setDireccion(e.target.value),style:campo,autoComplete:"street-address","data-gufi-src":"page.tsx:121"}),error&&__gh("p",{role:"alert",style:{fontSize:13.5,color:"#b42318",margin:0},"data-gufi-src":"page.tsx:122"},error),__gh("button",{type:"submit",disabled:enviando,style:{...boton,opacity:enviando?.75:1},"data-gufi-src":"page.tsx:123"},enviando?"Enviando":`Pedir ${kg} kg \xB7 ${euros(total)}`),__gh("p",{style:{fontSize:12.5,color:T.suave,textAlign:"center",margin:"2px 0 0"},"data-gufi-src":"page.tsx:124"},"Lo pagas con la factura, cuando te llegue."))),!datos&&__gh("button",{type:"button",onClick:()=>setDatos(!0),style:{...boton,marginTop:18},"data-gufi-src":"page.tsx:129"},"Pedir \xB7 ",euros(total)))}function Hecho({numero,volver}){return __gh(import_framer_motion.motion.section,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.45,ease:EASE},style:{padding:"56px 24px",textAlign:"center"}},__gh(import_framer_motion.motion.span,{initial:{scale:.6,opacity:0},animate:{scale:1,opacity:1},transition:{duration:.45,ease:EASE,delay:.1},style:{width:64,height:64,borderRadius:99,background:T.tinta,color:"#f2e4cf",display:"inline-grid",placeItems:"center"}},__gh(import_lucide_react.Check,{size:30,strokeWidth:2.4})),__gh("p",{style:{fontSize:14,color:T.suave,margin:"22px 0 0"},"data-gufi-src":"page.tsx:142"},"Pedido ",numero),__gh("h1",{style:{fontFamily:T.serif,fontSize:34,fontWeight:700,letterSpacing:"-0.6px",margin:"4px 0 0"},"data-gufi-src":"page.tsx:143"},"\xA1Recibido!"),__gh("p",{style:{fontSize:15,color:T.suave,margin:"10px auto 0",maxWidth:300,lineHeight:1.45},"data-gufi-src":"page.tsx:144"},"Lo tostamos hoy y te lo llevamos en la ruta de la tarde."),__gh("button",{type:"button",onClick:volver,style:{marginTop:26,border:`1px solid ${T.raya}`,background:"#fff",borderRadius:12,height:44,padding:"0 18px",fontSize:14.5,fontWeight:600,color:T.tinta,cursor:"pointer",fontFamily:T.sans},"data-gufi-src":"page.tsx:145"},"Seguir mirando"))}function Web({gufi}){let[vista,setVista,params]=gufi.router.usePathView({initial:"inicio",routes:{inicio:"/",cafe:"/cafe/:cafeId",pedido:"/pedido/:numero"}}),{data,loading,error}=gufi.useData("tostadero__cafes",{sorters:[{field:"orden",order:"asc"}],pageSize:50}),cafes=data.slice().sort((a,b)=>a.orden-b.orden),cafe=vista==="cafe"?cafes.find(c=>String(c.id)===params.cafeId):null;return __gh("div",{style:{minHeight:"100vh",background:T.fondo,color:T.tinta,fontFamily:T.sans},"data-gufi-src":"page.tsx:156"},__gh("div",{style:{maxWidth:720,margin:"0 auto"},"data-gufi-src":"page.tsx:157"},__gh(Cabecera,{onInicio:()=>setVista("inicio")}),error&&__gh("p",{role:"alert",style:{padding:"0 20px",color:"#b42318"},"data-gufi-src":"page.tsx:159"},"No hemos podido cargar los caf\xE9s: ",String(error.message??error)),vista==="inicio"&&!loading&&__gh(Inicio,{cafes,abrir:c=>setVista("cafe",{cafeId:c.id})}),vista==="cafe"&&cafe&&__gh(Ficha,{gufi,cafe,volver:()=>setVista("inicio"),hecho:n=>setVista("pedido",{numero:n})}),vista==="pedido"&&__gh(Hecho,{numero:params.numero,volver:()=>setVista("inicio")})))}var featureConfig={dataSources,meta:{name:"Web de Grano",version:"1.0.0"}};var stdin_default=Web;