{
  "version": 3,
  "sources": ["../../../src/assets/dynamic-importmap/fetch.ts"],
  "sourcesContent": ["/**\n * This code is derived from the following projects:\n *\n * 1. dynamic-importmap (https://github.com/keller-mark/dynamic-importmap)\n * 2. es-module-shims (https://github.com/guybedford/es-module-shims)\n *\n * The original implementation was created by Guy Bedford in es-module-shims,\n * then adapted by Mark Keller in dynamic-importmap, and further modified\n * for use in this project.\n *\n * Both projects are licensed under the MIT license.\n *\n * MIT License: https://opensource.org/licenses/MIT\n */\n\n/**\n * Internal dependencies\n */\nimport { type ModuleLoad } from './loader';\n\nconst fetching = ( url: string, parent?: string ) => {\n\treturn ` fetching ${ url }${ parent ? ` from ${ parent }` : '' }`;\n};\n\nconst jsContentType = /^(text|application)\\/(x-)?javascript(;|$)/;\n\n/**\n * Fetches the passed module URL and return the corresponding `ModuleLoad`\n * instance. If the passed URL does not point to a JS file, the function\n * throws and error.\n *\n * @param url       Module URL.\n * @param fetchOpts Fetch init options.\n * @param parent    Parent module URL referencing this URL (if any).\n * @return Promise with a `ModuleLoad` instance.\n */\nexport async function fetchModule(\n\turl: string,\n\tfetchOpts: RequestInit,\n\tparent: string\n): Promise< ModuleLoad > {\n\tlet res: Response;\n\ttry {\n\t\tres = await fetch( url, fetchOpts );\n\t} catch {\n\t\tthrow Error( `Network error${ fetching( url, parent ) }.` );\n\t}\n\tif ( ! res.ok ) {\n\t\tthrow Error( `Error ${ res.status }${ fetching( url, parent ) }.` );\n\t}\n\tconst contentType = res.headers.get( 'content-type' );\n\tif ( ! jsContentType.test( contentType ) ) {\n\t\tthrow Error(\n\t\t\t`Bad Content-Type \"${ contentType }\"${ fetching( url, parent ) }.`\n\t\t);\n\t}\n\treturn { responseUrl: res.url, source: await res.text() };\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBA,IAAM,WAAW,CAAE,KAAa,WAAqB;AACpD,SAAO,aAAc,GAAI,GAAI,SAAS,SAAU,MAAO,KAAK,EAAG;AAChE;AAEA,IAAM,gBAAgB;AAYtB,eAAsB,YACrB,KACA,WACA,QACwB;AACxB,MAAI;AACJ,MAAI;AACH,UAAM,MAAM,MAAO,KAAK,SAAU;AAAA,EACnC,QAAQ;AACP,UAAM,MAAO,gBAAiB,SAAU,KAAK,MAAO,CAAE,GAAI;AAAA,EAC3D;AACA,MAAK,CAAE,IAAI,IAAK;AACf,UAAM,MAAO,SAAU,IAAI,MAAO,GAAI,SAAU,KAAK,MAAO,CAAE,GAAI;AAAA,EACnE;AACA,QAAM,cAAc,IAAI,QAAQ,IAAK,cAAe;AACpD,MAAK,CAAE,cAAc,KAAM,WAAY,GAAI;AAC1C,UAAM;AAAA,MACL,qBAAsB,WAAY,IAAK,SAAU,KAAK,MAAO,CAAE;AAAA,IAChE;AAAA,EACD;AACA,SAAO,EAAE,aAAa,IAAI,KAAK,QAAQ,MAAM,IAAI,KAAK,EAAE;AACzD;",
  "names": []
}
