export interface Branch {
    id: number;
    name: string;
    code: string;
}
export interface Department {
    id: number;
    name: string;
    branch_id: number;
    branch?: Branch;
}
export interface Assignment {
    id?: number;
    role: string;
    branch_id: number | null;
    department_id: number | null;
    branch?: Branch;
    department?: Department;
}
export interface User {
    id: number;
    name: string;
    email: string;
    user_type: "staff" | "student";
    active: boolean;
    must_change_password: boolean;
    assignments: Assignment[];
    student?: Student;
}
export interface Period {
    id: number;
    name: string;
    kind: string;
    starts_on: string;
    ends_on: string;
    school_year: string;
    enrollment_open: boolean;
    term_key?: string | null;
}
export interface Program {
    id: number;
    name: string;
    level: string;
    college_id: number | null;
    default_curriculum_id: number | null;
    curriculum_template_id: number | null;
    duration_years: number;
    semesters_per_year: number;
    start_year: number;
    college?: { id: number; name: string } | null;
}
export interface Subject {
    id: number;
    name: string;
    code: string;
    units: string;
}
export interface Requirement {
    id: number;
    subject_id: number;
    year_level: number;
    term_label: string;
    term_key?: string | null;
    classification?: string | null;
    subject: Subject;
    unitLines?: {
        id: number;
        unit_type_id: number;
        credits: string;
        unitType: UnitType;
    }[];
    prerequisites: {
        id: number;
        required_subject_id: number;
        requiredSubject: Subject;
    }[];
}
export interface Curriculum {
    id: number;
    version: string;
    program_id: number;
    program: Program;
    published: boolean;
    subjects: Requirement[];
}
export interface Student {
    id: number;
    first_name: string;
    middle_name?: string | null;
    last_name: string;
    suffix?: string | null;
    student_number: string;
    home_branch_id: number;
    email?: string;
    birth_date?: string;
    user_id?: number;
    is_transferee?: boolean;
    is_blacklisted?: boolean;
    blacklist_reason?: string | null;
    photo_url?: string | null;
    phone?: string | null;
    address?: string | null;
    guardian_name?: string | null;
    guardian_phone?: string | null;
    created_at?: string;
    portal_status?: "active" | "inactive" | "not_linked";
    homeBranch?: Branch;
    assignments?: { curriculum_id: number; curriculum: Curriculum }[];
}
export interface Category {
    name: string;
    weight: number;
}
export interface Conversion {
    min: number;
    max: number;
    grade: number;
    passed: boolean;
}
export interface Policy {
    id: number;
    name: string;
    level: string;
    scale: "percentage" | "numeric";
    passing_mark: number | null;
    categories: Category[];
    conversions: Conversion[];
}
export interface Material {
    id: number;
    title: string;
    topic: string;
    url: string | null;
    original_name: string | null;
    course?: Course;
}
export interface Course {
    id: number;
    branch_id: number;
    department_id: number;
    academic_period_id: number;
    subject_id: number;
    program_id: number;
    teacher_id: number;
    section: string;
    schedule: string;
    meetings?: Meeting[] | null;
    sections?: Section[];
    capacity: number;
    roster_count?: number;
    finalized_at: string | null;
    subject: Subject;
    teacher: User;
    period: Period;
    branch: Branch;
    program: Program;
    department: Department;
    policy_snapshot: Policy;
    materials?: Material[];
}
export interface Clearance {
    status?: "cleared" | "on_hold";
    kind: string;
    reason: string;
    terms: string;
    approved_by: number;
    arrangement_approved_by?: number | null;
    arrangement_reason?: string | null;
    arrangement_terms?: string | null;
}
export interface CorSnapshot {
    school: string;
    student_number: string;
    student_name: string;
    branch: string;
    period: string;
    program: string;
    curriculum: string;
    year_level: number;
    home_section?: string | null;
    subjects: {
        code: string;
        name: string;
        units: string;
        section: string;
        schedule: string;
        teacher: string;
        classification?: string | null;
    }[];
}
export interface Enrollment {
    id: number;
    student_id: number;
    branch_id: number;
    academic_period_id: number;
    curriculum_id: number;
    year_level: number;
    section_id?: number | null;
    section?: Section | null;
    section_snapshot?: { id: number; name: string } | null;
    cor_version?: number;
    cor_issued_at?: string;
    corVersions?: {
        id: number;
        version: number;
        issued_at: string;
        reason: string | null;
    }[];
    status: string;
    cor_number: string | null;
    finalized_at: string | null;
    cor_snapshot: CorSnapshot | null;
    student: Student;
    period: Period;
    branch: Branch;
    curriculum: Curriculum;
    courses: Course[];
    clearance: Clearance | null;
}
export interface Grade {
    id: number;
    student_id: number;
    course_offering_id: number;
    official_grade: string;
    calculated_result: string;
    passed: boolean;
    adjustment_reason: string | null;
    finalized_at: string | null;
    course?: Course;
    corrections?: {
        id: number;
        old_grade: string;
        new_grade: string;
        reason: string;
        created_at: string;
    }[];
}
export interface Assessment {
    id: number;
    title: string;
    category: string;
    max_score: string;
    assessed_on: string;
    scores: { id: number; student_id: number; score: string }[];
}
export interface Calculation {
    result: number;
    official_grade: number | null;
    passed: boolean | null;
    missing: string[];
    breakdown: {
        category: string;
        earned: number;
        maximum: number;
        weight: number;
        contribution: number;
    }[];
}
export interface Credit {
    credited_units?: string | null;
    completes_subject?: boolean;
    id: number;
    student_id: number;
    branch_id: number;
    curriculum_id: number;
    subject_id: number;
    source_school: string;
    source_subject: string;
    source_grade: string;
    status: string;
    reason: string;
    student: Student;
    subject: Subject;
    curriculum: Curriculum;
}
export interface FinancialEntry {
    id: number;
    student_id: number;
    branch_id: number;
    kind: string;
    amount_cents: number;
    description: string;
    reference: string;
    created_at: string;
    period: Period | null;
    branch: Branch;
}
export interface Options {
    curriculum_templates?: {
        id: number;
        name: string;
        description: string | null;
    }[];
    unit_types?: UnitType[];
    branch_settings?: BranchSetting[];
    branch_periods?: BranchPeriod[];
    colleges: { id: number; name: string }[];
    branches: Branch[];
    departments: Department[];
    periods: Period[];
    programs: Program[];
    subjects: Subject[];
    curricula: Curriculum[];
    policies: Policy[];
    teachers: User[];
    courses: Course[];
    sections?: Section[];
    school_settings?: { id: number; level: string; enrollment_kind: string }[];
    global_setup?: boolean;
}
export interface UnitType {
    id: number;
    name: string;
    pricing_mode: "per_credit" | "fixed";
    price: string;
}
export interface BranchSetting {
    id: number;
    branch_id: number;
    level: string;
    enrollment_kind: string;
}
export interface BranchPeriod {
    id: number;
    branch_id: number;
    level: string;
    academic_period_id: number;
}

