PageSourceSearch

https://radreport.com.br/assets/TemplateVariablesModal-9uBeop48.js

js radreport.com.br collected 2026-09-24 14:36:50 UTC 21,955 bytes, 1 lines download raw bytes

1import{j as s}from"./vendor-query-skQMsM6X.js";import{r as f}from"./vendor-react-DyYvSSk1.js";import{am as Ae,an as Ve,ao as Fe,ap as Ie,aQ as re,aq as _,aK as Oe,T as M,p as U,ah as Ee,as as ke,aL as G,I as A,a6 as Le,a8 as Re,aR as ie,a9 as Pe,bj as Be,r as Ue,v as qe,x as $e,y as He,z as We,ab as ze}from"./index-BGwtrXIa.js";import{f as Ge}from"./textInsertionPipeline-DBj7ChR4.js";import{C as ce,a as le,b as de}from"./collapsible-CSslgSh4.js";import{e as Ke,g as Ze,f as Qe,i as K,c as Z,p as ue,a as V,b as Je,d as Xe}from"./templateVariableProcessor-BxWBf8HQ.js";import{c as Ye,d as q}from"./templateFormatter-CtNPpNn7.js";import{F as me,bu as es,ae as pe,bo as ss,u as ts,aK as xe,bx as Q,aa as ge,Z as as,y as ns,aN as os,bi as rs,ac as is,cs,aq as ls,_ as ds}from"./vendor-ui-CCmu0bzQ.js";import{p as us}from"./parse-CtdOddQZ.js";import{p as he}from"./pt-BR-0bEujIJO.js";import"./vendor-supabase-BfoV2C50.js";import"./asrTelemetry-RkcLEV-H.js";function fe(i,h){const j=new Date().getTime()-i.getTime(),d=Math.floor(j/(1e3*60*60*24));return d<0?{weeks:0,days:0}:{weeks:Math.floor(d/7),days:d%7}}function je(i){const h=i.getTime()+24192e6;return new Date(h)}
1function ms(i){return i<=0?0:9.54+1.482*i+.1676*Math.pow(i,2)}function ps(i){return i<=0?0:10.35+2.46*i+.17*Math.pow(i,2)}function xs(i){return i<=0?0:8.96+.54*i+3e-4*Math.pow(i,3)}function gs(i,h,n,j){const d=[];if(i>0&&d.push(ms(i)),j>0&&d.push(ps(j)),d.length===0&&h>0&&d.push(xs(h)),d.length===0)return{weeks:0,days:0,totalDays:0};const N=d.reduce((L,F)=>L+F,0)/d.length,m=Math.floor(N),S=Math.round((N-m)*7),$=Math.round(N*7);return{weeks:S>6?m+1:m,days:S>6?0:S,totalDays:$}}function hs(i,h,n,j){if(i<=0||h<=0||n<=0||j<=0)return 0;const d=1.3596+.0064*h+.0424*n+.174*j+61e-5*i*n-.00386*n*j,N=Math.pow(10,d);return N>50?Math.round(N):0}function fs(i,h){if(i<=0||h<20||h>42)return null;const n={20:{p10:249,p50:300,p90:366},22:{p10:375,p50:460,p90:560},24:{p10:530,p50:660,p90:800},26:{p10:715,p50:900,p90:1100},28:{p10:930,p50:1180,p90:1450},30:{p10:1180,p50:1500,p90:1850},32:{p10:1460,p50:1880,p90:2320},34:{p10:1790,p50:2300,p90:2850},36:{p10:2150,p50:2750,p90:3400},38:{p10:2550,p50:3200,p90:3900},40:{p10:2850,p50:3500,p90:4200},42:{p10:3e3,p50:3600,p90:4300}},j=Math.round(h/2)*2,d=n[Math.min(42,Math.max(20,j))];return d?i<=d.p10?Math.max(1,Math.round(i/d.p10*10)):i>=d.p90?Math.min(99,90+Math.round((i-d.p90)/d.p90*9)):i<d.p50?10+Math.round((i-d.p10)/(d.p50-d.p10)*40):50+Math.round((i-d.p50)/(d.p90-d.p50)*40):50}function J(i){return i.toLocaleDateString("pt-BR")}function _e(i){if(!i)return null;const h=i.split("/");if(h.length===3){const j=parseInt(h[0],10),d=parseInt(h[1],10)-1,N=parseInt(h[2],10),m=new Date(N,d,j);if(!isNaN(m.getTime()))return m}const n=new Date(i);return isNaN(n.getTime())?null:n}function As({open:i,onOpenChange:h,template:n,onSubmit:j}){const[d,N]=f.useState([]),[m,S]=f.useState({}),[$,L]=f.useState({}),[F,R]=f.useState({}),[X,Ne]=f.useState(!0),[Y,ee]=f.useState(!0),[C,se]=f.useState([]),[P,te]=f.useState([]),[I,B]=f.useState(null),[v,H]=f.useState("biometria"),[T,be]=f.useState(!1),O=n?Ke(n):[],ae=O.length>1,w=(n==null?void 0:n.variaveis)||[],D=f.useMemo(()=>n?n.tecnica_config&&n.tecnica_config.tipo!=="auto"?n.tecnica_config:Ze(n.conteudo.tecnica):{tipo:"unico",concatenar:!1},[n]);f.useEffect(()=>{if(i&&n){if(D.tipo==="complementar")N(O);else{const o=Qe(n);N(o?[o]:[])}const e={},t={};w.forEach(o=>{o.valor_padrao!==void 0&&o.valor_padrao!==null&&(e[o.nome]=o.valor_padrao),K(o)&&(t[o.nome]=Z())}),S(e),L(t),R({}),ee(!0),se([]),te(["titulo","tecnica","achados","impressao","adicionais"]);const c=w.find(o=>o.nome==="ig_source_mode");if(c!=null&&c.valor_padrao){const o=c.valor_padrao.toString();H(o==="DUM conhecida"?"dum":o==="USG prévio"?"usg_previo":"biometria")}else H("biometria")}},[i,n,w]);const W=f.useMemo(()=>{const e=w.map(t=>t.nome.toLowerCase());return e.includes("data_dum")||e.includes("dum")||e.includes("dbp")&&e.includes("cf")},[w]);f.useEffect(()=>{if(!W)return;const e={},t=a=>{const u=m[a];if(typeof u=="number")return u;if(typeof u=="string"&&u!==""){const p=parseFloat(u.replace(",","."));return isNaN(p)?0:p}return 0},c=t("dbp"),o=t("cc"),r=t("ca"),l=t("cf");if(v==="dum"){const a=m.data_dum;if(a){const u=_e(a);if(u){const p=fe(u);e.ig_dum_semanas=p.weeks,e.ig_dum_dias=p.days,e.ig_final_semanas=p.weeks,e.ig_final_dias=p.days,e.ig_fonte="dum";const x=je(u);e.dpp=J(x)}}}if(v==="usg_previo"){const a=m.data_usg_previo,u=t("ig_previo_semanas"),p=t("ig_previo_dias");if(a&&u>0){const x=_e(a);if(x){const b=u*7+p,y=new Date(x);y.setDate(y.getDate()-b),e.dum_calculada=J(y);const g=fe(y);e.ig_usg_semanas=g.weeks,e.ig_usg_dias=g.days,e.ig_final_semanas=g.weeks,e.ig_final_dias=g.days,e.ig_fonte="usg_previo";const oe=je(y);e.dpp=J(oe)}}}if(v==="biometria"&&(c>0||l>0)){const a=gs(c,o,r,l);e.ig_usg_semanas=a.weeks,e.ig_usg_dias=a.days,e.ig_biometria_semanas=a.weeks,e.ig_biometria_dias=a.days,e.ig_final_semanas=a.weeks,e.ig_final_dias=a.days,e.ig_fonte="biometria"}if(!T&&c>0&&r>0&&l>0){const a=hs(c,o,r,l);if(a>0){e.peso_estimado=Math.round(a);const u=t("ig_final_semanas")||t("ig_usg_semanas")||t("ig_dum_semanas")||t("ig_biometria_semanas");if(u>=20){const p=fs(a,u);p!==null&&(e.percentil_peso=Math.round(p))}}}Object.keys(e).length>0&&S(a=>
1Object.entries(e).some(([p,x])=>a[p]!==x)?{...a,...e}:a)},[W,v,T,JSON.stringify({data_dum:m.data_dum,data_usg_previo:m.data_usg_previo,ig_previo_semanas:m.ig_previo_semanas,ig_previo_dias:m.ig_previo_dias,dbp:m.dbp,cc:m.cc,ca:m.ca,cf:m.cf,ig_final_semanas:m.ig_final_semanas,ig_usg_semanas:m.ig_usg_semanas,ig_dum_semanas:m.ig_dum_semanas})]);const z=f.useMemo(()=>{if(!n)return[];const e=ue(n.condicoes_logicas,m),t=V(n.conteudo.achados,e),c=V(n.conteudo.impressao,e),o=n.conteudo.adicionais?V(n.conteudo.adicionais,e):"";let r="";D.tipo==="complementar"?r=(D.ordem_exibicao||O).filter(b=>n.conteudo.tecnica[b]).map(b=>{const y=V(n.conteudo.tecnica[b],e);return D.prefixo_label?`${b.charAt(0).toUpperCase()+b.slice(1).toLowerCase()}: ${y}`:y}).join(D.separador||". "):r=d.map(p=>n.conteudo.tecnica[p]).filter(Boolean).map(p=>V(p,e)).join(D.separador||" ");const l=[],a=Ye(n.titulo),u=V(a,e);return l.push({id:"titulo",label:"Título",html:`<h2 style="text-align: center; text-transform: uppercase; font-weight: bold; margin-bottom: 12pt;">${u}</h2>`}),r&&l.push({id:"tecnica",label:"Técnica",html:`<h3 style="text-transform: uppercase; font-weight: bold; margin-top: 18pt; margin-bottom: 8pt;">TÉCNICA</h3>${q(r)}`}),l.push({id:"achados",label:"Achados",html:`<h3 style="text-transform: uppercase; font-weight: bold; margin-top: 18pt; margin-bottom: 8pt;">ACHADOS</h3>${q(t)}`}),l.push({id:"impressao",label:"Impressão",html:`<h3 style="text-transform: uppercase; font-weight: bold; margin-top: 18pt; margin-bottom: 8pt;">IMPRESSÃO</h3>${q(c)}`}),o&&l.push({id:"adicionais",label:"Adicionais",html:`<h3 style="text-transform: uppercase; font-weight: bold; margin-top: 18pt; margin-bottom: 8pt;">ADICIONAIS</h3>${q(o)}`}),l},[n,d,m]),ye=f.useMemo(()=>{const e=new Map(z.map(t=>[t.id,t]));return P.filter(t=>!C.includes(t)&&e.has(t)).map(t=>e.get(t).html).join("")},[z,P,C]),we=e=>{se(t=>t.includes(e)?t.filter(c=>c!==e):[...t,e])},ve=(e,t)=>{B(t),e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",t)},De=e=>{e.preventDefault(),e.dataTransfer.dropEffect="move"},Se=(e,t)=>{if(e.preventDefault(),!I||I===t){B(null);return}te(c=>{const o=[...c],r=o.indexOf(I),l=o.indexOf(t);return o.splice(r,1),o.splice(l,0,I),o}),B(null)},Me=()=>{B(null)},E=(e,t)=>{const c=w.find(r=>r.nome===e);let o=t;if((c==null?void 0:c.tipo)==="numero"&&typeof t=="string"&&t!==""){const r=parseFloat(t.replace(",","."));o=isNaN(r)?0:r}S(r=>({...r,[e]:o})),F[e]&&R(r=>{const l={...r};return delete l[e],l})},k=(e,t,c)=>{L(o=>{const l={...o[e]||Z(),[t]:c},a=Xe(l);return S(u=>({...u,[e]:a})),{...o,[e]:l}}),F[e]&&R(o=>{const r={...o};return delete r[e],r})},Ce=()=>(R({}),!0),Te=()=>{Ce();const e=ue(n==null?void 0:n.condicoes_logicas,m);j(d,e,C,P),h(!1)},ne=e=>{var o,r,l;const t=m[e.nome],c=F[e.nome];if(W&&(e.nome==="data_dum"&&v!=="dum"||["data_usg_previo","ig_previo_semanas","ig_previo_dias","dum_calculada"].includes(e.nome)&&v!=="usg_previo"||["ig_dum_semanas","ig_dum_dias"].includes(e.nome)&&v!=="dum"||["dbp","cc","ca","cf"].includes(e.nome)&&v==="dum"||["ig_biometria_semanas","ig_biometria_dias","ig_usg_semanas","ig_usg_dias"].includes(e.nome)&&v==="dum"))return null;if(e.tipo==="volume"||K(e)){const a=$[e.nome]||Z(),u=Je(a.x,a.y,a.z),p=a.useCalculated?u:a.directVolume;return s.jsxs("div",{className:"space-y-3 p-4 rounded-lg border border-border bg-muted/30",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs(_,{className:"text-sm font-medium",children:[e.descricao||e.nome,s.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",e.unidade||"cm³",")"]}),e.obrigatorio&&s.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx(xe,{className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:a.useCalculated?"text-blue-500 font-medium":"text-muted-foreground",children:"Medidas"}),s.jsx(G,{checked:!a.useCalculated,onCheckedChange:x=>k(e.nome,"useCalculated",!x),className:"h-4 w-7"}),s.jsx("span",{className:a.useCalculated?"text-muted-foreground":"text-blue-500 font-medium",children:"Direto"}),s.jsx(Q,{className:"h-3.5 w-3.5 text-muted-foreground"})]})]}),a.useCalculated?s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[s.jsxs("div",{children:[s.jsx(_,{className:"text-xs text-muted-foreground",children:"X (cm)"}),s.jsx(A,{type:"number",step:"0.1",min:"0",value:a.x||"",onChange:x=>k(e.nome,"x",parseFloat(x.target.value)||0),placeholder:"0,0",className:"h-8 text-sm"})]}),s.jsxs("div",{children:[s.jsx(_,{className:"text-xs text-muted-foreground",children:"Y (cm)"}),s.jsx(A,{type:"number",step:"0.1",min:"0",value:a.y||"",onChange:x=>k(e.nome,"y",parseFloat(x.target.value)||0),placeholder:"0,0",className:"h-8 text-sm"})]}),s.jsxs("div",{children:[s.jsx(_,{className:"text-xs text-muted-foreground",children:"Z (cm)"}),s.jsx(A,{type:"number",step:"0.1",min:"0",value:a.z||"",onChange:x=>k(e.nome,"z",parseFloat(x.target.value)||0),placeholder:"0,0",className:"h-8 text-sm"})]})]}),s.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[s.jsx(Q,{className:"h-3 w-3"}),"Fórmula elipsoide: L × W × H × 0,52 =",s.jsxs("span",{className:"font-semibold text-blue-500",children:[u.toLocaleStr
1ing("pt-BR",{minimumFractionDigits:1,maximumFractionDigits:1})," cm³"]})]})]}):s.jsxs("div",{className:"space-y-2",children:[s.jsx(A,{type:"number",step:"0.1",min:"0",value:a.directVolume||"",onChange:x=>k(e.nome,"directVolume",parseFloat(x.target.value)||0),placeholder:"0,0",className:c?"border-destructive":""}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Volume informado pelo equipamento ou medido diretamente"})]}),s.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-border",children:[s.jsx("span",{className:"text-sm text-muted-foreground",children:"Volume final:"}),s.jsxs("span",{className:"text-lg font-bold text-blue-500",children:[p.toLocaleString("pt-BR",{minimumFractionDigits:1,maximumFractionDigits:1})," ",e.unidade||"cm³"]})]}),c&&s.jsx("p",{className:"text-xs text-destructive",children:c})]},e.nome)}switch(e.tipo){case"texto":return s.jsxs("div",{className:"space-y-1",children:[s.jsx(_,{htmlFor:e.nome,className:"text-xs",children:e.descricao||e.nome}),s.jsx(A,{id:e.nome,value:(t==null?void 0:t.toString())||"",onChange:g=>E(e.nome,g.target.value),placeholder:((o=e.valor_padrao)==null?void 0:o.toString())||"",className:"h-8 text-sm"})]},e.nome);case"numero":const a=e.calculado===!0,u=["peso_estimado","percentil_peso"].includes(e.nome),p=a&&(!u||!T);return s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs(_,{htmlFor:e.nome,className:M("text-xs",p?"text-muted-foreground":""),children:[e.descricao||e.nome,e.unidade&&s.jsxs("span",{className:"text-muted-foreground",children:["(",e.unidade,")"]})]}),a&&!u&&s.jsxs(ze,{variant:"outline",className:"text-[10px] py-0 px-1 bg-blue-500/10 text-blue-600 border-blue-500/30",children:[s.jsx(as,{className:"h-2.5 w-2.5 mr-0.5"}),"Auto"]})]}),u&&e.nome==="peso_estimado"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:M("text-[10px]",T?"text-muted-foreground":"text-blue-500 font-medium"),children:"Auto"}),s.jsx(G,{checked:T,onCheckedChange:be,className:"h-4 w-7"}),s.jsx("span",{className:M("text-[10px]",T?"text-blue-500 font-medium":"text-muted-foreground"),children:"Manual"})]})]}),s.jsx(A,{id:e.nome,type:"number",min:e.minimo,max:e.maximo,step:"0.1",value:(t==null?void 0:t.toString())||"",onChange:g=>E(e.nome,parseFloat(g.target.value)||0),placeholder:((r=e.valor_padrao)==null?void 0:r.toString())||"",className:M("h-8 text-sm",c&&"border-destructive",p&&"bg-muted/50 text-blue-600 font-medium cursor-not-allowed"),disabled:p,readOnly:p})]},e.nome);case"select":const x=g=>{E(e.nome,g),e.nome==="ig_source_mode"&&H(g==="DUM conhecida"?"dum":g==="USG prévio"?"usg_previo":"biometria")};return s.jsxs("div",{className:"space-y-1",children:[s.jsx(_,{htmlFor:e.nome,className:"text-xs",children:e.descricao||e.nome}),s.jsxs(Ue,{value:(t==null?void 0:t.toString())||"",onValueChange:x,children:[s.jsx(qe,{className:"h-8 text-sm",children:s.jsx($e,{placeholder:"Selecione..."})}),s.jsx(He,{children:(l=e.opcoes)==null?void 0:l.map(g=>s.jsx(We,{value:g,children:g},g))})]})]},e.nome);case"boolean":return s.jsxs("div",{className:"flex items-center justify-between space-y-2",children:[s.jsx(_,{htmlFor:e.nome,children:e.descricao||e.nome}),s.jsx(G,{id:e.nome,checked:!!t,onCheckedChange:g=>E(e.nome,g)})]},e.nome);case"data":const b=t?us(t,"dd/MM/yyyy",new Date):void 0,y=b&&!isNaN(b.getTime());return s.jsxs("div",{className:"space-y-2",children:[s.jsxs(_,{htmlFor:e.nome,children:[e.descricao||e.nome,e.obrigatorio&&s.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),s.jsxs(Le,{children:[s.jsx(Re,{asChild:!0,children:s.jsxs(U,{variant:"outline",className:M("w-full justify-start text-left font-normal",!y&&"text-muted-foreground",c&&"border-destructive"),children:[s.jsx(ge,{className:"mr-2 h-4 w-4"}),y?ie(b,"dd/MM/yyyy",{locale:he}):"Selecione a data..."]})}),s.jsx(Pe,{className:"w-auto p-0",align:"start",children:s.jsx(Be,{mode:"single",selected:y?b:void 0,onSelect:g=>{g&&E(e.nome,ie(g,"dd/MM/yyyy"))},locale:he,initialFocus:!0,className:"pointer-events-auto"})})]}),c&&s.jsx("p",{className:"text-xs text-destructive",children:c})]},e.nome);default:return null}};return n?s.jsx(Ae,{open:i,onOpenChange:h,children:s.jsxs(Ve,{className:"max-w-4xl max-h-[90vh] flex flex-col",children:[s.jsxs(Fe,{children:[s.jsxs(Ie,{className:"flex items-center gap-2",children:[s.jsx(me,{className:"h-5 w-5 text-blue-500"}),Ge(n.titulo)]}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:[n.modalidade," • ",n.regiao]})]}),s.jsx(re,{className:"flex-1 -mx-6 px-6 [&>[data-radix-scroll-area-viewport]]:scroll-smooth [&_[data-orientation=vertical]]:w-2 [&_[data-orientation=vertical]]:bg-muted/50 [&_[data-orientation=vertical]]:rounded-full [&_[data-orientation=vertical]_>_div]:bg-blue-500/40 [&_[data-orientation=vertical]_>_div]:hover:bg-blue-500/60 [&_[data-orientation=vertical]_>_div]:rounded-full",children:s.jsxs("div",{className:"space-y-6 py-4",children:[ae&&D.tipo==="alternativo"&&s.jsxs("div",{className:"space-y-3",children:[s.jsx(_,{className:"text-base font-semibold",children:"TÉCNICA (selecione uma ou mais)"}),s.jsx("div",{className:"space-y-2",children:O.map(e=>s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(Oe,{id:`tech-${e}`,checked:d.includes(e),onCheckedChange:t=>{N(t?c=>[...c,e]:c=>c.filter(o=>o!==e))}}),s.jsx(_,{htmlFor:`tech-${e}`,className:"cursor-pointer",children:e})]},e))})]}),ae&&D.tipo==="complementar"&&s.jsxs("div",{className:"space-y-3",children:[s.jsx(_,{className:"text-base font-semibold",children:"TÉCNICA"}),s.jsx("div",{className:"text-sm bg-muted/30 p-3 rounded-lg space-y-1 border border-border/50",children:O.map(e=>s.jsxs("div",{className:"text-muted-foreground",children:[D.prefixo_label&&s.jsxs("span",{className:"font-medium text-foreground",children:[e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),":"]}
1)," ",s.jsx("span",{className:"text-foreground/80",children:n==null?void 0:n.conteudo.tecnica[e]})]},e))}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Campos complementares são concatenados automaticamente"})]}),w.length>0&&s.jsxs(ce,{open:X,onOpenChange:Ne,children:[s.jsxs(le,{className:"flex items-center justify-between w-full py-2 px-3 rounded-lg bg-muted/30 hover:bg-muted/50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(es,{className:"h-4 w-4 text-blue-500"}),s.jsx(_,{className:"text-base font-semibold cursor-pointer",children:"VARIÁVEIS"}),s.jsxs("span",{className:"text-xs text-muted-foreground bg-muted px-2 py-0.5 rounded-full",children:[Object.keys(m).filter(e=>m[e]!==void 0&&m[e]!=="").length,"/",w.length," preenchidas"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{const e=w.filter(t=>t.obrigatorio&&(m[t.nome]===void 0||m[t.nome]==="")).length;return e>0&&s.jsxs("span",{className:"text-xs bg-amber-500/20 text-amber-500 px-2 py-0.5 rounded-full",children:[e," obrigatória",e>1?"s":""," pendente",e>1?"s":""]})})(),s.jsx(pe,{className:`h-4 w-4 text-muted-foreground transition-transform duration-200 ${X?"rotate-180":""}`})]})]}),s.jsx(de,{className:"mt-3",children:s.jsx("div",{className:"max-h-[400px] overflow-y-auto pr-2",children:(()=>{const e={datas:{label:"DATAS",icon:s.jsx(ge,{className:"h-4 w-4"}),order:1},biometria:{label:"BIOMETRIA FETAL",icon:s.jsx(xe,{className:"h-3.5 w-3.5"}),order:2},ig_calculada:{label:"IDADES GESTACIONAIS",icon:s.jsx(Q,{className:"h-3.5 w-3.5"}),order:3},peso:{label:"PESO FETAL",icon:s.jsx(ns,{className:"h-3.5 w-3.5"}),order:4},caracteristicas:{label:"CARACTERÍSTICAS FETAIS",icon:s.jsx(os,{className:"h-3.5 w-3.5"}),order:5},cordao:{label:"CORDÃO UMBILICAL",icon:s.jsx(rs,{className:"h-3.5 w-3.5"}),order:6},placenta:{label:"PLACENTA",icon:s.jsx(is,{className:"h-3.5 w-3.5"}),order:7},liquido:{label:"LÍQUIDO AMNIÓTICO",icon:s.jsx(cs,{className:"h-3.5 w-3.5"}),order:8},vitalidade:{label:"VITALIDADE",icon:s.jsx(ls,{className:"h-3.5 w-3.5"}),order:9},outros:{label:"OUTROS",icon:s.jsx(ds,{className:"h-3.5 w-3.5"}),order:99}},t=w.reduce((r,l)=>{const a=l.grupo||"outros";return r[a]||(r[a]=[]),r[a].push(l),r},{}),c=Object.entries(t).sort(([r],[l])=>{var p,x;const a=((p=e[r])==null?void 0:p.order)??99,u=((x=e[l])==null?void 0:x.order)??99;return a-u});return c.some(([r])=>r!=="outros")?s.jsx("div",{className:"space-y-4",children:c.map(([r,l])=>{const a=e[r]||e.outros;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-border/50 pb-1.5",children:[s.jsx("span",{className:"text-blue-500",children:a.icon}),s.jsx("span",{className:"text-xs font-semibold text-muted-foreground tracking-wide",children:a.label}),s.jsx("span",{className:"text-[10px] text-muted-foreground/60 bg-muted px-1 py-0.5 rounded",children:l.length})]}),s.jsx("div",{className:M("grid gap-2",l.some(u=>u.tipo==="volume"||K(u))?"grid-cols-1":"grid-cols-2"),children:l.map(ne)})]},r)})}):s.jsx("div",{className:"space-y-3",children:w.map(ne)})})()})})]}),s.jsxs(ce,{open:Y,onOpenChange:ee,children:[s.jsxs(le,{className:"flex items-center justify-between w-full py-2 px-3 rounded-lg bg-muted/30 hover:bg-muted/50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(me,{className:"h-4 w-4 text-blue-500"}),s.jsx(_,{className:"text-base font-semibold cursor-pointer",children:"PREVIEW"}),C.length>0&&s.jsxs("span",{className:"text-xs bg-amber-500/20 text-amber-500 px-2 py-0.5 rounded-full",children:[C.length," seção removida",C.length>1?"s":""]})]}),s.jsx(pe,{className:`h-4 w-4 text-muted-foreground transition-transform duration-200 ${Y?"rotate-180":""}`})]}),s.jsxs(de,{className:"mt-3",children:[s.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:P.map((e,t)=>{const c=z.find(l=>l.id===e);if(!c)return null;const o=C.includes(e),r=I===e;return s.jsxs("div",{draggable:!o,onDragStart:l=>ve(l,e),onDragOver:De,onDrop:l=>Se(l,e),onDragEnd:Me,className:M("flex items-center gap-2 bg-muted/40 rounded-lg px-2 py-1.5 border border-border/50 cursor-grab active:cursor-grabbing transition-all",r&&"opacity-50 scale-95 border-blue-500",o&&"cursor-default"),children:[!
1o&&s.jsx(ss,{className:"h-4 w-4 text-muted-foreground/60"}),s.jsxs(U,{variant:o?"destructive":"outline",size:"sm",onClick:()=>we(e),className:M("h-7 text-xs gap-1.5 px-3",o&&"line-through opacity-60"),children:[o&&s.jsx(ts,{className:"h-3 w-3"}),c.label]})]},e)})}),s.jsx(re,{className:"h-[300px] w-full rounded-lg border border-border [&_[data-orientation=vertical]]:w-1.5 [&_[data-orientation=vertical]]:bg-transparent [&_[data-orientation=vertical]_>_div]:bg-blue-500/30 [&_[data-orientation=vertical]_>_div]:hover:bg-blue-500/50 [&_[data-orientation=vertical]_>_div]:rounded-full",children:s.jsx("div",{className:"p-4 bg-background prose prose-sm prose-invert max-w-none",style:{color:"hsl(var(--foreground))"},dangerouslySetInnerHTML:{__html:Ee(ye)}})})]})]})]})}),s.jsxs(ke,{children:[s.jsx(U,{variant:"outline",onClick:()=>h(!1),children:"Cancelar"}),s.jsx(U,{onClick:Te,className:"bg-blue-600 hover:bg-blue-700",children:"Aplicar Template"})]})]})}):null}export{As as TemplateVariablesModal};

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.