"""A minimal route profile — single core stroke.

The `@lpdk.route_profile` decorator turns a builder function into a
RouteProfile. Inside the body, call `p.layer(...)` once per continuous
stroke. The profile here defines just the silicon core — no claddings.
"""
import lumicron as lm
import lumicron_pdk as lpdk

LAYER = lpdk.LayerTable(
    SILC = lpdk.Layer(9, 0, color="#008000", min_width=0.2, min_radius=5.0),
)


@lpdk.route_profile(port_width=0.5, radius=10.0, radius_min=5.0)
def silc_strip(p):
    """0.5 µm silicon core — minimal viable strip waveguide."""
    p.layer(LAYER.SILC, width=p.port_width)


# Optional: collect every profile this PDK exposes into one namespace,
# the way end-users will reference them as `pdk.RP.silc_strip`.
RP = lpdk.RouteProfiles(silc_strip=silc_strip)


@lm.pcell
def BasicProfileDemo():
    """Demo: route between two ports using the profile we just defined."""
    c = lm.CELL("BasicProfileDemo")
    c.add(lm.PORT(
        "in", position=(0, 0), direction=0,
        route_profile=silc_strip,
    ))
    c.add(lm.PORT(
        "out", position=(400, 200), direction=180,
        route_profile=silc_strip,
    ))
    c.Route(c.ports["in"], c.ports["out"])
    return c


if __name__ == "__main__":
    BasicProfileDemo().to_gds("basic_profile_demo.gds")
