const require_rolldown_runtime = require('../../../../../../../_virtual/rolldown_runtime.js');

//#region ../../node_modules/.pnpm/libphonenumber-js@1.11.3/node_modules/libphonenumber-js/build/findNumbers/LRUCache.js
var require_LRUCache = /* @__PURE__ */ require_rolldown_runtime.__commonJS({ "../../node_modules/.pnpm/libphonenumber-js@1.11.3/node_modules/libphonenumber-js/build/findNumbers/LRUCache.js": ((exports) => {
	Object.defineProperty(exports, "__esModule", { value: true });
	function _defineProperties(target, props) {
		for (var i = 0; i < props.length; i++) {
			var descriptor = props[i];
			descriptor.enumerable = descriptor.enumerable || false;
			descriptor.configurable = true;
			if ("value" in descriptor) descriptor.writable = true;
			Object.defineProperty(target, descriptor.key, descriptor);
		}
	}
	function _createClass(Constructor, protoProps, staticProps) {
		if (protoProps) _defineProperties(Constructor.prototype, protoProps);
		if (staticProps) _defineProperties(Constructor, staticProps);
		Object.defineProperty(Constructor, "prototype", { writable: false });
		return Constructor;
	}
	function _classCallCheck(instance, Constructor) {
		if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
	}
	var Node = /* @__PURE__ */ _createClass(function Node$1(key, value) {
		var next = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null;
		var prev = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null;
		_classCallCheck(this, Node$1);
		this.key = key;
		this.value = value;
		this.next = next;
		this.prev = prev;
	});
	var LRUCache = /* @__PURE__ */ function() {
		function LRUCache$1() {
			var limit = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 10;
			_classCallCheck(this, LRUCache$1);
			this.size = 0;
			this.limit = limit;
			this.head = null;
			this.tail = null;
			this.cache = {};
		}
		_createClass(LRUCache$1, [
			{
				key: "put",
				value: function put(key, value) {
					this.ensureLimit();
					if (!this.head) this.head = this.tail = new Node(key, value);
					else {
						var node = new Node(key, value, this.head);
						this.head.prev = node;
						this.head = node;
					}
					this.cache[key] = this.head;
					this.size++;
				}
			},
			{
				key: "get",
				value: function get(key) {
					if (this.cache[key]) {
						var value = this.cache[key].value;
						this.remove(key);
						this.put(key, value);
						return value;
					}
					console.log("Item not available in cache for key ".concat(key));
				}
			},
			{
				key: "ensureLimit",
				value: function ensureLimit() {
					if (this.size === this.limit) this.remove(this.tail.key);
				}
			},
			{
				key: "remove",
				value: function remove(key) {
					var node = this.cache[key];
					if (node.prev !== null) node.prev.next = node.next;
					else this.head = node.next;
					if (node.next !== null) node.next.prev = node.prev;
					else this.tail = node.prev;
					delete this.cache[key];
					this.size--;
				}
			},
			{
				key: "clear",
				value: function clear() {
					this.head = null;
					this.tail = null;
					this.size = 0;
					this.cache = {};
				}
			}
		]);
		return LRUCache$1;
	}();
	exports["default"] = LRUCache;
}) });

//#endregion
Object.defineProperty(exports, 'default', {
  enumerable: true,
  get: function () {
    return require_LRUCache();
  }
});