export interface Meeting {
    day: number;
    start: string;
    end: string;
}
export interface Section {
    id: number;
    name: string;
    branch_id: number;
    department_id: number | null;
    capacity: number;
    current_count?: number;
    branch?: Branch;
    classes?: Course[];
    availabilities?: {
        id: number;
        section_id: number;
        program_id: number;
        academic_period_id: number;
        year_level: number;
        sort_order: number;
        program: Program;
        period: Period;
    }[];
    memberships?: {
        id: number;
        student_id: number;
        student: Student;
        confirmed_at: string;
        ended_at: string | null;
        end_reason: string | null;
    }[];
}
export interface Paginated<T> {
    data: T[];
    current_page: number;
    last_page: number;
    total: number;
    from: number | null;
    to: number | null;
    prev_page_url: string | null;
    next_page_url: string | null;
}
export interface Shared {
    auth: User | null;
    school: string;
    permissions: string[];
    roles: Record<string, { label: string; permissions: string[] }>;
    levels: Record<string, string>;
    flash: { success: string | null };
    errors: Record<string, string>;
    [key: string]: unknown;
}
export const person = (s: Student) =>
    [s.first_name, s.middle_name, s.last_name, s.suffix]
        .filter(Boolean)
        .join(" ");
export const money = (cents: number) =>
    new Intl.NumberFormat("en-PH", {
        style: "currency",
        currency: "PHP",
    }).format(cents / 100);
