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 ShareSASPermissions_exports = {};
__export(ShareSASPermissions_exports, {
  ShareSASPermissions: () => ShareSASPermissions
});
module.exports = __toCommonJS(ShareSASPermissions_exports);
class ShareSASPermissions {
  /**
   * Creates an {@link ShareSASPermissions} 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 shareSASPermissions = new ShareSASPermissions();
    for (const char of permissions) {
      switch (char) {
        case "r":
          shareSASPermissions.read = true;
          break;
        case "c":
          shareSASPermissions.create = true;
          break;
        case "w":
          shareSASPermissions.write = true;
          break;
        case "d":
          shareSASPermissions.delete = true;
          break;
        case "l":
          shareSASPermissions.list = true;
          break;
        default:
          throw new RangeError(`Invalid permission ${char}`);
      }
    }
    return shareSASPermissions;
  }
  /**
   * Specifies Read access granted.
   */
  read = false;
  /**
   * Specifies Create access granted.
   */
  create = false;
  /**
   * Specifies Write access granted.
   */
  write = false;
  /**
   * Specifies Delete access granted.
   */
  delete = false;
  /**
   * Specifies List access granted.
   */
  list = 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.create) {
      permissions.push("c");
    }
    if (this.write) {
      permissions.push("w");
    }
    if (this.delete) {
      permissions.push("d");
    }
    if (this.list) {
      permissions.push("l");
    }
    return permissions.join("");
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  ShareSASPermissions
});
//# sourceMappingURL=ShareSASPermissions.js.map
