import*as i18n from"../i18n/i18n.js";import*as QuickOpen from"../quick_open/quick_open.js";import{evaluateScriptSnippet,findSnippetsProject}from"./ScriptSnippetFileSystem.js";const UIStrings={noSnippetsFound:"No snippets found.",runSnippet:"Run snippet"},str_=i18n.i18n.registerUIStrings("snippets/SnippetsQuickOpen.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_),i18nLazyString=i18n.i18n.getLazilyComputedLocalizedString.bind(void 0,str_);let snippetsQuickOpenInstance;export class SnippetsQuickOpen extends QuickOpen.FilteredListWidget.Provider{constructor(){super(),this._snippets=[]}static instance(e={forceNew:null}){const{forceNew:t}=e;return snippetsQuickOpenInstance&&!t||(snippetsQuickOpenInstance=new SnippetsQuickOpen),snippetsQuickOpenInstance}selectItem(e,t){null!==e&&evaluateScriptSnippet(this._snippets[e])}notFoundText(e){return i18nString(UIStrings.noSnippetsFound)}attach(){this._snippets=findSnippetsProject().uiSourceCodes()}detach(){this._snippets=[]}itemCount(){return this._snippets.length}itemKeyAt(e){return this._snippets[e].name()}renderItem(e,t,i,n){i.textContent=unescape(this._snippets[e].name()),i.classList.add("monospace"),QuickOpen.FilteredListWidget.FilteredListWidget.highlightRanges(i,t,!0)}}QuickOpen.FilteredListWidget.registerProvider({prefix:"!",title:i18nLazyString(UIStrings.runSnippet),provider:SnippetsQuickOpen.instance});