<commit_before>import { Feature } from 'toolkit/extension/features/feature';
import { getEmberView } from 'toolkit/extension/utils/ember';
import {
  ensureGoalColumn,
  GOAL_TABLE_CELL_CLASSNAME,
} from 'toolkit/extension/features/budget/utils';

export class GoalIndicator extends Feature {
  injectCSS() {
    return require('./index.css');
  }

  shouldInvoke() {
    return true;
  }

  destroy() {
    $('.tk-goal-indicator').remove();
  }

  invoke() {
    this.addToolkitEmberHook('budget-table-row', 'didRender', this.addGoalIndicator);
  }

  addGoalIndicator(element) {
    if (!ensureGoalColumn(element)) {
      return;
    }

    const category = getEmberView(element.id, 'category');
    if (!category) {
      return;
    }

    // these need to be defined inside `invoke` because ynab must be on the window
    const GoalTypeLabels = {
      MF: ['M', 'Monthly budgeting goal'],
      NEED: ['S', 'Spending goal'],
      TB: ['T', 'Target balance goal'],
      TBD: ['D', 'Target by date goal'],
    };

    const goalContainer = element.querySelector(`.${GOAL_TABLE_CELL_CLASSNAME}`);
    const { monthlySubCategoryBudgetCalculation, goalType } = category;
    const hasUpcomingTransactions =
      monthlySubCategoryBudgetCalculation?.upcomingTransactionsCount > 0;
    const goalTypeElement = element.querySelector(<commit_msg>faet: support DEBT goals in goal indicator<commit_after>import { Feature } from 'toolkit/extension/features/feature';
import { getEmberView } from 'toolkit/extension/utils/ember';
import {
  ensureGoalColumn,
  GOAL_TABLE_CELL_CLASSNAME,
} from 'toolkit/extension/features/budget/utils';

export class GoalIndicator extends Feature {
  injectCSS() {
    return require('./index.css');
  }

  shouldInvoke() {
    return true;
  }

  destroy() {
    $('.tk-goal-indicator').remove();
  }

  invoke() {
    this.addToolkitEmberHook('budget-table-row', 'didRender', this.addGoalIndicator);
  }

  addGoalIndicator(element) {
    if (!ensureGoalColumn(element)) {
      return;
    }

    const category = getEmberView(element.id, 'category');
    if (!category) {
      return;
    }

    // these need to be defined inside `invoke` because ynab must be on the window
    const GoalTypeLabels = {
      MF: ['M', 'Monthly budgeting goal'],
      NEED: ['S', 'Spending goal'],
      TB: ['T', 'Target balance goal'],
      TBD: ['D', 'Target by date goal'],
      DEBT: ['MD', 'Debt goal'],
    };

    const goalContainer = element.querySelector(`.${GOAL_TABLE_CELL_CLASSNAME}`);
    const { monthlySubCategoryBudgetCalculation, goalType } = category;
    const hasUpcomingTransactions =
      monthlySubCategoryBudgetCalculation?.upcomingTransactionsCount > 0;
    const goalTypeElement = element.querySelector(
{'fraction_non_alphanumeric': 0.12989840348330914, 'fraction_numerical': 0.000725689404934688, 'mean_word_length': 3.6808149405772497, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7316351', 'n_tokens_mistral': 866, 'n_tokens_neox': 849, 'n_words': 191}