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: "Kinesis Video Signaling",
    serviceShapeName: "AWSAcuitySignalingService",
});
const auth = T.AwsAuthSigv4({ name: "kinesisvideo" });
const ver = T.ServiceVersion("2019-12-04");
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://kinesisvideo-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://kinesisvideo-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://kinesisvideo.${Region}.${_.getAttr(PartitionResult, "dualStackDnsSuffix")}`);
                    }
                    return err("DualStack is enabled but this partition does not support DualStack");
                }
                return e(`https://kinesisvideo.${Region}.${_.getAttr(PartitionResult, "dnsSuffix")}`);
            }
        }
    }
    return err("Invalid Configuration: Missing Region");
});
export const Service = /*@__PURE__*/ /*#__PURE__*/ S.String;
export const GetIceServerConfigRequest = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    ChannelARN: S.optional(S.String),
    ClientId: S.optional(S.String),
    Service: S.optional(Service),
    Username: S.optional(S.String),
}).pipe(T.all(T.Http({ method: "POST", uri: "/v1/get-ice-server-config" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "GetIceServerConfigRequest",
});
export const Uris = /*@__PURE__*/ /*#__PURE__*/ S.Array(S.String);
export const IceServer = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    Uris: S.optional(Uris),
    Username: S.optional(S.String),
    Password: S.optional(S.String),
    Ttl: S.optional(S.Number),
})).annotate({ identifier: "IceServer" });
export const IceServerList = /*@__PURE__*/ /*#__PURE__*/ S.Array(IceServer);
export const GetIceServerConfigResponse = /*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ IceServerList: S.optional(IceServerList) })).annotate({
    identifier: "GetIceServerConfigResponse",
});
export const SendAlexaOfferToMasterRequest = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({
    ChannelARN: S.optional(S.String),
    SenderClientId: S.optional(S.String),
    MessagePayload: S.optional(S.String),
}).pipe(T.all(T.Http({ method: "POST", uri: "/v1/send-alexa-offer-to-master" }), svc, auth, proto, ver, rules))).annotate({
    identifier: "SendAlexaOfferToMasterRequest",
});
export const SendAlexaOfferToMasterResponse = 
/*@__PURE__*/ /*#__PURE__*/ S.suspend(() => S.Struct({ Answer: S.optional(S.String) })).annotate({
    identifier: "SendAlexaOfferToMasterResponse",
});
//# Errors
export class ClientLimitExceededException extends S.TaggedErrorClass()("ClientLimitExceededException", { Message: S.optional(S.String) }).pipe(C.withBadRequestError) {
}
export class InvalidArgumentException extends S.TaggedErrorClass()("InvalidArgumentException", { Message: S.optional(S.String) }).pipe(C.withBadRequestError) {
}
export class InvalidClientException extends S.TaggedErrorClass()("InvalidClientException", { message: S.optional(S.String) }).pipe(C.withBadRequestError) {
}
export class NotAuthorizedException extends S.TaggedErrorClass()("NotAuthorizedException", { Message: S.optional(S.String) }).pipe(C.withAuthError) {
}
export class ResourceNotFoundException extends S.TaggedErrorClass()("ResourceNotFoundException", { Message: S.optional(S.String) }).pipe(C.withBadRequestError) {
}
export class SessionExpiredException extends S.TaggedErrorClass()("SessionExpiredException", { message: S.optional(S.String) }).pipe(C.withBadRequestError) {
}
/**
 * Gets the Interactive Connectivity Establishment (ICE) server configuration
 * information, including URIs, username, and password which can be used to configure the
 * WebRTC connection. The ICE component uses this configuration information to setup the
 * WebRTC connection, including authenticating with the Traversal Using Relays around NAT
 * (TURN) relay server.
 *
 * TURN is a protocol that is used to improve the connectivity of peer-to-peer
 * applications. By providing a cloud-based relay service, TURN ensures that a connection
 * can be established even when one or more peers are incapable of a direct peer-to-peer
 * connection. For more information, see A REST API For
 * Access To TURN Services.
 *
 * You can invoke this API to establish a fallback mechanism in case either of the peers
 * is unable to establish a direct peer-to-peer connection over a signaling channel. You
 * must specify either a signaling channel ARN or the client ID in order to invoke this
 * API.
 */
export const getIceServerConfig = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetIceServerConfigRequest,
    output: GetIceServerConfigResponse,
    errors: [
        ClientLimitExceededException,
        InvalidArgumentException,
        InvalidClientException,
        NotAuthorizedException,
        ResourceNotFoundException,
        SessionExpiredException,
    ],
}));
/**
 * This API allows you to connect WebRTC-enabled devices with Alexa display devices. When
 * invoked, it sends the Alexa Session Description Protocol (SDP) offer to the master peer.
 * The offer is delivered as soon as the master is connected to the specified signaling
 * channel. This API returns the SDP answer from the connected master. If the master is not
 * connected to the signaling channel, redelivery requests are made until the message
 * expires.
 */
export const sendAlexaOfferToMaster = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: SendAlexaOfferToMasterRequest,
    output: SendAlexaOfferToMasterResponse,
    errors: [
        ClientLimitExceededException,
        InvalidArgumentException,
        NotAuthorizedException,
        ResourceNotFoundException,
    ],
}));
//# sourceMappingURL=kinesis-video-signaling.js.map