import * as HttpClient from "effect/unstable/http/HttpClient";
import * as redacted from "effect/Redacted";
import * as S from "effect/Schema";
import * as API from "../client/api.js";
import * as T from "../traits.js";
import * as C from "../category.js";
import { SensitiveString } from "../sensitive.js";
const svc = T.AwsApiService({
    sdkId: "Personalize Runtime",
    serviceShapeName: "AmazonPersonalizeRuntime",
});
const auth = T.AwsAuthSigv4({ name: "personalize" });
const ver = T.ServiceVersion("2018-05-22");
const proto = T.AwsProtocolsRestJson1();
const rules = T.EndpointResolver((p, _) => {
    const { Region, UseDualStack = false, UseFIPS = false, Endpoint } = p;
    const e = (u, p = {}, h = {}) => ({
        type: "endpoint",
        endpoint: { url: u, properties: p, headers: h },
    });
    const err = (m) => ({
        type: "error",
        message: m,
    });
    if (Endpoint != null) {
        if (UseFIPS === true) {
            return err("Invalid Configuration: FIPS and custom endpoint are not supported");
        }
        if (UseDualStack === true) {
            return err("Invalid Configuration: Dualstack and custom endpoint are not supported");
        }
        return e(Endpoint);
    }
    if (Region != null) {
        {
            const PartitionResult = _.partition(Region);
            if (PartitionResult != null && PartitionResult !== false) {
                if (UseFIPS === true && UseDualStack === true) {
                    if (true === _.getAttr(PartitionResult, "supportsFIPS") &&
                        true === _.getAttr(PartitionResult, "supportsDualStack")) {
                        return e(`https://personalize-runtime-fips.${Region}.${_.getAttr(PartitionResult, "dualStackDnsSuffix")}`);
                    }
                    return err("FIPS and DualStack are enabled, but this partition does not support one or both");
                }
                if (UseFIPS === true) {
                    if (_.getAttr(PartitionResult, "supportsFIPS") === true) {
                        return e(`https://personalize-runtime-fips.${Region}.${_.getAttr(PartitionResult, "dnsSuffix")}`);
                    }
                    return err("FIPS is enabled but this partition does not support FIPS");
                }
                if (UseDualStack === true) {
                    if (true === _.getAttr(PartitionResult, "supportsDualStack")) {
                        return e(`https://personalize-runtime.${Region}.${_.getAttr(PartitionResult, "dualStackDnsSuffix")}`);
                    }
                    return err("DualStack is enabled but this partition does not support DualStack");
                }
                return e(`https://personalize-runtime.${Region}.${_.getAttr(PartitionResult, "dnsSuffix")}`);
            }
        }
    }
    return err("Invalid Configuration: Missing Region");
});
export const FilterValues = /*@__PURE__*/ /*#__PURE__*/ S.Record(S.String, SensitiveString.pipe(S.optional));
export const GetActionRecommendationsRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    campaignArn: S.optional(S.String),
    userId: S.optional(S.String),
    numResults: S.optional(S.Number),
    filterArn: S.optional(S.String),
    filterValues: S.optional(FilterValues),
}).pipe(T.all(T.Http({ method: "POST", uri: "/action-recommendations" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "GetActionRecommendationsRequest",
});
export const PredictedAction = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ actionId: S.optional(S.String), score: S.optional(S.Number) })).annotate({
    identifier: "PredictedAction",
});
export const ActionList = /*@__PURE__*/ /*#__PURE__*/ S.Array(PredictedAction);
export const GetActionRecommendationsResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    actionList: S.optional(ActionList),
    recommendationId: S.optional(S.String),
})).annotate({
    identifier: "GetActionRecommendationsResponse",
});
export const InputList = /*@__PURE__*/ /*#__PURE__*/ S.Array(S.String);
export const Context = /*@__PURE__*/ /*#__PURE__*/ S.Record(S.String, SensitiveString.pipe(S.optional));
export const ColumnNamesList = /*@__PURE__*/ /*#__PURE__*/ S.Array(S.String);
export const MetadataColumns = /*@__PURE__*/ /*#__PURE__*/ S.Record(S.String, ColumnNamesList.pipe(S.optional));
export const GetPersonalizedRankingRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    campaignArn: S.String,
    inputList: InputList,
    userId: S.String,
    context: S.optional(Context),
    filterArn: S.optional(S.String),
    filterValues: S.optional(FilterValues),
    metadataColumns: S.optional(MetadataColumns),
}).pipe(T.all(T.Http({ method: "POST", uri: "/personalize-ranking" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "GetPersonalizedRankingRequest",
});
export const Metadata = /*@__PURE__*/ /*#__PURE__*/ S.Record(S.String, S.String.pipe(S.optional));
export const ReasonList = /*@__PURE__*/ /*#__PURE__*/ S.Array(S.String);
export const PredictedItem = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    itemId: S.optional(S.String),
    score: S.optional(S.Number),
    promotionName: S.optional(S.String),
    metadata: S.optional(Metadata),
    reason: S.optional(ReasonList),
})).annotate({ identifier: "PredictedItem" });
export const ItemList = /*@__PURE__*/ /*#__PURE__*/ S.Array(PredictedItem);
export const GetPersonalizedRankingResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    personalizedRanking: S.optional(ItemList),
    recommendationId: S.optional(S.String),
})).annotate({
    identifier: "GetPersonalizedRankingResponse",
});
export const Promotion = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    name: S.optional(S.String),
    percentPromotedItems: S.optional(S.Number),
    filterArn: S.optional(S.String),
    filterValues: S.optional(FilterValues),
})).annotate({ identifier: "Promotion" });
export const PromotionList = /*@__PURE__*/ /*#__PURE__*/ S.Array(Promotion);
export const GetRecommendationsRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    campaignArn: S.optional(S.String),
    itemId: S.optional(S.String),
    userId: S.optional(S.String),
    numResults: S.optional(S.Number),
    context: S.optional(Context),
    filterArn: S.optional(S.String),
    filterValues: S.optional(FilterValues),
    recommenderArn: S.optional(S.String),
    promotions: S.optional(PromotionList),
    metadataColumns: S.optional(MetadataColumns),
}).pipe(T.all(T.Http({ method: "POST", uri: "/recommendations" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "GetRecommendationsRequest",
});
export const GetRecommendationsResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    itemList: S.optional(ItemList),
    recommendationId: S.optional(S.String),
})).annotate({
    identifier: "GetRecommendationsResponse",
});
//# Errors
export class InvalidInputException extends S.TaggedErrorClass()("InvalidInputException", { message: S.optional(S.String) }).pipe(C.withBadRequestError) {
}
export class ResourceNotFoundException extends S.TaggedErrorClass()("ResourceNotFoundException", { message: S.optional(S.String) }).pipe(C.withBadRequestError) {
}
/**
 * Returns a list of recommended actions in sorted in descending order by prediction score.
 * Use the `GetActionRecommendations` API if you have a custom
 * campaign that deploys a solution version trained with a PERSONALIZED_ACTIONS recipe.
 *
 * For more information about PERSONALIZED_ACTIONS recipes, see PERSONALIZED_ACTIONS recipes.
 * For more information about getting action recommendations, see Getting action recommendations.
 */
