import { z } from 'zod';
import { access_grant_pending_mutations } from './pending-mutations.js';
import { requested_access_method } from './requested-access-method.js';
const common_access_grant_error = z.object({
    created_at: z
        .string()
        .datetime()
        .describe('Date and time at which Seam created the error.'),
    message: z
        .string()
        .describe('Detailed description of the error. Provides insights into the issue and potentially how to rectify it.'),
});
const error_code_description = 'Unique identifier of the type of error. Enables quick recognition and categorization of the issue.';
const cannot_create_requested_access_methods_error = common_access_grant_error.extend({
    error_code: z
        .literal('cannot_create_requested_access_methods')
        .describe(error_code_description),
});
const common_access_grant_warning = z.object({
    created_at: z
        .string()
        .datetime()
        .describe('Date and time at which Seam created the warning.'),
    message: z
        .string()
        .describe('Detailed description of the warning. Provides insights into the issue and potentially how to rectify it.'),
});
const warning_code_description = 'Unique identifier of the type of warning. Enables quick recognition and categorization of the issue.';
const access_grant_error = z.discriminatedUnion('error_code', [
    cannot_create_requested_access_methods_error,
]);
export const _access_grant_error_map = z.object({
    cannot_create_requested_access_methods: cannot_create_requested_access_methods_error.optional().nullable(),
});
const being_deleted = common_access_grant_warning
    .extend({
    warning_code: z.literal('being_deleted').describe(warning_code_description),
})
    .describe('Indicates that the [access grant](https://docs.seam.co/latest/capability-guides/access-grants) is being deleted.');
const underprovisioned_access = common_access_grant_warning
    .extend({
    warning_code: z
        .literal('underprovisioned_access')
        .describe(warning_code_description),
})
    .describe('Indicates that the access grant should have access to more locations than it currently does. Access methods are being created for the missing locations.');
const overprovisioned_access = common_access_grant_warning
    .extend({
    warning_code: z
        .literal('overprovisioned_access')
        .describe(warning_code_description),
})
    .describe('Indicates that the access grant has access to locations it should not have. Access methods are being removed from the extra locations.');
const updating_access_times = common_access_grant_warning
    .extend({
    warning_code: z
        .literal('updating_access_times')
        .describe(warning_code_description),
    access_method_ids: z
        .array(z.string().uuid())
        .describe('IDs of the access methods being updated.'),
})
    .describe('Indicates that the access times for this [access grant](https://docs.seam.co/latest/capability-guides/access-grants) are being updated.');
const requested_code_unavailable = common_access_grant_warning
    .extend({
    warning_code: z
        .literal('requested_code_unavailable')
        .describe(warning_code_description),
    device_id: z
        .string()
        .uuid()
        .describe('ID of the device where the requested code was unavailable.'),
    original_code: z
        .string()
        .describe('The originally requested PIN code that was unavailable.'),
    new_code: z
        .string()
        .describe('The new PIN code that was assigned instead.'),
})
    .describe('Indicates that the requested PIN code was already in use on a device, so a different code was assigned.');
const device_does_not_support_access_codes = common_access_grant_warning
    .extend({
    warning_code: z
        .literal('device_does_not_support_access_codes')
        .describe(warning_code_description),
    device_id: z
        .string()
        .uuid()
        .describe('ID of the device that does not support access codes.'),
})
    .describe('Indicates that a device in the access grant does not support access codes and was excluded from code materialization.');
const access_grant_warning = z
    .discriminatedUnion('warning_code', [
    being_deleted,
    underprovisioned_access,
    overprovisioned_access,
    updating_access_times,
    requested_code_unavailable,
    device_does_not_support_access_codes,
])
    .describe('Warning associated with the [access grant](https://docs.seam.co/latest/capability-guides/access-grants).');
