{"version":3,"file":"add-comment.mjs","names":[],"sources":["../../../src/codemods/lib/add-comment.ts"],"sourcesContent":["import type { API, ASTPath } from 'jscodeshift';\n\nexport const ERROR_PREFIX = 'FIXME(mastra): ';\n\nfunction existsComment(comments: ASTPath<any>['node']['comments'], comment: string): boolean {\n  let hasComment = false;\n\n  if (comments) {\n    comments.forEach((commentNode: { value: string; type: string }) => {\n      const currentComment = commentNode.value.trim();\n      if (currentComment === comment) {\n        hasComment = true;\n      }\n    });\n\n    if (hasComment) {\n      return true;\n    }\n  }\n  return false;\n}\n\nexport function insertCommentOnce(node: ASTPath<any>['node'], j: API['j'], comment: string): boolean {\n  const hasCommentInInlineComments = existsComment(node.comments, comment);\n  const hasCommentInLeadingComments = existsComment(node.leadingComments, comment);\n\n  if (!hasCommentInInlineComments && !hasCommentInLeadingComments) {\n    node.comments = [...(node.comments || []), j.commentBlock(` ${comment} `)];\n    return true;\n  }\n\n  return false;\n}\n"],"mappings":";AAEA,MAAa,eAAe;AAE5B,SAAS,cAAc,UAA4C,SAA0B;CAC3F,IAAI,aAAa;CAEjB,IAAI,UAAU;EACZ,SAAS,SAAS,gBAAiD;GAEjE,IADuB,YAAY,MAAM,KACxB,MAAM,SACrB,aAAa;EAEjB,CAAC;EAED,IAAI,YACF,OAAO;CAEX;CACA,OAAO;AACT;AAEA,SAAgB,kBAAkB,MAA4B,GAAa,SAA0B;CACnG,MAAM,6BAA6B,cAAc,KAAK,UAAU,OAAO;CACvE,MAAM,8BAA8B,cAAc,KAAK,iBAAiB,OAAO;CAE/E,IAAI,CAAC,8BAA8B,CAAC,6BAA6B;EAC/D,KAAK,WAAW,CAAC,GAAI,KAAK,YAAY,CAAC,GAAI,EAAE,aAAa,IAAI,QAAQ,EAAE,CAAC;EACzE,OAAO;CACT;CAEA,OAAO;AACT"}