=> ({\n applyToStack: (clientStack) => {\n clientStack.addRelativeTo(throw200ExceptionsMiddleware(config), throw200ExceptionsMiddlewareOptions);\n },\n});\n","import { __extends } from \"tslib\";\nimport { CopyObjectOutput, CopyObjectRequest } from \"../models/models_0\";\nimport { deserializeAws_restXmlCopyObjectCommand, serializeAws_restXmlCopyObjectCommand, } from \"../protocols/Aws_restXml\";\nimport { getBucketEndpointPlugin } from \"@aws-sdk/middleware-bucket-endpoint\";\nimport { getThrow200ExceptionsPlugin } from \"@aws-sdk/middleware-sdk-s3\";\nimport { getSerdePlugin } from \"@aws-sdk/middleware-serde\";\nimport { getSsecPlugin } from \"@aws-sdk/middleware-ssec\";\nimport { Command as $Command } from \"@aws-sdk/smithy-client\";\n/**\n * Creates a copy of an object that is already stored in Amazon S3.
\n * \n * You can store individual objects of up to 5 TB in Amazon S3. You create a copy of your\n * object up to 5 GB in size in a single atomic operation using this API. However, to copy\n * an object greater than 5 GB, you must use the multipart upload Upload Part - Copy API.\n * For more information, see Copy Object Using the REST Multipart Upload API.
\n * \n * All copy requests must be authenticated. Additionally, you must have\n * read access to the source object and write\n * access to the destination bucket. For more information, see REST Authentication. Both the Region\n * that you want to copy the object from and the Region that you want to copy the object to\n * must be enabled for your account.
\n * A copy request might return an error when Amazon S3 receives the copy request or while Amazon S3\n * is copying the files. If the error occurs before the copy operation starts, you receive a\n * standard Amazon S3 error. If the error occurs during the copy operation, the error response is\n * embedded in the 200 OK
response. This means that a 200 OK
\n * response can contain either a success or an error. Design your application to parse the\n * contents of the response and handle it appropriately.
\n * If the copy is successful, you receive a response with information about the copied\n * object.
\n * \n * If the request is an HTTP 1.1 request, the response is chunk encoded. If it were not,\n * it would not contain the content-length, and you would need to read the entire\n * body.
\n * \n * The copy request charge is based on the storage class and Region that you specify for\n * the destination object. For pricing information, see Amazon S3 pricing.
\n * \n * Amazon S3 transfer acceleration does not support cross-Region copies. If you request a\n * cross-Region copy using a transfer acceleration endpoint, you get a 400 Bad\n * Request
error. For more information, see Transfer Acceleration.
\n * \n * \n * Metadata\n *
\n * When copying an object, you can preserve all metadata (default) or specify new metadata.\n * However, the ACL is not preserved and is set to private for the user making the request. To\n * override the default ACL setting, specify a new ACL when generating a copy request. For\n * more information, see Using ACLs.
\n * To specify whether you want the object metadata copied from the source object or\n * replaced with metadata provided in the request, you can optionally add the\n * x-amz-metadata-directive
header. When you grant permissions, you can use\n * the s3:x-amz-metadata-directive
condition key to enforce certain metadata\n * behavior when objects are uploaded. For more information, see Specifying Conditions in a\n * Policy in the Amazon S3 Developer Guide. For a complete list of\n * Amazon S3-specific condition keys, see Actions, Resources, and Condition Keys for\n * Amazon S3.
\n * \n * \n * x-amz-copy-source-if
Headers\n *
\n * To only copy an object under certain conditions, such as whether the Etag
\n * matches or whether the object was modified before or after a specified date, use the\n * following request parameters:
\n * \n * - \n *
\n * x-amz-copy-source-if-match
\n *
\n * \n * - \n *
\n * x-amz-copy-source-if-none-match
\n *
\n * \n * - \n *
\n * x-amz-copy-source-if-unmodified-since
\n *
\n * \n * - \n *
\n * x-amz-copy-source-if-modified-since
\n *
\n * \n *
\n * If both the x-amz-copy-source-if-match
and\n * x-amz-copy-source-if-unmodified-since
headers are present in the request\n * and evaluate as follows, Amazon S3 returns 200 OK
and copies the data:
\n * \n *\n * If both the x-amz-copy-source-if-none-match
and\n * x-amz-copy-source-if-modified-since
headers are present in the request and\n * evaluate as follows, Amazon S3 returns the 412 Precondition Failed
response\n * code:
\n * \n *\n * \n * All headers with the x-amz-
prefix, including\n * x-amz-copy-source
, must be signed.
\n * \n * \n * Server-side encryption\n *
\n * When you perform a CopyObject operation, you can optionally use the appropriate encryption-related headers to encrypt the object using server-side encryption with AWS managed encryption keys (SSE-S3 or SSE-KMS) or a customer-provided encryption key. With server-side encryption, Amazon S3 encrypts your data as it writes it to disks in its data centers and decrypts the data when you access it. For more information about server-side encryption, see Using\n * Server-Side Encryption.
\n * If a target object uses SSE-KMS, you can enable an S3 Bucket Key for the object. For more\n * information, see Amazon S3 Bucket Keys in the Amazon Simple Storage Service Developer Guide.
\n * \n * Access Control List (ACL)-Specific Request\n * Headers\n *
\n * When copying an object, you can optionally use headers to grant ACL-based permissions.\n * By default, all objects are private. Only the owner has full access control. When adding a\n * new object, you can grant permissions to individual AWS accounts or to predefined groups\n * defined by Amazon S3. These permissions are then added to the ACL on the object. For more\n * information, see Access Control List (ACL) Overview and Managing ACLs Using the REST\n * API.
\n *\n * \n * Storage Class Options\n *
\n * You can use the CopyObject
operation to change the storage class of an\n * object that is already stored in Amazon S3 using the StorageClass
parameter. For\n * more information, see Storage\n * Classes in the Amazon S3 Service Developer Guide.
\n * \n * Versioning\n *
\n * By default, x-amz-copy-source
identifies the current version of an object\n * to copy. If the current version is a delete marker, Amazon S3 behaves as if the object was\n * deleted. To copy a different version, use the versionId
subresource.
\n * If you enable versioning on the target bucket, Amazon S3 generates a unique version ID for\n * the object being copied. This version ID is different from the version ID of the source\n * object. Amazon S3 returns the version ID of the copied object in the\n * x-amz-version-id
response header in the response.
\n * If you do not enable versioning or suspend it on the target bucket, the version ID that\n * Amazon S3 generates is always null.
\n * If the source object's storage class is GLACIER, you must restore a copy of this object\n * before you can use it as a source object for the copy operation. For more information, see\n * RestoreObject.
\n * The following operations are related to CopyObject
:
\n * \n * For more information, see Copying\n * Objects.
\n */\nvar CopyObjectCommand = /** @class */ (function (_super) {\n __extends(CopyObjectCommand, _super);\n // Start section: command_properties\n // End section: command_properties\n function CopyObjectCommand(input) {\n var _this = \n // Start section: command_constructor\n _super.call(this) || this;\n _this.input = input;\n return _this;\n // End section: command_constructor\n }\n /**\n * @internal\n */\n CopyObjectCommand.prototype.resolveMiddleware = function (clientStack, configuration, options) {\n this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));\n this.middlewareStack.use(getThrow200ExceptionsPlugin(configuration));\n this.middlewareStack.use(getSsecPlugin(configuration));\n this.middlewareStack.use(getBucketEndpointPlugin(configuration));\n var stack = clientStack.concat(this.middlewareStack);\n var logger = configuration.logger;\n var clientName = \"S3Client\";\n var commandName = \"CopyObjectCommand\";\n var handlerExecutionContext = {\n logger: logger,\n clientName: clientName,\n commandName: commandName,\n inputFilterSensitiveLog: CopyObjectRequest.filterSensitiveLog,\n outputFilterSensitiveLog: CopyObjectOutput.filterSensitiveLog,\n };\n var requestHandler = configuration.requestHandler;\n return stack.resolve(function (request) {\n return requestHandler.handle(request.request, options || {});\n }, handlerExecutionContext);\n };\n CopyObjectCommand.prototype.serialize = function (input, context) {\n return serializeAws_restXmlCopyObjectCommand(input, context);\n };\n CopyObjectCommand.prototype.deserialize = function (output, context) {\n return deserializeAws_restXmlCopyObjectCommand(output, context);\n };\n return CopyObjectCommand;\n}($Command));\nexport { CopyObjectCommand };\n//# sourceMappingURL=CopyObjectCommand.js.map","import { __extends } from \"tslib\";\nimport { GetObjectOutput, GetObjectRequest } from \"../models/models_0\";\nimport { deserializeAws_restXmlGetObjectCommand, serializeAws_restXmlGetObjectCommand } from \"../protocols/Aws_restXml\";\nimport { getBucketEndpointPlugin } from \"@aws-sdk/middleware-bucket-endpoint\";\nimport { getSerdePlugin } from \"@aws-sdk/middleware-serde\";\nimport { getSsecPlugin } from \"@aws-sdk/middleware-ssec\";\nimport { Command as $Command } from \"@aws-sdk/smithy-client\";\n/**\n * Retrieves objects from Amazon S3. To use GET
, you must have READ
\n * access to the object. If you grant READ
access to the anonymous user, you can\n * return the object without using an authorization header.
\n *\n * An Amazon S3 bucket has no directory hierarchy such as you would find in a typical computer\n * file system. You can, however, create a logical hierarchy by using object key names that\n * imply a folder structure. For example, instead of naming an object sample.jpg
,\n * you can name it photos/2006/February/sample.jpg
.
\n *\n * To get an object from such a logical hierarchy, specify the full key name for the object\n * in the GET
operation. For a virtual hosted-style request example, if you have\n * the object photos/2006/February/sample.jpg
, specify the resource as\n * /photos/2006/February/sample.jpg
. For a path-style request example, if you\n * have the object photos/2006/February/sample.jpg
in the bucket named\n * examplebucket
, specify the resource as\n * /examplebucket/photos/2006/February/sample.jpg
. For more information about\n * request types, see HTTP Host Header Bucket Specification.
\n *\n * To distribute large files to many people, you can save bandwidth costs by using\n * BitTorrent. For more information, see Amazon S3\n * Torrent. For more information about returning the ACL of an object, see GetObjectAcl.
\n *\n * If the object you are retrieving is stored in the S3 Glacier or\n * S3 Glacier Deep Archive storage class, or S3 Intelligent-Tiering Archive or\n * S3 Intelligent-Tiering Deep Archive tiers, before you can retrieve the object you must first restore a\n * copy using RestoreObject. Otherwise, this operation returns an\n * InvalidObjectStateError
error. For information about restoring archived\n * objects, see Restoring Archived\n * Objects.
\n *\n * Encryption request headers, like x-amz-server-side-encryption
, should not\n * be sent for GET requests if your object uses server-side encryption with CMKs stored in AWS\n * KMS (SSE-KMS) or server-side encryption with Amazon S3–managed encryption keys (SSE-S3). If your\n * object does use these types of keys, you’ll get an HTTP 400 BadRequest error.
\n * If you encrypt an object by using server-side encryption with customer-provided\n * encryption keys (SSE-C) when you store the object in Amazon S3, then when you GET the object,\n * you must use the following headers:
\n * \n * - \n *
x-amz-server-side-encryption-customer-algorithm
\n * \n * - \n *
x-amz-server-side-encryption-customer-key
\n * \n * - \n *
x-amz-server-side-encryption-customer-key-MD5
\n * \n *
\n * For more information about SSE-C, see Server-Side Encryption (Using\n * Customer-Provided Encryption Keys).
\n *\n * Assuming you have permission to read object tags (permission for the\n * s3:GetObjectVersionTagging
action), the response also returns the\n * x-amz-tagging-count
header that provides the count of number of tags\n * associated with the object. You can use GetObjectTagging to retrieve\n * the tag set associated with an object.
\n *\n * \n * Permissions\n *
\n * You need the s3:GetObject
permission for this operation. For more\n * information, see Specifying Permissions\n * in a Policy. If the object you request does not exist, the error Amazon S3 returns\n * depends on whether you also have the s3:ListBucket
permission.
\n * \n * - \n *
If you have the s3:ListBucket
permission on the bucket, Amazon S3 will\n * return an HTTP status code 404 (\"no such key\") error.
\n * \n * - \n *
If you don’t have the s3:ListBucket
permission, Amazon S3 will return an\n * HTTP status code 403 (\"access denied\") error.
\n * \n *
\n *\n *\n * \n * Versioning\n *
\n * By default, the GET operation returns the current version of an object. To return a\n * different version, use the versionId
subresource.
\n *\n * \n * If the current version of the object is a delete marker, Amazon S3 behaves as if the\n * object was deleted and includes x-amz-delete-marker: true
in the\n * response.
\n * \n *\n *\n * For more information about versioning, see PutBucketVersioning.
\n *\n * \n * Overriding Response Header Values\n *
\n * There are times when you want to override certain response header values in a GET\n * response. For example, you might override the Content-Disposition response header value in\n * your GET request.
\n *\n * You can override values for a set of response headers using the following query\n * parameters. These response header values are sent only on a successful request, that is,\n * when status code 200 OK is returned. The set of headers you can override using these\n * parameters is a subset of the headers that Amazon S3 accepts when you create an object. The\n * response headers that you can override for the GET response are Content-Type
,\n * Content-Language
, Expires
, Cache-Control
,\n * Content-Disposition
, and Content-Encoding
. To override these\n * header values in the GET response, you use the following request parameters.
\n *\n * \n * You must sign the request, either using an Authorization header or a presigned URL,\n * when using these parameters. They cannot be used with an unsigned (anonymous)\n * request.
\n * \n * \n * - \n *
\n * response-content-type
\n *
\n * \n * - \n *
\n * response-content-language
\n *
\n * \n * - \n *
\n * response-expires
\n *
\n * \n * - \n *
\n * response-cache-control
\n *
\n * \n * - \n *
\n * response-content-disposition
\n *
\n * \n * - \n *
\n * response-content-encoding
\n *
\n * \n *
\n *\n * \n * Additional Considerations about Request Headers\n *
\n *\n * If both of the If-Match
and If-Unmodified-Since
headers are\n * present in the request as follows: If-Match
condition evaluates to\n * true
, and; If-Unmodified-Since
condition evaluates to\n * false
; then, S3 returns 200 OK and the data requested.
\n *\n * If both of the If-None-Match
and If-Modified-Since
headers are\n * present in the request as follows: If-None-Match
condition evaluates to\n * false
, and; If-Modified-Since
condition evaluates to\n * true
; then, S3 returns 304 Not Modified response code.
\n *\n * For more information about conditional requests, see RFC 7232.
\n *\n * The following operations are related to GetObject
:
\n * \n */\nvar GetObjectCommand = /** @class */ (function (_super) {\n __extends(GetObjectCommand, _super);\n // Start section: command_properties\n // End section: command_properties\n function GetObjectCommand(input) {\n var _this = \n // Start section: command_constructor\n _super.call(this) || this;\n _this.input = input;\n return _this;\n // End section: command_constructor\n }\n /**\n * @internal\n */\n GetObjectCommand.prototype.resolveMiddleware = function (clientStack, configuration, options) {\n this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));\n this.middlewareStack.use(getSsecPlugin(configuration));\n this.middlewareStack.use(getBucketEndpointPlugin(configuration));\n var stack = clientStack.concat(this.middlewareStack);\n var logger = configuration.logger;\n var clientName = \"S3Client\";\n var commandName = \"GetObjectCommand\";\n var handlerExecutionContext = {\n logger: logger,\n clientName: clientName,\n commandName: commandName,\n inputFilterSensitiveLog: GetObjectRequest.filterSensitiveLog,\n outputFilterSensitiveLog: GetObjectOutput.filterSensitiveLog,\n };\n var requestHandler = configuration.requestHandler;\n return stack.resolve(function (request) {\n return requestHandler.handle(request.request, options || {});\n }, handlerExecutionContext);\n };\n GetObjectCommand.prototype.serialize = function (input, context) {\n return serializeAws_restXmlGetObjectCommand(input, context);\n };\n GetObjectCommand.prototype.deserialize = function (output, context) {\n return deserializeAws_restXmlGetObjectCommand(output, context);\n };\n return GetObjectCommand;\n}($Command));\nexport { GetObjectCommand };\n//# sourceMappingURL=GetObjectCommand.js.map","import { __extends } from \"tslib\";\nimport { DeleteObjectOutput, DeleteObjectRequest } from \"../models/models_0\";\nimport { deserializeAws_restXmlDeleteObjectCommand, serializeAws_restXmlDeleteObjectCommand, } from \"../protocols/Aws_restXml\";\nimport { getBucketEndpointPlugin } from \"@aws-sdk/middleware-bucket-endpoint\";\nimport { getSerdePlugin } from \"@aws-sdk/middleware-serde\";\nimport { Command as $Command } from \"@aws-sdk/smithy-client\";\n/**\n * Removes the null version (if there is one) of an object and inserts a delete marker,\n * which becomes the latest version of the object. If there isn't a null version, Amazon S3 does\n * not remove any objects.
\n *\n * To remove a specific version, you must be the bucket owner and you must use the version\n * Id subresource. Using this subresource permanently deletes the version. If the object\n * deleted is a delete marker, Amazon S3 sets the response header,\n * x-amz-delete-marker
, to true.
\n *\n * If the object you want to delete is in a bucket where the bucket versioning\n * configuration is MFA Delete enabled, you must include the x-amz-mfa
request\n * header in the DELETE versionId
request. Requests that include\n * x-amz-mfa
must use HTTPS.
\n *\n * For more information about MFA Delete, see Using MFA Delete. To see sample requests that use versioning, see Sample Request.
\n *\n * You can delete objects by explicitly calling the DELETE Object API or configure its\n * lifecycle (PutBucketLifecycle) to\n * enable Amazon S3 to remove them for you. If you want to block users or accounts from removing or\n * deleting objects from your bucket, you must deny them the s3:DeleteObject
,\n * s3:DeleteObjectVersion
, and s3:PutLifeCycleConfiguration
\n * actions.
\n *\n * The following operation is related to DeleteObject
:
\n * \n */\nvar DeleteObjectCommand = /** @class */ (function (_super) {\n __extends(DeleteObjectCommand, _super);\n // Start section: command_properties\n // End section: command_properties\n function DeleteObjectCommand(input) {\n var _this = \n // Start section: command_constructor\n _super.call(this) || this;\n _this.input = input;\n return _this;\n // End section: command_constructor\n }\n /**\n * @internal\n */\n DeleteObjectCommand.prototype.resolveMiddleware = function (clientStack, configuration, options) {\n this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));\n this.middlewareStack.use(getBucketEndpointPlugin(configuration));\n var stack = clientStack.concat(this.middlewareStack);\n var logger = configuration.logger;\n var clientName = \"S3Client\";\n var commandName = \"DeleteObjectCommand\";\n var handlerExecutionContext = {\n logger: logger,\n clientName: clientName,\n commandName: commandName,\n inputFilterSensitiveLog: DeleteObjectRequest.filterSensitiveLog,\n outputFilterSensitiveLog: DeleteObjectOutput.filterSensitiveLog,\n };\n var requestHandler = configuration.requestHandler;\n return stack.resolve(function (request) {\n return requestHandler.handle(request.request, options || {});\n }, handlerExecutionContext);\n };\n DeleteObjectCommand.prototype.serialize = function (input, context) {\n return serializeAws_restXmlDeleteObjectCommand(input, context);\n };\n DeleteObjectCommand.prototype.deserialize = function (output, context) {\n return deserializeAws_restXmlDeleteObjectCommand(output, context);\n };\n return DeleteObjectCommand;\n}($Command));\nexport { DeleteObjectCommand };\n//# sourceMappingURL=DeleteObjectCommand.js.map","import { __extends } from \"tslib\";\nimport { ListObjectsOutput, ListObjectsRequest } from \"../models/models_0\";\nimport { deserializeAws_restXmlListObjectsCommand, serializeAws_restXmlListObjectsCommand, } from \"../protocols/Aws_restXml\";\nimport { getBucketEndpointPlugin } from \"@aws-sdk/middleware-bucket-endpoint\";\nimport { getSerdePlugin } from \"@aws-sdk/middleware-serde\";\nimport { Command as $Command } from \"@aws-sdk/smithy-client\";\n/**\n * Returns some or all (up to 1,000) of the objects in a bucket. You can use the request\n * parameters as selection criteria to return a subset of the objects in a bucket. A 200 OK\n * response can contain valid or invalid XML. Be sure to design your application to parse the\n * contents of the response and handle it appropriately.
\n * \n * This API has been revised. We recommend that you use the newer version, ListObjectsV2, when developing applications. For backward compatibility,\n * Amazon S3 continues to support ListObjects
.
\n * \n *\n *\n * The following operations are related to ListObjects
:
\n * \n */\nvar ListObjectsCommand = /** @class */ (function (_super) {\n __extends(ListObjectsCommand, _super);\n // Start section: command_properties\n // End section: command_properties\n function ListObjectsCommand(input) {\n var _this = \n // Start section: command_constructor\n _super.call(this) || this;\n _this.input = input;\n return _this;\n // End section: command_constructor\n }\n /**\n * @internal\n */\n ListObjectsCommand.prototype.resolveMiddleware = function (clientStack, configuration, options) {\n this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));\n this.middlewareStack.use(getBucketEndpointPlugin(configuration));\n var stack = clientStack.concat(this.middlewareStack);\n var logger = configuration.logger;\n var clientName = \"S3Client\";\n var commandName = \"ListObjectsCommand\";\n var handlerExecutionContext = {\n logger: logger,\n clientName: clientName,\n commandName: commandName,\n inputFilterSensitiveLog: ListObjectsRequest.filterSensitiveLog,\n outputFilterSensitiveLog: ListObjectsOutput.filterSensitiveLog,\n };\n var requestHandler = configuration.requestHandler;\n return stack.resolve(function (request) {\n return requestHandler.handle(request.request, options || {});\n }, handlerExecutionContext);\n };\n ListObjectsCommand.prototype.serialize = function (input, context) {\n return serializeAws_restXmlListObjectsCommand(input, context);\n };\n ListObjectsCommand.prototype.deserialize = function (output, context) {\n return deserializeAws_restXmlListObjectsCommand(output, context);\n };\n return ListObjectsCommand;\n}($Command));\nexport { ListObjectsCommand };\n//# sourceMappingURL=ListObjectsCommand.js.map","import { Int64 as IInt64 } from \"@aws-sdk/types\";\nimport { toHex } from \"@aws-sdk/util-hex-encoding\";\n\nexport interface Int64 extends IInt64 {}\n\n/**\n * A lossless representation of a signed, 64-bit integer. Instances of this\n * class may be used in arithmetic expressions as if they were numeric\n * primitives, but the binary representation will be preserved unchanged as the\n * `bytes` property of the object. The bytes should be encoded as big-endian,\n * two's complement integers.\n */\nexport class Int64 {\n constructor(readonly bytes: Uint8Array) {\n if (bytes.byteLength !== 8) {\n throw new Error(\"Int64 buffers must be exactly 8 bytes\");\n }\n }\n\n static fromNumber(number: number): Int64 {\n if (number > 9223372036854775807 || number < -9223372036854775808) {\n throw new Error(`${number} is too large (or, if negative, too small) to represent as an Int64`);\n }\n\n const bytes = new Uint8Array(8);\n for (let i = 7, remaining = Math.abs(Math.round(number)); i > -1 && remaining > 0; i--, remaining /= 256) {\n bytes[i] = remaining;\n }\n\n if (number < 0) {\n negate(bytes);\n }\n\n return new Int64(bytes);\n }\n\n /**\n * Called implicitly by infix arithmetic operators.\n */\n valueOf(): number {\n const bytes = this.bytes.slice(0);\n const negative = bytes[0] & 0b10000000;\n if (negative) {\n negate(bytes);\n }\n\n return parseInt(toHex(bytes), 16) * (negative ? -1 : 1);\n }\n\n toString() {\n return String(this.valueOf());\n }\n}\n\nfunction negate(bytes: Uint8Array): void {\n for (let i = 0; i < 8; i++) {\n bytes[i] ^= 0xff;\n }\n\n for (let i = 7; i > -1; i--) {\n bytes[i]++;\n if (bytes[i] !== 0) break;\n }\n}\n","import { Decoder, Encoder, MessageHeaders, MessageHeaderValue } from \"@aws-sdk/types\";\nimport { fromHex, toHex } from \"@aws-sdk/util-hex-encoding\";\n\nimport { Int64 } from \"./Int64\";\n\n/**\n * @internal\n */\nexport class HeaderMarshaller {\n constructor(private readonly toUtf8: Encoder, private readonly fromUtf8: Decoder) {}\n\n format(headers: MessageHeaders): Uint8Array {\n const chunks: Array = [];\n\n for (const headerName of Object.keys(headers)) {\n const bytes = this.fromUtf8(headerName);\n chunks.push(Uint8Array.from([bytes.byteLength]), bytes, this.formatHeaderValue(headers[headerName]));\n }\n\n const out = new Uint8Array(chunks.reduce((carry, bytes) => carry + bytes.byteLength, 0));\n let position = 0;\n for (const chunk of chunks) {\n out.set(chunk, position);\n position += chunk.byteLength;\n }\n\n return out;\n }\n\n private formatHeaderValue(header: MessageHeaderValue): Uint8Array {\n switch (header.type) {\n case \"boolean\":\n return Uint8Array.from([header.value ? HEADER_VALUE_TYPE.boolTrue : HEADER_VALUE_TYPE.boolFalse]);\n case \"byte\":\n return Uint8Array.from([HEADER_VALUE_TYPE.byte, header.value]);\n case \"short\":\n const shortView = new DataView(new ArrayBuffer(3));\n shortView.setUint8(0, HEADER_VALUE_TYPE.short);\n shortView.setInt16(1, header.value, false);\n return new Uint8Array(shortView.buffer);\n case \"integer\":\n const intView = new DataView(new ArrayBuffer(5));\n intView.setUint8(0, HEADER_VALUE_TYPE.integer);\n intView.setInt32(1, header.value, false);\n return new Uint8Array(intView.buffer);\n case \"long\":\n const longBytes = new Uint8Array(9);\n longBytes[0] = HEADER_VALUE_TYPE.long;\n longBytes.set(header.value.bytes, 1);\n return longBytes;\n case \"binary\":\n const binView = new DataView(new ArrayBuffer(3 + header.value.byteLength));\n binView.setUint8(0, HEADER_VALUE_TYPE.byteArray);\n binView.setUint16(1, header.value.byteLength, false);\n const binBytes = new Uint8Array(binView.buffer);\n binBytes.set(header.value, 3);\n return binBytes;\n case \"string\":\n const utf8Bytes = this.fromUtf8(header.value);\n const strView = new DataView(new ArrayBuffer(3 + utf8Bytes.byteLength));\n strView.setUint8(0, HEADER_VALUE_TYPE.string);\n strView.setUint16(1, utf8Bytes.byteLength, false);\n const strBytes = new Uint8Array(strView.buffer);\n strBytes.set(utf8Bytes, 3);\n return strBytes;\n case \"timestamp\":\n const tsBytes = new Uint8Array(9);\n tsBytes[0] = HEADER_VALUE_TYPE.timestamp;\n tsBytes.set(Int64.fromNumber(header.value.valueOf()).bytes, 1);\n return tsBytes;\n case \"uuid\":\n if (!UUID_PATTERN.test(header.value)) {\n throw new Error(`Invalid UUID received: ${header.value}`);\n }\n\n const uuidBytes = new Uint8Array(17);\n uuidBytes[0] = HEADER_VALUE_TYPE.uuid;\n uuidBytes.set(fromHex(header.value.replace(/\\-/g, \"\")), 1);\n return uuidBytes;\n }\n }\n\n parse(headers: DataView): MessageHeaders {\n const out: MessageHeaders = {};\n let position = 0;\n\n while (position < headers.byteLength) {\n const nameLength = headers.getUint8(position++);\n const name = this.toUtf8(new Uint8Array(headers.buffer, headers.byteOffset + position, nameLength));\n position += nameLength;\n\n switch (headers.getUint8(position++)) {\n case HEADER_VALUE_TYPE.boolTrue:\n out[name] = {\n type: BOOLEAN_TAG,\n value: true,\n };\n break;\n case HEADER_VALUE_TYPE.boolFalse:\n out[name] = {\n type: BOOLEAN_TAG,\n value: false,\n };\n break;\n case HEADER_VALUE_TYPE.byte:\n out[name] = {\n type: BYTE_TAG,\n value: headers.getInt8(position++),\n };\n break;\n case HEADER_VALUE_TYPE.short:\n out[name] = {\n type: SHORT_TAG,\n value: headers.getInt16(position, false),\n };\n position += 2;\n break;\n case HEADER_VALUE_TYPE.integer:\n out[name] = {\n type: INT_TAG,\n value: headers.getInt32(position, false),\n };\n position += 4;\n break;\n case HEADER_VALUE_TYPE.long:\n out[name] = {\n type: LONG_TAG,\n value: new Int64(new Uint8Array(headers.buffer, headers.byteOffset + position, 8)),\n };\n position += 8;\n break;\n case HEADER_VALUE_TYPE.byteArray:\n const binaryLength = headers.getUint16(position, false);\n position += 2;\n out[name] = {\n type: BINARY_TAG,\n value: new Uint8Array(headers.buffer, headers.byteOffset + position, binaryLength),\n };\n position += binaryLength;\n break;\n case HEADER_VALUE_TYPE.string:\n const stringLength = headers.getUint16(position, false);\n position += 2;\n out[name] = {\n type: STRING_TAG,\n value: this.toUtf8(new Uint8Array(headers.buffer, headers.byteOffset + position, stringLength)),\n };\n position += stringLength;\n break;\n case HEADER_VALUE_TYPE.timestamp:\n out[name] = {\n type: TIMESTAMP_TAG,\n value: new Date(new Int64(new Uint8Array(headers.buffer, headers.byteOffset + position, 8)).valueOf()),\n };\n position += 8;\n break;\n case HEADER_VALUE_TYPE.uuid:\n const uuidBytes = new Uint8Array(headers.buffer, headers.byteOffset + position, 16);\n position += 16;\n out[name] = {\n type: UUID_TAG,\n value: `${toHex(uuidBytes.subarray(0, 4))}-${toHex(uuidBytes.subarray(4, 6))}-${toHex(\n uuidBytes.subarray(6, 8)\n )}-${toHex(uuidBytes.subarray(8, 10))}-${toHex(uuidBytes.subarray(10))}`,\n };\n break;\n default:\n throw new Error(`Unrecognized header type tag`);\n }\n }\n\n return out;\n }\n}\n\nconst enum HEADER_VALUE_TYPE {\n boolTrue = 0,\n boolFalse,\n byte,\n short,\n integer,\n long,\n byteArray,\n string,\n timestamp,\n uuid,\n}\n\nconst BOOLEAN_TAG = \"boolean\";\nconst BYTE_TAG = \"byte\";\nconst SHORT_TAG = \"short\";\nconst INT_TAG = \"integer\";\nconst LONG_TAG = \"long\";\nconst BINARY_TAG = \"binary\";\nconst STRING_TAG = \"string\";\nconst TIMESTAMP_TAG = \"timestamp\";\nconst UUID_TAG = \"uuid\";\n\nconst UUID_PATTERN = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;\n","import { EventStreamMarshaller as EventMarshaller } from \"@aws-sdk/eventstream-marshaller\";\nimport { EventStreamMarshaller as UniversalEventStreamMarshaller } from \"@aws-sdk/eventstream-serde-universal\";\nimport { Decoder, Encoder, EventStreamMarshaller as IEventStreamMarshaller, Message } from \"@aws-sdk/types\";\n\nimport { iterableToReadableStream, readableStreamtoIterable } from \"./utils\";\n\nexport interface EventStreamMarshaller extends IEventStreamMarshaller {}\n\nexport interface EventStreamMarshallerOptions {\n utf8Encoder: Encoder;\n utf8Decoder: Decoder;\n}\n\n/**\n * Utility class used to serialize and deserialize event streams in\n * browsers and ReactNative.\n *\n * In browsers where ReadableStream API is available:\n * * deserialize from ReadableStream to an async iterable of output structure\n * * serialize from async iterable of input structure to ReadableStream\n * In ReactNative where only async iterable API is available:\n * * deserialize from async iterable of binaries to async iterable of output structure\n * * serialize from async iterable of input structure to async iterable of binaries\n *\n * We use ReadableStream API in browsers because of the consistency with other\n * streaming operations, where ReadableStream API is used to denote streaming data.\n * Whereas in ReactNative, ReadableStream API is not available, we use async iterable\n * for streaming data although it has lower throughput.\n */\nexport class EventStreamMarshaller {\n private readonly eventMarshaller: EventMarshaller;\n private readonly universalMarshaller: UniversalEventStreamMarshaller;\n constructor({ utf8Encoder, utf8Decoder }: EventStreamMarshallerOptions) {\n this.eventMarshaller = new EventMarshaller(utf8Encoder, utf8Decoder);\n this.universalMarshaller = new UniversalEventStreamMarshaller({\n utf8Decoder,\n utf8Encoder,\n });\n }\n\n deserialize(\n body: ReadableStream | AsyncIterable,\n deserializer: (input: { [event: string]: Message }) => Promise\n ): AsyncIterable {\n const bodyIterable = isReadableStream(body) ? readableStreamtoIterable(body) : body;\n return this.universalMarshaller.deserialize(bodyIterable, deserializer);\n }\n\n /**\n * Generate a stream that serialize events into stream of binary chunks;\n *\n * Caveat is that streaming request payload doesn't work on browser with native\n * xhr or fetch handler currently because they don't support upload streaming.\n * reference:\n * * https://bugs.chromium.org/p/chromium/issues/detail?id=688906\n * * https://bugzilla.mozilla.org/show_bug.cgi?id=1387483\n *\n */\n serialize(input: AsyncIterable, serializer: (event: T) => Message): ReadableStream | AsyncIterable {\n const serialziedIterable = this.universalMarshaller.serialize(input, serializer);\n return typeof ReadableStream === \"function\" ? iterableToReadableStream(serialziedIterable) : serialziedIterable;\n }\n}\n\nconst isReadableStream = (body: any): body is ReadableStream =>\n typeof ReadableStream === \"function\" && body instanceof ReadableStream;\n","import { Crc32 } from \"@aws-crypto/crc32\";\n\n// All prelude components are unsigned, 32-bit integers\nconst PRELUDE_MEMBER_LENGTH = 4;\n// The prelude consists of two components\nconst PRELUDE_LENGTH = PRELUDE_MEMBER_LENGTH * 2;\n// Checksums are always CRC32 hashes.\nconst CHECKSUM_LENGTH = 4;\n// Messages must include a full prelude, a prelude checksum, and a message checksum\nconst MINIMUM_MESSAGE_LENGTH = PRELUDE_LENGTH + CHECKSUM_LENGTH * 2;\n\n/**\n * @internal\n */\nexport interface MessageParts {\n headers: DataView;\n body: Uint8Array;\n}\n\n/**\n * @internal\n */\nexport function splitMessage({ byteLength, byteOffset, buffer }: ArrayBufferView): MessageParts {\n if (byteLength < MINIMUM_MESSAGE_LENGTH) {\n throw new Error(\"Provided message too short to accommodate event stream message overhead\");\n }\n\n const view = new DataView(buffer, byteOffset, byteLength);\n\n const messageLength = view.getUint32(0, false);\n\n if (byteLength !== messageLength) {\n throw new Error(\"Reported message length does not match received message length\");\n }\n\n const headerLength = view.getUint32(PRELUDE_MEMBER_LENGTH, false);\n const expectedPreludeChecksum = view.getUint32(PRELUDE_LENGTH, false);\n const expectedMessageChecksum = view.getUint32(byteLength - CHECKSUM_LENGTH, false);\n\n const checksummer = new Crc32().update(new Uint8Array(buffer, byteOffset, PRELUDE_LENGTH));\n if (expectedPreludeChecksum !== checksummer.digest()) {\n throw new Error(\n `The prelude checksum specified in the message (${expectedPreludeChecksum}) does not match the calculated CRC32 checksum (${checksummer.digest()})`\n );\n }\n\n checksummer.update(\n new Uint8Array(buffer, byteOffset + PRELUDE_LENGTH, byteLength - (PRELUDE_LENGTH + CHECKSUM_LENGTH))\n );\n if (expectedMessageChecksum !== checksummer.digest()) {\n throw new Error(\n `The message checksum (${checksummer.digest()}) did not match the expected value of ${expectedMessageChecksum}`\n );\n }\n\n return {\n headers: new DataView(buffer, byteOffset + PRELUDE_LENGTH + CHECKSUM_LENGTH, headerLength),\n body: new Uint8Array(\n buffer,\n byteOffset + PRELUDE_LENGTH + CHECKSUM_LENGTH + headerLength,\n messageLength - headerLength - (PRELUDE_LENGTH + CHECKSUM_LENGTH + CHECKSUM_LENGTH)\n ),\n };\n}\n","import { EventStreamMarshaller as EventMarshaller } from \"@aws-sdk/eventstream-marshaller\";\nimport { Encoder, Message } from \"@aws-sdk/types\";\n\nexport type UnmarshalledStreamOptions = {\n eventMarshaller: EventMarshaller;\n deserializer: (input: { [name: string]: Message }) => Promise;\n toUtf8: Encoder;\n};\n\nexport function getUnmarshalledStream(\n source: AsyncIterable,\n options: UnmarshalledStreamOptions\n): AsyncIterable {\n return {\n [Symbol.asyncIterator]: async function* () {\n for await (const chunk of source) {\n const message = options.eventMarshaller.unmarshall(chunk);\n const { value: messageType } = message.headers[\":message-type\"];\n if (messageType === \"error\") {\n // Unmodeled exception in event\n const unmodeledError = new Error((message.headers[\":error-message\"].value as string) || \"UnknownError\");\n unmodeledError.name = message.headers[\":error-code\"].value as string;\n throw unmodeledError;\n } else if (messageType === \"exception\") {\n // For modeled exception, push it to deserializer and throw after deserializing\n const code = message.headers[\":exception-type\"].value as string;\n const exception = { [code]: message };\n // Get parsed exception event in key(error code) value(structured error) pair.\n const deserializedException = await options.deserializer(exception);\n if (deserializedException.$unknown) {\n //this is an unmodeled exception then try parsing it with best effort\n const error = new Error(options.toUtf8(message.body));\n error.name = code;\n throw error;\n }\n throw deserializedException[code];\n } else if (messageType === \"event\") {\n const event = {\n [message.headers[\":event-type\"].value as string]: message,\n };\n const deserialized = await options.deserializer(event);\n if (deserialized.$unknown) continue;\n yield deserialized;\n } else {\n throw Error(`Unrecognizable event type: ${message.headers[\":event-type\"].value}`);\n }\n }\n },\n };\n}\n","export function getChunkedStream(source: AsyncIterable): AsyncIterable {\n let currentMessageTotalLength = 0;\n let currentMessagePendingLength = 0;\n let currentMessage: Uint8Array | null = null;\n let messageLengthBuffer: Uint8Array | null = null;\n const allocateMessage = (size: number) => {\n if (typeof size !== \"number\") {\n throw new Error(\"Attempted to allocate an event message where size was not a number: \" + size);\n }\n currentMessageTotalLength = size;\n currentMessagePendingLength = 4;\n currentMessage = new Uint8Array(size);\n const currentMessageView = new DataView(currentMessage.buffer);\n currentMessageView.setUint32(0, size, false); //set big-endian Uint32 to 0~3 bytes\n };\n\n const iterator = async function* () {\n const sourceIterator = source[Symbol.asyncIterator]();\n while (true) {\n const { value, done } = await sourceIterator.next();\n if (done) {\n if (!currentMessageTotalLength) {\n return;\n } else if (currentMessageTotalLength === currentMessagePendingLength) {\n yield currentMessage as Uint8Array;\n } else {\n throw new Error(\"Truncated event message received.\");\n }\n return;\n }\n\n const chunkLength = value.length;\n let currentOffset = 0;\n\n while (currentOffset < chunkLength) {\n // create new message if necessary\n if (!currentMessage) {\n // working on a new message, determine total length\n const bytesRemaining = chunkLength - currentOffset;\n // prevent edge case where total length spans 2 chunks\n if (!messageLengthBuffer) {\n messageLengthBuffer = new Uint8Array(4);\n }\n const numBytesForTotal = Math.min(\n 4 - currentMessagePendingLength, // remaining bytes to fill the messageLengthBuffer\n bytesRemaining // bytes left in chunk\n );\n\n messageLengthBuffer.set(\n // @ts-ignore error TS2532: Object is possibly 'undefined' for value\n value.slice(currentOffset, currentOffset + numBytesForTotal),\n currentMessagePendingLength\n );\n\n currentMessagePendingLength += numBytesForTotal;\n currentOffset += numBytesForTotal;\n\n if (currentMessagePendingLength < 4) {\n // not enough information to create the current message\n break;\n }\n allocateMessage(new DataView(messageLengthBuffer.buffer).getUint32(0, false));\n messageLengthBuffer = null;\n }\n\n // write data into current message\n const numBytesToWrite = Math.min(\n currentMessageTotalLength - currentMessagePendingLength, // number of bytes left to complete message\n chunkLength - currentOffset // number of bytes left in the original chunk\n );\n currentMessage!.set(\n // @ts-ignore error TS2532: Object is possibly 'undefined' for value\n value.slice(currentOffset, currentOffset + numBytesToWrite),\n currentMessagePendingLength\n );\n currentMessagePendingLength += numBytesToWrite;\n currentOffset += numBytesToWrite;\n\n // check if a message is ready to be pushed\n if (currentMessageTotalLength && currentMessageTotalLength === currentMessagePendingLength) {\n // push out the message\n yield currentMessage as Uint8Array;\n // cleanup\n currentMessage = null;\n currentMessageTotalLength = 0;\n currentMessagePendingLength = 0;\n }\n }\n }\n };\n\n return {\n [Symbol.asyncIterator]: iterator,\n };\n}\n","/**\n * A util function converting ReadableStream into an async iterable.\n * Reference: https://jakearchibald.com/2017/async-iterators-and-generators/#making-streams-iterate\n */\nexport const readableStreamtoIterable = (readableStream: ReadableStream): AsyncIterable => ({\n [Symbol.asyncIterator]: async function* () {\n const reader = readableStream.getReader();\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) return;\n yield value as T;\n }\n } finally {\n reader.releaseLock();\n }\n },\n});\n\n/**\n * A util function converting async iterable to a ReadableStream.\n */\nexport const iterableToReadableStream = (asyncIterable: AsyncIterable): ReadableStream => {\n const iterator = asyncIterable[Symbol.asyncIterator]();\n return new ReadableStream({\n async pull(controller) {\n const { done, value } = await iterator.next();\n if (done) {\n return controller.close();\n }\n controller.enqueue(value);\n },\n });\n};\n","import { __assign } from \"tslib\";\n// Partition default templates\nvar AWS_TEMPLATE = \"cognito-identity.{region}.amazonaws.com\";\nvar AWS_CN_TEMPLATE = \"cognito-identity.{region}.amazonaws.com.cn\";\nvar AWS_ISO_TEMPLATE = \"cognito-identity.{region}.c2s.ic.gov\";\nvar AWS_ISO_B_TEMPLATE = \"cognito-identity.{region}.sc2s.sgov.gov\";\nvar AWS_US_GOV_TEMPLATE = \"cognito-identity.{region}.amazonaws.com\";\n// Partition regions\nvar AWS_REGIONS = new Set([\n \"af-south-1\",\n \"ap-east-1\",\n \"ap-northeast-1\",\n \"ap-northeast-2\",\n \"ap-south-1\",\n \"ap-southeast-1\",\n \"ap-southeast-2\",\n \"ca-central-1\",\n \"eu-central-1\",\n \"eu-north-1\",\n \"eu-south-1\",\n \"eu-west-1\",\n \"eu-west-2\",\n \"eu-west-3\",\n \"me-south-1\",\n \"sa-east-1\",\n \"us-east-1\",\n \"us-east-2\",\n \"us-west-1\",\n \"us-west-2\",\n]);\nvar AWS_CN_REGIONS = new Set([\"cn-north-1\", \"cn-northwest-1\"]);\nvar AWS_ISO_REGIONS = new Set([\"us-iso-east-1\"]);\nvar AWS_ISO_B_REGIONS = new Set([\"us-isob-east-1\"]);\nvar AWS_US_GOV_REGIONS = new Set([\"us-gov-east-1\", \"us-gov-west-1\"]);\nexport var defaultRegionInfoProvider = function (region, options) {\n var regionInfo = undefined;\n switch (region) {\n // First, try to match exact region names.\n case \"ap-northeast-1\":\n regionInfo = {\n hostname: \"cognito-identity.ap-northeast-1.amazonaws.com\",\n partition: \"aws\",\n };\n break;\n case \"ap-northeast-2\":\n regionInfo = {\n hostname: \"cognito-identity.ap-northeast-2.amazonaws.com\",\n partition: \"aws\",\n };\n break;\n case \"ap-south-1\":\n regionInfo = {\n hostname: \"cognito-identity.ap-south-1.amazonaws.com\",\n partition: \"aws\",\n };\n break;\n case \"ap-southeast-1\":\n regionInfo = {\n hostname: \"cognito-identity.ap-southeast-1.amazonaws.com\",\n partition: \"aws\",\n };\n break;\n case \"ap-southeast-2\":\n regionInfo = {\n hostname: \"cognito-identity.ap-southeast-2.amazonaws.com\",\n partition: \"aws\",\n };\n break;\n case \"ca-central-1\":\n regionInfo = {\n hostname: \"cognito-identity.ca-central-1.amazonaws.com\",\n partition: \"aws\",\n };\n break;\n case \"cn-north-1\":\n regionInfo = {\n hostname: \"cognito-identity.cn-north-1.amazonaws.com.cn\",\n partition: \"aws-cn\",\n };\n break;\n case \"eu-central-1\":\n regionInfo = {\n hostname: \"cognito-identity.eu-central-1.amazonaws.com\",\n partition: \"aws\",\n };\n break;\n case \"eu-north-1\":\n regionInfo = {\n hostname: \"cognito-identity.eu-north-1.amazonaws.com\",\n partition: \"aws\",\n };\n break;\n case \"eu-west-1\":\n regionInfo = {\n hostname: \"cognito-identity.eu-west-1.amazonaws.com\",\n partition: \"aws\",\n };\n break;\n case \"eu-west-2\":\n regionInfo = {\n hostname: \"cognito-identity.eu-west-2.amazonaws.com\",\n partition: \"aws\",\n };\n break;\n case \"eu-west-3\":\n regionInfo = {\n hostname: \"cognito-identity.eu-west-3.amazonaws.com\",\n partition: \"aws\",\n };\n break;\n case \"fips-us-east-1\":\n regionInfo = {\n hostname: \"cognito-identity-fips.us-east-1.amazonaws.com\",\n partition: \"aws\",\n signingRegion: \"us-east-1\",\n };\n break;\n case \"fips-us-east-2\":\n regionInfo = {\n hostname: \"cognito-identity-fips.us-east-2.amazonaws.com\",\n partition: \"aws\",\n signingRegion: \"us-east-2\",\n };\n break;\n case \"fips-us-gov-west-1\":\n regionInfo = {\n hostname: \"cognito-identity-fips.us-gov-west-1.amazonaws.com\",\n partition: \"aws-us-gov\",\n signingRegion: \"us-gov-west-1\",\n };\n break;\n case \"fips-us-west-2\":\n regionInfo = {\n hostname: \"cognito-identity-fips.us-west-2.amazonaws.com\",\n partition: \"aws\",\n signingRegion: \"us-west-2\",\n };\n break;\n case \"sa-east-1\":\n regionInfo = {\n hostname: \"cognito-identity.sa-east-1.amazonaws.com\",\n partition: \"aws\",\n };\n break;\n case \"us-east-1\":\n regionInfo = {\n hostname: \"cognito-identity.us-east-1.amazonaws.com\",\n partition: \"aws\",\n };\n break;\n case \"us-east-2\":\n regionInfo = {\n hostname: \"cognito-identity.us-east-2.amazonaws.com\",\n partition: \"aws\",\n };\n break;\n case \"us-gov-west-1\":\n regionInfo = {\n hostname: \"cognito-identity.us-gov-west-1.amazonaws.com\",\n partition: \"aws-us-gov\",\n };\n break;\n case \"us-west-1\":\n regionInfo = {\n hostname: \"cognito-identity.us-west-1.amazonaws.com\",\n partition: \"aws\",\n };\n break;\n case \"us-west-2\":\n regionInfo = {\n hostname: \"cognito-identity.us-west-2.amazonaws.com\",\n partition: \"aws\",\n };\n break;\n // Next, try to match partition endpoints.\n default:\n if (AWS_REGIONS.has(region)) {\n regionInfo = {\n hostname: AWS_TEMPLATE.replace(\"{region}\", region),\n partition: \"aws\",\n };\n }\n if (AWS_CN_REGIONS.has(region)) {\n regionInfo = {\n hostname: AWS_CN_TEMPLATE.replace(\"{region}\", region),\n partition: \"aws-cn\",\n };\n }\n if (AWS_ISO_REGIONS.has(region)) {\n regionInfo = {\n hostname: AWS_ISO_TEMPLATE.replace(\"{region}\", region),\n partition: \"aws-iso\",\n };\n }\n if (AWS_ISO_B_REGIONS.has(region)) {\n regionInfo = {\n hostname: AWS_ISO_B_TEMPLATE.replace(\"{region}\", region),\n partition: \"aws-iso-b\",\n };\n }\n if (AWS_US_GOV_REGIONS.has(region)) {\n regionInfo = {\n hostname: AWS_US_GOV_TEMPLATE.replace(\"{region}\", region),\n partition: \"aws-us-gov\",\n };\n }\n // Finally, assume it's an AWS partition endpoint.\n if (regionInfo === undefined) {\n regionInfo = {\n hostname: AWS_TEMPLATE.replace(\"{region}\", region),\n partition: \"aws\",\n };\n }\n }\n return Promise.resolve(__assign({ signingService: \"cognito-identity\" }, regionInfo));\n};\n//# sourceMappingURL=endpoints.js.map","import { defaultRegionInfoProvider } from \"./endpoints\";\nimport { parseUrl } from \"@aws-sdk/url-parser\";\n/**\n * @internal\n */\nexport var ClientSharedValues = {\n apiVersion: \"2014-06-30\",\n disableHostPrefix: false,\n logger: {},\n regionInfoProvider: defaultRegionInfoProvider,\n serviceId: \"Cognito Identity\",\n urlParser: parseUrl,\n};\n//# sourceMappingURL=runtimeConfig.shared.js.map","import { __assign } from \"tslib\";\nimport packageInfo from \"./package.json\";\nimport { Sha256 } from \"@aws-crypto/sha256-browser\";\nimport { FetchHttpHandler, streamCollector } from \"@aws-sdk/fetch-http-handler\";\nimport { invalidProvider } from \"@aws-sdk/invalid-dependency\";\nimport { DEFAULT_MAX_ATTEMPTS } from \"@aws-sdk/middleware-retry\";\nimport { fromBase64, toBase64 } from \"@aws-sdk/util-base64-browser\";\nimport { calculateBodyLength } from \"@aws-sdk/util-body-length-browser\";\nimport { defaultUserAgent } from \"@aws-sdk/util-user-agent-browser\";\nimport { fromUtf8, toUtf8 } from \"@aws-sdk/util-utf8-browser\";\nimport { ClientSharedValues } from \"./runtimeConfig.shared\";\n/**\n * @internal\n */\nexport var ClientDefaultValues = __assign(__assign({}, ClientSharedValues), { runtime: \"browser\", base64Decoder: fromBase64, base64Encoder: toBase64, bodyLengthChecker: calculateBodyLength, credentialDefaultProvider: function (_) { return function () { return Promise.reject(new Error(\"Credential is missing\")); }; }, defaultUserAgentProvider: defaultUserAgent({\n serviceId: ClientSharedValues.serviceId,\n clientVersion: packageInfo.version,\n }), maxAttempts: DEFAULT_MAX_ATTEMPTS, region: invalidProvider(\"Region is missing\"), requestHandler: new FetchHttpHandler(), sha256: Sha256, streamCollector: streamCollector, utf8Decoder: fromUtf8, utf8Encoder: toUtf8 });\n//# sourceMappingURL=runtimeConfig.browser.js.map","import { Decoder, Encoder, EventSigner, EventStreamSerdeProvider, Provider } from \"@aws-sdk/types\";\n\nimport { EventStreamMarshaller } from \"./EventStreamMarshaller\";\n\n/** browser event stream serde utils provider */\nexport const eventStreamSerdeProvider: EventStreamSerdeProvider = (options: {\n utf8Encoder: Encoder;\n utf8Decoder: Decoder;\n eventSigner: EventSigner | Provider;\n}) => new EventStreamMarshaller(options);\n","import { __assign, __extends } from \"tslib\";\nimport { ClientDefaultValues as __ClientDefaultValues } from \"./runtimeConfig\";\nimport { resolveEndpointsConfig, resolveRegionConfig, } from \"@aws-sdk/config-resolver\";\nimport { resolveEventStreamSerdeConfig, } from \"@aws-sdk/eventstream-serde-config-resolver\";\nimport { resolveBucketEndpointConfig, } from \"@aws-sdk/middleware-bucket-endpoint\";\nimport { getContentLengthPlugin } from \"@aws-sdk/middleware-content-length\";\nimport { getAddExpectContinuePlugin } from \"@aws-sdk/middleware-expect-continue\";\nimport { getHostHeaderPlugin, resolveHostHeaderConfig, } from \"@aws-sdk/middleware-host-header\";\nimport { getLoggerPlugin } from \"@aws-sdk/middleware-logger\";\nimport { getRetryPlugin, resolveRetryConfig } from \"@aws-sdk/middleware-retry\";\nimport { getUseRegionalEndpointPlugin, getValidateBucketNamePlugin } from \"@aws-sdk/middleware-sdk-s3\";\nimport { getAwsAuthPlugin, resolveAwsAuthConfig, } from \"@aws-sdk/middleware-signing\";\nimport { getUserAgentPlugin, resolveUserAgentConfig, } from \"@aws-sdk/middleware-user-agent\";\nimport { Client as __Client, } from \"@aws-sdk/smithy-client\";\n/**\n * \n */\nvar S3Client = /** @class */ (function (_super) {\n __extends(S3Client, _super);\n function S3Client(configuration) {\n var _this = this;\n var _config_0 = __assign(__assign({}, __ClientDefaultValues), configuration);\n var _config_1 = resolveRegionConfig(_config_0);\n var _config_2 = resolveEndpointsConfig(_config_1);\n var _config_3 = resolveAwsAuthConfig(_config_2);\n var _config_4 = resolveRetryConfig(_config_3);\n var _config_5 = resolveHostHeaderConfig(_config_4);\n var _config_6 = resolveBucketEndpointConfig(_config_5);\n var _config_7 = resolveUserAgentConfig(_config_6);\n var _config_8 = resolveEventStreamSerdeConfig(_config_7);\n _this = _super.call(this, _config_8) || this;\n _this.config = _config_8;\n _this.middlewareStack.use(getAwsAuthPlugin(_this.config));\n _this.middlewareStack.use(getRetryPlugin(_this.config));\n _this.middlewareStack.use(getContentLengthPlugin(_this.config));\n _this.middlewareStack.use(getHostHeaderPlugin(_this.config));\n _this.middlewareStack.use(getLoggerPlugin(_this.config));\n _this.middlewareStack.use(getValidateBucketNamePlugin(_this.config));\n _this.middlewareStack.use(getUseRegionalEndpointPlugin(_this.config));\n _this.middlewareStack.use(getAddExpectContinuePlugin(_this.config));\n _this.middlewareStack.use(getUserAgentPlugin(_this.config));\n return _this;\n }\n S3Client.prototype.destroy = function () {\n _super.prototype.destroy.call(this);\n };\n return S3Client;\n}(__Client));\nexport { S3Client };\n//# sourceMappingURL=S3Client.js.map","import { EventStreamMarshaller, EventStreamSerdeProvider } from \"@aws-sdk/types\";\n\nexport interface EventStreamSerdeInputConfig {}\n\nexport interface EventStreamSerdeResolvedConfig {\n eventStreamMarshaller: EventStreamMarshaller;\n}\n\ninterface PreviouslyResolved {\n eventStreamSerdeProvider: EventStreamSerdeProvider;\n}\n\nexport const resolveEventStreamSerdeConfig = (\n input: T & PreviouslyResolved & EventStreamSerdeInputConfig\n): T & EventStreamSerdeResolvedConfig => ({\n ...input,\n eventStreamMarshaller: input.eventStreamSerdeProvider(input),\n});\n","import { SignatureV4, SignatureV4CryptoInit, SignatureV4Init } from \"@aws-sdk/signature-v4\";\nimport { RequestPresigner, RequestPresigningArguments } from \"@aws-sdk/types\";\nimport { HttpRequest as IHttpRequest } from \"@aws-sdk/types\";\n\nimport { SHA256_HEADER, UNSIGNED_PAYLOAD } from \"./constants\";\n\n/**\n * PartialBy makes properties specified in K optional in interface T\n * see: https://stackoverflow.com/questions/43159887/make-a-single-property-optional-in-typescript\n * */\ntype Omit = Pick>;\ntype PartialBy = Omit & Partial>;\n\nexport type S3RequestPresignerOptions = PartialBy<\n SignatureV4Init & SignatureV4CryptoInit,\n \"service\" | \"uriEscapePath\"\n> & { signingName?: string };\n\nexport class S3RequestPresigner implements RequestPresigner {\n private readonly signer: SignatureV4;\n constructor(options: S3RequestPresignerOptions) {\n const resolvedOptions = {\n // Allow `signingName` because we want to support usecase of supply client's resolved config\n // directly. Where service equals signingName.\n service: options.signingName || options.service || \"s3\",\n uriEscapePath: options.uriEscapePath || false,\n ...options,\n };\n this.signer = new SignatureV4(resolvedOptions);\n }\n\n public async presign(\n requestToSign: IHttpRequest,\n { unsignableHeaders = new Set(), unhoistableHeaders = new Set(), ...options }: RequestPresigningArguments = {}\n ): Promise {\n unsignableHeaders.add(\"content-type\");\n // S3 requires SSE headers to be signed in headers instead of query\n // See: https://github.com/aws/aws-sdk-js-v3/issues/1576\n Object.keys(requestToSign.headers)\n .map((header) => header.toLowerCase())\n .filter((header) => header.startsWith(\"x-amz-server-side-encryption\"))\n .forEach((header) => {\n unhoistableHeaders.add(header);\n });\n requestToSign.headers[SHA256_HEADER] = UNSIGNED_PAYLOAD;\n if (!requestToSign.headers[\"host\"]) {\n requestToSign.headers.host = requestToSign.hostname;\n }\n return this.signer.presign(requestToSign, {\n expiresIn: 900,\n unsignableHeaders,\n unhoistableHeaders,\n ...options,\n });\n }\n}\n","/*\n * Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use this file except in compliance with\n * the License. A copy of the License is located at\n *\n * http://aws.amazon.com/apache2.0/\n *\n * or in the \"license\" file accompanying this file. This file is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions\n * and limitations under the License.\n */\nvar __values = (this && this.__values) || function(o) {\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n if (m) return m.call(o);\n if (o && typeof o.length === \"number\") return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n};\nvar __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n};\nimport { HttpResponse } from '@aws-sdk/protocol-http';\nimport { buildQueryString } from '@aws-sdk/querystring-builder';\nimport axios from 'axios';\nimport { ConsoleLogger as Logger, Platform } from '@aws-amplify/core';\nvar logger = new Logger('axios-http-handler');\nexport var SEND_UPLOAD_PROGRESS_EVENT = 'sendUploadProgress';\nexport var SEND_DOWNLOAD_PROGRESS_EVENT = 'sendDownloadProgress';\nfunction isBlob(body) {\n return typeof Blob !== 'undefined' && body instanceof Blob;\n}\nvar normalizeHeaders = function (headers, normalizedName) {\n var e_1, _a;\n try {\n for (var _b = __values(Object.entries(headers)), _c = _b.next(); !_c.done; _c = _b.next()) {\n var _d = __read(_c.value, 2), k = _d[0], v = _d[1];\n if (k !== normalizedName &&\n k.toUpperCase() === normalizedName.toUpperCase()) {\n headers[normalizedName] = v;\n delete headers[k];\n }\n }\n }\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\n finally {\n try {\n if (_c && !_c.done && (_a = _b.return)) _a.call(_b);\n }\n finally { if (e_1) throw e_1.error; }\n }\n};\nexport var reactNativeRequestTransformer = [\n function (data, headers) {\n if (isBlob(data)) {\n normalizeHeaders(headers, 'Content-Type');\n normalizeHeaders(headers, 'Accept');\n return data;\n }\n // Axios' default transformRequest is an array\n return axios.defaults.transformRequest[0].call(null, data, headers);\n },\n];\nvar AxiosHttpHandler = /** @class */ (function () {\n function AxiosHttpHandler(httpOptions, emitter, cancelTokenSource) {\n if (httpOptions === void 0) { httpOptions = {}; }\n this.httpOptions = httpOptions;\n this.emitter = emitter;\n this.cancelTokenSource = cancelTokenSource;\n }\n AxiosHttpHandler.prototype.destroy = function () {\n // Do nothing. TLS and HTTP/2 connection pooling is handled by the\n // browser.\n };\n AxiosHttpHandler.prototype.handle = function (request, options) {\n var requestTimeoutInMs = this.httpOptions.requestTimeout;\n var emitter = this.emitter;\n var path = request.path;\n if (request.query) {\n var queryString = buildQueryString(request.query);\n if (queryString) {\n path += \"?\" + queryString;\n }\n }\n var port = request.port;\n var url = request.protocol + \"//\" + request.hostname + (port ? \":\" + port : '') + path;\n var axiosRequest = {};\n axiosRequest.url = url;\n axiosRequest.method = request.method;\n axiosRequest.headers = request.headers;\n // The host header is automatically added by the browser and adding it explicitly in the\n // axios request throws an error https://github.com/aws-amplify/amplify-js/issues/5376\n // This is because the host header is a forbidden header for the http client to set\n // see https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name and\n // https://fetch.spec.whatwg.org/#forbidden-header-name\n // The reason we are removing this header here instead of in the aws-sdk's client\n // middleware is that the host header is required to be in the request signature and if\n // we remove it from the middlewares, then the request fails because the header is added\n // by the browser but is absent from the signature.\n delete axiosRequest.headers['host'];\n if (request.body) {\n axiosRequest.data = request.body;\n }\n else {\n // Fix for https://github.com/aws-amplify/amplify-js/issues/5432\n // If the POST request body is empty but content-type header is set, axios is forcibly removing it\n // See https://github.com/axios/axios/issues/1535 and refusing to fix it https://github.com/axios/axios/issues/755\n // This change is a workaround to set the data as null (instead of undefined) to prevent axios from\n // removing the content-type header. Link for the source code\n // https://github.com/axios/axios/blob/dc4bc49673943e35280e5df831f5c3d0347a9393/lib/adapters/xhr.js#L121-L123\n if (axiosRequest.headers['Content-Type']) {\n axiosRequest.data = null;\n }\n }\n if (emitter) {\n axiosRequest.onUploadProgress = function (event) {\n emitter.emit(SEND_UPLOAD_PROGRESS_EVENT, event);\n logger.debug(event);\n };\n axiosRequest.onDownloadProgress = function (event) {\n emitter.emit(SEND_DOWNLOAD_PROGRESS_EVENT, event);\n logger.debug(event);\n };\n }\n // If a cancel token source is passed down from the provider, allows cancellation of in-flight requests\n if (this.cancelTokenSource) {\n axiosRequest.cancelToken = this.cancelTokenSource.token;\n }\n // From gamma release, aws-sdk now expects all response type to be of blob or streams\n axiosRequest.responseType = 'blob';\n // In Axios, Blobs are identified by calling Object.prototype.toString on the object. However, on React Native,\n // calling Object.prototype.toString on a Blob returns '[object Object]' instead of '[object Blob]', which causes \n // Axios to treat Blobs as generic Javascript objects. Therefore we need a to use a custom request transformer\n // to correctly handle Blob in React Native.\n if (Platform.isReactNative) {\n axiosRequest.transformRequest = reactNativeRequestTransformer;\n }\n var raceOfPromises = [\n axios\n .request(axiosRequest)\n .then(function (response) {\n return {\n response: new HttpResponse({\n headers: response.headers,\n statusCode: response.status,\n body: response.data,\n }),\n };\n })\n .catch(function (error) {\n // Error\n logger.error(error.message);\n throw error;\n }),\n requestTimeout(requestTimeoutInMs),\n ];\n return Promise.race(raceOfPromises);\n };\n return AxiosHttpHandler;\n}());\nexport { AxiosHttpHandler };\nfunction requestTimeout(timeoutInMs) {\n if (timeoutInMs === void 0) { timeoutInMs = 0; }\n return new Promise(function (resolve, reject) {\n if (timeoutInMs) {\n setTimeout(function () {\n var timeoutError = new Error(\"Request did not complete within \" + timeoutInMs + \" ms\");\n timeoutError.name = 'TimeoutError';\n reject(timeoutError);\n }, timeoutInMs);\n }\n });\n}\n//# sourceMappingURL=axios-http-handler.js.map","export var StorageErrorStrings;\n(function (StorageErrorStrings) {\n StorageErrorStrings[\"NO_CREDENTIALS\"] = \"No credentials\";\n StorageErrorStrings[\"NO_SRC_KEY\"] = \"source param should be an object with the property \\\"key\\\" with value of type string\";\n StorageErrorStrings[\"NO_DEST_KEY\"] = \"destination param should be an object with the property \\\"key\\\" with value of type string\";\n})(StorageErrorStrings || (StorageErrorStrings = {}));\nexport var AWSS3ProviderMultipartCopierErrors;\n(function (AWSS3ProviderMultipartCopierErrors) {\n AWSS3ProviderMultipartCopierErrors[\"CLEANUP_FAILED\"] = \"Multipart copy clean up failed\";\n AWSS3ProviderMultipartCopierErrors[\"NO_OBJECT_FOUND\"] = \"Object does not exist\";\n AWSS3ProviderMultipartCopierErrors[\"INVALID_QUEUESIZE\"] = \"Queue size must be a positive number\";\n AWSS3ProviderMultipartCopierErrors[\"NO_COPYSOURCE\"] = \"You must specify a copy source\";\n AWSS3ProviderMultipartCopierErrors[\"MAX_NUM_PARTS_EXCEEDED\"] = \"Only a maximum of 10000 parts are allowed\";\n})(AWSS3ProviderMultipartCopierErrors || (AWSS3ProviderMultipartCopierErrors = {}));\n//# sourceMappingURL=StorageErrorStrings.js.map","import { __extends } from \"tslib\";\nimport { PutObjectOutput, PutObjectRequest } from \"../models/models_0\";\nimport { deserializeAws_restXmlPutObjectCommand, serializeAws_restXmlPutObjectCommand } from \"../protocols/Aws_restXml\";\nimport { getBucketEndpointPlugin } from \"@aws-sdk/middleware-bucket-endpoint\";\nimport { getSerdePlugin } from \"@aws-sdk/middleware-serde\";\nimport { getSsecPlugin } from \"@aws-sdk/middleware-ssec\";\nimport { Command as $Command } from \"@aws-sdk/smithy-client\";\n/**\n * Adds an object to a bucket. You must have WRITE permissions on a bucket to add an object\n * to it.
\n *\n *\n * Amazon S3 never adds partial objects; if you receive a success response, Amazon S3 added the\n * entire object to the bucket.
\n *\n * Amazon S3 is a distributed system. If it receives multiple write requests for the same object\n * simultaneously, it overwrites all but the last object written. Amazon S3 does not provide object\n * locking; if you need this, make sure to build it into your application layer or use\n * versioning instead.
\n *\n * To ensure that data is not corrupted traversing the network, use the\n * Content-MD5
header. When you use this header, Amazon S3 checks the object\n * against the provided MD5 value and, if they do not match, returns an error. Additionally,\n * you can calculate the MD5 while putting an object to Amazon S3 and compare the returned ETag to\n * the calculated MD5 value.
\n * \n * The Content-MD5
header is required for any request to upload an object\n * with a retention period configured using Amazon S3 Object Lock. For more information about\n * Amazon S3 Object Lock, see Amazon S3 Object Lock Overview\n * in the Amazon Simple Storage Service Developer Guide.
\n * \n *\n *\n * \n * Server-side Encryption\n *
\n * You can optionally request server-side encryption. With server-side encryption, Amazon S3 encrypts your data as it writes it to disks in its data centers and decrypts the data\n * when you access it. You have the option to provide your own encryption key or use AWS\n * managed encryption keys (SSE-S3 or SSE-KMS). For more information, see Using Server-Side\n * Encryption.
\n * If you request server-side encryption using AWS Key Management Service (SSE-KMS), you can enable an S3 Bucket Key at the object-level. For more information, see Amazon S3 Bucket Keys in the Amazon Simple Storage Service Developer Guide.
\n * \n * Access Control List (ACL)-Specific Request\n * Headers\n *
\n * You can use headers to grant ACL- based permissions. By default, all objects are\n * private. Only the owner has full access control. When adding a new object, you can grant\n * permissions to individual AWS accounts or to predefined groups defined by Amazon S3. These\n * permissions are then added to the ACL on the object. For more information, see Access Control List\n * (ACL) Overview and Managing ACLs Using the REST\n * API.
\n *\n * \n * Storage Class Options\n *
\n * By default, Amazon S3 uses the STANDARD Storage Class to store newly created objects. The\n * STANDARD storage class provides high durability and high availability. Depending on\n * performance needs, you can specify a different Storage Class. Amazon S3 on Outposts only uses\n * the OUTPOSTS Storage Class. For more information, see Storage Classes in the Amazon S3\n * Service Developer Guide.
\n *\n *\n * \n * Versioning\n *
\n * If you enable versioning for a bucket, Amazon S3 automatically generates a unique version ID\n * for the object being stored. Amazon S3 returns this ID in the response. When you enable\n * versioning for a bucket, if Amazon S3 receives multiple write requests for the same object\n * simultaneously, it stores all of the objects.
\n * For more information about versioning, see Adding Objects to\n * Versioning Enabled Buckets. For information about returning the versioning state\n * of a bucket, see GetBucketVersioning.
\n *\n *\n * \n * Related Resources\n *
\n * \n */\nvar PutObjectCommand = /** @class */ (function (_super) {\n __extends(PutObjectCommand, _super);\n // Start section: command_properties\n // End section: command_properties\n function PutObjectCommand(input) {\n var _this = \n // Start section: command_constructor\n _super.call(this) || this;\n _this.input = input;\n return _this;\n // End section: command_constructor\n }\n /**\n * @internal\n */\n PutObjectCommand.prototype.resolveMiddleware = function (clientStack, configuration, options) {\n this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));\n this.middlewareStack.use(getSsecPlugin(configuration));\n this.middlewareStack.use(getBucketEndpointPlugin(configuration));\n var stack = clientStack.concat(this.middlewareStack);\n var logger = configuration.logger;\n var clientName = \"S3Client\";\n var commandName = \"PutObjectCommand\";\n var handlerExecutionContext = {\n logger: logger,\n clientName: clientName,\n commandName: commandName,\n inputFilterSensitiveLog: PutObjectRequest.filterSensitiveLog,\n outputFilterSensitiveLog: PutObjectOutput.filterSensitiveLog,\n };\n var requestHandler = configuration.requestHandler;\n return stack.resolve(function (request) {\n return requestHandler.handle(request.request, options || {});\n }, handlerExecutionContext);\n };\n PutObjectCommand.prototype.serialize = function (input, context) {\n return serializeAws_restXmlPutObjectCommand(input, context);\n };\n PutObjectCommand.prototype.deserialize = function (output, context) {\n return deserializeAws_restXmlPutObjectCommand(output, context);\n };\n return PutObjectCommand;\n}($Command));\nexport { PutObjectCommand };\n//# sourceMappingURL=PutObjectCommand.js.map","import { __assign } from \"tslib\";\nimport { Encryption, } from \"./models_0\";\nimport { SENSITIVE_STRING } from \"@aws-sdk/smithy-client\";\nexport var MetadataEntry;\n(function (MetadataEntry) {\n MetadataEntry.filterSensitiveLog = function (obj) { return (__assign({}, obj)); };\n})(MetadataEntry || (MetadataEntry = {}));\nexport var S3Location;\n(function (S3Location) {\n S3Location.filterSensitiveLog = function (obj) { return (__assign(__assign({}, obj), (obj.Encryption && { Encryption: Encryption.filterSensitiveLog(obj.Encryption) }))); };\n})(S3Location || (S3Location = {}));\nexport var OutputLocation;\n(function (OutputLocation) {\n OutputLocation.filterSensitiveLog = function (obj) { return (__assign(__assign({}, obj), (obj.S3 && { S3: S3Location.filterSensitiveLog(obj.S3) }))); };\n})(OutputLocation || (OutputLocation = {}));\nexport var FileHeaderInfo;\n(function (FileHeaderInfo) {\n FileHeaderInfo[\"IGNORE\"] = \"IGNORE\";\n FileHeaderInfo[\"NONE\"] = \"NONE\";\n FileHeaderInfo[\"USE\"] = \"USE\";\n})(FileHeaderInfo || (FileHeaderInfo = {}));\nexport var CSVInput;\n(function (CSVInput) {\n CSVInput.filterSensitiveLog = function (obj) { return (__assign({}, obj)); };\n})(CSVInput || (CSVInput = {}));\nexport var JSONType;\n(function (JSONType) {\n JSONType[\"DOCUMENT\"] = \"DOCUMENT\";\n JSONType[\"LINES\"] = \"LINES\";\n})(JSONType || (JSONType = {}));\nexport var JSONInput;\n(function (JSONInput) {\n JSONInput.filterSensitiveLog = function (obj) { return (__assign({}, obj)); };\n})(JSONInput || (JSONInput = {}));\nexport var ParquetInput;\n(function (ParquetInput) {\n ParquetInput.filterSensitiveLog = function (obj) { return (__assign({}, obj)); };\n})(ParquetInput || (ParquetInput = {}));\nexport var InputSerialization;\n(function (InputSerialization) {\n InputSerialization.filterSensitiveLog = function (obj) { return (__assign({}, obj)); };\n})(InputSerialization || (InputSerialization = {}));\nexport var QuoteFields;\n(function (QuoteFields) {\n QuoteFields[\"ALWAYS\"] = \"ALWAYS\";\n QuoteFields[\"ASNEEDED\"] = \"ASNEEDED\";\n})(QuoteFields || (QuoteFields = {}));\nexport var CSVOutput;\n(function (CSVOutput) {\n CSVOutput.filterSensitiveLog = function (obj) { return (__assign({}, obj)); };\n})(CSVOutput || (CSVOutput = {}));\nexport var JSONOutput;\n(function (JSONOutput) {\n JSONOutput.filterSensitiveLog = function (obj) { return (__assign({}, obj)); };\n})(JSONOutput || (JSONOutput = {}));\nexport var OutputSerialization;\n(function (OutputSerialization) {\n OutputSerialization.filterSensitiveLog = function (obj) { return (__assign({}, obj)); };\n})(OutputSerialization || (OutputSerialization = {}));\nexport var SelectParameters;\n(function (SelectParameters) {\n SelectParameters.filterSensitiveLog = function (obj) { return (__assign({}, obj)); };\n})(SelectParameters || (SelectParameters = {}));\nexport var RestoreRequestType;\n(function (RestoreRequestType) {\n RestoreRequestType[\"SELECT\"] = \"SELECT\";\n})(RestoreRequestType || (RestoreRequestType = {}));\nexport var RestoreRequest;\n(function (RestoreRequest) {\n RestoreRequest.filterSensitiveLog = function (obj) { return (__assign(__assign({}, obj), (obj.OutputLocation && { OutputLocation: OutputLocation.filterSensitiveLog(obj.OutputLocation) }))); };\n})(RestoreRequest || (RestoreRequest = {}));\nexport var RestoreObjectRequest;\n(function (RestoreObjectRequest) {\n RestoreObjectRequest.filterSensitiveLog = function (obj) { return (__assign(__assign({}, obj), (obj.RestoreRequest && { RestoreRequest: RestoreRequest.filterSensitiveLog(obj.RestoreRequest) }))); };\n})(RestoreObjectRequest || (RestoreObjectRequest = {}));\nexport var ContinuationEvent;\n(function (ContinuationEvent) {\n ContinuationEvent.filterSensitiveLog = function (obj) { return (__assign({}, obj)); };\n})(ContinuationEvent || (ContinuationEvent = {}));\nexport var EndEvent;\n(function (EndEvent) {\n EndEvent.filterSensitiveLog = function (obj) { return (__assign({}, obj)); };\n})(EndEvent || (EndEvent = {}));\nexport var Progress;\n(function (Progress) {\n Progress.filterSensitiveLog = function (obj) { return (__assign({}, obj)); };\n})(Progress || (Progress = {}));\nexport var ProgressEvent;\n(function (ProgressEvent) {\n ProgressEvent.filterSensitiveLog = function (obj) { return (__assign({}, obj)); };\n})(ProgressEvent || (ProgressEvent = {}));\nexport var RecordsEvent;\n(function (RecordsEvent) {\n RecordsEvent.filterSensitiveLog = function (obj) { return (__assign({}, obj)); };\n})(RecordsEvent || (RecordsEvent = {}));\nexport var Stats;\n(function (Stats) {\n Stats.filterSensitiveLog = function (obj) { return (__assign({}, obj)); };\n})(Stats || (Stats = {}));\nexport var StatsEvent;\n(function (StatsEvent) {\n StatsEvent.filterSensitiveLog = function (obj) { return (__assign({}, obj)); };\n})(StatsEvent || (StatsEvent = {}));\nexport var SelectObjectContentEventStream;\n(function (SelectObjectContentEventStream) {\n SelectObjectContentEventStream.visit = function (value, visitor) {\n if (value.Records !== undefined)\n return visitor.Records(value.Records);\n if (value.Stats !== undefined)\n return visitor.Stats(value.Stats);\n if (value.Progress !== undefined)\n return visitor.Progress(value.Progress);\n if (value.Cont !== undefined)\n return visitor.Cont(value.Cont);\n if (value.End !== undefined)\n return visitor.End(value.End);\n return visitor._(value.$unknown[0], value.$unknown[1]);\n };\n SelectObjectContentEventStream.filterSensitiveLog = function (obj) {\n var _a;\n if (obj.Records !== undefined)\n return { Records: RecordsEvent.filterSensitiveLog(obj.Records) };\n if (obj.Stats !== undefined)\n return { Stats: StatsEvent.filterSensitiveLog(obj.Stats) };\n if (obj.Progress !== undefined)\n return { Progress: ProgressEvent.filterSensitiveLog(obj.Progress) };\n if (obj.Cont !== undefined)\n return { Cont: ContinuationEvent.filterSensitiveLog(obj.Cont) };\n if (obj.End !== undefined)\n return { End: EndEvent.filterSensitiveLog(obj.End) };\n if (obj.$unknown !== undefined)\n return _a = {}, _a[obj.$unknown[0]] = \"UNKNOWN\", _a;\n };\n})(SelectObjectContentEventStream || (SelectObjectContentEventStream = {}));\nexport var SelectObjectContentOutput;\n(function (SelectObjectContentOutput) {\n SelectObjectContentOutput.filterSensitiveLog = function (obj) { return (__assign(__assign({}, obj), (obj.Payload && { Payload: \"STREAMING_CONTENT\" }))); };\n})(SelectObjectContentOutput || (SelectObjectContentOutput = {}));\nexport var RequestProgress;\n(function (RequestProgress) {\n RequestProgress.filterSensitiveLog = function (obj) { return (__assign({}, obj)); };\n})(RequestProgress || (RequestProgress = {}));\nexport var ScanRange;\n(function (ScanRange) {\n ScanRange.filterSensitiveLog = function (obj) { return (__assign({}, obj)); };\n})(ScanRange || (ScanRange = {}));\nexport var SelectObjectContentRequest;\n(function (SelectObjectContentRequest) {\n SelectObjectContentRequest.filterSensitiveLog = function (obj) { return (__assign(__assign({}, obj), (obj.SSECustomerKey && { SSECustomerKey: SENSITIVE_STRING }))); };\n})(SelectObjectContentRequest || (SelectObjectContentRequest = {}));\nexport var UploadPartOutput;\n(function (UploadPartOutput) {\n UploadPartOutput.filterSensitiveLog = function (obj) { return (__assign(__assign({}, obj), (obj.SSEKMSKeyId && { SSEKMSKeyId: SENSITIVE_STRING }))); };\n})(UploadPartOutput || (UploadPartOutput = {}));\nexport var UploadPartRequest;\n(function (UploadPartRequest) {\n UploadPartRequest.filterSensitiveLog = function (obj) { return (__assign(__assign({}, obj), (obj.SSECustomerKey && { SSECustomerKey: SENSITIVE_STRING }))); };\n})(UploadPartRequest || (UploadPartRequest = {}));\nexport var CopyPartResult;\n(function (CopyPartResult) {\n CopyPartResult.filterSensitiveLog = function (obj) { return (__assign({}, obj)); };\n})(CopyPartResult || (CopyPartResult = {}));\nexport var UploadPartCopyOutput;\n(function (UploadPartCopyOutput) {\n UploadPartCopyOutput.filterSensitiveLog = function (obj) { return (__assign(__assign({}, obj), (obj.SSEKMSKeyId && { SSEKMSKeyId: SENSITIVE_STRING }))); };\n})(UploadPartCopyOutput || (UploadPartCopyOutput = {}));\nexport var UploadPartCopyRequest;\n(function (UploadPartCopyRequest) {\n UploadPartCopyRequest.filterSensitiveLog = function (obj) { return (__assign(__assign(__assign({}, obj), (obj.SSECustomerKey && { SSECustomerKey: SENSITIVE_STRING })), (obj.CopySourceSSECustomerKey && { CopySourceSSECustomerKey: SENSITIVE_STRING }))); };\n})(UploadPartCopyRequest || (UploadPartCopyRequest = {}));\n//# sourceMappingURL=models_1.js.map","import { __extends } from \"tslib\";\nimport { CreateMultipartUploadOutput, CreateMultipartUploadRequest } from \"../models/models_0\";\nimport { deserializeAws_restXmlCreateMultipartUploadCommand, serializeAws_restXmlCreateMultipartUploadCommand, } from \"../protocols/Aws_restXml\";\nimport { getBucketEndpointPlugin } from \"@aws-sdk/middleware-bucket-endpoint\";\nimport { getSerdePlugin } from \"@aws-sdk/middleware-serde\";\nimport { getSsecPlugin } from \"@aws-sdk/middleware-ssec\";\nimport { Command as $Command } from \"@aws-sdk/smithy-client\";\n/**\n * This operation initiates a multipart upload and returns an upload ID. This upload ID is\n * used to associate all of the parts in the specific multipart upload. You specify this\n * upload ID in each of your subsequent upload part requests (see UploadPart). You also include this\n * upload ID in the final request to either complete or abort the multipart upload\n * request.
\n *\n * For more information about multipart uploads, see Multipart Upload Overview.
\n *\n * If you have configured a lifecycle rule to abort incomplete multipart uploads, the\n * upload must complete within the number of days specified in the bucket lifecycle\n * configuration. Otherwise, the incomplete multipart upload becomes eligible for an abort\n * operation and Amazon S3 aborts the multipart upload. For more information, see Aborting\n * Incomplete Multipart Uploads Using a Bucket Lifecycle Policy.
\n *\n * For information about the permissions required to use the multipart upload API, see\n * Multipart Upload API and\n * Permissions.
\n *\n * For request signing, multipart upload is just a series of regular requests. You initiate\n * a multipart upload, send one or more requests to upload parts, and then complete the\n * multipart upload process. You sign each request individually. There is nothing special\n * about signing multipart upload requests. For more information about signing, see Authenticating\n * Requests (AWS Signature Version 4).
\n *\n * \n * After you initiate a multipart upload and upload one or more parts, to stop being\n * charged for storing the uploaded parts, you must either complete or abort the multipart\n * upload. Amazon S3 frees up the space used to store the parts and stop charging you for\n * storing them only after you either complete or abort a multipart upload.
\n * \n *\n * You can optionally request server-side encryption. For server-side encryption, Amazon S3\n * encrypts your data as it writes it to disks in its data centers and decrypts it when you\n * access it. You can provide your own encryption key, or use AWS Key Management Service (AWS\n * KMS) customer master keys (CMKs) or Amazon S3-managed encryption keys. If you choose to provide\n * your own encryption key, the request headers you provide in UploadPart and UploadPartCopy requests must match the headers you used in the request to\n * initiate the upload by using CreateMultipartUpload
.
\n * To perform a multipart upload with encryption using an AWS KMS CMK, the requester must\n * have permission to the kms:Encrypt
, kms:Decrypt
,\n * kms:ReEncrypt*
, kms:GenerateDataKey*
, and\n * kms:DescribeKey
actions on the key. These permissions are required because\n * Amazon S3 must decrypt and read data from the encrypted file parts before it completes the\n * multipart upload.
\n *\n * If your AWS Identity and Access Management (IAM) user or role is in the same AWS account\n * as the AWS KMS CMK, then you must have these permissions on the key policy. If your IAM\n * user or role belongs to a different account than the key, then you must have the\n * permissions on both the key policy and your IAM user or role.
\n *\n *\n * For more information, see Protecting\n * Data Using Server-Side Encryption.
\n *\n * \n * - Access Permissions
\n * - \n *
When copying an object, you can optionally specify the accounts or groups that\n * should be granted specific permissions on the new object. There are two ways to\n * grant the permissions using the request headers:
\n * \n * - \n *
Specify a canned ACL with the x-amz-acl
request header. For\n * more information, see Canned ACL.
\n * \n * - \n *
Specify access permissions explicitly with the\n * x-amz-grant-read
, x-amz-grant-read-acp
,\n * x-amz-grant-write-acp
, and\n * x-amz-grant-full-control
headers. These parameters map to\n * the set of permissions that Amazon S3 supports in an ACL. For more information,\n * see Access Control List (ACL)\n * Overview.
\n * \n *
\n * You can use either a canned ACL or specify access permissions explicitly. You\n * cannot do both.
\n * \n * - Server-Side- Encryption-Specific Request Headers
\n * - \n *
You can optionally tell Amazon S3 to encrypt data at rest using server-side\n * encryption. Server-side encryption is for data encryption at rest. Amazon S3 encrypts\n * your data as it writes it to disks in its data centers and decrypts it when you\n * access it. The option you use depends on whether you want to use AWS managed\n * encryption keys or provide your own encryption key.
\n * \n * - \n *
Use encryption keys managed by Amazon S3 or customer master keys (CMKs) stored\n * in AWS Key Management Service (AWS KMS) – If you want AWS to manage the keys\n * used to encrypt data, specify the following headers in the request.
\n * \n * - \n *
x-amz-server-side-encryption
\n * \n * - \n *
x-amz-server-side-encryption-aws-kms-key-id
\n * \n * - \n *
x-amz-server-side-encryption-context
\n * \n *
\n * \n * If you specify x-amz-server-side-encryption:aws:kms
, but\n * don't provide x-amz-server-side-encryption-aws-kms-key-id
,\n * Amazon S3 uses the AWS managed CMK in AWS KMS to protect the data.
\n * \n * \n * All GET and PUT requests for an object protected by AWS KMS fail if\n * you don't make them with SSL or by using SigV4.
\n * \n * For more information about server-side encryption with CMKs stored in AWS\n * KMS (SSE-KMS), see Protecting Data Using Server-Side Encryption with CMKs stored in AWS\n * KMS.
\n * \n * - \n *
Use customer-provided encryption keys – If you want to manage your own\n * encryption keys, provide all the following headers in the request.
\n * \n * - \n *
x-amz-server-side-encryption-customer-algorithm
\n * \n * - \n *
x-amz-server-side-encryption-customer-key
\n * \n * - \n *
x-amz-server-side-encryption-customer-key-MD5
\n * \n *
\n * For more information about server-side encryption with CMKs stored in AWS\n * KMS (SSE-KMS), see Protecting Data Using Server-Side Encryption with CMKs stored in AWS\n * KMS.
\n * \n *
\n * \n * - Access-Control-List (ACL)-Specific Request Headers
\n * - \n *
You also can use the following access control–related headers with this\n * operation. By default, all objects are private. Only the owner has full access\n * control. When adding a new object, you can grant permissions to individual AWS\n * accounts or to predefined groups defined by Amazon S3. These permissions are then added\n * to the access control list (ACL) on the object. For more information, see Using ACLs. With this\n * operation, you can grant access permissions using one of the following two\n * methods:
\n * \n * - \n *
Specify a canned ACL (x-amz-acl
) — Amazon S3 supports a set of\n * predefined ACLs, known as canned ACLs. Each canned ACL\n * has a predefined set of grantees and permissions. For more information, see\n * Canned\n * ACL.
\n * \n * - \n *
Specify access permissions explicitly — To explicitly grant access\n * permissions to specific AWS accounts or groups, use the following headers.\n * Each header maps to specific permissions that Amazon S3 supports in an ACL. For\n * more information, see Access\n * Control List (ACL) Overview. In the header, you specify a list of\n * grantees who get the specific permission. To grant permissions explicitly,\n * use:
\n * \n * - \n *
x-amz-grant-read
\n * \n * - \n *
x-amz-grant-write
\n * \n * - \n *
x-amz-grant-read-acp
\n * \n * - \n *
x-amz-grant-write-acp
\n * \n * - \n *
x-amz-grant-full-control
\n * \n *
\n * You specify each grantee as a type=value pair, where the type is one of\n * the following:
\n * \n * - \n *
\n * id
– if the value specified is the canonical user ID\n * of an AWS account
\n * \n * - \n *
\n * uri
– if you are granting permissions to a predefined\n * group
\n * \n * - \n *
\n * emailAddress
– if the value specified is the email\n * address of an AWS account
\n * \n * Using email addresses to specify a grantee is only supported in the following AWS Regions:
\n * \n * For a list of all the Amazon S3 supported Regions and endpoints, see Regions and Endpoints in the AWS General Reference.
\n * \n * \n *
\n * For example, the following x-amz-grant-read
header grants the AWS accounts identified by account IDs permissions to read object data and its metadata:
\n * \n * x-amz-grant-read: id=\"11112222333\", id=\"444455556666\"
\n *
\n * \n *
\n *\n * \n *
\n *\n * The following operations are related to CreateMultipartUpload
:
\n * \n */\nvar CreateMultipartUploadCommand = /** @class */ (function (_super) {\n __extends(CreateMultipartUploadCommand, _super);\n // Start section: command_properties\n // End section: command_properties\n function CreateMultipartUploadCommand(input) {\n var _this = \n // Start section: command_constructor\n _super.call(this) || this;\n _this.input = input;\n return _this;\n // End section: command_constructor\n }\n /**\n * @internal\n */\n CreateMultipartUploadCommand.prototype.resolveMiddleware = function (clientStack, configuration, options) {\n this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));\n this.middlewareStack.use(getSsecPlugin(configuration));\n this.middlewareStack.use(getBucketEndpointPlugin(configuration));\n var stack = clientStack.concat(this.middlewareStack);\n var logger = configuration.logger;\n var clientName = \"S3Client\";\n var commandName = \"CreateMultipartUploadCommand\";\n var handlerExecutionContext = {\n logger: logger,\n clientName: clientName,\n commandName: commandName,\n inputFilterSensitiveLog: CreateMultipartUploadRequest.filterSensitiveLog,\n outputFilterSensitiveLog: CreateMultipartUploadOutput.filterSensitiveLog,\n };\n var requestHandler = configuration.requestHandler;\n return stack.resolve(function (request) {\n return requestHandler.handle(request.request, options || {});\n }, handlerExecutionContext);\n };\n CreateMultipartUploadCommand.prototype.serialize = function (input, context) {\n return serializeAws_restXmlCreateMultipartUploadCommand(input, context);\n };\n CreateMultipartUploadCommand.prototype.deserialize = function (output, context) {\n return deserializeAws_restXmlCreateMultipartUploadCommand(output, context);\n };\n return CreateMultipartUploadCommand;\n}($Command));\nexport { CreateMultipartUploadCommand };\n//# sourceMappingURL=CreateMultipartUploadCommand.js.map","import { __extends } from \"tslib\";\nimport { UploadPartOutput, UploadPartRequest } from \"../models/models_1\";\nimport { deserializeAws_restXmlUploadPartCommand, serializeAws_restXmlUploadPartCommand, } from \"../protocols/Aws_restXml\";\nimport { getBucketEndpointPlugin } from \"@aws-sdk/middleware-bucket-endpoint\";\nimport { getSerdePlugin } from \"@aws-sdk/middleware-serde\";\nimport { getSsecPlugin } from \"@aws-sdk/middleware-ssec\";\nimport { Command as $Command } from \"@aws-sdk/smithy-client\";\n/**\n * Uploads a part in a multipart upload.
\n * \n * In this operation, you provide part data in your request. However, you have an option\n * to specify your existing Amazon S3 object as a data source for the part you are uploading. To\n * upload a part from an existing object, you use the UploadPartCopy operation.\n *
\n * \n *\n * You must initiate a multipart upload (see CreateMultipartUpload)\n * before you can upload any part. In response to your initiate request, Amazon S3 returns an\n * upload ID, a unique identifier, that you must include in your upload part request.
\n * Part numbers can be any number from 1 to 10,000, inclusive. A part number uniquely\n * identifies a part and also defines its position within the object being created. If you\n * upload a new part using the same part number that was used with a previous part, the\n * previously uploaded part is overwritten. Each part must be at least 5 MB in size, except\n * the last part. There is no size limit on the last part of your multipart upload.
\n * To ensure that data is not corrupted when traversing the network, specify the\n * Content-MD5
header in the upload part request. Amazon S3 checks the part data\n * against the provided MD5 value. If they do not match, Amazon S3 returns an error.
\n *\n * If the upload request is signed with Signature Version 4, then AWS S3 uses the\n * x-amz-content-sha256
header as a checksum instead of\n * Content-MD5
. For more information see Authenticating Requests: Using the Authorization Header (AWS Signature Version\n * 4).
\n *\n *\n *\n * \n * Note: After you initiate multipart upload and upload\n * one or more parts, you must either complete or abort multipart upload in order to stop\n * getting charged for storage of the uploaded parts. Only after you either complete or abort\n * multipart upload, Amazon S3 frees up the parts storage and stops charging you for the parts\n * storage.
\n *\n * For more information on multipart uploads, go to Multipart Upload Overview in the\n * Amazon Simple Storage Service Developer Guide .
\n * For information on the permissions required to use the multipart upload API, go to\n * Multipart Upload API and\n * Permissions in the Amazon Simple Storage Service Developer Guide.
\n *\n * You can optionally request server-side encryption where Amazon S3 encrypts your data as it\n * writes it to disks in its data centers and decrypts it for you when you access it. You have\n * the option of providing your own encryption key, or you can use the AWS managed encryption\n * keys. If you choose to provide your own encryption key, the request headers you provide in\n * the request must match the headers you used in the request to initiate the upload by using\n * CreateMultipartUpload. For more information, go to Using Server-Side Encryption in\n * the Amazon Simple Storage Service Developer Guide.
\n *\n * Server-side encryption is supported by the S3 Multipart Upload actions. Unless you are\n * using a customer-provided encryption key, you don't need to specify the encryption\n * parameters in each UploadPart request. Instead, you only need to specify the server-side\n * encryption parameters in the initial Initiate Multipart request. For more information, see\n * CreateMultipartUpload.
\n *\n * If you requested server-side encryption using a customer-provided encryption key in your\n * initiate multipart upload request, you must provide identical encryption information in\n * each part upload using the following headers.
\n *\n *\n * \n * - \n *
x-amz-server-side-encryption-customer-algorithm
\n * \n * - \n *
x-amz-server-side-encryption-customer-key
\n * \n * - \n *
x-amz-server-side-encryption-customer-key-MD5
\n * \n *
\n *\n * \n * Special Errors\n *
\n * \n * - \n *
\n * - \n *
\n * Code: NoSuchUpload\n *
\n * \n * - \n *
\n * Cause: The specified multipart upload does not exist. The upload\n * ID might be invalid, or the multipart upload might have been aborted or\n * completed.\n *
\n * \n * - \n *
\n * HTTP Status Code: 404 Not Found \n *
\n * \n * - \n *
\n * SOAP Fault Code Prefix: Client\n *
\n * \n *
\n * \n *
\n *\n *\n *\n *\n *\n *\n * \n * Related Resources\n *
\n * \n */\nvar UploadPartCommand = /** @class */ (function (_super) {\n __extends(UploadPartCommand, _super);\n // Start section: command_properties\n // End section: command_properties\n function UploadPartCommand(input) {\n var _this = \n // Start section: command_constructor\n _super.call(this) || this;\n _this.input = input;\n return _this;\n // End section: command_constructor\n }\n /**\n * @internal\n */\n UploadPartCommand.prototype.resolveMiddleware = function (clientStack, configuration, options) {\n this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));\n this.middlewareStack.use(getSsecPlugin(configuration));\n this.middlewareStack.use(getBucketEndpointPlugin(configuration));\n var stack = clientStack.concat(this.middlewareStack);\n var logger = configuration.logger;\n var clientName = \"S3Client\";\n var commandName = \"UploadPartCommand\";\n var handlerExecutionContext = {\n logger: logger,\n clientName: clientName,\n commandName: commandName,\n inputFilterSensitiveLog: UploadPartRequest.filterSensitiveLog,\n outputFilterSensitiveLog: UploadPartOutput.filterSensitiveLog,\n };\n var requestHandler = configuration.requestHandler;\n return stack.resolve(function (request) {\n return requestHandler.handle(request.request, options || {});\n }, handlerExecutionContext);\n };\n UploadPartCommand.prototype.serialize = function (input, context) {\n return serializeAws_restXmlUploadPartCommand(input, context);\n };\n UploadPartCommand.prototype.deserialize = function (output, context) {\n return deserializeAws_restXmlUploadPartCommand(output, context);\n };\n return UploadPartCommand;\n}($Command));\nexport { UploadPartCommand };\n//# sourceMappingURL=UploadPartCommand.js.map","import { __extends } from \"tslib\";\nimport { CompleteMultipartUploadOutput, CompleteMultipartUploadRequest } from \"../models/models_0\";\nimport { deserializeAws_restXmlCompleteMultipartUploadCommand, serializeAws_restXmlCompleteMultipartUploadCommand, } from \"../protocols/Aws_restXml\";\nimport { getBucketEndpointPlugin } from \"@aws-sdk/middleware-bucket-endpoint\";\nimport { getThrow200ExceptionsPlugin } from \"@aws-sdk/middleware-sdk-s3\";\nimport { getSerdePlugin } from \"@aws-sdk/middleware-serde\";\nimport { Command as $Command } from \"@aws-sdk/smithy-client\";\n/**\n * Completes a multipart upload by assembling previously uploaded parts.
\n * You first initiate the multipart upload and then upload all parts using the UploadPart\n * operation. After successfully uploading all relevant parts of an upload, you call this\n * operation to complete the upload. Upon receiving this request, Amazon S3 concatenates all\n * the parts in ascending order by part number to create a new object. In the Complete\n * Multipart Upload request, you must provide the parts list. You must ensure that the parts\n * list is complete. This operation concatenates the parts that you provide in the list. For\n * each part in the list, you must provide the part number and the ETag
value,\n * returned after that part was uploaded.
\n * Processing of a Complete Multipart Upload request could take several minutes to\n * complete. After Amazon S3 begins processing the request, it sends an HTTP response header that\n * specifies a 200 OK response. While processing is in progress, Amazon S3 periodically sends white\n * space characters to keep the connection from timing out. Because a request could fail after\n * the initial 200 OK response has been sent, it is important that you check the response body\n * to determine whether the request succeeded.
\n * Note that if CompleteMultipartUpload
fails, applications should be prepared\n * to retry the failed requests. For more information, see Amazon S3 Error Best Practices.
\n * For more information about multipart uploads, see Uploading Objects Using Multipart\n * Upload.
\n * For information about permissions required to use the multipart upload API, see Multipart Upload API and\n * Permissions.
\n *\n *\n * \n * CompleteMultipartUpload
has the following special errors:
\n * \n * - \n *
Error code: EntityTooSmall
\n *
\n * \n * \n * - \n *
Error code: InvalidPart
\n *
\n * \n * \n * - \n *
Error code: InvalidPartOrder
\n *
\n * \n * \n * - \n *
Error code: NoSuchUpload
\n *
\n * \n * \n *
\n *\n * The following operations are related to CompleteMultipartUpload
:
\n * \n */\nvar CompleteMultipartUploadCommand = /** @class */ (function (_super) {\n __extends(CompleteMultipartUploadCommand, _super);\n // Start section: command_properties\n // End section: command_properties\n function CompleteMultipartUploadCommand(input) {\n var _this = \n // Start section: command_constructor\n _super.call(this) || this;\n _this.input = input;\n return _this;\n // End section: command_constructor\n }\n /**\n * @internal\n */\n CompleteMultipartUploadCommand.prototype.resolveMiddleware = function (clientStack, configuration, options) {\n this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));\n this.middlewareStack.use(getThrow200ExceptionsPlugin(configuration));\n this.middlewareStack.use(getBucketEndpointPlugin(configuration));\n var stack = clientStack.concat(this.middlewareStack);\n var logger = configuration.logger;\n var clientName = \"S3Client\";\n var commandName = \"CompleteMultipartUploadCommand\";\n var handlerExecutionContext = {\n logger: logger,\n clientName: clientName,\n commandName: commandName,\n inputFilterSensitiveLog: CompleteMultipartUploadRequest.filterSensitiveLog,\n outputFilterSensitiveLog: CompleteMultipartUploadOutput.filterSensitiveLog,\n };\n var requestHandler = configuration.requestHandler;\n return stack.resolve(function (request) {\n return requestHandler.handle(request.request, options || {});\n }, handlerExecutionContext);\n };\n CompleteMultipartUploadCommand.prototype.serialize = function (input, context) {\n return serializeAws_restXmlCompleteMultipartUploadCommand(input, context);\n };\n CompleteMultipartUploadCommand.prototype.deserialize = function (output, context) {\n return deserializeAws_restXmlCompleteMultipartUploadCommand(output, context);\n };\n return CompleteMultipartUploadCommand;\n}($Command));\nexport { CompleteMultipartUploadCommand };\n//# sourceMappingURL=CompleteMultipartUploadCommand.js.map","import { __extends } from \"tslib\";\nimport { AbortMultipartUploadOutput, AbortMultipartUploadRequest } from \"../models/models_0\";\nimport { deserializeAws_restXmlAbortMultipartUploadCommand, serializeAws_restXmlAbortMultipartUploadCommand, } from \"../protocols/Aws_restXml\";\nimport { getBucketEndpointPlugin } from \"@aws-sdk/middleware-bucket-endpoint\";\nimport { getSerdePlugin } from \"@aws-sdk/middleware-serde\";\nimport { Command as $Command } from \"@aws-sdk/smithy-client\";\n/**\n * This operation aborts a multipart upload. After a multipart upload is aborted, no\n * additional parts can be uploaded using that upload ID. The storage consumed by any\n * previously uploaded parts will be freed. However, if any part uploads are currently in\n * progress, those part uploads might or might not succeed. As a result, it might be necessary\n * to abort a given multipart upload multiple times in order to completely free all storage\n * consumed by all parts.
\n * To verify that all parts have been removed, so you don't get charged for the part\n * storage, you should call the ListParts operation and ensure that\n * the parts list is empty.
\n * For information about permissions required to use the multipart upload API, see Multipart Upload API and\n * Permissions.
\n * The following operations are related to AbortMultipartUpload
:
\n * \n */\nvar AbortMultipartUploadCommand = /** @class */ (function (_super) {\n __extends(AbortMultipartUploadCommand, _super);\n // Start section: command_properties\n // End section: command_properties\n function AbortMultipartUploadCommand(input) {\n var _this = \n // Start section: command_constructor\n _super.call(this) || this;\n _this.input = input;\n return _this;\n // End section: command_constructor\n }\n /**\n * @internal\n */\n AbortMultipartUploadCommand.prototype.resolveMiddleware = function (clientStack, configuration, options) {\n this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));\n this.middlewareStack.use(getBucketEndpointPlugin(configuration));\n var stack = clientStack.concat(this.middlewareStack);\n var logger = configuration.logger;\n var clientName = \"S3Client\";\n var commandName = \"AbortMultipartUploadCommand\";\n var handlerExecutionContext = {\n logger: logger,\n clientName: clientName,\n commandName: commandName,\n inputFilterSensitiveLog: AbortMultipartUploadRequest.filterSensitiveLog,\n outputFilterSensitiveLog: AbortMultipartUploadOutput.filterSensitiveLog,\n };\n var requestHandler = configuration.requestHandler;\n return stack.resolve(function (request) {\n return requestHandler.handle(request.request, options || {});\n }, handlerExecutionContext);\n };\n AbortMultipartUploadCommand.prototype.serialize = function (input, context) {\n return serializeAws_restXmlAbortMultipartUploadCommand(input, context);\n };\n AbortMultipartUploadCommand.prototype.deserialize = function (output, context) {\n return deserializeAws_restXmlAbortMultipartUploadCommand(output, context);\n };\n return AbortMultipartUploadCommand;\n}($Command));\nexport { AbortMultipartUploadCommand };\n//# sourceMappingURL=AbortMultipartUploadCommand.js.map","import { __extends } from \"tslib\";\nimport { ListPartsOutput, ListPartsRequest } from \"../models/models_0\";\nimport { deserializeAws_restXmlListPartsCommand, serializeAws_restXmlListPartsCommand } from \"../protocols/Aws_restXml\";\nimport { getBucketEndpointPlugin } from \"@aws-sdk/middleware-bucket-endpoint\";\nimport { getSerdePlugin } from \"@aws-sdk/middleware-serde\";\nimport { Command as $Command } from \"@aws-sdk/smithy-client\";\n/**\n * Lists the parts that have been uploaded for a specific multipart upload. This operation\n * must include the upload ID, which you obtain by sending the initiate multipart upload\n * request (see CreateMultipartUpload).\n * This request returns a maximum of 1,000 uploaded parts. The default number of parts\n * returned is 1,000 parts. You can restrict the number of parts returned by specifying the\n * max-parts
request parameter. If your multipart upload consists of more than\n * 1,000 parts, the response returns an IsTruncated
field with the value of true,\n * and a NextPartNumberMarker
element. In subsequent ListParts
\n * requests you can include the part-number-marker query string parameter and set its value to\n * the NextPartNumberMarker
field value from the previous response.
\n *\n * For more information on multipart uploads, see Uploading Objects Using Multipart\n * Upload.
\n *\n * For information on permissions required to use the multipart upload API, see Multipart Upload API and\n * Permissions.
\n *\n * The following operations are related to ListParts
:
\n * \n */\nvar ListPartsCommand = /** @class */ (function (_super) {\n __extends(ListPartsCommand, _super);\n // Start section: command_properties\n // End section: command_properties\n function ListPartsCommand(input) {\n var _this = \n // Start section: command_constructor\n _super.call(this) || this;\n _this.input = input;\n return _this;\n // End section: command_constructor\n }\n /**\n * @internal\n */\n ListPartsCommand.prototype.resolveMiddleware = function (clientStack, configuration, options) {\n this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));\n this.middlewareStack.use(getBucketEndpointPlugin(configuration));\n var stack = clientStack.concat(this.middlewareStack);\n var logger = configuration.logger;\n var clientName = \"S3Client\";\n var commandName = \"ListPartsCommand\";\n var handlerExecutionContext = {\n logger: logger,\n clientName: clientName,\n commandName: commandName,\n inputFilterSensitiveLog: ListPartsRequest.filterSensitiveLog,\n outputFilterSensitiveLog: ListPartsOutput.filterSensitiveLog,\n };\n var requestHandler = configuration.requestHandler;\n return stack.resolve(function (request) {\n return requestHandler.handle(request.request, options || {});\n }, handlerExecutionContext);\n };\n ListPartsCommand.prototype.serialize = function (input, context) {\n return serializeAws_restXmlListPartsCommand(input, context);\n };\n ListPartsCommand.prototype.deserialize = function (output, context) {\n return deserializeAws_restXmlListPartsCommand(output, context);\n };\n return ListPartsCommand;\n}($Command));\nexport { ListPartsCommand };\n//# sourceMappingURL=ListPartsCommand.js.map","/*\n * Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use this file except in compliance with\n * the License. A copy of the License is located at\n *\n * http://aws.amazon.com/apache2.0/\n *\n * or in the \"license\" file accompanying this file. This file is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions\n * and limitations under the License.\n */\nvar __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nimport { ConsoleLogger as Logger, getAmplifyUserAgent, Credentials, } from '@aws-amplify/core';\nimport { S3Client, PutObjectCommand, CreateMultipartUploadCommand, UploadPartCommand, CompleteMultipartUploadCommand, ListPartsCommand, AbortMultipartUploadCommand, } from '@aws-sdk/client-s3';\nimport { AxiosHttpHandler, SEND_UPLOAD_PROGRESS_EVENT, SEND_DOWNLOAD_PROGRESS_EVENT } from './axios-http-handler';\nimport * as events from 'events';\nvar logger = new Logger('AWSS3ProviderManagedUpload');\nvar localTestingStorageEndpoint = 'http://localhost:20005';\nvar SET_CONTENT_LENGTH_HEADER = 'contentLengthMiddleware';\nvar AWSS3ProviderManagedUpload = /** @class */ (function () {\n function AWSS3ProviderManagedUpload(params, opts, emitter) {\n // Defaults\n this.minPartSize = 5 * 1024 * 1024; // in MB\n this.queueSize = 4;\n // Data for current upload\n this.body = null;\n this.params = null;\n this.opts = null;\n this.completedParts = [];\n this.cancel = false;\n // Progress reporting\n this.bytesUploaded = 0;\n this.totalBytesToUpload = 0;\n this.emitter = null;\n this.params = params;\n this.opts = opts;\n this.emitter = emitter;\n }\n AWSS3ProviderManagedUpload.prototype.upload = function () {\n return __awaiter(this, void 0, void 0, function () {\n var _a, putObjectCommand, s3, uploadId, numberOfPartsToUpload, parts, start;\n var _this = this;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n _a = this;\n return [4 /*yield*/, this.validateAndSanitizeBody(this.params.Body)];\n case 1:\n _a.body = _b.sent();\n this.totalBytesToUpload = this.byteLength(this.body);\n if (!(this.totalBytesToUpload <= this.minPartSize)) return [3 /*break*/, 3];\n // Multipart upload is not required. Upload the sanitized body as is\n this.params.Body = this.body;\n putObjectCommand = new PutObjectCommand(this.params);\n return [4 /*yield*/, this._createNewS3Client(this.opts, this.emitter)];\n case 2:\n s3 = _b.sent();\n return [2 /*return*/, s3.send(putObjectCommand)];\n case 3: return [4 /*yield*/, this.createMultiPartUpload()];\n case 4:\n uploadId = _b.sent();\n numberOfPartsToUpload = Math.ceil(this.totalBytesToUpload / this.minPartSize);\n parts = this.createParts();\n start = 0;\n _b.label = 5;\n case 5:\n if (!(start < numberOfPartsToUpload)) return [3 /*break*/, 10];\n /** This first block will try to cancel the upload if the cancel\n *\trequest came before any parts uploads have started.\n **/\n return [4 /*yield*/, this.checkIfUploadCancelled(uploadId)];\n case 6:\n /** This first block will try to cancel the upload if the cancel\n *\trequest came before any parts uploads have started.\n **/\n _b.sent();\n // Upload as many as `queueSize` parts simultaneously\n return [4 /*yield*/, this.uploadParts(uploadId, parts.slice(start, start + this.queueSize))];\n case 7:\n // Upload as many as `queueSize` parts simultaneously\n _b.sent();\n /** Call cleanup a second time in case there were part upload requests\n * in flight. This is to ensure that all parts are cleaned up.\n */\n return [4 /*yield*/, this.checkIfUploadCancelled(uploadId)];\n case 8:\n /** Call cleanup a second time in case there were part upload requests\n * in flight. This is to ensure that all parts are cleaned up.\n */\n _b.sent();\n _b.label = 9;\n case 9:\n start += this.queueSize;\n return [3 /*break*/, 5];\n case 10:\n parts.map(function (part) {\n _this.removeEventListener(part);\n });\n return [4 /*yield*/, this.finishMultiPartUpload(uploadId)];\n case 11: \n // Step 3: Finalize the upload such that S3 can recreate the file\n return [2 /*return*/, _b.sent()];\n }\n });\n });\n };\n AWSS3ProviderManagedUpload.prototype.createParts = function () {\n var parts = [];\n for (var bodyStart = 0; bodyStart < this.totalBytesToUpload;) {\n var bodyEnd = Math.min(bodyStart + this.minPartSize, this.totalBytesToUpload);\n parts.push({\n bodyPart: this.body.slice(bodyStart, bodyEnd),\n partNumber: parts.length + 1,\n emitter: new events.EventEmitter(),\n _lastUploadedBytes: 0,\n });\n bodyStart += this.minPartSize;\n }\n return parts;\n };\n AWSS3ProviderManagedUpload.prototype.createMultiPartUpload = function () {\n return __awaiter(this, void 0, void 0, function () {\n var createMultiPartUploadCommand, s3, response;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n createMultiPartUploadCommand = new CreateMultipartUploadCommand(this.params);\n return [4 /*yield*/, this._createNewS3Client(this.opts)];\n case 1:\n s3 = _a.sent();\n // @aws-sdk/client-s3 seems to be ignoring the `ContentType` parameter, so we\n // are explicitly adding it via middleware.\n // https://github.com/aws/aws-sdk-js-v3/issues/2000\n s3.middlewareStack.add(function (next) { return function (args) {\n if (_this.params.ContentType &&\n args &&\n args.request &&\n args.request.headers) {\n args.request.headers['Content-Type'] = _this.params.ContentType;\n }\n return next(args);\n }; }, {\n step: 'build',\n });\n return [4 /*yield*/, s3.send(createMultiPartUploadCommand)];\n case 2:\n response = _a.sent();\n logger.debug(response.UploadId);\n return [2 /*return*/, response.UploadId];\n }\n });\n });\n };\n /**\n * @private Not to be extended outside of tests\n * @VisibleFotTesting\n */\n AWSS3ProviderManagedUpload.prototype.uploadParts = function (uploadId, parts) {\n return __awaiter(this, void 0, void 0, function () {\n var allResults, i, error_1;\n var _this = this;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n _a.trys.push([0, 2, , 3]);\n return [4 /*yield*/, Promise.all(parts.map(function (part) { return __awaiter(_this, void 0, void 0, function () {\n var s3, _a, Key, Bucket, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n this.setupEventListener(part);\n return [4 /*yield*/, this._createNewS3Client(this.opts, part.emitter)];\n case 1:\n s3 = _b.sent();\n _a = this.params, Key = _a.Key, Bucket = _a.Bucket, SSECustomerAlgorithm = _a.SSECustomerAlgorithm, SSECustomerKey = _a.SSECustomerKey, SSECustomerKeyMD5 = _a.SSECustomerKeyMD5;\n return [2 /*return*/, s3.send(new UploadPartCommand(__assign(__assign(__assign({ PartNumber: part.partNumber, Body: part.bodyPart, UploadId: uploadId, Key: Key,\n Bucket: Bucket }, (SSECustomerAlgorithm && { SSECustomerAlgorithm: SSECustomerAlgorithm })), (SSECustomerKey && { SSECustomerKey: SSECustomerKey })), (SSECustomerKeyMD5 && { SSECustomerKeyMD5: SSECustomerKeyMD5 }))))];\n }\n });\n }); }))];\n case 1:\n allResults = _a.sent();\n // The order of resolved promises is the same as input promise order.\n for (i = 0; i < allResults.length; i++) {\n this.completedParts.push({\n PartNumber: parts[i].partNumber,\n ETag: allResults[i].ETag,\n });\n }\n return [3 /*break*/, 3];\n case 2:\n error_1 = _a.sent();\n logger.error('error happened while uploading a part. Cancelling the multipart upload', error_1);\n this.cancelUpload();\n return [2 /*return*/];\n case 3: return [2 /*return*/];\n }\n });\n });\n };\n AWSS3ProviderManagedUpload.prototype.finishMultiPartUpload = function (uploadId) {\n return __awaiter(this, void 0, void 0, function () {\n var input, completeUploadCommand, s3, data, error_2;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n input = {\n Bucket: this.params.Bucket,\n Key: this.params.Key,\n UploadId: uploadId,\n MultipartUpload: { Parts: this.completedParts },\n };\n completeUploadCommand = new CompleteMultipartUploadCommand(input);\n return [4 /*yield*/, this._createNewS3Client(this.opts)];\n case 1:\n s3 = _a.sent();\n _a.label = 2;\n case 2:\n _a.trys.push([2, 4, , 5]);\n return [4 /*yield*/, s3.send(completeUploadCommand)];\n case 3:\n data = _a.sent();\n return [2 /*return*/, data.Key];\n case 4:\n error_2 = _a.sent();\n logger.error('error happened while finishing the upload. Cancelling the multipart upload', error_2);\n this.cancelUpload();\n return [2 /*return*/];\n case 5: return [2 /*return*/];\n }\n });\n });\n };\n AWSS3ProviderManagedUpload.prototype.checkIfUploadCancelled = function (uploadId) {\n return __awaiter(this, void 0, void 0, function () {\n var errorMessage, error_3;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!this.cancel) return [3 /*break*/, 5];\n errorMessage = 'Upload was cancelled.';\n _a.label = 1;\n case 1:\n _a.trys.push([1, 3, , 4]);\n return [4 /*yield*/, this.cleanup(uploadId)];\n case 2:\n _a.sent();\n return [3 /*break*/, 4];\n case 3:\n error_3 = _a.sent();\n errorMessage += \" \" + error_3.message;\n return [3 /*break*/, 4];\n case 4: throw new Error(errorMessage);\n case 5: return [2 /*return*/];\n }\n });\n });\n };\n AWSS3ProviderManagedUpload.prototype.cancelUpload = function () {\n this.cancel = true;\n };\n AWSS3ProviderManagedUpload.prototype.cleanup = function (uploadId) {\n return __awaiter(this, void 0, void 0, function () {\n var input, s3, data;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n // Reset this's state\n this.body = null;\n this.completedParts = [];\n this.bytesUploaded = 0;\n this.totalBytesToUpload = 0;\n input = {\n Bucket: this.params.Bucket,\n Key: this.params.Key,\n UploadId: uploadId,\n };\n return [4 /*yield*/, this._createNewS3Client(this.opts)];\n case 1:\n s3 = _a.sent();\n return [4 /*yield*/, s3.send(new AbortMultipartUploadCommand(input))];\n case 2:\n _a.sent();\n return [4 /*yield*/, s3.send(new ListPartsCommand(input))];\n case 3:\n data = _a.sent();\n if (data && data.Parts && data.Parts.length > 0) {\n throw new Error('Multi Part upload clean up failed');\n }\n return [2 /*return*/];\n }\n });\n });\n };\n AWSS3ProviderManagedUpload.prototype.removeEventListener = function (part) {\n part.emitter.removeAllListeners(SEND_UPLOAD_PROGRESS_EVENT);\n part.emitter.removeAllListeners(SEND_DOWNLOAD_PROGRESS_EVENT);\n };\n AWSS3ProviderManagedUpload.prototype.setupEventListener = function (part) {\n var _this = this;\n part.emitter.on(SEND_UPLOAD_PROGRESS_EVENT, function (progress) {\n _this.progressChanged(part.partNumber, progress.loaded - part._lastUploadedBytes);\n part._lastUploadedBytes = progress.loaded;\n });\n };\n AWSS3ProviderManagedUpload.prototype.progressChanged = function (partNumber, incrementalUpdate) {\n this.bytesUploaded += incrementalUpdate;\n this.emitter.emit(SEND_UPLOAD_PROGRESS_EVENT, {\n loaded: this.bytesUploaded,\n total: this.totalBytesToUpload,\n part: partNumber,\n key: this.params.Key,\n });\n };\n AWSS3ProviderManagedUpload.prototype.byteLength = function (input) {\n if (input === null || input === undefined)\n return 0;\n if (typeof input.byteLength === 'number') {\n return input.byteLength;\n }\n else if (typeof input.length === 'number') {\n return input.length;\n }\n else if (typeof input.size === 'number') {\n return input.size;\n }\n else if (typeof input.path === 'string') {\n /* NodeJs Support\n return require('fs').lstatSync(input.path).size;\n */\n }\n else {\n throw new Error('Cannot determine length of ' + input);\n }\n };\n AWSS3ProviderManagedUpload.prototype.validateAndSanitizeBody = function (body) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n if (this.isGenericObject(body)) {\n // Any javascript object\n return [2 /*return*/, JSON.stringify(body)];\n }\n else {\n // Files, arrayBuffer etc\n return [2 /*return*/, body];\n }\n return [2 /*return*/];\n });\n });\n };\n AWSS3ProviderManagedUpload.prototype.isGenericObject = function (body) {\n if (body !== null && typeof body === 'object') {\n try {\n return !(this.byteLength(body) >= 0);\n }\n catch (error) {\n // If we cannot determine the length of the body, consider it\n // as a generic object and upload a stringified version of it\n return true;\n }\n }\n return false;\n };\n /**\n * @private\n * creates an S3 client with new V3 aws sdk\n */\n AWSS3ProviderManagedUpload.prototype._createNewS3Client = function (config, emitter) {\n return __awaiter(this, void 0, void 0, function () {\n var credentials, region, dangerouslyConnectToHttpEndpointForTesting, cancelTokenSource, useAccelerateEndpoint, localTestingConfig, client;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this._getCredentials()];\n case 1:\n credentials = _a.sent();\n region = config.region, dangerouslyConnectToHttpEndpointForTesting = config.dangerouslyConnectToHttpEndpointForTesting, cancelTokenSource = config.cancelTokenSource, useAccelerateEndpoint = config.useAccelerateEndpoint;\n localTestingConfig = {};\n if (dangerouslyConnectToHttpEndpointForTesting) {\n localTestingConfig = {\n endpoint: localTestingStorageEndpoint,\n tls: false,\n bucketEndpoint: false,\n forcePathStyle: true,\n };\n }\n client = new S3Client(__assign(__assign({ region: region,\n credentials: credentials,\n useAccelerateEndpoint: useAccelerateEndpoint }, localTestingConfig), { requestHandler: new AxiosHttpHandler({}, emitter, cancelTokenSource), customUserAgent: getAmplifyUserAgent() }));\n client.middlewareStack.remove(SET_CONTENT_LENGTH_HEADER);\n return [2 /*return*/, client];\n }\n });\n });\n };\n /**\n * @private\n */\n AWSS3ProviderManagedUpload.prototype._getCredentials = function () {\n return Credentials.get()\n .then(function (credentials) {\n if (!credentials)\n return false;\n var cred = Credentials.shear(credentials);\n logger.debug('set credentials for storage', cred);\n return cred;\n })\n .catch(function (error) {\n logger.warn('ensure credentials error', error);\n return false;\n });\n };\n return AWSS3ProviderManagedUpload;\n}());\nexport { AWSS3ProviderManagedUpload };\n//# sourceMappingURL=AWSS3ProviderManagedUpload.js.map","var __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\n/*\n * Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use this file except in compliance with\n * the License. A copy of the License is located at\n *\n * http://aws.amazon.com/apache2.0/\n *\n * or in the \"license\" file accompanying this file. This file is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions\n * and limitations under the License.\n */\nimport { ConsoleLogger as Logger, Hub, Credentials, Parser, getAmplifyUserAgent, } from '@aws-amplify/core';\nimport { S3Client, GetObjectCommand, DeleteObjectCommand, ListObjectsCommand, CopyObjectCommand, } from '@aws-sdk/client-s3';\nimport { formatUrl } from '@aws-sdk/util-format-url';\nimport { createRequest } from '@aws-sdk/util-create-request';\nimport { S3RequestPresigner } from '@aws-sdk/s3-request-presigner';\nimport { AxiosHttpHandler, SEND_DOWNLOAD_PROGRESS_EVENT, SEND_UPLOAD_PROGRESS_EVENT } from './axios-http-handler';\nimport { StorageErrorStrings } from '../common/StorageErrorStrings';\nimport { AWSS3ProviderManagedUpload } from './AWSS3ProviderManagedUpload';\nimport * as events from 'events';\nvar logger = new Logger('AWSS3Provider');\nvar AMPLIFY_SYMBOL = (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function'\n ? Symbol.for('amplify_default')\n : '@@amplify_default');\nvar SET_CONTENT_LENGTH_HEADER = 'contentLengthMiddleware';\nvar DEFAULT_STORAGE_LEVEL = 'public';\nvar DEFAULT_PRESIGN_EXPIRATION = 900;\nvar dispatchStorageEvent = function (track, event, attrs, metrics, message) {\n if (track) {\n var data = { attrs: attrs };\n if (metrics) {\n data['metrics'] = metrics;\n }\n Hub.dispatch('storage', {\n event: event,\n data: data,\n message: message,\n }, 'Storage', AMPLIFY_SYMBOL);\n }\n};\nvar localTestingStorageEndpoint = 'http://localhost:20005';\n/**\n * Provide storage methods to use AWS S3\n */\nvar AWSS3Provider = /** @class */ (function () {\n /**\n * Initialize Storage with AWS configurations\n * @param {Object} config - Configuration object for storage\n */\n function AWSS3Provider(config) {\n this._config = config ? config : {};\n logger.debug('Storage Options', this._config);\n }\n /**\n * get the category of the plugin\n */\n AWSS3Provider.prototype.getCategory = function () {\n return AWSS3Provider.CATEGORY;\n };\n /**\n * get provider name of the plugin\n */\n AWSS3Provider.prototype.getProviderName = function () {\n return AWSS3Provider.PROVIDER_NAME;\n };\n /**\n * Configure Storage part with aws configuration\n * @param {Object} config - Configuration of the Storage\n * @return {Object} - Current configuration\n */\n AWSS3Provider.prototype.configure = function (config) {\n logger.debug('configure Storage', config);\n if (!config)\n return this._config;\n var amplifyConfig = Parser.parseMobilehubConfig(config);\n this._config = Object.assign({}, this._config, amplifyConfig.Storage);\n if (!this._config.bucket) {\n logger.debug('Do not have bucket yet');\n }\n return this._config;\n };\n /**\n * Copy an object from a source object to a new object within the same bucket. Can optionally copy files across\n * different level or identityId (if source object's level is 'protected').\n *\n * @async\n * @param {S3CopySource} src - Key and optionally access level and identityId of the source object.\n * @param {S3CopyDestination} dest - Key and optionally access level of the destination object.\n * @param {S3ProviderCopyConfig} [config] - Optional configuration for s3 commands.\n * @return {Promise} The key of the copied object.\n */\n AWSS3Provider.prototype.copy = function (src, dest, config) {\n return __awaiter(this, void 0, void 0, function () {\n var credentialsOK, opt, acl, bucket, cacheControl, expires, track, serverSideEncryption, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, SSEKMSKeyId, _a, srcLevel, srcIdentityId, srcKey, _b, destLevel, destKey, srcPrefix, destPrefix, finalSrcKey, finalDestKey, params, s3, error_1;\n return __generator(this, function (_c) {\n switch (_c.label) {\n case 0: return [4 /*yield*/, this._ensureCredentials()];\n case 1:\n credentialsOK = _c.sent();\n if (!credentialsOK || !this._isWithCredentials(this._config)) {\n throw new Error(StorageErrorStrings.NO_CREDENTIALS);\n }\n opt = Object.assign({}, this._config, config);\n acl = opt.acl, bucket = opt.bucket, cacheControl = opt.cacheControl, expires = opt.expires, track = opt.track, serverSideEncryption = opt.serverSideEncryption, SSECustomerAlgorithm = opt.SSECustomerAlgorithm, SSECustomerKey = opt.SSECustomerKey, SSECustomerKeyMD5 = opt.SSECustomerKeyMD5, SSEKMSKeyId = opt.SSEKMSKeyId;\n _a = src.level, srcLevel = _a === void 0 ? DEFAULT_STORAGE_LEVEL : _a, srcIdentityId = src.identityId, srcKey = src.key;\n _b = dest.level, destLevel = _b === void 0 ? DEFAULT_STORAGE_LEVEL : _b, destKey = dest.key;\n if (!srcKey || typeof srcKey !== 'string') {\n throw new Error(StorageErrorStrings.NO_SRC_KEY);\n }\n if (!destKey || typeof destKey !== 'string') {\n throw new Error(StorageErrorStrings.NO_DEST_KEY);\n }\n if (srcLevel !== 'protected' && srcIdentityId) {\n logger.warn(\"You may copy files from another user if the source level is \\\"protected\\\", currently it's \" + srcLevel);\n }\n srcPrefix = this._prefix(__assign(__assign(__assign({}, opt), { level: srcLevel }), (srcIdentityId && { identityId: srcIdentityId })));\n destPrefix = this._prefix(__assign(__assign({}, opt), { level: destLevel }));\n finalSrcKey = bucket + \"/\" + srcPrefix + srcKey;\n finalDestKey = \"\" + destPrefix + destKey;\n logger.debug(\"copying \" + finalSrcKey + \" to \" + finalDestKey);\n params = {\n Bucket: bucket,\n CopySource: finalSrcKey,\n Key: finalDestKey,\n // Copies over metadata like contentType as well\n MetadataDirective: 'COPY',\n };\n if (cacheControl)\n params.CacheControl = cacheControl;\n if (expires)\n params.Expires = expires;\n if (serverSideEncryption) {\n params.ServerSideEncryption = serverSideEncryption;\n }\n if (SSECustomerAlgorithm) {\n params.SSECustomerAlgorithm = SSECustomerAlgorithm;\n }\n if (SSECustomerKey) {\n params.SSECustomerKey = SSECustomerKey;\n }\n if (SSECustomerKeyMD5) {\n params.SSECustomerKeyMD5 = SSECustomerKeyMD5;\n }\n if (SSEKMSKeyId) {\n params.SSEKMSKeyId = SSEKMSKeyId;\n }\n if (acl)\n params.ACL = acl;\n s3 = this._createNewS3Client(opt);\n s3.middlewareStack.remove(SET_CONTENT_LENGTH_HEADER);\n _c.label = 2;\n case 2:\n _c.trys.push([2, 4, , 5]);\n return [4 /*yield*/, s3.send(new CopyObjectCommand(params))];\n case 3:\n _c.sent();\n dispatchStorageEvent(track, 'copy', {\n method: 'copy',\n result: 'success',\n }, null, \"Copy success from \" + srcKey + \" to \" + destKey);\n return [2 /*return*/, {\n key: destKey,\n }];\n case 4:\n error_1 = _c.sent();\n dispatchStorageEvent(track, 'copy', {\n method: 'copy',\n result: 'failed',\n }, null, \"Copy failed from \" + srcKey + \" to \" + destKey);\n throw error_1;\n case 5: return [2 /*return*/];\n }\n });\n });\n };\n AWSS3Provider.prototype.get = function (key, config) {\n return __awaiter(this, void 0, void 0, function () {\n var credentialsOK, opt, bucket, download, cacheControl, contentDisposition, contentEncoding, contentLanguage, contentType, expires, track, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, progressCallback, prefix, final_key, emitter, s3, params, getObjectCommand, response, error_2, signer, request, url, _a, error_3;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0: return [4 /*yield*/, this._ensureCredentials()];\n case 1:\n credentialsOK = _b.sent();\n if (!credentialsOK || !this._isWithCredentials(this._config)) {\n throw new Error(StorageErrorStrings.NO_CREDENTIALS);\n }\n opt = Object.assign({}, this._config, config);\n bucket = opt.bucket, download = opt.download, cacheControl = opt.cacheControl, contentDisposition = opt.contentDisposition, contentEncoding = opt.contentEncoding, contentLanguage = opt.contentLanguage, contentType = opt.contentType, expires = opt.expires, track = opt.track, SSECustomerAlgorithm = opt.SSECustomerAlgorithm, SSECustomerKey = opt.SSECustomerKey, SSECustomerKeyMD5 = opt.SSECustomerKeyMD5, progressCallback = opt.progressCallback;\n prefix = this._prefix(opt);\n final_key = prefix + key;\n emitter = new events.EventEmitter();\n s3 = this._createNewS3Client(opt, emitter);\n logger.debug('get ' + key + ' from ' + final_key);\n params = {\n Bucket: bucket,\n Key: final_key,\n };\n // See: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#getObject-property\n if (cacheControl)\n params.ResponseCacheControl = cacheControl;\n if (contentDisposition)\n params.ResponseContentDisposition = contentDisposition;\n if (contentEncoding)\n params.ResponseContentEncoding = contentEncoding;\n if (contentLanguage)\n params.ResponseContentLanguage = contentLanguage;\n if (contentType)\n params.ResponseContentType = contentType;\n if (SSECustomerAlgorithm) {\n params.SSECustomerAlgorithm = SSECustomerAlgorithm;\n }\n if (SSECustomerKey) {\n params.SSECustomerKey = SSECustomerKey;\n }\n if (SSECustomerKeyMD5) {\n params.SSECustomerKeyMD5 = SSECustomerKeyMD5;\n }\n if (!(download === true)) return [3 /*break*/, 5];\n getObjectCommand = new GetObjectCommand(params);\n _b.label = 2;\n case 2:\n _b.trys.push([2, 4, , 5]);\n if (progressCallback) {\n if (typeof progressCallback === 'function') {\n emitter.on(SEND_DOWNLOAD_PROGRESS_EVENT, function (progress) {\n progressCallback(progress);\n });\n }\n else {\n logger.warn('progressCallback should be a function, not a ' + typeof progressCallback);\n }\n }\n return [4 /*yield*/, s3.send(getObjectCommand)];\n case 3:\n response = _b.sent();\n emitter.removeAllListeners(SEND_DOWNLOAD_PROGRESS_EVENT);\n dispatchStorageEvent(track, 'download', { method: 'get', result: 'success' }, {\n fileSize: Number(response.Body['size'] || response.Body['length']),\n }, \"Download success for \" + key);\n return [2 /*return*/, response];\n case 4:\n error_2 = _b.sent();\n dispatchStorageEvent(track, 'download', {\n method: 'get',\n result: 'failed',\n }, null, \"Download failed with \" + error_2.message);\n throw error_2;\n case 5:\n _b.trys.push([5, 8, , 9]);\n signer = new S3RequestPresigner(__assign({}, s3.config));\n return [4 /*yield*/, createRequest(s3, new GetObjectCommand(params))];\n case 6:\n request = _b.sent();\n _a = formatUrl;\n return [4 /*yield*/, signer.presign(request, { expiresIn: expires || DEFAULT_PRESIGN_EXPIRATION })];\n case 7:\n url = _a.apply(void 0, [_b.sent()]);\n dispatchStorageEvent(track, 'getSignedUrl', { method: 'get', result: 'success' }, null, \"Signed URL: \" + url);\n return [2 /*return*/, url];\n case 8:\n error_3 = _b.sent();\n logger.warn('get signed url error', error_3);\n dispatchStorageEvent(track, 'getSignedUrl', { method: 'get', result: 'failed' }, null, \"Could not get a signed URL for \" + key);\n throw error_3;\n case 9: return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Put a file in S3 bucket specified to configure method\n * @param {string} key - key of the object\n * @param {PutObjectCommandInput[\"Body\"]} object - File to be put in Amazon S3 bucket\n * @param {S3ProviderPutConfig} [config] - Optional configuration for the underlying S3 command\n * @return {Promise} - promise resolves to an object with the new object's key on success\n */\n AWSS3Provider.prototype.put = function (key, object, config) {\n return __awaiter(this, void 0, void 0, function () {\n var credentialsOK, opt, bucket, track, progressCallback, contentType, contentDisposition, contentEncoding, cacheControl, expires, metadata, tagging, acl, serverSideEncryption, SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, SSEKMSKeyId, type, prefix, final_key, params, emitter, uploader, response, error_4;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this._ensureCredentials()];\n case 1:\n credentialsOK = _a.sent();\n if (!credentialsOK || !this._isWithCredentials(this._config)) {\n throw new Error(StorageErrorStrings.NO_CREDENTIALS);\n }\n opt = Object.assign({}, this._config, config);\n bucket = opt.bucket, track = opt.track, progressCallback = opt.progressCallback;\n contentType = opt.contentType, contentDisposition = opt.contentDisposition, contentEncoding = opt.contentEncoding, cacheControl = opt.cacheControl, expires = opt.expires, metadata = opt.metadata, tagging = opt.tagging, acl = opt.acl;\n serverSideEncryption = opt.serverSideEncryption, SSECustomerAlgorithm = opt.SSECustomerAlgorithm, SSECustomerKey = opt.SSECustomerKey, SSECustomerKeyMD5 = opt.SSECustomerKeyMD5, SSEKMSKeyId = opt.SSEKMSKeyId;\n type = contentType ? contentType : 'binary/octet-stream';\n prefix = this._prefix(opt);\n final_key = prefix + key;\n logger.debug('put ' + key + ' to ' + final_key);\n params = {\n Bucket: bucket,\n Key: final_key,\n Body: object,\n ContentType: type,\n };\n if (cacheControl) {\n params.CacheControl = cacheControl;\n }\n if (contentDisposition) {\n params.ContentDisposition = contentDisposition;\n }\n if (contentEncoding) {\n params.ContentEncoding = contentEncoding;\n }\n if (expires) {\n params.Expires = expires;\n }\n if (metadata) {\n params.Metadata = metadata;\n }\n if (tagging) {\n params.Tagging = tagging;\n }\n if (serverSideEncryption) {\n params.ServerSideEncryption = serverSideEncryption;\n }\n if (SSECustomerAlgorithm) {\n params.SSECustomerAlgorithm = SSECustomerAlgorithm;\n }\n if (SSECustomerKey) {\n params.SSECustomerKey = SSECustomerKey;\n }\n if (SSECustomerKeyMD5) {\n params.SSECustomerKeyMD5 = SSECustomerKeyMD5;\n }\n if (SSEKMSKeyId) {\n params.SSEKMSKeyId = SSEKMSKeyId;\n }\n emitter = new events.EventEmitter();\n uploader = new AWSS3ProviderManagedUpload(params, opt, emitter);\n if (acl) {\n params.ACL = acl;\n }\n _a.label = 2;\n case 2:\n _a.trys.push([2, 4, , 5]);\n if (progressCallback) {\n if (typeof progressCallback === 'function') {\n emitter.on(SEND_UPLOAD_PROGRESS_EVENT, function (progress) {\n progressCallback(progress);\n });\n }\n else {\n logger.warn('progressCallback should be a function, not a ' + typeof progressCallback);\n }\n }\n return [4 /*yield*/, uploader.upload()];\n case 3:\n response = _a.sent();\n logger.debug('upload result', response);\n dispatchStorageEvent(track, 'upload', { method: 'put', result: 'success' }, null, \"Upload success for \" + key);\n return [2 /*return*/, {\n key: key,\n }];\n case 4:\n error_4 = _a.sent();\n logger.warn('error uploading', error_4);\n dispatchStorageEvent(track, 'upload', { method: 'put', result: 'failed' }, null, \"Error uploading \" + key);\n throw error_4;\n case 5: return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Remove the object for specified key\n * @param {string} key - key of the object\n * @param {S3ProviderRemoveConfig} [config] - Optional configuration for the underlying S3 command\n * @return {Promise} - Promise resolves upon successful removal of the object\n */\n AWSS3Provider.prototype.remove = function (key, config) {\n return __awaiter(this, void 0, void 0, function () {\n var credentialsOK, opt, bucket, track, prefix, final_key, s3, params, deleteObjectCommand, response, error_5;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this._ensureCredentials()];\n case 1:\n credentialsOK = _a.sent();\n if (!credentialsOK || !this._isWithCredentials(this._config)) {\n throw new Error(StorageErrorStrings.NO_CREDENTIALS);\n }\n opt = Object.assign({}, this._config, config);\n bucket = opt.bucket, track = opt.track;\n prefix = this._prefix(opt);\n final_key = prefix + key;\n s3 = this._createNewS3Client(opt);\n logger.debug('remove ' + key + ' from ' + final_key);\n params = {\n Bucket: bucket,\n Key: final_key,\n };\n deleteObjectCommand = new DeleteObjectCommand(params);\n _a.label = 2;\n case 2:\n _a.trys.push([2, 4, , 5]);\n return [4 /*yield*/, s3.send(deleteObjectCommand)];\n case 3:\n response = _a.sent();\n dispatchStorageEvent(track, 'delete', { method: 'remove', result: 'success' }, null, \"Deleted \" + key + \" successfully\");\n return [2 /*return*/, response];\n case 4:\n error_5 = _a.sent();\n dispatchStorageEvent(track, 'delete', { method: 'remove', result: 'failed' }, null, \"Deletion of \" + key + \" failed with \" + error_5);\n throw error_5;\n case 5: return [2 /*return*/];\n }\n });\n });\n };\n /**\n * List bucket objects relative to the level and prefix specified\n * @param {string} path - the path that contains objects\n * @param {S3ProviderListConfig} [config] - Optional configuration for the underlying S3 command\n * @return {Promise} - Promise resolves to list of keys, eTags, lastModified and file size for\n * all objects in path\n */\n AWSS3Provider.prototype.list = function (path, config) {\n return __awaiter(this, void 0, void 0, function () {\n var credentialsOK, opt, bucket, track, maxKeys, prefix, final_path, s3, params, listObjectsCommand, response, list, error_6;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this._ensureCredentials()];\n case 1:\n credentialsOK = _a.sent();\n if (!credentialsOK || !this._isWithCredentials(this._config)) {\n throw new Error(StorageErrorStrings.NO_CREDENTIALS);\n }\n opt = Object.assign({}, this._config, config);\n bucket = opt.bucket, track = opt.track, maxKeys = opt.maxKeys;\n prefix = this._prefix(opt);\n final_path = prefix + path;\n s3 = this._createNewS3Client(opt);\n logger.debug('list ' + path + ' from ' + final_path);\n params = {\n Bucket: bucket,\n Prefix: final_path,\n MaxKeys: maxKeys,\n };\n listObjectsCommand = new ListObjectsCommand(params);\n _a.label = 2;\n case 2:\n _a.trys.push([2, 4, , 5]);\n return [4 /*yield*/, s3.send(listObjectsCommand)];\n case 3:\n response = _a.sent();\n list = [];\n if (response && response.Contents) {\n list = response.Contents.map(function (item) {\n return {\n key: item.Key.substr(prefix.length),\n eTag: item.ETag,\n lastModified: item.LastModified,\n size: item.Size,\n };\n });\n }\n dispatchStorageEvent(track, 'list', { method: 'list', result: 'success' }, null, list.length + \" items returned from list operation\");\n logger.debug('list', list);\n return [2 /*return*/, list];\n case 4:\n error_6 = _a.sent();\n logger.warn('list error', error_6);\n dispatchStorageEvent(track, 'list', { method: 'list', result: 'failed' }, null, \"Listing items failed: \" + error_6.message);\n throw error_6;\n case 5: return [2 /*return*/];\n }\n });\n });\n };\n AWSS3Provider.prototype._ensureCredentials = function () {\n return __awaiter(this, void 0, void 0, function () {\n var credentials, cred, error_7;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n _a.trys.push([0, 2, , 3]);\n return [4 /*yield*/, Credentials.get()];\n case 1:\n credentials = _a.sent();\n if (!credentials)\n return [2 /*return*/, false];\n cred = Credentials.shear(credentials);\n logger.debug('set credentials for storage', cred);\n this._config.credentials = cred;\n return [2 /*return*/, true];\n case 2:\n error_7 = _a.sent();\n logger.warn('ensure credentials error', error_7);\n return [2 /*return*/, false];\n case 3: return [2 /*return*/];\n }\n });\n });\n };\n AWSS3Provider.prototype._isWithCredentials = function (config) {\n return typeof config === 'object' && config.hasOwnProperty('credentials');\n };\n AWSS3Provider.prototype._prefix = function (config) {\n var credentials = config.credentials, level = config.level;\n var customPrefix = config.customPrefix || {};\n var identityId = config.identityId || credentials.identityId;\n var privatePath = (customPrefix.private !== undefined ? customPrefix.private : 'private/') + identityId + '/';\n var protectedPath = (customPrefix.protected !== undefined ? customPrefix.protected : 'protected/') + identityId + '/';\n var publicPath = customPrefix.public !== undefined ? customPrefix.public : 'public/';\n switch (level) {\n case 'private':\n return privatePath;\n case 'protected':\n return protectedPath;\n default:\n return publicPath;\n }\n };\n /**\n * Creates an S3 client with new V3 aws sdk\n */\n AWSS3Provider.prototype._createNewS3Client = function (config, emitter) {\n var region = config.region, credentials = config.credentials, cancelTokenSource = config.cancelTokenSource, dangerouslyConnectToHttpEndpointForTesting = config.dangerouslyConnectToHttpEndpointForTesting;\n var localTestingConfig = {};\n if (dangerouslyConnectToHttpEndpointForTesting) {\n localTestingConfig = {\n endpoint: localTestingStorageEndpoint,\n tls: false,\n bucketEndpoint: false,\n forcePathStyle: true,\n };\n }\n var s3client = new S3Client(__assign(__assign({ region: region,\n credentials: credentials, customUserAgent: getAmplifyUserAgent() }, localTestingConfig), { requestHandler: new AxiosHttpHandler({}, emitter, cancelTokenSource) }));\n return s3client;\n };\n AWSS3Provider.CATEGORY = 'Storage';\n AWSS3Provider.PROVIDER_NAME = 'AWSS3';\n return AWSS3Provider;\n}());\nexport { AWSS3Provider };\n/**\n * @deprecated use named import\n */\nexport default AWSS3Provider;\n//# sourceMappingURL=AWSS3Provider.js.map","/*\n * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use this file except in compliance with\n * the License. A copy of the License is located at\n *\n * http://aws.amazon.com/apache2.0/\n *\n * or in the \"license\" file accompanying this file. This file is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions\n * and limitations under the License.\n */\nvar __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n};\nimport { ConsoleLogger as Logger, Parser } from '@aws-amplify/core';\nimport { AWSS3Provider } from './providers';\nimport axios from 'axios';\nvar logger = new Logger('StorageClass');\nvar DEFAULT_PROVIDER = 'AWSS3';\n/**\n * Provide storage methods to use AWS S3\n */\nvar Storage = /** @class */ (function () {\n /**\n * Initialize Storage\n * @param {Object} config - Configuration object for storage\n */\n function Storage() {\n this._config = {};\n this._pluggables = [];\n this._cancelTokenSourceMap = new WeakMap();\n logger.debug('Storage Options', this._config);\n this.get = this.get.bind(this);\n this.put = this.put.bind(this);\n this.remove = this.remove.bind(this);\n this.list = this.list.bind(this);\n }\n Storage.prototype.getModuleName = function () {\n return 'Storage';\n };\n /**\n * add plugin into Storage category\n * @param {Object} pluggable - an instance of the plugin\n */\n Storage.prototype.addPluggable = function (pluggable) {\n if (pluggable && pluggable.getCategory() === 'Storage') {\n this._pluggables.push(pluggable);\n var config = {};\n config = pluggable.configure(this._config[pluggable.getProviderName()]);\n return config;\n }\n };\n /**\n * Get the plugin object\n * @param providerName - the name of the plugin\n */\n Storage.prototype.getPluggable = function (providerName) {\n var pluggable = this._pluggables.find(function (pluggable) { return pluggable.getProviderName() === providerName; });\n if (pluggable === undefined) {\n logger.debug('No plugin found with providerName', providerName);\n return null;\n }\n else\n return pluggable;\n };\n /**\n * Remove the plugin object\n * @param providerName - the name of the plugin\n */\n Storage.prototype.removePluggable = function (providerName) {\n this._pluggables = this._pluggables.filter(function (pluggable) { return pluggable.getProviderName() !== providerName; });\n return;\n };\n /**\n * Configure Storage\n * @param {Object} config - Configuration object for storage\n * @return {Object} - Current configuration\n */\n Storage.prototype.configure = function (config) {\n var _this = this;\n logger.debug('configure Storage');\n if (!config)\n return this._config;\n var amplifyConfig = Parser.parseMobilehubConfig(config);\n var storageKeysFromConfig = Object.keys(amplifyConfig.Storage);\n var storageArrayKeys = [\n 'bucket',\n 'region',\n 'level',\n 'track',\n 'customPrefix',\n 'serverSideEncryption',\n 'SSECustomerAlgorithm',\n 'SSECustomerKey',\n 'SSECustomerKeyMD5',\n 'SSEKMSKeyId',\n ];\n var isInStorageArrayKeys = function (k) { return storageArrayKeys.some(function (x) { return x === k; }); };\n var checkConfigKeysFromArray = function (k) { return k.find(function (k) { return isInStorageArrayKeys(k); }); };\n if (storageKeysFromConfig &&\n checkConfigKeysFromArray(storageKeysFromConfig) &&\n !amplifyConfig.Storage[DEFAULT_PROVIDER]) {\n amplifyConfig.Storage[DEFAULT_PROVIDER] = {};\n }\n Object.entries(amplifyConfig.Storage).map(function (_a) {\n var _b = __read(_a, 2), key = _b[0], value = _b[1];\n if (key && isInStorageArrayKeys(key) && value !== undefined) {\n amplifyConfig.Storage[DEFAULT_PROVIDER][key] = value;\n delete amplifyConfig.Storage[key];\n }\n });\n // only update new values for each provider\n Object.keys(amplifyConfig.Storage).forEach(function (providerName) {\n if (typeof amplifyConfig.Storage[providerName] !== 'string') {\n _this._config[providerName] = __assign(__assign({}, _this._config[providerName]), amplifyConfig.Storage[providerName]);\n }\n });\n this._pluggables.forEach(function (pluggable) {\n pluggable.configure(_this._config[pluggable.getProviderName()]);\n });\n if (this._pluggables.length === 0) {\n this.addPluggable(new AWSS3Provider());\n }\n return this._config;\n };\n Storage.prototype.getCancellableTokenSource = function () {\n return axios.CancelToken.source();\n };\n Storage.prototype.updateRequestToBeCancellable = function (request, cancelTokenSource) {\n this._cancelTokenSourceMap.set(request, cancelTokenSource);\n };\n /**\n * Cancels an inflight request\n *\n * @param request - The request to cancel\n * @param [message] - A message to include in the cancelation exception\n */\n Storage.prototype.cancel = function (request, message) {\n var cancelTokenSource = this._cancelTokenSourceMap.get(request);\n if (cancelTokenSource) {\n cancelTokenSource.cancel(message);\n }\n else {\n logger.debug('The request does not map to any cancel token');\n }\n };\n Storage.prototype.copy = function (src, dest, config) {\n var _a;\n var provider = ((_a = config) === null || _a === void 0 ? void 0 : _a.provider) || DEFAULT_PROVIDER;\n var prov = this._pluggables.find(function (pluggable) { return pluggable.getProviderName() === provider; });\n if (prov === undefined) {\n logger.debug('No plugin found with providerName', provider);\n return Promise.reject('No plugin found in Storage for the provider');\n }\n var cancelTokenSource = this.getCancellableTokenSource();\n if (typeof prov.copy !== 'function') {\n return Promise.reject(\".copy is not implemented on provider \" + prov.getProviderName());\n }\n var responsePromise = prov.copy(src, dest, __assign(__assign({}, config), { cancelTokenSource: cancelTokenSource }));\n this.updateRequestToBeCancellable(responsePromise, cancelTokenSource);\n return responsePromise;\n };\n Storage.prototype.get = function (key, config) {\n var _a;\n var provider = ((_a = config) === null || _a === void 0 ? void 0 : _a.provider) || DEFAULT_PROVIDER;\n var prov = this._pluggables.find(function (pluggable) { return pluggable.getProviderName() === provider; });\n if (prov === undefined) {\n logger.debug('No plugin found with providerName', provider);\n return Promise.reject('No plugin found in Storage for the provider');\n }\n var cancelTokenSource = this.getCancellableTokenSource();\n var responsePromise = prov.get(key, __assign(__assign({}, config), { cancelTokenSource: cancelTokenSource }));\n this.updateRequestToBeCancellable(responsePromise, cancelTokenSource);\n return responsePromise;\n };\n Storage.prototype.isCancelError = function (error) {\n return axios.isCancel(error);\n };\n Storage.prototype.put = function (key, object, config) {\n var _a;\n var provider = ((_a = config) === null || _a === void 0 ? void 0 : _a.provider) || DEFAULT_PROVIDER;\n var prov = this._pluggables.find(function (pluggable) { return pluggable.getProviderName() === provider; });\n if (prov === undefined) {\n logger.debug('No plugin found with providerName', provider);\n return Promise.reject('No plugin found in Storage for the provider');\n }\n var cancelTokenSource = this.getCancellableTokenSource();\n var responsePromise = prov.put(key, object, __assign(__assign({}, config), { cancelTokenSource: cancelTokenSource }));\n this.updateRequestToBeCancellable(responsePromise, cancelTokenSource);\n return responsePromise;\n };\n Storage.prototype.remove = function (key, config) {\n var _a;\n var provider = ((_a = config) === null || _a === void 0 ? void 0 : _a.provider) || DEFAULT_PROVIDER;\n var prov = this._pluggables.find(function (pluggable) { return pluggable.getProviderName() === provider; });\n if (prov === undefined) {\n logger.debug('No plugin found with providerName', provider);\n return Promise.reject('No plugin found in Storage for the provider');\n }\n return prov.remove(key, config);\n };\n Storage.prototype.list = function (path, config) {\n var _a;\n var provider = ((_a = config) === null || _a === void 0 ? void 0 : _a.provider) || DEFAULT_PROVIDER;\n var prov = this._pluggables.find(function (pluggable) { return pluggable.getProviderName() === provider; });\n if (prov === undefined) {\n logger.debug('No plugin found with providerName', provider);\n return Promise.reject('No plugin found in Storage for the provider');\n }\n return prov.list(path, config);\n };\n return Storage;\n}());\nexport { Storage };\n/**\n * @deprecated use named import\n */\nexport default Storage;\n//# sourceMappingURL=Storage.js.map","var purple = {\n 50: '#f3e5f5',\n 100: '#e1bee7',\n 200: '#ce93d8',\n 300: '#ba68c8',\n 400: '#ab47bc',\n 500: '#9c27b0',\n 600: '#8e24aa',\n 700: '#7b1fa2',\n 800: '#6a1b9a',\n 900: '#4a148c',\n A100: '#ea80fc',\n A200: '#e040fb',\n A400: '#d500f9',\n A700: '#aa00ff'\n};\nexport default purple;","var deepPurple = {\n 50: '#ede7f6',\n 100: '#d1c4e9',\n 200: '#b39ddb',\n 300: '#9575cd',\n 400: '#7e57c2',\n 500: '#673ab7',\n 600: '#5e35b1',\n 700: '#512da8',\n 800: '#4527a0',\n 900: '#311b92',\n A100: '#b388ff',\n A200: '#7c4dff',\n A400: '#651fff',\n A700: '#6200ea'\n};\nexport default deepPurple;","var lightBlue = {\n 50: '#e1f5fe',\n 100: '#b3e5fc',\n 200: '#81d4fa',\n 300: '#4fc3f7',\n 400: '#29b6f6',\n 500: '#03a9f4',\n 600: '#039be5',\n 700: '#0288d1',\n 800: '#0277bd',\n 900: '#01579b',\n A100: '#80d8ff',\n A200: '#40c4ff',\n A400: '#00b0ff',\n A700: '#0091ea'\n};\nexport default lightBlue;","var cyan = {\n 50: '#e0f7fa',\n 100: '#b2ebf2',\n 200: '#80deea',\n 300: '#4dd0e1',\n 400: '#26c6da',\n 500: '#00bcd4',\n 600: '#00acc1',\n 700: '#0097a7',\n 800: '#00838f',\n 900: '#006064',\n A100: '#84ffff',\n A200: '#18ffff',\n A400: '#00e5ff',\n A700: '#00b8d4'\n};\nexport default cyan;","var teal = {\n 50: '#e0f2f1',\n 100: '#b2dfdb',\n 200: '#80cbc4',\n 300: '#4db6ac',\n 400: '#26a69a',\n 500: '#009688',\n 600: '#00897b',\n 700: '#00796b',\n 800: '#00695c',\n 900: '#004d40',\n A100: '#a7ffeb',\n A200: '#64ffda',\n A400: '#1de9b6',\n A700: '#00bfa5'\n};\nexport default teal;","var lightGreen = {\n 50: '#f1f8e9',\n 100: '#dcedc8',\n 200: '#c5e1a5',\n 300: '#aed581',\n 400: '#9ccc65',\n 500: '#8bc34a',\n 600: '#7cb342',\n 700: '#689f38',\n 800: '#558b2f',\n 900: '#33691e',\n A100: '#ccff90',\n A200: '#b2ff59',\n A400: '#76ff03',\n A700: '#64dd17'\n};\nexport default lightGreen;","var lime = {\n 50: '#f9fbe7',\n 100: '#f0f4c3',\n 200: '#e6ee9c',\n 300: '#dce775',\n 400: '#d4e157',\n 500: '#cddc39',\n 600: '#c0ca33',\n 700: '#afb42b',\n 800: '#9e9d24',\n 900: '#827717',\n A100: '#f4ff81',\n A200: '#eeff41',\n A400: '#c6ff00',\n A700: '#aeea00'\n};\nexport default lime;","var yellow = {\n 50: '#fffde7',\n 100: '#fff9c4',\n 200: '#fff59d',\n 300: '#fff176',\n 400: '#ffee58',\n 500: '#ffeb3b',\n 600: '#fdd835',\n 700: '#fbc02d',\n 800: '#f9a825',\n 900: '#f57f17',\n A100: '#ffff8d',\n A200: '#ffff00',\n A400: '#ffea00',\n A700: '#ffd600'\n};\nexport default yellow;","var amber = {\n 50: '#fff8e1',\n 100: '#ffecb3',\n 200: '#ffe082',\n 300: '#ffd54f',\n 400: '#ffca28',\n 500: '#ffc107',\n 600: '#ffb300',\n 700: '#ffa000',\n 800: '#ff8f00',\n 900: '#ff6f00',\n A100: '#ffe57f',\n A200: '#ffd740',\n A400: '#ffc400',\n A700: '#ffab00'\n};\nexport default amber;","var deepOrange = {\n 50: '#fbe9e7',\n 100: '#ffccbc',\n 200: '#ffab91',\n 300: '#ff8a65',\n 400: '#ff7043',\n 500: '#ff5722',\n 600: '#f4511e',\n 700: '#e64a19',\n 800: '#d84315',\n 900: '#bf360c',\n A100: '#ff9e80',\n A200: '#ff6e40',\n A400: '#ff3d00',\n A700: '#dd2c00'\n};\nexport default deepOrange;","var brown = {\n 50: '#efebe9',\n 100: '#d7ccc8',\n 200: '#bcaaa4',\n 300: '#a1887f',\n 400: '#8d6e63',\n 500: '#795548',\n 600: '#6d4c41',\n 700: '#5d4037',\n 800: '#4e342e',\n 900: '#3e2723',\n A100: '#d7ccc8',\n A200: '#bcaaa4',\n A400: '#8d6e63',\n A700: '#5d4037'\n};\nexport default brown;","var blueGrey = {\n 50: '#eceff1',\n 100: '#cfd8dc',\n 200: '#b0bec5',\n 300: '#90a4ae',\n 400: '#78909c',\n 500: '#607d8b',\n 600: '#546e7a',\n 700: '#455a64',\n 800: '#37474f',\n 900: '#263238',\n A100: '#cfd8dc',\n A200: '#b0bec5',\n A400: '#78909c',\n A700: '#455a64'\n};\nexport default blueGrey;","import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport * as React from 'react';\nimport { isFragment } from 'react-is';\nimport PropTypes from 'prop-types';\nimport clsx from 'clsx';\nimport { HTMLElementType } from '@material-ui/utils';\nimport withStyles from '../styles/withStyles';\nimport Popover from '../Popover';\nimport MenuList from '../MenuList';\nimport * as ReactDOM from 'react-dom';\nimport setRef from '../utils/setRef';\nimport useTheme from '../styles/useTheme';\nimport deprecatedPropType from '../utils/deprecatedPropType';\nvar RTL_ORIGIN = {\n vertical: 'top',\n horizontal: 'right'\n};\nvar LTR_ORIGIN = {\n vertical: 'top',\n horizontal: 'left'\n};\nexport var styles = {\n /* Styles applied to the `Paper` component. */\n paper: {\n // specZ: The maximum height of a simple menu should be one or more rows less than the view\n // height. This ensures a tapable area outside of the simple menu with which to dismiss\n // the menu.\n maxHeight: 'calc(100% - 96px)',\n // Add iOS momentum scrolling.\n WebkitOverflowScrolling: 'touch'\n },\n\n /* Styles applied to the `List` component via `MenuList`. */\n list: {\n // We disable the focus ring for mouse, touch and keyboard users.\n outline: 0\n }\n};\nvar Menu = /*#__PURE__*/React.forwardRef(function Menu(props, ref) {\n var _props$autoFocus = props.autoFocus,\n autoFocus = _props$autoFocus === void 0 ? true : _props$autoFocus,\n children = props.children,\n classes = props.classes,\n _props$disableAutoFoc = props.disableAutoFocusItem,\n disableAutoFocusItem = _props$disableAutoFoc === void 0 ? false : _props$disableAutoFoc,\n _props$MenuListProps = props.MenuListProps,\n MenuListProps = _props$MenuListProps === void 0 ? {} : _props$MenuListProps,\n onClose = props.onClose,\n onEnteringProp = props.onEntering,\n open = props.open,\n _props$PaperProps = props.PaperProps,\n PaperProps = _props$PaperProps === void 0 ? {} : _props$PaperProps,\n PopoverClasses = props.PopoverClasses,\n _props$transitionDura = props.transitionDuration,\n transitionDuration = _props$transitionDura === void 0 ? 'auto' : _props$transitionDura,\n _props$TransitionProp = props.TransitionProps;\n _props$TransitionProp = _props$TransitionProp === void 0 ? {} : _props$TransitionProp;\n\n var onEntering = _props$TransitionProp.onEntering,\n TransitionProps = _objectWithoutProperties(_props$TransitionProp, [\"onEntering\"]),\n _props$variant = props.variant,\n variant = _props$variant === void 0 ? 'selectedMenu' : _props$variant,\n other = _objectWithoutProperties(props, [\"autoFocus\", \"children\", \"classes\", \"disableAutoFocusItem\", \"MenuListProps\", \"onClose\", \"onEntering\", \"open\", \"PaperProps\", \"PopoverClasses\", \"transitionDuration\", \"TransitionProps\", \"variant\"]);\n\n var theme = useTheme();\n var autoFocusItem = autoFocus && !disableAutoFocusItem && open;\n var menuListActionsRef = React.useRef(null);\n var contentAnchorRef = React.useRef(null);\n\n var getContentAnchorEl = function getContentAnchorEl() {\n return contentAnchorRef.current;\n };\n\n var handleEntering = function handleEntering(element, isAppearing) {\n if (menuListActionsRef.current) {\n menuListActionsRef.current.adjustStyleForScrollbar(element, theme);\n }\n\n if (onEnteringProp) {\n onEnteringProp(element, isAppearing);\n }\n\n if (onEntering) {\n onEntering(element, isAppearing);\n }\n };\n\n var handleListKeyDown = function handleListKeyDown(event) {\n if (event.key === 'Tab') {\n event.preventDefault();\n\n if (onClose) {\n onClose(event, 'tabKeyDown');\n }\n }\n };\n /**\r\n * the index of the item should receive focus\r\n * in a `variant=\"selectedMenu\"` it's the first `selected` item\r\n * otherwise it's the very first item.\r\n */\n\n\n var activeItemIndex = -1; // since we inject focus related props into children we have to do a lookahead\n // to check if there is a `selected` item. We're looking for the last `selected`\n // item and use the first valid item as a fallback\n\n React.Children.map(children, function (child, index) {\n if (! /*#__PURE__*/React.isValidElement(child)) {\n return;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (isFragment(child)) {\n console.error([\"Material-UI: The Menu component doesn't accept a Fragment as a child.\", 'Consider providing an array instead.'].join('\\n'));\n }\n }\n\n if (!child.props.disabled) {\n if (variant !== \"menu\" && child.props.selected) {\n activeItemIndex = index;\n } else if (activeItemIndex === -1) {\n activeItemIndex = index;\n }\n }\n });\n var items = React.Children.map(children, function (child, index) {\n if (index === activeItemIndex) {\n return /*#__PURE__*/React.cloneElement(child, {\n ref: function ref(instance) {\n // #StrictMode ready\n contentAnchorRef.current = ReactDOM.findDOMNode(instance);\n setRef(child.ref, instance);\n }\n });\n }\n\n return child;\n });\n return /*#__PURE__*/React.createElement(Popover, _extends({\n getContentAnchorEl: getContentAnchorEl,\n classes: PopoverClasses,\n onClose: onClose,\n TransitionProps: _extends({\n onEntering: handleEntering\n }, TransitionProps),\n anchorOrigin: theme.direction === 'rtl' ? RTL_ORIGIN : LTR_ORIGIN,\n transformOrigin: theme.direction === 'rtl' ? RTL_ORIGIN : LTR_ORIGIN,\n PaperProps: _extends({}, PaperProps, {\n classes: _extends({}, PaperProps.classes, {\n root: classes.paper\n })\n }),\n open: open,\n ref: ref,\n transitionDuration: transitionDuration\n }, other), /*#__PURE__*/React.createElement(MenuList, _extends({\n onKeyDown: handleListKeyDown,\n actions: menuListActionsRef,\n autoFocus: autoFocus && (activeItemIndex === -1 || disableAutoFocusItem),\n autoFocusItem: autoFocusItem,\n variant: variant\n }, MenuListProps, {\n className: clsx(classes.list, MenuListProps.className)\n }), items));\n});\nprocess.env.NODE_ENV !== \"production\" ? Menu.propTypes = {\n // ----------------------------- Warning --------------------------------\n // | These PropTypes are generated from the TypeScript type definitions |\n // | To update them edit the d.ts file and run \"yarn proptypes\" |\n // ----------------------------------------------------------------------\n\n /**\r\n * A HTML element, or a function that returns it.\r\n * It's used to set the position of the menu.\r\n */\n anchorEl: PropTypes\n /* @typescript-to-proptypes-ignore */\n .oneOfType([HTMLElementType, PropTypes.func]),\n\n /**\r\n * If `true` (Default) will focus the `[role=\"menu\"]` if no focusable child is found. Disabled\r\n * children are not focusable. If you set this prop to `false` focus will be placed\r\n * on the parent modal container. This has severe accessibility implications\r\n * and should only be considered if you manage focus otherwise.\r\n */\n autoFocus: PropTypes.bool,\n\n /**\r\n * Menu contents, normally `MenuItem`s.\r\n */\n children: PropTypes.node,\n\n /**\r\n * Override or extend the styles applied to the component.\r\n * See [CSS API](#css) below for more details.\r\n */\n classes: PropTypes.object,\n\n /**\r\n * When opening the menu will not focus the active item but the `[role=\"menu\"]`\r\n * unless `autoFocus` is also set to `false`. Not using the default means not\r\n * following WAI-ARIA authoring practices. Please be considerate about possible\r\n * accessibility implications.\r\n */\n disableAutoFocusItem: PropTypes.bool,\n\n /**\r\n * Props applied to the [`MenuList`](/api/menu-list/) element.\r\n */\n MenuListProps: PropTypes.object,\n\n /**\r\n * Callback fired when the component requests to be closed.\r\n *\r\n * @param {object} event The event source of the callback.\r\n * @param {string} reason Can be: `\"escapeKeyDown\"`, `\"backdropClick\"`, `\"tabKeyDown\"`.\r\n */\n onClose: PropTypes.func,\n\n /**\r\n * Callback fired before the Menu enters.\r\n * @deprecated Use the `TransitionProps` prop instead.\r\n */\n onEnter: deprecatedPropType(PropTypes.func, 'Use the `TransitionProps` prop instead.'),\n\n /**\r\n * Callback fired when the Menu has entered.\r\n * @deprecated Use the `TransitionProps` prop instead.\r\n */\n onEntered: deprecatedPropType(PropTypes.func, 'Use the `TransitionProps` prop instead.'),\n\n /**\r\n * Callback fired when the Menu is entering.\r\n * @deprecated Use the `TransitionProps` prop instead.\r\n */\n onEntering: deprecatedPropType(PropTypes.func, 'Use the `TransitionProps` prop instead.'),\n\n /**\r\n * Callback fired before the Menu exits.\r\n * @deprecated Use the `TransitionProps` prop instead.\r\n */\n onExit: deprecatedPropType(PropTypes.func, 'Use the `TransitionProps` prop instead.'),\n\n /**\r\n * Callback fired when the Menu has exited.\r\n * @deprecated Use the `TransitionProps` prop instead.\r\n */\n onExited: deprecatedPropType(PropTypes.func, 'Use the `TransitionProps` prop instead.'),\n\n /**\r\n * Callback fired when the Menu is exiting.\r\n * @deprecated Use the `TransitionProps` prop instead.\r\n */\n onExiting: deprecatedPropType(PropTypes.func, 'Use the `TransitionProps` prop instead.'),\n\n /**\r\n * If `true`, the menu is visible.\r\n */\n open: PropTypes.bool.isRequired,\n\n /**\r\n * @ignore\r\n */\n PaperProps: PropTypes.object,\n\n /**\r\n * `classes` prop applied to the [`Popover`](/api/popover/) element.\r\n */\n PopoverClasses: PropTypes.object,\n\n /**\r\n * The length of the transition in `ms`, or 'auto'\r\n */\n transitionDuration: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.shape({\n appear: PropTypes.number,\n enter: PropTypes.number,\n exit: PropTypes.number\n })]),\n\n /**\r\n * Props applied to the transition element.\r\n * By default, the element is based on this [`Transition`](http://reactcommunity.org/react-transition-group/transition) component.\r\n */\n TransitionProps: PropTypes.object,\n\n /**\r\n * The variant to use. Use `menu` to prevent selected items from impacting the initial focus\r\n * and the vertical alignment relative to the anchor element.\r\n */\n variant: PropTypes.oneOf(['menu', 'selectedMenu'])\n} : void 0;\nexport default withStyles(styles, {\n name: 'MuiMenu'\n})(Menu);","function _typeof(obj) {\n \"@babel/helpers - typeof\";\n\n if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n module.exports = _typeof = function _typeof(obj) {\n return typeof obj;\n };\n\n module.exports[\"default\"] = module.exports, module.exports.__esModule = true;\n } else {\n module.exports = _typeof = function _typeof(obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n };\n\n module.exports[\"default\"] = module.exports, module.exports.__esModule = true;\n }\n\n return _typeof(obj);\n}\n\nmodule.exports = _typeof;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\nimport NativeSelectInput from './NativeSelectInput';\nimport withStyles from '../styles/withStyles';\nimport formControlState from '../FormControl/formControlState';\nimport useFormControl from '../FormControl/useFormControl';\nimport ArrowDropDownIcon from '../internal/svg-icons/ArrowDropDown';\nimport Input from '../Input';\nexport var styles = function styles(theme) {\n return {\n /* Styles applied to the select component `root` class. */\n root: {},\n\n /* Styles applied to the select component `select` class. */\n select: {\n '-moz-appearance': 'none',\n // Reset\n '-webkit-appearance': 'none',\n // Reset\n // When interacting quickly, the text can end up selected.\n // Native select can't be selected either.\n userSelect: 'none',\n borderRadius: 0,\n // Reset\n minWidth: 16,\n // So it doesn't collapse.\n cursor: 'pointer',\n '&:focus': {\n // Show that it's not an text input\n backgroundColor: theme.palette.type === 'light' ? 'rgba(0, 0, 0, 0.05)' : 'rgba(255, 255, 255, 0.05)',\n borderRadius: 0 // Reset Chrome style\n\n },\n // Remove IE 11 arrow\n '&::-ms-expand': {\n display: 'none'\n },\n '&$disabled': {\n cursor: 'default'\n },\n '&[multiple]': {\n height: 'auto'\n },\n '&:not([multiple]) option, &:not([multiple]) optgroup': {\n backgroundColor: theme.palette.background.paper\n },\n '&&': {\n paddingRight: 24\n }\n },\n\n /* Styles applied to the select component if `variant=\"filled\"`. */\n filled: {\n '&&': {\n paddingRight: 32\n }\n },\n\n /* Styles applied to the select component if `variant=\"outlined\"`. */\n outlined: {\n borderRadius: theme.shape.borderRadius,\n '&&': {\n paddingRight: 32\n }\n },\n\n /* Styles applied to the select component `selectMenu` class. */\n selectMenu: {\n height: 'auto',\n // Resets for multpile select with chips\n minHeight: '1.1876em',\n // Required for select\\text-field height consistency\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n overflow: 'hidden'\n },\n\n /* Pseudo-class applied to the select component `disabled` class. */\n disabled: {},\n\n /* Styles applied to the icon component. */\n icon: {\n // We use a position absolute over a flexbox in order to forward the pointer events\n // to the input and to support wrapping tags..\n position: 'absolute',\n right: 0,\n top: 'calc(50% - 12px)',\n // Center vertically\n pointerEvents: 'none',\n // Don't block pointer events on the select under the icon.\n color: theme.palette.action.active,\n '&$disabled': {\n color: theme.palette.action.disabled\n }\n },\n\n /* Styles applied to the icon component if the popup is open. */\n iconOpen: {\n transform: 'rotate(180deg)'\n },\n\n /* Styles applied to the icon component if `variant=\"filled\"`. */\n iconFilled: {\n right: 7\n },\n\n /* Styles applied to the icon component if `variant=\"outlined\"`. */\n iconOutlined: {\n right: 7\n },\n\n /* Styles applied to the underlying native input component. */\n nativeInput: {\n bottom: 0,\n left: 0,\n position: 'absolute',\n opacity: 0,\n pointerEvents: 'none',\n width: '100%'\n }\n };\n};\nvar defaultInput = /*#__PURE__*/React.createElement(Input, null);\n/**\r\n * An alternative to `` with a much smaller bundle size footprint.\r\n */\n\nvar NativeSelect = /*#__PURE__*/React.forwardRef(function NativeSelect(props, ref) {\n var children = props.children,\n classes = props.classes,\n _props$IconComponent = props.IconComponent,\n IconComponent = _props$IconComponent === void 0 ? ArrowDropDownIcon : _props$IconComponent,\n _props$input = props.input,\n input = _props$input === void 0 ? defaultInput : _props$input,\n inputProps = props.inputProps,\n variant = props.variant,\n other = _objectWithoutProperties(props, [\"children\", \"classes\", \"IconComponent\", \"input\", \"inputProps\", \"variant\"]);\n\n var muiFormControl = useFormControl();\n var fcs = formControlState({\n props: props,\n muiFormControl: muiFormControl,\n states: ['variant']\n });\n return /*#__PURE__*/React.cloneElement(input, _extends({\n // Most of the logic is implemented in `NativeSelectInput`.\n // The `Select` component is a simple API wrapper to expose something better to play with.\n inputComponent: NativeSelectInput,\n inputProps: _extends({\n children: children,\n classes: classes,\n IconComponent: IconComponent,\n variant: fcs.variant,\n type: undefined\n }, inputProps, input ? input.props.inputProps : {}),\n ref: ref\n }, other));\n});\nprocess.env.NODE_ENV !== \"production\" ? NativeSelect.propTypes = {\n // ----------------------------- Warning --------------------------------\n // | These PropTypes are generated from the TypeScript type definitions |\n // | To update them edit the d.ts file and run \"yarn proptypes\" |\n // ----------------------------------------------------------------------\n\n /**\r\n * The option elements to populate the select with.\r\n * Can be some `