import BaseChatMessage from"../../../common/documents/chat-message.mjs";import ServerDocumentMixin from"../backend/server-document.mjs";export default class ChatMessage extends(ServerDocumentMixin(BaseChatMessage)){static _migrationRegistry=[...super._migrationRegistry,{fn:migrateRolls,version:12},{fn:migrateUserToAuthor,version:12},{fn:migrateTypeToStyle,version:12}];async _preCreate(e,t,r){if(!1===await super._preCreate(e,t,r))return!1;null===this.timestamp&&this.updateSource({timestamp:t.modifiedTime})}}function migrateRolls(e){return"roll"in e&&("rolls"in e||(e.rolls=[e.roll]),delete e.roll,!0)}function migrateUserToAuthor(e){return ChatMessage._addDataFieldMigration(e,"user","author")}function migrateTypeToStyle(e){return"number"==typeof e.type&&!("style"in e)&&(e.style=Object.values(CONST.CHAT_MESSAGE_STYLES).includes(e.type)?e.type:0,e.type=CONST.BASE_DOCUMENT_TYPE,!0)}