1import{j as e}from"./query-CkjDa6TK.js";import{j as K,a as c}from"./react-DkkCGPT4.js";import{eZ as V,e_ as ee,D as $,q as p,E as se,f as G,af as te,I as u,b4 as re,A as ae}from"./index-BYV5a2iT.js";import{f as ne}from"./confetti-CgkQzud_.js";import{C as ie}from"./circle-alert-DsJiIWhi.js";import{P as le}from"./printer-B8lShu_w.js";import{P as X}from"./pen-tool-D2CWgXI0.js";import{U as oe}from"./user-nxWDl_hy.js";import{R as ce}from"./rotate-ccw-B03aJoRq.js";import"./forms-xixe_uvK.js";function ye(){var U,F;const{id:k}=K(),g=V(k),C=ee(k),[o,j]=c.useState({}),[b,B]=c.useState(""),[y,z]=c.useState(""),[S,_]=c.useState(""),[q,P]=c.useState(""),[H,J]=c.useState(!1),x=c.useRef(null),[M,D]=c.useState(!1),[N,R]=c.useState(!1),[O,A]=c.useState(""),[f,T]=c.useState(null),i=(U=g.data)==null?void 0:U.template,d=(F=g.data)==null?void 0:F.organisation;c.useEffect(()=>{const s=x.current;if(!s)return;const r=s.getContext("2d");if(!r)return;const n=s.getBoundingClientRect(),t=window.devicePixelRatio||1;s.width=n.width*t,s.height=n.height*t,r.scale(t,t),r.lineCap="round",r.lineJoin="round",r.lineWidth=2.5,r.strokeStyle="#0f172a"},[i,f]);const E=s=>{const r=x.current;if(!r)return;const n=r.getContext("2d");if(!n)return;D(!0);const t=r.getBoundingClientRect(),a="touches"in s?s.touches[0].clientX:s.clientX,l="touches"in s?s.touches[0].clientY:s.clientY,h=a-t.left,w=l-t.top;n.beginPath(),n.moveTo(h,w)},L=s=>{if(!M)return;const r=x.current;if(!r)return;const n=r.getContext("2d");if(!n)return;const t=r.getBoundingClientRect(),a="touches"in s?s.touches[0].clientX:s.clientX,l="touches"in s?s.touches[0].clientY:s.clientY,h=a-t.left,w=l-t.top;n.lineTo(h,w),n.stroke(),R(!0)},v=()=>{if(!M)return;D(!1);const s=x.current;s&&A(s.toDataURL("image/png"))},Y=()=>{const s=x.current;if(!s)return;const r=s.getContext("2d");r&&(r.clearRect(0,0,s.width,s.height),R(!1),A(""))},m=(s,r)=>{j(n=>({...n,[s]:r}))},Q=(s,r)=>{const n=o[s]??[],t=n.includes(r)?n.filter(a=>a!==r):[...n,r];j(a=>({...a,[s]:t}))},W=s=>{if(s.preventDefault(),!b.trim()){alert("Please enter your full legal name.");return}if(!y.trim()){alert("Please enter your email address.");return}const r=(i==null?void 0:i.fields)??[];for(const t of r)if(t.required){const a=o[t.key];if(a==null||a===""||Array.isArray(a)&&a.length===0){alert(`Please answer the required question: "${t.label}"`);return}}if(((i==null?void 0:i.requiresSignature)||r.some(t=>t.type==="signature"))&&!N){alert("Please sign your signature in the designated signature pad below.");return}C.mutate({data:o,signatureUrl:O||void 0,respondent:{name:b.trim(),email:y.trim(),phone:S.trim()}},{onSuccess:t=>{T(t),ne()},onError:t=>{alert(`Submission failed: ${t.message}`)}})};if(g.isLoading)return e.jsx("div",{className:"min-h-screen bg-slate-50 dark:bg-slate-950 flex flex-col items-center justify-center p-4",children:e.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground animate-pulse",children:[e.jsx($,{className:"h-6 w-6 text-primary animate-spin"}),e.jsx("span",{children:"Loading formâ¦"})]})});if(g.isError||!i)return e.jsx("div",{className:"min-h-screen bg-slate-50 dark:bg-slate-950 flex flex-col items-center justify-center p-4",children:e.jsxs("div",{className:"max-w-md w-full rounded-2xl border bg-card p-8 text-center shadow-lg space-y-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-destructive/10 text-destructive flex items-center justify-center mx-auto",children:e.jsx(ie,{className:"h-6 w-6"})}),e.jsx("h2",{className:"text-xl font-display font-bold",children:"Form Not Available"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This digital form template does not exist, has been paused, or is no longer accepting submissions."}),e.jsx(p,{variant:"outline",onClick:()=>window.location.reload(),className:"mx-auto",children:"Try Again"})]})});if(f)return e.jsx("div",{className:"min-h-screen bg-slate-50 dark:bg-slate-950 py-12 px-4 flex flex-col items-center justify-center",children:e.jsxs("div",{className:"max-w-xl w-full rounded-2xl border bg-card p-8 text-center shadow-xl border-t-8 border-t-emerald-500 space-y-6 animate-in fade-in zoom-in duration-300",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-500/10 text-emerald-600 flex items-center justify-center mx-auto",children:e.jsx(se,{className:"h-10 w-10 text-emerald-500"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-2xl font-display font-bold text-foreground",children:"Response Recorded!"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Thank you, ",e.jsx("strong",{className:"text-foreground",children:b}),". Your response for"," ",e.jsxs("strong",{children:['"',i.name,'"']})," has been successfully received by"," ",e.jsx("strong",{children:(d==null?void 0:d.name)||"GymLoop"}),"."]})]}),f.memberConnected?e.jsxs("div",{className:"rounded-xl border border-emerald-500/30 bg-emerald-500/10 p-4 text-left space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-emerald-800 dark:text-emerald-300 font-semibold text-sm",children:[e.jsx(G,{className:"h-5 w-5 text-emerald-600 shrink-0"}),e.jsx("span",{children:"Connected to Your Member Documents Space"})]}),e.jsxs("p",{className:"text-xs text-emerald-700 dark:text-emerald-400",children:["GymLoop recognized your membership profile (",e.jsx("strong",{children:f.memberName}),"). A verified copy of this signed form has been automatically placed into your personal documents space!"]})]}):e.jsx("div",{className:"rounded-xl border bg-muted/40 p-4 text-xs text-muted-foreground text-left",children:"A copy of your submission has been logged with front desk staff and will be linked if you register for an active membership."}),e.jsxs("div",{className:"pt-2 flex flex-col sm:flex-row items-center justify-center gap-3",children:[e.jsx(p,{variant:"outline",onClick:()=>{T(null),j({}),Y()},className:"w-full sm:w-auto",children:"Submit another response"}),e.jsxs(p,{variant:"primary",onClick:()=>window.print(),className:"w-full sm:w-auto gap-1.5",children:[e.jsx(le,{className:"h-4 w-4"})," Print / Save PDF"]})]}),e.jsxs("div",{className:"text-[11px] text-muted-foreground pt-4 border-t",children:["Powered by ",e.jsx("strong",{children:"GymLoop"})," Digital Forms & Documents"]})]})});const I=i.fields??[],Z=i.requiresSignature||I.some(s=>s.type==="signature");return e.jsx("div",{className:"min-h-screen bg-slate-50/80 dark:bg-slate-950 py-8 px-4 sm:px-6",children:e.jsxs("div",{className:"max-w-2xl mx-auto
1space-y-5",children:[e.jsx("div",{className:"rounded-2xl border bg-card shadow-sm overflow-hidden border-t-8 border-t-primary",children:e.jsxs("div",{className:"p-6 sm:p-8 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[d!=null&&d.logoUrl?e.jsx("img",{src:d.logoUrl,alt:d.name,className:"h-10 w-10 rounded-xl object-contain border bg-white p-1"}):e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary/10 text-primary flex items-center justify-center font-bold font-display",children:e.jsx($,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs uppercase tracking-wider font-bold text-primary",children:(d==null?void 0:d.name)||"GymLoop Partner Gym"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Digital Member Documents & Forms"})]})]}),i.requiresSignature&&e.jsxs(te,{tone:"info",className:"gap-1 shrink-0",children:[e.jsx(X,{className:"h-3 w-3"})," E-Signature"]})]}),e.jsxs("div",{className:"border-t pt-4 space-y-2",children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-display font-bold text-foreground",children:i.name}),i.description&&e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-line leading-relaxed",children:i.description})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground border-t pt-3",children:[e.jsx("span",{className:"text-destructive font-semibold",children:"* Indicates required question"}),e.jsxs("span",{className:"flex items-center gap-1 text-emerald-600 dark:text-emerald-400 font-medium",children:[e.jsx(G,{className:"h-3.5 w-3.5"})," Direct Member Sync"]})]})]})}),e.jsxs("form",{onSubmit:W,className:"space-y-4",children:[e.jsxs("div",{className:"rounded-2xl border bg-card p-6 shadow-xs space-y-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold text-sm flex items-center gap-1.5",children:[e.jsx(oe,{className:"h-4 w-4 text-primary"})," Respondent Information"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Please provide your official identification details to connect this document with your profile."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs font-semibold block mb-1",children:["Full Legal Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(u,{required:!0,value:b,onChange:s=>B(s.target.value),placeholder:"e.g. Aarav Mehta",className:"text-sm"})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs font-semibold block mb-1",children:["Email Address ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(u,{type:"email",required:!0,value:y,onChange:s=>z(s.target.value),placeholder:"e.g. [email protected]",className:"text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold block mb-1",children:"Phone Number (Optional)"}),e.jsx(u,{type:"tel",value:S,onChange:s=>_(s.target.value),placeholder:"+91 98765 43210",className:"text-sm"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold block mb-1.5",children:"Are you an existing gym member?"}),e.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[e.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"isMember",checked:q==="yes",onChange:()=>P("yes"),className:"text-primary"}),e.jsx("span",{children:"Yes, I have an active membership"})]}),e.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"isMember",checked:q==="no",onChange:()=>P("no"),className:"text-primary"}),e.jsx("span",{children:"No, I am a new guest or visitor"})]})]})]})]})]}),I.map((s,r)=>{const n=o[s.key]!=null&&o[s.key]!=="";return e.jsxs("div",{className:`rounded-2xl border bg-card p-6 shadow-xs transition-all space-y-3 ${n?"border-primary/30":""}`,children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-sm text-foreground flex items-start justify-between gap-2",children:e.jsxs("span",{children:[r+1,". ",s.label,s.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]})}),s.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s.description})]}),s.type==="text"&&e.jsx(u,{required:s.required,value:o[s.key]??"",onChange:t=>m(s.key,t.target.value),placeholder:s.placeholder||"Your answer",className:"text-sm"}),s.type==="textarea"&&e.jsx(re,{required:s.required,rows:3,value:o[s.key]??"",onChange:t=>m(s.key,t.target.value),placeholder:s.placeholder||"Type your detailed answer here...",className:"text-sm"}),s.type==="number"&&e.jsx(u,{type:"number",required:s.required,value:o[s.key]??"",onChange:t=>m(s.key,t.target.value),placeholder:s.placeholder||"0",className:"text-sm max-w-xs"}),s.type==="date"&&e.jsx(u,{type:"date",required:s.required,value:o[s.key]??"",onChange:t=>m(s.key,t.target.value),className:"text-sm max-w-xs"}),s.type==="radio"&&e.jsx("div",{className:"space-y-2 pt-1",children:(s.options??["Yes","No"]).map((t,a)=>{const l=o[s.key]===t;return e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-xl border text-xs cursor-pointer transition-all ${l?"border-primary bg-primary/5 text-foreground font-medium shadow-xs":"hover:bg-muted/40 text-muted-foreground"}`,children:[e.jsx("input",{type:"radio",name:`radio_${s.key}`,checked:l,onChange:()=>m(s.key,t),className:"text-primary"}),e.jsx("span",{className:"flex-1",children:t})]},a)})}),s.type==="checkbox"&&e.jsx("div",{className:"space-y-2 pt-1",children:(s.options??["I agree"]).map((t,a)=>{const l=(o[s.key]??[]).includes(t);return e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-xl border text-xs cursor-pointer transition-all ${l?"border-primary bg-primary/5 text-foreground font-medium shadow-xs":"hover:bg-muted/40 text-muted-foreground"}`,children:[e.jsx("input",{type:"checkbox",checked:l,onChange:()=>Q(s.key,t),className:"rounded border-input text-primary"}),e.jsx("span",{className:"flex-1",children:t})]},a)})}),s.type==="select"&&e.jsxs("select",{required:s.required,value:o[s.key]??"",onChange:t=>m(s.key,t.target.value),className:"w-full rounded-xl border bg-background px-3 py-2.5 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary",children:[e.jsx("option",{value:"",children:"Choose an option..."}),(s.options??[]).map((t,a)=>e.jsx("option",{value:t,children:t},a))]}),s.type==="scale"&&e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:s.scaleMinLabel||"Minimum"}),e.jsx("span",{children:s.scaleMaxLabel||"Maximum"})]}),e.jsx("div",{className:"flex items-center justify-between gap-1 sm:gap-2",children:Array.from({length:(s.scaleMax??5)-(s.scaleMin??1)+1}).map((t,a)=>{const l=(s.scaleMin??1)+a,h=o[s.key]===l;return e.jsx("button",{type:"button",onClick:()=>m(s.key,l),className:`flex-1 py-2.5 rounded-xl border text-xs font-semibold transition-all ${h?"bg-primary text-primary-foreground border-primary shadow-sm scale-105":"bg-background hover:bg-muted/50 text-foreground"}`,children:l},l)})})]})]},s.key||r)}),Z&&e.jsxs("div",{className:"rounded-2xl border bg-card p-6 shadow-xs space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold text-sm flex items-center gap-1.5 text-foreground",children:[e.jsx(X,{className:"h-4 w-4 text-primary"})," Digital E-Signature Pad"," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Use your finger or mouse to draw your legal signature in the box below."})]}),N&&e.jsxs(p,{type:"button",size:"sm",variant:"ghost",onClick:Y,className:"text-xs gap-1 text-muted-foreground hover:text-destructive",children:[e.jsx(ce,{className:"h-3.5 w-3.5"})," Clear signature"]})]}),e.jsxs("div",{className:"relative rounded-xl border bg-white overflow-hidden shadow-inner touch-none",children:[e.jsx("canvas",{ref:x,onMouseDown:E,onMouseMove:L,onMouseUp:v,onMouseLeave:v,onTouchStart:E,onTouchMove:L,onTouchEnd:v,className:"w-full h-36 curs
1or-crosshair block"}),!N&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none text-slate-400 text-xs italic",children:"Sign here with finger or mouse"})]}),e.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer pt-2",children:[e.jsx("input",{type:"checkbox",required:!0,checked:H,onChange:s=>J(s.target.checked),className:"mt-0.5 rounded border-input text-primary"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"I acknowledge and certify that all the information provided above is complete and accurate, and that this electronic signature has the same legal force as a physical pen signature."})]})]}),e.jsx("div",{className:"pt-2",children:e.jsxs(p,{type:"submit",size:"lg",loading:C.isPending,className:"w-full text-base font-semibold py-6 rounded-xl shadow-md gap-2",children:[e.jsx("span",{children:"Submit Form"}),e.jsx(ae,{className:"h-4 w-4"})]})})]}),e.jsx("div",{className:"text-center text-xs text-muted-foreground py-4",children:"Secured with 256-bit encryption · Synced with GymLoop Member Documents"})]})})}export{ye as PublicFormPage};
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.