/*!
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
*/
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../view/dist/index.js"),t=require("../../state/dist/index.js"),i=require("../../../crelt/index.js");class o{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class n{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(i,o,l){let r=l.facet(x).markerFilter;r&&(i=r(i,l));let a=i.slice().sort((e,t)=>e.from-t.from||e.to-t.to),c=new t.RangeSetBuilder,d=[],f=0,u=l.doc.iter(),m=0,h=l.doc.length;for(let t=0;;){let i,o,n=t==a.length?null:a[t];if(!n&&!d.length)break;if(d.length)i=f,o=d.reduce((e,t)=>Math.min(e,t.to),n&&n.from>i?n.from:1e8);else{if(i=n.from,i>h)break;o=n.to,d.push(n),t++}for(;t<a.length;){let e=a[t];if(e.from!=i||!(e.to>e.from||e.to==i)){o=Math.min(e.from,o);break}d.push(e),t++,o=Math.min(e.to,o)}o=Math.min(o,h);let s=!1;if(d.some(e=>e.from==i&&(e.to==o||o==h))&&(s=i==o,!s&&o-i<10)){let e=i-(m+u.value.length);e>0&&(u.next(e),m=i);for(let t=i;;){if(t>=o){s=!0;break}if(!u.lineBreak&&m+u.value.length>t)break;t=m+u.value.length,m+=u.value.length,u.next()}}let l=E(d);if(s)c.add(i,i,e.Decoration.widget({widget:new T(l),diagnostics:d.slice()}));else{let t=d.reduce((e,t)=>t.markClass?e+" "+t.markClass:e,"");c.add(i,o,e.Decoration.mark({class:"cm-lintRange cm-lintRange-"+l+t,diagnostics:d.slice(),inclusiveEnd:d.some(e=>e.to>o)}))}if(f=o,f==h)break;for(let e=0;e<d.length;e++)d[e].to<=f&&d.splice(e--,1)}let g=c.finish();return new n(g,o,s(g))}}function s(e,t=null,i=0){let n=null;return e.between(i,1e9,(e,i,{spec:s})=>{if(!(t&&s.diagnostics.indexOf(t)<0))if(n){if(s.diagnostics.indexOf(n.diagnostic)<0)return!1;n=new o(n.from,i,n.diagnostic)}else n=new o(e,i,t||s.diagnostics[0])}),n}function l(e,t){let i=t.pos,o=t.end||i,n=e.state.facet(x).hideOn(e,i,o);if(null!=n)return n;let s=e.startState.doc.lineAt(t.pos);return!(!e.effects.some(e=>e.is(c))&&!e.changes.touchesRange(s.from,Math.max(s.to,o)))}function r(e,i){return e.field(u,!1)?i:i.concat(t.StateEffect.appendConfig.of($))}function a(e,t){return{effects:r(e,[c.of(t)])}}const c=t.StateEffect.define(),d=t.StateEffect.define(),f=t.StateEffect.define(),u=t.StateField.define({create:()=>new n(e.Decoration.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let i=e.diagnostics.map(t.changes),o=null,l=e.panel;if(e.selected){let n=t.changes.mapPos(e.selected.from,1);o=s(i,e.selected.diagnostic,n)||s(i,null,n)}!i.size&&l&&t.state.facet(x).autoPanel&&(l=null),e=new n(i,l,o)}for(let i of t.effects)if(i.is(c)){let o=t.state.facet(x).autoPanel?i.value.length?D.open:null:e.panel;e=n.init(i.value,o,t.state)}else i.is(d)?e=new n(e.diagnostics,i.value?D.open:null,e.selected):i.is(f)&&(e=new n(e.diagnostics,e.panel,i.value));return e},provide:t=>[e.showPanel.from(t,e=>e.panel),e.EditorView.decorations.from(t,e=>e.diagnostics)]}),m=e.Decoration.mark({class:"cm-lintRange cm-lintRange-active"});function h(e,t,i){let o,{diagnostics:n}=e.state.field(u),s=-1,l=-1;n.between(t-(i<0?1:0),t+(i>0?1:0),(e,n,{spec:r})=>{if(t>=e&&t<=n&&(e==n||(t>e||i>0)&&(t<n||i<0)))return o=r.diagnostics,s=e,l=n,!1});let r=e.state.facet(x).tooltipFilter;return o&&r&&(o=r(o,e.state)),o?{pos:s,end:l,above:e.state.doc.lineAt(s).to<l,create:()=>({dom:g(e,o)})}:null}function g(e,t){return i.default("ul",{class:"cm-tooltip-lint"},t.map(t=>S(e,t,!1)))}const p=t=>{let i=t.state.field(u,!1);i&&i.panel||t.dispatch({effects:r(t.state,[d.of(!0)])});let o=e.getPanel(t,D.open);return o&&o.dom.querySelector(".cm-panel-lint ul").focus(),!0},v=e=>{let t=e.state.field(u,!1);return!(!t||!t.panel)&&(e.dispatch({effects:d.of(!1)}),!0)},w=e=>{let t=e.state.field(u,!1);if(!t)return!1;let i=e.state.selection.main,o=s(t.diagnostics,null,i.to+1);return!(!o&&(o=s(t.diagnostics,null,0),!o||o.from==i.from&&o.to==i.to))&&(e.dispatch({selection:{anchor:o.from,head:o.to},scrollIntoView:!0}),!0)},b=[{key:"Mod-Shift-m",run:p,preventDefault:!0},{key:"F8",run:w}],k=e.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.timeout=-1,this.set=!0;let{delay:t}=e.state.facet(x);this.lintTime=Date.now()+t,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,t)}run(){clearTimeout(this.timeout);let t=Date.now();if(t<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-t);else{this.set=!1;let{state:t}=this.view,{sources:i}=t.facet(x);i.length&&function(e,t,i){let o=[],n=-1;for(let s of e)s.then(i=>{o.push(i),clearTimeout(n),o.length==e.length?t(o):n=setTimeout(()=>t(o),200)},i)}(i.map(e=>Promise.resolve(e(this.view))),e=>{this.view.state.doc==t.doc&&this.view.dispatch(a(this.view.state,e.reduce((e,t)=>e.concat(t))))},t=>{e.logException(this.view.state,t)})}}update(e){let t=e.state.facet(x);(e.docChanged||t!=e.startState.facet(x)||t.needsRefresh&&t.needsRefresh(e))&&(this.lintTime=Date.now()+t.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,t.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});const x=t.Facet.define({combine:e=>({sources:e.map(e=>e.source).filter(e=>null!=e),...t.combineConfig(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:y,tooltipFilter:y,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,o,n)=>e(i,o,n)||t(i,o,n):e:t,autoPanel:(e,t)=>e||t})})});function y(e,t){return e?t?(i,o)=>t(e(i,o),o):e:t}function C(e){let t=[];if(e)e:for(let{name:i}of e){for(let e=0;e<i.length;e++){let o=i[e];if(/[a-zA-Z]/.test(o)&&!t.some(e=>e.toLowerCase()==o.toLowerCase())){t.push(o);continue e}}t.push("")}return t}function S(e,t,o){var n;let l=o?C(t.actions):[];return i.default("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},i.default("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null===(n=t.actions)||void 0===n?void 0:n.map((o,n)=>{let r=!1,a=i=>{if(i.preventDefault(),r)return;r=!0;let n=s(e.state.field(u).diagnostics,t);n&&o.apply(e,n.from,n.to)},{name:c}=o,d=l[n]?c.indexOf(l[n]):-1,f=d<0?c:[c.slice(0,d),i.default("u",c.slice(d,d+1)),c.slice(d+1)],m=o.markClass?" "+o.markClass:"";return i.default("button",{type:"button",class:"cm-diagnosticAction"+m,onclick:a,onmousedown:a,"aria-label":` Action: ${c}${d<0?"":` (access key "${l[n]})"`}.`},f)}),t.source&&i.default("div",{class:"cm-diagnosticSource"},t.source))}class T extends e.WidgetType{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return i.default("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class R{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=S(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class D{constructor(e){this.view=e,this.items=[];this.list=i.default("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(27==t.keyCode)v(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:i}=this.items[this.selectedIndex],o=C(i.actions);for(let n=0;n<o.length;n++)if(o[n].toUpperCase().charCodeAt(0)==t.keyCode){let t=s(this.view.state.field(u).diagnostics,i);t&&i.actions[n].apply(e,t.from,t.to)}}}t.preventDefault()}},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=i.default("div",{class:"cm-panel-lint"},this.list,i.default("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>v(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(u).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(u),i=0,o=!1,n=null,s=new Set;for(e.between(0,this.view.state.doc.length,(e,l,{spec:r})=>{for(let a of r.diagnostics){if(s.has(a))continue;s.add(a);let e,l=-1;for(let t=i;t<this.items.length;t++)if(this.items[t].diagnostic==a){l=t;break}l<0?(e=new R(this.view,a),this.items.splice(i,0,e),o=!0):(e=this.items[l],l>i&&(this.items.splice(i,l-i),o=!0)),t&&e.diagnostic==t.diagnostic?e.dom.hasAttribute("aria-selected")||(e.dom.setAttribute("aria-selected","true"),n=e):e.dom.hasAttribute("aria-selected")&&e.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)o=!0,this.items.pop();0==this.items.length&&(this.items.push(new R(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),o=!0),n?(this.list.setAttribute("aria-activedescendant",n.id),this.view.requestMeasure({key:this,read:()=>({sel:n.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let i=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/i:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/i)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),o&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=s(this.view.state.field(u).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:f.of(t)})}static open(e){return new D(e)}}function P(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function L(e){return P(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const M=e.EditorView.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:L("#d11")},".cm-lintRange-warning":{backgroundImage:L("orange")},".cm-lintRange-info":{backgroundImage:L("#999")},".cm-lintRange-hint":{backgroundImage:L("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function A(e){return"error"==e?4:"warning"==e?3:"info"==e?2:1}function E(e){let t="hint",i=1;for(let o of e){let e=A(o.severity);e>i&&(i=e,t=o.severity)}return t}class F extends e.GutterMarker{constructor(e){super(),this.diagnostics=e,this.severity=E(e)}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,o=e.state.facet(H).tooltipFilter;return o&&(i=o(i,e.state)),i.length&&(t.onmouseover=()=>function(e,t,i){function o(){let o=e.elementAtHeight(t.getBoundingClientRect().top+5-e.documentTop);e.coordsAtPos(o.from)&&e.dispatch({effects:j.of({pos:o.from,above:!1,clip:!1,create:()=>({dom:g(e,i),getCoords:()=>t.getBoundingClientRect()})})}),t.onmouseout=t.onmousemove=null,function(e,t){let i=o=>{let n=t.getBoundingClientRect();if(!(o.clientX>n.left-10&&o.clientX<n.right+10&&o.clientY>n.top-10&&o.clientY<n.bottom+10)){for(let e=o.target;e;e=e.parentNode)if(1==e.nodeType&&e.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",i),e.state.field(V)&&e.dispatch({effects:j.of(null)})}};window.addEventListener("mousemove",i)}(e,t)}let{hoverTime:n}=e.state.facet(H),s=setTimeout(o,n);t.onmouseout=()=>{clearTimeout(s),t.onmouseout=t.onmousemove=null},t.onmousemove=()=>{clearTimeout(s),s=setTimeout(o,n)}}(e,t,i)),t}}function I(e,i){let o=Object.create(null);for(let t of i){let i=e.lineAt(t.from);(o[i.from]||(o[i.from]=[])).push(t)}let n=[];for(let t in o)n.push(new F(o[t]).range(+t));return t.RangeSet.of(n,!0)}const B=e.gutter({class:"cm-gutter-lint",markers:e=>e.state.field(O),widgetMarker:(e,t,i)=>{let o=[];return e.state.field(O).between(i.from,i.to,(e,t,n)=>{e>i.from&&e<i.to&&o.push(...n.diagnostics)}),o.length?new F(o):null}}),O=t.StateField.define({create:()=>t.RangeSet.empty,update(e,t){e=e.map(t.changes);let i=t.state.facet(H).markerFilter;for(let o of t.effects)if(o.is(c)){let n=o.value;i&&(n=i(n||[],t.state)),e=I(t.state.doc,n.slice(0))}return e}}),j=t.StateEffect.define(),V=t.StateField.define({create:()=>null,update:(e,t)=>(e&&t.docChanged&&(e=l(t,e)?null:{...e,pos:t.changes.mapPos(e.pos)}),t.effects.reduce((e,t)=>t.is(j)?t.value:e,e)),provide:t=>e.showTooltip.from(t)}),q=e.EditorView.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:P('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:P('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:P('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),$=[u,e.EditorView.decorations.compute([u],t=>{let{selected:i,panel:o}=t.field(u);return i&&o&&i.from!=i.to?e.Decoration.set([m.range(i.from,i.to)]):e.Decoration.none}),e.hoverTooltip(h,{hideOn:l}),M],H=t.Facet.define({combine:e=>t.combineConfig(e,{hoverTime:300,markerFilter:null,tooltipFilter:null})});exports.closeLintPanel=v,exports.lintGutter=function(e={}){return[H.of(e),O,B,q,V]},exports.lintKeymap=b,exports.linter=function(e,t={}){return[x.of({source:e,config:t}),k,$]},exports.nextDiagnostic=w,exports.openLintPanel=p,exports.setDiagnostics=a,exports.setDiagnosticsEffect=c;