1import{r as a,b as O,j as e,t as c}from"./index-BTknFgmn.js";import{C as p,b as h,c as u,a as f}from"./card-CA4X9pcm.js";import{B as D}from"./button-e-SLIh0W.js";import{I as j}from"./input-octY78VM.js";import{L as d}from"./label-BVyzOqvp.js";import{T as F}from"./textarea-CA6E-q-4.js";import{B as J}from"./badge-D0GmcwL9.js";import{S as q,a as K,b as Q,c as X,d as Z}from"./select-BaKNKXoe.js";import{C as ee}from"./checkbox-DWvAz3jA.js";import{L as C}from"./loader-circle-DyoLk0tc.js";import{S as se}from"./shield-alert-ByRdl3R7.js";import{T as ae}from"./tag-D1g2JaR0.js";import{L as te}from"./link-2-KlBQOBej.js";import{C as le}from"./clock-CVhNAm5O.js";import{G as re}from"./gift-X2-iCvYp.js";import{S as ie}from"./sparkles-B2JGDFvD.js";import{M as ne}from"./mail-CHaqL-KZ.js";import{S as oe}from"./send-DoE82yej.js";import{E as ce}from"./eye-LViw_OZl.js";import"./index-I7b3yQLw.js";import"./index-BdQq_4o_.js";import"./index-diE-tiei.js";import"./index-CCW-eNe_.js";import"./index-DgkGV3C0.js";import"./index-CJZsa5lM.js";import"./index-DalST0TR.js";import"./index-BBHh-466.js";import"./index-BNyGG0Ms.js";import"./index-Duc6mrUA.js";import"./index-BPJaiOXt.js";import"./index-0OQW4ssD.js";import"./chevron-down-CVFtQbg7.js";import"./check-CjawTMvI.js";import"./chevron-up-PBxzjLmN.js";const L=[{value:"discount_code",label:"Discount Code",icon:ae,valuePlaceholder:"SAVE30"},{value:"payment_link",label:"Direct Payment Link",icon:te,valuePlaceholder:"https://..."},{value:"free_trial",label:"Free Trial Extension",icon:le,valuePlaceholder:"14 days"}],de=[{value:"sandbox",label:"Sandbox / Free Trial"},{value:"paid_active",label:"Active Subscribers"},{value:"paid_expired",label:"Expired Subscribers"},{value:"pending_payment",label:"Pending Payment"},{value:"cancelled",label:"Cancelled"}],me=`Hi {{name}}, 2 3We hope things are going wonderfully over at {{company}}! We've been so grateful to have you with us on your {{current_plan}} journey, and we wanted to do something special just for you. 4 5We put together a little thank-you offer below â we'd love to keep supporting your events and help you unlock even more of what EventFlow can do. 6 7If you have any questions at all, just reply to this email. We're real humans and we're always here to help. ð`;function Ge(){var _;const[l,T]=a.useState(null),[A,M]=a.useState(!0),[g,U]=a.useState(""),[t,z]=a.useState("discount_code"),[r,I]=a.useState(""),[v,B]=a.useState(""),[b,V]=a.useState(""),[N,W]=a.useState(me),[w,Y]=a.useState(""),[k,R]=a.useState(["sandbox","paid_expired"]),[m,$]=a.useState(""),[y,E]=a.useState(!1);a.useEffect(()=>{(async()=>{try{const s=await O.auth.me();T(s)}catch{T(null)}M(!1)})()},[]);const G=s=>{R(n=>n.includes(s)?n.filter(S=>S!==s):[...n,s])},P=async(s=!1)=>{var n,S;if(!g.trim()||!N.trim()){c.error("Please fill in the offer title and message.");return}if(!s&&k.length===0){c.error("Please select at least one recipient group.");return}if(s&&!m.trim()){c.error("Please enter a test email address.");return}E(!0);try{const x={offerTitle:g.trim(),offerType:t,offerValue:r.trim(),offerDetails:v.trim(),expirationDate:b||void 0,personalizedMessage:N.trim(),ctaUrl:w.trim()||void 0,...s?{testEmail:m.trim()}:{targetStatuses:k}},o=await O.functions.invoke("sendUpgradeOfferEmails",x);(n=o.data)!=null&&n.success?c.success(s?`Test email sent to ${m}!`:`Sent ${o.data.sent} of ${o.data.totalRecipients} emails${o.data.failed?` (${o.data.failed} failed)`:""}.`):c.error(((S=o.data)==null?void 0:S.error)||"Failed to send emails.")}catch(x){c.error((x==null?void 0:x.message)||"Failed to send upgrade offer.")}finally{E(!1)}},H=N.replace(/\{\{\s*name\s*\}\}/gi,((_=l==null?void 0:l.full_name)==null?void 0:_.split(" ")[0])||"Jane").replace(/\{\{\s*company\s*\}\}/gi,"Acme Events").replace(/\{\{\s*current_plan\s*\}\}/gi,"Sandbox (Free Trial)");if(A)return e.jsx("div",{className:"flex items-center justify-center py-24",children:e.jsx(C,{className:"w-8 h-8 animate-spin text-slate-400"})});if((l==null?void 0:l.role)!=="admin")return e.jsxs("div",{className:"flex flex-col items-center justify-center py-24 text-center",children:[e.jsx(se,{className:"w-16 h-16 text-red-400 mb-4"}),e.jsx("h1",{className:"text-2xl font-bold text-slate-900 mb-2",children:"Access Denied"}),e.jsx("p",{className:"text-slate-500",children:"This page is restricted to administrators only."})]});const i=L.find(s=>s.value===t);return e.jsxs("div",{className:"space-y-6 max-w-6xl",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-gradient-to-br from-violet-500 to-pink-500 flex items-center justify-center",children:e.jsx(re,{className:"w-6 h-6 text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl lg:text-3xl font-bold text-slate-900 dark:text-slate-100",children:"Manage Upgrade Offers"}),e.jsx("p",{className:"text-slate-500 mt-1",children:"Send personalized, friendly upgrade emails to your users"})]})]}
7),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-5 gap-6",children:[e.jsxs("div",{className:"lg:col-span-3 space-y-5",children:[e.jsxs(p,{children:[e.jsx(h,{className:"pb-3",children:e.jsxs(u,{className:"text-base flex items-center gap-2",children:[e.jsx(ie,{className:"w-4 h-4 text-violet-600"}),"Offer Details"]})}),e.jsxs(f,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(d,{children:"Offer Title *"}),e.jsx(j,{value:g,onChange:s=>U(s.target.value),placeholder:"e.g., 30% Off Your First Paid Plan",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(d,{children:"Offer Type *"}),e.jsxs(q,{value:t,onValueChange:z,children:[e.jsx(K,{className:"mt-1",children:e.jsx(Q,{})}),e.jsx(X,{children:L.map(s=>e.jsx(Z,{value:s.value,children:s.label},s.value))})]})]}),e.jsxs("div",{children:[e.jsx(d,{children:t==="discount_code"?"Code":t==="payment_link"?"Link URL":"Trial Duration"}),e.jsx(j,{value:r,onChange:s=>I(s.target.value),placeholder:i==null?void 0:i.valuePlaceholder,className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(d,{children:"What's Included / Package Details"}),e.jsx(F,{value:v,onChange:s=>B(s.target.value),placeholder:"e.g., Unlimited events, priority support, advanced analytics...",rows:4,className:"mt-1"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(d,{children:"Expiration Date (optional)"}),e.jsx(j,{type:"date",value:b,onChange:s=>V(s.target.value),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(d,{children:"CTA Button Link (optional)"}),e.jsx(j,{value:w,onChange:s=>Y(s.target.value),placeholder:"https://...",className:"mt-1"})]})]})]})]}),e.jsxs(p,{children:[e.jsx(h,{className:"pb-3",children:e.jsxs(u,{className:"text-base flex items-center gap-2",children:[e.jsx(ne,{className:"w-4 h-4 text-violet-600"}),"Personalized Message"]})}),e.jsxs(f,{className:"space-y-3",children:[e.jsxs("p",{className:"text-xs text-slate-500",children:["Use ",e.jsx("code",{className:"bg-slate-100 px-1 rounded",children:"{{name}}"}),","," ",e.jsx("code",{className:"bg-slate-100 px-1 rounded",children:"{{company}}"}),", and"," ",e.jsx("code",{className:"bg-slate-100 px-1 rounded",children:"{{current_plan}}"})," for personalization."]}),e.jsx(F,{value:N,onChange:s=>W(s.target.value),rows:10,className:"font-mono text-sm"})]})]}),e.jsxs(p,{children:[e.jsx(h,{className:"pb-3",children:e.jsx(u,{className:"text-base",children:"Recipients"})}),e.jsxs(f,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-slate-500",children:"Select which user groups should receive this offer:"}),de.map(s=>e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[e.jsx(ee,{checked:k.includes(s.value),onCheckedChange:()=>G(s.value)}),e.jsx("span",{className:"text-sm text-slate-700",children:s.label})]},s.value))]})]}),e.jsxs(p,{children:[e.jsx(h,{className:"pb-3",children:e.jsx(u,{className:"text-base",children:"Test Before Sending"})}),e.jsx(f,{className:"space-y-3",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{type:"email",value:m,onChange:s=>$(s.target.value),placeholder:"[email protected]"}),e.jsx(D,{variant:"outline",onClick:()=>P(!0),disabled:y||!m.trim(),children:y?e.jsx(C,{className:"w-4 h-4 animate-spin"}):"Send Test"})]})})]}),e.jsx(D,{size:"lg",onClick:()=>P(!1),disabled:y,className:"w-full bg-gradient-to-r from-violet-600 to-pink-600 hover:from-violet-700 hover:to-pink-700",children:y?e.jsxs(e.Fragment,{children:[e.jsx(C,{className:"w-4 h-4 mr-2 animate-spin"})," Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"w-4 h-4 mr-2"})," Send Offer Emails"]})})]}),e.jsx("div",{className:"lg:col-span-2",children:e.jsxs(p,{className:"sticky top-24",children:[e.jsx(h,{className:"pb-3",children:e.jsxs(u,{className:"text-base flex items-center gap-2",children:[e.jsx(ce,{className:"w-4 h-4 text-violet-600"}),"Live Preview"]})}),e.jsxs(f,{children:[e.jsxs("div",{className:"rounded-xl overflow-hidden border border-slate-200 bg-slate-50",children:[e.jsxs("div",{className:"bg-gradient-to-br from-violet-600 to-pink-500 p-6 text-center text-white",children:[e.jsxs("p",{className:"text-xs uppercase tracking-widest text-pink-100 mb-1",children:["A Special ",(i==null?void 0:i.label)||"Offer"," Just For You"]}),e.jsxs("h2",{className:"text-xl font-bold leading-tight",children:[g||"Your Offer Title"," ð"]})]}),e.jsxs("div",{className:"p-5 bg-white space-y-4 text-sm",children:[e.jsx("p",{className:"whitespace-pre-wrap text-slate-700 leading-relaxed",children:H}),t==="discount_code"&&r&&e.jsxs("div",{className:"bg-violet-50 border-2 border-dashed border-violet-400 rounded-xl p-4 text-center",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-widest text-violet-700 font-semibold",children:"Your Exclusive Code"}),e.jsx("p",{className:"text-2xl font-bold text-violet-800 font-mono tracking-widest mt-1",children:r})]}),t==="free_trial"&&r&&e.jsxs("div",{className:"bg-emerald-50 border-2 border-emerald-400 rounded-xl p-4 text-center",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-widest text-emerald-700 font-semibold",children:"Free Trial Extension"}),e.jsx("p",{className:"text-lg font-bold text-emerald-800 mt-1",children:r})]}),v&&e.jsxs("div",{className:"bg-slate-50 border-l-2 border-violet-500 rounded-r-md p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-widest text-slate-500 font-semibold mb-1",children:"What's Included"}),e.jsx("p",{className:"text-slate-700 whitespace-pre-wrap",children:v})]}),w&&e.jsx("div",{className:"text-center py-2",children:e.jsx("span",{className:"inline-block bg-violet-600 text-white px-6 py-3 rounded-lg font-semibold",children:"Claim Your Offer â"})}),b&&e.jsxs("p",{className:"text-xs bg-amber-50 text-amber-800 border-l-2 border-amber-500 p-2 rounded",children:["â° E
7xpires on ",e.jsx("strong",{children:b})]})]})]}),e.jsx(J,{variant:"outline",className:"mt-3 text-xs",children:"Sample â uses real names when sent"})]})]})})]})]})}export{Ge as default};
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.