declare module "@univerjs/core/facade" {
  import type { IFUniverSheetsThreadCommentMixin, ISheetsThreadCommentEventParamConfig } from "@univerjs/sheets-thread-comment/facade";

  interface IFSheetsThreadCommentEventNameMixin {
      /**
       * Event fired after comment added
       * @see {@link ISheetCommentAddEventParams}
       * @example
       * ```ts
       * const disposable = univerAPI.addEvent(univerAPI.Event.CommentAdded, (params) => {
       *   const { comment, workbook, worksheet, row, col } = params;
       *   console.log(params);
       * });
       *
       * // Remove the event listener, use `disposable.dispose()`
       * ```
       */
      readonly CommentAdded: 'CommentAdded';
      /**
       * Event fired before comment added
       * @see {@link IBeforeSheetCommentAddEventParams}
       * @example
       * ```ts
       * const disposable = univerAPI.addEvent(univerAPI.Event.BeforeCommentAdd, (params) => {
       *   const { comment, workbook, worksheet, row, col } = params;
       *   console.log(params);
       *
       *   // Cancel the comment add operation
       *   params.cancel = true;
       * });
       *
       * // Remove the event listener, use `disposable.dispose()`
       * ```
       */
      readonly BeforeCommentAdd: 'BeforeCommentAdd';
      /**
       * Event fired after comment updated
       * @see {@link ISheetCommentUpdateEventParams}
       * @example
       * ```ts
       * const disposable = univerAPI.addEvent(univerAPI.Event.CommentUpdated, (params) => {
       *   const { comment, workbook, worksheet, row, col } = params;
       *   console.log(params);
       * });
       *
       * // Remove the event listener, use `disposable.dispose()`
       * ```
       */
      readonly CommentUpdated: 'CommentUpdated';
      /**
       * Event fired before comment update
       * @see {@link IBeforeSheetCommentUpdateEventParams}
       * @example
       * ```ts
       * const disposable = univerAPI.addEvent(univerAPI.Event.BeforeCommentUpdate, (params) => {
       *   const { comment, workbook, worksheet, row, col, newContent } = params;
       *   console.log(params);
       *
       *   // Cancel the comment update operation
       *   params.cancel = true;
       * });
       *
       * // Remove the event listener, use `disposable.dispose()`
       * ```
       */
      readonly BeforeCommentUpdate: 'BeforeCommentUpdate';
      /**
       * Event fired after comment deleted
       * @see {@link ISheetCommentDeleteEventParams}
       * @example
       * ```ts
       * const disposable = univerAPI.addEvent(univerAPI.Event.CommentDeleted, (params) => {
       *   const { commentId, workbook, worksheet } = params;
       *   console.log(params);
       * });
       *
       * // Remove the event listener, use `disposable.dispose()`
       * ```
       */
      readonly CommentDeleted: 'CommentDeleted';
      /**
       * Event fired before comment delete
       * @see {@link IBeforeSheetCommentDeleteEventParams}
       * @example
       * ```ts
       * const disposable = univerAPI.addEvent(univerAPI.Event.BeforeCommentDelete, (params) => {
       *   const { comment, workbook, worksheet, row, col } = params;
       *   console.log(params);
       *
       *   // Cancel the comment delete operation
       *   params.cancel = true;
       * });
       *
       * // Remove the event listener, use `disposable.dispose()`
       * ```
       */
      readonly BeforeCommentDelete: 'BeforeCommentDelete';
      /**
       * Event fired after comment resolve
       * @see {@link ISheetCommentResolveEventParams}
       * @example
       * ```ts
       * const disposable = univerAPI.addEvent(univerAPI.Event.CommentResolved, (params) => {
       *   const { comment, row, col, resolved, workbook, worksheet } = params;
       *   console.log(params);
       * });
       *
       * // Remove the event listener, use `disposable.dispose()`
       * ```
       */
      readonly CommentResolved: 'CommentResolved';
      /**
       * Event fired before comment resolve
       * @see {@link ISheetCommentResolveEventParams}
       * @example
       * ```ts
       * const disposable = univerAPI.addEvent(univerAPI.Event.BeforeCommentResolve, (params) => {
       *   const { comment, row, col, resolved, workbook, worksheet } = params;
       *   console.log(params);
       *
       *   // Cancel the comment resolve operation
       *   params.cancel = true;
       * });
       *
       * // Remove the event listener, use `disposable.dispose()`
       * ```
       */
      readonly BeforeCommentResolve: 'BeforeCommentResolve';
  }
}

