"use client";
import { createContext, useContext } from "react";
import type { Annotatie } from "@/data/regelgeving";

interface RegelgevingActies {
  getAnnotaties: (artikelId: string) => Annotatie[];
  isBladwijzer: (artikelId: string) => boolean;
  getVolledigeTekst: (artikelId: string) => string | undefined;
  toggleBladwijzer: (artikelId: string) => void;
  addAnnotatie: (artikelId: string, tekst: string) => void;
  updateAnnotatie: (annotatieId: string, tekst: string) => void;
  deleteAnnotatie: (annotatieId: string) => void;
  setVolledigeTekst: (artikelId: string, tekst: string) => void;
}

export const RegelgevingActiesContext = createContext<RegelgevingActies | null>(null);

export function useRegelgevingActies() {
  const ctx = useContext(RegelgevingActiesContext);
  if (!ctx) throw new Error("useRegelgevingActies must be used within RegelgevingActiesContext");
  return ctx;
}
