import"./hoisted.yFz1BYXO.js";const e=a=>document.getElementById(a),n=a=>document.getElementById(a);let c=1;const _=7;function L(a){for(let t=1;t<=_;t++){e(`step-${t}`)?.classList.toggle("hidden",t!==a);const l=document.querySelector(`[data-step="${t}"]`);l&&(l.classList.toggle("active",t===a),l.classList.toggle("done",t{c===_?N():k(c)&&(c===3&&w(),c===4&&$(),c===6&&q(),L(c+1))});e("btn-back")?.addEventListener("click",()=>{c>1&&L(c-1)});document.querySelectorAll('input[name="provides_telecom"]').forEach(a=>{a.addEventListener("change",()=>{const r=document.querySelector('input[name="provides_telecom"]:checked')?.value;e("q-voip-catch")?.classList.toggle("hidden",r!=="no"),e("not-a-filer")?.classList.add("hidden"),r==="yes"&&(e("q-pstn")?.classList.remove("hidden"),e("q-infra")?.classList.remove("hidden"))})});document.querySelectorAll('input[name="provides_voip_any"]').forEach(a=>{a.addEventListener("change",()=>{document.querySelector('input[name="provides_voip_any"]:checked')?.value==="no"?(e("not-a-filer")?.classList.remove("hidden"),e("q-pstn")?.classList.add("hidden"),e("q-infra")?.classList.add("hidden")):(e("not-a-filer")?.classList.add("hidden"),e("q-pstn")?.classList.remove("hidden"),e("q-infra")?.classList.remove("hidden"))})});document.querySelectorAll('input[name="infra_type"]').forEach(a=>{a.addEventListener("change",()=>{const r=document.querySelector('input[name="infra_type"]:checked')?.value;e("reseller-note")?.classList.toggle("hidden",r!=="reseller"&&r!=="both")})});document.querySelector('input[name="svc_cat"][value="other"]')?.addEventListener("change",a=>{e("other-desc-field")?.classList.toggle("hidden",!a.target.checked)});function k(a){if(a===1){const r=document.querySelector('input[name="provides_telecom"]:checked')?.value;if(!r)return alert("Please answer whether you provide telecommunications services."),!1;if(r==="no"){const t=document.querySelector('input[name="provides_voip_any"]:checked')?.value;if(!t)return alert("Please answer whether you provide VoIP or calling services."),!1;if(t==="no")return!1}return document.querySelector('input[name="pstn_connected"]:checked')?.value?document.querySelector('input[name="infra_type"]:checked')?.value?!0:(alert("Please indicate if you are facilities-based or a reseller."),!1):(alert("Please indicate if your service is connected to the PSTN."),!1)}if(a===2)return document.querySelectorAll('input[name="svc_cat"]:checked').length===0?(alert("Please select at least one service category."),!1):!0;if(a===3){const r=parseFloat(n("total_revenue").value.replace(/[,$]/g,""));return!r&&r!==0?(alert("Please enter your total annual telecom revenue."),!1):!0}return a===5?n("entity_name").value.trim()?n("ein").value.trim()?n("contact_name").value.trim()?n("contact_email").value.trim()?!0:(alert("Please enter a contact email."),!1):(alert("Please enter a contact name."),!1):(alert("Please enter your EIN / Tax ID."),!1):(alert("Please enter your legal entity name."),!1):a===7?n("disclaimer").checked?document.querySelector('input[name="service_tier"]:checked')?.value?!0:(alert("Please select a service tier."),!1):(alert("Please acknowledge the disclaimer."),!1):!0}function w(){const a=parseFloat(n("total_revenue").value.replace(/[,$]/g,""))||0,r=(parseFloat(n("pct_interstate").value)||0)/100,t=(parseFloat(n("pct_international").value)||0)/100,l=(parseFloat(n("pct_end_user").value)||0)/100,o=a*r,s=a*t,d=(o+s)*l/4,u=document.querySelector('input[name="pstn_connected"]:checked')?.value,m=document.querySelector('input[name="infra_type"]:checked')?.value,x=u==="yes"?"Interconnected VoIP":"Non-Interconnected VoIP";e("result-filer-type").textContent=x,e("result-infra").textContent=m==="facilities"?"Facilities-Based":m==="reseller"?"Reseller":"Facilities + Reseller";const p=d<=37175,h=e("result-deminimis-card");p?(h.className="rounded-xl p-5 border bg-green-50 border-green-200",e("dm-icon").innerHTML=' ',e("result-dm-label").className="text-sm font-bold text-green-800",e("result-dm-label").textContent="De Minimis — Simplified Filing",e("result-dm-detail").className="text-xs text-green-700 mt-1",e("result-dm-detail").textContent=`Quarterly end-user interstate+international revenue: $${d.toLocaleString("en-US",{maximumFractionDigits:0})} (threshold: $37,175). You're exempt from quarterly 499-Q filings and direct USF contributions.`):(h.className="rounded-xl p-5 border bg-amber-50 border-amber-200",e("dm-icon").innerHTML=' ',e("result-dm-label").className="text-sm font-bold text-amber-800",e("result-dm-label").textContent="Full Contributor — Quarterly Filing Required",e("result-dm-detail").className="text-xs text-amber-800 mt-1",e("result-dm-detail").textContent=`Quarterly end-user interstate+international revenue: $${d.toLocaleString("en-US",{maximumFractionDigits:0})} (exceeds $37,175 threshold). You must file Form 499-Q quarterly and make USF contributions.`);const v=e("result-lire-card");if(s>0){v.classList.remove("hidden");const f=o/(o+s);f<.12?(v.className="rounded-xl p-5 border bg-green-50 border-green-200",e("lire-icon").innerHTML=' ',e("result-lire-label").className="text-sm font-bold text-green-800",e("result-lire-label").textContent="LIRE Eligible — International Revenue Excluded",e("result-lire-detail").className="text-xs text-green-700 mt-1",e("result-lire-detail").textContent=`Interstate is ${(f*100).toFixed(1)}% of combined interstate+international (threshold: <12%). Your international revenue is excluded from USF contribution calculations.`):(v.className="rounded-xl p-5 border bg-gray-50 border-gray-200",e("lire-icon").innerHTML=' ',e("result-lire-label").className="text-sm font-bold text-gray-700",e("result-lire-label").textContent="Not LIRE Eligible",e("result-lire-detail").className="text-xs text-gray-600 mt-1",e("result-lire-detail").textContent=`Interstate is ${(f*100).toFixed(1)}% of combined (must be <12%). All revenues subject to USF calculations.`)}else v.classList.add("hidden");const b=e("result-filings");b.innerHTML="";const y=(f,C,S)=>{const g=document.createElement("div");g.className="flex items-center gap-2",g.innerHTML=C?`${f} ${S} `:`${f} ${S} `,b.appendChild(g)};y("Form 499-A (Annual)",!0,"— due April 1"),y("Form 499-Q (Quarterly)",!p,p?"— exempt (de minimis)":"— Feb 1, May 1, Aug 1, Nov 1"),y("Reseller Certificate",m==="reseller"||m==="both",m==="reseller"||m==="both"?"— annual":"— not applicable"),y("CPNI Annual Certification",u==="yes",u==="yes"?"— due March 1":"— interconnected VoIP only"),y("RMD Registration",!0,"— annual recertification March 1"),p?(e("result-tier-name").textContent="499-A Filing Only",e("result-tier-desc").textContent="De minimis filers only need the annual 499-A. No quarterly filing required.",e("result-tier-price").textContent="$499"):u==="yes"?(e("result-tier-name").textContent="Full Compliance Annual",e("result-tier-desc").textContent="Includes 499-A, quarterly 499-Q, CPNI certification, RMD recertification, and compliance calendar.",e("result-tier-price").textContent="$1,499/yr"):(e("result-tier-name").textContent="499-A + 499-Q Annual",e("result-tier-desc").textContent="Annual filing plus 4 quarterly filings for the year.",e("result-tier-price").textContent="$799")}const I=[{id:"303",label:"Local Exchange Service",cats:["clec","interconnected_voip"]},{id:"306",label:"Interstate Toll Service",cats:["ixc","interconnected_voip","clec","wireless","prepaid"]},{id:"307",label:"Intrastate Toll Service",cats:["ixc","interconnected_voip","clec","wireless","prepaid"]},{id:"308",label:"International Service",cats:["ixc","interconnected_voip","wireless","prepaid"]},{id:"309",label:"Interconnected VoIP (Interstate)",cats:["interconnected_voip"]},{id:"310",label:"Interconnected VoIP (Intrastate)",cats:["interconnected_voip"]},{id:"311",label:"Non-Interconnected VoIP",cats:["non_interconnected_voip","conferencing"]},{id:"312",label:"Payphone / Operator Services",cats:["other"]},{id:"314",label:"Other Telecom Revenue",cats:["other","satellite","conferencing","prepaid"]}];function $(){const a=[...document.querySelectorAll('input[name="svc_cat"]:checked')].map(t=>t.value),r=e("revenue-lines");r.innerHTML="";for(const t of I){if(!t.cats.some(o=>a.includes(o)))continue;const l=document.createElement("tr");l.innerHTML=`
Line ${t.id}: ${t.label}
`,r.appendChild(l)}r.querySelectorAll(".rev-input").forEach(t=>{t.addEventListener("input",E)})}function E(){let a=0,r=0;document.querySelectorAll('.rev-input[data-type="enduser"]').forEach(t=>a+=parseFloat(t.value)||0),document.querySelectorAll('.rev-input[data-type="wholesale"]').forEach(t=>r+=parseFloat(t.value)||0),e("rev-total-enduser").textContent=`$${a.toLocaleString()}`,e("rev-total-wholesale").textContent=`$${r.toLocaleString()}`}function q(){const a=e("review-summary");a.innerHTML="";const r=[{title:"Entity",items:[["Legal Name",n("entity_name").value],["EIN",n("ein").value],["FRN",n("frn").value||"New registration needed"],["Filer Type",e("result-filer-type").textContent||""]]},{title:"Classification",items:[["Filing Status",e("result-dm-label").textContent||""],["LIRE",e("result-lire-label")?.textContent||"N/A"]]},{title:"Contact",items:[["Name",n("contact_name").value],["Email",n("contact_email").value],["Phone",n("contact_phone").value]]}];for(const t of r){const l=document.createElement("div");l.className="bg-white border border-gray-200 rounded-xl p-4",l.innerHTML=`${t.title}
`+t.items.map(([o,s])=>`${o} ${s}
`).join(""),a.appendChild(l)}}async function N(){if(!k(7))return;const a=e("btn-next");a.disabled=!0,a.textContent="Submitting...";const r=window.__PW_API||"https://api.performancewest.net",t=e("submit-status");try{const l=parseFloat(n("total_revenue").value.replace(/[,$]/g,""))||0,o=[...document.querySelectorAll('input[name="svc_cat"]:checked')].map(v=>v.value),s=document.querySelector('input[name="pstn_connected"]:checked')?.value,i=document.querySelector('input[name="infra_type"]:checked')?.value,d={jurisdiction:"FCC",legal_name:n("entity_name").value.trim(),dba_name:n("dba_name").value.trim()||null,ein:n("ein").value.trim()||null,frn:n("frn").value.trim()||null,filer_id_499:n("filer_id").value.trim()||null,filer_type:s==="yes"?"interconnected_voip":"non_interconnected_voip",infra_type:i,is_deminimis:e("result-dm-label")?.textContent?.includes("De Minimis")||!1,is_lire:e("result-lire-label")?.textContent?.includes("LIRE Eligible")||!1,service_categories:o,contact_name:n("contact_name").value.trim(),contact_email:n("contact_email").value.trim(),contact_phone:n("contact_phone").value.trim(),ceo_name:n("ceo_name").value.trim(),ceo_title:n("ceo_title").value.trim(),address_street:n("address_street").value.trim(),address_city:n("address_city").value.trim(),address_state:n("address_state").value.trim(),address_zip:n("address_zip").value.trim(),total_revenue_cents:Math.round(l*100),interstate_pct:parseFloat(n("pct_interstate").value)||0,international_pct:parseFloat(n("pct_international").value)||0,customer_email:n("contact_email").value.trim()},x=(await(await fetch(`${r}/api/v1/entities/telecom`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)})).json())?.id,p=document.querySelector('input[name="service_tier"]:checked')?.value,h={"499a_only":"499-A Filing Only ($499)","499a_499q":"499-A + 499-Q Annual ($799)",full_compliance:"Full Compliance Annual ($1,499/yr)"};t.className="mt-4 rounded-lg p-4 text-sm bg-green-50 text-green-800 border border-green-200",t.classList.remove("hidden"),t.innerHTML=`
Order received — ${d.legal_name}
Service: ${h[p||"499a_499q"]}
${x?`Entity ID: ${x}
`:""}
We'll contact you within 1 business day to begin the filing process.
`,a.textContent="Submitted"}catch(l){t.className="mt-4 rounded-lg p-4 text-sm bg-red-50 text-red-800 border border-red-200",t.classList.remove("hidden"),t.textContent=l.message||"Something went wrong. Please try again or contact us.",a.disabled=!1,a.textContent="Submit Order"}}e("btn-import")?.addEventListener("click",async()=>{const a=n("import_filer_id").value.trim();if(!a){alert("Please enter your USAC 499 Filer ID.");return}const r=e("btn-import"),t=e("import-status");r.disabled=!0,r.textContent="Importing...",t.className="mt-2 text-xs text-blue-700",t.textContent="Connecting to USAC E-File... This may take up to 30 seconds.",t.classList.remove("hidden");try{const l=window.__PW_API||"https://api.performancewest.net",s=await(await fetch(`${l}/api/v1/fcc/import-499a`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filer_id:a})})).json();if(s.success&&s.entity){const i=s.entity;if(i.legal_name&&(n("entity_name").value=i.legal_name),i.ein&&(n("ein").value=i.ein),i.frn&&(n("frn").value=i.frn),i.filer_id&&(n("filer_id").value=i.filer_id),i.address&&(n("address_street").value=i.address),i.city&&(n("address_city").value=i.city),i.state&&(n("address_state").value=i.state),i.zip&&(n("address_zip").value=i.zip),i.contact_name&&(n("contact_name").value=i.contact_name),i.contact_email&&(n("contact_email").value=i.contact_email),i.contact_phone&&(n("contact_phone").value=i.contact_phone),s.service_categories)for(const d of s.service_categories){const u=document.querySelector(`input[name="svc_cat"][value="${d}"]`);u&&(u.checked=!0)}t.className="mt-2 text-xs text-green-700",t.textContent=`Imported ${s.filing_year||"prior year"} data for ${i.legal_name||a}. Review and update as needed.`}else s.manual_entry_required?(t.className="mt-2 text-xs text-amber-700",t.textContent="Import service is offline. Please enter your information manually below."):(t.className="mt-2 text-xs text-red-700",t.textContent=s.error||"Could not import data. Please enter manually.")}catch{t.className="mt-2 text-xs text-red-700",t.textContent="Connection failed. Please enter your information manually."}finally{r.disabled=!1,r.textContent="Import Data"}});["pct_interstate","pct_international","pct_intrastate"].forEach(a=>{n(a)?.addEventListener("input",()=>{const r=(parseFloat(n("pct_interstate").value)||0)+(parseFloat(n("pct_international").value)||0)+(parseFloat(n("pct_intrastate").value)||0),t=e("pct-total");t&&(t.textContent=`Total: ${r}%`,t.className=r===100?"text-xs text-green-600 mt-1":"text-xs text-red-600 mt-1")})});