@react-native/debugger-frontend
Version:
Debugger frontend for React Native based on Chrome DevTools
1 lines • 89.8 kB
JavaScript
import*as e from"../../core/common/common.js";import*as t from"../../core/platform/platform.js";import{assertNotNullOrUndefined as o}from"../../core/platform/platform.js";import*as r from"../../core/sdk/sdk.js";import*as s from"../text_utils/text_utils.js";import*as i from"../workspace/workspace.js";import*as n from"../../core/i18n/i18n.js";const a={unknownErrorLoadingFile:"Unknown error loading file"},c=n.i18n.registerUIStrings("models/bindings/ContentProviderBasedProject.ts",a),u=n.i18n.getLocalizedString.bind(void 0,c);class d extends i.Workspace.ProjectStore{#e;#t;constructor(e,t,o,r,s){super(e,t,o,r),this.#e=s,this.#t=new WeakMap,e.addProject(this)}async requestFileContent(e){const{contentProvider:t}=this.#t.get(e);try{return await t.requestContentData()}catch(e){return{error:e?String(e):u(a.unknownErrorLoadingFile)}}}isServiceProject(){return this.#e}async requestMetadata(e){const{metadata:t}=this.#t.get(e);return t}canSetFileContent(){return!1}async setFileContent(e,t,o){}fullDisplayName(e){let t=e.parentURL().replace(/^(?:https?|file)\:\/\//,"");try{t=decodeURI(t)}catch{}return t+"/"+e.displayName(!0)}mimeType(e){const{mimeType:t}=this.#t.get(e);return t}canRename(){return!1}rename(e,t,o){const r=e.url();this.performRename(r,t,((t,r)=>{t&&r&&this.renameUISourceCode(e,r),o(t,r)}))}excludeFolder(e){}canExcludeFolder(e){return!1}async createFile(e,t,o,r){return null}canCreateFile(){return!1}deleteFile(e){}remove(){}performRename(e,t,o){o(!1)}searchInFileContent(e,t,o,r){const{contentProvider:s}=this.#t.get(e);return s.searchInContent(t,o,r)}async findFilesMatchingSearchRequest(e,o,r){const i=new Map;return r.setTotalWork(o.length),await Promise.all(o.map(async function(o){let n=!0,a=[];for(const r of e.queries().slice()){const i=await this.searchInFileContent(o,r,!e.ignoreCase(),e.isRegex());if(!i.length){n=!1;break}a=t.ArrayUtilities.mergeOrdered(a,i,s.ContentProvider.SearchMatch.comparator)}n&&i.set(o,a);r.incrementWorked(1)}.bind(this))),r.done(),i}indexContent(e){queueMicrotask(e.done.bind(e))}addUISourceCodeWithProvider(e,t,o,r){this.#t.set(e,{mimeType:r,metadata:o,contentProvider:t}),this.addUISourceCode(e)}addContentProvider(e,t,o){const r=this.createUISourceCode(e,t.contentType());return this.addUISourceCodeWithProvider(r,t,null,o),r}reset(){this.removeProject(),this.workspace().addProject(this)}dispose(){this.removeProject()}}var l=Object.freeze({__proto__:null,ContentProviderBasedProject:d});const g={removeFromIgnoreList:"Remove from ignore list",addScriptToIgnoreList:"Add script to ignore list",addDirectoryToIgnoreList:"Add directory to ignore list",addAllContentScriptsToIgnoreList:"Add all extension scripts to ignore list",addAllThirdPartyScriptsToIgnoreList:"Add all third-party scripts to ignore list",addAllAnonymousScriptsToIgnoreList:"Add all anonymous scripts to ignore list"},p=n.i18n.registerUIStrings("models/bindings/IgnoreListManager.ts",g),h=n.i18n.getLocalizedString.bind(void 0,p);let m;class S{#o;#r;#s;#i;constructor(t){this.#o=t,r.TargetManager.TargetManager.instance().addModelListener(r.DebuggerModel.DebuggerModel,r.DebuggerModel.Events.GlobalObjectCleared,this.clearCacheIfNeeded.bind(this),this),r.TargetManager.TargetManager.instance().addModelListener(r.RuntimeModel.RuntimeModel,r.RuntimeModel.Events.ExecutionContextCreated,this.onExecutionContextCreated,this,{scoped:!0}),r.TargetManager.TargetManager.instance().addModelListener(r.RuntimeModel.RuntimeModel,r.RuntimeModel.Events.ExecutionContextDestroyed,this.onExecutionContextDestroyed,this,{scoped:!0}),e.Settings.Settings.instance().moduleSetting("skip-stack-frames-pattern").addChangeListener(this.patternChanged.bind(this)),e.Settings.Settings.instance().moduleSetting("skip-content-scripts").addChangeListener(this.patternChanged.bind(this)),e.Settings.Settings.instance().moduleSetting("automatically-ignore-list-known-third-party-scripts").addChangeListener(this.patternChanged.bind(this)),e.Settings.Settings.instance().moduleSetting("enable-ignore-listing").addChangeListener(this.patternChanged.bind(this)),e.Settings.Settings.instance().moduleSetting("skip-anonymous-scripts").addChangeListener(this.patternChanged.bind(this)),this.#r=new Set,this.#s=new Map,this.#i=new Set,r.TargetManager.TargetManager.instance().observeModels(r.DebuggerModel.DebuggerModel,this)}static instance(e={forceNew:null,debuggerWorkspaceBinding:null}){const{forceNew:t,debuggerWorkspaceBinding:o}=e;if(!m||t){if(!o)throw new Error(`Unable to create settings: debuggerWorkspaceBinding must be provided: ${(new Error).stack}`);m=new S(o)}return m}static removeInstance(){m=void 0}addChangeListener(e){this.#r.add(e)}removeChangeListener(e){this.#r.delete(e)}modelAdded(e){this.setIgnoreListPatterns(e);const t=e.sourceMapManager();t.addEventListener(r.SourceMapManager.Events.SourceMapAttached,this.sourceMapAttached,this),t.addEventListener(r.SourceMapManager.Events.SourceMapDetached,this.sourceMapDetached,this)}modelRemoved(e){this.clearCacheIfNeeded();const t=e.sourceMapManager();t.removeEventListener(r.SourceMapManager.Events.SourceMapAttached,this.sourceMapAttached,this),t.removeEventListener(r.SourceMapManager.Events.SourceMapDetached,this.sourceMapDetached,this)}isContentScript(e){return!e.isDefault}onExecutionContextCreated(e){if(this.isContentScript(e.data)&&(this.#i.add(e.data.uniqueId),this.skipContentScripts))for(const e of r.TargetManager.TargetManager.instance().models(r.DebuggerModel.DebuggerModel))this.updateIgnoredExecutionContexts(e)}onExecutionContextDestroyed(e){if(this.isContentScript(e.data)&&(this.#i.delete(e.data.uniqueId),this.skipContentScripts))for(const e of r.TargetManager.TargetManager.instance().models(r.DebuggerModel.DebuggerModel))this.updateIgnoredExecutionContexts(e)}clearCacheIfNeeded(){this.#s.size>1024&&this.#s.clear()}getSkipStackFramesPatternSetting(){return e.Settings.Settings.instance().moduleSetting("skip-stack-frames-pattern")}setIgnoreListPatterns(e){const t=this.enableIgnoreListing?this.getSkipStackFramesPatternSetting().getAsArray():[],o=[];for(const e of t)!e.disabled&&e.pattern&&o.push(e.pattern);return e.setBlackboxPatterns(o,this.skipAnonymousScripts)}updateIgnoredExecutionContexts(e){return e.setBlackboxExecutionContexts(this.skipContentScripts?Array.from(this.#i):[])}getGeneralRulesForUISourceCode(e){return{isContentScript:e.project().type()===i.Workspace.projectTypes.ContentScripts,isKnownThirdParty:e.isKnownThirdParty()}}isUserOrSourceMapIgnoreListedUISourceCode(e){if(e.isUnconditionallyIgnoreListed())return!0;const t=this.uiSourceCodeURL(e);return this.isUserIgnoreListedURL(t,this.getGeneralRulesForUISourceCode(e))}isUserIgnoreListedURL(e,t){if(!this.enableIgnoreListing)return!1;if(t?.isContentScript&&this.skipContentScripts)return!0;if(t?.isKnownThirdParty&&this.automaticallyIgnoreListKnownThirdPartyScripts)return!0;if(!e)return this.skipAnonymousScripts;if(this.#s.has(e))return Boolean(this.#s.get(e));const o=null!==this.getFirstMatchedRegex(e);return this.#s.set(e,o),o}getFirstMatchedRegex(e){if(!e)return null;const t=this.getSkipStackFramesPatternSetting().getAsArray();if(!this.urlToRegExpString(e))return null;for(let o=0;o<t.length;++o){const r=t[o];if(r.disabled||r.disabledForUrl===e)continue;const s=new RegExp(r.pattern);if(s.test(e))return s}return null}sourceMapAttached(e){const t=e.data.client,o=e.data.sourceMap;this.updateScriptRanges(t,o)}sourceMapDetached(e){const t=e.data.client;this.updateScriptRanges(t,void 0)}async updateScriptRanges(e,t){let o=!1;if(S.instance().isUserIgnoreListedURL(e.sourceURL,{isContentScript:e.isContentScript()})||(o=t?.sourceURLs().some((e=>this.isUserIgnoreListedURL(e,{isKnownThirdParty:t.hasIgnoreListHint(e)})))??!1),!o)return L.get(e)&&await e.setBlackboxedRanges([])&&L.delete(e),void await this.#o.updateLocations(e);if(!t)return;const r=t.findRanges((e=>this.isUserIgnoreListedURL(e,{isKnownThirdParty:t.hasIgnoreListHint(e)})),{isStartMatching:!0}).flatMap((e=>[e.start,e.end]));!function(e,t){if(e.length!==t.length)return!1;for(let o=0;o<e.length;++o)if(e[o].lineNumber!==t[o].lineNumber||e[o].columnNumber!==t[o].columnNumber)return!1;return!0}(L.get(e)||[],r)&&await e.setBlackboxedRanges(r)&&L.set(e,r),this.#o.updateLocations(e)}uiSourceCodeURL(e){return e.project().type()===i.Workspace.projectTypes.Debugger?null:e.url()}canIgnoreListUISourceCode(e){const t=this.uiSourceCodeURL(e);return!!t&&Boolean(this.urlToRegExpString(t))}ignoreListUISourceCode(e){const t=this.uiSourceCodeURL(e);t&&this.ignoreListURL(t)}unIgnoreListUISourceCode(e){this.unIgnoreListURL(this.uiSourceCodeURL(e),this.getGeneralRulesForUISourceCode(e))}get enableIgnoreListing(){return e.Settings.Settings.instance().moduleSetting("enable-ignore-listing").get()}set enableIgnoreListing(t){e.Settings.Settings.instance().moduleSetting("enable-ignore-listing").set(t)}get skipContentScripts(){return this.enableIgnoreListing&&e.Settings.Settings.instance().moduleSetting("skip-content-scripts").get()}get skipAnonymousScripts(){return this.enableIgnoreListing&&e.Settings.Settings.instance().moduleSetting("skip-anonymous-scripts").get()}get automaticallyIgnoreListKnownThirdPartyScripts(){return this.enableIgnoreListing&&e.Settings.Settings.instance().moduleSetting("automatically-ignore-list-known-third-party-scripts").get()}ignoreListContentScripts(){this.enableIgnoreListing||(this.enableIgnoreListing=!0),e.Settings.Settings.instance().moduleSetting("skip-content-scripts").set(!0)}unIgnoreListContentScripts(){e.Settings.Settings.instance().moduleSetting("skip-content-scripts").set(!1)}ignoreListAnonymousScripts(){this.enableIgnoreListing||(this.enableIgnoreListing=!0),e.Settings.Settings.instance().moduleSetting("skip-anonymous-scripts").set(!0)}unIgnoreListAnonymousScripts(){e.Settings.Settings.instance().moduleSetting("skip-anonymous-scripts").set(!1)}ignoreListThirdParty(){this.enableIgnoreListing||(this.enableIgnoreListing=!0),e.Settings.Settings.instance().moduleSetting("automatically-ignore-list-known-third-party-scripts").set(!0)}unIgnoreListThirdParty(){e.Settings.Settings.instance().moduleSetting("automatically-ignore-list-known-third-party-scripts").set(!1)}ignoreListURL(e){const t=this.urlToRegExpString(e);t&&this.addRegexToIgnoreList(t,e)}addRegexToIgnoreList(e,t){const o=this.getSkipStackFramesPatternSetting().getAsArray();let r=!1;for(let s=0;s<o.length;++s){const i=o[s];(i.pattern===e||t&&i.disabledForUrl===t)&&(i.disabled=!1,i.disabledForUrl=void 0,r=!0)}r||o.push({pattern:e,disabled:!1}),this.enableIgnoreListing||(this.enableIgnoreListing=!0),this.getSkipStackFramesPatternSetting().setAsArray(o)}unIgnoreListURL(e,t){if(t?.isContentScript&&this.unIgnoreListContentScripts(),t?.isKnownThirdParty&&this.unIgnoreListThirdParty(),!e)return void this.unIgnoreListAnonymousScripts();let o=this.getSkipStackFramesPatternSetting().getAsArray();const r=S.instance().urlToRegExpString(e);if(r){o=o.filter((function(e){return e.pattern!==r}));for(let t=0;t<o.length;++t){const r=o[t];if(!r.disabled)try{new RegExp(r.pattern).test(e)&&(r.disabled=!0,r.disabledForUrl=e)}catch{}}this.getSkipStackFramesPatternSetting().setAsArray(o)}}removeIgnoreListPattern(e){let t=this.getSkipStackFramesPatternSetting().getAsArray();t=t.filter((function(t){return t.pattern!==e})),this.getSkipStackFramesPatternSetting().setAsArray(t)}ignoreListHasPattern(e,t){return this.getSkipStackFramesPatternSetting().getAsArray().some((o=>!(t&&o.disabled)&&o.pattern===e))}async patternChanged(){this.#s.clear();const e=[];for(const t of r.TargetManager.TargetManager.instance().models(r.DebuggerModel.DebuggerModel)){e.push(this.setIgnoreListPatterns(t));const o=t.sourceMapManager();for(const r of t.scripts())e.push(this.updateScriptRanges(r,o.sourceMapForClient(r)));e.push(this.updateIgnoredExecutionContexts(t))}await Promise.all(e);const t=Array.from(this.#r);for(const e of t)e();this.patternChangeFinishedForTests()}patternChangeFinishedForTests(){}urlToRegExpString(o){const r=new e.ParsedURL.ParsedURL(o);if(r.isAboutBlank()||r.isDataURL())return"";if(!r.isValid)return"^"+t.StringUtilities.escapeForRegExp(o)+"$";let s=r.lastPathComponent;if(s?s="/"+s:r.folderPathComponents&&(s=r.folderPathComponents+"/"),s||(s=r.host),!s)return"";const i=r.scheme;let n="";return i&&"http"!==i&&"https"!==i&&(n="^"+i+"://","chrome-extension"===i&&(n+=r.host+"\\b"),n+=".*"),n+t.StringUtilities.escapeForRegExp(s)+(o.endsWith(s)?"$":"\\b")}getIgnoreListURLContextMenuItems(e){if(e.project().type()===i.Workspace.projectTypes.FileSystem)return[];const t=[],o=this.canIgnoreListUISourceCode(e),r=this.isUserOrSourceMapIgnoreListedUISourceCode(e),s=!this.uiSourceCodeURL(e),{isContentScript:n,isKnownThirdParty:a}=this.getGeneralRulesForUISourceCode(e);return r?(o||n||a||s)&&t.push({text:h(g.removeFromIgnoreList),callback:this.unIgnoreListUISourceCode.bind(this,e),jslogContext:"remove-script-from-ignorelist"}):(o?t.push({text:h(g.addScriptToIgnoreList),callback:this.ignoreListUISourceCode.bind(this,e),jslogContext:"add-script-to-ignorelist"}):s&&t.push({text:h(g.addAllAnonymousScriptsToIgnoreList),callback:this.ignoreListAnonymousScripts.bind(this),jslogContext:"add-anonymous-scripts-to-ignorelist"}),t.push(...this.getIgnoreListGeneralContextMenuItems({isContentScript:n,isKnownThirdParty:a}))),t}getIgnoreListGeneralContextMenuItems(e){const t=[];return e?.isContentScript&&t.push({text:h(g.addAllContentScriptsToIgnoreList),callback:this.ignoreListContentScripts.bind(this),jslogContext:"add-content-scripts-to-ignorelist"}),e?.isKnownThirdParty&&t.push({text:h(g.addAllThirdPartyScriptsToIgnoreList),callback:this.ignoreListThirdParty.bind(this),jslogContext:"add-3p-scripts-to-ignorelist"}),t}getIgnoreListFolderContextMenuItems(e,o){const r=[],s="^"+t.StringUtilities.escapeForRegExp(e)+"/";return this.ignoreListHasPattern(s,!0)?r.push({text:h(g.removeFromIgnoreList),callback:this.removeIgnoreListPattern.bind(this,s),jslogContext:"remove-from-ignore-list"}):this.isUserIgnoreListedURL(e,o)?r.push({text:h(g.removeFromIgnoreList),callback:this.unIgnoreListURL.bind(this,e,o),jslogContext:"remove-from-ignore-list"}):o?.isCurrentlyIgnoreListed||(r.push({text:h(g.addDirectoryToIgnoreList),callback:this.addRegexToIgnoreList.bind(this,s),jslogContext:"add-directory-to-ignore-list"}),r.push(...this.getIgnoreListGeneralContextMenuItems(o))),r}}const L=new WeakMap;var M=Object.freeze({__proto__:null,IgnoreListManager:S});const f=new WeakMap,b=new WeakMap;let C;class w extends e.ObjectWrapper.ObjectWrapper{constructor(){super()}static instance({forceNew:e}={forceNew:!1}){return C&&!e||(C=new w),C}}class I{static resolveFrame(e,t){const o=I.targetForUISourceCode(e),s=o?.model(r.ResourceTreeModel.ResourceTreeModel);return s?s.frameForId(t):null}static setInitialFrameAttribution(e,t){if(!t)return;const o=I.resolveFrame(e,t);if(!o)return;const r=new Map;r.set(t,{frame:o,count:1}),f.set(e,r)}static cloneInitialFrameAttribution(e,t){const o=f.get(e);if(!o)return;const r=new Map;for(const e of o.keys()){const t=o.get(e);void 0!==t&&r.set(e,{frame:t.frame,count:t.count})}f.set(t,r)}static addFrameAttribution(e,t){const o=I.resolveFrame(e,t);if(!o)return;const r=f.get(e);if(!r)return;const s=r.get(t)||{frame:o,count:0};if(s.count+=1,r.set(t,s),1!==s.count)return;const i={uiSourceCode:e,frame:o};w.instance().dispatchEventToListeners("FrameAttributionAdded",i)}static removeFrameAttribution(e,t){const o=f.get(e);if(!o)return;const r=o.get(t);if(console.assert(Boolean(r),"Failed to remove frame attribution for url: "+e.url()),!r)return;if(r.count-=1,r.count>0)return;o.delete(t);const s={uiSourceCode:e,frame:r.frame};w.instance().dispatchEventToListeners("FrameAttributionRemoved",s)}static targetForUISourceCode(e){return b.get(e.project())||null}static setTargetForProject(e,t){b.set(e,t)}static getTargetForProject(e){return b.get(e)||null}static framesForUISourceCode(e){const t=I.targetForUISourceCode(e),o=t?.model(r.ResourceTreeModel.ResourceTreeModel),s=f.get(e);if(!o||!s)return[];return Array.from(s.keys()).map((e=>o.frameForId(e))).filter((e=>!!e))}}var v=Object.freeze({__proto__:null,NetworkProject:I,NetworkProjectManager:w});class y{#n;#o;#a=new Map;#c;#u;#d=new Map;#l=new Map;#g=new t.MapUtilities.Multimap;constructor(e,t,o){this.#n=e.sourceMapManager(),this.#o=o,this.#c=new d(t,"jsSourceMaps:stub:"+e.target().id(),i.Workspace.projectTypes.Service,"",!0),this.#u=[this.#n.addEventListener(r.SourceMapManager.Events.SourceMapWillAttach,this.sourceMapWillAttach,this),this.#n.addEventListener(r.SourceMapManager.Events.SourceMapFailedToAttach,this.sourceMapFailedToAttach,this),this.#n.addEventListener(r.SourceMapManager.Events.SourceMapAttached,this.sourceMapAttached,this),this.#n.addEventListener(r.SourceMapManager.Events.SourceMapDetached,this.sourceMapDetached,this)]}setFunctionRanges(e,t){for(const o of this.#g.get(e))o.augmentWithScopes(e.url(),t)}addStubUISourceCode(t){const o=this.#c.addContentProvider(e.ParsedURL.ParsedURL.concatenate(t.sourceURL,":sourcemap"),s.StaticContentProvider.StaticContentProvider.fromString(t.sourceURL,e.ResourceType.resourceTypes.Script,"\n\n\n\n\n// Please wait a bit.\n// Compiled script is not shown while source map is being loaded!"),"text/javascript");this.#a.set(t,o)}removeStubUISourceCode(e){const t=this.#a.get(e);this.#a.delete(e),t&&this.#c.removeUISourceCode(t.url())}getLocationRangesForSameSourceLocation(e){const t=e.debuggerModel,o=e.script();if(!o)return[];const r=this.#n.sourceMapForClient(o);if(!r)return[];const{lineNumber:s,columnNumber:i}=o.rawLocationToRelativeLocation(e),n=r.findEntry(s,i);if(!n||!n.sourceURL)return[];const a=this.#l.get(r);if(!a)return[];const c=a.uiSourceCodeForURL(n.sourceURL);if(!c)return[];if(!this.#g.hasValue(c,r))return[];return r.findReverseRanges(n.sourceURL,n.sourceLineNumber,n.sourceColumnNumber).map((({startLine:e,startColumn:r,endLine:s,endColumn:i})=>{const n=o.relativeLocationToRawLocation({lineNumber:e,columnNumber:r}),a=o.relativeLocationToRawLocation({lineNumber:s,columnNumber:i});return{start:t.createRawLocation(o,n.lineNumber,n.columnNumber),end:t.createRawLocation(o,a.lineNumber,a.columnNumber)}}))}uiSourceCodeForURL(e,t){const o=t?i.Workspace.projectTypes.ContentScripts:i.Workspace.projectTypes.Network;for(const t of this.#d.values()){if(t.type()!==o)continue;const r=t.uiSourceCodeForURL(e);if(r)return r}return null}rawLocationToUILocation(e){const t=e.script();if(!t)return null;const{lineNumber:o,columnNumber:r}=t.rawLocationToRelativeLocation(e),s=this.#a.get(t);if(s)return new i.UISourceCode.UILocation(s,o,r);const n=this.#n.sourceMapForClient(t);if(!n)return null;const a=this.#l.get(n);if(!a)return null;const c=n.findEntry(o,r,e.inlineFrameIndex);if(!c||!c.sourceURL)return null;const u=a.uiSourceCodeForURL(c.sourceURL);return u&&this.#g.hasValue(u,n)?u.uiLocation(c.sourceLineNumber,c.sourceColumnNumber):null}uiLocationToRawLocations(e,t,o){const r=[];for(const s of this.#g.get(e)){const i=s.sourceLineMapping(e.url(),t,o);if(!i)continue;const n=this.#n.clientForSourceMap(s);if(!n)continue;const a=n.relativeLocationToRawLocation(i);r.push(n.debuggerModel.createRawLocation(n,a.lineNumber,a.columnNumber))}return r}uiLocationRangeToRawLocationRanges(e,t){if(!this.#g.has(e))return null;const o=[];for(const r of this.#g.get(e)){const s=this.#n.clientForSourceMap(r);if(s)for(const i of r.reverseMapTextRanges(e.url(),t)){const e=s.relativeLocationToRawLocation(i.start),t=s.relativeLocationToRawLocation(i.end),r=s.debuggerModel.createRawLocation(s,e.lineNumber,e.columnNumber),n=s.debuggerModel.createRawLocation(s,t.lineNumber,t.columnNumber);o.push({start:r,end:n})}}return o}getMappedLines(e){if(!this.#g.has(e))return null;const t=new Set;for(const o of this.#g.get(e))for(const r of o.mappings())r.sourceURL===e.url()&&t.add(r.sourceLineNumber);return t}sourceMapWillAttach(e){const{client:t}=e.data;this.addStubUISourceCode(t),this.#o.updateLocations(t),S.instance().isUserIgnoreListedURL(t.sourceURL,{isContentScript:t.isContentScript()})&&this.#n.cancelAttachSourceMap(t)}sourceMapFailedToAttach(e){const{client:t}=e.data;this.removeStubUISourceCode(t),this.#o.updateLocations(t)}sourceMapAttached(t){const{client:o,sourceMap:n}=t.data,a=new Set([o]);this.removeStubUISourceCode(o);const c=o.target(),u=`jsSourceMaps:${o.isContentScript()?"extensions":""}:${c.id()}`;let l=this.#d.get(u);if(!l){const e=o.isContentScript()?i.Workspace.projectTypes.ContentScripts:i.Workspace.projectTypes.Network;l=new d(this.#c.workspace(),u,e,"",!1),I.setTargetForProject(l,c),this.#d.set(u,l)}this.#l.set(n,l);for(const t of n.sourceURLs()){const c=e.ResourceType.resourceTypes.SourceMapScript,u=l.createUISourceCode(t,c);n.hasIgnoreListHint(t)&&u.markKnownThirdParty();const d=n.embeddedContentByURL(t),g=null!==d?s.StaticContentProvider.StaticContentProvider.fromString(t,c,d):new r.CompilerSourceMappingContentProvider.CompilerSourceMappingContentProvider(t,c,o.createPageResourceLoadInitiator());let p=null;if(null!==d){const e=new TextEncoder;p=new i.UISourceCode.UISourceCodeMetadata(null,e.encode(d).length)}const h=e.ResourceType.ResourceType.mimeFromURL(t)??c.canonicalMimeType();this.#g.set(u,n),I.setInitialFrameAttribution(u,o.frameId);const m=l.uiSourceCodeForURL(t);if(null!==m){for(const e of this.#g.get(m)){this.#g.delete(m,e);const o=this.#n.clientForSourceMap(e);o&&(I.removeFrameAttribution(m,o.frameId),n.compatibleForURL(t,e)&&(this.#g.set(u,e),I.addFrameAttribution(u,o.frameId)),a.add(o))}l.removeUISourceCode(t)}l.addUISourceCodeWithProvider(u,g,p,h)}Promise.all([...a].map((e=>this.#o.updateLocations(e)))).then((()=>this.sourceMapAttachedForTest(n)))}sourceMapDetached(e){const{client:t,sourceMap:o}=e.data,r=this.#l.get(o);if(r){for(const e of r.uiSourceCodes())this.#g.delete(e,o)&&(I.removeFrameAttribution(e,t.frameId),this.#g.has(e)||r.removeUISourceCode(e.url()));this.#l.delete(o),this.#o.updateLocations(t)}}scriptsForUISourceCode(e){const t=[];for(const o of this.#g.get(e)){const e=this.#n.clientForSourceMap(o);e&&t.push(e)}return t}sourceMapAttachedForTest(e){}dispose(){e.EventTarget.removeEventListeners(this.#u);for(const e of this.#d.values())e.dispose();this.#c.dispose()}}var T=Object.freeze({__proto__:null,CompilerScriptMapping:y});class R{#p;#h;#m;constructor(e,t){this.#p=e,this.#h=t,this.#h.add(this),this.#m=null}async update(){this.#p&&(this.#m?await this.#m.then((()=>this.update())):(this.#m=this.#p(this),await this.#m,this.#m=null))}async uiLocation(){throw new Error("Not implemented")}dispose(){this.#h.delete(this),this.#p=null}isDisposed(){return!this.#h.has(this)}async isIgnoreListed(){throw new Error("Not implemented")}}class F{#S;constructor(){this.#S=new Set}add(e){this.#S.add(e)}delete(e){this.#S.delete(e)}has(e){return this.#S.has(e)}disposeAll(){for(const e of this.#S)e.dispose()}}var U=Object.freeze({__proto__:null,LiveLocationPool:F,LiveLocationWithPool:R});class P{#n;#L;#u;#M;constructor(e,t,o){this.#n=t,this.#L=new d(o,"cssSourceMaps:"+e.id(),i.Workspace.projectTypes.Network,"",!1),I.setTargetForProject(this.#L,e),this.#M=new Map,this.#u=[this.#n.addEventListener(r.SourceMapManager.Events.SourceMapAttached,this.sourceMapAttached,this),this.#n.addEventListener(r.SourceMapManager.Events.SourceMapDetached,this.sourceMapDetached,this)]}sourceMapAttachedForTest(e){}async sourceMapAttached(e){const t=e.data.client,o=e.data.sourceMap,r=this.#L,s=this.#M;for(const e of o.sourceURLs()){let i=s.get(e);i||(i=new j(r,e,t.createPageResourceLoadInitiator()),s.set(e,i)),i.addSourceMap(o,t.frameId)}await z.instance().updateLocations(t),this.sourceMapAttachedForTest(o)}async sourceMapDetached(e){const t=e.data.client,o=e.data.sourceMap,r=this.#M;for(const e of o.sourceURLs()){const s=r.get(e);s&&(s.removeSourceMap(o,t.frameId),s.getUiSourceCode()||r.delete(e))}await z.instance().updateLocations(t)}rawLocationToUILocation(e){const t=e.header();if(!t)return null;const o=this.#n.sourceMapForClient(t);if(!o)return null;let{lineNumber:r,columnNumber:s}=e;o.mapsOrigin()&&t.isInline&&(r-=t.startLine,0===r&&(s-=t.startColumn));const i=o.findEntry(r,s);if(!i||!i.sourceURL)return null;const n=this.#L.uiSourceCodeForURL(i.sourceURL);return n?n.uiLocation(i.sourceLineNumber,i.sourceColumnNumber):null}uiLocationToRawLocations(e){const{uiSourceCode:t,lineNumber:o,columnNumber:s=0}=e,i=k.get(t);if(!i)return[];const n=[];for(const e of i.getReferringSourceMaps()){const i=e.findReverseEntries(t.url(),o,s),a=this.#n.clientForSourceMap(e);a&&n.push(...i.map((e=>new r.CSSModel.CSSLocation(a,e.lineNumber,e.columnNumber))))}return n}static uiSourceOrigin(e){const t=k.get(e);return t?t.getReferringSourceMaps().map((e=>e.compiledURL())):[]}dispose(){e.EventTarget.removeEventListeners(this.#u),this.#L.dispose()}}const k=new WeakMap;let j=class{#L;#f;#b;referringSourceMaps;uiSourceCode;constructor(e,t,o){this.#L=e,this.#f=t,this.#b=o,this.referringSourceMaps=[],this.uiSourceCode=null}recreateUISourceCodeIfNeeded(t){const o=this.referringSourceMaps[this.referringSourceMaps.length-1],n=e.ResourceType.resourceTypes.SourceMapStyleSheet,a=o.embeddedContentByURL(this.#f),c=null!==a?s.StaticContentProvider.StaticContentProvider.fromString(this.#f,n,a):new r.CompilerSourceMappingContentProvider.CompilerSourceMappingContentProvider(this.#f,n,this.#b),u=this.#L.createUISourceCode(this.#f,n);k.set(u,this);const d=e.ResourceType.ResourceType.mimeFromURL(this.#f)||n.canonicalMimeType(),l="string"==typeof a?new i.UISourceCode.UISourceCodeMetadata(null,a.length):null;this.uiSourceCode?(I.cloneInitialFrameAttribution(this.uiSourceCode,u),this.#L.removeUISourceCode(this.uiSourceCode.url())):I.setInitialFrameAttribution(u,t),this.uiSourceCode=u,this.#L.addUISourceCodeWithProvider(this.uiSourceCode,c,l,d)}addSourceMap(e,t){this.uiSourceCode&&I.addFrameAttribution(this.uiSourceCode,t),this.referringSourceMaps.push(e),this.recreateUISourceCodeIfNeeded(t)}removeSourceMap(e,t){const o=this.uiSourceCode;I.removeFrameAttribution(o,t);const r=this.referringSourceMaps.lastIndexOf(e);-1!==r&&this.referringSourceMaps.splice(r,1),this.referringSourceMaps.length?this.recreateUISourceCodeIfNeeded(t):(this.#L.removeUISourceCode(o.url()),this.uiSourceCode=null)}getReferringSourceMaps(){return this.referringSourceMaps}getUiSourceCode(){return this.uiSourceCode}};var D=Object.freeze({__proto__:null,SASSSourceMapping:P});function E(e){return r.ResourceTreeModel.ResourceTreeModel.resourceForURL(e)}function x(e,t,o){const s=e.model(r.ResourceTreeModel.ResourceTreeModel);if(!s)return null;const i=s.frameForId(t);return i?N(i.resourceForURL(o)):null}function N(e){return!e||"number"!=typeof e.contentSize()&&!e.lastModified()?null:new i.UISourceCode.UISourceCodeMetadata(e.lastModified(),e.contentSize())}var A=Object.freeze({__proto__:null,displayNameForURL:function(o){if(!o)return"";const s=E(o);if(s)return s.displayName;const n=i.Workspace.WorkspaceImpl.instance().uiSourceCodeForURL(o);if(n)return n.displayName();const a=r.TargetManager.TargetManager.instance().inspectedURL();if(!a)return t.StringUtilities.trimURL(o,"");const c=e.ParsedURL.ParsedURL.fromString(a);if(!c)return o;const u=c.lastPathComponent,d=a.indexOf(u);if(-1!==d&&d+u.length===a.length){const e=a.substring(0,d);if(o.startsWith(e)&&o.length>d)return o.substring(d)}const l=t.StringUtilities.trimURL(o,c.host);return"/"===l?c.host+"/":l},metadataForURL:x,resourceForURL:E,resourceMetadata:N});const O=new WeakMap;class W{#C;#w;#I;#v;#u;constructor(e,t){this.#C=e;const o=this.#C.target();this.#w=new d(t,"css:"+o.id(),i.Workspace.projectTypes.Network,"",!1),I.setTargetForProject(this.#w,o),this.#I=new d(t,"inspector:"+o.id(),i.Workspace.projectTypes.Inspector,"",!0),this.#v=new Map,this.#u=[this.#C.addEventListener(r.CSSModel.Events.StyleSheetAdded,this.styleSheetAdded,this),this.#C.addEventListener(r.CSSModel.Events.StyleSheetRemoved,this.styleSheetRemoved,this),this.#C.addEventListener(r.CSSModel.Events.StyleSheetChanged,this.styleSheetChanged,this)]}addSourceMap(e,t){this.#v.get(e)?.addSourceMap(e,t)}rawLocationToUILocation(e){const t=e.header();if(!t||!this.acceptsHeader(t))return null;const o=this.#v.get(t.resourceURL());if(!o)return null;let r=e.lineNumber,s=e.columnNumber;if(t.isInline&&t.hasSourceURL){r-=t.lineNumberInSource(0);const e=t.columnNumberInSource(r,0);void 0===e?s=e:s-=e}return o.getUiSourceCode().uiLocation(r,s)}uiLocationToRawLocations(e){const t=O.get(e.uiSourceCode);if(!t)return[];const o=[];for(const s of t.getHeaders()){let t=e.lineNumber,i=e.columnNumber;s.isInline&&s.hasSourceURL&&(i=s.columnNumberInSource(t,e.columnNumber||0),t=s.lineNumberInSource(t)),o.push(new r.CSSModel.CSSLocation(s,t,i))}return o}acceptsHeader(e){return!e.isConstructedByNew()&&(!(e.isInline&&!e.hasSourceURL&&"inspector"!==e.origin)&&!!e.resourceURL())}styleSheetAdded(e){const t=e.data;if(!this.acceptsHeader(t))return;const o=t.resourceURL();let r=this.#v.get(o);if(r)r.addHeader(t);else{const e=t.isViaInspector()?this.#I:this.#w;r=new B(this.#C,e,t),this.#v.set(o,r)}}styleSheetRemoved(e){const t=e.data;if(!this.acceptsHeader(t))return;const o=t.resourceURL(),r=this.#v.get(o);r&&(1===r.getHeaders().size?(r.dispose(),this.#v.delete(o)):r.removeHeader(t))}styleSheetChanged(e){const t=this.#C.styleSheetHeaderForId(e.data.styleSheetId);if(!t||!this.acceptsHeader(t))return;const o=this.#v.get(t.resourceURL());o&&o.styleSheetChanged(t)}dispose(){for(const e of this.#v.values())e.dispose();this.#v.clear(),e.EventTarget.removeEventListeners(this.#u),this.#I.removeProject(),this.#w.removeProject()}}class B{#C;#L;headers;uiSourceCode;#u;#y;#T;#R;#F;constructor(t,o,r){this.#C=t,this.#L=o,this.headers=new Set([r]);const s=t.target(),n=r.resourceURL(),a=x(s,r.frameId,n);this.uiSourceCode=this.#L.createUISourceCode(n,r.contentType()),O.set(this.uiSourceCode,this),I.setInitialFrameAttribution(this.uiSourceCode,r.frameId),this.#L.addUISourceCodeWithProvider(this.uiSourceCode,this,a,"text/css"),this.#u=[this.uiSourceCode.addEventListener(i.UISourceCode.Events.WorkingCopyChanged,this.workingCopyChanged,this),this.uiSourceCode.addEventListener(i.UISourceCode.Events.WorkingCopyCommitted,this.workingCopyCommitted,this)],this.#y=new e.Throttler.Throttler(B.updateTimeout),this.#T=!1}addHeader(e){this.headers.add(e),I.addFrameAttribution(this.uiSourceCode,e.frameId)}removeHeader(e){this.headers.delete(e),I.removeFrameAttribution(this.uiSourceCode,e.frameId)}styleSheetChanged(e){if(console.assert(this.headers.has(e)),this.#F||!this.headers.has(e))return;const t=this.mirrorContent.bind(this,e,!0);this.#y.schedule(t,"Default")}workingCopyCommitted(){if(this.#R)return;const e=this.mirrorContent.bind(this,this.uiSourceCode,!0);this.#y.schedule(e,"AsSoonAsPossible")}workingCopyChanged(){if(this.#R)return;const e=this.mirrorContent.bind(this,this.uiSourceCode,!1);this.#y.schedule(e,"Default")}async mirrorContent(e,t){if(this.#T)return void this.styleFileSyncedForTest();let o=null;if(o=e===this.uiSourceCode?this.uiSourceCode.workingCopy():s.ContentData.ContentData.textOr(await e.requestContentData(),null),null===o||this.#T)return void this.styleFileSyncedForTest();e!==this.uiSourceCode&&(this.#R=!0,this.uiSourceCode.setWorkingCopy(o),this.#R=!1),this.#F=!0;const r=[];for(const s of this.headers)s!==e&&r.push(this.#C.setStyleSheetText(s.id,o,t));await Promise.all(r),this.#F=!1,this.styleFileSyncedForTest()}styleFileSyncedForTest(){}dispose(){this.#T||(this.#T=!0,this.#L.removeUISourceCode(this.uiSourceCode.url()),e.EventTarget.removeEventListeners(this.#u))}contentURL(){return console.assert(this.headers.size>0),this.#U().originalContentProvider().contentURL()}contentType(){return console.assert(this.headers.size>0),this.#U().originalContentProvider().contentType()}requestContent(){return console.assert(this.headers.size>0),this.#U().originalContentProvider().requestContent()}requestContentData(){return console.assert(this.headers.size>0),this.#U().originalContentProvider().requestContentData()}searchInContent(e,t,o){return console.assert(this.headers.size>0),this.#U().originalContentProvider().searchInContent(e,t,o)}#U(){return console.assert(this.headers.size>0),this.headers.values().next().value}static updateTimeout=200;getHeaders(){return this.headers}getUiSourceCode(){return this.uiSourceCode}addSourceMap(e,t){const o=this.#C.sourceMapManager();this.headers.forEach((r=>{o.detachSourceMap(r),o.attachSourceMap(r,e,t)}))}}var H=Object.freeze({__proto__:null,StyleFile:B,StylesSourceMapping:W});let _;class z{#P;#k;#j;constructor(e,t){this.#P=e,this.#k=new Map,t.observeModels(r.CSSModel.CSSModel,this),this.#j=new Set}static instance(e={forceNew:null,resourceMapping:null,targetManager:null}){const{forceNew:t,resourceMapping:o,targetManager:r}=e;if(!_||t){if(!o||!r)throw new Error(`Unable to create CSSWorkspaceBinding: resourceMapping and targetManager must be provided: ${(new Error).stack}`);_=new z(o,r)}return _}static removeInstance(){_=void 0}get modelToInfo(){return this.#k}getCSSModelInfo(e){return this.#k.get(e)}modelAdded(e){this.#k.set(e,new V(e,this.#P))}modelRemoved(e){this.getCSSModelInfo(e).dispose(),this.#k.delete(e)}async pendingLiveLocationChangesPromise(){await Promise.all(this.#j)}recordLiveLocationChange(e){e.then((()=>{this.#j.delete(e)})),this.#j.add(e)}async updateLocations(e){const t=this.getCSSModelInfo(e.cssModel()).updateLocations(e);this.recordLiveLocationChange(t),await t}createLiveLocation(e,t,o){const r=this.getCSSModelInfo(e.cssModel()).createLiveLocation(e,t,o);return this.recordLiveLocationChange(r),r}propertyRawLocation(e,t){const o=e.ownerStyle;if(!o||o.type!==r.CSSStyleDeclaration.Type.Regular||!o.styleSheetId)return null;const s=o.cssModel().styleSheetHeaderForId(o.styleSheetId);if(!s)return null;const i=t?e.nameRange():e.valueRange();if(!i)return null;const n=i.startLine,a=i.startColumn;return new r.CSSModel.CSSLocation(s,s.lineNumberInSource(n),s.columnNumberInSource(n,a))}propertyUILocation(e,t){const o=this.propertyRawLocation(e,t);return o?this.rawLocationToUILocation(o):null}rawLocationToUILocation(e){return this.getCSSModelInfo(e.cssModel()).rawLocationToUILocation(e)}uiLocationToRawLocations(e){const t=[];for(const o of this.#k.values())t.push(...o.uiLocationToRawLocations(e));return t}}let V=class{#u;#P;#D;#E;#S;#x;constructor(e,o){this.#u=[e.addEventListener(r.CSSModel.Events.StyleSheetAdded,(e=>{this.styleSheetAdded(e)}),this),e.addEventListener(r.CSSModel.Events.StyleSheetRemoved,(e=>{this.styleSheetRemoved(e)}),this)],this.#P=o,this.#D=new W(e,o.workspace);const s=e.sourceMapManager();this.#E=new P(e.target(),s,o.workspace),this.#S=new t.MapUtilities.Multimap,this.#x=new t.MapUtilities.Multimap}get locations(){return this.#S}async createLiveLocation(e,t,o){const r=new q(e,this,t,o),s=e.header();return s?(r.setHeader(s),this.#S.set(s,r),await r.update()):this.#x.set(e.url,r),r}disposeLocation(e){const t=e.header();t?this.#S.delete(t,e):this.#x.delete(e.url,e)}updateLocations(e){const t=[];for(const o of this.#S.get(e))t.push(o.update());return Promise.all(t)}async styleSheetAdded(e){const t=e.data;if(!t.sourceURL)return;const o=[];for(const e of this.#x.get(t.sourceURL))e.setHeader(t),this.#S.set(t,e),o.push(e.update());await Promise.all(o),this.#x.deleteAll(t.sourceURL)}async styleSheetRemoved(e){const t=e.data,o=[];for(const e of this.#S.get(t))e.setHeader(t),this.#x.set(e.url,e),o.push(e.update());await Promise.all(o),this.#S.deleteAll(t)}addSourceMap(e,t){this.#D.addSourceMap(e,t)}rawLocationToUILocation(e){let t=null;return t=t||this.#E.rawLocationToUILocation(e),t=t||this.#D.rawLocationToUILocation(e),t=t||this.#P.cssLocationToUILocation(e),t}uiLocationToRawLocations(e){let t=this.#E.uiLocationToRawLocations(e);return t.length?t:(t=this.#D.uiLocationToRawLocations(e),t.length?t:this.#P.uiLocationToCSSLocations(e))}dispose(){e.EventTarget.removeEventListeners(this.#u),this.#D.dispose(),this.#E.dispose()}};class q extends R{url;#N;#A;#O;headerInternal;constructor(e,t,o,r){super(o,r),this.url=e.url,this.#N=e.lineNumber,this.#A=e.columnNumber,this.#O=t,this.headerInternal=null}header(){return this.headerInternal}setHeader(e){this.headerInternal=e}async uiLocation(){if(!this.headerInternal)return null;const e=new r.CSSModel.CSSLocation(this.headerInternal,this.#N,this.#A);return z.instance().rawLocationToUILocation(e)}dispose(){super.dispose(),this.#O.disposeLocation(this)}async isIgnoreListed(){return!1}}var G=Object.freeze({__proto__:null,CSSWorkspaceBinding:z,LiveLocation:q,ModelInfo:V});const K={errorInDebuggerLanguagePlugin:"Error in debugger language plugin: {PH1}",loadingDebugSymbolsForVia:"[{PH1}] Loading debug symbols for {PH2} (via {PH3})...",loadingDebugSymbolsFor:"[{PH1}] Loading debug symbols for {PH2}...",loadedDebugSymbolsForButDidnt:"[{PH1}] Loaded debug symbols for {PH2}, but didn't find any source files",loadedDebugSymbolsForFound:"[{PH1}] Loaded debug symbols for {PH2}, found {PH3} source file(s)",failedToLoadDebugSymbolsFor:"[{PH1}] Failed to load debug symbols for {PH2} ({PH3})",failedToLoadDebugSymbolsForFunction:'No debug information for function "{PH1}"',debugSymbolsIncomplete:"The debug information for function {PH1} is incomplete"},$=n.i18n.registerUIStrings("models/bindings/DebuggerLanguagePlugins.ts",K),J=n.i18n.getLocalizedString.bind(void 0,$);function X(e){return`${e.sourceURL}@${e.hash}`}function Q(e){const{script:t}=e;return{rawModuleId:X(t),codeOffset:e.location().columnNumber-(t.codeOffset()||0),inlineFrameIndex:e.inlineFrameIndex}}class Y extends Error{exception;exceptionDetails;constructor(e,t){const{description:o}=t.exception||{};super(o||t.text),this.exception=e,this.exceptionDetails=t}static makeLocal(e,t){const o={type:"object",subtype:"error",description:t},r={text:"Uncaught",exceptionId:-1,columnNumber:0,lineNumber:0,exception:o},s=e.debuggerModel.runtimeModel().createRemoteObject(o);return new Y(s,r)}}class Z extends r.RemoteObject.LocalJSONObject{constructor(e){super(e)}get description(){return this.type}get type(){return"namespace"}}async function ee(e,t,o){if("reftype"===t.type){const o=await async function(e,t){if(!/^(local|global|operand)$/.test(t.valueClass))return{type:"undefined"};const o=Number(t.index),r=`${t.valueClass}s[${o}]`,s=await e.debuggerModel.agent.invoke_evaluateOnCallFrame({callFrameId:e.id,expression:r,silent:!0,generatePreview:!0,throwOnSideEffect:!0});return s.getError()||s.exceptionDetails?{type:"undefined"}:s.result}(e,t);return e.debuggerModel.runtimeModel().createRemoteObject(o)}return new re(e,t,o)}class te extends r.RemoteObject.RemoteObjectImpl{variables;#W;#B;stopId;constructor(e,t,o){super(e.debuggerModel.runtimeModel(),void 0,"object",void 0,null),this.variables=[],this.#W=e,this.#B=o,this.stopId=t}async doGetProperties(e,t,o){if(t)return{properties:[],internalProperties:[]};const s=[],i={};function n(e,t){return new r.RemoteObject.RemoteObjectProperty(e,t,!1,!1,!0,!1)}for(const e of this.variables){let t;try{const o=await this.#B.evaluate(e.name,Q(this.#W),this.stopId);t=o?await ee(this.#W,o,this.#B):new r.RemoteObject.LocalJSONObject(void 0)}catch(e){console.warn(e),t=new r.RemoteObject.LocalJSONObject(void 0)}if(e.nestedName&&e.nestedName.length>1){let o=i;for(let t=0;t<e.nestedName.length-1;t++){const r=e.nestedName[t];let s=o[r];s||(s=new Z({}),o[r]=s),o=s.value}o[e.nestedName[e.nestedName.length-1]]=t}else s.push(n(e.name,t))}for(const e in i)s.push(n(e,i[e]));return{properties:s,internalProperties:[]}}}class oe{#H;#_;#z;#V;#q;constructor(e,t,o,r,s,i){if(s&&"data:"!==new URL(s).protocol)throw new Error("The icon must be a data:-URL");this.#H=e,this.#_=o,this.#z=r,this.#V=s,this.#q=new te(e,t,i)}async getVariableValue(e){for(let t=0;t<this.#q.variables.length;++t){if(this.#q.variables[t].name!==e)continue;const o=await this.#q.getAllProperties(!1,!1);if(!o.properties)continue;const{value:r}=o.properties[t];if(r)return r}return null}callFrame(){return this.#H}type(){return this.#_}typeName(){return this.#z}name(){}range(){return null}object(){return this.#q}description(){return""}icon(){return this.#V}extraProperties(){return[]}}class re extends r.RemoteObject.RemoteObject{extensionObject;plugin;callFrame;constructor(e,t,o){super(),this.extensionObject=t,this.plugin=o,this.callFrame=e}get linearMemoryAddress(){return this.extensionObject.linearMemoryAddress}get linearMemorySize(){return this.extensionObject.linearMemorySize}get objectId(){return this.extensionObject.objectId}get type(){return"array"===this.extensionObject.type||"null"===this.extensionObject.type?"object":this.extensionObject.type}get subtype(){if("array"===this.extensionObject.type||"null"===this.extensionObject.type)return this.extensionObject.type}get value(){return this.extensionObject.value}unserializableValue(){}get description(){return this.extensionObject.description}set description(e){}get hasChildren(){return this.extensionObject.hasChildren}get preview(){}get className(){return this.extensionObject.className??null}arrayLength(){return 0}arrayBufferByteLength(){return 0}getOwnProperties(e,t){return this.getAllProperties(!1,e,t)}async getAllProperties(e,t,s){const{objectId:i}=this.extensionObject;if(i){o(this.plugin.getProperties);const e=await this.plugin.getProperties(i);return{properties:await Promise.all(e.map((async e=>new r.RemoteObject.RemoteObjectProperty(e.name,await ee(this.callFrame,e.value,this.plugin))))),internalProperties:null}}return{properties:null,internalProperties:null}}release(){const{objectId:e}=this.extensionObject;e&&(o(this.plugin.releaseObject),this.plugin.releaseObject(e))}debuggerModel(){return this.callFrame.debuggerModel}runtimeModel(){return this.callFrame.debuggerModel.runtimeModel()}isLinearMemoryInspectable(){return void 0!==this.extensionObject.linearMemoryAddress}}class se{#G;#o;#K;#$;#J;callFrameByStopId=new Map;stopIdByCallFrame=new Map;nextStopId=0n;constructor(e,t,o){this.#G=t,this.#o=o,this.#K=[],this.#$=new Map,e.observeModels(r.DebuggerModel.DebuggerModel,this),this.#J=new Map}async evaluateOnCallFrame(e,t){const{script:o}=e,{expression:s,returnByValue:i,throwOnSideEffect:n}=t,{plugin:a}=await this.rawModuleIdAndPluginForScript(o);if(!a)return null;const c=Q(e);if(0===(await a.rawLocationToSourceLocation(c)).length)return null;if(i)return{error:"Cannot return by value"};if(n)return{error:"Cannot guarantee side-effect freedom"};try{const t=await a.evaluate(s,c,this.stopIdForCallFrame(e));return t?{object:await ee(e,t,a),exceptionDetails:void 0}:{object:new r.RemoteObject.LocalJSONObject(void 0),exceptionDetails:void 0}}catch(t){if(t instanceof Y){const{exception:e,exceptionDetails:o}=t;return{object:e,exceptionDetails:o}}const{exception:o,exceptionDetails:r}=Y.makeLocal(e,t.message);return{object:o,exceptionDetails:r}}}stopIdForCallFrame(e){let t=this.stopIdByCallFrame.get(e);return void 0!==t||(t=this.nextStopId++,this.stopIdByCallFrame.set(e,t),this.callFrameByStopId.set(t,e)),t}callFrameForStopId(e){return this.callFrameByStopId.get(e)}expandCallFrames(e){return Promise.all(e.map((async e=>{const t=await this.getFunctionInfo(e.script,e.location());if(t){if("frames"in t&&t.frames.length)return t.frames.map((({name:t},o)=>e.createVirtualCallFrame(o,t)));if("missingSymbolFiles"in t&&t.missingSymbolFiles.length){const o=t.missingSymbolFiles,r=J(K.debugSymbolsIncomplete,{PH1:e.functionName});e.missingDebugInfoDetails={details:r,resources:o}}else e.missingDebugInfoDetails={details:J(K.failedToLoadDebugSymbolsForFunction,{PH1:e.functionName}),resources:[]}}return e}))).then((e=>e.flat()))}modelAdded(e){this.#$.set(e,new ie(e,this.#G)),e.addEventListener(r.DebuggerModel.Events.GlobalObjectCleared,this.globalObjectCleared,this),e.addEventListener(r.DebuggerModel.Events.ParsedScriptSource,this.parsedScriptSource,this),e.addEventListener(r.DebuggerModel.Events.DebuggerResumed,this.debuggerResumed,this),e.setEvaluateOnCallFrameCallback(this.evaluateOnCallFrame.bind(this)),e.setExpandCallFramesCallback(this.expandCallFrames.bind(this))}modelRemoved(t){t.removeEventListener(r.DebuggerModel.Events.GlobalObjectCleared,this.globalObjectCleared,this),t.removeEventListener(r.DebuggerModel.Events.ParsedScriptSource,this.parsedScriptSource,this),t.removeEventListener(r.DebuggerModel.Events.DebuggerResumed,this.debuggerResumed,this),t.setEvaluateOnCallFrameCallback(null),t.setExpandCallFramesCallback(null);const o=this.#$.get(t);o&&(o.dispose(),this.#$.delete(t)),this.#J.forEach(((o,r)=>{const s=o.scripts.filter((e=>e.debuggerModel!==t));0===s.length?(o.plugin.removeRawModule(r).catch((t=>{e.Console.Console.instance().error(J(K.errorInDebuggerLanguagePlugin,{PH1:t.message}),!1)})),this.#J.delete(r)):o.scripts=s}))}globalObjectCleared(e){const t=e.data;this.modelRemoved(t),this.modelAdded(t)}addPlugin(e){this.#K.push(e);for(const e of this.#$.keys())for(const t of e.scripts())this.hasPluginForScript(t)||this.parsedScriptSource({data:t})}removePlugin(e){this.#K=this.#K.filter((t=>t!==e));const t=new Set;this.#J.forEach(((o,r)=>{o.plugin===e&&(o.scripts.forEach((e=>t.add(e))),this.#J.delete(r))}));for(const e of t){this.#$.get(e.debuggerModel).removeScript(e),this.parsedScriptSource({data:e})}}hasPluginForScript(e){const t=X(e),o=this.#J.get(t);return o?.scripts.includes(e)??!1}async rawModuleIdAndPluginForScript(e){const t=X(e),o=this.#J.get(t);return o&&(await o.addRawModulePromise,o===this.#J.get(t))?{rawModuleId:t,plugin:o.plugin}:{rawModuleId:t,plugin:null}}uiSourceCodeForURL(e,t){const o=this.#$.get(e);return o?o.getProject().uiSourceCodeForURL(t):null}async rawLocationToUILocation(t){const o=t.script();if(!o)return null;const{rawModuleId:r,plugin:s}=await this.rawModuleIdAndPluginForScript(o);if(!s)return null;const i={rawModuleId:r,codeOffset:t.columnNumber-(o.codeOffset()||0),inlineFrameIndex:t.inlineFrameIndex};try{const e=await s.rawLocationToSourceLocation(i);for(const t of e){const e=this.uiSourceCodeForURL(o.debuggerModel,t.sourceFileURL);if(e)return e.uiLocation(t.lineNumber,t.columnNumber>=0?t.columnNumber:void 0)}}catch(t){e.Console.Console.instance().error(J(K.errorInDebuggerLanguagePlugin,{PH1:t.message}),!1)}return null}uiLocationToRawLocationRanges(t,o,s=-1){const i=[];return this.scriptsForUISourceCode(t).forEach((e=>{const n=X(e),a=this.#J.get(n);if(!a)return;const{plugin:c}=a;i.push(async function(e,i,n){const a={rawModuleId:e,sourceFileURL:t.url(),lineNumber:o,columnNumber:s},c=await i.sourceLocationToRawLocation(a);if(!c)return[];return c.map((e=>({start:new r.DebuggerModel.Location(n.debuggerModel,n.scriptId,0,Number(e.startOffset)+(n.codeOffset()||0)),end:new r.DebuggerModel.Location(n.debuggerModel,n.scriptId,0,Number(e.endOffset)+(n.codeOffset()||0))})))}(n,c,e))})),0===i.length?Promise.resolve(null):Promise.all(i).then((e=>e.flat())).catch((t=>(e.Console.Console.instance().error(J(K.errorInDebuggerLanguagePlugin,{PH1:t.message}),!1),null)))}async uiLocationToRawLocations(e,t,o){const r=await this.uiLocationToRawLocationRanges(e,t,o);return r?r.map((({start:e})=>e)):null}async uiLocationRangeToRawLocationRanges(e,t){const o=[];for(let r=t.startLine;r<=t.endLine;++r)o.push(this.uiLocationToRawLocationRanges(e,r));const r=[];for(const e of await Promise.all(o)){if(null===e)return null;for(const o of e){const[e,i]=await Promise.all([this.rawLocationToUILocation(o.start),this.rawLocationToUILocation(o.end)]);if(null===e||null===i)continue;t.intersection(new s.TextRange.TextRange(e.lineNumber,e.columnNumber??0,i.lineNumber,i.columnNumber??1/0)).isEmpty()||r.push(o)}}return r}scriptsForUISourceCode(e){for(const t of this.#$.values()){const o=t.uiSourceCodeToScripts.get(e);if(o)return o}return[]}setDebugInfoURL(e,t){this.hasPluginForScript(e)||(e.debugSymbols={type:"ExternalDWARF",externalURL:t},this.parsedScriptSource({data:e}),e.debuggerModel.setDebugInfoURL(e,t))}parsedScriptSource(t){const o=t.data;if(o.sourceURL)for(const t of this.#K){if(!t.handleScript(o))continue;const r=X(o);let s=this.#J.get(r);if(s)s.scripts.push(o);else{const i=(async()=>{const i=e.Console.Console.instance(),n=o.sourceURL,a=o.debugSymbols?.externalURL||"";a?i.log(J(K.loadingDebugSymbolsForVia,{PH1:t.name,PH2:n,PH3:a})):i.log(J(K.loadingDebugSymbolsFor,{PH1:t.name,PH2:n}));try{const c=!a&&e.ParsedURL.schemeIs(n,"wasm:")?await o.getWasmBytecode():void 0,u=await t.addRawModule(r,a,{url:n,code:c});if(s!==this.#J.get(r))return[];if("missingSymbolFiles"in u){const e=t.createPageResourceLoadInitiator();return{missingSymbolFiles:u.missingSymbolFiles.map((t=>({resourceUrl:t,initiator:e})))}}const d=u;return 0===d.length?i.warn(J(K.loadedDebugSymbolsForButDidnt,{PH1:t.name,PH2:n})):i.log(J(K.loadedDebugSymbolsForFound,{PH1:t.name,PH2:n,PH3:d.length})),d}catch(e){return i.error(J(K.failedToLoadDebugSymbolsFor,{PH1:t.name,PH2:n,PH3:e.message}),!1),this.#J.delete(r),[]}})();s={rawModuleId:r,plugin:t,scripts:[o],addRawModulePromise:i},this.#J.set(r,s)}return void s.addRawModulePromise.then((e=>{if(!("missingSymbolFiles"in e)&&o.debuggerModel.scriptForId(o.scriptId)===o){const t=this.#$.get(o.debuggerModel);t&&(t.addSourceFiles(o,e),this.#o.updateLocations(o))}}))}}debuggerResumed(e){const t=Array.from(this.callFrameByStopId.values()).filter((t=>t.debuggerModel===e.data));for(const e of t){const t=this.stopIdByCallFrame.get(e);o(t),this.stopIdByCallFrame.delete(e),this.callFrameByStopId.delete(t)}}getSourcesForScript(e){const t=X(e),o=this.#J.get(t);return o?o.addRawModulePromise:Promise.resolve(void 0)}async resolveScopeChain(t){const o=t.script,{rawModuleId:r,plugin:s}=await this.rawModuleIdAndPluginForScript(o);if(!s)return null;const i={rawModuleId:r,codeOffset:t.location().columnNumber-(o.codeOffset()||0),inlineFrameIndex:t.inlineFrameIndex},n=this.stopIdForCallFrame(t);try{if(0===(await s.rawLocationToSourceLocation(i)).length)return null;const e=new Map,o=await s.listVariablesInScope(i);for(const r of o||[]){let o=e.get(r.scope);if(!o){const{type:i,typeName:a,icon:c}=await s.getScopeInfo(r.scope);o=new oe(t,n,i,a,c,s),e.set(r.scope,o)}o.object().variables.push(r)}return Array.from(