declare module "@univerjs/sheets-thread-comment/facade" {
  import type { IDocumentBody, Nullable, RichTextValue } from "@univerjs/core";

  import type { IEventBase } from "@univerjs/core/facade";

  import type { FRange, FWorkbook, FWorksheet } from "@univerjs/sheets/facade";

  import type { IAddCommentCommandParams, IBaseComment, IThreadComment } from "@univerjs/thread-comment";

  // @ts-ignore: optional external type dependency may be absent in generated workspaces.
  import type { IDisposable } from "@univerjs/core";

  class FSheetsThreadCommentEventNameMixin {
      get CommentAdded(): 'CommentAdded';
      get BeforeCommentAdd(): 'BeforeCommentAdd';
      get CommentUpdated(): 'CommentUpdated';
      get BeforeCommentUpdate(): 'BeforeCommentUpdate';
      get CommentDeleted(): 'CommentDeleted';
      get BeforeCommentDelete(): 'BeforeCommentDelete';
      get CommentResolved(): 'CommentResolved';
      get BeforeCommentResolve(): 'BeforeCommentResolve';
  }

  /**
   * Event interface triggered after a comment is added to a sheet
   * @interface ISheetCommentAddEventParams
   * @augments {IEventBase}
   */
  interface ISheetCommentAddEventParams extends IEventBase {
      /** The workbook instance */
      workbook: FWorkbook;
      /** The worksheet where the comment is added */
      worksheet: FWorksheet;
      /** Row index of the comment */
      row: number;
      /** Column index of the comment */
      col: number;
      /** The added comment object */
      comment: FThreadComment;
  }

  /**
   * Event interface triggered before a comment is added to a sheet
   * @interface IBeforeSheetCommentAddEventParams
   * @augments {IEventBase}
   */
  interface IBeforeSheetCommentAddEventParams extends IEventBase {
      /** The workbook instance */
      workbook: FWorkbook;
      /** The worksheet where the comment will be added */
      worksheet: FWorksheet;
      /** Row index for the new comment */
      row: number;
      /** Column index for the new comment */
      col: number;
      /** The comment item to be added */
      comment: FTheadCommentItem;
  }

  /**
   * Event interface triggered after a comment is updated in a sheet
   * @interface ISheetCommentUpdateEventParams
   * @augments {IEventBase}
   */
  interface ISheetCommentUpdateEventParams extends IEventBase {
      /** The workbook instance */
      workbook: FWorkbook;
      /** The worksheet containing the updated comment */
      worksheet: FWorksheet;
      /** Row index of the comment */
      row: number;
      /** Column index of the comment */
      col: number;
      /** The updated comment object */
      comment: FThreadComment;
  }

  /**
   * Event interface triggered before a comment is updated in a sheet
   * @interface IBeforeSheetCommentUpdateEventParams
   * @augments {IEventBase}
   */
  interface IBeforeSheetCommentUpdateEventParams extends IEventBase {
      /** The workbook instance */
      workbook: FWorkbook;
      /** The worksheet containing the comment */
      worksheet: FWorksheet;
      /** Row index of the comment */
      row: number;
      /** Column index of the comment */
      col: number;
      /** The current comment object */
      comment: FThreadComment;
      /** The new content to replace the existing comment */
      newContent: RichTextValue;
  }

  /**
   * Event interface triggered before a comment is deleted from a sheet
   * @interface IBeforeSheetCommentDeleteEventParams
   * @augments {IEventBase}
   */
  interface IBeforeSheetCommentDeleteEventParams extends IEventBase {
      /** The workbook instance */
      workbook: FWorkbook;
      /** The worksheet containing the comment */
      worksheet: FWorksheet;
      /** Row index of the comment */
      row: number;
      /** Column index of the comment */
      col: number;
      /** The comment to be deleted */
      comment: FThreadComment;
  }

