${game.i18n.localize("DD.ClearAllDialogContent")}
`,yes:()=>this.dungeon?.deleteAll()})}async generate(e){this.dungeon?await this.dungeon.deleteAll():await this.createNewDungeon(),await(async(e,t={})=>{try{switch(t.algorithm){case"2d-dungeon":await Xn(e,t);break;case"rot-js-cellular":await Kn(e,t);break;case"dungeoneer":await jn(e,t)}}catch(e){console.error(e),ui.notifications.error("Error generating dungeon... please try again.")}})(this.dungeon,e)}async loadDungeon(){const{journalEntry:t,note:n}=await function(){for(const t of canvas.scene.notes){const n=game.journal.get(t.entryId);if(n&&n.getFlag(e,"dungeonVersion"))return{journalEntry:n,note:t}}return{journalEntry:null,note:null}}();t?(this.dungeon=new Qe(t,n),await this.dungeon.loadFromJournalEntry(),this.addChildAt(this.dungeon,0)):this.dungeon=null}async createNewDungeon(){await $n(),await this.loadDungeon()}_onClickLeft(e){const{preview:t,drawingsState:n,destination:i}=e.interactionData;if(n>=1&&t.isPolygon)return t._addPoint(i,{snap:!e.shiftKey,round:!0}),t._chain=!0,t.refresh();super._onClickLeft(e)}_onClickLeft2(e){const{drawingsState:t,preview:n}=e.interactionData;t>=1&&n.isPolygon?e.interactionData.drawingsState=2:super._onClickLeft2(e)}async _onDragLeftStart(e){await super._onDragLeftStart(e);const t=e.interactionData,n=getDocumentClass("Drawing");let i;try{i=new n(this._getNewDrawingData(t.origin),{parent:canvas.scene})}catch(e){throw e instanceof foundry.data.validation.DataModelValidationError&&ui.notifications.error("DRAWING.JointValidationErrorUI",{localize:!0}),e}const r=new this.constructor.placeableClass(i);t.preview=this.preview.addChild(r),t.drawingsState=1,r.draw()}_onDragLeftMove(e){const{preview:t,drawingsState:n}=e.interactionData;if(t&&!t._destroyed&&(null===t.parent&&this.preview.addChild(t),n>=1)){Qn()?function(e,t){const{destination:n}=t.interactionData,i=n,r=Date.now()-e._drawTime