import{a as S,i as F,r as c,d as w,j as e,L as y}from"./index-D4ZMoJFe.js";import{F as M,a as A}from"./FinancialStatementsSubnav-CFTBoOxW.js";import{R as E}from"./refresh-ccw-DqBcVzHT.js";import{F as I}from"./file-check-2-Bn1iyHnp.js";import{A as _}from"./arrow-right-CbCEXg_0.js";function O(){var u,g,j,N,b;const{selectedCompanyId:k,selectedCompany:l,user:a}=S(),{pushToast:d}=F(),[o,r]=c.useState(!0),[p,h]=c.useState(""),[t,f]=c.useState(null),x=k||((u=a==null?void 0:a.company)==null?void 0:u.id)||(a==null?void 0:a.companyId)||"",C=c.useMemo(()=>{const s=new Map(M.map(n=>[n.key,n.description]));return((t==null?void 0:t.items)||[]).map(n=>({...n,description:s.get(n.key)||""}))},[t]),m=c.useCallback(async()=>{var s,n;if(!x){f(null),r(!1);return}r(!0),h("");try{const i=await w.get("/financial-statements",{params:{company_id:x}});f(i.data)}catch(i){const v=((n=(s=i==null?void 0:i.response)==null?void 0:s.data)==null?void 0:n.message)||"Impossible de charger les états financiers SCF.";h(v),d({title:"Chargement impossible",description:v,tone:"danger"})}finally{r(!1)}},[x,d]);return c.useEffect(()=>{m()},[m]),e.jsxs("div",{className:"space-y-6",children:[e.jsx("section",{className:"card-panel p-6 sm:p-8",children:e.jsxs("div",{className:"flex flex-col gap-4 xl:flex-row xl:items-start xl:justify-between",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase tracking-[0.2em] text-accent",children:"États financiers SCF"}),e.jsx("h1",{className:"mt-3 text-3xl font-semibold text-text",children:"États Financiers SCF"}),e.jsx("p",{className:"mt-3 max-w-3xl text-sm leading-7 text-textMuted",children:"Préparez le bilan, le compte de résultat, le tableau des flux de trésorerie, la variation des capitaux propres et l'annexe à partir du mapping SCF."})]}),e.jsx(A,{})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 print:hidden",children:[e.jsxs("button",{type:"button",className:"btn-secondary inline-flex items-center gap-2",onClick:m,disabled:o,children:[e.jsx(E,{size:16}),"Actualiser"]}),e.jsxs(y,{to:"/financial-statements/export",className:"btn-primary inline-flex items-center gap-2",children:[e.jsx(I,{size:16}),"Centre d'export"]})]})]})}),e.jsxs("section",{className:"grid gap-4 xl:grid-cols-3",children:[e.jsxs("div",{className:"card-panel p-5",children:[e.jsx("p",{className:"text-xs uppercase tracking-[0.18em] text-textMuted",children:"Société"}),e.jsx("p",{className:"mt-3 text-lg font-semibold text-text",children:((g=t==null?void 0:t.company)==null?void 0:g.name)||(l==null?void 0:l.name)||"—"})]}),e.jsxs("div",{className:"card-panel p-5",children:[e.jsx("p",{className:"text-xs uppercase tracking-[0.18em] text-textMuted",children:"Exercice courant"}),e.jsx("p",{className:"mt-3 text-lg font-semibold text-text",children:((j=t==null?void 0:t.fiscal_year)==null?void 0:j.label)||((N=a==null?void 0:a.fiscalYear)==null?void 0:N.label)||"—"})]}),e.jsxs("div",{className:"card-panel p-5",children:[e.jsx("p",{className:"text-xs uppercase tracking-[0.18em] text-textMuted",children:"Comparatif"}),e.jsx("p",{className:"mt-3 text-lg font-semibold text-text",children:((b=t==null?void 0:t.comparative_fiscal_year)==null?void 0:b.label)||"Non disponible"})]})]}),p?e.jsx("section",{className:"card-panel p-8",children:e.jsx("p",{className:"text-sm text-danger",children:p})}):null,e.jsx("section",{className:"grid gap-4 xl:grid-cols-2",children:o?e.jsx("div",{className:"card-panel p-8 text-sm text-textMuted xl:col-span-2",children:"Chargement des états financiers..."}):C.map(s=>e.jsxs(y,{to:s.path,className:"card-panel group flex h-full flex-col justify-between p-6 transition hover:border-accent/30 hover:bg-accent/5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase tracking-[0.18em] text-accent",children:s.key==="mapping"?"Paramétrage":"État réglementaire"}),e.jsx("h2",{className:"mt-3 text-xl font-semibold text-text",children:s.title}),e.jsx("p",{className:"mt-3 text-sm leading-7 text-textMuted",children:s.description})]}),e.jsxs("div",{className:"mt-5 inline-flex items-center gap-2 text-sm font-medium text-accent",children:["Ouvrir",e.jsx(_,{size:16,className:"transition group-hover:translate-x-1"})]})]},s.key))})]})}export{O as default};
