PageSourceSearch

https://hermidamaia.adv.br/assets/usePublicationDetailController-y-0dfOS_.js

js hermidamaia.adv.br collected 2026-10-05 00:43:00 UTC 45,006 bytes, 9 lines download raw bytes

1import{b as _,j as e}from"./vendor-three-BGGFfWe7.js";import{dt as je,d as ss,u as xe,z as I,du as os,dv as ls,dw as is,dx as cs,b as as,b4 as us,dy as Ze,af as R,ag as z,ah as U,ai as B,aj as m,a9 as ms,b5 as xs,ap as gs,dz as ps,dA as js,df as hs,d3 as Ye,dB as vs,E as fs,dC as Ns,c5 as _s,cG as bs,c as ys,j as Qe,Q as ws,bq as Cs,aP as Ss,ae as H,dD as ks}from"./index-zO3nSPIa.js";function es(s){const n=String(s||"").trim();if(!n)throw new Error("PUBLICATION_ID_REQUIRED");return n}const As={get:async s=>{const n=es(s),t=await je(`/api/publications/${encodeURIComponent(n)}/context`);return(t==null?void 0:t.data)||null},resolve:async s=>{const n=es(s),t=await je(`/api/publications/${encodeURIComponent(n)}/context/resolve`,{method:"POST"});return(t==null?void 0:t.data)||null}},Ps=[{id:"manifestacao_geral",label:"Manifestação geral — 15 dias úteis"},{id:"recurso_apelacao",label:"Recurso de Apelação — 15 dias úteis"},{id:"contrarrazoes_apelacao",label:"Contrarrazões de Apelação — 15 dias úteis"},{id:"recurso_ordinario",label:"Recurso Ordinário — 15 dias úteis"},{id:"defesa_civel",label:"Defesa no processo civil — 15 dias úteis"},{id:"impugnacao_custa",label:"Impugnação ao valor de custas — 15 dias úteis"},{id:"cumprimento_provimento",label:"Cumprimento de provimento — 15 dias úteis"}];function v(s,n,t="—"){for(const p of n){const o=s==null?void 0:s[p];if(o!=null&&o!=="")return o}return t}function W(s){if(!s)return"—";const n=String(s),t=n.match(/^(\d{4})-(\d{2})-(\d{2})(?:$|T00:00(?::00(?:\.000)?)?Z?$)/);if(t)return`${t[3]}/${t[2]}/${t[1]}`;try{return new Intl.DateTimeFormat("pt-BR",{dateStyle:"short",timeStyle:"short"}).format(new Date(s))}catch{return n}}function Is(s){return Array.isArray(s)?s:[]}function ie(s){return Is(s).map(n=>typeof n=="string"?n:(n==null?void 0:n.message)||(n==null?void 0:n.code)||JSON.stringify(n))}function N({label:s,value:n,accent:t=!1}){return e.jsxs("div",{className:`rounded-lg p-2.5 ${t?"bg-[#FFF3EC]":"bg-muted"}`,children:[e.jsx("p",{className:"text-[9px] uppercase tracking-wide text-muted-foreground",children:s}),e.jsx("p",{className:"mt-1 break-words text-[11px] font-semibold text-[#3F3A36]",children:n??"—"})]})}function X({title:s,children:n,tone:t="neutral"}){const p=t==="warning"?"border-amber-200 bg-amber-50 text-amber-950":t==="error"?"border-red-200 bg-red-50 text-red-800":"border-border bg-card text-foreground/80";return e.jsxs("div",{className:`rounded-lg border p-3 text-[11px] leading-5 ${p}`,children:[e.jsx("p",{className:"font-semibold",children:s}),e.jsx("div",{className:"mt-1",children:n})]})}function Ds({publication:s,chainQuery:n,chain:t,onRefresh:p=null}){var de,Q,re,oe,ne,le;const o=ss(),[D,se]=_.useState(""),[c,A]=_.useState(""),[Z,V]=_.useState(""),[J,d]=_.useState(""),[b,k]=_.useState(""),F=(t==null?void 0:t.candidates)||[],l=F.find(r=>String(r.id)===String(D))||F[0]||null,j=((de=t==null?void 0:t.assessments)==null?void 0:de[0])||null,g=((Q=t==null?void 0:t.resolutions)==null?void 0:Q.find(r=>r.status==="validated"))||((re=t==null?void 0:t.resolutions)==null?void 0:re[0])||null,y=((t==null?void 0:t.termGroups)||[]).flatMap(r=>r.terms||[]),f=y.find(r=>v(r,["countStartDate","count_start_date"],null))||y[0]||null,E=(t==null?void 0:t.deadlines)||[];_.useEffect(()=>{D&&!F.some(r=>String(r.id)===String(D))&&se("")},[F,D]);const q=xe({queryKey:["publication-deadline-review-timeline",(l==null?void 0:l.id)||"none"],queryFn:()=>ps(l.id),enabled:!!(l!=null&&l.id),retry:!1}),K=xe({queryKey:["publication-deadline-review-correlation",(l==null?void 0:l.id)||"none"],queryFn:()=>js(l.id),enabled:!!(l!=null&&l.id&&(l==null?void 0:l.correlation_state)==="ambiguous"),retry:!1}),M=async()=>{var r;await Promise.all([o.invalidateQueries({queryKey:["publication-treatment-envelope",s==null?void 0:s.id]}),o.invalidateQueries({queryKey:["publication-deadline-review-timeline"]}),o.invalidateQueries({queryKey:["publication-deadline-review-correlation"]})]),await((r=n==null?void 0:n.refetch)==null?void 0:r.call(n)),await(p==null?void 0:p())},L=I({mutationFn:r=>os(j.id,r,c.trim()||null),onSuccess:async(r,h)=>{k(h==="confirm"?"Assessment confirmado pela autoridade Base44; o candidate permanece sujeito à validação humana.":"Assessment rejeitado para nova revisão pela autoridade Base44."),A(""),await M()},onError:r=>k((r==null?void 0:r.message)||"Não foi possível revisar o assessment.")}),w=I({mutationFn:()=>ls(g.id,c.trim()||null),onSuccess:async()=>{k("Termo DJEN validado pela autoridade Base44; o candidate permanece sujeito à revisão humana."),A(""),await M()},onError:r=>k((r==null?void 0:r.message)||"Não foi possível validar o termo DJEN.")}),P=I({mutationFn:r=>is(l.id,r,c.trim()||null),onSuccess:async(r,h)=>{k(h==="approve"?"Candidate confirmado pela autoridade Base44; a materialização continua separada e exige validação explícita.":"Candidate rejeitado com trilha de validação Base44."),A(""),await M()},onError:r=>k((r==null?void 0:r.message)||"Não foi possível revisar o candidate.")}),u=I({mutationFn:()=>cs(l.id,J||null,Z.trim()),onSuccess:async()=>{k("Correlação ambígua resolvida e auditada pela autoridade Base44."),V(""),d(""),await M()},onError:r=>k((r==null?void 0:r.message)||"Não foi possível resolver a correlação.")}),[C,x]=_.useState("manifestacao_geral"),T=I({mutationFn:()=>as.functions.invoke("calcularPrazoProcessual",{publicacao_id:s==null?void 0:s.id,rule_id:C}),onSuccess:async r=>{var G;const h=(G=r==null?void 0:r.data)==null?void 0:G.calculation;k(h?`Prazo calculado: ${h.data_limite} (ciência ${h.data_ciencia}). Revisão humana obrigatória.`:"Prazo calculado e materializado."),await M()},onError:r=>k((r==null?void 0:r.message)||"Não foi possível calcular o prazo.")});if(n!=null&&n.isLoading)return e.jsx(X,{title:"Carregando revisão jurídica",children:"Consultando assessment, resolução, termo, candidates e deadlines no HMCode."});if(n!=null&&n.isError)return e.jsxs(X,{title:"Falha ao carregar a cadeia de prazo",tone:"error",children:[e.jsx("p",{children:"O erro não foi convert
1ido em vazio. Tente novamente para recuperar a cadeia canônica."}),e.jsx("button",{type:"button",onClick:()=>n.refetch(),className:"mt-2 font-medium underline",children:"Tentar novamente"})]});const $=(l==null?void 0:l.calculation)||(l==null?void 0:l.calculation_snapshot)||{},S=[...ie(t==null?void 0:t.issues),...ie(l==null?void 0:l.blockers),...ie(l==null?void 0:l.warnings),...ie($==null?void 0:$.blockers),...ie($==null?void 0:$.warnings)],Y=v($,["memory","steps","calculation_memory","trace"],(l==null?void 0:l.calculation_memory)||(l==null?void 0:l.steps)||[]),ae=((oe=K.data)==null?void 0:oe.movement_candidates)||((ne=K.data)==null?void 0:ne.candidates)||[];return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"hm-kicker",children:"Revisão jurídica de prazo"}),e.jsx("p",{className:"mt-1 text-[11px] leading-5 text-muted-foreground",children:"Assessment → resolution → term resolution → candidate → deadline materializado. O navegador somente apresenta e dispara operações canônicas."})]}),e.jsx("button",{type:"button",onClick:()=>{var r;return(r=n==null?void 0:n.refetch)==null?void 0:r.call(n)},disabled:n==null?void 0:n.isFetching,title:"Atualizar cadeia jurídica",className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-border bg-card",children:e.jsx(us,{className:`h-3.5 w-3.5 ${n!=null&&n.isFetching?"animate-spin":""}`})})]}),(t==null?void 0:t.partial)&&e.jsx(X,{title:"Leitura parcial",tone:"warning",children:"Nem todos os segmentos da cadeia puderam ser carregados. Os dados visíveis são preservados e as falhas permanecem explícitas."}),b&&e.jsx(X,{title:"Resultado da operação",children:b}),e.jsx("div",{className:"rounded-lg border border-border bg-card p-3",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Ze,{className:"h-4 w-4 text-primary"}),e.jsx("p",{className:"text-xs font-semibold",children:"Calcular prazo"}),e.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[e.jsxs(R,{value:C,onValueChange:x,children:[e.jsx(z,{className:"h-8 w-56 bg-card text-xs",children:e.jsx(U,{})}),e.jsx(B,{children:Ps.map(r=>e.jsx(m,{value:r.id,children:r.label},r.id))})]}),e.jsxs("button",{type:"button",disabled:!(s!=null&&s.id)||T.isPending,onClick:()=>T.mutate(),className:"inline-flex h-8 items-center gap-1.5 rounded-lg bg-primary px-3 text-xs font-medium text-white disabled:opacity-40",children:[e.jsx(Ze,{className:"h-3.5 w-3.5"}),T.isPending?"Calculando…":"Calcular"]})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-5",children:[e.jsx(N,{label:"Assessment",value:(j==null?void 0:j.decision)||(j==null?void 0:j.generation)||(j==null?void 0:j.status)||"não classificado",accent:!0}),e.jsx(N,{label:"Resolution",value:(g==null?void 0:g.status)||"—"}),e.jsx(N,{label:"Term",value:(f==null?void 0:f.status)||"—"}),e.jsx(N,{label:"Candidates",value:F.length}),e.jsx(N,{label:"Deadlines",value:E.length})]}),e.jsx("div",{className:"rounded-lg border border-border bg-muted p-3",children:e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsx(N,{label:"Publicação",value:(s==null?void 0:s.numero_cnj)||(s==null?void 0:s.numero_djen)||"—"}),e.jsx(N,{label:"Processo",value:(s==null?void 0:s.process_number)||(s==null?void 0:s.processNumber)||(s==null?void 0:s.process_id)||"sem vínculo"}),e.jsx(N,{label:"Publicação",value:W((s==null?void 0:s.data_publicacao)||(s==null?void 0:s.publication_at))}),e.jsx(N,{label:"Disponibilização",value:W((s==null?void 0:s.data_disponibilizacao)||(s==null?void 0:s.availability_at))})]})}),j?e.jsx("div",{className:"rounded-lg border border-border bg-card p-3",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold",children:"Assessment"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Gera prazo: ",v(j,["decision","generation"],"não classificado")," · status: ",j.status||"—"," · confidence: ",j.confidence??"—"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{type:"button",disabled:L.isPending,onClick:()=>L.mutate("confirm"),className:"inline-flex items-center gap-1 rounded-lg border border-emerald-200 px-2.5 py-1.5 text-[10px] text-emerald-700",children:[e.jsx(ms,{className:"h-3.5 w-3.5"}),"Confirmar"]}),e.jsxs("button",{type:"button",disabled:L.isPending,onClick:()=>L.mutate("reject"),className:"inline-flex items-center gap-1 rounded-lg border border-red-200 px-2.5 py-1.5 text-[10px] text-red-700",children:[e.jsx(xs,{className:"h-3.5 w-3.5"}),"Rejeitar"]})]})]})}):e.jsx(X,{title:"Assessment ausente",tone:"warning",children:"A publicação ainda não possui classificação persistida de geração de prazo."}),g&&e.jsxs("div",{className:"rounded-lg border border-border bg-card p-3",children:[e.jsx("p",{className:"text-xs font-semibold",children:"Regra e calendário"}),e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsx(N,{label:"Regra",value:v(g,["rule_name","ruleName","rule_authority_id","ruleAuthorityId","rule_id"])}),e.jsx(N,{label:"Versão da regra",value:v(g,["rule_version","ruleVersion","engine_revision"])}),e.jsx(N,{label:"Calendário",value:v(g,["calendar_name","calendarName","calendar_authority_id","calendarAuthorityId","calendar_id"])}),e.jsx(N,{label:"Versão / hash",value:v(g,["calendar_version","calendarVersion","calendar_hash","calendarHash"])})]})]}),f&&e.jsx("div",{className:"rounded-lg border border-border bg-card p-3",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold",children:"Termo inicial"}),e.jsxs("p",{className:"mt-1 text-[10px] text-muted-foreground",children:[W(v(f,["countStartDate","count_start_date","start_date"],null))," · ",v(f,["basis","legal_basis","source"],"fundamento não informado")]})]}),g&&e.jsxs("button",{type:"button",disabled:w.isPending,onClick:()=>w.mutate(),className:"inline-flex items-center gap-1 rounded-lg border border-primary/70 px-2.5 py-1.5 text-[10px] text-primary",children:[e.jsx(gs,{className:"h-3.5 w-3.5"}),"Validar termo DJEN"]})]})}),F.length===0?e.jsx(X,{title:"Nenhum candidate",children:"Não há cálculo candidato persistido para esta publicação."}):e.jsxs("div",{className:"rounded-lg border border-border bg-card p-3",children:[e.jsx("p",{className:"text-xs font-semibold",children:"Candidates de prazo"}),e.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:"Candidate não é Deadline operacional. A materialização é exibida separadamente."}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:F.map(r=>e.jsxs("button",{type:"button",onClick:()=>se(r.id),className:`rounded-lg border px-2.5 py-1.5 text-[10px] ${(l==null?void 0:l.id)===r.id?"border-primary bg-[#FFF3EC] text-[#8F4931]":"border-border"}`,children:[W(v(r,["calculated_due_date","due_date","dueDate"],null))," · ",r.status||"candidate"]},r.id))}),l&&e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(N,{label:"Data calculada",value:W(v(l,["calculated_due_date","due_date","dueDate"],null)),accent:!0}),e.jsx(N,{label:"Termo inicial",value:W(v(l,["count_start_date","countStartDate"],v(f,["countStartDate","count_start_date"],null)))}),e.jsx(N,{label:"Duração",value:`${v(l,["duration","duration_value","days"],"—")} ${v(l,["duration_unit","unit"],"")}`.trim()}),e.jsx(N,{label:"Timezone",value:v(l,["timezone","time_zone"],"America/Manaus")})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsx(N,{label:"Provenance",value:v(l,["provenance","source","source_type"],v($,["provenance","source"],"—"))}),e.jsx(N,{label:"Engine revision",value:v($,["engine_revision","engineRevision","revision"],v(l,["engine_revision"],"—"))})]}),e.jsx("textarea",{value:c,onChange:r=>A(r.target.value),rows:2,placeholder:"Motivo/nota de revisão (quando exigido)",className:"w-full rounded-lg border border-border bg-card p-2 text-[11px]"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",disabled:P.isPending,onClick:()=>P.mutate("approve"),className:"rounded-lg bg-primary px-3 py-2 text-[10px] font-medium text-white disabled:opacity-50",children:"Confirmar candidate"}),e.jsx("button",{type:"button",disabled:P.isPending||!c.trim(),onClick:()=>P.mutate("reject"),className:"rounded-lg border border-red-200 px-3 py-2 text-[10px] font-medium text-red-700 disabled:opacity-50",children:"Rejeitar candidate"})]})]})]}),(l==null?void 0:l.correlation_state)==="ambiguous"&&e.jsxs(X,{title:"Correlação ambígua — revisão humana obrigatória",tone:"warning",children:[e.jsx("p",{children:"Selecione explicitamente o movimento correspondente ou registre que nenhum se aplica."}),K.isLoading?e.jsx("p",{className:"mt-2",children:"Carregando movimentos candidatos..."}):K.isError?e.jsx("p",{className:"mt-2",children:"Não foi possível carregar a revisão de correlação."}):e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("select",{value:J,onChange:r=>d(r.target.value),className:"w-full rounded-lg border bg-card p-2 text-[11px]",children:[e.jsx("option",{value:"",children:"Nenhum dos movimentos"}),ae.map(r=>
1e.jsx("option",{value:r.id,children:r.label||r.title||r.id},r.id))]}),e.jsx("textarea",{value:Z,onChange:r=>V(r.target.value),rows:2,placeholder:"Motivo obrigatório",className:"w-full rounded-lg border bg-card p-2 text-[11px]"}),e.jsx("button",{type:"button",disabled:!Z.trim()||u.isPending,onClick:()=>u.mutate(),className:"rounded-lg border border-amber-300 bg-card px-3 py-2 text-[10px] font-medium",children:"Resolver correlação"})]})]}),S.length>0&&e.jsx(X,{title:"Warnings / blockers",tone:"warning",children:e.jsx("ul",{className:"list-disc pl-4",children:[...new Set(S)].map(r=>e.jsx("li",{children:r},r))})}),e.jsxs("div",{className:"rounded-lg border border-border bg-card p-3",children:[e.jsx("p",{className:"text-xs font-semibold",children:"Memória de cálculo"}),Array.isArray(Y)&&Y.length?e.jsx("div",{className:"mt-2 space-y-1",children:Y.map((r,h)=>e.jsx("div",{className:"rounded-md bg-muted p-2 text-[10px] leading-5",children:typeof r=="string"?r:(r==null?void 0:r.label)||(r==null?void 0:r.message)||(r==null?void 0:r.action)||JSON.stringify(r)},(r==null?void 0:r.id)||h))}):e.jsx("p",{className:"mt-2 text-[10px] text-muted-foreground",children:"A memória detalhada não foi fornecida neste candidate."}),q.isError&&e.jsx("p",{className:"mt-2 text-[10px] text-amber-800",children:"A timeline do candidate não pôde ser carregada."}),(((le=q.data)==null?void 0:le.items)||[]).length>0&&e.jsxs("div",{className:"mt-3 border-t border-border pt-2",children:[e.jsx("p",{className:"text-[10px] font-semibold",children:"Timeline / auditoria"}),q.data.items.map(r=>e.jsxs("p",{className:"mt-1 text-[10px] text-muted-foreground",children:[r.label||r.action||r.type," · ",W(r.occurred_at||r.created_at)]},r.id))]})]}),e.jsxs("div",{className:"rounded-lg border border-border bg-card p-3",children:[e.jsx("p",{className:"text-xs font-semibold",children:"Deadline materializado"}),E.length===0?e.jsx("p",{className:"mt-2 text-[10px] text-muted-foreground",children:"Nenhum Deadline operacional com vínculo persistido a esta publicação/candidate."}):e.jsx("div",{className:"mt-2 space-y-2",children:E.map(r=>e.jsxs("div",{className:"rounded-md bg-muted p-2 text-[10px]",children:[e.jsx("span",{className:"font-medium",children:r.title||r.id}),e.jsxs("span",{className:"ml-2 text-muted-foreground",children:[W(r.due_date||r.dueDate)," · ",r.status||"—"]})]},r.id))})]})]})}function O(s){return(s==null?void 0:s.user_id)||(s==null?void 0:s.userId)||(s==null?void 0:s.id)||""}function ee(s){return(s==null?void 0:s.display_name)||(s==null?void 0:s.displayName)||(s==null?void 0:s.name)||(s==null?void 0:s.email)||""}function Fs(s){return(s||[]).filter(n=>O(n)&&ee(n))}function te(s){if(!s)return"—";try{return new Intl.DateTimeFormat("pt-BR",{dateStyle:"short",timeStyle:"short"}).format(new Date(s))}catch{return String(s)}}function rs(s,n){var t,p;return((t=n==null?void 0:n.process)==null?void 0:t.formatted_number)||((p=n==null?void 0:n.process)==null?void 0:p.number)||(s==null?void 0:s.process_number)||(s==null?void 0:s.processNumber)||""}function ue(s,n){const t=rs(s,n);return`Publicação ${(s==null?void 0:s.id)||""}${t?` · Processo ${t}`:""}`}function pe(s){var n,t;return`publication:${s}:pending:${((t=(n=globalThis.crypto)==null?void 0:n.randomUUID)==null?void 0:t.call(n))||Date.now()}`}const Ts=[["aguardando_vinculo","Aguardando vínculo"],["aguardando_tratamento","Aguardando tratamento"],["em_tratamento","Em tratamento"],["aguardando_validacao","Aguardando validação"],["tratada","Tratada"],["sem_prazo","Sem prazo"],["sem_providencia","Sem providência"]];function qs({publication:s,team:n=[],view:t,onViewChange:p,onClose:o,onAssign:D,assigning:se=!1,treatmentEnvelope:c=null,treatmentEnvelopeQuery:A,deadlineChainQuery:Z,deadlineChain:V}){var Ce,Se,ke,Ae,Pe,Ie,De,Fe,Te,$e,Re,ze,Ue,Be,qe,Me,Le,Oe,Ve,Ee,Ke,He,Je,Ge,We,Xe;const J=ss(),d=(c==null?void 0:c.context)||null,b=(c==null?void 0:c.actions)||{tasks:[],discussions:[],events:[],pendings:[]},k=(c==null?void 0:c.timeline)||[],F=(c==null?void 0:c.issues)||[],l=((Ce=d==null?void 0:d.process)==null?void 0:Ce.id)||((Se=c==null?void 0:c.publication)==null?void 0:Se.process_id)||(s==null?void 0:s.process_id)||(s==null?void 0:s.processId)||null,j=((ke=d==null?void 0:d.case)==null?void 0:ke.id)||((Ae=c==null?void 0:c.publication)==null?void 0:Ae.case_id)||(s==null?void 0:s.case_id)||(s==null?void 0:s.caseId)||null,g=((Pe=d==null?void 0:d.client)==null?void 0:Pe.id)||((Ie=c==null?void 0:c.publication)==null?void 0:Ie.client_id)||(s==null?void 0:s.client_id)||(s==null?void 0:s.clientId)||null,y=(d==null?void 0:d.assignee_user_id
1)||(s==null?void 0:s.assignee_user_id)||(s==null?void 0:s.assigneeUserId)||((De=d==null?void 0:d.process)==null?void 0:De.responsible_user_id)||"",[f,E]=_.useState(""),[q,K]=_.useState(""),[M,L]=_.useState(""),[w,P]=_.useState({title:"",dueAt:"",responsibleUserId:"",priority:"normal"}),[u,C]=_.useState({title:"",startsAt:"",endsAt:"",responsibleUserId:"",type:"audiencia",mode:"presencial",location:"",meetUrl:"",notes:""}),[x,T]=_.useState({title:"",instructions:"",kind:"information",priority:"normal",dueAt:""}),[$,S]=_.useState(""),Y=_.useRef(pe(s==null?void 0:s.id)),ae=JSON.stringify([x.title,x.instructions,x.kind,x.priority,x.dueAt]),de=_.useRef(ae);_.useEffect(()=>{y&&(L(a=>a||y),P(a=>a.responsibleUserId?a:{...a,responsibleUserId:y}),C(a=>a.responsibleUserId?a:{...a,responsibleUserId:y}))},[y]),_.useEffect(()=>{de.current!==ae&&(Y.current=pe(s==null?void 0:s.id),de.current=ae)},[ae,s==null?void 0:s.id]);const Q=async()=>{var a;await Promise.all([J.invalidateQueries({queryKey:["publication-treatment-envelope",s==null?void 0:s.id]}),J.invalidateQueries({queryKey:["publicacoes-worklist"]})]),await((a=A==null?void 0:A.refetch)==null?void 0:a.call(A))},re=I({mutationFn:()=>As.resolve(s.id),onSuccess:async()=>{S("Vínculos canônicos persistidos e auditados pelo HMCode."),await Q()},onError:a=>S((a==null?void 0:a.message)||"O contexto exige revisão humana antes da persistência.")}),oe=I({mutationFn:a=>hs(s.id,a),onSuccess:async()=>{S("Lifecycle de tratamento persistido pela autoridade Base44 governada."),await Q()},onError:a=>S((a==null?void 0:a.message)||"Transição de tratamento recusada pelo backend.")}),ne=I({mutationFn:()=>as.functions.invoke("tratarPublicacao",{publication_id:s.id}),onSuccess:async a=>{const i=(a==null?void 0:a.data)||{};S(`Publicação tratada: sinal de prazo ${i.deadline_signal||"—"}, audiência ${i.hearing_signal?"sim":"não"}. ${i.candidate_id?`Candidate criado: ${i.candidate_id.slice(0,8)}…`:"Nenhum candidate criado."} Próximo estado: ${i.next_state||"—"}.`),await Q()},onError:a=>S((a==null?void 0:a.message)||"Não foi possível tratar a publicação canonicamente.")}),le=xe({queryKey:["publication-action-conversations",g],queryFn:()=>ks({clientId:g,limit:100}),enabled:t==="discussion"&&!!g,staleTime:3e4,retry:!1}),r=le.data||[],h=r.find(a=>String(a.id)===String(q)),G=async a=>{S(a),await Q()},he=I({mutationFn:(a="task")=>Ye({titulo:w.title.trim(),data_limite:w.dueAt?w.dueAt.slice(0,10):null,caso_id:j,processo_id:l,cliente_id:g,responsavel_id:w.responsibleUserId||y||null,source_type:"publicacao",source_id:s==null?void 0:s.id,publicacao_id:s==null?void 0:s.id,prioridade:w.priority,descricao:`${ue(s,d)}${f.trim()?`
2
3${f.trim()}`:""}`,observacoes:a==="discussion"?"Discussão interna originada do tratamento de publicação.":null}),onSuccess:()=>G("Tarefa criada na autoridade Base44 e reapresentada no envelope operacional."),onError:a=>S((a==null?void 0:a.message)||"Não foi possível criar a tarefa.")}),ve=I({mutationFn:()=>Ye({titulo:`Discussão interna · ${rs(s,d)||(s==null?void 0:s.title)||"publicação"}`,caso_id:j,processo_id:l,cliente_id:g,responsavel_id:M||y||null,source_type:"publicacao",source_id:s==null?void 0:s.id,publicacao_id:s==null?void 0:s.id,prioridade:"normal",descricao:`${ue(s,d)}
4
5${f.trim()}`,observacoes:"Discussão interna originada do tratamento de publicação."}),onSuccess:()=>G("Discussão interna criada na autoridade Base44 e reapresentada no envelope operacional."),onError:a=>S((a==null?void 0:a.message)||"Não foi possível iniciar a discussão interna.")}),fe=I({mutationFn:()=>vs({conversationId:q,channel:h==null?void 0:h.channel,text:`${f.trim()}
6
7[Ref.: ${ue(s,d)}]`,provider:(h==null?void 0:h.channel)||"internal"}),onSuccess:()=>G("Mensagem enviada explicitamente pelo Balcão."),onError:a=>S((a==null?void 0:a.message)||"Não foi possível enviar a mensagem.")}),Ne=I({mutationFn:()=>fs({titulo:u.title.trim(),starts_at:new Date(u.startsAt).toISOString(),ends_at:u.endsAt?new Date(u.endsAt).toISOString():null,tipo:u.type==="audiencia"?"audiencia":"compromisso",modalidade:u.mode==="virtual"?"virtual":u.mode==="hibrida"?"hibrida":"presencial",local:u.location.trim()||null,meet_url:u.meetUrl.trim()||null,status:"confirmado",cliente_id:g,caso_id:j,processo_id:l,responsavel_id:u.responsibleUserId||y||null,publicacao_id:s==null?void 0:s.id,source_type:"manual",source_id:s==null?void 0:s.id,observacoes:`${ue(s,d)}${u.notes.trim()?`
8
9${u.notes.trim()}`:""}`}),onSuccess:()=>G("Compromisso criado na autoridade Base44; a projeção de calendário segue pelo Calendar Engine governado."),onError:a=>S((a==null?void 0:a.message)||"Não foi possível criar o compromisso.")}),_e=I({mutationFn:()=>Ns({cliente_id:g,caso_id:j,processo_id:l,titulo:x.title.trim(),instrucoes:x.instructions.trim()||null,tipo:x.kind,prioridade:x.priority,data_limite:x.dueAt?x.dueAt.slice(0,10):null,responsavel_id:y||null,publicacao_id:s==null?void 0:s.id,operation_key:Y.current}),onSuccess:async()=>{Y.current=pe(s==null?void 0:s.id),await G("Pendência criada pela autoridade Base44 e reapresentada no envelope operacional.")},onError:a=>S((a==null?void 0:a.message)||"Não foi possível criar a pendência.")}),ns=()=>{S(""),t==="home"?o==null||o():p("home")},be=((Fe=d==null?void 0:d.treatment)==null?void 0:Fe.status)||(s==null?void 0:s.treatment_status)||"aguardando_tratamento",ye=((Te=d==null?void 0:d.relationships)==null?void 0:Te.issues)||[],we=!!(($e=d==null?void 0:d.relationships)!=null&&$e.ambiguous),ge=n.find(a=>String(O(a))===String(y)),ce=Fs(n),ts=[["responsibility",_s,"Atribuir responsável"],["discussion",bs,`Discussão (${((Re=b.discu
9ssions)==null?void 0:Re.length)||0})`],["deadline",ys,`Prazo / providência (${((ze=V==null?void 0:V.deadlines)==null?void 0:ze.length)||0})`],["task",Qe,`Tarefa (${((Ue=b.tasks)==null?void 0:Ue.length)||0})`],["event",ws,`Audiência / compromisso (${((Be=b.events)==null?void 0:Be.length)||0})`]];return e.jsxs("section",{className:"mb-3 rounded-xl border border-[#D8C8BE] bg-[#FFF9F5] p-4","aria-live":"polite",children:[e.jsxs("button",{type:"button",onClick:ns,className:"mb-3 inline-flex items-center gap-1.5 text-xs font-medium text-[#8F4931]",children:[e.jsx(Cs,{className:"h-3.5 w-3.5"}),"Voltar"]}),e.jsxs("div",{className:"mb-3 rounded-xl border border-border bg-card p-3",children:[e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4 text-[10px]",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Processo"}),e.jsx("p",{className:"font-semibold",children:((qe=d==null?void 0:d.process)==null?void 0:qe.formatted_number)||"Sem vínculo canônico"}),e.jsx("p",{children:((Me=d==null?void 0:d.process)==null?void 0:Me.title)||"Partes canônicas ainda não confirmadas"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Cliente / caso"}),e.jsx("p",{className:"font-semibold",children:((Le=d==null?void 0:d.client)==null?void 0:Le.name)||"Sem cliente canônico"}),e.jsx("p",{children:((Oe=d==null?void 0:d.case)==null?void 0:Oe.title)||"Sem caso canônico"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Publicação"}),e.jsx("p",{children:((Ve=d==null?void 0:d.publication)==null?void 0:Ve.tribunal)||(s==null?void 0:s.tribunal)||"—"}),e.jsxs("p",{children:[te(((Ee=d==null?void 0:d.publication)==null?void 0:Ee.publication_at)||(s==null?void 0:s.data_publicacao))," · disp. ",te(((Ke=d==null?void 0:d.publication)==null?void 0:Ke.available_at)||(s==null?void 0:s.data_disponibilizacao))]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Responsável"}),e.jsx("p",{className:"font-semibold",children:ge&&ee(ge)?ee(ge):"Não atribuído"}),e.jsx("p",{children:be})]})]}),e.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg bg-muted p-2",children:[e.jsx("span",{className:"text-[8px] uppercase tracking-wide text-muted-foreground",children:"Ação necessária"}),e.jsx("p",{className:"mt-1 text-[10px] font-semibold",children:(s==null?void 0:s.action_required)===!0?"Sim":(s==null?void 0:s.action_required)===!1?"Não":"Não classificada"})]}),e.jsxs("div",{className:"rounded-lg bg-muted p-2",children:[e.jsx("span",{className:"text-[8px] uppercase tracking-wide text-muted-foreground",children:"Gera prazo"}),e.jsx("p",{className:"mt-1 text-[10px] font-semibold",children:(s==null?void 0:s.generates_deadline)||"Não classificado"})]}),e.jsxs("div",{className:"rounded-lg bg-muted p-2",children:[e.jsx("span",{className:"text-[8px] uppercase tracking-wide text-muted-foreground",children:"Validação de prazo"}),e.jsx("p",{className:"mt-1 text-[10px] font-semibold",children:(s==null?void 0:s.deadline_validation_status)||"—"})]})]}),e.jsx("div",{className:"mt-3 max-h-40 overflow-y-auto whitespace-pre-wrap rounded-lg border border-border bg-muted p-3 text-[10px] leading-5 text-foreground/80",children:(s==null?void 0:s.content)||"Conteúdo da publicação não disponível."}),A.isLoading&&e.jsx("p",{className:"mt-2 text-[10px] text-muted-foreground",children:"Carregando envelope operacional…"}),A.isError&&e.jsx("p",{className:"mt-2 text-[10px] text-red-700",children:"Não foi possível carregar o envelope operacional. Nenhum dado periférico será mascarado como vazio."}),ye.length>0&&e.jsx("div",{className:"mt-2 rounded-lg border border-amber-200 bg-amber-50 p-2 text-[10px] text-amber-900",children:ye.map(a=>e.jsxs("p",{children:[e.jsx("strong",{children:a.code})," · ",a.message]},a.code))}),F.length>0&&e.jsxs("div",{className:"mt-2 rounded-lg border border-orange-200 bg-orange-50 p-2 text-[10px] text-orange-900",children:[e.jsx("p",{className:"font-semibold",children:"Leitura parcial do workspace"}),F.map(a=>e.jsxs("p",{children:[e.jsx("strong",{children:a.source})," · ",a.code," · ",a.message]},`${a.source}:${a.code}`))]}),(d==null?void 0:d.needs_persistence)&&e.jsx("button",{type:"button",disabled:we||re.isPending,onClick:()=>re.mutate(),className:"mt-2 rounded-lg border border-primary/70 px-2.5 py-1.5 text-[10px] font-medium text-primary disabled:opacity-40",children:we?"Revisão de vínculo necessária":re.isPending?"Resolvendo…":"Persistir vínculos canônicos"}),e.jsx("div",{className:"mt-2",children:e.jsxs(R,{value:be,onValueChange:a=>oe.mutate(a),disabled:oe.isPending,children:[e.jsx(z,{className:"h-9","aria-label":"Status do tratamento",children:e.jsx(U,{})}),e.jsx(B,{children:Ts.map(([a,i])=>e.jsx(m,{value:a,children:i},a))})]})})]}
9),$&&e.jsx("div",{className:"mb-3 rounded-lg border border-[#E1C7B8] bg-card p-3 text-[11px] text-[#6E3D2B]",children:$}),t==="home"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxs("button",{type:"button",disabled:ne.isPending||!(s!=null&&s.id),onClick:()=>ne.mutate(),className:"inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-2 text-xs font-medium text-white hover:bg-primary disabled:opacity-40",children:[ne.isPending?"Tratando…":"Tratar publicação",e.jsx(Ss,{className:"h-3.5 w-3.5"})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Classifica ato, identifica providência, sinal de prazo e audiência. Cria candidate se necessário."})]}),e.jsx("p",{className:"hm-kicker",children:"Workspace operacional único"}),e.jsx("p",{className:"mt-1 text-[11px] leading-5 text-muted-foreground",children:"Ações, prazo, contexto e timeline são projetados pelas Entities e Functions canônicas do Base44; writes permanecem endpoints específicos."}),e.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[ts.map(([a,i,ds])=>e.jsxs("button",{type:"button",onClick:()=>p(a),className:"rounded-lg border bg-card p-3 text-left text-xs",children:[e.jsx(i,{className:"mb-1 h-4 w-4"}),ds]},a)),e.jsxs("button",{type:"button",onClick:()=>p("pending"),disabled:!g,className:"rounded-lg border bg-card p-3 text-left text-xs disabled:opacity-50",children:[e.jsx(Qe,{className:"mb-1 h-4 w-4"}),"Pendência do cliente (",((He=b.pendings)==null?void 0:He.length)||0,")"]})]}),k.length>0&&e.jsxs("div",{className:"mt-3 rounded-lg border bg-card p-3",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-[#7B716A]",children:"Timeline compacta"}),e.jsx("div",{className:"mt-2 space-y-1.5",children:k.slice(0,6).map(a=>e.jsxs("div",{className:"flex gap-2 text-[10px]",children:[e.jsx("span",{className:"shrink-0 text-muted-foreground",children:te(a.occurred_at)}),e.jsx("span",{children:a.label||a.action})]},a.id))})]})]}),t==="responsibility"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"hm-kicker",children:"Responsabilidade jurídica"}),e.jsxs(R,{value:(d==null?void 0:d.assignee_user_id)||(s==null?void 0:s.assignee_user_id)||"none",onValueChange:a=>D==null?void 0:D(a==="none"?null:a),disabled:se,children:[e.jsx(z,{className:"mt-3",children:e.jsx(U,{placeholder:"Sem responsável"})}),e.jsxs(B,{children:[e.jsx(m,{value:"none",children:"Sem responsável"}),ce.map(a=>e.jsx(m,{value:O(a),children:ee(a)},O(a)))]})]})]}),t==="discussion"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"hm-kicker",children:"Comentário ou discussão"}),((Je=b.discussions)==null?void 0:Je.length)>0&&e.jsxs("div",{className:"mt-2 rounded-lg border bg-card p-3",children:[e.jsx("p",{className:"text-[10px] font-semibold",children:"Discussões relacionadas"}),b.discussions.map(a=>e.jsxs("div",{className:"mt-2 border-t pt-2 text-[10px]",children:[e.jsx("p",{className:"font-medium",children:a.title}),e.jsx("p",{children:a.description||"Sem descrição"}),e.jsx("p",{className:"text-muted-foreground",children:a.status})]},a.id))]}),e.jsx("p",{className:"mt-2 text-[10px] text-muted-foreground",children:"O domínio atual persiste discussão interna como task_type=discussion; ainda não existe thread canônica de comentários para continuar uma mesma thread."}),e.jsx("textarea",{value:f,onChange:a=>E(a.target.value),rows:4,"aria-label":"Comentário ou mensagem",className:"mt-3 w-full rounded-lg border p-3 text-sm"}),e.jsxs("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsxs(R,{value:M||"none",onValueChange:a=>L(a==="none"?"":a),children:[e.jsx(z,{children:e.jsx(U,{placeholder:"Equipe"})}),e.jsxs(B,{children:[e.jsx(m,{value:"none",children:"Sem responsável específico"}),ce.map(a=>e.jsx(m,{value:O(a),children:ee(a)},O(a)))]})]}),e.jsx("button",{type:"button",disabled:!f.trim()||ve.isPending,onClick:()=>ve.mutate(),className:"mt-2 w-full rounded-lg border px-3 py-2 text-xs",children:"Criar nova discussão interna"})]}),e.jsx("div",{children:g?e.jsxs(e.Fragment,{children:[e.jsxs(R,{value:q||"n
9one",onValueChange:a=>K(a==="none"?"":a),children:[e.jsx(z,{children:e.jsx(U,{placeholder:"Conversa do cliente"})}),e.jsxs(B,{children:[e.jsx(m,{value:"none",children:"Escolha uma conversa"}),r.map(a=>e.jsx(m,{value:String(a.id),children:a.contact_name||a.contact_email||a.channel||a.id},a.id))]})]}),e.jsx("button",{type:"button",disabled:!q||!f.trim()||fe.isPending,onClick:()=>{h&&window.confirm(`Enviar esta mensagem via ${h.channel||"canal selecionado"} para ${h.contact_name||h.contact_email||"o cliente"}?`)&&fe.mutate()},className:"mt-2 w-full rounded-lg border px-3 py-2 text-xs",children:"Confirmar e enviar ao cliente"}),le.isError&&e.jsx("p",{className:"mt-2 text-[10px] text-red-700",children:"Falha ao listar conversas; nenhuma conversa nova será criada automaticamente."})]}):e.jsx("p",{className:"rounded-lg border border-dashed p-3 text-[11px]",children:"Sem cliente canônico; envio ao cliente bloqueado."})})]})]}),t==="deadline"&&e.jsx(Ds,{publication:s,chainQuery:Z,chain:V}),t==="task"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"hm-kicker",children:"Tarefas relacionadas"}),((Ge=b.tasks)==null?void 0:Ge.length)>0&&e.jsx("div",{className:"mt-2 space-y-2",children:b.tasks.map(a=>e.jsxs("div",{className:"rounded-lg border bg-card p-2 text-[10px]",children:[e.jsx("strong",{children:a.title}),e.jsxs("p",{children:[a.status," · ",a.priority||"normal"," · ",te(a.dueAt||a.due_date)]})]},a.id))}),e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx(H,{value:w.title,onChange:a=>P(i=>({...i,title:a.target.value})),placeholder:"Título"}),e.jsx(H,{type:"datetime-local",value:w.dueAt,onChange:a=>P(i=>({...i,dueAt:a.target.value}))}),e.jsxs(R,{value:w.priority,onValueChange:a=>P(i=>({...i,priority:a})),children:[e.jsx(z,{children:e.jsx(U,{})}),e.jsxs(B,{children:[e.jsx(m,{value:"normal",children:"Normal"}),e.jsx(m,{value:"high",children:"Alta"}),e.jsx(m,{value:"urgente",children:"Urgente"})]})]}),e.jsxs(R,{value:w.responsibleUserId||"none",onValueChange:a=>P(i=>({...i,responsibleUserId:a==="none"?"":a})),children:[e.jsx(z,{children:e.jsx(U,{placeholder:"Responsável"})}),e.jsxs(B,{children:[e.jsx(m,{value:"none",children:"Herdar responsável"}),ce.map(a=>e.jsx(m,{value:O(a),children:ee(a)},O(a)))]})]}),e.jsx("textarea",{value:f,onChange:a=>E(a.target.value),rows:3,"aria-label":"Descrição da tarefa",className:"w-full rounded-lg border p-3 text-sm"}),e.jsx("button",{type:"button",disabled:!w.title.trim()||he.isPending,onClick:()=>he.mutate("task"),className:"rounded-lg bg-primary px-4 py-2 text-sm text-white",children:"Criar tarefa"})]})]}),t==="event"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"hm-kicker",children:"Agenda vinculada"}),((We=b.events)==null?void 0:We.length)>0&&e.jsx("div",{className:"mt-2 space-y-2",children:b.events.map(a=>e.jsxs("div",{className:"rounded-lg border bg-card p-2 text-[10px]",children:[e.jsx("strong",{children:a.title}),e.jsxs("p",{children:[te(a.startsAt||a.starts_at)," · ",a.mode||"—"," · sync ",a.calendarSyncState||a.calendar_sync_state||"not_synced"]})]},a.id))}),e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx(H,{value:u.title,onChange:a=>C(i=>({...i,title:a.target.value})),placeholder:"Título"}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsx(H,{type:"datetime-local",value:u.startsAt,onChange:a=>C(i=>({...i,startsAt:a.target.value}))}),e.jsx(H,{type:"datetime-local",value:u.endsAt,onChange:a=>C(i=>({...i,endsAt:a.target.value}))})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs(R,{value:u.type,onValueChange:a=>C(i=>({...i,type:a})),children:[e.jsx(z,{children:e.jsx(U,{})}),e.jsxs(B,{children:[e.jsx(m,{value:"audiencia",children:"Audiência"}),e.jsx(m,{value:"compromisso",children:"Compromisso"}),e.jsx(m,{value:"reuniao",children:"Reunião"})]})]}),e.jsxs(R,{value:u.mode,onValueChange:a=>C(i=>({...i,mode:a})),children:[e.jsx(z,{children:e.jsx(U,{})}),e.jsxs(B,{children:[e.jsx(m,{value:"presencial",children:"Presencial"}),e.jsx(m,{value:"virtual",children:"Virtual"}),e.jsx(m,{value:"hibrido",children:"Híbrido"})]})]})]}),e.jsx(H,{value:u.location,onChange:a=>C(i=>({...i,location:a.target.value})),placeholder:"Local"}),e.jsx(H,{value:u.meetUrl,onChange:a=>C(i=>({...i,meetUrl:a.target.value})),placeholder:"Link da sala virtual"}),e.jsxs(R,{value:u.responsibleUserId||"none",onValueChange:a=>C(i=>({...i,responsibleUserId:a==="none"?"":a})),children:[e.jsx(z,{children:e.jsx(U,{placeholder:"Responsável"})}),e.jsxs(B,{children:[e.jsx(m,{value:"none",children:"Herdar responsável"}),ce.map(a=>e.jsx(m,{value:O(a),children:ee(a)},O(a)))]})]}),e.jsx("textarea",{value:u.notes,onChange:a=>C(i=>({...i,notes:a.target.value})),rows:3,"aria-label":"Observações do evento",className:"w-full rounded-lg border p-3 text-sm"}),e.jsx("button",{type:"button",disabled:!u.title.trim()||!u.startsAt||Ne.isPending,onClick:()=>Ne.mutate(),className:"rounded-lg bg-primary px-4 py-2 text-sm text-white",children:"Criar evento"})]})]}),t==="pending"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"hm-kicker",children:"Pendências bilaterais do cliente"}),g?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 space-y-2",children:(Xe=b.pendings)==null?void 0:Xe.map(a=>e.jsxs("div",{className:"rounded-lg border bg-card p-2 text-[10px]",children:[e.jsx("strong",{children:a.title}),e.jsxs("p",{children:[a.kind," · ",a.status," · ",te(a.updatedAt||a.updated_at||a.createdAt||a.created_at)]}),a.responseText&&e.jsxs("p",{children:["Resposta: ",a.responseText]})]},a.id))}),e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx(H,{value:x.title,onChange:a=>T(i=>({...i,title:a.target.value})),placeholder:"Pendência"}),e.jsxs(R,{value:x.kind,onValueChange:a=>T(i=>({...i,kind:a})),children:[e.jsx(z,{children:e.jsx(U,{})}),e.jsxs(B,{children:[e.jsx(m,{value:"information",children:"Informação"}),e.jsx(m,{value:"document",children:"Documento"}),e.jsx(m,{value:"action",children:"Ação"}),e.jsx(m,{value:"form",children:"Formulário"}),e.jsx(m,{value:"signature",children:"Assinatura"})]})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs(R,{value:x.priority,onValueChange:a=>T(i=>({...i,priority:a})),children:[e.jsx(z,{children:e.jsx(U,{})}),e.jsxs(B,{children:[e.jsx(m,{value:"normal",children:"Normal"}),e.jsx(m,{value:"high",children:"Alta"}),e.jsx(m,{value:"urgent",children:"Urgente"})]})]}),e.jsx(H,{type:"datetime-local",value:x.dueAt,onChange:a=>T(i=>({...i,dueAt:a.target.value}))})]}),e.jsx("textarea",{value:x.instructions,onChange:a=>T(i=>({...i,instructions:a.target.value})),rows:4,"aria-label":"Instruções da pendência",className:"w-full rounded-lg border p-3 text-sm"}
9),e.jsx("button",{type:"button",disabled:!x.title.trim()||_e.isPending,onClick:()=>_e.mutate(),className:"rounded-lg bg-primary px-4 py-2 text-sm text-white",children:"Criar pendência"})]})]}):e.jsx("p",{className:"mt-2 rounded-lg border border-dashed p-3 text-[11px]",children:"Sem cliente canônico; esta ação permanece bloqueada."})]})]})}function $s(s){const n=String(s||"").trim();if(!n)throw new Error("PUBLICATION_ID_REQUIRED");return n}const Rs=Object.freeze({get:async s=>{const n=$s(s),t=await je(`/api/publications/${encodeURIComponent(n)}/treatment-envelope`);return(t==null?void 0:t.data)||null}});function me(s,n){return{...s,data:n}}function zs(s){var n,t;return{...s,correlation_state:(s==null?void 0:s.correlation_state)||(s==null?void 0:s.correlationState)||"none",correlation_mode:(s==null?void 0:s.correlation_mode)||(s==null?void 0:s.correlationMode)||"none",calculated_due_date:(s==null?void 0:s.calculated_due_date)||(s==null?void 0:s.due_date)||(s==null?void 0:s.dueAt)||((n=s==null?void 0:s.calculation)==null?void 0:n.dueDate)||null,count_start_date:(s==null?void 0:s.count_start_date)||(s==null?void 0:s.countStartDate)||((t=s==null?void 0:s.calculation)==null?void 0:t.countStartDate)||null,duration:(s==null?void 0:s.duration)??(s==null?void 0:s.duration_value)??(s==null?void 0:s.explicitDuration)??null,duration_unit:(s==null?void 0:s.duration_unit)||(s==null?void 0:s.explicitDurationUnit)||null,materialized_deadline_id:(s==null?void 0:s.materialized_deadline_id)||(s==null?void 0:s.materializedDeadlineId)||null}}function Ms(s){var g,y,f,E,q,K,M,L,w,P,u,C;const n=(s==null?void 0:s.id)||null,t=!!(n&&!(s!=null&&s.projection_only)),p=xe({queryKey:["publication-treatment-envelope",n],queryFn:()=>Rs.get(n),enabled:t,staleTime:3e4,retry:!1}),o=p.data||null,D=(o==null?void 0:o.issues)||[],se=((g=o==null?void 0:o.deadlines)==null?void 0:g.materialized)||[],c=((y=o==null?void 0:o.deadlines)==null?void 0:y.resolutions)||[],A=((f=o==null?void 0:o.deadlines)==null?void 0:f.terms)||[],Z=(((E=o==null?void 0:o.deadlines)==null?void 0:E.candidates)||[]).map(zs),V=c.map(x=>({resolutionId:x.id,terms:A.filter(T=>String(T.resolutionPackageId||T.resolution_package_id||"")===String(x.id))})),J={publicationId:n,processId:((K=(q=o==null?void 0:o.context)==null?void 0:q.process)==null?void 0:K.id)||((M=o==null?void 0:o.publication)==null?void 0:M.process_id)||null,assessments:((L=o==null?void 0:o.deadlines)==null?void 0:L.assessments)||[],resolutions:c,termGroups:V,candidates:Z,deadlines:se,partial:D.length>0,issues:D},d=D.filter(x=>["tasks","events","pendings"].includes(x==null?void 0:x.source)),b={tasks:((w=o==null?void 0:o.actions)==null?void 0:w.tasks)||[],discussions:((P=o==null?void 0:o.actions)==null?void 0:P.discussions)||[],events:((u=o==null?void 0:o.actions)==null?void 0:u.events)||[],pendings:((C=o==null?void 0:o.actions)==null?void 0:C.pendings)||[],partial:d.length>0,errors:d},k=me(p,(o==null?void 0:o.context)||null),F=me(p,{items:(o==null?void 0:o.timeline)||[]}),l=me(p,b),j=me(p,J);return{publicationTreatmentEnvelopeQuery:p,treatmentEnvelope:o,publicationContextQuery:k,publicationContext:(o==null?void 0:o.context)||null,publicationTimelineQuery:F,publicationActionsQuery:l,publicationActions:b,publicationDeadlineChainQuery:j,deadlineChain:J}}export{qs as P,Ms as u};

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.