/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
import{getPanel as e,showDialog as t,EditorView as r,ViewPlugin as i,Decoration as n,showPanel as s,runScopeHandlers as o}from"../../view/dist/index.js";import{StateEffect as l,EditorSelection as a,StateField as h,Prec as c,codePointAt as u,codePointSize as f,Facet as d,combineConfig as m,CharCategory as p,EditorState as g,RangeSetBuilder as v,fromCodePoint as x,findClusterBreak as b}from"../../state/dist/index.js";import w from"../../../crelt/index.js";const y="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class M{constructor(e,t,r=0,i=e.length,n,s){this.test=s,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(r,i),this.bufferStart=r,this.normalize=n?e=>n(y(e)):y,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return u(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=x(e),r=this.bufferStart+this.bufferPos;this.bufferPos+=f(e);let i=this.normalize(t);if(i.length)for(let n=0,s=r;;n++){let e=i.charCodeAt(n),o=this.match(e,s,this.bufferPos+this.bufferStart);if(n==i.length-1){if(o)return this.value=o,this;break}s==r&&n<t.length&&t.charCodeAt(n)==e&&s++}}}match(e,t,r){let i=null;for(let n=0;n<this.matches.length;n+=2){let t=this.matches[n],s=!1;this.query.charCodeAt(t)==e&&(t==this.query.length-1?i={from:this.matches[n+1],to:r}:(this.matches[n]++,s=!0)),s||(this.matches.splice(n,2),n-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?i={from:t,to:r}:this.matches.push(1,t)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}"undefined"!=typeof Symbol&&(M.prototype[Symbol.iterator]=function(){return this});const k={from:-1,to:-1,match:/* @__PURE__ */ /.*/.exec("")},S="gm"+(null==/x/.unicode?"":"u");class q{constructor(e,t,r,i=0,n=e.length){if(this.text=e,this.to=n,this.curLine="",this.done=!1,this.value=k,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new W(e,t,r,i,n);this.re=new RegExp(t,S+((null==r?void 0:r.ignoreCase)?"i":"")),this.test=null==r?void 0:r.test,this.iter=e.iter();let s=e.lineAt(i);this.curLineStart=s.from,this.matchPos=F(e,i),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let r=this.curLineStart+t.index,i=r+t[0].length;if(this.matchPos=F(this.text,i+(r==i?1:0)),r==this.curLineStart+this.curLine.length&&this.nextLine(),(r<i||r>this.value.to)&&(!this.test||this.test(r,i,t)))return this.value={from:r,to:i,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}const L=/* @__PURE__ */new WeakMap;class C{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,r){let i=L.get(e);if(!i||i.from>=r||i.to<=t){let i=new C(t,e.sliceString(t,r));return L.set(e,i),i}if(i.from==t&&i.to==r)return i;let{text:n,from:s}=i;return s>t&&(n=e.sliceString(t,s)+n,s=t),i.to<r&&(n+=e.sliceString(i.to,r)),L.set(e,new C(s,n)),new C(t,n.slice(t-s,r-s))}}class W{constructor(e,t,r,i,n){this.text=e,this.to=n,this.done=!1,this.value=k,this.matchPos=F(e,i),this.re=new RegExp(t,S+((null==r?void 0:r.ignoreCase)?"i":"")),this.test=null==r?void 0:r.test,this.flat=C.get(e,i,this.chunkEnd(i+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,r=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,r,t)))return this.value={from:e,to:r,match:t},this.matchPos=F(this.text,r+(e==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=C.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function F(e,t){if(t>=e.length)return t;let r,i=e.lineAt(t);for(;t<i.to&&(r=i.text.charCodeAt(t-i.from))>=56320&&r<57344;)t++;return t}"undefined"!=typeof Symbol&&(q.prototype[Symbol.iterator]=W.prototype[Symbol.iterator]=function(){return this});const A=e=>{let{state:i}=e,n=String(i.doc.lineAt(e.state.selection.main.head).number),{close:s,result:o}=t(e,{label:i.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:i.phrase("go")});return o.then(t=>{let n=t&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.elements.line.value);if(!n)return void e.dispatch({effects:s});let o=i.doc.lineAt(i.selection.main.head),[,l,h,c,u]=n,f=c?+c.slice(1):0,d=h?+h:o.number;if(h&&u){let e=d/100;l&&(e=e*("-"==l?-1:1)+o.number/i.doc.lines),d=Math.round(i.doc.lines*e)}else h&&l&&(d=d*("-"==l?-1:1)+o.number);let m=i.doc.line(Math.max(1,Math.min(i.doc.lines,d))),p=a.cursor(m.from+Math.max(0,Math.min(f,m.length)));e.dispatch({effects:[s,r.scrollIntoView(p.from,{y:"center"})],selection:p})}),!0},D={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},R=/* @__PURE__ */d.define({combine:e=>m(e,D,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});function P(e){return[O,z]}const E=/* @__PURE__ */n.mark({class:"cm-selectionMatch"}),I=/* @__PURE__ */n.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function $(e,t,r,i){return!(0!=r&&e(t.sliceDoc(r-1,r))==p.Word||i!=t.doc.length&&e(t.sliceDoc(i,i+1))==p.Word)}const z=/* @__PURE__ */i.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(R),{state:r}=e,i=r.selection;if(i.ranges.length>1)return n.none;let s,o=i.main,l=null;if(o.empty){if(!t.highlightWordAroundCursor)return n.none;let e=r.wordAt(o.head);if(!e)return n.none;l=r.charCategorizer(o.head),s=r.sliceDoc(e.from,e.to)}else{let e=o.to-o.from;if(e<t.minSelectionLength||e>200)return n.none;if(t.wholeWords){if(s=r.sliceDoc(o.from,o.to),l=r.charCategorizer(o.head),!$(l,r,o.from,o.to)||!function(e,t,r,i){return e(t.sliceDoc(r,r+1))==p.Word&&e(t.sliceDoc(i-1,i))==p.Word}(l,r,o.from,o.to))return n.none}else if(s=r.sliceDoc(o.from,o.to),!s)return n.none}let a=[];for(let h of e.visibleRanges){let e=new M(r.doc,s,h.from,h.to);for(;!e.next().done;){let{from:i,to:s}=e.value;if((!l||$(l,r,i,s))&&(o.empty&&i<=o.from&&s>=o.to?a.push(I.range(i,s)):(i>=o.to||s<=o.from)&&a.push(E.range(i,s)),a.length>t.maxMatches))return n.none}}return n.set(a)}},{decorations:e=>e.decorations}),O=/* @__PURE__ */r.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const T=({state:e,dispatch:t})=>{let{ranges:i}=e.selection;if(i.some(e=>e.from===e.to))return(({state:e,dispatch:t})=>{let{selection:r}=e,i=a.create(r.ranges.map(t=>e.wordAt(t.head)||a.cursor(t.head)),r.mainIndex);return!i.eq(r)&&(t(e.update({selection:i})),!0)})({state:e,dispatch:t});let n=e.sliceDoc(i[0].from,i[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=n))return!1;let s=function(e,t){let{main:r,ranges:i}=e.selection,n=e.wordAt(r.head),s=n&&n.from==r.from&&n.to==r.to;for(let o=!1,l=new M(e.doc,t,i[i.length-1].to);;){if(l.next(),!l.done){if(o&&i.some(e=>e.from==l.value.from))continue;if(s){let t=e.wordAt(l.value.from);if(!t||t.from!=l.value.from||t.to!=l.value.to)continue}return l.value}if(o)return null;l=new M(e.doc,t,0,Math.max(0,i[i.length-1].from-1)),o=!0}}(e,n);return!!s&&(t(e.update({selection:e.selection.addRange(a.range(s.from,s.to),!1),effects:r.scrollIntoView(s.to)})),!0)},j=/* @__PURE__ */d.define({combine:e=>m(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new ge(e),scrollToMatch:e=>r.scrollIntoView(e)})});class V{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,S),!0}catch(t){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?"\t":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new J(this):new B(this)}getCursor(e,t=0,r){let i=e.doc?e:g.create({doc:e});return null==r&&(r=i.doc.length),this.regexp?G(this,i,t,r):Q(this,i,t,r)}}class K{constructor(e){this.spec=e}}function Q(e,t,r,i){let n;var s,o;return e.wholeWord&&(s=t.doc,o=t.charCategorizer(t.selection.main.head),n=(e,t,r,i)=>((i>e||i+r.length<t)&&(i=Math.max(0,e-2),r=s.sliceString(i,Math.min(s.length,t+2))),!(o(N(r,e-i))==p.Word&&o(H(r,e-i))==p.Word||o(H(r,t-i))==p.Word&&o(N(r,t-i))==p.Word))),e.test&&(n=function(e,t,r){return(i,n,s,o)=>{if(r&&!r(i,n,s,o))return!1;let l=i>=o&&n<=o+s.length?s.slice(i-o,n-o):t.doc.sliceString(i,n);return e(l,t,i,n)}}(e.test,t,n)),new M(t.doc,e.unquoted,r,i,e.caseSensitive?void 0:e=>e.toLowerCase(),n)}class B extends K{constructor(e){super(e)}nextMatch(e,t,r){let i=Q(this.spec,e,r,e.doc.length).nextOverlapping();if(i.done){let r=Math.min(e.doc.length,t+this.spec.unquoted.length);i=Q(this.spec,e,0,r).nextOverlapping()}return i.done||i.value.from==t&&i.value.to==r?null:i.value}prevMatchInRange(e,t,r){for(let i=r;;){let r=Math.max(t,i-1e4-this.spec.unquoted.length),n=Q(this.spec,e,r,i),s=null;for(;!n.nextOverlapping().done;)s=n.value;if(s)return s;if(r==t)return null;i-=1e4}}prevMatch(e,t,r){let i=this.prevMatchInRange(e,0,t);return i||(i=this.prevMatchInRange(e,Math.max(0,r-this.spec.unquoted.length),e.doc.length)),!i||i.from==t&&i.to==r?null:i}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let r=Q(this.spec,e,0,e.doc.length),i=[];for(;!r.next().done;){if(i.length>=t)return null;i.push(r.value)}return i}highlight(e,t,r,i){let n=Q(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,e.doc.length));for(;!n.next().done;)i(n.value.from,n.value.to)}}function G(e,t,r,i){let n;var s;return e.wholeWord&&(s=t.charCategorizer(t.selection.main.head),n=(e,t,r)=>!r[0].length||(s(N(r.input,r.index))!=p.Word||s(H(r.input,r.index))!=p.Word)&&(s(H(r.input,r.index+r[0].length))!=p.Word||s(N(r.input,r.index+r[0].length))!=p.Word)),e.test&&(n=function(e,t,r){return(i,n,s)=>(!r||r(i,n,s))&&e(s[0],t,i,n)}(e.test,t,n)),new q(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:n},r,i)}function N(e,t){return e.slice(b(e,t,!1),t)}function H(e,t){return e.slice(t,b(e,t))}class J extends K{nextMatch(e,t,r){let i=G(this.spec,e,r,e.doc.length).next();return i.done&&(i=G(this.spec,e,0,t).next()),i.done?null:i.value}prevMatchInRange(e,t,r){for(let i=1;;i++){let n=Math.max(t,r-1e4*i),s=G(this.spec,e,n,r),o=null;for(;!s.next().done;)o=s.value;if(o&&(n==t||o.from>n+10))return o;if(n==t)return null}}prevMatch(e,t,r){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,r,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,r)=>{if("&"==r)return e.match[0];if("$"==r)return"$";for(let i=r.length;i>0;i--){let t=+r.slice(0,i);if(t>0&&t<e.match.length)return e.match[t]+r.slice(i)}return t})}matchAll(e,t){let r=G(this.spec,e,0,e.doc.length),i=[];for(;!r.next().done;){if(i.length>=t)return null;i.push(r.value)}return i}highlight(e,t,r,i){let n=G(this.spec,e,Math.max(0,t-250),Math.min(r+250,e.doc.length));for(;!n.next().done;)i(n.value.from,n.value.to)}}const U=/* @__PURE__ */l.define(),X=/* @__PURE__ */l.define(),Y=/* @__PURE__ */h.define({create:e=>new Z(ce(e).create(),null),update(e,t){for(let r of t.effects)r.is(U)?e=new Z(r.value.create(),e.panel):r.is(X)&&(e=new Z(e.query,r.value?he:null));return e},provide:e=>s.from(e,e=>e.panel)});class Z{constructor(e,t){this.query=e,this.panel=t}}const _=/* @__PURE__ */n.mark({class:"cm-searchMatch"}),ee=/* @__PURE__ */n.mark({class:"cm-searchMatch cm-searchMatch-selected"}),te=/* @__PURE__ */i.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(Y))}update(e){let t=e.state.field(Y);(t!=e.startState.field(Y)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return n.none;let{view:r}=this,i=new v;for(let n=0,s=r.visibleRanges,o=s.length;n<o;n++){let{from:t,to:l}=s[n];for(;n<o-1&&l>s[n+1].from-500;)l=s[++n].to;e.highlight(r.state,t,l,(e,t)=>{let n=r.state.selection.ranges.some(r=>r.from==e&&r.to==t);i.add(e,t,n?ee:_)})}return i.finish()}},{decorations:e=>e.decorations});function re(e){return t=>{let r=t.state.field(Y,!1);return r&&r.query.spec.valid?e(t,r):de(t)}}const ie=/* @__PURE__ */re((e,{query:t})=>{let{to:r}=e.state.selection.main,i=t.nextMatch(e.state,r,r);if(!i)return!1;let n=a.single(i.from,i.to),s=e.state.facet(j);return e.dispatch({selection:n,effects:[we(e,i),s.scrollToMatch(n.main,e)],userEvent:"select.search"}),fe(e),!0}),ne=/* @__PURE__ */re((e,{query:t})=>{let{state:r}=e,{from:i}=r.selection.main,n=t.prevMatch(r,i,i);if(!n)return!1;let s=a.single(n.from,n.to),o=e.state.facet(j);return e.dispatch({selection:s,effects:[we(e,n),o.scrollToMatch(s.main,e)],userEvent:"select.search"}),fe(e),!0}),se=/* @__PURE__ */re((e,{query:t})=>{let r=t.matchAll(e.state,1e3);return!(!r||!r.length)&&(e.dispatch({selection:a.create(r.map(e=>a.range(e.from,e.to))),userEvent:"select.search.matches"}),!0)}),oe=({state:e,dispatch:t})=>{let r=e.selection;if(r.ranges.length>1||r.main.empty)return!1;let{from:i,to:n}=r.main,s=[],o=0;for(let l=new M(e.doc,e.sliceDoc(i,n));!l.next().done;){if(s.length>1e3)return!1;l.value.from==i&&(o=s.length),s.push(a.range(l.value.from,l.value.to))}return t(e.update({selection:a.create(s,o),userEvent:"select.search.matches"})),!0},le=/* @__PURE__ */re((e,{query:t})=>{let{state:i}=e,{from:n,to:s}=i.selection.main;if(i.readOnly)return!1;let o=t.nextMatch(i,n,n);if(!o)return!1;let l,h,c=o,u=[],f=[];c.from==n&&c.to==s&&(h=i.toText(t.getReplacement(c)),u.push({from:c.from,to:c.to,insert:h}),c=t.nextMatch(i,c.from,c.to),f.push(r.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(n).number)+".")));let d=e.state.changes(u);return c&&(l=a.single(c.from,c.to).map(d),f.push(we(e,c)),f.push(i.facet(j).scrollToMatch(l.main,e))),e.dispatch({changes:d,selection:l,effects:f,userEvent:"input.replace"}),!0}),ae=/* @__PURE__ */re((e,{query:t})=>{if(e.state.readOnly)return!1;let i=t.matchAll(e.state,1e9).map(e=>{let{from:r,to:i}=e;return{from:r,to:i,insert:t.getReplacement(e)}});if(!i.length)return!1;let n=e.state.phrase("replaced $ matches",i.length)+".";return e.dispatch({changes:i,effects:r.announce.of(n),userEvent:"input.replace.all"}),!0});function he(e){return e.state.facet(j).createPanel(e)}function ce(e,t){var r,i,n,s,o;let l=e.selection.main,a=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!a)return t;let h=e.facet(j);return new V({search:(null!==(r=null==t?void 0:t.literal)&&void 0!==r?r:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:null!==(i=null==t?void 0:t.caseSensitive)&&void 0!==i?i:h.caseSensitive,literal:null!==(n=null==t?void 0:t.literal)&&void 0!==n?n:h.literal,regexp:null!==(s=null==t?void 0:t.regexp)&&void 0!==s?s:h.regexp,wholeWord:null!==(o=null==t?void 0:t.wholeWord)&&void 0!==o?o:h.wholeWord})}function ue(t){let r=e(t,he);return r&&r.dom.querySelector("[main-field]")}function fe(e){let t=ue(e);t&&t==e.root.activeElement&&t.select()}const de=e=>{let t=e.state.field(Y,!1);if(t&&t.panel){let r=ue(e);if(r&&r!=e.root.activeElement){let i=ce(e.state,t.query.spec);i.valid&&e.dispatch({effects:U.of(i)}),r.focus(),r.select()}}else e.dispatch({effects:[X.of(!0),t?U.of(ce(e.state,t.query.spec)):l.appendConfig.of(Me)]});return!0},me=t=>{let r=t.state.field(Y,!1);if(!r||!r.panel)return!1;let i=e(t,he);return i&&i.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:X.of(!1)}),!0},pe=[{key:"Mod-f",run:de,scope:"editor search-panel"},{key:"F3",run:ie,shift:ne,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:ie,shift:ne,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:me,scope:"editor search-panel"},{key:"Mod-Shift-l",run:oe},{key:"Mod-Alt-g",run:A},{key:"Mod-d",run:T,preventDefault:!0}];class ge{constructor(e){this.view=e;let t=this.query=e.state.field(Y).query.spec;function r(e,t,r){return w("button",{class:"cm-button",name:e,onclick:t,type:"button"},r)}this.commit=this.commit.bind(this),this.searchField=w("input",{value:t.search,placeholder:ve(e,"Find"),"aria-label":ve(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=w("input",{value:t.replace,placeholder:ve(e,"Replace"),"aria-label":ve(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=w("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=w("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=w("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=w("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,r("next",()=>ie(e),[ve(e,"next")]),r("prev",()=>ne(e),[ve(e,"previous")]),r("select",()=>se(e),[ve(e,"all")]),w("label",null,[this.caseField,ve(e,"match case")]),w("label",null,[this.reField,ve(e,"regexp")]),w("label",null,[this.wordField,ve(e,"by word")]),...e.state.readOnly?[]:[w("br"),this.replaceField,r("replace",()=>le(e),[ve(e,"replace")]),r("replaceAll",()=>ae(e),[ve(e,"replace all")])],w("button",{name:"close",onclick:()=>me(e),"aria-label":ve(e,"close"),type:"button"},["×"])])}commit(){let e=new V({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:U.of(e)}))}keydown(e){o(this.view,e,"search-panel")?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?ne:ie)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),le(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(U)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(j).top}}function ve(e,t){return e.state.phrase(t)}const xe=30,be=/[\s\.,:;?!]/;function we(e,{from:t,to:i}){let n=e.state.doc.lineAt(t),s=e.state.doc.lineAt(i).to,o=Math.max(n.from,t-xe),l=Math.min(s,i+xe),a=e.state.sliceDoc(o,l);if(o!=n.from)for(let r=0;r<xe;r++)if(!be.test(a[r+1])&&be.test(a[r])){a=a.slice(r);break}if(l!=s)for(let r=a.length-1;r>a.length-xe;r--)if(!be.test(a[r-1])&&be.test(a[r])){a=a.slice(0,r);break}return r.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${n.number}.`)}const ye=/* @__PURE__ */r.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),Me=[Y,
/* @__PURE__ */c.low(te),ye];export{q as RegExpCursor,M as SearchCursor,V as SearchQuery,me as closeSearchPanel,ie as findNext,ne as findPrevious,A as gotoLine,P as highlightSelectionMatches,de as openSearchPanel,ae as replaceAll,le as replaceNext,pe as searchKeymap,se as selectMatches,T as selectNextOccurrence,oe as selectSelectionMatches,U as setSearchQuery};