import{SourceFrameImpl}from'./SourceFrame.js';export class ResourceSourceFrame extends SourceFrameImpl{constructor(resource,autoPrettyPrint,codeMirrorOptions){super(async()=>{let content=(await resource.requestContent()).content||'';if(await resource.contentEncoded()){content=window.atob(content);}
return{content,isEncoded:false};},codeMirrorOptions);this._resource=resource;this.setCanPrettyPrint(this._resource.contentType().isDocumentOrScriptOrStyleSheet(),autoPrettyPrint);}
static createSearchableView(resource,highlighterType,autoPrettyPrint){return new SearchableContainer(resource,highlighterType,autoPrettyPrint);}
get resource(){return this._resource;}
populateTextAreaContextMenu(contextMenu,lineNumber,columnNumber){contextMenu.appendApplicableItems(this._resource);return Promise.resolve();}}
export class SearchableContainer extends UI.VBox{constructor(resource,highlighterType,autoPrettyPrint){super(true);this.registerRequiredCSS('source_frame/resourceSourceFrame.css');const sourceFrame=new ResourceSourceFrame(resource,autoPrettyPrint);this._sourceFrame=sourceFrame;sourceFrame.setHighlighterType(highlighterType);const searchableView=new UI.SearchableView(sourceFrame);searchableView.element.classList.add('searchable-view');searchableView.setPlaceholder(ls`Find`);sourceFrame.show(searchableView.element);sourceFrame.setSearchableView(searchableView);searchableView.show(this.contentElement);const toolbar=new UI.Toolbar('toolbar',this.contentElement);sourceFrame.toolbarItems().then(items=>{items.map(item=>toolbar.appendToolbarItem(item));});}
async revealPosition(lineNumber,columnNumber){this._sourceFrame.revealPosition(lineNumber,columnNumber,true);}}