1"use strict";(self.webpackChunkeximio_client=self.webpackChunkeximio_client||[]).push([[920],{31880(e,t,a){a(9950);var n=a(1320),s=a(15769),o=a(69780),i=a(9213),l=a(21671),r=a(34075),c=a(16491),d=a(82053),u=a(45458),A=a(99063),h=a(95720),x=a(26821),m=a(12015),p=a(20517),g=a(361),y=a(59051),v=a.n(y),f=a(36392),j=a(44414);const b=e=>{if("EMAIL"===e.channel||"COLLECTION_EMAIL"===e.channel)switch(e.state){case"ENVIADO":return(0,j.jsx)(p.A,{style:{fontSize:16,color:f.J.pending,marginRight:5}});case"RECIBIDO":return(0,j.jsx)(p.A,{style:{fontSize:16,color:f.J.successful,marginRight:5}});case"LE\xcdDO":return(0,j.jsx)(x.A,{style:{fontSize:16,color:f.J.successful,marginRight:5}});case"RECHAZADO":return(0,j.jsx)(u.A,{style:{fontSize:16,color:f.J.alert,marginRight:5}});default:return null}else switch(e.state){case"ENVIADO":return(0,j.jsx)(A.A,{style:{fontSize:16,color:f.J.pending,marginRight:5}});case"RECIBIDO":return(0,j.jsx)(A.A,{style:{fontSize:16,color:f.J.successful,marginRight:5}});case"LE\xcdDO":return(0,j.jsx)(h.A,{style:{fontSize:16,color:f.J.successful,marginRight:5}});case"RECHAZADO":return(0,j.jsx)(A.A,{style:{fontSize:16,color:f.J.alert,marginRight:5}});default:return null}};a.d(t,["g",0,e=>{let t=e.events,a=e.showChannelColumn,u=void 0!==a&&a;const A=[...t].sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime());return(0,j.jsx)(n.A,{children:(0,j.jsxs)(s.A,{size:"small",children:[(0,j.jsx)(o.A,{children:(0,j.jsxs)(i.A,{style:{backgroundColor:"#F9FCF8"},children:[u&&(0,j.jsx)(l.A,{children:(0,j.jsx)("strong",{children:"Canal / Tipo"})}),(0,j.jsx)(l.A,{children:(0,j.jsx)("strong",{children:"Estado"})}),(0,j.jsx)(l.A,{children:(0,j.jsx)("strong",{children:"Destinatario"})}),(0,j.jsx)(l.A,{align:"right",children:(0,j.jsx)("strong",{children:"Fecha y Hora"})})]})}),(0,j.jsx)(r.A,{children:A.map((e,t)=>{return(0,j.jsxs)(i.A,{hover:!0,style:{verticalAlign:"top"},children:[u&&(0,j.jsx)(l.A,{children:(0,j.jsxs)(c.A,{style:{display:"flex",flexDirection:"column"},children:[(0,j.jsxs)(c.A,{style:{display:"flex",alignItems:"center"},children:[(a=e.channel,"EMAIL"===a||"COLLECTION_EMAIL"===a?(0,j.jsx)(m.A,{style:{fontSize:16,color:f.J.iconOlive,marginRight:5}}):(0,j.jsx)(g.A,{style:{fontSize:16,color:f.J.primary,marginRight:5}})),(0,j.jsx)(d.A,{variant:"body2",fontWeight:"bold",style:{color:f.J.GREEN_2,fontSize:"0.85rem"},children:"EMAIL"===e.channel||"COLLECTION_EMAIL"===e.channel?"Correo":"WhatsApp"})]}),e.typeLabel&&(0,j.jsx)(d.A,{variant:"caption",color:"text.secondary",style:{fontSize:"0.75rem",marginTop:2},children:e.typeLabel})]})}),(0,j.jsx)(l.A,{children:(0,j.jsxs)(c.A,{style:{display:"flex",alignItems:"center"},children:[b(e),(0,j.jsx)(d.A,{variant:"body2",fontWeight:"bold",style:{fontSize:"0.85rem"},children:e.state})]})}),(0,j.jsxs)(l.A,{style:{maxWidth:220},children:[(0,j.jsx)(d.A,{variant:"body2",style:{fontSize:"0.85rem",wordBreak:"break-all"},children:e.recipient}),e.details&&(0,j.jsx)(d.A,{variant:"caption",color:"text.secondary",style:{display:"block",fontSize:"0.75rem",marginTop:2,fontStyle:"italic"},children:e.details})]}),(0,j.jsx)(l.A,{align:"right",style:{whiteSpace:"nowrap"},children:(0,j.jsx)(d.A,{variant:"body2",style:{fontSize:"0.85rem"},children:v()(e.timestamp).format("DD/MM/YYYY hh:mm A")})})]},"".concat(e.id,"-").concat(t));var a})})]})})}])},96456(e,t,a){a.r(t);var n=a(89379),s=a(5544),o=a(9950),i=a(98061),l=a(32218),r=a(3480),c=a(59051),d=a.n(c),u=a(48555),A=a(46589),h=a(25277),x=a(16491),m=a(46639),p=a(48089),g=a(60899),y=a(50704),v=a(82053),f=a(18216),j=a(11966),b=a(84142),C=a(8145),E=a(25333),_=a(1320),S=a(2235),D=a(15769),z=a(69780),I=a(9213),O=a(21671),N=a(34075),k=a(25979),M=a(19647),P=a(70006),R=a(23266),w=a(96583),T=a(40033),W=a(28170),L=a(79739),B=a(93038),V=a(4983),F=a(42209),H=a(78287),G=a(55858),Y=a(76283),U=a(20888),J=a(50495),$=a(77995),q=a(31451),Z=a(42917),K=a(58672),X=a(19223),Q=a(91602),ee=a(8104),te=a(79629),ae=a(31880),ne=a(36392),se=a(44414);const oe=["PENDIENTE","POR_VENCER","VENCIDA","PAGADA","PAGO_CONFIRMADO_CLIENTE","PAGO_VALIDADO_USUARIO","CANCELADA"],ie=()=>{var e,t,a,c,ie,le,re,ce,de,ue,Ae,he;const xe=(0,A.A)("(max-width:768px)"),me=(0,i.d4)(e=>e.config),pe=(0,i.d4)(e=>e.companiesInfo),ge=(0,o.useMemo)(()=>Array.isArray(pe)?pe:[],[pe]),ye=me.workspace,ve=ge.find(e=>String(e.ruc)===String(me.workspace)),fe=!!me.isSuperAdmin,je=ve&&(ve.has_active_contract||ve.active_plan_id||ve.active_plan_code),be=!fe&&!je&&(!ve||!ve.user_sol||""===ve.user_sol.trim()),Ce=(0,o.useState)(0),Ee=(0,s.A)(Ce,2),_e=Ee[0],Se=Ee[1],De=(0,o.useState)(!0),ze=(0,s.A)(De,2),Ie=ze[0],Oe=ze[1],Ne=(0,o.useState)(null),ke=(0,s.A)(Ne,2),Me=ke[0],Pe=ke[1],Re=(0,o.useState)([]),we=(0,s.A)(Re,2),Te=we[0],We=we[1],Le=(0,o.useState)(1),Be=(0,s.A)(Le,2),Ve=Be[0],Fe=Be[1],He=(0,o.useState)(!1),Ge=(0,s.A)(He,2),Ye=Ge[0],Ue=Ge[1],Je=(0,o.useState)(null),$e=(0,s.A)(Je,2),qe=$e[0],Ze=$e[1],Ke=(0,o.useState)("vencimiento"),Xe=(0,s.A)(Ke,2),Qe=Xe[0],et=Xe[1],tt=(0,o.useState)("asc"),at=(0,s.A)(tt,2),nt=at[0],st=at[1],ot=(0,o.useState)(""),it=(0,s.A)(ot,2),lt=it[0],rt=it[1],ct=(0,o.useState)([]),dt=(0,s.A)(ct,2),ut=dt[0],At=dt[1],ht=(0,o.useState)({PENDIENTE:"",POR_VENCER:"",VENCIDA:"",PAGADA:"",PAGO_CONFIRMADO_CLIENTE:"",PAGO_VALIDADO_USUARIO:"",CANCELADA:""}),xt=(0,s.A)(ht,2),mt=xt[0],pt=xt[1],gt=(0,o.useState)(3),yt=(0,s.A)(gt,2),vt=yt[0],ft=yt[1],jt=(0,o.useState)("BOTH"),bt=(0,s.A)(jt,2),Ct=bt[0],Et=bt[1],_t=(0,o.useState)("08:00"),St=(0,s.A)(_t,2),Dt=St[0],zt=St[1],It=(0,o.useState)("18:00"),Ot=(0,s.A)(It,2),Nt=Ot[0],kt=Ot[1],Mt=(0,o.useState)(3),Pt=(0,s.A)(Mt,2),Rt=Pt[0],wt=Pt[1],Tt=(0,o.useState)("1, 3, 5"),Wt=(0,s.A)(Tt,2),Lt=Wt[0],Bt=Wt[1],Vt=(0,o.useState)(!1),Ft=(0,s.A)(Vt,2),Ht=Ft[0],Gt=Ft[1],Yt=(0,o.useState)([]),Ut=(0,s.A)(Yt,2),Jt=Ut[0],$t=Ut[1],qt=(0,o.useState)(1),Zt=(0,s.A)(qt,2),Kt=Zt[0],Xt=Zt[1],Qt=(0,o.useState)(1),ea=(0,s.A)(Qt,2),ta=ea[0],aa=ea[1],na=(0,o.useState)(0),sa=(0,s.A)(na,2),oa=sa[0],ia=sa[1],la=(0,o.useState)(""),ra=(0,s.A)(la,2),ca=ra[0],da=ra[1],ua=(0,o.useState)({}),Aa=(0,s.A)(ua,2),ha=Aa[0],xa=Aa[1],ma=(0,o.useState)(!1),pa=(0,s.A)(ma,2),ga=pa[0],ya=pa[1],va=(0,o.useState)(!1),fa=(0,s.A)(va,2),ja=fa[0],ba=fa[1],Ca=(0,o.useState)(null),Ea=(0,s.A)(Ca,2),_a=Ea[0],Sa=Ea[1],Da=(0,o.useState)(null),za=(0,s.A)(Da,2),Ia=za[0],Oa=za[1],Na=(0,o.useState)(!1),ka=(0,s.A)(Na,2),Ma=ka[0],Pa=ka[1],Ra=ge.find(e=>e.ruc===ye)||{legal_name:"Mi Empresa"},wa=(0,o.useState)(!1),Ta=(0,s.A)(wa,2),Wa=Ta[0],La=Ta[1],Ba=(0,o.useState)(null),Va=(0,s.A)(Ba,2),Fa=Va[0],Ha=Va[1],Ga=(0,o.useState)(""),Ya=(0,s.A)(Ga,2),Ua=Ya[0],Ja=Ya[1],$a=(0,o.useState)(""),qa=(0,s.A)($a,2),Za=qa[0],Ka=qa[1],Xa=(0,o.useState)("PAGADA"),Qa=(0,s.A)(Xa,2),en=Qa[0],tn=Qa[1],an=(0,o.useState)(!1),nn=(0,s.A)(an,2),sn=nn[0],on=nn[1],ln=(0,o.useState)(null),rn=(0,s.A)(ln,2),cn=rn[0],dn=rn[1],un=(0,o.useState)(""),An=(0,s.A)(un,2),hn=An[0],xn=An[1],mn=(0,o.useMemo)(()=>null===ge||void 0===ge?void 0:ge.find(e=>e.ruc===ye),[ge,ye]),pn=(0,o.useMemo)(()=>{var e;
1const t=null===mn||void 0===mn||null===(e=mn.company_setting)||void 0===e?void 0:e.bank_accounts;if(!t)return[];try{return"string"===typeof t?JSON.parse(t):t}catch(a){return[]}},[mn]),gn=e=>{Ha(e),Ja(""),Ka(""),tn("PAGADA"),La(!0)},yn=e=>{dn(e),xn(e.status),on(!0)},vn=(0,o.useState)(!1),fn=(0,s.A)(vn,2),jn=fn[0],bn=fn[1],Cn=(0,o.useState)(null),En=(0,s.A)(Cn,2),_n=En[0],Sn=En[1],Dn=e=>{Sn(e),bn(!0)},zn=e=>{Qe===e?st(e=>"asc"===e?"desc":"asc"):(et(e),st("asc")),Fe(1)},In=(0,o.useMemo)(()=>{if(!Te)return[];const e=lt.trim().toLowerCase();return e?Te.filter(t=>{var a,n,s;const o="".concat((null===(a=t.document)||void 0===a?void 0:a.serie)||"","-").concat((null===(n=t.document)||void 0===n?void 0:n.number)||"").toLowerCase(),i=((null===(s=t.client)||void 0===s?void 0:s.legal_name)||"").toLowerCase();return o.includes(e)||i.includes(e)}):Te},[Te,lt]),On=(0,o.useMemo)(()=>{const e=[...In];return e.sort((e,t)=>{var a,n,s,o,i,l;let r,c;switch(Qe){case"factura":r="".concat((null===(a=e.document)||void 0===a?void 0:a.serie)||"","-").concat((null===(n=e.document)||void 0===n?void 0:n.number)||""),c="".concat((null===(s=t.document)||void 0===s?void 0:s.serie)||"","-").concat((null===(o=t.document)||void 0===o?void 0:o.number)||"");break;case"cliente":r=(null===(i=e.client)||void 0===i?void 0:i.legal_name)||"",c=(null===(l=t.client)||void 0===l?void 0:l.legal_name)||"";break;case"monto":r=Number(e.total_amount||0),c=Number(t.total_amount||0);break;case"vencimiento":default:r=e.due_date||"",c=t.due_date||"";break;case"estado":r=e.status||"",c=t.status||"";break;case"recordatorios":r=Number(e.reminders_sent||0),c=Number(t.reminders_sent||0)}return"string"===typeof r?(r=r.toLowerCase(),c=c.toLowerCase(),r<c?"asc"===nt?-1:1:r>c?"asc"===nt?1:-1:0):"asc"===nt?r-c:c-r}),e},[In,Qe,nt]),Nn=Math.ceil(On.length/10),kn=(0,o.useMemo)(()=>{const e=10*(Ve-1);return On.slice(e,e+10)},[On,Ve]),Mn=(0,o.useCallback)(async e=>{if(!ye)return;Oe(!0);const t=!e||e.current;try{var a;const e=await l.A.get("/api/v1/companies/".concat(ye,"/collection/config"));if(!t)return;if(null!==(a=e.data)&&void 0!==a&&a.result){var n;const a=e.data.config;Pe(a),ft(a.max_reminders_per_invoice),Et(a.allowed_channels),zt(a.allowed_time_range_start),kt(a.allowed_time_range_end),wt(a.days_before_due_date),Array.isArray(a.days_after_due_date)&&Bt(a.days_after_due_date.join(", "));let r=[];try{var s;const e=await l.A.get("/api/infobip/waba/templates/".concat(ye));t&&null!==(s=e.data)&&void 0!==s&&s.result&&(r=e.data.templates.filter(e=>"1"===e.state&&(!e.use_case||""===String(e.use_case).trim())))}catch(d){console.error("Failed to load standard waba templates, will fallback to collection-specific endpoint",d)}const c=await l.A.get("/api/v1/companies/".concat(ye,"/collection/templates"));if(t&&null!==(n=c.data)&&void 0!==n&&n.result){Array.isArray(c.data.availableTemplates)?At(c.data.availableTemplates):At(r);const e=c.data.templates,t={PENDIENTE:"",POR_VENCER:"",VENCIDA:"",PAGADA:"",PAGO_CONFIRMADO_CLIENTE:"",PAGO_VALIDADO_USUARIO:"",CANCELADA:""};e.forEach(e=>{"WHATSAPP"===e.channel&&e.collection_state&&oe.includes(e.collection_state)&&(t[e.collection_state]=e.waba_template_id||"")}),pt(t)}if(a.is_active){var o;const e=await l.A.get("/api/v1/collection/invoices?ruc=".concat(ye,"&page=1&limit=5000"));if(!t)return;null!==(o=e.data)&&void 0!==o&&o.result&&We(e.data.invoices)}try{var i;const e=await l.A.get("/api/v1/collection/usage?ruc=".concat(ye));t&&null!==(i=e.data)&&void 0!==i&&i.result&&Oa(e.data)}catch(u){console.error("Failed to load collection usage metrics",u)}}}catch(A){var c;if(!t)return;console.error("Failed to load collection data",A),r.toast.error("Error al cargar los datos de cobranzas: "+((null===(c=A.response)||void 0===c||null===(c=c.data)||void 0===c?void 0:c.msg)||A.message))}finally{t&&Oe(!1)}},[ye]);(0,o.useEffect)(()=>{const e={current:!0};return Mn(e),()=>{e.current=!1}},[Mn]);const Pn=async()=>{try{var e;Oe(!0);null!==(e=(await l.A.put("/api/v1/companies/".concat(ye,"/collection/config"),{is_active:!0,max_reminders_per_invoice:vt,allowed_channels:Ct,allowed_time_range_start:Dt,allowed_time_range_end:Nt,days_before_due_date:Rt,days_after_due_date:Lt.split(",").map(e=>Number(e.trim())).filter(e=>!isNaN(e))})).data)&&void 0!==e&&e.result&&(r.toast.success("\xa1Cobranza aut\xf3noma activada exitosamente!"),Mn())}catch(a){var t;r.toast.error("Error al activar cobranza: "+((null===(t=a.response)||void 0===t||null===(t=t.data)||void 0===t?void 0:t.msg)||a.message)),Oe(!1)}},Rn=async()=>{Pa(!0);try{var e;const t=await l.A.post("/api/v1/collection/request-private-number",{ruc:ye});null!==(e=t.data)&&void 0!==e&&e.result&&r.toast.success(t.data.msg||"Solicitud enviada correctamente.")}catch(a){var t;r.toast.error("Error al enviar la solicitud: "+((null===(t=a.response)||void 0===t||null===(t=t.data)||void 0===t?void 0:t.msg)||a.message))}finally{Pa(!1)}},wn=(0,o.useState)(!1),Tn=(0,s.A)(wn,2),Wn=Tn[0],Ln=Tn[1],Bn=(0,o.useState)(null),Vn=(0,s.A)(Bn,2),Fn=Vn[0],Hn=Vn[1],Gn=(0,o.useState)([]),Yn=(0,s.A)(Gn,2),Un=Yn[0],Jn=Yn[1],$n=(0,o.useState)(!1),qn=(0,s.A)($n,2),Zn=qn[0],Kn=qn[1];if(be)return(0,se.jsxs)("div",{style:{height:"100%",position:"relative"},children:[(0,se.jsx)(ee.A,{}),(0,se.jsx)(u.N,{moduleName:"Cobranzas"})]});const Xn=async e=>{Ln(!0),Kn(!0),Hn(e);try{var t;const a=await l.A.get("/api/v1/collection/invoices/".concat(e.id,"/history"));null!==(t=a.data)&&void 0!==t&&t.result&&Jn(a.data.history||[])}catch(n){var a;r.toast.error("Error al cargar historial: "+((null===(a=n.response)||void 0===a||null===(a=a.data)||void 0===a?void 0:a.msg)||n.message))}finally{Kn(!1)}},Qn=async(e,t)=>{try{var a;const n=t?"PAGADA":"PENDIENTE";null!==(a=(await l.A.patch("/api/v1/collection/invoices/".concat(e,"/status"),{status:n})).data)&&void 0!==a&&a.result&&(r.toast.success(t?"Pago validado correctamente.":"Factura devuelta a estado pendiente."),Mn())}catch(s){var n;r.toast.error("Error al actualizar estado de pago: "+((null===(n=s.response)||void 0===n||null===(n=n.data)||void 0===n?void 0:n.msg)||s.message))}},es=async e=>{Sa(e);try{var t;const a=await l.A.post("/api/v1/collection/invoices/".concat(e,"/send-manual-notification"));null!==(t=a.data)&&void 0!==t&&t.result&&(r.toast.success(a.data.msg||"Notificaci\xf3n manual enviada con \xe9xito."),Mn())}catch(n){var a;r.toast.error("Error al enviar notificaci\xf3n manual: "+((null===(a=n.response)||void 0===a||null===(a=a.data)||void 0===a?void 0:a.msg)||n.message))}finally{Sa(null)}},ts=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(ye){ba(!0);try{var a;const n=await l.A.get("/api/v1/companies/".concat(ye,"/collection/eligible-invoices?page=").concat(e,"&limit=5&search=").concat(encodeURIComponent(t)));null!==(a=n.data)&&void 0!==a&&a.result&&($t(n.data.documents||[]),aa(n.data.pages||1),ia(n.data.total||0),Xt(e))}catch(n){console.error("Failed to load eligible invoices",n),r.toast.error("Error al cargar comprobantes elegibles")}
1finally{ba(!1)}}},as=e=>{xa(t=>(0,n.A)((0,n.A)({},t),{},{[e]:!t[e]}))},ns=e=>{let t="default",a=e;switch(e){case"PENDIENTE":t="info",a="PENDIENTE";break;case"POR_VENCER":t="warning",a="POR VENCER";break;case"VENCIDA":t="error",a="VENCIDA";break;case"PAGADA":t="success",a="PAGADA";break;case"PAGO_CONFIRMADO_CLIENTE":t="secondary",a="PAGO CONFIRMADO CLIENTE";break;case"PAGO_VALIDADO_USUARIO":t="success",a="PAGO VALIDADO";break;case"CANCELADA":t="default",a="CANCELADA"}return(0,se.jsx)(h.A,{label:a,color:t,size:"small",style:{fontWeight:"bold"}})};return Ie&&!Me?(0,se.jsx)(x.A,{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh"},children:(0,se.jsx)(m.A,{color:"success"})}):Me&&!Me.is_active?(0,se.jsxs)("div",{style:{height:"100%",minHeight:"100vh",backgroundColor:"#f9fcf8"},children:[(0,se.jsx)(ee.A,{}),(0,se.jsx)(x.A,{style:{maxWidth:850,margin:"60px auto",padding:"0 20px"},children:(0,se.jsxs)(p.A,{style:{padding:"40px 30px",textAlign:"center",borderRadius:16,boxShadow:"0 8px 30px rgba(103,155,96,0.08)"},children:[(0,se.jsx)(x.A,{style:{display:"flex",justifyContent:"center",marginBottom:20},children:(0,se.jsx)(Z.A,{style:{fontSize:80,color:"#679B60"}})}),(0,se.jsx)(te.A,{bold:700,type:"h1",color:"#2E4F29",margin:"0 0 10px 0",children:"\xa1Recupera tu dinero un 65% m\xe1s r\xe1pido de forma 100% Aut\xf3noma!"}),(0,se.jsx)(te.A,{bold:500,type:"h3",color:"#555",margin:"0 0 30px 0",children:"T\xfa solo emite tus facturas como siempre. Ratifika detectar\xe1 de forma inteligente las ventas al cr\xe9dito y programar\xe1 alertas automatizadas por WhatsApp y Correo para asegurar tus pagos a tiempo."}),(0,se.jsxs)(g.Ay,{container:!0,spacing:3,style:{marginBottom:35,textAlign:"left"},children:[(0,se.jsx)(g.Ay,{item:!0,xs:12,md:4,children:(0,se.jsx)(p.A,{variant:"outlined",style:{height:"100%",borderRadius:12,backgroundColor:"white"},children:(0,se.jsxs)(y.A,{children:[(0,se.jsxs)(x.A,{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10},children:[(0,se.jsx)(J.A,{style:{color:"#679B60"}}),(0,se.jsx)(v.A,{variant:"subtitle1",fontWeight:"bold",children:"Recordatorios"})]}),(0,se.jsx)(v.A,{variant:"body2",color:"text.secondary",style:{fontSize:"0.85rem",lineHeight:1.5},children:"Symmetrical alerts are dispatched in sequence based on due dates. Plus, send manual triggers with 1-click on-demand."})]})})}),(0,se.jsx)(g.Ay,{item:!0,xs:12,md:4,children:(0,se.jsx)(p.A,{variant:"outlined",style:{height:"100%",borderRadius:12,backgroundColor:"white"},children:(0,se.jsxs)(y.A,{children:[(0,se.jsxs)(x.A,{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10},children:[(0,se.jsx)($.A,{style:{color:"#679B60"}}),(0,se.jsx)(v.A,{variant:"subtitle1",fontWeight:"bold",children:"Pausas Inteligentes"})]}),(0,se.jsx)(v.A,{variant:"body2",color:"text.secondary",style:{fontSize:"0.85rem",lineHeight:1.5},children:"If a debtor replies with a payment confirmation, alerts pause instantly to prevent awkward or redundant messaging."})]})})}),(0,se.jsx)(g.Ay,{item:!0,xs:12,md:4,children:(0,se.jsx)(p.A,{variant:"outlined",style:{height:"100%",borderRadius:12,backgroundColor:"white"},children:(0,se.jsxs)(y.A,{children:[(0,se.jsxs)(x.A,{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10},children:[(0,se.jsx)(Y.A,{style:{color:"#679B60"}}),(0,se.jsx)(v.A,{variant:"subtitle1",fontWeight:"bold",children:"Tasa de Recuperaci\xf3n"})]}),(0,se.jsx)(v.A,{variant:"body2",color:"text.secondary",style:{fontSize:"0.85rem",lineHeight:1.5},children:"Monitor your exact recovery rate, DSO average payment days, and detailed KPIs for a perfect collection tracking."})]})})})]}),(0,se.jsxs)(x.A,{style:{background:"linear-gradient(135deg, #fdfbf7 0%, #f1f6f0 100%)",border:"2px dashed #679B60",borderRadius:16,padding:"24px 20px",marginBottom:30,textAlign:"left"},children:[(0,se.jsx)(te.A,{bold:700,type:"h2",color:"#2E4F29",margin:"0 0 10px 0",children:"\ud83c\udf81 \xa1Regalo de Bienvenida: 10 Mensajes Gratis de Prueba!"}),(0,se.jsxs)(v.A,{variant:"body2",color:"text.secondary",style:{lineHeight:1.6,fontSize:"0.9rem"},children:["Activa el servicio sin ning\xfan compromiso y disfruta de ",(0,se.jsx)("strong",{children:"10 notificaciones por WhatsApp completamente GRATIS"})," durante tu primer mes con el canal compartido de Ratifika.",(0,se.jsx)("br",{}),"A partir del mensaje 11, se pasar\xe1 al plan de pago mensual a solo ",(0,se.jsx)("strong",{children:"S/ 0.2561 + IGV"}
1)," por mensaje adicional enviado con \xe9xito (sujeto a cambios en las pol\xedticas de Meta o fluctuaciones cambiarias)."]})]}),(0,se.jsxs)(x.A,{style:{backgroundColor:"#fff",border:"1px solid #e5e7eb",borderRadius:16,padding:"20px",marginBottom:35,textAlign:"left",display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:16},children:[(0,se.jsxs)(x.A,{style:{flex:"1 1 450px"},children:[(0,se.jsx)(te.A,{bold:600,type:"h3",color:"#2E4F29",margin:"0 0 6px 0",children:"\xbfPrefieres usar tu propio n\xfamero telef\xf3nico corporativo?"}),(0,se.jsx)(v.A,{variant:"body2",color:"text.secondary",style:{fontSize:"0.85rem"},children:"Aumenta la confianza de tus clientes enviando todos los recordatorios autom\xe1ticos bajo tu propio branding e identidad comercial. (Aplica cargo extra por integraci\xf3n t\xe9cnica)."})]}),(0,se.jsx)(f.A,{variant:"outlined",color:"success",onClick:Rn,disabled:Ma,style:{borderRadius:20,textTransform:"none",fontWeight:"bold"},children:Ma?"Enviando solicitud...":"Solicitar N\xfamero Propio"})]}),(0,se.jsx)(f.A,{variant:"contained",size:"large",onClick:Pn,style:{backgroundColor:"#679B60",color:"white",padding:"14px 48px",borderRadius:30,fontSize:16,fontWeight:"bold",boxShadow:"0 4px 15px rgba(103,155,96,0.3)"},children:"Activar M\xf3dulo Gratis de Bienvenida"})]})})]}):(0,se.jsxs)("div",{style:{minHeight:"100vh",backgroundColor:"#f9fcf8",paddingBottom:60},children:[(0,se.jsx)(ee.A,{}),(0,se.jsxs)(x.A,{style:{maxWidth:"100%",margin:"40px auto",padding:"0 40px"},children:[(0,se.jsx)(x.A,{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:30},children:(0,se.jsxs)(x.A,{style:{display:"flex",alignItems:"center",gap:10},children:[(0,se.jsx)(v.A,{color:"text.secondary",variant:"body2",children:Ra.legal_name}),(0,se.jsx)(h.A,{label:"Cobranza Activa",color:"success",style:{fontWeight:"bold"}})]})}),(0,se.jsx)(x.A,{style:{borderBottom:1,borderColor:"divider",marginBottom:20},children:(0,se.jsxs)(j.A,{value:_e,onChange:(e,t)=>
1Se(t),color:"success",children:[(0,se.jsx)(b.A,{label:"Facturas de Cr\xe9dito",icon:(0,se.jsx)(Y.A,{}),iconPosition:"start"}),(0,se.jsx)(b.A,{label:"Configurar Recordatorios",icon:(0,se.jsx)(G.A,{}),iconPosition:"start"})]})}),0===_e&&(0,se.jsx)(g.Ay,{container:!0,spacing:3,children:(0,se.jsxs)(g.Ay,{item:!0,xs:12,children:[(0,se.jsxs)(x.A,{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:15,gap:16,flexWrap:"wrap"},children:[(0,se.jsx)(f.A,{variant:"outlined",color:"success",startIcon:(0,se.jsx)(K.A,{}),onClick:()=>{Gt(!0),xa({}),da(""),ts(1,"")},style:{borderRadius:20,textTransform:"none",fontWeight:"bold",whiteSpace:"nowrap"},children:"Importar Comprobantes Anteriores"}),(0,se.jsxs)(x.A,{style:{display:"flex",gap:12,flex:1,justifyContent:"flex-end",maxWidth:600},children:[(0,se.jsx)(C.A,{size:"small",placeholder:"Buscar por factura o cliente...",value:lt,onChange:e=>{rt(e.target.value),Fe(1)},InputProps:{startAdornment:(0,se.jsx)(X.A,{style:{color:"#aaa",marginRight:5,fontSize:20}})},style:{minWidth:250,backgroundColor:"#fff",borderRadius:4}}),(0,se.jsx)(f.A,{variant:"outlined",color:"primary",onClick:()=>{if(0===Te.length)return void r.toast.warn("No hay datos de cobranza para exportar.");const e=Te.map(e=>['"'.concat(e.document.serie,"-").concat(e.document.number,'"'),'"'.concat(e.client.legal_name.replace(/"/g,'""'),'"'),d().utc(e.document.issue_date).utcOffset(-5).format("YYYY-MM-DD"),e.due_date,Number(e.total_amount).toFixed(2),Number(e.pending_amount).toFixed(2),e.status,e.reminders_sent,'"'.concat(e.bank_account||"",'"'),'"'.concat(e.transaction_number||"",'"'),e.reconciled_at?d()(e.reconciled_at).format("YYYY-MM-DD HH:mm:ss"):""]),t=[["Factura/Boleta","Cliente","Fecha de Emision","Fecha de Vencimiento","Monto Total","Monto Pendiente","Estado de Cobranza","Recordatorios Enviados","Cuenta de Conciliacion","Nro. Operacion Bancaria","Fecha de Conciliacion"].join(";"),...e.map(e=>e.join(";"))].join("\n"),a=new Blob(["\ufeff"+t],{type:"text/csv;charset=utf-8;"}),n=URL.createObjectURL(a),s=document.createElement("a");s.setAttribute("href",n),s.setAttribute("download","Reporte_Cobranzas_Conciliacion_".concat(d()().format("YYYYMMDD_HHmmss"),".csv")),document.body.appendChild(s),s.click(),document.body.removeChild(s)},style:{borderRadius:20,textTransform:"none",fontWeight:"bold",whiteSpace:"nowrap"},children:"Exportar a Excel"})]})]}),xe?(0,se.jsx)(g.Ay,{container:!0,spacing:2,children:0===kn.length?(0,se.jsx)(g.Ay,{item:!0,xs:12,children:(0,se.jsx)(p.A,{variant:"outlined",style:{borderRadius:12,border:"1px solid rgba(0,0,0,0.08)",padding:"40px 0",textAlign:"center"},children:(0,se.jsxs)(y.A,{children:[(0,se.jsx)(U.A,{style:{fontSize:40,color:"#aaa"}}),(0,se.jsx)(v.A,{variant:"body2",color:"text.secondary",style:{marginTop:10},children:"No hay facturas de cr\xe9dito registradas para cobranza."})]})})}):kn.map(e=>{const t="PAGO_CONFIRMADO_CLIENTE"===e.status;return(0,se.jsx)(g.Ay,{item:!0,xs:12,children:(0,se.jsx)(p.A,{variant:"outlined",style:{borderRadius:12,border:"1px solid rgba(0,0,0,0.08)",backgroundColor:t?"#fdfbf2":"var(--color-bg-surface, #fff)",borderLeft:t?"4px solid #f57c00":"1px solid rgba(0,0,0,0.08)"},children:(0,se.jsxs)(y.A,{style:{padding:"16px"},children:[(0,se.jsxs)(x.A,{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:1.5,flexWrap:"wrap",gap:1,children:[(0,se.jsxs)(x.A,{children:[(0,se.jsxs)(v.A,{variant:"body1",fontWeight:"bold",style:{color:"var(--color-text-primary, #334155)"},children:[e.document.serie,"-",e.document.number]}),(0,se.jsxs)(v.A,{variant:"caption",color:"text.secondary",children:["Emitida: ",d().utc(e.document.issue_date).utcOffset(-5).format("YYYY-MM-DD")]})]}),ns(e.status)]}),(0,se.jsxs)(x.A,{display:"flex",flexDirection:"column",gap:1,mb:2,children:[(0,se.jsxs)(x.A,{display:"flex",justifyContent:"space-between",children:[(0,se.jsx)(v.A,{variant:"caption",style:{color:"text.secondary",fontWeight:"bold"},children:"Cliente:"}),(0,se.jsx)(v.A,{variant:"caption",align:"right",style:{color:"var(--color-text-primary, #475569)",maxWidth:"70%"},children:e.client.legal_name})]}),(0,se.jsxs)(x.A,{display:"flex",justifyContent:"space-between",children:[(0,se.jsx)(v.A,{variant:"caption",style:{color:"text.secondary",fontWeight:"bold"},children:"Monto Total:"}),(0,se.jsxs)(v.A,{variant:"caption",fontWeight:"bold",style:{color:ne.J.GREEN},children:["USD"===e.document.currency?"$":"S/"," ",Number(e.total_amount).toFixed(2)]})]}),(0,se.jsxs)(x.A,{display:"flex",justifyContent:"space-between",children:[(0,se.jsx)(v.A,{variant:"caption",style:{color:"text.secondary",fontWeight:"bold"},children:"F. Venc.:"}),(0,se.jsx)(v.A,{variant:"caption",style:{color:"var(--color-text-primary, #475569)"},children:e.due_date})]}),(0,se.jsxs)(x.A,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[(0,se.jsx)(v.A,{variant:"caption",style:{color:"text.secondary",fontWeight:"bold"},children:"Recordatorios:"}),(0,se.jsxs)(x.A,{style:{display:"flex",alignItems:"center",gap:6},children:[(0,se.jsx)(v.A,{variant:"body2",fontWeight:"bold",children:e.reminders_sent}),e.reminders_sent>0&&(0,se.jsx)(E.A,{size:"small",color:"success",onClick:()=>Xn(e),title:"Ver historial de recordatorios",style:{padding:2},children:(0,se.jsx)(q.A,{fontSize:"small"})}),(0,se.jsx)(E.A,{size:"small",color:"primary",onClick:()=>Dn(e),title:"Ver programaci\xf3n de recordatorios",style:{padding:2},children:(0,se.jsx)(Q.A,{fontSize:"small"})})]})]})]}),(0,se.jsxs)(x.A,{display:"flex",justifyContent:"flex-end",gap:1,style:{borderTop:"1px solid rgba(0,0,0,0.05)",paddingTop:8},children:[t?(0,se.jsxs)(se.Fragment,{children:[(0,se.jsxs)(f.A,{size:"small",variant:"contained",color:"success",onClick:()=>gn(e),title:"Conciliar Pago Recibido",style:{padding:"4px 8px",minWidth:"auto"},children:[(0,se.jsx)(V.A,{fontSize:"small"})," Conciliar"]}),(0,se.jsxs)(f.A,{size:"small",variant:"outlined",color:"error",onClick:()=>Qn(e.id,!1),title:"Rechazar y Devolver a Pendiente",style:{padding:"4px 8px",minWidth:"auto"},children:[(0,se.jsx)(F.A,{fontSize:"small"})," Rechazar"]})]}):["PENDIENTE","POR_VENCER","VENCIDA"].includes(e.status)?(0,se.jsx)(E.A,{size:"small",color:"warning",onClick:()=>es(e.id),title:"Enviar Notificaci\xf3n Manual",disabled:_a===e.id,style:{padding:4},children:_a===e.id?(0,se.jsx)(m.A,{size:20,color:"inherit"}):(0,se.jsx)(Z.A,{fontSize:"small"})}):null,(0,se.jsx)(E.A,{size:"small",color:"info",onClick:()=>yn(e),title:"Modificar Estado Manualmente",style:{padding:4},children:(0,se.jsx)(G.A,{fontSize:"small"})})]})]})})},e.id)})}):(0,se.jsx)(_.A,{component:S.A,style:{borderRadius:12,boxShadow:"0 4px 20px rgba(0,0,0,0.02)"},children:(0,se.jsxs)(D.A,{children:[(0,se.jsx)(z.A,{style:{backgroundColor:"#f1f6f0"},children:(0,se.jsxs)(I.A,{children:[(0,se.jsxs)(O.A,{onClick:()=>zn("factura"),style:{cursor:"pointer",userSelect:"none",fontWeight:"bold"},children:["Factura ","factura"===Qe?"asc"===nt?" \u25b2":" \u25bc":""]}),(0,se.jsxs)(O.A,{onClick:()=>zn("cliente"),style:{cursor:"pointer",userSelect:"none",fontWeight:"bold"},children:["Cliente ","cliente"===Qe?"asc"===nt?" \u25b2":" \u25bc":""]}),(0,se.jsxs)(O.A,{onClick:()=>zn("monto"),style:{cursor:"pointer",userSelect:"none",fontWeight:"bold"},children:["Monto Total ","monto"===Qe?"asc"===nt?" \u25b2":" \u25bc":""]}),(0,se.jsxs)(O.A,{onClick:()=>zn("vencimiento"),style:{cursor:"pointer",userSelect:"none",fontWeight:"bold"},children:["F. Venc. ","vencimiento"===Qe?"asc"===nt?" \u25b2":" \u25bc":""]}),(0,se.jsxs)(O.A,{onClick:()=>zn("estado"),style:{cursor:"pointer",userSelect:"none",fontWeight:"bold"},children:["Estado ","estado"===Qe?"asc"===nt?" \u25b2":" \u25bc":""]}),(0,se.jsxs)(O.A,{onClick:()=>zn("recordatorios"),style:{cursor:"pointer",userSelect:"none",fontWeight:"bold"},align:"center",children:["Recordat. ","recordatorios"===Qe?"asc"===nt?" \u25b2":" \u25bc":""]}),(0,se.jsx)(O.A,{align:"center",children:(0,se.jsx)("strong",{children:"Acciones"})})]})}),(0,se.jsx)(N.A,{children:0===kn.length?(0,se.jsx)(I.A,{children:(0,se.jsxs)(O.A,{colSpan:7,align:"center",style:{padding:"40px 0"},children:[(0,se.jsx)(U.A,{style:{fontSize:40,color:"#aaa"}}),(0,se.jsx)(v.A,{variant:"body2",color:"text.secondary",style:{marginTop:10},children:"No hay facturas de cr\xe9dito registradas para cobranza."})]})}):kn.map(e=>{const t="PAGO_CONFIRMADO_CLIENTE"===e.status;return(0,se.jsxs)(I.A,{style:{backgroundColor:t?"#fdfbf2":"inherit",borderLeft:t?"4px solid #f57c00":"none"},children:[(0,se.jsxs)(O.A,{children:[(0,se.jsxs)(v.A,{variant:"body2",fontWeight:"bold",children:[e.document.serie,"-",e.document.number]}),(0,se.jsxs)(v.A,{variant:"caption",color:"text.secondary",children:["Emitida: ",d().utc(e.document.issue_date).utcOffset(-5).format("YYYY-MM-DD")]})]}),(0,se.jsx)(O.A,{children:e.client.legal_name}),(0,se.jsxs)(O.A,{children:["USD"===e.document.currency?"$":"S/"," ",Number(e.total_amount).toFixed(2)]}),(0,se.jsx)(O.A,{children:e.due_date}),(0,se.jsx)(O.A,{children:ns(e.status)}),(0,se.jsx)(O.A,{align:"center",children:(0,se.jsxs)(x.A,{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:[(0,se.jsx)(v.A,{variant:"body2",fontWeight:"bold",children:e.reminders_sent}),e.reminders_sent>0&&(0,se.jsx)(E.A,{size:"small",color:"success",onClick:()=>Xn(e),title:"Ver historial de recordatorios",style:{padding:2},children:(0,se.jsx)(q.A,{fontSize:"small"})}),(0,se.jsx)(E.A,{size:"small",color:"primary",onClick:()=>Dn(e),title:"Ver programaci\xf3n de recordatorios",style:{padding:2},children:(0,se.jsx)(Q.A,{fontSize:"small"})})]})}),(0,se.jsx)(O.A,{align:"center",children:(0,se.jsxs)(x.A,{style:{display:"flex",gap:6,justifyContent:"center",alignItems:"center"},children:[t?(0,se.jsxs)(se.Fragment,{children:[(0,se.jsx)(f.A,{size:"small",variant:"contained",color:"success",onClick:()=>gn(e),title:"Conciliar Pago Recibido",style:{padding:"4px 8px",minWidth:"auto"},children:(0,se.jsx)(V.A,{fontSize:"small"})}),(0,se.jsx)(f.A,{size:"small",variant:"outlined",color:"error",onClick:()=>Qn(e.id,!1),title:"Rechazar y Devolver a Pendiente",style:{padding:"4px 8px",minWidth:"auto"},children:(0,se.jsx)(F.A,{fontSize:"small"})})]}):["PENDIENTE","POR_VENCER","VENCIDA"].includes(e.status)?(0,se.jsx)(E.A,{size:"small",color:"warning",onClick:()=>es(e.id),title:"Enviar Notificaci\xf3n Manual",disabled:_a===e.id,style:{padding:4},children:_a===e.id?(0,se.jsx)(m.A,{size:20,color:"inherit"}):(0,se.jsx)(Z.A,{fontSize:"small"})}):null,(0,se.jsx)(E.A,{size:"small",color:"info",onClick:()=>yn(e),title:"Modificar Estado Manualmente",style:{padding:4},children:(0,se.jsx)(G.A,{fontSize:"small"})})]})})]},e.id)})})]})}),Nn>1&&(0,se.jsxs)(x.A,{style:{display:"flex",justifyContent:"center",marginTop:20,gap:10},children:[(0,se.jsx)(f.A,{variant:"outlined",disabled:1===Ve,onClick:()=>Fe(Ve-1),size:"small",children:"Anterior"}),(0,se.jsxs)(v.A,{style:{display:"flex",alignItems:"center"},children:["P\xe1gina ",Ve," de ",Nn]}),(0,se.jsx)(f.A,{variant:"outlined",disabled:Ve===Nn,onClick:()=>Fe(Ve+1),size:"small",children:"Siguiente"})]})]})}),1===_e&&(0,se.jsxs)(p.A,{style:{borderRadius:12,padding:20,boxSh
1adow:"0 4px 20px rgba(0,0,0,0.02)"},children:[(0,se.jsx)(te.A,{bold:700,type:"h2",color:"#2E4F29",margin:"0 0 20px 0",children:"Pol\xedticas de Cobranza y Plantillas de Env\xedo"}),(0,se.jsxs)(g.Ay,{container:!0,spacing:3,children:[(0,se.jsx)(g.Ay,{item:!0,xs:12,sm:6,children:(0,se.jsx)(C.A,{label:"Recordatorios m\xe1ximos por factura",type:"number",fullWidth:!0,value:vt,onChange:e=>ft(Number(e.target.value)),style:{marginBottom:20}})}),(0,se.jsx)(g.Ay,{item:!0,xs:12,sm:6,children:(0,se.jsxs)(k.A,{fullWidth:!0,style:{marginBottom:20},children:[(0,se.jsx)(M.A,{children:"Canales de env\xedo permitidos"}),(0,se.jsxs)(P.A,{value:Ct,onChange:e=>Et(e.target.value),label:"Canales de env\xedo permitidos",children:[(0,se.jsx)(R.A,{value:"WHATSAPP",children:"Solo WhatsApp (Infobip)"}),(0,se.jsx)(R.A,{value:"EMAIL",children:"Solo Correo Electr\xf3nico"}),(0,se.jsx)(R.A,{value:"BOTH",children:"Ambos Canales (WhatsApp y Email)"})]})]})}),(0,se.jsx)(g.Ay,{item:!0,xs:12,sm:6,children:(0,se.jsx)(C.A,{label:"Hora de inicio de env\xedo permitido",type:"time",fullWidth:!0,value:Dt,onChange:e=>zt(e.target.value),style:{marginBottom:20}})}),(0,se.jsx)(g.Ay,{item:!0,xs:12,sm:6,children:(0,se.jsx)(C.A,{label:"Hora de fin de env\xedo permitido",type:"time",fullWidth:!0,value:Nt,onChange:e=>kt(e.target.value),style:{marginBottom:20}})}),(0,se.jsx)(g.Ay,{item:!0,xs:12,sm:6,children:(0,se.jsx)(C.A,{label:"D\xedas de anticipaci\xf3n (Antes del vencimiento)",type:"number",fullWidth:!0,value:Rt,onChange:e=>wt(Number(e.target.value)),style:{marginBottom:20}})}),(0,se.jsx)(g.Ay,{item:!0,xs:12,sm:6,children:(0,se.jsx)(C.A,{label:"D\xedas posteriores al vencimiento (Separados por coma)",type:"text",fullWidth:!0,value:Lt,onChange:e=>Bt(e.target.value),placeholder:"Ej: 1, 3, 5",style:{marginBottom:20}})})]}),(0,se.jsx)(te.A,{bold:700,type:"h3",color:"#2E4F29",margin:"20px 0 15px 0",children:"Asociaci\xf3n de Plantillas de WhatsApp por Estado de Cobranza"}),(0,se.jsx)(g.Ay,{container:!0,spacing:3,style:{marginBottom:20},children:oe.map(e=>(0,se.jsx)(g.Ay,{item:!0,xs:12,sm:6,md:4,children:(0,se.jsxs)(k.A,{fullWidth:!0,style:{marginBottom:10},children:[(0,se.jsxs)(M.A,{style:{fontSize:"14px"},children:["Plantilla para ",e.replace(/_/g," ")]}),(0,se.jsxs)(x.A,{style:{display:"flex",gap:"8px",alignItems:"center"},children:[(0,se.jsxs)(P.A,{value:mt[e]||"",onChange:t=>((e,t)=>{pt(a=>(0,n.A)((0,n.A)({},a),{},{[e]:t}))})(e,t.target.value),label:"Plantilla para ".concat(e.replace(/_/g," ")),style:{fontSize:"13px",flex:1},children:[(0,se.jsx)(R.A,{value:"",children:"-- Ninguna --"}),0===ut.length?(0,se.jsx)(R.A,{disabled:!0,value:"",children:"No hay plantillas de WhatsApp activas"}):ut.map(e=>(0,se.jsx)(R.A,{value:e.id,style:{fontSize:"13px"},children:e.template_name},e.id))]}),(0,se.jsx)(f.A,{variant:"outlined",color:"secondary",disabled:!mt[e],onClick:()=>{const t=ut.find(t=>t.id===mt[e]);t&&(Ze(t),Ue(!0))},style:{minWidth:"40px",padding:"6px"},title:"Previsualizar plantilla seleccionada",children:(0,se.jsx)(H.A,{})})]})]})},e))}),(0,se.jsx)(x.A,{style:{display:"flex",gap:10,marginTop:20},children:(0,se.jsx)(f.A,{variant:"contained",onClick:async()=>{try{var e;const t=Lt.split(",").map(e=>Number(e.trim())).filter(e=>!isNaN(e));if(null!==(e=(await l.A.put("/api/v1/companies/".concat(ye,"/collection/config"),{is_active:!Me||Me.is_active,max_reminders_per_invoice:vt,allowed_channels:Ct,allowed_time_range_start:Dt,allowed_time_range_end:Nt,days_before_due_date:Rt,days_after_due_date:t})).data)&&void 0!==e&&e.result){const e=oe.map(async e=>{const t=mt[e];if(!t)return l.A.post("/api/v1/companies/".concat(ye,"/collection/templates"),{collection_state:e,channel:"WHATSAPP",waba_template_id:null,template_name:null,is_active:!1});{const a=ut.find(e=>e.id===Number(t));if(a)return l.A.post("/api/v1/companies/".concat(ye,"/collection/templates"),{collection_state:e,channel:"WHATSAPP",waba_template_id:a.id,template_name:a.template_name,is_active:!0})}});await Promise.all(e),r.toast.success("Configuraci\xf3n de recordatorios guardada correctamente"),Mn()}}catch(a){var t;r.toast.error("Error al guardar configuraci\xf3n: "+((null===(t=a.response)||void 0===t||null===(t=t.data)||void 0===t?void 0:t.msg)||a.message))}},style:{backgroundColor:"#679B60",color:"white"},children:"Guardar Configuraci\xf3n"})})]})]}),(0,se.jsx)(x.A,{children:Ia&&(0,se.jsxs)(x.A,{style:{backgroundColor:"white",border:"1px solid #e5e7eb",borderRadius:12,padding:"16px 20px",marginBottom:30,display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:16,boxShadow:"0 2px 10px rgba(0,0,0,0.01)"},children:[(0,se.jsxs)(x.A,{style:{display:"flex",alignItems:"center",gap:12},children:[(0,se.jsx)(Z.A,{style:{color:"#679B60"}}),(0,se.jsxs)(x.A,{children:[(0,se.jsx)(v.A,{variant:"subtitle2",fontWeight:"bold",color:"#2E4F29",children:"Consumo Mensual de Notificaciones (WhatsApp)"}),(0,se.jsxs)(v.A,{variant:"body2",color:"text.secondary",children:["Has utilizado ",(0,se.jsx)("strong",{children:Ia.usedThisMonth})," de tus ",(0,se.jsx)("strong",{children:Ia.freeLimit})," mensajes gratis de bienvenida de este mes.",Ia.usedThisMonth>
1Ia.freeLimit&&(0,se.jsxs)("span",{style:{color:"#d32f2f",fontWeight:"bold"},children:[" ","(Exceso de ",Ia.usedThisMonth-Ia.freeLimit," mensajes facturables en el pr\xf3ximo corte mensual)"]})]})]})]}),(0,se.jsxs)(x.A,{style:{textAlign:"right"},children:[(0,se.jsxs)(v.A,{variant:"caption",color:"text.secondary",style:{display:"block"},children:["Canal: ",(0,se.jsx)("strong",{children:"EXIMIO"===Ia.wabaMode?"N\xfamero Compartido Ratifika":"N\xfamero Propio Personalizado"})]}),(0,se.jsxs)(v.A,{variant:"caption",color:"text.secondary",style:{display:"block"},children:["Mensaje adicional: ",(0,se.jsxs)("strong",{children:["S/ ",Ia.unitPrice.toFixed(4)," + IGV"]})]}),"EXIMIO"===Ia.wabaMode&&(0,se.jsx)(f.A,{size:"small",variant:"text",color:"success",onClick:Rn,disabled:Ma,style:{textTransform:"none",fontWeight:"bold",padding:0},children:Ma?"Solicitando...":"Solicitar N\xfamero Propio Corporativo"})]})]})}),(0,se.jsxs)(w.A,{open:Ye,onClose:()=>Ue(!1),maxWidth:"xs",fullWidth:!0,children:[(0,se.jsx)(T.A,{style:{fontWeight:"bold",textAlign:"center"},children:"Previsualizaci\xf3n de Plantilla"}),(0,se.jsx)(W.A,{style:{backgroundColor:"#e5ddd5",padding:"20px 10px",minHeight:300},children:(0,se.jsx)(x.A,{style:{display:"flex",justifyContent:"flex-start",marginBottom:15},children:(0,se.jsxs)(x.A,{style:{backgroundColor:"white",borderRadius:"0px 15px 15px 15px",padding:12,maxWidth:"85%",boxShadow:"0 1px 1px rgba(0,0,0,0.1)",position:"relative"},children:[(0,se.jsxs)(v.A,{variant:"caption",style:{color:"#075e54",fontWeight:"bold",display:"block",marginBottom:4},children:["Plantilla: ",(null===qe||void 0===qe?void 0:qe.template_name)||"Desconocida"]}),(null===qe||void 0===qe?void 0:qe.header_content)&&(0,se.jsx)(v.A,{variant:"subtitle2",style:{fontWeight:"bold",color:"#111",display:"block",marginBottom:6},children:"string"===typeof qe.header_content?qe.header_content:qe.header_content.text||""}),(0,se.jsx)(v.A,{variant:"body2",style:{color:"#303030",lineHeight:1.4,whiteSpace:"pre-wrap"},children:null!==qe&&void 0!==qe&&qe.body_content?qe.body_content.replace(/\{\{1\}\}/g,Ra.legal_name||"EXIMIO S.A.C").replace(/\{\{2\}\}/g,"F001-0003421").replace(/\{\{3\}\}/g,"28/07/2026").replace(/\{\{4\}\}/g,"S/ 1,500.00").replace(/\{\{5\}\}/g,"Departamento de Cobranzas"):(0,se.jsxs)(se.Fragment,{children:["Estimado cliente de ",(0,se.jsx)("strong",{children:Ra.legal_name}),", le recordamos que su factura"," ",(0,se.jsx)("strong",{children:"F001-0000345"})," vence el ",(0,se.jsx)("strong",{children:"28/07/2026"})," por un total de"," ",(0,se.jsx)("strong",{children:"S/ 1,500.00 PEN"}),". Agradecemos su puntualidad. Atentamente, Departamento de Cobranzas."]})}),(null===qe||void 0===qe?void 0:qe.footer_content)&&(0,se.jsx)(v.A,{variant:"caption",style:{color:"#868686",display:"block",marginTop:6,fontSize:11},children:qe.footer_content}),(0,se.jsx)(x.A,{style:{display:"flex",justifyContent:"flex-end",marginTop:4},children:(0,se.jsx)(v.A,{variant:"caption",style:{color:"#868686",fontSize:9},children:"08:30 AM"})})]})})}),(0,se.jsx)(L.A,{children:(0,se.jsx)(f.A,{onClick:()=>Ue(!1),color:"success",style:{fontWeight:"bold"},children:"Entendido"})})]}),(0,se.jsxs)(w.A,{open:!1===Ye&&Ht,onClose:()=>Gt(!1),maxWidth:"md",fullWidth:!0,children:[(0,se.jsx)(T.A,{style:{fontWeight:"bold",color:"#2E4F29"},children:"Importar Comprobantes Anteriores a Cobranzas"}),(0,se.jsxs)(W.A,{style:{paddingTop:10},children:[(0,se.jsx)(v.A,{variant:"body2",color:"text.secondary",style:{marginBottom:20},children:"Selecciona las facturas y boletas de cr\xe9dito emitidas anteriormente que deseas agregar al flujo de cobranza autom\xe1tica. El sistema calcular\xe1 su estado inicial (VENCIDA, POR_VENCER o PENDIENTE) seg\xfan su fecha de vencimiento."}),(0,se.jsxs)(x.A,{style:{display:"flex",gap:10,marginBottom:20},children:[(0,se.jsx)(C.A,{size:"small",placeholder:"Buscar por serie-n\xfamero o Raz\xf3n Social del cliente...",fullWidth:!0,value:ca,onChange:e=>da(e.target.value),onKeyDown:e=>{"Enter"===e.key&&ts(1,ca)},InputProps:{endAdornment:(0,se.jsx)(E.A,{onClick:()=>ts(1,ca),size:"small",children:(0,se.jsx)(X.A,{})})}}),(0,se.jsx)(f.A,{variant:"contained",onClick:()=>ts(1,ca),style:{backgroundColor:"#679B60",color:"white",textTransform:"none",fontWeight:"bold"},children:"Buscar"})]}),ja?(0,se.jsx)(x.A,{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:(0,se.jsx)(m.A,{color:"success"})}):0===Jt.length?(0,se.jsxs)(x.A,{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"40px 0"},children:[(0,se.jsx)(U.A,{style:{fontSize:40,color:"#aaa"}}),(0,se.jsx)(v.A,{variant:"body2",color:"text.secondary",style:{marginTop:10},children:"No se encontraron comprobantes anteriores pendientes de importar."})]}):(0,se.jsxs)(se.Fragment,{children:[(0,se.jsx)(_.A,{component:S.A,variant:"outlined",style:{borderRadius:8,boxShadow:"none"},children:(0,se.jsxs)(D.A,{size:"small",children:[(0,se.jsx)(z.A,{style:{backgroundColor:"#f9fcf8"},children:(0,se.jsxs)(I.A,{children:[(0,se.jsx)(O.A,{padding:"checkbox",children:(0,se.jsx)(B.A,{indeterminate:Jt.some(e=>ha[e.id])&&!Jt.every(e=>ha[e.id]),checked:Jt.length>0&&Jt.every(e=>ha[e.id]),onChange:()=>{const e=Jt.every(e=>ha[e.id]),t=(0,n.A)({},ha);Jt.forEach(a=>{t[a.id]=!e}),xa(t)},color:"success"})}),(0,se.jsx)(O.A,{children:(0,se.jsx)("strong",{children:"Comprobante"})}),(0,se.jsx)(O.A,{children:(0,se.jsx)("strong",{children:"Cliente"})}),(0,se.jsx)(O.A,{children:(0,se.jsx)("strong",{children:"F. Emisi\xf3n"})}),(0,se.jsx)(O.A,{children:(0,se.jsx)("strong",{children:"F. Vencim
1iento"})}),(0,se.jsx)(O.A,{align:"right",children:(0,se.jsx)("strong",{children:"Monto"})})]})}),(0,se.jsx)(N.A,{children:Jt.map(e=>{var t;const a=!!ha[e.id];return(0,se.jsxs)(I.A,{hover:!0,selected:a,onClick:()=>as(e.id),style:{cursor:"pointer"},children:[(0,se.jsx)(O.A,{padding:"checkbox",onClick:e=>e.stopPropagation(),children:(0,se.jsx)(B.A,{checked:a,onChange:()=>as(e.id),color:"success"})}),(0,se.jsxs)(O.A,{children:[(0,se.jsxs)(v.A,{variant:"body2",fontWeight:"bold",children:[e.serie,"-",e.number]}),(0,se.jsx)(v.A,{variant:"caption",color:"text.secondary",children:"01"===e.document_type?"Factura":"Boleta"})]}),(0,se.jsx)(O.A,{children:(null===(t=e.receiver)||void 0===t?void 0:t.legal_name)||"Cliente Desconocido"}),(0,se.jsx)(O.A,{children:e.issue_date?d().utc(e.issue_date).utcOffset(-5).format("YYYY-MM-DD"):""}),(0,se.jsx)(O.A,{children:e.due_date?d()(e.due_date).format("YYYY-MM-DD"):""}),(0,se.jsx)(O.A,{align:"right",children:(0,se.jsxs)("strong",{children:["USD"===e.currency?"$":"S/"," ",Number(e.total_value).toFixed(2)]})})]},e.id)})})]})}),(0,se.jsxs)(x.A,{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:15},children:[(0,se.jsxs)(v.A,{variant:"caption",color:"text.secondary",children:["Total elegibles: ",oa," | Seleccionados: ",Object.values(ha).filter(Boolean).length]}),ta>1&&(0,se.jsxs)(x.A,{style:{display:"flex",gap:10},children:[(0,se.jsx)(f.A,{variant:"outlined",size:"small",disabled:1===Kt,onClick:()=>ts(Kt-1,ca),children:"Anterior"}),(0,se.jsxs)(v.A,{variant:"body2",style:{display:"flex",alignItems:"center"},children:["P\xe1gina ",Kt," de ",ta]}),(0,se.jsx)(f.A,{variant:"outlined",size:"small",disabled:Kt===ta,onClick:()=>ts(Kt+1,ca),children:"Siguiente"})]})]})]})]}),(0,se.jsxs)(L.A,{style:{borderTop:"1px solid #f0f0f0",padding:"12px 24px"},children:[(0,se.jsx)(f.A,{onClick:()=>Gt(!1),disabled:ga,color:"inherit",style:{textTransform:"none"},children:"Cancelar"}),(0,se.jsx)(f.A,{onClick:async()=>{const e=Object.keys(ha).map(Number).filter(e=>ha[e]);if(0!==e.length){ya(!0);try{var t;const a=await l.A.post("/api/v1/companies/".concat(ye,"/collection/import-invoices"),{document_ids:e});null!==(t=a.data)&&void 0!==t&&t.result&&(r.toast.success(a.data.msg||"Comprobantes importados con \xe9xito."),Gt(!1),Mn())}catch(n){var a;console.error("Failed to import invoices",n),r.toast.error("Error al importar comprobantes: "+((null===(a=n.response)||void 0===a||null===(a=a.data)||void 0===a?void 0:a.msg)||n.message))}finally{ya(!1)}}else r.toast.warn("Por favor, selecciona al menos un comprobante para importar.")},disabled:ga||0===Object.values(ha).filter(Boolean).length,variant:"contained",style:{backgroundColor:"#679B60",color:"white",textTransform:"none",fontWeight:"bold"},children:ga?"Importando...":"Importar Seleccionadas"})]})]}),(0,se.jsxs)(w.A,{open:Wn,onClose:()=>Ln(!1),maxWidth:"sm",fullWidth:!0,children:[(0,se.jsx)(T.A,{style:{backgroundColor:"#f9fcf8",borderBottom:"1px solid #eee",padding:"16px 24px"},children:(0,se.jsxs)(x.A,{style:{display:"flex",alignItems:"center",gap:8},children:[(0,se.jsx)(q.A,{style:{color:"#679B60"}}),(0,se.jsxs)(x.A,{children:[(0,se.jsx)(v.A,{variant:"h6",fontWeight:"bold",style:{color:"#2E4F29"},children:"Historial de Notificaciones de Cobranza"}),Fn&&(0,se.jsxs)(v.A,{variant:"caption",color:"text.secondary",children:["Comprobante: ",null===(e=Fn.document)||void 0===e?void 0:e.serie,"-",null===(t=Fn.document)||void 0===t?void 0:t.number," | Cliente: ",null===(a=Fn.client)||void 0===a?void 0:a.legal_name]})]})]})}),(0,se.jsx)(W.A,{style:{paddingTop:20,paddingBottom:20},children:Zn?(0,se.jsx)(x.A,{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:(0,se.jsx)(m.A,{color:"success"})}):0===Un.length?(0,se.jsxs)(x.A,{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"40px 0"},children:[(0,se.jsx)(U.A,{style:{fontSize:40,color:"#aaa"}}),(0,se.jsx)(v.A,{variant:"body2",color:"text.secondary",style:{marginTop:10},children:"No se han enviado recordatorios para este comprobante a\xfan."})]}):(0,se.jsx)(ae.g,{showChannelColumn:!0,events:Un.map(e=>{var t,a,n;const s=null===(t=e.content)||void 0===t?void 0:t.is_manual,o=[];null!==(a=e.content)&&void 0!==a&&a.template_name&&o.push("Plantilla: ".concat(e.content.template_name)),s&&o.push("(Manual)"),e.error_message&&o.push("Error: ".concat(e.error_message));const i=o.join(" | ");let l="ENVIADO";return l="DELIVERED"===e.provider_status?"RECIBIDO":"SEEN"===e.provider_status?"LE\xcdDO":"FAILED"===e.provider_status||"REJECTED"===e.provider_status?"RECHAZADO":(e.provider_status,"ENVIADO"),{id:e.id,channel:"EMAIL"===e.channel?"COLLECTION_EMAIL":"COLLECTION_WHATSAPP",typeLabel:"REMINDER_BEFORE"===e.type?"Recordatorio Pre-Vencimiento":"Recordatorio Post-Vencimiento",state:l,recipient:(null===(n=e.content)||void 0===n?void 0:n.recipient)||"(no especificado)",timestamp:e.sent_at,details:i}})})}
1),(0,se.jsx)(L.A,{style:{borderTop:"1px solid #f0f0f0",padding:"12px 24px"},children:(0,se.jsx)(f.A,{onClick:()=>Ln(!1),variant:"contained",style:{backgroundColor:"#679B60",color:"white",textTransform:"none",fontWeight:"bold",borderRadius:20},children:"Cerrar"})})]}),(0,se.jsxs)(w.A,{open:jn,onClose:()=>bn(!1),maxWidth:"sm",fullWidth:!0,children:[(0,se.jsx)(T.A,{style:{backgroundColor:"#f9fcf8",borderBottom:"1px solid #eee",padding:"16px 24px"},children:(0,se.jsxs)(x.A,{style:{display:"flex",alignItems:"center",gap:8},children:[(0,se.jsx)(Q.A,{style:{color:"#1976d2"}}),(0,se.jsxs)(x.A,{children:[(0,se.jsx)(v.A,{variant:"h6",fontWeight:"bold",style:{color:"#2E4F29"},children:"Planificaci\xf3n de Recordatorios Aut\xf3nomos"}),_n&&(0,se.jsxs)(v.A,{variant:"caption",color:"text.secondary",children:["Comprobante: ",null===(c=_n.document)||void 0===c?void 0:c.serie,"-",null===(ie=_n.document)||void 0===ie?void 0:ie.number," | Cliente: ",null===(le=_n.client)||void 0===le?void 0:le.legal_name]})]})]})}),(0,se.jsx)(W.A,{style:{paddingTop:20,paddingBottom:20},children:_n&&(0,se.jsxs)(x.A,{children:[(0,se.jsxs)(x.A,{style:{display:"flex",justifyContent:"space-between",backgroundColor:"#f9f9f9",padding:"12px 16px",borderRadius:8,marginBottom:20,border:"1px solid #eaeaea"},children:[(0,se.jsxs)(x.A,{children:[(0,se.jsx)(v.A,{variant:"caption",color:"text.secondary",style:{display:"block",fontWeight:"bold"},children:"ESTADO DE COBRANZA"}),(0,se.jsx)(x.A,{style:{marginTop:4},children:ns(_n.status)})]}),(0,se.jsxs)(x.A,{style:{textAlign:"right"},children:[(0,se.jsx)(v.A,{variant:"caption",color:"text.secondary",style:{display:"block",fontWeight:"bold"},children:"SALDO TOTAL"}),(0,se.jsxs)(v.A,{variant:"subtitle1",fontWeight:"bold",style:{color:"#2E4F29",marginTop:2},children:["USD"===(null===(re=_n.document)||void 0===re?void 0:re.currency)?"$":"S/"," ",Number(_n.total_amount).toFixed(2)]})]})]}),(0,se.jsx)(v.A,{variant:"subtitle2",fontWeight:"bold",color:"#2E4F29",style:{marginBottom:15},children:"Cronograma Estimado de Notificaciones"}),(0,se.jsx)(x.A,{style:{display:"flex",flexDirection:"column",gap:12},children:(e=>{const t=[],a=d()(e.due_date),n=d()(),s=d()(e.due_date).subtract(Rt,"days"),o=e.reminders_sent>0||n.isAfter(s,"day");t.push({type:"PRE_DUE",label:"Recordatorio Pre-Vencimiento (".concat(Rt," d\xedas antes)"),date:s,status:o?"COMPLETADO":"PROGRAMADO",canAdvance:!o&&!["PAGADA","PAGO_CONFIRMADO_CLIENTE","PAGO_VALIDADO_USUARIO","CANCELADA"].includes(e.status)}),t.push({type:"DUE_DATE",label:"FECHA DE VENCIMIENTO DE LA FACTURA",date:a,status:n.isAfter(a,"day")?"VENCIDA":"VIGENTE",canAdvance:!1});return Lt.split(",").map(e=>Number(e.trim())).filter(e=>!isNaN(e)&&e>0).sort((e,t)=>e-t).forEach((a,s)=>{const o=d()(e.due_date).add(a,"days");let i="PROGRAMADO",l=!0;if(["PAGADA","PAGO_CONFIRMADO_CLIENTE","PAGO_VALIDADO_USUARIO","CANCELADA"].includes(e.status))i="PAUSADO / PAGADO",l=!1;else if(n.isAfter(o,"day")){const t=1+(s+1);i=e.reminders_sent>=t?"ENVIADO":"COMPLETADO / VENCIDO",l=!1}t.push({type:"POST_DUE",label:"Recordatorio Post-Vencimiento (+".concat(a," d\xeda").concat(a>1?"s":"",")"),date:o,status:i,canAdvance:l})}),t})(_n).map((e,t)=>{const a="DUE_DATE"===e.type,n="COMPLETADO"===e.status||"ENVIADO"===e.status||"COMPLETADO / VENCIDO"===e.status||"VENCIDA"===e.status,s="PAUSADO / PAGADO"===e.status;let o="#1976d2";return a?o="VENCIDA"===e.status?"#d32f2f":"#2e7d32":n?o="#2e7d32":s&&(o="#9e9e9e"),(0,se.jsxs)(x.A,{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",borderRadius:8,border:a?"1.5px dashed #bbb":"1px solid #e5e7eb",backgroundColor:a?"#fdfdfd":s?"#f9f9f9":"white",boxShadow:"0 1px 3px rgba(0,0,0,0.01)"},children:[(0,se.jsxs)(x.A,{style:{display:"flex",gap:12,alignItems:"center"},children:[(0,se.jsx)(x.A,{style:{width:10,height:10,borderRadius:"50%",backgroundColor:o,boxSh
1adow:"0 0 0 3px ".concat(o,"22")}}),(0,se.jsxs)(x.A,{children:[(0,se.jsx)(v.A,{variant:"body2",fontWeight:"bold",color:a?"#d32f2f":"text.primary",style:{fontSize:"13px"},children:e.label}),(0,se.jsxs)(v.A,{variant:"caption",color:"text.secondary",style:{display:"block",marginTop:2},children:["Fecha estimada: ",(0,se.jsx)("strong",{children:e.date.format("YYYY-MM-DD")})]})]})]}),(0,se.jsxs)(x.A,{style:{display:"flex",alignItems:"center",gap:8},children:[(0,se.jsx)(h.A,{label:e.status,size:"small",color:"PROGRAMADO"===e.status||"VIGENTE"===e.status?"primary":"COMPLETADO"===e.status||"ENVIADO"===e.status?"success":"VENCIDA"===e.status?"error":"default",style:{fontWeight:"bold",fontSize:"11px"}}),e.canAdvance&&(0,se.jsx)(f.A,{size:"small",variant:"outlined",color:"success",onClick:()=>{bn(!1),es(_n.id)},style:{textTransform:"none",fontSize:"11px",fontWeight:"bold",borderRadius:12,padding:"2px 8px"},children:"Enviar ya"})]})]},t)})})]})}),(0,se.jsx)(L.A,{style:{borderTop:"1px solid #f0f0f0",padding:"12px 24px"},children:(0,se.jsx)(f.A,{onClick:()=>bn(!1),variant:"contained",style:{backgroundColor:"#1976d2",color:"white",textTransform:"none",fontWeight:"bold",borderRadius:20},children:"Cerrar"})})]}),(0,se.jsxs)(w.A,{open:sn,onClose:()=>on(!1),maxWidth:"xs",fullWidth:!0,children:[(0,se.jsx)(T.A,{style:{backgroundColor:"#f9fcf8",borderBottom:"1px solid #eee"},children:(0,se.jsx)(v.A,{variant:"h6",fontWeight:"bold",style:{color:"#2E4F29"},children:"Modificar Estado de Factura"})}),(0,se.jsx)(W.A,{style:{paddingTop:20},children:cn&&(0,se.jsxs)(x.A,{children:[(0,se.jsxs)(v.A,{variant:"body2",style:{marginBottom:15},children:["Est\xe1s modificando el estado de la factura ",(0,se.jsxs)("strong",{children:[null===(ce=cn.document)||void 0===ce?void 0:ce.serie,"-",null===(de=cn.document)||void 0===de?void 0:de.number]}),"."]}),(0,se.jsxs)(k.A,{fullWidth:!0,size:"small",children:[(0,se.jsx)(M.A,{id:"status-select-label",children:"Nuevo Estado"}),(0,se.jsx)(P.A,{labelId:"status-select-label",value:hn,label:"Nuevo Estado",onChange:e=>xn(e.target.value),children:oe.map(e=>(0,se.jsx)(R.A,{value:e,children:e.replace(/_/g," ")},e))})]})]})}),(0,se.jsxs)(L.A,{style:{borderTop:"1px solid #f0f0f0",padding:"12px 24px"},children:[(0,se.jsx)(f.A,{onClick:()=>on(!1),style:{color:"#666"},children:"Cancelar"}),(0,se.jsx)(f.A,{onClick:async()=>{if(cn){if(on(!1),["PAGADA","PAGO_VALIDADO_USUARIO"].includes(hn))return Ha(cn),Ja(""),Ka(""),tn(hn),void La(!0);try{var e;null!==(e=(await l.A.patch("/api/v1/collection/invoices/".concat(cn.id,"/status"),{status:hn})).data)&&void 0!==e&&e.result&&(r.toast.success("Estado de factura actualizado correctamente."),Mn())}catch(a){var t;r.toast.error("Error al actualizar estado: "+((null===(t=a.response)||void 0===t||null===(t=t.data)||void 0===t?void 0:t.msg)||a.message))}}},variant:"contained",style:{backgroundColor:"#679B60",color:"white",fontWeight:"bold"},children:"Guardar Cambio"})]})]}),(0,se.jsxs)(w.A,{open:Wa,onClose:()=>La(!1),maxWidth:"sm",fullWidth:!0,children:[(0,se.jsx)(T.A,{style:{backgroundColor:"#f9fcf8",borderBottom:"1px solid #eee"},children:(0,se.jsx)(v.A,{variant:"h6",fontWeight:"bold",style:{color:"#2E4F29"},children:"Conciliaci\xf3n Bancaria Manual y Confirmaci\xf3n de Pago"})}),(0,se.jsx)(W.A,{style:{paddingTop:20},children:Fa&&(0,se.jsxs)(x.A,{children:[(0,se.jsxs)(v.A,{variant:"body2",style:{marginBottom:15},children:["Registra la cuenta bancaria de destino y el n\xfamero de operaci\xf3n para la factura ",(0,se.jsxs)("strong",{children:[null===(ue=Fa.document)||void 0===ue?void 0:ue.serie,"-",null===(Ae=Fa.document)||void 0===Ae?void 0:Ae.number]})," (Monto: ","USD"===(null===(he=Fa.document)||void 0===he?void 0:he.currency)?"$":"S/"," ",Number(Fa.total_amount).toFixed(2),")."]}),0===pn.length?(0,se.jsxs)(x.A,{style:{backgroundColor:"#fff5f5",border:"1px solid #ff8080",padding:12,borderRadius:8,marginBottom:20},children:[(0,se.jsx)(v.A,{variant:"body2",color:"error",fontWeight:"bold",children:"\u26a0\ufe0f No hay cuentas bancarias configuradas."}),(0,se.jsx)(v.A,{variant:"caption",color:"text.secondary",children:"Por favor, configura las cuentas bancarias de la empresa primero en la secci\xf3n de Configuraci\xf3n de la Empresa para activar la conciliaci\xf3n. Puedes escribir una manualmente abajo si es urgente."})]}):null,(0,se.jsxs)(g.Ay,{container:!0,spacing:2,children:[(0,se.jsx)(g.Ay,{item:!0,xs:12,children:(0,se.jsxs)(k.A,{fullWidth:!0,size:"small",children:[(0,se.jsx)(M.A,{id:"bank-select-label",children:"Cuenta Bancaria de Destino"}),(0,se.jsxs)(P.A,{labelId:"bank-select-label",value:Ua,label:"Cuenta Bancaria de Destino",onChange:e=>Ja(e.target.value),children:[pn.map((e,t)=>(0,se.jsxs)(R.A,{value:"".concat(e.bank_name," - ").concat(e.account_number," (").concat(e.currency,")"),children:[e.bank_name," - ",e.account_number," (",e.currency,")"]},t)),(0,se.jsx)(R.A,{value:"OTRA",children:"Escribir otra cuenta manualmente..."})]})]})}),("OTRA"===Ua||0===pn.length)&&(0,se.jsx)(g.Ay,{item:!0,xs:12,children:(0,se.jsx)(C.A,{fullWidth:!0,size:"small",label:"Escribe la Cuenta Bancaria manualmente",placeholder:"Ej. BCP Soles - 191-xxxx",onChange:e=>Ja(e.target.value)})}),(0,se.jsx)(g.Ay,{item:!0,xs:12,children:(0,se.jsx)(C.A,{fullWidth:!0,size:"small",label:"N\xfamero de Operaci\xf3n Bancaria",placeholder:"Ej. OP-987123",value:Za,onChange:e=>Ka(e.target.value)})}),(0,se.jsx)(g.Ay,{item:!0,xs:12,children:(0,se.jsxs)(k.A,{fullWidth:!0,size:"small",children:[(0,se.jsx)(M.A,{id:"reconcile-status-label",children:"Estado de la Factura"}),(0,se.jsxs)(P.A,{labelId:"reconcile-status-label",value:en,label:"Estado de la Factura",onChange:e=>tn(e.target.value),children:[(0,se.jsx)(R.A,{value:"PAGADA",children:"PAGADA (Conciliaci\xf3n Completa)"}),(0,se.jsx)(R.A,{value:"PAGO_VALIDADO_USUARIO",children:"PAGO VALIDADO POR USUARIO"})]})]})})]})]})}
1),(0,se.jsxs)(L.A,{style:{borderTop:"1px solid #f0f0f0",padding:"12px 24px"},children:[(0,se.jsx)(f.A,{onClick:()=>La(!1),style:{color:"#666"},children:"Cancelar"}),(0,se.jsx)(f.A,{onClick:async()=>{if(Fa)try{var e;null!==(e=(await l.A.post("/api/v1/collection/invoices/".concat(Fa.id,"/reconcile"),{status:en,bank_account:Ua||null,transaction_number:Za||null})).data)&&void 0!==e&&e.result&&(r.toast.success("Pago conciliado y confirmado correctamente."),La(!1),Mn())}catch(a){var t;r.toast.error("Error al conciliar pago: "+((null===(t=a.response)||void 0===t||null===(t=t.data)||void 0===t?void 0:t.msg)||a.message))}},disabled:!Ua||!Za.trim(),variant:"contained",style:{backgroundColor:"#679B60",color:"white",fontWeight:"bold"},children:"Confirmar y Conciliar Pago"})]})]})]})};a.d(t,["default",0,ie])},58672(e,t,a){var n=a(24994);t.A=void 0;var s=n(a(79526)),o=a(44414);t.A=(0,s.default)((0,o.jsx)("path",{d:"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4zm-1-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8"}),"AddCircleOutline")},76283(e,t,a){var n=a(24994);t.A=void 0;var s=n(a(79526)),o=a(44414);t.A=(0,s.default)((0,o.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2M9 17H7v-5h2zm4 0h-2v-3h2zm0-5h-2v-2h2zm4 5h-2V7h2z"}),"Analytics")},77995(e,t,a){var n=a(24994);t.A=void 0;var s=n(a(79526)),o=a(44414);t.A=(0,s.default)((0,o.jsx)("path",{d:"M12 6v3l4-4-4-4v3c-4.42 0-8 3.58-8 8 0 1.57.46 3.03 1.24 4.26L6.7 14.8c-.45-.83-.7-1.79-.7-2.8 0-3.31 2.69-6 6-6m6.76 1.74L17.3 9.2c.44.84.7 1.79.7 2.8 0 3.31-2.69 6-6 6v-3l-4 4 4 4v-3c4.42 0 8-3.58 8-8 0-1.57-.46-3.03-1.24-4.26"}),"Autorenew")},42209(e,t,a){var n=a(24994);t.A=void 0;var s=n(a(79526)),o=a(44414);t.A=(0,s.default)((0,o.jsx)("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2m5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12z"}),"Cancel")},31451(e,t,a){var n=a(24994);t.A=void 0;var s=n(a(79526)),o=a(44414);t.A=(0,s.default)((0,o.jsx)("path",{d:"M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9m-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8z"}),"History")},20888(e,t,a){var n=a(24994);t.A=void 0;var s=n(a(79526)),o=a(44414);t.A=(0,s.default)((0,o.jsx)("path",{d:"M6 2v6h.01L6 8.01 10 12l-4 4 .01.01H6V22h12v-5.99h-.01L18 16l-4-4 4-3.99-.01-.01H18V2zm10 14.5V20H8v-3.5l4-4zm-4-5-4-4V4h8v3.5z"}),"HourglassEmpty")},42917(e,t,a){var n=a(24994);t.A=void 0;var s=n(a(79526)),o=a(44414);t.A=(0,s.default)((0,o.jsx)("path",{d:"M7.58 4.08 6.15 2.65C3.75 4.48 2.17 7.3 2.03 10.5h2c.15-2.65 1.51-4.97 3.55-6.42m12.39 6.42h2c-.15-3.2-1.73-6.02-4.12-7.85l-1.42 1.43c2.02 1.45 3.39 3.77 3.54 6.42M18 11c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2zm-6 11c.14 0 .27-.01.4-.04.65-.14 1.18-.58 1.44-1.18.1-.24.15-.5.15-.78h-4c.01 1.1.9 2 2.01 2"}),"NotificationsActive")},78287(e,t,a){var n=a(24994);t.A=void 0;var s=n(a(79526)),o=a(44414);t.A=(0,s.default)((0,o.jsx)("path",{d:"M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.89-2-2-2m0 16H5V7h14zm-5.5-6c0 .83-.67 1.5-1.5 1.5s-1.5-.67-1.5-1.5.67-1.5 1.5-1.5 1.5.67 1.5 1.5M12 9c-2.73 0-5.06 1.66-6 4 .94 2.34 3.27 4 6 4s5.06-1.66 6-4c-.94-2.34-3.27-4-6-4m0 6.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5"}),"Preview")},91602(e,t,a){var n=a(24994);t.A=void 0;var s=n(a(79526)),o=a(44414);t.A=(0,s.default)([(0,o.jsx)("path",{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"},"0"),(0,o.jsx)("path",{d:"M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"},"1")],"Schedule")},19223(e,t,a){var n=a(24994);t.A=void 0;var s=n(a(79526)),o=a(44414);t.A=(0,s.default)((0,o.jsx)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14"}),"Search")},55858(e,t,a){var n=a(24994);t.A=void 0;var s=n(a(79526)),o=a(44414);t.A=(0,s.default)((0,o.jsx)("path",{d:"M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6"}),"Settings")},50495(e,t,a){var n=a(24994);t.A=void 0;var s=n(a(79526)),o=a(44414);t.A=(0,s.default)((0,o.jsx)("path",{d:"m16 6 2.29 2.29-4.88 4.88-4-4L2 16.59 3.41 18l6-6 4 4 6.3-6.29L22 12V6z"}),"TrendingUp")},45458(e,t,a){var n=a(65471),s=a(44414);const o=(0,n.A)([(0,s.jsx)("path",{d:"m3 17.97 6.1-2.61c.02-.14.04-.29.07-.43L3 15.75zM16.5 11c-3.03 0-5.5 2.47-5.5 5.5s2.47 5.5 5.5 5.5 5.5-2.47 5.5-5.5-2.47-5.5-5.5-5.5m2.47 7.27-.71.71-1.77-1.77-1.77 1.77-.71-.71 1.77-1.77-1.77-1.77.71-.71 1.77 1.77 1.77-1.77.71.71-1.77 1.77zM3 8.25l7.52 1-7.51-3.22z",opacity:".3"},"0"),(0,s.jsx)("path",{d:"M16.5 9c-.42 0-.83.04-1.24.11L1.01 3 1 10l10.06 1.34c-.42.44-.78.93-1.09 1.46L1 14l.01 7 8.07-3.46C9.59 21.19 12.71 24 16.5 24c4.14 0 7.5-3.36 7.5-7.5S20.64 9 16.5 9M3 8.25l.01-2.22 7.51 3.22zm6.1 7.11L3 17.97v-2.22l6.17-.82c-.03.14-.05.28-.07.43M16.5 22c-3.03 0-5.5-2.47-5.5-5.5s2.47-5.5 5.5-5.5 5.5 2.47 5.5 5.5-2.47 5.5-5.5 5.5"},"1"),(0,s.jsx)("path",{d:"m18.27 14.03-1.77 1.76-1.77-1.76-.7.7 1.76 1.77-1.76 1.77.7.7 1.77-1.76 1.77 1.76.7-.7-1.76-1.77 1.76-1.77z"},"2")],"CancelScheduleSendTwoTone");a.d(t,["A",0,o])},43809(e,t,a){var n=a(65471),s=a(44414);const o=(0,n.A)([(0,s.jsx)("path",{d:"M12 4c-4.41 0-8 3.59-8 8s3.59 8 8 8 8-3.59 8-8-3.59-8-8-8m-2 13-4-4 1.41-1.41L10 14.17l6.59-6.59L18 9z",opacity:".3"},"0"),(0,s.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m4.59-12.42L10 14.17l-2.59-2.58L6 13l4 4 8-8z"},"1")],"CheckCircleTwoTone");a.d(t,["A",0,o])},50173(e,t,a){var n=a(65471),s=a(44414);const o=(0,n.A)([(0,s.jsx)("path",{d:"M22 5H2v14h20zM9 6c1.65 0 3 1.35 3 3s-1.35 3-3 3-3-1.35-3-3
11.35-3 3-3m6 12H3v-1.41C3 14.08 6.97 13 9 13s6 1.08 6 3.58zm2.85-4h1.64L21 16l-1.99 1.99c-1.31-.98-2.28-2.38-2.73-3.99-.18-.64-.28-1.31-.28-2s.1-1.36.28-2c.45-1.62 1.42-3.01 2.73-3.99L21 8l-1.51 2h-1.64c-.22.63-.35 1.3-.35 2s.13 1.37.35 2",opacity:".3"},"0"),(0,s.jsx)("path",{d:"M2 21h20c1.1 0 1.99-.9 1.99-2L24 5c0-1.1-.9-2-2-2H2C.9 3 0 3.9 0 5v14c0 1.1.9 2 2 2M2 5h20v14H2zm17.49 5L21 8l-1.99-1.99c-1.31.98-2.28 2.37-2.73 3.99-.18.64-.28 1.31-.28 2s.1 1.36.28 2c.45 1.61 1.42 3.01 2.73 3.99L21 16l-1.51-2h-1.64c-.22-.63-.35-1.3-.35-2s.13-1.37.35-2zM9 12c1.65 0 3-1.35 3-3s-1.35-3-3-3-3 1.35-3 3 1.35 3 3 3m0-4c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1m0 5c-2.03 0-6 1.08-6 3.58V18h12v-1.41C15 14.08 11.03 13 9 13m-3.52 3c.74-.5 2.22-1 3.52-1s2.77.49 3.52 1z"},"1")],"ContactPhoneTwoTone");a.d(t,["A",0,o])},99063(e,t,a){var n=a(65471),s=a(44414);const o=(0,n.A)((0,s.jsx)("path",{d:"M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z"}),"Done");a.d(t,["A",0,o])},95720(e,t,a){var n=a(65471),s=a(44414);const o=(0,n.A)((0,s.jsx)("path",{d:"m18 7-1.41-1.41-6.34 6.34 1.41 1.41zm4.24-1.41L11.66 16.17 7.48 12l-1.41 1.41L11.66 19l12-12zM.41 13.41 6 19l1.41-1.41L1.83 12z"}),"DoneAll");a.d(t,["A",0,o])},26821(e,t,a){var n=a(65471),s=a(44414);const o=(0,n.A)([(0,s.jsx)("path",{d:"m12 15.36-8-5.02V18h16l-.01-7.63z",opacity:".3"},"0"),(0,s.jsx)("path",{d:"M21.99 8c0-.72-.37-1.35-.94-1.7L12 1 2.95 6.3C2.38 6.65 2 7.28 2 8v10c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2zM12 3.32 19.99 8v.01L12 13 4 8zM4 18v-7.66l8 5.02 7.99-4.99L20 18z"},"1")],"DraftsTwoTone");a.d(t,["A",0,o])},12015(e,t,a){var n=a(65471),s=a(44414);const o=(0,n.A)((0,s.jsx)("path",{d:"M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2m0 4-8 5-8-5V6l8 5 8-5z"}),"Email");a.d(t,["A",0,o])},20517(e,t,a){var n=a(65471),s=a(44414);const o=(0,n.A)([(0,s.jsx)("path",{d:"m20 8-8 5-8-5v10h16zm0-2H4l8 4.99z",opacity:".3"},"0"),(0,s.jsx)("path",{d:"M4 20h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2M20 6l-8 4.99L4 6zM4 8l8 5 8-5v10H4z"},"1")],"EmailTwoTone");a.d(t,["A",0,o])},79184(e,t,a){var n=a(65471),s=a(44414);const o=(0,n.A)((0,s.jsx)("path",{d:"M21 10h-8.35C11.83 7.67 9.61 6 7 6c-3.31 0-6 2.69-6 6s2.69 6 6 6c2.61 0 4.83-1.67 5.65-4H13l2 2 2-2 2 2 4-4.04zM7 15c-1.65 0-3-1.35-3-3s1.35-3 3-3 3 1.35 3 3-1.35 3-3 3"}),"KeyTwoTone");a.d(t,["A",0,o])},77078(e,t,a){var n=a(65471),s=a(44414);const o=(0,n.A)((0,s.jsx)("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2M9 6c0-1.66 1.34-3 3-3s3 1.34 3 3v2H9zm9 14H6V10h12zm-6-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2"}),"LockOutlined");a.d(t,["A",0,o])}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.