/* global React, I, Button, Reveal, Logo */
const { useState:useH2S, useEffect:useH2E, useRef:useH2R } = React;

/* ============ INTEGRATIONS NETWORK ============ */
const INTEG = [
  { n:"Epic",            x:15, y:18 },
  { n:"Cerner",          x:11, y:50 },
  { n:"Meditech",        x:15, y:82 },
  { n:"Athena",          x:85, y:18 },
  { n:"eCW",             x:89, y:50 },
  { n:"Practice Fusion", x:85, y:82 },
];
function Integrations(){
  return React.createElement("section",{ className:"section" },
    React.createElement("div",{ className:"wrap" },
      React.createElement(Reveal,null, React.createElement("p",{ className:"eyebrow" }, "Integrations")),
      React.createElement(Reveal,{ delay:60 }, React.createElement("h2",{ className:"h-sec" }, "The intelligence layer between your systems")),
      React.createElement(Reveal,{ delay:120 }, React.createElement("p",{ className:"sub-sec" }, "MedCode reads from the platforms you already run, then routes explainable coding back — no rip-and-replace.")),
      React.createElement(Reveal,{ delay:160, scale:true },
        React.createElement("div",{ className:"integ" },
          React.createElement("svg",{ className:"integ-svg", viewBox:"0 0 100 100", preserveAspectRatio:"none" },
            INTEG.map((nd,i)=>(
              React.createElement("line",{ key:i, x1:50, y1:50, x2:nd.x, y2:nd.y,
                className:"integ-link", strokeDasharray:"3 3",
                style:{ vectorEffect:"non-scaling-stroke", animation:`dashflow ${3+i*0.5}s linear infinite` } })
            ))
          ),
          React.createElement("div",{ className:"integ-core float" },
            React.createElement("div",null, React.createElement("b",null,"MedCode"), React.createElement("span",null,"AI layer"))),
          INTEG.map((nd,i)=>(
            React.createElement("div",{ key:nd.n, className:"integ-node",
              style:{ left:`${nd.x}%`, top:`${nd.y}%`, animation:`floaty ${6+i}s ease-in-out infinite` } },
              React.createElement("span",{ className:"nd" }), nd.n)
          ))
        ))
    )
  );
}

/* ============ PRICING ============ */
const PLANS = [
  { tag:"Starter", m:1, a:1, desc:"For solo reviewers piloting AI-assisted coding.",
    feats:["10 notes per month","MDM scoring","ICD candidate suggestions","Email support"], cta:"Start free", variant:"ghost" },
  { tag:"Professional", m:79, a:63, desc:"For coding teams that need defensible recommendations.", feat:true,
    feats:["500 notes per month","Full audit trail export","CPT + ICD guidance","Reviewer collaboration","Priority support"], cta:"Choose plan", variant:"grad" },
  { tag:"Enterprise", m:149, a:119, desc:"For health systems running outpatient reviews at scale.",
    feats:["Unlimited notes","Custom MDM policies","SSO + audit log","Dedicated success manager"], cta:"Contact sales", variant:"dark" },
];
function Pricing({ go }){
  const [annual, setAnnual] = useH2S(false);
  return React.createElement("section",{ className:"section" },
    React.createElement("div",{ className:"wrap" },
      React.createElement(Reveal,null, React.createElement("h2",{ className:"h-sec" }, "Select the plan that fits your needs")),
      React.createElement(Reveal,{ delay:80 },
        React.createElement("div",{ className:"price-toggle" },
          React.createElement("button",{ className:annual?"":"on", onClick:()=>setAnnual(false) }, "Monthly"),
          React.createElement("button",{ className:annual?"on":"", onClick:()=>setAnnual(true) }, "Annual · save 20%"))),
      React.createElement("div",{ className:"price-grid" },
        PLANS.map((p,i)=>(
          React.createElement(Reveal,{ key:p.tag, delay:i*90 },
            React.createElement("div",{ className:`price-card ${p.feat?"feat":""}` },
              p.feat && React.createElement("div",{ className:"glow" }),
              React.createElement("div",{ className:"price-tag" }, p.tag),
              React.createElement("div",{ className:"price-amt" },
                React.createElement("b",null, "$", annual?p.a:p.m),
                React.createElement("span",null, "/ month")),
              React.createElement("p",{ className:"price-desc" }, p.desc),
              React.createElement("ul",{ className:"price-feats" },
                p.feats.map(f=>React.createElement("li",{ key:f },
                  React.createElement("span",{ className:"ck" }, React.createElement(I.check,{ size:12 })), f))),
              React.createElement(Button,{ variant:p.variant, icon:p.feat, onClick:()=>go("new"),
                style:{ width:"100%", justifyContent:"center" } }, p.cta)
            )))
        )
      )
    )
  );
}

