1import{j as e,u as Ae}from"./data-DN-eP4ae.js";import{r as d,k as _t}from"./react-BUOzgyp0.js";import{B as G,gP as Nt,s as Me,bF as we,ax as St,c as se,dV as kt,bA as Be,a4 as ye,J as Ct,bu as Ft,av as W,aT as Tt,ay as Et,A as Pt,n as fe}from"./index-6GUxm5Tl.js";import{S as De,a as ze,b as Ue,c as Ve,d as Xe}from"./select-C1j_15i9.js";import{a as tt,R as st}from"./radio-group-CORZjgwn.js";import{S as It}from"./SubmissionReceipt-Czuzjal6.js";import{s as Rt,o as He,c as $t,r as qt,u as Lt,h as Ot,g as At,a as Mt,f as Ge,i as Je,e as me,j as Ke,t as Ze,k as We,p as Ye,d as Bt,S as Dt,v as zt,w as Ut,x as Qe}from"./usePublicCatalog-D2AxmdpI.js";import{l as Vt,r as Xt}from"./resilient-config-DDzJFn4_.js";import{s as ie}from"./publicClient-9ctSWRjg.js";import{r as Ht,i as Gt}from"./index-BcGPsw-6.js";import{d as Jt}from"./index-Cfh7sjn9.js";import{w as Kt}from"./form-fields-CvZ2Waut.js";import{M as Zt}from"./minus-DzNOUrXP.js";import{u as Wt}from"./usePublicOrgBranding-CJd6EbdP.js";import{u as Yt}from"./head-BBAUgEcO.js";import{P as Qt,s as rt,a as es,b as ts}from"./phone-input-N3YvTTa3.js";import{U as ss}from"./upload-ByQVSpnZ.js";import"./documents-Bju1cS7G.js";import"./charts-BjVT6r80.js";import"./FormAnswerFields-IktbIzHR.js";import"./pencil-DC8kxVxB.js";import"./save-Bg7aMJuF.js";import"./format-BOCe1Q81.js";import"./star-BwrGBDd5.js";const rs=({value:r,onChange:n,invalid:s,disabled:l})=>{const v=d.useRef(null),N=d.useRef(!1),[E,w]=d.useState(!!r);d.useEffect(()=>{const h=v.current;if(!h)return;const y=h.getContext("2d");y&&(y.lineWidth=2,y.lineCap="round",y.lineJoin="round",y.strokeStyle=getComputedStyle(h).color||"#000")},[]);const P=h=>{const y=h.currentTarget.getBoundingClientRect();return{x:(h.clientX-y.left)/y.width*h.currentTarget.width,y:(h.clientY-y.top)/y.height*h.currentTarget.height}},S=h=>{if(l)return;h.currentTarget.setPointerCapture(h.pointerId);const y=h.currentTarget.getContext("2d");if(!y)return;const{x:R,y:$}=P(h);y.beginPath(),y.moveTo(R,$),N.current=!0},U=h=>{if(!N.current||l)return;const y=h.currentTarget.getContext("2d");if(!y)return;const{x:R,y:$}=P(h);y.lineTo(R,$),y.stroke(),w(!0)},V=h=>{N.current&&(N.current=!1,n(h.currentTarget.toDataURL("image/png")))},X=()=>{const h=v.current,y=h==null?void 0:h.getContext("2d");!h||!y||(y.clearRect(0,0,h.width,h.height),w(!1),n(""))};return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("canvas",{ref:v,width:600,height:180,onPointerDown:S,onPointerMove:U,onPointerUp:V,onPointerLeave:V,className:`w-full h-[120px] rounded-md border bg-background touch-none text-foreground ${s?"border-destructive":""}`}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:E?"Signature captured":"Sign inside the box using your finger or mouse"}),e.jsxs(G,{type:"button",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:X,disabled:l,children:[e.jsx(Nt,{className:"h-3 w-3 mr-1"})," Clear"]})]})]})};async function ns(r,n){return Vt({kind:"form",id:n?`${r}.${n}`:r,timeoutMs:12e3,loadLive:async()=>{const s={_slug:r};n&&(s._org_id=n);const{data:l,error:v}=await Me.rpc("get_public_form_by_slug",s);if(v)throw v;return l||null},onLiveSuccess:()=>Xt(r,n),loadSnapshot:async()=>{var E;const s={_slug:r};n&&(s._org_id=n);const{data:l,error:v}=await Me.rpc("get_public_form_snapshot",s);if(v||!l)return null;const N=l;return(E=N==null?void 0:N.data)!=null&&E.id?{data:N.data,publishedAt:N.published_at??null}:null}})}const nt=ie;async function as(r){const{data:n,error:s}=await nt.rpc("get_public_review_form",{p_token:r});return s||!n?{kind:"missing"}:n.expired?{kind:"expired"}:{kind:"ok",review:n}}async function be(r,n){try{await nt.rpc("record_review_evidence",{p_token:r,p_event_type:n})}catch{}}const at=["website_url_confirm","company_fax"],it="",_e=it.length>0,is="https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit";let pe=null;function os(){return!_e||typeof window>"u"||window.turnstile?Promise.resolve():pe||(pe=new Promise(r=>{const n=document.createElement("script");n.src=is,n.async=!0,n.defer=!0,n.onload=()=>r(),n.onerror=()=>r(),document.head.appendChild(n)}),pe)}function ot(){return at.reduce((r,n)=>(r[n]="",r),{})}function cs(r){const n=Date.now();return{bot_token:r.botToken??null,honeypot:r.honeypot??ot(),started_at:r.startedAt,elapsed_ms:Math.max(0,n-r.startedAt),page:typeof window<"u"?window.location.pathname:null,referrer:typeof document<"u"&&document.referrer||null,screen:typeof window<"u"&&window.screen?`${window.screen.width}x${window.screen.height}`:null,timezone:typeof Intl<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone??null:null}}
1function ls(){const r=d.useRef(Date.now()),[n,s]=d.useState(ot),[l,v]=d.useState(null),N=d.useCallback(()=>cs({botToken:l,honeypot:n,startedAt:r.current}),[l,n]);return{honeypot:n,setHoneypot:s,botToken:l,setBotToken:v,evidence:N,startedAt:r}}function ds({values:r,onChange:n}){return e.jsx("div",{"aria-hidden":"true",className:"absolute left-[-9999px] top-auto h-px w-px overflow-hidden",children:at.map(s=>e.jsx("input",{type:"text",name:s,tabIndex:-1,autoComplete:"off",value:r[s]??"",onChange:l=>n({...r,[s]:l.target.value})},s))})}function us({onToken:r}){const n=d.useRef(null),s=d.useRef(null);return d.useEffect(()=>{if(!_e)return;let l=!1;return os().then(()=>{if(!(l||!n.current||!window.turnstile||s.current))try{s.current=window.turnstile.render(n.current,{sitekey:it,callback:v=>r(v),"expired-callback":()=>r(null),"error-callback":()=>r(null),appearance:"interaction-only",size:"flexible"})}catch{}}),()=>{if(l=!0,s.current&&window.turnstile){try{window.turnstile.remove(s.current)}catch{}s.current=null}}},[r]),_e?e.jsx("div",{ref:n,className:"flex justify-center"}):null}function ms({field:r,items:n,selections:s,onChange:l,loading:v,invalid:N}){var R,$,re,ne;const E=r.catalogMultiple!==!1,w=r.catalogQuantity!==!1,P=(R=r.catalogItemIds)!=null&&R.length?n.filter(x=>r.catalogItemIds.includes(x.id)):n,S=x=>s.find(_=>_.offer_id===x),U=(x,_)=>{const I={offer_id:x.id,name:x.name,unit_price:Number(x.price)||0,quantity:1,currency:x.currency_code};if(!E){l(_?[I]:[]);return}l(_?[...s,I]:s.filter(q=>q.offer_id!==x.id))},V=(x,_)=>{l(s.map(I=>I.offer_id===x?{...I,quantity:Math.max(1,Math.min(99,_))}:I))},X=(($=s[0])==null?void 0:$.currency)||((re=P[0])==null?void 0:re.currency_code)||"NGN",h=Rt(s);if(v)return e.jsx("p",{className:"text-xs text-muted-foreground",children:"Loading products and services..."});if(P.length===0)return e.jsx("p",{className:"text-xs text-muted-foreground",children:"No items are available right now."});const y=P.map(x=>{const _=S(x.id),I=x.price!==null&&x.price!==void 0&&Number(x.price)>0;return e.jsx("div",{className:se("rounded-lg border p-3 transition-colors",_?"border-primary bg-primary/5":"hover:bg-muted/40"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[E?e.jsx(we,{checked:!!_,onCheckedChange:q=>U(x,!!q),className:"mt-0.5"}):e.jsx(tt,{value:x.id,className:"mt-0.5"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("p",{className:"text-sm font-medium leading-tight",children:x.name}),e.jsx("p",{className:"text-sm font-semibold shrink-0",children:I?He(Number(x.price),x.currency_code):"On request"})]}),x.short_description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-2",children:x.short_description}),_&&w&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx(G,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>V(x.id,_.quantity-1),children:e.jsx(Zt,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-sm w-6 text-center tabular-nums",children:_.quantity}),e.jsx(G,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>V(x.id,_.quantity+1),children:e.jsx(St,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:x.unit_label?x.unit_label:"qty"})]})]})]})},x.id)});return e.jsxs("div",{className:se("space-y-2",N&&"rounded-lg ring-1 ring-destructive p-1"),children:[E?e.jsx("div",{className:"space-y-2",children:y}):e.jsx(st,{value:((ne=s[0])==null?void 0:ne.offer_id)||"",onValueChange:x=>{const _=P.find(I=>I.id===x);_&&U(_,!0)},className:"space-y-2",children:y}),s.length>0&&h>0&&e.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-muted/60 px-3 py-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1.5",children:[e.jsx(kt,{className:"h-3.5 w-3.5"})," Order total"]}),e.jsx("span",{className:"text-sm font-semibold",children:He(h,X)})]})]})}const je=10;function ps(r){const n=`form_idem_${r}`;try{const s=sessionStorage.getItem(n);if(s)return s;const l=crypto.randomUUID();return sessionStorage.setItem(n,l),l}catch{return`${r}-${Date.now()}`}}function et(r){try{sessionStorage.removeItem(`form_idem_${r}`)}catch{}}const hs=["image/png","image/jpeg","image/webp","image/gif","application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","text/csv","text/plain"],xs=".png,.jpg,.jpeg,.webp,.gif,.pdf,.doc,.docx,.xls,.xlsx,.csv,.txt";function Ne(r){return`form_draft_${r}`}function gs(r){try{const n=localStorage.getItem(Ne(r));if(!n)return null;const s=JSON.parse(n);return!s||typeof s!="object"||!s.responses||Object.keys(s.responses).length===0?null:{responses:s.responses,step:Number(s.step)||0}}catch{return null}}function ys(r,n,s){try{localStorage.setItem(Ne(r),JSON.stringify({responses:n,step:s,at:Date.now()}))}catch{}}function ve(r){try{localStorage.removeItem(Ne(r))}catch{}}function fs(r){const{branding:n}=Wt((r==null?void 0:r.org_id)??null);Yt(r!=null&&r.name?{kind:"form",label:r.name,publicDescription:r.description??null,orgName:(n==null?void 0:n.business_name)??null,imageUrl:(n==null?void 0:n.logo_url)??null,url:window.location.href.split("?")[0]}:null)}const ae={full_name:{pattern:/^[A-Za-zÃ-ÿ0-9'.,\u2019 \-]{2,100}
1$/,message:"Name must be 2â100 characters (letters, spaces, hyphens, apostrophes or periods)",sanitize:r=>r.replace(/[^A-Za-zÃ-ÿ0-9'.,\u2019 \-]/g,"")},email:{pattern:/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/,message:"Please enter a valid email address"},phone:{pattern:ts,message:es,sanitize:rt},company:{pattern:/^[A-Za-zÃ-ÿ0-9 &.,'\-]{1,150}$/,message:"Company name contains invalid characters (max 150 chars)"},job_title:{pattern:/^[A-Za-zÃ-ÿ0-9 &.,'/\-]{1,100}$/,message:"Job title contains invalid characters (max 100 chars)"},location:{pattern:/^[A-Za-zÃ-ÿ0-9 ,.\-]{1,150}$/,message:"Location contains invalid characters"},cover_letter:{pattern:/^[\s\S]{0,5000}$/,message:"Cover letter must be under 5,000 characters"}};function ct(r){return ae[r.id]?ae[r.id]:r.type==="email"?ae.email:r.type==="phone"||r.type==="tel"?ae.phone:r.type==="text"&&/\bname\b/i.test(r.label)&&!/company|business|event/i.test(r.label)?ae.full_name:null}function H(r,n){const s=n.trim();if(r.required&&!s)return`${r.label} is required`;if(!s)return null;const l=ct(r);return l&&!l.pattern.test(s)?l.message:Ut(r,s)}const Us=()=>{var qe;const{slug:r,token:n}=_t(),[s,l]=d.useState({}),[v,N]=d.useState({}),[E,w]=d.useState({}
1),[P,S]=d.useState({}),[U,V]=d.useState(!1),X=ls(),[h,y]=d.useState(null),[R,$]=d.useState(!1),[re,ne]=d.useState(null),[x,_]=d.useState(null),[I,q]=d.useState(0),[lt,Se]=d.useState(!1),[ke,Ce]=d.useState({}),[oe,Fe]=d.useState(null),Te=d.useRef(!1),Ee=new URLSearchParams(window.location.search).get("org"),{data:M}=Ae({queryKey:["public-review",n],queryFn:async()=>n?await as(n):null,enabled:!!n,retry:1}),B=(M==null?void 0:M.kind)==="ok"?M.review:null,{data:Y,isLoading:dt,error:ut}=Ae({queryKey:["public-form",r,Ee],queryFn:async()=>r?await ns(r,Ee):null,enabled:!!r&&!n,retry:1}),mt=n?!M:dt,o=(B==null?void 0:B.form)??(Y==null?void 0:Y.data)??null;Y==null||Y.source,fs(o);const J=o!=null&&o.id?n?`${o.id}:${n}`:o.id:"",C=d.useMemo(()=>Kt(Array.isArray(o==null?void 0:o.fields)?o.fields:[]),[o==null?void 0:o.fields]),Q=(o==null?void 0:o.settings)||{},Pe=Q.success_message||Q.successMessage||"Thank you for your submission!",pt=C.some(t=>t.type==="catalog"),{data:ht=[],isLoading:xt}=$t(pt?o==null?void 0:o.org_id:null),j=d.useMemo(()=>qt(o==null?void 0:o.style),[o==null?void 0:o.style]);Lt(j);const ce=j.background.image&&(j.background.overlay||0)>0?(j.background.overlay||0)/100:0,le=se("bg-card border shadow-sm p-6",Ot[j.card.radius||"rounded"]),ee=d.useMemo(()=>At(Q,C),[o==null?void 0:o.id,JSON.stringify(Q.sections||null),C.length]),D=d.useMemo(()=>Mt(ee,C,s),[ee,C,s]),K=D.length>1,L=Math.min(I,Math.max(D.length-1,0)),z=D[L],Ie=z?Ge(C,z,ee).filter(t=>Je(t,s)):C.filter(t=>Je(t,s)),he=L>=D.length-1;d.useEffect(()=>{if(!(o!=null&&o.id)||Te.current)return;Te.current=!0;const t=gs(J);t&&(l(t.responses),q(t.step),Se(!0))},[o==null?void 0:o.id]),d.useEffect(()=>{if(!(o!=null&&o.id)||R||Object.keys(s).length===0)return;const t=setTimeout(()=>ys(J,s,L),600);return()=>clearTimeout(t)},[s,L,o==null?void 0:o.id,R]),d.useEffect(()=>{!n||!B||(be(n,"link_clicked"),be(n,"viewed"))},[n,B]);const Re=d.useRef(!1);d.useEffect(()=>{!n||Re.current||Object.keys(s).length!==0&&(Re.current=!0,be(n,"started"))},[s,n]);const O=d.useCallback((t,m)=>{const c=ct(t),f=c!=null&&c.sanitize?c.sanitize(m):m;l(u=>({...u,[t.id]:f})),w(u=>({...u,[t.id]:P[t.id]?H(t,f):u[t.id]}))},[P]),te=d.useCallback(t=>{S(m=>({...m,[t.id]:!0})),w(m=>({...m,[t.id]:H(t,s[t.id]||"")}))},[s]),gt=d.useCallback((t,m)=>{if(S(c=>({...c,[t.id]:!0})),!m){N(c=>{const f={...c};return delete f[t.id],f}),l(c=>({...c,[t.id]:""})),w(c=>({...c,[t.id]:t.required?`${t.label} is required`:null}));return}if(!hs.includes(m.type)){w(c=>({...c,[t.id]:`Unsupported file type "${m.name.split(".").pop()}". Accepted: PNG, JPG, PDF, DOC, DOCX, XLS, XLSX, CSV, TXT`}));return}if(m.size>je*1024*1024){w(c=>({...c,[t.id]:`File is too large (${(m.size/1024/1024).toFixed(1)}MB). Maximum size is ${je}MB.`}));return}N(c=>({...c,[t.id]:m})),l(c=>({...c,[t.id]:m.name})),w(c=>({...c,[t.id]:null}))},[]),yt=t=>new Promise((m,c)=>{const f=new FileReader;f.onload=()=>{const u=String(f.result||"");m(u.slice(u.indexOf(",")+1))},f.onerror=()=>c(new Error("The file could not be read")),f.readAsDataURL(t)}),ft=async(t,m)=>{const c={};for(const[f,u]of Object.entries(v)){const a=await yt(u),{data:i,error:p}=await ie.functions.invoke("form-upload",{body:{orgId:t,formId:m,fieldId:f,fileName:u.name,contentType:u.type,fileBase64:a}}),b=i==null?void 0:i.publicUrl;if(p||!b)throw new Error(`File upload failed for "${u.name}"`);c[f]=b}return c},bt=(t,m)=>{const c={};let f=!1;if(t.forEach(u=>{if(u.type==="file")u.required&&!v[u.id]&&(c[u.id]=`${u.label} is required - please select a file to upload`,f=!0);else{const a=H(u,s[u.id]||"");c[u.id]=a,a&&(f=!0)}}),w(u=>({...u,...c})),S(u=>({...u,...Object.fromEntries(t.map(a=>[a.id,!0]))})),f){const u=Object.entries(c).filter(([,a])=>a).map(([a,i])=>{const p=t.find(b=>b.id===a);return p?`${p.label}: ${i}`:i});fe.error(m,{description:u.slice(0,3).join(" ⢠")+(u.length>3?` and ${u.length-3} more`:"")})}return!f},$e=()=>{bt(Ie,"Please fix the errors below")&&(q(Math.min(L+1,D.length-1)),window.scrollTo({top:0,behavior:"smooth"}))},jt=()=>{q(Math.max(L-1,0)),window.scrollTo({top:0,behavior:"smooth"})},vt=async t=>{var u,a;if(t.preventDefault(),K&&!he){$e();return}const m={};let c=!1;
1if(Qe(ee,C,s).forEach(i=>{if(i.type==="file")i.required&&!v[i.id]&&(m[i.id]=`${i.label} is required - please select a file to upload`,c=!0);else{const p=H(i,s[i.id]||"");m[i.id]=p,p&&(c=!0)}}),w(m),S(Object.fromEntries(C.map(i=>[i.id,!0]))),c){const i=Object.entries(m).filter(([,b])=>b).map(([b,T])=>{const k=C.find(de=>de.id===b);return k?`${k.label}: ${T}`:T}),p=(u=Object.entries(m).find(([,b])=>b))==null?void 0:u[0];if(p&&K){const b=D.findIndex(T=>Ge(C,T,ee).some(k=>k.id===p));b>=0&&q(b)}fe.error("Please fix the errors below",{description:i.slice(0,3).join(" ⢠")+(i.length>3?` â¦and ${i.length-3} more`:"")});return}if(o){V(!0);try{let i={};Object.keys(v).length>0&&(i=await ft(o.org_id,o.id));const p=new Set(Qe(ee,C,s).map(A=>A.id)),T={...Object.fromEntries(Object.entries(s).filter(([A])=>p.has(A)||p.has(A.replace(/__referrer$/,"")))),...i},k=new URLSearchParams(window.location.search),de=Object.fromEntries(Object.entries(ke).filter(([A,ge])=>p.has(A)&&ge.length>0)),{data:g,error:Le}=await ie.functions.invoke("form-submit",{body:{form_id:o.id,slug:o.slug,org_id:o.org_id,idempotency_key:ps(J),data:T,review_token:n??void 0,capture:X.evidence(),metadata:{review_token:n??void 0,utm_source:k.get("utm_source"),utm_medium:k.get("utm_medium"),utm_campaign:k.get("utm_campaign"),catalog_selections:Object.keys(de).length>0?de:void 0}}});if(Le)throw Le;if(g&&g.success===!1)throw new Error(g.error||"Submission failed");if(g!=null&&g.held_for_review){et(J),ve(J),y(g.message||"Thank you. We have your request and will be in touch shortly."),$(!0);return}if(n){const A=Ht(C,T),{averageRating:ge,sentiment:wt}=Gt(A);try{await ie.rpc("complete_review_from_submission",{p_token:n,p_submission_id:(g==null?void 0:g.submission_id)??null,p_average_rating:ge,p_sentiment:wt})}catch{}}const ue=C.find(A=>A.type==="referral_source"),Oe=ue?T[ue.id]:null;if(ue&&Oe&&(g!=null&&g.contact_id))try{await ie.rpc("resolve_form_referral",{p_form_id:o.id,p_contact_id:g.contact_id,p_source:Oe,p_referrer_text:T[`${ue.id}__referrer`]||null})}catch{}et(J),ve(J);const xe=Q.redirect_url;if(xe&&/^https?:\/\//i.test(xe)){window.location.href=xe;return}const Z=(a=g==null?void 0:g.results)==null?void 0:a.create_invoice;(Z==null?void 0:Z.status)==="created"&&Z.url&&Fe({url:Z.url,number:Z.invoice_number??null,total:Number(Z.total??0)}),_((g==null?void 0:g.edit_token)??null),ne({submission_id:(g==null?void 0:g.submission_id)??"",form_name:o.name,form_description:o.description,success_message:Pe,fields:C,data:T,submitted_at:new Date().toISOString(),edit_history:[],can_edit:!!(g!=null&&g.edit_token)&&Q.allow_respondent_edit!==!1,expires_at:(g==null?void 0:g.edit_expires_at)??null}),$(!0)}catch(i){const p=(i==null?void 0:i.message)||"Unknown error",b=p.toLowerCase();b.includes("file upload failed")||b.includes("row-level security")||b.includes("permission")||b.includes("failed to fetch")||b.includes("network")||b.includes("too large")||b.includes("payload")||b.includes("duplicate")||`${p.length>120?p.slice(0,120)+"â¦":p}`,console.error("[FormSubmission]",p,i),fe.error("Submission failed")}finally{V(!1)}}};if(mt)return e.jsx("div",{className:"flex items-center justify-center min-h-screen bg-background",children:e.jsx(Be,{className:"h-8 w-8 animate-spin text-primary"})});if(n&&M&&M.kind!=="ok")return e.jsx("div",{className:"flex items-center justify-center min-h-screen bg-background",children:e.jsxs("div",{className:"text-center space-y-2 max-w-md p-8",children:[e.jsx("h1",{className:"text-2xl font-bold",children:M.kind==="expired"?"This review link has expired":"Review not found"}),e.jsx("p",{className:"text-muted-foreground",children:M.kind==="expired"?"Please ask the business for a fresh link.":"This link may have been removed or already replaced."})]})});if(B&&B.completed_at&&!R)return e.jsx("div",{className:"flex items-center justify-center min-h-screen bg-background",children:e.jsxs("div",{className:"text-center space-y-2 max-w-md p-8",children:[e.jsx(ye,{className:"h-8 w-8 text-primary mx-auto","aria-hidden":"true"}),e.jsx("h1",{className:"text-xl font-semibold",children:"Thank y
1ou - we have your feedback"}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:["You already completed this review",(qe=B.business)!=null&&qe.name?` for ${B.business.name}`:"","."]})]})});if(ut||!o)return e.jsx("div",{className:"flex items-center justify-center min-h-screen bg-background",children:e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Form not found"}),e.jsx("p",{className:"text-muted-foreground",children:"This form may have been removed or is no longer active."})]})});if(o&&o.status==="paused")return e.jsx("div",{className:"flex items-center justify-center min-h-screen bg-background",children:e.jsxs("div",{className:"text-center space-y-3 max-w-md mx-auto p-8",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Form Closed"}),e.jsx("p",{className:"text-muted-foreground",children:"This form is no longer accepting responses. Please check back later."})]})});if(R)return e.jsxs("div",{className:"relative min-h-screen bg-background flex items-start justify-center py-12 px-4",style:Ye(j),children:[ce>0&&e.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{backgroundColor:`rgba(0,0,0,${ce})`}}
1),e.jsxs("div",{className:"relative w-full max-w-md space-y-4",style:{...We(j),...Ze(j)},children:[oe&&e.jsxs("div",{className:se(le,"space-y-2"),style:me(j),children:[e.jsx("p",{className:"text-sm font-semibold",children:"Your order invoice is ready"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[oe.number?`Invoice ${oe.number}. `:"","Open it to see payment details and upload your proof of payment. We will confirm and send your receipt once the payment is verified."]}),e.jsx(G,{asChild:!0,className:"w-full",children:e.jsx("a",{href:oe.url,target:"_blank",rel:"noopener noreferrer",children:"View invoice"})})]}),h?e.jsxs("div",{className:se(le,"space-y-2 text-center"),style:me(j),children:[e.jsx(ye,{className:"mx-auto h-10 w-10 text-primary"}),e.jsx("p",{className:"text-sm font-semibold",children:"Thank you"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:h})]}):re?e.jsx(It,{token:x,initial:re,footer:e.jsx("div",{className:"text-center",children:e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>{$(!1),ne(null),_(null),l({}),N({}),w({}),S({}),Ce({}),Fe(null),q(0)},children:"Submit another response"})})}):e.jsxs("div",{className:se(le,"text-center space-y-3"),style:me(j),children:[e.jsx(ye,{className:"h-12 w-12 text-primary mx-auto"}),e.jsx("h2",{className:"text-xl font-semibold",children:Pe})]}),j.bottom_banner.showAfterSubmit!==!1&&e.jsx(Ke,{style:j})]})]});const F=({fieldId:t})=>{const m=E[t];return!m||!P[t]?null:e.jsx("p",{className:"text-xs font-medium text-destructive mt-1",children:m})};return e.jsxs("div",{className:"relative min-h-screen bg-background flex items-start justify-center py-12 px-4",style:Ye(j),children:[ce>0&&e.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{backgroundColor:`rgba(0,0,0,${ce})`}}
1),e.jsxs("div",{className:"relative w-full max-w-md space-y-4",style:{...We(j),...Ze(j)},children:[e.jsx(Bt,{style:j}),e.jsxs("div",{className:le,style:me(j),children:[e.jsxs("div",{className:"mb-6 space-y-1.5",children:[e.jsx("h1",{className:"text-xl font-bold leading-tight",children:o.name}),o.description&&e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-line break-words",children:o.description})]}),lt&&e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-2 rounded-lg border bg-muted/40 px-3 py-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"We restored your saved answers."}),e.jsx("button",{type:"button",className:"text-xs font-medium underline underline-offset-2",onClick:()=>{o!=null&&o.id&&ve(o.id),l({}),w({}),S({}),q(0),Se(!1)},children:"Start over"})]}),K&&e.jsxs("div",{className:"mb-5 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Step ",L+1," of ",D.length]}),e.jsxs("span",{children:[Math.round((L+1)/D.length*100),"%"]})]}),e.jsx(Ct,{value:(L+1)/D.length*100,className:"h-1.5"})]}),z&&K&&(z.title||z.description)&&e.jsxs("div",{className:"mb-4 space-y-0.5",children:[z.title&&e.jsx("h2",{className:"text-base font-semibold",children:z.title}),z.description&&e.jsx("p",{className:"text-xs text-muted-foreground whitespace-pre-line",children:z.description})]}),e.jsxs("form",{onSubmit:vt,noValidate:!0,className:"space-y-4",children:[Ie.map(t=>{var u;const m=((u=t.options)==null?void 0:u.split(",").map(a=>a.trim()).filter(Boolean))||[],c=P[t.id]&&!!E[t.id],f=c?"border-destructive focus-visible:ring-destructive":"";return e.jsxs("div",{className:"space-y-1.5",children:[t.type!=="hidden"&&e.jsxs(Ft,{className:"text-sm",children:[t.label,t.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),t.type==="text"&&e.jsxs(e.Fragment,{children:[e.jsx(W,{placeholder:t.placeholder,required:t.required,value:s[t.id]||"",onChange:a=>O(t,a.target.value),onBlur:()=>te(t),className:f,maxLength:150}),e.jsx(F,{fieldId:t.id})]}),t.type==="email"&&e.jsxs(e.Fragment,{children:[e.jsx(W,{type:"email",placeholder:t.placeholder||"[email protected]",required:t.required,value:s[t.id]||"",onChange:a=>O(t,a.target.value),onBlur:()=>te(t),className:f,maxLength:255}),e.jsx(F,{fieldId:t.id})]}),(t.type==="phone"||t.type==="tel")&&e.jsxs(e.Fragment,{children:[e.jsx(W,{type:"tel",inputMode:"numeric",placeholder:t.placeholder||"08000000000",required:t.required,value:s[t.id]||"",onChange:a=>O(t,rt(a.target.value)),onBlur:()=>te(t),className:f,maxLength:Qt}),e.jsx(F,{fieldId:t.id})]}),t.type==="number"&&e.jsxs(e.Fragment,{children:[e.jsx(W,{type:"number",placeholder:t.placeholder||"0",required:t.required,value:s[t.id]||"",onChange:a=>O(t,a.target.value),onBlur:()=>te(t),className:f,min:0}),e.jsx(F,{fieldId:t.id})]}),(t.type==="date"||t.type==="time")&&e.jsxs(e.Fragment,{children:[e.jsx(W,{type:t.type,required:t.required,value:s[t.id]||"",onChange:a=>O(t,a.target.value),onBlur:()=>te(t),className:f}),e.jsx(F,{fieldId:t.id})]}),t.type==="signature"&&e.jsxs(e.Fragment,{children:[e.jsx(rs,{value:s[t.id],invalid:c,onChange:a=>{l(i=>({...i,[t.id]:a})),S(i=>({...i,[t.id]:!0})),w(i=>({...i,[t.id]:t.required&&!a?`${t.label} is required`:null}))}}),e.jsx(F,{fieldId:t.id})]}),(t.type==="rating"||t.type==="recommendation")&&e.jsxs(e.Fragment,{children:[e.jsx(Dt,{kind:t.type,value:s[t.id]||"",onChange:a=>{O(t,a),S(i=>({...i,[t.id]:!0})),w(i=>({...i,[t.id]:null}))}}),e.jsx(F,{fieldId:t.id})]}),t.type==="referral_source"&&e.jsxs(e.Fragment,{children:[e.jsxs(De,{required:t.required,value:s[t.id]||"",onValueChange:a=>{O(t,a),l(i=>({...i,[`${t.id}__referrer`]:""}))},children:[e.jsx(ze,{className:f,children:e.jsx(Ue,{placeholder:"Select one"})}),e.jsx(Ve,{children:Jt.map(a=>e.jsx(Xe,{value:a,children:a},a))})]}),["Existing customer","Team member","Partner"].includes(s[t.id]||"")&&e.jsx(W,{className:"mt-2",placeholder:s[t.id]==="Team member"?"Who referred you? (their name)":"Who referred you? (name, phone or email)",value:s[`${t.id}__referrer`]||"",onChange:a=>l(i=>({...i,[`${t.id}__referrer`]:a.target.value})),maxLength:120}),e.jsx(F,{fieldId:t.id})]}),t.type==="textarea"&&e.jsxs(e.Fragment,{children:[e.jsx(Tt,{placeholder:t.placeholder,rows:3,required:t.required,value:s[t.id]||"",onChange:a=>O(t,a.target.value),onBlur:()=>te(t),className:c?"border-destructive focus-visible:ring-destructive":"",maxLength:5e3}),e.jsx(F,{fieldId:t.id})]}),(t.type==="dropdown"||t.type==="select")&&e.jsxs(e.Fragment,{children:[e.jsxs(De,{required:t.required,value:s[t.id]||"",onValueChange:a=>{O(t,a),S(i=>({...i,[t.id]:!0})),w(i=>({...i,[t.id]:H(t,a)}))},children:[e.jsx(ze,{className:c?"border-destructive":"",children:e.jsx(Ue,{placeholder:t.placeholder||"Select an option"})}),e.jsx(Ve,{children:m.map(a=>e.jsx(Xe,{value:a,children:a},a))})]}),e.jsx(F,{fieldId:t.id})]}),t.type==="checkbox"&&e.jsxs("div",{className:"space-y-2",children:[m.length>0?m.map(a=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{checked:(s[t.id]||"").split(";").includes(a),onCheckedChange:i=>{const p=(s[t.id]||"").split(";
1").filter(Boolean),T=(i?[...p,a]:p.filter(k=>k!==a)).join(";");l(k=>({...k,[t.id]:T})),S(k=>({...k,[t.id]:!0})),w(k=>({...k,[t.id]:H(t,T)}))}}),e.jsx("span",{className:"text-sm",children:a})]},a)):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{checked:s[t.id]==="true",onCheckedChange:a=>{const i=a?"true":"false";l(p=>({...p,[t.id]:i}))}}),e.jsx("span",{className:"text-sm",children:t.label})]}),e.jsx(F,{fieldId:t.id})]}),t.type==="radio"&&e.jsxs(e.Fragment,{children:[e.jsx(st,{value:s[t.id]||"",onValueChange:a=>{O(t,a),S(i=>({...i,[t.id]:!0})),w(i=>({...i,[t.id]:H(t,a)}))},children:m.map(a=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(tt,{value:a}),e.jsx("span",{className:"text-sm",children:a})]},a))}),e.jsx(F,{fieldId:t.id})]}),t.type==="file"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(W,{type:"file",accept:xs,className:`text-sm ${c?"border-destructive":""}`,onChange:a=>{var i;return gt(t,((i=a.target.files)==null?void 0:i[0])||null)}}),v[t.id]&&!E[t.id]&&e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(ss,{className:"h-3 w-3"}),v[t.id].name," (",(v[t.id].size/1024).toFixed(0),"KB)"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Max ",je,"MB ⢠PNG, JPG, PDF, DOC, DOCX, XLS, XLSX, CSV, TXT"]})]}),e.jsx(F,{fieldId:t.id})]}),t.type==="catalog"&&e.jsxs(e.Fragment,{children:[e.jsx(ms,{field:t,items:ht,loading:xt,invalid:c,selections:ke[t.id]||[],onChange:a=>{Ce(p=>({...p,[t.id]:a}));const i=zt(a);l(p=>({...p,[t.id]:i})),S(p=>({...p,[t.id]:!0})),w(p=>({...p,[t.id]:H(t,i)}))}}),e.jsx(F,{fieldId:t.id})]}),t.type==="hidden"&&e.jsx("input",{type:"hidden",name:t.id,value:s[t.id]||""})]},t.id)}),e.jsx(ds,{values:X.honeypot,onChange:X.setHoneypot}),(!K||he)&&e.jsx(us,{onToken:X.setBotToken}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[K&&L>0&&e.jsxs(G,{type:"button",variant:"outline",className:"flex-1",onClick:jt,disabled:U,children:[e.jsx(Et,{className:"h-4 w-4 mr-1"})," Back"]}),K&&!he?e.jsxs(G,{type:"button",className:"flex-1",onClick:$e,style:j.card.accent?{backgroundColor:j.card.accent,color:"#fff"}:void 0,children:["Next ",e.jsx(Pt,{className:"h-4 w-4 ml-1"})]}):e.jsxs(G,{type:"submit",className:"flex-1",disabled:U,style:j.card.accent?{backgroundColor:j.card.accent,color:"#fff"}:void 0,children:[U&&e.jsx(Be,{className:"h-4 w-4 mr-2 animate-spin"}),"Submit"]})]})]})]}),e.jsx(Ke,{style:j})]})]})};export{Us 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.