1import{j as e}from"./app-C1iegf7Q.js";import{b as v,u as G,H,L}from"./inertia-BpyZy4w-.js";import{c as J,b as q,B as W,e as Y,f as z,d as K,a as Q}from"./broadcast-send-test-rF23S-FC.js";import{B as w}from"./button-BE4q1_FS.js";import{C as X}from"./checkbox-Bj_6CKpj.js";import{I as h}from"./input-DJt0nBB3.js";import{L as o}from"./label-Czc25Mye.js";import{S as T,e as B,f as F,a as $,c as A}from"./select-Bn8hgKYl.js";import{a as Z}from"./admin-layout-BhXWbUlP.js";import{A as ee}from"./arrow-left-DCX0fhKH.js";import{P as te}from"./pencil-DJkCCH8r.js";import{L as E}from"./lock-eEI5w3jQ.js";/* empty css */import"./badge-B51Owt1e.js";import"./utils-BiuKVCuu.js";import"./card-B-nADP2d.js";import"./tabs-DD7MnLSX.js";import"./index-Dc_FVRD7.js";import"./index-iZtkVXs0.js";import"./index-B0NHTN87.js";import"./index-CGXdj8xB.js";import"./index-C_n-C52S.js";import"./index-CL12STDK.js";import"./index-Cja0wFUH.js";import"./index-XydtsrKA.js";import"./index-C48dRAib.js";import"./index-B1PKR-s8.js";import"./smartphone-CH_9476b.js";import"./createLucideIcon-wqc1LSWg.js";import"./mail-Dwbp3545.js";import"./bell-BvDZckLh.js";import"./megaphone-opizzcRj.js";import"./dialog-DrkalYDs.js";import"./index-BewtL6Hn.js";import"./index-BDqbV96p.js";import"./Combination-Cr5kvm8y.js";import"./x-DQSeRCcH.js";import"./separator-Dx9QSwii.js";import"./index-DdRFMukF.js";import"./clock-BtI_SZvJ.js";import"./triangle-alert-C7AVwNi-.js";import"./users-BCcupCXV.js";import"./calendar-C9IvR7oY.js";import"./send-COySMMwK.js";import"./index-DgRF6w_M.js";import"./index-DJlprK4q.js";import"./index-DV0GpYST.js";import"./index-B9qJRYKv.js";import"./link-DKPEjeqT.js";import"./underline-BUwyLhKb.js";import"./unlink-CeG1DYqQ.js";import"./list-BgP0xxm1.js";import"./quote-BLp7dxmt.js";import"./loader-circle-C_KBZAGS.js";import"./image-vCg-0Xge.js";import"./index-Cs5D2gCo.js";import"./index-BRU_LjHB.js";import"./check-0O-UND6N.js";import"./index-BdQq_4o_.js";import"./index-D4vO54bj.js";import"./index-DyGg2PJd.js";import"./chevron-down-B1YaU0K5.js";import"./chevron-up-CLp5HMgA.js";import"./app-logo-Dz0wogSq.js";import"./logo-light-DU4bWymm.js";import"./flash-toast-C6O0iVL1.js";import"./info-D2ZN_yLm.js";import"./circle-x-Bp6Mbpgt.js";import"./circle-check-BMWvzPMx.js";import"./menu-BR3Nc3Gr.js";import"./folder-open-I72SPUVk.js";import"./pound-sterling-D16GLaAZ.js";import"./book-open-DVFlG_9t.js";function ae(){const p={audience:"everyone",caseStatus:"active",journeys:[],payment:"all"};if(typeof window>"u")return p;const l=new URLSearchParams(window.location.search),c=l.get("audience"),u=c==="cases"||c==="users"||c==="event"||c==="contacts"?c:"everyone",g=l.get("case_status")??"",_=["active","inactive","all"].includes(g)?g:"active",j=(l.get("journeys")??"").split(",").map(d=>d.trim()).filter(Boolean),f=l.get("payment")??"",y=["paid","unpaid","all"].includes(f)?f:"all";return{audience:u,caseStatus:_,journeys:j,payment:y}}function bt({tierOptions:p,channelOptions:l,caseStatusOptions:c,casePaymentOptions:u,visaTypeOptions:g,eventOptions:_,contactSourceOptions:j,contactImportPlatformOptions:f,journeyOptions:y}){const d=v.useMemo(()=>ae(),[]),[P,b]=v.useState(!1),[n,U]=v.useState(d.audience),[m,I]=v.useState(!0),{data:a,setData:s,post:S,processing:N,errors:r,transform:k}=G({title:"",body:"",target_audience:d.audience,target_tier:"all",target_visa_types:[],target_event_id:null,target_contact_source:"",target_contact_registered:"all",target_contact_import_platform:"",target_case_status:d.caseStatus,target_case_journeys:d.journeys,target_case_payment:d.payment,channels:["mail"],scheduled_at:"",action_url:"",action_text:"",from_name:"",save_as_draft:!1}),x=t=>{U(t),s(i=>({...i,target_audience:t,target_event_id:t==="event"?i.target_event_id:null,channels:t==="contacts"?["mail"]:t==="everyone"?Array.from(new Set([...i.channels,"mail"])):i.channels.length?i.channels:["mail"]}))},D=t=>{t.preventDefault(),b(!0)},R=()=>{confirm("Are you sure you want to send this broadcast?")&&(k(t=>({...t,save_as_draft:!1})),S("/admin/broadcasts",{onSuccess:()=>b(!1)}))},M=()=>{k(t=>({...t,save_as_draft:!0})),S("/admin/broadcasts",{onFinish:()=>k(t=>
1({...t,save_as_draft:!1}))})},V=t=>{const i=a.channels;i.includes(t)?s("channels",i.filter(C=>C!==t)):s("channels",[...i,t])};return e.jsxs(Z,{children:[e.jsx(H,{title:"Create Broadcast - Admin"}),e.jsx("div",{className:"px-4 py-5 sm:px-6 sm:py-7",children:e.jsxs("div",{className:"mx-auto max-w-7xl",children:[e.jsxs("div",{className:"mb-5",children:[e.jsxs(L,{href:"/admin/broadcasts",className:"mb-2 inline-flex items-center gap-1 text-xs font-medium text-ink-3 hover:text-ink",children:[e.jsx(ee,{className:"h-3.5 w-3.5"})," Back to broadcasts"]}),e.jsx("h1",{className:"text-xl font-semibold text-ink",children:"Create Broadcast"})]}),e.jsx("form",{onSubmit:D,children:e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-3 lg:items-start",children:[e.jsxs("div",{className:"space-y-6 lg:col-span-2",children:[e.jsxs("div",{className:"rounded-card border border-line bg-white p-5",children:[e.jsx("h2",{className:"text-base font-semibold text-ink",children:"Content"}),e.jsxs("p",{className:"mt-0.5 text-sm text-ink-3",children:["The notification content users will see. Use ","{user.name}",", ","{user.email}",", or"," ","{user.first_name}"," for personalisation."]}),e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"title",children:"Title *"}),e.jsx(h,{id:"title",value:a.title,onChange:t=>s("title",t.target.value),placeholder:"e.g., New Feature: Document Checker",maxLength:255,required:!0}),r.title&&e.jsx("p",{className:"mt-1 text-sm text-red",children:r.title})]}),e.jsxs("div",{children:[e.jsx(o,{children:"Body *"}),e.jsx("div",{className:"mt-1",children:e.jsx(J,{value:a.body,onChange:t=>s("body",t),placeholder:"Write your broadcast message...",error:r.body})}),r.body&&e.jsx("p",{className:"mt-1 text-sm text-red",children:r.body})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(o,{htmlFor:"from_name",children:"Sender Name"}),e.jsx("button",{type:"button",onClick:()=>{m||s("from_name",""),I(!m)},className:"inline-flex items-center gap-1 text-xs text-ink-3 hover:text-ink",children:m?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"h-3 w-3"})," Change"]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{className:"h-3 w-3"})," Lock"]})})]}),m?e.jsxs("div",{className:"mt-1 flex items-center gap-2 rounded-lg border border-line bg-bg-2 px-3 py-2",children:[e.jsx(E,{className:"h-3.5 w-3.5 shrink-0 text-ink-3"}),e.jsx("span",{className:"text-sm text-ink-3",children:"Using default sender name"})]}):e.jsx(h,{id:"from_name",value:a.from_name,onChange:t=>s("from_name",t.target.value),placeholder:"e.g. Yomi from Borderless",maxLength:100,autoFocus:!0}),e.jsx("p",{className:"mt-1 text-xs text-ink-3",children:m?"Default sender is used. Click Change to override for this broadcast.":"Overrides the default sender name for this broadcast only."}),r.from_name&&e.jsx("p",{className:"mt-1 text-sm text-red",children:r.from_name})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"action_url",children:"Action URL"}),e.jsx(h,{id:"action_url",value:a.action_url,onChange:t=>s("action_url",t.target.value),placeholder:"https://..."}),r.action_url&&e.jsx("p",{className:"mt-1 text-sm text-red",children:r.action_url})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"action_text",children:"Action Button Text"}),e.jsx(h,{id:"action_text",value:a.action_text,onChange:t=>s("action_text",t.target.value),placeholder:"e.g., Learn More",maxLength:100}),r.action_text&&e.jsx("p",{className:"mt-1 text-sm text-red",children:r.action_text})]})]})]})]}),e.jsxs("div",{className:"rounded-card border border-line bg-white p-5",children:[e.jsx("h2",{className:"text-base font-semibold text-ink",children:"Targeting"}),e.jsx("p",{className:"mt-0.5 text-sm text-ink-3",children:"Choose who receives this broadcast"}),e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"flex w-fit flex-wrap gap-1 rounded-lg bg-bg-2 p-1",children:[e.jsx("button",{type:"button",onClick:()=>x("everyone"),className:`rounded-md px-3 py-1.5 text-sm transition-colors ${n==="everyone"?"bg-white font-medium text-ink shadow-sm":"text-ink-3 hover:text-ink"}`,children:"Everyone (users + leads)"}),e.jsx("button",{type:"button",onClick:()=>x("users"),className:`rounded-md px-3 py-1.5 text-sm transition-colors ${n==="users"?"bg-white font-medium text-ink shadow-sm":"text-ink-3 hover:text-ink"}`,children:"All Users"}),e.jsx("button",{type:"button",onClick:()=>x("cases"),className:`rounded-md px-3 py-1.5 text-sm transition-colors ${n==="cases"?"bg-white font-medium text-ink shadow-sm":"text-ink-3 hover:text-ink"}`,children:"Case clients"}),e.jsx("button",{type:"button",onClick:()=>x("event"),className:`rounded-md px-3 py-1.5 text-sm transition-colors ${n==="event"?"bg-white font-medium text-ink shadow-sm":"text-ink-3 hover:text-ink"}`,children:"Event Participants"}),e.jsx("button",{type:"button",onClick:()=>x("contacts"),className:`rounded-md px-3 py-1.5 text-sm transition-colors ${n==="contacts"?"bg-white font-medium text-ink shadow-sm":"text-ink-3 hover:text-ink"}`,children:"Contacts / leads"})]}),n==="contacts"&&e.jsx(q,{source:a.target_contact_source,registered:a.target_contact_registered,importPlatform:a.target_contact_import_platform,sourceOptions:j,importPlatformOptions:f,onSourceChange:t=>s("target_contact_source",t),onRegisteredChange:t=>s("target_contact_registered",t),onImportPlatformChange:t=>s("target_contact_import_platform",t)}),n==="everyone"&&e.jsx("p",{className:"text-xs text-ink-3",children:"Goes to every registered user plus every captured lead who has not signed up. Users get the channels you pick below (filtered by their notification preferences); leads get email only. Anyone who has unsubscribed or bounced is skipped, and anyone who is both a user and a lead is emailed once."}),n==="cases"&&e.jsx(W,{status:a.target_case_status,journeys:a.target_case_journeys,payment:a.target_case_payment,statusOptions:c,journeyOptions:y,paymentOptions:u,onStatusChange:t=>s("target_case_status",t),onJourneysChange:t=>s("target_case_journeys",t),onPaymentChange:t=>s("target_case_payment",t)}),n==="users"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"target_tier",children:"Subscription Tier *"}),e.jsxs(T,{value:a.target_tier,onValueChange:t=>s("target_tier",t),children:[e.jsx(B,{children:e.jsx(F,{placeholder:"Select tier"})}),e.jsx($,{children:Object.entries(p).map(([t,i])=>e.jsx(A,{value:t,children:i},t))})]}),r.target_tier&&e.jsx("p",{className:"mt-1 text-sm text-red",children:r.target_tier})]}),e.jsxs("div",{children:[e.jsx(o,{children:"Visa Type Targeting"}),e.jsx("p",{className:"mb-2 text-xs text-ink-3",children:"Optionally restrict to specific visa holders. Leave empty for all users."}),e.jsx("div",{className:"grid max-h-48 grid-cols-2 gap-2 overflow-y-auto rounded-lg border border-line p-3",children:g.map(t=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:a.target_visa_types.includes(t.value),onChange:i=>{const C=i.target.checked?[...a.target_visa_types,t.value]:a.target_visa_types.filter(O=>O!==t.value);s("target_visa_types",C)},className:"rounded border-line"}),t.label]},t.value))})]})]}),n==="event"&&e.jsxs("div",{children:[e.jsx(o,{htmlFor:"target_event_id",children:"Event *"}),e.jsx("p",{className:"mb-2 text-xs text-ink-3",children:"The broadcast will be sent to all confirmed participants of this event. Guest registrations (no account) receive email only."}),e.jsxs(T,{value:a.target_event_id?.toString()??"",onValueChange:t=>s("target_event_id",t?parseInt(t):null),children:[e.jsx(B,{children:e.jsx(F,{placeholder:"Select an event..."})}),e.jsx($,{children:_.map(t=>e.jsx(A,{value:t.value.toString(),children:t.label},t.value))})]}),r.target_event_id&&e.jsx("p",{className:"mt-1 text-sm text-red",children:r.target_event_id})]}),e.jsx(Y,{audience:a.target_audience,targetTier:a.target_tier,targetVisaTypes:a.target_visa_types,targetEventId:a.target_event_id,targetContactSource:a.target_contact_source,targetContactRegistered:a.target_contact_registered,targetContactImportPlatform:a.target_contact_import_platform,targetCaseStatus:a.target_case_status,targetCaseJourneys:a.target_case_journeys,targetCasePayment:a.target_case_payment})]})]}),e.jsxs("div",{className:"rounded-card border border-line bg-white p-5",children:[e.jsx("h2",{className:"text-base font-semibold text-ink",children:"Delivery Channels"}),e.jsx("p",{className:"mt-0.5 text-sm text-ink-3",children:"Select channels to send through. User notification preferences will further filter delivery."}),e.jsxs("div",{className:"mt-4 space-y-3",children:[n==="contacts"?e.jsx("p",{className:"text-sm text-ink-3",children:"Contacts / leads have no account, so this broadcast goes out by email only."}):e.jsxs(e.Fragment,{children:[n==="everyone"&&e.jsx("p",{className:"text-sm text-ink-3",children:"These channels apply to registered users. Leads always re
1ceive email only, so keep Email selected to reach them."}),Object.entries(l).map(([t,i])=>e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-line p-3",children:[e.jsx(X,{id:`channel-${t}`,checked:a.channels.includes(t),onCheckedChange:()=>V(t)}),e.jsx(o,{htmlFor:`channel-${t}`,className:"cursor-pointer font-normal",children:i})]},t))]}),r.channels&&e.jsx("p",{className:"text-sm text-red",children:r.channels})]})]}),e.jsxs("div",{className:"rounded-card border border-line bg-white p-5",children:[e.jsx("h2",{className:"text-base font-semibold text-ink",children:"Scheduling"}),e.jsx("p",{className:"mt-0.5 text-sm text-ink-3",children:"Leave empty to send immediately, or pick a future date/time"}),e.jsxs("div",{className:"mt-4",children:[e.jsx(o,{htmlFor:"scheduled_at",children:"Schedule For"}),e.jsx(h,{id:"scheduled_at",type:"datetime-local",value:a.scheduled_at,onChange:t=>s("scheduled_at",t.target.value),className:"max-w-xs"}),e.jsx("p",{className:"mt-1 text-xs text-ink-3",children:"Leave empty to send immediately after creation"}),r.scheduled_at&&e.jsx("p",{className:"mt-1 text-sm text-red",children:r.scheduled_at})]})]}),e.jsx(z,{title:a.title,body:a.body,channels:a.channels,actionUrl:a.action_url,actionText:a.action_text,targetEventId:a.target_event_id}),e.jsxs("div",{className:"flex justify-end gap-4",children:[e.jsx(w,{type:"button",variant:"outline",asChild:!0,children:e.jsx(L,{href:"/admin/broadcasts",children:"Cancel"})}),e.jsx(w,{type:"button",variant:"outline",disabled:N,onClick:M,children:"Save as draft"}),e.jsx(w,{type:"submit",disabled:N,children:a.scheduled_at?"Schedule Broadcast":"Send Now"})]})]}),e.jsx("div",{className:"lg:col-span-1",children:e.jsx("div",{className:"lg:sticky lg:top-6",children:e.jsx(K,{title:a.title,body:a.body,actionUrl:a.action_url,actionText:a.action_text,channels:a.channels})})})]})}),e.jsx(Q,{open:P,onOpenChange:b,onConfirm:R,processing:N,title:a.title,body:a.body,actionUrl:a.action_url,actionText:a.action_text,targetTier:n==="users"?a.target_tier:"all",targetEventLabel:n==="event"?_.find(t=>t.value===a.target_event_id)?.label??null:n==="contacts"?`Leads: ${a.target_contact_source?j.find(t=>t.value===a.target_contact_source)?.label??a.target_contact_source:"All sources"}${a.target_contact_import_platform?` (${a.target_contact_import_platform})`:""} · ${a.target_contact_registered==="guest"?"no account":a.target_contact_registered==="registered"?"has account":"everyone"}`:n==="everyone"?"Everyone: all registered users + all leads (email only)":n==="c
1ases"?`Case clients: ${c[a.target_case_status]??a.target_case_status} · ${a.target_case_journeys.length?a.target_case_journeys.map(t=>y.find(i=>i.value===t)?.label??t).join(", "):"all journeys"}${a.target_case_payment!=="all"?` · ${u[a.target_case_payment]??a.target_case_payment}`:""}`:null,channels:a.channels,scheduledAt:a.scheduled_at,tierOptions:p,channelOptions:l})]})})]})}export{bt 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.