/* Growth OS — Módulos: Growth Model, Fechamento, Relatórios, Integrações, Contexto, Config */
(function(){
const R=window.React,h=R.createElement,{useState}=R;
const G=window.GOS,L=window.GOSlib,Icon=window.GOSIcon;

function PageHead(p){
  return h("div",{className:"page-head"},
    h("div",null,
      h("p",{className:"kicker",style:{marginBottom:14}},p.kicker),
      h("h1",null,p.title),
      p.sub&&h("p",{className:"ph-sub"},p.sub)),
    p.actions&&h("div",{className:"ph-actions"},p.actions));
}

/* ============ GROWTH MODEL ============ */
function GrowthModel(props){
  const{company:co,period}=props;
  const gm=co.growthModel;
  const [vals,setVals]=useState(gm.stages.map(s=>{const ind=co.indicators.find(i=>i.key===s.metric);return ind?L.agg(ind,[G.CUR]):0;}));
  const set=(i,v)=>setVals(a=>a.map((x,j)=>j===i?(parseFloat(v)||0):x));
  const rate=(i)=>i<vals.length-1&&vals[i]?Math.round(vals[i+1]/vals[i]*1000)/10:null;
  const reset=()=>setVals(gm.stages.map(s=>{const ind=co.indicators.find(i=>i.key===s.metric);return ind?L.agg(ind,[G.CUR]):0;}));
  const [sim,setSim]=useState(false);
  return h("div",{className:"wrap fade-in"},
    h(PageHead,{kicker:"Growth Model · "+period.label,title:"Como esforço vira resultado",
      sub:"Cada etapa tem volume de entrada, saída e taxa de conversão. Edite os nós para simular cenários — dados reais e simulações permanecem separados.",
      actions:[h("button",{key:1,className:"chip"+(sim?" on":" static"),onClick:()=>setSim(s=>!s)},sim?"Modo simulação ativo":"Ativar simulação"),sim&&h("button",{key:2,className:"btn btn-ghost btn-sm",onClick:reset},h(Icon,{name:"refresh",size:14}),"Restaurar reais")]}),
    sim&&h("div",{className:"chip static",style:{marginBottom:16,color:"var(--warn)",borderColor:"rgba(232,200,106,.4)"}},h(Icon,{name:"alert",size:13}),"Você está simulando. Alterações não substituem os dados reais."),
    h("div",{className:"panel"},
      h("div",{className:"panel-hd"},h("h3",null,gm.name),h("span",{className:"lbl"},"junho/26")),
      h("div",{className:"gm-flow"},
        gm.stages.map((s,i)=>h(React.Fragment,{key:i},
          h("div",{className:"gm-node"},
            h("div",{className:"gn-l"},s.label),
            sim?h("input",{className:"gn-edit",type:"number",value:vals[i],onChange:e=>set(i,e.target.value)}):h("div",{className:"gn-v"},L.fmtNum(vals[i]))),
          i<gm.stages.length-1&&h("div",{className:"gm-conv"},
            h("span",{className:"gc-rate"},rate(i)!=null?rate(i)+"%":"—"),
            h("span",{className:"gc-arrow"},h(Icon,{name:"arrowR",size:16})),
            h("span",{className:"gc-loss"},vals[i]&&vals[i+1]!=null?"−"+L.fmtNum(vals[i]-vals[i+1]):""))))
      )),
    h("div",{className:"grid-3",style:{marginTop:16}},
      miniStat("Conversão ponta a ponta",vals[0]?(Math.round(vals[vals.length-2]/vals[0]*1000)/10)+"%":"—","do topo ao fechamento"),
      miniStat("Maior perda",biggestLoss(gm,vals),"etapa a otimizar"),
      miniStat("Receita decomposta",decompRevenue(co),"meta mensal pelo modelo")));
}
function biggestLoss(gm,vals){let max=0,label="—";for(let i=0;i<vals.length-2;i++){const loss=vals[i]-vals[i+1];const pct=vals[i]?loss/vals[i]:0;if(pct>max){max=pct;label=`${gm.stages[i].label} → ${gm.stages[i+1].label}`;}}return label;}
function decompRevenue(co){const r=co.indicators.find(i=>i.key==="rcont");return r&&r.goal?L.fmtMoneyBRL(r.goal,true):"—";}
function miniStat(l,v,x){return h("div",{className:"panel",style:{padding:"18px 20px"}},h("div",{className:"lbl"},l),h("div",{className:"sora",style:{fontSize:26,marginTop:10,letterSpacing:"-.03em"}},v),h("div",{className:"muted",style:{fontSize:12,marginTop:6}},x));}

/* ============ FECHAMENTO MENSAL ============ */
const CLOSE_STEPS=["Validar atualizações e integrações","Identificar campos ausentes ou inconsistentes","Revisar metas e indicadores","Registrar fatos que afetaram o mês","Gerar leitura automática dos acontecimentos","Registrar decisões e ações do próximo período","Fechar o mês e gerar relatório final"];
const STATE_DOT={aberto:"var(--mist)",revisao:"var(--warn)",fechado:"var(--up)"};
function Fechamento(props){
  const{company:co}=props;
  const monthKeys=Object.keys(co.months).sort();
  const[sel,setSel]=useState(G.CUR);
  const[states,setStates]=useState({...Object.fromEntries(monthKeys.map(k=>[k,co.months[k].state]))});
  const[checks,setChecks]=useState({});
  const st=states[sel];
  const toggle=i=>setChecks(c=>({...c,[sel+"-"+i]:!c[sel+"-"+i]}));
  const done=CLOSE_STEPS.filter((_,i)=>checks[sel+"-"+i]).length;
  const closeMonth=()=>{setStates(s=>({...s,[sel]:"fechado"}));props.toast("Mês "+L.monthLong(sel)+" fechado. Relatório final gerado.");};
  const period={keys:[sel],label:L.monthLong(sel),cmp:null};
  const signals=window.GOSSignals(co,{keys:[sel],cmp:{keys:[prevKey(sel)],label:L.monthLong(prevKey(sel))}});
  return h("div",{className:"wrap fade-in"},
    h(PageHead,{kicker:"Registro mensal e fechamento",title:"Fechamento",
      sub:"O mês é a espinha dorsal. Fechado, vira a fotografia oficial — alterações posteriores geram histórico e nova versão."}),
    h("div",{className:"month-strip",style:{marginBottom:24}},
      monthKeys.map(k=>h("button",{key:k,className:"month-cell"+(sel===k?" on":""),onClick:()=>setSel(k)},
        h("div",{className:"mc-m"},L.monthLong(k)),
        h("div",{className:"mc-s"},h("i",{style:{background:STATE_DOT[states[k]]}}),h("span",{style:{color:STATE_DOT[states[k]]}},stateLabel(states[k])))))),
    h("div",{className:"grid-2",style:{gridTemplateColumns:"1.3fr 1fr",alignItems:"start",gap:20}},
      h("div",{className:"panel"},
        h("div",{className:"panel-hd"},h("h3",null,"Fluxo de fechamento · "+L.monthLong(sel)),h("span",{className:"status-pill "+st},stateLabel(st))),
        h("div",{style:{display:"flex",flexDirection:"column",gap:2}},
          CLOSE_STEPS.map((s,i)=>{const ck=checks[sel+"-"+i]||st==="fechado";return h("button",{key:i,onClick:()=>st!=="fechado"&&toggle(i),style:{display:"flex",alignItems:"center",gap:12,padding:"12px 0",borderBottom:i<CLOSE_STEPS.length-1?"1px solid var(--line-d2)":"none",textAlign:"left",opacity:st==="fechado"?.7:1,cursor:st==="fechado"?"default":"pointer"}},
            h("span",{style:{width:22,height:22,borderRadius:6,border:"1px solid "+(ck?"var(--lume)":"var(--line-d)"),background:ck?"var(--lume)":"transparent",display:"grid",placeItems:"center",flexShrink:0,color:"var(--foco)"}},ck&&h(Icon,{name:"check",size:13})),
            h("span",{style:{fontSize:14,color:ck?"var(--papel)":"var(--mist)"}},h("span",{className:"mono",style:{color:"var(--mist-2)",fontSize:11,marginRight:8}},String(i+1).padStart(2,"0")),s));})),
        st!=="fechado"?h("button",{className:"btn btn-lume",style:{marginTop:18,width:"100%",justifyContent:"center",opacity:done>=5?1:.5,pointerEvents:done>=5?"auto":"none"},onClick:closeMonth},h(Icon,{name:"check",size:16}),done>=5?"Fechar mês e gerar relatório":`Complete ao menos 5 etapas (${done}/7)`)
          :h("div",{className:"chip static",style:{marginTop:18,width:"100%",justifyContent:"center",color:"var(--up)",borderColor:"rgba(143,224,122,.4)"}},h(Icon,{name:"check",size:14}),"Mês fechado · fotografia oficial")),
      h("div",{style:{display:"flex",flexDirection:"column",gap:20}},
        h("div",{className:"panel"},
          h("div",{className:"panel-hd"},h("h3",null,"Principais sinais"),h("span",{className:"lbl"},signals.length+" no mês")),
          signals.slice(0,4).map((s,i)=>h("div",{key:i,style:{display:"flex",gap:10,padding:"10px 0",borderBottom:i<3?"1px solid var(--line-d2)":"none"}},
            h("span",{className:"sg-kind "+s.kind,style:{alignSelf:"flex-start"}},s.kind),
            h("span",{style:{fontSize:13,lineHeight:1.4}},s.text[0],h("b",{className:"sora"},s.text[1]),s.text[2])))),
        h("div",{className:"panel"},
          h("div",{className:"panel-hd"},h("h3",null,"Contexto do mês")),
          co.context.filter(c=>c.date.startsWith(sel)).length?co.context.filter(c=>c.date.startsWith(sel)).map((ce,i)=>h("div",{className:"ctx-item",key:i,style:{borderBottom:"none"}},h("span",{className:"ci-cat"},ce.cat),h("span",{className:"ci-txt"},ce.txt))):h("p",{className:"muted",style:{fontSize:13}},"Nenhum fato registrado neste mês. Registre fatos que os números não carregam.")))));
}
function prevKey(k){const i=G.keys6.indexOf(k);return i>0?G.keys6[i-1]:k;}
function stateLabel(s){return{aberto:"Aberto",revisao:"Em revisão",fechado:"Fechado"}[s]||s;}

/* ============ INTEGRAÇÕES ============ */
function Integrations(props){
  const{company:co}=props;
  return h("div",{className:"wrap fade-in"},
    h(PageHead,{kicker:"Fontes conectadas",title:"Integrações",
      sub:"Cada valor mantém referência à origem. Status mostra atualização e qualidade — não apenas “conectado”.",
      actions:[h("button",{key:1,className:"btn btn-ghost btn-sm"},h(Icon,{name:"plus",size:14}),"Conectar fonte")]}),
    co.integrations.map((it,i)=>h("div",{className:"intg-row",key:i},
      h("div",{className:"ir-icon",style:{color:co.color}},it.name[0]),
      h("div",{style:{minWidth:0,flex:1}},
        h("div",{className:"ir-name"},it.name),
        h("div",{className:"ir-sub"},it.kind+" · "+(it.entities==="—"?"sem entidades":it.entities))),
      h("div",{style:{textAlign:"right",flexShrink:0,display:"flex",flexDirection:"column",gap:6,alignItems:"flex-end"}},
        h("span",{className:"intg-status "+it.status},h("span",{style:{width:6,height:6,borderRadius:"50%",background:"currentColor"}}),statusLabel(it.status)),
        h("span",{className:"mono",style:{fontSize:10,color:"var(--mist-2)"}},"sync "+it.sync)),
      h("div",{style:{width:1,alignSelf:"stretch",background:"var(--line-d)"}}),
      h("div",{style:{width:180,flexShrink:0}},
        h("div",{className:"lbl",style:{fontSize:8.5}},"Período coberto"),
        h("div",{style:{fontSize:12,marginTop:4}},it.cover),
        it.pend!=="—"&&h("div",{style:{fontSize:11,marginTop:6,color:"var(--warn)",lineHeight:1.4}},h(Icon,{name:"alert",size:11,style:{display:"inline",verticalAlign:"-2px",marginRight:4}}),it.pend))
    )));
}
function statusLabel(s){return{conectada:"Conectada",atencao:"Atenção",erro:"Erro",desconectada:"Desconectada"}[s]||s;}

/* ============ CONTEXTO ============ */
const CTX_CATS=["Campanha","Equipe","Preço","Produto","Externo","Técnico","Estratégia","Operação","Sazonalidade"];
function Context(props){
  const{company:co}=props;
  const[list,setList]=useState(co.context.slice().sort((a,b)=>b.date.localeCompare(a.date)));
  const[form,setForm]=useState({date:"2026-06-30",cat:"Campanha",txt:""});
  const add=()=>{if(!form.txt.trim())return;setList(l=>[{...form},...l].sort((a,b)=>b.date.localeCompare(a.date)));setForm(f=>({...f,txt:""}));props.toast("Contexto registrado.");};
  return h("div",{className:"wrap fade-in"},
    h(PageHead,{kicker:"Memória da empresa",title:"Contexto mensal",
      sub:"Fatos que os números não carregam. Ajudam interpretações futuras, mas não provam causalidade."}),
    h("div",{className:"grid-2",style:{gridTemplateColumns:"1fr 1.4fr",alignItems:"start",gap:20}},
      h("div",{className:"panel"},
        h("div",{className:"panel-hd"},h("h3",null,"Registrar fato")),
        h("div",{className:"field"},h("label",null,"Data"),h("input",{type:"date",value:form.date,onChange:e=>setForm(f=>({...f,date:e.target.value}))})),
        h("div",{className:"field"},h("label",null,"Categoria"),h("select",{value:form.cat,onChange:e=>setForm(f=>({...f,cat:e.target.value}))},CTX_CATS.map(c=>h("option",{key:c},c)))),
        h("div",{className:"field"},h("label",null,"Fato"),h("textarea",{rows:4,value:form.txt,onChange:e=>setForm(f=>({...f,txt:e.target.value})),placeholder:"Ex.: Nova landing page entrou no ar em 12/06."})),
        h("button",{className:"btn btn-lume",style:{width:"100%",justifyContent:"center"},onClick:add},h(Icon,{name:"plus",size:15}),"Registrar contexto"),
        h("p",{className:"muted",style:{fontSize:11.5,marginTop:14,lineHeight:1.5}},"Linguagem segura: descreva coincidências sem afirmar causa. Ex.: “A queda coincide com…”.")),
      h("div",{className:"panel"},
        h("div",{className:"panel-hd"},h("h3",null,"Linha do tempo"),h("span",{className:"lbl"},list.length+" registros")),
        list.map((ce,i)=>h("div",{className:"ctx-item",key:i,style:i===list.length-1?{borderBottom:"none"}:null},
          h("span",{className:"ci-date"},fmtD(ce.date)),
          h("span",{className:"ci-cat"},ce.cat),
          h("span",{className:"ci-txt"},ce.txt))))));
}
function fmtD(s){const[y,m,d]=s.split("-");return`${d} ${G.MONTHS.find(x=>x[0]===m)[1].toLowerCase()}`;}

/* ============ CONFIGURAÇÕES ============ */
function Config(props){
  const{company:co}=props;
  return h("div",{className:"wrap fade-in"},
    h(PageHead,{kicker:"Configurações da empresa",title:"Indicadores, metas e fórmulas",
      sub:"Definições que valem só para "+co.name+". Tipo, direção desejável, meta, faixa saudável e confiabilidade por indicador."}),
    h("div",{className:"panel",style:{padding:0,overflow:"hidden"}},
      h("table",{className:"dtable",style:{fontSize:12.5}},
        h("thead",null,h("tr",null,h("th",null,"Indicador"),h("th",null,"Categoria"),h("th",null,"Tipo"),h("th",null,"Direção"),h("th",null,"Meta"),h("th",null,"Fonte"),h("th",null,"Confiança"))),
        h("tbody",null,co.indicators.map(ind=>h("tr",{key:ind.key,onClick:()=>props.onOpen(ind.key),style:{cursor:"pointer"}},
          h("td",null,h("span",{className:"cell-name"},ind.name,ind.star&&h("span",{style:{color:"var(--lume)",marginLeft:6}},"★"))),
          h("td",{style:{textAlign:"right",color:"var(--mist)"}},ind.cat),
          h("td",{style:{textAlign:"right",color:"var(--mist)"}},ind.type),
          h("td",{style:{textAlign:"right",color:"var(--mist)"}},dirShort(ind.dir)),
          h("td",{className:"num"},ind.goal!=null?L.fmtVal(ind,ind.goal,true):"—"),
          h("td",{style:{textAlign:"right",color:"var(--mist)"}},ind.source),
          h("td",{style:{textAlign:"right"}},h("span",{className:"conf-badge "+ind.conf,style:{fontSize:9.5}},ind.conf)))))))
  );
}
function dirShort(d){return{maior:"↑ maior",menor:"↓ menor",faixa:"↔ faixa",monitor:"• monitorar"}[d]||d;}

/* ============ RELATÓRIOS ============ */
const SECTIONS=["Resumo executivo","Marketing e aquisição","Comercial","Receita","Clientes","Operação","Contexto e decisões","Sinais e tendências"];
function Reports(props){
  const{company:co}=props;
  const[lib,setLib]=useState(co.reports.slice());
  const[build,setBuild]=useState(false);
  const addReport=r=>{setLib(l=>[r,...l]);props.toast("Relatório gerado e salvo na biblioteca.");};
  return h("div",{className:"wrap fade-in"},
    h(PageHead,{kicker:"Relatórios e biblioteca",title:"Relatórios",
      sub:"Documentos versionados por empresa, período e status. Todo relatório identifica empresa, período, versão, fontes e quem gerou.",
      actions:[h("button",{key:1,className:"btn btn-lume btn-sm",onClick:()=>setBuild(true)},h(Icon,{name:"plus",size:15}),"Gerar relatório")]}),
    h("div",{className:"section-lbl",style:{marginTop:8}},h("h2",null,"Biblioteca"),h("span",{className:"sl-line"}),h("span",{className:"sl-count"},lib.length+" documentos")),
    lib.map((r,i)=>h("div",{className:"rep-row",key:i},
      h("div",{className:"rr-ico"},"PDF"),
      h("div",{style:{flex:1,minWidth:0}},
        h("div",{className:"rr-t"},r.title),
        h("div",{className:"rr-m"},r.type+" · "+r.period+" · "+r.ver+(r.gen!=="—"?" · gerado "+r.gen:" · não gerado")+" · por "+r.by)),
      h("span",{className:"status-pill "+r.status},r.status),
      h("button",{className:"btn btn-ghost btn-sm",onClick:()=>props.toast(r.status==="preliminar"?"Gere uma versão final antes de baixar.":"Baixando "+r.title+"…")},h(Icon,{name:"download",size:14}),"PDF"))),
    build&&h(ReportBuilder,{company:co,period:props.period,onClose:()=>setBuild(false),onGenerate:r=>{addReport(r);setBuild(false);}}));
}
function ReportBuilder(props){
  const{company:co,period}=props;
  const[type,setType]=useState("Mensal");
  const[secs,setSecs]=useState(Object.fromEntries(SECTIONS.map(s=>[s,true])));
  const[email,setEmail]=useState("");
  const now="30 jun 2026 · 14:20";
  const gen=()=>{props.onGenerate({title:`Relatório ${type.toLowerCase()} · ${period.label}`,type,period:period.label,gen:now.split(" · ")[0],ver:"v1",status:"final",by:"Rodrigo Fass"});};
  const chosen=SECTIONS.filter(s=>secs[s]);
  return h("div",{className:"modal-scrim",onClick:props.onClose},
    h("div",{className:"modal",style:{width:"min(960px,95vw)"},onClick:e=>e.stopPropagation()},
      h("div",{className:"modal-hd"},
        h("div",null,
          h("div",{className:"modal-bc"},h("span",null,"Relatórios"),h(Icon,{name:"chevronR",size:11}),h("span",{style:{color:"var(--papel)"}},"Gerar")),
          h("h2",null,"Gerar relatório"),
          h("p",{className:"mh-def"},"Selecione tipo, período e seções. Pré-visualize antes de gerar a versão.")),
        h("button",{className:"modal-close",onClick:props.onClose},h(Icon,{name:"close",size:18}))),
      h("div",{className:"modal-body"},
        h("div",{className:"grid-2",style:{gridTemplateColumns:"1fr 1.2fr",alignItems:"start",gap:22}},
          h("div",null,
            h("div",{className:"field"},h("label",null,"Tipo de relatório"),h("select",{value:type,onChange:e=>setType(e.target.value)},["Indicador","Mensal","Trimestral","Anual","Período personalizado"].map(o=>h("option",{key:o},o)))),
            h("div",{className:"field"},h("label",null,"Período"),h("input",{value:period.label,readOnly:true,style:{color:"var(--mist)"}})),
            h("div",{className:"lbl",style:{margin:"6px 0 10px"}},"Seções"),
            h("div",{style:{display:"flex",flexDirection:"column",gap:7}},
              SECTIONS.map(s=>h("button",{key:s,onClick:()=>setSecs(c=>({...c,[s]:!c[s]})),style:{display:"flex",alignItems:"center",gap:10,textAlign:"left"}},
                h("span",{style:{width:20,height:20,borderRadius:6,border:"1px solid "+(secs[s]?"var(--lume)":"var(--line-d)"),background:secs[s]?"var(--lume)":"transparent",display:"grid",placeItems:"center",color:"var(--foco)",flexShrink:0}},secs[s]&&h(Icon,{name:"check",size:12})),
                h("span",{style:{fontSize:13.5,color:secs[s]?"var(--papel)":"var(--mist)"}},s)))),
            h("div",{className:"field",style:{marginTop:16}},h("label",null,"Enviar por e-mail (opcional)"),h("input",{value:email,onChange:e=>setEmail(e.target.value),placeholder:"destinatario@empresa.com"}))),
          h("div",null,
            h("div",{className:"lbl",style:{marginBottom:10}},"Pré-visualização"),
            h(ReportPreview,{co,type,period,secs:chosen,now})))),
      h("div",{className:"modal-foot"},
        h("button",{className:"btn btn-ghost",onClick:props.onClose},"Cancelar"),
        h("button",{className:"btn btn-lume",onClick:gen},h(Icon,{name:"file",size:15}),"Gerar versão")) ));
}
function ReportPreview(props){
  const{co,type,period,secs,now}=props;
  const stars=co.indicators.filter(i=>i.star).slice(0,4);
  return h("div",{style:{background:"#ffffff",color:"var(--ink)",borderRadius:12,border:"1px solid rgba(0,0,0,.08)",padding:"26px 28px",maxHeight:440,overflowY:"auto"}},
    h("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:18,paddingBottom:16,borderBottom:"1px solid rgba(0,0,0,.1)"}},
      h("div",{style:{width:26,height:26,borderRadius:7,background:"var(--musgo)",display:"grid",placeItems:"center"}},h("img",{src:"assets/symbol-orange.png",style:{width:16}})),
      h("div",null,h("div",{style:{fontFamily:"var(--sora)",fontWeight:600,fontSize:14}},"Growth OS"),h("div",{style:{fontFamily:"var(--mono)",fontSize:8.5,letterSpacing:".15em",color:"var(--ink-faint)",textTransform:"uppercase"}},"Relatório "+type))),
    h("div",{style:{fontFamily:"var(--sora)",fontWeight:600,fontSize:22,letterSpacing:"-.02em",lineHeight:1.1}},co.name),
    h("div",{style:{fontFamily:"var(--mono)",fontSize:10.5,color:"var(--ink-soft)",marginTop:8,letterSpacing:".03em"}},period.label+" · "+type+" · v1 · final"),
    h("div",{style:{display:"flex",gap:14,flexWrap:"wrap",margin:"18px 0"}},
      stars.map(ind=>{const c=L.agg(ind,period.keys);return h("div",{key:ind.key,style:{minWidth:110}},
        h("div",{style:{fontFamily:"var(--mono)",fontSize:8.5,letterSpacing:".08em",textTransform:"uppercase",color:"var(--ink-faint)"}},ind.name),
        h("div",{style:{fontFamily:"var(--sora)",fontWeight:600,fontSize:20,letterSpacing:"-.02em",color:"var(--ink)",marginTop:4}},L.fmtVal(ind,c,true)));})),
    secs.slice(0,4).map(s=>h("div",{key:s,style:{marginTop:14}},
      h("div",{style:{fontFamily:"var(--sora)",fontWeight:600,fontSize:13,color:"var(--musgo)"}},s),
      h("div",{style:{fontSize:11.5,color:"var(--ink-soft)",lineHeight:1.5,marginTop:5}},sectionBlurb(s,co,period)))),
    h("div",{style:{marginTop:20,paddingTop:14,borderTop:"1px solid rgba(0,0,0,.1)",fontFamily:"var(--mono)",fontSize:8.5,color:"var(--ink-faint)",letterSpacing:".04em"}},"Gerado em "+now+" · Rodrigo Fass · Fontes: "+[...new Set(co.integrations.filter(x=>x.status==="conectada").map(x=>x.name))].slice(0,3).join(", ")));
}
function sectionBlurb(s,co,period){
  const rrec=co.indicators.find(i=>i.key==="rrec"),conv=co.indicators.find(i=>i.key==="conversao");
  if(s==="Resumo executivo")return`No período ${period.label}, ${co.name} registrou receita recebida de ${L.fmtMoneyBRL(L.agg(rrec,period.keys),true)}. Sinais e desvios detalhados nas seções seguintes.`;
  if(s==="Receita")return`Receita recebida: ${L.fmtMoneyBRL(L.agg(rrec,period.keys),true)}. Contratada e faturada acompanhadas mês a mês.`;
  if(s==="Comercial"&&conv)return`Conversão do período em ${L.fmtVal(conv,L.agg(conv,period.keys))}. Funil detalhado no Growth Model.`;
  return"Conteúdo consolidado a partir dos indicadores e do contexto registrados para o período.";
}

Object.assign(window,{GOSGrowthModel:GrowthModel,GOSFechamento:Fechamento,GOSIntegrations:Integrations,GOSContext:Context,GOSConfig:Config,GOSReports:Reports});
})();
