import BaseJournalEntry from"../../../common/documents/journal-entry.mjs";import ServerDocumentMixin from"../backend/server-document.mjs";import*as CONST from"../../../common/constants.mjs";export default class JournalEntry extends(ServerDocumentMixin(BaseJournalEntry)){static _migrationRegistry=[...super._migrationRegistry,{fn:migrateJournalEntryPages,version:12}];static socketListeners(e){e.on("showEntry",this.#e.bind(e)),e.on("shareImage",this.#t.bind(e))}static#e(e,{force:t=!1,users:n=[]},r){if(n.length)for(const r of n){const n=game.users.find((e=>e.id===r));n&&n.sockets.forEach((n=>n.emit("showEntry",e,t)))}else this.broadcast.emit("showEntry",e,t);r(!0)}static#t({users:e,...t}={}){if(e?.length)for(const n of e){const e=game.users.find((e=>e.id===n));e&&e.sockets.forEach((e=>e.emit("shareImage",t)))}else this.broadcast.emit("shareImage",t)}}function migrateJournalEntryPages(e){if(!("img"in e)&&!("content"in e))return!1;if(Array.isArray(e.pages)&&e.pages.length>0)return delete e.img,delete e.content,!0;e.pages=[];const t=e.img&&e.content;return e.img&&e.pages.push({name:`${t?"Figure: ":""}${e.name}`,type:"image",src:e.img,title:{show:!1}}),e.content&&e.pages.push({name:e.name,type:"text",title:{show:!1},text:{format:CONST.JOURNAL_ENTRY_PAGE_FORMATS.HTML,content:e.content}}),delete e.img,delete e.content,!0}