import { serializeAiExtractFieldOption } from './aiExtractFieldOption.js';
import { deserializeAiExtractFieldOption } from './aiExtractFieldOption.js';
import { BoxSdkError } from '../box/errors.js';
import { sdIsString } from '../serialization/json.js';
import { sdIsList } from '../serialization/json.js';
import { sdIsMap } from '../serialization/json.js';
export function serializeAiExtractSubField(val) {
    return {
        ['key']: val.key,
        ['description']: val.description,
        ['displayName']: val.displayName,
        ['prompt']: val.prompt,
        ['type']: val.type,
        ['options']: val.options == void 0
            ? val.options
            : val.options.map(function (item) {
                return serializeAiExtractFieldOption(item);
            }),
    };
}
export function deserializeAiExtractSubField(val) {
    if (!sdIsMap(val)) {
        throw new BoxSdkError({
            message: 'Expecting a map for "AiExtractSubField"',
        });
    }
    if (val.key == void 0) {
        throw new BoxSdkError({
            message: 'Expecting "key" of type "AiExtractSubField" to be defined',
        });
    }
    if (!sdIsString(val.key)) {
        throw new BoxSdkError({
            message: 'Expecting string for "key" of type "AiExtractSubField"',
        });
    }
    const key = val.key;
    if (!(val.description == void 0) && !sdIsString(val.description)) {
        throw new BoxSdkError({
            message: 'Expecting string for "description" of type "AiExtractSubField"',
        });
    }
    const description = val.description == void 0 ? void 0 : val.description;
    if (!(val.displayName == void 0) && !sdIsString(val.displayName)) {
        throw new BoxSdkError({
            message: 'Expecting string for "displayName" of type "AiExtractSubField"',
        });
    }
    const displayName = val.displayName == void 0 ? void 0 : val.displayName;
    if (!(val.prompt == void 0) && !sdIsString(val.prompt)) {
        throw new BoxSdkError({
            message: 'Expecting string for "prompt" of type "AiExtractSubField"',
        });
    }
    const prompt = val.prompt == void 0 ? void 0 : val.prompt;
    if (!(val.type == void 0) && !sdIsString(val.type)) {
        throw new BoxSdkError({
            message: 'Expecting string for "type" of type "AiExtractSubField"',
        });
    }
    const type = val.type == void 0 ? void 0 : val.type;
    if (!(val.options == void 0) && !sdIsList(val.options)) {
        throw new BoxSdkError({
            message: 'Expecting array for "options" of type "AiExtractSubField"',
        });
    }
    const options = val.options == void 0
        ? void 0
        : sdIsList(val.options)
            ? val.options.map(function (itm) {
                return deserializeAiExtractFieldOption(itm);
            })
            : [];
    return {
        key: key,
        description: description,
        displayName: displayName,
        prompt: prompt,
        type: type,
        options: options,
    };
}
//# sourceMappingURL=aiExtractSubField.js.map