modscape 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -426,7 +426,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
426
426
  `:n=="r"?"\r":n=="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 Mue(this):new Eue(this)}getCursor(e,r=0,n){let i=e.doc?e:Dt.create({doc:e});return n==null&&(n=i.doc.length),this.regexp?cu(this,i,r,n):uu(this,i,r,n)}}class YF{constructor(e){this.spec=e}}function kue(t,e,r){return(n,i,a,s)=>{if(r&&!r(n,i,a,s))return!1;let l=n>=s&&i<=s+a.length?a.slice(n-s,i-s):e.doc.sliceString(n,i);return t(l,e,n,i)}}function uu(t,e,r,n){let i;return t.wholeWord&&(i=Tue(e.doc,e.charCategorizer(e.selection.main.head))),t.test&&(i=kue(t.test,e,i)),new Vu(e.doc,t.unquoted,r,n,t.caseSensitive?void 0:a=>a.toLowerCase(),i)}function Tue(t,e){return(r,n,i,a)=>((a>r||a+i.length<n)&&(a=Math.max(0,r-2),i=t.sliceString(a,Math.min(t.length,n+2))),(e(Yg(i,r-a))!=cr.Word||e(Xg(i,r-a))!=cr.Word)&&(e(Xg(i,n-a))!=cr.Word||e(Yg(i,n-a))!=cr.Word))}class Eue extends YF{constructor(e){super(e)}nextMatch(e,r,n){let i=uu(this.spec,e,n,e.doc.length).nextOverlapping();if(i.done){let a=Math.min(e.doc.length,r+this.spec.unquoted.length);i=uu(this.spec,e,0,a).nextOverlapping()}return i.done||i.value.from==r&&i.value.to==n?null:i.value}prevMatchInRange(e,r,n){for(let i=n;;){let a=Math.max(r,i-1e4-this.spec.unquoted.length),s=uu(this.spec,e,a,i),l=null;for(;!s.nextOverlapping().done;)l=s.value;if(l)return l;if(a==r)return null;i-=1e4}}prevMatch(e,r,n){let i=this.prevMatchInRange(e,0,r);return i||(i=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),i&&(i.from!=r||i.to!=n)?i:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,r){let n=uu(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=r)return null;i.push(n.value)}return i}highlight(e,r,n,i){let a=uu(this.spec,e,Math.max(0,r-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!a.next().done;)i(a.value.from,a.value.to)}}function Aue(t,e,r){return(n,i,a)=>(!r||r(n,i,a))&&t(a[0],e,n,i)}function cu(t,e,r,n){let i;return t.wholeWord&&(i=Oue(e.charCategorizer(e.selection.main.head))),t.test&&(i=Aue(t.test,e,i)),new UF(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:i},r,n)}function Yg(t,e){return t.slice(Wr(t,e,!1),e)}function Xg(t,e){return t.slice(e,Wr(t,e))}function Oue(t){return(e,r,n)=>!n[0].length||(t(Yg(n.input,n.index))!=cr.Word||t(Xg(n.input,n.index))!=cr.Word)&&(t(Xg(n.input,n.index+n[0].length))!=cr.Word||t(Yg(n.input,n.index+n[0].length))!=cr.Word)}class Mue extends YF{nextMatch(e,r,n){let i=cu(this.spec,e,n,e.doc.length).next();return i.done&&(i=cu(this.spec,e,0,r).next()),i.done?null:i.value}prevMatchInRange(e,r,n){for(let i=1;;i++){let a=Math.max(r,n-i*1e4),s=cu(this.spec,e,a,n),l=null;for(;!s.next().done;)l=s.value;if(l&&(a==r||l.from>a+10))return l;if(a==r)return null}}prevMatch(e,r,n){return this.prevMatchInRange(e,0,r)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(r,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let i=n.length;i>0;i--){let a=+n.slice(0,i);if(a>0&&a<e.match.length)return e.match[a]+n.slice(i)}return r})}matchAll(e,r){let n=cu(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=r)return null;i.push(n.value)}return i}highlight(e,r,n,i){let a=cu(this.spec,e,Math.max(0,r-250),Math.min(n+250,e.doc.length));for(;!a.next().done;)i(a.value.from,a.value.to)}}const ah=yt.define(),tA=yt.define(),$s=Sn.define({create(t){return new FC(mT(t).create(),null)},update(t,e){for(let r of e.effects)r.is(ah)?t=new FC(r.value.create(),t.panel):r.is(tA)&&(t=new FC(t.query,r.value?rA:null));return t},provide:t=>th.from(t,e=>e.panel)});class FC{constructor(e,r){this.query=e,this.panel=r}}const Rue=ut.mark({class:"cm-searchMatch"}),Due=ut.mark({class:"cm-searchMatch cm-searchMatch-selected"}),_ue=mr.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field($s))}update(t){let e=t.state.field($s);(e!=t.startState.field($s)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return ut.none;let{view:r}=this,n=new Wa;for(let i=0,a=r.visibleRanges,s=a.length;i<s;i++){let{from:l,to:o}=a[i];for(;i<s-1&&o>a[i+1].from-500;)o=a[++i].to;t.highlight(r.state,l,o,(c,h)=>{let d=r.state.selection.ranges.some(g=>g.from==c&&g.to==h);n.add(c,h,d?Due:Rue)})}return n.finish()}},{decorations:t=>t.decorations});function Ph(t){return e=>{let r=e.state.field($s,!1);return r&&r.query.spec.valid?t(e,r):QF(e)}}const Wg=Ph((t,{query:e})=>{let{to:r}=t.state.selection.main,n=e.nextMatch(t.state,r,r);if(!n)return!1;let i=Ae.single(n.from,n.to),a=t.state.facet(ic);return t.dispatch({selection:i,effects:[nA(t,n),a.scrollToMatch(i.main,t)],userEvent:"select.search"}),WF(t),!0}),Qg=Ph((t,{query:e})=>{let{state:r}=t,{from:n}=r.selection.main,i=e.prevMatch(r,n,n);if(!i)return!1;let a=Ae.single(i.from,i.to),s=t.state.facet(ic);return t.dispatch({selection:a,effects:[nA(t,i),s.scrollToMatch(a.main,t)],userEvent:"select.search"}),WF(t),!0}),Nue=Ph((t,{query:e})=>{let r=e.matchAll(t.state,1e3);return!r||!r.length?!1:(t.dispatch({selection:Ae.create(r.map(n=>Ae.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),Bue=({state:t,dispatch:e})=>{let r=t.selection;if(r.ranges.length>1||r.main.empty)return!1;let{from:n,to:i}=r.main,a=[],s=0;for(let l=new Vu(t.doc,t.sliceDoc(n,i));!l.next().done;){if(a.length>1e3)return!1;l.value.from==n&&(s=a.length),a.push(Ae.range(l.value.from,l.value.to))}return e(t.update({selection:Ae.create(a,s),userEvent:"select.search.matches"})),!0},Qz=Ph((t,{query:e})=>{let{state:r}=t,{from:n,to:i}=r.selection.main;if(r.readOnly)return!1;let a=e.nextMatch(r,n,n);if(!a)return!1;let s=a,l=[],o,c,h=[];s.from==n&&s.to==i&&(c=r.toText(e.getReplacement(s)),l.push({from:s.from,to:s.to,insert:c}),s=e.nextMatch(r,s.from,s.to),h.push(Ue.announce.of(r.phrase("replaced match on line $",r.doc.lineAt(n).number)+".")));let d=t.state.changes(l);return s&&(o=Ae.single(s.from,s.to).map(d),h.push(nA(t,s)),h.push(r.facet(ic).scrollToMatch(o.main,t))),t.dispatch({changes:d,selection:o,effects:h,userEvent:"input.replace"}),!0}),Lue=Ph((t,{query:e})=>{if(t.state.readOnly)return!1;let r=e.matchAll(t.state,1e9).map(i=>{let{from:a,to:s}=i;return{from:a,to:s,insert:e.getReplacement(i)}});if(!r.length)return!1;let n=t.state.phrase("replaced $ matches",r.length)+".";return t.dispatch({changes:r,effects:Ue.announce.of(n),userEvent:"input.replace.all"}),!0});function rA(t){return t.state.facet(ic).createPanel(t)}function mT(t,e){var r,n,i,a,s;let l=t.selection.main,o=l.empty||l.to>l.from+100?"":t.sliceDoc(l.from,l.to);if(e&&!o)return e;let c=t.facet(ic);return new GF({search:((r=e?.literal)!==null&&r!==void 0?r:c.literal)?o:o.replace(/\n/g,"\\n"),caseSensitive:(n=e?.caseSensitive)!==null&&n!==void 0?n:c.caseSensitive,literal:(i=e?.literal)!==null&&i!==void 0?i:c.literal,regexp:(a=e?.regexp)!==null&&a!==void 0?a:c.regexp,wholeWord:(s=e?.wholeWord)!==null&&s!==void 0?s:c.wholeWord})}function XF(t){let e=VE(t,rA);return e&&e.dom.querySelector("[main-field]")}function WF(t){let e=XF(t);e&&e==t.root.activeElement&&e.select()}const QF=t=>{let e=t.state.field($s,!1);if(e&&e.panel){let r=XF(t);if(r&&r!=t.root.activeElement){let n=mT(t.state,e.query.spec);n.valid&&t.dispatch({effects:ah.of(n)}),r.focus(),r.select()}}else t.dispatch({effects:[tA.of(!0),e?ah.of(mT(t.state,e.query.spec)):yt.appendConfig.of(que)]});return!0},KF=t=>{let e=t.state.field($s,!1);if(!e||!e.panel)return!1;let r=VE(t,rA);return r&&r.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:tA.of(!1)}),!0},Pue=[{key:"Mod-f",run:QF,scope:"editor search-panel"},{key:"F3",run:Wg,shift:Qg,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Wg,shift:Qg,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:KF,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Bue},{key:"Mod-Alt-g",run:hue},{key:"Mod-d",run:Cue,preventDefault:!0}];class zue{constructor(e){this.view=e;let r=this.query=e.state.field($s).query.spec;this.commit=this.commit.bind(this),this.searchField=Wt("input",{value:r.search,placeholder:li(e,"Find"),"aria-label":li(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Wt("input",{value:r.replace,placeholder:li(e,"Replace"),"aria-label":li(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Wt("input",{type:"checkbox",name:"case",form:"",checked:r.caseSensitive,onchange:this.commit}),this.reField=Wt("input",{type:"checkbox",name:"re",form:"",checked:r.regexp,onchange:this.commit}),this.wordField=Wt("input",{type:"checkbox",name:"word",form:"",checked:r.wholeWord,onchange:this.commit});function n(i,a,s){return Wt("button",{class:"cm-button",name:i,onclick:a,type:"button"},s)}this.dom=Wt("div",{onkeydown:i=>this.keydown(i),class:"cm-search"},[this.searchField,n("next",()=>Wg(e),[li(e,"next")]),n("prev",()=>Qg(e),[li(e,"previous")]),n("select",()=>Nue(e),[li(e,"all")]),Wt("label",null,[this.caseField,li(e,"match case")]),Wt("label",null,[this.reField,li(e,"regexp")]),Wt("label",null,[this.wordField,li(e,"by word")]),...e.state.readOnly?[]:[Wt("br"),this.replaceField,n("replace",()=>Qz(e),[li(e,"replace")]),n("replaceAll",()=>Lue(e),[li(e,"replace all")])],Wt("button",{name:"close",onclick:()=>KF(e),"aria-label":li(e,"close"),type:"button"},["×"])])}commit(){let e=new GF({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:ah.of(e)}))}keydown(e){Fae(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Qg:Wg)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Qz(this.view))}update(e){for(let r of e.transactions)for(let n of r.effects)n.is(ah)&&!n.value.eq(this.query)&&this.setQuery(n.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(ic).top}}function li(t,e){return t.state.phrase(e)}const Dp=30,_p=/[\s\.,:;?!]/;function nA(t,{from:e,to:r}){let n=t.state.doc.lineAt(e),i=t.state.doc.lineAt(r).to,a=Math.max(n.from,e-Dp),s=Math.min(i,r+Dp),l=t.state.sliceDoc(a,s);if(a!=n.from){for(let o=0;o<Dp;o++)if(!_p.test(l[o+1])&&_p.test(l[o])){l=l.slice(o);break}}if(s!=i){for(let o=l.length-1;o>l.length-Dp;o--)if(!_p.test(l[o-1])&&_p.test(l[o])){l=l.slice(0,o);break}}return Ue.announce.of(`${t.state.phrase("current match")}. ${l} ${t.state.phrase("on line")} ${n.number}.`)}const Iue=Ue.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"}}),que=[$s,po.low(_ue),Iue];class ZF{constructor(e,r,n,i){this.state=e,this.pos=r,this.explicit=n,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let r=bn(this.state).resolveInner(this.pos,-1);for(;r&&e.indexOf(r.name)<0;)r=r.parent;return r?{from:r.from,to:this.pos,text:this.state.sliceDoc(r.from,this.pos),type:r.type}:null}matchBefore(e){let r=this.state.doc.lineAt(this.pos),n=Math.max(r.from,this.pos-250),i=r.text.slice(n-r.from,this.pos-r.from),a=i.search(JF(e,!1));return a<0?null:{from:n+a,to:this.pos,text:i.slice(a)}}get aborted(){return this.abortListeners==null}addEventListener(e,r,n){e=="abort"&&this.abortListeners&&(this.abortListeners.push(r),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function Kz(t){let e=Object.keys(t).join(""),r=/\w/.test(e);return r&&(e=e.replace(/\w/g,"")),`[${r?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function jue(t){let e=Object.create(null),r=Object.create(null);for(let{label:i}of t){e[i[0]]=!0;for(let a=1;a<i.length;a++)r[i[a]]=!0}let n=Kz(e)+Kz(r)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function Fue(t){let e=t.map(i=>typeof i=="string"?{label:i}:i),[r,n]=e.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:jue(e);return i=>{let a=i.matchBefore(n);return a||i.explicit?{from:a?a.from:i.pos,options:e,validFor:r}:null}}class Zz{constructor(e,r,n,i){this.completion=e,this.source=r,this.match=n,this.score=i}}function Wl(t){return t.selection.main.from}function JF(t,e){var r;let{source:n}=t,i=e&&n[0]!="^",a=n[n.length-1]!="$";return!i&&!a?t:new RegExp(`${i?"^":""}(?:${n})${a?"$":""}`,(r=t.flags)!==null&&r!==void 0?r:t.ignoreCase?"i":"")}const eH=ma.define();function Hue(t,e,r,n){let{main:i}=t.selection,a=r-i.from,s=n-i.from;return{...t.changeByRange(l=>{if(l!=i&&r!=n&&t.sliceDoc(l.from+a,l.from+s)!=t.sliceDoc(r,n))return{range:l};let o=t.toText(e);return{changes:{from:l.from+a,to:n==i.from?l.to:l.from+s,insert:o},range:Ae.cursor(l.from+a+o.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const Jz=new WeakMap;function Vue(t){if(!Array.isArray(t))return t;let e=Jz.get(t);return e||Jz.set(t,e=Fue(t)),e}const Kg=yt.define(),sh=yt.define();class Uue{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let r=0;r<e.length;){let n=Vn(e,r),i=aa(n);this.chars.push(n);let a=e.slice(r,r+i),s=a.toUpperCase();this.folded.push(Vn(s==a?a.toLowerCase():s,0)),r+=i}this.astral=e.length!=this.chars.length}ret(e,r){return this.score=e,this.matched=r,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:r,folded:n,any:i,precise:a,byWord:s}=this;if(r.length==1){let S=Vn(e,0),k=aa(S),E=k==e.length?0:-100;if(S!=r[0])if(S==n[0])E+=-200;else return null;return this.ret(E,[0,k])}let l=e.indexOf(this.pattern);if(l==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let o=r.length,c=0;if(l<0){for(let S=0,k=Math.min(e.length,200);S<k&&c<o;){let E=Vn(e,S);(E==r[c]||E==n[c])&&(i[c++]=S),S+=aa(E)}if(c<o)return null}let h=0,d=0,g=!1,m=0,y=-1,x=-1,b=/[a-z]/.test(e),w=!0;for(let S=0,k=Math.min(e.length,200),E=0;S<k&&d<o;){let M=Vn(e,S);l<0&&(h<o&&M==r[h]&&(a[h++]=S),m<o&&(M==r[m]||M==n[m]?(m==0&&(y=S),x=S+1,m++):m=0));let R,O=M<255?M>=48&&M<=57||M>=97&&M<=122?2:M>=65&&M<=90?1:0:(R=TE(M))!=R.toLowerCase()?1:R!=R.toUpperCase()?2:0;(!S||O==1&&b||E==0&&O!=0)&&(r[d]==M||n[d]==M&&(g=!0)?s[d++]=S:s.length&&(w=!1)),E=O,S+=aa(M)}return d==o&&s[0]==0&&w?this.result(-100+(g?-200:0),s,e):m==o&&y==0?this.ret(-200-e.length+(x==e.length?0:-100),[0,x]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):m==o?this.ret(-900-e.length,[y,x]):d==o?this.result(-100+(g?-200:0)+-700+(w?0:-1100),s,e):r.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,e)}result(e,r,n){let i=[],a=0;for(let s of r){let l=s+(this.astral?aa(Vn(n,s)):1);a&&i[a-1]==s?i[a-1]=l:(i[a++]=s,i[a++]=l)}return this.ret(e-n.length,i)}}class $ue{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let r=e.slice(0,this.pattern.length),n=r==this.pattern?0:r.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,r.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}const Xr=We.define({combine(t){return ya(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Gue,filterStrict:!1,compareCompletions:(e,r)=>(e.sortText||e.label).localeCompare(r.sortText||r.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,r)=>e&&r,closeOnBlur:(e,r)=>e&&r,icons:(e,r)=>e&&r,tooltipClass:(e,r)=>n=>eI(e(n),r(n)),optionClass:(e,r)=>n=>eI(e(n),r(n)),addToOptions:(e,r)=>e.concat(r),filterStrict:(e,r)=>e||r})}});function eI(t,e){return t?e?t+" "+e:t:e}function Gue(t,e,r,n,i,a){let s=t.textDirection==Jt.RTL,l=s,o=!1,c="top",h,d,g=e.left-i.left,m=i.right-e.right,y=n.right-n.left,x=n.bottom-n.top;if(l&&g<Math.min(y,m)?l=!1:!l&&m<Math.min(y,g)&&(l=!0),y<=(l?g:m))h=Math.max(i.top,Math.min(r.top,i.bottom-x))-e.top,d=Math.min(400,l?g:m);else{o=!0,d=Math.min(400,(s?e.right:i.right-e.left)-30);let S=i.bottom-e.bottom;S>=x||S>e.top?h=r.bottom-e.top:(c="bottom",h=e.bottom-r.top)}let b=(e.bottom-e.top)/a.offsetHeight,w=(e.right-e.left)/a.offsetWidth;return{style:`${c}: ${h/b}px; max-width: ${d/w}px`,class:"cm-completionInfo-"+(o?s?"left-narrow":"right-narrow":l?"left":"right")}}const iA=yt.define();function Yue(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(r){let n=document.createElement("div");return n.classList.add("cm-completionIcon"),r.type&&n.classList.add(...r.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render(r,n,i,a){let s=document.createElement("span");s.className="cm-completionLabel";let l=r.displayLabel||r.label,o=0;for(let c=0;c<a.length;){let h=a[c++],d=a[c++];h>o&&s.appendChild(document.createTextNode(l.slice(o,h)));let g=s.appendChild(document.createElement("span"));g.appendChild(document.createTextNode(l.slice(h,d))),g.className="cm-completionMatchedText",o=d}return o<l.length&&s.appendChild(document.createTextNode(l.slice(o))),s},position:50},{render(r){if(!r.detail)return null;let n=document.createElement("span");return n.className="cm-completionDetail",n.textContent=r.detail,n},position:80}),e.sort((r,n)=>r.position-n.position).map(r=>r.render)}function HC(t,e,r){if(t<=r)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let i=Math.floor(e/r);return{from:i*r,to:(i+1)*r}}let n=Math.floor((t-e)/r);return{from:t-(n+1)*r,to:t-n*r}}class Xue{constructor(e,r,n){this.view=e,this.stateField=r,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:o=>this.placeInfo(o),key:this},this.space=null,this.currentClass="";let i=e.state.field(r),{options:a,selected:s}=i.open,l=e.state.facet(Xr);this.optionContent=Yue(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=HC(a.length,s,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",o=>{let{options:c}=e.state.field(r).open;for(let h=o.target,d;h&&h!=this.dom;h=h.parentNode)if(h.nodeName=="LI"&&(d=/-(\d+)$/.exec(h.id))&&+d[1]<c.length){this.applyCompletion(e,c[+d[1]]),o.preventDefault();return}if(o.target==this.list){let h=this.list.classList.contains("cm-completionListIncompleteTop")&&o.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&o.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;h!=null&&(e.dispatch({effects:iA.of(h)}),o.preventDefault())}}),this.dom.addEventListener("focusout",o=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(Xr).closeOnBlur&&o.relatedTarget!=e.contentDOM&&e.dispatch({effects:sh.of(null)})}),this.showOptions(a,i.id)}mount(){this.updateSel()}showOptions(e,r){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,r,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var r;let n=e.state.field(this.stateField),i=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=i){let{options:a,selected:s,disabled:l}=n.open;(!i.open||i.open.options!=a)&&(this.range=HC(a.length,s,e.state.facet(Xr).maxRenderedOptions),this.showOptions(a,n.id)),this.updateSel(),l!=((r=i.open)===null||r===void 0?void 0:r.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let r=this.tooltipClass(e);if(r!=this.currentClass){for(let n of this.currentClass.split(" "))n&&this.dom.classList.remove(n);for(let n of r.split(" "))n&&this.dom.classList.add(n);this.currentClass=r}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),r=e.open;(r.selected>-1&&r.selected<this.range.from||r.selected>=this.range.to)&&(this.range=HC(r.options.length,r.selected,this.view.state.facet(Xr).maxRenderedOptions),this.showOptions(r.options,e.id));let n=this.updateSelectedOption(r.selected);if(n){this.destroyInfo();let{completion:i}=r.options[r.selected],{info:a}=i;if(!a)return;let s=typeof a=="string"?document.createTextNode(a):a(i);if(!s)return;"then"in s?s.then(l=>{l&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(l,i)}).catch(l=>Xn(this.view.state,l,"completion info")):(this.addInfoPane(s,i),n.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,r){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",n.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:i,destroy:a}=e;n.appendChild(i),this.infoDestroy=a||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let r=null;for(let n=this.list.firstChild,i=this.range.from;n;n=n.nextSibling,i++)n.nodeName!="LI"||!n.id?i--:i==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),r=n):n.hasAttribute("aria-selected")&&(n.removeAttribute("aria-selected"),n.removeAttribute("aria-describedby"));return r&&Que(this.list,r),r}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let r=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),i=e.getBoundingClientRect(),a=this.space;if(!a){let s=this.dom.ownerDocument.documentElement;a={left:0,top:0,right:s.clientWidth,bottom:s.clientHeight}}return i.top>Math.min(a.bottom,r.bottom)-10||i.bottom<Math.max(a.top,r.top)+10?null:this.view.state.facet(Xr).positionInfo(this.view,r,i,n,a,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,r,n){const i=document.createElement("ul");i.id=r,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",s=>{s.target==i&&s.preventDefault()});let a=null;for(let s=n.from;s<n.to;s++){let{completion:l,match:o}=e[s],{section:c}=l;if(c){let g=typeof c=="string"?c:c.name;if(g!=a&&(s>n.from||n.from==0))if(a=g,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let m=i.appendChild(document.createElement("completion-section"));m.textContent=g}}const h=i.appendChild(document.createElement("li"));h.id=r+"-"+s,h.setAttribute("role","option");let d=this.optionClass(l);d&&(h.className=d);for(let g of this.optionContent){let m=g(l,this.view.state,this.view,o);m&&h.appendChild(m)}}return n.from&&i.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function Wue(t,e){return r=>new Xue(r,t,e)}function Que(t,e){let r=t.getBoundingClientRect(),n=e.getBoundingClientRect(),i=r.height/t.offsetHeight;n.top<r.top?t.scrollTop-=(r.top-n.top)/i:n.bottom>r.bottom&&(t.scrollTop+=(n.bottom-r.bottom)/i)}function tI(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function Kue(t,e){let r=[],n=null,i=null,a=h=>{r.push(h);let{section:d}=h.completion;if(d){n||(n=[]);let g=typeof d=="string"?d:d.name;n.some(m=>m.name==g)||n.push(typeof d=="string"?{name:g}:d)}},s=e.facet(Xr);for(let h of t)if(h.hasResult()){let d=h.result.getMatch;if(h.result.filter===!1)for(let g of h.result.options)a(new Zz(g,h.source,d?d(g):[],1e9-r.length));else{let g=e.sliceDoc(h.from,h.to),m,y=s.filterStrict?new $ue(g):new Uue(g);for(let x of h.result.options)if(m=y.match(x.label)){let b=x.displayLabel?d?d(x,m.matched):[]:m.matched,w=m.score+(x.boost||0);if(a(new Zz(x,h.source,b,w)),typeof x.section=="object"&&x.section.rank==="dynamic"){let{name:S}=x.section;i||(i=Object.create(null)),i[S]=Math.max(w,i[S]||-1e9)}}}}if(n){let h=Object.create(null),d=0,g=(m,y)=>(m.rank==="dynamic"&&y.rank==="dynamic"?i[y.name]-i[m.name]:0)||(typeof m.rank=="number"?m.rank:1e9)-(typeof y.rank=="number"?y.rank:1e9)||(m.name<y.name?-1:1);for(let m of n.sort(g))d-=1e5,h[m.name]=d;for(let m of r){let{section:y}=m.completion;y&&(m.score+=h[typeof y=="string"?y:y.name])}}let l=[],o=null,c=s.compareCompletions;for(let h of r.sort((d,g)=>g.score-d.score||c(d.completion,g.completion))){let d=h.completion;!o||o.label!=d.label||o.detail!=d.detail||o.type!=null&&d.type!=null&&o.type!=d.type||o.apply!=d.apply||o.boost!=d.boost?l.push(h):tI(h.completion)>tI(o)&&(l[l.length-1]=h),o=h.completion}return l}class xu{constructor(e,r,n,i,a,s){this.options=e,this.attrs=r,this.tooltip=n,this.timestamp=i,this.selected=a,this.disabled=s}setSelected(e,r){return e==this.selected||e>=this.options.length?this:new xu(this.options,rI(r,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,r,n,i,a,s){if(i&&!s&&e.some(c=>c.isPending))return i.setDisabled();let l=Kue(e,r);if(!l.length)return i&&e.some(c=>c.isPending)?i.setDisabled():null;let o=r.facet(Xr).selectOnOpen?0:-1;if(i&&i.selected!=o&&i.selected!=-1){let c=i.options[i.selected].completion;for(let h=0;h<l.length;h++)if(l[h].completion==c){o=h;break}}return new xu(l,rI(n,o),{pos:e.reduce((c,h)=>h.hasResult()?Math.min(c,h.from):c,1e8),create:nce,above:a.aboveCursor},i?i.timestamp:Date.now(),o,!1)}map(e){return new xu(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new xu(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Zg{constructor(e,r,n){this.active=e,this.id=r,this.open=n}static start(){return new Zg(tce,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:r}=e,n=r.facet(Xr),a=(n.override||r.languageDataAt("autocomplete",Wl(r)).map(Vue)).map(o=>(this.active.find(h=>h.source==o)||new Ai(o,this.active.some(h=>h.state!=0)?1:0)).update(e,n));a.length==this.active.length&&a.every((o,c)=>o==this.active[c])&&(a=this.active);let s=this.open,l=e.effects.some(o=>o.is(aA));s&&e.docChanged&&(s=s.map(e.changes)),e.selection||a.some(o=>o.hasResult()&&e.changes.touchesRange(o.from,o.to))||!Zue(a,this.active)||l?s=xu.build(a,r,this.id,s,n,l):s&&s.disabled&&!a.some(o=>o.isPending)&&(s=null),!s&&a.every(o=>!o.isPending)&&a.some(o=>o.hasResult())&&(a=a.map(o=>o.hasResult()?new Ai(o.source,0):o));for(let o of e.effects)o.is(iA)&&(s=s&&s.setSelected(o.value,this.id));return a==this.active&&s==this.open?this:new Zg(a,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Jue:ece}}function Zue(t,e){if(t==e)return!0;for(let r=0,n=0;;){for(;r<t.length&&!t[r].hasResult();)r++;for(;n<e.length&&!e[n].hasResult();)n++;let i=r==t.length,a=n==e.length;if(i||a)return i==a;if(t[r++].result!=e[n++].result)return!1}}const Jue={"aria-autocomplete":"list"},ece={};function rI(t,e){let r={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(r["aria-activedescendant"]=t+"-"+e),r}const tce=[];function tH(t,e){if(t.isUserEvent("input.complete")){let n=t.annotation(eH);if(n&&e.activateOnCompletion(n))return 12}let r=t.isUserEvent("input.type");return r&&e.activateOnTyping?5:r?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class Ai{constructor(e,r,n=!1){this.source=e,this.state=r,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(e,r){let n=tH(e,r),i=this;(n&8||n&16&&this.touches(e))&&(i=new Ai(i.source,0)),n&4&&i.state==0&&(i=new Ai(this.source,1)),i=i.updateFor(e,n);for(let a of e.effects)if(a.is(Kg))i=new Ai(i.source,1,a.value);else if(a.is(sh))i=new Ai(i.source,0);else if(a.is(aA))for(let s of a.value)s.source==i.source&&(i=s);return i}updateFor(e,r){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Wl(e.state))}}class Du extends Ai{constructor(e,r,n,i,a,s){super(e,3,r),this.limit=n,this.result=i,this.from=a,this.to=s}hasResult(){return!0}updateFor(e,r){var n;if(!(r&3))return this.map(e.changes);let i=this.result;i.map&&!e.changes.empty&&(i=i.map(i,e.changes));let a=e.changes.mapPos(this.from),s=e.changes.mapPos(this.to,1),l=Wl(e.state);if(l>s||!i||r&2&&(Wl(e.startState)==this.from||l<this.limit))return new Ai(this.source,r&4?1:0);let o=e.changes.mapPos(this.limit);return rce(i.validFor,e.state,a,s)?new Du(this.source,this.explicit,o,i,a,s):i.update&&(i=i.update(i,a,s,new ZF(e.state,l,!1)))?new Du(this.source,this.explicit,o,i,i.from,(n=i.to)!==null&&n!==void 0?n:Wl(e.state)):new Ai(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new Du(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new Ai(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function rce(t,e,r,n){if(!t)return!1;let i=e.sliceDoc(r,n);return typeof t=="function"?t(i,r,n,e):JF(t,!0).test(i)}const aA=yt.define({map(t,e){return t.map(r=>r.map(e))}}),Un=Sn.define({create(){return Zg.start()},update(t,e){return t.update(e)},provide:t=>[HE.from(t,e=>e.tooltip),Ue.contentAttributes.from(t,e=>e.attrs)]});function sA(t,e){const r=e.completion.apply||e.completion.label;let n=t.state.field(Un).active.find(i=>i.source==e.source);return n instanceof Du?(typeof r=="string"?t.dispatch({...Hue(t.state,r,n.from,n.to),annotations:eH.of(e.completion)}):r(t,e.completion,n.from,n.to),!0):!1}const nce=Wue(Un,sA);function Np(t,e="option"){return r=>{let n=r.state.field(Un,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<r.state.facet(Xr).interactionDelay)return!1;let i=1,a;e=="page"&&(a=B9(r,n.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector("li").offsetHeight)-1));let{length:s}=n.open.options,l=n.open.selected>-1?n.open.selected+i*(t?1:-1):t?0:s-1;return l<0?l=e=="page"?0:s-1:l>=s&&(l=e=="page"?s-1:0),r.dispatch({effects:iA.of(l)}),!0}}const ice=t=>{let e=t.state.field(Un,!1);return t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(Xr).interactionDelay?!1:sA(t,e.open.options[e.open.selected])},VC=t=>t.state.field(Un,!1)?(t.dispatch({effects:Kg.of(!0)}),!0):!1,ace=t=>{let e=t.state.field(Un,!1);return!e||!e.active.some(r=>r.state!=0)?!1:(t.dispatch({effects:sh.of(null)}),!0)};class sce{constructor(e,r){this.active=e,this.context=r,this.time=Date.now(),this.updates=[],this.done=void 0}}const lce=50,oce=1e3,uce=mr.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(Un).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(Un),r=t.state.facet(Xr);if(!t.selectionSet&&!t.docChanged&&t.startState.field(Un)==e)return;let n=t.transactions.some(a=>{let s=tH(a,r);return s&8||(a.selection||a.docChanged)&&!(s&3)});for(let a=0;a<this.running.length;a++){let s=this.running[a];if(n||s.context.abortOnDocChange&&t.docChanged||s.updates.length+t.transactions.length>lce&&Date.now()-s.time>oce){for(let l of s.context.abortListeners)try{l()}catch(o){Xn(this.view.state,o)}s.context.abortListeners=null,this.running.splice(a--,1)}else s.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(a=>a.effects.some(s=>s.is(Kg)))&&(this.pendingStart=!0);let i=this.pendingStart?50:r.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(a=>a.isPending&&!this.running.some(s=>s.active.source==a.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let a of t.transactions)a.isUserEvent("input.type")?this.composing=2:this.composing==2&&a.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(Un);for(let r of e.active)r.isPending&&!this.running.some(n=>n.active.source==r.source)&&this.startQuery(r);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Xr).updateSyncTime))}startQuery(t){let{state:e}=this.view,r=Wl(e),n=new ZF(e,r,t.explicit,this.view),i=new sce(t,n);this.running.push(i),Promise.resolve(t.source(n)).then(a=>{i.context.aborted||(i.done=a||null,this.scheduleAccept())},a=>{this.view.dispatch({effects:sh.of(null)}),Xn(this.view.state,a)})}scheduleAccept(){this.running.every(t=>t.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Xr).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],r=this.view.state.facet(Xr),n=this.view.state.field(Un);for(let i=0;i<this.running.length;i++){let a=this.running[i];if(a.done===void 0)continue;if(this.running.splice(i--,1),a.done){let l=Wl(a.updates.length?a.updates[0].startState:this.view.state),o=Math.min(l,a.done.from+(a.active.explicit?0:1)),c=new Du(a.active.source,a.active.explicit,o,a.done,a.done.from,(t=a.done.to)!==null&&t!==void 0?t:l);for(let h of a.updates)c=c.update(h,r);if(c.hasResult()){e.push(c);continue}}let s=n.active.find(l=>l.source==a.active.source);if(s&&s.isPending)if(a.done==null){let l=new Ai(a.active.source,0);for(let o of a.updates)l=l.update(o,r);l.isPending||e.push(l)}else this.startQuery(s)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:aA.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(Un,!1);if(e&&e.tooltip&&this.view.state.facet(Xr).closeOnBlur){let r=e.open&&B9(this.view,e.open.tooltip);(!r||!r.dom.contains(t.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:sh.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Kg.of(!1)}),20),this.composing=0}}}),cce=typeof navigator=="object"&&/Win/.test(navigator.platform),fce=po.highest(Ue.domEventHandlers({keydown(t,e){let r=e.state.field(Un,!1);if(!r||!r.open||r.open.disabled||r.open.selected<0||t.key.length>1||t.ctrlKey&&!(cce&&t.altKey)||t.metaKey)return!1;let n=r.open.options[r.open.selected],i=r.active.find(s=>s.source==n.source),a=n.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(t.key)>-1&&sA(e,n),!1}})),hce=Ue.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),lh={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},$l=yt.define({map(t,e){let r=e.mapPos(t,-1,On.TrackAfter);return r??void 0}}),lA=new class extends Js{};lA.startSide=1;lA.endSide=-1;const rH=Sn.define({create(){return Et.empty},update(t,e){if(t=t.map(e.changes),e.selection){let r=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:n=>n>=r.from&&n<=r.to})}for(let r of e.effects)r.is($l)&&(t=t.update({add:[lA.range(r.value,r.value+1)]}));return t}});function dce(){return[gce,rH]}const UC="()[]{}<>«»»«[]{}";function nH(t){for(let e=0;e<UC.length;e+=2)if(UC.charCodeAt(e)==t)return UC.charAt(e+1);return TE(t<128?t:t+1)}function iH(t,e){return t.languageDataAt("closeBrackets",e)[0]||lh}const pce=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),gce=Ue.inputHandler.of((t,e,r,n)=>{if((pce?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let i=t.state.selection.main;if(n.length>2||n.length==2&&aa(Vn(n,0))==1||e!=i.from||r!=i.to)return!1;let a=yce(t.state,n);return a?(t.dispatch(a),!0):!1}),vce=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=iH(t,t.selection.main.head).brackets||lh.brackets,i=null,a=t.changeByRange(s=>{if(s.empty){let l=bce(t.doc,s.head);for(let o of n)if(o==l&&em(t.doc,s.head)==nH(Vn(o,0)))return{changes:{from:s.head-o.length,to:s.head+o.length},range:Ae.cursor(s.head-o.length)}}return{range:i=s}});return i||e(t.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},mce=[{key:"Backspace",run:vce}];function yce(t,e){let r=iH(t,t.selection.main.head),n=r.brackets||lh.brackets;for(let i of n){let a=nH(Vn(i,0));if(e==i)return a==i?Sce(t,i,n.indexOf(i+i+i)>-1,r):xce(t,i,a,r.before||lh.before);if(e==a&&aH(t,t.selection.main.from))return wce(t,i,a)}return null}function aH(t,e){let r=!1;return t.field(rH).between(0,t.doc.length,n=>{n==e&&(r=!0)}),r}function em(t,e){let r=t.sliceString(e,e+2);return r.slice(0,aa(Vn(r,0)))}function bce(t,e){let r=t.sliceString(e-2,e);return aa(Vn(r,0))==r.length?r:r.slice(1)}function xce(t,e,r,n){let i=null,a=t.changeByRange(s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:r,from:s.to}],effects:$l.of(s.to+e.length),range:Ae.range(s.anchor+e.length,s.head+e.length)};let l=em(t.doc,s.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+r,from:s.head},effects:$l.of(s.head+e.length),range:Ae.cursor(s.head+e.length)}:{range:i=s}});return i?null:t.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function wce(t,e,r){let n=null,i=t.changeByRange(a=>a.empty&&em(t.doc,a.head)==r?{changes:{from:a.head,to:a.head+r.length,insert:r},range:Ae.cursor(a.head+r.length)}:n={range:a});return n?null:t.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function Sce(t,e,r,n){let i=n.stringPrefixes||lh.stringPrefixes,a=null,s=t.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:$l.of(l.to+e.length),range:Ae.range(l.anchor+e.length,l.head+e.length)};let o=l.head,c=em(t.doc,o),h;if(c==e){if(nI(t,o))return{changes:{insert:e+e,from:o},effects:$l.of(o+e.length),range:Ae.cursor(o+e.length)};if(aH(t,o)){let g=r&&t.sliceDoc(o,o+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:o,to:o+g.length,insert:g},range:Ae.cursor(o+g.length)}}}else{if(r&&t.sliceDoc(o-2*e.length,o)==e+e&&(h=iI(t,o-2*e.length,i))>-1&&nI(t,h))return{changes:{insert:e+e+e+e,from:o},effects:$l.of(o+e.length),range:Ae.cursor(o+e.length)};if(t.charCategorizer(o)(c)!=cr.Word&&iI(t,o,i)>-1&&!Cce(t,o,e,i))return{changes:{insert:e+e,from:o},effects:$l.of(o+e.length),range:Ae.cursor(o+e.length)}}return{range:a=l}});return a?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function nI(t,e){let r=bn(t).resolveInner(e+1);return r.parent&&r.from==e}function Cce(t,e,r,n){let i=bn(t).resolveInner(e,-1),a=n.reduce((s,l)=>Math.max(s,l.length),0);for(let s=0;s<5;s++){let l=t.sliceDoc(i.from,Math.min(i.to,i.from+r.length+a)),o=l.indexOf(r);if(!o||o>-1&&n.indexOf(l.slice(0,o))>-1){let h=i.firstChild;for(;h&&h.from==i.from&&h.to-h.from>r.length+o;){if(t.sliceDoc(h.to-r.length,h.to)==r)return!1;h=h.firstChild}return!0}let c=i.to==e&&i.parent;if(!c)break;i=c}return!1}function iI(t,e,r){let n=t.charCategorizer(e);if(n(t.sliceDoc(e-1,e))!=cr.Word)return e;for(let i of r){let a=e-i.length;if(t.sliceDoc(a,e)==i&&n(t.sliceDoc(a-1,a))!=cr.Word)return a}return-1}function kce(t={}){return[fce,Un,Xr.of(t),uce,Tce,hce]}const sH=[{key:"Ctrl-Space",run:VC},{mac:"Alt-`",run:VC},{mac:"Alt-i",run:VC},{key:"Escape",run:ace},{key:"ArrowDown",run:Np(!0)},{key:"ArrowUp",run:Np(!1)},{key:"PageDown",run:Np(!0,"page")},{key:"PageUp",run:Np(!1,"page")},{key:"Enter",run:ice}],Tce=po.highest($v.computeN([Xr],t=>t.facet(Xr).defaultKeymap?[sH]:[]));class aI{constructor(e,r,n){this.from=e,this.to=r,this.diagnostic=n}}class ql{constructor(e,r,n){this.diagnostics=e,this.panel=r,this.selected=n}static init(e,r,n){let i=n.facet(oh).markerFilter;i&&(e=i(e,n));let a=e.slice().sort((m,y)=>m.from-y.from||m.to-y.to),s=new Wa,l=[],o=0,c=n.doc.iter(),h=0,d=n.doc.length;for(let m=0;;){let y=m==a.length?null:a[m];if(!y&&!l.length)break;let x,b;if(l.length)x=o,b=l.reduce((k,E)=>Math.min(k,E.to),y&&y.from>x?y.from:1e8);else{if(x=y.from,x>d)break;b=y.to,l.push(y),m++}for(;m<a.length;){let k=a[m];if(k.from==x&&(k.to>k.from||k.to==x))l.push(k),m++,b=Math.min(k.to,b);else{b=Math.min(k.from,b);break}}b=Math.min(b,d);let w=!1;if(l.some(k=>k.from==x&&(k.to==b||b==d))&&(w=x==b,!w&&b-x<10)){let k=x-(h+c.value.length);k>0&&(c.next(k),h=x);for(let E=x;;){if(E>=b){w=!0;break}if(!c.lineBreak&&h+c.value.length>E)break;E=h+c.value.length,h+=c.value.length,c.next()}}let S=Ice(l);if(w)s.add(x,x,ut.widget({widget:new Bce(S),diagnostics:l.slice()}));else{let k=l.reduce((E,M)=>M.markClass?E+" "+M.markClass:E,"");s.add(x,b,ut.mark({class:"cm-lintRange cm-lintRange-"+S+k,diagnostics:l.slice(),inclusiveEnd:l.some(E=>E.to>b)}))}if(o=b,o==d)break;for(let k=0;k<l.length;k++)l[k].to<=o&&l.splice(k--,1)}let g=s.finish();return new ql(g,r,al(g))}}function al(t,e=null,r=0){let n=null;return t.between(r,1e9,(i,a,{spec:s})=>{if(!(e&&s.diagnostics.indexOf(e)<0))if(!n)n=new aI(i,a,e||s.diagnostics[0]);else{if(s.diagnostics.indexOf(n.diagnostic)<0)return!1;n=new aI(n.from,a,n.diagnostic)}}),n}function Ece(t,e){let r=e.pos,n=e.end||r,i=t.state.facet(oh).hideOn(t,r,n);if(i!=null)return i;let a=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(s=>s.is(lH))||t.changes.touchesRange(a.from,Math.max(a.to,n)))}function Ace(t,e){return t.field(ci,!1)?e:e.concat(yt.appendConfig.of(qce))}const lH=yt.define(),oA=yt.define(),oH=yt.define(),ci=Sn.define({create(){return new ql(ut.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let r=t.diagnostics.map(e.changes),n=null,i=t.panel;if(t.selected){let a=e.changes.mapPos(t.selected.from,1);n=al(r,t.selected.diagnostic,a)||al(r,null,a)}!r.size&&i&&e.state.facet(oh).autoPanel&&(i=null),t=new ql(r,i,n)}for(let r of e.effects)if(r.is(lH)){let n=e.state.facet(oh).autoPanel?r.value.length?uh.open:null:t.panel;t=ql.init(r.value,n,e.state)}else r.is(oA)?t=new ql(t.diagnostics,r.value?uh.open:null,t.selected):r.is(oH)&&(t=new ql(t.diagnostics,t.panel,r.value));return t},provide:t=>[th.from(t,e=>e.panel),Ue.decorations.from(t,e=>e.diagnostics)]}),Oce=ut.mark({class:"cm-lintRange cm-lintRange-active"});function Mce(t,e,r){let{diagnostics:n}=t.state.field(ci),i,a=-1,s=-1;n.between(e-(r<0?1:0),e+(r>0?1:0),(o,c,{spec:h})=>{if(e>=o&&e<=c&&(o==c||(e>o||r>0)&&(e<c||r<0)))return i=h.diagnostics,a=o,s=c,!1});let l=t.state.facet(oh).tooltipFilter;return i&&l&&(i=l(i,t.state)),i?{pos:a,end:s,above:t.state.doc.lineAt(a).to<s,create(){return{dom:Rce(t,i)}}}:null}function Rce(t,e){return Wt("ul",{class:"cm-tooltip-lint"},e.map(r=>cH(t,r,!1)))}const Dce=t=>{let e=t.state.field(ci,!1);(!e||!e.panel)&&t.dispatch({effects:Ace(t.state,[oA.of(!0)])});let r=VE(t,uh.open);return r&&r.dom.querySelector(".cm-panel-lint ul").focus(),!0},sI=t=>{let e=t.state.field(ci,!1);return!e||!e.panel?!1:(t.dispatch({effects:oA.of(!1)}),!0)},_ce=t=>{let e=t.state.field(ci,!1);if(!e)return!1;let r=t.state.selection.main,n=al(e.diagnostics,null,r.to+1);return!n&&(n=al(e.diagnostics,null,0),!n||n.from==r.from&&n.to==r.to)?!1:(t.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),!0)},Nce=[{key:"Mod-Shift-m",run:Dce,preventDefault:!0},{key:"F8",run:_ce}],oh=We.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...ya(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:lI,tooltipFilter:lI,needsRefresh:(e,r)=>e?r?n=>e(n)||r(n):e:r,hideOn:(e,r)=>e?r?(n,i,a)=>e(n,i,a)||r(n,i,a):e:r,autoPanel:(e,r)=>e||r})}}});function lI(t,e){return t?e?(r,n)=>e(t(r,n),n):t:e}function uH(t){let e=[];if(t)e:for(let{name:r}of t){for(let n=0;n<r.length;n++){let i=r[n];if(/[a-zA-Z]/.test(i)&&!e.some(a=>a.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function cH(t,e,r){var n;let i=r?uH(e.actions):[];return Wt("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Wt("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(n=e.actions)===null||n===void 0?void 0:n.map((a,s)=>{let l=!1,o=m=>{if(m.preventDefault(),l)return;l=!0;let y=al(t.state.field(ci).diagnostics,e);y&&a.apply(t,y.from,y.to)},{name:c}=a,h=i[s]?c.indexOf(i[s]):-1,d=h<0?c:[c.slice(0,h),Wt("u",c.slice(h,h+1)),c.slice(h+1)],g=a.markClass?" "+a.markClass:"";return Wt("button",{type:"button",class:"cm-diagnosticAction"+g,onclick:o,onmousedown:o,"aria-label":` Action: ${c}${h<0?"":` (access key "${i[s]})"`}.`},d)}),e.source&&Wt("div",{class:"cm-diagnosticSource"},e.source))}class Bce extends ba{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Wt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class oI{constructor(e,r){this.diagnostic=r,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=cH(e,r,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class uh{constructor(e){this.view=e,this.items=[];let r=i=>{if(!(i.ctrlKey||i.altKey||i.metaKey)){if(i.keyCode==27)sI(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:a}=this.items[this.selectedIndex],s=uH(a.actions);for(let l=0;l<s.length;l++)if(s[l].toUpperCase().charCodeAt(0)==i.keyCode){let o=al(this.view.state.field(ci).diagnostics,a);o&&a.actions[l].apply(e,o.from,o.to)}}else return;i.preventDefault()}},n=i=>{for(let a=0;a<this.items.length;a++)this.items[a].dom.contains(i.target)&&this.moveSelection(a)};this.list=Wt("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:r,onclick:n}),this.dom=Wt("div",{class:"cm-panel-lint"},this.list,Wt("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>sI(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(ci).selected;if(!e)return-1;for(let r=0;r<this.items.length;r++)if(this.items[r].diagnostic==e.diagnostic)return r;return-1}update(){let{diagnostics:e,selected:r}=this.view.state.field(ci),n=0,i=!1,a=null,s=new Set;for(e.between(0,this.view.state.doc.length,(l,o,{spec:c})=>{for(let h of c.diagnostics){if(s.has(h))continue;s.add(h);let d=-1,g;for(let m=n;m<this.items.length;m++)if(this.items[m].diagnostic==h){d=m;break}d<0?(g=new oI(this.view,h),this.items.splice(n,0,g),i=!0):(g=this.items[d],d>n&&(this.items.splice(n,d-n),i=!0)),r&&g.diagnostic==r.diagnostic?g.dom.hasAttribute("aria-selected")||(g.dom.setAttribute("aria-selected","true"),a=g):g.dom.hasAttribute("aria-selected")&&g.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();this.items.length==0&&(this.items.push(new oI(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),a?(this.list.setAttribute("aria-activedescendant",a.id),this.view.requestMeasure({key:this,read:()=>({sel:a.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:o})=>{let c=o.height/this.list.offsetHeight;l.top<o.top?this.list.scrollTop-=(o.top-l.top)/c:l.bottom>o.bottom&&(this.list.scrollTop+=(l.bottom-o.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function r(){let n=e;e=n.nextSibling,n.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)r();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)r()}moveSelection(e){if(this.selectedIndex<0)return;let r=this.view.state.field(ci),n=al(r.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:oH.of(n)})}static open(e){return new uh(e)}}function Lce(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function Bp(t){return Lce(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Pce=Ue.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:Bp("#d11")},".cm-lintRange-warning":{backgroundImage:Bp("orange")},".cm-lintRange-info":{backgroundImage:Bp("#999")},".cm-lintRange-hint":{backgroundImage:Bp("#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}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function zce(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function Ice(t){let e="hint",r=1;for(let n of t){let i=zce(n.severity);i>r&&(r=i,e=n.severity)}return e}const qce=[ci,Ue.decorations.compute([ci],t=>{let{selected:e,panel:r}=t.field(ci);return!e||!r||e.from==e.to?ut.none:ut.set([Oce.range(e.from,e.to)])}),Mse(Mce,{hideOn:Ece}),Pce];var uI=function(e){e===void 0&&(e={});var{crosshairCursor:r=!1}=e,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(mce)),e.defaultKeymap!==!1&&(n=n.concat(uue)),e.searchKeymap!==!1&&(n=n.concat(Pue)),e.historyKeymap!==!1&&(n=n.concat(voe)),e.foldKeymap!==!1&&(n=n.concat(Rle)),e.completionKeymap!==!1&&(n=n.concat(sH)),e.lintKeymap!==!1&&(n=n.concat(Nce));var i=[];return e.lineNumbers!==!1&&i.push(Hse()),e.highlightActiveLineGutter!==!1&&i.push($se()),e.highlightSpecialChars!==!1&&i.push(ise()),e.history!==!1&&i.push(loe()),e.foldGutter!==!1&&i.push(Ble()),e.drawSelection!==!1&&i.push(Yae()),e.dropCursor!==!1&&i.push(Zae()),e.allowMultipleSelections!==!1&&i.push(Dt.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&i.push(xle()),e.syntaxHighlighting!==!1&&i.push(lF(Ile,{fallback:!0})),e.bracketMatching!==!1&&i.push($le()),e.closeBrackets!==!1&&i.push(dce()),e.autocompletion!==!1&&i.push(kce()),e.rectangularSelection!==!1&&i.push(yse()),r!==!1&&i.push(wse()),e.highlightActiveLine!==!1&&i.push(cse()),e.highlightSelectionMatches!==!1&&i.push(gue()),e.tabSize&&typeof e.tabSize=="number"&&i.push(Yv.of(" ".repeat(e.tabSize))),i.concat([$v.of(n.flat())]).filter(Boolean)};const jce="#e5c07b",cI="#e06c75",Fce="#56b6c2",Hce="#ffffff",ig="#abb2bf",yT="#7d8799",Vce="#61afef",Uce="#98c379",fI="#d19a66",$ce="#c678dd",Gce="#21252b",hI="#2c313a",dI="#282c34",$C="#353a42",Yce="#3E4451",pI="#528bff",Xce=Ue.theme({"&":{color:ig,backgroundColor:dI},".cm-content":{caretColor:pI},".cm-cursor, .cm-dropCursor":{borderLeftColor:pI},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Yce},".cm-panels":{backgroundColor:Gce,color:ig},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:dI,color:yT,border:"none"},".cm-activeLineGutter":{backgroundColor:hI},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:$C},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:$C,borderBottomColor:$C},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:hI,color:ig}}},{dark:!0}),Wce=Bh.define([{tag:be.keyword,color:$ce},{tag:[be.name,be.deleted,be.character,be.propertyName,be.macroName],color:cI},{tag:[be.function(be.variableName),be.labelName],color:Vce},{tag:[be.color,be.constant(be.name),be.standard(be.name)],color:fI},{tag:[be.definition(be.name),be.separator],color:ig},{tag:[be.typeName,be.className,be.number,be.changed,be.annotation,be.modifier,be.self,be.namespace],color:jce},{tag:[be.operator,be.operatorKeyword,be.url,be.escape,be.regexp,be.link,be.special(be.string)],color:Fce},{tag:[be.meta,be.comment],color:yT},{tag:be.strong,fontWeight:"bold"},{tag:be.emphasis,fontStyle:"italic"},{tag:be.strikethrough,textDecoration:"line-through"},{tag:be.link,color:yT,textDecoration:"underline"},{tag:be.heading,fontWeight:"bold",color:cI},{tag:[be.atom,be.bool,be.special(be.variableName)],color:fI},{tag:[be.processingInstruction,be.string,be.inserted],color:Uce},{tag:be.invalid,color:Hce}]),fH=[Xce,lF(Wce)];var Qce=Ue.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),Kce=function(e){e===void 0&&(e={});var{indentWithTab:r=!0,editable:n=!0,readOnly:i=!1,theme:a="light",placeholder:s="",basicSetup:l=!0}=e,o=[];switch(r&&o.unshift($v.of([cue])),l&&(typeof l=="boolean"?o.unshift(uI()):o.unshift(uI(l))),s&&o.unshift(pse(s)),a){case"light":o.push(Qce);break;case"dark":o.push(fH);break;case"none":break;default:o.push(a);break}return n===!1&&o.push(Ue.editable.of(!1)),i&&o.push(Dt.readOnly.of(!0)),[...o]},Zce=t=>({line:t.state.doc.lineAt(t.state.selection.main.from),lineCount:t.state.doc.lines,lineBreak:t.state.lineBreak,length:t.state.doc.length,readOnly:t.state.readOnly,tabSize:t.state.tabSize,selection:t.state.selection,selectionAsSingle:t.state.selection.asSingle().main,ranges:t.state.selection.ranges,selectionCode:t.state.sliceDoc(t.state.selection.main.from,t.state.selection.main.to),selections:t.state.selection.ranges.map(e=>t.state.sliceDoc(e.from,e.to)),selectedText:t.state.selection.ranges.some(e=>!e.empty)});class Jce{constructor(e,r){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=r,this.timeoutMS=r,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(r=>{try{r()}catch(n){console.error("TimeoutLatch callback error:",n)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class gI{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var GC=null,efe=()=>typeof window>"u"?new gI:(GC||(GC=new gI),GC),vI=ma.define(),tfe=200,rfe=[];function nfe(t){var{value:e,selection:r,onChange:n,onStatistics:i,onCreateEditor:a,onUpdate:s,extensions:l=rfe,autoFocus:o,theme:c="light",height:h=null,minHeight:d=null,maxHeight:g=null,width:m=null,minWidth:y=null,maxWidth:x=null,placeholder:b="",editable:w=!0,readOnly:S=!1,indentWithTab:k=!0,basicSetup:E=!0,root:M,initialState:R}=t,[O,N]=ve.useState(),[B,D]=ve.useState(),[_,P]=ve.useState(),z=ve.useState(()=>({current:null}))[0],H=ve.useState(()=>({current:null}))[0],$=Ue.theme({"&":{height:h,minHeight:d,maxHeight:g,width:m,minWidth:y,maxWidth:x},"& .cm-scroller":{height:"100% !important"}}),q=Ue.updateListener.of(ee=>{if(ee.docChanged&&typeof n=="function"&&!ee.transactions.some(G=>G.annotation(vI))){z.current?z.current.reset():(z.current=new Jce(()=>{if(H.current){var G=H.current;H.current=null,G()}z.current=null},tfe),efe().add(z.current));var te=ee.state.doc,I=te.toString();n(I,ee)}i&&i(Zce(ee))}),V=Kce({theme:c,editable:w,readOnly:S,placeholder:b,indentWithTab:k,basicSetup:E}),X=[q,$,...V];return s&&typeof s=="function"&&X.push(Ue.updateListener.of(s)),X=X.concat(l),ve.useLayoutEffect(()=>{if(O&&!_){var ee={doc:e,selection:r,extensions:X},te=R?Dt.fromJSON(R.json,ee,R.fields):Dt.create(ee);if(P(te),!B){var I=new Ue({state:te,parent:O,root:M});D(I),a&&a(I,te)}}return()=>{B&&(P(void 0),D(void 0))}},[O,_]),ve.useEffect(()=>{t.container&&N(t.container)},[t.container]),ve.useEffect(()=>()=>{B&&(B.destroy(),D(void 0)),z.current&&(z.current.cancel(),z.current=null)},[B]),ve.useEffect(()=>{o&&B&&B.focus()},[o,B]),ve.useEffect(()=>{B&&B.dispatch({effects:yt.reconfigure.of(X)})},[c,l,h,d,g,m,y,x,b,w,S,k,E,n,s]),ve.useEffect(()=>{if(e!==void 0){var ee=B?B.state.doc.toString():"";if(B&&e!==ee){var te=z.current&&!z.current.isDone,I=()=>{B&&e!==B.state.doc.toString()&&B.dispatch({changes:{from:0,to:B.state.doc.toString().length,insert:e||""},annotations:[vI.of(!0)]})};te?H.current=I:I()}}},[e,B]),{state:_,setState:P,view:B,setView:D,container:O,setContainer:N}}var ife=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],hH=ve.forwardRef((t,e)=>{var{className:r,value:n="",selection:i,extensions:a=[],onChange:s,onStatistics:l,onCreateEditor:o,onUpdate:c,autoFocus:h,theme:d="light",height:g,minHeight:m,maxHeight:y,width:x,minWidth:b,maxWidth:w,basicSetup:S,placeholder:k,indentWithTab:E,editable:M,readOnly:R,root:O,initialState:N}=t,B=Bne(t,ife),D=ve.useRef(null),{state:_,view:P,container:z,setContainer:H}=nfe({root:O,value:n,autoFocus:h,theme:d,height:g,minHeight:m,maxHeight:y,width:x,minWidth:b,maxWidth:w,basicSetup:S,placeholder:k,indentWithTab:E,editable:M,readOnly:R,selection:i,onChange:s,onStatistics:l,onCreateEditor:o,onUpdate:c,extensions:a,initialState:N});ve.useImperativeHandle(e,()=>({editor:D.current,state:_,view:P}),[D,z,_,P]);var $=ve.useCallback(V=>{D.current=V,H(V)},[H]);if(typeof n!="string")throw new Error("value must be typeof string but got "+typeof n);var q=typeof d=="string"?"cm-theme-"+d:"cm-theme";return A.jsx("div",Tk({ref:$,className:""+q+(r?" "+r:"")},B))});hH.displayName="CodeMirror";var mI={};class Jg{constructor(e,r,n,i,a,s,l,o,c,h=0,d){this.p=e,this.stack=r,this.state=n,this.reducePos=i,this.pos=a,this.score=s,this.buffer=l,this.bufferBase=o,this.curContext=c,this.lookAhead=h,this.parent=d}toString(){return`[${this.stack.filter((e,r)=>r%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,r,n=0){let i=e.parser.context;return new Jg(e,[],r,n,n,0,[],0,i?new yI(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,r){this.stack.push(this.state,r,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var r;let n=e>>19,i=e&65535,{parser:a}=this.p,s=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),l=a.dynamicPrecedence(i);if(l&&(this.score+=l),n==0){this.pushState(a.getGoto(this.state,i,!0),this.reducePos),i<a.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,s?8:4,!0),this.reduceContext(i,this.reducePos);return}let o=this.stack.length-(n-1)*3-(e&262144?6:0),c=o?this.stack[o-2]:this.p.ranges[0].from,h=this.reducePos-c;h>=2e3&&!(!((r=this.p.parser.nodeSet.types[i])===null||r===void 0)&&r.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=h):this.p.lastBigReductionSize<h&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=c,this.p.lastBigReductionSize=h));let d=o?this.stack[o-1]:0,g=this.bufferBase+this.buffer.length-d;if(i<a.minRepeatTerm||e&131072){let m=a.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,c,m,g+4,!0)}if(e&262144)this.state=this.stack[o];else{let m=this.stack[o-3];this.state=a.getGoto(m,i,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(i,c)}storeNode(e,r,n,i=4,a=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let s=this,l=this.buffer.length;if(l==0&&s.parent&&(l=s.bufferBase-s.parent.bufferBase,s=s.parent),l>0&&s.buffer[l-4]==0&&s.buffer[l-1]>-1){if(r==n)return;if(s.buffer[l-2]>=r){s.buffer[l-2]=n;return}}}if(!a||this.pos==n)this.buffer.push(e,r,n,i);else{let s=this.buffer.length;if(s>0&&(this.buffer[s-4]!=0||this.buffer[s-1]<0)){let l=!1;for(let o=s;o>0&&this.buffer[o-2]>n;o-=4)if(this.buffer[o-1]>=0){l=!0;break}if(l)for(;s>0&&this.buffer[s-2]>n;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,i>4&&(i-=4)}this.buffer[s]=e,this.buffer[s+1]=r,this.buffer[s+2]=n,this.buffer[s+3]=i}}shift(e,r,n,i){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let a=e,{parser:s}=this.p;this.pos=i;let l=s.stateFlag(a,1);!l&&(i>n||r<=s.maxNode)&&(this.reducePos=i),this.pushState(a,l?n:Math.min(n,this.reducePos)),this.shiftContext(r,n),r<=s.maxNode&&this.buffer.push(r,n,i,4)}else this.pos=i,this.shiftContext(r,n),r<=this.p.parser.maxNode&&this.buffer.push(r,n,i,4)}apply(e,r,n,i){e&65536?this.reduce(e):this.shift(e,r,n,i)}useNode(e,r){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(r,i),this.buffer.push(n,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,r=e.buffer.length;for(;r>0&&e.buffer[r-2]>e.reducePos;)r-=4;let n=e.buffer.slice(r),i=e.bufferBase+r;for(;e&&i==e.bufferBase;)e=e.parent;return new Jg(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,r){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,r,4),this.storeNode(0,this.pos,r,n?8:4),this.pos=this.reducePos=r,this.score-=190}canShift(e){for(let r=new afe(this);;){let n=this.p.parser.stateSlot(r.state,4)||this.p.parser.hasAction(r.state,e);if(n==0)return!1;if((n&65536)==0)return!0;r.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let r=this.p.parser.nextStates(this.state);if(r.length>8||this.stack.length>=120){let i=[];for(let a=0,s;a<r.length;a+=2)(s=r[a+1])!=this.state&&this.p.parser.hasAction(s,e)&&i.push(r[a],s);if(this.stack.length<120)for(let a=0;i.length<8&&a<r.length;a+=2){let s=r[a+1];i.some((l,o)=>o&1&&l==s)||i.push(r[a],s)}r=i}let n=[];for(let i=0;i<r.length&&n.length<4;i+=2){let a=r[i+1];if(a==this.state)continue;let s=this.split();s.pushState(a,this.pos),s.storeNode(0,s.pos,s.pos,4,!0),s.shiftContext(r[i],this.pos),s.reducePos=this.pos,s.score-=200,n.push(s)}return n}forceReduce(){let{parser:e}=this.p,r=e.stateSlot(this.state,5);if((r&65536)==0)return!1;if(!e.validAction(this.state,r)){let n=r>>19,i=r&65535,a=this.stack.length-n*3;if(a<0||e.getGoto(this.stack[a],i,!1)<0){let s=this.findForcedReduction();if(s==null)return!1;r=s}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(r),!0}findForcedReduction(){let{parser:e}=this.p,r=[],n=(i,a)=>{if(!r.includes(i))return r.push(i),e.allActions(i,s=>{if(!(s&393216))if(s&65536){let l=(s>>19)-a;if(l>1){let o=s&65535,c=this.stack.length-l*3;if(c>=0&&e.getGoto(this.stack[c],o,!1)>=0)return l<<19|65536|o}}else{let l=n(s,a+1);if(l!=null)return l}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let r=0;r<this.stack.length;r+=3)if(this.stack[r]!=e.stack[r])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,r){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(r)))}reduceContext(e,r){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(r)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let r=new yI(this.curContext.tracker,e);r.hash!=this.curContext.hash&&this.emitContext(),this.curContext=r}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class yI{constructor(e,r){this.tracker=e,this.context=r,this.hash=e.strict?e.hash(r):0}}class afe{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let r=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],r,!0);this.state=i}}class ev{constructor(e,r,n){this.stack=e,this.pos=r,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,r=e.bufferBase+e.buffer.length){return new ev(e,r,r-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new ev(this.stack,this.pos,this.index)}}function Lp(t,e=Uint16Array){if(typeof t!="string")return t;let r=null;for(let n=0,i=0;n<t.length;){let a=0;for(;;){let s=t.charCodeAt(n++),l=!1;if(s==126){a=65535;break}s>=92&&s--,s>=34&&s--;let o=s-32;if(o>=46&&(o-=46,l=!0),a+=o,l)break;a*=46}r?r[i++]=a:r=new e(a)}return r}class ag{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const bI=new ag;class sfe{constructor(e,r){this.input=e,this.ranges=r,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=bI,this.rangeIndex=0,this.pos=this.chunkPos=r[0].from,this.range=r[0],this.end=r[r.length-1].to,this.readNext()}resolveOffset(e,r){let n=this.range,i=this.rangeIndex,a=this.pos+e;for(;a<n.from;){if(!i)return null;let s=this.ranges[--i];a-=n.from-s.to,n=s}for(;r<0?a>n.to:a>=n.to;){if(i==this.ranges.length-1)return null;let s=this.ranges[++i];a+=s.from-n.to,n=s}return a}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let r of this.ranges)if(r.to>e)return Math.max(e,r.from);return this.end}peek(e){let r=this.chunkOff+e,n,i;if(r>=0&&r<this.chunk.length)n=this.pos+e,i=this.chunk.charCodeAt(r);else{let a=this.resolveOffset(e,1);if(a==null)return-1;if(n=a,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let s=this.rangeIndex,l=this.range;for(;l.to<=n;)l=this.ranges[++s];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-n)),i=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),i}acceptToken(e,r=0){let n=r?this.resolveOffset(r,-1):this.pos;if(n==null||n<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}acceptTokenTo(e,r){this.token.value=e,this.token.end=r}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:r}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=r,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),r=this.pos+e.length;this.chunk=r>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,r){if(r?(this.token=r,r.start=e,r.lookAhead=e+1,r.value=r.extended=-1):this.token=bI,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,r){if(e>=this.chunkPos&&r<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,r-this.chunkPos);if(e>=this.chunk2Pos&&r<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,r-this.chunk2Pos);if(e>=this.range.from&&r<=this.range.to)return this.input.read(e,r);let n="";for(let i of this.ranges){if(i.from>=r)break;i.to>e&&(n+=this.input.read(Math.max(i.from,e),Math.min(i.to,r)))}return n}}class _u{constructor(e,r){this.data=e,this.id=r}token(e,r){let{parser:n}=r.p;lfe(this.data,e,r,this.id,n.data,n.tokenPrecTable)}}_u.prototype.contextual=_u.prototype.fallback=_u.prototype.extend=!1;_u.prototype.fallback=_u.prototype.extend=!1;class tm{constructor(e,r={}){this.token=e,this.contextual=!!r.contextual,this.fallback=!!r.fallback,this.extend=!!r.extend}}function lfe(t,e,r,n,i,a){let s=0,l=1<<n,{dialect:o}=r.p.parser;e:for(;(l&t[s])!=0;){let c=t[s+1];for(let m=s+3;m<c;m+=2)if((t[m+1]&l)>0){let y=t[m];if(o.allows(y)&&(e.token.value==-1||e.token.value==y||ofe(y,e.token.value,i,a))){e.acceptToken(y);break}}let h=e.next,d=0,g=t[s+2];if(e.next<0&&g>d&&t[c+g*3-3]==65535){s=t[c+g*3-1];continue e}for(;d<g;){let m=d+g>>1,y=c+m+(m<<1),x=t[y],b=t[y+1]||65536;if(h<x)g=m;else if(h>=b)d=m+1;else{s=t[y+2],e.advance();continue e}}break}}function xI(t,e,r){for(let n=e,i;(i=t[n])!=65535;n++)if(i==r)return n-e;return-1}function ofe(t,e,r,n){let i=xI(r,n,e);return i<0||xI(r,n,t)<i}const oi=typeof process<"u"&&mI&&/\bparse\b/.test(mI.LOG);let YC=null;function wI(t,e,r){let n=t.cursor(gr.IncludeAnonymous);for(n.moveTo(e);;)if(!(r<0?n.childBefore(e):n.childAfter(e)))for(;;){if((r<0?n.to<e:n.from>e)&&!n.type.isError)return r<0?Math.max(0,Math.min(n.to-1,e-25)):Math.min(t.length,Math.max(n.from+1,e+25));if(r<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return r<0?0:t.length}}class ufe{constructor(e,r){this.fragments=e,this.nodeSet=r,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?wI(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?wI(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let r=this.trees.length-1;if(r<0)return this.nextFragment(),null;let n=this.trees[r],i=this.index[r];if(i==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let a=n.children[i],s=this.start[r]+n.positions[i];if(s>e)return this.nextStart=s,null;if(a instanceof Cr){if(s==e){if(s<this.safeFrom)return null;let l=s+a.length;if(l<=this.safeTo){let o=a.prop(Ct.lookAhead);if(!o||l+o<this.fragment.to)return a}}this.index[r]++,s+a.length>=Math.max(this.safeFrom,e)&&(this.trees.push(a),this.start.push(s),this.index.push(0))}else this.index[r]++,this.nextStart=s+a.length}}}class cfe{constructor(e,r){this.stream=r,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new ag)}getActions(e){let r=0,n=null,{parser:i}=e.p,{tokenizers:a}=i,s=i.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,o=0;for(let c=0;c<a.length;c++){if((1<<c&s)==0)continue;let h=a[c],d=this.tokens[c];if(!(n&&!h.fallback)&&((h.contextual||d.start!=e.pos||d.mask!=s||d.context!=l)&&(this.updateCachedToken(d,h,e),d.mask=s,d.context=l),d.lookAhead>d.end+25&&(o=Math.max(d.lookAhead,o)),d.value!=0)){let g=r;if(d.extended>-1&&(r=this.addActions(e,d.extended,d.end,r)),r=this.addActions(e,d.value,d.end,r),!h.extend&&(n=d,r>g))break}}for(;this.actions.length>r;)this.actions.pop();return o&&e.setLookAhead(o),!n&&e.pos==this.stream.end&&(n=new ag,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,r=this.addActions(e,n.value,n.end,r)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let r=new ag,{pos:n,p:i}=e;return r.start=n,r.end=Math.min(n+1,i.stream.end),r.value=n==i.stream.end?i.parser.eofTerm:0,r}updateCachedToken(e,r,n){let i=this.stream.clipPos(n.pos);if(r.token(this.stream.reset(i,e),n),e.value>-1){let{parser:a}=n.p;for(let s=0;s<a.specialized.length;s++)if(a.specialized[s]==e.value){let l=a.specializers[s](this.stream.read(e.start,e.end),n);if(l>=0&&n.p.parser.dialect.allows(l>>1)){(l&1)==0?e.value=l>>1:e.extended=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,r,n,i){for(let a=0;a<i;a+=3)if(this.actions[a]==e)return i;return this.actions[i++]=e,this.actions[i++]=r,this.actions[i++]=n,i}addActions(e,r,n,i){let{state:a}=e,{parser:s}=e.p,{data:l}=s;for(let o=0;o<2;o++)for(let c=s.stateSlot(a,o?2:1);;c+=3){if(l[c]==65535)if(l[c+1]==1)c=Fa(l,c+2);else{i==0&&l[c+1]==2&&(i=this.putAction(Fa(l,c+2),r,n,i));break}l[c]==r&&(i=this.putAction(Fa(l,c+1),r,n,i))}return i}}class ffe{constructor(e,r,n,i){this.parser=e,this.input=r,this.ranges=i,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new sfe(r,i),this.tokens=new cfe(e,this.stream),this.topTerm=e.top[1];let{from:a}=i[0];this.stacks=[Jg.start(this,e.top[0],a)],this.fragments=n.length&&this.stream.end-a>e.bufferLength*4?new ufe(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,r=this.minStackPos,n=this.stacks=[],i,a;if(this.bigReductionCount>300&&e.length==1){let[s]=e;for(;s.forceReduce()&&s.stack.length&&s.stack[s.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let s=0;s<e.length;s++){let l=e[s];for(;;){if(this.tokens.mainToken=null,l.pos>r)n.push(l);else{if(this.advanceStack(l,n,e))continue;{i||(i=[],a=[]),i.push(l);let o=this.tokens.getMainToken(l);a.push(o.value,o.end)}}break}}if(!n.length){let s=i&&pfe(i);if(s)return oi&&console.log("Finish with "+this.stackID(s)),this.stackToTree(s);if(this.parser.strict)throw oi&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+r);this.recovering||(this.recovering=5)}if(this.recovering&&i){let s=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,a,n);if(s)return oi&&console.log("Force-finish "+this.stackID(s)),this.stackToTree(s.forceAll())}if(this.recovering){let s=this.recovering==1?1:this.recovering*3;if(n.length>s)for(n.sort((l,o)=>o.score-l.score);n.length>s;)n.pop();n.some(l=>l.reducePos>r)&&this.recovering--}else if(n.length>1){e:for(let s=0;s<n.length-1;s++){let l=n[s];for(let o=s+1;o<n.length;o++){let c=n[o];if(l.sameState(c)||l.buffer.length>500&&c.buffer.length>500)if((l.score-c.score||l.buffer.length-c.buffer.length)>0)n.splice(o--,1);else{n.splice(s--,1);continue e}}}n.length>12&&(n.sort((s,l)=>l.score-s.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let s=1;s<n.length;s++)n[s].pos<this.minStackPos&&(this.minStackPos=n[s].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,r,n){let i=e.pos,{parser:a}=this,s=oi?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,h=c?e.curContext.hash:0;for(let d=this.fragments.nodeAt(i);d;){let g=this.parser.nodeSet.types[d.type.id]==d.type?a.getGoto(e.state,d.type.id):-1;if(g>-1&&d.length&&(!c||(d.prop(Ct.contextHash)||0)==h))return e.useNode(d,g),oi&&console.log(s+this.stackID(e)+` (via reuse of ${a.getName(d.type.id)})`),!0;if(!(d instanceof Cr)||d.children.length==0||d.positions[0]>0)break;let m=d.children[0];if(m instanceof Cr&&d.positions[0]==0)d=m;else break}}let l=a.stateSlot(e.state,4);if(l>0)return e.reduce(l),oi&&console.log(s+this.stackID(e)+` (via always-reduce ${a.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let o=this.tokens.getActions(e);for(let c=0;c<o.length;){let h=o[c++],d=o[c++],g=o[c++],m=c==o.length||!n,y=m?e:e.split(),x=this.tokens.mainToken;if(y.apply(h,d,x?x.start:y.pos,g),oi&&console.log(s+this.stackID(y)+` (via ${(h&65536)==0?"shift":`reduce of ${a.getName(h&65535)}`} for ${a.getName(d)} @ ${i}${y==e?"":", split"})`),m)return!0;y.pos>i?r.push(y):n.push(y)}return!1}advanceFully(e,r){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return SI(e,r),!0}}runRecovery(e,r,n){let i=null,a=!1;for(let s=0;s<e.length;s++){let l=e[s],o=r[s<<1],c=r[(s<<1)+1],h=oi?this.stackID(l)+" -> ":"";if(l.deadEnd&&(a||(a=!0,l.restart(),oi&&console.log(h+this.stackID(l)+" (restarted)"),this.advanceFully(l,n))))continue;let d=l.split(),g=h;for(let m=0;m<10&&d.forceReduce()&&(oi&&console.log(g+this.stackID(d)+" (via force-reduce)"),!this.advanceFully(d,n));m++)oi&&(g=this.stackID(d)+" -> ");for(let m of l.recoverByInsert(o))oi&&console.log(h+this.stackID(m)+" (via recover-insert)"),this.advanceFully(m,n);this.stream.end>l.pos?(c==l.pos&&(c++,o=0),l.recoverByDelete(o,c),oi&&console.log(h+this.stackID(l)+` (via recover-delete ${this.parser.getName(o)})`),SI(l,n)):(!i||i.score<d.score)&&(i=d)}return i}stackToTree(e){return e.close(),Cr.build({buffer:ev.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let r=(YC||(YC=new WeakMap)).get(e);return r||YC.set(e,r=String.fromCodePoint(this.nextStackID++)),r+e}}function SI(t,e){for(let r=0;r<e.length;r++){let n=e[r];if(n.pos==t.pos&&n.sameState(t)){e[r].score<t.score&&(e[r]=t);return}}e.push(t)}class hfe{constructor(e,r,n){this.source=e,this.flags=r,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}}const XC=t=>t;class dfe{constructor(e){this.start=e.start,this.shift=e.shift||XC,this.reduce=e.reduce||XC,this.reuse=e.reuse||XC,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class tv extends U9{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let r=e.nodeNames.split(" ");this.minRepeatTerm=r.length;for(let l=0;l<e.repeatNodeCount;l++)r.push("");let n=Object.keys(e.topRules).map(l=>e.topRules[l][1]),i=[];for(let l=0;l<r.length;l++)i.push([]);function a(l,o,c){i[l].push([o,o.deserialize(String(c))])}if(e.nodeProps)for(let l of e.nodeProps){let o=l[0];typeof o=="string"&&(o=Ct[o]);for(let c=1;c<l.length;){let h=l[c++];if(h>=0)a(h,o,l[c++]);else{let d=l[c+-h];for(let g=-h;g>0;g--)a(l[c++],o,d);c++}}}this.nodeSet=new UE(r.map((l,o)=>Zn.define({name:o>=this.minRepeatTerm?void 0:l,id:o,props:i[o],top:n.indexOf(o)>-1,error:o==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(o)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=j9;let s=Lp(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(CI),this.states=Lp(e.states,Uint32Array),this.data=Lp(e.stateData),this.goto=Lp(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new _u(s,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,r,n){let i=new ffe(this,e,r,n);for(let a of this.wrappers)i=a(i,e,r,n);return i}getGoto(e,r,n=!1){let i=this.goto;if(r>=i[0])return-1;for(let a=i[r+1];;){let s=i[a++],l=s&1,o=i[a++];if(l&&n)return o;for(let c=a+(s>>1);a<c;a++)if(i[a]==e)return o;if(l)return-1}}hasAction(e,r){let n=this.data;for(let i=0;i<2;i++)for(let a=this.stateSlot(e,i?2:1),s;;a+=3){if((s=n[a])==65535)if(n[a+1]==1)s=n[a=Fa(n,a+2)];else{if(n[a+1]==2)return Fa(n,a+2);break}if(s==r||s==0)return Fa(n,a+1)}return 0}stateSlot(e,r){return this.states[e*6+r]}stateFlag(e,r){return(this.stateSlot(e,0)&r)>0}validAction(e,r){return!!this.allActions(e,n=>n==r?!0:null)}allActions(e,r){let n=this.stateSlot(e,4),i=n?r(n):void 0;for(let a=this.stateSlot(e,1);i==null;a+=3){if(this.data[a]==65535)if(this.data[a+1]==1)a=Fa(this.data,a+2);else break;i=r(Fa(this.data,a+1))}return i}nextStates(e){let r=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=Fa(this.data,n+2);else break;if((this.data[n+2]&1)==0){let i=this.data[n+1];r.some((a,s)=>s&1&&a==i)||r.push(this.data[n],i)}}return r}configure(e){let r=Object.assign(Object.create(tv.prototype),this);if(e.props&&(r.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);r.top=n}return e.tokenizers&&(r.tokenizers=this.tokenizers.map(n=>{let i=e.tokenizers.find(a=>a.from==n);return i?i.to:n})),e.specializers&&(r.specializers=this.specializers.slice(),r.specializerSpecs=this.specializerSpecs.map((n,i)=>{let a=e.specializers.find(l=>l.from==n.external);if(!a)return n;let s=Object.assign(Object.assign({},n),{external:a.to});return r.specializers[i]=CI(s),s})),e.contextTracker&&(r.context=e.contextTracker),e.dialect&&(r.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(r.strict=e.strict),e.wrap&&(r.wrappers=r.wrappers.concat(e.wrap)),e.bufferLength!=null&&(r.bufferLength=e.bufferLength),r}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let r=this.dynamicPrecedences;return r==null?0:r[e]||0}parseDialect(e){let r=Object.keys(this.dialects),n=r.map(()=>!1);if(e)for(let a of e.split(" ")){let s=r.indexOf(a);s>=0&&(n[s]=!0)}let i=null;for(let a=0;a<r.length;a++)if(!n[a])for(let s=this.dialects[r[a]],l;(l=this.data[s++])!=65535;)(i||(i=new Uint8Array(this.maxTerm+1)))[l]=1;return new hfe(e,n,i)}static deserialize(e){return new tv(e)}}function Fa(t,e){return t[e]|t[e+1]<<16}function pfe(t){let e=null;for(let r of t){let n=r.p.stoppedAt;(r.pos==r.p.stream.end||n!=null&&r.pos>n)&&r.p.parser.stateFlag(r.state,2)&&(!e||e.score<r.score)&&(e=r)}return e}function CI(t){if(t.external){let e=t.extend?1:0;return(r,n)=>t.external(r,n)<<1|e}return t.get}const fu=63,kI=64,gfe=1,vfe=2,dH=3,mfe=4,pH=5,yfe=6,bfe=7,gH=65,xfe=66,wfe=8,Sfe=9,Cfe=10,kfe=11,Tfe=12,vH=13,Efe=19,Afe=20,Ofe=29,Mfe=33,Rfe=34,Dfe=47,_fe=0,uA=1,bT=2,ch=3,xT=4;class jl{constructor(e,r,n){this.parent=e,this.depth=r,this.type=n,this.hash=(e?e.hash+e.hash<<8:0)+r+(r<<4)+n}}jl.top=new jl(null,-1,_fe);function Df(t,e){for(let r=0,n=e-t.pos-1;;n--,r++){let i=t.peek(n);if(Za(i)||i==-1)return r}}function wT(t){return t==32||t==9}function Za(t){return t==10||t==13}function mH(t){return wT(t)||Za(t)}function Gl(t){return t<0||mH(t)}const Nfe=new dfe({start:jl.top,reduce(t,e){return t.type==ch&&(e==Afe||e==Rfe)?t.parent:t},shift(t,e,r,n){if(e==dH)return new jl(t,Df(n,n.pos),uA);if(e==gH||e==pH)return new jl(t,Df(n,n.pos),bT);if(e==fu)return t.parent;if(e==Efe||e==Mfe)return new jl(t,0,ch);if(e==vH&&t.type==xT)return t.parent;if(e==Dfe){let i=/[1-9]/.exec(n.read(n.pos,r.pos));if(i)return new jl(t,t.depth+ +i[0],xT)}return t},hash(t){return t.hash}});function Uu(t,e,r=0){return t.peek(r)==e&&t.peek(r+1)==e&&t.peek(r+2)==e&&Gl(t.peek(r+3))}const Bfe=new tm((t,e)=>{if(t.next==-1&&e.canShift(kI))return t.acceptToken(kI);let r=t.peek(-1);if((Za(r)||r<0)&&e.context.type!=ch){if(Uu(t,45))if(e.canShift(fu))t.acceptToken(fu);else return t.acceptToken(gfe,3);if(Uu(t,46))if(e.canShift(fu))t.acceptToken(fu);else return t.acceptToken(vfe,3);let n=0;for(;t.next==32;)n++,t.advance();(n<e.context.depth||n==e.context.depth&&e.context.type==uA&&(t.next!=45||!Gl(t.peek(1))))&&t.next!=-1&&!Za(t.next)&&t.next!=35&&t.acceptToken(fu,-n)}},{contextual:!0}),Lfe=new tm((t,e)=>{if(e.context.type==ch){t.next==63&&(t.advance(),Gl(t.next)&&t.acceptToken(bfe));return}if(t.next==45)t.advance(),Gl(t.next)&&t.acceptToken(e.context.type==uA&&e.context.depth==Df(t,t.pos-1)?mfe:dH);else if(t.next==63)t.advance(),Gl(t.next)&&t.acceptToken(e.context.type==bT&&e.context.depth==Df(t,t.pos-1)?yfe:pH);else{let r=t.pos;for(;;)if(wT(t.next)){if(t.pos==r)return;t.advance()}else if(t.next==33)yH(t);else if(t.next==38)ST(t);else if(t.next==42){ST(t);break}else if(t.next==39||t.next==34){if(cA(t,!0))break;return}else if(t.next==91||t.next==123){if(!zfe(t))return;break}else{bH(t,!0,!1,0);break}for(;wT(t.next);)t.advance();if(t.next==58){if(t.pos==r&&e.canShift(Ofe))return;let n=t.peek(1);Gl(n)&&t.acceptTokenTo(e.context.type==bT&&e.context.depth==Df(t,r)?xfe:gH,r)}}},{contextual:!0});function Pfe(t){return t>32&&t<127&&t!=34&&t!=37&&t!=44&&t!=60&&t!=62&&t!=92&&t!=94&&t!=96&&t!=123&&t!=124&&t!=125}function TI(t){return t>=48&&t<=57||t>=97&&t<=102||t>=65&&t<=70}function EI(t,e){return t.next==37?(t.advance(),TI(t.next)&&t.advance(),TI(t.next)&&t.advance(),!0):Pfe(t.next)||e&&t.next==44?(t.advance(),!0):!1}function yH(t){if(t.advance(),t.next==60){for(t.advance();;)if(!EI(t,!0)){t.next==62&&t.advance();break}}else for(;EI(t,!1););}function ST(t){for(t.advance();!Gl(t.next)&&rv(t.next)!="f";)t.advance()}function cA(t,e){let r=t.next,n=!1,i=t.pos;for(t.advance();;){let a=t.next;if(a<0)break;if(t.advance(),a==r)if(a==39)if(t.next==39)t.advance();else break;else break;else if(a==92&&r==34)t.next>=0&&t.advance();else if(Za(a)){if(e)return!1;n=!0}else if(e&&t.pos>=i+1024)return!1}return!n}function zfe(t){for(let e=[],r=t.pos+1024;;)if(t.next==91||t.next==123)e.push(t.next),t.advance();else if(t.next==39||t.next==34){if(!cA(t,!0))return!1}else if(t.next==93||t.next==125){if(e[e.length-1]!=t.next-2)return!1;if(e.pop(),t.advance(),!e.length)return!0}else{if(t.next<0||t.pos>r||Za(t.next))return!1;t.advance()}}const Ife="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";function rv(t){return t<33?"u":t>125?"s":Ife[t-33]}function WC(t,e){let r=rv(t);return r!="u"&&!(e&&r=="f")}function bH(t,e,r,n){if(rv(t.next)=="s"||(t.next==63||t.next==58||t.next==45)&&WC(t.peek(1),r))t.advance();else return!1;let i=t.pos;for(;;){let a=t.next,s=0,l=n+1;for(;mH(a);){if(Za(a)){if(e)return!1;l=0}else l++;a=t.peek(++s)}if(!(a>=0&&(a==58?WC(t.peek(s+1),r):a==35?t.peek(s-1)!=32:WC(a,r)))||!r&&l<=n||l==0&&!r&&(Uu(t,45,s)||Uu(t,46,s)))break;if(e&&rv(a)=="f")return!1;for(let c=s;c>=0;c--)t.advance();if(e&&t.pos>i+1024)return!1}return!0}const qfe=new tm((t,e)=>{if(t.next==33)yH(t),t.acceptToken(Tfe);else if(t.next==38||t.next==42){let r=t.next==38?Cfe:kfe;ST(t),t.acceptToken(r)}else t.next==39||t.next==34?(cA(t,!1),t.acceptToken(Sfe)):bH(t,!1,e.context.type==ch,e.context.depth)&&t.acceptToken(wfe)}),jfe=new tm((t,e)=>{let r=e.context.type==xT?e.context.depth:-1,n=t.pos;e:for(;;){let i=0,a=t.next;for(;a==32;)a=t.peek(++i);if(!i&&(Uu(t,45,i)||Uu(t,46,i))||!Za(a)&&(r<0&&(r=Math.max(e.context.depth+1,i)),i<r))break;for(;;){if(t.next<0)break e;let s=Za(t.next);if(t.advance(),s)continue e;n=t.pos}}t.acceptTokenTo(vH,n)}),Ffe=$9({DirectiveName:be.keyword,DirectiveContent:be.attributeValue,"DirectiveEnd DocEnd":be.meta,QuotedLiteral:be.string,BlockLiteralHeader:be.special(be.string),BlockLiteralContent:be.content,Literal:be.content,"Key/Literal Key/QuotedLiteral":be.definition(be.propertyName),"Anchor Alias":be.labelName,Tag:be.typeName,Comment:be.lineComment,": , -":be.separator,"?":be.punctuation,"[ ]":be.squareBracket,"{ }":be.brace}),Hfe=tv.deserialize({version:14,states:"5lQ!ZQgOOO#PQfO'#CpO#uQfO'#DOOOQR'#Dv'#DvO$qQgO'#DRO%gQdO'#DUO%nQgO'#DUO&ROaO'#D[OOQR'#Du'#DuO&{QgO'#D^O'rQgO'#D`OOQR'#Dt'#DtO(iOqO'#DbOOQP'#Dj'#DjO(zQaO'#CmO)YQgO'#CmOOQP'#Cm'#CmQ)jQaOOQ)uQgOOQ]QgOOO*PQdO'#CrO*nQdO'#CtOOQO'#Dw'#DwO+]Q`O'#CxO+hQdO'#CwO+rQ`O'#CwOOQO'#Cv'#CvO+wQdO'#CvOOQO'#Cq'#CqO,UQ`O,59[O,^QfO,59[OOQR,59[,59[OOQO'#Cx'#CxO,eQ`O'#DPO,pQdO'#DPOOQO'#Dx'#DxO,zQdO'#DxO-XQ`O,59jO-aQfO,59jOOQR,59j,59jOOQR'#DS'#DSO-hQcO,59mO-sQgO'#DVO.TQ`O'#DVO.YQcO,59pOOQR'#DX'#DXO#|QfO'#DWO.hQcO'#DWOOQR,59v,59vO.yOWO,59vO/OOaO,59vO/WOaO,59vO/cQgO'#D_OOQR,59x,59xO0VQgO'#DaOOQR,59z,59zOOQP,59|,59|O0yOaO,59|O1ROaO,59|O1aOqO,59|OOQP-E7h-E7hO1oQgO,59XOOQP,59X,59XO2PQaO'#DeO2_QgO'#DeO2oQgO'#DkOOQP'#Dk'#DkQ)jQaOOO3PQdO'#CsOOQO,59^,59^O3kQdO'#CuOOQO,59`,59`OOQO,59c,59cO4VQdO,59cO4aQdO'#CzO4kQ`O'#CzOOQO,59b,59bOOQU,5:Q,5:QOOQR1G.v1G.vO4pQ`O1G.vOOQU-E7d-E7dO4xQdO,59kOOQO,59k,59kO5SQdO'#DQO5^Q`O'#DQOOQO,5:d,5:dOOQU,5:R,5:ROOQR1G/U1G/UO5cQ`O1G/UOOQU-E7e-E7eO5kQgO'#DhO5xQcO1G/XOOQR1G/X1G/XOOQR,59q,59qO6TQgO,59qO6eQdO'#DiO6lQgO'#DiO7PQcO1G/[OOQR1G/[1G/[OOQR,59r,59rO#|QfO,59rOOQR1G/b1G/bO7_OWO1G/bO7dOaO1G/bOOQR,59y,59yOOQR,59{,59{OOQP1G/h1G/hO7lOaO1G/hO7tOaO1G/hO8POaO1G/hOOQP1G.s1G.sO8_QgO,5:POOQP,5:P,5:POOQP,5:V,5:VOOQP-E7i-E7iOOQO,59_,59_OOQO,59a,59aOOQO1G.}1G.}OOQO,59f,59fO8oQdO,59fOOQR7+$b7+$bP,XQ`O'#DfOOQO1G/V1G/VOOQO,59l,59lO8yQdO,59lOOQR7+$p7+$pP9TQ`O'#DgOOQR'#DT'#DTOOQR,5:S,5:SOOQR-E7f-E7fOOQR7+$s7+$sOOQR1G/]1G/]O9YQgO'#DYO9jQ`O'#DYOOQR,5:T,5:TO#|QfO'#DZO9oQcO'#DZOOQR-E7g-E7gOOQR7+$v7+$vOOQR1G/^1G/^OOQR7+$|7+$|O:QOWO7+$|OOQP7+%S7+%SO:VOaO7+%SO:_OaO7+%SOOQP1G/k1G/kOOQO1G/Q1G/QOOQO1G/W1G/WOOQR,59t,59tO:jQgO,59tOOQR,59u,59uO#|QfO,59uOOQR<<Hh<<HhOOQP<<Hn<<HnO:zOaO<<HnOOQR1G/`1G/`OOQR1G/a1G/aOOQPAN>YAN>Y",stateData:";S~O!fOS!gOS^OS~OP_OQbORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!V[O!cTO~O`cO~P]OVkOWROXROYeOZfO[dOcPOmhOqQO~OboO~P!bOVtOWROXROYeOZfO[dOcPOmrOqQO~OpwO~P#WORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!cTO~OSvP!avP!bvP~P#|OWROXROYeOZfO[dOcPOqQO~OmzO~P%OOm!OOUzP!azP!bzP!dzP~P#|O^!SO!b!QO!f!TO!g!RO~ORSOTUOWROXROcPOqQO!PVO!cTO~OY!UOP!QXQ!QX!V!QX!`!QXS!QX!a!QX!b!QXU!QXm!QX!d!QX~P&aO[!WOP!SXQ!SX!V!SX!`!SXS!SX!a!SX!b!SXU!SXm!SX!d!SX~P&aO^!ZO!W![O!b!YO!f!]O!g!YO~OP!_O!V[OQaX!`aX~OPaXQaX!VaX!`aX~P#|OP!bOQ!cO!V[O~OP_O!V[O~P#|OWROXROY!fOcPOqQObfXmfXofXpfX~OWROXRO[!hOcPOqQObhXmhXohXphX~ObeXmlXoeX~ObkXokX~P%OOm!kO~Om!lObnPonP~P%OOb!pOo!oO~Ob!pO~P!bOm!sOosXpsX~OosXpsX~P%OOm!uOotPptP~P%OOo!xOp!yO~Op!yO~P#WOS!|O!a#OO!b#OO~OUyX!ayX!byX!dyX~P#|Om#QO~OU#SO!a#UO!b#UO!d#RO~Om#WOUzX!azX!bzX!dzX~O]#XO~O!b#XO!g#YO~O^#ZO!b#XO!g#YO~OP!RXQ!RX!V!RX!`!RXS!RX!a!RX!b!RXU!RXm!RX!d!RX~P&aOP!TXQ!TX!V!TX!`!TXS!TX!a!TX!b!TXU!TXm!TX!d!TX~P&aO!b#^O!g#^O~O^#_O!b#^O!f#`O!g#^O~O^#_O!W#aO!b#^O!g#^O~OPaaQaa!Vaa!`aa~P#|OP#cO!V[OQ!XX!`!XX~OP!XXQ!XX!V!XX!`!XX~P#|OP_O!V[OQ!_X!`!_X~P#|OWROXROcPOqQObgXmgXogXpgX~OWROXROcPOqQObiXmiXoiXpiX~Obkaoka~P%OObnXonX~P%OOm#kO~Ob#lOo!oO~Oosapsa~P%OOotXptX~P%OOm#pO~Oo!xOp#qO~OSwP!awP!bwP~P#|OS!|O!a#vO!b#vO~OUya!aya!bya!dya~P#|Om#xO~P%OOm#{OU}P!a}P!b}P!d}P~P#|OU#SO!a$OO!b$OO!d#RO~O]$QO~O!b$QO!g$RO~O!b$SO!g$SO~O^$TO!b$SO!g$SO~O^$TO!b$SO!f$UO!g$SO~OP!XaQ!Xa!V!Xa!`!Xa~P#|Obnaona~P%OOotapta~P%OOo!xO~OU|X!a|X!b|X!d|X~P#|Om$ZO~Om$]OU}X!a}X!b}X!d}X~O]$^O~O!b$_O!g$_O~O^$`O!b$_O!g$_O~OU|a!a|a!b|a!d|a~P#|O!b$cO!g$cO~O",goto:",]!mPPPPPPPPPPPPPPPPP!nPP!v#v#|$`#|$c$f$j$nP%VPPP!v%Y%^%a%{&O%a&R&U&X&_&b%aP&e&{&e'O'RPP']'a'g'm's'y(XPPPPPPPP(_)e*X+c,VUaObcR#e!c!{ROPQSTUXY_bcdehknrtvz!O!U!W!_!b!c!f!h!k!l!s!u!|#Q#R#S#W#c#k#p#x#{$Z$]QmPR!qnqfPQThknrtv!k!l!s!u#R#k#pR!gdR!ieTlPnTjPnSiPnSqQvQ{TQ!mkQ!trQ!vtR#y#RR!nkTsQvR!wt!RWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]RySR#t!|R|TR|UQ!PUR#|#SR#z#RR#z#SyZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]R!VXR!XYa]O^abc!a!c!eT!da!eQnPR!rnQvQR!{vQ!}yR#u!}Q#T|R#}#TW^Obc!cS!^^!aT!aa!eQ!eaR#f!eW`Obc!cQxSS}U#SQ!`_Q#PzQ#V!OQ#b!_Q#d!bQ#s!|Q#w#QQ$P#WQ$V#cQ$Y#xQ$[#{Q$a$ZR$b$]xZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]Q!VXQ!XYQ#[!UR#]!W!QWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]pfPQThknrtv!k!l!s!u#R#k#pQ!gdQ!ieQ#g!fR#h!hSgPn^pQTkrtv#RQ!jhQ#i!kQ#j!lQ#n!sQ#o!uQ$W#kR$X#pQuQR!zv",nodeNames:"⚠ DirectiveEnd DocEnd - - ? ? ? Literal QuotedLiteral Anchor Alias Tag BlockLiteralContent Comment Stream BOM Document ] [ FlowSequence Item Tagged Anchored Anchored Tagged FlowMapping Pair Key : Pair , } { FlowMapping Pair Pair BlockSequence Item Item BlockMapping Pair Pair Key Pair Pair BlockLiteral BlockLiteralHeader Tagged Anchored Anchored Tagged Directive DirectiveName DirectiveContent Document",maxTerm:74,context:Nfe,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[Ffe],skippedNodes:[0],repeatNodeCount:6,tokenData:"-Y~RnOX#PXY$QYZ$]Z]#P]^$]^p#Ppq$Qqs#Pst$btu#Puv$yv|#P|}&e}![#P![!]'O!]!`#P!`!a'i!a!}#P!}#O*g#O#P#P#P#Q+Q#Q#o#P#o#p+k#p#q'i#q#r,U#r;'S#P;'S;=`#z<%l?HT#P?HT?HU,o?HUO#PQ#UU!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PQ#kTOY#PZs#Pt;'S#P;'S;=`#z<%lO#PQ#}P;=`<%l#P~$VQ!f~XY$Qpq$Q~$bO!g~~$gS^~OY$bZ;'S$b;'S;=`$s<%lO$b~$vP;=`<%l$bR%OX!WQOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR%rX!WQ!VPOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR&bP;=`<%l%kR&lUoP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'VUmP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'p[!PP!WQOY#PZp#Ppq#hq{#P{|(f|}#P}!O(f!O!R#P!R![)p![;'S#P;'S;=`#z<%lO#PR(mW!PP!WQOY#PZp#Ppq#hq!R#P!R![)V![;'S#P;'S;=`#z<%lO#PR)^U!PP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR)wY!PP!WQOY#PZp#Ppq#hq{#P{|)V|}#P}!O)V!O;'S#P;'S;=`#z<%lO#PR*nUcP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+XUbP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+rUqP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,]UpP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,vU`P!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#P",tokenizers:[Bfe,Lfe,qfe,jfe,0,1],topRules:{Stream:[0,15]},tokenPrec:0}),Vfe=qg.define({name:"yaml",parser:Hfe.configure({props:[W9.add({Stream:t=>{for(let e=t.node.resolve(t.pos,-1);e&&e.to>=t.pos;e=e.parent){if(e.name=="BlockLiteralContent"&&e.from<e.to)return t.baseIndentFor(e);if(e.name=="BlockLiteral")return t.baseIndentFor(e)+t.unit;if(e.name=="BlockSequence"||e.name=="BlockMapping")return t.column(e.from,1);if(e.name=="QuotedLiteral")return null;if(e.name=="Literal"){let r=t.column(e.from,1);if(r==t.lineIndent(e.from,1))return r;if(e.to>t.pos)return null}}return null},FlowMapping:Nz({closing:"}"}),FlowSequence:Nz({closing:"]"})}),Z9.add({"FlowMapping FlowSequence":Sle,"Item Pair BlockLiteral":(t,e)=>({from:e.doc.lineAt(t.from).to,to:t.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});function Ufe(){return new fle(Vfe)}const $fe=()=>{const{error:t,isCliMode:e,yamlInput:r,setYamlInput:n,parseAndSetSchema:i,savingStatus:a,lastUpdateSource:s,theme:l,currentModelSlug:o}=vt(),[c,h]=ve.useState(r),d=ve.useRef(null),g=ve.useRef(null),m=ve.useRef(!0);ve.useEffect(()=>{if(!g.current?.view)return;const w=g.current.view,S=w.state.doc.toString();w.dispatch({changes:{from:0,to:S.length,insert:r},annotations:Sr.addToHistory.of(!1)}),h(r)},[o]),ve.useEffect(()=>{if(!g.current?.view)return;const w=g.current.view,S=w.state.doc.toString();if(m.current&&r){w.dispatch({changes:{from:0,to:S.length,insert:r},annotations:Sr.addToHistory.of(!1)}),h(r),m.current=!1;return}s!=="user"&&S!==r&&(w.dispatch({changes:{from:0,to:S.length,insert:r},userEvent:"remote-edit"}),h(r))},[r,s]);const y=ve.useCallback(w=>{h(w),!(!w||w.trim()==="")&&(d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{n(w),i(w)},300))},[n,i]),x=()=>{g.current?.view&&ZE(g.current.view)},b=()=>{g.current?.view&&Ug(g.current.view)};return A.jsxs("div",{className:"flex-1 flex flex-col gap-3 overflow-hidden p-4 pt-2 h-full sidebar-content",children:[A.jsxs("div",{className:"flex items-center justify-between px-1",children:[e?A.jsxs("div",{className:"flex items-center gap-4",children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-blue-500 animate-pulse"}),A.jsx("span",{className:`text-[10px] font-bold uppercase tracking-widest ${l==="dark"?"text-slate-500":"text-slate-400"}`,children:"Auto-sync active"})]}),A.jsxs("div",{className:"flex items-center gap-1.5 min-w-[60px]",children:[a==="saving"&&A.jsxs("div",{className:"flex items-center gap-1 text-slate-400 animate-pulse",children:[A.jsx(Zre,{size:10,className:"animate-spin"}),A.jsx("span",{className:"text-[9px] font-bold uppercase",children:"Saving"})]}),a==="saved"&&A.jsxs("div",{className:"flex items-center gap-1 text-emerald-500",children:[A.jsx(Bre,{size:10}),A.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider",children:"Saved"})]}),a==="error"&&A.jsxs("div",{className:"flex items-center gap-1 text-red-500",children:[A.jsx(Qp,{size:10}),A.jsx("span",{className:"text-[9px] font-bold uppercase",children:"Error"})]})]})]}):A.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 bg-blue-500/10 border border-blue-500/30 rounded-md",children:[A.jsx(Qp,{size:12,className:"text-blue-400"}),A.jsx("span",{className:"text-[10px] text-blue-300 font-medium uppercase tracking-tight",children:"Sandbox Mode"})]}),A.jsxs("div",{className:"flex items-center gap-3",children:[A.jsxs("div",{className:`flex rounded-lg p-0.5 border ${l==="dark"?"bg-slate-800/50 border-slate-700/50":"bg-slate-100 border-slate-200"}`,children:[A.jsx("button",{onClick:x,className:`p-1.5 rounded-md transition-all active:scale-95 ${l==="dark"?"text-slate-400 hover:bg-slate-700 hover:text-slate-100":"text-slate-500 hover:bg-white hover:text-blue-600 hover:shadow-sm"}`,title:"Undo (Ctrl+Z)",children:A.jsx(Ene,{size:14})}),A.jsx("div",{className:`w-px h-4 self-center mx-0.5 ${l==="dark"?"bg-slate-700/50":"bg-slate-200"}`}),A.jsx("button",{onClick:b,className:`p-1.5 rounded-md transition-all active:scale-95 ${l==="dark"?"text-slate-400 hover:bg-slate-700 hover:text-slate-100":"text-slate-500 hover:bg-white hover:text-blue-600 hover:shadow-sm"}`,title:"Redo (Ctrl+Y)",children:A.jsx(pne,{size:14})})]}),A.jsxs("div",{className:"flex items-center gap-1 text-slate-400 dark:text-slate-600 cursor-help",title:"Pro Tip: Use Ctrl+Z to undo visual changes!",children:[A.jsx(CE,{size:12}),A.jsx("span",{className:"text-[9px] font-bold uppercase tracking-tighter",children:"Undo Active"})]})]})]}),A.jsxs("div",{className:`relative flex-1 flex flex-col min-h-0 border rounded-md overflow-hidden transition-colors ${l==="dark"?"border-slate-700 bg-[#282c34]":"border-slate-200 bg-white"}`,children:[A.jsx(hH,{ref:g,value:c,height:"100%",theme:l==="dark"?fH:"light",extensions:[Ufe()],onChange:y,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0},className:"flex-1 text-sm overflow-auto"}),t&&c===r&&A.jsxs("div",{className:"absolute bottom-4 left-4 right-4 p-3 bg-red-900/90 border border-red-500/50 rounded-md text-red-100 text-xs flex gap-2 items-start z-10 shadow-2xl backdrop-blur-sm animate-in fade-in slide-in-from-bottom-2",children:[A.jsx(Qp,{size:14,className:"shrink-0 mt-0.5 text-red-400"}),A.jsx("span",{children:t})]})]}),A.jsx("div",{className:"flex justify-between items-center pt-1 shrink-0",children:A.jsx("div",{className:"text-[10px] text-slate-500 italic",children:e?"Changes are automatically reflected and saved to file.":"Changes are reflected instantly but reset on reload."})})]})},Gfe=()=>{const{availableFiles:t,currentModelSlug:e,setCurrentModel:r,isSidebarOpen:n,theme:i}=vt();if(!n||t.length<=0)return null;const a=e||t[0]?.slug;return A.jsxs("div",{className:"px-4 mb-4",children:[A.jsx("div",{className:"flex items-center justify-between mb-1.5 px-1",children:A.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Current Model"})}),A.jsxs("div",{className:"relative group",children:[A.jsx("select",{value:a,onChange:s=>r(s.target.value),className:`w-full pl-9 pr-8 py-2 rounded-md text-sm appearance-none focus:outline-none focus:ring-1 focus:ring-blue-500/50 transition-all shadow-sm cursor-pointer ${i==="dark"?"bg-slate-800 border-slate-700 text-slate-100 hover:bg-slate-750":"bg-white border-slate-200 text-slate-900 hover:bg-slate-50 shadow-slate-200/50"}`,children:t.map(s=>A.jsx("option",{value:s.slug,className:i==="light"?"bg-white text-slate-900":"bg-slate-800 text-slate-100",children:s.name},s.slug))}),A.jsx(Hl,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-blue-500 pointer-events-none"}),A.jsx(Ha,{size:14,className:`absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none transition-colors ${i==="dark"?"text-slate-500 group-hover:text-slate-300":"text-slate-400 group-hover:text-slate-600"}`})]})]})},Yfe=()=>{const{schema:t,bulkAddRelationship:e,theme:r}=vt(),[n,i]=ve.useState("er"),[a,s]=ve.useState(""),[l,o]=ve.useState(""),[c,h]=ve.useState("one-to-many"),[d,g]=ve.useState(!1),[m,y]=ve.useState(!1),[x,b]=ve.useState(0),[w,S]=ve.useState(!1),k=ve.useRef(null),E=ve.useRef(null),M=ve.useMemo(()=>{if(!t)return[];const D=[];return t.tables.forEach(_=>{D.push(_.id),n==="er"&&_.columns?.forEach(P=>{D.push(`${_.id}.${P.id}`)})}),D},[t,n]),R=ve.useMemo(()=>a?M.filter(D=>D.toLowerCase().includes(a.toLowerCase())).slice(0,8):[],[a,M]),O=ve.useMemo(()=>{const D=l.toLowerCase(),_=M.filter(P=>P.toLowerCase().includes(D));if(n==="er"&&D.includes(".")){const P=D.split(".")[1]||"";_.unshift(`*.${P}`)}return _.slice(0,8)},[l,M,n]);ve.useEffect(()=>{k.current?.focus()},[]);const N=()=>{if(!a||!l)return;const D=a.split("."),_=D[0],P=D[1];e({table:_,column:P},l,c),S(!0),setTimeout(()=>S(!1),1500),o(""),E.current?.focus()},B=(D,_)=>{D.stopPropagation();const P=_==="source"?R:O;D.key==="ArrowDown"?(D.preventDefault(),b(z=>(z+1)%(P.length||1))):D.key==="ArrowUp"?(D.preventDefault(),b(z=>(z-1+(P.length||1))%(P.length||1))):D.key==="Enter"&&(P[x]?_==="source"?(s(P[x]),g(!1),E.current?.focus()):(o(P[x]),y(!1)):_==="target"&&a&&l&&N())};return A.jsxs("div",{className:"flex-1 flex flex-col gap-6 p-4 overflow-auto sidebar-content",children:[A.jsxs("div",{className:"flex flex-col gap-4",children:[A.jsxs("section",{className:"relative",children:[A.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[A.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-slate-500",children:"Source"}),A.jsxs("div",{className:`flex rounded-full p-0.5 border ${r==="dark"?"bg-slate-950/50 border-slate-800":"bg-slate-100 border-slate-200"}`,children:[A.jsxs("button",{onClick:()=>{i("er"),h("one-to-many")},className:`px-2 py-0.5 rounded-full flex items-center gap-1 transition-all ${n==="er"?r==="dark"?"bg-slate-700 text-blue-400 shadow-sm":"bg-white text-blue-600 shadow-sm":"text-[9px] font-bold text-slate-500 hover:text-slate-400 uppercase tracking-tighter"}`,children:[A.jsx(Ck,{size:10}),A.jsx("span",{className:"text-[9px] font-black uppercase tracking-tighter",children:"ER"})]}),A.jsxs("button",{onClick:()=>{i("lineage"),h("lineage")},className:`px-2 py-0.5 rounded-full flex items-center gap-1 transition-all ${n==="lineage"?r==="dark"?"bg-slate-700 text-blue-400 shadow-sm":"bg-white text-blue-600 shadow-sm":"text-[9px] font-bold text-slate-500 hover:text-slate-400 uppercase tracking-tighter"}`,children:[A.jsx(SE,{size:10}),A.jsx("span",{className:"text-[9px] font-black uppercase tracking-tighter",children:"Flow"})]})]})]}),A.jsx("input",{ref:k,type:"text",placeholder:n==="er"?"table.column":"table_id",className:`w-full px-4 py-2.5 rounded-xl text-sm font-bold outline-none transition-all border-2 border-transparent ${r==="dark"?"bg-slate-800 text-white placeholder-slate-600 focus:border-blue-500/50":"bg-slate-50 text-slate-900 focus:border-blue-500/30"}`,value:a,onChange:D=>{s(D.target.value),g(!0),b(0)},onFocus:()=>g(!0),onBlur:()=>setTimeout(()=>g(!1),200),onKeyDown:D=>B(D,"source")}),d&&R.length>0&&A.jsx("div",{className:`absolute top-full left-0 right-0 mt-1 rounded-xl shadow-xl border-2 overflow-hidden z-[110] ${r==="dark"?"bg-slate-800 border-slate-700":"bg-white border-slate-200"}`,children:R.map((D,_)=>A.jsx("div",{className:`px-4 py-2 text-xs font-bold cursor-pointer ${x===_?"bg-blue-600 text-white":r==="dark"?"hover:bg-slate-700 text-slate-300":"hover:bg-slate-100 text-slate-600"}`,onMouseDown:()=>{s(D),E.current?.focus()},children:D},D))})]}),A.jsx("section",{className:"flex justify-center -my-2 relative z-10",children:A.jsxs("div",{className:`flex items-center gap-3 px-3 py-1 rounded-full border shadow-sm ${r==="dark"?"bg-slate-800 border-slate-700":"bg-white border-slate-100"}`,children:[n==="er"?A.jsxs("select",{className:"bg-transparent text-[10px] font-black uppercase tracking-widest outline-none cursor-pointer text-blue-500",value:c,onChange:D=>h(D.target.value),children:[A.jsx("option",{value:"one-to-many",children:"1 : N"}),A.jsx("option",{value:"one-to-one",children:"1 : 1"}),A.jsx("option",{value:"many-to-one",children:"N : 1"}),A.jsx("option",{value:"many-to-many",children:"N : N"})]}):A.jsx(Ha,{size:14,className:"text-blue-500 animate-pulse"}),A.jsx("div",{className:"w-px h-3 bg-slate-700/50"}),A.jsx(kre,{size:12,className:"text-slate-500"})]})}),A.jsxs("section",{className:"relative",children:[A.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-slate-500 mb-1.5 block",children:"Target"}),A.jsx("input",{ref:E,type:"text",placeholder:n==="er"?"target.column or *.column":"target_table",className:`w-full px-4 py-2.5 rounded-xl text-sm font-bold outline-none transition-all border-2 border-transparent ${r==="dark"?"bg-slate-800 text-white placeholder-slate-600 focus:border-blue-500/50":"bg-slate-50 text-slate-900 focus:border-blue-500/30"}`,value:l,onChange:D=>{o(D.target.value),y(!0),b(0)},onFocus:()=>y(!0),onBlur:()=>setTimeout(()=>y(!1),200),onKeyDown:D=>B(D,"target")}),m&&O.length>0&&A.jsx("div",{className:`absolute top-full left-0 right-0 mt-1 rounded-xl shadow-xl border-2 overflow-hidden z-[110] ${r==="dark"?"bg-slate-800 border-slate-700":"bg-white border-slate-200"}`,children:O.map((D,_)=>A.jsx("div",{className:`px-4 py-2 text-xs font-bold cursor-pointer ${x===_?"bg-blue-600 text-white":r==="dark"?"hover:bg-slate-700 text-slate-300":"hover:bg-slate-100 text-slate-600"}`,onMouseDown:()=>{o(D)},children:A.jsxs("div",{className:"flex items-center justify-between",children:[A.jsx("span",{children:D}),D.startsWith("*")&&A.jsx("span",{className:"px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400 text-[8px] font-black uppercase",children:"Bulk"})]})},D))})]})]}),A.jsxs("div",{className:"mt-auto flex flex-col gap-3",children:[A.jsxs("button",{onClick:N,className:`w-full py-3 rounded-xl text-[10px] font-black uppercase tracking-[0.2em] shadow-lg transition-all active:scale-[0.98] flex items-center justify-center gap-2 group ${w?"bg-emerald-600 text-white":"bg-blue-600 hover:bg-blue-700 text-white"}`,children:[w?A.jsx(c6,{size:14}):A.jsx(kE,{size:14,className:"group-hover:animate-bounce"}),w?"Connected!":"Connect Objects"]}),A.jsxs("div",{className:"flex items-center justify-center gap-2 text-[9px] text-slate-500 font-bold uppercase tracking-tight text-center",children:[A.jsx(CE,{size:10,className:"text-blue-500 shrink-0"}),A.jsxs("span",{children:["Tip: Use ",A.jsx("kbd",{className:`px-1.5 py-0.5 rounded font-bold ${r==="dark"?"bg-slate-700 text-blue-400":"bg-slate-200 text-blue-700"}`,children:"*.id"})," for bulk linking"]})]})]})]})},xH=""+new URL("../favicon.svg",import.meta.url).href,Xfe=()=>{const{isSidebarOpen:t,setIsSidebarOpen:e,showAnnotations:r,setShowAnnotations:n,showER:i,setShowER:a,showLineage:s,setShowLineage:l,connectMode:o,setConnectMode:c,isCompactMode:h,setIsCompactMode:d,addTable:g,addDomain:m,addAnnotation:y,theme:x,getSelectedTable:b,getSelectedDomain:w}=vt(),[S,k]=ve.useState(!1),E=()=>{const z=window.__modscapeCy;if(!z)return{x:window.innerWidth/2,y:window.innerHeight/2};const H=z.pan(),$=z.zoom(),q=window.innerWidth/2,V=window.innerHeight/2;return{x:(q-H.x)/$,y:(V-H.y)/$}},M=b(),R=w(),O=()=>{const z=E();m(z.x-300,z.y-200)},N=()=>{const z=E();g(z.x-160,z.y-125)},B=()=>{const z=M||R,H=E();r||n(!0),z?y({x:50,y:-50},z.id,M?"table":"domain"):y({x:H.x-60,y:H.y-40})},D=(z,H="text-blue-500")=>`
427
427
  flex items-center justify-center w-10 h-10 rounded-xl transition-all relative group
428
428
  ${z?`bg-blue-600/10 ${H} shadow-inner`:x==="dark"?"text-slate-500 hover:text-slate-300 hover:bg-slate-800/30":"text-slate-400 hover:text-slate-600 hover:bg-slate-100"}
429
- `,_=({text:z})=>A.jsxs("div",{className:"absolute left-14 px-2 py-1 bg-slate-800 text-white text-[10px] font-bold rounded opacity-0 group-hover:opacity-100 pointer-events-none transition-opacity whitespace-nowrap z-[60] border border-slate-700 shadow-xl",children:[z,A.jsx("div",{className:"absolute top-1/2 -left-1 -translate-y-1/2 border-4 border-transparent border-r-slate-800"})]}),P=({keys:z,label:H})=>A.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-slate-100 dark:border-slate-800 last:border-0",children:[A.jsx("span",{className:"text-xs font-medium text-slate-500",children:H}),A.jsx("div",{className:"flex gap-1",children:z.map($=>A.jsx("kbd",{className:"px-1.5 py-0.5 bg-slate-100 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded text-[10px] font-bold font-mono text-slate-600 dark:text-slate-300 min-w-[20px] text-center shadow-sm",children:$},$))})]});return A.jsxs(A.Fragment,{children:[A.jsxs("div",{className:`w-14 h-full flex flex-col items-center py-4 border-l transition-colors z-50 ${x==="dark"?"bg-slate-950 border-slate-800":"bg-slate-50 border-slate-200"}`,children:[A.jsx("button",{onClick:()=>e(!t),className:`mb-6 p-2 rounded-xl transition-all ${x==="dark"?"hover:bg-slate-800 text-slate-400 hover:text-white":"hover:bg-white hover:shadow-md text-slate-500 hover:text-slate-900"}`,children:t?A.jsx(f6,{size:20}):A.jsx("img",{src:xH,alt:"Logo",className:"w-6 h-6 rounded-md shadow-lg"})}),A.jsxs("div",{className:"flex flex-col items-center mb-4 gap-2",children:[A.jsx("div",{className:"text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80 mb-1",children:"View"}),A.jsxs("div",{className:"flex flex-col gap-2",children:[A.jsxs("button",{onClick:()=>l(!s),className:D(s,"text-blue-400"),children:[A.jsx(C4,{size:20}),A.jsx(_,{text:s?"Hide Lineage Edges":"Show Lineage Edges"})]}),A.jsxs("button",{onClick:()=>a(!i),className:D(i,"text-slate-400"),children:[A.jsx(Ck,{size:20}),A.jsx(_,{text:i?"Hide ER Edges":"Show ER Edges"})]}),A.jsxs("button",{onClick:()=>n(!r),className:D(r,"text-amber-500"),children:[A.jsx(zu,{size:20}),A.jsx(_,{text:r?"Hide Annotations":"Show Annotations"})]}),A.jsxs("button",{onClick:()=>d(!h),className:D(h,"text-slate-400"),children:[A.jsx(Cne,{size:20}),A.jsx(_,{text:h?"Show Columns":"Hide Columns"})]})]})]}),A.jsx("div",{className:`w-8 border-t mb-4 ${x==="dark"?"border-slate-800":"border-slate-200"}`}),A.jsxs("div",{className:"flex flex-col items-center mb-4 gap-2",children:[A.jsx("div",{className:"text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80 mb-1",children:"Add"}),A.jsxs("div",{className:"flex flex-col gap-2",children:[A.jsxs("button",{onClick:O,className:D(!1,"text-blue-400"),children:[A.jsx(g6,{size:20}),A.jsx(_,{text:"Add Domain (D)"})]}),A.jsxs("button",{onClick:N,className:D(!1,"text-emerald-400"),children:[A.jsx(Ure,{size:20}),A.jsx(_,{text:"Add Table (T)"})]}),A.jsxs("button",{onClick:B,className:D(!1,"text-amber-400"),children:[A.jsxs("div",{className:"relative",children:[A.jsx(zu,{size:20}),A.jsx(Gf,{size:10,className:"absolute -bottom-1 -right-1 text-amber-500 font-bold stroke-[3px]"})]}),A.jsx(_,{text:"Add Sticky Note (S)"})]}),A.jsxs("button",{onClick:()=>c(o==="lineage"?null:"lineage"),className:D(o==="lineage","text-blue-400"),children:[A.jsx(C4,{size:20}),A.jsx(_,{text:o==="lineage"?"Exit Lineage Mode (Esc)":"Draw Lineage Edge (C)"})]}),A.jsxs("button",{onClick:()=>c(o==="er"?null:"er"),className:D(o==="er","text-emerald-400"),children:[A.jsx(Ck,{size:20}),A.jsx(_,{text:o==="er"?"Exit ER Mode (Esc)":"Draw ER Edge"})]})]})]}),A.jsx("div",{className:`w-8 border-t mb-6 ${x==="dark"?"border-slate-800":"border-slate-200"}`}),A.jsxs("div",{className:"mt-auto flex flex-col gap-2",children:[A.jsxs("button",{onClick:()=>window.__modscapeAutoLayout?.(),className:D(!1,"text-orange-400"),children:[A.jsx(Rne,{size:20}),A.jsx(_,{text:"Auto Layout (left → right)"})]}),A.jsxs("button",{onClick:()=>k(!0),className:D(S),children:[A.jsx(h6,{size:20}),A.jsx(_,{text:"Shortcut Guide"})]})]})]}),S&&A.jsxs("div",{className:"fixed inset-0 z-[200] flex items-center justify-center p-4 animate-in fade-in duration-200",children:[A.jsx("div",{className:"absolute inset-0 bg-slate-950/40 backdrop-blur-sm",onClick:()=>k(!1)}),A.jsxs("div",{className:`relative w-full max-w-sm shadow-2xl rounded-2xl border p-6 animate-in zoom-in-95 duration-200 ${x==="dark"?"bg-slate-900 border-slate-700":"bg-white border-slate-200"}`,children:[A.jsxs("div",{className:"flex items-center justify-between mb-6",children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("div",{className:"p-2 bg-blue-500/10 rounded-lg",children:A.jsx(d6,{size:18,className:"text-blue-500"})}),A.jsx("h2",{className:"font-bold text-base",children:"Shortcut Guide"})]}),A.jsx("button",{onClick:()=>k(!1),className:"p-1 hover:bg-slate-100 dark:hover:bg-slate-800 rounded-full transition-colors text-slate-400",children:A.jsx(Oh,{size:20})})]}),A.jsxs("div",{className:"space-y-6",children:[A.jsxs("section",{children:[A.jsx("h3",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-3",children:"General"}),A.jsx(P,{label:"Command Palette",keys:["Ctrl","K"]}),A.jsx(P,{label:"Quick Connect",keys:["L"]}),A.jsx(P,{label:"Find Entities",keys:["/"]}),A.jsx(P,{label:"Switch Theme",keys:["\\"]})]}),A.jsxs("section",{children:[A.jsx("h3",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-3",children:"Quick Create"}),A.jsx(P,{label:"New Table",keys:["T"]}),A.jsx(P,{label:"New Domain",keys:["D"]}),A.jsx(P,{label:"New Sticky Note",keys:["S"]})]}),A.jsxs("section",{children:[A.jsx("h3",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-3",children:"Canvas Control"}),A.jsx(P,{label:"Pan / Scroll",keys:["↑","↓","←","→"]}),A.jsx(P,{label:"Clear Selection",keys:["Esc"]}),A.jsx(P,{label:"Delete Selected",keys:["Del","⌫"]})]})]}),A.jsx("div",{className:"mt-8 pt-4 border-t border-slate-100 dark:border-slate-800 flex justify-center",children:A.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"Pro-tip: Focus the canvas to use shortcuts."})})]})]})]})},Wfe=ve.memo(()=>{const{isSidebarOpen:t,isCliMode:e,theme:r,savingStatus:n,activeTab:i,setActiveTab:a}=vt(so(s=>({isSidebarOpen:s.isSidebarOpen,isCliMode:s.isCliMode,theme:s.theme,savingStatus:s.savingStatus,activeTab:s.activeTab,setActiveTab:s.setActiveTab})));return A.jsxs("div",{className:`relative h-full flex flex-row border-r transition-all duration-300 ease-in-out shadow-2xl z-50 ${t?"w-[456px]":"w-14"} ${r==="dark"?"bg-slate-900 border-slate-800":"bg-white border-slate-200"}`,children:[A.jsxs("div",{className:`flex-1 flex flex-col min-w-0 overflow-hidden transition-all duration-300 sidebar-content ${r==="dark"?"bg-slate-900":"bg-white"} ${t?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"}`,style:{width:t?"400px":"0px"},children:[A.jsxs("div",{className:`p-4 border-b flex items-center justify-between ${r==="dark"?"border-slate-800":"border-slate-100"}`,children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("img",{src:xH,alt:"Modscape Logo",className:"w-5 h-5 rounded-md"}),A.jsx("h1",{className:`text-base font-bold tracking-tight ${r==="dark"?"text-white":"text-slate-900"}`,children:"Modscape"}),e&&A.jsx("span",{className:"px-1.5 py-0.5 bg-emerald-500/10 border border-emerald-500/30 text-emerald-500 text-[10px] font-bold rounded uppercase ml-1 animate-pulse",title:"Connected & Syncing",children:"Live"})]}),n==="saving"&&A.jsx("span",{className:"text-[10px] text-slate-500 animate-pulse uppercase font-bold tracking-widest",children:"Saving..."})]}),A.jsx("div",{className:"mt-4",children:A.jsx(Gfe,{})}),A.jsx("div",{className:"px-4 mt-6",children:A.jsxs("div",{className:`flex p-1 rounded-xl ${r==="dark"?"bg-slate-800/50":"bg-slate-100"}`,children:[A.jsxs("button",{onClick:()=>a("editor"),className:`flex-1 flex items-center justify-center gap-2 py-2 rounded-lg text-[10px] font-black uppercase tracking-widest transition-all ${i==="editor"?r==="dark"?"bg-slate-700 text-blue-400 shadow-lg":"bg-white text-blue-600 shadow-sm":"text-slate-500 hover:text-slate-400"}`,children:[A.jsx(Fre,{size:14}),"Editor"]}),A.jsxs("button",{onClick:()=>a("connect"),className:`flex-1 flex items-center justify-center gap-2 py-2 rounded-lg text-[10px] font-black uppercase tracking-widest transition-all ${i==="connect"?r==="dark"?"bg-slate-700 text-blue-400 shadow-lg":"bg-white text-blue-600 shadow-sm":"text-slate-500 hover:text-slate-400"}`,children:[A.jsx(kE,{size:14}),"Connect"]})]})}),A.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden mt-4",children:i==="connect"?A.jsx(Yfe,{}):A.jsx($fe,{})}),A.jsx("div",{className:`p-3 border-t flex items-center justify-between ${r==="dark"?"border-slate-800 bg-slate-950/20":"border-slate-100 bg-slate-50/50"}`,children:A.jsx("p",{className:"text-[10px] text-slate-500 font-medium px-1",children:"Modscape v2.0.2"})})]}),A.jsx(Xfe,{})]})}),Qfe=ve.memo(()=>{const{schema:t,theme:e,setSelectedTableId:r,setFocusNodeId:n,isRightPanelOpen:i,activeRightPanelTab:a}=vt(so(y=>({schema:y.schema,theme:y.theme,setSelectedTableId:y.setSelectedTableId,setFocusNodeId:y.setFocusNodeId,isRightPanelOpen:y.isRightPanelOpen,activeRightPanelTab:y.activeRightPanelTab}))),[s,l]=ve.useState(""),[o,c]=ve.useState(new Set),h=ve.useRef(null);ve.useEffect(()=>{if(i&&a==="tables"){const y=setTimeout(()=>h.current?.focus(),300);return()=>clearTimeout(y)}},[i,a]);const d=y=>{const x=new Set(o);x.has(y)?x.delete(y):x.add(y),c(x)},g=y=>{r(y),n(y)},m=ve.useMemo(()=>{if(!t)return{domains:[],unassigned:[]};const y={},x=new Set;t.domains?.forEach(S=>{y[S.id]=[]}),t.tables.forEach(S=>{const k=t.domains?.find(M=>M.tables.includes(S.id));(S.name.toLowerCase().includes(s.toLowerCase())||S.id.toLowerCase().includes(s.toLowerCase()))&&k&&(y[k.id].push(S),x.add(S.id))});const b=(t.domains||[]).filter(S=>{const k=y[S.id].length>0,E=S.name.toLowerCase().includes(s.toLowerCase())||S.id.toLowerCase().includes(s.toLowerCase());return k||E&&s!==""}).map(S=>({...S,tables:y[S.id]})),w=t.tables.filter(S=>(S.name.toLowerCase().includes(s.toLowerCase())||S.id.toLowerCase().includes(s.toLowerCase()))&&!x.has(S.id)&&!t.domains?.some(E=>E.tables.includes(S.id)));return{domains:b,unassigned:w}},[t,s]);return A.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[A.jsxs("div",{className:"relative mb-4 shrink-0",children:[A.jsx(Tu,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),A.jsx("input",{ref:h,type:"text",value:s,onChange:y=>l(y.target.value),placeholder:"Search tables...",className:`w-full pl-9 pr-4 py-2 rounded-md text-sm transition-all shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500/50 ${e==="dark"?"bg-slate-800 border-slate-700 text-slate-100":"bg-white border-slate-200 text-slate-900 shadow-slate-200/50"}`})]}),A.jsxs("div",{className:"flex-1 space-y-4 overflow-auto pr-1",children:[m.domains.map(y=>{const x=o.has(y.id);return A.jsxs("section",{className:"flex flex-col",children:[A.jsxs("div",{className:`flex items-center justify-between group px-1 py-1.5 cursor-pointer rounded transition-colors ${e==="dark"?"hover:bg-slate-800/30":"hover:bg-slate-100"}`,onClick:()=>d(y.id),children:[A.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[x?A.jsx(Eg,{size:12,className:"text-slate-500"}):A.jsx(Ha,{size:12,className:"text-slate-500"}),A.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:y.color||"#3b82f6"}}),A.jsx("h3",{className:`text-[10px] font-bold uppercase tracking-wider truncate ${e==="dark"?"text-slate-300":"text-slate-600"}`,children:y.name}),A.jsx("span",{className:`text-[9px] font-medium px-1.5 py-0.5 rounded-full ${e==="dark"?"text-slate-600 bg-slate-800/50":"text-slate-400 bg-slate-100"}`,children:y.tables.length})]}),A.jsx("button",{onClick:b=>{b.stopPropagation(),g(y.id)},className:"opacity-0 group-hover:opacity-100 p-1 hover:text-blue-500 text-slate-500 transition-all",children:A.jsx(Wp,{size:12})})]}),!x&&A.jsxs("div",{className:`ml-4 mt-1 space-y-0.5 border-l pl-2 ${e==="dark"?"border-slate-800":"border-slate-100"}`,children:[y.tables.map(b=>A.jsxs("button",{onClick:()=>g(b.id),className:`w-full flex items-center justify-between group p-1.5 text-xs rounded border border-transparent transition-all text-left ${e==="dark"?"hover:bg-slate-800/50 text-slate-400 hover:text-slate-200":"hover:bg-blue-50 text-slate-500 hover:text-blue-600"}`,children:[A.jsxs("span",{className:"flex flex-col min-w-0",children:[A.jsx("span",{className:"truncate",children:b.name}),b.name!==b.id&&A.jsx("span",{className:"truncate font-mono text-[9px] opacity-50",children:b.id})]}),A.jsx(Wp,{size:10,className:"opacity-0 group-hover:opacity-100 shrink-0"})]},b.id)),y.tables.length===0&&A.jsx("div",{className:"p-2 text-[10px] text-slate-500 italic",children:"No tables"})]})]},y.id)}),m.unassigned.length>0&&A.jsxs("section",{className:"flex flex-col",children:[A.jsx("div",{className:`flex items-center justify-between group px-1 py-1.5 cursor-pointer rounded transition-colors ${e==="dark"?"hover:bg-slate-800/30":"hover:bg-slate-100"}`,onClick:()=>d("unassigned"),children:A.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[o.has("unassigned")?A.jsx(Eg,{size:12,className:"text-slate-500"}):A.jsx(Ha,{size:12,className:"text-slate-500"}),A.jsx(h6,{size:12,className:"text-slate-500 shrink-0"}),A.jsx("h3",{className:`text-[10px] font-bold uppercase tracking-wider truncate ${e==="dark"?"text-slate-500":"text-slate-400"}`,children:"Unassigned"}),A.jsx("span",{className:`text-[9px] font-medium px-1.5 py-0.5 rounded-full ${e==="dark"?"text-slate-600 bg-slate-800/50":"text-slate-400 bg-slate-100"}`,children:m.unassigned.length})]})}),!o.has("unassigned")&&A.jsx("div",{className:`ml-4 mt-1 space-y-0.5 border-l pl-2 ${e==="dark"?"border-slate-800":"border-slate-100"}`,children:m.unassigned.map(y=>A.jsxs("button",{onClick:()=>g(y.id),className:`w-full flex items-center justify-between group p-1.5 text-xs rounded border border-transparent transition-all text-left ${e==="dark"?"hover:bg-slate-800/50 text-slate-400 hover:text-slate-200":"hover:bg-blue-50 text-slate-500 hover:text-blue-600"}`,children:[A.jsxs("span",{className:"flex flex-col min-w-0",children:[A.jsx("span",{className:"truncate",children:y.name}),y.name!==y.id&&A.jsx("span",{className:"truncate font-mono text-[9px] opacity-50",children:y.id})]}),A.jsx(Wp,{size:10,className:"opacity-0 group-hover:opacity-100 shrink-0"})]},y.id))})]})]})]})}),Kfe=t=>{const e={},r=(n,i,a,s,l)=>{e[n]||(e[n]=[]),e[n].push({from:n,to:i,type:a,id:s,metadata:l}),e[i]||(e[i]=[]),e[i].push({from:i,to:n,type:a,id:s,metadata:l})};return t.relationships?.forEach((n,i)=>{r(n.from.table,n.to.table,"er",`er-${i}`,n)}),t.lineage?.forEach((n,i)=>{r(n.from,n.to,"lineage",`lin-${n.from}-${n.to}-${i}`,{direction:"upstream"})}),e},Zfe=(t,e,r)=>{if(e===r)return[];const n=Kfe(t),i=[e],a=new Set([e]),s={};for(;i.length>0;){const l=i.shift();if(l===r){const c=[];let h=r;for(;h!==e;){const d=s[h];c.unshift(d),h=d.from}return c}const o=n[l]||[];for(const c of o)a.has(c.to)||(a.add(c.to),s[c.to]={from:l,to:c.to,edge:c},i.push(c.to))}return null},Jfe=()=>{const{schema:t,theme:e,setPathFinderResult:r,setFocusNodeId:n}=vt(),[i,a]=ve.useState(""),[s,l]=ve.useState(""),[o,c]=ve.useState(null),[h,d]=ve.useState(!1),g=ve.useMemo(()=>t?.tables||[],[t]),m=()=>{if(!t||!i||!s)return;const x=Zfe(t,i,s);if(c(x),d(!0),x){const b=Array.from(new Set([i,...x.map(S=>S.to)])),w=x.map(S=>S.edge.id);r({nodeIds:b,edgeIds:w})}else r(null)},y=()=>{c(null),d(!1),r(null)};return A.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[A.jsxs("div",{className:"space-y-4 mb-6",children:[A.jsxs("div",{children:[A.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-widest block mb-1.5",children:"From Table"}),A.jsxs("select",{value:i,onChange:x=>a(x.target.value),className:`w-full p-2 rounded-md text-sm border shadow-sm focus:ring-1 focus:ring-blue-500/50 outline-none ${e==="dark"?"bg-slate-800 border-slate-700 text-slate-100":"bg-white border-slate-200 text-slate-900"}`,children:[A.jsx("option",{value:"",children:"Select source..."}),g.map(x=>A.jsx("option",{value:x.id,children:x.name},x.id))]})]}),A.jsxs("div",{children:[A.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-widest block mb-1.5",children:"To Table"}),A.jsxs("select",{value:s,onChange:x=>l(x.target.value),className:`w-full p-2 rounded-md text-sm border shadow-sm focus:ring-1 focus:ring-blue-500/50 outline-none ${e==="dark"?"bg-slate-800 border-slate-700 text-slate-100":"bg-white border-slate-200 text-slate-900"}`,children:[A.jsx("option",{value:"",children:"Select target..."}),g.map(x=>A.jsx("option",{value:x.id,children:x.name},x.id))]})]}),A.jsxs("div",{className:"flex gap-2 pt-2",children:[A.jsxs("button",{onClick:m,disabled:!i||!s,className:`flex-1 flex items-center justify-center gap-2 py-2 rounded-md text-xs font-bold transition-all ${!i||!s?"bg-slate-100 text-slate-400 cursor-not-allowed":"bg-blue-600 text-white hover:bg-blue-500 shadow-lg shadow-blue-500/20 active:scale-95"}`,children:[A.jsx(Tu,{size:14}),"FIND PATH"]}),h&&A.jsx("button",{onClick:y,className:`p-2 rounded-md border transition-all hover:bg-slate-100 dark:hover:bg-slate-800 ${e==="dark"?"border-slate-700 text-slate-400":"border-slate-200 text-slate-500"}`,title:"Clear search results",children:A.jsx(Oh,{size:14})})]})]}),A.jsxs("div",{className:"flex-1 overflow-auto pr-1",children:[h&&!o&&A.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center",children:[A.jsx(Qp,{size:32,className:"text-slate-300 mb-2"}),A.jsx("p",{className:"text-sm text-slate-500 italic",children:"No path found between these tables."})]}),o&&A.jsxs("div",{className:"space-y-1",children:[A.jsx("div",{className:`p-3 rounded-lg border border-l-4 border-l-blue-500 mb-4 ${e==="dark"?"bg-slate-800/30 border-slate-700":"bg-blue-50/50 border-blue-100"}`,children:A.jsxs("p",{className:"text-xs font-medium text-slate-500",children:["Path found with ",A.jsx("span",{className:"font-bold text-blue-500",children:o.length})," steps"]})}),A.jsxs("div",{className:"relative pl-4 space-y-0",children:[A.jsx("div",{className:"absolute left-1 top-2 bottom-2 w-0.5 bg-slate-200 dark:bg-slate-800"}),A.jsxs("div",{className:"relative mb-4",children:[A.jsx("div",{className:"absolute -left-[15px] top-1 w-2.5 h-2.5 rounded-full bg-blue-500 border-2 border-white dark:border-slate-900"}),A.jsx("button",{onClick:()=>n(i),className:"text-xs font-bold hover:text-blue-500 transition-colors",children:g.find(x=>x.id===i)?.name})]}),o.map((x,b)=>A.jsxs("div",{className:"mb-4",children:[A.jsxs("div",{className:`flex items-center gap-2 my-2 py-1 px-2 rounded border w-fit transition-colors ${e==="dark"?"bg-slate-800/50 border-slate-700 text-slate-400":x.edge.type==="er"?"bg-emerald-50 border-emerald-100 text-emerald-700":"bg-blue-50 border-blue-100 text-blue-700"}`,children:[x.edge.type==="er"?A.jsx(Hl,{size:10,className:e==="dark"?"text-emerald-500":"text-emerald-600"}):A.jsx(SE,{size:10,className:e==="dark"?"text-blue-400":"text-blue-600"}),A.jsx("span",{className:"text-[9px] font-bold uppercase tracking-tighter",children:x.edge.type==="er"?`ER (${x.edge.metadata.type})`:"Lineage"})]}),A.jsxs("div",{className:"relative",children:[A.jsx("div",{className:"absolute -left-[15px] top-1 w-2.5 h-2.5 rounded-full bg-slate-400 border-2 border-white dark:border-slate-900"}),A.jsx("button",{onClick:()=>n(x.to),className:"text-xs font-bold hover:text-blue-500 transition-colors",children:g.find(w=>w.id===x.to)?.name})]})]},b))]})]})]})]})},ehe=()=>{const{schema:t,theme:e,setSelectedAnnotationId:r,setFocusNodeId:n}=vt(),[i,a]=ve.useState(""),s=ve.useMemo(()=>t?.annotations?t.annotations.filter(o=>o.text.toLowerCase().includes(i.toLowerCase())):[],[t,i]),l=o=>{r(o),n(o)};return A.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[A.jsxs("div",{className:"relative mb-4 shrink-0",children:[A.jsx(Tu,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),A.jsx("input",{type:"text",value:i,onChange:o=>a(o.target.value),placeholder:"Search notes...",className:`w-full pl-9 pr-4 py-2 rounded-md text-sm transition-all shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500/50 ${e==="dark"?"bg-slate-800 border-slate-700 text-slate-100":"bg-white border-slate-200 text-slate-900 shadow-slate-200/50"}`})]}),A.jsxs("div",{className:"flex-1 space-y-2 overflow-auto pr-1",children:[s.length===0&&i&&A.jsxs("div",{className:"text-center py-10 text-slate-500 italic text-sm",children:['No notes matching "',i,'"']}),s.map(o=>A.jsxs("button",{onClick:()=>l(o.id),className:`w-full p-3 text-left rounded-lg border transition-all group relative ${e==="dark"?"bg-slate-800/40 border-slate-700 hover:border-blue-500/50 hover:bg-slate-800/60":"bg-white border-slate-200 hover:border-blue-300 hover:bg-blue-50/30 shadow-sm"}`,children:[A.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[A.jsx(zu,{size:12,className:o.type==="callout"?"text-blue-400":"text-amber-400"}),A.jsx("span",{className:"text-[10px] font-bold uppercase tracking-tighter text-slate-500",children:o.type==="callout"?"Callout":"Sticky Note"}),A.jsx(Wp,{size:12,className:"ml-auto opacity-0 group-hover:opacity-100 transition-opacity text-blue-500"})]}),A.jsx("p",{className:`text-xs line-clamp-3 leading-relaxed ${e==="dark"?"text-slate-300":"text-slate-600"}`,children:o.text}),o.targetId&&A.jsxs("div",{className:"mt-2 flex items-center gap-1.5 opacity-60",children:[A.jsx("div",{className:"w-1 h-1 rounded-full bg-slate-400"}),A.jsxs("span",{className:"text-[9px] font-medium truncate italic",children:["Attached to ",o.targetId]})]})]},o.id)),!i&&s.length===0&&A.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center opacity-40",children:[A.jsx(p6,{size:48,className:"mb-4 text-slate-400"}),A.jsx("p",{className:"text-sm font-medium",children:"No annotations in this model yet."})]})]})]})},the=ve.memo(()=>{const{isRightPanelOpen:t,setIsRightPanelOpen:e,activeRightPanelTab:r,setActiveRightPanelTab:n,theme:i,isPresentationMode:a,setIsPresentationMode:s,toggleTheme:l}=vt(so(h=>({isRightPanelOpen:h.isRightPanelOpen,setIsRightPanelOpen:h.setIsRightPanelOpen,activeRightPanelTab:h.activeRightPanelTab,setActiveRightPanelTab:h.setActiveRightPanelTab,theme:h.theme,isPresentationMode:h.isPresentationMode,setIsPresentationMode:h.setIsPresentationMode,toggleTheme:h.toggleTheme}))),o=h=>`
429
+ `,_=({text:z})=>A.jsxs("div",{className:"absolute left-14 px-2 py-1 bg-slate-800 text-white text-[10px] font-bold rounded opacity-0 group-hover:opacity-100 pointer-events-none transition-opacity whitespace-nowrap z-[60] border border-slate-700 shadow-xl",children:[z,A.jsx("div",{className:"absolute top-1/2 -left-1 -translate-y-1/2 border-4 border-transparent border-r-slate-800"})]}),P=({keys:z,label:H})=>A.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-slate-100 dark:border-slate-800 last:border-0",children:[A.jsx("span",{className:"text-xs font-medium text-slate-500",children:H}),A.jsx("div",{className:"flex gap-1",children:z.map($=>A.jsx("kbd",{className:"px-1.5 py-0.5 bg-slate-100 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded text-[10px] font-bold font-mono text-slate-600 dark:text-slate-300 min-w-[20px] text-center shadow-sm",children:$},$))})]});return A.jsxs(A.Fragment,{children:[A.jsxs("div",{className:`w-14 h-full flex flex-col items-center py-4 border-l transition-colors z-50 ${x==="dark"?"bg-slate-950 border-slate-800":"bg-slate-50 border-slate-200"}`,children:[A.jsx("button",{onClick:()=>e(!t),className:`mb-6 p-2 rounded-xl transition-all ${x==="dark"?"hover:bg-slate-800 text-slate-400 hover:text-white":"hover:bg-white hover:shadow-md text-slate-500 hover:text-slate-900"}`,children:t?A.jsx(f6,{size:20}):A.jsx("img",{src:xH,alt:"Logo",className:"w-6 h-6 rounded-md shadow-lg"})}),A.jsxs("div",{className:"flex flex-col items-center mb-4 gap-2",children:[A.jsx("div",{className:"text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80 mb-1",children:"View"}),A.jsxs("div",{className:"flex flex-col gap-2",children:[A.jsxs("button",{onClick:()=>l(!s),className:D(s,"text-blue-400"),children:[A.jsx(C4,{size:20}),A.jsx(_,{text:s?"Hide Lineage Edges":"Show Lineage Edges"})]}),A.jsxs("button",{onClick:()=>a(!i),className:D(i,"text-slate-400"),children:[A.jsx(Ck,{size:20}),A.jsx(_,{text:i?"Hide ER Edges":"Show ER Edges"})]}),A.jsxs("button",{onClick:()=>n(!r),className:D(r,"text-amber-500"),children:[A.jsx(zu,{size:20}),A.jsx(_,{text:r?"Hide Annotations":"Show Annotations"})]}),A.jsxs("button",{onClick:()=>d(!h),className:D(!h,"text-slate-400"),children:[A.jsx(Cne,{size:20}),A.jsx(_,{text:h?"Show Columns":"Hide Columns"})]})]})]}),A.jsx("div",{className:`w-8 border-t mb-4 ${x==="dark"?"border-slate-800":"border-slate-200"}`}),A.jsxs("div",{className:"flex flex-col items-center mb-4 gap-2",children:[A.jsx("div",{className:"text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80 mb-1",children:"Add"}),A.jsxs("div",{className:"flex flex-col gap-2",children:[A.jsxs("button",{onClick:O,className:D(!1,"text-blue-400"),children:[A.jsx(g6,{size:20}),A.jsx(_,{text:"Add Domain (D)"})]}),A.jsxs("button",{onClick:N,className:D(!1,"text-emerald-400"),children:[A.jsx(Ure,{size:20}),A.jsx(_,{text:"Add Table (T)"})]}),A.jsxs("button",{onClick:B,className:D(!1,"text-amber-400"),children:[A.jsxs("div",{className:"relative",children:[A.jsx(zu,{size:20}),A.jsx(Gf,{size:10,className:"absolute -bottom-1 -right-1 text-amber-500 font-bold stroke-[3px]"})]}),A.jsx(_,{text:"Add Sticky Note (S)"})]}),A.jsxs("button",{onClick:()=>c(o==="lineage"?null:"lineage"),className:D(o==="lineage","text-blue-400"),children:[A.jsx(C4,{size:20}),A.jsx(_,{text:o==="lineage"?"Exit Lineage Mode (Esc)":"Draw Lineage Edge (C)"})]}),A.jsxs("button",{onClick:()=>c(o==="er"?null:"er"),className:D(o==="er","text-emerald-400"),children:[A.jsx(Ck,{size:20}),A.jsx(_,{text:o==="er"?"Exit ER Mode (Esc)":"Draw ER Edge"})]})]})]}),A.jsx("div",{className:`w-8 border-t mb-6 ${x==="dark"?"border-slate-800":"border-slate-200"}`}),A.jsxs("div",{className:"mt-auto flex flex-col gap-2",children:[A.jsxs("button",{onClick:()=>window.__modscapeAutoLayout?.(),className:D(!1,"text-orange-400"),children:[A.jsx(Rne,{size:20}),A.jsx(_,{text:"Auto Layout (left → right)"})]}),A.jsxs("button",{onClick:()=>k(!0),className:D(S),children:[A.jsx(h6,{size:20}),A.jsx(_,{text:"Shortcut Guide"})]})]})]}),S&&A.jsxs("div",{className:"fixed inset-0 z-[200] flex items-center justify-center p-4 animate-in fade-in duration-200",children:[A.jsx("div",{className:"absolute inset-0 bg-slate-950/40 backdrop-blur-sm",onClick:()=>k(!1)}),A.jsxs("div",{className:`relative w-full max-w-sm shadow-2xl rounded-2xl border p-6 animate-in zoom-in-95 duration-200 ${x==="dark"?"bg-slate-900 border-slate-700":"bg-white border-slate-200"}`,children:[A.jsxs("div",{className:"flex items-center justify-between mb-6",children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("div",{className:"p-2 bg-blue-500/10 rounded-lg",children:A.jsx(d6,{size:18,className:"text-blue-500"})}),A.jsx("h2",{className:"font-bold text-base",children:"Shortcut Guide"})]}),A.jsx("button",{onClick:()=>k(!1),className:"p-1 hover:bg-slate-100 dark:hover:bg-slate-800 rounded-full transition-colors text-slate-400",children:A.jsx(Oh,{size:20})})]}),A.jsxs("div",{className:"space-y-6",children:[A.jsxs("section",{children:[A.jsx("h3",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-3",children:"General"}),A.jsx(P,{label:"Command Palette",keys:["Ctrl","K"]}),A.jsx(P,{label:"Quick Connect",keys:["L"]}),A.jsx(P,{label:"Find Entities",keys:["/"]}),A.jsx(P,{label:"Switch Theme",keys:["\\"]})]}),A.jsxs("section",{children:[A.jsx("h3",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-3",children:"Quick Create"}),A.jsx(P,{label:"New Table",keys:["T"]}),A.jsx(P,{label:"New Domain",keys:["D"]}),A.jsx(P,{label:"New Sticky Note",keys:["S"]})]}),A.jsxs("section",{children:[A.jsx("h3",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-3",children:"Canvas Control"}),A.jsx(P,{label:"Pan / Scroll",keys:["↑","↓","←","→"]}),A.jsx(P,{label:"Clear Selection",keys:["Esc"]}),A.jsx(P,{label:"Delete Selected",keys:["Del","⌫"]})]})]}),A.jsx("div",{className:"mt-8 pt-4 border-t border-slate-100 dark:border-slate-800 flex justify-center",children:A.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"Pro-tip: Focus the canvas to use shortcuts."})})]})]})]})},Wfe=ve.memo(()=>{const{isSidebarOpen:t,isCliMode:e,theme:r,savingStatus:n,activeTab:i,setActiveTab:a}=vt(so(s=>({isSidebarOpen:s.isSidebarOpen,isCliMode:s.isCliMode,theme:s.theme,savingStatus:s.savingStatus,activeTab:s.activeTab,setActiveTab:s.setActiveTab})));return A.jsxs("div",{className:`relative h-full flex flex-row border-r transition-all duration-300 ease-in-out shadow-2xl z-50 ${t?"w-[456px]":"w-14"} ${r==="dark"?"bg-slate-900 border-slate-800":"bg-white border-slate-200"}`,children:[A.jsxs("div",{className:`flex-1 flex flex-col min-w-0 overflow-hidden transition-all duration-300 sidebar-content ${r==="dark"?"bg-slate-900":"bg-white"} ${t?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"}`,style:{width:t?"400px":"0px"},children:[A.jsxs("div",{className:`p-4 border-b flex items-center justify-between ${r==="dark"?"border-slate-800":"border-slate-100"}`,children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("img",{src:xH,alt:"Modscape Logo",className:"w-5 h-5 rounded-md"}),A.jsx("h1",{className:`text-base font-bold tracking-tight ${r==="dark"?"text-white":"text-slate-900"}`,children:"Modscape"}),e&&A.jsx("span",{className:"px-1.5 py-0.5 bg-emerald-500/10 border border-emerald-500/30 text-emerald-500 text-[10px] font-bold rounded uppercase ml-1 animate-pulse",title:"Connected & Syncing",children:"Live"})]}),n==="saving"&&A.jsx("span",{className:"text-[10px] text-slate-500 animate-pulse uppercase font-bold tracking-widest",children:"Saving..."})]}),A.jsx("div",{className:"mt-4",children:A.jsx(Gfe,{})}),A.jsx("div",{className:"px-4 mt-6",children:A.jsxs("div",{className:`flex p-1 rounded-xl ${r==="dark"?"bg-slate-800/50":"bg-slate-100"}`,children:[A.jsxs("button",{onClick:()=>a("editor"),className:`flex-1 flex items-center justify-center gap-2 py-2 rounded-lg text-[10px] font-black uppercase tracking-widest transition-all ${i==="editor"?r==="dark"?"bg-slate-700 text-blue-400 shadow-lg":"bg-white text-blue-600 shadow-sm":"text-slate-500 hover:text-slate-400"}`,children:[A.jsx(Fre,{size:14}),"Editor"]}),A.jsxs("button",{onClick:()=>a("connect"),className:`flex-1 flex items-center justify-center gap-2 py-2 rounded-lg text-[10px] font-black uppercase tracking-widest transition-all ${i==="connect"?r==="dark"?"bg-slate-700 text-blue-400 shadow-lg":"bg-white text-blue-600 shadow-sm":"text-slate-500 hover:text-slate-400"}`,children:[A.jsx(kE,{size:14}),"Connect"]})]})}),A.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden mt-4",children:i==="connect"?A.jsx(Yfe,{}):A.jsx($fe,{})}),A.jsx("div",{className:`p-3 border-t flex items-center justify-between ${r==="dark"?"border-slate-800 bg-slate-950/20":"border-slate-100 bg-slate-50/50"}`,children:A.jsx("p",{className:"text-[10px] text-slate-500 font-medium px-1",children:"Modscape v2.0.3"})})]}),A.jsx(Xfe,{})]})}),Qfe=ve.memo(()=>{const{schema:t,theme:e,setSelectedTableId:r,setFocusNodeId:n,isRightPanelOpen:i,activeRightPanelTab:a}=vt(so(y=>({schema:y.schema,theme:y.theme,setSelectedTableId:y.setSelectedTableId,setFocusNodeId:y.setFocusNodeId,isRightPanelOpen:y.isRightPanelOpen,activeRightPanelTab:y.activeRightPanelTab}))),[s,l]=ve.useState(""),[o,c]=ve.useState(new Set),h=ve.useRef(null);ve.useEffect(()=>{if(i&&a==="tables"){const y=setTimeout(()=>h.current?.focus(),300);return()=>clearTimeout(y)}},[i,a]);const d=y=>{const x=new Set(o);x.has(y)?x.delete(y):x.add(y),c(x)},g=y=>{r(y),n(y)},m=ve.useMemo(()=>{if(!t)return{domains:[],unassigned:[]};const y={},x=new Set;t.domains?.forEach(S=>{y[S.id]=[]}),t.tables.forEach(S=>{const k=t.domains?.find(M=>M.tables.includes(S.id));(S.name.toLowerCase().includes(s.toLowerCase())||S.id.toLowerCase().includes(s.toLowerCase()))&&k&&(y[k.id].push(S),x.add(S.id))});const b=(t.domains||[]).filter(S=>{const k=y[S.id].length>0,E=S.name.toLowerCase().includes(s.toLowerCase())||S.id.toLowerCase().includes(s.toLowerCase());return k||E&&s!==""}).map(S=>({...S,tables:y[S.id]})),w=t.tables.filter(S=>(S.name.toLowerCase().includes(s.toLowerCase())||S.id.toLowerCase().includes(s.toLowerCase()))&&!x.has(S.id)&&!t.domains?.some(E=>E.tables.includes(S.id)));return{domains:b,unassigned:w}},[t,s]);return A.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[A.jsxs("div",{className:"relative mb-4 shrink-0",children:[A.jsx(Tu,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),A.jsx("input",{ref:h,type:"text",value:s,onChange:y=>l(y.target.value),placeholder:"Search tables...",className:`w-full pl-9 pr-4 py-2 rounded-md text-sm transition-all shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500/50 ${e==="dark"?"bg-slate-800 border-slate-700 text-slate-100":"bg-white border-slate-200 text-slate-900 shadow-slate-200/50"}`})]}),A.jsxs("div",{className:"flex-1 space-y-4 overflow-auto pr-1",children:[m.domains.map(y=>{const x=o.has(y.id);return A.jsxs("section",{className:"flex flex-col",children:[A.jsxs("div",{className:`flex items-center justify-between group px-1 py-1.5 cursor-pointer rounded transition-colors ${e==="dark"?"hover:bg-slate-800/30":"hover:bg-slate-100"}`,onClick:()=>d(y.id),children:[A.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[x?A.jsx(Eg,{size:12,className:"text-slate-500"}):A.jsx(Ha,{size:12,className:"text-slate-500"}),A.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:y.color||"#3b82f6"}}),A.jsx("h3",{className:`text-[10px] font-bold uppercase tracking-wider truncate ${e==="dark"?"text-slate-300":"text-slate-600"}`,children:y.name}),A.jsx("span",{className:`text-[9px] font-medium px-1.5 py-0.5 rounded-full ${e==="dark"?"text-slate-600 bg-slate-800/50":"text-slate-400 bg-slate-100"}`,children:y.tables.length})]}),A.jsx("button",{onClick:b=>{b.stopPropagation(),g(y.id)},className:"opacity-0 group-hover:opacity-100 p-1 hover:text-blue-500 text-slate-500 transition-all",children:A.jsx(Wp,{size:12})})]}),!x&&A.jsxs("div",{className:`ml-4 mt-1 space-y-0.5 border-l pl-2 ${e==="dark"?"border-slate-800":"border-slate-100"}`,children:[y.tables.map(b=>A.jsxs("button",{onClick:()=>g(b.id),className:`w-full flex items-center justify-between group p-1.5 text-xs rounded border border-transparent transition-all text-left ${e==="dark"?"hover:bg-slate-800/50 text-slate-400 hover:text-slate-200":"hover:bg-blue-50 text-slate-500 hover:text-blue-600"}`,children:[A.jsxs("span",{className:"flex flex-col min-w-0",children:[A.jsx("span",{className:"truncate",children:b.name}),b.name!==b.id&&A.jsx("span",{className:"truncate font-mono text-[9px] opacity-50",children:b.id})]}),A.jsx(Wp,{size:10,className:"opacity-0 group-hover:opacity-100 shrink-0"})]},b.id)),y.tables.length===0&&A.jsx("div",{className:"p-2 text-[10px] text-slate-500 italic",children:"No tables"})]})]},y.id)}),m.unassigned.length>0&&A.jsxs("section",{className:"flex flex-col",children:[A.jsx("div",{className:`flex items-center justify-between group px-1 py-1.5 cursor-pointer rounded transition-colors ${e==="dark"?"hover:bg-slate-800/30":"hover:bg-slate-100"}`,onClick:()=>d("unassigned"),children:A.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[o.has("unassigned")?A.jsx(Eg,{size:12,className:"text-slate-500"}):A.jsx(Ha,{size:12,className:"text-slate-500"}),A.jsx(h6,{size:12,className:"text-slate-500 shrink-0"}),A.jsx("h3",{className:`text-[10px] font-bold uppercase tracking-wider truncate ${e==="dark"?"text-slate-500":"text-slate-400"}`,children:"Unassigned"}),A.jsx("span",{className:`text-[9px] font-medium px-1.5 py-0.5 rounded-full ${e==="dark"?"text-slate-600 bg-slate-800/50":"text-slate-400 bg-slate-100"}`,children:m.unassigned.length})]})}),!o.has("unassigned")&&A.jsx("div",{className:`ml-4 mt-1 space-y-0.5 border-l pl-2 ${e==="dark"?"border-slate-800":"border-slate-100"}`,children:m.unassigned.map(y=>A.jsxs("button",{onClick:()=>g(y.id),className:`w-full flex items-center justify-between group p-1.5 text-xs rounded border border-transparent transition-all text-left ${e==="dark"?"hover:bg-slate-800/50 text-slate-400 hover:text-slate-200":"hover:bg-blue-50 text-slate-500 hover:text-blue-600"}`,children:[A.jsxs("span",{className:"flex flex-col min-w-0",children:[A.jsx("span",{className:"truncate",children:y.name}),y.name!==y.id&&A.jsx("span",{className:"truncate font-mono text-[9px] opacity-50",children:y.id})]}),A.jsx(Wp,{size:10,className:"opacity-0 group-hover:opacity-100 shrink-0"})]},y.id))})]})]})]})}),Kfe=t=>{const e={},r=(n,i,a,s,l)=>{e[n]||(e[n]=[]),e[n].push({from:n,to:i,type:a,id:s,metadata:l}),e[i]||(e[i]=[]),e[i].push({from:i,to:n,type:a,id:s,metadata:l})};return t.relationships?.forEach((n,i)=>{r(n.from.table,n.to.table,"er",`er-${i}`,n)}),t.lineage?.forEach((n,i)=>{r(n.from,n.to,"lineage",`lin-${n.from}-${n.to}-${i}`,{direction:"upstream"})}),e},Zfe=(t,e,r)=>{if(e===r)return[];const n=Kfe(t),i=[e],a=new Set([e]),s={};for(;i.length>0;){const l=i.shift();if(l===r){const c=[];let h=r;for(;h!==e;){const d=s[h];c.unshift(d),h=d.from}return c}const o=n[l]||[];for(const c of o)a.has(c.to)||(a.add(c.to),s[c.to]={from:l,to:c.to,edge:c},i.push(c.to))}return null},Jfe=()=>{const{schema:t,theme:e,setPathFinderResult:r,setFocusNodeId:n}=vt(),[i,a]=ve.useState(""),[s,l]=ve.useState(""),[o,c]=ve.useState(null),[h,d]=ve.useState(!1),g=ve.useMemo(()=>t?.tables||[],[t]),m=()=>{if(!t||!i||!s)return;const x=Zfe(t,i,s);if(c(x),d(!0),x){const b=Array.from(new Set([i,...x.map(S=>S.to)])),w=x.map(S=>S.edge.id);r({nodeIds:b,edgeIds:w})}else r(null)},y=()=>{c(null),d(!1),r(null)};return A.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[A.jsxs("div",{className:"space-y-4 mb-6",children:[A.jsxs("div",{children:[A.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-widest block mb-1.5",children:"From Table"}),A.jsxs("select",{value:i,onChange:x=>a(x.target.value),className:`w-full p-2 rounded-md text-sm border shadow-sm focus:ring-1 focus:ring-blue-500/50 outline-none ${e==="dark"?"bg-slate-800 border-slate-700 text-slate-100":"bg-white border-slate-200 text-slate-900"}`,children:[A.jsx("option",{value:"",children:"Select source..."}),g.map(x=>A.jsx("option",{value:x.id,children:x.name},x.id))]})]}),A.jsxs("div",{children:[A.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-widest block mb-1.5",children:"To Table"}),A.jsxs("select",{value:s,onChange:x=>l(x.target.value),className:`w-full p-2 rounded-md text-sm border shadow-sm focus:ring-1 focus:ring-blue-500/50 outline-none ${e==="dark"?"bg-slate-800 border-slate-700 text-slate-100":"bg-white border-slate-200 text-slate-900"}`,children:[A.jsx("option",{value:"",children:"Select target..."}),g.map(x=>A.jsx("option",{value:x.id,children:x.name},x.id))]})]}),A.jsxs("div",{className:"flex gap-2 pt-2",children:[A.jsxs("button",{onClick:m,disabled:!i||!s,className:`flex-1 flex items-center justify-center gap-2 py-2 rounded-md text-xs font-bold transition-all ${!i||!s?"bg-slate-100 text-slate-400 cursor-not-allowed":"bg-blue-600 text-white hover:bg-blue-500 shadow-lg shadow-blue-500/20 active:scale-95"}`,children:[A.jsx(Tu,{size:14}),"FIND PATH"]}),h&&A.jsx("button",{onClick:y,className:`p-2 rounded-md border transition-all hover:bg-slate-100 dark:hover:bg-slate-800 ${e==="dark"?"border-slate-700 text-slate-400":"border-slate-200 text-slate-500"}`,title:"Clear search results",children:A.jsx(Oh,{size:14})})]})]}),A.jsxs("div",{className:"flex-1 overflow-auto pr-1",children:[h&&!o&&A.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center",children:[A.jsx(Qp,{size:32,className:"text-slate-300 mb-2"}),A.jsx("p",{className:"text-sm text-slate-500 italic",children:"No path found between these tables."})]}),o&&A.jsxs("div",{className:"space-y-1",children:[A.jsx("div",{className:`p-3 rounded-lg border border-l-4 border-l-blue-500 mb-4 ${e==="dark"?"bg-slate-800/30 border-slate-700":"bg-blue-50/50 border-blue-100"}`,children:A.jsxs("p",{className:"text-xs font-medium text-slate-500",children:["Path found with ",A.jsx("span",{className:"font-bold text-blue-500",children:o.length})," steps"]})}),A.jsxs("div",{className:"relative pl-4 space-y-0",children:[A.jsx("div",{className:"absolute left-1 top-2 bottom-2 w-0.5 bg-slate-200 dark:bg-slate-800"}),A.jsxs("div",{className:"relative mb-4",children:[A.jsx("div",{className:"absolute -left-[15px] top-1 w-2.5 h-2.5 rounded-full bg-blue-500 border-2 border-white dark:border-slate-900"}),A.jsx("button",{onClick:()=>n(i),className:"text-xs font-bold hover:text-blue-500 transition-colors",children:g.find(x=>x.id===i)?.name})]}),o.map((x,b)=>A.jsxs("div",{className:"mb-4",children:[A.jsxs("div",{className:`flex items-center gap-2 my-2 py-1 px-2 rounded border w-fit transition-colors ${e==="dark"?"bg-slate-800/50 border-slate-700 text-slate-400":x.edge.type==="er"?"bg-emerald-50 border-emerald-100 text-emerald-700":"bg-blue-50 border-blue-100 text-blue-700"}`,children:[x.edge.type==="er"?A.jsx(Hl,{size:10,className:e==="dark"?"text-emerald-500":"text-emerald-600"}):A.jsx(SE,{size:10,className:e==="dark"?"text-blue-400":"text-blue-600"}),A.jsx("span",{className:"text-[9px] font-bold uppercase tracking-tighter",children:x.edge.type==="er"?`ER (${x.edge.metadata.type})`:"Lineage"})]}),A.jsxs("div",{className:"relative",children:[A.jsx("div",{className:"absolute -left-[15px] top-1 w-2.5 h-2.5 rounded-full bg-slate-400 border-2 border-white dark:border-slate-900"}),A.jsx("button",{onClick:()=>n(x.to),className:"text-xs font-bold hover:text-blue-500 transition-colors",children:g.find(w=>w.id===x.to)?.name})]})]},b))]})]})]})]})},ehe=()=>{const{schema:t,theme:e,setSelectedAnnotationId:r,setFocusNodeId:n}=vt(),[i,a]=ve.useState(""),s=ve.useMemo(()=>t?.annotations?t.annotations.filter(o=>o.text.toLowerCase().includes(i.toLowerCase())):[],[t,i]),l=o=>{r(o),n(o)};return A.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[A.jsxs("div",{className:"relative mb-4 shrink-0",children:[A.jsx(Tu,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),A.jsx("input",{type:"text",value:i,onChange:o=>a(o.target.value),placeholder:"Search notes...",className:`w-full pl-9 pr-4 py-2 rounded-md text-sm transition-all shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500/50 ${e==="dark"?"bg-slate-800 border-slate-700 text-slate-100":"bg-white border-slate-200 text-slate-900 shadow-slate-200/50"}`})]}),A.jsxs("div",{className:"flex-1 space-y-2 overflow-auto pr-1",children:[s.length===0&&i&&A.jsxs("div",{className:"text-center py-10 text-slate-500 italic text-sm",children:['No notes matching "',i,'"']}),s.map(o=>A.jsxs("button",{onClick:()=>l(o.id),className:`w-full p-3 text-left rounded-lg border transition-all group relative ${e==="dark"?"bg-slate-800/40 border-slate-700 hover:border-blue-500/50 hover:bg-slate-800/60":"bg-white border-slate-200 hover:border-blue-300 hover:bg-blue-50/30 shadow-sm"}`,children:[A.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[A.jsx(zu,{size:12,className:o.type==="callout"?"text-blue-400":"text-amber-400"}),A.jsx("span",{className:"text-[10px] font-bold uppercase tracking-tighter text-slate-500",children:o.type==="callout"?"Callout":"Sticky Note"}),A.jsx(Wp,{size:12,className:"ml-auto opacity-0 group-hover:opacity-100 transition-opacity text-blue-500"})]}),A.jsx("p",{className:`text-xs line-clamp-3 leading-relaxed ${e==="dark"?"text-slate-300":"text-slate-600"}`,children:o.text}),o.targetId&&A.jsxs("div",{className:"mt-2 flex items-center gap-1.5 opacity-60",children:[A.jsx("div",{className:"w-1 h-1 rounded-full bg-slate-400"}),A.jsxs("span",{className:"text-[9px] font-medium truncate italic",children:["Attached to ",o.targetId]})]})]},o.id)),!i&&s.length===0&&A.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center opacity-40",children:[A.jsx(p6,{size:48,className:"mb-4 text-slate-400"}),A.jsx("p",{className:"text-sm font-medium",children:"No annotations in this model yet."})]})]})]})},the=ve.memo(()=>{const{isRightPanelOpen:t,setIsRightPanelOpen:e,activeRightPanelTab:r,setActiveRightPanelTab:n,theme:i,isPresentationMode:a,setIsPresentationMode:s,toggleTheme:l}=vt(so(h=>({isRightPanelOpen:h.isRightPanelOpen,setIsRightPanelOpen:h.setIsRightPanelOpen,activeRightPanelTab:h.activeRightPanelTab,setActiveRightPanelTab:h.setActiveRightPanelTab,theme:h.theme,isPresentationMode:h.isPresentationMode,setIsPresentationMode:h.setIsPresentationMode,toggleTheme:h.toggleTheme}))),o=h=>`
430
430
  flex items-center justify-center w-10 h-10 rounded-xl transition-all relative group
431
431
  ${h?"bg-blue-600/10 text-blue-500 shadow-inner":i==="dark"?"text-slate-500 hover:text-slate-300 hover:bg-slate-800/30":"text-slate-400 hover:text-slate-600 hover:bg-slate-100"}
432
432
  `,c=({text:h})=>A.jsxs("div",{className:"absolute right-14 px-2 py-1 bg-slate-800 text-white text-[10px] font-bold rounded opacity-0 group-hover:opacity-100 pointer-events-none transition-opacity whitespace-nowrap z-[60] border border-slate-700 shadow-xl",children:[h,A.jsx("div",{className:"absolute top-1/2 -right-1 -translate-y-1/2 border-4 border-transparent border-l-slate-800"})]});return A.jsxs("div",{className:`relative h-full flex flex-row transition-all duration-300 ease-in-out shadow-2xl z-50 ${t?"w-[456px]":"w-14"}`,children:[A.jsxs("div",{className:`w-14 h-full flex flex-col items-center py-4 border-l transition-colors z-50 ${i==="dark"?"bg-slate-950 border-slate-800":"bg-slate-50 border-slate-200"}`,children:[A.jsx("button",{onClick:()=>e(!t),className:`mb-6 p-2 rounded-xl transition-all ${i==="dark"?"hover:bg-slate-800 text-slate-400 hover:text-white":"hover:bg-white hover:shadow-md text-slate-500 hover:text-slate-900"}`,children:t?A.jsx(Eg,{size:20}):A.jsx(f6,{size:20})}),A.jsxs("div",{className:"flex flex-col gap-2 mb-6",children:[A.jsxs("button",{onClick:()=>{n("tables"),e(!0)},className:o(r==="tables"&&t),children:[A.jsx(Qre,{size:20}),A.jsx(c,{text:"Tables & Entities"})]}),A.jsxs("button",{onClick:()=>{n("path"),e(!0)},className:o(r==="path"&&t),children:[A.jsx(vne,{size:20}),A.jsx(c,{text:"Path Finder"})]}),A.jsxs("button",{onClick:()=>{n("notes"),e(!0)},className:o(r==="notes"&&t),children:[A.jsx(p6,{size:20}),A.jsx(c,{text:"Note Search"})]})]}),A.jsxs("div",{className:"mt-auto flex flex-col gap-2 pb-2",children:[A.jsxs("button",{onClick:()=>s(!0),className:o(a),children:[A.jsx(fne,{size:20}),A.jsx(c,{text:"Presentation Mode"})]}),A.jsxs("button",{onClick:l,className:o(!1),children:[i==="dark"?A.jsx(kk,{size:20}):A.jsx(nne,{size:20}),A.jsx(c,{text:i==="dark"?"Light Mode":"Dark Mode"})]})]})]}),A.jsxs("div",{className:`flex-1 flex flex-col min-w-0 overflow-hidden transition-all duration-300 sidebar-content ${i==="dark"?"bg-slate-900":"bg-white"} ${t?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"}`,style:{width:t?"400px":"0px"},children:[A.jsx("div",{className:`p-4 border-b flex items-center justify-between ${i==="dark"?"border-slate-800":"border-slate-100"}`,children:A.jsxs("h2",{className:`text-sm font-bold tracking-tight uppercase ${i==="dark"?"text-white":"text-slate-900"}`,children:[r==="tables"&&"Tables",r==="path"&&"Path Finder",r==="notes"&&"Note Search"]})}),r==="tables"&&A.jsx(Qfe,{}),r==="path"&&A.jsx(Jfe,{}),r==="notes"&&A.jsx(ehe,{})]})]})}),rhe=ve.memo(()=>{const{schema:t,isCommandPaletteOpen:e,setIsCommandPaletteOpen:r,executePipeline:n,setHighlightedNodeIds:i,setFocusNodeId:a,theme:s}=vt(so(E=>({schema:E.schema,isCommandPaletteOpen:E.isCommandPaletteOpen,setIsCommandPaletteOpen:E.setIsCommandPaletteOpen,executePipeline:E.executePipeline,setHighlightedNodeIds:E.setHighlightedNodeIds,setFocusNodeId:E.setFocusNodeId,theme:E.theme}))),[l,o]=ve.useState(""),[c,h]=ve.useState(0),[d,g]=ve.useState(null),m=ve.useRef(null),y=ve.useRef(null),x=ve.useMemo(()=>l.trim()?n(l,!0):{stages:[],outputIds:[]},[l,n]),b=ve.useMemo(()=>{if(!t)return[];if(!l.trim().toLowerCase())return[{id:"select",label:"Select tables...",icon:A.jsx(ane,{size:14}),desc:"select [pattern] or select *",action:()=>o("select ")},{id:"search",label:"Find table...",icon:A.jsx(Tu,{size:14}),desc:"Jump to entity",action:()=>o("search ")},{id:"add-table",label:"Add table...",icon:A.jsx(Gf,{size:14}),desc:"Create a new table node",action:()=>o("add table ")},{id:"add-domain",label:"Add domain...",icon:A.jsx(Gf,{size:14}),desc:"Create a new domain container",action:()=>o("add domain ")},{id:"fit",label:"Fit View",icon:A.jsx(ene,{size:14}),desc:"Show entire model",action:()=>w("fit")},{id:"theme",label:"Switch Theme",icon:A.jsx(kk,{size:14}),desc:"Toggle dark/light mode",action:()=>o("theme ")}];const M=l.split("|"),R=M[M.length-1],O=R.trim().split(/\s+/),N=O[0].toLowerCase(),B=M.slice(0,-1).join("|")+(M.length>1?"|":"");if(N==="select"){const D=O.slice(1).join(" ").toLowerCase();return(t.tables||[]).filter(_=>_.id.toLowerCase().includes(D)||_.name.toLowerCase().includes(D)).slice(0,8).map(_=>({id:_.id,label:_.name,icon:A.jsx(Tu,{size:14}),desc:`Table: ${_.id}`,action:()=>o(`${B} select ${_.id}`)}))}if(N==="mv"){const D=O.findIndex(z=>z.toLowerCase()==="to"),_=D>-1?O.slice(D+1).join(" ").toLowerCase():O.slice(1).join(" ").toLowerCase(),P=D>-1?O.slice(0,D+1).join(" "):"mv";return(t.domains||[]).filter(z=>z.id.toLowerCase().includes(_)||z.name.toLowerCase().includes(_)).slice(0,8).map(z=>({id:z.id,label:z.name,icon:A.jsx(lne,{size:14}),desc:`Domain: ${z.id}`,action:()=>o(`${B} ${P} ${z.id}`)}))}if(N==="theme"){const D=O.slice(1).join(" ").toLowerCase();return["dark","light"].filter(_=>_.includes(D)).map(_=>({id:_,label:_,icon:A.jsx(kk,{size:14}),desc:"UI Appearance",action:()=>o(`${B} theme ${_}`)}))}if(N==="search"||N==="find"||!["mv","add","select","theme","fit"].includes(N)){const D=N==="search"||N==="find"?O.slice(1).join(" ").toLowerCase():R.trim().toLowerCase();return(t.tables||[]).filter(_=>_.id.toLowerCase().includes(D)||_.name.toLowerCase().includes(D)).slice(0,10).map(_=>({id:_.id,label:`Go to ${_.name}`,icon:A.jsx(Tu,{size:14}),desc:_.id,action:()=>{N==="search"||N==="find"||M.length===1?(a(_.id),r(!1)):o(`${B} select ${_.id}`)}}))}return[]},[t,l,a,r]);ve.useEffect(()=>{i(e?x.outputIds:[])},[e,x.outputIds,i]),ve.useEffect(()=>{if(y.current){const E=y.current.children[c];E&&E.scrollIntoView({block:"nearest",behavior:"smooth"})}},[c]),ve.useEffect(()=>{e&&(o(""),g(null),h(0),setTimeout(()=>m.current?.focus(),10))},[e]);const w=E=>{const M=E||l;if(!M.trim())return;if(M==="fit"){window.__modscapeFitView?.(),S("success","View fitted");return}const R=n(M,!1);if(R.stages.length>0&&R.stages.every(O=>O.status==="success"))S("success","Pipeline executed successfully");else{const O=R.stages.find(N=>N.status==="error");O&&S("info",O.message)}},S=(E,M)=>{g({type:E,msg:M}),setTimeout(()=>{g(null),E==="success"&&o("")},1500)},k=E=>{E.stopPropagation(),E.key==="Escape"?r(!1):E.key==="ArrowDown"?(E.preventDefault(),h(M=>(M+1)%(b.length||1))):E.key==="ArrowUp"?(E.preventDefault(),h(M=>(M-1+(b.length||1))%(b.length||1))):E.key==="Tab"?(E.preventDefault(),b.length>0&&b[c]&&b[c].action()):E.key==="Enter"&&(E.preventDefault(),w())};return e?A.jsxs("div",{className:`fixed inset-0 z-[2000] flex items-start justify-center pt-[15vh] px-4 backdrop-blur-[2px] animate-in fade-in duration-200 ${s==="dark"?"bg-slate-950/20":"bg-white/20"}`,children:[A.jsx("div",{className:"absolute inset-0",onClick:()=>r(!1)}),A.jsxs("div",{className:`relative w-full max-w-2xl rounded-2xl shadow-[0_32px_64px_-12px_rgba(0,0,0,0.5)] border-2 overflow-hidden animate-in slide-in-from-top-4 duration-300 ${s==="dark"?"bg-slate-900 border-slate-700 text-white":"bg-white border-slate-200 text-slate-900"}`,children:[A.jsxs("div",{className:`flex items-center px-4 py-4 gap-3 border-b ${s==="dark"?"border-slate-800/50":"border-slate-100"}`,children:[A.jsx("div",{className:"p-1.5 bg-blue-600 rounded-lg text-white shadow-lg shadow-blue-500/20",children:A.jsx(d6,{size:18})}),A.jsx("input",{ref:m,type:"text",placeholder:"select * | mv Core | stack v",className:`flex-1 bg-transparent border-none outline-none text-lg font-bold tracking-tight ${s==="dark"?"placeholder-slate-600":"placeholder-slate-400"}`,value:l,onChange:E=>{o(E.target.value),h(0)},onKeyDown:k}),A.jsx("kbd",{className:`px-1.5 py-0.5 rounded text-[10px] font-black border ${s==="dark"?"bg-slate-800 text-slate-500 border-slate-700":"bg-slate-100 text-slate-400 border-slate-200"}`,children:"ESC"})]}),d?A.jsxs("div",{className:`px-4 py-6 flex flex-col items-center justify-center gap-3 animate-in zoom-in-95 duration-200 ${d.type==="success"?"text-emerald-500":"text-blue-500"}`,children:[A.jsx("div",{className:`p-3 rounded-full ${d.type==="success"?"bg-emerald-500/10":"bg-blue-500/10"}`,children:d.type==="success"?A.jsx(c6,{size:32}):A.jsx(CE,{size:32})}),A.jsx("span",{className:"text-sm font-black uppercase tracking-widest",children:d.msg})]}):A.jsxs(A.Fragment,{children:[l.trim()&&A.jsxs("div",{className:`px-4 py-4 border-b flex flex-col gap-3 ${s==="dark"?"bg-slate-950/20":"bg-slate-50/50"}`,children:[A.jsxs("div",{className:"flex items-center justify-between",children:[A.jsx("h4",{className:"text-[10px] font-black uppercase tracking-[0.2em] text-slate-500",children:"Execution Plan"}),A.jsx(kE,{size:12,className:"text-blue-500 animate-pulse"})]}),A.jsx("div",{className:"flex flex-col gap-2",children:x.stages.length>0?x.stages.map((E,M)=>A.jsxs("div",{className:"flex items-center gap-3 group",children:[A.jsx("div",{className:`w-5 h-5 rounded-full flex items-center justify-center text-[10px] font-bold ${E.status==="success"?"bg-emerald-500/20 text-emerald-500":E.status==="active"?"bg-blue-500 text-white animate-pulse":"bg-slate-800 text-slate-500"}`,children:M+1}),A.jsx("div",{className:"flex flex-col",children:A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("span",{className:"text-xs font-black uppercase tracking-wider",children:E.command}),A.jsx("span",{className:"text-[10px] text-slate-500 font-medium",children:E.message})]})})]},M)):A.jsx("div",{className:"text-[10px] text-slate-500 italic",children:"Parsing command..."})})]}),A.jsxs("div",{className:"flex flex-col",children:[b.length>0&&A.jsx("div",{ref:y,className:"max-h-[300px] overflow-auto py-2 border-b border-slate-800/30",children:b.map((E,M)=>A.jsxs("div",{className:`px-4 py-3 flex items-center justify-between cursor-pointer transition-colors ${c===M?"bg-blue-600 text-white":s==="dark"?"hover:bg-slate-800 text-slate-300":"hover:bg-slate-50 text-slate-600"}`,onClick:()=>E.action(),children:[A.jsxs("div",{className:"flex items-center gap-3",children:[A.jsx("div",{className:c===M?"text-white":"text-slate-500",children:E.icon}),A.jsxs("div",{className:"flex flex-col",children:[A.jsx("span",{className:"text-sm font-bold",children:E.label}),E.desc&&A.jsx("span",{className:`text-[10px] ${c===M?"text-blue-100":"text-slate-500"}`,children:E.desc})]})]}),c===M&&A.jsx(Eg,{size:14,className:"opacity-50"})]},`${E.id}-${M}`))}),l.includes("|")&&A.jsxs("div",{className:"p-4 flex flex-col gap-3",children:[A.jsx("div",{className:"flex items-center justify-between",children:A.jsxs("h4",{className:"text-[10px] font-black uppercase tracking-[0.2em] text-slate-500",children:["Working Set (",x.outputIds.length,")"]})}),A.jsx("div",{className:"flex flex-wrap gap-1.5 max-h-[120px] overflow-auto",children:x.outputIds.length>0?x.outputIds.map(E=>A.jsx("div",{className:`px-2 py-0.5 rounded text-[10px] font-bold border ${s==="dark"?"bg-blue-500/10 border-blue-500/20 text-blue-400":"bg-blue-50 border-blue-100 text-blue-600"}`,children:E},E)):A.jsx("div",{className:"text-[10px] text-slate-500 italic",children:"No tables in current scope"})})]})]})]}),A.jsxs("div",{className:`px-4 py-3 border-t flex items-center justify-between ${s==="dark"?"bg-slate-950/30 border-slate-800/50":"bg-slate-50/50 border-slate-100"}`,children:[A.jsxs("div",{className:"flex items-center gap-4 text-[9px] font-bold text-slate-500 uppercase",children:[A.jsxs("div",{className:"flex items-center gap-1",children:[A.jsx("kbd",{className:`px-1 rounded border ${s==="dark"?"bg-slate-800 border-slate-700":"bg-slate-100 border-slate-200"}`,children:"↑↓"}),A.jsx("span",{children:"Navigate"})]}),A.jsxs("div",{className:"flex items-center gap-1",children:[A.jsx("kbd",{className:`px-1 rounded border ${s==="dark"?"bg-slate-800 border-slate-700":"bg-slate-100 border-slate-200"}`,children:"Tab"}),A.jsx("span",{children:"Select"})]}),A.jsxs("div",{className:"flex items-center gap-1",children:[A.jsx("kbd",{className:`px-1 rounded border ${s==="dark"?"bg-slate-800 border-slate-700":"bg-slate-100 border-slate-200"}`,children:"Enter"}),A.jsx("span",{children:"Execute"})]})]}),A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("div",{className:`w-2 h-2 rounded-full ${x.outputIds.length>0?"bg-emerald-500 animate-pulse":"bg-slate-700"}`}),A.jsxs("span",{className:"text-[9px] font-black text-slate-500 uppercase tracking-widest",children:[x.outputIds.length," target entities"]})]})]})]})]}):null}),nhe=()=>{const{isPresentationMode:t,setIsPresentationMode:e,theme:r}=vt();return t?A.jsx("div",{className:"fixed top-6 right-6 z-[100] flex items-center gap-2 animate-in fade-in slide-in-from-top-4 duration-500",children:A.jsx("button",{onClick:()=>e(!1),className:`p-2.5 rounded-full border shadow-2xl backdrop-blur-md transition-all hover:rotate-90 active:scale-90 ${r==="dark"?"bg-slate-900/80 border-slate-700 text-slate-400 hover:text-white":"bg-white/80 border-slate-200 text-slate-500 hover:text-slate-900"}`,title:"Exit Presentation Mode (Esc)",children:A.jsx(Oh,{size:20})})}):null},ihe=()=>{const{getSelectedTable:t,getSelectedDomain:e,getSelectedRelationship:r,selectedTableIds:n,setSelectedTableIds:i,distributeSelectedTables:a,setSelectedTableId:s,setSelectedEdgeId:l,setSelectedAnnotationId:o,theme:c}=vt(),h=t(),d=e(),g=r(),m=n.length>1;if(!h&&!d&&!g&&!m)return null;const y=()=>{s(null),i([]),l(null),o(null)};return A.jsxs("div",{className:`absolute top-4 right-4 z-10 flex items-center gap-3 border rounded-xl shadow-2xl p-1.5 px-4 animate-in fade-in slide-in-from-top-4 duration-300 ${c==="dark"?"bg-slate-900/90 backdrop-blur-md border-blue-500/30":"bg-white/90 backdrop-blur-md border-blue-200 shadow-blue-500/5"}`,children:[A.jsxs("div",{className:`flex items-center gap-2 border-r pr-4 mr-1 ${c==="dark"?"border-slate-700":"border-slate-100"}`,children:[m?A.jsx(Yre,{size:16,className:"text-blue-500"}):A.jsxs(A.Fragment,{children:[h&&A.jsx(Hl,{size:16,className:"text-emerald-500"}),d&&A.jsx(g6,{size:16,className:"text-blue-500"}),g&&(g.relationship.type==="lineage"?A.jsx(SE,{size:16,className:"text-blue-400"}):A.jsx(zu,{size:16,className:"text-amber-500"}))]}),A.jsxs("div",{className:"flex flex-col leading-tight",children:[A.jsx("span",{className:"text-[10px] font-bold uppercase tracking-widest text-slate-500",children:m?"Multi-Selection":`Selected ${h?"Table":d?"Domain":g?.relationship.type==="lineage"?"Lineage":"Relation"}`}),A.jsx("span",{className:`text-xs font-semibold truncate max-w-[180px] ${c==="dark"?"text-slate-200":"text-slate-800"}`,children:m?`${n.length} tables selected`:h?h.name:d?d.name:g?`${g.relationship.from.table} → ${g.relationship.to.table}`:""})]})]}),A.jsxs("div",{className:"flex items-center gap-1",children:[m&&A.jsxs("div",{className:"flex items-center gap-1 mr-2 pr-2 border-r border-slate-700/30",children:[A.jsx("button",{onClick:()=>a("vertical"),className:"flex items-center justify-center w-8 h-8 hover:bg-blue-500/20 text-slate-400 hover:text-blue-400 rounded-lg transition-all",title:"Align Vertically (V)",children:A.jsx(Sre,{size:16})}),A.jsx("button",{onClick:()=>a("horizontal"),className:"flex items-center justify-center w-8 h-8 hover:bg-blue-500/20 text-slate-400 hover:text-blue-400 rounded-lg transition-all",title:"Align Horizontally (H)",children:A.jsx(xre,{size:16})})]}),A.jsx("button",{onClick:y,className:`flex items-center justify-center w-8 h-8 rounded-lg transition-all ${c==="dark"?"hover:bg-slate-800 text-slate-500 hover:text-slate-300":"hover:bg-slate-100 text-slate-400 hover:text-slate-600"}`,title:"Clear Selection (Esc)",children:A.jsx(Oh,{size:16})})]})]})};function ahe(){const{schema:t,setSelectedTableId:e,selectedTableId:r,selectedEdgeId:n,setSelectedEdgeId:i,selectedAnnotationId:a,setSelectedAnnotationId:s,focusNodeId:l,setFocusNodeId:o,removeNode:c,bulkRemoveTables:h,removeEdge:d,removeAnnotation:g,showAnnotations:m,addTable:y,addDomain:x,addAnnotation:b,theme:w,isPresentationMode:S,setIsPresentationMode:k,refreshModelData:E,fetchAvailableFiles:M,isModelLoading:R,isCliMode:O,distributeSelectedTables:N,selectedTableIds:B,toggleTableSelection:D,toggleEdgeSelection:_,connectMode:P,setConnectMode:z,currentModelSlug:H}=vt(so(K=>({schema:K.schema,setSelectedTableId:K.setSelectedTableId,selectedTableId:K.selectedTableId,selectedEdgeId:K.selectedEdgeId,setSelectedEdgeId:K.setSelectedEdgeId,selectedAnnotationId:K.selectedAnnotationId,setSelectedAnnotationId:K.setSelectedAnnotationId,focusNodeId:K.focusNodeId,setFocusNodeId:K.setFocusNodeId,removeNode:K.removeNode,bulkRemoveTables:K.bulkRemoveTables,removeEdge:K.removeEdge,removeAnnotation:K.removeAnnotation,showAnnotations:K.showAnnotations,addTable:K.addTable,addDomain:K.addDomain,addAnnotation:K.addAnnotation,theme:K.theme,isPresentationMode:K.isPresentationMode,setIsPresentationMode:K.setIsPresentationMode,refreshModelData:K.refreshModelData,fetchAvailableFiles:K.fetchAvailableFiles,isModelLoading:K.isModelLoading,isCliMode:K.isCliMode,distributeSelectedTables:K.distributeSelectedTables,selectedTableIds:K.selectedTableIds,toggleTableSelection:K.toggleTableSelection,toggleEdgeSelection:K.toggleEdgeSelection,connectMode:K.connectMode,setConnectMode:K.setConnectMode,currentModelSlug:K.currentModelSlug}))),$=ve.useRef(null),q=ve.useRef(null),V=ve.useRef(null),X=ve.useCallback(K=>{$.current=K},[]),ee=ve.useCallback(K=>{q.current=K},[]),te=ve.useCallback(K=>{V.current=K},[]);ve.useEffect(()=>{if(!H)return;const K=setTimeout(()=>$.current?.(),300);return()=>clearTimeout(K)},[H]);const I=ve.useRef(null),G=ve.useRef(null),re=ve.useRef(1e3);ve.useEffect(()=>{if(!O)return;const K=()=>{const oe=window.location.protocol==="https:"?"wss:":"ws:",Se=new WebSocket(`${oe}//${window.location.host}`);Se.onopen=()=>{re.current=1e3},Se.onmessage=at=>{try{const Me=JSON.parse(at.data);Me.type==="update"?E():Me.type==="files_changed"&&M()}catch{}},Se.onclose=()=>{I.current=null,G.current&&window.clearTimeout(G.current),G.current=window.setTimeout(()=>{re.current=Math.min(re.current*1.5,3e4),K()},re.current)},Se.onerror=()=>Se.close(),I.current=Se};return K(),()=>{I.current&&(I.current.onclose=null,I.current.close()),G.current&&window.clearTimeout(G.current)}},[O,E,M]),ve.useEffect(()=>{l&&q.current&&(q.current(l),o(null))},[l,o]),ve.useEffect(()=>{window.__modscapeFitView=()=>$.current?.(),window.__modscapeAutoLayout=()=>V.current?.()},[]),ve.useEffect(()=>{const K=oe=>{if(oe.key==="Escape"){if(S){k(!1);return}if(vt.getState().connectMode){vt.getState().setConnectMode(null);return}e(null),i(null),s(null),vt.getState().setSelectedTableIds([]);return}const Se=document.activeElement;if(Se?.tagName==="INPUT"||Se?.tagName==="TEXTAREA"||Se?.isContentEditable||Se?.closest(".cm-editor")||Se?.closest(".sidebar-content")||oe.repeat)return;const Me=oe.key.toLowerCase();if(Me==="/"){oe.preventDefault(),vt.getState().setIsRightPanelOpen(!0),vt.getState().setActiveRightPanelTab("tables");return}if(Me==="k"&&(oe.ctrlKey||oe.metaKey)){oe.preventDefault(),vt.getState().setIsCommandPaletteOpen(!vt.getState().isCommandPaletteOpen);return}if(Me==="l"){oe.preventDefault();const He=vt.getState().activeTab;vt.getState().setActiveTab(He==="connect"?"editor":"connect"),vt.getState().setIsSidebarOpen(!0);return}if((Me==="v"||Me==="h")&&B.length>1){oe.preventDefault(),N?.(Me==="v"?"vertical":"horizontal");return}if(oe.key==="Backspace"||oe.key==="Delete"){if(B.length>1){h(B),vt.getState().setSelectedTableIds([]);return}if(!r&&!a){if(n){if(n.startsWith("lin-")){const He=n.lastIndexOf("-"),$e=parseInt(n.slice(He+1)),Ne=t?.lineage?.[$e];Ne&&d(Ne.from,Ne.to,"lineage")}else{const He=t?.relationships?.find(($e,Ne)=>`er-${Ne}`===n);He&&d(He.from.table,He.to.table,"er")}i(null)}return}}if((oe.key==="Backspace"||oe.key==="Delete")&&(r||a)){a?(g(a),s(null)):r&&(c(r),e(null));return}};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[S,k,e,i,s,r,n,a,B,N,t,c,h,d,g]);const Y=ve.useCallback(K=>{D(K)},[D]),W=ve.useCallback(K=>{_(K.id)},[_]),Z=ve.useCallback(()=>{e(null),i(null),s(null),vt.getState().setSelectedTableIds([])},[e,i,s]),ie=ve.useCallback(K=>{e(null),i(null),s(K)},[e,i,s]),we=ve.useCallback(K=>{s(null),i(null),D(K)},[s,i,D]),de=ve.useCallback((K,oe,Se)=>{K==="lineage"?vt.getState().addLineage(oe,Se):vt.getState().addRelationship(oe,Se)},[]),se=ve.useCallback((K,oe)=>{y(K,oe)},[y]),j=ve.useCallback((K,oe)=>{x(K,oe)},[x]),Q=ve.useCallback((K,oe)=>{m||vt.getState().setShowAnnotations(!0),b({x:K,y:oe})},[b,m]);return A.jsxs("div",{className:"flex-1 relative h-full flex flex-col overflow-hidden",children:[A.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[!S&&A.jsx(ihe,{}),A.jsx(nhe,{}),A.jsx(rhe,{}),P&&A.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-50 pointer-events-none",children:A.jsxs("div",{className:`flex items-center gap-2 px-4 py-1.5 backdrop-blur-md rounded-full shadow-xl border ${w==="dark"?"bg-slate-950/70 border-green-500/50":"bg-white/80 border-green-500/40"}`,children:[A.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),A.jsxs("span",{className:`text-[10px] font-black uppercase tracking-widest ${w==="dark"?"text-green-400":"text-green-600"}`,children:[P==="lineage"?"Lineage":"ER"," Connect Mode"]}),A.jsx("div",{className:`w-px h-3 ${w==="dark"?"bg-green-500/20":"bg-green-500/30"}`}),A.jsx("span",{className:`text-[10px] font-bold ${w==="dark"?"text-green-400/70":"text-green-600/70"}`,children:"Click source → target · Esc to exit"}),A.jsx("button",{className:"pointer-events-auto ml-1 opacity-60 hover:opacity-100 transition-opacity",onClick:()=>z(null),children:A.jsx("span",{className:`text-[10px] font-bold ${w==="dark"?"text-green-400":"text-green-600"}`,children:"✕"})})]})}),R&&A.jsxs("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,zIndex:10,pointerEvents:"none"},children:[A.jsx("div",{style:{width:36,height:36,border:`3px solid ${w==="dark"?"#334155":"#e2e8f0"}`,borderTopColor:w==="dark"?"#60a5fa":"#3b82f6",borderRadius:"50%",animation:"spin 0.8s linear infinite"}}),A.jsx("span",{style:{fontSize:13,color:w==="dark"?"#94a3b8":"#64748b",fontWeight:500},children:"Loading model…"})]}),A.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"}),t&&A.jsx(dre,{onNodeClick:Y,onEdgeClick:W,onPaneClick:Z,onAnnotationClick:ie,onDomainClick:we,onAddTableAt:se,onAddDomainAt:j,onAddAnnotationAt:Q,onFitView:X,onFocusNode:ee,onEdgeCreated:de,onAutoLayout:te})]}),!S&&A.jsx(Nne,{})]})}function she(){const[t,e]=ve.useState(!1),{isCliMode:r,fetchAvailableFiles:n,setCurrentModel:i,setSchema:a,theme:s,isPresentationMode:l}=vt(),o=!!window.__MODSCAPE_DATA__;return ve.useEffect(()=>{if(r){n().then(()=>{const h=new URLSearchParams(window.location.search).get("model");h?i(h):fetch("/api/model").then(d=>d.json()).then(d=>a(d))}),e(!0);return}if(o){const c=window.__MODSCAPE_DATA__;c?.models?.length>0&&n().then(()=>{const d=new URLSearchParams(window.location.search).get("model");d?i(d):(a(c.models[0].schema),c.models[0].slug&&i(c.models[0].slug))})}e(!0)},[r,o,n,i,a]),t?A.jsxs("div",{className:`flex h-screen w-screen overflow-hidden font-sans transition-colors duration-300 ${s==="dark"?"dark bg-slate-950 text-slate-100":"bg-slate-50 text-slate-900"}`,children:[!l&&A.jsx(Wfe,{}),A.jsx(ahe,{}),!l&&A.jsx(the,{})]}):null}AI.createRoot(document.getElementById("root")).render(A.jsx(ve.StrictMode,{children:A.jsx(she,{})}));
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="./favicon.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Modscape</title>
8
- <script type="module" crossorigin src="./assets/index-BFdr345z.js"></script>
8
+ <script type="module" crossorigin src="./assets/index-nIGQ5zIu.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="./assets/index-zFK5TNtm.css">
10
10
  </head>
11
11
  <body>