  /**
   * Event interface triggered after a comment is deleted from a sheet
   * @interface ISheetCommentDeleteEventParams
   * @augments {IEventBase}
   */
  interface ISheetCommentDeleteEventParams extends IEventBase {
      /** The workbook instance */
      workbook: FWorkbook;
      /** The worksheet that contained the comment */
      worksheet: FWorksheet;
      /** The ID of the deleted comment */
      commentId: string;
  }

  /**
   * Event interface triggered when a comment's resolve status changes
   * @interface ISheetCommentResolveEventParams
   * @augments {IEventBase}
   */
  interface ISheetCommentResolveEventParams extends IEventBase {
      /** The workbook instance */
      workbook: FWorkbook;
      /** The worksheet containing the comment */
      worksheet: FWorksheet;
      /** Row index of the comment */
      row: number;
      /** Column index of the comment */
      col: number;
      /** The comment object */
      comment: FThreadComment;
      /** The new resolve status */
      resolved: boolean;
  }

  interface ISheetsThreadCommentEventParamConfig {
      BeforeCommentAdd: IBeforeSheetCommentAddEventParams;
      CommentAdded: ISheetCommentAddEventParams;
      BeforeCommentUpdate: IBeforeSheetCommentUpdateEventParams;
      CommentUpdated: ISheetCommentUpdateEventParams;
      BeforeCommentDelete: IBeforeSheetCommentDeleteEventParams;
      CommentDeleted: ISheetCommentDeleteEventParams;
      BeforeCommentResolve: ISheetCommentResolveEventParams;
      CommentResolved: ISheetCommentResolveEventParams;
  }

  interface IFRangeSheetsThreadCommentMixin {
      /**
       * Get the comment of the start cell in the current range.
       * @returns {FThreadComment | null} The comment of the start cell in the current range. If the cell does not have a comment, return `null`.
       * @example
       * ```ts
       * const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
       * if (!fWorksheet) return;
       * const range = fWorksheet.getActiveRange();
       * const comment = range.getComment();
       * ```
       */
      getComment(): Nullable<FThreadComment>;
      /**
       * Get the comments in the current range.
       * @returns {FThreadComment[]} The comments in the current range.
       * @example
       * ```ts
       * const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
       * if (!fWorksheet) return;
       * const range = fWorksheet.getActiveRange();
       * const comments = range.getComments();
       * comments.forEach((comment) => {
       *   console.log(comment.getContent());
       * });
       * ```
       */
      getComments(): FThreadComment[];
      /**
       * Add a comment to the start cell in the current range.
       * @param content The content of the comment.
       * @returns Whether the comment is added successfully.
       * @example
       * ```ts
       * // Create a new comment
       * const richText = univerAPI.newRichText().insertText('hello univer');
       * const commentBuilder = univerAPI.newTheadComment()
       *   .setContent(richText);
       * console.log(commentBuilder.content.toPlainText());
       *
       * // Add the comment to the cell A1
       * const fWorkbook = univerAPI.getActiveWorkbook();
       * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
       * if (!fWorksheet) return;
       * const cell = fWorksheet.getRange('A1');
       * const result = await cell.addCommentAsync(commentBuilder);
       * console.log(result);
       * ```
       */
      addCommentAsync(content: IDocumentBody | FTheadCommentBuilder): Promise<boolean>;
      /**
       * Clear the comment of the start cell in the current range.
       * @returns Whether the comment is cleared successfully.
       */
      clearCommentAsync(): Promise<boolean>;
      /**
       * Clear all of the comments in the current range.
       * @returns Whether the comments are cleared successfully.
       * @example
       * ```ts
       * const fWorksheet = univerAPI.getActiveWorkbook().getSheetByName('Sheet1');
       * if (!fWorksheet) return;
       * const range = fWorksheet.getActiveRange();
       * const success = await range.clearCommentsAsync();
       * ```
       */
      clearCommentsAsync(): Promise<boolean>;
  }

