import { createAccessControl } from 'better-auth/plugins/access';
import { adminAc, defaultStatements } from 'better-auth/plugins/admin/access';

const statement = {
  ...defaultStatements,
  audit: ['list'],
  setting: ['list', 'update'],
  house: ['list', 'create', 'update', 'delete'],
  box: ['list', 'create', 'update', 'delete'],
  item: ['list', 'create', 'update', 'delete'],
} as const;

const ac = createAccessControl(statement);

const admin = ac.newRole({
  ...adminAc.statements,
  audit: ['list'],
  setting: ['list', 'update'],
  house: ['list', 'create', 'update', 'delete'],
  box: ['list', 'create', 'update', 'delete'],
  item: ['list', 'create', 'update', 'delete'],
});

const user = ac.newRole({
  setting: ['list', 'update'],
  house: ['list', 'create', 'update', 'delete'],
});

export { ac, admin, user };
