1import{u as k,j as e,H as w}from"./app-CAmgRONu.js";import{L}from"./Layout-DefmHGYh.js";import{B as c}from"./Button-UHKI6iPL.js";import{I as l,S as C}from"./Select-ByBEYgW8.js";import{I as B}from"./ImageUpload-CRi7mEXU.js";/* empty css */function P({difficulties:p,stops:d,badges:g,suggestedRouteId:h}){const{data:r,setData:o,post:u,processing:b,errors:a}=k({name:"",description:"",distance_km:"0",elevation_gain:"0",difficulty:"",stops_ids:[],estimated_time:"",points_bonus:"0",badge_reward_id:"",hero_image:null}),j=s=>{s.preventDefault(),u("/admin/routes",{forceFormData:!0})},y=s=>{r.stops_ids.includes(s)?o("stops_ids",r.stops_ids.filter(t=>t!==s)):o("stops_ids",[...r.stops_ids,s])},m=(s,t)=>{const i=[...r.stops_ids],n=t==="up"?s-1:s+1;n<0||n>=i.length||([i[s],i[n]]=[i[n],i[s]],o("stops_ids",i))},f=s=>{o("stops_ids",r.stops_ids.filter(t=>t!==s))},v=s=>d.find(t=>t.stop_id===s),N=[{value:"",label:"Nessun badge premio"},...g.map(s=>({value:s.badge_id,label:`${s.name} (${s.badge_id})`}))],_={easy:"border-green-300 bg-green-50 text-green-700",medium:"border-yellow-300 bg-yellow-50 text-yellow-700",hard:"border-orange-300 bg-orange-50 text-orange-700"},x={cantina:"bg-purple-100 text-purple-700",murale:"bg-blue-100 text-blue-700",poi:"bg-yellow-100 text-yellow-700",ristoro:"bg-orange-100 text-orange-700"};return e.jsxs(L,{title:"Nuovo Percorso",children:[e.jsx(w,{title:"Nuovo Percorso"}),e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(c,{href:"/admin/routes",variant:"ghost",size:"sm",children:[e.jsx("svg",{className:"mr-1 h-5 w-5",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})}),"Indietro"]})}),e.jsx("h1",{className:"mt-4 text-2xl font-bold text-gray-900",children:"Nuovo Percorso"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Crea un nuovo percorso cicloturistico per BiciInComune"})]}),e.jsxs("form",{onSubmit:j,className:"space-y-8",children:[e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white p-6",children:[e.jsx("h2",{className:"mb-4 text-lg font-semibold text-gray-900",children:"Informazioni Base"}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2",children:[e.jsx(l,{label:"ID Percorso",name:"route_id",value:h,disabled:!0,helpText:"Generato automaticamente"}),e.jsx("div",{className:"sm:col-span-2",children:e.jsx(l,{label:"Nome",name:"name",value:r.name,onChange:s=>o("name",s.target.value),error:a.name,placeholder:"Es. Anello delle Cantine, Via del Vino",required:!0})}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Descrizione"}),e.jsx("textarea",{name:"description",value:r.description,onChange:s=>o("description",s.target.value),rows:3,className:` 2 block w-full rounded-lg border px-3 py-2 text-gray-900 shadow-sm 3 placeholder:text-gray-400 4 focus:outline-none focus:ring-2 focus:ring-offset-0 5 ${a.description?"border-red-300 focus:border-red-500 focus:ring-red-500":"border-gray-300 focus:border-primary-500 focus:ring-primary-500"} 6 `,placeholder:"Descrivi il percorso, i punti di interesse principali, il paesaggio..."}),a.description&&e.jsx("p",{className:"mt-1 text-sm text-red-600",children:a.description})]})]})]}),e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white p-6",children:[e.jsx("h2",{className:"mb-4 text-lg font-semibold text-gray-900",children:"Difficoltà "}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:["Seleziona la difficoltà ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:Object.entries(p).map(([s,t])=>e.jsxs("label",{className:` 7 flex items-center justify-center gap-2 p-3 rounded-lg border-2 cursor-pointer transition-all 8 ${r.difficulty===s?_[s]+" ring-2 ring-offset-1 ring-primary-500":"border-gray-200 hover:border-gray-300"} 9 `,children:[e.jsx("input",{type:"radio",name:"difficulty",value:s,checked:r.difficulty===s,onChange:i=>o("difficulty",i.target.value),className:"sr-only"}),e.jsx("span",{className:`text-sm font-medium ${r.difficulty===s?"":"text-gray-700"}`,children:t})]},s))}),a.difficulty&&e.jsx("p",{className:"mt-1 text-sm text-red-600",children:a.difficulty})]})]}),e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white p-6",children:[e.jsx("h2",{className:"mb-4 text-lg font-semibold text-gray-900",children:"Dati Percorso"}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-3",children:[e.jsx(l,{label:"Distanza (km)",name:"distance_km",type:"number",step:"0.1",min:"0",max:"1000",value:r.distance_km,onCh
9ange:s=>o("distance_km",s.target.value),error:a.distance_km,helpText:"Lunghezza totale del percorso",required:!0}),e.jsx(l,{label:"Dislivello (m)",name:"elevation_gain",type:"number",min:"0",max:"10000",value:r.elevation_gain,onChange:s=>o("elevation_gain",s.target.value),error:a.elevation_gain,helpText:"Dislivello positivo totale"}),e.jsx(l,{label:"Tempo Stimato",name:"estimated_time",value:r.estimated_time,onChange:s=>o("estimated_time",s.target.value),error:a.estimated_time,placeholder:'Es. "4-5 ore", "2h 30min"',helpText:"Formato libero (es. 4-5 ore)"})]}),e.jsxs("div",{className:"mt-4 p-4 rounded-lg bg-gray-50 border border-gray-200",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700 mb-2",children:"Anteprima"}),e.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("svg",{className:"h-4 w-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 10.5a3 3 0 11-6 0 3 3 0 016 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 10.5c0 7.142-7.5 11.25-7.5 11.25S4.5 17.642 4.5 10.5a7.5 7.5 0 1115 0z"})]}),e.jsxs("span",{className:"text-gray-600",children:[parseFloat(r.distance_km||"0").toLocaleString("it-IT",{minimumFractionDigits:1,maximumFractionDigits:1})," km"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("svg",{className:"h-4 w-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 18L9 11.25l4.306 4.307a11.95 11.95 0 015.814-5.519l2.74-1.22m0 0l-5.94-2.28m5.94 2.28l-2.28 5.941"})}),e.jsxs("span",{className:"text-gray-600",children:[parseInt(r.elevation_gain||"0").toLocaleString("it-IT"),"m dislivello"]})]}),r.estimated_time&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("svg",{className:"h-4 w-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("span",{className:"text-gray-600",children:r.estimated_time})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("svg",{className:"h-4 w-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 10.5a3 3 0 11-6 0 3 3 0 016 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 10.5c0 7.142-7.5 11.25-7.5 11.25S4.5 17.642 4.5 10.5a7.5 7.5 0 1115 0z"})]}),e.jsxs("span",{className:"text-gray-600",children:[r.stops_ids.length," tappe"]})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white p-6",children:[e.jsx("h2",{className:"mb-4 text-lg font-semibold text-gray-900",children:"Tappe del Percorso"}),r.stops_ids.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("h3",{className:"text-sm font-medium text-gray-700 mb-2",children:["Tappe selezionate (",r.stops_ids.length,")",e.jsx("span",{className:"text-gray-500 font-normal ml-2",children:"- Trascina per riordinare"})]}),e.jsx("div",{className:"space-y-2",children:r.stops_ids.map((s,t)=>{const i=v(s);return i?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-primary-50 border border-primary-200 rounded-lg",children:[e.jsx("span",{className:"w-6 h-6 flex items-center justify-center bg-primary-600 text-white text-xs font-bold rounded-full",children:t+1}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-gray-900",children:i.name}),e.jsx("p",{className:"text-xs text-gray-500",children:i.stop_id})]}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${x[i.type]||"bg-gray-100 text-gray-700"}`,children:i.type}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{type:"button",onClick:()=>m(t,"up"),disabled:t===0,className:"p-1 text-gray-400 hover:text-gray-600 disabled:opacity-30",children:e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 15.75l7.5-7.5 7.5 7.5"})})}),e.jsx("button",{type:"button",onClick:()=>m(t,"down"),disabled:t===r.stops_ids.length-1,className:"p-1 text-gray-400 hover:text-gray-600 disabled:opacity-30",children:e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 8.25l-7.5 7.5-7.5-7.5"})})}),e.jsx("button",{type:"button",onClick:()=>f(s),className:"p-1 text-red-400 hover:text-red-600",children:e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]},s):null})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700 mb-2",children:"Tappe disponibili"}),d.length===0?e.jsx("p",{className:"text-sm text-gray-500 p-4 bg-gray-50 rounded-lg",children:"Nessuna tappa disponibile. Crea prima delle tappe."}):e.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3 max-h-80 overflow-y-auto p-1",children:d.filter(s=>!r.stops_ids.includes(s.stop_id)).map(s=>e.jsxs("button",{type:"button",onClick:()=>y(s.stop_id),className:"flex items-center gap-2 p-3 text-left border border-gray-200 rounded-lg hover:border-primary-300 hover:bg-primary-50 transition-colors",children:[e.jsx("svg",{className:"h-5 w-5 text-gray-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-gray-900 truncate",children:s.name}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-gray-500",children:s.stop_id}),e.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${x[s.type]||"bg-gray-100 text-gray-700"}`,children:s.type})]})]})]},s.id))})]}),a.stops_ids&&e.jsx("p",{className:"mt-2 text-sm text-red-600",children:a.stops_ids})]}),e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white p-6",children:[e.jsx("h2",{className:"mb-4 text-lg font-semibold text-gray-900",children:"Premio per Completamento"}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(l,{label:"Punti Bonus",name:"points_bonus",type:"number",min:"0",max:"100000",value:r.points_bonus,onChange:s=>o("points_bonus",s.target.value),error:a.points_bonus,helpText:"Punti ottenuti completando il percorso"}),e.jsx("div",{className:"mt-4 p-4 rounded-lg bg-yellow-50 border border-yellow-200",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{className:"h-5 w-5 text-yellow-600",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"})}),e.jsxs("span",{className:"text-sm font-medium text-yellow-800",children:["Anteprima: +",parseInt(r.points_bonus||"0").toLocaleStr
9ing("it-IT")," punti"]})]})})]}),e.jsx(C,{label:"Badge Premio (opzionale)",name:"badge_reward_id",options:N,value:r.badge_reward_id,onChange:s=>o("badge_reward_id",s.target.value),error:a.badge_reward_id,helpText:"Badge sbloccato al completamento del percorso"})]})]}),e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white p-6",children:[e.jsx("h2",{className:"mb-4 text-lg font-semibold text-gray-900",children:"Immagine"}),e.jsx(B,{label:"Immagine del Percorso",onChange:s=>o("hero_image",s),error:a.hero_image,helpText:"Immagine rappresentativa del percorso (max 5MB)"})]}),e.jsxs("div",{className:"flex justify-end gap-4",children:[e.jsx(c,{href:"/admin/routes",variant:"secondary",children:"Annulla"}),e.jsx(c,{type:"submit",loading:b,children:"Crea Percorso"})]})]})]})}export{P 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.