"""Delivery permission definitions — Phase 10.0–10.8."""
from __future__ import annotations

DELIVERY_VIEW = "delivery.view"
DELIVERY_MANAGE = "delivery.manage"

ORGANIZATIONS_VIEW = "delivery.organizations.view"
ORGANIZATIONS_CREATE = "delivery.organizations.create"
ORGANIZATIONS_UPDATE = "delivery.organizations.update"
ORGANIZATIONS_DELETE = "delivery.organizations.delete"
ORGANIZATIONS_MANAGE = "delivery.organizations.manage"

HUBS_VIEW = "delivery.hubs.view"
HUBS_CREATE = "delivery.hubs.create"
HUBS_UPDATE = "delivery.hubs.update"
HUBS_DELETE = "delivery.hubs.delete"
HUBS_MANAGE = "delivery.hubs.manage"

EXTERNAL_PROVIDERS_VIEW = "delivery.external_providers.view"
EXTERNAL_PROVIDERS_CREATE = "delivery.external_providers.create"
EXTERNAL_PROVIDERS_UPDATE = "delivery.external_providers.update"
EXTERNAL_PROVIDERS_DELETE = "delivery.external_providers.delete"
EXTERNAL_PROVIDERS_MANAGE = "delivery.external_providers.manage"

ROUTING_ENGINES_VIEW = "delivery.routing_engines.view"
ROUTING_ENGINES_CREATE = "delivery.routing_engines.create"
ROUTING_ENGINES_UPDATE = "delivery.routing_engines.update"
ROUTING_ENGINES_DELETE = "delivery.routing_engines.delete"
ROUTING_ENGINES_MANAGE = "delivery.routing_engines.manage"

CONFIGURATIONS_VIEW = "delivery.configurations.view"
CONFIGURATIONS_CREATE = "delivery.configurations.create"
CONFIGURATIONS_UPDATE = "delivery.configurations.update"
CONFIGURATIONS_DELETE = "delivery.configurations.delete"
CONFIGURATIONS_MANAGE = "delivery.configurations.manage"

SETTINGS_VIEW = "delivery.settings.view"
SETTINGS_MANAGE = "delivery.settings.manage"

AUDIT_VIEW = "delivery.audit.view"

# Phase 10.1 — Driver Management
DRIVERS_VIEW = "delivery.drivers.view"
DRIVERS_CREATE = "delivery.drivers.create"
DRIVERS_UPDATE = "delivery.drivers.update"
DRIVERS_DELETE = "delivery.drivers.delete"
DRIVERS_ACTIVATE = "delivery.drivers.activate"
DRIVERS_SUSPEND = "delivery.drivers.suspend"
DRIVERS_RESUME = "delivery.drivers.resume"
DRIVERS_DEACTIVATE = "delivery.drivers.deactivate"
DRIVERS_BLOCK = "delivery.drivers.block"
DRIVERS_UNBLOCK = "delivery.drivers.unblock"
DRIVERS_ARCHIVE = "delivery.drivers.archive"
DRIVERS_LIFECYCLE_VIEW = "delivery.drivers.lifecycle.view"
DRIVERS_CREDENTIALS_VIEW = "delivery.drivers.credentials.view"
DRIVERS_CREDENTIALS_MANAGE = "delivery.drivers.credentials.manage"
DRIVERS_DOCUMENTS_VIEW = "delivery.drivers.documents.view"
DRIVERS_DOCUMENTS_MANAGE = "delivery.drivers.documents.manage"
DRIVERS_MANAGE = "delivery.drivers.manage"

# Phase 10.2 — Fleet & Vehicles
FLEETS_VIEW = "delivery.fleets.view"
FLEETS_CREATE = "delivery.fleets.create"
FLEETS_UPDATE = "delivery.fleets.update"
FLEETS_DELETE = "delivery.fleets.delete"
FLEETS_MANAGE = "delivery.fleets.manage"

VEHICLE_TYPES_VIEW = "delivery.vehicle_types.view"
VEHICLE_TYPES_CREATE = "delivery.vehicle_types.create"
VEHICLE_TYPES_UPDATE = "delivery.vehicle_types.update"
VEHICLE_TYPES_DELETE = "delivery.vehicle_types.delete"
VEHICLE_TYPES_MANAGE = "delivery.vehicle_types.manage"

VEHICLES_VIEW = "delivery.vehicles.view"
VEHICLES_CREATE = "delivery.vehicles.create"
VEHICLES_UPDATE = "delivery.vehicles.update"
VEHICLES_DELETE = "delivery.vehicles.delete"
VEHICLES_ASSIGNMENTS_VIEW = "delivery.vehicles.assignments.view"
VEHICLES_ASSIGNMENTS_MANAGE = "delivery.vehicles.assignments.manage"
VEHICLES_MANAGE = "delivery.vehicles.manage"

