var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
  return value;
};

// src/server.ts
var Server = class {
  constructor(party) {
    this.party = party;
    __publicField(this, "lastMessage", null);
    party.storage.get("head").then((head) => {
      if (head) {
        this.lastMessage = head;
      }
    });
  }
  onConnect(conn) {
    if (this.lastMessage) {
      conn.send(this.lastMessage);
    }
  }
  onMessage(message, sender) {
    this.lastMessage = message;
    this.party.broadcast(message, [sender.id]);
    this.party.storage.put("head", message);
  }
};
export {
  Server as default
};
//# sourceMappingURL=server.esm.js.map
