"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DECLARED_AGE_PREF = exports.PERSONAL_DETAILS_PREF = void 0;
exports.prefAllowed = prefAllowed;
exports.isReadOnlyPref = isReadOnlyPref;
exports.getAgeFromDatestring = getAgeFromDatestring;
exports.PERSONAL_DETAILS_PREF = 'app.bsky.actor.defs#personalDetailsPref';
exports.DECLARED_AGE_PREF = 'app.bsky.actor.defs#declaredAgePref';
const FULL_ACCESS_ONLY_PREFS = new Set([exports.PERSONAL_DETAILS_PREF]);
function prefAllowed(prefType, options) {
    if (options?.hasAccessFull === true) {
        return true;
    }
    return !FULL_ACCESS_ONLY_PREFS.has(prefType);
}
const READ_ONLY_PREFS = new Set([exports.DECLARED_AGE_PREF]);
function isReadOnlyPref(prefType) {
    return READ_ONLY_PREFS.has(prefType);
}
function getAgeFromDatestring(birthDate) {
    const bday = new Date(birthDate);
    const today = new Date();
    let age = today.getFullYear() - bday.getFullYear();
    const m = today.getMonth() - bday.getMonth();
    if (m < 0 || (m === 0 && today.getDate() < bday.getDate())) {
        age--;
    }
    return age;
}
//# sourceMappingURL=util.js.map