<commit_before>/// <reference path='../../typings/angularjs/angular.d.ts' />
import {runtime} from "../common/angular1";
import {IPromise} from "angular";
import trace from "../common/trace";

import {ITransitionOptions, ITreeChanges} from "./interface";
import {$transition, matchState} from "./transitionService";
import TransitionHook from "./transitionHook";
import HookBuilder from "./hookBuilder";
import {RejectFactory} from "./rejectFactory"

import {IParamsNode, ITransNode, IPath, IParamsPath, ITransPath} from "../path/interface";
import Path from "../path/path";
import PathFactory from "../path/pathFactory"

import {IPromises, IResolvables} from "../resolve/interface";
import Resolvable from "../resolve/resolvable";
import ResolveContext from "../resolve/resolveContext";
import PathContext from "../resolve/pathContext";


import {IStateViewConfig, IStateParams} from "../state/interface";
import {StateParams} from "../state/state"
import StateReference from "../state/stateReference"
import {IState, IStateDeclaration} from "../state/interface";

import {IRawParams} from "../params/interface"
import {ParamValues} from "../params/paramValues"

import {defaults, eq, extend, filter, flatten, forEach, identity, invoke, is, isEq, isFunction, isObject, isPromise, isDefined,
    map, noop, not, objectKeys, parse, pattern, pipe, pluck, prop, toJson, unnest, unroll, val, pairs} from "../common/common";


var transitionCount = 0, REJECT = new RejectFactory();

const stateSelf = (state: IState) => state.self;

/**
 * @ngdoc object
 * @name ui.router.state.type:Transition
 *
 * @description
 * Represents a transition between two states, and contains all contextual information about the
 * to/from states and parameters, as well as the list of states being entered and exited as a
 * result of this transition.
 *
 * @param {Object} from The origin {@link ui.router.state.$stateProvider#state state} from which the transition is leaving.
 * @param {Object} to The target {@link ui.router.state.$stateProvider#state state} being transitioned to.
 * @param {Object} options An object hash of the options for this transition.
 *
 * @returns {Object} New `Transition` object
 */
export class Transition {
  $id: number;

  _deferreds: any;
  private _treeChanges: ITreeChanges;

  promise: IPromise<any>;
  prepromise: IPromise<any>;
  redirects: IPromise<any>;

  constructor(fromPath: ITransPath, toPath: IParamsPath, private _options: ITransitionOptions = {}) {
    this._treeChanges = this._calcTreeChanges(fromPath, toPath, _options.reloadState);
    this.$id = transitionCount++;
    this._options.current = val(this);

    this._deferreds = {
      prehooks: runtime.$q.defer(), // Resolved when the transition is complete, but success callback not run yet
      posthooks: runtime.$q.defer(), // Resolved when the transition is complete, after success callbacks
      redirects: runtime.$q.defer() // Resolved when any transition redirects are complete
    };
    
    // Expose three promises to users of Transition
    this.prepromise = this._deferreds.prehooks.promise;
    this.promise = this._deferreds.posthooks.promise;
    this.redirects = this._deferreds.redirects.promise;
  }

  _calcTreeChanges(fromPath: ITransPath, toPath: IParamsPath, reloadState: IState): ITreeChanges {
    function nonDynamicParams(state) {
      return state.params.$$filter(not(prop('dynamic')));<commit_msg>fix(Transition): Only set default value of options.current if not already set<commit_after>/// <reference path='../../typings/angularjs/angular.d.ts' />
import {runtime} from "../common/angular1";
import {IPromise} from "angular";
import trace from "../common/trace";

import {ITransitionOptions, ITreeChanges} from "./interface";
import {$transition, matchState} from "./transitionService";
import TransitionHook from "./transitionHook";
import HookBuilder from "./hookBuilder";
import {RejectFactory} from "./rejectFactory"

import {IParamsNode, ITransNode, IPath, IParamsPath, ITransPath} from "../path/interface";
import Path from "../path/path";
import PathFactory from "../path/pathFactory"

import {IPromises, IResolvables} from "../resolve/interface";
import Resolvable from "../resolve/resolvable";
import ResolveContext from "../resolve/resolveContext";
import PathContext from "../resolve/pathContext";


import {IStateViewConfig, IStateParams} from "../state/interface";
import {StateParams} from "../state/state"
import StateReference from "../state/stateReference"
import {IState, IStateDeclaration} from "../state/interface";

import {IRawParams} from "../params/interface"
import {ParamValues} from "../params/paramValues"

import {defaults, eq, extend, filter, flatten, forEach, identity, invoke, is, isEq, isFunction, isObject, isPromise, isDefined,
    map, noop, not, objectKeys, parse, pattern, pipe, pluck, prop, toJson, unnest, unroll, val, pairs} from "../common/common";


var transitionCount = 0, REJECT = new RejectFactory();

const stateSelf = (state: IState) => state.self;

/**
 * @ngdoc object
 * @name ui.router.state.type:Transition
 *
 * @description
 * Represents a transition between two states, and contains all contextual information about the
 * to/from states and parameters, as well as the list of states being entered and exited as a
 * result of this transition.
 *
 * @param {Object} from The origin {@link ui.router.state.$stateProvider#state state} from which the transition is leaving.
 * @param {Object} to The target {@link ui.router.state.$stateProvider#state state} being transitioned to.
 * @param {Object} options An object hash of the options for this transition.
 *
 * @returns {Object} New `Transition` object
 */
export class Transition {
  $id: number;

  private _options: ITransitionOptions;
  private _treeChanges: ITreeChanges;

  private _deferreds: any;

  promise: IPromise<any>;
  prepromise: IPromise<any>;
  redirects: IPromise<any>;

  constructor(fromPath: ITransPath, toPath: IParamsPath, _options: ITransitionOptions = {}) {
    this._options = extend({ current: val(this) }, _options);
    this.$id = transitionCount++;
    this._treeChanges = this._calcTreeChanges(fromPath, toPath, _options.reloadState);

    this._deferreds = {
      prehooks: runtime.$q.defer(), // Resolved when the transition is complete, but success callback not run yet
      posthooks: runtime.$q.defer(), // Resolved when the transition is complete, after success callbacks
      redirects: runtime.$q.defer() // Resolved when any transition redirects are complete
    };
    
    // Expose three promises to users of Transition
    this.prepromise = this._deferreds.prehooks.promise;
    this.promise = this._deferreds.posthooks.promise;
    this.redirects = this._deferreds.redirects.promise;
  }

  _calcTreeChanges(fromPath: ITransPath, toPath: IParamsPath, reloadState: IState): ITreeChanges {
    function nonDynamicParams(state) {
      return state.params.$$filter(not(prop('dynamic')));
{'fraction_non_alphanumeric': 0.1239230327398047, 'fraction_numerical': 0.0005743825387708214, 'mean_word_length': 4.621468926553672, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '1436719', 'n_tokens_mistral': 1949, 'n_tokens_neox': 1939, 'n_words': 633}