import{o as a,c as r,b as s,a as u,q as E,z,h as f,d as i,ax as L,aI as $,B as h,i as y,r as o,e as T}from"./vendor-BDR7yMJi.js";import{u as A,S as U,c as j,s as q,a as G}from"./index-BSaHX2oa.js";const I={class:"h-[90vh]"},M={class:"btns flex items-center gap-2"},W={key:0,class:"mb-20 p-4"},H={key:1,class:"p-4"},J={class:"mb-4"},K={class:"mb-4"},O={key:0,class:"block mt-1 text-green-600"},Q={class:"mb-4"},R={key:0,class:"block mt-1 text-green-600"},X={key:2,class:"flex justify-center items-center flex-col h-[30vh]"},Y={class:"mb-4 text-lg font-semibold"},Z=["href"],ee={class:"flex justify-between items-center p-4"},ae={__name:"ExtractionPDF",setup(se){const{showSuccess:S,showError:k,showWarn:D}=A(),P=["BDS","Modèle 45"],c=o(null),n=o("etape1"),p=o(null),d=o(null),m=o(""),v=o(""),b=o(""),x=o(""),_=T(()=>c.value==="BDS"&&p.value&&d.value),w=t=>{const e=t.files;e&&e.length>0&&(p.value=e[0],m.value=e[0].name)},B=t=>{const e=t.files;e&&e.length>0&&(d.value=e[0],v.value=e[0].name)},C=()=>{n.value="etape2"},N=async()=>{if(!_.value){D("Veuillez remplir tous les champs requis.");return}const t=new FormData;t.append("typeFichier",c.value),t.append("exel",d.value),t.append("pdf",p.value);try{let e=`${q.lienApi}/genererPDF`,l=await G.post(e,t);n.value="etape3",b.value=l.data.url,x.value=l.data.nomFile,S("Le PDF a été généré avec succès.")}catch(e){const l=e.response?.data?.message||e.message;k(`Une erreur est survenue : 
${l}`)}};return(t,e)=>{const l=z,V=L,g=$;return a(),r("div",I,[s("div",M,[u(l,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[0]||(e[0]=F=>E(U)("ExtractionPDF"))})]),s("div",null,[n.value==="etape1"?(a(),r("div",W,[...e[2]||(e[2]=[s("h1",{class:"text-xl font-bold mb-4"},"Assistance génération PDF - CNSS",-1),s("p",null,[f(" Bienvenue dans l'assistant de génération d'un fichier PDF à partir du fichier BDS et le modèle 45 de la CNSS."),s("br"),f(" Sur le fichier Excel, assurez-vous d'avoir sur la colonne A les matricules de la CNSS. ")],-1)])])):i("",!0),n.value==="etape2"?(a(),r("div",H,[s("div",J,[u(V,{size:"small",modelValue:c.value,"onUpdate:modelValue":e[1]||(e[1]=F=>c.value=F),options:P,placeholder:"Type de fichier",class:"w-full md:w-14rem"},null,8,["modelValue"])]),s("div",K,[e[3]||(e[3]=s("label",{class:"block mb-2"},"Fichier source (PDF)",-1)),u(g,{mode:"basic",multiple:!1,accept:"application/pdf",maxFileSize:1e7,chooseLabel:"Parcourir",class:"w-full",onSelect:w}),m.value?(a(),r("small",O," Fichier sélectionné: "+h(m.value),1)):i("",!0)]),s("div",Q,[e[4]||(e[4]=s("label",{class:"block mb-2"},"Fichier de données (Excel)",-1)),u(g,{mode:"basic",multiple:!1,accept:".xls,.xlsx",maxFileSize:1e7,chooseLabel:"Parcourir",class:"w-full",onSelect:B}),v.value?(a(),r("small",R," Fichier sélectionné: "+h(v.value),1)):i("",!0)])])):i("",!0),n.value==="etape3"?(a(),r("div",X,[s("h3",Y,h(x.value),1),s("a",{href:b.value,class:"p-button p-button-primary",target:"_blank"},[...e[5]||(e[5]=[s("span",{class:"flex items-center gap-2"},[f(" Télécharger "),s("i",{class:"pi pi-download"})],-1)])],8,Z)])):i("",!0),s("div",ee,[e[6]||(e[6]=s("img",{src:j,alt:"Logo",class:"logo-omag"},null,-1)),s("div",null,[n.value==="etape1"?(a(),y(l,{key:0,label:"Suivant",icon:"pi pi-arrow-right",iconPos:"right",onClick:C,class:"p-button-primary"})):i("",!0),n.value==="etape2"?(a(),y(l,{key:1,label:"Générer",icon:"pi pi-sync",iconPos:"right",onClick:N,class:"p-button-primary",disabled:!_.value},null,8,["disabled"])):i("",!0)])])])])}}};export{ae as default};
