PageSourceSearch

https://ttypes.ai/assets/SurveyNative-BY7FFXTz.js

js ttypes.ai collected 2026-10-05 13:49:00 UTC 40,010 bytes, 17 lines download raw bytes

1import{j as r,r as C,be as Ae,bf as he,ai as je,u as Re,c as Me,bg as ye,a0 as ue,g as be,b1 as xe,bh as ve,bi as Ne,bj as Oe,ba as $e}from"./index-BR27rmZV.js";import{A as we}from"./arrow-left-SHzaYs_f.js";function Se(e,i){const t=i[e.questionId],o=e.value;switch(e.op){case"equals":return t===o;case"notEquals":return t!==o;case"includes":return Array.isArray(t)&&t.includes(o);case"in":return Array.isArray(o)&&o.includes(t);case"notIn":return Array.isArray(o)&&!o.includes(t);case"gt":return Number(t)>Number(o);case"lt":return Number(t)<Number(o);case"gte":return Number(t)>=Number(o);case"lte":return Number(t)<=Number(o);default:return!0}}function ae(e,i){if(!e)return!0;const t=e.all?e.all.every(c=>Se(c,i)):!0,o=e.any?e.any.some(c=>Se(c,i)):!0,n=e.not?!ae(e.not,i):!0;return e.all&&e.any?t&&o&&n:e.all?t&&n:e.any?o&&n:n}function ke({question:e,value:i,onChange:t}){if(e.options){const n=e;if(n.type==="radio")return r.jsxs("fieldset",{className:"space-y-2",children:[r.jsx("legend",{className:"text-base font-medium",children:n.title}),n.description&&r.jsx("p",{className:"text-sm text-muted-foreground",children:n.description}),r.jsx("div",{className:"space-y-1",children:n.options.map(c=>r.jsxs("label",{className:"flex items-center gap-2 p-3 rounded-md border border-gray-200 bg-white hover:bg-gray-50 shadow-sm transition-colors cursor-pointer",children:[r.jsx("input",{className:"h-4 w-4 accent-indigo-600",type:"radio",name:n.id,value:c.value,checked:i===c.value,onChange:()=>t(c.value),autoComplete:"off"}),r.jsx("span",{className:"text-sm",children:c.label})]},c.value))})]});if(n.type==="checkbox"){const c=Array.isArray(i)?i:[];return r.jsxs("fieldset",{className:"space-y-2",children:[r.jsx("legend",{className:"text-base font-medium",children:n.title}),n.description&&r.jsx("p",{className:"text-sm text-muted-foreground",children:n.description}),r.jsx("div",{className:"space-y-1",children:n.options.map(u=>{const N=c.includes(u.value);return r.jsxs("label",{className:"flex items-center gap-2 p-3 rounded-md border border-gray-200 bg-white hover:bg-gray-50 shadow-sm transition-colors cursor-pointer",children:[r.jsx("input",{className:"h-4 w-4 accent-indigo-600",type:"checkbox",name:`${n.id}-${u.value}`,checked:N,onChange:D=>{D.target.checked?t([...c,u.value]):t(c.filter(v=>v!==u.value))},autoComplete:"off"}),r.jsx("span",{className:"text-sm",children:u.label})]},u.value)})})]})}if(n.type==="select")return r.jsxs("label",{className:"block space-y-1",children:[r.jsx("div",{className:"text-base font-medium",children:n.title}),n.description&&r.jsx("p",{className:"text-sm text-muted-foreground",children:n.description}),r.jsxs("select",{className:"w-full border border-gray-300 rounded-md px-3 py-2 bg-white shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500",value:i??"",onChange:c=>t(c.target.value),autoComplete:"off",children:[r.jsx("option",{value:"",disabled:!0,children:"Select..."}),n.options.map(c=>r.jsx("option",{value:c.value,children:c.label},c.value))]})]})}const o=e;return o.type==="textarea"?r.jsxs("label",{className:"block space-y-1",children:[r.jsx("div",{className:"text-base font-medium",children:o.title}),o.description&&r.jsx("p",{className:"text-sm text-muted-foreground",children:o.description}),r.jsx("textarea",{className:"w-full border border-gray-300 rounded-md px-3 py-2 bg-white shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500",value:i??"",onChange:n=>t(n.target.value),rows:4,autoComplete:"off"})]}):o.type==="number"?r.jsxs("label",{className:"block space-y-1",children:[r.jsx("div",{className:"text-base font-medium",children:o.title}),o.description&&r.jsx("p",{className:"text-sm text-muted-foreground",children:o.description}),r.jsx("input",{className:"w-full border border-gray-300 rounded-md px-3 py-2 bg-white shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500",type:"number",value:i??"",onChange:n=>t(n.target.value===""?"":Number(n.target.value)),autoComplete:"off"})]}):r.jsxs("label",{className:"block space-y-1",children:[r.jsx("div",{className:"text-base font-medium",children:o.title}),o.description&&r.jsx("p",{className:"text-sm text-muted-foreground",children:o.description}),r.jsx("input",{className:"w-full border border-gray-300 rounded-md px-3 py-2 bg-white shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500",type:"text",value:i??"",onChange:n=>t(n.target.value),autoComplete:"off"})]})}function Ie({definition:e,initialAnswers:i,onSubmit:t,onChange:o,submitLabel:n="Submit",nextLabel:c="Next",backLabel:u="Back",mode:N="page",showTitle:D=!0,progressOffset:v=0,progressTotalOverride:S}){const[j,l]=C.useState(i??{}),[x,p]=C.useState(0),[y,R]=C.useState(0),[d,g]=C.useState({}),[f,M]=C.useState(!1),a=C.useRef(null);C.useEffect(()=>()=>{a.current&&clearTimeout(a.current)},[]);const T=C.useMemo(()=>e.pages.filter(s=>ae(s.visibleIf,j)),[e.pages,j]),b=T[x],V=C.useMemo(()=>{const s=[];for(const h of T)h.questions.forEach((I,m)=>{ae(I.visibleIf,j)&&s.push({page:h,idx:m,id:I.id})});return s},[T,j]);function P(s,h){const I={...j,[s]:h};l(I),o==null||o(I)}function X(s){const h={};for(const I of s.questions){if(!ae(I.visibleIf,j)||!I.required)continue;const A=j[I.id];(A==null||A===""||Array.isArray(A)&&A.length===0)&&(h[I.id]="This field is required")}return g(h),Object.keys(h).length===0}function W(s){const h={};let I=!1,m=!0;for(const se of e.pages)for(const K of se.questions)if(K.id===s){I=!!K.required,m=ae(K.visibleIf,j);break}if(!m||!I)return g({}),!0;const A=j[s];return(A==null||A===""||Array.isArray(A)&&A.length===0)&&(h[s]="This field is required"),g(h),Object.keys(h).length===0}function ee(){if(N==="question"){const s=V[y];if(!s||!W(s.id))return;const h=y+1;h<V.length&&R(h)}else{if(!b||!X(b))return;const s=x+1;s<T.length&&p(s)}}function w(){if(N==="question"){const s=y-1;s>=0&&R(s)}else{const s=x-1;s>=0&&p(s)}}async function Q(){if(!f){if(N==="question"){const s=V[y];if(!s||!W(s.id))return}else if(!b||!X(b))return;M(!0);try{const s=await(t==null?void 0:t(j));if(s&&typeof s=="object"&&"success"in s&&!s.success){const h=s.message||"Submission failed";console.error("Submission error:",h),alert(h),M(!1);return}}catch(s){console.error("Submission error:",s);const h=s instanceof Error?s.message:"Submission failed";alert(h),M(!1);return}}}const z=N==="question"?V[y]:void 0,O=N==="question"?y>=V.length-1:x>=T.length-1,Y=S??(N==="question"?V.length:T.length),B=v+(N==="question"?y:x);C.useEffect(()=>{N==="question"?y>=V.length&&R(Math.max(0,V.length-1)):x>=T.length&&p(Math.max(0,T.length-1))},[V.length,T.length,N]);function k(s){var I,m;const h=(m=(I=s.target)==null?void 0:I.tagName)==null?void 0:m.toLowerCase();h==="input"||h==="textarea"||h==="select"||(s.key==="ArrowRight"||s.key==="Enter"?(s.preventDefault(),O||ee()):s.key==="ArrowLeft"&&(s.preventDefault(),w()))}return N==="page"&&!b?r.jsx("div",{className:"text-sm text-muted-foreground",children:"No content available."}):r.jsxs("div",{className:"space-y-6",onKeyDown:k,tabIndex:0,children:[r.jsxs("div",{className:"space-y-3",children:[D&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("h2",{className:"text-2xl font-semibold",children:e.title}),r.jsx("div",{className:"text-xs text-muted-foreground",children:N==="question"?`Question ${B+1} of ${Y}`:`Page ${B+1} of ${Y}`})]}),N==="page"&&(b==null?void 0:b.title)&&r.jsx("h3",{className:"text-xl font-medium",children:b.title}),N==="page"&&(b==null?void 0:b.description)&&r.jsx("p",{className:"text-gray-700",children:b.description})]}),r.jsx("div",{className:"w-full h-2 bg-gray-200/70 rounded-full overflow-hidden",children:r.jsx("div",{className:"h-2 bg-gradient-to-r from-indigo-500 via-purple-500 to-pink-500 rounded-full transition-all",style:{width:`${Math.round((B+1)/Math.max(Y,1)*100)}%`}})})]}),N==="page"?r.jsx("div",{className:"space-y-6",children:b==null?void 0:b.questions.filter(s=>ae(s.visibleIf,j)).map(s=>r.jsxs("div",{className:"space-y-2 p-6 border border-gray-100 rounded-xl bg-white shadow-md",children:[r.jsx(ke,{question:s,value:j[s.id],onChange:h=>P(s.id,h)}),d[s.id]&&r.jsx("div",{className:"text-red-600 text-sm mt-1",children:d[s.id]})]},s.id))}):r.jsx("div",{className:"space-y-6",children:r.jsx(Ae,{mode:"wait",children:z?r.jsxs(he.div,{initial:{opacity:0,y:8}
1,animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.2,ease:"easeOut"},className:"space-y-2 p-6 border border-gray-100 rounded-2xl bg-white shadow-lg",children:[r.jsx(ke,{question:z.page.questions[z.idx],value:j[z.id],onChange:s=>P(z.id,s)}),d[z.id]&&r.jsx("div",{className:"text-red-600 text-sm mt-1",children:d[z.id]})]},z.id):r.jsx(he.div,{initial:{opacity:0},animate:{opacity:1},className:"text-sm text-muted-foreground",children:"No question available."},"no-q")})}),r.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[r.jsx("button",{onClick:w,disabled:N==="question"?y===0:x===0,className:"px-4 py-2 rounded-md border border-gray-200 bg-white hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:u}),O?r.jsxs("button",{onClick:Q,disabled:f,className:"px-4 py-2 rounded-md bg-emerald-600 text-white hover:bg-emerald-700 focus:outline-none focus:ring-2 focus:ring-emerald-400 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:[f&&r.jsxs("svg",{className:"animate-spin h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[r.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),f?"Submitting...":n]}):r.jsx("button",{onClick:ee,className:"px-4 py-2 rounded-md bg-indigo-600 text-white hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-400",children:c})]}),r.jsx("div",{className:"text-xs text-muted-foreground"})]})}function de(e){return typeof e=="string"?{text:e}:e}const Z=e=>typeof e=="string"?e.trim():String(e??"");function ge(e,i){const t=Z(i),o=e.find(c=>Z(c.text)===t);if(o)return o;const n=Number(t);if(!Number.isNaN(n)&&Number.isFinite(n)){const c=e[n-1];if(c)return c}}function Ee(e,i=[],t=""){let o=[];return e.forEach(n=>{var D;const c=n.id.trim(),u=[...i,c],N=t?`${t} > ${n.name}`:n.name;o.push({id:c,name:n.name,fullName:N,path:u,score:0,answeredQuestions:0,totalQuestions:0}),(D=n.children)!=null&&D.length&&(o=o.concat(Ee(n.children,u,N)))}),o}function ie(e,i){const t=i.trim();if(e[t])return e[t];const o=Object.values(e).find(n=>n.name.toLowerCase()===t.toLowerCase());return o?(console.warn(`[surveyScoring] Category ID mismatch detected and resolved:
2       - Searched for ID: "${i}"
3       - Matched by name: "${o.name}"
4       - Using ID: "${o.id}"
5       This is expected if category IDs changed in database.`),o):(console.error(`[surveyScoring] Category not found: "${i}"
6     Available categories: ${Object.values(e).map(n=>`${n.name} (${n.id})`).join(", ")}`),null)}function ce(e,i){var c,u,N,D,v,S,j;if(!((c=e==null?void 0:e.categories)!=null&&c.length))return[];const t=Ee(e.categories),o={};t.forEach(l=>{o[l.id]={...l}});for(const l of e.questions){const x=i[l.id];if(x==null||x==="")continue;const p=new Set;if(l.type==="radio"||l.type==="likert"||l.type==="categorized"){const R=(l.options||[]).map(de),d=ge(R,x);if((u=d==null?void 0:d.categoryMappings)!=null&&u.length&&d.categoryMappings.forEach(g=>{const f=ie(o,g);if(f){const M=l.type==="categorized"?1:d.weight||1;f.score+=M,p.add(f.id)}}),p.size===0&&((N=l.categoryPath)!=null&&N.length)){const g=(d==null?void 0:d.weight)||1;l.categoryPath.forEach(f=>{const M=ie(o,f);M&&(M.score+=g,p.add(M.id))})}}else if(l.type==="checkbox"){const R=(l.options||[]).map(de),d=Array.isArray(x)?x:[];for(const g of d){const f=ge(R,g);(D=f==null?void 0:f.categoryMappings)!=null&&D.length&&f.categoryMappings.forEach(M=>{const a=ie(o,M);a&&(a.score+=f.weight||1,p.add(a.id))})}if(p.size===0&&((v=l.categoryPath)!=null&&v.length)){const g=d.reduce((f,M)=>{const a=ge(R,M);return f+((a==null?void 0:a.weight)||1)},0);l.categoryPath.forEach(f=>{const M=ie(o,f);M&&(M.score+=g,p.add(M.id))})}}else l.type==="text"&&(S=l.categoryPath)!=null&&S.length&&String(x).trim().length>0&&l.categoryPath.forEach(R=>{const d=ie(o,R);d&&(d.score+=1,p.add(d.id))});for(const R of p){const d=ie(o,R);d&&d.answeredQuestions++}const y=new Set;(j=l.categoryPath)!=null&&j.length&&l.categoryPath.forEach(R=>y.add(R.trim())),(l.options||[]).forEach(R=>{var g;(g=de(R).categoryMappings)==null||g.forEach(f=>y.add(f.trim()))});for(const R of y){const d=ie(o,R);d&&d.totalQuestions++}}return Object.values(o).map(l=>{const x=l.totalQuestions>0?Math.round(l.answeredQuestions/l.totalQuestions*100):0,p=l.answeredQuestions>0?parseFloat((l.score/l.answeredQuestions).toFixed(2)):0;return{...l,completionRate:x,averageScore:p}}).filter(l=>l.totalQuestions>0).sort((l,x)=>x.score-l.score)}function Ce(e,i){if(!e||!(i!=null&&i.length))return null;const t=i.filter(o=>o.path[0]===e.id);return t.length>0?t[0]:null}function De({normalAnswers:e,tiebreakerData:i,allAnswers:t,survey:o,categoryScores:n}){console.group("🔗 TIEBREAKER RESOLUTION DEBUG"),console.log("Normal Answers:",e),console.log("Tiebreaker Data:",i),console.log("Combined Answers:",t),o.questions.filter(u=>u.isTiebreaker).forEach(u=>{var D,v;const N=i[u.id];if(N!=null&&N!==""){const S=Z(N),l=(u.options||[]).map(x=>typeof x=="string"?{text:x}:x).find(x=>Z(x.text)===S);console.log(`Tiebreaker Q: "${(D=u.label)==null?void 0:D.substring(0,50)}..."`),console.log(`  User Answer: "${N}" (trimmed: "${S}")`),console.log("  Matched Option:",l?{text:(v=l.text)==null?void 0:v.substring(0,40),categoryMappings:l.categoryMappings}:"NO MATCH - option not found!")}}),console.log("Category Scores After Resolution:",n.map(u=>({name:u.name,id:u.id,score:u.score}))),console.groupEnd()}function le(e,i){var S,j;const t=ce(e,i),o=t.filter(l=>l.path.length===1),n=t.filter(l=>l.path.length>1),c=(()=>{var p;if(o.length<2)return[];const l=((p=o[0])==null?void 0:p.score)??0;if(l<=0)return[];const x=o.filter(y=>y.score===l);return x.length>1?x:[]})();let u=o[0]??(t.length?t[0]:null);if(c.length>1){const l=new Set(c.map(y=>y.id.trim())),x={};for(const y of l)x[y]=0;for(const y of e.questions){if(!y.isTiebreaker||(y.tieCategories&&y.tieCategories.length>0?y.tieCategories.map(a=>a.trim()).filter(a=>l.has(a)):Array.from(l)).length===0)continue;const d=i[y.id];if(d==null||d==="")continue;const g=(a,T)=>{x[a]!==void 0&&(x[a]+=T)};if(y.mappingMode==="answer"){if(typeof d=="string")g(d,1);else if(Array.isArray(d))for(const a of d)g(String(a),1);else typeof d=="number"&&g(String(d),1);continue}const f=(y.options||[]).map(a=>typeof a=="string"?{text:a}:a),M=a=>{if(a!=null&&a.categoryMappings)for(const T of a.categoryMappings){const b=T.trim();l.has(b)&&g(b,a.weight??1)}};if(y.type==="radio"||y.type==="likert"||y.type==="categorized"){const a=(()=>{const T=Z(d),b=f.find(P=>Z(P.text)===T);if(b)return b;const V=Number(T);
6if(!Number.isNaN(V)&&Number.isFinite(V))return f[V-1]})();M(a)}else if(y.type==="checkbox"){const a=Array.isArray(d)?d:[];for(const T of a){const b=Z(T),V=f.find(W=>Z(W.text)===b),P=Number(b),X=V??(!Number.isNaN(P)&&Number.isFinite(P)?f[P-1]:void 0);M(X)}}}const p=Object.entries(x).sort((y,R)=>R[1]-y[1]);if(p.length>0&&p[0][1]>0){const y=p[0][0],R=((S=p[1])==null?void 0:S[1])??-1/0;if(p[0][1]>R){const d=o.find(g=>g.id===y)||null;d&&(u=d)}}if(c.length>1&&u&&l.has(u.id)){const y={};for(const d of l)y[d]=0;for(const d of n){const g=d.path[0];l.has(g)&&(y[g]+=d.score)}const R=Object.entries(y).sort((d,g)=>g[1]-d[1]);if(R.length>0){const d=R[0][0],g=((j=R[1])==null?void 0:j[1])??-1/0;if(R[0][1]>g){const f=o.find(M=>M.id===d)||null;f&&(u=f)}}}if(c.length>1&&u&&l.has(u.id)){const y=[...c].sort((g,f)=>f.completionRate-g.completionRate),R=y[0]||null,d=y[1]||null;R&&(!d||R.completionRate>d.completionRate)&&(u=R)}}const N=Ce(u,n),D=c.length>1&&(!u||c.every(l=>l.id!==(u==null?void 0:u.id))),v=c.length>1&&!D;return{answers:i,categoryScores:t,primaryCategories:o,subtypeCategories:n,topCategory:u,topSubcategory:N,hasTie:D,tiedCategories:c.length>1&&u?c.filter(l=>l.id!==u.id):c,tieResolved:v,timestamp:new Date().toISOString()}}function Pe(e){const i=[...e];for(let t=i.length-1;t>0;t--){const o=Math.floor(Math.random()*(t+1));[i[t],i[o]]=[i[o],i[t]]}return i}function fe(e,i,t){const o=e.map(c=>{const u=Array.isArray(c.options)?c.options:[],D=(t?Pe(u):u).map(j=>({value:j.text,label:j.text}));let v="radio";c.type==="checkbox"&&(v="checkbox"),c.type==="select"&&(v="select"),c.type==="number"&&(v="number"),c.type==="textarea"&&(v="textarea"),c.type==="text"&&(v="text");const S={id:c.id,type:v,title:c.label??"",required:!!c.required,visibleIf:void 0};return v==="radio"||v==="checkbox"||v==="select"?{...S,options:D}:S});return{id:"phase",title:i,pages:[{id:"phase",title:i,questions:o}]}}function Qe({rawConfig:e,surveyId:i,initialAnswers:t,onFinalize:o}){const[n,c]=C.useState("main"),[u,N]=C.useState(t||{}),[D,v]=C.useState(null),[S,j]=C.useState([]),[l,x]=C.useState(null),[p,y]=C.useState(!1),[R,d]=C.useState([]),[g,f]=C.useState(!1),M=C.useMemo(()=>{const w=new Map;return(e.blocks||[]).forEach(Q=>w.set(Q.id,Q)),w},[e.blocks]),a=C.useMemo(()=>{const w=new Map,Q=z=>{(z||[]).forEach(O=>{if(O!=null&&O.id){const Y=O.id.trim(),B=O.fullName;w.set(Y,B||O.name||Y)}Array.isArray(O==null?void 0:O.children)&&O.children.length&&Q(O.children)})};try{Q(e.categories||[])}catch{}return w},[e]),T=C.useMemo(()=>({categories:e.categories,questions:e.questions||[],title:e.title}),[e]),b=C.useMemo(()=>(e.questions||[]).filter(z=>!z.isTiebreaker).filter(z=>{const O=z.blockId?M.get(z.blockId):void 0;return O?(O.blockType||"main")==="main":!0}),[e.questions,M]),V=C.useMemo(()=>{const w=(e.questions||[]).filter(k=>!!k.isTiebreaker);if(console.log(`
7🎯 Filtering tiebreaker questions for tied IDs:`,S),console.log(`Total tiebreaker questions in config: ${w.length}`),S.length===0)return console.log("No tied IDs yet, returning all tiebreaker questions"),w;const Q=w.filter(k=>Array.isArray(k.tieCategories)&&k.tieCategories.some(s=>S.includes(s.trim())));console.log(`Explicitly tagged tiebreakers: ${Q.length}`);const z=Q.length>0?Q:w;console.log(`Base tiebreakers to filter: ${z.length}`);const O=z.filter(k=>{if(!k.tieCategories||k.tieCategories.length===0)return console.log(`  ✓ General tiebreaker (no tieCategories): ${k.id}`),!0;const s=k.tieCategories.filter(I=>S.includes(I.trim())),h=s.length>=Math.min(2,S.length);return console.log(`  ${h?"✓":"✗"} Q ${k.id}: tieCategories=${k.tieCategories.join(",")}, covered=${s.length}/${S.length}`),h});console.log(`Permissive filtering result: ${O.length} questions`);const Y=O.filter(k=>!k.tieCategories||k.tieCategories.length===0?!0:S.every(s=>k.tieCategories.map(h=>h.trim()).includes(s)));console.log(`Strict filtering result: ${Y.length} questions`);const B=Y.length>0?Y:O;return console.log(`✅ Final tiebreaker questions: ${B.length}
8`),B},[e.questions,S]),P=C.useMemo(()=>{if(!D)return[];const w=(s,h)=>{if(!s)return null;const I=h.trim();for(const m of s){if((m==null?void 0:m.id.trim())===I)return m;if(Array.isArray(m==null?void 0:m.children)&&m.children.length>0){const A=w(m.children,I);if(A)return A}}return null},Q=w(e.categories||[],D.id),z=new Set([D.id.trim()]);if(Q!=null&&Q.children&&Array.isArray(Q.children)){const s=h=>{h.forEach(I=>{const m=I==null?void 0:I.id;m&&z.add(m.trim());const A=I==null?void 0:I.children;Array.isArray(A)&&A.length>0&&s(A)})};s(Q.children)}const O=(e.blocks||[]).filter(s=>(s.blockType||"category")==="category"&&s.conditionalOn&&z.has(s.conditionalOn.trim())),Y=e.questions||[];if(O.length===0)return console.warn("[SurveyFlow] No category blocks foun
8d for:",Array.from(z)),[];const B=new Set(O.map(s=>s.id));return Y.filter(s=>s.blockId&&B.has(s.blockId)&&!s.isTiebreaker)},[e,D]);C.useMemo(()=>n!=="category"||!D?null:(e.blocks||[]).filter(Q=>(Q.blockType||"category")==="category"&&Q.conditionalOn&&P.some(z=>z.blockId===Q.id))[0]||null,[n,D,e.blocks,P]);const X=C.useMemo(()=>{let w;return n==="main"?w=fe(b,"Survey",e.randomizeAnswers):n==="tiebreaker"?(console.log("🔗 Showing tiebreaker questions:",V.map(Q=>{var z,O,Y;return{id:Q.id,label:(z=Q.label)==null?void 0:z.substring(0,60),tieCategories:Q.tieCategories,tieCategoryNames:(O=Q.tieCategories)==null?void 0:O.map(B=>a.get(B)),options:(Y=Q.options)==null?void 0:Y.map(B=>{var k,s;return{text:(k=B.text)==null?void 0:k.substring(0,40),categoryMappings:B.categoryMappings,categoryNames:(s=B.categoryMappings)==null?void 0:s.map(h=>a.get(h))}})}})),w=fe(V,"Tiebreakers",e.randomizeAnswers)):w=fe(P,"",e.randomizeAnswers),w},[n,b,V,P,e.randomizeAnswers,a]);function W(w,Q){var J,se,K;if(console.log(`
9🎲 === TIEBREAKER RESOLUTION START ===`),console.log("Tied category IDs:",w),console.log("Tied category names:",w.map(E=>a.get(E.trim()))),console.log("Tiebreaker answers:",Q),!w.length){console.log("❌ No tied categories - returning undefined");return}const z=w.map(E=>E.trim()),O=new Set(z),Y=new Map(z.map(E=>[E,0])),B=e.questions||[],k=(E,$)=>{Y.has(E)&&(Y.set(E,(Y.get(E)||0)+$),console.log(`  ➕ Awarded ${$} point(s) to: ${a.get(E)||E}`))};console.log("Starting fresh tiebreaker scoring - all categories at 0 points");const s=B.filter(E=>!(!E.isTiebreaker||!Q[E.id]));console.log(`Found ${s.length} tiebreaker question(s) with answers:`,s.map(E=>{var $,F,U;return{id:E.id,label:($=E.label)==null?void 0:$.substring(0,50),tieCategories:(F=E.tieCategories)==null?void 0:F.map(q=>q.trim()),tieCategoryNames:(U=E.tieCategories)==null?void 0:U.map(q=>a.get(q.trim()))}}));for(const[E,$]of Object.entries(Q||{})){const F=B.find(L=>L.id===E);if(!(F!=null&&F.isTiebreaker))continue;console.log(`
10📋 Processing tiebreaker question ${E}:`,(J=F.label)==null?void 0:J.substring(0,50)),console.log("  Question type:",F.type),console.log("  Question mappingMode:",F.mappingMode),console.log("  Answer value:",$),console.log("  Answer type:",typeof $,Array.isArray($)?"(array)":"");const U=Array.isArray(F.tieCategories)&&F.tieCategories.length?F.tieCategories.map(L=>L.trim()).filter(L=>O.has(L)):z;if(console.log("  Relevant categories:",U.map(L=>a.get(L)||L)),U.length===0){console.log("  ⚠️ SKIPPED: No relevant categories");continue}if(F.mappingMode==="answer"){console.log('  📍 Question uses mappingMode="answer", checking if answer is in tied set...'),typeof $=="string"&&O.has($)?(console.log("  ✅ Answer matches a tied category ID, awarding 1 point"),k($,1)):console.log("  ⚠️ Answer does not match any tied category ID");continue}console.log("  ➡️ Proceeding to option matching..."),console.log("  ➡️ Proceeding to option matching...");const q=Array.isArray(F.options)?F.options:[];if(console.log(`  🔍 Question has ${q.length} options`),q.length===0){console.log("  ❌ ERROR: Question has no options! Cannot match answer.");continue}const ne=L=>{var _,pe;console.log("  🔎 Attempting to match answer:",L);const G=Z(L);console.log("  🔎 Normalized to:",G);const te=q.find(re=>Z(re.text)===G);if(te)return console.log("  ✅ Matched option by text:",(_=te.text)==null?void 0:_.substring(0,40)),te;console.log("  ⚠️ No text match found. Trying index match...");const H=Number(G);if(console.log(`  🔎 As number: ${H} (isNaN: ${Number.isNaN(H)})`),!Number.isNaN(H)&&Number.isFinite(H)){const re=q[H-1];if(re)return console.log("  ✅ Matched option by index:",(pe=re.text)==null?void 0:pe.substring(0,40)),re}console.log("  ❌ NO MATCH FOUND for answer:",L),console.log("  Available option texts:",q.map(re=>Z(re.text)))};if(Array.isArray($)){console.log("  📦 Answer is an array, processing multiple values...");for(const L of $){const G=ne(L);if(!((se=G==null?void 0:G.categoryMappings)!=null&&se.length)){console.log("  ⚠️ Option has no categoryMappings");continue}console.log("  Option categoryMappings:",G.categoryMappings);const te=F.type==="categorized"?1:G.weight??1;console.log(`  🎲 Question type: ${F.type}, Using points: ${te}`);for(const H of G.categoryMappings){const _=H.trim();O.has(_)?k(_,te):console.log(`  ⚠️ Category ${_} (${a.get(_)}) not in tied set`)}}}else{console.log("  📦 Answer is a single value, picking option...");const L=ne($);if(!L){console.log("  ❌ ERROR: Could not match answer to any option!");continue}if(!((K=L==null?void 0:L.categoryMappings)!=null&&K.length)){console.log("  ⚠️ Option has no categoryMappings");continue}const G=L.categoryMappings.map(H=>({id:H.trim(),name:a.get(H.trim()),inTiedSet:O.has(H.trim())}));console.log("  📊 Option categoryMappings:",G);const te=F.type==="categorized"?1:L.weight??1;console.log(`  🎲 Question type: ${F.type}, Using points: ${te} (opt.weight = ${L.weight})`);for(const H of L.categoryMappings){const _=H.trim();O.has(_)?k(_,te):console.log(`  ⚠️ Category ${_} (${a.get(_)}) not in tied set`)}}}const h=Array.from(Y.entries()).map(([E,$])=>({id:E,name:a.get(E)||E,score:$}));console.log(`
11📊 FINAL TIEBREAKER SCORE TALLY:`),console.table(h);const I=[...Y.entries()].sort((E,$)=>$[1]-E[1]),m=I[0],A=I[1];if(console.log(`
12🎯 TIEBREAKER RESOLUTION DECISION:`),console.log(`  #1: ${a.get(m==null?void 0:m[0])||(m==null?void 0:m[0])} = ${(m==null?void 0:m[1])||0} points`),console.log(`  #2: ${a.get(A==null?void 0:A[0])||(A==null?void 0:A[0])} = ${(A==null?void 0:A[1])||0} points`),m&&(m[1]||0)>0&&(!A||m[1]>A[1]))return console.log(`  ✅ RESOLVED: ${a.get(m[0])} wins with ${m[1]} points!`),console.log(`🎲 === TIEBREAKER RESOLUTION END ===
13`),m[0];!m||(m[1]||0)===0?(console.log("  ❌ NOT RESOLVED: No points awarded"),console.log("  💡 Check: Does the tiebreaker option have correct categoryMappings?"),console.log('  💡 Check: Is the question type "categorized" so it uses 1 point instead of weight?')):A&&m[1]===A[1]&&(console.log("  ❌ NOT RESOLVED: Still tied after tiebreaker!"),console.log("  💡 Check: Does the tiebreaker option map to BOTH tied categories?")),console.log(`🎲 === TIEBREAKER RESOLUTION END ===
14`)}async function ee(w){var Q,z,O,Y;if(g)return console.log("⚠️ Already submitting, ignoring duplicate submission"),{success:!1,message:"Already processing"};if(n==="tiebreaker"&&V.length===0){if(console.error("🚨 CRITICAL: In tiebreaker phase but no tiebreaker questions available!"),console.log("Using emergency fallback resolution..."),S.length>0){const h=S[0];if(console.log(`✅ Emergency fallback: Selected ${a.get(h)}`),l==="primary"){const I=ce(T,u).find(m=>m.id.trim()===h);if(I&&(v(I),e.surveyMode==="multi-level"&&!!(e.blocks||[]).find(A=>(A.blockType||"category")==="category"&&A.conditionalOn===h)))return c("category"),x(null),f(!1),window.scrollTo({top:0,behavior:"smooth"}),{success:!0}}else if(l==="subtype"){const I={...u,...w},m=le(T,I);m.resolvedSubtypeId=h,m.tieResolved=!!p,p&&(m.tiebreakerBetween=R,m.tiebreakerBetweenNames=R.map(se=>a.get(se)||se));const A=m.categoryScores.find(se=>se.id.trim()===h);return A&&(m.topSubcategory=A),await o(I,m)}}console.log("Proceeding to finalization with current answers...");const B={...u,...w},k=le(T,B);return await o(B,k)}f(!0);try{const B={...u,...w};N(B);let k;const s=ce(T,B),h=s.filter(K=>K.path.length===1),I=h[0]??(s[0]||null),m=((Q=h[0])==null?void 0:Q.score)??0,A=h.filter(K=>K.score===m&&m>0);if(n==="main"){if(A.length>1){const E=A.map($=>
14$.id.trim());return j(E),d(E),x("primary"),y(!0),c("tiebreaker"),f(!1),window.scrollTo({top:0,behavior:"smooth"}),{success:!0}}if(v(I||null),x(null),e.surveyMode==="multi-level"&&!!(e.blocks||[]).find(E=>(E.blockType||"category")==="category"&&E.conditionalOn===((I==null?void 0:I.id)||"")))return c("category"),f(!1),window.scrollTo({top:0,behavior:"smooth"}),{success:!0}}if(n==="tiebreaker"){const K=ce(T,B),$=K.filter(F=>F.path.length===1)[0]??(K[0]||null);if(De({normalAnswers:u,tiebreakerData:w,allAnswers:B,survey:T,categoryScores:K}),l==="primary"&&(v($||null),e.surveyMode==="multi-level"&&!!(e.blocks||[]).find(U=>(U.blockType||"category")==="category"&&U.conditionalOn===(($==null?void 0:$.id)||""))))return c("category"),x(null),f(!1),f(!1),window.scrollTo({top:0,behavior:"smooth"}),{success:!0};if(l==="subtype"){if(console.group("🔗 SUBTYPE TIEBREAKER RESOLUTION DEBUG"),console.log("Tied Subtype IDs:",S),console.log("Tied Subtype Names:",S.map(U=>a.get(U)||U)),console.log("Tiebreaker Answers:",w),(e.questions||[]).filter(U=>!!U.isTiebreaker).forEach(U=>{var ne,L,G;const q=w[U.id];if(q){console.log(`
15Tiebreaker Q [${U.id}]: "${(ne=U.label)==null?void 0:ne.substring(0,60)}..."`),console.log(`  User Answer: "${q}"`);const te=Array.isArray(q)?typeof q[0]=="string"||typeof q[0]=="number"?q[0]:String(q[0]):q,H=(L=U.options)==null?void 0:L.find(_=>Z(_.text)===Z(te));console.log("  Matched Option:",H?{text:(G=H.text)==null?void 0:G.substring(0,40),categoryMappings:H.categoryMappings,weight:H.weight}:"NO MATCH")}}),k=W(S,w),console.log(`
16Resolved from tiebreaker answers:`,k?a.get(k):"not resolved"),!k){const U=K.filter(L=>S.includes(L.id.trim())).sort((L,G)=>(G.score||0)-(L.score||0));console.log("Scores after tiebreaker:",U.map(L=>({name:L.name,id:L.id,score:L.score})));const q=U[0],ne=U[1];q&&(!ne||(q.score||0)>(ne.score||0))&&(k=q.id.trim()),console.log("Resolved from scores:",k?a.get(k):"not resolved")}!k&&S.length>0&&(k=S[0],console.log("Using fallback (first tied ID):",a.get(k))),console.log(`
17✅ Final Resolved Subtype:`,k?a.get(k):"none"),console.groupEnd()}x(null)}if(n==="category"&&D){const E=ce(T,B).filter(U=>U.path.length>1&&U.path[0]===D.id).sort((U,q)=>q.score-U.score),$=((z=E[0])==null?void 0:z.score)??0,F=$>0?E.filter(U=>U.score===$):[];if(F.length>1){const U=F.map(q=>q.id.trim());return console.log("🔗 SUBTYPE TIE DETECTED!"),console.log("Tied subtypes:",F.map(q=>({name:q.name,id:q.id,score:q.score}))),console.log("Tied IDs (normalized):",U),j(U),d(U),x("subtype"),y(!0),c("tiebreaker"),f(!1),window.scrollTo({top:0,behavior:"smooth"}),{success:!0}}}const J=le(T,B);if(J.tieResolved=!!p,p&&(J.tiebreakerBetween=R,J.tiebreakerBetweenNames=R.map(K=>a.get(K)||K)),k){J.resolvedSubtypeId=k;const K=k.trim(),E=J.categoryScores.find($=>$.id.trim()===K);console.log("🎯 Overriding topSubcategory with resolved tiebreaker winner:"),console.log("  Resolved ID:",K),console.log("  Resolved Name:",a.get(K)),console.log("  Found in scores:",!!E),E?(console.log("  Previous topSubcategory:",(O=J.topSubcategory)==null?void 0:O.name),J.topSubcategory=E,console.log("  New topSubcategory:",(Y=J.topSubcategory)==null?void 0:Y.name)):(console.error("  ERROR: Could not find resolved subtype in category scores!"),console.log("  Available subtype IDs:",J.categoryScores.filter($=>$.path.length>1).map($=>({id:$.id,name:$.name}))))}return await o(B,J)}catch(B){return console.error("Submission error:",B),f(!1),{success:!1,message:B instanceof Error?B.message:"Submission failed"}}}return C.useMemo(()=>S.map(w=>a.get(w)||w),[S,a]),r.jsx("div",{className:"space-y-4",children:r.jsx(Ie,{definition:X,mode:"question",showTitle:!0,nextLabel:"Next",backLabel:"Back",submitLabel:n==="category"?"Submit":"Continue",onSubmit:ee,progressOffset:n==="category"?b.length:0,progressTotalOverride:n==="category"?b.length+P.length:void 0},`${n}-${(D==null?void 0:D.id)||""}`)})}function ze(e){return Array.isArray(e)?e.map(i=>{const t=i.type==="number"?"number":i.type==="textarea"?"textarea":"text";return{id:i.id,type:t,title:i.label,required:!!i.required}}):[]}function Te(e){const i=[...e];for(let t=i.length-1;t>0;t--){const o=Math.floor(Math.random()*(t+1));[i[t],i[o]]=[i[o],i[t]]}return i}function me(e,i){let t="radio";e.type==="checkbox"?t="checkbox":e.type==="number"?t="number":e.type==="textarea"?t="textarea":e.type==="text"?t="text":e.type==="select"&&(t="select");const o={id:e.id,type:t,title:e.label,required:!!e.required};if(t==="text"||t==="textarea"||t==="number")return o;const n=Array.isArray(e.options)?e.options:[],u=(i!=null&&i.randomizeAnswers?Te(n):n).map(N=>({value:N.text,label:N.text}));return{...o,options:u}}function Be(e,i){let t;try{t=JSON.parse(e)}catch{throw new Error("Invalid survey config JSON")}const o=ze(t.formInfo);let n=Array.isArray(t.questions)?t.questions:[];if(t.randomizeQuestions){const v=n.filter(j=>j.type!=="likert"),S=n.filter(j=>j.type==="likert");n=[...Te(v),...S]}const c=new Map,u=[];for(const v of n){const S=v.blockId;if(S&&typeof S=="string"){const j=c.get(S)||[];j.push(v),c.set(S,j)}else u.push(v)}const N=[];o.length>0&&N.push({id:"form-info",title:"Your Info",questions:o});const D=new Map;
17(t.blocks||[]).forEach(v=>D.set(v.id,v));for(const[v,S]of c.entries()){const j=D.get(v),l=(j==null?void 0:j.name)||"Survey",x=S.map(p=>me(p,{randomizeAnswers:t.randomizeAnswers}));N.push({id:`block-${v}`,title:l,questions:x})}return u.length>0&&c.size===0?N.push({id:"main",title:"Survey",questions:u.map(v=>me(v,{randomizeAnswers:t.randomizeAnswers}))}):u.length>0&&N.push({id:"unassigned",title:"Additional Questions",questions:u.map(v=>me(v,{randomizeAnswers:t.randomizeAnswers}))}),{id:(i==null?void 0:i.surveyId)||"portable-survey",title:t.title||"Survey",description:t.description||void 0,pages:N}}const oe={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_ADMIN_EMAILS:"[email protected], [email protected], [email protected], [email protected]",VITE_ADMIN_ENABLED:"true",VITE_AUTH_DOMAIN:"auth.ttypes.ai",VITE_ENTERPRISE_MODE:"false",VITE_ENVIRONMENT:"production",VITE_FORCE_TIE:"false",VITE_SENTRY_DSN:"https://862b8884fa192949e8a54282025eae98@o4511404278677504.ingest.us.sentry.io/4511404317016064",VITE_SUPER_ADMIN_EMAILS:"[email protected], [email protected], [email protected], [email protected]",VITE_SURVEY_API_URL:"https://t90vzahwk9.execute-api.us-east-1.amazonaws.com/dev",VITE_TENANT_ID:"0498e418-f051-7022-ebf0-1c028a33788f",VITE_USE_SURVEY_PROXY:"true"};function qe(){const{id:e}=je(),i=Re(),{accessTier:t,hasAssessmentAccess:o,assessmentCompleted:n,loading:c}=Me(),[u,N]=C.useState(null),[D,v]=C.useState(null),[S,j]=C.useState(!1),[l,x]=C.useState(!1),[p,y]=C.useState(null),R=C.useMemo(()=>"0498e418-f051-7022-ebf0-1c028a33788f",[]);C.useEffect(()=>{if(c||o)return;const g=oe==null?void 0:oe.VITE_RAPID_SURVEY_ID;g&&e&&e!==g&&i("/assessments",{replace:!0})},[c,o,e,i]),C.useEffect(()=>{if(c||t!=="assessment"||!n)return;const g=oe==null?void 0:oe.VITE_RAPID_SURVEY_ID;(!g||e&&e!==g)&&i("/library",{replace:!0})},[c,t,n,e,i]);const d=async g=>{if(t!=="assessment"||n)return;const f=oe==null?void 0:oe.VITE_RAPID_SURVEY_ID;if(!(f&&e&&e===f))try{await Oe(g)}catch(M){console.error("completeOneTimeAssessment failed:",M)}};return C.useEffect(()=>{let g=!0;async function f(){if(!e){v("We couldn't find this survey. Please return to the dashboard and try again.");return}j(!0),v(null);try{const{parsed:M}=await $e(R||void 0),T=(M.surveys||[]).find(P=>(P.surveyId||P.id)===e),b=T==null?void 0:T.config;if(!b||typeof b!="string")throw new Error("This survey is not properly configured. Please contact support for assistance.");const V=Be(b,{surveyId:e});try{const P=JSON.parse(b);g&&y(P)}catch{g&&y(null)}g&&N(V)}catch(M){g&&v(M instanceof Error?M.message:String(M))}finally{g&&j(!1)}}return f(),()=>{g=!1}},[e,R]),S?r.jsx("div",{className:"p-4",children:"Loading your assessment…"}):D?r.jsx("div",{className:"max-w-2xl mx-auto p-6",children:r.jsxs("div",{className:"bg-card rounded-xl border border-border shadow-soft p-6",children:[r.jsx("h2",{className:"font-semibold text-foreground mb-2",children:"Unable to Load Survey"}),r.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:D}),r.jsxs("button",{onClick:()=>i("/"),className:"inline-flex items-center gap-2 px-3 py-2 text-sm font-medium text-muted-foreground hover:text-foreground rounded-lg hover:bg-accent/50 transition-all duration-200",children:[r.jsx(we,{className:"w-4 h-4"}),"Return to Dashboard"]})]})}):u?r.jsxs("div",{className:"max-w-3xl mx-auto p-4",children:[r.jsx("div",{className:"mb-6",children:r.jsxs("button",{onClick:()=>i("/"),className:"inline-flex items-center gap-2 px-3 py-2 text-sm font-medium text-muted-foreground hover:text-foreground rounded-lg hover:bg-accent/50 transition-all duration-200",children:[r.jsx(we,{className:"w-4 h-4"}),"Back to Dashboard"]})}),r.jsxs("div",{className:"mb-6 rounded-2xl p-6 bg-gradient-to-br from-indigo-50 via-white to-pink-50 border border-gray-100 glow-soft",children:[r.jsx("h1",{className:"text-3xl font-semibold tracking-tight bg-clip-text text-transparent bg-gradient-to-r from-indigo-600 via-purple-600 to-pink-600 font-display",children:u.title}),u.description&&r.jsx("p",{className:"mt-2 text-sm text-muted-foreground max-w-prose",children:u.description})]}),p&&p.surveyMode==="multi-level"?r.jsx(Qe,{rawConfig:p,surveyId:e,onFinalize:async(g,f)=>{var M,a;try{if(x(!0),Object.keys(g||{}).length<5)return{success:!1,message:"Please complete more questions before submitting"};if(!f||!f.topCategory||!((M=f.categoryScores)!=null&&M.length))return{success:!1,message:"Unable to compute results. Please try again."};await ye({surveyId:e,responses:g,result:f,status:"completed",completionPercentage:100});try{const b=ue(f);if(b!=null&&b.id){const V=await be(),P=V.userId??V.username??"";P&&(await xe({id:P,tType:b.id}
17),window.dispatchEvent(new CustomEvent("tTypeUpdated")),window.dispatchEvent(new CustomEvent("surveyPreferenceChanged")))}}catch(b){console.error("Failed to save t-type to profile:",b)}await d((a=ue(f))==null?void 0:a.fullName),ve(),Ne("assessment_complete").catch(()=>{});try{sessionStorage.setItem("surveyRedirected","true")}catch{}return i(`/survey/native/${e}/results`,{state:{surveyTitle:u.title},replace:!0}),{success:!0}}catch(T){const b=T instanceof Error?T.message:String(T);return console.error("Submit failed:",b),{success:!1,message:b}}finally{x(!1)}}}):r.jsx(Ie,{definition:u,mode:"question",showTitle:!1,onSubmit:async g=>{var f,M;if(!e)return{success:!1,message:"Missing survey id"};if(l)return{success:!1,message:"Already submitting"};try{x(!0);let a;if(p&&p.surveyMode==="single"){const P=new Set(p.questions.map(ee=>ee.id)),X=p.formInfo;X&&X.forEach(ee=>{ee.id&&P.add(ee.id)});const W={};Object.entries(g).forEach(([ee,w])=>{P.has(ee)&&(typeof w=="string"||typeof w=="number"||Array.isArray(w))&&(W[ee]=w)}),a=le(p,W)}else if(p&&p.categories){const P={};Object.entries(g).forEach(([X,W])=>{(typeof W=="string"||typeof W=="number"||Array.isArray(W))&&(P[X]=W)}),a=le(p,P)}const T=Object.keys(g||{}).length,b=!(p!=null&&p.categories)||p.categories.length===0,V=(p==null?void 0:p.surveyMode)==="single"?5:b?3:20;if(T<V)return{success:!1,message:`Please complete at least ${V} questions before submitting`};if(a&&!b&&(!a.topCategory||!((f=a.categoryScores)!=null&&f.length)))return{success:!1,message:"Unable to compute valid results. Please try again."};if(await ye({surveyId:e,responses:g,result:a,status:"completed",completionPercentage:100}),a)try{const P=ue(a);if(P!=null&&P.id){const X=await be(),W=X.userId??X.username??"";W&&(await xe({id:W,tType:P.id}),window.dispatchEvent(new CustomEvent("tTypeUpdated")),window.dispatchEvent(new CustomEvent("surveyPreferenceChanged")))}}catch(P){console.error("Failed to save t-type to profile:",P)}await d(a?(M=ue(a))==null?void 0:M.fullName:void 0),ve(),Ne("assessment_complete").catch(()=>{});try{sessionStorage.setItem("surveyRedirected","true")}catch{}return i(`/survey/native/${e}/results`,{state:{surveyTitle:u.title},replace:!0}),{success:!0}}catch(a){const T=a instanceof Error?a.message:String(a);return console.error("Submit failed:",T),{success:!1,message:T}}finally{x(!1)}},submitLabel:l?"Submitting…":"Submit",nextLabel:"Next",backLabel:"Back"})]}):r.jsx("div",{className:"p-4",children:"Preparing your assessment…"})}export{qe 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.