/**
 * AWS's hard maximum lifetime of an S3 SigV4 presigned URL — seven days. A
 * requested expiry above this can't be served by a raw presigned link, so the
 * delivery transparently falls back to the persistent-download-URL system.
 */
export const S3_PRESIGNED_URL_MAX_EXPIRATION_SECONDS = 604800;
/**
 * Postgres `integer` column ceiling. Every numeric org setting is stored in an
 * `integer` column, so a value above this overflows the column (a DB error, not
 * a clean validation failure). Used as the hard upper bound for all of them.
 */
export const POSTGRES_INTEGER_MAX = 2147483647;
/**
 * The single source of truth for resolving a stored (raw) org settings record
 * against the instance defaults: an explicit per-org value wins; a value that's
 * `null`, or simply absent (an unset column / no row at all), falls back to the
 * instance default. Used by the backend for both the API response (so the
 * frontend just displays the effective value) and the login flow, so the two
 * can never drift.
 */
export const resolveEffectiveOrganizationSettings = (raw, instanceDefaults) => ({
    oidcLinkingEnabled: raw.oidcLinkingEnabled ?? instanceDefaults.enableOidcLinking,
    oidcToEmailLinkingEnabled: raw.oidcToEmailLinkingEnabled ??
        instanceDefaults.enableOidcToEmailLinking,
    // Opt-in only — no instance default, so an unset value resolves to false.
    supportImpersonationEnabled: raw.supportImpersonationEnabled ?? false,
    // Base is resolved to an effective number (falls back to the env default).
    scheduledDeliveryExpirationSeconds: raw.scheduledDeliveryExpirationSeconds ??
        instanceDefaults.scheduledDeliveryExpirationSeconds,
    // Per-channel overrides are surfaced raw (null = inherit base) so the UI
    // can tell "not set" apart from an explicit value; their fallback to the
    // base happens at delivery time, not here.
    scheduledDeliveryExpirationSecondsEmail: raw.scheduledDeliveryExpirationSecondsEmail ?? null,
    scheduledDeliveryExpirationSecondsSlack: raw.scheduledDeliveryExpirationSecondsSlack ?? null,
    scheduledDeliveryExpirationSecondsMsTeams: raw.scheduledDeliveryExpirationSecondsMsTeams ?? null,
    scheduledDeliveryExpirationSecondsGoogleChat: raw.scheduledDeliveryExpirationSecondsGoogleChat ?? null,
    // Limits resolve to an effective number (fall back to the env default).
    queryLimit: raw.queryLimit ?? instanceDefaults.queryLimit,
    csvCellsLimit: raw.csvCellsLimit ?? instanceDefaults.csvCellsLimit,
});
//# sourceMappingURL=organizationSettings.js.map