'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var bite_formatBite = require('../../bite/format-bite.js');
var thirdParty_cosNodejsSdkV5 = require('../../third-party/cos-nodejs-sdk-v5.js');

/**
 * 获取腾讯云 COS SDK 实例
 * 创建并返回一个配置好的 COS 客户端实例
 * @param secretId - 腾讯云 SecretId
 * @param secretKey - 腾讯云 SecretKey
 * @returns COS SDK 实例
 * @example
 * ```ts
 * const cos = getCOSInstance('your-secret-id', 'your-secret-key');
 * // 使用 cos 实例进行文件操作
 * ```
 */
function getCOSInstance(secretId, secretKey) {
  var COS = thirdParty_cosNodejsSdkV5.getCosNodejsSdkV5();
  var cos = new COS({
    SecretId: secretId,
    SecretKey: secretKey
  });
  return cos;
}
/**
 * COS 文件上传进度回调函数
 * 显示上传进度、速度、已上传大小和总大小
 * @param info - 上传进度信息
 * @param info.percent - 上传进度百分比（0-1）
 * @param info.speed - 上传速度（字节/秒）
 * @param info.total - 文件总大小（字节）
 * @param info.loaded - 已上传大小（字节）
 * @example
 * ```ts
 * onUploadCOSProgress({
 *   percent: 0.5,
 *   speed: 1024000,
 *   total: 10240000,
 *   loaded: 5120000
 * });
 * // 输出: 总共：9.77 MB，已上传：4.88 MB，进度：50%，速度：1000.00 KB/s
 * ```
 */
function onUploadCOSProgress(info) {
  var percent = parseInt("".concat(info.percent * 10000), 10) / 100;
  var speed = bite_formatBite.formatBite(info.speed || 0);
  var total = bite_formatBite.formatBite(info.total || 0);
  var loaded = bite_formatBite.formatBite(info.loaded || 0);
  console.log("[uploadCOSFile] \u603B\u5171\uFF1A".concat(total, "\uFF0C\u5DF2\u4E0A\u4F20\uFF1A").concat(loaded, "\uFF0C\u8FDB\u5EA6\uFF1A").concat(percent, "%\uFF0C\u901F\u5EA6\uFF1A").concat(speed, "/s;"));
}

exports.getCOSInstance = getCOSInstance;
exports.onUploadCOSProgress = onUploadCOSProgress;
