import { DraftOrder, SearchQuery, WebsitePage, UIMenu, Address, PhoneNumber, TransportMethod, Order, SearchObject, Login, OrderlyClient } from '@orderlyshop/core-client';
import { SearchQueryConfig } from './query.js';

type StorefrontClient = OrderlyClient;
interface SortOption {
    label: string;
    orderBy: string[];
}
interface NavigationDefinition {
    label: string;
    slug: string;
    heroImage?: string;
    heroLayout?: CategoryHeroLayout;
    heroCoverCount?: number;
    query?: SearchQueryConfig;
    description?: string;
    children?: NavigationDefinition[];
}
type CategoryHeroLayout = "image" | "split" | "covers";
/**
 * Derived values created from NavigationDefinition for rendered storefront pages.
 */
interface NavigationMetadata {
    slug: string;
    parentId?: string;
    pathSegments: string[];
    query: SearchQuery;
    searchText: string;
    description: string;
    heroImage: string;
    heroLayout: CategoryHeroLayout;
    heroCoverCount: number;
    pagePath: string;
}
/**
 * Runtime navigation item consumed by default shop/page components.
 */
interface ResolvedNavigationItem extends NavigationItem {
    metadata: NavigationMetadata;
    children?: ResolvedNavigationItem[];
}
/**
 * Backward-compatible aliases for the earlier category naming.
 */
type CategoryDefinition = NavigationDefinition;
type CategoryMetadata = NavigationMetadata;
type CategoryNavigationItem = ResolvedNavigationItem;
type CategoryUrlMode = "path" | "hash";
type StorefrontProductUrlMode = "hash" | "path";
type NavigationLayout = "vertical" | "horizontal" | "burgermenu";
type BasketDisplayMode = "drawer" | "inline-desktop";
type ProductGridPagingMode = "manual" | "button" | "infinite" | "dynamic";
interface ProductGridState {
    loading: boolean;
    error?: unknown;
    products: SearchObject[];
    count: number;
    estimatedTotalCount?: number;
    hasMore: boolean;
}
type BasketChangeReason = "load" | "set-draft" | "add-product" | "set-quantity" | "remove-line" | "clear" | "verify";
type BasketChangeEvent = CustomEvent<DraftOrder> & {
    reason?: BasketChangeReason;
};
interface ProductEventDetail {
    product: SearchObject;
    controllerUpdated?: boolean;
}
interface OrderCreatedDetail {
    order: Order;
    draft: DraftOrder;
}
interface CheckoutProfile {
    address?: Address;
    email?: string;
    phoneNumber?: PhoneNumber;
    updatedAt: string;
}
interface StorefrontRouteMetadata {
    title?: string;
    description?: string;
    canonicalHref?: string;
}
interface StorefrontHomeRouteMatch extends StorefrontRouteMetadata {
    kind: "home";
    url: URL;
    path: string;
}
interface StorefrontCategoryRouteMatch extends StorefrontRouteMetadata {
    kind: "category";
    url: URL;
    path: string;
    category: ResolvedNavigationItem;
}
interface StorefrontProductRouteMatch extends StorefrontRouteMetadata {
    kind: "product";
    url: URL;
    path: string;
    shareUrl: string;
}
interface StorefrontCheckoutRouteMatch extends StorefrontRouteMetadata {
    kind: "checkout";
    url: URL;
    path: string;
}
interface StorefrontPaymentSuccessRouteMatch extends StorefrontRouteMetadata {
    kind: "payment-success";
    url: URL;
    path: string;
    orderIdParam?: string;
}
interface StorefrontPaymentFailureRouteMatch extends StorefrontRouteMetadata {
    kind: "payment-failure";
    url: URL;
    path: string;
    orderIdParam?: string;
}
interface StorefrontStaticRouteConfig extends StorefrontRouteMetadata {
    path: string;
    create: () => HTMLElement;
}
interface StorefrontStaticRouteMatch extends StorefrontRouteMetadata {
    kind: "static";
    url: URL;
    path: string;
    route: StorefrontStaticRouteConfig;
}
type StorefrontRouteMatch = StorefrontHomeRouteMatch | StorefrontCategoryRouteMatch | StorefrontProductRouteMatch | StorefrontCheckoutRouteMatch | StorefrontPaymentSuccessRouteMatch | StorefrontPaymentFailureRouteMatch | StorefrontStaticRouteMatch;
interface StorefrontProductRouteConfig {
    mode?: StorefrontProductUrlMode;
    pathRoot?: string;
    buildPath?: (shareUrl: string) => string;
    parsePath?: (url: URL) => string | undefined;
}
interface StorefrontPageFactories {
    home?: (route: StorefrontHomeRouteMatch) => HTMLElement;
    category?: (route: StorefrontCategoryRouteMatch) => HTMLElement;
    product?: (route: StorefrontProductRouteMatch) => HTMLElement;
    checkout?: (route: StorefrontCheckoutRouteMatch) => HTMLElement;
    paymentSuccess?: (route: StorefrontPaymentSuccessRouteMatch) => HTMLElement;
    paymentFailure?: (route: StorefrontPaymentFailureRouteMatch) => HTMLElement;
}
interface StorefrontRouterConfig {
    /** Defaults to true when the router is configured through configureShop() or configureStorefrontRouter({}). */
    enabled?: boolean;
    tagPrefix?: string;
    viewTransitions?: boolean | "auto";
    staticRoutes?: StorefrontStaticRouteConfig[];
    product?: StorefrontProductRouteConfig;
    pageFactories?: StorefrontPageFactories;
}
interface NavigationItem {
    id: string;
    label: string;
    href?: string;
    target?: "_self" | "_blank";
    query?: SearchQuery;
    page?: WebsitePage;
    menu?: UIMenu;
    children?: NavigationItem[];
    disabled?: boolean;
    metadata?: unknown;
}
interface NavigationSelectionDetail {
    item: NavigationItem;
}
interface CheckoutReadyDetail {
    draft: DraftOrder;
    profile: CheckoutProfile;
    transportMethod?: TransportMethod;
}
interface SessionDetail {
    login?: Login;
}

export type { StorefrontProductRouteMatch as A, BasketChangeReason as B, CheckoutProfile as C, StorefrontRouteMetadata as D, StorefrontStaticRouteConfig as E, StorefrontStaticRouteMatch as F, NavigationItem as N, OrderCreatedDetail as O, ProductGridPagingMode as P, ResolvedNavigationItem as R, StorefrontRouteMatch as S, NavigationLayout as a, NavigationDefinition as b, CategoryUrlMode as c, CategoryDefinition as d, CategoryNavigationItem as e, NavigationMetadata as f, StorefrontRouterConfig as g, SortOption as h, StorefrontProductUrlMode as i, StorefrontProductRouteConfig as j, BasketDisplayMode as k, CategoryHeroLayout as l, ProductGridState as m, BasketChangeEvent as n, CategoryMetadata as o, CheckoutReadyDetail as p, NavigationSelectionDetail as q, ProductEventDetail as r, SessionDetail as s, StorefrontCategoryRouteMatch as t, StorefrontCheckoutRouteMatch as u, StorefrontClient as v, StorefrontHomeRouteMatch as w, StorefrontPageFactories as x, StorefrontPaymentFailureRouteMatch as y, StorefrontPaymentSuccessRouteMatch as z };
