1import{j as e}from"./vendor-query-DvnPdOMX.js";import{r as a,m as ie,k as ae}from"./vendor-react-woJBpfBI.js";import{v as $,R as M,a as k,ap as Y,aq as Q,ar as oe,a1 as B,as as ce}from"./index-1YQNuixL.js";import{g as de}from"./index-Db7_1mpD.js";import{m as T,A as J}from"./vendor-motion-ZmH_6coE.js";import{q as F,C as P,k as le,r as ue,bv as xe}from"./vendor-icons-BLMEbmRV.js";import{S as me}from"./SuccessCheck-Dqes8Ke1.js";import"./vendor-supabase-DaZXgOw0.js";import"./vendor-utils-BNe0Xlio.js";const he=[.16,1,.3,1];function fe({current:t,total:n}){const i=n>0?t/n*100:0;return e.jsx("div",{className:"w-[120px] sm:w-[140px] h-1 rounded-sm bg-muted overflow-hidden",children:e.jsx(T.div,{className:"h-full rounded-sm bg-accent",animate:{width:`${i}%`},transition:{duration:.35,ease:he}})})}function D({children:t,current:n,total:i,showProgress:s=!0}){return e.jsxs("div",{className:"min-h-screen bg-white flex flex-col",children:[e.jsxs("header",{className:"h-14 flex-shrink-0 border-b border-default flex items-center justify-between px-6 bg-white/95 backdrop-blur-sm sticky top-0 z-30",children:[e.jsx("img",{src:"/logo-mint.png",alt:"Trakkr",className:"rounded",style:{width:28,height:28}}),s&&i>0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-[12px] text-muted tabular-nums hidden sm:block",children:[n," of ",i]}),e.jsx(fe,{current:n,total:i})]})]}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-5 sm:px-6 py-8",children:e.jsx("div",{className:"w-full max-w-[600px]",children:t})}),e.jsxs("footer",{className:"h-10 flex-shrink-0 border-t border-default flex items-center justify-between px-6",children:[e.jsxs("div",{className:"hidden sm:flex items-center gap-1.5 text-[10px] text-muted/60",children:[e.jsx("kbd",{className:"px-1.5 py-0.5 rounded border border-default/60 text-[10px] font-mono text-muted/50",children:"â"}),e.jsx("kbd",{className:"px-1.5 py-0.5 rounded border border-default/60 text-[10px] font-mono text-muted/50",children:"â"}),e.jsx("span",{children:"navigate"}),e.jsx("span",{className:"mx-1",children:"·"}),e.jsx("kbd",{className:"px-1.5 py-0.5 rounded border border-default/60 text-[10px] font-mono text-muted/50",children:"Enter"}),e.jsx("span",{children:"continue"})]}),e.jsx("div",{})]})]})}function pe({survey:t,preselectedAudience:n,onStart:i}){const{entitlements:s}=$(),r=n?t.audiences.find(f=>f.id===n):void 0,p=s?.plan,g=(p?t.incentive?.planOverrides?.[p]:void 0)?.description??t.incentive?.description;return e.jsx("div",{className:"max-w-[480px] mx-auto text-center",children:e.jsxs(M,{children:[e.jsx(k,{delay:.1,direction:"up",distance:12,children:e.jsx("div",{className:"w-9 h-9 rounded bg-accent-subtle flex items-center justify-center mx-auto mb-5",children:e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",className:"text-accent",children:e.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}),e.jsx(k,{delay:.2,direction:"up",distance:10,children:e.jsx("h1",{className:"text-[24px] font-semibold tracking-tight text-primary",children:t.title})}),e.jsx(k,{delay:.3,direction:"up",distance:8,children:e.jsxs("p",{className:"text-[14px] text-secondary leading-relaxed mt-3",children:[t.subtitle," Takes about ",t.estimatedMinutes," minutes."]})}),r?e.jsx(k,{delay:.45,direction:"up",distance:6,children:e.jsxs("button",{onClick:()=>i(r),className:"mt-6 h-11 px-6 bg-accent-subtle text-accent rounded text-[14px] font-medium inline-flex items-center gap-2 hover:bg-accent hover:text-white active:scale-[0.98] transition-all duration-200",children:["Begin survey",e.jsx(F,{size:16,strokeWidth:1.5})]})}):e.jsx(k,{delay:.45,direction:"up",distance:6,children:e.jsx("div",{className:"mt-8 space-y-3 text-left",children:t.audiences.map(f=>e.jsx("button",{onClick:()=>i(f),className:"w-full text-left px-5 py-4 rounded border border-default bg-white hover:border-accent/40 hover:bg-accent-subtle/15 transition-colors duration-200 group cursor-pointer",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[14px] font-medium text-primary",children:f.label}),e.jsx("div",{className:"text-[13px] text-muted mt-0.5",children:f.description})]}),e.jsx(F,{size:16,strokeWidth:1.5,className:"text-muted group-hover:text-accent transition-colors"})]})},f.id))})}),e.jsx(k,{delay:.55,direction:"fade",children:e.jsx("p",{className:"text-[12px] text-muted mt-4",children:g||"Your responses help us build a better product."})})]})})}const W="ABCDEFGHIJ";function be({question:t,value:n,onAnswer:i,onNext:s}
1){const[r,p]=a.useState((typeof n?.value=="string"?n.value:"")||""),[c,g]=a.useState(n?.otherText||""),[f,j]=a.useState(-1),w=a.useRef([]),d=a.useRef(null),o=a.useMemo(()=>t.options||[],[t.options]),x=o.find(l=>l.id===r)?.hasOtherInput&&r,u=a.useCallback(l=>{if(p(l),o.find(v=>v.id===l)?.hasOtherInput){i({questionId:t.id,value:l,otherText:c});return}i({questionId:t.id,value:l}),d.current&&clearTimeout(d.current),d.current=setTimeout(s,600)},[o,t.id,c,i,s]);return a.useEffect(()=>{function l(m){(m.key==="ArrowDown"||m.key==="ArrowUp")&&(m.preventDefault(),j(b=>{const y=m.key==="ArrowDown"?Math.min(b+1,o.length-1):Math.max(b-1,0);return w.current[y]?.focus(),y})),m.key==="Enter"&&f>=0&&(m.preventDefault(),u(o[f].id));const v=W.indexOf(m.key.toUpperCase());v>=0&&v<o.length&&!m.metaKey&&!m.ctrlKey&&document.activeElement?.tagName!=="INPUT"&&document.activeElement?.tagName!=="TEXTAREA"&&(m.preventDefault(),u(o[v].id),j(v))}return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[o,f,u]),a.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]),e.jsxs("div",{children:[e.jsx(Y,{stagger:.04,delay:.15,direction:"up",children:e.jsx("div",{className:"space-y-2.5",children:o.map((l,m)=>{const v=r===l.id;return e.jsx(Q,{distance:6,children:e.jsxs("button",{ref:b=>{w.current[m]=b},onClick:()=>u(l.id),className:`w-full text-left px-4 py-3 rounded transition-colors duration-200 flex items-center gap-3 outline-none focus-visible:ring-2 focus-visible:ring-accent/20 ${v?"border border-accent bg-accent-subtle/20":"border border-default hover:border-hover hover:bg-muted/20"}`,children:[e.jsx("span",{className:`w-6 h-6 rounded flex items-center justify-center text-[11px] font-medium flex-shrink-0 transition-colors duration-200 hidden sm:flex ${v?"bg-accent-subtle text-accent":"bg-muted/50 text-muted"}`,children:W[m]}),e.jsx("span",{className:"text-[14px] font-medium text-primary flex-1",children:l.label}),v&&e.jsx(T.div,{initial:{scale:.85,opacity:0},animate:{scale:1,opacity:1},transition:{duration:.2,ease:[.16,1,.3,1]},children:e.jsx(P,{size:15,strokeWidth:1.75,className:"text-accent"})})]})},l.id)})})}),x&&e.jsxs(T.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},transition:{duration:.25},className:"mt-3",children:[e.jsx("input",{type:"text",autoFocus:!0,value:c,onChange:l=>{g(l.target.value),i({questionId:t.id,value:r,otherText:l.target.value})},onKeyDown:l=>{l.key==="Enter"&&c.trim()&&(l.preventDefault(),s())},placeholder:"Add details...",className:"w-full px-4 py-3 rounded border border-default text-[14px] text-primary placeholder:text-muted/60 focus:border-accent/60 focus:ring-1 focus:ring-accent/10 outline-none transition-colors duration-200"}),e.jsx("div",{className:"flex justify-end mt-3",children:e.jsx("button",{onClick:s,disabled:!c.trim(),className:"h-9 px-5 rounded text-[13px] font-medium bg-accent-subtle text-accent hover:bg-accent hover:text-white disabled:opacity-40 disabled:pointer-events-none transition-all duration-200",children:"Continue"})})]})]})}const G="ABCDEFGHIJ";function ye({question:t,value:n,onAnswer:i,onNext:s}){const[r,p]=a.useState(Array.isArray(n?.value)?n.value:[]),[c,g]=a.useState(n?.otherText?{other:n.otherText}:{}),[f,j]=a.useState(-1),w=a.useRef([]),d=a.useMemo(()=>t.options||[],[t.options]),o=a.useCallback(x=>{p(u=>u.includes(x)?u.filter(m=>m!==x):[...u,x])},[]);a.useEffect(()=>{if(r.length>0){const x=d.find(u=>u.hasOtherInput&&r.includes(u.id));i({questionId:t.id,value:r,otherText:x?c[x.id]:void 0})}},[r,c,t.id,d,i]),a.useEffect(()=>{function x(u){(u.key==="ArrowDown"||u.key==="ArrowUp")&&(u.preventDefault(),j(m=>{const v=u.key==="ArrowDown"?Math.min(m+1,d.length-1):Math.max(m-1,0);return w.current[v]?.focus(),v})),u.key===" "&&f>=0&&(u.preventDefault(),o(d[f].id)),u.key==="Enter"&&r.length>0&&document.activeElement?.tagName!=="INPUT"&&(u.preventDefault(),s());const l=G.indexOf(u.key.toUpperCase());l>=0&&l<d.length&&!u.metaKey&&!u.ctrlKey&&document.activeElement?.tagName!=="INPUT"&&document.activeElement?.tagName!=="TEXTAREA"&&(u.preventDefault(),o(d[l].id),j(l))}return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[d,f,r,o,s]);const N=d.some(x=>x.hasOtherInput&&r.includes(x.id));return e.jsxs("div",{children:[e.jsx(Y,{stagger:.04,delay:.15,direction:"up",children:e.jsx("div",{className:"space-y-2.5",children:d.map((x,u)=>{const l=r.includes(x.id);return e.jsxs(Q,{distance:6,children:[e.jsxs("button",{ref:m=>{w.current[u]=m},onClick:()=>o(x.id),className:`w-full text-left px-4 py-3 rounded transition-colors duration-200 flex items-center gap-3 outline-none focus-visible:ring-2 focus-visible:ring-accent/20 ${l?"border border-accent bg-accent-subtle/20":"border border-default hover:border-hover hover:bg-muted/20"}`,children:[e.jsx("span",{className:`w-[18px] h-[18px] rounded-sm flex items-center justify-center flex-shrink-0 transition-all duration-200 ${l?"bg-accent":"border border-muted/40"}`,children:l&&e.jsx(T.div,{initial:{scale:.5},animate:{scale:1},transition:{duration:.15,ease:[.16,1,.3,1]},children:e.jsx(P,{size:12,strokeWidth:2.5,className:"text-white"})})}),e.jsx("span",{className:"text-[14px] font-medium text-primary flex-1",children:x.label}),e.jsx("span",{className:"text-[11px] font-medium text-muted hidden sm:block",children:G[u]})]}),x.hasOtherInput&&l&&e.jsx(T.div,{initial:{opacity:0,height:0}
1,animate:{opacity:1,height:"auto"},transition:{duration:.25},className:"mt-2 ml-8",children:e.jsx("input",{type:"text",autoFocus:!0,value:c[x.id]||"",onChange:m=>g(v=>({...v,[x.id]:m.target.value})),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),s())},placeholder:"Add details...",className:"w-full px-3 py-2 rounded border border-default text-[13px] text-primary placeholder:text-muted/60 focus:border-accent/60 focus:ring-1 focus:ring-accent/10 outline-none transition-colors duration-200"})})]},x.id)})})}),r.length>0&&e.jsx(T.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.25,ease:[.16,1,.3,1]},className:"flex justify-end mt-5",children:e.jsx("button",{onClick:s,disabled:N&&!c[d.find(x=>x.hasOtherInput)?.id||""],className:"h-9 px-5 rounded text-[13px] font-medium bg-accent-subtle text-accent hover:bg-accent hover:text-white disabled:opacity-40 disabled:pointer-events-none transition-all duration-200",children:"Continue"})})]})}function ge({question:t,value:n,onAnswer:i,onNext:s}){const[r,p]=a.useState((typeof n?.value=="string"?n.value:"")||""),c=a.useRef(null),g=t.maxLength||500,f=r.trim().length>2;a.useEffect(()=>{const o=setTimeout(()=>c.current?.focus(),400);return()=>clearTimeout(o)},[]);function j(o){o.length<=g&&(p(o),i({questionId:t.id,value:o}))}function w(o){o.key==="Enter"&&(o.metaKey||o.ctrlKey)&&f&&(o.preventDefault(),s()),!t.multiline&&o.key==="Enter"&&!o.shiftKey&&f&&(o.preventDefault(),s())}const d=r.length>=g?"text-error":r.length>=g-50?"text-warning":"text-muted";return e.jsx(k,{delay:.15,direction:"up",distance:8,children:e.jsxs("div",{children:[t.multiline!==!1?e.jsx("textarea",{ref:c,value:r,onChange:o=>j(o.target.value),onKeyDown:w,placeholder:t.placeholder||"Type your answer here...",rows:4,className:"w-full h-[120px] px-4 py-3 rounded border border-default bg-white text-[14px] text-primary placeholder:text-muted/60 focus:border-accent/60 focus:ring-1 focus:ring-accent/10 outline-none resize-none transition-colors duration-200"}):e.jsx("input",{ref:c,type:"text",value:r,onChange:o=>j(o.target.value),onKeyDown:w,placeholder:t.placeholder||"Type your answer here...",className:"w-full px-4 py-3 rounded border border-default bg-white text-[14px] text-primary placeholder:text-muted/60 focus:border-accent/60 focus:ring-1 focus:ring-accent/10 outline-none transition-colors duration-200"}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsxs("span",{className:`text-[11px] font-mono tabular-nums ${d}`,children:[r.length,"/",g]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] text-muted hidden sm:block",children:t.multiline!==!1?"â+Enter":"Enter"}),e.jsx("button",{onClick:s,disabled:!f,className:"h-9 px-5 rounded text-[13px] font-medium bg-accent-subtle text-accent hover:bg-accent hover:text-white disabled:opacity-40 disabled:pointer-events-none transition-all duration-200",children:"Continue"})]})]})]})})}const X=[{code:"USD",symbol:"$"},{code:"EUR",symbol:"â¬"},{code:"GBP",symbol:"£"},{code:"AUD",symbol:"A$"},{code:"CAD",symbol:"C$"}],ve={US:"USD",GB:"GBP",AU:"AUD",CA:"CAD",DE:"EUR",FR:"EUR",IT:"EUR",ES:"EUR",NL:"EUR",BE:"EUR",AT:"EUR",IE:"EUR",PT:"EUR",FI:"EUR",GR:"EUR",LU:"EUR",SK:"EUR",SI:"EUR",EE:"EUR",LV:"EUR",LT:"EUR",CY:"EUR",MT:"EUR",HR:"EUR"};function je(){try{const n=(navigator.language||"en-US").split("-"),i=n[n.length-1]?.toUpperCase()||"";return ve[i]||"USD"}catch{return"USD"}}function we(t){return X.find(n=>n.code===t)?.symbol||"$"}function Ne({question:t,value:n,onAnswer:i,onNext:s}){const r=n?.value,[p,c]=a.useState(r?.low||""),[g,f]=a.useState(r?.high||""),[j,w]=a.useState(()=>r?.currency||je()),[d,o]=a.useState(!1),N=a.useRef(null),x=a.useRef(null),u=a.useRef(null),l=t.priceLabels||["At what price would this feel like a no-brainer?","At what price would you start to wonder if it's worth it?"],m=we(j),v=p.trim()!==""&&g.trim()!=="";a.useEffect(()=>{const y=setTimeout(()=>N.current?.focus(),400);return()=>clearTimeout(y)},[]),a.useEffect(()=>{(p||g)&&i({questionId:t.id,value:{low:p,high:g,currency:j}})},[p,g,j,t.id,i]),a.useEffect(()=>{if(!d)return;function y(U){u.current&&!u.current.contains(U.target)&&o(!1)}function R(U){U.key==="Escape"&&o(!1)}return document.addEventListener("mousedown",y),document.addEventListener("keydown",R),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",R)}},[d]);function b(y,R){y.key==="Enter"&&(y.preventDefault(),R==="low"?x.current?.focus():v&&s())}return e.jsxs(M,{children:[e.jsx(k,{delay:.05,direction:"fade",children:e.jsxs("div",{className:"flex items-center gap-1.5 mb-3 ml-0.5",children:[e.jsx("span",{className:"text-[13px] text-muted",children:"Prices in"}),e.jsxs("div",{className:"relative",ref:u,children:[e.jsxs("button",{type:"button",onClick:()=>o(!d),className:"flex items-center gap-1 text-[13px] font-medium text-secondary hover:text-primary transition-colors duration-200",children:[m," ",j,e.jsx(le,{size:11,strokeWidth:1.5,className:`opacity-50 transition-transform duration-200 ${d?"rotate-180":""}`})]}),d&&e.jsx("div",{className:"absolute top-full left-0 mt-1 bg-white border border-default rounded shadow-sm py-1 z-10 min-w-[120px]",children:X.map(y=>e.jsxs("button",{type:"button",onClick:()=>{w(y.code),o(!1)},className:"w-full flex items-center gap-2 px-3 py-1.5 text-[13px] hover:bg-muted/50 transition-colors duration-150",children:[e.jsx("span",{className:"w-5 text-right font-medium text-primary",children:y.symbol}),e.jsx("span",{className:"text-secondary",children:y.code}),y.code===j&&e.jsx(P,{size:12,strokeWidth:1.5,className:"ml-auto text-accent"})]},y.code))})]})]})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(k,{delay:.15,direction:"up",distance:8,children:e.jsxs("div",{className:"border border-default rounded bg-white p-5 focu
1s-within:border-accent/60 focus-within:ring-1 focus-within:ring-accent/10 transition-colors duration-200",children:[e.jsx("p",{className:"text-[14px] text-secondary leading-relaxed mb-4",children:l[0]}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-[28px] font-semibold text-muted select-none",children:m}),e.jsx("input",{ref:N,type:"number",min:"0",value:p,onChange:y=>c(y.target.value),onKeyDown:y=>b(y,"low"),placeholder:"0",className:"text-[28px] font-semibold tracking-tight tabular-nums text-primary bg-transparent border-none outline-none w-[120px] placeholder:text-muted/40 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"}),e.jsx("span",{className:"text-[14px] text-muted select-none",children:"/mo"})]})]})}),e.jsx(k,{delay:.25,direction:"up",distance:8,children:e.jsxs("div",{className:"border border-default rounded bg-white p-5 focus-within:border-accent/60 focus-within:ring-1 focus-within:ring-accent/10 transition-colors duration-200",children:[e.jsx("p",{className:"text-[14px] text-secondary leading-relaxed mb-4",children:l[1]}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-[28px] font-semibold text-muted select-none",children:m}),e.jsx("input",{ref:x,type:"number",min:"0",value:g,onChange:y=>f(y.target.value),onKeyDown:y=>b(y,"high"),placeholder:"0",className:"text-[28px] font-semibold tracking-tight tabular-nums text-primary bg-transparent border-none outline-none w-[120px] placeholder:text-muted/40 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"}),e.jsx("span",{className:"text-[14px] text-muted select-none",children:"/mo"})]})]})})]}),e.jsx(k,{delay:.35,direction:"fade",children:e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx("button",{onClick:s,disabled:!v,className:"h-9 px-5 rounded text-[13px] font-medium bg-accent-subtle text-accent hover:bg-accent hover:text-white disabled:opacity-40 disabled:pointer-events-none transition-all duration-200",children:"Continue"})})})]})}const H=[.16,1,.3,1];function ke({question:t,value:n,onAnswer:i,onNext:s}){const r=t.maxdiffSets||[],p=Array.isArray(n?.value)?n.value:[],[c,g]=a.useState(Math.min(p.length,r.length-1)),[f,j]=a.useState(p),[w,d]=a.useState(""),[o,N]=a.useState(""),x=r[c],u=w!==""&&o!=="",l=a.useCallback(()=>{if(!u)return;const b=[...f];if(b[c]={most:w,least:o},j(b),c<r.length-1){const y=c+1,R=b[y];d(R?.most||""),N(R?.least||""),g(y)}else i({questionId:t.id,value:b}),s()},[u,f,c,w,o,r.length,t.id,i,s]);function m(b){b===o&&N(""),d(b===w?"":b)}function v(b){b===w&&d(""),N(b===o?"":b)}return x?e.jsxs("div",{children:[e.jsxs("div",{className:"text-[12px] text-muted tabular-nums mb-5",children:["Set ",c+1," of ",r.length]}),e.jsx(J,{mode:"wait",children:e.jsxs(T.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-12},transition:{duration:.35,ease:H},children:[e.jsxs("div",{className:"hidden sm:block",children:[e.jsxs("div",{className:"grid grid-cols-[48px_1fr_48px] gap-x-2 mb-3",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted font-semibold text-center",children:"Least"}),e.jsx("span",{}),e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted font-semibold text-center",children:"Most"})]}),e.jsx("div",{className:"grid grid-cols-[48px_1fr_48px] gap-x-2 gap-y-2.5",children:x.items.map(b=>e.jsx(Ee,{item:b,most:w,least:o,onMost:m,onLeast:v},b.id))})]}),e.jsx("div",{className:"sm:hidden space-y-2.5",children:x.items.map(b=>e.jsx(Se,{item:b,most:w,least:o,onMost:m,onLeast:v},b.id))})]},x.id)}),u&&e.jsx(T.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.25,ease:H},className:"flex justify-end mt-5",children:e.jsx("button",{onClick:l,className:"h-9 px-5 rounded text-[13px] font-medium bg-accent-subtle text-accent hover:bg-accent hover:text-white transition-all duration-200",children:c<r.length-1?"Next set":"Continue"})})]}):null}function Ee({item:t,most:n,least:i,onMost:s,onLeast:r}){const p=i===t.id,c=n===t.id;return e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>r(t.id),className:`w-10 h-10 rounded border flex items-center justify-center transition-colors duration-200 cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-accent/20 ${p?"border-error/60 bg-error-subtle/50":"border-default hover:border-hover hover:bg-muted/30"}`,children:e.jsx("span",{className:`w-4 h-4 rounded-full transition-all duration-150 ${p?"bg-error":"border border-muted/40"}`,children:p&&e.jsx(T.span,{className:"block w-full h-full rounded-full bg-error",initial:{scale:.5},animate:{scale:1},transition:{duration:.15,ease:[.16,1,.3,1]}})})}),e.jsx("div",{className:`px-4 py-2.5 rounded border text-[14px] font-medium text-primary transition-colors duration-200 ${c?"border-accent/20":p?"border-error/20":"border-default"}`,children:t.label}),e.jsx("button",{onClick:()=>s(t.id),className:`w-10 h-10 rounded border flex items-center justify-center transition-colors duration-200 cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-accent/20 ${c?"border-accent/60 bg-accent-subtle/50":"border-default hover:border-hover hover:bg-muted/30"}`,children:e.jsx("span",{className:`w-4 h-4 rounded-full transition-all duration-150 ${c?"bg-accent":"border border-muted/40"}`,children:c&&e.jsx(T.span,{className:"block w-full h-full rounded-full bg-accent",initial:{scale:.5},animate:{scale:1},transition:{duration:.15,ease:[.16,1,.3,1]}})})})]})}function Se({item:t,most:n,least:i,onMost:s,onLeast:r}){const p=i===t.id,c=n===t.id;return e.jsxs("div",{className:"border border-default rounded p-4",children:[e.jsx("div",{className:"text-[14px] font-medium text-primary mb-3",children:t.label}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>s(t.id),className:`h-8 px-3 rounded text-[12px] font-medium border transition-colors duration-200 ${c?"bg-accent-subtle/50 text-accent border-accent/50":"border-default text-secondary hover:bg-muted/30"}`,children:"Most valuable"}),e.jsx("button",{onClick:()=>r(t.id),className:`h-8 px-3 rounded text-[12px] font-medium border transition-colors duration-200 ${p?"bg-error-subtle/50 text-error border-error/50":"border-default text-secondary hover:bg-muted/30"}`,children:"Least valuable"})]})]})}const Ce=[.16,1,.3,1];function Re({question:t,answer:n,onAnswer:i,onNext:s,onBack:r,direction:p}){const c=p==="forward";return e.jsx(J,{mode:"wait",children:e.jsxs(T.div,{initial:{opacity:0,y:c?20:-20}
1,animate:{opacity:1,y:0},exit:{opacity:0,y:c?-12:12},transition:{duration:.35,ease:Ce},children:[e.jsx("h2",{className:"text-[20px] font-semibold tracking-tight text-primary leading-snug",children:t.text}),t.subtitle&&e.jsx("p",{className:"text-[13px] text-muted mt-2",children:t.subtitle}),e.jsxs("div",{className:"mt-8",children:[t.type==="single_choice"&&e.jsx(be,{question:t,value:n,onAnswer:i,onNext:s}),t.type==="multi_choice"&&e.jsx(ye,{question:t,value:n,onAnswer:i,onNext:s}),t.type==="free_text"&&e.jsx(ge,{question:t,value:n,onAnswer:i,onNext:s}),t.type==="price_input"&&e.jsx(Ne,{question:t,value:n,onAnswer:i,onNext:s}),t.type==="maxdiff"&&e.jsx(ke,{question:t,value:n,onAnswer:i,onNext:s})]}),r&&e.jsxs("button",{onClick:r,className:"mt-6 flex items-center gap-1 text-[13px] text-muted hover:text-secondary transition-colors",children:[e.jsx(ue,{size:14,strokeWidth:1.5}),"Back"]})]},t.id)})}function Te({index:t,title:n,subtitle:i,onContinue:s}){const r=a.useRef(null);return a.useEffect(()=>(r.current=setTimeout(s,2500),()=>{r.current&&clearTimeout(r.current)}),[s]),a.useEffect(()=>{function p(c){c.key==="Enter"&&(c.preventDefault(),r.current&&clearTimeout(r.current),s())}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[s]),e.jsx("div",{className:"text-center",children:e.jsxs(M,{children:[e.jsx(k,{delay:.1,direction:"fade",children:e.jsxs("span",{className:"text-[11px] font-semibold tracking-[0.08em] text-accent tabular-nums",children:["[",String(t+1).padStart(2,"0"),"]"]})}),e.jsx(k,{delay:.2,direction:"up",distance:8,children:e.jsx("h2",{className:"text-[20px] font-semibold tracking-tight text-primary mt-2",children:n})}),i&&e.jsx(k,{delay:.35,direction:"up",distance:6,children:e.jsx("p",{className:"text-[14px] text-secondary mt-1",children:i})})]})})}function Ie({incentive:t}){const{user:n}=$(),i=n?.plan,s=t?i&&t.planOverrides?.[i]?t.planOverrides[i]:{headline:t.headline,description:t.description}:null;return e.jsx("div",{className:"max-w-[480px] mx-auto text-center",children:e.jsxs(M,{children:[e.jsx(k,{delay:.3,direction:"scale",scale:.9,children:e.jsx("div",{className:"flex justify-center mb-5",children:e.jsx(me,{show:!0,size:"lg"})})}),e.jsx(k,{delay:.5,direction:"up",distance:10,children:e.jsx("h1",{className:"text-[24px] font-semibold tracking-tight text-primary",children:"Thank you"})}),e.jsx(k,{delay:.65,direction:"up",distance:8,children:e.jsx("p",{className:"text-[14px] text-secondary mt-2 leading-relaxed",children:"Your input directly shapes what we build next."})}),s&&e.jsx(k,{delay:.85,direction:"up",distance:6,children:e.jsxs("div",{className:"border border-default rounded bg-white p-5 mt-6 text-left",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-accent-subtle flex items-center justify-center shrink-0 mt-0.5",children:e.jsx(xe,{size:15,strokeWidth:1.5,className:"text-accent"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-[15px] font-semibold text-primary",children:s.headline}),e.jsx("p",{className:"text-[13px] text-secondary mt-1 leading-relaxed",children:s.description})]})]}),e.jsx("div",{className:"mt-4 px-4 py-2 rounded bg-accent-subtle/25 text-[13px] text-accent font-medium text-center",children:"You're in the draw"})]})}),e.jsx(k,{delay:1,direction:"fade",children:e.jsx("a",{href:"/",className:"text-[12px] text-muted hover:text-secondary inline-block mt-4 transition-colors",children:"Return to Trakkr"})})]})})}function V(t){const n=[];return t.sections.forEach((i,s)=>{s>0&&n.push({type:"section",section:i,sectionIndex:s}),i.questions.forEach(r=>{n.push({type:"question",question:r})})}),n}function Z(t,n){if(!t.showIf)return!0;const i=n[t.showIf.questionId];if(!i)return!1;const s=i.value;return typeof s=="string"?t.showIf.values.includes(s):Array.isArray(s)&&typeof s[0]=="string"?s.some(r=>t.showIf.values.includes(r)):!1}function O(t,n){return t.type==="section"?!0:!t.question||Z(t.question,n)}function Ue(t,n){return t.sections.reduce((i,s)=>i+s.questions.filter(r=>Z(r,n)).length,0)}function ze(){const{slug:t=""}=ie(),[n]=ae(),{user:i}=$(),s=de(t),r=n.get("t")||void 0,c=n.get("audience")||void 0||(i?.id?"paying":void 0),[g,f]=a.useState("welcome"),[j,w]=a.useState(null),[d,o]=a.use
1State(0),[N,x]=a.useState({}),[u,l]=a.useState(),[m,v]=a.useState("forward"),[b,y]=a.useState(!1),R=a.useRef(!1),U=a.useRef(N);U.current=N;const S=a.useMemo(()=>j?V(j):[],[j]),L=j?Ue(j,N):0,z=a.useMemo(()=>{let h=0;for(let E=0;E<=d&&E<S.length;E++){const C=S[E];C.type==="question"&&O(C,N)&&h++}return h},[S,d,N]),I=S[d];a.useEffect(()=>{if(b||!t)return;async function h(){try{const E=B(),C=await ce(t,{token:r,anonymousId:E});if(C&&C.answers&&Object.keys(C.answers).length>0&&(l(C.id),x(C.answers),C.audience_segment&&s)){const _=s.audiences.find(K=>K.id===C.audience_segment);if(_){w(_);const K=V(_),re=Math.min(C.question_index,K.length-1);o(Math.max(0,re)),C.is_partial?f("questions"):f("completion")}}}catch{}finally{y(!0)}}h()},[t,r,b,s]);const A=a.useCallback(async(h=!1)=>{if(!(R.current||!j)){R.current=!0;try{const E=await oe(t,{respondent_token:r,anonymous_id:i?void 0:B(),audience_segment:j.id,answers:U.current,metadata:{userAgent:navigator.userAgent,referrer:document.referrer,utm_source:n.get("utm_source")||void 0,utm_medium:n.get("utm_medium")||void 0,utm_campaign:n.get("utm_campaign")||void 0},question_index:d,is_complete:h,response_id:u});l(E.id)}catch(E){console.error("[Survey] Save failed:",E)}finally{R.current=!1}}},[t,r,i,j,d,u,n]);a.useEffect(()=>{function h(){document.visibilityState==="hidden"&&g==="questions"&&A()}function E(){g==="questions"&&A()}return document.addEventListener("visibilitychange",h),window.addEventListener("beforeunload",E),()=>{document.removeEventListener("visibilitychange",h),window.removeEventListener("beforeunload",E)}},[A,g]);function q(h){w(h),f("questions"),o(0),v("forward")}const ee=a.useCallback(h=>{x(E=>({...E,[h.questionId]:h}))},[]);function te(){let h=d+1;for(;h<S.length&&!O(S[h],N);)h++;if(h>=S.length){A(!0),f("completion");return}A(),v("forward"),o(h),S[h].type==="section"?f("section-transition"):f("questions")}function ne(){if(d>0){v("backward");let h=d-1;for(;h>0&&!O(S[h],N);)h--;for(;h>0&&S[h].type==="section";)h--;o(h),f("questions")}}function se(){v("forward");let h=d+1;for(;h<S.length&&!O(S[h],N);)h++;o(h),f("questions")}return s?b?g==="welcome"?e.jsx(D,{current:0,total:0,showProgress:!1,children:e.jsx(pe,{survey:s,preselectedAudience:c,onStart:q})}):g==="completion"?e.jsx(D,{current:L,total:L,children:e.jsx(Ie,{incentive:s.incentive})}):g==="section-transition"&&I?.section?e.jsx(D,{current:z,total:L,children:e.jsx(Te,{index:I.sectionIndex||0,title:I.section.title,subtitle:I.section.subtitle,onContinue:se})}):g==="questions"&&I?.question?e.jsx(D,{current:z,total:L,children:e.jsx(Re,{question:I.question,answer:N[I.question.id],onAnswer:ee,onNext:te,onBack:d>0?ne:void 0,direction:m})}):null:e.jsx(D,{current:0,total:0,showProgress:!1,children:e.jsx("div",{className:"flex items-center justify-center",children:e.jsx("div",{className:"w-5 h-5 border-2 border-accent border-t-transparent rounded-full animate-spin"})})}):e.jsx(D,{current:0,total:0,showProgress:!1,children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-[20px] font-semibold text-primary",children:"Survey not found"}),e.jsx("p",{className:"text-[14px] text-secondary mt-2",children:"This survey may have ended or the link may be incorrect."}),e.jsx("a",{href:"/",className:"text-[13px] text-accent mt-4 inline-block hover:underline",children:"Return to Trakkr"})]})})}export{ze 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.