/* ============ TESTIMONIALS ============ */
const TESTI = [
  { q:"We cut average review time from six minutes to under a minute. The evidence trail is what sold our compliance team.", n:"Dr. Amelia Sato", r:"Lead Reviewer, Crestwell Health", i:"AS" },
  { q:"Finally a tool that explains why a code was chosen. The CPT and ICD mappings hold up under audit.", n:"Marcus Liu", r:"Coding Director, NorthBay Clinics", i:"ML" },
  { q:"The pilot flow let us evaluate the platform with zero IT overhead. We were running real encounters by day two.", n:"Priya Natarajan", r:"Director of Revenue Integrity", i:"PN" },
  { q:"The audit-ready export dropped straight into our billing review. No reformatting, no guesswork.", n:"Dana Whitfield", r:"Revenue Cycle Lead, Meridian", i:"DW" },
  { q:"MDM scoring matched our senior coders on the cases we spot-checked. That earned a lot of trust fast.", n:"Sai Krishnan", r:"Compliance Analyst, Cedar Park", i:"SK" },
  { q:"It reads like a coder thinking out loud. New reviewers ramp far faster with the rationale attached.", n:"Renee Alvarez", r:"Coding Manager, Lakeside", i:"RA" },
];
function TCard({ t }){
  return React.createElement("div",{ className:"tcard float-2", style:{ animationDuration:`${8+Math.random()*4}s` } },
    React.createElement("span",{ className:"tq" }, React.createElement(I.quote,{ size:24 })),
    React.createElement("p",null, t.q),
    React.createElement("div",{ className:"tu" },
      React.createElement("div",{ className:"tav" }, t.i),
      React.createElement("div",{ className:"tn" }, React.createElement("b",null,t.n), React.createElement("span",null,t.r)))
  );
}
function Testimonials(){
  const cols=[[TESTI[0],TESTI[3]],[TESTI[1],TESTI[4]],[TESTI[2],TESTI[5]]];
  return React.createElement("section",{ className:"section" },
    React.createElement("div",{ className:"wrap" },
      React.createElement(Reveal,null, React.createElement("h2",{ className:"h-sec" }, "Success stories from our users")),
      React.createElement("div",{ className:"tcols" },
        cols.map((c,i)=>(
          React.createElement(Reveal,{ key:i, delay:i*100, className:"tcol" },
            c.map(t=>React.createElement(TCard,{ key:t.n, t })))))
      )
    )
  );
}

/* ============ FAQ ============ */
const FAQS = [
  { q:"What types of notes can MedCode analyze?", a:"Office and outpatient visit notes in plain text, PDF, or DOCX. The analyzer is tuned for the 99202–99215 CPT range and produces a full MDM breakdown across Problems, Data, and Risk." },
  { q:"How is the MDM level determined?", a:"Each encounter is scored across the three MDM elements against the 2021 E/M guidelines. The final level is set by the two of three elements that meet or exceed it — exactly the logic a human coder applies." },
  { q:"Does it replace a human coder?", a:"No. MedCode produces guidance-oriented output with a quoted evidence trail designed to accelerate human review and standardize rationale — not to bill autonomously." },
  { q:"Can we plug in our own model provider?", a:"Yes. The model layer sits behind a backend adapter, so teams can swap or upgrade providers without rebuilding the workflow or the review surface." },
  { q:"What about PHI and security?", a:"Notes are processed transiently for this demo and never stored. Production deployments support SSO, full audit logging, configurable retention, and BAAs." },
];
function FAQ(){
  const [open,setOpen]=useH2S(0);
  return React.createElement("section",{ className:"section" },
    React.createElement("div",{ className:"wrap" },
      React.createElement(Reveal,null, React.createElement("h2",{ className:"h-sec" }, "What can this AI platform help me with?")),
      React.createElement("div",{ className:"faq" },
        FAQS.map(function(f,i){
          return React.createElement(Reveal,{ key:i, delay:i*50 },
            React.createElement("div",{ className:`faq-item ${open===i?"open":""}` },
              React.createElement("div",{ className:"faq-q", onClick:()=>setOpen(open===i?-1:i) },
                React.createElement("span",null,f.q),
                React.createElement("span",{ className:"fc" }, React.createElement(I.chevron,{ size:20 }))
              ),
              React.createElement("div",{ className:"faq-a", style:{ maxHeight: open===i?240:0 } },
                React.createElement("div",{ className:"faq-a-in" }, f.a)
              )
            )
          );
        })
      )
    )
  );
}

