const i={client:{routeBase:"/clients",apiBase:"/clients",importRoute:"/clients/import",templateApi:"/clients/template",singular:"client",singularLabel:"Client",plural:"Clients",agedBalanceTitle:"Balance âgée clients",scheduleTitle:"Échéancier clients",defaultCollectiveSearch:"411"},supplier:{routeBase:"/suppliers",apiBase:"/suppliers",importRoute:"/suppliers/import",templateApi:"/suppliers/template",singular:"fournisseur",singularLabel:"Fournisseur",plural:"Fournisseurs",agedBalanceTitle:"Balance âgée fournisseurs",scheduleTitle:"Échéancier fournisseurs",defaultCollectiveSearch:"401"}},p=[{value:"all",label:"Tous"},{value:"true",label:"Actifs"},{value:"false",label:"Inactifs"}],u=[{value:"all",label:"Tous les soldes"},{value:"true",label:"Avec solde"},{value:"false",label:"Solde nul"}],_=[{value:"cash",label:"Espèces"},{value:"check",label:"Chèque"},{value:"transfer",label:"Virement"},{value:"other",label:"Autre"}],o=()=>{var e,a;return((a=(e=window.crypto)==null?void 0:e.randomUUID)==null?void 0:a.call(e))||`${Date.now()}-${Math.random().toString(16).slice(2)}`},b=(e,a=null)=>({company_id:e||"",ref_code:(a==null?void 0:a.ref_code)||"",name:(a==null?void 0:a.name)||"",nif:(a==null?void 0:a.nif)||"",rc:(a==null?void 0:a.rc)||"",nis:(a==null?void 0:a.nis)||"",ai:(a==null?void 0:a.ai)||"",industry_sector:(a==null?void 0:a.industry_sector)||"",registration_date:(a==null?void 0:a.registration_date)||"",address:(a==null?void 0:a.address)||"",city:(a==null?void 0:a.city)||"",wilaya:(a==null?void 0:a.wilaya)||"",postal_code:(a==null?void 0:a.postal_code)||"",phone:(a==null?void 0:a.phone)||"",email:(a==null?void 0:a.email)||"",fax:(a==null?void 0:a.fax)||"",principal_contact:(a==null?void 0:a.principal_contact)||"",account_id:(a==null?void 0:a.account_id)||"",collective_account_code:(a==null?void 0:a.collective_account_code)||"",collective_account_label:(a==null?void 0:a.collective_account_label)||"",collective_account_search:a!=null&&a.collective_account_code&&(a!=null&&a.collective_account_label)?`${a.collective_account_code} · ${a.collective_account_label}`:"",payment_terms:(a==null?void 0:a.payment_terms)??30,credit_limit:a!=null&&a.credit_limit?String(Number(a.credit_limit).toFixed(2)):"",preferred_payment_method:(a==null?void 0:a.preferred_payment_method)||"",is_active:(a==null?void 0:a.is_active)??!0,_local_id:o()}),h=e=>({company_id:e.company_id,ref_code:e.ref_code.trim(),name:e.name.trim(),nif:e.nif.trim(),rc:e.rc.trim(),nis:e.nis.trim(),ai:e.ai.trim(),industry_sector:e.industry_sector.trim(),registration_date:e.registration_date||null,address:e.address.trim(),city:e.city.trim(),wilaya:e.wilaya.trim(),postal_code:e.postal_code.trim(),phone:e.phone.trim(),email:e.email.trim(),fax:e.fax.trim(),principal_contact:e.principal_contact.trim(),account_id:Number(e.account_id),payment_terms:Number(e.payment_terms||0),credit_limit:Number(String(e.credit_limit||"0").replace(",",".")),preferred_payment_method:e.preferred_payment_method||null,is_active:!!e.is_active}),f=e=>{const a={};if(e.name.trim()||(a.name="La raison sociale est obligatoire."),e.account_id||(a.account_id="Le compte collectif est obligatoire."),e.credit_limit){const n=Number(String(e.credit_limit).replace(",","."));(!Number.isFinite(n)||n<0)&&(a.credit_limit="Le plafond de crédit est invalide.")}return(!Number.isFinite(Number(e.payment_terms))||Number(e.payment_terms)<0)&&(a.payment_terms="Le délai de paiement est invalide."),a},y=e=>e>0?"text-accent":e<0?"text-danger":"text-textMuted",d=(e,a)=>[e,...a].map(n=>n.map(l=>`"${String(l??"").replaceAll('"','""')}"`).join(";")).join(`
`),s=(e,a,n="text/plain;charset=utf-8;")=>{const l=new Blob([a],{type:n}),c=window.URL.createObjectURL(l),t=document.createElement("a");t.href=c,t.setAttribute("download",e),document.body.appendChild(t),t.click(),document.body.removeChild(t),window.setTimeout(()=>{window.URL.revokeObjectURL(c)},1e4)},g=({filename:e,title:a,columns:n,rows:l})=>{const c=`
    <html>
      <head>
        <meta charset="utf-8" />
        <style>
          body { font-family: Arial, sans-serif; padding: 24px; }
          h1 { margin-bottom: 16px; }
          table { border-collapse: collapse; width: 100%; }
          th, td { border: 1px solid #d5dbe5; padding: 8px 10px; font-size: 12px; }
          th { background: #eff4fb; text-align: left; }
          td.amount { text-align: right; font-family: monospace; }
        </style>
      </head>
      <body>
        <h1>${a}</h1>
        <table>
          <thead>
            <tr>${n.map(t=>`<th>${t}</th>`).join("")}</tr>
          </thead>
          <tbody>
            ${l.map(t=>`<tr>${t.map(r=>`<td class="${typeof r=="number"?"amount":""}">${r??""}</td>`).join("")}</tr>`).join("")}
          </tbody>
        </table>
      </body>
    </html>
  `;s(e,c,"application/vnd.ms-excel;charset=utf-8;")},v=({title:e,subtitle:a="",columns:n,rows:l})=>{const c=window.open("","_blank","width=1200,height=900");c&&(c.document.write(`
    <html>
      <head>
        <title>${e}</title>
        <style>
          body { font-family: Arial, sans-serif; padding: 24px; color: #0f172a; }
          h1 { margin: 0 0 8px; }
          p { margin: 0 0 18px; color: #475569; }
          table { border-collapse: collapse; width: 100%; }
          th, td { border: 1px solid #d5dbe5; padding: 8px 10px; font-size: 12px; }
          th { background: #eff4fb; text-align: left; }
          td.amount { text-align: right; font-family: monospace; }
        </style>
      </head>
      <body>
        <h1>${e}</h1>
        <p>${a}</p>
        <table>
          <thead>
            <tr>${n.map(t=>`<th>${t}</th>`).join("")}</tr>
          </thead>
          <tbody>
            ${l.map(t=>`<tr>${t.map(r=>`<td class="${typeof r=="number"?"amount":""}">${r??""}</td>`).join("")}</tr>`).join("")}
          </tbody>
        </table>
      </body>
    </html>
  `),c.document.close(),c.focus(),c.print())},x=(e,a,n)=>({csv:d(["Date","N° Pièce","Journal","Libellé","Débit","Crédit","Solde cumulé"],[...a.map(l=>[l.entry_date,l.piece_ref||l.entry_number,l.journal_code,l.label,l.formatted_debit,l.formatted_credit,l.formatted_running_balance]),["","","","Totaux",n.formatted_total_debit,n.formatted_total_credit,n.formatted_final_balance]]),excelRows:[...a.map(l=>[l.entry_date,l.piece_ref||l.entry_number,l.journal_code,l.label,l.formatted_debit,l.formatted_credit,l.formatted_running_balance]),["","","","Totaux",n.formatted_total_debit,n.formatted_total_credit,n.formatted_final_balance]],title:`Relevé de compte - ${e.name}`});export{p as A,u as B,_ as P,i as T,d as a,x as b,b as c,s as d,g as e,y as g,v as p,h as s,f as v};
