new-site/site/public/_astro/hoisted.BnJ-ljAn.js
justin f8cd37ac8c Initial commit — Performance West telecom compliance platform
Includes: API (Express/TypeScript), Astro site, Python workers,
document generators, FCC compliance tools, Canada CRTC formation,
Ansible infrastructure, and deployment scripts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-27 06:54:22 -05:00

48 lines
27 KiB
JavaScript

import"./hoisted.yFz1BYXO.js";const O=[{code:"AL",name:"Alabama",llcFee:23600,corpFee:23600,annualFee:5e3,expeditedFee:1e4,expeditedLabel:"24-hour"},{code:"AK",name:"Alaska",llcFee:25e3,corpFee:25e3,annualFee:5e3,expeditedFee:1e4,expeditedLabel:"Expedited"},{code:"AZ",name:"Arizona",llcFee:5e3,corpFee:6e3,annualFee:0,expeditedFee:3500,expeditedLabel:"Expedited"},{code:"AR",name:"Arkansas",llcFee:4500,corpFee:4500,annualFee:15e3,expeditedFee:2500,expeditedLabel:"Expedited"},{code:"CA",name:"California",llcFee:7e3,corpFee:1e4,annualFee:81e3,expeditedFee:35e3,expeditedLabel:"24-hour"},{code:"CO",name:"Colorado",llcFee:5e3,corpFee:5e3,annualFee:2500,expeditedFee:0,expeditedLabel:""},{code:"CT",name:"Connecticut",llcFee:12e3,corpFee:25e3,annualFee:8e3,expeditedFee:5e3,expeditedLabel:"24-hour"},{code:"DE",name:"Delaware",llcFee:9e3,corpFee:8900,annualFee:3e4,expeditedFee:1e4,expeditedLabel:"24-hour"},{code:"DC",name:"District of Columbia",llcFee:9900,corpFee:22e3,annualFee:15e3,expeditedFee:1e4,expeditedLabel:"Expedited"},{code:"FL",name:"Florida",llcFee:12500,corpFee:7e3,annualFee:13875,expeditedFee:5e3,expeditedLabel:"1-2 day"},{code:"GA",name:"Georgia",llcFee:1e4,corpFee:1e4,annualFee:6e3,expeditedFee:1e4,expeditedLabel:"Same day"},{code:"HI",name:"Hawaii",llcFee:5e3,corpFee:5e3,annualFee:3500,expeditedFee:2500,expeditedLabel:"Expedited"},{code:"ID",name:"Idaho",llcFee:1e4,corpFee:1e4,annualFee:0,expeditedFee:2e3,expeditedLabel:"Expedited"},{code:"IL",name:"Illinois",llcFee:15e3,corpFee:17500,annualFee:7500,expeditedFee:1e4,expeditedLabel:"24-hour"},{code:"IN",name:"Indiana",llcFee:9500,corpFee:9500,annualFee:1500,expeditedFee:0,expeditedLabel:""},{code:"IA",name:"Iowa",llcFee:5e3,corpFee:5e3,annualFee:1500,expeditedFee:2500,expeditedLabel:"Expedited"},{code:"KS",name:"Kansas",llcFee:16e3,corpFee:9e3,annualFee:5e3,expeditedFee:0,expeditedLabel:""},{code:"KY",name:"Kentucky",llcFee:4e3,corpFee:5e3,annualFee:1500,expeditedFee:1e3,expeditedLabel:"2-day"},{code:"LA",name:"Louisiana",llcFee:1e4,corpFee:7500,annualFee:3500,expeditedFee:5e3,expeditedLabel:"24-hour"},{code:"ME",name:"Maine",llcFee:17500,corpFee:14500,annualFee:8500,expeditedFee:5e3,expeditedLabel:"24-hour"},{code:"MD",name:"Maryland",llcFee:1e4,corpFee:12e3,annualFee:3e4,expeditedFee:5e3,expeditedLabel:"Same day"},{code:"MA",name:"Massachusetts",llcFee:5e4,corpFee:27500,annualFee:5e4,expeditedFee:5500,expeditedLabel:"24-hour"},{code:"MI",name:"Michigan",llcFee:5e3,corpFee:6e3,annualFee:2500,expeditedFee:5e3,expeditedLabel:"24-hour"},{code:"MN",name:"Minnesota",llcFee:15500,corpFee:16e3,annualFee:0,expeditedFee:0,expeditedLabel:""},{code:"MS",name:"Mississippi",llcFee:5e3,corpFee:5e3,annualFee:0,expeditedFee:5e3,expeditedLabel:"24-hour"},{code:"MO",name:"Missouri",llcFee:5e3,corpFee:5800,annualFee:0,expeditedFee:0,expeditedLabel:""},{code:"MT",name:"Montana",llcFee:7e3,corpFee:7e3,annualFee:2e3,expeditedFee:2e3,expeditedLabel:"1-day"},{code:"NE",name:"Nebraska",llcFee:10500,corpFee:6500,annualFee:650,expeditedFee:5e3,expeditedLabel:"Expedited"},{code:"NV",name:"Nevada",llcFee:42500,corpFee:72500,annualFee:35e3,expeditedFee:12500,expeditedLabel:"24-hour"},{code:"NH",name:"New Hampshire",llcFee:1e4,corpFee:1e4,annualFee:1e4,expeditedFee:2500,expeditedLabel:"Expedited"},{code:"NJ",name:"New Jersey",llcFee:12500,corpFee:12500,annualFee:7500,expeditedFee:5e3,expeditedLabel:"Expedited"},{code:"NM",name:"New Mexico",llcFee:5e3,corpFee:1e4,annualFee:0,expeditedFee:1e4,expeditedLabel:"24-hour"},{code:"NY",name:"New York",llcFee:2e4,corpFee:12500,annualFee:450,expeditedFee:2500,expeditedLabel:"24-hour"},{code:"NC",name:"North Carolina",llcFee:12500,corpFee:12500,annualFee:2e4,expeditedFee:1e4,expeditedLabel:"Same day"},{code:"ND",name:"North Dakota",llcFee:13500,corpFee:1e4,annualFee:5e3,expeditedFee:0,expeditedLabel:""},{code:"OH",name:"Ohio",llcFee:9900,corpFee:9900,annualFee:0,expeditedFee:1e4,expeditedLabel:"Expedited"},{code:"OK",name:"Oklahoma",llcFee:1e4,corpFee:5e3,annualFee:2500,expeditedFee:2500,expeditedLabel:"Expedited"},{code:"OR",name:"Oregon",llcFee:1e4,corpFee:1e4,annualFee:1e4,expeditedFee:5e3,expeditedLabel:"Same day"},{code:"PA",name:"Pennsylvania",llcFee:12500,corpFee:12500,annualFee:700,expeditedFee:1e4,expeditedLabel:"Same day"},{code:"RI",name:"Rhode Island",llcFee:15e3,corpFee:23e3,annualFee:5e3,expeditedFee:0,expeditedLabel:""},{code:"SC",name:"South Carolina",llcFee:11e3,corpFee:13500,annualFee:0,expeditedFee:0,expeditedLabel:""},{code:"SD",name:"South Dakota",llcFee:15e3,corpFee:15e3,annualFee:5500,expeditedFee:5e3,expeditedLabel:"Expedited"},{code:"TN",name:"Tennessee",llcFee:3e4,corpFee:1e4,annualFee:3e4,expeditedFee:0,expeditedLabel:""},{code:"TX",name:"Texas",llcFee:3e4,corpFee:3e4,annualFee:0,expeditedFee:2500,expeditedLabel:"Expedited"},{code:"UT",name:"Utah",llcFee:5400,corpFee:7e3,annualFee:1800,expeditedFee:7500,expeditedLabel:"1-day"},{code:"VT",name:"Vermont",llcFee:12500,corpFee:12500,annualFee:4500,expeditedFee:0,expeditedLabel:""},{code:"VA",name:"Virginia",llcFee:1e4,corpFee:7500,annualFee:5e3,expeditedFee:2e4,expeditedLabel:"Same day"},{code:"WA",name:"Washington",llcFee:18e3,corpFee:18e3,annualFee:6e3,expeditedFee:5e3,expeditedLabel:"Expedited"},{code:"WV",name:"West Virginia",llcFee:1e4,corpFee:5e3,annualFee:2500,expeditedFee:0,expeditedLabel:""},{code:"WI",name:"Wisconsin",llcFee:13e3,corpFee:1e4,annualFee:2500,expeditedFee:2500,expeditedLabel:"Expedited"},{code:"WY",name:"Wyoming",llcFee:1e4,corpFee:1e4,annualFee:6e3,expeditedFee:0,expeditedLabel:""}],B=17900,V=39900;let L=B;const R=9900,H=4900,D=4900,j=9900;let g=null;function F(t){return"$"+(t/100).toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:0})}function s(t){return document.getElementById(t)}function i(t){return document.getElementById(t)}function f(t){return document.getElementById(t)}let _=1;const E=5;function k(){const t=f("state_code").value;return O.find(a=>a.code===t)||null}function $(){return document.querySelector('input[name="entity_type"]:checked')?.value||"llc"}function M(){return $()==="llc"}function N(){const t=k();return t?$()==="llc"?t.llcFee:t.corpFee:0}function P(){const t=[f("state_code"),f("principal_state"),f("mailing_state")];for(const a of t){if(!a)continue;const r=a.id==="state_code";for(;a.options.length>1;)a.remove(1);for(const l of O){const e=document.createElement("option");if(e.value=l.code,r){const n=l.annualFee>0?` · renewal ${F(l.annualFee)}/yr`:" · no annual fee";e.textContent=`${l.name} — LLC ${F(l.llcFee)} / Corp ${F(l.corpFee)}${n}`}else e.textContent=l.name;a.appendChild(e)}}}function I(t){for(let l=1;l<=E;l++){const e=s(`step-${l}`);e&&e.classList.toggle("hidden",l!==t)}s("step-success")?.classList.add("hidden"),document.querySelectorAll("#progress li").forEach(l=>{const e=parseInt(l.dataset.step||"0"),n=l.querySelector(".step-dot"),d=l.querySelector("p"),o=l.querySelector(".step-line");e<t?(n.className="step-dot flex items-center justify-center w-8 h-8 rounded-full border-2 border-pw-600 bg-pw-600 text-white text-xs font-bold shrink-0",n.innerHTML='<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="3"><path stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"/></svg>',d&&(d.className="mt-1.5 text-xs font-medium text-pw-700 hidden sm:block"),o&&(o.className="step-line hidden sm:block flex-1 h-0.5 bg-pw-600 mx-2")):e===t?(n.className="step-dot flex items-center justify-center w-8 h-8 rounded-full border-2 border-pw-600 bg-pw-600 text-white text-xs font-bold shrink-0",n.textContent=String(e),d&&(d.className="mt-1.5 text-xs font-medium text-pw-700 hidden sm:block"),o&&(o.className="step-line hidden sm:block flex-1 h-0.5 bg-gray-200 mx-2")):(n.className="step-dot flex items-center justify-center w-8 h-8 rounded-full border-2 border-gray-300 bg-white text-gray-400 text-xs font-bold shrink-0",n.textContent=String(e),d&&(d.className="mt-1.5 text-xs font-medium text-gray-400 hidden sm:block"),o&&(o.className="step-line hidden sm:block flex-1 h-0.5 bg-gray-200 mx-2"))});const a=s("btn-back"),r=s("btn-next");a.classList.toggle("invisible",t===1),t===E?r.innerHTML='Submit Order <svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"/></svg>':r.innerHTML='Next <svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M13.5 4.5L21 12m0 0l-7.5 7.5M21 12H3"/></svg>',_=t,window.scrollTo({top:0,behavior:"smooth"})}function Y(t){for(let r=1;r<=E;r++)s(`step-${r}`)?.classList.add("hidden");s("step-success")?.classList.remove("hidden"),s("form-nav")?.classList.add("hidden"),s("progress")?.classList.add("hidden");const a=s("success-order-number");a&&(a.textContent=t)}function K(t){if(t===1)return f("state_code").value?!0:(alert("Please select a state."),f("state_code").focus(),!1);if(t===2)return i("entity_name").value.trim()?i("principal_address").value.trim()?i("principal_city").value.trim()?f("principal_state").value?i("principal_zip").value.trim()?!0:(alert("Please enter the ZIP code."),i("principal_zip").focus(),!1):(alert("Please select the state."),f("principal_state").focus(),!1):(alert("Please enter the city."),i("principal_city").focus(),!1):(alert("Please enter the principal business address."),i("principal_address").focus(),!1):(alert("Please enter an entity name."),i("entity_name").focus(),!1);if(t===3){const a=W();if(a.length===0)return s("members-error")?.classList.remove("hidden"),!1;s("members-error")?.classList.add("hidden");for(let r=0;r<a.length;r++)if(!a[r].name.trim())return alert(`Please enter a name for member ${r+1}.`),!1;return!0}if(t===4)return!0;if(t===5){if(!i("customer_name").value.trim())return alert("Please enter your name."),i("customer_name").focus(),!1;const a=i("customer_email").value.trim();return!a||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a)?(alert("Please enter a valid email address."),i("customer_email").focus(),!1):i("consent").checked?!0:(alert("Please agree to the Terms of Service and Privacy Policy."),!1)}return!0}let T=0;function J(){return["Member","Manager","Organizer"]}function Z(){return["Director","Officer","Incorporator"]}function U(){T++;const t=T,a=M(),r=a?J():Z(),l=`
<div class="member-card rounded-lg border border-gray-200 p-4" data-member="${t}">
<div class="flex items-center justify-between mb-3">
<h4 class="text-sm font-semibold text-gray-900">${a?"Member":"Officer"} #${t}</h4>
<button type="button" class="remove-member text-xs text-red-500 hover:text-red-700 transition-colors" data-member="${t}">Remove</button>
</div>
<div class="space-y-3">
<div class="grid sm:grid-cols-2 gap-3">
<div>
<label class="block text-xs font-medium text-gray-600 mb-1">Full Name <span class="text-red-500">*</span></label>
<input type="text" class="member-name w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-pw-500 focus:border-pw-500 transition-colors" placeholder="Full name" />
</div>
<div>
<label class="block text-xs font-medium text-gray-600 mb-1">Title</label>
<select class="member-title w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 focus:outline-none focus:ring-2 focus:ring-pw-500 focus:border-pw-500 transition-colors bg-white">
${r.map(n=>`<option value="${n}">${n}</option>`).join("")}
</select>
</div>
</div>
<div>
<label class="block text-xs font-medium text-gray-600 mb-1">Street Address</label>
<input type="text" class="member-address w-full rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-pw-500 focus:border-pw-500 transition-colors" placeholder="Street address" />
</div>
<div class="grid grid-cols-5 gap-3">
<input type="text" class="member-city col-span-2 rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-pw-500 focus:border-pw-500 transition-colors" placeholder="City" />
<input type="text" class="member-state col-span-2 rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-pw-500 focus:border-pw-500 transition-colors" placeholder="State" maxlength="2" />
<input type="text" class="member-zip col-span-1 rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-pw-500 focus:border-pw-500 transition-colors" placeholder="ZIP" maxlength="10" />
</div>
${a?`<div>
<label class="block text-xs font-medium text-gray-600 mb-1">Ownership %</label>
<input type="number" class="member-ownership w-32 rounded-lg border border-gray-300 px-3 py-2 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-pw-500 focus:border-pw-500 transition-colors" placeholder="e.g. 50" min="0" max="100" />
</div>`:""}
</div>
</div>
`,e=s("members-list");if(e){e.insertAdjacentHTML("beforeend",l);const n=e.querySelector(`[data-member="${t}"]`);n?.querySelector(".remove-member")?.addEventListener("click",()=>{n.remove()})}}function W(){const t=document.querySelectorAll(".member-card"),a=[];return t.forEach(r=>{a.push({name:r.querySelector(".member-name")?.value||"",title:r.querySelector(".member-title")?.value||"",address:r.querySelector(".member-address")?.value||"",city:r.querySelector(".member-city")?.value||"",state:r.querySelector(".member-state")?.value||"",zip:r.querySelector(".member-zip")?.value||"",ownership:r.querySelector(".member-ownership")?.value||""})}),a}function G(){const t=N(),a=s("estimate-box");if(t>0&&a){a.classList.remove("hidden");const r=t+L,l=s("estimate-total");l&&(l.textContent=F(r));const e=s("estimate-state-fee");e&&(e.textContent=F(t));const n=s("estimate-service-fee");n&&(n.textContent=F(L))}else a&&a.classList.add("hidden")}function C(){const t=k(),a=N(),r=i("addon_ra").checked,l=i("addon_ein").checked,e=i("addon_oa").checked,n=i("addon_expedited").checked,d=t?t.expeditedFee:0,o=z=>s(z),x=o("summary-state-name");x&&(x.textContent=t?t.name:"--");const c=o("summary-state-fee");c&&(c.textContent=F(a));const u=o("summary-service-fee");u&&(g?u.innerHTML=`<s class="text-gray-400">${F(L)}</s> <span class="text-green-700">${F(L-g.cents)}</span>`:u.textContent=F(L));const p=o("estimate-service-fee");p&&(p.textContent=F(L));const b=o("summary-discount-row"),v=o("summary-discount-code"),y=o("summary-discount-amount");g?(b?.classList.remove("hidden"),v&&(v.textContent=g.code),y&&(y.textContent=`-${F(g.cents)}`)):b?.classList.add("hidden"),o("summary-ra-row")?.classList.toggle("hidden",!r),o("summary-ein-row")?.classList.toggle("hidden",!l),o("summary-oa-row")?.classList.toggle("hidden",!e),o("summary-exp-row")?.classList.toggle("hidden",!n);const m=o("summary-exp-fee");m&&(m.textContent=F(d));const w=t?.code==="WY"?H:R;let h=a+L;g&&(h-=g.cents),r&&(h+=w),l&&(h+=D),e&&(h+=j),n&&(h+=d),h<0&&(h=0);const A=o("summary-total");A&&(A.textContent=F(h))}function S(){const t=M(),a=s("management-type-group");a&&a.classList.toggle("hidden",!t);const r=s("addon_oa_row");r&&r.classList.toggle("hidden",!t),t||(i("addon_oa").checked=!1);const l=k(),e=s("addon_exp_row");if(l&&l.expeditedFee>0){e&&e.classList.remove("hidden");const n=s("expedited-price");n&&(n.textContent=F(l.expeditedFee));const d=s("expedited-label");d&&l.expeditedLabel&&(d.textContent=`${l.expeditedLabel} processing with the state.`)}else e&&e.classList.add("hidden"),i("addon_expedited").checked=!1;G(),C()}async function q(){const t=i("name_search"),a=t.value.trim(),r=k(),l=s("name-search-result"),e=s("name-search-btn");if(!a||a.length<2){alert("Please enter at least 2 characters."),t.focus();return}if(!r){alert("Please select a state first."),f("state_code").focus();return}e.disabled=!0,e.textContent="Checking...",l&&(l.classList.remove("hidden"),l.innerHTML='<p class="text-sm text-gray-500">Searching...</p>');try{const d=await(await fetch(`${window.__PW_API||"https://api.performancewest.net"}/api/v1/states/${r.code}/name-search?name=${encodeURIComponent(a)}`)).json();if(l)if(d.available===!0)l.innerHTML=`
<div class="flex items-center gap-2 text-green-700">
<svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
<span class="text-sm font-medium">"${d.name}" appears to be available in ${r.name}.</span>
</div>`;else if(d.available===!1){let o=`
<div class="flex items-center gap-2 text-red-700">
<svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M9.75 9.75l4.5 4.5m0-4.5l-4.5 4.5M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
<span class="text-sm font-medium">"${d.name}" is not available in ${r.name}.</span>
</div>`;if(d.similar_names&&d.similar_names.length>0){o+='<p class="text-xs text-gray-500 mt-2">Similar names on file:</p><ul class="text-xs text-gray-600 mt-1 ml-5 list-disc">';for(const x of d.similar_names)o+=`<li>${x}</li>`;o+="</ul>"}l.innerHTML=o}else l.innerHTML=`
<div class="flex items-center gap-2 text-amber-700">
<svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"/></svg>
<span class="text-sm font-medium">${d.message||"Name search is being processed."}</span>
</div>
<p class="text-xs text-gray-500 mt-1">You can proceed with your order. We'll verify name availability during processing.</p>`}catch{l&&(l.innerHTML=`<p class="text-sm text-red-600">Could not check name availability. You can proceed and we'll verify during processing.</p>`)}finally{e.disabled=!1,e.textContent="Check"}}async function Q(){const t=s("btn-next"),a=s("submit-status");t.disabled=!0,t.innerHTML="Submitting...",a&&(a.classList.remove("hidden"),a.className="mt-5 rounded-lg p-4 text-sm bg-gray-50 text-gray-600 border border-gray-200",a.textContent="Placing your order...");const r=k(),l=N(),e=i("addon_ra").checked,n=i("addon_ein").checked,d=i("addon_oa").checked,o=i("addon_expedited").checked,x=r&&o?r.expeditedFee:0,c=g?g.cents:0,u=r?.code==="WY"?H:R;let p=l+L-c;e&&(p+=u),n&&(p+=D),d&&(p+=j),o&&(p+=x),p<0&&(p=0);const b=i("mailing_same").checked,y=document.querySelector('input[name="tier"]:checked')?.value==="complete"?"complete":"basic",m={customer_name:i("customer_name").value.trim(),customer_email:i("customer_email").value.trim(),customer_phone:i("customer_phone").value.trim()||null,customer_company:i("customer_company").value.trim()||null,state_code:r?.code||"",entity_type:$(),entity_name:i("entity_name").value.trim(),entity_name_alt:i("entity_name_alt").value.trim()||null,management_type:M()?f("management_type").value:null,purpose:i("purpose").value.trim()||"Any lawful business activity",principal_address:i("principal_address").value.trim(),principal_city:i("principal_city").value.trim(),principal_state:f("principal_state").value,principal_zip:i("principal_zip").value.trim(),mailing_address:b?null:i("mailing_address").value.trim()||null,mailing_city:b?null:i("mailing_city").value.trim()||null,mailing_state:b?null:f("mailing_state").value||null,mailing_zip:b?null:i("mailing_zip").value.trim()||null,members:W(),include_ra_service:e,include_ein:n,include_operating_agreement:d,expedited:o,state_fee_cents:l,service_fee_cents:L-c,expedited_fee_cents:x,total_cents:p,discount_code:g?g.code:null,tier:y};try{const w=await fetch((window.__PW_API||"https://api.performancewest.net")+"/api/v1/formations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)}),h=await w.json();if(w.ok&&h.success)Y(h.order_number);else throw new Error(h.error||"Unknown error")}catch(w){a&&(a.className="mt-5 rounded-lg p-4 text-sm bg-red-50 text-red-800 border border-red-200",a.textContent=w.message||"Something went wrong. Please try again or contact us."),t.disabled=!1,t.innerHTML='Submit Order <svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"/></svg>'}}document.addEventListener("DOMContentLoaded",()=>{P(),U();let t=[{code:"BC",name:"British Columbia",feeCad:35e3,feeUsd:28200,annualCad:4200,annualUsd:3400},{code:"AB",name:"Alberta",feeCad:27500,feeUsd:22100,annualCad:2e3,annualUsd:1600},{code:"ON",name:"Ontario",feeCad:36e3,feeUsd:29e3,annualCad:0,annualUsd:0},{code:"QC",name:"Quebec",feeCad:37900,feeUsd:30500,annualCad:8800,annualUsd:7100},{code:"MB",name:"Manitoba",feeCad:35e3,feeUsd:28200,annualCad:0,annualUsd:0},{code:"SK",name:"Saskatchewan",feeCad:26600,feeUsd:21400,annualCad:0,annualUsd:0},{code:"NS",name:"Nova Scotia",feeCad:42682,feeUsd:34400,annualCad:11400,annualUsd:9200},{code:"NB",name:"New Brunswick",feeCad:26200,feeUsd:21100,annualCad:6700,annualUsd:5400},{code:"PE",name:"Prince Edward Island",feeCad:31e3,feeUsd:25e3,annualCad:0,annualUsd:0},{code:"NL",name:"Newfoundland and Labrador",feeCad:3e4,feeUsd:24200,annualCad:2500,annualUsd:2100}];fetch(window.__PW_API?window.__PW_API+"/api/v1/fx/ca-provinces":"https://api.performancewest.net/api/v1/fx/ca-provinces").then(e=>e.json()).then(e=>{e.provinces&&(t=e.provinces,f("country").value==="CA"&&populateCanadaProvinces())}).catch(()=>{}),f("country").addEventListener("change",()=>{const e=f("country").value,n=s("canada-telecom-callout"),d=s("state-select-wrapper"),o=s("state-label");f("state_code");function x(){const c=f("state_code");for(;c.options.length>1;)c.remove(1);for(const u of t){const p=document.createElement("option");p.value=u.code;const b=`C$${(u.feeCad/100).toFixed(0)}`,v=`US$${(u.feeUsd/100).toFixed(0)}`,y=u.annualUsd>0?` · renewal C$${(u.annualCad/100).toFixed(0)} / US$${(u.annualUsd/100).toFixed(0)}/yr`:" · no annual fee";p.textContent=`${u.name}${b} (${v})${y}`,c.appendChild(p)}}if(e==="CA"){n?.classList.remove("hidden"),d?.classList.remove("hidden"),o&&(o.innerHTML='Province <span class="text-red-500">*</span>'),x();const c=s("entity-label-1"),u=s("entity-sub-1"),p=s("entity-label-2"),b=s("entity-sub-2"),v=s("entity-label-3"),y=s("entity-sub-3");c&&(c.textContent="Ltd."),u&&(u.textContent="Limited Company"),p&&(p.textContent="Inc."),b&&(b.textContent="Incorporated"),v&&(v.textContent="Corp."),y&&(y.textContent="Corporation");const m=document.querySelectorAll('input[name="entity_type"]');m[0]&&(m[0].value="ltd"),m[1]&&(m[1].value="inc"),m[2]&&(m[2].value="corp")}else{n?.classList.add("hidden"),d?.classList.remove("hidden"),o&&(o.innerHTML='Formation State <span class="text-red-500">*</span>'),P();const c=s("entity-label-1"),u=s("entity-sub-1"),p=s("entity-label-2"),b=s("entity-sub-2"),v=s("entity-label-3"),y=s("entity-sub-3");c&&(c.textContent="LLC"),u&&(u.textContent="Limited Liability Co."),p&&(p.textContent="Corporation"),b&&(b.textContent="C-Corp"),v&&(v.textContent="S-Corp"),y&&(y.textContent="S-Corp Election");const m=document.querySelectorAll('input[name="entity_type"]');m[0]&&(m[0].value="llc"),m[1]&&(m[1].value="corporation"),m[2]&&(m[2].value="s_corp")}}),f("state_code").addEventListener("change",()=>{S()}),document.querySelectorAll('input[name="entity_type"]').forEach(e=>{e.addEventListener("change",()=>{S(),document.querySelectorAll(".entity-radio").forEach(n=>{const d=n.querySelector("input");n.classList.toggle("border-pw-500",d.checked),n.classList.toggle("bg-pw-50",d.checked),n.classList.toggle("border-gray-200",!d.checked)})})}),document.querySelectorAll(".entity-radio").forEach(e=>{const n=e.querySelector("input");e.classList.toggle("border-pw-500",n.checked),e.classList.toggle("bg-pw-50",n.checked)}),i("mailing_same").addEventListener("change",()=>{s("mailing-fields")?.classList.toggle("hidden",i("mailing_same").checked)}),s("name-search-btn")?.addEventListener("click",q),i("name_search").addEventListener("keydown",e=>{e.key==="Enter"&&(e.preventDefault(),q())}),s("add-member-btn")?.addEventListener("click",()=>U()),["addon_ra","addon_ein","addon_oa","addon_expedited"].forEach(e=>{s(e)?.addEventListener("change",C)}),s("btn-next")?.addEventListener("click",()=>{if(K(_)){if(_===1){const e=i("name_search").value.trim(),n=i("entity_name");e&&!n.value.trim()&&(n.value=e)}if(_===3&&(S(),C()),_===E){Q();return}I(_+1)}}),s("btn-back")?.addEventListener("click",()=>{_>1&&I(_-1)});async function a(e){if(!e||e.trim().length<2)return;e=e.toUpperCase().trim();const n=s("discount-status"),d=i("discount_code"),o=s("btn-apply-discount");o&&(o.disabled=!0,o.textContent="Checking..."),n&&(n.classList.remove("hidden"),n.className="mt-2 text-xs text-gray-500",n.textContent="Validating code...");try{const x=await fetch(`${window.__PW_API||"https://api.performancewest.net"}/api/v1/discount/${encodeURIComponent(e)}?service=formation&amount=${L}`),c=await x.json();x.ok&&c.valid?(g={code:c.code,type:c.discount_type,value:c.discount_value,cents:c.discount_cents,description:c.description},d&&(d.value=c.code,d.disabled=!0,d.classList.add("bg-green-50","border-green-300")),o&&(o.textContent="Applied",o.classList.add("bg-green-100","text-green-700","border-green-300")),n&&(n.className="mt-2 text-xs text-green-700",n.textContent=`${c.description} applied.${c.referral_partner?` Referred by: ${c.referral_partner}`:""}`),C()):(g=null,n&&(n.className="mt-2 text-xs text-red-600",n.textContent=c.error||"Invalid discount code."),o&&(o.disabled=!1,o.textContent="Apply"),C())}catch{n&&(n.className="mt-2 text-xs text-gray-500",n.textContent="Could not verify code. You can proceed without it."),o&&(o.disabled=!1,o.textContent="Apply")}}s("btn-apply-discount")?.addEventListener("click",()=>{const e=i("discount_code").value.trim();e&&a(e)}),s("discount_code")?.addEventListener("keydown",e=>{if(e.key==="Enter"){e.preventDefault();const n=i("discount_code").value.trim();n&&a(n)}});const l=new URLSearchParams(window.location.search).get("code");if(l){const e=i("discount_code");e&&(e.value=l.toUpperCase()),a(l)}document.querySelectorAll('input[name="tier"]').forEach(e=>{e.addEventListener("change",n=>{const d=n.target.value;L=d==="complete"?V:B;const o=i("addon_ein"),x=i("addon_oa"),c=i("addon_ra");d==="complete"?(o.checked=!0,o.disabled=!0,x.checked=!0,x.disabled=!0,c.checked=!0,c.disabled=!0):(o.disabled=!1,x.disabled=!1,c.disabled=!1),document.getElementById("tier-basic-label")?.classList.toggle("border-pw-500",d==="basic"),document.getElementById("tier-basic-label")?.classList.toggle("bg-pw-50",d==="basic"),document.getElementById("tier-complete-label")?.classList.toggle("border-pw-500",d==="complete"),document.getElementById("tier-complete-label")?.classList.toggle("bg-pw-50",d==="complete"),C()})}),document.getElementById("tier-basic-label")?.classList.add("border-pw-500","bg-pw-50")});