PageSourceSearch

https://bliss-it-services.pages.dev/assets/SiteDetailPage-B4IrbCA-.js

js bliss-it-services.pages.dev collected 2026-10-03 05:38:24 UTC 107,571 bytes, 1 lines download raw bytes

1import{a as n,j as e}from"./three-vendors-DGQpa7F9.js";import{L as V,t as Nt,v as Ct,w as kt,x as St,y as _t,l as Pt,B as _,z as Lt,A as Wa,C as Zs,D as Et,E as At,r as Rt,G as Dt,e as Ft,m as Vs,H as Ut,I as Tt,J as $t,s as Mt,K as qa,M as Ks,d as za,N as Bt,O as Ot,P as It,Q as Wt,R as qt,S as zt,T as Gt,U as Ht,q as Vt}from"./index-BxOGVMpa.js";const Kt={plan:{eyebrow:"Phase 1 / Plan",heading:a=>`Tell Bliss what ${a} needs`,description:"Add the business context, goals, offers, budget range, examples, and concerns Bliss should use to prepare the professional three-tier plan.",placeholder:"Write naturally. Include anything Bliss should know before preparing your plan.",prompts:["What does this business do, and who is the best customer?","Which services, products, or offers matter most?","What should the website help people do?","What budget, timeline, examples, or concerns should Bliss know?","What would make the project feel successful?"]},build:{eyebrow:"Phase 2 / Build",heading:()=>"Keep build details in one place",description:"Add copy changes, asset notes, design feedback, examples, and decisions your account manager should consider while the site is being built.",placeholder:"Write build notes, requested changes, asset context, or decisions your team should know.",prompts:["What pages, content, or images still need attention?","What should the team know about brand, tone, or examples?","Which decisions are approved, blocked, or still open?"]},launch:{eyebrow:"Phase 3 / Launch",heading:()=>"Prepare the site to go live",description:"Add domain notes, timing preferences, DNS access details, final checks, and anything Bliss should confirm before launch.",placeholder:"Write launch notes, timing preferences, DNS details, or final instructions.",prompts:["Which domain should be primary?","Who has access to DNS or registrar accounts?","Are there final launch timing preferences or blockers?"]},grow:{eyebrow:"Phase 4 / Grow",heading:()=>"Capture growth ideas for after launch",description:"Add SEO ideas, content updates, campaigns, new offers, conversion goals, and improvements to revisit once the site is live.",placeholder:"Write growth ideas, content updates, SEO goals, or future service opportunities.",prompts:["Which services or locations should grow next?","What content, offers, or campaigns should come after launch?","What would make the site more valuable over time?"]}};function Yt(a){return{collecting:"Collecting notes",submitted:"Submitted for review",drafting:"Plan in progress",published:"Plan ready",accepted:"Tier accepted"}[a]??"Collecting notes"}function Jt(a){return a?new Date(a).toLocaleString():"Not submitted yet"}function us({projectId:a,projectName:m,phaseKey:l,phaseLabel:v,composerRequest:E=0}){const[F,d]=n.useState([]),[A,j]=n.useState(null),[g,W]=n.useState(!0),[ae,x]=n.useState(!1),[M,q]=n.useState(!1),[B,w]=n.useState(null),[te,we]=n.useState(""),[he,Ne]=n.useState(""),[k,Ie]=n.useState(null),[We,ie]=n.useState(!1),ne=Kt[l],o=l==="plan",b=A?.status!=="collecting",R=n.useMemo(()=>k?F.find(p=>p.id===k)??null:null,[k,F]);n.useEffect(()=>{let p=!1;return(async()=>{try{W(!0),w(null);const N=await Nt(a,l);if(p)return;d(N.data.entries),j(N.data.lifecycle)}catch(N){p||w(N instanceof Error?N.message:"Failed to load planning journal.")}finally{p||W(!1)}})(),()=>{p=!0}},[a,l]),n.useEffect(()=>{E>0&&ie(!0)},[E]),n.useEffect(()=>{R&&(we(R.title),Ne(R.body),ie(!0))},[R]);const ge=()=>{Ie(null),we(""),Ne(""),ie(!1)},Xe=async()=>{const p=te.trim(),L=he.trim();if(!(!p||!L||ae))try{if(x(!0),w(null),k)await Ct(a,k,{title:p,body:L}),d(N=>N.map(ke=>ke.id===k?{...ke,title:p,body:L,updated_at_iso:new Date().toISOString()}:ke));else{const N=await kt(a,{phase:l,title:p,body:L});d(ke=>[N.data,...ke]),A||j({project_id:a,status:"collecting",submitted_at:null,submitted_by_name:null,submitted_by_email:null,published_proposal_id:null,selected_tier_id:null,created_at:N.data.created_at,updated_at:N.data.updated_at,submitted_at_iso:null,created_at_iso:N.data.created_at_iso,updated_at_iso:N.data.updated_at_iso})}ge()}catch(N){w(N instanceof Error?N.message:"Failed to save phase note.")}finally{x(!1)}},Ce=async p=>{if(window.confirm("Remove this phase note?"))try{w(null),await St(a,p),d(L=>L.filter(N=>N.id!==p)),k===p&&ge()}catch(L){w(L instanceof Error?L.message:"Failed to remove phase note.")}},U=async()=>
1{if(!(!o||M||F.length===0))try{q(!0),w(null);const p=await _t(a);j(L=>({...L??{project_id:a,created_at:null,created_at_iso:null,published_proposal_id:null,selected_tier_id:null},...p.data.lifecycle}))}catch(p){w(p instanceof Error?p.message:"Failed to submit planning journal.")}finally{q(!1)}};return g?e.jsxs("section",{className:"site-detail-section",children:[e.jsx("div",{className:"portal-panel-header",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:v}),e.jsx("h3",{children:"Phase notes"})]})}),e.jsx("p",{className:"admin-text-muted",children:"Loading planning journal..."})]}):e.jsxs("div",{className:"site-plan-journal-grid",children:[e.jsxs("section",{className:"site-detail-section site-plan-journal-main",children:[e.jsxs("div",{className:"portal-panel-header",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:ne.eyebrow}),e.jsx("h3",{children:ne.heading(m)}),e.jsx("p",{className:"site-detail-section-desc",children:ne.description})]}),o?e.jsx("span",{className:"status-pill",children:Yt(A?.status??"collecting")}):e.jsx("button",{type:"button",className:"primary",onClick:()=>ie(!0),children:"Add Phase"})]}),B?e.jsx("p",{className:"error-text",children:B}):null,We?e.jsxs("div",{className:"site-plan-journal-composer",children:[e.jsx("input",{type:"text",className:"site-detail-connect-select",value:te,maxLength:180,placeholder:"Short label, e.g. Customer goals, domain timing, homepage notes...",onChange:p=>we(p.target.value)}),e.jsx("textarea",{className:"site-detail-connect-select site-plan-journal-textarea",value:he,rows:8,placeholder:ne.placeholder,onChange:p=>Ne(p.target.value)}),e.jsxs("div",{className:"site-plan-journal-actions",children:[e.jsx("button",{type:"button",className:"ghost",onClick:ge,children:k?"Cancel edit":"Cancel"}),e.jsx("button",{type:"button",className:"primary",disabled:ae||!te.trim()||!he.trim(),onClick:Xe,children:ae?"Saving...":k?"Save changes":"Add Phase"})]})]}):e.jsxs("button",{type:"button",className:"site-plan-journal-add-card",onClick:()=>ie(!0),children:[e.jsx("span",{children:"+"}),e.jsx("strong",{children:"Add Phase"}),e.jsx("small",{children:"Write what you are thinking about this phase."})]}),e.jsx("div",{className:"site-plan-journal-entries",children:F.length===0?e.jsx("p",{className:"admin-text-muted",children:"No phase notes yet."}):F.map(p=>e.jsxs("article",{className:"site-plan-journal-entry",children:[e.jsxs("div",{children:[e.jsx("strong",{children:p.title}),e.jsx("p",{children:p.body}),e.jsxs("small",{children:["Updated ",p.updated_at_iso?new Date(p.updated_at_iso).toLocaleString():"recently"]})]}),e.jsxs("div",{className:"site-plan-journal-entry-actions",children:[e.jsx("button",{type:"button",className:"portal-link",onClick:()=>Ie(p.id),children:"Edit"}),e.jsx("button",{type:"button",className:"portal-link danger",onClick:()=>void Ce(p.id),children:"Remove"})]})]},p.id))})]}),e.jsxs("aside",{className:"site-detail-section site-plan-journal-side",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Next step"}),e.jsx("h3",{children:o?b?"Staff review is underway":"Submit when the notes feel complete":"Keep adding context as the phase moves"}),e.jsx("p",{className:"site-detail-section-desc",children:o?b?"Bliss will turn this into a staff-reviewed plan with three tiers, ROI framing, budget range, final prices, agreement, and payment.":"Your journal stays editable. Submit it when it has enough context for Bliss to draft the formal plan.":"These notes help your account manager keep the project moving with the right context, decisions, and follow-ups."})]}),e.jsx("div",{className:"site-plan-prompt-list",children:ne.prompts.map(p=>e.jsx("span",{children:p},p))}),o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"site-plan-review-box",children:[e.jsx("strong",{children:"Submitted"}),e.jsx("span",{children:Jt(A?.submitted_at_iso??null)})]}),e.jsx("button",{type:"button",className:"primary",disabled:M||F.length===0,onClick:()=>void U(),children:M?"Submitting...":b?"Resubmit updated journal":"Submit for review"}),e.jsx(V,{to:"/dashboard/proposal-agreements",className:"ghost site-plan-proposal-link",children:"View proposal agreements"})]}):null]})]})}function Ga(a){if(!Number.isFinite(a)||a<=0)return"0 B";const m=["B","KB","MB","GB","TB"];let l=a,v=0;for(;l>=1024&&v<m.length-1;)l/=1024,v+=1;return`${l>=10||v===0?l.toFixed(0):l.toFixed(1)} ${m[v]}`}function Qt(a){const m=new Date(a);
1return Number.isNaN(m.getTime())?"Unknown":m.toLocaleString()}function Zt({projectId:a}){const{session:m}=Pt(),[l,v]=n.useState([]),[E,F]=n.useState(null),[d,A]=n.useState(!0),[j,g]=n.useState(null),[W,ae]=n.useState(""),[x,M]=n.useState(""),[q,B]=n.useState(!1),[w,te]=n.useState(null),[we,he]=n.useState(null);async function Ne(){const[o,b]=await Promise.all([Wa(a),Zs(a)]);v(o.data?.objects??[]),F(b.data??null)}n.useEffect(()=>{let o=!1;return(async()=>{try{A(!0),g(null);const[R,ge]=await Promise.all([Wa(a),Zs(a)]);if(o)return;v(R.data?.objects??[]),F(ge.data??null)}catch(R){if(o)return;console.error("Failed to load project files",R),g(R instanceof Error?R.message:"Failed to load R2 storage and files")}finally{o||A(!1)}})(),()=>{o=!0}},[a]);const k=n.useMemo(()=>{const o=W.trim().toLowerCase();return o?l.filter(b=>b.key.toLowerCase().includes(o)||b.file_name.toLowerCase().includes(o)||b.folder.toLowerCase().includes(o)||String(b.content_type||"").toLowerCase().includes(o)):l},[l,W]),Ie=n.useMemo(()=>k.reduce((o,b)=>o+Number(b.size||0),0),[k]),We=m?.role==="client"?m.clientRole==="owner"||m.clientRole==="billing"||!m.clientRole:!!E?.can_manage;async function ie(o){const b=Array.from(o.target.files||[]);if(b.length)try{B(!0),te(null),await Et(a,{files:b,folder:x.trim()||void 0}),await Ne(),o.target.value=""}catch(R){console.error("Failed to upload project files",R),te(R instanceof Error?R.message:"Failed to upload files")}finally{B(!1)}}async function ne(o){try{he(o),te(null),await At(a,o),await Ne()}catch(b){console.error("Failed to delete project file",b),te(b instanceof Error?b.message:"Failed to delete file")}finally{he(null)}}return e.jsxs("section",{className:"site-detail-section",children:[e.jsxs("div",{className:"portal-panel-header",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Uploads"}),e.jsx("h3",{children:"Project files"})]}),e.jsxs("span",{className:"portal-inline-note",children:[k.length," file",k.length===1?"":"s"," / ",Ga(Ie)]})]}),e.jsx("p",{className:"site-detail-section-desc",children:"Upload logos, photos, copy, examples, and other assets your account manager should use during the build."}),e.jsxs("div",{className:"site-files-toolbar",children:[e.jsxs("label",{className:"site-files-search",children:[e.jsx(_,{name:"search",size:16}),e.jsx("input",{type:"search",value:W,onChange:o=>ae(o.target.value),placeholder:"Search files or folders"})]}),We?e.jsxs("div",{className:"site-files-upload-controls",children:[e.jsxs("label",{className:"site-files-storage-input site-files-folder-input",children:[e.jsx("span",{children:"Folder"}),e.jsx("input",{type:"text",value:x,onChange:o=>M(o.target.value),placeholder:"Optional folder path"})]}),e.jsxs("label",{className:"btn-primary site-files-upload-button",children:[q?"Uploading...":"Add files",e.jsx("input",{type:"file",multiple:!0,onChange:ie,disabled:q})]})]}):null]}),w?e.jsx("p",{className:"error-text",children:w}):null,d?e.jsx("p",{className:"admin-text-muted",children:"Loading files..."}):null,!d&&j?e.jsx("p",{className:"error-text",children:j}):null,!d&&!j&&k.length===0?e.jsx("p",{className:"admin-text-muted",children:l.length===0?"No project files have been uploaded yet.":"No files match that search."}):null,!d&&!j&&k.length>0?e.jsx("div",{className:"site-files-table-wrap",children:e.jsxs("table",{className:"site-files-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Folder"}),e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Size"}),e.jsx("th",{children:"Uploaded"}),e.jsx("th",{children:"Action"})]})}),e.jsx("tbody",{children:k.slice().sort((o,b)=>o.key.localeCompare(b.key)).map(o=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("div",{className:"site-files-name",children:[e.jsx("span",{className:"site-files-name-icon",children:e.jsx(_,{name:"storage",size:16})}),e.jsxs("div",{children:[e.jsx("strong",{children:o.file_name}),e.jsx("span",{className:"site-files-key",children:o.key})]})]})}),e.jsx("td",{children:o.folder||"Root"}),e.jsx("td",{children:o.content_type||"Unknown"}),e.jsx("td",{children:Ga(o.size)}),e.jsx("td",{children:Qt(o.uploaded)}),e.jsx("td",{children:e.jsxs("div",{className:"site-files-actions",children:[e.jsx("a",{className:"portal-link",href:Lt(a,o.key),target:"_blank",rel:"noreferrer",children:"Open"}),We?e.jsx("button",{type:"button",className:"btn-ghost danger",onClick:()=>void ne(o.key),disabled:we===o.key,children:we===o.key?"Deleting...":"Delete"}):null]})})]},`${o.key}:${o.etag}`))})]})}):null]})}const Oe=a=>
1a.toLocaleString("en-US"),Ze=a=>new Date(a).toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:"UTC"});function hs({title:a,rows:m}){return e.jsxs("section",{className:"traffic-breakdown","aria-label":a,children:[e.jsxs("div",{className:"traffic-list-heading",children:[e.jsx("h4",{children:a}),e.jsx("span",{children:"Page views"})]}),m.length?e.jsx("ul",{className:"site-overview-list",children:m.map((l,v)=>e.jsxs("li",{className:"site-overview-row",children:[e.jsx("span",{children:l.label}),e.jsx("strong",{children:Oe(l.page_views)})]},`${l.label}-${v}`))}):e.jsx("p",{className:"site-detail-section-desc",children:"No activity recorded for this period."})]})}function Xt({projectId:a}){const[m,l]=n.useState(30),[v,E]=n.useState(0),[F,d]=n.useState({key:"",loading:!0}),A=`${a}:${m}:${v}`,j=F.key===A?F:{loading:!0};n.useEffect(()=>{const x=new AbortController;let M=!1;const q=setTimeout(()=>x.abort(),35e3);return d({key:A,loading:!0}),Rt(`/api/client-portal/projects/${encodeURIComponent(a)}/cloudflare-analytics?days=${m}`,{signal:x.signal}).then(B=>{M||d({key:A,loading:!1,data:B.data})}).catch(B=>{if(M)return;const w=B?.response?.status;d({key:A,loading:!1,unauthorized:w===401,error:w===401?"Your session has ended. Sign in again to view this report.":w===403?"You do not have access to this site's analytics. 
1Contact your Bliss team.":"We couldn't load website traffic. Check your connection and try again."})}).finally(()=>clearTimeout(q)),()=>{M=!0,clearTimeout(q),x.abort()}},[a,m,A]);const g=j.data?.status==="ready"?j.data.report:null,W=Math.max(1,...g?.daily.map(x=>x.page_views)||[]),ae=g?.daily.map((x,M)=>`${M*600/(g.daily.length-1)},${150-x.page_views/W*140}`).join(" ");return e.jsxs("section",{className:"traffic-report","aria-label":"Website traffic",children:[e.jsxs("div",{className:"portal-panel-header traffic-header",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Cloudflare Web Analytics"}),e.jsx("h3",{children:"Website traffic"})]}),e.jsxs("div",{className:"traffic-controls",children:[e.jsxs("label",{children:["Period ",e.jsxs("select",{value:m,onChange:x=>l(Number(x.target.value)),children:[e.jsx("option",{value:7,children:"Last 7 complete days"}),e.jsx("option",{value:30,children:"Last 30 complete days"})]})]}),e.jsx("button",{className:"ghost",type:"button",disabled:j.loading,onClick:()=>E(x=>x+1),children:"Refresh"})]})]}),e.jsxs("div",{className:"traffic-content","aria-busy":j.loading,children:[j.loading?e.jsx("p",{className:"portal-surface-state",role:"status",children:"Loading website traffic…"}):null,j.error?e.jsxs("div",{className:"portal-surface-state",role:"alert",children:[e.jsx("span",{children:j.error}),j.unauthorized?e.jsx("a",{href:`/login?returnTo=${encodeURIComponent(window.location.pathname+window.location.search)}`,children:"Sign in"}):e.jsx("button",{className:"ghost",type:"button",onClick:()=>E(x=>x+1),children:"Try again"})]}):null,j.data?.status==="setup_required"?e.jsx("p",{className:"portal-surface-state",role:"status",children:j.data.message}):null,g?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"site-detail-section-desc",children:[Ze(g.from)," – ",Ze(new Date(Date.parse(g.to)-864e5).toISOString())," · Complete days, UTC",e.jsx("br",{}),g.hosts.join(", ")]}),e.jsxs("div",{className:"site-detail-grow-metrics",children:[e.jsxs("div",{className:"site-detail-grow-metric",children:[e.jsx("span",{className:"meta",children:"Page views"}),e.jsx("strong",{children:Oe(g.totals.page_views)})]}),e.jsxs("div",{className:"site-detail-grow-metric",children:[e.jsx("span",{className:"meta",children:"Visits"}),e.jsx("strong",{children:Oe(g.totals.visits)})]}),e.jsxs("div",{className:"site-detail-grow-metric",children:[e.jsx("span",{className:"meta",children:"Page load time · 75th percentile"}),e.jsx("strong",{children:g.page_load_seconds_p75===null?"Not available":`${g.page_load_seconds_p75.toLocaleString("en-US",{maximumFractionDigits:2})} s`})]})]}),g.totals.page_views===0?e.jsx("p",{className:"portal-surface-state",role:"status",children:"No page views were recorded in this period. If tracking was recently enabled, check back after a complete day of visits."}):e.jsxs(e.Fragment,{children:[e.jsxs("figure",{className:"traffic-chart",children:[e.jsxs("figcaption",{children:["Daily page views ",e.jsxs("span",{children:["Peak ",Oe(W)]})]}),e.jsxs("svg",{viewBox:"0 0 600 160",role:"img","aria-label":`Daily page views over ${g.period_days} days. Exact values are available in the daily data table below.`,children:[e.jsx("line",{x1:"0",y1:"150",x2:"600",y2:"150",className:"traffic-chart-baseline"}),e.jsx("polyline",{points:ae,fill:"none",stroke:"currentColor",strokeWidth:"3",vectorEffect:"non-scaling-stroke"})]}),e.jsxs("div",{className:"traffic-chart-labels",children:[e.jsx("span",{children:Ze(g.from)}),e.jsx("span",{children:Ze(g.daily[g.daily.length-1].date)})]})]}),e.jsxs("details",{className:"traffic-daily",children:[e.jsx("summary",{children:"View daily figures"}),e.jsxs("table",{children:[e.jsx("caption",{children:"Daily traffic · UTC"}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Date"}),e.jsx("th",{scope:"col",children:"Page views"}),e.jsx("th",{scope:"col",children:"Visits"})]})}),e.jsx("tbody",{children:g.daily.map(x=>e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:Ze(x.date)}),e.jsx("td",{children:Oe(x.page_views)}),e.jsx("td",{children:Oe(x.visits)})]},x.date))})]})]})]}),e.jsxs("div",{className:"traffic-breakdowns",children:[e.jsx(hs,{title:"Top pages",rows:g.pages}),e.jsx(hs,{title:"Referring websites",rows:g.referrers}),e.jsx(hs,{title:"Devices",rows:g.devices}),e.jsx(hs,{title:"Countries",rows:g.countries})]}),e.jsxs("p",{className:"site-detail-section-desc traffic-method",children:[g.sampled?"These figures are estimates based on sampled traffic. ":"","Known bots are excluded. Visits count arrivals from outside this website, including direct arrivals; they are not unique people. A page load time of ",g.page_load_seconds_p75===null?"“Not available” means there are not enough measurements or performance reporting is unavailable.":`${g.page_load_seconds_p75.toLocaleStr
1ing("en-US",{maximumFractionDigits:2})} seconds means 75% of measured loads were this fast or faster.`]}),e.jsxs("p",{className:"site-detail-section-desc",children:["Updated ",new Date(g.generated_at).toLocaleString("en-US"),j.data?.status==="ready"&&j.data.cached?" · Saved report (up to 5 minutes old)":""]})]}):null]})]})}const Ys=[{slug:"commerce-storefront-template",productId:"prod-commerce-storefront-template",label:"Launch Store",price:"$39/mo",priceCents:3900,billingInterval:"monthly",body:"Catalog, cart, checkout, orders, shipping settings, and 5 GB media storage."},{slug:"commerce-storefront-growth",productId:"prod-commerce-storefront-growth",label:"Growth Store",price:"$79/mo",priceCents:7900,billingInterval:"monthly",body:"Adds customer accounts, subscriptions, wholesale, promo codes, and 20 GB media storage."},{slug:"commerce-storefront-ai-assisted",productId:"prod-commerce-storefront-ai-assisted",label:"AI Assisted Store",price:"$149/mo",priceCents:14900,billingInterval:"monthly",body:"Growth Store plus monthly AI credits for content, store review, and reply drafts."}],en={enabled:!1,variant:"coming_soon",title:"",message:"",passwordProtected:!1};function sn(a){return{enabled:a?.enabled===!0,variant:a?.variant==="maintenance"?"maintenance":"coming_soon",title:typeof a?.title=="string"?a.title:"",message:typeof a?.message=="string"?a.message:"",passwordProtected:a?.password_protected===!0}}function an(a){return a.enabled?a.variant==="maintenance"?"Maintenance Mode":"Coming Soon":"Live Site"}const tn=[["/templates/commerce/",5180],["/templates/funeral-home/",5181],["/templates/creator-portfolio/",5182],["/templates/nonprofit/",5184],["/templates/wellness-therapy/",5185],["/templates/affiliate/",5186],["/templates/amazon-growth/",5187],["/templates/home-services/",5188]];function nn(){return typeof window<"u"&&/^(127\.0\.0\.1|localhost)$/.test(window.location.hostname)}function ln(a){if(!nn()||!a.startsWith("/templates/"))return a;const m=tn.find(([l])=>a.startsWith(l));return m?`http://127.0.0.1:${m[1]}${a}`:a}function rn(a){return a?a.previewUrl?ln(a.previewUrl):a.liveUrl?a.liveUrl:a.deploySourceType==="cloudflare_pages"&&a.cloudflarePagesProject?`https://${a.cloudflarePagesProject}.pages.dev`:`/site-preview/${encodeURIComponent(a.id)}`:""}const on=[{id:"plan",label:"Plan"},{id:"design",label:"Design"},{id:"development",label:"Development"},{id:"qa",label:"QA"},{id:"publish",label:"Publish"}],gs=[{id:"plan",label:"Plan",icon:"spark",description:"Capture business context and turn it into a staff-reviewed plan."},{id:"build",label:"Build",icon:"projects",description:"Share assets, feedback, decisions, and account manager updates."},{id:"launch",label:"Launch",icon:"domains",description:"Handle domains, readiness, and self-service publishing."},{id:"grow",label:"Grow",icon:"analytics",description:"Collect SEO, analytics, c
1onversion, and future growth ideas."}],fs=[{value:"clean",label:"Clean",description:"Minimal storefront styling with calm contrast.",primaryColor:"#0b2135",accentColor:"#0f8f88"},{value:"bold",label:"Bold",description:"Stronger color contrast for a sharper retail feel.",primaryColor:"#1d2557",accentColor:"#f97316"},{value:"luxury",label:"Luxury",description:"Deeper tones with a premium warm accent.",primaryColor:"#172033",accentColor:"#d6a94a"},{value:"playful",label:"Playful",description:"Softer baby-retail colors with a friendly feel.",primaryColor:"#5b4b8a",accentColor:"#f5a6c8"},{value:"custom",label:"Custom",description:"Use exact brand colors.",primaryColor:"#0b2135",accentColor:"#0f8f88"}],cn={pages:{eyebrow:"Page content",title:"Edit store pages",body:"This will become a focused page-content modal. For now, open the full editor to update homepage and supporting pages.",bullets:["Homepage content","Catalog and subscription page text","About, contact, FAQ, and policy copy"]},products:{eyebrow:"Catalog",title:"Review products and categories",body:"This will become the lightweight product manager. For now, use the full editor to review catalog details.",bullets:["Product visibility","Images and descriptions","Prices, stock labels, and category placement"]},contact:{eyebrow:"Store details",title:"Contact and pickup info",body:"This will become the contact, pickup, and map setup modal. For now, open the full editor or launch setup.",bullets:["Support email and phone","Pickup address and hours","Map and domain readiness"]}};function Ha(a){return on.find(l=>l.id===a)?.label??"Plan"}function Re(a){return Number.isFinite(a)?a>0&&a<.01?"<0.01 GB":`${a.toFixed(a>=10?1:2)} GB`:"0 GB"}function De(a){return!Number.isFinite(a)||a<=0?"None":new Intl.NumberFormat("en-US").format(a)}function Va(a){return a==="legacy"?"Legacy family tree":a==="basic"?"Basic family links":"Not included"}function ue(a){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:a%100===0?0:2}).format(a/100)}function Be(a){return a?new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(new Date(a*1e3)):"Not scheduled"}function P(a){return!!(a&&typeof a=="object"&&!Array.isArray(a))}function Ka(a){if(!P(a)||!Array.isArray(a.completedSteps))return new Set;const m=new Set(["brand","content","apps","domain","publish"]);return new Set(a.completedSteps.filter(l=>m.has(l)))}function dn(a){return fs.some(m=>m.value===a)?a:"clean"}function Ya(a,m){return typeof a=="string"&&/^#[0-9a-fA-F]{6}$/.test(a)?a:m}function Js(a,m){const l=P(a?.config)?a?.config??{}:{},v=P(l.brand)?l.brand:{};return{storeName:typeof l.storeName=="string"&&l.storeName.trim()?l.storeName:m,tagline:typeof l.tagline=="string"?l.tagline:"",logoUrl:typeof l.logoUrl=="string"?l.logoUrl:"",palette:dn(v.palette),primaryColor:Ya(v.primaryColor,"#0b2135"),accentColor:Ya(v.accentColor,"#0f8f88")}}function Qs(a){const m=P(a?.config)?a?.config??{}:{},l=P(m.homepage)?m.homepage:{};return{heroSubtitle:typeof l.heroSubtitle=="string"?l.heroSubtitle:"",heroTitle:typeof l.heroTitle=="string"?l.heroTitle:"",heroBody:typeof l.heroBody=="string"?l.heroBody:"",primaryCtaLabel:typeof l.primaryCtaLabel=="string"?l.primaryCtaLabel:"",secondaryCtaLabel:typeof l.secondaryCtaLabel=="string"?l.secondaryCtaLabel:"",heroImageUrl:typeof l.heroImageUrl=="string"?l.heroImageUrl:""}}function un(){const{projectId:a}=Dt(),m=Ft(),[l,v]=n.useState(null),[E,F]=n.useState([]),[d,A]=n.useState(null),[j,g]=n.useState(!1),[W,ae]=n.useState([]),[x,M]=n.useState(""),[q,B]=n.useState(!1),[w,te]=n.useState(en),[we,he]=n.useState(!1),[Ne,k]=n.useState(""),[Ie,We]=n.useState(!1),[ie,ne]=n.useState(null),[o,b]=n.useState([]),[R,ge]=n.useState(!0),[Xe,Ce]=n.useState(null),[U,p]=n.useState(!1),[L,N]=n.useState(null),[ke,Xs]=n.useState(!1),[xs,js]=n.useState(null),[qe,bs]=n.useState([]),[ea,sa]=n.useState(!1),[ze,ys]=n.useState(""),[Ge,aa]=n.useState(!1),[vs,ta]=n.useState(!1),[Ja,na]=n.useState(""),[ws,ia]=n.useState(""),[le,Ns]=n.useState(null),[Cs,la]=n.useState(!1),[ra,ks]=n.useState(null),[oa,Qa]=n.useState(1),[Ss,ca]=n.useState(!1),[da,es]=n.useState(null),[K,z]=n.useState("template"),[fe,ma]=n.useState(null),[Za,pa]=n.useState(!1),[ua,_s]=n.useState(null),[ss]=n.useState(0),[f,Se]=n.useState(null),[Q,Fe]=n.useState(null),[ha,ga]=n.useState(null),[G,Ps]=n.useState(null),[fa,Ls]=n.useState([]),[D,Es]=n.useState(null),[re,as]=n.useState(""),[xa,ja]=n.useState(!1),[As,ba]=n.useState(!1),[ya,ts]=n.useState(null),[va,xe]=n.useState(null),[S,Rs]=n.useState(null),[wa,Ds]=n.useState(null),[Xa,He]=n.useState(!1),[Na,Ca]=n.useState(""),[Ue,ka]=n.useState(!1),[Sa,ns]=n.useState(null),[H,Fs]=n.useState(null),[u,Us]=n.useState(()=>Js(null,"")),[y,Ts]=n.useState(()=>Qs(null)),[$s,_a]=n.useState(null),[Z,is]=n.useState(!1),[oe,ls]=n.useState(!1),[rs,Y]=n.useState(null),[os,je]=n.useState(null),[Ms,Pa]=n.useState(null),[La,Ea]=n.useState(null),Bs=n.useRef(null),c=l?.apps?.find(s=>
1s.id===a),Ve=ie??"plan",et=rn(c),O=c?.siteType==="template"||!!f,X=et,Aa="View site",Te=async()=>{if(!a||U)return;const s=window.open("","_blank");p(!0);try{const t=await $t(a);s?(s.opener=null,s.location.href=t.data.launch_url):window.open(t.data.launch_url,"_blank","noopener,noreferrer")}catch(t){s?.close(),Ce(t instanceof Error?t.message:"Failed to open site admin")}finally{p(!1)}},Ra=O&&c?.status==="Demo",Da=s=>{if(!a||!c)return;const t=Ys.find(r=>r.slug===s);if(!t)return;const i={id:t.productId,name:t.label,slug:t.slug,category_name:"Baby retail",price_cents:t.priceCents,billing_interval:t.billingInterval,description:`Activate ${c.name} from private demo to live storefront.`,quantity:1,metadata:{activation_project_id:a,site_name:c.name}};Mt([i]),m("/dashboard/checkout")},st=async()=>{if(!(!a||j))try{g(!0),Ce(null);const s=await fetch(`/api/client-portal/projects/${encodeURIComponent(a)}/launch-checkout`,{method:"POST",credentials:"include"}),t=await s.json().catch(()=>null);if(!s.ok||t?.success===!1)throw new Error(t?.error?.message||"Unable to start launch checkout");t?.data?.checkoutUrl?window.location.assign(t.data.checkoutUrl):m(t?.data?.invoiceUrl||"/dashboard/invoices")}catch(s){Ce(s instanceof Error?s.message:"Unable to start launch checkout")}finally{g(!1)}},Fa=()=>{c&&(Ca(c.name),ns(null),He(!0))},at=async s=>{if(s.preventDefault(),!a||Ue)return;const t=Na.replace(/\s+/g," ").trim();if(!t){ns("Enter a site name.");return}try{ka(!0),ns(null);const r=(await Vt(a,t)).data.project.name;v(h=>h&&{...h,apps:h.apps.map(se=>se.id===a?{...se,name:r}:se)}),He(!1)}catch(i){ns(i instanceof Error?i.message:"Failed to rename site.")}finally{ka(!1)}},Ua=O?gs.filter(s=>s.id!=="plan"):gs,tt=gs.some(s=>s.id===K)&&!(O&&K==="plan")?K:Ve,cs=Ua.find(s=>s.id===tt)??Ua[0]??gs[0],Os=E.some(s=>s.status==="Connected"),T=E.length>0,ce=l?.stripeSummary?.hasConnectedAccount===!0,I=!!f?.published_at,$=f?.template_key?.startsWith("nonprofit-")||P(f?.config)&&f?.config?.templateFamily==="nonprofit"||P(f?.config)&&f?.config?.sourceProductSlug==="community-nonprofit-template"||/nonprofit/i.test(c?.name??""),ee=f?.template_key==="funeral-home-memorial"||P(f?.config)&&String(f.config.sourceProductSlug||"").includes("funeral-home")||/funeral|memorial/i.test(c?.name??""),J=f?.template_key==="wellness-therapy"||P(f?.config)&&String(f.config.sourceProductSlug||"").includes("wellness-therapy")||/wellness|therapy/i.test(c?.name??""),Is=ee?"obituary platform":J?"wellness site":$?"site":"storefront",Ta=ee?"Obituary platform":J?"Wellness site":$?"Site":"Storefront",$e=ee?"Open staff dashboard":J?"Open Wellness Studio":"Open site admin",Me=ee?{eyebrow:"Obituary platform setup",title:"Set up your obituary platform",body:"Customize service pages, planning intake, obituary content, family care paths, and launch details.",previewLabel:"Preview platform",liveDraftLabel:"Live obituary draft",helpBody:"Send a support request when you want help with content, obituaries, domains, or launch timing."}:J?{eyebrow:"Wellness site setup",title:"Set up your wellness site",body:"Customize treatments, paid offers, booking details, memberships, resources, and launch readiness.",previewLabel:"Preview wellness site",liveDraftLabel:"Live wellness draft",helpBody:"Send a support request when you want help with treatment copy, booking, checkout, domains, or launch timing."}:$?{eyebrow:"Nonprofit site setup",title:"Set up your nonprofit site",body:"Customize programs, donation prompts, volunteer paths, events, updates, and launch details.",previewLabel:"Preview site",liveDraftLabel:"Live nonprofit draft",helpBody:"Send a support request when you want help with content, donations, domains, or launch timing."}:{eyebrow:"Storefront setup",title:"Set up your storefront",body:"Customize the template, review Page Content, connect checkout, and prepare this store for launch.",previewLabel:"Preview storefront",liveDraftLabel:"Live draft",helpBody:"Send a support request when you want help with content, checkout, domains, or launch timing."},be=Q?.recurring_plan??null,nt=be?`${ue(be.amount_cents)}/${be.billing_interval==="yearly"?"yr":"mo"}`:"Invoice managed",it=be?`${be.status}${be.last_charge_status?`, last charge ${be.last_charge_status}`:""}`:"No recurring plan",ye=P(f?.config)?f.config:{},lt=String(ye.templateAccessMode||ye.accessMode||"").trim().toLowerCase(),$a=String(ye.publishState||"").trim().toLowerCase(),Ws=c?.status==="Live"||lt==="paid"||$a==="live_ready"||$a==="live",ve=P(ye.commerce)?ye.commerce:{},Ma=P(ye.contact)?ye.contact:{},Ke=ha?.totals.allocated_gb??0,qs=ha?.totals.used_gb??0,rt=Math.max(0,Ke-qs),Ba=Ke>0?Math.min(100,Math.round(qs/Ke*100)):0,C=async s=>{if(Fs(s),Y(null),je(null),s==="brand"&&Us(Js(f,c?.name??"")),s==="pages"&&Ts(Qs(f)),!(s!=="brand"&&s!=="pages")&&a)try{const t=await Vs(a,{lock:"acquire"});Se(t.data.template_site),Fe(t.data.template??null),_a(t.data.editor_lock??null),s==="brand"&&Us(Js(t.data.template_site,c?.name??"")),s==="pages"&&Ts(Qs(t.data.template_site)),t.data.permissions?.can_edit===!1&&Y("This template is locked for editing right now.")}catch(t){Y(t instanceof Error?t.message:"Failed to open setup editor.")}},Ye=()=>{Z||oe||(Fs(null),Y(null),je(null))},de=s=>{Us(t=>({...t,...s})),je(null)},_e=s=>{Ts(t=>({...t,...s})),je(null)},ot=s=>{const t=fs.find(i=>i.value===s);de({palette:s,...t&&t.value!=="custom"?{primaryColor:t.primaryColor,accentColor:t.accentColor}:{}})},ct=async s=>{if(!(!a||!s)){ls(!0),Y(null);try{const t=await qa(a,s);de({logoUrl:t.data.asset.url}),je("Logo uploaded.")}catch(t){Y(t instanceof Error?t.message:"Logo upload failed.")}finally{ls(!1)}}},dt=async s=>{if(!(!a||!s)){ls(!0),Y(null);try{const t=await qa(a,s);_e({heroImageUrl:t.data.asset.url}),je("Hero image uploaded.")}catch(t){Y(t instanceof Error?t.message:"Hero image upload failed.")}finally{ls(!1)}}},mt=async()=>
1{if(!(!a||!f||Z)){is(!0),Y(null);try{const s=P(f.config)?f.config:{},t=P(s.brand)?s.brand:{},i={...s,storeName:u.storeName.trim()||c?.name||(J?"Wellness Studio":$?"Nonprofit Site":"Storefront"),tagline:u.tagline.trim(),logoUrl:u.logoUrl.trim(),brand:{...t,palette:u.palette,primaryColor:u.primaryColor,accentColor:u.accentColor}},r=await Ks(a,{template_key:f.template_key||(J?"wellness-therapy":"commerce-default"),template_version:f.template_version||(J?"wellness-therapy@1":"commerce-default@1"),status:f.status==="published"?"preview":f.status,config:i},{lockToken:$s?.token});Se(r.data.template_site),Fe(r.data.template??null),je("Brand draft saved.")}catch(s){Y(s instanceof Error?s.message:"Failed to save brand draft.")}finally{is(!1)}}},pt=async()=>{if(!(!a||!f||Z)){is(!0),Y(null);try{const s=P(f.config)?f.config:{},t=P(s.homepage)?s.homepage:{},i={...s,homepage:{...t,heroSubtitle:y.heroSubtitle.trim(),heroTitle:y.heroTitle.trim(),heroBody:y.heroBody.trim(),primaryCtaLabel:y.primaryCtaLabel.trim(),secondaryCtaLabel:y.secondaryCtaLabel.trim(),heroImageUrl:y.heroImageUrl.trim()}},r=await Ks(a,{template_key:f.template_key||(J?"wellness-therapy":ee?"funeral-home-memorial":"commerce-default"),template_version:f.template_version||(J?"wellness-therapy@1":ee?"funeral-home-memorial@1":"commerce-default@1"),status:f.status==="published"?"preview":f.status,config:i},{lockToken:$s?.token});Se(r.data.template_site),Fe(r.data.template??null),je("Homepage draft saved.")}catch(s){Y(s instanceof Error?s.message:"Failed to save homepage draft.")}finally{is(!1)}}},ut=ee?[{icon:"spark",title:"Brand and logo",body:"Review the funeral home name, logo, colors, and message families will see.",status:"Ready",action:"Edit setup",onClick:()=>void C("brand")},{icon:"book",title:"Service pages",body:"Edit homepage, services, planning, obituary pages, family care, and contact content.",status:I?"Published":"Draft",action:"Edit pages",onClick:()=>void C("pages")},{icon:"catalog",title:"Obituaries",body:"Review obituary paths, tribute collection, and staff-facing obituary workflows.",status:"Review",action:"Review content",onClick:()=>void C("products")},{icon:"domains",title:"Contact and launch info",body:"Confirm phone, location, immediate-need routing, map settings, and domain readiness.",status:T?"Connected":"Needs domain",action:T?"Review launch":"Connect domain",onClick:()=>void C("contact")}]:J?[{icon:"spark",title:"Brand and logo",body:"Review the wellness practice name, logo, colors, and message new clients will see.",status:"Ready",action:"Edit setup",onClick:()=>void C("brand")},{icon:"book",title:"Treatment pages",body:"Edit homepage copy, treatment pathways, practitioner details, resources, and contact content.",status:I?"Published":"Draft",action:"Edit pages",onClick:()=>void C("pages")},{icon:"catalog",title:"Paid offers",body:"Review consultations, wellness packages, digital guides, checkout readiness, and membership options.",status:ce?"Payments ready":"Needs payments",action:"Review offers",onClick:()=>void C("products")},{icon:"domains",title:"Booking and launch info",body:"Confirm booking URL, phone, email, location, domain readiness, and client inquiry routing.",status:T?"Connected":"Needs domain",action:T?"Review launch":"Connect domain",onClick:()=>void C("contact")}]:$?[{icon:"spark",title:"Brand and logo",body:"Review the organization name, logo, colors, and tagline visitors will see.",status:"Ready",action:"Edit setup",onClick:()=>void C("brand")},{icon:"book",title:"Page Content",body:"Edit homepage copy, programs, impact proof, events, donation prompts, volunteer paths, and updates.",status:I?"Published":"Draft",action:"Edit pages",onClick:()=>void C("pages")},{icon:"catalog",title:"Programs and impact",body:"Review service areas, program cards, outcome metrics, and the proof supporters need.",status:"Review",action:"Review content",onClick:()=>void C("products")},{icon:"domains",title:"Contact and launch info",body:"Confirm contact details, service area language, support routing, and domain readiness.",status:T?"Connected":"Needs domain",action:T?"Review launch":"Connect domain",onClick:()=>void C("contact")}]:[{icon:"spark",title:"Brand and logo",body:"Review the store name, logo, colors, and tagline customers will see.",status:"Ready",action:"Edit setup",onClick:()=>void C("brand")},{icon:"book",title:"Page Content",body:"Edit homepage, catalog, subscriptions, wholesale, about, 
1contact, FAQ, and policy pages.",status:I?"Published":"Draft",action:"Edit pages",onClick:()=>void C("pages")},{icon:"catalog",title:"Products and categories",body:"Review catalog visibility, product photos, prices, stock labels, and category pages.",status:"Review",action:"Review catalog",onClick:()=>void C("products")},{icon:"domains",title:"Contact and pickup info",body:"Confirm support details, local pickup, map settings, and domain readiness.",status:T?"Connected":"Needs domain",action:T?"Review launch":"Connect domain",onClick:()=>void C("contact")}],ht=[{label:T?"Domain connected":"Connect a domain",body:T?"Review the connected domain before launch.":"Choose and connect the domain customers will visit.",complete:T,action:()=>z("launch"),actionLabel:T?"Review":"Connect"},{label:ce?$?"Donation path connected":"Checkout connected":$?"Connect donations":"Connect checkout",body:ce?$?"Payment processing is ready for donations and supporter actions.":"Payment processing is ready for storefront orders.":$?"Finish donation setup so supporters can give from the site.":"Finish checkout setup so customers can place orders.",complete:ce,action:()=>z("template"),actionLabel:"Open"},{label:I?`${Ta} published`:"Publish latest draft",body:I?`The latest ${Is} draft has been published.`:"Publish the current draft when content is ready.",complete:I,action:()=>z("template"),actionLabel:I?"View":"Publish"},{label:w.enabled?"Visitor gate is active":"Visitor mode ready",body:w.enabled?"Manage the public visitor gate before launch.":`Public visitors can see the active ${Is}.`,complete:!w.enabled,action:()=>z("launch"),actionLabel:"Manage"}],gt=s=>{const t=new Set(["productCatalog","shipping","customerAccounts","subscriptions","wholesale"]),i=new Set(["stripeConnect","stripePayments","donations"]);if(new Set(["media"]).has(s)){C("brand");return}if(t.has(s)||i.has(s)){C("products");return}C("pages")},Pe=(Q?.plugins??[]).map(s=>{let t="included",i="Included",r="Configure",h="layers";return s.key==="stripeConnect"||s.key==="stripePayments"||s.key==="donations"?(h="billing",t=ce?"active":"setup",i=ce?"Active":"Setup needed",r=ce?"Review":s.key==="donations"?"Connect donations":"Connect payments"):s.key==="productCatalog"?(h="catalog",t="active",i="Active",r="Manage catalog"):s.key==="shipping"?(h="domains",t=ve.shippingMode?"active":"setup",i=ve.shippingMode?"Active":"Setup needed",r="Review shipping"):s.key==="subscriptions"?(h="activity",t=ve.subscriptionsEnabled===!0?"active":"setup",i=ve.subscriptionsEnabled===!0?"Active":"Setup needed",r="Configure subscriptions"):s.key==="wholesale"?(h="handshake",t=ve.wholesaleEnabled===!0?"active":"setup",i=ve.wholesaleEnabled===!0?"Active":"Setup needed",r="Configure wholesale"):s.key==="customerAccounts"?(h="clients",t=ve.customerAccountsEnabled===!1?"setup":"active",i=ve.customerAccountsEnabled===!1?"Setup needed":"Active",r="Review accounts"):s.key==="blogging"?(h="book",r="Edit posts"):s.key==="seo"?(h="search",r="Review SEO"):s.key==="media"?(h="storage",t="active",i="Active",r="Manage media"):s.key==="policies"?(h="shield",r="Review policies"):s.key==="inquiryForms"?(h="email",t=Ma.email?"active":"setup",i=Ma.email?"Active":"Setup needed",r="Review forms"):s.key==="events"?(h="activity",r="Review events"):s.key==="portfolio"||s.key==="galleries"?(h="grid",r="Edit work"):s.key==="bookings"?(h="tickets",t=ce?"included":"setup",i=ce?"Included":"Setup needed",r="Review bookings"):s.key==="memorials"||s.key==="planning"||s.key==="familyPortal"||s.key==="staffDashboard"||s.key==="carePlans"||s.key==="livestream"?(h=s.key==="livestream"?"activity":"building",r="Review setup"):s.key==="volunteers"&&(h="team",r="Review volunteers"),{key:s.key,label:s.label,description:s.description,status:t,statusLabel:i,actionLabel:r,icon:h,onClick:()=>gt(s.key)}}),zs=Ka(ye.firstRunOnboarding),ds=Pe.filter(s=>s.status==="setup").length,Le=[{id:"brand",title:"Brand basics",body:"Confirm business name, logo, colors, and the first impression visitors will see.",actionLabel:"Edit brand",complete:zs.has("brand"),icon:"spark",onAction:()=>void C("brand")},{id:"content",title:"Page content",body:"Review starter copy and replace the most important page sections with business-s
1pecific content.",actionLabel:"Edit content",complete:zs.has("content"),icon:"book",onAction:()=>void C("pages")},{id:"apps",title:"Apps and features",body:ds>0?`${ds} installed app${ds===1?"":"s"} still need setup.`:"Installed apps are ready for launch review.",actionLabel:"Open apps",complete:zs.has("apps")||Pe.length>0&&ds===0,icon:"layers",onAction:()=>{const s=Pe.find(t=>t.status==="setup")??Pe[0];s&&s.onClick()}},{id:"domain",title:"Domain",body:T?"A domain is connected for this site.":"Connect the domain visitors will use.",actionLabel:T?"Review domain":"Connect domain",complete:T,icon:"domains",onAction:()=>z("launch")},{id:"publish",title:"Publish",body:I?"The latest draft has been published.":"Publish the current draft when the setup is ready.",actionLabel:I?"View publish state":"Open publish",complete:I,icon:"globe",onAction:()=>z("template")}],Gs=Le.filter(s=>s.complete).length,ft=Gs===Le.length,xt=async s=>{if(!(!a||!f||Ms))try{Pa(s),Ea(null);const t=await Vs(a,{lock:"acquire",lockToken:$s?.token??void 0}),i=t.data.template_site,r=t.data.editor_lock?.token??null,h=P(i.config)?i.config:{},se=P(h.firstRunOnboarding)?h.firstRunOnboarding:{},Ae=new Set(Ka(se));Ae.add(s);const me=Le.filter(pe=>pe.complete).map(pe=>pe.id);for(const pe of me)Ae.add(pe);const Hs={...h,firstRunOnboarding:{...se,completedSteps:Array.from(Ae),completed:Le.every(pe=>pe.id===s||pe.complete||Ae.has(pe.id)),updatedAt:Math.floor(Date.now()/1e3)}},Qe=await Ks(a,{template_key:i.template_key,template_version:i.template_version,status:i.status,config:Hs},{lockToken:r});Se(Qe.data.template_site),Fe(Qe.data.template??null),_a(t.data.editor_lock??null)}catch(t){Ea(t instanceof Error?t.message:"Failed to save setup progress.")}finally{Pa(null)}},ms=H&&H!=="brand"&&$?{pages:{eyebrow:"Page content",title:"Edit nonprofit pages",body:"Open the full editor to update the homepage, programs, impact, events, donation prompts, volunteer paths, and community updates.",bullets:["Homepage mission copy","Programs and impact sections","Donation, volunteer, events, and update content"]},products:{eyebrow:"Programs and impact",title:"Review programs and impact",body:"Open the full editor to tune program cards, service details, impact metrics, and supporter proof.",bullets:["Program descriptions","Outcome metrics","Supporter and volunteer prompts"]},contact:{eyebrow:"Launch details",title:"Contact and launch info",body:"Open the full editor or launch setup to confirm contact routing, service area notes, domain readiness, and supporter next steps.",bullets:["Contact email and phone","Service area and location notes","Domain and launch readiness"]}}[H]:H&&H!=="brand"&&J?{pages:{eyebrow:"Page content",title:"Edit wellness pages",body:"Open the full editor to update the homepage, treatments, pathways, practitioner bio, resources, memberships, and contact copy.",bullets:["Homepage and treatment copy","Practitioner proof and care philosophy","Resources, memberships, and contact sections"]},products:{eyebrow:"Paid offers",title:"Review paid wellness offers",body:"Open the full editor to tune consultation packages, digital guides, checkout settings, and membership presentation.",bullets:["Consultation and package prices","Stripe checkout readiness","Digital resources and membership copy"]},contact:{eyebrow:"Booking details",title:"Contact and booking info",body:"Open the full editor or launch setup to confirm booking URL, phone, email, location, domain readiness, and inquiry routing.",bullets:["Booking link and contact details","Inquiry form routing","Domain and launch readiness"]}}[H]:H&&H!=="brand"?cn[H]:null,Ee=J?{subline:"Treatments, paid offers, booking, and resources in one calm client path.",category:"Wellness therapy website",headline:"Make natural care easy to understand, book, and pay for.",body:"Present treatments, consultation packages, digital resources, and membership options with a clear next step.",primaryCta:"Book consultation",secondaryCta:"Explore treatments",share:"A polished wellness website with treatment pathways, paid offers, booking, and client inquiries."}:$?{subline:"Connecting neighbors to practical care.",category:"Community services nonprofit",headline:"Make the mission easy to understand and support.",body:"Programs, donations, events, and volunteer opportunities in one clear site.",primaryCta:"Donate now",secondaryCta:"Volunteer",share:"A mission-first nonprofit website for programs, donations, events, and volunteer recruiting."}:{subline:"Diapers, wipes, and everyday baby care delivered.",category:"Premium baby retail storefront",headline:"Baby essentials delivered without the scramble.",body:"Shop trusted diapers, wipes, bundles, and recurring delivery plans.",primaryCta:"Shop all products",secondaryCta:"Explore subscriptions",share:"A polished baby store with product browsing, checkout, and payments."};n.useEffect(()=>{O&&K==="plan"&&z("template")},[K,O]);const Je=async()=>
1{if(a)try{const s=await fetch(`/api/client-portal/projects/${a}/domains`,{credentials:"include"});if(!s.ok)return;const t=await s.json(),i=t.data??t;F(i.connected??i.domains??[]),ae(i.available??[])}catch{F([]),ae([])}};n.useEffect(()=>{if(!a)return;(async()=>{try{ge(!0),Ce(null);const t=await za();if(v(t),!t.apps?.some(me=>me.id===a))return;const[,r,h,se,Ae]=await Promise.all([Je(),fetch(`/api/client-portal/projects/${a}/coming-soon`,{credentials:"include"}),Bt(a).catch(()=>({success:!1,data:null})),Ot(a).catch(()=>({success:!1,data:null})),fetch(`/api/client-portal/projects/${a}/publication-gate`,{credentials:"include"})]);if(Ae.ok){const me=await Ae.json();A(me.data??me)}else A(null);if(r.ok){const me=await r.json(),Hs=me.data??me,Qe=sn(Hs);te(Qe),he(Qe.passwordProtected),k("")}h?.success&&h.data?ne(h.data.delivery_phase):ne("plan"),se?.success&&se.data?b(Array.isArray(se.data.milestones)?se.data.milestones:[]):b([])}catch(t){console.error("Failed to load site",t),Ce(t instanceof Error?t.message:"Failed to load site")}finally{ge(!1)}})()},[a]),n.useEffect(()=>{if(!a)return;(async()=>{Xs(!0),sa(!0);try{const[t,i]=await Promise.all([It(a).catch(()=>({success:!1,data:{file:null}})),Wt(a).catch(()=>({success:!1,data:{messages:[]}}))]);if(t?.success&&t.data?.file){N(t.data.file);try{const r=await qt(t.data.file.id,3600),h=r.data?.url??r.url??null;js(h)}catch{js(null)}}else N(null),js(null);i?.success&&Array.isArray(i.data?.messages)?bs(i.data.messages):bs([])}finally{Xs(!1),sa(!1)}})()},[a]),n.useEffect(()=>{!a||!c||c.siteType==="template"&&Vs(a).then(s=>{Se(s.data.template_site),Fe(s.data.template??null)}).catch(s=>{console.error("Failed to load template site preview metadata",s),Se(null),Fe(null)})},[a,c]),n.useEffect(()=>{!a||!c||Zs(a).then(s=>ga(s.data)).catch(s=>{console.error("Failed to load project storage usage",s),ga(null)})},[a,c]),n.useEffect(()=>{if(!a||!c||!ee){Ps(null),Ls([]),Es(null),as("");return}let s=!1;return ja(!0),ts(null),Ut(a).then(t=>{s||(Ps(t.data.care_plan),Ls(t.data.options??[]),Es(t.data.usage??null),as(t.data.care_plan?.pending_plan_slug??t.data.care_plan?.current_plan_slug??""))}).catch(t=>{s||ts(t instanceof Error?t.message:"Failed to load package.")}).finally(()=>{s||ja(!1)}),()=>{s=!0}},[ee,a,c]),n.useEffect(()=>{if(!a||!c||K!=="grow")return;let s=!1;return pa(!0),_s(null),Tt(a,30).then(t=>{s||(ma(t.data.summary),t.data.stale&&_s("Showing the latest saved analytics report while Google refreshes."))}).catch(t=>{if(s)return;ma(null);const i=t instanceof Error?t.message:"Analytics are not available yet.";_s(/not configured|not enabled/i.test(i)?"Google Analytics has not been connected to this site yet.":i)}).finally(()=>{s||pa(!1)}),()=>{s=!0}},[K,c,a]),n.useEffect(()=>{Bs.current?.scrollIntoView({behavior:"smooth"})},[qe]);const ps=async()=>{const s=ze.trim();if(!(!a||!s||Ge)){aa(!0);try{const t=await zt(a,{body:s}),i=t.data??t;i&&bs(r=>[...r,i]),ys("")}catch(t){console.error("Send message failed",t),alert(t instanceof Error?t.message:"Failed to send message.")}finally{aa(!1)}}},jt=async()=>{if(!(!a||!x)){B(!0);try{const s=await fetch(`/api/client-portal/projects/${a}/domains`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({domainId:x})});if(!s.ok){const t=await s.json().catch(()=>({})),i=typeof t.error=="string"?t.error:t.error?.message??"Failed to connect domain.";alert(i);return}M(""),await Je()}catch(s){alert(s instanceof Error?s.message:"Failed to connect domain.")}finally{B(!1)}}},bt=async s=>{if(!(!a||!window.confirm("Remove this domain from the site? You can connect it again later."))){B(!0);try{const i=await fetch(`/api/client-portal/projects/${a}/domains/${s}`,{method:"DELETE",credentials:"include"});if(!i.ok){const r=await i.json().catch(()=>({})),h=typeof r.error=="string"?r.error:r.error?.message??"Failed to disconnect domain.";alert(h);return}await Je()}catch(i){alert(i instanceof Error?i.message:"Failed to disconnect domain.")}finally{B(!1)}}},Oa=async()=>{const s=ws.trim().toLowerCase();if(!(!s||Cs)){la(!0),ks(null),Ns(null),es(null);try{const t=await fetch(`/api/domains/search?query=${encodeURIComponent(s)}`,{credentials:"include"}),i=await t.json();if(!t.ok){ks(i.error?.message??"Domain search failed.");return}const r=i.data??i;Ns({domain:r.domain??s,available:!!r.available,premium:r.premium,price:r.price,currency:r.currency,message:r.message})}catch(t){ks(t instanceof Error?t.message:"Domain search failed.")}finally{la(!1)}}},yt=async()=>
1{if(!(!a||!l?.client?.id||!le?.domain||Ss)){ca(!0),es(null);try{const s=await fetch("/api/domains/purchase",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:l.client.id,domain_name:le.domain,years:oa})}),t=await s.json().catch(()=>({}));if(!s.ok){const r=typeof t.error=="string"?t.error:t.error?.message??"Domain purchase failed.";es(r);return}const i=t.data?.id??t.id;i&&await fetch(`/api/client-portal/projects/${a}/domains`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({domainId:i})}),ia(""),Ns(null),await Je()}catch(s){es(s instanceof Error?s.message:"Domain purchase failed.")}finally{ca(!1)}}},vt=async()=>{if(!(!a||vs)){ta(!0);try{const s=await Gt(a);Se(s.data.template_site);const t=await za();v(t),na(""),await Je()}catch(s){alert(s instanceof Error?s.message:"Failed to make this site live.")}finally{ta(!1)}}},wt=async()=>{if(!(!a||!re||As)){ba(!0),ts(null),xe(null),Ds(null);try{const s=S?.new_plan_slug===re,t=await Ht(a,re,s),i=t.data.preview??null;if(!s){Rs(i),i?.change_type==="same"?xe("This package is already active."):i?.change_type==="downgrade"?xe(`${i.new_plan_name} will start ${Be(i.effective_date)}. Confirm to schedule this change.`):i&&xe(`Review and confirm ${ue(i.amount_due_today_cents)} due today before we charge your saved payment method.`);return}const r=t.data.care_plan;Ps(r),Ls(t.data.options??[]),Es(t.data.usage??null),as(r?.pending_plan_slug??r?.current_plan_slug??re),Rs(null),t.data.payment?.requires_authentication&&t.data.payment.checkout_url?(Ds(t.data.payment.checkout_url),xe("Payment needs one more verification step before the upgrade can activate.")):t.data.payment&&!t.data.payment.success?xe(t.data.payment.message||"The package change is waiting for payment."):xe(r?.pending_plan_slug?`${r.pending_plan_name} is scheduled for ${Be(r.pending_effective_date)}.`:`${r?.current_plan_name??"Package"} is active.`)}catch(s){ts(s instanceof Error?s.message:"Failed to update package.")}finally{ba(!1)}}};if(!a)return e.jsx("div",{className:"sites-page site-detail-page",children:e.jsxs("div",{className:"portal-loading",children:[e.jsx("p",{children:"Missing site."}),e.jsx(V,{to:"/dashboard/sites",className:"portal-link site-detail-back-link",children:"Back to sites"})]})});if(R)return e.jsx("div",{className:"sites-page site-detail-page",children:e.jsx("div",{className:"portal-loading",children:e.jsx("p",{children:"Loading site..."})})});if(Xe||!c)return e.jsx("div",{className:"sites-page site-detail-page",children:e.jsxs("div",{className:"portal-loading",children:[e.jsx("p",{className:"error-text",children:Xe||"Site not found."}),e.jsx(V,{to:"/dashboard/sites",className:"portal-link site-detail-back-link",children:"Back to sites"})]})});const Ia=Xa?e.jsx("div",{className:"modal-overlay",onClick:()=>!Ue&&He(!1),"aria-hidden":"true",children:e.jsxs("form",{className:"modal-content sites-rename-modal",role:"dialog","aria-modal":"true","aria-labelledby":"site-detail-rename-title",onSubmit:at,onClick:s=>s.stopPropagation(),children:[e.jsxs("header",{className:"sites-rename-modal-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Site name"}),e.jsx("h2",{id:"site-detail-rename-title",children:"Rename site"})]}),e.jsx("button",{type:"button",className:"modal-close",onClick:()=>He(!1),disabled:Ue,"aria-label":"Close",children:e.jsx("span",{"aria-hidden":"true",children:"×"})})]}),e.jsxs("label",{className:"sites-rename-field",children:[e.jsx("span",{children:"Display name"}),e.jsx("input",{autoFocus:!0,value:Na,onChange:s=>Ca(s.target.value),maxLength:120,placeholder:"Discount Diaper World"})]}),Sa?e.jsx("p",{className:"error-text",children:Sa}):null,e.jsxs("div",{className:"sites-rename-actions",children:[e.jsx("button",{type:"button",className:"ghost",onClick:()=>He(!1),disabled:Ue,children:"Cancel"}),e.jsx("button",{type:"submit",className:"primary",disabled:Ue,children:Ue?"Saving...":"Save name"})]})]})}):null;return O?e.jsxs("div",{className:"sites-page site-detail-page site-detail-page--custom-console site-detail-page--template-console",children:[e.jsxs("section",{className:"site-console-card","aria-label":`${c.name} website console`,children:[e.jsxs("div",{className:"site-console-card-header",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Website"}),e.jsxs("div",{className:"site-detail-title-row",children:[e.jsx("h1",{children:c.name}),e.jsxs("button",{type:"button",className:"site-detail-rename-button",onClick:Fa,children:[e.jsx(_,{name:"edit",size:15}),"Rename"]})]})]}),e.jsxs("div",{className:"site-detail-header-actions",children:[e.jsx(V,{to:"/dashboard/sites",className:"ghost",children:"Back to sites"}),e.jsxs("a",{href:X,target:"_blank",rel:"noreferrer",className:"ghost",children:[e.jsx(_,{name:"globe",size:16}),e.jsx("span",{children:Aa})]}),e.jsx(V,{to:"/dashboard/support",className:"ghost",children:"Request changes"}),e.jsx("button",{type:"button",className:"primary",onClick:()=>void Te(),disabled:U,children:U?"Opening...":$e}),e.jsx("span",{className:`status-pill ${c.status==="In Progress"?"status-warning":""}`,children:c.status})]})]}),e.jsxs("div",{className:"sites-card-browser site-command-browser",children:[e.jsxs("div",{className:"sites-card-browser-bar",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{}),e.jsx("strong",{className:"site-console-browser-label",children:"Live preview"}),e.jsx("span",{className:"sites-card-browser-url",children:X.replace(/^https?:\/\//,"")})]}),e.jsx("div",{className:"site-command-preview-frame-wrap",children:e.jsx("iframe",{className:"site-command-preview-frame",src:X,title:`${c.name} preview`,loading:"lazy"})})]}),Ra?e.jsxs("section",{className:"template-demo-activation","aria-label":"Activate demo site",children:[e.jsxs("div",{className:"template-demo-activation-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Demo site"}),e.jsx("h2",{children:"Activate this demo to go live"}),e.jsx("p",{children:"Choose a monthly store plan, complete checkout, then this demo unlocks publishing, domains, and live checkout setup."})]}),e.jsx("span",{className:"status-pill status-warning",children:"Payment required"})]}),e.jsx("div",{className:"template-demo-activation-grid",children:Ys.map(s=>e.jsxs("button",{type:"button",className:"template-demo-activation-plan",onClick:()=>Da(s.slug),children:[e.jsxs("span",{children:[e.jsx("strong",{children:s.label}),e.jsx("small",{children:s.body})]}),e.jsx("b",{children:s.price})]},s.slug))})]}):null]}),Ia]}):e.jsxs("div",{className:`sites-page site-detail-page site-detail-page--custom-console ${O?"site-detail-page--template-console":""}`,children:[e.jsxs("section",{className:"site-console-card","aria-label":`${c.name} website console`,children:[e.jsxs("div",{className:"site-console-card-header",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Website"}),e.jsxs("div",{className:"site-detail-title-row",children:[e.jsx("h1",{children:c.name}),e.jsxs("button",{type:"button",className:"site-detail-rename-button",onClick:Fa,children:[e.jsx(_,{name:"edit",size:15}),"Rename"]})]})]}),e.jsxs("div",{className:"site-detail-header-actions",children:[e.jsx(V,{to:"/dashboard/sites",className:"ghost",children:"Back to sites"}),e.jsxs("a",{href:X,target:"_blank",rel:"noreferrer",className:"ghost",children:[e.jsx(_,{name:"globe",size:16}),e.jsx("span",{children:Aa})]}),e.jsx(V,{to:"/dashboard/support",className:"ghost",children:"Request changes"}),e.jsx("button",{type:"button",className:"primary",onClick:()=>void Te(),disabled:U,children:U?"Opening...":$e}),e.jsx("span",{className:`status-pill ${c.status==="In Progress"?"status-warning":""}`,children:c.status})]})]}),e.jsxs("div",{className:"sites-card-browser site-command-browser",children:[e.jsxs("div",{className:"sites-card-browser-bar",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{}),e.jsx("strong",{className:"site-console-browser-label",children:"Live preview"}),e.jsx("span",{className:"sites-card-browser-url",children:X.replace(/^https?:\/\//,"")})]}),e.jsx("div",{className:"site-command-preview-frame-wrap",children:e.jsx("iframe",{className:"site-command-preview-frame",src:X,title:`${c.name} preview`,loading:"lazy"})})]}),Ra?e.jsxs("section",{className:"template-demo-activation","aria-label":"Activate demo site",children:[e.jsxs("div",{className:"template-demo-activation-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Demo site"}),e.jsx("h2",{children:"Activate this demo to go live"}),e.jsx("p",{children:"Choose a monthly store plan, complete checkout, then this demo unlocks publishing, domains, and live checkout setup."})]}),e.jsx("span",{className:"status-pill status-warning",children:"Payment required"})]}),e.jsx("div",{className:"template-demo-activation-grid",children:Ys.map(s=>e.jsxs("button",{type:"button",className:"template-demo-activation-plan",onClick:()=>Da(s.slug),children:[e.jsxs("span",{children:[e.jsx("strong",{children:s.label}),e.jsx("small",{children:s.body})]}),e.jsx("b",{children:s.price})]},s.slug))})]}):null]}),d?.gated?e.jsxs("section",{className:"template-demo-activation template-client-review","aria-label":"Campaign website launch requirements",children:[e.jsxs("div",{className:"template-demo-activation-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Private client preview"}),e.jsx("h2",{children:d.public?"Your site is ready for public launch":"Review your website. Pay when you’re ready."}),e.jsx("p",{children:"Take your time reviewing the site above. No invoice is created until you choose to start checkout."})]}),e.jsx("span",{className:`status-pill ${d.public?"":"status-warning"}`,children:d.public?"Public access ready":"Private"})]}),e.jsxs("div",{className:"template-demo-activation-grid",children:[e.jsxs("div",{className:"template-demo-activation-plan",children:[e.jsxs("span",{children:[e.jsxs("strong",{children:["$",(d.launchOffer?.buildAmount??d.buildInvoice?.amount??0).toFixed(2)," website build"]}),e.jsx("small",{children:d.buildPaid?"Paid in full":d.activationFunded?"Payment plan active":"Included when you start checkout"})]}),e.jsx("b",{children:d.buildPaid?"Complete":d.activationFunded?"In progress":"Proposed"})]}),e.jsxs("div",{className:"template-demo-activation-plan",children:[e.jsxs("span",{children:[e.jsxs("strong",{children:["$",(d.launchOffer?.hostingMonthlyAmount??25).toFixed(2)," ",d.launchOffer?.hostingBillingInterval==="annual"?"prepaid annual hosting":"monthly hosting"]}),e.jsx("small",{children:d.hostingActive?"Hosting is active":d.launchOffer?.hostingBillingInterval==="annual"?"One prepaid year included":"First month included; renews one month after payment"})]}),e.jsx("b",{children:d.hostingActive?"Active":"Proposed"})]}),e.jsxs("button",{className:"template-demo-activation-plan",type:"button",onClick:()=>z("launch"),children:[e.jsxs("span",{children:[e.jsx("strong",{children:d.launchOffer?.domainName||"Optional custom domain"}),e.jsx("small",{children:d.launchOffer?.domainName?"Funded from the payment plan and provisioned automatically":"Search, purchase, and automatically connect a campaign domain"})]}),e.jsx("b",{children:E.length?"Connected":d.launchOffer?.domainProvisioningStatus==="needs_attention"?"Needs attention":"Included"})]})]}),d.launchOffer?e.jsxs("div",{className:"template-demo-activation-grid","aria-label":"Website payment plan balance",children:[e.jsxs("div",{className:"template-demo-activation-plan",children:[e.jsxs("span",{children:[e.jsxs("strong",{children:["$",d.launchOffer.totalPrincipalAmount.toFixed(2)," full principal"]}),e.jsx("small",{children:"Website, launch hosting, and domain allocation"})]}),e.jsx("b",{children:"Original"})]}),e.jsxs("div",{className:"template-demo-activation-plan",children:[e.jsxs("span",{children:[e.jsxs("strong",{children:["$",d.launchOffer.paidPrincipalAmount.toFixed(2)," paid down"]}),e.jsx("small",{children:"Verified principal payments"})]}),e.jsx("b",{children:"Paid"})]}),e.jsxs("div",{className:"template-demo-activation-plan",children:[e.jsxs("span",{children:[e.jsxs("strong",{children:["$",d.launchOffer.remainingPrincipalAmount.toFixed(2)," remaining"]}),e.jsx("small",{children:"Processing fee is calculated on each payment"})]}),e.jsx("b",{children:"Balance"})]})]}
1):null,d.launchOffer&&d.launchOffer.remainingPrincipalAmount>0?e.jsxs("div",{className:"template-demo-activation-actions",children:[d.launchOffer.activationInvoiceId&&d.launchOffer.activationInvoiceStatus!=="paid"&&d.launchOffer.activationInvoiceStatus!=="cancelled"?e.jsx(V,{className:"primary",to:"/dashboard/invoices",children:"Continue secure payment"}):e.jsx("button",{className:"primary",type:"button",onClick:()=>void st(),disabled:j,children:j?"Preparing checkout...":`${d.activationFunded?"Make next payment":"Start checkout"} — $${Math.min(d.launchOffer.initialPaymentAmount,d.launchOffer.remainingPrincipalAmount).toFixed(2)}`}),e.jsx("small",{children:"Processing fee is added at checkout. Recurring hosting begins one month after activation."})]}):null]}):null,K==="overview"&&O?e.jsxs("div",{className:"site-overview-grid",children:[e.jsxs("section",{className:"site-detail-section",children:[e.jsx("div",{className:"portal-panel-header",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Worksp
1ace overview"}),e.jsx("h3",{children:"What matters right now"})]})}),e.jsxs("div",{className:"site-overview-list",children:[e.jsxs("div",{className:"site-overview-row",children:[e.jsx("span",{className:"site-command-attention-icon","aria-hidden":"true",children:e.jsx(_,{name:"projects",size:16})}),e.jsxs("div",{children:[e.jsxs("strong",{children:[Ha(Ve)," phase"]}),e.jsx("p",{children:"Your team is moving this site through planning, build, review, and launch."})]})]}),e.jsxs("div",{className:"site-overview-row",children:[e.jsx("span",{className:"site-command-attention-icon","aria-hidden":"true",children:e.jsx(_,{name:"domains",size:16})}),e.jsxs("div",{children:[e.jsxs("strong",{children:[E.length," connected domain",E.length===1?"":"s"]}),e.jsx("p",{children:E.length>0?"Domain routing is connected for this site.":"Connect a domain when this site is ready for launch."})]})]}),e.jsxs("div",{className:"site-overview-row",children:[e.jsx("span",{className:"site-command-attention-icon","aria-hidden":"true",children:e.jsx(_,{name:"warning",size:16})}),e.jsxs("div",{children:[e.jsx("strong",{children:an(w)}),e.jsxs("p",{children:["Public visitors are currently seeing ",w.enabled?"your branded gate page.":"your active site build."]})]})]})]})]}),e.jsxs("section",{className:"site-detail-section",children:[e.jsxs("div",{className:"portal-panel-header",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Delivery"}),e.jsx("h3",{children:"Latest milestones"})]}),e.jsx("button",{type:"button",className:"portal-link",onClick:()=>z("build"),children:"View all"})]}),o.length===0?e.jsx("p",{className:"admin-text-muted",children:"No milestones have been published yet."}):e.jsx("ul",{className:"site-detail-milestones-list",children:o.slice(0,3).map(s=>e.jsxs("li",{className:"site-detail-milestone-item",children:[e.jsx("span",{className:"site-detail-milestone-title",children:s.title}),e.jsx("span",{className:"meta site-detail-milestone-meta",children:s.status.replaceAll("_"," ")})]},s.id))})]}),e.jsxs("section",{className:"site-detail-section site-overview-wide",children:[e.jsx("div",{className:"portal-panel-header",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Client actions"}),e.jsx("h3",{children:O?`${Ta}, launch, and support`:"Plan, build, and launch"})]})}),e.jsxs("div",{className:"portal-action-list site-overview-actions",children:[O?null:e.jsx("button",{type:"button",className:"portal-action-card",onClick:()=>z("plan"),children:e.jsxs("div",{children:[e.jsx("strong",{children:"Planning journal"}),e.jsx("span",{children:"Add business context and submit it for staff review."})]})}),e.jsx("button",{type:"button",className:"portal-action-card",onClick:()=>z("template"),children:e.jsxs("div",{children:[e.jsx("strong",{children:$?"Nonprofit site settings":"Storefront settings"}),e.jsx("span",{children:"Edit Page Content, template fields, page toggles, and publish state."})]})}),e.jsx(V,{to:"/dashboard/support",className:"portal-action-card",children:e.jsxs("div",{children:[e.jsx("strong",{children:"Request changes"}),e.jsx("span",{children:"Send content, design, or launch changes to Bliss."})]})}),e.jsx("button",{type:"button",className:"portal-action-card",onClick:()=>z("build"),children:e.jsxs("div",{children:[e.jsx("strong",{children:"Send files and assets"}),e.jsx("span",{children:"Upload logos, photos, copy docs, and references for this site."})]})})]})]})]}):K==="template"&&!O?e.jsx(e.Fragment,{children:O?e.jsxs("section",{className:"template-setup-workspace template-setup-workspace--console",children:[e.jsxs("div",{className:"template-setup-hero",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:Me.eyebrow}),e.jsx("h2",{children:Me.title}),e.jsx("p",{children:Me.body})]}),e.jsxs("div",{className:"template-setup-hero-actions",children:[e.jsx("button",{type:"button",className:"primary",onClick:()=>void Te(),disabled:U,children:U?"Opening...":$e}),e.jsx("a",{href:X,target:"_blank",rel:"noreferrer",className:"ghost",children:Me.previewLabel})]})]}),ft?e.jsx("section",{className:"template-first-run-wizard template-first-run-wizard--complete","aria-label":"First-run template setup complete",children:e.jsxs("div",{className:"template-first-run-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Setup complete"}),e.jsx("h3",{children:"Your launch checklist is complete"}),e.jsx("p",{children:"Keep using the editor, app manager, and launch tools as the site grows."})]}),e.jsx("span",{className:"status-pill status-live",children:"Ready"})]})}):e.jsxs("section",{className:"template-first-run-wizard","aria-label":"First-run template setup",children:[e.jsxs("div",{className:"template-first-run-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"First-run setup"}),e.jsx("h3",{children:"Turn the starter template into your live business site"}),e.jsx("p",{children:"Purchase is complete. Work through these steps when you are ready; the starter site stays usable while setup continues."})]}),e.jsxs("div",{className:"template-first-run-progress",children:[e.jsxs("strong",{children:[Gs,"/",Le.length]}),e.jsx("span",{children:"complete"})]})]}),e.jsx("div",{className:"template-first-run-track","aria-hidden":"true",children:e.jsx("span",{style:{width:`${Math.round(Gs/Le.length*100)}%`}})}),La?e.jsx("p",{className:"template-first-run-error",children:La}):null,e.jsx("div",{className:"template-first-run-grid",children:Le.map(s=>e.jsxs("article",{className:`template-first-run-step ${s.complete?"is-complete":""}`,children:[e.jsx("span",{className:"template-first-run-step-icon","aria-hidden":"true",children:e.jsx(_,{name:s.complete?"check-circle":s.icon,size:17})}),e.jsxs("div",{children:[e.jsx("h4",{children:s.title}),e.jsx("p",{children:s.body}),e.jsxs("div",{className:"template-first-run-actions",children:[e.jsx("button",{type:"button",className:"portal-link",onClick:s.onAction,children:s.actionLabel}),!s.complete&&s.id!=="domain"&&s.id!=="publish"?e.jsx("button",{type:"button",className:"portal-link",onClick:()=>void xt(s.id),disabled:Ms===s.id,children:Ms===s.id?"Saving...":"Mark done"}):null]})]})]},s.id))})]}
1),Q?e.jsxs("section",{className:"template-client-manifest","aria-label":"Current theme and apps",children:[e.jsxs("div",{className:"template-client-manifest-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Installed theme"}),e.jsx("h3",{children:Q.name}),e.jsx("p",{children:Q.description})]}),e.jsx("span",{className:"status-pill status-live",children:Q.category})]}),e.jsxs("div",{className:"template-client-manifest-grid",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Apps"}),e.jsx("strong",{children:Q.app_count})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Capabilities"}),e.jsx("strong",{children:Q.capabilities.length})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Renewal"}),e.jsx("strong",{children:nt})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Next invoice"}),e.jsx("strong",{children:Be(be?.next_invoice_date)})]})]}),e.jsxs("div",{className:"template-client-plugin-row",children:[Q.plugins.slice(0,10).map(s=>e.jsx("span",{title:s.description,children:s.label},s.key)),Q.plugins.length>10?e.jsxs("span",{children:["+",Q.plugins.length-10," more"]}):null]}),e.jsxs("p",{className:"template-client-renewal-note",children:["Renewals are handled through Bliss invoices. ",it,"."]})]}):null,Pe.length>0?e.jsxs("section",{className:"template-app-manager","aria-label":"Installed app manager",children:[e.jsxs("div",{className:"template-app-manager-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"App manager"}),e.jsx("h3",{children:"Installed apps and setup"}),e.jsx("p",{children:"Only apps included with this theme are shown here."})]}),e.jsxs("span",{className:"status-pill",children:[Pe.filter(s=>s.status==="setup").length," need setup"]})]}),e.jsx("div",{className:"template-app-manager-grid",children:Pe.map(s=>e.jsxs("article",{className:`template-app-card template-app-card--${s.status}`,children:[e.jsxs("div",{className:"template-app-card-head",children:[e.jsx("span",{className:"template-app-card-icon","aria-hidden":"true",children:e.jsx(_,{name:s.icon,size:17})}),e.jsx("span",{className:`template-app-status template-app-status--${s.status}`,children:s.statusLabel})]}),e.jsxs("div",{children:[e.jsx("h4",{children:s.label}),e.jsx("p",{children:s.description})]}),e.jsx("button",{type:"button",className:"portal-link",onClick:s.onClick,children:s.actionLabel})]},s.key))})]}):null,e.jsx("div",{className:"template-setup-layout",children:e.jsxs("div",{className:"template-setup-main",children:[e.jsxs("article",{className:"template-setup-preview-card",children:[e.jsx("div",{className:"sites-card-browser site-command-browser template-setup-preview-browser",children:e.jsx("div",{className:"template-setup-preview-frame-wrap",children:e.jsx("iframe",{className:"site-command-preview-frame",src:X,title:`${c.name} ${Is} preview`,loading:"lazy"})})}),e.jsxs("div",{className:"template-setup-preview-actions",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:Me.liveDraftLabel}),e.jsx("h3",{children:c.name})]}),e.jsx("a",{href:X,target:"_blank",rel:"noreferrer",className:"portal-link",children:"Open preview"})]}),Ke>0?e.jsxs("div",{className:"template-setup-storage-card",children:[e.jsxs("div",{className:"template-setup-storage-head",children:[e.jsxs("span",{children:[e.jsx(_,{name:"storage",size:16}),"Media storage"]}),e.jsxs("strong",{children:[Ba,"% used"]})]}),e.jsx("div",{className:"template-setup-storage-bar","aria-hidden":"true",children:e.jsx("span",{style:{width:`${Ba}%`}})}),e.jsxs("p",{children:[Re(qs)," of ",Re(Ke)," used."," ",Re(rt)," remaining."]})]}):null,ee?e.jsxs("div",{className:"template-setup-package-card",children:[e.jsxs("div",{className:"template-setup-package-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Package"}),e.jsx("h3",{children:G?.current_plan_name??"Memorial package"}),e.jsx("p",{children:G?`${ue(G.amount_cents)}/mo. Next invoice ${Be(G.next_invoice_date)}.`:xa?"Loading package...":"No active package found for this obituary platform."})]}),G?.status?e.jsx("span",{className:"status-pill",children:G.status}):null]}),G?.pending_plan_slug?e.jsxs("div",{className:"template-setup-package-pending",children:[G.pending_plan_name," starts ",Be(G.pending_effective_date),"."]}):null,fa.length>0?e.jsx("div",{className:"template-setup-package-options",role:"radiogroup","aria-label":"Memorial package",children:fa.map(s=>
1{const t=re===s.slug,i=G?.current_plan_slug===s.slug&&!G.pending_plan_slug;return e.jsxs("button",{type:"button",className:`template-setup-package-option ${t?"active":""}`,onClick:()=>{as(s.slug),Rs(null),Ds(null),xe(null)},"aria-pressed":t,children:[e.jsxs("span",{children:[e.jsx("strong",{children:s.name}),i?e.jsx("em",{children:"Current"}):null]}),e.jsxs("b",{children:[ue(s.amountCents),"/mo"]}),e.jsxs("small",{children:[Re(s.entitlements.storageGb)," storage | ",De(s.entitlements.aiActionsMonthly)," AI actions/mo | ",Va(s.entitlements.familyTree)]})]},s.slug)})}):null,D?e.jsxs("div",{className:"template-setup-entitlement-grid",children:[e.jsxs("div",{className:"template-setup-entitlement-card",children:[e.jsx("span",{children:"Storage"}),e.jsxs("strong",{children:[Re(D.storage.used_gb)," / ",Re(D.storage.allocated_gb)]}),e.jsx("div",{className:"template-setup-storage-bar","aria-hidden":"true",children:e.jsx("span",{style:{width:`${Math.min(100,D.storage.usage_percent)}%`}})}),e.jsxs("small",{children:[Re(D.storage.included_gb)," included in this package."]})]}),e.jsxs("div",{className:"template-setup-entitlement-card",children:[e.jsx("span",{children:"Cloudflare AI"}),e.jsxs("strong",{children:[De(D.ai.used_actions)," / ",De(D.ai.included_actions)]}),e.jsx("div",{className:"template-setup-storage-bar","aria-hidden":"true",children:e.jsx("span",{style:{width:`${Math.min(100,D.ai.usage_percent)}%`}})}),e.jsxs("small",{children:[De(D.ai.remaining_actions)," actions left for ",D.ai.period_key,"."]})]}),e.jsxs("div",{className:"template-setup-entitlement-card",children:[e.jsx("span",{children:"Workflow"}),e.jsxs("strong",{children:[De(D.workflow.active_cases)," active cases"]}),e.jsxs("small",{children:[De(D.workflow.memorial_pages)," memorials | ",De(D.workflow.family_accounts)," family accounts"]})]}),e.jsxs("div",{className:"template-setup-entitlement-card",children:[e.jsx("span",{children:"Legacy tools"}),e.jsx("strong",{children:Va(D.limits.familyTree)}),e.jsxs("small",{children:["Family portal ",D.limits.familyPortal?"included":"not included"," | support payments ",D.limits.memorialSupport?"included":"not included"]})]})]}):null,S?e.jsxs("div",{className:"template-setup-package-confirm",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Change"}),e.jsxs("strong",{children:[S.current_plan_name," to ",S.new_plan_name]})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Effective"}),e.jsx("strong",{children:Be(S.effective_date)})]}),S.change_type==="upgrade"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("span",{children:"Prorated package difference"}),e.jsx("strong",{children:ue(S.prorated_subtotal_cents)})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Processing fee"}),e.jsx("strong",{children:ue(S.processing_fee_cents)})]})]}):null,e.jsxs("div",{className:"template-setup-package-confirm-total",children:[e.jsx("span",{children:"Total due today"}),e.jsx("strong",{children:ue(S.amount_due_today_cents)})]}),e.jsx("p",{children:S.change_type==="upgrade"?`${S.new_plan_name} will become active after this confirmed payment. Future renewals will be ${ue(S.new_amount_cents)}/mo.`:S.change_type==="downgrade"?`${S.new_plan_name} will start at the next renewal. No payment is due today.`:"No package change is needed."})]}):null,e.jsxs("div",{className:"template-setup-package-actions",children:[e.jsx("button",{type:"button",className:"primary",onClick:()=>void wt(),disabled:As||xa||!re||!S&&re===(G?.pending_plan_slug??G?.current_plan_slug),children:As?S?.new_plan_slug===re?"Confirming...":"Reviewing...":S?.new_plan_slug===re?S.amount_due_today_cents>0?`Confirm and pay ${ue(S.amount_due_today_cents)}`:"Confirm change":"Review package change"}),e.jsx("small",{children:"Upgrades apply now. Downgrades apply at the next renewal."})]}),ya?e.jsx("p",{className:"error-text",children:ya}):null,va?e.jsx("p",{className:"template-setup-package-message",children:va}):null,wa?e.jsx("a",{className:"portal-link",href:wa,children:"Complete payment verification"}):null]}):null]}),e.jsxs("div",{className:"template-setup-card-grid",children:[ut.map(s=>e.jsxs("button",{type:"button",className:"template-setup-card",onClick:s.onClick,children:[e.jsx("span",{className:"template-setup-card-icon",children:e.jsx(_,{name:s.icon,size:18})}),e.jsxs("span",{className:"template-setup-card-copy",children:[e.jsxs("span",{className:"template-setup-card-head",children:[e.jsx("strong",{children:s.title}),e.jsx("em",{children:s.status})]}),e.jsx("small",{children:s.body}),e.jsx("span",{className:"template-setup-card-action",children:s.action})]})]},s.title)),ht.map(s=>e.jsxs("button",{type:"button",className:`template-setup-card ${s.complete?"is-complete":""}`,onClick:s.action,children:[e.jsx("span",{className:"template-setup-card-icon",children:e.jsx(_,{name:s.complete?"check-circle":"warning",size:18})}),e.jsxs("span",{className:"template-setup-card-copy",children:[e.jsxs("span",{className:"template-setup-card-head",children:[e.jsx("strong",{children:s.label}),e.jsx("em",{children:s.complete?"Ready":"Action needed"})]}),e.jsx("small",{children:s.body}),e.jsx("span",{className:"template-setup-card-action",children:s.actionLabel})]})]},s.label))]})]})}),e.jsx("div",{className:"template-setup-editor-section",children:e.jsxs("div",{className:"template-setup-help-card",children:[e.jsx("p",{className:"eyebrow",children:"Need help?"}),e.jsx("h3",{children:"Ask Bliss to handle the next step"}),e.jsx("p",{children:Me.helpBody}),e.jsx(V,{to:"/dashboard/support",className:"ghost",children:"Request help"})]})})]}):null}):K==="plan"&&!O?e.jsxs(e.Fragment,{children:[e.jsx(us,{projectId:c.id,projectName:c.name,phaseKey:"plan",phaseLabel:cs.label,composerRequest:ss}),e.jsxs("div",{className:"site-detail-plan-phase-grid",children:[e.jsxs("div",{className:"portal-summary-stack",children:[e.jsxs("section",{className:"site-detail-section",children:[e.jsx("div",{className:"portal-panel-header",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Review"}),e.jsx("h3",{children:"Plan document"})]})}),ke?e.jsx("p",{className:"admin-text-muted",children:"Loading plan document..."}):L&&xs?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"site-detail-section-desc site-detail-section-desc--spaced",children:[L.original_filename," - Last updated ",L.updated_at_iso.slice(0,10)]}),e.jsx("div",{className:"site-detail-plan-preview",children:e.jsx("iframe",{title:"Plan PDF",src:xs,className:"site-detail-plan-iframe"})}),e.jsx("a",{href:xs,target:"_blank",rel:"noopener noreferrer",className:"portal-link site-detail-download-l
1ink",children:"Download plan PDF"})]}):L?e.jsx("p",{className:"admin-text-muted",children:"Unable to load the preview. Download the document directly from your team."}):e.jsx("p",{className:"admin-text-muted",children:"No plan document has been uploaded yet. Your team will place it here for review."})]}),e.jsxs("section",{className:"site-detail-section",children:[e.jsx("div",{className:"portal-panel-header",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Agreement"}),e.jsx("h3",{children:"Choose, sign, and pay"})]})}),e.jsx("p",{className:"site-detail-section-desc",children:"When Bliss publishes the staff-reviewed three-tier plan, choose the tier that fits, sign the agreement, and complete payment from Proposal Agreements."}),e.jsx(V,{to:"/dashboard/proposal-agreements",className:"primary",children:"Open proposal agreements"})]})]}),e.jsxs("section",{id:"project-messages",className:"site-detail-section site-detail-message-panel",children:[e.jsx("div",{className:"portal-panel-header",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Collaboration"}),e.jsx("h3",{children:"Project messages"})]})}),e.jsx("p",{className:"site-detail-section-desc site-detail-section-desc--spaced",children:"Use this thread to ask questions or confirm changes directly with your team."}),ea?e.jsx("p",{className:"admin-text-muted",children:"Loading messages..."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"site-detail-message-scroll",children:[qe.length===0?e.jsx("p",{className:"admin-text-muted",children:"No messages yet. Start the thread when you are ready."}):qe.map(s=>e.jsxs("div",{className:`site-detail-message-bubble ${s.sender_type==="client"?"site-detail-message-bubble--client":""}`,children:[e.jsxs("div",{className:"site-detail-message-meta",children:[s.sender_name," / ",new Date(s.created_at_iso).toLocaleString()]}),e.jsx("div",{className:"site-detail-message-body",children:s.body})]},s.id)),e.jsx("div",{ref:Bs})]}),e.jsxs("div",{className:"site-detail-message-composer",children:[e.jsx("input",{type:"text",className:"filter-select site-detail-message-input",placeholder:"Type a message...",value:ze,onChange:s=>ys(s.target.value),onKeyDown:s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),ps())}}),e.jsx("button",{type:"button",className:"primary",disabled:Ge||!ze.trim(),onClick:ps,children:Ge?"Sending...":"Send"})]})]})]})]})]}):K==="build"?e.jsxs("div",{className:"portal-summary-stack",children:[e.jsx(us,{projectId:c.id,projectName:c.name,phaseKey:"build",phaseLabel:cs.label,composerRequest:ss}),e.jsxs("section",{className:"site-detail-section",children:[e.jsx("div",{className:"portal-panel-header",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Build"}),e.jsx("h3",{children:"Updates from your team"})]})}),e.jsx("p",{className:"site-detail-section-desc",children:"Follow client-readable updates, review the preview, and send assets or decisions your account manager needs."}),e.jsxs("div",{className:"site-detail-build-actions",children:[e.jsx("a",{href:X,target:"_blank",rel:"noreferrer",className:"primary",children:"View preview"}),e.jsx(V,{to:"/dashboard/support",className:"ghost",children:"Request changes"})]}),e.jsxs("div",{className:"site-detail-delivery-phase",children:[e.jsx("strong",{children:"Current status:"}),e.jsx("span",{className:"status-pill status-live site-detail-delivery-phase-pill",children:Ha(Ve)})]}),o.length===0?e.jsx("p",{className:"admin-text-muted",children:"No milestones have been published yet."}):e.jsx("ul",{className:"site-detail-milestones-list",children:o.map(s=>e.jsxs("li",{className:"site-detail-milestone-item",children:[e.jsx("span",{className:"site-detail-milestone-title",children:s.title}),e.jsx("span",{className:"meta site-detail-milestone-meta",children:s.status.replaceAll("_"," ")}),s.due_date?e.jsxs("span",{className:"meta",children:["Due ",s.due_date]}):null,s.completed_at?e.jsxs("span",{className:"meta",children:["Completed ",new Date(s.completed_at).toLocaleDateString()]}):null]},s.id))})]}),e.jsx(Zt,{projectId:c.id}),e.jsxs("section",{className:"site-detail-section site-detail-message-panel",children:[e.jsx("div",{className:"portal-panel-header",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Account manager"}),e.jsx("h3",{children:"Messages and updates"})]})}),e.jsx("p",{className:"site-detail-section-desc site-detail-section-desc--spaced",children:"Use this thread for build questions, content decisions, approvals, and updates from your account manager."}),ea?e.jsx("p",{className:"admin-text-muted",children:"Loading messages..."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"site-detail-message-scroll",children:[qe.length===0?e.jsx("p",{className:"admin-text-muted",children:"No messages yet."}):qe.map(s=>e.jsxs("div",{className:`site-detail-message-bubble ${s.sender_type==="client"?"site-detail-message-bubble--client":""}`,children:[e.jsxs("div",{className:"site-detail-message-meta",children:[s.sender_name," / ",new Date(s.created_at_iso).toLocaleStr
1ing()]}),e.jsx("div",{className:"site-detail-message-body",children:s.body})]},s.id)),e.jsx("div",{ref:Bs})]}),e.jsxs("div",{className:"site-detail-message-composer",children:[e.jsx("input",{type:"text",className:"filter-select site-detail-message-input",placeholder:"Message your account manager...",value:ze,onChange:s=>ys(s.target.value),onKeyDown:s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),ps())}}),e.jsx("button",{type:"button",className:"primary",disabled:Ge||!ze.trim(),onClick:ps,children:Ge?"Sending...":"Send"})]})]})]})]}):K==="launch"?e.jsxs("div",{className:"portal-summary-stack",children:[e.jsx(us,{projectId:c.id,projectName:c.name,phaseKey:"launch",phaseLabel:cs.label,composerRequest:ss}),e.jsxs("section",{className:"site-detail-section",children:[e.jsx("div",{className:"portal-panel-header",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Domains"}),e.jsx("h3",{children:"Connected domains"})]})}),e.jsx("p",{className:"site-detail-section-desc",children:"Attach one of your account domains to this site, or disconnect a domain that should no longer route here."}),E.length===0?e.jsx("p",{className:"admin-text-muted",children:"No domains are currently connected to this site."}):e.jsx("ul",{className:"site-detail-domains-list",children:E.map(s=>e.jsxs("li",{className:"site-detail-domain-item",children:[e.jsxs("div",{className:"site-detail-domain-info",children:[e.jsx("strong",{children:s.domain}),e.jsxs("div",{className:"site-detail-domain-meta",children:[e.jsx("span",{className:`status-pill ${s.status==="Connected"?"status-live":"status-warning"}`,children:s.status}),s.is_primary?e.jsx("span",{className:"status-pill status-live",children:"Primary"}):null]})]}),e.jsx("button",{type:"button",className:"site-detail-domain-disconnect",disabled:q,onClick:()=>void bt(s.id),children:"Disconnect"})]},s.id))}),e.jsxs("div",{className:"site-detail-connect-domain",children:[e.jsx("label",{htmlFor:"site-detail-connect-select",className:"site-detail-connect-label",children:"Connect a domain"}),e.jsxs("div",{className:"site-detail-connect-row",children:[e.jsxs("select",{id:"site-detail-connect-select",className:"site-detail-connect-select",value:x,onChange:s=>M(s.target.value),disabled:q||W.length===0,children:[e.jsx("option",{value:"",children:W.length===0?"No other domains to connect":"Select a domain..."}),W.map(s=>e.jsx("option",{value:s.id,children:s.domain},s.id))]}),e.jsx("button",{type:"button",className:"site-detail-connect-btn",disabled:q||!x,onClick:jt,children:q?"Connecting...":"Connect"})]})]}),e.jsxs("div",{className:"site-detail-domain-search",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"site-detail-domain-search",className:"site-detail-connect-label",children:"Buy a new domain"}),e.jsxs("div",{className:"site-detail-connect-row",children:[e.jsx("input",{id:"site-detail-domain-search",type:"search",className:"site-detail-connect-select",value:ws,placeholder:"example.com",onChange:s=>ia(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),Oa())}}),e.jsx("button",{type:"button",className:"site-detail-connect-btn",disabled:Cs||!ws.trim(),onClick:()=>void Oa(),children:Cs?"Searching...":"Search"})]})]}),ra?e.jsx("p",{className:"error-text",children:ra}):null,da?e.jsx("p",{className:"error-text",children:da}):null,le?e.jsxs("div",{className:"site-detail-domain-result",children:[e.jsxs("div",{children:[e.jsx("strong",{children:le.domain}),e.jsx("p",{children:le.available?`${le.currency??"USD"} ${le.price??0}/year before processing fees.`:le.message??"This domain is not available."})]}),le.available?e.jsxs("div",{className:"site-detail-connect-row",children:[e.jsxs("select",{className:"site-detail-connect-select",value:oa,onChange:s=>Qa(Number(s.target.value)),children:[e.jsx("option",{value:1,children:"1 year"}),e.jsx("option",{value:2,children:"2 years"}),e.jsx("option",{value:3,children:"3 years"})]}),e.jsx("button",{type:"button",className:"primary",disabled:Ss,onClick:()=>void yt(),children:Ss?"Buying...":"Buy and connect"})]}):null]}):null]})]}),e.jsxs("section",{className:"site-detail-section",children:[e.jsx("div",{className:"portal-panel-header",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Go live"}),e.jsx("h3",{children:"Make this site live"})]})}),e.jsx("p",{className:"site-detail-section-desc",children:"Review the final preview and connected domain. When everything looks ready, publish the site to the connected custom domain."}),e.jsxs("div",{className:"site-launch-readiness",children:[e.jsxs("div",{className:Os?"ready":"",children:[e.jsx("strong",{children:"Domain connected"}),e.jsx("span",{children:Os?"Ready":"Connect a domain before going live"})]}),e.jsxs("div",{className:I?"ready":"",children:[e.jsx("strong",{children:"Storefront published"}),e.jsx("span",{children:I?"Latest storefront is published":"Publish the storefront before going live"})]}),e.jsxs("div",{className:Ws?"ready":"",children:[e.jsx("strong",{children:"Live status"}),e.jsx("span",{children:Ws?"Live on connected domain":"Not live yet"})]})]}),Ws?e.jsxs("div",{className:"portal-surface-state",children:[e.jsx(_,{name:"check-circle",size:18}),e.jsx("span",{children:"This site is live. Customers can visit the connected custom domain once DNS has finished updating."})]}):e.jsxs("div",{className:"site-launch-request-box",children:[e.jsx("textarea",{className:"site-detail-connect-select",rows:3,value:Ja,placeholder:"Optional internal note for this launch...",onChange:s=>na(s.target.value)}),e.jsxs("div",{className:"site-detail-build-actions",children:[e.jsx("a",{href:X,target:"_blank",rel:"noreferrer",className:"ghost",children:"Open preview"}),e.jsx("button",{type:"button",className:"primary",disabled:vs||!Os||!I,onClick:()=>void vt(),children:vs?"Publishing...":"Make site live"})]})]})]})]}):e.jsxs("div",{className:"site-detail-grow-grid",children:[e.jsx(us,{projectId:c.id,projectName:c.name,phaseKey:"grow",phaseLabel:cs.label,composerRequest:ss}),e.jsxs("section",{className:"site-detail-section",children:[e.jsx("div",{className:"portal-panel-header",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Grow"}),e.jsx("h3",{children:Ve==="publish"?"Revenue and visibility":"Growth tools unlock after launch"})]})}),Ve==="publish"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"site-detail-grow-metrics",children:[e.jsxs("div",{className:"site-detail-grow-metric",children:[e.jsx("span",{className:"meta",children:"Revenue this month"}),e.jsx("strong",{children:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(l?.revenueSummary?.monthlyRevenue??0)})]}),e.jsxs("div",{className:"site-detail-grow-metric",children:[e.jsx("span",{className:"meta",children:"Payments tracked"}),e.jsx("strong",{children:l?.revenueSummary?.paymentsTracked??0})]}),e.jsxs("div",{className:"site-detail-grow-metric",children:[e.jsx("span",{className:"meta",children:"Stripe connected sites"}),e.jsx("strong",{children:l?.stripeSummary?.connectedSites??0})]})]}),e.jsx("p",{className:"site-detail-section-desc",children:"As payments, leads, and SEO data grow, this section will become the business dashboard for this one site."})]}):e.jsxs("div",{className:"portal-surface-state",children:[e.jsx(_,{name:"analytics",size:18}),e.jsx("span",{children:"After launch, this space will track SEO, analytics, c
1ontent updates, conversion improvements, and ongoing growth offers."})]}),a?e.jsx(Xt,{projectId:a},a):null,Za?e.jsx("p",{className:"admin-text-muted",children:"Loading Google Analytics..."}):fe?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"portal-panel-header",style:{marginTop:"1.25rem"},children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Google Analytics - last 30 days"}),e.jsx("h3",{children:"Website audience"})]})}),e.jsxs("div",{className:"site-detail-grow-metrics",children:[e.jsxs("div",{className:"site-detail-grow-metric",children:[e.jsx("span",{className:"meta",children:"Active users"}),e.jsx("strong",{children:fe.totals.active_users.toLocaleString()})]}),e.jsxs("div",{className:"site-detail-grow-metric",children:[e.jsx("span",{className:"meta",children:"Sessions"}),e.jsx("strong",{children:fe.totals.sessions.toLocaleString()})]}),e.jsxs("div",{className:"site-detail-grow-metric",children:[e.jsx("span",{className:"meta",children:"Page views"}),e.jsx("strong",{children:fe.totals.page_views.toLocaleString()})]}),e.jsxs("div",{className:"site-detail-grow-metric",children:[e.jsx("span",{className:"meta",children:"Key events"}),e.jsx("strong",{children:fe.totals.key_events.toLocaleString()})]})]}),fe.channels.length?e.jsx("div",{className:"site-overview-list",style:{marginTop:"1rem"},children:fe.channels.slice(0,5).map(s=>e.jsxs("div",{className:"site-overview-row",children:[e.jsx("span",{children:s.channel}),e.jsxs("strong",{children:[s.sessions.toLocaleString()," sessions"]})]},s.channel))}):null,e.jsxs("p",{className:"site-detail-section-desc",children:["Updated ",new Date(fe.generated_at*1e3).toLocaleString()]})]}):ua?e.jsxs("div",{className:"portal-surface-state",style:{marginTop:"1rem"},children:[e.jsx(_,{name:"analytics",size:18}),e.jsx("span",{children:ua})]}):null]}),e.jsxs("section",{className:"site-detail-section",children:[e.jsx("div",{className:"portal-panel-header",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:"Next growth moves"}),e.jsx("h3",{children:"What will help this site perform better"})]})}),e.jsxs("div",{className:"portal-action-list",children:[e.jsx("div",{className:"portal-action-card",children:e.jsxs("div",{children:[e.jsx("strong",{children:"Turn on automated SEO"}),e.jsx("span",{children:"Keep publishing and refreshing pages that help this site rank over time."})]})}),e.jsx("div",{className:"portal-action-card",children:e.jsxs("div",{children:[e.jsx("strong",{children:"Connect Stripe if you take payments"}),e.jsx("span",{children:"Track website-driven income directly inside the workspace once payments are connected."})]})}),e.jsx("div",{className:"portal-action-card",children:e.jsxs("div",{children:[e.jsx("strong",{children:"Strengthen your service pages"}),e.jsx("span",{children:"Send requested updates so Bliss can sharpen offers, proof, service areas, and conversion paths."})]})})]})]})]}),H?e.jsx("div",{className:"template-setup-modal-backdrop",role:"presentation",onMouseDown:Ye,children:e.jsxs("div",{className:"template-setup-modal",role:"dialog","aria-modal":"true","aria-labelledby":"template-setup-modal-title",onMouseDown:s=>s.stopPropagation(),children:[e.jsx("button",{type:"button",className:"template-setup-modal-close",onClick:Ye,"aria-label":"Close setup editor",children:"×"}),H==="brand"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"template-setup-modal-header",children:[e.jsx("p",{className:"eyebrow",children:$?"Organization identity":"Store identity"}),e.jsx("h3",{id:"template-setup-modal-title",children:"Brand and logo"}),e.jsx("p",{children:$?"Set the organization name, logo, colors, and default brand styling visitors will see.":"Set the store name, logo, colors, and default brand styling customers will see."})]}),e.jsxs("div",{className:"template-setup-modal-grid",children:[e.jsxs("div",{className:"template-setup-modal-fields",children:[e.jsxs("label",{className:"site-plan-field-label",children:[$?"Organization name":"Store name",e.jsx("input",{value:u.storeName,onChange:s=>de({storeName:s.target.value})})]}),e.jsxs("label",{className:"site-plan-field-label",children:["Tagline",e.jsx("input",{value:u.tagline,onChange:s=>de({tagline:s.target.value})})]}),e.jsxs("label",{className:"site-plan-field-label",children:["Logo URL",e.jsx("input",{value:u.logoUrl,placeholder:"https://...",onChange:s=>de({logoUrl:s.target.value})})]}),e.jsxs("div",{className:"template-setup-logo-upload",children:[e.jsx("div",{className:"template-setup-logo-preview",children:u.logoUrl?e.jsx("img",{src:u.logoUrl,alt:""}):e.jsx("span",{children:u.storeName.slice(0,2)||"BL"})}),e.jsxs("div",{children:[e.jsx("strong",{children:"Logo image"}),e.jsx("p",{children:"Upload a logo or keep using the URL field as a fallback."}),e.jsxs("label",{className:"template-setup-file-button",children:[oe?"Uploading...":u.logoUrl?"Change logo":"Choose logo",e.jsx("input",{type:"file",accept:"image/*",disabled:oe||Z,onChange:s=>{ct(s.target.files?.[0]),s.currentTarget.value=""}})]})]})]}),e.jsxs("div",{className:"template-setup-palette-group",children:[e.jsx("span",{children:"Style preset"}),e.jsx("div",{className:"template-setup-palette-options",children:fs.map(s=>e.jsxs("button",{type:"button",className:u.palette===s.value?"active":"",onClick:()=>
1ot(s.value),children:[e.jsxs("span",{"aria-hidden":"true",children:[e.jsx("i",{style:{backgroundColor:s.primaryColor}}),e.jsx("i",{style:{backgroundColor:s.accentColor}})]}),s.label]},s.value))}),e.jsx("small",{children:fs.find(s=>s.value===u.palette)?.description})]}),e.jsxs("div",{className:"template-setup-color-grid",children:[e.jsxs("label",{className:"site-plan-field-label",children:["Primary color",e.jsx("input",{type:"color",value:u.primaryColor,onChange:s=>de({palette:"custom",primaryColor:s.target.value})}),e.jsx("input",{value:u.primaryColor,onChange:s=>de({palette:"custom",primaryColor:s.target.value})})]}),e.jsxs("label",{className:"site-plan-field-label",children:["Accent color",e.jsx("input",{type:"color",value:u.accentColor,onChange:s=>de({palette:"custom",accentColor:s.target.value})}),e.jsx("input",{value:u.accentColor,onChange:s=>de({palette:"custom",accentColor:s.target.value})})]})]})]}),e.jsxs("aside",{className:"template-setup-brand-preview",children:[e.jsx("p",{className:"eyebrow",children:"Live brand preview"}),e.jsxs("div",{className:"template-setup-brand-preview-card",style:{"--template-brand-primary":u.primaryColor,"--template-brand-accent":u.accentColor},children:[e.jsxs("div",{className:"template-setup-brand-preview-header",children:[e.jsx("span",{children:u.logoUrl?e.jsx("img",{src:u.logoUrl,alt:""}):u.storeName.slice(0,2)||"BL"}),e.jsxs("div",{children:[e.jsx("strong",{children:u.storeName||c.name}),e.jsx("small",{children:u.tagline||Ee.subline})]})]}),e.jsxs("div",{className:"template-setup-brand-preview-hero",children:[e.jsx("small",{children:Ee.category}),e.jsx("strong",{children:Ee.headline}),e.jsx("p",{children:u.tagline||Ee.body}),e.jsxs("div",{children:[e.jsx("button",{type:"button",children:Ee.primaryCta}),e.jsx("button",{type:"button",children:Ee.secondaryCta})]})]})]}),e.jsxs("div",{className:"template-setup-share-preview",children:[e.jsx("span",{children:u.logoUrl?e.jsx("img",{src:u.logoUrl,alt:""}):u.storeName.slice(0,2)||"BL"}),e.jsxs("div",{children:[e.jsx("strong",{children:u.storeName||c.name}),e.jsx("p",{children:u.tagline||Ee.share})]})]})]})]}),rs?e.jsx("div",{className:"template-setup-modal-alert is-error",children:rs}):null,os?e.jsx("div",{className:"template-setup-modal-alert is-success",children:os}):null,e.jsxs("div",{className:"template-setup-modal-footer",children:[e.jsx("button",{type:"button",className:"ghost",onClick:Ye,disabled:Z||oe,children:"Cancel"}),e.jsx("button",{type:"button",className:"ghost",onClick:()=>void Te(),disabled:U,children:U?"Opening...":$e}),e.jsx("button",{type:"button",className:"primary",onClick:()=>void mt(),disabled:Z||oe,children:Z?"Saving...":"Save draft"})]})]}):H==="pages"&&ee?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"template-setup-modal-header",children:[e.jsx("p",{className:"eyebrow",children:"Homepage"}),e.jsx("h3",{id:"template-setup-modal-title",children:"Edit homepage"}),e.jsx("p",{children:"Update the first page families see: headline, supporting copy, calls to action, and hero image."})]}),e.jsxs("div",{className:"template-setup-modal-grid",children:[e.jsxs("div",{className:"template-setup-modal-fields",children:[e.jsxs("label",{className:"site-plan-field-label",children:["Hero eyebrow",e.jsx("input",{value:y.heroSubtitle,onChange:s=>_e({heroSubtitle:s.target.value})})]}),e.jsxs("label",{className:"site-plan-field-label",children:["H1 headline",e.jsx("input",{value:y.heroTitle,onChange:s=>_e({heroTitle:s.target.value})})]}),e.jsxs("label",{className:"site-plan-field-label",children:["Intro paragraph",e.jsx("textarea",{rows:4,value:y.heroBody,onChange:s=>_e({heroBody:s.target.value})})]}),e.jsxs("div",{className:"template-setup-color-grid",children:[e.jsxs("label",{className:"site-plan-field-label",children:["Primary button",e.jsx("input",{value:y.primaryCtaLabel,onChange:s=>_e({primaryCtaLabel:s.target.value})})]}),e.jsxs("label",{className:"site-plan-field-label",children:["Secondary button",e.jsx("input",{value:y.secondaryCtaLabel,onChange:s=>_e({secondaryCtaLabel:s.target.value})})]})]}),e.jsxs("label",{className:"site-plan-field-label",children:["Hero image URL",e.jsx("input",{value:y.heroImageUrl,placeholder:"/templates/funeral-home/hero-chapel.png",onCh
1ange:s=>_e({heroImageUrl:s.target.value})})]}),e.jsxs("div",{className:"template-setup-logo-upload",children:[e.jsx("div",{className:"template-setup-logo-preview template-setup-hero-thumb",children:y.heroImageUrl?e.jsx("img",{src:y.heroImageUrl,alt:""}):e.jsx("span",{children:"Hero"})}),e.jsxs("div",{children:[e.jsx("strong",{children:"Hero image"}),e.jsx("p",{children:"Upload a homepage image or use a URL already in the site library."}),e.jsxs("label",{className:"template-setup-file-button",children:[oe?"Uploading...":y.heroImageUrl?"Change image":"Choose image",e.jsx("input",{type:"file",accept:"image/*",disabled:oe||Z,onChange:s=>{dt(s.target.files?.[0]),s.currentTarget.value=""}})]})]})]})]}),e.jsxs("aside",{className:"template-setup-brand-preview",children:[e.jsx("p",{className:"eyebrow",children:"Homepage preview"}),e.jsxs("div",{className:"template-setup-home-preview",style:{"--template-brand-primary":u.primaryColor,"--template-brand-accent":u.accentColor},children:[y.heroImageUrl?e.jsx("img",{src:y.heroImageUrl,alt:""}):null,e.jsx("small",{children:y.heroSubtitle||"A digital care system for families"}),e.jsx("strong",{children:y.heroTitle||"Honoring Life With Care, Compassion, and Dignity."}),e.jsx("p",{children:y.heroBody||"Give families a calm place to begin arrangements, review service options, view obituaries, and stay connected."}),e.jsxs("div",{children:[e.jsx("button",{type:"button",children:y.primaryCtaLabel||"Begin Arrangements"}),e.jsx("button",{type:"button",children:y.secondaryCtaLabel||"View Obituaries"})]})]})]})]}),rs?e.jsx("div",{className:"template-setup-modal-alert is-error",children:rs}):null,os?e.jsx("div",{className:"template-setup-modal-alert is-success",children:os}):null,e.jsxs("div",{className:"template-setup-modal-footer",children:[e.jsx("button",{type:"button",className:"ghost",onClick:Ye,disabled:Z||oe,children:"Cancel"}),e.jsx("button",{type:"button",className:"ghost",onClick:()=>void Te(),disabled:U,children:U?"Opening...":$e}),e.jsx("button",{type:"button",className:"primary",onClick:()=>void pt(),disabled:Z||oe,children:Z?"Saving...":"Save homepage draft"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"template-setup-modal-header",children:[e.jsx("p",{className:"eyebrow",children:ms?.eyebrow}),e.jsx("h3",{id:"template-setup-modal-title",children:ms?.title}),e.jsx("p",{children:ms?.body})]}),e.jsx("div",{className:"template-setup-modal-placeholder",children:(ms?.bullets??[]).map(s=>e.jsxs("span",{children:[e.jsx(_,{name:"check-circle",size:16}),s]},s))}),e.jsxs("div",{className:"template-setup-modal-footer",children:[e.jsx("button",{type:"button",className:"ghost",onClick:Ye,children:"Cancel"}),H==="contact"?e.jsx("button",{type:"button",className:"ghost",onClick:()=>{Fs(null),z("launch")},children:"Launch setup"}):null,e.jsx("button",{type:"button",className:"primary",onClick:()=>void Te(),disabled:U,children:U?"Opening...":$e})]})]})]})}):null,O?e.jsx("div",{className:"site-detail-back",children:e.jsx(V,{to:"/dashboard/sites",className:"portal-link site-detail-back-link",children:"Back to sites"})}):null,Ia]})}export{un 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.