PageSourceSearch

https://panel.trustpanel.com.br/assets/ProspectDetail-BaB1to85.js

js trustpanel.com.br collected 2026-10-02 01:19:43 UTC 33,556 bytes, 97 lines download raw bytes

1import{c as _e,H as Ee,a as d,u as Q,g as fe,e as J,s as he,ah as se,r as c,j as e,D as ge,ac as be,B as i,T as f,x as Te,X,f as je,A as Fe,at as ve,au as ke,b as z,G as Z,ae as ye,ad as ae,Q as Ce,y as re,aw as Pe,ag as Re,ar as We,ce as Ae,O as Me,n as ne,t as Be,aA as Ie,I as ie}from"./index-BXOdV3oC.js";import{S as le}from"./StatusChip-D-lk5AiQ.js";import{E as Ne}from"./EmptyState-D4tKLFXz.js";import{P as qe}from"./PageSkeleton-JnXkria2.js";import{C as $e}from"./ConfirmDialog-B3FEPtZs.js";import{p as Oe,P as Le,a as He}from"./ProspectConvertDialog-BBJg5_QV.js";import{p as K}from"./proposalService-CFm-x6cK.js";import{m as g,p as Se,a as Ue}from"./priceListService-DzN77piS.js";import{P as Ge}from"./PageHero-GlRRrsRc.js";import{P as Ve}from"./PageHelp-BviT0zF8.js";import{p as Xe,P as Ze}from"./printBrand-CLV7XEoi.js";import{S as Ke}from"./sparkles-CDPotVtd.js";import{A as ce}from"./arrow-right-CxUultYD.js";import{T as we}from"./trash-2-DxTo1K2z.js";import{C as oe}from"./check-COJ5nPn4.js";import{F as ze}from"./file-text-Du5ZIQYt.js";import{M as Qe}from"./MenuItem-pF0X8i6V.js";import{A as Ye}from"./arrow-left-DvbGgexV.js";import{P as de}from"./pencil-Bc8PiYPG.js";import{U as Je}from"./user-plus-BmvLLdBL.js";import{T as eo,a as xe}from"./Tabs-CZRlQ8FR.js";import{G as w}from"./Grid-_HczheMI.js";import{M as oo}from"./map-pin-DYW5qqTB.js";import{B as so}from"./ProspectFields-DGKCYaVW.js";import{C as De}from"./Card-CskSdyba.js";import{T as to}from"./TableContainer-DZvSgqdB.js";import{T as ao,a as ro,b as pe,c as V,d as no}from"./TableRow-DWvfpWE2.js";import{E as io}from"./eye-5zIIonC9.js";import"./check-circle-2-Cc9AEuIB.js";import"./x-circle-Dm22saZD.js";import"./Skeleton-C3PGKq08.js";import"./save-7BigC7bF.js";import"./InputAdornment-Jit50FNc.js";import"./mail-DMQrJBM0.js";import"./phone-Cuu9AbeC.js";import"./Checkbox-BocqMkBm.js";import"./SwitchBase-BFUyzDbI.js";import"./Breadcrumbs-BvrE1KQw.js";import"./chevron-right-o86ANSVF.js";import"./KeyboardArrowRight-D-2iOnlr.js";import"./sliders-horizontal-I_z8c5Ti.js";/**
2 * @license lucide-react v0.344.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const lo=_e("FileBarChart2",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 18v-1",key:"zg0ygc"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"M16 18v-3",key:"j5jt4h"}]]),O=o=>o.replace(/[&<>]/g,l=>l==="&"?"&amp;":l==="<"?"&lt;":"&gt;");function co(o,l){const{prospect:a,modLabel:p,recommended:m}=l,s=(m==null?void 0:m.plan.nome)===o.plan.nome,h=m?o.total-m.total:0,k=o.certExc>0?`<div class="line"><span>${o.certExc} certs exc. × ${g(o.plan.exc_cert)}</span><b class="add">+ ${g(o.certExcCost)}</b></div>`:'<div class="line"><span>Sem certs excedentes</span><b class="ok">R$ 0,00</b></div>',F=o.userExc>0?`<div class="line"><span>${o.userExc} users exc. × ${g(o.plan.exc_user)}</span><b class="add">+ ${g(o.userExcCost)}</b></div>`:'<div class="line"><span>Sem users excedentes</span><b class="ok">R$ 0,00</b></div>',E=s?"Melhor custo-benefício para o perfil atual.":h>0?`Custa <b>${g(h)}/mês a mais</b> que o plano recomendado.`:"Mesmo custo do plano recomendado.";return`
7    <div class="card${s?" rec":""}">
8      ${s?'<div class="pill">✓ Recomendado</div>':'<div class="pill ghost">&nbsp;</div>'}
9      <div>
10        <div class="pname">${O(o.plan.nome)} ${O(p)}</div>
11        <div class="pinc">${o.plan.certs_inclusos} certificados inclusos · ${o.plan.users_inclusos} usuários</div>
12      </div>
13      <div class="sec custo">Composição do custo</div>
14      <div class="lines">
15        <div class="line"><span>Base do plano</span><b>${g(o.base)}</b></div>
16        ${k}
17        ${F}
18      </div>
19      <div class="sec cli">Situação do cliente</div>
20      <div class="lines">
21        <div class="line"><span>Certificados (cliente / plano)</span><b class="${o.certExc>0?"warn":""}">${a.qtd_certificados} / ${o.plan.certs_inclusos}</b></div>
22        <div class="line"><span>Usuários (cliente / plano)</span><b class="${o.userExc>0?"warn":""}">${a.qtd_usuarios} / ${o.plan.users_inclusos}</b></div>
23      </div>
24      <div class="total-lbl">Total mensal estimado</div>
25      <div class="total${s?" rec":""}">${g(o.total)}<span>/mês</span></div>
26      <div class="note">${E}</div>
27    </div>`}function xo(o){const{prospect:l,modLabel:a,rows:p}=o,m=new Date().toLocaleDateString("pt-BR"),s=p.map(y=>co(y,o)).join(""),h=Xe(),k=Ee("light"),F=k.feedback.successFg,E=k.feedback.warningFg,A=`<!doctype html><html lang="pt-BR"><head><meta charset="utf-8">
28    <title>Planos: ${O(l.razao_social)}</title>
29    <style>
30      * { box-sizing: border-box; margin: 0; padding: 0; }
31      html, body { background: #f4f5f3; }
32      body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: #1a2620; padding: 26px; }
33      .sheet { max-width: 1040px; margin: 0 auto; }
34      .hero {
35        background: linear-gradient(135deg, ${h.primaria} 0%, ${h.acento} 100%);
36        color: #fff; padding: 26px 32px; border-radius: 16px;
37        display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px;
38      }
39      .hero-brand { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; opacity: .9; }
40      .hero h1 { font-size: 23px; font-weight: 800; margin: 9px 0 4px; line-height: 1.15; }
41      .hero .sub { font-size: 12.5px; opacity: .82; }
42      .mod {
43        flex-shrink: 0; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.4);
44        border-radius: 22px; padding: 8px 18px; font-size: 11px; font-weight: 800;
45        text-transform: uppercase; letter-spacing: .08em; white-space: nowrap;
46      }
47      .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
48      .card {
49        background: #fff; border: 1.5px solid #e6e6e1; border-radius: 14px; padding: 16px;
50        display: flex; flex-direction: column; gap: 10px; break-inside: avoid; page-break-inside: avoid;
51      }
52      .card.rec { border-color: ${h.acento}; box-shadow: 0 0 0 3px ${d(h.acento,.14)}; }
53      /* Tinta em acentoEscuro, não tintaAcento: a pílula é texto de 10px sobre
54         o tinte de 15% do acento, e na marca padrão o tom mais claro fica em
55         3,45:1 — abaixo dos 4,5:1 que texto normal exige. Mesma razão pela
56         qual o h2 da folha de procuração migrou. */
57      .pill { align-self: flex-start; background: ${d(h.acento,.15)}; color: ${h.acentoEscuro}; font-size: 10px;
58        font-weight: 800; padding: 4px 9px; border-radius: 6px; text-transform: uppercase; letter-spacing: .03em; }
59      .pill.ghost { background: transparent; color: transparent; }
60      .pname { font-size: 15.5px; font-weight: 800; color: #16321f; line-height: 1.2; }
61      .pinc { font-size: 11px; color: #6b7770; margin-top: 3px; }
62      .sec { font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
63      .sec.custo { color: #3B5BBD; }
64      .sec.cli { color: #8A8F8C; }
65      .lines { display: flex; flex-direction: column; gap: 4px; }
66      .line { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: #5b6b63; }
67      .line b { color: #1c2b24; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
68      .line b.add, .line b.warn { color: ${E}; }
69      .line b.ok { color: ${F}; }
70      .total-lbl { font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: #8A8F8C; margin-top: auto; }
71      .total { font-size: 22px; font-weight: 800; color: ${h.primaria}; line-height: 1.05; font-variant-numeric: tabular-nums; }
72      .total.rec { color: ${h.tintaAcento}; }
73      .total span { font-size: 11px; font-weight: 600; color: #8A8F8C; }
74      .note { background: #f6f8f6; border-radius: 8px; padding: 9px 11px; font-size: 10.5px; color: #5b6b63; }
75      .note b { color: #1c2b24; }
76      .footer { text-align: center; color: #9aa0a6; font-size: 10.5px; margin-top: 20px; letter-spacing: .02em; }
77      .empty { text-align: center; color: #9aa0a6; font-size: 13px; padding: 32px; }
78      @page { size: A4; margin: 12mm; }
79      @media print {
80        body { background: #fff; padding: 0; }
81        .hero, .card, .pill, .note, .sec { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
82      }
83    </style></head>
84    <body>
85      <div class="sheet">
86        <div class="hero">
87          <div>
88            <div class="hero-brand">${O(h.nome)}</div>
89            <h1>Proposta de Planos: ${O(l.razao_social)}</h1>
90            <div class="sub">${l.qtd_certificados} certificados · ${l.qtd_usuarios} usuários · ${O(a)} · Impresso em ${m}</div>
91          </div>
92          <div class="mod">${O(a)}</div>
93        </div>
94        ${s?`<div class="grid">${s}</div>`:'<div class="empty">Nenhum plano disponível para esta modalidade.</div>'}
95        <div class="footer">${O(h.rodape)}</div>
96      </div>
97    </body></html>`,T=window.open("","_blank","width=1024,height=768");return T?(T.document.write(A),T.document.close(),T.focus(),T.print(),!0):!1}const po=(o,l,a)=>{const p=Number(o.valor_sugerido)||0,m=Math.max(0,l-o.certs_inclusos),s=Math.max(0,a-o.users_inclusos),h=m*(Number(o.exc_cert)||0),k=s*(Number(o.exc_user)||0);return{plan:o,base:p,certExc:m,certExcCost:h,userExc:s,userExcCost:k,total:p+h+k}};function mo({open:o,onClose:l,prospect:a,drafts:p=[],onDraftsChanged:m}){const s=Q(),{color:h}=fe(J().palette.mode),k=he(),F=se(),[E,A]=c.useState(null),[T,y]=c.useState(!0),[D,W]=c.useState(null),[_,L]=c.useState(!1),[M,H]=c.useState(!1),[v,R]=c.useState(!1),[B,C]=c.useState(!1);c.useEffect(()=>{o&&(y(!0),W(null),H(!1),C(!1),Se.active().then(A).catch(()=>A(null)).finally(()=>y(!1)))},[o]);const n=c.useMemo(()=>E?E.planos.filter(t=>t.modalidade===a.modalidade).sort((t,b)=>t.ordem-b.ordem).map(t=>po(t,a.qtd_certificados,a.qtd_usuarios)):[],[E,a]),j=c.useMemo(()=>n.length===0?null:n.reduce((t,b)=>
97b.total<t.total?b:t,n[0]),[n]);c.useEffect(()=>{j&&D===null&&W(j.plan.nome)},[j,D]);const $=c.useMemo(()=>p.length===0?null:[...p].sort((t,b)=>new Date(b.updated_at).getTime()-new Date(t.updated_at).getTime())[0],[p]),N=$!==null&&!M,U=()=>{$&&k(`/adm/proposals/${$.id}/edit`)},I=async()=>{R(!0);try{const t=await Promise.allSettled(p.map(S=>K.remove(S.id)));m==null||m(),t.every(S=>S.status==="fulfilled")?H(!0):F.error("Não foi possível descartar todos os rascunhos.")}finally{R(!1),C(!1)}},x=async()=>{if(D){L(!0);try{const t=await K.createDraft(a.id,D);k(`/adm/proposals/${t.id}/edit`)}catch{L(!1)}}},r=a.modalidade==="WEB"?"Web":"On-premise",q=n.find(t=>t.plan.nome===D)??null,u=()=>xo({prospect:a,modLabel:r,rows:n,recommended:j});return e.jsxs(e.Fragment,{children:[e.jsxs(ge,{open:o,onClose:_?void 0:l,maxWidth:"lg",fullWidth:!0,scroll:"paper",slotProps:{backdrop:{sx:{backgroundColor:d("#0B1F17",.55),backdropFilter:"blur(3px)"}}},PaperProps:{sx:{borderRadius:4,overflow:"hidden",m:{xs:2,sm:3,md:5},width:{xs:"calc(100% - 32px)",md:"calc(100% - 80px)"},maxHeight:{xs:"calc(100% - 32px)",md:"calc(100% - 96px)"},boxShadow:"0 32px 80px -24px rgba(11, 31, 23, 0.55)"}},children:[e.jsxs(be,{component:"div",sx:{px:{xs:2.5,md:3.5},py:2.5,background:s.gradients.card,color:"#fff",display:"flex",alignItems:"flex-start",gap:1.5},children:[e.jsx(i,{sx:{flexShrink:0,mt:.25,width:40,height:40,borderRadius:2,display:{xs:"none",sm:"flex"},alignItems:"center",justifyContent:"center",bgcolor:d("#fff",.14)},children:e.jsx(Ke,{size:20})}),e.jsxs(i,{sx:{flex:1,minWidth:0},children:[e.jsx(f,{sx:{fontFamily:"Montserrat",fontWeight:700,fontSize:"0.68rem",letterSpacing:"0.08em",textTransform:"uppercase",opacity:.7},children:"Escolha o plano"}),e.jsx(f,{sx:{fontFamily:"Montserrat",fontWeight:700,fontSize:"1.15rem",lineHeight:1.25},children:a.razao_social}),e.jsxs(f,{sx:{fontSize:"0.8rem",opacity:.85,fontWeight:400,mt:.25},children:[a.qtd_certificados," certificados · ",a.qtd_usuarios," usuários · ",r]})]}),e.jsx(Te,{"aria-label":"Fechar",onClick:l,disabled:_,size:"small",sx:{color:d("#fff",.85),"&:hover":{bgcolor:d("#fff",.15),color:"#fff"}},children:e.jsx(X,{size:20})})]}),e.jsx(je,{dividers:!0,sx:{p:{xs:2,md:3},backgroundColor:d(s.cream,.4),borderColor:d(s.greenDark,.08)},children:N&&$?e.jsxs(i,{sx:{py:6,px:{xs:1,md:4},display:"flex",flexDirection:"column",alignItems:"center",gap:2,textAlign:"center"},children:[e.jsx(i,{sx:{width:48,height:48,borderRadius:2.5,display:"flex",alignItems:"center",justifyContent:"center",color:h.feedback.warningFg,bgcolor:d(h.feedback.warningFg,.12)},children:e.jsx(Fe,{size:24})}),e.jsxs(i,{children:[e.jsx(f,{sx:{fontFamily:"Montserrat",fontWeight:800,fontSize:"1.05rem",color:s.greenDark},children:"Este prospect já tem um rascunho aberto"}),e.jsxs(f,{sx:{fontSize:"0.85rem",color:"text.secondary",mt:.75},children:[$.plano_recomendado||"Sem plano"," · ",g($.total_mensal),"/mês"]}),e.jsxs(f,{sx:{fontSize:"0.78rem",color:"text.secondary"},children:["editado ",ve(new Date($.updated_at),{addSuffix:!0,locale:ke})]})]}),e.jsxs(i,{sx:{display:"flex",flexWrap:"wrap",justifyContent:"center",gap:1.5,mt:1},children:[e.jsx(z,{variant:"contained",onClick:U,disabled:v,endIcon:e.jsx(ce,{size:16}),sx:{textTransform:"none",fontWeight:700,borderRadius:"10px",px:2.5,backgroundColor:s.green,color:"#fff","&:hover":{backgroundColor:s.greenMid}},children:"Continuar rascunho"}),e.jsx(z,{onClick:()=>C(!0),disabled:v,startIcon:v?e.jsx(Z,{size:15,color:"inherit"}):e.jsx(we,{size:15}),sx:{textTransform:"none",fontWeight:600,borderRadius:"10px",color:h.feedback.warningFg,border:`1px solid ${d(h.feedback.warningFg,.3)}`,"&:hover":{borderColor:h.feedback.warningFg,backgroundColor:d(h.feedback.warningFg,.06)}},children:"Descartar e começar novo"})]})]}):T?e.jsx(i,{sx:{display:"flex",justifyContent:"center",py:8},children:e.jsx(Z,{})}):n.length===0?e.jsx(i,{sx:{py:8,textAlign:"center",color:"text.secondary"},children:e.jsxs(f,{children:["Nenhuma tabela de preço ativa com planos para a modalidade ",r,"."]})}):e.jsx(i,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},gap:2,overflowX:{md:"auto"},pt:1.5,pb:1.5,"&::-webkit-scrollbar":{height:8},"&::-webkit-scrollbar-thumb":{backgroundColor:d(s.greenDark,.2),borderRadius:8}},children:n.map(t=>{const b=(j==null?void 0:j.plan.nome)===t.plan.nome,S=D===t.plan.nome,te=j?t.total-j.total:0;return e.jsxs(i,{onClick:()=>W(t.plan.nome),role:"button",tabIndex:0,"aria-pressed":S,onKeyDown:ee=>{(ee.key==="Enter"||ee.key===" ")&&(ee.preventDefault(),W(t.plan.nome))},sx:{position:"relative",flex:{md:"1 1 0"},minWidth:{xs:"auto",md:240},cursor:"pointer",backgroundColor:s.cardBg,borderRadius:3,border:`2px solid ${S?s.green:d(s.greenDark,.12)}`,boxShadow:S?`0 0 0 4px ${d(s.green,.14)}, 0 12px 28px -14px ${d(s.greenDark,.4)}`:"0 1px 2px rgba(11, 31, 23, 0.04)",p:2.25,display:"flex",flexDirection:"column",gap:1.5,transition:"border-color 0.15s, box-shadow 0.15s, transform 0.15s","&:hover":{borderColor:S?s.green:d(s.green,.5),transform:"translateY(-2px)"}},children:[e.jsx(i,{sx:{position:"absolute",top:12,right:12,width:22,height:22,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",border:`2px solid ${S?s.green:d(s.greenDark,.25)}`,bgcolor:S?s.green:"transparent",color:"#fff",transition:"background-color 0.15s, border-color 0.15s"},children:S&&e.jsx(oe,{size:13,strokeWidth:3})}),e.jsxs(i,{sx:{alignSelf:"flex-start",display:"inline-flex",alignItems:"center",gap:.5,fontSize:"0.62rem",fontWeight:700,px:1,py:.4,borderRadius:1,bgcolor:b?d(s.green,.15):d("#B91C1C",.1),color:b?s.greenMid:"#B91C1C"},children:[b?e.jsx(oe,{size:12}):e.jsx(X,{size:12}),b?"Recomendado":"Não recomendado"]}),e.jsxs(i,{children:[e.jsxs(f,{sx:{fontWeight:700,fontSize:"1rem",color:s.greenDark},children:[t.plan.nome," ",r]}),e.jsxs(f,{sx:{fontSize:"0.72rem",color:"text.secondary"},children:[t.plan.certs_inclusos," certificados inclusos · ",t.plan.users_inclusos," usuários"]})]}),e.jsxs(me,{title:"Composição do custo",hue:"#4F7BF5",children:[e.jsx(G,{label:"Base do plano",value:g(t.base)}),t.certExc>0?e.jsx(G,{label:`${t.certExc} certs exc. × ${g(t.plan.exc_cert)}`,value:`+ ${g(t.certExcCost)}`,warn:!0}):e.jsx(G,{label:"Sem certs excedentes",value:"R$ 0,00",ok:!0}),t.userExc>0?e.jsx(G,{label:`${t.userExc} users exc. × ${g(t.plan.exc_user)}`,value:`+ ${g(t.userExcCost)}`,warn:!0}):e.jsx(G,{label:"Sem users excedentes",value:"R$ 0,00",ok:!0})]}),e.jsxs(me,{title:"Situação do cliente",hue:Ue.implantacao,children:[e.jsx(G,{label:"Certificados (cliente / plano)",value:`${a.qtd_certificados} / ${t.plan.certs_inclusos}`,warn:t.certExc>0}),e.jsx(G,{label:"Usuários (cliente / plano)",value:`${a.qtd_usuarios} / ${t.plan.users_inclusos}`,warn:t.userExc>0})]}),e.jsxs(i,{children:[e.jsx(f,{sx:{fontSize:"0.62rem",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.05em",color:"text.secondary"},children:"Total mensal estimado"}),e.jsxs(f,{sx:{fontWeight:800,fontSize:"1.5rem",color:b?s.greenMid:s.greenDark,lineHeight:1.1},children:[g(t.total),e.jsx(i,{component:"span",sx:{fontSize:"0.75rem",fontWeight:500,color:"text.secondary"},children:"/mês"})]})]}),e.jsx(i,{sx:{mt:"auto",p:1.25,borderRadius:1.5,backgroundColor:d(s.greenDark,.04),fontSize:"0.72rem",color:"text.secondary"},children:b?e.jsx(e.Fragment,{children:"Melhor custo-benefício para o perfil atual."}):te>0?e.jsxs(e.Fragment,{children:["Custa ",e.jsxs("strong",{children:[g(te),"/mês a mais"]})," que o plano recomendado."]}):e.jsx(e.Fragment,{children:"Mesmo custo do plano recomendado."})})]}
97,t.plan.id)})})}),e.jsx(ye,{sx:{px:{xs:2,md:3.5},py:2,gap:1.5,backgroundColor:s.cardBg,borderTop:`1px solid ${d(s.greenDark,.08)}`},children:N?e.jsx(z,{onClick:l,startIcon:e.jsx(X,{size:16}),sx:{ml:"auto",textTransform:"none",fontWeight:600,color:d(s.greenDark,.7)},children:"Fechar"}):e.jsxs(e.Fragment,{children:[e.jsx(i,{sx:{flex:1,minWidth:0,display:{xs:"none",sm:"block"}},children:q?e.jsxs(f,{sx:{fontSize:"0.82rem",color:"text.secondary"},children:["Plano selecionado:"," ",e.jsxs(i,{component:"span",sx:{fontWeight:700,color:s.greenDark},children:[q.plan.nome," ",r]})," ","·"," ",e.jsxs(i,{component:"span",sx:{fontWeight:700,color:s.greenMid},children:[g(q.total),"/mês"]})]}):e.jsx(f,{sx:{fontSize:"0.82rem",color:"text.secondary"},children:"Selecione um plano para continuar."})}),e.jsx(z,{onClick:u,disabled:_||n.length===0,startIcon:e.jsx(Ze,{size:16}),sx:{textTransform:"none",fontWeight:600,borderRadius:"10px",color:s.greenDark,border:`1px solid ${d(s.greenDark,.25)}`,"&:hover":{borderColor:s.green,backgroundColor:d(s.green,.06)}},children:"Imprimir"}),e.jsx(z,{onClick:l,disabled:_,startIcon:e.jsx(X,{size:16}),sx:{textTransform:"none",fontWeight:600,color:d(s.greenDark,.7)},children:"Fechar"}),e.jsx(z,{variant:"contained",onClick:x,disabled:_||!D,startIcon:_?e.jsx(Z,{size:16,color:"inherit"}):void 0,endIcon:_?void 0:e.jsx(ce,{size:16}),sx:{textTransform:"none",fontWeight:700,borderRadius:"10px",px:2.5,backgroundColor:s.green,color:"#fff","&:hover":{backgroundColor:s.greenMid}},children:_?"Carregando…":"Próximo"})]})})]}),e.jsx($e,{open:B,onClose:()=>C(!1),onConfirm:I,tone:"danger",title:p.length>1?"Descartar rascunhos":"Descartar rascunho",description:p.length>1?`Os ${p.length} rascunhos deste prospect serão perdidos definitivamente. Esta ação não pode ser desfeita.`:"O rascunho atual será perdido definitivamente. Esta ação não pode ser desfeita.",confirmLabel:"Descartar",loading:v})]})}function me({title:o,hue:l,children:a}){return e.jsxs(i,{children:[e.jsx(f,{sx:{fontSize:"0.6rem",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.05em",color:d(l,.9),mb:.5},children:o}),e.jsx(i,{sx:{display:"flex",flexDirection:"column",gap:.4},children:a})]})}function G({label:o,value:l,warn:a,ok:p}){const{color:m}=fe(J().palette.mode);return e.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",gap:1,fontSize:"0.74rem"},children:[e.jsx(f,{sx:{fontSize:"inherit",color:"text.secondary"},children:o}),e.jsx(f,{sx:{fontSize:"inherit",fontWeight:700,whiteSpace:"nowrap",color:a?m.feedback.warningFg:p?m.feedback.successFg:"text.primary"},children:l})]})}const uo=10*1024*1024,fo=(o,l,a)=>{const p=Math.max(0,l-o.certs_inclusos),m=Math.max(0,a-o.users_inclusos),s=p*(Number(o.exc_cert)||0)+m*(Number(o.exc_user)||0);return{certExc:p,userExc:m,excedente:s,base:Number(o.valor_sugerido)||0}},ho=o=>Number(o.replace(/\./g,"").replace(",","."));function go({open:o,onClose:l,prospect:a,onSent:p}){const m=Q(),s=J(),h=se(),k=c.useRef(null),[F,E]=c.useState([]),[A,T]=c.useState(!0),[y,D]=c.useState(null),[W,_]=c.useState(""),[L,M]=c.useState(""),[H,v]=c.useState(null),[R,B]=c.useState(!1);c.useEffect(()=>{o&&(D(null),_(""),M(""),v(null),T(!0),Se.active().then(x=>{E(x.planos.filter(r=>r.modalidade===a.modalidade).sort((r,q)=>r.ordem-q.ordem))}).catch(()=>E([])).finally(()=>T(!1)))},[o,a.modalidade]);const C=c.useMemo(()=>F.find(x=>x.nome===W)??null,[F,W]),n=c.useMemo(()=>C?fo(C,a.qtd_certificados,a.qtd_usuarios):null,[C,a.qtd_certificados,a.qtd_usuarios]);c.useEffect(()=>{n&&M((n.base+n.excedente).toFixed(2).replace(".",","))},[n]);const j=ho(L),$=n?j-(n.base+n.excedente):0,N=x=>{if(x){if(!x.name.toLowerCase().endsWith(".pdf")){v("Envie o orçamento em PDF.");return}if(x.size>uo){v("Arquivo muito grande (máximo 10 MB).");return}v(null),D(x)}},U=async()=>{if(!y||!C||!n)return;if(!Number.isFinite(j)||j<=0){v("Informe o total mensal fechado com o cliente.");return}
97if(j<n.excedente){v(`O mensal informado não cobre o excedente deste volume (${g(n.excedente)}). Confira o plano escolhido.`);return}const x=Number(C.valor_minimo)||0;if(j-n.excedente<x){v(`A mensalidade do plano ficaria em ${g(j-n.excedente)}, abaixo do mínimo de negociação de ${g(x)} deste plano.`);return}B(!0),v(null);try{await K.uploadExternal({prospectId:a.id,plano:C.nome,totalMensal:j.toFixed(2),pdf:y}),h.success("Orçamento registrado."),p==null||p(),l()}catch(r){v(Pe(r,"Não foi possível registrar o orçamento."))}finally{B(!1)}},I=!A&&F.length===0;return e.jsxs(ge,{open:o,onClose:R?void 0:l,maxWidth:"sm",fullWidth:!0,children:[e.jsxs(be,{sx:{pb:1.5},children:[e.jsx(f,{variant:"caption",sx:{display:"block",fontSize:"0.68rem",letterSpacing:"0.08em",textTransform:"uppercase",opacity:.7},children:"Orçamento pronto"}),e.jsx(f,{sx:{fontSize:"1.15rem",fontWeight:800},children:a.razao_social}),e.jsx(f,{variant:"caption",color:"text.secondary",children:"Para orçamentos montados fora do sistema. O PDF é o seu; o plano e o valor ficam registrados para que a conversão em cliente já saia com a assinatura certa."})]}),e.jsx(je,{dividers:!0,children:A?e.jsx(i,{sx:{display:"flex",justifyContent:"center",py:4},children:e.jsx(Z,{size:28})}):I?e.jsx(ae,{severity:"warning",children:"Não há plano nesta modalidade na tabela de preços ativa. Ative uma tabela em Comercial > Tabelas de Preço antes de registrar o orçamento."}):e.jsxs(e.Fragment,{children:[e.jsxs(i,{onDragOver:x=>x.preventDefault(),onDrop:x=>{var r;x.preventDefault(),N((r=x.dataTransfer.files)==null?void 0:r[0])},sx:{borderRadius:2,border:`1px dashed ${d(m.greenDark,.25)}`,backgroundColor:d(m.green,.04),px:2,py:y?1.5:3,display:"flex",alignItems:"center",gap:1.5,justifyContent:y?"space-between":"center",textAlign:"center"},children:[y?e.jsxs(e.Fragment,{children:[e.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:1.25,minWidth:0},children:[e.jsx(ze,{size:20,color:m.green}),e.jsxs(i,{sx:{minWidth:0},children:[e.jsx(f,{variant:"body2",fontWeight:700,noWrap:!0,children:y.name}),e.jsxs(f,{variant:"caption",color:"text.secondary",children:[(y.size/1024/1024).toFixed(1)," MB"]})]})]}),e.jsx(z,{size:"small",startIcon:e.jsx(X,{size:14}),onClick:()=>D(null),children:"Trocar"})]}):e.jsxs(i,{children:[e.jsx(z,{variant:"outlined",startIcon:e.jsx(Ce,{size:16}),onClick:()=>{var x;return(x=k.current)==null?void 0:x.click()},children:"Escolher o PDF"}),e.jsx(f,{variant:"caption",color:"text.secondary",sx:{display:"block",mt:1},children:"ou arraste o arquivo aqui. Até 10 MB."})]}),e.jsx("input",{ref:k,type:"file",accept:"application/pdf,.pdf",hidden:!0,onChange:x=>{var r;return N((r=x.target.files)==null?void 0:r[0])}})]}),e.jsx(re,{select:!0,fullWidth:!0,label:"Plano vendido",value:W,onChange:x=>_(x.target.value),sx:{mt:2.5},helperText:`Volume do cliente: ${a.qtd_certificados} certificados e ${a.qtd_usuarios} usuários, do cadastro do lead.`,children:F.map(x=>e.jsx(Qe,{value:x.nome,children:`${x.nome} · ${x.certs_inclusos} certificados | ${x.users_inclusos} usuários`},x.id??x.nome))}),e.jsx(re,{fullWidth:!0,label:"Total mensal fechado",value:L,onChange:x=>M(x.target.value),disabled:!C,sx:{mt:2},InputProps:{startAdornment:e.jsx(i,{component:"span",sx:{mr:1,color:"text.secondary"},children:"R$"})}}),n&&e.jsxs(i,{sx:{mt:1.5,px:2,py:1.25,borderRadius:2,backgroundColor:s.palette.action.hover},children:[e.jsxs(f,{variant:"caption",color:"text.secondary",sx:{display:"block"},children:["Pela tabela: plano ",g(n.base),n.certExc>0&&` + ${n.certExc} certificados excedentes`,n.userExc>0&&` + ${n.userExc} usuários excedentes`,n.excedente>0&&` (${g(n.excedente)})`," = ",e.jsx(i,{component:"span",sx:{fontWeight:700},children:g(n.base+n.excedente)})]}),Number.isFinite($)&&Math.abs($)>=.01&&e.jsx(f,{variant:"caption",sx:{display:"block",mt:.5,fontWeight:700},children:$<0?`Desconto de ${g(Math.abs($))} sobre a tabela.`:`Acréscimo de ${g($)} sobre a tabela.`})]}),H&&e.jsx(ae,{severity:"error",sx:{mt:2},children:H})]})}),e.jsxs(ye,{sx:{px:3,py:2},children:[e.jsx(z,{onClick:l,disabled:R,children:"Cancelar"}),e.jsx(z,{variant:"contained",startIcon:R?e.jsx(Z,{size:14,color:"inherit"}):e.jsx(oe,{size:16}),onClick:U,disabled:R||!y||!C,children:"Registrar orçamento"})]})]})}const bo=o=>o==="WEB"?"Web":"On-premise",jo=o=>o?o.replace(/\D/g,"").replace(/(\d{5})(\d{3})/,"$1-$2"):"-",ue=o=>o?new Date(o).toLocaleDateString("pt-BR"):"-",vo=o=>
97o?`editado ${ve(new Date(o),{addSuffix:!0,locale:ke})}`:"-";function P({label:o,value:l}){const a=Q();return e.jsxs(i,{children:[e.jsx(f,{sx:{fontSize:"0.62rem",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.05em",color:d(a.greenDark,.5),mb:.25},children:o}),e.jsx(f,{variant:"body2",sx:{color:a.greenDark,fontWeight:500},component:"div",children:l==null||l===""?"-":l})]})}function Y({icon:o,title:l,children:a}){const p=Q();return e.jsxs(De,{sx:{borderRadius:2,border:`1px solid ${d(p.greenDark,.1)}`,overflow:"hidden",mb:2.5},children:[e.jsxs(i,{sx:{px:2.5,py:1.75,borderBottom:`1px solid ${d(p.greenDark,.08)}`,borderLeft:`4px solid ${p.green}`,display:"flex",alignItems:"center",gap:1.25},children:[e.jsx(o,{size:17,color:p.green}),e.jsx(f,{variant:"subtitle2",fontWeight:700,sx:{color:p.greenDark,textTransform:"uppercase",letterSpacing:"0.04em"},children:l})]}),e.jsx(i,{sx:{p:2.5},children:a})]})}function ls(){const o=Q(),l=J().palette.common.white,a={borderRadius:"10px",textTransform:"none",fontWeight:700,color:l,borderColor:d(l,.5),"&:hover":{borderColor:l,backgroundColor:d(l,.1)}},p=se(),{id:m}=Re(),s=he(),[h,k]=c.useState(null),[F,E]=c.useState(!0),[A,T]=c.useState(!1),[y,D]=c.useState(!1),[W,_]=c.useState(!1),[L,M]=c.useState(!1),[H]=We(),[v,R]=c.useState(H.get("tab")==="orcamentos"?"orcamentos":"detalhes"),[B,C]=c.useState([]),[n,j]=c.useState(null),[$,N]=c.useState(!1),U=c.useCallback(()=>{E(!0),Oe.get(Number(m)).then(k).finally(()=>E(!1))},[m]);c.useEffect(U,[U]);const I=c.useCallback(()=>{K.list().then(u=>{const t=u.results.filter(b=>b.prospect===Number(m));t.sort((b,S)=>b.status!==S.status?b.status==="RASCUNHO"?-1:1:b.status==="RASCUNHO"?new Date(S.updated_at).getTime()-new Date(b.updated_at).getTime():S.numero.localeCompare(b.numero)),C(t)}).catch(()=>{})},[m]);c.useEffect(I,[I]);const x=async()=>{if(n){N(!0);try{await K.remove(n.id),p.success("Orçamento excluído."),j(null),I()}catch{p.error("Não foi possível excluir o orçamento.")}finally{N(!1)}}};if(F||!h)return e.jsx(qe,{variant:"card"});const r=h,q=Ae(r.razao_social,r.nome_fantasia);return e.jsxs(i,{sx:{pb:4},"data-testid":"prospect-detail-page",children:[e.jsx(z,{variant:"text",startIcon:e.jsx(Ye,{size:16}),onClick:()=>s("/adm/prospects"),sx:{mb:2},children:"Voltar"}),e.jsx(Ge,{dataTour:"adm-prospect-hero",breadcrumb:[{label:"Prospects",to:"/adm/prospects"},{label:r.razao_social||"Sem nome"}],title:r.razao_social,uppercaseTitle:!0,subtitle:e.jsxs(e.Fragment,{children:[q&&e.jsx(i,{component:"span",sx:{display:"block",fontWeight:600,opacity:.92},children:q}),`${Me(r.documento)||"Sem documento"} · ${bo(r.modalidade)} · Cadastrado em ${ue(r.created_at)}`]}),icon:ne,action:e.jsxs(e.Fragment,{children:[e.jsx(z,{variant:"outlined",startIcon:e.jsx(de,{size:16}),onClick:()=>T(!0),sx:a,children:"Editar"}),e.jsx(z,{variant:"outlined",startIcon:e.jsx(Je,{size:16}),onClick:()=>M(!0),sx:a,children:"Converter em cliente"}),e.jsx(z,{variant:"outlined",startIcon:e.jsx(Ce,{size:16}),onClick:()=>_(!0),sx:a,children:"Enviar PDF"}),e.jsx(Be,{startIcon:e.jsx(lo,{size:16}),onClick:()=>D(!0),children:"Gerar Orçamento"}),e.jsx(Ve,{onStepChange:u=>{u===2&&R("orcamentos")}})]})}),e.jsx(i,{"data-tour":"adm-prospect-tabs",sx:{borderBottom:`1px solid ${d(o.greenDark,.1)}`,mb:2.5},children:e.jsxs(eo,{value:v,onChange:(u,t)=>R(t),sx:{"& .MuiTabs-indicator":{backgroundColor:o.green}},children:[e.jsx(xe,{label:"Detalhes",value:"detalhes",sx:{textTransform:"none",fontWeight:700}}),e.jsx(xe,{label:`Orçamentos (${B.length})`,value:"orcamentos",sx:{textTransform:"none",fontWeight:700}})]})}),e.jsx(i,{"data-tour":"adm-prospect-panel",children:v==="detalhes"?e.jsxs(e.Fragment,{children:[e.jsx(Y,{icon:ne,title:"Dados cadastrais",children:e.jsxs(w,{container:!0,spacing:2.5,children:[e.jsx(w,{item:!0,xs:12,children:e.jsx(P,{label:"Razão social",value:e.jsx(i,{component:"span",sx:{textTransform:"uppercase"},children:r.razao_social})})}),e.jsx(w,{item:!0,xs:12,sm:6,children:e.jsx(P,{label:"Telefone",value:Ie(r.telefone)})}),e.jsx(w,{item:!0,xs:12,sm:6,children:e.jsx(P,{label:"E-mail",value:r.email})})]})}),e.jsx(Y,{icon:oo,title:"Endereço",children:e.jsxs(w,{container:!0,spacing:2.5,children:[e.jsx(w,{item:!0,xs:12,sm:6,children:e.jsx(P,{label:"Endereço",value:r.endereco})}),e.jsx(w,{item:!0,xs:6,sm:2,children:e.jsx(P,{label:"Nº",value:r.numero})}),e.jsx(w,{item:!0,xs:6,sm:4,children:e.jsx(P,{label:"Bairro",value:r.bairro})}),e.jsx(w,{item:!0,xs:12,sm:4,children:e.jsx(P,{label:"Complemento",value:r.complemento})}),e.jsx(w,{item:!0,xs:12,sm:4,children:e.jsx(P,{label:"Cidade",value:r.cidade})}),e.jsx(w,{item:!0,xs:6,sm:2,children:e.jsx(P,{label:"Estado",value:r.estado})}),e.jsx(w,{item:!0,xs:6,sm:2,children:e.jsx(P,{label:"CEP",value:jo(r.cep)})})]})}),e.jsx(Y,{icon:so,title:"Volume do cliente",children:e.jsxs(w,{container:!0,spacing:2.5,children:[e.jsx(w,{item:!0,xs:6,sm:4,children:e.jsx(P,{label:"Certificados",value:r.qtd_certificados??0})}),e.jsx(w,{item:!0,xs:6,sm:4,children:e.jsx(P,{label:"Usuários",value:r.qtd_usuarios??0})})]})}),r.observacoes&&e.jsx(Y,{icon:ze,title:"Observações",children:e.jsx(f,{variant:"body2",sx:{color:o.greenDark,whiteSpace:"pre-wrap"},children:r.observacoes})})]}):e.jsx(De,{sx:{borderRadius:2,border:`1px solid ${d(o.greenDark,.1)}`,overflow:"hidden"},children:B.length===0?e.jsx(i,{sx:{py:6,px:3},children:e.jsx(Ne,{title:"Nenhum orçamento",description:'Clique em "Gerar Orçamento" para montar um aqui, ou em "Enviar PDF" para registrar um que você já fez por fora.'})}):e.jsx(to,{children:e.jsxs(ao,{children:[e.jsx(ro,{children:e.jsx(pe,{children:["Número","Status","Total mensal","Atualizado",""].map((u,t)=>e.jsx(V,{align:t===4?"right":"left",children:u},u||"acoes"))})}),e.jsx(no,{children:B.map((u,t)=>e.jsxs(pe,{hover:!0,sx:{backgroundColor:t%2===0?o.cardBg:d(o.cream,.35)},children:[e.jsxs(V,{sx:{fontWeight:700,color:o.greenDark},children:[u.numero||`#${u.id}
97`,u.origem==="ENVIADO"&&e.jsx(f,{variant:"caption",sx:{display:"block",fontWeight:600,color:d(o.greenDark,.55)},children:"PDF enviado"})]}),e.jsx(V,{children:u.status==="FINALIZADA"?e.jsx(le,{tone:"success",label:"Finalizada",size:"sm",withDot:!0}):e.jsx(le,{tone:"warning",label:"Rascunho",size:"sm"})}),e.jsx(V,{children:g(u.total_mensal)}),e.jsx(V,{children:u.status==="RASCUNHO"?vo(u.updated_at):ue(u.updated_at)}),e.jsxs(V,{align:"right",sx:{whiteSpace:"nowrap"},children:[u.status==="RASCUNHO"?e.jsx(z,{size:"small",startIcon:e.jsx(de,{size:15}),onClick:()=>s(`/adm/proposals/${u.id}/edit`),sx:{textTransform:"none",fontWeight:700,color:o.greenMid},children:"Continuar"}):e.jsx(ie,{"aria-label":"Abrir PDF do orçamento",disabled:!u.pdf_url,onClick:()=>u.pdf_url&&window.open(u.pdf_url,"_blank","noopener"),children:e.jsx(io,{size:18})}),e.jsx(ie,{"aria-label":"Excluir orçamento",tone:"danger",onClick:()=>j(u),children:e.jsx(we,{size:18})})]})]},u.id))})]})})})}),e.jsx(Le,{open:A,onClose:()=>T(!1),onSaved:U,initial:r}),e.jsx(mo,{open:y,onClose:()=>D(!1),prospect:r,drafts:B.filter(u=>u.status==="RASCUNHO"),onDraftsChanged:I}),e.jsx(go,{open:W,onClose:()=>_(!1),prospect:r,onSent:()=>{I(),R("orcamentos")}}),e.jsx(He,{open:L,prospect:r,onClose:()=>M(!1),onConverted:u=>{M(!1),s(`/adm/clients/${u}`)}}),e.jsx($e,{open:!!n,tone:"danger",title:"Excluir orçamento",description:`Excluir o orçamento ${(n==null?void 0:n.numero)||""}?`,confirmLabel:"Excluir",loading:$,onConfirm:x,onClose:()=>j(null)})]})}export{ls as default};

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.