import{s as je,a as De,e as Pe,b as qe,u as Ge,g as Je,d as Ke,r as Qe,f as Te,o as We,n as ae}from"../chunks/DHedsUi_.js";import{S as Ae,i as He,k as ie,l as te,m as W,n as ce,o as fe,p as ue,d as f,x as me,A as ve,q as Ue,a as le,b as n,r as de,u as m,z as be,c as d,e as b,g as z,v as ne,f as A,h as _,j as O,t as H,s as se,y as Ye,w as Se,B as Ne}from"../chunks/G8UKEBBn.js";import{I as Xe,g as Ze,a as et,e as re}from"../chunks/C1tDbyYL.js";import{a as $e}from"../chunks/DjUyxgK6.js";import{F as tt}from"../chunks/CUwAs-mp.js";import{D as lt}from"../chunks/BojKV9te.js";import{T as st,a as at}from"../chunks/7IRyKQzz.js";function rt(r){let e;const l=r[2].default,t=qe(l,r,r[3],null);return{c(){t&&t.c()},l(a){t&&t.l(a)},m(a,o){t&&t.m(a,o),e=!0},p(a,o){t&&t.p&&(!e||o&8)&&Ge(t,l,a,a[3],e?Ke(l,a[3],o,null):Je(a[3]),null)},i(a){e||(W(t,a),e=!0)},o(a){te(t,a),e=!1},d(a){t&&t.d(a)}}}function nt(r){let e,l;const t=[{name:"minus"},r[1],{iconNode:r[0]}];let a={$$slots:{default:[rt]},$$scope:{ctx:r}};for(let o=0;o{l(1,e=De(De({},e),Pe(s))),"$$scope"in s&&l(3,a=s.$$scope)},e=Pe(e),[o,e,t,a]}class it extends Ae{constructor(e){super(),He(this,e,ot,nt,je,{})}}function ze(r,e,l){const t=r.slice();return t[15]=e[l],t}function ct(r,e,l){const t=r.slice();return t[12]=e[l],t}function Oe(r,e,l){const t=r.slice();return t[18]=e[l],t}function Be(r,e,l){const t=r.slice();return t[21]=e[l],t}function Fe(r){let e,l=r[21].name+"",t,a;return{c(){e=_("option"),t=H(l),this.h()},l(o){e=d(o,"OPTION",{});var s=b(e);t=A(s,l),s.forEach(f),this.h()},h(){e.__value=a=r[21].id,be(e,e.__value)},m(o,s){le(o,e,s),n(e,t)},p(o,s){s&2&&l!==(l=o[21].name+"")&&se(t,l),s&2&&a!==(a=o[21].id)&&(e.__value=a,be(e,e.__value))},d(o){o&&f(e)}}}function Le(r){let e,l=r[18]+"",t;return{c(){e=_("option"),t=H(l),this.h()},l(a){e=d(a,"OPTION",{});var o=b(e);t=A(o,l),o.forEach(f),this.h()},h(){e.__value=r[18],be(e,e.__value)},m(a,o){le(a,e,o),n(e,t)},p:ae,d(a){a&&f(e)}}}function ft(r){let e,l,t,a,o=re(r[0]),s=[];for(let c=0;cte(s[c],1,1,()=>{s[c]=null});let h=r[0].length>1&&Re(r);return{c(){e=_("div");for(let c=0;c1?h?h.p(c,g):(h=Re(c),h.c(),h.m(t.parentNode,t)):h&&(h.d(1),h=null)},i(c){if(!a){for(let g=0;g=0?"text-green-600":"text-red-500")),m(p,"class","px-5 py-4"),m(V,"class","grid grid-cols-3 divide-x divide-gray-50 dark:divide-gray-800"),m(e,"class","bg-white dark:bg-gray-900 rounded-xl border border-gray-100 dark:border-gray-800 overflow-hidden")},m(I,S){le(I,e,S),n(e,l),n(l,t),n(t,o),n(l,s),n(l,y),n(y,h),n(y,g),n(e,u),n(e,V),n(V,P),n(P,U),ce(x,U,null),n(U,w),n(P,B),n(P,F),n(F,J),n(V,N),n(V,Y),n(Y,$),ce(D,$,null),n($,X),n(Y,Z),n(Y,j),n(j,C),n(V,G),n(V,p),n(p,T),ce(L,T,null),n(T,Q),n(p,i),n(p,k),n(k,v),n(e,ee),K=!0},p(I,S){(!K||S&1)&&a!==(a=I[15].property_name+"")&&se(o,a),(!K||S&17)&&c!==(c=(I[15].year||I[4])+"")&&se(g,c),(!K||S&1)&&q!==(q=I[7](I[15].total_income)+"")&&se(J,q),(!K||S&1)&&R!==(R=I[7](I[15].total_expense)+"")&&se(C,R),(!K||S&1)&&E!==(E=I[7](I[15].balance)+"")&&se(v,E),(!K||S&1&&M!==(M="text-lg font-semibold "+(I[15].balance>=0?"text-green-600":"text-red-500")))&&m(k,"class",M)},i(I){K||(W(x.$$.fragment,I),W(D.$$.fragment,I),W(L.$$.fragment,I),K=!0)},o(I){te(x.$$.fragment,I),te(D.$$.fragment,I),te(L.$$.fragment,I),K=!1},d(I){I&&f(e),ie(x),ie(D),ie(L)}}}function Re(r){let e,l,t,a,o,s,y,h,c="Revenus totaux",g,u,V=r[7](r[5].income)+"",P,U,x,w,B="Dépenses totales",F,q,J=r[7](r[5].expense)+"",N,Y,$,D,X="Bénéfice net",Z,j,R=r[7](r[5].balance)+"",C,G;return{c(){e=_("div"),l=_("h3"),t=H("Total consolidé — "),a=H(r[4]),o=O(),s=_("div"),y=_("div"),h=_("p"),h.textContent=c,g=O(),u=_("p"),P=H(V),U=O(),x=_("div"),w=_("p"),w.textContent=B,F=O(),q=_("p"),N=H(J),Y=O(),$=_("div"),D=_("p"),D.textContent=X,Z=O(),j=_("p"),C=H(R),this.h()},l(p){e=d(p,"DIV",{class:!0});var T=b(e);l=d(T,"H3",{class:!0});var L=b(l);t=A(L,"Total consolidé — "),a=A(L,r[4]),L.forEach(f),o=z(T),s=d(T,"DIV",{class:!0});var Q=b(s);y=d(Q,"DIV",{});var i=b(y);h=d(i,"P",{class:!0,"data-svelte-h":!0}),ne(h)!=="svelte-174cuzg"&&(h.textContent=c),g=z(i),u=d(i,"P",{class:!0});var k=b(u);P=A(k,V),k.forEach(f),i.forEach(f),U=z(Q),x=d(Q,"DIV",{});var E=b(x);w=d(E,"P",{class:!0,"data-svelte-h":!0}),ne(w)!=="svelte-sdhht4"&&(w.textContent=B),F=z(E),q=d(E,"P",{class:!0});var v=b(q);N=A(v,J),v.forEach(f),E.forEach(f),Y=z(Q),$=d(Q,"DIV",{});var M=b($);D=d(M,"P",{class:!0,"data-svelte-h":!0}),ne(D)!=="svelte-o6g5rn"&&(D.textContent=X),Z=z(M),j=d(M,"P",{class:!0});var ee=b(j);C=A(ee,R),ee.forEach(f),M.forEach(f),Q.forEach(f),T.forEach(f),this.h()},h(){m(l,"class","text-sm font-medium text-gray-400 mb-4"),m(h,"class","text-xs text-gray-400 mb-1"),m(u,"class","text-xl font-semibold text-green-400"),m(w,"class","text-xs text-gray-400 mb-1"),m(q,"class","text-xl font-semibold text-red-400"),m(D,"class","text-xs text-gray-400 mb-1"),m(j,"class",G="text-xl font-semibold "+(r[5].balance>=0?"text-green-400":"text-red-400")),m(s,"class","grid grid-cols-3 gap-4"),m(e,"class","bg-gray-900 dark:bg-gray-800 rounded-xl p-5 text-white")},m(p,T){le(p,e,T),n(e,l),n(l,t),n(l,a),n(e,o),n(e,s),n(s,y),n(y,h),n(y,g),n(y,u),n(u,P),n(s,U),n(s,x),n(x,w),n(x,F),n(x,q),n(q,N),n(s,Y),n(s,$),n($,D),n($,Z),n($,j),n(j,C)},p(p,T){T&16&&se(a,p[4]),T&32&&V!==(V=p[7](p[5].income)+"")&&se(P,V),T&32&&J!==(J=p[7](p[5].expense)+"")&&se(N,J),T&32&&R!==(R=p[7](p[5].balance)+"")&&se(C,R),T&32&&G!==(G="text-xl font-semibold "+(p[5].balance>=0?"text-green-400":"text-red-400"))&&m(j,"class",G)},d(p){p&&f(e)}}}function _t(r){let e;return{c(){e=_("div"),this.h()},l(l){e=d(l,"DIV",{class:!0}),b(e).forEach(f),this.h()},h(){m(e,"class","h-32 bg-gray-100 dark:bg-gray-800 rounded-xl animate-pulse")},m(l,t){le(l,e,t)},p:ae,d(l){l&&f(e)}}}function pt(r){let e,l,t,a,o,s,y="Export fiscal",h,c,g,u,V,P,U=`L'export CSV est formaté pour Excel (séparateur point-virgule, encodage UTF-8 avec BOM). Il reprend toutes les transactions de l'année sélectionnée avec leur catégorie, et inclut le total des revenus, dépenses et le bénéfice net.`,x,w,B,F,q="Tous les biens",J,N,Y,$,D,X,Z,j;a=new tt({props:{size:22,class:"text-gray-400"}}),g=new lt({props:{size:16}});let R=re(r[1]),C=[];for(let i=0;ir[10].call(B)),m(N,"class","px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"),r[4]===void 0&&Te(()=>r[11].call(N)),m(w,"class","flex flex-wrap gap-3 mb-6"),m(e,"class","p-6 max-w-4xl mx-auto")},m(i,k){le(i,e,k),n(e,l),n(l,t),ce(a,t,null),n(t,o),n(t,s),n(l,h),n(l,c),ce(g,c,null),n(c,u),n(e,V),n(e,P),n(e,x),n(e,w),n(w,B),n(B,F);for(let E=0;E{L[E]=null}),Ue(),D=L[$],D?D.p(i,k):(D=L[$]=T[$](i),D.c()),W(D,1),D.m(e,null))},i(i){X||(W(a.$$.fragment,i),W(g.$$.fragment,i),W(D),X=!0)},o(i){te(a.$$.fragment,i),te(g.$$.fragment,i),te(D),X=!1},d(i){i&&f(e),ie(a),ie(g),me(C,i),me(p,i),L[$].d(),Z=!1,Qe(j)}}}function ht(r,e,l){let t,a=[],o=[],s=!0,y="",h=String(new Date().getFullYear());const c=Array.from({length:5},(x,w)=>String(new Date().getFullYear()-w)),g=x=>Number(x||0).toLocaleString("fr-FR",{minimumFractionDigits:2})+" €";We(async()=>{l(1,a=await $e.properties.list()||[]),await u()});async function u(){l(2,s=!0);const x={year:h};y&&(x.property_id=y),l(0,o=await $e.fiscal.summary(x)||[]),l(2,s=!1)}function V(){const x={year:h};y&&(x.property_id=y),window.open($e.fiscal.exportUrl(x),"_blank")}function P(){y=Ne(this),l(3,y),l(1,a)}function U(){h=Ne(this),l(4,h),l(6,c)}return r.$$.update=()=>{r.$$.dirty&1&&l(5,t=o.reduce((x,w)=>({income:x.income+(w.total_income||0),expense:x.expense+(w.total_expense||0),balance:x.balance+(w.balance||0)}),{income:0,expense:0,balance:0}))},[o,a,s,y,h,t,c,g,u,V,P,U]}class Et extends Ae{constructor(e){super(),He(this,e,ht,pt,je,{})}}export{Et as component};