# Phase 10.3 — Availability, Shifts & Working Zones
AVAILABILITY_VIEW = "delivery.availability.view"
AVAILABILITY_MANAGE = "delivery.availability.manage"

SHIFTS_VIEW = "delivery.shifts.view"
SHIFTS_CREATE = "delivery.shifts.create"
SHIFTS_UPDATE = "delivery.shifts.update"
SHIFTS_DELETE = "delivery.shifts.delete"
SHIFTS_ASSIGNMENTS_VIEW = "delivery.shifts.assignments.view"
SHIFTS_ASSIGNMENTS_MANAGE = "delivery.shifts.assignments.manage"
SHIFTS_MANAGE = "delivery.shifts.manage"

WORKING_ZONES_VIEW = "delivery.working_zones.view"
WORKING_ZONES_CREATE = "delivery.working_zones.create"
WORKING_ZONES_UPDATE = "delivery.working_zones.update"
WORKING_ZONES_DELETE = "delivery.working_zones.delete"
WORKING_ZONES_MANAGE = "delivery.working_zones.manage"

# Phase 10.4 — Pricing, Capabilities & Bundles
PRICING_RULES_VIEW = "delivery.pricing_rules.view"
PRICING_RULES_CREATE = "delivery.pricing_rules.create"
PRICING_RULES_UPDATE = "delivery.pricing_rules.update"
PRICING_RULES_DELETE = "delivery.pricing_rules.delete"
PRICING_RULES_MANAGE = "delivery.pricing_rules.manage"

CAPABILITIES_VIEW = "delivery.capabilities.view"
CAPABILITIES_CREATE = "delivery.capabilities.create"
CAPABILITIES_UPDATE = "delivery.capabilities.update"
CAPABILITIES_DELETE = "delivery.capabilities.delete"
CAPABILITIES_MANAGE = "delivery.capabilities.manage"

BUNDLES_VIEW = "delivery.bundles.view"
BUNDLES_CREATE = "delivery.bundles.create"
BUNDLES_UPDATE = "delivery.bundles.update"
BUNDLES_DELETE = "delivery.bundles.delete"
BUNDLES_MANAGE = "delivery.bundles.manage"

# Phase 10.5 — Dispatch Engine
DISPATCH_JOBS_VIEW = "delivery.dispatch.jobs.view"
DISPATCH_JOBS_CREATE = "delivery.dispatch.jobs.create"
DISPATCH_JOBS_UPDATE = "delivery.dispatch.jobs.update"
DISPATCH_JOBS_DELETE = "delivery.dispatch.jobs.delete"
DISPATCH_JOBS_STATUS = "delivery.dispatch.jobs.status"
DISPATCH_JOBS_MANAGE = "delivery.dispatch.jobs.manage"

DISPATCH_ASSIGNMENTS_VIEW = "delivery.dispatch.assignments.view"
DISPATCH_ASSIGNMENTS_CREATE = "delivery.dispatch.assignments.create"
DISPATCH_ASSIGNMENTS_UPDATE = "delivery.dispatch.assignments.update"
DISPATCH_ASSIGNMENTS_MANAGE = "delivery.dispatch.assignments.manage"

DISPATCH_VIEW = "delivery.dispatch.view"
DISPATCH_MANAGE = "delivery.dispatch.manage"

# Phase 10.6 — Routing & Optimization
ROUTES_VIEW = "delivery.routes.view"
ROUTES_CREATE = "delivery.routes.create"
ROUTES_UPDATE = "delivery.routes.update"
ROUTES_DELETE = "delivery.routes.delete"
ROUTES_STOPS_VIEW = "delivery.routes.stops.view"
ROUTES_STOPS_MANAGE = "delivery.routes.stops.manage"
ROUTES_MANAGE = "delivery.routes.manage"

OPTIMIZATION_RUNS_VIEW = "delivery.optimization.runs.view"
OPTIMIZATION_RUNS_CREATE = "delivery.optimization.runs.create"
OPTIMIZATION_RUNS_MANAGE = "delivery.optimization.runs.manage"

ROUTING_VIEW = "delivery.routing.view"
ROUTING_MANAGE = "delivery.routing.manage"

# Phase 10.7 — Tracking & Proof of Delivery
TRACKING_SESSIONS_VIEW = "delivery.tracking.sessions.view"
TRACKING_SESSIONS_CREATE = "delivery.tracking.sessions.create"
TRACKING_SESSIONS_UPDATE = "delivery.tracking.sessions.update"
TRACKING_SESSIONS_MANAGE = "delivery.tracking.sessions.manage"

