const ResourceLoader={};export default ResourceLoader;let _lastStreamId=0;const _boundStreams={};const _bindOutputStream=function(stream){_boundStreams[++_lastStreamId]=stream;return _lastStreamId;};const _discardOutputStream=function(id){_boundStreams[id].close();delete _boundStreams[id];};export const streamWrite=function(id,chunk){_boundStreams[id].write(chunk);};export function load(url,headers,callback){const stream=new Common.StringOutputStream();loadAsStream(url,headers,stream,mycallback);function mycallback(statusCode,headers){callback(statusCode,headers,stream.data());}} export const loadAsStream=function(url,headers,stream,callback){const streamId=_bindOutputStream(stream);const parsedURL=new Common.ParsedURL(url);if(parsedURL.isDataURL()){loadXHR(url).then(dataURLDecodeSuccessful).catch(dataURLDecodeFailed);return;} const rawHeaders=[];if(headers){for(const key in headers){rawHeaders.push(key+': '+headers[key]);}} Host.InspectorFrontendHost.loadNetworkResource(url,rawHeaders.join('\r\n'),streamId,finishedCallback);function finishedCallback(response){if(callback){callback(response.statusCode,response.headers||{});} _discardOutputStream(streamId);} function dataURLDecodeSuccessful(text){streamWrite(streamId,text);finishedCallback(({statusCode:200}));} function dataURLDecodeFailed(){finishedCallback(({statusCode:404}));}};self.Host=self.Host||{};Host=Host||{};Host.ResourceLoader=ResourceLoader;Host.ResourceLoader.streamWrite=streamWrite;Host.ResourceLoader.load=load;Host.ResourceLoader.loadAsStream=loadAsStream;