/* ============ CONTACT ============ */
function ContactViz(){
  return React.createElement("div",{ className:"cl-viz" },
    React.createElement("svg",{ width:"100%", height:200, viewBox:"0 0 300 200", style:{overflow:"visible"} },
      // orbits
      [54,84,112].map((r,i)=>React.createElement("circle",{ key:i, cx:90, cy:100, r, fill:"none", stroke:"#d8d2f3", strokeWidth:1, strokeDasharray:"2 5", style:{ animation:`spin ${20+i*8}s linear infinite`, transformOrigin:"90px 100px" } })),
      React.createElement("circle",{ cx:90, cy:100, r:26, fill:"#16182a" }),
      // agent nodes
      [[90,46],[202,100],[90,154],[40,60]].map((p,i)=>React.createElement("g",{ key:i },
        React.createElement("circle",{ cx:p[0], cy:p[1], r:13, fill:"#fff", stroke:"#e2e0ef" }),
        React.createElement("circle",{ cx:p[0], cy:p[1], r:13, fill:"none", stroke:"#8b7ee6", strokeWidth:1.5, opacity:.0 },
          React.createElement("animate",{ attributeName:"opacity", values:"0;.8;0", dur:"2.4s", begin:`${i*.5}s`, repeatCount:"indefinite" }),
          React.createElement("animate",{ attributeName:"r", values:"13;20;13", dur:"2.4s", begin:`${i*.5}s`, repeatCount:"indefinite" }))
      ))
    ),
    React.createElement("svg",{ width:24, height:24, viewBox:"0 0 24 24", style:{ position:"absolute", left:78, top:88, color:"#cfc7f2" }, fill:"none", stroke:"currentColor", strokeWidth:1.6 },
      React.createElement("path",{ d:"M9 4a3 3 0 00-3 3 3 3 0 00-1 5 3 3 0 002 5 3 3 0 005 0V4M15 4a3 3 0 013 3 3 3 0 011 5 3 3 0 01-2 5", strokeLinecap:"round", strokeLinejoin:"round" }))
  );
}
function Contact(){
  const [form,setForm]=useH2S({ name:"", email:"", msg:"" });
  const [sent,setSent]=useH2S(false);
  const [err,setErr]=useH2S({});
  const submit=(e)=>{ e.preventDefault();
    const er={}; if(!form.name.trim()) er.name=1; if(!/^\S+@\S+\.\S+$/.test(form.email)) er.email=1;
    setErr(er); if(Object.keys(er).length) return; setSent(true);
  };
  return React.createElement("section",{ className:"section" },
    React.createElement("div",{ className:"wrap" },
      React.createElement(Reveal,{ scale:true },
        React.createElement("div",{ className:"contact-card" },
          React.createElement("div",{ className:"contact-l" },
            React.createElement("h3",null,"Built for teams that want scalable AI workflows"),
            React.createElement("p",null,"Ask about pilots, workflows, or coding review needs. Share evaluation needs around outpatient coding automation, MDM review support, CPT/ICD guidance, or audit-ready workflows."),
            React.createElement(ContactViz,null)),
          React.createElement("form",{ className:"contact-r", onSubmit:submit },
            React.createElement("div",{ className:"qc" }, "Quick contact"),
            sent
              ? React.createElement("div",{ className:"success-pop" }, React.createElement(I.check,{ size:18 }), "Thanks — we'll be in touch shortly.")
              : React.createElement(React.Fragment,null,
                  React.createElement("input",{ className:"field", placeholder:"Your name", value:form.name,
                    onChange:e=>setForm({...form,name:e.target.value}), style:err.name?{borderColor:"#e08a8a"}:undefined }),
                  React.createElement("input",{ className:"field", placeholder:"Work email", value:form.email,
                    onChange:e=>setForm({...form,email:e.target.value}), style:err.email?{borderColor:"#e08a8a"}:undefined }),
                  React.createElement("textarea",{ className:"field", rows:4, placeholder:"Tell us about your coding review needs", value:form.msg,
                    onChange:e=>setForm({...form,msg:e.target.value}) }),
                  React.createElement(Button,{ variant:"dark", icon:false, style:{ width:"100%", justifyContent:"center" } }, "Send message"))
          ))
      )
    )
  );
}