  class FRangeSheetsThreadCommentMixin {
      getComment(): Nullable<FThreadComment>;
      getComments(): FThreadComment[];
      addComment(content: IDocumentBody | FTheadCommentBuilder): Promise<boolean>;
      clearComment(): Promise<boolean>;
      clearComments(): Promise<boolean>;
      addCommentAsync(content: IDocumentBody | FTheadCommentBuilder): Promise<boolean>;
      clearCommentAsync(): Promise<boolean>;
      clearCommentsAsync(): Promise<boolean>;
  }

  /**
   * An readonly class that represents a comment.
   * @ignore
   */
  class FTheadCommentItem {
      /**
       * Create a new FTheadCommentItem
       * @param {IThreadComment|undefined} comment The comment
       * @returns {FTheadCommentItem} A new instance of FTheadCommentItem
       * @example
       * ```ts
       * const commentBuilder = univerAPI.newTheadComment();
       * console.log(commentBuilder);
       * ```
       */
      static create(comment?: IThreadComment): FTheadCommentItem;
      /**
       * Get the person id of the comment
       * @returns {string} The person id of the comment
       * @example
       * ```ts
       * const commentBuilder = univerAPI.newTheadComment();
       * console.log(commentBuilder.personId);
       * ```
       */
      get personId(): string;
      /**
       * Get the date time of the comment
       * @returns {string} The date time of the comment
       * @example
       * ```ts
       * const commentBuilder = univerAPI.newTheadComment();
       * console.log(commentBuilder.dateTime);
       * ```
       */
      get dateTime(): string;
      /**
       * Get the content of the comment
       * @returns {RichTextValue} The content of the comment
       * @example
       * ```ts
       * const commentBuilder = univerAPI.newTheadComment();
       * console.log(commentBuilder.content);
       * ```
       */
      get content(): RichTextValue;
      /**
       * Get the id of the comment
       * @returns {string} The id of the comment
       * @example
       * ```ts
       * const commentBuilder = univerAPI.newTheadComment();
       * console.log(commentBuilder.id);
       * ```
       */
      get id(): string;
      /**
       * Get the thread id of the comment
       * @returns {string} The thread id of the comment
       * @example
       * ```ts
       * const commentBuilder = univerAPI.newTheadComment();
       * console.log(commentBuilder.threadId);
       * ```
       */
      get threadId(): string;
      /**
       * Copy the comment
       * @returns {FTheadCommentBuilder} The comment builder
       * @example
       * ```ts
       * const commentBuilder = univerAPI.newTheadComment();
       * const newCommentBuilder = commentBuilder.copy();
       * console.log(newCommentBuilder);
       * ```
       */
      copy(): FTheadCommentBuilder;
  }

