(function(){ "use strict"; /* ---------- verified program data (from programs_db.py, research 2026-09-26/27) ---------- */ var PROGRAMS = [ {id:"snap", name:"SNAP Food Benefits (Texas HHSC)", what:"Monthly grocery money on a Lone Star Card — up to $994/mo for a family of 4 (FY2026 max).", phone:"2-1-1 or 877-541-7905", apply:"https://www.yourtexasbenefits.com/Learn/Home", est:"snap"}, {id:"wic", name:"WIC — Women, Infants & Children", what:"Healthy food, nutrition classes and breastfeeding support for pregnant women and kids under 5. No citizenship requirement.", phone:"800-942-3678", apply:"https://texaswic.org/apply"}, {id:"medicaid", name:"Texas Medicaid", what:"FREE health coverage for kids, pregnant women, seniors and people with disabilities.", phone:"2-1-1 or 1-877-541-7905", apply:"https://www.yourtexasbenefits.com/Learn/Home"}, {id:"chip", name:"Texas CHIP — Children's Health Insurance", what:"Low-cost health coverage for kids 18 & under — enrollment $50 or less per year, co-pays $3–$35.", phone:"2-1-1", apply:"https://www.yourtexasbenefits.com/Learn/Home"}, {id:"tanf", name:"TANF Cash Help", what:"Monthly cash for families with kids and little to no income (family of 3 ≈ $382/mo).", phone:"2-1-1 or 877-541-7905", apply:"https://www.yourtexasbenefits.com/Learn/Home", est:"tanf"}, {id:"opportunity_home", name:"Opportunity Home — Public Housing & Section 8", what:"Rent based on income (around 30%). Apply the moment a waitlist opens — they fill fast.", phone:"210-477-6000", apply:"https://homesa.org/housing/find-a-home/apply-for-housing/"}, {id:"hap", name:"City of San Antonio Housing Assistance (HAP)", what:"Up to 3 months of rent (max ~$3,500) + up to $1,500 in utility help, paid straight to your landlord. ⏰ Enrollment windows fill fast.", phone:"210-207-6459", apply:"https://www.sa.gov/Directory/Departments/NHSD/Housing-Support/Renter-Support/About-HAP", hot:true}, {id:"trla_rtc", name:"Right to Counsel — Free Eviction Lawyer", what:"A FREE attorney if you're facing eviction. Call immediately if you have court papers. ⏰", phone:"210-212-3703", apply:"https://www.trla.org/", hot:true}, {id:"cps_discount", name:"CPS Energy Affordability Discount", what:"Up to 25% off your electric bill every month (35% if you're 60+).", phone:"1-888-207-7434", apply:"https://www.sa.gov/Directory/Departments/DHS/Financial-Assistance/Utility-Assistance", est:"utility"}, {id:"sa_utility", name:"City of San Antonio Utility Assistance", what:"Help paying energy bills — priority for households with kids, disabilities, or adults 60+.", phone:"210-207-8198", apply:"https://www.sa.gov/Directory/Departments/DHS/Financial-Assistance/Utility-Assistance"}, {id:"vita", name:"VITA — Free Tax Preparation", what:"IRS-certified volunteers do your taxes FREE (Jan–Apr) — including EITC and Child Tax Credit.", phone:"210-207-6575", apply:"https://vitasa.org/"}, {id:"twc_unemp", name:"Texas Unemployment Benefits", what:"Partial income replacement if you lost your job or had hours cut — roughly $75–$605/week.", phone:"800-939-6631", apply:"https://www.twc.texas.gov/services/apply-benefits"}, {id:"wioa", name:"WIOA — Free Career Training (Workforce Solutions Alamo)", what:"FREE career counseling, job training and certifications at 16 Alamo-area career centers.", phone:"210-438-0581", apply:"https://www.workforcesolutionsalamo.org/information-sessions/"}, {id:"ccs", name:"Child Care Scholarships (CCS)", what:"Helps working parents pay for child care. Apply early — there can be a waitlist.", phone:"1-888-265-6461", apply:"https://childcare.twc.texas.gov/find/register?mode=signup"}, {id:"va", name:"VA Benefits", what:"Health care, disability compensation, GI Bill, home loans and more for veterans.", phone:"1-800-827-1005", apply:"https://benefits.va.gov/benefits/applying.asp"}, {id:"tvc", name:"Texas Veterans Commission", what:"FREE help filing VA disability claims, job placement and education benefits.", phone:"1-800-252-8387", apply:"https://tvc.texas.gov/"}, {id:"hud_vash", name:"HUD-VASH — Housing for Homeless Veterans", what:"Rental voucher + VA case management for veterans facing homelessness. ⏰", phone:"877-424-3838", apply:"https://www.va.gov/south-texas-health-care/health-services/homeless-veteran-care/", hot:true}, {id:"foodbank", name:"San Antonio Food Bank — Free Food + Application Help", what:"Free groceries AND free one-on-one help applying for SNAP, Medicaid and TANF. No citizenship requirement for food.", phone:"210-431-8326", apply:"https://safoodbank.org/our-programs/benefits-assistance/"}, {id:"trla", name:"Texas RioGrande Legal Aid", what:"FREE civil legal help — housing, family, benefits denials. English and Spanish.", phone:"(833) 329-8752", apply:"https://www.trla.org/"}, {id:"211", name:"2-1-1 Texas Helpline", what:"One free call connects you to thousands of local services. 24/7, 100+ languages.", phone:"2-1-1", apply:"https://www.211texas.org/"} ]; /* 2025 federal poverty guidelines (48 states), monthly */ var FPL_M = {1:1304.17, 2:1762.50, 3:2220.83, 4:2679.17, 5:3137.50, 6:3595.83, 7:4054.17, 8:4512.50}; var SNAP_MAX = {1:298, 2:548, 3:783, 4:994, 5:1158, 6:1390, 7:1536, 8:1755}; /* FY2026 max allotments */ function fpl(hh, pct){ var b = FPL_M[Math.min(hh,8)] || 4512.50; if(hh>8) b += (hh-8)*478.33; return b*pct; } function initChecker(root){ if(!root || root.dataset.init) return; root.dataset.init = "1"; var $ = function(s){ return root.querySelector(s); }; var $$ = function(s){ return Array.prototype.slice.call(root.querySelectorAll(s)); }; var state = { zip:"", hh:3, income:3000, sit:{}, focus:null, name:"", phone:"", email:"", pref:"", consent:false, dob:"", street:"", city:"", employment:"", income_amount:"", income_period:"", citizenship:"", top_needs:[], language:"en", contact_time:"", hear_about:"", notes:"" }; try { var sc = root.closest('[data-sabck-focus]'); if (sc) state.focus = sc.getAttribute('data-sabck-focus'); } catch(e){} /* ---------- navigation ---------- */ var order = ["start","zip","household","income","situations","contact","results"]; function show(name){ $$(".sabck-screen").forEach(function(el){ el.classList.toggle("sabck-active", el.dataset.screen===name); }); var i = order.indexOf(name); $("#sabck-pfill").style.width = Math.round(i/(order.length-1)*100) + "%"; root.scrollIntoView({behavior:"smooth", block:"start"}); /* funnel analytics: quiz start + per-step progress (server dedupes per visitor/day) */ try{ if(name==="zip") sabckFunnel("quiz_start"); else if(name==="household") sabckFunnel("quiz_step", 2); else if(name==="income") sabckFunnel("quiz_step", 3); else if(name==="situations") sabckFunnel("quiz_step", 4); else if(name==="results") sabckFunnel("quiz_step", 5); }catch(e){} } /* Anonymous funnel beacon: start/step events only, no answers attached. */ function sabckFunnel(ev, step){ try{ var d = {event: ev, page: window.location.pathname}; if(step) d.step = step; var x = new XMLHttpRequest(); x.open("POST", "/wp-json/sab/v1/quiz-event", true); x.setRequestHeader("Content-Type", "application/json"); x.send(JSON.stringify(d)); }catch(e){} } /* Lead capture: contact info + quiz answers, stored and emailed to the owner. */ function sendLead(){ try{ var res = match(); var sitKeys = Object.keys(state.sit).filter(function(k){ return state.sit[k]; }); var d = { name: state.name, phone: state.phone, email: state.email, pref: state.pref, consent: state.consent ? 1 : 0, dob: state.dob, street: state.street, city: state.city, employment: state.employment, income_amount: state.income_amount, income_period: state.income_period, citizenship: state.citizenship, top_need: state.top_needs.join(","), language: state.language, contact_time: state.contact_time, hear_about: state.hear_about, notes: state.notes, zip: state.zip, hh: state.hh, income: state.income, sit: sitKeys.join(","), matched: res.map(function(r){ return r.p.id; }).join(","), count: res.length, value: res.reduce(function(s,r){ return s+(r.val||0); }, 0), page: window.location.pathname }; var x = new XMLHttpRequest(); x.open("POST", "/wp-json/sab/v1/quiz-lead", true); x.setRequestHeader("Content-Type", "application/json"); x.send(JSON.stringify(d)); }catch(e){} } /* Delegated clicks: one listener on the checker root survives DOM rewrites by translators/optimizers that replace child nodes. */ root.addEventListener("click", function(e){ var t = e.target; var el = (t && t.nodeType === 1) ? t : (t && t.parentElement ? t.parentElement : null); function closest(sel){ var n = el; while(n && n !== root){ if(n.matches && n.matches(sel)) return n; n = n.parentElement; } return null; } var nx = closest("[data-next]"); if(nx){ show(nx.getAttribute("data-next")); return; } if(closest("#sabck-zip-next")){ var z = $("#sabck-zip").value.trim(); if(!/^\d{5}$/.test(z)){ $("#sabck-zip-err").style.display="block"; return; } $("#sabck-zip-err").style.display="none"; state.zip = z; show("household"); return; } if(closest("#sabck-hh-minus")){ state.hh=Math.max(1,state.hh-1); $("#sabck-hh-val").textContent=state.hh; return; } if(closest("#sabck-hh-plus")){ state.hh=Math.min(10,state.hh+1); $("#sabck-hh-val").textContent=state.hh; return; } var incBtn = closest("#sabck-income-opts button"); if(incBtn){ state.income=parseFloat(incBtn.getAttribute("data-val")); show("situations"); return; } if(closest("#sabck-see-results")){ $$(".sabck-checks input").forEach(function(c){ state.sit[c.value]=c.checked; }); show("contact"); return; } if(closest("#sabck-contact-submit")){ var nm = $("#sabck-name").value.trim(); var ph = $("#sabck-phone").value.trim(); var em = $("#sabck-email").value.trim(); var digits = ph.replace(/[^0-9]/g, ""); var dob = $("#sabck-dob").value; var dobOk = /^\d{4}-\d{2}-\d{2}$/.test(dob) && (function(){ var p = dob.split("-"); var y = +p[0], m = +p[1], d = +p[2]; if(y < 1900 || y > new Date().getFullYear()) return false; var dt = new Date(y, m-1, d); return dt.getFullYear()===y && dt.getMonth()===m-1 && dt.getDate()===d && dt <= new Date(); })(); var street = $("#sabck-street").value.trim(); var city = $("#sabck-city").value.trim(); var employment = $("#sabck-employment").value; var incAmtRaw = $("#sabck-income-amount").value.trim(); var incAmt = parseFloat(incAmtRaw); var incPer = $("#sabck-income-period").value; var incOk = incAmtRaw !== "" && !isNaN(incAmt) && incAmt >= 0 && incAmt <= 10000000 && (incPer === "week" || incPer === "month" || incPer === "year"); var citizenship = $("#sabck-citizenship").value; var topNeeds = []; var tnBoxes = document.querySelectorAll("#sabck-topneeds input[type=checkbox]:checked"); for(var ti = 0; ti < tnBoxes.length; ti++){ topNeeds.push(tnBoxes[ti].value); } var ok = nm.length >= 2 && digits.length >= 7 && digits.length <= 15 && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(em) && dobOk && street.length >= 3 && city.length >= 2 && employment !== "" && incOk && citizenship !== "" && topNeeds.length > 0; $("#sabck-contact-err").style.display = ok ? "none" : "block"; if(!ok) return; state.name = nm; state.phone = ph; state.email = em; state.dob = dob; state.street = street; state.city = city; state.employment = employment; state.income_amount = incAmt; state.income_period = incPer; state.citizenship = citizenship; state.top_needs = topNeeds; var lg = $("#sabck-language"); state.language = lg ? lg.value : "en"; var ct = $("#sabck-contacttime"); state.contact_time = ct ? ct.value : ""; var ha = $("#sabck-hearabout"); state.hear_about = ha ? ha.value.trim() : ""; var nt = $("#sabck-notes"); state.notes = nt ? nt.value.trim().slice(0, 2000) : ""; var pr = $("#sabck-pref"); state.pref = pr ? pr.value : ""; var cs = $("#sabck-consent"); state.consent = cs ? cs.checked : false; sendLead(); renderResults(); show("results"); return; } var sh = closest("[data-share]"); if(sh){ doShare(sh.getAttribute("data-share")); } }); /* ---------- matching engine ---------- */ function match(){ var hh=state.hh, inc=state.income, s=state.sit, out=[]; function add(id, why, val){ var p=null; PROGRAMS.forEach(function(x){ if(x.id===id) p=x; }); if(p) out.push({p:p, why:why, val:val||0}); } var snapLim = fpl(hh,1.65), medLim = fpl(hh,1.33), chipLim = fpl(hh,2.00); if(inc <= snapLim) add("snap","Your income is under the SNAP limit for a household of "+hh+".", SNAP_MAX[Math.min(hh,8)]||1755); if(s.youngchild) add("wic","You have a young child or are pregnant — WIC has no citizenship requirement."); if(s.kids && inc <= medLim) add("medicaid","Your kids likely qualify for free coverage at your income."); else if((s.senior||s.disabled) && inc <= medLim) add("medicaid","Seniors and people with disabilities can qualify at your income."); if(s.kids && inc > medLim && inc <= chipLim) add("chip","Your income is above Medicaid but under the CHIP limit — low-cost kids' coverage."); else if(s.kids && inc <= chipLim) add("chip","Backup option if Medicaid doesn't come through — CHIP covers kids cheaply."); if(s.kids && inc <= 1000) add("tanf","Very low income with kids — TANF provides monthly cash help.", 382); if(inc <= snapLim) add("opportunity_home","Low-income households can apply when waitlists open."); if(s.eviction){ add("trla_rtc","You're facing eviction — a free lawyer can fight it."); add("hap","Behind on rent? HAP can cover up to 3 months."); } else if(inc <= fpl(hh,0.80)) add("hap","Your income is under 80% of area median — HAP rental help when enrollment opens."); if(inc <= fpl(hh,1.25)) add("cps_discount","Your income qualifies for up to 25% off your CPS Energy bill.", 45); if(inc <= fpl(hh,1.50)) add("sa_utility","Your income is under the city utility-assistance limit."); if(inc <= 5417) add("vita","Your income is under $65k/yr — get your taxes done free."); if(s.unemployed){ add("twc_unemp","You lost work or hours — unemployment can replace part of your income."); add("wioa","Free job training while you get back on your feet."); } if(s.kids && (s.unemployed || true)) add("ccs","Working or training with kids? Child care scholarships help pay for it."); if(s.veteran){ add("va","As a veteran, start with your full VA benefits check."); add("tvc","Free help filing VA claims and finding work."); if(s.eviction) add("hud_vash","Veteran facing housing loss — HUD-VASH combines a voucher with VA support."); } add("foodbank","Open to everyone in the area — free food plus free help applying for benefits."); if(s.eviction || inc <= snapLim) add("trla","Free legal help if any application is denied or you need legal aid."); add("211","Catch-all: one call finds any local help we didn't list."); /* de-dupe + sort: hot first, then by value, then focus */ var seen={}, ded=[]; out.forEach(function(r){ if(!seen[r.p.id]){ seen[r.p.id]=1; ded.push(r); } }); ded.sort(function(a,b){ if(state.focus){ if(a.p.id===state.focus) return -1; if(b.p.id===state.focus) return 1; } if(!!a.p.hot!==!!b.p.hot) return a.p.hot?-1:1; return (b.val||0)-(a.val||0); }); return ded; } function renderResults(){ var res = match(); var total = res.reduce(function(s,r){ return s+(r.val||0); }, 0); $("#sabck-res-headline").textContent = "You may qualify for " + res.length + " programs"; var inSA = /^782\d{2}$/.test(state.zip); $("#sabck-res-sub").textContent = inSA ? "Based on a household of "+state.hh+" with ~$"+state.income.toLocaleString()+"/mo income in "+state.zip+"." : "Based on a household of "+state.hh+" with ~$"+state.income.toLocaleString()+"/mo income. (Note: "+state.zip+" looks outside San Antonio — some local programs may not apply.)"; if(total>0){ $("#sabck-res-value").style.display="block"; $("#sabck-res-value-num").textContent = "$"+total.toLocaleString(); } var list = $("#sabck-res-list"); list.innerHTML=""; res.forEach(function(r){ var card=document.createElement("div"); card.className="sabck-card"; var badge = r.p.hot ? '⏰ Time-sensitive' : '✓ May qualify'; var valLine = r.val ? '
Worth up to ~$'+r.val.toLocaleString()+'/mo
' : ''+r.why+'
'; card.innerHTML = ''+r.why+'
'+valLine : valLine) + ''+r.p.what+'
' + '' + 'Apply →'; list.appendChild(card); }); /* ---------- anonymous usage analytics (no IP / no email stored) ---------- */ try { var ev = { event: "complete", zip3: (state.zip||"").substring(0,3), hh: state.hh, income: state.income, sit: Object.keys(state.sit).filter(function(k){ return state.sit[k]; }).join(","), matched: res.map(function(r){ return r.p.id; }).join(","), count: res.length, value: res.reduce(function(s,r){ return s+(r.val||0); }, 0), page: window.location.pathname }; var xhr = new XMLHttpRequest(); xhr.open("POST", "/wp-json/sab/v1/quiz-event", true); xhr.setRequestHeader("Content-Type", "application/json"); xhr.send(JSON.stringify(ev)); } catch(e){} } /* ---------- share ---------- */ var shareUrl = window.location.href.split('#')[0]; var shareText = "I just checked which San Antonio benefits I qualify for — it takes 60 seconds and it's free:"; function doShare(k){ var u=encodeURIComponent(shareUrl), t=encodeURIComponent(shareText); if(k==="facebook") window.open("https://www.facebook.com/sharer/sharer.php?u="+u,"_blank","width=600,height=500"); else if(k==="whatsapp") window.open("https://wa.me/?text="+t+"%20"+u,"_blank"); else if(k==="x") window.open("https://twitter.com/intent/tweet?text="+t+"&url="+u,"_blank"); else if(k==="copy"){ var done=function(){ var d=$("#sabck-share-done"); d.style.display="block"; setTimeout(function(){d.style.display="none";},2500); }; if(navigator.clipboard) navigator.clipboard.writeText(shareText+" "+shareUrl).then(done,done); else done(); } } } /* end initChecker */ function initAllCheckers(){ var nodes = document.querySelectorAll(".sab-checker"); for(var i=0;i