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EAAO,MAC3C,EAAK,OAAO,EAAO,MAEvB,KAAO,CACL,IAAI,GAAS,EAEb,OAAS,EAAQ,EAAM,QAAQ,CAC7B,MAAM,EAAO,EAAM,GACnB,EAAK,OAAO,EACd,CACF,CAEA,OAAO,CACT,CAtCA,KAAK,UAAU,KAAO,EAEtB,KAAK,UAAU,KAAO,KAEtB,KAAK,UAAU,KAAO","file":"/npm/linked-list@3.1.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/linked-list@3.1.0/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * Creates an iterator that iterates over a list (through an item).\n *\n * @template {Item} [T=Item]\n */\nclass ItemIterator {\n  /**\n   * Create a new iterator.\n   *\n   * @param {T|null} item\n   */\n  constructor(item) {\n    /** @type {T|null} */\n    this.item = item\n  }\n\n  /**\n   * Move to the next item.\n   *\n   * @returns {IteratorResult<T, null>}\n   */\n  next() {\n    const value = this.item\n\n    if (value) {\n      this.item = value.next\n      return {value, done: false}\n    }\n\n    return {value: null, done: true}\n  }\n}\n\n/**\n * Double linked list item.\n */\nexport class Item {\n  /**\n   * Create a new linked list item.\n   */\n  constructor() {\n    /* eslint-disable no-unused-expressions */\n    /**\n     * The following item or `null` otherwise.\n     *\n     * @type {this|null}\n     */\n    this.next\n\n    /**\n     * The preceding item or `null` otherwise.\n     *\n     * @type {this|null}\n     */\n    this.prev\n\n    /**\n     * The list this item belongs to or `null` otherwise.\n     *\n     * @type {List<this>|null}\n     */\n    this.list\n    /* eslint-enable no-unused-expressions */\n  }\n\n  /**\n   * Add the given item **after** the operated on item in a list.\n   *\n   * Throws an error when the given item has no `detach`, `append`, or\n   * `prepend` methods.\n   * Returns `false` when the operated on item is not attached to a list,\n   * otherwise the given item.\n   *\n   * @param {this} item\n   * @returns {this|false}\n   */\n  append(item) {\n    const list = this.list\n\n    if (!item || !item.append || !item.prepend || !item.detach) {\n      throw new Error(\n        'An argument without append, prepend, or detach methods was given to `Item#append`.'\n      )\n    }\n\n    // If self is detached or appending ourselves, return false.\n    if (!list || this === item) {\n      return false\n    }\n\n    // Detach the appendee.\n    item.detach()\n\n    // If self has a next item…\n    if (this.next) {\n      item.next = this.next\n      this.next.prev = item\n    }\n\n    // Connect the appendee.\n    item.prev = this\n    item.list = list\n\n    // Set the next item of self to the appendee.\n    this.next = item\n\n    // If the the parent list has no last item or if self is the parent lists last\n    // item, link the lists last item to the appendee.\n    if (this === list.tail || !list.tail) {\n      list.tail = item\n    }\n\n    list.size++\n\n    return item\n  }\n\n  /**\n   * Add the given item **before** the operated on item in a list.\n   *\n   * Throws an error when the given item has no `detach`, `append`, or `prepend`\n   * methods.\n   * Returns `false` when the operated on item is not attached to a list,\n   * otherwise the given item.\n   *\n   * @param {this} item\n   * @returns {this|false}\n   */\n  prepend(item) {\n    const list = this.list\n\n    if (!item || !item.append || !item.prepend || !item.detach) {\n      throw new Error(\n        'An argument without append, prepend, or detach methods was given to `Item#prepend`.'\n      )\n    }\n\n    // If self is detached or prepending ourselves, return false.\n    if (!list || this === item) {\n      return false\n    }\n\n    // Detach the prependee.\n    item.detach()\n\n    // If self has a previous item...\n    if (this.prev) {\n      item.prev = this.prev\n      this.prev.next = item\n    }\n\n    // Connect the prependee.\n    item.next = this\n    item.list = list\n\n    // Set the previous item of self to the prependee.\n    this.prev = item\n\n    // If self is the first item in the parent list, link the lists first item to\n    // the prependee.\n    if (this === list.head) {\n      list.head = item\n    }\n\n    // If the the parent list has no last item, link the lists last item to self.\n    if (!list.tail) {\n      list.tail = this\n    }\n\n    list.size++\n\n    return item\n  }\n\n  /**\n   * Remove the operated on item from its parent list.\n   *\n   * Removes references to it on its parent `list`, and `prev` and `next`\n   * items.\n   * Relinks all references.\n   * Returns the operated on item.\n   * Even when it was already detached.\n   *\n   * @returns {this}\n   */\n  detach() {\n    const list = this.list\n\n    if (!list) {\n      return this\n    }\n\n    // If self is the last item in the parent list, link the lists last item to\n    // the previous item.\n    if (list.tail === this) {\n      list.tail = this.prev\n    }\n\n    // If self is the first item in the parent list, link the lists first item to\n    // the next item.\n    if (list.head === this) {\n      list.head = this.next\n    }\n\n    // If both the last and first items in the parent list are the same, remove\n    // the link to the last item.\n    if (list.tail === list.head) {\n      list.tail = null\n    }\n\n    // If a previous item exists, link its next item to selfs next item.\n    if (this.prev) {\n      this.prev.next = this.next\n    }\n\n    // If a next item exists, link its previous item to selfs previous item.\n    if (this.next) {\n      this.next.prev = this.prev\n    }\n\n    // Remove links from self to both the next and previous items, and to the\n    // parent list.\n    this.prev = null\n    this.next = null\n    this.list = null\n\n    list.size--\n\n    return this\n  }\n}\n\n// type-coverage:ignore-next-line\nItem.prototype.next = null\n// type-coverage:ignore-next-line\nItem.prototype.prev = null\n// type-coverage:ignore-next-line\nItem.prototype.list = null\n\n/**\n * Double linked list.\n *\n * @template {Item} [T=Item]\n * @implements {Iterable<T>}\n */\nexport class List {\n  /**\n   * Create a new `this` from the given array of items.\n   *\n   * Ignores `null` or `undefined` values.\n   * Throws an error when a given item has no `detach`, `append`, or `prepend`\n   * methods.\n   *\n   * @template {Item} [T=Item]\n   * @param {Array<T|null|undefined>} [items]\n   */\n  static from(items) {\n    /** @type {List<T>} */\n    const list = new this()\n    return appendAll(list, items)\n  }\n\n  /**\n   * Create a new `this` from the given arguments.\n   *\n   * Ignores `null` or `undefined` values.\n   * Throws an error when a given item has no `detach`, `append`, or `prepend`\n   * methods.\n   *\n   * @template {Item} [T=Item]\n   * @param {Array<T|null|undefined>} items\n   * @returns {List<T>}\n   */\n  static of(...items) {\n    /** @type {List<T>} */\n    const list = new this()\n    return appendAll(list, items)\n  }\n\n  /**\n   * Create a new list from the given items.\n   *\n   * Ignores `null` or `undefined` values.\n   * Throws an error when a given item has no `detach`, `append`, or `prepend`\n   * methods.\n   *\n   * @param {Array<T|null|undefined>} items\n   */\n  constructor(...items) {\n    /* eslint-disable no-unused-expressions */\n    /**\n     * The number of items in the list.\n     *\n     * @type {number}\n     */\n    this.size\n\n    /**\n     * The first item in a list or `null` otherwise.\n     *\n     * @type {T|null}\n     */\n    this.head\n\n    /**\n     * The last item in a list and `null` otherwise.\n     *\n     * > 👉 **Note**: a list with only one item has **no tail**, only a head.\n     *\n     * @type {T|null}\n     */\n    this.tail\n    /* eslint-enable no-unused-expressions */\n\n    appendAll(this, items)\n  }\n\n  /**\n   * Append an item to a list.\n   *\n   * Throws an error when the given item has no `detach`, `append`, or `prepend`\n   * methods.\n   * Returns the given item.\n   *\n   * @param {T|null|undefined} [item]\n   * @returns {T|false}\n   */\n  append(item) {\n    if (!item) {\n      return false\n    }\n\n    if (!item.append || !item.prepend || !item.detach) {\n      throw new Error(\n        'An argument without append, prepend, or detach methods was given to `List#append`.'\n      )\n    }\n\n    // If self has a last item, defer appending to the last items append method,\n    // and return the result.\n    if (this.tail) {\n      return this.tail.append(item)\n    }\n\n    // If self has a first item, defer appending to the first items append method,\n    // and return the result.\n    if (this.head) {\n      return this.head.append(item)\n    }\n\n    // …otherwise, there is no `tail` or `head` item yet.\n    item.detach()\n    item.list = this\n    this.head = item\n    this.size++\n\n    return item\n  }\n\n  /**\n   * Prepend an item to a list.\n   *\n   * Throws an error when the given item has no `detach`, `append`, or `prepend`\n   * methods.\n   * Returns the given item.\n   *\n   * @param {T|null|undefined} [item]\n   * @returns {T|false}\n   */\n  prepend(item) {\n    if (!item) {\n      return false\n    }\n\n    if (!item.append || !item.prepend || !item.detach) {\n      throw new Error(\n        'An argument without append, prepend, or detach methods was given to `List#prepend`.'\n      )\n    }\n\n    if (this.head) {\n      return this.head.prepend(item)\n    }\n\n    item.detach()\n    item.list = this\n    this.head = item\n    this.size++\n\n    return item\n  }\n\n  /**\n   * Returns the items of the list as an array.\n   *\n   * This does *not* detach the items.\n   *\n   * > **Note**: `List` also implements an iterator.\n   * > That means you can also do `[...list]` to get an array.\n   */\n  toArray() {\n    let item = this.head\n    /** @type {Array<T>} */\n    const result = []\n\n    while (item) {\n      result.push(item)\n      item = item.next\n    }\n\n    return result\n  }\n\n  /**\n   * Creates an iterator from the list.\n   *\n   * @returns {ItemIterator<T>}\n   */\n  [Symbol.iterator]() {\n    return new ItemIterator(this.head)\n  }\n}\n\n// type-coverage:ignore-next-line\nList.prototype.size = 0\n// type-coverage:ignore-next-line\nList.prototype.tail = null\n// type-coverage:ignore-next-line\nList.prototype.head = null\n\n/**\n * Creates a new list from the items passed in.\n *\n * @template {List<T>} TheList\n * @template {Item} [T=Item]\n * @param {TheList} list\n * @param {Array<T|null|undefined>|undefined} [items]\n * @returns {TheList}\n */\nfunction appendAll(list, items) {\n  if (!items) {\n    return list\n  }\n\n  if (items[Symbol.iterator]) {\n    const iterator = items[Symbol.iterator]()\n    /** @type {IteratorResult<T|null|undefined, null>} */\n    let result\n\n    while ((result = iterator.next()) && !result.done) {\n      list.append(result.value)\n    }\n  } else {\n    let index = -1\n\n    while (++index < items.length) {\n      const item = items[index]\n      list.append(item)\n    }\n  }\n\n  return list\n}\n"]}