  /**
   * A builder for thread comment. use {@link FUniver} `univerAPI.newTheadComment()` to create a new builder.
   */
  class FTheadCommentBuilder extends FTheadCommentItem {
      static create(comment?: IThreadComment): FTheadCommentBuilder;
      /**
       * Set the content of the comment
       * @param {IDocumentBody | RichTextValue} content The content of the comment
       * @returns {FTheadCommentBuilder} The comment builder for chaining
       * @example
       * ```ts
       * // Create a new comment
       * const richText = univerAPI.newRichText().insertText('hello univer');
       * const commentBuilder = univerAPI.newTheadComment()
       *   .setContent(richText);
       * console.log(commentBuilder.content);
       *
       * // Add the comment to the cell A1
       * const fWorkbook = univerAPI.getActiveWorkbook();
       * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
       * if (!fWorksheet) return;
       * const cell = fWorksheet.getRange('A1');
       * const result = await cell.addCommentAsync(commentBuilder);
       * console.log(result);
       * ```
       */
      setContent(content: IDocumentBody | RichTextValue): FTheadCommentBuilder;
      /**
       * Set the person id of the comment
       * @param {string} userId The person id of the comment
       * @returns {FTheadCommentBuilder} The comment builder for chaining
       * @example
       * ```ts
       * // Create a new comment
       * const richText = univerAPI.newRichText().insertText('hello univer');
       * const commentBuilder = univerAPI.newTheadComment()
       *   .setContent(richText)
       *   .setPersonId('mock-user-id');
       * console.log(commentBuilder.personId);
       *
       * // Add the comment to the cell A1
       * const fWorkbook = univerAPI.getActiveWorkbook();
       * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
       * if (!fWorksheet) return;
       * const cell = fWorksheet.getRange('A1');
       * const result = await cell.addCommentAsync(commentBuilder);
       * console.log(result);
       * ```
       */
      setPersonId(userId: string): FTheadCommentBuilder;
      /**
       * Set the date time of the comment
       * @param {Date} date The date time of the comment
       * @returns {FTheadCommentBuilder} The comment builder for chaining
       * @example
       * ```ts
       * // Create a new comment
       * const richText = univerAPI.newRichText().insertText('hello univer');
       * const commentBuilder = univerAPI.newTheadComment()
       *   .setContent(richText)
       *   .setDateTime(new Date('2025-02-21 14:22:22'));
       * console.log(commentBuilder.dateTime);
       *
       * // Add the comment to the cell A1
       * const fWorkbook = univerAPI.getActiveWorkbook();
       * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
       * if (!fWorksheet) return;
       * const cell = fWorksheet.getRange('A1');
       * const result = await cell.addCommentAsync(commentBuilder);
       * console.log(result);
       * ```
       */
      setDateTime(date: Date): FTheadCommentBuilder;
      /**
       * Set the id of the comment
       * @param {string} id The id of the comment
       * @returns {FTheadCommentBuilder} The comment builder for chaining
       * @example
       * ```ts
       * // Create a new comment
       * const richText = univerAPI.newRichText().insertText('hello univer');
       * const commentBuilder = univerAPI.newTheadComment()
       *   .setContent(richText)
       *   .setId('mock-comment-id');
       * console.log(commentBuilder.id);
       *
       * // Add the comment to the cell A1
       * const fWorkbook = univerAPI.getActiveWorkbook();
       * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
       * if (!fWorksheet) return;
       * const cell = fWorksheet.getRange('A1');
       * const result = await cell.addCommentAsync(commentBuilder);
       * console.log(result);
       * ```
       */
      setId(id: string): FTheadCommentBuilder;
      /**
       * Set the thread id of the comment
       * @param {string} threadId The thread id of the comment
       * @returns {FTheadCommentBuilder} The comment builder
       * @example
       * ```ts
       * // Create a new comment
       * const richText = univerAPI.newRichText().insertText('hello univer');
       * const commentBuilder = univerAPI.newTheadComment()
       *   .setContent(richText)
       *   .setThreadId('mock-thread-id');
       * console.log(commentBuilder.threadId);
       *
       * // Add the comment to the cell A1
       * const fWorkbook = univerAPI.getActiveWorkbook();
       * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
       * if (!fWorksheet) return;
       * const cell = fWorksheet.getRange('A1');
       * const result = await cell.addCommentAsync(commentBuilder);
       * console.log(result);
       * ```
       */
      setThreadId(threadId: string): FTheadCommentBuilder;
      /**
       * Build the comment
       * @returns {IThreadComment} The comment
       * @example
       * ```ts
       * const richText = univerAPI.newRichText().insertText('hello univer');
       * const comment = univerAPI.newTheadComment()
       *   .setContent(richText)
       *   .setPersonId('mock-user-id')
       *   .setDateTime(new Date('2025-02-21 14:22:22'))
       *   .setId('mock-comment-id')
       *   .setThreadId('mock-thread-id')
       *   .build();
       * console.log(comment);
       * ```
       */
      build(): IThreadComment;
  }