/* ============ FOOTER ============ */
function Footer({ go }){
  const [email,setEmail]=useH2S(""); const [ok,setOk]=useH2S(false);
  return React.createElement("footer",{ className:"footer" },
    React.createElement("div",{ className:"wrap" },
      React.createElement("div",{ style:{ display:"flex", justifyContent:"space-between", flexWrap:"wrap", gap:24, alignItems:"center", paddingBottom:46, borderBottom:"1px solid var(--line)", marginBottom:46 } },
        React.createElement("div",null,
          React.createElement("h4",{ style:{ fontSize:20, fontWeight:600, margin:0, letterSpacing:"-.01em" } }, "Get coding-automation tips in your inbox"),
          React.createElement("p",{ style:{ fontSize:14, color:"var(--muted)", margin:"6px 0 0" } }, "Structured outpatient coding guidance, transparent MDM scoring, and audit-ready rationale.")),
        React.createElement("form",{ className:"news", onSubmit:e=>{e.preventDefault(); if(/^\S+@\S+\.\S+$/.test(email)) setOk(true);} },
          ok ? React.createElement("div",{ className:"success-pop" }, React.createElement(I.check,{size:16}), "Subscribed")
            : React.createElement(React.Fragment,null,
                React.createElement("input",{ className:"field", placeholder:"you@clinic.com", value:email, onChange:e=>setEmail(e.target.value) }),
                React.createElement(Button,{ variant:"grad" }, "Subscribe")))
      ),
      React.createElement("div",{ className:"foot-grid" },
        React.createElement("div",{ className:"foot-brand" },
          React.createElement("div",{ className:"brand" }, React.createElement(Logo,null), React.createElement("span",null,"MedCode")),
          React.createElement("p",null,"MedCode delivers structured outpatient coding guidance with transparent MDM scoring, CPT recommendations, and audit-ready rationale.")),
        React.createElement("div",{ className:"foot-col" },
          React.createElement("h5",null,"Product"),
          [["Product overview","product"],["Note Analyzer","new"],["Pricing","home"]].map(l=>React.createElement("a",{ key:l[0], onClick:()=>go(l[1]) }, l[0]))),
        React.createElement("div",{ className:"foot-col" },
          React.createElement("h5",null,"Company"),
          [["Solutions","solutions"],["Security","security"],["Blog","blog"],["Contact","contact"]].map(l=>React.createElement("a",{ key:l[0], onClick:()=>go(l[1]) }, l[0]))),
        React.createElement("div",{ className:"foot-col" },
          React.createElement("h5",null,"Contact"),
          React.createElement("a",{ onClick:()=>go("contact") },"+1 (833) 323-0371"),
          React.createElement("a",{ onClick:()=>go("contact") },"hello@medcode.io"),
          React.createElement("p",{ style:{ fontSize:13, color:"var(--muted)", lineHeight:1.5, marginTop:4 } }, "Built for teams reviewing outpatient documentation at scale."))
      ),
      React.createElement("div",{ className:"foot-bottom" }, "© 2026 MedCode. Built for outpatient coding teams.")
    )
  );
}

Object.assign(window, { Integrations, Pricing, Testimonials, FAQ, Contact, Footer });
