<commit_before>import {
  Opaque,
  Option,
  Simple
} from '@glimmer/interfaces';
import {
  CachedReference,
  combine,
  map,
  Reference,
  Tag,
} from '@glimmer/reference';
import {
  ElementOperations
} from '@glimmer/runtime';
import { Core, Ops } from '@glimmer/wire-format';
import { assert } from 'ember-debug';
import { get } from 'ember-metal';
import { String as StringUtils } from 'ember-runtime';
import { ROOT_REF } from '../component';
import { Component } from './curly-component-state-bucket';
import { htmlSafe, isHTMLSafe, SafeString } from './string';

function referenceForKey(component: Component, key: string) {
  return component[ROOT_REF].get(key);
}

function referenceForParts(component: Component, parts: string[]): Reference {
  let isAttrs = parts[0] === 'attrs';

  // TODO deprecate this
  if (isAttrs) {
    parts.shift();

    if (parts.length === 1) {
      return referenceForKey(component, parts[0]);
    }
  }

  return referenceForParts(component[ROOT_REF], parts);
}

// TODO we should probably do this transform at build time
export function wrapComponentClassAttribute(hash: Core.Hash) {
  if (hash === null) {
    return;
  }
<commit_msg>Bring over referenceFromParts<commit_after>import {
  Opaque,
  Option,
  Simple
} from '@glimmer/interfaces';
import {
  CachedReference,
  combine,
  map,
  Reference,
  Tag,
  VersionedPathReference
} from '@glimmer/reference';
import {
  ElementOperations
} from '@glimmer/runtime';
import { Core, Ops } from '@glimmer/wire-format';
import { assert } from 'ember-debug';
import { get } from 'ember-metal';
import { String as StringUtils } from 'ember-runtime';
import { ROOT_REF } from '../component';
import { Component } from './curly-component-state-bucket';
import { htmlSafe, isHTMLSafe, SafeString } from './string';

function referenceForKey(component: Component, key: string) {
  return component[ROOT_REF].get(key);
}

function referenceFromParts(root: VersionedPathReference<Opaque>, parts: string[]): VersionedPathReference<Opaque> {
  let reference = root;

  for (let i=0; i<parts.length; i++) {
    reference = reference.get(parts[i]);
  }

  return reference;
}

function referenceForParts(component: Component, parts: string[]): Reference {
  let isAttrs = parts[0] === 'attrs';

  // TODO deprecate this
  if (isAttrs) {
    parts.shift();

    if (parts.length === 1) {
      return referenceForKey(component, parts[0]);
    }
  }

  return referenceFromParts(component[ROOT_REF], parts);
}

// TODO we should probably do this transform at build time
export function wrapComponentClassAttribute(hash: Core.Hash) {
  if (hash === null) {
    return;
  }

{'fraction_non_alphanumeric': 0.13506395786305492, 'fraction_numerical': 0.0026335590669676447, 'mean_word_length': 4.328657314629258, 'pattern_counts': {'":': 0, '<': 6, '<?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': '6950558', 'n_tokens_mistral': 824, 'n_tokens_neox': 820, 'n_words': 223}