class ImportExportModal implements Modal {
  self(): HTMLElement | null { 
    return document.getElementById("import-export-container");
  }
  
  visible(): boolean {
    return this.self()?.style.display != "none";
  }
  
  setVisible(v: boolean): void {
    const modal = this.self();
    if (modal) {
      modal.style.display = v ? "block" : "none";
    }
  }
  
  setTitle(title: string): void {
    const modalH2 = document.getElementById("import-export-title");
    if (modalH2) {
      modalH2.innerHTML = title;
    }
  }
  
  setTextArea(text: string, readonly: boolean): void {
    const textarea = document.getElementById("import-export-textarea") as HTMLTextAreaElement;
    if (textarea) {
      textarea.value = text;
      textarea.readOnly = readonly;
    }
  }
  
  setErrMsg(text: string, visible: boolean): void {
    const errMsg = document.getElementById("import-export-error");
    if (errMsg) {
      errMsg.innerHTML = text;
      errMsg.style.display = visible ? "unset" : "none";
    }
  }
  
  copyTextArea(): void {
    const textarea = document.getElementById("import-export-textarea") as HTMLTextAreaElement;
    if (textarea) {
      textarea.select();
      textarea.setSelectionRange(0, 9999999);
      navigator.clipboard.writeText(textarea.value);
    }
  }
  
  getText(): string {
    const textarea = document.getElementById("import-export-textarea") as HTMLTextAreaElement;
    if (textarea) {
      return textarea.value;
    }
    return "";
  }
  
  okBtn(): HTMLElement | null {
    return document.getElementById("import-export-ok-btn");
  }
  
  cancelBtn(): HTMLElement | null {
    return document.getElementById("import-export-cancel-btn");
  }
}