Plugin Directory

Changeset 3233000


Ignore:
Timestamp:
02/01/2025 09:24:38 AM (14 months ago)
Author:
melioze
Message:

version 1.4.6

Location:
my-easy-compta
Files:
793 added
13 edited

Legend:

Unmodified
Added
Removed
  • my-easy-compta/trunk/assets/dist/api.min.js

    r3198779 r3233000  
    1 (function(t,n){const x=o,e=t();for(;[];)try{if(parseInt(x(157))/1+parseInt(x(145))/2+-parseInt(x(165))/3+-parseInt(x(147))/4*(-parseInt(x(163))/5)+parseInt(x(154))/6+-parseInt(x(164))/7+parseInt(x(149))/8===n)break;e.push(e.shift())}catch{e.push(e.shift())}})(i,533847);function o(t,n){const x=i();return o=function(e,a){return e=e-145,x[e]},o(t,n)}function d(t,n,x="\u20AC"){const e=o,a=parseFloat(t),c=parseFloat(n),r=a*(c/100);return(a+r)[e(150)](2)[e(159)](/\B(?=(\d{3})+(?!\d))/g," ")+" "+x}function i(){const t=["toFixed","message","YYYY","length","1724556aQeIwl","...","before","411747Ngehzc","visible","replace","split","indexOf","push","15650mHtAdm","3486420DwrHvY","2634936dAOTfo","1071960JjqVWm","type","676oZNDjz","toString","1168768kuGUZs"];return i=function(){return t},i()}function l(t,n="\u20AC"){const x=o;return parseFloat(t)[x(150)](2).replace(/\B(?=(\d{3})+(?!\d))/g," ")+" "+n}function _(t,n){const x=o;let e=[];if(n<=5)for(let a=1;a<=n;a++)e[x(162)](a);else if(t<=3){for(let a=1;a<=5;a++)e[x(162)](a);e.push(x(155)),e[x(162)](n)}else if(t>n-3){e[x(162)](1),e.push(x(155));for(let a=n-4;a<=n;a++)e.push(a)}else{e.push(1),e[x(162)]("...");for(let a=t-1;a<=t+1;a++)e[x(162)](a);e[x(162)](x(155)),e[x(162)](n)}return e}function h(t,n,x){const e=o,a=parseFloat(t).toFixed(2)[e(159)](/\B(?=(\d{3})+(?!\d))/g," ");return x===e(156)?n+" "+a:a+" "+n}function m(t,n,x){const e=o;t[e(151)]=n,t[e(146)]=x,t.visible=!![],setTimeout(()=>{const a=e;t[a(158)]=![]},3e3)}(function(t,n){const x=u,e=t();for(;[];)try{if(-parseInt(x(145))/1+-parseInt(x(154))/2+parseInt(x(156))/3+-parseInt(x(164))/4+-parseInt(x(162))/5+-parseInt(x(160))/6+parseInt(x(158))/7===n)break;e.push(e.shift())}catch{e.push(e.shift())}})(p,305098);async function y(){const t=u;try{const n=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:t(163),headers:{"Content-Type":t(153),"X-WP-Nonce":myEasyComptaAdmin[t(150)]}});if(n.ok){const x=await n[t(159)]();let e=null,a=null,c=null;if(x[t(148)]){const r=x[t(148)],s=await fetch(t(147)+r,{method:t(163),headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});s.ok?e=(await s[t(159)]())[t(149)]:console.error("Failed to fetch currency data:",s[t(157)])}if(x[t(155)]==1){const r=x[t(146)],s=await fetch(t(165)+r,{method:t(163),headers:{"Content-Type":t(153),"X-WP-Nonce":myEasyComptaAdmin[t(150)]}});s.ok?a=await s[t(159)]():console[t(152)](t(166),s[t(157)]);const f=await fetch(t(151),{method:"GET",headers:{"Content-Type":t(153),"X-WP-Nonce":myEasyComptaAdmin[t(150)]}});f.ok?c=await f.json():console[t(152)](t(166),f.statusText)}else a=0,c=0;return{settings:x,currencySymbol:e,vatData:a,listVatData:c}}else{const x=await n[t(159)]();throw new Error(x[t(161)])}}catch(n){throw console[t(152)](n),new Error(n[t(161)])}}function u(t,n){const x=p();return u=function(e,a){return e=e-145,x[e]},u(t,n)}function p(){const t=["256787GfDCZt","default_vat","/wp-json/my-easy-compta/v1/settings/currency/","default_currency","symbol","nonce","/wp-json/my-easy-compta/v1/settings/vats","error","application/json","108060tUBZmi","vat_active","1751346bnNmui","statusText","8127196IqaMkg","json","3027240ZthHWF","message","847000cEDMkn","GET","1819820xRIJth","/wp-json/my-easy-compta/v1/settings/vat/","Failed to fetch VAT data:"];return p=function(){return t},p()}export{l as a,h as b,d as c,y as f,_ as g,m as s};
     1function f(){const x=["1008WoePvl","toString","209930vcpihy","...","28Szbzgm","410824CKtXRq","visible","YYYY","type","before","24369JvYmXN","split","Invalid Date","push","6clJdjA","38071QrOsFs","13ShAfMX","418539fEIipE","8410BrjzhS","length","2691qlKoKe","message","replace","652PCZBrT","96RJLJIs","indexOf","28262486ESnXUc","toFixed"];return f=function(){return x},f()}(function(x,n){const t=o,e=x();for(;[];)try{if(parseInt(t(328))/1*(-parseInt(t(325))/2)+-parseInt(t(321))/3*(-parseInt(t(334))/4)+-parseInt(t(341))/5*(parseInt(t(335))/6)+parseInt(t(343))/7*(-parseInt(t(316))/8)+-parseInt(t(331))/9*(parseInt(t(329))/10)+-parseInt(t(326))/11*(parseInt(t(339))/12)+parseInt(t(327))/13*(parseInt(t(337))/14)===n)break;e.push(e.shift())}catch{e.push(e.shift())}})(f,667810);function l(x,n,t="\u20AC"){const e=o,a=parseFloat(x),c=parseFloat(n),r=a*(c/100);return(a+r)[e(338)](2)[e(333)](/\B(?=(\d{3})+(?!\d))/g," ")+" "+t}function o(x,n){const t=f();return o=function(e,a){return e=e-316,t[e]},o(x,n)}function u(x,n="\u20AC"){const t=o;return parseFloat(x)[t(338)](2)[t(333)](/\B(?=(\d{3})+(?!\d))/g," ")+" "+n}function _(x,n){const t=o;let e=[];if(n<=5)for(let a=1;a<=n;a++)e[t(324)](a);else if(x<=3){for(let a=1;a<=5;a++)e[t(324)](a);e[t(324)]("..."),e[t(324)](n)}else if(x>n-3){e[t(324)](1),e[t(324)](t(342));for(let a=n-4;a<=n;a++)e.push(a)}else{e[t(324)](1),e[t(324)](t(342));for(let a=x-1;a<=x+1;a++)e[t(324)](a);e[t(324)](t(342)),e[t(324)](n)}return e}function h(x,n,t){const e=o,a=parseFloat(x)[e(338)](2)[e(333)](/\B(?=(\d{3})+(?!\d))/g," ");return t===e(320)?n+" "+a:a+" "+n}function y(x,n,t){const e=o;x[e(332)]=n,x[e(319)]=t,x.visible=!![],setTimeout(()=>{const a=e;x[a(317)]=![]},3e3)}(function(x,n){const t=d,e=x();for(;[];)try{if(-parseInt(t(484))/1*(-parseInt(t(489))/2)+parseInt(t(479))/3*(parseInt(t(483))/4)+parseInt(t(475))/5*(parseInt(t(481))/6)+-parseInt(t(497))/7+-parseInt(t(495))/8+-parseInt(t(496))/9+-parseInt(t(480))/10*(-parseInt(t(492))/11)===n)break;e.push(e.shift())}catch{e.push(e.shift())}})(p,895587);function d(x,n){const t=p();return d=function(e,a){return e=e-474,t[e]},d(x,n)}function p(){const x=["/wp-json/my-easy-compta/v1/settings/vat/","/wp-json/my-easy-compta/v1/settings/get","message","/wp-json/my-easy-compta/v1/settings/currency/","936lUgvUF","symbol","json","286bfPKuw","default_currency","Failed to fetch VAT data:","2851904EMysxV","12957768gkxEAZ","4515504kLnQLj","application/json","statusText","738135vZXKwB","GET","Failed to fetch currency data:","error","2120949hVPeAs","202690TDlsQp","60PoGanK","nonce","4tvCMno","1339FvvyRP"];return p=function(){return x},p()}async function m(){const x=d;try{const n=await fetch(x(486),{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin[x(482)]}});if(n.ok){const t=await n[x(491)]();let e=null,a=null,c=null;if(t[x(493)]){const r=t[x(493)],s=await fetch(x(488)+r,{method:x(476),headers:{"Content-Type":x(498),"X-WP-Nonce":myEasyComptaAdmin[x(482)]}});s.ok?e=(await s[x(491)]())[x(490)]:console[x(478)](x(477),s[x(474)])}if(t.vat_active==1){const r=t.default_vat,s=await fetch(x(485)+r,{method:x(476),headers:{"Content-Type":x(498),"X-WP-Nonce":myEasyComptaAdmin[x(482)]}});s.ok?a=await s[x(491)]():console[x(478)](x(494),s[x(474)]);const i=await fetch("/wp-json/my-easy-compta/v1/settings/vats",{method:x(476),headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin[x(482)]}});i.ok?c=await i[x(491)]():console.error("Failed to fetch VAT data:",i[x(474)])}else a=0,c=0;return{settings:t,currencySymbol:e,vatData:a,listVatData:c}}else{const t=await n[x(491)]();throw new Error(t[x(487)])}}catch(n){throw console.error(n),new Error(n[x(487)])}}export{u as a,h as b,l as c,m as f,_ as g,y as s};
  • my-easy-compta/trunk/assets/dist/app.min.js

    r3198779 r3233000  
    1 import{_ as p,o as a,c as o,a as t,t as i,F as f,r as x,b as h,d as u,e as v,f as E,h as b}from"./plugin-vue_export-helper.min.js";const C={name:"Stats",data(){return{unpaidAmountsByCurrency:[],MonthExpenses:0,currentMonthEarnings:"",totalEarnings:"",symbol:"",loading:!1}},mounted(){this.calculateUnpaidAmount(),this.calculateCurrentMonthExpenses(),this.fetchCurrentMonthEarnings(),this.fetchTotalEarnings()},methods:{async calculateUnpaidAmount(){try{this.loading=!0;const n=await(await fetch("/wp-json/my-easy-compta/v1/stats/unpaid-invoices",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}})).json(),r=[];for(const l in n){const{total_amount:e,symbol:c}=n[l];r.push({currencyId:l,total_amount:e,symbol:c})}this.unpaidAmountsByCurrency=r,this.loading=!1}catch(s){console.error("Erreur lors du calcul des montants impay\xE9s :",s),this.loading=!1}},async calculateCurrentMonthExpenses(){try{this.loading=!0;const n=await(await fetch("/wp-json/my-easy-compta/v1/stats/expenses-month",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}})).json();this.MonthExpenses=n.total_expenses,this.symbol=n.default_currency,this.loading=!1}catch(s){console.error("Erreur lors de la r\xE9cup\xE9ration des d\xE9penses du mois en cours :",s),this.loading=!1}},async fetchCurrentMonthEarnings(){try{this.loading=!0;const s=await fetch("/wp-json/my-easy-compta/v1/stats/current-month-earnings",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const n=await s.json();this.currentMonthEarnings=n,this.loading=!1}catch(s){console.error("Erreur lors de la r\xE9cup\xE9ration des revenus du mois en cours :",s),this.loading=!1}},async fetchTotalEarnings(){try{this.loading=!0;const s=await fetch("/wp-json/my-easy-compta/v1/stats/total-earnings",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const n=await s.json();this.totalEarnings=n,this.loading=!1}catch(s){console.error("Erreur lors de la r\xE9cup\xE9ration de la totalit\xE9 des revenus :",s),this.loading=!1}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},T={class:"mt-8"},A={class:"grid lg:grid-cols-4 mt-2 md:grid-cols-2 grid-cols-1 gap-6"},I={class:"stats shadow border"},M={class:"stat"},P=t("div",{class:"stat-figure dark:text-slate-300 text-primary"},[t("i",{class:"fas fa-hand-holding-usd text-4xl"})],-1),j={class:"stat-title dark:text-slate-300"},$={class:"stat-value dark:text-slate-300 text-primary"},N={key:0},B=h('<div class="flex flex-col gap-4 w-40"><div class="flex gap-4 items-center"><div class="flex flex-col gap-4"><div class="skeleton h-4 w-40"></div><div class="skeleton h-4 w-40"></div></div></div></div>',1),S=[B],G={key:1},H={class:"stats shadow border"},V={class:"stat"},W=t("div",{class:"stat-figure dark:text-slate-300 text-primary"},[t("i",{class:"fas fa-receipt text-4xl"})],-1),X={class:"stat-title dark:text-slate-300"},F={class:"stat-value dark:text-slate-300 text-primary"},R={key:0},L=h('<div class="flex flex-col gap-4 w-40"><div class="flex gap-4 items-center"><div class="flex flex-col gap-4"><div class="skeleton h-4 w-40"></div><div class="skeleton h-4 w-40"></div></div></div></div>',1),D=[L],Y={key:1},Z={key:0},J={key:1},K={class:"stat-desc"},U={class:"stats shadow border"},q={class:"stat"},z=t("div",{class:"stat-figure dark:text-slate-300 text-primary"},[t("i",{class:"far fa-money-bill-alt text-4xl"})],-1),O={class:"stat-title dark:text-slate-300"},Q={class:"stat-value dark:text-slate-300 text-primary"},ss={key:0},ts=h('<div class="flex flex-col gap-4 w-40"><div class="flex gap-4 items-center"><div class="flex flex-col gap-4"><div class="skeleton h-4 w-40"></div><div class="skeleton h-4 w-40"></div></div></div></div>',1),es=[ts],ns={key:1},as={key:0},os={key:1},is={class:"stat-desc"},rs={class:"stats shadow border"},cs={class:"stat"},ls=t("div",{class:"stat-figure dark:text-slate-300 text-primary"},[t("i",{class:"fas fa-file-invoice-dollar text-4xl"})],-1),ds={class:"stat-title dark:text-slate-300"},hs={class:"stat-value dark:text-slate-300 text-primary"},_s={key:0},ms=h('<div class="flex flex-col gap-4 w-40"><div class="flex gap-4 items-center"><div class="flex flex-col gap-4"><div class="skeleton h-4 w-40"></div><div class="skeleton h-4 w-40"></div></div></div></div>',1),ps=[ms],us={key:1},vs={key:0},ys={key:1},fs=t("div",{class:"stat-desc"},null,-1);function xs(s,n,r,l,e,c){return a(),o("div",T,[t("div",A,[t("div",I,[t("div",M,[P,t("div",j,i(c.translations.unpaid),1),t("div",$,[e.loading?(a(),o("div",N,S)):(a(),o("div",G,[(a(!0),o(f,null,x(e.unpaidAmountsByCurrency,d=>(a(),o("div",{key:d.currencyId},i(d.total_amount)+i(d.symbol),1))),128))]))])])]),t("div",H,[t("div",V,[W,t("div",X,i(c.translations.expenses),1),t("div",F,[e.loading?(a(),o("div",R,D)):(a(),o("div",Y,[e.MonthExpenses?(a(),o("span",Z,i(e.MonthExpenses)+i(e.symbol),1)):(a(),o("span",J," 0"+i(e.symbol),1))]))]),t("div",K,i(c.translations.current_month),1)])]),t("div",U,[t("div",q,[z,t("div",O,i(c.translations.earnings),1),t("div",Q,[e.loading?(a(),o("div",ss,es)):(a(),o("div",ns,[e.currentMonthEarnings?(a(),o("span",as,i(e.currentMonthEarnings.total)+" "+i(e.currentMonthEarnings.default_currency_symbol),1)):(a(),o("span",os," 0"+i(e.symbol),1))]))]),t("div",is,i(c.translations.current_month),1)])]),t("div",rs,[t("div",cs,[ls,t("div",ds,i(c.translations.all_Earnings),1),t("div",hs,[e.loading?(a(),o("div",_s,ps)):(a(),o("div",us,[e.totalEarnings?(a(),o("span",vs,i(e.totalEarnings.total)+" "+i(e.totalEarnings.default_currency_symbol),1)):(a(),o("span",ys," 0"+i(e.totalEarnings.default_currency_symbol),1))]))]),fs])])])])}var gs=p(C,[["render",xs]]);const ws={name:"BarChart",data(){return{payments:[],expenses:[],months:[],loading:!0}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},mounted(){this.fetchMonthlyPaymentsExpenses()},methods:{async fetchMonthlyPaymentsExpenses(){try{const s=await fetch("/wp-json/my-easy-compta/v1/stats/monthly-payments-expenses",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const n=await s.json();this.payments=n.payments,this.expenses=n.expenses,this.months=n.months,this.loading=!1,this.$nextTick(()=>{this.loadChart()})}catch(s){console.error("Erreur lors de la r\xE9cup\xE9ration des paiements et des d\xE9penses mensuels:",s),this.loading=!1}},loadChart(){typeof Chart!="undefined"?this.createChart():console.error("Chart.js is not loaded")},createChart(){const s=this.translations,n=document.getElementById("bar-chart").getContext("2d");new Chart(n,{type:"bar",data:{labels:this.months,datasets:[{label:s.earnings,backgroundColor:"#42A5F5",data:this.payments},{label:s.expenses,backgroundColor:"#FF00AA",data:this.expenses}]},options:{responsive:!0,scales:{x:{beginAtZero:!0},y:{beginAtZero:!0}}}})}}},ks={class:"text-xl font-semibold"},Es=t("div",{class:"divider mt-2"},null,-1),bs={class:"h-full w-full pb-6"},Cs={key:0},Ts=h('<div class="flex flex-col gap-4 w-full"><div class="skeleton h-4 w-full"></div><div class="skeleton h-4 w-full"></div><div class="skeleton h-32 w-full"></div><div class="skeleton h-4 w-full"></div><div class="skeleton h-4 w-full"></div></div>',1),As=[Ts],Is={key:1,id:"bar-chart"};function Ms(s,n,r,l,e,c){return a(),o("div",null,[t("div",ks,i(c.translations.annual_payments_overview),1),Es,t("div",bs,[e.loading?(a(),o("div",Cs,As)):(a(),o("canvas",Is))])])}var Ps=p(ws,[["render",Ms]]);const js={name:"InvoicesHistory",data(){return{recentPayments:[],loading:!0}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},mounted(){this.fetchRecentPayments()},methods:{async fetchRecentPayments(){try{const s=await fetch("/wp-json/my-easy-compta/v1/stats/recent-payments",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const n=await s.json();this.recentPayments=n,this.loading=!1}catch(s){console.error("Erreur lors de la r\xE9cup\xE9ration des paiements r\xE9cents:",s),this.loading=!1}}}},$s={class:"text-xl font-semibold"},Ns=t("div",{class:"divider mt-2"},null,-1),Bs={class:"overflow-x-auto"},Ss={key:0},Gs=h('<div class="flex flex-col gap-4 w-full"><div class="skeleton h-4 w-full"></div><div class="skeleton h-4 w-full"></div><div class="skeleton h-32 w-full"></div><div class="skeleton h-4 w-full"></div><div class="skeleton h-4 w-full"></div></div>',1),Hs=[Gs],Vs={key:1},Ws={class:"text-gray-500"},Xs={key:2,class:"table table-xs ecwp-table-dash-invoice"},Fs={class:"badge badge-outline badge-success badge-sm"};function Rs(s,n,r,l,e,c){return a(),o("div",null,[t("div",$s,i(c.translations.recently_paid_invoice),1),Ns,t("div",Bs,[e.loading?(a(),o("div",Ss,Hs)):e.recentPayments.length===0?(a(),o("div",Vs,[t("div",Ws,i(c.translations.no_data_for_moment),1)])):(a(),o("table",Xs,[t("tbody",null,[(a(!0),o(f,null,x(e.recentPayments,d=>(a(),o("tr",{key:d.invoice_number},[t("td",null,i(d.invoice_number),1),t("td",null,i(d.total_amount)+i(d.symbol),1),t("td",null,[t("span",Fs,i(d.method_name),1)])]))),128))])]))])])}var Ls=p(js,[["render",Rs]]);const Ds={name:"Dashboard",components:{Stats:gs,BarChart:Ps,InvoicesHistory:Ls},methods:{setTheme(s){document.documentElement.setAttribute("data-theme",s),localStorage.setItem("theme",s)},toggleTheme(){document.documentElement.getAttribute("data-theme")==="dark"?this.setTheme("winter"):this.setTheme("dark")}},mounted(){const s=localStorage.getItem("theme");s?this.setTheme(s):window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches&&this.setTheme("dark")},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},Ys={class:"relative pt-2 pr-4"},Zs={class:"ecwp-swap swap swap-rotate bg-base-100 p-2 mt-10"},Js=t("i",{class:"swap-off far fa-sun text-xl"},null,-1),Ks=t("i",{class:"swap-on far fa-moon text-xl"},null,-1),Us={class:"grid lg:grid-cols-3 mt-4 grid-cols-1 gap-6"},qs={class:"card w-full p-6 bg-base-100 shadow-xl col-span-2 mt-4"},zs={class:"card w-full p-6 bg-base-100 shadow-xl mt-4"};function Os(s,n,r,l,e,c){const d=u("Stats"),g=u("BarChart"),w=u("InvoicesHistory");return a(),o("div",Ys,[t("label",Zs,[t("input",{type:"checkbox",class:"theme-controller",onChange:n[0]||(n[0]=(...k)=>c.toggleTheme&&c.toggleTheme(...k))},null,32),Js,Ks]),v(d),t("div",Us,[t("div",qs,[v(g)]),t("div",zs,[v(w)])])])}var Qs=p(Ds,[["render",Os]]);const y=m;(function(s,n){const r=m,l=s();for(;[];)try{if(-parseInt(r(456))/1*(parseInt(r(465))/2)+-parseInt(r(458))/3*(-parseInt(r(463))/4)+-parseInt(r(464))/5+-parseInt(r(455))/6+-parseInt(r(462))/7*(parseInt(r(460))/8)+-parseInt(r(466))/9*(parseInt(r(461))/10)+parseInt(r(454))/11===n)break;l.push(l.shift())}catch{l.push(l.shift())}})(_,459597);function _(){const s=["56sRRwZh","1673510gLdnfm","442771JKtPNK","1433780eMTcLg","654570LYcrYd","259124GmJvNd","9VNtRwd","19750544cnVNEI","4942524GyreVC","1MScYeo","mount","3nMDpnP","#my-easy-compta-admin-app"];return _=function(){return s},_()}function m(s,n){const r=_();return m=function(l,e){return l=l-454,r[l]},m(s,n)}const st=E({render:()=>b(Qs)});st[y(457)](y(459));
     1import{_ as u,o as a,c as o,a as t,t as i,F as y,r as f,b as h,d as p,e as v,f as k,h as b}from"./plugin-vue_export-helper.min.js";const E={name:"Stats",data(){return{unpaidAmountsByCurrency:[],MonthExpenses:0,currentMonthEarnings:"",totalEarnings:"",symbol:"",loading:!1}},mounted(){this.calculateUnpaidAmount(),this.calculateCurrentMonthExpenses(),this.fetchCurrentMonthEarnings(),this.fetchTotalEarnings()},methods:{async calculateUnpaidAmount(){try{this.loading=!0;const n=await(await fetch("/wp-json/my-easy-compta/v1/stats/unpaid-invoices",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}})).json(),r=[];for(const l in n){const{total_amount:e,symbol:c}=n[l];r.push({currencyId:l,total_amount:e,symbol:c})}this.unpaidAmountsByCurrency=r,this.loading=!1}catch(s){console.error("Erreur lors du calcul des montants impay\xE9s :",s),this.loading=!1}},async calculateCurrentMonthExpenses(){try{this.loading=!0;const n=await(await fetch("/wp-json/my-easy-compta/v1/stats/expenses-month",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}})).json();this.MonthExpenses=n.total_expenses,this.symbol=n.default_currency,this.loading=!1}catch(s){console.error("Erreur lors de la r\xE9cup\xE9ration des d\xE9penses du mois en cours :",s),this.loading=!1}},async fetchCurrentMonthEarnings(){try{this.loading=!0;const s=await fetch("/wp-json/my-easy-compta/v1/stats/current-month-earnings",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const n=await s.json();this.currentMonthEarnings=n,this.loading=!1}catch(s){console.error("Erreur lors de la r\xE9cup\xE9ration des revenus du mois en cours :",s),this.loading=!1}},async fetchTotalEarnings(){try{this.loading=!0;const s=await fetch("/wp-json/my-easy-compta/v1/stats/total-earnings",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const n=await s.json();this.totalEarnings=n,this.loading=!1}catch(s){console.error("Erreur lors de la r\xE9cup\xE9ration de la totalit\xE9 des revenus :",s),this.loading=!1}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},C={class:"mt-8"},T={class:"grid lg:grid-cols-4 mt-2 md:grid-cols-2 grid-cols-1 gap-6"},A={class:"stats shadow border"},I={class:"stat"},M=t("div",{class:"stat-figure dark:text-slate-300 text-primary"},[t("i",{class:"fas fa-hand-holding-usd text-4xl"})],-1),P={class:"stat-title dark:text-slate-300"},j={class:"stat-value dark:text-slate-300 text-primary"},$={key:0},B=h('<div class="flex flex-col gap-4 w-40"><div class="flex gap-4 items-center"><div class="flex flex-col gap-4"><div class="skeleton h-4 w-40"></div><div class="skeleton h-4 w-40"></div></div></div></div>',1),N=[B],S={key:1},H={class:"stats shadow border"},G={class:"stat"},W=t("div",{class:"stat-figure dark:text-slate-300 text-primary"},[t("i",{class:"fas fa-receipt text-4xl"})],-1),F={class:"stat-title dark:text-slate-300"},X={class:"stat-value dark:text-slate-300 text-primary"},V={key:0},D=h('<div class="flex flex-col gap-4 w-40"><div class="flex gap-4 items-center"><div class="flex flex-col gap-4"><div class="skeleton h-4 w-40"></div><div class="skeleton h-4 w-40"></div></div></div></div>',1),U=[D],J={key:1},R={key:0},Z={key:1},q={class:"stat-desc"},L={class:"stats shadow border"},Q={class:"stat"},Y=t("div",{class:"stat-figure dark:text-slate-300 text-primary"},[t("i",{class:"far fa-money-bill-alt text-4xl"})],-1),z={class:"stat-title dark:text-slate-300"},K={class:"stat-value dark:text-slate-300 text-primary"},O={key:0},ss=h('<div class="flex flex-col gap-4 w-40"><div class="flex gap-4 items-center"><div class="flex flex-col gap-4"><div class="skeleton h-4 w-40"></div><div class="skeleton h-4 w-40"></div></div></div></div>',1),ts=[ss],es={key:1},ns={key:0},as={key:1},os={class:"stat-desc"},is={class:"stats shadow border"},rs={class:"stat"},cs=t("div",{class:"stat-figure dark:text-slate-300 text-primary"},[t("i",{class:"fas fa-file-invoice-dollar text-4xl"})],-1),ls={class:"stat-title dark:text-slate-300"},ds={class:"stat-value dark:text-slate-300 text-primary"},hs={key:0},_s=h('<div class="flex flex-col gap-4 w-40"><div class="flex gap-4 items-center"><div class="flex flex-col gap-4"><div class="skeleton h-4 w-40"></div><div class="skeleton h-4 w-40"></div></div></div></div>',1),ms=[_s],us={key:1},ps={key:0},vs={key:1},ys=t("div",{class:"stat-desc"},null,-1);function fs(s,n,r,l,e,c){return a(),o("div",C,[t("div",T,[t("div",A,[t("div",I,[M,t("div",P,i(c.translations.unpaid),1),t("div",j,[e.loading?(a(),o("div",$,N)):(a(),o("div",S,[(a(!0),o(y,null,f(e.unpaidAmountsByCurrency,d=>(a(),o("div",{key:d.currencyId},i(d.total_amount)+i(d.symbol),1))),128))]))])])]),t("div",H,[t("div",G,[W,t("div",F,i(c.translations.expenses),1),t("div",X,[e.loading?(a(),o("div",V,U)):(a(),o("div",J,[e.MonthExpenses?(a(),o("span",R,i(e.MonthExpenses)+i(e.symbol),1)):(a(),o("span",Z," 0"+i(e.symbol),1))]))]),t("div",q,i(c.translations.current_month),1)])]),t("div",L,[t("div",Q,[Y,t("div",z,i(c.translations.earnings),1),t("div",K,[e.loading?(a(),o("div",O,ts)):(a(),o("div",es,[e.currentMonthEarnings?(a(),o("span",ns,i(e.currentMonthEarnings.total)+" "+i(e.currentMonthEarnings.default_currency_symbol),1)):(a(),o("span",as," 0"+i(e.symbol),1))]))]),t("div",os,i(c.translations.current_month),1)])]),t("div",is,[t("div",rs,[cs,t("div",ls,i(c.translations.all_Earnings),1),t("div",ds,[e.loading?(a(),o("div",hs,ms)):(a(),o("div",us,[e.totalEarnings?(a(),o("span",ps,i(e.totalEarnings.total)+" "+i(e.totalEarnings.default_currency_symbol),1)):(a(),o("span",vs," 0"+i(e.totalEarnings.default_currency_symbol),1))]))]),ys])])])])}var xs=u(E,[["render",fs]]);const gs={name:"BarChart",data(){return{payments:[],expenses:[],months:[],loading:!0}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},mounted(){this.fetchMonthlyPaymentsExpenses()},methods:{async fetchMonthlyPaymentsExpenses(){try{const s=await fetch("/wp-json/my-easy-compta/v1/stats/monthly-payments-expenses",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const n=await s.json();this.payments=n.payments,this.expenses=n.expenses,this.months=n.months,this.loading=!1,this.$nextTick(()=>{this.loadChart()})}catch(s){console.error("Erreur lors de la r\xE9cup\xE9ration des paiements et des d\xE9penses mensuels:",s),this.loading=!1}},loadChart(){typeof Chart!="undefined"?this.createChart():console.error("Chart.js is not loaded")},createChart(){const s=this.translations,n=document.getElementById("bar-chart").getContext("2d");new Chart(n,{type:"bar",data:{labels:this.months,datasets:[{label:s.earnings,backgroundColor:"#42A5F5",data:this.payments},{label:s.expenses,backgroundColor:"#FF00AA",data:this.expenses}]},options:{responsive:!0,scales:{x:{beginAtZero:!0},y:{beginAtZero:!0}}}})}}},ws={class:"text-xl font-semibold"},ks=t("div",{class:"divider mt-2"},null,-1),bs={class:"h-full w-full pb-6"},Es={key:0},Cs=h('<div class="flex flex-col gap-4 w-full"><div class="skeleton h-4 w-full"></div><div class="skeleton h-4 w-full"></div><div class="skeleton h-32 w-full"></div><div class="skeleton h-4 w-full"></div><div class="skeleton h-4 w-full"></div></div>',1),Ts=[Cs],As={key:1,id:"bar-chart"};function Is(s,n,r,l,e,c){return a(),o("div",null,[t("div",ws,i(c.translations.annual_payments_overview),1),ks,t("div",bs,[e.loading?(a(),o("div",Es,Ts)):(a(),o("canvas",As))])])}var Ms=u(gs,[["render",Is]]);const Ps={name:"InvoicesHistory",data(){return{recentPayments:[],loading:!0}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},mounted(){this.fetchRecentPayments()},methods:{async fetchRecentPayments(){try{const s=await fetch("/wp-json/my-easy-compta/v1/stats/recent-payments",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const n=await s.json();this.recentPayments=n,this.loading=!1}catch(s){console.error("Erreur lors de la r\xE9cup\xE9ration des paiements r\xE9cents:",s),this.loading=!1}}}},js={class:"text-xl font-semibold"},$s=t("div",{class:"divider mt-2"},null,-1),Bs={class:"overflow-x-auto"},Ns={key:0},Ss=h('<div class="flex flex-col gap-4 w-full"><div class="skeleton h-4 w-full"></div><div class="skeleton h-4 w-full"></div><div class="skeleton h-32 w-full"></div><div class="skeleton h-4 w-full"></div><div class="skeleton h-4 w-full"></div></div>',1),Hs=[Ss],Gs={key:1},Ws={class:"text-gray-500"},Fs={key:2,class:"table table-xs ecwp-table-dash-invoice"},Xs={class:"badge badge-outline badge-success badge-sm"};function Vs(s,n,r,l,e,c){return a(),o("div",null,[t("div",js,i(c.translations.recently_paid_invoice),1),$s,t("div",Bs,[e.loading?(a(),o("div",Ns,Hs)):e.recentPayments.length===0?(a(),o("div",Gs,[t("div",Ws,i(c.translations.no_data_for_moment),1)])):(a(),o("table",Fs,[t("tbody",null,[(a(!0),o(y,null,f(e.recentPayments,d=>(a(),o("tr",{key:d.invoice_number},[t("td",null,i(d.invoice_number),1),t("td",null,i(d.total_amount)+i(d.symbol),1),t("td",null,[t("span",Xs,i(d.method_name),1)])]))),128))])]))])])}var Ds=u(Ps,[["render",Vs]]);const Us={name:"Dashboard",components:{Stats:xs,BarChart:Ms,InvoicesHistory:Ds},methods:{setTheme(s){document.documentElement.setAttribute("data-theme",s),localStorage.setItem("theme",s)},toggleTheme(){document.documentElement.getAttribute("data-theme")==="dark"?this.setTheme("winter"):this.setTheme("dark")}},mounted(){const s=localStorage.getItem("theme");s?this.setTheme(s):window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches&&this.setTheme("dark")},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},Js={class:"relative pt-2 pr-4"},Rs={class:"ecwp-swap swap swap-rotate bg-base-100 p-2 mt-10"},Zs=t("i",{class:"swap-off far fa-sun text-xl"},null,-1),qs=t("i",{class:"swap-on far fa-moon text-xl"},null,-1),Ls={class:"grid lg:grid-cols-3 mt-4 grid-cols-1 gap-6"},Qs={class:"card w-full p-6 bg-base-100 shadow-xl col-span-2 mt-4"},Ys={class:"card w-full p-6 bg-base-100 shadow-xl mt-4"};function zs(s,n,r,l,e,c){const d=p("Stats"),x=p("BarChart"),g=p("InvoicesHistory");return a(),o("div",Js,[t("label",Rs,[t("input",{type:"checkbox",class:"theme-controller",onChange:n[0]||(n[0]=(...w)=>c.toggleTheme&&c.toggleTheme(...w))},null,32),Zs,qs]),v(d),t("div",Ls,[t("div",Qs,[v(x)]),t("div",Ys,[v(g)])])])}var Ks=u(Us,[["render",zs]]);const Os=m;function _(){const s=["580532ksbGJP","145380QoPNeJ","2HsmISf","#my-easy-compta-admin-app","32973riBdUp","405006rfmvVm","292269CSdYBk","2496735IrxFMf","759944mIlGqV","15cDWhde"];return _=function(){return s},_()}function m(s,n){const r=_();return m=function(l,e){return l=l-133,r[l]},m(s,n)}(function(s,n){const r=m,l=s();for(;[];)try{if(parseInt(r(140))/1+-parseInt(r(138))/2*(parseInt(r(142))/3)+-parseInt(r(136))/4+-parseInt(r(135))/5*(-parseInt(r(137))/6)+parseInt(r(141))/7+-parseInt(r(134))/8+parseInt(r(133))/9===n)break;l.push(l.shift())}catch{l.push(l.shift())}})(_,103387);const st=k({render:()=>b(Ks)});st.mount(Os(139));
  • my-easy-compta/trunk/assets/dist/clients.min.js

    r3198779 r3233000  
    1 import{_ as P,o as d,c,a as t,t as i,F as u,r as _,g,n as y,w as A,i as p,v as j,j as E,k as v,l as x,d as f,e as b,m as B,f as O,h as D}from"./plugin-vue_export-helper.min.js";import{C as S,R as V}from"./RemoveAlert.min.js";import{A as W,r as L}from"./index.min.js";import{g as N,f as U,s as F}from"./api.min.js";import"./VueSearchSelect.min.js";import"./vue-datepicker.min.js";import"./vue3-editor.common.min.js";const R={props:{loading:Boolean,showModal:Boolean,modalId:String,modalTitle:String,client:Object,currencyOptions:{type:Array,default:()=>[]}},data(){const e=window.myEasyComptaAdmin.easyComptaTranslations;return{addon_siret_active:"",localCurrencyOptions:this.currencyOptions,translations:e}},computed:{skeletonItems(){return Array.from({length:7},(e,s)=>s)},fields(){const e=window.myEasyComptaAdmin.easyComptaTranslations;return{company_name:{label:e.company_name},manager_name:{label:e.manager_name},email:{label:e.email},phone:{label:e.phone},mobile_phone:{label:e.mobile},website:{label:e.website},address:{label:e.address},city:{label:e.city},postal_code:{label:e.postal_code},country:{label:e.country}}}},mounted(){this.fetchOptions()},methods:{closeModal(){const e=document.getElementById(this.modalId);e&&(e.close(),this.$emit("close"))},fetchOptions(){fetch("/wp-json/my-easy-compta/v1/options",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{e.currency_options&&(this.localCurrencyOptions=e.currency_options,this.addon_siret_active=e.addon_siret_active)}).catch(e=>{console.error("Erreur lors de la r\xE9cup\xE9ration des options",e)})},getCurrencyOption(e){const s=this.localCurrencyOptions.find(l=>l.id===e);return s?s.name:"N/A"}}},X=["id","open"],z={class:"modal-box"},q={class:"font-bold text-lg"},J={key:0},K={class:"grid grid-cols-2 gap-4"},Q=t("div",{class:"skeleton h-4 w-full mb-2"},null,-1),G=t("div",{class:"skeleton h-4 w-full"},null,-1),H=[Q,G],Y={key:1},Z={class:"grid grid-cols-2 gap-4"},$={key:0,class:"py-2"},tt={class:"text-sm font-medium text-gray-500"},et={class:"mt-1 text-sm text-gray-900"},st=t("dl",{class:"divide-y divide-gray-200"},null,-1),nt={key:1,class:"py-2"},lt={class:"text-sm font-medium text-gray-500"},ot={class:"mt-1 text-sm text-gray-900"},it=t("dl",{class:"divide-y divide-gray-200"},null,-1),at={class:"grid grid-cols-1 gap-4"},dt={key:0,class:"py-2"},ct={class:"text-sm font-medium text-gray-500"},rt={class:"mt-1 text-sm text-gray-900"},mt=t("dl",{class:"divide-y divide-gray-200"},null,-1),ht={class:"grid grid-cols-2 gap-4"},ut={class:"text-sm font-medium text-gray-500"},_t={class:"mt-1 text-sm text-gray-900"},pt=t("dl",{class:"divide-y divide-gray-200"},null,-1),gt={class:"grid grid-cols-2 gap-4"},yt={class:"py-2"},ft={class:"text-sm font-medium text-gray-500"},bt={class:"mt-1 text-sm text-gray-900"},vt=t("dl",{class:"divide-y divide-gray-200"},null,-1),xt={class:"py-2"},wt={class:"text-sm font-medium text-gray-500"},Ct={class:"mt-1 text-sm text-gray-900"},kt=t("dl",{class:"divide-y divide-gray-200"},null,-1),Mt={key:2},Pt={class:"grid grid-cols-2 gap-4"},Et=t("div",{class:"skeleton h-4 w-full mb-2"},null,-1),Tt=t("div",{class:"skeleton h-4 w-full"},null,-1),It=[Et,Tt];function At(e,s,l,m,n,o){return d(),c("dialog",{id:l.modalId,class:"modal",open:l.showModal},[t("div",z,[t("h3",q,i(l.modalTitle),1),t("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:s[0]||(s[0]=r=>o.closeModal())}," \u2715 "),l.loading?(d(),c("div",J,[t("div",K,[(d(!0),c(u,null,_(o.skeletonItems,r=>(d(),c("div",{key:r,class:"py-2"},H))),128))])])):l.client?(d(),c("div",Y,[t("div",Z,[l.client.siret_number!=0&&n.addon_siret_active?(d(),c("div",$,[t("dt",tt,i(n.translations.siret),1),t("dd",et,i(l.client.siret_number),1),st])):g("",!0),l.client.siren_number!=0?(d(),c("div",nt,[t("dt",lt,i(n.translations.siren),1),t("dd",ot,i(l.client.siren_number),1),it])):g("",!0)]),t("div",at,[l.client.tax_number!=0?(d(),c("div",dt,[t("dt",ct,i(n.translations.tax_number),1),t("dd",rt,i(l.client.tax_number),1),mt])):g("",!0)]),t("div",ht,[(d(!0),c(u,null,_(o.fields,(r,h)=>(d(),c("div",{key:h,class:"py-2"},[t("dt",ut,i(r.label),1),t("dd",_t,i(l.client[h]),1),pt]))),128))]),t("div",gt,[t("div",yt,[t("dt",ft,i(n.translations.currency),1),t("dd",bt,i(o.getCurrencyOption(l.client.currency_id)),1),vt])]),t("div",xt,[t("dt",wt,i(n.translations.note),1),t("dd",Ct,i(l.client.note),1),kt])])):(d(),c("div",Mt,[t("div",Pt,[(d(!0),c(u,null,_(o.skeletonItems,r=>(d(),c("div",{key:r,class:"py-2"},It))),128))])]))])],8,X)}var jt=P(R,[["render",At]]);const Bt={props:{loading:Boolean,showModal:Boolean,modalId:String,modalTitle:String,client:Object},data(){const e=window.myEasyComptaAdmin.easyComptaTranslations;return{editedClient:{...this.client},toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},currencyOptions:[],fields:{siren_number:{label:e.siren},tax_number:{label:e.tax_number},company_name:{label:e.company_name},manager_name:{label:e.manager_name},email:{label:e.email},phone:{label:e.phone,type:"tel"},mobile_phone:{label:e.mobile,type:"tel"},website:{label:e.website,type:"url"},address:{label:e.address},city:{label:e.city},postal_code:{label:e.postal_code},country:{label:e.country}},loadingBtn:!1}},mounted(){this.fetchOptions()},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},skeletonItems(){return Array.from({length:10},(e,s)=>s)},currencyOptions(){return this.currencyOptions}},methods:{closeModal(){document.getElementById("modal_client_edit").close()},async submitForm(){this.loadingBtn=!0;try{const e=await fetch(`/wp-json/my-easy-compta/v1/clients/${this.editedClient.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.editedClient)});if(e.ok){const s=await e.json();this.loadingBtn=!1,this.closeModal(),this.showToast(s.message,"alert-success"),this.$emit("clientEdited")}else{const s=`Error editing client: ${e.statusText}`;this.showToast(s,"alert-error"),console.error(s),this.loadingBtn=!1}}catch(e){const s=e.response&&e.response.data&&e.response.data.message?e.response.data.message:"Error editing client";this.showToast(s,"alert-error"),console.error("Error editing client:",e),this.loadingBtn=!1}},async fetchOptions(){try{const e=await fetch("/wp-json/my-easy-compta/v1/options",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}});if(e.ok){const s=await e.json();this.currencyOptions=s.currency_options}else throw new Error(`Failed to fetch options: ${e.statusText}`)}catch(e){console.error("Error fetching options:",e)}},showToast(e,s){this.toast.message=e,this.toast.type=s,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}},watch:{client:{handler(e){this.editedClient={...e}},immediate:!0}}},Ot=["id","open"],Dt={class:"modal-box"},St={class:"font-bold text-lg"},Vt={key:0},Wt={class:"grid grid-cols-2 gap-4"},Lt=t("div",{class:"skeleton h-4 w-full mb-2"},null,-1),Nt=t("div",{class:"skeleton h-4 w-full"},null,-1),Ut=[Lt,Nt],Ft={class:"grid grid-cols-2 gap-4"},Rt=["for"],Xt=["type","id","onUpdate:modelValue"],zt={class:"grid grid-cols-2 gap-4"},qt={class:"ecwp-group form-group"},Jt={for:"currencyId",class:"ecwp-label form-label"},Kt=["value"],Qt={class:"ecwp-group form-group mt-4"},Gt={for:"note",class:"ecwp-label form-label"},Ht={class:"form-group mt-4 flex justify-end"},Yt=["disabled"],Zt={key:0,class:"loading loading-spinner loading-sm"};function $t(e,s,l,m,n,o){return d(),c("div",null,[n.toast.visible?(d(),c("div",{key:0,class:y(["toast",n.toast.position]),style:{zIndex:9999}},[t("div",{class:y(["alert",n.toast.type,"text-white"])},[t("span",null,i(n.toast.message),1)],2)],2)):g("",!0),t("dialog",{id:l.modalId,class:"modal",open:l.showModal},[t("div",Dt,[t("h3",St,i(l.modalTitle),1),t("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:s[0]||(s[0]=r=>o.closeModal())}," \u2715 "),l.loading?(d(),c("div",Vt,[t("div",Wt,[(d(!0),c(u,null,_(o.skeletonItems,r=>(d(),c("div",{key:r,class:"py-2"},Ut))),128))])])):(d(),c("form",{key:1,onSubmit:s[3]||(s[3]=A((...r)=>o.submitForm&&o.submitForm(...r),["prevent"])),class:"form"},[t("div",Ft,[(d(!0),c(u,null,_(n.fields,(r,h)=>(d(),c("div",{key:h,class:"ecwp-group form-group"},[t("label",{for:h,class:"ecwp-label form-label"},i(r.label),9,Rt),p(t("input",{type:r.type||"text",id:h,"onUpdate:modelValue":k=>n.editedClient[h]=k,class:y(["ecwp-input input","input-bordered",r.class||"w-full"])},null,10,Xt),[[j,n.editedClient[h]]])]))),128))]),t("div",zt,[t("div",qt,[t("label",Jt,i(o.translations.currency),1),p(t("select",{id:"currencyId","onUpdate:modelValue":s[1]||(s[1]=r=>n.editedClient.currency_id=r),class:"ecwp-input select select-bordered w-full"},[(d(!0),c(u,null,_(o.currencyOptions,(r,h)=>(d(),c("option",{key:h,value:r.id},i(r.name)+" - "+i(r.code)+" ("+i(r.symbol)+") ",9,Kt))),128))],512),[[E,n.editedClient.currency_id]])])]),t("div",Qt,[t("label",Gt,i(o.translations.note),1),p(t("textarea",{id:"note","onUpdate:modelValue":s[2]||(s[2]=r=>n.editedClient.note=r),class:"ecwp-input textarea textarea-bordered w-full",rows:"4"},null,512),[[v,n.editedClient.note]])]),t("div",Ht,[t("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[x(i(o.translations.save)+" ",1),n.loadingBtn?(d(),c("span",Zt)):g("",!0)],8,Yt)])],32))])],8,Ot)])}var te=P(Bt,[["render",$t]]);const ee={name:"Clients",components:{Card:S,AddClientModal:W,ClientDetailsModal:jt,ClientEditModal:te,RemoveModal:V},data(){return{clients:[],filteredClients:[],filters:{company_name:"",manager_name:"",email:"",phone:""},showClientDetailsModal:!1,editClientModal:!1,showRemoveModal:!1,selectedClient:null,currentPage:1,totalPages:1,paginationButtons:[],loading:!0,settings:[],loadingModal:!1,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},created(){this.fetchClients(),this.loadSettings()},methods:{AddNew(){modal_clients.showModal()},fetchClients(e=1){this.loading=!0;const{perPage:s}=this;fetch(`/wp-json/my-easy-compta/v1/clients?page=${e}&per_page=${s}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(l=>l.json()).then(l=>{this.clients=l.clients,this.filteredClients=l.clients,this.totalCount=l.total_count,this.totalPages=l.total_pages,this.currentPage=l.page,this.perPage=s,this.generatePaginationButtons()}).catch(l=>{console.error("Error fetching clients:",l)}).finally(()=>{this.loading=!1})},fetchClientsWithFilters(e=1){this.loading=!0;const{perPage:s,filters:l}=this,m=new URLSearchParams({page:e,per_page:s,company_name:l.company_name,manager_name:l.manager_name,email:l.email,phone:l.phone}).toString();fetch(`/wp-json/my-easy-compta/v1/clients?${m}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(n=>n.json()).then(n=>{this.clients=n.clients,this.filteredClients=n.clients,this.totalCount=n.total_count,this.totalPages=n.total_pages,this.currentPage=n.page,this.perPage=s,this.generatePaginationButtons()}).catch(n=>{console.error("Error fetching clients with filters:",n)}).finally(()=>{this.loading=!1})},fetchClientDetails(e){fetch(`/wp-json/my-easy-compta/v1/clients/details/${e}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>s.json()).then(s=>{this.selectedClient=s,this.loadingModal=!1}).catch(s=>{console.error("Error fetching client details:",s),this.loadingModal=!1})},showClientDetails(e){this.loadingModal=!0,this.showClientDetailsModal=!0,modal_client_details.showModal(),this.fetchClientDetails(e.id)},editClient(e){this.loadingModal=!0,this.editClientModal=!0,modal_client_edit.showModal(),this.fetchClientDetails(e.id)},generatePaginationButtons(){this.paginationButtons=N(this.currentPage,this.totalPages)},goToPage(e){e!=="..."&&this.fetchClients(e)},perPageChanged(){this.fetchClients()},confirmDeleteClient(e){this.selectedClient=e,modal_client_remove.showModal(),this.showRemoveModal=!0},deleteClient(e){this.loading=!0;const s=e.id;fetch(`/wp-json/my-easy-compta/v1/clients/${s}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(l=>{if(!l.ok)throw new Error("Network response was not ok");return l.json()}).then(l=>{l.success?(this.fetchClients(),this.showToast(l.message,"alert-success")):(this.showToast(l.message,"alert-error"),console.error("Error deleting client:",l.statusText))}).catch(l=>{console.log(l.message);const m=l&&l.message?l.message:"Error deleting client";m==="This client cannot be deleted because it has associated data."?this.showToast(m,"alert-error"):console.error("Error deleting client:",l)})},async loadSettings(){try{this.loadingPrice=!0;const{settings:e,currencySymbol:s,vatData:l}=await U();this.settings=e,this.default_currency_symbol=s,this.default_vat=l,this.loadingPrice=!1}catch(e){this.showToast(e.message,"alert-error"),this.loadingPrice=!1}},showToast(e,s){F(this.toast,e,s)}},computed:{skeletonItems(){return Array.from({length:5},(e,s)=>s)},totalPages(){return Math.ceil(this.totalCount/this.perPage)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},se={class:"pt-2 pr-4"},ne={class:"flex justify-between items-center"},le={class:"card-title"},oe=t("i",{class:"fas fa-plus-circle"},null,-1),ie={key:0,class:"ms-2"},ae={class:"btn btn-outline btn-accent rounded-full hover:text-white",href:"/wp-admin/admin.php?page=my-easy-compta-export#tab1"},de=t("i",{class:"fas fa-file-export"},null,-1),ce=["data-tip"],re={class:"btn btn-outline btn-accent rounded-full",disabled:""},me=t("i",{class:"fas fa-file-export"},null,-1),he=t("div",{class:"divider mt-2"},null,-1),ue={class:"flex items-center mb-4"},_e={for:"perPageSelect",class:"mr-2"},pe=["value"],ge={class:"overflow-x-auto"},ye={class:"table w-full"},fe={class:"flex justify-center"},be={key:0},ve={class:"flex items-center gap-3"},xe={class:"avatar"},we={class:"mask mask-squircle w-12 h-12"},Ce={version:"1.1",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 122.9 122.9",style:{"enable-background":"new 0 0 122.9 122.9"},"xml:space":"preserve"},ke=t("g",null,[t("path",{d:"M61.4,0c17,0,32.3,6.9,43.4,18c11.1,11.1,18,26.5,18,43.4c0,17-6.9,32.3-18,43.4c-11.1,11.1-26.5,18-43.4,18 s-32.3-6.9-43.4-18C6.9,93.8,0,78.4,0,61.4c0-17,6.9-32.3,18-43.4C29.1,6.9,44.5,0,61.4,0L61.4,0z M41.3,54.3c-1.1,0-2,0.3-2.5,0.7 c-0.3,0.2-0.6,0.5-0.7,0.8c-0.2,0.4-0.3,0.8-0.2,1.4c0,1.5,0.8,3.5,2.4,5.8l0,0l0,0l5,8c2,3.2,4.1,6.5,6.8,8.9 c2.5,2.3,5.6,3.9,9.6,3.9c4.4,0,7.6-1.6,10.2-4.1c2.7-2.5,4.9-6,7-9.5l5.7-9.3c1.1-2.4,1.4-4,1.2-5c-0.1-0.6-0.8-0.8-1.8-0.9 c-0.2,0-0.5,0-0.7,0c-0.3,0-0.5,0-0.8,0c-0.2,0-0.3,0-0.4,0c-0.5,0-1,0-1.6-0.1l1.9-8.6c-14.4,2.3-25.2-8.4-40.4-2.1L43,54.4 C42.4,54.4,41.8,54.4,41.3,54.3L41.3,54.3L41.3,54.3L41.3,54.3z M18.8,95.7c7.1-2.5,19.6-3.8,25.4-7.7c1-1.3,2.1-2.9,3.1-4.3 c0.6-0.9,1.1-1.7,1.6-2.3c0.1-0.1,0.2-0.2,0.3-0.3c-2.4-2.5-4.4-5.5-6.3-8.5l-5-8C36,61.8,35,59.3,35,57.3c0-1,0.1-1.9,0.5-2.6 c0.4-0.8,1-1.5,1.7-2c0.4-0.2,0.8-0.5,1.2-0.6c-0.3-4.3-0.4-9.8-0.2-14.4c0.1-1.1,0.3-2.2,0.6-3.3c1.3-4.6,4.5-8.3,8.5-10.8 c1.4-0.9,2.9-1.6,4.6-2.2c2.9-1.1,1.5-5.5,4.7-5.6c7.5-0.2,19.8,6.2,24.6,11.4c2.8,3,4.6,7,4.9,12.3l-0.3,13.1l0,0 c1.4,0.4,2.3,1.3,2.7,2.7c0.4,1.6,0,3.8-1.4,6.9l0,0c0,0.1-0.1,0.1-0.1,0.2l-5.7,9.4c-2.2,3.6-4.5,7.3-7.5,10.1L73.7,82l0,0 c0.4,0.5,0.8,1.1,1.2,1.7c0.8,1.1,1.6,2.4,2.5,3.6c5.3,4.5,19.3,5.9,26.7,8.6c7.6-9.4,12.1-21.4,12.1-34.4c0-15.1-6.1-28.8-16-38.7 c-9.9-9.9-23.6-16-38.7-16s-28.8,6.1-38.7,16c-9.9,9.9-16,23.6-16,38.7C6.7,74.4,11.2,86.3,18.8,95.7L18.8,95.7z M77,90.5 c-1.4-1.6-2.8-3.7-4.1-5.5c-0.4-0.5-0.7-1.1-1.1-1.5c-2.7,2-6,3.3-10.3,3.3c-4.5,0-8-1.6-10.9-4.1c0,0,0,0.1-0.1,0.1 c-0.5,0.7-1,1.4-1.6,2.3c-1.1,1.6-2.3,3.3-3.4,4.8C45.6,100,71.1,106,77,90.5L77,90.5z"})],-1),Me=[ke],Pe={class:"font-bold"},Ee={class:"text-sm opacity-50"},Te={class:"badge badge-ghost badge-sm"},Ie={class:"flex justify-end"},Ae=["data-tip"],je=["onClick"],Be=t("i",{class:"far fa-eye"},null,-1),Oe=[Be],De=["data-tip"],Se=["onClick"],Ve=t("i",{class:"fas fa-pencil-alt"},null,-1),We=[Ve],Le=["data-tip"],Ne=["onClick"],Ue=t("i",{class:"far fa-trash-alt"},null,-1),Fe=[Ue],Re={key:0},Xe=t("div",{class:"flex gap-4 items-center"},[t("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),t("div",{class:"flex flex-col gap-4 w-full"},[t("div",{class:"skeleton h-4 w-full"}),t("div",{class:"skeleton h-4 w-full"})])],-1),ze=t("div",{class:"divider my-1"},null,-1),qe=[Xe,ze],Je={class:"join ecwp_pagination mt-6 pt-4"},Ke=["onClick"];function Qe(e,s,l,m,n,o){const r=f("client-details-modal"),h=f("client-edit-modal"),k=f("remove-modal"),T=f("AddClientModal"),I=f("Card");return d(),c("div",se,[n.toast.visible?(d(),c("div",{key:0,class:y(["toast",n.toast.position]),style:{zIndex:9999}},[t("div",{class:y(["alert",n.toast.type,"text-white"])},[t("span",null,i(n.toast.message),1)],2)],2)):g("",!0),b(r,{loading:n.loadingModal,"show-modal":n.showClientDetailsModal,"modal-id":"modal_client_details","modal-title":o.translations.client_details,client:n.selectedClient,onClose:s[0]||(s[0]=a=>n.showClientDetailsModal=!1)},null,8,["loading","show-modal","modal-title","client"]),b(h,{loading:n.loadingModal,"show-modal":n.editClientModal,"modal-id":"modal_client_edit","modal-title":o.translations.edit_client,client:n.selectedClient,onClose:s[1]||(s[1]=a=>n.editClientModal=!1),onClientEdited:o.fetchClients},null,8,["loading","show-modal","modal-title","client","onClientEdited"]),b(k,{"modal-id":"modal_client_remove","show-modal":n.showRemoveModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:s[2]||(s[2]=a=>o.deleteClient(n.selectedClient)),onCancel:s[3]||(s[3]=a=>n.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),b(I,{topMargin:"mt-8"},{default:B(()=>[t("div",ne,[t("h2",le,i(o.translations.clients),1),t("div",null,[t("button",{class:"btn btn-primary rounded-full",onClick:s[4]||(s[4]=(...a)=>o.AddNew&&o.AddNew(...a))},[x(i(o.translations.add)+" ",1),oe]),n.settings.easy_compta_export_addon_active==1?(d(),c("span",ie,[t("a",ae,[x(i(o.translations.export)+" ",1),de])])):(d(),c("span",{key:1,class:"tooltip tooltip-left tooltip-warning ms-2","data-tip":o.translations.active_export_addon},[t("button",re,[x(i(o.translations.export)+" ",1),me])],8,ce))])]),he,b(T,{onClientAdded:o.fetchClients},null,8,["onClientAdded"]),t("div",ue,[t("label",_e,i(o.translations.display_per_page),1),p(t("select",{id:"perPageSelect","onUpdate:modelValue":s[5]||(s[5]=a=>n.perPage=a),onChange:s[6]||(s[6]=(...a)=>o.perPageChanged&&o.perPageChanged(...a))},[(d(!0),c(u,null,_(n.perPageOptions,a=>(d(),c("option",{key:a,value:a},i(a),9,pe))),128))],544),[[E,n.perPage]])]),t("div",ge,[t("table",ye,[t("thead",null,[t("tr",null,[t("th",null,[t("div",null,i(o.translations.company_name),1),p(t("input",{"onUpdate:modelValue":s[7]||(s[7]=a=>n.filters.company_name=a),onInput:s[8]||(s[8]=()=>o.fetchClientsWithFilters()),type:"text",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[v,n.filters.company_name]])]),t("th",null,[t("div",null,i(o.translations.manager_name),1),p(t("input",{"onUpdate:modelValue":s[9]||(s[9]=a=>n.filters.manager_name=a),onInput:s[10]||(s[10]=()=>o.fetchClientsWithFilters()),type:"text",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[v,n.filters.manager_name]])]),t("th",null,[t("div",null,i(o.translations.email),1),p(t("input",{"onUpdate:modelValue":s[11]||(s[11]=a=>n.filters.email=a),onInput:s[12]||(s[12]=()=>o.fetchClientsWithFilters()),type:"text",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[v,n.filters.email]])]),t("th",null,[t("div",null,i(o.translations.phone),1),p(t("input",{"onUpdate:modelValue":s[13]||(s[13]=a=>n.filters.phone=a),onInput:s[14]||(s[14]=()=>o.fetchClientsWithFilters()),type:"text",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[v,n.filters.phone]])]),t("th",fe,i(o.translations.actions),1)])]),n.loading?g("",!0):(d(),c("tbody",be,[(d(!0),c(u,null,_(n.clients,a=>(d(),c("tr",{key:a.id},[t("td",null,[t("div",ve,[t("div",xe,[t("div",we,[(d(),c("svg",Ce,Me))])]),t("div",null,[t("div",Pe,i(a.company_name),1),t("div",Ee,[t("span",Te,i(a.city)+" - "+i(a.country),1)])])])]),t("td",null,i(a.manager_name),1),t("td",null,i(a.email),1),t("td",null,i(a.phone),1),t("td",Ie,[t("span",{class:"lg:tooltip","data-tip":o.translations.view},[t("button",{class:"btn btn-circle mx-1",onClick:M=>o.showClientDetails(a)},Oe,8,je)],8,Ae),t("span",{class:"lg:tooltip","data-tip":o.translations.edit},[t("button",{class:"btn btn-circle mx-1",onClick:M=>o.editClient(a)},We,8,Se)],8,De),t("span",{class:"lg:tooltip","data-tip":o.translations.delete},[t("button",{onClick:M=>o.confirmDeleteClient(a),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},Fe,8,Ne)],8,Le)])]))),128))]))]),n.loading?(d(),c("div",Re,[(d(!0),c(u,null,_(n.skeletonRows,a=>(d(),c("div",{key:a,class:"flex flex-col gap-4 w-full"},qe))),128))])):g("",!0),t("div",Je,[(d(!0),c(u,null,_(n.paginationButtons,a=>(d(),c("button",{key:a,class:y(["join-item btn",{"btn-disabled":a==="..."||a===n.currentPage}]),onClick:M=>o.goToPage(a)},i(a),11,Ke))),128))])])]),_:1})])}var Ge=P(ee,[["render",Qe]]);const He=w;(function(e,s){const l=w,m=e();for(;[];)try{if(-parseInt(l(220))/1*(-parseInt(l(222))/2)+parseInt(l(219))/3+-parseInt(l(215))/4+parseInt(l(214))/5*(parseInt(l(221))/6)+-parseInt(l(217))/7+parseInt(l(216))/8+-parseInt(l(213))/9*(parseInt(l(223))/10)===s)break;m.push(m.shift())}catch{m.push(m.shift())}})(C,112868);function w(e,s){const l=C();return w=function(m,n){return m=m-213,l[m]},w(e,s)}function C(){const e=["451464Vsmuvd","133709MkhQuW","12762tPsAda","2yRyVHQ","1970KwYjga","9918laZgpu","340CJopGa","803956eSjUEg","1350888vCRCtX","467201qKaipA","use"];return C=function(){return e},C()}const Ye=O({render:()=>D(Ge)});Ye[He(218)](L).mount("#my-easy-compta-clients-app");
     1import{_ as P,o as d,c,a as t,t as i,F as u,r as _,g,n as y,w as j,i as p,v as B,j as T,k as b,l as x,d as f,e as v,m as D,f as O,h as S}from"./plugin-vue_export-helper.min.js";import{C as F,R as N}from"./RemoveAlert.min.js";import{A as U,r as L}from"./index.min.js";import{g as V,f as W,s as R}from"./api.min.js";import"./VueSearchSelect.min.js";import"./vue-datepicker.min.js";import"./vue3-editor.common.min.js";const z={props:{loading:Boolean,showModal:Boolean,modalId:String,modalTitle:String,client:Object,currencyOptions:{type:Array,default:()=>[]}},data(){const e=window.myEasyComptaAdmin.easyComptaTranslations;return{addon_siret_active:"",localCurrencyOptions:this.currencyOptions,translations:e}},computed:{skeletonItems(){return Array.from({length:7},(e,s)=>s)},fields(){const e=window.myEasyComptaAdmin.easyComptaTranslations;return{company_name:{label:e.company_name},manager_name:{label:e.manager_name},email:{label:e.email},phone:{label:e.phone},mobile_phone:{label:e.mobile},website:{label:e.website},address:{label:e.address},city:{label:e.city},postal_code:{label:e.postal_code},country:{label:e.country}}}},mounted(){this.fetchOptions()},methods:{closeModal(){const e=document.getElementById(this.modalId);e&&(e.close(),this.$emit("close"))},fetchOptions(){fetch("/wp-json/my-easy-compta/v1/options",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{e.currency_options&&(this.localCurrencyOptions=e.currency_options,this.addon_siret_active=e.addon_siret_active)}).catch(e=>{console.error("Erreur lors de la r\xE9cup\xE9ration des options",e)})},getCurrencyOption(e){const s=this.localCurrencyOptions.find(n=>n.id===e);return s?s.name:"N/A"}}},X=["id","open"],q={class:"modal-box"},G={class:"font-bold text-lg"},Z={key:0},H={class:"grid grid-cols-2 gap-4"},J=t("div",{class:"skeleton h-4 w-full mb-2"},null,-1),Q=t("div",{class:"skeleton h-4 w-full"},null,-1),K=[J,Q],Y={key:1},$={class:"grid grid-cols-2 gap-4"},tt={key:0,class:"py-2"},et={class:"text-sm font-medium text-gray-500"},st={class:"mt-1 text-sm text-gray-900"},nt=t("dl",{class:"divide-y divide-gray-200"},null,-1),lt={key:1,class:"py-2"},ot={class:"text-sm font-medium text-gray-500"},it={class:"mt-1 text-sm text-gray-900"},at=t("dl",{class:"divide-y divide-gray-200"},null,-1),dt={class:"grid grid-cols-1 gap-4"},ct={key:0,class:"py-2"},rt={class:"text-sm font-medium text-gray-500"},mt={class:"mt-1 text-sm text-gray-900"},ht=t("dl",{class:"divide-y divide-gray-200"},null,-1),ut={class:"grid grid-cols-2 gap-4"},_t={class:"text-sm font-medium text-gray-500"},pt={class:"mt-1 text-sm text-gray-900"},gt=t("dl",{class:"divide-y divide-gray-200"},null,-1),yt={class:"grid grid-cols-2 gap-4"},ft={class:"py-2"},vt={class:"text-sm font-medium text-gray-500"},bt={class:"mt-1 text-sm text-gray-900"},xt=t("dl",{class:"divide-y divide-gray-200"},null,-1),wt={class:"py-2"},Ct={class:"text-sm font-medium text-gray-500"},kt={class:"mt-1 text-sm text-gray-900"},Mt=t("dl",{class:"divide-y divide-gray-200"},null,-1),Pt={key:2},Et={class:"grid grid-cols-2 gap-4"},Tt=t("div",{class:"skeleton h-4 w-full mb-2"},null,-1),It=t("div",{class:"skeleton h-4 w-full"},null,-1),At=[Tt,It];function jt(e,s,n,m,l,o){return d(),c("dialog",{id:n.modalId,class:"modal",open:n.showModal},[t("div",q,[t("h3",G,i(n.modalTitle),1),t("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:s[0]||(s[0]=r=>o.closeModal())}," \u2715 "),n.loading?(d(),c("div",Z,[t("div",H,[(d(!0),c(u,null,_(o.skeletonItems,r=>(d(),c("div",{key:r,class:"py-2"},K))),128))])])):n.client?(d(),c("div",Y,[t("div",$,[n.client.siret_number!=0&&l.addon_siret_active?(d(),c("div",tt,[t("dt",et,i(l.translations.siret),1),t("dd",st,i(n.client.siret_number),1),nt])):g("",!0),n.client.siren_number!=0?(d(),c("div",lt,[t("dt",ot,i(l.translations.siren),1),t("dd",it,i(n.client.siren_number),1),at])):g("",!0)]),t("div",dt,[n.client.tax_number!=0?(d(),c("div",ct,[t("dt",rt,i(l.translations.tax_number),1),t("dd",mt,i(n.client.tax_number),1),ht])):g("",!0)]),t("div",ut,[(d(!0),c(u,null,_(o.fields,(r,h)=>(d(),c("div",{key:h,class:"py-2"},[t("dt",_t,i(r.label),1),t("dd",pt,i(n.client[h]),1),gt]))),128))]),t("div",yt,[t("div",ft,[t("dt",vt,i(l.translations.currency),1),t("dd",bt,i(o.getCurrencyOption(n.client.currency_id)),1),xt])]),t("div",wt,[t("dt",Ct,i(l.translations.note),1),t("dd",kt,i(n.client.note),1),Mt])])):(d(),c("div",Pt,[t("div",Et,[(d(!0),c(u,null,_(o.skeletonItems,r=>(d(),c("div",{key:r,class:"py-2"},At))),128))])]))])],8,X)}var Bt=P(z,[["render",jt]]);const Dt={props:{loading:Boolean,showModal:Boolean,modalId:String,modalTitle:String,client:Object},data(){const e=window.myEasyComptaAdmin.easyComptaTranslations;return{editedClient:{...this.client},toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},currencyOptions:[],fields:{siren_number:{label:e.siren},tax_number:{label:e.tax_number},company_name:{label:e.company_name},manager_name:{label:e.manager_name},email:{label:e.email},phone:{label:e.phone,type:"tel"},mobile_phone:{label:e.mobile,type:"tel"},website:{label:e.website,type:"url"},address:{label:e.address},city:{label:e.city},postal_code:{label:e.postal_code},country:{label:e.country}},loadingBtn:!1}},mounted(){this.fetchOptions()},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},skeletonItems(){return Array.from({length:10},(e,s)=>s)},currencyOptions(){return this.currencyOptions}},methods:{closeModal(){document.getElementById("modal_client_edit").close()},async submitForm(){this.loadingBtn=!0;try{const e=await fetch(`/wp-json/my-easy-compta/v1/clients/${this.editedClient.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.editedClient)});if(e.ok){const s=await e.json();this.loadingBtn=!1,this.closeModal(),this.showToast(s.message,"alert-success"),this.$emit("clientEdited")}else{const s=`Error editing client: ${e.statusText}`;this.showToast(s,"alert-error"),console.error(s),this.loadingBtn=!1}}catch(e){const s=e.response&&e.response.data&&e.response.data.message?e.response.data.message:"Error editing client";this.showToast(s,"alert-error"),console.error("Error editing client:",e),this.loadingBtn=!1}},async fetchOptions(){try{const e=await fetch("/wp-json/my-easy-compta/v1/options",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}});if(e.ok){const s=await e.json();this.currencyOptions=s.currency_options}else throw new Error(`Failed to fetch options: ${e.statusText}`)}catch(e){console.error("Error fetching options:",e)}},showToast(e,s){this.toast.message=e,this.toast.type=s,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}},watch:{client:{handler(e){this.editedClient={...e}},immediate:!0}}},Ot=["id","open"],St={class:"modal-box"},Ft={class:"font-bold text-lg"},Nt={key:0},Ut={class:"grid grid-cols-2 gap-4"},Lt=t("div",{class:"skeleton h-4 w-full mb-2"},null,-1),Vt=t("div",{class:"skeleton h-4 w-full"},null,-1),Wt=[Lt,Vt],Rt={class:"grid grid-cols-2 gap-4"},zt=["for"],Xt=["type","id","onUpdate:modelValue"],qt={class:"grid grid-cols-2 gap-4"},Gt={class:"ecwp-group form-group"},Zt={for:"currencyId",class:"ecwp-label form-label"},Ht=["value"],Jt={class:"ecwp-group form-group mt-4"},Qt={for:"note",class:"ecwp-label form-label"},Kt={class:"form-group mt-4 flex justify-end"},Yt=["disabled"],$t={key:0,class:"loading loading-spinner loading-sm"};function te(e,s,n,m,l,o){return d(),c("div",null,[l.toast.visible?(d(),c("div",{key:0,class:y(["toast",l.toast.position]),style:{zIndex:9999}},[t("div",{class:y(["alert",l.toast.type,"text-white"])},[t("span",null,i(l.toast.message),1)],2)],2)):g("",!0),t("dialog",{id:n.modalId,class:"modal",open:n.showModal},[t("div",St,[t("h3",Ft,i(n.modalTitle),1),t("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:s[0]||(s[0]=r=>o.closeModal())}," \u2715 "),n.loading?(d(),c("div",Nt,[t("div",Ut,[(d(!0),c(u,null,_(o.skeletonItems,r=>(d(),c("div",{key:r,class:"py-2"},Wt))),128))])])):(d(),c("form",{key:1,onSubmit:s[3]||(s[3]=j((...r)=>o.submitForm&&o.submitForm(...r),["prevent"])),class:"form"},[t("div",Rt,[(d(!0),c(u,null,_(l.fields,(r,h)=>(d(),c("div",{key:h,class:"ecwp-group form-group"},[t("label",{for:h,class:"ecwp-label form-label"},i(r.label),9,zt),p(t("input",{type:r.type||"text",id:h,"onUpdate:modelValue":k=>l.editedClient[h]=k,class:y(["ecwp-input input","input-bordered",r.class||"w-full"])},null,10,Xt),[[B,l.editedClient[h]]])]))),128))]),t("div",qt,[t("div",Gt,[t("label",Zt,i(o.translations.currency),1),p(t("select",{id:"currencyId","onUpdate:modelValue":s[1]||(s[1]=r=>l.editedClient.currency_id=r),class:"ecwp-input select select-bordered w-full"},[(d(!0),c(u,null,_(o.currencyOptions,(r,h)=>(d(),c("option",{key:h,value:r.id},i(r.name)+" - "+i(r.code)+" ("+i(r.symbol)+") ",9,Ht))),128))],512),[[T,l.editedClient.currency_id]])])]),t("div",Jt,[t("label",Qt,i(o.translations.note),1),p(t("textarea",{id:"note","onUpdate:modelValue":s[2]||(s[2]=r=>l.editedClient.note=r),class:"ecwp-input textarea textarea-bordered w-full",rows:"4"},null,512),[[b,l.editedClient.note]])]),t("div",Kt,[t("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:l.loadingBtn},[x(i(o.translations.save)+" ",1),l.loadingBtn?(d(),c("span",$t)):g("",!0)],8,Yt)])],32))])],8,Ot)])}var ee=P(Dt,[["render",te]]);const se={name:"Clients",components:{Card:F,AddClientModal:U,ClientDetailsModal:Bt,ClientEditModal:ee,RemoveModal:N},data(){return{clients:[],filteredClients:[],filters:{company_name:"",manager_name:"",email:"",phone:""},showClientDetailsModal:!1,editClientModal:!1,showRemoveModal:!1,selectedClient:null,currentPage:1,totalPages:1,paginationButtons:[],loading:!0,settings:[],loadingModal:!1,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},created(){this.fetchClients(),this.loadSettings()},methods:{AddNew(){modal_clients.showModal()},fetchClients(e=1){this.loading=!0;const{perPage:s}=this;fetch(`/wp-json/my-easy-compta/v1/clients?page=${e}&per_page=${s}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(n=>n.json()).then(n=>{this.clients=n.clients,this.filteredClients=n.clients,this.totalCount=n.total_count,this.totalPages=n.total_pages,this.currentPage=n.page,this.perPage=s,this.generatePaginationButtons()}).catch(n=>{console.error("Error fetching clients:",n)}).finally(()=>{this.loading=!1})},fetchClientsWithFilters(e=1){this.loading=!0;const{perPage:s,filters:n}=this,m=new URLSearchParams({page:e,per_page:s,company_name:n.company_name,manager_name:n.manager_name,email:n.email,phone:n.phone}).toString();fetch(`/wp-json/my-easy-compta/v1/clients?${m}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(l=>l.json()).then(l=>{this.clients=l.clients,this.filteredClients=l.clients,this.totalCount=l.total_count,this.totalPages=l.total_pages,this.currentPage=l.page,this.perPage=s,this.generatePaginationButtons()}).catch(l=>{console.error("Error fetching clients with filters:",l)}).finally(()=>{this.loading=!1})},fetchClientDetails(e){fetch(`/wp-json/my-easy-compta/v1/clients/details/${e}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>s.json()).then(s=>{this.selectedClient=s,this.loadingModal=!1}).catch(s=>{console.error("Error fetching client details:",s),this.loadingModal=!1})},showClientDetails(e){this.loadingModal=!0,this.showClientDetailsModal=!0,modal_client_details.showModal(),this.fetchClientDetails(e.id)},editClient(e){this.loadingModal=!0,this.editClientModal=!0,modal_client_edit.showModal(),this.fetchClientDetails(e.id)},generatePaginationButtons(){this.paginationButtons=V(this.currentPage,this.totalPages)},goToPage(e){e!=="..."&&this.fetchClients(e)},perPageChanged(){this.fetchClients()},confirmDeleteClient(e){this.selectedClient=e,modal_client_remove.showModal(),this.showRemoveModal=!0},deleteClient(e){this.loading=!0;const s=e.id;fetch(`/wp-json/my-easy-compta/v1/clients/${s}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(n=>{if(!n.ok)throw new Error("Network response was not ok");return n.json()}).then(n=>{n.success?(this.fetchClients(),this.showToast(n.message,"alert-success")):(this.showToast(n.message,"alert-error"),console.error("Error deleting client:",n.statusText))}).catch(n=>{console.log(n.message);const m=n&&n.message?n.message:"Error deleting client";m==="This client cannot be deleted because it has associated data."?this.showToast(m,"alert-error"):console.error("Error deleting client:",n)})},async loadSettings(){try{this.loadingPrice=!0;const{settings:e,currencySymbol:s,vatData:n}=await W();this.settings=e,this.default_currency_symbol=s,this.default_vat=n,this.loadingPrice=!1}catch(e){this.showToast(e.message,"alert-error"),this.loadingPrice=!1}},showToast(e,s){R(this.toast,e,s)}},computed:{skeletonItems(){return Array.from({length:5},(e,s)=>s)},totalPages(){return Math.ceil(this.totalCount/this.perPage)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},ne={class:"pt-2 pr-4"},le={class:"flex justify-between items-center"},oe={class:"card-title"},ie=t("i",{class:"fas fa-plus-circle"},null,-1),ae={key:0,class:"ms-2"},de={class:"btn btn-outline btn-accent rounded-full hover:text-white",href:"/wp-admin/admin.php?page=my-easy-compta-export#tab1"},ce=t("i",{class:"fas fa-file-export"},null,-1),re=["data-tip"],me={class:"btn btn-outline btn-accent rounded-full",disabled:""},he=t("i",{class:"fas fa-file-export"},null,-1),ue=t("div",{class:"divider mt-2"},null,-1),_e={class:"flex items-center mb-4"},pe={for:"perPageSelect",class:"mr-2"},ge=["value"],ye={class:"overflow-x-auto"},fe={class:"table w-full"},ve={class:"flex justify-center"},be={key:0},xe={class:"flex items-center gap-3"},we={class:"avatar"},Ce={class:"mask mask-squircle w-12 h-12"},ke={version:"1.1",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 122.9 122.9",style:{"enable-background":"new 0 0 122.9 122.9"},"xml:space":"preserve"},Me=t("g",null,[t("path",{d:"M61.4,0c17,0,32.3,6.9,43.4,18c11.1,11.1,18,26.5,18,43.4c0,17-6.9,32.3-18,43.4c-11.1,11.1-26.5,18-43.4,18 s-32.3-6.9-43.4-18C6.9,93.8,0,78.4,0,61.4c0-17,6.9-32.3,18-43.4C29.1,6.9,44.5,0,61.4,0L61.4,0z M41.3,54.3c-1.1,0-2,0.3-2.5,0.7 c-0.3,0.2-0.6,0.5-0.7,0.8c-0.2,0.4-0.3,0.8-0.2,1.4c0,1.5,0.8,3.5,2.4,5.8l0,0l0,0l5,8c2,3.2,4.1,6.5,6.8,8.9 c2.5,2.3,5.6,3.9,9.6,3.9c4.4,0,7.6-1.6,10.2-4.1c2.7-2.5,4.9-6,7-9.5l5.7-9.3c1.1-2.4,1.4-4,1.2-5c-0.1-0.6-0.8-0.8-1.8-0.9 c-0.2,0-0.5,0-0.7,0c-0.3,0-0.5,0-0.8,0c-0.2,0-0.3,0-0.4,0c-0.5,0-1,0-1.6-0.1l1.9-8.6c-14.4,2.3-25.2-8.4-40.4-2.1L43,54.4 C42.4,54.4,41.8,54.4,41.3,54.3L41.3,54.3L41.3,54.3L41.3,54.3z M18.8,95.7c7.1-2.5,19.6-3.8,25.4-7.7c1-1.3,2.1-2.9,3.1-4.3 c0.6-0.9,1.1-1.7,1.6-2.3c0.1-0.1,0.2-0.2,0.3-0.3c-2.4-2.5-4.4-5.5-6.3-8.5l-5-8C36,61.8,35,59.3,35,57.3c0-1,0.1-1.9,0.5-2.6 c0.4-0.8,1-1.5,1.7-2c0.4-0.2,0.8-0.5,1.2-0.6c-0.3-4.3-0.4-9.8-0.2-14.4c0.1-1.1,0.3-2.2,0.6-3.3c1.3-4.6,4.5-8.3,8.5-10.8 c1.4-0.9,2.9-1.6,4.6-2.2c2.9-1.1,1.5-5.5,4.7-5.6c7.5-0.2,19.8,6.2,24.6,11.4c2.8,3,4.6,7,4.9,12.3l-0.3,13.1l0,0 c1.4,0.4,2.3,1.3,2.7,2.7c0.4,1.6,0,3.8-1.4,6.9l0,0c0,0.1-0.1,0.1-0.1,0.2l-5.7,9.4c-2.2,3.6-4.5,7.3-7.5,10.1L73.7,82l0,0 c0.4,0.5,0.8,1.1,1.2,1.7c0.8,1.1,1.6,2.4,2.5,3.6c5.3,4.5,19.3,5.9,26.7,8.6c7.6-9.4,12.1-21.4,12.1-34.4c0-15.1-6.1-28.8-16-38.7 c-9.9-9.9-23.6-16-38.7-16s-28.8,6.1-38.7,16c-9.9,9.9-16,23.6-16,38.7C6.7,74.4,11.2,86.3,18.8,95.7L18.8,95.7z M77,90.5 c-1.4-1.6-2.8-3.7-4.1-5.5c-0.4-0.5-0.7-1.1-1.1-1.5c-2.7,2-6,3.3-10.3,3.3c-4.5,0-8-1.6-10.9-4.1c0,0,0,0.1-0.1,0.1 c-0.5,0.7-1,1.4-1.6,2.3c-1.1,1.6-2.3,3.3-3.4,4.8C45.6,100,71.1,106,77,90.5L77,90.5z"})],-1),Pe=[Me],Ee={class:"font-bold"},Te={class:"text-sm opacity-50"},Ie={class:"badge badge-ghost badge-sm"},Ae={class:"flex justify-end"},je=["data-tip"],Be=["onClick"],De=t("i",{class:"far fa-eye"},null,-1),Oe=[De],Se=["data-tip"],Fe=["onClick"],Ne=t("i",{class:"fas fa-pencil-alt"},null,-1),Ue=[Ne],Le=["data-tip"],Ve=["onClick"],We=t("i",{class:"far fa-trash-alt"},null,-1),Re=[We],ze={key:0},Xe=t("div",{class:"flex gap-4 items-center"},[t("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),t("div",{class:"flex flex-col gap-4 w-full"},[t("div",{class:"skeleton h-4 w-full"}),t("div",{class:"skeleton h-4 w-full"})])],-1),qe=t("div",{class:"divider my-1"},null,-1),Ge=[Xe,qe],Ze={class:"join ecwp_pagination mt-6 pt-4"},He=["onClick"];function Je(e,s,n,m,l,o){const r=f("client-details-modal"),h=f("client-edit-modal"),k=f("remove-modal"),I=f("AddClientModal"),A=f("Card");return d(),c("div",ne,[l.toast.visible?(d(),c("div",{key:0,class:y(["toast",l.toast.position]),style:{zIndex:9999}},[t("div",{class:y(["alert",l.toast.type,"text-white"])},[t("span",null,i(l.toast.message),1)],2)],2)):g("",!0),v(r,{loading:l.loadingModal,"show-modal":l.showClientDetailsModal,"modal-id":"modal_client_details","modal-title":o.translations.client_details,client:l.selectedClient,onClose:s[0]||(s[0]=a=>l.showClientDetailsModal=!1)},null,8,["loading","show-modal","modal-title","client"]),v(h,{loading:l.loadingModal,"show-modal":l.editClientModal,"modal-id":"modal_client_edit","modal-title":o.translations.edit_client,client:l.selectedClient,onClose:s[1]||(s[1]=a=>l.editClientModal=!1),onClientEdited:o.fetchClients},null,8,["loading","show-modal","modal-title","client","onClientEdited"]),v(k,{"modal-id":"modal_client_remove","show-modal":l.showRemoveModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:s[2]||(s[2]=a=>o.deleteClient(l.selectedClient)),onCancel:s[3]||(s[3]=a=>l.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),v(A,{topMargin:"mt-8"},{default:D(()=>[t("div",le,[t("h2",oe,i(o.translations.clients),1),t("div",null,[t("button",{class:"btn btn-primary rounded-full",onClick:s[4]||(s[4]=(...a)=>o.AddNew&&o.AddNew(...a))},[x(i(o.translations.add)+" ",1),ie]),l.settings.easy_compta_export_addon_active==1?(d(),c("span",ae,[t("a",de,[x(i(o.translations.export)+" ",1),ce])])):(d(),c("span",{key:1,class:"tooltip tooltip-left tooltip-warning ms-2","data-tip":o.translations.active_export_addon},[t("button",me,[x(i(o.translations.export)+" ",1),he])],8,re))])]),ue,v(I,{onClientAdded:o.fetchClients},null,8,["onClientAdded"]),t("div",_e,[t("label",pe,i(o.translations.display_per_page),1),p(t("select",{id:"perPageSelect","onUpdate:modelValue":s[5]||(s[5]=a=>l.perPage=a),onChange:s[6]||(s[6]=(...a)=>o.perPageChanged&&o.perPageChanged(...a))},[(d(!0),c(u,null,_(l.perPageOptions,a=>(d(),c("option",{key:a,value:a},i(a),9,ge))),128))],544),[[T,l.perPage]])]),t("div",ye,[t("table",fe,[t("thead",null,[t("tr",null,[t("th",null,[t("div",null,i(o.translations.company_name),1),p(t("input",{"onUpdate:modelValue":s[7]||(s[7]=a=>l.filters.company_name=a),onInput:s[8]||(s[8]=()=>o.fetchClientsWithFilters()),type:"text",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[b,l.filters.company_name]])]),t("th",null,[t("div",null,i(o.translations.manager_name),1),p(t("input",{"onUpdate:modelValue":s[9]||(s[9]=a=>l.filters.manager_name=a),onInput:s[10]||(s[10]=()=>o.fetchClientsWithFilters()),type:"text",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[b,l.filters.manager_name]])]),t("th",null,[t("div",null,i(o.translations.email),1),p(t("input",{"onUpdate:modelValue":s[11]||(s[11]=a=>l.filters.email=a),onInput:s[12]||(s[12]=()=>o.fetchClientsWithFilters()),type:"text",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[b,l.filters.email]])]),t("th",null,[t("div",null,i(o.translations.phone),1),p(t("input",{"onUpdate:modelValue":s[13]||(s[13]=a=>l.filters.phone=a),onInput:s[14]||(s[14]=()=>o.fetchClientsWithFilters()),type:"text",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[b,l.filters.phone]])]),t("th",ve,i(o.translations.actions),1)])]),l.loading?g("",!0):(d(),c("tbody",be,[(d(!0),c(u,null,_(l.clients,a=>(d(),c("tr",{key:a.id},[t("td",null,[t("div",xe,[t("div",we,[t("div",Ce,[(d(),c("svg",ke,Pe))])]),t("div",null,[t("div",Ee,i(a.company_name),1),t("div",Te,[t("span",Ie,i(a.city)+" - "+i(a.country),1)])])])]),t("td",null,i(a.manager_name),1),t("td",null,i(a.email),1),t("td",null,i(a.phone),1),t("td",Ae,[t("span",{class:"lg:tooltip","data-tip":o.translations.view},[t("button",{class:"btn btn-circle mx-1",onClick:M=>o.showClientDetails(a)},Oe,8,Be)],8,je),t("span",{class:"lg:tooltip","data-tip":o.translations.edit},[t("button",{class:"btn btn-circle mx-1",onClick:M=>o.editClient(a)},Ue,8,Fe)],8,Se),t("span",{class:"lg:tooltip","data-tip":o.translations.delete},[t("button",{onClick:M=>o.confirmDeleteClient(a),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},Re,8,Ve)],8,Le)])]))),128))]))]),l.loading?(d(),c("div",ze,[(d(!0),c(u,null,_(l.skeletonRows,a=>(d(),c("div",{key:a,class:"flex flex-col gap-4 w-full"},Ge))),128))])):g("",!0),t("div",Ze,[(d(!0),c(u,null,_(l.paginationButtons,a=>(d(),c("button",{key:a,class:y(["join-item btn",{"btn-disabled":a==="..."||a===l.currentPage}]),onClick:M=>o.goToPage(a)},i(a),11,He))),128))])])]),_:1})])}var Qe=P(se,[["render",Je]]);const E=C;(function(e,s){const n=C,m=e();for(;[];)try{if(-parseInt(n(411))/1+parseInt(n(406))/2*(parseInt(n(415))/3)+parseInt(n(416))/4*(parseInt(n(405))/5)+parseInt(n(413))/6*(-parseInt(n(407))/7)+-parseInt(n(409))/8+-parseInt(n(404))/9*(parseInt(n(408))/10)+parseInt(n(403))/11*(parseInt(n(414))/12)===s)break;m.push(m.shift())}catch{m.push(m.shift())}})(w,620368);function w(){const e=["1650DCQjcU","861lbezwp","11276610ruaUAF","1276240SxHnqm","mount","539019oXbRZl","use","34614AdiUuF","58308GASady","18yIpMFH","17548nMFZee","6677NLEGTD","9DpdPgZ","230uNGyhr"];return w=function(){return e},w()}const Ke=O({render:()=>S(Qe)});function C(e,s){const n=w();return C=function(m,l){return m=m-403,n[m]},C(e,s)}Ke[E(412)](L)[E(410)]("#my-easy-compta-clients-app");
  • my-easy-compta/trunk/assets/dist/credits.min.js

    r3198779 r3233000  
    1 import{_ as b,d as x,o as r,c as d,n as g,a as e,t as i,g as f,e as y,m as C,i as k,F as h,r as u,j as T,f as I,h as E}from"./plugin-vue_export-helper.min.js";import{C as j,R as A}from"./RemoveAlert.min.js";import{g as M,b as R,s as B,f as D}from"./api.min.js";const S={name:"Credits",components:{Card:j,RemoveModal:A},data(){return{credits:[],selectedCredit:null,currentPage:1,totalPages:1,paginationButtons:[],loading:!0,loadingPrice:!0,loadingPdfId:null,loadingModal:!1,showRemoveModal:!1,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],settings:[],default_currency_symbol:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},created(){this.fetchCredits(),this.loadSettings()},methods:{fetchCredits(n=1){this.loading=!0;const{perPage:t}=this;fetch(`/wp-json/my-easy-compta/v1/credits?page=${n}&per_page=${t}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(o=>o.json()).then(o=>{this.credits=o.credits,this.totalCount=o.total_count,this.totalPages=o.total_pages,this.currentPage=o.page,this.perPage=t,this.generatePaginationButtons()}).catch(o=>{console.error("Error fetching credits:",o)}).finally(()=>{this.loading=!1})},generatePaginationButtons(){this.paginationButtons=M(this.currentPage,this.totalPages)},goToPage(n){n!=="..."&&this.fetchCredits(n)},perPageChanged(){this.fetchCredits()},formatAmount(n,t){return R(n,t,this.settings.currency_position)},showToast(n,t){B(this.toast,n,t)},confirmDeleteCredit(n){this.selectedCredit=n,modal_credit_remove.showModal(),this.showRemoveModal=!0},deleteCredit(n){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/credits/${n}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>{if(!t.ok)throw new Error("Network response was not ok");return t.json()}).then(t=>{t.success?(this.fetchCredits(),this.showToast(t.message,"alert-success")):(this.showToast(t.message,"alert-error"),console.error("Error deleting credit:",t.statusText))}).catch(t=>{console.error("Error deleting credit:",t)})},exportToPDF(n){this.loadingPdfId=n,fetch(`/wp-json/my-easy-compta/v1/credits/pdf/${n}`,{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>{if(!t.ok)throw this.loadingPdfId=null,new Error("Network response was not ok");return this.loadingPdfId=null,t.blob()}).then(t=>{const o=URL.createObjectURL(t);this.loadingPdfId=null,window.open(o)}).catch(t=>{this.loadingPdfId=null,console.error("There was a problem with the fetch operation:",t)})},async loadSettings(){try{this.loadingPrice=!0;const{settings:n,currencySymbol:t,vatData:o}=await D();this.settings=n,this.default_currency_symbol=t,this.default_vat=o,this.loadingPrice=!1}catch(n){this.showToast(n.message,"alert-error"),this.loadingPrice=!1}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},N={class:"pt-2 pr-4"},V={class:"flex justify-between items-center"},F={class:"card-title"},U=e("div",{class:"divider mt-2"},null,-1),z={class:"flex items-center mb-4"},L={for:"perPageSelect",class:"mr-2"},O=["value"],q={class:"overflow-x-auto"},G={key:0,class:"table w-full"},W={class:"flex justify-end"},X={key:0},H={key:1},J=e("span",{class:"loading loading-bars loading-sm"},null,-1),K=[J],Q={class:"flex justify-end"},Y=["data-tip"],Z=["onClick"],$=e("i",{class:"far fa-trash-alt"},null,-1),ee=[$],te=["data-tip"],se=["onClick","disabled"],ne={key:0,class:"far fa-file-pdf","aria-hidden":"true"},oe={key:1,class:"loading loading-spinner loading-sm"},ae={key:1},le=e("div",{class:"flex gap-4 items-center"},[e("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),e("div",{class:"flex flex-col gap-4 w-full"},[e("div",{class:"skeleton h-4 w-full"}),e("div",{class:"skeleton h-4 w-full"})])],-1),ie=e("div",{class:"divider my-1"},null,-1),re=[le,ie],de={class:"join ecwp_pagination mt-6 pt-4"},ce=["onClick"];function he(n,t,o,c,a,l){const w=x("remove-modal"),P=x("Card");return r(),d("div",N,[a.toast.visible?(r(),d("div",{key:0,class:g(["toast",a.toast.position]),style:{zIndex:9999}},[e("div",{class:g(["alert",a.toast.type,"text-white"])},[e("span",null,i(a.toast.message),1)],2)],2)):f("",!0),y(w,{"modal-id":"modal_credit_remove","show-modal":a.showRemoveModal,title:l.translations.are_you_sure,message:l.translations.no_turning_back,confirmText:l.translations.yes_delete_it,cancelText:l.translations.cancel,onConfirm:t[0]||(t[0]=s=>this.deleteCredit(a.selectedCredit)),onCancel:t[1]||(t[1]=s=>a.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),y(P,{topMargin:"mt-8"},{default:C(()=>[e("div",V,[e("h2",F,i(l.translations.credits),1)]),U,e("div",z,[e("label",L,i(l.translations.display_per_page),1),k(e("select",{id:"perPageSelect","onUpdate:modelValue":t[2]||(t[2]=s=>a.perPage=s),onChange:t[3]||(t[3]=(...s)=>l.perPageChanged&&l.perPageChanged(...s))},[(r(!0),d(h,null,u(a.perPageOptions,s=>(r(),d("option",{key:s,value:s},i(s),9,O))),128))],544),[[T,a.perPage]])]),e("div",q,[a.loading?(r(),d("div",ae,[(r(!0),d(h,null,u(a.skeletonRows,s=>(r(),d("div",{key:s,class:"flex flex-col gap-4 w-full"},re))),128))])):(r(),d("table",G,[e("thead",null,[e("tr",null,[e("th",null,i(l.translations.credit_number),1),e("th",null,i(l.translations.invoice_number),1),e("th",null,i(l.translations.client),1),e("th",null,i(l.translations.payment_date),1),e("th",null,i(l.translations.created_at),1),e("th",null,i(l.translations.amount),1),e("th",W,i(l.translations.actions),1)])]),e("tbody",null,[(r(!0),d(h,null,u(a.credits,s=>(r(),d("tr",{key:s.id},[e("td",null,i(s.credit_number),1),e("td",null,i(s.invoice_number),1),e("td",null,i(s.client_name),1),e("td",null,i(s.due_date),1),e("td",null,i(s.created_at),1),e("td",null,[a.loadingPrice?(r(),d("div",H,K)):(r(),d("div",X,[e("span",null,i(l.formatAmount(s.total_amount,a.default_currency_symbol)),1)]))]),e("td",Q,[e("span",{class:"lg:tooltip","data-tip":l.translations.delete},[e("button",{onClick:p=>l.confirmDeleteCredit(s.id),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},ee,8,Z)],8,Y),e("span",{class:"lg:tooltip","data-tip":l.translations.export},[e("button",{onClick:p=>l.exportToPDF(s.credit_id),class:"btn btn-circle mx-1 text-green-700",disabled:a.loadingPdfId===s.credit_id},[a.loadingPdfId!==s.credit_id?(r(),d("i",ne)):f("",!0),a.loadingPdfId===s.credit_id?(r(),d("span",oe)):f("",!0)],8,se)],8,te)])]))),128))])])),e("div",de,[(r(!0),d(h,null,u(a.paginationButtons,s=>(r(),d("button",{key:s,class:g(["join-item btn",{"btn-disabled":s==="..."||s===a.currentPage}]),onClick:p=>l.goToPage(s)},i(s),11,ce))),128))])])]),_:1})])}var ue=b(S,[["render",he]]);function _(){const n=["153024pVqAmT","8CUzbJE","8726109qThqbg","mount","601995YINiPa","48645hiegzh","212538VUNjAk","2QHOwMi","8722044HNKGIv","6613445tFEajG","#my-easy-compta-credits-app"];return _=function(){return n},_()}const v=m;(function(n,t){const o=m,c=n();for(;[];)try{if(-parseInt(o(272))/1+-parseInt(o(275))/2*(-parseInt(o(274))/3)+parseInt(o(268))/4+-parseInt(o(277))/5+parseInt(o(276))/6+parseInt(o(270))/7+-parseInt(o(269))/8*(parseInt(o(273))/9)===t)break;c.push(c.shift())}catch{c.push(c.shift())}})(_,879274);function m(n,t){const o=_();return m=function(c,a){return c=c-268,o[c]},m(n,t)}const _e=I({render:()=>E(ue)});_e[v(271)](v(278));
     1import{_ as P,d as x,o as r,c as d,n as f,a as e,t as i,g,e as y,m as C,i as b,F as h,r as u,j as k,f as I,h as T}from"./plugin-vue_export-helper.min.js";import{C as E,R as j}from"./RemoveAlert.min.js";import{g as R,b as A,s as B,f as D}from"./api.min.js";const M={name:"Credits",components:{Card:E,RemoveModal:j},data(){return{credits:[],selectedCredit:null,currentPage:1,totalPages:1,paginationButtons:[],loading:!0,loadingPrice:!0,loadingPdfId:null,loadingModal:!1,showRemoveModal:!1,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],settings:[],default_currency_symbol:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},created(){this.fetchCredits(),this.loadSettings()},methods:{fetchCredits(n=1){this.loading=!0;const{perPage:t}=this;fetch(`/wp-json/my-easy-compta/v1/credits?page=${n}&per_page=${t}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(o=>o.json()).then(o=>{this.credits=o.credits,this.totalCount=o.total_count,this.totalPages=o.total_pages,this.currentPage=o.page,this.perPage=t,this.generatePaginationButtons()}).catch(o=>{console.error("Error fetching credits:",o)}).finally(()=>{this.loading=!1})},generatePaginationButtons(){this.paginationButtons=R(this.currentPage,this.totalPages)},goToPage(n){n!=="..."&&this.fetchCredits(n)},perPageChanged(){this.fetchCredits()},formatAmount(n,t){return A(n,t,this.settings.currency_position)},showToast(n,t){B(this.toast,n,t)},confirmDeleteCredit(n){this.selectedCredit=n,modal_credit_remove.showModal(),this.showRemoveModal=!0},deleteCredit(n){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/credits/${n}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>{if(!t.ok)throw new Error("Network response was not ok");return t.json()}).then(t=>{t.success?(this.fetchCredits(),this.showToast(t.message,"alert-success")):(this.showToast(t.message,"alert-error"),console.error("Error deleting credit:",t.statusText))}).catch(t=>{console.error("Error deleting credit:",t)})},exportToPDF(n){this.loadingPdfId=n,fetch(`/wp-json/my-easy-compta/v1/credits/pdf/${n}`,{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>{if(!t.ok)throw this.loadingPdfId=null,new Error("Network response was not ok");return this.loadingPdfId=null,t.blob()}).then(t=>{const o=URL.createObjectURL(t);this.loadingPdfId=null,window.open(o)}).catch(t=>{this.loadingPdfId=null,console.error("There was a problem with the fetch operation:",t)})},async loadSettings(){try{this.loadingPrice=!0;const{settings:n,currencySymbol:t,vatData:o}=await D();this.settings=n,this.default_currency_symbol=t,this.default_vat=o,this.loadingPrice=!1}catch(n){this.showToast(n.message,"alert-error"),this.loadingPrice=!1}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},S={class:"pt-2 pr-4"},F={class:"flex justify-between items-center"},N={class:"card-title"},U=e("div",{class:"divider mt-2"},null,-1),V={class:"flex items-center mb-4"},W={for:"perPageSelect",class:"mr-2"},X=["value"],z={class:"overflow-x-auto"},L={key:0,class:"table w-full"},O={class:"flex justify-end"},H={key:0},Q={key:1},J=e("span",{class:"loading loading-bars loading-sm"},null,-1),Z=[J],G={class:"flex justify-end"},q=["data-tip"],K=["onClick"],Y=e("i",{class:"far fa-trash-alt"},null,-1),$=[Y],ee=["data-tip"],te=["onClick","disabled"],se={key:0,class:"far fa-file-pdf","aria-hidden":"true"},ne={key:1,class:"loading loading-spinner loading-sm"},oe={key:1},ae=e("div",{class:"flex gap-4 items-center"},[e("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),e("div",{class:"flex flex-col gap-4 w-full"},[e("div",{class:"skeleton h-4 w-full"}),e("div",{class:"skeleton h-4 w-full"})])],-1),le=e("div",{class:"divider my-1"},null,-1),ie=[ae,le],re={class:"join ecwp_pagination mt-6 pt-4"},de=["onClick"];function ce(n,t,o,c,a,l){const v=x("remove-modal"),w=x("Card");return r(),d("div",S,[a.toast.visible?(r(),d("div",{key:0,class:f(["toast",a.toast.position]),style:{zIndex:9999}},[e("div",{class:f(["alert",a.toast.type,"text-white"])},[e("span",null,i(a.toast.message),1)],2)],2)):g("",!0),y(v,{"modal-id":"modal_credit_remove","show-modal":a.showRemoveModal,title:l.translations.are_you_sure,message:l.translations.no_turning_back,confirmText:l.translations.yes_delete_it,cancelText:l.translations.cancel,onConfirm:t[0]||(t[0]=s=>this.deleteCredit(a.selectedCredit)),onCancel:t[1]||(t[1]=s=>a.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),y(w,{topMargin:"mt-8"},{default:C(()=>[e("div",F,[e("h2",N,i(l.translations.credits),1)]),U,e("div",V,[e("label",W,i(l.translations.display_per_page),1),b(e("select",{id:"perPageSelect","onUpdate:modelValue":t[2]||(t[2]=s=>a.perPage=s),onChange:t[3]||(t[3]=(...s)=>l.perPageChanged&&l.perPageChanged(...s))},[(r(!0),d(h,null,u(a.perPageOptions,s=>(r(),d("option",{key:s,value:s},i(s),9,X))),128))],544),[[k,a.perPage]])]),e("div",z,[a.loading?(r(),d("div",oe,[(r(!0),d(h,null,u(a.skeletonRows,s=>(r(),d("div",{key:s,class:"flex flex-col gap-4 w-full"},ie))),128))])):(r(),d("table",L,[e("thead",null,[e("tr",null,[e("th",null,i(l.translations.credit_number),1),e("th",null,i(l.translations.invoice_number),1),e("th",null,i(l.translations.client),1),e("th",null,i(l.translations.payment_date),1),e("th",null,i(l.translations.created_at),1),e("th",null,i(l.translations.amount),1),e("th",O,i(l.translations.actions),1)])]),e("tbody",null,[(r(!0),d(h,null,u(a.credits,s=>(r(),d("tr",{key:s.id},[e("td",null,i(s.credit_number),1),e("td",null,i(s.invoice_number),1),e("td",null,i(s.client_name),1),e("td",null,i(s.due_date),1),e("td",null,i(s.created_at),1),e("td",null,[a.loadingPrice?(r(),d("div",Q,Z)):(r(),d("div",H,[e("span",null,i(l.formatAmount(s.total_amount,a.default_currency_symbol)),1)]))]),e("td",G,[e("span",{class:"lg:tooltip","data-tip":l.translations.delete},[e("button",{onClick:p=>l.confirmDeleteCredit(s.id),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},$,8,K)],8,q),e("span",{class:"lg:tooltip","data-tip":l.translations.export},[e("button",{onClick:p=>l.exportToPDF(s.credit_id),class:"btn btn-circle mx-1 text-green-700",disabled:a.loadingPdfId===s.credit_id},[a.loadingPdfId!==s.credit_id?(r(),d("i",se)):g("",!0),a.loadingPdfId===s.credit_id?(r(),d("span",ne)):g("",!0)],8,te)],8,ee)])]))),128))])])),e("div",re,[(r(!0),d(h,null,u(a.paginationButtons,s=>(r(),d("button",{key:s,class:f(["join-item btn",{"btn-disabled":s==="..."||s===a.currentPage}]),onClick:p=>l.goToPage(s)},i(s),11,de))),128))])])]),_:1})])}var he=P(M,[["render",ce]]);const ue=_;(function(n,t){const o=_,c=n();for(;[];)try{if(parseInt(o(265))/1+-parseInt(o(266))/2+-parseInt(o(274))/3*(-parseInt(o(270))/4)+parseInt(o(273))/5*(-parseInt(o(269))/6)+parseInt(o(268))/7*(parseInt(o(272))/8)+-parseInt(o(271))/9+parseInt(o(264))/10===t)break;c.push(c.shift())}catch{c.push(c.shift())}})(m,510348);function _(n,t){const o=m();return _=function(c,a){return c=c-264,o[c]},_(n,t)}const _e=I({render:()=>T(he)});function m(){const n=["10QzkoRw","3EsaPOE","11306630oEUyyW","344288sRQpZN","1675932FSonAV","#my-easy-compta-credits-app","1002799HXNiCP","2807886AQWJeE","3906968jJIDZH","2796066rUnXih","8hihzkH"];return m=function(){return n},m()}_e.mount(ue(267));
  • my-easy-compta/trunk/assets/dist/expenses.min.js

    r3198779 r3233000  
    1 import{_ as T,o as a,c as i,n as f,a as t,t as d,g as m,w as j,F as x,r as y,i as g,v as A,j as b,k as E,l as v,d as w,H as M,e as C,m as V,f as B,h as I}from"./plugin-vue_export-helper.min.js";import{C as S,R as F}from"./RemoveAlert.min.js";import{T as W}from"./VueSearchSelect.min.js";import{V as U}from"./vue-datepicker.min.js";import{f as N,g as O,b as R,s as X}from"./api.min.js";const q={data(){const s=window.myEasyComptaAdmin.easyComptaTranslations;return{loadingBtn:!1,formData:{amount:"",expense_date:"",client_id:"",category_id:"",attachment:null,note:""},options:{clients:[],categories:[]},fields:{expense_date:{label:s.expense_date},client_id:{label:s.client},amount:{label:s.amount},category_id:{label:s.category}},toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{async fetchOptions(){try{const s=await fetch("/wp-json/my-easy-compta/v1/expenses/clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}),e=await fetch("/wp-json/my-easy-compta/v1/expenses/categories",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}});if(e.ok){const r=await e.json();this.options.categories=r;const p=await s.json();this.options.clients=p}else this.showToast("Erreur lors de la r\xE9cup\xE9ration des cat\xE9gories","alert-error"),console.error("Erreur lors de la r\xE9cup\xE9ration des cat\xE9gories")}catch(s){this.showToast(s,"alert-error"),console.error("Erreur lors de la r\xE9cup\xE9ration des options:",s)}},async submitForm(){this.loadingBtn=!0;const s=new FormData;s.append("amount",this.formData.amount),s.append("expense_date",this.formData.expense_date),s.append("client_id",this.formData.client_id),s.append("category_id",this.formData.category_id),this.$refs.attachment.files[0]&&s.append("attachment",this.$refs.attachment.files[0]),s.append("note",this.formData.note);try{const e=await fetch("/wp-json/my-easy-compta/v1/expenses",{method:"POST",body:s,headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}),r=await e.json();e.ok?(this.loadingBtn=!1,this.$emit("expenseAdded"),this.showToast(r.message,"alert-success"),this.resetForm(),this.closeModal()):(this.showToast(r.message||"Erreur lors de l'ajout de la d\xE9pense","alert-error"),console.error("Erreur lors de l'ajout de la d\xE9pense"),this.loadingBtn=!1)}catch(e){this.showToast(e,"alert-error"),console.error("Erreur lors de l'ajout de la d\xE9pense:",e),this.loadingBtn=!1}},showToast(s,e){this.toast.message=s,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},closeModal(){document.getElementById("modal_expenses").close()},resetForm(){this.formData={amount:"",expense_date:"",client_id:"",category_id:"",attachment:null,note:""},this.$refs.attachment.value=null}},mounted(){this.fetchOptions()}},z={id:"modal_expenses",class:"modal"},L={class:"modal-box"},J={class:"font-bold text-lg"},G={class:"grid grid-cols-2 gap-4"},H=["for"],K=["type","id","onUpdate:modelValue"],Y=["id"],Z=["value"],Q={value:""},$=["value"],ee={class:"ecwp-group form-group relative"},te={for:"attachment",class:"ecwp-label form-label"},se={type:"file",id:"attachment",ref:"attachment",class:"ecwp-input input input-bordered w-full peer"},ne={class:"ecwp-group form-group mt-4 relative"},oe={for:"note",class:"ecwp-label form-label"},le={class:"form-group mt-4 flex justify-end"},ae=["disabled"],ie={key:0,class:"loading loading-spinner loading-sm"};function re(s,e,r,p,n,l){return a(),i("div",null,[n.toast.visible?(a(),i("div",{key:0,class:f(["toast",n.toast.position]),style:{zIndex:9999}},[t("div",{class:f(["alert",n.toast.type,"text-white"])},[t("span",null,d(n.toast.message),1)],2)],2)):m("",!0),t("dialog",z,[t("div",L,[t("h3",J,d(l.translations.add),1),t("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(..._)=>l.closeModal&&l.closeModal(..._))}," \u2715 "),t("form",{onSubmit:e[5]||(e[5]=j((..._)=>l.submitForm&&l.submitForm(..._),["prevent"]))},[t("div",G,[(a(!0),i(x,null,y(n.fields,(_,u)=>(a(),i("div",{key:u,class:"ecwp-group form-group"},[t("label",{for:u,class:f(["ecwp-label form-label",u==="client_id"?"label-search":""])},d(_.label),11,H),u!=="category_id"&&u!=="client_id"&&u!=="expense_date"?g((a(),i("input",{key:0,type:_.type||"text",id:u,"onUpdate:modelValue":c=>n.formData[u]=c,class:f(["ecwp-input input","input-bordered",_.class||"w-full"])},null,10,K)),[[A,n.formData[u]]]):m("",!0),u==="category_id"?g((a(),i("select",{key:1,id:u,"onUpdate:modelValue":e[1]||(e[1]=c=>n.formData.category_id=c),class:f(["ecwp-input input","input-bordered",_.class||"w-full"])},[(a(!0),i(x,null,y(n.options.categories,c=>(a(),i("option",{key:c.id,value:c.id},d(c.name),9,Z))),128))],10,Y)),[[b,n.formData.category_id]]):m("",!0),u==="client_id"?g((a(),i("select",{key:2,id:"client_id","onUpdate:modelValue":e[2]||(e[2]=c=>n.formData.client_id=c),class:"ecwp-input input input-bordered w-full peer"},[t("option",Q,d(l.translations.select_client),1),(a(!0),i(x,null,y(n.options.clients,c=>(a(),i("option",{key:c.id,value:c.id},d(c.company_name),9,$))),128))],512)),[[b,n.formData.client_id]]):m("",!0),u=="expense_date"?g((a(),i("input",{key:3,type:"date",id:"expense_date","onUpdate:modelValue":e[3]||(e[3]=c=>n.formData.expense_date=c),class:"ecwp-input input input-bordered w-full peer",placeholder:"Date de d\xE9pense",required:""},null,512)),[[E,n.formData.expense_date]]):m("",!0)]))),128))]),t("div",ee,[t("label",te,d(l.translations.attached_file),1),t("input",se,null,512)]),t("div",ne,[t("label",oe,d(l.translations.note),1),g(t("textarea",{id:"note","onUpdate:modelValue":e[4]||(e[4]=_=>n.formData.note=_),class:"ecwp-input textarea textarea-bordered w-full peer",rows:"4",placeholder:"Note"},null,512),[[E,n.formData.note]])]),t("div",le,[t("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[v(d(l.translations.add)+" ",1),n.loadingBtn?(a(),i("span",ie)):m("",!0)],8,ae)])],32)])])])}var de=T(q,[["render",re]]);const ce={components:{ModelSelect:W,VueDatePicker:U},props:{loading:{type:Boolean,default:!1},showModal:{type:Boolean,default:!1},modalId:{type:String,required:!0},modalTitle:{type:String,default:""},expense:{type:Object,default:()=>({id:null,expense_date:"",client_id:"",amount:"",category_id:"",notes:""})},categories:Array,clients:Array},data(){const s=window.myEasyComptaAdmin.easyComptaTranslations;return{editedExpense:{...this.expense},loadingBtn:!1,clientOptions:[],toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},fields:{expense_date:{label:s.expense_date},client_id:{label:s.client},amount:{label:s.amount},category_id:{label:s.category}}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return s=>{if(!s)return"";const e=s.getDate().toString().padStart(2,"0"),r=(s.getMonth()+1).toString().padStart(2,"0"),p=s.getFullYear();return`${e}-${r}-${p}`}},skeletonItems(){return Array.from({length:10},(s,e)=>e)},categoriesExpenses(){return this.categories},clients(){return this.clients}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const s=await fetch(`/wp-json/my-easy-compta/v1/expenses/${this.editedExpense.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.editedExpense)});if(s.ok){const e=await s.json();this.closeModal(),this.showToast(e.message,"alert-success"),this.$emit("expenseEdited"),this.loadingBtn=!1}else{const e=`Error editing expense: ${s.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(s){const e=s.response&&s.response.data&&s.response.data.message?s.response.data.message:"Error editing expense";this.showToast(e,"alert-error"),console.error("Error editing expense:",s),this.loadingBtn=!1}},showToast(s,e){this.toast.message=s,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}},watch:{expense:{handler(s){this.editedExpense={...s}},immediate:!0}}},pe=["id","open"],ue={class:"modal-box"},me={class:"font-bold text-lg"},he={key:0},_e={class:"grid grid-cols-2 gap-4"},fe=t("div",{class:"skeleton h-4 w-full mb-2"},null,-1),ge=t("div",{class:"skeleton h-4 w-full"},null,-1),xe=[fe,ge],ye={class:"grid grid-cols-2 gap-4"},we=["for"],be=["type","id","onUpdate:modelValue"],ve=["id"],Ee=["value"],Ce={class:"ecwp-group form-group mt-4"},ke={for:"note",class:"ecwp-label form-label"},Pe={class:"form-group mt-4 flex justify-end"},Te=["disabled"],De={key:0,class:"loading loading-spinner loading-sm"};function Me(s,e,r,p,n,l){const _=w("model-select"),u=w("VueDatePicker");return a(),i("div",null,[n.toast.visible?(a(),i("div",{key:0,class:f(["toast",n.toast.position]),style:{zIndex:9999}},[t("div",{class:f(["alert",n.toast.type,"text-white"])},[t("span",null,d(n.toast.message),1)],2)],2)):m("",!0),t("dialog",{id:r.modalId,class:"modal",open:r.showModal},[t("div",ue,[t("h3",me,d(r.modalTitle),1),t("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...c)=>l.closeModal&&l.closeModal(...c))}," \u2715 "),r.loading?(a(),i("div",he,[t("div",_e,[(a(!0),i(x,null,y(l.skeletonItems,c=>(a(),i("div",{key:c,class:"py-2"},xe))),128))])])):(a(),i("form",{key:1,onSubmit:e[5]||(e[5]=j((...c)=>l.submitForm&&l.submitForm(...c),["prevent"])),class:"form"},[t("div",ye,[(a(!0),i(x,null,y(n.fields,(c,h)=>(a(),i("div",{key:h,class:"ecwp-group form-group"},[t("label",{for:h,class:f(["ecwp-label form-label",h==="client_id"?"label-search":""])},d(c.label),11,we),h!=="category_id"&&h!=="client_id"&&h!=="expense_date"?g((a(),i("input",{key:0,type:c.type||"text",id:h,"onUpdate:modelValue":o=>n.editedExpense[h]=o,class:f(["ecwp-input input","input-bordered",c.class||"w-full"])},null,10,be)),[[A,n.editedExpense[h]]]):m("",!0),h==="category_id"?g((a(),i("select",{key:1,id:h,"onUpdate:modelValue":e[1]||(e[1]=o=>n.editedExpense.category_id=o),class:f(["ecwp-input input","input-bordered",c.class||"w-full"])},[(a(!0),i(x,null,y(l.categoriesExpenses,o=>(a(),i("option",{key:o.id,value:o.id},d(o.name),9,Ee))),128))],10,ve)),[[b,n.editedExpense.category_id]]):m("",!0),h==="client_id"?(a(),M(_,{key:2,modelValue:n.editedExpense.client_id,"onUpdate:modelValue":e[2]||(e[2]=o=>n.editedExpense.client_id=o),options:l.clients,label:"text","track-by":"value",placeholder:l.translations.select,class:"ecwp-input input input-bordered w-full",required:""},null,8,["modelValue","options","placeholder"])):m("",!0),h=="expense_date"?(a(),M(u,{key:3,class:"ecwp-input ecwp-date input input-bordered w-full",id:"invoiceDate",modelValue:n.editedExpense.expense_date,"onUpdate:modelValue":e[3]||(e[3]=o=>n.editedExpense.expense_date=o),"enable-time-picker":!1,"auto-apply":"",format:l.formattedDate,locale:"fr",required:""},null,8,["modelValue","format"])):m("",!0)]))),128))]),t("div",Ce,[t("label",ke,d(l.translations.note),1),g(t("textarea",{id:"note","onUpdate:modelValue":e[4]||(e[4]=c=>n.editedExpense.notes=c),class:"ecwp-input textarea textarea-bordered w-full",rows:"4"},null,512),[[E,n.editedExpense.notes]])]),t("div",Pe,[t("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[v(d(l.translations.save)+" ",1),n.loadingBtn?(a(),i("span",De)):m("",!0)],8,Te)])],32))])],8,pe)])}var je=T(ce,[["render",Me]]);const Ae={name:"Expenses",components:{Card:S,AddExpenseModal:de,ExpenseEditModal:je,RemoveModal:F},data(){return{expenses:[],filteredExpenses:[],filters:{client:"",expense_date:"",total_amount:"",category:""},categories_expenses:[],categoriesExpenses:[],listClients:[],clientOptions:[],currentPage:1,totalPages:1,paginationButtons:[],loading:!0,loadingPrice:!0,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],settings:[],default_currency_symbol:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},editExpenseModal:!1,showRemoveModal:!1,selectedExpense:null}},created(){this.fetchExpensesWithFilters(),this.fetchClients(),this.fetchCategoriesExpenses(),this.loadSettings()},methods:{AddNew(){modal_expenses.showModal()},isImage(s){return["jpg","jpeg","png","gif","webp"].includes(s)},fetchExpenses(s=1){this.loading=!0;const{perPage:e}=this;fetch(`/wp-json/my-easy-compta/v1/expenses?page=${s}&per_page=${e}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(r=>r.json()).then(r=>{this.expenses=r.expenses,this.totalPages=r.total_pages,this.currentPage=r.page,this.totalCount=r.total_count,this.perPage=e,this.generatePaginationButtons()}).catch(r=>{console.error("Error fetching expenses:",r)}).finally(()=>{this.loading=!1})},fetchExpensesWithFilters(s=1){this.loading=!0;const{perPage:e,filters:r}=this,p=new URLSearchParams({page:s,per_page:e,...r}).toString();fetch(`/wp-json/my-easy-compta/v1/expenses?${p}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(n=>n.json()).then(n=>{this.expenses=n.expenses,this.totalCount=n.total_count,this.totalPages=n.total_pages,this.currentPage=s,this.perPage=e,this.generatePaginationButtons()}).catch(n=>{console.error("Error fetching expenses with filters:",n)}).finally(()=>{this.loading=!1})},fetchClients(){fetch("/wp-json/my-easy-compta/v1/clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>s.json()).then(s=>{this.clients=s.clients}).catch(s=>{console.error("Error fetching clients:",s)})},fetchCategoriesExpenses(){fetch("/wp-json/my-easy-compta/v1/expenses/categories",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>s.json()).then(s=>{this.categories_expenses=s}).catch(s=>{console.error("Error fetching categories expenses:",s)})},async loadSettings(){try{this.loadingPrice=!0;const{settings:s,currencySymbol:e,vatData:r}=await N();this.settings=s,this.default_currency_symbol=e,this.default_vat=r,this.loadingPrice=!1}catch(s){this.showToast(s.message,"alert-error"),this.loadingPrice=!1}},generatePaginationButtons(){this.paginationButtons=O(this.currentPage,this.totalPages)},goToPage(s){s!=="..."&&this.fetchExpensesWithFilters(s)},perPageChanged(){this.fetchExpensesWithFilters()},formatAmount(s,e){return R(s,e,this.settings.currency_position)},showToast(s,e){X(this.toast,s,e)},editExpense(s){this.loadingModal=!0,this.editExpenseModal=!0,modal_expense_edit.showModal(),this.fetchExpenseDetails(s)},fetchExpenseDetails(s){fetch(`/wp-json/my-easy-compta/v1/expenses/details/${s}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{this.selectedExpense=e,this.categoriesExpenses=e.categories_expenses,this.listClients=e.list_clients,this.clientOptions=this.listClients.map(r=>({value:r.id,text:`${r.company_name}`})),this.loadingModal=!1}).catch(e=>{console.error("Error fetching expense details:",e),this.loadingModal=!1})},confirmDeleteExpense(s){this.selectedExpense=s,modal_expense_remove.showModal(),this.showRemoveModal=!0},deleteExpense(s){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/expenses/${s}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Network response was not ok");return e.json()}).then(e=>{e.success?(this.fetchExpenses(),this.showToast(e.message,"alert-success")):(this.showToast(e.message,"alert-error"),console.error("Error deleting expense:",e.statusText))}).catch(e=>{console.error("Error deleting expense:",e)}),this.showRemoveModal=!1}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},defaultImage(){return window.myEasyComptaAdmin.pluginUrl+"/assets/img/file.svg"}}},Ve={class:"pt-2 pr-4"},Be={class:"flex justify-between items-center"},Ie={class:"card-title"},Se=t("i",{class:"fas fa-plus-circle"},null,-1),Fe={key:0,class:"ms-2"},We={class:"btn btn-outline btn-accent rounded-full hover:text-white",href:"/wp-admin/admin.php?page=my-easy-compta-export#tab5"},Ue=t("i",{class:"fas fa-file-export"},null,-1),Ne=["data-tip"],Oe={class:"btn btn-outline btn-accent rounded-full",disabled:""},Re=t("i",{class:"fas fa-file-export"},null,-1),Xe=t("div",{class:"divider mt-2"},null,-1),qe={class:"flex items-center mb-4"},ze={for:"perPageSelect",class:"mr-2"},Le=["value"],Je={class:"overflow-x-auto"},Ge={class:"table w-full"},He={value:""},Ke=["value"],Ye={value:""},Ze=["value"],Qe={class:"align-top"},$e={class:"align-top"},et={class:"flex justify-center"},tt={key:0},st={key:0},nt={key:1},ot=t("span",{class:"loading loading-bars loading-sm"},null,-1),lt=[ot],at={key:0,class:"avatar"},it={key:0,class:"w-16 mask mask-squircle"},rt=["href"],dt=["src"],ct={key:1,class:"w-16 mask mask-squircle"},pt=["href"],ut=["src"],mt={class:"flex justify-end"},ht=["data-tip"],_t=["onClick"],ft=t("i",{class:"fas fa-pencil-alt"},null,-1),gt=[ft],xt=["data-tip"],yt=["onClick"],wt=t("i",{class:"far fa-trash-alt"},null,-1),bt=[wt],vt={key:0},Et=t("div",{class:"flex gap-4 items-center"},[t("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),t("div",{class:"flex flex-col gap-4 w-full"},[t("div",{class:"skeleton h-4 w-full"}),t("div",{class:"skeleton h-4 w-full"})])],-1),Ct=t("div",{class:"divider my-1"},null,-1),kt=[Et,Ct],Pt={class:"join ecwp_pagination mt-6 pt-4"},Tt=["onClick"];function Dt(s,e,r,p,n,l){const _=w("AddExpenseModal"),u=w("expense-edit-modal"),c=w("remove-modal"),h=w("Card");return a(),i("div",Ve,[n.toast.visible?(a(),i("div",{key:0,class:f(["toast",n.toast.position]),style:{zIndex:9999}},[t("div",{class:f(["alert",n.toast.type,"text-white"])},[t("span",null,d(n.toast.message),1)],2)],2)):m("",!0),C(_,{onExpenseAdded:l.fetchExpenses},null,8,["onExpenseAdded"]),C(u,{loading:n.loading,"show-modal":n.editExpenseModal,"modal-id":"modal_expense_edit","modal-title":l.translations.edit_expense,expense:n.selectedExpense,categories:n.categoriesExpenses,clients:n.clientOptions,onExpenseEdited:l.fetchExpenses},null,8,["loading","show-modal","modal-title","expense","categories","clients","onExpenseEdited"]),C(c,{"modal-id":"modal_expense_remove","show-modal":n.showRemoveModal,title:l.translations.are_you_sure,message:l.translations.no_turning_back,confirmText:l.translations.yes_delete_it,cancelText:l.translations.cancel,onConfirm:e[0]||(e[0]=o=>this.deleteExpense(n.selectedExpense)),onCancel:e[1]||(e[1]=o=>n.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),C(h,{topMargin:"mt-8"},{default:V(()=>[t("div",Be,[t("h2",Ie,d(l.translations.expenses),1),t("div",null,[t("button",{class:"btn btn-primary rounded-full",onClick:e[2]||(e[2]=(...o)=>l.AddNew&&l.AddNew(...o))},[v(d(l.translations.add)+" ",1),Se]),n.settings.easy_compta_export_addon_active==1?(a(),i("span",Fe,[t("a",We,[v(d(l.translations.export)+" ",1),Ue])])):(a(),i("span",{key:1,class:"tooltip tooltip-left tooltip-warning ms-2","data-tip":l.translations.active_export_addon},[t("button",Oe,[v(d(l.translations.export)+" ",1),Re])],8,Ne))])]),Xe,t("div",qe,[t("label",ze,d(l.translations.display_per_page),1),g(t("select",{id:"perPageSelect","onUpdate:modelValue":e[3]||(e[3]=o=>n.perPage=o),onChange:e[4]||(e[4]=(...o)=>l.perPageChanged&&l.perPageChanged(...o))},[(a(!0),i(x,null,y(n.perPageOptions,o=>(a(),i("option",{key:o,value:o},d(o),9,Le))),128))],544),[[b,n.perPage]])]),t("div",Je,[t("table",Ge,[t("thead",null,[t("tr",null,[t("th",null,[t("div",null,d(l.translations.expense_date),1),g(t("input",{"onUpdate:modelValue":e[5]||(e[5]=o=>n.filters.expense_date=o),onInput:e[6]||(e[6]=o=>l.fetchExpensesWithFilters()),type:"date",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[E,n.filters.expense_date]])]),t("th",null,[t("div",null,d(l.translations.amount),1),g(t("input",{"onUpdate:modelValue":e[7]||(e[7]=o=>n.filters.total_amount=o),onInput:e[8]||(e[8]=o=>l.fetchExpensesWithFilters()),type:"text",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[E,n.filters.total_amount]])]),t("th",null,[t("div",null,d(l.translations.client),1),g(t("select",{"onUpdate:modelValue":e[9]||(e[9]=o=>n.filters.client=o),onChange:e[10]||(e[10]=o=>l.fetchExpensesWithFilters()),class:"ecwp-input input-xs input-bordered mt-2"},[t("option",He,d(l.translations.all),1),(a(!0),i(x,null,y(s.clients,o=>(a(),i("option",{key:o.id,value:o.company_name},d(o.company_name),9,Ke))),128))],544),[[b,n.filters.client]])]),t("th",null,[t("div",null,d(l.translations.category),1),g(t("select",{"onUpdate:modelValue":e[11]||(e[11]=o=>n.filters.category=o),onChange:e[12]||(e[12]=o=>l.fetchExpensesWithFilters()),class:"ecwp-input input-xs input-bordered mt-2"},[t("option",Ye,d(l.translations.all),1),(a(!0),i(x,null,y(n.categories_expenses,o=>(a(),i("option",{key:o.id,value:o.name},d(o.name),9,Ze))),128))],544),[[b,n.filters.category]])]),t("th",Qe,d(l.translations.attachment),1),t("th",$e,d(l.translations.note),1),t("th",et,d(l.translations.actions),1)])]),n.loading?m("",!0):(a(),i("tbody",tt,[(a(!0),i(x,null,y(n.expenses,o=>(a(),i("tr",{key:o.id},[t("td",null,d(o.expense_date),1),t("td",null,[n.loadingPrice?(a(),i("div",nt,lt)):(a(),i("div",st,[t("span",null,d(l.formatAmount(o.amount,n.default_currency_symbol)),1)]))]),t("td",null,d(o.company_name),1),t("td",null,d(o.name),1),t("td",null,[o.attachment_url?(a(),i("div",at,[l.isImage(o.type)?(a(),i("div",it,[t("a",{href:o.attachment_url,target:"_blank"},[t("img",{src:o.attachment_url},null,8,dt)],8,rt)])):(a(),i("div",ct,[t("a",{href:o.attachment_url,target:"_blank"},[t("img",{src:l.defaultImage},null,8,ut)],8,pt)]))])):m("",!0)]),t("td",null,d(o.notes),1),t("td",mt,[t("span",{class:"lg:tooltip","data-tip":l.translations.edit},[t("button",{onClick:D=>l.editExpense(o.id),class:"btn btn-circle mx-1"},gt,8,_t)],8,ht),t("span",{class:"lg:tooltip","data-tip":l.translations.delete},[t("button",{onClick:D=>l.confirmDeleteExpense(o.id),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},bt,8,yt)],8,xt)])]))),128))]))]),n.loading?(a(),i("div",vt,[(a(!0),i(x,null,y(n.skeletonRows,o=>(a(),i("div",{key:o,class:"flex flex-col gap-4 w-full"},kt))),128))])):m("",!0),t("div",Pt,[(a(!0),i(x,null,y(n.paginationButtons,o=>(a(),i("button",{key:o,class:f(["join-item btn",{"btn-disabled":o==="..."||o===n.currentPage}]),onClick:D=>l.goToPage(o)},d(o),11,Tt))),128))])])]),_:1})])}var Mt=T(Ae,[["render",Dt]]);function k(){const s=["mount","306930BAeiJW","550968JLDlLn","3691758NOXWfE","60407JuNawv","20EuAFEK","35VrZyVR","2818476bRDRIn","814578csGjNW","3238460wOlSoz"];return k=function(){return s},k()}const jt=P;(function(s,e){const r=P,p=s();for(;[];)try{if(parseInt(r(152))/1+-parseInt(r(156))/2+parseInt(r(159))/3*(-parseInt(r(153))/4)+parseInt(r(157))/5+parseInt(r(161))/6+parseInt(r(154))/7*(parseInt(r(160))/8)+-parseInt(r(155))/9===e)break;p.push(p.shift())}catch{p.push(p.shift())}})(k,435744);function P(s,e){const r=k();return P=function(p,n){return p=p-152,r[p]},P(s,e)}const At=B({render:()=>I(Mt)});At[jt(158)]("#my-easy-compta-expenses-app");
     1import{_ as T,o as a,c as i,n as f,a as t,t as d,g as m,w as A,F as x,r as y,i as g,v as V,j as b,k as E,l as v,d as w,H as D,e as C,m as B,f as I,h as S}from"./plugin-vue_export-helper.min.js";import{C as U,R as W}from"./RemoveAlert.min.js";import{T as F}from"./VueSearchSelect.min.js";import{V as N}from"./vue-datepicker.min.js";import{f as O,g as R,b as X,s as z}from"./api.min.js";const q={data(){const s=window.myEasyComptaAdmin.easyComptaTranslations;return{loadingBtn:!1,formData:{amount:"",expense_date:"",client_id:"",category_id:"",attachment:null,note:""},options:{clients:[],categories:[]},fields:{expense_date:{label:s.expense_date},client_id:{label:s.client},amount:{label:s.amount},category_id:{label:s.category}},toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{async fetchOptions(){try{const s=await fetch("/wp-json/my-easy-compta/v1/expenses/clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}),e=await fetch("/wp-json/my-easy-compta/v1/expenses/categories",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}});if(e.ok){const r=await e.json();this.options.categories=r;const p=await s.json();this.options.clients=p}else this.showToast("Erreur lors de la r\xE9cup\xE9ration des cat\xE9gories","alert-error"),console.error("Erreur lors de la r\xE9cup\xE9ration des cat\xE9gories")}catch(s){this.showToast(s,"alert-error"),console.error("Erreur lors de la r\xE9cup\xE9ration des options:",s)}},async submitForm(){this.loadingBtn=!0;const s=new FormData;s.append("amount",this.formData.amount),s.append("expense_date",this.formData.expense_date),s.append("client_id",this.formData.client_id),s.append("category_id",this.formData.category_id),this.$refs.attachment.files[0]&&s.append("attachment",this.$refs.attachment.files[0]),s.append("note",this.formData.note);try{const e=await fetch("/wp-json/my-easy-compta/v1/expenses",{method:"POST",body:s,headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}),r=await e.json();e.ok?(this.loadingBtn=!1,this.$emit("expenseAdded"),this.showToast(r.message,"alert-success"),this.resetForm(),this.closeModal()):(this.showToast(r.message||"Erreur lors de l'ajout de la d\xE9pense","alert-error"),console.error("Erreur lors de l'ajout de la d\xE9pense"),this.loadingBtn=!1)}catch(e){this.showToast(e,"alert-error"),console.error("Erreur lors de l'ajout de la d\xE9pense:",e),this.loadingBtn=!1}},showToast(s,e){this.toast.message=s,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},closeModal(){document.getElementById("modal_expenses").close()},resetForm(){this.formData={amount:"",expense_date:"",client_id:"",category_id:"",attachment:null,note:""},this.$refs.attachment.value=null}},mounted(){this.fetchOptions()}},L={id:"modal_expenses",class:"modal"},Y={class:"modal-box"},G={class:"font-bold text-lg"},H={class:"grid grid-cols-2 gap-4"},J=["for"],K=["type","id","onUpdate:modelValue"],Q=["id"],Z=["value"],$={value:""},ee=["value"],te={class:"ecwp-group form-group relative"},se={for:"attachment",class:"ecwp-label form-label"},ne={type:"file",id:"attachment",ref:"attachment",class:"ecwp-input input input-bordered w-full peer"},oe={class:"ecwp-group form-group mt-4 relative"},le={for:"note",class:"ecwp-label form-label"},ae={class:"form-group mt-4 flex justify-end"},ie=["disabled"],re={key:0,class:"loading loading-spinner loading-sm"};function de(s,e,r,p,n,l){return a(),i("div",null,[n.toast.visible?(a(),i("div",{key:0,class:f(["toast",n.toast.position]),style:{zIndex:9999}},[t("div",{class:f(["alert",n.toast.type,"text-white"])},[t("span",null,d(n.toast.message),1)],2)],2)):m("",!0),t("dialog",L,[t("div",Y,[t("h3",G,d(l.translations.add),1),t("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(..._)=>l.closeModal&&l.closeModal(..._))}," \u2715 "),t("form",{onSubmit:e[5]||(e[5]=A((..._)=>l.submitForm&&l.submitForm(..._),["prevent"]))},[t("div",H,[(a(!0),i(x,null,y(n.fields,(_,u)=>(a(),i("div",{key:u,class:"ecwp-group form-group"},[t("label",{for:u,class:f(["ecwp-label form-label",u==="client_id"?"label-search":""])},d(_.label),11,J),u!=="category_id"&&u!=="client_id"&&u!=="expense_date"?g((a(),i("input",{key:0,type:_.type||"text",id:u,"onUpdate:modelValue":c=>n.formData[u]=c,class:f(["ecwp-input input","input-bordered",_.class||"w-full"])},null,10,K)),[[V,n.formData[u]]]):m("",!0),u==="category_id"?g((a(),i("select",{key:1,id:u,"onUpdate:modelValue":e[1]||(e[1]=c=>n.formData.category_id=c),class:f(["ecwp-input input","input-bordered",_.class||"w-full"])},[(a(!0),i(x,null,y(n.options.categories,c=>(a(),i("option",{key:c.id,value:c.id},d(c.name),9,Z))),128))],10,Q)),[[b,n.formData.category_id]]):m("",!0),u==="client_id"?g((a(),i("select",{key:2,id:"client_id","onUpdate:modelValue":e[2]||(e[2]=c=>n.formData.client_id=c),class:"ecwp-input input input-bordered w-full peer"},[t("option",$,d(l.translations.select_client),1),(a(!0),i(x,null,y(n.options.clients,c=>(a(),i("option",{key:c.id,value:c.id},d(c.company_name),9,ee))),128))],512)),[[b,n.formData.client_id]]):m("",!0),u=="expense_date"?g((a(),i("input",{key:3,type:"date",id:"expense_date","onUpdate:modelValue":e[3]||(e[3]=c=>n.formData.expense_date=c),class:"ecwp-input input input-bordered w-full peer",placeholder:"Date de d\xE9pense",required:""},null,512)),[[E,n.formData.expense_date]]):m("",!0)]))),128))]),t("div",te,[t("label",se,d(l.translations.attached_file),1),t("input",ne,null,512)]),t("div",oe,[t("label",le,d(l.translations.note),1),g(t("textarea",{id:"note","onUpdate:modelValue":e[4]||(e[4]=_=>n.formData.note=_),class:"ecwp-input textarea textarea-bordered w-full peer",rows:"4",placeholder:"Note"},null,512),[[E,n.formData.note]])]),t("div",ae,[t("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[v(d(l.translations.add)+" ",1),n.loadingBtn?(a(),i("span",re)):m("",!0)],8,ie)])],32)])])])}var ce=T(q,[["render",de]]);const pe={components:{ModelSelect:F,VueDatePicker:N},props:{loading:{type:Boolean,default:!1},showModal:{type:Boolean,default:!1},modalId:{type:String,required:!0},modalTitle:{type:String,default:""},expense:{type:Object,default:()=>({id:null,expense_date:"",client_id:"",amount:"",category_id:"",notes:""})},categories:Array,clients:Array},data(){const s=window.myEasyComptaAdmin.easyComptaTranslations;return{editedExpense:{...this.expense},loadingBtn:!1,clientOptions:[],toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},fields:{expense_date:{label:s.expense_date},client_id:{label:s.client},amount:{label:s.amount},category_id:{label:s.category}}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return s=>{if(!s)return"";const e=s.getDate().toString().padStart(2,"0"),r=(s.getMonth()+1).toString().padStart(2,"0"),p=s.getFullYear();return`${e}-${r}-${p}`}},skeletonItems(){return Array.from({length:10},(s,e)=>e)},categoriesExpenses(){return this.categories},clients(){return this.clients}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const s=await fetch(`/wp-json/my-easy-compta/v1/expenses/${this.editedExpense.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.editedExpense)});if(s.ok){const e=await s.json();this.closeModal(),this.showToast(e.message,"alert-success"),this.$emit("expenseEdited"),this.loadingBtn=!1}else{const e=`Error editing expense: ${s.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(s){const e=s.response&&s.response.data&&s.response.data.message?s.response.data.message:"Error editing expense";this.showToast(e,"alert-error"),console.error("Error editing expense:",s),this.loadingBtn=!1}},showToast(s,e){this.toast.message=s,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}},watch:{expense:{handler(s){this.editedExpense={...s}},immediate:!0}}},ue=["id","open"],me={class:"modal-box"},he={class:"font-bold text-lg"},_e={key:0},fe={class:"grid grid-cols-2 gap-4"},ge=t("div",{class:"skeleton h-4 w-full mb-2"},null,-1),xe=t("div",{class:"skeleton h-4 w-full"},null,-1),ye=[ge,xe],we={class:"grid grid-cols-2 gap-4"},be=["for"],ve=["type","id","onUpdate:modelValue"],Ee=["id"],Ce=["value"],ke={class:"ecwp-group form-group mt-4"},Pe={for:"note",class:"ecwp-label form-label"},Te={class:"form-group mt-4 flex justify-end"},Me=["disabled"],De={key:0,class:"loading loading-spinner loading-sm"};function je(s,e,r,p,n,l){const _=w("model-select"),u=w("VueDatePicker");return a(),i("div",null,[n.toast.visible?(a(),i("div",{key:0,class:f(["toast",n.toast.position]),style:{zIndex:9999}},[t("div",{class:f(["alert",n.toast.type,"text-white"])},[t("span",null,d(n.toast.message),1)],2)],2)):m("",!0),t("dialog",{id:r.modalId,class:"modal",open:r.showModal},[t("div",me,[t("h3",he,d(r.modalTitle),1),t("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...c)=>l.closeModal&&l.closeModal(...c))}," \u2715 "),r.loading?(a(),i("div",_e,[t("div",fe,[(a(!0),i(x,null,y(l.skeletonItems,c=>(a(),i("div",{key:c,class:"py-2"},ye))),128))])])):(a(),i("form",{key:1,onSubmit:e[5]||(e[5]=A((...c)=>l.submitForm&&l.submitForm(...c),["prevent"])),class:"form"},[t("div",we,[(a(!0),i(x,null,y(n.fields,(c,h)=>(a(),i("div",{key:h,class:"ecwp-group form-group"},[t("label",{for:h,class:f(["ecwp-label form-label",h==="client_id"?"label-search":""])},d(c.label),11,be),h!=="category_id"&&h!=="client_id"&&h!=="expense_date"?g((a(),i("input",{key:0,type:c.type||"text",id:h,"onUpdate:modelValue":o=>n.editedExpense[h]=o,class:f(["ecwp-input input","input-bordered",c.class||"w-full"])},null,10,ve)),[[V,n.editedExpense[h]]]):m("",!0),h==="category_id"?g((a(),i("select",{key:1,id:h,"onUpdate:modelValue":e[1]||(e[1]=o=>n.editedExpense.category_id=o),class:f(["ecwp-input input","input-bordered",c.class||"w-full"])},[(a(!0),i(x,null,y(l.categoriesExpenses,o=>(a(),i("option",{key:o.id,value:o.id},d(o.name),9,Ce))),128))],10,Ee)),[[b,n.editedExpense.category_id]]):m("",!0),h==="client_id"?(a(),D(_,{key:2,modelValue:n.editedExpense.client_id,"onUpdate:modelValue":e[2]||(e[2]=o=>n.editedExpense.client_id=o),options:l.clients,label:"text","track-by":"value",placeholder:l.translations.select,class:"ecwp-input input input-bordered w-full",required:""},null,8,["modelValue","options","placeholder"])):m("",!0),h=="expense_date"?(a(),D(u,{key:3,class:"ecwp-input ecwp-date input input-bordered w-full",id:"invoiceDate",modelValue:n.editedExpense.expense_date,"onUpdate:modelValue":e[3]||(e[3]=o=>n.editedExpense.expense_date=o),"enable-time-picker":!1,"auto-apply":"",format:l.formattedDate,locale:"fr",required:""},null,8,["modelValue","format"])):m("",!0)]))),128))]),t("div",ke,[t("label",Pe,d(l.translations.note),1),g(t("textarea",{id:"note","onUpdate:modelValue":e[4]||(e[4]=c=>n.editedExpense.notes=c),class:"ecwp-input textarea textarea-bordered w-full",rows:"4"},null,512),[[E,n.editedExpense.notes]])]),t("div",Te,[t("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[v(d(l.translations.save)+" ",1),n.loadingBtn?(a(),i("span",De)):m("",!0)],8,Me)])],32))])],8,ue)])}var Ae=T(pe,[["render",je]]);const Ve={name:"Expenses",components:{Card:U,AddExpenseModal:ce,ExpenseEditModal:Ae,RemoveModal:W},data(){return{expenses:[],filteredExpenses:[],filters:{client:"",expense_date:"",total_amount:"",category:""},categories_expenses:[],categoriesExpenses:[],listClients:[],clientOptions:[],currentPage:1,totalPages:1,paginationButtons:[],loading:!0,loadingPrice:!0,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],settings:[],default_currency_symbol:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},editExpenseModal:!1,showRemoveModal:!1,selectedExpense:null}},created(){this.fetchExpensesWithFilters(),this.fetchClients(),this.fetchCategoriesExpenses(),this.loadSettings()},methods:{AddNew(){modal_expenses.showModal()},isImage(s){return["jpg","jpeg","png","gif","webp"].includes(s)},fetchExpenses(s=1){this.loading=!0;const{perPage:e}=this;fetch(`/wp-json/my-easy-compta/v1/expenses?page=${s}&per_page=${e}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(r=>r.json()).then(r=>{this.expenses=r.expenses,this.totalPages=r.total_pages,this.currentPage=r.page,this.totalCount=r.total_count,this.perPage=e,this.generatePaginationButtons()}).catch(r=>{console.error("Error fetching expenses:",r)}).finally(()=>{this.loading=!1})},fetchExpensesWithFilters(s=1){this.loading=!0;const{perPage:e,filters:r}=this,p=new URLSearchParams({page:s,per_page:e,...r}).toString();fetch(`/wp-json/my-easy-compta/v1/expenses?${p}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(n=>n.json()).then(n=>{this.expenses=n.expenses,this.totalCount=n.total_count,this.totalPages=n.total_pages,this.currentPage=s,this.perPage=e,this.generatePaginationButtons()}).catch(n=>{console.error("Error fetching expenses with filters:",n)}).finally(()=>{this.loading=!1})},fetchClients(){fetch("/wp-json/my-easy-compta/v1/clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>s.json()).then(s=>{this.clients=s.clients}).catch(s=>{console.error("Error fetching clients:",s)})},fetchCategoriesExpenses(){fetch("/wp-json/my-easy-compta/v1/expenses/categories",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>s.json()).then(s=>{this.categories_expenses=s}).catch(s=>{console.error("Error fetching categories expenses:",s)})},async loadSettings(){try{this.loadingPrice=!0;const{settings:s,currencySymbol:e,vatData:r}=await O();this.settings=s,this.default_currency_symbol=e,this.default_vat=r,this.loadingPrice=!1}catch(s){this.showToast(s.message,"alert-error"),this.loadingPrice=!1}},generatePaginationButtons(){this.paginationButtons=R(this.currentPage,this.totalPages)},goToPage(s){s!=="..."&&this.fetchExpensesWithFilters(s)},perPageChanged(){this.fetchExpensesWithFilters()},formatAmount(s,e){return X(s,e,this.settings.currency_position)},showToast(s,e){z(this.toast,s,e)},editExpense(s){this.loadingModal=!0,this.editExpenseModal=!0,modal_expense_edit.showModal(),this.fetchExpenseDetails(s)},fetchExpenseDetails(s){fetch(`/wp-json/my-easy-compta/v1/expenses/details/${s}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{this.selectedExpense=e,this.categoriesExpenses=e.categories_expenses,this.listClients=e.list_clients,this.clientOptions=this.listClients.map(r=>({value:r.id,text:`${r.company_name}`})),this.loadingModal=!1}).catch(e=>{console.error("Error fetching expense details:",e),this.loadingModal=!1})},confirmDeleteExpense(s){this.selectedExpense=s,modal_expense_remove.showModal(),this.showRemoveModal=!0},deleteExpense(s){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/expenses/${s}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Network response was not ok");return e.json()}).then(e=>{e.success?(this.fetchExpenses(),this.showToast(e.message,"alert-success")):(this.showToast(e.message,"alert-error"),console.error("Error deleting expense:",e.statusText))}).catch(e=>{console.error("Error deleting expense:",e)}),this.showRemoveModal=!1}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},defaultImage(){return window.myEasyComptaAdmin.pluginUrl+"/assets/img/file.svg"}}},Be={class:"pt-2 pr-4"},Ie={class:"flex justify-between items-center"},Se={class:"card-title"},Ue=t("i",{class:"fas fa-plus-circle"},null,-1),We={key:0,class:"ms-2"},Fe={class:"btn btn-outline btn-accent rounded-full hover:text-white",href:"/wp-admin/admin.php?page=my-easy-compta-export#tab5"},Ne=t("i",{class:"fas fa-file-export"},null,-1),Oe=["data-tip"],Re={class:"btn btn-outline btn-accent rounded-full",disabled:""},Xe=t("i",{class:"fas fa-file-export"},null,-1),ze=t("div",{class:"divider mt-2"},null,-1),qe={class:"flex items-center mb-4"},Le={for:"perPageSelect",class:"mr-2"},Ye=["value"],Ge={class:"overflow-x-auto"},He={class:"table w-full"},Je={value:""},Ke=["value"],Qe={value:""},Ze=["value"],$e={class:"align-top"},et={class:"align-top"},tt={class:"flex justify-center"},st={key:0},nt={key:0},ot={key:1},lt=t("span",{class:"loading loading-bars loading-sm"},null,-1),at=[lt],it={key:0,class:"avatar"},rt={key:0,class:"w-16 mask mask-squircle"},dt=["href"],ct=["src"],pt={key:1,class:"w-16 mask mask-squircle"},ut=["href"],mt=["src"],ht={class:"flex justify-end"},_t=["data-tip"],ft=["onClick"],gt=t("i",{class:"fas fa-pencil-alt"},null,-1),xt=[gt],yt=["data-tip"],wt=["onClick"],bt=t("i",{class:"far fa-trash-alt"},null,-1),vt=[bt],Et={key:0},Ct=t("div",{class:"flex gap-4 items-center"},[t("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),t("div",{class:"flex flex-col gap-4 w-full"},[t("div",{class:"skeleton h-4 w-full"}),t("div",{class:"skeleton h-4 w-full"})])],-1),kt=t("div",{class:"divider my-1"},null,-1),Pt=[Ct,kt],Tt={class:"join ecwp_pagination mt-6 pt-4"},Mt=["onClick"];function Dt(s,e,r,p,n,l){const _=w("AddExpenseModal"),u=w("expense-edit-modal"),c=w("remove-modal"),h=w("Card");return a(),i("div",Be,[n.toast.visible?(a(),i("div",{key:0,class:f(["toast",n.toast.position]),style:{zIndex:9999}},[t("div",{class:f(["alert",n.toast.type,"text-white"])},[t("span",null,d(n.toast.message),1)],2)],2)):m("",!0),C(_,{onExpenseAdded:l.fetchExpenses},null,8,["onExpenseAdded"]),C(u,{loading:n.loading,"show-modal":n.editExpenseModal,"modal-id":"modal_expense_edit","modal-title":l.translations.edit_expense,expense:n.selectedExpense,categories:n.categoriesExpenses,clients:n.clientOptions,onExpenseEdited:l.fetchExpenses},null,8,["loading","show-modal","modal-title","expense","categories","clients","onExpenseEdited"]),C(c,{"modal-id":"modal_expense_remove","show-modal":n.showRemoveModal,title:l.translations.are_you_sure,message:l.translations.no_turning_back,confirmText:l.translations.yes_delete_it,cancelText:l.translations.cancel,onConfirm:e[0]||(e[0]=o=>this.deleteExpense(n.selectedExpense)),onCancel:e[1]||(e[1]=o=>n.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),C(h,{topMargin:"mt-8"},{default:B(()=>[t("div",Ie,[t("h2",Se,d(l.translations.expenses),1),t("div",null,[t("button",{class:"btn btn-primary rounded-full",onClick:e[2]||(e[2]=(...o)=>l.AddNew&&l.AddNew(...o))},[v(d(l.translations.add)+" ",1),Ue]),n.settings.easy_compta_export_addon_active==1?(a(),i("span",We,[t("a",Fe,[v(d(l.translations.export)+" ",1),Ne])])):(a(),i("span",{key:1,class:"tooltip tooltip-left tooltip-warning ms-2","data-tip":l.translations.active_export_addon},[t("button",Re,[v(d(l.translations.export)+" ",1),Xe])],8,Oe))])]),ze,t("div",qe,[t("label",Le,d(l.translations.display_per_page),1),g(t("select",{id:"perPageSelect","onUpdate:modelValue":e[3]||(e[3]=o=>n.perPage=o),onChange:e[4]||(e[4]=(...o)=>l.perPageChanged&&l.perPageChanged(...o))},[(a(!0),i(x,null,y(n.perPageOptions,o=>(a(),i("option",{key:o,value:o},d(o),9,Ye))),128))],544),[[b,n.perPage]])]),t("div",Ge,[t("table",He,[t("thead",null,[t("tr",null,[t("th",null,[t("div",null,d(l.translations.expense_date),1),g(t("input",{"onUpdate:modelValue":e[5]||(e[5]=o=>n.filters.expense_date=o),onInput:e[6]||(e[6]=o=>l.fetchExpensesWithFilters()),type:"date",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[E,n.filters.expense_date]])]),t("th",null,[t("div",null,d(l.translations.amount),1),g(t("input",{"onUpdate:modelValue":e[7]||(e[7]=o=>n.filters.total_amount=o),onInput:e[8]||(e[8]=o=>l.fetchExpensesWithFilters()),type:"text",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[E,n.filters.total_amount]])]),t("th",null,[t("div",null,d(l.translations.client),1),g(t("select",{"onUpdate:modelValue":e[9]||(e[9]=o=>n.filters.client=o),onChange:e[10]||(e[10]=o=>l.fetchExpensesWithFilters()),class:"ecwp-input input-xs input-bordered mt-2"},[t("option",Je,d(l.translations.all),1),(a(!0),i(x,null,y(s.clients,o=>(a(),i("option",{key:o.id,value:o.company_name},d(o.company_name),9,Ke))),128))],544),[[b,n.filters.client]])]),t("th",null,[t("div",null,d(l.translations.category),1),g(t("select",{"onUpdate:modelValue":e[11]||(e[11]=o=>n.filters.category=o),onChange:e[12]||(e[12]=o=>l.fetchExpensesWithFilters()),class:"ecwp-input input-xs input-bordered mt-2"},[t("option",Qe,d(l.translations.all),1),(a(!0),i(x,null,y(n.categories_expenses,o=>(a(),i("option",{key:o.id,value:o.name},d(o.name),9,Ze))),128))],544),[[b,n.filters.category]])]),t("th",$e,d(l.translations.attachment),1),t("th",et,d(l.translations.note),1),t("th",tt,d(l.translations.actions),1)])]),n.loading?m("",!0):(a(),i("tbody",st,[(a(!0),i(x,null,y(n.expenses,o=>(a(),i("tr",{key:o.id},[t("td",null,d(o.expense_date),1),t("td",null,[n.loadingPrice?(a(),i("div",ot,at)):(a(),i("div",nt,[t("span",null,d(l.formatAmount(o.amount,n.default_currency_symbol)),1)]))]),t("td",null,d(o.company_name),1),t("td",null,d(o.name),1),t("td",null,[o.attachment_url?(a(),i("div",it,[l.isImage(o.type)?(a(),i("div",rt,[t("a",{href:o.attachment_url,target:"_blank"},[t("img",{src:o.attachment_url},null,8,ct)],8,dt)])):(a(),i("div",pt,[t("a",{href:o.attachment_url,target:"_blank"},[t("img",{src:l.defaultImage},null,8,mt)],8,ut)]))])):m("",!0)]),t("td",null,d(o.notes),1),t("td",ht,[t("span",{class:"lg:tooltip","data-tip":l.translations.edit},[t("button",{onClick:M=>l.editExpense(o.id),class:"btn btn-circle mx-1"},xt,8,ft)],8,_t),t("span",{class:"lg:tooltip","data-tip":l.translations.delete},[t("button",{onClick:M=>l.confirmDeleteExpense(o.id),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},vt,8,wt)],8,yt)])]))),128))]))]),n.loading?(a(),i("div",Et,[(a(!0),i(x,null,y(n.skeletonRows,o=>(a(),i("div",{key:o,class:"flex flex-col gap-4 w-full"},Pt))),128))])):m("",!0),t("div",Tt,[(a(!0),i(x,null,y(n.paginationButtons,o=>(a(),i("button",{key:o,class:f(["join-item btn",{"btn-disabled":o==="..."||o===n.currentPage}]),onClick:M=>l.goToPage(o)},d(o),11,Mt))),128))])])]),_:1})])}var jt=T(Ve,[["render",Dt]]);const j=k;function k(s,e){const r=P();return k=function(p,n){return p=p-130,r[p]},k(s,e)}(function(s,e){const r=k,p=s();for(;[];)try{if(-parseInt(r(135))/1+parseInt(r(138))/2+-parseInt(r(130))/3*(parseInt(r(136))/4)+parseInt(r(133))/5+parseInt(r(140))/6+-parseInt(r(139))/7*(parseInt(r(132))/8)+-parseInt(r(131))/9===e)break;p.push(p.shift())}catch{p.push(p.shift())}})(P,588951);function P(){const s=["3016805YyAAaU","mount","562844PKORUN","44LxeWnw","#my-easy-compta-expenses-app","2222796aoyhWa","62272zpTrzs","4110558YwsniT","71316dWuESM","6957549Gnhibz","192zVwAIS"];return P=function(){return s},P()}const At=I({render:()=>S(jt)});At[j(134)](j(137));
  • my-easy-compta/trunk/assets/dist/index.min.js

    r3198779 r3233000  
    1 import{_ as ne,o as u,c as h,n as I,a as r,t as c,g,w as J,i as D,k as W,F,r as U,p as ai,l as C,j as ue,v as li,s as ci,u as Ct,q as di,x as ui,y as eo,z as hi,A as jt,B as Re,h as to,C as Cn,D as mi,E as fi,d as O,e as P,m as me,G as no,H as pi}from"./plugin-vue_export-helper.min.js";import{C as Ze,R as qt}from"./RemoveAlert.min.js";import{T as hn}from"./VueSearchSelect.min.js";import{V as Nt}from"./vue-datepicker.min.js";import{f as mn,c as so,a as oo,g as io,b as ro,s as ao}from"./api.min.js";import{v as mt}from"./vue3-editor.common.min.js";function lo(t,e){return function(){return t.apply(e,arguments)}}const{toString:_i}=Object.prototype,{getPrototypeOf:ts}=Object,fn=(t=>e=>{const s=_i.call(e);return t[s]||(t[s]=s.slice(8,-1).toLowerCase())})(Object.create(null)),Pe=t=>(t=t.toLowerCase(),e=>fn(e)===t),pn=t=>e=>typeof e===t,{isArray:ft}=Array,Rt=pn("undefined");function gi(t){return t!==null&&!Rt(t)&&t.constructor!==null&&!Rt(t.constructor)&&xe(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const co=Pe("ArrayBuffer");function yi(t){let e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&co(t.buffer),e}const bi=pn("string"),xe=pn("function"),uo=pn("number"),_n=t=>t!==null&&typeof t=="object",vi=t=>t===!0||t===!1,zt=t=>{if(fn(t)!=="object")return!1;const e=ts(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},wi=Pe("Date"),xi=Pe("File"),Ei=Pe("Blob"),Ci=Pe("FileList"),Ti=t=>_n(t)&&xe(t.pipe),Ii=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||xe(t.append)&&((e=fn(t))==="formdata"||e==="object"&&xe(t.toString)&&t.toString()==="[object FormData]"))},ki=Pe("URLSearchParams"),[Ai,Si,Di,Pi]=["ReadableStream","Request","Response","Headers"].map(Pe),ji=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Bt(t,e,{allOwnKeys:s=!1}={}){if(t===null||typeof t=="undefined")return;let i,n;if(typeof t!="object"&&(t=[t]),ft(t))for(i=0,n=t.length;i<n;i++)e.call(null,t[i],i,t);else{const o=s?Object.getOwnPropertyNames(t):Object.keys(t),a=o.length;let l;for(i=0;i<a;i++)l=o[i],e.call(null,t[l],l,t)}}function ho(t,e){e=e.toLowerCase();const s=Object.keys(t);let i=s.length,n;for(;i-- >0;)if(n=s[i],e===n.toLowerCase())return n;return null}const mo=(()=>typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:global)(),fo=t=>!Rt(t)&&t!==mo;function Un(){const{caseless:t}=fo(this)&&this||{},e={},s=(i,n)=>{const o=t&&ho(e,n)||n;zt(e[o])&&zt(i)?e[o]=Un(e[o],i):zt(i)?e[o]=Un({},i):ft(i)?e[o]=i.slice():e[o]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&Bt(arguments[i],s);return e}const Ri=(t,e,s,{allOwnKeys:i}={})=>(Bt(e,(n,o)=>{s&&xe(n)?t[o]=lo(n,s):t[o]=n},{allOwnKeys:i}),t),Mi=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),Oi=(t,e,s,i)=>{t.prototype=Object.create(e.prototype,i),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),s&&Object.assign(t.prototype,s)},qi=(t,e,s,i)=>{let n,o,a;const l={};if(e=e||{},t==null)return e;do{for(n=Object.getOwnPropertyNames(t),o=n.length;o-- >0;)a=n[o],(!i||i(a,t,e))&&!l[a]&&(e[a]=t[a],l[a]=!0);t=s!==!1&&ts(t)}while(t&&(!s||s(t,e))&&t!==Object.prototype);return e},Ni=(t,e,s)=>{t=String(t),(s===void 0||s>t.length)&&(s=t.length),s-=e.length;const i=t.indexOf(e,s);return i!==-1&&i===s},Bi=t=>{if(!t)return null;if(ft(t))return t;let e=t.length;if(!uo(e))return null;const s=new Array(e);for(;e-- >0;)s[e]=t[e];return s},Vi=(t=>e=>t&&e instanceof t)(typeof Uint8Array!="undefined"&&ts(Uint8Array)),Fi=(t,e)=>{const i=(t&&t[Symbol.iterator]).call(t);let n;for(;(n=i.next())&&!n.done;){const o=n.value;e.call(t,o[0],o[1])}},Ui=(t,e)=>{let s;const i=[];for(;(s=t.exec(e))!==null;)i.push(s);return i},Li=Pe("HTMLFormElement"),Wi=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(s,i,n){return i.toUpperCase()+n}),ps=(({hasOwnProperty:t})=>(e,s)=>t.call(e,s))(Object.prototype),Xi=Pe("RegExp"),po=(t,e)=>{const s=Object.getOwnPropertyDescriptors(t),i={};Bt(s,(n,o)=>{let a;(a=e(n,o,t))!==!1&&(i[o]=a||n)}),Object.defineProperties(t,i)},Hi=t=>{po(t,(e,s)=>{if(xe(t)&&["arguments","caller","callee"].indexOf(s)!==-1)return!1;const i=t[s];if(!!xe(i)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+s+"'")})}})},Qi=(t,e)=>{const s={},i=n=>{n.forEach(o=>{s[o]=!0})};return ft(t)?i(t):i(String(t).split(e)),s},zi=()=>{},Gi=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e,Tn="abcdefghijklmnopqrstuvwxyz",_s="0123456789",_o={DIGIT:_s,ALPHA:Tn,ALPHA_DIGIT:Tn+Tn.toUpperCase()+_s},Ji=(t=16,e=_o.ALPHA_DIGIT)=>{let s="";const{length:i}=e;for(;t--;)s+=e[Math.random()*i|0];return s};function Yi(t){return!!(t&&xe(t.append)&&t[Symbol.toStringTag]==="FormData"&&t[Symbol.iterator])}const Ki=t=>{const e=new Array(10),s=(i,n)=>{if(_n(i)){if(e.indexOf(i)>=0)return;if(!("toJSON"in i)){e[n]=i;const o=ft(i)?[]:{};return Bt(i,(a,l)=>{const f=s(a,n+1);!Rt(f)&&(o[l]=f)}),e[n]=void 0,o}}return i};return s(t,0)},Zi=Pe("AsyncFunction"),$i=t=>t&&(_n(t)||xe(t))&&xe(t.then)&&xe(t.catch);var b={isArray:ft,isArrayBuffer:co,isBuffer:gi,isFormData:Ii,isArrayBufferView:yi,isString:bi,isNumber:uo,isBoolean:vi,isObject:_n,isPlainObject:zt,isReadableStream:Ai,isRequest:Si,isResponse:Di,isHeaders:Pi,isUndefined:Rt,isDate:wi,isFile:xi,isBlob:Ei,isRegExp:Xi,isFunction:xe,isStream:Ti,isURLSearchParams:ki,isTypedArray:Vi,isFileList:Ci,forEach:Bt,merge:Un,extend:Ri,trim:ji,stripBOM:Mi,inherits:Oi,toFlatObject:qi,kindOf:fn,kindOfTest:Pe,endsWith:Ni,toArray:Bi,forEachEntry:Fi,matchAll:Ui,isHTMLForm:Li,hasOwnProperty:ps,hasOwnProp:ps,reduceDescriptors:po,freezeMethods:Hi,toObjectSet:Qi,toCamelCase:Wi,noop:zi,toFiniteNumber:Gi,findKey:ho,global:mo,isContextDefined:fo,ALPHABET:_o,generateString:Ji,isSpecCompliantForm:Yi,toJSONObject:Ki,isAsyncFn:Zi,isThenable:$i};function V(t,e,s,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),s&&(this.config=s),i&&(this.request=i),n&&(this.response=n)}b.inherits(V,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:b.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const go=V.prototype,yo={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{yo[t]={value:t}});Object.defineProperties(V,yo);Object.defineProperty(go,"isAxiosError",{value:!0});V.from=(t,e,s,i,n,o)=>{const a=Object.create(go);return b.toFlatObject(t,a,function(f){return f!==Error.prototype},l=>l!=="isAxiosError"),V.call(a,t.message,e,s,i,n),a.cause=t,a.name=t.name,o&&Object.assign(a,o),a};var er=null;function Ln(t){return b.isPlainObject(t)||b.isArray(t)}function bo(t){return b.endsWith(t,"[]")?t.slice(0,-2):t}function gs(t,e,s){return t?t.concat(e).map(function(n,o){return n=bo(n),!s&&o?"["+n+"]":n}).join(s?".":""):e}function tr(t){return b.isArray(t)&&!t.some(Ln)}const nr=b.toFlatObject(b,{},null,function(e){return/^is[A-Z]/.test(e)});function gn(t,e,s){if(!b.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,s=b.toFlatObject(s,{metaTokens:!0,dots:!1,indexes:!1},!1,function(x,j){return!b.isUndefined(j[x])});const i=s.metaTokens,n=s.visitor||m,o=s.dots,a=s.indexes,f=(s.Blob||typeof Blob!="undefined"&&Blob)&&b.isSpecCompliantForm(e);if(!b.isFunction(n))throw new TypeError("visitor must be a function");function d(v){if(v===null)return"";if(b.isDate(v))return v.toISOString();if(!f&&b.isBlob(v))throw new V("Blob is not supported. Use a Buffer instead.");return b.isArrayBuffer(v)||b.isTypedArray(v)?f&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function m(v,x,j){let q=v;if(v&&!j&&typeof v=="object"){if(b.endsWith(x,"{}"))x=i?x:x.slice(0,-2),v=JSON.stringify(v);else if(b.isArray(v)&&tr(v)||(b.isFileList(v)||b.endsWith(x,"[]"))&&(q=b.toArray(v)))return x=bo(x),q.forEach(function(k,Q){!(b.isUndefined(k)||k===null)&&e.append(a===!0?gs([x],Q,o):a===null?x:x+"[]",d(k))}),!1}return Ln(v)?!0:(e.append(gs(j,x,o),d(v)),!1)}const p=[],y=Object.assign(nr,{defaultVisitor:m,convertValue:d,isVisitable:Ln});function _(v,x){if(!b.isUndefined(v)){if(p.indexOf(v)!==-1)throw Error("Circular reference detected in "+x.join("."));p.push(v),b.forEach(v,function(q,S){(!(b.isUndefined(q)||q===null)&&n.call(e,q,b.isString(S)?S.trim():S,x,y))===!0&&_(q,x?x.concat(S):[S])}),p.pop()}}if(!b.isObject(t))throw new TypeError("data must be an object");return _(t),e}function ys(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(i){return e[i]})}function ns(t,e){this._pairs=[],t&&gn(t,this,e)}const vo=ns.prototype;vo.append=function(e,s){this._pairs.push([e,s])};vo.toString=function(e){const s=e?function(i){return e.call(this,i,ys)}:ys;return this._pairs.map(function(n){return s(n[0])+"="+s(n[1])},"").join("&")};function sr(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function wo(t,e,s){if(!e)return t;const i=s&&s.encode||sr,n=s&&s.serialize;let o;if(n?o=n(e,s):o=b.isURLSearchParams(e)?e.toString():new ns(e,s).toString(i),o){const a=t.indexOf("#");a!==-1&&(t=t.slice(0,a)),t+=(t.indexOf("?")===-1?"?":"&")+o}return t}class or{constructor(){this.handlers=[]}use(e,s,i){return this.handlers.push({fulfilled:e,rejected:s,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){b.forEach(this.handlers,function(i){i!==null&&e(i)})}}var bs=or,xo={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ir=typeof URLSearchParams!="undefined"?URLSearchParams:ns,rr=typeof FormData!="undefined"?FormData:null,ar=typeof Blob!="undefined"?Blob:null,lr={isBrowser:!0,classes:{URLSearchParams:ir,FormData:rr,Blob:ar},protocols:["http","https","file","blob","url","data"]};const ss=typeof window!="undefined"&&typeof document!="undefined",cr=(t=>ss&&["ReactNative","NativeScript","NS"].indexOf(t)<0)(typeof navigator!="undefined"&&navigator.product),dr=(()=>typeof WorkerGlobalScope!="undefined"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),ur=ss&&window.location.href||"http://localhost";var hr=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ss,hasStandardBrowserWebWorkerEnv:dr,hasStandardBrowserEnv:cr,origin:ur},Symbol.toStringTag,{value:"Module"})),Ae={...hr,...lr};function mr(t,e){return gn(t,new Ae.classes.URLSearchParams,Object.assign({visitor:function(s,i,n,o){return Ae.isNode&&b.isBuffer(s)?(this.append(i,s.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},e))}function fr(t){return b.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function pr(t){const e={},s=Object.keys(t);let i;const n=s.length;let o;for(i=0;i<n;i++)o=s[i],e[o]=t[o];return e}function Eo(t){function e(s,i,n,o){let a=s[o++];if(a==="__proto__")return!0;const l=Number.isFinite(+a),f=o>=s.length;return a=!a&&b.isArray(n)?n.length:a,f?(b.hasOwnProp(n,a)?n[a]=[n[a],i]:n[a]=i,!l):((!n[a]||!b.isObject(n[a]))&&(n[a]=[]),e(s,i,n[a],o)&&b.isArray(n[a])&&(n[a]=pr(n[a])),!l)}if(b.isFormData(t)&&b.isFunction(t.entries)){const s={};return b.forEachEntry(t,(i,n)=>{e(fr(i),n,s,0)}),s}return null}function _r(t,e,s){if(b.isString(t))try{return(e||JSON.parse)(t),b.trim(t)}catch(i){if(i.name!=="SyntaxError")throw i}return(s||JSON.stringify)(t)}const os={transitional:xo,adapter:["xhr","http","fetch"],transformRequest:[function(e,s){const i=s.getContentType()||"",n=i.indexOf("application/json")>-1,o=b.isObject(e);if(o&&b.isHTMLForm(e)&&(e=new FormData(e)),b.isFormData(e))return n?JSON.stringify(Eo(e)):e;if(b.isArrayBuffer(e)||b.isBuffer(e)||b.isStream(e)||b.isFile(e)||b.isBlob(e)||b.isReadableStream(e))return e;if(b.isArrayBufferView(e))return e.buffer;if(b.isURLSearchParams(e))return s.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let l;if(o){if(i.indexOf("application/x-www-form-urlencoded")>-1)return mr(e,this.formSerializer).toString();if((l=b.isFileList(e))||i.indexOf("multipart/form-data")>-1){const f=this.env&&this.env.FormData;return gn(l?{"files[]":e}:e,f&&new f,this.formSerializer)}}return o||n?(s.setContentType("application/json",!1),_r(e)):e}],transformResponse:[function(e){const s=this.transitional||os.transitional,i=s&&s.forcedJSONParsing,n=this.responseType==="json";if(b.isResponse(e)||b.isReadableStream(e))return e;if(e&&b.isString(e)&&(i&&!this.responseType||n)){const a=!(s&&s.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(l){if(a)throw l.name==="SyntaxError"?V.from(l,V.ERR_BAD_RESPONSE,this,null,this.response):l}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ae.classes.FormData,Blob:Ae.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};b.forEach(["delete","get","head","post","put","patch"],t=>{os.headers[t]={}});var is=os;const gr=b.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);var yr=t=>{const e={};let s,i,n;return t&&t.split(`
     1import{_ as ne,o as u,c as h,n as I,a as r,t as c,g,w as J,i as D,k as W,F,r as U,p as ai,l as C,j as ue,v as li,s as ci,u as Ct,q as di,x as ui,y as eo,z as hi,A as Rt,B as je,h as to,C as Cn,D as mi,E as fi,d as O,e as P,m as me,G as no,H as pi}from"./plugin-vue_export-helper.min.js";import{C as Ze,R as qt}from"./RemoveAlert.min.js";import{T as hn}from"./VueSearchSelect.min.js";import{V as Nt}from"./vue-datepicker.min.js";import{f as mn,c as so,a as oo,g as io,b as ro,s as ao}from"./api.min.js";import{v as mt}from"./vue3-editor.common.min.js";function lo(t,e){return function(){return t.apply(e,arguments)}}const{toString:_i}=Object.prototype,{getPrototypeOf:ts}=Object,fn=(t=>e=>{const s=_i.call(e);return t[s]||(t[s]=s.slice(8,-1).toLowerCase())})(Object.create(null)),Pe=t=>(t=t.toLowerCase(),e=>fn(e)===t),pn=t=>e=>typeof e===t,{isArray:ft}=Array,jt=pn("undefined");function gi(t){return t!==null&&!jt(t)&&t.constructor!==null&&!jt(t.constructor)&&Ee(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const co=Pe("ArrayBuffer");function yi(t){let e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&co(t.buffer),e}const bi=pn("string"),Ee=pn("function"),uo=pn("number"),_n=t=>t!==null&&typeof t=="object",vi=t=>t===!0||t===!1,Qt=t=>{if(fn(t)!=="object")return!1;const e=ts(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},wi=Pe("Date"),xi=Pe("File"),Ei=Pe("Blob"),Ci=Pe("FileList"),Ti=t=>_n(t)&&Ee(t.pipe),Ii=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||Ee(t.append)&&((e=fn(t))==="formdata"||e==="object"&&Ee(t.toString)&&t.toString()==="[object FormData]"))},ki=Pe("URLSearchParams"),[Ai,Si,Di,Pi]=["ReadableStream","Request","Response","Headers"].map(Pe),Ri=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Bt(t,e,{allOwnKeys:s=!1}={}){if(t===null||typeof t=="undefined")return;let i,n;if(typeof t!="object"&&(t=[t]),ft(t))for(i=0,n=t.length;i<n;i++)e.call(null,t[i],i,t);else{const o=s?Object.getOwnPropertyNames(t):Object.keys(t),a=o.length;let l;for(i=0;i<a;i++)l=o[i],e.call(null,t[l],l,t)}}function ho(t,e){e=e.toLowerCase();const s=Object.keys(t);let i=s.length,n;for(;i-- >0;)if(n=s[i],e===n.toLowerCase())return n;return null}const mo=(()=>typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:typeof window!="undefined"?window:global)(),fo=t=>!jt(t)&&t!==mo;function Un(){const{caseless:t}=fo(this)&&this||{},e={},s=(i,n)=>{const o=t&&ho(e,n)||n;Qt(e[o])&&Qt(i)?e[o]=Un(e[o],i):Qt(i)?e[o]=Un({},i):ft(i)?e[o]=i.slice():e[o]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&Bt(arguments[i],s);return e}const ji=(t,e,s,{allOwnKeys:i}={})=>(Bt(e,(n,o)=>{s&&Ee(n)?t[o]=lo(n,s):t[o]=n},{allOwnKeys:i}),t),Mi=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),Oi=(t,e,s,i)=>{t.prototype=Object.create(e.prototype,i),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),s&&Object.assign(t.prototype,s)},qi=(t,e,s,i)=>{let n,o,a;const l={};if(e=e||{},t==null)return e;do{for(n=Object.getOwnPropertyNames(t),o=n.length;o-- >0;)a=n[o],(!i||i(a,t,e))&&!l[a]&&(e[a]=t[a],l[a]=!0);t=s!==!1&&ts(t)}while(t&&(!s||s(t,e))&&t!==Object.prototype);return e},Ni=(t,e,s)=>{t=String(t),(s===void 0||s>t.length)&&(s=t.length),s-=e.length;const i=t.indexOf(e,s);return i!==-1&&i===s},Bi=t=>{if(!t)return null;if(ft(t))return t;let e=t.length;if(!uo(e))return null;const s=new Array(e);for(;e-- >0;)s[e]=t[e];return s},Vi=(t=>e=>t&&e instanceof t)(typeof Uint8Array!="undefined"&&ts(Uint8Array)),Fi=(t,e)=>{const i=(t&&t[Symbol.iterator]).call(t);let n;for(;(n=i.next())&&!n.done;){const o=n.value;e.call(t,o[0],o[1])}},Ui=(t,e)=>{let s;const i=[];for(;(s=t.exec(e))!==null;)i.push(s);return i},Li=Pe("HTMLFormElement"),Wi=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(s,i,n){return i.toUpperCase()+n}),ps=(({hasOwnProperty:t})=>(e,s)=>t.call(e,s))(Object.prototype),Xi=Pe("RegExp"),po=(t,e)=>{const s=Object.getOwnPropertyDescriptors(t),i={};Bt(s,(n,o)=>{let a;(a=e(n,o,t))!==!1&&(i[o]=a||n)}),Object.defineProperties(t,i)},Hi=t=>{po(t,(e,s)=>{if(Ee(t)&&["arguments","caller","callee"].indexOf(s)!==-1)return!1;const i=t[s];if(!!Ee(i)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+s+"'")})}})},zi=(t,e)=>{const s={},i=n=>{n.forEach(o=>{s[o]=!0})};return ft(t)?i(t):i(String(t).split(e)),s},Qi=()=>{},Gi=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e,Tn="abcdefghijklmnopqrstuvwxyz",_s="0123456789",_o={DIGIT:_s,ALPHA:Tn,ALPHA_DIGIT:Tn+Tn.toUpperCase()+_s},Ji=(t=16,e=_o.ALPHA_DIGIT)=>{let s="";const{length:i}=e;for(;t--;)s+=e[Math.random()*i|0];return s};function Yi(t){return!!(t&&Ee(t.append)&&t[Symbol.toStringTag]==="FormData"&&t[Symbol.iterator])}const Ki=t=>{const e=new Array(10),s=(i,n)=>{if(_n(i)){if(e.indexOf(i)>=0)return;if(!("toJSON"in i)){e[n]=i;const o=ft(i)?[]:{};return Bt(i,(a,l)=>{const f=s(a,n+1);!jt(f)&&(o[l]=f)}),e[n]=void 0,o}}return i};return s(t,0)},Zi=Pe("AsyncFunction"),$i=t=>t&&(_n(t)||Ee(t))&&Ee(t.then)&&Ee(t.catch);var b={isArray:ft,isArrayBuffer:co,isBuffer:gi,isFormData:Ii,isArrayBufferView:yi,isString:bi,isNumber:uo,isBoolean:vi,isObject:_n,isPlainObject:Qt,isReadableStream:Ai,isRequest:Si,isResponse:Di,isHeaders:Pi,isUndefined:jt,isDate:wi,isFile:xi,isBlob:Ei,isRegExp:Xi,isFunction:Ee,isStream:Ti,isURLSearchParams:ki,isTypedArray:Vi,isFileList:Ci,forEach:Bt,merge:Un,extend:ji,trim:Ri,stripBOM:Mi,inherits:Oi,toFlatObject:qi,kindOf:fn,kindOfTest:Pe,endsWith:Ni,toArray:Bi,forEachEntry:Fi,matchAll:Ui,isHTMLForm:Li,hasOwnProperty:ps,hasOwnProp:ps,reduceDescriptors:po,freezeMethods:Hi,toObjectSet:zi,toCamelCase:Wi,noop:Qi,toFiniteNumber:Gi,findKey:ho,global:mo,isContextDefined:fo,ALPHABET:_o,generateString:Ji,isSpecCompliantForm:Yi,toJSONObject:Ki,isAsyncFn:Zi,isThenable:$i};function V(t,e,s,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),s&&(this.config=s),i&&(this.request=i),n&&(this.response=n)}b.inherits(V,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:b.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const go=V.prototype,yo={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{yo[t]={value:t}});Object.defineProperties(V,yo);Object.defineProperty(go,"isAxiosError",{value:!0});V.from=(t,e,s,i,n,o)=>{const a=Object.create(go);return b.toFlatObject(t,a,function(f){return f!==Error.prototype},l=>l!=="isAxiosError"),V.call(a,t.message,e,s,i,n),a.cause=t,a.name=t.name,o&&Object.assign(a,o),a};var er=null;function Ln(t){return b.isPlainObject(t)||b.isArray(t)}function bo(t){return b.endsWith(t,"[]")?t.slice(0,-2):t}function gs(t,e,s){return t?t.concat(e).map(function(n,o){return n=bo(n),!s&&o?"["+n+"]":n}).join(s?".":""):e}function tr(t){return b.isArray(t)&&!t.some(Ln)}const nr=b.toFlatObject(b,{},null,function(e){return/^is[A-Z]/.test(e)});function gn(t,e,s){if(!b.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,s=b.toFlatObject(s,{metaTokens:!0,dots:!1,indexes:!1},!1,function(x,R){return!b.isUndefined(R[x])});const i=s.metaTokens,n=s.visitor||m,o=s.dots,a=s.indexes,f=(s.Blob||typeof Blob!="undefined"&&Blob)&&b.isSpecCompliantForm(e);if(!b.isFunction(n))throw new TypeError("visitor must be a function");function d(v){if(v===null)return"";if(b.isDate(v))return v.toISOString();if(!f&&b.isBlob(v))throw new V("Blob is not supported. Use a Buffer instead.");return b.isArrayBuffer(v)||b.isTypedArray(v)?f&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function m(v,x,R){let q=v;if(v&&!R&&typeof v=="object"){if(b.endsWith(x,"{}"))x=i?x:x.slice(0,-2),v=JSON.stringify(v);else if(b.isArray(v)&&tr(v)||(b.isFileList(v)||b.endsWith(x,"[]"))&&(q=b.toArray(v)))return x=bo(x),q.forEach(function(k,z){!(b.isUndefined(k)||k===null)&&e.append(a===!0?gs([x],z,o):a===null?x:x+"[]",d(k))}),!1}return Ln(v)?!0:(e.append(gs(R,x,o),d(v)),!1)}const p=[],y=Object.assign(nr,{defaultVisitor:m,convertValue:d,isVisitable:Ln});function _(v,x){if(!b.isUndefined(v)){if(p.indexOf(v)!==-1)throw Error("Circular reference detected in "+x.join("."));p.push(v),b.forEach(v,function(q,S){(!(b.isUndefined(q)||q===null)&&n.call(e,q,b.isString(S)?S.trim():S,x,y))===!0&&_(q,x?x.concat(S):[S])}),p.pop()}}if(!b.isObject(t))throw new TypeError("data must be an object");return _(t),e}function ys(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(i){return e[i]})}function ns(t,e){this._pairs=[],t&&gn(t,this,e)}const vo=ns.prototype;vo.append=function(e,s){this._pairs.push([e,s])};vo.toString=function(e){const s=e?function(i){return e.call(this,i,ys)}:ys;return this._pairs.map(function(n){return s(n[0])+"="+s(n[1])},"").join("&")};function sr(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function wo(t,e,s){if(!e)return t;const i=s&&s.encode||sr,n=s&&s.serialize;let o;if(n?o=n(e,s):o=b.isURLSearchParams(e)?e.toString():new ns(e,s).toString(i),o){const a=t.indexOf("#");a!==-1&&(t=t.slice(0,a)),t+=(t.indexOf("?")===-1?"?":"&")+o}return t}class or{constructor(){this.handlers=[]}use(e,s,i){return this.handlers.push({fulfilled:e,rejected:s,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){b.forEach(this.handlers,function(i){i!==null&&e(i)})}}var bs=or,xo={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ir=typeof URLSearchParams!="undefined"?URLSearchParams:ns,rr=typeof FormData!="undefined"?FormData:null,ar=typeof Blob!="undefined"?Blob:null,lr={isBrowser:!0,classes:{URLSearchParams:ir,FormData:rr,Blob:ar},protocols:["http","https","file","blob","url","data"]};const ss=typeof window!="undefined"&&typeof document!="undefined",cr=(t=>ss&&["ReactNative","NativeScript","NS"].indexOf(t)<0)(typeof navigator!="undefined"&&navigator.product),dr=(()=>typeof WorkerGlobalScope!="undefined"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),ur=ss&&window.location.href||"http://localhost";var hr=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ss,hasStandardBrowserWebWorkerEnv:dr,hasStandardBrowserEnv:cr,origin:ur},Symbol.toStringTag,{value:"Module"})),Ae={...hr,...lr};function mr(t,e){return gn(t,new Ae.classes.URLSearchParams,Object.assign({visitor:function(s,i,n,o){return Ae.isNode&&b.isBuffer(s)?(this.append(i,s.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},e))}function fr(t){return b.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function pr(t){const e={},s=Object.keys(t);let i;const n=s.length;let o;for(i=0;i<n;i++)o=s[i],e[o]=t[o];return e}function Eo(t){function e(s,i,n,o){let a=s[o++];if(a==="__proto__")return!0;const l=Number.isFinite(+a),f=o>=s.length;return a=!a&&b.isArray(n)?n.length:a,f?(b.hasOwnProp(n,a)?n[a]=[n[a],i]:n[a]=i,!l):((!n[a]||!b.isObject(n[a]))&&(n[a]=[]),e(s,i,n[a],o)&&b.isArray(n[a])&&(n[a]=pr(n[a])),!l)}if(b.isFormData(t)&&b.isFunction(t.entries)){const s={};return b.forEachEntry(t,(i,n)=>{e(fr(i),n,s,0)}),s}return null}function _r(t,e,s){if(b.isString(t))try{return(e||JSON.parse)(t),b.trim(t)}catch(i){if(i.name!=="SyntaxError")throw i}return(s||JSON.stringify)(t)}const os={transitional:xo,adapter:["xhr","http","fetch"],transformRequest:[function(e,s){const i=s.getContentType()||"",n=i.indexOf("application/json")>-1,o=b.isObject(e);if(o&&b.isHTMLForm(e)&&(e=new FormData(e)),b.isFormData(e))return n?JSON.stringify(Eo(e)):e;if(b.isArrayBuffer(e)||b.isBuffer(e)||b.isStream(e)||b.isFile(e)||b.isBlob(e)||b.isReadableStream(e))return e;if(b.isArrayBufferView(e))return e.buffer;if(b.isURLSearchParams(e))return s.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let l;if(o){if(i.indexOf("application/x-www-form-urlencoded")>-1)return mr(e,this.formSerializer).toString();if((l=b.isFileList(e))||i.indexOf("multipart/form-data")>-1){const f=this.env&&this.env.FormData;return gn(l?{"files[]":e}:e,f&&new f,this.formSerializer)}}return o||n?(s.setContentType("application/json",!1),_r(e)):e}],transformResponse:[function(e){const s=this.transitional||os.transitional,i=s&&s.forcedJSONParsing,n=this.responseType==="json";if(b.isResponse(e)||b.isReadableStream(e))return e;if(e&&b.isString(e)&&(i&&!this.responseType||n)){const a=!(s&&s.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(l){if(a)throw l.name==="SyntaxError"?V.from(l,V.ERR_BAD_RESPONSE,this,null,this.response):l}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ae.classes.FormData,Blob:Ae.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};b.forEach(["delete","get","head","post","put","patch"],t=>{os.headers[t]={}});var is=os;const gr=b.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);var yr=t=>{const e={};let s,i,n;return t&&t.split(`
    22`).forEach(function(a){n=a.indexOf(":"),s=a.substring(0,n).trim().toLowerCase(),i=a.substring(n+1).trim(),!(!s||e[s]&&gr[s])&&(s==="set-cookie"?e[s]?e[s].push(i):e[s]=[i]:e[s]=e[s]?e[s]+", "+i:i)}),e};const vs=Symbol("internals");function bt(t){return t&&String(t).trim().toLowerCase()}function Gt(t){return t===!1||t==null?t:b.isArray(t)?t.map(Gt):String(t)}function br(t){const e=Object.create(null),s=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let i;for(;i=s.exec(t);)e[i[1]]=i[2];return e}const vr=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function In(t,e,s,i,n){if(b.isFunction(i))return i.call(this,e,s);if(n&&(e=s),!!b.isString(e)){if(b.isString(i))return e.indexOf(i)!==-1;if(b.isRegExp(i))return i.test(e)}}function wr(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,s,i)=>s.toUpperCase()+i)}function xr(t,e){const s=b.toCamelCase(" "+e);["get","set","has"].forEach(i=>{Object.defineProperty(t,i+s,{value:function(n,o,a){return this[i].call(this,e,n,o,a)},configurable:!0})})}class yn{constructor(e){e&&this.set(e)}set(e,s,i){const n=this;function o(l,f,d){const m=bt(f);if(!m)throw new Error("header name must be a non-empty string");const p=b.findKey(n,m);(!p||n[p]===void 0||d===!0||d===void 0&&n[p]!==!1)&&(n[p||f]=Gt(l))}const a=(l,f)=>b.forEach(l,(d,m)=>o(d,m,f));if(b.isPlainObject(e)||e instanceof this.constructor)a(e,s);else if(b.isString(e)&&(e=e.trim())&&!vr(e))a(yr(e),s);else if(b.isHeaders(e))for(const[l,f]of e.entries())o(f,l,i);else e!=null&&o(s,e,i);return this}get(e,s){if(e=bt(e),e){const i=b.findKey(this,e);if(i){const n=this[i];if(!s)return n;if(s===!0)return br(n);if(b.isFunction(s))return s.call(this,n,i);if(b.isRegExp(s))return s.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,s){if(e=bt(e),e){const i=b.findKey(this,e);return!!(i&&this[i]!==void 0&&(!s||In(this,this[i],i,s)))}return!1}delete(e,s){const i=this;let n=!1;function o(a){if(a=bt(a),a){const l=b.findKey(i,a);l&&(!s||In(i,i[l],l,s))&&(delete i[l],n=!0)}}return b.isArray(e)?e.forEach(o):o(e),n}clear(e){const s=Object.keys(this);let i=s.length,n=!1;for(;i--;){const o=s[i];(!e||In(this,this[o],o,e,!0))&&(delete this[o],n=!0)}return n}normalize(e){const s=this,i={};return b.forEach(this,(n,o)=>{const a=b.findKey(i,o);if(a){s[a]=Gt(n),delete s[o];return}const l=e?wr(o):String(o).trim();l!==o&&delete s[o],s[l]=Gt(n),i[l]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const s=Object.create(null);return b.forEach(this,(i,n)=>{i!=null&&i!==!1&&(s[n]=e&&b.isArray(i)?i.join(", "):i)}),s}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,s])=>e+": "+s).join(`
    3 `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...s){const i=new this(e);return s.forEach(n=>i.set(n)),i}static accessor(e){const i=(this[vs]=this[vs]={accessors:{}}).accessors,n=this.prototype;function o(a){const l=bt(a);i[l]||(xr(n,a),i[l]=!0)}return b.isArray(e)?e.forEach(o):o(e),this}}yn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);b.reduceDescriptors(yn.prototype,({value:t},e)=>{let s=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(i){this[s]=i}}});b.freezeMethods(yn);var Se=yn;function kn(t,e){const s=this||is,i=e||s,n=Se.from(i.headers);let o=i.data;return b.forEach(t,function(l){o=l.call(s,o,n.normalize(),e?e.status:void 0)}),n.normalize(),o}function Co(t){return!!(t&&t.__CANCEL__)}function pt(t,e,s){V.call(this,t==null?"canceled":t,V.ERR_CANCELED,e,s),this.name="CanceledError"}b.inherits(pt,V,{__CANCEL__:!0});function To(t,e,s){const i=s.config.validateStatus;!s.status||!i||i(s.status)?t(s):e(new V("Request failed with status code "+s.status,[V.ERR_BAD_REQUEST,V.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s))}function Er(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function Cr(t,e){t=t||10;const s=new Array(t),i=new Array(t);let n=0,o=0,a;return e=e!==void 0?e:1e3,function(f){const d=Date.now(),m=i[o];a||(a=d),s[n]=f,i[n]=d;let p=o,y=0;for(;p!==n;)y+=s[p++],p=p%t;if(n=(n+1)%t,n===o&&(o=(o+1)%t),d-a<e)return;const _=m&&d-m;return _?Math.round(y*1e3/_):void 0}}function Tr(t,e){let s=0;const i=1e3/e;let n=null;return function(){const a=this===!0,l=Date.now();if(a||l-s>i)return n&&(clearTimeout(n),n=null),s=l,t.apply(null,arguments);n||(n=setTimeout(()=>(n=null,s=Date.now(),t.apply(null,arguments)),i-(l-s)))}}var tn=(t,e,s=3)=>{let i=0;const n=Cr(50,250);return Tr(o=>{const a=o.loaded,l=o.lengthComputable?o.total:void 0,f=a-i,d=n(f),m=a<=l;i=a;const p={loaded:a,total:l,progress:l?a/l:void 0,bytes:f,rate:d||void 0,estimated:d&&l&&m?(l-a)/d:void 0,event:o,lengthComputable:l!=null};p[e?"download":"upload"]=!0,t(p)},s)},Ir=Ae.hasStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),s=document.createElement("a");let i;function n(o){let a=o;return e&&(s.setAttribute("href",a),a=s.href),s.setAttribute("href",a),{href:s.href,protocol:s.protocol?s.protocol.replace(/:$/,""):"",host:s.host,search:s.search?s.search.replace(/^\?/,""):"",hash:s.hash?s.hash.replace(/^#/,""):"",hostname:s.hostname,port:s.port,pathname:s.pathname.charAt(0)==="/"?s.pathname:"/"+s.pathname}}return i=n(window.location.href),function(a){const l=b.isString(a)?n(a):a;return l.protocol===i.protocol&&l.host===i.host}}():function(){return function(){return!0}}(),kr=Ae.hasStandardBrowserEnv?{write(t,e,s,i,n,o){const a=[t+"="+encodeURIComponent(e)];b.isNumber(s)&&a.push("expires="+new Date(s).toGMTString()),b.isString(i)&&a.push("path="+i),b.isString(n)&&a.push("domain="+n),o===!0&&a.push("secure"),document.cookie=a.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Ar(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function Sr(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function Io(t,e){return t&&!Ar(e)?Sr(t,e):e}const ws=t=>t instanceof Se?{...t}:t;function nt(t,e){e=e||{};const s={};function i(d,m,p){return b.isPlainObject(d)&&b.isPlainObject(m)?b.merge.call({caseless:p},d,m):b.isPlainObject(m)?b.merge({},m):b.isArray(m)?m.slice():m}function n(d,m,p){if(b.isUndefined(m)){if(!b.isUndefined(d))return i(void 0,d,p)}else return i(d,m,p)}function o(d,m){if(!b.isUndefined(m))return i(void 0,m)}function a(d,m){if(b.isUndefined(m)){if(!b.isUndefined(d))return i(void 0,d)}else return i(void 0,m)}function l(d,m,p){if(p in e)return i(d,m);if(p in t)return i(void 0,d)}const f={url:o,method:o,data:o,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:l,headers:(d,m)=>n(ws(d),ws(m),!0)};return b.forEach(Object.keys(Object.assign({},t,e)),function(m){const p=f[m]||n,y=p(t[m],e[m],m);b.isUndefined(y)&&p!==l||(s[m]=y)}),s}var ko=t=>{const e=nt({},t);let{data:s,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:o,headers:a,auth:l}=e;e.headers=a=Se.from(a),e.url=wo(Io(e.baseURL,e.url),t.params,t.paramsSerializer),l&&a.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let f;if(b.isFormData(s)){if(Ae.hasStandardBrowserEnv||Ae.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if((f=a.getContentType())!==!1){const[d,...m]=f?f.split(";").map(p=>p.trim()).filter(Boolean):[];a.setContentType([d||"multipart/form-data",...m].join("; "))}}if(Ae.hasStandardBrowserEnv&&(i&&b.isFunction(i)&&(i=i(e)),i||i!==!1&&Ir(e.url))){const d=n&&o&&kr.read(o);d&&a.set(n,d)}return e};const Dr=typeof XMLHttpRequest!="undefined";var Pr=Dr&&function(t){return new Promise(function(s,i){const n=ko(t);let o=n.data;const a=Se.from(n.headers).normalize();let{responseType:l}=n,f;function d(){n.cancelToken&&n.cancelToken.unsubscribe(f),n.signal&&n.signal.removeEventListener("abort",f)}let m=new XMLHttpRequest;m.open(n.method.toUpperCase(),n.url,!0),m.timeout=n.timeout;function p(){if(!m)return;const _=Se.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),x={data:!l||l==="text"||l==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:_,config:t,request:m};To(function(q){s(q),d()},function(q){i(q),d()},x),m=null}"onloadend"in m?m.onloadend=p:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(p)},m.onabort=function(){!m||(i(new V("Request aborted",V.ECONNABORTED,n,m)),m=null)},m.onerror=function(){i(new V("Network Error",V.ERR_NETWORK,n,m)),m=null},m.ontimeout=function(){let v=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const x=n.transitional||xo;n.timeoutErrorMessage&&(v=n.timeoutErrorMessage),i(new V(v,x.clarifyTimeoutError?V.ETIMEDOUT:V.ECONNABORTED,n,m)),m=null},o===void 0&&a.setContentType(null),"setRequestHeader"in m&&b.forEach(a.toJSON(),function(v,x){m.setRequestHeader(x,v)}),b.isUndefined(n.withCredentials)||(m.withCredentials=!!n.withCredentials),l&&l!=="json"&&(m.responseType=n.responseType),typeof n.onDownloadProgress=="function"&&m.addEventListener("progress",tn(n.onDownloadProgress,!0)),typeof n.onUploadProgress=="function"&&m.upload&&m.upload.addEventListener("progress",tn(n.onUploadProgress)),(n.cancelToken||n.signal)&&(f=_=>{!m||(i(!_||_.type?new pt(null,t,m):_),m.abort(),m=null)},n.cancelToken&&n.cancelToken.subscribe(f),n.signal&&(n.signal.aborted?f():n.signal.addEventListener("abort",f)));const y=Er(n.url);if(y&&Ae.protocols.indexOf(y)===-1){i(new V("Unsupported protocol "+y+":",V.ERR_BAD_REQUEST,t));return}m.send(o||null)})};const jr=(t,e)=>{let s=new AbortController,i;const n=function(f){if(!i){i=!0,a();const d=f instanceof Error?f:this.reason;s.abort(d instanceof V?d:new pt(d instanceof Error?d.message:d))}};let o=e&&setTimeout(()=>{n(new V(`timeout ${e} of ms exceeded`,V.ETIMEDOUT))},e);const a=()=>{t&&(o&&clearTimeout(o),o=null,t.forEach(f=>{f&&(f.removeEventListener?f.removeEventListener("abort",n):f.unsubscribe(n))}),t=null)};t.forEach(f=>f&&f.addEventListener&&f.addEventListener("abort",n));const{signal:l}=s;return l.unsubscribe=a,[l,()=>{o&&clearTimeout(o),o=null}]};var Rr=jr;const Mr=function*(t,e){let s=t.byteLength;if(!e||s<e){yield t;return}let i=0,n;for(;i<s;)n=i+e,yield t.slice(i,n),i=n},Or=async function*(t,e,s){for await(const i of t)yield*Mr(ArrayBuffer.isView(i)?i:await s(String(i)),e)},xs=(t,e,s,i,n)=>{const o=Or(t,e,n);let a=0;return new ReadableStream({type:"bytes",async pull(l){const{done:f,value:d}=await o.next();if(f){l.close(),i();return}let m=d.byteLength;s&&s(a+=m),l.enqueue(new Uint8Array(d))},cancel(l){return i(l),o.return()}},{highWaterMark:2})},Es=(t,e)=>{const s=t!=null;return i=>setTimeout(()=>e({lengthComputable:s,total:t,loaded:i}))},bn=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Ao=bn&&typeof ReadableStream=="function",Wn=bn&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),qr=Ao&&(()=>{let t=!1;const e=new Request(Ae.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e})(),Cs=64*1024,Xn=Ao&&!!(()=>{try{return b.isReadableStream(new Response("").body)}catch{}})(),nn={stream:Xn&&(t=>t.body)};bn&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!nn[e]&&(nn[e]=b.isFunction(t[e])?s=>s[e]():(s,i)=>{throw new V(`Response type '${e}' is not supported`,V.ERR_NOT_SUPPORT,i)})})})(new Response);const Nr=async t=>{if(t==null)return 0;if(b.isBlob(t))return t.size;if(b.isSpecCompliantForm(t))return(await new Request(t).arrayBuffer()).byteLength;if(b.isArrayBufferView(t))return t.byteLength;if(b.isURLSearchParams(t)&&(t=t+""),b.isString(t))return(await Wn(t)).byteLength},Br=async(t,e)=>{const s=b.toFiniteNumber(t.getContentLength());return s==null?Nr(e):s};var Vr=bn&&(async t=>{let{url:e,method:s,data:i,signal:n,cancelToken:o,timeout:a,onDownloadProgress:l,onUploadProgress:f,responseType:d,headers:m,withCredentials:p="same-origin",fetchOptions:y}=ko(t);d=d?(d+"").toLowerCase():"text";let[_,v]=n||o||a?Rr([n,o],a):[],x,j;const q=()=>{!x&&setTimeout(()=>{_&&_.unsubscribe()}),x=!0};let S;try{if(f&&qr&&s!=="get"&&s!=="head"&&(S=await Br(m,i))!==0){let Y=new Request(e,{method:"POST",body:i,duplex:"half"}),K;b.isFormData(i)&&(K=Y.headers.get("content-type"))&&m.setContentType(K),Y.body&&(i=xs(Y.body,Cs,Es(S,tn(f)),null,Wn))}b.isString(p)||(p=p?"cors":"omit"),j=new Request(e,{...y,signal:_,method:s.toUpperCase(),headers:m.normalize().toJSON(),body:i,duplex:"half",withCredentials:p});let k=await fetch(j);const Q=Xn&&(d==="stream"||d==="response");if(Xn&&(l||Q)){const Y={};["status","statusText","headers"].forEach(je=>{Y[je]=k[je]});const K=b.toFiniteNumber(k.headers.get("content-length"));k=new Response(xs(k.body,Cs,l&&Es(K,tn(l,!0)),Q&&q,Wn),Y)}d=d||"text";let le=await nn[b.findKey(nn,d)||"text"](k,t);return!Q&&q(),v&&v(),await new Promise((Y,K)=>{To(Y,K,{data:le,headers:Se.from(k.headers),status:k.status,statusText:k.statusText,config:t,request:j})})}catch(k){throw q(),k&&k.name==="TypeError"&&/fetch/i.test(k.message)?Object.assign(new V("Network Error",V.ERR_NETWORK,t,j),{cause:k.cause||k}):V.from(k,k&&k.code,t,j)}});const Hn={http:er,xhr:Pr,fetch:Vr};b.forEach(Hn,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const Ts=t=>`- ${t}`,Fr=t=>b.isFunction(t)||t===null||t===!1;var So={getAdapter:t=>{t=b.isArray(t)?t:[t];const{length:e}=t;let s,i;const n={};for(let o=0;o<e;o++){s=t[o];let a;if(i=s,!Fr(s)&&(i=Hn[(a=String(s)).toLowerCase()],i===void 0))throw new V(`Unknown adapter '${a}'`);if(i)break;n[a||"#"+o]=i}if(!i){const o=Object.entries(n).map(([l,f])=>`adapter ${l} `+(f===!1?"is not supported by the environment":"is not available in the build"));let a=e?o.length>1?`since :
     3`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...s){const i=new this(e);return s.forEach(n=>i.set(n)),i}static accessor(e){const i=(this[vs]=this[vs]={accessors:{}}).accessors,n=this.prototype;function o(a){const l=bt(a);i[l]||(xr(n,a),i[l]=!0)}return b.isArray(e)?e.forEach(o):o(e),this}}yn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);b.reduceDescriptors(yn.prototype,({value:t},e)=>{let s=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(i){this[s]=i}}});b.freezeMethods(yn);var Se=yn;function kn(t,e){const s=this||is,i=e||s,n=Se.from(i.headers);let o=i.data;return b.forEach(t,function(l){o=l.call(s,o,n.normalize(),e?e.status:void 0)}),n.normalize(),o}function Co(t){return!!(t&&t.__CANCEL__)}function pt(t,e,s){V.call(this,t==null?"canceled":t,V.ERR_CANCELED,e,s),this.name="CanceledError"}b.inherits(pt,V,{__CANCEL__:!0});function To(t,e,s){const i=s.config.validateStatus;!s.status||!i||i(s.status)?t(s):e(new V("Request failed with status code "+s.status,[V.ERR_BAD_REQUEST,V.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s))}function Er(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function Cr(t,e){t=t||10;const s=new Array(t),i=new Array(t);let n=0,o=0,a;return e=e!==void 0?e:1e3,function(f){const d=Date.now(),m=i[o];a||(a=d),s[n]=f,i[n]=d;let p=o,y=0;for(;p!==n;)y+=s[p++],p=p%t;if(n=(n+1)%t,n===o&&(o=(o+1)%t),d-a<e)return;const _=m&&d-m;return _?Math.round(y*1e3/_):void 0}}function Tr(t,e){let s=0;const i=1e3/e;let n=null;return function(){const a=this===!0,l=Date.now();if(a||l-s>i)return n&&(clearTimeout(n),n=null),s=l,t.apply(null,arguments);n||(n=setTimeout(()=>(n=null,s=Date.now(),t.apply(null,arguments)),i-(l-s)))}}var tn=(t,e,s=3)=>{let i=0;const n=Cr(50,250);return Tr(o=>{const a=o.loaded,l=o.lengthComputable?o.total:void 0,f=a-i,d=n(f),m=a<=l;i=a;const p={loaded:a,total:l,progress:l?a/l:void 0,bytes:f,rate:d||void 0,estimated:d&&l&&m?(l-a)/d:void 0,event:o,lengthComputable:l!=null};p[e?"download":"upload"]=!0,t(p)},s)},Ir=Ae.hasStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),s=document.createElement("a");let i;function n(o){let a=o;return e&&(s.setAttribute("href",a),a=s.href),s.setAttribute("href",a),{href:s.href,protocol:s.protocol?s.protocol.replace(/:$/,""):"",host:s.host,search:s.search?s.search.replace(/^\?/,""):"",hash:s.hash?s.hash.replace(/^#/,""):"",hostname:s.hostname,port:s.port,pathname:s.pathname.charAt(0)==="/"?s.pathname:"/"+s.pathname}}return i=n(window.location.href),function(a){const l=b.isString(a)?n(a):a;return l.protocol===i.protocol&&l.host===i.host}}():function(){return function(){return!0}}(),kr=Ae.hasStandardBrowserEnv?{write(t,e,s,i,n,o){const a=[t+"="+encodeURIComponent(e)];b.isNumber(s)&&a.push("expires="+new Date(s).toGMTString()),b.isString(i)&&a.push("path="+i),b.isString(n)&&a.push("domain="+n),o===!0&&a.push("secure"),document.cookie=a.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Ar(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function Sr(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function Io(t,e){return t&&!Ar(e)?Sr(t,e):e}const ws=t=>t instanceof Se?{...t}:t;function nt(t,e){e=e||{};const s={};function i(d,m,p){return b.isPlainObject(d)&&b.isPlainObject(m)?b.merge.call({caseless:p},d,m):b.isPlainObject(m)?b.merge({},m):b.isArray(m)?m.slice():m}function n(d,m,p){if(b.isUndefined(m)){if(!b.isUndefined(d))return i(void 0,d,p)}else return i(d,m,p)}function o(d,m){if(!b.isUndefined(m))return i(void 0,m)}function a(d,m){if(b.isUndefined(m)){if(!b.isUndefined(d))return i(void 0,d)}else return i(void 0,m)}function l(d,m,p){if(p in e)return i(d,m);if(p in t)return i(void 0,d)}const f={url:o,method:o,data:o,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:l,headers:(d,m)=>n(ws(d),ws(m),!0)};return b.forEach(Object.keys(Object.assign({},t,e)),function(m){const p=f[m]||n,y=p(t[m],e[m],m);b.isUndefined(y)&&p!==l||(s[m]=y)}),s}var ko=t=>{const e=nt({},t);let{data:s,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:o,headers:a,auth:l}=e;e.headers=a=Se.from(a),e.url=wo(Io(e.baseURL,e.url),t.params,t.paramsSerializer),l&&a.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let f;if(b.isFormData(s)){if(Ae.hasStandardBrowserEnv||Ae.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if((f=a.getContentType())!==!1){const[d,...m]=f?f.split(";").map(p=>p.trim()).filter(Boolean):[];a.setContentType([d||"multipart/form-data",...m].join("; "))}}if(Ae.hasStandardBrowserEnv&&(i&&b.isFunction(i)&&(i=i(e)),i||i!==!1&&Ir(e.url))){const d=n&&o&&kr.read(o);d&&a.set(n,d)}return e};const Dr=typeof XMLHttpRequest!="undefined";var Pr=Dr&&function(t){return new Promise(function(s,i){const n=ko(t);let o=n.data;const a=Se.from(n.headers).normalize();let{responseType:l}=n,f;function d(){n.cancelToken&&n.cancelToken.unsubscribe(f),n.signal&&n.signal.removeEventListener("abort",f)}let m=new XMLHttpRequest;m.open(n.method.toUpperCase(),n.url,!0),m.timeout=n.timeout;function p(){if(!m)return;const _=Se.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),x={data:!l||l==="text"||l==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:_,config:t,request:m};To(function(q){s(q),d()},function(q){i(q),d()},x),m=null}"onloadend"in m?m.onloadend=p:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(p)},m.onabort=function(){!m||(i(new V("Request aborted",V.ECONNABORTED,n,m)),m=null)},m.onerror=function(){i(new V("Network Error",V.ERR_NETWORK,n,m)),m=null},m.ontimeout=function(){let v=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const x=n.transitional||xo;n.timeoutErrorMessage&&(v=n.timeoutErrorMessage),i(new V(v,x.clarifyTimeoutError?V.ETIMEDOUT:V.ECONNABORTED,n,m)),m=null},o===void 0&&a.setContentType(null),"setRequestHeader"in m&&b.forEach(a.toJSON(),function(v,x){m.setRequestHeader(x,v)}),b.isUndefined(n.withCredentials)||(m.withCredentials=!!n.withCredentials),l&&l!=="json"&&(m.responseType=n.responseType),typeof n.onDownloadProgress=="function"&&m.addEventListener("progress",tn(n.onDownloadProgress,!0)),typeof n.onUploadProgress=="function"&&m.upload&&m.upload.addEventListener("progress",tn(n.onUploadProgress)),(n.cancelToken||n.signal)&&(f=_=>{!m||(i(!_||_.type?new pt(null,t,m):_),m.abort(),m=null)},n.cancelToken&&n.cancelToken.subscribe(f),n.signal&&(n.signal.aborted?f():n.signal.addEventListener("abort",f)));const y=Er(n.url);if(y&&Ae.protocols.indexOf(y)===-1){i(new V("Unsupported protocol "+y+":",V.ERR_BAD_REQUEST,t));return}m.send(o||null)})};const Rr=(t,e)=>{let s=new AbortController,i;const n=function(f){if(!i){i=!0,a();const d=f instanceof Error?f:this.reason;s.abort(d instanceof V?d:new pt(d instanceof Error?d.message:d))}};let o=e&&setTimeout(()=>{n(new V(`timeout ${e} of ms exceeded`,V.ETIMEDOUT))},e);const a=()=>{t&&(o&&clearTimeout(o),o=null,t.forEach(f=>{f&&(f.removeEventListener?f.removeEventListener("abort",n):f.unsubscribe(n))}),t=null)};t.forEach(f=>f&&f.addEventListener&&f.addEventListener("abort",n));const{signal:l}=s;return l.unsubscribe=a,[l,()=>{o&&clearTimeout(o),o=null}]};var jr=Rr;const Mr=function*(t,e){let s=t.byteLength;if(!e||s<e){yield t;return}let i=0,n;for(;i<s;)n=i+e,yield t.slice(i,n),i=n},Or=async function*(t,e,s){for await(const i of t)yield*Mr(ArrayBuffer.isView(i)?i:await s(String(i)),e)},xs=(t,e,s,i,n)=>{const o=Or(t,e,n);let a=0;return new ReadableStream({type:"bytes",async pull(l){const{done:f,value:d}=await o.next();if(f){l.close(),i();return}let m=d.byteLength;s&&s(a+=m),l.enqueue(new Uint8Array(d))},cancel(l){return i(l),o.return()}},{highWaterMark:2})},Es=(t,e)=>{const s=t!=null;return i=>setTimeout(()=>e({lengthComputable:s,total:t,loaded:i}))},bn=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Ao=bn&&typeof ReadableStream=="function",Wn=bn&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),qr=Ao&&(()=>{let t=!1;const e=new Request(Ae.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e})(),Cs=64*1024,Xn=Ao&&!!(()=>{try{return b.isReadableStream(new Response("").body)}catch{}})(),nn={stream:Xn&&(t=>t.body)};bn&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!nn[e]&&(nn[e]=b.isFunction(t[e])?s=>s[e]():(s,i)=>{throw new V(`Response type '${e}' is not supported`,V.ERR_NOT_SUPPORT,i)})})})(new Response);const Nr=async t=>{if(t==null)return 0;if(b.isBlob(t))return t.size;if(b.isSpecCompliantForm(t))return(await new Request(t).arrayBuffer()).byteLength;if(b.isArrayBufferView(t))return t.byteLength;if(b.isURLSearchParams(t)&&(t=t+""),b.isString(t))return(await Wn(t)).byteLength},Br=async(t,e)=>{const s=b.toFiniteNumber(t.getContentLength());return s==null?Nr(e):s};var Vr=bn&&(async t=>{let{url:e,method:s,data:i,signal:n,cancelToken:o,timeout:a,onDownloadProgress:l,onUploadProgress:f,responseType:d,headers:m,withCredentials:p="same-origin",fetchOptions:y}=ko(t);d=d?(d+"").toLowerCase():"text";let[_,v]=n||o||a?jr([n,o],a):[],x,R;const q=()=>{!x&&setTimeout(()=>{_&&_.unsubscribe()}),x=!0};let S;try{if(f&&qr&&s!=="get"&&s!=="head"&&(S=await Br(m,i))!==0){let Y=new Request(e,{method:"POST",body:i,duplex:"half"}),K;b.isFormData(i)&&(K=Y.headers.get("content-type"))&&m.setContentType(K),Y.body&&(i=xs(Y.body,Cs,Es(S,tn(f)),null,Wn))}b.isString(p)||(p=p?"cors":"omit"),R=new Request(e,{...y,signal:_,method:s.toUpperCase(),headers:m.normalize().toJSON(),body:i,duplex:"half",withCredentials:p});let k=await fetch(R);const z=Xn&&(d==="stream"||d==="response");if(Xn&&(l||z)){const Y={};["status","statusText","headers"].forEach(Re=>{Y[Re]=k[Re]});const K=b.toFiniteNumber(k.headers.get("content-length"));k=new Response(xs(k.body,Cs,l&&Es(K,tn(l,!0)),z&&q,Wn),Y)}d=d||"text";let le=await nn[b.findKey(nn,d)||"text"](k,t);return!z&&q(),v&&v(),await new Promise((Y,K)=>{To(Y,K,{data:le,headers:Se.from(k.headers),status:k.status,statusText:k.statusText,config:t,request:R})})}catch(k){throw q(),k&&k.name==="TypeError"&&/fetch/i.test(k.message)?Object.assign(new V("Network Error",V.ERR_NETWORK,t,R),{cause:k.cause||k}):V.from(k,k&&k.code,t,R)}});const Hn={http:er,xhr:Pr,fetch:Vr};b.forEach(Hn,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const Ts=t=>`- ${t}`,Fr=t=>b.isFunction(t)||t===null||t===!1;var So={getAdapter:t=>{t=b.isArray(t)?t:[t];const{length:e}=t;let s,i;const n={};for(let o=0;o<e;o++){s=t[o];let a;if(i=s,!Fr(s)&&(i=Hn[(a=String(s)).toLowerCase()],i===void 0))throw new V(`Unknown adapter '${a}'`);if(i)break;n[a||"#"+o]=i}if(!i){const o=Object.entries(n).map(([l,f])=>`adapter ${l} `+(f===!1?"is not supported by the environment":"is not available in the build"));let a=e?o.length>1?`since :
    44`+o.map(Ts).join(`
    5 `):" "+Ts(o[0]):"as no adapter specified";throw new V("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return i},adapters:Hn};function An(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new pt(null,t)}function Is(t){return An(t),t.headers=Se.from(t.headers),t.data=kn.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),So.getAdapter(t.adapter||is.adapter)(t).then(function(i){return An(t),i.data=kn.call(t,t.transformResponse,i),i.headers=Se.from(i.headers),i},function(i){return Co(i)||(An(t),i&&i.response&&(i.response.data=kn.call(t,t.transformResponse,i.response),i.response.headers=Se.from(i.response.headers))),Promise.reject(i)})}const Do="1.7.2",rs={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{rs[t]=function(i){return typeof i===t||"a"+(e<1?"n ":" ")+t}});const ks={};rs.transitional=function(e,s,i){function n(o,a){return"[Axios v"+Do+"] Transitional option '"+o+"'"+a+(i?". "+i:"")}return(o,a,l)=>{if(e===!1)throw new V(n(a," has been removed"+(s?" in "+s:"")),V.ERR_DEPRECATED);return s&&!ks[a]&&(ks[a]=!0,console.warn(n(a," has been deprecated since v"+s+" and will be removed in the near future"))),e?e(o,a,l):!0}};function Ur(t,e,s){if(typeof t!="object")throw new V("options must be an object",V.ERR_BAD_OPTION_VALUE);const i=Object.keys(t);let n=i.length;for(;n-- >0;){const o=i[n],a=e[o];if(a){const l=t[o],f=l===void 0||a(l,o,t);if(f!==!0)throw new V("option "+o+" must be "+f,V.ERR_BAD_OPTION_VALUE);continue}if(s!==!0)throw new V("Unknown option "+o,V.ERR_BAD_OPTION)}}var Qn={assertOptions:Ur,validators:rs};const Qe=Qn.validators;class sn{constructor(e){this.defaults=e,this.interceptors={request:new bs,response:new bs}}async request(e,s){try{return await this._request(e,s)}catch(i){if(i instanceof Error){let n;Error.captureStackTrace?Error.captureStackTrace(n={}):n=new Error;const o=n.stack?n.stack.replace(/^.+\n/,""):"";try{i.stack?o&&!String(i.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(i.stack+=`
    6 `+o):i.stack=o}catch{}}throw i}}_request(e,s){typeof e=="string"?(s=s||{},s.url=e):s=e||{},s=nt(this.defaults,s);const{transitional:i,paramsSerializer:n,headers:o}=s;i!==void 0&&Qn.assertOptions(i,{silentJSONParsing:Qe.transitional(Qe.boolean),forcedJSONParsing:Qe.transitional(Qe.boolean),clarifyTimeoutError:Qe.transitional(Qe.boolean)},!1),n!=null&&(b.isFunction(n)?s.paramsSerializer={serialize:n}:Qn.assertOptions(n,{encode:Qe.function,serialize:Qe.function},!0)),s.method=(s.method||this.defaults.method||"get").toLowerCase();let a=o&&b.merge(o.common,o[s.method]);o&&b.forEach(["delete","get","head","post","put","patch","common"],v=>{delete o[v]}),s.headers=Se.concat(a,o);const l=[];let f=!0;this.interceptors.request.forEach(function(x){typeof x.runWhen=="function"&&x.runWhen(s)===!1||(f=f&&x.synchronous,l.unshift(x.fulfilled,x.rejected))});const d=[];this.interceptors.response.forEach(function(x){d.push(x.fulfilled,x.rejected)});let m,p=0,y;if(!f){const v=[Is.bind(this),void 0];for(v.unshift.apply(v,l),v.push.apply(v,d),y=v.length,m=Promise.resolve(s);p<y;)m=m.then(v[p++],v[p++]);return m}y=l.length;let _=s;for(p=0;p<y;){const v=l[p++],x=l[p++];try{_=v(_)}catch(j){x.call(this,j);break}}try{m=Is.call(this,_)}catch(v){return Promise.reject(v)}for(p=0,y=d.length;p<y;)m=m.then(d[p++],d[p++]);return m}getUri(e){e=nt(this.defaults,e);const s=Io(e.baseURL,e.url);return wo(s,e.params,e.paramsSerializer)}}b.forEach(["delete","get","head","options"],function(e){sn.prototype[e]=function(s,i){return this.request(nt(i||{},{method:e,url:s,data:(i||{}).data}))}});b.forEach(["post","put","patch"],function(e){function s(i){return function(o,a,l){return this.request(nt(l||{},{method:e,headers:i?{"Content-Type":"multipart/form-data"}:{},url:o,data:a}))}}sn.prototype[e]=s(),sn.prototype[e+"Form"]=s(!0)});var Jt=sn;class as{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let s;this.promise=new Promise(function(o){s=o});const i=this;this.promise.then(n=>{if(!i._listeners)return;let o=i._listeners.length;for(;o-- >0;)i._listeners[o](n);i._listeners=null}),this.promise.then=n=>{let o;const a=new Promise(l=>{i.subscribe(l),o=l}).then(n);return a.cancel=function(){i.unsubscribe(o)},a},e(function(o,a,l){i.reason||(i.reason=new pt(o,a,l),s(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const s=this._listeners.indexOf(e);s!==-1&&this._listeners.splice(s,1)}static source(){let e;return{token:new as(function(n){e=n}),cancel:e}}}var Lr=as;function Wr(t){return function(s){return t.apply(null,s)}}function Xr(t){return b.isObject(t)&&t.isAxiosError===!0}const zn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(zn).forEach(([t,e])=>{zn[e]=t});var Hr=zn;function Po(t){const e=new Jt(t),s=lo(Jt.prototype.request,e);return b.extend(s,Jt.prototype,e,{allOwnKeys:!0}),b.extend(s,e,null,{allOwnKeys:!0}),s.create=function(n){return Po(nt(t,n))},s}const re=Po(is);re.Axios=Jt;re.CanceledError=pt;re.CancelToken=Lr;re.isCancel=Co;re.VERSION=Do;re.toFormData=gn;re.AxiosError=V;re.Cancel=re.CanceledError;re.all=function(e){return Promise.all(e)};re.spread=Wr;re.isAxiosError=Xr;re.mergeConfig=nt;re.AxiosHeaders=Se;re.formToJSON=t=>Eo(b.isHTMLForm(t)?new FormData(t):t);re.getAdapter=So.getAdapter;re.HttpStatusCode=Hr;re.default=re;var As=re;const Qr={data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{formData:{siret:"",company_name:"",siren_number:"",manager_name:"",address:"",city:"",postal_code:"",country:"",phone:"",mobile_phone:"",email:"",website:"",currency_id:"",note:"",user_create:""},fields:{company_name:{label:t.company_name,type:"text",required:!0},manager_name:{label:t.manager_name,type:"text"},address:{label:t.address,type:"text",required:!0},city:{label:t.city,type:"text",required:!0},postal_code:{label:t.postal_code,type:"text"},country:{label:t.country,type:"text"},phone:{label:t.phone,type:"tel",required:!0},mobile_phone:{label:t.mobile,type:"tel"},email:{label:t.email,type:"email",required:!0},website:{label:t.website,type:"url"},currency_id:{label:t.currency,type:"text",required:!0}},options:{currency_options:[],default_currency:"",addon_user_active:!1,addon_siret_active:!1},toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},loadingBtn:!1,loadingSiret:!1}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{submitForm(){this.loadingBtn=!0,As.post("/wp-json/my-easy-compta/v1/clients/add",this.formData,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>{t.data.success?(this.showToast(t.data.message,"alert-success"),this.loadingBtn=!1,this.resetForm(),this.closeModal(),this.$emit("clientAdded")):(this.showToast(t.data.message,"alert-error"),this.loadingBtn=!1)}).catch(t=>{const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Erreur serveur";console.error(t),this.showToast(e,"alert-error"),this.loadingBtn=!1})},closeModal(){document.getElementById("modal_clients").close()},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},resetForm(){for(let t in this.formData)this.formData[t]=""},getOptions(t){return t==="currency_id"?this.options.currency_options:[]},fetchOptions(){As.get("/wp-json/my-easy-compta/v1/options",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>{this.options.currency_options=t.data.currency_options,this.options.default_currency=t.data.default_currency,this.options.addon_user_active=t.data.addon_user_active,this.options.addon_siret_active=t.data.addon_siret_active}).catch(t=>{console.error("Erreur lors de la r\xE9cup\xE9ration des options",t)})},fetchCompanyInfo(t){t.preventDefault(),this.loadingSiret=!0;const e=this.formData.siret;e?fetch(`/wp-json/my-easy-compta/v1/fetch-company-info/${e}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>{if(!s.ok)throw new Error("Network response was not ok");return s.json()}).then(s=>{s?(this.formData.company_name=s.company_name,this.formData.manager_name=s.manager_name,this.formData.address=s.address,this.formData.postal_code=s.postal_code,this.formData.city=s.city,this.formData.siren_number=s.siren,this.showToast("Informations charg\xE9es avec succ\xE8s","alert-success"),this.loadingSiret=!1):(this.showToast("Aucune information trouv\xE9e pour ce SIRET","alert-error"),this.loadingSiret=!1)}).catch(s=>{console.error("Error fetching company info:",s),this.showToast("Erreur lors du chargement des informations","alert-error"),this.loadingSiret=!1}):(this.showToast("Veuillez saisir un num\xE9ro SIRET","alert-error"),this.loadingSiret=!1)}},mounted(){this.fetchOptions()}},zr={id:"modal_clients",class:"modal"},Gr={class:"modal-box"},Jr={class:"font-bold text-lg"},Yr={key:0,class:"grid grid-cols-1 gap-4"},Kr={class:"ecwp-group form-group relative join"},Zr={for:"siret",class:"ecwp-label form-label"},$r=["disabled"],ea={key:0,class:"loading loading-spinner loading-sm"},ta={key:1},na={class:"grid grid-cols-1 gap-4"},sa={class:"ecwp-group form-group relative"},oa={for:"siren",class:"ecwp-label form-label"},ia={class:"grid grid-cols-1 gap-4"},ra={class:"ecwp-group form-group relative"},aa={for:"tax_number",class:"ecwp-label form-label"},la={class:"grid grid-cols-2 gap-4"},ca=["for"],da=["id","onUpdate:modelValue","required"],ua=["value"],ha=["value"],ma=["type","id","onUpdate:modelValue","required"],fa={class:"ecwp-group form-group mt-4 relative"},pa=["for"],_a={key:1,class:"ecwp-group form-group mt-6 w-52 flex justify-between"},ga={class:"form-group mt-4 flex justify-end"},ya=["disabled"],ba={key:0,class:"loading loading-spinner loading-sm"};function va(t,e,s,i,n,o){return u(),h("div",null,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),r("dialog",zr,[r("div",Gr,[r("h3",Jr,c(o.translations.new_client),1),r("form",{onSubmit:e[7]||(e[7]=J((...a)=>o.submitForm&&o.submitForm(...a),["prevent"]))},[r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=a=>o.closeModal())}," \u2715 "),n.options.addon_siret_active?(u(),h("div",Yr,[r("div",Kr,[r("label",Zr,c(o.translations.siret),1),D(r("input",{type:"number",id:"siret","onUpdate:modelValue":e[1]||(e[1]=a=>n.formData.siret=a),class:"ecwp-input input input-bordered w-full"},null,512),[[W,n.formData.siret]]),r("button",{onClick:e[2]||(e[2]=(...a)=>o.fetchCompanyInfo&&o.fetchCompanyInfo(...a)),class:"btn join-item rounded-r-full mt-5",disabled:n.loadingSiret},[n.loadingSiret?(u(),h("span",ea)):(u(),h("span",ta,c(o.translations.search),1))],8,$r)])])):g("",!0),r("div",na,[r("div",sa,[r("label",oa,c(o.translations.siren),1),D(r("input",{type:"number",id:"siren","onUpdate:modelValue":e[3]||(e[3]=a=>n.formData.siren_number=a),class:"ecwp-input input input-bordered w-full"},null,512),[[W,n.formData.siren_number]])])]),r("div",ia,[r("div",ra,[r("label",aa,c(o.translations.tax_number),1),D(r("input",{type:"text",id:"tax_number","onUpdate:modelValue":e[4]||(e[4]=a=>n.formData.tax_number=a),class:"ecwp-input input input-bordered w-full"},null,512),[[W,n.formData.tax_number]])])]),r("div",la,[(u(!0),h(F,null,U(n.fields,(a,l)=>(u(),h("div",{key:l,class:"ecwp-group form-group relative"},[r("label",{for:l,class:"ecwp-label form-label"},c(a.label),9,ca),l==="currency_id"?D((u(),h("select",{key:0,id:l,"onUpdate:modelValue":f=>n.formData[l]=f,class:"ecwp-input input input-bordered w-full peer",required:a.required},[r("option",{value:n.options.default_currency},c(o.translations.default_currency),9,ua),(u(!0),h(F,null,U(o.getOptions(l),f=>(u(),h("option",{key:f.id,value:f.id},c(f.name)+" - "+c(f.code)+" ("+c(f.symbol)+") ",9,ha))),128))],8,da)),[[ue,n.formData[l]]]):D((u(),h("input",{key:1,type:a.type,id:l,"onUpdate:modelValue":f=>n.formData[l]=f,class:"ecwp-input input input-bordered w-full peer",placeholder:" ",required:a.required},null,8,ma)),[[li,n.formData[l]]])]))),128))]),r("div",fa,[r("label",{for:t.key,class:"ecwp-label form-label"},c(o.translations.note),9,pa),D(r("textarea",{id:"note","onUpdate:modelValue":e[5]||(e[5]=a=>n.formData.note=a),class:"ecwp-input textarea textarea-bordered w-full peer",rows:"4",placeholder:" "},null,512),[[W,n.formData.note]])]),n.options.addon_user_active?(u(),h("div",_a,[r("label",null,c(o.translations.create_user),1),D(r("input",{class:"ecwp-switch",type:"checkbox","onUpdate:modelValue":e[6]||(e[6]=a=>n.formData.user_create=a)},null,512),[[ai,n.formData.user_create]])])):g("",!0),r("div",ga,[r("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(c(o.translations.add)+" ",1),n.loadingBtn?(u(),h("span",ba)):g("",!0)],8,ya)])],32)])])])}var jo=ne(Qr,[["render",va]]);/*!
     5`):" "+Ts(o[0]):"as no adapter specified";throw new V("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return i},adapters:Hn};function An(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new pt(null,t)}function Is(t){return An(t),t.headers=Se.from(t.headers),t.data=kn.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),So.getAdapter(t.adapter||is.adapter)(t).then(function(i){return An(t),i.data=kn.call(t,t.transformResponse,i),i.headers=Se.from(i.headers),i},function(i){return Co(i)||(An(t),i&&i.response&&(i.response.data=kn.call(t,t.transformResponse,i.response),i.response.headers=Se.from(i.response.headers))),Promise.reject(i)})}const Do="1.7.2",rs={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{rs[t]=function(i){return typeof i===t||"a"+(e<1?"n ":" ")+t}});const ks={};rs.transitional=function(e,s,i){function n(o,a){return"[Axios v"+Do+"] Transitional option '"+o+"'"+a+(i?". "+i:"")}return(o,a,l)=>{if(e===!1)throw new V(n(a," has been removed"+(s?" in "+s:"")),V.ERR_DEPRECATED);return s&&!ks[a]&&(ks[a]=!0,console.warn(n(a," has been deprecated since v"+s+" and will be removed in the near future"))),e?e(o,a,l):!0}};function Ur(t,e,s){if(typeof t!="object")throw new V("options must be an object",V.ERR_BAD_OPTION_VALUE);const i=Object.keys(t);let n=i.length;for(;n-- >0;){const o=i[n],a=e[o];if(a){const l=t[o],f=l===void 0||a(l,o,t);if(f!==!0)throw new V("option "+o+" must be "+f,V.ERR_BAD_OPTION_VALUE);continue}if(s!==!0)throw new V("Unknown option "+o,V.ERR_BAD_OPTION)}}var zn={assertOptions:Ur,validators:rs};const ze=zn.validators;class sn{constructor(e){this.defaults=e,this.interceptors={request:new bs,response:new bs}}async request(e,s){try{return await this._request(e,s)}catch(i){if(i instanceof Error){let n;Error.captureStackTrace?Error.captureStackTrace(n={}):n=new Error;const o=n.stack?n.stack.replace(/^.+\n/,""):"";try{i.stack?o&&!String(i.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(i.stack+=`
     6`+o):i.stack=o}catch{}}throw i}}_request(e,s){typeof e=="string"?(s=s||{},s.url=e):s=e||{},s=nt(this.defaults,s);const{transitional:i,paramsSerializer:n,headers:o}=s;i!==void 0&&zn.assertOptions(i,{silentJSONParsing:ze.transitional(ze.boolean),forcedJSONParsing:ze.transitional(ze.boolean),clarifyTimeoutError:ze.transitional(ze.boolean)},!1),n!=null&&(b.isFunction(n)?s.paramsSerializer={serialize:n}:zn.assertOptions(n,{encode:ze.function,serialize:ze.function},!0)),s.method=(s.method||this.defaults.method||"get").toLowerCase();let a=o&&b.merge(o.common,o[s.method]);o&&b.forEach(["delete","get","head","post","put","patch","common"],v=>{delete o[v]}),s.headers=Se.concat(a,o);const l=[];let f=!0;this.interceptors.request.forEach(function(x){typeof x.runWhen=="function"&&x.runWhen(s)===!1||(f=f&&x.synchronous,l.unshift(x.fulfilled,x.rejected))});const d=[];this.interceptors.response.forEach(function(x){d.push(x.fulfilled,x.rejected)});let m,p=0,y;if(!f){const v=[Is.bind(this),void 0];for(v.unshift.apply(v,l),v.push.apply(v,d),y=v.length,m=Promise.resolve(s);p<y;)m=m.then(v[p++],v[p++]);return m}y=l.length;let _=s;for(p=0;p<y;){const v=l[p++],x=l[p++];try{_=v(_)}catch(R){x.call(this,R);break}}try{m=Is.call(this,_)}catch(v){return Promise.reject(v)}for(p=0,y=d.length;p<y;)m=m.then(d[p++],d[p++]);return m}getUri(e){e=nt(this.defaults,e);const s=Io(e.baseURL,e.url);return wo(s,e.params,e.paramsSerializer)}}b.forEach(["delete","get","head","options"],function(e){sn.prototype[e]=function(s,i){return this.request(nt(i||{},{method:e,url:s,data:(i||{}).data}))}});b.forEach(["post","put","patch"],function(e){function s(i){return function(o,a,l){return this.request(nt(l||{},{method:e,headers:i?{"Content-Type":"multipart/form-data"}:{},url:o,data:a}))}}sn.prototype[e]=s(),sn.prototype[e+"Form"]=s(!0)});var Jt=sn;class as{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let s;this.promise=new Promise(function(o){s=o});const i=this;this.promise.then(n=>{if(!i._listeners)return;let o=i._listeners.length;for(;o-- >0;)i._listeners[o](n);i._listeners=null}),this.promise.then=n=>{let o;const a=new Promise(l=>{i.subscribe(l),o=l}).then(n);return a.cancel=function(){i.unsubscribe(o)},a},e(function(o,a,l){i.reason||(i.reason=new pt(o,a,l),s(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const s=this._listeners.indexOf(e);s!==-1&&this._listeners.splice(s,1)}static source(){let e;return{token:new as(function(n){e=n}),cancel:e}}}var Lr=as;function Wr(t){return function(s){return t.apply(null,s)}}function Xr(t){return b.isObject(t)&&t.isAxiosError===!0}const Qn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Qn).forEach(([t,e])=>{Qn[e]=t});var Hr=Qn;function Po(t){const e=new Jt(t),s=lo(Jt.prototype.request,e);return b.extend(s,Jt.prototype,e,{allOwnKeys:!0}),b.extend(s,e,null,{allOwnKeys:!0}),s.create=function(n){return Po(nt(t,n))},s}const re=Po(is);re.Axios=Jt;re.CanceledError=pt;re.CancelToken=Lr;re.isCancel=Co;re.VERSION=Do;re.toFormData=gn;re.AxiosError=V;re.Cancel=re.CanceledError;re.all=function(e){return Promise.all(e)};re.spread=Wr;re.isAxiosError=Xr;re.mergeConfig=nt;re.AxiosHeaders=Se;re.formToJSON=t=>Eo(b.isHTMLForm(t)?new FormData(t):t);re.getAdapter=So.getAdapter;re.HttpStatusCode=Hr;re.default=re;var As=re;const zr={data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{formData:{siret:"",company_name:"",siren_number:"",manager_name:"",address:"",city:"",postal_code:"",country:"",phone:"",mobile_phone:"",email:"",website:"",currency_id:"",note:"",user_create:""},fields:{company_name:{label:t.company_name,type:"text",required:!0},manager_name:{label:t.manager_name,type:"text"},address:{label:t.address,type:"text",required:!0},city:{label:t.city,type:"text",required:!0},postal_code:{label:t.postal_code,type:"text"},country:{label:t.country,type:"text"},phone:{label:t.phone,type:"tel",required:!0},mobile_phone:{label:t.mobile,type:"tel"},email:{label:t.email,type:"email",required:!0},website:{label:t.website,type:"url"},currency_id:{label:t.currency,type:"text",required:!0}},options:{currency_options:[],default_currency:"",addon_user_active:!1,addon_siret_active:!1},toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},loadingBtn:!1,loadingSiret:!1}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{submitForm(){this.loadingBtn=!0,As.post("/wp-json/my-easy-compta/v1/clients/add",this.formData,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>{t.data.success?(this.showToast(t.data.message,"alert-success"),this.loadingBtn=!1,this.resetForm(),this.closeModal(),this.$emit("clientAdded")):(this.showToast(t.data.message,"alert-error"),this.loadingBtn=!1)}).catch(t=>{const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Erreur serveur";console.error(t),this.showToast(e,"alert-error"),this.loadingBtn=!1})},closeModal(){document.getElementById("modal_clients").close()},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},resetForm(){for(let t in this.formData)this.formData[t]=""},getOptions(t){return t==="currency_id"?this.options.currency_options:[]},fetchOptions(){As.get("/wp-json/my-easy-compta/v1/options",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>{this.options.currency_options=t.data.currency_options,this.options.default_currency=t.data.default_currency,this.options.addon_user_active=t.data.addon_user_active,this.options.addon_siret_active=t.data.addon_siret_active}).catch(t=>{console.error("Erreur lors de la r\xE9cup\xE9ration des options",t)})},fetchCompanyInfo(t){t.preventDefault(),this.loadingSiret=!0;const e=this.formData.siret;e?fetch(`/wp-json/my-easy-compta/v1/fetch-company-info/${e}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>{if(!s.ok)throw new Error("Network response was not ok");return s.json()}).then(s=>{s?(this.formData.company_name=s.company_name,this.formData.manager_name=s.manager_name,this.formData.address=s.address,this.formData.postal_code=s.postal_code,this.formData.city=s.city,this.formData.siren_number=s.siren,this.showToast("Informations charg\xE9es avec succ\xE8s","alert-success"),this.loadingSiret=!1):(this.showToast("Aucune information trouv\xE9e pour ce SIRET","alert-error"),this.loadingSiret=!1)}).catch(s=>{console.error("Error fetching company info:",s),this.showToast("Erreur lors du chargement des informations","alert-error"),this.loadingSiret=!1}):(this.showToast("Veuillez saisir un num\xE9ro SIRET","alert-error"),this.loadingSiret=!1)}},mounted(){this.fetchOptions()}},Qr={id:"modal_clients",class:"modal"},Gr={class:"modal-box"},Jr={class:"font-bold text-lg"},Yr={key:0,class:"grid grid-cols-1 gap-4"},Kr={class:"ecwp-group form-group relative join"},Zr={for:"siret",class:"ecwp-label form-label"},$r=["disabled"],ea={key:0,class:"loading loading-spinner loading-sm"},ta={key:1},na={class:"grid grid-cols-1 gap-4"},sa={class:"ecwp-group form-group relative"},oa={for:"siren",class:"ecwp-label form-label"},ia={class:"grid grid-cols-1 gap-4"},ra={class:"ecwp-group form-group relative"},aa={for:"tax_number",class:"ecwp-label form-label"},la={class:"grid grid-cols-2 gap-4"},ca=["for"],da=["id","onUpdate:modelValue","required"],ua=["value"],ha=["value"],ma=["type","id","onUpdate:modelValue","required"],fa={class:"ecwp-group form-group mt-4 relative"},pa=["for"],_a={key:1,class:"ecwp-group form-group mt-6 w-52 flex justify-between"},ga={class:"form-group mt-4 flex justify-end"},ya=["disabled"],ba={key:0,class:"loading loading-spinner loading-sm"};function va(t,e,s,i,n,o){return u(),h("div",null,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),r("dialog",Qr,[r("div",Gr,[r("h3",Jr,c(o.translations.new_client),1),r("form",{onSubmit:e[7]||(e[7]=J((...a)=>o.submitForm&&o.submitForm(...a),["prevent"]))},[r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=a=>o.closeModal())}," \u2715 "),n.options.addon_siret_active?(u(),h("div",Yr,[r("div",Kr,[r("label",Zr,c(o.translations.siret),1),D(r("input",{type:"number",id:"siret","onUpdate:modelValue":e[1]||(e[1]=a=>n.formData.siret=a),class:"ecwp-input input input-bordered w-full"},null,512),[[W,n.formData.siret]]),r("button",{onClick:e[2]||(e[2]=(...a)=>o.fetchCompanyInfo&&o.fetchCompanyInfo(...a)),class:"btn join-item rounded-r-full mt-5",disabled:n.loadingSiret},[n.loadingSiret?(u(),h("span",ea)):(u(),h("span",ta,c(o.translations.search),1))],8,$r)])])):g("",!0),r("div",na,[r("div",sa,[r("label",oa,c(o.translations.siren),1),D(r("input",{type:"number",id:"siren","onUpdate:modelValue":e[3]||(e[3]=a=>n.formData.siren_number=a),class:"ecwp-input input input-bordered w-full"},null,512),[[W,n.formData.siren_number]])])]),r("div",ia,[r("div",ra,[r("label",aa,c(o.translations.tax_number),1),D(r("input",{type:"text",id:"tax_number","onUpdate:modelValue":e[4]||(e[4]=a=>n.formData.tax_number=a),class:"ecwp-input input input-bordered w-full"},null,512),[[W,n.formData.tax_number]])])]),r("div",la,[(u(!0),h(F,null,U(n.fields,(a,l)=>(u(),h("div",{key:l,class:"ecwp-group form-group relative"},[r("label",{for:l,class:"ecwp-label form-label"},c(a.label),9,ca),l==="currency_id"?D((u(),h("select",{key:0,id:l,"onUpdate:modelValue":f=>n.formData[l]=f,class:"ecwp-input input input-bordered w-full peer",required:a.required},[r("option",{value:n.options.default_currency},c(o.translations.default_currency),9,ua),(u(!0),h(F,null,U(o.getOptions(l),f=>(u(),h("option",{key:f.id,value:f.id},c(f.name)+" - "+c(f.code)+" ("+c(f.symbol)+") ",9,ha))),128))],8,da)),[[ue,n.formData[l]]]):D((u(),h("input",{key:1,type:a.type,id:l,"onUpdate:modelValue":f=>n.formData[l]=f,class:"ecwp-input input input-bordered w-full peer",placeholder:" ",required:a.required},null,8,ma)),[[li,n.formData[l]]])]))),128))]),r("div",fa,[r("label",{for:t.key,class:"ecwp-label form-label"},c(o.translations.note),9,pa),D(r("textarea",{id:"note","onUpdate:modelValue":e[5]||(e[5]=a=>n.formData.note=a),class:"ecwp-input textarea textarea-bordered w-full peer",rows:"4",placeholder:" "},null,512),[[W,n.formData.note]])]),n.options.addon_user_active?(u(),h("div",_a,[r("label",null,c(o.translations.create_user),1),D(r("input",{class:"ecwp-switch",type:"checkbox","onUpdate:modelValue":e[6]||(e[6]=a=>n.formData.user_create=a)},null,512),[[ai,n.formData.user_create]])])):g("",!0),r("div",ga,[r("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(c(o.translations.add)+" ",1),n.loadingBtn?(u(),h("span",ba)):g("",!0)],8,ya)])],32)])])])}var Ro=ne(zr,[["render",va]]);/*!
    77  * vue-router v4.4.0
    88  * (c) 2024 Eduardo San Martin Morote
    99  * @license MIT
    10   */const rt=typeof document!="undefined";function wa(t){return t.__esModule||t[Symbol.toStringTag]==="Module"}const G=Object.assign;function Sn(t,e){const s={};for(const i in e){const n=e[i];s[i]=De(n)?n.map(t):t(n)}return s}const Tt=()=>{},De=Array.isArray,Ro=/#/g,xa=/&/g,Ea=/\//g,Ca=/=/g,Ta=/\?/g,Mo=/\+/g,Ia=/%5B/g,ka=/%5D/g,Oo=/%5E/g,Aa=/%60/g,qo=/%7B/g,Sa=/%7C/g,No=/%7D/g,Da=/%20/g;function ls(t){return encodeURI(""+t).replace(Sa,"|").replace(Ia,"[").replace(ka,"]")}function Pa(t){return ls(t).replace(qo,"{").replace(No,"}").replace(Oo,"^")}function Gn(t){return ls(t).replace(Mo,"%2B").replace(Da,"+").replace(Ro,"%23").replace(xa,"%26").replace(Aa,"`").replace(qo,"{").replace(No,"}").replace(Oo,"^")}function ja(t){return Gn(t).replace(Ca,"%3D")}function Ra(t){return ls(t).replace(Ro,"%23").replace(Ta,"%3F")}function Ma(t){return t==null?"":Ra(t).replace(Ea,"%2F")}function Mt(t){try{return decodeURIComponent(""+t)}catch{}return""+t}const Oa=/\/$/,qa=t=>t.replace(Oa,"");function Dn(t,e,s="/"){let i,n={},o="",a="";const l=e.indexOf("#");let f=e.indexOf("?");return l<f&&l>=0&&(f=-1),f>-1&&(i=e.slice(0,f),o=e.slice(f+1,l>-1?l:e.length),n=t(o)),l>-1&&(i=i||e.slice(0,l),a=e.slice(l,e.length)),i=Fa(i!=null?i:e,s),{fullPath:i+(o&&"?")+o+a,path:i,query:n,hash:Mt(a)}}function Na(t,e){const s=e.query?t(e.query):"";return e.path+(s&&"?")+s+(e.hash||"")}function Ss(t,e){return!e||!t.toLowerCase().startsWith(e.toLowerCase())?t:t.slice(e.length)||"/"}function Ba(t,e,s){const i=e.matched.length-1,n=s.matched.length-1;return i>-1&&i===n&&dt(e.matched[i],s.matched[n])&&Bo(e.params,s.params)&&t(e.query)===t(s.query)&&e.hash===s.hash}function dt(t,e){return(t.aliasOf||t)===(e.aliasOf||e)}function Bo(t,e){if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const s in t)if(!Va(t[s],e[s]))return!1;return!0}function Va(t,e){return De(t)?Ds(t,e):De(e)?Ds(e,t):t===e}function Ds(t,e){return De(e)?t.length===e.length&&t.every((s,i)=>s===e[i]):t.length===1&&t[0]===e}function Fa(t,e){if(t.startsWith("/"))return t;if(!t)return e;const s=e.split("/"),i=t.split("/"),n=i[i.length-1];(n===".."||n===".")&&i.push("");let o=s.length-1,a,l;for(a=0;a<i.length;a++)if(l=i[a],l!==".")if(l==="..")o>1&&o--;else break;return s.slice(0,o).join("/")+"/"+i.slice(a).join("/")}const ze={path:"/",name:void 0,params:{},query:{},hash:"",fullPath:"/",matched:[],meta:{},redirectedFrom:void 0};var Ot;(function(t){t.pop="pop",t.push="push"})(Ot||(Ot={}));var It;(function(t){t.back="back",t.forward="forward",t.unknown=""})(It||(It={}));function Ua(t){if(!t)if(rt){const e=document.querySelector("base");t=e&&e.getAttribute("href")||"/",t=t.replace(/^\w+:\/\/[^\/]+/,"")}else t="/";return t[0]!=="/"&&t[0]!=="#"&&(t="/"+t),qa(t)}const La=/^[^#]+#/;function Wa(t,e){return t.replace(La,"#")+e}function Xa(t,e){const s=document.documentElement.getBoundingClientRect(),i=t.getBoundingClientRect();return{behavior:e.behavior,left:i.left-s.left-(e.left||0),top:i.top-s.top-(e.top||0)}}const vn=()=>({left:window.scrollX,top:window.scrollY});function Ha(t){let e;if("el"in t){const s=t.el,i=typeof s=="string"&&s.startsWith("#"),n=typeof s=="string"?i?document.getElementById(s.slice(1)):document.querySelector(s):s;if(!n)return;e=Xa(n,t)}else e=t;"scrollBehavior"in document.documentElement.style?window.scrollTo(e):window.scrollTo(e.left!=null?e.left:window.scrollX,e.top!=null?e.top:window.scrollY)}function Ps(t,e){return(history.state?history.state.position-e:-1)+t}const Jn=new Map;function Qa(t,e){Jn.set(t,e)}function za(t){const e=Jn.get(t);return Jn.delete(t),e}let Ga=()=>location.protocol+"//"+location.host;function Vo(t,e){const{pathname:s,search:i,hash:n}=e,o=t.indexOf("#");if(o>-1){let l=n.includes(t.slice(o))?t.slice(o).length:1,f=n.slice(l);return f[0]!=="/"&&(f="/"+f),Ss(f,"")}return Ss(s,t)+i+n}function Ja(t,e,s,i){let n=[],o=[],a=null;const l=({state:y})=>{const _=Vo(t,location),v=s.value,x=e.value;let j=0;if(y){if(s.value=_,e.value=y,a&&a===v){a=null;return}j=x?y.position-x.position:0}else i(_);n.forEach(q=>{q(s.value,v,{delta:j,type:Ot.pop,direction:j?j>0?It.forward:It.back:It.unknown})})};function f(){a=s.value}function d(y){n.push(y);const _=()=>{const v=n.indexOf(y);v>-1&&n.splice(v,1)};return o.push(_),_}function m(){const{history:y}=window;!y.state||y.replaceState(G({},y.state,{scroll:vn()}),"")}function p(){for(const y of o)y();o=[],window.removeEventListener("popstate",l),window.removeEventListener("beforeunload",m)}return window.addEventListener("popstate",l),window.addEventListener("beforeunload",m,{passive:!0}),{pauseListeners:f,listen:d,destroy:p}}function js(t,e,s,i=!1,n=!1){return{back:t,current:e,forward:s,replaced:i,position:window.history.length,scroll:n?vn():null}}function Ya(t){const{history:e,location:s}=window,i={value:Vo(t,s)},n={value:e.state};n.value||o(i.value,{back:null,current:i.value,forward:null,position:e.length-1,replaced:!0,scroll:null},!0);function o(f,d,m){const p=t.indexOf("#"),y=p>-1?(s.host&&document.querySelector("base")?t:t.slice(p))+f:Ga()+t+f;try{e[m?"replaceState":"pushState"](d,"",y),n.value=d}catch(_){console.error(_),s[m?"replace":"assign"](y)}}function a(f,d){const m=G({},e.state,js(n.value.back,f,n.value.forward,!0),d,{position:n.value.position});o(f,m,!0),i.value=f}function l(f,d){const m=G({},n.value,e.state,{forward:f,scroll:vn()});o(m.current,m,!0);const p=G({},js(i.value,f,null),{position:m.position+1},d);o(f,p,!1),i.value=f}return{location:i,state:n,push:l,replace:a}}function Ka(t){t=Ua(t);const e=Ya(t),s=Ja(t,e.state,e.location,e.replace);function i(o,a=!0){a||s.pauseListeners(),history.go(o)}const n=G({location:"",base:t,go:i,createHref:Wa.bind(null,t)},e,s);return Object.defineProperty(n,"location",{enumerable:!0,get:()=>e.location.value}),Object.defineProperty(n,"state",{enumerable:!0,get:()=>e.state.value}),n}function Za(t){return t=location.host?t||location.pathname+location.search:"",t.includes("#")||(t+="#"),Ka(t)}function $a(t){return typeof t=="string"||t&&typeof t=="object"}function Fo(t){return typeof t=="string"||typeof t=="symbol"}const Uo=Symbol("");var Rs;(function(t){t[t.aborted=4]="aborted",t[t.cancelled=8]="cancelled",t[t.duplicated=16]="duplicated"})(Rs||(Rs={}));function ut(t,e){return G(new Error,{type:t,[Uo]:!0},e)}function Fe(t,e){return t instanceof Error&&Uo in t&&(e==null||!!(t.type&e))}const Ms="[^/]+?",el={sensitive:!1,strict:!1,start:!0,end:!0},tl=/[.+*?^${}()[\]/\\]/g;function nl(t,e){const s=G({},el,e),i=[];let n=s.start?"^":"";const o=[];for(const d of t){const m=d.length?[]:[90];s.strict&&!d.length&&(n+="/");for(let p=0;p<d.length;p++){const y=d[p];let _=40+(s.sensitive?.25:0);if(y.type===0)p||(n+="/"),n+=y.value.replace(tl,"\\$&"),_+=40;else if(y.type===1){const{value:v,repeatable:x,optional:j,regexp:q}=y;o.push({name:v,repeatable:x,optional:j});const S=q||Ms;if(S!==Ms){_+=10;try{new RegExp(`(${S})`)}catch(Q){throw new Error(`Invalid custom RegExp for param "${v}" (${S}): `+Q.message)}}let k=x?`((?:${S})(?:/(?:${S}))*)`:`(${S})`;p||(k=j&&d.length<2?`(?:/${k})`:"/"+k),j&&(k+="?"),n+=k,_+=20,j&&(_+=-8),x&&(_+=-20),S===".*"&&(_+=-50)}m.push(_)}i.push(m)}if(s.strict&&s.end){const d=i.length-1;i[d][i[d].length-1]+=.7000000000000001}s.strict||(n+="/?"),s.end?n+="$":s.strict&&(n+="(?:/|$)");const a=new RegExp(n,s.sensitive?"":"i");function l(d){const m=d.match(a),p={};if(!m)return null;for(let y=1;y<m.length;y++){const _=m[y]||"",v=o[y-1];p[v.name]=_&&v.repeatable?_.split("/"):_}return p}function f(d){let m="",p=!1;for(const y of t){(!p||!m.endsWith("/"))&&(m+="/"),p=!1;for(const _ of y)if(_.type===0)m+=_.value;else if(_.type===1){const{value:v,repeatable:x,optional:j}=_,q=v in d?d[v]:"";if(De(q)&&!x)throw new Error(`Provided param "${v}" is an array but it is not repeatable (* or + modifiers)`);const S=De(q)?q.join("/"):q;if(!S)if(j)y.length<2&&(m.endsWith("/")?m=m.slice(0,-1):p=!0);else throw new Error(`Missing required param "${v}"`);m+=S}}return m||"/"}return{re:a,score:i,keys:o,parse:l,stringify:f}}function sl(t,e){let s=0;for(;s<t.length&&s<e.length;){const i=e[s]-t[s];if(i)return i;s++}return t.length<e.length?t.length===1&&t[0]===40+40?-1:1:t.length>e.length?e.length===1&&e[0]===40+40?1:-1:0}function Lo(t,e){let s=0;const i=t.score,n=e.score;for(;s<i.length&&s<n.length;){const o=sl(i[s],n[s]);if(o)return o;s++}if(Math.abs(n.length-i.length)===1){if(Os(i))return 1;if(Os(n))return-1}return n.length-i.length}function Os(t){const e=t[t.length-1];return t.length>0&&e[e.length-1]<0}const ol={type:0,value:""},il=/[a-zA-Z0-9_]/;function rl(t){if(!t)return[[]];if(t==="/")return[[ol]];if(!t.startsWith("/"))throw new Error(`Invalid path "${t}"`);function e(_){throw new Error(`ERR (${s})/"${d}": ${_}`)}let s=0,i=s;const n=[];let o;function a(){o&&n.push(o),o=[]}let l=0,f,d="",m="";function p(){!d||(s===0?o.push({type:0,value:d}):s===1||s===2||s===3?(o.length>1&&(f==="*"||f==="+")&&e(`A repeatable param (${d}) must be alone in its segment. eg: '/:ids+.`),o.push({type:1,value:d,regexp:m,repeatable:f==="*"||f==="+",optional:f==="*"||f==="?"})):e("Invalid state to consume buffer"),d="")}function y(){d+=f}for(;l<t.length;){if(f=t[l++],f==="\\"&&s!==2){i=s,s=4;continue}switch(s){case 0:f==="/"?(d&&p(),a()):f===":"?(p(),s=1):y();break;case 4:y(),s=i;break;case 1:f==="("?s=2:il.test(f)?y():(p(),s=0,f!=="*"&&f!=="?"&&f!=="+"&&l--);break;case 2:f===")"?m[m.length-1]=="\\"?m=m.slice(0,-1)+f:s=3:m+=f;break;case 3:p(),s=0,f!=="*"&&f!=="?"&&f!=="+"&&l--,m="";break;default:e("Unknown state");break}}return s===2&&e(`Unfinished custom RegExp for param "${d}"`),p(),a(),n}function al(t,e,s){const i=nl(rl(t.path),s),n=G(i,{record:t,parent:e,children:[],alias:[]});return e&&!n.record.aliasOf==!e.record.aliasOf&&e.children.push(n),n}function ll(t,e){const s=[],i=new Map;e=Bs({strict:!1,end:!0,sensitive:!1},e);function n(p){return i.get(p)}function o(p,y,_){const v=!_,x=cl(p);x.aliasOf=_&&_.record;const j=Bs(e,p),q=[x];if("alias"in p){const Q=typeof p.alias=="string"?[p.alias]:p.alias;for(const le of Q)q.push(G({},x,{components:_?_.record.components:x.components,path:le,aliasOf:_?_.record:x}))}let S,k;for(const Q of q){const{path:le}=Q;if(y&&le[0]!=="/"){const Y=y.record.path,K=Y[Y.length-1]==="/"?"":"/";Q.path=y.record.path+(le&&K+le)}if(S=al(Q,y,j),_?_.alias.push(S):(k=k||S,k!==S&&k.alias.push(S),v&&p.name&&!Ns(S)&&a(p.name)),Wo(S)&&f(S),x.children){const Y=x.children;for(let K=0;K<Y.length;K++)o(Y[K],S,_&&_.children[K])}_=_||S}return k?()=>{a(k)}:Tt}function a(p){if(Fo(p)){const y=i.get(p);y&&(i.delete(p),s.splice(s.indexOf(y),1),y.children.forEach(a),y.alias.forEach(a))}else{const y=s.indexOf(p);y>-1&&(s.splice(y,1),p.record.name&&i.delete(p.record.name),p.children.forEach(a),p.alias.forEach(a))}}function l(){return s}function f(p){const y=hl(p,s);s.splice(y,0,p),p.record.name&&!Ns(p)&&i.set(p.record.name,p)}function d(p,y){let _,v={},x,j;if("name"in p&&p.name){if(_=i.get(p.name),!_)throw ut(1,{location:p});j=_.record.name,v=G(qs(y.params,_.keys.filter(k=>!k.optional).concat(_.parent?_.parent.keys.filter(k=>k.optional):[]).map(k=>k.name)),p.params&&qs(p.params,_.keys.map(k=>k.name))),x=_.stringify(v)}else if(p.path!=null)x=p.path,_=s.find(k=>k.re.test(x)),_&&(v=_.parse(x),j=_.record.name);else{if(_=y.name?i.get(y.name):s.find(k=>k.re.test(y.path)),!_)throw ut(1,{location:p,currentLocation:y});j=_.record.name,v=G({},y.params,p.params),x=_.stringify(v)}const q=[];let S=_;for(;S;)q.unshift(S.record),S=S.parent;return{name:j,path:x,params:v,matched:q,meta:ul(q)}}t.forEach(p=>o(p));function m(){s.length=0,i.clear()}return{addRoute:o,resolve:d,removeRoute:a,clearRoutes:m,getRoutes:l,getRecordMatcher:n}}function qs(t,e){const s={};for(const i of e)i in t&&(s[i]=t[i]);return s}function cl(t){return{path:t.path,redirect:t.redirect,name:t.name,meta:t.meta||{},aliasOf:void 0,beforeEnter:t.beforeEnter,props:dl(t),children:t.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:"components"in t?t.components||null:t.component&&{default:t.component}}}function dl(t){const e={},s=t.props||!1;if("component"in t)e.default=s;else for(const i in t.components)e[i]=typeof s=="object"?s[i]:s;return e}function Ns(t){for(;t;){if(t.record.aliasOf)return!0;t=t.parent}return!1}function ul(t){return t.reduce((e,s)=>G(e,s.meta),{})}function Bs(t,e){const s={};for(const i in t)s[i]=i in e?e[i]:t[i];return s}function hl(t,e){let s=0,i=e.length;for(;s!==i;){const o=s+i>>1;Lo(t,e[o])<0?i=o:s=o+1}const n=ml(t);return n&&(i=e.lastIndexOf(n,i-1)),i}function ml(t){let e=t;for(;e=e.parent;)if(Wo(e)&&Lo(t,e)===0)return e}function Wo({record:t}){return!!(t.name||t.components&&Object.keys(t.components).length||t.redirect)}function fl(t){const e={};if(t===""||t==="?")return e;const i=(t[0]==="?"?t.slice(1):t).split("&");for(let n=0;n<i.length;++n){const o=i[n].replace(Mo," "),a=o.indexOf("="),l=Mt(a<0?o:o.slice(0,a)),f=a<0?null:Mt(o.slice(a+1));if(l in e){let d=e[l];De(d)||(d=e[l]=[d]),d.push(f)}else e[l]=f}return e}function Vs(t){let e="";for(let s in t){const i=t[s];if(s=ja(s),i==null){i!==void 0&&(e+=(e.length?"&":"")+s);continue}(De(i)?i.map(o=>o&&Gn(o)):[i&&Gn(i)]).forEach(o=>{o!==void 0&&(e+=(e.length?"&":"")+s,o!=null&&(e+="="+o))})}return e}function pl(t){const e={};for(const s in t){const i=t[s];i!==void 0&&(e[s]=De(i)?i.map(n=>n==null?null:""+n):i==null?i:""+i)}return e}const _l=Symbol(""),Fs=Symbol(""),cs=Symbol(""),Xo=Symbol(""),Yn=Symbol("");function vt(){let t=[];function e(i){return t.push(i),()=>{const n=t.indexOf(i);n>-1&&t.splice(n,1)}}function s(){t=[]}return{add:e,list:()=>t.slice(),reset:s}}function Ge(t,e,s,i,n,o=a=>a()){const a=i&&(i.enterCallbacks[n]=i.enterCallbacks[n]||[]);return()=>new Promise((l,f)=>{const d=y=>{y===!1?f(ut(4,{from:s,to:e})):y instanceof Error?f(y):$a(y)?f(ut(2,{from:e,to:y})):(a&&i.enterCallbacks[n]===a&&typeof y=="function"&&a.push(y),l())},m=o(()=>t.call(i&&i.instances[n],e,s,d));let p=Promise.resolve(m);t.length<3&&(p=p.then(d)),p.catch(y=>f(y))})}function Pn(t,e,s,i,n=o=>o()){const o=[];for(const a of t)for(const l in a.components){let f=a.components[l];if(!(e!=="beforeRouteEnter"&&!a.instances[l]))if(gl(f)){const m=(f.__vccOpts||f)[e];m&&o.push(Ge(m,s,i,a,l,n))}else{let d=f();o.push(()=>d.then(m=>{if(!m)return Promise.reject(new Error(`Couldn't resolve component "${l}" at "${a.path}"`));const p=wa(m)?m.default:m;a.components[l]=p;const _=(p.__vccOpts||p)[e];return _&&Ge(_,s,i,a,l,n)()}))}}return o}function gl(t){return typeof t=="object"||"displayName"in t||"props"in t||"__vccOpts"in t}function Us(t){const e=jt(cs),s=jt(Xo),i=Re(()=>{const f=Ct(t.to);return e.resolve(f)}),n=Re(()=>{const{matched:f}=i.value,{length:d}=f,m=f[d-1],p=s.matched;if(!m||!p.length)return-1;const y=p.findIndex(dt.bind(null,m));if(y>-1)return y;const _=Ls(f[d-2]);return d>1&&Ls(m)===_&&p[p.length-1].path!==_?p.findIndex(dt.bind(null,f[d-2])):y}),o=Re(()=>n.value>-1&&wl(s.params,i.value.params)),a=Re(()=>n.value>-1&&n.value===s.matched.length-1&&Bo(s.params,i.value.params));function l(f={}){return vl(f)?e[Ct(t.replace)?"replace":"push"](Ct(t.to)).catch(Tt):Promise.resolve()}return{route:i,href:Re(()=>i.value.href),isActive:o,isExactActive:a,navigate:l}}const yl=eo({name:"RouterLink",compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"}},useLink:Us,setup(t,{slots:e}){const s=hi(Us(t)),{options:i}=jt(cs),n=Re(()=>({[Ws(t.activeClass,i.linkActiveClass,"router-link-active")]:s.isActive,[Ws(t.exactActiveClass,i.linkExactActiveClass,"router-link-exact-active")]:s.isExactActive}));return()=>{const o=e.default&&e.default(s);return t.custom?o:to("a",{"aria-current":s.isExactActive?t.ariaCurrentValue:null,href:s.href,onClick:s.navigate,class:n.value},o)}}}),bl=yl;function vl(t){if(!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)&&!t.defaultPrevented&&!(t.button!==void 0&&t.button!==0)){if(t.currentTarget&&t.currentTarget.getAttribute){const e=t.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(e))return}return t.preventDefault&&t.preventDefault(),!0}}function wl(t,e){for(const s in e){const i=e[s],n=t[s];if(typeof i=="string"){if(i!==n)return!1}else if(!De(n)||n.length!==i.length||i.some((o,a)=>o!==n[a]))return!1}return!0}function Ls(t){return t?t.aliasOf?t.aliasOf.path:t.path:""}const Ws=(t,e,s)=>t!=null?t:e!=null?e:s,xl=eo({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,default:"default"},route:Object},compatConfig:{MODE:3},setup(t,{attrs:e,slots:s}){const i=jt(Yn),n=Re(()=>t.route||i.value),o=jt(Fs,0),a=Re(()=>{let d=Ct(o);const{matched:m}=n.value;let p;for(;(p=m[d])&&!p.components;)d++;return d}),l=Re(()=>n.value.matched[a.value]);Cn(Fs,Re(()=>a.value+1)),Cn(_l,l),Cn(Yn,n);const f=mi();return fi(()=>[f.value,l.value,t.name],([d,m,p],[y,_,v])=>{m&&(m.instances[p]=d,_&&_!==m&&d&&d===y&&(m.leaveGuards.size||(m.leaveGuards=_.leaveGuards),m.updateGuards.size||(m.updateGuards=_.updateGuards))),d&&m&&(!_||!dt(m,_)||!y)&&(m.enterCallbacks[p]||[]).forEach(x=>x(d))},{flush:"post"}),()=>{const d=n.value,m=t.name,p=l.value,y=p&&p.components[m];if(!y)return Xs(s.default,{Component:y,route:d});const _=p.props[m],v=_?_===!0?d.params:typeof _=="function"?_(d):_:null,j=to(y,G({},v,e,{onVnodeUnmounted:q=>{q.component.isUnmounted&&(p.instances[m]=null)},ref:f}));return Xs(s.default,{Component:j,route:d})||j}}});function Xs(t,e){if(!t)return null;const s=t(e);return s.length===1?s[0]:s}const El=xl;function Cl(t){const e=ll(t.routes,t),s=t.parseQuery||fl,i=t.stringifyQuery||Vs,n=t.history,o=vt(),a=vt(),l=vt(),f=ci(ze);let d=ze;rt&&t.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const m=Sn.bind(null,w=>""+w),p=Sn.bind(null,Ma),y=Sn.bind(null,Mt);function _(w,A){let T,R;return Fo(w)?(T=e.getRecordMatcher(w),R=A):R=w,e.addRoute(R,T)}function v(w){const A=e.getRecordMatcher(w);A&&e.removeRoute(A)}function x(){return e.getRoutes().map(w=>w.record)}function j(w){return!!e.getRecordMatcher(w)}function q(w,A){if(A=G({},A||f.value),typeof w=="string"){const L=Dn(s,w,A.path),ae=e.resolve({path:L.path},A),yt=n.createHref(L.fullPath);return G(L,ae,{params:y(ae.params),hash:Mt(L.hash),redirectedFrom:void 0,href:yt})}let T;if(w.path!=null)T=G({},w,{path:Dn(s,w.path,A.path).path});else{const L=G({},w.params);for(const ae in L)L[ae]==null&&delete L[ae];T=G({},w,{params:p(L)}),A.params=p(A.params)}const R=e.resolve(T,A),Z=w.hash||"";R.params=m(y(R.params));const se=Na(i,G({},w,{hash:Pa(Z),path:R.path})),X=n.createHref(se);return G({fullPath:se,hash:Z,query:i===Vs?pl(w.query):w.query||{}},R,{redirectedFrom:void 0,href:X})}function S(w){return typeof w=="string"?Dn(s,w,f.value.path):G({},w)}function k(w,A){if(d!==w)return ut(8,{from:A,to:w})}function Q(w){return K(w)}function le(w){return Q(G(S(w),{replace:!0}))}function Y(w){const A=w.matched[w.matched.length-1];if(A&&A.redirect){const{redirect:T}=A;let R=typeof T=="function"?T(w):T;return typeof R=="string"&&(R=R.includes("?")||R.includes("#")?R=S(R):{path:R},R.params={}),G({query:w.query,hash:w.hash,params:R.path!=null?{}:w.params},R)}}function K(w,A){const T=d=q(w),R=f.value,Z=w.state,se=w.force,X=w.replace===!0,L=Y(T);if(L)return K(G(S(L),{state:typeof L=="object"?G({},Z,L.state):Z,force:se,replace:X}),A||T);const ae=T;ae.redirectedFrom=A;let yt;return!se&&Ba(i,R,T)&&(yt=ut(16,{to:ae,from:R}),_t(R,R,!0,!1)),(yt?Promise.resolve(yt):Xe(ae,R)).catch(_e=>Fe(_e)?Fe(_e,2)?_e:Ut(_e):Ve(_e,ae,R)).then(_e=>{if(_e){if(Fe(_e,2))return K(G({replace:X},S(_e.to),{state:typeof _e.to=="object"?G({},Z,_e.to.state):Z,force:se}),A||ae)}else _e=He(ae,R,!0,X,Z);return Ee(ae,R,_e),_e})}function je(w,A){const T=k(w,A);return T?Promise.reject(T):Promise.resolve()}function ce(w){const A=Lt.values().next().value;return A&&typeof A.runWithContext=="function"?A.runWithContext(w):w()}function Xe(w,A){let T;const[R,Z,se]=Tl(w,A);T=Pn(R.reverse(),"beforeRouteLeave",w,A);for(const L of R)L.leaveGuards.forEach(ae=>{T.push(Ge(ae,w,A))});const X=je.bind(null,w,A);return T.push(X),st(T).then(()=>{T=[];for(const L of o.list())T.push(Ge(L,w,A));return T.push(X),st(T)}).then(()=>{T=Pn(Z,"beforeRouteUpdate",w,A);for(const L of Z)L.updateGuards.forEach(ae=>{T.push(Ge(ae,w,A))});return T.push(X),st(T)}).then(()=>{T=[];for(const L of se)if(L.beforeEnter)if(De(L.beforeEnter))for(const ae of L.beforeEnter)T.push(Ge(ae,w,A));else T.push(Ge(L.beforeEnter,w,A));return T.push(X),st(T)}).then(()=>(w.matched.forEach(L=>L.enterCallbacks={}),T=Pn(se,"beforeRouteEnter",w,A,ce),T.push(X),st(T))).then(()=>{T=[];for(const L of a.list())T.push(Ge(L,w,A));return T.push(X),st(T)}).catch(L=>Fe(L,8)?L:Promise.reject(L))}function Ee(w,A,T){l.list().forEach(R=>ce(()=>R(w,A,T)))}function He(w,A,T,R,Z){const se=k(w,A);if(se)return se;const X=A===ze,L=rt?history.state:{};T&&(R||X?n.replace(w.fullPath,G({scroll:X&&L&&L.scroll},Z)):n.push(w.fullPath,Z)),f.value=w,_t(w,A,T,X),Ut()}let fe;function qe(){fe||(fe=n.listen((w,A,T)=>{if(!fs.listening)return;const R=q(w),Z=Y(R);if(Z){K(G(Z,{replace:!0}),R).catch(Tt);return}d=R;const se=f.value;rt&&Qa(Ps(se.fullPath,T.delta),vn()),Xe(R,se).catch(X=>Fe(X,12)?X:Fe(X,2)?(K(X.to,R).then(L=>{Fe(L,20)&&!T.delta&&T.type===Ot.pop&&n.go(-1,!1)}).catch(Tt),Promise.reject()):(T.delta&&n.go(-T.delta,!1),Ve(X,R,se))).then(X=>{X=X||He(R,se,!1),X&&(T.delta&&!Fe(X,8)?n.go(-T.delta,!1):T.type===Ot.pop&&Fe(X,20)&&n.go(-1,!1)),Ee(R,se,X)}).catch(Tt)}))}let Ne=vt(),Ce=vt(),Be;function Ve(w,A,T){Ut(w);const R=Ce.list();return R.length?R.forEach(Z=>Z(w,A,T)):console.error(w),Promise.reject(w)}function xn(){return Be&&f.value!==ze?Promise.resolve():new Promise((w,A)=>{Ne.add([w,A])})}function Ut(w){return Be||(Be=!w,qe(),Ne.list().forEach(([A,T])=>w?T(w):A()),Ne.reset()),w}function _t(w,A,T,R){const{scrollBehavior:Z}=t;if(!rt||!Z)return Promise.resolve();const se=!T&&za(Ps(w.fullPath,0))||(R||!T)&&history.state&&history.state.scroll||null;return ui().then(()=>Z(w,A,se)).then(X=>X&&Ha(X)).catch(X=>Ve(X,w,A))}const gt=w=>n.go(w);let En;const Lt=new Set,fs={currentRoute:f,listening:!0,addRoute:_,removeRoute:v,clearRoutes:e.clearRoutes,hasRoute:j,getRoutes:x,resolve:q,options:t,push:Q,replace:le,go:gt,back:()=>gt(-1),forward:()=>gt(1),beforeEach:o.add,beforeResolve:a.add,afterEach:l.add,onError:Ce.add,isReady:xn,install(w){const A=this;w.component("RouterLink",bl),w.component("RouterView",El),w.config.globalProperties.$router=A,Object.defineProperty(w.config.globalProperties,"$route",{enumerable:!0,get:()=>Ct(f)}),rt&&!En&&f.value===ze&&(En=!0,Q(n.location).catch(Z=>{}));const T={};for(const Z in ze)Object.defineProperty(T,Z,{get:()=>f.value[Z],enumerable:!0});w.provide(cs,A),w.provide(Xo,di(T)),w.provide(Yn,f);const R=w.unmount;Lt.add(w),w.unmount=function(){Lt.delete(w),Lt.size<1&&(d=ze,fe&&fe(),fe=null,f.value=ze,En=!1,Be=!1),R()}}};function st(w){return w.reduce((A,T)=>A.then(()=>ce(T)),Promise.resolve())}return fs}function Tl(t,e){const s=[],i=[],n=[],o=Math.max(e.matched.length,t.matched.length);for(let a=0;a<o;a++){const l=e.matched[a];l&&(t.matched.find(d=>dt(d,l))?i.push(l):s.push(l));const f=t.matched[a];f&&(e.matched.find(d=>dt(d,f))||n.push(f))}return[s,i,n]}const Il={name:"QuoteEdit",components:{Card:Ze,ModelSelect:hn,VueDatePicker:Nt},data(){return{quote:{quote_number:"",due_date:"",provisional_start_date:"",client_id:"",client:null,status:""},showError:!1,loading:!1,loadingBtn:!1,clients:[],clientOptions:[],settings:[],toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return t=>{if(!t)return"";const e=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getFullYear();return`${e}-${s}-${i}`}}},mounted(){this.fetchClients(),this.fetchSettings(),this.fetchQuoteDetails()},methods:{cancelAction(){this.$router.push("/quotes")},fetchClients(){this.loading=!0,fetch("/wp-json/my-easy-compta/v1/list-clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.clients=t.clients,this.clientOptions=this.clients.map(e=>({value:e.id,text:`${e.company_name} - ${e.email} (${e.currency_symbol})`})),this.quote.client_id&&this.setClientById(this.quote.client_id)}).catch(t=>{console.error("Error fetching clients:",t)}).finally(()=>{this.loading=!1})},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,t.ok){const e=await t.json();this.settings=e}else{const e=await t.json();console.error("Error fetching settings:",e)}}catch(t){this.loading=!1,console.error("Error fetching settings:",t)}},fetchQuoteDetails(){const t=this.$route.params.id;!t||(this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{e?(this.quote=e,this.setClientById(this.quote.client_id)):(console.error("Error fetching quote details:",e.message),this.showToast(e.message,"alert-error"))}).catch(e=>{console.error("Error fetching quote details:",e),this.showToast(e,"alert-error")}).finally(()=>{this.loading=!1}))},setClientById(t){this.quote.client=this.clients.find(e=>e.id===t)||null,this.quote.client_id=t},submitQuote(){if(!this.quote.due_date||!this.quote.provisional_start_date||!this.quote.client_id||!this.quote.status){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.loadingBtn=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/${this.$route.params.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.quote)}).then(t=>{if(!t.ok)throw this.loadingBtn=!1,new Error("Network response was not ok");return t.json()}).then(t=>{t.success?(this.loadingBtn=!1,this.showToast(t.message,"alert-success"),this.$router.push({name:"QuoteViewDetail",params:{id:t.id}})):(console.error("Error submitting quote:",t.message),this.showToast(t.message,"alert-error"),this.loadingBtn=!1)}).catch(t=>{console.error("Error submitting quote:",t),this.showToast(t,"alert-error"),this.loadingBtn=!1})},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},kl={class:"pt-2 pr-4"},Al={class:"flex justify-between items-center mb-4"},Sl={class:"card-title"},Dl=r("div",{class:"divider mt-2"},null,-1),Pl={key:0,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},jl={class:"grid grid-cols-3 gap-4"},Rl={class:"ecwp-group form-group mb-4"},Ml={for:"quoteNumber",class:"ecwp-label"},Ol={class:"ecwp-group form-group mb-4"},ql={for:"quoteDate",class:"ecwp-label"},Nl={class:"ecwp-group form-group mb-4"},Bl={for:"quoteProvisanalDate",class:"ecwp-label"},Vl={class:"grid grid-cols-2 gap-4"},Fl={class:"ecwp-group form-group mb-4"},Ul={for:"client",class:"ecwp-label"},Ll={class:"ecwp-group form-group mb-4"},Wl={for:"status",class:"ecwp-label"},Xl={value:"draft"},Hl={value:"pending"},Ql={value:"approved"},zl={value:"rejected"},Gl={class:"flex justify-between"},Jl=["disabled"],Yl={key:0,class:"loading loading-spinner loading-sm"};function Kl(t,e,s,i,n,o){const a=O("VueDatePicker"),l=O("model-select"),f=O("Card");return u(),h("div",kl,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),P(f,{topMargin:"mt-8",modalType:"modal_quote_new"},{default:me(()=>[r("div",Al,[r("h2",Sl,c(o.translations.edit_quote),1)]),Dl,n.loading?(u(),h("div",Pl)):g("",!0),r("form",{onSubmit:e[6]||(e[6]=J((...d)=>o.submitQuote&&o.submitQuote(...d),["prevent"]))},[r("div",jl,[r("div",Rl,[r("label",Ml,c(o.translations.quote_number),1),D(r("input",{type:"text",id:"quoteNumber","onUpdate:modelValue":e[0]||(e[0]=d=>n.quote.quote_number=d),class:"ecwp-input input input-bordered w-full",disabled:"true"},null,512),[[W,n.quote.quote_number]])]),r("div",Ol,[r("label",ql,c(o.translations.due_date),1),P(a,{class:I(["ecwp-input ecwp-date input input-bordered w-full",[!n.quote.due_date&&n.showError?"input-error":""]]),id:"quoteDate",modelValue:n.quote.due_date,"onUpdate:modelValue":e[1]||(e[1]=d=>n.quote.due_date=d),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date},null,8,["class","modelValue","format","min-date"])]),r("div",Nl,[r("label",Bl,c(o.translations.provisional_date),1),P(a,{class:I(["ecwp-input ecwp-date input input-bordered w-full",[!n.quote.provisional_start_date&&n.showError?"input-error":""]]),id:"quoteProvisanalDate",modelValue:n.quote.provisional_start_date,"onUpdate:modelValue":e[2]||(e[2]=d=>n.quote.provisional_start_date=d),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date},null,8,["class","modelValue","format","min-date"])])]),r("div",Vl,[r("div",Fl,[r("label",Ul,c(o.translations.company_name),1),P(l,{modelValue:n.quote.client_id,"onUpdate:modelValue":e[3]||(e[3]=d=>n.quote.client_id=d),options:n.clientOptions,label:"text","track-by":"value",placeholder:o.translations.select,class:I(["ecwp-input input input-bordered w-full",[!n.quote.client_id&&n.showError?"input-error":""]])},null,8,["modelValue","options","placeholder","class"])]),r("div",Ll,[r("label",Wl,c(o.translations.status),1),D(r("select",{id:"status","onUpdate:modelValue":e[4]||(e[4]=d=>n.quote.status=d),required:"",class:I(["ecwp-input select select-bordered w-full",[!n.quote.status&&n.showError?"input-error":""]])},[r("option",Xl,c(o.translations.draft),1),r("option",Hl,c(o.translations.pending),1),r("option",Ql,c(o.translations.approved),1),r("option",zl,c(o.translations.rejected),1)],2),[[ue,n.quote.status]])])]),r("div",Gl,[r("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:e[5]||(e[5]=(...d)=>o.cancelAction&&o.cancelAction(...d))},c(o.translations.cancel),1),r("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(c(o.translations.save)+" ",1),n.loadingBtn?(u(),h("span",Yl)):g("",!0)],8,Jl)])],32)]),_:1})])}var Ho=ne(Il,[["render",Kl]]);const Zl={props:{isVisible:{type:Boolean,default:!1},title:{type:String,default:"Confirmation"},message:{type:String,default:"Are you sure?"},confirmText:{type:String,default:"Confirm"},cancelText:{type:String,default:"Cancel"},status:{type:String}},data(){return{selectedPaymentMethod:""}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{onConfirm(){this.$emit("confirm"),this.closeModal()},onCancel(){this.$emit("cancel"),this.closeModal()},closeModal(){document.getElementById("modal_confirm").close()}}},$l=["open"],ec={class:"modal-box"},tc={class:"font-bold text-lg"},nc=r("div",{class:"text-center text-red-400 mb-2"},[r("i",{class:"fas fa-exclamation-triangle text-4xl"})],-1),sc={class:"text-lg font-semibold text-center"},oc={class:"my-4 text-center text-xl"},ic={class:"flex justify-between space-x-4"};function rc(t,e,s,i,n,o){return u(),h("div",null,[r("dialog",{id:"modal_confirm",class:"modal",open:t.showModal},[r("div",ec,[r("h3",tc,c(t.modalTitle),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...a)=>o.closeModal&&o.closeModal(...a))}," \u2715 "),nc,r("h2",sc,c(s.title),1),r("p",oc,c(s.message),1),r("div",ic,[r("button",{onClick:e[1]||(e[1]=(...a)=>o.onCancel&&o.onCancel(...a)),class:"btn btn-secondary rounded-full"},c(s.cancelText),1),r("button",{onClick:e[2]||(e[2]=(...a)=>o.onConfirm&&o.onConfirm(...a)),class:"btn rounded-full btn-error text-white"},c(s.confirmText),1)])])],8,$l)])}var ds=ne(Zl,[["render",rc]]);const ac={name:"QuotesList",components:{Card:Ze,QuoteEditModal:Ho,ConfirmModal:ds,RemoveModal:qt},data(){return{quotes:[],filteredQuotes:[],filters:{quote_number:"",client:"",status:"",total_amount:"",due_date:"",created_at:""},showQuoteDetailsModal:!1,editQuoteModal:!1,selectedQuote:null,currentPage:1,totalCount:0,totalPages:1,paginationButtons:[],loading:!0,loadingPrice:!0,loadingModal:!1,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],clients:[],client_currency:"",default_vat:"",default_currency:"",default_currency_symbol:"",settings:{},toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},created(){this.fetchQuotesWithFilters(),this.loadSettings(),this.fetchClients()},methods:{fetchQuotes(t=1){this.loading=!0;const{perPage:e}=this;fetch(`/wp-json/my-easy-compta/v1/quotes?page=${t}&per_page=${e}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>s.json()).then(s=>{this.quotes=s.quotes,this.totalCount=s.total_count,this.totalPages=s.total_pages,this.currentPage=t,this.perPage=e,this.generatePaginationButtons()}).catch(s=>{console.error("Error fetching quotes:",s)}).finally(()=>{this.loading=!1})},fetchQuotesWithFilters(t=1){this.loading=!0;const{perPage:e,filters:s}=this,i=new URLSearchParams({page:t,per_page:e,...s}).toString();fetch(`/wp-json/my-easy-compta/v1/quotes?${i}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(n=>n.json()).then(n=>{this.quotes=n.quotes,this.totalCount=n.total_count,this.totalPages=n.total_pages,this.currentPage=t,this.perPage=e,this.generatePaginationButtons()}).catch(n=>{console.error("Error fetching quotes with filters:",n)}).finally(()=>{this.loading=!1})},fetchClients(){fetch("/wp-json/my-easy-compta/v1/clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.clients=t.clients}).catch(t=>{console.error("Error fetching clients:",t)})},async loadSettings(){try{this.loadingPrice=!0;const{settings:t,currencySymbol:e,vatData:s}=await mn();this.settings=t,this.default_currency_symbol=e,this.default_vat=s,this.loadingPrice=!1}catch(t){this.showToast(t.message,"alert-error"),this.loadingPrice=!1}},calculateVAT(t){return so(t,this.default_vat.rate)},calculateWithoutVAT(t){return oo(t)},generatePaginationButtons(){this.paginationButtons=io(this.currentPage,this.totalPages)},goToPage(t){t!=="..."&&this.fetchQuotesWithFilters(t)},perPageChanged(){this.fetchQuotesWithFilters()},formatAmount(t,e){return ro(t,e,this.settings.currency_position)},confirmDuplicateQuote(t){this.selectedQuote=t,modal_confirm.showModal(),this.showRemoveModal=!0},duplicateQuote(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/duplicate/${t}`,{method:"POST",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Network response was not ok");return e.json()}).then(e=>{e.success?(this.fetchQuotesWithFilters(),this.showToast(e.message,"alert-success")):(this.showToast(e.message,"alert-error"),console.error("Error duplicate quote:",e.statusText))}).catch(e=>{console.log(e.message),this.showToast(e.message,"alert-error")})},confirmDeleteQuote(t){this.selectedQuote=t,modal_quotes_remove.showModal(),this.showRemoveModal=!0},deleteQuote(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/delete/${t}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Network response was not ok");return e.json()}).then(e=>{e.success?(this.fetchQuotesWithFilters(),this.showToast(e.message,"alert-success")):(this.showToast(e.message,"alert-error"),console.error("Error deleting quote:",e.statusText))}).catch(e=>{console.log(e.message),this.showToast(e.message,"alert-error")})},showToast(t,e){ao(this.toast,t,e)}},computed:{skeletonItems(){return Array.from({length:5},(t,e)=>e)},totalPages(){return Math.ceil(this.totalCount/this.perPage)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},lc={class:"pt-2 pr-4"},cc={class:"flex justify-between items-center"},dc={class:"card-title"},uc={class:"btn btn-primary rounded-full"},hc=r("i",{class:"fas fa-plus-circle"},null,-1),mc={key:0,class:"ms-2"},fc={class:"btn btn-outline btn-accent rounded-full hover:text-white",href:"/wp-admin/admin.php?page=my-easy-compta-export#tab2"},pc=r("i",{class:"fas fa-file-export"},null,-1),_c=["data-tip"],gc={class:"btn btn-outline btn-accent rounded-full",disabled:""},yc=r("i",{class:"fas fa-file-export"},null,-1),bc=r("div",{class:"divider mt-2"},null,-1),vc={class:"flex items-center mb-4"},wc={for:"perPageSelect",class:"mr-2"},xc=["value"],Ec={class:"overflow-x-auto"},Cc={class:"table w-full"},Tc={value:""},Ic=["value"],kc={value:""},Ac={value:"draft"},Sc={value:"pending"},Dc={value:"approved"},Pc={value:"rejected"},jc={class:"flex justify-center"},Rc={key:0},Mc={key:0,class:"badge badge-warning badge-outline badge-sm"},Oc={key:1,class:"badge badge-secondary badge-outline badge-sm"},qc={key:2,class:"badge badge-success badge-outline badge-sm"},Nc={key:3,class:"badge badge-error badge-outline badge-sm"},Bc={key:0},Vc={key:0},Fc={key:0},Uc={key:1},Lc={key:1},Wc={key:0},Xc={key:1},Hc={key:1},Qc=r("span",{class:"loading loading-bars loading-sm"},null,-1),zc=[Qc],Gc={key:0},Jc={key:1},Yc=r("span",{class:"loading loading-bars loading-sm"},null,-1),Kc=[Yc],Zc={key:0},$c={key:1},ed=r("span",{class:"loading loading-bars loading-sm"},null,-1),td=[ed],nd={class:"flex justify-end"},sd=["data-tip"],od=r("button",{class:"btn btn-circle mx-1"},[r("i",{class:"far fa-eye"})],-1),id=["data-tip"],rd=r("button",{class:"btn btn-circle mx-1"},[r("i",{class:"fas fa-pencil-alt"})],-1),ad=["data-tip"],ld=["onClick"],cd=r("i",{class:"far fa-copy"},null,-1),dd=[cd],ud=["data-tip"],hd=["onClick"],md=r("i",{class:"far fa-trash-alt"},null,-1),fd=[md],pd={key:0},_d=r("div",{class:"flex gap-4 items-center"},[r("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),r("div",{class:"flex flex-col gap-4 w-full"},[r("div",{class:"skeleton h-4 w-full"}),r("div",{class:"skeleton h-4 w-full"})])],-1),gd=r("div",{class:"divider my-1"},null,-1),yd=[_d,gd],bd={class:"join ecwp_pagination mt-6 pt-4"},vd=["onClick"];function wd(t,e,s,i,n,o){const a=O("confirm-modal"),l=O("remove-modal"),f=O("router-link"),d=O("Card");return u(),h("div",lc,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),P(a,{"show-modal":t.showConfirmModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,onConfirm:e[0]||(e[0]=m=>this.duplicateQuote(n.selectedQuote)),onCancel:e[1]||(e[1]=m=>t.showConfirmModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),P(l,{"modal-id":"modal_quotes_remove","show-modal":t.showRemoveModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:e[2]||(e[2]=m=>this.deleteQuote(n.selectedQuote)),onCancel:e[3]||(e[3]=m=>t.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),P(d,{topMargin:"mt-8"},{default:me(()=>[r("div",cc,[r("h2",dc,c(o.translations.quotes),1),r("div",null,[P(f,{to:{name:"QuoteNew"}},{default:me(()=>[r("button",uc,[C(c(o.translations.add)+" ",1),hc])]),_:1}),n.settings.easy_compta_export_addon_active==1?(u(),h("span",mc,[r("a",fc,[C(c(o.translations.export)+" ",1),pc])])):(u(),h("span",{key:1,class:"tooltip tooltip-left tooltip-warning ms-2","data-tip":o.translations.active_export_addon},[r("button",gc,[C(c(o.translations.export)+" ",1),yc])],8,_c))])]),bc,r("div",vc,[r("label",wc,c(o.translations.display_per_page),1),D(r("select",{id:"perPageSelect","onUpdate:modelValue":e[4]||(e[4]=m=>n.perPage=m),onChange:e[5]||(e[5]=(...m)=>o.perPageChanged&&o.perPageChanged(...m))},[(u(!0),h(F,null,U(n.perPageOptions,m=>(u(),h("option",{key:m,value:m},c(m),9,xc))),128))],544),[[ue,n.perPage]])]),r("div",Ec,[r("table",Cc,[r("thead",null,[r("tr",null,[r("th",null,[r("div",null,c(o.translations.quote_number),1),D(r("input",{"onUpdate:modelValue":e[6]||(e[6]=m=>n.filters.quote_number=m),onInput:e[7]||(e[7]=m=>o.fetchQuotesWithFilters()),type:"text",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[W,n.filters.quote_number]])]),r("th",null,[r("div",null,c(o.translations.client),1),D(r("select",{"onUpdate:modelValue":e[8]||(e[8]=m=>n.filters.client=m),onChange:e[9]||(e[9]=m=>o.fetchQuotesWithFilters()),class:"ecwp-input input-xs input-bordered mt-2"},[r("option",Tc,c(o.translations.all),1),(u(!0),h(F,null,U(n.clients,m=>(u(),h("option",{key:m.id,value:m.company_name},c(m.company_name),9,Ic))),128))],544),[[ue,n.filters.client]])]),r("th",null,[r("div",null,c(o.translations.status),1),D(r("select",{"onUpdate:modelValue":e[10]||(e[10]=m=>n.filters.status=m),onChange:e[11]||(e[11]=m=>o.fetchQuotesWithFilters()),class:"ecwp-input input-xs input-bordered mt-2"},[r("option",kc,c(o.translations.all_statuses),1),r("option",Ac,c(o.translations.draft),1),r("option",Sc,c(o.translations.pending),1),r("option",Dc,c(o.translations.approved),1),r("option",Pc,c(o.translations.rejected),1)],544),[[ue,n.filters.status]])]),r("th",null,[r("div",null,c(o.translations.total),1),D(r("input",{"onUpdate:modelValue":e[12]||(e[12]=m=>n.filters.total_amount=m),onInput:e[13]||(e[13]=m=>o.fetchQuotesWithFilters()),type:"text",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[W,n.filters.total_amount]])]),r("th",null,[r("div",null,c(o.translations.due_date),1),D(r("input",{"onUpdate:modelValue":e[14]||(e[14]=m=>n.filters.due_date=m),onInput:e[15]||(e[15]=m=>o.fetchQuotesWithFilters()),type:"date",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[W,n.filters.due_date]])]),r("th",null,[r("div",null,c(o.translations.created_at),1),D(r("input",{"onUpdate:modelValue":e[16]||(e[16]=m=>n.filters.created_at=m),onInput:e[17]||(e[17]=m=>o.fetchQuotesWithFilters()),type:"date",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[W,n.filters.created_at]])]),r("th",jc,c(o.translations.actions),1)])]),n.loading?g("",!0):(u(),h("tbody",Rc,[(u(!0),h(F,null,U(n.quotes,m=>(u(),h("tr",{key:m.id},[r("td",null,c(m.quote_number),1),r("td",null,c(m.client_name),1),r("td",null,[m.status=="draft"?(u(),h("span",Mc,c(o.translations.draft),1)):g("",!0),m.status=="pending"?(u(),h("span",Oc,c(o.translations.pending),1)):g("",!0),m.status=="approved"?(u(),h("span",qc,c(o.translations.approved),1)):g("",!0),m.status=="rejected"?(u(),h("span",Nc,c(o.translations.rejected),1)):g("",!0)]),r("td",null,[n.loadingPrice?(u(),h("div",Hc,zc)):(u(),h("div",Bc,[n.settings.vat_active==1?(u(),h("div",Vc,[n.default_currency_symbol==m.client_currency||m.client_currency==null?(u(),h("span",Fc,c(o.formatAmount(m.total_amount,n.default_currency_symbol)),1)):(u(),h("span",Uc,c(o.formatAmount(m.total_amount,m.client_currency)),1))])):(u(),h("div",Lc,[n.default_currency_symbol==m.client_currency||m.client_currency==null?(u(),h("span",Wc,c(o.formatAmount(m.total_amount,n.default_currency_symbol)),1)):(u(),h("span",Xc,c(o.formatAmount(m.total_amount,m.client_currency)),1))]))]))]),r("td",null,[n.loadingPrice?(u(),h("div",Jc,Kc)):(u(),h("div",Gc,c(m.due_date),1))]),r("td",null,[n.loadingPrice?(u(),h("div",$c,td)):(u(),h("div",Zc,c(m.created),1))]),r("td",nd,[r("span",{class:"lg:tooltip","data-tip":o.translations.view},[P(f,{to:{name:"QuoteViewDetail",params:{id:m.id}}},{default:me(()=>[od]),_:2},1032,["to"])],8,sd),r("span",{class:"lg:tooltip","data-tip":o.translations.edit},[P(f,{to:{name:"QuoteEdit",params:{id:m.id}}},{default:me(()=>[rd]),_:2},1032,["to"])],8,id),r("span",{class:"lg:tooltip","data-tip":o.translations.duplicate},[r("button",{onClick:p=>o.confirmDuplicateQuote(m.id),class:"btn btn-circle text-purple-600 hover:text-purple-900 mx-1"},dd,8,ld)],8,ad),r("span",{class:"lg:tooltip","data-tip":o.translations.delete},[r("button",{onClick:p=>o.confirmDeleteQuote(m.id),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},fd,8,hd)],8,ud)])]))),128))]))]),n.loading?(u(),h("div",pd,[(u(!0),h(F,null,U(n.skeletonRows,m=>(u(),h("div",{key:m,class:"flex flex-col gap-4 w-full"},yd))),128))])):g("",!0)]),r("div",bd,[(u(!0),h(F,null,U(n.paginationButtons,m=>(u(),h("button",{key:m,class:I(["join-item btn",{"btn-disabled":m==="..."||m===n.currentPage}]),onClick:p=>o.goToPage(m)},c(m),11,vd))),128))])]),_:1})])}var xd=ne(ac,[["render",wd]]);const Ed={name:"sendQuote",components:{VueEditor:mt.exports.VueEditor},props:{showModal:Boolean,modalId:String,client:Object,quoteId:Number,loading:Boolean,subject:String,content:String},data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{loading:!1,loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},toolbarOptions:[["bold","italic","underline","strike"],["link"],[{list:"ordered"},{list:"bullet"}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{align:[]}],[{align:"right"},{align:"center"},{align:"justify"}],["clean"]],fields:{client_email:{label:t.client,value:"",disabled:!0},email_subject:{label:t.email_subject,value:""},email_message:{label:t.email_content,value:"",type:"textarea"}}}},watch:{client:{immediate:!0,handler(t){this.fields.client_email.value=(t==null?void 0:t.email)||""}},subject:{immediate:!0,handler(t){this.fields.email_subject.value=t||""}},content:{immediate:!0,handler(t){this.fields.email_message.value=t||""}}},computed:{skeletonItems(){return Array.from({length:10},(t,e)=>e)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const t=await fetch("/wp-json/my-easy-compta/v1/emails/send-email",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({type:"quote",id:this.quoteId,client_email:this.client.email,email_subject:this.fields.email_subject.value,email_message:this.fields.email_message.value})});if(t.ok){const e=await t.json();this.loadingBtn=!1,this.closeModal(),this.showToast(e.message,"alert-success")}else{const e=`Error sending email: ${t.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(t){const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Error sending email";this.showToast(e,"alert-error"),console.error("Error sending email:",t),this.loadingBtn=!1}},updateFieldValue(t,e){this.fields[t].value=e},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},Cd=["id","open"],Td={class:"modal-box"},Id={class:"font-bold text-lg"},kd={key:0},Ad={class:"grid grid-cols-1 gap-4"},Sd=r("div",{class:"skeleton h-4 w-full mb-2"},null,-1),Dd=r("div",{class:"skeleton h-4 w-full"},null,-1),Pd=[Sd,Dd],jd={class:"grid grid-cols-1 gap-4"},Rd=["type"],Md=["for"],Od=["id","value","disabled","onInput"],qd={key:1},Nd=["for"],Bd={class:"form-group mt-4 flex justify-end"},Vd=["disabled"],Fd={key:0,class:"loading loading-spinner loading-sm"};function Ud(t,e,s,i,n,o){const a=O("vue-editor");return u(),h("div",null,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),r("dialog",{id:s.modalId,class:"modal",open:s.showModal},[r("div",Td,[r("h3",Id,c(o.translations.send_quote),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=l=>o.closeModal())}," \u2715 "),n.loading?(u(),h("div",kd,[r("div",Ad,[(u(!0),h(F,null,U(o.skeletonItems,l=>(u(),h("div",{key:l,class:"py-2"},Pd))),128))])])):(u(),h("form",{key:1,onSubmit:e[1]||(e[1]=J((...l)=>o.submitForm&&o.submitForm(...l),["prevent"])),class:"form"},[r("div",jd,[(u(!0),h(F,null,U(n.fields,(l,f)=>(u(),h("div",{key:f,class:"ecwp-group form-group"},[l.type!=="textarea"?(u(),h("div",{key:0,type:l.type||"text"},[r("label",{for:f,class:"ecwp-label form-label"},c(l.label),9,Md),r("input",{id:f,class:I(["ecwp-input input input-bordered",l.class||"w-full"]),value:l.value,disabled:l.disabled,onInput:d=>o.updateFieldValue(f,d.target.value)},null,42,Od)],8,Rd)):(u(),h("div",qd,[r("label",{for:f,class:"form-label"},c(l.label),9,Nd),P(a,{modelValue:l.value,"onUpdate:modelValue":d=>l.value=d,editorToolbar:n.toolbarOptions},null,8,["modelValue","onUpdate:modelValue","editorToolbar"])]))]))),128))]),r("div",Bd,[r("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(c(o.translations.send)+" ",1),n.loadingBtn?(u(),h("span",Fd)):g("",!0)],8,Vd)])],32))])],8,Cd)])}var Ld=ne(Ed,[["render",Ud]]);const Wd={components:{VueDatePicker:Nt},props:{isVisible:{type:Boolean,default:!1},title:{type:String,default:"Confirmation"},message:{type:String,default:"Are you sure?"},confirmText:{type:String,default:"Confirm"},cancelText:{type:String,default:"Cancel"},totalAmount:{type:String,required:!0},currency:{type:String,required:!0},advanceSold:{type:String,required:!0},quoteId:{type:Number,required:!0}},data(){return{showError:!1,selectedType:"",inputValue:0,due_date:"",invoiceSolded:!1,establishedAdvances:[],loading:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return t=>{if(!t)return"";const e=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getFullYear();return`${e}-${s}-${i}`}},remainingAmount(){this.loading=!0;const t=this.establishedAdvances.reduce((e,s)=>{const i=parseFloat(s.advance_amount);return isNaN(i)?(console.error("Erreur: advance_amount n'est pas un nombre valide",s.advance_amount),e):e+i},0);return this.totalAmount-t},inputValueExceeds(){return this.remainingAmount==0?!0:this.selectedType==="percentage"?this.calculatedAmount>this.remainingAmount:this.selectedType==="fixed"?this.inputValue>this.remainingAmount:!1},calculatedAmount(){return this.selectedType==="percentage"?this.inputValue/100*this.remainingAmount:this.inputValue}},created(){this.fetchEstablishedAdvances(this.quoteId)},methods:{fetchEstablishedAdvances(t){const e=`/wp-json/my-easy-compta/v1/advance/${t}`;fetch(e,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>s.json()).then(s=>{this.establishedAdvances=s}).catch(s=>{console.error("Error fetching advances:",s)})},onConfirm(){if(!this.inputValueExceeds){if(this.advanceSold=="no_sold"){if(!this.inputValue||!this.due_date||this.advanceSold=="no_sold"&&!this.selectedType){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.$emit("confirm",{type:this.selectedType,value:this.inputValue,date:this.due_date})}else{if(!this.due_date){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.$emit("confirm",{type:"fixed",value:this.remainingAmount,date:this.due_date})}this.closeModal()}},onCancel(){this.$emit("cancel"),this.closeModal()},closeModal(){document.getElementById("modal_advance").close()},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},Xd=["open"],Hd={class:"modal-box overflow-visible"},Qd={class:"font-bold text-lg"},zd={class:"text-lg font-semibold text-center"},Gd={class:"my-4 text-center text-xl"},Jd={key:0,class:"text-red-500 text-sm"},Yd={class:"grid grid-cols-2 gap-4"},Kd={key:0},Zd={class:"flex ecwp-group form-group mb-4"},$d=r("label",{for:"advance-type",class:"ecwp-label"},"Type",-1),eu=r("option",{value:"percentage"},"Pourcentage",-1),tu=r("option",{value:"fixed"},"Montant fixe",-1),nu=[eu,tu],su={key:1},ou={class:"flex ecwp-group form-group mb-4"},iu=r("label",{for:"advance-type",class:"ecwp-label"},"Valeur",-1),ru={class:"absolute items-center border rounded-md right-0 top-6"},au={class:"px-3 py-2.5 rounded-l-md bg-base-300 border-r"},lu={key:0},cu={key:1},du={key:1,class:"mt-2"},uu={class:"text-sm"},hu={key:2,class:"flex ecwp-group form-group mb-4"},mu={for:"quoteDate",class:"ecwp-label"},fu={key:3},pu={class:"flex justify-between space-x-4 mt-4"},_u=["disabled"];function gu(t,e,s,i,n,o){const a=O("VueDatePicker");return u(),h("div",null,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),r("dialog",{id:"modal_advance",class:"modal",open:s.isVisible},[r("div",Hd,[r("h3",Qd,c(t.modalTitle),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...l)=>o.closeModal&&o.closeModal(...l))}," \u2715 "),r("h2",zd,c(s.title),1),r("p",Gd," Montant total restant : "+c(o.remainingAmount)+" "+c(s.currency),1),o.inputValueExceeds&&!n.invoiceSolded?(u(),h("p",Jd," Le montant s\xE9lectionn\xE9 d\xE9passe le montant total du devis. ")):g("",!0),r("div",Yd,[s.advanceSold=="no_sold"&&!n.invoiceSolded?(u(),h("div",Kd,[r("div",Zd,[$d,D(r("select",{"onUpdate:modelValue":e[1]||(e[1]=l=>n.selectedType=l),id:"advance-type",class:I(["ecwp-select ecwp-input input input-bordered w-full",{"input-error":!n.selectedType&&n.showError}])},nu,2),[[ue,n.selectedType]])])])):g("",!0),n.selectedType&&s.advanceSold=="no_sold"&&!n.invoiceSolded?(u(),h("div",su,[r("div",ou,[iu,D(r("input",{"onUpdate:modelValue":e[2]||(e[2]=l=>n.inputValue=l),type:"text",id:"advance-value",class:I([{"input-error":!n.inputValue&&n.showError},"ecwp-input input input-bordered w-full"])},null,2),[[W,n.inputValue]]),r("div",ru,[r("div",au,[n.selectedType==="percentage"?(u(),h("span",lu,"%")):(u(),h("span",cu,c(s.currency),1))])])])])):g("",!0)]),n.selectedType==="percentage"&&!o.inputValueExceeds&!n.invoiceSolded?(u(),h("div",du,[r("p",uu," Montant bas\xE9 sur le pourcentage: "+c(o.calculatedAmount)+" "+c(s.currency),1)])):g("",!0),n.invoiceSolded?g("",!0):(u(),h("div",hu,[r("label",mu,c(o.translations.due_date),1),P(a,{class:I(["ecwp-input ecwp-date input input-bordered w-full",[!n.inputValue&&n.showError?"input-error":""]]),id:"quoteDate",modelValue:n.due_date,"onUpdate:modelValue":e[3]||(e[3]=l=>n.due_date=l),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date,locale:"fr",required:""},null,8,["modelValue","format","min-date","class"])])),n.invoiceSolded?(u(),h("div",fu,"Facture d\xE9j\xE0 sold\xE9")):g("",!0),r("div",pu,[r("button",{onClick:e[4]||(e[4]=(...l)=>o.onCancel&&o.onCancel(...l)),class:"btn btn-secondary rounded-full"},c(s.cancelText),1),r("button",{onClick:e[5]||(e[5]=(...l)=>o.onConfirm&&o.onConfirm(...l)),disabled:o.inputValueExceeds,class:"btn rounded-full btn-error text-white"},c(s.confirmText),9,_u)])])],8,Xd)])}var yu=ne(Wd,[["render",gu]]);const bu={name:"QuoteNavBar",components:{SendQuoteModal:Ld,ConfirmModal:ds,AdvanceModal:yu},props:{quoteInfo:Object,emailActive:Number,advanceActive:Number,currency:String,noItems:Boolean},data(){return{selectedQuote:null,advanceSold:!1,sendQuoteModal:!1,loadingModal:!1,loadingPdf:!1,loading:!1,client_detail:null,subject:"",content:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{async changeQuoteStatus(t){try{const s=await(await fetch("/wp-json/my-easy-compta/v1/quotes/update-status",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({id:this.quoteInfo.id,status:t})})).json();s.success?(this.quoteInfo.status=t,this.quoteInfo.total_amount=s.total_amount,this.showToast(s.message,"alert-success")):(console.error("Failed to update quote status:",s.message),this.showToast(s.message,"alert-error"))}catch(e){console.error("An error occurred while updating quote status:",e),this.showToast(e,"alert-error")}},convertToInvoice(t){fetch(`/wp-json/my-easy-compta/v1/quotes/convert-quote/${t}`,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{e.success?(this.showToast(e.message,"alert-success"),this.$router.push({name:"InvoiceViewDetail",params:{id:e.id}})):this.showToast(e.message,"alert-error")}).catch(e=>{console.error("Error converting quote:",e),this.showToast(e.message,"alert-error")})},handleAdvanceInvoiceConfirm(t){const{type:e,value:s,date:i}=t;this.convertAdvanceInvoice(this.selectedQuote,e,s,i)},convertAdvanceInvoice(t,e,s,i){fetch(`/wp-json/my-easy-compta/v1/quotes/convert-advance/${t}`,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({advance_type:e,advance_value:s,advance_date:i})}).then(n=>n.json()).then(n=>{n.success?(this.showToast(n.message,"alert-success"),this.$router.push({name:"InvoiceViewDetail",params:{id:n.id}})):this.showToast(n.message,"alert-error")}).catch(n=>{console.error("Error converting quote:",n),this.showToast(n.message,"alert-error")})},confirmConvertQuote(t){this.selectedQuote=t,modal_confirm.showModal(),this.showRemoveModal=!0},ConvertAdvanceQuote(t,e){this.selectedQuote=t,this.advanceSold=e,modal_advance.showModal(),this.showRemoveModal=!0},exportToPDF(){this.loadingPdf=!0;const t=this.quoteInfo.id;fetch(`/wp-json/my-easy-compta/v1/quotes/pdf/${t}`,{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw this.loadingPdf=!1,new Error("Network response was not ok");return this.loadingPdf=!1,e.blob()}).then(e=>{const s=URL.createObjectURL(e);window.open(s),this.loadingPdf=!1}).catch(e=>{console.error("There was a problem with the fetch operation:",e),this.loadingPdf=!1})},sendQuote(t){this.loadingModal=!0,this.sendQuoteModal=!0,modal_send_quote.showModal(),this.fetchClient(t),this.fetchSettings()},fetchClient(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/clients/details/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Client not found");return e.json()}).then(e=>{this.client_detail=e,this.loading=!1}).catch(e=>{console.error("Error fetching client info:",e),this.loading=!1})},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok){const e=await t.json();this.subject=e.email_quote_subject,this.content=e.email_quote_content,this.loading=!1}else{const e=await t.json();this.showToast(e.message,"alert-error"),this.loading=!1}}catch(t){this.loading=!1,this.showToast(t.message,"alert-error")}},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},vu={key:0},wu={key:1},xu={key:3,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},Eu=r("span",{class:"loading loading-spinner text-primary loading-lg"},null,-1),Cu=[Eu],Tu={class:"navbar bg-base-100 mb-4 shadow-xl rounded-box flex justify-between"},Iu=r("div",{class:"dropdown"},[r("div",{tabindex:"0",role:"button",class:"btn btn-ghost lg:hidden"},[r("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 6h16M4 12h8m-8 6h16"})])]),r("ul",{tabindex:"0",class:"menu menu-sm dropdown-content mt-3 z-[1] p-2 shadow bg-base-100 rounded-box w-52"},[r("li",null,[r("a",null,"Item 1")]),r("li",null,[r("a",null,"Parent"),r("ul",{class:"p-2"},[r("li",null,[r("a",null,"Submenu 1")]),r("li",null,[r("a",null,"Submenu 2")])])]),r("li",null,[r("a",null,"Item 3")])])],-1),ku={class:"hidden lg:flex gap-2"},Au={class:"btn btn-sm"},Su=r("i",{class:"far fa-edit"},null,-1),Du=r("i",{class:"fa fa-check"},null,-1),Pu=["data-tip"],ju={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},Ru=r("i",{class:"fas fa-check"},null,-1),Mu=r("i",{class:"fa fa-check"},null,-1),Ou=r("i",{class:"fa fa-times"},null,-1),qu={key:4},Nu={class:"dropdown"},Bu={tabindex:"0",role:"button",class:"btn btn-sm"},Vu=r("i",{class:"fas fa-exchange-alt"},null,-1),Fu={tabindex:"0",class:"dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow"},Uu={key:0},Lu={key:5},Wu=r("i",{class:"fas fa-exchange-alt"},null,-1),Xu={class:"flex gap-2"},Hu=r("i",{class:"fas fa-paper-plane"},null,-1),Qu={key:0},zu={key:1},Gu={key:2,class:"far fa-envelope"},Ju=["data-tip"],Yu={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},Ku=r("i",{class:"fas fa-paper-plane"},null,-1),Zu=["data-tip"],$u={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},eh=r("i",{class:"fas fa-paper-plane"},null,-1),th=["disabled"],nh=r("i",{class:"far fa-file-pdf"},null,-1),sh={key:0,class:"loading loading-spinner loading-sm"};function oh(t,e,s,i,n,o){const a=O("send-quote-modal"),l=O("confirm-modal"),f=O("advance-modal"),d=O("router-link");return u(),h("div",null,[s.emailActive==1?(u(),h("div",vu,[P(a,{loading:n.loadingModal,"show-modal":n.sendQuoteModal,"modal-id":"modal_send_quote",client:n.client_detail,"quote-id":s.quoteInfo.id,subject:n.subject,content:n.content,onClose:e[0]||(e[0]=m=>n.sendQuoteModal=!1)},null,8,["loading","show-modal","client","quote-id","subject","content"])])):g("",!0),P(l,{"show-modal":t.showConfirmModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,onConfirm:e[1]||(e[1]=m=>this.convertToInvoice(n.selectedQuote)),onCancel:e[2]||(e[2]=m=>t.showConfirmModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),s.advanceActive==1?(u(),h("div",wu,[P(f,{"show-modal":t.showConfirmModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,"total-amount":s.quoteInfo.total_amount,currency:s.currency,quoteId:s.quoteInfo.id,"advance-sold":n.advanceSold,onConfirm:o.handleAdvanceInvoiceConfirm,onCancel:e[3]||(e[3]=m=>t.showConfirmModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText","total-amount","currency","quoteId","advance-sold","onConfirm"])])):g("",!0),n.toast.visible?(u(),h("div",{key:2,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),n.loading?(u(),h("div",xu,Cu)):g("",!0),r("div",Tu,[r("div",null,[Iu,r("div",ku,[P(d,{to:{name:"QuoteEdit",params:{id:s.quoteInfo.id}}},{default:me(()=>[r("button",Au,[Su,C(c(o.translations.edit_quote),1)])]),_:1},8,["to"]),s.quoteInfo.status=="draft"&&!s.noItems?(u(),h("button",{key:0,class:"btn btn-outline btn-success btn-sm",onClick:e[4]||(e[4]=m=>o.changeQuoteStatus("pending"))},[Du,C(" "+c(o.translations.validate_quote),1)])):g("",!0),s.quoteInfo.status=="draft"&&s.noItems?(u(),h("div",{key:1,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.min_article},[r("button",ju,[Ru,C(" "+c(o.translations.validate_quote),1)])],8,Pu)):g("",!0),(s.quoteInfo.status=="pending"||s.quoteInfo.status=="rejected")&&!s.noItems?(u(),h("button",{key:2,class:"btn btn-outline btn-success btn-sm",onClick:e[5]||(e[5]=m=>o.changeQuoteStatus("approved"))},[Mu,C(" "+c(o.translations.mark_as_accepted),1)])):g("",!0),(s.quoteInfo.status=="pending"||s.quoteInfo.status=="approved")&&!s.noItems?(u(),h("button",{key:3,class:"btn btn-outline btn-error btn-sm",onClick:e[6]||(e[6]=m=>o.changeQuoteStatus("rejected"))},[Ou,C(" "+c(o.translations.mark_as_rejected),1)])):g("",!0),s.advanceActive==1&&s.quoteInfo.converted!=1&&s.quoteInfo.status=="approved"&&!s.noItems?(u(),h("div",qu,[r("div",Nu,[r("div",Bu,[Vu,C(" "+c(o.translations.convertToInvoice),1)]),r("ul",Fu,[s.quoteInfo.advance!=1?(u(),h("li",Uu,[r("a",{href:"#",onClick:e[7]||(e[7]=J(m=>o.confirmConvertQuote(s.quoteInfo.id),["prevent"]))}," Facture global ")])):g("",!0),r("li",null,[r("a",{href:"#",onClick:e[8]||(e[8]=J(m=>o.ConvertAdvanceQuote(s.quoteInfo.id,"no_sold"),["prevent"]))}," Facture d'acompte "),s.quoteInfo.advance!=0?(u(),h("a",{key:0,href:"#",onClick:e[9]||(e[9]=J(m=>o.ConvertAdvanceQuote(s.quoteInfo.id,"sold"),["prevent"]))}," Facture du solde ")):g("",!0)])])])])):g("",!0),s.advanceActive!=1&&s.quoteInfo.converted!=1&&s.quoteInfo.status=="approved"&&!s.noItems?(u(),h("div",Lu,[r("button",{onClick:e[10]||(e[10]=m=>o.confirmConvertQuote(s.quoteInfo.id)),class:"btn btn-sm"},[Wu,C(" "+c(o.translations.convertToInvoice),1)])])):g("",!0)])]),r("div",Xu,[s.emailActive==1&&s.quoteInfo.status!="draft"?(u(),h("button",{key:0,onClick:e[11]||(e[11]=J(m=>o.sendQuote(s.quoteInfo.client_id),["prevent"])),class:"btn btn-outline btn-primary btn-sm hover:text-white"},[Hu,s.quoteInfo.sent==1?(u(),h("span",Qu,c(o.translations.resend_quote),1)):(u(),h("span",zu,c(o.translations.send_quote),1)),s.quoteInfo.sent==1?(u(),h("i",Gu)):g("",!0)])):s.emailActive==1&&s.quoteInfo.status=="draft"?(u(),h("div",{key:1,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.quote_draft_cannot_send},[r("button",Yu,[Ku,C(" "+c(o.translations.send_quote),1)])],8,Ju)):(u(),h("div",{key:2,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.active_email_addon},[r("button",$u,[eh,C(" "+c(o.translations.send_quote),1)])],8,Zu)),r("button",{onClick:e[12]||(e[12]=(...m)=>o.exportToPDF&&o.exportToPDF(...m)),class:"btn btn-outline btn-success btn-sm",disabled:n.loadingPdf},[nh,C(" "+c(o.translations.exportToPDF)+" ",1),n.loadingPdf?(u(),h("span",sh)):g("",!0)],8,th)])])])}var ih=ne(bu,[["render",oh]]);const rh={components:{VueEditor:mt.exports.VueEditor},props:{loading:Boolean,showModal:Boolean,modalId:String,modalTitle:String,item:Object},data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{editedItem:{...this.item},loading:this.loading,loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},fields:{item_name:{label:t.item_name},item_description:{label:t.description,type:"textarea"},quantity:{label:t.quantity,type:"number"},vat_rate:{label:t.vat,type:"number"},unit_price:{label:t.unit_price,type:"number"},discount:{label:t.discount,type:"number"}}}},computed:{skeletonItems(){return Array.from({length:10},(t,e)=>e)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const t=await fetch(`/wp-json/my-easy-compta/v1/quotes/edit-item/${this.editedItem.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.editedItem)});if(t.ok){const e=await t.json();this.loadingBtn=!1,this.closeModal(),this.showToast(e.message,"alert-success"),this.$emit("itemEdited")}else{const e=`Error editing item: ${t.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(t){const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Error editing item";this.showToast(e,"alert-error"),console.error("Error editing item:",t),this.loadingBtn=!1}},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},resize(){let t=this.$refs.textarea;t.style.height="auto",t.style.height=t.scrollHeight+"px"},increase(){this.newItem.quantity++},decrease(){this.newItem.quantity>1&&this.newItem.quantity--}},watch:{item:{handler(t){this.editedItem={...t}},immediate:!0}}},ah=["id","open"],lh={class:"modal-box"},ch={class:"font-bold text-lg"},dh={key:0},uh={class:"grid grid-cols-1 gap-4"},hh=r("div",{class:"skeleton h-4 w-full mb-2"},null,-1),mh=r("div",{class:"skeleton h-4 w-full"},null,-1),fh=[hh,mh],ph={class:"grid grid-cols-1 gap-4"},_h=["type"],gh=["for"],yh=["id","onUpdate:modelValue"],bh={key:1},vh=["for"],wh={class:"form-group mt-4 flex justify-end"},xh=["disabled"],Eh={key:0,class:"loading loading-spinner loading-sm"};function Ch(t,e,s,i,n,o){const a=O("vue-editor");return u(),h("div",null,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),r("dialog",{id:s.modalId,class:"modal",open:s.showModal},[r("div",lh,[r("h3",ch,c(s.modalTitle),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=l=>o.closeModal())}," \u2715 "),n.loading?(u(),h("div",dh,[r("div",uh,[(u(!0),h(F,null,U(o.skeletonItems,l=>(u(),h("div",{key:l,class:"py-2"},fh))),128))])])):(u(),h("form",{key:1,onSubmit:e[1]||(e[1]=J((...l)=>o.submitForm&&o.submitForm(...l),["prevent"])),class:"form"},[r("div",ph,[(u(!0),h(F,null,U(n.fields,(l,f)=>(u(),h("div",{key:f,class:"ecwp-group form-group"},[l.type!=="textarea"?(u(),h("div",{key:0,type:l.type||"text"},[r("label",{for:f,class:"ecwp-label form-label"},c(l.label),9,gh),D(r("input",{id:f,"onUpdate:modelValue":d=>n.editedItem[f]=d,class:I(["ecwp-input input input-bordered",l.class||"w-full"])},null,10,yh),[[W,n.editedItem[f]]])],8,_h)):(u(),h("div",bh,[r("label",{for:f,class:"form-label"},c(l.label),9,vh),P(a,{id:f,modelValue:n.editedItem[f],"onUpdate:modelValue":d=>n.editedItem[f]=d,editorToolbar:t.toolbarOptions},null,8,["id","modelValue","onUpdate:modelValue","editorToolbar"])]))]))),128))]),r("div",wh,[r("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(c(o.translations.save)+" ",1),n.loadingBtn?(u(),h("span",Eh)):g("",!0)],8,xh)])],32))])],8,ah)])}var Th=ne(rh,[["render",Ch]]);const Ih={props:{showModal:Boolean,modalId:String,modalTitle:String},data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{articles:[],translations:t}},computed:{skeletonItems(){return Array.from({length:7},(t,e)=>e)}},mounted(){this.fetchArticlesList()},methods:{closeModal(){const t=document.getElementById(this.modalId);t&&(t.close(),this.$emit("close"))},selectItem(t){this.$emit("select-article",t),this.closeModal()},fetchArticlesList(){this.loading=!0,fetch("/wp-json/my-easy-compta/v1/articles",{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.articles=t,this.loading=!1}).catch(t=>{console.error("Erreur lors du chargement des articles :",t),this.loading=!1})}}},kh=["id","open"],Ah={class:"modal-box"},Sh={class:"font-bold text-lg"},Dh={key:0},Ph={key:0,class:""},jh=["onClick"],Rh={key:1},Mh={class:"grid grid-cols-2 gap-4"},Oh=r("div",{class:"skeleton h-4 w-full mb-2"},null,-1),qh=r("div",{class:"skeleton h-4 w-full"},null,-1),Nh=[Oh,qh];function Bh(t,e,s,i,n,o){return u(),h("dialog",{id:s.modalId,class:"modal",open:s.showModal},[r("div",Ah,[r("h3",Sh,c(s.modalTitle),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=a=>o.closeModal())}," \u2715 "),n.articles?(u(),h("div",Dh,[n.articles.length?(u(),h("ul",Ph,[(u(!0),h(F,null,U(n.articles,a=>(u(),h("li",{key:a.name,onClick:l=>o.selectItem(a),class:"flex justify-between autocomplete-item hover:bg-base-200"},[r("span",null,[r("strong",null,c(a.ref),1),C(" - "+c(a.name),1)]),r("span",null,[r("strong",null,c(a.unit_price),1)])],8,jh))),128))])):g("",!0)])):(u(),h("div",Rh,[r("div",Mh,[(u(!0),h(F,null,U(o.skeletonItems,a=>(u(),h("div",{key:a,class:"py-2"},Nh))),128))])]))])],8,kh)}var Qo=ne(Ih,[["render",Bh]]);/**!
     10  */const rt=typeof document!="undefined";function wa(t){return t.__esModule||t[Symbol.toStringTag]==="Module"}const G=Object.assign;function Sn(t,e){const s={};for(const i in e){const n=e[i];s[i]=De(n)?n.map(t):t(n)}return s}const Tt=()=>{},De=Array.isArray,jo=/#/g,xa=/&/g,Ea=/\//g,Ca=/=/g,Ta=/\?/g,Mo=/\+/g,Ia=/%5B/g,ka=/%5D/g,Oo=/%5E/g,Aa=/%60/g,qo=/%7B/g,Sa=/%7C/g,No=/%7D/g,Da=/%20/g;function ls(t){return encodeURI(""+t).replace(Sa,"|").replace(Ia,"[").replace(ka,"]")}function Pa(t){return ls(t).replace(qo,"{").replace(No,"}").replace(Oo,"^")}function Gn(t){return ls(t).replace(Mo,"%2B").replace(Da,"+").replace(jo,"%23").replace(xa,"%26").replace(Aa,"`").replace(qo,"{").replace(No,"}").replace(Oo,"^")}function Ra(t){return Gn(t).replace(Ca,"%3D")}function ja(t){return ls(t).replace(jo,"%23").replace(Ta,"%3F")}function Ma(t){return t==null?"":ja(t).replace(Ea,"%2F")}function Mt(t){try{return decodeURIComponent(""+t)}catch{}return""+t}const Oa=/\/$/,qa=t=>t.replace(Oa,"");function Dn(t,e,s="/"){let i,n={},o="",a="";const l=e.indexOf("#");let f=e.indexOf("?");return l<f&&l>=0&&(f=-1),f>-1&&(i=e.slice(0,f),o=e.slice(f+1,l>-1?l:e.length),n=t(o)),l>-1&&(i=i||e.slice(0,l),a=e.slice(l,e.length)),i=Fa(i!=null?i:e,s),{fullPath:i+(o&&"?")+o+a,path:i,query:n,hash:Mt(a)}}function Na(t,e){const s=e.query?t(e.query):"";return e.path+(s&&"?")+s+(e.hash||"")}function Ss(t,e){return!e||!t.toLowerCase().startsWith(e.toLowerCase())?t:t.slice(e.length)||"/"}function Ba(t,e,s){const i=e.matched.length-1,n=s.matched.length-1;return i>-1&&i===n&&dt(e.matched[i],s.matched[n])&&Bo(e.params,s.params)&&t(e.query)===t(s.query)&&e.hash===s.hash}function dt(t,e){return(t.aliasOf||t)===(e.aliasOf||e)}function Bo(t,e){if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const s in t)if(!Va(t[s],e[s]))return!1;return!0}function Va(t,e){return De(t)?Ds(t,e):De(e)?Ds(e,t):t===e}function Ds(t,e){return De(e)?t.length===e.length&&t.every((s,i)=>s===e[i]):t.length===1&&t[0]===e}function Fa(t,e){if(t.startsWith("/"))return t;if(!t)return e;const s=e.split("/"),i=t.split("/"),n=i[i.length-1];(n===".."||n===".")&&i.push("");let o=s.length-1,a,l;for(a=0;a<i.length;a++)if(l=i[a],l!==".")if(l==="..")o>1&&o--;else break;return s.slice(0,o).join("/")+"/"+i.slice(a).join("/")}const Qe={path:"/",name:void 0,params:{},query:{},hash:"",fullPath:"/",matched:[],meta:{},redirectedFrom:void 0};var Ot;(function(t){t.pop="pop",t.push="push"})(Ot||(Ot={}));var It;(function(t){t.back="back",t.forward="forward",t.unknown=""})(It||(It={}));function Ua(t){if(!t)if(rt){const e=document.querySelector("base");t=e&&e.getAttribute("href")||"/",t=t.replace(/^\w+:\/\/[^\/]+/,"")}else t="/";return t[0]!=="/"&&t[0]!=="#"&&(t="/"+t),qa(t)}const La=/^[^#]+#/;function Wa(t,e){return t.replace(La,"#")+e}function Xa(t,e){const s=document.documentElement.getBoundingClientRect(),i=t.getBoundingClientRect();return{behavior:e.behavior,left:i.left-s.left-(e.left||0),top:i.top-s.top-(e.top||0)}}const vn=()=>({left:window.scrollX,top:window.scrollY});function Ha(t){let e;if("el"in t){const s=t.el,i=typeof s=="string"&&s.startsWith("#"),n=typeof s=="string"?i?document.getElementById(s.slice(1)):document.querySelector(s):s;if(!n)return;e=Xa(n,t)}else e=t;"scrollBehavior"in document.documentElement.style?window.scrollTo(e):window.scrollTo(e.left!=null?e.left:window.scrollX,e.top!=null?e.top:window.scrollY)}function Ps(t,e){return(history.state?history.state.position-e:-1)+t}const Jn=new Map;function za(t,e){Jn.set(t,e)}function Qa(t){const e=Jn.get(t);return Jn.delete(t),e}let Ga=()=>location.protocol+"//"+location.host;function Vo(t,e){const{pathname:s,search:i,hash:n}=e,o=t.indexOf("#");if(o>-1){let l=n.includes(t.slice(o))?t.slice(o).length:1,f=n.slice(l);return f[0]!=="/"&&(f="/"+f),Ss(f,"")}return Ss(s,t)+i+n}function Ja(t,e,s,i){let n=[],o=[],a=null;const l=({state:y})=>{const _=Vo(t,location),v=s.value,x=e.value;let R=0;if(y){if(s.value=_,e.value=y,a&&a===v){a=null;return}R=x?y.position-x.position:0}else i(_);n.forEach(q=>{q(s.value,v,{delta:R,type:Ot.pop,direction:R?R>0?It.forward:It.back:It.unknown})})};function f(){a=s.value}function d(y){n.push(y);const _=()=>{const v=n.indexOf(y);v>-1&&n.splice(v,1)};return o.push(_),_}function m(){const{history:y}=window;!y.state||y.replaceState(G({},y.state,{scroll:vn()}),"")}function p(){for(const y of o)y();o=[],window.removeEventListener("popstate",l),window.removeEventListener("beforeunload",m)}return window.addEventListener("popstate",l),window.addEventListener("beforeunload",m,{passive:!0}),{pauseListeners:f,listen:d,destroy:p}}function Rs(t,e,s,i=!1,n=!1){return{back:t,current:e,forward:s,replaced:i,position:window.history.length,scroll:n?vn():null}}function Ya(t){const{history:e,location:s}=window,i={value:Vo(t,s)},n={value:e.state};n.value||o(i.value,{back:null,current:i.value,forward:null,position:e.length-1,replaced:!0,scroll:null},!0);function o(f,d,m){const p=t.indexOf("#"),y=p>-1?(s.host&&document.querySelector("base")?t:t.slice(p))+f:Ga()+t+f;try{e[m?"replaceState":"pushState"](d,"",y),n.value=d}catch(_){console.error(_),s[m?"replace":"assign"](y)}}function a(f,d){const m=G({},e.state,Rs(n.value.back,f,n.value.forward,!0),d,{position:n.value.position});o(f,m,!0),i.value=f}function l(f,d){const m=G({},n.value,e.state,{forward:f,scroll:vn()});o(m.current,m,!0);const p=G({},Rs(i.value,f,null),{position:m.position+1},d);o(f,p,!1),i.value=f}return{location:i,state:n,push:l,replace:a}}function Ka(t){t=Ua(t);const e=Ya(t),s=Ja(t,e.state,e.location,e.replace);function i(o,a=!0){a||s.pauseListeners(),history.go(o)}const n=G({location:"",base:t,go:i,createHref:Wa.bind(null,t)},e,s);return Object.defineProperty(n,"location",{enumerable:!0,get:()=>e.location.value}),Object.defineProperty(n,"state",{enumerable:!0,get:()=>e.state.value}),n}function Za(t){return t=location.host?t||location.pathname+location.search:"",t.includes("#")||(t+="#"),Ka(t)}function $a(t){return typeof t=="string"||t&&typeof t=="object"}function Fo(t){return typeof t=="string"||typeof t=="symbol"}const Uo=Symbol("");var js;(function(t){t[t.aborted=4]="aborted",t[t.cancelled=8]="cancelled",t[t.duplicated=16]="duplicated"})(js||(js={}));function ut(t,e){return G(new Error,{type:t,[Uo]:!0},e)}function Fe(t,e){return t instanceof Error&&Uo in t&&(e==null||!!(t.type&e))}const Ms="[^/]+?",el={sensitive:!1,strict:!1,start:!0,end:!0},tl=/[.+*?^${}()[\]/\\]/g;function nl(t,e){const s=G({},el,e),i=[];let n=s.start?"^":"";const o=[];for(const d of t){const m=d.length?[]:[90];s.strict&&!d.length&&(n+="/");for(let p=0;p<d.length;p++){const y=d[p];let _=40+(s.sensitive?.25:0);if(y.type===0)p||(n+="/"),n+=y.value.replace(tl,"\\$&"),_+=40;else if(y.type===1){const{value:v,repeatable:x,optional:R,regexp:q}=y;o.push({name:v,repeatable:x,optional:R});const S=q||Ms;if(S!==Ms){_+=10;try{new RegExp(`(${S})`)}catch(z){throw new Error(`Invalid custom RegExp for param "${v}" (${S}): `+z.message)}}let k=x?`((?:${S})(?:/(?:${S}))*)`:`(${S})`;p||(k=R&&d.length<2?`(?:/${k})`:"/"+k),R&&(k+="?"),n+=k,_+=20,R&&(_+=-8),x&&(_+=-20),S===".*"&&(_+=-50)}m.push(_)}i.push(m)}if(s.strict&&s.end){const d=i.length-1;i[d][i[d].length-1]+=.7000000000000001}s.strict||(n+="/?"),s.end?n+="$":s.strict&&(n+="(?:/|$)");const a=new RegExp(n,s.sensitive?"":"i");function l(d){const m=d.match(a),p={};if(!m)return null;for(let y=1;y<m.length;y++){const _=m[y]||"",v=o[y-1];p[v.name]=_&&v.repeatable?_.split("/"):_}return p}function f(d){let m="",p=!1;for(const y of t){(!p||!m.endsWith("/"))&&(m+="/"),p=!1;for(const _ of y)if(_.type===0)m+=_.value;else if(_.type===1){const{value:v,repeatable:x,optional:R}=_,q=v in d?d[v]:"";if(De(q)&&!x)throw new Error(`Provided param "${v}" is an array but it is not repeatable (* or + modifiers)`);const S=De(q)?q.join("/"):q;if(!S)if(R)y.length<2&&(m.endsWith("/")?m=m.slice(0,-1):p=!0);else throw new Error(`Missing required param "${v}"`);m+=S}}return m||"/"}return{re:a,score:i,keys:o,parse:l,stringify:f}}function sl(t,e){let s=0;for(;s<t.length&&s<e.length;){const i=e[s]-t[s];if(i)return i;s++}return t.length<e.length?t.length===1&&t[0]===40+40?-1:1:t.length>e.length?e.length===1&&e[0]===40+40?1:-1:0}function Lo(t,e){let s=0;const i=t.score,n=e.score;for(;s<i.length&&s<n.length;){const o=sl(i[s],n[s]);if(o)return o;s++}if(Math.abs(n.length-i.length)===1){if(Os(i))return 1;if(Os(n))return-1}return n.length-i.length}function Os(t){const e=t[t.length-1];return t.length>0&&e[e.length-1]<0}const ol={type:0,value:""},il=/[a-zA-Z0-9_]/;function rl(t){if(!t)return[[]];if(t==="/")return[[ol]];if(!t.startsWith("/"))throw new Error(`Invalid path "${t}"`);function e(_){throw new Error(`ERR (${s})/"${d}": ${_}`)}let s=0,i=s;const n=[];let o;function a(){o&&n.push(o),o=[]}let l=0,f,d="",m="";function p(){!d||(s===0?o.push({type:0,value:d}):s===1||s===2||s===3?(o.length>1&&(f==="*"||f==="+")&&e(`A repeatable param (${d}) must be alone in its segment. eg: '/:ids+.`),o.push({type:1,value:d,regexp:m,repeatable:f==="*"||f==="+",optional:f==="*"||f==="?"})):e("Invalid state to consume buffer"),d="")}function y(){d+=f}for(;l<t.length;){if(f=t[l++],f==="\\"&&s!==2){i=s,s=4;continue}switch(s){case 0:f==="/"?(d&&p(),a()):f===":"?(p(),s=1):y();break;case 4:y(),s=i;break;case 1:f==="("?s=2:il.test(f)?y():(p(),s=0,f!=="*"&&f!=="?"&&f!=="+"&&l--);break;case 2:f===")"?m[m.length-1]=="\\"?m=m.slice(0,-1)+f:s=3:m+=f;break;case 3:p(),s=0,f!=="*"&&f!=="?"&&f!=="+"&&l--,m="";break;default:e("Unknown state");break}}return s===2&&e(`Unfinished custom RegExp for param "${d}"`),p(),a(),n}function al(t,e,s){const i=nl(rl(t.path),s),n=G(i,{record:t,parent:e,children:[],alias:[]});return e&&!n.record.aliasOf==!e.record.aliasOf&&e.children.push(n),n}function ll(t,e){const s=[],i=new Map;e=Bs({strict:!1,end:!0,sensitive:!1},e);function n(p){return i.get(p)}function o(p,y,_){const v=!_,x=cl(p);x.aliasOf=_&&_.record;const R=Bs(e,p),q=[x];if("alias"in p){const z=typeof p.alias=="string"?[p.alias]:p.alias;for(const le of z)q.push(G({},x,{components:_?_.record.components:x.components,path:le,aliasOf:_?_.record:x}))}let S,k;for(const z of q){const{path:le}=z;if(y&&le[0]!=="/"){const Y=y.record.path,K=Y[Y.length-1]==="/"?"":"/";z.path=y.record.path+(le&&K+le)}if(S=al(z,y,R),_?_.alias.push(S):(k=k||S,k!==S&&k.alias.push(S),v&&p.name&&!Ns(S)&&a(p.name)),Wo(S)&&f(S),x.children){const Y=x.children;for(let K=0;K<Y.length;K++)o(Y[K],S,_&&_.children[K])}_=_||S}return k?()=>{a(k)}:Tt}function a(p){if(Fo(p)){const y=i.get(p);y&&(i.delete(p),s.splice(s.indexOf(y),1),y.children.forEach(a),y.alias.forEach(a))}else{const y=s.indexOf(p);y>-1&&(s.splice(y,1),p.record.name&&i.delete(p.record.name),p.children.forEach(a),p.alias.forEach(a))}}function l(){return s}function f(p){const y=hl(p,s);s.splice(y,0,p),p.record.name&&!Ns(p)&&i.set(p.record.name,p)}function d(p,y){let _,v={},x,R;if("name"in p&&p.name){if(_=i.get(p.name),!_)throw ut(1,{location:p});R=_.record.name,v=G(qs(y.params,_.keys.filter(k=>!k.optional).concat(_.parent?_.parent.keys.filter(k=>k.optional):[]).map(k=>k.name)),p.params&&qs(p.params,_.keys.map(k=>k.name))),x=_.stringify(v)}else if(p.path!=null)x=p.path,_=s.find(k=>k.re.test(x)),_&&(v=_.parse(x),R=_.record.name);else{if(_=y.name?i.get(y.name):s.find(k=>k.re.test(y.path)),!_)throw ut(1,{location:p,currentLocation:y});R=_.record.name,v=G({},y.params,p.params),x=_.stringify(v)}const q=[];let S=_;for(;S;)q.unshift(S.record),S=S.parent;return{name:R,path:x,params:v,matched:q,meta:ul(q)}}t.forEach(p=>o(p));function m(){s.length=0,i.clear()}return{addRoute:o,resolve:d,removeRoute:a,clearRoutes:m,getRoutes:l,getRecordMatcher:n}}function qs(t,e){const s={};for(const i of e)i in t&&(s[i]=t[i]);return s}function cl(t){return{path:t.path,redirect:t.redirect,name:t.name,meta:t.meta||{},aliasOf:void 0,beforeEnter:t.beforeEnter,props:dl(t),children:t.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:"components"in t?t.components||null:t.component&&{default:t.component}}}function dl(t){const e={},s=t.props||!1;if("component"in t)e.default=s;else for(const i in t.components)e[i]=typeof s=="object"?s[i]:s;return e}function Ns(t){for(;t;){if(t.record.aliasOf)return!0;t=t.parent}return!1}function ul(t){return t.reduce((e,s)=>G(e,s.meta),{})}function Bs(t,e){const s={};for(const i in t)s[i]=i in e?e[i]:t[i];return s}function hl(t,e){let s=0,i=e.length;for(;s!==i;){const o=s+i>>1;Lo(t,e[o])<0?i=o:s=o+1}const n=ml(t);return n&&(i=e.lastIndexOf(n,i-1)),i}function ml(t){let e=t;for(;e=e.parent;)if(Wo(e)&&Lo(t,e)===0)return e}function Wo({record:t}){return!!(t.name||t.components&&Object.keys(t.components).length||t.redirect)}function fl(t){const e={};if(t===""||t==="?")return e;const i=(t[0]==="?"?t.slice(1):t).split("&");for(let n=0;n<i.length;++n){const o=i[n].replace(Mo," "),a=o.indexOf("="),l=Mt(a<0?o:o.slice(0,a)),f=a<0?null:Mt(o.slice(a+1));if(l in e){let d=e[l];De(d)||(d=e[l]=[d]),d.push(f)}else e[l]=f}return e}function Vs(t){let e="";for(let s in t){const i=t[s];if(s=Ra(s),i==null){i!==void 0&&(e+=(e.length?"&":"")+s);continue}(De(i)?i.map(o=>o&&Gn(o)):[i&&Gn(i)]).forEach(o=>{o!==void 0&&(e+=(e.length?"&":"")+s,o!=null&&(e+="="+o))})}return e}function pl(t){const e={};for(const s in t){const i=t[s];i!==void 0&&(e[s]=De(i)?i.map(n=>n==null?null:""+n):i==null?i:""+i)}return e}const _l=Symbol(""),Fs=Symbol(""),cs=Symbol(""),Xo=Symbol(""),Yn=Symbol("");function vt(){let t=[];function e(i){return t.push(i),()=>{const n=t.indexOf(i);n>-1&&t.splice(n,1)}}function s(){t=[]}return{add:e,list:()=>t.slice(),reset:s}}function Ge(t,e,s,i,n,o=a=>a()){const a=i&&(i.enterCallbacks[n]=i.enterCallbacks[n]||[]);return()=>new Promise((l,f)=>{const d=y=>{y===!1?f(ut(4,{from:s,to:e})):y instanceof Error?f(y):$a(y)?f(ut(2,{from:e,to:y})):(a&&i.enterCallbacks[n]===a&&typeof y=="function"&&a.push(y),l())},m=o(()=>t.call(i&&i.instances[n],e,s,d));let p=Promise.resolve(m);t.length<3&&(p=p.then(d)),p.catch(y=>f(y))})}function Pn(t,e,s,i,n=o=>o()){const o=[];for(const a of t)for(const l in a.components){let f=a.components[l];if(!(e!=="beforeRouteEnter"&&!a.instances[l]))if(gl(f)){const m=(f.__vccOpts||f)[e];m&&o.push(Ge(m,s,i,a,l,n))}else{let d=f();o.push(()=>d.then(m=>{if(!m)return Promise.reject(new Error(`Couldn't resolve component "${l}" at "${a.path}"`));const p=wa(m)?m.default:m;a.components[l]=p;const _=(p.__vccOpts||p)[e];return _&&Ge(_,s,i,a,l,n)()}))}}return o}function gl(t){return typeof t=="object"||"displayName"in t||"props"in t||"__vccOpts"in t}function Us(t){const e=Rt(cs),s=Rt(Xo),i=je(()=>{const f=Ct(t.to);return e.resolve(f)}),n=je(()=>{const{matched:f}=i.value,{length:d}=f,m=f[d-1],p=s.matched;if(!m||!p.length)return-1;const y=p.findIndex(dt.bind(null,m));if(y>-1)return y;const _=Ls(f[d-2]);return d>1&&Ls(m)===_&&p[p.length-1].path!==_?p.findIndex(dt.bind(null,f[d-2])):y}),o=je(()=>n.value>-1&&wl(s.params,i.value.params)),a=je(()=>n.value>-1&&n.value===s.matched.length-1&&Bo(s.params,i.value.params));function l(f={}){return vl(f)?e[Ct(t.replace)?"replace":"push"](Ct(t.to)).catch(Tt):Promise.resolve()}return{route:i,href:je(()=>i.value.href),isActive:o,isExactActive:a,navigate:l}}const yl=eo({name:"RouterLink",compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"}},useLink:Us,setup(t,{slots:e}){const s=hi(Us(t)),{options:i}=Rt(cs),n=je(()=>({[Ws(t.activeClass,i.linkActiveClass,"router-link-active")]:s.isActive,[Ws(t.exactActiveClass,i.linkExactActiveClass,"router-link-exact-active")]:s.isExactActive}));return()=>{const o=e.default&&e.default(s);return t.custom?o:to("a",{"aria-current":s.isExactActive?t.ariaCurrentValue:null,href:s.href,onClick:s.navigate,class:n.value},o)}}}),bl=yl;function vl(t){if(!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)&&!t.defaultPrevented&&!(t.button!==void 0&&t.button!==0)){if(t.currentTarget&&t.currentTarget.getAttribute){const e=t.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(e))return}return t.preventDefault&&t.preventDefault(),!0}}function wl(t,e){for(const s in e){const i=e[s],n=t[s];if(typeof i=="string"){if(i!==n)return!1}else if(!De(n)||n.length!==i.length||i.some((o,a)=>o!==n[a]))return!1}return!0}function Ls(t){return t?t.aliasOf?t.aliasOf.path:t.path:""}const Ws=(t,e,s)=>t!=null?t:e!=null?e:s,xl=eo({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,default:"default"},route:Object},compatConfig:{MODE:3},setup(t,{attrs:e,slots:s}){const i=Rt(Yn),n=je(()=>t.route||i.value),o=Rt(Fs,0),a=je(()=>{let d=Ct(o);const{matched:m}=n.value;let p;for(;(p=m[d])&&!p.components;)d++;return d}),l=je(()=>n.value.matched[a.value]);Cn(Fs,je(()=>a.value+1)),Cn(_l,l),Cn(Yn,n);const f=mi();return fi(()=>[f.value,l.value,t.name],([d,m,p],[y,_,v])=>{m&&(m.instances[p]=d,_&&_!==m&&d&&d===y&&(m.leaveGuards.size||(m.leaveGuards=_.leaveGuards),m.updateGuards.size||(m.updateGuards=_.updateGuards))),d&&m&&(!_||!dt(m,_)||!y)&&(m.enterCallbacks[p]||[]).forEach(x=>x(d))},{flush:"post"}),()=>{const d=n.value,m=t.name,p=l.value,y=p&&p.components[m];if(!y)return Xs(s.default,{Component:y,route:d});const _=p.props[m],v=_?_===!0?d.params:typeof _=="function"?_(d):_:null,R=to(y,G({},v,e,{onVnodeUnmounted:q=>{q.component.isUnmounted&&(p.instances[m]=null)},ref:f}));return Xs(s.default,{Component:R,route:d})||R}}});function Xs(t,e){if(!t)return null;const s=t(e);return s.length===1?s[0]:s}const El=xl;function Cl(t){const e=ll(t.routes,t),s=t.parseQuery||fl,i=t.stringifyQuery||Vs,n=t.history,o=vt(),a=vt(),l=vt(),f=ci(Qe);let d=Qe;rt&&t.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const m=Sn.bind(null,w=>""+w),p=Sn.bind(null,Ma),y=Sn.bind(null,Mt);function _(w,A){let T,j;return Fo(w)?(T=e.getRecordMatcher(w),j=A):j=w,e.addRoute(j,T)}function v(w){const A=e.getRecordMatcher(w);A&&e.removeRoute(A)}function x(){return e.getRoutes().map(w=>w.record)}function R(w){return!!e.getRecordMatcher(w)}function q(w,A){if(A=G({},A||f.value),typeof w=="string"){const L=Dn(s,w,A.path),ae=e.resolve({path:L.path},A),yt=n.createHref(L.fullPath);return G(L,ae,{params:y(ae.params),hash:Mt(L.hash),redirectedFrom:void 0,href:yt})}let T;if(w.path!=null)T=G({},w,{path:Dn(s,w.path,A.path).path});else{const L=G({},w.params);for(const ae in L)L[ae]==null&&delete L[ae];T=G({},w,{params:p(L)}),A.params=p(A.params)}const j=e.resolve(T,A),Z=w.hash||"";j.params=m(y(j.params));const se=Na(i,G({},w,{hash:Pa(Z),path:j.path})),X=n.createHref(se);return G({fullPath:se,hash:Z,query:i===Vs?pl(w.query):w.query||{}},j,{redirectedFrom:void 0,href:X})}function S(w){return typeof w=="string"?Dn(s,w,f.value.path):G({},w)}function k(w,A){if(d!==w)return ut(8,{from:A,to:w})}function z(w){return K(w)}function le(w){return z(G(S(w),{replace:!0}))}function Y(w){const A=w.matched[w.matched.length-1];if(A&&A.redirect){const{redirect:T}=A;let j=typeof T=="function"?T(w):T;return typeof j=="string"&&(j=j.includes("?")||j.includes("#")?j=S(j):{path:j},j.params={}),G({query:w.query,hash:w.hash,params:j.path!=null?{}:w.params},j)}}function K(w,A){const T=d=q(w),j=f.value,Z=w.state,se=w.force,X=w.replace===!0,L=Y(T);if(L)return K(G(S(L),{state:typeof L=="object"?G({},Z,L.state):Z,force:se,replace:X}),A||T);const ae=T;ae.redirectedFrom=A;let yt;return!se&&Ba(i,j,T)&&(yt=ut(16,{to:ae,from:j}),_t(j,j,!0,!1)),(yt?Promise.resolve(yt):Xe(ae,j)).catch(_e=>Fe(_e)?Fe(_e,2)?_e:Ut(_e):Ve(_e,ae,j)).then(_e=>{if(_e){if(Fe(_e,2))return K(G({replace:X},S(_e.to),{state:typeof _e.to=="object"?G({},Z,_e.to.state):Z,force:se}),A||ae)}else _e=He(ae,j,!0,X,Z);return Ce(ae,j,_e),_e})}function Re(w,A){const T=k(w,A);return T?Promise.reject(T):Promise.resolve()}function ce(w){const A=Lt.values().next().value;return A&&typeof A.runWithContext=="function"?A.runWithContext(w):w()}function Xe(w,A){let T;const[j,Z,se]=Tl(w,A);T=Pn(j.reverse(),"beforeRouteLeave",w,A);for(const L of j)L.leaveGuards.forEach(ae=>{T.push(Ge(ae,w,A))});const X=Re.bind(null,w,A);return T.push(X),st(T).then(()=>{T=[];for(const L of o.list())T.push(Ge(L,w,A));return T.push(X),st(T)}).then(()=>{T=Pn(Z,"beforeRouteUpdate",w,A);for(const L of Z)L.updateGuards.forEach(ae=>{T.push(Ge(ae,w,A))});return T.push(X),st(T)}).then(()=>{T=[];for(const L of se)if(L.beforeEnter)if(De(L.beforeEnter))for(const ae of L.beforeEnter)T.push(Ge(ae,w,A));else T.push(Ge(L.beforeEnter,w,A));return T.push(X),st(T)}).then(()=>(w.matched.forEach(L=>L.enterCallbacks={}),T=Pn(se,"beforeRouteEnter",w,A,ce),T.push(X),st(T))).then(()=>{T=[];for(const L of a.list())T.push(Ge(L,w,A));return T.push(X),st(T)}).catch(L=>Fe(L,8)?L:Promise.reject(L))}function Ce(w,A,T){l.list().forEach(j=>ce(()=>j(w,A,T)))}function He(w,A,T,j,Z){const se=k(w,A);if(se)return se;const X=A===Qe,L=rt?history.state:{};T&&(j||X?n.replace(w.fullPath,G({scroll:X&&L&&L.scroll},Z)):n.push(w.fullPath,Z)),f.value=w,_t(w,A,T,X),Ut()}let fe;function qe(){fe||(fe=n.listen((w,A,T)=>{if(!fs.listening)return;const j=q(w),Z=Y(j);if(Z){K(G(Z,{replace:!0}),j).catch(Tt);return}d=j;const se=f.value;rt&&za(Ps(se.fullPath,T.delta),vn()),Xe(j,se).catch(X=>Fe(X,12)?X:Fe(X,2)?(K(X.to,j).then(L=>{Fe(L,20)&&!T.delta&&T.type===Ot.pop&&n.go(-1,!1)}).catch(Tt),Promise.reject()):(T.delta&&n.go(-T.delta,!1),Ve(X,j,se))).then(X=>{X=X||He(j,se,!1),X&&(T.delta&&!Fe(X,8)?n.go(-T.delta,!1):T.type===Ot.pop&&Fe(X,20)&&n.go(-1,!1)),Ce(j,se,X)}).catch(Tt)}))}let Ne=vt(),Te=vt(),Be;function Ve(w,A,T){Ut(w);const j=Te.list();return j.length?j.forEach(Z=>Z(w,A,T)):console.error(w),Promise.reject(w)}function xn(){return Be&&f.value!==Qe?Promise.resolve():new Promise((w,A)=>{Ne.add([w,A])})}function Ut(w){return Be||(Be=!w,qe(),Ne.list().forEach(([A,T])=>w?T(w):A()),Ne.reset()),w}function _t(w,A,T,j){const{scrollBehavior:Z}=t;if(!rt||!Z)return Promise.resolve();const se=!T&&Qa(Ps(w.fullPath,0))||(j||!T)&&history.state&&history.state.scroll||null;return ui().then(()=>Z(w,A,se)).then(X=>X&&Ha(X)).catch(X=>Ve(X,w,A))}const gt=w=>n.go(w);let En;const Lt=new Set,fs={currentRoute:f,listening:!0,addRoute:_,removeRoute:v,clearRoutes:e.clearRoutes,hasRoute:R,getRoutes:x,resolve:q,options:t,push:z,replace:le,go:gt,back:()=>gt(-1),forward:()=>gt(1),beforeEach:o.add,beforeResolve:a.add,afterEach:l.add,onError:Te.add,isReady:xn,install(w){const A=this;w.component("RouterLink",bl),w.component("RouterView",El),w.config.globalProperties.$router=A,Object.defineProperty(w.config.globalProperties,"$route",{enumerable:!0,get:()=>Ct(f)}),rt&&!En&&f.value===Qe&&(En=!0,z(n.location).catch(Z=>{}));const T={};for(const Z in Qe)Object.defineProperty(T,Z,{get:()=>f.value[Z],enumerable:!0});w.provide(cs,A),w.provide(Xo,di(T)),w.provide(Yn,f);const j=w.unmount;Lt.add(w),w.unmount=function(){Lt.delete(w),Lt.size<1&&(d=Qe,fe&&fe(),fe=null,f.value=Qe,En=!1,Be=!1),j()}}};function st(w){return w.reduce((A,T)=>A.then(()=>ce(T)),Promise.resolve())}return fs}function Tl(t,e){const s=[],i=[],n=[],o=Math.max(e.matched.length,t.matched.length);for(let a=0;a<o;a++){const l=e.matched[a];l&&(t.matched.find(d=>dt(d,l))?i.push(l):s.push(l));const f=t.matched[a];f&&(e.matched.find(d=>dt(d,f))||n.push(f))}return[s,i,n]}const Il={name:"QuoteEdit",components:{Card:Ze,ModelSelect:hn,VueDatePicker:Nt},data(){return{quote:{quote_number:"",due_date:"",provisional_start_date:"",client_id:"",client:null,status:""},showError:!1,loading:!1,loadingBtn:!1,clients:[],clientOptions:[],settings:[],toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return t=>{if(!t)return"";const e=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getFullYear();return`${e}-${s}-${i}`}}},mounted(){this.fetchClients(),this.fetchSettings(),this.fetchQuoteDetails()},methods:{cancelAction(){this.$router.push("/quotes")},fetchClients(){this.loading=!0,fetch("/wp-json/my-easy-compta/v1/list-clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.clients=t.clients,this.clientOptions=this.clients.map(e=>({value:e.id,text:`${e.company_name} - ${e.email} (${e.currency_symbol})`})),this.quote.client_id&&this.setClientById(this.quote.client_id)}).catch(t=>{console.error("Error fetching clients:",t)}).finally(()=>{this.loading=!1})},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,t.ok){const e=await t.json();this.settings=e}else{const e=await t.json();console.error("Error fetching settings:",e)}}catch(t){this.loading=!1,console.error("Error fetching settings:",t)}},fetchQuoteDetails(){const t=this.$route.params.id;!t||(this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{e?(this.quote=e,this.setClientById(this.quote.client_id)):(console.error("Error fetching quote details:",e.message),this.showToast(e.message,"alert-error"))}).catch(e=>{console.error("Error fetching quote details:",e),this.showToast(e,"alert-error")}).finally(()=>{this.loading=!1}))},setClientById(t){this.quote.client=this.clients.find(e=>e.id===t)||null,this.quote.client_id=t},submitQuote(){if(!this.quote.due_date||!this.quote.provisional_start_date||!this.quote.client_id||!this.quote.status){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.loadingBtn=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/${this.$route.params.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.quote)}).then(t=>{if(!t.ok)throw this.loadingBtn=!1,new Error("Network response was not ok");return t.json()}).then(t=>{t.success?(this.loadingBtn=!1,this.showToast(t.message,"alert-success"),this.$router.push({name:"QuoteViewDetail",params:{id:t.id}})):(console.error("Error submitting quote:",t.message),this.showToast(t.message,"alert-error"),this.loadingBtn=!1)}).catch(t=>{console.error("Error submitting quote:",t),this.showToast(t,"alert-error"),this.loadingBtn=!1})},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},kl={class:"pt-2 pr-4"},Al={class:"flex justify-between items-center mb-4"},Sl={class:"card-title"},Dl=r("div",{class:"divider mt-2"},null,-1),Pl={key:0,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},Rl={class:"grid grid-cols-3 gap-4"},jl={class:"ecwp-group form-group mb-4"},Ml={for:"quoteNumber",class:"ecwp-label"},Ol={class:"ecwp-group form-group mb-4"},ql={for:"quoteDate",class:"ecwp-label"},Nl={class:"ecwp-group form-group mb-4"},Bl={for:"quoteProvisanalDate",class:"ecwp-label"},Vl={class:"grid grid-cols-2 gap-4"},Fl={class:"ecwp-group form-group mb-4"},Ul={for:"client",class:"ecwp-label"},Ll={class:"ecwp-group form-group mb-4"},Wl={for:"status",class:"ecwp-label"},Xl={value:"draft"},Hl={value:"pending"},zl={value:"approved"},Ql={value:"rejected"},Gl={class:"flex justify-between"},Jl=["disabled"],Yl={key:0,class:"loading loading-spinner loading-sm"};function Kl(t,e,s,i,n,o){const a=O("VueDatePicker"),l=O("model-select"),f=O("Card");return u(),h("div",kl,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),P(f,{topMargin:"mt-8",modalType:"modal_quote_new"},{default:me(()=>[r("div",Al,[r("h2",Sl,c(o.translations.edit_quote),1)]),Dl,n.loading?(u(),h("div",Pl)):g("",!0),r("form",{onSubmit:e[6]||(e[6]=J((...d)=>o.submitQuote&&o.submitQuote(...d),["prevent"]))},[r("div",Rl,[r("div",jl,[r("label",Ml,c(o.translations.quote_number),1),D(r("input",{type:"text",id:"quoteNumber","onUpdate:modelValue":e[0]||(e[0]=d=>n.quote.quote_number=d),class:"ecwp-input input input-bordered w-full",disabled:"true"},null,512),[[W,n.quote.quote_number]])]),r("div",Ol,[r("label",ql,c(o.translations.due_date),1),P(a,{class:I(["ecwp-input ecwp-date input input-bordered w-full",[!n.quote.due_date&&n.showError?"input-error":""]]),id:"quoteDate",modelValue:n.quote.due_date,"onUpdate:modelValue":e[1]||(e[1]=d=>n.quote.due_date=d),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date},null,8,["class","modelValue","format","min-date"])]),r("div",Nl,[r("label",Bl,c(o.translations.provisional_date),1),P(a,{class:I(["ecwp-input ecwp-date input input-bordered w-full",[!n.quote.provisional_start_date&&n.showError?"input-error":""]]),id:"quoteProvisanalDate",modelValue:n.quote.provisional_start_date,"onUpdate:modelValue":e[2]||(e[2]=d=>n.quote.provisional_start_date=d),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date},null,8,["class","modelValue","format","min-date"])])]),r("div",Vl,[r("div",Fl,[r("label",Ul,c(o.translations.company_name),1),P(l,{modelValue:n.quote.client_id,"onUpdate:modelValue":e[3]||(e[3]=d=>n.quote.client_id=d),options:n.clientOptions,label:"text","track-by":"value",placeholder:o.translations.select,class:I(["ecwp-input input input-bordered w-full",[!n.quote.client_id&&n.showError?"input-error":""]])},null,8,["modelValue","options","placeholder","class"])]),r("div",Ll,[r("label",Wl,c(o.translations.status),1),D(r("select",{id:"status","onUpdate:modelValue":e[4]||(e[4]=d=>n.quote.status=d),required:"",class:I(["ecwp-input select select-bordered w-full",[!n.quote.status&&n.showError?"input-error":""]])},[r("option",Xl,c(o.translations.draft),1),r("option",Hl,c(o.translations.pending),1),r("option",zl,c(o.translations.approved),1),r("option",Ql,c(o.translations.rejected),1)],2),[[ue,n.quote.status]])])]),r("div",Gl,[r("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:e[5]||(e[5]=(...d)=>o.cancelAction&&o.cancelAction(...d))},c(o.translations.cancel),1),r("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(c(o.translations.save)+" ",1),n.loadingBtn?(u(),h("span",Yl)):g("",!0)],8,Jl)])],32)]),_:1})])}var Ho=ne(Il,[["render",Kl]]);const Zl={props:{isVisible:{type:Boolean,default:!1},title:{type:String,default:"Confirmation"},message:{type:String,default:"Are you sure?"},confirmText:{type:String,default:"Confirm"},cancelText:{type:String,default:"Cancel"},status:{type:String}},data(){return{selectedPaymentMethod:""}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{onConfirm(){this.$emit("confirm"),this.closeModal()},onCancel(){this.$emit("cancel"),this.closeModal()},closeModal(){document.getElementById("modal_confirm").close()}}},$l=["open"],ec={class:"modal-box"},tc={class:"font-bold text-lg"},nc=r("div",{class:"text-center text-red-400 mb-2"},[r("i",{class:"fas fa-exclamation-triangle text-4xl"})],-1),sc={class:"text-lg font-semibold text-center"},oc={class:"my-4 text-center text-xl"},ic={class:"flex justify-between space-x-4"};function rc(t,e,s,i,n,o){return u(),h("div",null,[r("dialog",{id:"modal_confirm",class:"modal",open:t.showModal},[r("div",ec,[r("h3",tc,c(t.modalTitle),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...a)=>o.closeModal&&o.closeModal(...a))}," \u2715 "),nc,r("h2",sc,c(s.title),1),r("p",oc,c(s.message),1),r("div",ic,[r("button",{onClick:e[1]||(e[1]=(...a)=>o.onCancel&&o.onCancel(...a)),class:"btn btn-secondary rounded-full"},c(s.cancelText),1),r("button",{onClick:e[2]||(e[2]=(...a)=>o.onConfirm&&o.onConfirm(...a)),class:"btn rounded-full btn-error text-white"},c(s.confirmText),1)])])],8,$l)])}var ds=ne(Zl,[["render",rc]]);const ac={name:"QuotesList",components:{Card:Ze,QuoteEditModal:Ho,ConfirmModal:ds,RemoveModal:qt},data(){return{quotes:[],filteredQuotes:[],filters:{quote_number:"",client:"",status:"",total_amount:"",due_date:"",created_at:""},showQuoteDetailsModal:!1,editQuoteModal:!1,selectedQuote:null,currentPage:1,totalCount:0,totalPages:1,paginationButtons:[],loading:!0,loadingPrice:!0,loadingModal:!1,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],clients:[],client_currency:"",default_vat:"",default_currency:"",default_currency_symbol:"",settings:{},toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},created(){this.fetchQuotesWithFilters(),this.loadSettings(),this.fetchClients()},methods:{fetchQuotes(t=1){this.loading=!0;const{perPage:e}=this;fetch(`/wp-json/my-easy-compta/v1/quotes?page=${t}&per_page=${e}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>s.json()).then(s=>{this.quotes=s.quotes,this.totalCount=s.total_count,this.totalPages=s.total_pages,this.currentPage=t,this.perPage=e,this.generatePaginationButtons()}).catch(s=>{console.error("Error fetching quotes:",s)}).finally(()=>{this.loading=!1})},fetchQuotesWithFilters(t=1){this.loading=!0;const{perPage:e,filters:s}=this,i=new URLSearchParams({page:t,per_page:e,...s}).toString();fetch(`/wp-json/my-easy-compta/v1/quotes?${i}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(n=>n.json()).then(n=>{this.quotes=n.quotes,this.totalCount=n.total_count,this.totalPages=n.total_pages,this.currentPage=t,this.perPage=e,this.generatePaginationButtons()}).catch(n=>{console.error("Error fetching quotes with filters:",n)}).finally(()=>{this.loading=!1})},fetchClients(){fetch("/wp-json/my-easy-compta/v1/clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.clients=t.clients}).catch(t=>{console.error("Error fetching clients:",t)})},async loadSettings(){try{this.loadingPrice=!0;const{settings:t,currencySymbol:e,vatData:s}=await mn();this.settings=t,this.default_currency_symbol=e,this.default_vat=s,this.loadingPrice=!1}catch(t){this.showToast(t.message,"alert-error"),this.loadingPrice=!1}},calculateVAT(t){return so(t,this.default_vat.rate)},calculateWithoutVAT(t){return oo(t)},generatePaginationButtons(){this.paginationButtons=io(this.currentPage,this.totalPages)},goToPage(t){t!=="..."&&this.fetchQuotesWithFilters(t)},perPageChanged(){this.fetchQuotesWithFilters()},formatAmount(t,e){return ro(t,e,this.settings.currency_position)},confirmDuplicateQuote(t){this.selectedQuote=t,modal_confirm.showModal(),this.showRemoveModal=!0},duplicateQuote(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/duplicate/${t}`,{method:"POST",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Network response was not ok");return e.json()}).then(e=>{e.success?(this.fetchQuotesWithFilters(),this.showToast(e.message,"alert-success")):(this.showToast(e.message,"alert-error"),console.error("Error duplicate quote:",e.statusText))}).catch(e=>{console.log(e.message),this.showToast(e.message,"alert-error")})},confirmDeleteQuote(t){this.selectedQuote=t,modal_quotes_remove.showModal(),this.showRemoveModal=!0},deleteQuote(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/delete/${t}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Network response was not ok");return e.json()}).then(e=>{e.success?(this.fetchQuotesWithFilters(),this.showToast(e.message,"alert-success")):(this.showToast(e.message,"alert-error"),console.error("Error deleting quote:",e.statusText))}).catch(e=>{console.log(e.message),this.showToast(e.message,"alert-error")})},showToast(t,e){ao(this.toast,t,e)}},computed:{skeletonItems(){return Array.from({length:5},(t,e)=>e)},totalPages(){return Math.ceil(this.totalCount/this.perPage)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},lc={class:"pt-2 pr-4"},cc={class:"flex justify-between items-center"},dc={class:"card-title"},uc={class:"btn btn-primary rounded-full"},hc=r("i",{class:"fas fa-plus-circle"},null,-1),mc={key:0,class:"ms-2"},fc={class:"btn btn-outline btn-accent rounded-full hover:text-white",href:"/wp-admin/admin.php?page=my-easy-compta-export#tab2"},pc=r("i",{class:"fas fa-file-export"},null,-1),_c=["data-tip"],gc={class:"btn btn-outline btn-accent rounded-full",disabled:""},yc=r("i",{class:"fas fa-file-export"},null,-1),bc=r("div",{class:"divider mt-2"},null,-1),vc={class:"flex items-center mb-4"},wc={for:"perPageSelect",class:"mr-2"},xc=["value"],Ec={class:"overflow-x-auto"},Cc={class:"table w-full"},Tc={value:""},Ic=["value"],kc={value:""},Ac={value:"draft"},Sc={value:"pending"},Dc={value:"approved"},Pc={value:"rejected"},Rc={class:"flex justify-center"},jc={key:0},Mc={key:0,class:"badge badge-warning badge-outline badge-sm"},Oc={key:1,class:"badge badge-secondary badge-outline badge-sm"},qc={key:2,class:"badge badge-success badge-outline badge-sm"},Nc={key:3,class:"badge badge-error badge-outline badge-sm"},Bc={key:0},Vc={key:0},Fc={key:0},Uc={key:1},Lc={key:1},Wc={key:0},Xc={key:1},Hc={key:1},zc=r("span",{class:"loading loading-bars loading-sm"},null,-1),Qc=[zc],Gc={key:0},Jc={key:1},Yc=r("span",{class:"loading loading-bars loading-sm"},null,-1),Kc=[Yc],Zc={key:0},$c={key:1},ed=r("span",{class:"loading loading-bars loading-sm"},null,-1),td=[ed],nd={class:"flex justify-end"},sd=["data-tip"],od=r("button",{class:"btn btn-circle mx-1"},[r("i",{class:"far fa-eye"})],-1),id=["data-tip"],rd=r("button",{class:"btn btn-circle mx-1"},[r("i",{class:"fas fa-pencil-alt"})],-1),ad=["data-tip"],ld=["onClick"],cd=r("i",{class:"far fa-copy"},null,-1),dd=[cd],ud=["data-tip"],hd=["onClick"],md=r("i",{class:"far fa-trash-alt"},null,-1),fd=[md],pd={key:0},_d=r("div",{class:"flex gap-4 items-center"},[r("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),r("div",{class:"flex flex-col gap-4 w-full"},[r("div",{class:"skeleton h-4 w-full"}),r("div",{class:"skeleton h-4 w-full"})])],-1),gd=r("div",{class:"divider my-1"},null,-1),yd=[_d,gd],bd={class:"join ecwp_pagination mt-6 pt-4"},vd=["onClick"];function wd(t,e,s,i,n,o){const a=O("confirm-modal"),l=O("remove-modal"),f=O("router-link"),d=O("Card");return u(),h("div",lc,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),P(a,{"show-modal":t.showConfirmModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,onConfirm:e[0]||(e[0]=m=>this.duplicateQuote(n.selectedQuote)),onCancel:e[1]||(e[1]=m=>t.showConfirmModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),P(l,{"modal-id":"modal_quotes_remove","show-modal":t.showRemoveModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:e[2]||(e[2]=m=>this.deleteQuote(n.selectedQuote)),onCancel:e[3]||(e[3]=m=>t.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),P(d,{topMargin:"mt-8"},{default:me(()=>[r("div",cc,[r("h2",dc,c(o.translations.quotes),1),r("div",null,[P(f,{to:{name:"QuoteNew"}},{default:me(()=>[r("button",uc,[C(c(o.translations.add)+" ",1),hc])]),_:1}),n.settings.easy_compta_export_addon_active==1?(u(),h("span",mc,[r("a",fc,[C(c(o.translations.export)+" ",1),pc])])):(u(),h("span",{key:1,class:"tooltip tooltip-left tooltip-warning ms-2","data-tip":o.translations.active_export_addon},[r("button",gc,[C(c(o.translations.export)+" ",1),yc])],8,_c))])]),bc,r("div",vc,[r("label",wc,c(o.translations.display_per_page),1),D(r("select",{id:"perPageSelect","onUpdate:modelValue":e[4]||(e[4]=m=>n.perPage=m),onChange:e[5]||(e[5]=(...m)=>o.perPageChanged&&o.perPageChanged(...m))},[(u(!0),h(F,null,U(n.perPageOptions,m=>(u(),h("option",{key:m,value:m},c(m),9,xc))),128))],544),[[ue,n.perPage]])]),r("div",Ec,[r("table",Cc,[r("thead",null,[r("tr",null,[r("th",null,[r("div",null,c(o.translations.quote_number),1),D(r("input",{"onUpdate:modelValue":e[6]||(e[6]=m=>n.filters.quote_number=m),onInput:e[7]||(e[7]=m=>o.fetchQuotesWithFilters()),type:"text",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[W,n.filters.quote_number]])]),r("th",null,[r("div",null,c(o.translations.client),1),D(r("select",{"onUpdate:modelValue":e[8]||(e[8]=m=>n.filters.client=m),onChange:e[9]||(e[9]=m=>o.fetchQuotesWithFilters()),class:"ecwp-input input-xs input-bordered mt-2"},[r("option",Tc,c(o.translations.all),1),(u(!0),h(F,null,U(n.clients,m=>(u(),h("option",{key:m.id,value:m.company_name},c(m.company_name),9,Ic))),128))],544),[[ue,n.filters.client]])]),r("th",null,[r("div",null,c(o.translations.status),1),D(r("select",{"onUpdate:modelValue":e[10]||(e[10]=m=>n.filters.status=m),onChange:e[11]||(e[11]=m=>o.fetchQuotesWithFilters()),class:"ecwp-input input-xs input-bordered mt-2"},[r("option",kc,c(o.translations.all_statuses),1),r("option",Ac,c(o.translations.draft),1),r("option",Sc,c(o.translations.pending),1),r("option",Dc,c(o.translations.approved),1),r("option",Pc,c(o.translations.rejected),1)],544),[[ue,n.filters.status]])]),r("th",null,[r("div",null,c(o.translations.total),1),D(r("input",{"onUpdate:modelValue":e[12]||(e[12]=m=>n.filters.total_amount=m),onInput:e[13]||(e[13]=m=>o.fetchQuotesWithFilters()),type:"text",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[W,n.filters.total_amount]])]),r("th",null,[r("div",null,c(o.translations.due_date),1),D(r("input",{"onUpdate:modelValue":e[14]||(e[14]=m=>n.filters.due_date=m),onInput:e[15]||(e[15]=m=>o.fetchQuotesWithFilters()),type:"date",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[W,n.filters.due_date]])]),r("th",null,[r("div",null,c(o.translations.created_at),1),D(r("input",{"onUpdate:modelValue":e[16]||(e[16]=m=>n.filters.created_at=m),onInput:e[17]||(e[17]=m=>o.fetchQuotesWithFilters()),type:"date",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[W,n.filters.created_at]])]),r("th",Rc,c(o.translations.actions),1)])]),n.loading?g("",!0):(u(),h("tbody",jc,[(u(!0),h(F,null,U(n.quotes,m=>(u(),h("tr",{key:m.id},[r("td",null,c(m.quote_number),1),r("td",null,c(m.client_name),1),r("td",null,[m.status=="draft"?(u(),h("span",Mc,c(o.translations.draft),1)):g("",!0),m.status=="pending"?(u(),h("span",Oc,c(o.translations.pending),1)):g("",!0),m.status=="approved"?(u(),h("span",qc,c(o.translations.approved),1)):g("",!0),m.status=="rejected"?(u(),h("span",Nc,c(o.translations.rejected),1)):g("",!0)]),r("td",null,[n.loadingPrice?(u(),h("div",Hc,Qc)):(u(),h("div",Bc,[n.settings.vat_active==1?(u(),h("div",Vc,[n.default_currency_symbol==m.client_currency||m.client_currency==null?(u(),h("span",Fc,c(o.formatAmount(m.total_amount,n.default_currency_symbol)),1)):(u(),h("span",Uc,c(o.formatAmount(m.total_amount,m.client_currency)),1))])):(u(),h("div",Lc,[n.default_currency_symbol==m.client_currency||m.client_currency==null?(u(),h("span",Wc,c(o.formatAmount(m.total_amount,n.default_currency_symbol)),1)):(u(),h("span",Xc,c(o.formatAmount(m.total_amount,m.client_currency)),1))]))]))]),r("td",null,[n.loadingPrice?(u(),h("div",Jc,Kc)):(u(),h("div",Gc,c(m.due_date),1))]),r("td",null,[n.loadingPrice?(u(),h("div",$c,td)):(u(),h("div",Zc,c(m.created),1))]),r("td",nd,[r("span",{class:"lg:tooltip","data-tip":o.translations.view},[P(f,{to:{name:"QuoteViewDetail",params:{id:m.id}}},{default:me(()=>[od]),_:2},1032,["to"])],8,sd),r("span",{class:"lg:tooltip","data-tip":o.translations.edit},[P(f,{to:{name:"QuoteEdit",params:{id:m.id}}},{default:me(()=>[rd]),_:2},1032,["to"])],8,id),r("span",{class:"lg:tooltip","data-tip":o.translations.duplicate},[r("button",{onClick:p=>o.confirmDuplicateQuote(m.id),class:"btn btn-circle text-purple-600 hover:text-purple-900 mx-1"},dd,8,ld)],8,ad),r("span",{class:"lg:tooltip","data-tip":o.translations.delete},[r("button",{onClick:p=>o.confirmDeleteQuote(m.id),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},fd,8,hd)],8,ud)])]))),128))]))]),n.loading?(u(),h("div",pd,[(u(!0),h(F,null,U(n.skeletonRows,m=>(u(),h("div",{key:m,class:"flex flex-col gap-4 w-full"},yd))),128))])):g("",!0)]),r("div",bd,[(u(!0),h(F,null,U(n.paginationButtons,m=>(u(),h("button",{key:m,class:I(["join-item btn",{"btn-disabled":m==="..."||m===n.currentPage}]),onClick:p=>o.goToPage(m)},c(m),11,vd))),128))])]),_:1})])}var xd=ne(ac,[["render",wd]]);const Ed={name:"sendQuote",components:{VueEditor:mt.exports.VueEditor},props:{showModal:Boolean,modalId:String,client:Object,quoteId:Number,loading:Boolean,subject:String,content:String},data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{loading:!1,loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},toolbarOptions:[["bold","italic","underline","strike"],["link"],[{list:"ordered"},{list:"bullet"}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{align:[]}],[{align:"right"},{align:"center"},{align:"justify"}],["clean"]],fields:{client_email:{label:t.client,value:"",disabled:!0},email_subject:{label:t.email_subject,value:""},email_message:{label:t.email_content,value:"",type:"textarea"}}}},watch:{client:{immediate:!0,handler(t){this.fields.client_email.value=(t==null?void 0:t.email)||""}},subject:{immediate:!0,handler(t){this.fields.email_subject.value=t||""}},content:{immediate:!0,handler(t){this.fields.email_message.value=t||""}}},computed:{skeletonItems(){return Array.from({length:10},(t,e)=>e)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const t=await fetch("/wp-json/my-easy-compta/v1/emails/send-email",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({type:"quote",id:this.quoteId,client_email:this.client.email,email_subject:this.fields.email_subject.value,email_message:this.fields.email_message.value})});if(t.ok){const e=await t.json();this.loadingBtn=!1,this.closeModal(),this.showToast(e.message,"alert-success")}else{const e=`Error sending email: ${t.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(t){const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Error sending email";this.showToast(e,"alert-error"),console.error("Error sending email:",t),this.loadingBtn=!1}},updateFieldValue(t,e){this.fields[t].value=e},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},Cd=["id","open"],Td={class:"modal-box"},Id={class:"font-bold text-lg"},kd={key:0},Ad={class:"grid grid-cols-1 gap-4"},Sd=r("div",{class:"skeleton h-4 w-full mb-2"},null,-1),Dd=r("div",{class:"skeleton h-4 w-full"},null,-1),Pd=[Sd,Dd],Rd={class:"grid grid-cols-1 gap-4"},jd=["type"],Md=["for"],Od=["id","value","disabled","onInput"],qd={key:1},Nd=["for"],Bd={class:"form-group mt-4 flex justify-end"},Vd=["disabled"],Fd={key:0,class:"loading loading-spinner loading-sm"};function Ud(t,e,s,i,n,o){const a=O("vue-editor");return u(),h("div",null,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),r("dialog",{id:s.modalId,class:"modal",open:s.showModal},[r("div",Td,[r("h3",Id,c(o.translations.send_quote),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=l=>o.closeModal())}," \u2715 "),n.loading?(u(),h("div",kd,[r("div",Ad,[(u(!0),h(F,null,U(o.skeletonItems,l=>(u(),h("div",{key:l,class:"py-2"},Pd))),128))])])):(u(),h("form",{key:1,onSubmit:e[1]||(e[1]=J((...l)=>o.submitForm&&o.submitForm(...l),["prevent"])),class:"form"},[r("div",Rd,[(u(!0),h(F,null,U(n.fields,(l,f)=>(u(),h("div",{key:f,class:"ecwp-group form-group"},[l.type!=="textarea"?(u(),h("div",{key:0,type:l.type||"text"},[r("label",{for:f,class:"ecwp-label form-label"},c(l.label),9,Md),r("input",{id:f,class:I(["ecwp-input input input-bordered",l.class||"w-full"]),value:l.value,disabled:l.disabled,onInput:d=>o.updateFieldValue(f,d.target.value)},null,42,Od)],8,jd)):(u(),h("div",qd,[r("label",{for:f,class:"form-label"},c(l.label),9,Nd),P(a,{modelValue:l.value,"onUpdate:modelValue":d=>l.value=d,editorToolbar:n.toolbarOptions},null,8,["modelValue","onUpdate:modelValue","editorToolbar"])]))]))),128))]),r("div",Bd,[r("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(c(o.translations.send)+" ",1),n.loadingBtn?(u(),h("span",Fd)):g("",!0)],8,Vd)])],32))])],8,Cd)])}var Ld=ne(Ed,[["render",Ud]]);const Wd={components:{VueDatePicker:Nt},props:{isVisible:{type:Boolean,default:!1},title:{type:String,default:"Confirmation"},message:{type:String,default:"Are you sure?"},confirmText:{type:String,default:"Confirm"},cancelText:{type:String,default:"Cancel"},totalAmount:{type:String,required:!0},currency:{type:String,required:!0},advanceSold:{type:String,required:!0},quoteId:{type:Number,required:!0}},data(){return{showError:!1,selectedType:"",inputValue:0,due_date:"",invoiceSolded:!1,establishedAdvances:[],loading:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return t=>{if(!t)return"";const e=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getFullYear();return`${e}-${s}-${i}`}},remainingAmount(){this.loading=!0;const t=this.establishedAdvances.reduce((e,s)=>{const i=parseFloat(s.advance_amount);return isNaN(i)?(console.error("Erreur: advance_amount n'est pas un nombre valide",s.advance_amount),e):e+i},0);return this.totalAmount-t},inputValueExceeds(){return this.remainingAmount==0?!0:this.selectedType==="percentage"?this.calculatedAmount>this.remainingAmount:this.selectedType==="fixed"?this.inputValue>this.remainingAmount:!1},calculatedAmount(){return this.selectedType==="percentage"?this.inputValue/100*this.remainingAmount:this.inputValue}},created(){this.fetchEstablishedAdvances(this.quoteId)},methods:{fetchEstablishedAdvances(t){const e=`/wp-json/my-easy-compta/v1/advance/${t}`;fetch(e,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>s.json()).then(s=>{this.establishedAdvances=s}).catch(s=>{console.error("Error fetching advances:",s)})},onConfirm(){if(!this.inputValueExceeds){if(this.advanceSold=="no_sold"){if(!this.inputValue||!this.due_date||this.advanceSold=="no_sold"&&!this.selectedType){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.$emit("confirm",{type:this.selectedType,value:this.inputValue,date:this.due_date})}else{if(!this.due_date){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.$emit("confirm",{type:"fixed",value:this.remainingAmount,date:this.due_date})}this.closeModal()}},onCancel(){this.$emit("cancel"),this.closeModal()},closeModal(){document.getElementById("modal_advance").close()},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},Xd=["open"],Hd={class:"modal-box overflow-visible"},zd={class:"font-bold text-lg"},Qd={class:"text-lg font-semibold text-center"},Gd={class:"my-4 text-center text-xl"},Jd={key:0,class:"text-red-500 text-sm"},Yd={class:"grid grid-cols-2 gap-4"},Kd={key:0},Zd={class:"flex ecwp-group form-group mb-4"},$d=r("label",{for:"advance-type",class:"ecwp-label"},"Type",-1),eu=r("option",{value:"percentage"},"Pourcentage",-1),tu=r("option",{value:"fixed"},"Montant fixe",-1),nu=[eu,tu],su={key:1},ou={class:"flex ecwp-group form-group mb-4"},iu=r("label",{for:"advance-type",class:"ecwp-label"},"Valeur",-1),ru={class:"absolute items-center border rounded-md right-0 top-6"},au={class:"px-3 py-2.5 rounded-l-md bg-base-300 border-r"},lu={key:0},cu={key:1},du={key:1,class:"mt-2"},uu={class:"text-sm"},hu={key:2,class:"flex ecwp-group form-group mb-4"},mu={for:"quoteDate",class:"ecwp-label"},fu={key:3},pu={class:"flex justify-between space-x-4 mt-4"},_u=["disabled"];function gu(t,e,s,i,n,o){const a=O("VueDatePicker");return u(),h("div",null,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),r("dialog",{id:"modal_advance",class:"modal",open:s.isVisible},[r("div",Hd,[r("h3",zd,c(t.modalTitle),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...l)=>o.closeModal&&o.closeModal(...l))}," \u2715 "),r("h2",Qd,c(s.title),1),r("p",Gd," Montant total restant : "+c(o.remainingAmount)+" "+c(s.currency),1),o.inputValueExceeds&&!n.invoiceSolded?(u(),h("p",Jd," Le montant s\xE9lectionn\xE9 d\xE9passe le montant total du devis. ")):g("",!0),r("div",Yd,[s.advanceSold=="no_sold"&&!n.invoiceSolded?(u(),h("div",Kd,[r("div",Zd,[$d,D(r("select",{"onUpdate:modelValue":e[1]||(e[1]=l=>n.selectedType=l),id:"advance-type",class:I(["ecwp-select ecwp-input input input-bordered w-full",{"input-error":!n.selectedType&&n.showError}])},nu,2),[[ue,n.selectedType]])])])):g("",!0),n.selectedType&&s.advanceSold=="no_sold"&&!n.invoiceSolded?(u(),h("div",su,[r("div",ou,[iu,D(r("input",{"onUpdate:modelValue":e[2]||(e[2]=l=>n.inputValue=l),type:"text",id:"advance-value",class:I([{"input-error":!n.inputValue&&n.showError},"ecwp-input input input-bordered w-full"])},null,2),[[W,n.inputValue]]),r("div",ru,[r("div",au,[n.selectedType==="percentage"?(u(),h("span",lu,"%")):(u(),h("span",cu,c(s.currency),1))])])])])):g("",!0)]),n.selectedType==="percentage"&&!o.inputValueExceeds&!n.invoiceSolded?(u(),h("div",du,[r("p",uu," Montant bas\xE9 sur le pourcentage: "+c(o.calculatedAmount)+" "+c(s.currency),1)])):g("",!0),n.invoiceSolded?g("",!0):(u(),h("div",hu,[r("label",mu,c(o.translations.due_date),1),P(a,{class:I(["ecwp-input ecwp-date input input-bordered w-full",[!n.inputValue&&n.showError?"input-error":""]]),id:"quoteDate",modelValue:n.due_date,"onUpdate:modelValue":e[3]||(e[3]=l=>n.due_date=l),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date,locale:"fr",required:""},null,8,["modelValue","format","min-date","class"])])),n.invoiceSolded?(u(),h("div",fu,"Facture d\xE9j\xE0 sold\xE9")):g("",!0),r("div",pu,[r("button",{onClick:e[4]||(e[4]=(...l)=>o.onCancel&&o.onCancel(...l)),class:"btn btn-secondary rounded-full"},c(s.cancelText),1),r("button",{onClick:e[5]||(e[5]=(...l)=>o.onConfirm&&o.onConfirm(...l)),disabled:o.inputValueExceeds,class:"btn rounded-full btn-error text-white"},c(s.confirmText),9,_u)])])],8,Xd)])}var yu=ne(Wd,[["render",gu]]);const bu={name:"QuoteNavBar",components:{SendQuoteModal:Ld,ConfirmModal:ds,AdvanceModal:yu},props:{quoteInfo:Object,emailActive:Number,advanceActive:Number,currency:String,noItems:Boolean},data(){return{selectedQuote:null,advanceSold:!1,sendQuoteModal:!1,loadingModal:!1,loadingPdf:!1,loading:!1,client_detail:null,subject:"",content:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{async changeQuoteStatus(t){try{const s=await(await fetch("/wp-json/my-easy-compta/v1/quotes/update-status",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({id:this.quoteInfo.id,status:t})})).json();s.success?(this.quoteInfo.status=t,this.quoteInfo.total_amount=s.total_amount,this.showToast(s.message,"alert-success")):(console.error("Failed to update quote status:",s.message),this.showToast(s.message,"alert-error"))}catch(e){console.error("An error occurred while updating quote status:",e),this.showToast(e,"alert-error")}},convertToInvoice(t){fetch(`/wp-json/my-easy-compta/v1/quotes/convert-quote/${t}`,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{e.success?(this.showToast(e.message,"alert-success"),this.$router.push({name:"InvoiceViewDetail",params:{id:e.id}})):this.showToast(e.message,"alert-error")}).catch(e=>{console.error("Error converting quote:",e),this.showToast(e.message,"alert-error")})},handleAdvanceInvoiceConfirm(t){const{type:e,value:s,date:i}=t;this.convertAdvanceInvoice(this.selectedQuote,e,s,i)},convertAdvanceInvoice(t,e,s,i){fetch(`/wp-json/my-easy-compta/v1/quotes/convert-advance/${t}`,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({advance_type:e,advance_value:s,advance_date:i})}).then(n=>n.json()).then(n=>{n.success?(this.showToast(n.message,"alert-success"),this.$router.push({name:"InvoiceViewDetail",params:{id:n.id}})):this.showToast(n.message,"alert-error")}).catch(n=>{console.error("Error converting quote:",n),this.showToast(n.message,"alert-error")})},confirmConvertQuote(t){this.selectedQuote=t,modal_confirm.showModal(),this.showRemoveModal=!0},ConvertAdvanceQuote(t,e){this.selectedQuote=t,this.advanceSold=e,modal_advance.showModal(),this.showRemoveModal=!0},exportToPDF(){this.loadingPdf=!0;const t=this.quoteInfo.id;fetch(`/wp-json/my-easy-compta/v1/quotes/pdf/${t}`,{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw this.loadingPdf=!1,new Error("Network response was not ok");return this.loadingPdf=!1,e.blob()}).then(e=>{const s=URL.createObjectURL(e);window.open(s),this.loadingPdf=!1}).catch(e=>{console.error("There was a problem with the fetch operation:",e),this.loadingPdf=!1})},sendQuote(t){this.loadingModal=!0,this.sendQuoteModal=!0,modal_send_quote.showModal(),this.fetchClient(t),this.fetchSettings()},fetchClient(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/clients/details/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Client not found");return e.json()}).then(e=>{this.client_detail=e,this.loading=!1}).catch(e=>{console.error("Error fetching client info:",e),this.loading=!1})},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok){const e=await t.json();this.subject=e.email_quote_subject,this.content=e.email_quote_content,this.loading=!1}else{const e=await t.json();this.showToast(e.message,"alert-error"),this.loading=!1}}catch(t){this.loading=!1,this.showToast(t.message,"alert-error")}},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},vu={key:0},wu={key:1},xu={key:3,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},Eu=r("span",{class:"loading loading-spinner text-primary loading-lg"},null,-1),Cu=[Eu],Tu={class:"navbar bg-base-100 mb-4 shadow-xl rounded-box flex justify-between"},Iu=r("div",{class:"dropdown"},[r("div",{tabindex:"0",role:"button",class:"btn btn-ghost lg:hidden"},[r("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 6h16M4 12h8m-8 6h16"})])]),r("ul",{tabindex:"0",class:"menu menu-sm dropdown-content mt-3 z-[1] p-2 shadow bg-base-100 rounded-box w-52"},[r("li",null,[r("a",null,"Item 1")]),r("li",null,[r("a",null,"Parent"),r("ul",{class:"p-2"},[r("li",null,[r("a",null,"Submenu 1")]),r("li",null,[r("a",null,"Submenu 2")])])]),r("li",null,[r("a",null,"Item 3")])])],-1),ku={class:"hidden lg:flex gap-2"},Au={class:"btn btn-sm"},Su=r("i",{class:"far fa-edit"},null,-1),Du=r("i",{class:"fa fa-check"},null,-1),Pu=["data-tip"],Ru={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},ju=r("i",{class:"fas fa-check"},null,-1),Mu=r("i",{class:"fa fa-check"},null,-1),Ou=r("i",{class:"fa fa-times"},null,-1),qu={key:4},Nu={class:"dropdown"},Bu={tabindex:"0",role:"button",class:"btn btn-sm"},Vu=r("i",{class:"fas fa-exchange-alt"},null,-1),Fu={tabindex:"0",class:"dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow"},Uu={key:0},Lu={key:5},Wu=r("i",{class:"fas fa-exchange-alt"},null,-1),Xu={class:"flex gap-2"},Hu=r("i",{class:"fas fa-paper-plane"},null,-1),zu={key:0},Qu={key:1},Gu={key:2,class:"far fa-envelope"},Ju=["data-tip"],Yu={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},Ku=r("i",{class:"fas fa-paper-plane"},null,-1),Zu=["data-tip"],$u={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},eh=r("i",{class:"fas fa-paper-plane"},null,-1),th=["disabled"],nh=r("i",{class:"far fa-file-pdf"},null,-1),sh={key:0,class:"loading loading-spinner loading-sm"};function oh(t,e,s,i,n,o){const a=O("send-quote-modal"),l=O("confirm-modal"),f=O("advance-modal"),d=O("router-link");return u(),h("div",null,[s.emailActive==1?(u(),h("div",vu,[P(a,{loading:n.loadingModal,"show-modal":n.sendQuoteModal,"modal-id":"modal_send_quote",client:n.client_detail,"quote-id":s.quoteInfo.id,subject:n.subject,content:n.content,onClose:e[0]||(e[0]=m=>n.sendQuoteModal=!1)},null,8,["loading","show-modal","client","quote-id","subject","content"])])):g("",!0),P(l,{"show-modal":t.showConfirmModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,onConfirm:e[1]||(e[1]=m=>this.convertToInvoice(n.selectedQuote)),onCancel:e[2]||(e[2]=m=>t.showConfirmModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),s.advanceActive==1?(u(),h("div",wu,[P(f,{"show-modal":t.showConfirmModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,"total-amount":s.quoteInfo.total_amount,currency:s.currency,quoteId:s.quoteInfo.id,"advance-sold":n.advanceSold,onConfirm:o.handleAdvanceInvoiceConfirm,onCancel:e[3]||(e[3]=m=>t.showConfirmModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText","total-amount","currency","quoteId","advance-sold","onConfirm"])])):g("",!0),n.toast.visible?(u(),h("div",{key:2,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),n.loading?(u(),h("div",xu,Cu)):g("",!0),r("div",Tu,[r("div",null,[Iu,r("div",ku,[P(d,{to:{name:"QuoteEdit",params:{id:s.quoteInfo.id}}},{default:me(()=>[r("button",Au,[Su,C(c(o.translations.edit_quote),1)])]),_:1},8,["to"]),s.quoteInfo.status=="draft"&&!s.noItems?(u(),h("button",{key:0,class:"btn btn-outline btn-success btn-sm",onClick:e[4]||(e[4]=m=>o.changeQuoteStatus("pending"))},[Du,C(" "+c(o.translations.validate_quote),1)])):g("",!0),s.quoteInfo.status=="draft"&&s.noItems?(u(),h("div",{key:1,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.min_article},[r("button",Ru,[ju,C(" "+c(o.translations.validate_quote),1)])],8,Pu)):g("",!0),(s.quoteInfo.status=="pending"||s.quoteInfo.status=="rejected")&&!s.noItems?(u(),h("button",{key:2,class:"btn btn-outline btn-success btn-sm",onClick:e[5]||(e[5]=m=>o.changeQuoteStatus("approved"))},[Mu,C(" "+c(o.translations.mark_as_accepted),1)])):g("",!0),(s.quoteInfo.status=="pending"||s.quoteInfo.status=="approved")&&!s.noItems?(u(),h("button",{key:3,class:"btn btn-outline btn-error btn-sm",onClick:e[6]||(e[6]=m=>o.changeQuoteStatus("rejected"))},[Ou,C(" "+c(o.translations.mark_as_rejected),1)])):g("",!0),s.advanceActive==1&&s.quoteInfo.converted!=1&&s.quoteInfo.status=="approved"&&!s.noItems?(u(),h("div",qu,[r("div",Nu,[r("div",Bu,[Vu,C(" "+c(o.translations.convertToInvoice),1)]),r("ul",Fu,[s.quoteInfo.advance!=1?(u(),h("li",Uu,[r("a",{href:"#",onClick:e[7]||(e[7]=J(m=>o.confirmConvertQuote(s.quoteInfo.id),["prevent"]))}," Facture global ")])):g("",!0),r("li",null,[r("a",{href:"#",onClick:e[8]||(e[8]=J(m=>o.ConvertAdvanceQuote(s.quoteInfo.id,"no_sold"),["prevent"]))}," Facture d'acompte "),s.quoteInfo.advance!=0?(u(),h("a",{key:0,href:"#",onClick:e[9]||(e[9]=J(m=>o.ConvertAdvanceQuote(s.quoteInfo.id,"sold"),["prevent"]))}," Facture du solde ")):g("",!0)])])])])):g("",!0),s.advanceActive!=1&&s.quoteInfo.converted!=1&&s.quoteInfo.status=="approved"&&!s.noItems?(u(),h("div",Lu,[r("button",{onClick:e[10]||(e[10]=m=>o.confirmConvertQuote(s.quoteInfo.id)),class:"btn btn-sm"},[Wu,C(" "+c(o.translations.convertToInvoice),1)])])):g("",!0)])]),r("div",Xu,[s.emailActive==1&&s.quoteInfo.status!="draft"?(u(),h("button",{key:0,onClick:e[11]||(e[11]=J(m=>o.sendQuote(s.quoteInfo.client_id),["prevent"])),class:"btn btn-outline btn-primary btn-sm hover:text-white"},[Hu,s.quoteInfo.sent==1?(u(),h("span",zu,c(o.translations.resend_quote),1)):(u(),h("span",Qu,c(o.translations.send_quote),1)),s.quoteInfo.sent==1?(u(),h("i",Gu)):g("",!0)])):s.emailActive==1&&s.quoteInfo.status=="draft"?(u(),h("div",{key:1,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.quote_draft_cannot_send},[r("button",Yu,[Ku,C(" "+c(o.translations.send_quote),1)])],8,Ju)):(u(),h("div",{key:2,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.active_email_addon},[r("button",$u,[eh,C(" "+c(o.translations.send_quote),1)])],8,Zu)),r("button",{onClick:e[12]||(e[12]=(...m)=>o.exportToPDF&&o.exportToPDF(...m)),class:"btn btn-outline btn-success btn-sm",disabled:n.loadingPdf},[nh,C(" "+c(o.translations.exportToPDF)+" ",1),n.loadingPdf?(u(),h("span",sh)):g("",!0)],8,th)])])])}var ih=ne(bu,[["render",oh]]);const rh={components:{VueEditor:mt.exports.VueEditor},props:{loading:Boolean,showModal:Boolean,modalId:String,modalTitle:String,item:Object},data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{editedItem:{...this.item},loading:this.loading,loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},fields:{item_name:{label:t.item_name},item_description:{label:t.description,type:"textarea"},quantity:{label:t.quantity,type:"number"},vat_rate:{label:t.vat,type:"number"},unit_price:{label:t.unit_price,type:"number"},discount:{label:t.discount,type:"number"}}}},computed:{skeletonItems(){return Array.from({length:10},(t,e)=>e)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const t=await fetch(`/wp-json/my-easy-compta/v1/quotes/edit-item/${this.editedItem.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.editedItem)});if(t.ok){const e=await t.json();this.loadingBtn=!1,this.closeModal(),this.showToast(e.message,"alert-success"),this.$emit("itemEdited")}else{const e=`Error editing item: ${t.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(t){const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Error editing item";this.showToast(e,"alert-error"),console.error("Error editing item:",t),this.loadingBtn=!1}},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},resize(){let t=this.$refs.textarea;t.style.height="auto",t.style.height=t.scrollHeight+"px"},increase(){this.newItem.quantity++},decrease(){this.newItem.quantity>1&&this.newItem.quantity--}},watch:{item:{handler(t){this.editedItem={...t}},immediate:!0}}},ah=["id","open"],lh={class:"modal-box"},ch={class:"font-bold text-lg"},dh={key:0},uh={class:"grid grid-cols-1 gap-4"},hh=r("div",{class:"skeleton h-4 w-full mb-2"},null,-1),mh=r("div",{class:"skeleton h-4 w-full"},null,-1),fh=[hh,mh],ph={class:"grid grid-cols-1 gap-4"},_h=["type"],gh=["for"],yh=["id","onUpdate:modelValue"],bh={key:1},vh=["for"],wh={class:"form-group mt-4 flex justify-end"},xh=["disabled"],Eh={key:0,class:"loading loading-spinner loading-sm"};function Ch(t,e,s,i,n,o){const a=O("vue-editor");return u(),h("div",null,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),r("dialog",{id:s.modalId,class:"modal",open:s.showModal},[r("div",lh,[r("h3",ch,c(s.modalTitle),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=l=>o.closeModal())}," \u2715 "),n.loading?(u(),h("div",dh,[r("div",uh,[(u(!0),h(F,null,U(o.skeletonItems,l=>(u(),h("div",{key:l,class:"py-2"},fh))),128))])])):(u(),h("form",{key:1,onSubmit:e[1]||(e[1]=J((...l)=>o.submitForm&&o.submitForm(...l),["prevent"])),class:"form"},[r("div",ph,[(u(!0),h(F,null,U(n.fields,(l,f)=>(u(),h("div",{key:f,class:"ecwp-group form-group"},[l.type!=="textarea"?(u(),h("div",{key:0,type:l.type||"text"},[r("label",{for:f,class:"ecwp-label form-label"},c(l.label),9,gh),D(r("input",{id:f,"onUpdate:modelValue":d=>n.editedItem[f]=d,class:I(["ecwp-input input input-bordered",l.class||"w-full"])},null,10,yh),[[W,n.editedItem[f]]])],8,_h)):(u(),h("div",bh,[r("label",{for:f,class:"form-label"},c(l.label),9,vh),P(a,{id:f,modelValue:n.editedItem[f],"onUpdate:modelValue":d=>n.editedItem[f]=d,editorToolbar:t.toolbarOptions},null,8,["id","modelValue","onUpdate:modelValue","editorToolbar"])]))]))),128))]),r("div",wh,[r("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(c(o.translations.save)+" ",1),n.loadingBtn?(u(),h("span",Eh)):g("",!0)],8,xh)])],32))])],8,ah)])}var Th=ne(rh,[["render",Ch]]);const Ih={props:{showModal:Boolean,modalId:String,modalTitle:String},data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{articles:[],translations:t}},computed:{skeletonItems(){return Array.from({length:7},(t,e)=>e)}},mounted(){this.fetchArticlesList()},methods:{closeModal(){const t=document.getElementById(this.modalId);t&&(t.close(),this.$emit("close"))},selectItem(t){this.$emit("select-article",t),this.closeModal()},fetchArticlesList(){this.loading=!0,fetch("/wp-json/my-easy-compta/v1/articles",{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.articles=t,this.loading=!1}).catch(t=>{console.error("Erreur lors du chargement des articles :",t),this.loading=!1})}}},kh=["id","open"],Ah={class:"modal-box"},Sh={class:"font-bold text-lg"},Dh={key:0},Ph={key:0,class:""},Rh=["onClick"],jh={key:1},Mh={class:"grid grid-cols-2 gap-4"},Oh=r("div",{class:"skeleton h-4 w-full mb-2"},null,-1),qh=r("div",{class:"skeleton h-4 w-full"},null,-1),Nh=[Oh,qh];function Bh(t,e,s,i,n,o){return u(),h("dialog",{id:s.modalId,class:"modal",open:s.showModal},[r("div",Ah,[r("h3",Sh,c(s.modalTitle),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=a=>o.closeModal())}," \u2715 "),n.articles?(u(),h("div",Dh,[n.articles.length?(u(),h("ul",Ph,[(u(!0),h(F,null,U(n.articles,a=>(u(),h("li",{key:a.name,onClick:l=>o.selectItem(a),class:"flex justify-between autocomplete-item hover:bg-base-200"},[r("span",null,[r("strong",null,c(a.ref),1),C(" - "+c(a.name),1)]),r("span",null,[r("strong",null,c(a.unit_price),1)])],8,Rh))),128))])):g("",!0)])):(u(),h("div",jh,[r("div",Mh,[(u(!0),h(F,null,U(o.skeletonItems,a=>(u(),h("div",{key:a,class:"py-2"},Nh))),128))])]))])],8,kh)}var zo=ne(Ih,[["render",Bh]]);/**!
    1111 * Sortable 1.15.2
    1212 * @author  RubaXa   <trash@rubaxa.org>
    1313 * @author  owenm    <owen23355@gmail.com>
    1414 * @license MIT
    15  */function Hs(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),s.push.apply(s,i)}return s}function Oe(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?Hs(Object(s),!0).forEach(function(i){Vh(t,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Hs(Object(s)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(s,i))})}return t}function Yt(t){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Yt=function(e){return typeof e}:Yt=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Yt(t)}function Vh(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function Le(){return Le=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(t[i]=s[i])}return t},Le.apply(this,arguments)}function Fh(t,e){if(t==null)return{};var s={},i=Object.keys(t),n,o;for(o=0;o<i.length;o++)n=i[o],!(e.indexOf(n)>=0)&&(s[n]=t[n]);return s}function Uh(t,e){if(t==null)return{};var s=Fh(t,e),i,n;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(n=0;n<o.length;n++)i=o[n],!(e.indexOf(i)>=0)&&(!Object.prototype.propertyIsEnumerable.call(t,i)||(s[i]=t[i]))}return s}var Lh="1.15.2";function Ue(t){if(typeof window!="undefined"&&window.navigator)return!!navigator.userAgent.match(t)}var We=Ue(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Vt=Ue(/Edge/i),Qs=Ue(/firefox/i),kt=Ue(/safari/i)&&!Ue(/chrome/i)&&!Ue(/android/i),zo=Ue(/iP(ad|od|hone)/i),Go=Ue(/chrome/i)&&Ue(/android/i),Jo={capture:!1,passive:!1};function z(t,e,s){t.addEventListener(e,s,!We&&Jo)}function H(t,e,s){t.removeEventListener(e,s,!We&&Jo)}function on(t,e){if(!!e){if(e[0]===">"&&(e=e.substring(1)),t)try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch{return!1}return!1}}function Wh(t){return t.host&&t!==document&&t.host.nodeType?t.host:t.parentNode}function ke(t,e,s,i){if(t){s=s||document;do{if(e!=null&&(e[0]===">"?t.parentNode===s&&on(t,e):on(t,e))||i&&t===s)return t;if(t===s)break}while(t=Wh(t))}return null}var zs=/\s+/g;function ye(t,e,s){if(t&&e)if(t.classList)t.classList[s?"add":"remove"](e);else{var i=(" "+t.className+" ").replace(zs," ").replace(" "+e+" "," ");t.className=(i+(s?" "+e:"")).replace(zs," ")}}function N(t,e,s){var i=t&&t.style;if(i){if(s===void 0)return document.defaultView&&document.defaultView.getComputedStyle?s=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(s=t.currentStyle),e===void 0?s:s[e];!(e in i)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),i[e]=s+(typeof s=="string"?"":"px")}}function ct(t,e){var s="";if(typeof t=="string")s=t;else do{var i=N(t,"transform");i&&i!=="none"&&(s=i+" "+s)}while(!e&&(t=t.parentNode));var n=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return n&&new n(s)}function Yo(t,e,s){if(t){var i=t.getElementsByTagName(e),n=0,o=i.length;if(s)for(;n<o;n++)s(i[n],n);return i}return[]}function Me(){var t=document.scrollingElement;return t||document.documentElement}function ie(t,e,s,i,n){if(!(!t.getBoundingClientRect&&t!==window)){var o,a,l,f,d,m,p;if(t!==window&&t.parentNode&&t!==Me()?(o=t.getBoundingClientRect(),a=o.top,l=o.left,f=o.bottom,d=o.right,m=o.height,p=o.width):(a=0,l=0,f=window.innerHeight,d=window.innerWidth,m=window.innerHeight,p=window.innerWidth),(e||s)&&t!==window&&(n=n||t.parentNode,!We))do if(n&&n.getBoundingClientRect&&(N(n,"transform")!=="none"||s&&N(n,"position")!=="static")){var y=n.getBoundingClientRect();a-=y.top+parseInt(N(n,"border-top-width")),l-=y.left+parseInt(N(n,"border-left-width")),f=a+o.height,d=l+o.width;break}while(n=n.parentNode);if(i&&t!==window){var _=ct(n||t),v=_&&_.a,x=_&&_.d;_&&(a/=x,l/=v,p/=v,m/=x,f=a+m,d=l+p)}return{top:a,left:l,bottom:f,right:d,width:p,height:m}}}function Gs(t,e,s){for(var i=Ke(t,!0),n=ie(t)[e];i;){var o=ie(i)[s],a=void 0;if(s==="top"||s==="left"?a=n>=o:a=n<=o,!a)return i;if(i===Me())break;i=Ke(i,!1)}return!1}function ht(t,e,s,i){for(var n=0,o=0,a=t.children;o<a.length;){if(a[o].style.display!=="none"&&a[o]!==M.ghost&&(i||a[o]!==M.dragged)&&ke(a[o],s.draggable,t,!1)){if(n===e)return a[o];n++}o++}return null}function us(t,e){for(var s=t.lastElementChild;s&&(s===M.ghost||N(s,"display")==="none"||e&&!on(s,e));)s=s.previousElementSibling;return s||null}function we(t,e){var s=0;if(!t||!t.parentNode)return-1;for(;t=t.previousElementSibling;)t.nodeName.toUpperCase()!=="TEMPLATE"&&t!==M.clone&&(!e||on(t,e))&&s++;return s}function Js(t){var e=0,s=0,i=Me();if(t)do{var n=ct(t),o=n.a,a=n.d;e+=t.scrollLeft*o,s+=t.scrollTop*a}while(t!==i&&(t=t.parentNode));return[e,s]}function Xh(t,e){for(var s in t)if(!!t.hasOwnProperty(s)){for(var i in e)if(e.hasOwnProperty(i)&&e[i]===t[s][i])return Number(s)}return-1}function Ke(t,e){if(!t||!t.getBoundingClientRect)return Me();var s=t,i=!1;do if(s.clientWidth<s.scrollWidth||s.clientHeight<s.scrollHeight){var n=N(s);if(s.clientWidth<s.scrollWidth&&(n.overflowX=="auto"||n.overflowX=="scroll")||s.clientHeight<s.scrollHeight&&(n.overflowY=="auto"||n.overflowY=="scroll")){if(!s.getBoundingClientRect||s===document.body)return Me();if(i||e)return s;i=!0}}while(s=s.parentNode);return Me()}function Hh(t,e){if(t&&e)for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s]);return t}function jn(t,e){return Math.round(t.top)===Math.round(e.top)&&Math.round(t.left)===Math.round(e.left)&&Math.round(t.height)===Math.round(e.height)&&Math.round(t.width)===Math.round(e.width)}var At;function Ko(t,e){return function(){if(!At){var s=arguments,i=this;s.length===1?t.call(i,s[0]):t.apply(i,s),At=setTimeout(function(){At=void 0},e)}}}function Qh(){clearTimeout(At),At=void 0}function Zo(t,e,s){t.scrollLeft+=e,t.scrollTop+=s}function $o(t){var e=window.Polymer,s=window.jQuery||window.Zepto;return e&&e.dom?e.dom(t).cloneNode(!0):s?s(t).clone(!0)[0]:t.cloneNode(!0)}function ei(t,e,s){var i={};return Array.from(t.children).forEach(function(n){var o,a,l,f;if(!(!ke(n,e.draggable,t,!1)||n.animated||n===s)){var d=ie(n);i.left=Math.min((o=i.left)!==null&&o!==void 0?o:1/0,d.left),i.top=Math.min((a=i.top)!==null&&a!==void 0?a:1/0,d.top),i.right=Math.max((l=i.right)!==null&&l!==void 0?l:-1/0,d.right),i.bottom=Math.max((f=i.bottom)!==null&&f!==void 0?f:-1/0,d.bottom)}}),i.width=i.right-i.left,i.height=i.bottom-i.top,i.x=i.left,i.y=i.top,i}var ve="Sortable"+new Date().getTime();function zh(){var t=[],e;return{captureAnimationState:function(){if(t=[],!!this.options.animation){var i=[].slice.call(this.el.children);i.forEach(function(n){if(!(N(n,"display")==="none"||n===M.ghost)){t.push({target:n,rect:ie(n)});var o=Oe({},t[t.length-1].rect);if(n.thisAnimationDuration){var a=ct(n,!0);a&&(o.top-=a.f,o.left-=a.e)}n.fromRect=o}})}},addAnimationState:function(i){t.push(i)},removeAnimationState:function(i){t.splice(Xh(t,{target:i}),1)},animateAll:function(i){var n=this;if(!this.options.animation){clearTimeout(e),typeof i=="function"&&i();return}var o=!1,a=0;t.forEach(function(l){var f=0,d=l.target,m=d.fromRect,p=ie(d),y=d.prevFromRect,_=d.prevToRect,v=l.rect,x=ct(d,!0);x&&(p.top-=x.f,p.left-=x.e),d.toRect=p,d.thisAnimationDuration&&jn(y,p)&&!jn(m,p)&&(v.top-p.top)/(v.left-p.left)===(m.top-p.top)/(m.left-p.left)&&(f=Jh(v,y,_,n.options)),jn(p,m)||(d.prevFromRect=m,d.prevToRect=p,f||(f=n.options.animation),n.animate(d,v,p,f)),f&&(o=!0,a=Math.max(a,f),clearTimeout(d.animationResetTimer),d.animationResetTimer=setTimeout(function(){d.animationTime=0,d.prevFromRect=null,d.fromRect=null,d.prevToRect=null,d.thisAnimationDuration=null},f),d.thisAnimationDuration=f)}),clearTimeout(e),o?e=setTimeout(function(){typeof i=="function"&&i()},a):typeof i=="function"&&i(),t=[]},animate:function(i,n,o,a){if(a){N(i,"transition",""),N(i,"transform","");var l=ct(this.el),f=l&&l.a,d=l&&l.d,m=(n.left-o.left)/(f||1),p=(n.top-o.top)/(d||1);i.animatingX=!!m,i.animatingY=!!p,N(i,"transform","translate3d("+m+"px,"+p+"px,0)"),this.forRepaintDummy=Gh(i),N(i,"transition","transform "+a+"ms"+(this.options.easing?" "+this.options.easing:"")),N(i,"transform","translate3d(0,0,0)"),typeof i.animated=="number"&&clearTimeout(i.animated),i.animated=setTimeout(function(){N(i,"transition",""),N(i,"transform",""),i.animated=!1,i.animatingX=!1,i.animatingY=!1},a)}}}}function Gh(t){return t.offsetWidth}function Jh(t,e,s,i){return Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))/Math.sqrt(Math.pow(e.top-s.top,2)+Math.pow(e.left-s.left,2))*i.animation}var ot=[],Rn={initializeByDefault:!0},Ft={mount:function(e){for(var s in Rn)Rn.hasOwnProperty(s)&&!(s in e)&&(e[s]=Rn[s]);ot.forEach(function(i){if(i.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),ot.push(e)},pluginEvent:function(e,s,i){var n=this;this.eventCanceled=!1,i.cancel=function(){n.eventCanceled=!0};var o=e+"Global";ot.forEach(function(a){!s[a.pluginName]||(s[a.pluginName][o]&&s[a.pluginName][o](Oe({sortable:s},i)),s.options[a.pluginName]&&s[a.pluginName][e]&&s[a.pluginName][e](Oe({sortable:s},i)))})},initializePlugins:function(e,s,i,n){ot.forEach(function(l){var f=l.pluginName;if(!(!e.options[f]&&!l.initializeByDefault)){var d=new l(e,s,e.options);d.sortable=e,d.options=e.options,e[f]=d,Le(i,d.defaults)}});for(var o in e.options)if(!!e.options.hasOwnProperty(o)){var a=this.modifyOption(e,o,e.options[o]);typeof a!="undefined"&&(e.options[o]=a)}},getEventProperties:function(e,s){var i={};return ot.forEach(function(n){typeof n.eventProperties=="function"&&Le(i,n.eventProperties.call(s[n.pluginName],e))}),i},modifyOption:function(e,s,i){var n;return ot.forEach(function(o){!e[o.pluginName]||o.optionListeners&&typeof o.optionListeners[s]=="function"&&(n=o.optionListeners[s].call(e[o.pluginName],i))}),n}};function Yh(t){var e=t.sortable,s=t.rootEl,i=t.name,n=t.targetEl,o=t.cloneEl,a=t.toEl,l=t.fromEl,f=t.oldIndex,d=t.newIndex,m=t.oldDraggableIndex,p=t.newDraggableIndex,y=t.originalEvent,_=t.putSortable,v=t.extraEventProperties;if(e=e||s&&s[ve],!!e){var x,j=e.options,q="on"+i.charAt(0).toUpperCase()+i.substr(1);window.CustomEvent&&!We&&!Vt?x=new CustomEvent(i,{bubbles:!0,cancelable:!0}):(x=document.createEvent("Event"),x.initEvent(i,!0,!0)),x.to=a||s,x.from=l||s,x.item=n||s,x.clone=o,x.oldIndex=f,x.newIndex=d,x.oldDraggableIndex=m,x.newDraggableIndex=p,x.originalEvent=y,x.pullMode=_?_.lastPutMode:void 0;var S=Oe(Oe({},v),Ft.getEventProperties(i,e));for(var k in S)x[k]=S[k];s&&s.dispatchEvent(x),j[q]&&j[q].call(e,x)}}var Kh=["evt"],ge=function(e,s){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=i.evt,o=Uh(i,Kh);Ft.pluginEvent.bind(M)(e,s,Oe({dragEl:E,parentEl:te,ghostEl:B,rootEl:$,nextEl:tt,lastDownEl:Kt,cloneEl:ee,cloneHidden:Ye,dragStarted:wt,putSortable:de,activeSortable:M.active,originalEvent:n,oldIndex:lt,oldDraggableIndex:St,newIndex:be,newDraggableIndex:Je,hideGhostForTarget:oi,unhideGhostForTarget:ii,cloneNowHidden:function(){Ye=!0},cloneNowShown:function(){Ye=!1},dispatchSortableEvent:function(l){pe({sortable:s,name:l,originalEvent:n})}},o))};function pe(t){Yh(Oe({putSortable:de,cloneEl:ee,targetEl:E,rootEl:$,oldIndex:lt,oldDraggableIndex:St,newIndex:be,newDraggableIndex:Je},t))}var E,te,B,$,tt,Kt,ee,Ye,lt,be,St,Je,Wt,de,at=!1,rn=!1,an=[],$e,Te,Mn,On,Ys,Ks,wt,it,Dt,Pt=!1,Xt=!1,Zt,he,qn=[],Kn=!1,ln=[],wn=typeof document!="undefined",Ht=zo,Zs=Vt||We?"cssFloat":"float",Zh=wn&&!Go&&!zo&&"draggable"in document.createElement("div"),ti=function(){if(!!wn){if(We)return!1;var t=document.createElement("x");return t.style.cssText="pointer-events:auto",t.style.pointerEvents==="auto"}}(),ni=function(e,s){var i=N(e),n=parseInt(i.width)-parseInt(i.paddingLeft)-parseInt(i.paddingRight)-parseInt(i.borderLeftWidth)-parseInt(i.borderRightWidth),o=ht(e,0,s),a=ht(e,1,s),l=o&&N(o),f=a&&N(a),d=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+ie(o).width,m=f&&parseInt(f.marginLeft)+parseInt(f.marginRight)+ie(a).width;if(i.display==="flex")return i.flexDirection==="column"||i.flexDirection==="column-reverse"?"vertical":"horizontal";if(i.display==="grid")return i.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(o&&l.float&&l.float!=="none"){var p=l.float==="left"?"left":"right";return a&&(f.clear==="both"||f.clear===p)?"vertical":"horizontal"}return o&&(l.display==="block"||l.display==="flex"||l.display==="table"||l.display==="grid"||d>=n&&i[Zs]==="none"||a&&i[Zs]==="none"&&d+m>n)?"vertical":"horizontal"},$h=function(e,s,i){var n=i?e.left:e.top,o=i?e.right:e.bottom,a=i?e.width:e.height,l=i?s.left:s.top,f=i?s.right:s.bottom,d=i?s.width:s.height;return n===l||o===f||n+a/2===l+d/2},em=function(e,s){var i;return an.some(function(n){var o=n[ve].options.emptyInsertThreshold;if(!(!o||us(n))){var a=ie(n),l=e>=a.left-o&&e<=a.right+o,f=s>=a.top-o&&s<=a.bottom+o;if(l&&f)return i=n}}),i},si=function(e){function s(o,a){return function(l,f,d,m){var p=l.options.group.name&&f.options.group.name&&l.options.group.name===f.options.group.name;if(o==null&&(a||p))return!0;if(o==null||o===!1)return!1;if(a&&o==="clone")return o;if(typeof o=="function")return s(o(l,f,d,m),a)(l,f,d,m);var y=(a?l:f).options.group.name;return o===!0||typeof o=="string"&&o===y||o.join&&o.indexOf(y)>-1}}var i={},n=e.group;(!n||Yt(n)!="object")&&(n={name:n}),i.name=n.name,i.checkPull=s(n.pull,!0),i.checkPut=s(n.put),i.revertClone=n.revertClone,e.group=i},oi=function(){!ti&&B&&N(B,"display","none")},ii=function(){!ti&&B&&N(B,"display","")};wn&&!Go&&document.addEventListener("click",function(t){if(rn)return t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.stopImmediatePropagation&&t.stopImmediatePropagation(),rn=!1,!1},!0);var et=function(e){if(E){e=e.touches?e.touches[0]:e;var s=em(e.clientX,e.clientY);if(s){var i={};for(var n in e)e.hasOwnProperty(n)&&(i[n]=e[n]);i.target=i.rootEl=s,i.preventDefault=void 0,i.stopPropagation=void 0,s[ve]._onDragOver(i)}}},tm=function(e){E&&E.parentNode[ve]._isOutsideThisEl(e.target)};function M(t,e){if(!(t&&t.nodeType&&t.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(t));this.el=t,this.options=e=Le({},e),t[ve]=this;var s={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(t.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return ni(t,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(a,l){a.setData("Text",l.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:M.supportPointer!==!1&&"PointerEvent"in window&&!kt,emptyInsertThreshold:5};Ft.initializePlugins(this,t,s);for(var i in s)!(i in e)&&(e[i]=s[i]);si(e);for(var n in this)n.charAt(0)==="_"&&typeof this[n]=="function"&&(this[n]=this[n].bind(this));this.nativeDraggable=e.forceFallback?!1:Zh,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?z(t,"pointerdown",this._onTapStart):(z(t,"mousedown",this._onTapStart),z(t,"touchstart",this._onTapStart)),this.nativeDraggable&&(z(t,"dragover",this),z(t,"dragenter",this)),an.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),Le(this,zh())}M.prototype={constructor:M,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(it=null)},_getDirection:function(e,s){return typeof this.options.direction=="function"?this.options.direction.call(this,e,s,E):this.options.direction},_onTapStart:function(e){if(!!e.cancelable){var s=this,i=this.el,n=this.options,o=n.preventOnFilter,a=e.type,l=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,f=(l||e).target,d=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||f,m=n.filter;if(cm(i),!E&&!(/mousedown|pointerdown/.test(a)&&e.button!==0||n.disabled)&&!d.isContentEditable&&!(!this.nativeDraggable&&kt&&f&&f.tagName.toUpperCase()==="SELECT")&&(f=ke(f,n.draggable,i,!1),!(f&&f.animated)&&Kt!==f)){if(lt=we(f),St=we(f,n.draggable),typeof m=="function"){if(m.call(this,e,f,this)){pe({sortable:s,rootEl:d,name:"filter",targetEl:f,toEl:i,fromEl:i}),ge("filter",s,{evt:e}),o&&e.cancelable&&e.preventDefault();return}}else if(m&&(m=m.split(",").some(function(p){if(p=ke(d,p.trim(),i,!1),p)return pe({sortable:s,rootEl:p,name:"filter",targetEl:f,fromEl:i,toEl:i}),ge("filter",s,{evt:e}),!0}),m)){o&&e.cancelable&&e.preventDefault();return}n.handle&&!ke(d,n.handle,i,!1)||this._prepareDragStart(e,l,f)}}},_prepareDragStart:function(e,s,i){var n=this,o=n.el,a=n.options,l=o.ownerDocument,f;if(i&&!E&&i.parentNode===o){var d=ie(i);if($=o,E=i,te=E.parentNode,tt=E.nextSibling,Kt=i,Wt=a.group,M.dragged=E,$e={target:E,clientX:(s||e).clientX,clientY:(s||e).clientY},Ys=$e.clientX-d.left,Ks=$e.clientY-d.top,this._lastX=(s||e).clientX,this._lastY=(s||e).clientY,E.style["will-change"]="all",f=function(){if(ge("delayEnded",n,{evt:e}),M.eventCanceled){n._onDrop();return}n._disableDelayedDragEvents(),!Qs&&n.nativeDraggable&&(E.draggable=!0),n._triggerDragStart(e,s),pe({sortable:n,name:"choose",originalEvent:e}),ye(E,a.chosenClass,!0)},a.ignore.split(",").forEach(function(m){Yo(E,m.trim(),Nn)}),z(l,"dragover",et),z(l,"mousemove",et),z(l,"touchmove",et),z(l,"mouseup",n._onDrop),z(l,"touchend",n._onDrop),z(l,"touchcancel",n._onDrop),Qs&&this.nativeDraggable&&(this.options.touchStartThreshold=4,E.draggable=!0),ge("delayStart",this,{evt:e}),a.delay&&(!a.delayOnTouchOnly||s)&&(!this.nativeDraggable||!(Vt||We))){if(M.eventCanceled){this._onDrop();return}z(l,"mouseup",n._disableDelayedDrag),z(l,"touchend",n._disableDelayedDrag),z(l,"touchcancel",n._disableDelayedDrag),z(l,"mousemove",n._delayedDragTouchMoveHandler),z(l,"touchmove",n._delayedDragTouchMoveHandler),a.supportPointer&&z(l,"pointermove",n._delayedDragTouchMoveHandler),n._dragStartTimer=setTimeout(f,a.delay)}else f()}},_delayedDragTouchMoveHandler:function(e){var s=e.touches?e.touches[0]:e;Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){E&&Nn(E),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;H(e,"mouseup",this._disableDelayedDrag),H(e,"touchend",this._disableDelayedDrag),H(e,"touchcancel",this._disableDelayedDrag),H(e,"mousemove",this._delayedDragTouchMoveHandler),H(e,"touchmove",this._delayedDragTouchMoveHandler),H(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,s){s=s||e.pointerType=="touch"&&e,!this.nativeDraggable||s?this.options.supportPointer?z(document,"pointermove",this._onTouchMove):s?z(document,"touchmove",this._onTouchMove):z(document,"mousemove",this._onTouchMove):(z(E,"dragend",this),z($,"dragstart",this._onDragStart));try{document.selection?$t(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,s){if(at=!1,$&&E){ge("dragStarted",this,{evt:s}),this.nativeDraggable&&z(document,"dragover",tm);var i=this.options;!e&&ye(E,i.dragClass,!1),ye(E,i.ghostClass,!0),M.active=this,e&&this._appendGhost(),pe({sortable:this,name:"start",originalEvent:s})}else this._nulling()},_emulateDragOver:function(){if(Te){this._lastX=Te.clientX,this._lastY=Te.clientY,oi();for(var e=document.elementFromPoint(Te.clientX,Te.clientY),s=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(Te.clientX,Te.clientY),e!==s);)s=e;if(E.parentNode[ve]._isOutsideThisEl(e),s)do{if(s[ve]){var i=void 0;if(i=s[ve]._onDragOver({clientX:Te.clientX,clientY:Te.clientY,target:e,rootEl:s}),i&&!this.options.dragoverBubble)break}e=s}while(s=s.parentNode);ii()}},_onTouchMove:function(e){if($e){var s=this.options,i=s.fallbackTolerance,n=s.fallbackOffset,o=e.touches?e.touches[0]:e,a=B&&ct(B,!0),l=B&&a&&a.a,f=B&&a&&a.d,d=Ht&&he&&Js(he),m=(o.clientX-$e.clientX+n.x)/(l||1)+(d?d[0]-qn[0]:0)/(l||1),p=(o.clientY-$e.clientY+n.y)/(f||1)+(d?d[1]-qn[1]:0)/(f||1);if(!M.active&&!at){if(i&&Math.max(Math.abs(o.clientX-this._lastX),Math.abs(o.clientY-this._lastY))<i)return;this._onDragStart(e,!0)}if(B){a?(a.e+=m-(Mn||0),a.f+=p-(On||0)):a={a:1,b:0,c:0,d:1,e:m,f:p};var y="matrix(".concat(a.a,",").concat(a.b,",").concat(a.c,",").concat(a.d,",").concat(a.e,",").concat(a.f,")");N(B,"webkitTransform",y),N(B,"mozTransform",y),N(B,"msTransform",y),N(B,"transform",y),Mn=m,On=p,Te=o}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!B){var e=this.options.fallbackOnBody?document.body:$,s=ie(E,!0,Ht,!0,e),i=this.options;if(Ht){for(he=e;N(he,"position")==="static"&&N(he,"transform")==="none"&&he!==document;)he=he.parentNode;he!==document.body&&he!==document.documentElement?(he===document&&(he=Me()),s.top+=he.scrollTop,s.left+=he.scrollLeft):he=Me(),qn=Js(he)}B=E.cloneNode(!0),ye(B,i.ghostClass,!1),ye(B,i.fallbackClass,!0),ye(B,i.dragClass,!0),N(B,"transition",""),N(B,"transform",""),N(B,"box-sizing","border-box"),N(B,"margin",0),N(B,"top",s.top),N(B,"left",s.left),N(B,"width",s.width),N(B,"height",s.height),N(B,"opacity","0.8"),N(B,"position",Ht?"absolute":"fixed"),N(B,"zIndex","100000"),N(B,"pointerEvents","none"),M.ghost=B,e.appendChild(B),N(B,"transform-origin",Ys/parseInt(B.style.width)*100+"% "+Ks/parseInt(B.style.height)*100+"%")}},_onDragStart:function(e,s){var i=this,n=e.dataTransfer,o=i.options;if(ge("dragStart",this,{evt:e}),M.eventCanceled){this._onDrop();return}ge("setupClone",this),M.eventCanceled||(ee=$o(E),ee.removeAttribute("id"),ee.draggable=!1,ee.style["will-change"]="",this._hideClone(),ye(ee,this.options.chosenClass,!1),M.clone=ee),i.cloneId=$t(function(){ge("clone",i),!M.eventCanceled&&(i.options.removeCloneOnHide||$.insertBefore(ee,E),i._hideClone(),pe({sortable:i,name:"clone"}))}),!s&&ye(E,o.dragClass,!0),s?(rn=!0,i._loopId=setInterval(i._emulateDragOver,50)):(H(document,"mouseup",i._onDrop),H(document,"touchend",i._onDrop),H(document,"touchcancel",i._onDrop),n&&(n.effectAllowed="move",o.setData&&o.setData.call(i,n,E)),z(document,"drop",i),N(E,"transform","translateZ(0)")),at=!0,i._dragStartId=$t(i._dragStarted.bind(i,s,e)),z(document,"selectstart",i),wt=!0,kt&&N(document.body,"user-select","none")},_onDragOver:function(e){var s=this.el,i=e.target,n,o,a,l=this.options,f=l.group,d=M.active,m=Wt===f,p=l.sort,y=de||d,_,v=this,x=!1;if(Kn)return;function j(Ve,xn){ge(Ve,v,Oe({evt:e,isOwner:m,axis:_?"vertical":"horizontal",revert:a,dragRect:n,targetRect:o,canSort:p,fromSortable:y,target:i,completed:S,onMove:function(_t,gt){return Qt($,s,E,n,_t,ie(_t),e,gt)},changed:k},xn))}function q(){j("dragOverAnimationCapture"),v.captureAnimationState(),v!==y&&y.captureAnimationState()}function S(Ve){return j("dragOverCompleted",{insertion:Ve}),Ve&&(m?d._hideClone():d._showClone(v),v!==y&&(ye(E,de?de.options.ghostClass:d.options.ghostClass,!1),ye(E,l.ghostClass,!0)),de!==v&&v!==M.active?de=v:v===M.active&&de&&(de=null),y===v&&(v._ignoreWhileAnimating=i),v.animateAll(function(){j("dragOverAnimationComplete"),v._ignoreWhileAnimating=null}),v!==y&&(y.animateAll(),y._ignoreWhileAnimating=null)),(i===E&&!E.animated||i===s&&!i.animated)&&(it=null),!l.dragoverBubble&&!e.rootEl&&i!==document&&(E.parentNode[ve]._isOutsideThisEl(e.target),!Ve&&et(e)),!l.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),x=!0}function k(){be=we(E),Je=we(E,l.draggable),pe({sortable:v,name:"change",toEl:s,newIndex:be,newDraggableIndex:Je,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),i=ke(i,l.draggable,s,!0),j("dragOver"),M.eventCanceled)return x;if(E.contains(e.target)||i.animated&&i.animatingX&&i.animatingY||v._ignoreWhileAnimating===i)return S(!1);if(rn=!1,d&&!l.disabled&&(m?p||(a=te!==$):de===this||(this.lastPutMode=Wt.checkPull(this,d,E,e))&&f.checkPut(this,d,E,e))){if(_=this._getDirection(e,i)==="vertical",n=ie(E),j("dragOverValid"),M.eventCanceled)return x;if(a)return te=$,q(),this._hideClone(),j("revert"),M.eventCanceled||(tt?$.insertBefore(E,tt):$.appendChild(E)),S(!0);var Q=us(s,l.draggable);if(!Q||im(e,_,this)&&!Q.animated){if(Q===E)return S(!1);if(Q&&s===e.target&&(i=Q),i&&(o=ie(i)),Qt($,s,E,n,i,o,e,!!i)!==!1)return q(),Q&&Q.nextSibling?s.insertBefore(E,Q.nextSibling):s.appendChild(E),te=s,k(),S(!0)}else if(Q&&om(e,_,this)){var le=ht(s,0,l,!0);if(le===E)return S(!1);if(i=le,o=ie(i),Qt($,s,E,n,i,o,e,!1)!==!1)return q(),s.insertBefore(E,le),te=s,k(),S(!0)}else if(i.parentNode===s){o=ie(i);var Y=0,K,je=E.parentNode!==s,ce=!$h(E.animated&&E.toRect||n,i.animated&&i.toRect||o,_),Xe=_?"top":"left",Ee=Gs(i,"top","top")||Gs(E,"top","top"),He=Ee?Ee.scrollTop:void 0;it!==i&&(K=o[Xe],Pt=!1,Xt=!ce&&l.invertSwap||je),Y=rm(e,i,o,_,ce?1:l.swapThreshold,l.invertedSwapThreshold==null?l.swapThreshold:l.invertedSwapThreshold,Xt,it===i);var fe;if(Y!==0){var qe=we(E);do qe-=Y,fe=te.children[qe];while(fe&&(N(fe,"display")==="none"||fe===B))}if(Y===0||fe===i)return S(!1);it=i,Dt=Y;var Ne=i.nextElementSibling,Ce=!1;Ce=Y===1;var Be=Qt($,s,E,n,i,o,e,Ce);if(Be!==!1)return(Be===1||Be===-1)&&(Ce=Be===1),Kn=!0,setTimeout(sm,30),q(),Ce&&!Ne?s.appendChild(E):i.parentNode.insertBefore(E,Ce?Ne:i),Ee&&Zo(Ee,0,He-Ee.scrollTop),te=E.parentNode,K!==void 0&&!Xt&&(Zt=Math.abs(K-ie(i)[Xe])),k(),S(!0)}if(s.contains(E))return S(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){H(document,"mousemove",this._onTouchMove),H(document,"touchmove",this._onTouchMove),H(document,"pointermove",this._onTouchMove),H(document,"dragover",et),H(document,"mousemove",et),H(document,"touchmove",et)},_offUpEvents:function(){var e=this.el.ownerDocument;H(e,"mouseup",this._onDrop),H(e,"touchend",this._onDrop),H(e,"pointerup",this._onDrop),H(e,"touchcancel",this._onDrop),H(document,"selectstart",this)},_onDrop:function(e){var s=this.el,i=this.options;if(be=we(E),Je=we(E,i.draggable),ge("drop",this,{evt:e}),te=E&&E.parentNode,be=we(E),Je=we(E,i.draggable),M.eventCanceled){this._nulling();return}at=!1,Xt=!1,Pt=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Zn(this.cloneId),Zn(this._dragStartId),this.nativeDraggable&&(H(document,"drop",this),H(s,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),kt&&N(document.body,"user-select",""),N(E,"transform",""),e&&(wt&&(e.cancelable&&e.preventDefault(),!i.dropBubble&&e.stopPropagation()),B&&B.parentNode&&B.parentNode.removeChild(B),($===te||de&&de.lastPutMode!=="clone")&&ee&&ee.parentNode&&ee.parentNode.removeChild(ee),E&&(this.nativeDraggable&&H(E,"dragend",this),Nn(E),E.style["will-change"]="",wt&&!at&&ye(E,de?de.options.ghostClass:this.options.ghostClass,!1),ye(E,this.options.chosenClass,!1),pe({sortable:this,name:"unchoose",toEl:te,newIndex:null,newDraggableIndex:null,originalEvent:e}),$!==te?(be>=0&&(pe({rootEl:te,name:"add",toEl:te,fromEl:$,originalEvent:e}),pe({sortable:this,name:"remove",toEl:te,originalEvent:e}),pe({rootEl:te,name:"sort",toEl:te,fromEl:$,originalEvent:e}),pe({sortable:this,name:"sort",toEl:te,originalEvent:e})),de&&de.save()):be!==lt&&be>=0&&(pe({sortable:this,name:"update",toEl:te,originalEvent:e}),pe({sortable:this,name:"sort",toEl:te,originalEvent:e})),M.active&&((be==null||be===-1)&&(be=lt,Je=St),pe({sortable:this,name:"end",toEl:te,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){ge("nulling",this),$=E=te=B=tt=ee=Kt=Ye=$e=Te=wt=be=Je=lt=St=it=Dt=de=Wt=M.dragged=M.ghost=M.clone=M.active=null,ln.forEach(function(e){e.checked=!0}),ln.length=Mn=On=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":E&&(this._onDragOver(e),nm(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],s,i=this.el.children,n=0,o=i.length,a=this.options;n<o;n++)s=i[n],ke(s,a.draggable,this.el,!1)&&e.push(s.getAttribute(a.dataIdAttr)||lm(s));return e},sort:function(e,s){var i={},n=this.el;this.toArray().forEach(function(o,a){var l=n.children[a];ke(l,this.options.draggable,n,!1)&&(i[o]=l)},this),s&&this.captureAnimationState(),e.forEach(function(o){i[o]&&(n.removeChild(i[o]),n.appendChild(i[o]))}),s&&this.animateAll()},save:function(){var e=this.options.store;e&&e.set&&e.set(this)},closest:function(e,s){return ke(e,s||this.options.draggable,this.el,!1)},option:function(e,s){var i=this.options;if(s===void 0)return i[e];var n=Ft.modifyOption(this,e,s);typeof n!="undefined"?i[e]=n:i[e]=s,e==="group"&&si(i)},destroy:function(){ge("destroy",this);var e=this.el;e[ve]=null,H(e,"mousedown",this._onTapStart),H(e,"touchstart",this._onTapStart),H(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(H(e,"dragover",this),H(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(s){s.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),an.splice(an.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!Ye){if(ge("hideClone",this),M.eventCanceled)return;N(ee,"display","none"),this.options.removeCloneOnHide&&ee.parentNode&&ee.parentNode.removeChild(ee),Ye=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(Ye){if(ge("showClone",this),M.eventCanceled)return;E.parentNode==$&&!this.options.group.revertClone?$.insertBefore(ee,E):tt?$.insertBefore(ee,tt):$.appendChild(ee),this.options.group.revertClone&&this.animate(E,ee),N(ee,"display",""),Ye=!1}}};function nm(t){t.dataTransfer&&(t.dataTransfer.dropEffect="move"),t.cancelable&&t.preventDefault()}function Qt(t,e,s,i,n,o,a,l){var f,d=t[ve],m=d.options.onMove,p;return window.CustomEvent&&!We&&!Vt?f=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(f=document.createEvent("Event"),f.initEvent("move",!0,!0)),f.to=e,f.from=t,f.dragged=s,f.draggedRect=i,f.related=n||e,f.relatedRect=o||ie(e),f.willInsertAfter=l,f.originalEvent=a,t.dispatchEvent(f),m&&(p=m.call(d,f,a)),p}function Nn(t){t.draggable=!1}function sm(){Kn=!1}function om(t,e,s){var i=ie(ht(s.el,0,s.options,!0)),n=ei(s.el,s.options,B),o=10;return e?t.clientX<n.left-o||t.clientY<i.top&&t.clientX<i.right:t.clientY<n.top-o||t.clientY<i.bottom&&t.clientX<i.left}function im(t,e,s){var i=ie(us(s.el,s.options.draggable)),n=ei(s.el,s.options,B),o=10;return e?t.clientX>n.right+o||t.clientY>i.bottom&&t.clientX>i.left:t.clientY>n.bottom+o||t.clientX>i.right&&t.clientY>i.top}function rm(t,e,s,i,n,o,a,l){var f=i?t.clientY:t.clientX,d=i?s.height:s.width,m=i?s.top:s.left,p=i?s.bottom:s.right,y=!1;if(!a){if(l&&Zt<d*n){if(!Pt&&(Dt===1?f>m+d*o/2:f<p-d*o/2)&&(Pt=!0),Pt)y=!0;else if(Dt===1?f<m+Zt:f>p-Zt)return-Dt}else if(f>m+d*(1-n)/2&&f<p-d*(1-n)/2)return am(e)}return y=y||a,y&&(f<m+d*o/2||f>p-d*o/2)?f>m+d/2?1:-1:0}function am(t){return we(E)<we(t)?1:-1}function lm(t){for(var e=t.tagName+t.className+t.src+t.href+t.textContent,s=e.length,i=0;s--;)i+=e.charCodeAt(s);return i.toString(36)}function cm(t){ln.length=0;for(var e=t.getElementsByTagName("input"),s=e.length;s--;){var i=e[s];i.checked&&ln.push(i)}}function $t(t){return setTimeout(t,0)}function Zn(t){return clearTimeout(t)}wn&&z(document,"touchmove",function(t){(M.active||at)&&t.cancelable&&t.preventDefault()});M.utils={on:z,off:H,css:N,find:Yo,is:function(e,s){return!!ke(e,s,e,!1)},extend:Hh,throttle:Ko,closest:ke,toggleClass:ye,clone:$o,index:we,nextTick:$t,cancelNextTick:Zn,detectDirection:ni,getChild:ht};M.get=function(t){return t[ve]};M.mount=function(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];e[0].constructor===Array&&(e=e[0]),e.forEach(function(i){if(!i.prototype||!i.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(i));i.utils&&(M.utils=Oe(Oe({},M.utils),i.utils)),Ft.mount(i)})};M.create=function(t,e){return new M(t,e)};M.version=Lh;var oe=[],xt,$n,es=!1,Bn,Vn,cn,Et;function dm(){function t(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var e in this)e.charAt(0)==="_"&&typeof this[e]=="function"&&(this[e]=this[e].bind(this))}return t.prototype={dragStarted:function(s){var i=s.originalEvent;this.sortable.nativeDraggable?z(document,"dragover",this._handleAutoScroll):this.options.supportPointer?z(document,"pointermove",this._handleFallbackAutoScroll):i.touches?z(document,"touchmove",this._handleFallbackAutoScroll):z(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(s){var i=s.originalEvent;!this.options.dragOverBubble&&!i.rootEl&&this._handleAutoScroll(i)},drop:function(){this.sortable.nativeDraggable?H(document,"dragover",this._handleAutoScroll):(H(document,"pointermove",this._handleFallbackAutoScroll),H(document,"touchmove",this._handleFallbackAutoScroll),H(document,"mousemove",this._handleFallbackAutoScroll)),$s(),en(),Qh()},nulling:function(){cn=$n=xt=es=Et=Bn=Vn=null,oe.length=0},_handleFallbackAutoScroll:function(s){this._handleAutoScroll(s,!0)},_handleAutoScroll:function(s,i){var n=this,o=(s.touches?s.touches[0]:s).clientX,a=(s.touches?s.touches[0]:s).clientY,l=document.elementFromPoint(o,a);if(cn=s,i||this.options.forceAutoScrollFallback||Vt||We||kt){Fn(s,this.options,l,i);var f=Ke(l,!0);es&&(!Et||o!==Bn||a!==Vn)&&(Et&&$s(),Et=setInterval(function(){var d=Ke(document.elementFromPoint(o,a),!0);d!==f&&(f=d,en()),Fn(s,n.options,d,i)},10),Bn=o,Vn=a)}else{if(!this.options.bubbleScroll||Ke(l,!0)===Me()){en();return}Fn(s,this.options,Ke(l,!1),!1)}}},Le(t,{pluginName:"scroll",initializeByDefault:!0})}function en(){oe.forEach(function(t){clearInterval(t.pid)}),oe=[]}function $s(){clearInterval(Et)}var Fn=Ko(function(t,e,s,i){if(!!e.scroll){var n=(t.touches?t.touches[0]:t).clientX,o=(t.touches?t.touches[0]:t).clientY,a=e.scrollSensitivity,l=e.scrollSpeed,f=Me(),d=!1,m;$n!==s&&($n=s,en(),xt=e.scroll,m=e.scrollFn,xt===!0&&(xt=Ke(s,!0)));var p=0,y=xt;do{var _=y,v=ie(_),x=v.top,j=v.bottom,q=v.left,S=v.right,k=v.width,Q=v.height,le=void 0,Y=void 0,K=_.scrollWidth,je=_.scrollHeight,ce=N(_),Xe=_.scrollLeft,Ee=_.scrollTop;_===f?(le=k<K&&(ce.overflowX==="auto"||ce.overflowX==="scroll"||ce.overflowX==="visible"),Y=Q<je&&(ce.overflowY==="auto"||ce.overflowY==="scroll"||ce.overflowY==="visible")):(le=k<K&&(ce.overflowX==="auto"||ce.overflowX==="scroll"),Y=Q<je&&(ce.overflowY==="auto"||ce.overflowY==="scroll"));var He=le&&(Math.abs(S-n)<=a&&Xe+k<K)-(Math.abs(q-n)<=a&&!!Xe),fe=Y&&(Math.abs(j-o)<=a&&Ee+Q<je)-(Math.abs(x-o)<=a&&!!Ee);if(!oe[p])for(var qe=0;qe<=p;qe++)oe[qe]||(oe[qe]={});(oe[p].vx!=He||oe[p].vy!=fe||oe[p].el!==_)&&(oe[p].el=_,oe[p].vx=He,oe[p].vy=fe,clearInterval(oe[p].pid),(He!=0||fe!=0)&&(d=!0,oe[p].pid=setInterval(function(){i&&this.layer===0&&M.active._onTouchMove(cn);var Ne=oe[this.layer].vy?oe[this.layer].vy*l:0,Ce=oe[this.layer].vx?oe[this.layer].vx*l:0;typeof m=="function"&&m.call(M.dragged.parentNode[ve],Ce,Ne,t,cn,oe[this.layer].el)!=="continue"||Zo(oe[this.layer].el,Ce,Ne)}.bind({layer:p}),24))),p++}while(e.bubbleScroll&&y!==f&&(y=Ke(y,!1)));es=d}},30),ri=function(e){var s=e.originalEvent,i=e.putSortable,n=e.dragEl,o=e.activeSortable,a=e.dispatchSortableEvent,l=e.hideGhostForTarget,f=e.unhideGhostForTarget;if(!!s){var d=i||o;l();var m=s.changedTouches&&s.changedTouches.length?s.changedTouches[0]:s,p=document.elementFromPoint(m.clientX,m.clientY);f(),d&&!d.el.contains(p)&&(a("spill"),this.onSpill({dragEl:n,putSortable:i}))}};function hs(){}hs.prototype={startIndex:null,dragStart:function(e){var s=e.oldDraggableIndex;this.startIndex=s},onSpill:function(e){var s=e.dragEl,i=e.putSortable;this.sortable.captureAnimationState(),i&&i.captureAnimationState();var n=ht(this.sortable.el,this.startIndex,this.options);n?this.sortable.el.insertBefore(s,n):this.sortable.el.appendChild(s),this.sortable.animateAll(),i&&i.animateAll()},drop:ri};Le(hs,{pluginName:"revertOnSpill"});function ms(){}ms.prototype={onSpill:function(e){var s=e.dragEl,i=e.putSortable,n=i||this.sortable;n.captureAnimationState(),s.parentNode&&s.parentNode.removeChild(s),n.animateAll()},drop:ri};Le(ms,{pluginName:"removeOnSpill"});M.mount(new dm);M.mount(ms,hs);const um={name:"QuoteViewDetail",components:{Card:Ze,QuoteNavBar:ih,EditItemModal:Th,RemoveModal:qt,ArticleModal:Qo},data(){return{selectedItem:null,selectedInvoiceId:null,editItemsModal:!1,no_items:!0,loading:!0,loading_add:!1,quote:[],quoteItems:[],newItem:{loading_del:!1,item_ref:"",item_name:"",item_category:"Type",item_description:"",quantity:1,vat_rate:0,unit_price:0,discount:0,total_price:0,total_amount:0},vatRate:0,settings:[],list_vats:[],client_detail:[],client_email:null,client_currency:"",default_vat:"",default_currency:"",default_currency_symbol:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},showArticlesModal:!1,articles:[],categories:[],showDropdown:!1,refs:[],showDropdownRef:!1}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},isQuoteExpired(){const t=new Date().getTime(),e=this.quote.due_date?new Date(this.quote.due_date).getTime():null;return e&&e<t},totalAmountWithoutDiscount(){const t=this.quoteItems.reduce((e,s)=>{const i=s.quantity*s.unit_price;return e+i},0);return this.formatCurrency(t)},totalAmount(){const t=this.quoteItems.reduce((e,s)=>e+parseFloat(s.total_price),0);return this.formatCurrency(t)},totalAmountDefaultCurrency(){return(this.quoteItems.reduce((i,n)=>i+parseFloat(n.total_amount),0)*this.quote.exchange_rate).toFixed(2)},totalAmountWithVAT(){const t=parseFloat(this.totalAmount);if(this.settings.vat_active==1){const e=parseFloat(this.calculateVAT());return this.formatCurrency(t+e)}else return this.formatCurrency(t)},signatureImageUrl(){const t="/wp-json/my-easy-compta/v1/signature-image/",e=myEasyComptaAdmin.nonce;return`${t}${this.quote.file_sign}?_wpnonce=${e}`}},methods:{getUniqueVATRates(){const t=new Set;return this.quoteItems.forEach(e=>{e.vat_rate&&t.add(e.vat_rate)}),Array.from(t)},calculateVATForRate(t){let e=0;return this.quoteItems.forEach(s=>{if(s.vat_rate===t){const i=s.quantity*s.unit_price,n=i*s.discount/100;e+=(i-n)*t/100}}),this.formatCurrency(e)},calculateTotalAmountWithVAT(){let t=this.quoteItems.reduce((e,s)=>e+parseFloat(s.total_amount),0);return this.formatCurrency(t)},fetchQuote(){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/${this.$route.params.id}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{t?(this.quote=t,this.fetchClientInfo(t.client_id)):console.error("Quote not found")}).catch(t=>{console.error("Error fetching quote:",t),this.loading=!1})},fetchClientInfo(t){fetch(`/wp-json/my-easy-compta/v1/clients/details/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Client not found");return e.json()}).then(e=>{this.client_detail=e,this.client_email=e.email;const s=e.currency_id;s&&this.fetchCurrencyDetails(s)}).catch(e=>{console.error("Error fetching client info:",e),this.loading=!1})},fetchItems(){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/${this.$route.params.id}/items`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{t.code=="no_items_found"?(console.error("No items found"),this.quoteItems=[],this.loading=!1,this.no_items=!0):(this.quoteItems=t,this.loading=!1,this.no_items=!1)}).catch(t=>{console.error("Error fetching items:",t),this.loading=!1})},fetchCurrencyDetails(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/settings/currency/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Currency details not found");return this.loading=!1,e.json()}).then(e=>{this.client_currency=e.symbol,this.loading=!1}).catch(e=>{this.loading=!1,console.error("Error fetching currency details:",e)})},updateTotal(){const t=this.newItem.quantity*this.newItem.unit_price,e=t*this.newItem.discount/100,s=t-e;var i=0;if(this.settings.vat_active==1){const n=s*this.newItem.vat_rate/100;i=s+n}else i=s;this.newItem.total_price=this.formatCurrency(s),this.newItem.total_amount=this.formatCurrency(i)},calculateTotalWithVat(t,e,s,i){const n=t*e,o=n*i/100,a=n-o,l=a*s/100,f=a+l;return this.formatCurrency(f)},calculateTotal(t,e,s){const i=t*e,n=i*s/100,a=i-n;return this.formatCurrency(a)},submitItems(){this.updateTotal();const t={...this.newItem,quote_id:this.$route.params.id};this.loading_add=!0,fetch("/wp-json/my-easy-compta/v1/quotes/element-add",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(t)}).then(e=>e.json()).then(e=>{e.success?(this.loading_add=!1,this.fetchItems(),this.newItem={item_name:"",item_ref:"",item_category:"",item_description:"",quantity:1,vat_rate:this.default_vat.rate,unit_price:0,discount:0,total_price:0,total_amount:0}):(this.showToast(e.message,"alert-error"),console.error("Error submitting item:",e.message),this.loading_add=!1)}).catch(e=>{this.showToast(e.message,"alert-error"),console.error("Error submitting item:",e),this.loading_add=!1})},increase(){this.newItem.quantity++},decrease(){this.newItem.quantity>1&&this.newItem.quantity--},confirmremoveItem(t,e){this.selectedItem=t,this.selectedInvoiceId=e,modal_item_remove.showModal(),this.showRemoveModal=!0},removeItem(t,e){const s=this.quoteItems.find(i=>i.id===t);s.loading_del=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/element-delete/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({quote_id:e})}).then(i=>i.json()).then(i=>{i.success?(s.loading_del=!1,this.fetchItems()):(this.showToast(i.message,"alert-error"),console.error("Error removing item:",i.message),s.loading_del=!1)}).catch(i=>{this.showToast(i.message,"alert-error"),console.error("Error removing item:",i),s.loading_del=!1})},editItem(t){this.loadingModal=!0,this.editItemsModal=!0,modal_edit_item.showModal(),this.fetchItemDetails(t)},fetchItemDetails(t){fetch(`/wp-json/my-easy-compta/v1/quotes/item-details/${t}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{this.selectedItem=e,this.loading=!1}).catch(e=>{console.error("Error fetching item details:",e),this.loading=!1})},formatCurrency(t){const e=t.toFixed(2),s=this.client_currency!==this.default_currency_symbol?this.client_currency:this.default_currency_symbol;return`${e}${s}`},calculateDiscountAmountWithVAT(t,e,s,i){const o=t*e*i/100,a=o*s/100,l=o+a;return this.formatCurrency(l)},calculateDiscountAmount(t,e,s){const o=t*e*s/100;return this.formatCurrency(o)},calculateVAT(){const t=parseFloat(this.totalAmount),e=parseFloat(this.default_vat.rate),s=t*(e/100);return this.formatCurrency(s)},onDragEnd(t){const e=this.quoteItems[t.oldIndex];this.quoteItems.splice(t.oldIndex,1),this.quoteItems.splice(t.newIndex,0,e);const s=this.quoteItems.map(i=>i.id);this.saveOrderToDatabase(s)},nl2br(t){return t?t.replace(/\n/g,"<br>"):""},resize(){let t=this.$refs.textarea;t.style.height="auto",t.style.height=t.scrollHeight+"px"},saveOrderToDatabase(t){fetch("/wp-json/my-easy-compta/v1/quotes/update-quote-items-order",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({order:t})}).then(e=>{e.ok?console.log("Order saved successfully."):console.error("Failed to save order:",e.statusText)}).catch(e=>{console.error("Error saving order:",e)})},fetchCategoriesArticles(){fetch("/wp-json/my-easy-compta/v1/categories-articles",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.categories=t}).catch(t=>console.error("Error fetching categories:",t))},ShowModalArticles(){this.showArticlesModal=!0,modal_articles.showModal()},applySelectedArticle(t){this.newItem.item_ref=t.ref,this.newItem.item_name=t.name,this.newItem.item_description=t.description||"",this.newItem.unit_price=t.unit_price||0},fetchArticles(){if(this.newItem.item_name.length<1){this.articles=[];return}const t=document.getElementById("loader_articles");t.classList.remove("hidden"),fetch(`/wp-json/my-easy-compta/v1/articles?search=${this.newItem.item_name}&method=name`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{this.articles=e}).catch(e=>console.error("Error fetching articles:",e)).finally(()=>{t.classList.add("hidden")})},selectItem(t){this.newItem.item_ref=t.ref,this.newItem.item_name=t.name,this.newItem.item_description=t.description,this.newItem.unit_price=t.unit_price,this.showDropdown=!1,this.showDropdownRef=!1},fetchRefs(){if(this.newItem.item_ref.length<1){this.refs=[];return}fetch(`/wp-json/my-easy-compta/v1/articles?search=${this.newItem.item_ref}&method=ref`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.refs=t}).catch(t=>console.error("Error fetching refrences:",t))},async loadSettings(){try{this.loading=!0,this.loadingPrice=!0;const{settings:t,currencySymbol:e,vatData:s,listVatData:i}=await mn();this.settings=t,this.default_currency_symbol=e,this.default_vat=s,this.list_vats=i,this.newItem.vat_rate=this.default_vat.rate,this.loadingPrice=!1,this.loading=!1}catch(t){this.showToast(t.message,"alert-error"),this.loadingPrice=!1,this.loading=!1}},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},highlightMatch(t){if(!this.newItem.item_name)return t;const e=new RegExp(`(${this.escapeRegExp(this.newItem.item_name)})`,"gi");return t.replace(e,"<b>$1</b>")},escapeRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},handleClickOutside(t){this.$el.contains(t.target)||(this.showDropdown=!1,this.showDropdownRef=!1)}},beforeDestroy(){document.removeEventListener("click",this.handleClickOutside)},mounted(){this.fetchQuote(),this.fetchItems(),this.loadSettings(),this.fetchCategoriesArticles(),document.addEventListener("click",this.handleClickOutside);const t=document.querySelector("tbody");M.create(t,{animation:150,handle:".drag-handle",onEnd:this.onDragEnd})}},hm={class:"pt-2 pr-4"},mm={key:1,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},fm=r("span",{class:"loading loading-spinner text-primary loading-lg"},null,-1),pm=[fm],_m={key:2},gm={role:"alert",class:"alert alert-warning"},ym=r("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6 shrink-0 stroke-current",fill:"none",viewBox:"0 0 24 24"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})],-1),bm={key:0,class:"relative"},vm={class:"ecwp-watermark"},wm={class:"grid grid-cols-2"},xm={class:"md:col-span-1"},Em=["src"],Cm={class:"md:col-span-1 text-right"},Tm={class:"text-lg font-semibold"},Im={key:0,class:"badge badge-warning text-white"},km={key:1,class:"badge badge-secondary text-white"},Am={key:2,class:"badge badge-success text-white"},Sm={key:3,class:"badge badge-error text-white"},Dm={class:"bg-base-300 rounded-lg shadow-md flex justify-between p-4 mt-4 gap-4"},Pm=r("br",null,null,-1),jm=r("br",null,null,-1),Rm=r("br",null,null,-1),Mm=["href"],Om=r("br",null,null,-1),qm=r("br",null,null,-1),Nm=r("br",null,null,-1),Bm=["href"],Vm=r("br",null,null,-1),Fm=["href"],Um={class:"table mt-8"},Lm=r("th",null,null,-1),Wm={width:"5%"},Xm={width:"19%"},Hm={width:"21%"},Qm={width:"10%",class:"text-center"},zm={width:"8%",class:"text-center"},Gm={key:0,width:"5%",class:"text-center"},Jm={key:1,width:"5%"},Ym={width:"10%",class:"text-center"},Km={width:"10%",class:"text-right"},Zm=r("th",{width:"18%",class:"text-right inv-actions"},null,-1),$m=r("td",{class:"draggable-item drag-handle px-2"},[r("i",{class:"fas fa-sort"})],-1),ef={key:0,class:"badge badge-ghost badge-xs"},tf=["innerHTML"],nf={class:"text-center"},sf={class:"text-center"},of={key:0},rf={key:1},af={key:0,class:"text-center"},lf={key:1},cf={key:2,class:"text-center"},df=r("br",null,null,-1),uf={key:3,class:"text-center"},hf=r("br",null,null,-1),mf={class:"text-right"},ff={key:0},pf={key:1},_f=["data-tip"],gf=["onClick"],yf=r("i",{class:"far fa-edit"},null,-1),bf=[yf],vf=["data-tip"],wf=["onClick"],xf={key:0,class:"far fa-trash-alt"},Ef={key:1,class:"loading loading-spinner loading-xs"},Cf={key:0},Tf={class:"align-top px-2"},If=r("i",{class:"fas fa-list-ul"},null,-1),kf=[If],Af={class:"align-top px-2"},Sf={class:"flex items-center border rounded-md relative"},Df=["placeholder"],Pf={key:0,class:"autocomplete-dropdown bg-base-300"},jf=["onClick","innerHTML"],Rf={class:"align-top px-2"},Mf=r("option",{disabled:"",selected:""},"Type",-1),Of=["value"],qf={class:"flex items-center border rounded-md relative"},Nf=r("span",{id:"loader_articles",class:"loading loading-spinner loading-xs absolute right-2 hidden"},null,-1),Bf=["placeholder"],Vf={key:0,class:"autocomplete-dropdown bg-base-300"},Ff=["onClick","innerHTML"],Uf={class:"align-top"},Lf={class:"flex items-center rounded-md"},Wf=["placeholder"],Xf={class:"align-top"},Hf={class:"flex items-center border rounded-lg"},Qf={class:"inline-flex"},zf=["placeholder"],Gf={class:"align-top"},Jf={class:"flex items-center border rounded-md"},Yf=["placeholder"],Kf={key:0,class:"align-top"},Zf=["value"],$f={key:1,class:"align-top"},ep={class:"align-top"},tp={class:"flex items-center border rounded-md"},np=["placeholder"],sp=r("div",{class:"px-3 py-2.5 rounded-l-md bg-base-300 border-r"}," % ",-1),op={key:2,class:"text-right"},ip={key:3,class:"text-right"},rp=["data-tip"],ap={type:"submit",class:"bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded"},lp={key:0,class:"fa fa-plus"},cp={key:1,class:"loading loading-spinner loading-xs"},dp={colspan:"8",class:"text-right no-border"},up={class:"text-right"},hp={key:0,class:"line-through"},mp=r("td",null,null,-1),fp={colspan:"8",class:"text-right no-border"},pp={class:"text-right"},_p=r("td",null,null,-1),gp={colspan:"8",class:"text-right no-border font-bold text-xl"},yp={class:"text-right no-border font-bold text-xl"},bp=r("td",null,null,-1),vp={key:2},wp={colspan:"8",class:"text-right no-border"},xp={class:"text-right no-border"},Ep={key:3},Cp={colspan:"8",class:"text-right no-border"},Tp={class:"text-right no-border font-bold text-xl"},Ip={key:1,class:"relative"},kp={class:"flex justify-end mt-4"},Ap={class:"border-2 border-slate-300 max-w-md"},Sp=["src"];function Dp(t,e,s,i,n,o){const a=O("QuoteNavBar"),l=O("remove-modal"),f=O("article-modal"),d=O("edit-item-modal"),m=O("Card");return u(),h("div",hm,[P(a,{quoteInfo:n.quote,emailActive:n.settings.easy_compta_email_addon_active,advanceActive:n.settings.easy_compta_advance_addon_active,currency:n.default_currency_symbol,noItems:n.no_items},null,8,["quoteInfo","emailActive","advanceActive","currency","noItems"]),n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),P(l,{"modal-id":"modal_item_remove","show-modal":t.showRemoveModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:e[0]||(e[0]=p=>this.removeItem(n.selectedItem,n.selectedInvoiceId)),onCancel:e[1]||(e[1]=p=>t.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),P(f,{"show-modal":n.showArticlesModal,"modal-id":"modal_articles","modal-title":o.translations.select,onSelectArticle:o.applySelectedArticle,onClose:e[2]||(e[2]=p=>n.showArticlesModal=!1)},null,8,["show-modal","modal-title","onSelectArticle"]),n.loading?(u(),h("div",mm,pm)):g("",!0),o.isQuoteExpired&&n.quote.status=="pending"?(u(),h("div",_m,[r("div",gm,[ym,r("span",null,c(o.translations.quote_expired),1)])])):g("",!0),P(m,{topMargin:"mt-8",id:"quote-content"},{default:me(()=>[n.settings.easy_compta_signature_addon_active&&n.quote.signed==1?(u(),h("div",bm,[r("span",vm,c(o.translations.signed),1)])):g("",!0),r("div",wm,[r("div",xm,[r("div",null,[r("img",{src:n.settings.logo_url,style:no({width:n.settings.logo_width+"px"}),alt:"Logo"},null,12,Em)])]),r("div",Cm,[r("p",Tm,c(n.quote.quote_number),1),r("div",null,[C(c(o.translations.created_at)+": ",1),r("strong",null,c(n.quote.created_at),1)]),r("div",null,[C(c(o.translations.due_date)+": ",1),r("strong",null,c(n.quote.due_date),1)]),r("div",null,[C(c(o.translations.provisional_date)+": ",1),r("strong",null,c(n.quote.provisional_start_date),1)]),r("div",null,[C(c(o.translations.status)+": ",1),n.quote.status=="draft"?(u(),h("span",Im,c(o.translations.draft),1)):g("",!0),n.quote.status=="pending"?(u(),h("span",km,c(o.translations.pending),1)):g("",!0),n.quote.status=="approved"?(u(),h("span",Am,c(o.translations.approved),1)):g("",!0),n.quote.status=="rejected"?(u(),h("span",Sm,c(o.translations.rejected),1)):g("",!0)])])]),r("div",Dm,[r("div",null,[r("strong",null,c(o.translations.bill_to)+":",1),r("h4",null,[r("strong",null,c(n.client_detail.company_name),1)]),r("p",null,[C(c(n.client_detail.address),1),Pm,C(" "+c(n.client_detail.postal_code)+", "+c(n.client_detail.city)+" ",1),jm,C(" "+c(n.client_detail.country),1),Rm,n.client_detail.phone?(u(),h("a",{key:0,href:"tel:"+n.client_detail.phone},c(n.client_detail.phone),9,Mm)):g("",!0)])]),r("div",null,[r("strong",null,c(o.translations.received_from)+":",1),r("h4",null,[r("strong",null,c(n.settings.company_name),1)]),r("p",null,[C(c(n.settings.company_address),1),Om,C(" "+c(n.settings.postal_code)+", "+c(n.settings.city)+" ",1),qm,C(" "+c(n.settings.country),1),Nm,n.settings.company_phone?(u(),h("a",{key:0,href:"tel:"+n.settings.company_phone},c(n.settings.company_phone),9,Bm)):g("",!0),Vm,n.settings.mobile_phone?(u(),h("a",{key:1,href:"tel:"+n.settings.mobile_phone},c(n.settings.mobile_phone),9,Fm)):g("",!0)])])]),P(d,{loading:t.loadingModal,"show-modal":n.editItemsModal,"modal-id":"modal_edit_item","modal-title":o.translations.edit_item,item:n.selectedItem,onClose:e[3]||(e[3]=p=>n.editItemsModal=!1),onItemEdited:o.fetchItems},null,8,["loading","show-modal","modal-title","item","onItemEdited"]),r("form",{onSubmit:e[24]||(e[24]=J((...p)=>o.submitItems&&o.submitItems(...p),["prevent"]))},[r("table",Um,[r("thead",null,[r("tr",null,[Lm,r("th",Wm,c(o.translations.item_ref),1),r("th",Xm,c(o.translations.item_name),1),r("th",Hm,c(o.translations.description),1),r("th",Qm,c(o.translations.quantity),1),r("th",zm,c(o.translations.unit_price),1),n.settings.vat_active==1?(u(),h("th",Gm,c(o.translations.vat),1)):(u(),h("th",Jm)),r("th",Ym,c(o.translations.discount),1),r("th",Km,c(o.translations.total),1),Zm])]),r("tbody",null,[(u(!0),h(F,null,U(n.quoteItems,(p,y)=>(u(),h("tr",{key:p.id||y},[$m,r("td",null,c(p.item_ref),1),r("td",null,[p.category_name?(u(),h("div",ef,c(p.category_name),1)):g("",!0),r("div",null,c(p.item_name),1)]),r("td",{innerHTML:o.nl2br(p.item_description)},null,8,tf),r("td",nf,c(p.quantity),1),r("td",sf,[C(c(p.unit_price),1),n.default_currency_symbol==n.client_currency?(u(),h("span",of,c(n.default_currency_symbol),1)):(u(),h("span",rf,c(n.client_currency),1))]),n.settings.vat_active==1?(u(),h("td",af,c(p.vat_rate)+"% ",1)):(u(),h("td",lf)),n.settings.vat_active==1?(u(),h("td",cf,[C(c(p.discount)+"% ",1),df,C(" "+c(o.calculateDiscountAmountWithVAT(p.quantity,p.unit_price,p.vat_rate,p.discount)),1)])):(u(),h("td",uf,[C(c(p.discount)+"% ",1),hf,C(" "+c(o.calculateDiscountAmount(p.quantity,p.unit_price,p.discount)),1)])),r("td",mf,[C(c(p.total_amount)+" ",1),n.default_currency_symbol==n.client_currency?(u(),h("span",ff,c(n.default_currency_symbol),1)):(u(),h("span",pf,c(n.client_currency),1))]),r("td",null,[n.quote.status=="draft"||n.quote.status=="pending"?(u(),h("span",{key:0,class:"lg:tooltip","data-tip":o.translations.edit},[r("button",{onClick:J(_=>o.editItem(p.id),["prevent"]),class:"bg-purple-500 hover:bg-purple-700 text-white font-bold py-2 px-3 rounded"},bf,8,gf)],8,_f)):g("",!0),n.quote.status=="draft"||n.quote.status=="pending"?(u(),h("span",{key:1,class:"lg:tooltip","data-tip":o.translations.delete},[r("button",{onClick:J(_=>o.confirmremoveItem(p.id,n.quote.id),["prevent"]),class:"bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-3 mx-2 rounded"},[p.loading_del?g("",!0):(u(),h("i",xf)),p.loading_del?(u(),h("span",Ef)):g("",!0)],8,wf)],8,vf)):g("",!0)])]))),128)),n.quote.status=="draft"||n.quote.status=="pending"?(u(),h("tr",Cf,[r("td",Tf,[r("span",{class:"cursor-pointer",onClick:e[4]||(e[4]=J((...p)=>o.ShowModalArticles&&o.ShowModalArticles(...p),["prevent"]))},kf)]),r("td",Af,[r("div",Sf,[D(r("input",{type:"text","onUpdate:modelValue":e[5]||(e[5]=p=>n.newItem.item_ref=p),onInput:e[6]||(e[6]=(...p)=>o.fetchRefs&&o.fetchRefs(...p)),onFocus:e[7]||(e[7]=p=>n.showDropdownRef=!0),placeholder:o.translations.item_ref,class:"w-full p-2.5 bg-transparent input-xs outline-none"},null,40,Df),[[W,n.newItem.item_ref]]),n.showDropdownRef&&n.refs.length?(u(),h("ul",Pf,[(u(!0),h(F,null,U(n.refs,p=>(u(),h("li",{key:p.ref,onClick:y=>o.selectItem(p),class:"autocomplete-item hover:bg-base-200",innerHTML:o.highlightMatch(p.ref)},null,8,jf))),128))])):g("",!0)])]),r("td",Rf,[D(r("select",{class:"select select-xs w-full mb-1 ecwp-select","onUpdate:modelValue":e[8]||(e[8]=p=>n.newItem.item_category=p)},[Mf,(u(!0),h(F,null,U(n.categories,p=>(u(),h("option",{key:p.id,value:p.id},c(p.name),9,Of))),128))],512),[[ue,n.newItem.item_category]]),r("div",qf,[Nf,D(r("input",{type:"text","onUpdate:modelValue":e[9]||(e[9]=p=>n.newItem.item_name=p),onInput:e[10]||(e[10]=(...p)=>o.fetchArticles&&o.fetchArticles(...p)),onFocus:e[11]||(e[11]=p=>n.showDropdown=!0),placeholder:o.translations.item_name,class:"w-full p-2.5 bg-transparent input-xs outline-none"},null,40,Bf),[[W,n.newItem.item_name]]),n.showDropdown&&n.articles.length?(u(),h("ul",Vf,[(u(!0),h(F,null,U(n.articles,p=>(u(),h("li",{key:p.name,onClick:y=>o.selectItem(p),class:"autocomplete-item hover:bg-base-200",innerHTML:o.highlightMatch(p.name)},null,8,Ff))),128))])):g("",!0)])]),r("td",Uf,[r("div",Lf,[D(r("textarea",{"onUpdate:modelValue":e[12]||(e[12]=p=>n.newItem.item_description=p),placeholder:o.translations.item_description,class:"textarea textarea-bordered input-xs w-full",onInput:e[13]||(e[13]=p=>o.resize()),ref:"textarea"},null,40,Wf),[[W,n.newItem.item_description]])])]),r("td",Xf,[r("div",Hf,[r("div",Qf,[r("div",{class:"select-none border py-3 px-2 cursor-pointer bg-base-300 hover:bg-gray-200 rounded-l",onClick:e[14]||(e[14]=(...p)=>o.decrease&&o.decrease(...p))}," - "),D(r("input",{type:"text",pattern:"([0-9]+.{0,1}[0-9]*,{0,1})*[0-9]","onUpdate:modelValue":e[15]||(e[15]=p=>n.newItem.quantity=p),placeholder:o.translations.quantity,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[16]||(e[16]=(...p)=>o.updateTotal&&o.updateTotal(...p))},null,40,zf),[[W,n.newItem.quantity]]),r("div",{class:"select-none border py-3 px-2 cursor-pointer bg-base-300 hover:bg-gray-200 rounded-r",onClick:e[17]||(e[17]=(...p)=>o.increase&&o.increase(...p))}," + ")])])]),r("td",Gf,[r("div",Jf,[D(r("input",{type:"text",pattern:"([0-9]+.{0,1}[0-9]*,{0,1})*[0-9]","onUpdate:modelValue":e[18]||(e[18]=p=>n.newItem.unit_price=p),placeholder:o.translations.unit_price,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[19]||(e[19]=(...p)=>o.updateTotal&&o.updateTotal(...p))},null,40,Yf),[[W,n.newItem.unit_price]])])]),n.settings.vat_active==1?(u(),h("td",Kf,[D(r("select",{"onUpdate:modelValue":e[20]||(e[20]=p=>n.newItem.vat_rate=p),onChange:e[21]||(e[21]=(...p)=>o.updateTotal&&o.updateTotal(...p)),class:"select select-md w-full mb-1 ecwp-select min-w-20"},[(u(!0),h(F,null,U(n.list_vats,p=>(u(),h("option",{key:p,value:p.rate},c(p.rate)+"% ",9,Zf))),128))],544),[[ue,n.newItem.vat_rate]])])):(u(),h("td",$f)),r("td",ep,[r("div",tp,[D(r("input",{type:"number",min:"0",max:"100","onUpdate:modelValue":e[22]||(e[22]=p=>n.newItem.discount=p),placeholder:o.translations.discount,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[23]||(e[23]=(...p)=>o.updateTotal&&o.updateTotal(...p))},null,40,np),[[W,n.newItem.discount]]),sp])]),n.settings.vat_active==1?(u(),h("td",op,c(o.calculateTotalWithVat(n.newItem.quantity,n.newItem.unit_price,n.newItem.vat_rate,n.newItem.discount)),1)):(u(),h("td",ip,c(o.calculateTotal(n.newItem.quantity,n.newItem.unit_price,n.newItem.discount)),1)),r("td",null,[r("span",{class:"lg:tooltip","data-tip":o.translations.add},[r("button",ap,[n.loading_add?g("",!0):(u(),h("i",lp)),n.loading_add?(u(),h("span",cp)):g("",!0)])],8,rp)])])):g("",!0),r("tr",null,[r("td",dp,[r("strong",null,c(o.translations.subtotal),1)]),r("td",up,[o.totalAmount!==o.totalAmountWithoutDiscount?(u(),h("span",hp,c(o.totalAmountWithoutDiscount),1)):g("",!0),C(" "+c(o.totalAmount),1)]),mp]),n.settings.vat_active==1?(u(!0),h(F,{key:1},U(o.getUniqueVATRates(),(p,y)=>(u(),h("tr",{key:y},[r("td",fp,[r("strong",null,c(o.translations.tax)+" ("+c(p)+"%) ",1)]),r("td",pp,c(o.calculateVATForRate(p)),1),_p]))),128)):g("",!0),r("tr",null,[r("td",gp,[r("strong",null,c(o.translations.total),1)]),r("td",yp,c(o.calculateTotalAmountWithVAT()),1),bp]),n.client_currency!=n.default_currency_symbol?(u(),h("tr",vp,[r("td",wp,[r("strong",null,c(o.translations.exchange_rate),1)]),r("td",xp,c(n.quote.exchange_rate),1)])):g("",!0),n.client_currency!=n.default_currency_symbol?(u(),h("tr",Ep,[r("td",Cp,[r("strong",null,c(o.translations.total)+" "+c(n.default_currency_symbol),1)]),r("td",Tp,c(o.totalAmountDefaultCurrency)+c(n.default_currency_symbol),1)])):g("",!0)])])],32),n.settings.easy_compta_signature_addon_active&&n.quote.signed==1&&n.quote.file_sign?(u(),h("div",Ip,[r("div",kp,[r("span",Ap,[r("img",{src:o.signatureImageUrl,alt:"Signature"},null,8,Sp)])])])):g("",!0)]),_:1})])}var Pp=ne(um,[["render",Dp]]);const jp={name:"QuoteNew",components:{Card:Ze,ModelSelect:hn,VueDatePicker:Nt,AddClientModal:jo},data(){return{clientOptions:[],clients:[],quote:{number:"",due_date:"",provisional_start_date:"",client_id:"",status:""},showError:!1,loading:!1,loadingBtn:!1,settings:[],last_quote_number:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return t=>{if(!t)return"";const e=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getFullYear();return`${e}-${s}-${i}`}}},mounted(){this.fetchClients(),this.fetchSettings()},methods:{AddNew(){modal_clients.showModal()},cancelAction(){this.$router.push("/quotes")},fetchClients(){this.loading=!0,fetch("/wp-json/my-easy-compta/v1/list-clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.clients=t.clients,this.clientOptions=this.clients.map(e=>({value:e.id,text:`${e.company_name} - ${e.email} (${e.currency_symbol})`}))}).catch(t=>{console.error("Error fetching clients:",t)}).finally(()=>{this.loading=!1})},customLabel(t){return t.text},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,t.ok){const e=await t.json();this.settings=e;const s=`${this.settings.quote_prefix}_${String(this.settings.last_quote_id).padStart(4,"0")}`;this.quote.number=s}else{const e=await t.json()}}catch{this.loading=!1}},submitQuote(){if(!this.quote.due_date||!this.quote.provisional_start_date||!this.quote.client_id||!this.quote.status){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.loadingBtn=!0,fetch("/wp-json/my-easy-compta/v1/quotes",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.quote)}).then(t=>{if(!t.ok)throw this.loadingBtn=!1,new Error("Network response was not ok");return t.json()}).then(t=>{t.success?(this.loadingBtn=!1,this.showToast(t.message,"alert-success"),this.$router.push({name:"QuoteViewDetail",params:{id:t.id}})):(this.loadingBtn=!1,console.error("Error submitting quote:",t.message),this.showToast(t.message,"alert-error"))}).catch(t=>{this.loadingBtn=!1,console.error("Error submitting quote:",t),this.showToast(t,"alert-error")})},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},Rp={class:"pt-2 pr-4"},Mp={class:"flex justify-between items-center mb-4"},Op={class:"card-title"},qp=r("div",{class:"divider mt-2"},null,-1),Np={key:0,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},Bp={class:"grid grid-cols-3 gap-4"},Vp={class:"ecwp-group form-group mb-4"},Fp={for:"quoteNumber",class:"ecwp-label"},Up={class:"ecwp-group form-group mb-4"},Lp={for:"quoteDate",class:"ecwp-label"},Wp={class:"ecwp-group form-group mb-4"},Xp={for:"quoteDatePr",class:"ecwp-label"},Hp={class:"grid grid-cols-2 gap-4"},Qp={class:"mb-4"},zp={class:"flex gap-2 items-end"},Gp=r("i",{class:"fas fa-plus"},null,-1),Jp=[Gp],Yp={class:"ecwp-group form-group w-full"},Kp={for:"client",class:"ecwp-label"},Zp={class:"ecwp-group form-group mb-4"},$p={for:"status",class:"ecwp-label"},e_={value:"draft",selected:""},t_={value:"pending"},n_={value:"approved"},s_={value:"rejected"},o_={class:"flex justify-between"},i_=["disabled"],r_={key:0,class:"loading loading-spinner loading-sm"};function a_(t,e,s,i,n,o){const a=O("VueDatePicker"),l=O("model-select"),f=O("Card"),d=O("AddClientModal");return u(),h("div",Rp,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),P(f,{topMargin:"mt-8",modalType:"modal_quote_new"},{default:me(()=>[r("div",Mp,[r("h2",Op,c(o.translations.new_quote),1)]),qp,n.loading?(u(),h("div",Np)):g("",!0),r("form",{onSubmit:e[7]||(e[7]=J((...m)=>o.submitQuote&&o.submitQuote(...m),["prevent"]))},[r("div",Bp,[r("div",Vp,[r("label",Fp,c(o.translations.quote_number),1),D(r("input",{type:"text",id:"quoteNumber","onUpdate:modelValue":e[0]||(e[0]=m=>n.quote.number=m),class:"ecwp-input input input-bordered w-full",disabled:"disabled"},null,512),[[W,n.quote.number]])]),r("div",Up,[r("label",Lp,c(o.translations.due_date),1),P(a,{class:I(["ecwp-input ecwp-date input input-bordered w-full",[!n.quote.due_date&&n.showError?"input-error":""]]),id:"quoteDate",modelValue:n.quote.due_date,"onUpdate:modelValue":e[1]||(e[1]=m=>n.quote.due_date=m),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date,locale:"fr"},null,8,["class","modelValue","format","min-date"])]),r("div",Wp,[r("label",Xp,c(o.translations.provisional_date),1),P(a,{class:I(["ecwp-input ecwp-date input input-bordered w-full",[!n.quote.provisional_start_date&&n.showError?"input-error":""]]),id:"quoteDatePr",modelValue:n.quote.provisional_start_date,"onUpdate:modelValue":e[2]||(e[2]=m=>n.quote.provisional_start_date=m),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date,locale:"fr"},null,8,["class","modelValue","format","min-date"])])]),r("div",Hp,[r("div",Qp,[r("div",zp,[r("button",{type:"button",class:"btn btn-primary",onClick:e[3]||(e[3]=(...m)=>o.AddNew&&o.AddNew(...m))},Jp),r("div",Yp,[r("label",Kp,c(o.translations.company_name),1),P(l,{modelValue:n.quote.client_id,"onUpdate:modelValue":e[4]||(e[4]=m=>n.quote.client_id=m),options:n.clientOptions,label:"text","track-by":"value",placeholder:o.translations.select,class:I(["ecwp-input input input-bordered w-full",[!n.quote.client_id&&n.showError?"input-error":""]])},null,8,["modelValue","options","placeholder","class"])])])]),r("div",Zp,[r("label",$p,c(o.translations.status),1),D(r("select",{id:"status","onUpdate:modelValue":e[5]||(e[5]=m=>n.quote.status=m),class:I(["ecwp-input select select-bordered w-full",[!n.quote.status&&n.showError?"input-error":""]])},[r("option",e_,c(o.translations.draft),1),r("option",t_,c(o.translations.pending),1),r("option",n_,c(o.translations.approved),1),r("option",s_,c(o.translations.rejected),1)],2),[[ue,n.quote.status]])])]),r("div",o_,[r("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:e[6]||(e[6]=(...m)=>o.cancelAction&&o.cancelAction(...m))},c(o.translations.cancel),1),r("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(c(o.translations.submit)+" ",1),n.loadingBtn?(u(),h("span",r_)):g("",!0)],8,i_)])],32)]),_:1}),P(d,{onClientAdded:o.fetchClients},null,8,["onClientAdded"])])}var l_=ne(jp,[["render",a_]]);const c_={name:"InvoicesList",components:{Card:Ze,RemoveModal:qt},data(){return{invoices:[],filteredInvoices:[],filters:{invoice_number:"",client:"",status:"",total_amount:"",due_date:"",created_at:""},showInvoiceDetailsModal:!1,editInvoiceModal:!1,selectedInvoice:null,currentPage:1,totalCount:0,totalPages:1,paginationButtons:[],loading:!0,loadingPrice:!0,loadingModal:!1,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],client_currency:"",default_vat:"",default_currency:"",default_currency_symbol:"",settings:{},toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},created(){this.fetchInvoices(),this.fetchClients(),this.loadSettings()},methods:{fetchInvoices(t=1){this.loading=!0;const{perPage:e}=this;fetch(`/wp-json/my-easy-compta/v1/invoices?page=${t}&per_page=${e}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>s.json()).then(s=>{this.invoices=s.invoices,this.totalCount=s.total_count,this.totalPages=s.total_pages,this.currentPage=t,this.perPage=e,this.generatePaginationButtons()}).catch(s=>{console.error("Error fetching invoices:",s)}).finally(()=>{this.loading=!1})},fetchInvoicesWithFilters(t=1){this.loading=!0;const{perPage:e,filters:s}=this,i=new URLSearchParams({page:t,per_page:e,...s}).toString();fetch(`/wp-json/my-easy-compta/v1/invoices?${i}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(n=>n.json()).then(n=>{this.invoices=n.invoices,this.totalCount=n.total_count,this.totalPages=n.total_pages,this.currentPage=t,this.perPage=e,this.generatePaginationButtons()}).catch(n=>{console.error("Error fetching invoices with filters:",n)}).finally(()=>{this.loading=!1})},fetchClients(){fetch("/wp-json/my-easy-compta/v1/clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.clients=t.clients}).catch(t=>{console.error("Error fetching clients:",t)})},async loadSettings(){try{this.loadingPrice=!0;const{settings:t,currencySymbol:e,vatData:s}=await mn();this.settings=t,this.default_currency_symbol=e,this.default_vat=s,this.loadingPrice=!1}catch(t){this.showToast(t.message,"alert-error"),this.loadingPrice=!1}},calculateVAT(t){return so(t,this.default_vat.rate)},calculateWithoutVAT(t){return oo(t)},generatePaginationButtons(){this.paginationButtons=io(this.currentPage,this.totalPages)},goToPage(t){t!=="..."&&this.fetchInvoicesWithFilters(t)},perPageChanged(){this.fetchInvoicesWithFilters()},formatAmount(t,e){return ro(t,e,this.settings.currency_position)},showToast(t,e){ao(this.toast,t,e)},confirmDeleteInvoice(t){this.selectedInvoice=t,modal_invoice_remove.showModal(),this.showRemoveModal=!0},deleteInvoice(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/delete/${t}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Network response was not ok");return e.json()}).then(e=>{e.success?(this.fetchInvoices(),this.showToast(e.message,"alert-success")):(this.showToast(e.message,"alert-error"),console.error("Error deleting invoice:",e.statusText))}).catch(e=>{console.log(e.message);const s=e&&e.message?e.message:"Error deleting client";s==="This client cannot be deleted because it has associated data."?this.showToast(s,"alert-error"):console.error("Error deleting client:",e)})}},computed:{skeletonItems(){return Array.from({length:5},(t,e)=>e)},totalPages(){return Math.ceil(this.totalCount/this.perPage)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},d_={class:"pt-2 pr-4"},u_={class:"flex justify-between items-center"},h_={class:"card-title"},m_={class:"btn btn-primary rounded-full"},f_=r("i",{class:"fas fa-plus-circle"},null,-1),p_={key:0,class:"ms-2"},__={class:"btn btn-outline btn-accent rounded-full hover:text-white",href:"/wp-admin/admin.php?page=my-easy-compta-export#tab3"},g_=r("i",{class:"fas fa-file-export"},null,-1),y_=["data-tip"],b_={class:"btn btn-outline btn-accent rounded-full",disabled:""},v_=r("i",{class:"fas fa-file-export"},null,-1),w_=r("div",{class:"divider mt-2"},null,-1),x_={class:"flex items-center mb-4"},E_={for:"perPageSelect",class:"mr-2"},C_=["value"],T_={class:"overflow-x-auto"},I_={class:"table w-full"},k_={value:""},A_=["value"],S_={value:""},D_={value:"draft"},P_={value:"unpaid"},j_={value:"paid"},R_={class:"flex justify-center"},M_={key:0},O_={key:0,class:"badge badge-primary badge-outline badge-sm mr-2"},q_={key:0,class:"badge badge-scondary badge-outline badge-sm"},N_={key:1,class:"badge badge-warning badge-outline badge-sm"},B_={key:2,class:"badge badge-success badge-outline badge-sm"},V_={key:3,class:"badge badge-error badge-outline badge-sm ms-2"},F_={key:0},U_={key:0},L_={key:0},W_={key:1},X_={key:0},H_={key:1},Q_={key:1},z_=r("span",{class:"loading loading-bars loading-sm"},null,-1),G_=[z_],J_={key:0},Y_={key:1},K_=r("span",{class:"loading loading-bars loading-sm"},null,-1),Z_=[K_],$_={key:0},eg={key:1},tg=r("span",{class:"loading loading-bars loading-sm"},null,-1),ng=[tg],sg={class:"flex justify-end"},og=["data-tip"],ig=r("button",{class:"btn btn-circle mx-1"},[r("i",{class:"far fa-eye"})],-1),rg=["data-tip"],ag=r("button",{class:"btn btn-circle mx-1"},[r("i",{class:"fas fa-pencil-alt"})],-1),lg=["data-tip"],cg=["onClick"],dg=r("i",{class:"far fa-trash-alt"},null,-1),ug=[dg],hg={key:0},mg=r("div",{class:"flex gap-4 items-center"},[r("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),r("div",{class:"flex flex-col gap-4 w-full"},[r("div",{class:"skeleton h-4 w-full"}),r("div",{class:"skeleton h-4 w-full"})])],-1),fg=r("div",{class:"divider my-1"},null,-1),pg=[mg,fg],_g={class:"join ecwp_pagination mt-6 pt-4"},gg=["onClick"];function yg(t,e,s,i,n,o){const a=O("remove-modal"),l=O("router-link"),f=O("Card");return u(),h("div",d_,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),P(a,{"modal-id":"modal_invoice_remove","show-modal":t.showRemoveModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:e[0]||(e[0]=d=>this.deleteInvoice(n.selectedInvoice)),onCancel:e[1]||(e[1]=d=>t.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),P(f,{topMargin:"mt-8"},{default:me(()=>[r("div",u_,[r("h2",h_,c(o.translations.invoices),1),r("div",null,[P(l,{to:{name:"InvoiceNew"}},{default:me(()=>[r("button",m_,[C(c(o.translations.add)+" ",1),f_])]),_:1}),n.settings.easy_compta_export_addon_active==1?(u(),h("span",p_,[r("a",__,[C(c(o.translations.export)+" ",1),g_])])):(u(),h("span",{key:1,class:"tooltip tooltip-left tooltip-warning ms-2","data-tip":o.translations.active_export_addon},[r("button",b_,[C(c(o.translations.export)+" ",1),v_])],8,y_))])]),w_,r("div",x_,[r("label",E_,c(o.translations.display_per_page),1),D(r("select",{id:"perPageSelect","onUpdate:modelValue":e[2]||(e[2]=d=>n.perPage=d),onChange:e[3]||(e[3]=(...d)=>o.perPageChanged&&o.perPageChanged(...d))},[(u(!0),h(F,null,U(n.perPageOptions,d=>(u(),h("option",{key:d,value:d},c(d),9,C_))),128))],544),[[ue,n.perPage]])]),r("div",T_,[r("table",I_,[r("thead",null,[r("tr",null,[r("th",null,[r("div",null,c(o.translations.invoice_number),1),D(r("input",{"onUpdate:modelValue":e[4]||(e[4]=d=>n.filters.invoice_number=d),onInput:e[5]||(e[5]=d=>o.fetchInvoicesWithFilters()),type:"text",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[W,n.filters.invoice_number]])]),r("th",null,[r("div",null,c(o.translations.client),1),D(r("select",{"onUpdate:modelValue":e[6]||(e[6]=d=>n.filters.client=d),onChange:e[7]||(e[7]=d=>o.fetchInvoicesWithFilters()),class:"ecwp-input input-xs input-bordered mt-2"},[r("option",k_,c(o.translations.all),1),(u(!0),h(F,null,U(t.clients,d=>(u(),h("option",{key:d.id,value:d.company_name},c(d.company_name),9,A_))),128))],544),[[ue,n.filters.client]])]),r("th",null,[r("div",null,c(o.translations.status),1),D(r("select",{"onUpdate:modelValue":e[8]||(e[8]=d=>n.filters.status=d),onChange:e[9]||(e[9]=d=>o.fetchInvoicesWithFilters()),class:"ecwp-input input-xs input-bordered mt-2"},[r("option",S_,c(o.translations.all_statuses),1),r("option",D_,c(o.translations.draft),1),r("option",P_,c(o.translations.unpaid),1),r("option",j_,c(o.translations.paid),1)],544),[[ue,n.filters.status]])]),r("th",null,[r("div",null,c(o.translations.total),1),D(r("input",{"onUpdate:modelValue":e[10]||(e[10]=d=>n.filters.total_amount=d),onInput:e[11]||(e[11]=d=>o.fetchInvoicesWithFilters()),type:"text",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[W,n.filters.total_amount]])]),r("th",null,[r("div",null,c(o.translations.due_date),1),D(r("input",{"onUpdate:modelValue":e[12]||(e[12]=d=>n.filters.due_date=d),onInput:e[13]||(e[13]=d=>o.fetchInvoicesWithFilters()),type:"date",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[W,n.filters.due_date]])]),r("th",null,[r("div",null,c(o.translations.created_at),1),D(r("input",{"onUpdate:modelValue":e[14]||(e[14]=d=>n.filters.created_at=d),onInput:e[15]||(e[15]=d=>o.fetchInvoicesWithFilters()),type:"date",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[W,n.filters.created_at]])]),r("th",R_,c(o.translations.actions),1)])]),n.loading?g("",!0):(u(),h("tbody",M_,[(u(!0),h(F,null,U(n.invoices,d=>(u(),h("tr",{key:d.id},[r("td",null,[d.advance==1?(u(),h("span",O_,c(o.translations.advance),1)):g("",!0),C(c(d.invoice_number),1)]),r("td",null,c(d.client_name),1),r("td",null,[d.status=="draft"?(u(),h("span",q_,c(o.translations.draft),1)):g("",!0),d.status=="unpaid"?(u(),h("span",N_,c(o.translations.unpaid),1)):g("",!0),d.status=="paid"?(u(),h("span",B_,c(o.translations.paid),1)):g("",!0),d.credit=="1"?(u(),h("span",V_,c(o.translations.credit),1)):g("",!0)]),r("td",null,[n.loadingPrice?(u(),h("div",Q_,G_)):(u(),h("div",F_,[n.settings.easy_compta_advance_addon_active&&d.advance==1?(u(),h("div",U_,c(o.formatAmount(d.advance_amount,d.client_currency||n.default_currency_symbol)),1)):g("",!0),n.settings.vat_active==1?(u(),h("div",{key:1,class:I({"text-xs":d.advance==1})},[n.default_currency_symbol==d.client_currency||d.client_currency==null?(u(),h("span",L_,c(o.formatAmount(d.total_amount,n.default_currency_symbol)),1)):(u(),h("span",W_,c(o.formatAmount(d.total_amount,d.client_currency)),1))],2)):(u(),h("div",{key:2,class:I({"text-xs":d.advance==1})},[n.default_currency_symbol==d.client_currency||d.client_currency==null?(u(),h("span",X_,c(o.formatAmount(d.total_amount,n.default_currency_symbol)),1)):(u(),h("span",H_,c(o.formatAmount(d.total_amount,d.client_currency)),1))],2))]))]),r("td",null,[n.loadingPrice?(u(),h("div",Y_,Z_)):(u(),h("div",J_,c(d.due_date),1))]),r("td",null,[n.loadingPrice?(u(),h("div",eg,ng)):(u(),h("div",$_,c(d.created),1))]),r("td",sg,[r("span",{class:"lg:tooltip","data-tip":o.translations.view},[P(l,{to:{name:"InvoiceViewDetail",params:{id:d.id}}},{default:me(()=>[ig]),_:2},1032,["to"])],8,og),d.status=="draft"?(u(),h("span",{key:0,class:"lg:tooltip","data-tip":o.translations.edit},[P(l,{to:{name:"InvoiceEdit",params:{id:d.id}}},{default:me(()=>[ag]),_:2},1032,["to"])],8,rg)):g("",!0),d.status=="draft"?(u(),h("span",{key:1,class:"lg:tooltip","data-tip":o.translations.delete},[r("button",{onClick:m=>o.confirmDeleteInvoice(d.id),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},ug,8,cg)],8,lg)):g("",!0)])]))),128))]))]),n.loading?(u(),h("div",hg,[(u(!0),h(F,null,U(n.skeletonRows,d=>(u(),h("div",{key:d,class:"flex flex-col gap-4 w-full"},pg))),128))])):g("",!0)]),r("div",_g,[(u(!0),h(F,null,U(n.paginationButtons,d=>(u(),h("button",{key:d,class:I(["join-item btn",{"btn-disabled":d==="..."||d===n.currentPage}]),onClick:m=>o.goToPage(d)},c(d),11,gg))),128))])]),_:1})])}var bg=ne(c_,[["render",yg]]);const vg={name:"sendInvoice",components:{VueEditor:mt.exports.VueEditor},props:{showModal:Boolean,modalId:String,client:Object,invoiceId:Number,loading:Boolean,subject:String,content:String},data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{loading:!1,loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},toolbarOptions:[["bold","italic","underline","strike"],["link"],[{list:"ordered"},{list:"bullet"}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{align:[]}],[{align:"right"},{align:"center"},{align:"justify"}],["clean"]],fields:{client_email:{label:t.client,value:"",disabled:!0},email_subject:{label:t.email_subject,value:""},email_message:{label:t.email_content,value:"",type:"textarea"}}}},watch:{client:{immediate:!0,handler(t){this.fields.client_email.value=(t==null?void 0:t.email)||""}},subject:{immediate:!0,handler(t){this.fields.email_subject.value=t||""}},content:{immediate:!0,handler(t){this.fields.email_message.value=t||""}}},computed:{skeletonItems(){return Array.from({length:10},(t,e)=>e)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const t=await fetch("/wp-json/my-easy-compta/v1/emails/send-email",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({type:"invoice",id:this.invoiceId,client_email:this.client.email,email_subject:this.fields.email_subject.value,email_message:this.fields.email_message.value})});if(t.ok){const e=await t.json();this.loadingBtn=!1,this.closeModal(),this.showToast(e.message,"alert-success")}else{const e=`Error sending email: ${t.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(t){const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Error sending email";this.showToast(e,"alert-error"),console.error("Error sending email:",t),this.loadingBtn=!1}},updateFieldValue(t,e){this.fields[t].value=e},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},wg=["id","open"],xg={class:"modal-box"},Eg={class:"font-bold text-lg"},Cg={key:0},Tg={class:"grid grid-cols-1 gap-4"},Ig=r("div",{class:"skeleton h-4 w-full mb-2"},null,-1),kg=r("div",{class:"skeleton h-4 w-full"},null,-1),Ag=[Ig,kg],Sg={class:"grid grid-cols-1 gap-4"},Dg=["type"],Pg=["for"],jg=["id","value","disabled","onInput"],Rg={key:1},Mg=["for"],Og={class:"form-group mt-4 flex justify-end"},qg=["disabled"],Ng={key:0,class:"loading loading-spinner loading-sm"};function Bg(t,e,s,i,n,o){const a=O("vue-editor");return u(),h("div",null,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),r("dialog",{id:s.modalId,class:"modal",open:s.showModal},[r("div",xg,[r("h3",Eg,c(o.translations.send_invoice),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=l=>o.closeModal())}," \u2715 "),n.loading?(u(),h("div",Cg,[r("div",Tg,[(u(!0),h(F,null,U(o.skeletonItems,l=>(u(),h("div",{key:l,class:"py-2"},Ag))),128))])])):(u(),h("form",{key:1,onSubmit:e[1]||(e[1]=J((...l)=>o.submitForm&&o.submitForm(...l),["prevent"])),class:"form"},[r("div",Sg,[(u(!0),h(F,null,U(n.fields,(l,f)=>(u(),h("div",{key:f,class:"ecwp-group form-group"},[l.type!=="textarea"?(u(),h("div",{key:0,type:l.type||"text"},[r("label",{for:f,class:"ecwp-label form-label"},c(l.label),9,Pg),r("input",{id:f,class:I(["ecwp-input input input-bordered",l.class||"w-full"]),value:l.value,disabled:l.disabled,onInput:d=>o.updateFieldValue(f,d.target.value)},null,42,jg)],8,Dg)):(u(),h("div",Rg,[r("label",{for:f,class:"form-label"},c(l.label),9,Mg),P(a,{modelValue:l.value,"onUpdate:modelValue":d=>l.value=d,editorToolbar:n.toolbarOptions},null,8,["modelValue","onUpdate:modelValue","editorToolbar"])]))]))),128))]),r("div",Og,[r("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(c(o.translations.send)+" ",1),n.loadingBtn?(u(),h("span",Ng)):g("",!0)],8,qg)])],32))])],8,wg)])}var Vg=ne(vg,[["render",Bg]]);const Fg={props:{isVisible:{type:Boolean,default:!1},title:{type:String,default:"Confirmation"},message:{type:String,default:"Are you sure?"},confirmText:{type:String,default:"Confirm"},cancelText:{type:String,default:"Cancel"},status:{type:String}},data(){return{selectedPaymentMethod:"",paymentMethods:[],hasPaymentMethodError:!1}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},mounted(){this.fetchPaymentMethods()},methods:{async fetchPaymentMethods(){try{const t=await fetch("/wp-json/my-easy-compta/v1/payments/methods",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(!t.ok)throw new Error(`Erreur : ${t.status}`);const e=await t.json();this.paymentMethods=e}catch(t){console.error("Erreur lors de la r\xE9cup\xE9ration des m\xE9thodes de paiement :",t)}},onConfirm(){if(!this.selectedPaymentMethod){this.hasPaymentMethodError=!0;return}this.hasPaymentMethodError=!1,this.$emit("confirm",this.selectedPaymentMethod),this.closeModal()},onCancel(){this.$emit("cancel"),this.closeModal()},closeModal(){document.getElementById("modal_confirm_paid").close()}}},Ug=["open"],Lg={class:"modal-box"},Wg={class:"font-bold text-lg"},Xg=r("div",{class:"text-center text-red-400 mb-2"},[r("i",{class:"fas fa-exclamation-triangle text-4xl"})],-1),Hg={class:"text-lg font-semibold text-center"},Qg={class:"my-4 text-center text-xl"},zg={key:0,class:"mt-4 mb-4"},Gg={class:"ecwp-group form-group"},Jg={for:"payment_method",class:"ecwp-label form-label"},Yg={value:""},Kg=["value"],Zg={class:"flex justify-between space-x-4"};function $g(t,e,s,i,n,o){return u(),h("div",null,[r("dialog",{id:"modal_confirm_paid",class:"modal",open:t.showModal},[r("div",Lg,[r("h3",Wg,c(t.modalTitle),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...a)=>o.closeModal&&o.closeModal(...a))}," \u2715 "),Xg,r("h2",Hg,c(s.title),1),r("p",Qg,c(s.message),1),s.status==="paid"?(u(),h("div",zg,[r("div",Gg,[r("label",Jg,c(o.translations.payment_method),1),D(r("select",{id:"payment_method","onUpdate:modelValue":e[1]||(e[1]=a=>n.selectedPaymentMethod=a),class:I([{"input-error":n.hasPaymentMethodError},"ecwp-input input input-bordered w-full"])},[r("option",Yg,c(o.translations.select),1),(u(!0),h(F,null,U(n.paymentMethods,a=>(u(),h("option",{key:a.id,value:a.id},c(a.method_name),9,Kg))),128))],2),[[ue,n.selectedPaymentMethod]])])])):g("",!0),r("div",Zg,[r("button",{onClick:e[2]||(e[2]=(...a)=>o.onCancel&&o.onCancel(...a)),class:"btn btn-secondary rounded-full"},c(s.cancelText),1),r("button",{onClick:e[3]||(e[3]=(...a)=>o.onConfirm&&o.onConfirm(...a)),class:"btn rounded-full btn-error text-white"},c(s.confirmText),1)])])],8,Ug)])}var ey=ne(Fg,[["render",$g]]);const ty={props:{isVisible:{type:Boolean,default:!1},title:{type:String,default:"Confirmation"},message:{type:String,default:"Are you sure?"},confirmText:{type:String,default:"Confirm"},cancelText:{type:String,default:"Cancel"},status:{type:String}},data(){return{selectedPaymentMethod:""}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{onConfirm(){this.$emit("confirm",this.selectedPaymentMethod),this.closeModal()},onCancel(){this.$emit("cancel"),this.closeModal()},closeModal(){document.getElementById("modal_confirm_credit").close()}}},ny=["open"],sy={class:"modal-box"},oy={class:"font-bold text-lg"},iy=r("div",{class:"text-center text-red-400 mb-2"},[r("i",{class:"fas fa-exclamation-triangle text-4xl"})],-1),ry={class:"text-lg font-semibold text-center"},ay={class:"my-4 text-center text-xl"},ly={class:"flex justify-between space-x-4"};function cy(t,e,s,i,n,o){return u(),h("div",null,[r("dialog",{id:"modal_confirm_credit",class:"modal",open:t.showModal},[r("div",sy,[r("h3",oy,c(t.modalTitle),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...a)=>o.closeModal&&o.closeModal(...a))}," \u2715 "),iy,r("h2",ry,c(s.title),1),r("p",ay,c(s.message),1),r("div",ly,[r("button",{onClick:e[1]||(e[1]=(...a)=>o.onCancel&&o.onCancel(...a)),class:"btn btn-secondary rounded-full"},c(s.cancelText),1),r("button",{onClick:e[2]||(e[2]=(...a)=>o.onConfirm&&o.onConfirm(...a)),class:"btn rounded-full btn-error text-white"},c(s.confirmText),1)])])],8,ny)])}var dy=ne(ty,[["render",cy]]);const uy={name:"InvoiceNavBar",components:{SendInvoiceModal:Vg,RemoveModal:qt,ConfirmModal:ds,ConfirmModalPaid:ey,ConfirmModalCredit:dy},props:{invoiceInfo:Object,currencyDefault:Object,currencyClient:Object,emailActive:String,qrCodeActive:String,totalAmount:String,noItems:Boolean},data(){return{showConfirmModal:!1,showConfirmCreditModal:!1,loading:!1,sendInvoiceModal:!1,loadingModal:!1,loadingPdf:!1,client_detail:null,selectedStatus:null,subject:"",content:"",showQrCodeModal:!1,qrCodeSrc:""}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{changeInvoiceStatusWithPaymentMethod(t){const e=this.selectedStatus;this.changeInvoiceStatus(e,t),this.showConfirmModal=!1},async changeInvoiceStatus(t,e){this.loading=!0;try{const i=await(await fetch("/wp-json/my-easy-compta/v1/invoices/update-status",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({id:this.invoiceInfo.id,status:t,method:e})})).json();i.success?(this.invoiceInfo.status=t,this.loading=!1):(console.error("Failed to update invoice status:",i.message),this.loading=!1)}catch(s){console.error("An error occurred while updating invoice status:",s)}},async addCreditInvoice(){this.loading=!0;try{const e=await(await fetch("/wp-json/my-easy-compta/v1/invoices/credit",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({id:this.invoiceInfo.id})})).json();e.success?(this.invoiceInfo.credit=1,this.loading=!1):(console.error("Failed to update invoice status:",e.message),this.loading=!1)}catch(t){console.error("An error occurred while updating invoice status:",t)}},exportToPDF(t){this.loadingPdf=!0;let s=`/wp-json/my-easy-compta/v1/invoices/pdf/${this.invoiceInfo.id}?currency_id=${t}`;fetch(s,{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(i=>{if(!i.ok)throw this.loadingPdf=!1,new Error("Network response was not ok");return i.blob()}).then(i=>{const n=URL.createObjectURL(i);window.open(n),this.loadingPdf=!1}).catch(i=>{console.error("There was a problem with the fetch operation:",i),this.loadingPdf=!1})},sendInvoice(t){this.loadingModal=!0,this.sendInvoiceModal=!0,modal_send_invoice.showModal(),this.fetchClient(t),this.fetchSettings()},fetchClient(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/clients/details/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Client not found");return e.json()}).then(e=>{this.client_detail=e,this.loading=!1}).catch(e=>{console.error("Error fetching client info:",e),this.loading=!1})},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,t.ok){const e=await t.json();this.subject=e.email_invoice_subject,this.content=e.email_invoice_content}else{const e=await t.json();this.showToast(e.message,"alert-error")}}catch(t){this.loading=!1,this.showToast(t.message,"alert-error")}},confirmValidateInvoice(t){this.selectedStatus=t,t=="unpaid"?modal_confirm.showModal():t=="paid"&&modal_confirm_paid.showModal(),this.showConfirmModal=!0},confirmCreditInvoice(){modal_confirm_credit.showModal(),this.showConfirmCreditModal=!0},async generateQRCode(){this.loading=!0;try{const t=await fetch("/wp-json/my-easy-compta/v1/generate-qrcode",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({invoice_ref:this.invoiceInfo.invoice_number||`Facture #${this.invoiceInfo.number}`,price:parseFloat(this.invoiceInfo.total_amount)})}),e=await t.json();t.ok&&e.qr_code?(this.qrCodeSrc=e.qr_code,this.showQrCodeModal=!0):console.error("Erreur lors de la g\xE9n\xE9ration du QR Code :",e.message)}catch(t){console.error("Erreur lors de l'appel \xE0 l'API pour g\xE9n\xE9rer le QR code :",t)}finally{this.loading=!1}},closeQrCodeModal(){this.showQrCodeModal=!1},downloadQRCode(){const t=document.createElement("a");t.href=this.qrCodeSrc,t.download=`qr_code_${this.invoiceInfo.invoice_number||this.invoiceInfo.number}.png`,t.click()}}},hy={key:0},my={key:1,class:"modal modal-open"},fy={class:"modal-box"},py={class:"font-bold text-lg"},_y={class:"mb-4"},gy=["src"],yy={class:"flex justify-end space-x-4"},by={key:2,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},vy=r("span",{class:"loading loading-spinner text-primary loading-lg"},null,-1),wy=[vy],xy={class:"navbar bg-base-100 mb-4 shadow-xl rounded-box flex justify-between"},Ey=r("div",{class:"dropdown"},[r("div",{tabindex:"0",role:"button",class:"btn btn-ghost lg:hidden"},[r("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 6h16M4 12h8m-8 6h16"})])]),r("ul",{tabindex:"0",class:"menu menu-sm dropdown-content mt-3 z-[1] p-2 shadow bg-base-100 rounded-box w-52"},[r("li",null,[r("a",null,"Item")]),r("li",null,[r("a",null,"Parent"),r("ul",{class:"p-2"},[r("li",null,[r("a",null,"Submenu")]),r("li",null,[r("a",null,"Submenu")])])]),r("li",null,[r("a",null,"Item")])])],-1),Cy={class:"hidden lg:flex gap-2"},Ty={class:"btn btn-sm"},Iy=r("i",{class:"far fa-edit"},null,-1),ky={key:1},Ay={class:"btn btn-sm",disabled:""},Sy=r("i",{class:"far fa-edit"},null,-1),Dy={key:2},Py=r("i",{class:"fa fa-check"},null,-1),jy={class:"btn btn-outline btn-success btn-sm hover:text-white",disabled:""},Ry=r("i",{class:"fa fa-check"},null,-1),My={key:0},Oy={class:"btn btn-sm ms-2",disabled:""},qy=r("i",{class:"fas fa-undo"},null,-1),Ny={key:1},By=r("i",{class:"fas fa-undo"},null,-1),Vy=["disabled"],Fy=r("i",{class:"far fa-file-pdf"},null,-1),Uy={key:0,class:"loading loading-spinner loading-sm"},Ly={class:"flex gap-2"},Wy=r("i",{class:"fas fa-paper-plane"},null,-1),Xy={key:0},Hy={key:1},Qy={key:2,class:"far fa-envelope"},zy=["data-tip"],Gy={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},Jy=r("i",{class:"fas fa-paper-plane"},null,-1),Yy=["data-tip"],Ky={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},Zy=r("i",{class:"fas fa-paper-plane"},null,-1),$y={key:3},eb=r("i",{class:"fas fa-qrcode"},null,-1),tb={key:1,click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},nb=r("i",{class:"fas fa-qrcode"},null,-1),sb=["data-tip"],ob={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},ib=r("i",{class:"fas fa-qrcode"},null,-1),rb={key:5},ab={key:0,class:"dropdown dropdown-end"},lb={tabindex:"0",role:"button",class:"btn btn-outline btn-success btn-sm"},cb=r("i",{class:"far fa-file-pdf"},null,-1),db={key:0,class:"loading loading-spinner loading-sm"},ub={tabindex:"0",class:"dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow"},hb=["disabled"],mb=["disabled"],fb={key:6},pb=["disabled"],_b=r("i",{class:"far fa-file-pdf"},null,-1),gb={key:0},yb={key:1},bb={key:2,class:"loading loading-spinner loading-sm"},vb=r("i",{class:"fas fa-check"},null,-1),wb=["data-tip"],xb={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},Eb=r("i",{class:"fas fa-check"},null,-1);function Cb(t,e,s,i,n,o){const a=O("send-invoice-modal"),l=O("confirm-modal"),f=O("confirm-modal-paid"),d=O("confirm-modal-credit"),m=O("router-link");return u(),h("div",null,[s.emailActive==1?(u(),h("div",hy,[P(a,{loading:n.loadingModal,"show-modal":n.sendInvoiceModal,"modal-id":"modal_send_invoice",client:n.client_detail,"invoice-id":s.invoiceInfo.id,subject:n.subject,content:n.content,onClose:e[0]||(e[0]=p=>n.sendInvoiceModal=!1)},null,8,["loading","show-modal","client","invoice-id","subject","content"])])):g("",!0),P(l,{"show-modal":n.showConfirmModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,status:n.selectedStatus,onConfirm:e[1]||(e[1]=p=>o.changeInvoiceStatus("unpaid")),onCancel:e[2]||(e[2]=p=>n.showConfirmModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText","status"]),P(f,{"show-modal":n.showConfirmModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,status:n.selectedStatus,onConfirm:o.changeInvoiceStatusWithPaymentMethod,onCancel:e[3]||(e[3]=p=>n.showConfirmModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText","status","onConfirm"]),P(d,{"show-modal":n.showConfirmCreditModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,onConfirm:e[4]||(e[4]=p=>this.addCreditInvoice()),onCancel:e[5]||(e[5]=p=>n.showConfirmCreditModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),s.qrCodeActive==1&&n.showQrCodeModal?(u(),h("div",my,[r("div",fy,[r("h3",py,c(o.translations.download_qr_code),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[6]||(e[6]=p=>o.closeQrCodeModal())}," \u2715 "),r("div",_y,[r("img",{src:n.qrCodeSrc,alt:"QR Code",class:"max-w-full h-auto mx-auto"},null,8,gy)]),r("div",yy,[r("button",{onClick:e[7]||(e[7]=(...p)=>o.downloadQRCode&&o.downloadQRCode(...p)),class:"btn btn-primary"},c(o.translations.download_qr_code),1)])])])):g("",!0),n.loading?(u(),h("div",by,wy)):g("",!0),r("div",xy,[r("div",null,[Ey,r("div",Cy,[s.invoiceInfo.status=="draft"?(u(),pi(m,{key:0,to:{name:"InvoiceEdit",params:{id:s.invoiceInfo.id}}},{default:me(()=>[r("button",Ty,[Iy,C(" "+c(o.translations.edit_invoice),1)])]),_:1},8,["to"])):(u(),h("div",ky,[r("button",Ay,[Sy,C(" "+c(o.translations.edit_invoice),1)])])),s.invoiceInfo.status=="unpaid"&&!s.noItems?(u(),h("div",Dy,[r("button",{class:"btn btn-outline btn-success btn-sm hover:text-white",onClick:e[8]||(e[8]=p=>o.confirmValidateInvoice("paid"))},[Py,C(" "+c(o.translations.mark_as_paid),1)])])):(u(),h(F,{key:3},[r("div",null,[r("button",jy,[Ry,C(" "+c(o.translations.mark_as_paid),1)])]),s.invoiceInfo.credit!=0&&s.invoiceInfo.status=="paid"&&!s.noItems?(u(),h("div",My,[r("button",Oy,[qy,C(" "+c(o.translations.credit_invoice),1)])])):g("",!0),s.invoiceInfo.credit==0&&s.invoiceInfo.status=="paid"&&!s.noItems?(u(),h("div",Ny,[r("button",{class:"btn btn-sm ms-2",onClick:e[9]||(e[9]=p=>o.confirmCreditInvoice())},[By,C(" "+c(o.translations.credit_invoice),1)])])):g("",!0)],64))])]),s.invoiceInfo.status=="draft"?(u(),h("button",{key:0,onClick:e[10]||(e[10]=p=>o.exportToPDF(s.currencyDefault.currency_id)),class:"btn btn-outline btn-secondary btn-sm",disabled:n.loadingPdf},[Fy,r("span",null,c(o.translations.previewPDF),1),n.loadingPdf?(u(),h("span",Uy)):g("",!0)],8,Vy)):g("",!0),r("div",Ly,[s.emailActive==1&&s.invoiceInfo.status!="draft"?(u(),h("button",{key:0,onClick:e[11]||(e[11]=J(p=>o.sendInvoice(s.invoiceInfo.client_id),["prevent"])),class:"btn btn-outline btn-primary btn-sm hover:text-white"},[Wy,s.invoiceInfo.sent==1?(u(),h("span",Xy,c(o.translations.resend_invoice),1)):(u(),h("span",Hy,c(o.translations.send_invoice),1)),s.invoiceInfo.sent==1?(u(),h("i",Qy)):g("",!0)])):s.emailActive==1&&s.invoiceInfo.status=="draft"?(u(),h("div",{key:1,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.draft_cannot_send},[r("button",Gy,[Jy,C(" "+c(o.translations.send_invoice),1)])],8,zy)):(u(),h("div",{key:2,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.active_email_addon},[r("button",Ky,[Zy,C(" "+c(o.translations.send_invoice),1)])],8,Yy)),s.qrCodeActive==1?(u(),h("div",$y,[s.invoiceInfo.status=="unpaid"?(u(),h("button",{key:0,class:"btn btn-outline btn-accent btn-sm",onClick:e[12]||(e[12]=(...p)=>o.generateQRCode&&o.generateQRCode(...p))},[eb,C(" "+c(o.translations.generate_qrcode),1)])):(u(),h("button",tb,[nb,C(" "+c(o.translations.generate_qrcode),1)]))])):(u(),h("div",{key:4,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.active_qrcode_addon},[r("button",ob,[ib,C(" "+c(o.translations.generate_qrcode),1)])],8,sb)),s.currencyDefault.currency_id!==s.currencyClient.currency_id?(u(),h("div",rb,[s.invoiceInfo.status!="draft"?(u(),h("div",ab,[r("div",lb,[cb,C(" "+c(o.translations.exportToPDF)+" ",1),n.loadingPdf?(u(),h("span",db)):g("",!0)]),r("ul",ub,[r("li",null,[r("a",{onClick:e[13]||(e[13]=p=>o.exportToPDF(s.currencyDefault.currency_id)),disabled:n.loadingPdf},c(o.translations.invoice_in)+" "+c(s.currencyDefault.currency_symbol),9,hb)]),r("li",null,[r("a",{onClick:e[14]||(e[14]=p=>o.exportToPDF(s.currencyClient.currency_id)),disabled:n.loadingPdf},c(o.translations.invoice_in)+" "+c(s.currencyClient.currency_symbol),9,mb)])])])):g("",!0)])):(u(),h("div",fb,[s.invoiceInfo.status!="draft"?(u(),h("button",{key:0,onClick:e[15]||(e[15]=p=>o.exportToPDF(s.currencyDefault.currency_id)),class:"btn btn-outline btn-success btn-sm",disabled:n.loadingPdf},[_b,s.invoiceInfo.status!="draft"?(u(),h("span",gb,c(o.translations.exportToPDF),1)):(u(),h("span",yb,c(o.translations.previewPDF),1)),n.loadingPdf?(u(),h("span",bb)):g("",!0)],8,pb)):g("",!0)])),s.invoiceInfo.status=="draft"&&!s.noItems?(u(),h("button",{key:7,class:"btn btn-outline btn-success btn-sm hover:text-white",onClick:e[16]||(e[16]=p=>o.confirmValidateInvoice("unpaid"))},[vb,C(" "+c(o.translations.validateInvoice),1)])):g("",!0),s.invoiceInfo.status=="draft"&&s.noItems?(u(),h("div",{key:8,class:"tooltip tooltip-left tooltip-warning","data-tip":o.translations.min_article},[r("button",xb,[Eb,C(" "+c(o.translations.validateInvoice),1)])],8,wb)):g("",!0)])])])}var Tb=ne(uy,[["render",Cb]]);const Ib={components:{VueEditor:mt.exports.VueEditor},props:{loading:Boolean,showModal:Boolean,modalId:String,modalTitle:String,item:Object},data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{editedItem:{...this.item},loading:this.loading,loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},fields:{item_name:{label:t.item_name},item_description:{label:t.item_description,type:"textarea"},quantity:{label:t.quantity,type:"number"},vat_rate:{label:t.vat,type:"number"},unit_price:{label:t.unit_price,type:"number"},discount:{label:t.discount,type:"number"}}}},computed:{skeletonItems(){return Array.from({length:10},(t,e)=>e)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const t=await fetch(`/wp-json/my-easy-compta/v1/invoices/edit-item/${this.editedItem.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.editedItem)});if(t.ok){const e=await t.json();this.loadingBtn=!1,this.closeModal(),this.showToast(e.message,"alert-success"),this.$emit("itemEdited")}else{const e=`Error editing item: ${t.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(t){const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Error editing item";this.showToast(e,"alert-error"),console.error("Error editing item:",t),this.loadingBtn=!1}},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},increase(){this.newItem.quantity++},decrease(){this.newItem.quantity>1&&this.newItem.quantity--}},watch:{item:{handler(t){this.editedItem={...t}},immediate:!0}}},kb=["id","open"],Ab={class:"modal-box"},Sb={class:"font-bold text-lg"},Db={key:0},Pb={class:"grid grid-cols-1 gap-4"},jb=r("div",{class:"skeleton h-4 w-full mb-2"},null,-1),Rb=r("div",{class:"skeleton h-4 w-full"},null,-1),Mb=[jb,Rb],Ob={class:"grid grid-cols-1 gap-4"},qb=["type"],Nb=["for"],Bb=["id","onUpdate:modelValue"],Vb={key:1},Fb=["for"],Ub={class:"form-group mt-4 flex justify-end"},Lb=["disabled"],Wb={key:0,class:"loading loading-spinner loading-sm"};function Xb(t,e,s,i,n,o){const a=O("vue-editor");return u(),h("div",null,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),r("dialog",{id:s.modalId,class:"modal",open:s.showModal},[r("div",Ab,[r("h3",Sb,c(s.modalTitle),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=l=>o.closeModal())}," \u2715 "),n.loading?(u(),h("div",Db,[r("div",Pb,[(u(!0),h(F,null,U(o.skeletonItems,l=>(u(),h("div",{key:l,class:"py-2"},Mb))),128))])])):(u(),h("form",{key:1,onSubmit:e[1]||(e[1]=J((...l)=>o.submitForm&&o.submitForm(...l),["prevent"])),class:"form"},[r("div",Ob,[(u(!0),h(F,null,U(n.fields,(l,f)=>(u(),h("div",{key:f,class:"ecwp-group form-group"},[l.type!=="textarea"?(u(),h("div",{key:0,type:l.type||"text"},[r("label",{for:f,class:"ecwp-label form-label"},c(l.label),9,Nb),D(r("input",{id:f,"onUpdate:modelValue":d=>n.editedItem[f]=d,class:I(["ecwp-input input input-bordered",l.class||"w-full"])},null,10,Bb),[[W,n.editedItem[f]]])],8,qb)):(u(),h("div",Vb,[r("label",{for:f,class:"form-label"},c(l.label),9,Fb),P(a,{id:f,modelValue:n.editedItem[f],"onUpdate:modelValue":d=>n.editedItem[f]=d,editorToolbar:t.toolbarOptions},null,8,["id","modelValue","onUpdate:modelValue","editorToolbar"])]))]))),128))]),r("div",Ub,[r("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(c(o.translations.save)+" ",1),n.loadingBtn?(u(),h("span",Wb)):g("",!0)],8,Lb)])],32))])],8,kb)])}var Hb=ne(Ib,[["render",Xb]]);const Qb={components:{VueEditor:mt.exports.VueEditor},props:{loading:Boolean,showModal:Boolean,modalId:String,modalTitle:String,disb:Object},data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{editedDisb:{...this.disb},loading:this.loading,loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},fields:{title:{label:t.item_name},description:{label:t.item_description,type:"textarea"},unit_price:{label:t.unit_price,type:"number"}}}},computed:{skeletonItems(){return Array.from({length:10},(t,e)=>e)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const t=await fetch(`/wp-json/my-easy-compta/v1/invoices/edit-disb/${this.editedDisb.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.editedDisb)});if(t.ok){const e=await t.json();this.loadingBtn=!1,this.closeModal(),this.showToast(e.message,"alert-success"),this.$emit("disbEdited")}else{const e=`Error editing item: ${t.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(t){const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Error editing item";this.showToast(e,"alert-error"),console.error("Error editing item:",t),this.loadingBtn=!1}},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},increase(){this.newItem.quantity++},decrease(){this.newItem.quantity>1&&this.newItem.quantity--}},watch:{disb:{handler(t){this.editedDisb={...t}},immediate:!0}}},zb=["id","open"],Gb={class:"modal-box"},Jb={class:"font-bold text-lg"},Yb={key:0},Kb={class:"grid grid-cols-1 gap-4"},Zb=r("div",{class:"skeleton h-4 w-full mb-2"},null,-1),$b=r("div",{class:"skeleton h-4 w-full"},null,-1),ev=[Zb,$b],tv={class:"grid grid-cols-1 gap-4"},nv=["type"],sv=["for"],ov=["id","onUpdate:modelValue"],iv={key:1},rv=["for"],av={class:"form-group mt-4 flex justify-end"},lv=["disabled"],cv={key:0,class:"loading loading-spinner loading-sm"};function dv(t,e,s,i,n,o){const a=O("vue-editor");return u(),h("div",null,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),r("dialog",{id:s.modalId,class:"modal",open:s.showModal},[r("div",Gb,[r("h3",Jb,c(s.modalTitle),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=l=>o.closeModal())}," \u2715 "),n.loading?(u(),h("div",Yb,[r("div",Kb,[(u(!0),h(F,null,U(o.skeletonItems,l=>(u(),h("div",{key:l,class:"py-2"},ev))),128))])])):(u(),h("form",{key:1,onSubmit:e[1]||(e[1]=J((...l)=>o.submitForm&&o.submitForm(...l),["prevent"])),class:"form"},[r("div",tv,[(u(!0),h(F,null,U(n.fields,(l,f)=>(u(),h("div",{key:f,class:"ecwp-group form-group"},[l.type!=="textarea"?(u(),h("div",{key:0,type:l.type||"text"},[r("label",{for:f,class:"ecwp-label form-label"},c(l.label),9,sv),D(r("input",{id:f,"onUpdate:modelValue":d=>n.editedDisb[f]=d,class:I(["ecwp-input input input-bordered",l.class||"w-full"])},null,10,ov),[[W,n.editedDisb[f]]])],8,nv)):(u(),h("div",iv,[r("label",{for:f,class:"form-label"},c(l.label),9,rv),P(a,{id:f,modelValue:n.editedDisb[f],"onUpdate:modelValue":d=>n.editedDisb[f]=d,editorToolbar:t.toolbarOptions},null,8,["id","modelValue","onUpdate:modelValue","editorToolbar"])]))]))),128))]),r("div",av,[r("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(c(o.translations.save)+" ",1),n.loadingBtn?(u(),h("span",cv)):g("",!0)],8,lv)])],32))])],8,zb)])}var uv=ne(Qb,[["render",dv]]);const hv={name:"sendRemind",components:{VueEditor:mt.exports.VueEditor},props:{showModal:Boolean,modalId:String,client:Object,invoiceId:Number,loading:Boolean,subject:String,content:String},data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{loading:!1,loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},toolbarOptions:[["bold","italic","underline","strike"],["link"],[{list:"ordered"},{list:"bullet"}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{align:[]}],[{align:"right"},{align:"center"},{align:"justify"}],["clean"]],fields:{client_email:{label:t.client,value:"",disabled:!0},email_subject:{label:t.email_subject,value:""},email_message:{label:t.email_content,value:"",type:"textarea"}}}},watch:{client:{immediate:!0,handler(t){this.fields.client_email.value=(t==null?void 0:t.email)||""}},subject:{immediate:!0,handler(t){this.fields.email_subject.value=t||""}},content:{immediate:!0,handler(t){this.fields.email_message.value=t||""}}},computed:{skeletonItems(){return Array.from({length:10},(t,e)=>e)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const t=await fetch("/wp-json/my-easy-compta/v1/emails/send-email",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({type:"remind",id:this.invoiceId,client_email:this.client.email,email_subject:this.fields.email_subject.value,email_message:this.fields.email_message.value})});if(t.ok){const e=await t.json();this.loadingBtn=!1,this.closeModal(),this.showToast(e.message,"alert-success")}else{const e=`Error sending email: ${t.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(t){const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Error sending email";this.showToast(e,"alert-error"),console.error("Error sending email:",t),this.loadingBtn=!1}},updateFieldValue(t,e){this.fields[t].value=e},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},mv=["id","open"],fv={class:"modal-box"},pv={class:"font-bold text-lg"},_v={key:0},gv={class:"grid grid-cols-1 gap-4"},yv=r("div",{class:"skeleton h-4 w-full mb-2"},null,-1),bv=r("div",{class:"skeleton h-4 w-full"},null,-1),vv=[yv,bv],wv={class:"grid grid-cols-1 gap-4"},xv=["type"],Ev=["for"],Cv=["id","value","disabled","onInput"],Tv={key:1},Iv=["for"],kv={class:"form-group mt-4 flex justify-end"},Av=["disabled"],Sv={key:0,class:"loading loading-spinner loading-sm"};function Dv(t,e,s,i,n,o){const a=O("vue-editor");return u(),h("div",null,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),r("dialog",{id:s.modalId,class:"modal",open:s.showModal},[r("div",fv,[r("h3",pv,c(o.translations.remind_invoice),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=l=>o.closeModal())}," \u2715 "),n.loading?(u(),h("div",_v,[r("div",gv,[(u(!0),h(F,null,U(o.skeletonItems,l=>(u(),h("div",{key:l,class:"py-2"},vv))),128))])])):(u(),h("form",{key:1,onSubmit:e[1]||(e[1]=J((...l)=>o.submitForm&&o.submitForm(...l),["prevent"])),class:"form"},[r("div",wv,[(u(!0),h(F,null,U(n.fields,(l,f)=>(u(),h("div",{key:f,class:"ecwp-group form-group"},[l.type!=="textarea"?(u(),h("div",{key:0,type:l.type||"text"},[r("label",{for:f,class:"ecwp-label form-label"},c(l.label),9,Ev),r("input",{id:f,class:I(["ecwp-input input input-bordered",l.class||"w-full"]),value:l.value,disabled:l.disabled,onInput:d=>o.updateFieldValue(f,d.target.value)},null,42,Cv)],8,xv)):(u(),h("div",Tv,[r("label",{for:f,class:"form-label"},c(l.label),9,Iv),P(a,{modelValue:l.value,"onUpdate:modelValue":d=>l.value=d,editorToolbar:n.toolbarOptions},null,8,["modelValue","onUpdate:modelValue","editorToolbar"])]))]))),128))]),r("div",kv,[r("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(c(o.translations.send)+" ",1),n.loadingBtn?(u(),h("span",Sv)):g("",!0)],8,Av)])],32))])],8,mv)])}var Pv=ne(hv,[["render",Dv]]);const jv={name:"InvoiceViewDetail",components:{Card:Ze,InvoiceNavBar:Tb,EditItemModal:Hb,EditDisbModal:uv,RemoveModal:qt,RemindInvoiceModal:Pv,ArticleModal:Qo},data(){return{selectedItem:null,selectedDisb:null,SelectedInvoiceId:null,editItemsModal:!1,editDisbModal:!1,RemindInvoiceModal:!1,no_items:!0,loading:!1,loading_add:!1,invoice:[],invoiceItems:[],newItem:{loading_del:!1,item_name:"",item_ref:"",item_category:"Type",item_description:"",quantity:1,vat_rate:0,unit_price:0,discount:0,total_price:0,total_amount:0},settings:[],client_detail:[],list_vats:[],client_currency:"",default_vat:"",default_currency:"",default_currency_symbol:"",showArticlesModal:!1,articles:[],categories:[],refs:[],showDropdown:!1,showDropdownRef:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},showDisbursements:!1,disbursementsExist:!1,disbursementsItem:{title:"",description:"",unit_price:""},loading_add_disbursements:!1,disbursementsList:[]}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},isInvoiceOverdue(){const t=new Date().getTime(),e=this.invoice.due_date?new Date(this.invoice.due_date).getTime():null;return e&&e<t},defaultCurrency(){return{currency_id:this.settings.default_currency,currency_symbol:this.default_currency_symbol}},clientCurrency(){return{currency_id:this.client_detail.currency_id,currency_symbol:this.client_currency}},totalAmountWithoutDiscount(){const t=this.invoiceItems.reduce((e,s)=>{const i=s.quantity*s.unit_price;return e+i},0);return this.formatCurrency(t)},totalAmount(){const t=this.invoiceItems.reduce((e,s)=>e+parseFloat(s.total_price),0);return this.formatCurrency(t)},totalAmountDefaultCurrency(){return(this.invoiceItems.reduce((i,n)=>i+parseFloat(n.total_amount),0)*this.invoice.exchange_rate).toFixed(2)},totalAmountWithVAT(){const t=parseFloat(this.totalAmount);if(this.settings.vat_active==1){const e=parseFloat(this.calculateVAT());return this.formatCurrency(t+e)}else return this.formatCurrency(t)}},methods:{getUniqueVATRates(){const t=new Set;return this.invoiceItems.forEach(e=>{e.vat_rate&&t.add(e.vat_rate)}),Array.from(t)},calculateVATForRate(t){let e=0;return this.invoiceItems.forEach(s=>{if(s.vat_rate===t){const i=s.quantity*s.unit_price,n=i*s.discount/100;e+=(i-n)*t/100}}),this.formatCurrency(e)},totalDisbursements(){let t=0;return this.disbursementsList&&this.disbursementsList.length>0&&(t+=this.disbursementsList.reduce((e,s)=>e+parseFloat(s.unit_price||0),0)),this.formatCurrency(t)},calculateTotalAmountWithVAT(){let t=this.invoiceItems.reduce((e,s)=>e+parseFloat(s.total_amount),0);return this.disbursementsList&&this.disbursementsList.length>0&&(t+=this.disbursementsList.reduce((e,s)=>e+parseFloat(s.unit_price||0),0)),this.settings.easy_compta_woo_addon_active==1&&(t+=parseFloat(this.invoice.shipping_amount||0)),this.formatCurrency(t)},formatShippingAmout(t){return this.formatShippingCurrency(t)},formatShippingCurrency(t){const s=(parseFloat(t)||0).toFixed(2),i=this.client_currency!==this.default_currency_symbol?this.client_currency:this.default_currency_symbol;return`${s}${i}`},fetchInvoice(){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/${this.$route.params.id}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{t?(this.invoice=t,this.fetchClientInfo(t.client_id)):console.error("Invoice not found")}).catch(t=>{console.error("Error fetching invoice:",t),this.loading=!1})},fetchClientInfo(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/clients/details/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Client not found");return e.json()}).then(e=>{this.client_detail=e;const s=e.currency_id;s&&this.fetchCurrencyDetails(s)}).catch(e=>{console.error("Error fetching client info:",e),this.loading=!1})},fetchItems(){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/${this.$route.params.id}/items`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{t.code=="no_items_found"?(console.error("No items found"),this.invoiceItems=[],this.loading=!1,this.no_items=!0):(this.invoiceItems=t,this.loading=!1,this.no_items=!1)}).catch(t=>{console.error("Error fetching items:",t),this.loading=!1})},fetchDisbursements(){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/disbursements/${this.$route.params.id}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{t.code==="no_disbursements"?(console.error("No disbursements found"),this.disbursementsList=[],this.disbursementsExist=!1):(this.disbursementsList=t,this.disbursementsExist=!0),this.loading=!1}).catch(t=>{console.error("Error fetching disbursements:",t),this.loading=!1})},fetchCurrencyDetails(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/settings/currency/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw this.loading=!1,new Error("Currency details not found");return this.loading=!1,e.json()}).then(e=>{this.client_currency=e.symbol,this.loading=!1}).catch(e=>{this.loading=!1,console.error("Error fetching currency details:",e)})},updateTotal(){const t=this.newItem.quantity*this.newItem.unit_price,e=t*this.newItem.discount/100,s=t-e;var i=0;if(this.settings.vat_active==1){const n=s*this.newItem.vat_rate/100;i=s+n}else i=s;this.newItem.total_price=this.formatCurrency(s),this.newItem.total_amount=this.formatCurrency(i)},calculateTotalWithVat(t,e,s,i){const n=t*e,o=n*i/100,a=n-o,l=a*s/100,f=a+l;return this.formatCurrency(f)},calculateTotal(t,e,s){const i=t*e,n=i*s/100,a=i-n;return this.formatCurrency(a)},submitItems(){this.updateTotal();const t={...this.newItem,invoice_id:this.$route.params.id};this.loading_add=!0,fetch("/wp-json/my-easy-compta/v1/invoices/element-add",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(t)}).then(e=>e.json()).then(e=>{e.success?(this.loading_add=!1,this.fetchItems(),this.newItem={item_name:"",item_ref:"",item_category:"Type",item_description:"",quantity:1,vat_rate:this.default_vat.rate,unit_price:0,discount:0,total_price:0,total_amount:0}):(this.showToast(e.message,"alert-error"),console.error("Error submitting item:",e.message),this.loading_add=!1)}).catch(e=>{this.showToast(e.message,"alert-error"),console.error("Error submitting item:",e),this.loading_add=!1})},increase(){this.newItem.quantity++},decrease(){this.newItem.quantity>1&&this.newItem.quantity--},confirmremoveItem(t,e){this.selectedItem=t,this.SelectedInvoiceId=e,modal_remove_item.showModal(),this.showRemoveModal=!0},removeItem(t,e){const s=this.invoiceItems.find(i=>i.id===t);s.loading_del=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/element-delete/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({invoice_id:e})}).then(i=>i.json()).then(i=>{i.success?(s.loading_del=!1,this.fetchItems()):(this.showToast(i.message,"alert-error"),console.error("Error removing item:",i.message),s.loading_del=!1)}).catch(i=>{this.showToast(i.message,"alert-error"),console.error("Error removing item:",i),s.loading_del=!1})},editItem(t){this.loadingModal=!0,this.editItemsModal=!0,modal_edit_item.showModal(),this.fetchItemDetails(t)},fetchItemDetails(t){fetch(`/wp-json/my-easy-compta/v1/invoices/item-details/${t}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{this.selectedItem=e,this.loading=!1}).catch(e=>{console.error("Error fetching item details:",e),this.loading=!1})},editDisb(t){this.loadingModal=!0,this.editDisbModal=!0,modal_edit_disb.showModal(),this.fetchDisbDetails(t)},fetchDisbDetails(t){fetch(`/wp-json/my-easy-compta/v1/invoices/disb-details/${t}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{this.selectedDisb=e,this.loading=!1}).catch(e=>{console.error("Error fetching item details:",e),this.loading=!1})},confirmremoveDisb(t,e){this.selectedDisb=t,this.SelectedInvoiceId=e,modal_remove_disb.showModal(),this.showRemoveModalDisb=!0},removeDisb(t,e){const s=this.disbursementsList.find(i=>i.id===t);s.loading_del=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/disb-delete/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({invoice_id:e})}).then(i=>i.json()).then(i=>{i.success?(s.loading_del=!1,this.fetchDisbursements()):(this.showToast(i.message,"alert-error"),console.error("Error removing item:",i.message),s.loading_del=!1)}).catch(i=>{this.showToast(i.message,"alert-error"),console.error("Error removing item:",i),s.loading_del=!1})},formatCurrency(t){const e=t.toFixed(2),s=this.client_currency!==this.default_currency_symbol?this.client_currency:this.default_currency_symbol;return`${e}${s}`},calculateDiscountAmountWithVAT(t,e,s,i){const o=t*e*i/100,a=o*s/100,l=o+a;return this.formatCurrency(l)},calculateDiscountAmount(t,e,s){const o=t*e*s/100;return this.formatCurrency(o)},calculateVAT(){const t=parseFloat(this.totalAmount),e=parseFloat(this.default_vat.rate),s=t*(e/100);return this.formatCurrency(s)},onDragEnd(t){const e=this.invoiceItems[t.oldIndex];this.invoiceItems.splice(t.oldIndex,1),this.invoiceItems.splice(t.newIndex,0,e);const s=this.invoiceItems.map(i=>i.id);this.saveOrderToDatabase(s)},nl2br(t){return t?t.replace(/\n/g,"<br>"):""},resize(){let t=this.$refs.textarea;t.style.height="auto",t.style.height=t.scrollHeight+"px"},saveOrderToDatabase(t){fetch("/wp-json/my-easy-compta/v1/invoices/update-invoice-items-order",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({order:t})}).then(e=>{e.ok?console.log("Order saved successfully."):console.error("Failed to save order:",e.statusText)}).catch(e=>{console.error("Error saving order:",e)})},fetchCategoriesArticles(){fetch("/wp-json/my-easy-compta/v1/categories-articles",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.categories=t}).catch(t=>console.error("Error fetching categories:",t))},ShowModalArticles(){this.showArticlesModal=!0,modal_articles.showModal()},applySelectedArticle(t){this.newItem.item_ref=t.ref,this.newItem.item_name=t.name,this.newItem.item_description=t.description||"",this.newItem.unit_price=t.unit_price||0},fetchArticles(){if(this.newItem.item_name.length<1){this.articles=[];return}const t=document.getElementById("loader_articles");t.classList.remove("hidden"),fetch(`/wp-json/my-easy-compta/v1/articles?search=${this.newItem.item_name}&method=name`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{this.articles=e}).catch(e=>console.error("Error fetching articles:",e)).finally(()=>{t.classList.add("hidden")})},toggleDisbursements(){this.showDisbursements=!this.showDisbursements},addDisbursements(){this.loading_add_disbursements=!0,fetch("/wp-json/my-easy-compta/v1/invoices/disbursements",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({invoice_id:this.invoice.id,title:this.disbursementsItem.title,description:this.disbursementsItem.description,unit_price:parseFloat(this.disbursementsItem.unit_price)})}).then(t=>{if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return t.json()}).then(t=>{this.disbursementsItem={title:"",description:"",unit_price:""},this.disbursementsList.push(t),this.disbursementsExist=!0}).catch(t=>{console.error("Erreur lors de l'ajout du d\xE9bours :",t)}).finally(()=>{this.loading_add_disbursements=!1})},selectItem(t){this.newItem.item_ref=t.ref,this.newItem.item_name=t.name,this.newItem.item_description=t.description,this.newItem.unit_price=t.unit_price,this.showDropdown=!1,this.showDropdownRef=!1},fetchRefs(){if(this.newItem.item_ref.length<1){this.refs=[];return}fetch(`/wp-json/my-easy-compta/v1/articles?search=${this.newItem.item_ref}&method=ref`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.refs=t}).catch(t=>console.error("Error fetching refrences:",t))},async loadSettings(){try{this.loadingPrice=!0;const{settings:t,currencySymbol:e,vatData:s,listVatData:i}=await mn();this.settings=t,this.default_currency_symbol=e,this.default_vat=s,this.list_vats=i,this.newItem.vat_rate=this.default_vat.rate,this.loadingPrice=!1}catch(t){this.showToast(t.message,"alert-error"),this.loadingPrice=!1}},highlightMatch(t){if(!this.newItem.item_name)return t;const e=new RegExp(`(${this.escapeRegExp(this.newItem.item_name)})`,"gi");return t.replace(e,"<b>$1</b>")},escapeRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},handleClickOutside(t){this.$el.contains(t.target)||(this.showDropdown=!1,this.showDropdownRef=!1)},sendRemind(t){this.loadingModal=!0,this.RemindInvoiceModal=!0,modal_send_remind.showModal(),this.fetchClientInfo(t),this.loadSettings()},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}},beforeDestroy(){document.removeEventListener("click",this.handleClickOutside)},mounted(){this.fetchInvoice(),this.fetchItems(),this.loadSettings(),this.fetchCategoriesArticles(),this.fetchDisbursements(),document.addEventListener("click",this.handleClickOutside);const t=document.querySelector("tbody");M.create(t,{animation:150,handle:".drag-handle",onEnd:this.onDragEnd})}},Rv={class:"pt-2 pr-4"},Mv={key:0},Ov={key:2,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},qv=r("span",{class:"loading loading-spinner text-primary loading-lg"},null,-1),Nv=[qv],Bv={key:3},Vv={role:"alert",class:"alert alert-warning"},Fv=r("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6 shrink-0 stroke-current",fill:"none",viewBox:"0 0 24 24"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})],-1),Uv={key:0},Lv=["data-tip"],Wv={class:"btn btn-sm btn-primary",disabled:""},Xv={class:"grid grid-cols-2"},Hv={class:"md:col-span-1"},Qv=["src"],zv={class:"md:col-span-1 text-right"},Gv={class:"text-lg font-semibold"},Jv={key:0,class:"badge badge-error text-white"},Yv={key:1,class:"badge badge-error text-white"},Kv={key:2,class:"badge badge-success text-white"},Zv={class:"bg-base-300 rounded-lg shadow-md flex justify-between p-4 mt-4 gap-4"},$v=r("br",null,null,-1),e1=r("br",null,null,-1),t1=r("br",null,null,-1),n1=["href"],s1=r("br",null,null,-1),o1=r("br",null,null,-1),i1=r("br",null,null,-1),r1=["href"],a1=r("br",null,null,-1),l1=["href"],c1={class:"table mt-8"},d1=r("th",null,null,-1),u1={width:"5%"},h1={width:"19%"},m1={width:"21%"},f1={width:"10%",class:"text-center"},p1={width:"8%",class:"text-center"},_1={key:0,width:"5%",class:"text-center"},g1={key:1,width:"5%"},y1={width:"10%",class:"text-center"},b1={width:"10%",class:"text-right"},v1=r("th",{width:"18%",class:"text-right inv-actions"},null,-1),w1={class:"draggable-item drag-handle px-2"},x1={key:0,class:"fas fa-sort"},E1={key:0,class:"badge badge-ghost badge-xs"},C1=["innerHTML"],T1={class:"text-center"},I1={class:"text-center"},k1={key:0},A1={key:1},S1={key:0,class:"text-center"},D1={key:1},P1={key:2,class:"text-center"},j1=r("br",null,null,-1),R1={key:3,class:"text-center"},M1=r("br",null,null,-1),O1={class:"text-right"},q1={key:0},N1={key:1},B1={key:0},V1=["data-tip"],F1=["onClick"],U1=r("i",{class:"far fa-edit"},null,-1),L1=[U1],W1=["data-tip"],X1=["onClick"],H1={key:0,class:"far fa-trash-alt"},Q1={key:1,class:"loading loading-spinner loading-xs"},z1={key:0},G1={class:"align-top px-2"},J1=r("i",{class:"fas fa-list-ul"},null,-1),Y1=[J1],K1={class:"align-top px-2"},Z1={class:"flex items-center border rounded-md relative"},$1=["placeholder"],ew={key:0,class:"autocomplete-dropdown bg-base-100"},tw=["onClick","innerHTML"],nw={class:"align-top px-2"},sw=r("option",{disabled:"",selected:""},"Type",-1),ow=["value"],iw={class:"flex items-center border rounded-md relative"},rw=r("span",{id:"loader_articles",class:"loading loading-spinner loading-xs absolute right-2 hidden"},null,-1),aw=["placeholder"],lw={key:0,class:"autocomplete-dropdown bg-base-100"},cw=["onClick","innerHTML"],dw={class:"align-top"},uw={class:"flex items-center rounded-md"},hw=["placeholder"],mw={class:"align-top"},fw={class:"flex items-center border rounded-lg"},pw={class:"inline-flex"},_w=["placeholder"],gw={class:"align-top"},yw={class:"flex items-center border rounded-md"},bw=["placeholder"],vw={key:0,class:"align-top"},ww=["value"],xw={key:1,class:"align-top"},Ew={class:"align-top"},Cw={class:"flex items-center border rounded-md"},Tw=["placeholder"],Iw=r("div",{class:"px-3 py-2.5 rounded-l-md bg-base-300 border-r"}," % ",-1),kw={key:2,class:"text-right"},Aw={key:3,class:"text-right"},Sw={key:0},Dw=["data-tip"],Pw={type:"submit",class:"bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded"},jw={key:0,class:"fa fa-plus"},Rw={key:1,class:"loading loading-spinner loading-xs"},Mw={key:1},Ow={colspan:"12",class:"font-bold text-lg pl-0 pt-10"},qw={key:1,class:"ml-2"},Nw={key:2},Bw={class:"p-2",colspan:"3"},Vw={class:"p-2"},Fw={class:"p-2",colspan:"1"},Uw={class:"p-2",colspan:"3"},Lw=["innerHTML"],Ww={class:"p-2"},Xw={class:"p-2",colspan:"2"},Hw={key:0},Qw=["data-tip"],zw=["onClick"],Gw=r("i",{class:"far fa-edit"},null,-1),Jw=[Gw],Yw=["data-tip"],Kw=["onClick"],Zw={key:0,class:"far fa-trash-alt"},$w={key:1,class:"loading loading-spinner loading-xs"},e0={key:3},t0={class:"align-top px-2",colspan:"3"},n0={class:"flex items-center border rounded-md"},s0=["placeholder"],o0={class:"align-top px-2"},i0={class:"flex items-center rounded-md"},r0=["placeholder"],a0={class:"align-top"},l0={class:"flex items-center border rounded-md"},c0=["placeholder"],d0=r("td",{class:"align-top",colspan:"3"},null,-1),u0={class:"text-right"},h0=["data-tip"],m0={key:0,class:"fa fa-plus"},f0={key:1,class:"loading loading-spinner loading-xs"},p0={class:"border-t-4"},_0={colspan:"8",class:"text-right no-border"},g0={class:"text-right"},y0={key:0,class:"line-through"},b0=r("td",null,null,-1),v0={colspan:"8",class:"text-right no-border"},w0={class:"text-right"},x0=r("td",null,null,-1),E0={key:5},C0={colspan:"8",class:"text-right no-border"},T0={class:"text-right no-border"},I0={key:6},k0={colspan:"8",class:"text-right no-border"},A0={class:"text-right no-border"},S0=r("td",null,null,-1),D0={colspan:"8",class:"text-right no-border font-bold text-xl"},P0={class:"text-right no-border font-bold text-xl"},j0=r("td",null,null,-1),R0={key:7},M0={colspan:"8",class:"text-right no-border"},O0={class:"text-right no-border"},q0={key:8},N0={colspan:"8",class:"text-right no-border"},B0={class:"text-right no-border font-bold text-xl"};function V0(t,e,s,i,n,o){const a=O("InvoiceNavBar"),l=O("remove-modal"),f=O("article-modal"),d=O("remind-invoice-modal"),m=O("edit-item-modal"),p=O("edit-disb-modal"),y=O("Card");return u(),h("div",Rv,[P(a,{invoiceInfo:n.invoice,currencyDefault:o.defaultCurrency,currencyClient:o.clientCurrency,emailActive:n.settings.easy_compta_email_addon_active,qrCodeActive:n.settings.easy_compta_qrcode_addon_active,noItems:n.no_items},null,8,["invoiceInfo","currencyDefault","currencyClient","emailActive","qrCodeActive","noItems"]),P(l,{"modal-id":"modal_remove_item","show-modal":t.showRemoveModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:e[0]||(e[0]=_=>this.removeItem(n.selectedItem,n.SelectedInvoiceId)),onCancel:e[1]||(e[1]=_=>t.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),P(l,{"modal-id":"modal_remove_disb","show-modal":t.showRemoveModalDisb,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:e[2]||(e[2]=_=>this.removeDisb(n.selectedDisb,n.SelectedInvoiceId)),onCancel:e[3]||(e[3]=_=>t.showRemoveModalDisb=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),P(f,{"show-modal":n.showArticlesModal,"modal-id":"modal_articles","modal-title":o.translations.select,onSelectArticle:o.applySelectedArticle,onClose:e[4]||(e[4]=_=>n.showArticlesModal=!1)},null,8,["show-modal","modal-title","onSelectArticle"]),n.settings.easy_compta_email_addon_active==1?(u(),h("div",Mv,[P(d,{loading:t.loadingModal,"show-modal":n.RemindInvoiceModal,"modal-id":"modal_send_remind",client:n.client_detail,"invoice-id":n.invoice.id,subject:n.settings.remind_invoice_subject,content:n.settings.remind_invoice_content,onClose:e[5]||(e[5]=_=>n.RemindInvoiceModal=!1)},null,8,["loading","show-modal","client","invoice-id","subject","content"])])):g("",!0),n.toast.visible?(u(),h("div",{key:1,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),n.loading?(u(),h("div",Ov,Nv)):g("",!0),o.isInvoiceOverdue&&n.invoice.status=="unpaid"?(u(),h("div",Bv,[r("div",Vv,[Fv,r("span",null,c(o.translations.invoice_overdue),1),n.settings.easy_compta_email_addon_active==1?(u(),h("div",Uv,[r("button",{onClick:e[6]||(e[6]=J(_=>o.sendRemind(n.invoice.client_id),["prevent"])),class:"btn btn-sm btn-primary"},c(o.translations.remind_invoice),1)])):(u(),h("div",{key:1,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.active_email_addon},[r("button",Wv,c(o.translations.remind_invoice),1)],8,Lv))])])):g("",!0),P(y,{topMargin:"mt-8",id:"invoice-content"},{default:me(()=>[r("div",Xv,[r("div",Hv,[r("div",null,[r("img",{src:n.settings.logo_url,style:no({width:n.settings.logo_width+"px"}),alt:"Logo"},null,12,Qv)])]),r("div",zv,[r("p",Gv,c(n.invoice.invoice_number),1),r("div",null,[C(c(o.translations.created_at)+": ",1),r("strong",null,c(n.invoice.created_at),1)]),r("div",null,[C(c(o.translations.due_date)+": ",1),r("strong",null,c(n.invoice.due_date),1)]),r("div",null,[C(c(o.translations.status)+": ",1),n.invoice.status=="draft"?(u(),h("span",Jv,c(o.translations.draft),1)):g("",!0),n.invoice.status=="unpaid"?(u(),h("span",Yv,c(o.translations.unpaid),1)):g("",!0),n.invoice.status=="paid"?(u(),h("span",Kv,c(o.translations.paid),1)):g("",!0)])])]),r("div",Zv,[r("div",null,[r("strong",null,c(o.translations.bill_to)+":",1),r("h4",null,[r("strong",null,c(n.client_detail.company_name),1)]),r("p",null,[C(c(n.client_detail.address),1),$v,C(" "+c(n.client_detail.postal_code)+", "+c(n.client_detail.city)+" ",1),e1,C(" "+c(n.client_detail.country),1),t1,n.client_detail.phone?(u(),h("a",{key:0,href:"tel:"+n.client_detail.phone},c(n.client_detail.phone),9,n1)):g("",!0)])]),r("div",null,[r("strong",null,c(o.translations.received_from)+":",1),r("h4",null,[r("strong",null,c(n.settings.company_name),1)]),r("p",null,[C(c(n.settings.company_address),1),s1,C(" "+c(n.settings.postal_code)+", "+c(n.settings.city)+" ",1),o1,C(" "+c(n.settings.country),1),i1,n.settings.company_phone?(u(),h("a",{key:0,href:"tel:"+n.settings.company_phone},c(n.settings.company_phone),9,r1)):g("",!0),a1,n.settings.mobile_phone?(u(),h("a",{key:1,href:"tel:"+n.settings.mobile_phone},c(n.settings.mobile_phone),9,l1)):g("",!0)])])]),P(m,{loading:t.loadingModal,"show-modal":n.editItemsModal,"modal-id":"modal_edit_item","modal-title":o.translations.edit_item,item:n.selectedItem,onClose:e[7]||(e[7]=_=>n.editItemsModal=!1),onItemEdited:o.fetchItems},null,8,["loading","show-modal","modal-title","item","onItemEdited"]),P(p,{loading:t.loadingModal,"show-modal":n.editDisbModal,"modal-id":"modal_edit_disb","modal-title":o.translations.edit_item,disb:n.selectedDisb,onClose:e[8]||(e[8]=_=>n.editDisbModal=!1),onDisbEdited:o.fetchDisbursements},null,8,["loading","show-modal","modal-title","disb","onDisbEdited"]),r("form",{onSubmit:e[34]||(e[34]=J((..._)=>o.submitItems&&o.submitItems(..._),["prevent"]))},[r("table",c1,[r("thead",null,[r("tr",null,[d1,r("th",u1,c(o.translations.item_ref),1),r("th",h1,c(o.translations.item_name),1),r("th",m1,c(o.translations.description),1),r("th",f1,c(o.translations.quantity),1),r("th",p1,c(o.translations.unit_price),1),n.settings.vat_active==1?(u(),h("th",_1,c(o.translations.vat),1)):(u(),h("th",g1)),r("th",y1,c(o.translations.discount),1),r("th",b1,c(o.translations.total),1),v1])]),r("tbody",null,[(u(!0),h(F,null,U(n.invoiceItems,(_,v)=>(u(),h("tr",{key:_.id||v},[r("td",w1,[n.invoice.status=="draft"?(u(),h("i",x1)):g("",!0)]),r("td",null,c(_.item_ref),1),r("td",null,[_.category_name?(u(),h("div",E1,c(_.category_name),1)):g("",!0),r("div",null,c(_.item_name),1)]),r("td",{innerHTML:o.nl2br(_.item_description)},null,8,C1),r("td",T1,c(_.quantity),1),r("td",I1,[C(c(_.unit_price),1),n.default_currency_symbol==n.client_currency?(u(),h("span",k1,c(n.default_currency_symbol),1)):(u(),h("span",A1,c(n.client_currency),1))]),n.settings.vat_active==1?(u(),h("td",S1,c(_.vat_rate)+"% ",1)):(u(),h("td",D1)),n.settings.vat_active==1?(u(),h("td",P1,[C(c(_.discount)+"% ",1),j1,C(" "+c(o.calculateDiscountAmountWithVAT(_.quantity,_.unit_price,_.vat_rate,_.discount)),1)])):(u(),h("td",R1,[C(c(_.discount)+"% ",1),M1,C(" "+c(o.calculateDiscountAmount(_.quantity,_.unit_price,_.discount)),1)])),r("td",O1,[C(c(_.total_amount)+" ",1),n.default_currency_symbol==n.client_currency?(u(),h("span",q1,c(n.default_currency_symbol),1)):(u(),h("span",N1,c(n.client_currency),1))]),r("td",null,[n.invoice.status=="draft"?(u(),h("div",B1,[r("span",{class:"lg:tooltip","data-tip":o.translations.edit},[r("button",{onClick:J(x=>o.editItem(_.id),["prevent"]),class:"bg-purple-500 hover:bg-purple-700 text-white font-bold py-2 px-3 rounded"},L1,8,F1)],8,V1),r("span",{class:"lg:tooltip","data-tip":o.translations.delete},[r("button",{onClick:J(x=>o.confirmremoveItem(_.id,n.invoice.id),["prevent"]),class:"bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-3 mx-2 rounded"},[_.loading_del?g("",!0):(u(),h("i",H1)),_.loading_del?(u(),h("span",Q1)):g("",!0)],8,X1)],8,W1)])):g("",!0)])]))),128)),n.invoice.status=="draft"?(u(),h("tr",z1,[r("td",G1,[r("span",{class:"cursor-pointer",onClick:e[9]||(e[9]=J((..._)=>o.ShowModalArticles&&o.ShowModalArticles(..._),["prevent"]))},Y1)]),r("td",K1,[r("div",Z1,[D(r("input",{type:"text","onUpdate:modelValue":e[10]||(e[10]=_=>n.newItem.item_ref=_),onInput:e[11]||(e[11]=(..._)=>o.fetchRefs&&o.fetchRefs(..._)),onFocus:e[12]||(e[12]=_=>n.showDropdownRef=!0),placeholder:o.translations.item_ref,class:"w-full p-2.5 input-xs outline-none"},null,40,$1),[[W,n.newItem.item_ref]]),n.showDropdownRef&&n.refs.length?(u(),h("ul",ew,[(u(!0),h(F,null,U(n.refs,_=>(u(),h("li",{key:_.ref,onClick:v=>o.selectItem(_),class:"autocomplete-item",innerHTML:o.highlightMatch(_.ref)},null,8,tw))),128))])):g("",!0)])]),r("td",nw,[D(r("select",{class:"select select-xs w-full mb-1 ecwp-select","onUpdate:modelValue":e[13]||(e[13]=_=>n.newItem.item_category=_)},[sw,(u(!0),h(F,null,U(n.categories,_=>(u(),h("option",{key:_.id,value:_.id},c(_.name),9,ow))),128))],512),[[ue,n.newItem.item_category]]),r("div",iw,[rw,D(r("input",{type:"text","onUpdate:modelValue":e[14]||(e[14]=_=>n.newItem.item_name=_),onInput:e[15]||(e[15]=(..._)=>o.fetchArticles&&o.fetchArticles(..._)),onFocus:e[16]||(e[16]=_=>n.showDropdown=!0),placeholder:o.translations.item_name,class:"w-full p-2.5 bg-transparent input-xs outline-none"},null,40,aw),[[W,n.newItem.item_name]]),n.showDropdown&&n.articles.length?(u(),h("ul",lw,[(u(!0),h(F,null,U(n.articles,_=>(u(),h("li",{key:_.name,onClick:v=>o.selectItem(_),class:"autocomplete-item bt-primary",innerHTML:o.highlightMatch(_.name)},null,8,cw))),128))])):g("",!0)])]),r("td",dw,[r("div",uw,[D(r("textarea",{"onUpdate:modelValue":e[17]||(e[17]=_=>n.newItem.item_description=_),placeholder:o.translations.item_description,class:"textarea textarea-bordered input-xs w-full",onInput:e[18]||(e[18]=_=>o.resize()),ref:"textarea"},null,40,hw),[[W,n.newItem.item_description]])])]),r("td",mw,[r("div",fw,[r("div",pw,[r("div",{class:"select-none border py-3 px-2 cursor-pointer bg-base-300 hover:bg-gray-200 rounded-l",onClick:e[19]||(e[19]=(..._)=>o.decrease&&o.decrease(..._))}," - "),D(r("input",{type:"text",pattern:"([0-9]+.{0,1}[0-9]*,{0,1})*[0-9]","onUpdate:modelValue":e[20]||(e[20]=_=>n.newItem.quantity=_),placeholder:o.translations.quantity,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[21]||(e[21]=(..._)=>o.updateTotal&&o.updateTotal(..._))},null,40,_w),[[W,n.newItem.quantity]]),r("div",{class:"select-none border py-3 px-2 cursor-pointer bg-base-300 hover:bg-gray-200 rounded-r",onClick:e[22]||(e[22]=(..._)=>o.increase&&o.increase(..._))}," + ")])])]),r("td",gw,[r("div",yw,[D(r("input",{type:"text",pattern:"([0-9]+.{0,1}[0-9]*,{0,1})*[0-9]","onUpdate:modelValue":e[23]||(e[23]=_=>n.newItem.unit_price=_),placeholder:o.translations.unit_price,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[24]||(e[24]=(..._)=>o.updateTotal&&o.updateTotal(..._))},null,40,bw),[[W,n.newItem.unit_price]])])]),n.settings.vat_active==1?(u(),h("td",vw,[D(r("select",{"onUpdate:modelValue":e[25]||(e[25]=_=>n.newItem.vat_rate=_),onChange:e[26]||(e[26]=(..._)=>o.updateTotal&&o.updateTotal(..._)),class:"select select-md w-full mb-1 ecwp-select min-w-20"},[(u(!0),h(F,null,U(n.list_vats,_=>(u(),h("option",{key:_,value:_.rate},c(_.rate)+"% ",9,ww))),128))],544),[[ue,n.newItem.vat_rate]])])):(u(),h("td",xw)),r("td",Ew,[r("div",Cw,[D(r("input",{type:"number","onUpdate:modelValue":e[27]||(e[27]=_=>n.newItem.discount=_),min:"0",max:"100",placeholder:o.translations.discount,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[28]||(e[28]=(..._)=>o.updateTotal&&o.updateTotal(..._))},null,40,Tw),[[W,n.newItem.discount]]),Iw])]),n.settings.vat_active==1?(u(),h("td",kw,c(o.calculateTotalWithVat(n.newItem.quantity,n.newItem.unit_price,n.newItem.vat_rate,n.newItem.discount)),1)):(u(),h("td",Aw,c(o.calculateTotal(n.newItem.quantity,n.newItem.unit_price,n.newItem.discount)),1)),r("td",null,[n.invoice.status=="draft"?(u(),h("div",Sw,[r("span",{class:"lg:tooltip","data-tip":o.translations.add},[r("button",Pw,[n.loading_add?g("",!0):(u(),h("i",jw)),n.loading_add?(u(),h("span",Rw)):g("",!0)])],8,Dw)])):g("",!0)])])):g("",!0),n.settings.active_disbursements==1?(u(),h("tr",Mw,[r("td",Ow,[n.invoice.status=="draft"?(u(),h("button",{key:0,onClick:e[29]||(e[29]=J((..._)=>o.toggleDisbursements&&o.toggleDisbursements(..._),["prevent"])),class:"btn btn-primary py-2 px-4 rounded text-white"},[r("i",{class:I({"fas fa-plus":!n.showDisbursements,"fas fa-minus":n.showDisbursements})},null,2)])):g("",!0),n.invoice.status=="draft"||n.disbursementsExist?(u(),h("span",qw,c(o.translations.disbursements),1)):g("",!0)])])):g("",!0),n.settings.active_disbursements==1&&n.disbursementsList&&n.disbursementsList.length>0?(u(),h("tr",Nw,[r("th",Bw,c(o.translations.item_name),1),r("th",Vw,c(o.translations.description),1),r("th",Fw,c(o.translations.unit_price),1)])):g("",!0),(u(!0),h(F,null,U(n.disbursementsList,_=>(u(),h("tr",{key:_.id},[r("td",Uw,c(_.title),1),r("td",{class:"p-2",innerHTML:o.nl2br(_.description)},null,8,Lw),r("td",Ww,c(o.calculateTotal(1,_.unit_price,0)),1),r("td",Xw,[n.invoice.status=="draft"?(u(),h("div",Hw,[r("span",{class:"lg:tooltip","data-tip":o.translations.edit},[r("button",{onClick:J(v=>o.editDisb(_.id),["prevent"]),class:"bg-purple-500 hover:bg-purple-700 text-white font-bold py-2 px-3 rounded"},Jw,8,zw)],8,Qw),r("span",{class:"lg:tooltip","data-tip":o.translations.delete},[r("button",{onClick:J(v=>o.confirmremoveDisb(_.id,n.invoice.id),["prevent"]),class:"bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-3 mx-2 rounded"},[_.loading_del?g("",!0):(u(),h("i",Zw)),_.loading_del?(u(),h("span",$w)):g("",!0)],8,Kw)],8,Yw)])):g("",!0)])]))),128)),n.settings.active_disbursements==1&&n.showDisbursements&&n.invoice.status=="draft"?(u(),h("tr",e0,[r("td",t0,[r("div",n0,[D(r("input",{type:"text","onUpdate:modelValue":e[30]||(e[30]=_=>n.disbursementsItem.title=_),placeholder:o.translations.title,class:"w-full p-2.5 bg-transparent input-xs outline-none"},null,8,s0),[[W,n.disbursementsItem.title]])])]),r("td",o0,[r("div",i0,[D(r("textarea",{"onUpdate:modelValue":e[31]||(e[31]=_=>n.disbursementsItem.description=_),placeholder:o.translations.description,class:"textarea textarea-bordered input-xs w-full"},null,8,r0),[[W,n.disbursementsItem.description]])])]),r("td",a0,[r("div",l0,[D(r("input",{type:"text",pattern:"([0-9]+.{0,1}[0-9]*,{0,1})*[0-9]","onUpdate:modelValue":e[32]||(e[32]=_=>n.disbursementsItem.unit_price=_),placeholder:o.translations.price,class:"w-full p-2.5 bg-transparent input-xs outline-none"},null,8,c0),[[W,n.disbursementsItem.unit_price]])])]),d0,r("td",u0,c(o.calculateTotal(1,n.disbursementsItem.unit_price,0)),1),r("td",null,[r("span",{class:"lg:tooltip","data-tip":o.translations.add_disbursements},[r("button",{type:"submit",class:"bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded",onClick:e[33]||(e[33]=J((..._)=>o.addDisbursements&&o.addDisbursements(..._),["prevent"]))},[n.loading_add_disbursements?g("",!0):(u(),h("i",m0)),n.loading_add_disbursements?(u(),h("span",f0)):g("",!0)])],8,h0)])])):g("",!0),r("tr",p0,[r("td",_0,[r("strong",null,c(o.translations.subtotal),1)]),r("td",g0,[o.totalAmount!==o.totalAmountWithoutDiscount?(u(),h("span",y0,c(o.totalAmountWithoutDiscount),1)):g("",!0),C(" "+c(o.totalAmount),1)]),b0]),n.settings.vat_active==1?(u(!0),h(F,{key:4},U(o.getUniqueVATRates(),(_,v)=>(u(),h("tr",{key:v},[r("td",v0,[r("strong",null,c(o.translations.tax)+" ("+c(_)+"%) ",1)]),r("td",w0,c(o.calculateVATForRate(_)),1),x0]))),128)):g("",!0),n.invoice.shipping_amount?(u(),h("tr",E0,[r("td",C0,[r("strong",null,c(o.translations.shipping_fees),1)]),r("td",T0,c(o.formatShippingAmout(n.invoice.shipping_amount)),1)])):g("",!0),n.settings.active_disbursements==1&&n.disbursementsExist?(u(),h("tr",I0,[r("td",k0,[r("strong",null,c(o.translations.total_disbursements),1)]),r("td",A0,c(o.totalDisbursements()),1),S0])):g("",!0),r("tr",null,[r("td",D0,[r("strong",null,c(o.translations.total),1)]),r("td",P0,c(o.calculateTotalAmountWithVAT()),1),j0]),n.client_currency!=n.default_currency_symbol?(u(),h("tr",R0,[r("td",M0,[r("strong",null,c(o.translations.exchange_rate),1)]),r("td",O0,c(n.invoice.exchange_rate),1)])):g("",!0),n.client_currency!=n.default_currency_symbol?(u(),h("tr",q0,[r("td",N0,[r("strong",null,c(o.translations.total)+" "+c(n.default_currency_symbol),1)]),r("td",B0,c(o.totalAmountDefaultCurrency)+c(n.default_currency_symbol),1)])):g("",!0)])])],32)]),_:1})])}var F0=ne(jv,[["render",V0]]);const U0={name:"InvoiceNew",components:{Card:Ze,ModelSelect:hn,VueDatePicker:Nt,AddClientModal:jo},data(){return{invoice:{invoice_number:"",due_date:"",client_id:"",client:null,status:"",exchange_rate:0},showError:!1,loading:!1,loadingBtn:!1,clients:[],clientOptions:[],settings:[],last_invoice_number:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return t=>{if(!t)return"";const e=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getFullYear();return`${e}-${s}-${i}`}},currencyMismatch(){const t=this.clients.find(e=>e.id===this.invoice.client_id);return t&&this.settings.default_currency!==t.currency_id}},mounted(){this.fetchClients(),this.fetchSettings()},methods:{AddNew(){modal_clients.showModal()},cancelAction(){this.$router.push("/invoices")},fetchClients(){this.loading=!0,fetch("/wp-json/my-easy-compta/v1/list-clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.clients=t.clients,this.clientOptions=this.clients.map(e=>({value:e.id,text:`${e.company_name} - ${e.email} (${e.currency_symbol})`}))}).catch(t=>{console.error("Error fetching clients:",t)}).finally(()=>{this.loading=!1})},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,t.ok){const e=await t.json();this.settings=e;const s=`${this.settings.invoice_prefix}_${String(this.settings.last_invoice_id).padStart(4,"0")}`;this.invoice.number=s}else{const e=await t.json()}}catch{this.loading=!1}},handleClientChange(){const t=this.clients.find(e=>e.id===this.invoice.client_id);t&&this.settings.default_currency!==t.currency_id?this.invoice.exchange_rate=1:this.invoice.exchange_rate=0},submitInvoice(){if(!this.invoice.due_date||!this.invoice.client_id||!this.invoice.status){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.loadingBtn=!0,fetch("/wp-json/my-easy-compta/v1/invoices",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.invoice)}).then(t=>{if(!t.ok)throw new Error("Network response was not ok");return t.json()}).then(t=>{t.success?(this.loadingBtn=!1,this.showToast(t.message,"alert-success"),this.$router.push({name:"InvoiceViewDetail",params:{id:t.id}})):(console.error("Error submitting invoice:",t.message),this.showToast(t.message,"alert-error"),this.loadingBtn=!1)}).catch(t=>{console.error("Error submitting invoice:",t),this.showToast(t,"alert-error"),this.loadingBtn=!1})},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},L0={class:"pt-2 pr-4"},W0={class:"flex justify-between items-center mb-4"},X0={class:"card-title"},H0=r("div",{class:"divider mt-2"},null,-1),Q0={key:0,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},z0={class:"grid grid-cols-2 gap-4"},G0={class:"ecwp-group form-group mb-4"},J0={for:"invoiceNumber",class:"ecwp-label"},Y0={class:"ecwp-group form-group mb-4"},K0={for:"invoiceDate",class:"ecwp-label"},Z0={class:"mb-4"},$0={class:"flex gap-2 items-end"},ex=r("i",{class:"fas fa-plus"},null,-1),tx=[ex],nx={class:"ecwp-group form-group w-full"},sx={for:"client",class:"ecwp-label"},ox={class:"ecwp-group form-group mb-4"},ix={for:"status",class:"ecwp-label"},rx={value:"draft"},ax={key:0,class:"ecwp-group form-group mb-4"},lx={for:"exchangeRate",class:"ecwp-label"},cx={class:"flex justify-between"},dx=["disabled"],ux={key:0,class:"loading loading-spinner loading-sm"};function hx(t,e,s,i,n,o){const a=O("VueDatePicker"),l=O("model-select"),f=O("Card"),d=O("AddClientModal");return u(),h("div",L0,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),P(f,{topMargin:"mt-8",modalType:"modal_invoice_new"},{default:me(()=>[r("div",W0,[r("h2",X0,c(o.translations.new_invoice),1)]),H0,n.loading?(u(),h("div",Q0)):g("",!0),r("form",{onSubmit:e[7]||(e[7]=J((...m)=>o.submitInvoice&&o.submitInvoice(...m),["prevent"]))},[r("div",z0,[r("div",G0,[r("label",J0,c(o.translations.invoice_number),1),D(r("input",{type:"text",id:"invoiceNumber","onUpdate:modelValue":e[0]||(e[0]=m=>n.invoice.number=m),class:"ecwp-input input input-bordered w-full",disabled:"disabled"},null,512),[[W,n.invoice.number]])]),r("div",Y0,[r("label",K0,c(o.translations.due_date),1),P(a,{class:I(["ecwp-input ecwp-date input input-bordered w-full",[!n.invoice.due_date&&n.showError?"input-error":""]]),id:"invoiceDate",modelValue:n.invoice.due_date,"onUpdate:modelValue":e[1]||(e[1]=m=>n.invoice.due_date=m),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date,locale:"fr"},null,8,["class","modelValue","format","min-date"])]),r("div",Z0,[r("div",$0,[r("button",{type:"button",class:"btn btn-primary",onClick:e[2]||(e[2]=(...m)=>o.AddNew&&o.AddNew(...m))},tx),r("div",nx,[r("label",sx,c(o.translations.company_name),1),P(l,{modelValue:n.invoice.client_id,"onUpdate:modelValue":e[3]||(e[3]=m=>n.invoice.client_id=m),options:n.clientOptions,label:"text","track-by":"value",placeholder:o.translations.select,class:I(["ecwp-input input input-bordered w-full",[!n.invoice.client_id&&n.showError?"input-error":""]])},null,8,["modelValue","options","placeholder","class"])])])]),r("div",ox,[r("label",ix,c(o.translations.status),1),D(r("select",{id:"status","onUpdate:modelValue":e[4]||(e[4]=m=>n.invoice.status=m),class:I(["ecwp-input select select-bordered w-full",[!n.invoice.status&&n.showError?"input-error":""]])},[r("option",rx,c(o.translations.draft),1)],2),[[ue,n.invoice.status]])]),o.currencyMismatch?(u(),h("div",ax,[r("label",lx,c(o.translations.exchange_rate),1),D(r("input",{type:"text",id:"exchangeRate","onUpdate:modelValue":e[5]||(e[5]=m=>n.invoice.exchange_rate=m),class:"ecwp-input input input-bordered w-full",required:""},null,512),[[W,n.invoice.exchange_rate]])])):g("",!0)]),r("div",cx,[r("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:e[6]||(e[6]=(...m)=>o.cancelAction&&o.cancelAction(...m))},c(o.translations.cancel),1),r("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(c(o.translations.submit)+" ",1),n.loadingBtn?(u(),h("span",ux)):g("",!0)],8,dx)])],32)]),_:1}),P(d,{onClientAdded:o.fetchClients},null,8,["onClientAdded"])])}var mx=ne(U0,[["render",hx]]);const fx={name:"invoiceEdit",components:{Card:Ze,ModelSelect:hn,VueDatePicker:Nt},data(){return{invoice:{invoice_number:"",due_date:"",client_id:"",client:null,status:"paid",exchange_rate:0},showError:!1,loading:!1,loadingBtn:!1,clients:[],clientOptions:[],settings:[],toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return t=>{if(!t)return"";const e=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getFullYear();return`${e}-${s}-${i}`}},currencyMismatch(){const t=this.clients.find(e=>e.id===this.invoice.client_id);return t&&this.settings.default_currency!==t.currency_id}},mounted(){this.fetchClients(),this.fetchSettings(),this.fetchInvoiceDetails()},methods:{cancelAction(){this.$router.push("/invoices")},fetchClients(){this.loading=!0,fetch("/wp-json/my-easy-compta/v1/list-clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.clients=t.clients,this.clientOptions=this.clients.map(e=>({value:e.id,text:`${e.company_name} - ${e.email} (${e.currency_symbol})`})),this.invoice.client_id&&this.setClientById(this.invoice.client_id)}).catch(t=>{console.error("Error fetching clients:",t)}).finally(()=>{this.loading=!1})},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,t.ok){const e=await t.json();this.settings=e}else{const e=await t.json();console.error("Error fetching settings:",e)}}catch(t){this.loading=!1,console.error("Error fetching settings:",t)}},fetchInvoiceDetails(){const t=this.$route.params.id;!t||(this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{e?this.invoice=e:(console.error("Error fetching invoice details:",e.message),this.showToast(e.message,"alert-error"))}).catch(e=>{console.error("Error fetching invoice details:",e),this.showToast(e,"alert-error")}).finally(()=>{this.loading=!1}))},setClientById(t){this.invoice.client=this.clients.find(e=>e.id===t)||null},handleClientChange(){const t=this.clients.find(e=>e.id===this.invoice.client_id);t&&this.settings.default_currency!==t.currency_id?this.invoice.exchange_rate=1:this.invoice.exchange_rate=0},submitInvoice(){if(!this.invoice.due_date||!this.invoice.client_id||!this.invoice.status){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.loadingBtn=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/${this.$route.params.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.invoice)}).then(t=>{if(!t.ok)throw this.loadingBtn=!1,new Error("Network response was not ok");return t.json()}).then(t=>{t.success?(this.loadingBtn=!1,this.showToast(t.message,"alert-success"),this.$router.push({name:"InvoiceViewDetail",params:{id:t.id}})):(this.loadingBtn=!1,console.error("Error submitting invoice:",t.message),this.showToast(t.message,"alert-error"))}).catch(t=>{this.loadingBtn=!1,console.error("Error submitting invoice:",t),this.showToast(t,"alert-error")})},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},px={class:"pt-2 pr-4"},_x={class:"flex justify-between items-center mb-4"},gx={class:"card-title"},yx=r("div",{class:"divider mt-2"},null,-1),bx={key:0,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},vx={class:"grid grid-cols-2 gap-4"},wx={class:"ecwp-group form-group mb-4"},xx={for:"invoiceNumber",class:"ecwp-label"},Ex={class:"ecwp-group form-group mb-4"},Cx={for:"invoiceDate",class:"ecwp-label"},Tx={class:"ecwp-group form-group mb-4"},Ix={for:"client",class:"ecwp-label"},kx={class:"ecwp-group form-group mb-4"},Ax={for:"status",class:"ecwp-label"},Sx={value:"draft",selected:""},Dx={value:"unpaid"},Px={value:"paid"},jx={key:0,class:"ecwp-group form-group mb-4"},Rx={for:"exchangeRate",class:"ecwp-label"},Mx={class:"flex justify-between"},Ox=["disabled"],qx={key:0,class:"loading loading-spinner loading-sm"};function Nx(t,e,s,i,n,o){const a=O("VueDatePicker"),l=O("model-select"),f=O("Card");return u(),h("div",px,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),P(f,{topMargin:"mt-8",modalType:"modal_invoice_new"},{default:me(()=>[r("div",_x,[r("h2",gx,c(o.translations.edit_invoice),1)]),yx,n.loading?(u(),h("div",bx)):g("",!0),r("form",{onSubmit:e[6]||(e[6]=J((...d)=>o.submitInvoice&&o.submitInvoice(...d),["prevent"]))},[r("div",vx,[r("div",wx,[r("label",xx,c(o.translations.invoice_number),1),D(r("input",{type:"text",id:"invoiceNumber","onUpdate:modelValue":e[0]||(e[0]=d=>n.invoice.invoice_number=d),class:"ecwp-input input input-bordered w-full",disabled:"true"},null,512),[[W,n.invoice.invoice_number]])]),r("div",Ex,[r("label",Cx,c(o.translations.due_date),1),P(a,{class:I(["ecwp-input ecwp-date input input-bordered w-full",[!n.invoice.due_date&&n.showError?"input-error":""]]),id:"invoiceDate",modelValue:n.invoice.due_date,"onUpdate:modelValue":e[1]||(e[1]=d=>n.invoice.due_date=d),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date,locale:"fr"},null,8,["class","modelValue","format","min-date"])]),r("div",Tx,[r("label",Ix,c(o.translations.company_name),1),P(l,{modelValue:n.invoice.client_id,"onUpdate:modelValue":e[2]||(e[2]=d=>n.invoice.client_id=d),options:n.clientOptions,label:"text","track-by":"value",placeholder:o.translations.select,class:I(["ecwp-input input input-bordered w-full",[!n.invoice.client_id&&n.showError?"input-error":""]])},null,8,["modelValue","options","placeholder","class"])]),r("div",kx,[r("label",Ax,c(o.translations.status),1),D(r("select",{id:"status","onUpdate:modelValue":e[3]||(e[3]=d=>n.invoice.status=d),class:I(["ecwp-input select select-bordered w-full",[!n.invoice.status&&n.showError?"input-error":""]])},[r("option",Sx,c(o.translations.draft),1),r("option",Dx,c(o.translations.unpaid),1),r("option",Px,c(o.translations.paid),1)],2),[[ue,n.invoice.status]])]),o.currencyMismatch?(u(),h("div",jx,[r("label",Rx,c(o.translations.exchange_rate),1),D(r("input",{type:"text",id:"exchangeRate","onUpdate:modelValue":e[4]||(e[4]=d=>n.invoice.exchange_rate=d),class:"ecwp-input input input-bordered w-full",required:""},null,512),[[W,n.invoice.exchange_rate]])])):g("",!0)]),r("div",Mx,[r("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:e[5]||(e[5]=(...d)=>o.cancelAction&&o.cancelAction(...d))},c(o.translations.cancel),1),r("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(c(o.translations.save)+" ",1),n.loadingBtn?(u(),h("span",qx)):g("",!0)],8,Ox)])],32)]),_:1})])}var Bx=ne(fx,[["render",Nx]]);function dn(){const t=["InvoiceEdit","11xbjhaP","9734912KFmffv","84054neSbAH","InvoiceViewDetail","336178mQcVxk","QuoteNew","/quotes","/quote/detail/:id","21OqjKMt","QuoteViewDetail","Invoice","721mAHVIA","/invoice/detail/:id","25bgCFIU","924716VWdcDG","/quote/new","10215414WJDFxf","20110930vrsulG","/quote/edit/:id","1431848VWFYQc","/invoices"];return dn=function(){return t},dn()}const Ie=un;(function(t,e){const s=un,i=t();for(;[];)try{if(parseInt(s(107))/1+-parseInt(s(119))/2*(-parseInt(s(123))/3)+parseInt(s(112))/4*(-parseInt(s(106))/5)+parseInt(s(117))/6*(-parseInt(s(126))/7)+parseInt(s(116))/8+-parseInt(s(109))/9+-parseInt(s(110))/10*(-parseInt(s(115))/11)===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(dn,961513);function un(t,e){const s=dn();return un=function(i,n){return i=i-105,s[i]},un(t,e)}const Vx=[{path:Ie(121),name:"Quote",component:xd},{path:Ie(122),name:Ie(124),component:Pp},{path:Ie(108),name:Ie(120),component:l_},{path:Ie(111),name:"QuoteEdit",component:Ho},{path:Ie(113),name:Ie(125),component:bg},{path:Ie(105),name:Ie(118),component:F0},{path:"/invoice/edit/:id",name:Ie(114),component:Bx},{path:"/invoice/new",name:"InvoiceNew",component:mx}],Qx=Cl({history:Za(),routes:Vx});export{jo as A,Qx as r};
     15 */function Hs(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),s.push.apply(s,i)}return s}function Oe(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?Hs(Object(s),!0).forEach(function(i){Vh(t,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Hs(Object(s)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(s,i))})}return t}function Yt(t){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Yt=function(e){return typeof e}:Yt=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Yt(t)}function Vh(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function Le(){return Le=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(t[i]=s[i])}return t},Le.apply(this,arguments)}function Fh(t,e){if(t==null)return{};var s={},i=Object.keys(t),n,o;for(o=0;o<i.length;o++)n=i[o],!(e.indexOf(n)>=0)&&(s[n]=t[n]);return s}function Uh(t,e){if(t==null)return{};var s=Fh(t,e),i,n;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(n=0;n<o.length;n++)i=o[n],!(e.indexOf(i)>=0)&&(!Object.prototype.propertyIsEnumerable.call(t,i)||(s[i]=t[i]))}return s}var Lh="1.15.2";function Ue(t){if(typeof window!="undefined"&&window.navigator)return!!navigator.userAgent.match(t)}var We=Ue(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Vt=Ue(/Edge/i),zs=Ue(/firefox/i),kt=Ue(/safari/i)&&!Ue(/chrome/i)&&!Ue(/android/i),Qo=Ue(/iP(ad|od|hone)/i),Go=Ue(/chrome/i)&&Ue(/android/i),Jo={capture:!1,passive:!1};function Q(t,e,s){t.addEventListener(e,s,!We&&Jo)}function H(t,e,s){t.removeEventListener(e,s,!We&&Jo)}function on(t,e){if(!!e){if(e[0]===">"&&(e=e.substring(1)),t)try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch{return!1}return!1}}function Wh(t){return t.host&&t!==document&&t.host.nodeType?t.host:t.parentNode}function ke(t,e,s,i){if(t){s=s||document;do{if(e!=null&&(e[0]===">"?t.parentNode===s&&on(t,e):on(t,e))||i&&t===s)return t;if(t===s)break}while(t=Wh(t))}return null}var Qs=/\s+/g;function be(t,e,s){if(t&&e)if(t.classList)t.classList[s?"add":"remove"](e);else{var i=(" "+t.className+" ").replace(Qs," ").replace(" "+e+" "," ");t.className=(i+(s?" "+e:"")).replace(Qs," ")}}function N(t,e,s){var i=t&&t.style;if(i){if(s===void 0)return document.defaultView&&document.defaultView.getComputedStyle?s=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(s=t.currentStyle),e===void 0?s:s[e];!(e in i)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),i[e]=s+(typeof s=="string"?"":"px")}}function ct(t,e){var s="";if(typeof t=="string")s=t;else do{var i=N(t,"transform");i&&i!=="none"&&(s=i+" "+s)}while(!e&&(t=t.parentNode));var n=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return n&&new n(s)}function Yo(t,e,s){if(t){var i=t.getElementsByTagName(e),n=0,o=i.length;if(s)for(;n<o;n++)s(i[n],n);return i}return[]}function Me(){var t=document.scrollingElement;return t||document.documentElement}function ie(t,e,s,i,n){if(!(!t.getBoundingClientRect&&t!==window)){var o,a,l,f,d,m,p;if(t!==window&&t.parentNode&&t!==Me()?(o=t.getBoundingClientRect(),a=o.top,l=o.left,f=o.bottom,d=o.right,m=o.height,p=o.width):(a=0,l=0,f=window.innerHeight,d=window.innerWidth,m=window.innerHeight,p=window.innerWidth),(e||s)&&t!==window&&(n=n||t.parentNode,!We))do if(n&&n.getBoundingClientRect&&(N(n,"transform")!=="none"||s&&N(n,"position")!=="static")){var y=n.getBoundingClientRect();a-=y.top+parseInt(N(n,"border-top-width")),l-=y.left+parseInt(N(n,"border-left-width")),f=a+o.height,d=l+o.width;break}while(n=n.parentNode);if(i&&t!==window){var _=ct(n||t),v=_&&_.a,x=_&&_.d;_&&(a/=x,l/=v,p/=v,m/=x,f=a+m,d=l+p)}return{top:a,left:l,bottom:f,right:d,width:p,height:m}}}function Gs(t,e,s){for(var i=Ke(t,!0),n=ie(t)[e];i;){var o=ie(i)[s],a=void 0;if(s==="top"||s==="left"?a=n>=o:a=n<=o,!a)return i;if(i===Me())break;i=Ke(i,!1)}return!1}function ht(t,e,s,i){for(var n=0,o=0,a=t.children;o<a.length;){if(a[o].style.display!=="none"&&a[o]!==M.ghost&&(i||a[o]!==M.dragged)&&ke(a[o],s.draggable,t,!1)){if(n===e)return a[o];n++}o++}return null}function us(t,e){for(var s=t.lastElementChild;s&&(s===M.ghost||N(s,"display")==="none"||e&&!on(s,e));)s=s.previousElementSibling;return s||null}function xe(t,e){var s=0;if(!t||!t.parentNode)return-1;for(;t=t.previousElementSibling;)t.nodeName.toUpperCase()!=="TEMPLATE"&&t!==M.clone&&(!e||on(t,e))&&s++;return s}function Js(t){var e=0,s=0,i=Me();if(t)do{var n=ct(t),o=n.a,a=n.d;e+=t.scrollLeft*o,s+=t.scrollTop*a}while(t!==i&&(t=t.parentNode));return[e,s]}function Xh(t,e){for(var s in t)if(!!t.hasOwnProperty(s)){for(var i in e)if(e.hasOwnProperty(i)&&e[i]===t[s][i])return Number(s)}return-1}function Ke(t,e){if(!t||!t.getBoundingClientRect)return Me();var s=t,i=!1;do if(s.clientWidth<s.scrollWidth||s.clientHeight<s.scrollHeight){var n=N(s);if(s.clientWidth<s.scrollWidth&&(n.overflowX=="auto"||n.overflowX=="scroll")||s.clientHeight<s.scrollHeight&&(n.overflowY=="auto"||n.overflowY=="scroll")){if(!s.getBoundingClientRect||s===document.body)return Me();if(i||e)return s;i=!0}}while(s=s.parentNode);return Me()}function Hh(t,e){if(t&&e)for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s]);return t}function Rn(t,e){return Math.round(t.top)===Math.round(e.top)&&Math.round(t.left)===Math.round(e.left)&&Math.round(t.height)===Math.round(e.height)&&Math.round(t.width)===Math.round(e.width)}var At;function Ko(t,e){return function(){if(!At){var s=arguments,i=this;s.length===1?t.call(i,s[0]):t.apply(i,s),At=setTimeout(function(){At=void 0},e)}}}function zh(){clearTimeout(At),At=void 0}function Zo(t,e,s){t.scrollLeft+=e,t.scrollTop+=s}function $o(t){var e=window.Polymer,s=window.jQuery||window.Zepto;return e&&e.dom?e.dom(t).cloneNode(!0):s?s(t).clone(!0)[0]:t.cloneNode(!0)}function ei(t,e,s){var i={};return Array.from(t.children).forEach(function(n){var o,a,l,f;if(!(!ke(n,e.draggable,t,!1)||n.animated||n===s)){var d=ie(n);i.left=Math.min((o=i.left)!==null&&o!==void 0?o:1/0,d.left),i.top=Math.min((a=i.top)!==null&&a!==void 0?a:1/0,d.top),i.right=Math.max((l=i.right)!==null&&l!==void 0?l:-1/0,d.right),i.bottom=Math.max((f=i.bottom)!==null&&f!==void 0?f:-1/0,d.bottom)}}),i.width=i.right-i.left,i.height=i.bottom-i.top,i.x=i.left,i.y=i.top,i}var we="Sortable"+new Date().getTime();function Qh(){var t=[],e;return{captureAnimationState:function(){if(t=[],!!this.options.animation){var i=[].slice.call(this.el.children);i.forEach(function(n){if(!(N(n,"display")==="none"||n===M.ghost)){t.push({target:n,rect:ie(n)});var o=Oe({},t[t.length-1].rect);if(n.thisAnimationDuration){var a=ct(n,!0);a&&(o.top-=a.f,o.left-=a.e)}n.fromRect=o}})}},addAnimationState:function(i){t.push(i)},removeAnimationState:function(i){t.splice(Xh(t,{target:i}),1)},animateAll:function(i){var n=this;if(!this.options.animation){clearTimeout(e),typeof i=="function"&&i();return}var o=!1,a=0;t.forEach(function(l){var f=0,d=l.target,m=d.fromRect,p=ie(d),y=d.prevFromRect,_=d.prevToRect,v=l.rect,x=ct(d,!0);x&&(p.top-=x.f,p.left-=x.e),d.toRect=p,d.thisAnimationDuration&&Rn(y,p)&&!Rn(m,p)&&(v.top-p.top)/(v.left-p.left)===(m.top-p.top)/(m.left-p.left)&&(f=Jh(v,y,_,n.options)),Rn(p,m)||(d.prevFromRect=m,d.prevToRect=p,f||(f=n.options.animation),n.animate(d,v,p,f)),f&&(o=!0,a=Math.max(a,f),clearTimeout(d.animationResetTimer),d.animationResetTimer=setTimeout(function(){d.animationTime=0,d.prevFromRect=null,d.fromRect=null,d.prevToRect=null,d.thisAnimationDuration=null},f),d.thisAnimationDuration=f)}),clearTimeout(e),o?e=setTimeout(function(){typeof i=="function"&&i()},a):typeof i=="function"&&i(),t=[]},animate:function(i,n,o,a){if(a){N(i,"transition",""),N(i,"transform","");var l=ct(this.el),f=l&&l.a,d=l&&l.d,m=(n.left-o.left)/(f||1),p=(n.top-o.top)/(d||1);i.animatingX=!!m,i.animatingY=!!p,N(i,"transform","translate3d("+m+"px,"+p+"px,0)"),this.forRepaintDummy=Gh(i),N(i,"transition","transform "+a+"ms"+(this.options.easing?" "+this.options.easing:"")),N(i,"transform","translate3d(0,0,0)"),typeof i.animated=="number"&&clearTimeout(i.animated),i.animated=setTimeout(function(){N(i,"transition",""),N(i,"transform",""),i.animated=!1,i.animatingX=!1,i.animatingY=!1},a)}}}}function Gh(t){return t.offsetWidth}function Jh(t,e,s,i){return Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))/Math.sqrt(Math.pow(e.top-s.top,2)+Math.pow(e.left-s.left,2))*i.animation}var ot=[],jn={initializeByDefault:!0},Ft={mount:function(e){for(var s in jn)jn.hasOwnProperty(s)&&!(s in e)&&(e[s]=jn[s]);ot.forEach(function(i){if(i.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),ot.push(e)},pluginEvent:function(e,s,i){var n=this;this.eventCanceled=!1,i.cancel=function(){n.eventCanceled=!0};var o=e+"Global";ot.forEach(function(a){!s[a.pluginName]||(s[a.pluginName][o]&&s[a.pluginName][o](Oe({sortable:s},i)),s.options[a.pluginName]&&s[a.pluginName][e]&&s[a.pluginName][e](Oe({sortable:s},i)))})},initializePlugins:function(e,s,i,n){ot.forEach(function(l){var f=l.pluginName;if(!(!e.options[f]&&!l.initializeByDefault)){var d=new l(e,s,e.options);d.sortable=e,d.options=e.options,e[f]=d,Le(i,d.defaults)}});for(var o in e.options)if(!!e.options.hasOwnProperty(o)){var a=this.modifyOption(e,o,e.options[o]);typeof a!="undefined"&&(e.options[o]=a)}},getEventProperties:function(e,s){var i={};return ot.forEach(function(n){typeof n.eventProperties=="function"&&Le(i,n.eventProperties.call(s[n.pluginName],e))}),i},modifyOption:function(e,s,i){var n;return ot.forEach(function(o){!e[o.pluginName]||o.optionListeners&&typeof o.optionListeners[s]=="function"&&(n=o.optionListeners[s].call(e[o.pluginName],i))}),n}};function Yh(t){var e=t.sortable,s=t.rootEl,i=t.name,n=t.targetEl,o=t.cloneEl,a=t.toEl,l=t.fromEl,f=t.oldIndex,d=t.newIndex,m=t.oldDraggableIndex,p=t.newDraggableIndex,y=t.originalEvent,_=t.putSortable,v=t.extraEventProperties;if(e=e||s&&s[we],!!e){var x,R=e.options,q="on"+i.charAt(0).toUpperCase()+i.substr(1);window.CustomEvent&&!We&&!Vt?x=new CustomEvent(i,{bubbles:!0,cancelable:!0}):(x=document.createEvent("Event"),x.initEvent(i,!0,!0)),x.to=a||s,x.from=l||s,x.item=n||s,x.clone=o,x.oldIndex=f,x.newIndex=d,x.oldDraggableIndex=m,x.newDraggableIndex=p,x.originalEvent=y,x.pullMode=_?_.lastPutMode:void 0;var S=Oe(Oe({},v),Ft.getEventProperties(i,e));for(var k in S)x[k]=S[k];s&&s.dispatchEvent(x),R[q]&&R[q].call(e,x)}}var Kh=["evt"],ge=function(e,s){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=i.evt,o=Uh(i,Kh);Ft.pluginEvent.bind(M)(e,s,Oe({dragEl:E,parentEl:te,ghostEl:B,rootEl:$,nextEl:tt,lastDownEl:Kt,cloneEl:ee,cloneHidden:Ye,dragStarted:wt,putSortable:de,activeSortable:M.active,originalEvent:n,oldIndex:lt,oldDraggableIndex:St,newIndex:ve,newDraggableIndex:Je,hideGhostForTarget:oi,unhideGhostForTarget:ii,cloneNowHidden:function(){Ye=!0},cloneNowShown:function(){Ye=!1},dispatchSortableEvent:function(l){pe({sortable:s,name:l,originalEvent:n})}},o))};function pe(t){Yh(Oe({putSortable:de,cloneEl:ee,targetEl:E,rootEl:$,oldIndex:lt,oldDraggableIndex:St,newIndex:ve,newDraggableIndex:Je},t))}var E,te,B,$,tt,Kt,ee,Ye,lt,ve,St,Je,Wt,de,at=!1,rn=!1,an=[],$e,Ie,Mn,On,Ys,Ks,wt,it,Dt,Pt=!1,Xt=!1,Zt,he,qn=[],Kn=!1,ln=[],wn=typeof document!="undefined",Ht=Qo,Zs=Vt||We?"cssFloat":"float",Zh=wn&&!Go&&!Qo&&"draggable"in document.createElement("div"),ti=function(){if(!!wn){if(We)return!1;var t=document.createElement("x");return t.style.cssText="pointer-events:auto",t.style.pointerEvents==="auto"}}(),ni=function(e,s){var i=N(e),n=parseInt(i.width)-parseInt(i.paddingLeft)-parseInt(i.paddingRight)-parseInt(i.borderLeftWidth)-parseInt(i.borderRightWidth),o=ht(e,0,s),a=ht(e,1,s),l=o&&N(o),f=a&&N(a),d=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+ie(o).width,m=f&&parseInt(f.marginLeft)+parseInt(f.marginRight)+ie(a).width;if(i.display==="flex")return i.flexDirection==="column"||i.flexDirection==="column-reverse"?"vertical":"horizontal";if(i.display==="grid")return i.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(o&&l.float&&l.float!=="none"){var p=l.float==="left"?"left":"right";return a&&(f.clear==="both"||f.clear===p)?"vertical":"horizontal"}return o&&(l.display==="block"||l.display==="flex"||l.display==="table"||l.display==="grid"||d>=n&&i[Zs]==="none"||a&&i[Zs]==="none"&&d+m>n)?"vertical":"horizontal"},$h=function(e,s,i){var n=i?e.left:e.top,o=i?e.right:e.bottom,a=i?e.width:e.height,l=i?s.left:s.top,f=i?s.right:s.bottom,d=i?s.width:s.height;return n===l||o===f||n+a/2===l+d/2},em=function(e,s){var i;return an.some(function(n){var o=n[we].options.emptyInsertThreshold;if(!(!o||us(n))){var a=ie(n),l=e>=a.left-o&&e<=a.right+o,f=s>=a.top-o&&s<=a.bottom+o;if(l&&f)return i=n}}),i},si=function(e){function s(o,a){return function(l,f,d,m){var p=l.options.group.name&&f.options.group.name&&l.options.group.name===f.options.group.name;if(o==null&&(a||p))return!0;if(o==null||o===!1)return!1;if(a&&o==="clone")return o;if(typeof o=="function")return s(o(l,f,d,m),a)(l,f,d,m);var y=(a?l:f).options.group.name;return o===!0||typeof o=="string"&&o===y||o.join&&o.indexOf(y)>-1}}var i={},n=e.group;(!n||Yt(n)!="object")&&(n={name:n}),i.name=n.name,i.checkPull=s(n.pull,!0),i.checkPut=s(n.put),i.revertClone=n.revertClone,e.group=i},oi=function(){!ti&&B&&N(B,"display","none")},ii=function(){!ti&&B&&N(B,"display","")};wn&&!Go&&document.addEventListener("click",function(t){if(rn)return t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.stopImmediatePropagation&&t.stopImmediatePropagation(),rn=!1,!1},!0);var et=function(e){if(E){e=e.touches?e.touches[0]:e;var s=em(e.clientX,e.clientY);if(s){var i={};for(var n in e)e.hasOwnProperty(n)&&(i[n]=e[n]);i.target=i.rootEl=s,i.preventDefault=void 0,i.stopPropagation=void 0,s[we]._onDragOver(i)}}},tm=function(e){E&&E.parentNode[we]._isOutsideThisEl(e.target)};function M(t,e){if(!(t&&t.nodeType&&t.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(t));this.el=t,this.options=e=Le({},e),t[we]=this;var s={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(t.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return ni(t,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(a,l){a.setData("Text",l.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:M.supportPointer!==!1&&"PointerEvent"in window&&!kt,emptyInsertThreshold:5};Ft.initializePlugins(this,t,s);for(var i in s)!(i in e)&&(e[i]=s[i]);si(e);for(var n in this)n.charAt(0)==="_"&&typeof this[n]=="function"&&(this[n]=this[n].bind(this));this.nativeDraggable=e.forceFallback?!1:Zh,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?Q(t,"pointerdown",this._onTapStart):(Q(t,"mousedown",this._onTapStart),Q(t,"touchstart",this._onTapStart)),this.nativeDraggable&&(Q(t,"dragover",this),Q(t,"dragenter",this)),an.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),Le(this,Qh())}M.prototype={constructor:M,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(it=null)},_getDirection:function(e,s){return typeof this.options.direction=="function"?this.options.direction.call(this,e,s,E):this.options.direction},_onTapStart:function(e){if(!!e.cancelable){var s=this,i=this.el,n=this.options,o=n.preventOnFilter,a=e.type,l=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,f=(l||e).target,d=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||f,m=n.filter;if(cm(i),!E&&!(/mousedown|pointerdown/.test(a)&&e.button!==0||n.disabled)&&!d.isContentEditable&&!(!this.nativeDraggable&&kt&&f&&f.tagName.toUpperCase()==="SELECT")&&(f=ke(f,n.draggable,i,!1),!(f&&f.animated)&&Kt!==f)){if(lt=xe(f),St=xe(f,n.draggable),typeof m=="function"){if(m.call(this,e,f,this)){pe({sortable:s,rootEl:d,name:"filter",targetEl:f,toEl:i,fromEl:i}),ge("filter",s,{evt:e}),o&&e.cancelable&&e.preventDefault();return}}else if(m&&(m=m.split(",").some(function(p){if(p=ke(d,p.trim(),i,!1),p)return pe({sortable:s,rootEl:p,name:"filter",targetEl:f,fromEl:i,toEl:i}),ge("filter",s,{evt:e}),!0}),m)){o&&e.cancelable&&e.preventDefault();return}n.handle&&!ke(d,n.handle,i,!1)||this._prepareDragStart(e,l,f)}}},_prepareDragStart:function(e,s,i){var n=this,o=n.el,a=n.options,l=o.ownerDocument,f;if(i&&!E&&i.parentNode===o){var d=ie(i);if($=o,E=i,te=E.parentNode,tt=E.nextSibling,Kt=i,Wt=a.group,M.dragged=E,$e={target:E,clientX:(s||e).clientX,clientY:(s||e).clientY},Ys=$e.clientX-d.left,Ks=$e.clientY-d.top,this._lastX=(s||e).clientX,this._lastY=(s||e).clientY,E.style["will-change"]="all",f=function(){if(ge("delayEnded",n,{evt:e}),M.eventCanceled){n._onDrop();return}n._disableDelayedDragEvents(),!zs&&n.nativeDraggable&&(E.draggable=!0),n._triggerDragStart(e,s),pe({sortable:n,name:"choose",originalEvent:e}),be(E,a.chosenClass,!0)},a.ignore.split(",").forEach(function(m){Yo(E,m.trim(),Nn)}),Q(l,"dragover",et),Q(l,"mousemove",et),Q(l,"touchmove",et),Q(l,"mouseup",n._onDrop),Q(l,"touchend",n._onDrop),Q(l,"touchcancel",n._onDrop),zs&&this.nativeDraggable&&(this.options.touchStartThreshold=4,E.draggable=!0),ge("delayStart",this,{evt:e}),a.delay&&(!a.delayOnTouchOnly||s)&&(!this.nativeDraggable||!(Vt||We))){if(M.eventCanceled){this._onDrop();return}Q(l,"mouseup",n._disableDelayedDrag),Q(l,"touchend",n._disableDelayedDrag),Q(l,"touchcancel",n._disableDelayedDrag),Q(l,"mousemove",n._delayedDragTouchMoveHandler),Q(l,"touchmove",n._delayedDragTouchMoveHandler),a.supportPointer&&Q(l,"pointermove",n._delayedDragTouchMoveHandler),n._dragStartTimer=setTimeout(f,a.delay)}else f()}},_delayedDragTouchMoveHandler:function(e){var s=e.touches?e.touches[0]:e;Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){E&&Nn(E),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;H(e,"mouseup",this._disableDelayedDrag),H(e,"touchend",this._disableDelayedDrag),H(e,"touchcancel",this._disableDelayedDrag),H(e,"mousemove",this._delayedDragTouchMoveHandler),H(e,"touchmove",this._delayedDragTouchMoveHandler),H(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,s){s=s||e.pointerType=="touch"&&e,!this.nativeDraggable||s?this.options.supportPointer?Q(document,"pointermove",this._onTouchMove):s?Q(document,"touchmove",this._onTouchMove):Q(document,"mousemove",this._onTouchMove):(Q(E,"dragend",this),Q($,"dragstart",this._onDragStart));try{document.selection?$t(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,s){if(at=!1,$&&E){ge("dragStarted",this,{evt:s}),this.nativeDraggable&&Q(document,"dragover",tm);var i=this.options;!e&&be(E,i.dragClass,!1),be(E,i.ghostClass,!0),M.active=this,e&&this._appendGhost(),pe({sortable:this,name:"start",originalEvent:s})}else this._nulling()},_emulateDragOver:function(){if(Ie){this._lastX=Ie.clientX,this._lastY=Ie.clientY,oi();for(var e=document.elementFromPoint(Ie.clientX,Ie.clientY),s=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(Ie.clientX,Ie.clientY),e!==s);)s=e;if(E.parentNode[we]._isOutsideThisEl(e),s)do{if(s[we]){var i=void 0;if(i=s[we]._onDragOver({clientX:Ie.clientX,clientY:Ie.clientY,target:e,rootEl:s}),i&&!this.options.dragoverBubble)break}e=s}while(s=s.parentNode);ii()}},_onTouchMove:function(e){if($e){var s=this.options,i=s.fallbackTolerance,n=s.fallbackOffset,o=e.touches?e.touches[0]:e,a=B&&ct(B,!0),l=B&&a&&a.a,f=B&&a&&a.d,d=Ht&&he&&Js(he),m=(o.clientX-$e.clientX+n.x)/(l||1)+(d?d[0]-qn[0]:0)/(l||1),p=(o.clientY-$e.clientY+n.y)/(f||1)+(d?d[1]-qn[1]:0)/(f||1);if(!M.active&&!at){if(i&&Math.max(Math.abs(o.clientX-this._lastX),Math.abs(o.clientY-this._lastY))<i)return;this._onDragStart(e,!0)}if(B){a?(a.e+=m-(Mn||0),a.f+=p-(On||0)):a={a:1,b:0,c:0,d:1,e:m,f:p};var y="matrix(".concat(a.a,",").concat(a.b,",").concat(a.c,",").concat(a.d,",").concat(a.e,",").concat(a.f,")");N(B,"webkitTransform",y),N(B,"mozTransform",y),N(B,"msTransform",y),N(B,"transform",y),Mn=m,On=p,Ie=o}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!B){var e=this.options.fallbackOnBody?document.body:$,s=ie(E,!0,Ht,!0,e),i=this.options;if(Ht){for(he=e;N(he,"position")==="static"&&N(he,"transform")==="none"&&he!==document;)he=he.parentNode;he!==document.body&&he!==document.documentElement?(he===document&&(he=Me()),s.top+=he.scrollTop,s.left+=he.scrollLeft):he=Me(),qn=Js(he)}B=E.cloneNode(!0),be(B,i.ghostClass,!1),be(B,i.fallbackClass,!0),be(B,i.dragClass,!0),N(B,"transition",""),N(B,"transform",""),N(B,"box-sizing","border-box"),N(B,"margin",0),N(B,"top",s.top),N(B,"left",s.left),N(B,"width",s.width),N(B,"height",s.height),N(B,"opacity","0.8"),N(B,"position",Ht?"absolute":"fixed"),N(B,"zIndex","100000"),N(B,"pointerEvents","none"),M.ghost=B,e.appendChild(B),N(B,"transform-origin",Ys/parseInt(B.style.width)*100+"% "+Ks/parseInt(B.style.height)*100+"%")}},_onDragStart:function(e,s){var i=this,n=e.dataTransfer,o=i.options;if(ge("dragStart",this,{evt:e}),M.eventCanceled){this._onDrop();return}ge("setupClone",this),M.eventCanceled||(ee=$o(E),ee.removeAttribute("id"),ee.draggable=!1,ee.style["will-change"]="",this._hideClone(),be(ee,this.options.chosenClass,!1),M.clone=ee),i.cloneId=$t(function(){ge("clone",i),!M.eventCanceled&&(i.options.removeCloneOnHide||$.insertBefore(ee,E),i._hideClone(),pe({sortable:i,name:"clone"}))}),!s&&be(E,o.dragClass,!0),s?(rn=!0,i._loopId=setInterval(i._emulateDragOver,50)):(H(document,"mouseup",i._onDrop),H(document,"touchend",i._onDrop),H(document,"touchcancel",i._onDrop),n&&(n.effectAllowed="move",o.setData&&o.setData.call(i,n,E)),Q(document,"drop",i),N(E,"transform","translateZ(0)")),at=!0,i._dragStartId=$t(i._dragStarted.bind(i,s,e)),Q(document,"selectstart",i),wt=!0,kt&&N(document.body,"user-select","none")},_onDragOver:function(e){var s=this.el,i=e.target,n,o,a,l=this.options,f=l.group,d=M.active,m=Wt===f,p=l.sort,y=de||d,_,v=this,x=!1;if(Kn)return;function R(Ve,xn){ge(Ve,v,Oe({evt:e,isOwner:m,axis:_?"vertical":"horizontal",revert:a,dragRect:n,targetRect:o,canSort:p,fromSortable:y,target:i,completed:S,onMove:function(_t,gt){return zt($,s,E,n,_t,ie(_t),e,gt)},changed:k},xn))}function q(){R("dragOverAnimationCapture"),v.captureAnimationState(),v!==y&&y.captureAnimationState()}function S(Ve){return R("dragOverCompleted",{insertion:Ve}),Ve&&(m?d._hideClone():d._showClone(v),v!==y&&(be(E,de?de.options.ghostClass:d.options.ghostClass,!1),be(E,l.ghostClass,!0)),de!==v&&v!==M.active?de=v:v===M.active&&de&&(de=null),y===v&&(v._ignoreWhileAnimating=i),v.animateAll(function(){R("dragOverAnimationComplete"),v._ignoreWhileAnimating=null}),v!==y&&(y.animateAll(),y._ignoreWhileAnimating=null)),(i===E&&!E.animated||i===s&&!i.animated)&&(it=null),!l.dragoverBubble&&!e.rootEl&&i!==document&&(E.parentNode[we]._isOutsideThisEl(e.target),!Ve&&et(e)),!l.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),x=!0}function k(){ve=xe(E),Je=xe(E,l.draggable),pe({sortable:v,name:"change",toEl:s,newIndex:ve,newDraggableIndex:Je,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),i=ke(i,l.draggable,s,!0),R("dragOver"),M.eventCanceled)return x;if(E.contains(e.target)||i.animated&&i.animatingX&&i.animatingY||v._ignoreWhileAnimating===i)return S(!1);if(rn=!1,d&&!l.disabled&&(m?p||(a=te!==$):de===this||(this.lastPutMode=Wt.checkPull(this,d,E,e))&&f.checkPut(this,d,E,e))){if(_=this._getDirection(e,i)==="vertical",n=ie(E),R("dragOverValid"),M.eventCanceled)return x;if(a)return te=$,q(),this._hideClone(),R("revert"),M.eventCanceled||(tt?$.insertBefore(E,tt):$.appendChild(E)),S(!0);var z=us(s,l.draggable);if(!z||im(e,_,this)&&!z.animated){if(z===E)return S(!1);if(z&&s===e.target&&(i=z),i&&(o=ie(i)),zt($,s,E,n,i,o,e,!!i)!==!1)return q(),z&&z.nextSibling?s.insertBefore(E,z.nextSibling):s.appendChild(E),te=s,k(),S(!0)}else if(z&&om(e,_,this)){var le=ht(s,0,l,!0);if(le===E)return S(!1);if(i=le,o=ie(i),zt($,s,E,n,i,o,e,!1)!==!1)return q(),s.insertBefore(E,le),te=s,k(),S(!0)}else if(i.parentNode===s){o=ie(i);var Y=0,K,Re=E.parentNode!==s,ce=!$h(E.animated&&E.toRect||n,i.animated&&i.toRect||o,_),Xe=_?"top":"left",Ce=Gs(i,"top","top")||Gs(E,"top","top"),He=Ce?Ce.scrollTop:void 0;it!==i&&(K=o[Xe],Pt=!1,Xt=!ce&&l.invertSwap||Re),Y=rm(e,i,o,_,ce?1:l.swapThreshold,l.invertedSwapThreshold==null?l.swapThreshold:l.invertedSwapThreshold,Xt,it===i);var fe;if(Y!==0){var qe=xe(E);do qe-=Y,fe=te.children[qe];while(fe&&(N(fe,"display")==="none"||fe===B))}if(Y===0||fe===i)return S(!1);it=i,Dt=Y;var Ne=i.nextElementSibling,Te=!1;Te=Y===1;var Be=zt($,s,E,n,i,o,e,Te);if(Be!==!1)return(Be===1||Be===-1)&&(Te=Be===1),Kn=!0,setTimeout(sm,30),q(),Te&&!Ne?s.appendChild(E):i.parentNode.insertBefore(E,Te?Ne:i),Ce&&Zo(Ce,0,He-Ce.scrollTop),te=E.parentNode,K!==void 0&&!Xt&&(Zt=Math.abs(K-ie(i)[Xe])),k(),S(!0)}if(s.contains(E))return S(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){H(document,"mousemove",this._onTouchMove),H(document,"touchmove",this._onTouchMove),H(document,"pointermove",this._onTouchMove),H(document,"dragover",et),H(document,"mousemove",et),H(document,"touchmove",et)},_offUpEvents:function(){var e=this.el.ownerDocument;H(e,"mouseup",this._onDrop),H(e,"touchend",this._onDrop),H(e,"pointerup",this._onDrop),H(e,"touchcancel",this._onDrop),H(document,"selectstart",this)},_onDrop:function(e){var s=this.el,i=this.options;if(ve=xe(E),Je=xe(E,i.draggable),ge("drop",this,{evt:e}),te=E&&E.parentNode,ve=xe(E),Je=xe(E,i.draggable),M.eventCanceled){this._nulling();return}at=!1,Xt=!1,Pt=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Zn(this.cloneId),Zn(this._dragStartId),this.nativeDraggable&&(H(document,"drop",this),H(s,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),kt&&N(document.body,"user-select",""),N(E,"transform",""),e&&(wt&&(e.cancelable&&e.preventDefault(),!i.dropBubble&&e.stopPropagation()),B&&B.parentNode&&B.parentNode.removeChild(B),($===te||de&&de.lastPutMode!=="clone")&&ee&&ee.parentNode&&ee.parentNode.removeChild(ee),E&&(this.nativeDraggable&&H(E,"dragend",this),Nn(E),E.style["will-change"]="",wt&&!at&&be(E,de?de.options.ghostClass:this.options.ghostClass,!1),be(E,this.options.chosenClass,!1),pe({sortable:this,name:"unchoose",toEl:te,newIndex:null,newDraggableIndex:null,originalEvent:e}),$!==te?(ve>=0&&(pe({rootEl:te,name:"add",toEl:te,fromEl:$,originalEvent:e}),pe({sortable:this,name:"remove",toEl:te,originalEvent:e}),pe({rootEl:te,name:"sort",toEl:te,fromEl:$,originalEvent:e}),pe({sortable:this,name:"sort",toEl:te,originalEvent:e})),de&&de.save()):ve!==lt&&ve>=0&&(pe({sortable:this,name:"update",toEl:te,originalEvent:e}),pe({sortable:this,name:"sort",toEl:te,originalEvent:e})),M.active&&((ve==null||ve===-1)&&(ve=lt,Je=St),pe({sortable:this,name:"end",toEl:te,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){ge("nulling",this),$=E=te=B=tt=ee=Kt=Ye=$e=Ie=wt=ve=Je=lt=St=it=Dt=de=Wt=M.dragged=M.ghost=M.clone=M.active=null,ln.forEach(function(e){e.checked=!0}),ln.length=Mn=On=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":E&&(this._onDragOver(e),nm(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],s,i=this.el.children,n=0,o=i.length,a=this.options;n<o;n++)s=i[n],ke(s,a.draggable,this.el,!1)&&e.push(s.getAttribute(a.dataIdAttr)||lm(s));return e},sort:function(e,s){var i={},n=this.el;this.toArray().forEach(function(o,a){var l=n.children[a];ke(l,this.options.draggable,n,!1)&&(i[o]=l)},this),s&&this.captureAnimationState(),e.forEach(function(o){i[o]&&(n.removeChild(i[o]),n.appendChild(i[o]))}),s&&this.animateAll()},save:function(){var e=this.options.store;e&&e.set&&e.set(this)},closest:function(e,s){return ke(e,s||this.options.draggable,this.el,!1)},option:function(e,s){var i=this.options;if(s===void 0)return i[e];var n=Ft.modifyOption(this,e,s);typeof n!="undefined"?i[e]=n:i[e]=s,e==="group"&&si(i)},destroy:function(){ge("destroy",this);var e=this.el;e[we]=null,H(e,"mousedown",this._onTapStart),H(e,"touchstart",this._onTapStart),H(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(H(e,"dragover",this),H(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(s){s.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),an.splice(an.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!Ye){if(ge("hideClone",this),M.eventCanceled)return;N(ee,"display","none"),this.options.removeCloneOnHide&&ee.parentNode&&ee.parentNode.removeChild(ee),Ye=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(Ye){if(ge("showClone",this),M.eventCanceled)return;E.parentNode==$&&!this.options.group.revertClone?$.insertBefore(ee,E):tt?$.insertBefore(ee,tt):$.appendChild(ee),this.options.group.revertClone&&this.animate(E,ee),N(ee,"display",""),Ye=!1}}};function nm(t){t.dataTransfer&&(t.dataTransfer.dropEffect="move"),t.cancelable&&t.preventDefault()}function zt(t,e,s,i,n,o,a,l){var f,d=t[we],m=d.options.onMove,p;return window.CustomEvent&&!We&&!Vt?f=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(f=document.createEvent("Event"),f.initEvent("move",!0,!0)),f.to=e,f.from=t,f.dragged=s,f.draggedRect=i,f.related=n||e,f.relatedRect=o||ie(e),f.willInsertAfter=l,f.originalEvent=a,t.dispatchEvent(f),m&&(p=m.call(d,f,a)),p}function Nn(t){t.draggable=!1}function sm(){Kn=!1}function om(t,e,s){var i=ie(ht(s.el,0,s.options,!0)),n=ei(s.el,s.options,B),o=10;return e?t.clientX<n.left-o||t.clientY<i.top&&t.clientX<i.right:t.clientY<n.top-o||t.clientY<i.bottom&&t.clientX<i.left}function im(t,e,s){var i=ie(us(s.el,s.options.draggable)),n=ei(s.el,s.options,B),o=10;return e?t.clientX>n.right+o||t.clientY>i.bottom&&t.clientX>i.left:t.clientY>n.bottom+o||t.clientX>i.right&&t.clientY>i.top}function rm(t,e,s,i,n,o,a,l){var f=i?t.clientY:t.clientX,d=i?s.height:s.width,m=i?s.top:s.left,p=i?s.bottom:s.right,y=!1;if(!a){if(l&&Zt<d*n){if(!Pt&&(Dt===1?f>m+d*o/2:f<p-d*o/2)&&(Pt=!0),Pt)y=!0;else if(Dt===1?f<m+Zt:f>p-Zt)return-Dt}else if(f>m+d*(1-n)/2&&f<p-d*(1-n)/2)return am(e)}return y=y||a,y&&(f<m+d*o/2||f>p-d*o/2)?f>m+d/2?1:-1:0}function am(t){return xe(E)<xe(t)?1:-1}function lm(t){for(var e=t.tagName+t.className+t.src+t.href+t.textContent,s=e.length,i=0;s--;)i+=e.charCodeAt(s);return i.toString(36)}function cm(t){ln.length=0;for(var e=t.getElementsByTagName("input"),s=e.length;s--;){var i=e[s];i.checked&&ln.push(i)}}function $t(t){return setTimeout(t,0)}function Zn(t){return clearTimeout(t)}wn&&Q(document,"touchmove",function(t){(M.active||at)&&t.cancelable&&t.preventDefault()});M.utils={on:Q,off:H,css:N,find:Yo,is:function(e,s){return!!ke(e,s,e,!1)},extend:Hh,throttle:Ko,closest:ke,toggleClass:be,clone:$o,index:xe,nextTick:$t,cancelNextTick:Zn,detectDirection:ni,getChild:ht};M.get=function(t){return t[we]};M.mount=function(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];e[0].constructor===Array&&(e=e[0]),e.forEach(function(i){if(!i.prototype||!i.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(i));i.utils&&(M.utils=Oe(Oe({},M.utils),i.utils)),Ft.mount(i)})};M.create=function(t,e){return new M(t,e)};M.version=Lh;var oe=[],xt,$n,es=!1,Bn,Vn,cn,Et;function dm(){function t(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var e in this)e.charAt(0)==="_"&&typeof this[e]=="function"&&(this[e]=this[e].bind(this))}return t.prototype={dragStarted:function(s){var i=s.originalEvent;this.sortable.nativeDraggable?Q(document,"dragover",this._handleAutoScroll):this.options.supportPointer?Q(document,"pointermove",this._handleFallbackAutoScroll):i.touches?Q(document,"touchmove",this._handleFallbackAutoScroll):Q(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(s){var i=s.originalEvent;!this.options.dragOverBubble&&!i.rootEl&&this._handleAutoScroll(i)},drop:function(){this.sortable.nativeDraggable?H(document,"dragover",this._handleAutoScroll):(H(document,"pointermove",this._handleFallbackAutoScroll),H(document,"touchmove",this._handleFallbackAutoScroll),H(document,"mousemove",this._handleFallbackAutoScroll)),$s(),en(),zh()},nulling:function(){cn=$n=xt=es=Et=Bn=Vn=null,oe.length=0},_handleFallbackAutoScroll:function(s){this._handleAutoScroll(s,!0)},_handleAutoScroll:function(s,i){var n=this,o=(s.touches?s.touches[0]:s).clientX,a=(s.touches?s.touches[0]:s).clientY,l=document.elementFromPoint(o,a);if(cn=s,i||this.options.forceAutoScrollFallback||Vt||We||kt){Fn(s,this.options,l,i);var f=Ke(l,!0);es&&(!Et||o!==Bn||a!==Vn)&&(Et&&$s(),Et=setInterval(function(){var d=Ke(document.elementFromPoint(o,a),!0);d!==f&&(f=d,en()),Fn(s,n.options,d,i)},10),Bn=o,Vn=a)}else{if(!this.options.bubbleScroll||Ke(l,!0)===Me()){en();return}Fn(s,this.options,Ke(l,!1),!1)}}},Le(t,{pluginName:"scroll",initializeByDefault:!0})}function en(){oe.forEach(function(t){clearInterval(t.pid)}),oe=[]}function $s(){clearInterval(Et)}var Fn=Ko(function(t,e,s,i){if(!!e.scroll){var n=(t.touches?t.touches[0]:t).clientX,o=(t.touches?t.touches[0]:t).clientY,a=e.scrollSensitivity,l=e.scrollSpeed,f=Me(),d=!1,m;$n!==s&&($n=s,en(),xt=e.scroll,m=e.scrollFn,xt===!0&&(xt=Ke(s,!0)));var p=0,y=xt;do{var _=y,v=ie(_),x=v.top,R=v.bottom,q=v.left,S=v.right,k=v.width,z=v.height,le=void 0,Y=void 0,K=_.scrollWidth,Re=_.scrollHeight,ce=N(_),Xe=_.scrollLeft,Ce=_.scrollTop;_===f?(le=k<K&&(ce.overflowX==="auto"||ce.overflowX==="scroll"||ce.overflowX==="visible"),Y=z<Re&&(ce.overflowY==="auto"||ce.overflowY==="scroll"||ce.overflowY==="visible")):(le=k<K&&(ce.overflowX==="auto"||ce.overflowX==="scroll"),Y=z<Re&&(ce.overflowY==="auto"||ce.overflowY==="scroll"));var He=le&&(Math.abs(S-n)<=a&&Xe+k<K)-(Math.abs(q-n)<=a&&!!Xe),fe=Y&&(Math.abs(R-o)<=a&&Ce+z<Re)-(Math.abs(x-o)<=a&&!!Ce);if(!oe[p])for(var qe=0;qe<=p;qe++)oe[qe]||(oe[qe]={});(oe[p].vx!=He||oe[p].vy!=fe||oe[p].el!==_)&&(oe[p].el=_,oe[p].vx=He,oe[p].vy=fe,clearInterval(oe[p].pid),(He!=0||fe!=0)&&(d=!0,oe[p].pid=setInterval(function(){i&&this.layer===0&&M.active._onTouchMove(cn);var Ne=oe[this.layer].vy?oe[this.layer].vy*l:0,Te=oe[this.layer].vx?oe[this.layer].vx*l:0;typeof m=="function"&&m.call(M.dragged.parentNode[we],Te,Ne,t,cn,oe[this.layer].el)!=="continue"||Zo(oe[this.layer].el,Te,Ne)}.bind({layer:p}),24))),p++}while(e.bubbleScroll&&y!==f&&(y=Ke(y,!1)));es=d}},30),ri=function(e){var s=e.originalEvent,i=e.putSortable,n=e.dragEl,o=e.activeSortable,a=e.dispatchSortableEvent,l=e.hideGhostForTarget,f=e.unhideGhostForTarget;if(!!s){var d=i||o;l();var m=s.changedTouches&&s.changedTouches.length?s.changedTouches[0]:s,p=document.elementFromPoint(m.clientX,m.clientY);f(),d&&!d.el.contains(p)&&(a("spill"),this.onSpill({dragEl:n,putSortable:i}))}};function hs(){}hs.prototype={startIndex:null,dragStart:function(e){var s=e.oldDraggableIndex;this.startIndex=s},onSpill:function(e){var s=e.dragEl,i=e.putSortable;this.sortable.captureAnimationState(),i&&i.captureAnimationState();var n=ht(this.sortable.el,this.startIndex,this.options);n?this.sortable.el.insertBefore(s,n):this.sortable.el.appendChild(s),this.sortable.animateAll(),i&&i.animateAll()},drop:ri};Le(hs,{pluginName:"revertOnSpill"});function ms(){}ms.prototype={onSpill:function(e){var s=e.dragEl,i=e.putSortable,n=i||this.sortable;n.captureAnimationState(),s.parentNode&&s.parentNode.removeChild(s),n.animateAll()},drop:ri};Le(ms,{pluginName:"removeOnSpill"});M.mount(new dm);M.mount(ms,hs);const um={name:"QuoteViewDetail",components:{Card:Ze,QuoteNavBar:ih,EditItemModal:Th,RemoveModal:qt,ArticleModal:zo},data(){return{selectedItem:null,selectedInvoiceId:null,editItemsModal:!1,no_items:!0,loading:!0,loading_add:!1,quote:[],quoteItems:[],newItem:{loading_del:!1,item_ref:"",item_name:"",item_category:"Type",item_description:"",quantity:1,vat_rate:0,unit_price:0,discount:0,total_price:0,total_amount:0},vatRate:0,settings:[],list_vats:[],client_detail:[],client_email:null,client_currency:"",default_vat:"",default_currency:"",default_currency_symbol:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},showArticlesModal:!1,articles:[],categories:[],showDropdown:!1,refs:[],showDropdownRef:!1}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},isQuoteExpired(){const t=new Date().getTime(),e=this.quote.due_date?new Date(this.quote.due_date).getTime():null;return e&&e<t},totalAmountWithoutDiscount(){const t=this.quoteItems.reduce((e,s)=>{const i=s.quantity*s.unit_price;return e+i},0);return this.formatCurrency(t)},totalAmount(){const t=this.quoteItems.reduce((e,s)=>e+parseFloat(s.total_price),0);return this.formatCurrency(t)},totalAmountDefaultCurrency(){return(this.quoteItems.reduce((i,n)=>i+parseFloat(n.total_amount),0)*this.quote.exchange_rate).toFixed(2)},totalAmountWithVAT(){const t=parseFloat(this.totalAmount);if(this.settings.vat_active==1){const e=parseFloat(this.calculateVAT());return this.formatCurrency(t+e)}else return this.formatCurrency(t)},signatureImageUrl(){const t="/wp-json/my-easy-compta/v1/signature-image/",e=myEasyComptaAdmin.nonce;return`${t}${this.quote.file_sign}?_wpnonce=${e}`}},methods:{getUniqueVATRates(){const t=new Set;return this.quoteItems.forEach(e=>{e.vat_rate&&t.add(e.vat_rate)}),Array.from(t)},calculateVATForRate(t){let e=0;return this.quoteItems.forEach(s=>{if(s.vat_rate===t){const i=s.quantity*s.unit_price,n=i*s.discount/100;e+=(i-n)*t/100}}),this.formatCurrency(e)},calculateTotalAmountWithVAT(){let t=this.quoteItems.reduce((e,s)=>e+parseFloat(s.total_amount),0);return this.formatCurrency(t)},fetchQuote(){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/${this.$route.params.id}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{t?(this.quote=t,this.fetchClientInfo(t.client_id)):console.error("Quote not found")}).catch(t=>{console.error("Error fetching quote:",t),this.loading=!1})},fetchClientInfo(t){fetch(`/wp-json/my-easy-compta/v1/clients/details/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Client not found");return e.json()}).then(e=>{this.client_detail=e,this.client_email=e.email;const s=e.currency_id;s&&this.fetchCurrencyDetails(s)}).catch(e=>{console.error("Error fetching client info:",e),this.loading=!1})},fetchItems(){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/${this.$route.params.id}/items`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{t.code=="no_items_found"?(console.error("No items found"),this.quoteItems=[],this.loading=!1,this.no_items=!0):(this.quoteItems=t,this.loading=!1,this.no_items=!1)}).catch(t=>{console.error("Error fetching items:",t),this.loading=!1})},fetchCurrencyDetails(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/settings/currency/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Currency details not found");return this.loading=!1,e.json()}).then(e=>{this.client_currency=e.symbol,this.loading=!1}).catch(e=>{this.loading=!1,console.error("Error fetching currency details:",e)})},updateTotal(){const t=this.newItem.quantity*this.newItem.unit_price,e=t*this.newItem.discount/100,s=t-e;var i=0;if(this.settings.vat_active==1){const n=s*this.newItem.vat_rate/100;i=s+n}else i=s;this.newItem.total_price=this.formatCurrency(s),this.newItem.total_amount=this.formatCurrency(i)},calculateTotalWithVat(t,e,s,i){const n=t*e,o=n*i/100,a=n-o,l=a*s/100,f=a+l;return this.formatCurrency(f)},calculateTotal(t,e,s){const i=t*e,n=i*s/100,a=i-n;return this.formatCurrency(a)},submitItems(){this.updateTotal();const t={...this.newItem,quote_id:this.$route.params.id};this.loading_add=!0,fetch("/wp-json/my-easy-compta/v1/quotes/element-add",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(t)}).then(e=>e.json()).then(e=>{e.success?(this.loading_add=!1,this.fetchItems(),this.newItem={item_name:"",item_ref:"",item_category:"",item_description:"",quantity:1,vat_rate:this.default_vat.rate,unit_price:0,discount:0,total_price:0,total_amount:0}):(this.showToast(e.message,"alert-error"),console.error("Error submitting item:",e.message),this.loading_add=!1)}).catch(e=>{this.showToast(e.message,"alert-error"),console.error("Error submitting item:",e),this.loading_add=!1})},increase(){this.newItem.quantity++},decrease(){this.newItem.quantity>1&&this.newItem.quantity--},confirmremoveItem(t,e){this.selectedItem=t,this.selectedInvoiceId=e,modal_item_remove.showModal(),this.showRemoveModal=!0},removeItem(t,e){const s=this.quoteItems.find(i=>i.id===t);s.loading_del=!0,fetch(`/wp-json/my-easy-compta/v1/quotes/element-delete/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({quote_id:e})}).then(i=>i.json()).then(i=>{i.success?(s.loading_del=!1,this.fetchItems()):(this.showToast(i.message,"alert-error"),console.error("Error removing item:",i.message),s.loading_del=!1)}).catch(i=>{this.showToast(i.message,"alert-error"),console.error("Error removing item:",i),s.loading_del=!1})},editItem(t){this.loadingModal=!0,this.editItemsModal=!0,modal_edit_item.showModal(),this.fetchItemDetails(t)},fetchItemDetails(t){fetch(`/wp-json/my-easy-compta/v1/quotes/item-details/${t}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{this.selectedItem=e,this.loading=!1}).catch(e=>{console.error("Error fetching item details:",e),this.loading=!1})},formatCurrency(t){const e=t.toFixed(2),s=this.client_currency!==this.default_currency_symbol?this.client_currency:this.default_currency_symbol;return`${e}${s}`},calculateDiscountAmountWithVAT(t,e,s,i){const o=t*e*i/100,a=o*s/100,l=o+a;return this.formatCurrency(l)},calculateDiscountAmount(t,e,s){const o=t*e*s/100;return this.formatCurrency(o)},calculateVAT(){const t=parseFloat(this.totalAmount),e=parseFloat(this.default_vat.rate),s=t*(e/100);return this.formatCurrency(s)},onDragEnd(t){const e=this.quoteItems[t.oldIndex];this.quoteItems.splice(t.oldIndex,1),this.quoteItems.splice(t.newIndex,0,e);const s=this.quoteItems.map(i=>i.id);this.saveOrderToDatabase(s)},nl2br(t){return t?t.replace(/\n/g,"<br>"):""},resize(){let t=this.$refs.textarea;t.style.height="auto",t.style.height=t.scrollHeight+"px"},saveOrderToDatabase(t){fetch("/wp-json/my-easy-compta/v1/quotes/update-quote-items-order",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({order:t})}).then(e=>{e.ok?console.log("Order saved successfully."):console.error("Failed to save order:",e.statusText)}).catch(e=>{console.error("Error saving order:",e)})},fetchCategoriesArticles(){fetch("/wp-json/my-easy-compta/v1/categories-articles",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.categories=t}).catch(t=>console.error("Error fetching categories:",t))},ShowModalArticles(){this.showArticlesModal=!0,modal_articles.showModal()},applySelectedArticle(t){this.newItem.item_ref=t.ref,this.newItem.item_name=t.name,this.newItem.item_description=t.description||"",this.newItem.unit_price=t.unit_price||0},fetchArticles(){if(this.newItem.item_name.length<1){this.articles=[];return}const t=document.getElementById("loader_articles");t.classList.remove("hidden"),fetch(`/wp-json/my-easy-compta/v1/articles?search=${this.newItem.item_name}&method=name`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{this.articles=e}).catch(e=>console.error("Error fetching articles:",e)).finally(()=>{t.classList.add("hidden")})},selectItem(t){this.newItem.item_ref=t.ref,this.newItem.item_name=t.name,this.newItem.item_description=t.description,this.newItem.unit_price=t.unit_price,this.showDropdown=!1,this.showDropdownRef=!1},fetchRefs(){if(this.newItem.item_ref.length<1){this.refs=[];return}fetch(`/wp-json/my-easy-compta/v1/articles?search=${this.newItem.item_ref}&method=ref`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.refs=t}).catch(t=>console.error("Error fetching refrences:",t))},async loadSettings(){try{this.loading=!0,this.loadingPrice=!0;const{settings:t,currencySymbol:e,vatData:s,listVatData:i}=await mn();this.settings=t,this.default_currency_symbol=e,this.default_vat=s,this.list_vats=i,this.newItem.vat_rate=this.default_vat.rate,this.loadingPrice=!1,this.loading=!1}catch(t){this.showToast(t.message,"alert-error"),this.loadingPrice=!1,this.loading=!1}},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},highlightMatch(t){if(!this.newItem.item_name)return t;const e=new RegExp(`(${this.escapeRegExp(this.newItem.item_name)})`,"gi");return t.replace(e,"<b>$1</b>")},escapeRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},handleClickOutside(t){this.$el.contains(t.target)||(this.showDropdown=!1,this.showDropdownRef=!1)}},beforeDestroy(){document.removeEventListener("click",this.handleClickOutside)},mounted(){this.fetchQuote(),this.fetchItems(),this.loadSettings(),this.fetchCategoriesArticles(),document.addEventListener("click",this.handleClickOutside);const t=document.querySelector("tbody");M.create(t,{animation:150,handle:".drag-handle",onEnd:this.onDragEnd})}},hm={class:"pt-2 pr-4"},mm={key:1,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},fm=r("span",{class:"loading loading-spinner text-primary loading-lg"},null,-1),pm=[fm],_m={key:2},gm={role:"alert",class:"alert alert-warning"},ym=r("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6 shrink-0 stroke-current",fill:"none",viewBox:"0 0 24 24"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})],-1),bm={key:0,class:"relative"},vm={class:"ecwp-watermark"},wm={class:"grid grid-cols-2"},xm={class:"md:col-span-1"},Em=["src"],Cm={class:"md:col-span-1 text-right"},Tm={class:"text-lg font-semibold"},Im={key:0,class:"badge badge-warning text-white"},km={key:1,class:"badge badge-secondary text-white"},Am={key:2,class:"badge badge-success text-white"},Sm={key:3,class:"badge badge-error text-white"},Dm={class:"bg-base-300 rounded-lg shadow-md flex justify-between p-4 mt-4 gap-4"},Pm=r("br",null,null,-1),Rm=r("br",null,null,-1),jm=r("br",null,null,-1),Mm=["href"],Om=r("br",null,null,-1),qm=r("br",null,null,-1),Nm=r("br",null,null,-1),Bm=["href"],Vm=r("br",null,null,-1),Fm=["href"],Um={class:"table mt-8"},Lm=r("th",null,null,-1),Wm={width:"5%"},Xm={width:"19%"},Hm={width:"21%"},zm={width:"10%",class:"text-center"},Qm={width:"8%",class:"text-center"},Gm={key:0,width:"5%",class:"text-center"},Jm={key:1,width:"5%"},Ym={width:"10%",class:"text-center"},Km={width:"10%",class:"text-right"},Zm=r("th",{width:"18%",class:"text-right inv-actions"},null,-1),$m=r("td",{class:"draggable-item drag-handle px-2"},[r("i",{class:"fas fa-sort"})],-1),ef={key:0,class:"badge badge-ghost badge-xs"},tf=["innerHTML"],nf={class:"text-center"},sf={class:"text-center"},of={key:0},rf={key:1},af={key:0,class:"text-center"},lf={key:1},cf={key:2,class:"text-center"},df=r("br",null,null,-1),uf={key:3,class:"text-center"},hf=r("br",null,null,-1),mf={class:"text-right"},ff={key:0},pf={key:1},_f=["data-tip"],gf=["onClick"],yf=r("i",{class:"far fa-edit"},null,-1),bf=[yf],vf=["data-tip"],wf=["onClick"],xf={key:0,class:"far fa-trash-alt"},Ef={key:1,class:"loading loading-spinner loading-xs"},Cf={key:0},Tf={class:"align-top px-2"},If=r("i",{class:"fas fa-list-ul"},null,-1),kf=[If],Af={class:"align-top px-2"},Sf={class:"flex items-center border rounded-md relative"},Df=["placeholder"],Pf={key:0,class:"autocomplete-dropdown bg-base-300"},Rf=["onClick","innerHTML"],jf={class:"align-top px-2"},Mf=r("option",{disabled:"",selected:""},"Type",-1),Of=["value"],qf={class:"flex items-center border rounded-md relative"},Nf=r("span",{id:"loader_articles",class:"loading loading-spinner loading-xs absolute right-2 hidden"},null,-1),Bf=["placeholder"],Vf={key:0,class:"autocomplete-dropdown bg-base-300"},Ff=["onClick","innerHTML"],Uf={class:"align-top"},Lf={class:"flex items-center rounded-md"},Wf=["placeholder"],Xf={class:"align-top"},Hf={class:"flex items-center border rounded-lg"},zf={class:"inline-flex"},Qf=["placeholder"],Gf={class:"align-top"},Jf={class:"flex items-center border rounded-md"},Yf=["placeholder"],Kf={key:0,class:"align-top"},Zf=["value"],$f={key:1,class:"align-top"},ep={class:"align-top"},tp={class:"flex items-center border rounded-md"},np=["placeholder"],sp=r("div",{class:"px-3 py-2.5 rounded-l-md bg-base-300 border-r"}," % ",-1),op={key:2,class:"text-right"},ip={key:3,class:"text-right"},rp=["data-tip"],ap={type:"submit",class:"bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded"},lp={key:0,class:"fa fa-plus"},cp={key:1,class:"loading loading-spinner loading-xs"},dp={colspan:"8",class:"text-right no-border"},up={class:"text-right"},hp={key:0,class:"line-through"},mp=r("td",null,null,-1),fp={colspan:"8",class:"text-right no-border"},pp={class:"text-right"},_p=r("td",null,null,-1),gp={colspan:"8",class:"text-right no-border font-bold text-xl"},yp={class:"text-right no-border font-bold text-xl"},bp=r("td",null,null,-1),vp={key:2},wp={colspan:"8",class:"text-right no-border"},xp={class:"text-right no-border"},Ep={key:3},Cp={colspan:"8",class:"text-right no-border"},Tp={class:"text-right no-border font-bold text-xl"},Ip={key:1,class:"relative"},kp={class:"flex justify-end mt-4"},Ap={class:"border-2 border-slate-300 max-w-md"},Sp=["src"];function Dp(t,e,s,i,n,o){const a=O("QuoteNavBar"),l=O("remove-modal"),f=O("article-modal"),d=O("edit-item-modal"),m=O("Card");return u(),h("div",hm,[P(a,{quoteInfo:n.quote,emailActive:n.settings.easy_compta_email_addon_active,advanceActive:n.settings.easy_compta_advance_addon_active,currency:n.default_currency_symbol,noItems:n.no_items},null,8,["quoteInfo","emailActive","advanceActive","currency","noItems"]),n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),P(l,{"modal-id":"modal_item_remove","show-modal":t.showRemoveModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:e[0]||(e[0]=p=>this.removeItem(n.selectedItem,n.selectedInvoiceId)),onCancel:e[1]||(e[1]=p=>t.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),P(f,{"show-modal":n.showArticlesModal,"modal-id":"modal_articles","modal-title":o.translations.select,onSelectArticle:o.applySelectedArticle,onClose:e[2]||(e[2]=p=>n.showArticlesModal=!1)},null,8,["show-modal","modal-title","onSelectArticle"]),n.loading?(u(),h("div",mm,pm)):g("",!0),o.isQuoteExpired&&n.quote.status=="pending"?(u(),h("div",_m,[r("div",gm,[ym,r("span",null,c(o.translations.quote_expired),1)])])):g("",!0),P(m,{topMargin:"mt-8",id:"quote-content"},{default:me(()=>[n.settings.easy_compta_signature_addon_active&&n.quote.signed==1?(u(),h("div",bm,[r("span",vm,c(o.translations.signed),1)])):g("",!0),r("div",wm,[r("div",xm,[r("div",null,[r("img",{src:n.settings.logo_url,style:no({width:n.settings.logo_width+"px"}),alt:"Logo"},null,12,Em)])]),r("div",Cm,[r("p",Tm,c(n.quote.quote_number),1),r("div",null,[C(c(o.translations.created_at)+": ",1),r("strong",null,c(n.quote.created_at),1)]),r("div",null,[C(c(o.translations.due_date)+": ",1),r("strong",null,c(n.quote.due_date),1)]),r("div",null,[C(c(o.translations.provisional_date)+": ",1),r("strong",null,c(n.quote.provisional_start_date),1)]),r("div",null,[C(c(o.translations.status)+": ",1),n.quote.status=="draft"?(u(),h("span",Im,c(o.translations.draft),1)):g("",!0),n.quote.status=="pending"?(u(),h("span",km,c(o.translations.pending),1)):g("",!0),n.quote.status=="approved"?(u(),h("span",Am,c(o.translations.approved),1)):g("",!0),n.quote.status=="rejected"?(u(),h("span",Sm,c(o.translations.rejected),1)):g("",!0)])])]),r("div",Dm,[r("div",null,[r("strong",null,c(o.translations.bill_to)+":",1),r("h4",null,[r("strong",null,c(n.client_detail.company_name),1)]),r("p",null,[C(c(n.client_detail.address),1),Pm,C(" "+c(n.client_detail.postal_code)+", "+c(n.client_detail.city)+" ",1),Rm,C(" "+c(n.client_detail.country),1),jm,n.client_detail.phone?(u(),h("a",{key:0,href:"tel:"+n.client_detail.phone},c(n.client_detail.phone),9,Mm)):g("",!0)])]),r("div",null,[r("strong",null,c(o.translations.received_from)+":",1),r("h4",null,[r("strong",null,c(n.settings.company_name),1)]),r("p",null,[C(c(n.settings.company_address),1),Om,C(" "+c(n.settings.postal_code)+", "+c(n.settings.city)+" ",1),qm,C(" "+c(n.settings.country),1),Nm,n.settings.company_phone?(u(),h("a",{key:0,href:"tel:"+n.settings.company_phone},c(n.settings.company_phone),9,Bm)):g("",!0),Vm,n.settings.mobile_phone?(u(),h("a",{key:1,href:"tel:"+n.settings.mobile_phone},c(n.settings.mobile_phone),9,Fm)):g("",!0)])])]),P(d,{loading:t.loadingModal,"show-modal":n.editItemsModal,"modal-id":"modal_edit_item","modal-title":o.translations.edit_item,item:n.selectedItem,onClose:e[3]||(e[3]=p=>n.editItemsModal=!1),onItemEdited:o.fetchItems},null,8,["loading","show-modal","modal-title","item","onItemEdited"]),r("form",{onSubmit:e[24]||(e[24]=J((...p)=>o.submitItems&&o.submitItems(...p),["prevent"]))},[r("table",Um,[r("thead",null,[r("tr",null,[Lm,r("th",Wm,c(o.translations.item_ref),1),r("th",Xm,c(o.translations.item_name),1),r("th",Hm,c(o.translations.description),1),r("th",zm,c(o.translations.quantity),1),r("th",Qm,c(o.translations.unit_price),1),n.settings.vat_active==1?(u(),h("th",Gm,c(o.translations.vat),1)):(u(),h("th",Jm)),r("th",Ym,c(o.translations.discount),1),r("th",Km,c(o.translations.total),1),Zm])]),r("tbody",null,[(u(!0),h(F,null,U(n.quoteItems,(p,y)=>(u(),h("tr",{key:p.id||y},[$m,r("td",null,c(p.item_ref),1),r("td",null,[p.category_name?(u(),h("div",ef,c(p.category_name),1)):g("",!0),r("div",null,c(p.item_name),1)]),r("td",{innerHTML:o.nl2br(p.item_description)},null,8,tf),r("td",nf,c(p.quantity),1),r("td",sf,[C(c(p.unit_price),1),n.default_currency_symbol==n.client_currency?(u(),h("span",of,c(n.default_currency_symbol),1)):(u(),h("span",rf,c(n.client_currency),1))]),n.settings.vat_active==1?(u(),h("td",af,c(p.vat_rate)+"% ",1)):(u(),h("td",lf)),n.settings.vat_active==1?(u(),h("td",cf,[C(c(p.discount)+"% ",1),df,C(" "+c(o.calculateDiscountAmountWithVAT(p.quantity,p.unit_price,p.vat_rate,p.discount)),1)])):(u(),h("td",uf,[C(c(p.discount)+"% ",1),hf,C(" "+c(o.calculateDiscountAmount(p.quantity,p.unit_price,p.discount)),1)])),r("td",mf,[C(c(p.total_amount)+" ",1),n.default_currency_symbol==n.client_currency?(u(),h("span",ff,c(n.default_currency_symbol),1)):(u(),h("span",pf,c(n.client_currency),1))]),r("td",null,[n.quote.status=="draft"||n.quote.status=="pending"?(u(),h("span",{key:0,class:"lg:tooltip","data-tip":o.translations.edit},[r("button",{onClick:J(_=>o.editItem(p.id),["prevent"]),class:"bg-purple-500 hover:bg-purple-700 text-white font-bold py-2 px-3 rounded"},bf,8,gf)],8,_f)):g("",!0),n.quote.status=="draft"||n.quote.status=="pending"?(u(),h("span",{key:1,class:"lg:tooltip","data-tip":o.translations.delete},[r("button",{onClick:J(_=>o.confirmremoveItem(p.id,n.quote.id),["prevent"]),class:"bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-3 mx-2 rounded"},[p.loading_del?g("",!0):(u(),h("i",xf)),p.loading_del?(u(),h("span",Ef)):g("",!0)],8,wf)],8,vf)):g("",!0)])]))),128)),n.quote.status=="draft"||n.quote.status=="pending"?(u(),h("tr",Cf,[r("td",Tf,[r("span",{class:"cursor-pointer",onClick:e[4]||(e[4]=J((...p)=>o.ShowModalArticles&&o.ShowModalArticles(...p),["prevent"]))},kf)]),r("td",Af,[r("div",Sf,[D(r("input",{type:"text","onUpdate:modelValue":e[5]||(e[5]=p=>n.newItem.item_ref=p),onInput:e[6]||(e[6]=(...p)=>o.fetchRefs&&o.fetchRefs(...p)),onFocus:e[7]||(e[7]=p=>n.showDropdownRef=!0),placeholder:o.translations.item_ref,class:"w-full p-2.5 bg-transparent input-xs outline-none"},null,40,Df),[[W,n.newItem.item_ref]]),n.showDropdownRef&&n.refs.length?(u(),h("ul",Pf,[(u(!0),h(F,null,U(n.refs,p=>(u(),h("li",{key:p.ref,onClick:y=>o.selectItem(p),class:"autocomplete-item hover:bg-base-200",innerHTML:o.highlightMatch(p.ref)},null,8,Rf))),128))])):g("",!0)])]),r("td",jf,[D(r("select",{class:"select select-xs w-full mb-1 ecwp-select","onUpdate:modelValue":e[8]||(e[8]=p=>n.newItem.item_category=p)},[Mf,(u(!0),h(F,null,U(n.categories,p=>(u(),h("option",{key:p.id,value:p.id},c(p.name),9,Of))),128))],512),[[ue,n.newItem.item_category]]),r("div",qf,[Nf,D(r("input",{type:"text","onUpdate:modelValue":e[9]||(e[9]=p=>n.newItem.item_name=p),onInput:e[10]||(e[10]=(...p)=>o.fetchArticles&&o.fetchArticles(...p)),onFocus:e[11]||(e[11]=p=>n.showDropdown=!0),placeholder:o.translations.item_name,class:"w-full p-2.5 bg-transparent input-xs outline-none"},null,40,Bf),[[W,n.newItem.item_name]]),n.showDropdown&&n.articles.length?(u(),h("ul",Vf,[(u(!0),h(F,null,U(n.articles,p=>(u(),h("li",{key:p.name,onClick:y=>o.selectItem(p),class:"autocomplete-item hover:bg-base-200",innerHTML:o.highlightMatch(p.name)},null,8,Ff))),128))])):g("",!0)])]),r("td",Uf,[r("div",Lf,[D(r("textarea",{"onUpdate:modelValue":e[12]||(e[12]=p=>n.newItem.item_description=p),placeholder:o.translations.item_description,class:"textarea textarea-bordered input-xs w-full",onInput:e[13]||(e[13]=p=>o.resize()),ref:"textarea"},null,40,Wf),[[W,n.newItem.item_description]])])]),r("td",Xf,[r("div",Hf,[r("div",zf,[r("div",{class:"select-none border py-3 px-2 cursor-pointer bg-base-300 hover:bg-gray-200 rounded-l",onClick:e[14]||(e[14]=(...p)=>o.decrease&&o.decrease(...p))}," - "),D(r("input",{type:"text",pattern:"([0-9]+.{0,1}[0-9]*,{0,1})*[0-9]","onUpdate:modelValue":e[15]||(e[15]=p=>n.newItem.quantity=p),placeholder:o.translations.quantity,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[16]||(e[16]=(...p)=>o.updateTotal&&o.updateTotal(...p))},null,40,Qf),[[W,n.newItem.quantity]]),r("div",{class:"select-none border py-3 px-2 cursor-pointer bg-base-300 hover:bg-gray-200 rounded-r",onClick:e[17]||(e[17]=(...p)=>o.increase&&o.increase(...p))}," + ")])])]),r("td",Gf,[r("div",Jf,[D(r("input",{type:"text",pattern:"([0-9]+.{0,1}[0-9]*,{0,1})*[0-9]","onUpdate:modelValue":e[18]||(e[18]=p=>n.newItem.unit_price=p),placeholder:o.translations.unit_price,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[19]||(e[19]=(...p)=>o.updateTotal&&o.updateTotal(...p))},null,40,Yf),[[W,n.newItem.unit_price]])])]),n.settings.vat_active==1?(u(),h("td",Kf,[D(r("select",{"onUpdate:modelValue":e[20]||(e[20]=p=>n.newItem.vat_rate=p),onChange:e[21]||(e[21]=(...p)=>o.updateTotal&&o.updateTotal(...p)),class:"select select-md w-full mb-1 ecwp-select min-w-20"},[(u(!0),h(F,null,U(n.list_vats,p=>(u(),h("option",{key:p,value:p.rate},c(p.rate)+"% ",9,Zf))),128))],544),[[ue,n.newItem.vat_rate]])])):(u(),h("td",$f)),r("td",ep,[r("div",tp,[D(r("input",{type:"number",min:"0",max:"100","onUpdate:modelValue":e[22]||(e[22]=p=>n.newItem.discount=p),placeholder:o.translations.discount,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[23]||(e[23]=(...p)=>o.updateTotal&&o.updateTotal(...p))},null,40,np),[[W,n.newItem.discount]]),sp])]),n.settings.vat_active==1?(u(),h("td",op,c(o.calculateTotalWithVat(n.newItem.quantity,n.newItem.unit_price,n.newItem.vat_rate,n.newItem.discount)),1)):(u(),h("td",ip,c(o.calculateTotal(n.newItem.quantity,n.newItem.unit_price,n.newItem.discount)),1)),r("td",null,[r("span",{class:"lg:tooltip","data-tip":o.translations.add},[r("button",ap,[n.loading_add?g("",!0):(u(),h("i",lp)),n.loading_add?(u(),h("span",cp)):g("",!0)])],8,rp)])])):g("",!0),r("tr",null,[r("td",dp,[r("strong",null,c(o.translations.subtotal),1)]),r("td",up,[o.totalAmount!==o.totalAmountWithoutDiscount?(u(),h("span",hp,c(o.totalAmountWithoutDiscount),1)):g("",!0),C(" "+c(o.totalAmount),1)]),mp]),n.settings.vat_active==1?(u(!0),h(F,{key:1},U(o.getUniqueVATRates(),(p,y)=>(u(),h("tr",{key:y},[r("td",fp,[r("strong",null,c(o.translations.tax)+" ("+c(p)+"%) ",1)]),r("td",pp,c(o.calculateVATForRate(p)),1),_p]))),128)):g("",!0),r("tr",null,[r("td",gp,[r("strong",null,c(o.translations.total),1)]),r("td",yp,c(o.calculateTotalAmountWithVAT()),1),bp]),n.client_currency!=n.default_currency_symbol?(u(),h("tr",vp,[r("td",wp,[r("strong",null,c(o.translations.exchange_rate),1)]),r("td",xp,c(n.quote.exchange_rate),1)])):g("",!0),n.client_currency!=n.default_currency_symbol?(u(),h("tr",Ep,[r("td",Cp,[r("strong",null,c(o.translations.total)+" "+c(n.default_currency_symbol),1)]),r("td",Tp,c(o.totalAmountDefaultCurrency)+c(n.default_currency_symbol),1)])):g("",!0)])])],32),n.settings.easy_compta_signature_addon_active&&n.quote.signed==1&&n.quote.file_sign?(u(),h("div",Ip,[r("div",kp,[r("span",Ap,[r("img",{src:o.signatureImageUrl,alt:"Signature"},null,8,Sp)])])])):g("",!0)]),_:1})])}var Pp=ne(um,[["render",Dp]]);const Rp={name:"QuoteNew",components:{Card:Ze,ModelSelect:hn,VueDatePicker:Nt,AddClientModal:Ro},data(){return{clientOptions:[],clients:[],quote:{number:"",due_date:"",provisional_start_date:"",client_id:"",status:""},showError:!1,loading:!1,loadingBtn:!1,settings:[],last_quote_number:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return t=>{if(!t)return"";const e=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getFullYear();return`${e}-${s}-${i}`}}},mounted(){this.fetchClients(),this.fetchSettings()},methods:{AddNew(){modal_clients.showModal()},cancelAction(){this.$router.push("/quotes")},fetchClients(){this.loading=!0,fetch("/wp-json/my-easy-compta/v1/list-clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.clients=t.clients,this.clientOptions=this.clients.map(e=>({value:e.id,text:`${e.company_name} - ${e.email} (${e.currency_symbol})`}))}).catch(t=>{console.error("Error fetching clients:",t)}).finally(()=>{this.loading=!1})},customLabel(t){return t.text},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,t.ok){const e=await t.json();this.settings=e;const s=`${this.settings.quote_prefix}_${String(this.settings.last_quote_id).padStart(4,"0")}`;this.quote.number=s}else{const e=await t.json()}}catch{this.loading=!1}},submitQuote(){if(!this.quote.due_date||!this.quote.provisional_start_date||!this.quote.client_id||!this.quote.status){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.loadingBtn=!0,fetch("/wp-json/my-easy-compta/v1/quotes",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.quote)}).then(t=>{if(!t.ok)throw this.loadingBtn=!1,new Error("Network response was not ok");return t.json()}).then(t=>{t.success?(this.loadingBtn=!1,this.showToast(t.message,"alert-success"),this.$router.push({name:"QuoteViewDetail",params:{id:t.id}})):(this.loadingBtn=!1,console.error("Error submitting quote:",t.message),this.showToast(t.message,"alert-error"))}).catch(t=>{this.loadingBtn=!1,console.error("Error submitting quote:",t),this.showToast(t,"alert-error")})},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},jp={class:"pt-2 pr-4"},Mp={class:"flex justify-between items-center mb-4"},Op={class:"card-title"},qp=r("div",{class:"divider mt-2"},null,-1),Np={key:0,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},Bp={class:"grid grid-cols-3 gap-4"},Vp={class:"ecwp-group form-group mb-4"},Fp={for:"quoteNumber",class:"ecwp-label"},Up={class:"ecwp-group form-group mb-4"},Lp={for:"quoteDate",class:"ecwp-label"},Wp={class:"ecwp-group form-group mb-4"},Xp={for:"quoteDatePr",class:"ecwp-label"},Hp={class:"grid grid-cols-2 gap-4"},zp={class:"mb-4"},Qp={class:"flex gap-2 items-end"},Gp=r("i",{class:"fas fa-plus"},null,-1),Jp=[Gp],Yp={class:"ecwp-group form-group w-full"},Kp={for:"client",class:"ecwp-label"},Zp={class:"ecwp-group form-group mb-4"},$p={for:"status",class:"ecwp-label"},e_={value:"draft",selected:""},t_={value:"pending"},n_={value:"approved"},s_={value:"rejected"},o_={class:"flex justify-between"},i_=["disabled"],r_={key:0,class:"loading loading-spinner loading-sm"};function a_(t,e,s,i,n,o){const a=O("VueDatePicker"),l=O("model-select"),f=O("Card"),d=O("AddClientModal");return u(),h("div",jp,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),P(f,{topMargin:"mt-8",modalType:"modal_quote_new"},{default:me(()=>[r("div",Mp,[r("h2",Op,c(o.translations.new_quote),1)]),qp,n.loading?(u(),h("div",Np)):g("",!0),r("form",{onSubmit:e[7]||(e[7]=J((...m)=>o.submitQuote&&o.submitQuote(...m),["prevent"]))},[r("div",Bp,[r("div",Vp,[r("label",Fp,c(o.translations.quote_number),1),D(r("input",{type:"text",id:"quoteNumber","onUpdate:modelValue":e[0]||(e[0]=m=>n.quote.number=m),class:"ecwp-input input input-bordered w-full",disabled:"disabled"},null,512),[[W,n.quote.number]])]),r("div",Up,[r("label",Lp,c(o.translations.due_date),1),P(a,{class:I(["ecwp-input ecwp-date input input-bordered w-full",[!n.quote.due_date&&n.showError?"input-error":""]]),id:"quoteDate",modelValue:n.quote.due_date,"onUpdate:modelValue":e[1]||(e[1]=m=>n.quote.due_date=m),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date,locale:"fr"},null,8,["class","modelValue","format","min-date"])]),r("div",Wp,[r("label",Xp,c(o.translations.provisional_date),1),P(a,{class:I(["ecwp-input ecwp-date input input-bordered w-full",[!n.quote.provisional_start_date&&n.showError?"input-error":""]]),id:"quoteDatePr",modelValue:n.quote.provisional_start_date,"onUpdate:modelValue":e[2]||(e[2]=m=>n.quote.provisional_start_date=m),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date,locale:"fr"},null,8,["class","modelValue","format","min-date"])])]),r("div",Hp,[r("div",zp,[r("div",Qp,[r("button",{type:"button",class:"btn btn-primary",onClick:e[3]||(e[3]=(...m)=>o.AddNew&&o.AddNew(...m))},Jp),r("div",Yp,[r("label",Kp,c(o.translations.company_name),1),P(l,{modelValue:n.quote.client_id,"onUpdate:modelValue":e[4]||(e[4]=m=>n.quote.client_id=m),options:n.clientOptions,label:"text","track-by":"value",placeholder:o.translations.select,class:I(["ecwp-input input input-bordered w-full",[!n.quote.client_id&&n.showError?"input-error":""]])},null,8,["modelValue","options","placeholder","class"])])])]),r("div",Zp,[r("label",$p,c(o.translations.status),1),D(r("select",{id:"status","onUpdate:modelValue":e[5]||(e[5]=m=>n.quote.status=m),class:I(["ecwp-input select select-bordered w-full",[!n.quote.status&&n.showError?"input-error":""]])},[r("option",e_,c(o.translations.draft),1),r("option",t_,c(o.translations.pending),1),r("option",n_,c(o.translations.approved),1),r("option",s_,c(o.translations.rejected),1)],2),[[ue,n.quote.status]])])]),r("div",o_,[r("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:e[6]||(e[6]=(...m)=>o.cancelAction&&o.cancelAction(...m))},c(o.translations.cancel),1),r("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(c(o.translations.submit)+" ",1),n.loadingBtn?(u(),h("span",r_)):g("",!0)],8,i_)])],32)]),_:1}),P(d,{onClientAdded:o.fetchClients},null,8,["onClientAdded"])])}var l_=ne(Rp,[["render",a_]]);const c_={name:"InvoicesList",components:{Card:Ze,RemoveModal:qt},data(){return{invoices:[],filteredInvoices:[],filters:{invoice_number:"",client:"",status:"",total_amount:"",due_date:"",created_at:""},showInvoiceDetailsModal:!1,editInvoiceModal:!1,selectedInvoice:null,currentPage:1,totalCount:0,totalPages:1,paginationButtons:[],loading:!0,loadingPrice:!0,loadingModal:!1,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],client_currency:"",default_vat:"",default_currency:"",default_currency_symbol:"",settings:{},toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},created(){this.fetchInvoices(),this.fetchClients(),this.loadSettings()},methods:{fetchInvoices(t=1){this.loading=!0;const{perPage:e}=this;fetch(`/wp-json/my-easy-compta/v1/invoices?page=${t}&per_page=${e}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>s.json()).then(s=>{this.invoices=s.invoices,this.totalCount=s.total_count,this.totalPages=s.total_pages,this.currentPage=t,this.perPage=e,this.generatePaginationButtons()}).catch(s=>{console.error("Error fetching invoices:",s)}).finally(()=>{this.loading=!1})},fetchInvoicesWithFilters(t=1){this.loading=!0;const{perPage:e,filters:s}=this,i=new URLSearchParams({page:t,per_page:e,...s}).toString();fetch(`/wp-json/my-easy-compta/v1/invoices?${i}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(n=>n.json()).then(n=>{this.invoices=n.invoices,this.totalCount=n.total_count,this.totalPages=n.total_pages,this.currentPage=t,this.perPage=e,this.generatePaginationButtons()}).catch(n=>{console.error("Error fetching invoices with filters:",n)}).finally(()=>{this.loading=!1})},fetchClients(){fetch("/wp-json/my-easy-compta/v1/clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.clients=t.clients}).catch(t=>{console.error("Error fetching clients:",t)})},async loadSettings(){try{this.loadingPrice=!0;const{settings:t,currencySymbol:e,vatData:s}=await mn();this.settings=t,this.default_currency_symbol=e,this.default_vat=s,this.loadingPrice=!1}catch(t){this.showToast(t.message,"alert-error"),this.loadingPrice=!1}},calculateVAT(t){return so(t,this.default_vat.rate)},calculateWithoutVAT(t){return oo(t)},generatePaginationButtons(){this.paginationButtons=io(this.currentPage,this.totalPages)},goToPage(t){t!=="..."&&this.fetchInvoicesWithFilters(t)},perPageChanged(){this.fetchInvoicesWithFilters()},formatAmount(t,e){return ro(t,e,this.settings.currency_position)},showToast(t,e){ao(this.toast,t,e)},confirmDeleteInvoice(t){this.selectedInvoice=t,modal_invoice_remove.showModal(),this.showRemoveModal=!0},deleteInvoice(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/delete/${t}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Network response was not ok");return e.json()}).then(e=>{e.success?(this.fetchInvoices(),this.showToast(e.message,"alert-success")):(this.showToast(e.message,"alert-error"),console.error("Error deleting invoice:",e.statusText))}).catch(e=>{console.log(e.message);const s=e&&e.message?e.message:"Error deleting client";s==="This client cannot be deleted because it has associated data."?this.showToast(s,"alert-error"):console.error("Error deleting client:",e)})}},computed:{skeletonItems(){return Array.from({length:5},(t,e)=>e)},totalPages(){return Math.ceil(this.totalCount/this.perPage)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},d_={class:"pt-2 pr-4"},u_={class:"flex justify-between items-center"},h_={class:"card-title"},m_={class:"btn btn-primary rounded-full"},f_=r("i",{class:"fas fa-plus-circle"},null,-1),p_={key:0,class:"ms-2"},__={class:"btn btn-outline btn-accent rounded-full hover:text-white",href:"/wp-admin/admin.php?page=my-easy-compta-export#tab3"},g_=r("i",{class:"fas fa-file-export"},null,-1),y_=["data-tip"],b_={class:"btn btn-outline btn-accent rounded-full",disabled:""},v_=r("i",{class:"fas fa-file-export"},null,-1),w_=r("div",{class:"divider mt-2"},null,-1),x_={class:"flex items-center mb-4"},E_={for:"perPageSelect",class:"mr-2"},C_=["value"],T_={class:"overflow-x-auto"},I_={class:"table w-full"},k_={value:""},A_=["value"],S_={value:""},D_={value:"draft"},P_={value:"unpaid"},R_={value:"paid"},j_={class:"flex justify-center"},M_={key:0},O_={key:0,class:"badge badge-primary badge-outline badge-sm mr-2"},q_={key:0,class:"badge badge-scondary badge-outline badge-sm"},N_={key:1,class:"badge badge-warning badge-outline badge-sm"},B_={key:2,class:"badge badge-success badge-outline badge-sm"},V_={key:3,class:"badge badge-error badge-outline badge-sm ms-2"},F_={key:0},U_={key:0},L_={key:0},W_={key:1},X_={key:0},H_={key:1},z_={key:1},Q_=r("span",{class:"loading loading-bars loading-sm"},null,-1),G_=[Q_],J_={key:0},Y_={key:1},K_=r("span",{class:"loading loading-bars loading-sm"},null,-1),Z_=[K_],$_={key:0},eg={key:1},tg=r("span",{class:"loading loading-bars loading-sm"},null,-1),ng=[tg],sg={class:"flex justify-end"},og=["data-tip"],ig=r("button",{class:"btn btn-circle mx-1"},[r("i",{class:"far fa-eye"})],-1),rg=["data-tip"],ag=r("button",{class:"btn btn-circle mx-1"},[r("i",{class:"fas fa-pencil-alt"})],-1),lg=["data-tip"],cg=["onClick"],dg=r("i",{class:"far fa-trash-alt"},null,-1),ug=[dg],hg={key:0},mg=r("div",{class:"flex gap-4 items-center"},[r("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),r("div",{class:"flex flex-col gap-4 w-full"},[r("div",{class:"skeleton h-4 w-full"}),r("div",{class:"skeleton h-4 w-full"})])],-1),fg=r("div",{class:"divider my-1"},null,-1),pg=[mg,fg],_g={class:"join ecwp_pagination mt-6 pt-4"},gg=["onClick"];function yg(t,e,s,i,n,o){const a=O("remove-modal"),l=O("router-link"),f=O("Card");return u(),h("div",d_,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),P(a,{"modal-id":"modal_invoice_remove","show-modal":t.showRemoveModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:e[0]||(e[0]=d=>this.deleteInvoice(n.selectedInvoice)),onCancel:e[1]||(e[1]=d=>t.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),P(f,{topMargin:"mt-8"},{default:me(()=>[r("div",u_,[r("h2",h_,c(o.translations.invoices),1),r("div",null,[P(l,{to:{name:"InvoiceNew"}},{default:me(()=>[r("button",m_,[C(c(o.translations.add)+" ",1),f_])]),_:1}),n.settings.easy_compta_export_addon_active==1?(u(),h("span",p_,[r("a",__,[C(c(o.translations.export)+" ",1),g_])])):(u(),h("span",{key:1,class:"tooltip tooltip-left tooltip-warning ms-2","data-tip":o.translations.active_export_addon},[r("button",b_,[C(c(o.translations.export)+" ",1),v_])],8,y_))])]),w_,r("div",x_,[r("label",E_,c(o.translations.display_per_page),1),D(r("select",{id:"perPageSelect","onUpdate:modelValue":e[2]||(e[2]=d=>n.perPage=d),onChange:e[3]||(e[3]=(...d)=>o.perPageChanged&&o.perPageChanged(...d))},[(u(!0),h(F,null,U(n.perPageOptions,d=>(u(),h("option",{key:d,value:d},c(d),9,C_))),128))],544),[[ue,n.perPage]])]),r("div",T_,[r("table",I_,[r("thead",null,[r("tr",null,[r("th",null,[r("div",null,c(o.translations.invoice_number),1),D(r("input",{"onUpdate:modelValue":e[4]||(e[4]=d=>n.filters.invoice_number=d),onInput:e[5]||(e[5]=d=>o.fetchInvoicesWithFilters()),type:"text",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[W,n.filters.invoice_number]])]),r("th",null,[r("div",null,c(o.translations.client),1),D(r("select",{"onUpdate:modelValue":e[6]||(e[6]=d=>n.filters.client=d),onChange:e[7]||(e[7]=d=>o.fetchInvoicesWithFilters()),class:"ecwp-input input-xs input-bordered mt-2"},[r("option",k_,c(o.translations.all),1),(u(!0),h(F,null,U(t.clients,d=>(u(),h("option",{key:d.id,value:d.company_name},c(d.company_name),9,A_))),128))],544),[[ue,n.filters.client]])]),r("th",null,[r("div",null,c(o.translations.status),1),D(r("select",{"onUpdate:modelValue":e[8]||(e[8]=d=>n.filters.status=d),onChange:e[9]||(e[9]=d=>o.fetchInvoicesWithFilters()),class:"ecwp-input input-xs input-bordered mt-2"},[r("option",S_,c(o.translations.all_statuses),1),r("option",D_,c(o.translations.draft),1),r("option",P_,c(o.translations.unpaid),1),r("option",R_,c(o.translations.paid),1)],544),[[ue,n.filters.status]])]),r("th",null,[r("div",null,c(o.translations.total),1),D(r("input",{"onUpdate:modelValue":e[10]||(e[10]=d=>n.filters.total_amount=d),onInput:e[11]||(e[11]=d=>o.fetchInvoicesWithFilters()),type:"text",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[W,n.filters.total_amount]])]),r("th",null,[r("div",null,c(o.translations.due_date),1),D(r("input",{"onUpdate:modelValue":e[12]||(e[12]=d=>n.filters.due_date=d),onInput:e[13]||(e[13]=d=>o.fetchInvoicesWithFilters()),type:"date",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[W,n.filters.due_date]])]),r("th",null,[r("div",null,c(o.translations.created_at),1),D(r("input",{"onUpdate:modelValue":e[14]||(e[14]=d=>n.filters.created_at=d),onInput:e[15]||(e[15]=d=>o.fetchInvoicesWithFilters()),type:"date",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[W,n.filters.created_at]])]),r("th",j_,c(o.translations.actions),1)])]),n.loading?g("",!0):(u(),h("tbody",M_,[(u(!0),h(F,null,U(n.invoices,d=>(u(),h("tr",{key:d.id},[r("td",null,[d.advance==1?(u(),h("span",O_,c(o.translations.advance),1)):g("",!0),C(c(d.invoice_number),1)]),r("td",null,c(d.client_name),1),r("td",null,[d.status=="draft"?(u(),h("span",q_,c(o.translations.draft),1)):g("",!0),d.status=="unpaid"?(u(),h("span",N_,c(o.translations.unpaid),1)):g("",!0),d.status=="paid"?(u(),h("span",B_,c(o.translations.paid),1)):g("",!0),d.credit=="1"?(u(),h("span",V_,c(o.translations.credit),1)):g("",!0)]),r("td",null,[n.loadingPrice?(u(),h("div",z_,G_)):(u(),h("div",F_,[n.settings.easy_compta_advance_addon_active&&d.advance==1?(u(),h("div",U_,c(o.formatAmount(d.advance_amount,d.client_currency||n.default_currency_symbol)),1)):g("",!0),n.settings.vat_active==1?(u(),h("div",{key:1,class:I({"text-xs":d.advance==1})},[n.default_currency_symbol==d.client_currency||d.client_currency==null?(u(),h("span",L_,c(o.formatAmount(d.total_amount,n.default_currency_symbol)),1)):(u(),h("span",W_,c(o.formatAmount(d.total_amount,d.client_currency)),1))],2)):(u(),h("div",{key:2,class:I({"text-xs":d.advance==1})},[n.default_currency_symbol==d.client_currency||d.client_currency==null?(u(),h("span",X_,c(o.formatAmount(d.total_amount,n.default_currency_symbol)),1)):(u(),h("span",H_,c(o.formatAmount(d.total_amount,d.client_currency)),1))],2))]))]),r("td",null,[n.loadingPrice?(u(),h("div",Y_,Z_)):(u(),h("div",J_,c(d.due_date),1))]),r("td",null,[n.loadingPrice?(u(),h("div",eg,ng)):(u(),h("div",$_,c(d.created),1))]),r("td",sg,[r("span",{class:"lg:tooltip","data-tip":o.translations.view},[P(l,{to:{name:"InvoiceViewDetail",params:{id:d.id}}},{default:me(()=>[ig]),_:2},1032,["to"])],8,og),d.status=="draft"?(u(),h("span",{key:0,class:"lg:tooltip","data-tip":o.translations.edit},[P(l,{to:{name:"InvoiceEdit",params:{id:d.id}}},{default:me(()=>[ag]),_:2},1032,["to"])],8,rg)):g("",!0),d.status=="draft"?(u(),h("span",{key:1,class:"lg:tooltip","data-tip":o.translations.delete},[r("button",{onClick:m=>o.confirmDeleteInvoice(d.id),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},ug,8,cg)],8,lg)):g("",!0)])]))),128))]))]),n.loading?(u(),h("div",hg,[(u(!0),h(F,null,U(n.skeletonRows,d=>(u(),h("div",{key:d,class:"flex flex-col gap-4 w-full"},pg))),128))])):g("",!0)]),r("div",_g,[(u(!0),h(F,null,U(n.paginationButtons,d=>(u(),h("button",{key:d,class:I(["join-item btn",{"btn-disabled":d==="..."||d===n.currentPage}]),onClick:m=>o.goToPage(d)},c(d),11,gg))),128))])]),_:1})])}var bg=ne(c_,[["render",yg]]);const vg={name:"sendInvoice",components:{VueEditor:mt.exports.VueEditor},props:{showModal:Boolean,modalId:String,client:Object,invoiceId:Number,loading:Boolean,subject:String,content:String},data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{loading:!1,loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},toolbarOptions:[["bold","italic","underline","strike"],["link"],[{list:"ordered"},{list:"bullet"}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{align:[]}],[{align:"right"},{align:"center"},{align:"justify"}],["clean"]],fields:{client_email:{label:t.client,value:"",disabled:!0},email_subject:{label:t.email_subject,value:""},email_message:{label:t.email_content,value:"",type:"textarea"}}}},watch:{client:{immediate:!0,handler(t){this.fields.client_email.value=(t==null?void 0:t.email)||""}},subject:{immediate:!0,handler(t){this.fields.email_subject.value=t||""}},content:{immediate:!0,handler(t){this.fields.email_message.value=t||""}}},computed:{skeletonItems(){return Array.from({length:10},(t,e)=>e)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const t=await fetch("/wp-json/my-easy-compta/v1/emails/send-email",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({type:"invoice",id:this.invoiceId,client_email:this.client.email,email_subject:this.fields.email_subject.value,email_message:this.fields.email_message.value})});if(t.ok){const e=await t.json();this.loadingBtn=!1,this.closeModal(),this.showToast(e.message,"alert-success")}else{const e=`Error sending email: ${t.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(t){const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Error sending email";this.showToast(e,"alert-error"),console.error("Error sending email:",t),this.loadingBtn=!1}},updateFieldValue(t,e){this.fields[t].value=e},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},wg=["id","open"],xg={class:"modal-box"},Eg={class:"font-bold text-lg"},Cg={key:0},Tg={class:"grid grid-cols-1 gap-4"},Ig=r("div",{class:"skeleton h-4 w-full mb-2"},null,-1),kg=r("div",{class:"skeleton h-4 w-full"},null,-1),Ag=[Ig,kg],Sg={class:"grid grid-cols-1 gap-4"},Dg=["type"],Pg=["for"],Rg=["id","value","disabled","onInput"],jg={key:1},Mg=["for"],Og={class:"form-group mt-4 flex justify-end"},qg=["disabled"],Ng={key:0,class:"loading loading-spinner loading-sm"};function Bg(t,e,s,i,n,o){const a=O("vue-editor");return u(),h("div",null,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),r("dialog",{id:s.modalId,class:"modal",open:s.showModal},[r("div",xg,[r("h3",Eg,c(o.translations.send_invoice),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=l=>o.closeModal())}," \u2715 "),n.loading?(u(),h("div",Cg,[r("div",Tg,[(u(!0),h(F,null,U(o.skeletonItems,l=>(u(),h("div",{key:l,class:"py-2"},Ag))),128))])])):(u(),h("form",{key:1,onSubmit:e[1]||(e[1]=J((...l)=>o.submitForm&&o.submitForm(...l),["prevent"])),class:"form"},[r("div",Sg,[(u(!0),h(F,null,U(n.fields,(l,f)=>(u(),h("div",{key:f,class:"ecwp-group form-group"},[l.type!=="textarea"?(u(),h("div",{key:0,type:l.type||"text"},[r("label",{for:f,class:"ecwp-label form-label"},c(l.label),9,Pg),r("input",{id:f,class:I(["ecwp-input input input-bordered",l.class||"w-full"]),value:l.value,disabled:l.disabled,onInput:d=>o.updateFieldValue(f,d.target.value)},null,42,Rg)],8,Dg)):(u(),h("div",jg,[r("label",{for:f,class:"form-label"},c(l.label),9,Mg),P(a,{modelValue:l.value,"onUpdate:modelValue":d=>l.value=d,editorToolbar:n.toolbarOptions},null,8,["modelValue","onUpdate:modelValue","editorToolbar"])]))]))),128))]),r("div",Og,[r("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(c(o.translations.send)+" ",1),n.loadingBtn?(u(),h("span",Ng)):g("",!0)],8,qg)])],32))])],8,wg)])}var Vg=ne(vg,[["render",Bg]]);const Fg={props:{isVisible:{type:Boolean,default:!1},title:{type:String,default:"Confirmation"},message:{type:String,default:"Are you sure?"},confirmText:{type:String,default:"Confirm"},cancelText:{type:String,default:"Cancel"},status:{type:String}},data(){return{selectedPaymentMethod:"",paymentMethods:[],hasPaymentMethodError:!1}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},mounted(){this.fetchPaymentMethods()},methods:{async fetchPaymentMethods(){try{const t=await fetch("/wp-json/my-easy-compta/v1/payments/methods",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(!t.ok)throw new Error(`Erreur : ${t.status}`);const e=await t.json();this.paymentMethods=e}catch(t){console.error("Erreur lors de la r\xE9cup\xE9ration des m\xE9thodes de paiement :",t)}},onConfirm(){if(!this.selectedPaymentMethod){this.hasPaymentMethodError=!0;return}this.hasPaymentMethodError=!1,this.$emit("confirm",this.selectedPaymentMethod),this.closeModal()},onCancel(){this.$emit("cancel"),this.closeModal()},closeModal(){document.getElementById("modal_confirm_paid").close()}}},Ug=["open"],Lg={class:"modal-box"},Wg={class:"font-bold text-lg"},Xg=r("div",{class:"text-center text-red-400 mb-2"},[r("i",{class:"fas fa-exclamation-triangle text-4xl"})],-1),Hg={class:"text-lg font-semibold text-center"},zg={class:"my-4 text-center text-xl"},Qg={key:0,class:"mt-4 mb-4"},Gg={class:"ecwp-group form-group"},Jg={for:"payment_method",class:"ecwp-label form-label"},Yg={value:""},Kg=["value"],Zg={class:"flex justify-between space-x-4"};function $g(t,e,s,i,n,o){return u(),h("div",null,[r("dialog",{id:"modal_confirm_paid",class:"modal",open:t.showModal},[r("div",Lg,[r("h3",Wg,c(t.modalTitle),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...a)=>o.closeModal&&o.closeModal(...a))}," \u2715 "),Xg,r("h2",Hg,c(s.title),1),r("p",zg,c(s.message),1),s.status==="paid"?(u(),h("div",Qg,[r("div",Gg,[r("label",Jg,c(o.translations.payment_method),1),D(r("select",{id:"payment_method","onUpdate:modelValue":e[1]||(e[1]=a=>n.selectedPaymentMethod=a),class:I([{"input-error":n.hasPaymentMethodError},"ecwp-input input input-bordered w-full"])},[r("option",Yg,c(o.translations.select),1),(u(!0),h(F,null,U(n.paymentMethods,a=>(u(),h("option",{key:a.id,value:a.id},c(a.method_name),9,Kg))),128))],2),[[ue,n.selectedPaymentMethod]])])])):g("",!0),r("div",Zg,[r("button",{onClick:e[2]||(e[2]=(...a)=>o.onCancel&&o.onCancel(...a)),class:"btn btn-secondary rounded-full"},c(s.cancelText),1),r("button",{onClick:e[3]||(e[3]=(...a)=>o.onConfirm&&o.onConfirm(...a)),class:"btn rounded-full btn-error text-white"},c(s.confirmText),1)])])],8,Ug)])}var ey=ne(Fg,[["render",$g]]);const ty={props:{isVisible:{type:Boolean,default:!1},title:{type:String,default:"Confirmation"},message:{type:String,default:"Are you sure?"},confirmText:{type:String,default:"Confirm"},cancelText:{type:String,default:"Cancel"},status:{type:String}},data(){return{selectedPaymentMethod:""}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{onConfirm(){this.$emit("confirm",this.selectedPaymentMethod),this.closeModal()},onCancel(){this.$emit("cancel"),this.closeModal()},closeModal(){document.getElementById("modal_confirm_credit").close()}}},ny=["open"],sy={class:"modal-box"},oy={class:"font-bold text-lg"},iy=r("div",{class:"text-center text-red-400 mb-2"},[r("i",{class:"fas fa-exclamation-triangle text-4xl"})],-1),ry={class:"text-lg font-semibold text-center"},ay={class:"my-4 text-center text-xl"},ly={class:"flex justify-between space-x-4"};function cy(t,e,s,i,n,o){return u(),h("div",null,[r("dialog",{id:"modal_confirm_credit",class:"modal",open:t.showModal},[r("div",sy,[r("h3",oy,c(t.modalTitle),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=(...a)=>o.closeModal&&o.closeModal(...a))}," \u2715 "),iy,r("h2",ry,c(s.title),1),r("p",ay,c(s.message),1),r("div",ly,[r("button",{onClick:e[1]||(e[1]=(...a)=>o.onCancel&&o.onCancel(...a)),class:"btn btn-secondary rounded-full"},c(s.cancelText),1),r("button",{onClick:e[2]||(e[2]=(...a)=>o.onConfirm&&o.onConfirm(...a)),class:"btn rounded-full btn-error text-white"},c(s.confirmText),1)])])],8,ny)])}var dy=ne(ty,[["render",cy]]);const uy={name:"InvoiceNavBar",components:{SendInvoiceModal:Vg,RemoveModal:qt,ConfirmModal:ds,ConfirmModalPaid:ey,ConfirmModalCredit:dy},props:{invoiceInfo:Object,currencyDefault:Object,currencyClient:Object,emailActive:String,qrCodeActive:String,totalAmount:String,noItems:Boolean},data(){return{showConfirmModal:!1,showConfirmCreditModal:!1,loading:!1,sendInvoiceModal:!1,loadingModal:!1,loadingPdf:!1,client_detail:null,selectedStatus:null,subject:"",content:"",showQrCodeModal:!1,qrCodeSrc:""}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{changeInvoiceStatusWithPaymentMethod(t){const e=this.selectedStatus;this.changeInvoiceStatus(e,t),this.showConfirmModal=!1},async changeInvoiceStatus(t,e){this.loading=!0;try{const i=await(await fetch("/wp-json/my-easy-compta/v1/invoices/update-status",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({id:this.invoiceInfo.id,status:t,method:e})})).json();i.success?(this.invoiceInfo.status=t,this.loading=!1):(console.error("Failed to update invoice status:",i.message),this.loading=!1)}catch(s){console.error("An error occurred while updating invoice status:",s)}},async addCreditInvoice(){this.loading=!0;try{const e=await(await fetch("/wp-json/my-easy-compta/v1/invoices/credit",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({id:this.invoiceInfo.id})})).json();e.success?(this.invoiceInfo.credit=1,this.loading=!1):(console.error("Failed to update invoice status:",e.message),this.loading=!1)}catch(t){console.error("An error occurred while updating invoice status:",t)}},exportToPDF(t){this.loadingPdf=!0;let s=`/wp-json/my-easy-compta/v1/invoices/pdf/${this.invoiceInfo.id}?currency_id=${t}`;fetch(s,{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(i=>{if(!i.ok)throw this.loadingPdf=!1,new Error("Network response was not ok");return i.blob()}).then(i=>{const n=URL.createObjectURL(i);window.open(n),this.loadingPdf=!1}).catch(i=>{console.error("There was a problem with the fetch operation:",i),this.loadingPdf=!1})},sendInvoice(t){this.loadingModal=!0,this.sendInvoiceModal=!0,modal_send_invoice.showModal(),this.fetchClient(t),this.fetchSettings()},fetchClient(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/clients/details/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Client not found");return e.json()}).then(e=>{this.client_detail=e,this.loading=!1}).catch(e=>{console.error("Error fetching client info:",e),this.loading=!1})},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,t.ok){const e=await t.json();this.subject=e.email_invoice_subject,this.content=e.email_invoice_content}else{const e=await t.json();this.showToast(e.message,"alert-error")}}catch(t){this.loading=!1,this.showToast(t.message,"alert-error")}},confirmValidateInvoice(t){this.selectedStatus=t,t=="unpaid"?modal_confirm.showModal():t=="paid"&&modal_confirm_paid.showModal(),this.showConfirmModal=!0},confirmCreditInvoice(){modal_confirm_credit.showModal(),this.showConfirmCreditModal=!0},async generateQRCode(){this.loading=!0;try{const t=await fetch("/wp-json/my-easy-compta/v1/generate-qrcode",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({invoice_ref:this.invoiceInfo.invoice_number||`Facture #${this.invoiceInfo.number}`,price:parseFloat(this.invoiceInfo.total_amount)})}),e=await t.json();t.ok&&e.qr_code?(this.qrCodeSrc=e.qr_code,this.showQrCodeModal=!0):console.error("Erreur lors de la g\xE9n\xE9ration du QR Code :",e.message)}catch(t){console.error("Erreur lors de l'appel \xE0 l'API pour g\xE9n\xE9rer le QR code :",t)}finally{this.loading=!1}},closeQrCodeModal(){this.showQrCodeModal=!1},downloadQRCode(){const t=document.createElement("a");t.href=this.qrCodeSrc,t.download=`qr_code_${this.invoiceInfo.invoice_number||this.invoiceInfo.number}.png`,t.click()}}},hy={key:0},my={key:1,class:"modal modal-open"},fy={class:"modal-box"},py={class:"font-bold text-lg"},_y={class:"mb-4"},gy=["src"],yy={class:"flex justify-end space-x-4"},by={key:2,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},vy=r("span",{class:"loading loading-spinner text-primary loading-lg"},null,-1),wy=[vy],xy={class:"navbar bg-base-100 mb-4 shadow-xl rounded-box flex justify-between"},Ey=r("div",{class:"dropdown"},[r("div",{tabindex:"0",role:"button",class:"btn btn-ghost lg:hidden"},[r("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 6h16M4 12h8m-8 6h16"})])]),r("ul",{tabindex:"0",class:"menu menu-sm dropdown-content mt-3 z-[1] p-2 shadow bg-base-100 rounded-box w-52"},[r("li",null,[r("a",null,"Item")]),r("li",null,[r("a",null,"Parent"),r("ul",{class:"p-2"},[r("li",null,[r("a",null,"Submenu")]),r("li",null,[r("a",null,"Submenu")])])]),r("li",null,[r("a",null,"Item")])])],-1),Cy={class:"hidden lg:flex gap-2"},Ty={class:"btn btn-sm"},Iy=r("i",{class:"far fa-edit"},null,-1),ky={key:1},Ay={class:"btn btn-sm",disabled:""},Sy=r("i",{class:"far fa-edit"},null,-1),Dy={key:2},Py=r("i",{class:"fa fa-check"},null,-1),Ry={class:"btn btn-outline btn-success btn-sm hover:text-white",disabled:""},jy=r("i",{class:"fa fa-check"},null,-1),My={key:0},Oy={class:"btn btn-sm ms-2",disabled:""},qy=r("i",{class:"fas fa-undo"},null,-1),Ny={key:1},By=r("i",{class:"fas fa-undo"},null,-1),Vy=["disabled"],Fy=r("i",{class:"far fa-file-pdf"},null,-1),Uy={key:0,class:"loading loading-spinner loading-sm"},Ly={class:"flex gap-2"},Wy=r("i",{class:"fas fa-paper-plane"},null,-1),Xy={key:0},Hy={key:1},zy={key:2,class:"far fa-envelope"},Qy=["data-tip"],Gy={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},Jy=r("i",{class:"fas fa-paper-plane"},null,-1),Yy=["data-tip"],Ky={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},Zy=r("i",{class:"fas fa-paper-plane"},null,-1),$y={key:3},eb=r("i",{class:"fas fa-qrcode"},null,-1),tb={key:1,click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},nb=r("i",{class:"fas fa-qrcode"},null,-1),sb=["data-tip"],ob={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},ib=r("i",{class:"fas fa-qrcode"},null,-1),rb={key:5},ab={key:0,class:"dropdown dropdown-end"},lb={tabindex:"0",role:"button",class:"btn btn-outline btn-success btn-sm"},cb=r("i",{class:"far fa-file-pdf"},null,-1),db={key:0,class:"loading loading-spinner loading-sm"},ub={tabindex:"0",class:"dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow"},hb=["disabled"],mb=["disabled"],fb={key:6},pb=["disabled"],_b=r("i",{class:"far fa-file-pdf"},null,-1),gb={key:0},yb={key:1},bb={key:2,class:"loading loading-spinner loading-sm"},vb=r("i",{class:"fas fa-check"},null,-1),wb=["data-tip"],xb={click:"#",class:"btn btn-outline btn-primary btn-sm hover:text-white",disabled:""},Eb=r("i",{class:"fas fa-check"},null,-1);function Cb(t,e,s,i,n,o){const a=O("send-invoice-modal"),l=O("confirm-modal"),f=O("confirm-modal-paid"),d=O("confirm-modal-credit"),m=O("router-link");return u(),h("div",null,[s.emailActive==1?(u(),h("div",hy,[P(a,{loading:n.loadingModal,"show-modal":n.sendInvoiceModal,"modal-id":"modal_send_invoice",client:n.client_detail,"invoice-id":s.invoiceInfo.id,subject:n.subject,content:n.content,onClose:e[0]||(e[0]=p=>n.sendInvoiceModal=!1)},null,8,["loading","show-modal","client","invoice-id","subject","content"])])):g("",!0),P(l,{"show-modal":n.showConfirmModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,status:n.selectedStatus,onConfirm:e[1]||(e[1]=p=>o.changeInvoiceStatus("unpaid")),onCancel:e[2]||(e[2]=p=>n.showConfirmModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText","status"]),P(f,{"show-modal":n.showConfirmModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,status:n.selectedStatus,onConfirm:o.changeInvoiceStatusWithPaymentMethod,onCancel:e[3]||(e[3]=p=>n.showConfirmModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText","status","onConfirm"]),P(d,{"show-modal":n.showConfirmCreditModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_confirm_it,cancelText:o.translations.cancel,onConfirm:e[4]||(e[4]=p=>this.addCreditInvoice()),onCancel:e[5]||(e[5]=p=>n.showConfirmCreditModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),s.qrCodeActive==1&&n.showQrCodeModal?(u(),h("div",my,[r("div",fy,[r("h3",py,c(o.translations.download_qr_code),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[6]||(e[6]=p=>o.closeQrCodeModal())}," \u2715 "),r("div",_y,[r("img",{src:n.qrCodeSrc,alt:"QR Code",class:"max-w-full h-auto mx-auto"},null,8,gy)]),r("div",yy,[r("button",{onClick:e[7]||(e[7]=(...p)=>o.downloadQRCode&&o.downloadQRCode(...p)),class:"btn btn-primary"},c(o.translations.download_qr_code),1)])])])):g("",!0),n.loading?(u(),h("div",by,wy)):g("",!0),r("div",xy,[r("div",null,[Ey,r("div",Cy,[s.invoiceInfo.status=="draft"?(u(),pi(m,{key:0,to:{name:"InvoiceEdit",params:{id:s.invoiceInfo.id}}},{default:me(()=>[r("button",Ty,[Iy,C(" "+c(o.translations.edit_invoice),1)])]),_:1},8,["to"])):(u(),h("div",ky,[r("button",Ay,[Sy,C(" "+c(o.translations.edit_invoice),1)])])),s.invoiceInfo.status=="unpaid"&&!s.noItems?(u(),h("div",Dy,[r("button",{class:"btn btn-outline btn-success btn-sm hover:text-white",onClick:e[8]||(e[8]=p=>o.confirmValidateInvoice("paid"))},[Py,C(" "+c(o.translations.mark_as_paid),1)])])):(u(),h(F,{key:3},[r("div",null,[r("button",Ry,[jy,C(" "+c(o.translations.mark_as_paid),1)])]),s.invoiceInfo.credit!=0&&s.invoiceInfo.status=="paid"&&!s.noItems?(u(),h("div",My,[r("button",Oy,[qy,C(" "+c(o.translations.credit_invoice),1)])])):g("",!0),s.invoiceInfo.credit==0&&s.invoiceInfo.status=="paid"&&!s.noItems?(u(),h("div",Ny,[r("button",{class:"btn btn-sm ms-2",onClick:e[9]||(e[9]=p=>o.confirmCreditInvoice())},[By,C(" "+c(o.translations.credit_invoice),1)])])):g("",!0)],64))])]),s.invoiceInfo.status=="draft"?(u(),h("button",{key:0,onClick:e[10]||(e[10]=p=>o.exportToPDF(s.currencyDefault.currency_id)),class:"btn btn-outline btn-secondary btn-sm",disabled:n.loadingPdf},[Fy,r("span",null,c(o.translations.previewPDF),1),n.loadingPdf?(u(),h("span",Uy)):g("",!0)],8,Vy)):g("",!0),r("div",Ly,[s.emailActive==1&&s.invoiceInfo.status!="draft"?(u(),h("button",{key:0,onClick:e[11]||(e[11]=J(p=>o.sendInvoice(s.invoiceInfo.client_id),["prevent"])),class:"btn btn-outline btn-primary btn-sm hover:text-white"},[Wy,s.invoiceInfo.sent==1?(u(),h("span",Xy,c(o.translations.resend_invoice),1)):(u(),h("span",Hy,c(o.translations.send_invoice),1)),s.invoiceInfo.sent==1?(u(),h("i",zy)):g("",!0)])):s.emailActive==1&&s.invoiceInfo.status=="draft"?(u(),h("div",{key:1,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.draft_cannot_send},[r("button",Gy,[Jy,C(" "+c(o.translations.send_invoice),1)])],8,Qy)):(u(),h("div",{key:2,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.active_email_addon},[r("button",Ky,[Zy,C(" "+c(o.translations.send_invoice),1)])],8,Yy)),s.qrCodeActive==1?(u(),h("div",$y,[s.invoiceInfo.status=="unpaid"?(u(),h("button",{key:0,class:"btn btn-outline btn-accent btn-sm",onClick:e[12]||(e[12]=(...p)=>o.generateQRCode&&o.generateQRCode(...p))},[eb,C(" "+c(o.translations.generate_qrcode),1)])):(u(),h("button",tb,[nb,C(" "+c(o.translations.generate_qrcode),1)]))])):(u(),h("div",{key:4,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.active_qrcode_addon},[r("button",ob,[ib,C(" "+c(o.translations.generate_qrcode),1)])],8,sb)),s.currencyDefault.currency_id!==s.currencyClient.currency_id?(u(),h("div",rb,[s.invoiceInfo.status!="draft"?(u(),h("div",ab,[r("div",lb,[cb,C(" "+c(o.translations.exportToPDF)+" ",1),n.loadingPdf?(u(),h("span",db)):g("",!0)]),r("ul",ub,[r("li",null,[r("a",{onClick:e[13]||(e[13]=p=>o.exportToPDF(s.currencyDefault.currency_id)),disabled:n.loadingPdf},c(o.translations.invoice_in)+" "+c(s.currencyDefault.currency_symbol),9,hb)]),r("li",null,[r("a",{onClick:e[14]||(e[14]=p=>o.exportToPDF(s.currencyClient.currency_id)),disabled:n.loadingPdf},c(o.translations.invoice_in)+" "+c(s.currencyClient.currency_symbol),9,mb)])])])):g("",!0)])):(u(),h("div",fb,[s.invoiceInfo.status!="draft"?(u(),h("button",{key:0,onClick:e[15]||(e[15]=p=>o.exportToPDF(s.currencyDefault.currency_id)),class:"btn btn-outline btn-success btn-sm",disabled:n.loadingPdf},[_b,s.invoiceInfo.status!="draft"?(u(),h("span",gb,c(o.translations.exportToPDF),1)):(u(),h("span",yb,c(o.translations.previewPDF),1)),n.loadingPdf?(u(),h("span",bb)):g("",!0)],8,pb)):g("",!0)])),s.invoiceInfo.status=="draft"&&!s.noItems?(u(),h("button",{key:7,class:"btn btn-outline btn-success btn-sm hover:text-white",onClick:e[16]||(e[16]=p=>o.confirmValidateInvoice("unpaid"))},[vb,C(" "+c(o.translations.validateInvoice),1)])):g("",!0),s.invoiceInfo.status=="draft"&&s.noItems?(u(),h("div",{key:8,class:"tooltip tooltip-left tooltip-warning","data-tip":o.translations.min_article},[r("button",xb,[Eb,C(" "+c(o.translations.validateInvoice),1)])],8,wb)):g("",!0)])])])}var Tb=ne(uy,[["render",Cb]]);const Ib={components:{VueEditor:mt.exports.VueEditor},props:{loading:Boolean,showModal:Boolean,modalId:String,modalTitle:String,item:Object},data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{editedItem:{...this.item},loading:this.loading,loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},fields:{item_name:{label:t.item_name},item_description:{label:t.item_description,type:"textarea"},quantity:{label:t.quantity,type:"number"},vat_rate:{label:t.vat,type:"number"},unit_price:{label:t.unit_price,type:"number"},discount:{label:t.discount,type:"number"}}}},computed:{skeletonItems(){return Array.from({length:10},(t,e)=>e)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const t=await fetch(`/wp-json/my-easy-compta/v1/invoices/edit-item/${this.editedItem.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.editedItem)});if(t.ok){const e=await t.json();this.loadingBtn=!1,this.closeModal(),this.showToast(e.message,"alert-success"),this.$emit("itemEdited")}else{const e=`Error editing item: ${t.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(t){const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Error editing item";this.showToast(e,"alert-error"),console.error("Error editing item:",t),this.loadingBtn=!1}},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},increase(){this.newItem.quantity++},decrease(){this.newItem.quantity>1&&this.newItem.quantity--}},watch:{item:{handler(t){this.editedItem={...t}},immediate:!0}}},kb=["id","open"],Ab={class:"modal-box"},Sb={class:"font-bold text-lg"},Db={key:0},Pb={class:"grid grid-cols-1 gap-4"},Rb=r("div",{class:"skeleton h-4 w-full mb-2"},null,-1),jb=r("div",{class:"skeleton h-4 w-full"},null,-1),Mb=[Rb,jb],Ob={class:"grid grid-cols-1 gap-4"},qb=["type"],Nb=["for"],Bb=["id","onUpdate:modelValue"],Vb={key:1},Fb=["for"],Ub={class:"form-group mt-4 flex justify-end"},Lb=["disabled"],Wb={key:0,class:"loading loading-spinner loading-sm"};function Xb(t,e,s,i,n,o){const a=O("vue-editor");return u(),h("div",null,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),r("dialog",{id:s.modalId,class:"modal",open:s.showModal},[r("div",Ab,[r("h3",Sb,c(s.modalTitle),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=l=>o.closeModal())}," \u2715 "),n.loading?(u(),h("div",Db,[r("div",Pb,[(u(!0),h(F,null,U(o.skeletonItems,l=>(u(),h("div",{key:l,class:"py-2"},Mb))),128))])])):(u(),h("form",{key:1,onSubmit:e[1]||(e[1]=J((...l)=>o.submitForm&&o.submitForm(...l),["prevent"])),class:"form"},[r("div",Ob,[(u(!0),h(F,null,U(n.fields,(l,f)=>(u(),h("div",{key:f,class:"ecwp-group form-group"},[l.type!=="textarea"?(u(),h("div",{key:0,type:l.type||"text"},[r("label",{for:f,class:"ecwp-label form-label"},c(l.label),9,Nb),D(r("input",{id:f,"onUpdate:modelValue":d=>n.editedItem[f]=d,class:I(["ecwp-input input input-bordered",l.class||"w-full"])},null,10,Bb),[[W,n.editedItem[f]]])],8,qb)):(u(),h("div",Vb,[r("label",{for:f,class:"form-label"},c(l.label),9,Fb),P(a,{id:f,modelValue:n.editedItem[f],"onUpdate:modelValue":d=>n.editedItem[f]=d,editorToolbar:t.toolbarOptions},null,8,["id","modelValue","onUpdate:modelValue","editorToolbar"])]))]))),128))]),r("div",Ub,[r("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(c(o.translations.save)+" ",1),n.loadingBtn?(u(),h("span",Wb)):g("",!0)],8,Lb)])],32))])],8,kb)])}var Hb=ne(Ib,[["render",Xb]]);const zb={components:{VueEditor:mt.exports.VueEditor},props:{loading:Boolean,showModal:Boolean,modalId:String,modalTitle:String,disb:Object},data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{editedDisb:{...this.disb},loading:this.loading,loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},fields:{title:{label:t.item_name},description:{label:t.item_description,type:"textarea"},unit_price:{label:t.unit_price,type:"number"}}}},computed:{skeletonItems(){return Array.from({length:10},(t,e)=>e)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const t=await fetch(`/wp-json/my-easy-compta/v1/invoices/edit-disb/${this.editedDisb.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.editedDisb)});if(t.ok){const e=await t.json();this.loadingBtn=!1,this.closeModal(),this.showToast(e.message,"alert-success"),this.$emit("disbEdited")}else{const e=`Error editing item: ${t.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(t){const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Error editing item";this.showToast(e,"alert-error"),console.error("Error editing item:",t),this.loadingBtn=!1}},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},increase(){this.newItem.quantity++},decrease(){this.newItem.quantity>1&&this.newItem.quantity--}},watch:{disb:{handler(t){this.editedDisb={...t}},immediate:!0}}},Qb=["id","open"],Gb={class:"modal-box"},Jb={class:"font-bold text-lg"},Yb={key:0},Kb={class:"grid grid-cols-1 gap-4"},Zb=r("div",{class:"skeleton h-4 w-full mb-2"},null,-1),$b=r("div",{class:"skeleton h-4 w-full"},null,-1),ev=[Zb,$b],tv={class:"grid grid-cols-1 gap-4"},nv=["type"],sv=["for"],ov=["id","onUpdate:modelValue"],iv={key:1},rv=["for"],av={class:"form-group mt-4 flex justify-end"},lv=["disabled"],cv={key:0,class:"loading loading-spinner loading-sm"};function dv(t,e,s,i,n,o){const a=O("vue-editor");return u(),h("div",null,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),r("dialog",{id:s.modalId,class:"modal",open:s.showModal},[r("div",Gb,[r("h3",Jb,c(s.modalTitle),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=l=>o.closeModal())}," \u2715 "),n.loading?(u(),h("div",Yb,[r("div",Kb,[(u(!0),h(F,null,U(o.skeletonItems,l=>(u(),h("div",{key:l,class:"py-2"},ev))),128))])])):(u(),h("form",{key:1,onSubmit:e[1]||(e[1]=J((...l)=>o.submitForm&&o.submitForm(...l),["prevent"])),class:"form"},[r("div",tv,[(u(!0),h(F,null,U(n.fields,(l,f)=>(u(),h("div",{key:f,class:"ecwp-group form-group"},[l.type!=="textarea"?(u(),h("div",{key:0,type:l.type||"text"},[r("label",{for:f,class:"ecwp-label form-label"},c(l.label),9,sv),D(r("input",{id:f,"onUpdate:modelValue":d=>n.editedDisb[f]=d,class:I(["ecwp-input input input-bordered",l.class||"w-full"])},null,10,ov),[[W,n.editedDisb[f]]])],8,nv)):(u(),h("div",iv,[r("label",{for:f,class:"form-label"},c(l.label),9,rv),P(a,{id:f,modelValue:n.editedDisb[f],"onUpdate:modelValue":d=>n.editedDisb[f]=d,editorToolbar:t.toolbarOptions},null,8,["id","modelValue","onUpdate:modelValue","editorToolbar"])]))]))),128))]),r("div",av,[r("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(c(o.translations.save)+" ",1),n.loadingBtn?(u(),h("span",cv)):g("",!0)],8,lv)])],32))])],8,Qb)])}var uv=ne(zb,[["render",dv]]);const hv={name:"sendRemind",components:{VueEditor:mt.exports.VueEditor},props:{showModal:Boolean,modalId:String,client:Object,invoiceId:Number,loading:Boolean,subject:String,content:String},data(){const t=window.myEasyComptaAdmin.easyComptaTranslations;return{loading:!1,loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},toolbarOptions:[["bold","italic","underline","strike"],["link"],[{list:"ordered"},{list:"bullet"}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{align:[]}],[{align:"right"},{align:"center"},{align:"justify"}],["clean"]],fields:{client_email:{label:t.client,value:"",disabled:!0},email_subject:{label:t.email_subject,value:""},email_message:{label:t.email_content,value:"",type:"textarea"}}}},watch:{client:{immediate:!0,handler(t){this.fields.client_email.value=(t==null?void 0:t.email)||""}},subject:{immediate:!0,handler(t){this.fields.email_subject.value=t||""}},content:{immediate:!0,handler(t){this.fields.email_message.value=t||""}}},computed:{skeletonItems(){return Array.from({length:10},(t,e)=>e)},translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},methods:{closeModal(){document.getElementById(this.modalId).close()},async submitForm(){this.loadingBtn=!0;try{const t=await fetch("/wp-json/my-easy-compta/v1/emails/send-email",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({type:"remind",id:this.invoiceId,client_email:this.client.email,email_subject:this.fields.email_subject.value,email_message:this.fields.email_message.value})});if(t.ok){const e=await t.json();this.loadingBtn=!1,this.closeModal(),this.showToast(e.message,"alert-success")}else{const e=`Error sending email: ${t.statusText}`;this.showToast(e,"alert-error"),console.error(e),this.loadingBtn=!1}}catch(t){const e=t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Error sending email";this.showToast(e,"alert-error"),console.error("Error sending email:",t),this.loadingBtn=!1}},updateFieldValue(t,e){this.fields[t].value=e},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},mv=["id","open"],fv={class:"modal-box"},pv={class:"font-bold text-lg"},_v={key:0},gv={class:"grid grid-cols-1 gap-4"},yv=r("div",{class:"skeleton h-4 w-full mb-2"},null,-1),bv=r("div",{class:"skeleton h-4 w-full"},null,-1),vv=[yv,bv],wv={class:"grid grid-cols-1 gap-4"},xv=["type"],Ev=["for"],Cv=["id","value","disabled","onInput"],Tv={key:1},Iv=["for"],kv={class:"form-group mt-4 flex justify-end"},Av=["disabled"],Sv={key:0,class:"loading loading-spinner loading-sm"};function Dv(t,e,s,i,n,o){const a=O("vue-editor");return u(),h("div",null,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),r("dialog",{id:s.modalId,class:"modal",open:s.showModal},[r("div",fv,[r("h3",pv,c(o.translations.remind_invoice),1),r("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:e[0]||(e[0]=l=>o.closeModal())}," \u2715 "),n.loading?(u(),h("div",_v,[r("div",gv,[(u(!0),h(F,null,U(o.skeletonItems,l=>(u(),h("div",{key:l,class:"py-2"},vv))),128))])])):(u(),h("form",{key:1,onSubmit:e[1]||(e[1]=J((...l)=>o.submitForm&&o.submitForm(...l),["prevent"])),class:"form"},[r("div",wv,[(u(!0),h(F,null,U(n.fields,(l,f)=>(u(),h("div",{key:f,class:"ecwp-group form-group"},[l.type!=="textarea"?(u(),h("div",{key:0,type:l.type||"text"},[r("label",{for:f,class:"ecwp-label form-label"},c(l.label),9,Ev),r("input",{id:f,class:I(["ecwp-input input input-bordered",l.class||"w-full"]),value:l.value,disabled:l.disabled,onInput:d=>o.updateFieldValue(f,d.target.value)},null,42,Cv)],8,xv)):(u(),h("div",Tv,[r("label",{for:f,class:"form-label"},c(l.label),9,Iv),P(a,{modelValue:l.value,"onUpdate:modelValue":d=>l.value=d,editorToolbar:n.toolbarOptions},null,8,["modelValue","onUpdate:modelValue","editorToolbar"])]))]))),128))]),r("div",kv,[r("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(c(o.translations.send)+" ",1),n.loadingBtn?(u(),h("span",Sv)):g("",!0)],8,Av)])],32))])],8,mv)])}var Pv=ne(hv,[["render",Dv]]);const Rv={name:"InvoiceViewDetail",components:{Card:Ze,InvoiceNavBar:Tb,EditItemModal:Hb,EditDisbModal:uv,RemoveModal:qt,RemindInvoiceModal:Pv,ArticleModal:zo},data(){return{selectedItem:null,selectedDisb:null,SelectedInvoiceId:null,editItemsModal:!1,editDisbModal:!1,RemindInvoiceModal:!1,no_items:!0,loading:!1,loading_add:!1,invoice:[],invoiceItems:[],newItem:{loading_del:!1,item_name:"",item_ref:"",item_category:"Type",item_description:"",quantity:1,vat_rate:0,unit_price:0,discount:0,total_price:0,total_amount:0},settings:[],client_detail:[],list_vats:[],client_currency:"",default_vat:"",default_currency:"",default_currency_symbol:"",showArticlesModal:!1,articles:[],categories:[],refs:[],showDropdown:!1,showDropdownRef:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},showDisbursements:!1,disbursementsExist:!1,disbursementsItem:{title:"",description:"",unit_price:""},loading_add_disbursements:!1,disbursementsList:[]}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},isInvoiceOverdue(){const t=new Date().getTime(),e=this.invoice.due_date?new Date(this.invoice.due_date).getTime():null;return e&&e<t},defaultCurrency(){return{currency_id:this.settings.default_currency,currency_symbol:this.default_currency_symbol}},clientCurrency(){return{currency_id:this.client_detail.currency_id,currency_symbol:this.client_currency}},totalAmountWithoutDiscount(){const t=this.invoiceItems.reduce((e,s)=>{const i=s.quantity*s.unit_price;return e+i},0);return this.formatCurrency(t)},totalAmount(){const t=this.invoiceItems.reduce((e,s)=>e+parseFloat(s.total_price),0);return this.formatCurrency(t)},totalAmountDefaultCurrency(){return(this.invoiceItems.reduce((i,n)=>i+parseFloat(n.total_amount),0)*this.invoice.exchange_rate).toFixed(2)},totalAmountWithVAT(){const t=parseFloat(this.totalAmount);if(this.settings.vat_active==1){const e=parseFloat(this.calculateVAT());return this.formatCurrency(t+e)}else return this.formatCurrency(t)}},methods:{getUniqueVATRates(){const t=new Set;return this.invoiceItems.forEach(e=>{e.vat_rate&&t.add(e.vat_rate)}),Array.from(t)},calculateVATForRate(t){let e=0;return this.invoiceItems.forEach(s=>{if(s.vat_rate===t){const i=s.quantity*s.unit_price,n=i*s.discount/100;e+=(i-n)*t/100}}),this.formatCurrency(e)},totalDisbursements(){let t=0;return this.disbursementsList&&this.disbursementsList.length>0&&(t+=this.disbursementsList.reduce((e,s)=>e+parseFloat(s.unit_price||0),0)),this.formatCurrency(t)},calculateTotalAmountWithVAT(){let t=this.invoiceItems.reduce((e,s)=>e+parseFloat(s.total_amount),0);return this.disbursementsList&&this.disbursementsList.length>0&&(t+=this.disbursementsList.reduce((e,s)=>e+parseFloat(s.unit_price||0),0)),this.settings.easy_compta_woo_addon_active==1&&(t+=parseFloat(this.invoice.shipping_amount||0)),this.formatCurrency(t)},formatShippingAmout(t){return this.formatShippingCurrency(t)},formatShippingCurrency(t){const s=(parseFloat(t)||0).toFixed(2),i=this.client_currency!==this.default_currency_symbol?this.client_currency:this.default_currency_symbol;return`${s}${i}`},fetchInvoice(){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/${this.$route.params.id}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{t?(this.invoice=t,this.fetchClientInfo(t.client_id)):console.error("Invoice not found")}).catch(t=>{console.error("Error fetching invoice:",t),this.loading=!1})},fetchClientInfo(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/clients/details/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw new Error("Client not found");return e.json()}).then(e=>{this.client_detail=e;const s=e.currency_id;s&&this.fetchCurrencyDetails(s)}).catch(e=>{console.error("Error fetching client info:",e),this.loading=!1})},fetchItems(){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/${this.$route.params.id}/items`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{t.code=="no_items_found"?(console.error("No items found"),this.invoiceItems=[],this.loading=!1,this.no_items=!0):(this.invoiceItems=t,this.loading=!1,this.no_items=!1)}).catch(t=>{console.error("Error fetching items:",t),this.loading=!1})},fetchDisbursements(){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/disbursements/${this.$route.params.id}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{t.code==="no_disbursements"?(console.error("No disbursements found"),this.disbursementsList=[],this.disbursementsExist=!1):(this.disbursementsList=t,this.disbursementsExist=!0),this.loading=!1}).catch(t=>{console.error("Error fetching disbursements:",t),this.loading=!1})},fetchCurrencyDetails(t){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/settings/currency/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>{if(!e.ok)throw this.loading=!1,new Error("Currency details not found");return this.loading=!1,e.json()}).then(e=>{this.client_currency=e.symbol,this.loading=!1}).catch(e=>{this.loading=!1,console.error("Error fetching currency details:",e)})},updateTotal(){const t=this.newItem.quantity*this.newItem.unit_price,e=t*this.newItem.discount/100,s=t-e;var i=0;if(this.settings.vat_active==1){const n=s*this.newItem.vat_rate/100;i=s+n}else i=s;this.newItem.total_price=this.formatCurrency(s),this.newItem.total_amount=this.formatCurrency(i)},calculateTotalWithVat(t,e,s,i){const n=t*e,o=n*i/100,a=n-o,l=a*s/100,f=a+l;return this.formatCurrency(f)},calculateTotal(t,e,s){const i=t*e,n=i*s/100,a=i-n;return this.formatCurrency(a)},submitItems(){this.updateTotal();const t={...this.newItem,invoice_id:this.$route.params.id};this.loading_add=!0,fetch("/wp-json/my-easy-compta/v1/invoices/element-add",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(t)}).then(e=>e.json()).then(e=>{e.success?(this.loading_add=!1,this.fetchItems(),this.newItem={item_name:"",item_ref:"",item_category:"Type",item_description:"",quantity:1,vat_rate:this.default_vat.rate,unit_price:0,discount:0,total_price:0,total_amount:0}):(this.showToast(e.message,"alert-error"),console.error("Error submitting item:",e.message),this.loading_add=!1)}).catch(e=>{this.showToast(e.message,"alert-error"),console.error("Error submitting item:",e),this.loading_add=!1})},increase(){this.newItem.quantity++},decrease(){this.newItem.quantity>1&&this.newItem.quantity--},confirmremoveItem(t,e){this.selectedItem=t,this.SelectedInvoiceId=e,modal_remove_item.showModal(),this.showRemoveModal=!0},removeItem(t,e){const s=this.invoiceItems.find(i=>i.id===t);s.loading_del=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/element-delete/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({invoice_id:e})}).then(i=>i.json()).then(i=>{i.success?(s.loading_del=!1,this.fetchItems()):(this.showToast(i.message,"alert-error"),console.error("Error removing item:",i.message),s.loading_del=!1)}).catch(i=>{this.showToast(i.message,"alert-error"),console.error("Error removing item:",i),s.loading_del=!1})},editItem(t){this.loadingModal=!0,this.editItemsModal=!0,modal_edit_item.showModal(),this.fetchItemDetails(t)},fetchItemDetails(t){fetch(`/wp-json/my-easy-compta/v1/invoices/item-details/${t}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{this.selectedItem=e,this.loading=!1}).catch(e=>{console.error("Error fetching item details:",e),this.loading=!1})},editDisb(t){this.loadingModal=!0,this.editDisbModal=!0,modal_edit_disb.showModal(),this.fetchDisbDetails(t)},fetchDisbDetails(t){fetch(`/wp-json/my-easy-compta/v1/invoices/disb-details/${t}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{this.selectedDisb=e,this.loading=!1}).catch(e=>{console.error("Error fetching item details:",e),this.loading=!1})},confirmremoveDisb(t,e){this.selectedDisb=t,this.SelectedInvoiceId=e,modal_remove_disb.showModal(),this.showRemoveModalDisb=!0},removeDisb(t,e){const s=this.disbursementsList.find(i=>i.id===t);s.loading_del=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/disb-delete/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({invoice_id:e})}).then(i=>i.json()).then(i=>{i.success?(s.loading_del=!1,this.fetchDisbursements()):(this.showToast(i.message,"alert-error"),console.error("Error removing item:",i.message),s.loading_del=!1)}).catch(i=>{this.showToast(i.message,"alert-error"),console.error("Error removing item:",i),s.loading_del=!1})},formatCurrency(t){const e=t.toFixed(2),s=this.client_currency!==this.default_currency_symbol?this.client_currency:this.default_currency_symbol;return`${e}${s}`},calculateDiscountAmountWithVAT(t,e,s,i){const o=t*e*i/100,a=o*s/100,l=o+a;return this.formatCurrency(l)},calculateDiscountAmount(t,e,s){const o=t*e*s/100;return this.formatCurrency(o)},calculateVAT(){const t=parseFloat(this.totalAmount),e=parseFloat(this.default_vat.rate),s=t*(e/100);return this.formatCurrency(s)},onDragEnd(t){const e=this.invoiceItems[t.oldIndex];this.invoiceItems.splice(t.oldIndex,1),this.invoiceItems.splice(t.newIndex,0,e);const s=this.invoiceItems.map(i=>i.id);this.saveOrderToDatabase(s)},nl2br(t){return t?t.replace(/\n/g,"<br>"):""},resize(){let t=this.$refs.textarea;t.style.height="auto",t.style.height=t.scrollHeight+"px"},saveOrderToDatabase(t){fetch("/wp-json/my-easy-compta/v1/invoices/update-invoice-items-order",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({order:t})}).then(e=>{e.ok?console.log("Order saved successfully."):console.error("Failed to save order:",e.statusText)}).catch(e=>{console.error("Error saving order:",e)})},fetchCategoriesArticles(){fetch("/wp-json/my-easy-compta/v1/categories-articles",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.categories=t}).catch(t=>console.error("Error fetching categories:",t))},ShowModalArticles(){this.showArticlesModal=!0,modal_articles.showModal()},applySelectedArticle(t){this.newItem.item_ref=t.ref,this.newItem.item_name=t.name,this.newItem.item_description=t.description||"",this.newItem.unit_price=t.unit_price||0},fetchArticles(){if(this.newItem.item_name.length<1){this.articles=[];return}const t=document.getElementById("loader_articles");t.classList.remove("hidden"),fetch(`/wp-json/my-easy-compta/v1/articles?search=${this.newItem.item_name}&method=name`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{this.articles=e}).catch(e=>console.error("Error fetching articles:",e)).finally(()=>{t.classList.add("hidden")})},toggleDisbursements(){this.showDisbursements=!this.showDisbursements},addDisbursements(){this.loading_add_disbursements=!0,fetch("/wp-json/my-easy-compta/v1/invoices/disbursements",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({invoice_id:this.invoice.id,title:this.disbursementsItem.title,description:this.disbursementsItem.description,unit_price:parseFloat(this.disbursementsItem.unit_price)})}).then(t=>{if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return t.json()}).then(t=>{this.disbursementsItem={title:"",description:"",unit_price:""},this.disbursementsList.push(t),this.disbursementsExist=!0}).catch(t=>{console.error("Erreur lors de l'ajout du d\xE9bours :",t)}).finally(()=>{this.loading_add_disbursements=!1})},selectItem(t){this.newItem.item_ref=t.ref,this.newItem.item_name=t.name,this.newItem.item_description=t.description,this.newItem.unit_price=t.unit_price,this.showDropdown=!1,this.showDropdownRef=!1},fetchRefs(){if(this.newItem.item_ref.length<1){this.refs=[];return}fetch(`/wp-json/my-easy-compta/v1/articles?search=${this.newItem.item_ref}&method=ref`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.refs=t}).catch(t=>console.error("Error fetching refrences:",t))},async loadSettings(){try{this.loadingPrice=!0;const{settings:t,currencySymbol:e,vatData:s,listVatData:i}=await mn();this.settings=t,this.default_currency_symbol=e,this.default_vat=s,this.list_vats=i,this.newItem.vat_rate=this.default_vat.rate,this.loadingPrice=!1}catch(t){this.showToast(t.message,"alert-error"),this.loadingPrice=!1}},highlightMatch(t){if(!this.newItem.item_name)return t;const e=new RegExp(`(${this.escapeRegExp(this.newItem.item_name)})`,"gi");return t.replace(e,"<b>$1</b>")},escapeRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},handleClickOutside(t){this.$el.contains(t.target)||(this.showDropdown=!1,this.showDropdownRef=!1)},sendRemind(t){this.loadingModal=!0,this.RemindInvoiceModal=!0,modal_send_remind.showModal(),this.fetchClientInfo(t),this.loadSettings()},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}},beforeDestroy(){document.removeEventListener("click",this.handleClickOutside)},mounted(){this.fetchInvoice(),this.fetchItems(),this.loadSettings(),this.fetchCategoriesArticles(),this.fetchDisbursements(),document.addEventListener("click",this.handleClickOutside);const t=document.querySelector("tbody");M.create(t,{animation:150,handle:".drag-handle",onEnd:this.onDragEnd})}},jv={class:"pt-2 pr-4"},Mv={key:0},Ov={key:2,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},qv=r("span",{class:"loading loading-spinner text-primary loading-lg"},null,-1),Nv=[qv],Bv={key:3},Vv={role:"alert",class:"alert alert-warning"},Fv=r("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6 shrink-0 stroke-current",fill:"none",viewBox:"0 0 24 24"},[r("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})],-1),Uv={key:0},Lv=["data-tip"],Wv={class:"btn btn-sm btn-primary",disabled:""},Xv={class:"grid grid-cols-2"},Hv={class:"md:col-span-1"},zv=["src"],Qv={class:"md:col-span-1 text-right"},Gv={class:"text-lg font-semibold"},Jv={key:0,class:"badge badge-error text-white"},Yv={key:1,class:"badge badge-error text-white"},Kv={key:2,class:"badge badge-success text-white"},Zv={class:"bg-base-300 rounded-lg shadow-md flex justify-between p-4 mt-4 gap-4"},$v=r("br",null,null,-1),e1=r("br",null,null,-1),t1=r("br",null,null,-1),n1=["href"],s1=r("br",null,null,-1),o1=r("br",null,null,-1),i1=r("br",null,null,-1),r1=["href"],a1=r("br",null,null,-1),l1=["href"],c1={class:"table mt-8"},d1=r("th",null,null,-1),u1={width:"5%"},h1={width:"19%"},m1={width:"21%"},f1={width:"10%",class:"text-center"},p1={width:"8%",class:"text-center"},_1={key:0,width:"5%",class:"text-center"},g1={key:1,width:"5%"},y1={width:"10%",class:"text-center"},b1={width:"10%",class:"text-right"},v1=r("th",{width:"18%",class:"text-right inv-actions"},null,-1),w1={class:"draggable-item drag-handle px-2"},x1={key:0,class:"fas fa-sort"},E1={key:0,class:"badge badge-ghost badge-xs"},C1=["innerHTML"],T1={class:"text-center"},I1={class:"text-center"},k1={key:0},A1={key:1},S1={key:0,class:"text-center"},D1={key:1},P1={key:2,class:"text-center"},R1=r("br",null,null,-1),j1={key:3,class:"text-center"},M1=r("br",null,null,-1),O1={class:"text-right"},q1={key:0},N1={key:1},B1={key:0},V1=["data-tip"],F1=["onClick"],U1=r("i",{class:"far fa-edit"},null,-1),L1=[U1],W1=["data-tip"],X1=["onClick"],H1={key:0,class:"far fa-trash-alt"},z1={key:1,class:"loading loading-spinner loading-xs"},Q1={key:0},G1={class:"align-top px-2"},J1=r("i",{class:"fas fa-list-ul"},null,-1),Y1=[J1],K1={class:"align-top px-2"},Z1={class:"flex items-center border rounded-md relative"},$1=["placeholder"],ew={key:0,class:"autocomplete-dropdown bg-base-100"},tw=["onClick","innerHTML"],nw={class:"align-top px-2"},sw=r("option",{disabled:"",selected:""},"Type",-1),ow=["value"],iw={class:"flex items-center border rounded-md relative"},rw=r("span",{id:"loader_articles",class:"loading loading-spinner loading-xs absolute right-2 hidden"},null,-1),aw=["placeholder"],lw={key:0,class:"autocomplete-dropdown bg-base-100"},cw=["onClick","innerHTML"],dw={class:"align-top"},uw={class:"flex items-center rounded-md"},hw=["placeholder"],mw={class:"align-top"},fw={class:"flex items-center border rounded-lg"},pw={class:"inline-flex"},_w=["placeholder"],gw={class:"align-top"},yw={class:"flex items-center border rounded-md"},bw=["placeholder"],vw={key:0,class:"align-top"},ww=["value"],xw={key:1,class:"align-top"},Ew={class:"align-top"},Cw={class:"flex items-center border rounded-md"},Tw=["placeholder"],Iw=r("div",{class:"px-3 py-2.5 rounded-l-md bg-base-300 border-r"}," % ",-1),kw={key:2,class:"text-right"},Aw={key:3,class:"text-right"},Sw={key:0},Dw=["data-tip"],Pw={type:"submit",class:"bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded"},Rw={key:0,class:"fa fa-plus"},jw={key:1,class:"loading loading-spinner loading-xs"},Mw={key:1},Ow={colspan:"12",class:"font-bold text-lg pl-0 pt-10"},qw={key:1,class:"ml-2"},Nw={key:2},Bw={class:"p-2",colspan:"3"},Vw={class:"p-2"},Fw={class:"p-2",colspan:"1"},Uw={class:"p-2",colspan:"3"},Lw=["innerHTML"],Ww={class:"p-2"},Xw={class:"p-2",colspan:"2"},Hw={key:0},zw=["data-tip"],Qw=["onClick"],Gw=r("i",{class:"far fa-edit"},null,-1),Jw=[Gw],Yw=["data-tip"],Kw=["onClick"],Zw={key:0,class:"far fa-trash-alt"},$w={key:1,class:"loading loading-spinner loading-xs"},e0={key:3},t0={class:"align-top px-2",colspan:"3"},n0={class:"flex items-center border rounded-md"},s0=["placeholder"],o0={class:"align-top px-2"},i0={class:"flex items-center rounded-md"},r0=["placeholder"],a0={class:"align-top"},l0={class:"flex items-center border rounded-md"},c0=["placeholder"],d0=r("td",{class:"align-top",colspan:"3"},null,-1),u0={class:"text-right"},h0=["data-tip"],m0={key:0,class:"fa fa-plus"},f0={key:1,class:"loading loading-spinner loading-xs"},p0={class:"border-t-4"},_0={colspan:"8",class:"text-right no-border"},g0={class:"text-right"},y0={key:0,class:"line-through"},b0=r("td",null,null,-1),v0={colspan:"8",class:"text-right no-border"},w0={class:"text-right"},x0=r("td",null,null,-1),E0={key:5},C0={colspan:"8",class:"text-right no-border"},T0={class:"text-right no-border"},I0={key:6},k0={colspan:"8",class:"text-right no-border"},A0={class:"text-right no-border"},S0=r("td",null,null,-1),D0={colspan:"8",class:"text-right no-border font-bold text-xl"},P0={class:"text-right no-border font-bold text-xl"},R0=r("td",null,null,-1),j0={key:7},M0={colspan:"8",class:"text-right no-border"},O0={class:"text-right no-border"},q0={key:8},N0={colspan:"8",class:"text-right no-border"},B0={class:"text-right no-border font-bold text-xl"};function V0(t,e,s,i,n,o){const a=O("InvoiceNavBar"),l=O("remove-modal"),f=O("article-modal"),d=O("remind-invoice-modal"),m=O("edit-item-modal"),p=O("edit-disb-modal"),y=O("Card");return u(),h("div",jv,[P(a,{invoiceInfo:n.invoice,currencyDefault:o.defaultCurrency,currencyClient:o.clientCurrency,emailActive:n.settings.easy_compta_email_addon_active,qrCodeActive:n.settings.easy_compta_qrcode_addon_active,noItems:n.no_items},null,8,["invoiceInfo","currencyDefault","currencyClient","emailActive","qrCodeActive","noItems"]),P(l,{"modal-id":"modal_remove_item","show-modal":t.showRemoveModal,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:e[0]||(e[0]=_=>this.removeItem(n.selectedItem,n.SelectedInvoiceId)),onCancel:e[1]||(e[1]=_=>t.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),P(l,{"modal-id":"modal_remove_disb","show-modal":t.showRemoveModalDisb,title:o.translations.are_you_sure,message:o.translations.no_turning_back,confirmText:o.translations.yes_delete_it,cancelText:o.translations.cancel,onConfirm:e[2]||(e[2]=_=>this.removeDisb(n.selectedDisb,n.SelectedInvoiceId)),onCancel:e[3]||(e[3]=_=>t.showRemoveModalDisb=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),P(f,{"show-modal":n.showArticlesModal,"modal-id":"modal_articles","modal-title":o.translations.select,onSelectArticle:o.applySelectedArticle,onClose:e[4]||(e[4]=_=>n.showArticlesModal=!1)},null,8,["show-modal","modal-title","onSelectArticle"]),n.settings.easy_compta_email_addon_active==1?(u(),h("div",Mv,[P(d,{loading:t.loadingModal,"show-modal":n.RemindInvoiceModal,"modal-id":"modal_send_remind",client:n.client_detail,"invoice-id":n.invoice.id,subject:n.settings.remind_invoice_subject,content:n.settings.remind_invoice_content,onClose:e[5]||(e[5]=_=>n.RemindInvoiceModal=!1)},null,8,["loading","show-modal","client","invoice-id","subject","content"])])):g("",!0),n.toast.visible?(u(),h("div",{key:1,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),n.loading?(u(),h("div",Ov,Nv)):g("",!0),o.isInvoiceOverdue&&n.invoice.status=="unpaid"?(u(),h("div",Bv,[r("div",Vv,[Fv,r("span",null,c(o.translations.invoice_overdue),1),n.settings.easy_compta_email_addon_active==1?(u(),h("div",Uv,[r("button",{onClick:e[6]||(e[6]=J(_=>o.sendRemind(n.invoice.client_id),["prevent"])),class:"btn btn-sm btn-primary"},c(o.translations.remind_invoice),1)])):(u(),h("div",{key:1,class:"tooltip tooltip-bottom tooltip-warning","data-tip":o.translations.active_email_addon},[r("button",Wv,c(o.translations.remind_invoice),1)],8,Lv))])])):g("",!0),P(y,{topMargin:"mt-8",id:"invoice-content"},{default:me(()=>[r("div",Xv,[r("div",Hv,[r("div",null,[r("img",{src:n.settings.logo_url,style:no({width:n.settings.logo_width+"px"}),alt:"Logo"},null,12,zv)])]),r("div",Qv,[r("p",Gv,c(n.invoice.invoice_number),1),r("div",null,[C(c(o.translations.created_at)+": ",1),r("strong",null,c(n.invoice.created_at),1)]),r("div",null,[C(c(o.translations.due_date)+": ",1),r("strong",null,c(n.invoice.due_date),1)]),r("div",null,[C(c(o.translations.status)+": ",1),n.invoice.status=="draft"?(u(),h("span",Jv,c(o.translations.draft),1)):g("",!0),n.invoice.status=="unpaid"?(u(),h("span",Yv,c(o.translations.unpaid),1)):g("",!0),n.invoice.status=="paid"?(u(),h("span",Kv,c(o.translations.paid),1)):g("",!0)])])]),r("div",Zv,[r("div",null,[r("strong",null,c(o.translations.bill_to)+":",1),r("h4",null,[r("strong",null,c(n.client_detail.company_name),1)]),r("p",null,[C(c(n.client_detail.address),1),$v,C(" "+c(n.client_detail.postal_code)+", "+c(n.client_detail.city)+" ",1),e1,C(" "+c(n.client_detail.country),1),t1,n.client_detail.phone?(u(),h("a",{key:0,href:"tel:"+n.client_detail.phone},c(n.client_detail.phone),9,n1)):g("",!0)])]),r("div",null,[r("strong",null,c(o.translations.received_from)+":",1),r("h4",null,[r("strong",null,c(n.settings.company_name),1)]),r("p",null,[C(c(n.settings.company_address),1),s1,C(" "+c(n.settings.postal_code)+", "+c(n.settings.city)+" ",1),o1,C(" "+c(n.settings.country),1),i1,n.settings.company_phone?(u(),h("a",{key:0,href:"tel:"+n.settings.company_phone},c(n.settings.company_phone),9,r1)):g("",!0),a1,n.settings.mobile_phone?(u(),h("a",{key:1,href:"tel:"+n.settings.mobile_phone},c(n.settings.mobile_phone),9,l1)):g("",!0)])])]),P(m,{loading:t.loadingModal,"show-modal":n.editItemsModal,"modal-id":"modal_edit_item","modal-title":o.translations.edit_item,item:n.selectedItem,onClose:e[7]||(e[7]=_=>n.editItemsModal=!1),onItemEdited:o.fetchItems},null,8,["loading","show-modal","modal-title","item","onItemEdited"]),P(p,{loading:t.loadingModal,"show-modal":n.editDisbModal,"modal-id":"modal_edit_disb","modal-title":o.translations.edit_item,disb:n.selectedDisb,onClose:e[8]||(e[8]=_=>n.editDisbModal=!1),onDisbEdited:o.fetchDisbursements},null,8,["loading","show-modal","modal-title","disb","onDisbEdited"]),r("form",{onSubmit:e[34]||(e[34]=J((..._)=>o.submitItems&&o.submitItems(..._),["prevent"]))},[r("table",c1,[r("thead",null,[r("tr",null,[d1,r("th",u1,c(o.translations.item_ref),1),r("th",h1,c(o.translations.item_name),1),r("th",m1,c(o.translations.description),1),r("th",f1,c(o.translations.quantity),1),r("th",p1,c(o.translations.unit_price),1),n.settings.vat_active==1?(u(),h("th",_1,c(o.translations.vat),1)):(u(),h("th",g1)),r("th",y1,c(o.translations.discount),1),r("th",b1,c(o.translations.total),1),v1])]),r("tbody",null,[(u(!0),h(F,null,U(n.invoiceItems,(_,v)=>(u(),h("tr",{key:_.id||v},[r("td",w1,[n.invoice.status=="draft"?(u(),h("i",x1)):g("",!0)]),r("td",null,c(_.item_ref),1),r("td",null,[_.category_name?(u(),h("div",E1,c(_.category_name),1)):g("",!0),r("div",null,c(_.item_name),1)]),r("td",{innerHTML:o.nl2br(_.item_description)},null,8,C1),r("td",T1,c(_.quantity),1),r("td",I1,[C(c(_.unit_price),1),n.default_currency_symbol==n.client_currency?(u(),h("span",k1,c(n.default_currency_symbol),1)):(u(),h("span",A1,c(n.client_currency),1))]),n.settings.vat_active==1?(u(),h("td",S1,c(_.vat_rate)+"% ",1)):(u(),h("td",D1)),n.settings.vat_active==1?(u(),h("td",P1,[C(c(_.discount)+"% ",1),R1,C(" "+c(o.calculateDiscountAmountWithVAT(_.quantity,_.unit_price,_.vat_rate,_.discount)),1)])):(u(),h("td",j1,[C(c(_.discount)+"% ",1),M1,C(" "+c(o.calculateDiscountAmount(_.quantity,_.unit_price,_.discount)),1)])),r("td",O1,[C(c(_.total_amount)+" ",1),n.default_currency_symbol==n.client_currency?(u(),h("span",q1,c(n.default_currency_symbol),1)):(u(),h("span",N1,c(n.client_currency),1))]),r("td",null,[n.invoice.status=="draft"?(u(),h("div",B1,[r("span",{class:"lg:tooltip","data-tip":o.translations.edit},[r("button",{onClick:J(x=>o.editItem(_.id),["prevent"]),class:"bg-purple-500 hover:bg-purple-700 text-white font-bold py-2 px-3 rounded"},L1,8,F1)],8,V1),r("span",{class:"lg:tooltip","data-tip":o.translations.delete},[r("button",{onClick:J(x=>o.confirmremoveItem(_.id,n.invoice.id),["prevent"]),class:"bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-3 mx-2 rounded"},[_.loading_del?g("",!0):(u(),h("i",H1)),_.loading_del?(u(),h("span",z1)):g("",!0)],8,X1)],8,W1)])):g("",!0)])]))),128)),n.invoice.status=="draft"?(u(),h("tr",Q1,[r("td",G1,[r("span",{class:"cursor-pointer",onClick:e[9]||(e[9]=J((..._)=>o.ShowModalArticles&&o.ShowModalArticles(..._),["prevent"]))},Y1)]),r("td",K1,[r("div",Z1,[D(r("input",{type:"text","onUpdate:modelValue":e[10]||(e[10]=_=>n.newItem.item_ref=_),onInput:e[11]||(e[11]=(..._)=>o.fetchRefs&&o.fetchRefs(..._)),onFocus:e[12]||(e[12]=_=>n.showDropdownRef=!0),placeholder:o.translations.item_ref,class:"w-full p-2.5 input-xs outline-none"},null,40,$1),[[W,n.newItem.item_ref]]),n.showDropdownRef&&n.refs.length?(u(),h("ul",ew,[(u(!0),h(F,null,U(n.refs,_=>(u(),h("li",{key:_.ref,onClick:v=>o.selectItem(_),class:"autocomplete-item",innerHTML:o.highlightMatch(_.ref)},null,8,tw))),128))])):g("",!0)])]),r("td",nw,[D(r("select",{class:"select select-xs w-full mb-1 ecwp-select","onUpdate:modelValue":e[13]||(e[13]=_=>n.newItem.item_category=_)},[sw,(u(!0),h(F,null,U(n.categories,_=>(u(),h("option",{key:_.id,value:_.id},c(_.name),9,ow))),128))],512),[[ue,n.newItem.item_category]]),r("div",iw,[rw,D(r("input",{type:"text","onUpdate:modelValue":e[14]||(e[14]=_=>n.newItem.item_name=_),onInput:e[15]||(e[15]=(..._)=>o.fetchArticles&&o.fetchArticles(..._)),onFocus:e[16]||(e[16]=_=>n.showDropdown=!0),placeholder:o.translations.item_name,class:"w-full p-2.5 bg-transparent input-xs outline-none"},null,40,aw),[[W,n.newItem.item_name]]),n.showDropdown&&n.articles.length?(u(),h("ul",lw,[(u(!0),h(F,null,U(n.articles,_=>(u(),h("li",{key:_.name,onClick:v=>o.selectItem(_),class:"autocomplete-item bt-primary",innerHTML:o.highlightMatch(_.name)},null,8,cw))),128))])):g("",!0)])]),r("td",dw,[r("div",uw,[D(r("textarea",{"onUpdate:modelValue":e[17]||(e[17]=_=>n.newItem.item_description=_),placeholder:o.translations.item_description,class:"textarea textarea-bordered input-xs w-full",onInput:e[18]||(e[18]=_=>o.resize()),ref:"textarea"},null,40,hw),[[W,n.newItem.item_description]])])]),r("td",mw,[r("div",fw,[r("div",pw,[r("div",{class:"select-none border py-3 px-2 cursor-pointer bg-base-300 hover:bg-gray-200 rounded-l",onClick:e[19]||(e[19]=(..._)=>o.decrease&&o.decrease(..._))}," - "),D(r("input",{type:"text",pattern:"([0-9]+.{0,1}[0-9]*,{0,1})*[0-9]","onUpdate:modelValue":e[20]||(e[20]=_=>n.newItem.quantity=_),placeholder:o.translations.quantity,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[21]||(e[21]=(..._)=>o.updateTotal&&o.updateTotal(..._))},null,40,_w),[[W,n.newItem.quantity]]),r("div",{class:"select-none border py-3 px-2 cursor-pointer bg-base-300 hover:bg-gray-200 rounded-r",onClick:e[22]||(e[22]=(..._)=>o.increase&&o.increase(..._))}," + ")])])]),r("td",gw,[r("div",yw,[D(r("input",{type:"text",pattern:"([0-9]+.{0,1}[0-9]*,{0,1})*[0-9]","onUpdate:modelValue":e[23]||(e[23]=_=>n.newItem.unit_price=_),placeholder:o.translations.unit_price,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[24]||(e[24]=(..._)=>o.updateTotal&&o.updateTotal(..._))},null,40,bw),[[W,n.newItem.unit_price]])])]),n.settings.vat_active==1?(u(),h("td",vw,[D(r("select",{"onUpdate:modelValue":e[25]||(e[25]=_=>n.newItem.vat_rate=_),onChange:e[26]||(e[26]=(..._)=>o.updateTotal&&o.updateTotal(..._)),class:"select select-md w-full mb-1 ecwp-select min-w-20"},[(u(!0),h(F,null,U(n.list_vats,_=>(u(),h("option",{key:_,value:_.rate},c(_.rate)+"% ",9,ww))),128))],544),[[ue,n.newItem.vat_rate]])])):(u(),h("td",xw)),r("td",Ew,[r("div",Cw,[D(r("input",{type:"number","onUpdate:modelValue":e[27]||(e[27]=_=>n.newItem.discount=_),min:"0",max:"100",placeholder:o.translations.discount,class:"w-full p-2.5 bg-transparent outline-none max-w-40 min-w-10",onInput:e[28]||(e[28]=(..._)=>o.updateTotal&&o.updateTotal(..._))},null,40,Tw),[[W,n.newItem.discount]]),Iw])]),n.settings.vat_active==1?(u(),h("td",kw,c(o.calculateTotalWithVat(n.newItem.quantity,n.newItem.unit_price,n.newItem.vat_rate,n.newItem.discount)),1)):(u(),h("td",Aw,c(o.calculateTotal(n.newItem.quantity,n.newItem.unit_price,n.newItem.discount)),1)),r("td",null,[n.invoice.status=="draft"?(u(),h("div",Sw,[r("span",{class:"lg:tooltip","data-tip":o.translations.add},[r("button",Pw,[n.loading_add?g("",!0):(u(),h("i",Rw)),n.loading_add?(u(),h("span",jw)):g("",!0)])],8,Dw)])):g("",!0)])])):g("",!0),n.settings.active_disbursements==1?(u(),h("tr",Mw,[r("td",Ow,[n.invoice.status=="draft"?(u(),h("button",{key:0,onClick:e[29]||(e[29]=J((..._)=>o.toggleDisbursements&&o.toggleDisbursements(..._),["prevent"])),class:"btn btn-primary py-2 px-4 rounded text-white"},[r("i",{class:I({"fas fa-plus":!n.showDisbursements,"fas fa-minus":n.showDisbursements})},null,2)])):g("",!0),n.invoice.status=="draft"||n.disbursementsExist?(u(),h("span",qw,c(o.translations.disbursements),1)):g("",!0)])])):g("",!0),n.settings.active_disbursements==1&&n.disbursementsList&&n.disbursementsList.length>0?(u(),h("tr",Nw,[r("th",Bw,c(o.translations.item_name),1),r("th",Vw,c(o.translations.description),1),r("th",Fw,c(o.translations.unit_price),1)])):g("",!0),(u(!0),h(F,null,U(n.disbursementsList,_=>(u(),h("tr",{key:_.id},[r("td",Uw,c(_.title),1),r("td",{class:"p-2",innerHTML:o.nl2br(_.description)},null,8,Lw),r("td",Ww,c(o.calculateTotal(1,_.unit_price,0)),1),r("td",Xw,[n.invoice.status=="draft"?(u(),h("div",Hw,[r("span",{class:"lg:tooltip","data-tip":o.translations.edit},[r("button",{onClick:J(v=>o.editDisb(_.id),["prevent"]),class:"bg-purple-500 hover:bg-purple-700 text-white font-bold py-2 px-3 rounded"},Jw,8,Qw)],8,zw),r("span",{class:"lg:tooltip","data-tip":o.translations.delete},[r("button",{onClick:J(v=>o.confirmremoveDisb(_.id,n.invoice.id),["prevent"]),class:"bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-3 mx-2 rounded"},[_.loading_del?g("",!0):(u(),h("i",Zw)),_.loading_del?(u(),h("span",$w)):g("",!0)],8,Kw)],8,Yw)])):g("",!0)])]))),128)),n.settings.active_disbursements==1&&n.showDisbursements&&n.invoice.status=="draft"?(u(),h("tr",e0,[r("td",t0,[r("div",n0,[D(r("input",{type:"text","onUpdate:modelValue":e[30]||(e[30]=_=>n.disbursementsItem.title=_),placeholder:o.translations.title,class:"w-full p-2.5 bg-transparent input-xs outline-none"},null,8,s0),[[W,n.disbursementsItem.title]])])]),r("td",o0,[r("div",i0,[D(r("textarea",{"onUpdate:modelValue":e[31]||(e[31]=_=>n.disbursementsItem.description=_),placeholder:o.translations.description,class:"textarea textarea-bordered input-xs w-full"},null,8,r0),[[W,n.disbursementsItem.description]])])]),r("td",a0,[r("div",l0,[D(r("input",{type:"text",pattern:"([0-9]+.{0,1}[0-9]*,{0,1})*[0-9]","onUpdate:modelValue":e[32]||(e[32]=_=>n.disbursementsItem.unit_price=_),placeholder:o.translations.price,class:"w-full p-2.5 bg-transparent input-xs outline-none"},null,8,c0),[[W,n.disbursementsItem.unit_price]])])]),d0,r("td",u0,c(o.calculateTotal(1,n.disbursementsItem.unit_price,0)),1),r("td",null,[r("span",{class:"lg:tooltip","data-tip":o.translations.add_disbursements},[r("button",{type:"submit",class:"bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded",onClick:e[33]||(e[33]=J((..._)=>o.addDisbursements&&o.addDisbursements(..._),["prevent"]))},[n.loading_add_disbursements?g("",!0):(u(),h("i",m0)),n.loading_add_disbursements?(u(),h("span",f0)):g("",!0)])],8,h0)])])):g("",!0),r("tr",p0,[r("td",_0,[r("strong",null,c(o.translations.subtotal),1)]),r("td",g0,[o.totalAmount!==o.totalAmountWithoutDiscount?(u(),h("span",y0,c(o.totalAmountWithoutDiscount),1)):g("",!0),C(" "+c(o.totalAmount),1)]),b0]),n.settings.vat_active==1?(u(!0),h(F,{key:4},U(o.getUniqueVATRates(),(_,v)=>(u(),h("tr",{key:v},[r("td",v0,[r("strong",null,c(o.translations.tax)+" ("+c(_)+"%) ",1)]),r("td",w0,c(o.calculateVATForRate(_)),1),x0]))),128)):g("",!0),n.invoice.shipping_amount?(u(),h("tr",E0,[r("td",C0,[r("strong",null,c(o.translations.shipping_fees),1)]),r("td",T0,c(o.formatShippingAmout(n.invoice.shipping_amount)),1)])):g("",!0),n.settings.active_disbursements==1&&n.disbursementsExist?(u(),h("tr",I0,[r("td",k0,[r("strong",null,c(o.translations.total_disbursements),1)]),r("td",A0,c(o.totalDisbursements()),1),S0])):g("",!0),r("tr",null,[r("td",D0,[r("strong",null,c(o.translations.total),1)]),r("td",P0,c(o.calculateTotalAmountWithVAT()),1),R0]),n.client_currency!=n.default_currency_symbol?(u(),h("tr",j0,[r("td",M0,[r("strong",null,c(o.translations.exchange_rate),1)]),r("td",O0,c(n.invoice.exchange_rate),1)])):g("",!0),n.client_currency!=n.default_currency_symbol?(u(),h("tr",q0,[r("td",N0,[r("strong",null,c(o.translations.total)+" "+c(n.default_currency_symbol),1)]),r("td",B0,c(o.totalAmountDefaultCurrency)+c(n.default_currency_symbol),1)])):g("",!0)])])],32)]),_:1})])}var F0=ne(Rv,[["render",V0]]);const U0={name:"InvoiceNew",components:{Card:Ze,ModelSelect:hn,VueDatePicker:Nt,AddClientModal:Ro},data(){return{invoice:{invoice_number:"",due_date:"",client_id:"",client:null,status:"",exchange_rate:0},showError:!1,loading:!1,loadingBtn:!1,clients:[],clientOptions:[],settings:[],last_invoice_number:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return t=>{if(!t)return"";const e=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getFullYear();return`${e}-${s}-${i}`}},currencyMismatch(){const t=this.clients.find(e=>e.id===this.invoice.client_id);return t&&this.settings.default_currency!==t.currency_id}},mounted(){this.fetchClients(),this.fetchSettings()},methods:{AddNew(){modal_clients.showModal()},cancelAction(){this.$router.push("/invoices")},fetchClients(){this.loading=!0,fetch("/wp-json/my-easy-compta/v1/list-clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.clients=t.clients,this.clientOptions=this.clients.map(e=>({value:e.id,text:`${e.company_name} - ${e.email} (${e.currency_symbol})`}))}).catch(t=>{console.error("Error fetching clients:",t)}).finally(()=>{this.loading=!1})},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,t.ok){const e=await t.json();this.settings=e;const s=`${this.settings.invoice_prefix}_${String(this.settings.last_invoice_id).padStart(4,"0")}`;this.invoice.number=s}else{const e=await t.json()}}catch{this.loading=!1}},handleClientChange(){const t=this.clients.find(e=>e.id===this.invoice.client_id);t&&this.settings.default_currency!==t.currency_id?this.invoice.exchange_rate=1:this.invoice.exchange_rate=0},submitInvoice(){if(!this.invoice.due_date||!this.invoice.client_id||!this.invoice.status){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.loadingBtn=!0,fetch("/wp-json/my-easy-compta/v1/invoices",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.invoice)}).then(t=>{if(!t.ok)throw new Error("Network response was not ok");return t.json()}).then(t=>{t.success?(this.loadingBtn=!1,this.showToast(t.message,"alert-success"),this.$router.push({name:"InvoiceViewDetail",params:{id:t.id}})):(console.error("Error submitting invoice:",t.message),this.showToast(t.message,"alert-error"),this.loadingBtn=!1)}).catch(t=>{console.error("Error submitting invoice:",t),this.showToast(t,"alert-error"),this.loadingBtn=!1})},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},L0={class:"pt-2 pr-4"},W0={class:"flex justify-between items-center mb-4"},X0={class:"card-title"},H0=r("div",{class:"divider mt-2"},null,-1),z0={key:0,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},Q0={class:"grid grid-cols-2 gap-4"},G0={class:"ecwp-group form-group mb-4"},J0={for:"invoiceNumber",class:"ecwp-label"},Y0={class:"ecwp-group form-group mb-4"},K0={for:"invoiceDate",class:"ecwp-label"},Z0={class:"mb-4"},$0={class:"flex gap-2 items-end"},ex=r("i",{class:"fas fa-plus"},null,-1),tx=[ex],nx={class:"ecwp-group form-group w-full"},sx={for:"client",class:"ecwp-label"},ox={class:"ecwp-group form-group mb-4"},ix={for:"status",class:"ecwp-label"},rx={value:"draft"},ax={key:0,class:"ecwp-group form-group mb-4"},lx={for:"exchangeRate",class:"ecwp-label"},cx={class:"flex justify-between"},dx=["disabled"],ux={key:0,class:"loading loading-spinner loading-sm"};function hx(t,e,s,i,n,o){const a=O("VueDatePicker"),l=O("model-select"),f=O("Card"),d=O("AddClientModal");return u(),h("div",L0,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),P(f,{topMargin:"mt-8",modalType:"modal_invoice_new"},{default:me(()=>[r("div",W0,[r("h2",X0,c(o.translations.new_invoice),1)]),H0,n.loading?(u(),h("div",z0)):g("",!0),r("form",{onSubmit:e[7]||(e[7]=J((...m)=>o.submitInvoice&&o.submitInvoice(...m),["prevent"]))},[r("div",Q0,[r("div",G0,[r("label",J0,c(o.translations.invoice_number),1),D(r("input",{type:"text",id:"invoiceNumber","onUpdate:modelValue":e[0]||(e[0]=m=>n.invoice.number=m),class:"ecwp-input input input-bordered w-full",disabled:"disabled"},null,512),[[W,n.invoice.number]])]),r("div",Y0,[r("label",K0,c(o.translations.due_date),1),P(a,{class:I(["ecwp-input ecwp-date input input-bordered w-full",[!n.invoice.due_date&&n.showError?"input-error":""]]),id:"invoiceDate",modelValue:n.invoice.due_date,"onUpdate:modelValue":e[1]||(e[1]=m=>n.invoice.due_date=m),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date,locale:"fr"},null,8,["class","modelValue","format","min-date"])]),r("div",Z0,[r("div",$0,[r("button",{type:"button",class:"btn btn-primary",onClick:e[2]||(e[2]=(...m)=>o.AddNew&&o.AddNew(...m))},tx),r("div",nx,[r("label",sx,c(o.translations.company_name),1),P(l,{modelValue:n.invoice.client_id,"onUpdate:modelValue":e[3]||(e[3]=m=>n.invoice.client_id=m),options:n.clientOptions,label:"text","track-by":"value",placeholder:o.translations.select,class:I(["ecwp-input input input-bordered w-full",[!n.invoice.client_id&&n.showError?"input-error":""]])},null,8,["modelValue","options","placeholder","class"])])])]),r("div",ox,[r("label",ix,c(o.translations.status),1),D(r("select",{id:"status","onUpdate:modelValue":e[4]||(e[4]=m=>n.invoice.status=m),class:I(["ecwp-input select select-bordered w-full",[!n.invoice.status&&n.showError?"input-error":""]])},[r("option",rx,c(o.translations.draft),1)],2),[[ue,n.invoice.status]])]),o.currencyMismatch?(u(),h("div",ax,[r("label",lx,c(o.translations.exchange_rate),1),D(r("input",{type:"text",id:"exchangeRate","onUpdate:modelValue":e[5]||(e[5]=m=>n.invoice.exchange_rate=m),class:"ecwp-input input input-bordered w-full",required:""},null,512),[[W,n.invoice.exchange_rate]])])):g("",!0)]),r("div",cx,[r("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:e[6]||(e[6]=(...m)=>o.cancelAction&&o.cancelAction(...m))},c(o.translations.cancel),1),r("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(c(o.translations.submit)+" ",1),n.loadingBtn?(u(),h("span",ux)):g("",!0)],8,dx)])],32)]),_:1}),P(d,{onClientAdded:o.fetchClients},null,8,["onClientAdded"])])}var mx=ne(U0,[["render",hx]]);const fx={name:"invoiceEdit",components:{Card:Ze,ModelSelect:hn,VueDatePicker:Nt},data(){return{invoice:{invoice_number:"",due_date:"",client_id:"",client:null,status:"paid",exchange_rate:0},showError:!1,loading:!1,loadingBtn:!1,clients:[],clientOptions:[],settings:[],toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return t=>{if(!t)return"";const e=t.getDate().toString().padStart(2,"0"),s=(t.getMonth()+1).toString().padStart(2,"0"),i=t.getFullYear();return`${e}-${s}-${i}`}},currencyMismatch(){const t=this.clients.find(e=>e.id===this.invoice.client_id);return t&&this.settings.default_currency!==t.currency_id}},mounted(){this.fetchClients(),this.fetchSettings(),this.fetchInvoiceDetails()},methods:{cancelAction(){this.$router.push("/invoices")},fetchClients(){this.loading=!0,fetch("/wp-json/my-easy-compta/v1/list-clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.clients=t.clients,this.clientOptions=this.clients.map(e=>({value:e.id,text:`${e.company_name} - ${e.email} (${e.currency_symbol})`})),this.invoice.client_id&&this.setClientById(this.invoice.client_id)}).catch(t=>{console.error("Error fetching clients:",t)}).finally(()=>{this.loading=!1})},async fetchSettings(){try{this.loading=!0;const t=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,t.ok){const e=await t.json();this.settings=e}else{const e=await t.json();console.error("Error fetching settings:",e)}}catch(t){this.loading=!1,console.error("Error fetching settings:",t)}},fetchInvoiceDetails(){const t=this.$route.params.id;!t||(this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/${t}`,{headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(e=>e.json()).then(e=>{e?this.invoice=e:(console.error("Error fetching invoice details:",e.message),this.showToast(e.message,"alert-error"))}).catch(e=>{console.error("Error fetching invoice details:",e),this.showToast(e,"alert-error")}).finally(()=>{this.loading=!1}))},setClientById(t){this.invoice.client=this.clients.find(e=>e.id===t)||null},handleClientChange(){const t=this.clients.find(e=>e.id===this.invoice.client_id);t&&this.settings.default_currency!==t.currency_id?this.invoice.exchange_rate=1:this.invoice.exchange_rate=0},submitInvoice(){if(!this.invoice.due_date||!this.invoice.client_id||!this.invoice.status){this.showError=!0,this.showToast("Veuillez remplir tous les champs obligatoires.","alert-error");return}this.loadingBtn=!0,fetch(`/wp-json/my-easy-compta/v1/invoices/${this.$route.params.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.invoice)}).then(t=>{if(!t.ok)throw this.loadingBtn=!1,new Error("Network response was not ok");return t.json()}).then(t=>{t.success?(this.loadingBtn=!1,this.showToast(t.message,"alert-success"),this.$router.push({name:"InvoiceViewDetail",params:{id:t.id}})):(this.loadingBtn=!1,console.error("Error submitting invoice:",t.message),this.showToast(t.message,"alert-error"))}).catch(t=>{this.loadingBtn=!1,console.error("Error submitting invoice:",t),this.showToast(t,"alert-error")})},showToast(t,e){this.toast.message=t,this.toast.type=e,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}}},px={class:"pt-2 pr-4"},_x={class:"flex justify-between items-center mb-4"},gx={class:"card-title"},yx=r("div",{class:"divider mt-2"},null,-1),bx={key:0,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},vx={class:"grid grid-cols-2 gap-4"},wx={class:"ecwp-group form-group mb-4"},xx={for:"invoiceNumber",class:"ecwp-label"},Ex={class:"ecwp-group form-group mb-4"},Cx={for:"invoiceDate",class:"ecwp-label"},Tx={class:"ecwp-group form-group mb-4"},Ix={for:"client",class:"ecwp-label"},kx={class:"ecwp-group form-group mb-4"},Ax={for:"status",class:"ecwp-label"},Sx={value:"draft",selected:""},Dx={key:0,class:"ecwp-group form-group mb-4"},Px={for:"exchangeRate",class:"ecwp-label"},Rx={class:"flex justify-between"},jx=["disabled"],Mx={key:0,class:"loading loading-spinner loading-sm"};function Ox(t,e,s,i,n,o){const a=O("VueDatePicker"),l=O("model-select"),f=O("Card");return u(),h("div",px,[n.toast.visible?(u(),h("div",{key:0,class:I(["toast",n.toast.position]),style:{zIndex:9999}},[r("div",{class:I(["alert",n.toast.type,"text-white"])},[r("span",null,c(n.toast.message),1)],2)],2)):g("",!0),P(f,{topMargin:"mt-8",modalType:"modal_invoice_new"},{default:me(()=>[r("div",_x,[r("h2",gx,c(o.translations.edit_invoice),1)]),yx,n.loading?(u(),h("div",bx)):g("",!0),r("form",{onSubmit:e[6]||(e[6]=J((...d)=>o.submitInvoice&&o.submitInvoice(...d),["prevent"]))},[r("div",vx,[r("div",wx,[r("label",xx,c(o.translations.invoice_number),1),D(r("input",{type:"text",id:"invoiceNumber","onUpdate:modelValue":e[0]||(e[0]=d=>n.invoice.invoice_number=d),class:"ecwp-input input input-bordered w-full",disabled:"true"},null,512),[[W,n.invoice.invoice_number]])]),r("div",Ex,[r("label",Cx,c(o.translations.due_date),1),P(a,{class:I(["ecwp-input ecwp-date input input-bordered w-full",[!n.invoice.due_date&&n.showError?"input-error":""]]),id:"invoiceDate",modelValue:n.invoice.due_date,"onUpdate:modelValue":e[1]||(e[1]=d=>n.invoice.due_date=d),"enable-time-picker":!1,"auto-apply":"",format:o.formattedDate,"min-date":new Date,locale:"fr"},null,8,["class","modelValue","format","min-date"])]),r("div",Tx,[r("label",Ix,c(o.translations.company_name),1),P(l,{modelValue:n.invoice.client_id,"onUpdate:modelValue":e[2]||(e[2]=d=>n.invoice.client_id=d),options:n.clientOptions,label:"text","track-by":"value",placeholder:o.translations.select,class:I(["ecwp-input input input-bordered w-full",[!n.invoice.client_id&&n.showError?"input-error":""]])},null,8,["modelValue","options","placeholder","class"])]),r("div",kx,[r("label",Ax,c(o.translations.status),1),D(r("select",{id:"status","onUpdate:modelValue":e[3]||(e[3]=d=>n.invoice.status=d),class:I(["ecwp-input select select-bordered w-full",[!n.invoice.status&&n.showError?"input-error":""]])},[r("option",Sx,c(o.translations.draft),1)],2),[[ue,n.invoice.status]])]),o.currencyMismatch?(u(),h("div",Dx,[r("label",Px,c(o.translations.exchange_rate),1),D(r("input",{type:"text",id:"exchangeRate","onUpdate:modelValue":e[4]||(e[4]=d=>n.invoice.exchange_rate=d),class:"ecwp-input input input-bordered w-full",required:""},null,512),[[W,n.invoice.exchange_rate]])])):g("",!0)]),r("div",Rx,[r("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:e[5]||(e[5]=(...d)=>o.cancelAction&&o.cancelAction(...d))},c(o.translations.cancel),1),r("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(c(o.translations.save)+" ",1),n.loadingBtn?(u(),h("span",Mx)):g("",!0)],8,jx)])],32)]),_:1})])}var qx=ne(fx,[["render",Ox]]);const ye=dn;(function(t,e){const s=dn,i=t();for(;[];)try{if(parseInt(s(347))/1*(parseInt(s(334))/2)+parseInt(s(339))/3*(parseInt(s(344))/4)+parseInt(s(340))/5+parseInt(s(351))/6*(-parseInt(s(337))/7)+-parseInt(s(346))/8*(-parseInt(s(331))/9)+-parseInt(s(332))/10*(-parseInt(s(338))/11)+-parseInt(s(336))/12===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(un,107449);function dn(t,e){const s=un();return dn=function(i,n){return i=i-331,s[i]},dn(t,e)}function un(){const t=["/invoice/detail/:id","6kZDNRr","QuoteNew","Quote","/invoices","/quote/new","72zCelvB","20cpuPEp","Invoice","2064wNbdMG","QuoteEdit","7235484hdUdeR","121450YfuOKo","835802GUCJbG","11319ApwCgR","276605zUwEeK","/invoice/new","/quote/edit/:id","InvoiceViewDetail","172ybDWqh","/quote/detail/:id","158024KbskhN","194setAFx","InvoiceNew","/quotes"];return un=function(){return t},un()}const Nx=[{path:ye(349),name:ye(353),component:xd},{path:ye(345),name:"QuoteViewDetail",component:Pp},{path:ye(355),name:ye(352),component:l_},{path:ye(342),name:ye(335),component:Ho},{path:ye(354),name:ye(333),component:bg},{path:ye(350),name:ye(343),component:F0},{path:"/invoice/edit/:id",name:"InvoiceEdit",component:qx},{path:ye(341),name:ye(348),component:mx}],Xx=Cl({history:Za(),routes:Nx});export{Ro as A,Xx as r};
  • my-easy-compta/trunk/assets/dist/invoices.min.js

    r3198779 r3233000  
    1 import{_ as i,d as _,o as b,H as f,f as u,h as m}from"./plugin-vue_export-helper.min.js";import{r as I}from"./index.min.js";import"./RemoveAlert.min.js";import"./VueSearchSelect.min.js";import"./vue-datepicker.min.js";import"./api.min.js";import"./vue3-editor.common.min.js";const h={name:"Invoices",mounted(){this.$router.push("/invoices")}};function d(r,n,t,e,a,p){const c=_("router-view");return b(),f(c)}var v=i(h,[["render",d]]);const x=s;function o(){const r=["1874444cYjBha","8508ziFIot","4389120SfgMwj","1891386MlBAzU","1608ThcFFh","115dvZyYA","6115557pGfACO","mount","use","70NyqMMh","69558LTXDqx","1iKIFCY","5359608IabFkJ"];return o=function(){return r},o()}(function(r,n){const t=s,e=r();for(;[];)try{if(-parseInt(t(180))/1*(parseInt(t(185))/2)+parseInt(t(173))/3*(parseInt(t(183))/4)+parseInt(t(174))/5*(parseInt(t(179))/6)+-parseInt(t(175))/7+-parseInt(t(181))/8+parseInt(t(184))/9+-parseInt(t(178))/10*(-parseInt(t(182))/11)===n)break;e.push(e.shift())}catch{e.push(e.shift())}})(o,597924);function s(r,n){const t=o();return s=function(e,a){return e=e-173,t[e]},s(r,n)}const l=u({render:()=>m(v)});l[x(177)](I)[x(176)]("#my-easy-compta-invoices-app");
     1import{_ as c,d as i,o as _,H as u,f,h as m}from"./plugin-vue_export-helper.min.js";import{r as d}from"./index.min.js";import"./RemoveAlert.min.js";import"./VueSearchSelect.min.js";import"./vue-datepicker.min.js";import"./api.min.js";import"./vue3-editor.common.min.js";const h={name:"Invoices",mounted(){this.$router.push("/invoices")}};function I(r,n,t,e,s,x){const p=i("router-view");return _(),u(p)}var b=c(h,[["render",I]]);const l=o;function o(r,n){const t=a();return o=function(e,s){return e=e-426,t[e]},o(r,n)}(function(r,n){const t=o,e=r();for(;[];)try{if(-parseInt(t(433))/1+parseInt(t(435))/2*(parseInt(t(426))/3)+-parseInt(t(429))/4+parseInt(t(430))/5+parseInt(t(434))/6*(parseInt(t(427))/7)+-parseInt(t(431))/8+-parseInt(t(428))/9*(-parseInt(t(436))/10)===n)break;e.push(e.shift())}catch{e.push(e.shift())}})(a,601760);function a(){const r=["7qfryxV","790821RaFqfp","3783472WcRvDh","1245265LoidVy","2711880NFAopl","#my-easy-compta-invoices-app","92774RTQHkS","5981496mEkBxZ","939622zMdUfu","30UMhxpS","3rEjiol"];return a=function(){return r},a()}const v=f({render:()=>m(b)});v.use(d).mount(l(432));
  • my-easy-compta/trunk/assets/dist/payments.min.js

    r3198779 r3233000  
    1 import{_ as T,d as g,o as l,c as r,n as _,a as e,t as d,g as f,F as p,r as h,w as j,i as y,v as B,j as v,H as V,k as b,l as C,e as k,m as I,f as A,h as F}from"./plugin-vue_export-helper.min.js";import{C as D,R as S}from"./RemoveAlert.min.js";import{V as W}from"./vue-datepicker.min.js";import{g as U,b as R,s as N,f as X}from"./api.min.js";const L={components:{VueDatePicker:W},props:{loading:{type:Boolean,default:!1},showModal:{type:Boolean,default:!1},modalId:{type:String,required:!0},modalTitle:{type:String,default:""},payment:{type:Object,default:()=>({id:null,invoice_number:"",company_name:"",amount:"",payment_method_id:"",payment_date:"",note:"",payment_methods:[]})},disabled:{type:Boolean,default:!0},methods:Array},data(){const s=window.myEasyComptaAdmin.easyComptaTranslations;return{editedPayment:{...this.payment},loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},fields:{invoice_number:{label:s.invoice_number,disabled:this.disabled},company_name:{label:s.client,disabled:this.disabled},amount:{label:s.amount,disabled:!1},payment_method:{label:s.payment_method},payment_date:{label:s.payment_date}}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return s=>{if(!s)return"";const t=s.getDate().toString().padStart(2,"0"),i=(s.getMonth()+1).toString().padStart(2,"0"),c=s.getFullYear();return`${t}-${i}-${c}`}},paymentMethods(){return this.methods},skeletonItems(){return Array.from({length:10},(s,t)=>t)}},methods:{closeModal(){document.getElementById("modal_payment_edit").close()},async submitForm(){this.loadingBtn=!0;try{const s=await fetch(`/wp-json/my-easy-compta/v1/payments/${this.editedPayment.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.editedPayment)});if(s.ok){const t=await s.json();this.closeModal(),this.loadingBtn=!1,this.showToast(t.message,"alert-success"),this.$emit("paymentEdited")}else{this.loadingBtn=!1;const t=`Error editing payment: ${s.statusText}`;this.showToast(t,"alert-error"),console.error(t)}}catch(s){const t=s.response&&s.response.data&&s.response.data.message?s.response.data.message:"Error editing payment";this.showToast(t,"alert-error"),console.error("Error editing payment:",s),this.loadingBtn=!1}},showToast(s,t){this.toast.message=s,this.toast.type=t,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}},watch:{payment:{handler(s){this.editedPayment={...s}},immediate:!0}}},O=["id","open"],z={class:"modal-box"},q={class:"font-bold text-lg"},H={key:0},J={class:"grid grid-cols-2 gap-4"},Y=e("div",{class:"skeleton h-4 w-full mb-2"},null,-1),G=e("div",{class:"skeleton h-4 w-full"},null,-1),K=[Y,G],Q={class:"grid grid-cols-2 gap-4"},Z=["for"],$=["type","id","onUpdate:modelValue","disabled"],tt=["id"],et=["value"],st={class:"ecwp-group form-group mt-4"},nt={for:"note",class:"ecwp-label form-label"},ot={class:"form-group mt-4 flex justify-end"},at=["disabled"],lt={key:0,class:"loading loading-spinner loading-sm"};function it(s,t,i,c,n,a){const w=g("VueDatePicker");return l(),r("div",null,[n.toast.visible?(l(),r("div",{key:0,class:_(["toast",n.toast.position]),style:{zIndex:9999}},[e("div",{class:_(["alert",n.toast.type,"text-white"])},[e("span",null,d(n.toast.message),1)],2)],2)):f("",!0),e("dialog",{id:i.modalId,class:"modal",open:i.showModal},[e("div",z,[e("h3",q,d(i.modalTitle),1),e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[0]||(t[0]=(...m)=>a.closeModal&&a.closeModal(...m))}," \u2715 "),i.loading?(l(),r("div",H,[e("div",J,[(l(!0),r(p,null,h(a.skeletonItems,m=>(l(),r("div",{key:m,class:"py-2"},K))),128))])])):(l(),r("form",{key:1,onSubmit:t[4]||(t[4]=j((...m)=>a.submitForm&&a.submitForm(...m),["prevent"])),class:"form"},[e("div",Q,[(l(!0),r(p,null,h(n.fields,(m,u)=>(l(),r("div",{key:u,class:"ecwp-group form-group"},[e("label",{for:u,class:"ecwp-label form-label"},d(m.label),9,Z),u!=="payment_method"&&u!=="payment_date"?y((l(),r("input",{key:0,type:m.type||"text",id:u,"onUpdate:modelValue":o=>n.editedPayment[u]=o,class:_(["ecwp-input input","input-bordered",m.class||"w-full"]),disabled:m.disabled},null,10,$)),[[B,n.editedPayment[u]]]):u=="payment_method"?y((l(),r("select",{key:1,id:u,"onUpdate:modelValue":t[1]||(t[1]=o=>n.editedPayment.payment_method_id=o),class:_(["ecwp-input input","input-bordered",m.class||"w-full"])},[(l(!0),r(p,null,h(a.paymentMethods,o=>(l(),r("option",{key:o.id,value:o.id},d(o.method_name),9,et))),128))],10,tt)),[[v,n.editedPayment.payment_method_id]]):u=="payment_date"?(l(),V(w,{key:2,class:"ecwp-input ecwp-date input input-bordered w-full",id:"invoiceDate",modelValue:n.editedPayment.payment_date,"onUpdate:modelValue":t[2]||(t[2]=o=>n.editedPayment.payment_date=o),"enable-time-picker":!1,"auto-apply":"",format:a.formattedDate,"min-date":new Date,locale:"fr",required:""},null,8,["modelValue","format","min-date"])):f("",!0)]))),128))]),e("div",st,[e("label",nt,d(a.translations.note),1),y(e("textarea",{id:"note","onUpdate:modelValue":t[3]||(t[3]=m=>n.editedPayment.notes=m),class:"ecwp-input textarea textarea-bordered w-full",rows:"4"},null,512),[[b,n.editedPayment.notes]])]),e("div",ot,[e("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(d(a.translations.save)+" ",1),n.loadingBtn?(l(),r("span",lt)):f("",!0)],8,at)])],32))])],8,O)])}var rt=T(L,[["render",it]]);const dt={name:"Payments",components:{Card:D,PaymentEditModal:rt,RemoveModal:S},data(){return{payments:[],filteredPayments:[],filters:{invoice_number:"",client:"",payment_date:"",total_amount:"",payment_methods:""},clients:[],payments_methods:[],paymentMethods:[],paymentForm:{invoice_id:"",client_id:"",amount:"",payment_method_id:"",payment_date:""},editPaymentModal:!1,selectedPayment:null,currentPage:1,totalPages:1,paginationButtons:[],loading:!0,loadingPrice:!0,loadingModal:!1,showRemoveModal:!1,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],settings:[],default_currency_symbol:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},created(){this.fetchPaymentsWithFilters(),this.fetchClients(),this.fetchPaymentMethods(),this.loadSettings()},methods:{fetchPayments(s=1){this.loading=!0;const{perPage:t}=this;fetch(`/wp-json/my-easy-compta/v1/payments?page=${s}&per_page=${t}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(i=>i.json()).then(i=>{this.payments=i.payments,this.totalCount=i.total_count,this.totalPages=i.total_pages,this.currentPage=i.page,this.perPage=t,this.generatePaginationButtons()}).catch(i=>{console.error("Error fetching payments:",i)}).finally(()=>{this.loading=!1})},fetchPaymentsWithFilters(s=1){this.loading=!0;const{perPage:t,filters:i}=this,c=new URLSearchParams({page:s,per_page:t,...i}).toString();fetch(`/wp-json/my-easy-compta/v1/payments?${c}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(n=>n.json()).then(n=>{this.payments=n.payments,this.totalCount=n.total_count,this.totalPages=n.total_pages,this.currentPage=s,this.perPage=t,this.generatePaginationButtons()}).catch(n=>{console.error("Error fetching payments with filters:",n)}).finally(()=>{this.loading=!1})},fetchClients(){fetch("/wp-json/my-easy-compta/v1/clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>s.json()).then(s=>{this.clients=s.clients}).catch(s=>{console.error("Error fetching clients:",s)})},fetchPaymentMethods(){fetch("/wp-json/my-easy-compta/v1/payments/methods",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>s.json()).then(s=>{this.payments_methods=s}).catch(s=>{console.error("Error fetching payment Methods:",s)})},editPayment(s){this.loadingModal=!0,this.editPaymentModal=!0,modal_payment_edit.showModal(),this.fetchPaymentDetails(s)},fetchPaymentDetails(s){fetch(`/wp-json/my-easy-compta/v1/payments/details/${s}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.selectedPayment=t,this.paymentMethods=t.payment_methods,this.loadingModal=!1}).catch(t=>{console.error("Error fetching payment details:",t),this.loadingModal=!1})},generatePaginationButtons(){this.paginationButtons=U(this.currentPage,this.totalPages)},goToPage(s){s!=="..."&&this.fetchPaymentsWithFilters(s)},perPageChanged(){this.fetchPaymentsWithFilters()},formatAmount(s,t){return R(s,t,this.settings.currency_position)},showToast(s,t){N(this.toast,s,t)},closePaymentModal(){this.showPaymentModal=!1},confirmDeletePayment(s){this.selectedPayment=s,modal_payment_remove.showModal(),this.showRemoveModal=!0},deletePayment(s){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/payments/${s}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>{if(!t.ok)throw new Error("Network response was not ok");return t.json()}).then(t=>{t.success?(this.fetchPayments(),this.showToast(t.message,"alert-success")):(this.showToast(t.message,"alert-error"),console.error("Error deleting payment:",t.statusText))}).catch(t=>{console.error("Error deleting payment:",t)})},async loadSettings(){try{this.loadingPrice=!0;const{settings:s,currencySymbol:t,vatData:i}=await X();this.settings=s,this.default_currency_symbol=t,this.default_vat=i,this.loadingPrice=!1}catch(s){this.showToast(s.message,"alert-error"),this.loadingPrice=!1}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},mt={class:"pt-2 pr-4"},ct={class:"flex justify-between items-center"},ut={class:"card-title"},pt={key:0},ht={class:"btn btn-outline btn-accent rounded-full",href:"/wp-admin/admin.php?page=my-easy-compta-export#tab4"},yt=e("i",{class:"fas fa-file-export"},null,-1),_t=["data-tip"],ft={class:"btn btn-outline btn-accent rounded-full",disabled:""},gt=e("i",{class:"fas fa-file-export"},null,-1),vt=e("div",{class:"divider mt-2"},null,-1),bt={class:"flex items-center mb-4"},Pt={for:"perPageSelect",class:"mr-2"},xt=["value"],wt={class:"overflow-x-auto"},kt={class:"table w-full"},Ct={value:""},Mt=["value"],Et={value:""},Tt=["value"],jt={class:"align-top"},Bt={class:"flex justify-center"},Vt={key:0},It={key:0},At={key:1},Ft=e("span",{class:"loading loading-bars loading-sm"},null,-1),Dt=[Ft],St={class:"flex justify-end"},Wt=["data-tip"],Ut=["onClick"],Rt=e("i",{class:"fas fa-pencil-alt"},null,-1),Nt=[Rt],Xt=["data-tip"],Lt=["onClick"],Ot=e("i",{class:"far fa-trash-alt"},null,-1),zt=[Ot],qt={key:0},Ht=e("div",{class:"flex gap-4 items-center"},[e("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),e("div",{class:"flex flex-col gap-4 w-full"},[e("div",{class:"skeleton h-4 w-full"}),e("div",{class:"skeleton h-4 w-full"})])],-1),Jt=e("div",{class:"divider my-1"},null,-1),Yt=[Ht,Jt],Gt={class:"join ecwp_pagination mt-6 pt-4"},Kt=["onClick"];function Qt(s,t,i,c,n,a){const w=g("payment-edit-modal"),m=g("remove-modal"),u=g("Card");return l(),r("div",mt,[n.toast.visible?(l(),r("div",{key:0,class:_(["toast",n.toast.position]),style:{zIndex:9999}},[e("div",{class:_(["alert",n.toast.type,"text-white"])},[e("span",null,d(n.toast.message),1)],2)],2)):f("",!0),k(w,{loading:n.loadingModal,"show-modal":n.editPaymentModal,"modal-id":"modal_payment_edit","modal-title":a.translations.edit_payment,payment:n.selectedPayment,methods:n.paymentMethods,onClose:t[0]||(t[0]=o=>n.editPaymentModal=!1),onPaymentEdited:a.fetchPayments},null,8,["loading","show-modal","modal-title","payment","methods","onPaymentEdited"]),k(m,{"modal-id":"modal_payment_remove","show-modal":n.showRemoveModal,title:a.translations.are_you_sure,message:a.translations.no_turning_back,confirmText:a.translations.yes_delete_it,cancelText:a.translations.cancel,onConfirm:t[1]||(t[1]=o=>this.deletePayment(n.selectedPayment)),onCancel:t[2]||(t[2]=o=>n.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),k(u,{topMargin:"mt-8"},{default:I(()=>[e("div",ct,[e("h2",ut,d(a.translations.payments),1),n.settings.easy_compta_export_addon_active==1?(l(),r("div",pt,[e("a",ht,[C(d(a.translations.export)+" ",1),yt])])):(l(),r("div",{key:1,class:"tooltip tooltip-left tooltip-warning","data-tip":a.translations.active_export_addon},[e("button",ft,[C(d(a.translations.export)+" ",1),gt])],8,_t))]),vt,e("div",bt,[e("label",Pt,d(a.translations.display_per_page),1),y(e("select",{id:"perPageSelect","onUpdate:modelValue":t[3]||(t[3]=o=>n.perPage=o),onChange:t[4]||(t[4]=(...o)=>a.perPageChanged&&a.perPageChanged(...o))},[(l(!0),r(p,null,h(n.perPageOptions,o=>(l(),r("option",{key:o,value:o},d(o),9,xt))),128))],544),[[v,n.perPage]])]),e("div",wt,[e("table",kt,[e("thead",null,[e("tr",null,[e("th",null,[e("div",null,d(a.translations.invoice_number),1),y(e("input",{"onUpdate:modelValue":t[5]||(t[5]=o=>n.filters.invoice_number=o),onInput:t[6]||(t[6]=o=>a.fetchPaymentsWithFilters()),type:"text",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[b,n.filters.invoice_number]])]),e("th",null,[e("div",null,d(a.translations.client),1),y(e("select",{"onUpdate:modelValue":t[7]||(t[7]=o=>n.filters.client=o),onChange:t[8]||(t[8]=o=>a.fetchPaymentsWithFilters()),class:"ecwp-input input-xs input-bordered mt-2"},[e("option",Ct,d(a.translations.all),1),(l(!0),r(p,null,h(n.clients,o=>(l(),r("option",{key:o.id,value:o.company_name},d(o.company_name),9,Mt))),128))],544),[[v,n.filters.client]])]),e("th",null,[e("div",null,d(a.translations.payment_date),1),y(e("input",{"onUpdate:modelValue":t[9]||(t[9]=o=>n.filters.payment_date=o),onInput:t[10]||(t[10]=o=>a.fetchPaymentsWithFilters()),type:"date",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[b,n.filters.payment_date]])]),e("th",null,[e("div",null,d(a.translations.amount),1),y(e("input",{"onUpdate:modelValue":t[11]||(t[11]=o=>n.filters.total_amount=o),onInput:t[12]||(t[12]=o=>a.fetchPaymentsWithFilters()),type:"text",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[b,n.filters.total_amount]])]),e("th",null,[e("div",null,d(a.translations.payment_method),1),y(e("select",{"onUpdate:modelValue":t[13]||(t[13]=o=>n.filters.payment_method=o),onChange:t[14]||(t[14]=o=>a.fetchPaymentsWithFilters()),class:"ecwp-input input-xs input-bordered mt-2"},[e("option",Et,d(a.translations.all),1),(l(!0),r(p,null,h(n.payments_methods,o=>(l(),r("option",{key:o.id,value:o.method_name},d(o.method_name),9,Tt))),128))],544),[[v,n.filters.payment_method]])]),e("th",jt,d(a.translations.note),1),e("th",Bt,d(a.translations.actions),1)])]),n.loading?f("",!0):(l(),r("tbody",Vt,[(l(!0),r(p,null,h(n.payments,o=>(l(),r("tr",{key:o.id},[e("td",null,d(o.invoice_number),1),e("td",null,d(o.company_name),1),e("td",null,d(o.payment_date),1),e("td",null,[n.loadingPrice?(l(),r("div",At,Dt)):(l(),r("div",It,[e("span",null,d(a.formatAmount(o.amount,n.default_currency_symbol)),1)]))]),e("td",null,d(o.payment_method),1),e("td",null,d(o.notes),1),e("td",St,[e("span",{class:"lg:tooltip","data-tip":a.translations.edit},[e("button",{class:"btn btn-circle mx-1",onClick:M=>a.editPayment(o.id)},Nt,8,Ut)],8,Wt),e("span",{class:"lg:tooltip","data-tip":a.translations.delete},[e("button",{onClick:M=>a.confirmDeletePayment(o.id),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},zt,8,Lt)],8,Xt)])]))),128))]))]),n.loading?(l(),r("div",qt,[(l(!0),r(p,null,h(n.skeletonRows,o=>(l(),r("div",{key:o,class:"flex flex-col gap-4 w-full"},Yt))),128))])):f("",!0),e("div",Gt,[(l(!0),r(p,null,h(n.paginationButtons,o=>(l(),r("button",{key:o,class:_(["join-item btn",{"btn-disabled":o==="..."||o===n.currentPage}]),onClick:M=>a.goToPage(o)},d(o),11,Kt))),128))])])]),_:1})])}var Zt=T(dt,[["render",Qt]]);function P(s,t){const i=x();return P=function(c,n){return c=c-206,i[c]},P(s,t)}function x(){const s=["361459xyyEEz","#my-easy-compta-payments-app","191802LUdTkY","14TFTFtx","18253800AAEACR","72bkPCLe","2795WJIlBm","2606408hsoHiu","10IpUClp","2252908DpaPjF","1742148OLAtUV","mount"];return x=function(){return s},x()}const E=P;(function(s,t){const i=P,c=s();for(;[];)try{if(-parseInt(i(215))/1+-parseInt(i(211))/2*(-parseInt(i(217))/3)+-parseInt(i(212))/4+parseInt(i(209))/5*(-parseInt(i(208))/6)+-parseInt(i(206))/7*(parseInt(i(210))/8)+-parseInt(i(213))/9+parseInt(i(207))/10===t)break;c.push(c.shift())}catch{c.push(c.shift())}})(x,368482);const $t=A({render:()=>F(Zt)});$t[E(214)](E(216));
     1import{_ as T,d as g,o as l,c as r,n as _,a as e,t as d,g as f,F as p,r as h,w as j,i as y,v as B,j as v,H as V,k as b,l as C,e as k,m as I,f as D,h as S}from"./plugin-vue_export-helper.min.js";import{C as W,R as F}from"./RemoveAlert.min.js";import{V as A}from"./vue-datepicker.min.js";import{g as U,b as R,s as X,f as N}from"./api.min.js";const L={components:{VueDatePicker:A},props:{loading:{type:Boolean,default:!1},showModal:{type:Boolean,default:!1},modalId:{type:String,required:!0},modalTitle:{type:String,default:""},payment:{type:Object,default:()=>({id:null,invoice_number:"",company_name:"",amount:"",payment_method_id:"",payment_date:"",note:"",payment_methods:[]})},disabled:{type:Boolean,default:!0},methods:Array},data(){const s=window.myEasyComptaAdmin.easyComptaTranslations;return{editedPayment:{...this.payment},loadingBtn:!1,toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},fields:{invoice_number:{label:s.invoice_number,disabled:this.disabled},company_name:{label:s.client,disabled:this.disabled},amount:{label:s.amount,disabled:!1},payment_method:{label:s.payment_method},payment_date:{label:s.payment_date}}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations},formattedDate(){return s=>{if(!s)return"";const t=s.getDate().toString().padStart(2,"0"),i=(s.getMonth()+1).toString().padStart(2,"0"),c=s.getFullYear();return`${t}-${i}-${c}`}},paymentMethods(){return this.methods},skeletonItems(){return Array.from({length:10},(s,t)=>t)}},methods:{closeModal(){document.getElementById("modal_payment_edit").close()},async submitForm(){this.loadingBtn=!0;try{const s=await fetch(`/wp-json/my-easy-compta/v1/payments/${this.editedPayment.id}`,{method:"PUT",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.editedPayment)});if(s.ok){const t=await s.json();this.closeModal(),this.loadingBtn=!1,this.showToast(t.message,"alert-success"),this.$emit("paymentEdited")}else{this.loadingBtn=!1;const t=`Error editing payment: ${s.statusText}`;this.showToast(t,"alert-error"),console.error(t)}}catch(s){const t=s.response&&s.response.data&&s.response.data.message?s.response.data.message:"Error editing payment";this.showToast(t,"alert-error"),console.error("Error editing payment:",s),this.loadingBtn=!1}},showToast(s,t){this.toast.message=s,this.toast.type=t,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)}},watch:{payment:{handler(s){this.editedPayment={...s}},immediate:!0}}},q=["id","open"],O={class:"modal-box"},Y={class:"font-bold text-lg"},z={key:0},Q={class:"grid grid-cols-2 gap-4"},H=e("div",{class:"skeleton h-4 w-full mb-2"},null,-1),J=e("div",{class:"skeleton h-4 w-full"},null,-1),G=[H,J],Z={class:"grid grid-cols-2 gap-4"},K=["for"],$=["type","id","onUpdate:modelValue","disabled"],tt=["id"],et=["value"],st={class:"ecwp-group form-group mt-4"},nt={for:"note",class:"ecwp-label form-label"},ot={class:"form-group mt-4 flex justify-end"},at=["disabled"],lt={key:0,class:"loading loading-spinner loading-sm"};function it(s,t,i,c,n,a){const x=g("VueDatePicker");return l(),r("div",null,[n.toast.visible?(l(),r("div",{key:0,class:_(["toast",n.toast.position]),style:{zIndex:9999}},[e("div",{class:_(["alert",n.toast.type,"text-white"])},[e("span",null,d(n.toast.message),1)],2)],2)):f("",!0),e("dialog",{id:i.modalId,class:"modal",open:i.showModal},[e("div",O,[e("h3",Y,d(i.modalTitle),1),e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[0]||(t[0]=(...m)=>a.closeModal&&a.closeModal(...m))}," \u2715 "),i.loading?(l(),r("div",z,[e("div",Q,[(l(!0),r(p,null,h(a.skeletonItems,m=>(l(),r("div",{key:m,class:"py-2"},G))),128))])])):(l(),r("form",{key:1,onSubmit:t[4]||(t[4]=j((...m)=>a.submitForm&&a.submitForm(...m),["prevent"])),class:"form"},[e("div",Z,[(l(!0),r(p,null,h(n.fields,(m,u)=>(l(),r("div",{key:u,class:"ecwp-group form-group"},[e("label",{for:u,class:"ecwp-label form-label"},d(m.label),9,K),u!=="payment_method"&&u!=="payment_date"?y((l(),r("input",{key:0,type:m.type||"text",id:u,"onUpdate:modelValue":o=>n.editedPayment[u]=o,class:_(["ecwp-input input","input-bordered",m.class||"w-full"]),disabled:m.disabled},null,10,$)),[[B,n.editedPayment[u]]]):u=="payment_method"?y((l(),r("select",{key:1,id:u,"onUpdate:modelValue":t[1]||(t[1]=o=>n.editedPayment.payment_method_id=o),class:_(["ecwp-input input","input-bordered",m.class||"w-full"])},[(l(!0),r(p,null,h(a.paymentMethods,o=>(l(),r("option",{key:o.id,value:o.id},d(o.method_name),9,et))),128))],10,tt)),[[v,n.editedPayment.payment_method_id]]):u=="payment_date"?(l(),V(x,{key:2,class:"ecwp-input ecwp-date input input-bordered w-full",id:"invoiceDate",modelValue:n.editedPayment.payment_date,"onUpdate:modelValue":t[2]||(t[2]=o=>n.editedPayment.payment_date=o),"enable-time-picker":!1,"auto-apply":"",format:a.formattedDate,"min-date":new Date,locale:"fr",required:""},null,8,["modelValue","format","min-date"])):f("",!0)]))),128))]),e("div",st,[e("label",nt,d(a.translations.note),1),y(e("textarea",{id:"note","onUpdate:modelValue":t[3]||(t[3]=m=>n.editedPayment.notes=m),class:"ecwp-input textarea textarea-bordered w-full",rows:"4"},null,512),[[b,n.editedPayment.notes]])]),e("div",ot,[e("button",{type:"submit",class:"btn btn-primary rounded-full",disabled:n.loadingBtn},[C(d(a.translations.save)+" ",1),n.loadingBtn?(l(),r("span",lt)):f("",!0)],8,at)])],32))])],8,q)])}var rt=T(L,[["render",it]]);const dt={name:"Payments",components:{Card:W,PaymentEditModal:rt,RemoveModal:F},data(){return{payments:[],filteredPayments:[],filters:{invoice_number:"",client:"",payment_date:"",total_amount:"",payment_methods:""},clients:[],payments_methods:[],paymentMethods:[],paymentForm:{invoice_id:"",client_id:"",amount:"",payment_method_id:"",payment_date:""},editPaymentModal:!1,selectedPayment:null,currentPage:1,totalPages:1,paginationButtons:[],loading:!0,loadingPrice:!0,loadingModal:!1,showRemoveModal:!1,skeletonRows:5,perPage:10,perPageOptions:[5,10,20,50],settings:[],default_currency_symbol:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"}}},created(){this.fetchPaymentsWithFilters(),this.fetchClients(),this.fetchPaymentMethods(),this.loadSettings()},methods:{fetchPayments(s=1){this.loading=!0;const{perPage:t}=this;fetch(`/wp-json/my-easy-compta/v1/payments?page=${s}&per_page=${t}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(i=>i.json()).then(i=>{this.payments=i.payments,this.totalCount=i.total_count,this.totalPages=i.total_pages,this.currentPage=i.page,this.perPage=t,this.generatePaginationButtons()}).catch(i=>{console.error("Error fetching payments:",i)}).finally(()=>{this.loading=!1})},fetchPaymentsWithFilters(s=1){this.loading=!0;const{perPage:t,filters:i}=this,c=new URLSearchParams({page:s,per_page:t,...i}).toString();fetch(`/wp-json/my-easy-compta/v1/payments?${c}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(n=>n.json()).then(n=>{this.payments=n.payments,this.totalCount=n.total_count,this.totalPages=n.total_pages,this.currentPage=s,this.perPage=t,this.generatePaginationButtons()}).catch(n=>{console.error("Error fetching payments with filters:",n)}).finally(()=>{this.loading=!1})},fetchClients(){fetch("/wp-json/my-easy-compta/v1/clients",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>s.json()).then(s=>{this.clients=s.clients}).catch(s=>{console.error("Error fetching clients:",s)})},fetchPaymentMethods(){fetch("/wp-json/my-easy-compta/v1/payments/methods",{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(s=>s.json()).then(s=>{this.payments_methods=s}).catch(s=>{console.error("Error fetching payment Methods:",s)})},editPayment(s){this.loadingModal=!0,this.editPaymentModal=!0,modal_payment_edit.showModal(),this.fetchPaymentDetails(s)},fetchPaymentDetails(s){fetch(`/wp-json/my-easy-compta/v1/payments/details/${s}`,{headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>t.json()).then(t=>{this.selectedPayment=t,this.paymentMethods=t.payment_methods,this.loadingModal=!1}).catch(t=>{console.error("Error fetching payment details:",t),this.loadingModal=!1})},generatePaginationButtons(){this.paginationButtons=U(this.currentPage,this.totalPages)},goToPage(s){s!=="..."&&this.fetchPaymentsWithFilters(s)},perPageChanged(){this.fetchPaymentsWithFilters()},formatAmount(s,t){return R(s,t,this.settings.currency_position)},showToast(s,t){X(this.toast,s,t)},closePaymentModal(){this.showPaymentModal=!1},confirmDeletePayment(s){this.selectedPayment=s,modal_payment_remove.showModal(),this.showRemoveModal=!0},deletePayment(s){this.loading=!0,fetch(`/wp-json/my-easy-compta/v1/payments/${s}`,{method:"DELETE",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce}}).then(t=>{if(!t.ok)throw new Error("Network response was not ok");return t.json()}).then(t=>{t.success?(this.fetchPayments(),this.showToast(t.message,"alert-success")):(this.showToast(t.message,"alert-error"),console.error("Error deleting payment:",t.statusText))}).catch(t=>{console.error("Error deleting payment:",t)})},async loadSettings(){try{this.loadingPrice=!0;const{settings:s,currencySymbol:t,vatData:i}=await N();this.settings=s,this.default_currency_symbol=t,this.default_vat=i,this.loadingPrice=!1}catch(s){this.showToast(s.message,"alert-error"),this.loadingPrice=!1}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}}},mt={class:"pt-2 pr-4"},ct={class:"flex justify-between items-center"},ut={class:"card-title"},pt={key:0},ht={class:"btn btn-outline btn-accent rounded-full",href:"/wp-admin/admin.php?page=my-easy-compta-export#tab4"},yt=e("i",{class:"fas fa-file-export"},null,-1),_t=["data-tip"],ft={class:"btn btn-outline btn-accent rounded-full",disabled:""},gt=e("i",{class:"fas fa-file-export"},null,-1),vt=e("div",{class:"divider mt-2"},null,-1),bt={class:"flex items-center mb-4"},Pt={for:"perPageSelect",class:"mr-2"},wt=["value"],xt={class:"overflow-x-auto"},kt={class:"table w-full"},Ct={value:""},Mt=["value"],Et={value:""},Tt=["value"],jt={class:"align-top"},Bt={class:"flex justify-center"},Vt={key:0},It={key:0},Dt={key:1},St=e("span",{class:"loading loading-bars loading-sm"},null,-1),Wt=[St],Ft={class:"flex justify-end"},At=["data-tip"],Ut=["onClick"],Rt=e("i",{class:"fas fa-pencil-alt"},null,-1),Xt=[Rt],Nt=["data-tip"],Lt=["onClick"],qt=e("i",{class:"far fa-trash-alt"},null,-1),Ot=[qt],Yt={key:0},zt=e("div",{class:"flex gap-4 items-center"},[e("div",{class:"skeleton w-16 h-16 rounded-full shrink-0"}),e("div",{class:"flex flex-col gap-4 w-full"},[e("div",{class:"skeleton h-4 w-full"}),e("div",{class:"skeleton h-4 w-full"})])],-1),Qt=e("div",{class:"divider my-1"},null,-1),Ht=[zt,Qt],Jt={class:"join ecwp_pagination mt-6 pt-4"},Gt=["onClick"];function Zt(s,t,i,c,n,a){const x=g("payment-edit-modal"),m=g("remove-modal"),u=g("Card");return l(),r("div",mt,[n.toast.visible?(l(),r("div",{key:0,class:_(["toast",n.toast.position]),style:{zIndex:9999}},[e("div",{class:_(["alert",n.toast.type,"text-white"])},[e("span",null,d(n.toast.message),1)],2)],2)):f("",!0),k(x,{loading:n.loadingModal,"show-modal":n.editPaymentModal,"modal-id":"modal_payment_edit","modal-title":a.translations.edit_payment,payment:n.selectedPayment,methods:n.paymentMethods,onClose:t[0]||(t[0]=o=>n.editPaymentModal=!1),onPaymentEdited:a.fetchPayments},null,8,["loading","show-modal","modal-title","payment","methods","onPaymentEdited"]),k(m,{"modal-id":"modal_payment_remove","show-modal":n.showRemoveModal,title:a.translations.are_you_sure,message:a.translations.no_turning_back,confirmText:a.translations.yes_delete_it,cancelText:a.translations.cancel,onConfirm:t[1]||(t[1]=o=>this.deletePayment(n.selectedPayment)),onCancel:t[2]||(t[2]=o=>n.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),k(u,{topMargin:"mt-8"},{default:I(()=>[e("div",ct,[e("h2",ut,d(a.translations.payments),1),n.settings.easy_compta_export_addon_active==1?(l(),r("div",pt,[e("a",ht,[C(d(a.translations.export)+" ",1),yt])])):(l(),r("div",{key:1,class:"tooltip tooltip-left tooltip-warning","data-tip":a.translations.active_export_addon},[e("button",ft,[C(d(a.translations.export)+" ",1),gt])],8,_t))]),vt,e("div",bt,[e("label",Pt,d(a.translations.display_per_page),1),y(e("select",{id:"perPageSelect","onUpdate:modelValue":t[3]||(t[3]=o=>n.perPage=o),onChange:t[4]||(t[4]=(...o)=>a.perPageChanged&&a.perPageChanged(...o))},[(l(!0),r(p,null,h(n.perPageOptions,o=>(l(),r("option",{key:o,value:o},d(o),9,wt))),128))],544),[[v,n.perPage]])]),e("div",xt,[e("table",kt,[e("thead",null,[e("tr",null,[e("th",null,[e("div",null,d(a.translations.invoice_number),1),y(e("input",{"onUpdate:modelValue":t[5]||(t[5]=o=>n.filters.invoice_number=o),onInput:t[6]||(t[6]=o=>a.fetchPaymentsWithFilters()),type:"text",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[b,n.filters.invoice_number]])]),e("th",null,[e("div",null,d(a.translations.client),1),y(e("select",{"onUpdate:modelValue":t[7]||(t[7]=o=>n.filters.client=o),onChange:t[8]||(t[8]=o=>a.fetchPaymentsWithFilters()),class:"ecwp-input input-xs input-bordered mt-2"},[e("option",Ct,d(a.translations.all),1),(l(!0),r(p,null,h(n.clients,o=>(l(),r("option",{key:o.id,value:o.company_name},d(o.company_name),9,Mt))),128))],544),[[v,n.filters.client]])]),e("th",null,[e("div",null,d(a.translations.payment_date),1),y(e("input",{"onUpdate:modelValue":t[9]||(t[9]=o=>n.filters.payment_date=o),onInput:t[10]||(t[10]=o=>a.fetchPaymentsWithFilters()),type:"date",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[b,n.filters.payment_date]])]),e("th",null,[e("div",null,d(a.translations.amount),1),y(e("input",{"onUpdate:modelValue":t[11]||(t[11]=o=>n.filters.total_amount=o),onInput:t[12]||(t[12]=o=>a.fetchPaymentsWithFilters()),type:"text",class:"ecwp-input input-xs input-bordered mt-2"},null,544),[[b,n.filters.total_amount]])]),e("th",null,[e("div",null,d(a.translations.payment_method),1),y(e("select",{"onUpdate:modelValue":t[13]||(t[13]=o=>n.filters.payment_method=o),onChange:t[14]||(t[14]=o=>a.fetchPaymentsWithFilters()),class:"ecwp-input input-xs input-bordered mt-2"},[e("option",Et,d(a.translations.all),1),(l(!0),r(p,null,h(n.payments_methods,o=>(l(),r("option",{key:o.id,value:o.method_name},d(o.method_name),9,Tt))),128))],544),[[v,n.filters.payment_method]])]),e("th",jt,d(a.translations.note),1),e("th",Bt,d(a.translations.actions),1)])]),n.loading?f("",!0):(l(),r("tbody",Vt,[(l(!0),r(p,null,h(n.payments,o=>(l(),r("tr",{key:o.id},[e("td",null,d(o.invoice_number),1),e("td",null,d(o.company_name),1),e("td",null,d(o.payment_date),1),e("td",null,[n.loadingPrice?(l(),r("div",Dt,Wt)):(l(),r("div",It,[e("span",null,d(a.formatAmount(o.amount,n.default_currency_symbol)),1)]))]),e("td",null,d(o.payment_method),1),e("td",null,d(o.notes),1),e("td",Ft,[e("span",{class:"lg:tooltip","data-tip":a.translations.edit},[e("button",{class:"btn btn-circle mx-1",onClick:M=>a.editPayment(o.id)},Xt,8,Ut)],8,At),e("span",{class:"lg:tooltip","data-tip":a.translations.delete},[e("button",{onClick:M=>a.confirmDeletePayment(o.id),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},Ot,8,Lt)],8,Nt)])]))),128))]))]),n.loading?(l(),r("div",Yt,[(l(!0),r(p,null,h(n.skeletonRows,o=>(l(),r("div",{key:o,class:"flex flex-col gap-4 w-full"},Ht))),128))])):f("",!0),e("div",Jt,[(l(!0),r(p,null,h(n.paginationButtons,o=>(l(),r("button",{key:o,class:_(["join-item btn",{"btn-disabled":o==="..."||o===n.currentPage}]),onClick:M=>a.goToPage(o)},d(o),11,Gt))),128))])])]),_:1})])}var Kt=T(dt,[["render",Zt]]);function P(s,t){const i=w();return P=function(c,n){return c=c-117,i[c]},P(s,t)}const E=P;function w(){const s=["645650YFRYWX","294520VDjvDL","#my-easy-compta-payments-app","2QPeRjY","693096blLaZB","6dQLuGW","mount","2352085kacCuu","107617XrVrwQ","3784BePTLI","999kJsabq","2207611pPvrHM"];return w=function(){return s},w()}(function(s,t){const i=P,c=s();for(;[];)try{if(parseInt(i(118))/1+parseInt(i(125))/2*(parseInt(i(126))/3)+-parseInt(i(123))/4+parseInt(i(117))/5+parseInt(i(127))/6*(-parseInt(i(121))/7)+parseInt(i(119))/8*(-parseInt(i(120))/9)+-parseInt(i(122))/10===t)break;c.push(c.shift())}catch{c.push(c.shift())}})(w,302995);const $t=D({render:()=>S(Kt)});$t[E(128)](E(124));
  • my-easy-compta/trunk/assets/dist/quotes.min.js

    r3198779 r3233000  
    1 import{_ as c,d as u,o as _,H as i,f as m,h as d}from"./plugin-vue_export-helper.min.js";import{r as h}from"./index.min.js";import"./RemoveAlert.min.js";import"./VueSearchSelect.min.js";import"./vue-datepicker.min.js";import"./api.min.js";import"./vue3-editor.common.min.js";const I={name:"Quotes",mounted(){this.$router.push("/quotes")}};function b(r,n,e,t,x,f){const a=u("router-view");return _(),i(a)}var l=c(I,[["render",b]]);const p=s;function o(){const r=["1664013HENPmr","4021788fENmKh","597396ZnBvYF","6AOQzyO","1548190REhuDW","330269cXgXxy","5fffzFz","13843881peofXm","3930514aFarkK","8ebeisU","mount","176PfJVcH","#my-easy-compta-quotes-app"];return o=function(){return r},o()}(function(r,n){const e=s,t=r();for(;[];)try{if(parseInt(e(241))/1*(parseInt(e(239))/2)+parseInt(e(249))/3+-parseInt(e(238))/4*(-parseInt(e(242))/5)+parseInt(e(237))/6+-parseInt(e(244))/7+parseInt(e(245))/8*(parseInt(e(243))/9)+parseInt(e(240))/10*(-parseInt(e(247))/11)===n)break;t.push(t.shift())}catch{t.push(t.shift())}})(o,864728);function s(r,n){const e=o();return s=function(t,x){return t=t-237,e[t]},s(r,n)}const v=m({render:()=>d(l)});v.use(h)[p(246)](p(248));
     1import{_ as u,d as _,o as i,H as f,f as m,h as d}from"./plugin-vue_export-helper.min.js";import{r as h}from"./index.min.js";import"./RemoveAlert.min.js";import"./VueSearchSelect.min.js";import"./vue-datepicker.min.js";import"./api.min.js";import"./vue3-editor.common.min.js";const I={name:"Quotes",mounted(){this.$router.push("/quotes")}};function l(r,n,t,e,p,a){const c=_("router-view");return i(),f(c)}var v=u(I,[["render",l]]);const x=o;function o(r,n){const t=s();return o=function(e,p){return e=e-270,t[e]},o(r,n)}(function(r,n){const t=o,e=r();for(;[];)try{if(-parseInt(t(272))/1+-parseInt(t(275))/2+parseInt(t(277))/3+parseInt(t(281))/4+-parseInt(t(273))/5*(-parseInt(t(274))/6)+-parseInt(t(280))/7+parseInt(t(278))/8*(parseInt(t(270))/9)===n)break;e.push(e.shift())}catch{e.push(e.shift())}})(s,691157);function s(){const r=["45JtUTpJ","#my-easy-compta-quotes-app","1255986lXSZuV","65580aTXsLl","444ZdefBP","374286EUIbnT","mount","1458093vgrgxz","954632LigNwK","use","3860843VqpRpt","2530300OydpHa"];return s=function(){return r},s()}const $=m({render:()=>d(v)});$[x(279)](h)[x(276)](x(271));
  • my-easy-compta/trunk/assets/dist/settings.min.js

    r3198779 r3233000  
    1 import{_ as tt,d as I,o as c,c as d,n as y,a as e,t as l,g as b,e as x,m as G,l as g,w as k,i as p,k as f,G as C,F as T,r as S,j as V,y as et,T as st,Z as nt,J as it,f as ot,h as at}from"./plugin-vue_export-helper.min.js";import{C as lt,R as rt}from"./RemoveAlert.min.js";import{v as ct}from"./vue3-editor.common.min.js";const dt={name:"Settings",components:{Card:lt,VueEditor:ct.exports.VueEditor,RemoveModal:rt},data(){return{loading:!1,selectedTab:1,form:{company_name:"",company_address:"",postal_code:"",city:"",country:"",company_email:"",company_phone:"",mobile_phone:"",fax:"",logo_mentions_active:"",logo_url:"",logo_path:"",default_currency:"",currency_position:"",vat_active:"",default_vat:"",date_format:"",logo_width:"",logo_mentions:"",invoice_color:"",invoice_prefix:"",active_disbursements:"",show_phone:"",show_email:"",show_siren:"",show_tax_number:"",show_watermark:"",show_watermark_only_paid:"",invoice_footer:"",invoice_terms:"",credit_color:"",credit_prefix:"",credit_footer:"",credit_terms:"",quote_color:"",quote_prefix:"",quote_footer:"",quote_terms:"",easy_compta_planning_addon_active:"",easy_compta_email_addon_active:"",easy_compta_payment_addon_active:"",easy_compta_signature_addon_active:"",easy_compta_stats_addon_active:"",easy_compta_qrcode_addon_active:"",easy_compta_stripe_secret_api:"",email_quote_subject:"",email_invoice_subject:"",remind_invoice_subject:"",remind_invoice_content:"",email_quote_content:"",email_invoice_content:"",email_create_account_subject:"",email_create_account_content:"",easycompta_siret_token_api:""},articles:[],categories:[],currencies:[],vats:[],expenses:[],planning:[],payments:[],logoPreviewUrl:"",previewWidth:"",showArticleModal:!1,showCurrencyModal:!1,showVATModal:!1,showPaymentModal:!1,showExpenseModal:!1,showPlanningModal:!1,currencyForm:{id:null,name:"",symbol:""},articleForm:{id:null,ref:"",name:"",description:"",unit_price:""},vatForm:{id:null,description:"",rate:""},paymentForm:{id:null,method_name:""},expenseForm:{id:null,name:""},planningForm:{id:null,name:"",background:"",color:""},showRemoveModal:!1,deleteType:null,selectedId:null,editingArticle:!1,editingCurrency:!1,editingVAT:!1,editingExpense:!1,editingPayment:!1,editingPlanning:!1,activeTabEmail:"tab1",activeTabUsers:"user1",license_key:"",loadingLicense:!1,licenseData:null,installed_versions:{},updatesAvailable:{},errorMessage:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},toolbarOptions:[["bold","italic","underline","strike"],["link"],[{list:"ordered"},{list:"bullet"}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{align:[]}],[{align:"right"},{align:"center"},{align:"justify"}],["clean"],["html"]]}},methods:{setActiveTab(s){this.activeTabEmail=s},setActiveTabUsers(s){this.activeTabUsers=s},selectTab(s){this.selectedTab=s,window.location.hash=`tab${s}`},checkHash(){const s=window.location.hash;if(s){const t=parseInt(s.replace("#tab",""));isNaN(t)||(this.selectedTab=t)}},tabClass(s){return this.selectedTab===s?"tab tab-active":"tab"},async fetchSettings(){try{this.loading=!0;const s=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,s.ok){const t=await s.json();this.form={...this.form,...t},this.logoPreviewUrl=t.logo_url||"",this.form.easy_compta_planning_addon_active==1&&this.fetchPlanningCat()}else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.loading=!1,this.showToast(s.message,"alert-error")}},async handleSubmit(){try{this.loading=!0;const s=await fetch("/wp-json/my-easy-compta/v1/settings/save",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.form)});if(this.loading=!1,s.ok){const t=await s.json();this.showToast(t,"alert-success")}else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.loading=!1,this.showToast(s.message,"alert-error")}},async fetchArticles(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/articles",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok){const t=await s.json();this.articles=t.articles,this.categories=t.categories}else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async fetchCurrencies(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/currencies",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok)this.currencies=await s.json();else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async fetchVATs(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/vats",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok)this.vats=await s.json();else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async fetchPaymentsMethods(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/payments-methods",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok)this.payments=await s.json();else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async fetchExpensesCat(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/expenses-cat",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok)this.expenses=await s.json();else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async fetchPlanningCat(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/planning-cat",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok)this.planning=await s.json();else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async handleLogoUpload(s){const t=s.target.files[0];if(t){const o=new FormData;o.append("logo",t);try{const r=await fetch("/wp-json/my-easy-compta/v1/settings/upload-logo",{method:"POST",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce},body:o});if(r.ok){const i=await r.json();this.form.logo_url=i.url,this.form.logo_path=i.path,this.logoPreviewUrl=i.url,this.showToast("Logo uploaded successfully","alert-success")}else{const i=await r.json();this.showToast(i.message,"alert-error")}}catch(r){this.showToast(r.message,"alert-error")}}},async addArticle(){this.articleForm={id:null,ref:"",name:"",description:"",price:""},this.editingArticle=!1,this.showArticleModal=!0,this.$nextTick(()=>{document.getElementById("modal_article").showModal()})},async addCurrency(){this.currencyForm={id:null,name:"",symbol:""},this.editingCurrency=!1,this.showCurrencyModal=!0,this.$nextTick(()=>{document.getElementById("modal_currency").showModal()})},async deleteArticle(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/articles/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.articles=this.articles.filter(o=>o.id!==s),this.showToast(this.translations.deleted_successfully,"alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async deleteCategory(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/category/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.categories=this.categories.filter(o=>o.id!==s),this.showToast(this.translations.deleted_successfully,"alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async editArticle(s){const t=this.articles.find(o=>o.id===s);this.articleForm={...t},this.editingArticle=!0,this.showArticleModal=!0,this.$nextTick(()=>{document.getElementById("modal_article").showModal()})},async editCurrency(s){const t=this.currencies.find(o=>o.id===s);this.currencyForm={...t},this.editingCurrency=!0,this.showCurrencyModal=!0,this.$nextTick(()=>{document.getElementById("modal_currency").showModal()})},async deleteCurrency(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/currencies/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.currencies=this.currencies.filter(o=>o.id!==s),this.showToast("Currency deleted successfully","alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async saveArticle(){const s=this.editingArticle?"PUT":"POST",t=this.editingArticle?`/wp-json/my-easy-compta/v1/settings/articles/${this.articleForm.id}`:"/wp-json/my-easy-compta/v1/settings/articles";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.articleForm)});if(o.ok){const r=await o.json();if(this.editingArticle){const i=this.articles.findIndex(n=>n.id===r.id);this.articles[i]=r}else this.articles.push(r);this.showToast(`Article ${this.editingArticle?"updated":"added"} successfully`,"alert-success"),this.closeArticleModal(),this.fetchArticles()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},async saveCurrency(){const s=this.editingCurrency?"PUT":"POST",t=this.editingCurrency?`/wp-json/my-easy-compta/v1/settings/currencies/${this.currencyForm.id}`:"/wp-json/my-easy-compta/v1/settings/currencies";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.currencyForm)});if(o.ok){const r=await o.json();if(this.editingCurrency){const i=this.currencies.findIndex(n=>n.id===r.id);this.currencies[i]=r}else this.currencies.push(r);this.showToast(`Currency ${this.editingCurrency?"updated":"added"} successfully`,"alert-success"),this.closeCurrencyModal(),this.fetchCurrencies()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},async addVAT(){this.vatForm={id:null,description:"",rate:""},this.editingVAT=!1,this.showVATModal=!0,this.$nextTick(()=>{document.getElementById("modal_vat").showModal()})},async editVAT(s){const t=this.vats.find(o=>o.id===s);this.vatForm={...t},this.editingVAT=!0,this.showVATModal=!0,this.$nextTick(()=>{document.getElementById("modal_vat").showModal()})},async deleteVAT(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/vats/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.vats=this.vats.filter(o=>o.id!==s),this.showToast("VAT deleted successfully","alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async saveVAT(){const s=this.editingVAT?"PUT":"POST",t=this.editingVAT?`/wp-json/my-easy-compta/v1/settings/vats/${this.vatForm.id}`:"/wp-json/my-easy-compta/v1/settings/vats";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.vatForm)});if(o.ok){const r=await o.json();if(this.editingVAT){const i=this.vats.findIndex(n=>n.id===r.id);this.vats[i]=r}else this.vats.push(r);this.showToast(`VAT ${this.editingVAT?"updated":"added"} successfully`,"alert-success"),this.closeVATModal(),this.fetchVATs()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},async addPayment(){this.paymentForm={id:null,method_name:""},this.editingPayment=!1,this.showPaymentModal=!0,this.$nextTick(()=>{document.getElementById("modal_payments").showModal()})},async editPayment(s){const t=this.payments.find(o=>o.id===s);this.paymentForm={...t},this.editingPayment=!0,this.showPaymentModal=!0,this.$nextTick(()=>{document.getElementById("modal_payments").showModal()})},async deletePayment(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/payments-methods/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.payments=this.payments.filter(o=>o.id!==s),this.showToast("Payment method deleted successfully","alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async savePayment(){const s=this.editingPayment?"PUT":"POST",t=this.editingPayment?`/wp-json/my-easy-compta/v1/settings/payments-methods/${this.paymentForm.id}`:"/wp-json/my-easy-compta/v1/settings/payments-methods";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.paymentForm)});if(o.ok){const r=await o.json();if(this.editingPayment){const i=this.payments.findIndex(n=>n.id===r.id);this.payments[i]=r}else this.payments.push(r);this.showToast(`Payment method ${this.editingPayment?"updated":"added"} successfully`,"alert-success"),this.closePaymentModal(),this.fetchPaymentsMethods()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},async addExpCat(){this.expenseForm={id:null,name:""},this.editingExpense=!1,this.showExpenseModal=!0,this.$nextTick(()=>{document.getElementById("modal_expenses").showModal()})},async editExpCat(s){const t=this.expenses.find(o=>o.id===s);this.expenseForm={...t},this.editingExpense=!0,this.showExpenseModal=!0,this.$nextTick(()=>{document.getElementById("modal_expenses").showModal()})},async deleteExpCat(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/expenses-categories/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.expenses=this.expenses.filter(o=>o.id!==s),this.showToast("Expense category deleted successfully","alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async saveExpCat(){const s=this.editingExpense?"PUT":"POST",t=this.editingExpense?`/wp-json/my-easy-compta/v1/settings/expenses-categories/${this.expenseForm.id}`:"/wp-json/my-easy-compta/v1/settings/expenses-categories";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.expenseForm)});if(o.ok){const r=await o.json();if(this.editingExpense){const i=this.expenses.findIndex(n=>n.id===r.id);this.expenses[i]=r}else this.expenses.push(r);this.showToast(`Expense category ${this.editingExpense?"updated":"added"} successfully`,"alert-success"),this.closeExpenseModal(),this.fetchExpensesCat()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},async addPlanningCat(){this.planningForm={id:null,name:""},this.editingPlanning=!1,this.showPlanningModal=!0,this.$nextTick(()=>{document.getElementById("modal_planning").showModal()})},async editPlanningCat(s){const t=this.planning.find(o=>o.id===s);this.planningForm={...t},this.editingPlanning=!0,this.showPlanningModal=!0,this.$nextTick(()=>{document.getElementById("modal_planning").showModal()})},async deletePlanningCat(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/planning-categories/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.planning=this.planning.filter(o=>o.id!==s),this.showToast("Planning category deleted successfully","alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async savePlanningCat(){this.loading=!0;const s=this.editingPlanning?"PUT":"POST",t=this.editingPlanning?`/wp-json/my-easy-compta/v1/settings/planning-categories/${this.planningForm.id}`:"/wp-json/my-easy-compta/v1/settings/planning-categories";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.planningForm)});if(o.ok){const r=await o.json();if(this.editingPlanning){const i=this.planning.findIndex(n=>n.id===r.id);this.planning[i]=r,this.loading=!1}else this.planning.push(r),this.loading=!1;this.showToast(`Planning category ${this.editingPlanning?"updated":"added"} successfully`,"alert-success"),this.closePlanningModal(),this.fetchPlanningCat()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},closeCurrencyModal(){this.showCurrencyModal=!1},closeArticleModal(){this.showArticleModal=!1},closeVATModal(){this.showVATModal=!1},closePaymentModal(){this.showPaymentModal=!1},closeExpenseModal(){this.showExpenseModal=!1},closePlanningModal(){this.showPlanningModal=!1},updatePreviewWidth(){this.previewWidth=this.form.logo_width+"px"},updateVatActive(s){this.form.vat_active=s.target.checked?1:0},updateLogoMentionsActive(s){this.form.logo_mentions_active=s.target.checked?1:0},updateEmailLogsActive(s){this.form.email_log_active=s.target.checked?1:0},updateFormField(s,t){this.form[t]=s.target.checked?1:0},showToast(s,t){this.toast.message=s,this.toast.type=t,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},handleDeletion(s,t){const o=this.getDeletionFunction(s);o?o(t):this.showToast("error","alert-error")},delete_item(s,t){this.deleteType=s,this.selectedId=t,modal_settings_remove.showModal(),this.showRemoveModal=!0},getDeletionFunction(s){switch(s){case"licence":return this.confirmLicense;case"vat":return this.deleteVAT;case"currency":return this.deleteCurrency;case"expense":return this.deleteExpCat;case"payment":return this.deletePayment;case"planning":return this.deletePlanningCat;case"article":return this.deleteArticle;case"category_article":return this.deleteCategory;default:return null}},async checkLicense(){this.loading=!0,this.loadingLicense=!0,this.errorMessage="",this.licenseData=null;try{const t=await(await fetch("/wp-json/my-easy-compta/v1/license/validate-license",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({license_key:this.license_key})})).json();t.valid?(this.licenseData=t,await this.storeLicense(t),location.reload()):this.errorMessage=t.message}catch{this.errorMessage="An error occurred while validating the license."}finally{this.loadingLicense=!1}},async refresh_licence(){this.loading=!0;try{const t=await(await fetch("/wp-json/my-easy-compta/v1/license/refresh-license",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}})).json();t.valid?location.reload():this.errorMessage=t.message}catch{this.errorMessage="An error occurred while refreshing the license."}},async storeLicense(s){try{await fetch("/wp-json/my-easy-compta/v1/license/store-license",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({license_key:this.license_key,license_data:s})})}catch{this.errorMessage="An error occurred while storing the license.",this.loading=!1}},async loadLicenseDetails(){this.loading=!0;try{const s=await fetch("/wp-json/my-easy-compta/v1/license/check-license",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok){const t=await s.json();t.valid&&(this.licenseData=t.license_data,this.installed_versions=t.installed_versions,this.license_key="****-****-****-****-****"+this.license_key.substr(this.license_key.length-4),this.loading=!1)}else console.error("Failed to load license details"),this.loading=!1}catch(s){console.error("Error loading license details",s),this.loading=!1}},async confirmLicense(){this.loading=!0;try{const s=await fetch("/wp-json/my-easy-compta/v1/license/delete-license",{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok){const t=await s.json();this.showToast(t.message,"alert-success"),this.licenseData="",this.license_key="",location.reload()}else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async checkUpdatePlugin(s,t){try{const r=await(await fetch("/wp-json/my-easy-compta/v1/license/check-update",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({plugin_slug:s,current_version:t})})).json();r.success?r.update_available?(this.showToast(this.translations.update_available+" "+r.new_version,"alert-success"),this.updatesAvailable[s]=r.update_available):this.showToast(this.translations.no_update_available,"alert-error"):this.showToast(this.translations.failed_update_available,"alert-error")}catch(o){console.error("Error checking for plugin update:",o),this.showToast(this.translations.failed_update_available,"alert-error")}},async installUpdatePlugin(s){try{const o=await(await fetch("/wp-json/my-easy-compta/v1/license/download-update",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({plugin_slug:s})})).json();if(o.success){this.showToast(this.translations.success,"alert-success");const r=document.createElement("a");r.href=o.download_url,r.setAttribute("download",""),document.body.appendChild(r),r.click(),document.body.removeChild(r)}else this.showToast(this.translations.error,"alert-error")}catch(t){console.error("Error checking for plugin update:",t),this.showToast(this.translations.error,"alert-error")}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},beforeUnmount(){window.removeEventListener("hashchange",this.checkHash)},mounted(){this.checkHash(),window.addEventListener("hashchange",this.checkHash),this.fetchSettings(),this.fetchArticles(),this.fetchCurrencies(),this.fetchVATs(),this.fetchPaymentsMethods(),this.fetchExpensesCat(),this.loadLicenseDetails()}},ut={class:"pt-2 pr-4"},ht={class:"flex justify-between items-center"},pt={class:"card-title"},mt=e("div",{class:"divider mt-2"},null,-1),ft={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4"},bt={class:"tabs tabs-vertical tabs-boxed col-span-1"},_t=e("i",{class:"fas fa-home mr-2"},null,-1),gt=e("i",{class:"fas fa-tools mr-2"},null,-1),vt=e("i",{class:"fas fa-newspaper mr-2"},null,-1),yt=e("i",{class:"fas fa-file-invoice-dollar mr-2"},null,-1),wt=e("i",{class:"fas fa-undo mr-2"},null,-1),xt=e("i",{class:"far fa-question-circle mr-2"},null,-1),kt=e("i",{class:"fas fa-dollar-sign mr-2"},null,-1),Ct=e("i",{class:"fas fa-money-check-alt mr-2"},null,-1),Tt=e("i",{class:"fas fa-shopping-basket mr-2"},null,-1),Mt=e("i",{class:"fas fa-calendar-alt mr-2"},null,-1),At=e("i",{class:"far fa-envelope mr-2"},null,-1),St=e("i",{class:"fas fa-user mr-2"},null,-1),Pt=e("i",{class:"far fa-credit-card mr-2"},null,-1),Et=e("i",{class:"far fa-chart-bar mr-2"},null,-1),jt=e("i",{class:"fas fa-qrcode mr-2"},null,-1),Vt=e("i",{class:"far fa-id-badge mr-2"},null,-1),It={class:"col-span-3 p-4 bg-base-300 rounded-lg shadow-md content-tabs"},Ft={key:0,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},Rt=e("span",{class:"loading loading-spinner text-primary loading-lg"},null,-1),Ut=[Rt],Dt={key:1},Ht={class:"text-xl font-semibold mb-4"},Nt={class:"grid grid-cols-1 md:grid-cols-2 gap-4"},Yt={class:"ecwp-group form-control"},qt={class:"ecwp-label label",for:"company-code"},Lt={class:"ecwp-group form-control"},Ot={class:"ecwp-label label",for:"tax-number"},Xt={class:"ecwp-group form-control"},Wt={class:"ecwp-label label",for:"company-name"},Bt={class:"ecwp-group form-control"},zt={class:"ecwp-label label",for:"company-address"},Gt={class:"ecwp-group form-control"},Jt={class:"ecwp-label label",for:"postal-code"},Zt={class:"ecwp-group form-control"},Kt={class:"ecwp-label label",for:"city"},Qt={class:"ecwp-group form-control"},$t={class:"ecwp-label label",for:"country"},te={class:"ecwp-group form-control"},ee={class:"ecwp-label label",for:"company-email"},se={class:"ecwp-group form-control"},ne={class:"ecwp-label label",for:"company-phone"},ie={class:"ecwp-group form-control"},oe={class:"ecwp-label label",for:"mobile-phone"},ae={class:"ecwp-group form-control"},le={class:"ecwp-label label",for:"fax"},re=e("div",{class:"divider my-4"},null,-1),ce={key:0},de={class:"grid grid-cols-2 gap-4"},ue={class:"ecwp-group form-control indicator"},he={class:"ecwp-label label",for:"company-code"},pe=e("span",{class:"indicator-item badge mt-5 border-blue-700"},[e("a",{href:"https://api.gouv.fr/les-api/sirene_v3",target:"_blank"},"?")],-1),me={class:"mt-6 flex justify-end"},fe={type:"submit",class:"btn btn-primary rounded-full"},be=e("i",{class:"far fa-save"},null,-1),_e={key:2},ge={class:"text-xl font-semibold mb-4"},ve={class:"form-control mt-4 mb-1"},ye={class:"cursor-pointer"},we={class:"label-text mr-2 font-bold"},xe=["checked"],ke={key:0,class:"ecwp-group form-control"},Ce={class:"ecwp-label label",for:"logo-mentions"},Te={class:"ecwp-group form-control"},Me={class:"label"},Ae={class:"ecwp-file"},Se={for:"file_logo"},Pe=e("i",{class:"fas fa-cloud-upload-alt mr-2"},null,-1),Ee={key:0,class:"max-w-md"},je={class:"py-2 font-bold"},Ve={key:0},Ie=["src"],Fe={class:"ecwp-group form-control"},Re={class:"ecwp-label label"},Ue=["value"],De={class:"ecwp-group form-control"},He={class:"ecwp-label label"},Ne={value:"before"},Ye={value:"after"},qe={class:"form-control mt-4 mb-1"},Le={class:"cursor-pointer"},Oe={class:"label-text mr-2 font-bold"},Xe=["checked"],We={key:1,class:"ecwp-group form-control"},Be={class:"ecwp-label label"},ze=e("option",{value:"0"},null,-1),Ge=["value"],Je={class:"ecwp-group form-control mt-2"},Ze={class:"ecwp-label label"},Ke=e("option",{value:"DD-MM-YYYY",selected:"selected"}," DD-MM-YYYY ",-1),Qe=e("option",{value:"MM-DD-YYYY"},"MM-DD-YYYY",-1),$e=e("option",{value:"YYYY-MM-DD"},"YYYY-MM-DD",-1),ts=e("option",{value:"YYYY/MM/DD"},"YYYY/MM/DD",-1),es=e("option",{value:"DD/MM/YYYY"},"DD/MM/YYYY",-1),ss=e("option",{value:"MM/DD/YYYY"},"MM/DD/YYYY",-1),ns=e("option",{value:"YYYY.MM.DD"},"YYYY.MM.DD",-1),is=e("option",{value:"DD.MM.YYYY"},"DD.MM.YYYY",-1),os=e("option",{value:"MM.DD.YYYY"},"MM.DD.YYYY",-1),as=[Ke,Qe,$e,ts,es,ss,ns,is,os],ls={class:"mt-6 flex justify-end"},rs={type:"submit",class:"btn btn-primary rounded-full"},cs=e("i",{class:"far fa-save"},null,-1),ds={key:3},us={key:0,id:"modal_article",class:"modal"},hs={class:"modal-box"},ps={class:"ecwp-group form-control"},ms={class:"ecwp-label label",for:"name_ref"},fs={class:"ecwp-group form-control"},bs={class:"ecwp-label label",for:"name_article"},_s={class:"ecwp-group form-control"},gs={class:"ecwp-label label",for:"desc_article"},vs={class:"ecwp-group form-control"},ys={class:"ecwp-label label",for:"price_article"},ws={class:"form-group mt-4 flex justify-end"},xs={type:"submit",class:"btn btn-primary rounded-full mx-2"},ks={class:"flex justify-between items-center mb-4"},Cs={class:"text-lg font-semibold"},Ts=e("i",{class:"fas fa-plus mr-2"},null,-1),Ms={class:"table-container"},As={class:"table w-full"},Ss=["onClick"],Ps=e("i",{class:"fas fa-edit"},null,-1),Es=[Ps],js=["onClick"],Vs=e("i",{class:"fas fa-trash"},null,-1),Is=[Vs],Fs=e("div",{class:"divider mt-2 mb-4"},null,-1),Rs={class:"text-xl font-semibold mb-4"},Us={class:"table-container"},Ds={class:"table w-full"},Hs=["onClick"],Ns=e("i",{class:"fas fa-trash"},null,-1),Ys=[Ns],qs={key:4},Ls={class:"text-xl font-semibold mb-4"},Os={class:"grid grid-cols-2 gap-4"},Xs={class:"ecwp-group form-control"},Ws={class:"ecwp-label label",for:"invoice-color"},Bs={class:"ecwp-group form-control"},zs={class:"ecwp-label label",for:"invoice-prefix"},Gs=e("div",{class:"divider my-4"},null,-1),Js={class:"grid grid-cols-1 gap-4"},Zs={class:"form-control mt-4 mb-1"},Ks={class:"cursor-pointer"},Qs=["checked"],$s={class:"label-text mr-2 font-bold"},tn=e("div",{class:"divider my-4"},null,-1),en={class:"grid grid-cols-2 gap-4"},sn={class:"form-control mt-4 mb-1"},nn={class:"cursor-pointer"},on=["checked"],an={class:"label-text mr-2 font-bold"},ln={class:"form-control mt-4 mb-1"},rn={class:"cursor-pointer"},cn=["checked"],dn={class:"label-text mr-2 font-bold"},un={class:"form-control mt-4 mb-1"},hn={class:"cursor-pointer"},pn=["checked"],mn={class:"label-text mr-2 font-bold"},fn={class:"form-control mt-4 mb-1"},bn={class:"cursor-pointer"},_n=["checked"],gn={class:"label-text mr-2 font-bold"},vn={class:"form-control mt-4 mb-1"},yn={class:"cursor-pointer"},wn=["checked"],xn={class:"label-text mr-2 font-bold"},kn={key:0,class:"form-control mt-4 mb-1"},Cn={class:"cursor-pointer"},Tn=["checked"],Mn={class:"label-text mr-2 font-bold"},An=e("div",{class:"divider my-4"},null,-1),Sn={class:"grid grid-cols-2 gap-4"},Pn={class:"ecwp-group form-control"},En={class:"ecwp-label label",for:"conditions-payment"},jn={class:"ecwp-group form-control"},Vn={class:"ecwp-label label",for:"mode-payment"},In={class:"grid grid-cols-1 gap-4"},Fn={class:"form-control"},Rn={class:"ecwp-label label",for:"invoice-prefix"},Un={class:"grid grid-cols-2 gap-4"},Dn={class:"ecwp-group form-control"},Hn={class:"ecwp-label label",for:"invoice-iban"},Nn={class:"ecwp-group form-control"},Yn={class:"ecwp-label label",for:"invoice-bic"},qn={class:"form-control"},Ln={class:"ecwp-label label",for:"invoice-prefix"},On={class:"mt-6 flex justify-end"},Xn={type:"submit",class:"btn btn-primary rounded-full"},Wn=e("i",{class:"far fa-save"},null,-1),Bn={key:5},zn={class:"text-xl font-semibold mb-4"},Gn={class:"grid grid-cols-2 gap-4"},Jn={class:"ecwp-group form-control"},Zn={class:"ecwp-label label",for:"credit-color"},Kn={class:"ecwp-group form-control"},Qn={class:"ecwp-label label",for:"credit-prefix"},$n={class:"grid grid-cols-1 gap-4"},ti={class:"form-control"},ei={class:"ecwp-label label",for:"credit-prefix"},si={class:"form-control"},ni={class:"ecwp-label label",for:"credit-prefix"},ii={class:"mt-6 flex justify-end"},oi={type:"submit",class:"btn btn-primary rounded-full"},ai=e("i",{class:"far fa-save"},null,-1),li={key:6},ri={class:"text-xl font-semibold mb-4"},ci={class:"grid grid-cols-2 gap-4"},di={class:"ecwp-group form-control"},ui={class:"ecwp-label label",for:"quote-color"},hi={class:"ecwp-group form-control"},pi={class:"ecwp-label label",for:"quote-prefix"},mi={class:"grid grid-cols-1 gap-4"},fi={class:"form-control"},bi={class:"ecwp-label label",for:"quote-prefix"},_i={class:"form-control"},gi={class:"ecwp-label label",for:"quote-prefix"},vi={class:"mt-6 flex justify-end"},yi={type:"submit",class:"btn btn-primary rounded-full"},wi=e("i",{class:"far fa-save"},null,-1),xi={key:7},ki={class:"text-xl font-semibold mb-4"},Ci={key:0,id:"modal_currency",class:"modal"},Ti={class:"modal-box"},Mi={class:"ecwp-group form-control"},Ai={class:"ecwp-label label",for:"name_currency"},Si={class:"ecwp-group form-control"},Pi={class:"ecwp-label label",for:"symbol_currency"},Ei={class:"ecwp-group form-control"},ji={class:"ecwp-label label",for:"code_currency"},Vi={class:"form-group mt-4 flex justify-end"},Ii={type:"submit",class:"btn btn-primary rounded-full mx-2"},Fi={class:"mb-8"},Ri={class:"flex justify-between items-center mb-4"},Ui={class:"text-lg font-semibold"},Di=e("i",{class:"fas fa-plus mr-2"},null,-1),Hi={class:"table-container"},Ni={class:"table w-full"},Yi=["onClick"],qi=e("i",{class:"fas fa-edit"},null,-1),Li=[qi],Oi=["onClick"],Xi=e("i",{class:"fas fa-trash"},null,-1),Wi=[Xi],Bi={key:0,id:"modal_vat",class:"modal"},zi={class:"modal-box"},Gi={class:"ecwp-group form-control"},Ji={class:"ecwp-label label",for:"vat-description"},Zi={class:"ecwp-group form-control"},Ki={class:"ecwp-label label",for:"vat-rate"},Qi={class:"form-group mt-4 flex justify-end"},$i={type:"submit",class:"btn btn-primary rounded-full mx-2"},to={class:"flex justify-between items-center mb-4"},eo={class:"text-lg font-semibold"},so=e("i",{class:"fas fa-plus mr-2"},null,-1),no={class:"table-container"},io={class:"table w-full"},oo=["onClick"],ao=e("i",{class:"fas fa-edit"},null,-1),lo=[ao],ro=["onClick"],co=e("i",{class:"fas fa-trash"},null,-1),uo=[co],ho={key:8},po={class:"text-xl font-semibold mb-4"},mo={key:0,id:"modal_payments",class:"modal"},fo={class:"modal-box"},bo={class:"ecwp-group form-control"},_o={class:"ecwp-label label",for:"name_payment"},go={class:"form-group mt-4 flex justify-end"},vo={type:"submit",class:"btn btn-primary rounded-full mx-2"},yo={class:"mb-8"},wo={class:"flex justify-between items-center mb-4"},xo={class:"text-lg font-semibold"},ko=e("i",{class:"fas fa-plus mr-2"},null,-1),Co={class:"table-container"},To={class:"table w-full"},Mo=["onClick"],Ao=e("i",{class:"fas fa-edit"},null,-1),So=[Ao],Po=["onClick"],Eo=e("i",{class:"fas fa-trash"},null,-1),jo=[Eo],Vo={key:9},Io={class:"text-xl font-semibold mb-4"},Fo={key:0,id:"modal_expenses",class:"modal"},Ro={class:"modal-box"},Uo={class:"ecwp-group form-control"},Do={class:"ecwp-label label",for:"name_expense"},Ho={class:"form-group mt-4 flex justify-end"},No={type:"submit",class:"btn btn-primary rounded-full mx-2"},Yo={class:"mb-8"},qo={class:"flex justify-between items-center mb-4"},Lo={class:"text-lg font-semibold"},Oo=e("i",{class:"fas fa-plus mr-2"},null,-1),Xo={class:"table-container"},Wo={class:"table w-full"},Bo=["onClick"],zo=e("i",{class:"fas fa-edit"},null,-1),Go=[zo],Jo=["onClick"],Zo=e("i",{class:"fas fa-trash"},null,-1),Ko=[Zo],Qo={key:10},$o={class:"text-xl font-semibold mb-4"},ta={key:0,id:"modal_planning",class:"modal"},ea={class:"modal-box"},sa={class:"ecwp-group form-control"},na={class:"ecwp-label label",for:"name_planning"},ia={class:"ecwp-group form-control"},oa={class:"ecwp-label label",for:"background_planning"},aa={class:"ecwp-group form-control"},la={class:"ecwp-label label",for:"color_planning"},ra={class:"form-group mt-4 flex justify-end"},ca=["disabled"],da={key:0,class:"loading loading-spinner loading-sm"},ua={class:"mb-8"},ha={class:"flex justify-between items-center mb-4"},pa={class:"text-lg font-semibold"},ma=e("i",{class:"fas fa-plus mr-2"},null,-1),fa={class:"table-container"},ba={class:"table w-full"},_a=["onClick"],ga=e("i",{class:"fas fa-edit"},null,-1),va=[ga],ya=["onClick"],wa=e("i",{class:"fas fa-trash"},null,-1),xa=[wa],ka={key:11},Ca={class:"text-xl font-semibold mb-4"},Ta={class:"form-control mt-4 mb-4"},Ma={class:"cursor-pointer"},Aa={class:"label-text mr-2 font-bold"},Sa=["checked"],Pa=e("div",{class:"divider mt-2 mb-4"},null,-1),Ea={role:"tablist",class:"tabs tabs-boxed"},ja={key:0,class:"p-4"},Va={class:"grid grid-cols-1 gap-4"},Ia={class:"ecwp-group form-control"},Fa={class:"ecwp-label label",for:"email_invoice_subject"},Ra={class:"form-control"},Ua={class:"ecwp-label label"},Da=e("div",{class:"mockup-code bg-base-900 mt-4"},[e("pre",null,[e("b",null,"{REF}")]),e("pre",null,[e("b",null,"{CLIENT}")]),e("pre",null,[e("b",null,"{DUE_DATE}")]),e("pre",null,[e("b",null,"{AMOUNT}")]),e("pre",null,[e("b",null,"{CURRENCY}")])],-1),Ha={key:1,class:"p-4"},Na={class:"grid grid-cols-1 gap-4"},Ya={class:"ecwp-group form-control"},qa={class:"ecwp-label label",for:"email_quote_subject"},La={class:"form-control"},Oa={class:"ecwp-label label"},Xa=e("div",{class:"mockup-code bg-base-900 mt-4"},[e("pre",null,[e("b",null,"{REF}")]),e("pre",null,[e("b",null,"{CLIENT}")]),e("pre",null,[e("b",null,"{AMOUNT}")]),e("pre",null,[e("b",null,"{CURRENCY}")]),e("pre",null,[e("b",null,"{CREATED_DATE}")]),e("pre",null,[e("b",null,"{DUE_DATE}")])],-1),Wa={key:2,class:"p-4"},Ba={class:"grid grid-cols-1 gap-4"},za={class:"ecwp-group form-control"},Ga={class:"ecwp-label label",for:"remind_invoice_subject"},Ja={class:"form-control"},Za={class:"ecwp-label label"},Ka=e("div",{class:"mockup-code bg-base-900 mt-4"},[e("pre",null,[e("b",null,"{REF}")]),e("pre",null,[e("b",null,"{CLIENT}")]),e("pre",null,[e("b",null,"{DUE_DATE}")]),e("pre",null,[e("b",null,"{AMOUNT}")]),e("pre",null,[e("b",null,"{CURRENCY}")])],-1),Qa={key:3,class:"p-4"},$a={role:"alert",class:"alert shadow"},tl=e("i",{class:"fas fa-exclamation-circle"},null,-1),el={class:"text-xl text-center my-4"},sl={class:"mt-6 flex justify-end"},nl={type:"submit",class:"btn btn-primary rounded-full"},il=e("i",{class:"far fa-save"},null,-1),ol={key:12},al={class:"text-xl font-semibold mb-4"},ll={role:"tablist",class:"tabs tabs-boxed"},rl={key:0,class:"p-4"},cl={class:"grid grid-cols-1 gap-4"},dl={class:"ecwp-group form-control"},ul={class:"ecwp-label label",for:"email_create_account_subject"},hl={class:"form-control"},pl={class:"ecwp-label label"},ml=e("div",{class:"mockup-code bg-base-900 mt-4"},[e("pre",null,[e("b",null,"{CLIENT}")]),e("pre",null,[e("b",null,"{USERNAME}")]),e("pre",null,[e("b",null,"{PASSWORD}")])],-1),fl={class:"mt-6 flex justify-end"},bl={type:"submit",class:"btn btn-primary rounded-full"},_l=e("i",{class:"far fa-save"},null,-1),gl={key:1,class:"p-4"},vl={role:"alert",class:"alert shadow"},yl=e("i",{class:"fas fa-exclamation-circle"},null,-1),wl={class:"text-xl text-center my-4"},xl={key:13},kl={class:"text-xl font-semibold mb-4"},Cl={class:"grid grid-cols-1 gap-4"},Tl={class:"ecwp-group form-control"},Ml={class:"ecwp-label label",for:"stripe-mode"},Al={value:"test"},Sl={value:"live"},Pl={key:0},El={class:"ecwp-group form-control"},jl={class:"ecwp-label label",for:"stripe-public-key-test"},Vl={class:"ecwp-group form-control"},Il={class:"ecwp-label label",for:"stripe-secret-key-test"},Fl={key:1},Rl={class:"ecwp-group form-control"},Ul={class:"ecwp-label label",for:"stripe-public-key-live"},Dl={class:"ecwp-group form-control"},Hl={class:"ecwp-label label",for:"stripe-secret-key-live"},Nl={class:"mt-6 flex justify-end"},Yl={type:"submit",class:"btn btn-primary rounded-full"},ql=e("i",{class:"far fa-save"},null,-1),Ll={key:14},Ol={class:"text-xl font-semibold mb-4"},Xl={class:"grid grid-cols-1 gap-4"},Wl={class:"ecwp-group form-control mt-2"},Bl={class:"ecwp-label label",for:"limit-declaration"},zl={class:"ecwp-group form-control mt-2"},Gl={class:"ecwp-label label",for:"limit-tva"},Jl={class:"mt-6 flex justify-end"},Zl={type:"submit",class:"btn btn-primary rounded-full"},Kl=e("i",{class:"far fa-save"},null,-1),Ql={key:15},$l={class:"text-xl font-semibold mb-4"},tr={class:"grid grid-cols-1 gap-4"},er={class:"ecwp-group form-control mt-2"},sr={class:"ecwp-label label",for:"stripe-api"},nr={class:"mt-6 flex justify-end"},ir={type:"submit",class:"btn btn-primary rounded-full"},or=e("i",{class:"far fa-save"},null,-1),ar={key:16},lr={class:"text-xl font-semibold mb-4"},rr={class:"grid grid-cols-2 gap-4"},cr={class:"ecwp-group form-group relative join"},dr={class:"ecwp-label label",for:"license-code"},ur=["disabled"],hr=["disabled"],pr={key:0,class:"loading loading-spinner loading-sm"},mr={key:1},fr={class:"grid grid-cols-1 gap-4"},br={key:0,class:"error-message"},_r={key:1,class:"overflow-x-auto my-4"},gr={class:"table table-xs table-pin-rows table-pin-cols"},vr=e("i",{class:"fas fa-sync"},null,-1),yr=[vr],wr=e("i",{class:"far fa-trash-alt"},null,-1),xr=[wr],kr={class:"table table-xs table-pin-rows table-pin-cols mt-6"},Cr=["onClick"],Tr=["onClick"],Mr=["onClick"];function Ar(s,t,o,r,i,n){const m=I("remove-modal"),u=I("color-input"),_=I("vue-editor"),M=I("Card");return c(),d("div",ut,[i.toast.visible?(c(),d("div",{key:0,class:y(["toast",i.toast.position]),style:{zIndex:9999}},[e("div",{class:y(["alert",i.toast.type,"text-white"])},[e("span",null,l(i.toast.message),1)],2)],2)):b("",!0),x(m,{"modal-id":"modal_settings_remove","show-modal":i.showRemoveModal,title:n.translations.are_you_sure,message:n.translations.no_turning_back,confirmText:n.translations.yes_delete_it,cancelText:n.translations.cancel,onConfirm:t[0]||(t[0]=a=>n.handleDeletion(i.deleteType,i.selectedId)),onCancel:t[1]||(t[1]=a=>i.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),x(M,{topMargin:"mt-8"},{default:G(()=>[e("div",ht,[e("h2",pt,l(n.translations.settings),1)]),mt,e("div",ft,[e("div",bt,[e("a",{class:y([n.tabClass(1),"justify-start w-full"]),onClick:t[2]||(t[2]=a=>n.selectTab(1))},[_t,g(" "+l(n.translations.general_settings),1)],2),e("a",{class:y([n.tabClass(2),"justify-start w-full"]),onClick:t[3]||(t[3]=a=>n.selectTab(2))},[gt,g(" "+l(n.translations.system_settings),1)],2),e("a",{class:y([n.tabClass(3),"justify-start w-full"]),onClick:t[4]||(t[4]=a=>n.selectTab(3))},[vt,g(" "+l(n.translations.articles_settings),1)],2),e("a",{class:y([n.tabClass(4),"justify-start w-full"]),onClick:t[5]||(t[5]=a=>n.selectTab(4))},[yt,g(" "+l(n.translations.invoices_settings),1)],2),e("a",{class:y([n.tabClass(5),"justify-start w-full"]),onClick:t[6]||(t[6]=a=>n.selectTab(5))},[wt,g(" "+l(n.translations.credits_settings),1)],2),e("a",{class:y([n.tabClass(6),"justify-start w-full"]),onClick:t[7]||(t[7]=a=>n.selectTab(6))},[xt,g(" "+l(n.translations.quotes_settings),1)],2),e("a",{class:y([n.tabClass(7),"justify-start w-full"]),onClick:t[8]||(t[8]=a=>n.selectTab(7))},[kt,g(" "+l(n.translations.currency_vat_settings),1)],2),e("a",{class:y([n.tabClass(8),"justify-start w-full"]),onClick:t[9]||(t[9]=a=>n.selectTab(8))},[Ct,g(" "+l(n.translations.payments_settings),1)],2),e("a",{class:y([n.tabClass(9),"justify-start w-full"]),onClick:t[10]||(t[10]=a=>n.selectTab(9))},[Tt,g(" "+l(n.translations.expenses_settings),1)],2),i.form.easy_compta_planning_addon_active==1?(c(),d("a",{key:0,class:y([n.tabClass(10),"justify-start w-full"]),onClick:t[11]||(t[11]=a=>n.selectTab(10))},[Mt,g(" "+l(n.translations.planning_settings),1)],2)):b("",!0),i.form.easy_compta_email_addon_active==1?(c(),d("a",{key:1,class:y([n.tabClass(11),"justify-start w-full"]),onClick:t[12]||(t[12]=a=>n.selectTab(11))},[At,g(" "+l(n.translations.email_settings),1)],2)):b("",!0),i.form.easy_compta_user_addon_active==1?(c(),d("a",{key:2,class:y([n.tabClass(12),"justify-start w-full"]),onClick:t[13]||(t[13]=a=>n.selectTab(12))},[St,g(" "+l(n.translations.users_settings),1)],2)):b("",!0),i.form.easy_compta_payment_addon_active==1?(c(),d("a",{key:3,class:y([n.tabClass(13),"justify-start w-full"]),onClick:t[14]||(t[14]=a=>n.selectTab(13))},[Pt,g(" "+l(n.translations.stripe_settings),1)],2)):b("",!0),i.form.easy_compta_stats_addon_active==1?(c(),d("a",{key:4,class:y([n.tabClass(14),"justify-start w-full"]),onClick:t[15]||(t[15]=a=>n.selectTab(14))},[Et,g(" "+l(n.translations.stats_settings),1)],2)):b("",!0),i.form.easy_compta_qrcode_addon_active==1?(c(),d("a",{key:5,class:y([n.tabClass(15),"justify-start w-full"]),onClick:t[16]||(t[16]=a=>n.selectTab(15))},[jt,g(" "+l(n.translations.qrcode_settings),1)],2)):b("",!0),e("a",{class:y([n.tabClass(16),"justify-start w-full"]),onClick:t[17]||(t[17]=a=>n.selectTab(16))},[Vt,g(" "+l(n.translations.validation_license),1)],2)]),e("div",It,[i.loading?(c(),d("div",Ft,Ut)):b("",!0),i.selectedTab===1?(c(),d("div",Dt,[e("h2",Ht,l(n.translations.general_settings),1),e("form",{onSubmit:t[30]||(t[30]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",Nt,[e("div",Yt,[e("label",qt,l(n.translations.company_code),1),p(e("input",{type:"text",id:"company-code","onUpdate:modelValue":t[18]||(t[18]=a=>i.form.company_code=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.company_code]])]),e("div",Lt,[e("label",Ot,l(n.translations.tax_number),1),p(e("input",{type:"text",id:"tax-number","onUpdate:modelValue":t[19]||(t[19]=a=>i.form.tax_number=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.tax_number]])]),e("div",Xt,[e("label",Wt,l(n.translations.company_name),1),p(e("input",{type:"text",id:"company-name","onUpdate:modelValue":t[20]||(t[20]=a=>i.form.company_name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.company_name]])]),e("div",Bt,[e("label",zt,l(n.translations.address),1),p(e("input",{type:"text",id:"company-address","onUpdate:modelValue":t[21]||(t[21]=a=>i.form.company_address=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.company_address]])]),e("div",Gt,[e("label",Jt,l(n.translations.postal_code),1),p(e("input",{type:"text",id:"postal-code","onUpdate:modelValue":t[22]||(t[22]=a=>i.form.postal_code=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.postal_code]])]),e("div",Zt,[e("label",Kt,l(n.translations.city),1),p(e("input",{type:"text",id:"city","onUpdate:modelValue":t[23]||(t[23]=a=>i.form.city=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.city]])]),e("div",Qt,[e("label",$t,l(n.translations.country),1),p(e("input",{type:"text",id:"country","onUpdate:modelValue":t[24]||(t[24]=a=>i.form.country=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.country]])]),e("div",te,[e("label",ee,l(n.translations.email),1),p(e("input",{type:"email",id:"company-email","onUpdate:modelValue":t[25]||(t[25]=a=>i.form.company_email=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.company_email]])]),e("div",se,[e("label",ne,l(n.translations.phone),1),p(e("input",{type:"tel",id:"company-phone","onUpdate:modelValue":t[26]||(t[26]=a=>i.form.company_phone=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.company_phone]])]),e("div",ie,[e("label",oe,l(n.translations.mobile),1),p(e("input",{type:"tel",id:"mobile-phone","onUpdate:modelValue":t[27]||(t[27]=a=>i.form.mobile_phone=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.mobile_phone]])]),e("div",ae,[e("label",le,l(n.translations.fax),1),p(e("input",{type:"tel",id:"fax","onUpdate:modelValue":t[28]||(t[28]=a=>i.form.fax=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.fax]])])]),re,i.form.easy_compta_siret_addon_active==1?(c(),d("div",ce,[e("div",de,[e("div",ue,[e("label",he,l(n.translations.siret_api_token),1),pe,p(e("input",{type:"text",id:"company-code","onUpdate:modelValue":t[29]||(t[29]=a=>i.form.easycompta_siret_token_api=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.easycompta_siret_token_api]])])])])):b("",!0),e("div",me,[e("button",fe,[be,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===2?(c(),d("div",_e,[e("h2",ge,l(n.translations.system_settings),1),e("form",{onSubmit:t[41]||(t[41]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",ve,[e("label",ye,[e("span",we,l(n.translations.activate_logo_mentions),1),e("input",{type:"checkbox",checked:i.form.logo_mentions_active==1,onChange:t[31]||(t[31]=(...a)=>n.updateLogoMentionsActive&&n.updateLogoMentionsActive(...a)),class:"wcpa-ui-toggle"},null,40,xe)])]),i.form.logo_mentions_active==1?(c(),d("div",ke,[e("label",Ce,l(n.translations.logo_mentions),1),p(e("input",{type:"text",id:"logo-mentions","onUpdate:modelValue":t[32]||(t[32]=a=>i.form.logo_mentions=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.logo_mentions]])])):b("",!0),e("div",Te,[e("label",Me,l(n.translations.company_logo),1),e("div",Ae,[e("input",{id:"file_logo",type:"file",onChange:t[33]||(t[33]=(...a)=>n.handleLogoUpload&&n.handleLogoUpload(...a)),accept:"image/*",class:"ecwp-file-input file-input file-input-bordered file-input-info w-full max-w-xs"},null,32),e("label",Se,[e("span",null,[Pe,g(l(n.translations.select),1)])])]),i.logoPreviewUrl?(c(),d("div",Ee,[p(e("input",{type:"range",min:"0",max:"400","onUpdate:modelValue":t[34]||(t[34]=a=>i.form.logo_width=a),class:"range mt-4",onChange:t[35]||(t[35]=(...a)=>n.updatePreviewWidth&&n.updatePreviewWidth(...a))},null,544),[[f,i.form.logo_width]]),e("div",je,l(i.form.logo_width)+" px",1),i.form.logo_width!==null?(c(),d("div",Ve,[e("img",{src:i.logoPreviewUrl,alt:"Logo Preview",class:"mb-6",style:C({width:i.form.logo_width+"px"})},null,12,Ie)])):b("",!0)])):b("",!0)]),e("div",Fe,[e("label",Re,l(n.translations.default_currency),1),p(e("select",{"onUpdate:modelValue":t[36]||(t[36]=a=>i.form.default_currency=a),class:"ecwp-input input input-bordered"},[(c(!0),d(T,null,S(i.currencies,a=>(c(),d("option",{value:a.id,key:a.id},l(a.name)+" ("+l(a.symbol)+") ",9,Ue))),128))],512),[[V,i.form.default_currency]])]),e("div",De,[e("label",He,l(n.translations.currency_position),1),p(e("select",{"onUpdate:modelValue":t[37]||(t[37]=a=>i.form.currency_position=a),class:"ecwp-input input input-bordered"},[e("option",Ne,l(n.translations.before_amount),1),e("option",Ye,l(n.translations.after_amount),1)],512),[[V,i.form.currency_position]])]),e("div",qe,[e("label",Le,[e("span",Oe,l(n.translations.activate_vat),1),e("input",{type:"checkbox",checked:i.form.vat_active==1,onChange:t[38]||(t[38]=(...a)=>n.updateVatActive&&n.updateVatActive(...a)),class:"wcpa-ui-toggle"},null,40,Xe)])]),i.form.vat_active==1?(c(),d("div",We,[e("label",Be,l(n.translations.default_vat),1),p(e("select",{"onUpdate:modelValue":t[39]||(t[39]=a=>i.form.default_vat=a),class:"ecwp-input input input-bordered"},[ze,(c(!0),d(T,null,S(i.vats,a=>(c(),d("option",{value:a.id,key:a.id},l(a.description)+" - "+l(a.rate)+"% ",9,Ge))),128))],512),[[V,i.form.default_vat]])])):b("",!0),e("div",Je,[e("label",Ze,l(n.translations.format_date),1),p(e("select",{"onUpdate:modelValue":t[40]||(t[40]=a=>i.form.date_format=a),class:"ecwp-input input input-bordered"},as,512),[[V,i.form.date_format]])]),e("div",ls,[e("button",rs,[cs,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===3?(c(),d("div",ds,[i.showArticleModal?(c(),d("dialog",us,[e("div",hs,[e("h3",null,l(i.editingArticle?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[48]||(t[48]=k((...a)=>n.saveArticle&&n.saveArticle(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[42]||(t[42]=(...a)=>n.closeArticleModal&&n.closeArticleModal(...a))}," \u2715 "),e("div",ps,[e("label",ms,l(n.translations.item_ref),1),p(e("input",{type:"text",id:"name_ref","onUpdate:modelValue":t[43]||(t[43]=a=>i.articleForm.ref=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.articleForm.ref]])]),e("div",fs,[e("label",bs,l(n.translations.item_name),1),p(e("input",{type:"text",id:"name_article","onUpdate:modelValue":t[44]||(t[44]=a=>i.articleForm.name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.articleForm.name]])]),e("div",_s,[e("label",gs,l(n.translations.description),1),p(e("textarea",{id:"desc_article","onUpdate:modelValue":t[45]||(t[45]=a=>i.articleForm.description=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.articleForm.description]])]),e("div",vs,[e("label",ys,l(n.translations.unit_price),1),p(e("input",{type:"text",id:"price_article","onUpdate:modelValue":t[46]||(t[46]=a=>i.articleForm.unit_price=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.articleForm.unit_price]])]),e("div",ws,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[47]||(t[47]=(...a)=>n.closeArticleModal&&n.closeArticleModal(...a))},l(n.translations.cancel),1),e("button",xs,l(i.editingArticle?n.translations.save:n.translations.add),1)])],32)])])):b("",!0),e("div",ks,[e("h3",Cs,l(n.translations.articles_settings),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[49]||(t[49]=(...a)=>n.addArticle&&n.addArticle(...a))},[Ts,g(" "+l(n.translations.add),1)])]),e("div",Ms,[e("table",As,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.item_ref),1),e("th",null,l(n.translations.name),1),e("th",null,l(n.translations.description),1),e("th",null,l(n.translations.unit_price),1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.articles,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.ref),1),e("td",null,l(a.name),1),e("td",null,l(a.description),1),e("td",null,l(a.unit_price),1),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:v=>n.editArticle(a.id)},Es,8,Ss),e("button",{class:"p-2 text-error",onClick:v=>n.delete_item("article",a.id)},Is,8,js)])]))),128))])])]),Fs,e("h2",Rs,l(n.translations.categories),1),e("div",Us,[e("table",Ds,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.name),1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.categories,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.name),1),e("td",null,[e("button",{class:"p-2 text-error",onClick:v=>n.delete_item("category_article",a.id)},Ys,8,Hs)])]))),128))])])])])):b("",!0),i.selectedTab===4?(c(),d("div",qs,[e("h2",Ls,l(n.translations.invoices_settings),1),e("form",{onSubmit:t[66]||(t[66]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",Os,[e("div",Xs,[e("label",Ws,l(n.translations.invoice_color),1),p(e("input",{type:"text",id:"invoice-color","onUpdate:modelValue":t[50]||(t[50]=a=>i.form.invoice_color=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.invoice_color]]),x(u,{modelValue:i.form.invoice_color,"onUpdate:modelValue":t[51]||(t[51]=a=>i.form.invoice_color=a)},null,8,["modelValue"])]),e("div",Bs,[e("label",zs,l(n.translations.invoice_prefix),1),p(e("input",{type:"text",id:"invoice-prefix","onUpdate:modelValue":t[52]||(t[52]=a=>i.form.invoice_prefix=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.invoice_prefix]])])]),Gs,e("div",Js,[e("div",Zs,[e("label",Ks,[e("input",{type:"checkbox",checked:i.form.active_disbursements==1,onChange:t[53]||(t[53]=a=>n.updateFormField(a,"active_disbursements")),class:"wcpa-ui-toggle"},null,40,Qs),e("span",$s,l(n.translations.active_disbursements),1)])])]),tn,e("div",en,[e("div",sn,[e("label",nn,[e("input",{type:"checkbox",checked:i.form.show_phone==1,onChange:t[54]||(t[54]=a=>n.updateFormField(a,"show_phone")),class:"wcpa-ui-toggle"},null,40,on),e("span",an,l(n.translations.show_phone),1)])]),e("div",ln,[e("label",rn,[e("input",{type:"checkbox",checked:i.form.show_email==1,onChange:t[55]||(t[55]=a=>n.updateFormField(a,"show_email")),class:"wcpa-ui-toggle"},null,40,cn),e("span",dn,l(n.translations.show_email),1)])]),e("div",un,[e("label",hn,[e("input",{type:"checkbox",checked:i.form.show_siren==1,onChange:t[56]||(t[56]=a=>n.updateFormField(a,"show_siren")),class:"wcpa-ui-toggle"},null,40,pn),e("span",mn,l(n.translations.show_siren),1)])]),e("div",fn,[e("label",bn,[e("input",{type:"checkbox",checked:i.form.show_tax_number==1,onChange:t[57]||(t[57]=a=>n.updateFormField(a,"show_tax_number")),class:"wcpa-ui-toggle"},null,40,_n),e("span",gn,l(n.translations.show_tax_number),1)])]),e("div",vn,[e("label",yn,[e("input",{type:"checkbox",checked:i.form.show_watermark==1,onChange:t[58]||(t[58]=a=>n.updateFormField(a,"show_watermark")),class:"wcpa-ui-toggle"},null,40,wn),e("span",xn,l(n.translations.show_watermark),1)])]),i.form.show_watermark==1?(c(),d("div",kn,[e("label",Cn,[e("input",{type:"checkbox",checked:i.form.show_watermark_only_paid==1,onChange:t[59]||(t[59]=a=>n.updateFormField(a,"show_watermark_only_paid")),class:"wcpa-ui-toggle"},null,40,Tn),e("span",Mn,l(n.translations.show_watermark_only_paid),1)])])):b("",!0)]),An,e("div",Sn,[e("div",Pn,[e("label",En,l(n.translations.payment_conditions),1),p(e("input",{type:"text",id:"conditions-payment","onUpdate:modelValue":t[60]||(t[60]=a=>i.form.payment_conditions=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.payment_conditions]])]),e("div",jn,[e("label",Vn,l(n.translations.payment_mode),1),p(e("input",{type:"text",id:"mode-payment","onUpdate:modelValue":t[61]||(t[61]=a=>i.form.payment_mode=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.payment_mode]])])]),e("div",In,[e("div",Fn,[e("label",Rn,l(n.translations.invoice_terms),1),e("div",null,[x(_,{modelValue:i.form.invoice_terms,"onUpdate:modelValue":t[62]||(t[62]=a=>i.form.invoice_terms=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])]),e("div",Un,[e("div",Dn,[e("label",Hn,l(n.translations.invoice_iban),1),p(e("input",{type:"text",id:"invoice-iban","onUpdate:modelValue":t[63]||(t[63]=a=>i.form.invoice_iban=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.invoice_iban]])]),e("div",Nn,[e("label",Yn,l(n.translations.invoice_bic),1),p(e("input",{type:"text",id:"invoice-bic","onUpdate:modelValue":t[64]||(t[64]=a=>i.form.invoice_bic=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.invoice_bic]])])]),e("div",qn,[e("label",Ln,l(n.translations.invoice_footer),1),e("div",null,[x(_,{modelValue:i.form.invoice_footer,"onUpdate:modelValue":t[65]||(t[65]=a=>i.form.invoice_footer=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])])]),e("div",On,[e("button",Xn,[Wn,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===5?(c(),d("div",Bn,[e("h2",zn,l(n.translations.credits_settings),1),e("form",{onSubmit:t[72]||(t[72]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",Gn,[e("div",Jn,[e("label",Zn,l(n.translations.credit_color),1),p(e("input",{type:"text",id:"credit-color","onUpdate:modelValue":t[67]||(t[67]=a=>i.form.credit_color=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.credit_color]]),x(u,{modelValue:i.form.credit_color,"onUpdate:modelValue":t[68]||(t[68]=a=>i.form.credit_color=a)},null,8,["modelValue"])]),e("div",Kn,[e("label",Qn,l(n.translations.credit_prefix),1),p(e("input",{type:"text",id:"credit-prefix","onUpdate:modelValue":t[69]||(t[69]=a=>i.form.credit_prefix=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.credit_prefix]])])]),e("div",$n,[e("div",ti,[e("label",ei,l(n.translations.credit_footer),1),e("div",null,[x(_,{modelValue:i.form.credit_footer,"onUpdate:modelValue":t[70]||(t[70]=a=>i.form.credit_footer=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])]),e("div",si,[e("label",ni,l(n.translations.credit_terms),1),e("div",null,[x(_,{modelValue:i.form.credit_terms,"onUpdate:modelValue":t[71]||(t[71]=a=>i.form.credit_terms=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])])]),e("div",ii,[e("button",oi,[ai,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===6?(c(),d("div",li,[e("h2",ri,l(n.translations.quotes_settings),1),e("form",{onSubmit:t[78]||(t[78]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",ci,[e("div",di,[e("label",ui,l(n.translations.quote_color),1),p(e("input",{type:"text",id:"quote-color","onUpdate:modelValue":t[73]||(t[73]=a=>i.form.quote_color=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.quote_color]]),x(u,{modelValue:i.form.quote_color,"onUpdate:modelValue":t[74]||(t[74]=a=>i.form.quote_color=a)},null,8,["modelValue"])]),e("div",hi,[e("label",pi,l(n.translations.quote_prefix),1),p(e("input",{type:"text",id:"quote-prefix","onUpdate:modelValue":t[75]||(t[75]=a=>i.form.quote_prefix=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.quote_prefix]])])]),e("div",mi,[e("div",fi,[e("label",bi,l(n.translations.quote_footer),1),e("div",null,[x(_,{modelValue:i.form.quote_footer,"onUpdate:modelValue":t[76]||(t[76]=a=>i.form.quote_footer=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])]),e("div",_i,[e("label",gi,l(n.translations.quote_terms),1),e("div",null,[x(_,{modelValue:i.form.quote_terms,"onUpdate:modelValue":t[77]||(t[77]=a=>i.form.quote_terms=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])])]),e("div",vi,[e("button",yi,[wi,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===7?(c(),d("div",xi,[e("h2",ki,l(n.translations.currency_vat_settings),1),i.showCurrencyModal?(c(),d("dialog",Ci,[e("div",Ti,[e("h3",null,l(i.editingCurrency?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[84]||(t[84]=k((...a)=>n.saveCurrency&&n.saveCurrency(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[79]||(t[79]=(...a)=>n.closeCurrencyModal&&n.closeCurrencyModal(...a))}," \u2715 "),e("div",Mi,[e("label",Ai,l(n.translations.name),1),p(e("input",{type:"text",id:"name_currency","onUpdate:modelValue":t[80]||(t[80]=a=>i.currencyForm.name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.currencyForm.name]])]),e("div",Si,[e("label",Pi,l(n.translations.symbol),1),p(e("input",{type:"text",id:"symbol_currency","onUpdate:modelValue":t[81]||(t[81]=a=>i.currencyForm.symbol=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.currencyForm.symbol]])]),e("div",Ei,[e("label",ji,l(n.translations.code),1),p(e("input",{type:"text",id:"code_currency","onUpdate:modelValue":t[82]||(t[82]=a=>i.currencyForm.code=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.currencyForm.code]])]),e("div",Vi,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[83]||(t[83]=(...a)=>n.closeCurrencyModal&&n.closeCurrencyModal(...a))},l(n.translations.cancel),1),e("button",Ii,l(i.editingCurrency?n.translations.save:n.translations.add),1)])],32)])])):b("",!0),e("div",Fi,[e("div",Ri,[e("h3",Ui,l(n.translations.currencies),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[85]||(t[85]=(...a)=>n.addCurrency&&n.addCurrency(...a))},[Di,g(" "+l(n.translations.add_currency),1)])]),e("div",Hi,[e("table",Ni,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.name),1),e("th",null,l(n.translations.symbol),1),e("th",null,l(n.translations.code),1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.currencies,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.name),1),e("td",null,l(a.symbol),1),e("td",null,l(a.code),1),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:v=>n.editCurrency(a.id)},Li,8,Yi),e("button",{class:"p-2 text-error",onClick:v=>n.delete_item("currency",a.id)},Wi,8,Oi)])]))),128))])])])]),e("div",null,[i.showVATModal?(c(),d("dialog",Bi,[e("div",zi,[e("h3",null,l(i.editingVAT?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[90]||(t[90]=k((...a)=>n.saveVAT&&n.saveVAT(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[86]||(t[86]=(...a)=>n.closeVATModal&&n.closeVATModal(...a))}," \u2715 "),e("div",Gi,[e("label",Ji,l(n.translations.description),1),p(e("input",{type:"text",id:"vat-description","onUpdate:modelValue":t[87]||(t[87]=a=>i.vatForm.description=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.vatForm.description]])]),e("div",Zi,[e("label",Ki,l(n.translations.rate)+" (%)",1),p(e("input",{type:"text",id:"vat-rate","onUpdate:modelValue":t[88]||(t[88]=a=>i.vatForm.rate=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.vatForm.rate]])]),e("div",Qi,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[89]||(t[89]=(...a)=>n.closeVATModal&&n.closeVATModal(...a))},l(n.translations.cancel),1),e("button",$i,l(i.editingVAT?n.translations.save:n.translations.add),1)])],32)])])):b("",!0),e("div",to,[e("h3",eo,l(n.translations.vat_rates),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[91]||(t[91]=(...a)=>n.addVAT&&n.addVAT(...a))},[so,g(" "+l(n.translations.add_vat),1)])]),e("div",no,[e("table",io,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.description),1),e("th",null,l(n.translations.rate)+" (%)",1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.vats,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.description),1),e("td",null,l(a.rate),1),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:v=>n.editVAT(a.id)},lo,8,oo),e("button",{class:"p-2 text-error",onClick:v=>n.delete_item("vat",a.id)},uo,8,ro)])]))),128))])])])])])):b("",!0),i.selectedTab===8?(c(),d("div",ho,[e("h2",po,l(n.translations.payments_settings),1),i.showPaymentModal?(c(),d("dialog",mo,[e("div",fo,[e("h3",null,l(i.editingPayment?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[95]||(t[95]=k((...a)=>n.savePayment&&n.savePayment(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[92]||(t[92]=(...a)=>n.closePaymentModal&&n.closePaymentModal(...a))}," \u2715 "),e("div",bo,[e("label",_o,l(n.translations.name),1),p(e("input",{type:"text",id:"name_payment","onUpdate:modelValue":t[93]||(t[93]=a=>i.paymentForm.method_name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.paymentForm.method_name]])]),e("div",go,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[94]||(t[94]=(...a)=>n.closePaymentModal&&n.closePaymentModal(...a))},l(n.translations.cancel),1),e("button",vo,l(i.editingPayment?n.translations.save:n.translations.add),1)])],32)])])):b("",!0),e("div",yo,[e("div",wo,[e("h3",xo,l(n.translations.payments_methods),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[96]||(t[96]=(...a)=>n.addPayment&&n.addPayment(...a))},[ko,g(l(n.translations.add_method),1)])]),e("div",Co,[e("table",To,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.id),1),e("th",null,l(n.translations.name),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.payments,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.id),1),e("td",null,l(a.method_name),1),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:v=>n.editPayment(a.id)},So,8,Mo),e("button",{class:"p-2 text-error",onClick:v=>n.delete_item("payment",a.id)},jo,8,Po)])]))),128))])])])])])):b("",!0),i.selectedTab===9?(c(),d("div",Vo,[e("h2",Io,l(n.translations.expenses_settings),1),i.showExpenseModal?(c(),d("dialog",Fo,[e("div",Ro,[e("h3",null,l(i.editingExpense?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[100]||(t[100]=k((...a)=>n.saveExpCat&&n.saveExpCat(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[97]||(t[97]=(...a)=>n.closeExpenseModal&&n.closeExpenseModal(...a))}," \u2715 "),e("div",Uo,[e("label",Do,l(n.translations.name),1),p(e("input",{type:"text",id:"name_expense","onUpdate:modelValue":t[98]||(t[98]=a=>i.expenseForm.name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.expenseForm.name]])]),e("div",Ho,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[99]||(t[99]=(...a)=>n.closeExpenseModal&&n.closeExpenseModal(...a))},l(n.translations.cancel),1),e("button",No,l(i.editingExpense?n.translations.save:n.translations.add),1)])],32)])])):b("",!0),e("div",Yo,[e("div",qo,[e("h3",Lo,l(n.translations.expenses_categories),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[101]||(t[101]=(...a)=>n.addExpCat&&n.addExpCat(...a))},[Oo,g(" "+l(n.translations.add_category),1)])]),e("div",Xo,[e("table",Wo,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.id),1),e("th",null,l(n.translations.name),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.expenses,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.id),1),e("td",null,l(a.name),1),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:v=>n.editExpCat(a.id)},Go,8,Bo),e("button",{class:"p-2 text-error",onClick:v=>n.delete_item("expense",a.id)},Ko,8,Jo)])]))),128))])])])])])):b("",!0),i.selectedTab===10?(c(),d("div",Qo,[e("h2",$o,l(n.translations.planning_settings),1),i.showPlanningModal?(c(),d("dialog",ta,[e("div",ea,[e("h3",null,l(i.editingPlanning?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[109]||(t[109]=k((...a)=>n.savePlanningCat&&n.savePlanningCat(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[102]||(t[102]=(...a)=>n.closePlanningModal&&n.closePlanningModal(...a))}," \u2715 "),e("div",sa,[e("label",na,l(n.translations.name),1),p(e("input",{type:"text",id:"name_planning","onUpdate:modelValue":t[103]||(t[103]=a=>i.planningForm.name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.planningForm.name]])]),e("div",ia,[e("label",oa,l(n.translations.background),1),p(e("input",{type:"text",id:"background_planning","onUpdate:modelValue":t[104]||(t[104]=a=>i.planningForm.background=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.planningForm.background]]),x(u,{modelValue:i.planningForm.background,"onUpdate:modelValue":t[105]||(t[105]=a=>i.planningForm.background=a)},null,8,["modelValue"])]),e("div",aa,[e("label",la,l(n.translations.text_color),1),p(e("input",{type:"text",id:"color_planning","onUpdate:modelValue":t[106]||(t[106]=a=>i.planningForm.color=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.planningForm.color]]),x(u,{modelValue:i.planningForm.color,"onUpdate:modelValue":t[107]||(t[107]=a=>i.planningForm.color=a)},null,8,["modelValue"])]),e("div",ra,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[108]||(t[108]=(...a)=>n.closePlanningModal&&n.closePlanningModal(...a))},l(n.translations.cancel),1),e("button",{type:"submit",class:"btn btn-primary rounded-full mx-2",disabled:i.loading},[g(l(i.editingPlanning?n.translations.save:n.translations.add)+" ",1),i.loading?(c(),d("span",da)):b("",!0)],8,ca)])],32)])])):b("",!0),e("div",ua,[e("div",ha,[e("h3",pa,l(n.translations.planning_categories),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[110]||(t[110]=(...a)=>n.addPlanningCat&&n.addPlanningCat(...a))},[ma,g(" "+l(n.translations.add_category),1)])]),e("div",fa,[e("table",ba,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.id),1),e("th",null,l(n.translations.name),1),e("th",null,l(n.translations.background),1),e("th",null,l(n.translations.color),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.planning,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.id),1),e("td",null,l(a.name),1),e("td",null,[e("span",{class:"ecwp-color-preview",style:C({backgroundColor:a.background})},null,4)]),e("td",null,[e("span",{class:"ecwp-color-preview",style:C({backgroundColor:a.color})},null,4)]),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:v=>n.editPlanningCat(a.id)},va,8,_a),e("button",{class:"p-2 text-error",onClick:v=>n.delete_item("planning",a.id)},xa,8,ya)])]))),128))])])])])])):b("",!0),i.selectedTab===11?(c(),d("div",ka,[e("h2",Ca,l(n.translations.email_settings),1),e("form",{onSubmit:t[122]||(t[122]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",Ta,[e("label",Ma,[e("span",Aa,l(n.translations.email_log_active),1),e("input",{type:"checkbox",checked:i.form.email_log_active==1,onChange:t[111]||(t[111]=(...a)=>n.updateEmailLogsActive&&n.updateEmailLogsActive(...a)),class:"wcpa-ui-toggle"},null,40,Sa)])]),Pa,e("div",Ea,[e("a",{role:"tab",class:y(["tab",{"tab-active":i.activeTabEmail==="tab1"}]),onClick:t[112]||(t[112]=a=>n.setActiveTab("tab1"))},l(n.translations.email_invoice),3),e("a",{role:"tab",class:y(["tab",{"tab-active":i.activeTabEmail==="tab2"}]),onClick:t[113]||(t[113]=a=>n.setActiveTab("tab2"))},l(n.translations.email_quote),3),e("a",{role:"tab",class:y(["tab",{"tab-active":i.activeTabEmail==="tab3"}]),onClick:t[114]||(t[114]=a=>n.setActiveTab("tab3"))},l(n.translations.invoice_reminder),3),e("a",{role:"tab",class:y(["tab",{"tab-active":i.activeTabEmail==="tab4"}]),onClick:t[115]||(t[115]=a=>n.setActiveTab("tab4"))},l(n.translations.payment_received),3)]),i.activeTabEmail==="tab1"?(c(),d("div",ja,[e("div",Va,[e("div",Ia,[e("label",Fa,l(n.translations.email_subject),1),p(e("input",{type:"text",id:"email_invoice_subject","onUpdate:modelValue":t[116]||(t[116]=a=>i.form.email_invoice_subject=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.email_invoice_subject]])]),e("div",Ra,[e("label",Ua,l(n.translations.email_content),1),e("div",null,[x(_,{modelValue:i.form.email_invoice_content,"onUpdate:modelValue":t[117]||(t[117]=a=>i.form.email_invoice_content=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])]),Da])])])):b("",!0),i.activeTabEmail==="tab2"?(c(),d("div",Ha,[e("div",Na,[e("div",Ya,[e("label",qa,l(n.translations.email_subject),1),p(e("input",{type:"text",id:"email_quote_subject","onUpdate:modelValue":t[118]||(t[118]=a=>i.form.email_quote_subject=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.email_quote_subject]])]),e("div",La,[e("label",Oa,l(n.translations.email_content),1),e("div",null,[x(_,{modelValue:i.form.email_quote_content,"onUpdate:modelValue":t[119]||(t[119]=a=>i.form.email_quote_content=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])]),Xa])])])):b("",!0),i.activeTabEmail==="tab3"?(c(),d("div",Wa,[e("div",Ba,[e("div",za,[e("label",Ga,l(n.translations.email_subject),1),p(e("input",{type:"text",id:"remind_invoice_subject","onUpdate:modelValue":t[120]||(t[120]=a=>i.form.remind_invoice_subject=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.remind_invoice_subject]])]),e("div",Ja,[e("label",Za,l(n.translations.email_content),1),e("div",null,[x(_,{modelValue:i.form.remind_invoice_content,"onUpdate:modelValue":t[121]||(t[121]=a=>i.form.remind_invoice_content=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])]),Ka])])])):b("",!0),i.activeTabEmail==="tab4"?(c(),d("div",Qa,[e("div",$a,[tl,e("div",null,[e("h2",el,l(n.translations.coming_soon),1)])])])):b("",!0),e("div",sl,[e("button",nl,[il,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===12?(c(),d("div",ol,[e("h2",al,l(n.translations.users_settings),1),e("div",ll,[e("a",{role:"tab",class:y(["tab",{"tab-active":i.activeTabUsers==="user1"}]),onClick:t[123]||(t[123]=a=>n.setActiveTabUsers("user1"))}," Automatic create account ",2),e("a",{role:"tab",class:y(["tab",{"tab-active":i.activeTabUsers==="user2"}]),onClick:t[124]||(t[124]=a=>n.setActiveTabUsers("user2"))}," Lost password ",2)]),i.activeTabUsers==="user1"?(c(),d("div",rl,[e("form",{onSubmit:t[127]||(t[127]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",cl,[e("div",dl,[e("label",ul,l(n.translations.email_subject),1),p(e("input",{type:"text",id:"email_create_account_subject","onUpdate:modelValue":t[125]||(t[125]=a=>i.form.email_create_account_subject=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.email_create_account_subject]])]),e("div",hl,[e("label",pl,l(n.translations.email_content),1),e("div",null,[x(_,{modelValue:i.form.email_create_account_content,"onUpdate:modelValue":t[126]||(t[126]=a=>i.form.email_create_account_content=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])]),ml])]),e("div",fl,[e("button",bl,[_l,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.activeTabUsers==="user2"?(c(),d("div",gl,[e("div",vl,[yl,e("div",null,[e("h2",wl,l(n.translations.coming_soon),1)])])])):b("",!0)])):b("",!0),i.selectedTab===13?(c(),d("div",xl,[e("h2",kl,l(n.translations.stripe_settings),1),e("form",{onSubmit:t[133]||(t[133]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",Cl,[e("div",Tl,[e("label",Ml,l(n.translations.stripe_mode),1),p(e("select",{id:"stripe-mode","onUpdate:modelValue":t[128]||(t[128]=a=>i.form.stripe_mode=a),class:"ecwp-input input input-bordered",required:""},[e("option",Al,l(n.translations.test_mode),1),e("option",Sl,l(n.translations.live_mode),1)],512),[[V,i.form.stripe_mode]])]),i.form.stripe_mode==="test"?(c(),d("div",Pl,[e("div",El,[e("label",jl,l(n.translations.stripe_public_key_test),1),p(e("input",{type:"text",id:"stripe-public-key-test","onUpdate:modelValue":t[129]||(t[129]=a=>i.form.stripe_public_key_test=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.stripe_public_key_test]])]),e("div",Vl,[e("label",Il,l(n.translations.stripe_secret_key_test),1),p(e("input",{type:"text",id:"stripe-secret-key-test","onUpdate:modelValue":t[130]||(t[130]=a=>i.form.stripe_secret_key_test=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.stripe_secret_key_test]])])])):b("",!0),i.form.stripe_mode==="live"?(c(),d("div",Fl,[e("div",Rl,[e("label",Ul,l(n.translations.stripe_public_key_live),1),p(e("input",{type:"text",id:"stripe-public-key-live","onUpdate:modelValue":t[131]||(t[131]=a=>i.form.stripe_public_key_live=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.stripe_public_key_live]])]),e("div",Dl,[e("label",Hl,l(n.translations.stripe_secret_key_live),1),p(e("input",{type:"text",id:"stripe-secret-key-live","onUpdate:modelValue":t[132]||(t[132]=a=>i.form.stripe_secret_key_live=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.stripe_secret_key_live]])])])):b("",!0)]),e("div",Nl,[e("button",Yl,[ql,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===14?(c(),d("div",Ll,[e("h2",Ol,l(n.translations.stats_settings),1),e("form",{onSubmit:t[136]||(t[136]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",Xl,[e("div",Wl,[e("label",Bl,l(n.translations.limit_declaration),1),p(e("input",{type:"number",id:"limit-declaration","onUpdate:modelValue":t[134]||(t[134]=a=>i.form.limit_declaration=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.limit_declaration]])]),e("div",zl,[e("label",Gl,l(n.translations.limit_tva),1),p(e("input",{type:"number",id:"limit-tva","onUpdate:modelValue":t[135]||(t[135]=a=>i.form.limit_tva=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.limit_tva]])])]),e("div",Jl,[e("button",Zl,[Kl,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===15?(c(),d("div",Ql,[e("h2",$l,l(n.translations.qrcode_settings),1),e("form",{onSubmit:t[138]||(t[138]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",tr,[e("div",er,[e("label",sr,l(n.translations.stripe_api),1),p(e("input",{type:"text",id:"stripe-api","onUpdate:modelValue":t[137]||(t[137]=a=>i.form.easy_compta_stripe_secret_api=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.easy_compta_stripe_secret_api]])])]),e("div",nr,[e("button",ir,[or,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===16?(c(),d("div",ar,[e("h2",lr,l(n.translations.validation_license),1),e("div",rr,[e("div",cr,[e("label",dr,l(n.translations.license_key),1),p(e("input",{type:"text",id:"license-code","onUpdate:modelValue":t[139]||(t[139]=a=>i.license_key=a),class:"ecwp-input input input-bordered w-full",disabled:i.licenseData&&i.licenseData.valid,required:""},null,8,ur),[[f,i.license_key]]),e("button",{onClick:t[140]||(t[140]=(...a)=>n.checkLicense&&n.checkLicense(...a)),class:"btn btn-primary join-item rounded-r-full mt-5 -me-1",disabled:i.loadingLicense||i.licenseData&&i.licenseData.valid},[i.loadingLicense?(c(),d("span",pr)):(c(),d("span",mr,l(n.translations.validate),1))],8,hr)])]),e("div",fr,[i.errorMessage?(c(),d("div",br,l(i.errorMessage),1)):b("",!0),i.licenseData?(c(),d("div",_r,[e("table",gr,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.domain),1),e("th",null,l(n.translations.addon_name),1),e("th",null,l(n.translations.activation_date),1),e("th",null,l(n.translations.expiry_date),1),e("th",null,l(n.translations.status),1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[e("tr",null,[e("td",null,l(i.licenseData.domain),1),e("td",null,[(c(!0),d(T,null,S(i.licenseData.plugins,(a,v)=>(c(),d("div",{key:v},l(v),1))),128))]),e("td",null,l(i.licenseData.start_date),1),e("td",null,l(i.licenseData.end_date),1),e("td",null,l(i.licenseData.valid?"Valid":"Invalid"),1),e("td",null,[e("button",{onClick:t[141]||(t[141]=a=>n.refresh_licence()),class:"btn btn-circle text-blue-500 hover:text-blue-700 mx-1"},yr),e("button",{onClick:t[142]||(t[142]=a=>n.delete_item("licence","")),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},xr)])])])]),e("table",kr,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.addon_name),1),e("th",null,l(n.translations.slug),1),e("th",null,l(n.translations.installed),1),e("th",null,l(n.translations.version),1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.licenseData.plugins,a=>(c(),d("tr",{key:a},[e("td",null,l(a.product_name),1),e("td",null,l(a.product_slug),1),e("td",null,[i.installed_versions[a.product_slug]?(c(),d(T,{key:0},[g(l(n.translations.installed),1)],64)):(c(),d(T,{key:1},[g(l(n.translations.not_installed),1)],64))]),e("td",null,l(i.installed_versions[a.product_slug]),1),e("td",null,[i.installed_versions[a.product_slug]?(c(),d(T,{key:0},[e("button",{onClick:v=>n.checkUpdatePlugin(a.product_slug,i.installed_versions[a.product_slug]),class:"btn btn-sm text-red-500 hover:text-red-700 mx-1"},l(n.translations.check_update),9,Cr),i.updatesAvailable[a.product_slug]?(c(),d("button",{key:0,onClick:v=>n.installUpdatePlugin(a.product_slug,i.updatesAvailable[a.product_slug]),class:"btn btn-sm text-blue-500 hover:text-blue-700 mx-1"},l(n.translations.download),9,Tr)):b("",!0)],64)):(c(),d("button",{key:1,onClick:v=>n.installUpdatePlugin(a.product_slug,i.updatesAvailable[a.product_slug]),class:"btn btn-sm text-green-500 hover:green-red-700 mx-1"},l(n.translations.download),9,Mr))])]))),128))])])])):b("",!0)])])):b("",!0)])])]),_:1})])}var Sr=tt(dt,[["render",Ar]]);function R(s){return R=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},R(s)}var Pr=/^\s+/,Er=/\s+$/;function h(s,t){if(s=s||"",t=t||{},s instanceof h)return s;if(!(this instanceof h))return new h(s,t);var o=jr(s);this._originalInput=s,this._r=o.r,this._g=o.g,this._b=o.b,this._a=o.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||o.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=o.ok}h.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(t.r*299+t.g*587+t.b*114)/1e3},getLuminance:function(){var t=this.toRgb(),o,r,i,n,m,u;return o=t.r/255,r=t.g/255,i=t.b/255,o<=.03928?n=o/12.92:n=Math.pow((o+.055)/1.055,2.4),r<=.03928?m=r/12.92:m=Math.pow((r+.055)/1.055,2.4),i<=.03928?u=i/12.92:u=Math.pow((i+.055)/1.055,2.4),.2126*n+.7152*m+.0722*u},setAlpha:function(t){return this._a=J(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=L(this._r,this._g,this._b);return{h:t.h*360,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=L(this._r,this._g,this._b),o=Math.round(t.h*360),r=Math.round(t.s*100),i=Math.round(t.v*100);return this._a==1?"hsv("+o+", "+r+"%, "+i+"%)":"hsva("+o+", "+r+"%, "+i+"%, "+this._roundA+")"},toHsl:function(){var t=q(this._r,this._g,this._b);return{h:t.h*360,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=q(this._r,this._g,this._b),o=Math.round(t.h*360),r=Math.round(t.s*100),i=Math.round(t.l*100);return this._a==1?"hsl("+o+", "+r+"%, "+i+"%)":"hsla("+o+", "+r+"%, "+i+"%, "+this._roundA+")"},toHex:function(t){return O(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return Rr(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(w(this._r,255)*100)+"%",g:Math.round(w(this._g,255)*100)+"%",b:Math.round(w(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(w(this._r,255)*100)+"%, "+Math.round(w(this._g,255)*100)+"%, "+Math.round(w(this._b,255)*100)+"%)":"rgba("+Math.round(w(this._r,255)*100)+"%, "+Math.round(w(this._g,255)*100)+"%, "+Math.round(w(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:zr[O(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var o="#"+X(this._r,this._g,this._b,this._a),r=o,i=this._gradientType?"GradientType = 1, ":"";if(t){var n=h(t);r="#"+X(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+i+"startColorstr="+o+",endColorstr="+r+")"},toString:function(t){var o=!!t;t=t||this._format;var r=!1,i=this._a<1&&this._a>=0,n=!o&&i&&(t==="hex"||t==="hex6"||t==="hex3"||t==="hex4"||t==="hex8"||t==="name");return n?t==="name"&&this._a===0?this.toName():this.toRgbString():(t==="rgb"&&(r=this.toRgbString()),t==="prgb"&&(r=this.toPercentageRgbString()),(t==="hex"||t==="hex6")&&(r=this.toHexString()),t==="hex3"&&(r=this.toHexString(!0)),t==="hex4"&&(r=this.toHex8String(!0)),t==="hex8"&&(r=this.toHex8String()),t==="name"&&(r=this.toName()),t==="hsl"&&(r=this.toHslString()),t==="hsv"&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return h(this.toString())},_applyModification:function(t,o){var r=t.apply(null,[this].concat([].slice.call(o)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(Nr,arguments)},brighten:function(){return this._applyModification(Yr,arguments)},darken:function(){return this._applyModification(qr,arguments)},desaturate:function(){return this._applyModification(Ur,arguments)},saturate:function(){return this._applyModification(Dr,arguments)},greyscale:function(){return this._applyModification(Hr,arguments)},spin:function(){return this._applyModification(Lr,arguments)},_applyCombination:function(t,o){return t.apply(null,[this].concat([].slice.call(o)))},analogous:function(){return this._applyCombination(Wr,arguments)},complement:function(){return this._applyCombination(Or,arguments)},monochromatic:function(){return this._applyCombination(Br,arguments)},splitcomplement:function(){return this._applyCombination(Xr,arguments)},triad:function(){return this._applyCombination(W,[3])},tetrad:function(){return this._applyCombination(W,[4])}};h.fromRatio=function(s,t){if(R(s)=="object"){var o={};for(var r in s)s.hasOwnProperty(r)&&(r==="a"?o[r]=s[r]:o[r]=F(s[r]));s=o}return h(s,t)};function jr(s){var t={r:0,g:0,b:0},o=1,r=null,i=null,n=null,m=!1,u=!1;return typeof s=="string"&&(s=Kr(s)),R(s)=="object"&&(j(s.r)&&j(s.g)&&j(s.b)?(t=Vr(s.r,s.g,s.b),m=!0,u=String(s.r).substr(-1)==="%"?"prgb":"rgb"):j(s.h)&&j(s.s)&&j(s.v)?(r=F(s.s),i=F(s.v),t=Fr(s.h,r,i),m=!0,u="hsv"):j(s.h)&&j(s.s)&&j(s.l)&&(r=F(s.s),n=F(s.l),t=Ir(s.h,r,n),m=!0,u="hsl"),s.hasOwnProperty("a")&&(o=s.a)),o=J(o),{ok:m,format:s.format||u,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:o}}function Vr(s,t,o){return{r:w(s,255)*255,g:w(t,255)*255,b:w(o,255)*255}}function q(s,t,o){s=w(s,255),t=w(t,255),o=w(o,255);var r=Math.max(s,t,o),i=Math.min(s,t,o),n,m,u=(r+i)/2;if(r==i)n=m=0;else{var _=r-i;switch(m=u>.5?_/(2-r-i):_/(r+i),r){case s:n=(t-o)/_+(t<o?6:0);break;case t:n=(o-s)/_+2;break;case o:n=(s-t)/_+4;break}n/=6}return{h:n,s:m,l:u}}function Ir(s,t,o){var r,i,n;s=w(s,360),t=w(t,100),o=w(o,100);function m(M,a,v){return v<0&&(v+=1),v>1&&(v-=1),v<1/6?M+(a-M)*6*v:v<1/2?a:v<2/3?M+(a-M)*(2/3-v)*6:M}if(t===0)r=i=n=o;else{var u=o<.5?o*(1+t):o+t-o*t,_=2*o-u;r=m(_,u,s+1/3),i=m(_,u,s),n=m(_,u,s-1/3)}return{r:r*255,g:i*255,b:n*255}}function L(s,t,o){s=w(s,255),t=w(t,255),o=w(o,255);var r=Math.max(s,t,o),i=Math.min(s,t,o),n,m,u=r,_=r-i;if(m=r===0?0:_/r,r==i)n=0;else{switch(r){case s:n=(t-o)/_+(t<o?6:0);break;case t:n=(o-s)/_+2;break;case o:n=(s-t)/_+4;break}n/=6}return{h:n,s:m,v:u}}function Fr(s,t,o){s=w(s,360)*6,t=w(t,100),o=w(o,100);var r=Math.floor(s),i=s-r,n=o*(1-t),m=o*(1-i*t),u=o*(1-(1-i)*t),_=r%6,M=[o,m,n,n,u,o][_],a=[u,o,o,m,n,n][_],v=[n,n,u,o,o,m][_];return{r:M*255,g:a*255,b:v*255}}function O(s,t,o,r){var i=[E(Math.round(s).toString(16)),E(Math.round(t).toString(16)),E(Math.round(o).toString(16))];return r&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}function Rr(s,t,o,r,i){var n=[E(Math.round(s).toString(16)),E(Math.round(t).toString(16)),E(Math.round(o).toString(16)),E(Z(r))];return i&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)&&n[3].charAt(0)==n[3].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0)+n[3].charAt(0):n.join("")}function X(s,t,o,r){var i=[E(Z(r)),E(Math.round(s).toString(16)),E(Math.round(t).toString(16)),E(Math.round(o).toString(16))];return i.join("")}h.equals=function(s,t){return!s||!t?!1:h(s).toRgbString()==h(t).toRgbString()};h.random=function(){return h.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function Ur(s,t){t=t===0?0:t||10;var o=h(s).toHsl();return o.s-=t/100,o.s=H(o.s),h(o)}function Dr(s,t){t=t===0?0:t||10;var o=h(s).toHsl();return o.s+=t/100,o.s=H(o.s),h(o)}function Hr(s){return h(s).desaturate(100)}function Nr(s,t){t=t===0?0:t||10;var o=h(s).toHsl();return o.l+=t/100,o.l=H(o.l),h(o)}function Yr(s,t){t=t===0?0:t||10;var o=h(s).toRgb();return o.r=Math.max(0,Math.min(255,o.r-Math.round(255*-(t/100)))),o.g=Math.max(0,Math.min(255,o.g-Math.round(255*-(t/100)))),o.b=Math.max(0,Math.min(255,o.b-Math.round(255*-(t/100)))),h(o)}function qr(s,t){t=t===0?0:t||10;var o=h(s).toHsl();return o.l-=t/100,o.l=H(o.l),h(o)}function Lr(s,t){var o=h(s).toHsl(),r=(o.h+t)%360;return o.h=r<0?360+r:r,h(o)}function Or(s){var t=h(s).toHsl();return t.h=(t.h+180)%360,h(t)}function W(s,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var o=h(s).toHsl(),r=[h(s)],i=360/t,n=1;n<t;n++)r.push(h({h:(o.h+n*i)%360,s:o.s,l:o.l}));return r}function Xr(s){var t=h(s).toHsl(),o=t.h;return[h(s),h({h:(o+72)%360,s:t.s,l:t.l}),h({h:(o+216)%360,s:t.s,l:t.l})]}function Wr(s,t,o){t=t||6,o=o||30;var r=h(s).toHsl(),i=360/o,n=[h(s)];for(r.h=(r.h-(i*t>>1)+720)%360;--t;)r.h=(r.h+i)%360,n.push(h(r));return n}function Br(s,t){t=t||6;for(var o=h(s).toHsv(),r=o.h,i=o.s,n=o.v,m=[],u=1/t;t--;)m.push(h({h:r,s:i,v:n})),n=(n+u)%1;return m}h.mix=function(s,t,o){o=o===0?0:o||50;var r=h(s).toRgb(),i=h(t).toRgb(),n=o/100,m={r:(i.r-r.r)*n+r.r,g:(i.g-r.g)*n+r.g,b:(i.b-r.b)*n+r.b,a:(i.a-r.a)*n+r.a};return h(m)};h.readability=function(s,t){var o=h(s),r=h(t);return(Math.max(o.getLuminance(),r.getLuminance())+.05)/(Math.min(o.getLuminance(),r.getLuminance())+.05)};h.isReadable=function(s,t,o){var r=h.readability(s,t),i,n;switch(n=!1,i=Qr(o),i.level+i.size){case"AAsmall":case"AAAlarge":n=r>=4.5;break;case"AAlarge":n=r>=3;break;case"AAAsmall":n=r>=7;break}return n};h.mostReadable=function(s,t,o){var r=null,i=0,n,m,u,_;o=o||{},m=o.includeFallbackColors,u=o.level,_=o.size;for(var M=0;M<t.length;M++)n=h.readability(s,t[M]),n>i&&(i=n,r=h(t[M]));return h.isReadable(s,r,{level:u,size:_})||!m?r:(o.includeFallbackColors=!1,h.mostReadable(s,["#fff","#000"],o))};var Y=h.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},zr=h.hexNames=Gr(Y);function Gr(s){var t={};for(var o in s)s.hasOwnProperty(o)&&(t[s[o]]=o);return t}function J(s){return s=parseFloat(s),(isNaN(s)||s<0||s>1)&&(s=1),s}function w(s,t){Jr(s)&&(s="100%");var o=Zr(s);return s=Math.min(t,Math.max(0,parseFloat(s))),o&&(s=parseInt(s*t,10)/100),Math.abs(s-t)<1e-6?1:s%t/parseFloat(t)}function H(s){return Math.min(1,Math.max(0,s))}function A(s){return parseInt(s,16)}function Jr(s){return typeof s=="string"&&s.indexOf(".")!=-1&&parseFloat(s)===1}function Zr(s){return typeof s=="string"&&s.indexOf("%")!=-1}function E(s){return s.length==1?"0"+s:""+s}function F(s){return s<=1&&(s=s*100+"%"),s}function Z(s){return Math.round(parseFloat(s)*255).toString(16)}function B(s){return A(s)/255}var P=function(){var s="[-\\+]?\\d+%?",t="[-\\+]?\\d*\\.\\d+%?",o="(?:"+t+")|(?:"+s+")",r="[\\s|\\(]+("+o+")[,|\\s]+("+o+")[,|\\s]+("+o+")\\s*\\)?",i="[\\s|\\(]+("+o+")[,|\\s]+("+o+")[,|\\s]+("+o+")[,|\\s]+("+o+")\\s*\\)?";return{CSS_UNIT:new RegExp(o),rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function j(s){return!!P.CSS_UNIT.exec(s)}function Kr(s){s=s.replace(Pr,"").replace(Er,"").toLowerCase();var t=!1;if(Y[s])s=Y[s],t=!0;else if(s=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var o;return(o=P.rgb.exec(s))?{r:o[1],g:o[2],b:o[3]}:(o=P.rgba.exec(s))?{r:o[1],g:o[2],b:o[3],a:o[4]}:(o=P.hsl.exec(s))?{h:o[1],s:o[2],l:o[3]}:(o=P.hsla.exec(s))?{h:o[1],s:o[2],l:o[3],a:o[4]}:(o=P.hsv.exec(s))?{h:o[1],s:o[2],v:o[3]}:(o=P.hsva.exec(s))?{h:o[1],s:o[2],v:o[3],a:o[4]}:(o=P.hex8.exec(s))?{r:A(o[1]),g:A(o[2]),b:A(o[3]),a:B(o[4]),format:t?"name":"hex8"}:(o=P.hex6.exec(s))?{r:A(o[1]),g:A(o[2]),b:A(o[3]),format:t?"name":"hex"}:(o=P.hex4.exec(s))?{r:A(o[1]+""+o[1]),g:A(o[2]+""+o[2]),b:A(o[3]+""+o[3]),a:B(o[4]+""+o[4]),format:t?"name":"hex8"}:(o=P.hex3.exec(s))?{r:A(o[1]+""+o[1]),g:A(o[2]+""+o[2]),b:A(o[3]+""+o[3]),format:t?"name":"hex"}:!1}function Qr(s){var t,o;return s=s||{level:"AA",size:"small"},t=(s.level||"AA").toUpperCase(),o=(s.size||"small").toLowerCase(),t!=="AA"&&t!=="AAA"&&(t="AA"),o!=="small"&&o!=="large"&&(o="small"),{level:t,size:o}}var K={name:"ColorPicker",props:["color","position","boxRect","disableAlpha","disableTextInputs"],emits:["updateColor","hueInputStart","hueInputEnd","hueInput","alphaInputStart","alphaInputEnd","alphaInput","saturationInputStart","saturationInputEnd","saturationInput","ready","change"],inject:["tinycolor"],data(){return{h:void 0,s:void 0,v:void 0,a:void 0,hueTranslateX:0,alphaTranslateX:0,saturationTranslateX:0,saturationTranslateY:0,sliderPointerWidth:0,saturationPointerWidth:0,saturationPointerHeight:0,pickerPositionA:{anchor:"top",offset:0},pickerPositionB:{anchor:"left",offset:0},pickerWidth:0,pickerHeight:0,textInputsFormat:"rgb",textInputActive:null,textInputsFreeze:{},arrowColor:"#0f0f0f",sliderWidth:0}},computed:{pureHueBackground(){return{background:"hsl("+this.h+", 100%, 50%)"}},hexString(){return this.color.toHexString()},huePointerStyles(){return{transform:"translate("+(this.hueTranslateX-this.sliderPointerWidth*.5)+"px)"}},alphaPointerStyles(){return{transform:"translate("+(this.alphaTranslateX-this.sliderPointerWidth*.5)+"px)"}},alphaPointerTransparentStyles(){return{backgroundPosition:-this.alphaTranslateX+"px"}},alphaPointerColorStyles(){return{opacity:this.a}},alphaCanvasStyles(){return{background:"linear-gradient(90deg, transparent 0%, "+this.color.toHexString()+" 100%)"}},saturationPointerStyles(){const s=this.saturationTranslateX-this.saturationPointerWidth*.5,t=this.saturationTranslateY+this.saturationPointerHeight*.5;return{transform:"translate("+s+"px, "+t+"px)"}},arrowsStyles(){return{"--arrow-color":this.arrowColor}},pickerPosition(){const s={},t={top:"bottom",bottom:"top",left:"right",right:"left"};let o;["top","bottom"].includes(this.position[0])?(s.marginLeft=0,s.marginRight=0,o=this.boxRect.height):(s.marginTop=0,s.marginBottom=0,o=this.boxRect.width);let r=t[this.position[0]];return s[r]=o+"px",this.position[1]==="center"?(["left","right"].includes(r)?(r="top",o=this.pickerHeight-this.boxRect.height):(r="left",o=this.pickerWidth-this.boxRect.width),o*=.5):(r=t[this.position[1]],o=0),s[r]=-o+"px",s},textInputs(){const s=this.textInputsFormat,t={};if(["name","hex"].includes(s))t.hex=this.color.toString("hex");else{const o=this.color.toString(s).split("(")[1].slice(0,-1).split(", ");s.split("").forEach((r,i)=>t[r]=o[i])}if(this.disableAlpha||(t.a=Number(this.color.getAlpha().toFixed(2))),t.hasOwnProperty("h")&&(t.h=Math.round(this.h),t.hasOwnProperty("l"))){let o=this.s;const r=this.v||.001,i=(2-o)*r/2;i<.5&&(o*=r/(i*2),t.s=Math.round(o*100)+"%")}return t}},methods:{saturationPickStart(s){this.getCanvasRects(),document.addEventListener("pointerup",this.saturationPickEnd),document.addEventListener("pointermove",this.saturationPickMove),this.saturationPickMove(s),this.emitHook("saturationInputStart",{s:this.s,v:this.v}),this.colorSnapshot=this.color.toRgbString()},saturationPickEnd(s){document.removeEventListener("pointerup",this.saturationPickEnd),document.removeEventListener("pointermove",this.saturationPickMove),this.emitHook("saturationInputEnd",{s:this.s,v:this.v}),this.colorSnapshot!==this.color.toRgbString()&&this.emitHook("change",{h:this.h,s:this.s,v:this.v,a:this.a})},saturationPickMove(s){s.clientX>=this.saturationCanvasRect.x&&s.clientX<=this.saturationCanvasRect.right?this.s=(s.clientX-this.saturationCanvasRect.x)/this.saturationCanvasRect.width:s.clientX<this.saturationCanvasRect.x?this.s=0:this.s=1,s.clientY>=this.saturationCanvasRect.y&&s.clientY<=this.saturationCanvasRect.bottom?this.v=1-(s.clientY-this.saturationCanvasRect.y)/this.saturationCanvasRect.height:s.clientY<this.saturationCanvasRect.y?this.v=1:this.v=0},huePickStart(s){this.getCanvasRects(),document.addEventListener("pointerup",this.huePickEnd),document.addEventListener("pointermove",this.huePickMove),this.huePickMove(s),this.emitHook("hueInputStart",{h:this.h}),this.colorSnapshot=this.color.toRgbString()},huePickEnd(s){document.removeEventListener("pointerup",this.huePickEnd),document.removeEventListener("pointermove",this.huePickMove),this.emitHook("hueInputEnd",{h:this.h}),this.colorSnapshot!==this.color.toRgbString()&&this.emitHook("change",{h:this.h,s:this.s,v:this.v,a:this.a})},huePickMove(s){s.clientX>=this.hueCanvasRect.x&&s.clientX<=this.hueCanvasRect.right?this.h=(s.clientX-this.hueCanvasRect.x)*360/this.hueCanvasRect.width:s.clientX<this.hueCanvasRect.x?this.h=0:this.h=360},alphaPickStart(s){this.getCanvasRects(),document.addEventListener("pointerup",this.alphaPickEnd),document.addEventListener("pointermove",this.alphaPickMove),this.alphaPickMove(s),this.emitHook("alphaInputStart",{a:this.a}),this.colorSnapshot=this.color.toRgbString()},alphaPickEnd(s){document.removeEventListener("pointerup",this.alphaPickEnd),document.removeEventListener("pointermove",this.alphaPickMove),this.emitHook("alphaInputEnd",{a:this.a}),this.colorSnapshot!==this.color.toRgbString()&&this.emitHook("change",{h:this.h,s:this.s,v:this.v,a:this.a})},alphaPickMove(s){s.clientX>=this.alphaCanvasRect.x&&s.clientX<=this.alphaCanvasRect.right?this.a=(s.clientX-this.alphaCanvasRect.x)/this.alphaCanvasRect.width:s.clientX<this.alphaCanvasRect.x?this.a=0:this.a=1},emitUpdate(s){s=s||{h:this.h,s:this.s,v:this.v,a:this.a},this.$emit("updateColor",s)},emitHook(s,t){if(typeof t=="object")for(let[o,r]of Object.entries(t))t[o]=Number(r.toFixed(3));else t=Number(t.toFixed(3));this.$emit(s,t)},textInputInputHandler(s){const t=s.target.dataset.component;this.textInputsFreeze[t]=s.target.value;let o={...this.textInputsFreeze};if(o.hasOwnProperty("hex")){const n=o.a;o=this.tinycolor(o.hex),o.getFormat()!=="hex8"&&o.setAlpha(n)}else o=this.tinycolor(o);const r=o.toHsv();if(this.textInputsFormat==="hsl"&&(r.h===0&&(r.h=parseInt(this.textInputsFreeze.h)),r.v===0)){let n=this.textInputsFreeze.s;const m=n.indexOf("%")!==-1;n=parseFloat(n),!n||n<0?n=0:(m||n>1)&&(n=Math.min(n*.01,1));const u=.001,_=n*u+u;n=2-2*u/_,r.s=n}const i={h:.5,s:.001,v:.001};t!=="a"?(Object.keys(r).filter(n=>n!=="a").forEach(n=>{const m=this[n],u=r[n];Math.abs(m-u)>i[n]&&(this[n]=u)}),o.getFormat()==="hex8"&&o.getOriginalInput().length>7&&(this.disableAlpha?Object.assign(this.$data,{h:0,s:0,v:0}):(this.a=r.a,this.textInputsFreeze.a=Number(this.a.toFixed(2))))):this.a=r.a},textInputFocusHandler(s){this.textInputActive||(this.textInputsFreeze={...this.textInputs},this.colorSnapshot=this.color.toRgbString()),this.textInputActive=s.target.dataset.component},textInputBlurHandler(s){setTimeout(()=>{this.textInputActive===s.target.dataset.component&&(this.colorSnapshot!==this.color.toRgbString()&&this.emitHook("change",{h:this.h,s:this.s,v:this.v,a:this.a}),this.textInputsFreeze={},this.textInputActive=null)},0)},textInputFormatChange(s){const t=["rgb","name","hsl"];this.textInputsFormat;let o=t.indexOf(this.textInputsFormat)+s;o<0?o=t.length-1:o===t.length&&(o=0),this.textInputsFormat=t[o]},getCanvasRects(){this.saturationCanvasRect=this.$refs.saturationCanvas.getBoundingClientRect(),this.hueCanvasRect=this.$refs.hueCanvas.getBoundingClientRect(),this.alphaCanvasRect=this.disableAlpha?{}:this.$refs.alphaCanvas.getBoundingClientRect()},init(){const s=this.$refs.pickerRoot,t=window.getComputedStyle(s);Object.assign(this.$data,this.color.toHsv()),window.requestAnimationFrame(()=>{const{width:r,height:i}=s.getBoundingClientRect();this.pickerHeight=i,this.pickerWidth=r,this.getCanvasRects(),this.hueTranslateX=this.h*this.hueCanvasRect.width/360,this.alphaTranslateX=this.a*this.alphaCanvasRect.width,this.saturationTranslateX=this.s*this.saturationCanvasRect.width,this.saturationTranslateY=-this.v*this.saturationCanvasRect.height,this.sliderPointerWidth=this.$refs.huePointer.offsetWidth,this.saturationPointerWidth=this.$refs.saturationPointer.offsetWidth,this.saturationPointerHeight=this.$refs.saturationPointer.offsetHeight,window.requestAnimationFrame(()=>{this.$emit("ready")})});const o=t.getPropertyValue("background-color");this.tinycolor(o).isDark()&&(this.arrowColor="#fbfbfb")},fillCanvas(){let s=this.$refs.hueCanvas,t=s.getContext("2d"),o=t.createLinearGradient(s.width,0,0,0);o.addColorStop(0,"hsl(0,100%,50%)"),o.addColorStop(.17,"hsl(298.8, 100%, 50%)"),o.addColorStop(.33,"hsl(241.2, 100%, 50%)"),o.addColorStop(.5,"hsl(180, 100%, 50%)"),o.addColorStop(.67,"hsl(118.8, 100%, 50%)"),o.addColorStop(.83,"hsl(61.2,100%,50%)"),o.addColorStop(1,"hsl(360,100%,50%)"),t.fillStyle=o,t.fillRect(0,0,s.width,s.height),s=this.$refs.saturationCanvas,t=s.getContext("2d"),o=t.createLinearGradient(0,0,s.width,0),o.addColorStop(0,"rgba(250,250,250,1)"),o.addColorStop(1,"rgba(250,250,250,0)"),t.fillStyle=o,t.fillRect(0,0,s.width,s.height),o=t.createLinearGradient(0,s.height,0,0),o.addColorStop(0,"rgba(0,0,0,1)"),o.addColorStop(1,"rgba(0,0,0,0)"),t.fillStyle=o,t.fillRect(0,0,s.width,s.height)}},watch:{h(s,t){this.hueTranslateX=this.h*this.hueCanvasRect.width/360,t!==void 0&&(this.emitUpdate(),this.emitHook("hueInput",{h:this.h}))},s(s,t){this.saturationTranslateX=this.s*this.saturationCanvasRect.width,t!==void 0&&(this.emitUpdate(),this.emitHook("saturationInput",{s:this.s,v:this.v}))},v(s,t){this.saturationTranslateY=-this.v*this.saturationCanvasRect.height,t!==void 0&&(this.emitUpdate(),this.emitHook("saturationInput",{s:this.s,v:this.v}))},a(s,t){this.alphaTranslateX=this.a*this.alphaCanvasRect.width,t!==void 0&&(this.emitUpdate(),this.emitHook("alphaInput",{a:this.a}))}},mounted(){this.getCanvasRects(),this.fillCanvas()},beforeUnmount(){}};const $r={class:"slider-canvas",ref:"saturationCanvas"},tc={class:"slider-container"},ec={class:"slider-canvas",ref:"hueCanvas"},sc={class:"slider-active-area"},nc={class:"slider-container transparency-pattern"},ic={class:"slider-active-area"},oc={class:"text-inputs-wrapper"},ac=["for"],lc=["value","id","data-component"];function rc(s,t,o,r,i,n){return c(),d("div",{ref:"pickerRoot",style:C([n.pickerPosition])},[e("div",{class:"saturation-area",style:C(n.pureHueBackground),onPointerdown:t[0]||(t[0]=(...m)=>n.saturationPickStart&&n.saturationPickStart(...m))},[e("canvas",$r,null,512),e("div",{class:"saturation-pointer",ref:"saturationPointer",style:C([n.saturationPointerStyles,{background:n.hexString}])},null,4)],36),e("div",{class:"slider",onPointerdown:t[1]||(t[1]=(...m)=>n.huePickStart&&n.huePickStart(...m))},[e("div",tc,[e("canvas",ec,null,512)]),e("div",sc,[e("div",{class:"slider-pointer",ref:"huePointer",style:C([n.huePointerStyles,n.pureHueBackground])},null,4)])],32),o.disableAlpha?b("",!0):(c(),d("div",{key:0,class:"slider",onPointerdown:t[2]||(t[2]=(...m)=>n.alphaPickStart&&n.alphaPickStart(...m))},[e("div",nc,[e("div",{class:"slider-canvas",ref:"alphaCanvas",style:C(n.alphaCanvasStyles)},null,4)]),e("div",ic,[e("div",{class:"slider-pointer",ref:"alphaPointer",style:C(n.alphaPointerStyles)},[e("div",{class:"pointer-transparent",style:C(n.alphaPointerTransparentStyles)},[e("div",{class:"pointer-color",style:C([n.alphaPointerColorStyles,{background:n.hexString}])},null,4)],4)],4)])],32)),o.disableTextInputs?b("",!0):(c(),d("div",{key:1,class:"text-inputs-area",style:C({"--outline-color":n.hexString})},[e("div",oc,[(c(!0),d(T,null,S(i.textInputActive?i.textInputsFreeze:n.textInputs,(m,u)=>(c(),d("div",{key:"text-input-"+u,class:"text-input-container"},[e("label",{for:"text-input-"+u},l(u),9,ac),e("input",{value:m,class:"text-input",autocomplete:"off",spellcheck:"false",id:"text-input-"+u,"data-component":u,onInput:t[3]||(t[3]=k((..._)=>n.textInputInputHandler&&n.textInputInputHandler(..._),["prevent"])),onFocus:t[4]||(t[4]=(..._)=>n.textInputFocusHandler&&n.textInputFocusHandler(..._)),onBlur:t[5]||(t[5]=(..._)=>n.textInputBlurHandler&&n.textInputBlurHandler(..._)),onKeypress:t[6]||(t[6]=it(_=>_.target.blur(),["enter"]))},null,40,lc)]))),128))]),e("div",{class:"text-format-arrows",style:C(n.arrowsStyles)},[e("div",{class:"arrow up",onClick:t[7]||(t[7]=m=>n.textInputFormatChange(-1))}),e("div",{class:"arrow down",onClick:t[8]||(t[8]=m=>n.textInputFormatChange(1))})],4)],4))],4)}function Q(s,t){t===void 0&&(t={});var o=t.insertAt;if(!(!s||typeof document=="undefined")){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",o==="top"&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=s:i.appendChild(document.createTextNode(s))}}var cc=`.color-input .pointer-transparent, .color-input .pointer-color, .color-input .slider-canvas, .color-input .slider-container {
     1import{_ as tt,d as I,o as c,c as d,n as y,a as e,t as l,g as b,e as x,m as G,l as g,w as k,i as p,k as f,G as C,F as T,r as S,j as V,y as et,T as st,Z as nt,J as it,f as ot,h as at}from"./plugin-vue_export-helper.min.js";import{C as lt,R as rt}from"./RemoveAlert.min.js";import{v as ct}from"./vue3-editor.common.min.js";const dt={name:"Settings",components:{Card:lt,VueEditor:ct.exports.VueEditor,RemoveModal:rt},data(){return{loading:!1,selectedTab:1,form:{company_name:"",company_address:"",postal_code:"",city:"",country:"",company_email:"",company_phone:"",mobile_phone:"",fax:"",logo_mentions_active:"",logo_url:"",logo_path:"",default_currency:"",currency_position:"",vat_active:"",default_vat:"",date_format:"",logo_width:"",logo_mentions:"",invoice_color:"",invoice_prefix:"",active_disbursements:"",show_phone:"",show_email:"",show_siren:"",show_tax_number:"",show_watermark:"",show_watermark_only_paid:"",invoice_footer:"",invoice_terms:"",credit_color:"",credit_prefix:"",credit_footer:"",credit_terms:"",quote_color:"",quote_prefix:"",quote_footer:"",quote_terms:"",easy_compta_planning_addon_active:"",easy_compta_email_addon_active:"",easy_compta_payment_addon_active:"",easy_compta_signature_addon_active:"",easy_compta_stats_addon_active:"",easy_compta_qrcode_addon_active:"",easy_compta_stripe_secret_api:"",email_quote_subject:"",email_invoice_subject:"",remind_invoice_subject:"",remind_invoice_content:"",email_quote_content:"",email_invoice_content:"",email_create_account_subject:"",email_create_account_content:"",easycompta_siret_token_api:""},articles:[],categories:[],currencies:[],vats:[],expenses:[],planning:[],payments:[],logoPreviewUrl:"",previewWidth:"",showArticleModal:!1,showCurrencyModal:!1,showVATModal:!1,showPaymentModal:!1,showExpenseModal:!1,showPlanningModal:!1,currencyForm:{id:null,name:"",symbol:""},articleForm:{id:null,ref:"",name:"",description:"",unit_price:""},vatForm:{id:null,description:"",rate:""},paymentForm:{id:null,method_name:""},expenseForm:{id:null,name:""},planningForm:{id:null,name:"",background:"",color:""},showRemoveModal:!1,deleteType:null,selectedId:null,editingArticle:!1,editingCurrency:!1,editingVAT:!1,editingExpense:!1,editingPayment:!1,editingPlanning:!1,activeTabEmail:"tab1",activeTabUsers:"user1",license_key:"",loadingLicense:!1,licenseData:null,installed_versions:{},updatesAvailable:{},errorMessage:"",toast:{visible:!1,message:"",type:"alert-success",position:"toast-bottom toast-end"},toolbarOptions:[["bold","italic","underline","strike"],["link"],[{list:"ordered"},{list:"bullet"}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{align:[]}],[{align:"right"},{align:"center"},{align:"justify"}],["clean"],["html"]]}},methods:{setActiveTab(s){this.activeTabEmail=s},setActiveTabUsers(s){this.activeTabUsers=s},selectTab(s){this.selectedTab=s,window.location.hash=`tab${s}`},checkHash(){const s=window.location.hash;if(s){const t=parseInt(s.replace("#tab",""));isNaN(t)||(this.selectedTab=t)}},tabClass(s){return this.selectedTab===s?"tab tab-active":"tab"},async fetchSettings(){try{this.loading=!0;const s=await fetch("/wp-json/my-easy-compta/v1/settings/get",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(this.loading=!1,s.ok){const t=await s.json();this.form={...this.form,...t},this.logoPreviewUrl=t.logo_url||"",this.form.easy_compta_planning_addon_active==1&&this.fetchPlanningCat()}else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.loading=!1,this.showToast(s.message,"alert-error")}},async handleSubmit(){try{this.loading=!0;const s=await fetch("/wp-json/my-easy-compta/v1/settings/save",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.form)});if(this.loading=!1,s.ok){const t=await s.json();this.showToast(t,"alert-success")}else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.loading=!1,this.showToast(s.message,"alert-error")}},async fetchArticles(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/articles",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok){const t=await s.json();this.articles=t.articles,this.categories=t.categories}else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async fetchCurrencies(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/currencies",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok)this.currencies=await s.json();else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async fetchVATs(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/vats",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok)this.vats=await s.json();else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async fetchPaymentsMethods(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/payments-methods",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok)this.payments=await s.json();else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async fetchExpensesCat(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/expenses-cat",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok)this.expenses=await s.json();else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async fetchPlanningCat(){try{const s=await fetch("/wp-json/my-easy-compta/v1/settings/planning-cat",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok)this.planning=await s.json();else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async handleLogoUpload(s){const t=s.target.files[0];if(t){const o=new FormData;o.append("logo",t);try{const r=await fetch("/wp-json/my-easy-compta/v1/settings/upload-logo",{method:"POST",headers:{"X-WP-Nonce":myEasyComptaAdmin.nonce},body:o});if(r.ok){const i=await r.json();this.form.logo_url=i.url,this.form.logo_path=i.path,this.logoPreviewUrl=i.url,this.showToast("Logo uploaded successfully","alert-success")}else{const i=await r.json();this.showToast(i.message,"alert-error")}}catch(r){this.showToast(r.message,"alert-error")}}},async addArticle(){this.articleForm={id:null,ref:"",name:"",description:"",price:""},this.editingArticle=!1,this.showArticleModal=!0,this.$nextTick(()=>{document.getElementById("modal_article").showModal()})},async addCurrency(){this.currencyForm={id:null,name:"",symbol:""},this.editingCurrency=!1,this.showCurrencyModal=!0,this.$nextTick(()=>{document.getElementById("modal_currency").showModal()})},async deleteArticle(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/articles/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.articles=this.articles.filter(o=>o.id!==s),this.showToast(this.translations.deleted_successfully,"alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async deleteCategory(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/category/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.categories=this.categories.filter(o=>o.id!==s),this.showToast(this.translations.deleted_successfully,"alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async editArticle(s){const t=this.articles.find(o=>o.id===s);this.articleForm={...t},this.editingArticle=!0,this.showArticleModal=!0,this.$nextTick(()=>{document.getElementById("modal_article").showModal()})},async editCurrency(s){const t=this.currencies.find(o=>o.id===s);this.currencyForm={...t},this.editingCurrency=!0,this.showCurrencyModal=!0,this.$nextTick(()=>{document.getElementById("modal_currency").showModal()})},async deleteCurrency(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/currencies/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.currencies=this.currencies.filter(o=>o.id!==s),this.showToast("Currency deleted successfully","alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async saveArticle(){const s=this.editingArticle?"PUT":"POST",t=this.editingArticle?`/wp-json/my-easy-compta/v1/settings/articles/${this.articleForm.id}`:"/wp-json/my-easy-compta/v1/settings/articles";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.articleForm)});if(o.ok){const r=await o.json();if(this.editingArticle){const i=this.articles.findIndex(n=>n.id===r.id);this.articles[i]=r}else this.articles.push(r);this.showToast(`Article ${this.editingArticle?"updated":"added"} successfully`,"alert-success"),this.closeArticleModal(),this.fetchArticles()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},async saveCurrency(){const s=this.editingCurrency?"PUT":"POST",t=this.editingCurrency?`/wp-json/my-easy-compta/v1/settings/currencies/${this.currencyForm.id}`:"/wp-json/my-easy-compta/v1/settings/currencies";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.currencyForm)});if(o.ok){const r=await o.json();if(this.editingCurrency){const i=this.currencies.findIndex(n=>n.id===r.id);this.currencies[i]=r}else this.currencies.push(r);this.showToast(`Currency ${this.editingCurrency?"updated":"added"} successfully`,"alert-success"),this.closeCurrencyModal(),this.fetchCurrencies()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},async addVAT(){this.vatForm={id:null,description:"",rate:""},this.editingVAT=!1,this.showVATModal=!0,this.$nextTick(()=>{document.getElementById("modal_vat").showModal()})},async editVAT(s){const t=this.vats.find(o=>o.id===s);this.vatForm={...t},this.editingVAT=!0,this.showVATModal=!0,this.$nextTick(()=>{document.getElementById("modal_vat").showModal()})},async deleteVAT(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/vats/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.vats=this.vats.filter(o=>o.id!==s),this.showToast("VAT deleted successfully","alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async saveVAT(){const s=this.editingVAT?"PUT":"POST",t=this.editingVAT?`/wp-json/my-easy-compta/v1/settings/vats/${this.vatForm.id}`:"/wp-json/my-easy-compta/v1/settings/vats";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.vatForm)});if(o.ok){const r=await o.json();if(this.editingVAT){const i=this.vats.findIndex(n=>n.id===r.id);this.vats[i]=r}else this.vats.push(r);this.showToast(`VAT ${this.editingVAT?"updated":"added"} successfully`,"alert-success"),this.closeVATModal(),this.fetchVATs()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},async addPayment(){this.paymentForm={id:null,method_name:""},this.editingPayment=!1,this.showPaymentModal=!0,this.$nextTick(()=>{document.getElementById("modal_payments").showModal()})},async editPayment(s){const t=this.payments.find(o=>o.id===s);this.paymentForm={...t},this.editingPayment=!0,this.showPaymentModal=!0,this.$nextTick(()=>{document.getElementById("modal_payments").showModal()})},async deletePayment(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/payments-methods/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.payments=this.payments.filter(o=>o.id!==s),this.showToast("Payment method deleted successfully","alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async savePayment(){const s=this.editingPayment?"PUT":"POST",t=this.editingPayment?`/wp-json/my-easy-compta/v1/settings/payments-methods/${this.paymentForm.id}`:"/wp-json/my-easy-compta/v1/settings/payments-methods";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.paymentForm)});if(o.ok){const r=await o.json();if(this.editingPayment){const i=this.payments.findIndex(n=>n.id===r.id);this.payments[i]=r}else this.payments.push(r);this.showToast(`Payment method ${this.editingPayment?"updated":"added"} successfully`,"alert-success"),this.closePaymentModal(),this.fetchPaymentsMethods()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},async addExpCat(){this.expenseForm={id:null,name:""},this.editingExpense=!1,this.showExpenseModal=!0,this.$nextTick(()=>{document.getElementById("modal_expenses").showModal()})},async editExpCat(s){const t=this.expenses.find(o=>o.id===s);this.expenseForm={...t},this.editingExpense=!0,this.showExpenseModal=!0,this.$nextTick(()=>{document.getElementById("modal_expenses").showModal()})},async deleteExpCat(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/expenses-categories/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.expenses=this.expenses.filter(o=>o.id!==s),this.showToast("Expense category deleted successfully","alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async saveExpCat(){const s=this.editingExpense?"PUT":"POST",t=this.editingExpense?`/wp-json/my-easy-compta/v1/settings/expenses-categories/${this.expenseForm.id}`:"/wp-json/my-easy-compta/v1/settings/expenses-categories";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.expenseForm)});if(o.ok){const r=await o.json();if(this.editingExpense){const i=this.expenses.findIndex(n=>n.id===r.id);this.expenses[i]=r}else this.expenses.push(r);this.showToast(`Expense category ${this.editingExpense?"updated":"added"} successfully`,"alert-success"),this.closeExpenseModal(),this.fetchExpensesCat()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},async addPlanningCat(){this.planningForm={id:null,name:""},this.editingPlanning=!1,this.showPlanningModal=!0,this.$nextTick(()=>{document.getElementById("modal_planning").showModal()})},async editPlanningCat(s){const t=this.planning.find(o=>o.id===s);this.planningForm={...t},this.editingPlanning=!0,this.showPlanningModal=!0,this.$nextTick(()=>{document.getElementById("modal_planning").showModal()})},async deletePlanningCat(s){try{const t=await fetch(`/wp-json/my-easy-compta/v1/settings/planning-categories/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(t.ok)this.planning=this.planning.filter(o=>o.id!==s),this.showToast("Planning category deleted successfully","alert-success");else{const o=await t.json();this.showToast(o.message,"alert-error")}}catch(t){this.showToast(t.message,"alert-error")}},async savePlanningCat(){this.loading=!0;const s=this.editingPlanning?"PUT":"POST",t=this.editingPlanning?`/wp-json/my-easy-compta/v1/settings/planning-categories/${this.planningForm.id}`:"/wp-json/my-easy-compta/v1/settings/planning-categories";try{const o=await fetch(t,{method:s,headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify(this.planningForm)});if(o.ok){const r=await o.json();if(this.editingPlanning){const i=this.planning.findIndex(n=>n.id===r.id);this.planning[i]=r,this.loading=!1}else this.planning.push(r),this.loading=!1;this.showToast(`Planning category ${this.editingPlanning?"updated":"added"} successfully`,"alert-success"),this.closePlanningModal(),this.fetchPlanningCat()}else{const r=await o.json();this.showToast(r.message,"alert-error")}}catch(o){this.showToast(o.message,"alert-error")}},closeCurrencyModal(){this.showCurrencyModal=!1},closeArticleModal(){this.showArticleModal=!1},closeVATModal(){this.showVATModal=!1},closePaymentModal(){this.showPaymentModal=!1},closeExpenseModal(){this.showExpenseModal=!1},closePlanningModal(){this.showPlanningModal=!1},updatePreviewWidth(){this.previewWidth=this.form.logo_width+"px"},updateVatActive(s){this.form.vat_active=s.target.checked?1:0},updateLogoMentionsActive(s){this.form.logo_mentions_active=s.target.checked?1:0},updateEmailLogsActive(s){this.form.email_log_active=s.target.checked?1:0},updateFormField(s,t){this.form[t]=s.target.checked?1:0},showToast(s,t){this.toast.message=s,this.toast.type=t,this.toast.visible=!0,setTimeout(()=>{this.toast.visible=!1},3e3)},handleDeletion(s,t){const o=this.getDeletionFunction(s);o?o(t):this.showToast("error","alert-error")},delete_item(s,t){this.deleteType=s,this.selectedId=t,modal_settings_remove.showModal(),this.showRemoveModal=!0},getDeletionFunction(s){switch(s){case"licence":return this.confirmLicense;case"vat":return this.deleteVAT;case"currency":return this.deleteCurrency;case"expense":return this.deleteExpCat;case"payment":return this.deletePayment;case"planning":return this.deletePlanningCat;case"article":return this.deleteArticle;case"category_article":return this.deleteCategory;default:return null}},async checkLicense(){this.loading=!0,this.loadingLicense=!0,this.errorMessage="",this.licenseData=null;try{const t=await(await fetch("/wp-json/my-easy-compta/v1/license/validate-license",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({license_key:this.license_key})})).json();t.valid?(this.licenseData=t,await this.storeLicense(t),location.reload()):this.errorMessage=t.message}catch{this.errorMessage="An error occurred while validating the license."}finally{this.loadingLicense=!1}},async refresh_licence(){this.loading=!0;try{const t=await(await fetch("/wp-json/my-easy-compta/v1/license/refresh-license",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}})).json();t.valid?location.reload():this.errorMessage=t.message}catch{this.errorMessage="An error occurred while refreshing the license."}},async storeLicense(s){try{await fetch("/wp-json/my-easy-compta/v1/license/store-license",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({license_key:this.license_key,license_data:s})})}catch{this.errorMessage="An error occurred while storing the license.",this.loading=!1}},async loadLicenseDetails(){this.loading=!0;try{const s=await fetch("/wp-json/my-easy-compta/v1/license/check-license",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok){const t=await s.json();t.valid&&(this.licenseData=t.license_data,this.installed_versions=t.installed_versions,this.license_key="****-****-****-****-****"+this.license_key.substr(this.license_key.length-4),this.loading=!1)}else console.error("Failed to load license details"),this.loading=!1}catch(s){console.error("Error loading license details",s),this.loading=!1}},async confirmLicense(){this.loading=!0;try{const s=await fetch("/wp-json/my-easy-compta/v1/license/delete-license",{method:"DELETE",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce}});if(s.ok){const t=await s.json();this.showToast(t.message,"alert-success"),this.licenseData="",this.license_key="",location.reload()}else{const t=await s.json();this.showToast(t.message,"alert-error")}}catch(s){this.showToast(s.message,"alert-error")}},async checkUpdatePlugin(s,t){try{const r=await(await fetch("/wp-json/my-easy-compta/v1/license/check-update",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({plugin_slug:s,current_version:t})})).json();r.success?r.update_available?(this.showToast(this.translations.update_available+" "+r.new_version,"alert-success"),this.updatesAvailable[s]=r.update_available):this.showToast(this.translations.no_update_available,"alert-error"):this.showToast(this.translations.failed_update_available,"alert-error")}catch(o){console.error("Error checking for plugin update:",o),this.showToast(this.translations.failed_update_available,"alert-error")}},async installUpdatePlugin(s){try{const o=await(await fetch("/wp-json/my-easy-compta/v1/license/download-update",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":myEasyComptaAdmin.nonce},body:JSON.stringify({plugin_slug:s})})).json();if(o.success){this.showToast(this.translations.success,"alert-success");const r=document.createElement("a");r.href=o.download_url,r.setAttribute("download",""),document.body.appendChild(r),r.click(),document.body.removeChild(r)}else this.showToast(this.translations.error,"alert-error")}catch(t){console.error("Error checking for plugin update:",t),this.showToast(this.translations.error,"alert-error")}}},computed:{translations(){return window.myEasyComptaAdmin.easyComptaTranslations}},beforeUnmount(){window.removeEventListener("hashchange",this.checkHash)},mounted(){this.checkHash(),window.addEventListener("hashchange",this.checkHash),this.fetchSettings(),this.fetchArticles(),this.fetchCurrencies(),this.fetchVATs(),this.fetchPaymentsMethods(),this.fetchExpensesCat(),this.loadLicenseDetails()}},ut={class:"pt-2 pr-4"},ht={class:"flex justify-between items-center"},pt={class:"card-title"},mt=e("div",{class:"divider mt-2"},null,-1),ft={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4"},bt={class:"tabs tabs-vertical tabs-boxed col-span-1"},_t=e("i",{class:"fas fa-home mr-2"},null,-1),gt=e("i",{class:"fas fa-tools mr-2"},null,-1),vt=e("i",{class:"fas fa-newspaper mr-2"},null,-1),yt=e("i",{class:"fas fa-file-invoice-dollar mr-2"},null,-1),wt=e("i",{class:"fas fa-undo mr-2"},null,-1),xt=e("i",{class:"far fa-question-circle mr-2"},null,-1),kt=e("i",{class:"fas fa-dollar-sign mr-2"},null,-1),Ct=e("i",{class:"fas fa-money-check-alt mr-2"},null,-1),Tt=e("i",{class:"fas fa-shopping-basket mr-2"},null,-1),Mt=e("i",{class:"fas fa-calendar-alt mr-2"},null,-1),At=e("i",{class:"far fa-envelope mr-2"},null,-1),St=e("i",{class:"fas fa-user mr-2"},null,-1),Pt=e("i",{class:"far fa-credit-card mr-2"},null,-1),Et=e("i",{class:"far fa-chart-bar mr-2"},null,-1),jt=e("i",{class:"fas fa-qrcode mr-2"},null,-1),Vt=e("i",{class:"far fa-id-badge mr-2"},null,-1),It={class:"col-span-3 p-4 bg-base-300 rounded-lg shadow-md content-tabs"},Ft={key:0,class:"fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-900 bg-opacity-50 z-50"},Rt=e("span",{class:"loading loading-spinner text-primary loading-lg"},null,-1),Ut=[Rt],Dt={key:1},Ht={class:"text-xl font-semibold mb-4"},Nt={class:"grid grid-cols-1 md:grid-cols-2 gap-4"},Yt={class:"ecwp-group form-control"},qt={class:"ecwp-label label",for:"company-code"},Lt={class:"ecwp-group form-control"},Ot={class:"ecwp-label label",for:"tax-number"},Xt={class:"ecwp-group form-control"},Wt={class:"ecwp-label label",for:"company-name"},Bt={class:"ecwp-group form-control"},zt={class:"ecwp-label label",for:"company-address"},Gt={class:"ecwp-group form-control"},Jt={class:"ecwp-label label",for:"postal-code"},Zt={class:"ecwp-group form-control"},Qt={class:"ecwp-label label",for:"city"},Kt={class:"ecwp-group form-control"},$t={class:"ecwp-label label",for:"country"},te={class:"ecwp-group form-control"},ee={class:"ecwp-label label",for:"company-email"},se={class:"ecwp-group form-control"},ne={class:"ecwp-label label",for:"company-phone"},ie={class:"ecwp-group form-control"},oe={class:"ecwp-label label",for:"mobile-phone"},ae={class:"ecwp-group form-control"},le={class:"ecwp-label label",for:"fax"},re=e("div",{class:"divider my-4"},null,-1),ce={key:0},de={class:"grid grid-cols-2 gap-4"},ue={class:"ecwp-group form-control indicator"},he={class:"ecwp-label label",for:"company-code"},pe=e("span",{class:"indicator-item badge mt-5 border-blue-700"},[e("a",{href:"https://api.gouv.fr/les-api/sirene_v3",target:"_blank"},"?")],-1),me={class:"mt-6 flex justify-end"},fe={type:"submit",class:"btn btn-primary rounded-full"},be=e("i",{class:"far fa-save"},null,-1),_e={key:2},ge={class:"text-xl font-semibold mb-4"},ve={class:"form-control mt-4 mb-1"},ye={class:"cursor-pointer"},we={class:"label-text mr-2 font-bold"},xe=["checked"],ke={key:0,class:"ecwp-group form-control"},Ce={class:"ecwp-label label",for:"logo-mentions"},Te={class:"ecwp-group form-control"},Me={class:"label"},Ae={class:"ecwp-file"},Se={for:"file_logo"},Pe=e("i",{class:"fas fa-cloud-upload-alt mr-2"},null,-1),Ee={key:0,class:"max-w-md"},je={class:"py-2 font-bold"},Ve={key:0},Ie=["src"],Fe={class:"ecwp-group form-control"},Re={class:"ecwp-label label"},Ue=["value"],De={class:"ecwp-group form-control"},He={class:"ecwp-label label"},Ne={value:"before"},Ye={value:"after"},qe={class:"form-control mt-4 mb-1"},Le={class:"cursor-pointer"},Oe={class:"label-text mr-2 font-bold"},Xe=["checked"],We={key:1,class:"ecwp-group form-control"},Be={class:"ecwp-label label"},ze=e("option",{value:"0"},null,-1),Ge=["value"],Je={class:"ecwp-group form-control mt-2"},Ze={class:"ecwp-label label"},Qe=e("option",{value:"DD-MM-YYYY",selected:"selected"}," DD-MM-YYYY ",-1),Ke=e("option",{value:"MM-DD-YYYY"},"MM-DD-YYYY",-1),$e=e("option",{value:"YYYY-MM-DD"},"YYYY-MM-DD",-1),ts=e("option",{value:"YYYY/MM/DD"},"YYYY/MM/DD",-1),es=e("option",{value:"DD/MM/YYYY"},"DD/MM/YYYY",-1),ss=e("option",{value:"MM/DD/YYYY"},"MM/DD/YYYY",-1),ns=e("option",{value:"YYYY.MM.DD"},"YYYY.MM.DD",-1),is=e("option",{value:"DD.MM.YYYY"},"DD.MM.YYYY",-1),os=e("option",{value:"MM.DD.YYYY"},"MM.DD.YYYY",-1),as=[Qe,Ke,$e,ts,es,ss,ns,is,os],ls={class:"mt-6 flex justify-end"},rs={type:"submit",class:"btn btn-primary rounded-full"},cs=e("i",{class:"far fa-save"},null,-1),ds={key:3},us={key:0,id:"modal_article",class:"modal"},hs={class:"modal-box"},ps={class:"ecwp-group form-control"},ms={class:"ecwp-label label",for:"name_ref"},fs={class:"ecwp-group form-control"},bs={class:"ecwp-label label",for:"name_article"},_s={class:"ecwp-group form-control"},gs={class:"ecwp-label label",for:"desc_article"},vs={class:"ecwp-group form-control"},ys={class:"ecwp-label label",for:"price_article"},ws={class:"form-group mt-4 flex justify-end"},xs={type:"submit",class:"btn btn-primary rounded-full mx-2"},ks={class:"flex justify-between items-center mb-4"},Cs={class:"text-lg font-semibold"},Ts=e("i",{class:"fas fa-plus mr-2"},null,-1),Ms={class:"table-container"},As={class:"table w-full"},Ss=["onClick"],Ps=e("i",{class:"fas fa-edit"},null,-1),Es=[Ps],js=["onClick"],Vs=e("i",{class:"fas fa-trash"},null,-1),Is=[Vs],Fs=e("div",{class:"divider mt-2 mb-4"},null,-1),Rs={class:"text-xl font-semibold mb-4"},Us={class:"table-container"},Ds={class:"table w-full"},Hs=["onClick"],Ns=e("i",{class:"fas fa-trash"},null,-1),Ys=[Ns],qs={key:4},Ls={class:"text-xl font-semibold mb-4"},Os={class:"grid grid-cols-2 gap-4"},Xs={class:"ecwp-group form-control"},Ws={class:"ecwp-label label",for:"invoice-color"},Bs={class:"ecwp-group form-control"},zs={class:"ecwp-label label",for:"invoice-prefix"},Gs=e("div",{class:"divider my-4"},null,-1),Js={class:"grid grid-cols-1 gap-4"},Zs={class:"form-control mt-4 mb-1"},Qs={class:"cursor-pointer"},Ks=["checked"],$s={class:"label-text mr-2 font-bold"},tn=e("div",{class:"divider my-4"},null,-1),en={class:"grid grid-cols-2 gap-4"},sn={class:"form-control mt-4 mb-1"},nn={class:"cursor-pointer"},on=["checked"],an={class:"label-text mr-2 font-bold"},ln={class:"form-control mt-4 mb-1"},rn={class:"cursor-pointer"},cn=["checked"],dn={class:"label-text mr-2 font-bold"},un={class:"form-control mt-4 mb-1"},hn={class:"cursor-pointer"},pn=["checked"],mn={class:"label-text mr-2 font-bold"},fn={class:"form-control mt-4 mb-1"},bn={class:"cursor-pointer"},_n=["checked"],gn={class:"label-text mr-2 font-bold"},vn={class:"form-control mt-4 mb-1"},yn={class:"cursor-pointer"},wn=["checked"],xn={class:"label-text mr-2 font-bold"},kn={key:0,class:"form-control mt-4 mb-1"},Cn={class:"cursor-pointer"},Tn=["checked"],Mn={class:"label-text mr-2 font-bold"},An=e("div",{class:"divider my-4"},null,-1),Sn={class:"grid grid-cols-2 gap-4"},Pn={class:"ecwp-group form-control"},En={class:"ecwp-label label",for:"conditions-payment"},jn={class:"ecwp-group form-control"},Vn={class:"ecwp-label label",for:"mode-payment"},In={class:"grid grid-cols-1 gap-4"},Fn={class:"form-control"},Rn={class:"ecwp-label label",for:"invoice-prefix"},Un={class:"grid grid-cols-2 gap-4"},Dn={class:"ecwp-group form-control"},Hn={class:"ecwp-label label",for:"invoice-iban"},Nn={class:"ecwp-group form-control"},Yn={class:"ecwp-label label",for:"invoice-bic"},qn={class:"form-control"},Ln={class:"ecwp-label label",for:"invoice-prefix"},On={class:"mt-6 flex justify-end"},Xn={type:"submit",class:"btn btn-primary rounded-full"},Wn=e("i",{class:"far fa-save"},null,-1),Bn={key:5},zn={class:"text-xl font-semibold mb-4"},Gn={class:"grid grid-cols-2 gap-4"},Jn={class:"ecwp-group form-control"},Zn={class:"ecwp-label label",for:"credit-color"},Qn={class:"ecwp-group form-control"},Kn={class:"ecwp-label label",for:"credit-prefix"},$n={class:"grid grid-cols-1 gap-4"},ti={class:"form-control"},ei={class:"ecwp-label label",for:"credit-prefix"},si={class:"form-control"},ni={class:"ecwp-label label",for:"credit-prefix"},ii={class:"mt-6 flex justify-end"},oi={type:"submit",class:"btn btn-primary rounded-full"},ai=e("i",{class:"far fa-save"},null,-1),li={key:6},ri={class:"text-xl font-semibold mb-4"},ci={class:"grid grid-cols-2 gap-4"},di={class:"ecwp-group form-control"},ui={class:"ecwp-label label",for:"quote-color"},hi={class:"ecwp-group form-control"},pi={class:"ecwp-label label",for:"quote-prefix"},mi={class:"grid grid-cols-1 gap-4"},fi={class:"form-control"},bi={class:"ecwp-label label",for:"quote-prefix"},_i={class:"form-control"},gi={class:"ecwp-label label",for:"quote-prefix"},vi={class:"mt-6 flex justify-end"},yi={type:"submit",class:"btn btn-primary rounded-full"},wi=e("i",{class:"far fa-save"},null,-1),xi={key:7},ki={class:"text-xl font-semibold mb-4"},Ci={key:0,id:"modal_currency",class:"modal"},Ti={class:"modal-box"},Mi={class:"ecwp-group form-control"},Ai={class:"ecwp-label label",for:"name_currency"},Si={class:"ecwp-group form-control"},Pi={class:"ecwp-label label",for:"symbol_currency"},Ei={class:"ecwp-group form-control"},ji={class:"ecwp-label label",for:"code_currency"},Vi={class:"form-group mt-4 flex justify-end"},Ii={type:"submit",class:"btn btn-primary rounded-full mx-2"},Fi={class:"mb-8"},Ri={class:"flex justify-between items-center mb-4"},Ui={class:"text-lg font-semibold"},Di=e("i",{class:"fas fa-plus mr-2"},null,-1),Hi={class:"table-container"},Ni={class:"table w-full"},Yi=["onClick"],qi=e("i",{class:"fas fa-edit"},null,-1),Li=[qi],Oi=["onClick"],Xi=e("i",{class:"fas fa-trash"},null,-1),Wi=[Xi],Bi={key:0,id:"modal_vat",class:"modal"},zi={class:"modal-box"},Gi={class:"ecwp-group form-control"},Ji={class:"ecwp-label label",for:"vat-description"},Zi={class:"ecwp-group form-control"},Qi={class:"ecwp-label label",for:"vat-rate"},Ki={class:"form-group mt-4 flex justify-end"},$i={type:"submit",class:"btn btn-primary rounded-full mx-2"},to={class:"flex justify-between items-center mb-4"},eo={class:"text-lg font-semibold"},so=e("i",{class:"fas fa-plus mr-2"},null,-1),no={class:"table-container"},io={class:"table w-full"},oo=["onClick"],ao=e("i",{class:"fas fa-edit"},null,-1),lo=[ao],ro=["onClick"],co=e("i",{class:"fas fa-trash"},null,-1),uo=[co],ho={key:8},po={class:"text-xl font-semibold mb-4"},mo={key:0,id:"modal_payments",class:"modal"},fo={class:"modal-box"},bo={class:"ecwp-group form-control"},_o={class:"ecwp-label label",for:"name_payment"},go={class:"form-group mt-4 flex justify-end"},vo={type:"submit",class:"btn btn-primary rounded-full mx-2"},yo={class:"mb-8"},wo={class:"flex justify-between items-center mb-4"},xo={class:"text-lg font-semibold"},ko=e("i",{class:"fas fa-plus mr-2"},null,-1),Co={class:"table-container"},To={class:"table w-full"},Mo=["onClick"],Ao=e("i",{class:"fas fa-edit"},null,-1),So=[Ao],Po=["onClick"],Eo=e("i",{class:"fas fa-trash"},null,-1),jo=[Eo],Vo={key:9},Io={class:"text-xl font-semibold mb-4"},Fo={key:0,id:"modal_expenses",class:"modal"},Ro={class:"modal-box"},Uo={class:"ecwp-group form-control"},Do={class:"ecwp-label label",for:"name_expense"},Ho={class:"form-group mt-4 flex justify-end"},No={type:"submit",class:"btn btn-primary rounded-full mx-2"},Yo={class:"mb-8"},qo={class:"flex justify-between items-center mb-4"},Lo={class:"text-lg font-semibold"},Oo=e("i",{class:"fas fa-plus mr-2"},null,-1),Xo={class:"table-container"},Wo={class:"table w-full"},Bo=["onClick"],zo=e("i",{class:"fas fa-edit"},null,-1),Go=[zo],Jo=["onClick"],Zo=e("i",{class:"fas fa-trash"},null,-1),Qo=[Zo],Ko={key:10},$o={class:"text-xl font-semibold mb-4"},ta={key:0,id:"modal_planning",class:"modal"},ea={class:"modal-box"},sa={class:"ecwp-group form-control"},na={class:"ecwp-label label",for:"name_planning"},ia={class:"ecwp-group form-control"},oa={class:"ecwp-label label",for:"background_planning"},aa={class:"ecwp-group form-control"},la={class:"ecwp-label label",for:"color_planning"},ra={class:"form-group mt-4 flex justify-end"},ca=["disabled"],da={key:0,class:"loading loading-spinner loading-sm"},ua={class:"mb-8"},ha={class:"flex justify-between items-center mb-4"},pa={class:"text-lg font-semibold"},ma=e("i",{class:"fas fa-plus mr-2"},null,-1),fa={class:"table-container"},ba={class:"table w-full"},_a=["onClick"],ga=e("i",{class:"fas fa-edit"},null,-1),va=[ga],ya=["onClick"],wa=e("i",{class:"fas fa-trash"},null,-1),xa=[wa],ka={key:11},Ca={class:"text-xl font-semibold mb-4"},Ta={class:"form-control mt-4 mb-4"},Ma={class:"cursor-pointer"},Aa={class:"label-text mr-2 font-bold"},Sa=["checked"],Pa=e("div",{class:"divider mt-2 mb-4"},null,-1),Ea={role:"tablist",class:"tabs tabs-boxed"},ja={key:0,class:"p-4"},Va={class:"grid grid-cols-1 gap-4"},Ia={class:"ecwp-group form-control"},Fa={class:"ecwp-label label",for:"email_invoice_subject"},Ra={class:"form-control"},Ua={class:"ecwp-label label"},Da=e("div",{class:"mockup-code bg-base-900 mt-4"},[e("pre",null,[e("b",null,"{REF}")]),e("pre",null,[e("b",null,"{CLIENT}")]),e("pre",null,[e("b",null,"{DUE_DATE}")]),e("pre",null,[e("b",null,"{AMOUNT}")]),e("pre",null,[e("b",null,"{CURRENCY}")])],-1),Ha={key:1,class:"p-4"},Na={class:"grid grid-cols-1 gap-4"},Ya={class:"ecwp-group form-control"},qa={class:"ecwp-label label",for:"email_quote_subject"},La={class:"form-control"},Oa={class:"ecwp-label label"},Xa=e("div",{class:"mockup-code bg-base-900 mt-4"},[e("pre",null,[e("b",null,"{REF}")]),e("pre",null,[e("b",null,"{CLIENT}")]),e("pre",null,[e("b",null,"{AMOUNT}")]),e("pre",null,[e("b",null,"{CURRENCY}")]),e("pre",null,[e("b",null,"{CREATED_DATE}")]),e("pre",null,[e("b",null,"{DUE_DATE}")])],-1),Wa={key:2,class:"p-4"},Ba={class:"grid grid-cols-1 gap-4"},za={class:"ecwp-group form-control"},Ga={class:"ecwp-label label",for:"remind_invoice_subject"},Ja={class:"form-control"},Za={class:"ecwp-label label"},Qa=e("div",{class:"mockup-code bg-base-900 mt-4"},[e("pre",null,[e("b",null,"{REF}")]),e("pre",null,[e("b",null,"{CLIENT}")]),e("pre",null,[e("b",null,"{DUE_DATE}")]),e("pre",null,[e("b",null,"{AMOUNT}")]),e("pre",null,[e("b",null,"{CURRENCY}")])],-1),Ka={key:3,class:"p-4"},$a={role:"alert",class:"alert shadow"},tl=e("i",{class:"fas fa-exclamation-circle"},null,-1),el={class:"text-xl text-center my-4"},sl={class:"mt-6 flex justify-end"},nl={type:"submit",class:"btn btn-primary rounded-full"},il=e("i",{class:"far fa-save"},null,-1),ol={key:12},al={class:"text-xl font-semibold mb-4"},ll={role:"tablist",class:"tabs tabs-boxed"},rl={key:0,class:"p-4"},cl={class:"grid grid-cols-1 gap-4"},dl={class:"ecwp-group form-control"},ul={class:"ecwp-label label",for:"email_create_account_subject"},hl={class:"form-control"},pl={class:"ecwp-label label"},ml=e("div",{class:"mockup-code bg-base-900 mt-4"},[e("pre",null,[e("b",null,"{CLIENT}")]),e("pre",null,[e("b",null,"{USERNAME}")]),e("pre",null,[e("b",null,"{PASSWORD}")])],-1),fl={class:"mt-6 flex justify-end"},bl={type:"submit",class:"btn btn-primary rounded-full"},_l=e("i",{class:"far fa-save"},null,-1),gl={key:1,class:"p-4"},vl={role:"alert",class:"alert shadow"},yl=e("i",{class:"fas fa-exclamation-circle"},null,-1),wl={class:"text-xl text-center my-4"},xl={key:13},kl={class:"text-xl font-semibold mb-4"},Cl={class:"grid grid-cols-1 gap-4"},Tl={class:"ecwp-group form-control"},Ml={class:"ecwp-label label",for:"stripe-mode"},Al={value:"test"},Sl={value:"live"},Pl={key:0},El={class:"ecwp-group form-control"},jl={class:"ecwp-label label",for:"stripe-public-key-test"},Vl={class:"ecwp-group form-control"},Il={class:"ecwp-label label",for:"stripe-secret-key-test"},Fl={key:1},Rl={class:"ecwp-group form-control"},Ul={class:"ecwp-label label",for:"stripe-public-key-live"},Dl={class:"ecwp-group form-control"},Hl={class:"ecwp-label label",for:"stripe-secret-key-live"},Nl={class:"mt-6 flex justify-end"},Yl={type:"submit",class:"btn btn-primary rounded-full"},ql=e("i",{class:"far fa-save"},null,-1),Ll={key:14},Ol={class:"text-xl font-semibold mb-4"},Xl={class:"grid grid-cols-1 gap-4"},Wl={class:"ecwp-group form-control mt-2"},Bl={class:"ecwp-label label",for:"limit-declaration"},zl={class:"ecwp-group form-control mt-2"},Gl={class:"ecwp-label label",for:"limit-tva"},Jl={class:"mt-6 flex justify-end"},Zl={type:"submit",class:"btn btn-primary rounded-full"},Ql=e("i",{class:"far fa-save"},null,-1),Kl={key:15},$l={class:"text-xl font-semibold mb-4"},tr={class:"grid grid-cols-1 gap-4"},er={class:"ecwp-group form-control mt-2"},sr={class:"ecwp-label label",for:"stripe-api"},nr={class:"mt-6 flex justify-end"},ir={type:"submit",class:"btn btn-primary rounded-full"},or=e("i",{class:"far fa-save"},null,-1),ar={key:16},lr={class:"text-xl font-semibold mb-4"},rr={class:"grid grid-cols-2 gap-4"},cr={class:"ecwp-group form-group relative join"},dr={class:"ecwp-label label",for:"license-code"},ur=["disabled"],hr=["disabled"],pr={key:0,class:"loading loading-spinner loading-sm"},mr={key:1},fr={class:"grid grid-cols-1 gap-4"},br={key:0,class:"error-message"},_r={key:1,class:"overflow-x-auto my-4"},gr={class:"table table-xs table-pin-rows table-pin-cols"},vr=e("i",{class:"fas fa-sync"},null,-1),yr=[vr],wr=e("i",{class:"far fa-trash-alt"},null,-1),xr=[wr],kr={class:"table table-xs table-pin-rows table-pin-cols mt-6"},Cr=["onClick"],Tr=["onClick"],Mr=["onClick"];function Ar(s,t,o,r,i,n){const m=I("remove-modal"),u=I("color-input"),_=I("vue-editor"),M=I("Card");return c(),d("div",ut,[i.toast.visible?(c(),d("div",{key:0,class:y(["toast",i.toast.position]),style:{zIndex:9999}},[e("div",{class:y(["alert",i.toast.type,"text-white"])},[e("span",null,l(i.toast.message),1)],2)],2)):b("",!0),x(m,{"modal-id":"modal_settings_remove","show-modal":i.showRemoveModal,title:n.translations.are_you_sure,message:n.translations.no_turning_back,confirmText:n.translations.yes_delete_it,cancelText:n.translations.cancel,onConfirm:t[0]||(t[0]=a=>n.handleDeletion(i.deleteType,i.selectedId)),onCancel:t[1]||(t[1]=a=>i.showRemoveModal=!1)},null,8,["show-modal","title","message","confirmText","cancelText"]),x(M,{topMargin:"mt-8"},{default:G(()=>[e("div",ht,[e("h2",pt,l(n.translations.settings),1)]),mt,e("div",ft,[e("div",bt,[e("a",{class:y([n.tabClass(1),"justify-start w-full"]),onClick:t[2]||(t[2]=a=>n.selectTab(1))},[_t,g(" "+l(n.translations.general_settings),1)],2),e("a",{class:y([n.tabClass(2),"justify-start w-full"]),onClick:t[3]||(t[3]=a=>n.selectTab(2))},[gt,g(" "+l(n.translations.system_settings),1)],2),e("a",{class:y([n.tabClass(3),"justify-start w-full"]),onClick:t[4]||(t[4]=a=>n.selectTab(3))},[vt,g(" "+l(n.translations.articles_settings),1)],2),e("a",{class:y([n.tabClass(4),"justify-start w-full"]),onClick:t[5]||(t[5]=a=>n.selectTab(4))},[yt,g(" "+l(n.translations.invoices_settings),1)],2),e("a",{class:y([n.tabClass(5),"justify-start w-full"]),onClick:t[6]||(t[6]=a=>n.selectTab(5))},[wt,g(" "+l(n.translations.credits_settings),1)],2),e("a",{class:y([n.tabClass(6),"justify-start w-full"]),onClick:t[7]||(t[7]=a=>n.selectTab(6))},[xt,g(" "+l(n.translations.quotes_settings),1)],2),e("a",{class:y([n.tabClass(7),"justify-start w-full"]),onClick:t[8]||(t[8]=a=>n.selectTab(7))},[kt,g(" "+l(n.translations.currency_vat_settings),1)],2),e("a",{class:y([n.tabClass(8),"justify-start w-full"]),onClick:t[9]||(t[9]=a=>n.selectTab(8))},[Ct,g(" "+l(n.translations.payments_settings),1)],2),e("a",{class:y([n.tabClass(9),"justify-start w-full"]),onClick:t[10]||(t[10]=a=>n.selectTab(9))},[Tt,g(" "+l(n.translations.expenses_settings),1)],2),i.form.easy_compta_planning_addon_active==1?(c(),d("a",{key:0,class:y([n.tabClass(10),"justify-start w-full"]),onClick:t[11]||(t[11]=a=>n.selectTab(10))},[Mt,g(" "+l(n.translations.planning_settings),1)],2)):b("",!0),i.form.easy_compta_email_addon_active==1?(c(),d("a",{key:1,class:y([n.tabClass(11),"justify-start w-full"]),onClick:t[12]||(t[12]=a=>n.selectTab(11))},[At,g(" "+l(n.translations.email_settings),1)],2)):b("",!0),i.form.easy_compta_user_addon_active==1?(c(),d("a",{key:2,class:y([n.tabClass(12),"justify-start w-full"]),onClick:t[13]||(t[13]=a=>n.selectTab(12))},[St,g(" "+l(n.translations.users_settings),1)],2)):b("",!0),i.form.easy_compta_payment_addon_active==1?(c(),d("a",{key:3,class:y([n.tabClass(13),"justify-start w-full"]),onClick:t[14]||(t[14]=a=>n.selectTab(13))},[Pt,g(" "+l(n.translations.stripe_settings),1)],2)):b("",!0),i.form.easy_compta_stats_addon_active==1?(c(),d("a",{key:4,class:y([n.tabClass(14),"justify-start w-full"]),onClick:t[15]||(t[15]=a=>n.selectTab(14))},[Et,g(" "+l(n.translations.stats_settings),1)],2)):b("",!0),i.form.easy_compta_qrcode_addon_active==1?(c(),d("a",{key:5,class:y([n.tabClass(15),"justify-start w-full"]),onClick:t[16]||(t[16]=a=>n.selectTab(15))},[jt,g(" "+l(n.translations.qrcode_settings),1)],2)):b("",!0),e("a",{class:y([n.tabClass(16),"justify-start w-full"]),onClick:t[17]||(t[17]=a=>n.selectTab(16))},[Vt,g(" "+l(n.translations.validation_license),1)],2)]),e("div",It,[i.loading?(c(),d("div",Ft,Ut)):b("",!0),i.selectedTab===1?(c(),d("div",Dt,[e("h2",Ht,l(n.translations.general_settings),1),e("form",{onSubmit:t[30]||(t[30]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",Nt,[e("div",Yt,[e("label",qt,l(n.translations.company_code),1),p(e("input",{type:"text",id:"company-code","onUpdate:modelValue":t[18]||(t[18]=a=>i.form.company_code=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.company_code]])]),e("div",Lt,[e("label",Ot,l(n.translations.tax_number),1),p(e("input",{type:"text",id:"tax-number","onUpdate:modelValue":t[19]||(t[19]=a=>i.form.tax_number=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.tax_number]])]),e("div",Xt,[e("label",Wt,l(n.translations.company_name),1),p(e("input",{type:"text",id:"company-name","onUpdate:modelValue":t[20]||(t[20]=a=>i.form.company_name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.company_name]])]),e("div",Bt,[e("label",zt,l(n.translations.address),1),p(e("input",{type:"text",id:"company-address","onUpdate:modelValue":t[21]||(t[21]=a=>i.form.company_address=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.company_address]])]),e("div",Gt,[e("label",Jt,l(n.translations.postal_code),1),p(e("input",{type:"text",id:"postal-code","onUpdate:modelValue":t[22]||(t[22]=a=>i.form.postal_code=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.postal_code]])]),e("div",Zt,[e("label",Qt,l(n.translations.city),1),p(e("input",{type:"text",id:"city","onUpdate:modelValue":t[23]||(t[23]=a=>i.form.city=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.city]])]),e("div",Kt,[e("label",$t,l(n.translations.country),1),p(e("input",{type:"text",id:"country","onUpdate:modelValue":t[24]||(t[24]=a=>i.form.country=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.country]])]),e("div",te,[e("label",ee,l(n.translations.email),1),p(e("input",{type:"email",id:"company-email","onUpdate:modelValue":t[25]||(t[25]=a=>i.form.company_email=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.company_email]])]),e("div",se,[e("label",ne,l(n.translations.phone),1),p(e("input",{type:"tel",id:"company-phone","onUpdate:modelValue":t[26]||(t[26]=a=>i.form.company_phone=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.company_phone]])]),e("div",ie,[e("label",oe,l(n.translations.mobile),1),p(e("input",{type:"tel",id:"mobile-phone","onUpdate:modelValue":t[27]||(t[27]=a=>i.form.mobile_phone=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.mobile_phone]])]),e("div",ae,[e("label",le,l(n.translations.fax),1),p(e("input",{type:"tel",id:"fax","onUpdate:modelValue":t[28]||(t[28]=a=>i.form.fax=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.fax]])])]),re,i.form.easy_compta_siret_addon_active==1?(c(),d("div",ce,[e("div",de,[e("div",ue,[e("label",he,l(n.translations.siret_api_token),1),pe,p(e("input",{type:"text",id:"company-code","onUpdate:modelValue":t[29]||(t[29]=a=>i.form.easycompta_siret_token_api=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.easycompta_siret_token_api]])])])])):b("",!0),e("div",me,[e("button",fe,[be,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===2?(c(),d("div",_e,[e("h2",ge,l(n.translations.system_settings),1),e("form",{onSubmit:t[41]||(t[41]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",ve,[e("label",ye,[e("span",we,l(n.translations.activate_logo_mentions),1),e("input",{type:"checkbox",checked:i.form.logo_mentions_active==1,onChange:t[31]||(t[31]=(...a)=>n.updateLogoMentionsActive&&n.updateLogoMentionsActive(...a)),class:"wcpa-ui-toggle"},null,40,xe)])]),i.form.logo_mentions_active==1?(c(),d("div",ke,[e("label",Ce,l(n.translations.logo_mentions),1),p(e("input",{type:"text",id:"logo-mentions","onUpdate:modelValue":t[32]||(t[32]=a=>i.form.logo_mentions=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.logo_mentions]])])):b("",!0),e("div",Te,[e("label",Me,l(n.translations.company_logo),1),e("div",Ae,[e("input",{id:"file_logo",type:"file",onChange:t[33]||(t[33]=(...a)=>n.handleLogoUpload&&n.handleLogoUpload(...a)),accept:"image/*",class:"ecwp-file-input file-input file-input-bordered file-input-info w-full max-w-xs"},null,32),e("label",Se,[e("span",null,[Pe,g(l(n.translations.select),1)])])]),i.logoPreviewUrl?(c(),d("div",Ee,[p(e("input",{type:"range",min:"0",max:"400","onUpdate:modelValue":t[34]||(t[34]=a=>i.form.logo_width=a),class:"range mt-4",onChange:t[35]||(t[35]=(...a)=>n.updatePreviewWidth&&n.updatePreviewWidth(...a))},null,544),[[f,i.form.logo_width]]),e("div",je,l(i.form.logo_width)+" px",1),i.form.logo_width!==null?(c(),d("div",Ve,[e("img",{src:i.logoPreviewUrl,alt:"Logo Preview",class:"mb-6",style:C({width:i.form.logo_width+"px"})},null,12,Ie)])):b("",!0)])):b("",!0)]),e("div",Fe,[e("label",Re,l(n.translations.default_currency),1),p(e("select",{"onUpdate:modelValue":t[36]||(t[36]=a=>i.form.default_currency=a),class:"ecwp-input input input-bordered"},[(c(!0),d(T,null,S(i.currencies,a=>(c(),d("option",{value:a.id,key:a.id},l(a.name)+" ("+l(a.symbol)+") ",9,Ue))),128))],512),[[V,i.form.default_currency]])]),e("div",De,[e("label",He,l(n.translations.currency_position),1),p(e("select",{"onUpdate:modelValue":t[37]||(t[37]=a=>i.form.currency_position=a),class:"ecwp-input input input-bordered"},[e("option",Ne,l(n.translations.before_amount),1),e("option",Ye,l(n.translations.after_amount),1)],512),[[V,i.form.currency_position]])]),e("div",qe,[e("label",Le,[e("span",Oe,l(n.translations.activate_vat),1),e("input",{type:"checkbox",checked:i.form.vat_active==1,onChange:t[38]||(t[38]=(...a)=>n.updateVatActive&&n.updateVatActive(...a)),class:"wcpa-ui-toggle"},null,40,Xe)])]),i.form.vat_active==1?(c(),d("div",We,[e("label",Be,l(n.translations.default_vat),1),p(e("select",{"onUpdate:modelValue":t[39]||(t[39]=a=>i.form.default_vat=a),class:"ecwp-input input input-bordered"},[ze,(c(!0),d(T,null,S(i.vats,a=>(c(),d("option",{value:a.id,key:a.id},l(a.description)+" - "+l(a.rate)+"% ",9,Ge))),128))],512),[[V,i.form.default_vat]])])):b("",!0),e("div",Je,[e("label",Ze,l(n.translations.format_date),1),p(e("select",{"onUpdate:modelValue":t[40]||(t[40]=a=>i.form.date_format=a),class:"ecwp-input input input-bordered"},as,512),[[V,i.form.date_format]])]),e("div",ls,[e("button",rs,[cs,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===3?(c(),d("div",ds,[i.showArticleModal?(c(),d("dialog",us,[e("div",hs,[e("h3",null,l(i.editingArticle?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[48]||(t[48]=k((...a)=>n.saveArticle&&n.saveArticle(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[42]||(t[42]=(...a)=>n.closeArticleModal&&n.closeArticleModal(...a))}," \u2715 "),e("div",ps,[e("label",ms,l(n.translations.item_ref),1),p(e("input",{type:"text",id:"name_ref","onUpdate:modelValue":t[43]||(t[43]=a=>i.articleForm.ref=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.articleForm.ref]])]),e("div",fs,[e("label",bs,l(n.translations.item_name),1),p(e("input",{type:"text",id:"name_article","onUpdate:modelValue":t[44]||(t[44]=a=>i.articleForm.name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.articleForm.name]])]),e("div",_s,[e("label",gs,l(n.translations.description),1),p(e("textarea",{id:"desc_article","onUpdate:modelValue":t[45]||(t[45]=a=>i.articleForm.description=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.articleForm.description]])]),e("div",vs,[e("label",ys,l(n.translations.unit_price),1),p(e("input",{type:"text",id:"price_article","onUpdate:modelValue":t[46]||(t[46]=a=>i.articleForm.unit_price=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.articleForm.unit_price]])]),e("div",ws,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[47]||(t[47]=(...a)=>n.closeArticleModal&&n.closeArticleModal(...a))},l(n.translations.cancel),1),e("button",xs,l(i.editingArticle?n.translations.save:n.translations.add),1)])],32)])])):b("",!0),e("div",ks,[e("h3",Cs,l(n.translations.articles_settings),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[49]||(t[49]=(...a)=>n.addArticle&&n.addArticle(...a))},[Ts,g(" "+l(n.translations.add),1)])]),e("div",Ms,[e("table",As,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.item_ref),1),e("th",null,l(n.translations.name),1),e("th",null,l(n.translations.description),1),e("th",null,l(n.translations.unit_price),1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.articles,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.ref),1),e("td",null,l(a.name),1),e("td",null,l(a.description),1),e("td",null,l(a.unit_price),1),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:v=>n.editArticle(a.id)},Es,8,Ss),e("button",{class:"p-2 text-error",onClick:v=>n.delete_item("article",a.id)},Is,8,js)])]))),128))])])]),Fs,e("h2",Rs,l(n.translations.categories),1),e("div",Us,[e("table",Ds,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.name),1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.categories,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.name),1),e("td",null,[e("button",{class:"p-2 text-error",onClick:v=>n.delete_item("category_article",a.id)},Ys,8,Hs)])]))),128))])])])])):b("",!0),i.selectedTab===4?(c(),d("div",qs,[e("h2",Ls,l(n.translations.invoices_settings),1),e("form",{onSubmit:t[66]||(t[66]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",Os,[e("div",Xs,[e("label",Ws,l(n.translations.invoice_color),1),p(e("input",{type:"text",id:"invoice-color","onUpdate:modelValue":t[50]||(t[50]=a=>i.form.invoice_color=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.invoice_color]]),x(u,{modelValue:i.form.invoice_color,"onUpdate:modelValue":t[51]||(t[51]=a=>i.form.invoice_color=a)},null,8,["modelValue"])]),e("div",Bs,[e("label",zs,l(n.translations.invoice_prefix),1),p(e("input",{type:"text",id:"invoice-prefix","onUpdate:modelValue":t[52]||(t[52]=a=>i.form.invoice_prefix=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.invoice_prefix]])])]),Gs,e("div",Js,[e("div",Zs,[e("label",Qs,[e("input",{type:"checkbox",checked:i.form.active_disbursements==1,onChange:t[53]||(t[53]=a=>n.updateFormField(a,"active_disbursements")),class:"wcpa-ui-toggle"},null,40,Ks),e("span",$s,l(n.translations.active_disbursements),1)])])]),tn,e("div",en,[e("div",sn,[e("label",nn,[e("input",{type:"checkbox",checked:i.form.show_phone==1,onChange:t[54]||(t[54]=a=>n.updateFormField(a,"show_phone")),class:"wcpa-ui-toggle"},null,40,on),e("span",an,l(n.translations.show_phone),1)])]),e("div",ln,[e("label",rn,[e("input",{type:"checkbox",checked:i.form.show_email==1,onChange:t[55]||(t[55]=a=>n.updateFormField(a,"show_email")),class:"wcpa-ui-toggle"},null,40,cn),e("span",dn,l(n.translations.show_email),1)])]),e("div",un,[e("label",hn,[e("input",{type:"checkbox",checked:i.form.show_siren==1,onChange:t[56]||(t[56]=a=>n.updateFormField(a,"show_siren")),class:"wcpa-ui-toggle"},null,40,pn),e("span",mn,l(n.translations.show_siren),1)])]),e("div",fn,[e("label",bn,[e("input",{type:"checkbox",checked:i.form.show_tax_number==1,onChange:t[57]||(t[57]=a=>n.updateFormField(a,"show_tax_number")),class:"wcpa-ui-toggle"},null,40,_n),e("span",gn,l(n.translations.show_tax_number),1)])]),e("div",vn,[e("label",yn,[e("input",{type:"checkbox",checked:i.form.show_watermark==1,onChange:t[58]||(t[58]=a=>n.updateFormField(a,"show_watermark")),class:"wcpa-ui-toggle"},null,40,wn),e("span",xn,l(n.translations.show_watermark),1)])]),i.form.show_watermark==1?(c(),d("div",kn,[e("label",Cn,[e("input",{type:"checkbox",checked:i.form.show_watermark_only_paid==1,onChange:t[59]||(t[59]=a=>n.updateFormField(a,"show_watermark_only_paid")),class:"wcpa-ui-toggle"},null,40,Tn),e("span",Mn,l(n.translations.show_watermark_only_paid),1)])])):b("",!0)]),An,e("div",Sn,[e("div",Pn,[e("label",En,l(n.translations.payment_conditions),1),p(e("input",{type:"text",id:"conditions-payment","onUpdate:modelValue":t[60]||(t[60]=a=>i.form.payment_conditions=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.payment_conditions]])]),e("div",jn,[e("label",Vn,l(n.translations.payment_mode),1),p(e("input",{type:"text",id:"mode-payment","onUpdate:modelValue":t[61]||(t[61]=a=>i.form.payment_mode=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.payment_mode]])])]),e("div",In,[e("div",Fn,[e("label",Rn,l(n.translations.invoice_terms),1),e("div",null,[x(_,{modelValue:i.form.invoice_terms,"onUpdate:modelValue":t[62]||(t[62]=a=>i.form.invoice_terms=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])]),e("div",Un,[e("div",Dn,[e("label",Hn,l(n.translations.invoice_iban),1),p(e("input",{type:"text",id:"invoice-iban","onUpdate:modelValue":t[63]||(t[63]=a=>i.form.invoice_iban=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.invoice_iban]])]),e("div",Nn,[e("label",Yn,l(n.translations.invoice_bic),1),p(e("input",{type:"text",id:"invoice-bic","onUpdate:modelValue":t[64]||(t[64]=a=>i.form.invoice_bic=a),class:"ecwp-input input input-bordered"},null,512),[[f,i.form.invoice_bic]])])]),e("div",qn,[e("label",Ln,l(n.translations.invoice_footer),1),e("div",null,[x(_,{modelValue:i.form.invoice_footer,"onUpdate:modelValue":t[65]||(t[65]=a=>i.form.invoice_footer=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])])]),e("div",On,[e("button",Xn,[Wn,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===5?(c(),d("div",Bn,[e("h2",zn,l(n.translations.credits_settings),1),e("form",{onSubmit:t[72]||(t[72]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",Gn,[e("div",Jn,[e("label",Zn,l(n.translations.credit_color),1),p(e("input",{type:"text",id:"credit-color","onUpdate:modelValue":t[67]||(t[67]=a=>i.form.credit_color=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.credit_color]]),x(u,{modelValue:i.form.credit_color,"onUpdate:modelValue":t[68]||(t[68]=a=>i.form.credit_color=a)},null,8,["modelValue"])]),e("div",Qn,[e("label",Kn,l(n.translations.credit_prefix),1),p(e("input",{type:"text",id:"credit-prefix","onUpdate:modelValue":t[69]||(t[69]=a=>i.form.credit_prefix=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.credit_prefix]])])]),e("div",$n,[e("div",ti,[e("label",ei,l(n.translations.credit_footer),1),e("div",null,[x(_,{modelValue:i.form.credit_footer,"onUpdate:modelValue":t[70]||(t[70]=a=>i.form.credit_footer=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])]),e("div",si,[e("label",ni,l(n.translations.credit_terms),1),e("div",null,[x(_,{modelValue:i.form.credit_terms,"onUpdate:modelValue":t[71]||(t[71]=a=>i.form.credit_terms=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])])]),e("div",ii,[e("button",oi,[ai,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===6?(c(),d("div",li,[e("h2",ri,l(n.translations.quotes_settings),1),e("form",{onSubmit:t[78]||(t[78]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",ci,[e("div",di,[e("label",ui,l(n.translations.quote_color),1),p(e("input",{type:"text",id:"quote-color","onUpdate:modelValue":t[73]||(t[73]=a=>i.form.quote_color=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.quote_color]]),x(u,{modelValue:i.form.quote_color,"onUpdate:modelValue":t[74]||(t[74]=a=>i.form.quote_color=a)},null,8,["modelValue"])]),e("div",hi,[e("label",pi,l(n.translations.quote_prefix),1),p(e("input",{type:"text",id:"quote-prefix","onUpdate:modelValue":t[75]||(t[75]=a=>i.form.quote_prefix=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.quote_prefix]])])]),e("div",mi,[e("div",fi,[e("label",bi,l(n.translations.quote_footer),1),e("div",null,[x(_,{modelValue:i.form.quote_footer,"onUpdate:modelValue":t[76]||(t[76]=a=>i.form.quote_footer=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])]),e("div",_i,[e("label",gi,l(n.translations.quote_terms),1),e("div",null,[x(_,{modelValue:i.form.quote_terms,"onUpdate:modelValue":t[77]||(t[77]=a=>i.form.quote_terms=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])])])]),e("div",vi,[e("button",yi,[wi,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===7?(c(),d("div",xi,[e("h2",ki,l(n.translations.currency_vat_settings),1),i.showCurrencyModal?(c(),d("dialog",Ci,[e("div",Ti,[e("h3",null,l(i.editingCurrency?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[84]||(t[84]=k((...a)=>n.saveCurrency&&n.saveCurrency(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[79]||(t[79]=(...a)=>n.closeCurrencyModal&&n.closeCurrencyModal(...a))}," \u2715 "),e("div",Mi,[e("label",Ai,l(n.translations.name),1),p(e("input",{type:"text",id:"name_currency","onUpdate:modelValue":t[80]||(t[80]=a=>i.currencyForm.name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.currencyForm.name]])]),e("div",Si,[e("label",Pi,l(n.translations.symbol),1),p(e("input",{type:"text",id:"symbol_currency","onUpdate:modelValue":t[81]||(t[81]=a=>i.currencyForm.symbol=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.currencyForm.symbol]])]),e("div",Ei,[e("label",ji,l(n.translations.code),1),p(e("input",{type:"text",id:"code_currency","onUpdate:modelValue":t[82]||(t[82]=a=>i.currencyForm.code=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.currencyForm.code]])]),e("div",Vi,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[83]||(t[83]=(...a)=>n.closeCurrencyModal&&n.closeCurrencyModal(...a))},l(n.translations.cancel),1),e("button",Ii,l(i.editingCurrency?n.translations.save:n.translations.add),1)])],32)])])):b("",!0),e("div",Fi,[e("div",Ri,[e("h3",Ui,l(n.translations.currencies),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[85]||(t[85]=(...a)=>n.addCurrency&&n.addCurrency(...a))},[Di,g(" "+l(n.translations.add_currency),1)])]),e("div",Hi,[e("table",Ni,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.name),1),e("th",null,l(n.translations.symbol),1),e("th",null,l(n.translations.code),1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.currencies,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.name),1),e("td",null,l(a.symbol),1),e("td",null,l(a.code),1),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:v=>n.editCurrency(a.id)},Li,8,Yi),e("button",{class:"p-2 text-error",onClick:v=>n.delete_item("currency",a.id)},Wi,8,Oi)])]))),128))])])])]),e("div",null,[i.showVATModal?(c(),d("dialog",Bi,[e("div",zi,[e("h3",null,l(i.editingVAT?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[90]||(t[90]=k((...a)=>n.saveVAT&&n.saveVAT(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[86]||(t[86]=(...a)=>n.closeVATModal&&n.closeVATModal(...a))}," \u2715 "),e("div",Gi,[e("label",Ji,l(n.translations.description),1),p(e("input",{type:"text",id:"vat-description","onUpdate:modelValue":t[87]||(t[87]=a=>i.vatForm.description=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.vatForm.description]])]),e("div",Zi,[e("label",Qi,l(n.translations.rate)+" (%)",1),p(e("input",{type:"text",id:"vat-rate","onUpdate:modelValue":t[88]||(t[88]=a=>i.vatForm.rate=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.vatForm.rate]])]),e("div",Ki,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[89]||(t[89]=(...a)=>n.closeVATModal&&n.closeVATModal(...a))},l(n.translations.cancel),1),e("button",$i,l(i.editingVAT?n.translations.save:n.translations.add),1)])],32)])])):b("",!0),e("div",to,[e("h3",eo,l(n.translations.vat_rates),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[91]||(t[91]=(...a)=>n.addVAT&&n.addVAT(...a))},[so,g(" "+l(n.translations.add_vat),1)])]),e("div",no,[e("table",io,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.description),1),e("th",null,l(n.translations.rate)+" (%)",1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.vats,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.description),1),e("td",null,l(a.rate),1),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:v=>n.editVAT(a.id)},lo,8,oo),e("button",{class:"p-2 text-error",onClick:v=>n.delete_item("vat",a.id)},uo,8,ro)])]))),128))])])])])])):b("",!0),i.selectedTab===8?(c(),d("div",ho,[e("h2",po,l(n.translations.payments_settings),1),i.showPaymentModal?(c(),d("dialog",mo,[e("div",fo,[e("h3",null,l(i.editingPayment?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[95]||(t[95]=k((...a)=>n.savePayment&&n.savePayment(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[92]||(t[92]=(...a)=>n.closePaymentModal&&n.closePaymentModal(...a))}," \u2715 "),e("div",bo,[e("label",_o,l(n.translations.name),1),p(e("input",{type:"text",id:"name_payment","onUpdate:modelValue":t[93]||(t[93]=a=>i.paymentForm.method_name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.paymentForm.method_name]])]),e("div",go,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[94]||(t[94]=(...a)=>n.closePaymentModal&&n.closePaymentModal(...a))},l(n.translations.cancel),1),e("button",vo,l(i.editingPayment?n.translations.save:n.translations.add),1)])],32)])])):b("",!0),e("div",yo,[e("div",wo,[e("h3",xo,l(n.translations.payments_methods),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[96]||(t[96]=(...a)=>n.addPayment&&n.addPayment(...a))},[ko,g(l(n.translations.add_method),1)])]),e("div",Co,[e("table",To,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.id),1),e("th",null,l(n.translations.name),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.payments,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.id),1),e("td",null,l(a.method_name),1),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:v=>n.editPayment(a.id)},So,8,Mo),e("button",{class:"p-2 text-error",onClick:v=>n.delete_item("payment",a.id)},jo,8,Po)])]))),128))])])])])])):b("",!0),i.selectedTab===9?(c(),d("div",Vo,[e("h2",Io,l(n.translations.expenses_settings),1),i.showExpenseModal?(c(),d("dialog",Fo,[e("div",Ro,[e("h3",null,l(i.editingExpense?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[100]||(t[100]=k((...a)=>n.saveExpCat&&n.saveExpCat(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[97]||(t[97]=(...a)=>n.closeExpenseModal&&n.closeExpenseModal(...a))}," \u2715 "),e("div",Uo,[e("label",Do,l(n.translations.name),1),p(e("input",{type:"text",id:"name_expense","onUpdate:modelValue":t[98]||(t[98]=a=>i.expenseForm.name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.expenseForm.name]])]),e("div",Ho,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[99]||(t[99]=(...a)=>n.closeExpenseModal&&n.closeExpenseModal(...a))},l(n.translations.cancel),1),e("button",No,l(i.editingExpense?n.translations.save:n.translations.add),1)])],32)])])):b("",!0),e("div",Yo,[e("div",qo,[e("h3",Lo,l(n.translations.expenses_categories),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[101]||(t[101]=(...a)=>n.addExpCat&&n.addExpCat(...a))},[Oo,g(" "+l(n.translations.add_category),1)])]),e("div",Xo,[e("table",Wo,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.id),1),e("th",null,l(n.translations.name),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.expenses,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.id),1),e("td",null,l(a.name),1),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:v=>n.editExpCat(a.id)},Go,8,Bo),e("button",{class:"p-2 text-error",onClick:v=>n.delete_item("expense",a.id)},Qo,8,Jo)])]))),128))])])])])])):b("",!0),i.selectedTab===10?(c(),d("div",Ko,[e("h2",$o,l(n.translations.planning_settings),1),i.showPlanningModal?(c(),d("dialog",ta,[e("div",ea,[e("h3",null,l(i.editingPlanning?n.translations.edit:n.translations.add),1),e("form",{onSubmit:t[109]||(t[109]=k((...a)=>n.savePlanningCat&&n.savePlanningCat(...a),["prevent"]))},[e("button",{class:"btn btn-sm btn-circle btn-ghost absolute right-2 top-2",onClick:t[102]||(t[102]=(...a)=>n.closePlanningModal&&n.closePlanningModal(...a))}," \u2715 "),e("div",sa,[e("label",na,l(n.translations.name),1),p(e("input",{type:"text",id:"name_planning","onUpdate:modelValue":t[103]||(t[103]=a=>i.planningForm.name=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.planningForm.name]])]),e("div",ia,[e("label",oa,l(n.translations.background),1),p(e("input",{type:"text",id:"background_planning","onUpdate:modelValue":t[104]||(t[104]=a=>i.planningForm.background=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.planningForm.background]]),x(u,{modelValue:i.planningForm.background,"onUpdate:modelValue":t[105]||(t[105]=a=>i.planningForm.background=a)},null,8,["modelValue"])]),e("div",aa,[e("label",la,l(n.translations.text_color),1),p(e("input",{type:"text",id:"color_planning","onUpdate:modelValue":t[106]||(t[106]=a=>i.planningForm.color=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.planningForm.color]]),x(u,{modelValue:i.planningForm.color,"onUpdate:modelValue":t[107]||(t[107]=a=>i.planningForm.color=a)},null,8,["modelValue"])]),e("div",ra,[e("button",{type:"button",class:"btn btn-secondary rounded-full",onClick:t[108]||(t[108]=(...a)=>n.closePlanningModal&&n.closePlanningModal(...a))},l(n.translations.cancel),1),e("button",{type:"submit",class:"btn btn-primary rounded-full mx-2",disabled:i.loading},[g(l(i.editingPlanning?n.translations.save:n.translations.add)+" ",1),i.loading?(c(),d("span",da)):b("",!0)],8,ca)])],32)])])):b("",!0),e("div",ua,[e("div",ha,[e("h3",pa,l(n.translations.planning_categories),1),e("button",{class:"btn btn-primary rounded-full",onClick:t[110]||(t[110]=(...a)=>n.addPlanningCat&&n.addPlanningCat(...a))},[ma,g(" "+l(n.translations.add_category),1)])]),e("div",fa,[e("table",ba,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.id),1),e("th",null,l(n.translations.name),1),e("th",null,l(n.translations.background),1),e("th",null,l(n.translations.color),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.planning,a=>(c(),d("tr",{key:a.id},[e("td",null,l(a.id),1),e("td",null,l(a.name),1),e("td",null,[e("span",{class:"ecwp-color-preview",style:C({backgroundColor:a.background})},null,4)]),e("td",null,[e("span",{class:"ecwp-color-preview",style:C({backgroundColor:a.color})},null,4)]),e("td",null,[e("button",{class:"p-2 text-secondary",onClick:v=>n.editPlanningCat(a.id)},va,8,_a),e("button",{class:"p-2 text-error",onClick:v=>n.delete_item("planning",a.id)},xa,8,ya)])]))),128))])])])])])):b("",!0),i.selectedTab===11?(c(),d("div",ka,[e("h2",Ca,l(n.translations.email_settings),1),e("form",{onSubmit:t[122]||(t[122]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",Ta,[e("label",Ma,[e("span",Aa,l(n.translations.email_log_active),1),e("input",{type:"checkbox",checked:i.form.email_log_active==1,onChange:t[111]||(t[111]=(...a)=>n.updateEmailLogsActive&&n.updateEmailLogsActive(...a)),class:"wcpa-ui-toggle"},null,40,Sa)])]),Pa,e("div",Ea,[e("a",{role:"tab",class:y(["tab",{"tab-active":i.activeTabEmail==="tab1"}]),onClick:t[112]||(t[112]=a=>n.setActiveTab("tab1"))},l(n.translations.email_invoice),3),e("a",{role:"tab",class:y(["tab",{"tab-active":i.activeTabEmail==="tab2"}]),onClick:t[113]||(t[113]=a=>n.setActiveTab("tab2"))},l(n.translations.email_quote),3),e("a",{role:"tab",class:y(["tab",{"tab-active":i.activeTabEmail==="tab3"}]),onClick:t[114]||(t[114]=a=>n.setActiveTab("tab3"))},l(n.translations.invoice_reminder),3),e("a",{role:"tab",class:y(["tab",{"tab-active":i.activeTabEmail==="tab4"}]),onClick:t[115]||(t[115]=a=>n.setActiveTab("tab4"))},l(n.translations.payment_received),3)]),i.activeTabEmail==="tab1"?(c(),d("div",ja,[e("div",Va,[e("div",Ia,[e("label",Fa,l(n.translations.email_subject),1),p(e("input",{type:"text",id:"email_invoice_subject","onUpdate:modelValue":t[116]||(t[116]=a=>i.form.email_invoice_subject=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.email_invoice_subject]])]),e("div",Ra,[e("label",Ua,l(n.translations.email_content),1),e("div",null,[x(_,{modelValue:i.form.email_invoice_content,"onUpdate:modelValue":t[117]||(t[117]=a=>i.form.email_invoice_content=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])]),Da])])])):b("",!0),i.activeTabEmail==="tab2"?(c(),d("div",Ha,[e("div",Na,[e("div",Ya,[e("label",qa,l(n.translations.email_subject),1),p(e("input",{type:"text",id:"email_quote_subject","onUpdate:modelValue":t[118]||(t[118]=a=>i.form.email_quote_subject=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.email_quote_subject]])]),e("div",La,[e("label",Oa,l(n.translations.email_content),1),e("div",null,[x(_,{modelValue:i.form.email_quote_content,"onUpdate:modelValue":t[119]||(t[119]=a=>i.form.email_quote_content=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])]),Xa])])])):b("",!0),i.activeTabEmail==="tab3"?(c(),d("div",Wa,[e("div",Ba,[e("div",za,[e("label",Ga,l(n.translations.email_subject),1),p(e("input",{type:"text",id:"remind_invoice_subject","onUpdate:modelValue":t[120]||(t[120]=a=>i.form.remind_invoice_subject=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.remind_invoice_subject]])]),e("div",Ja,[e("label",Za,l(n.translations.email_content),1),e("div",null,[x(_,{modelValue:i.form.remind_invoice_content,"onUpdate:modelValue":t[121]||(t[121]=a=>i.form.remind_invoice_content=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])]),Qa])])])):b("",!0),i.activeTabEmail==="tab4"?(c(),d("div",Ka,[e("div",$a,[tl,e("div",null,[e("h2",el,l(n.translations.coming_soon),1)])])])):b("",!0),e("div",sl,[e("button",nl,[il,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===12?(c(),d("div",ol,[e("h2",al,l(n.translations.users_settings),1),e("div",ll,[e("a",{role:"tab",class:y(["tab",{"tab-active":i.activeTabUsers==="user1"}]),onClick:t[123]||(t[123]=a=>n.setActiveTabUsers("user1"))}," Automatic create account ",2),e("a",{role:"tab",class:y(["tab",{"tab-active":i.activeTabUsers==="user2"}]),onClick:t[124]||(t[124]=a=>n.setActiveTabUsers("user2"))}," Lost password ",2)]),i.activeTabUsers==="user1"?(c(),d("div",rl,[e("form",{onSubmit:t[127]||(t[127]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",cl,[e("div",dl,[e("label",ul,l(n.translations.email_subject),1),p(e("input",{type:"text",id:"email_create_account_subject","onUpdate:modelValue":t[125]||(t[125]=a=>i.form.email_create_account_subject=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.email_create_account_subject]])]),e("div",hl,[e("label",pl,l(n.translations.email_content),1),e("div",null,[x(_,{modelValue:i.form.email_create_account_content,"onUpdate:modelValue":t[126]||(t[126]=a=>i.form.email_create_account_content=a),editorToolbar:i.toolbarOptions},null,8,["modelValue","editorToolbar"])]),ml])]),e("div",fl,[e("button",bl,[_l,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.activeTabUsers==="user2"?(c(),d("div",gl,[e("div",vl,[yl,e("div",null,[e("h2",wl,l(n.translations.coming_soon),1)])])])):b("",!0)])):b("",!0),i.selectedTab===13?(c(),d("div",xl,[e("h2",kl,l(n.translations.stripe_settings),1),e("form",{onSubmit:t[133]||(t[133]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",Cl,[e("div",Tl,[e("label",Ml,l(n.translations.stripe_mode),1),p(e("select",{id:"stripe-mode","onUpdate:modelValue":t[128]||(t[128]=a=>i.form.stripe_mode=a),class:"ecwp-input input input-bordered",required:""},[e("option",Al,l(n.translations.test_mode),1),e("option",Sl,l(n.translations.live_mode),1)],512),[[V,i.form.stripe_mode]])]),i.form.stripe_mode==="test"?(c(),d("div",Pl,[e("div",El,[e("label",jl,l(n.translations.stripe_public_key_test),1),p(e("input",{type:"text",id:"stripe-public-key-test","onUpdate:modelValue":t[129]||(t[129]=a=>i.form.stripe_public_key_test=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.stripe_public_key_test]])]),e("div",Vl,[e("label",Il,l(n.translations.stripe_secret_key_test),1),p(e("input",{type:"text",id:"stripe-secret-key-test","onUpdate:modelValue":t[130]||(t[130]=a=>i.form.stripe_secret_key_test=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.stripe_secret_key_test]])])])):b("",!0),i.form.stripe_mode==="live"?(c(),d("div",Fl,[e("div",Rl,[e("label",Ul,l(n.translations.stripe_public_key_live),1),p(e("input",{type:"text",id:"stripe-public-key-live","onUpdate:modelValue":t[131]||(t[131]=a=>i.form.stripe_public_key_live=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.stripe_public_key_live]])]),e("div",Dl,[e("label",Hl,l(n.translations.stripe_secret_key_live),1),p(e("input",{type:"text",id:"stripe-secret-key-live","onUpdate:modelValue":t[132]||(t[132]=a=>i.form.stripe_secret_key_live=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.stripe_secret_key_live]])])])):b("",!0)]),e("div",Nl,[e("button",Yl,[ql,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===14?(c(),d("div",Ll,[e("h2",Ol,l(n.translations.stats_settings),1),e("form",{onSubmit:t[136]||(t[136]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",Xl,[e("div",Wl,[e("label",Bl,l(n.translations.limit_declaration),1),p(e("input",{type:"number",id:"limit-declaration","onUpdate:modelValue":t[134]||(t[134]=a=>i.form.limit_declaration=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.limit_declaration]])]),e("div",zl,[e("label",Gl,l(n.translations.limit_tva),1),p(e("input",{type:"number",id:"limit-tva","onUpdate:modelValue":t[135]||(t[135]=a=>i.form.limit_tva=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.limit_tva]])])]),e("div",Jl,[e("button",Zl,[Ql,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===15?(c(),d("div",Kl,[e("h2",$l,l(n.translations.qrcode_settings),1),e("form",{onSubmit:t[138]||(t[138]=k((...a)=>n.handleSubmit&&n.handleSubmit(...a),["prevent"]))},[e("div",tr,[e("div",er,[e("label",sr,l(n.translations.stripe_api),1),p(e("input",{type:"text",id:"stripe-api","onUpdate:modelValue":t[137]||(t[137]=a=>i.form.easy_compta_stripe_secret_api=a),class:"ecwp-input input input-bordered",required:""},null,512),[[f,i.form.easy_compta_stripe_secret_api]])])]),e("div",nr,[e("button",ir,[or,g(" "+l(n.translations.save),1)])])],32)])):b("",!0),i.selectedTab===16?(c(),d("div",ar,[e("h2",lr,l(n.translations.validation_license),1),e("div",rr,[e("div",cr,[e("label",dr,l(n.translations.license_key),1),p(e("input",{type:"text",id:"license-code","onUpdate:modelValue":t[139]||(t[139]=a=>i.license_key=a),class:"ecwp-input input input-bordered w-full",disabled:i.licenseData&&i.licenseData.valid,required:""},null,8,ur),[[f,i.license_key]]),e("button",{onClick:t[140]||(t[140]=(...a)=>n.checkLicense&&n.checkLicense(...a)),class:"btn btn-primary join-item rounded-r-full mt-5 -me-1",disabled:i.loadingLicense||i.licenseData&&i.licenseData.valid},[i.loadingLicense?(c(),d("span",pr)):(c(),d("span",mr,l(n.translations.validate),1))],8,hr)])]),e("div",fr,[i.errorMessage?(c(),d("div",br,l(i.errorMessage),1)):b("",!0),i.licenseData?(c(),d("div",_r,[e("table",gr,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.domain),1),e("th",null,l(n.translations.addon_name),1),e("th",null,l(n.translations.activation_date),1),e("th",null,l(n.translations.expiry_date),1),e("th",null,l(n.translations.status),1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[e("tr",null,[e("td",null,l(i.licenseData.domain),1),e("td",null,[(c(!0),d(T,null,S(i.licenseData.plugins,(a,v)=>(c(),d("div",{key:v},l(v),1))),128))]),e("td",null,l(i.licenseData.start_date),1),e("td",null,l(i.licenseData.end_date),1),e("td",null,l(i.licenseData.valid?"Valid":"Invalid"),1),e("td",null,[e("button",{onClick:t[141]||(t[141]=a=>n.refresh_licence()),class:"btn btn-circle text-blue-500 hover:text-blue-700 mx-1"},yr),e("button",{onClick:t[142]||(t[142]=a=>n.delete_item("licence","")),class:"btn btn-circle text-red-500 hover:text-red-700 mx-1"},xr)])])])]),e("table",kr,[e("thead",null,[e("tr",null,[e("th",null,l(n.translations.addon_name),1),e("th",null,l(n.translations.slug),1),e("th",null,l(n.translations.installed),1),e("th",null,l(n.translations.version),1),e("th",null,l(n.translations.actions),1)])]),e("tbody",null,[(c(!0),d(T,null,S(i.licenseData.plugins,a=>(c(),d("tr",{key:a},[e("td",null,l(a.product_name),1),e("td",null,l(a.product_slug),1),e("td",null,[i.installed_versions[a.product_slug]?(c(),d(T,{key:0},[g(l(n.translations.installed),1)],64)):(c(),d(T,{key:1},[g(l(n.translations.not_installed),1)],64))]),e("td",null,l(i.installed_versions[a.product_slug]),1),e("td",null,[i.installed_versions[a.product_slug]?(c(),d(T,{key:0},[e("button",{onClick:v=>n.checkUpdatePlugin(a.product_slug,i.installed_versions[a.product_slug]),class:"btn btn-sm text-red-500 hover:text-red-700 mx-1"},l(n.translations.check_update),9,Cr),i.updatesAvailable[a.product_slug]?(c(),d("button",{key:0,onClick:v=>n.installUpdatePlugin(a.product_slug,i.updatesAvailable[a.product_slug]),class:"btn btn-sm text-blue-500 hover:text-blue-700 mx-1"},l(n.translations.download),9,Tr)):b("",!0)],64)):(c(),d("button",{key:1,onClick:v=>n.installUpdatePlugin(a.product_slug,i.updatesAvailable[a.product_slug]),class:"btn btn-sm text-green-500 hover:green-red-700 mx-1"},l(n.translations.download),9,Mr))])]))),128))])])])):b("",!0)])])):b("",!0)])])]),_:1})])}var Sr=tt(dt,[["render",Ar]]);function R(s){return R=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},R(s)}var Pr=/^\s+/,Er=/\s+$/;function h(s,t){if(s=s||"",t=t||{},s instanceof h)return s;if(!(this instanceof h))return new h(s,t);var o=jr(s);this._originalInput=s,this._r=o.r,this._g=o.g,this._b=o.b,this._a=o.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||o.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=o.ok}h.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(t.r*299+t.g*587+t.b*114)/1e3},getLuminance:function(){var t=this.toRgb(),o,r,i,n,m,u;return o=t.r/255,r=t.g/255,i=t.b/255,o<=.03928?n=o/12.92:n=Math.pow((o+.055)/1.055,2.4),r<=.03928?m=r/12.92:m=Math.pow((r+.055)/1.055,2.4),i<=.03928?u=i/12.92:u=Math.pow((i+.055)/1.055,2.4),.2126*n+.7152*m+.0722*u},setAlpha:function(t){return this._a=J(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=q(this._r,this._g,this._b);return{h:t.h*360,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=q(this._r,this._g,this._b),o=Math.round(t.h*360),r=Math.round(t.s*100),i=Math.round(t.v*100);return this._a==1?"hsv("+o+", "+r+"%, "+i+"%)":"hsva("+o+", "+r+"%, "+i+"%, "+this._roundA+")"},toHsl:function(){var t=Y(this._r,this._g,this._b);return{h:t.h*360,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=Y(this._r,this._g,this._b),o=Math.round(t.h*360),r=Math.round(t.s*100),i=Math.round(t.l*100);return this._a==1?"hsl("+o+", "+r+"%, "+i+"%)":"hsla("+o+", "+r+"%, "+i+"%, "+this._roundA+")"},toHex:function(t){return L(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return Rr(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(w(this._r,255)*100)+"%",g:Math.round(w(this._g,255)*100)+"%",b:Math.round(w(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(w(this._r,255)*100)+"%, "+Math.round(w(this._g,255)*100)+"%, "+Math.round(w(this._b,255)*100)+"%)":"rgba("+Math.round(w(this._r,255)*100)+"%, "+Math.round(w(this._g,255)*100)+"%, "+Math.round(w(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:zr[L(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var o="#"+O(this._r,this._g,this._b,this._a),r=o,i=this._gradientType?"GradientType = 1, ":"";if(t){var n=h(t);r="#"+O(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+i+"startColorstr="+o+",endColorstr="+r+")"},toString:function(t){var o=!!t;t=t||this._format;var r=!1,i=this._a<1&&this._a>=0,n=!o&&i&&(t==="hex"||t==="hex6"||t==="hex3"||t==="hex4"||t==="hex8"||t==="name");return n?t==="name"&&this._a===0?this.toName():this.toRgbString():(t==="rgb"&&(r=this.toRgbString()),t==="prgb"&&(r=this.toPercentageRgbString()),(t==="hex"||t==="hex6")&&(r=this.toHexString()),t==="hex3"&&(r=this.toHexString(!0)),t==="hex4"&&(r=this.toHex8String(!0)),t==="hex8"&&(r=this.toHex8String()),t==="name"&&(r=this.toName()),t==="hsl"&&(r=this.toHslString()),t==="hsv"&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return h(this.toString())},_applyModification:function(t,o){var r=t.apply(null,[this].concat([].slice.call(o)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(Nr,arguments)},brighten:function(){return this._applyModification(Yr,arguments)},darken:function(){return this._applyModification(qr,arguments)},desaturate:function(){return this._applyModification(Ur,arguments)},saturate:function(){return this._applyModification(Dr,arguments)},greyscale:function(){return this._applyModification(Hr,arguments)},spin:function(){return this._applyModification(Lr,arguments)},_applyCombination:function(t,o){return t.apply(null,[this].concat([].slice.call(o)))},analogous:function(){return this._applyCombination(Wr,arguments)},complement:function(){return this._applyCombination(Or,arguments)},monochromatic:function(){return this._applyCombination(Br,arguments)},splitcomplement:function(){return this._applyCombination(Xr,arguments)},triad:function(){return this._applyCombination(X,[3])},tetrad:function(){return this._applyCombination(X,[4])}};h.fromRatio=function(s,t){if(R(s)=="object"){var o={};for(var r in s)s.hasOwnProperty(r)&&(r==="a"?o[r]=s[r]:o[r]=F(s[r]));s=o}return h(s,t)};function jr(s){var t={r:0,g:0,b:0},o=1,r=null,i=null,n=null,m=!1,u=!1;return typeof s=="string"&&(s=Qr(s)),R(s)=="object"&&(j(s.r)&&j(s.g)&&j(s.b)?(t=Vr(s.r,s.g,s.b),m=!0,u=String(s.r).substr(-1)==="%"?"prgb":"rgb"):j(s.h)&&j(s.s)&&j(s.v)?(r=F(s.s),i=F(s.v),t=Fr(s.h,r,i),m=!0,u="hsv"):j(s.h)&&j(s.s)&&j(s.l)&&(r=F(s.s),n=F(s.l),t=Ir(s.h,r,n),m=!0,u="hsl"),s.hasOwnProperty("a")&&(o=s.a)),o=J(o),{ok:m,format:s.format||u,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:o}}function Vr(s,t,o){return{r:w(s,255)*255,g:w(t,255)*255,b:w(o,255)*255}}function Y(s,t,o){s=w(s,255),t=w(t,255),o=w(o,255);var r=Math.max(s,t,o),i=Math.min(s,t,o),n,m,u=(r+i)/2;if(r==i)n=m=0;else{var _=r-i;switch(m=u>.5?_/(2-r-i):_/(r+i),r){case s:n=(t-o)/_+(t<o?6:0);break;case t:n=(o-s)/_+2;break;case o:n=(s-t)/_+4;break}n/=6}return{h:n,s:m,l:u}}function Ir(s,t,o){var r,i,n;s=w(s,360),t=w(t,100),o=w(o,100);function m(M,a,v){return v<0&&(v+=1),v>1&&(v-=1),v<1/6?M+(a-M)*6*v:v<1/2?a:v<2/3?M+(a-M)*(2/3-v)*6:M}if(t===0)r=i=n=o;else{var u=o<.5?o*(1+t):o+t-o*t,_=2*o-u;r=m(_,u,s+1/3),i=m(_,u,s),n=m(_,u,s-1/3)}return{r:r*255,g:i*255,b:n*255}}function q(s,t,o){s=w(s,255),t=w(t,255),o=w(o,255);var r=Math.max(s,t,o),i=Math.min(s,t,o),n,m,u=r,_=r-i;if(m=r===0?0:_/r,r==i)n=0;else{switch(r){case s:n=(t-o)/_+(t<o?6:0);break;case t:n=(o-s)/_+2;break;case o:n=(s-t)/_+4;break}n/=6}return{h:n,s:m,v:u}}function Fr(s,t,o){s=w(s,360)*6,t=w(t,100),o=w(o,100);var r=Math.floor(s),i=s-r,n=o*(1-t),m=o*(1-i*t),u=o*(1-(1-i)*t),_=r%6,M=[o,m,n,n,u,o][_],a=[u,o,o,m,n,n][_],v=[n,n,u,o,o,m][_];return{r:M*255,g:a*255,b:v*255}}function L(s,t,o,r){var i=[E(Math.round(s).toString(16)),E(Math.round(t).toString(16)),E(Math.round(o).toString(16))];return r&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}function Rr(s,t,o,r,i){var n=[E(Math.round(s).toString(16)),E(Math.round(t).toString(16)),E(Math.round(o).toString(16)),E(Z(r))];return i&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)&&n[3].charAt(0)==n[3].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0)+n[3].charAt(0):n.join("")}function O(s,t,o,r){var i=[E(Z(r)),E(Math.round(s).toString(16)),E(Math.round(t).toString(16)),E(Math.round(o).toString(16))];return i.join("")}h.equals=function(s,t){return!s||!t?!1:h(s).toRgbString()==h(t).toRgbString()};h.random=function(){return h.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function Ur(s,t){t=t===0?0:t||10;var o=h(s).toHsl();return o.s-=t/100,o.s=H(o.s),h(o)}function Dr(s,t){t=t===0?0:t||10;var o=h(s).toHsl();return o.s+=t/100,o.s=H(o.s),h(o)}function Hr(s){return h(s).desaturate(100)}function Nr(s,t){t=t===0?0:t||10;var o=h(s).toHsl();return o.l+=t/100,o.l=H(o.l),h(o)}function Yr(s,t){t=t===0?0:t||10;var o=h(s).toRgb();return o.r=Math.max(0,Math.min(255,o.r-Math.round(255*-(t/100)))),o.g=Math.max(0,Math.min(255,o.g-Math.round(255*-(t/100)))),o.b=Math.max(0,Math.min(255,o.b-Math.round(255*-(t/100)))),h(o)}function qr(s,t){t=t===0?0:t||10;var o=h(s).toHsl();return o.l-=t/100,o.l=H(o.l),h(o)}function Lr(s,t){var o=h(s).toHsl(),r=(o.h+t)%360;return o.h=r<0?360+r:r,h(o)}function Or(s){var t=h(s).toHsl();return t.h=(t.h+180)%360,h(t)}function X(s,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var o=h(s).toHsl(),r=[h(s)],i=360/t,n=1;n<t;n++)r.push(h({h:(o.h+n*i)%360,s:o.s,l:o.l}));return r}function Xr(s){var t=h(s).toHsl(),o=t.h;return[h(s),h({h:(o+72)%360,s:t.s,l:t.l}),h({h:(o+216)%360,s:t.s,l:t.l})]}function Wr(s,t,o){t=t||6,o=o||30;var r=h(s).toHsl(),i=360/o,n=[h(s)];for(r.h=(r.h-(i*t>>1)+720)%360;--t;)r.h=(r.h+i)%360,n.push(h(r));return n}function Br(s,t){t=t||6;for(var o=h(s).toHsv(),r=o.h,i=o.s,n=o.v,m=[],u=1/t;t--;)m.push(h({h:r,s:i,v:n})),n=(n+u)%1;return m}h.mix=function(s,t,o){o=o===0?0:o||50;var r=h(s).toRgb(),i=h(t).toRgb(),n=o/100,m={r:(i.r-r.r)*n+r.r,g:(i.g-r.g)*n+r.g,b:(i.b-r.b)*n+r.b,a:(i.a-r.a)*n+r.a};return h(m)};h.readability=function(s,t){var o=h(s),r=h(t);return(Math.max(o.getLuminance(),r.getLuminance())+.05)/(Math.min(o.getLuminance(),r.getLuminance())+.05)};h.isReadable=function(s,t,o){var r=h.readability(s,t),i,n;switch(n=!1,i=Kr(o),i.level+i.size){case"AAsmall":case"AAAlarge":n=r>=4.5;break;case"AAlarge":n=r>=3;break;case"AAAsmall":n=r>=7;break}return n};h.mostReadable=function(s,t,o){var r=null,i=0,n,m,u,_;o=o||{},m=o.includeFallbackColors,u=o.level,_=o.size;for(var M=0;M<t.length;M++)n=h.readability(s,t[M]),n>i&&(i=n,r=h(t[M]));return h.isReadable(s,r,{level:u,size:_})||!m?r:(o.includeFallbackColors=!1,h.mostReadable(s,["#fff","#000"],o))};var N=h.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},zr=h.hexNames=Gr(N);function Gr(s){var t={};for(var o in s)s.hasOwnProperty(o)&&(t[s[o]]=o);return t}function J(s){return s=parseFloat(s),(isNaN(s)||s<0||s>1)&&(s=1),s}function w(s,t){Jr(s)&&(s="100%");var o=Zr(s);return s=Math.min(t,Math.max(0,parseFloat(s))),o&&(s=parseInt(s*t,10)/100),Math.abs(s-t)<1e-6?1:s%t/parseFloat(t)}function H(s){return Math.min(1,Math.max(0,s))}function A(s){return parseInt(s,16)}function Jr(s){return typeof s=="string"&&s.indexOf(".")!=-1&&parseFloat(s)===1}function Zr(s){return typeof s=="string"&&s.indexOf("%")!=-1}function E(s){return s.length==1?"0"+s:""+s}function F(s){return s<=1&&(s=s*100+"%"),s}function Z(s){return Math.round(parseFloat(s)*255).toString(16)}function W(s){return A(s)/255}var P=function(){var s="[-\\+]?\\d+%?",t="[-\\+]?\\d*\\.\\d+%?",o="(?:"+t+")|(?:"+s+")",r="[\\s|\\(]+("+o+")[,|\\s]+("+o+")[,|\\s]+("+o+")\\s*\\)?",i="[\\s|\\(]+("+o+")[,|\\s]+("+o+")[,|\\s]+("+o+")[,|\\s]+("+o+")\\s*\\)?";return{CSS_UNIT:new RegExp(o),rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function j(s){return!!P.CSS_UNIT.exec(s)}function Qr(s){s=s.replace(Pr,"").replace(Er,"").toLowerCase();var t=!1;if(N[s])s=N[s],t=!0;else if(s=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var o;return(o=P.rgb.exec(s))?{r:o[1],g:o[2],b:o[3]}:(o=P.rgba.exec(s))?{r:o[1],g:o[2],b:o[3],a:o[4]}:(o=P.hsl.exec(s))?{h:o[1],s:o[2],l:o[3]}:(o=P.hsla.exec(s))?{h:o[1],s:o[2],l:o[3],a:o[4]}:(o=P.hsv.exec(s))?{h:o[1],s:o[2],v:o[3]}:(o=P.hsva.exec(s))?{h:o[1],s:o[2],v:o[3],a:o[4]}:(o=P.hex8.exec(s))?{r:A(o[1]),g:A(o[2]),b:A(o[3]),a:W(o[4]),format:t?"name":"hex8"}:(o=P.hex6.exec(s))?{r:A(o[1]),g:A(o[2]),b:A(o[3]),format:t?"name":"hex"}:(o=P.hex4.exec(s))?{r:A(o[1]+""+o[1]),g:A(o[2]+""+o[2]),b:A(o[3]+""+o[3]),a:W(o[4]+""+o[4]),format:t?"name":"hex8"}:(o=P.hex3.exec(s))?{r:A(o[1]+""+o[1]),g:A(o[2]+""+o[2]),b:A(o[3]+""+o[3]),format:t?"name":"hex"}:!1}function Kr(s){var t,o;return s=s||{level:"AA",size:"small"},t=(s.level||"AA").toUpperCase(),o=(s.size||"small").toLowerCase(),t!=="AA"&&t!=="AAA"&&(t="AA"),o!=="small"&&o!=="large"&&(o="small"),{level:t,size:o}}var Q={name:"ColorPicker",props:["color","position","boxRect","disableAlpha","disableTextInputs"],emits:["updateColor","hueInputStart","hueInputEnd","hueInput","alphaInputStart","alphaInputEnd","alphaInput","saturationInputStart","saturationInputEnd","saturationInput","ready","change"],inject:["tinycolor"],data(){return{h:void 0,s:void 0,v:void 0,a:void 0,hueTranslateX:0,alphaTranslateX:0,saturationTranslateX:0,saturationTranslateY:0,sliderPointerWidth:0,saturationPointerWidth:0,saturationPointerHeight:0,pickerPositionA:{anchor:"top",offset:0},pickerPositionB:{anchor:"left",offset:0},pickerWidth:0,pickerHeight:0,textInputsFormat:"rgb",textInputActive:null,textInputsFreeze:{},arrowColor:"#0f0f0f",sliderWidth:0}},computed:{pureHueBackground(){return{background:"hsl("+this.h+", 100%, 50%)"}},hexString(){return this.color.toHexString()},huePointerStyles(){return{transform:"translate("+(this.hueTranslateX-this.sliderPointerWidth*.5)+"px)"}},alphaPointerStyles(){return{transform:"translate("+(this.alphaTranslateX-this.sliderPointerWidth*.5)+"px)"}},alphaPointerTransparentStyles(){return{backgroundPosition:-this.alphaTranslateX+"px"}},alphaPointerColorStyles(){return{opacity:this.a}},alphaCanvasStyles(){return{background:"linear-gradient(90deg, transparent 0%, "+this.color.toHexString()+" 100%)"}},saturationPointerStyles(){const s=this.saturationTranslateX-this.saturationPointerWidth*.5,t=this.saturationTranslateY+this.saturationPointerHeight*.5;return{transform:"translate("+s+"px, "+t+"px)"}},arrowsStyles(){return{"--arrow-color":this.arrowColor}},pickerPosition(){const s={},t={top:"bottom",bottom:"top",left:"right",right:"left"};let o;["top","bottom"].includes(this.position[0])?(s.marginLeft=0,s.marginRight=0,o=this.boxRect.height):(s.marginTop=0,s.marginBottom=0,o=this.boxRect.width);let r=t[this.position[0]];return s[r]=o+"px",this.position[1]==="center"?(["left","right"].includes(r)?(r="top",o=this.pickerHeight-this.boxRect.height):(r="left",o=this.pickerWidth-this.boxRect.width),o*=.5):(r=t[this.position[1]],o=0),s[r]=-o+"px",s},textInputs(){const s=this.textInputsFormat,t={};if(["name","hex"].includes(s))t.hex=this.color.toString("hex");else{const o=this.color.toString(s).split("(")[1].slice(0,-1).split(", ");s.split("").forEach((r,i)=>t[r]=o[i])}if(this.disableAlpha||(t.a=Number(this.color.getAlpha().toFixed(2))),t.hasOwnProperty("h")&&(t.h=Math.round(this.h),t.hasOwnProperty("l"))){let o=this.s;const r=this.v||.001,i=(2-o)*r/2;i<.5&&(o*=r/(i*2),t.s=Math.round(o*100)+"%")}return t}},methods:{saturationPickStart(s){this.getCanvasRects(),document.addEventListener("pointerup",this.saturationPickEnd),document.addEventListener("pointermove",this.saturationPickMove),this.saturationPickMove(s),this.emitHook("saturationInputStart",{s:this.s,v:this.v}),this.colorSnapshot=this.color.toRgbString()},saturationPickEnd(s){document.removeEventListener("pointerup",this.saturationPickEnd),document.removeEventListener("pointermove",this.saturationPickMove),this.emitHook("saturationInputEnd",{s:this.s,v:this.v}),this.colorSnapshot!==this.color.toRgbString()&&this.emitHook("change",{h:this.h,s:this.s,v:this.v,a:this.a})},saturationPickMove(s){s.clientX>=this.saturationCanvasRect.x&&s.clientX<=this.saturationCanvasRect.right?this.s=(s.clientX-this.saturationCanvasRect.x)/this.saturationCanvasRect.width:s.clientX<this.saturationCanvasRect.x?this.s=0:this.s=1,s.clientY>=this.saturationCanvasRect.y&&s.clientY<=this.saturationCanvasRect.bottom?this.v=1-(s.clientY-this.saturationCanvasRect.y)/this.saturationCanvasRect.height:s.clientY<this.saturationCanvasRect.y?this.v=1:this.v=0},huePickStart(s){this.getCanvasRects(),document.addEventListener("pointerup",this.huePickEnd),document.addEventListener("pointermove",this.huePickMove),this.huePickMove(s),this.emitHook("hueInputStart",{h:this.h}),this.colorSnapshot=this.color.toRgbString()},huePickEnd(s){document.removeEventListener("pointerup",this.huePickEnd),document.removeEventListener("pointermove",this.huePickMove),this.emitHook("hueInputEnd",{h:this.h}),this.colorSnapshot!==this.color.toRgbString()&&this.emitHook("change",{h:this.h,s:this.s,v:this.v,a:this.a})},huePickMove(s){s.clientX>=this.hueCanvasRect.x&&s.clientX<=this.hueCanvasRect.right?this.h=(s.clientX-this.hueCanvasRect.x)*360/this.hueCanvasRect.width:s.clientX<this.hueCanvasRect.x?this.h=0:this.h=360},alphaPickStart(s){this.getCanvasRects(),document.addEventListener("pointerup",this.alphaPickEnd),document.addEventListener("pointermove",this.alphaPickMove),this.alphaPickMove(s),this.emitHook("alphaInputStart",{a:this.a}),this.colorSnapshot=this.color.toRgbString()},alphaPickEnd(s){document.removeEventListener("pointerup",this.alphaPickEnd),document.removeEventListener("pointermove",this.alphaPickMove),this.emitHook("alphaInputEnd",{a:this.a}),this.colorSnapshot!==this.color.toRgbString()&&this.emitHook("change",{h:this.h,s:this.s,v:this.v,a:this.a})},alphaPickMove(s){s.clientX>=this.alphaCanvasRect.x&&s.clientX<=this.alphaCanvasRect.right?this.a=(s.clientX-this.alphaCanvasRect.x)/this.alphaCanvasRect.width:s.clientX<this.alphaCanvasRect.x?this.a=0:this.a=1},emitUpdate(s){s=s||{h:this.h,s:this.s,v:this.v,a:this.a},this.$emit("updateColor",s)},emitHook(s,t){if(typeof t=="object")for(let[o,r]of Object.entries(t))t[o]=Number(r.toFixed(3));else t=Number(t.toFixed(3));this.$emit(s,t)},textInputInputHandler(s){const t=s.target.dataset.component;this.textInputsFreeze[t]=s.target.value;let o={...this.textInputsFreeze};if(o.hasOwnProperty("hex")){const n=o.a;o=this.tinycolor(o.hex),o.getFormat()!=="hex8"&&o.setAlpha(n)}else o=this.tinycolor(o);const r=o.toHsv();if(this.textInputsFormat==="hsl"&&(r.h===0&&(r.h=parseInt(this.textInputsFreeze.h)),r.v===0)){let n=this.textInputsFreeze.s;const m=n.indexOf("%")!==-1;n=parseFloat(n),!n||n<0?n=0:(m||n>1)&&(n=Math.min(n*.01,1));const u=.001,_=n*u+u;n=2-2*u/_,r.s=n}const i={h:.5,s:.001,v:.001};t!=="a"?(Object.keys(r).filter(n=>n!=="a").forEach(n=>{const m=this[n],u=r[n];Math.abs(m-u)>i[n]&&(this[n]=u)}),o.getFormat()==="hex8"&&o.getOriginalInput().length>7&&(this.disableAlpha?Object.assign(this.$data,{h:0,s:0,v:0}):(this.a=r.a,this.textInputsFreeze.a=Number(this.a.toFixed(2))))):this.a=r.a},textInputFocusHandler(s){this.textInputActive||(this.textInputsFreeze={...this.textInputs},this.colorSnapshot=this.color.toRgbString()),this.textInputActive=s.target.dataset.component},textInputBlurHandler(s){setTimeout(()=>{this.textInputActive===s.target.dataset.component&&(this.colorSnapshot!==this.color.toRgbString()&&this.emitHook("change",{h:this.h,s:this.s,v:this.v,a:this.a}),this.textInputsFreeze={},this.textInputActive=null)},0)},textInputFormatChange(s){const t=["rgb","name","hsl"];this.textInputsFormat;let o=t.indexOf(this.textInputsFormat)+s;o<0?o=t.length-1:o===t.length&&(o=0),this.textInputsFormat=t[o]},getCanvasRects(){this.saturationCanvasRect=this.$refs.saturationCanvas.getBoundingClientRect(),this.hueCanvasRect=this.$refs.hueCanvas.getBoundingClientRect(),this.alphaCanvasRect=this.disableAlpha?{}:this.$refs.alphaCanvas.getBoundingClientRect()},init(){const s=this.$refs.pickerRoot,t=window.getComputedStyle(s);Object.assign(this.$data,this.color.toHsv()),window.requestAnimationFrame(()=>{const{width:r,height:i}=s.getBoundingClientRect();this.pickerHeight=i,this.pickerWidth=r,this.getCanvasRects(),this.hueTranslateX=this.h*this.hueCanvasRect.width/360,this.alphaTranslateX=this.a*this.alphaCanvasRect.width,this.saturationTranslateX=this.s*this.saturationCanvasRect.width,this.saturationTranslateY=-this.v*this.saturationCanvasRect.height,this.sliderPointerWidth=this.$refs.huePointer.offsetWidth,this.saturationPointerWidth=this.$refs.saturationPointer.offsetWidth,this.saturationPointerHeight=this.$refs.saturationPointer.offsetHeight,window.requestAnimationFrame(()=>{this.$emit("ready")})});const o=t.getPropertyValue("background-color");this.tinycolor(o).isDark()&&(this.arrowColor="#fbfbfb")},fillCanvas(){let s=this.$refs.hueCanvas,t=s.getContext("2d"),o=t.createLinearGradient(s.width,0,0,0);o.addColorStop(0,"hsl(0,100%,50%)"),o.addColorStop(.17,"hsl(298.8, 100%, 50%)"),o.addColorStop(.33,"hsl(241.2, 100%, 50%)"),o.addColorStop(.5,"hsl(180, 100%, 50%)"),o.addColorStop(.67,"hsl(118.8, 100%, 50%)"),o.addColorStop(.83,"hsl(61.2,100%,50%)"),o.addColorStop(1,"hsl(360,100%,50%)"),t.fillStyle=o,t.fillRect(0,0,s.width,s.height),s=this.$refs.saturationCanvas,t=s.getContext("2d"),o=t.createLinearGradient(0,0,s.width,0),o.addColorStop(0,"rgba(250,250,250,1)"),o.addColorStop(1,"rgba(250,250,250,0)"),t.fillStyle=o,t.fillRect(0,0,s.width,s.height),o=t.createLinearGradient(0,s.height,0,0),o.addColorStop(0,"rgba(0,0,0,1)"),o.addColorStop(1,"rgba(0,0,0,0)"),t.fillStyle=o,t.fillRect(0,0,s.width,s.height)}},watch:{h(s,t){this.hueTranslateX=this.h*this.hueCanvasRect.width/360,t!==void 0&&(this.emitUpdate(),this.emitHook("hueInput",{h:this.h}))},s(s,t){this.saturationTranslateX=this.s*this.saturationCanvasRect.width,t!==void 0&&(this.emitUpdate(),this.emitHook("saturationInput",{s:this.s,v:this.v}))},v(s,t){this.saturationTranslateY=-this.v*this.saturationCanvasRect.height,t!==void 0&&(this.emitUpdate(),this.emitHook("saturationInput",{s:this.s,v:this.v}))},a(s,t){this.alphaTranslateX=this.a*this.alphaCanvasRect.width,t!==void 0&&(this.emitUpdate(),this.emitHook("alphaInput",{a:this.a}))}},mounted(){this.getCanvasRects(),this.fillCanvas()},beforeUnmount(){}};const $r={class:"slider-canvas",ref:"saturationCanvas"},tc={class:"slider-container"},ec={class:"slider-canvas",ref:"hueCanvas"},sc={class:"slider-active-area"},nc={class:"slider-container transparency-pattern"},ic={class:"slider-active-area"},oc={class:"text-inputs-wrapper"},ac=["for"],lc=["value","id","data-component"];function rc(s,t,o,r,i,n){return c(),d("div",{ref:"pickerRoot",style:C([n.pickerPosition])},[e("div",{class:"saturation-area",style:C(n.pureHueBackground),onPointerdown:t[0]||(t[0]=(...m)=>n.saturationPickStart&&n.saturationPickStart(...m))},[e("canvas",$r,null,512),e("div",{class:"saturation-pointer",ref:"saturationPointer",style:C([n.saturationPointerStyles,{background:n.hexString}])},null,4)],36),e("div",{class:"slider",onPointerdown:t[1]||(t[1]=(...m)=>n.huePickStart&&n.huePickStart(...m))},[e("div",tc,[e("canvas",ec,null,512)]),e("div",sc,[e("div",{class:"slider-pointer",ref:"huePointer",style:C([n.huePointerStyles,n.pureHueBackground])},null,4)])],32),o.disableAlpha?b("",!0):(c(),d("div",{key:0,class:"slider",onPointerdown:t[2]||(t[2]=(...m)=>n.alphaPickStart&&n.alphaPickStart(...m))},[e("div",nc,[e("div",{class:"slider-canvas",ref:"alphaCanvas",style:C(n.alphaCanvasStyles)},null,4)]),e("div",ic,[e("div",{class:"slider-pointer",ref:"alphaPointer",style:C(n.alphaPointerStyles)},[e("div",{class:"pointer-transparent",style:C(n.alphaPointerTransparentStyles)},[e("div",{class:"pointer-color",style:C([n.alphaPointerColorStyles,{background:n.hexString}])},null,4)],4)],4)])],32)),o.disableTextInputs?b("",!0):(c(),d("div",{key:1,class:"text-inputs-area",style:C({"--outline-color":n.hexString})},[e("div",oc,[(c(!0),d(T,null,S(i.textInputActive?i.textInputsFreeze:n.textInputs,(m,u)=>(c(),d("div",{key:"text-input-"+u,class:"text-input-container"},[e("label",{for:"text-input-"+u},l(u),9,ac),e("input",{value:m,class:"text-input",autocomplete:"off",spellcheck:"false",id:"text-input-"+u,"data-component":u,onInput:t[3]||(t[3]=k((..._)=>n.textInputInputHandler&&n.textInputInputHandler(..._),["prevent"])),onFocus:t[4]||(t[4]=(..._)=>n.textInputFocusHandler&&n.textInputFocusHandler(..._)),onBlur:t[5]||(t[5]=(..._)=>n.textInputBlurHandler&&n.textInputBlurHandler(..._)),onKeypress:t[6]||(t[6]=it(_=>_.target.blur(),["enter"]))},null,40,lc)]))),128))]),e("div",{class:"text-format-arrows",style:C(n.arrowsStyles)},[e("div",{class:"arrow up",onClick:t[7]||(t[7]=m=>n.textInputFormatChange(-1))}),e("div",{class:"arrow down",onClick:t[8]||(t[8]=m=>n.textInputFormatChange(1))})],4)],4))],4)}function K(s,t){t===void 0&&(t={});var o=t.insertAt;if(!(!s||typeof document=="undefined")){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",o==="top"&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=s:i.appendChild(document.createTextNode(s))}}var cc=`.color-input .pointer-transparent, .color-input .pointer-color, .color-input .slider-canvas, .color-input .slider-container {
    22  width: 100%;
    33  height: 100%;
     
    111111.color-input .text-format-arrows .arrow:hover {
    112112  opacity: 0.8;
    113 }`;Q(cc);K.render=rc;var dc="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAiIGhlaWdodD0iMTAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgPHJlY3QgaGVpZ2h0PSI1IiB3aWR0aD0iNSIgeT0iMCIgeD0iMCIgZmlsbD0iI2NjY2NjYyIgc2hhcGUtcmVuZGVyaW5nPSJjcmlzcEVkZ2VzIi8+CiAgPHJlY3QgaGVpZ2h0PSI1IiB3aWR0aD0iNSIgeT0iNSIgeD0iNSIgZmlsbD0iI2NjY2NjYyIgc2hhcGUtcmVuZGVyaW5nPSJjcmlzcEVkZ2VzIi8+Cjwvc3ZnPg==";const uc=(s,t)=>{for(;!/^(body|html)$/i.test(s.tagName);){if(s===t)return!0;s=s.parentNode}return!1};var $=et({name:"ColorInput",props:{modelValue:[String,Object],position:{type:String,default:"bottom"},transition:{type:String,default:"picker-popup"},disableAlpha:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},disableTextInputs:{type:Boolean,default:!1},format:String},emits:["mounted","beforeUnmount","update:modelValue","pickStart","pickEnd","hueInputStart","hueInputEnd","hueInput","alphaInputStart","alphaInputEnd","alphaInput","saturationInputStart","saturationInputEnd","saturationInput","change"],components:{ColorPicker:K},provide:{tinycolor:h},data(){return{color:null,active:!1,ready:!1,hidePicker:!1,boxRect:{},innerBoxRect:{},textInputsFormat:"rgb",originalFormat:"rgb",originalType:null}},computed:{boxColorStyles(){return{background:this.color.toRgbString()}},processedPosition(){const s=["top","right","bottom","left","center"],t={top:"bottom",right:"left",bottom:"top",left:"right"},o=s.slice(0,4).flatMap((i,n)=>s.map(m=>t[i]===m?!1:i===m?i:i+" "+m)).filter(i=>i);let r=this.position.toLowerCase();return o.includes(r)||(r&&console.warn("[vue-color-input]: invalid position -> "+r),r="bottom center"),r=r.split(" "),r[1]=r[1]||"center",r},processedFormat(){let s=["rgb","hsv","hsl"];s=s.concat(s.flatMap(i=>[i+" object","object "+i,i+" string","string "+i])),s=s.concat(["name","hex","hex8"].flatMap(i=>[i,i+" string","string "+i]));let t=this.format,o=!1;t?(t=t.toLowerCase(),s.includes(t)?o=!0:(console.warn("[vue-color-input]: invalid format -> "+t),t=this.originalFormat)):t=this.originalFormat,t=t.split(" ");let r=t.findIndex(i=>["string","object"].includes(i));return r<0?r=["rgb","hsv","hsl"].includes(t[0])?this.originalType:"string":r=t.splice(r,1)[0],t=t[0],{type:r,format:t,force:o}},processedDisableAlpha(){const s=this.processedFormat;return s.force&&["hex","name"].includes(s.format)?!0:this.disableAlpha}},methods:{pickStart(s){this.active||this.disabled||(this.getBoxRect(),this.active=!0,this.ready=!1,this.hidePicker=!0,this.$refs.picker.init(),document.body.addEventListener("pointerdown",this.pickEnd),this.$emit("pickStart"))},pickEnd(s){!this.active||s&&uc(s.target,this.$refs.picker.$refs.pickerRoot)||(document.body.removeEventListener("pointerdown",this.pickEnd),this.active=!1,this.$emit("pickEnd"))},init(){this.color=h(this.modelValue);let s=this.color.getFormat();this.originalFormat=s||"rgb";let t=typeof this.modelValue;this.originalType=["string","object"].includes(t)?t:"string",this.processedFormat,this.output=null,this.color.isValid()||console.warn("[vue-color-input]: invalid color -> "+this.color.getOriginalInput())},emitUpdate(s){s&&(this.color=h(s));let t=this.processedFormat.format;this.color.getAlpha()<1&&["hex","name"].includes(t)&&(this.processedFormat.force?this.color.setAlpha(1):t="rgb"),this.processedFormat.type==="object"?this.output=this.color["to"+t.charAt(0).toUpperCase()+t.slice(1)]():this.output=this.color.toString(t),this.$emit("update:modelValue",this.output)},getBoxRect(){this.boxRect=this.$refs.root.getBoundingClientRect()}},created(){this.init(),this.cssVars={"--transparent-pattern":"url("+dc+")"}},mounted(){this.$emit("mounted")},beforeUnmount(){this.pickEnd(),this.$emit("beforeUnmount")},watch:{modelValue(){let s=typeof this.modelValue=="object"?JSON.stringify(this.modelValue):this.modelValue,t=typeof this.output=="object"?JSON.stringify(this.output):this.output;s!==t&&(this.init(),this.active&&this.$nextTick(function(){this.$refs.picker.init()}))},disabled(){this.pickEnd()},processedDisableAlpha(s){s&&(this.color.setAlpha(1),this.emitUpdate()),this.active&&this.$nextTick(function(){this.$refs.picker.init()})},format(){this.emitUpdate()}}});const hc={class:"inner transparent"};function pc(s,t,o,r,i,n){const m=I("color-picker");return c(),d("div",{class:"color-input user",ref:"root",style:C(s.cssVars)},[e("div",{class:y(["box",{active:s.active,disabled:s.disabled}]),onClick:t[0]||(t[0]=k((...u)=>s.pickStart&&s.pickStart(...u),["stop"])),ref:"box"},[e("div",hc,[e("div",{class:"color",style:C(s.boxColorStyles)},null,4)])],2),x(st,{name:s.transition},{default:G(()=>[p(x(m,{class:"picker-popup",color:this.color,position:s.processedPosition,"disable-alpha":s.processedDisableAlpha,boxRect:s.boxRect,"disable-text-inputs":s.disableTextInputs,style:C({visibility:s.hidePicker?"hidden":""}),onReady:t[1]||(t[1]=u=>s.hidePicker=!1),onUpdateColor:s.emitUpdate,onHueInputStart:t[2]||(t[2]=u=>s.$emit("hueInputStart",u)),onHueInputEnd:t[3]||(t[3]=u=>s.$emit("hueInputEnd",u)),onHueInput:t[4]||(t[4]=u=>s.$emit("hueInput",u)),onAlphaInputStart:t[5]||(t[5]=u=>s.$emit("alphaInputStart",u)),onAlphaInputEnd:t[6]||(t[6]=u=>s.$emit("alphaInputEnd",u)),onAlphaInput:t[7]||(t[7]=u=>s.$emit("alphaInput",u)),onSaturationInputStart:t[8]||(t[8]=u=>s.$emit("saturationInputStart",u)),onSaturationInputEnd:t[9]||(t[9]=u=>s.$emit("saturationInputEnd",u)),onSaturationInput:t[10]||(t[10]=u=>s.$emit("saturationInput",u)),onChange:t[11]||(t[11]=u=>s.$emit("change",u)),ref:"picker"},null,8,["color","position","disable-alpha","boxRect","disable-text-inputs","style","onUpdateColor"]),[[nt,s.active]])]),_:1},8,["name"])],4)}var mc=`.color-input .box .color, .color-input .box .transparent {
     113}`;K(cc);Q.render=rc;var dc="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAiIGhlaWdodD0iMTAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgPHJlY3QgaGVpZ2h0PSI1IiB3aWR0aD0iNSIgeT0iMCIgeD0iMCIgZmlsbD0iI2NjY2NjYyIgc2hhcGUtcmVuZGVyaW5nPSJjcmlzcEVkZ2VzIi8+CiAgPHJlY3QgaGVpZ2h0PSI1IiB3aWR0aD0iNSIgeT0iNSIgeD0iNSIgZmlsbD0iI2NjY2NjYyIgc2hhcGUtcmVuZGVyaW5nPSJjcmlzcEVkZ2VzIi8+Cjwvc3ZnPg==";const uc=(s,t)=>{for(;!/^(body|html)$/i.test(s.tagName);){if(s===t)return!0;s=s.parentNode}return!1};var $=et({name:"ColorInput",props:{modelValue:[String,Object],position:{type:String,default:"bottom"},transition:{type:String,default:"picker-popup"},disableAlpha:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},disableTextInputs:{type:Boolean,default:!1},format:String},emits:["mounted","beforeUnmount","update:modelValue","pickStart","pickEnd","hueInputStart","hueInputEnd","hueInput","alphaInputStart","alphaInputEnd","alphaInput","saturationInputStart","saturationInputEnd","saturationInput","change"],components:{ColorPicker:Q},provide:{tinycolor:h},data(){return{color:null,active:!1,ready:!1,hidePicker:!1,boxRect:{},innerBoxRect:{},textInputsFormat:"rgb",originalFormat:"rgb",originalType:null}},computed:{boxColorStyles(){return{background:this.color.toRgbString()}},processedPosition(){const s=["top","right","bottom","left","center"],t={top:"bottom",right:"left",bottom:"top",left:"right"},o=s.slice(0,4).flatMap((i,n)=>s.map(m=>t[i]===m?!1:i===m?i:i+" "+m)).filter(i=>i);let r=this.position.toLowerCase();return o.includes(r)||(r&&console.warn("[vue-color-input]: invalid position -> "+r),r="bottom center"),r=r.split(" "),r[1]=r[1]||"center",r},processedFormat(){let s=["rgb","hsv","hsl"];s=s.concat(s.flatMap(i=>[i+" object","object "+i,i+" string","string "+i])),s=s.concat(["name","hex","hex8"].flatMap(i=>[i,i+" string","string "+i]));let t=this.format,o=!1;t?(t=t.toLowerCase(),s.includes(t)?o=!0:(console.warn("[vue-color-input]: invalid format -> "+t),t=this.originalFormat)):t=this.originalFormat,t=t.split(" ");let r=t.findIndex(i=>["string","object"].includes(i));return r<0?r=["rgb","hsv","hsl"].includes(t[0])?this.originalType:"string":r=t.splice(r,1)[0],t=t[0],{type:r,format:t,force:o}},processedDisableAlpha(){const s=this.processedFormat;return s.force&&["hex","name"].includes(s.format)?!0:this.disableAlpha}},methods:{pickStart(s){this.active||this.disabled||(this.getBoxRect(),this.active=!0,this.ready=!1,this.hidePicker=!0,this.$refs.picker.init(),document.body.addEventListener("pointerdown",this.pickEnd),this.$emit("pickStart"))},pickEnd(s){!this.active||s&&uc(s.target,this.$refs.picker.$refs.pickerRoot)||(document.body.removeEventListener("pointerdown",this.pickEnd),this.active=!1,this.$emit("pickEnd"))},init(){this.color=h(this.modelValue);let s=this.color.getFormat();this.originalFormat=s||"rgb";let t=typeof this.modelValue;this.originalType=["string","object"].includes(t)?t:"string",this.processedFormat,this.output=null,this.color.isValid()||console.warn("[vue-color-input]: invalid color -> "+this.color.getOriginalInput())},emitUpdate(s){s&&(this.color=h(s));let t=this.processedFormat.format;this.color.getAlpha()<1&&["hex","name"].includes(t)&&(this.processedFormat.force?this.color.setAlpha(1):t="rgb"),this.processedFormat.type==="object"?this.output=this.color["to"+t.charAt(0).toUpperCase()+t.slice(1)]():this.output=this.color.toString(t),this.$emit("update:modelValue",this.output)},getBoxRect(){this.boxRect=this.$refs.root.getBoundingClientRect()}},created(){this.init(),this.cssVars={"--transparent-pattern":"url("+dc+")"}},mounted(){this.$emit("mounted")},beforeUnmount(){this.pickEnd(),this.$emit("beforeUnmount")},watch:{modelValue(){let s=typeof this.modelValue=="object"?JSON.stringify(this.modelValue):this.modelValue,t=typeof this.output=="object"?JSON.stringify(this.output):this.output;s!==t&&(this.init(),this.active&&this.$nextTick(function(){this.$refs.picker.init()}))},disabled(){this.pickEnd()},processedDisableAlpha(s){s&&(this.color.setAlpha(1),this.emitUpdate()),this.active&&this.$nextTick(function(){this.$refs.picker.init()})},format(){this.emitUpdate()}}});const hc={class:"inner transparent"};function pc(s,t,o,r,i,n){const m=I("color-picker");return c(),d("div",{class:"color-input user",ref:"root",style:C(s.cssVars)},[e("div",{class:y(["box",{active:s.active,disabled:s.disabled}]),onClick:t[0]||(t[0]=k((...u)=>s.pickStart&&s.pickStart(...u),["stop"])),ref:"box"},[e("div",hc,[e("div",{class:"color",style:C(s.boxColorStyles)},null,4)])],2),x(st,{name:s.transition},{default:G(()=>[p(x(m,{class:"picker-popup",color:this.color,position:s.processedPosition,"disable-alpha":s.processedDisableAlpha,boxRect:s.boxRect,"disable-text-inputs":s.disableTextInputs,style:C({visibility:s.hidePicker?"hidden":""}),onReady:t[1]||(t[1]=u=>s.hidePicker=!1),onUpdateColor:s.emitUpdate,onHueInputStart:t[2]||(t[2]=u=>s.$emit("hueInputStart",u)),onHueInputEnd:t[3]||(t[3]=u=>s.$emit("hueInputEnd",u)),onHueInput:t[4]||(t[4]=u=>s.$emit("hueInput",u)),onAlphaInputStart:t[5]||(t[5]=u=>s.$emit("alphaInputStart",u)),onAlphaInputEnd:t[6]||(t[6]=u=>s.$emit("alphaInputEnd",u)),onAlphaInput:t[7]||(t[7]=u=>s.$emit("alphaInput",u)),onSaturationInputStart:t[8]||(t[8]=u=>s.$emit("saturationInputStart",u)),onSaturationInputEnd:t[9]||(t[9]=u=>s.$emit("saturationInputEnd",u)),onSaturationInput:t[10]||(t[10]=u=>s.$emit("saturationInput",u)),onChange:t[11]||(t[11]=u=>s.$emit("change",u)),ref:"picker"},null,8,["color","position","disable-alpha","boxRect","disable-text-inputs","style","onUpdateColor"]),[[nt,s.active]])]),_:1},8,["name"])],4)}var mc=`.color-input .box .color, .color-input .box .transparent {
    114114  width: 100%;
    115115  height: 100%;
     
    168168.color-input .picker-popup-leave-active {
    169169  transition: transform 0.3s, opacity 0.3s;
    170 }`;Q(mc);$.render=pc;var fc=(()=>{const s=$;return s.install=t=>{t.component("ColorInput",s)},s})();const N=D;function U(){const s=["1050210rwFmDC","1634936KkrbOS","1064368XeFuKT","232316uiAPvD","420fPXMNB","2YkUgCB","5hEFsBz","mount","use","228899XngPdn","#my-easy-compta-settings-app","1883kXXjzt","291981QxLffg","1902HrignB"];return U=function(){return s},U()}(function(s,t){const o=D,r=s();for(;[];)try{if(-parseInt(o(218))/1+-parseInt(o(220))/2*(parseInt(o(213))/3)+parseInt(o(216))/4*(-parseInt(o(207))/5)+-parseInt(o(214))/6*(parseInt(o(212))/7)+parseInt(o(217))/8+parseInt(o(215))/9+-parseInt(o(219))/10*(-parseInt(o(210))/11)===t)break;r.push(r.shift())}catch{r.push(r.shift())}})(U,300064);const z=ot({render:()=>at(Sr)});function D(s,t){const o=U();return D=function(r,i){return r=r-207,o[r]},D(s,t)}z[N(209)](fc),z[N(208)](N(211));
     170}`;K(mc);$.render=pc;var fc=(()=>{const s=$;return s.install=t=>{t.component("ColorInput",s)},s})();const B=D;function U(){const s=["36492aElmoz","mount","173241bJOHkX","122RnAErw","1675835ykDWZa","7332768LACjcR","40115MBValX","11849625JVZjUD","236xMQRSw","#my-easy-compta-settings-app","2421810IEvdqH"];return U=function(){return s},U()}function D(s,t){const o=U();return D=function(r,i){return r=r-218,o[r]},D(s,t)}(function(s,t){const o=D,r=s();for(;[];)try{if(-parseInt(o(228))/1+parseInt(o(218))/2*(parseInt(o(226))/3)+-parseInt(o(223))/4*(-parseInt(o(221))/5)+-parseInt(o(225))/6+parseInt(o(219))/7+parseInt(o(220))/8+-parseInt(o(222))/9===t)break;r.push(r.shift())}catch{r.push(r.shift())}})(U,477861);const z=ot({render:()=>at(Sr)});z.use(fc),z[B(227)](B(224));
  • my-easy-compta/trunk/includes/Modules/PDFGenerator.php

    r3190628 r3233000  
    390390            'margin_header' => 10,
    391391            'margin_footer' => 10,
     392            'autoPageBreak' => true,
     393            'keep_table_proportions' => true,
    392394        ]);
    393395
     
    654656            $sub_total_discounted += $total_after_discount;
    655657
    656             $items_html .= '<tr>
     658            $items_html .= '<tr style="page-break-after: always;page-break-inside: avoid;">
    657659                <td width="10%" style="border: 0.2mm solid #ffffff; background-color: #F5F5F5; vertical-align: top;">' .
    658660            nl2br($item_ref) . '</td>
  • my-easy-compta/trunk/my-easy-compta.php

    r3198779 r3233000  
    33 * Plugin Name: myEasyCompta
    44 * Description: Streamline your financial management with myEasyCompta, an all-in-one accounting plugin. Effortlessly handle quotes, invoices, expenses, and more, all within a sleek, user-friendly interface. Perfect for freelancers and small businesses looking to simplify their accounting processes.
    5  * Version: 1.4.5
     5 * Version: 1.4.6
    66 * Author: MELIOZ.dev
    77 * Author URI: https://myeasycompta.com
     
    2222 *
    2323 * @package myEasyCompta
    24  * @since 1.4.5
     24 * @since 1.4.6
    2525 */
    2626
     
    3737     * @var string
    3838     */
    39     public $version = '1.4.5';
     39    public $version = '1.4.6';
    4040    private $version_migration_db = false;
    4141
  • my-easy-compta/trunk/readme.txt

    r3198779 r3233000  
    44Tested up to: 6.7.1
    55Requires PHP: 8.0
    6 Stable tag: 1.4.5
     6Stable tag: 1.4.6
    77License: GPLv2 or later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    7979
    8080== Changelog ==
     81
     82= 1.4.6 =
     83* Fix: disable invoice status change in invoice modification mode.
    8184
    8285= 1.4.5 =
Note: See TracChangeset for help on using the changeset viewer.