1import{bC as he,u as ge,j as e,B as w,b4 as xe,l as re,r as l,ac as d,ad as F,ae as z,af as $,ag as W,ah as h,ab as K,b5 as P,R as ve,i as je}from"./index-Db4qfLtJ.js";import{B as _e}from"./badge-B13RZfEt.js";import{C as ce}from"./checkbox-BhNOJxJe.js";import{S as de}from"./skeleton-8NjDJt9K.js";import{T as fe,a as be,b as Y,c as ae}from"./tabs-C0SDnV8_.js";import{C as ye}from"./ConfirmActionDialog-COVjcmTM.js";import{a as Ne,C as Ce}from"./use-admin-sms-compliance-CSmD57NX.js";import{L as le}from"./lock-Dx-4HVuJ.js";import{S as oe}from"./save-Bzw5dS6P.js";import{f as we}from"./format-DyStx0k9.js";import{E as Se}from"./external-link-BdKUXdmw.js";import{S as Ae}from"./send-BKG_37I8.js";const Te={first_name:"",last_name:"",business_title:"",job_position:"Other",email:"",phone:""};function q(s){return s instanceof Error?s.message:String(s)}function O({title:s,description:u,children:t}){return e.jsxs("section",{className:"border-t py-6 first:border-t-0 first:pt-2",children:[e.jsxs("div",{className:"mb-5",children:[e.jsx("h2",{className:"text-base font-semibold",children:s}),u&&e.jsx("p",{className:"mt-1 max-w-3xl text-sm text-muted-foreground",children:u})]}),t]})}function n({label:s,children:u,hint:t,action:c}){return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("label",{className:"block space-y-1.5",children:[e.jsx("span",{className:"block text-sm font-medium leading-none",children:s}),u]}),c,t&&e.jsx("p",{className:"text-xs text-muted-foreground",children:t})]})}function C({complete:s,children:u}){const t=s?je:Ce;return e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(t,{className:`h-4 w-4 ${s?"text-emerald-600":"text-muted-foreground"}`,"aria-hidden":"true"}),e.jsx("span",{children:u})]})}function Pe({initial:s,save:u,saving:t,locked:c}){const{toast:_}=re(),[f,g]=l.useState(s?.legal_name||""),[j,m]=l.useState(s?.business_type||""),[o,x]=l.useState(""),[b,S]=l.useState(!1),[N,r]=l.useState(s?.legal_address_line1||""),[v,A]=l.useState(s?.legal_address_line2||""),[L,k]=l.useState(s?.legal_address_city||""),[E,D]=l.useState(s?.legal_address_region||""),[R,M]=l.useState(s?.legal_address_postal_code||""),[I,B]=l.useState(s?.legal_address_country_code||"US"),[H,p]=l.useState(s?.website_url||""),[U,T]=l.useState(s?.support_email||""),[J,X]=l.useState(s?.support_phone||""),[Q,Z]=l.useState(s?.business_industry||"TRANSPORTATION"),[ee,se]=l.useState(s?.business_regions_of_operation||"USA_AND_CANADA"),[te,ie]=l.useState(s?.brand_registration_type||"low_volume_standard"),[i,y]=l.useState(s?.authorized_representative||Te),[ne,ue]=l.useState(!1),me=async a=>{if(a.preventDefault(),!j){_({title:"Select the DSP business type",variant:"destructive"});return}const G={legal_name:f,business_type:j,legal_address_line1:N,legal_address_line2:v,legal_address_city:L,legal_address_region:E,legal_address_postal_code:R,legal_address_country_code:I,website_url:H,support_email:U,support_phone:J,business_industry:Q,business_regions_of_operation:ee,brand_registration_type:te};o?G.ein=o:b&&(G.clear_ein=!0),ne?G.authorized_representative=null:G.authorized_representative=i;try{await u(G),x(""),S(!1),_({title:"Business profile saved"})}catch(pe){_({title:"Could not save business profile",description:q(pe),variant:"destructive"})}};return e.jsxs("form",{onSubmit:me,children:[c&&e.jsxs("p",{role:"status",className:"mb-5 flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(le,{className:"h-4 w-4"})," Locked after Twilio Customer Profile submission."]}),e.jsxs("fieldset",{disabled:c,className:"min-w-0 space-y-8",children:[e.jsx(O,{title:"Legal entity",description:"Use the exact details on the DSP's IRS and state registration records.",children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(n,{label:"Legal business name",children:e.jsx(d,{value:f,onChange:a=>g(a.target.value)})}),e.jsx(n,{label:"Business type",children:e.jsxs(F,{value:j,onValueChange:m,children:[e.jsx(z,{children:e.jsx($,{placeholder:"Select business type"})}),e.jsxs(W,{children:[e.jsx(h,{value:"llc",children:"LLC"}),e.jsx(h,{value:"corporation",children:"Corporation"}),e.jsx(h,{value:"partnership",children:"Partnership"}),e.jsx(h,{value:"nonprofit",children:"Nonprofit"}),e.jsx(h,{value:"government",children:"Government"})]})]})}),e.jsx(n,{label:"EIN",hint:o?"The new EIN will replace the stored value when you save.":b?"The stored EIN will be removed when you save.":s?.ein_configured?`Stored securely; ending in ${s.ein_last4}. Leave blank to keep it.`:"Encrypted before storage and never shown again.",action:s?.ein_configured?e.jsx(w,{type:"button",variant:"outline",size:"sm",onClick:()=>{x(""),S(a=>!a)},children:b?"Keep stored EIN":"Remove stored EIN"}):void 0,children:e.jsx(d,{autoComplete:"off",inputMode:"numeric",placeholder:"12-3456789",value:o,onChange:a=>x(a.target.value)})}),e.jsx(n,{label:"Website",children:e.jsx(d,{type:"url",placeholder:"https://example.com",value:H,onChange:a=>p(a.target.value)})}),e.jsx(n,{label:"Industry",children:e.jsxs(F,{value:Q,onValueChange:Z,children:[e.jsx(z,{children:e.jsx($,{})}),e.jsxs(W,{children:[e.jsx(h,{value:"TRANSPORTATION",children:"Transportation"}),e.jsx(h,{value:"PROFESSIONAL_SERVICES",children:"Professional services"}),e.jsx(h,{value:"TECHNOLOGY",children:"Technology"}),e.jsx(h,{value:"RETAIL",children:"Retail"})]})]})}),e.jsx(n,{label:"Regions of operation",children:e.jsxs(F,{value:ee,onValueChange:se,children:[e.jsx(z,{children:e.jsx($,{})}),e.jsxs(W,{children:[e.jsx(h,{value:"USA_AND_CANADA",children:"USA and Canada"}),e.jsx(h,{value:"LATIN_AMERICA",children:"Latin America"}),e.jsx(h,{value:"EUROPE",children:"Europe"}),e.jsx(h,{value:"ASIA",children:"Asia"}),e.jsx(h,{value:"AFRICA",children:"Africa"})]})]})}),e.jsx(n,{label:"A2P brand registration",children:e.jsxs(F,{value:te,onValueChange:a=>ie(a),children:[e.jsx(z,{children:e.jsx($,{})}),e.jsxs(W,{children:[e.jsx(h,{value:"low_volume_standard",children:"Low-volume standard"}),e.jsx(h,{value:"standard",children:"Standard"})]})]})})]})}),e.jsx(O,{title:"Legal address",children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(n,{label:"Address line 1",children:e.jsx(d,{value:N,onChange:a=>r(a.target.value)})}),e.jsx(n,{label:"Address line 2",children:e.jsx(d,{value:v,onCh
1ange:a=>A(a.target.value)})}),e.jsx(n,{label:"City",children:e.jsx(d,{value:L,onChange:a=>k(a.target.value)})}),e.jsx(n,{label:"State or region",children:e.jsx(d,{value:E,onChange:a=>D(a.target.value)})}),e.jsx(n,{label:"Postal code",children:e.jsx(d,{value:R,onChange:a=>M(a.target.value)})}),e.jsx(n,{label:"Country code",children:e.jsx(d,{maxLength:2,value:I,onChange:a=>B(a.target.value.toUpperCase())})})]})}),e.jsxs(O,{title:"Authorized representative",description:"Twilio may contact this person to verify the DSP. These fields are encrypted together.",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(n,{label:"First name",children:e.jsx(d,{value:i.first_name,onChange:a=>y({...i,first_name:a.target.value})})}),e.jsx(n,{label:"Last name",children:e.jsx(d,{value:i.last_name,onChange:a=>y({...i,last_name:a.target.value})})}),e.jsx(n,{label:"Business title",children:e.jsx(d,{value:i.business_title,onChange:a=>y({...i,business_title:a.target.value})})}),e.jsx(n,{label:"Job position",children:e.jsxs(F,{value:i.job_position,onValueChange:a=>y({...i,job_position:a}),children:[e.jsx(z,{children:e.jsx($,{})}),e.jsx(W,{children:["Director","GM","VP","CEO","CFO","General Counsel","Other"].map(a=>e.jsx(h,{value:a,children:a},a))})]})}),e.jsx(n,{label:"Email",children:e.jsx(d,{type:"email",value:i.email,onChange:a=>y({...i,email:a.target.value})})}),e.jsx(n,{label:"Phone",children:e.jsx(d,{placeholder:"+14085551234",value:i.phone,onChange:a=>y({...i,phone:a.target.value})})})]}),s?.authorized_representative&&e.jsx(w,{type:"button",variant:"outline",size:"sm",className:"mt-4",onClick:()=>ue(a=>!a),children:ne?"Keep stored representative":"Remove stored representative"}),ne&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"The stored representative will be removed when you save."})]}),e.jsx(O,{title:"Customer support",description:"This contact is used in HELP responses and customer policy pages.",children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(n,{label:"Support email",children:e.jsx(d,{type:"email",value:U,onChange:a=>T(a.target.value)})}),e.jsx(n,{label:"Support phone",children:e.jsx(d,{placeholder:"+14085551234",value:J,onChange:a=>X(a.target.value)})})]})}),e.jsxs(w,{type:"submit",disabled:t||!j,children:[t?e.jsx(K,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(oe,{className:"mr-2 h-4 w-4"}),"Save business profile"]})]})]})}function Oe({purpose:s,initial:u,save:t,saving:c,locked:_}){const{toast:f}=re(),g=s==="hiring"?"Hiring":"Dispatch",[j,m]=l.useState(u?.program_description||""),[o,x]=l.useState(u?.opt_in_flow||""),[b,S]=l.useState((u?.message_samples||[]).join(` 2`)),[N,r]=l.useState(u?.estimated_monthly_messages?.toString()||""),[v,A]=l.useState(u?.has_embedded_links??!0),[L,k]=l.useState(u?.has_embedded_phone_numbers??!0),[E,D]=l.useState(u?.help_message||""),[R,M]=l.useState(u?.stop_message||"Reply STOP to opt out."),[I,B]=l.useState(u?.twilio_usecase||"LOW_VOLUME"),H=async p=>{p.preventDefault();const U={program_description:j,opt_in_flow:o,message_samples:b.split(` 3`).map(T=>T.trim()).filter(Boolean),estimated_monthly_messages:N===""?null:Number(N),has_embedded_links:v,has_embedded_phone_numbers:L,help_message:E,stop_message:R,twilio_usecase:I};try{await t(s,U),f({title:`${g} program saved`})}catch(T){f({title:`Could not save ${g.toLowerCase()} program`,description:q(T),variant:"destructive"})}};return e.jsxs("form",{onSubmit:H,children:[_&&e.jsxs("p",{role:"status",className:"mb-5 flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(le,{className:"h-4 w-4"})," Locked after Twilio campaign submission."]}),e.jsxs("fieldset",{disabled:_,className:"min-w-0 space-y-6",children:[e.jsxs("div",{className:"grid gap-5",children:[e.jsx(n,{label:"Program description",children:e.jsx(P,{rows:3,value:j,onChange:p=>m(p.target.value)})}),e.jsx(n,{label:"How recipients opt in",children:e.jsx(P,{rows:5,value:o,onChange:p=>x(p.target.value)})}),e.jsx(n,{label:"Message samples",hint:"Enter 2â5 realistic samples, one per line.",children:e.jsx(P,{rows:6,value:b,onChange:p=>S(p.target.value)})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(n,{label:"Estimated monthly messages",children:e.jsx(d,{type:"number",min:"0",value:N,onChange:p=>r(p.target.value)})}),e.jsx(n,{label:"A2P campaign use case",children:e.jsxs(F,{value:
3I,onValueChange:B,children:[e.jsx(z,{children:e.jsx($,{})}),e.jsxs(W,{children:[e.jsx(h,{value:"LOW_VOLUME",children:"Low volume mixed"}),e.jsx(h,{value:"CUSTOMER_CARE",children:"Customer care"}),e.jsx(h,{value:"DELIVERY_NOTIFICATION",children:"Delivery notification"}),e.jsx(h,{value:"ACCOUNT_NOTIFICATION",children:"Account notification"}),e.jsx(h,{value:"MIXED",children:"Mixed"})]})]})}),e.jsxs("div",{className:"space-y-3 pt-7",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(ce,{checked:v,onCheckedChange:p=>A(p===!0)})," Messages may contain links"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(ce,{checked:L,onCheckedChange:p=>k(p===!0)})," Messages may contain phone numbers"]})]})]}),e.jsx(n,{label:"HELP response",children:e.jsx(P,{rows:3,value:E,onChange:p=>D(p.target.value)})}),e.jsx(n,{label:"STOP disclosure",children:e.jsx(P,{rows:2,value:R,onChange:p=>M(p.target.value)})})]}),e.jsxs(w,{type:"submit",disabled:c,children:[c?e.jsx(K,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(oe,{className:"mr-2 h-4 w-4"}),"Save ",g.toLowerCase()," program"]})]})]})}function Le({companyName:s,shortCode:u,initial:t,urls:c,save:_,publish:f,saving:g,publishing:j,locked:m}){const{toast:o}=re(),[x,b]=l.useState(t?.slug||u.toLowerCase().replace(/[^a-z0-9]+/g,"-")),[S,N]=l.useState(t?.display_name||s),[r,v]=l.useState(t?.legal_name||""),[A,L]=l.useState(t?.website_url||""),[k,E]=l.useState(t?.privacy_contact_email||""),[D,R]=l.useState(t?.privacy_contact_phone||""),[M,I]=l.useState(t?.mailing_address||""),[B,H]=l.useState(t?.hiring_program_name||"Hiring updates"),[p,U]=l.useState(t?.hiring_opt_in_description||""),[T,J]=l.useState(t?.dispatch_program_name||"Dispatch updates"),[X,Q]=l.useState(t?.dispatch_opt_in_description||""),[Z,ee]=l.useState(t?.effective_date||we(new Date,"yyyy-MM-dd")),se=()=>({slug:x,display_name:S,legal_name:r,website_url:A,privacy_contact_email:k,privacy_contact_phone:D,mailing_address:M,hiring_program_name:B,hiring_opt_in_description:p,dispatch_program_name:T,dispatch_opt_in_description:X,effective_date:Z}),te=async i=>{i.preventDefault();try{await _(se()),o({title:"Policy profile saved"})}catch(y){o({title:"Could not save policy profile",description:q(y),variant:"destructive"})}},ie=async()=>{try{await _(se()),await f(!t?.is_published),o({title:t?.is_published?"Policy pages unpublished":"Policy pages published"})}catch(i){o({title:"Could not change publication status",description:q(i),variant:"destructive"})}};return e.jsxs("form",{onSubmit:te,children:[m&&e.jsxs("p",{role:"status",className:"mb-5 flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(le,{className:"h-4 w-4"})," Locked after Twilio campaign submission."]}),e.jsxs("fieldset",{disabled:m,className:"min-w-0 space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(n,{label:"URL slug",children:e.jsx(d,{value:x,onChange:i=>b(i.target.value.toLowerCase())})}),e.jsx(n,{label:"Display name",children:e.jsx(d,{value:S,onChange:i=>N(i.target.value)})}),e.jsx(n,{label:"Legal name",children:e.jsx(d,{value:r,onChange:i=>v(i.target.value)})}),e.jsx(n,{label:"Website",children:e.jsx(d,{type:"url",value:A,onChange:i=>L(i.target.value)})}),e.jsx(n,{label:"Privacy email",children:e.jsx(d,{type:"email",value:k,onChange:i=>E(i.target.value)})}),e.jsx(n,{label:"Privacy phone",children:e.jsx(d,{value:D,onChange:i=>R(i.target.value)})}),e.jsx(n,{label:"Effective date",children:e.jsx(d,{type:"date",value:Z,onChange:i=>ee(i.target.value)})})]}),e.jsx(n,{label:"Public mailing address",children:e.jsx(P,{rows:2,value:M,onChange:i=>I(i.target.value)})}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-4 border-t pt-4",children:[e.jsx(n,{label:"Hiring program name",children:e.jsx(d,{value:B,onChange:i=>H(i.target.value)})}),e.jsx(n,{label:"Hiring opt-in description",children:e.jsx(P,{rows:6,value:p,onChange:i=>U(i.target.value)})})]}),e.jsxs("div",{className:"space-y-4 border-t pt-4",children:[e.jsx(n,{label:"Dispatch program name",children:e.jsx(d,{value:T,onChange:i=>J(i.target.value)})}
3),e.jsx(n,{label:"Dispatch opt-in description",children:e.jsx(P,{rows:6,value:X,onChange:i=>Q(i.target.value)})})]})]}),c&&e.jsx("div",{className:"space-y-2 border-t pt-4 text-sm",children:[["Privacy",c.privacy],["SMS terms",c.sms_terms]].map(([i,y])=>e.jsxs("a",{className:"flex items-center gap-2 text-indigo-700 underline",href:y,target:"_blank",rel:"noreferrer",children:[i,": ",y,e.jsx(Se,{className:"h-3.5 w-3.5","aria-hidden":"true"})]},y))}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(w,{type:"submit",disabled:g,children:[g?e.jsx(K,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(oe,{className:"mr-2 h-4 w-4"}),"Save policy profile"]}),e.jsxs(w,{type:"button",variant:t?.is_published?"outline":"default",disabled:j,onClick:ie,children:[j?e.jsx(K,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Ae,{className:"mr-2 h-4 w-4"}),t?.is_published?"Unpublish pages":"Publish pages"]})]})]})]})}const V={"customer-profile":"Create customer profile","trust-product":"Create trust product",brand:"Register brand",services:"Create Messaging Services",campaigns:"Register campaigns",refresh:"Refresh Twilio status",cutover:"Activate dedicated senders"};function Ee({detail:s,runAction:u,runningAction:t,setAdvancedOptOut:c,savingAdvancedOptOut:_}){const{toast:f}=re(),[g,j]=l.useState(null),m=s.profile,o=Object.fromEntries(s.programs.map(r=>[r.purpose,r])),x=!!(m?.last_provider_error||m?.sender_cutover_blocked_at)||s.programs.some(r=>!!r.last_provider_error),b=s.provider_config.credentials&&s.provider_config.notification_email&&s.provider_config.public_url,S={"customer-profile":s.readiness.business,"trust-product":m?.twilio_customer_profile_status==="twilio-approved",brand:m?.twilio_customer_profile_status==="twilio-approved"&&m?.twilio_trust_product_status==="twilio-approved",services:s.readiness.messaging,campaigns:s.readiness.brand&&s.readiness.services&&s.readiness.messaging&&s.readiness.policies,refresh:!!(m?.twilio_customer_profile_sid||m?.twilio_trust_product_sid||m?.twilio_brand_sid),cutover:s.readiness.campaigns&&s.readiness.services&&s.readiness.advanced_opt_out&&s.provider_config.routing_enabled},N=async(r,v)=>{try{await c(r,v),f({title:`${r==="hiring"?"Hiring":"Dispatch"} Advanced Opt-Out status saved`})}catch(A){throw f({title:"Could not save Advanced Opt-Out status",description:q(A),variant:"destructive"}),A}};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(O,{title:"Registration readiness",children:e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:[e.jsx(C,{complete:s.readiness.business,children:"Business profile"}),e.jsx(C,{complete:s.readiness.messaging,children:"Messaging evidence"}),e.jsx(C,{complete:s.readiness.policies,children:"Published policies"}),e.jsx(C,{complete:s.readiness.customer_profile,children:"Secondary customer profile"}),e.jsx(C,{complete:s.readiness.trust_product,children:"Trust product"}),e.jsx(C,{complete:s.readiness.brand,children:"Brand approval"}),e.jsx(C,{complete:s.readiness.campaigns,children:"Campaign approvals"}),e.jsx(C,{complete:s.readiness.services,children:"Messaging Services"}),e.jsx(C,{complete:s.readiness.advanced_opt_out,children:"Advanced Opt-Out"}),e.jsx(C,{complete:s.readiness.senders_active,children:"Dedicated senders active"})]})}),e.jsxs(O,{title:"Twilio actions",children:[!b&&e.jsxs("div",{className:"mb-4 border-l-4 border-amber-500 bg-amber-50 px-4 py-3 text-sm text-amber-950",children:["Provider configuration is incomplete: ",Object.entries(s.provider_config).filter(([r,v])=>r!=="routing_enabled"&&!v).map(([r])=>r.replace("_"," ")).join(", "),"."]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.keys(V).map(r=>e.jsxs(w,{type:"button",variant:r==="cutover"?"destructive":r==="refresh"?"outline":"default",disabled:!b||!S[r]||!!t,onClick:()=>j(r),children:[t===r?e.jsx(K,{className:"mr-2 h-4 w-4 animate-spin"}):r==="refresh"&&e.jsx(ve,{className:"mr-2 h-4 w-4"}),V[r]]},r))}),m?.provider_operation&&e.jsxs("p",{className:"mt-3 text-sm text-muted-foreground",children:["Operation in progress: ",m.provider_operation.split(":").at(0)?.replaceAll("-"," ")||"Twilio update"]})]}),e.jsx(O,{title:"Advanced Opt-Out",description:"Confirm each Messaging Service after its HELP response includes the DSP support contact in Twilio Console.",children:e.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:["hiring","dispatch"].map(r=>{const v=!!o[r]?.advanced_opt_out_configured_at;return e.jsxs("div",{className:"flex items-center justify-between gap-3 border px-3 py-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium capitalize",children:r}),e.jsx("p",{className:"text-xs text-muted-foreground",children:v?"Confirmed":"Not confirmed"})]}),e.jsx(w,{type:"button",size:"sm",variant:"outline",disabled:!o[r]||_,onClick:()=>{N(r,!v)},children:v?"Clear confirmation":"Mark configured"})]},r)})})}),e.jsxs(O,{title:"Twilio artifacts",children:[e.jsxs("dl",{className:"grid gap-x-8 gap-y-4 text-sm md:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Customer profile"}),e.jsx("dd",{className:"mt-1 font-mono text-xs",children:m?.twilio_customer_profile_sid||"Not created"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Trust product"}),e.jsx("dd",{className:"mt-1 font-mono text-xs",children:m?.twilio_trust_product_sid||"Not created"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Brand"}),e.jsx("dd",{className:"mt-1 font-mono text-xs",children:m?.twilio_brand_sid||"Not created"})]}),["hiring","dispatch"].map(r=>e.jsxs("div",{children:[e.jsxs("dt",{className:"capitalize text-muted-foreground",children:[r," campaign / service"]}),e.jsxs("dd",{className:"mt-1 font-mono text-xs",children:[o[r]?.twilio_campaign_sid||"Not created"," / ",o[r]?.twilio_messaging_service_sid||"Not created"]})]},r))]}),x&&e.jsx("p",{className:"mt-4 text-sm text-danger-deep",children:"Last provider operation requires attention. Refresh or retry after correcting the reported Twilio issue."})]}),e.jsx(ye,{open:!!g,onOpenChange:r=>{r||j(null)},title:g?`${V[g]}?`:"Run Twilio action?",consequence:g==="cutover"?"This moves the DSP phone numbers from their current Messaging Service into the approved hiring and dispatch services, then switches live SMS rout
3ing. Failed moves are rolled back.":"This creates or updates compliance resources in the connected Twilio account. It does not buy phone numbers or switch live SMS traffic.",confirmLabel:g?V[g]:"Run action",destructive:g==="cutover",onConfirm:async()=>{if(!g)return;const r=g;try{await u(r),f({title:`${V[r]} completed`}),j(null)}catch(v){throw f({title:`${V[r]} failed`,description:q(v),variant:"destructive"}),v}}})]})}function We(){const{companyId:s=""}=he(),u=ge(),t=Ne(s);if(t.isLoading)return e.jsxs("div",{className:"space-y-4",children:[e.jsx(de,{className:"h-10 w-80"}),e.jsx(de,{className:"h-[420px] w-full"})]});if(t.isError||!t.data)return e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-danger-deep",children:"Could not load this SMS compliance record."}),e.jsx(w,{variant:"outline",onClick:()=>u("/admin/sms-compliance"),children:"Back"})]});const c=t.data,_=o=>c.programs.find(x=>x.purpose===o)||null,f=(o,x,b="draft")=>!!o&&String(x||"").toLowerCase()!==b,g=f(c.profile?.twilio_customer_profile_sid,c.profile?.t
3wilio_customer_profile_status),j=o=>f(_(o)?.twilio_campaign_sid,_(o)?.twilio_campaign_status),m=["hiring","dispatch"].some(j);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs(w,{variant:"ghost",size:"sm",onClick:()=>u("/admin/sms-compliance"),children:[e.jsx(xe,{className:"mr-1 h-4 w-4"})," Back"]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:c.company.name}),e.jsx(_e,{variant:c.readiness.active?"default":c.readiness.ready_for_registration?"secondary":"outline",children:c.readiness.active?"Active":c.readiness.ready_for_registration?"Ready to register":"Collecting details"})]}),e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:[c.company.short_code," · SMS compliance registration"]})]}),e.jsxs(fe,{defaultValue:"business",children:[e.jsxs(be,{className:"h-auto w-full justify-start overflow-x-auto",children:[e.jsx(Y,{value:"business",children:"Business"}),e.jsx(Y,{value:"hiring",children:"Hiring"}),e.jsx(Y,{value:"dispatch",children:"Dispatch"}),e.jsx(Y,{value:"policies",children:"Policies"}),e.jsx(Y,{value:"twilio",children:"Twilio"})]}),e.jsx(ae,{value:"business",className:"mt-6",children:e.jsx(Pe,{initial:c.profile,save:t.saveProfile,saving:t.isSavingProfile,locked:g},c.profile?.updated_at||"new")}),["hiring","dispatch"].map(o=>e.jsx(ae,{value:o,className:"mt-6",children:e.jsx(Oe,{purpose:o,initial:_(o),save:(x,b)=>t.saveProgram({purpose:x,input:b}),saving:t.isSavingProgram,locked:j(o)},_(o)?.updated_at||o)},o)),e.jsx(ae,{value:"policies",className:"mt-6",children:e.jsx(Le,{companyName:c.company.name,shortCode:c.company.short_code,initial:c.public_profile,urls:c.policy_urls,save:t.savePublicProfile,publish:t.publishPublicProfile,saving:t.isSavingPublicProfile,publishing:t.isPublishing,locked:m},c.public_profile?.updated_at||"new")}),e.jsx(ae,{value:"twilio",className:"mt-6",children:e.jsx(Ee,{detail:c,runAction:t.runTwilioAction,runningAction:t.runningTwilioAction,setAdvancedOptOut:(o,x)=>t.setAdvancedOptOut({purpose:o,configured:x}),savingAdvancedOptOut:t.isSavingAdvancedOptOut})})]})]})}export{We 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.