  /**
   * A class that represents a thread comment already in the sheet.
   */
  class FThreadComment {
      /**
       * Whether the comment is a root comment
       * @returns {boolean} Whether the comment is a root comment
       * @example
       * ```ts
       * const fWorkbook = univerAPI.getActiveWorkbook();
       * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
       * if (!fWorksheet) return;
       * const comments = fWorksheet.getComments();
       * comments.forEach((comment) => {
       *   console.log(comment.getIsRoot());
       * });
       * ```
       */
      getIsRoot(): boolean;
      /**
       * Get the comment data
       * @returns {IBaseComment} The comment data
       * @example
       * ```ts
       * const fWorkbook = univerAPI.getActiveWorkbook();
       * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
       * if (!fWorksheet) return;
       * const comments = fWorksheet.getComments();
       * comments.forEach((comment) => {
       *   console.log(comment.getCommentData());
       * });
       * ```
       */
      getCommentData(): IBaseComment;
      /**
       * Get the replies of the comment
       * @returns {FThreadComment[]} the replies of the comment
       * @example
       * ```ts
       * const fWorkbook = univerAPI.getActiveWorkbook();
       * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
       * if (!fWorksheet) return;
       * const comments = fWorksheet.getComments();
       * comments.forEach((comment) => {
       *   if (comment.getIsRoot()) {
       *     const replies = comment.getReplies();
       *     replies.forEach((reply) => {
       *       console.log(reply.getCommentData());
       *     });
       *   }
       * });
       * ```
       */
      getReplies(): FThreadComment[] | undefined;
      /**
       * Get the range of the comment
       * @returns {FRange | null} The range of the comment
       * @example
       * ```ts
       * const fWorkbook = univerAPI.getActiveWorkbook();
       * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
       * if (!fWorksheet) return;
       * const comments = fWorksheet.getComments();
       * comments.forEach((comment) => {
       *   console.log(comment.getRange().getA1Notation());
       * });
       * ```
       */
      getRange(): FRange | null;
      /**
       * Get the rich text of the comment
       * @returns {RichTextValue} The rich text of the comment
       * @example
       * ```ts
       * const fWorkbook = univerAPI.getActiveWorkbook();
       * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
       * if (!fWorksheet) return;
       * const comments = fWorksheet.getComments();
       * comments.forEach((comment) => {
       *   console.log(comment.getRichText());
       * });
       * ```
       */
      getRichText(): RichTextValue;
      /**
       * Delete the comment and it's replies
       * @returns {Promise<boolean>} Whether the comment is deleted successfully
       * @example
       * ```ts
       * const fWorkbook = univerAPI.getActiveWorkbook();
       * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
       * if (!fWorksheet) return;
       * const comments = fWorksheet.getComments();
       *
       * // Delete the first comment
       * const result = await comments[0]?.deleteAsync();
       * console.log(result);
       * ```
       */
      deleteAsync(): Promise<boolean>;
      /**
       * Update the comment content
       * @param {IDocumentBody | RichTextValue} content The new content of the comment
       * @returns {Promise<boolean>} Whether the comment is updated successfully
       * @example
       * ```ts
       * const fWorkbook = univerAPI.getActiveWorkbook();
       * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
       * if (!fWorksheet) return;
       *
       * // Create a new comment
       * const richText = univerAPI.newRichText().insertText('hello univer');
       * const commentBuilder = univerAPI.newTheadComment()
       *   .setContent(richText)
       *   .setId('mock-comment-id');
       * const cell = fWorksheet.getRange('A1');
       * await cell.addCommentAsync(commentBuilder);
       *
       * // Update the comment after 3 seconds
       * setTimeout(async () => {
       *   const comment = fWorksheet.getCommentById('mock-comment-id');
       *   const newRichText = univerAPI.newRichText().insertText('Hello Univer AI');
       *   const result = await comment.updateAsync(newRichText);
       *   console.log(result);
       * }, 3000);
       * ```
       */
      updateAsync(content: IDocumentBody | RichTextValue): Promise<boolean>;
      /**
       * Resolve the comment
       * @param {boolean} resolved Whether the comment is resolved
       * @returns {Promise<boolean>} Set the comment to resolved or not operation result
       * @example
       * ```ts
       * const fWorkbook = univerAPI.getActiveWorkbook();
       * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
       * if (!fWorksheet) return;
       *
       * // Create a new comment
       * const richText = univerAPI.newRichText().insertText('hello univer');
       * const commentBuilder = univerAPI.newTheadComment()
       *   .setContent(richText)
       *   .setId('mock-comment-id');
       * const cell = fWorksheet.getRange('A1');
       * await cell.addCommentAsync(commentBuilder);
       *
       * // Resolve the comment after 3 seconds
       * setTimeout(async () => {
       *   const comment = fWorksheet.getCommentById('mock-comment-id');
       *   const result = await comment.resolveAsync(true);
       *   console.log(result);
       * }, 3000);
       * ```
       */
      resolveAsync(resolved?: boolean): Promise<boolean>;
      /**
       * Reply to the comment
       * @param {FTheadCommentBuilder} comment The comment to reply to
       * @returns {Promise<boolean>} Whether the comment is replied successfully
       * @example
       * ```ts
       * const fWorkbook = univerAPI.getActiveWorkbook();
       * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
       * if (!fWorksheet) return;
       *
       * // Create a new comment
       * const richText = univerAPI.newRichText().insertText('hello univer');
       * const commentBuilder = univerAPI.newTheadComment()
       *   .setContent(richText)
       *   .setId('mock-comment-id');
       * const cell = fWorksheet.getRange('A1');
       * await cell.addCommentAsync(commentBuilder);
       *
       * // Reply to the comment
       * const replyText = univerAPI.newRichText().insertText('Hello Univer AI');
       * const reply = univerAPI.newTheadComment().setContent(replyText);
       * const comment = fWorksheet.getCommentById('mock-comment-id');
       * const result = await comment.replyAsync(reply);
       * console.log(result);
       * ```
       */
      replyAsync(comment: FTheadCommentBuilder): Promise<boolean>;
  }

