text: var __assign = (this && this.__assign) || Object.assign || function(t) {
      for (var s, i = 1, n = arguments.length; i < n; i++) {
          s = arguments[i];
          for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
              t[p] = s[p];
      }
      return t;
  };
  /**
   * @internalapi
   * @module url
   */ /** for typedoc */
  import { forEach, extend } from '../common/common';
  import { isObject, isDefined, isFunction, isString } from '../common/predicates';
  import { UrlMatcher } from './urlMatcher';
  import { Param, DefType } from '../params/param';
  import { ParamTypes } from '../params/paramTypes';
  /** @internalapi */
  var ParamFactory = /** @class */ (function () {
      function ParamFactory(umf) {
          this.umf = umf;
      }
      ParamFactory.prototype.fromConfig = function (id, type, state) {
          return new Param(id, type, DefType.CONFIG, this.umf, state);
      };
      ParamFactory.prototype.fromPath = function (id, type, state) {
          return new Param(id, type, DefType.PATH, this.umf, state);
      };
      ParamFactory.prototype.fromSearch = function (id, type, state) {
          return new Param(id, type, DefType.SEARCH, this.umf, state);
      };
      return ParamFactory;
  }());
  export { ParamFactory };
  /**
   * Factory for [[UrlMatcher]] instances.
   *
   * The factory is available to ng1 services as
   * `$urlMatcherFactory` or ng1 providers as `$urlMatcherFactoryProvider`.
   */
  var UrlMatcherFactory = /** @class */ (function () {
      function UrlMatcherFactory() {
          /** @hidden */ this.paramTypes = new ParamTypes();
          /** @hidden */ this._isCaseInsensitive = false;
          /** @hidden */ this._isStrictMode = true;
          /** @hidden */ this._defaultSquashPolicy = false;
          /** @internalapi Creates a new [[Param]] for a given location (DefType) */
          this.paramFactory = new ParamFactory(this);
          extend(this, { UrlMatcher: UrlMatcher, Param: Param });
      }
      /** @inheritdoc */
      UrlMatcherFactory.prototype.caseInsensitive = function (value) {
          return (this._isCaseInsensitive = isDefined(value) ? value : this._isCaseInsensitive);
      };
      /** @inheritdoc */
      UrlMatcherFactory.prototype.strictMode = function (value) {
          return (this._isStrictMode = isDefined(value) ? value : this._isStrictMode);
      };
      /** @inheritdoc */
      UrlMatcherFactory.prototype.defaultSquashPolicy = function (value) {
          if (isDefined(value) && value !== true && value !== false && !isString(value))
              throw new Error("Invalid squash policy: " + value + ". Valid policies: false, true, arbitrary-string");
          return (this._defaultSquashPolicy = isDefined(value) ? value : this._defaultSquashPolicy);
      };
      /**
       * Creates a [[UrlMatcher]] for the specified pattern.
       *
       * @param pattern  The URL pattern.
       * @param config  The config object hash.
       * @returns The UrlMatcher.
       */
      UrlMatcherFactory.prototype.compile = function (pattern, config) {
          // backward-compatible support for config.params -> config.state.params
          var params = config && !config.state && config.params;
          config = params ? __assign({ state: { params: params } }, config) : config;
          var globalConfig = { strict: this._isStrictMode, caseInsensitive: this._isCaseInsensitive };
          return new UrlMatcher(pattern, this.paramTypes, this.paramFactory, extend(globalConfig, config));
      };
      /**
       * Returns true if the specified object is a [[UrlMatcher]], or false otherwise.
       *
       * @param object  The object to perform the type check against.
       * @returns `true` if the object matches the `UrlMatcher` interface, by
       *          implementing all the same methods.
       */
      UrlMatcherFactory.prototype.isMatcher = function (object) {
          // TODO: typeof?
          if (!isObject(object))
              return false;
          var result = true;
          forEach(UrlMatcher.prototype, function (val, name) {
              if (isFunction(val))
                  result = result && (isDefined(object[name]) && isFunction(object[name]));
          });
          return result;
      };
      /**
       * Creates and registers a custom [[ParamType]] object
       *
       * A [[ParamType]] can be used to generate URLs with typed parameters.
       *
       * @param name  The type name.
       * @param definition The type definition. See [[ParamTypeDefinition]] for information on the values accepted.
       * @param definitionFn A function that is injected before the app runtime starts.
       *        The result of this function should be a [[ParamTypeDefinition]].
       *        The result is merged into the existing `definition`.
       *        See [[ParamType]] for information on the values accepted.
       *
       * @returns - if a type was registered: the [[UrlMatcherFactory]]
       *   - if only the `name` parameter was specified: the currently registered [[ParamType]] object, or undefined
       *
       * Note: Register custom types *before using them* in a state definition.
       *
       * See [[ParamTypeDefinition]] for examples
       */
      UrlMatcherFactory.prototype.type = function (name, definition, definitionFn) {
          var type = this.paramTypes.type(name, definition, definitionFn);
          return !isDefined(definition) ? type : this;
      };
      /** @hidden */
      UrlMatcherFactory.prototype.$get = function () {
          this.paramTypes.enqueue = false;
          this.paramTypes._flushTypeQueue();
          return this;
      };
      /** @internalapi */
      UrlMatcherFactory.prototype.dispose = function () {
          this.paramTypes.dispose();
      };
      return UrlMatcherFactory;
  }());
  export { UrlMatcherFactory };
  //# sourceMappingURL=urlMatcherFactory.js.map