import*as i18n from"../i18n/i18n.js";import*as TextEditor from"../text_editor/text_editor.js";const UIStrings={deletions:"Deletion:{PH1}",additions:"Addition:{PH1}"},str_=i18n.i18n.registerUIStrings("changes/ChangesTextEditor.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);export class ChangesTextEditor extends TextEditor.CodeMirrorTextEditor.CodeMirrorTextEditor{constructor(t){t.inputStyle="devToolsAccessibleDiffTextArea",super(t),this.codeMirror().setOption("gutters",["CodeMirror-linenumbers","changes-diff-gutter"]),this.codeMirror().setOption("extraKeys",{Enter:!1,Space:!1,Left:function(t){const e=t.getScrollInfo();e.left>0&&t.scrollTo(e.left-Math.round(e.clientWidth/6),null)},Right:function(t){const e=t.getScrollInfo();t.scrollTo(e.left+Math.round(e.clientWidth/6),null)}})}updateDiffGutter(t){this.codeMirror().eachLine((e=>{const i=this.codeMirror().getLineNumber(e),r=t[i];let o;"deletion"===r.type?(o=document.createElement("div"),o.classList.add("deletion"),o.classList.add("changes-diff-gutter-marker"),o.textContent="-"):"addition"===r.type&&(o=document.createElement("div"),o.classList.add("addition"),o.classList.add("changes-diff-gutter-marker"),o.textContent="+"),o&&this.codeMirror().setGutterMarker(e,"changes-diff-gutter",o)}))}}export class DevToolsAccessibleDiffTextArea extends TextEditor.CodeMirrorTextEditor.DevToolsAccessibleTextArea{reset(t){super.reset(t);const e=this.cm.doc;if(this.textAreaBusy(Boolean(t))||"object"!==typeof e.modeOption)return;const i=e.modeOption.diffRows[this.cm.getCursor().line].type;"deletion"===i&&(this.textarea.value=i18nString(UIStrings.deletions,{PH1:this.textarea.value})),"addition"===i&&(this.textarea.value=i18nString(UIStrings.additions,{PH1:this.textarea.value})),this.prevInput=this.textarea.value}}CodeMirror.inputStyles.devToolsAccessibleDiffTextArea=DevToolsAccessibleDiffTextArea;