1import{j as e}from"./vendor-ui-bootstrap-613dad89.js";import{r}from"./vendor-react-4c7f50f2.js";import{u as ce}from"./main-722823a7.js";import{a as U}from"./api.service-846da950.js";import{R as de,B as me,a as ue,g as he,A as xe,f as pe,d as fe,X as je,Y as ge,T as ve}from"./vendor-charts-6c028842.js";import{f as re,t as Ne,e as be}from"./rankingCertificados-29cc0ca2.js";import"./vendor-ui-material-b69ee68f.js";import"./vendor-firebase-7ea6fd91.js";import"./vendor-utils-de6b936e.js";const W="/dashboards/emissao-certificados";class Se{async getSerieDiaria({dias:n,federacaoId:i}={}){const c={};n&&(c.dias=n),i&&(c.federacaoId=i);const{data:s}=await U.get(`${W}/serie-diaria`,{params:c});return s}async getLista({pageSize:n,cursor:i,federacaoId:c}={}){const s={};n&&(s.pageSize=n),i&&(s.cursor=i),c&&(s.federacaoId=c);const{data:j}=await U.get(`${W}/lista`,{params:s});return j}async getRankingGub({ano:n,federacaoId:i}={}){const c={};n&&(c.ano=n),i&&(c.federacaoId=i);const{data:s}=await U.get(`${W}/ranking-gub`,{params:c});return s}async getTotal({federacaoId:n}={}){const i={};n&&(i.federacaoId=n);const{data:c}=await U.get(`${W}/total`,{params:i});return c}}const V=new Se;const H="#0d9488",ke=[{valor:7,label:"Ãltimos 7 dias"},{valor:15,label:"Ãltimos 15 dias"},{valor:30,label:"Ãltimos 30 dias"},{valor:60,label:"Ãltimos 60 dias"},{valor:90,label:"Ãltimos 90 dias"},{valor:180,label:"Ãltimos 180 dias"},{valor:365,label:"Ãltimos 12 meses"}],Ce=[10,25,50];function ye(o){const[,n,i]=o.split("-");return`${i}/${n}`}function se(o){const[n,i,c]=o.split("-");return`${c}/${i}/${n}`}function Ee(o){if(!o)return{data:"â",hora:null};const n=new Date(o);return Number.isNaN(n.getTime())?{data:"â",hora:null}:{data:n.toLocaleDateString("pt-BR",{timeZone:"America/Sao_Paulo"}),hora:n.toLocaleTimeString("pt-BR",{timeZone:"America/Sao_Paulo",hour:"2-digit",minute:"2-digit"})}}function Re({badge:o,dias:n=30,onDiasChange:i,serie:c=[],kpis:s={},truncado:j=!1,diaParcial:b=!1,diasCobertos:y=null,itens:p=[],pageSize:w=10,onPageSizeChange:E,pagina:R=1,temProxima:L=!1,onAnterior:B,onProxima:$,total:m=null,loadingSerie:g=!1,loadingLista:S=!1,erroFatal:v=null,erroSerie:P=null,erroLista:d=null,onRecarregarSerie:A,onRecarregarLista:a,children:h=null,exibirLinhaDoTempo:f=!0,atualizadoEm:k=null}){var K,D;const N=r.useMemo(()=>c.map(t=>({...t,rotulo:ye(t.dia)})),[c]),G=n<=90,O=G&&N.length<=15,Y=G?Math.max(0,Math.ceil(N.length/15)-1):Math.max(0,Math.ceil(N.length/12)-1),I=({active:t,payload:x})=>{if(!t||!x||!x.length)return null;const C=x[0].payload;return e.jsxs("div",{className:"dec-tooltip",children:[e.jsx("strong",{children:se(C.dia)}),e.jsxs("div",{children:[C.quantidade.toLocaleString("pt-BR")," ",C.quantidade===1?"certificado":"certificados"]})]})},X=[e.jsx(fe,{vertical:!1,stroke:"var(--dec-border)",strokeDasharray:"3 3"},"grid"),e.jsx(je,{dataKey:"rotulo",interval:Y,tick:{fill:"var(--dec-ink-3)",fontSize:11.5},axisLine:!1,tickLine:!1,minTickGap:4},"x"),e.jsx(ge,{allowDecimals:!1,width:40,tick:{fill:"var(--dec-ink-3)",fontSize:11.5},axisLine:!1,tickLine:!1},"y"),e.jsx(ve,{cursor:{fill:"var(--dec-accent-soft)"},content:I},"tooltip")],M=j&&y?y:n,_=M===1?"1 dia":`${M.toLocaleString("pt-BR")} dias`,q=p.length?(R-1)*w+1:0,Z=p.length?q+p.length-1:0,T=(t,x)=>e.jsxs("div",{className:"dec-error",children:[e.jsx("div",{children:t}),x?e.jsx("button",{type:"button",className:"dec-btn mt-3",onClick:x,style:{marginTop:12},children:"Tentar novamente"}):null]});return e.jsxs("div",{className:"dec-wrap",children:[e.jsxs("div",{className:"dec-header",children:[e.jsxs("div",{children:[o?e.jsx("span",{className:"dec-badge",children:o}):null,e.jsx("h2",{className:"dec-title",children:"Emissão de Certificados"}),e.jsx("p",{className:"dec-subtitle",children:f?"Certificados efetivamente gerados na federação â volume diário e linha do tempo das emissões mais recentes.":"Certificados efetivamente gerados na federação â volume diário de emissões."}),k?e.jsxs("p",{className:"dec-updated",children:["Números calculados em ",k," · atualizados a cada 6 horas"]}):null]}),e.jsx("div",{className:"dec-filters",children:e.jsxs("label",{className:"dec-field",children:["PerÃodo",e.jsx("select",{value:n,onChange:t=>i(Number(t.target.value)),disabled:g,children:ke.map(t=>e.jsx("option",{value:t.valor,children:t.label},t.valor))})]})})]}),v?e.jsx("div",{className:"dec-error",children:v}):e.jsxs(e.Fragment,{children:[j?e.jsxs("div",{className:"dec-alert",children:[e.jsx("span",{className:"material-icons-outlined",children:"warning_amber"}),e.jsxs("span",{children:["O perÃodo selecionado ultrapassou o limite de leitura do relatório.",b?e.jsxs(e.Fragment,{children:[" ","O volume é tão alto que o limite se esgotou dentro de um único dia: o gráfico mostra ",e.jsx("strong",{children:"apenas esse dia, e incompleto"}),"."]}):e.jsxs(e.Fragment,{children:[" ","O gráfico e os indicadores abaixo cobrem apenas os"," ",e.jsxs("strong",{children:["últimos ",_]}),", não os ",n," pedidos â os dias mais antigos ficaram fora da leitura."]})," ","Reduza o perÃodo para obter números exatos."]})]}):null,e.jsxs("div",{className:"dec-kpis",children:[e.jsxs("div",{className:"dec-kpi",children:[e.jsx("div",{className:"dec-kpi-label",children:"Emitidos no perÃodo"}),e.jsx("div",{className:"dec-kpi-value",children:(s.total??0).toLocaleStr
1ing("pt-BR")}),e.jsxs("div",{className:"dec-kpi-hint",children:["Ãltimos ",_]})]}),e.jsxs("div",{className:"dec-kpi",children:[e.jsx("div",{className:"dec-kpi-label",children:"Média diária"}),e.jsx("div",{className:"dec-kpi-value",children:(s.mediaDiaria??0).toLocaleString("pt-BR")}),e.jsxs("div",{className:"dec-kpi-hint",children:[(s.diasComEmissao??0).toLocaleString("pt-BR")," dia(s) com emissão"]})]}),e.jsxs("div",{className:"dec-kpi",children:[e.jsx("div",{className:"dec-kpi-label",children:"Maior volume em um dia"}),e.jsx("div",{className:"dec-kpi-value",children:(((K=s.pico)==null?void 0:K.quantidade)??0).toLocaleString("pt-BR")}),e.jsx("div",{className:"dec-kpi-hint",children:(D=s.pico)!=null&&D.dia?se(s.pico.dia):"â"})]}),e.jsxs("div",{className:"dec-kpi",children:[e.jsx("div",{className:"dec-kpi-label",children:"Total acumulado"}),e.jsx("div",{className:"dec-kpi-value",children:m===null?"â":m.toLocaleString("pt-BR")}),e.jsx("div",{className:"dec-kpi-hint",children:"Histórico completo da federação"})]})]}),e.jsxs("div",{className:"dec-panel",children:[e.jsx("div",{className:"dec-panel-head",children:e.jsxs("div",{children:[e.jsx("h3",{className:"dec-panel-title",children:"Certificados emitidos por dia"}),e.jsxs("p",{className:"dec-panel-sub",children:["Quantidade de certificados concluÃdos a cada dia nos últimos ",_,"."]})]})}),g?e.jsx("div",{className:"dec-loading",children:"Carregando gráficoâ¦"}):P?T(P,A):e.jsx(de,{width:"100%",height:300,children:G?e.jsxs(me,{data:N,margin:{top:16,right:12,bottom:4,left:0},children:[X,e.jsx(ue,{dataKey:"quantidade",fill:H,radius:[4,4,0,0],maxBarSize:26,isAnimationActive:!1,children:O?e.jsx(he,{dataKey:"quantidade",position:"top",formatter:t=>t>0?t.toLocaleString("pt-BR"):"",style:{fill:"var(--dec-ink-3)",fontSize:11.5,fontWeight:700}}):null})]}):e.jsxs(xe,{data:N,margin:{top:16,right:12,bottom:4,left:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"decAreaFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:H,stopOpacity:.28}),e.jsx("stop",{offset:"100%",stopColor:H,stopOpacity:.02})]})}),X,e.jsx(pe,{type:"monotone",dataKey:"quantidade",stroke:H,strokeWidth:2,fill:"url(#decAreaFill)",dot:!1,activeDot:{r:4,strokeWidth:2,stroke:"var(--dec-surface)"},isAnimationActive:!1})]})})]}),f?e.jsxs("div",{className:"dec-panel",children:[e.jsxs("div",{className:"dec-panel-head",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"dec-panel-title",children:"Linha do tempo das emissões"}),e.jsx("p",{className:"dec-panel-sub",children:"Certificados gerados na federação, do mais recente para o mais antigo."})]}),e.jsxs("label",{className:"dec-field",children:["Por página",e.jsx("select",{value:w,onChange:t=>E(Number(t.target.value)),disabled:S,children:Ce.map(t=>e.jsx("option",{value:t,children:t},t))})]})]}),S?e.jsx("div",{className:"dec-loading",children:"Carregando emissõesâ¦"}):d?T(d,a):p.length===0?e.jsx("div",{className:"dec-empty",children:"Nenhum certificado emitido encontrado para esta federação."}):e.jsx("div",{className:"dec-table-scroll",children:e.jsxs("table",{className:"dec-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{width:120},children:"Emitido em"}),e.jsx("th",{children:"Praticante"}),e.jsx("th",{children:"Graduação"}),e.jsx("th",{children:"Mestre examinador"}),e.jsx("th",{className:"dec-num",style:{width:90},children:"Nº seq."}),e.jsx("th",{style:{width:110},children:"Certificado"})]})}),e.jsx("tbody",{children:p.map(t=>{const{data:x,hora:C}=Ee(t.emitidoEm);return e.jsxs("tr",{children:[e.jsxs("td",{className:"dec-when",children:[x,C?e.jsx("small",{children:C}):null]}),e.jsxs("td",{children:[e.jsx("div",{style:{fontWeight:600},children:t.praticante}),t.matricula?e.jsxs("div",{style:{fontSize:"0.78rem",color:"var(--dec-ink-3)"},children:["MatrÃcula ",t.matricula]}):null,t.associacao?e.jsx("div",{style:{fontSize:"0.78rem",color:"var(--dec-ink-3)"},children:t.associacao}):null]}),e.jsx("td",{children:t.graduacao||e.jsx("span",{className:"dec-muted",children:"â"})}),e.jsx("td",{children:t.mestreExaminador||e.jsx("span",{className:"dec-muted",children:"â"})}),e.jsx("td",{className:"dec-num",children:t.numeroSequencialAnual??e.jsx("span",{className:"dec-muted",children:"â"})}),e.jsx("td",{children:t.certificadoUrl?e.jsx("a",{className:"dec-link",href:t.certificadoUrl,target:"_blank",rel:"noopener noreferrer",children:"Abrir PDF"}):e.jsx("span",{className:"dec-muted",children:"â"})})]},t.id)})})]})}),e.jsxs("div",{className:d?"d-none":"dec-pagination",children:[e.jsx("div",{className:"dec-p
1agination-info",children:p.length===0?"Nenhum registro":`Exibindo ${q.toLocaleString("pt-BR")}â${Z.toLocaleString("pt-BR")}${m!==null?` de ${m.toLocaleString("pt-BR")}`:""}`}),e.jsxs("div",{className:"dec-pagination-actions",children:[e.jsx("button",{type:"button",className:"dec-btn",onClick:B,disabled:S||R<=1,children:"Anterior"}),e.jsxs("span",{className:"dec-pagination-info",children:["Página ",R]}),e.jsx("button",{type:"button",className:"dec-btn",onClick:$,disabled:S||!L,children:"Próxima"})]})]})]}):null,h]})]})}const te=new Date().getFullYear(),z=!1,Ae=!1;function De({federacaoId:o,sigla:n}){var A;const[i,c]=r.useState(te),[s,j]=r.useState(null),[b,y]=r.useState(!0),[p,w]=r.useState(null),[E,R]=r.useState(null),L=r.useCallback(async()=>{var a,h;if(!o){y(!1);return}y(!0);try{const f=await V.getRankingGub({ano:i,federacaoId:o});j(f),w(null)}catch(f){console.error("Erro ao carregar ranking de GUB:",f),j(null),w(((h=(a=f==null?void 0:f.response)==null?void 0:a.data)==null?void 0:h.error)||"Não foi possÃvel carregar o ranking. Verifique seu acesso e tente novamente.")}finally{y(!1)}},[i,o]);r.useEffect(()=>{L()},[L]);const B=async a=>{if(s){R(a);try{await be(a,s,{sigla:n,prefixoArquivo:"ranking-gub",detalharOrigem:z})}catch(h){console.error(`Erro ao exportar ranking (${a}):`,h),alert("Não foi possÃvel gerar o arquivo. Tente novamente.")}finally{R(null)}}},$=[...new Set([i,te,...((A=s==null?void 0:s.kpis)==null?void 0:A.anosDisponiveis)||[]])].sort((a,h)=>h-a),m=(s==null?void 0:s.escopo)==="cbtkd",g=m?((s==null?void 0:s.federacoes)||[]).map(a=>({id:a.federacaoId,nome:a.sigla||a.nome,detalhe:`${a.sigla?`${a.nome} · `:""}${a.qtdMestres} mestre(s)`,contador:a.contador??0,saldoInicial:a.saldoInicial??0,total:a.total})):((s==null?void 0:s.ranking)||[]).map(a=>({id:a.mestreId,nome:a.nome,detalhe:null,contador:a.contador??0,saldoInicial:a.saldoInicial??0,total:a.total})),S=g.length?g[0].total:0,v=(s==null?void 0:s.kpis)||{},P=re(s==null?void 0:s.geradoEm),d=a=>(a??0).toLocaleString("pt-BR");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"dec-panel",children:[e.jsxs("div",{className:"dec-panel-head",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"dec-panel-title",children:m?"Certificados de GUB por federação":"Ranking de mestres â GUBs"}),e.jsxs("p",{className:"dec-panel-sub",children:[m?"Certificados de faixas coloridas por federação no ano, somando os mestres filiados a cada uma.":z?"Certificados de faixas coloridas por mestre no ano: emitidos pelo sistema mais o saldo inicial registrado no histórico dos alunos.":"Certificados de faixas coloridas por mestre no ano.",P?` Calculado em ${P} · atualizado a cada 6 horas.`:""]})]}),e.jsxs("div",{className:"dec-filters",children:[e.jsxs("label",{className:"dec-field",children:["Ano",e.jsx("select",{value:i,onChange:a=>c(Number(a.target.value)),disabled:b,children:$.map(a=>e.jsx("option",{value:a,children:a},a))})]}),e.jsxs("button",{type:"button",className:"dec-btn",onClick:()=>B("pdf"),disabled:b||!!E||g.length===0,children:[e.jsx("span",{className:"material-icons-outlined dec-btn-icon",children:"picture_as_pdf"}),E==="pdf"?"Gerandoâ¦":"PDF"]}),e.jsxs("button",{type:"button",className:"dec-btn",onClick:()=>B("xlsx"),disabled:b||!!E||g.length===0,children:[e.jsx("span",{className:"material-icons-outlined dec-btn-icon",children:"table_view"}),E==="xlsx"?"Gerandoâ¦":"XLSX"]})]})]}),!b&&!p?Ne(s).map(a=>e.jsxs("div",{className:"dec-alert",children:[e.jsx("span",{className:"material-icons-outlined",children:"info"}),e.jsx("span",{children:a})]},a)):null,b?e.jsx("div",{className:"dec-loading",children:"Carregando rankingâ¦"}):p?e.jsxs("div",{className:"dec-error",children:[e.jsx("div",{children:p}),e.jsx("button",{type:"button",className:"dec-btn",onClick:L,style:{marginTop:12},children:"Tentar novamente"})]}):g.length===0?e.jsxs("div",{className:"dec-empty",children:["Nenhum certificado de GUB registrado em ",i,m?".":" para mestres desta federação."]}):e.jsx("div",{className:"dec-table-scroll",children:e.jsxs("table",{className:"dec-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"dec-num",style:{width:56},children:"#"}),e.jsx("th",{children:m?"Federação":"Mestre"}),z?e.jsxs(e.Fragment,{children:[e.jsx("th",{className:"dec-num",style:{width:120},children:"Pelo sistema"}),e.jsx("th",{className:"dec-num",style:{width:120},children:"Saldo inicial"})]}):null,e.jsx("th",{style:{width:"40%"},children:"Total"})]})}),e.jsx("tbody",{children:g.map((a,h)=>e.jsxs("tr",{children:[e.jsx("td",{className:"dec-num",children:e.jsx("span",{className:`dec-rank${h<3?" top":""}`,children:h+1})}),e.jsxs("td",{children:[e.jsx("div",{style:{fontWeight:600},children:a.nome}),a.detalhe?e.jsx("div",{style:{fontSize:"0.78rem",color:"var(--dec-ink-3)"},children:a.detalhe}):null]}),z?e.jsxs(e.Fragment,{children:[e.jsx("td",{className:"dec-num",children:d(a.contador)}),e.jsx("td",{className:"dec-num",children:d(a.saldoInicial)})]}):null,e.jsx("td",{children:e.jsxs("div",{className:"dec-rank-bar",children:[e.jsx("div",{className:"dec-rank-bar-track",children:e.jsx("div",{className:"dec-rank-bar-fill",style:{width:`${S?a.total/S*100:0}%`}})}),e.jsx("strong",{children:d(a.total)})]})})]},a.id))}),e.jsx("tfoot",{children:e.jsxs("tr",{children:[e.jsx("td",{}),e.jsx("td",{children:m?`Total nacional · ${d(v.qtdFederacoes)} federação(ões)`:`Total da federação · ${d(v.qtdMestres)} mestre(s)`}),z?e.jsxs(e.Fragment,{children:[e.jsx("td",{className:"dec-num",children:d(v.totalContador)}),e.jsx("td",{className:"dec-num",children:d(v.totalSaldoInicial)})]}):null,e.jsx("td",{children:e.jsx("strong",{children:d(v.totalGeral)})})]})})]})})]}
1),Ae?e.jsxs("div",{className:"dec-panel",children:[e.jsx("div",{className:"dec-panel-head",children:e.jsxs("div",{children:[e.jsx("h3",{className:"dec-panel-title",children:m?"Certificados de DAN por federação":"Ranking de mestres â DANs"}),e.jsx("p",{className:"dec-panel-sub",children:"Certificados de faixa preta no ano."})]})}),e.jsx("div",{className:"dec-empty",children:"A contagem de certificados de DAN ainda não está disponÃvel."})]}):null]})}const we=9902,Le=9e3,ie=!1;function Fe(){const{domainDetails:o,currentUser:n}=ce(),i=(o==null?void 0:o.domainId)||null,c=(n==null?void 0:n.rulesOwned)||[],s=c.includes(we)||c.includes(Le),[j,b]=r.useState(30),[y,p]=r.useState([]),[w,E]=r.useState({}),[R,L]=r.useState(!1),[B,$]=r.useState(!1),[m,g]=r.useState(null),[S,v]=r.useState(null),[P,d]=r.useState(!0),[A,a]=r.useState(10),[h,f]=r.useState([]),[k,N]=r.useState(1),[G,O]=r.useState(!1),[Y,I]=r.useState(!0),[X,M]=r.useState(null),[_,q]=r.useState(null),[Z,T]=r.useState(null),K=o&&!i?"Não foi possÃvel identificar a federação deste portal. Recarregue a página ou contate o suporte.":null,D=r.useRef([]),[t,x]=r.useState(null),C=(l,u)=>{var F,ae;return((ae=(F=l==null?void 0:l.response)==null?void 0:F.data)==null?void 0:ae.error)||u||"Não foi possÃvel carregar os dados. Verifique seu acesso a este dashboard e tente novamente."},Q=r.useCallback(async()=>{if(!i){d(!1);return}d(!0);try{const l=await V.getSerieDiaria({dias:j,federacaoId:i});p(l.serie||[]),E(l.kpis||{}),L(!!l.truncado),$(!!l.diaParcial),g(typeof l.diasCobertos=="number"?l.diasCobertos:null),v(l.geradoEm||null),q(null)}catch(l){console.error("Erro ao carregar série diária de emissões:",l),q(C(l))}finally{d(!1)}},[j,i]),J=r.useCallback(async()=>{var l;if(!i){I(!1);return}I(!0);try{const u=await V.getLista({pageSize:A,cursor:t,federacaoId:i});f(u.itens||[]),O(!!u.temProxima),T(null),u.proximoCursor&&(D.current[k-1]=u.proximoCursor)}catch(u){console.error("Erro ao carregar linha do tempo de emissões:",u),f([]),O(!1);const F=(l=u==null?void 0:u.response)==null?void 0:l.status;if(t&&(F===400||F===403)){console.warn("Cursor de paginação inválido â voltando à primeira página."),D.current=[],N(1),x(null),T(null);return}T(C(u))}finally{I(!1)}},[A,t,k,i]),ee=r.useCallback(async()=>{if(i)try{const l=await V.getTotal({federacaoId:i});M(typeof l.total=="number"?l.total:null)}catch(l){console.warn("Não foi possÃvel obter o total de certificados:",l),M(null)}},[i]);r.useEffect(()=>{Q()},[Q]),r.useEffect(()=>{ie&&J()},[J]),r.useEffect(()=>{ee()},[ee]);const le=l=>{D.current=[],N(1),x(null),a(l)},ne=()=>{const l=D.current[k-1];l&&(N(u=>u+1),x(l))},oe=()=>{if(k<=1)return;const l=k-1;N(l),x(l===1?null:D.current[l-2]||null)};return o?e.jsx(Re,{badge:`${o.sigla||"Federação"} · Certificados emitidos`,dias:j,onDiasChange:b,serie:y,kpis:w,truncado:R,diaParcial:B,diasCobertos:m,itens:h,pageSize:A,onPageSizeChange:le,pagina:k,temProxima:G,onAnterior:oe,onProxima:ne,total:X,loadingSerie:P,loadingLista:Y,erroFatal:K,erroSerie:_,erroLista:Z,onRecarregarSerie:Q,onRecarregarLista:J,exibirLinhaDoTempo:ie,atualizadoEm:re(S),children:s?e.jsx(De,{federacaoId:i,sigla:o.sigla}):null}):e.jsx("div",{className:"p-4",children:"Carregandoâ¦"})}export{Fe as default}; 2//# sourceMappingURL=DashboardEmissaoCertificadosPage-b6e56d93.js.map
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.