1import{u as T,r as m,p as y,j as e,L}from"./index-CmUU21-Z.js";import{C as O}from"./ClientShell-BFqy9J-l.js";import{C as f,f as P,c as b}from"./clientUi-DV9eaSuD.js";import{u as $}from"./useActiveDossier-K7QWSXK9.js";import"./loyalty-BnFCLfN1.js";/* empty css */const w=()=>e.jsx("svg",{viewBox:"0 0 24 24",className:"mt-0.5 h-4 w-4 shrink-0 text-emerald-600",fill:"none",stroke:"currentColor",strokeWidth:2.4,children:e.jsx("path",{d:"m5 13 4 4L19 7"})});function A({pax:t,index:i,customerId:c,bookingId:x,onUploaded:p}){const{t:s}=T(),[d,h]=m.useState(null),[r,o]=m.useState(!0),[g,n]=m.useState(!0),j=m.useRef(null),u=m.useRef(null),N=!!t.photoUrl,v=!!t.passportScanUrl,W=(t.firstName||"").trim(),B=(t.lastName||"").trim(),U=`${W} ${B}`.trim()||s("client:documents.travelerN",{n:i+1}),R=((W[0]||"")+(B[0]||"")).toUpperCase()||"GM",C=t.civility||t.title||t.gender||"",k=t.birthDate||t.dateOfBirth||t.dob,D=(()=>{if(!k)return null;const l=new Date(k);if(Number.isNaN(l.getTime()))return null;const a=Date.now()-l.getTime();return Math.floor(a/315576e5)})(),E=t.nationality||t.nationalite||"",M=async(l,a)=>{if(!(!a||!c||!x)){if(a.size>15*1024*1024){b(s("client:documents.fileTooLarge"));return}h(l);try{await y.uploadPassengerFile(c,x,t.id,l,a),l==="photo"?o(!0):n(!0),b(s("client:documents.docReceived")),p()}catch(S){b((S==null?void 0:S.message)||s("client:documents.uploadFailed"))}finally{h(null)}}},F=async l=>{if(!(!c||!x)&&window.confirm(s("client:documents.confirmDelete"))){h(l);try{await y.deletePassengerFile(c,x,t.id,l),l==="photo"?o(!0):n(!0),b(s("client:documents.docDeleted")),p()}catch(a){b((a==null?void 0:a.message)||s("client:documents.deleteFailed"))}finally{h(null)}}};return e.jsxs("section",{className:"overflow-hidden rounded-2xl border border-ink/8 bg-cream-100 shadow-soft",children:[e.jsxs("div",{className:"flex items-center gap-3 bg-navy px-4 py-3 sm:px-5",children:[e.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-full bg-white/12 text-[12px] font-bold text-gold-light",children:R}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[10.5px] font-bold uppercase tracking-wider text-gold-light",children:s("client:documents.travelerN",{n:i+1})}),e.jsxs("h3",{className:"font-display text-[16.5px] leading-tight text-white",children:[C?`${C} `:"",U]})]})]}),e.jsxs("div",{className:"grid gap-4 p-4 sm:grid-cols-[150px_1fr] sm:p-5",children:[e.jsxs("div",{className:"relative",children:[e.jsx("input",{ref:j,type:"file",accept:"image/*",className:"sr-only",onChange:l=>{var a;return M("photo",(a=l.target.files)==null?void 0:a[0])}}),e.jsxs("button",{type:"button",onClick:()=>{var l;return(l=j.current)==null?void 0:l.click()},disabled:d==="photo",className:`group relative flex aspect-[3/4] w-full flex-col items-center justify-center overflow-hidden rounded-2xl border-2 border-dashed text-center transition disabled:opacity-60 ${N?"border-emerald-400 bg-emerald-50/40":"border-red-brand/40 bg-red-pale/40 hover:border-red-brand"}`,children:[N&&r&&e.jsx("img",{src:t.photoUrl,alt:s("client:documents.photoId"),onError:()=>o(!1),className:"absolute inset-0 h-full w-full object-cover"}),!(N&&r)&&e.jsx("div",{className:"relative flex flex-col items-center",children:N?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"grid h-12 w-12 place-items-center rounded-full bg-emerald-500 text-white",children:e.jsx("svg",{viewBox:"0 0 24 24",className:"h-6 w-6",fill:"none",stroke:"currentColor",strokeWidth:2.6,children:e.jsx("path",{d:"m5 13 4 4L19 7"})})}),e.jsx("span",{className:"mt-2 text-[12px] font-bold text-emerald-700",children:s("client:documents.photoReceived")})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"grid h-12 w-12 place-items-center rounded-full bg-red-brand text-white",children:e.jsxs("svg",{viewBox:"0 0 24 24",className:"h-6 w-6",fill:"none",stroke:"currentColor",strokeWidth:1.8,children:[e.jsx("circle",{cx:"12",cy:"9",r:"3.4"}),e.jsx("path",{d:"M5 20a7 7 0 0 1 14 0"})]})}),e.jsx("span",{className:"mt-2 text-[12px] font-bold text-navy",children:s("client:documents.photoId")}),e.jsx("span",{className:"text-[10.5px] text-ink-mute",children:s("client:documents.imageOrPdf")})]})}),e.jsxs("span",{className:`absolute bottom-2 left-1/2 inline-flex -translate-x-1/2 items-center gap-1.5 rounded-full px-3 py-1.5 text-[11px] font-bold text-white ${N&&r?"bg-navy/85 backdrop-blur":"bg-navy"}
1`,children:[e.jsx(f,{name:"upload",className:"h-3.5 w-3.5",strokeWidth:2}),s(d==="photo"?"client:documents.sending":N?"client:documents.replace":"client:documents.upload")]})]}),N&&e.jsxs("button",{type:"button",onClick:()=>F("photo"),disabled:d==="photo",title:s("client:documents.deletePhotoTitle"),className:"absolute right-2 top-2 z-20 inline-flex items-center gap-1 rounded-full bg-white/90 px-2.5 py-1 text-[11px] font-bold text-red-brand shadow-soft backdrop-blur transition hover:bg-white disabled:opacity-60",children:[e.jsx("svg",{viewBox:"0 0 24 24",className:"h-3.5 w-3.5",fill:"none",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"})}),s("client:documents.delete")]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-y-2.5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.04em] text-ink-mute",children:s("client:documents.birthDate")}),e.jsx("p",{className:"text-[13.5px] font-semibold text-ink",children:k?P(k):"â"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.04em] text-ink-mute",children:s("client:documents.age")}),e.jsx("p",{className:"text-[13.5px] font-semibold text-ink",children:D!=null?s("client:documents.ageYears",{age:D}):"â"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.04em] text-ink-mute",children:s("client:documents.civilStatus")}),e.jsx("p",{className:"text-[13.5px] font-semibold text-ink",children:C||"â"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.04em] text-ink-mute",children:s("client:documents.nationality")}),e.jsx("p",{className:"text-[13.5px] font-semibold text-ink",children:E||"â"})]})]}),e.jsxs("div",{className:"mt-3 rounded-xl border border-ink/8 bg-white p-3.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("svg",{viewBox:"0 0 24 24",className:"h-4 w-4 text-gold-deep",fill:"none",stroke:"currentColor",strokeWidth:2,children:[e.jsx("rect",{x:"5",y:"3",width:"14",height:"18",rx:"2"}),e.jsx("circle",{cx:"12",cy:"10",r:"3"}),e.jsx("path",{d:"M9 17h6"})]}),e.jsx("p",{className:"text-[12px] font-bold uppercase tracking-wide text-navy",children:s("client:documents.passportScan")}),v?e.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-bold text-emerald-700",children:[e.jsx("svg",{viewBox:"0 0 24 24",className:"h-3 w-3",fill:"none",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{d:"m5 13 4 4L19 7"})}),s("client:documents.received")]}):e.jsx("span",{className:"ml-auto inline-flex items-center gap-1 rounded-full bg-red-pale px-2 py-0.5 text-[11px] font-bold text-red-brand",children:s("client:documents.missing")})]}),e.jsx("p",{className:"mt-1.5 text-[12px] leading-relaxed text-ink-mute",children:s("client:documents.passportScanHint")}),v&&g&&e.jsx("a",{href:t.passportScanUrl,target:"_blank",rel:"noopener noreferrer",className:"mt-2.5 block",children:e.jsx("img",{src:t.passportScanUrl,alt:s("client:documents.passportScan"),onError:()=>n(!1),className:"max-h-48 w-full rounded-lg border border-ink/10 bg-white object-contain"})}),e.jsxs("div",{className:"mt-2.5 flex flex-wrap gap-2",children:[v&&e.jsxs("a",{href:t.passportScanUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 rounded-full border border-ink/15 px-3.5 py-2 text-[12.5px] font-semibold text-navy transition hover:bg-cream-200",children:[e.jsxs("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none",stroke:"currentColor",strokeWidth:2,children:[e.jsx("path",{d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7Z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),s("client:documents.view")]}),e.jsx("input",{ref:u,type:"file",accept:"image/*,application/pdf",className:"sr-only",onChange:l=>{var a;return M("passport",(a=l.target.files)==null?void 0:a[0])}}),e.jsxs("button",{type:"button",onClick:()=>{var l;return(l=u.current)==null?void 0:l.click()},disabled:d==="passport",className:"inline-flex items-center gap-1.5 rounded-full bg-navy px-3.5 py-2 text-[12.5px] font-bold text-white transition active:scale-95 disabled:opacity-60",children:[e.jsxs("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none",stroke:"currentColor",strokeWidth:2,children:[e.jsx("rect",{x:"5",y:"3",width:"14",height:"18",rx:"2"}),e.jsx("circle",{cx:"12",cy:"10",r:"3"})]}),s(d==="passport"?"client:documents.sending":v?"client:documents.replaceScan":"client:documents.uploadScan")]}),v&&e.jsxs("button",{type:"button",onClick:()=>F("passport"),disabled:d==="passport",className:"inline-flex items-center gap-1.5 rounded-full border border-red-brand/30 px-3.5 py-2 text-[12.5px] font-semibold text-red-brand transition hover:bg-red-pale disabled:opacity-60",children:[e.jsx("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"})}),s("client:documents.delete")]})]})]})]})]})]})}const Y=()=>{const{t}=T(),{loading:i,customerId:c,bookingId:x,booking:p,active:s,passengers:d,reload:h}=$(),[r,o]=m.useState([]);m.useEffect(()=>{let n=!1;if(!c){o([]);return}return(async()=>{try{const j=await y.get(`/api/customers/${c}/documents`);if(n)return;const u=j.data;o(Array.isArray(u)?u:(u==null?void 0:u.documents)??[])}catch{n||o([])}})(),()=>{n=!0}},[c]);const g=(p==null?void 0:p.bookingReference)||(s==null?void 0:s.reference)||"";return e.jsx(O,{children:e.jsxs("div",{className:"mx-auto max-w-[980px]",children:[e.jsxs(L,{to:"/client/dashboard",className:"mb-4 inline-flex items-center gap-1.5 text-[13px] font-semibold text-ink-soft hover:text-red-brand",children:[e.jsx(f,{name:"chevron",className:"h-4 w-4 rotate-180",strokeWidth:2})," ",t("client:documents.backToDashboard")]}),i?e.jsx("div",{className:"flex justify-center py-24",children:e.jsx("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-red-brand/25 border-t-red-brand"})}):x?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[g&&e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.16em] text-red-brand",children:t("client:documents.dossierRef",{ref:g})}),e.jsx("h1",{className:"font-display text-[26px] leading-tight text-navy sm:text-[32px]",children:t("client:documents.title")}),e.jsx("p",{className:"mt-1 text-[13.5px] text-ink-soft",children:t("client:documents.subtitle")})]}),e.jsx("section",{className:"mt-5 overflow-hidden rounded-2xl border border-red-tint bg-cream-100 shadow-soft",children:e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("div",{className:"w-1.5 shrink-0 bg-gradient-to-b from-red-soft to-red-deep"}),e.jsxs("div",{className:"p-4 sm:p-5",children:[e.jsx("p",{className:"text-[11.5px] font-bold uppercase tracking-[0.14em] text-red-brand",children:t("client:documents.scanQualityEyebrow")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-soft",children:t("client:documents.scanQualityIntro")}),e.jsxs("ul",{className:"mt-2.5 grid gap-1.5 sm:grid-cols-2",children:[e.jsxs("li",{className:"flex items-start gap-2 text-[13px] text-ink-soft",children:[e.jsx(w,{}),t("client:documents.scanTip1")]}),e.jsxs("li",{className:"flex items-start gap-2 text-[13px] text-ink-soft",children:[e.jsx(w,{}),t("client:documents.scanTip2")]}),e.jsxs("li",{className:"flex items-start gap-2 text-[13px] text-ink-soft",children:[e.jsx(w,{}),t("client:documents.scanTip3")]}),e.jsxs("li",{className:"flex items-start gap-2 text-[13px] text-ink-soft",children:[e.jsx(w,{}),t("client:documents.scanTip4")]})]})]})]})}),e.jsx("div",{className:"mt-6 space-y-5",children:d.length?d.map((n,j)=>e.jsx(A,{pax:n,index:j,customerId:c,bookingId:x,onUploaded:h},n.id??j)):e.jsx("p",{className:"rounded-2xl border border-ink/8 bg-cream-100 p-6 text-center text-[13.5px] text-ink-soft shadow-soft",children:t("client:documents.noTravelers")})}),r.length>0&&e.jsxs("section",{className:"mt-6 overflow-hidden rounded-2xl border border-ink/8 bg-cream-100 shadow-soft",children:[e.jsxs("div",{className:"flex items-center gap-2.5 border-b border-ink/8 px-4 py-3.5 sm:px-5",children:[e.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-xl bg-red-pale text-red-brand",children:e.jsx(f,{name:"doc",className:"h-5 w-5",strokeWidth:2})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10.5px] font-bold uppercase tracking-wider text-red-brand",children:t("client:documents.libraryEyebrow")}),e.jsx("h3",{className:"font-display text-[16.5px] leading-tight text-navy",children:t("client:documents.alreadySubmitted")})]})]}),e.jsx("ul",{className:"divide-y divide-ink/8",children:r.map(n=>e.jsxs("li",{className:"flex items-center gap-3 px-4 py-3.5 sm:px-5",children:[e.jsx("span",{className:"grid h-10 w-10 shrink-0 place-items-center rounded-xl bg-cream-200 text-navy",children:e.jsx(f,{name:"doc",className:"h-5 w-5",strokeWidth:2})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-[13.5px] font-semibold text-ink",children:n.name||n.type||t("client:documents.docFallback")}),e.jsxs("p",{className:"truncate text-[12px] text-ink-mute",children:[n.type||"â",n.documentNumber?t("client:documents.docNumberSuffix",{num:n.documentNumber}):"",n.createdAt?` · ${P(n.createdAt)}`:""]})]}),n.status&&e.jsx("span",{className:"hidden shrink-0 rounded-full bg-emerald-50 px-2.5 py-1 text-[11px] font-bold text-emerald-700 sm:inline-flex",children:n.status}),n.url?e.jsxs("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex shrink-0 items-center gap-1.5 rounded-full bg-navy px-3.5 py-2 text-[12.5px] font-bold text-white transition active:scale-95",children:[e.jsx(f,{name:"download",className:"h-4 w-4",strokeWidth:2}),e.jsx("span",{className:"hidden sm:inline",children:t("client:documents.download")})]}):e.jsx("span",{className:"shrink-0 text-[12.5px] text-ink-mute",children:"â"})]},n.id))})]}),e.jsx("div",{className:"mt-6 overflow-hidden rounded-2xl border border-red-tint bg-cream-100 shadow-soft",children:e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("div",{className:"w-1.5 shrink-0 bg-gradient-to-b from-red-soft to-red-deep"}),e.jsxs("div",{className:"flex items-start gap-3 p-4 sm:p-5",children:[e.jsx("span",{className:"mt-0.5 grid h-9 w-9 shrink-0 place-items-center rounded-xl bg-red-pale text-red-brand",children:e.jsx(f,{name:"alert",className:"h-5 w-5",strokeWidth:2})}),e.jsxs("p",{className:"text-[13px] leading-relaxed text-ink-soft",children:[e.jsx("strong",{className:"text-ink",children:t("client:documents.visaTitle")}),t("client:documents.visaTextPart1"),e.jsx("strong",{className:"text-ink",children:t("client:documents.visaBold")}),t("client:documents.visaTextPart2")]})]})]})}),e.jsx("section",{className:"mt-6",children:e.jsx(I,{customerId:c})})]}):e.jsxs("section",{className:"overflow-hidden rounded-3xl border border-ink/8 bg-cream-100 p-8 text-center shadow-soft sm:p-12",children:[e.jsx("span",{className:"mx-auto grid h-14 w-14 place-items-center rounded-2xl bg-red-pale text-red-brand",children:e.jsx(f,{name:"upload",className:"h-7 w-7"})}),e.jsx("h2",{className:"font-display mt-4 text-[22px] text-navy sm:text-[26px]",children:t("client:documents.noDossierTitle")}),e.jsx("p",{className:"mx-auto mt-2 max-w-md text-[14px] text-ink-soft",children:t("client:documents.noDossierText")}),e.jsxs(L,{to:"/omra",className:"mt-6 inline-flex h-12 items-center justify-center gap-2 rounded-full bg-red-brand px-7 text-[14.5px] font-bold text-white shadow-soft transition active:scale-[0.98]",children:[t("client:documents.discoverOffers")," ",e.jsx(f,{name:"chevron",className:"h-4 w-4",strokeWidth:2.5})]})]})]})})};function I({customerId:t}){const{t:i}=T(),c=m.useRef(null),[x,p]=m.useState(!1),[s,d]=m.useState(""),h=async r=>{if(!r||!r.length||!t)return;p(!0);let o=0,g=0;try{for(const n of Array.from(r)){if(n.size>15*1024*1024){g+=1;continue}try{await y.uploadDocument(t,n,"autre"),o+=1}catch{}}o>0?(d(i("client:documents.filesSubmitted",{count:o})),b(i("client:documents.docsSubmitted"))):g>0?b(i("client:documents.fileTooLarge")):b(i("client:documents.uploadFailed"))}finally{p(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>{var r;return(r=c.current)==null?void 0:r.click()},disabled:x,className:"group flex w-full cursor-pointer flex-col items-center justify-center gap-2 rounded-3xl border-2 border-dashed border-navy/30 bg-cream-100 p-6 text-center shadow-soft transition hover:border-red-brand hover:bg-red-pale/30 disabled:opacity-60",children:[e.jsx("span",{className:"grid h-14 w-14 place-items-center rounded-full bg-navy text-white shadow-soft",children:e.jsxs("svg",{viewBox:"0 0 24 24",className:"h-7 w-7",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("path",{d:"M7 9l5-5 5 5M12 4v12"})]})}),e.jsx("p",{className:"font-display text-[17px] text-navy",children:i("client:documents.freeUploadTitle")}),e.jsx("p",{className:"max-w-md text-[13px] text-ink-soft",children:i("client:documents.freeUploadText")}),e.jsx("span",{className:"mt-1 inline-flex h-11 items-center gap-2 rounded-full bg-red-brand px-6 text-[14px] font-bold text-white",children:i(x?"client:documents.sending":"client:documents.freeUploadBtn")})]}),e.jsx("input",{ref:c,type:"file",accept:"image/*,application/pdf",multiple:!0,className:"sr-only",onChange:r=>h(r.target.files)}),s&&e.jsx("p",{className:"mt-2 text-center text-[12.5px] text-ink-mute",children:s})]})}export{Y as Documents,Y 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.