export default function EmbeddedDeltaMixin(e){return class extends e{async _preUpdate(e,t,s){if(!1===await super._preUpdate(e,t,s))return!1;const i=this.parent.getEmbeddedCollection(this.parentCollection);i.manages(this.id)||(i.set(this.id,this),t._wasAdopted=!0)}batchWrite(e,{restoreDelta:t=!1,...s}={}){const i=this.parent.getEmbeddedCollection(this.parentCollection);t&&!i.manages(this.id)?super.batchDelete(e):super.batchWrite(e,s)}batchDelete(e,{restoreDelta:t=!1}={}){const s=this.parent.getEmbeddedCollection(this.parentCollection);if(!t&&s.isTombstone(this.id)){const t=new foundry.data.TombstoneData({_id:this.id}),{dbKey:s,sublevelName:i}=this;this.constructor.batchWrite(t.toObject(),e,{dbKey:s,sublevelName:i})}else super.batchDelete(e)}}}