import{j as e,u as t,r as s}from"./vendor-utils-BvYwFWT7.js";import{d as r}from"./DeleteRounded-BdDsb7m-.js";import{i as o,B as i,T as a,A as n,o as l,s as d,k as c,G as p,E as x,v as m}from"./vendor-ui-12RU7iXG.js";import{r as h,u}from"./wizard.js";import{d as g}from"./NavigateBeforeRounded-DpQdjX25.js";import{d as j}from"./NavigateNextRounded-DfVv8lR5.js";import"./vendor-dates-qzxQr22O.js";var f={},b=o;Object.defineProperty(f,"__esModule",{value:!0});var v=f.default=void 0,y=b(h()),C=e;v=f.default=(0,y.default)((0,C.jsx)("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96M14 13v4h-4v-4H7l4.65-4.65c.2-.2.51-.2.71 0L17 13z"}),"CloudUploadRounded");const w=["image/jpeg","image/png","image/webp"];function z({wizardData:o,updateStepData:h,onNext:f,onBack:b,isMobile:y}){const{t:C}=t(),z=o.step_6||{},k=z.images||[],[D,S]=s.useState(!1),[A,R]=s.useState(null),B=s.useCallback(async e=>{R(null);const t=10-k.length,s=Array.from(e).slice(0,t);for(const o of s)if(w.includes(o.type))if(o.size>5242880)R(C("step6.fileTooLarge"));else{S(!0);try{const e=await u(o),t=[...z.images||[],{id:e.id,url:e.url}];h("step_6",{...z,images:t})}catch(r){R(r.message||C("common.error"))}finally{S(!1)}}else R(C("step6.invalidFormat"))},[k,z,h,C]),F=s.useCallback(e=>{const t=k.filter((t,s)=>s!==e);h("step_6",{...z,images:t})},[k,z,h]),[I,N]=s.useState(!1);return e.jsxs(i,{sx:{py:{xs:2,md:4}},children:[e.jsx(a,{variant:"h5",component:"h2",fontWeight:"bold",textAlign:"center",sx:{mb:1},children:C("step6.title")}),e.jsx(a,{variant:"body1",color:"text.secondary",textAlign:"center",sx:{mb:4},children:C("step6.subtitle")}),e.jsxs(i,{sx:{maxWidth:800,mx:"auto"},children:[A&&e.jsx(n,{severity:"error",onClose:()=>R(null),sx:{mb:3},children:A}),e.jsx(l,{variant:"outlined",onDragOver:e=>{e.preventDefault(),N(!0)},onDragLeave:()=>N(!1),onDrop:e=>{e.preventDefault(),N(!1),e.dataTransfer.files.length>0&&B(e.dataTransfer.files)},sx:{mb:4,border:"2px dashed",borderColor:I?"primary.main":"grey.300",backgroundColor:I?"primary.50":"grey.50",transition:"all 0.2s ease",cursor:k.length>=10?"not-allowed":"pointer",opacity:k.length>=10?.5:1},children:e.jsxs(d,{sx:{textAlign:"center",py:6},onClick:()=>{k.length<10&&document.getElementById("wahrb-media-input").click()},children:[e.jsx("input",{id:"wahrb-media-input",type:"file",accept:w.join(","),multiple:!0,onChange:e=>{e.target.files.length>0&&B(e.target.files)},style:{display:"none"}}),D?e.jsxs(e.Fragment,{children:[e.jsx(c,{size:48,sx:{mb:2}}),e.jsx(a,{children:C("step6.uploading")})]}):e.jsxs(e.Fragment,{children:[e.jsx(v,{sx:{fontSize:56,color:"primary.main",mb:2}}),e.jsx(a,{variant:"h6",gutterBottom:!0,children:C("step6.dropzone")}),e.jsx(a,{variant:"body2",color:"text.secondary",children:C("step6.maxSize")}),e.jsx(a,{variant:"body2",color:"text.secondary",children:C("step6.formats")})]})]})}),k.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(a,{variant:"body2",color:"text.secondary",sx:{mb:2},children:C("step6.reorder")}),e.jsx(p,{container:!0,spacing:2,children:k.map((t,s)=>e.jsx(p,{item:!0,xs:6,sm:4,md:3,children:e.jsxs(l,{sx:{position:"relative",overflow:"hidden"},children:[e.jsx(i,{component:"img",src:t.url,alt:`Photo ${s+1}`,sx:{width:"100%",height:140,objectFit:"cover",display:"block"}}),0===s&&e.jsx(i,{sx:{position:"absolute",top:4,left:4,bgcolor:"primary.main",color:"white",fontSize:"0.65rem",px:1,py:.25,borderRadius:1,fontWeight:"bold"},children:"PRINCIPALE"}),e.jsx(x,{size:"small",onClick:()=>F(s),sx:{position:"absolute",top:4,right:4,bgcolor:"rgba(255,255,255,0.85)","&:hover":{bgcolor:"error.light",color:"white"}},children:e.jsx(r,{fontSize:"small"})})]})},t.id||s))})]})]}),e.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",mt:4,pt:3,borderTop:"1px solid",borderColor:"divider"},children:[e.jsx(m,{variant:"outlined",onClick:b,startIcon:e.jsx(g,{}),children:C("wizard.buttons.previous")}),e.jsx(m,{variant:"contained",onClick:f,endIcon:e.jsx(j,{}),children:C("wizard.buttons.next")})]})]})}export{z as default};