export const getActionRecommendations = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetActionRecommendationsRequest,
    output: GetActionRecommendationsResponse,
    errors: [InvalidInputException, ResourceNotFoundException],
}));
/**
 * Re-ranks a list of recommended items for the given user. The first item in the list is
 * deemed the most likely item to be of interest to the user.
 *
 * The solution backing the campaign must have been created using a recipe of type
 * PERSONALIZED_RANKING.
 */
export const getPersonalizedRanking = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetPersonalizedRankingRequest,
    output: GetPersonalizedRankingResponse,
    errors: [InvalidInputException, ResourceNotFoundException],
}));
/**
 * Returns a list of recommended items. For campaigns, the campaign's Amazon Resource Name (ARN) is required and the required user and item input depends on the recipe type used to
 * create the solution backing the campaign as follows:
 *
 * - USER_PERSONALIZATION - `userId` required, `itemId` not used
 *
 * - RELATED_ITEMS - `itemId` required, `userId` not used
 *
 * Campaigns that are backed by a solution created using a recipe of type
 * PERSONALIZED_RANKING use the API.
 *
 * For recommenders, the recommender's ARN is required and the required item and user input depends on the use case (domain-based recipe) backing the recommender.
 * For information on use case requirements see Choosing recommender use cases.
 */
export const getRecommendations = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetRecommendationsRequest,
    output: GetRecommendationsResponse,
    errors: [InvalidInputException, ResourceNotFoundException],
}));
//# sourceMappingURL=personalize-runtime.js.map