TRACKING_POINTS_VIEW = "delivery.tracking.points.view"
TRACKING_POINTS_MANAGE = "delivery.tracking.points.manage"

PROOF_OF_DELIVERY_VIEW = "delivery.proof_of_delivery.view"
PROOF_OF_DELIVERY_CREATE = "delivery.proof_of_delivery.create"
PROOF_OF_DELIVERY_UPDATE = "delivery.proof_of_delivery.update"
PROOF_OF_DELIVERY_MANAGE = "delivery.proof_of_delivery.manage"

CUSTOMER_TRACKING_VIEW = "delivery.customer_tracking.view"
CUSTOMER_TRACKING_CREATE = "delivery.customer_tracking.create"
CUSTOMER_TRACKING_REVOKE = "delivery.customer_tracking.revoke"
CUSTOMER_TRACKING_MANAGE = "delivery.customer_tracking.manage"

TRACKING_VIEW = "delivery.tracking.view"
TRACKING_MANAGE = "delivery.tracking.manage"

# Phase 10.8 — Settlement
SETTLEMENTS_VIEW = "delivery.settlements.view"
SETTLEMENTS_CREATE = "delivery.settlements.create"
SETTLEMENTS_UPDATE = "delivery.settlements.update"
SETTLEMENTS_STATUS = "delivery.settlements.status"
SETTLEMENTS_LINES_VIEW = "delivery.settlements.lines.view"
SETTLEMENTS_LINES_MANAGE = "delivery.settlements.lines.manage"
SETTLEMENTS_MANAGE = "delivery.settlements.manage"

SETTLEMENT_VIEW = "delivery.settlement.view"
SETTLEMENT_MANAGE = "delivery.settlement.manage"

# Legacy aliases
FLEET_VIEW = FLEETS_VIEW
FLEET_MANAGE = FLEETS_MANAGE