  interface IFUniverSheetsThreadCommentMixin {
      /**
       * Create a new thread comment
       * @returns {FTheadCommentBuilder} The thead comment builder
       * @example
       * ```ts
       * // Create a new comment
       * const richText = univerAPI.newRichText().insertText('hello univer');
       * const commentBuilder = univerAPI.newTheadComment()
       *   .setContent(richText)
       *   .setPersonId('mock-user-id')
       *   .setDateTime(new Date('2025-02-21 14:22:22'))
       *   .setId('mock-comment-id')
       *   .setThreadId('mock-thread-id');
       *
       * // Add the comment to the cell A1
       * const fWorkbook = univerAPI.getActiveWorkbook();
       * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
       * if (!fWorksheet) return;
       * const cell = fWorksheet.getRange('A1');
       * const result = await cell.addCommentAsync(commentBuilder);
       * console.log(result);
       * ```
       */
      newTheadComment(): FTheadCommentBuilder;
  }

  class FUniverSheetsThreadCommentMixin {
      newTheadComment(comment?: IThreadComment): FTheadCommentBuilder;
  }

  interface IFWorkbookSheetsThreadCommentMixin {
      /**
       * Get all comments in the current workbook
       * @returns {FThreadComment[]} All comments in the current workbook
       * @example
       * ```ts
       * const fWorkbook = univerAPI.getActiveWorkbook();
       * const comments = fWorkbook.getComments();
       * comments.forEach((comment) => {
       *   const isRoot = comment.getIsRoot();
       *
       *   if (isRoot) {
       *     console.log('root comment:', comment.getCommentData());
       *
       *     const replies = comment.getReplies();
       *     replies.forEach((reply) => {
       *       console.log('reply comment:', reply.getCommentData());
       *     });
       *   }
       * });
       * ```
       */
      getComments(): FThreadComment[];
      /**
       * Clear all comments in the current workbook
       * @returns {Promise<boolean>} Whether the comments are cleared successfully.
       * @example
       * ```ts
       * const fWorkbook = univerAPI.getActiveWorkbook();
       * const result = await fWorkbook.clearComments();
       * console.log(result);
       * ```
       */
      clearComments(): Promise<boolean>;
  }

  class FWorkbookSheetsThreadCommentMixin {
      getComments(): FThreadComment[];
      clearComments(): Promise<boolean>;
  }

