<commit_before>import { privatize as P } from '@ember/-internals/container';
import type { OutletState as GlimmerOutletState, OutletView } from '@ember/-internals/glimmer';
import { computed, get, set } from '@ember/-internals/metal';
import type { Factory, FactoryClass, Owner } from '@ember/-internals/owner';
import { getOwner } from '@ember/-internals/owner';
import { BucketCache } from '@ember/-internals/routing';
import type RouterService from '@ember/-internals/routing/lib/services/router';
import { A as emberA, Evented, Object as EmberObject, typeOf } from '@ember/-internals/runtime';
import { assert, deprecate, info } from '@ember/debug';
import EmberError from '@ember/error';
import { cancel, once, run, scheduleOnce } from '@ember/runloop';
import { DEBUG } from '@glimmer/env';
import type { EmberLocation as IEmberLocation } from '../location/api';
import EmberLocation from '../location/api';
import type { RouteArgs, RouteOptions } from '../utils';
import { calculateCacheKey, extractRouteArgs, getActiveTargetName, resemblesURL } from '../utils';
import type { DSLCallback } from './dsl';
import DSL from './dsl';
import type { QueryParamMeta, RenderOptions } from './route';
import type Route from './route';
import {
  defaultSerialize,
  getFullQueryParams,
  hasDefaultSerialize,
  ROUTE_CONNECTIONS,
} from './route';
import RouterState from './router_state';

/**
@module @ember/routing
*/

import type {
  InternalRouteInfo,
  ModelFor,
  RouteInfo,
  RouteInfoWithAttributes,
  Transition,
  TransitionError,
  TransitionState,
} from 'router_js';
import Router, { logAbort, STATE_SYMBOL } from 'router_js';
import type { Timer } from 'backburner';
import type { EngineRouteInfo } from './engines';
import EngineInstance from '@ember/engine/instance';
import type { QueryParams } from 'route-recognizer';
import type { AnyFn, MethodNamesOf, OmitFirst } from '@ember/-internals/utils/types';

function defaultDidTransition<R extends Route>(
  this: EmberRouter<R>,
  infos: InternalRouteInfo<R>[]
) {
  updatePaths(this);

  this._cancelSlowTransitionTimer();

  this.notifyPropertyChange('url');
  this.set('currentState', this.targetState);

  if (DEBUG) {
    // @ts-expect-error namespace isn't public
    if (this.namespace.LOG_TRANSITIONS) {
      // eslint-disable-next-line no-console
      console.log(`Transitioned into '${EmberRouter._routePath(infos)}'`);
    }
  }
}

function defaultWillTransition<R extends Route>(
  this: EmberRouter<R>,
  oldInfos: InternalRouteInfo<R>[],
  newInfos: InternalRouteInfo<R>[]
) {
  if (DEBUG) {
    // @ts-expect-error namespace isn't public
    if (this.namespace.LOG_TRANSITIONS) {
      // eslint-disable-next-line no-console
      console.log(
        `Preparing to transition from '${EmberRouter._routePath(
          oldInfos
        )}' to '${EmberRouter._routePath(newInfos)}'`
      );
    }
  }
}

let freezeRouteInfo: Function;
if (DEBUG) {
  freezeRouteInfo = (transition: Transition) => {
    if (transition.from !== null && !Object.isFrozen(transition.from)) {
      Object.freeze(transition.from);
    }

    if (transition.to !== null && !Object.isFrozen(transition.to)) {
      Object.freeze(transition.to);
    }
  };
}

interface RenderOutletState {
  name: string;
  outlet: string;
}

interface NestedOutletState {
  [key: string]: OutletState;
}

interface OutletState<T extends RenderOutletState = RenderOutletState> {
  render: T;
  outlets: NestedOutletState;
  wasUsed?: boolean;
}

export interface QueryParam {
  prop: string;
  urlKey: string;
  type: string;
  route: Route;
  parts?: string[];
  values: {} | null;
  scopedPropertyName: string;
  scope: string;
  defaultValue: unknown;
  undecoratedDefaultValue: unknown;
  serializedValue: string | null | undefined;
  serializedDefaultValue: string | null | undefined;
  controllerName: string;
}

function K(this: Router<Route>) {
  return this;
}

const { slice } = Array.prototype;

/**
  The `EmberRouter` class manages the application state and URLs. Refer to
  the [routing guide](https://guides.emberjs.com/release/routing/) for documentation.

  @class EmberRouter
  @extends EmberObject
  @uses Evented
  @public
*/
class EmberRouter<R extends Route = Route> extends EmberObject.extend(Evented) implements Evented {
  /**
   Represents the URL of the root of the application, often '/'. This prefix is
    assumed on all routes defined on this router.

    @property rootURL
    @default '/'
    @public
  */
  // Set with reopen to allow overriding via extend
  declare rootURL: string;

  /**
   The `location` property determines the type of URL's that your
    application will use.

    The following location types are currently available:

    * `history` - use the browser's history API to make the URLs look just like any standard URL
    * `hash` - use `#` to separate the server part of the URL from the Ember part: `/blog/#/posts/new`
    * `none` - do not store the Ember URL in the actual browser URL (mainly used for testing)
    * `auto` - use the best option based on browser capabilities: `history` if possible, then `hash` if possible, otherwise `none`

    This value is defaulted to `auto` by the `locationType` setting of `/config/environment.js`

    @property location
    @default 'hash'
    @see {Location}
    @public
  */
  // Set with reopen to allow overriding via extend
  declare location: string | IEmberLocation;