const _access_grant_warning_map = z.object({
    being_deleted: being_deleted.optional().nullable(),
    underprovisioned_access: underprovisioned_access.optional().nullable(),
    overprovisioned_access: overprovisioned_access.optional().nullable(),
    updating_access_times: updating_access_times.optional().nullable(),
    requested_code_unavailable_by_device: z
        .record(z.string().uuid(), requested_code_unavailable)
        .optional()
        .nullable(),
    device_does_not_support_access_codes: z
        .record(z.string().uuid(), device_does_not_support_access_codes)
        .optional()
        .nullable(),
});
export const access_grant = z.object({
    workspace_id: z
        .string()
        .uuid()
        .describe('ID of the Seam workspace associated with the Access Grant.'),
    access_grant_id: z.string().uuid().describe('ID of the Access Grant.'),
    access_grant_key: z
        .string()
        .optional()
        .describe('Unique key for the access grant within the workspace.'),
    reservation_key: z
        .string()
        .optional()
        .describe('Reservation key for the access grant.'),
    user_identity_id: z
        .string()
        .uuid()
        .describe('ID of user identity to which the Access Grant gives access.'),
    location_ids: z.array(z.string().uuid()).describe(`
    ---
    deprecated: Use \`space_ids\`.
    ---
  `),
    space_ids: z
        .array(z.string().uuid())
        .describe('IDs of the spaces to which the Access Grant gives access.'),
    requested_access_methods: z
        .array(requested_access_method)
        .describe('Access methods that the user requested for the Access Grant.'),
    access_method_ids: z
        .array(z.string().uuid())
        .describe('IDs of the access methods created for the Access Grant.'),
    client_session_token: z
        .string()
        .optional()
        .describe('Client Session Token. Only returned if the Access Grant has a mobile_key access method.'),
    name: z
        .string()
        .nullable()
        .describe('Name of the Access Grant. If not provided, the display name will be computed.'),
    display_name: z.string().describe('Display name of the Access Grant.'),
    instant_key_url: z
        .string()
        .url()
        .optional()
        .describe('Instant Key URL. Only returned if the Access Grant has a single mobile_key access_method. '),
    created_at: z
        .string()
        .datetime()
        .describe('Date and time at which the Access Grant was created.'),
    starts_at: z
        .string()
        .datetime()
        .describe('Date and time at which the Access Grant starts.'),
    ends_at: z
        .string()
        .datetime()
        .nullable()
        .describe('Date and time at which the Access Grant ends.'),
    warnings: z
        .array(access_grant_warning)
        .describe('Warnings associated with the [access grant](https://docs.seam.co/latest/capability-guides/access-grants).'),
    errors: z
        .array(access_grant_error)
        .describe('Errors associated with the [access grant](https://docs.seam.co/latest/capability-guides/access-grants).'),
    customization_profile_id: z
        .string()
        .uuid()
        .optional()
        .describe('ID of the customization profile associated with the Access Grant.'),
    pending_mutations: z
        .array(access_grant_pending_mutations)
        .describe('List of pending mutations for the access grant. This shows updates that are in progress.'),
}).describe(`
  ---
  draft: Early access.
  route_path: /access_grants
  ---
  Represents an Access Grant. Access Grants enable you to grant a user identity access to spaces, entrances, and devices through one or more access methods, such as mobile keys, plastic cards, and PIN codes. You can create an Access Grant for an existing user identity, or you can create a new user identity *while* creating the new Access Grant.
  `);
// Unmanaged access grant schema - excludes client sessions, instant keys, customization profiles, and keys
export const unmanaged_access_grant = access_grant
    .omit({
    client_session_token: true,
    instant_key_url: true,
    customization_profile_id: true,
    access_grant_key: true,
    user_identity_id: true,
})
    .extend({
    user_identity_id: access_grant.shape.user_identity_id.optional(),
}).describe(`
  ---
  draft: Early access.
  route_path: /access_grants/unmanaged
  ---
  Represents an unmanaged Access Grant. Unmanaged Access Grants do not have client sessions, instant keys, customization profiles, or keys.
  `);
//# sourceMappingURL=access-grant.js.map