  interface IFWorksheetCommentMixin {
      /**
       * Get all comments in the current sheet
       * @returns {FThreadComment[]} All comments in the current sheet
       * @example
       * ```ts
       * const fWorkbook = univerAPI.getActiveWorkbook();
       * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
       * if (!fWorksheet) return;
       * const comments = fWorksheet.getComments();
       * comments.forEach((comment) => {
       *   const isRoot = comment.getIsRoot();
       *
       *   if (isRoot) {
       *     console.log('root comment:', comment.getCommentData());
       *
       *     const replies = comment.getReplies();
       *     replies.forEach((reply) => {
       *       console.log('reply comment:', reply.getCommentData());
       *     });
       *   }
       * });
       * ```
       */
      getComments(): FThreadComment[];
      /**
       * Clear all comments in the current sheet
       * @returns {Promise<boolean>} Whether the comments are cleared successfully.
       * @example
       * ```ts
       * const fWorkbook = univerAPI.getActiveWorkbook();
       * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
       * if (!fWorksheet) return;
       * const result = await fWorksheet.clearComments();
       * console.log(result);
       * ```
       */
      clearComments(): Promise<boolean>;
      /**
       * get comment by comment id
       * @param {string} commentId comment id
       * ```ts
       * const fWorkbook = univerAPI.getActiveWorkbook();
       * const fWorksheet = fWorkbook.getSheetByName('Sheet1');
       * if (!fWorksheet) return;
       *
       * // Create a new comment
       * const richText = univerAPI.newRichText().insertText('hello univer');
       * const commentBuilder = univerAPI.newTheadComment()
       *   .setContent(richText)
       *   .setId('mock-comment-id');
       * const cell = fWorksheet.getRange('A1');
       * await cell.addCommentAsync(commentBuilder);
       *
       * const comment = fWorksheet.getCommentById('mock-comment-id');
       * console.log(comment, comment?.getCommentData());
       * ```
       */
      getCommentById(commentId: string): FThreadComment | undefined;
  }

  class FWorksheetCommentMixin {
      getComments(): FThreadComment[];
      clearComments(): Promise<boolean>;
      /**
       * Subscribe to comment events.
       * @param callback Callback function, param contains comment info and target cell.
       */
      onCommented(callback: (params: IAddCommentCommandParams) => void): IDisposable;
      getCommentById(commentId: string): FThreadComment | undefined;
  }
}

declare module "@univerjs/thread-comment" {
  import type { IDocumentBody } from "@univerjs/core";

  interface IAddCommentCommandParams {
      unitId: string;
      subUnitId: string;
      comment: IThreadComment;
  }

  interface IBaseComment {
      id: string;
      threadId: string;
      dT: string;
      updateT?: string;
      personId: string;
      text: IDocumentBody;
      attachments?: string[];
      updated?: boolean;
      mentions?: string[];
      parentId?: string;
      resolved?: boolean;
      unitId: string;
      subUnitId: string;
      children?: IBaseComment[];
  }

  interface IThreadComment extends IBaseComment {
      ref: string;
  }
}

declare module "@univerjs/core/facade" {
  import type { IFUniverSheetsThreadCommentMixin, ISheetsThreadCommentEventParamConfig } from "@univerjs/sheets-thread-comment/facade";

  interface FEventName extends IFSheetsThreadCommentEventNameMixin {
  }

  interface IEventParamConfig extends ISheetsThreadCommentEventParamConfig {
  }
}

declare module "@univerjs/sheets/facade" {
  import type { IFRangeSheetsThreadCommentMixin, IFWorkbookSheetsThreadCommentMixin, IFWorksheetCommentMixin } from "@univerjs/sheets-thread-comment/facade";

  interface FRange extends IFRangeSheetsThreadCommentMixin {
  }
}

declare module "@univerjs/core/facade" {
  import type { IFUniverSheetsThreadCommentMixin, ISheetsThreadCommentEventParamConfig } from "@univerjs/sheets-thread-comment/facade";

  interface FUniver extends IFUniverSheetsThreadCommentMixin {
  }
}

declare module "@univerjs/sheets/facade" {
  import type { IFRangeSheetsThreadCommentMixin, IFWorkbookSheetsThreadCommentMixin, IFWorksheetCommentMixin } from "@univerjs/sheets-thread-comment/facade";

  interface FWorkbook extends IFWorkbookSheetsThreadCommentMixin {
  }
}

declare module "@univerjs/sheets/facade" {
  import type { IFRangeSheetsThreadCommentMixin, IFWorkbookSheetsThreadCommentMixin, IFWorksheetCommentMixin } from "@univerjs/sheets-thread-comment/facade";

  interface FWorksheet extends IFWorksheetCommentMixin {
  }
}
