{"version":3,"sources":["jsdelivr-header.js","/npm/gc-hook@0.4.1/cjs/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,aAGA,MAAM,SAAW,IAAI,sBACnB,EAAE,EAAoB,EAAM,MAEtB,GAAO,QAAQ,MAAM,KAAK,OAAO,KAAS,mBAAoB,aAClE,EAAmB,EAAK,IAItB,YAAc,OAAO,OAAO,MAiB5B,OAAS,CACb,EACA,GACE,QAAO,UAAS,OAAQ,EAAG,QAAQ,GAAS,eAK9C,MAAM,EAAS,GAAK,IAAI,MAAM,EAAM,GAAW,aACzC,EAAO,CAAC,EAAQ,CAAC,EAAoB,IAAQ,IAKnD,OAJc,IAAV,GAAiB,EAAK,KAAK,GAG/B,SAAS,YAAY,GACd,CAAM,EAEf,QAAQ,OAAS,OAOjB,MAAM,KAAO,GAAS,SAAS,WAAW,GAC1C,QAAQ,KAAO","file":"/npm/gc-hook@0.4.1/cjs/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/gc-hook@0.4.1/cjs/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","'use strict';\n// (c) Andrea Giammarchi - ISC\n\nconst registry = new FinalizationRegistry(\n  ([onGarbageCollected, held, debug]) => {\n    // \"%cThis is a green text\", \"color:green\"\n    if (debug) console.debug(`%c${String(held)}`, 'font-weight:bold', 'collected');\n    onGarbageCollected(held);\n  }\n);\n\nconst nullHandler = Object.create(null);\n\n/**\n * @template {unknown} H\n * @typedef {Object} GCHookOptions\n * @prop {boolean} [debug=false] if `true`, logs values once these can get collected.\n * @prop {ProxyHandler<object>} [handler] optional proxy handler to use instead of the default one.\n * @prop {H} [return=H] if specified, overrides the returned proxy with its value.\n * @prop {unknown} [token=H] it's the held value by default, but it can be any other token except the returned value itself.\n */\n\n/**\n * @template {unknown} H\n * @param {H} hold the reference to hold behind the scene and passed along the callback once it triggers.\n * @param {(held:H) => void} onGarbageCollected the callback that will receive the held value once its wrapper or indirect reference is no longer needed.\n * @param {GCHookOptions<H>} [options] an optional configuration object to change some default behavior.\n */\nconst create = (\n  hold,\n  onGarbageCollected,\n  { debug, handler, return: r, token = hold } = nullHandler\n) => {\n  // if no reference to return is defined,\n  // create a proxy for the held one and register that instead.\n  /** @type {H} */\n  const target = r || new Proxy(hold, handler || nullHandler);\n  const args = [target, [onGarbageCollected, hold, !!debug]];\n  if (token !== false) args.push(token);\n  // register the target reference in a way that\n  // the `onGarbageCollected(held)` callback will eventually notify.\n  registry.register(...args);\n  return target;\n};\nexports.create = create;\n\n/**\n * If previously registered as either `token` or `hold` value, allow explicit removal of the entry in the registry.\n * @param {unknown} token the token used during registration. If no `token` was passed, this can be the same `hold` reference.\n * @returns {boolean} `true` if successfully unregistered.\n */\nconst drop = token => registry.unregister(token);\nexports.drop = drop;\n"]}