PageSourceSearch

https://brasilmineral.com.br/_next/static/chunks/72234.e1aa228f27bbb052.js

js brasilmineral.com.br collected 2026-10-02 05:23:59 UTC 129,781 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[72234],{1606:(e,t,a)=>{"use strict";a.d(t,{k:()=>n});var r=a(95155),o=a(12115),i=a(29885),s=a(40980);let n=o.forwardRef(({className:e,value:t,...a},o)=>(0,r.jsx)(i.bL,{ref:o,className:(0,s.cn)("relative h-4 w-full overflow-hidden rounded-full bg-secondary",e),...a,children:(0,r.jsx)(i.C1,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));n.displayName=i.bL.displayName},9192:(e,t,a)=>{"use strict";a.d(t,{S:()=>l});var r=a(95155),o=a(12115),i=a(47279),s=a(94514),n=a(40980);let l=o.forwardRef(({className:e,...t},a)=>(0,r.jsx)(i.bL,{ref:a,className:(0,n.cn)("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:(0,r.jsx)(i.C1,{className:(0,n.cn)("flex items-center justify-center text-current"),children:(0,r.jsx)(s.A,{className:"h-4 w-4"})})}));l.displayName=i.bL.displayName},11626:(e,t,a)=>{"use strict";a.d(t,{F:()=>l});var r=a(95155),o=a(12115),i=a(33210),s=a(45160),n=a(40980);function l({value:e,onChange:t,suggestions:a=[],placeholder:d,className:c,id:u}){let[m,p]=(0,o.useState)(""),[g,f]=(0,o.useState)(!1),h=(0,o.useRef)(null),x=(0,o.useMemo)(()=>new Set(e.map(e=>e.toUpperCase())),[e]),v=(0,o.useMemo)(()=>{let e=m.trim().toUpperCase();return e?a.filter(t=>t.toUpperCase().includes(e)&&!x.has(t.toUpperCase())).slice(0,8):[]},[m,a,x]),b=a=>{let r=a.trim().toUpperCase();if(r){if(x.has(r))return void p("");t([...e,r]),p("")}},j=a=>{t(e.filter(e=>e!==a))},N=g&&v.length>0;return(0,r.jsxs)("div",{className:(0,n.cn)("relative",c),children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 min-h-9 w-full rounded-md border border-input bg-transparent px-2 py-1.5 text-sm ring-offset-background focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",onClick:()=>h.current?.focus(),children:[e.map(e=>(0,r.jsxs)(s.E,{variant:"secondary",className:"gap-1 pr-1 font-normal",children:[e,(0,r.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),j(e)},className:"rounded-full hover:bg-muted-foreground/20","aria-label":`Remover ${e}`,children:(0,r.jsx)(i.A,{size:12})})]},e)),(0,r.jsx)("input",{ref:h,id:u,value:m,onChange:e=>p(e.target.value),onKeyDown:t=>{"Enter"===t.key||","===t.key||"Tab"===t.key?m.trim()&&(t.preventDefault(),b(m)):"Backspace"===t.key&&!m&&e.length>0&&j(e[e.length-1])},onFocus:()=>f(!0),onBlur:()=>{setTimeout(()=>f(!1),150),m.trim()&&b(m)},placeholder:0===e.length?d:"",className:"flex-1 min-w-[8ch] bg-transparent outline-none placeholder:text-muted-foreground"})]}),N&&(0,r.jsx)("div",{className:"absolute z-20 mt-1 w-full max-h-48 overflow-auto rounded-md border bg-popover text-popover-foreground shadow-md",children:v.map(e=>(0,r.jsx)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),b(e),h.current?.focus()},className:"block w-full px-3 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",children:e},e))})]})}},12825:(e,t,a)=>{"use strict";a.d(t,{$d:()=>n,Bg:()=>l,LG:()=>o,mx:()=>d,p1:()=>s});let r={imagem:"article-images",video:"article-videos",destaque:"premium-article-images",pdf:"article-images"},o={imagem:{tipos:["image/jpeg","image/png","image/webp","image/gif"],extensoes:["jpg","jpeg","png","webp","gif"],maxBytes:0xa00000,rotulo:"imagem"},video:{tipos:["video/mp4"],extensoes:["mp4"],maxBytes:0xc800000,rotulo:"v\xeddeo"},pdf:{tipos:["application/pdf"],extensoes:["pdf"],maxBytes:0x3c00000,rotulo:"PDF"}};function i(e){let t=/\.([A-Za-z0-9]{1,5})$/.exec(e.trim());return t?t[1].toLowerCase():""}function s(e){return e>=1048576?`${(e/1048576).toFixed(1).replace(".",",")} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function n(e,t){let a="video"===t?o.video:"pdf"===t?o.pdf:o.imagem,r=i(e.name),n=a.tipos.includes(e.type),l=a.extensoes.includes(r);return(n||""===e.type&&l)&&l?e.size<=0?{ok:!1,mensagem:"O arquivo est\xe1 vazio."}:e.size>a.maxBytes?{ok:!1,mensagem:`O arquivo tem ${s(e.size)} e o limite para ${a.rotulo} \xe9 ${s(a.maxBytes)}.`}:{ok:!0}
1:{ok:!1,mensagem:"video"===t?"Este arquivo n\xe3o \xe9 um v\xeddeo MP4. Exporte o v\xeddeo como MP4 e tente de novo.":"pdf"===t?"Este arquivo n\xe3o \xe9 um PDF.":"Este arquivo n\xe3o \xe9 uma imagem aceita. Use JPG, PNG, WebP ou GIF."}}function l(e){return e.replace(/\.[A-Za-z0-9]{1,5}$/,"").normalize("NFD").replace(/\p{M}/gu,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60).replace(/-+$/g,"")||"arquivo"}function d(e,t,a,o){let s=i(t),n=o.replace(/[^a-z0-9]/gi,"").slice(0,8).toLowerCase()||"0";return`${r[e]}/${a}-${n}-${l(t)}${s?`.${s}`:""}`}},13276:(e,t,a)=>{"use strict";a.d(t,{$v:()=>h,EO:()=>m,Lt:()=>l,Rx:()=>x,Zr:()=>v,ck:()=>g,r7:()=>f,tv:()=>d,wd:()=>p});var r=a(95155),o=a(12115),i=a(86835),s=a(40980),n=a(89239);let l=i.bL,d=i.l9,c=i.ZL,u=o.forwardRef(({className:e,...t},a)=>(0,r.jsx)(i.hJ,{className:(0,s.cn)("fixed inset-0 z-50 bg-black/80  data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:a}));u.displayName=i.hJ.displayName;let m=o.forwardRef(({className:e,...t},a)=>(0,r.jsxs)(c,{children:[(0,r.jsx)(u,{}),(0,r.jsx)(i.UC,{ref:a,className:(0,s.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));m.displayName=i.UC.displayName;let p=({className:e,...t})=>(0,r.jsx)("div",{className:(0,s.cn)("flex flex-col space-y-2 text-center sm:text-left",e),...t});p.displayName="AlertDialogHeader";let g=({className:e,...t})=>(0,r.jsx)("div",{className:(0,s.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});g.displayName="AlertDialogFooter";let f=o.forwardRef(({className:e,...t},a)=>(0,r.jsx)(i.hE,{ref:a,className:(0,s.cn)("text-lg font-semibold",e),...t}));f.displayName=i.hE.displayName;let h=o.forwardRef(({className:e,...t},a)=>(0,r.jsx)(i.VY,{ref:a,className:(0,s.cn)("text-sm text-muted-foreground",e),...t}));h.displayName=i.VY.displayName;let x=o.forwardRef(({className:e,...t},a)=>(0,r.jsx)(i.rc,{ref:a,className:(0,s.cn)((0,n.r)(),e),...t}));x.displayName=i.rc.displayName;let v=o.forwardRef(({className:e,...t},a)=>(0,r.jsx)(i.ZD,{ref:a,className:(0,s.cn)((0,n.r)({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));v.displayName=i.ZD.displayName},18349:(e,t,a)=>{"use strict";a.d(t,{T:()=>s});var r=a(95155),o=a(12115),i=a(40980);let s=o.forwardRef(({className:e,...t},a)=>(0,r.jsx)("textarea",{className:(0,i.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:a,...t}));s.displayName="Textarea"},22353:(e,t,a)=>{"use strict";a.d(t,{X:()=>o,e:()=>r});let r="bm-editor-previa";function o(e,t,a){if(e.origin!==t||null==a||e.source!==a)return null;let o=e.data;return o&&"object"==typeof o&&o.canal===r?"pronta"===o.tipo?{canal:r,tipo:"pronta"}:"artigo"===o.tipo&&o.artigo&&"object"==typeof o.artigo?{canal:r,tipo:"artigo",artigo:o.artigo}:null:null}},33807:(e,t,a)=>{"use strict";a.d(t,{J:()=>d});var r=a(95155),o=a(12115),i=a(29486),s=a(18460),n=a(40980);let l=(0,s.F)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),d=o.forwardRef(({className:e,...t},a)=>(0,r.jsx)(i.b,{ref:a,className:(0,n.cn)(l(),e),...t}));d.displayName=i.b.displayName},40980:(e,t,a)=>{"use strict";a.d(t,{Y:()=>s,cn:()=>i,o:()=>n});var r=a(29722),o=a(622);function i(...e){return(0,o.QP)((0,r.$)(e))}function s(e){return e?e.toString().toLowerCase().trim().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[\s_]+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,""):`artigo-sem-titulo-${Date.now()}`}function n(e){return e&&"string"==typeof e?e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9]/g,""):""}},42763:(e,t,a)=>{"use strict";a.d(t,{Cf:()=>p,Es:()=>f,HM:()=>u,L3:()=>h,c7:()=>g,lG:()=>l,rr:()=>x,zM:()=>d});var r=a(95155),o=a(12115),i=a(43146),s=a(33210),n=a(40980);let l=i.bL,d=i.l9,c=i.ZL,u=i.bm,m=o.forwardRef(({className:e,...t},a)=>(0,r.jsx)(i.hJ,{ref:a,className:(0,n.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));m.displayName=i.hJ.displayName;let p=o.forwardRef(({className:e,children:t,hideCloseButton:a,...o},l)=>(0,r.jsxs)(c,{children:[(0,r.jsx)(m,{}),(0,r.jsxs)(i.UC,{ref:l,className:(0,n.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rou
1nded-lg",e),...o,children:[t,!a&&(0,r.jsxs)(i.bm,{className:"absolute right-4 top-4 z-10 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[(0,r.jsx)(s.A,{className:"h-4 w-4"}),(0,r.jsx)("span",{className:"sr-only",children:"Fechar"})]})]})]}));p.displayName=i.UC.displayName;let g=({className:e,...t})=>(0,r.jsx)("div",{className:(0,n.cn)("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});g.displayName="DialogHeader";let f=({className:e,...t})=>(0,r.jsx)("div",{className:(0,n.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});f.displayName="DialogFooter";let h=o.forwardRef(({className:e,...t},a)=>(0,r.jsx)(i.hE,{ref:a,className:(0,n.cn)("text-lg font-semibold leading-none tracking-tight",e),...t}));h.displayName=i.hE.displayName;let x=o.forwardRef(({className:e,...t},a)=>(0,r.jsx)(i.VY,{ref:a,className:(0,n.cn)("text-sm text-muted-foreground",e),...t}));x.displayName=i.VY.displayName},43012:(e,t,a)=>{"use strict";a.d(t,{T:()=>i});var r=a(95155);a(12115);var o=a(98947);function i({documento:e}){let t=(0,o.I7)(e);if(!t)return(0,r.jsx)("span",{className:"text-sm text-destructive",children:"Documento sem p\xe1ginas v\xe1lidas: n\xe3o aparece no site."});let a=t.paginas[0];return(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("img",{src:a.miniatura??a.url,alt:"",width:72,className:"h-auto w-[72px] shrink-0 rounded border"}),(0,r.jsxs)("div",{className:"min-w-0 text-sm",children:[(0,r.jsx)("div",{className:"font-semibold",children:t.titulo}),(0,r.jsxs)("div",{className:"text-muted-foreground",children:[t.paginas.length," ",1===t.paginas.length?"p\xe1gina":"p\xe1ginas"," com visualizador",t.pdfUrl?" e PDF para baixar":"","."]}),t.legenda&&(0,r.jsx)("div",{className:"mt-1 text-muted-foreground",children:t.legenda})]})]})}},45160:(e,t,a)=>{"use strict";a.d(t,{E:()=>n});var r=a(95155);a(12115);var o=a(18460),i=a(40980);let s=(0,o.F)("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function n({className:e,variant:t,...a}){return(0,r.jsx)("span",{className:(0,i.cn)(s({variant:t}),e),...a})}},46528:()=>{},60529:(e,t,a)=>{"use strict";a.d(t,{p:()=>s});var r=a(95155),o=a(12115),i=a(40980);let s=o.forwardRef(({className:e,type:t,...a},o)=>(0,r.jsx)("input",{type:t,className:(0,i.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:o,...a}));s.displayName="Input"},67619:(e,t,a)=>{"use strict";a.d(t,{H:()=>o,O:()=>r});let r=1,o={paginasMax:80,titulo:160,legenda:400,rotulo:12}},72234:(e,t,a)=>{"use strict";a.r(t),a.d(t,{EditorArtigo:()=>ab,EditorArtigoComDados:()=>aj});var r=a(95155);a(46528);var o=a(12115),i=a(98500),s=a.n(i),n=a(71319),l=a(6296),d=a(13545),c=a(80723),u=a(41585),m=a(17243),p=a(72242),g=a(6695);let f="max-w-3xl mx-auto",h="text-base font-semibold uppercase text-primary mb-4 hover:underline",x="container mx-auto px-4";function v(e){return e.normalize("NFD").replace(/[̀-ͯ]/g,"").replace(/\s+/g," ").trim().toUpperCase()}var b=a(13276),j=a(89239),N=a(9192),y=a(42763),w=a(60529),k=a(33807),C=a(11626),$=a(30928),A=a(19865),S=a(12825);class E extends Error{constructor(e){super(e),this.name="ErroDeUpload"}}async function q(e,t,a={}){let r=(0,S.$d)(e,t);if(!r.ok)throw new E(r.mensagem);let o="video"===t||"pdf"===t,i=o?null:await new Promise(t=>{let a=URL.createObjectURL(e),r=new Image;r.onload=()=>
1{URL.revokeObjectURL(a),t(r.naturalWidth>0&&r.naturalHeight>0?{largura:r.naturalWidth,altura:r.naturalHeight}:null)},r.onerror=()=>{URL.revokeObjectURL(a),t(null)},r.src=a});if(!o&&!i)throw new E("N\xe3o foi poss\xedvel abrir esta imagem. O arquivo pode estar danificado.");let s=(0,S.mx)(t,e.name,Date.now(),Math.random().toString(36).slice(2,8)),n=(0,$.bp)((0,$.KR)(A.IG,s),e,{contentType:e.type||void 0}),l=()=>n.cancel();a.sinal?.addEventListener("abort",l,{once:!0});try{return await new Promise((e,t)=>{n.on("state_changed",e=>a.aoProgredir?.(e.totalBytes>0?Math.round(e.bytesTransferred/e.totalBytes*100):0),t,()=>e())}),{url:await (0,$.qk)(n.snapshot.ref),...i??{}}}catch(e){throw new E(function(e){switch(e?.code??""){case"storage/unauthorized":case"storage/unauthenticated":return"Sua conta ainda n\xe3o tem permiss\xe3o para enviar arquivos. Pe\xe7a a um administrador para liberar e entre de novo no sistema.";case"storage/canceled":return"Envio cancelado.";case"storage/quota-exceeded":return"O armazenamento do site est\xe1 cheio. Avise um administrador.";case"storage/retry-limit-exceeded":case"storage/network-request-failed":return"A conex\xe3o caiu durante o envio. Confira a internet e tente de novo.";default:return"N\xe3o foi poss\xedvel enviar o arquivo. Tente de novo."}}(e))}finally{a.sinal?.removeEventListener("abort",l)}}var z=a(49387),L=a(72055),_=a(56842),P=a(68459),D=a(60565),M=a(54332),R=a(74272),O=a(43038),F=a(89123),B=a(48368),T=a(75311);let U=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),V=new Set(["script","style","textarea","title"]),I=e=>" "===e||"	"===e||"\n"===e||"\r"===e||"\f"===e,X=e=>!!e&&/[A-Za-z]/.test(e);function Q(e){let t=[],a=e.length,r=0;for(;r<a;){let o=e.indexOf("<",r);if(-1===o){t.push({kind:"text",value:e.slice(r)});break}o>r&&t.push({kind:"text",value:e.slice(r,o)});let i=e[o+1];if(e.startsWith("\x3c!--",o)){let a=e.indexOf("--\x3e",o+4);if(-1===a){t.push({kind:"malformed",raw:e.slice(o)});break}t.push({kind:"comment",raw:e.slice(o,a+3)}),r=a+3;continue}if(e.startsWith("<![CDATA[",o)){let a=e.indexOf("]]>",o+9);if(-1===a){t.push({kind:"malformed",raw:e.slice(o)});break}t.push({kind:"declaration",raw:e.slice(o,a+3)}),r=a+3;continue}if("!"===i||"?"===i){let a=e.indexOf(">",o+2);if(-1===a){t.push({kind:"malformed",raw:e.slice(o)});break}t.push({kind:"declaration",raw:e.slice(o,a+1)}),r=a+1;continue}if("/"===i){let a=/^<\/([A-Za-z][^\s>/]*)\s*>/.exec(e.slice(o,o+256));if(a){t.push({kind:"close",name:a[1].toLowerCase(),raw:a[0]}),r=o+a[0].length;continue}let i=e.indexOf(">",o+2);if(-1===i){t.push({kind:"malformed",raw:e.slice(o)});break}t.push({kind:"malformed",raw:e.slice(o,i+1)}),r=i+1;continue}if(X(i)){let{token:i,end:s}=function(e,t){let a=e.length,r=t+1,o=r;for(;r<a&&!I(e[r])&&"/"!==e[r]&&">"!==e[r];)r++;let i=e.slice(o,r).toLowerCase(),s=[],n=!1;for(;;){for(;r<a&&(I(e[r])||"/"===e[r]&&">"!==e[r+1]);)r++;if(r>=a)return{token:{kind:"malformed",raw:e.slice(t)},end:a};if(">"===e[r]){r++;break}if("/"===e[r]&&">"===e[r+1]){n=!0,r+=2;break}let o=r;for(;r<a&&!I(e[r])&&"="!==e[r]&&">"!==e[r]&&("/"!==e[r]||">"!==e[r+1]);)r++;let i=e.slice(o,r).toLowerCase();if(""===i){r++;continue}for(;r<a&&I(e[r]);)r++;if("="!==e[r]){s.push({name:i,value:null});continue}for(r++;r<a&&I(e[r]);)r++;if(r>=a)return{token:{kind:"malformed",raw:e.slice(t)},end:a};let l=e[r];if('"'===l||"'"===l){let o=e.indexOf(l,r+1);if(-1===o)return{token:{kind:"malformed",raw:e.slice(t)},end:a};s.push({name:i,value:e.slice(r+1,o)}),r=o+1}else{let t=r;for(;r<a&&!I(e[r])&&">"!==e[r];)r++;s.push({name:i,value:e.slice(t,r)})}}return{token:{kind:"open",name:i,attrs:s,selfClosing:n,raw:e.slice(t,r)},end:r}}(e,o);if(t.push(i),r=s,"malformed"===i.kind)break;if("open"===i.kind&&!i.selfClosing&&V.has(i.name)){let o=RegExp(`</${i.name}\\s*>`,"i"),s=e.slice(r),n=o.exec(s);n?(n.index>0&&t.push({kind:"text",value:s.slice(0,n.index)}),t.push({kind:"close",name:i.name,raw:n[0]}),r+=n.index+n[0].length):(s.length&&t.push({kind:"text",value:s}),r=a)}continue}t.push({kind:"text",value:"<"}),r=o+1}return t}let H=/&nbsp;|&#160;|&#xa0;|\u00a0/gi,G={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:"\xa0",colon:":",tab:"	",newline:"\n",lpar:"(",rpar:")",
1sol:"/",bsol:"\\",num:"#",semi:";",comma:",",period:"."};function J(e){return e.replace(/&(#x[0-9a-f]+|#[0-9]+|[a-z][a-z0-9]*);?/gi,(e,t)=>{if("#"===t[0]){let a="x"===t[1]||"X"===t[1]?parseInt(t.slice(2),16):parseInt(t.slice(1),10);if(!Number.isFinite(a)||a<=0||a>1114111)return e;try{return String.fromCodePoint(a)}catch{return e}}let a=G[t.toLowerCase()];return void 0!==a?a:e})}function W(e){let t="";for(let a of e)t+="text"===a.kind?a.value:a.raw;return t}let Y=new Set(["p","h2","ul","ol","li","blockquote","strong","em","b","i","br","a"]),Z=new Set(["p","h2","ul","ol","blockquote"]),K=new Set(["h1","h3","h4","h5","h6","u","span","font","sup","sub","mark","small","big","s","strike","del","div","abbr","cite","code","center"]),ee=new Set([...Y,...K]),et=new Set(["href","target","rel","title"]),ea=new Set(["dir","lang","xml:lang"]),er=new Set(["http","https","mailto","tel"]),eo=new Set(["font","mark","small","big","s","strike","del","center","sup","sub"]);var ei=a(76526),es=a(8348),en=a(43012),el=a(82159),ed=a(42781);let ec="topo",eu=el.bP.create({name:"doc",topNode:!0,content:`(block | ${ec})+`}),em=el.bP.create({name:"envoltorio",group:ec,content:"(block | envoltorio)+",defining:!0,parseHTML:()=>[{tag:"div"}],renderHTML:({HTMLAttributes:e})=>["div",(0,el.KV)(e,{"data-envoltorio":""}),0]}),ep=el.bP.create({name:"htmlBruto",group:ec,atom:!0,selectable:!0,draggable:!0,addAttributes:()=>({fonte:{default:"",rendered:!1},nome:{default:"",rendered:!1},motivos:{default:[],rendered:!1}}),renderHTML:({node:e})=>["div",{"data-html-bruto":"","data-nome":String(e.attrs.nome??"")}]}),eg=el.bP.create({name:"bloco",group:ec,atom:!0,selectable:!0,draggable:!0,addAttributes:()=>({dados:{default:null,rendered:!1},oculto:{default:!1,rendered:!1}}),renderHTML:({node:e})=>["div",{"data-bloco":"","data-tipo":e.attrs.dados?.type??""}]}),ef=["paragraph","heading","bulletList","orderedList","blockquote","envoltorio","htmlBruto","bloco"],eh=el.YY.create({name:"atributosDeOrigem",addGlobalAttributes(){let e=e=>({default:e,rendered:!1,keepOnSplit:!1,parseHTML:()=>e});return[{types:[...ef],attributes:{_item:e(null),_fonte:e(null),_apos:e(""),_pre:e(""),_norm0:e(null),_perde:e(!1)}}]}});function ex(e){return e.replace(/<(\/?)h[13-6]\b[^>]*>/gi,"<$1h2>").replace(/<\/?div\b[^>]*>/gi,"").replace(/<meta\b[^>]*>/gi,"")}function ev(e={}){return[eu,ed.A.configure({document:!1,heading:{levels:[2]},bold:{},italic:{},link:{openOnClick:!1,autolink:!1,linkOnPaste:!0,defaultProtocol:"https",HTMLAttributes:{target:null,rel:null,class:null}},underline:!1,strike:!1,code:!1,codeBlock:!1,horizontalRule:!1,trailingNode:!1}),em,e.htmlBruto??ep,e.bloco??eg,eh]}var eb=a(76865);let ej=["image","video_embed","field_video","gallery_grid","quote","grafico","documento"];function eN(e,t){let a=e.state.doc.nodeAt(t);return a&&"bloco"===a.type.name?a:null}function ey(e,t,a){let{doc:r}=e.state,o=r.nodeAt(t);if(!o)return!1;let i=r.resolve(t).index(0)+a;if(i<0||i>=r.childCount)return!1;let s=r.child(i),n=e.state.tr.delete(t,t+o.nodeSize),l=a<0?t-s.nodeSize:t+s.nodeSize;return n.insert(l,o),n.setSelection(eb.nh.create(n.doc,l)),e.view.dispatch(n.scrollIntoView()),!0}let ew=(0,o.createContext)(null);function ek({valor:e,children:t}){return(0,r.jsx)(ew.Provider,{value:e,children:t})}function eC(){let e=(0,o.useContext)(ew);if(!e)throw Error("useContextoBlocos fora do ProvedorDeBlocos");return e}let e$={svg:"gr\xe1fico em SVG",style:"estilos (CSS)",script:"script",figure:"figura",table:"tabela",iframe:"conte\xfado incorporado",img:"imagem",link:"link de recurso",meta:"metadados",main:"bloco de p\xe1gina",div:"bloco com formata\xe7\xe3o pr\xf3pria","(coment\xe1rio)":"coment\xe1rio","(declara\xe7\xe3o)":"declara\xe7\xe3o HTML","(malformado)":"HTML com defeito"};function eA(e){return"string"==typeof e&&/^https:\/\//i.test(e)?e:null}function eS({editor:e,getPos:t,editavel:a}){let i=(0,o.useContext)(ew),[s,n]=(0,o.useState)(!1),l=e=>{let a=t();void 0!==a&&e(a)};return s?(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm",role:"alertdialog","aria-label":"Confirmar remo\xe7\xe3o do bloco",children:[(0,r.jsx)("span",{className:"font-medium",children:"Remover este bloco?"}),(0,r.jsx)(j.$,{type:"button",size:"sm",variant:"destructive",onClick:()=>l(t=>(function(e,t){let{doc:a,schema:r}=e.state,o=a.nodeAt(t);if(!o)return!1;let i=e.state.tr;return 1===a.childCount?i.replaceWith(t,t+o.nodeSize,r.nodes.paragraph.create()):i.delete(t,t+o.nodeSize),i.setSelection(eb.LN.near
1(i.doc.resolve(Math.min(t,i.doc.content.size)),-1)),e.view.dispatch(i.scrollIntoView()),!0})(e,t)),children:"Remover"}),(0,r.jsx)(j.$,{type:"button",size:"sm",variant:"ghost",onClick:()=>n(!1),children:"Cancelar"})]}):(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[a&&i&&(0,r.jsxs)(j.$,{type:"button",size:"sm",variant:"outline",className:"h-8 gap-1.5",onClick:()=>l(e=>i.editarBloco(e)),children:[(0,r.jsx)(z.A,{className:"h-3.5 w-3.5","aria-hidden":!0})," Editar"]}),(0,r.jsx)(j.$,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8","aria-label":"Mover para cima",title:"Mover para cima",onClick:()=>l(t=>ey(e,t,-1)),children:(0,r.jsx)(L.A,{className:"h-4 w-4"})}),(0,r.jsx)(j.$,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8","aria-label":"Mover para baixo",title:"Mover para baixo",onClick:()=>l(t=>ey(e,t,1)),children:(0,r.jsx)(_.A,{className:"h-4 w-4"})}),(0,r.jsx)(j.$,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive","aria-label":"Remover bloco",title:"Remover",onClick:()=>n(!0),children:(0,r.jsx)(P.A,{className:"h-4 w-4"})})]})}function eE({node:e,selected:t,editor:a,getPos:o}){let i=String(e.attrs.nome??""),s=e$[i]??`bloco <${i}>`;return(0,r.jsx)(n.VRb,{as:"div",className:"not-prose my-4","data-html-bruto":"",contentEditable:!1,children:(0,r.jsxs)("div",{className:`flex items-start gap-3 rounded-lg border border-dashed px-4 py-3 text-sm ${t?"border-primary bg-primary/5":"border-amber-500/70 bg-amber-50 dark:bg-amber-950/20"}`,children:[(0,r.jsx)(D.A,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600","aria-hidden":!0}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"font-semibold",children:["Bloco especial: ",s]}),(0,r.jsx)("div",{className:"text-muted-foreground",children:"Aparece no site exatamente como est\xe1. N\xe3o d\xe1 para editar aqui, mas voc\xea pode mov\xea-lo ou remov\xea-lo."})]}),(0,r.jsx)(eS,{editor:a,getPos:o,editavel:!1})]})})}function eq({node:e,selected:t,editor:a,getPos:o}){let i,s=e.attrs.dados??null;if(e.attrs.oculto)return(0,r.jsx)(n.VRb,{as:"div",style:{display:"none"},"data-bloco":""});let{icone:l,texto:d}=function(e){switch(e?.type){case"image":return{icone:(0,r.jsx)(m.A,{className:"h-4 w-4","aria-hidden":!0}),texto:"Imagem"};case"video_embed":case"embed_video":case"field_video":return{icone:(0,r.jsx)(M.A,{className:"h-4 w-4","aria-hidden":!0}),texto:"V\xeddeo"};case"gallery_grid":case"field_media":return{icone:(0,r.jsx)(R.A,{className:"h-4 w-4","aria-hidden":!0}),texto:"Galeria de fotos"};case"quote":return{icone:(0,r.jsx)(O.A,{className:"h-4 w-4","aria-hidden":!0}),texto:"Cita\xe7\xe3o"};case"grafico":return{icone:(0,r.jsx)(F.A,{className:"h-4 w-4","aria-hidden":!0}),texto:`Gr\xe1fico (${es.XJ[e.grafico?.tipo]??"tipo desconhecido"})`};case"documento":return{icone:(0,r.jsx)(B.A,{className:"h-4 w-4","aria-hidden":!0}),texto:"PDF em p\xe1ginas"};default:return{icone:(0,r.jsx)(T.A,{className:"h-4 w-4","aria-hidden":!0}),texto:`Bloco (${String(e?.type??"desconhecido")})`}}}(s),c=null;if(s?.type==="image"&&eA(s.url))c=(0,r.jsxs)("figure",{className:"mx-auto my-2 max-w-xl",children:[(0,r.jsx)("img",{src:eA(s.url),alt:s.alt||"",className:"mx-auto max-h-72 rounded-lg"}),s.caption&&(0,r.jsx)("figcaption",{className:"mt-2 border-l-4 border-primary pl-3 text-xs text-muted-foreground",children:s.caption})]});else if(s?.type==="grafico")c=(0,r.jsx)("div",{className:"pointer-events-none",children:(0,r.jsx)(ei.B,{spec:s.grafico})});else if(s?.type==="documento")c=(0,r.jsx)("div",{className:"my-2",children:(0,r.jsx)(en.T,{documento:s.documento})});else if(s?.type==="quote"){let e=function(e){let t="";for(let a of e)"text"===a.kind?t+=a.value:"open"===a.kind&&"br"===a.name&&(t+=" ");return J(t).replace(/\s+/g," ").trim()}(Q(s.content??""));c=(0,r.jsxs)("blockquote",{className:"my-2 border-l-4 border-primary pl-4 italic text-muted-foreground",children:[e,s.author&&(0,r.jsxs)("footer",{className:"mt-1 text-sm font-semibold not-italic text-foreground",children:["— ",s.author]})]})}else if((s?.type==="video_embed"||s?.type==="field_video")&&s.url)c=(0,r.jsxs)("div",{className:"break-all text-xs text-muted-foreground",children:[s.title?`${s.title} — `:"",s.url]});else if(s?.type==="gallery_grid"){let e=(s.gallery?.images??[]).filter(e=>eA(e.url));c=(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.slice(0,6).map((e,t)=>(0,r.jsx)("img",{src:eA(e.url),alt:"",className:"h-16 w-16 rounded object-cover"},t))}),(0,r.jsxs)("div",{className:"mt-1 text-xs text-muted-foreground",children:[s.gallery?.images?.length??0," foto(s)",s.gallery?.title?` — ${s.gallery.title}`:""]})]})}return(0,r.jsx)(n.VRb,{as:"div",className:"not-prose my-4","data-bloco":"","data-tipo":s?.type??"",contentEditable:!1,
1children:(0,r.jsxs)("div",{className:`rounded-lg border px-4 py-3 ${t?"border-primary bg-primary/5":"border-border bg-muted/30"}`,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm font-semibold",children:[l,(0,r.jsx)("span",{className:"truncate",children:d})]}),(0,r.jsx)(eS,{editor:a,getPos:o,editavel:(i=s?.type,ej.includes(i))})]}),c]})})}let ez=ep.extend({addNodeView:()=>(0,n.gu3)(eE)}),eL=eg.extend({addNodeView:()=>(0,n.gu3)(eq)});var e_=a(27050);function eP(e,t,a){switch(t.type.name){case"htmlBruto":return String(t.attrs.fonte??"");case"bloco":return"";case"envoltorio":{let r="";return t.forEach(t=>{r+=eP(e,t,a)}),r}default:{let r=e_.ZF.fromSchema(e).serializeNode(t,{document:a});return r.querySelectorAll("li").forEach(e=>{let t=e.firstElementChild;1===e.childNodes.length&&t&&"P"===t.tagName&&e.replaceChildren(...Array.from(t.childNodes))}),r.outerHTML}}}function eD(e,t){return{_item:e.item,_fonte:e.fonte,_apos:e.apos,_pre:e.pre,_norm0:t,_perde:e.perdeVisual}}function eM(e){return{type:"htmlBruto",attrs:{fonte:e.fonte,nome:e.nome,motivos:e.motivos,...eD(e,e.fonte)}}}function eR(e,t,a){let r=[],o=0;for(let i of t){if("bloco"===i.tipo){r.push({type:"bloco",attrs:{dados:i.dados,oculto:!!i.oculto,_item:i.item}});continue}if("protegido"===i.nivel){r.push(eM(i));continue}let t=function(e,t,a){let r=a.defaultView;if(!r||""===t.trim())return null;for(let e of Q(t))if("malformed"===e.kind||"comment"===e.kind||"declaration"===e.kind||"open"===e.kind&&!ee.has(e.name))return null;let o=new r.DOMParser().parseFromString(`<!doctype html><body>${t.replace(/<(\/?)h[13-6]\b[^>]*>/gi,"<$1h2>")}</body>`,"text/html"),i=e_.S4.fromSchema(e).parse(o.body);if(1!==i.childCount)return null;let s=i.firstChild;return(o.body.textContent??"").replace(/\s+/g,"")!==s.textContent.replace(/\s+/g,"")?null:s}(e,i.fonte,a);if(!t){o++,r.push(eM(i));continue}let s=t.toJSON();s.attrs={...s.attrs??{},...eD(i,eP(e,t,a))},r.push(s)}return 0===r.length&&r.push({type:"paragraph"}),{json:{type:"doc",content:r},protegidosPorPerda:o}}function eO(e){let t=[];return e.forEach((e,a)=>{if(!e||"text"!==e.type||"string"!=typeof e.content)return void t.push({tipo:"bloco",item:a,dados:e});let r=function(e){let t=[],a=e.length,r=0;for(;r<a;){let o=e[r];if("text"===o.kind){let o=r,i=!0;for(;o<a&&"text"===e[o].kind;)""!==e[o].value.replace(H,"").trim()&&(i=!1),o++;t.push({kind:"text",tokens:e.slice(r,o),blank:i}),r=o;continue}if("open"===o.kind){if(o.selfClosing||U.has(o.name)){t.push({kind:"element",name:o.name,tokens:[o],closed:!0}),r++;continue}let i=1,s=r+1;for(;s<a&&i>0;){let t=e[s];"open"!==t.kind||t.selfClosing||U.has(t.name)?"close"===t.kind&&!U.has(t.name)&&i--:i++,s++}t.push({kind:"element",name:o.name,tokens:e.slice(r,s),closed:0===i}),r=s;continue}"close"===o.kind&&U.has(o.name)?t.push({kind:"comment",tokens:[o]}):"close"===o.kind||"malformed"===o.kind?t.push({kind:"malformed",tokens:[o]}):"comment"===o.kind?t.push({kind:"comment",tokens:[o]}):t.push({kind:"declaration",tokens:[o]}),r++}return t}(Q(e.content));if(0===r.filter(e=>!("text"===e.kind&&e.blank)).length)return void t.push({tipo:"bloco",item:a,dados:e,oculto:!0});let o="text"===r[0].kind&&r[0].blank?W(r[0].tokens):"",i=!0;r.forEach((e,s)=>{if("text"===e.kind&&e.blank)return;let n=r[s+1],l=n&&"text"===n.kind&&n.blank?W(n.tokens):"",d=function(e){let t=new Set,a="limpo",r=!1,o=(e,r)=>{t.add(r),("protegido"===e||"higienizavel"===e&&"limpo"===a)&&(a=e)};if("text"===e.kind)return o("higienizavel","texto-solto-no-topo"),{nivel:a,motivos:[...t],nome:"(texto solto)",perdeVisual:r};if("comment"===e.kind)return o("protegido","comentario"),{nivel:a,motivos:[...t],nome:"(coment\xe1rio)",perdeVisual:r};if("declaration"===e.kind)return o("protegido","declaracao"),{nivel:a,motivos:[...t],nome:"(declara\xe7\xe3o)",perdeVisual:r};if("malformed"===e.kind)return o("protegido","malformado"),{nivel:a,motivos:[...t],nome:"(malformado)",perdeVisual:r};let i=!0;for(let t of(e.closed||o("protegido","desbalanceado"),Z.has(e.name)||("div"===e.name?0===e.tokens[0].attrs.filter(e=>!ea.has(e.name)).length?o("higienizavel","topo:div-nu"):o("protegido","topo:div-com-atributos"):K.has(e.name)?(o("higienizavel",`topo:${e.name}`),(eo.has(e.name)||/^h[1-6]$/.test(e.name))&&(r=!0)):Y.has(e.name)?o("higienizavel",`topo-inline:${e.name}`):(o("protegido",`topo:${e.name}
1`),i=!1)),e.tokens)){if("malformed"===t.kind){o("protegido","malformado");continue}if("open"===t.kind){if(i&&!Y.has(t.name)){let a=t===e.tokens[0];"span"===t.name&&0===t.attrs.length||"div"===t.name&&"div"===e.name&&a||(K.has(t.name)?(o("higienizavel",`tag:${t.name}`),eo.has(t.name)&&(r=!0)):o("protegido",`tag:${t.name}`))}for(let e of t.attrs){if(e.name.startsWith("on")||"srcdoc"===e.name||"formaction"===e.name){o("protegido",`attr-perigoso:${e.name}`);continue}if("href"===e.name||"src"===e.name||"xlink:href"===e.name||"action"===e.name){let t=function(e){let t=J(e).replace(/[\x00-\x20\x7f-\x9f]/g,"").toLowerCase(),a=/^([a-z][a-z0-9+.-]*):/.exec(t);return a?a[1]:null}(e.value??"");null===t||er.has(t)||o("protegido",`url-esquema:${t}`)}if(i)if("id"===e.name)o("protegido","attr:id");else{if(ea.has(e.name)||"a"===t.name&&et.has(e.name))continue;o("higienizavel",`attr:${e.name}`),("style"===e.name||"class"===e.name)&&(r=!0)}}}}return{nivel:a,motivos:[...t],nome:e.name,perdeVisual:r}}(e);t.push({tipo:"no",item:a,fonte:W(e.tokens),apos:l,pre:i?o:"",nivel:d.nivel,nome:d.nome,motivos:d.motivos,perdeVisual:d.perdeVisual}),i=!1})}),t}let eF=e=>!!e.origem&&e.html===e.origem.norm0;async function eB(e){let t={};try{t=await e.json()}catch{}return{status:e.status,codigo:t.error??"ERRO",mensagem:t.message??eT(e.status),erros:t.erros,atual:t.atual}}function eT(e){return 401===e?"Sua sess\xe3o expirou. Entre de novo para continuar.":403===e?"Voc\xea n\xe3o tem permiss\xe3o para fazer isso.":404===e?"Artigo n\xe3o encontrado.":e>=500?"O servidor teve um problema. Nada foi alterado; tente de novo em instantes.":"N\xe3o foi poss\xedvel concluir a a\xe7\xe3o."}async function eU(e,t){let a=await e(`/api/admin/premium-articles/${t}/editor`);if(!a.ok)throw await eB(a);return await a.json()}async function eV(e){try{let t=await e("/api/admin/editor/taxonomia");return t.ok?await t.json():null}catch{return null}}async function eI(e,t,a){try{let r=await e(`/api/admin/premium-articles/${t}/save`,{method:"POST",body:JSON.stringify(a)});if(!r.ok)return{ok:!1,erro:await eB(r)};return{ok:!0,dados:await r.json()}}catch{return{ok:!1,erro:{status:0,codigo:"REDE",mensagem:"Sem conex\xe3o com o servidor. Suas altera\xe7\xf5es continuam aqui; tente de novo."}}}}async function eX(e,t){let a=await e(`/api/admin/premium-articles/${t}/revisions`);if(!a.ok)throw await eB(a);return(await a.json()).revisoes}async function eQ(e,t,a){try{let r=await e(`/api/admin/premium-articles/${t}/revisions/${a}/restore`,{method:"POST"});if(!r.ok)return{ok:!1,erro:await eB(r)};let o=await r.json();return{ok:!0,avisos:o.avisos}}catch{return{ok:!1,erro:{status:0,codigo:"REDE",mensagem:"Sem conex\xe3o com o servidor."}}}}let eH={title:"t\xedtulo",field_teaser_text:"linha fina",field_channel:"categoria",field_tags:"tags",field_paragraphs:"texto",field_teaser_media:"imagem de destaque",imageUrlCaption:"legenda da imagem",focalPoint:"enquadramento da imagem",body:"texto",published:"publica\xe7\xe3o",disableParagraphInjectors:"an\xfancios no texto",field_logocp:"patroc\xednio",field_ficha_tecnica_cp:"ficha t\xe9cnica",field_panelizer:"layout"};function eG({tag:e,valor:t,onChange:a,chave:i,className:s,style:n,placeholder:l,rotulo:d,maxLength:c}){let u=(0,o.useRef)(null);return(0,o.useEffect)(()=>{u.current&&(u.current.textContent=t)},[i]),(0,r.jsx)(e,{ref:u,className:s,style:n,contentEditable:"plaintext-only",suppressContentEditableWarning:!0,role:"textbox","aria-label":d,"aria-multiline":"false","data-placeholder":l,spellCheck:!0,onInput:e=>a((e.currentTarget.textContent??"").replace(/\s+/g," ")),onKeyDown:e=>{"Enter"===e.key&&e.preventDefault()},onPaste:e=>{e.preventDefault();let t=e.clipboardData.getData("text/plain").replace(/\s*[\r\n]+\s*/g," ");document.execCommand("insertText",!1,c?t.slice(0,c):t)}})}var eJ=a(18349);function eW({id:e,rotulo:t,ajuda:a,erro:o,children:i}){return(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(k.J,{htmlFor:e,className:"font-semibold",children:t}),i,a&&!o&&(0,r.jsx)("p",{id:`${e}-ajuda`,className:"text-xs text-muted-foreground",children:a}),o&&(0,r.jsx)("p",{id:`${e}-erro`,className:"text-sm text-destructive",role:"alert",children:o})]})}function eY({editando:e,aoCancelar:t,aoConfirmar:a,desabilitado:o}){return(0,r.jsxs)(y.Es,{className:"gap-2 sm:gap-0",children:[(0,r.jsx)(j.$,{type:"button",variant:"ghost",onClick:t,children:"Cancelar"}),(0,r.jsx)(j.$,{type:"button",onClick:a,disabled:o,children:e?"Salvar altera\xe7\xf5es":"Inserir no artigo"})]})}function eZ({children:e}){return(0,r.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive",role:"alert",children:e})}let eK=["brasilmineral.com.br","www.brasilmineral.com.br","saneamentoambiental.com.br","media.aso1.net","images.unsplash.com","upload.wikimedia.org","storage.googleapis.com","firebasestorage.googleapis.com","*.firebasestorage.app","i.ytimg.com","img.youtube.com"];var e0=a(54688);let e1=e=>e0.Yj({error:"Preencha este campo"}).trim().min(1,"Preencha este campo").max(e,`Use no m\xe1ximo ${e} caracteres`),e2=e0.ai({error:"Informe um n\xfamero v\xe1lido"}).min(-es.QX.valorAbsMax,"N\xfamero grande demais").max(es.QX.valorAbsMax,"N\xfamero grande demais"),e4=e0.Yj({error:"Informe a unidade (pode ficar em branco)"}).trim().max(es.QX.unidade,`Use no m\xe1ximo ${es.QX.unidade} caracteres`),e5=e0.re({sessaoId:e1(64),fonteIds:e0.YO(e1(64)).max(20)}),e3={v:e0.eu(es.rq),fonte:e1(es.QX.fonte),nota:e1(es.QX.nota).optional(),origem:e5.optional()},e9=e0.re({...e3,tipo:e0.eu("barras_horizontais"),titulo:e1(es.QX.titulo),subtitulo:e1(es.QX.subtitulo).optional(),unidade:e4,itens:e0.YO(e0.re({rotulo:e1(es.QX.rotulo),valor:e2,destaque:e0.k5(["principal","secundaria"]).optional()})).min(1,"Adicione pelo menos 1 barra").max(es.QX.itensMax,`Use no m\xe1ximo ${es.QX.itensMax} barras`)}),e6=e0.re({...e3,tipo:e0.eu("barras_pareadas"),titulo:e1(es.QX.titulo),subtitulo:e1(es.QX.subtitulo).optional(),unidade:e4,series:e0.PV([e1(es.QX.serie),e1(es.QX.serie)]),itens:e0.YO(e0.re({rotulo:e1(es.QX.rotulo),valores:e0.PV([e2,e2])})).min(1,"Adicione pelo menos 1 categoria").max(es.QX.itensMax,`Use no m\xe1ximo ${es.QX.itensMax} categorias`)}),e8=e0.re({...e3,tipo:e0.eu("timeline"),titulo:e1(es.QX.titulo),subtitulo:e1(es.QX.subtitulo).optional(),eventos:e0.YO(e0.re({data:e1(es.QX.eventoData),texto:e1(es.QX.eventoTexto),status:e0.k5(["concluido","previsto"])})).min(1,"Adicione pelo menos 1 evento").max(es.QX.eventosMax,`Use no m\xe1ximo ${es.QX.eventosMax} eventos`)}),e7=e0.re({...e3,tipo:e0.eu("numeros_chave"),titulo:e1(es.QX.titulo).optional(),itens:e0.YO(e0.re({valor:e1(es.QX.numeroValor),rotulo:e1(es.QX.numeroRotulo)})).min(es.QX.numerosMin,`Use de ${es.QX.numerosMin} a ${es.QX.numerosMax} n\xfameros`).max(es.QX.numerosMax,`Use de ${es.QX.numerosMin} a ${es.QX.numerosMax} n\xfameros`)}),te=e0.gM("tipo",[e9,e6,e8,e7]);function tt(e){let t=te.safeParse(e);return t.success?{ok:!0,spec:t.data}:{ok:!1,erros:t.error.issues.map(e=>({caminho:e.path.map(String).join("."),mensagem:e.message}))}}var ta=a(67619),tr=a(98947);function to(e){if("string"!=typeof e||0===e.length||e.length>2048||/[\x00-\x20\x7f<>"`\\]/.test(e))return null;try{let t=new URL(e);return"https:"!==t.protocol||!t.hostname||t.username||t.password?null:t}catch{return null}}function ti(e){let t=e.trim();return""===t||/^https?:\/\//i.test(t)?t:/^[\w-]+(\.[\w-]+)+([/?#].*)?$/.test(t)?`https://${t}`:t}let ts=(e,t)=>({ok:!1,erros:{[e]:t}});function tn(e,t,a=new Set){let r,o=to(e);return!!o&&("admin"===t||(r=o.hostname.toLowerCase(),eK.some(e=>e.startsWith("*.")?r.endsWith(e.slice(1))&&r.length>e.length-1:r===e))||a.has(e))}let tl="Este endere\xe7o de imagem n\xe3o funciona no site. Envie o arquivo do seu computador.",td=/^[A-Za-z0-9_-]{6,20}$/;function tc(e){let t=to(e);if(!t)return null;
1let a=t.hostname.toLowerCase(),r=t.pathname.split("/").filter(Boolean);if("youtu.be"===a){let e=r[0]??"";return td.test(e)?{servico:"YouTube",url:`https://www.youtube.com/watch?v=${e}`}:null}if(["youtube.com","www.youtube.com","m.youtube.com","youtube-nocookie.com","www.youtube-nocookie.com"].includes(a)){let e="";return"watch"===r[0]?e=t.searchParams.get("v")??"":["shorts","embed","live","v"].includes(r[0]??"")&&(e=r[1]??""),td.test(e)?{servico:"YouTube",url:`https://www.youtube.com/watch?v=${e}`}:null}if("vimeo.com"===a||"www.vimeo.com"===a||"player.vimeo.com"===a){let e=r.findIndex(e=>/^\d{5,12}$/.test(e));if(e<0)return null;let a=r[e],o=t.searchParams.get("h")??(/^[0-9a-f]{8,12}$/i.test(r[e+1]??"")?r[e+1]:"");return{servico:"Vimeo",url:`https://player.vimeo.com/video/${a}${o?`?h=${o}`:""}`}}return null}let tu=e=>e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");function tm(e){let t=e?.content??"";if(""===t.trim())return{texto:"",simples:!0};let a=/^\s*<p>([^<]*)<\/p>\s*$/.exec(t);return a?{texto:tu(a[1]),simples:!0}:/[<>]/.test(t)?{texto:"",simples:!1}:{texto:tu(t),simples:!0}}let tp=e=>Math.round(10*Math.min(100,Math.max(0,e)))/10;function tg(e){let t,a=e.trim().replace(/\s+/g,"");if(""===a)return null;if(a.includes(",")){if(!/^-?\d{1,3}(\.\d{3})*(,\d+)?$|^-?\d+(,\d+)?$/.test(a))return null;t=a.replace(/\./g,"").replace(",",".")}else if(/^-?\d{1,3}(\.\d{3})+$/.test(a))t=a.replace(/\./g,"");else{if(!/^-?\d+(\.\d+)?$/.test(a))return null;t=a}let r=Number(t);return Number.isFinite(r)?r:null}function tf(e){return Number.isFinite(e)?(Number.isInteger(e)?String(e):e.toFixed(10).replace(/0+$/,"").replace(/\.$/,"")).replace(".",","):""}function th(e="barras_horizontais"){return{tipo:e,titulo:"",subtitulo:"",unidade:"",fonte:"",nota:"",serieA:"",serieB:"",linhas:[{rotulo:"",valor:"",valorB:"",destaque:""},{rotulo:"",valor:"",valorB:"",destaque:""}],eventos:[{data:"",texto:"",previsto:!1}],numeros:[{valor:"",rotulo:""},{valor:"",rotulo:""}]}}let tx={titulo:"",legenda:"",primeiraPagina:"",capaSozinha:!1,pdfUrl:"",pdfBytes:0,paginas:[]};function tv({inicial:e,aoSalvar:t,aoCancelar:a}){let{texto:i,simples:s}=tm(e),[n,l]=(0,o.useState)(i),[d,c]=(0,o.useState)(e?.author??""),[u,m]=(0,o.useState)({});return(0,r.jsxs)("div",{className:"space-y-4",children:[s?(0,r.jsx)(eW,{id:"cit-texto",rotulo:"Frase",ajuda:"S\xf3 o texto da cita\xe7\xe3o, sem aspas.",erro:u.texto,children:(0,r.jsx)(eJ.T,{id:"cit-texto",value:n,onChange:e=>{l(e.target.value),m({})},rows:4,maxLength:2e3,autoFocus:!0})}):(0,r.jsx)("div",{className:"rounded-md border border-amber-500/60 bg-amber-50 px-3 py-2 text-sm dark:bg-amber-950/20",children:"Esta cita\xe7\xe3o tem formata\xe7\xe3o pr\xf3pria (negrito, links ou v\xe1rios par\xe1grafos), por isso o texto n\xe3o pode ser editado aqui. Voc\xea ainda pode mudar quem disse."}),(0,r.jsx)(eW,{id:"cit-autor",rotulo:"Quem disse",ajuda:"Nome e cargo. Ex.: Maria Souza, diretora da mineradora. (opcional)",erro:u.autor,children:(0,r.jsx)(w.p,{id:"cit-autor",value:d,onChange:e=>c(e.target.value),maxLength:120})}),(0,r.jsx)(eY,{editando:null!==e,aoCancelar:a,aoConfirmar:()=>{let a=function(e,t=null){let{simples:a}=tm(t);if(e.autor.length>120)return ts("autor","O nome pode ter no m\xe1ximo 120 caracteres.");let r={type:"quote"};if(t&&!a)r.content=t.content;else{if(""===e.texto.trim())return ts("texto","Escreva o texto da cita\xe7\xe3o.");if(e.texto.length>2e3)return ts("texto","A cita\xe7\xe3o pode ter no m\xe1ximo 2.000 caracteres.");r.content=`<p>${e.texto.trim().replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</p>`}return e.autor.trim()&&(r.author=e.autor.trim()),{ok:!0,valor:r}}({texto:n,autor:d},e);if(!a.ok)return m(a.erros);t(a.valor)}})]})}var tb=a(51914);let tj={barras_horizontais:"Compara valores lado a lado. Ex.: produ\xe7\xe3o por mina.",barras_pareadas:"Compara dois valores para cada item. Ex.: 2024 \xd7 2025.",timeline:"Etapas ao longo do tempo, com o que j\xe1 aconteceu e o que \xe9 previsto.",numeros_chave:"De 2 a 4 n\xfameros grandes em destaque. Ex.: investimento, produ\xe7\xe3o."};function tN({inicial:e,aoSalvar:t,aoCancelar:a}){let[{rascunho:i,aviso:s}]=(0,o.useState)(()=>(function(e){let t=e?.grafico;if(!t)return{rascunho:th(),aviso:null};let a=tt(t);return a.ok?{rascunho:function(e){let t=th(e.tipo);switch(t.fonte=e.fonte,t.nota=e.nota??"",e.tipo){case"barras_horizontais":return{...t,titulo:e.titulo,subtitulo:e.subtitulo??"",unidade:e.unidade,linhas:e.itens.map(e=>({rotulo:e.rotulo,valor:tf(e.valor),valorB:"",destaque:e.destaque??""}))};case"barras_pareadas":return{...t,titulo:e.titulo,subtitulo:e.subtitulo??"",unidade:e.unidade,serieA:e.series[0],serieB:e.series[1],linhas:e.itens.map(e=>({rotulo:e.rotulo,valor:tf(e.valores[0]),valorB:tf(e.valores[1]),destaque:""}))};case"timeline":return{...t,titulo:e.titulo,subtitulo:e.subtitulo??"",eventos:e.eventos.map(e=>({data:e.data,texto:e.texto,previsto:"previsto"===e.status}))};case"numeros_chave":return{...t,titulo:e.titulo??"",numeros:e.itens.map(e=>({valor:e.valor,rotulo:e.rotulo}))}}}(a.spec),aviso:null}:{rascunho:th(es.Un.includes(t.tipo??"")?t.tipo:"barras_horizontais"),aviso:"Os dados deste gr\xe1fico estavam incompletos e n\xe3o puderam ser carregados. Preencha de novo."}})(e)),[n,l]=(0,o.useState)(i),[d,c]=(0,o.useState)(!1),u=e?.grafico?.origem,m=(0,o.useMemo)(()=>(function(e,t){let a,r={},o={v:es.rq,fonte:e.fonte,...e.nota.trim()?{nota:e.nota}:{},...t?{origem:t}:{}}
1,i=e.subtitulo.trim()?{subtitulo:e.subtitulo}:{};switch(e.tipo){case"barras_horizontais":{let t=[];e.linhas.forEach((e,a)=>{if(""===e.rotulo.trim()&&""===e.valor.trim())return;let o=tg(e.valor);""===e.rotulo.trim()?r[`linha.${a}`]=`Linha ${a+1}: falta o nome.`:null===o?r[`linha.${a}`]=`Linha ${a+1}: o valor "${e.valor}" n\xe3o \xe9 um n\xfamero. Use v\xedrgula para decimais (12,5).`:t.push({rotulo:e.rotulo,valor:o,...e.destaque?{destaque:e.destaque}:{}})}),a={...o,tipo:e.tipo,titulo:e.titulo,...i,unidade:e.unidade,itens:t};break}case"barras_pareadas":{let t=[];e.linhas.forEach((e,a)=>{if(""===e.rotulo.trim()&&""===e.valor.trim()&&""===e.valorB.trim())return;let o=tg(e.valor),i=tg(e.valorB);""===e.rotulo.trim()?r[`linha.${a}`]=`Linha ${a+1}: falta o nome.`:null===o||null===i?r[`linha.${a}`]=`Linha ${a+1}: preencha os dois valores com n\xfameros (use v\xedrgula para decimais).`:t.push({rotulo:e.rotulo,valores:[o,i]})}),a={...o,tipo:e.tipo,titulo:e.titulo,...i,unidade:e.unidade,series:[e.serieA,e.serieB],itens:t};break}case"timeline":{let t=[];e.eventos.forEach((e,a)=>{(""!==e.data.trim()||""!==e.texto.trim())&&(""===e.data.trim()||""===e.texto.trim()?r[`evento.${a}`]=`Evento ${a+1}: preencha a data e o texto.`:t.push({data:e.data,texto:e.texto,status:e.previsto?"previsto":"concluido"}))}),a={...o,tipo:e.tipo,titulo:e.titulo,...i,eventos:t};break}case"numeros_chave":{let t=[];e.numeros.forEach((e,a)=>{(""!==e.valor.trim()||""!==e.rotulo.trim())&&(""===e.valor.trim()||""===e.rotulo.trim()?r[`numero.${a}`]=`N\xfamero ${a+1}: preencha o valor e o r\xf3tulo.`:t.push({valor:e.valor,rotulo:e.rotulo}))}),a={...o,tipo:e.tipo,...e.titulo.trim()?{titulo:e.titulo}:{},itens:t}}}if(Object.keys(r).length>0)return{ok:!1,erros:r};let s=tt(a);if(s.ok)return{ok:!0,valor:s.spec};for(let e of s.erros){let t=e.caminho,a="geral";t.startsWith("titulo")?a="titulo":t.startsWith("subtitulo")?a="subtitulo":t.startsWith("unidade")?a="unidade":t.startsWith("fonte")?a="fonte":t.startsWith("nota")?a="nota":t.startsWith("series")?a="series":(t.startsWith("itens")||t.startsWith("eventos"))&&(a="itens"),r[a]||(r[a]=e.mensagem)}return{ok:!1,erros:r}})(n,u),[n,u]),p=m.ok?{}:m.erros,g=e=>d?p[e]:void 0,f=e=>l(t=>({...t,...e})),h="barras_horizontais"===n.tipo||"barras_pareadas"===n.tipo,x="barras_pareadas"===n.tipo,v=(e,t)=>f({linhas:n.linhas.map((a,r)=>r===e?{...a,...t}:a)}),b=(e,t)=>{let a=e+t;if(a<0||a>=n.linhas.length)return;let r=[...n.linhas];[r[e],r[a]]=[r[a],r[e]],f({linhas:r})};return(0,r.jsxs)("div",{className:"grid gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[(0,r.jsxs)("div",{className:"space-y-4",children:[s&&(0,r.jsx)(eZ,{children:s}),(0,r.jsxs)("fieldset",{children:[(0,r.jsx)("legend",{className:"mb-2 text-sm font-semibold",children:"Tipo de gr\xe1fico"}),(0,r.jsx)("div",{className:"grid gap-2 sm:grid-cols-2",children:es.Un.map(e=>(0,r.jsxs)("label",{className:`cursor-pointer rounded-lg border p-2.5 text-sm transition-colors ${n.tipo===e?"border-primary bg-primary/5":"hover:bg-muted/40"}`,children:[(0,r.jsx)("input",{type:"radio",name:"grafico-tipo",className:"sr-only",checked:n.tipo===e,onChange:()=>f({tipo:e})}),(0,r.jsx)("span",{className:"block font-semibold",children:es.XJ[e]}),(0,r.jsx)("span",{className:"block text-xs text-muted-foreground",children:tj[e]})]},e))})]}),(0,r.jsx)(eW,{id:"gr-titulo",rotulo:"numeros_chave"===n.tipo?"T\xedtulo (opcional)":"T\xedtulo",erro:g("titulo"),children:(0,r.jsx)(w.p,{id:"gr-titulo",value:n.titulo,onChange:e=>f({titulo:e.target.value}),maxLength:es.QX.titulo})}),"numeros_chave"!==n.tipo&&(0,r.jsx)(eW,{id:"gr-subtitulo",rotulo:"Subt\xedtulo",ajuda:"(opcional)",erro:g("subtitulo"),children:(0,r.jsx)(w.p,{id:"gr-subtitulo",value:n.subtitulo,onChange:e=>f({subtitulo:e.target.value}),maxLength:es.QX.subtitulo})}),h&&(0,r.jsx)(eW,{id:"gr-unidade",rotulo:"Unidade",ajuda:"Ex.: %, US$ milh\xf5es, mil t. Com “%” a barra usa o n\xfamero como porcentagem. Pode ficar em branco.",erro:g("unidade"),children:(0,r.jsx)(w.p,{id:"gr-unidade",value:n.unidade,onChange:e=>f({unidade:e.target.value}),maxLength:es.QX.unidade,className:"max-w-xs"})}),x&&(0,r.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,r.jsx)(eW,{id:"gr-serie-a",rotulo:"Primeira s\xe9rie",ajuda:"Ex.: 2024",erro:g("series"),children:(0,r.jsx)(w.p,{id:"gr-serie-a",value:n.serieA,onChange:e=>f({serieA:e.target.value}),maxLength:es.QX.serie})}),(0,r.jsx)(eW,{id:"gr-serie-b",rotulo:"Segunda s\xe9rie",ajuda:"Ex.: 2025",children:(0,r.jsx)(w.p,{id:"gr-serie-b",value:n.serieB,onChange:e=>f({serieB:e.target.value}),maxLength:es.QX.serie})})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-sm font-semibold",children:h?"Dados":"timeline"===n.tipo?"Etapas":"N\xfameros"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"Use v\xedrgula nos decimais (12,5)"})]}),h&&(0,r.jsx)("ul",{className:"space-y-2",children:n.linhas.map((e,t)=>(0,r.jsxs)("li",{className:"grid grid-cols-[minmax(0,1fr)_5.5rem_auto] items-center gap-2 sm:grid-cols-[minmax(0,1fr)_6rem_auto]",children:[(0,r.jsxs)("div",{className:`grid gap-2 ${x?"col-span-1":""}`,children:[(0,r.jsx)(w.p,{"aria-label":`Nome da linha ${t+1}`,placeholder:"Nome",value:e.rotulo,onChange:e=>v(t,{rotulo:e.target.value}),maxLength:es.QX.rotulo}),!x&&(0,r.jsxs)("select",{"aria-label":`Destaque da linha ${t+1}`,className:"h-9 rounded-md border border-input bg-background px-2 text-sm",value:e.destaque,onChange:e=>v(t,{destaque:e.target.value}),children:[(0,r.jsx)("option",{value:"",children:"Cor normal"}),(0,r.jsx)("option",{value:"principal",children:"Destaque principal"}),(0,r.jsx)("option",{value:"secundaria",children:"Destaque secund\xe1rio"})]})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)(w.p,{"aria-label":`${x?`${n.serieA||"Primeiro"} da`:"Valor da"} linha ${t+1}`,inputMode:"decimal",placeholder:x?n.serieA||"Valor 1":"Valor",value:e.valor,onChange:e=>v(t,{valor:e.target.value})}),x&&(0,r.jsx)(w.p,{"aria-label":`${n.serieB||"Segundo"} da linha ${t+1}`,inputMode:"decimal",placeholder:n.serieB||"Valor 2",value:e.valorB,onChange:e=>v(t,{valorB:e.target.value})})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,r.jsx)(j.$,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7","aria-label":`Subir a linha ${t+1}`,disabled:0===t,onClick:()=>b(t,-1),children:(0,r.jsx)(L.A,{className:"h-3.5 w-3.5"})}),(0,r.jsx)(j.$,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7","aria-label":`Descer a linha ${t+1}`,disabled:t===n.linhas.length-1,onClick:()=>b(t,1),children:(0,r.jsx)(_.A,{className:"h-3.5 w-3.5"})}),(0,r.jsx)(j.$,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive","aria-label":`Remover a linha ${t+1}`,onClick:()=>f({linhas:n.linhas.filter((e,a)=>a!==t)}),children:(0,r.jsx)(P.A,{className:"h-3.5 w-3.5"})})]}),g(`linha.${t}`)&&(0,r.jsx)("p",{className:"col-span-3 text-sm text-destructive",role:"alert",children:g(`linha.${t}`)})]},t))}),"timeline"===n.tipo&&(0,r.jsx)("ul",{className:"space-y-2",children:n.eventos.map((e,t)=>(0,r.jsxs)("li",{className:"space-y-1.5 rounded-lg border p-2",children:[(0,r.jsxs)("div",{className:"grid grid-cols-[7rem_minmax(0,1fr)_auto] items-center gap-2",children:[(0,r.jsx)(w.p,{"aria-label":`Data da etapa ${t+1}`,placeholder:"Ex.: 4\xba tri/2026",value:e.data,onChange:e=>f({eventos:n.eventos.map((a,r)=>
1r===t?{...a,data:e.target.value}:a)}),maxLength:es.QX.eventoData}),(0,r.jsx)(w.p,{"aria-label":`Texto da etapa ${t+1}`,placeholder:"O que acontece",value:e.texto,onChange:e=>f({eventos:n.eventos.map((a,r)=>r===t?{...a,texto:e.target.value}:a)}),maxLength:es.QX.eventoTexto}),(0,r.jsx)(j.$,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive","aria-label":`Remover a etapa ${t+1}`,onClick:()=>f({eventos:n.eventos.filter((e,a)=>a!==t)}),children:(0,r.jsx)(P.A,{className:"h-4 w-4"})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(N.S,{id:`gr-prev-${t}`,checked:e.previsto,onCheckedChange:e=>f({eventos:n.eventos.map((a,r)=>r===t?{...a,previsto:!0===e}:a)})}),(0,r.jsx)(k.J,{htmlFor:`gr-prev-${t}`,className:"text-sm font-normal",children:"Ainda vai acontecer (previsto)"})]}),g(`evento.${t}`)&&(0,r.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:g(`evento.${t}`)})]},t))}),"numeros_chave"===n.tipo&&(0,r.jsx)("ul",{className:"space-y-2",children:n.numeros.map((e,t)=>(0,r.jsxs)("li",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"grid grid-cols-[8rem_minmax(0,1fr)_auto] items-center gap-2",children:[(0,r.jsx)(w.p,{"aria-label":`N\xfamero ${t+1}`,placeholder:"Ex.: US$ 500 mi",value:e.valor,onChange:e=>f({numeros:n.numeros.map((a,r)=>r===t?{...a,valor:e.target.value}:a)}),maxLength:es.QX.numeroValor}),(0,r.jsx)(w.p,{"aria-label":`R\xf3tulo do n\xfamero ${t+1}`,placeholder:"O que \xe9",value:e.rotulo,onChange:e=>f({numeros:n.numeros.map((a,r)=>r===t?{...a,rotulo:e.target.value}:a)}),maxLength:es.QX.numeroRotulo}),(0,r.jsx)(j.$,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive","aria-label":`Remover o n\xfamero ${t+1}`,onClick:()=>f({numeros:n.numeros.filter((e,a)=>a!==t)}),children:(0,r.jsx)(P.A,{className:"h-4 w-4"})})]}),g(`numero.${t}`)&&(0,r.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:g(`numero.${t}`)})]},t))}),g("itens")&&(0,r.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:g("itens")}),(0,r.jsxs)(j.$,{type:"button",variant:"outline",size:"sm",className:"gap-1",disabled:h&&n.linhas.length>=es.QX.itensMax||"timeline"===n.tipo&&n.eventos.length>=es.QX.eventosMax||"numeros_chave"===n.tipo&&n.numeros.length>=es.QX.numerosMax,onClick:()=>{h?f({linhas:[...n.linhas,{rotulo:"",valor:"",valorB:"",destaque:""}]}):"timeline"===n.tipo?f({eventos:[...n.eventos,{data:"",texto:"",previsto:!1}]}):f({numeros:[...n.numeros,{valor:"",rotulo:""}]})},children:[(0,r.jsx)(tb.A,{className:"h-4 w-4","aria-hidden":!0})," ",h?"Adicionar linha":"timeline"===n.tipo?"Adicionar etapa":"Adicionar n\xfamero"]})]}),(0,r.jsx)(eW,{id:"gr-fonte",rotulo:"Fonte",ajuda:"Obrigat\xf3ria: de onde v\xeam os n\xfameros. Ex.: Relat\xf3rio da empresa, 2026.",erro:g("fonte"),children:(0,r.jsx)(w.p,{id:"gr-fonte",value:n.fonte,onChange:e=>f({fonte:e.target.value}),maxLength:es.QX.fonte})}),(0,r.jsx)(eW,{id:"gr-nota",rotulo:"Nota",ajuda:"(opcional)",erro:g("nota"),children:(0,r.jsx)(w.p,{id:"gr-nota",value:n.nota,onChange:e=>f({nota:e.target.value}),maxLength:es.QX.nota})})]}),(0,r.jsxs)("div",{className:"min-w-0 lg:sticky lg:top-0 lg:self-start",children:[(0,r.jsx)("div",{className:"mb-2 text-sm font-semibold",children:"Como vai aparecer no site"}),(0,r.jsx)("div",{className:"rounded-lg border bg-background p-3","data-testid":"previa-grafico",children:m.ok?(0,r.jsx)(ei.B,{spec:m.valor}):(0,r.jsx)("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"Preencha o t\xedtulo, os dados e a fonte para ver a pr\xe9via do gr\xe1fico aqui."})}),d&&!m.ok&&(0,r.jsx)("div",{className:"mt-3",children:(0,r.jsx)(eZ,{children:"Faltam informa\xe7\xf5es no gr\xe1fico. Confira os campos em vermelho."})})]}),(0,r.jsx)("div",{className:"lg:col-span-2",children:(0,r.jsx)(eY,{editando:null!==e,aoCancelar:a,aoConfirmar:()=>{m.ok?t({type:"grafico",grafico:m.valor}):c(!0)}})})]})}var ty=a(21975),tw=a(1606);let tk=[{chave:"grande",largura:1600,qualidade:.8},{chave:"leitura",largura:900,qualidade:.78},{chave:"miniatura",largura:240,qualidade:.7}];
1class tC extends Error{constructor(e){super(e),this.name="ErroDePdf"}}async function t$(e,t,r){let o,{pdfjs:i}=await Promise.all([a.e(23309),a.e(33165)]).then(a.bind(a,33165));i.GlobalWorkerOptions.workerSrc="/pdf.worker.min.mjs";try{o=await i.getDocument({data:new Uint8Array(await e.arrayBuffer())}).promise}catch(e){throw new tC("PasswordException"===e?.name?"Este PDF est\xe1 protegido por senha. Salve uma c\xf3pia sem senha e tente de novo.":"N\xe3o foi poss\xedvel abrir este PDF. O arquivo pode estar danificado.")}try{let e=o.numPages;if(e>ta.H.paginasMax)throw new tC(`O PDF tem ${e} p\xe1ginas e o limite \xe9 ${ta.H.paginasMax}. Separe s\xf3 as p\xe1ginas da mat\xe9ria.`);let a=tk[0];for(let i=1;i<=e;i++){if(r?.aborted)throw new tC("Envio cancelado.");let s=await o.getPage(i),n=s.getViewport({scale:1}),l=s.getViewport({scale:a.largura/n.width}),d=document.createElement("canvas");d.width=Math.round(l.width),d.height=Math.round(l.height);let c=d.getContext("2d");c.fillStyle="#ffffff",c.fillRect(0,0,d.width,d.height),await s.render({canvasContext:c,viewport:l}).promise;let u={};for(let e of tk){let t=e.largura===d.width?d:function(e,t){let a=e;for(;a.width/2>t;){let e=document.createElement("canvas");e.width=Math.round(a.width/2),e.height=Math.round(a.height/2);let t=e.getContext("2d");t.imageSmoothingQuality="high",t.drawImage(a,0,0,e.width,e.height),a=e}let r=document.createElement("canvas");r.width=t,r.height=Math.round(e.height*t/e.width);let o=r.getContext("2d");return o.imageSmoothingQuality="high",o.drawImage(a,0,0,r.width,r.height),r}(d,e.largura);u[e.chave]={blob:await function(e,t){return new Promise((a,r)=>e.toBlob(e=>e?a(e):r(new tC("O navegador n\xe3o conseguiu gerar a imagem da p\xe1gina.")),"image/webp",t))}(t,e.qualidade),largura:t.width,altura:t.height}}s.cleanup(),await t({numero:i,arquivos:u},e)}return e}finally{o.destroy()}}let tA={grande:"1600",leitura:"900",miniatura:"240"};function tS({inicial:e,aoSalvar:t,aoCancelar:a}){let{enviar:i}=eC(),[s,n]=(0,o.useState)(()=>(function(e){let t=e?.type==="documento"?(0,tr.I7)(e.documento):null;if(!t)return tx;let a=t.paginas[0]?.rotulo??"";return{titulo:t.titulo,legenda:t.legenda??"",primeiraPagina:/^\d+$/.test(a)&&"1"!==a?a:"",capaSozinha:!!t.capaSozinha,pdfUrl:t.pdfUrl??"",pdfBytes:t.pdfBytes??0,paginas:t.paginas.map(e=>({url:e.url,largura:e.largura,altura:e.altura,...e.urlGrande?{urlGrande:e.urlGrande}:{},...e.miniatura?{miniatura:e.miniatura}:{}}))}})(e)),[d,c]=(0,o.useState)({}),[u,m]=(0,o.useState)(null),p=(0,o.useRef)(null),g=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>g.current?.abort(),[]);let f=null!==u,h=S.LG.pdf,x=async e=>{if(!e||f)return;let t=(0,S.$d)(e,"pdf");if(!t.ok)return c({paginas:t.mensagem});let a=new AbortController;g.current=a,c({});let r=(0,S.Bg)(e.name),o=[];try{m({texto:"Abrindo o PDF…",pct:0}),await t$(e,async(e,t)=>{m({texto:`Preparando e enviando a p\xe1gina ${e.numero} de ${t}…`,pct:Math.round((e.numero-1)/t*90)});let s={};for(let t of["grande","leitura","miniatura"]){let{blob:o}=e.arquivos[t],n=`${r}-p${String(e.numero).padStart(2,"0")}-${tA[t]}.webp`,l=await i(new File([o],n,{type:"image/webp"}),"imagem",{sinal:a.signal});s[t]=l.url}o.push({url:s.leitura,urlGrande:s.grande,miniatura:s.miniatura,largura:e.arquivos.leitura.largura,altura:e.arquivos.leitura.altura})},a.signal),m({texto:"Enviando o PDF original…",pct:90});let t=await i(e,"pdf",{sinal:a.signal,aoProgredir:e=>m({texto:"Enviando o PDF original…",pct:90+Math.round(e/10)})});if(a.signal.aborted)return;n(a=>({...a,paginas:o,pdfUrl:t.url,pdfBytes:e.size}))}catch(e){a.signal.aborted||c({paginas:e instanceof tC||e instanceof Error?e.message:"N\xe3o foi poss\xedvel preparar o PDF. Tente de novo."})}finally{a.signal.aborted||m(null),p.current&&(p.current.value="")}},v=s.paginas.length>0;return(0,r.jsxs)("div",{className:"space-y-4",children:[v&&(0,r.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border bg-muted/30 p-3",children:[(0,r.jsx)("img",{src:s.paginas[0].miniatura??s.paginas[0].url,alt:"",className:"h-20 w-auto rounded border bg-white"}),(0,r.jsxs)("div",{className:"text-sm",children:[(0,r.jsxs)("div",{className:"font-semibold",children:[s.paginas.length," ",1===s.paginas.length?"p\xe1gina pronta":"p\xe1ginas prontas"]}),(0,r.jsx)("div",{className:"text-muted-foreground",children:s.pdfUrl?`PDF original inclu\xeddo${s.pdfBytes?` (${(0,tr.ix)(s.pdfBytes)})`:""}, para quem quiser baixar.`:"Sem PDF para baixar."})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{role:"button",tabIndex:f?-1:0,"aria-disabled":f,onClick:()=>!f&&p.current?.click(),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||f||(e.preventDefault(),p.current?.click())},onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),x(e.dataTransfer.files[0])},className:`flex cursor-pointer flex-col items-center justify-center gap-1 rounded-lg border-2 border-dashed border-border px-4 py-6 text-center text-sm transition-colors hover:border-primary/60 hover:bg-muted/40 ${f?"pointer-events-none opacity-60":""}`,children:[f?(0,r.jsx)(l.A,{className:"h-5 w-5 animate-spin text-primary","aria-hidden":!0}):v?(0,r.jsx)(B.A,{className:"h-5 w-5 text-muted-foreground","aria-hidden":!0}):(0,r.jsx)(ty.A,{className:"h-5 w-5 text-muted-foreground","aria-hidden":!0}),(0,r.jsx)("span",{className:"font-medium",children:f?u.texto:v?"Trocar o PDF":"Escolher o PDF no computador ou arrastar at\xe9 aqui"}),(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:["S\xf3 as p\xe1ginas da mat\xe9ria: at\xe9 ",ta.H.paginasMax," p\xe1ginas e ",(0,S.p1)(h.maxBytes),". Cada p\xe1gina vira uma imagem leve; o PDF fica para baixar."]})]}),(0,r.jsx)("input",{ref:p,type:"file",className:"sr-only",tabIndex:-1,accept:"application/pdf,.pdf",onChange:e=>void x(e.target.files?.[0]),"data-testid":"seletor-de-pdf"}),u&&(0,r.jsxs)("div",{className:"mt-2","aria-live":"polite",children:[(0,r.jsx)(tw.k,{value:u.pct,className:"h-2"}),(0,r.jsxs)("div",{className:"mt-1 text-xs text-muted-foreground",children:[u.pct,"% — n\xe3o feche esta janela."]})]})]}),d.paginas&&(0,r.jsx)(eZ,{children:d.paginas}),(0,r.jsx)(eW,{id:"pdf-titulo",rotulo:"De onde \xe9 o documento",ajuda:"Aparece no alto do visualizador. Ex.: Brasil Mineral n\xba 257 – Dezembro de 2006",erro:d.titulo,children:(0,r.jsx)(w.p,{id:"pdf-titulo",value:s.titulo,onChange:e=>n(t=>({...t,titulo:e.target.value})),maxLength:ta.H.titulo})}),(0,r.jsx)(eW,{id:"pdf-legenda",rotulo:"Legenda",ajuda:"O que o leitor vai encontrar nas p\xe1ginas. (opcional)",erro:d.legenda,children:(0,r.jsx)(eJ.T,{id:"pdf-legenda",rows:3,value:s.legenda,onChange:e=>n(t=>({...t,legenda:e.target.value})),maxLength:ta.H.legenda})}),(0,r.jsx)(eW,{id:"pdf-primeira",rotulo:"N\xfamero impresso na primeira p\xe1gina",ajuda:"Se a mat\xe9ria come\xe7a na p\xe1gina 20 da revista, escreva 20: as miniaturas mostram 20, 21, 22… Em branco, contam a partir de 1.",erro:d.primeiraPagina,children:(0,r.jsx)(w.p,{id:"pdf-primeira",inputMode:"numeric",className:"max-w-28",value:s.primeiraPagina,onChange:e=>n(t=>({...t,primeiraPagina:e.target.value})),maxLength:4})}),(0,r.jsxs)("label",{className:"flex items-start gap-2 text-sm",children:[(0,r.jsx)("input",{type:"checkbox",className:"mt-1",checked:s.capaSozinha,onChange:e=>n(t=>({...t,capaSozinha:e.target.checked}))}),(0,r.jsxs)("span",{children:["A primeira p\xe1gina \xe9 uma capa",(0,r.jsx)("span",{className:"block text-xs text-muted-foreground",children:"Na tela cheia ela aparece sozinha e as outras em pares, como a revista aberta."})]})]}),(0,r.jsx)(eY,{editando:null!==e,aoCancelar:a,aoConfirmar:()=>{let e=function(e){let t=e.titulo.trim();if(0===e.paginas.length)return ts("paginas","Escolha o PDF: as p\xe1ginas ainda n\xe3o foram enviadas.");
1if(e.paginas.length>ta.H.paginasMax)return ts("paginas",`O PDF tem ${e.paginas.length} p\xe1ginas e o limite \xe9 ${ta.H.paginasMax}.`);if(""===t)return ts("titulo","Diga de onde \xe9 o documento (por exemplo: Brasil Mineral n\xba 257 – Dezembro de 2006).");if(t.length>ta.H.titulo)return ts("titulo",`No m\xe1ximo ${ta.H.titulo} caracteres.`);if(e.legenda.trim().length>ta.H.legenda)return ts("legenda",`No m\xe1ximo ${ta.H.legenda} caracteres.`);let a=e.primeiraPagina.trim();if(""!==a&&!/^\d{1,4}$/.test(a))return ts("primeiraPagina","Use s\xf3 o n\xfamero (por exemplo: 20).");let r=""===a?null:Number(a),o={v:ta.O,titulo:t,...e.legenda.trim()?{legenda:e.legenda.trim()}:{},...e.pdfUrl?{pdfUrl:e.pdfUrl,...e.pdfBytes>0?{pdfBytes:e.pdfBytes}:{}}:{},...e.capaSozinha?{capaSozinha:!0}:{},paginas:e.paginas.map((e,t)=>({...e,...null!==r?{rotulo:String(r+t)}:{}}))},i=(0,tr.I7)(o);return i&&i.paginas.length===e.paginas.length?{ok:!0,valor:{type:"documento",documento:i,content:(0,tr.Xr)(i)}}:ts("paginas","H\xe1 p\xe1gina que n\xe3o foi enviada ao armazenamento do site. Envie o PDF de novo.")}(s);if(!e.ok)return c(e.erros);t(e.valor)},desabilitado:f})]})}var tE=a(12651);function tq({tipo:e,multiplo:t=!1,onEnviado:a,rotulo:i,desabilitado:s=!1}){let{enviar:n}=eC(),d=(0,o.useRef)(null),c=(0,o.useRef)(null),[u,m]=(0,o.useState)(null),[p,g]=(0,o.useState)([]),[f,h]=(0,o.useState)(!1);(0,o.useEffect)(()=>()=>c.current?.abort(),[]);let x="video"===e?S.LG.video:S.LG.imagem,v="video"===e?`Somente MP4, at\xe9 ${(0,S.p1)(x.maxBytes)}`:`JPG, PNG, WebP ou GIF, at\xe9 ${(0,S.p1)(x.maxBytes)} cada`,b=null!==u,j=async r=>{if(0===r.length||b||s)return;let o=t?r:r.slice(0,1),i=new AbortController;c.current=i;let l=[];for(let[t,r]of(g([]),o.entries())){if(i.signal.aborted)break;m({nome:r.name,pct:0,posicao:t+1,total:o.length});try{let t=await n(r,e,{sinal:i.signal,aoProgredir:e=>m(t=>t?{...t,pct:e}:t)});i.signal.aborted||a(t,r)}catch(e){l.push(`${r.name}: ${e.message}`)}}i.signal.aborted||(m(null),g(l)),d.current&&(d.current.value="")};return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{role:"button",tabIndex:s||b?-1:0,"aria-disabled":s||b,"aria-label":i,onClick:()=>!b&&!s&&d.current?.click(),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||b||s||(e.preventDefault(),d.current?.click())},onDragOver:e=>{e.preventDefault(),h(!0)},onDragLeave:()=>h(!1),onDrop:e=>{e.preventDefault(),h(!1),j(Array.from(e.dataTransfer.files))},className:`flex cursor-pointer flex-col items-center justify-center gap-1 rounded-lg border-2 border-dashed px-4 py-6 text-center text-sm transition-colors ${f?"border-primary bg-primary/5":"border-border hover:border-primary/60 hover:bg-muted/40"} ${b||s?"pointer-events-none opacity-60":""}`,children:[b?(0,r.jsx)(l.A,{className:"h-5 w-5 animate-spin text-primary","aria-hidden":!0}):(0,r.jsx)(ty.A,{className:"h-5 w-5 text-muted-foreground","aria-hidden":!0}),(0,r.jsx)("span",{className:"font-medium",children:b?`Enviando ${u.nome}…`:i}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:v})]}),(0,r.jsx)("input",{ref:d,type:"file",className:"sr-only",tabIndex:-1,accept:x.tipos.join(","),multiple:t,onChange:e=>void j(Array.from(e.target.files??[])),"data-testid":"seletor-de-arquivo"}),u&&(0,r.jsxs)("div",{className:"mt-2","aria-live":"polite",children:[(0,r.jsx)(tw.k,{value:u.pct,className:"h-2"}),(0,r.jsxs)("div",{className:"mt-1 text-xs text-muted-foreground",children:[u.total>1?`Arquivo ${u.posicao} de ${u.total} — `:"",u.pct,"%"]})]}),p.length>0&&(0,r.jsx)("ul",{className:"mt-2 space-y-1 text-sm text-destructive",role:"alert",children:p.map(e=>(0,r.jsx)("li",{children:e},e))})]})}function tz({inicial:e,aoSalvar:t,aoCancelar:a}){let{papel:i,urlsDoArtigo:s}=eC(),[n,l]=(0,o.useState)(()=>({url:e?.url??"",alt:e?.alt??"",legenda:e?.caption??"",largura:e?.width,altura:e?.height})),[d,c]=(0,o.useState)(!1),[u,m]=(0,o.useState)({}),p=null!==to(n.url);return(0,r.jsxs)("div",{className:"space-y-4",children:[p&&(0,r.jsx)("div",{className:"rounded-lg border bg-muted/30 p-2",children:(0,r.jsx)("img",{src:n.url,alt:"",className:"mx-auto max-h-56 rounded"})}),(0,r.jsx)(tq,{tipo:"imagem",rotulo:p?"Trocar a imagem":"Escolher a imagem no computador ou arrastar at\xe9 aqui",onEnviado:e=>{l(t=>({...t,url:e.url,largura:e.largura,altura:e.altura})),m(e=>({...e,url:""}))}}),u.url&&(0,r.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:u.url}),d?(0,r.jsx)(eW,{id:"img-url",rotulo:"Endere\xe7o da imagem",ajuda:"S\xf3 use se a imagem j\xe1 estiver na internet em um endere\xe7o do site.",erro:void 0,children:(0,r.jsx)(w.p,{id:"img-url",value:n.url,onChange:e=>l(t=>({...t,url:e.target.value,largura:void 0,altura:void 0})),placeholder:"https://…"})}):(0,r.jsx)("button",{type:"button",className:"text-sm text-muted-foreground underline",onClick:()=>c(!0),children:"J\xe1 tenho o endere\xe7o da imagem"}),(0,r.jsx)(eW,{id:"img-alt",rotulo:"Descri\xe7\xe3o da imagem",ajuda:"Uma frase dizendo o que aparece. Ajuda quem usa leitor de tela e o Google. (opcional)",erro:u.alt,children:(0,r.jsx)(w.p,{id:"img-alt",value:n.alt,onChange:e=>l(t=>({...t,alt:e.target.value})),maxLength:300})}),(0,r.jsx)(eW,{id:"img-legenda",rotulo:"Legenda",ajuda:"Aparece abaixo da imagem. Ex.: “Vista a\xe9rea da mina. Foto: Fulano”. (opcional)",erro:u.legenda,children:(0,r.jsx)(w.p,{id:"img-legenda",value:n.legenda,onChange:e=>l(t=>({...t,legenda:e.target.value})),maxLength:500})}),(0,r.jsx)(eY,{editando:null!==e,aoCancelar:a,aoConfirmar:()=>{let a=function(e,t="editor",a,r=null){let o=ti(e.url);if(!to(o))return ts("url","Envie uma imagem ou informe um endere\xe7o que comece com https://.");if(!tn(o,t,a))return ts("url",tl);if(e.alt.length>300)return ts("alt","A descri\xe7\xe3o pode ter no m\xe1ximo 300 caracteres.");if(e.legenda.length>500)return ts("legenda","A legenda pode ter no m\xe1ximo 500 caracteres.");let i={type:"image",url:o};return e.alt.trim()&&(i.alt=e.alt.trim()),e.legenda.trim()&&(i.caption=e.legenda.trim()),r?.title&&(i.title=r.title),e.largura&&Number.isInteger(e.largura)&&e.largura>0&&e.largura<=2e4&&(i.width=e.largura),e.altura&&Number.isInteger(e.altura)&&e.altura>0&&e.altura<=2e4&&(i.height=e.altura),{ok:!0,valor:i}}(n,i,s,e);if(!a.ok)return m(a.erros);t(a.valor)}})]})}function tL({inicial:e,aoSalvar:t,aoCancelar:a}){let{papel:i}=eC(),[s,n]=(0,o.useState)(()=>
1({url:e?.url||e?.videoEmbed?.uri||"",titulo:e?.title||e?.videoEmbed?.title||""})),[l,d]=(0,o.useState)({}),c=tc(ti(s.url));return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(eW,{id:"vid-url",rotulo:"Endere\xe7o do v\xeddeo",ajuda:"Abra o v\xeddeo no YouTube ou no Vimeo, copie o endere\xe7o da barra do navegador e cole aqui.",erro:l.url,children:(0,r.jsx)(w.p,{id:"vid-url",value:s.url,onChange:e=>{n(t=>({...t,url:e.target.value})),d({})},placeholder:"https://www.youtube.com/watch?v=…",autoFocus:!0})}),c&&(0,r.jsxs)("p",{className:"flex items-center gap-1.5 text-sm text-emerald-700 dark:text-emerald-400",children:[(0,r.jsx)(tE.A,{className:"h-4 w-4","aria-hidden":!0})," V\xeddeo do ",c.servico," reconhecido."]}),!c&&""!==s.url.trim()&&"editor"===i&&(0,r.jsx)("p",{className:"text-sm text-amber-700 dark:text-amber-400",children:"S\xf3 links do YouTube ou do Vimeo funcionam aqui."}),(0,r.jsx)(eW,{id:"vid-titulo",rotulo:"T\xedtulo do v\xeddeo",ajuda:"Descreve o v\xeddeo para quem usa leitor de tela. (opcional)",erro:l.titulo,children:(0,r.jsx)(w.p,{id:"vid-titulo",value:s.titulo,onChange:e=>n(t=>({...t,titulo:e.target.value})),maxLength:200})}),(0,r.jsx)(eY,{editando:null!==e,aoCancelar:a,aoConfirmar:()=>{let e=function(e,t){let a=ti(e.url);if(!to(a))return ts("url","Cole o endere\xe7o do v\xeddeo (come\xe7a com https://).");let r=tc(a);if(!r&&"editor"===t)return ts("url","S\xf3 v\xeddeos do YouTube ou do Vimeo podem ser incorporados. Cole o link da p\xe1gina do v\xeddeo.");let o=r?.url??a;if(e.titulo.length>200)return ts("titulo","O t\xedtulo pode ter no m\xe1ximo 200 caracteres.");let i={type:"video_embed",url:o};return e.titulo.trim()&&(i.title=e.titulo.trim()),{ok:!0,valor:i}}(s,i);if(!e.ok)return d(e.erros);t(e.valor)}})]})}function t_({inicial:e,aoSalvar:t,aoCancelar:a}){let[i,s]=(0,o.useState)(()=>({url:e?.url||e?.drupalVideo?.url||"",titulo:e?.title||e?.drupalVideo?.title||""})),[n,l]=(0,o.useState)({}),d=null!==to(i.url);return(0,r.jsxs)("div",{className:"space-y-4",children:[d&&(0,r.jsx)("video",{src:i.url,controls:!0,preload:"metadata",className:"mx-auto max-h-56 w-full rounded-lg bg-black"}),(0,r.jsx)(tq,{tipo:"video",rotulo:d?"Trocar o v\xeddeo":"Escolher o v\xeddeo (MP4) no computador ou arrastar at\xe9 aqui",onEnviado:e=>{s(t=>({...t,url:e.url})),l({})}}),n.url&&(0,r.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:n.url}),(0,r.jsx)(eW,{id:"vidarq-titulo",rotulo:"T\xedtulo do v\xeddeo",ajuda:"Aparece abaixo do v\xeddeo. (opcional)",erro:n.titulo,children:(0,r.jsx)(w.p,{id:"vidarq-titulo",value:i.titulo,onChange:e=>s(t=>({...t,titulo:e.target.value})),maxLength:200})}),(0,r.jsx)(eY,{editando:null!==e,aoCancelar:a,aoConfirmar:()=>{let a=function(e,t=null){let a=ti(e.url);if(!to(a))return ts("url","Envie o v\xeddeo ou informe um endere\xe7o que comece com https://.");if(e.titulo.length>200)return ts("titulo","O t\xedtulo pode ter no m\xe1ximo 200 caracteres.");let r=e.titulo.trim(),o=t?.drupalVideo?.description,i={type:"field_video",url:a,drupalVideo:{url:a,...r?{title:r}:{},...o?{description:o}:{}}};return r&&(i.title=r),{ok:!0,valor:i}}(i,e);if(!a.ok)return l(a.erros);t(a.valor)}})]})}function tP({inicial:e,aoSalvar:t,aoCancelar:a}){let{papel:i,urlsDoArtigo:s}=eC(),[n,l]=(0,o.useState)(()=>{let t={titulo:e?.gallery?.title??"",fotografo:e?.gallery?.photographer??"",imagens:(e?.gallery?.images??[]).map(e=>({url:e.url,alt:e.alt??"",legenda:e.caption??""}))};return{titulo:t.titulo,fotografo:t.fotografo,fotos:t.imagens.map((e,t)=>({id:t,...e}))}}),[d,c]=(0,o.useState)({}),u=(e,t)=>l(a=>({...a,fotos:a.fotos.map(a=>a.id===e?{...a,...t}:a)})),m=(e,t)=>l(a=>{let r=e+t;if(r<0||r>=a.fotos.length)return a;let o=[...a.fotos];return[o[e],o[r]]=[o[r],o[e]],{...a,fotos:o}});return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(tq,{tipo:"imagem",multiplo:!0,rotulo:"Escolher fotos no computador ou arrastar at\xe9 aqui (pode ser v\xe1rias)",onEnviado:e=>{l(t=>({...t,fotos:[...t.fotos,{id:Math.max(-1,...t.fotos.map(e=>e.id))+1,url:e.url,alt:"",legenda:""}]})),c(e=>({...e,imagens:""}))}}),d.imagens&&(0,r.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:d.imagens}),n.fotos.length>0&&(0,r.jsx)("ol",{className:"max-h-[38vh] space-y-3 overflow-y-auto pr-1","aria-label":"Fotos da galeria",children:n.fotos.map((e,t)=>(0,r.jsxs)("li",{className:"flex gap-3 rounded-lg border p-2",children:[to(e.url)?(0,r.jsx)("img",{src:e.url,alt:"",className:"h-20 w-20 shrink-0 rounded object-cover"}):(0,r.jsx)("div",{className:"h-20 w-20 shrink-0 rounded bg-muted"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1 space-y-1.5",children:[(0,r.jsx)(w.p,{"aria-label":`Descri\xe7\xe3o da foto ${t+1}`,placeholder:"Descri\xe7\xe3o (opcional)",value:e.alt,onChange:t=>u(e.id,{alt:t.target.value}),maxLength:300}
1),(0,r.jsx)(w.p,{"aria-label":`Legenda da foto ${t+1}`,placeholder:"Legenda (opcional)",value:e.legenda,onChange:t=>u(e.id,{legenda:t.target.value}),maxLength:500})]}),(0,r.jsxs)("div",{className:"flex shrink-0 flex-col gap-1",children:[(0,r.jsx)(j.$,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":`Subir a foto ${t+1}`,disabled:0===t,onClick:()=>m(t,-1),children:(0,r.jsx)(L.A,{className:"h-4 w-4"})}),(0,r.jsx)(j.$,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":`Descer a foto ${t+1}`,disabled:t===n.fotos.length-1,onClick:()=>m(t,1),children:(0,r.jsx)(_.A,{className:"h-4 w-4"})}),(0,r.jsx)(j.$,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive","aria-label":`Remover a foto ${t+1}`,onClick:()=>{let t;return t=e.id,l(e=>({...e,fotos:e.fotos.filter(e=>e.id!==t)}))},children:(0,r.jsx)(P.A,{className:"h-4 w-4"})})]})]},e.id))}),(0,r.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,r.jsx)(eW,{id:"gal-titulo",rotulo:"T\xedtulo da galeria",ajuda:"(opcional)",erro:d.titulo,children:(0,r.jsx)(w.p,{id:"gal-titulo",value:n.titulo,onChange:e=>l(t=>({...t,titulo:e.target.value})),maxLength:200})}),(0,r.jsx)(eW,{id:"gal-fotografo",rotulo:"Cr\xe9dito das fotos",ajuda:"Ex.: Fulano de Tal. (opcional)",erro:d.fotografo,children:(0,r.jsx)(w.p,{id:"gal-fotografo",value:n.fotografo,onChange:e=>l(t=>({...t,fotografo:e.target.value})),maxLength:120})})]}),(0,r.jsx)(eY,{editando:null!==e,aoCancelar:a,aoConfirmar:()=>{let e=function(e,t="editor",a){if(0===e.imagens.length)return ts("imagens","Adicione pelo menos uma foto.");if(e.imagens.length>60)return ts("imagens","Use no m\xe1ximo 60 fotos.");if(e.titulo.length>200)return ts("titulo","O t\xedtulo pode ter no m\xe1ximo 200 caracteres.");if(e.fotografo.length>120)return ts("fotografo","O nome do fot\xf3grafo pode ter no m\xe1ximo 120 caracteres.");let r=[];for(let[o,i]of e.imagens.entries()){let e=ti(i.url);if(!to(e))return ts("imagens",`A foto ${o+1} n\xe3o tem um endere\xe7o v\xe1lido.`);if(!tn(e,t,a))return ts("imagens",`A foto ${o+1}: ${tl}`);if(i.alt.length>300||i.legenda.length>500)return ts("imagens",`A descri\xe7\xe3o ou a legenda da foto ${o+1} est\xe1 longa demais.`);r.push({url:e,...i.alt.trim()?{alt:i.alt.trim()}:{},...i.legenda.trim()?{caption:i.legenda.trim()}:{}})}let o={images:r};return e.titulo.trim()&&(o.title=e.titulo.trim()),e.fotografo.trim()&&(o.photographer=e.fotografo.trim()),{ok:!0,valor:{type:"gallery_grid",gallery:o}}}({titulo:n.titulo,fotografo:n.fotografo,imagens:n.fotos.map(({url:e,alt:t,legenda:a})=>({url:e,alt:t,legenda:a}))},i,s);if(!e.ok)return c(e.erros);t(e.valor)}})]})}let tD={image:{nome:"Imagem",descricao:"Uma foto ou ilustra\xe7\xe3o com legenda."},video_embed:{nome:"V\xeddeo do YouTube ou Vimeo",descricao:"Cole o endere\xe7o do v\xeddeo e ele aparece tocando no artigo."},field_video:{nome:"V\xeddeo (arquivo MP4)",descricao:"Envie um v\xeddeo do seu computador."},gallery_grid:{nome:"Galeria de fotos",descricao:"V\xe1rias fotos em uma grade que abre em tela cheia."},quote:{nome:"Cita\xe7\xe3o em destaque",descricao:"Uma frase em destaque, com quem disse."},grafico:{nome:"Gr\xe1fico",descricao:"Barras, linha do tempo ou n\xfameros em destaque."},documento:{nome:"PDF em p\xe1ginas",descricao:"Um PDF (mat\xe9ria de edi\xe7\xe3o antiga, relat\xf3rio) para folhear dentro do artigo, com tela cheia e op\xe7\xe3o de baixar."}};function tM({pedido:e,aoSalvar:t,aoCancelar:a}){let o={inicial:e.inicial,aoSalvar:t,aoCancelar:a};switch(e.tipo){case"image":return(0,r.jsx)(tz,{...o});case"video_embed":return(0,r.jsx)(tL,{...o});case"field_video":return(0,r.jsx)(t_,{...o});case"gallery_grid":return(0,r.jsx)(tP,{...o});case"quote":return(0,r.jsx)(tv,{...o});case"grafico":return(0,r.jsx)(tN,{...o});case"documento":return(0,r.jsx)(tS,{...o})}}function tR({pedido:e,onFechar:t,onConfirmar:a}){let o=e?.tipo==="grafico";return(0,r.jsx)(y.lG,{open:null!==e,onOpenChange:e=>!e&&t(),children:(0,r.jsx)(y.Cf,{className:`max-h-[92vh] overflow-y-auto ${o?"sm:max-w-5xl":"sm:max-w-xl"}`,onInteractOutside:e=>e.preventDefault(),children:e&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(y.c7,{children:[(0,r.jsxs)(y.L3,{children:[null===e.pos?"Inserir":"Editar",": ",tD[e.tipo].nome]}),(0,r.jsx)(y.rr,{children:tD[e.tipo].descricao})]}),(0,r.jsx)(tM,{pedido:e,aoSalvar:t=>a(e,t),aoCancelar:t},`${e.tipo}:${e.pos??"novo"}`)]})})})}var tO=a(55398);function tF({inicial:e,aoSalvar:t,aoCancelar:a}){let{papel:i,urlsDoArtigo:s}=eC(),[n,l]=(0,o.useState)(e),[d,c]=(0,o.useState)(!1),[u,m]=(0,o.useState)({}),p=null!==to(n.url);return(0,r.jsxs)("div",{className:"space-y-4",children:[p&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"mb-1 text-sm font-semibold",children:"Clique no que mais importa na foto"}),(0,r.jsxs)("div",{className:"relative mx-auto w-fit max-w-full cursor-crosshair overflow-hidden rounded-lg border",onClick:e=>{let t=e.currentTarget.getBoundingClientRect();0!==t.width&&0!==t.height&&l(a=>({...a,focal:{x:Math.round((e.clientX-t.left)/t.width*1e3)/10,y:Math.round((e.clientY-t.top)/t.height*1e3)/10}}))},"data-testid":"seletor-focal",children:[(0,r.jsx)("img",{src:n.url,alt:"",className:"block max-h-64 max-w-full select-none",draggable:!1}),n.focal&&(0,r.jsx)("span",{className:"pointer-events-none absolute h-6 w-6 -translate-x-1/2 -translate-y-1/2 roun
1ded-full border-2 border-white bg-primary/40 shadow ring-2 ring-primary",style:{left:`${n.focal.x}%`,top:`${n.focal.y}%`},"aria-hidden":!0})]}),(0,r.jsxs)("div",{className:"mt-1 flex items-center justify-between text-xs text-muted-foreground",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1",children:[(0,r.jsx)(tO.A,{className:"h-3.5 w-3.5","aria-hidden":!0})," ",n.focal?`Ponto marcado (${Math.round(n.focal.x)}% \xd7 ${Math.round(n.focal.y)}%)`:"Nenhum ponto marcado: o corte fica no centro."]}),n.focal&&(0,r.jsx)("button",{type:"button",className:"underline",onClick:()=>l(e=>({...e,focal:null})),children:"Voltar ao centro"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"mb-1 text-sm font-semibold",children:"Como fica no topo do artigo"}),(0,r.jsx)("div",{className:"h-32 w-full overflow-hidden rounded-lg border sm:h-40",children:(0,r.jsx)("img",{src:n.url,alt:"",className:"h-full w-full object-cover",style:{objectPosition:n.focal?`${n.focal.x}% ${n.focal.y}%`:"center"}})})]})]}),(0,r.jsx)(tq,{tipo:"destaque",rotulo:p?"Trocar a imagem":"Escolher a imagem no computador ou arrastar at\xe9 aqui",onEnviado:e=>{l(t=>({...t,url:e.url,focal:null})),m(e=>({...e,url:""}))}}),u.url&&(0,r.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:u.url}),d?(0,r.jsx)(eW,{id:"dest-url",rotulo:"Endere\xe7o da imagem",ajuda:"S\xf3 use se a imagem j\xe1 estiver na internet em um endere\xe7o do site.",children:(0,r.jsx)(w.p,{id:"dest-url",value:n.url,onChange:e=>l(t=>({...t,url:e.target.value,focal:null})),placeholder:"https://…"})}):(0,r.jsx)("button",{type:"button",className:"text-sm text-muted-foreground underline",onClick:()=>c(!0),children:"J\xe1 tenho o endere\xe7o da imagem"}),(0,r.jsx)(eW,{id:"dest-legenda",rotulo:"Legenda e cr\xe9dito",ajuda:"Aparece abaixo da foto. Ex.: “Mina de ferro em Minas Gerais. Foto: Fulano”. (opcional)",erro:u.legenda,children:(0,r.jsx)(w.p,{id:"dest-legenda",value:n.legenda,onChange:e=>l(t=>({...t,legenda:e.target.value})),maxLength:500})}),(0,r.jsx)(eY,{editando:!0,aoCancelar:a,aoConfirmar:()=>{let e=function(e,t,a){let r=ti(e.url);if(!to(r))return ts("url","Envie uma imagem ou informe um endere\xe7o que comece com https://.");if(!tn(r,t,a))return ts("url",tl);if(e.legenda.length>500)return ts("legenda","A legenda pode ter no m\xe1ximo 500 caracteres.");let o=e.focal&&Number.isFinite(e.focal.x)&&Number.isFinite(e.focal.y)?{x:tp(e.focal.x),y:tp(e.focal.y)}:null;return{ok:!0,valor:{url:r,legenda:e.legenda.trim(),focal:o}}}(n,i,s);if(!e.ok)return m(e.erros);t(e.valor)}})]})}function tB({aberto:e,destaque:t,onFechar:a,onConfirmar:o}){return(0,r.jsx)(y.lG,{open:e,onOpenChange:e=>!e&&a(),children:(0,r.jsx)(y.Cf,{className:"max-h-[92vh] overflow-y-auto sm:max-w-xl",onInteractOutside:e=>e.preventDefault(),children:e&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(y.c7,{children:[(0,r.jsx)(y.L3,{children:"Imagem de destaque"}),(0,r.jsx)(y.rr,{children:"A foto grande no topo do artigo e na p\xe1gina inicial."})]}),(0,r.jsx)(tF,{inicial:t,aoSalvar:o,aoCancelar:a})]})})})}var tT=a(50538),tU=a(9199),tV=a(99412);let tI={manual:"Edi\xe7\xe3o",enrichment:"Assistente",restore:"Restaura\xe7\xe3o"};function tX(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString("pt-BR",{dateStyle:"short",timeStyle:"short"})}function tQ({aberto:e,onFechar:t,...a}){return(0,r.jsx)(tV.cj,{open:e,onOpenChange:e=>!e&&t(),children:(0,r.jsxs)(tV.h,{className:"w-full overflow-y-auto sm:max-w-md",children:[(0,r.jsxs)(tV.Fm,{children:[(0,r.jsxs)(tV.qp,{className:"flex items-center gap-2",children:[(0,r.jsx)(tT.A,{className:"h-5 w-5"})," Hist\xf3rico de vers\xf5es"]}),(0,r.jsx)(tV.Qs,{children:"Cada vez que algu\xe9m publica uma altera\xe7\xe3o, a vers\xe3o anterior fica guardada aqui. Voc\xea pode voltar a qualquer uma delas."})]}),e&&(0,r.jsx)(tH,{onFechar:t,...a})]})})}function tH({onFechar:e,f:t,articleId:a,temAlteracoesLocais:i,onRestaurado:s,onErro:n}){let[d,c]=(0,o.useState)({tipo:"carregando"}),[u,m]=(0,o.useState)(0),[p,g]=(0,o.useState)(null),[f,h]=(0,o.useState)(!1);(0,o.useEffect)(()=>{let e=!0;return eX(t,a).then(t=>e&&c({tipo:"lista",lista:t}),t=>e&&c({tipo:"erro",mensagem:t.mensagem??"N\xe3o foi poss\xedvel carregar o hist\xf3rico."})),()=>{e=!1}},[t,a,u]);let x=async()=>
1{if(!p)return;h(!0);let r=await eQ(t,a,p.id);h(!1),g(null),r.ok?(s(r.avisos),e()):n(r.erro)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"mt-6 space-y-3",children:["carregando"===d.tipo&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,r.jsx)(l.A,{className:"h-4 w-4 animate-spin"})," Carregando…"]}),"erro"===d.tipo&&(0,r.jsxs)("div",{className:"text-sm text-destructive",children:[d.mensagem," ",(0,r.jsx)("button",{type:"button",className:"underline",onClick:()=>{c({tipo:"carregando"}),m(e=>e+1)},children:"Tentar de novo"})]}),"lista"===d.tipo&&0===d.lista.length&&(0,r.jsx)("div",{className:"text-sm text-muted-foreground",children:"Ainda n\xe3o h\xe1 vers\xf5es guardadas. A primeira aparece quando algu\xe9m publicar uma altera\xe7\xe3o."}),"lista"===d.tipo&&d.lista.map(e=>{let t;return(0,r.jsx)("div",{className:"rounded-lg border p-3 text-sm",children:(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("div",{className:"font-medium",children:tX(e.at)}),(0,r.jsxs)("div",{className:"text-muted-foreground",children:[tI[e.source]," por ",e.by.email??e.by.uid]}),(0,r.jsxs)("div",{className:"mt-1",children:["Mudou: ",(t=[...new Set(e.camposAlterados.map(e=>eH[e]??e))]).length?t.join(", "):"sem detalhes"]}),e.nota&&(0,r.jsxs)("div",{className:"mt-1 italic text-muted-foreground",children:["“",e.nota,"”"]})]}),(0,r.jsxs)(j.$,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:()=>g(e),children:[(0,r.jsx)(tU.A,{className:"h-3.5 w-3.5"})," Restaurar"]})]})},e.id)})]}),(0,r.jsx)(b.Lt,{open:!!p,onOpenChange:e=>!e&&!f&&g(null),children:(0,r.jsxs)(b.EO,{children:[(0,r.jsxs)(b.wd,{children:[(0,r.jsxs)(b.r7,{children:["Voltar para a vers\xe3o anterior a ",p?tX(p.at):"","?"]}),(0,r.jsxs)(b.$v,{children:["O artigo volta a ficar como estava antes daquela edi\xe7\xe3o e a mudan\xe7a vai para o site agora. O que est\xe1 no ar hoje tamb\xe9m fica guardado no hist\xf3rico, ent\xe3o d\xe1 para desfazer.",i&&(0,r.jsx)("strong",{className:"mt-2 block text-foreground",children:"Aten\xe7\xe3o: as altera\xe7\xf5es que voc\xea fez e ainda n\xe3o publicou nesta tela ser\xe3o descartadas."})]})]}),(0,r.jsxs)(b.ck,{children:[(0,r.jsx)(b.Zr,{disabled:f,children:"Cancelar"}),(0,r.jsx)(b.Rx,{disabled:f,onClick:e=>{e.preventDefault(),x()},children:f?"Restaurando…":"Restaurar"})]})]})})]})}var tG=a(37618),tJ=a(7915),tW=a(33210);let tY="bm-editor-boas-vindas-v1";function tZ(){let[e,t]=(0,o.useState)(()=>!function(){try{return"1"===window.localStorage.getItem(tY)}catch{return!1}}());if(!e)return null;let a=()=>{try{window.localStorage.setItem(tY,"1")}catch{}t(!1)},i=[{icone:tG.A,titulo:"Escreva direto no texto",texto:"A tela \xe9 igual ao artigo publicado. Clique onde quer mudar e digite."},{icone:F.A,titulo:"Use “Inserir” ou o “+” do fim",texto:"Imagem, v\xeddeo, galeria, cita\xe7\xe3o em destaque e gr\xe1fico entram onde voc\xea pediu."},{icone:tJ.A,titulo:"Confira na Pr\xe9via",texto:"Veja como fica no celular, no tablet e no computador antes de publicar."},{icone:tT.A,titulo:"Publique sem medo",texto:"A vers\xe3o anterior fica guardada no Hist\xf3rico e d\xe1 para voltar a ela."}];return(0,r.jsx)("div",{className:"mx-auto mt-4 max-w-3xl px-4","data-testid":"boas-vindas",children:(0,r.jsxs)("div",{className:"relative rounded-lg border bg-muted/30 p-4",children:[(0,r.jsx)("button",{type:"button",className:"absolute right-2 top-2 rounded p-1 text-muted-foreground hover:bg-muted","aria-label":"Fechar as dicas",onClick:a,children:(0,r.jsx)(tW.A,{className:"h-4 w-4"})}),(0,r.jsx)("div",{className:"mb-3 font-semibold",children:"Como editar aqui, em 4 passos"}),(0,r.jsx)("ol",{className:"grid gap-3 sm:grid-cols-2",children:i.map(({icone:e,titulo:t,texto:a},o)=>(0,r.jsxs)("li",{className:"flex gap-3",children:[(0,r.jsx)("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary",children:(0,r.jsx)(e,{className:"h-4 w-4","aria-hidden":!0})}),(0,r.jsxs)("span",{className:"text-sm",children:[(0,r.jsxs)("span",{className:"block font-semibold",children:[o+1,". ",t]}),(0,r.jsx)("span",{className:"text-muted-foreground",children:a})]})]},t))}),(0,r.jsx)("div",{className:"mt-3 flex justify-end",children:(0,r.jsx)(j.$,{type:"button",size:"sm",onClick:a,children:"Entendi"})})]})})}var tK=a(45005),t0=a(97364);let t1=[{tipo:"image",rotulo:"Imagem",icone:m.A},{tipo:"video_embed",rotulo:"V\xeddeo do YouTube ou Vimeo",icone:M.A},{tipo:"gallery_grid",rotulo:"Galeria de fotos",icone:R.A},{tipo:"quote",rotulo:"Cita\xe7\xe3o em destaque",icone:O.A},{tipo:"grafico",rotulo:"Gr\xe1fico",icone:F.A},{tipo:"documento",rotulo:"PDF em p\xe1ginas",icone:B.A},{tipo:"field_video",rotulo:"V\xeddeo (arquivo MP4)",icone:tK.A}];function t2({onParagrafo:e,onBloco:t}){return(0,r.jsx)("section",{"aria-label":"Adicionar ao fim do artigo",className:"mx-auto mt-2 max-w-3xl px-4","data-testid":"barra-inserir",children:(0,r.jsxs)("div",{className:"rounded-lg border border-dashed bg-muted/20 p-3",children:[(0,r.jsx)("div",{className:"mb-2 text-sm font-semibold text-muted-foreground",children:"Adicionar ao fim do artigo"}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsxs)(j.$,{type:"button",variant:"outline",size:"sm",className:"h-9 gap-1.5",onClick:e,children:[(0,r.jsx)(tb.A,{className:"h-4 w-4","aria-hidden":!0}),(0,r.jsx)(t0.A,{className:"h-4 w-4","aria-hidden":!0})," Par\xe1grafo"]}),t1.map(({tipo:e,rotulo:a,icone:o})=>(0,r.jsxs)(j.$,{type:"button",variant:"outline",size:"sm",className:"h-9 gap-1.5",onClick:()=>t(e),children:[(0,r.jsx)(tb.A,{className:"h-4 w-4","aria-hidden":!0}),(0,r.jsx)(o,{className:"h-4 w-4"})," ",a]},e))]})]})})}var t4=a(25237),t5=a(96618),t3=a(44254),t9=a(22353);let t6=[{id:"celular",rotulo:"Celular",px:390,icone:t4.A},{id:"tablet",rotulo:"Tablet",px:768,icone:t5.A},{id:"computador",rotulo:"Computador",px:1280,icone:t3.A}];function t8({montarArtigo:e}
1){let[t,a]=(0,o.useState)(390),[i,s]=(0,o.useState)(()=>({w:Math.round(.96*window.innerWidth),h:Math.round(.94*window.innerHeight-150)})),n=(0,o.useRef)(null),l=(0,o.useRef)(null),[d]=(0,o.useState)(e);(0,o.useEffect)(()=>{let e=e=>{let t=(0,t9.X)(e,window.location.origin,l.current?.contentWindow);t?.tipo==="pronta"&&l.current?.contentWindow?.postMessage({canal:t9.e,tipo:"artigo",artigo:d},window.location.origin)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[d]),(0,o.useEffect)(()=>{let e=n.current;if(!e)return;let t=new ResizeObserver(()=>s({w:e.clientWidth,h:e.clientHeight}));return t.observe(e),()=>t.disconnect()},[]);let c=i.w>0?Math.min(1,(i.w-24)/t):1,u=i.h>0?Math.max(300,(i.h-24)/c):600;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b px-4 py-2",role:"group","aria-label":"Largura da pr\xe9via",children:[t6.map(({id:e,rotulo:o,px:i,icone:s})=>(0,r.jsxs)(j.$,{type:"button",size:"sm",variant:t===i?"secondary":"ghost",className:"gap-1.5","aria-pressed":t===i,onClick:()=>a(i),children:[(0,r.jsx)(s,{className:"h-4 w-4","aria-hidden":!0})," ",o," ",(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:[i,"px"]})]},e)),c<1&&(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Reduzida a ",Math.round(100*c),"% para caber na janela; o layout \xe9 o de ",t,"px."]})]}),(0,r.jsx)("div",{ref:n,className:"min-h-0 flex-1 overflow-auto bg-muted/60 p-3",children:(0,r.jsx)("div",{className:"mx-auto",style:{width:t*c,height:u*c},children:(0,r.jsx)("iframe",{ref:l,src:"/editor-previa",title:"Pr\xe9via do artigo",className:"block border-0 bg-background shadow-md",style:{width:t,height:u,transform:`scale(${c})`,transformOrigin:"top left"}})})})]})}function t7({aberta:e,onFechar:t,montarArtigo:a}){return(0,r.jsx)(y.lG,{open:e,onOpenChange:e=>!e&&t(),children:(0,r.jsxs)(y.Cf,{className:"flex h-[94vh] max-w-[96vw] flex-col gap-0 overflow-hidden p-0 sm:max-w-[96vw]",children:[(0,r.jsxs)(y.c7,{className:"px-4 py-3",children:[(0,r.jsx)(y.L3,{children:"Pr\xe9via do artigo"}),(0,r.jsx)(y.rr,{children:"Como o leitor vai ver, com o que est\xe1 na tela agora (mesmo sem publicar). An\xfancios e “Veja tamb\xe9m” aparecem s\xf3 na p\xe1gina publicada."})]}),e&&(0,r.jsx)(t8,{montarArtigo:a})]})})}var ae=a(1751),at=a(92669),aa=a(23770),ar=a(97233),ao=a(38194),ai=a(77314),as=a(66088),an=a(55711),al=a(44529),ad=a(55243),ac=a(72264),au=a(97916);function am({ativo:e,desabilitado:t,onClick:a,icone:o,rotulo:i,titulo:s}){return(0,r.jsxs)(j.$,{type:"button",variant:e?"secondary":"ghost",size:"sm",className:"h-9 gap-1.5 px-2.5",disabled:t,onClick:a,"aria-pressed":e,title:s??i,onMouseDown:e=>e.preventDefault(),children:[o,(0,r.jsx)("span",{className:"hidden sm:inline",children:i})]})}function ap({editor:e,onLink:t,onInserir:a,onSalvar:o,onHistorico:i,onPrevia:s,salvando:d,alterado:c,status:u}){let m=(0,n.erU)({editor:e,selector:({editor:e})=>({negrito:e.isActive("bold"),italico:e.isActive("italic"),titulo:e.isActive("heading",{level:2}),paragrafo:e.isActive("paragraph"),lista:e.isActive("bulletList"),listaNum:e.isActive("orderedList"),citacao:e.isActive("blockquote"),link:e.isActive("link"),podeDesfazer:e.can().undo(),podeRefazer:e.can().redo()})}),p=()=>e.chain().focus();return(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1",role:"toolbar","aria-label":"Formata\xe7\xe3o do texto",children:[(0,r.jsx)(am,{icone:(0,r.jsx)(t0.A,{className:"h-4 w-4"}),rotulo:"Par\xe1grafo",ativo:m.paragrafo,onClick:()=>p().setParagraph().run()}),(0,r.jsx)(am,{icone:(0,r.jsx)(ae.A,{className:"h-4 w-4"}),rotulo:"T\xedtulo",titulo:"T\xedtulo de se\xe7\xe3o",ativo:m.titulo,onClick:()=>p().toggleHeading({level:2}).run()}),(0,r.jsx)(au.w,{orientation:"vertical",className:"mx-1 h-6"}),(0,r.jsx)(am,{icone:(0,r.jsx)(at.A,{className:"h-4 w-4"}),rotulo:"Negrito",ativo:m.negrito,onClick:()=>p().toggleBold().run()}),(0,r.jsx)(am,{icone:(0,r.jsx)(aa.A,{className:"h-4 w-4"}),rotulo:"It\xe1lico",ativo:m.italico,onClick:()=>p().toggleItalic().run()}),(0,r.jsx)(am,{icone:(0,r.jsx)(ar.A,{className:"h-4 w-4"}),rotulo:"Link",ativo:m.link,onClick:t}),(0,r.jsx)(au.w,{orientation:"vertical",className:"mx-1 h-6"}),(0,r.jsx)(am,{icone:(0,r.jsx)(ao.A,{className:"h-4 w-4"}),rotulo:"Lista",titulo:"Lista com marcadores",ativo:m.lista,onClick:()=>p().toggleBulletList().run()}),(0,r.jsx)(am,{icone:(0,r.jsx)(ai.A,{className:"h-4 w-4"}),rotulo:"Numerada",titulo:"Lista numerada",ativo:m.listaNum,onClick:()=>p().toggleOrderedList().run()}),(0,r.jsx)(am,{icone:(0,r.jsx)(O.A,{className:"h-4 w-4"}),rotulo:"Cita\xe7\xe3o",ativo:m.citacao,onClick:()=>p().toggleBlockquote().run()}),(0,r.jsx)(au.w,{orientation:"vertical",className:"mx-1 h-6"}),(0,r.jsxs)(ac.rI,{children:[(0,r.jsx)(ac.ty,{asChild:!0,children:(0,r.jsxs)(j.$,{type:"button",variant:"outline",size:"sm",className:"h-9 gap-1.5 px-2.5",title:"Inserir imagem, v\xeddeo, galeria, cita\xe7\xe3o em destaque ou gr\xe1fico depois do par\xe1grafo onde est\xe1 o cursor",children:[(0,r.jsx)(tb.A,{className:"h-4 w-4"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Inserir"}),(0,r.jsx)(as.A,{className:"h-3.5 w-3.5"})]})}),(0,r.jsxs)(ac.SQ,{align:"start",className:"w-64",children:[(0,r.jsx)(ac.lp,{className:"text-xs font-normal text-muted-foreground",children:"Vai entrar logo depois do par\xe1grafo onde est\xe1 o cursor"}),t1.map(({tipo:e,rotulo:t,icone:o})=>(0,r.jsxs)(ac._2,{className:"gap-2 py-2",onSelect:()=>a(e),children:[(0,r.jsx)(o,{className:"h-4 w-4"})," ",t]},e))]})]}),(0,r.jsx)(au.w,{orientation:"vertical",className:"mx-1 h-6"}),(0,r.jsx)(am,{icone:(0,r.jsx)(an.A,{className:"h-4 w-4"}
1),rotulo:"Desfazer",desabilitado:!m.podeDesfazer,onClick:()=>p().undo().run()}),(0,r.jsx)(am,{icone:(0,r.jsx)(al.A,{className:"h-4 w-4"}),rotulo:"Refazer",desabilitado:!m.podeRefazer,onClick:()=>p().redo().run()}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground","aria-live":"polite",children:u}),(0,r.jsxs)(j.$,{type:"button",variant:"outline",size:"sm",className:"h-9 gap-1.5",onClick:s,title:"Ver como o leitor vai ver, no celular, tablet e computador",children:[(0,r.jsx)(tJ.A,{className:"h-4 w-4"}),(0,r.jsx)("span",{className:"hidden md:inline",children:"Pr\xe9via"})]}),(0,r.jsxs)(j.$,{type:"button",variant:"outline",size:"sm",className:"h-9 gap-1.5",onClick:i,children:[(0,r.jsx)(tT.A,{className:"h-4 w-4"}),(0,r.jsx)("span",{className:"hidden md:inline",children:"Hist\xf3rico"})]}),(0,r.jsxs)(j.$,{type:"button",size:"sm",className:"h-9 gap-1.5",onClick:o,disabled:!c||d,children:[d?(0,r.jsx)(l.A,{className:"h-4 w-4 animate-spin"}):(0,r.jsx)(ad.A,{className:"h-4 w-4"}),"Publicar altera\xe7\xf5es"]})]})]})}let ag=e=>`bm-editor-rascunho:${e}`;function af(e){try{window.localStorage.removeItem(ag(e))}catch{}}function ah(e){let t=e=>{if(void 0===e||"function"==typeof e)return;if(null===e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(e=>t(e)??null);let a={};for(let r of Object.keys(e).sort()){let o=t(e[r]);void 0!==o&&(a[r]=o)}return a};return JSON.stringify(t(e)??null)}let ax=(e,t)=>ah(e)===ah(t),av=e=>({title:e.campos.title,teaser:e.campos.field_teaser_text,categoria:e.campos.field_channel,tags:e.campos.field_tags,destaque:{url:e.campos.field_teaser_media,legenda:e.campos.imageUrlCaption??"",focal:e.campos.focalPoint??null}});function ab({articleId:e}){let t=(0,p.F)(),[a,i]=(0,o.useState)({tipo:"carregando"}),n=(0,o.useRef)(0),c=(0,o.useCallback)(async()=>{i({tipo:"carregando"});try{let[a,r]=await Promise.all([eU(t,e),eV(t)]);
1n.current+=1,i({tipo:"pronto",payload:a,taxonomia:r,versao:n.current})}catch(e){i({tipo:"erro",mensagem:e.mensagem??e.message??"N\xe3o foi poss\xedvel abrir o artigo.",status:e.status})}},[t,e]);return((0,o.useEffect)(()=>{c()},[e]),"carregando"===a.tipo)?(0,r.jsxs)("div",{className:"flex min-h-[50vh] items-center justify-center gap-2 text-muted-foreground",children:[(0,r.jsx)(l.A,{className:"h-5 w-5 animate-spin"})," Abrindo o artigo…"]}):"erro"===a.tipo?(0,r.jsxs)("div",{className:"mx-auto flex min-h-[50vh] max-w-md flex-col items-center justify-center gap-3 text-center",children:[(0,r.jsx)(d.A,{className:"h-10 w-10 text-destructive"}),(0,r.jsx)("div",{className:"font-semibold",children:"N\xe3o foi poss\xedvel abrir o artigo"}),(0,r.jsx)("div",{className:"text-sm text-muted-foreground",children:a.mensagem}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(j.$,{variant:"outline",onClick:()=>void c(),children:"Tentar de novo"}),(0,r.jsx)(j.$,{variant:"ghost",asChild:!0,children:(0,r.jsx)(s(),{href:"/dashboard",children:"Voltar ao painel"})})]})]}):(0,r.jsx)(aj,{articleId:e,payload:a.payload,taxonomia:a.taxonomia,f:t,onRecarregar:c},a.versao)}function aj({articleId:e,payload:t,taxonomia:a,f:i,onRecarregar:d,aoCriarEditor:p,modoDeTeste:N,enviarArquivo:y}){let{toast:w}=(0,g.dj)(),$="admin"===t.papel,[A,S]=(0,o.useState)(()=>av(t)),E=(0,o.useRef)(av(t)),z=(0,o.useRef)(t.baseHash),L=(0,o.useRef)(t.campos.field_paragraphs),[_,P]=(0,o.useState)(0),[D,M]=(0,o.useState)(!1),[R,O]=(0,o.useState)(0),[F,B]=(0,o.useState)(!1),[T,U]=(0,o.useState)(!1),[V,I]=(0,o.useState)(!1),[X,Q]=(0,o.useState)(!1),[H,G]=(0,o.useState)(null),[J,W]=(0,o.useState)(null),[Y,Z]=(0,o.useState)(null),[K,ee]=(0,o.useState)(null),[et,ea]=(0,o.useState)(null),[er,eo]=(0,o.useState)(!1),[ei,es]=(0,o.useState)(!1),en=(0,o.useMemo)(()=>{let e=eO(t.campos.field_paragraphs);return eR((0,el._w)(ev()),e,document)},[t]),ed=(0,o.useMemo)(()=>ev({htmlBruto:ez,bloco:eL}),[]),ec=(0,n.hGv)({extensions:ed,content:en.json,immediatelyRender:!1,editorProps:{attributes:{"aria-label":"Texto do artigo",spellcheck:"true"},transformPastedHTML:ex}});(0,o.useEffect)(()=>{ec&&p&&p(ec)},[ec,p]);let eu=(0,o.useMemo)(()=>(function(e,t){let a=new Set;for(let r of(t&&a.add(t),e))for(let e of("image"===r.type&&r.url&&a.add(r.url),r.gallery?.images??[]))e.url&&a.add(e.url);return a})(t.campos.field_paragraphs,t.campos.field_teaser_media),[t]),em=(0,o.useCallback)((e,t)=>ea({tipo:e,pos:null,inicial:null,onde:t}),[]),ep=(0,o.useCallback)(e=>{let t;if(!ec)return;let a=eN(ec,e)?.attrs.dados;a&&(t=a.type,ej.includes(t))&&ea({tipo:a.type,pos:e,inicial:a,onde:"cursor"})},[ec]),eg=(0,o.useMemo)(()=>({papel:t.papel,urlsDoArtigo:eu,enviar:y??q,editarBloco:ep}),[t.papel,eu,y,ep]),ef=(0,o.useCallback)(()=>{var e,t,a,r,o;let i,s,n,l,d;return ec?(e=ec.schema,t=ec.state.doc,a=document,i=[],t.forEach(t=>{let r=t.attrs;if("bloco"===t.type.name)return void i.push({tipo:"bloco",item:r._item,dad
1os:t.attrs.dados,oculto:!!t.attrs.oculto});let o=null!==r._fonte&&void 0!==r._fonte&&null!==r._norm0&&void 0!==r._norm0?{fonte:r._fonte,apos:r._apos??"",pre:r._pre??"",norm0:r._norm0}:void 0;i.push({tipo:"texto",item:r._item,html:eP(e,t,a),origem:o})}),r=i,o=L.current,s=function(e){let t=Array(e.length).fill(NaN),a=-1;for(let r=0;r<e.length;r++){let o=e[r];if("texto"!==o.tipo)continue;if(null!==o.item&&void 0!==o.item){t[r]=o.item;continue}let i=r>0&&"texto"===e[r-1].tipo?t[r-1]:NaN;if(!Number.isNaN(i)){t[r]=i;continue}let s=NaN;for(let t=r+1;t<e.length&&"texto"===e[t].tipo;t++){let a=e[t].item;if(null!=a){s=a;break}}Number.isNaN(s)?t[r]=a--:t[r]=s}return t}(r),n=[],l=null,d=()=>{if(!l)return;let e=function(e,t){let a=e.nos.filter(e=>!("<p></p>"===e.html&&!eF(e)));if(0===a.length)return null;let r=e.item>=0?t[e.item]:void 0,o=a.every(eF),i=function(e){if(0===e.length)return"";let t=new Map;for(let a of e)t.set(a,(t.get(a)??0)+1);return[...t.entries()].sort((e,t)=>t[1]-e[1])[0][0]}(a.filter(e=>e.origem).map(e=>e.origem.apos)),s=a[0].origem?a[0].origem.pre:"";return(a.forEach((e,t)=>{s+=eF(e)?e.origem.fonte:e.html??"";let r=a[t+1];r?e.origem&&""!==e.origem.apos||e.origem&&r.origem?s+=e.origem.apos:s+=i:s+=e.origem?e.origem.apos:""}),r&&"text"===r.type&&o&&r.content===s)?r:r&&"text"===r.type?{...r,content:s}:{type:"text",content:s}}(l,o);e&&n.push(e),l=null},r.forEach((e,t)=>{if("bloco"===e.tipo){d(),e.dados&&n.push(e.dados);return}let a=s[t];l&&l.item===a||(d(),l={item:a,nos:[]}),l.nos.push(e)}),d(),n):L.current},[ec]);(0,o.useEffect)(()=>{let e;if(!ec)return;let t=()=>{clearTimeout(e),e=setTimeout(()=>{M(!ax(ef(),L.current)),O(e=>e+1)},250)};return ec.on("update",t),()=>{clearTimeout(e),ec.off("update",t)}},[ec,ef]);let eh=!ax(A,E.current),ey=D||eh;(0,o.useEffect)(()=>{let t=function(e){try{let t=window.localStorage.getItem(ag(e));if(!t)return null;let a=JSON.parse(t);return a&&1===a.v&&"string"==typeof a.baseHash&&a.docJson?a:null}catch{return null}}(e);t&&Z(t)},[]),(0,o.useEffect)(()=>{if(!ec||!ey)return;let t=setTimeout(()=>{!function(e,t){try{window.localStorage.setItem(ag(e),JSON.stringify(t))}catch{return!1}}(e,{v:1,baseHash:z.current,em:new Date().toISOString(),campos:A,docJson:ec.getJSON()})},1500);return()=>clearTimeout(t)},[ec,ey,A,R,e]),(0,o.useEffect)(()=>{if(!ey)return;let e=e=>{e.preventDefault(),e.returnValue=""};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[ey]);let ew=async()=>{var t,a;let r,o,s;if(!ec||F)return;if(""===A.title.trim())return void w({variant:"destructive",title:"O t\xedtulo n\xe3o pode ficar vazio"});let n={},l=E.current;A.title.trim()!==l.title.trim()&&(n.title=A.title),A.teaser!==l.teaser&&(n.field_teaser_text=A.teaser),A.categoria!==l.categoria&&(n.field_channel=A.categoria),ax(A.tags,l.tags)||(n.field_tags=A.tags),Object.assign(n,(t=l.destaque,a=A.destaque,r={},a.url!==t.url&&(r.field_teaser_media=a.url),a.legenda.trim()!==t.legenda.trim()&&(r.imageUrlCaption=""===a.legenda.trim()?null:a.legenda.trim()),o=t.focal,s=a.focal,((o?.x??null)!==(s?.x??null)||(o?.y??null)!==(s?.y??null))&&(r.focalPoint=s?{x:s.x,y:s.y}:null),r));let d=ef();if(ax(d,L.current)||(n.field_paragraphs=d),0===Object.keys(n).length)return void w({title:"Nada para publicar",description:"Voc\xea n\xe3o fez nenhuma altera\xe7\xe3o."});B(!0);let c=await eI(i,e,{baseHash:z.current,patch:n});if(B(!1),U(!1),!c.ok){let e=c.erro;if(409===e.status)G(e);else if("BLOCOS_INVALIDOS"===e.codigo||"CAMPO_INVALIDO"===e.codigo){let t=Array.isArray(e.erros)?e.erros.map(e=>e.mensagem??"").filter(Boolean):[];W(t.length?t:[e.mensagem])}else w({variant:"destructive",title:"N\xe3o foi poss\xedvel publicar",description:e.mensagem||eT(e.status)});return}if(z.current=c.dados.hash,E.current={...A},n.field_paragraphs){L.current=d;let e=ec.state.selection.from,t=eR(ec.schema,eO(d),document);ec.commands.setContent(t.json,{emitUpdate:!1}),ec.commands.setTextSelection(Math.min(e,ec.state.doc.content.size))}M(!1),ee(new Date),U(!1),af(e),w({title:c.dados.semMudancas?"Nada mudou":"Altera\xe7\xf5es publicadas",description:c.dados.semMudancas?"O artigo j\xe1 estava assim.":"J\xe1 est\xe3o no ar. A vers\xe3o anterior ficou no hist\xf3rico."})},eC=a?.categorias??[],e$=e=>eC.find(t=>v(t.nome)===v(e))?.nome,eA=""===A.categoria||void 0!==e$(A.categoria),eS=(0,o.useMemo)(()=>
1{if(!ec)return 0;let e=ec.state.doc.textContent.trim();return e?e.split(/\s+/).length:0},[ec,R]);if(!ec)return(0,r.jsxs)("div",{className:"flex min-h-[50vh] items-center justify-center gap-2 text-muted-foreground",children:[(0,r.jsx)(l.A,{className:"h-5 w-5 animate-spin"})," Preparando o editor…"]});let eE=F?"Publicando…":ey?"Altera\xe7\xf5es ainda n\xe3o publicadas":K?`Publicado \xe0s ${K.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}`:"Sem altera\xe7\xf5es";return(0,r.jsx)(ek,{valor:eg,children:(0,r.jsxs)("div",{className:"editor-artigo",children:[(0,r.jsx)("div",{className:"sticky top-0 z-30 border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",children:(0,r.jsxs)("div",{className:"mx-auto max-w-5xl px-4 py-2",children:[(0,r.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-2 text-xs text-muted-foreground",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(j.$,{variant:"ghost",size:"sm",className:"h-7 gap-1 px-2",asChild:!0,children:(0,r.jsxs)(s(),{href:"/dashboard",children:[(0,r.jsx)(c.A,{className:"h-3.5 w-3.5"})," Painel"]})}),(0,r.jsxs)("span",{children:[eS.toLocaleString("pt-BR")," palavras"]}),(0,r.jsxs)("span",{className:A.title.length>90?"font-semibold text-amber-600":"",children:["T\xedtulo: ",A.title.length," caracteres"]})]}),(0,r.jsx)("span",{children:t.somenteLeitura.updatedAt?`\xdaltima edi\xe7\xe3o: ${new Date(t.somenteLeitura.updatedAt).toLocaleString("pt-BR",{dateStyle:"short",timeStyle:"short"})}`:""})]}),(0,r.jsx)(ap,{editor:ec,onLink:()=>I(!0),onInserir:e=>em(e,"cursor"),onSalvar:()=>U(!0),onHistorico:()=>Q(!0),onPrevia:()=>es(!0),salvando:F,alterado:ey,status:eE})]})}),N&&(0,r.jsx)("div",{className:"bg-amber-500 px-4 py-1 text-center text-xs font-semibold text-black",children:"MODO DE TESTE (desenvolvimento): o artigo \xe9 lido do banco, mas nada \xe9 gravado. “Publicar” s\xf3 roda a valida\xe7\xe3o do servidor."}),(0,r.jsx)(tZ,{}),Y&&(0,r.jsx)("div",{className:"mx-auto mt-4 max-w-3xl px-4",children:(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-3 rounded-lg border border-amber-500/60 bg-amber-50 px-4 py-3 text-sm dark:bg-amber-950/20",children:[(0,r.jsx)(u.A,{className:"h-4 w-4 shrink-0 text-amber-600"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:["Encontramos altera\xe7\xf5es n\xe3o publicadas de ",new Date(Y.em).toLocaleString("pt-BR",{dateStyle:"short",timeStyle:"short"}),".",Y.baseHash!==t.baseHash&&(0,r.jsx)("strong",{children:" O artigo mudou desde ent\xe3o: confira o texto antes de publicar."})]}),(0,r.jsx)(j.$,{size:"sm",onClick:()=>{ec&&Y&&(S({...av(t),...Y.campos}),P(e=>e+1),ec.commands.setContent(Y.docJson,{emitUpdate:!0}),Z(null),w({title:"Rascunho recuperado",description:"Suas altera\xe7\xf5es n\xe3o publicadas voltaram para a tela."}))},children:"Recuperar"}),(0,r.jsx)(j.$,{size:"sm",variant:"ghost",onClick:()=>{af(e),Z(null)},children:"Descartar"})]})}),(0,r.jsxs)("article",{children:[(0,r.jsx)("header",{className:"container mx-auto px-4 py-12 md:py-16 text-center",children:(0,r.jsxs)("div",{className:f,children:[(0,r.jsx)("div",{className:"mb-4",children:$?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("input",{list:"editor-categorias",className:`${h} w-full max-w-md border-b border-dashed border-primary/40 bg-transparent text-center outline-none`,value:A.categoria,onChange:e=>S(t=>({...t,categoria:e.target.value})),"aria-label":"Categoria"}),(0,r.jsx)("datalist",{id:"editor-categorias",children:eC.map(e=>(0,r.jsx)("option",{value:e.nome},e.nome))})]}):(0,r.jsxs)("select",{className:`${h} cursor-pointer border-b border-dashed border-primary/40 bg-transparent text-center outline-none`,style:{lineHeight:"24px"},value:eA?e$(A.categoria)??"":A.categoria,onChange:e=>S(t=>({...t,categoria:e.target.value})),"aria-label":"Categoria",children:[!eA&&(0,r.jsxs)("option",{value:A.categoria,children:[A.categoria," (atual)"]}),eC.map(e=>(0,r.jsx)("option",{value:e.nome,children:e.nome},e.nome))]})}),(0,r.jsx)(eG,{tag:"h1",className:"text-4xl md:text-5xl font-bold leading-tight mb-4",style:{textWrap:"balance"}
1,valor:A.title,chave:_,onChange:e=>S(t=>({...t,title:e})),placeholder:"Escreva o t\xedtulo da mat\xe9ria",rotulo:"T\xedtulo da mat\xe9ria",maxLength:200}),(0,r.jsxs)("div",{className:"flex items-center justify-center space-x-4 text-muted-foreground text-sm",children:[t.somenteLeitura.author_name&&(0,r.jsxs)("span",{className:"font-semibold",children:["Por ",t.somenteLeitura.author_name]}),t.somenteLeitura.author_name&&t.somenteLeitura.created&&(0,r.jsx)("span",{children:"•"}),t.somenteLeitura.created&&(0,r.jsx)("span",{children:new Date(t.somenteLeitura.created).toLocaleDateString("pt-BR",{day:"numeric",month:"long",year:"numeric"})})]})]})}),(0,r.jsx)("div",{className:x,children:(0,r.jsxs)("figure",{className:"mx-auto mb-8 max-w-5xl",children:[A.destaque.url?(0,r.jsx)("div",{className:"relative h-64 w-full overflow-hidden rounded-xl shadow-lg md:h-96",children:(0,r.jsx)("img",{src:A.destaque.url,alt:"",className:"h-full w-full object-cover",style:{objectPosition:A.destaque.focal?`${A.destaque.focal.x}% ${A.destaque.focal.y}%`:"center"}})}):(0,r.jsx)("div",{className:"flex h-40 w-full items-center justify-center rounded-xl border-2 border-dashed text-sm text-muted-foreground",children:"Este artigo ainda n\xe3o tem imagem de destaque."}),A.destaque.legenda&&(0,r.jsx)("figcaption",{className:"mx-auto mt-3 max-w-4xl border-l-4 border-primary/70 pl-4 text-left text-xs text-muted-foreground",children:A.destaque.legenda}),(0,r.jsx)("div",{className:"mx-auto mt-2 max-w-4xl",children:(0,r.jsxs)(j.$,{type:"button",variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>eo(!0),children:[(0,r.jsx)(m.A,{className:"h-4 w-4","aria-hidden":!0})," ",A.destaque.url?"Trocar imagem, legenda ou enquadramento":"Adicionar imagem de destaque"]})})]})}),(0,r.jsx)("div",{className:x,children:(0,r.jsx)("div",{className:f,children:(0,r.jsxs)("div",{className:"prose prose-lg dark:prose-invert max-w-none mb-12",children:[(0,r.jsx)(eG,{tag:"p",className:"lead font-semibold",valor:A.teaser,chave:_,onChange:e=>S(t=>({...t,teaser:e})),placeholder:"Linha fina: uma frase que continua o t\xedtulo, sem repeti-lo",rotulo:"Linha fina",maxLength:600}),(0,r.jsx)(n.$Z$,{editor:ec})]})})})]}),(0,r.jsx)(t2,{onParagrafo:()=>(function(e){let{doc:t,schema:a}=e.state,r=t.lastChild;if(r&&"paragraph"===r.type.name&&0===r.content.size){let a=t.content.size-r.nodeSize;return e.view.dispatch(e.state.tr.setSelection(eb.U3.create(t,a+1)).scrollIntoView()),e.view.focus(),a}let o=t.content.size,i=e.state.tr.insert(o,a.nodes.paragraph.create());return i.setSelection(eb.U3.create(i.doc,o+1)),e.view.dispatch(i.scrollIntoView()),e.view.focus(),o})(ec),onBloco:e=>em(e,"fim")}),(0,r.jsx)("div",{className:"mx-auto max-w-3xl px-4 pb-24",children:(0,r.jsxs)("div",{className:"rounded-lg border p-4",children:[(0,r.jsx)(k.J,{htmlFor:"editor-tags",className:"mb-2 block font-semibold",children:"Etiquetas (tags)"}),(0,r.jsx)(C.F,{id:"editor-tags",value:A.tags,onChange:e=>S(t=>({...t,tags:e})),suggestions:(a?.tags??[]).map(e=>e.nome),placeholder:"Digite e aperte Enter para adicionar"}),(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"As etiquetas ligam esta mat\xe9ria a outras do mesmo assunto. Use as que j\xe1 existem sempre que puder."})]})}),(0,r.jsx)(aN,{editor:ec,aberto:V,onFechar:()=>I(!1)}),(0,r.jsx)(tR,{pedido:et,onFechar:()=>ea(null),onConfirmar:(e,t)=>{ec&&(null===e.pos?function(e,t,a="cursor"){let{schema:r}=e,o=function(e,t){let{doc:a,selection:r}=e.state;return"fim"===t?a.content.size:0===r.$to.depth?r.to:r.$to.after(1)}(e,a),{doc:i}=e.state,s=r.nodes.bloco.create({dados:t,oculto:!1,_item:null}),n=o<i.content.size?i.nodeAt(o):null,l=n&&"bloco"!==n.type.name&&"htmlBruto"!==n.type.name?null:r.nodes.paragraph.create(),d=e.state.tr.insert(o,l?[s,l]:[s]);d.setSelection(l?eb.U3.create(d.doc,o+s.nodeSize+1):eb.nh.create(d.doc,o)),e.view.dispatch(d.scrollIntoView())}(ec,t,e.onde):function(e,t,a){let r=eN(e,t);if(!r)return;let o=e.state.tr.setNodeMarkup(t,void 0,{...r.attrs,dados:a,oculto:!1});o.setSelection(eb.nh.create(o.doc,t)),e.view.dispatch(o)}(ec,e.pos,t),ea(null))}}),(0,r.jsx)(t7,{aberta:ei,onFechar:()=>es(!1),montarArtigo:()=>({id:e,uuid:e,slug:t.slug,title:A.title,summary:A.teaser,paragraphs:ef(),category:A.categoria,author:t.somenteLeitura.author_name??"",publishedAt:t.somenteLeitura.created?new Date(t.somenteLeitura.created):new Date,imageUrl:A.destaque.url,imageUrlCaption:A.destaque.legenda||void 0,focalPoint:A.destaque.focal??void 0,sponsorLogoUrl:t.campos.field_logocp,technicalSheet:t.campos.field_ficha_tecnica_cp,isSponsored:!!(t.campos.field_logocp||t.temFichaTecnica),tags:A.tags,link:`/noticias/${t.slug}`,published:t.campos.published,disableParagraphInjectors:t.campos.disableParagraphInjectors})}),(0,r.jsx)(tB,{aberto:er,destaque:A.destaque,onFechar:()=>eo(!1),onConfirmar:e=>{S(t=>({...t,destaque:e})),eo(!1)}}),(0,r.jsx)(b.Lt,{open:T,onOpenChange:e=>!F&&U(e),children:(0,r.jsxs)(b.EO,{children:[(0,r.jsxs)(b.wd,{children:[(0,r.jsx)(b.r7,{children:t.campos.published?"Publicar as altera\xe7\xf5es?":"Salvar as altera\xe7\xf5es?"}),(0,r.jsx)(b.$v,{children:t.campos.published?"O que voc\xea editou vai para o site agora. A vers\xe3o anterior fica guardada no hist\xf3rico e d\xe1 para voltar a ela.":"Este artigo n\xe3o est\xe1 publicado: as altera\xe7\xf5es ficam salvas, mas n\xe3o aparecem no site."})]}),(0,r.jsxs)(b.ck,{children:[(0,r.jsx)(b.Zr,{disabled:F,children:"Voltar a editar"}),(0,r.jsx)(b.Rx,{disabled:F,onClick:e=>{e.preventDefault(),ew()},children:F?"Publicando…":t.campos.published?"Publicar agora":"Salvar"})]})]})}),(0,r.jsx)(b.Lt,{open:!!H,onOpenChange:e=>!e&&G(null),children:(0,r.jsxs)(b.EO,{children:[(0,r.jsxs)(b.wd,{children:[(0,r.jsx)(b.r7,{children:"Outra pessoa alterou este artigo"}),(0,r.jsx)(b.$v,{children:"Enquanto voc\xea editava, algu\xe9m publicou uma altera\xe7\xe3o nesta mat\xe9ria. Para n\xe3o apagar o trabalho dela, nada foi publicado. Suas altera\xe7\xf5es continuam guardadas como rascunho neste navegador: recarregue o artigo, confira a vers\xe3o nova e recupere o rascunho."})]}),(0,r.jsxs)(b.ck,{children:[(0,r.jsx)(b.Zr,{children:"Continuar aqui"}),(0,r.jsx)(b.Rx,{onClick:()=>{G(null),d()},children:"Recarregar o artigo"})]})]})}),(0,r.jsx)(b.Lt,{open:!!J,onOpenChange:e=>!e&&W(null),children:(0,r.jsxs)(b.EO,{children:[(0,r.jsxs)(b.wd,{children:[(0,r.jsx)(b.r7,{children:"N\xe3o foi poss\xedvel publicar"}),(0,r.jsx)(b.$v,{children:"Nada foi alterado no site. Corrija o que est\xe1 abaixo e tente de novo:"})]}),(0,r.jsx)("ul",{className:"max-h-60 list-disc space-y-1 overflow-y-auto pl-5 text-sm",children:J?.map((e,t)=>(0,r.jsx)("li",{children:e},t))}),(0,r.jsx)(b.ck,{children:(0,r.jsx)(b.Rx,{onClick:()=>W(null),children:"Entendi"})})]})}),(0,r.jsx)(tQ,{aberto:X,onFechar:()=>Q(!1),f:i,articleId:e,temAlteracoesLocais:ey,onRestaurado:t=>{af(e),w({title:"Vers\xe3o restaurada",description:t?.length?t.join(" "):"O artigo voltou ao estado anterior e j\xe1 est\xe1 no ar."}),d()},onErro:e=>w({variant:"destructive",title:"N\xe3o foi poss\xedvel restaurar",description:e.mensagem})})]})})}function aN({editor:e,aberto:t,onFechar:a}){return(0,r.jsx)(y.lG,{open:t,onOpenChange:e=>!e&&a(),children:(0,r.jsx)(y.Cf,{children:t&&(0,r.jsx)(ay,{editor:e,onFechar:a})})})}function ay({editor:e,onFechar:t}){let[a,i]=(0,o.useState)(()=>e.getAttributes("link").href??""),[s,n]=(0,o.useState)(()=>"_blank"===e.getAttributes("link").target),[l,d]=(0,o.useState)(null),[c]=(0,o.useState)(()=>e.isActive("link")),[u]=(0,o.useState)(()=>e.state.selection.empty&&!e.isActive("link")),m=()=>{let r;if(""===a.trim()){e.chain().focus().extendMarkRange("link").unsetLink().run(),t();return}let o=""===(r=a.trim())?null:/^(https?:|mailto:|tel:|\/|#)/i.test(r)?r:/^[\w-]+(\.[\w-]+)+([/?#].*)?$/.test(r)?`https://${r}`:null;o?(e.chain().focus().extendMarkRange("link").setLink({href:o,target:s?"_blank":null,rel:s?"noopener noreferrer":null}).run(),t()):d("Esse endere\xe7o n\xe3o parece v\xe1lido. Exemplos: www.exemplo.com.br ou https://exemplo.com.br/pagina")};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(y.c7,{children:[(0,r.jsx)(y.L3,{children:c?"Editar link":"Adicionar link"}),(0,r.jsx)(y.rr,{children:u?"Primeiro selecione, no texto, as palavras que v\xe3o virar link.":"Endere\xe7o para onde as palavras 
1selecionadas v\xe3o levar."})]}),!u&&(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(k.J,{htmlFor:"editor-link-url",children:"Endere\xe7o"}),(0,r.jsx)(w.p,{id:"editor-link-url",value:a,onChange:e=>{i(e.target.value),d(null)},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),m())},placeholder:"www.exemplo.com.br",autoFocus:!0}),l&&(0,r.jsx)("p",{className:"mt-1 text-sm text-destructive",children:l})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(N.S,{id:"editor-link-aba",checked:s,onCheckedChange:e=>n(!0===e)}),(0,r.jsx)(k.J,{htmlFor:"editor-link-aba",className:"font-normal",children:"Abrir em uma nova aba"})]})]}),(0,r.jsxs)(y.Es,{children:[(0,r.jsx)(j.$,{variant:"ghost",onClick:t,children:"Cancelar"}),c&&(0,r.jsx)(j.$,{variant:"outline",onClick:()=>{e.chain().focus().extendMarkRange("link").unsetLink().run(),t()},children:"Remover link"}),!u&&(0,r.jsx)(j.$,{onClick:m,children:c?"Atualizar":"Adicionar"})]})]})}},72242:(e,t,a)=>{"use strict";a.d(t,{F:()=>i});var r=a(12115),o=a(48375);function i(){let{user:e}=(0,o.A)();return(0,r.useCallback)(async(t,a)=>{if(!e)throw Error("N\xe3o autenticado");let r=await e.getIdToken();return fetch(t,{...a,headers:{...a?.headers||{},Authorization:`Bearer ${r}`,...a?.body?{"Content-Type":"application/json"}:{}}})},[e])}},72264:(e,t,a)=>{"use strict";a.d(t,{SQ:()=>m,_2:()=>p,lp:()=>g,mB:()=>f,rI:()=>c,ty:()=>u});var r=a(95155),o=a(12115),i=a(57793),s=a(21362),n=a(94514),l=a(16950),d=a(40980);let c=i.bL,u=i.l9;i.YJ,i.ZL,i.Pb,i.z6,o.forwardRef(({className:e,inset:t,children:a,...o},n)=>(0,r.jsxs)(i.ZP,{ref:n,className:(0,d.cn)("flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...o,children:[a,(0,r.jsx)(s.A,{className:"ml-auto"})]})).displayName=i.ZP.displayName,o.forwardRef(({className:e,...t},a)=>(0,r.jsx)(i.G5,{ref:a,className:(0,d.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t})).displayName=i.G5.displayName;let m=o.forwardRef(({className:e,sideOffset:t=4,...a},o)=>(0,r.jsx)(i.ZL,{children:(0,r.jsx)(i.UC,{ref:o,sideOffset:t,className:(0,d.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...a})}));m.displayName=i.UC.displayName;let p=o.forwardRef(({className:e,inset:t,...a},o)=>(0,r.jsx)(i.q7,{ref:o,className:(0,d.cn)("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...a}));p.displayName=i.q7.displayName,o.forwardRef(({className:e,children:t,checked:a,...o},s)=>(0,r.jsxs)(i.H_,{ref:s,className:(0,d.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:a,...o,children:[(0,r.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,r.jsx)(i.VF,{children:(0,r.jsx)(n.A,{className:"h-4 w-4"})})}),t]})).displayName=i.H_.displayName,o.forwardRef(({className:e,children:t,...a},o)=>(0,r.jsxs)(i.hN,{ref:o,className:(0,d.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...a,children:[(0,r.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,r.jsx)(i.VF,{children:(0,r.jsx)(l.A,{className:"h-2 w-2 fill-current"})})}),t]})).displayName=i.hN.displayName;let g=o.forwardRef(({className:e,inset:t,...a},o)=>(0,r.jsx)(i.JU,{ref:o,className:(0,d.cn)("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...a}));g.displayName=i.JU.displayName;let f=o.forwardRef(({className:e,...t},a)=>(0,r.jsx)(i.wv,{ref:a,className:(0,d.cn)("-mx-1 my-1 h-px bg-muted",e),...t}));f.displayName=i.wv.displayName},89239:(e,t,a)=>{"use strict";a.d(t,{$:()=>d,r:()=>l});var r=a(95155),o=a(12115),i=a(42442),s=a(18460),n=a(40980);let l=(0,s.F)("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),d=o.forwardRef(({className:e,variant:t,size:a,asChild:o=!1,...s},d)=>{let c=o?i.DX:"button";return(0,r.jsx)(c,{className:(0,n.cn)(l({variant:t,size:a,className:e})),ref:d,...s})});d.displayName="Button"},97916:(e,t,a)=>{"use strict";a.d(t,{w:()=>n});var r=a(95155),o=a(12115),i=a(15763),s=a(40980);let n=o.forwardRef(({className:e,orientation:t="horizontal",decorative:a=!0,...o},n)=>(0,r.jsx)(i.b,{ref:n,decorative:a,orientation:t,className:(0,s.cn)("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",e),...o}));n.displayName=i.b.displayName},98947:(e,t,a)=>{"use strict";a.d(t,{I7:()=>d,OJ:()=>u,Xr:()=>c,ix:()=>m});var r=a(67619);let o=["firebasestorage.googleapis.com","storage.googleapis.com"],i=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),s=(e,t)=>{if("string"!=typeof e)return null;let a=e.trim();return""===a?null:a.slice(0,t)};function n(e){if("string"!=typeof e)return null;try{let t=new URL(e);return"https:"===t.protocol&&o.includes(t.hostname)?t.toString():null}catch{return null}}let l=e=>"number"==typeof e&&Number.isFinite(e)&&e>0&&e<=2e4?Math.round(e):null;function d(e){if(!i(e)||e.v!==r.O)return null;let t=[];for(let a of Array.isArray(e.paginas)?e.paginas.slice(0,r.H.paginasMax):[]){if(!i(a))continue;let e=n(a.url),o=l(a.largura),d=l(a.altura);if(!e||!o||!d)continue;let c=n(a.urlGrande)??void 0,u=n(a.miniatura)??void 0,m=s(a.rotulo,r.H.rotulo)??void 0;t.push({url:e,largura:o,altura:d,...c?{urlGrande:c}:{},...u?{miniatura:u}:{},...m?{rotulo:m}:{}})}if(0===t.length)return null;let a=s(e.titulo,r.H.titulo)??"Documento",o=s(e.legenda,r.H.legenda)??void 0,d=n(e.pdfUrl)??void 0,c="number"==typeof e.pdfBytes&&Number.isFinite(e.pdfBytes)&&e.pdfBytes>0?Math.round(e.pdfBytes):void 0;return{v:r.O,titulo:a,...o?{legenda:o}:{},...d?{pdfUrl:d}:{},...d&&c?{pdfBytes:c}:{},...!0===e.capaSozinha?{capaSozinha:!0}:{},paginas:t}}function c(e){let t=e.paginas.length;return`${e.titulo}${e.legenda?`: ${e.legenda}`:""} (${t} ${1===t?"p\xe1gina":"p\xe1ginas"} em imagem)`}function u(e,t){let a=[],r=0;for(t&&e>0&&(a.push([0]),r=1);r<e;r+=2)a.push(r+1<e?[r,r+1]:[r]);return a}function m(e){let t=e/1048576;return`${t>=10?Math.round(t):t.toFixed(1).replace(".",",")} MB`}},99412:(e,t,a)=>{"use strict";a.d(t,{Fm:()=>g,Qs:()=>h,cj:()=>d,h:()=>p,qp:()=>f});var r=a(95155),o=a(12115),i=a(43146),s=a(18460),n=a(33210),l=a(40980);let d=i.bL;i.l9,i.bm;let c=i.ZL,u=o.forwardRef(({className:e,...t},a)=>(0,r.jsx)(i.hJ,{className:(0,l.cn)("fixed inset-0 z-50 bg-black/80  data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:
1a}));u.displayName=i.hJ.displayName;let m=(0,s.F)("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4  border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),p=o.forwardRef(({side:e="right",className:t,children:a,...o},s)=>(0,r.jsxs)(c,{children:[(0,r.jsx)(u,{}),(0,r.jsxs)(i.UC,{ref:s,className:(0,l.cn)(m({side:e}),t),...o,children:[a,(0,r.jsxs)(i.bm,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[(0,r.jsx)(n.A,{className:"h-4 w-4"}),(0,r.jsx)("span",{className:"sr-only",children:"Close"})]})]})]}));p.displayName=i.UC.displayName;let g=({className:e,...t})=>(0,r.jsx)("div",{className:(0,l.cn)("flex flex-col space-y-2 text-center sm:text-left",e),...t});g.displayName="SheetHeader";let f=o.forwardRef(({className:e,...t},a)=>(0,r.jsx)(i.hE,{ref:a,className:(0,l.cn)("text-lg font-semibold text-foreground",e),...t}));f.displayName=i.hE.displayName;let h=o.forwardRef(({className:e,...t},a)=>(0,r.jsx)(i.VY,{ref:a,className:(0,l.cn)("text-sm text-muted-foreground",e),...t}));h.displayName=i.VY.displayName}}]);

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.