import*as i18n from"../i18n/i18n.js";import*as UI from"../ui/ui.js";import{SourceFrameImpl}from"./SourceFrame.js";const UIStrings={find:"Find"},str_=i18n.i18n.registerUIStrings("source_frame/ResourceSourceFrame.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);export class ResourceSourceFrame extends SourceFrameImpl{constructor(e,r,t){super((async()=>{let r=(await e.requestContent()).content||"";return await e.contentEncoded()&&(r=window.atob(r)),{content:r,isEncoded:!1}}),t),this._resource=e,this.setCanPrettyPrint(this._resource.contentType().isDocumentOrScriptOrStyleSheet(),r)}static createSearchableView(e,r,t){return new SearchableContainer(e,r,t)}get resource(){return this._resource}populateTextAreaContextMenu(e,r,t){return e.appendApplicableItems(this._resource),Promise.resolve()}}export class SearchableContainer extends UI.Widget.VBox{constructor(e,r,t){super(!0),this.registerRequiredCSS("source_frame/resourceSourceFrame.css",{enableLegacyPatching:!0});const n=new ResourceSourceFrame(e,t);this._sourceFrame=n,n.setHighlighterType(r);const s=new UI.SearchableView.SearchableView(n,n);s.element.classList.add("searchable-view"),s.setPlaceholder(i18nString(UIStrings.find)),n.show(s.element),n.setSearchableView(s),s.show(this.contentElement);const o=new UI.Toolbar.Toolbar("toolbar",this.contentElement);n.toolbarItems().then((e=>{e.map((e=>o.appendToolbarItem(e)))}))}async revealPosition(e,r){this._sourceFrame.revealPosition(e,r,!0)}}