var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var ContainerSASPermissions_exports = {};
__export(ContainerSASPermissions_exports, {
  ContainerSASPermissions: () => ContainerSASPermissions
});
module.exports = __toCommonJS(ContainerSASPermissions_exports);
class ContainerSASPermissions {
  /**
   * Creates an {@link ContainerSASPermissions} from the specified permissions string. This method will throw an
   * Error if it encounters a character that does not correspond to a valid permission.
   *
   * @param permissions -
   */
  static parse(permissions) {
    const containerSASPermissions = new ContainerSASPermissions();
    for (const char of permissions) {
      switch (char) {
        case "r":
          containerSASPermissions.read = true;
          break;
        case "a":
          containerSASPermissions.add = true;
          break;
        case "c":
          containerSASPermissions.create = true;
          break;
        case "w":
          containerSASPermissions.write = true;
          break;
        case "d":
          containerSASPermissions.delete = true;
          break;
        case "l":
          containerSASPermissions.list = true;
          break;
        case "t":
          containerSASPermissions.tag = true;
          break;
        case "x":
          containerSASPermissions.deleteVersion = true;
          break;
        case "m":
          containerSASPermissions.move = true;
          break;
        case "e":
          containerSASPermissions.execute = true;
          break;
        case "i":
          containerSASPermissions.setImmutabilityPolicy = true;
          break;
        case "y":
          containerSASPermissions.permanentDelete = true;
          break;
        case "f":
          containerSASPermissions.filterByTags = true;
          break;
        default:
          throw new RangeError(`Invalid permission ${char}`);
      }
    }
    return containerSASPermissions;
  }
  /**
   * Creates a {@link ContainerSASPermissions} from a raw object which contains same keys as it
   * and boolean values for them.
   *
   * @param permissionLike -
   */
  static from(permissionLike) {
    const containerSASPermissions = new ContainerSASPermissions();
    if (permissionLike.read) {
      containerSASPermissions.read = true;
    }
    if (permissionLike.add) {
      containerSASPermissions.add = true;
    }
    if (permissionLike.create) {
      containerSASPermissions.create = true;
    }
    if (permissionLike.write) {
      containerSASPermissions.write = true;
    }
    if (permissionLike.delete) {
      containerSASPermissions.delete = true;
    }
    if (permissionLike.list) {
      containerSASPermissions.list = true;
    }
    if (permissionLike.deleteVersion) {
      containerSASPermissions.deleteVersion = true;
    }
    if (permissionLike.tag) {
      containerSASPermissions.tag = true;
    }
    if (permissionLike.move) {
      containerSASPermissions.move = true;
    }
    if (permissionLike.execute) {
      containerSASPermissions.execute = true;
    }
    if (permissionLike.setImmutabilityPolicy) {
      containerSASPermissions.setImmutabilityPolicy = true;
    }
    if (permissionLike.permanentDelete) {
      containerSASPermissions.permanentDelete = true;
    }
    if (permissionLike.filterByTags) {
      containerSASPermissions.filterByTags = true;
    }
    return containerSASPermissions;
  }
  /**
   * Specifies Read access granted.
   */
  read = false;
  /**
   * Specifies Add access granted.
   */
  add = false;
  /**
   * Specifies Create access granted.
   */
  create = false;
  /**
   * Specifies Write access granted.
   */
  write = false;
  /**
   * Specifies Delete access granted.
   */
  delete = false;
  /**
   * Specifies Delete version access granted.
   */
  deleteVersion = false;
  /**
   * Specifies List access granted.
   */
  list = false;
  /**
   * Specfies Tag access granted.
   */
  tag = false;
  /**
   * Specifies Move access granted.
   */
  move = false;
  /**
   * Specifies Execute access granted.
   */
  execute = false;
  /**
   * Specifies SetImmutabilityPolicy access granted.
   */
  setImmutabilityPolicy = false;
  /**
   * Specifies that Permanent Delete is permitted.
   */
  permanentDelete = false;
  /**
   * Specifies that Filter Blobs by Tags is permitted.
   */
  filterByTags = false;
  /**
   * Converts the given permissions to a string. Using this method will guarantee the permissions are in an
   * order accepted by the service.
   *
   * The order of the characters should be as specified here to ensure correctness.
   * @see https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas
   *
   */
  toString() {
    const permissions = [];
    if (this.read) {
      permissions.push("r");
    }
    if (this.add) {
      permissions.push("a");
    }
    if (this.create) {
      permissions.push("c");
    }
    if (this.write) {
      permissions.push("w");
    }
    if (this.delete) {
      permissions.push("d");
    }
    if (this.deleteVersion) {
      permissions.push("x");
    }
    if (this.list) {
      permissions.push("l");
    }
    if (this.tag) {
      permissions.push("t");
    }
    if (this.move) {
      permissions.push("m");
    }
    if (this.execute) {
      permissions.push("e");
    }
    if (this.setImmutabilityPolicy) {
      permissions.push("i");
    }
    if (this.permanentDelete) {
      permissions.push("y");
    }
    if (this.filterByTags) {
      permissions.push("f");
    }
    return permissions.join("");
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  ContainerSASPermissions
});
//# sourceMappingURL=ContainerSASPermissions.js.map
