1import{j as e}from"./index-C_Fqshtm.js";import{d as Et,u as At,r as p,R as Dt}from"./router-BXL9ASSk.js";import{a as b}from"./index-BqDtoUCL.js";import{P as zt}from"./PetitionSearch-Ddt07jA8.js";import"./vendor-BNcAc9ko.js";(function(){try{var u=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};u.SENTRY_RELEASE={id:"[email protected]"}}catch{}})();try{(function(){var u=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},A=new u.Error().stack;A&&(u._sentryDebugIds=u._sentryDebugIds||{},u._sentryDebugIds[A]="935f0ef2-249b-4ff7-8ccd-e486f07a8f8e",u._sentryDebugIdIdentifier="sentry-dbid-935f0ef2-249b-4ff7-8ccd-e486f07a8f8e")})()}catch{}const _="/api/v1/admin/ab-testing",S=()=>({headers:{Authorization:`Bearer ${localStorage.getItem("auth_token")}`}}),Tt=[{key:"impression",label:"Impressions",color:"#3B82F6"},{key:"tier_select",label:"Tier Select",color:"#8B5CF6"},{key:"checkout_step",label:"Checkout",color:"#F59E0B"},{key:"payment_method_select",label:"Method Select",color:"#10B981"},{key:"payment_success",label:"Success",color:"#059669"},{key:"payment_failed",label:"Failed",color:"#EF4444"}],ue={draft:{bg:"#F3F4F6",text:"#374151",border:"#D1D5DB"},active:{bg:"#D1FAE5",text:"#065F46",border:"#6EE7B7"},paused:{bg:"#FEF3C7",text:"#92400E",border:"#FCD34D"},completed:{bg:"#DBEAFE",text:"#1E40AF",border:"#93C5FD"}},Pe={layout:"default",show_petition_image:!0,show_logo_banner:!1,show_payment_icons_above_tiers:!1,image_style:"full",tier_reverse_layout:!1,tier_display:"cards",tier_display_mode:"default",featured_badge_text:"Most popular",selected_tier_bg:"#cbe5f2",tier_reach_label:"Petition views",reach_display_mode:"default",default_tier:null,tier_order:null,pricing_template_id:null,hero_text_config_id:null,enable_monthly_option:!1,monthly_pricing_template_id:null,skip_boost_button:!1,monthly_display_style:"tabs",custom_amount_label:"ס××× ××ר",compact_card_form:!1,show_progress_bar:!1,progress_bar_position:"above_tabs",pay_button_shimmer:!1,high_payments_mode:"off",show_footer:!0},We={key:"title",text:"",font_size:28,font_weight:"bold",text_align:"left",visible:!0,color:null,line_height:1.2,margin_bottom:12,order:1},t={page:{minHeight:"100vh",background:"linear-gradient(135deg, #f0f9ff 0%, #e0e7ff 50%, #f0f9ff 100%)",fontFamily:"Inter, -apple-system, BlinkMacSystemFont, sans-serif"},header:{background:"white",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)",borderBottom:"3px solid #3B82F6",padding:"1.5rem 2rem"},headerInner:{maxWidth:"1200px",margin:"0 auto",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"1rem",flexWrap:"wrap"},backBtn:{background:"none",border:"1px solid #D1D5DB",borderRadius:"8px",padding:"8px 16px",cursor:"pointer",fontSize:"14px",color:"#374151",display:"flex",alignItems:"center",gap:"6px"},content:{maxWidth:"1200px",margin:"0 auto",padding:"2rem 1rem"},card:{background:"white",borderRadius:"12px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)",padding:"1.5rem",marginBottom:"1.5rem"},table:{width:"100%",borderCollapse:"collapse",fontSize:"14px"},th:{textAlign:"left",padding:"12px 16px",borderBottom:"2px solid #E5E7EB",fontWeight:600,color:"#374151",fontSize:"13px",textTransform:"uppercase",letterSpacing:"0.05em"},td:{padding:"12px 16px",borderBottom:"1px solid #F3F4F6",color:"#1F2937"},primaryBtn:{background:"#2563EB",color:"white",border:"none",borderRadius:"8px",padding:"10px 20px",fontSize:"14px",fontWeight:600,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"6px"},secondaryBtn:{background:"white",color:"#374151",border:"1px solid #D1D5DB",borderRadius:"8px",padding:"8px 16px",fontSize:"14px",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"6px"},dangerBtn:{background:"#FEE2E2",color:"#DC2626",border:"1px solid #FCA5A5",borderRadius:"8px",padding:"8px 16px",fontSize:"14px",cursor:"pointer"},successBtn:{background:"#D1FAE5",color:"#065F46",border:"1px solid #6EE7B7",borderRadius:"8px",padding:"8px 16px",fontSize:"14px",cursor:"pointer"},warningBtn:{background:"#FEF3C7",color:"#92400E",border:"1px solid #FCD34D",borderRadius:"8px",padding:"8px 16px",fontSize:"14px",cursor:"pointer"},badge:u=>({display:"inline-block",padding:"4px 12px",borderRadius:"9999px",fontSize:"12px",fontWeight:600,background:ue[u]?.bg||"#F3F4F6",color:ue[u]?.text||"#374151",border:`1px solid ${ue[u]?.border||"#D1D5DB"}`}),modal:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},modalContent:{background:"white",borderRadius:"16px",padding:"2rem",maxWidth:"600px",width:"100%",maxHeight:"80vh",overflowY:"auto",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"},input:{width:"100%",padding:"10px 14px",border:"1px solid #D1D5DB",borderRadius:"8px",fontSize:"14px",outline:"none",boxSizing:"border-box"},select:{width:"100%",padding:"10px 14px",border:"1px solid #D1D5DB",borderRadius:"8px",fontSize:"14px",outline:"none",boxSizing:"border-box",background:"white"},textarea:{width:"100%",padding:"10px 14px",border:"1px solid #D1D5DB",borderRadius:"8px",fontSize:"13px",fontFamily:"monospace",outline:"none",boxSizing:"border-box",minHeight:"120px",resize:"vertical"},label:{display:"block",fontSize:"13px",fontWeight:600,color:"#374151",marginBottom:"6px"}
1,formGroup:{marginBottom:"16px"},tabs:{display:"flex",gap:"4px",marginBottom:"1.5rem",background:"#F3F4F6",borderRadius:"10px",padding:"4px"},tab:u=>({padding:"10px 20px",border:"none",borderRadius:"8px",cursor:"pointer",fontSize:"14px",fontWeight:u?600:400,background:u?"white":"transparent",color:u?"#2563EB":"#6B7280",boxShadow:u?"0 1px 3px rgba(0,0,0,0.1)":"none",transition:"all 0.2s"})},It=u=>{const A=new Set(u.map(B=>B.variant.variant_key.toUpperCase()));for(let B=0;B<26;B++){const $=String.fromCharCode(65+B);if(!A.has($))return $}return""},$e=u=>`${u.getFullYear()}-${String(u.getMonth()+1).padStart(2,"0")}-${String(u.getDate()).padStart(2,"0")}`,Nt=()=>{const{experimentId:u}=Et(),A=At(),[B,$]=p.useState("experiments"),[G,Le]=p.useState([]),[g,me]=p.useState(null),[P,fe]=p.useState([]),[se,Ne]=p.useState([]),[je,Me]=p.useState([]),[ve,Z]=p.useState(!0),[_e,le]=p.useState(null),[E,Ve]=p.useState(null),[q,Je]=p.useState(!1),[He,re]=p.useState(!1),[be,Se]=p.useState(""),[we,Ce]=p.useState(!1),[k,Oe]=p.useState(null),[L,Ge]=p.useState(()=>{const i=new Date;return i.setDate(i.getDate()-30),$e(i)}),[N,Ue]=p.useState(()=>$e(new Date)),[f,Fe]=p.useState(null),[ke,Be]=p.useState(!1),[Ke,W]=p.useState(!1),[Xe,M]=p.useState(!1),[Ye,V]=p.useState(!1),[oe,U]=p.useState(null),[ae,Q]=p.useState(null),[Ee,de]=p.useState(null),[ce,ee]=p.useState(null),[Ze,qe]=p.useState(!1),[Ae,De]=p.useState(!1),[J,ze]=p.useState(!1),[Te,Qe]=p.useState("cta"),[K,et]=p.useState(null),[H,tt]=p.useState(null),[j,T]=p.useState({name:"",description:"",scope:"global",petition_id:"",traffic_percentage:100}),[it,te]=p.useState(null),[w,I]=p.useState({name:"",variant_key:"",weight:50,is_control:!1,config:JSON.stringify(Pe,null,2)}),[F,O]=p.useState({name:"",text_blocks:JSON.stringify([We],null,2),is_active:!0}),X=p.useCallback(async()=>{try{const{data:i}=await b.get(`${_}
1/experiments`,S());i.success&&(Le(i.experiments),le(null))}catch{le("Failed to load experiments")}},[]),z=p.useCallback(async i=>{try{Z(!0);const{data:s}=await b.get(`${_}/experiments/${i}`,S());s.success&&(me(s.experiment),fe(s.variant_results),window.scrollTo(0,0))}catch{le("Failed to load experiment detail")}finally{Z(!1)}},[]),Y=p.useCallback(async()=>{try{const{data:i}=await b.get(`${_}/text-configs`,S());i.success&&Ne(i.text_configs)}catch{console.warn("Failed to load text configs")}},[]),Ie=p.useCallback(async()=>{try{const{data:i}=await b.get(`${_}/pricing-templates`,S());i.success&&Me(i.templates)}catch{console.warn("Failed to load pricing templates")}},[]),nt=p.useCallback(async()=>{if(k)try{Be(!0);const i=new URLSearchParams;L&&i.set("from",L),N&&i.set("to",N);const{data:s}=await b.get(`${_}/experiments/${k}/report?${i.toString()}`,S());s.success&&Fe(s)}catch(i){console.error("Report error:",i),alert("Failed to generate report: "+(i instanceof Error?i.message:String(i)))}finally{Be(!1)}},[k,L,N]),ie=p.useCallback(async()=>{try{const{data:i}=await b.get(`${_}/default-config`,S());i.success&&i.default_config&&Ve(i.default_config)}catch{console.warn("Failed to load default config")}},[]),Re=p.useCallback(async()=>{try{const{data:i}=await b.get(`${_}/preview-petition`,S());i.slug&&(et(i.slug),tt(i.title||null))}catch{console.warn("Failed to load preview petition")}},[]),st=async()=>{try{const i=JSON.parse(be);Ce(!0);const{data:s}=await b.put(`${_}/default-config`,{config:i},S());s.success&&(await ie(),re(!1))}catch{alert("Invalid JSON or failed to save")}finally{Ce(!1)}},lt=async(i,s)=>{if(confirm("Apply this variant config as the default?"))try{const{data:y}=await b.post(`${_}/experiments/${i}
1/apply-default`,{variant_id:s},S());y.success&&(alert(y.message),await ie())}catch{alert("Failed to apply default")}};p.useEffect(()=>{window.scrollTo(0,0),(async()=>{Z(!0),await Promise.all([X(),Y(),Ie(),ie(),Re()]),Z(!1)})()},[X,Y,Ie,ie,Re]),p.useEffect(()=>{u?z(parseInt(u,10)):(me(null),fe([]))},[u,z]);const rt=async()=>{try{const i={name:j.name,description:j.description||null,scope:j.scope,traffic_percentage:j.traffic_percentage};j.scope==="petition"&&j.petition_id&&(i.petition_id=parseInt(j.petition_id,10));const{data:s}=await b.post(`${_}/experiments`,i,S());if(s.success){const y=s.experiment?.id;if(Ee&&y)try{await Promise.all(Ee.map(n=>b.post(`${_}/experiments/${y}/variants`,{name:n.name,variant_key:n.variant_key,weight:n.weight,is_control:n.is_control,config:n.config},S())))}catch{alert("Experiment created, but duplicating one or more variants failed â please review and add them manually.")}else if(!E?.config)alert("Experiment created, but the Default Config is not loaded yet â the Control variant was not created. Please add it manually.");else if(y)try{await b.post(`${_}/experiments/${y}/variants`,{name:"Control",variant_key:`control_default_${y}`,weight:50,is_control:!0,config:E.config},S())}catch{alert("Experiment created, but creating the Control variant failed â please add it manually.")}de(null),W(!1),pe(),await X()}else alert("Failed to create experiment")}catch{alert("Error creating experiment")}},ot=async i=>{try{const{data:s}=await b.get(`${_}
1/experiments/${i.id}`,S());if(!s.success){alert("Failed to load experiment for duplication");return}const y=(s.variant_results??[]).map(n=>n.variant);de(y),T({name:`Copy of ${i.name}`,description:i.description||"",scope:i.scope,petition_id:"",traffic_percentage:i.traffic_percentage}),te(null),U(null),W(!0)}catch{alert("Error loading experiment for duplication")}},at=async()=>{if(oe)try{const i={name:j.name,description:j.description||null,scope:j.scope,traffic_percentage:j.traffic_percentage};j.scope==="petition"&&j.petition_id&&(i.petition_id=parseInt(j.petition_id,10));const{data:s}=await b.put(`${_}/experiments/${oe.id}`,i,S());s.success&&(W(!1),U(null),pe(),await X(),u&&await z(parseInt(u,10)))}catch{alert("Error updating experiment")}},ne=async(i,s)=>{if(!(s==="completed"&&!confirm("Are you sure you want to complete this experiment? This cannot be undone.")))try{const{data:y}=await b.put(`${_}/experiments/${i}`,{status:s},S());y.success&&(await X(),u&&await z(parseInt(u,10)))}catch{alert("Error updating status")}},dt=async()=>{if(g)try{const i=JSON.parse(w.config),{data:s}=await b.post(`${_}/experiments/${g.id}/variants`,{name:w.name,variant_key:w.variant_key,weight:w.weight,is_control:w.is_control,config:i},S());s.success&&(M(!1),xe(),await z(g.id))}catch{alert("Invalid JSON config or error creating variant")}},ct=async()=>{if(!(!ae||!g))try{const i=JSON.parse(w.config),{data:s}=await b.put(`${_}/variants/${ae.id}`,{name:w.name,weight:w.weight,is_control:w.is_control,config:i},S());s.success&&(M(!1),Q(null),xe(),await z(g.id))}catch{alert("Invalid JSON config or error updating variant")}},pt=async i=>{if(confirm("Delete this variant?")&&g)try{const{data:s}=await b.delete(`${_}/variants/${i}`,S());s.success?await z(g.id):alert(s.message||"Failed to delete variant")}catch{alert("Error deleting variant")}},xt=i=>{window.open(`${_}/experiments/${i}/export`,"_blank")},ht=async()=>{if(!k)return;const i=new URLSearchParams;L&&i.append("from",L),N&&i.append("to",N);try{const s=localStorage.getItem("auth_token")||"",y=await fetch(`${_}/experiments/${k}/export-detailed?${i.toString()}`,{headers:{Authorization:`Bearer ${s}`}});if(!y.ok)throw new Error(`HTTP ${y.status}`);const n=await y.blob(),a=window.URL.createObjectURL(n),l=document.createElement("a");l.href=a,l.download=`ab_test_${k}_detailed.xlsx`,document.body.appendChild(l),l.click(),l.remove(),window.URL.revokeObjectURL(a)}catch(s){console.error("Export failed:",s),alert("Export failed â check console")}},yt=async i=>{if(confirm("Reset all events for this experiment? This cannot be undone."))try{const{data:s}=await b.post(`${_}/experiments/${i}/reset-events`,{},S());s.success&&(alert(s.message),await z(i))}catch{alert("Error resetting events")}},gt=async()=>{try{const i=JSON.parse(F.text_blocks),{data:s}=await b.post(`${_}/text-configs`,{name:F.name,text_blocks:i,is_active:F.is_active},S());s.success&&(V(!1),he(),await Y())}catch{alert("Invalid JSON or error creating text config")}},ut=async()=>{if(ce)try{const i=JSON.parse(F.text_blocks),{data:s}=await b.put(`${_}/text-configs/${ce.id}`,{name:F.name,text_blocks:i,is_active:F.is_active},S());s.success&&(V(!1),ee(null),he(),await Y())}catch{alert("Invalid JSON or error updating text config")}},pe=()=>{T({name:"",description:"",scope:"global",petition_id:"",traffic_percentage:100}),de(null),te(null)},xe=()=>{I({name:"",variant_key:"",weight:50,is_control:!1,config:JSON.stringify(Pe,null,2)})},he=()=>{O({name:"",text_blocks:JSON.stringify([We],null,2),is_active:!0})},mt=i=>{U(i),T({name:i.name,description:i.description||"",scope:i.scope,petition_id:i.petition_id?.toString()||"",traffic_percentage:i.traffic_percentage}),te(i.petition_id?{id:i.petition_id,title:`Petition #${i.petition_id}`,status:"â",signature_count:0}:null),W(!0)},ft=i=>{Q(i),I({name:i.name,variant_key:i.variant_key,weight:i.weight,is_control:i.is_control,config:JSON.stringify(i.config,null,2)}),M(!0)},jt=i=>{ee(i),O({name:i.name,text_blocks:JSON.stringify(i.text_blocks,null,2),is_active:i.is_active}),V(!0)},vt=i=>i.length===0?e.jsx("p",{style:{color:"#6B7280",fontStyle:"italic"},children:"No variants configured yet"}):e.jsx("div",{style:{display:"grid",gap:"2rem"},children:i.map(s=>{const y=Math.max(s.funnel.impression,s.funnel.tier_select,s.funnel.checkout_step,s.funnel.payment_method_select,s.funnel.payment_success,s.funnel.payment_failed,1);return e.jsxs("div",{style:{...t.card,marginBottom:0,border:s.variant.is_control?"2px solid #3B82F6":"1px solid #E5E7EB"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16
1px"},children:[e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:700,fontSize:"16px"},children:s.variant.name}),e.jsxs("span",{style:{marginLeft:"8px",color:"#6B7280",fontSize:"13px"},children:["(",s.variant.variant_key,")"]}),s.variant.is_control&&e.jsx("span",{style:{marginLeft:"8px",background:"#DBEAFE",color:"#1E40AF",padding:"2px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:600},children:"CONTROL"})]}),e.jsxs("div",{style:{display:"flex",gap:"16px",fontSize:"13px",color:"#6B7280"},children:[e.jsxs("span",{children:["Assignments: ",e.jsx("strong",{style:{color:"#1F2937"},children:s.assignments})]}),e.jsxs("span",{children:["Conv: ",e.jsxs("strong",{style:{color:"#059669"},children:[s.conversion_rate,"%"]})]}),e.jsxs("span",{children:["Revenue: ",e.jsxs("strong",{style:{color:"#1F2937"},children:["âª",s.total_revenue]})]}),e.jsxs("span",{children:["Avg: ",e.jsxs("strong",{style:{color:"#1F2937"},children:["âª",s.avg_payment]})]})]})]}),Tt.map(n=>{const a=s.funnel[n.key],l=y>0?a/y*100:0,v=s.funnel.impression>0?(a/s.funnel.impression*100).toFixed(1):"0";return e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"8px",gap:"12px"},children:[e.jsx("div",{style:{width:"120px",fontSize:"13px",color:"#374151",flexShrink:0},children:n.label}),e.jsx("div",{style:{flex:1,height:"24px",background:"#F3F4F6",borderRadius:"6px",overflow:"hidden",position:"relative"},children:e.jsx("div",{style:{height:"100%",width:`${Math.max(l,a>0?2:0)}%`,background:n.color,borderRadius:"6px",transition:"width 0.5s ease"}})}),e.jsxs("div",{style:{width:"100px",fontSize:"13px",textAlign:"right",color:"#1F2937",flexShrink:0},children:[e.jsx("strong",{children:a})," ",e.jsxs("span",{style:{color:"#9CA3AF"},children:["(",v,"%)"]})]})]},n.key)})]},s.variant.id)})}),_t=()=>g?e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:"1.5rem"},children:e.jsx("button",{style:t.backBtn,onClick:()=>A("/admin/ab-testing"),children:"â Back to Experiments"})}),e.jsx("div",{style:t.card,children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",flexWrap:"wrap",gap:"1rem"},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{fontSize:"1.5rem",fontWeight:700,marginBottom:"8px"},children:g.name}),g.description&&e.jsx("p",{style:{color:"#6B7280",marginBottom:"8px"},children:g.description}),e.jsxs("div",{style:{display:"flex",gap:"12px",flexWrap:"wrap",fontSize:"13px",color:"#6B7280"},children:[e.jsx("span",{style:t.badge(g.status),children:g.status.toUpperCase()}),e.jsxs("span",{children:["Scope: ",e.jsx("strong",{children:g.scope})]}),g.petition_id&&e.jsxs("span",{children:["Petition: ",e.jsx("strong",{children:g.petition_title||`#${g.petition_id}`})]}),e.jsxs("span",{children:["Traffic: ",e.jsxs("strong",{children:[g.traffic_percentage,"%"]})]}),g.started_at&&e.jsxs("span",{children:["Started: ",new Date(g.started_at).toLocaleDateString()]})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap"},children:[g.status==="draft"&&e.jsx("button",{style:t.successBtn,onClick:()=>ne(g.id,"active"),children:"Activate"}),g.status==="active"&&e.jsx("button",{style:t.warningBtn,onClick:()=>ne(g.id,"paused"),children:"Pause"}),g.status==="paused"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{style:t.successBtn,onClick:()=>ne(g.id,"active"),children:"Resume"}),e.jsx("button",{style:t.dangerBtn,onClick:()=>ne(g.id,"completed"),children:"Complete"})]}),e.jsx("button",{style:t.secondaryBtn,onClick:()=>mt(g),children:"Edit"}),e.jsx("button",{style:t.secondaryBtn,onClick:()=>xt(g.id),children:"Export CSV"}),e.jsx("button",{style:t.dangerBtn,onClick:()=>yt(g.id),children:"Reset Events"})]})]})}),e.jsxs("div",{style:t.card,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1rem"},children:[e.jsx("h3",{style:{fontSize:"1.1rem",fontWeight:700},children:"Funnel by Variant"}),e.jsx("button",{style:t.primaryBtn,onClick:()=>{xe(),Q(null),I(i=>({...i,variant_key:It(P)})),M(!0)},children:"+ Add Variant"})]}),vt(P)]}),P.length>0&&e.jsxs("div",{style:t.card,children:[e.jsx("h3",{style:{fontSize:"1.1rem",fontWeight:700,marginBottom:"1rem"},children:"Conversion Comparison"}),e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:t.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.th,children:"Variant"}),e.jsx("th",{style:t.th,children:"Assignments"}),e.jsx("th",{style:t.th,children:"Impressions"}),e.jsx("th",{style:t.th,children:"Successes"}),e.jsx("th",{style:t.th,children:"Conv Rate"}),e.jsx("th",{style:t.th,children:"Revenue"}),e.jsx("th",{style:t.th,children:"Avg Payment"})]})}),e.jsx("tbody",{children:P.map(i=>e.jsxs("tr",{children:[e.jsxs("td",{style:t.td,children:[e.jsx("strong",{children:i.variant.name}),i.variant.is_control&&e.jsx("span",{style:{marginLeft:"6px",color:"#3B82F6",fontSize:"11px"},children:"(Control)"})]}),e.jsx("td",{style:t.td,children:i.assignments}),e.jsx("td",{style:t.td,children:i.funnel.impression}),e.jsx("td",{style:t.td,children:i.funnel.payment_success}),e.jsxs("td",{style:{...t.td,fontWeight:700,color:"#059669"},children:[i.conversion_rate,"%"]}
1),e.jsxs("td",{style:t.td,children:["âª",i.total_revenue]}),e.jsxs("td",{style:t.td,children:["âª",i.avg_payment]})]},i.variant.id))})]})})]}),e.jsxs("div",{style:t.card,children:[e.jsx("h3",{style:{fontSize:"1.1rem",fontWeight:700,marginBottom:"1rem"},children:"Variant Configuration"}),P.length===0?e.jsx("p",{style:{color:"#6B7280",fontStyle:"italic"},children:"No variants yet. Add one to start testing."}):e.jsx("div",{style:{display:"grid",gap:"12px"},children:P.map(i=>{const s=g.scope==="petition"&&g.petition_slug||K,y=g.scope==="petition"&&g.petition_title||H;return e.jsxs("div",{style:{border:"1px solid #E5E7EB",borderRadius:"8px",padding:"16px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"},children:[e.jsxs("div",{children:[e.jsx("strong",{children:i.variant.name}),e.jsxs("span",{style:{marginLeft:"8px",color:"#6B7280",fontSize:"12px"},children:["Key: ",i.variant.variant_key," | Weight: ",i.variant.weight," | v",i.variant.config_version]}),i.variant.is_control&&e.jsx("span",{style:{marginLeft:"8px",background:"#DBEAFE",color:"#1E40AF",padding:"2px 6px",borderRadius:"4px",fontSize:"11px"},children:"Control"})]}),e.jsxs("div",{style:{display:"flex",gap:"6px",alignItems:"center"},children:[s?e.jsx("a",{href:`/sign/${s}/hero?ab_force=${i.variant.variant_key}&ab_preview_key=AH-preview-2026`,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"13px",color:"#3B82F6",textDecoration:"none",padding:"8px 12px",border:"1px solid #BFDBFE",borderRadius:"8px",background:"#EFF6FF",cursor:"pointer"},children:"Preview"}):e.jsx("span",{style:{fontSize:"13px",color:"#9CA3AF",padding:"8px 12px",cursor:"not-allowed"},children:"Preview"}),e.jsx("button",{style:t.secondaryBtn,onClick:()=>ft(i.variant),children:"Edit"}),g.status==="draft"&&e.jsx("button",{style:t.dangerBtn,onClick:()=>pt(i.variant.id),children:"Delete"})]})]}),s&&y&&e.jsxs("div",{style:{fontSize:"11px",color:"#9CA3AF",marginBottom:"6px",textAlign:"right"},children:["Preview: ",y.length>30?y.substring(0,30)+"...":y]}),e.jsx("pre",{style:{background:"#F9FAFB",border:"1px solid #E5E7EB",borderRadius:"6px",padding:"10px",fontSize:"12px",fontFamily:"monospace",overflow:"auto",maxHeight:"150px",margin:0},children:JSON.stringify(i.variant.config,null,2)})]},i.variant.id)})})]})]}):null,bt=()=>e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1.5rem"},children:[e.jsx("h2",{style:{fontSize:"1.3rem",fontWeight:700},children:"All Experiments"}),e.jsx("button",{style:t.primaryBtn,onClick:()=>{pe(),U(null),W(!0)},children:"+ Create Experiment"})]}),G.length===0?e.jsxs("div",{style:{...t.card,textAlign:"center",padding:"3rem"},children:[e.jsx("h3",{style:{color:"#374151",marginBottom:"8px"},children:"No Experiments Yet"}),e.jsx("p",{style:{color:"#6B7280"},children:"Create your first A/B test to start optimizing conversions."})]}):e.jsx("div",{style:t.card,children:e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:t.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.th,children:"ID"}),e.jsx("th",{style:t.th,children:"Name"}),e.jsx("th",{style:t.th,children:"Status"}),e.jsx("th",{style:t.th,children:"Scope"}),e.jsx("th",{style:t.th,children:"Traffic"}),e.jsx("th",{style:t.th,children:"Variants"}),e.jsx("th",{style:t.th,children:"Assignments"}),e.jsx("th",{style:t.th,children:"Events"}),e.jsx("th",{style:t.th,children:"Conv Rate"}),e.jsx("th",{style:t.th,children:"Actions"})]})}),e.jsx("tbody",{children:G.map(i=>e.jsxs("tr",{style:{cursor:"pointer"},onClick:()=>A(`/admin/ab-testing/${i.id}`),onMouseEnter:s=>{s.currentTarget.style.background="#F9FAFB"},onMouseLeave:s=>{s.currentTarget.style.background="white"},children:[e.jsxs("td",{style:t.td,children:["#",i.id]}),e.jsx("td",{style:{...t.td,fontWeight:600},children:i.name}),e.jsx("td",{style:t.td,children:e.jsx("span",{style:t.badge(i.status),children:i.status})}),e.jsxs("td",{style:t.td,children:[i.scope,i.petition_id?` â ${i.petition_title||`#${i.petition_id}`}`:""]}),e.jsxs("td",{style:t.td,children:[i.traffic_percentage,"%"]}),e.jsx("td",{style:t.td,children:i.variants_count}),e.jsx("td",{style:t.td,children:i.assignments_count}),e.jsx("td",{style:t.td,children:i.total_events}),e.jsxs("td",{style:{...t.td,fontWeight:700,color:i.conversion_rate>0?"#059669":"#6B7280"},children:[i.conversion_rate,"%"]}),e.jsxs("td",{style:t.td,children:[e.jsx("button",{style:{...t.secondaryBtn,padding:"4px 12px",fontSize:"12px"},onClick:s=>{s.stopPropagation(),A(`/admin/ab-testing/${i.id}`)},children:"View"}),e.jsx("button",{style:{...t.secondaryBtn,padding:"4px 12px",fontSize:"12px",marginLeft:"8px"},onClick:s=>{s.stopPropagation(),ot(i)},children:"Duplicate"})]})]},i.id))})]})})})]}),St=()=>e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1.5rem"},children:[e.jsx("h2",{style:{fontSize:"1.3rem",fontWeight:700},children:"Hero Text Configs"}),e.jsx("button",{style:t.primaryBtn,onClick:()=>{he(),ee(null),V(!0)},children:"+ Create Text Config"})]}),se.length===0?e.jsxs("div",{style:{...t.card,textAlign:"center",padding:"3rem"},children:[e.jsx("h3",{style:{color:"#374151",marginBottom:"8px"},children:"No Text Configs"}),e.jsx("p",{style:{color:"#6B7280"},children:"Create text configurations for hero promotion A/B testing."})]}):e.jsx("div",{style:{display:"grid",gap:"12px"},children:se.map(i=>e.jsxs("div",{style:t.card,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[e.jsxs("div",{children:[e.jsx("strong",{style:{fontSize:"16px"},children:i.name}),e.jsx("span",{style:{marginLeft:"12px",...t.badge(i.is_active?"active":"draft")},children:i.is_active?"Active":"Inactive"}),i.is_primary&&e.jsx("span",{style:{marginLeft:"8px",display:"inline-block",padding:"4px 12px",borderRadius:"9999px",fontSize:"12px",fontWeight:600,background:"#DBEAFE",color:"#1E40AF",border:"1px solid #93C5FD"},children:"Primary"}),e.jsxs("span",{style:{marginLeft:"12px",color:"#6B7280",fontSize:"12px"},children:["ID: ",i.id," | Blocks: ",i.text_blocks?.length||0]})]}),e.jsxs("div",{style:{display:"flex",gap:"6px"},children:[!i.is_primary&&e.jsx("button",{style:{...t.secondaryBtn,fontSize:"12px",padding:"6px 12px"},onClick:async()=>{try{const{data:s}=await b.put(`${_}/text-configs/${i.id}`,{is_primary:!0},S());s.success&&await Y()}catch{alert("Failed to set as primary")}},children:"Set as Primary"}),e.jsx("button",{style:t.secondaryBtn,onClick:()=>jt(i),children:"Edit"})]})]}),e.jsx("div",{style:{display:"grid",gap:"6px"},children:(i.text_blocks||[]).map((s,y)=>e.jsxs("div",{style:{display:"flex",gap:"12px",alignItems:"center",padding:"8px 12px",background:s.visible?"#F9FAFB":"#FEF2F2",borderRadius:"6px",fontSize:"13px"},children:[e.jsx("span",{style:{fontWeight:600,width:"80px",color:"#374151"},children:s.key}),e.jsx("span",{style:{flex:1,color:"#1F2937"},children:s.text||"(empty)"}
1),e.jsxs("span",{style:{color:"#9CA3AF",fontSize:"11px"},children:[s.font_size,"px / ",s.font_weight,!s.visible&&e.jsx("span",{style:{color:"#EF4444",marginLeft:"4px"},children:"Hidden"})]})]},y))})]},i.id))}),e.jsxs("div",{style:{...t.card,marginTop:"1.5rem",background:"#FFFBEB"},children:[e.jsx("h4",{style:{fontWeight:700,marginBottom:"8px",color:"#92400E"},children:"Text Block Reference"}),e.jsxs("div",{style:{fontSize:"13px",color:"#78716C"},children:[e.jsxs("p",{style:{marginBottom:"6px"},children:[e.jsx("strong",{children:"Available keys:"})," title, subtitle, description, secondary, cta, urgency"]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Tokens:"})," ","{petition_title}",", ","{first_name}",", ","{petition_signatures}",", ","{petition_target}",", ","{progress_percentage}",", ","{remaining_signatures}"]})]})]})]}),wt=()=>{if(!Ke)return null;const i=!!oe;return e.jsx("div",{style:t.modal,onClick:()=>W(!1),children:e.jsxs("div",{style:t.modalContent,onClick:s=>s.stopPropagation(),children:[e.jsx("h2",{style:{fontSize:"1.3rem",fontWeight:700,marginBottom:"1.5rem"},children:i?"Edit Experiment":"Create Experiment"}),e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"Name *"}),e.jsx("input",{style:t.input,value:j.name,onChange:s=>T({...j,name:s.target.value}),placeholder:"e.g. Hero Page Layout Test"})]}),e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"Description"}),e.jsx("input",{style:t.input,value:j.description,onChange:s=>T({...j,description:s.target.value}),placeholder:"What are we testing?"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"Scope *"}),e.jsxs("select",{style:t.select,value:j.scope,onChange:s=>T({...j,scope:s.target.value}),children:[e.jsx("option",{value:"global",children:"Global"}),e.jsx("option",{value:"petition",children:"Petition-specific"})]})]}),e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"Traffic %"}),e.jsx("input",{style:t.input,type:"number",min:1,max:100,value:j.traffic_percentage,onChange:s=>T({...j,traffic_percentage:parseInt(s.target.value,10)||100})})]})]}),j.scope==="petition"&&e.jsx("div",{style:t.formGroup,children:e.jsx(zt,{selected:it,onSelect:s=>{te(s),T({...j,petition_id:s?String(s.id):""})}})}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"flex-end",marginTop:"1.5rem"},children:[e.jsx("button",{style:t.secondaryBtn,onClick:()=>{W(!1),U(null)},children:"Cancel"}),e.jsx("button",{style:t.primaryBtn,onClick:i?at:rt,disabled:!j.name,children:i?"Update":"Create"})]})]})})},ye=(i,s,y,n,a)=>{let l={},v=!1;try{l=JSON.parse(i)}catch{v=!0}const d=(r,R)=>{const ge={...l,[r]:R};s(JSON.stringify(ge,null,2))},D={marginBottom:"12px",padding:"12px",background:"#F8FAFC",borderRadius:"8px",border:"1px solid #E2E8F0"},C={fontSize:"12px",fontWeight:700,color:"#1E40AF",marginBottom:"6px",textTransform:"uppercase",letterSpacing:"0.05em"},c={display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 0",borderBottom:"1px solid #F1F5F9"},x={fontSize:"14px",fontWeight:500,color:"#374151"},o={fontSize:"12px",color:"#9CA3AF",marginTop:"1px"},m=(r,R)=>e.jsx("div",{onClick:a?void 0:R,style:{width:"40px",height:"22px",borderRadius:"11px",cursor:a?"default":"pointer",background:r?"#3B82F6":"#D1D5DB",position:"relative",flexShrink:0,marginLeft:"12px",transition:"background 0.2s",opacity:a?.6:1},children:e.jsx("div",{style:{width:"18px",height:"18px",borderRadius:"50%",background:"white",position:"absolute",top:"2px",left:r?"20px":"2px",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})}),h={...t.input,width:"150px",padding:"6px 10px",background:a?"#F9FAFB":"white"};return v?e.jsxs("div",{children:[e.jsx("div",{style:{padding:"8px 12px",background:"#FEF2F2",border:"1px solid #FECACA",borderRadius:"6px",fontSize:"13px",color:"#991B1B",marginBottom:"8px"},children:"Invalid JSON â fix in raw editor below"}),e.jsx("textarea",{style:{...t.textarea,minHeight:"200px"},value:i,onChange:r=>s(r.target.value),readOnly:a})]}):e.jsxs("div",{children:[e.jsxs("div",{style:D,children:[e.jsx("div",{style:C,children:"Layout & Display"}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Layout"}),e.jsx("div",{style:o,children:"Page layout style"})]}),e.jsxs("select",{value:String(l.layout||"default"),onChange:r=>d("layout",r.target.value),disabled:a,style:h,children:[e.jsx("option",{value:"default",children:"Default"}),e.jsx("option",{value:"compact",children:"Compact"})]})]}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Show Petition Image"}),e.jsx("div",{style:o,children:"Display the petition image on the page"})]}),m(!!l.show_petition_image,()=>d("show_petition_image",!l.show_petition_image))]}),!!l.show_petition_image&&e.jsxs("div",{style:{...c,paddingLeft:"16px"},children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Image Style"}),e.jsx("div",{style:o,children:"How to display the petition image"})]}),e.jsxs("select",{value:String(l.image_style||"full"),onChange:r=>d("image_style",r.target.value),disabled:a,style:h,children:[e.jsx("option",{value:"full",children:"Full"}),e.jsx("option",{value:"banner",children:"Banner"}),e.jsx("option",{value:"none",children:"None"})]})]}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Show Logo Banner"}),e.jsx("div",{style:o,children:"Display the עצ××× logo at the top"})]}),m(!!l.show_logo_banner,()=>d("show_logo_banner",!l.show_logo_banner))]}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Payment Icons Above Tiers"}),e.jsx("div",{style:o,children:"Show payment method icons above the tier cards"})]}),m(!!l.show_payment_icons_above_tiers,()=>d("show_payment_icons_above_tiers",!l.show_payment_icons_above_tiers))]}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Rever
1se Tier Layout"}),e.jsx("div",{style:o,children:"Price on left, views on right"})]}),m(!!l.tier_reverse_layout,()=>d("tier_reverse_layout",!l.tier_reverse_layout))]}),e.jsxs("div",{style:c,children:[e.jsx("div",{style:x,children:"Skip Boost Button"}),m(!!l.skip_boost_button,()=>d("skip_boost_button",!l.skip_boost_button))]}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Tier Display Mode"}),e.jsx("div",{style:o,children:"How tiers are arranged on the page"})]}),e.jsxs("select",{value:String(l.tier_display_mode||"default"),onChange:r=>d("tier_display_mode",r.target.value),disabled:a,style:h,children:[e.jsx("option",{value:"default",children:"Default (stacked)"}),e.jsx("option",{value:"horizontal",children:"Horizontal (side-by-side)"})]})]}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Badge Text"}),e.jsx("div",{style:o,children:"Text shown on the default tier badge (e.g. Most Popular, Best Value)"})]}),e.jsx("input",{type:"text",value:l.featured_badge_text!=null?String(l.featured_badge_text):"Most popular",onChange:r=>d("featured_badge_text",r.target.value||"Most popular"),disabled:a,placeholder:"Most popular",style:{...t.input,width:"160px",padding:"6px 10px"}})]}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Selected Tier Background"}
1),e.jsx("div",{style:o,children:"Background color for selected tier card"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("input",{type:"text",value:l.selected_tier_bg!=null?String(l.selected_tier_bg):"#cbe5f2",onChange:r=>d("selected_tier_bg",r.target.value||"#cbe5f2"),disabled:a,placeholder:"#cbe5f2",style:{...t.input,width:"110px",padding:"6px 10px"}}),e.jsx("div",{style:{width:"28px",height:"28px",borderRadius:"6px",flexShrink:0,border:"1px solid #D1D5DB",background:String(l.selected_tier_bg||"#cbe5f2")}})]})]}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Tier Reach Label"}),e.jsx("div",{style:o,children:"Text shown after the reach number (e.g. Petition views, more exposure)"})]}),e.jsx("input",{type:"text",value:l.tier_reach_label!=null?String(l.tier_reach_label):"Petition views",onChange:r=>d("tier_reach_label",r.target.value||"Petition views"),disabled:a,placeholder:"Petition views",style:{...t.input,width:"160px",padding:"6px 10px"}})]}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Reach Display Mode"}),e.jsx("div",{style:o,children:"Where to show reach numbers: inside tier cards or below custom amount field"})]}),e.jsxs("select",{value:String(l.reach_display_mode||"default"),onChange:r=>d("reach_display_mode",r.target.value),disabled:a,style:h,children:[e.jsx("option",{value:"default",children:"Default (inside tier cards)"}),e.jsx("option",{value:"below_custom",children:"Below custom amount field"})]})]}),e.jsxs("div",{style:{...c,borderBottom:"none"},children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Custom Amount Label"}),e.jsx("div",{style:o,children:'Placeholder in custom amount field (default: "Other")'})]}),e.jsx("input",{type:"text",value:l.custom_amount_label!=null?String(l.custom_amount_label):"",onChange:r=>d("custom_amount_label",r.target.value||"ס××× ××ר"),disabled:a,placeholder:"Other",style:{...t.input,width:"160px",padding:"6px 10px"}})]}),e.jsxs("div",{style:c,children:[e.jsx("div",{style:x,children:"Compact Card Form"}),e.jsx("div",{style:o,children:"Hide country and ZIP fields from card payment form"}),m(!!l.compact_card_form,()=>d("compact_card_form",!l.compact_card_form))]})]}),e.jsxs("div",{style:D,children:[e.jsx("div",{style:C,children:"Payment Method Layout"}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"PayPal Position (One-time)"}),e.jsx("div",{style:o,children:"Where to show PayPal button in one-time payment mode"})]}),e.jsxs("select",{value:String(l.paypal_position_onetime||"default"),onChange:r=>d("paypal_position_onetime",r.target.value),disabled:a,style:{...h,width:"200px"},children:[e.jsx("option",{value:"default",children:"Default (above card form)"}),e.jsx("option",{value:"below_card",children:"Below card Pay button"})]})]}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"PayPal Position (Monthly)"}),e.jsx("div",{style:o,children:"Where to show PayPal button in monthly subscription mode"})]}),e.jsxs("select",{value:String(l.paypal_position_monthly||"default"),onChange:r=>d("paypal_position_monthly",r.target.value),disabled:a,style:{...h,width:"200px"},children:[e.jsx("option",{value:"default",children:"Default (above card form)"}),e.jsx("option",{value:"below_card",children:"Below card Pay button"})]})]}),e.jsxs("div",{style:c,children:[e.jsx("div",{style:x,children:"Show Progress Bar"}),e.jsx("div",{style:o,children:"Display petition progress bar (always ~85% full, dynamic goal)"}),m(!!l.show_progress_bar,()=>d("show_progress_bar",!l.show_progress_bar))]}),l.show_progress_bar&&e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Progress Bar Position"}),e.jsx("div",{style:o,children:"Where to render the progress bar"})]}),e.jsxs("select",{value:String(l.progress_bar_position||"above_tabs"),onChange:r=>d("progress_bar_position",r.target.value),disabled:a,style:{...h,width:"200px"},children:[e.jsx("option",{value:"above_tabs",children:"Above One-time/Monthly tabs"}),e.jsx("option",{value:"below_subtitle",children:"Below subtitle text"}),e.jsx("option",{value:"below_custom",children:"Below custom amount field"})]})]}),e.jsxs("div",{style:c,children:[e.jsx("div",{style:x,children:"Pay Button Shimmer"}),e.jsx("div",{style:o,children:"Animated shimmer sweeping across the Pay button"}),m(!!l.pay_button_shimmer,()=>d("pay_button_shimmer",!l.pay_button_shimmer))]}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"High-Value Payments"}),e.jsx("div",{style:o,children:"Inject high-value entries into recent supporters feed"})]}),e.jsxs("select",{value:String(l.high_payments_mode||"off"),onChange:r=>d("high_payments_mode",r.target.value),disabled:a,style:{...h,width:"260px"},children:[e.jsx("option",{value:"off",children:"Off"}),e.jsx("option",{value:"simulated",children:"Simulated (generated names, $50-$250)"}),e.jsx("option",{value:"top_real",children:"Top Real (highest actual payments)"})]})]}),e.jsxs("div",{style:{...c,borderBottom:"none"},children:[e.jsx("div",{style:x,children:"Show Footer"}),e.jsx("div",{style:o,children:"Display page footer (when hidden, legal text appears at bottom)"}),m(l.show_footer!==!1,()=>d("show_footer",l.show_footer===!1))]})]}),e.jsxs("div",{style:D,children:[e.jsx("div",{style:C,children:"Pricing & Text"}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Pricing Template"}),e.jsx("div",{style:o,children:"Which price tier set to use"})]}),e.jsxs("select",{value:l.pricing_template_id!=null?String(l.pricing_template_id):"",onCh
1ange:r=>d("pricing_template_id",r.target.value?parseInt(r.target.value,10):null),disabled:a,style:{...h,width:"200px"},children:[e.jsx("option",{value:"",children:"None (use default)"}),je.map(r=>e.jsxs("option",{value:String(r.id),children:[r.id," â ",r.name]},r.id))]})]}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Text Config"}),e.jsx("div",{style:o,children:"Pre-defined text block configuration"})]}),e.jsxs("select",{value:l.hero_text_config_id!=null?String(l.hero_text_config_id):"",onChange:r=>d("hero_text_config_id",r.target.value?parseInt(r.target.value,10):null),disabled:a,style:{...h,width:"200px"},children:[e.jsx("option",{value:"",children:"None (use default)"}),se.map(r=>e.jsxs("option",{value:String(r.id),children:[r.id," â ",r.name]},r.id))]})]}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Default Tier"}),e.jsx("div",{style:o,children:"Which tier is pre-selected on load"})]}),e.jsxs("select",{value:l.default_tier!=null?String(l.default_tier):"",onChange:r=>d("default_tier",r.target.value||null),disabled:a,style:{...h,width:"200px"},children:[e.jsx("option",{value:"",children:"None (no pre-selection)"}),e.jsx("option",{value:"lowest",children:"Lowest price"}),e.jsx("option",{value:"middle",children:"Middle price"}),e.jsx("option",{value:"highest",children:"Highest price"})]})]}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Tier Order"}),e.jsx("div",{style:o,children:"Custom display order (e.g. 2,3,1 or 3,1,2)"})]}),e.jsx("input",{type:"text",value:l.tier_order!=null?String(l.tier_order):"",onChange:r=>{const R=r.target.value.replace(/[^0-9,]/g,"");d("tier_order",R||null)},disabled:a,placeholder:"1,2,3 (default order)",style:{...t.input,width:"160px",padding:"6px 10px",borderColor:(()=>{const r=l.tier_order!=null?String(l.tier_order):"";return r?/^[0-9]+(,[0-9]+)*$/.test(r)?"#D1D5DB":"#EF4444":"#D1D5DB"})()}})]})]}),e.jsxs("div",{style:D,children:[e.jsx("div",{style:C,children:"Monthly Subscription"}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Enable Monthly Option"}),e.jsx("div",{style:o,children:"Show monthly/one-time toggle on the Hero page"})]}),m(!!l.enable_monthly_option,()=>d("enable_monthly_option",!l.enable_monthly_option))]}),!!l.enable_monthly_option&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Payment Methods"}),e.jsx("div",{style:o,children:"Which payment methods to show in monthly mode"})]}),e.jsxs("select",{value:String(l.monthly_payment_methods||"both"),onChange:r=>d("monthly_payment_methods",r.target.value),disabled:a,style:{...h,width:"200px"},children:[e.jsx("option",{value:"stripe_only",children:"Stripe (Card) Only"}),e.jsx("option",{value:"paypal_only",children:"PayPal Only"}),e.jsx("option",{value:"both",children:"Both (Stripe + PayPal)"})]})]}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Default Selected Tab"}),e.jsx("div",{style:o,children:"Which tab is pre-selected when page loads"})]}),e.jsxs("select",{value:String(l.default_payment_mode||"one_time"),onChange:r=>d("default_payment_mode",r.target.value),disabled:a,style:{...h,width:"200px"},children:[e.jsx("option",{value:"one_time",children:"One-time (default)"}),e.jsx("option",{value:"monthly",children:"Monthly"})]})]}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Monthly Pricing Template"}),e.jsx("div",{style:o,children:"Separate tiers for monthly (empty = same as one-time)"})]}),e.jsxs("select",{value:l.monthly_pricing_template_id!=null?String(l.monthly_pricing_template_id):"",onChange:r=>d("monthly_pricing_template_id",r.target.value?parseInt(r.target.value,10):null),disabled:a,style:{...h,width:"200px"},children:[e.jsx("option",{value:"",children:"None (use one-time tiers)"}),je.map(r=>e.jsxs("option",{value:String(r.id),children:[r.id," â ",r.name]},r.id))]})]}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Min Amount ($)"}),e.jsx("div",{style:o,children:"Minimum custom amount for monthly (min 5)"})]}),e.jsx("input",{type:"number",value:l.monthly_min_amount!=null?Number(l.monthly_min_amount):5,onChange:r=>d("monthly_min_amount",Math.max(5,Number(r.target.value))),disabled:a,min:5,style:{...t.input,width:"100px",padding:"6px 10px"}})]}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Max Amount ($)"}),e.jsx("div",{style:o,children:"Maximum custom amount for monthly (max 100)"})]}),e.jsx("input",{type:"number",value:l.monthly_max_amount!=null?Number(l.monthly_max_amount):100,onChange:r=>d("monthly_max_amount",Math.min(100,Number(r.target.value))),disabled:a,max:100,style:{...t.input,width:"100px",padding:"6px 10px"}})]}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Monthly Badge Text"}),e.jsx("div",{style:o,children:'Badge on Monthly toggle button (e.g. "Save 20%")'})]}),e.jsx("input",{type:"text",value:l.monthly_badge_text!=null?String(l.monthly_badge_text):"",onCh
1ange:r=>d("monthly_badge_text",r.target.value||null),disabled:a,placeholder:"None",style:{...t.input,width:"160px",padding:"6px 10px"}})]}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Monthly Display Style"}),e.jsx("div",{style:o,children:"How the one-time/monthly toggle is displayed"})]}),e.jsxs("select",{value:l.monthly_display_style||"tabs",onChange:r=>d("monthly_display_style",r.target.value),disabled:a,style:{...h,width:"200px"},children:[e.jsx("option",{value:"tabs",children:"Tabs (default)"}),e.jsx("option",{value:"minimal",children:"Minimal labels"}),e.jsx("option",{value:"toggle",children:"Toggle switch"}),e.jsx("option",{value:"inline_cta",children:"Inline CTA"}),e.jsx("option",{value:"pills",children:"Separated pills"})]})]}),e.jsxs("div",{style:c,children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Monthly Tab Heart Icon"}),e.jsx("div",{style:o,children:"Show â¤ï¸ emoji on the Monthly tab button"})]}),m(l.monthly_tab_show_heart!==!1,()=>d("monthly_tab_show_heart",l.monthly_tab_show_heart===!1))]}),e.jsxs("div",{style:{...c,borderBottom:"none"},children:[e.jsxs("div",{children:[e.jsx("div",{style:x,children:"Monthly CTA Text"}),e.jsx("div",{style:o,children:"CTA override â use $AMOUNT for selected amount"})]}),e.jsx("input",{type:"text",value:l.monthly_cta_text!=null?String(l.monthly_cta_text):"",onChange:r=>d("monthly_cta_text",r.target.value||null),disabled:a,placeholder:"Default",style:{...t.input,width:"200px",padding:"6px 10px"}})]})]})]}),e.jsxs("div",{style:{marginTop:"4px"},children:[e.jsxs("button",{onClick:()=>n(!y),type:"button",style:{background:"none",border:"none",cursor:"pointer",fontSize:"13px",color:"#6B7280",padding:"4px 0",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("span",{style:{fontSize:"10px"},children:y?"â¼":"â¶"}),"Raw JSON"]}),y&&e.jsx("textarea",{style:{...t.textarea,minHeight:"160px",marginTop:"4px"},value:i,onChange:r=>s(r.target.value),readOnly:a})]})]})},Ct=()=>{if(!Xe)return null;const i=!!ae;return e.jsx("div",{style:t.modal,onClick:()=>M(!1),children:e.jsxs("div",{style:t.modalContent,onClick:s=>s.stopPropagation(),children:[e.jsx("h2",{style:{fontSize:"1.3rem",fontWeight:700,marginBottom:"1.5rem"},children:i?"Edit Variant":"Add Variant"}),e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"Name *"}),e.jsx("input",{style:t.input,value:w.name,onChange:s=>I({...w,name:s.target.value}),placeholder:"e.g. Compact Layout"})]}),!i&&e.jsxs("div",{style:t.formGroup,children:[e.jsxs("label",{style:t.label,children:["Variant Key * ",e.jsx("span",{style:{fontWeight:400,color:"#9CA3AF"},children:"(max 10 chars)"})]}),e.jsx("input",{style:t.input,value:w.variant_key,onChange:s=>I({...w,variant_key:s.target.value.slice(0,10)}),placeholder:"e.g. A, B, compact"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"Weight (1-100)"}),e.jsx("input",{style:t.input,type:"number",min:1,max:100,value:w.weight,onChange:s=>I({...w,weight:parseInt(s.target.value,10)||50})})]}),e.jsx("div",{style:{...t.formGroup,display:"flex",alignItems:"center",paddingTop:"24px"},children:e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:w.is_control,onChange:s=>I({...w,is_control:s.target.checked})}),e.jsx("span",{style:{fontSize:"14px"},children:"Is Control"})]})})]}),e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"Config *"}),ye(w.config,s=>I({...w,config:s}),Ze,qe)]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"flex-end",marginTop:"1.5rem"},children:[e.jsx("button",{style:t.secondaryBtn,onClick:()=>{M(!1),Q(null)},children:"Cancel"}),e.jsx("button",{style:t.primaryBtn,onClick:i?ct:dt,disabled:!w.name||!i&&!w.variant_key,children:i?"Update":"Add"})]})]})})},Ft=()=>{let i=[],s=!1;try{const o=JSON.parse(F.text_blocks);Array.isArray(o)?i=o:s=!0}catch{s=!0}const y=o=>{O({...F,text_blocks:JSON.stringify(o,null,2)})},n=(o,m,h)=>{const r=i.map((R,ge)=>ge===o?{...R,[m]:h}:R);y(r)},a=o=>{y(i.filter((m,h)=>h!==o))},l=o=>{const m={title:{font_size:28,font_weight:"bold",line_height:1.2,margin_bottom:12},subtitle:{font_size:18,font_weight:"normal",line_height:1.4,margin_bottom:8},description:{font_size:16,font_weight:"normal",line_height:1.5,margin_bottom:12},secondary:{font_size:14,font_weight:"normal",line_height:1.5,margin_bottom:8},cta:{font_size:16,font_weight:"bold",line_height:1.3,margin_bottom:8},urgency:{font_size:14,font_weight:"bold",line_height:1.3,margin_bottom:8}},h=m[o]||m.description,r={key:o,text:"",font_size:h.font_size||16,font_weight:h.font_weight||"normal",text_align:"left",visible:!0,color:null,line_height:h.line_height||1.4,margin_bottom:h.margin_bottom||12,order:i.length+1};y([...i,r])}
1,v={title:"Title",subtitle:"Subtitle",description:"Description",secondary:"Secondary",cta:"CTA",urgency:"Urgency"},d=o=>["title","subtitle"].includes(o)?2:3,D=(o,m)=>e.jsx("div",{onClick:m,style:{width:"40px",height:"22px",borderRadius:"11px",cursor:"pointer",background:o?"#3B82F6":"#D1D5DB",position:"relative",flexShrink:0,transition:"background 0.2s"},children:e.jsx("div",{style:{width:"18px",height:"18px",borderRadius:"50%",background:"white",position:"absolute",top:"2px",left:o?"20px":"2px",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})}),C={fontSize:"13px",fontWeight:500,color:"#374151",minWidth:"90px"},c={...t.input,padding:"6px 10px",fontSize:"13px"},x={...t.input,padding:"6px 10px",fontSize:"13px",background:"white"};return s&&!J?e.jsxs("div",{children:[e.jsx("div",{style:{padding:"8px 12px",background:"#FEF2F2",border:"1px solid #FECACA",borderRadius:"6px",fontSize:"13px",color:"#991B1B",marginBottom:"8px"},children:"Invalid JSON â switch to Raw JSON below to fix"}),e.jsx("div",{style:{marginTop:"4px"},children:e.jsxs("button",{onClick:()=>ze(!0),type:"button",style:{background:"none",border:"none",cursor:"pointer",fontSize:"13px",color:"#6B7280",padding:"4px 0",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("span",{style:{fontSize:"10px"},children:"â¶"})," Raw JSON"]})})]}):e.jsxs("div",{children:[!J&&i.map((o,m)=>e.jsxs("div",{style:{background:o.visible?"white":"#F9FAFB",border:`1px solid ${o.visible?"#BFDBFE":"#E5E7EB"}`,borderLeft:`3px solid ${o.visible?"#3B82F6":"#D1D5DB"}`,borderRadius:"8px",padding:"12px 16px",marginBottom:"10px",opacity:o.visible?1:.7,transition:"all 0.2s"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:700,color:"#1E40AF"},children:v[o.key]||o.key}),e.jsxs("span",{style:{fontSize:"11px",color:"#9CA3AF",fontFamily:"monospace"},children:["(",o.key,")"]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx("span",{style:{fontSize:"12px",color:"#6B7280"},children:o.visible?"Visible":"Hidden"}),D(o.visible,()=>n(m,"visible",!o.visible)),e.jsx("button",{onClick:()=>a(m),type:"button",style:{background:"none",border:"none",cursor:"pointer",color:"#EF4444",fontSize:"18px",padding:"2px 6px",borderRadius:"4px",lineHeight:1},title:"Remove block",children:"Ã"})]})]}),o.visible&&e.jsxs("div",{style:{marginTop:"12px"},children:[e.jsxs("div",{style:{marginBottom:"10px"},children:[e.jsx("label",{style:C,children:"Text"}),e.jsx("textarea",{rows:d(o.key),style:{...t.input,fontFamily:"inherit",resize:"vertical",marginTop:"4px"},value:o.text,onChange:h=>n(m,"text",h.target.value),placeholder:`Enter ${(v[o.key]||o.key).toLowerCase()} text...`}),e.jsxs("div",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"2px"},children:["Tokens: ","{petition_title}"," ","{first_name}"," ","{petition_signatures}"," ","{petition_target}"]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px 16px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("label",{style:C,children:"Font Size"}),e.jsx("input",{type:"number",min:12,max:36,style:{...c,width:"70px"},value:o.font_size,onChange:h=>n(m,"font_size",parseInt(h.target.value)||16)})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("label",{style:C,children:"Weight"}),e.jsxs("select",{style:{...x,width:"100px"},value:o.font_weight,onChange:h=>n(m,"font_weight",h.target.value),children:[e.jsx("option",{value:"normal",children:"Normal"}),e.jsx("option",{value:"bold",children:"Bold"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("label",{style:C,children:"Align"}),e.jsxs("select",{style:{...x,width:"100px"},value:o.text_align||"left",onChange:h=>n(m,"text_align",h.target.value),children:[e.jsx("option",{value:"left",children:"Left"}),e.jsx("option",{value:"center",children:"Center"}),e.jsx("option",{value:"right",children:"Right"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("label",{style:C,children:"Color"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flex:1},children:[e.jsx("input",{style:{...c,flex:1},value:o.color||"",onChange:h=>n(m,"color",h.target.value||null),placeholder:"#6B7280"}),e.jsx("div",{style:{width:"24px",height:"24px",borderRadius:"4px",flexShrink:0,border:"1px solid #D1D5DB",background:o.color||"#000000"}})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("label",{style:C,children:"Line Height"}),e.jsx("input",{type:"number",min:1,max:2,step:.1,style:{...c,width:"70px"},value:o.line_height,onChange:h=>n(m,"line_height",parseFloat(h.target.value)||1.4)})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsxs("label",{style:C,children:["Margin ",e.jsx("span",{style:{fontSize:"11px"},children:"â"})]}),e.jsx("input",{type:"number",min:0,max:32,style:{...c,width:"70px"},value:o.margin_bottom,onChange:h=>n(m,"margin_bottom",parseInt(h.target.value)||0)}
1),e.jsx("span",{style:{fontSize:"12px",color:"#9CA3AF"},children:"px"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("label",{style:C,children:"Order"}),e.jsx("input",{type:"number",min:1,max:6,style:{...c,width:"70px"},value:o.order,onChange:h=>n(m,"order",parseInt(h.target.value)||1)})]})]})]})]},m)),!J&&e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px",alignItems:"center"},children:[e.jsxs("select",{value:Te,onChange:o=>Qe(o.target.value),style:{...x,width:"140px"},children:[e.jsx("option",{value:"title",children:"Title"}),e.jsx("option",{value:"subtitle",children:"Subtitle"}),e.jsx("option",{value:"description",children:"Description"}),e.jsx("option",{value:"secondary",children:"Secondary"}),e.jsx("option",{value:"cta",children:"CTA"}),e.jsx("option",{value:"urgency",children:"Urgency"})]}),e.jsx("button",{type:"button",onClick:()=>l(Te),style:{background:"white",color:"#2563EB",border:"1px dashed #93C5FD",borderRadius:"8px",padding:"8px 16px",fontSize:"13px",fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},children:"+ Add Text Block"})]}),e.jsxs("div",{style:{marginTop:"12px"},children:[e.jsxs("button",{onClick:()=>ze(!J),type:"button",style:{background:"none",border:"none",cursor:"pointer",fontSize:"13px",color:"#6B7280",padding:"4px 0",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("span",{style:{fontSize:"10px"},children:J?"â¼":"â¶"}),"Raw JSON"]}),J&&e.jsx("textarea",{style:{...t.textarea,minHeight:"200px",marginTop:"4px"},value:F.text_blocks,onChange:o=>O({...F,text_blocks:o.target.value})})]})]})},kt=()=>{if(!Ye)return null;const i=!!ce;return e.jsx("div",{style:t.modal,onClick:()=>V(!1),children:e.jsxs("div",{style:t.modalContent,onClick:s=>s.stopPropagation(),children:[e.jsx("h2",{style:{fontSize:"1.3rem",fontWeight:700,marginBottom:"1.5rem"},children:i?"Edit Text Config":"Create Text Config"}),e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"Name *"}),e.jsx("input",{style:t.input,value:F.name,onChange:s=>O({...F,name:s.target.value}),placeholder:"e.g. Urgency Focused Copy"})]}),e.jsx("div",{style:{...t.formGroup,display:"flex",alignItems:"center"},children:e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:F.is_active,onChange:s=>O({...F,is_active:s.target.checked})}),e.jsx("span",{style:{fontSize:"14px"},children:"Active"})]})}),e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"Text Blocks *"}),Ft()]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"flex-end",marginTop:"1.5rem"},children:[e.jsx("button",{style:t.secondaryBtn,onClick:()=>{V(!1),ee(null)},children:"Cancel"}),e.jsx("button",{style:t.primaryBtn,onClick:i?ut:gt,disabled:!F.name,children:i?"Update":"Create"})]})]})})},Bt=()=>{const i=f?.variants.find(n=>n.is_control),s=f?Math.max(...f.variants.map(n=>n.conversion_rate)):0,y=n=>{if(!f||!k||!G.find(v=>v.id===k))return null;const l=P.find(v=>v.variant.variant_key===n);return l?l.variant.id:null};return e.jsxs("div",{children:[e.jsx("h2",{style:{fontSize:"1.3rem",fontWeight:700,marginBottom:"1.5rem"},children:"Experiment Reports"}),e.jsx("div",{style:t.card,children:e.jsxs("div",{style:{display:"flex",gap:"16px",flexWrap:"wrap",alignItems:"flex-end"},children:[e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"Experiment"}),e.jsxs("select",{style:{...t.select,minWidth:"250px"},value:k??"",onChange:n=>{const a=n.target.value?parseInt(n.target.value,10):null;Oe(a),Fe(null),a&&z(a)},children:[e.jsx("option",{value:"",children:"-- Select Experiment --"}),G.map(n=>e.jsxs("option",{value:n.id,children:["#",n.id," - ",n.name," (",n.status,")"]},n.id))]})]}),e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"From"}),e.jsx("input",{style:t.input,type:"date",value:L,onChange:n=>Ge(n.target.value)})]}),e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"To"}),e.jsx("input",{style:t.input,type:"date",value:N,onChange:n=>Ue(n.target.value)})]}),e.jsx("div",{style:t.formGroup,children:e.jsx("button",{style:{...t.primaryBtn,opacity:k?1:.5},disabled:!k||ke,onClick:nt,children:ke?"Generating...":"Generate Report"})}),e.jsx("div",{style:t.formGroup,children:e.jsx("button",{style:{...t.secondaryBtn,opacity:k?1:.5,background:"#16a34a",color:"#fff",borderColor:"#16a34a"},disabled:!k,onClick:ht,children:"ð Export Detailed"})})]})}),f&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{...t.card,background:"#F0F9FF",borderLeft:"4px solid #3B82F6"},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:"12px"},children:[e.jsxs("div",{children:[e.jsx("h3",{style:{fontWeight:700,fontSize:"1.1rem",margin:0},children:f.experiment.name}),e.jsxs("span",{style:{fontSize:"13px",color:"#6B7280"},children:[f.date_range.from||"All time"," â ",f.date_range.to||"Now"," | ","Status: ",e.jsx("span",{style:t.badge(f.experiment.status),children:f.experiment.status})]})]}),e.jsxs("div",{style:{fontSize:"13px",color:"#6B7280"},children:[f.variants.length," variants"]})]})}),e.jsxs("div",{style:t.card,children:[e.jsx("h3",{style:{fontSize:"1.1rem",fontWeight:700,marginBottom:"1rem"},children:"Variant Performance"}),e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:t.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.th,children:"Variant"}),e.jsx("th",{style:t.th,children:"Control?"}),e.jsx("th",{style:t.th,children:"Impressions"}),e.jsx("th",{style:t.th,children:"Tier Select"}),e.jsx("th",{style:t.th,children:"Checkout"}),e.jsx("th",{style:t.th,children:"Method Select"}),e.jsx("th",{style:t.th,children:"Success"}),e.jsx("th",{style:t.th,children:"Failed"}),e.jsx("th",{style:t.th,children:"Conv %"}),e.jsx("th",{style:t.th,children:"Revenue"}),e.jsx("th",{style:t.th,children:"Avg Payment"}),e.jsx("th",{style:t.th,children:"Actions"})]})}),e.jsx("tbody",{children:f.variants.map(n=>{const a=n.conversion_rate===s&&s>0,l=n.by_payment_type||null,v=l&&l.recurring&&l.recurring.count>0;return e.jsxs(Dt.Fragment,{children:[e.jsxs("tr",{style:{background:a?"#F0FDF4":"white"},children:[e.jsxs("td",{style:t.td,children:[e.jsx("strong",{children:n.variant_key})," - ",n.name,a&&e.jsx("span",{style:{marginLeft:"8px",background:"#059669",color:"white",padding:"2px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:700},children:"WINNER"}),v&&e.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",color:"#6B7280"},children:"(Total)"})]}),e.jsx("td",{style:t.td,children:n.is_control?"â":"â"}),e.jsx("td",{style:t.td,children:n.impressions}),e.jsx("td",{style:t.td,children:n.tier_select}),e.jsx("td",{style:t.td,children:n.checkout_step}),e.jsx("td",{style:t.td,children:n.payment_method_select}),e.jsx("td",{style:{...t.td,fontWeight:700,color:"#059669"},children:n.payment_success}),e.jsx("td",{style:{...t.td,color:"#DC2626"},children:n.payment_failed}),e.jsxs("td",{style:{...t.td,fontWeight:700,color:a?"#059669":"#1F2937"},children:[n.conversion_rate,"%"]}),e.jsxs("td",{style:t.td,children:["âª",n.total_revenue.toFixed(2)]}),e.jsxs("td",{style:t.td,children:["âª",n.avg_payment.toFixed(2)]}),e.jsx("td",{style:t.td,children:f.experiment.status==="completed"&&e.jsx("button",{style:{...t.successBtn,padding:"4px 10px",fontSize:"12px"},onClick:()=>{const d=y(n.variant_key);d?lt(f.experiment.id,d):alert("Could not find variant ID. Please view the experiment detail first.")},children:"Apply as Default"})})]}),v&&l&&e.jsxs(e.Fragment,{children:[e.jsxs("tr",{style:{background:"#F9FAFB"},children:[e.jsx("td",{style:{...t.td,paddingLeft:"2rem",fontSize:"13px",color:"#6B7280"},children:"ð³ One-time"}),e.jsx("td",{style:t.td}
1),e.jsx("td",{style:{...t.td,color:"#9CA3AF"},children:"-"}),e.jsx("td",{style:{...t.td,color:"#9CA3AF"},children:"-"}),e.jsx("td",{style:{...t.td,color:"#9CA3AF"},children:"-"}),e.jsx("td",{style:{...t.td,color:"#9CA3AF"},children:"-"}),e.jsx("td",{style:{...t.td,fontWeight:600,color:"#059669"},children:l.one_time.count}),e.jsx("td",{style:t.td,children:"-"}),e.jsxs("td",{style:{...t.td,fontSize:"13px"},children:[l.one_time.conversion_rate,"%"]}),e.jsxs("td",{style:{...t.td,fontSize:"13px"},children:["âª",l.one_time.revenue.toFixed(2)]}),e.jsxs("td",{style:{...t.td,fontSize:"13px"},children:["âª",l.one_time.avg_payment.toFixed(2)]}),e.jsx("td",{style:t.td})]}),e.jsxs("tr",{style:{background:"#F0F9FF"},children:[e.jsx("td",{style:{...t.td,paddingLeft:"2rem",fontSize:"13px",color:"#6B7280"},children:"ð Recurring"}),e.jsx("td",{style:t.td}),e.jsx("td",{style:{...t.td,color:"#9CA3AF"},children:"-"}),e.jsx("td",{style:{...t.td,color:"#9CA3AF"},children:"-"}),e.jsx("td",{style:{...t.td,color:"#9CA3AF"},children:"-"}),e.jsx("td",{style:{...t.td,color:"#9CA3AF"},children:"-"}),e.jsx("td",{style:{...t.td,fontWeight:600,color:"#059669"},children:l.recurring.count}),e.jsx("td",{style:t.td,children:"-"}),e.jsxs("td",{style:{...t.td,fontSize:"13px"},children:[l.recurring.conversion_rate,"%"]}),e.jsxs("td",{style:{...t.td,fontSize:"13px"},children:["âª",l.recurring.revenue.toFixed(2)]}),e.jsxs("td",{style:{...t.td,fontSize:"13px"},children:["âª",l.recurring.avg_payment.toFixed(2)]}),e.jsx("td",{style:t.td})]})]})]},n.variant_key)})})]})})]}),f.daily&&f.daily.length>0&&e.jsxs("div",{style:t.card,children:[e.jsx("h3",{style:{fontSize:"1.1rem",fontWeight:700,marginBottom:"1rem"},children:"Daily Breakdown"}),e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:t.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.th,children:"Date"}),e.jsx("th",{style:t.th,children:"Variant"}),e.jsx("th",{style:t.th,children:"Impressions"}),e.jsx("th",{style:t.th,children:"Tier Select"}),e.jsx("th",{style:t.th,children:"Checkout"}),e.jsx("th",{style:t.th,children:"Method"}),e.jsx("th",{style:t.th,children:"Success"}),e.jsx("th",{style:t.th,children:"Failed"}),e.jsx("th",{style:t.th,children:"Conv %"}),e.jsx("th",{style:t.th,children:"Revenue"}),e.jsx("th",{style:t.th,children:"One-time"}),e.jsx("th",{style:t.th,children:"Recurring"})]})}),e.jsx("tbody",{children:f.daily.map((n,a)=>e.jsxs("tr",{style:{background:n.is_control?"#F0F9FF":"white",borderTop:a>0&&f.daily[a-1]?.date!==n.date?"3px solid #E5E7EB":void 0},children:[e.jsx("td",{style:{...t.td,fontWeight:a===0||f.daily[a-1]?.date!==n.date?700:400},children:a===0||f.daily[a-1]?.date!==n.date?n.date:""}),e.jsxs("td",{style:t.td,children:[e.jsx("strong",{children:n.variant_key}),n.is_control&&e.jsx("span",{style:{marginLeft:"4px",fontSize:"10px",color:"#3B82F6"},children:"â"})]}),e.jsx("td",{style:t.td,children:n.impressions}),e.jsx("td",{style:t.td,children:n.tier_select}),e.jsx("td",{style:t.td,children:n.checkout_step}),e.jsx("td",{style:t.td,children:n.payment_method_select}),e.jsx("td",{style:{...t.td,fontWeight:700,color:n.payment_success>0?"#059669":"#9CA3AF"},children:n.payment_success}),e.jsx("td",{style:{...t.td,color:n.payment_failed>0?"#DC2626":"#9CA3AF"},children:n.payment_failed}),e.jsxs("td",{style:{...t.td,fontWeight:600},children:[n.conv_pct,"%"]}),e.jsxs("td",{style:{...t.td,fontWeight:600},children:["âª",n.revenue.toFixed(2)]}),e.jsx("td",{style:{...t.td,fontSize:"12px"},children:n.onetime_count>0?`${n.onetime_count} (âª${n.onetime_revenue.toFixed(2)})`:"-"}),e.jsx("td",{style:{...t.td,fontSize:"12px",color:n.recurring_count>0?"#059669":"#9CA3AF"},children:n.recurring_count>0?`${n.recurring_count} (âª${n.recurring_revenue.toFixed(2)})`:"-"})]},a))})]})})]}),f.variants.some(n=>n.payment_failed>0)&&e.jsxs("div",{style:t.card,children:[e.jsx("h3",{style:{fontSize:"1.1rem",fontWeight:700,marginBottom:"1rem"},children:"Payment Failure Analysis"}),e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:t.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.th,children:"Variant"}),e.jsx("th",{style:t.th,children:"Total Failed"}),e.jsx("th",{style:t.th,children:"% of Total Attempts"})]})}),e.jsx("tbody",{children:f.variants.filter(n=>n.payment_failed>0).map(n=>{const a=n.payment_success+n.payment_failed,l=a>0?(n.payment_failed/a*100).toFixed(1):"0.0";return e.jsxs("tr",{style:{background:n.is_control?"#F0F9FF":"white"},children:[e.jsxs("td",{style:t.td,children:[e.jsx("strong",{children:n.variant_key})," - ",n.name,n.is_control&&e.jsx("span",{style:{marginLeft:"8px",background:"#DBEAFE",color:"#1E40AF",padding:"2px 6px",borderRadius:"4px",fontSize:"11px"},children:"Control"})]}),e.jsx("td",{style:{...t.td,color:"#DC2626",fontWeight:700},children:n.payment_failed}),e.jsxs("td",{style:{...t.td,fontWeight:600},children:[l,"%"]})]},n.variant_key)})})]})}),f.variants.some(n=>n.failure_breakdown&&n.failure_breakdown.length>0)&&e.jsxs("div",{style:{marginTop:"20px"},children:[e.jsx("h4",{style:{fontSize:"1rem",fontWeight:600,marginBottom:"12px"},children:"Error Code Breakdown"}),f.variants.filter(n=>n.failure_breakdown&&n.failure_breakdown.length>0).map(n=>
1e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsxs("div",{style:{fontWeight:600,fontSize:"13px",marginBottom:"6px"},children:[n.variant_key," - ",n.name,n.is_control&&e.jsx("span",{style:{marginLeft:"8px",background:"#DBEAFE",color:"#1E40AF",padding:"2px 6px",borderRadius:"4px",fontSize:"11px"},children:"Control"})]}),e.jsxs("table",{style:t.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.th,children:"Error Code"}),e.jsx("th",{style:t.th,children:"Count"}),e.jsx("th",{style:t.th,children:"Description"})]})}),e.jsx("tbody",{children:n.failure_breakdown.map(a=>{const l={card_declined:"Card declined by bank",insufficient_funds:"Insufficient funds",card_expired:"Card expired",incorrect_cvc:"Incorrect CVC",wallet_payment_failed:"Wallet payment failed",card_payment_failed:"Card payment failed"};return e.jsxs("tr",{children:[e.jsx("td",{style:{...t.td,fontFamily:"monospace",fontSize:"12px"},children:a.code}),e.jsx("td",{style:{...t.td,fontWeight:700,color:"#DC2626"},children:a.count}),e.jsx("td",{style:{...t.td,color:"#6B7280"},children:l[a.code]||a.code})]},a.code)})})]})]},n.variant_key))]}),!f.variants.some(n=>n.failure_breakdown&&n.failure_breakdown.length>0)&&e.jsx("p",{style:{marginTop:"12px",fontSize:"13px",color:"#6B7280",fontStyle:"italic"},children:"Error code breakdown available after 2026-03-27 (error_code tracking added on this date)"})]}),e.jsxs("div",{style:t.card,children:[e.jsx("h3",{style:{fontSize:"1.1rem",fontWeight:700,marginBottom:"1rem"},children:"Drop-off Analysis"}),e.jsx("div",{style:{display:"grid",gap:"16px"},children:f.variants.map(n=>{const a=[{key:"impression_to_tier",label:"Impression â Tier Select"},{key:"tier_to_checkout",label:"Tier Select â Checkout"},{key:"checkout_to_method",label:"Checkout â Method Select"},{key:"method_to_success",label:"Method Select â Success"}],l=Math.max(n.drop_off.impression_to_tier,n.drop_off.tier_to_checkout,n.drop_off.checkout_to_method,n.drop_off.method_to_success);return e.jsxs("div",{style:{border:"1px solid #E5E7EB",borderRadius:"8px",padding:"16px"},children:[e.jsxs("div",{style:{fontWeight:700,marginBottom:"12px"},children:[n.variant_key," - ",n.name,n.is_control&&e.jsx("span",{style:{marginLeft:"8px",background:"#DBEAFE",color:"#1E40AF",padding:"2px 6px",borderRadius:"4px",fontSize:"11px"},children:"Control"})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:a.map(v=>{const d=n.drop_off[v.key],D=d===l&&l>0,C=i?i.drop_off[v.key]:null,c=C!==null&&!n.is_control&&d<C,x=C!==null&&!n.is_control&&d>C;return e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 12px",background:D?"#FEF2F2":"#F9FAFB",borderRadius:"6px",border:D?"1px solid #FCA5A5":"1px solid #E5E7EB"},children:[e.jsx("span",{style:{fontSize:"13px",color:"#374151"},children:v.label}),e.jsxs("span",{style:{fontWeight:700,fontSize:"14px",color:D?"#DC2626":c?"#059669":x?"#DC2626":"#1F2937"},children:[d,"%",c&&e.jsx("span",{style:{marginLeft:"4px",fontSize:"11px"},children:"â¼"}),x&&e.jsx("span",{style:{marginLeft:"4px",fontSize:"11px"},children:"â²"})]})]},v.key)})})]},n.variant_key)})})]}),e.jsxs("div",{style:t.card,children:[e.jsx("h3",{style:{fontSize:"1.1rem",fontWeight:700,marginBottom:"1rem"},children:"Payment Methods"}),e.jsx("div",{style:{display:"grid",gap:"16px"},children:f.variants.map(n=>{const a=Object.entries(n.payment_methods),l=a.reduce((v,[,d])=>v+d,0);return e.jsxs("div",{style:{border:"1px solid #E5E7EB",borderRadius:"8px",padding:"16px"},children:[e.jsxs("div",{style:{fontWeight:700,marginBottom:"12px"},children:[n.variant_key," - ",n.name]}),a.length===0?e.jsx("p",{style:{color:"#9CA3AF",fontSize:"13px",fontStyle:"italic"},children:"No payment data"}):e.jsx("div",{style:{display:"flex",gap:"12px",flexWrap:"wrap"},children:a.map(([v,d])=>e.jsxs("div",{style:{background:"#F3F4F6",padding:"8px 16px",borderRadius:"8px",fontSize:"13px"},children:[e.jsx("span",{style:{fontWeight:600,textTransform:"capitalize"},children:v}),e.jsxs("span",{style:{marginLeft:"8px",color:"#6B7280"},children:[d," (",l>0?Math.round(d/l*100):0,"%)"]})]},v))})]},n.variant_key)})})]})]})]})};return ve&&G.length===0?e.jsx("div",{style:t.page,children:e.jsx("div",{style:{...t.content,textAlign:"center",paddingTop:"4rem"},children:e.jsx("p",{style:{color:"#6B7280"},children:"Loading A/B Testing Dashboard..."})})}):e.jsxs("div",{style:t.page,children:[e.jsx("div",{style:t.header,children:e.jsxs("div",{style:t.headerInner,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("button",{style:t.backBtn,onClick:()=>A("/admin/main"),children:"â Admin Hub"}),e.jsx("h1",{style:{fontSize:"1.5rem",fontWeight:700,color:"#1F2937",margin:0},children:"A/B Testing Management"})]}),_e&&e.jsx("div",{style:{background:"#FEE2E2",color:"#DC2626",padding:"8px 16px",borderRadius:"8px",fontSize:"14px"},children:_e})]})}),e.jsx("div",{style:t.content,children:u?ve?e.jsx("div",{style:{textAlign:"center",padding:"3rem"},children:e.jsx("p",{style:{color:"#6B7280"},children:"Loading experiment..."})}):_t():e.jsxs(e.Fragment,{children:[E&&e.jsxs("div",{style:{...t.card,border:"1px solid #93C5FD",background:q?"white":"#F0
1F9FF"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer"},onClick:()=>Je(!q),children:[e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:700,fontSize:"14px",color:"#1E40AF"},children:"Current Default Config"}),e.jsxs("span",{style:{marginLeft:"12px",fontSize:"13px",color:"#6B7280"},children:["Source: ",E.applied_from_experiment?`${E.applied_from_experiment} â ${E.applied_from_variant||"?"}`:E.applied_by?"Manual edit":"Initial seed"]})]}),e.jsx("span",{style:{fontSize:"18px",color:"#6B7280",userSelect:"none"},children:q?"â²":"â¼"})]}),q&&e.jsxs("div",{style:{marginTop:"16px"},children:[e.jsxs("div",{style:{fontSize:"13px",color:"#6B7280",marginBottom:"12px"},children:["Applied by: ",e.jsx("strong",{children:E.applied_by||"â"}),E.applied_at&&e.jsxs("span",{children:[" at ",new Date(E.applied_at).toLocaleString()]})]}),He?e.jsxs(e.Fragment,{children:[ye(be,Se,Ae,De),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"12px"},children:[e.jsx("button",{style:t.primaryBtn,onClick:st,disabled:we,children:we?"Saving...":"Save"}),e.jsx("button",{style:t.secondaryBtn,onClick:()=>re(!1),children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[ye(JSON.stringify(E.config,null,2),()=>{},Ae,De,!0),e.jsxs("div",{style:{marginTop:"8px",display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx("button",{style:t.secondaryBtn,onClick:()=>{Se(JSON.stringify(E.config,null,2)),re(!0)},children:"Edit Default"}),K?e.jsx("a",{href:`/sign/${K}/hero`,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"13px",color:"#3B82F6",textDecoration:"none",padding:"8px 12px",border:"1px solid #BFDBFE",borderRadius:"8px",background:"#EFF6FF",cursor:"pointer"},children:"Preview Default"}):e.jsx("span",{style:{fontSize:"13px",color:"#9CA3AF",padding:"8px 12px",cursor:"not-allowed"},children:"Preview Default"}),K&&H&&e.jsxs("span",{style:{fontSize:"11px",color:"#9CA3AF"},children:["(",H.length>30?H.substring(0,30)+"...":H,")"]})]})]})]})]}),e.jsx("div",{style:{marginBottom:"12px"},children:e.jsx("a",{href:"/admin/pricing/templates",style:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"8px 16px",backgroundColor:"#F3F4F6",border:"1px solid #D1D5DB",borderRadius:"8px",color:"#374151",textDecoration:"none",fontSize:"14px",fontWeight:500},children:"Manage Pricing Templates"})}),e.jsxs("div",{style:t.tabs,children:[e.jsx("button",{style:t.tab(B==="experiments"),onClick:()=>$("experiments"),children:"Experiments"}),e.jsx("button",{style:t.tab(B==="textConfigs"),onClick:()=>$("textConfigs"),children:"Text Configs"}),e.jsx("button",{style:t.tab(B==="reports"),onClick:()=>$("reports"),children:"Reports"})]}),B==="experiments"&&bt(),B==="textConfigs"&&St(),B==="reports"&&Bt()]})}),wt(),Ct(),kt()]})};export{Nt as default}; 2//# sourceMappingURL=AdminABTestingDashboard-CzNvFS2N.js.map
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.