import{s as h}from"./primevue-CfIk0_DY.js";import{_ as x,s as k,a as y}from"./index-BxIwIJfy.js";import{ah as $,o as b,a2 as w,b as r,c as o,d as e,v as D,t as p,q as N,f as _,p as S,a as l,y as c}from"./vue-core-Di3IuVqe.js";import"./cjs-helpers-psZwOBky.js";import"./vue-cal-DKMVGERa.js";import"./moment-BeHQNF8T.js";const C={class:"partage-page"},V={class:"partage-card"},B={key:0,class:"partage-centre"},F={key:1,class:"partage-centre"},L={class:"partage-muted"},M={key:2,class:"partage-doc"},P={class:"partage-barre"},q={class:"partage-fichier"},z={class:"partage-nom"},A={class:"partage-muted",style:{"font-size":"0.8rem"}},E={key:0},O=["href"],T=["src"],W={__name:"PartageDocument",setup(j){const u=$().params.token,d=k.lienApi,i=l("chargement"),g=l(""),s=l({}),m=c(()=>`${d}/public/partage/${u}/fichier`),f=c(()=>{const a=String(s.value.nom_fichier||"").toLowerCase();return a.endsWith(".pdf")?"pi pi-file-pdf":/\.(jpe?g|png|webp|gif)$/.test(a)?"pi pi-image":/\.(xls|xlsx|csv)$/.test(a)?"pi pi-file-excel":/\.(docx?|odt)$/.test(a)?"pi pi-file-word":"pi pi-file"}),v=c(()=>{if(!s.value.expire)return"";const a=new Date(s.value.expire);if(isNaN(a))return"";const t=n=>String(n).padStart(2,"0");return`${t(a.getDate())}/${t(a.getMonth()+1)}/${a.getFullYear()}`});return b(async()=>{try{const{data:a}=await w.get(`${d}/public/partage/${u}`);s.value=a,i.value="ok"}catch(a){g.value=a.response?.data?.error||"Ce lien de partage n'est plus valide (expiré, révoqué ou introuvable).",i.value="erreur"}}),(a,t)=>{const n=h;return r(),o("section",C,[e("div",V,[t[5]||(t[5]=e("div",{class:"partage-header"},[e("img",{src:y,alt:"OMAG",class:"partage-logo"})],-1)),i.value==="chargement"?(r(),o("div",B,[D(n,{strokeWidth:"4",style:{width:"42px",height:"42px"}}),t[0]||(t[0]=e("p",{class:"partage-muted"},"Ouverture du document…",-1))])):i.value==="erreur"?(r(),o("div",F,[t[1]||(t[1]=e("div",{class:"partage-icone partage-icone--rouge"},[e("i",{class:"pi pi-lock"})],-1)),t[2]||(t[2]=e("h2",{class:"partage-titre"},"Lien indisponible",-1)),e("p",L,p(g.value),1)])):(r(),o("div",M,[e("div",P,[e("div",q,[e("i",{class:N([f.value,"partage-fichier-icone"])},null,2),e("div",null,[e("div",z,p(s.value.nom_fichier),1),e("div",A,[t[3]||(t[3]=_(" Document partagé",-1)),v.value?(r(),o("span",E," · expire le "+p(v.value),1)):S("",!0)])])]),e("a",{href:m.value,target:"_blank",rel:"noopener",class:"partage-btn"},[...t[4]||(t[4]=[e("i",{class:"pi pi-download"},null,-1),_(" Télécharger ",-1)])],8,O)]),e("iframe",{src:m.value,class:"partage-apercu",title:"Document partagé"},null,8,T)]))])])}}},K=x(W,[["__scopeId","data-v-ec124781"]]);export{K as default};
