1import{j as e}from"./app-C1iegf7Q.js";import{h as H,b as w,u as J,H as q,L as O}from"./inertia-BpyZy4w-.js";import{c as W,b as Y,B as z,e as K,f as Q,d as X,a as Z}from"./broadcast-send-test-rF23S-FC.js";import{B as g}from"./button-BE4q1_FS.js";import{C as ee}from"./checkbox-Bj_6CKpj.js";import{I as m}from"./input-DJt0nBB3.js";import{L as c}from"./label-Czc25Mye.js";import{S as T,e as B,f as L,a as E,c as F}from"./select-Bn8hgKYl.js";import{a as te}from"./admin-layout-BhXWbUlP.js";import{A as ae}from"./arrow-left-DCX0fhKH.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 yt(){const{props:$}=H(),{broadcast:s,tierOptions:_,channelOptions:j,caseStatusOptions:v,casePaymentOptions:y,visaTypeOptions:A,eventOptions:f,contactSourceOptions:b,contactImportPlatformOptions:P,journeyOptions:N,flash:C}=$,k=s.target_audience==="everyone"?"everyone":s.target_audience==="contacts"?"contacts":s.target_audience==="cases"?"cases":s.target_event_id?"event":"users",[I,p]=w.useState(!1),[i,U]=w.useState(k),{data:a,setData:n,patch:S,processing:h,errors:r,transform:x}=J({title:s.title,body:s.body,target_audience:k,target_tier:s.target_tier||"all",target_visa_types:s.target_visa_types||[],target_event_id:s.target_event_id??null,target_contact_source:s.target_contact_source||"",target_contact_registered:s.target_contact_registered||"all",target_contact_import_platform:s.target_contact_import_platform||"",target_case_status:s.target_case_status||"active",target_case_journeys:s.target_case_journeys||[],target_case_payment:s.target_case_payment||"all",channels:s.channels,scheduled_at:s.scheduled_at?new Date(s.scheduled_at).toISOString().slice(0,16):"",action_url:s.action_url||"",action_text:s.action_text||"",from_name:s.from_name||"",save_as_draft:!1}),l=t=>{U(t),n(o=>({...o,target_audience:t,target_event_id:t==="event"?o.target_event_id:null,channels:t==="contacts"?["mail"]:t==="everyone"?Array.from(new Set([...o.channels,"mail"])):o.channels.length?o.channels:["mail"]}))},D=t=>{t.preventDefault(),p(!0)},M=()=>{confirm("Are you sure you want to send this broadcast?")&&(x(t=>({...t,save_as_draft:!1})),S(`/admin/broadcasts/${s.uuid}`,{onSuccess:()=>p(!1)}))},R=()=>{x(t=>({...t,save_as_draft:!0})),S(`/admin/broadcasts/${s.uuid}`,{onFinish:()=>x(t=>({...t,save_as_draft:!1}))})},V=t=>{const o=a.channels;o.includes(t)?n("channels",o.filter(u=>u!==t)):n("channels",[...o,t])},d=t=>`rounded-md px-3 py-1.5 text-sm transition-colors ${t?"bg-white font-medium text-ink shadow-sm":"text-ink-3 hover:text-ink"}`;return e.jsxs(te,{children:[e.jsx(q,{title:"Edit 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(O,{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(ae,{className:"h-3.5 w-3.5"})," Back to broadcasts"]}),e.jsx("h1",{className:"text-xl font-semibold text-ink",children:"Edit Broadcast"})]}),C.success&&e.jsx("div",{className:"mb-4 rounded-card border border-green/30 bg-green/10 px-4 py-3 text-sm text-green-ink",children:C.success}),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(c,{htmlFor:"title",children:"Title *"}),e.jsx(m,{id:"title",value:a.title,onChange:t=>n("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(c,{children:"Body *"}),e.jsx("div",{className:"mt-1",children:e.jsx(W,{value:a.body,onChange:t=>n("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.jsx(c,{htmlFor:"from_name",children:"Sender Name"}),e.jsx(m,{id:"from_name",value:a.from_name,onChange:t=>n("from_name",t.target.value),placeholder:"e.g. Yomi from Borderless",maxLength:100}),e.jsx("p",{className:"mt-1 text-xs text-ink-3",children:"Overrides the default sender name for this email. Leave empty to use the default."}),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(c,{htmlFor:"action_url",children:"Action URL"}),e.jsx(m,{id:"action_url",value:a.action_url,onChange:t=>n("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(c,{htmlFor:"action_text",children:"Action Button Text"}),e.jsx(m,{id:"action_text",value:a.action_text,onChange:t=>n("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:()=>l("everyone"),className:d(i==="everyone"),children:"Everyone (users + leads)"}),e.jsx("button",{type:"button",onClick:()=>l("users"),className:d(i==="users"),children:"All Users"}),e.jsx("button",{type:"button",onClick:()=>l("cases"),className:d(i==="cases"),children:"Case clients"}),e.jsx("button",{type:"button",onClick:()=>l("event"),className:d(i==="event"),children:"Event Participants"}),e.jsx("button",{type:"button",onClick:()=>l("contacts"),className:d(i==="contacts"),children:"Contacts / leads"})]}),i==="contacts"&&e.jsx(Y,{source:a.target_contact_source,registered:a.target_contact_registered,importPlatform:a.target_contact_import_platform,sourceOptions:b,importPlatformOptions:P,onSourceChange:t=>n("target_contact_source",t),onRegisteredChange:t=>n("target_contact_registered",t),onImportPlatformChange:t=>n("target_contact_import_platform",t)}),i==="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."}),i==="cases"&&e.jsx(z,{status:a.target_case_status,journeys:a.target_case_journeys,payment:a.target_case_payment,statusOptions:v,journeyOptions:N,paymentOptions:y,onStatusChange:t=>n("target_case_status",t),onJourneysChange:t=>n("target_case_journeys",t),onPaymentChange:t=>n("target_case_payment",t)}),i==="users"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(c,{htmlFor:"target_tier",children:"Subscription Tier *"}),e.jsxs(T,{value:a.target_tier,onValueChange:t=>n("target_tier",t),children:[e.jsx(B,{children:e.jsx(L,{placeholder:"Select tier"})}),e.jsx(E,{children:Object.entries(_).map(([t,o])=>e.jsx(F,{value:t,children:o},t))})]}),r.target_tier&&e.jsx("p",{className:"mt-1 text-sm text-red",children:r.target_tier})]}),e.jsxs("div",{children:[e.jsx(c,{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:A.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:o=>{const u=o.target.checked?[...a.target_visa_types,t.value]:a.target_visa_types.filter(G=>G!==t.value);n("target_visa_types",u)},className:"rounded border-line"}),t.label]},t.value))})]})]}),i==="event"&&e.jsxs("div",{children:[e.jsx(c,{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=>n("target_event_id",t?parseInt(t):null),children:[e.jsx(B,{children:e.jsx(L,{placeholder:"Select an event..."})}),e.jsx(E,{children:f.map(t=>e.jsx(F,{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(K,{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:[i==="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:[i==="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(j).map(([t,o])=>e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-line p-3",children:[e.jsx(ee,{id:`channel-${t}`,checked:a.channels.includes(t),onCheckedChange:()=>V(t)}),e.jsx(c,{htmlFor:`channel-${t}`,className:"cursor-pointer font-normal",children:o})]},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(c,{htmlFor:"scheduled_at",children:"Schedule For"}),e.jsx(m,{id:"scheduled_at",type:"datetime-local",value:a.scheduled_at,onChange:t=>n("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 on submit"}),r.scheduled_at&&e.jsx("p",{className:"mt-1 text-sm text-red",children:r.scheduled_at})]})]}),e.jsx(Q,{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(g,{type:"button",variant:"outline",asChild:!0,children:e.jsx(O,{href:"/admin/broadcasts",children:"Cancel"})}),e.jsx(g,{type:"button",variant:"outline",disabled:h,onClick:R,children:"Save as draft"}),e.jsx(g,{type:"submit",disabled:h,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(X,{title:a.title,body:a.body,actionUrl:a.action_url,actionText:a.action_text,channels:a.channels})})})]})}),e.jsx(Z,{open:I,onOpenChange:p,onConfirm:M,processing:h,title:a.title,body:a.body,actionUrl:a.action_url,actionText:a.action_text,targetTier:i==="users"?a.target_tier:"all",targetEventLabel:i==="event"?f.find(t=>t.value===a.target_event_id)?.label??null:i==="contacts"?`Leads: ${a.target_contact_source?b.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"}`:i==="everyone"?"Everyone: all registered users + all leads (email only)":i==="cases"?`Case clients: ${v[a.target_case_status]??a.target_case_status} · ${a.target_case_journeys.length?a.target_case_journeys.map(t=>N.find(o=>o.value===t)?.label??t).join(", "):"all journeys"}${a.target_case_payment!=="all"?` · ${y[a.target_case_payment]??a.target_case_payment}`:""}`:null,channels:a.channels,scheduledAt:a.scheduled_at,tierOptions:_,channelOptions:j})]})})]})}export{yt 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.