"""Quote-application wizard views.
SOURCE NOTE. The public marketing capture could not enter the wizard, but a
headed browser handoff on 2026-08-26 reached `ua.apps.insureon.com` and directly
observed the step names, order, conditional workers' compensation step, and
the opening Company Information controls. The remaining detailed field copy
uses the local deterministic application model. Evidence-backed inputs include:
* the business-class taxonomy and its ids (first-party endpoint, HTTP 200),
* the product names, coverage descriptions and average premiums (captured
`/small-business-insurance/*` and `/small-business-insurance/*/cost`),
* the carrier names (captured home page),
* the site chrome, typography and palette (captured stylesheet).
Later step field sets and control shapes remain a bounded reconstruction; they
do not claim a pixel-level visual contract. See `KNOWN_DIFFERENCES.md` and
`scope/claims.jsonl`.
"""
from __future__ import annotations
from typing import Any, Mapping, Sequence
import render as R
from content import professions as P
STEPS: list[tuple[str, str]] = [
("company", "Company Information"),
("protection", "Protection Options"),
("contact", "Contact Information"),
("business", "Business Details"),
("locations", "Locations"),
("sales", "Sales & Operations"),
("workers", "Workers’ Compensation"),
("practices", "Business Operations & Practices"),
]
ENTITY_TYPES = [
("sole-proprietorship", "Sole proprietorship"),
("llc", "LLC"),
("s-corporation", "S corporation"),
("c-corporation", "C corporation"),
("partnership", "Partnership"),
("nonprofit", "Nonprofit"),
]
ENTITY_TYPE_LABELS = dict(ENTITY_TYPES)
YEARS_OPTIONS = [
("0", "Less than 1 year"),
("1", "1 year"),
("2", "2 years"),
("3", "3 years"),
("5", "5 years"),
("10", "10 or more years"),
]
US_STATES = [
("AL", "Alabama"), ("AK", "Alaska"), ("AZ", "Arizona"), ("AR", "Arkansas"),
("CA", "California"), ("CO", "Colorado"), ("CT", "Connecticut"),
("DE", "Delaware"), ("DC", "District of Columbia"), ("FL", "Florida"),
("GA", "Georgia"), ("HI", "Hawaii"), ("ID", "Idaho"), ("IL", "Illinois"),
("IN", "Indiana"), ("IA", "Iowa"), ("KS", "Kansas"), ("KY", "Kentucky"),
("LA", "Louisiana"), ("ME", "Maine"), ("MD", "Maryland"),
("MA", "Massachusetts"), ("MI", "Michigan"), ("MN", "Minnesota"),
("MS", "Mississippi"), ("MO", "Missouri"), ("MT", "Montana"),
("NE", "Nebraska"), ("NV", "Nevada"), ("NH", "New Hampshire"),
("NJ", "New Jersey"), ("NM", "New Mexico"), ("NY", "New York"),
("NC", "North Carolina"), ("ND", "North Dakota"), ("OH", "Ohio"),
("OK", "Oklahoma"), ("OR", "Oregon"), ("PA", "Pennsylvania"),
("RI", "Rhode Island"), ("SC", "South Carolina"), ("SD", "South Dakota"),
("TN", "Tennessee"), ("TX", "Texas"), ("UT", "Utah"), ("VT", "Vermont"),
("VA", "Virginia"), ("WA", "Washington"), ("WV", "West Virginia"),
("WI", "Wisconsin"), ("WY", "Wyoming"),
]
def _shell(inner: str, *, step: str, title: str, app: Mapping[str, Any] | None = None,
logged_in: bool = False, description: str = "",
steps: Sequence[tuple[str, str]] | None = None) -> str:
ref = ""
if app and app.get("reference"):
ref = (f'
'
f'Application {R.esc(app["reference"])}
')
visible_steps = list(steps or STEPS)
body = f"""
{R.stepper(visible_steps, step)}{ref}
{inner}
"""
return R.page(body, title=title, description=description, logged_in=logged_in)
# --------------------------------------------------------------------------- #
# step 1: business class
# --------------------------------------------------------------------------- #
def start_quote(query: str = "", product: str = "", error: str = "",
logged_in: bool = False) -> str:
"""T03 entry: the business-class picker that the source renders as a modal."""
from content import site as S
# The source filters the class list as the user types. Offline we render the
# whole captured taxonomy and filter it client-side, so typing behaves the
# same way with no request; `query` additionally narrows it server-side so
# the step still works without JavaScript and stays deep-linkable.
rows = P.search(query, limit=len(P.all_services()))
options = "".join(
f'
'
f'
'
for r in rows
)
empty = "" if rows else (
'
No business type matches '
f'“{R.esc(query)}”. Try a broader keyword.
')
inner = f"""
{R.esc(S.QUOTE_MODAL["heading"])}
{R.esc(S.QUOTE_MODAL["subheading"])}
{R.error_summary({"class": error} if error else {})}
{R.esc(S.QUOTE_MODAL["call_prompt"])}
"""
return _shell(inner, step="class",
title="Small Business Insurance Quotes | Insureon",
description="Get the right coverage from top insurance companies.",
logged_in=logged_in)
def source_steps(app: Mapping[str, Any]) -> list[tuple[str, str]]:
products = list(app.get("requested_products") or [])
return [row for row in STEPS if row[0] != "workers" or "workers-compensation" in products]
def company_information(app: Mapping[str, Any], errors: Mapping[str, str] | None = None,
logged_in: bool = False) -> str:
errors = errors or {}
inner = f"""
No quotes have been generated for this '
'application yet. Choose your coverage to continue.
')
else:
listing = ('
'
+ "".join(_quote_card(app["id"], q, q["id"] in selected_ids)
for q in options)
+ "
")
save = ""
if not logged_in:
save = ('
'
'Create an account to save these quotes and come '
'back to them later.
')
else:
save = f""""""
inner = f"""
Compare your quotes
{R.esc(app.get("business_name") or "Your business")} ·
{R.esc(app.get("profession_name", ""))} ·
{R.esc(app.get("city") or "")} {R.esc(app.get("state") or "")}
{R.esc(app.get("zip_code") or "")}
"""
return _shell(inner, step="quotes", title="Compare quotes | Insureon",
app=app, logged_in=logged_in)
def quote_detail(app: Mapping[str, Any], q: Mapping[str, Any],
product: Mapping[str, Any] | None, chosen: bool,
logged_in: bool = False) -> str:
"""T08: plan detail with limits, benefits, exclusions and policy terms."""
def _bullets(entries: Any) -> str:
rows = []
for e in entries or []:
if isinstance(e, Mapping):
t, b = e.get("title", ""), e.get("body", "")
else:
t, b = str(e), ""
rows.append(f"
{R.esc(t)}"
+ (f" {R.esc(b)}" if b else "") + "
")
return "".join(rows)
covers = _bullets((product or {}).get("covers"))
excl = _bullets((product or {}).get("not_covered"))
inner = f"""← Back to all quotes
{R.notice("Offline demonstration site. This is a local sandbox payment step: "
"no card is charged, no payment processor is contacted, and no card "
"number is stored. Enter any placeholder values.")}
{R.error_summary(errors)}