import BaseTile from"../../../common/documents/tile.mjs";import ServerDocumentMixin from"../backend/server-document.mjs";import{getProperty,isPlainObject,setProperty}from"../../../common/utils/helpers.mjs";export default class Tile extends(ServerDocumentMixin(BaseTile)){static _migrationRegistry=[...super._migrationRegistry,{fn:migrateTextureData,version:12},{fn:migrateRoofOcclusion,version:12},{fn:migrateZToSort,version:12},{fn:migrateRoof,version:12},{fn:migratePosition,version:"14.349"},{fn:migrateOcclusionMode,version:"14.355"}]}function migrateTextureData(e){const t=Tile._addDataFieldMigration(e,"img","texture.src"),o=Tile._addDataFieldMigration(e,"tint","texture.tint");let i=!1;"width"in e&&e.width<0&&(e.width=Math.abs(e.width),setProperty(e,"texture.scaleX",-1),i=!0);let r=!1;return"height"in e&&e.height<0&&(e.height=Math.abs(e.height),setProperty(e,"texture.scaleY",-1),r=!0),t||o||i||r}function migrateRoofOcclusion(e){return!!isPlainObject(e.occlusion)&&(2===Number(e.occlusion.mode)&&(e.occlusion.mode=1,e.roof=!0,!0))}function migrateZToSort(e){return Tile._addDataFieldMigration(e,"z","sort")}function migrateRoof(e){if(!("roof"in e))return!1;const t=!!e.roof;return setProperty(e,"restrictions.light",t),setProperty(e,"restrictions.weather",t),delete e.roof,!0}function migratePosition(e){return isPlainObject(e.texture)||(e.texture={}),e.texture.anchorX??=.5,e.texture.anchorY??=.5,0===e.rotation?(e.texture.anchorX-=.5,e.texture.anchorY-=.5):(e.x=Math.round((e.x??0)+e.width/2),e.y=Math.round((e.y??0)+e.height/2)),!0}function migrateOcclusionMode(e){return!!isPlainObject(e.occlusion)&&(e.occlusion.mode>0?e.occlusion.modes=[1<<e.occlusion.mode-1]:e.occlusion.modes=[],delete e.occlusion.mode,!0)}