import * as HttpClient from "effect/unstable/http/HttpClient";
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";
const svc = T.AwsApiService({
    sdkId: "forecastquery",
    serviceShapeName: "AmazonForecastRuntime",
});
const auth = T.AwsAuthSigv4({ name: "forecast" });
const ver = T.ServiceVersion("2018-06-26");
const proto = T.AwsProtocolsAwsJson1_1();
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://forecastquery-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://forecastquery-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://forecastquery.${Region}.${_.getAttr(PartitionResult, "dualStackDnsSuffix")}`);
                    }
                    return err("DualStack is enabled but this partition does not support DualStack");
                }
                return e(`https://forecastquery.${Region}.${_.getAttr(PartitionResult, "dnsSuffix")}`);
            }
        }
    }
    return err("Invalid Configuration: Missing Region");
});
export const Filters = /*@__PURE__*/ /*#__PURE__*/ S.Record(S.String, S.String.pipe(S.optional));
export const QueryForecastRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    ForecastArn: S.String,
    StartDate: S.optional(S.String),
    EndDate: S.optional(S.String),
    Filters: Filters,
    NextToken: S.optional(S.String),
}).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "QueryForecastRequest",
});
export const DataPoint = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ Timestamp: S.optional(S.String), Value: S.optional(S.Number) })).annotate({ identifier: "DataPoint" });
export const TimeSeries = /*@__PURE__*/ /*#__PURE__*/ S.Array(DataPoint);
export const Predictions = /*@__PURE__*/ /*#__PURE__*/ S.Record(S.String, TimeSeries.pipe(S.optional));
export const Forecast = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ Predictions: S.optional(Predictions) })).annotate({ identifier: "Forecast" });
export const QueryForecastResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ Forecast: S.optional(Forecast) })).annotate({
    identifier: "QueryForecastResponse",
});
export const QueryWhatIfForecastRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    WhatIfForecastArn: S.String,
    StartDate: S.optional(S.String),
    EndDate: S.optional(S.String),
    Filters: Filters,
    NextToken: S.optional(S.String),
}).pipe(T.all(T.Http({ method: "POST", uri: "/" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "QueryWhatIfForecastRequest",
});
export const QueryWhatIfForecastResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ Forecast: S.optional(Forecast) })).annotate({
    identifier: "QueryWhatIfForecastResponse",
});
//# Errors
export class InvalidInputException extends S.TaggedErrorClass()("InvalidInputException", { Message: S.optional(S.String) }).pipe(C.withBadRequestError) {
}
export class InvalidNextTokenException extends S.TaggedErrorClass()("InvalidNextTokenException", { Message: S.optional(S.String) }).pipe(C.withBadRequestError) {
}
export class LimitExceededException extends S.TaggedErrorClass()("LimitExceededException", { Message: S.optional(S.String) }).pipe(C.withConflictError) {
}
export class ResourceInUseException extends S.TaggedErrorClass()("ResourceInUseException", { Message: S.optional(S.String) }).pipe(C.withConflictError) {
}
export class ResourceNotFoundException extends S.TaggedErrorClass()("ResourceNotFoundException", { Message: S.optional(S.String) }).pipe(C.withBadRequestError) {
}
/**
 * Retrieves a forecast for a single item, filtered by the supplied criteria.
 *
 * The criteria is a key-value pair. The key is either `item_id` (or the
 * equivalent non-timestamp, non-target field) from the `TARGET_TIME_SERIES` dataset,
 * or one of the forecast dimensions specified as part of the `FeaturizationConfig`
 * object.
 *
 * By default, `QueryForecast` returns the complete date range for the filtered
 * forecast. You can request a specific date range.
 *
 * To get the full forecast, use the CreateForecastExportJob operation.
 *
 * The forecasts generated by Amazon Forecast are in the same timezone as the dataset that was
 * used to create the predictor.
 */
export const queryForecast = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: QueryForecastRequest,
    output: QueryForecastResponse,
    errors: [
        InvalidInputException,
        InvalidNextTokenException,
        LimitExceededException,
        ResourceInUseException,
        ResourceNotFoundException,
    ],
}));
/**
 * Retrieves a what-if forecast.
 */
export const queryWhatIfForecast = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: QueryWhatIfForecastRequest,
    output: QueryWhatIfForecastResponse,
    errors: [
        InvalidInputException,
        InvalidNextTokenException,
        LimitExceededException,
        ResourceInUseException,
        ResourceNotFoundException,
    ],
}));
//# sourceMappingURL=forecastquery.js.map