<commit_before>import Ember from 'ember';
const { getOwner } = Ember;
import { transitionTo } from '../private-api';
import { modelType } from '@cardstack/rendering/helpers/cs-model-type';

export default Ember.Service.extend({
  overlays: Ember.inject.service('ember-overlays'),
  resourceMetadata: Ember.inject.service(),
  cardstackRouting: Ember.inject.service(),
  marks: Ember.computed.alias('overlays.marks'),

  fields: Ember.computed('marks', function() {
    return this.get('marks').filter(m => m.group === 'cardstack-fields');
  }),

  contentPages: Ember.computed('marks', function() {
    return this.get('marks').filter(m => m.group === 'cardstack-pages');
  }),

  activeContentItem: Ember.computed('contentPages', function() {
    return this.get('contentPages')[0];
  }),

  _activeItemMeta: Ember.computed('activeContentItem', function() {
    let model = this.get('activeContentItem.model')
    if (model) {
      return this.get('resourceMetadata').read(model);
    }
  }),

  branch: Ember.computed.alias('_activeItemMeta.branch'),

  activeFields: Ember.computed('activeContentItem', 'fields', function() {
    let item = this.get('activeContentItem');
    if (item) {
      return this.get('fields').filter(f => f.model.content === item.model);
    } else {
      return [];
    }
  }),

  // Can tools be enabled at all? This affects whether we will offer a
  // launcher button
  available: Ember.computed.alias('session.session.isAuthenticated'),

  // This is not a plain injection because it's optional -- if
  // cardstack tools is present, we use it, otherwise we are never
  // active and it doesn't matter.
  session: Ember.computed(function() {
    return Ember.getOwner(this).lookup('service:cardstack-session');
  }),

  // Tools are active when the user has hit the launcher button and
  // revealed the toolbars.
  active: false,

  // Which tab are we showing in the toolbox?
  activePanel: 'cs-composition-panel',
  activePanelChoices: [
    {
      id: 'cs-composition-panel',
      icon: {
        name: 'write',
        width: 13,
        height: 18
      },
    }
  ],

  // Are we viewing the current URL as a normal page in its own right,
  // or in one of its other forms (like a preview card)?<commit_msg>smarter defaults for when to make tools available<commit_after>import Ember from 'ember';
const { getOwner } = Ember;
import { transitionTo } from '../private-api';
import { modelType } from '@cardstack/rendering/helpers/cs-model-type';

export default Ember.Service.extend({
  overlays: Ember.inject.service('ember-overlays'),
  resourceMetadata: Ember.inject.service(),
  cardstackRouting: Ember.inject.service(),
  marks: Ember.computed.alias('overlays.marks'),

  fields: Ember.computed('marks', function() {
    return this.get('marks').filter(m => m.group === 'cardstack-fields');
  }),

  contentPages: Ember.computed('marks', function() {
    return this.get('marks').filter(m => m.group === 'cardstack-pages');
  }),

  activeContentItem: Ember.computed('contentPages', function() {
    return this.get('contentPages')[0];
  }),

  _activeItemMeta: Ember.computed('activeContentItem', function() {
    let model = this.get('activeContentItem.model')
    if (model) {
      return this.get('resourceMetadata').read(model);
    }
  }),

  branch: Ember.computed.alias('_activeItemMeta.branch'),

  activeFields: Ember.computed('activeContentItem', 'fields', function() {
    let item = this.get('activeContentItem');
    if (item) {
      return this.get('fields').filter(f => f.model.content === item.model);
    } else {
      return [];
    }
  }),

  // Can tools be enabled at all? This affects whether we will offer a
  // launcher button
  available: Ember.computed('sessionService.session.isAuthenticated', function() {
    // If cardstack-session service is available, tools are only
    // available when the session is authenticated. Otherwise we
    // default to always available.
    return !this.get('sessionService') || this.get('sessionService.session.isAuthenticated');
  }),

  // This is not a plain injection because it's optional -- if
  // cardstack-session is present, we use it, otherwise we are never
  // active and it doesn't matter.
  sessionService: Ember.computed(function() {
    return Ember.getOwner(this).lookup('service:cardstack-session');
  }),

  // Tools are active when the user has hit the launcher button and
  // revealed the toolbars.
  active: false,

  // Which tab are we showing in the toolbox?
  activePanel: 'cs-composition-panel',
  activePanelChoices: [
    {
      id: 'cs-composition-panel',
      icon: {
        name: 'write',
        width: 13,
        height: 18
      },
    }
  ],

  // Are we viewing the current URL as a normal page in its own right,
  // or in one of its other forms (like a preview card)?
{'fraction_non_alphanumeric': 0.1422360248447205, 'fraction_numerical': 0.002070393374741201, 'mean_word_length': 3.498137802607076, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '4901136', 'n_tokens_mistral': 1465, 'n_tokens_neox': 1429, 'n_words': 391}