PageSourceSearch

https://ai.trintaporcento.com.br/assets/admin.base-fiscal-D6eQ9McH.js

js trintaporcento.com.br collected 2026-10-06 04:45:08 UTC 12,325 bytes, 1 lines download raw bytes

1import{d as S,e as F,r as u,j as e,L as j,s as p,t as E}from"./index-CIcepXs3.js";import{B as x}from"./button-77ztRyNI.js";import{C as c}from"./card-BSY7RLuU.js";import{R as C,L as g,C as v}from"./refresh-cw-BTKuzjE4.js";import{E as R}from"./external-link--k6iVyqB.js";import{U as B,C as y}from"./upload-XPkTN0rB.js";import{F as b}from"./file-text-gxXz9cMG.js";import"./index-DSPCjlFI.js";import"./index-CobTJpls.js";import"./utils-DCADjnpI.js";const T=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],L=S("clock",T);const D=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],O=S("database",D),d=[{name:"CTN_Lei_5172_1966_Codigo_Tributario_Nacional",displayName:"CTN — Lei 5.172/1966",sphere:"Federal",source:"Planalto"},{name:"LC_87_1996_Lei_Kandir_ICMS",displayName:"LC 87/1996 — Lei Kandir (ICMS)",sphere:"Federal",source:"Planalto"},{name:"LC_116_2003_ISS",displayName:"LC 116/2003 — ISS",sphere:"Federal",source:"Planalto"},{name:"Lei_9430_1996_Legislacao_Tributaria_Federal",displayName:"Lei 9.430/1996 — Legislação Tributária",sphere:"Federal",source:"Planalto"},{name:"Lei_9718_1998_PIS_COFINS",displayName:"Lei 9.718/1998 — PIS/COFINS",sphere:"Federal",source:"Planalto"},{name:"Lei_10637_2002_PIS_Nao_Cumulativo",displayName:"Lei 10.637/2002 — PIS Não-Cumulativo",sphere:"Federal",source:"Planalto"},{name:"Lei_10833_2003_COFINS_Nao_Cumulativa",displayName:"Lei 10.833/2003 — COFINS Não-Cumulativa",sphere:"Federal",source:"Senado"},{name:"Lei_9249_1995_IRPJ_CSLL",displayName:"Lei 9.249/1995 — IRPJ/CSLL",sphere:"Federal",source:"Planalto"},{name:"Decreto_9580_2018_RIR_Regulamento_IR",displayName:"Decreto 9.580/2018 — RIR",sphere:"Federal",source:"Planalto"},{name:"LC_123_2006_Simples_Nacional",displayName:"LC 123/2006 — Simples Nacional",sphere:"Federal",source:"Planalto"},{name:"Lei_12973_2014_Tributacao_Lucros_Exterior",displayName:"Lei 12.973/2014 — Lucros no Exterior",sphere:"Federal",source:"Planalto"},{name:"DL_1598_1977_IR_Pessoas_Juridicas",displayName:"DL 1.598/1977 — IRPJ",sphere:"Federal",source:"Planalto"},{name:"MG_Lei_6763_1975_ICMS",displayName:"Lei 6.763/1975 — ICMS MG",sphere:"Estadual MG",source:"ALMG"},{name:"MG_RICMS_Decreto_43080_2002",displayName:"RICMS — Decreto 43.080/2002",sphere:"Estadual MG",source:"ALMG"},{name:"SP_RICMS_Decreto_45490_2000",displayName:"RICMS SP — Decreto 45.490/2000",sphere:"Estadual SP",source:"Fazenda SP"},{name:"SP_Lei_6374_1989_ICMS",displayName:"Lei 6.374/1989 — ICMS SP",sphere:"Estadual SP",source:"ALESP"},{name:"GO_CTE_Lei_11651_1991_Codigo_Tributario",displayName:"CTE — Lei 11.651/1991",sphere:"Estadual GO",source:"SEFAZ GO"},{name:"GO_RCTE_Decreto_4852_1997",displayName:"RCTE — Decreto 4.852/1997",sphere:"Estadual GO",source:"SEFAZ GO"},{name:"SC_Lei_10297_1996_ICMS",displayName:"Lei 10.297/1996 — ICMS SC",sphere:"Estadual SC",source:"SEF SC"},{name:"BH_Codigo_Tributario_Municipal",displayName:"Código Tributário Municipal BH",sphere:"Municipal BH",source:"Câmara BH"},{name:"BH_ISSQN_Lei_8725_2003",displayName:"ISSQN — Lei 8.725/2003",sphere:"Municipal BH",source:"Câmara BH"},{name:"BH_Regulamento_ISSQN_Decreto_17174_2019",displayName:"Regulamento ISSQN — Dec 17.174/2019",sphere:"Municipal BH",source:"Upload manual",manualOnly:!0,manualUrl:"https://leismunicipais.com.br/a1/mg/b/belo-horizonte/decreto/2019/1718/17174/decreto-n-17174-2019"},{name:"Contagem_Codigo_Tributario",displayName:"Código Tributário Contagem",sphere:"Municipal Contagem",source:"Prefeitura"},{name:"Contagem_ISSQN_LC_90_2012",displayName:"ISSQN — LC 90/2012",sphere:"Municipal Contagem",source:"Prefeitura"},{name:"Betim_Codigo_Tributario",displayName:"Código Tributário Betim",sphere:"Municipal Betim",source:"Upload manual",manualOnly:!0,manualUrl:"https://leismunicipais.com.br/codigo-tributario-betim-mg"},{name:"Betim_ISSQN_LC_6_2011",displayName:"ISSQN — LC 6/2011",sphere:"Municipal Betim",source:"Upload manual",manualOnly:!0,manualUrl:"https://leismunicipais.com.br/a1/mg/b/betim/lei-complementar/2011/1/6/lei-complementar-n-6-2011"}];function X(){const{session:i}=F(),[I,P]=u.useState([]),[k,h]=u.useState(!0),[N,f]=u.useState(new Set);async function m(){const{data:s}=await p.from("knowledge_areas").select("id").eq("slug","fiscal").single();if(!s){h(!1);return}const{data:a}=await p.from("documents").select("id, original_name, status, chunk_count, uploaded_at, processed_at").eq("area_id",s.id).neq("status","archived").order("uploaded_at",{ascending:!1});P(a??[]),h(!1)}u.useEffect(()=>{m();const s=setInterval(m,8e3);return()=>clearInterval(s)},[]);function w(s){const a=s.name.toLowerCase().replace(/[^a-z0-9]/g,"");return I.find(r=>{const t=(r.original_name??"").toLowerCase().replace(/[^a-z0-9]/g,"");return t.includes(a)||a.includes(t.replace(/\.txt$/,""))})}function _(s){const a=w(s);return a?{status:a.status==="archived"?"not_found":a.status,doc:a}:{status:s.manualOnly?"pending_manual":"not_found"}}async function M(s){i&&(f(a=>
1new Set(a).add(s)),await p.from("document_chunks").delete().eq("document_id",s),await p.from("documents").update({status:"processing",error_message:null,chunk_count:0}).eq("id",s),fetch("https://gpkmghexknouwioeufgh.supabase.co/functions/v1/process-document",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i.access_token}`},body:JSON.stringify({documentId:s})}).catch(()=>{}),E.success("Reprocessando…"),setTimeout(()=>{f(a=>{const r=new Set(a);return r.delete(s),r}),m()},3e3))}const z=[...new Set(d.map(s=>s.sphere))],l=d.reduce((s,a)=>{const{status:r}=_(a);return r==="active"?s.active++:r==="processing"?s.processing++:r==="error"?s.error++:s.pending++,s},{active:0,processing:0,error:0,pending:0});return e.jsxs("div",{className:"mx-auto max-w-6xl p-8",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-3xl",children:"Controle — Base Fiscal"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Acompanhe o status de cada documento planejado para a área Fiscal."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{to:"/admin/conhecimento",children:e.jsxs(x,{variant:"outline",size:"sm",children:[e.jsx(O,{className:"mr-2 size-4"})," Central de Conhecimento"]})}),e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>{h(!0),m()},children:[e.jsx(C,{className:"mr-2 size-4"})," Atualizar"]})]})]}),e.jsxs("div",{className:"mt-6 grid grid-cols-2 gap-4 sm:grid-cols-4",children:[e.jsxs(c,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-semibold text-green-600",children:l.active}),e.jsx("div",{className:"mt-1 text-xs uppercase tracking-wider text-muted-foreground",children:"Ativos"})]}),e.jsxs(c,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-semibold text-blue-600",children:l.processing}),e.jsx("div",{className:"mt-1 text-xs uppercase tracking-wider text-muted-foreground",children:"Processando"})]}),e.jsxs(c,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-semibold text-amber-600",children:l.pending}),e.jsx("div",{className:"mt-1 text-xs uppercase tracking-wider text-muted-foreground",children:"Pendentes"})]}),e.jsxs(c,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-semibold text-red-600",children:l.error}),e.jsx("div",{className:"mt-1 text-xs uppercase tracking-wider text-muted-foreground",children:"Erros"})]})]}),e.jsxs("div",{className:"mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:"Progresso geral"}),e.jsxs("span",{children:[l.active,"/",d.length," documentos ativos"]})]}),e.jsx("div",{className:"mt-1 h-2 w-full overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full rounded-full bg-green-600 transition-all duration-500",style:{width:`${l.active/d.length*100}%`}})})]}),k?e.jsxs("div",{className:"mt-10 flex items-center justify-center gap-2 text-sm text-muted-foreground",children:[e.jsx(g,{className:"size-4 animate-spin"})," Carregando dados…"]}):e.jsx("div",{className:"mt-8 space-y-8",children:z.map(s=>{const a=d.filter(t=>t.sphere===s),r=a.filter(t=>_(t).status==="active").length;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3 border-b border-border pb-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),e.jsxs("span",{className:"rounded-full bg-muted px-2 py-0.5 text-xs text-muted-foreground",children:[r,"/",a.length]})]}),e.jsx("div",{className:"mt-3 space-y-1",children:a.map(t=>{const{status:o,doc:n}=_(t);return e.jsxs("div",{className:"flex items-center justify-between rounded-md px-3 py-2.5 text-sm hover:bg-muted/40",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx(A,{status:o}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium",children:t.displayName}),e.jsxs("div",{className:"truncate text-xs text-muted-foreground",children:["Fonte: ",t.source,n?.chunk_count?` · ${n.chunk_count} trechos`:"",n?.processed_at?` · ${new Date(n.processed_at).toLocaleDateString("pt-BR")}`:""]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(G,{status:o}),o==="error"&&n&&e.jsx(x,{variant:"ghost",size:"sm",onClick:()=>M(n.id),disabled:N.has(n.id),children:e.jsx(C,{className:`size-3.5 ${N.has(n.id)?"animate-spin":""}`})}),t.manualOnly&&t.manualUrl&&e.jsxs("a",{href:t.manualUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-primary hover:bg-primary/10",children:[e.jsx(R,{className:"size-3"})," Buscar"]}),(o==="pending_manual"||o==="not_found")&&!t.manualOnly&&e.jsx(j,{to:"/admin/conhecimento",children:e.jsxs(x,{variant:"ghost",size:"sm",className:"text-xs",children:[e.jsx(B,{className:"mr-1 size-3"})," Upload"]})})]})]},t.name)}
1)})]},s)})}),e.jsxs(c,{className:"mt-8 p-4",children:[e.jsx("h3",{className:"text-sm font-semibold mb-2",children:"Legenda"}),e.jsxs("div",{className:"flex flex-wrap gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(v,{className:"size-3.5 text-green-600"})," Ativo — indexado e disponível para consultas"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(g,{className:"size-3.5 text-blue-600"})," Processando — chunking/embedding em andamento"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(L,{className:"size-3.5 text-amber-600"})," Pendente — requer upload manual"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(y,{className:"size-3.5 text-red-600"})," Erro — falha no processamento"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(b,{className:"size-3.5 text-muted-foreground"})," Não encontrado — ainda não ingerido"]})]})]})]})}function A({status:i}){switch(i){case"active":return e.jsx(v,{className:"size-4 shrink-0 text-green-600"});case"processing":return e.jsx(g,{className:"size-4 shrink-0 text-blue-600 animate-spin"});case"error":return e.jsx(y,{className:"size-4 shrink-0 text-red-600"});case"pending_manual":return e.jsx(L,{className:"size-4 shrink-0 text-amber-600"});case"not_found":return e.jsx(b,{className:"size-4 shrink-0 text-muted-foreground"})}}function G({status:i}){switch(i){case"active":return e.jsx("span",{className:"rounded-full bg-green-600/10 px-2 py-0.5 text-xs text-green-600",children:"Ativo"});case"processing":return e.jsx("span",{className:"rounded-full bg-blue-600/10 px-2 py-0.5 text-xs text-blue-600",children:"Processando"});case"error":return e.jsx("span",{className:"rounded-full bg-red-600/10 px-2 py-0.5 text-xs text-red-600",children:"Erro"});case"pending_manual":return e.jsx("span",{className:"rounded-full bg-amber-600/10 px-2 py-0.5 text-xs text-amber-600",children:"Upload manual"});case"not_found":return e.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-xs text-muted-foreground",children:"Não ingerido"})}}export{X as component};

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.