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

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

const acOrg = createAccessControl(statement);

const owner = acOrg.newRole({
  ...ownerAc.statements,
  house: ['list', 'create', 'update', 'delete'],
  box: ['list', 'create', 'update', 'delete'],
  item: ['list', 'create', 'update', 'delete'],
});

const adminOrg = acOrg.newRole({
  ...adminAc.statements,
  house: ['list', 'create', 'update', 'leave'],
  box: ['list', 'create', 'update', 'delete'],
  item: ['list', 'create', 'update', 'delete'],
});

const member = acOrg.newRole({
  house: ['list', 'leave'],
  box: ['list'],
  item: ['list', 'create', 'update', 'delete'],
});

export { acOrg, adminOrg, member, owner };