  _routerMicrolib!: Router<R>;
  _didSetupRouter = false;<commit_msg>[DOC] Document that `history` is the default `locationType` value<commit_after>import { privatize as P } from '@ember/-internals/container';
import type { OutletState as GlimmerOutletState, OutletView } from '@ember/-internals/glimmer';
import { computed, get, set } from '@ember/-internals/metal';
import type { Factory, FactoryClass, Owner } from '@ember/-internals/owner';
import { getOwner } from '@ember/-internals/owner';
import { BucketCache } from '@ember/-internals/routing';
import type RouterService from '@ember/-internals/routing/lib/services/router';
import { A as emberA, Evented, Object as EmberObject, typeOf } from '@ember/-internals/runtime';
import { assert, deprecate, info } from '@ember/debug';
import EmberError from '@ember/error';
import { cancel, once, run, scheduleOnce } from '@ember/runloop';
import { DEBUG } from '@glimmer/env';
import type { EmberLocation as IEmberLocation } from '../location/api';
import EmberLocation from '../location/api';
import type { RouteArgs, RouteOptions } from '../utils';
import { calculateCacheKey, extractRouteArgs, getActiveTargetName, resemblesURL } from '../utils';
import type { DSLCallback } from './dsl';
import DSL from './dsl';
import type { QueryParamMeta, RenderOptions } from './route';
import type Route from './route';
import {
  defaultSerialize,
  getFullQueryParams,
  hasDefaultSerialize,
  ROUTE_CONNECTIONS,
} from './route';
import RouterState from './router_state';

/**
@module @ember/routing
*/

import type {
  InternalRouteInfo,
  ModelFor,
  RouteInfo,
  RouteInfoWithAttributes,
  Transition,
  TransitionError,
  TransitionState,
} from 'router_js';
import Router, { logAbort, STATE_SYMBOL } from 'router_js';
import type { Timer } from 'backburner';
import type { EngineRouteInfo } from './engines';
import EngineInstance from '@ember/engine/instance';
import type { QueryParams } from 'route-recognizer';
import type { AnyFn, MethodNamesOf, OmitFirst } from '@ember/-internals/utils/types';

function defaultDidTransition<R extends Route>(
  this: EmberRouter<R>,
  infos: InternalRouteInfo<R>[]
) {
  updatePaths(this);

  this._cancelSlowTransitionTimer();

  this.notifyPropertyChange('url');
  this.set('currentState', this.targetState);

  if (DEBUG) {
    // @ts-expect-error namespace isn't public
    if (this.namespace.LOG_TRANSITIONS) {
      // eslint-disable-next-line no-console
      console.log(`Transitioned into '${EmberRouter._routePath(infos)}'`);
    }
  }
}

function defaultWillTransition<R extends Route>(
  this: EmberRouter<R>,
  oldInfos: InternalRouteInfo<R>[],
  newInfos: InternalRouteInfo<R>[]
) {
  if (DEBUG) {
    // @ts-expect-error namespace isn't public
    if (this.namespace.LOG_TRANSITIONS) {
      // eslint-disable-next-line no-console
      console.log(
        `Preparing to transition from '${EmberRouter._routePath(
          oldInfos
        )}' to '${EmberRouter._routePath(newInfos)}'`
      );
    }
  }
}

let freezeRouteInfo: Function;
if (DEBUG) {
  freezeRouteInfo = (transition: Transition) => {
    if (transition.from !== null && !Object.isFrozen(transition.from)) {
      Object.freeze(transition.from);
    }

    if (transition.to !== null && !Object.isFrozen(transition.to)) {
      Object.freeze(transition.to);
    }
  };
}

interface RenderOutletState {
  name: string;
  outlet: string;
}

interface NestedOutletState {
  [key: string]: OutletState;
}

interface OutletState<T extends RenderOutletState = RenderOutletState> {
  render: T;
  outlets: NestedOutletState;
  wasUsed?: boolean;
}

export interface QueryParam {
  prop: string;
  urlKey: string;
  type: string;
  route: Route;
  parts?: string[];
  values: {} | null;
  scopedPropertyName: string;
  scope: string;
  defaultValue: unknown;
  undecoratedDefaultValue: unknown;
  serializedValue: string | null | undefined;
  serializedDefaultValue: string | null | undefined;
  controllerName: string;
}

function K(this: Router<Route>) {
  return this;
}

const { slice } = Array.prototype;

/**
  The `EmberRouter` class manages the application state and URLs. Refer to
  the [routing guide](https://guides.emberjs.com/release/routing/) for documentation.

  @class EmberRouter
  @extends EmberObject
  @uses Evented
  @public
*/
class EmberRouter<R extends Route = Route> extends EmberObject.extend(Evented) implements Evented {
  /**
   Represents the URL of the root of the application, often '/'. This prefix is
    assumed on all routes defined on this router.

    @property rootURL
    @default '/'
    @public
  */
  // Set with reopen to allow overriding via extend
  declare rootURL: string;

  /**
   The `location` property determines the type of URL's that your
    application will use.

    The following location types are currently available:

    * `history` - use the browser's history API to make the URLs look just like any standard URL
    * `hash` - use `#` to separate the server part of the URL from the Ember part: `/blog/#/posts/new`
    * `none` - do not store the Ember URL in the actual browser URL (mainly used for testing)
    * `auto` - use the best option based on browser capabilities: `history` if possible, then `hash` if possible, otherwise `none`

    This value is defaulted to `history` by the `locationType` setting of `/config/environment.js`

    @property location
    @default 'hash'
    @see {Location}
    @public
  */
  // Set with reopen to allow overriding via extend
  declare location: string | IEmberLocation;

  _routerMicrolib!: Router<R>;
  _didSetupRouter = false;
{'fraction_non_alphanumeric': 0.11909725369346506, 'fraction_numerical': 0.0, 'mean_word_length': 4.045267489711934, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, 'https://': 2, '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': '2977366', 'n_tokens_mistral': 3353, 'n_tokens_neox': 3289, 'n_words': 999}