var __classPrivateFieldSet = this && this.__classPrivateFieldSet || function (receiver, state, value, kind, f) {
  if (kind === "m") throw new TypeError("Private method is not writable");
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
  return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
};

var __classPrivateFieldGet = this && this.__classPrivateFieldGet || function (receiver, state, kind, f) {
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};

var _args, _keys; // ets_tracing: off


import * as St from "../Structural";
export const CaseBrand = /*#__PURE__*/Symbol();
export function hasCaseBrand(self) {
  return typeof self === "object" && self != null && CaseBrand in self;
}
const h0 = /*#__PURE__*/St.hashString("@effect-ts/system/Case"); // @ts-expect-error

export const Case = class {
  constructor(args) {
    _args.set(this, void 0);

    _keys.set(this, void 0);

    __classPrivateFieldSet(this, _args, args, "f");

    if (typeof args === "object" && args != null) {
      const keys = Object.keys(args);

      for (let i = 0; i < keys.length; i++) {
        this[keys[i]] = args[keys[i]];
      }
    }

    __classPrivateFieldSet(this, _keys, Object.keys(this).sort(), "f");
  }

  copy(args) {
    // @ts-expect-error
    return new this.constructor({ ...__classPrivateFieldGet(this, _args, "f"),
      ...args
    });
  }

  get [(_args = new WeakMap(), _keys = new WeakMap(), CaseBrand)]() {
    return __classPrivateFieldGet(this, _keys, "f");
  }

  get [St.hashSym]() {
    let h = h0;

    for (const k of __classPrivateFieldGet(this, _keys, "f")) {
      h = St.combineHash(h, St.hash(this[k]));
    }

    return h;
  }

  [St.equalsSym](that) {
    if (this === that) {
      return true;
    }

    if (that instanceof this.constructor) {
      const kthat = that[CaseBrand];
      const len = kthat.length;

      if (len !== __classPrivateFieldGet(this, _keys, "f").length) {
        return false;
      }

      let eq = true;
      let i = 0;

      while (eq && i < len) {
        eq = __classPrivateFieldGet(this, _keys, "f")[i] === kthat[i] && St.equals(this[__classPrivateFieldGet(this, _keys, "f")[i]], that[kthat[i]]);
        i++;
      }

      return eq;
    }

    return false;
  }

};
export function Tagged(tag, key) {
  var _a;

  if (key) {
    class X extends Case {
      constructor() {
        super(...arguments); // @ts-expect-error

        this[_a] = tag;
      }

    }

    _a = key; // @ts-expect-error

    return X;
  }

  class X extends Case {
    constructor() {
      super(...arguments);
      this._tag = tag;
    }

  } // @ts-expect-error


  return X;
}
//# sourceMappingURL=index.js.map