// Derived from PDFium's constants/access_permissions.h
// Original: Copyright 2020 The PDFium Authors
// Licensed under BSD-3-Clause / Apache-2.0
// See pdfium-upstream/LICENSE for the original license.

//! User access permission bit flags.
//!
//! Corresponds to `pdfium::access_permissions` namespace.
//! PDF 1.7 spec, table 3.20.

/// Allow modifying document content.
pub const K_MODIFY_CONTENT: u32 = 1 << 3;

/// Allow modifying annotations and interactive form fields.
pub const K_MODIFY_ANNOTATION: u32 = 1 << 5;

/// Allow filling in existing interactive form fields.
pub const K_FILL_FORM: u32 = 1 << 8;

/// Allow extracting text and graphics for accessibility.
pub const K_EXTRACT_FOR_ACCESSIBILITY: u32 = 1 << 9;

// ---------------------------------------------------------------------------
// Tests — verify bit positions match PDF 1.7 spec Table 3.20
// ---------------------------------------------------------------------------

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_bit_positions_match_pdf_spec() {
        // Table 3.20: bit numbering is 1-based in spec; 0-based shifts here.
        assert_eq!(K_MODIFY_CONTENT, 1 << 3); // bit 4
        assert_eq!(K_MODIFY_ANNOTATION, 1 << 5); // bit 6
        assert_eq!(K_FILL_FORM, 1 << 8); // bit 9
        assert_eq!(K_EXTRACT_FOR_ACCESSIBILITY, 1 << 9); // bit 10
    }

    #[test]
    fn test_permissions_flags_are_disjoint() {
        let all = [
            K_MODIFY_CONTENT,
            K_MODIFY_ANNOTATION,
            K_FILL_FORM,
            K_EXTRACT_FOR_ACCESSIBILITY,
        ];
        for (i, &a) in all.iter().enumerate() {
            for (j, &b) in all.iter().enumerate() {
                if i != j {
                    assert_eq!(a & b, 0, "flags at indices {i} and {j} overlap");
                }
            }
        }
    }
}