ALL_PERMISSIONS: list[str] = [
    DELIVERY_VIEW,
    DELIVERY_MANAGE,
    ORGANIZATIONS_VIEW,
    ORGANIZATIONS_CREATE,
    ORGANIZATIONS_UPDATE,
    ORGANIZATIONS_DELETE,
    ORGANIZATIONS_MANAGE,
    HUBS_VIEW,
    HUBS_CREATE,
    HUBS_UPDATE,
    HUBS_DELETE,
    HUBS_MANAGE,
    EXTERNAL_PROVIDERS_VIEW,
    EXTERNAL_PROVIDERS_CREATE,
    EXTERNAL_PROVIDERS_UPDATE,
    EXTERNAL_PROVIDERS_DELETE,
    EXTERNAL_PROVIDERS_MANAGE,
    ROUTING_ENGINES_VIEW,
    ROUTING_ENGINES_CREATE,
    ROUTING_ENGINES_UPDATE,
    ROUTING_ENGINES_DELETE,
    ROUTING_ENGINES_MANAGE,
    CONFIGURATIONS_VIEW,
    CONFIGURATIONS_CREATE,
    CONFIGURATIONS_UPDATE,
    CONFIGURATIONS_DELETE,
    CONFIGURATIONS_MANAGE,
    SETTINGS_VIEW,
    SETTINGS_MANAGE,
    AUDIT_VIEW,
    DRIVERS_VIEW,
    DRIVERS_CREATE,
    DRIVERS_UPDATE,
    DRIVERS_DELETE,
    DRIVERS_ACTIVATE,
    DRIVERS_SUSPEND,
    DRIVERS_RESUME,
    DRIVERS_DEACTIVATE,
    DRIVERS_BLOCK,
    DRIVERS_UNBLOCK,
    DRIVERS_ARCHIVE,
    DRIVERS_LIFECYCLE_VIEW,
    DRIVERS_CREDENTIALS_VIEW,
    DRIVERS_CREDENTIALS_MANAGE,
    DRIVERS_DOCUMENTS_VIEW,
    DRIVERS_DOCUMENTS_MANAGE,
    DRIVERS_MANAGE,
    FLEETS_VIEW,
    FLEETS_CREATE,
    FLEETS_UPDATE,
    FLEETS_DELETE,
    FLEETS_MANAGE,
    VEHICLE_TYPES_VIEW,
    VEHICLE_TYPES_CREATE,
    VEHICLE_TYPES_UPDATE,
    VEHICLE_TYPES_DELETE,
    VEHICLE_TYPES_MANAGE,
    VEHICLES_VIEW,
    VEHICLES_CREATE,
    VEHICLES_UPDATE,
    VEHICLES_DELETE,
    VEHICLES_ASSIGNMENTS_VIEW,
    VEHICLES_ASSIGNMENTS_MANAGE,
    VEHICLES_MANAGE,
    AVAILABILITY_VIEW,
    AVAILABILITY_MANAGE,
    SHIFTS_VIEW,
    SHIFTS_CREATE,
    SHIFTS_UPDATE,
    SHIFTS_DELETE,
    SHIFTS_ASSIGNMENTS_VIEW,
    SHIFTS_ASSIGNMENTS_MANAGE,
    SHIFTS_MANAGE,
    WORKING_ZONES_VIEW,
    WORKING_ZONES_CREATE,
    WORKING_ZONES_UPDATE,
    WORKING_ZONES_DELETE,
    WORKING_ZONES_MANAGE,
    PRICING_RULES_VIEW,
    PRICING_RULES_CREATE,
    PRICING_RULES_UPDATE,
    PRICING_RULES_DELETE,
    PRICING_RULES_MANAGE,
    CAPABILITIES_VIEW,
    CAPABILITIES_CREATE,
    CAPABILITIES_UPDATE,
    CAPABILITIES_DELETE,
    CAPABILITIES_MANAGE,
    BUNDLES_VIEW,
    BUNDLES_CREATE,
    BUNDLES_UPDATE,
    BUNDLES_DELETE,
    BUNDLES_MANAGE,
    DISPATCH_JOBS_VIEW,
    DISPATCH_JOBS_CREATE,
    DISPATCH_JOBS_UPDATE,
    DISPATCH_JOBS_DELETE,
    DISPATCH_JOBS_STATUS,
    DISPATCH_JOBS_MANAGE,
    DISPATCH_ASSIGNMENTS_VIEW,
    DISPATCH_ASSIGNMENTS_CREATE,
    DISPATCH_ASSIGNMENTS_UPDATE,
    DISPATCH_ASSIGNMENTS_MANAGE,
    DISPATCH_VIEW,
    DISPATCH_MANAGE,
    ROUTES_VIEW,
    ROUTES_CREATE,
    ROUTES_UPDATE,
    ROUTES_DELETE,
    ROUTES_STOPS_VIEW,
    ROUTES_STOPS_MANAGE,
    ROUTES_MANAGE,
    OPTIMIZATION_RUNS_VIEW,
    OPTIMIZATION_RUNS_CREATE,
    OPTIMIZATION_RUNS_MANAGE,
    ROUTING_VIEW,
    ROUTING_MANAGE,
    TRACKING_SESSIONS_VIEW,
    TRACKING_SESSIONS_CREATE,
    TRACKING_SESSIONS_UPDATE,
    TRACKING_SESSIONS_MANAGE,
    TRACKING_POINTS_VIEW,
    TRACKING_POINTS_MANAGE,
    PROOF_OF_DELIVERY_VIEW,
    PROOF_OF_DELIVERY_CREATE,
    PROOF_OF_DELIVERY_UPDATE,
    PROOF_OF_DELIVERY_MANAGE,
    CUSTOMER_TRACKING_VIEW,
    CUSTOMER_TRACKING_CREATE,
    CUSTOMER_TRACKING_REVOKE,
    CUSTOMER_TRACKING_MANAGE,
    TRACKING_VIEW,
    TRACKING_MANAGE,
    SETTLEMENTS_VIEW,
    SETTLEMENTS_CREATE,
    SETTLEMENTS_UPDATE,
    SETTLEMENTS_STATUS,
    SETTLEMENTS_LINES_VIEW,
    SETTLEMENTS_LINES_MANAGE,
    SETTLEMENTS_MANAGE,
    SETTLEMENT_VIEW,
    SETTLEMENT_MANAGE,
    FLEET_VIEW,
    FLEET_MANAGE,
]

PERMISSION_PREFIXES: tuple[str, ...] = (
    "delivery.",
    "delivery.organizations.",
    "delivery.hubs.",
    "delivery.external_providers.",
    "delivery.routing_engines.",
    "delivery.configurations.",
    "delivery.settings.",
    "delivery.audit.",
    "delivery.drivers.",
    "delivery.fleets.",
    "delivery.vehicle_types.",
    "delivery.vehicles.",
    "delivery.availability.",
    "delivery.shifts.",
    "delivery.working_zones.",
    "delivery.pricing_rules.",
    "delivery.capabilities.",
    "delivery.bundles.",
    "delivery.dispatch.",
    "delivery.routes.",
    "delivery.optimization.",
    "delivery.tracking.",
    "delivery.proof_of_delivery.",
    "delivery.customer_tracking.",
    "delivery.settlements.",
    "delivery.fleet.",
    "delivery.routing.",
    "delivery.settlement.",
)
