modscape 1.1.5 → 1.1.6

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "modscape",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "Modscape: A YAML-driven data modeling visualizer CLI",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,7 +20,9 @@
20
20
  "scripts": {
21
21
  "build-ui": "cd visualizer && npm run build && rm -rf ../visualizer-dist && mv dist ../visualizer-dist",
22
22
  "dev": "node src/index.js dev",
23
- "test:e2e": "playwright test"
23
+ "test:e2e": "playwright test",
24
+ "test:all": "npm run build-ui && npm run test:e2e",
25
+ "test:update": "npm run build-ui && npm run test:e2e -- --update-snapshots"
24
26
  },
25
27
  "dependencies": {
26
28
  "@inquirer/prompts": "^8.3.0",
package/src/index.js CHANGED
@@ -8,6 +8,10 @@ import { build } from './build.js';
8
8
  import { initProject } from './init.js';
9
9
  import { exportModel } from './export.js';
10
10
  import { createModel } from './create.js';
11
+ import { createRequire } from 'module';
12
+
13
+ const require = createRequire(import.meta.url);
14
+ const pkg = require('../package.json');
11
15
 
12
16
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
13
17
  const VISUALIZER_PATH = path.resolve(__dirname, '../visualizer');
@@ -16,7 +20,7 @@ const program = new Command();
16
20
  program
17
21
  .name('modscape')
18
22
  .description('Modscape: A YAML-driven data modeling visualizer CLI')
19
- .version('1.0.9');
23
+ .version(pkg.version);
20
24
 
21
25
  program
22
26
  .command('init')
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "visualizer",
3
3
  "private": true,
4
- "version": "1.1.5",
4
+ "version": "1.1.6",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -51,7 +51,7 @@ Error generating stack: `+p.message+`
51
51
  `:i=="r"?"\r":i=="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 rie(this):new tie(this)}getCursor(e,n=0,i){let r=e.doc?e:nt.create({doc:e});return i==null&&(i=r.doc.length),this.regexp?Zl(this,r,n,i):Kl(this,r,n,i)}}class iB{constructor(e){this.spec=e}}function Jne(t,e,n){return(i,r,s,l)=>{if(n&&!n(i,r,s,l))return!1;let c=i>=l&&r<=l+s.length?s.slice(i-l,r-l):e.doc.sliceString(i,r);return t(c,e,i,r)}}function Kl(t,e,n,i){let r;return t.wholeWord&&(r=eie(e.doc,e.charCategorizer(e.selection.main.head))),t.test&&(r=Jne(t.test,e,r)),new Mo(e.doc,t.unquoted,n,i,t.caseSensitive?void 0:s=>s.toLowerCase(),r)}function eie(t,e){return(n,i,r,s)=>((s>n||s+r.length<i)&&(s=Math.max(0,n-2),r=t.sliceString(s,Math.min(t.length,i+2))),(e(Yd(r,n-s))!=At.Word||e(Qd(r,n-s))!=At.Word)&&(e(Qd(r,i-s))!=At.Word||e(Yd(r,i-s))!=At.Word))}class tie extends iB{constructor(e){super(e)}nextMatch(e,n,i){let r=Kl(this.spec,e,i,e.doc.length).nextOverlapping();if(r.done){let s=Math.min(e.doc.length,n+this.spec.unquoted.length);r=Kl(this.spec,e,0,s).nextOverlapping()}return r.done||r.value.from==n&&r.value.to==i?null:r.value}prevMatchInRange(e,n,i){for(let r=i;;){let s=Math.max(n,r-1e4-this.spec.unquoted.length),l=Kl(this.spec,e,s,r),c=null;for(;!l.nextOverlapping().done;)c=l.value;if(c)return c;if(s==n)return null;r-=1e4}}prevMatch(e,n,i){let r=this.prevMatchInRange(e,0,n);return r||(r=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),r&&(r.from!=n||r.to!=i)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,n){let i=Kl(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=n)return null;r.push(i.value)}return r}highlight(e,n,i,r){let s=Kl(this.spec,e,Math.max(0,n-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}function nie(t,e,n){return(i,r,s)=>(!n||n(i,r,s))&&t(s[0],e,i,r)}function Zl(t,e,n,i){let r;return t.wholeWord&&(r=iie(e.charCategorizer(e.selection.main.head))),t.test&&(r=nie(t.test,e,r)),new eB(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:r},n,i)}function Yd(t,e){return t.slice(dn(t,e,!1),e)}function Qd(t,e){return t.slice(e,dn(t,e))}function iie(t){return(e,n,i)=>!i[0].length||(t(Yd(i.input,i.index))!=At.Word||t(Qd(i.input,i.index))!=At.Word)&&(t(Qd(i.input,i.index+i[0].length))!=At.Word||t(Yd(i.input,i.index+i[0].length))!=At.Word)}class rie extends iB{nextMatch(e,n,i){let r=Zl(this.spec,e,i,e.doc.length).next();return r.done&&(r=Zl(this.spec,e,0,n).next()),r.done?null:r.value}prevMatchInRange(e,n,i){for(let r=1;;r++){let s=Math.max(n,i-r*1e4),l=Zl(this.spec,e,s,i),c=null;for(;!l.next().done;)c=l.value;if(c&&(s==n||c.from>s+10))return c;if(s==n)return null}}prevMatch(e,n,i){return this.prevMatchInRange(e,0,n)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let r=i.length;r>0;r--){let s=+i.slice(0,r);if(s>0&&s<e.match.length)return e.match[s]+i.slice(r)}return n})}matchAll(e,n){let i=Zl(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=n)return null;r.push(i.value)}return r}highlight(e,n,i,r){let s=Zl(this.spec,e,Math.max(0,n-250),Math.min(i+250,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}const Eu=Ue.define(),dC=Ue.define(),$s=Tn.define({create(t){return new hw(BS(t).create(),null)},update(t,e){for(let n of e.effects)n.is(Eu)?t=new hw(n.value.create(),t.panel):n.is(dC)&&(t=new hw(t.query,n.value?pC:null));return t},provide:t=>ku.from(t,e=>e.panel)});class hw{constructor(e,n){this.query=e,this.panel=n}}const sie=je.mark({class:"cm-searchMatch"}),aie=je.mark({class:"cm-searchMatch cm-searchMatch-selected"}),lie=Bt.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 je.none;let{view:n}=this,i=new ns;for(let r=0,s=n.visibleRanges,l=s.length;r<l;r++){let{from:c,to:u}=s[r];for(;r<l-1&&u>s[r+1].from-500;)u=s[++r].to;t.highlight(n.state,c,u,(h,d)=>{let m=n.state.selection.ranges.some(g=>g.from==h&&g.to==d);i.add(h,d,m?aie:sie)})}return i.finish()}},{decorations:t=>t.decorations});function Ku(t){return e=>{let n=e.state.field($s,!1);return n&&n.query.spec.valid?t(e,n):aB(e)}}const Xd=Ku((t,{query:e})=>{let{to:n}=t.state.selection.main,i=e.nextMatch(t.state,n,n);if(!i)return!1;let r=de.single(i.from,i.to),s=t.state.facet(Io);return t.dispatch({selection:r,effects:[mC(t,i),s.scrollToMatch(r.main,t)],userEvent:"select.search"}),sB(t),!0}),Wd=Ku((t,{query:e})=>{let{state:n}=t,{from:i}=n.selection.main,r=e.prevMatch(n,i,i);if(!r)return!1;let s=de.single(r.from,r.to),l=t.state.facet(Io);return t.dispatch({selection:s,effects:[mC(t,r),l.scrollToMatch(s.main,t)],userEvent:"select.search"}),sB(t),!0}),oie=Ku((t,{query:e})=>{let n=e.matchAll(t.state,1e3);return!n||!n.length?!1:(t.dispatch({selection:de.create(n.map(i=>de.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),cie=({state:t,dispatch:e})=>{let n=t.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:i,to:r}=n.main,s=[],l=0;for(let c=new Mo(t.doc,t.sliceDoc(i,r));!c.next().done;){if(s.length>1e3)return!1;c.value.from==i&&(l=s.length),s.push(de.range(c.value.from,c.value.to))}return e(t.update({selection:de.create(s,l),userEvent:"select.search.matches"})),!0},k5=Ku((t,{query:e})=>{let{state:n}=t,{from:i,to:r}=n.selection.main;if(n.readOnly)return!1;let s=e.nextMatch(n,i,i);if(!s)return!1;let l=s,c=[],u,h,d=[];l.from==i&&l.to==r&&(h=n.toText(e.getReplacement(l)),c.push({from:l.from,to:l.to,insert:h}),l=e.nextMatch(n,l.from,l.to),d.push(we.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(i).number)+".")));let m=t.state.changes(c);return l&&(u=de.single(l.from,l.to).map(m),d.push(mC(t,l)),d.push(n.facet(Io).scrollToMatch(u.main,t))),t.dispatch({changes:m,selection:u,effects:d,userEvent:"input.replace"}),!0}),uie=Ku((t,{query:e})=>{if(t.state.readOnly)return!1;let n=e.matchAll(t.state,1e9).map(r=>{let{from:s,to:l}=r;return{from:s,to:l,insert:e.getReplacement(r)}});if(!n.length)return!1;let i=t.state.phrase("replaced $ matches",n.length)+".";return t.dispatch({changes:n,effects:we.announce.of(i),userEvent:"input.replace.all"}),!0});function pC(t){return t.state.facet(Io).createPanel(t)}function BS(t,e){var n,i,r,s,l;let c=t.selection.main,u=c.empty||c.to>c.from+100?"":t.sliceDoc(c.from,c.to);if(e&&!u)return e;let h=t.facet(Io);return new nB({search:((n=e?.literal)!==null&&n!==void 0?n:h.literal)?u:u.replace(/\n/g,"\\n"),caseSensitive:(i=e?.caseSensitive)!==null&&i!==void 0?i:h.caseSensitive,literal:(r=e?.literal)!==null&&r!==void 0?r:h.literal,regexp:(s=e?.regexp)!==null&&s!==void 0?s:h.regexp,wholeWord:(l=e?.wholeWord)!==null&&l!==void 0?l:h.wholeWord})}function rB(t){let e=tC(t,pC);return e&&e.dom.querySelector("[main-field]")}function sB(t){let e=rB(t);e&&e==t.root.activeElement&&e.select()}const aB=t=>{let e=t.state.field($s,!1);if(e&&e.panel){let n=rB(t);if(n&&n!=t.root.activeElement){let i=BS(t.state,e.query.spec);i.valid&&t.dispatch({effects:Eu.of(i)}),n.focus(),n.select()}}else t.dispatch({effects:[dC.of(!0),e?Eu.of(BS(t.state,e.query.spec)):Ue.appendConfig.of(pie)]});return!0},lB=t=>{let e=t.state.field($s,!1);if(!e||!e.panel)return!1;let n=tC(t,pC);return n&&n.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:dC.of(!1)}),!0},fie=[{key:"Mod-f",run:aB,scope:"editor search-panel"},{key:"F3",run:Xd,shift:Wd,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Xd,shift:Wd,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:lB,scope:"editor search-panel"},{key:"Mod-Shift-l",run:cie},{key:"Mod-Alt-g",run:Hne},{key:"Mod-d",run:Zne,preventDefault:!0}];class hie{constructor(e){this.view=e;let n=this.query=e.state.field($s).query.spec;this.commit=this.commit.bind(this),this.searchField=mt("input",{value:n.search,placeholder:fi(e,"Find"),"aria-label":fi(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=mt("input",{value:n.replace,placeholder:fi(e,"Replace"),"aria-label":fi(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=mt("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=mt("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=mt("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function i(r,s,l){return mt("button",{class:"cm-button",name:r,onclick:s,type:"button"},l)}this.dom=mt("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,i("next",()=>Xd(e),[fi(e,"next")]),i("prev",()=>Wd(e),[fi(e,"previous")]),i("select",()=>oie(e),[fi(e,"all")]),mt("label",null,[this.caseField,fi(e,"match case")]),mt("label",null,[this.reField,fi(e,"regexp")]),mt("label",null,[this.wordField,fi(e,"by word")]),...e.state.readOnly?[]:[mt("br"),this.replaceField,i("replace",()=>k5(e),[fi(e,"replace")]),i("replaceAll",()=>uie(e),[fi(e,"replace all")])],mt("button",{name:"close",onclick:()=>lB(e),"aria-label":fi(e,"close"),type:"button"},["×"])])}commit(){let e=new nB({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:Eu.of(e)}))}keydown(e){gJ(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Wd:Xd)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),k5(this.view))}update(e){for(let n of e.transactions)for(let i of n.effects)i.is(Eu)&&!i.value.eq(this.query)&&this.setQuery(i.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(Io).top}}function fi(t,e){return t.state.phrase(e)}const $h=30,Gh=/[\s\.,:;?!]/;function mC(t,{from:e,to:n}){let i=t.state.doc.lineAt(e),r=t.state.doc.lineAt(n).to,s=Math.max(i.from,e-$h),l=Math.min(r,n+$h),c=t.state.sliceDoc(s,l);if(s!=i.from){for(let u=0;u<$h;u++)if(!Gh.test(c[u+1])&&Gh.test(c[u])){c=c.slice(u);break}}if(l!=r){for(let u=c.length-1;u>c.length-$h;u--)if(!Gh.test(c[u-1])&&Gh.test(c[u])){c=c.slice(0,u);break}}return we.announce.of(`${t.state.phrase("current match")}. ${c} ${t.state.phrase("on line")} ${i.number}.`)}const die=we.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"}}),pie=[$s,nl.low(lie),die];class oB{constructor(e,n,i,r){this.state=e,this.pos=n,this.explicit=i,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let n=_n(this.state).resolveInner(this.pos,-1);for(;n&&e.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(e){let n=this.state.doc.lineAt(this.pos),i=Math.max(n.from,this.pos-250),r=n.text.slice(i-n.from,this.pos-n.from),s=r.search(cB(e,!1));return s<0?null:{from:i+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,n,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(n),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function A5(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function mie(t){let e=Object.create(null),n=Object.create(null);for(let{label:r}of t){e[r[0]]=!0;for(let s=1;s<r.length;s++)n[r[s]]=!0}let i=A5(e)+A5(n)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function gie(t){let e=t.map(r=>typeof r=="string"?{label:r}:r),[n,i]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:mie(e);return r=>{let s=r.matchBefore(i);return s||r.explicit?{from:s?s.from:r.pos,options:e,validFor:n}:null}}class _5{constructor(e,n,i,r){this.completion=e,this.source=n,this.match=i,this.score=r}}function $a(t){return t.selection.main.from}function cB(t,e){var n;let{source:i}=t,r=e&&i[0]!="^",s=i[i.length-1]!="$";return!r&&!s?t:new RegExp(`${r?"^":""}(?:${i})${s?"$":""}`,(n=t.flags)!==null&&n!==void 0?n:t.ignoreCase?"i":"")}const uB=br.define();function yie(t,e,n,i){let{main:r}=t.selection,s=n-r.from,l=i-r.from;return{...t.changeByRange(c=>{if(c!=r&&n!=i&&t.sliceDoc(c.from+s,c.from+l)!=t.sliceDoc(n,i))return{range:c};let u=t.toText(e);return{changes:{from:c.from+s,to:i==r.from?c.to:c.from+l,insert:u},range:de.cursor(c.from+s+u.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const O5=new WeakMap;function vie(t){if(!Array.isArray(t))return t;let e=O5.get(t);return e||O5.set(t,e=gie(t)),e}const Kd=Ue.define(),Tu=Ue.define();class bie{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<e.length;){let i=Fn(e,n),r=cr(i);this.chars.push(i);let s=e.slice(n,n+r),l=s.toUpperCase();this.folded.push(Fn(l==s?s.toLowerCase():l,0)),n+=r}this.astral=e.length!=this.chars.length}ret(e,n){return this.score=e,this.matched=n,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:n,folded:i,any:r,precise:s,byWord:l}=this;if(n.length==1){let A=Fn(e,0),O=cr(A),E=O==e.length?0:-100;if(A!=n[0])if(A==i[0])E+=-200;else return null;return this.ret(E,[0,O])}let c=e.indexOf(this.pattern);if(c==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let u=n.length,h=0;if(c<0){for(let A=0,O=Math.min(e.length,200);A<O&&h<u;){let E=Fn(e,A);(E==n[h]||E==i[h])&&(r[h++]=A),A+=cr(E)}if(h<u)return null}let d=0,m=0,g=!1,v=0,x=-1,w=-1,C=/[a-z]/.test(e),k=!0;for(let A=0,O=Math.min(e.length,200),E=0;A<O&&m<u;){let M=Fn(e,A);c<0&&(d<u&&M==n[d]&&(s[d++]=A),v<u&&(M==n[v]||M==i[v]?(v==0&&(x=A),w=A+1,v++):v=0));let T,N=M<255?M>=48&&M<=57||M>=97&&M<=122?2:M>=65&&M<=90?1:0:(T=B2(M))!=T.toLowerCase()?1:T!=T.toUpperCase()?2:0;(!A||N==1&&C||E==0&&N!=0)&&(n[m]==M||i[m]==M&&(g=!0)?l[m++]=A:l.length&&(k=!1)),E=N,A+=cr(M)}return m==u&&l[0]==0&&k?this.result(-100+(g?-200:0),l,e):v==u&&x==0?this.ret(-200-e.length+(w==e.length?0:-100),[0,w]):c>-1?this.ret(-700-e.length,[c,c+this.pattern.length]):v==u?this.ret(-900-e.length,[x,w]):m==u?this.result(-100+(g?-200:0)+-700+(k?0:-1100),l,e):n.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,n,i){let r=[],s=0;for(let l of n){let c=l+(this.astral?cr(Fn(i,l)):1);s&&r[s-1]==l?r[s-1]=c:(r[s++]=l,r[s++]=c)}return this.ret(e-i.length,r)}}class xie{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 n=e.slice(0,this.pattern.length),i=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return i==null?null:(this.matched=[0,n.length],this.score=i+(e.length==this.pattern.length?0:-100),this)}}const hn=ke.define({combine(t){return xr(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:wie,filterStrict:!1,compareCompletions:(e,n)=>(e.sortText||e.label).localeCompare(n.sortText||n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,n)=>e&&n,closeOnBlur:(e,n)=>e&&n,icons:(e,n)=>e&&n,tooltipClass:(e,n)=>i=>E5(e(i),n(i)),optionClass:(e,n)=>i=>E5(e(i),n(i)),addToOptions:(e,n)=>e.concat(n),filterStrict:(e,n)=>e||n})}});function E5(t,e){return t?e?t+" "+e:t:e}function wie(t,e,n,i,r,s){let l=t.textDirection==vt.RTL,c=l,u=!1,h="top",d,m,g=e.left-r.left,v=r.right-e.right,x=i.right-i.left,w=i.bottom-i.top;if(c&&g<Math.min(x,v)?c=!1:!c&&v<Math.min(x,g)&&(c=!0),x<=(c?g:v))d=Math.max(r.top,Math.min(n.top,r.bottom-w))-e.top,m=Math.min(400,c?g:v);else{u=!0,m=Math.min(400,(l?e.right:r.right-e.left)-30);let A=r.bottom-e.bottom;A>=w||A>e.top?d=n.bottom-e.top:(h="bottom",d=e.bottom-n.top)}let C=(e.bottom-e.top)/s.offsetHeight,k=(e.right-e.left)/s.offsetWidth;return{style:`${h}: ${d/C}px; max-width: ${m/k}px`,class:"cm-completionInfo-"+(u?l?"left-narrow":"right-narrow":c?"left":"right")}}const gC=Ue.define();function Sie(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(n){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),n.type&&i.classList.add(...n.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(n,i,r,s){let l=document.createElement("span");l.className="cm-completionLabel";let c=n.displayLabel||n.label,u=0;for(let h=0;h<s.length;){let d=s[h++],m=s[h++];d>u&&l.appendChild(document.createTextNode(c.slice(u,d)));let g=l.appendChild(document.createElement("span"));g.appendChild(document.createTextNode(c.slice(d,m))),g.className="cm-completionMatchedText",u=m}return u<c.length&&l.appendChild(document.createTextNode(c.slice(u))),l},position:50},{render(n){if(!n.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=n.detail,i},position:80}),e.sort((n,i)=>n.position-i.position).map(n=>n.render)}function dw(t,e,n){if(t<=n)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let r=Math.floor(e/n);return{from:r*n,to:(r+1)*n}}let i=Math.floor((t-e)/n);return{from:t-(i+1)*n,to:t-i*n}}class Cie{constructor(e,n,i){this.view=e,this.stateField=n,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:u=>this.placeInfo(u),key:this},this.space=null,this.currentClass="";let r=e.state.field(n),{options:s,selected:l}=r.open,c=e.state.facet(hn);this.optionContent=Sie(c),this.optionClass=c.optionClass,this.tooltipClass=c.tooltipClass,this.range=dw(s.length,l,c.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",u=>{let{options:h}=e.state.field(n).open;for(let d=u.target,m;d&&d!=this.dom;d=d.parentNode)if(d.nodeName=="LI"&&(m=/-(\d+)$/.exec(d.id))&&+m[1]<h.length){this.applyCompletion(e,h[+m[1]]),u.preventDefault();return}if(u.target==this.list){let d=this.list.classList.contains("cm-completionListIncompleteTop")&&u.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&u.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;d!=null&&(e.dispatch({effects:gC.of(d)}),u.preventDefault())}}),this.dom.addEventListener("focusout",u=>{let h=e.state.field(this.stateField,!1);h&&h.tooltip&&e.state.facet(hn).closeOnBlur&&u.relatedTarget!=e.contentDOM&&e.dispatch({effects:Tu.of(null)})}),this.showOptions(s,r.id)}mount(){this.updateSel()}showOptions(e,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var n;let i=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=r){let{options:s,selected:l,disabled:c}=i.open;(!r.open||r.open.options!=s)&&(this.range=dw(s.length,l,e.state.facet(hn).maxRenderedOptions),this.showOptions(s,i.id)),this.updateSel(),c!=((n=r.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!c)}}updateTooltipClass(e){let n=this.tooltipClass(e);if(n!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of n.split(" "))i&&this.dom.classList.add(i);this.currentClass=n}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),n=e.open;(n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=dw(n.options.length,n.selected,this.view.state.facet(hn).maxRenderedOptions),this.showOptions(n.options,e.id));let i=this.updateSelectedOption(n.selected);if(i){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:s}=r;if(!s)return;let l=typeof s=="string"?document.createTextNode(s):s(r);if(!l)return;"then"in l?l.then(c=>{c&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(c,r)}).catch(c=>Xn(this.view.state,c,"completion info")):(this.addInfoPane(l,r),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,n){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:s}=e;i.appendChild(r),this.infoDestroy=s||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let n=null;for(let i=this.list.firstChild,r=this.range.from;i;i=i.nextSibling,r++)i.nodeName!="LI"||!i.id?r--:r==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),n=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return n&&Aie(this.list,n),n}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let n=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),s=this.space;if(!s){let l=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:l.clientWidth,bottom:l.clientHeight}}return r.top>Math.min(s.bottom,n.bottom)-10||r.bottom<Math.max(s.top,n.top)+10?null:this.view.state.facet(hn).positionInfo(this.view,n,r,i,s,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,n,i){const r=document.createElement("ul");r.id=n,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions")),r.addEventListener("mousedown",l=>{l.target==r&&l.preventDefault()});let s=null;for(let l=i.from;l<i.to;l++){let{completion:c,match:u}=e[l],{section:h}=c;if(h){let g=typeof h=="string"?h:h.name;if(g!=s&&(l>i.from||i.from==0))if(s=g,typeof h!="string"&&h.header)r.appendChild(h.header(h));else{let v=r.appendChild(document.createElement("completion-section"));v.textContent=g}}const d=r.appendChild(document.createElement("li"));d.id=n+"-"+l,d.setAttribute("role","option");let m=this.optionClass(c);m&&(d.className=m);for(let g of this.optionContent){let v=g(c,this.view.state,this.view,u);v&&d.appendChild(v)}}return i.from&&r.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function kie(t,e){return n=>new Cie(n,t,e)}function Aie(t,e){let n=t.getBoundingClientRect(),i=e.getBoundingClientRect(),r=n.height/t.offsetHeight;i.top<n.top?t.scrollTop-=(n.top-i.top)/r:i.bottom>n.bottom&&(t.scrollTop+=(i.bottom-n.bottom)/r)}function T5(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function _ie(t,e){let n=[],i=null,r=null,s=d=>{n.push(d);let{section:m}=d.completion;if(m){i||(i=[]);let g=typeof m=="string"?m:m.name;i.some(v=>v.name==g)||i.push(typeof m=="string"?{name:g}:m)}},l=e.facet(hn);for(let d of t)if(d.hasResult()){let m=d.result.getMatch;if(d.result.filter===!1)for(let g of d.result.options)s(new _5(g,d.source,m?m(g):[],1e9-n.length));else{let g=e.sliceDoc(d.from,d.to),v,x=l.filterStrict?new xie(g):new bie(g);for(let w of d.result.options)if(v=x.match(w.label)){let C=w.displayLabel?m?m(w,v.matched):[]:v.matched,k=v.score+(w.boost||0);if(s(new _5(w,d.source,C,k)),typeof w.section=="object"&&w.section.rank==="dynamic"){let{name:A}=w.section;r||(r=Object.create(null)),r[A]=Math.max(k,r[A]||-1e9)}}}}if(i){let d=Object.create(null),m=0,g=(v,x)=>(v.rank==="dynamic"&&x.rank==="dynamic"?r[x.name]-r[v.name]:0)||(typeof v.rank=="number"?v.rank:1e9)-(typeof x.rank=="number"?x.rank:1e9)||(v.name<x.name?-1:1);for(let v of i.sort(g))m-=1e5,d[v.name]=m;for(let v of n){let{section:x}=v.completion;x&&(v.score+=d[typeof x=="string"?x:x.name])}}let c=[],u=null,h=l.compareCompletions;for(let d of n.sort((m,g)=>g.score-m.score||h(m.completion,g.completion))){let m=d.completion;!u||u.label!=m.label||u.detail!=m.detail||u.type!=null&&m.type!=null&&u.type!=m.type||u.apply!=m.apply||u.boost!=m.boost?c.push(d):T5(d.completion)>T5(u)&&(c[c.length-1]=d),u=d.completion}return c}class ao{constructor(e,n,i,r,s,l){this.options=e,this.attrs=n,this.tooltip=i,this.timestamp=r,this.selected=s,this.disabled=l}setSelected(e,n){return e==this.selected||e>=this.options.length?this:new ao(this.options,M5(n,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,n,i,r,s,l){if(r&&!l&&e.some(h=>h.isPending))return r.setDisabled();let c=_ie(e,n);if(!c.length)return r&&e.some(h=>h.isPending)?r.setDisabled():null;let u=n.facet(hn).selectOnOpen?0:-1;if(r&&r.selected!=u&&r.selected!=-1){let h=r.options[r.selected].completion;for(let d=0;d<c.length;d++)if(c[d].completion==h){u=d;break}}return new ao(c,M5(i,u),{pos:e.reduce((h,d)=>d.hasResult()?Math.min(h,d.from):h,1e8),create:Rie,above:s.aboveCursor},r?r.timestamp:Date.now(),u,!1)}map(e){return new ao(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new ao(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Zd{constructor(e,n,i){this.active=e,this.id=n,this.open=i}static start(){return new Zd(Mie,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:n}=e,i=n.facet(hn),s=(i.override||n.languageDataAt("autocomplete",$a(n)).map(vie)).map(u=>(this.active.find(d=>d.source==u)||new Ni(u,this.active.some(d=>d.state!=0)?1:0)).update(e,i));s.length==this.active.length&&s.every((u,h)=>u==this.active[h])&&(s=this.active);let l=this.open,c=e.effects.some(u=>u.is(yC));l&&e.docChanged&&(l=l.map(e.changes)),e.selection||s.some(u=>u.hasResult()&&e.changes.touchesRange(u.from,u.to))||!Oie(s,this.active)||c?l=ao.build(s,n,this.id,l,i,c):l&&l.disabled&&!s.some(u=>u.isPending)&&(l=null),!l&&s.every(u=>!u.isPending)&&s.some(u=>u.hasResult())&&(s=s.map(u=>u.hasResult()?new Ni(u.source,0):u));for(let u of e.effects)u.is(gC)&&(l=l&&l.setSelected(u.value,this.id));return s==this.active&&l==this.open?this:new Zd(s,this.id,l)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Eie:Tie}}function Oie(t,e){if(t==e)return!0;for(let n=0,i=0;;){for(;n<t.length&&!t[n].hasResult();)n++;for(;i<e.length&&!e[i].hasResult();)i++;let r=n==t.length,s=i==e.length;if(r||s)return r==s;if(t[n++].result!=e[i++].result)return!1}}const Eie={"aria-autocomplete":"list"},Tie={};function M5(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}const Mie=[];function fB(t,e){if(t.isUserEvent("input.complete")){let i=t.annotation(uB);if(i&&e.activateOnCompletion(i))return 12}let n=t.isUserEvent("input.type");return n&&e.activateOnTyping?5:n?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class Ni{constructor(e,n,i=!1){this.source=e,this.state=n,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,n){let i=fB(e,n),r=this;(i&8||i&16&&this.touches(e))&&(r=new Ni(r.source,0)),i&4&&r.state==0&&(r=new Ni(this.source,1)),r=r.updateFor(e,i);for(let s of e.effects)if(s.is(Kd))r=new Ni(r.source,1,s.value);else if(s.is(Tu))r=new Ni(r.source,0);else if(s.is(yC))for(let l of s.value)l.source==r.source&&(r=l);return r}updateFor(e,n){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange($a(e.state))}}class vo extends Ni{constructor(e,n,i,r,s,l){super(e,3,n),this.limit=i,this.result=r,this.from=s,this.to=l}hasResult(){return!0}updateFor(e,n){var i;if(!(n&3))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let s=e.changes.mapPos(this.from),l=e.changes.mapPos(this.to,1),c=$a(e.state);if(c>l||!r||n&2&&($a(e.startState)==this.from||c<this.limit))return new Ni(this.source,n&4?1:0);let u=e.changes.mapPos(this.limit);return Nie(r.validFor,e.state,s,l)?new vo(this.source,this.explicit,u,r,s,l):r.update&&(r=r.update(r,s,l,new oB(e.state,c,!1)))?new vo(this.source,this.explicit,u,r,r.from,(i=r.to)!==null&&i!==void 0?i:$a(e.state)):new Ni(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new vo(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new Ni(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function Nie(t,e,n,i){if(!t)return!1;let r=e.sliceDoc(n,i);return typeof t=="function"?t(r,n,i,e):cB(t,!0).test(r)}const yC=Ue.define({map(t,e){return t.map(n=>n.map(e))}}),$n=Tn.define({create(){return Zd.start()},update(t,e){return t.update(e)},provide:t=>[eC.from(t,e=>e.tooltip),we.contentAttributes.from(t,e=>e.attrs)]});function vC(t,e){const n=e.completion.apply||e.completion.label;let i=t.state.field($n).active.find(r=>r.source==e.source);return i instanceof vo?(typeof n=="string"?t.dispatch({...yie(t.state,n,i.from,i.to),annotations:uB.of(e.completion)}):n(t,e.completion,i.from,i.to),!0):!1}const Rie=kie($n,vC);function Yh(t,e="option"){return n=>{let i=n.state.field($n,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(hn).interactionDelay)return!1;let r=1,s;e=="page"&&(s=F6(n,i.open.tooltip))&&(r=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:l}=i.open.options,c=i.open.selected>-1?i.open.selected+r*(t?1:-1):t?0:l-1;return c<0?c=e=="page"?0:l-1:c>=l&&(c=e=="page"?l-1:0),n.dispatch({effects:gC.of(c)}),!0}}const Die=t=>{let e=t.state.field($n,!1);return t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(hn).interactionDelay?!1:vC(t,e.open.options[e.open.selected])},pw=t=>t.state.field($n,!1)?(t.dispatch({effects:Kd.of(!0)}),!0):!1,Lie=t=>{let e=t.state.field($n,!1);return!e||!e.active.some(n=>n.state!=0)?!1:(t.dispatch({effects:Tu.of(null)}),!0)};class zie{constructor(e,n){this.active=e,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const qie=50,Bie=1e3,jie=Bt.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($n).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field($n),n=t.state.facet(hn);if(!t.selectionSet&&!t.docChanged&&t.startState.field($n)==e)return;let i=t.transactions.some(s=>{let l=fB(s,n);return l&8||(s.selection||s.docChanged)&&!(l&3)});for(let s=0;s<this.running.length;s++){let l=this.running[s];if(i||l.context.abortOnDocChange&&t.docChanged||l.updates.length+t.transactions.length>qie&&Date.now()-l.time>Bie){for(let c of l.context.abortListeners)try{c()}catch(u){Xn(this.view.state,u)}l.context.abortListeners=null,this.running.splice(s--,1)}else l.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(s=>s.effects.some(l=>l.is(Kd)))&&(this.pendingStart=!0);let r=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.isPending&&!this.running.some(l=>l.active.source==s.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let s of t.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field($n);for(let n of e.active)n.isPending&&!this.running.some(i=>i.active.source==n.source)&&this.startQuery(n);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(hn).updateSyncTime))}startQuery(t){let{state:e}=this.view,n=$a(e),i=new oB(e,n,t.explicit,this.view),r=new zie(t,i);this.running.push(r),Promise.resolve(t.source(i)).then(s=>{r.context.aborted||(r.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:Tu.of(null)}),Xn(this.view.state,s)})}scheduleAccept(){this.running.every(t=>t.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(hn).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(hn),i=this.view.state.field($n);for(let r=0;r<this.running.length;r++){let s=this.running[r];if(s.done===void 0)continue;if(this.running.splice(r--,1),s.done){let c=$a(s.updates.length?s.updates[0].startState:this.view.state),u=Math.min(c,s.done.from+(s.active.explicit?0:1)),h=new vo(s.active.source,s.active.explicit,u,s.done,s.done.from,(t=s.done.to)!==null&&t!==void 0?t:c);for(let d of s.updates)h=h.update(d,n);if(h.hasResult()){e.push(h);continue}}let l=i.active.find(c=>c.source==s.active.source);if(l&&l.isPending)if(s.done==null){let c=new Ni(s.active.source,0);for(let u of s.updates)c=c.update(u,n);c.isPending||e.push(c)}else this.startQuery(l)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:yC.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field($n,!1);if(e&&e.tooltip&&this.view.state.facet(hn).closeOnBlur){let n=e.open&&F6(this.view,e.open.tooltip);(!n||!n.dom.contains(t.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Tu.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Kd.of(!1)}),20),this.composing=0}}}),Iie=typeof navigator=="object"&&/Win/.test(navigator.platform),Pie=nl.highest(we.domEventHandlers({keydown(t,e){let n=e.state.field($n,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||t.key.length>1||t.ctrlKey&&!(Iie&&t.altKey)||t.metaKey)return!1;let i=n.open.options[n.open.selected],r=n.active.find(l=>l.source==i.source),s=i.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(t.key)>-1&&vC(e,i),!1}})),Hie=we.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"}}}),Mu={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Pa=Ue.define({map(t,e){let n=e.mapPos(t,-1,Ln.TrackAfter);return n??void 0}}),bC=new class extends Xs{};bC.startSide=1;bC.endSide=-1;const hB=Tn.define({create(){return Ze.empty},update(t,e){if(t=t.map(e.changes),e.selection){let n=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:i=>i>=n.from&&i<=n.to})}for(let n of e.effects)n.is(Pa)&&(t=t.update({add:[bC.range(n.value,n.value+1)]}));return t}});function Uie(){return[Fie,hB]}const mw="()[]{}<>«»»«[]{}";function dB(t){for(let e=0;e<mw.length;e+=2)if(mw.charCodeAt(e)==t)return mw.charAt(e+1);return B2(t<128?t:t+1)}function pB(t,e){return t.languageDataAt("closeBrackets",e)[0]||Mu}const Vie=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Fie=we.inputHandler.of((t,e,n,i)=>{if((Vie?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let r=t.state.selection.main;if(i.length>2||i.length==2&&cr(Fn(i,0))==1||e!=r.from||n!=r.to)return!1;let s=Yie(t.state,i);return s?(t.dispatch(s),!0):!1}),$ie=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=pB(t,t.selection.main.head).brackets||Mu.brackets,r=null,s=t.changeByRange(l=>{if(l.empty){let c=Qie(t.doc,l.head);for(let u of i)if(u==c&&Fp(t.doc,l.head)==dB(Fn(u,0)))return{changes:{from:l.head-u.length,to:l.head+u.length},range:de.cursor(l.head-u.length)}}return{range:r=l}});return r||e(t.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!r},Gie=[{key:"Backspace",run:$ie}];function Yie(t,e){let n=pB(t,t.selection.main.head),i=n.brackets||Mu.brackets;for(let r of i){let s=dB(Fn(r,0));if(e==r)return s==r?Kie(t,r,i.indexOf(r+r+r)>-1,n):Xie(t,r,s,n.before||Mu.before);if(e==s&&mB(t,t.selection.main.from))return Wie(t,r,s)}return null}function mB(t,e){let n=!1;return t.field(hB).between(0,t.doc.length,i=>{i==e&&(n=!0)}),n}function Fp(t,e){let n=t.sliceString(e,e+2);return n.slice(0,cr(Fn(n,0)))}function Qie(t,e){let n=t.sliceString(e-2,e);return cr(Fn(n,0))==n.length?n:n.slice(1)}function Xie(t,e,n,i){let r=null,s=t.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:n,from:l.to}],effects:Pa.of(l.to+e.length),range:de.range(l.anchor+e.length,l.head+e.length)};let c=Fp(t.doc,l.head);return!c||/\s/.test(c)||i.indexOf(c)>-1?{changes:{insert:e+n,from:l.head},effects:Pa.of(l.head+e.length),range:de.cursor(l.head+e.length)}:{range:r=l}});return r?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Wie(t,e,n){let i=null,r=t.changeByRange(s=>s.empty&&Fp(t.doc,s.head)==n?{changes:{from:s.head,to:s.head+n.length,insert:n},range:de.cursor(s.head+n.length)}:i={range:s});return i?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Kie(t,e,n,i){let r=i.stringPrefixes||Mu.stringPrefixes,s=null,l=t.changeByRange(c=>{if(!c.empty)return{changes:[{insert:e,from:c.from},{insert:e,from:c.to}],effects:Pa.of(c.to+e.length),range:de.range(c.anchor+e.length,c.head+e.length)};let u=c.head,h=Fp(t.doc,u),d;if(h==e){if(N5(t,u))return{changes:{insert:e+e,from:u},effects:Pa.of(u+e.length),range:de.cursor(u+e.length)};if(mB(t,u)){let g=n&&t.sliceDoc(u,u+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:u,to:u+g.length,insert:g},range:de.cursor(u+g.length)}}}else{if(n&&t.sliceDoc(u-2*e.length,u)==e+e&&(d=R5(t,u-2*e.length,r))>-1&&N5(t,d))return{changes:{insert:e+e+e+e,from:u},effects:Pa.of(u+e.length),range:de.cursor(u+e.length)};if(t.charCategorizer(u)(h)!=At.Word&&R5(t,u,r)>-1&&!Zie(t,u,e,r))return{changes:{insert:e+e,from:u},effects:Pa.of(u+e.length),range:de.cursor(u+e.length)}}return{range:s=c}});return s?null:t.update(l,{scrollIntoView:!0,userEvent:"input.type"})}function N5(t,e){let n=_n(t).resolveInner(e+1);return n.parent&&n.from==e}function Zie(t,e,n,i){let r=_n(t).resolveInner(e,-1),s=i.reduce((l,c)=>Math.max(l,c.length),0);for(let l=0;l<5;l++){let c=t.sliceDoc(r.from,Math.min(r.to,r.from+n.length+s)),u=c.indexOf(n);if(!u||u>-1&&i.indexOf(c.slice(0,u))>-1){let d=r.firstChild;for(;d&&d.from==r.from&&d.to-d.from>n.length+u;){if(t.sliceDoc(d.to-n.length,d.to)==n)return!1;d=d.firstChild}return!0}let h=r.to==e&&r.parent;if(!h)break;r=h}return!1}function R5(t,e,n){let i=t.charCategorizer(e);if(i(t.sliceDoc(e-1,e))!=At.Word)return e;for(let r of n){let s=e-r.length;if(t.sliceDoc(s,e)==r&&i(t.sliceDoc(s-1,s))!=At.Word)return s}return-1}function Jie(t={}){return[Pie,$n,hn.of(t),jie,ere,Hie]}const gB=[{key:"Ctrl-Space",run:pw},{mac:"Alt-`",run:pw},{mac:"Alt-i",run:pw},{key:"Escape",run:Lie},{key:"ArrowDown",run:Yh(!0)},{key:"ArrowUp",run:Yh(!1)},{key:"PageDown",run:Yh(!0,"page")},{key:"PageUp",run:Yh(!1,"page")},{key:"Enter",run:Die}],ere=nl.highest(zp.computeN([hn],t=>t.facet(hn).defaultKeymap?[gB]:[]));class D5{constructor(e,n,i){this.from=e,this.to=n,this.diagnostic=i}}class Ra{constructor(e,n,i){this.diagnostics=e,this.panel=n,this.selected=i}static init(e,n,i){let r=i.facet(Nu).markerFilter;r&&(e=r(e,i));let s=e.slice().sort((v,x)=>v.from-x.from||v.to-x.to),l=new ns,c=[],u=0,h=i.doc.iter(),d=0,m=i.doc.length;for(let v=0;;){let x=v==s.length?null:s[v];if(!x&&!c.length)break;let w,C;if(c.length)w=u,C=c.reduce((O,E)=>Math.min(O,E.to),x&&x.from>w?x.from:1e8);else{if(w=x.from,w>m)break;C=x.to,c.push(x),v++}for(;v<s.length;){let O=s[v];if(O.from==w&&(O.to>O.from||O.to==w))c.push(O),v++,C=Math.min(O.to,C);else{C=Math.min(O.from,C);break}}C=Math.min(C,m);let k=!1;if(c.some(O=>O.from==w&&(O.to==C||C==m))&&(k=w==C,!k&&C-w<10)){let O=w-(d+h.value.length);O>0&&(h.next(O),d=w);for(let E=w;;){if(E>=C){k=!0;break}if(!h.lineBreak&&d+h.value.length>E)break;E=d+h.value.length,d+=h.value.length,h.next()}}let A=dre(c);if(k)l.add(w,w,je.widget({widget:new cre(A),diagnostics:c.slice()}));else{let O=c.reduce((E,M)=>M.markClass?E+" "+M.markClass:E,"");l.add(w,C,je.mark({class:"cm-lintRange cm-lintRange-"+A+O,diagnostics:c.slice(),inclusiveEnd:c.some(E=>E.to>C)}))}if(u=C,u==m)break;for(let O=0;O<c.length;O++)c[O].to<=u&&c.splice(O--,1)}let g=l.finish();return new Ra(g,n,ta(g))}}function ta(t,e=null,n=0){let i=null;return t.between(n,1e9,(r,s,{spec:l})=>{if(!(e&&l.diagnostics.indexOf(e)<0))if(!i)i=new D5(r,s,e||l.diagnostics[0]);else{if(l.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new D5(i.from,s,i.diagnostic)}}),i}function tre(t,e){let n=e.pos,i=e.end||n,r=t.state.facet(Nu).hideOn(t,n,i);if(r!=null)return r;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(l=>l.is(yB))||t.changes.touchesRange(s.from,Math.max(s.to,i)))}function nre(t,e){return t.field(mi,!1)?e:e.concat(Ue.appendConfig.of(pre))}const yB=Ue.define(),xC=Ue.define(),vB=Ue.define(),mi=Tn.define({create(){return new Ra(je.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),i=null,r=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);i=ta(n,t.selected.diagnostic,s)||ta(n,null,s)}!n.size&&r&&e.state.facet(Nu).autoPanel&&(r=null),t=new Ra(n,r,i)}for(let n of e.effects)if(n.is(yB)){let i=e.state.facet(Nu).autoPanel?n.value.length?Ru.open:null:t.panel;t=Ra.init(n.value,i,e.state)}else n.is(xC)?t=new Ra(t.diagnostics,n.value?Ru.open:null,t.selected):n.is(vB)&&(t=new Ra(t.diagnostics,t.panel,n.value));return t},provide:t=>[ku.from(t,e=>e.panel),we.decorations.from(t,e=>e.diagnostics)]}),ire=je.mark({class:"cm-lintRange cm-lintRange-active"});function rre(t,e,n){let{diagnostics:i}=t.state.field(mi),r,s=-1,l=-1;i.between(e-(n<0?1:0),e+(n>0?1:0),(u,h,{spec:d})=>{if(e>=u&&e<=h&&(u==h||(e>u||n>0)&&(e<h||n<0)))return r=d.diagnostics,s=u,l=h,!1});let c=t.state.facet(Nu).tooltipFilter;return r&&c&&(r=c(r,t.state)),r?{pos:s,end:l,above:t.state.doc.lineAt(s).to<l,create(){return{dom:sre(t,r)}}}:null}function sre(t,e){return mt("ul",{class:"cm-tooltip-lint"},e.map(n=>xB(t,n,!1)))}const are=t=>{let e=t.state.field(mi,!1);(!e||!e.panel)&&t.dispatch({effects:nre(t.state,[xC.of(!0)])});let n=tC(t,Ru.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},L5=t=>{let e=t.state.field(mi,!1);return!e||!e.panel?!1:(t.dispatch({effects:xC.of(!1)}),!0)},lre=t=>{let e=t.state.field(mi,!1);if(!e)return!1;let n=t.state.selection.main,i=ta(e.diagnostics,null,n.to+1);return!i&&(i=ta(e.diagnostics,null,0),!i||i.from==n.from&&i.to==n.to)?!1:(t.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)},ore=[{key:"Mod-Shift-m",run:are,preventDefault:!0},{key:"F8",run:lre}],Nu=ke.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...xr(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:z5,tooltipFilter:z5,needsRefresh:(e,n)=>e?n?i=>e(i)||n(i):e:n,hideOn:(e,n)=>e?n?(i,r,s)=>e(i,r,s)||n(i,r,s):e:n,autoPanel:(e,n)=>e||n})}}});function z5(t,e){return t?e?(n,i)=>e(t(n,i),i):t:e}function bB(t){let e=[];if(t)e:for(let{name:n}of t){for(let i=0;i<n.length;i++){let r=n[i];if(/[a-zA-Z]/.test(r)&&!e.some(s=>s.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function xB(t,e,n){var i;let r=n?bB(e.actions):[];return mt("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},mt("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((s,l)=>{let c=!1,u=v=>{if(v.preventDefault(),c)return;c=!0;let x=ta(t.state.field(mi).diagnostics,e);x&&s.apply(t,x.from,x.to)},{name:h}=s,d=r[l]?h.indexOf(r[l]):-1,m=d<0?h:[h.slice(0,d),mt("u",h.slice(d,d+1)),h.slice(d+1)],g=s.markClass?" "+s.markClass:"";return mt("button",{type:"button",class:"cm-diagnosticAction"+g,onclick:u,onmousedown:u,"aria-label":` Action: ${h}${d<0?"":` (access key "${r[l]})"`}.`},m)}),e.source&&mt("div",{class:"cm-diagnosticSource"},e.source))}class cre extends wr{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return mt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class q5{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=xB(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Ru{constructor(e){this.view=e,this.items=[];let n=r=>{if(!(r.ctrlKey||r.altKey||r.metaKey)){if(r.keyCode==27)L5(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],l=bB(s.actions);for(let c=0;c<l.length;c++)if(l[c].toUpperCase().charCodeAt(0)==r.keyCode){let u=ta(this.view.state.field(mi).diagnostics,s);u&&s.actions[c].apply(e,u.from,u.to)}}else return;r.preventDefault()}},i=r=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(r.target)&&this.moveSelection(s)};this.list=mt("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:i}),this.dom=mt("div",{class:"cm-panel-lint"},this.list,mt("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>L5(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(mi).selected;if(!e)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==e.diagnostic)return n;return-1}update(){let{diagnostics:e,selected:n}=this.view.state.field(mi),i=0,r=!1,s=null,l=new Set;for(e.between(0,this.view.state.doc.length,(c,u,{spec:h})=>{for(let d of h.diagnostics){if(l.has(d))continue;l.add(d);let m=-1,g;for(let v=i;v<this.items.length;v++)if(this.items[v].diagnostic==d){m=v;break}m<0?(g=new q5(this.view,d),this.items.splice(i,0,g),r=!0):(g=this.items[m],m>i&&(this.items.splice(i,m-i),r=!0)),n&&g.diagnostic==n.diagnostic?g.dom.hasAttribute("aria-selected")||(g.dom.setAttribute("aria-selected","true"),s=g):g.dom.hasAttribute("aria-selected")&&g.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new q5(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:c,panel:u})=>{let h=u.height/this.list.offsetHeight;c.top<u.top?this.list.scrollTop-=(u.top-c.top)/h:c.bottom>u.bottom&&(this.list.scrollTop+=(c.bottom-u.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function n(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)n();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(mi),i=ta(n.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:vB.of(i)})}static open(e){return new Ru(e)}}function ure(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 Qh(t){return ure(`<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 fre=we.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:Qh("#d11")},".cm-lintRange-warning":{backgroundImage:Qh("orange")},".cm-lintRange-info":{backgroundImage:Qh("#999")},".cm-lintRange-hint":{backgroundImage:Qh("#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 hre(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function dre(t){let e="hint",n=1;for(let i of t){let r=hre(i.severity);r>n&&(n=r,e=i.severity)}return e}const pre=[mi,we.decorations.compute([mi],t=>{let{selected:e,panel:n}=t.field(mi);return!e||!n||e.from==e.to?je.none:je.set([ire.range(e.from,e.to)])}),ree(rre,{hideOn:tre}),fre];var B5=function(e){e===void 0&&(e={});var{crosshairCursor:n=!1}=e,i=[];e.closeBracketsKeymap!==!1&&(i=i.concat(Gie)),e.defaultKeymap!==!1&&(i=i.concat(jne)),e.searchKeymap!==!1&&(i=i.concat(fie)),e.historyKeymap!==!1&&(i=i.concat($te)),e.foldKeymap!==!1&&(i=i.concat(ste)),e.completionKeymap!==!1&&(i=i.concat(gB)),e.lintKeymap!==!1&&(i=i.concat(ore));var r=[];return e.lineNumbers!==!1&&r.push(yee()),e.highlightActiveLineGutter!==!1&&r.push(xee()),e.highlightSpecialChars!==!1&&r.push(DJ()),e.history!==!1&&r.push(qte()),e.foldGutter!==!1&&r.push(cte()),e.drawSelection!==!1&&r.push(SJ()),e.dropCursor!==!1&&r.push(OJ()),e.allowMultipleSelections!==!1&&r.push(nt.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&r.push(Xee()),e.syntaxHighlighting!==!1&&r.push(yq(dte,{fallback:!0})),e.bracketMatching!==!1&&r.push(xte()),e.closeBrackets!==!1&&r.push(Uie()),e.autocompletion!==!1&&r.push(Jie()),e.rectangularSelection!==!1&&r.push(YJ()),n!==!1&&r.push(WJ()),e.highlightActiveLine!==!1&&r.push(IJ()),e.highlightSelectionMatches!==!1&&r.push(Fne()),e.tabSize&&typeof e.tabSize=="number"&&r.push(Bp.of(" ".repeat(e.tabSize))),r.concat([zp.of(i.flat())]).filter(Boolean)};const mre="#e5c07b",j5="#e06c75",gre="#56b6c2",yre="#ffffff",cd="#abb2bf",jS="#7d8799",vre="#61afef",bre="#98c379",I5="#d19a66",xre="#c678dd",wre="#21252b",P5="#2c313a",H5="#282c34",gw="#353a42",Sre="#3E4451",U5="#528bff",Cre=we.theme({"&":{color:cd,backgroundColor:H5},".cm-content":{caretColor:U5},".cm-cursor, .cm-dropCursor":{borderLeftColor:U5},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Sre},".cm-panels":{backgroundColor:wre,color:cd},".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:H5,color:jS,border:"none"},".cm-activeLineGutter":{backgroundColor:P5},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:gw},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:gw,borderBottomColor:gw},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:P5,color:cd}}},{dark:!0}),kre=Xu.define([{tag:le.keyword,color:xre},{tag:[le.name,le.deleted,le.character,le.propertyName,le.macroName],color:j5},{tag:[le.function(le.variableName),le.labelName],color:vre},{tag:[le.color,le.constant(le.name),le.standard(le.name)],color:I5},{tag:[le.definition(le.name),le.separator],color:cd},{tag:[le.typeName,le.className,le.number,le.changed,le.annotation,le.modifier,le.self,le.namespace],color:mre},{tag:[le.operator,le.operatorKeyword,le.url,le.escape,le.regexp,le.link,le.special(le.string)],color:gre},{tag:[le.meta,le.comment],color:jS},{tag:le.strong,fontWeight:"bold"},{tag:le.emphasis,fontStyle:"italic"},{tag:le.strikethrough,textDecoration:"line-through"},{tag:le.link,color:jS,textDecoration:"underline"},{tag:le.heading,fontWeight:"bold",color:j5},{tag:[le.atom,le.bool,le.special(le.variableName)],color:I5},{tag:[le.processingInstruction,le.string,le.inserted],color:bre},{tag:le.invalid,color:yre}]),wB=[Cre,yq(kre)];var Are=we.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),_re=function(e){e===void 0&&(e={});var{indentWithTab:n=!0,editable:i=!0,readOnly:r=!1,theme:s="light",placeholder:l="",basicSetup:c=!0}=e,u=[];switch(n&&u.unshift(zp.of([Ine])),c&&(typeof c=="boolean"?u.unshift(B5()):u.unshift(B5(c))),l&&u.unshift(VJ(l)),s){case"light":u.push(Are);break;case"dark":u.push(wB);break;case"none":break;default:u.push(s);break}return i===!1&&u.push(we.editable.of(!1)),r&&u.push(nt.readOnly.of(!0)),[...u]},Ore=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 Ere{constructor(e,n){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=n,this.timeoutMS=n,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(n=>{try{n()}catch(i){console.error("TimeoutLatch callback error:",i)}})}}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 V5{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 yw=null,Tre=()=>typeof window>"u"?new V5:(yw||(yw=new V5),yw),F5=br.define(),Mre=200,Nre=[];function Rre(t){var{value:e,selection:n,onChange:i,onStatistics:r,onCreateEditor:s,onUpdate:l,extensions:c=Nre,autoFocus:u,theme:h="light",height:d=null,minHeight:m=null,maxHeight:g=null,width:v=null,minWidth:x=null,maxWidth:w=null,placeholder:C="",editable:k=!0,readOnly:A=!1,indentWithTab:O=!0,basicSetup:E=!0,root:M,initialState:T}=t,[N,I]=Y.useState(),[q,H]=Y.useState(),[B,$]=Y.useState(),V=Y.useState(()=>({current:null}))[0],D=Y.useState(()=>({current:null}))[0],P=we.theme({"&":{height:d,minHeight:m,maxHeight:g,width:v,minWidth:x,maxWidth:w},"& .cm-scroller":{height:"100% !important"}}),L=we.updateListener.of(U=>{if(U.docChanged&&typeof i=="function"&&!U.transactions.some(G=>G.annotation(F5))){V.current?V.current.reset():(V.current=new Ere(()=>{if(D.current){var G=D.current;D.current=null,G()}V.current=null},Mre),Tre().add(V.current));var re=U.state.doc,z=re.toString();i(z,U)}r&&r(Ore(U))}),Q=_re({theme:h,editable:k,readOnly:A,placeholder:C,indentWithTab:O,basicSetup:E}),Z=[L,P,...Q];return l&&typeof l=="function"&&Z.push(we.updateListener.of(l)),Z=Z.concat(c),Y.useLayoutEffect(()=>{if(N&&!B){var U={doc:e,selection:n,extensions:Z},re=T?nt.fromJSON(T.json,U,T.fields):nt.create(U);if($(re),!q){var z=new we({state:re,parent:N,root:M});H(z),s&&s(z,re)}}return()=>{q&&($(void 0),H(void 0))}},[N,B]),Y.useEffect(()=>{t.container&&I(t.container)},[t.container]),Y.useEffect(()=>()=>{q&&(q.destroy(),H(void 0)),V.current&&(V.current.cancel(),V.current=null)},[q]),Y.useEffect(()=>{u&&q&&q.focus()},[u,q]),Y.useEffect(()=>{q&&q.dispatch({effects:Ue.reconfigure.of(Z)})},[h,c,d,m,g,v,x,w,C,k,A,O,E,i,l]),Y.useEffect(()=>{if(e!==void 0){var U=q?q.state.doc.toString():"";if(q&&e!==U){var re=V.current&&!V.current.isDone,z=()=>{q&&e!==q.state.doc.toString()&&q.dispatch({changes:{from:0,to:q.state.doc.toString().length,insert:e||""},annotations:[F5.of(!0)]})};re?D.current=z:z()}}},[e,q]),{state:B,setState:$,view:q,setView:H,container:N,setContainer:I}}var Dre=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],SB=Y.forwardRef((t,e)=>{var{className:n,value:i="",selection:r,extensions:s=[],onChange:l,onStatistics:c,onCreateEditor:u,onUpdate:h,autoFocus:d,theme:m="light",height:g,minHeight:v,maxHeight:x,width:w,minWidth:C,maxWidth:k,basicSetup:A,placeholder:O,indentWithTab:E,editable:M,readOnly:T,root:N,initialState:I}=t,q=cK(t,Dre),H=Y.useRef(null),{state:B,view:$,container:V,setContainer:D}=Rre({root:N,value:i,autoFocus:d,theme:m,height:g,minHeight:v,maxHeight:x,width:w,minWidth:C,maxWidth:k,basicSetup:A,placeholder:O,indentWithTab:E,editable:M,readOnly:T,selection:r,onChange:l,onStatistics:c,onCreateEditor:u,onUpdate:h,extensions:s,initialState:I});Y.useImperativeHandle(e,()=>({editor:H.current,state:B,view:$}),[H,V,B,$]);var P=Y.useCallback(Q=>{H.current=Q,D(Q)},[D]);if(typeof i!="string")throw new Error("value must be typeof string but got "+typeof i);var L=typeof m=="string"?"cm-theme-"+m:"cm-theme";return S.jsx("div",$w({ref:P,className:""+L+(n?" "+n:"")},q))});SB.displayName="CodeMirror";var $5={};class Jd{constructor(e,n,i,r,s,l,c,u,h,d=0,m){this.p=e,this.stack=n,this.state=i,this.reducePos=r,this.pos=s,this.score=l,this.buffer=c,this.bufferBase=u,this.curContext=h,this.lookAhead=d,this.parent=m}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,i=0){let r=e.parser.context;return new Jd(e,[],n,i,i,0,[],0,r?new G5(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let i=e>>19,r=e&65535,{parser:s}=this.p,l=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),c=s.dynamicPrecedence(r);if(c&&(this.score+=c),i==0){this.pushState(s.getGoto(this.state,r,!0),this.reducePos),r<s.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,l?8:4,!0),this.reduceContext(r,this.reducePos);return}let u=this.stack.length-(i-1)*3-(e&262144?6:0),h=u?this.stack[u-2]:this.p.ranges[0].from,d=this.reducePos-h;d>=2e3&&!(!((n=this.p.parser.nodeSet.types[r])===null||n===void 0)&&n.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=d):this.p.lastBigReductionSize<d&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=d));let m=u?this.stack[u-1]:0,g=this.bufferBase+this.buffer.length-m;if(r<s.minRepeatTerm||e&131072){let v=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,h,v,g+4,!0)}if(e&262144)this.state=this.stack[u];else{let v=this.stack[u-3];this.state=s.getGoto(v,r,!0)}for(;this.stack.length>u;)this.stack.pop();this.reduceContext(r,h)}storeNode(e,n,i,r=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let l=this,c=this.buffer.length;if(c==0&&l.parent&&(c=l.bufferBase-l.parent.bufferBase,l=l.parent),c>0&&l.buffer[c-4]==0&&l.buffer[c-1]>-1){if(n==i)return;if(l.buffer[c-2]>=n){l.buffer[c-2]=i;return}}}if(!s||this.pos==i)this.buffer.push(e,n,i,r);else{let l=this.buffer.length;if(l>0&&(this.buffer[l-4]!=0||this.buffer[l-1]<0)){let c=!1;for(let u=l;u>0&&this.buffer[u-2]>i;u-=4)if(this.buffer[u-1]>=0){c=!0;break}if(c)for(;l>0&&this.buffer[l-2]>i;)this.buffer[l]=this.buffer[l-4],this.buffer[l+1]=this.buffer[l-3],this.buffer[l+2]=this.buffer[l-2],this.buffer[l+3]=this.buffer[l-1],l-=4,r>4&&(r-=4)}this.buffer[l]=e,this.buffer[l+1]=n,this.buffer[l+2]=i,this.buffer[l+3]=r}}shift(e,n,i,r){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let s=e,{parser:l}=this.p;this.pos=r;let c=l.stateFlag(s,1);!c&&(r>i||n<=l.maxNode)&&(this.reducePos=r),this.pushState(s,c?i:Math.min(i,this.reducePos)),this.shiftContext(n,i),n<=l.maxNode&&this.buffer.push(n,i,r,4)}else this.pos=r,this.shiftContext(n,i),n<=this.p.parser.maxNode&&this.buffer.push(n,i,r,4)}apply(e,n,i,r){e&65536?this.reduce(e):this.shift(e,n,i,r)}useNode(e,n){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(n,r),this.buffer.push(i,r,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,n=e.buffer.length;for(;n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let i=e.buffer.slice(n),r=e.bufferBase+n;for(;e&&r==e.bufferBase;)e=e.parent;return new Jd(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,i?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new Lre(this);;){let i=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(i==0)return!1;if((i&65536)==0)return!0;n.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let r=[];for(let s=0,l;s<n.length;s+=2)(l=n[s+1])!=this.state&&this.p.parser.hasAction(l,e)&&r.push(n[s],l);if(this.stack.length<120)for(let s=0;r.length<8&&s<n.length;s+=2){let l=n[s+1];r.some((c,u)=>u&1&&c==l)||r.push(n[s],l)}n=r}let i=[];for(let r=0;r<n.length&&i.length<4;r+=2){let s=n[r+1];if(s==this.state)continue;let l=this.split();l.pushState(s,this.pos),l.storeNode(0,l.pos,l.pos,4,!0),l.shiftContext(n[r],this.pos),l.reducePos=this.pos,l.score-=200,i.push(l)}return i}forceReduce(){let{parser:e}=this.p,n=e.stateSlot(this.state,5);if((n&65536)==0)return!1;if(!e.validAction(this.state,n)){let i=n>>19,r=n&65535,s=this.stack.length-i*3;if(s<0||e.getGoto(this.stack[s],r,!1)<0){let l=this.findForcedReduction();if(l==null)return!1;n=l}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],i=(r,s)=>{if(!n.includes(r))return n.push(r),e.allActions(r,l=>{if(!(l&393216))if(l&65536){let c=(l>>19)-s;if(c>1){let u=l&65535,h=this.stack.length-c*3;if(h>=0&&e.getGoto(this.stack[h],u,!1)>=0)return c<<19|65536|u}}else{let c=i(l,s+1);if(c!=null)return c}})};return i(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 n=0;n<this.stack.length;n+=3)if(this.stack[n]!=e.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(n)))}reduceContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(n)))}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 n=new G5(this.curContext.tracker,e);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}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 G5{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class Lre{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=r}}class ep{constructor(e,n,i){this.stack=e,this.pos=n,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new ep(e,n,n-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 ep(this.stack,this.pos,this.index)}}function Xh(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let i=0,r=0;i<t.length;){let s=0;for(;;){let l=t.charCodeAt(i++),c=!1;if(l==126){s=65535;break}l>=92&&l--,l>=34&&l--;let u=l-32;if(u>=46&&(u-=46,c=!0),s+=u,c)break;s*=46}n?n[r++]=s:n=new e(s)}return n}class ud{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const Y5=new ud;class zre{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=Y5,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let i=this.range,r=this.rangeIndex,s=this.pos+e;for(;s<i.from;){if(!r)return null;let l=this.ranges[--r];s-=i.from-l.to,i=l}for(;n<0?s>i.to:s>=i.to;){if(r==this.ranges.length-1)return null;let l=this.ranges[++r];s+=l.from-i.to,i=l}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let n of this.ranges)if(n.to>e)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,i,r;if(n>=0&&n<this.chunk.length)i=this.pos+e,r=this.chunk.charCodeAt(n);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(i=s,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let l=this.rangeIndex,c=this.range;for(;c.to<=i;)c=this.ranges[++l];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>c.to&&(this.chunk2=this.chunk2.slice(0,c.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(e,n=0){let i=n?this.resolveOffset(n,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=i}acceptTokenTo(e,n){this.token.value=e,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:n}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=n,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),n=this.pos+e.length;this.chunk=n>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,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=Y5,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,n){if(e>=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let i="";for(let r of this.ranges){if(r.from>=n)break;r.to>e&&(i+=this.input.read(Math.max(r.from,e),Math.min(r.to,n)))}return i}}class bo{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:i}=n.p;qre(this.data,e,n,this.id,i.data,i.tokenPrecTable)}}bo.prototype.contextual=bo.prototype.fallback=bo.prototype.extend=!1;bo.prototype.fallback=bo.prototype.extend=!1;class $p{constructor(e,n={}){this.token=e,this.contextual=!!n.contextual,this.fallback=!!n.fallback,this.extend=!!n.extend}}function qre(t,e,n,i,r,s){let l=0,c=1<<i,{dialect:u}=n.p.parser;e:for(;(c&t[l])!=0;){let h=t[l+1];for(let v=l+3;v<h;v+=2)if((t[v+1]&c)>0){let x=t[v];if(u.allows(x)&&(e.token.value==-1||e.token.value==x||Bre(x,e.token.value,r,s))){e.acceptToken(x);break}}let d=e.next,m=0,g=t[l+2];if(e.next<0&&g>m&&t[h+g*3-3]==65535){l=t[h+g*3-1];continue e}for(;m<g;){let v=m+g>>1,x=h+v+(v<<1),w=t[x],C=t[x+1]||65536;if(d<w)g=v;else if(d>=C)m=v+1;else{l=t[x+2],e.advance();continue e}}break}}function Q5(t,e,n){for(let i=e,r;(r=t[i])!=65535;i++)if(r==n)return i-e;return-1}function Bre(t,e,n,i){let r=Q5(n,i,e);return r<0||Q5(n,i,t)<r}const hi=typeof process<"u"&&$5&&/\bparse\b/.test($5.LOG);let vw=null;function X5(t,e,n){let i=t.cursor(Lt.IncludeAnonymous);for(i.moveTo(e);;)if(!(n<0?i.childBefore(e):i.childAfter(e)))for(;;){if((n<0?i.to<e:i.from>e)&&!i.type.isError)return n<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(t.length,Math.max(i.from+1,e+25));if(n<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return n<0?0:t.length}}class jre{constructor(e,n){this.fragments=e,this.nodeSet=n,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?X5(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?X5(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 n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let i=this.trees[n],r=this.index[n];if(r==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=i.children[r],l=this.start[n]+i.positions[r];if(l>e)return this.nextStart=l,null;if(s instanceof Ft){if(l==e){if(l<this.safeFrom)return null;let c=l+s.length;if(c<=this.safeTo){let u=s.prop(Qe.lookAhead);if(!u||c+u<this.fragment.to)return s}}this.index[n]++,l+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(l),this.index.push(0))}else this.index[n]++,this.nextStart=l+s.length}}}class Ire{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new ud)}getActions(e){let n=0,i=null,{parser:r}=e.p,{tokenizers:s}=r,l=r.stateSlot(e.state,3),c=e.curContext?e.curContext.hash:0,u=0;for(let h=0;h<s.length;h++){if((1<<h&l)==0)continue;let d=s[h],m=this.tokens[h];if(!(i&&!d.fallback)&&((d.contextual||m.start!=e.pos||m.mask!=l||m.context!=c)&&(this.updateCachedToken(m,d,e),m.mask=l,m.context=c),m.lookAhead>m.end+25&&(u=Math.max(m.lookAhead,u)),m.value!=0)){let g=n;if(m.extended>-1&&(n=this.addActions(e,m.extended,m.end,n)),n=this.addActions(e,m.value,m.end,n),!d.extend&&(i=m,n>g))break}}for(;this.actions.length>n;)this.actions.pop();return u&&e.setLookAhead(u),!i&&e.pos==this.stream.end&&(i=new ud,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,n=this.addActions(e,i.value,i.end,n)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new ud,{pos:i,p:r}=e;return n.start=i,n.end=Math.min(i+1,r.stream.end),n.value=i==r.stream.end?r.parser.eofTerm:0,n}updateCachedToken(e,n,i){let r=this.stream.clipPos(i.pos);if(n.token(this.stream.reset(r,e),i),e.value>-1){let{parser:s}=i.p;for(let l=0;l<s.specialized.length;l++)if(s.specialized[l]==e.value){let c=s.specializers[l](this.stream.read(e.start,e.end),i);if(c>=0&&i.p.parser.dialect.allows(c>>1)){(c&1)==0?e.value=c>>1:e.extended=c>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,n,i,r){for(let s=0;s<r;s+=3)if(this.actions[s]==e)return r;return this.actions[r++]=e,this.actions[r++]=n,this.actions[r++]=i,r}addActions(e,n,i,r){let{state:s}=e,{parser:l}=e.p,{data:c}=l;for(let u=0;u<2;u++)for(let h=l.stateSlot(s,u?2:1);;h+=3){if(c[h]==65535)if(c[h+1]==1)h=Xr(c,h+2);else{r==0&&c[h+1]==2&&(r=this.putAction(Xr(c,h+2),n,i,r));break}c[h]==n&&(r=this.putAction(Xr(c,h+1),n,i,r))}return r}}class Pre{constructor(e,n,i,r){this.parser=e,this.input=n,this.ranges=r,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 zre(n,r),this.tokens=new Ire(e,this.stream),this.topTerm=e.top[1];let{from:s}=r[0];this.stacks=[Jd.start(this,e.top[0],s)],this.fragments=i.length&&this.stream.end-s>e.bufferLength*4?new jre(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,i=this.stacks=[],r,s;if(this.bigReductionCount>300&&e.length==1){let[l]=e;for(;l.forceReduce()&&l.stack.length&&l.stack[l.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let l=0;l<e.length;l++){let c=e[l];for(;;){if(this.tokens.mainToken=null,c.pos>n)i.push(c);else{if(this.advanceStack(c,i,e))continue;{r||(r=[],s=[]),r.push(c);let u=this.tokens.getMainToken(c);s.push(u.value,u.end)}}break}}if(!i.length){let l=r&&Vre(r);if(l)return hi&&console.log("Finish with "+this.stackID(l)),this.stackToTree(l);if(this.parser.strict)throw hi&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&r){let l=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,i);if(l)return hi&&console.log("Force-finish "+this.stackID(l)),this.stackToTree(l.forceAll())}if(this.recovering){let l=this.recovering==1?1:this.recovering*3;if(i.length>l)for(i.sort((c,u)=>u.score-c.score);i.length>l;)i.pop();i.some(c=>c.reducePos>n)&&this.recovering--}else if(i.length>1){e:for(let l=0;l<i.length-1;l++){let c=i[l];for(let u=l+1;u<i.length;u++){let h=i[u];if(c.sameState(h)||c.buffer.length>500&&h.buffer.length>500)if((c.score-h.score||c.buffer.length-h.buffer.length)>0)i.splice(u--,1);else{i.splice(l--,1);continue e}}}i.length>12&&(i.sort((l,c)=>c.score-l.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let l=1;l<i.length;l++)i[l].pos<this.minStackPos&&(this.minStackPos=i[l].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,n,i){let r=e.pos,{parser:s}=this,l=hi?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let h=e.curContext&&e.curContext.tracker.strict,d=h?e.curContext.hash:0;for(let m=this.fragments.nodeAt(r);m;){let g=this.parser.nodeSet.types[m.type.id]==m.type?s.getGoto(e.state,m.type.id):-1;if(g>-1&&m.length&&(!h||(m.prop(Qe.contextHash)||0)==d))return e.useNode(m,g),hi&&console.log(l+this.stackID(e)+` (via reuse of ${s.getName(m.type.id)})`),!0;if(!(m instanceof Ft)||m.children.length==0||m.positions[0]>0)break;let v=m.children[0];if(v instanceof Ft&&m.positions[0]==0)m=v;else break}}let c=s.stateSlot(e.state,4);if(c>0)return e.reduce(c),hi&&console.log(l+this.stackID(e)+` (via always-reduce ${s.getName(c&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let u=this.tokens.getActions(e);for(let h=0;h<u.length;){let d=u[h++],m=u[h++],g=u[h++],v=h==u.length||!i,x=v?e:e.split(),w=this.tokens.mainToken;if(x.apply(d,m,w?w.start:x.pos,g),hi&&console.log(l+this.stackID(x)+` (via ${(d&65536)==0?"shift":`reduce of ${s.getName(d&65535)}`} for ${s.getName(m)} @ ${r}${x==e?"":", split"})`),v)return!0;x.pos>r?n.push(x):i.push(x)}return!1}advanceFully(e,n){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return W5(e,n),!0}}runRecovery(e,n,i){let r=null,s=!1;for(let l=0;l<e.length;l++){let c=e[l],u=n[l<<1],h=n[(l<<1)+1],d=hi?this.stackID(c)+" -> ":"";if(c.deadEnd&&(s||(s=!0,c.restart(),hi&&console.log(d+this.stackID(c)+" (restarted)"),this.advanceFully(c,i))))continue;let m=c.split(),g=d;for(let v=0;v<10&&m.forceReduce()&&(hi&&console.log(g+this.stackID(m)+" (via force-reduce)"),!this.advanceFully(m,i));v++)hi&&(g=this.stackID(m)+" -> ");for(let v of c.recoverByInsert(u))hi&&console.log(d+this.stackID(v)+" (via recover-insert)"),this.advanceFully(v,i);this.stream.end>c.pos?(h==c.pos&&(h++,u=0),c.recoverByDelete(u,h),hi&&console.log(d+this.stackID(c)+` (via recover-delete ${this.parser.getName(u)})`),W5(c,i)):(!r||r.score<m.score)&&(r=m)}return r}stackToTree(e){return e.close(),Ft.build({buffer:ep.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 n=(vw||(vw=new WeakMap)).get(e);return n||vw.set(e,n=String.fromCodePoint(this.nextStackID++)),n+e}}function W5(t,e){for(let n=0;n<e.length;n++){let i=e[n];if(i.pos==t.pos&&i.sameState(t)){e[n].score<t.score&&(e[n]=t);return}}e.push(t)}class Hre{constructor(e,n,i){this.source=e,this.flags=n,this.disabled=i}allows(e){return!this.disabled||this.disabled[e]==0}}const bw=t=>t;class Ure{constructor(e){this.start=e.start,this.shift=e.shift||bw,this.reduce=e.reduce||bw,this.reuse=e.reuse||bw,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class tp extends eq{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let c=0;c<e.repeatNodeCount;c++)n.push("");let i=Object.keys(e.topRules).map(c=>e.topRules[c][1]),r=[];for(let c=0;c<n.length;c++)r.push([]);function s(c,u,h){r[c].push([u,u.deserialize(String(h))])}if(e.nodeProps)for(let c of e.nodeProps){let u=c[0];typeof u=="string"&&(u=Qe[u]);for(let h=1;h<c.length;){let d=c[h++];if(d>=0)s(d,u,c[h++]);else{let m=c[h+-d];for(let g=-d;g>0;g--)s(c[h++],u,m);h++}}}this.nodeSet=new nC(n.map((c,u)=>ti.define({name:u>=this.minRepeatTerm?void 0:c,id:u,props:r[u],top:i.indexOf(u)>-1,error:u==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(u)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=W6;let l=Xh(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let c=0;c<this.specializerSpecs.length;c++)this.specialized[c]=this.specializerSpecs[c].term;this.specializers=this.specializerSpecs.map(K5),this.states=Xh(e.states,Uint32Array),this.data=Xh(e.stateData),this.goto=Xh(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(c=>typeof c=="number"?new bo(l,c):c),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,n,i){let r=new Pre(this,e,n,i);for(let s of this.wrappers)r=s(r,e,n,i);return r}getGoto(e,n,i=!1){let r=this.goto;if(n>=r[0])return-1;for(let s=r[n+1];;){let l=r[s++],c=l&1,u=r[s++];if(c&&i)return u;for(let h=s+(l>>1);s<h;s++)if(r[s]==e)return u;if(c)return-1}}hasAction(e,n){let i=this.data;for(let r=0;r<2;r++)for(let s=this.stateSlot(e,r?2:1),l;;s+=3){if((l=i[s])==65535)if(i[s+1]==1)l=i[s=Xr(i,s+2)];else{if(i[s+1]==2)return Xr(i,s+2);break}if(l==n||l==0)return Xr(i,s+1)}return 0}stateSlot(e,n){return this.states[e*6+n]}stateFlag(e,n){return(this.stateSlot(e,0)&n)>0}validAction(e,n){return!!this.allActions(e,i=>i==n?!0:null)}allActions(e,n){let i=this.stateSlot(e,4),r=i?n(i):void 0;for(let s=this.stateSlot(e,1);r==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Xr(this.data,s+2);else break;r=n(Xr(this.data,s+1))}return r}nextStates(e){let n=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Xr(this.data,i+2);else break;if((this.data[i+2]&1)==0){let r=this.data[i+1];n.some((s,l)=>l&1&&s==r)||n.push(this.data[i],r)}}return n}configure(e){let n=Object.assign(Object.create(tp.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=i}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(i=>{let r=e.tokenizers.find(s=>s.from==i);return r?r.to:i})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((i,r)=>{let s=e.specializers.find(c=>c.from==i.external);if(!s)return i;let l=Object.assign(Object.assign({},i),{external:s.to});return n.specializers[r]=K5(l),l})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}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 n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),i=n.map(()=>!1);if(e)for(let s of e.split(" ")){let l=n.indexOf(s);l>=0&&(i[l]=!0)}let r=null;for(let s=0;s<n.length;s++)if(!i[s])for(let l=this.dialects[n[s]],c;(c=this.data[l++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[c]=1;return new Hre(e,i,r)}static deserialize(e){return new tp(e)}}function Xr(t,e){return t[e]|t[e+1]<<16}function Vre(t){let e=null;for(let n of t){let i=n.p.stoppedAt;(n.pos==n.p.stream.end||i!=null&&n.pos>i)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.score<n.score)&&(e=n)}return e}function K5(t){if(t.external){let e=t.extend?1:0;return(n,i)=>t.external(n,i)<<1|e}return t.get}const Jl=63,Z5=64,Fre=1,$re=2,CB=3,Gre=4,kB=5,Yre=6,Qre=7,AB=65,Xre=66,Wre=8,Kre=9,Zre=10,Jre=11,ese=12,_B=13,tse=19,nse=20,ise=29,rse=33,sse=34,ase=47,lse=0,wC=1,IS=2,Du=3,PS=4;class Da{constructor(e,n,i){this.parent=e,this.depth=n,this.type=i,this.hash=(e?e.hash+e.hash<<8:0)+n+(n<<4)+i}}Da.top=new Da(null,-1,lse);function ru(t,e){for(let n=0,i=e-t.pos-1;;i--,n++){let r=t.peek(i);if(ss(r)||r==-1)return n}}function HS(t){return t==32||t==9}function ss(t){return t==10||t==13}function OB(t){return HS(t)||ss(t)}function Ha(t){return t<0||OB(t)}const ose=new Ure({start:Da.top,reduce(t,e){return t.type==Du&&(e==nse||e==sse)?t.parent:t},shift(t,e,n,i){if(e==CB)return new Da(t,ru(i,i.pos),wC);if(e==AB||e==kB)return new Da(t,ru(i,i.pos),IS);if(e==Jl)return t.parent;if(e==tse||e==rse)return new Da(t,0,Du);if(e==_B&&t.type==PS)return t.parent;if(e==ase){let r=/[1-9]/.exec(i.read(i.pos,n.pos));if(r)return new Da(t,t.depth+ +r[0],PS)}return t},hash(t){return t.hash}});function No(t,e,n=0){return t.peek(n)==e&&t.peek(n+1)==e&&t.peek(n+2)==e&&Ha(t.peek(n+3))}const cse=new $p((t,e)=>{if(t.next==-1&&e.canShift(Z5))return t.acceptToken(Z5);let n=t.peek(-1);if((ss(n)||n<0)&&e.context.type!=Du){if(No(t,45))if(e.canShift(Jl))t.acceptToken(Jl);else return t.acceptToken(Fre,3);if(No(t,46))if(e.canShift(Jl))t.acceptToken(Jl);else return t.acceptToken($re,3);let i=0;for(;t.next==32;)i++,t.advance();(i<e.context.depth||i==e.context.depth&&e.context.type==wC&&(t.next!=45||!Ha(t.peek(1))))&&t.next!=-1&&!ss(t.next)&&t.next!=35&&t.acceptToken(Jl,-i)}},{contextual:!0}),use=new $p((t,e)=>{if(e.context.type==Du){t.next==63&&(t.advance(),Ha(t.next)&&t.acceptToken(Qre));return}if(t.next==45)t.advance(),Ha(t.next)&&t.acceptToken(e.context.type==wC&&e.context.depth==ru(t,t.pos-1)?Gre:CB);else if(t.next==63)t.advance(),Ha(t.next)&&t.acceptToken(e.context.type==IS&&e.context.depth==ru(t,t.pos-1)?Yre:kB);else{let n=t.pos;for(;;)if(HS(t.next)){if(t.pos==n)return;t.advance()}else if(t.next==33)EB(t);else if(t.next==38)US(t);else if(t.next==42){US(t);break}else if(t.next==39||t.next==34){if(SC(t,!0))break;return}else if(t.next==91||t.next==123){if(!hse(t))return;break}else{TB(t,!0,!1,0);break}for(;HS(t.next);)t.advance();if(t.next==58){if(t.pos==n&&e.canShift(ise))return;let i=t.peek(1);Ha(i)&&t.acceptTokenTo(e.context.type==IS&&e.context.depth==ru(t,n)?Xre:AB,n)}}},{contextual:!0});function fse(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 J5(t){return t>=48&&t<=57||t>=97&&t<=102||t>=65&&t<=70}function e4(t,e){return t.next==37?(t.advance(),J5(t.next)&&t.advance(),J5(t.next)&&t.advance(),!0):fse(t.next)||e&&t.next==44?(t.advance(),!0):!1}function EB(t){if(t.advance(),t.next==60){for(t.advance();;)if(!e4(t,!0)){t.next==62&&t.advance();break}}else for(;e4(t,!1););}function US(t){for(t.advance();!Ha(t.next)&&np(t.next)!="f";)t.advance()}function SC(t,e){let n=t.next,i=!1,r=t.pos;for(t.advance();;){let s=t.next;if(s<0)break;if(t.advance(),s==n)if(s==39)if(t.next==39)t.advance();else break;else break;else if(s==92&&n==34)t.next>=0&&t.advance();else if(ss(s)){if(e)return!1;i=!0}else if(e&&t.pos>=r+1024)return!1}return!i}function hse(t){for(let e=[],n=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(!SC(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>n||ss(t.next))return!1;t.advance()}}const dse="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";function np(t){return t<33?"u":t>125?"s":dse[t-33]}function xw(t,e){let n=np(t);return n!="u"&&!(e&&n=="f")}function TB(t,e,n,i){if(np(t.next)=="s"||(t.next==63||t.next==58||t.next==45)&&xw(t.peek(1),n))t.advance();else return!1;let r=t.pos;for(;;){let s=t.next,l=0,c=i+1;for(;OB(s);){if(ss(s)){if(e)return!1;c=0}else c++;s=t.peek(++l)}if(!(s>=0&&(s==58?xw(t.peek(l+1),n):s==35?t.peek(l-1)!=32:xw(s,n)))||!n&&c<=i||c==0&&!n&&(No(t,45,l)||No(t,46,l)))break;if(e&&np(s)=="f")return!1;for(let h=l;h>=0;h--)t.advance();if(e&&t.pos>r+1024)return!1}return!0}const pse=new $p((t,e)=>{if(t.next==33)EB(t),t.acceptToken(ese);else if(t.next==38||t.next==42){let n=t.next==38?Zre:Jre;US(t),t.acceptToken(n)}else t.next==39||t.next==34?(SC(t,!1),t.acceptToken(Kre)):TB(t,!1,e.context.type==Du,e.context.depth)&&t.acceptToken(Wre)}),mse=new $p((t,e)=>{let n=e.context.type==PS?e.context.depth:-1,i=t.pos;e:for(;;){let r=0,s=t.next;for(;s==32;)s=t.peek(++r);if(!r&&(No(t,45,r)||No(t,46,r))||!ss(s)&&(n<0&&(n=Math.max(e.context.depth+1,r)),r<n))break;for(;;){if(t.next<0)break e;let l=ss(t.next);if(t.advance(),l)continue e;i=t.pos}}t.acceptTokenTo(_B,i)}),gse=tq({DirectiveName:le.keyword,DirectiveContent:le.attributeValue,"DirectiveEnd DocEnd":le.meta,QuotedLiteral:le.string,BlockLiteralHeader:le.special(le.string),BlockLiteralContent:le.content,Literal:le.content,"Key/Literal Key/QuotedLiteral":le.definition(le.propertyName),"Anchor Alias":le.labelName,Tag:le.typeName,Comment:le.lineComment,": , -":le.separator,"?":le.punctuation,"[ ]":le.squareBracket,"{ }":le.brace}),yse=tp.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:ose,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[gse],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:[cse,use,pse,mse,0,1],topRules:{Stream:[0,15]},tokenPrec:0}),vse=Id.define({name:"yaml",parser:yse.configure({props:[sq.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 n=t.column(e.from,1);if(n==t.lineIndent(e.from,1))return n;if(e.to>t.pos)return null}}return null},FlowMapping:l5({closing:"}"}),FlowSequence:l5({closing:"]"})}),oq.add({"FlowMapping FlowSequence":Kee,"Item Pair BlockLiteral":(t,e)=>({from:e.doc.lineAt(t.from).to,to:t.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});function bse(){return new Pee(vse)}const xse=()=>{const{error:t,isCliMode:e,yamlInput:n,setYamlInput:i,parseAndSetSchema:r,savingStatus:s,lastUpdateSource:l,theme:c,currentModelSlug:u}=en(),[h,d]=Y.useState(n),m=Y.useRef(null),g=Y.useRef(null),v=Y.useRef(!0);Y.useEffect(()=>{if(!g.current?.view)return;const k=g.current.view,A=k.state.doc.toString();k.dispatch({changes:{from:0,to:A.length,insert:n},annotations:Vt.addToHistory.of(!1)}),d(n)},[u]),Y.useEffect(()=>{if(!g.current?.view)return;const k=g.current.view,A=k.state.doc.toString();if(v.current&&n){k.dispatch({changes:{from:0,to:A.length,insert:n},annotations:Vt.addToHistory.of(!1)}),d(n),v.current=!1;return}l!=="user"&&A!==n&&(k.dispatch({changes:{from:0,to:A.length,insert:n},userEvent:"remote-edit"}),d(n))},[n,l]);const x=Y.useCallback(k=>{d(k),!(!k||k.trim()==="")&&(m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{i(k),r(k)},300))},[i,r]),w=()=>{g.current?.view&&uC(g.current.view)},C=()=>{g.current?.view&&Fd(g.current.view)};return S.jsxs("div",{className:"flex-1 flex flex-col gap-3 overflow-hidden p-4 pt-2 h-full sidebar-content",children:[S.jsxs("div",{className:"flex items-center justify-between px-1",children:[e?S.jsxs("div",{className:"flex items-center gap-4",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-blue-500 animate-pulse"}),S.jsx("span",{className:`text-[10px] font-bold uppercase tracking-widest ${c==="dark"?"text-slate-500":"text-slate-400"}`,children:"Auto-sync active"})]}),S.jsxs("div",{className:"flex items-center gap-1.5 min-w-[60px]",children:[s==="saving"&&S.jsxs("div",{className:"flex items-center gap-1 text-slate-400 animate-pulse",children:[S.jsx(EW,{size:10,className:"animate-spin"}),S.jsx("span",{className:"text-[9px] font-bold uppercase",children:"Saving"})]}),s==="saved"&&S.jsxs("div",{className:"flex items-center gap-1 text-emerald-500",children:[S.jsx(cW,{size:10}),S.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider",children:"Saved"})]}),s==="error"&&S.jsxs("div",{className:"flex items-center gap-1 text-red-500",children:[S.jsx(td,{size:10}),S.jsx("span",{className:"text-[9px] font-bold uppercase",children:"Error"})]})]})]}):S.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 bg-blue-500/10 border border-blue-500/30 rounded-md",children:[S.jsx(td,{size:12,className:"text-blue-400"}),S.jsx("span",{className:"text-[10px] text-blue-300 font-medium uppercase tracking-tight",children:"Sandbox Mode"})]}),S.jsxs("div",{className:"flex items-center gap-3",children:[S.jsxs("div",{className:`flex rounded-lg p-0.5 border ${c==="dark"?"bg-slate-800/50 border-slate-700/50":"bg-slate-100 border-slate-200"}`,children:[S.jsx("button",{onClick:w,className:`p-1.5 rounded-md transition-all active:scale-95 ${c==="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:S.jsx(JW,{size:14})}),S.jsx("div",{className:`w-px h-4 self-center mx-0.5 ${c==="dark"?"bg-slate-700/50":"bg-slate-200"}`}),S.jsx("button",{onClick:C,className:`p-1.5 rounded-md transition-all active:scale-95 ${c==="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:S.jsx(VW,{size:14})})]}),S.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:[S.jsx(xW,{size:12}),S.jsx("span",{className:"text-[9px] font-bold uppercase tracking-tighter",children:"Undo Active"})]})]})]}),S.jsxs("div",{className:`relative flex-1 flex flex-col min-h-0 border rounded-md overflow-hidden transition-colors ${c==="dark"?"border-slate-700 bg-[#282c34]":"border-slate-200 bg-white"}`,children:[S.jsx(SB,{ref:g,value:h,height:"100%",theme:c==="dark"?wB:"light",extensions:[bse()],onChange:x,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0},className:"flex-1 text-sm overflow-auto"}),t&&h===n&&S.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:[S.jsx(td,{size:14,className:"shrink-0 mt-0.5 text-red-400"}),S.jsx("span",{children:t})]})]}),S.jsx("div",{className:"flex justify-between items-center pt-1 shrink-0",children:S.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."})})]})},wse=()=>{const{availableFiles:t,currentModelSlug:e,setCurrentModel:n,isSidebarOpen:i,theme:r}=en();if(!i||t.length<=0)return null;const s=e||t[0]?.slug;return S.jsxs("div",{className:"px-4 mb-4",children:[S.jsx("div",{className:"flex items-center justify-between mb-1.5 px-1",children:S.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Current Model"})}),S.jsxs("div",{className:"relative group",children:[S.jsx("select",{value:s,onChange:l=>n(l.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 ${r==="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(l=>S.jsx("option",{value:l.slug,className:r==="light"?"bg-white text-slate-900":"bg-slate-800 text-slate-100",children:l.name},l.slug))}),S.jsx(Ba,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-blue-500 pointer-events-none"}),S.jsx(qa,{size:14,className:`absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none transition-colors ${r==="dark"?"text-slate-500 group-hover:text-slate-300":"text-slate-400 group-hover:text-slate-600"}`})]})]})},MB=""+new URL("../favicon.svg",import.meta.url).href,Sse=()=>{const{isSidebarOpen:t,setIsSidebarOpen:e,isPresentationMode:n,setIsPresentationMode:i,showER:r,setShowER:s,showLineage:l,setShowLineage:c,showAnnotations:u,setShowAnnotations:h,addTable:d,addDomain:m,addAnnotation:g,calculateAutoLayout:v,theme:x,toggleTheme:w,getSelectedTable:C,getSelectedDomain:k}=en(),{screenToFlowPosition:A}=Bu(),[O,E]=Y.useState(!1),M=C(),T=k(),N=()=>{const V=A({x:window.innerWidth/2,y:window.innerHeight/2});m(V.x-300,V.y-200)},I=()=>{const V=A({x:window.innerWidth/2,y:window.innerHeight/2});d(V.x-160,V.y-125)},q=()=>{const V=M||T,D=A({x:window.innerWidth/2,y:window.innerHeight/2});u||h(!0),V?g({x:50,y:-50},V.id,M?"table":"domain"):g({x:D.x-60,y:D.y-40})},H=(V,D="text-blue-500")=>`
52
52
  flex items-center justify-center w-10 h-10 rounded-xl transition-all relative group
53
53
  ${V?`bg-blue-600/10 ${D} 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"}
54
- `,B=({text:V})=>S.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:[V,S.jsx("div",{className:"absolute top-1/2 -left-1 -translate-y-1/2 border-4 border-transparent border-r-slate-800"})]}),$=({keys:V,label:D})=>S.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-slate-100 dark:border-slate-800 last:border-0",children:[S.jsx("span",{className:"text-xs font-medium text-slate-500",children:D}),S.jsx("div",{className:"flex gap-1",children:V.map(P=>S.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:P},P))})]});return S.jsxs(S.Fragment,{children:[S.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:[S.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?S.jsx(Sz,{size:20}):S.jsx("img",{src:MB,alt:"Logo",className:"w-6 h-6 rounded-md shadow-lg"})}),S.jsxs("div",{className:"flex flex-col items-center mb-4 gap-2",children:[S.jsx("div",{className:"text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80 mb-1",children:"View"}),S.jsxs("div",{className:"flex flex-col gap-2",children:[S.jsxs("button",{onClick:()=>s(!r),className:H(r,"text-emerald-500"),children:[S.jsx(BW,{size:20}),S.jsx(B,{text:r?"Hide ER":"Show ER"})]}),S.jsxs("button",{onClick:()=>c(!l),className:H(l,"text-blue-500"),children:[S.jsx(z2,{size:20}),S.jsx(B,{text:l?"Hide Lineage":"Show Lineage"})]}),S.jsxs("button",{onClick:()=>h(!u),className:H(u,"text-amber-500"),children:[S.jsx(ko,{size:20}),S.jsx(B,{text:u?"Hide Annotations":"Show Annotations"})]})]})]}),S.jsx("div",{className:`w-8 border-t mb-4 ${x==="dark"?"border-slate-800":"border-slate-200"}`}),S.jsxs("div",{className:"flex flex-col items-center mb-4 gap-2",children:[S.jsx("div",{className:"text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80 mb-1",children:"Add"}),S.jsxs("div",{className:"flex flex-col gap-2",children:[S.jsxs("button",{onClick:N,className:H(!1,"text-blue-400"),children:[S.jsx(Az,{size:20}),S.jsx(B,{text:"Add Domain (D)"})]}),S.jsxs("button",{onClick:I,className:H(!1,"text-emerald-400"),children:[S.jsx(gW,{size:20}),S.jsx(B,{text:"Add Table (T)"})]}),S.jsxs("button",{onClick:q,className:H(!1,"text-amber-400"),children:[S.jsxs("div",{className:"relative",children:[S.jsx(ko,{size:20}),S.jsx(Fw,{size:10,className:"absolute -bottom-1 -right-1 text-amber-500 font-bold stroke-[3px]"})]}),S.jsx(B,{text:"Add Sticky Note (S)"})]})]})]}),S.jsx("div",{className:`w-8 border-t mb-6 ${x==="dark"?"border-slate-800":"border-slate-200"}`}),S.jsxs("div",{className:"mt-auto flex flex-col gap-2",children:[S.jsxs("button",{onClick:()=>i(!0),className:H(n,"text-purple-500"),children:[S.jsx(PW,{size:20}),S.jsx(B,{text:"Presentation Mode"})]}),S.jsxs("button",{onClick:()=>v(),className:H(!1),children:[S.jsx(SW,{size:20}),S.jsx(B,{text:"Auto Layout"})]}),S.jsxs("button",{onClick:()=>E(!0),className:H(O),children:[S.jsx(Cz,{size:20}),S.jsx(B,{text:"Shortcut Guide"})]}),S.jsxs("button",{onClick:w,className:H(!1),children:[x==="dark"?S.jsx(QW,{size:20}):S.jsx(zW,{size:20}),S.jsx(B,{text:x==="dark"?"Light Mode":"Dark Mode"})]})]})]}),O&&S.jsxs("div",{className:"fixed inset-0 z-[200] flex items-center justify-center p-4 animate-in fade-in duration-200",children:[S.jsx("div",{className:"absolute inset-0 bg-slate-950/40 backdrop-blur-sm",onClick:()=>E(!1)}),S.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:[S.jsxs("div",{className:"flex items-center justify-between mb-6",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("div",{className:"p-2 bg-blue-500/10 rounded-lg",children:S.jsx(hW,{size:18,className:"text-blue-500"})}),S.jsx("h2",{className:"font-bold text-base",children:"Shortcut Guide"})]}),S.jsx("button",{onClick:()=>E(!1),className:"p-1 hover:bg-slate-100 dark:hover:bg-slate-800 rounded-full transition-colors text-slate-400",children:S.jsx(Vu,{size:20})})]}),S.jsxs("div",{className:"space-y-6",children:[S.jsxs("section",{children:[S.jsx("h3",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-3",children:"Quick Create"}),S.jsx($,{label:"New Table",keys:["T"]}),S.jsx($,{label:"New Domain",keys:["D"]}),S.jsx($,{label:"New Sticky Note",keys:["S"]})]}),S.jsxs("section",{children:[S.jsx("h3",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-3",children:"Canvas Control"}),S.jsx($,{label:"Pan / Scroll",keys:["↑","↓","←","→"]}),S.jsx($,{label:"Clear Selection",keys:["Esc"]}),S.jsx($,{label:"Delete Selected",keys:["Del","⌫"]})]}),S.jsxs("section",{children:[S.jsx("h3",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-3",children:"Navigation"}),S.jsx($,{label:"Find Entities",keys:["/"]}),S.jsx($,{label:"Exit Fullscreen",keys:["Esc"]})]})]}),S.jsx("div",{className:"mt-8 pt-4 border-t border-slate-100 dark:border-slate-800 flex justify-center",children:S.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"Pro-tip: Focus the canvas to use shortcuts."})})]})]})]})},Cse=()=>{const{isSidebarOpen:t,isCliMode:e,theme:n,savingStatus:i}=en();return S.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"} ${n==="dark"?"bg-slate-900 border-slate-800":"bg-white border-slate-200"}`,children:[S.jsxs("div",{className:`flex-1 flex flex-col min-w-0 overflow-hidden transition-all duration-300 sidebar-content ${n==="dark"?"bg-slate-900":"bg-white"} ${t?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"}`,style:{width:t?"400px":"0px"},children:[S.jsxs("div",{className:`p-4 border-b flex items-center justify-between ${n==="dark"?"border-slate-800":"border-slate-100"}`,children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("img",{src:MB,alt:"Modscape Logo",className:"w-5 h-5 rounded-md"}),S.jsx("h1",{className:`text-base font-bold tracking-tight ${n==="dark"?"text-white":"text-slate-900"}`,children:"Modscape"}),e&&S.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"})]}),i==="saving"&&S.jsx("span",{className:"text-[10px] text-slate-500 animate-pulse uppercase font-bold tracking-widest",children:"Saving..."})]}),S.jsx("div",{className:"mt-4",children:S.jsx(wse,{})}),S.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden mt-4",children:[S.jsx("div",{className:"px-4 py-2",children:S.jsx("h3",{className:"text-[10px] font-bold uppercase tracking-widest text-slate-500",children:"YAML Editor"})}),S.jsx(xse,{})]}),S.jsx("div",{className:`p-3 border-t flex items-center justify-between ${n==="dark"?"border-slate-800 bg-slate-950/20":"border-slate-100 bg-slate-50/50"}`,children:S.jsx("p",{className:"text-[10px] text-slate-500 font-medium px-1",children:"Modscape v1.1.5"})})]}),S.jsx(Sse,{})]})},kse=()=>{const{schema:t,theme:e,setSelectedTableId:n,setFocusNodeId:i}=en(),[r,s]=Y.useState(""),[l,c]=Y.useState(new Set),u=m=>{const g=new Set(l);g.has(m)?g.delete(m):g.add(m),c(g)},h=m=>{n(m),i(m)},d=Y.useMemo(()=>{if(!t)return{domains:[],unassigned:[]};const m={},g=new Set;t.domains?.forEach(w=>{m[w.id]=[]}),t.tables.forEach(w=>{const C=t.domains?.find(A=>A.tables.includes(w.id));(w.name.toLowerCase().includes(r.toLowerCase())||w.id.toLowerCase().includes(r.toLowerCase()))&&C&&(m[C.id].push(w),g.add(w.id))});const v=(t.domains||[]).filter(w=>{const C=m[w.id].length>0,k=w.name.toLowerCase().includes(r.toLowerCase())||w.id.toLowerCase().includes(r.toLowerCase());return C||k&&r!==""}).map(w=>({...w,tables:m[w.id]})),x=t.tables.filter(w=>(w.name.toLowerCase().includes(r.toLowerCase())||w.id.toLowerCase().includes(r.toLowerCase()))&&!g.has(w.id)&&!t.domains?.some(k=>k.tables.includes(w.id)));return{domains:v,unassigned:x}},[t,r]);return S.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[S.jsxs("div",{className:"relative mb-4 shrink-0",children:[S.jsx(q2,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),S.jsx("input",{type:"text",value:r,onChange:m=>s(m.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"}`})]}),S.jsxs("div",{className:"flex-1 space-y-4 overflow-auto pr-1",children:[d.domains.map(m=>{const g=l.has(m.id);return S.jsxs("section",{className:"flex flex-col",children:[S.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:()=>u(m.id),children:[S.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[g?S.jsx(Vw,{size:12,className:"text-slate-500"}):S.jsx(qa,{size:12,className:"text-slate-500"}),S.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:m.color||"#3b82f6"}}),S.jsx("h3",{className:`text-[10px] font-bold uppercase tracking-wider truncate ${e==="dark"?"text-slate-300":"text-slate-600"}`,children:m.name}),S.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.tables.length})]}),S.jsx("button",{onClick:v=>{v.stopPropagation(),h(m.id)},className:"opacity-0 group-hover:opacity-100 p-1 hover:text-blue-500 text-slate-500 transition-all",children:S.jsx(ed,{size:12})})]}),!g&&S.jsxs("div",{className:`ml-4 mt-1 space-y-0.5 border-l pl-2 ${e==="dark"?"border-slate-800":"border-slate-100"}`,children:[m.tables.map(v=>S.jsxs("button",{onClick:()=>h(v.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:[S.jsx("span",{className:"truncate",children:v.name}),S.jsx(ed,{size:10,className:"opacity-0 group-hover:opacity-100"})]},v.id)),m.tables.length===0&&S.jsx("div",{className:"p-2 text-[10px] text-slate-500 italic",children:"No tables"})]})]},m.id)}),d.unassigned.length>0&&S.jsxs("section",{className:"flex flex-col",children:[S.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:()=>u("unassigned"),children:S.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[l.has("unassigned")?S.jsx(Vw,{size:12,className:"text-slate-500"}):S.jsx(qa,{size:12,className:"text-slate-500"}),S.jsx(Cz,{size:12,className:"text-slate-500 shrink-0"}),S.jsx("h3",{className:`text-[10px] font-bold uppercase tracking-wider truncate ${e==="dark"?"text-slate-500":"text-slate-400"}`,children:"Unassigned"}),S.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:d.unassigned.length})]})}),!l.has("unassigned")&&S.jsx("div",{className:`ml-4 mt-1 space-y-0.5 border-l pl-2 ${e==="dark"?"border-slate-800":"border-slate-100"}`,children:d.unassigned.map(m=>S.jsxs("button",{onClick:()=>h(m.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:[S.jsx("span",{className:"truncate",children:m.name}),S.jsx(ed,{size:10,className:"opacity-0 group-hover:opacity-100"})]},m.id))})]})]})]})},Ase=t=>{const e={},n=(i,r,s,l,c)=>{e[i]||(e[i]=[]),e[i].push({from:i,to:r,type:s,id:l,metadata:c}),e[r]||(e[r]=[]),e[r].push({from:r,to:i,type:s,id:l,metadata:c})};return t.relationships?.forEach((i,r)=>{n(i.from.table,i.to.table,"er",`e-${r}`,i)}),t.tables.forEach(i=>{i.lineage?.upstream&&i.lineage.upstream.forEach((r,s)=>{n(r,i.id,"lineage",`lin-${r}-${i.id}-${s}`,{direction:"upstream"})})}),e},_se=(t,e,n)=>{if(e===n)return[];const i=Ase(t),r=[e],s=new Set([e]),l={};for(;r.length>0;){const c=r.shift();if(c===n){const h=[];let d=n;for(;d!==e;){const m=l[d];h.unshift(m),d=m.from}return h}const u=i[c]||[];for(const h of u)s.has(h.to)||(s.add(h.to),l[h.to]={from:c,to:h.to,edge:h},r.push(h.to))}return null},Ose=()=>{const{schema:t,theme:e,setPathFinderResult:n,setFocusNodeId:i}=en(),[r,s]=Y.useState(""),[l,c]=Y.useState(""),[u,h]=Y.useState(null),[d,m]=Y.useState(!1),g=Y.useMemo(()=>t?.tables||[],[t]),v=()=>{if(!t||!r||!l)return;const w=_se(t,r,l);if(h(w),m(!0),w){const C=Array.from(new Set([r,...w.map(A=>A.to)])),k=w.map(A=>A.edge.id);n({nodeIds:C,edgeIds:k})}else n(null)},x=()=>{h(null),m(!1),n(null)};return S.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[S.jsxs("div",{className:"space-y-4 mb-6",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-widest block mb-1.5",children:"From Table"}),S.jsxs("select",{value:r,onChange:w=>s(w.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:[S.jsx("option",{value:"",children:"Select source..."}),g.map(w=>S.jsx("option",{value:w.id,children:w.name},w.id))]})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-widest block mb-1.5",children:"To Table"}),S.jsxs("select",{value:l,onChange:w=>c(w.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:[S.jsx("option",{value:"",children:"Select target..."}),g.map(w=>S.jsx("option",{value:w.id,children:w.name},w.id))]})]}),S.jsxs("div",{className:"flex gap-2 pt-2",children:[S.jsxs("button",{onClick:v,disabled:!r||!l,className:`flex-1 flex items-center justify-center gap-2 py-2 rounded-md text-xs font-bold transition-all ${!r||!l?"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:[S.jsx(q2,{size:14}),"FIND PATH"]}),d&&S.jsx("button",{onClick:x,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:S.jsx(Vu,{size:14})})]})]}),S.jsxs("div",{className:"flex-1 overflow-auto pr-1",children:[d&&!u&&S.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center",children:[S.jsx(td,{size:32,className:"text-slate-300 mb-2"}),S.jsx("p",{className:"text-sm text-slate-500 italic",children:"No path found between these tables."})]}),u&&S.jsxs("div",{className:"space-y-1",children:[S.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:S.jsxs("p",{className:"text-xs font-medium text-slate-500",children:["Path found with ",S.jsx("span",{className:"font-bold text-blue-500",children:u.length})," steps"]})}),S.jsxs("div",{className:"relative pl-4 space-y-0",children:[S.jsx("div",{className:"absolute left-1 top-2 bottom-2 w-0.5 bg-slate-200 dark:bg-slate-800"}),S.jsxs("div",{className:"relative mb-4",children:[S.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"}),S.jsx("button",{onClick:()=>i(r),className:"text-xs font-bold hover:text-blue-500 transition-colors",children:g.find(w=>w.id===r)?.name})]}),u.map((w,C)=>S.jsxs("div",{className:"mb-4",children:[S.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":w.edge.type==="er"?"bg-emerald-50 border-emerald-100 text-emerald-700":"bg-blue-50 border-blue-100 text-blue-700"}`,children:[w.edge.type==="er"?S.jsx(Ba,{size:10,className:e==="dark"?"text-emerald-500":"text-emerald-600"}):S.jsx(z2,{size:10,className:e==="dark"?"text-blue-400":"text-blue-600"}),S.jsx("span",{className:"text-[9px] font-bold uppercase tracking-tighter",children:w.edge.type==="er"?`ER (${w.edge.metadata.type})`:"Lineage"})]}),S.jsxs("div",{className:"relative",children:[S.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"}),S.jsx("button",{onClick:()=>i(w.to),className:"text-xs font-bold hover:text-blue-500 transition-colors",children:g.find(k=>k.id===w.to)?.name})]})]},C))]})]})]})]})},Ese=()=>{const{schema:t,theme:e,setSelectedAnnotationId:n,setFocusNodeId:i}=en(),[r,s]=Y.useState(""),l=Y.useMemo(()=>t?.annotations?t.annotations.filter(u=>u.text.toLowerCase().includes(r.toLowerCase())):[],[t,r]),c=u=>{n(u),i(u)};return S.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[S.jsxs("div",{className:"relative mb-4 shrink-0",children:[S.jsx(q2,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),S.jsx("input",{type:"text",value:r,onChange:u=>s(u.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"}`})]}),S.jsxs("div",{className:"flex-1 space-y-2 overflow-auto pr-1",children:[l.length===0&&r&&S.jsxs("div",{className:"text-center py-10 text-slate-500 italic text-sm",children:['No notes matching "',r,'"']}),l.map(u=>S.jsxs("button",{onClick:()=>c(u.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:[S.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[S.jsx(ko,{size:12,className:u.type==="callout"?"text-blue-400":"text-amber-400"}),S.jsx("span",{className:"text-[10px] font-bold uppercase tracking-tighter text-slate-500",children:u.type==="callout"?"Callout":"Sticky Note"}),S.jsx(ed,{size:12,className:"ml-auto opacity-0 group-hover:opacity-100 transition-opacity text-blue-500"})]}),S.jsx("p",{className:`text-xs line-clamp-3 leading-relaxed ${e==="dark"?"text-slate-300":"text-slate-600"}`,children:u.text}),u.targetId&&S.jsxs("div",{className:"mt-2 flex items-center gap-1.5 opacity-60",children:[S.jsx("div",{className:"w-1 h-1 rounded-full bg-slate-400"}),S.jsxs("span",{className:"text-[9px] font-medium truncate italic",children:["Attached to ",u.targetId]})]})]},u.id)),!r&&l.length===0&&S.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center opacity-40",children:[S.jsx(kz,{size:48,className:"mb-4 text-slate-400"}),S.jsx("p",{className:"text-sm font-medium",children:"No annotations in this model yet."})]})]})]})},Tse=()=>{const{isRightPanelOpen:t,setIsRightPanelOpen:e,activeRightPanelTab:n,setActiveRightPanelTab:i,theme:r}=en(),s=c=>`
54
+ `,B=({text:V})=>S.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:[V,S.jsx("div",{className:"absolute top-1/2 -left-1 -translate-y-1/2 border-4 border-transparent border-r-slate-800"})]}),$=({keys:V,label:D})=>S.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-slate-100 dark:border-slate-800 last:border-0",children:[S.jsx("span",{className:"text-xs font-medium text-slate-500",children:D}),S.jsx("div",{className:"flex gap-1",children:V.map(P=>S.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:P},P))})]});return S.jsxs(S.Fragment,{children:[S.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:[S.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?S.jsx(Sz,{size:20}):S.jsx("img",{src:MB,alt:"Logo",className:"w-6 h-6 rounded-md shadow-lg"})}),S.jsxs("div",{className:"flex flex-col items-center mb-4 gap-2",children:[S.jsx("div",{className:"text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80 mb-1",children:"View"}),S.jsxs("div",{className:"flex flex-col gap-2",children:[S.jsxs("button",{onClick:()=>s(!r),className:H(r,"text-emerald-500"),children:[S.jsx(BW,{size:20}),S.jsx(B,{text:r?"Hide ER":"Show ER"})]}),S.jsxs("button",{onClick:()=>c(!l),className:H(l,"text-blue-500"),children:[S.jsx(z2,{size:20}),S.jsx(B,{text:l?"Hide Lineage":"Show Lineage"})]}),S.jsxs("button",{onClick:()=>h(!u),className:H(u,"text-amber-500"),children:[S.jsx(ko,{size:20}),S.jsx(B,{text:u?"Hide Annotations":"Show Annotations"})]})]})]}),S.jsx("div",{className:`w-8 border-t mb-4 ${x==="dark"?"border-slate-800":"border-slate-200"}`}),S.jsxs("div",{className:"flex flex-col items-center mb-4 gap-2",children:[S.jsx("div",{className:"text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80 mb-1",children:"Add"}),S.jsxs("div",{className:"flex flex-col gap-2",children:[S.jsxs("button",{onClick:N,className:H(!1,"text-blue-400"),children:[S.jsx(Az,{size:20}),S.jsx(B,{text:"Add Domain (D)"})]}),S.jsxs("button",{onClick:I,className:H(!1,"text-emerald-400"),children:[S.jsx(gW,{size:20}),S.jsx(B,{text:"Add Table (T)"})]}),S.jsxs("button",{onClick:q,className:H(!1,"text-amber-400"),children:[S.jsxs("div",{className:"relative",children:[S.jsx(ko,{size:20}),S.jsx(Fw,{size:10,className:"absolute -bottom-1 -right-1 text-amber-500 font-bold stroke-[3px]"})]}),S.jsx(B,{text:"Add Sticky Note (S)"})]})]})]}),S.jsx("div",{className:`w-8 border-t mb-6 ${x==="dark"?"border-slate-800":"border-slate-200"}`}),S.jsxs("div",{className:"mt-auto flex flex-col gap-2",children:[S.jsxs("button",{onClick:()=>i(!0),className:H(n,"text-purple-500"),children:[S.jsx(PW,{size:20}),S.jsx(B,{text:"Presentation Mode"})]}),S.jsxs("button",{onClick:()=>v(),className:H(!1),children:[S.jsx(SW,{size:20}),S.jsx(B,{text:"Auto Layout"})]}),S.jsxs("button",{onClick:()=>E(!0),className:H(O),children:[S.jsx(Cz,{size:20}),S.jsx(B,{text:"Shortcut Guide"})]}),S.jsxs("button",{onClick:w,className:H(!1),children:[x==="dark"?S.jsx(QW,{size:20}):S.jsx(zW,{size:20}),S.jsx(B,{text:x==="dark"?"Light Mode":"Dark Mode"})]})]})]}),O&&S.jsxs("div",{className:"fixed inset-0 z-[200] flex items-center justify-center p-4 animate-in fade-in duration-200",children:[S.jsx("div",{className:"absolute inset-0 bg-slate-950/40 backdrop-blur-sm",onClick:()=>E(!1)}),S.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:[S.jsxs("div",{className:"flex items-center justify-between mb-6",children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("div",{className:"p-2 bg-blue-500/10 rounded-lg",children:S.jsx(hW,{size:18,className:"text-blue-500"})}),S.jsx("h2",{className:"font-bold text-base",children:"Shortcut Guide"})]}),S.jsx("button",{onClick:()=>E(!1),className:"p-1 hover:bg-slate-100 dark:hover:bg-slate-800 rounded-full transition-colors text-slate-400",children:S.jsx(Vu,{size:20})})]}),S.jsxs("div",{className:"space-y-6",children:[S.jsxs("section",{children:[S.jsx("h3",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-3",children:"Quick Create"}),S.jsx($,{label:"New Table",keys:["T"]}),S.jsx($,{label:"New Domain",keys:["D"]}),S.jsx($,{label:"New Sticky Note",keys:["S"]})]}),S.jsxs("section",{children:[S.jsx("h3",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-3",children:"Canvas Control"}),S.jsx($,{label:"Pan / Scroll",keys:["↑","↓","←","→"]}),S.jsx($,{label:"Clear Selection",keys:["Esc"]}),S.jsx($,{label:"Delete Selected",keys:["Del","⌫"]})]}),S.jsxs("section",{children:[S.jsx("h3",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-3",children:"Navigation"}),S.jsx($,{label:"Find Entities",keys:["/"]}),S.jsx($,{label:"Exit Fullscreen",keys:["Esc"]})]})]}),S.jsx("div",{className:"mt-8 pt-4 border-t border-slate-100 dark:border-slate-800 flex justify-center",children:S.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"Pro-tip: Focus the canvas to use shortcuts."})})]})]})]})},Cse=()=>{const{isSidebarOpen:t,isCliMode:e,theme:n,savingStatus:i}=en();return S.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"} ${n==="dark"?"bg-slate-900 border-slate-800":"bg-white border-slate-200"}`,children:[S.jsxs("div",{className:`flex-1 flex flex-col min-w-0 overflow-hidden transition-all duration-300 sidebar-content ${n==="dark"?"bg-slate-900":"bg-white"} ${t?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"}`,style:{width:t?"400px":"0px"},children:[S.jsxs("div",{className:`p-4 border-b flex items-center justify-between ${n==="dark"?"border-slate-800":"border-slate-100"}`,children:[S.jsxs("div",{className:"flex items-center gap-2",children:[S.jsx("img",{src:MB,alt:"Modscape Logo",className:"w-5 h-5 rounded-md"}),S.jsx("h1",{className:`text-base font-bold tracking-tight ${n==="dark"?"text-white":"text-slate-900"}`,children:"Modscape"}),e&&S.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"})]}),i==="saving"&&S.jsx("span",{className:"text-[10px] text-slate-500 animate-pulse uppercase font-bold tracking-widest",children:"Saving..."})]}),S.jsx("div",{className:"mt-4",children:S.jsx(wse,{})}),S.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden mt-4",children:[S.jsx("div",{className:"px-4 py-2",children:S.jsx("h3",{className:"text-[10px] font-bold uppercase tracking-widest text-slate-500",children:"YAML Editor"})}),S.jsx(xse,{})]}),S.jsx("div",{className:`p-3 border-t flex items-center justify-between ${n==="dark"?"border-slate-800 bg-slate-950/20":"border-slate-100 bg-slate-50/50"}`,children:S.jsx("p",{className:"text-[10px] text-slate-500 font-medium px-1",children:"Modscape v1.1.6"})})]}),S.jsx(Sse,{})]})},kse=()=>{const{schema:t,theme:e,setSelectedTableId:n,setFocusNodeId:i}=en(),[r,s]=Y.useState(""),[l,c]=Y.useState(new Set),u=m=>{const g=new Set(l);g.has(m)?g.delete(m):g.add(m),c(g)},h=m=>{n(m),i(m)},d=Y.useMemo(()=>{if(!t)return{domains:[],unassigned:[]};const m={},g=new Set;t.domains?.forEach(w=>{m[w.id]=[]}),t.tables.forEach(w=>{const C=t.domains?.find(A=>A.tables.includes(w.id));(w.name.toLowerCase().includes(r.toLowerCase())||w.id.toLowerCase().includes(r.toLowerCase()))&&C&&(m[C.id].push(w),g.add(w.id))});const v=(t.domains||[]).filter(w=>{const C=m[w.id].length>0,k=w.name.toLowerCase().includes(r.toLowerCase())||w.id.toLowerCase().includes(r.toLowerCase());return C||k&&r!==""}).map(w=>({...w,tables:m[w.id]})),x=t.tables.filter(w=>(w.name.toLowerCase().includes(r.toLowerCase())||w.id.toLowerCase().includes(r.toLowerCase()))&&!g.has(w.id)&&!t.domains?.some(k=>k.tables.includes(w.id)));return{domains:v,unassigned:x}},[t,r]);return S.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[S.jsxs("div",{className:"relative mb-4 shrink-0",children:[S.jsx(q2,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),S.jsx("input",{type:"text",value:r,onChange:m=>s(m.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"}`})]}),S.jsxs("div",{className:"flex-1 space-y-4 overflow-auto pr-1",children:[d.domains.map(m=>{const g=l.has(m.id);return S.jsxs("section",{className:"flex flex-col",children:[S.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:()=>u(m.id),children:[S.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[g?S.jsx(Vw,{size:12,className:"text-slate-500"}):S.jsx(qa,{size:12,className:"text-slate-500"}),S.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:m.color||"#3b82f6"}}),S.jsx("h3",{className:`text-[10px] font-bold uppercase tracking-wider truncate ${e==="dark"?"text-slate-300":"text-slate-600"}`,children:m.name}),S.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.tables.length})]}),S.jsx("button",{onClick:v=>{v.stopPropagation(),h(m.id)},className:"opacity-0 group-hover:opacity-100 p-1 hover:text-blue-500 text-slate-500 transition-all",children:S.jsx(ed,{size:12})})]}),!g&&S.jsxs("div",{className:`ml-4 mt-1 space-y-0.5 border-l pl-2 ${e==="dark"?"border-slate-800":"border-slate-100"}`,children:[m.tables.map(v=>S.jsxs("button",{onClick:()=>h(v.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:[S.jsx("span",{className:"truncate",children:v.name}),S.jsx(ed,{size:10,className:"opacity-0 group-hover:opacity-100"})]},v.id)),m.tables.length===0&&S.jsx("div",{className:"p-2 text-[10px] text-slate-500 italic",children:"No tables"})]})]},m.id)}),d.unassigned.length>0&&S.jsxs("section",{className:"flex flex-col",children:[S.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:()=>u("unassigned"),children:S.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[l.has("unassigned")?S.jsx(Vw,{size:12,className:"text-slate-500"}):S.jsx(qa,{size:12,className:"text-slate-500"}),S.jsx(Cz,{size:12,className:"text-slate-500 shrink-0"}),S.jsx("h3",{className:`text-[10px] font-bold uppercase tracking-wider truncate ${e==="dark"?"text-slate-500":"text-slate-400"}`,children:"Unassigned"}),S.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:d.unassigned.length})]})}),!l.has("unassigned")&&S.jsx("div",{className:`ml-4 mt-1 space-y-0.5 border-l pl-2 ${e==="dark"?"border-slate-800":"border-slate-100"}`,children:d.unassigned.map(m=>S.jsxs("button",{onClick:()=>h(m.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:[S.jsx("span",{className:"truncate",children:m.name}),S.jsx(ed,{size:10,className:"opacity-0 group-hover:opacity-100"})]},m.id))})]})]})]})},Ase=t=>{const e={},n=(i,r,s,l,c)=>{e[i]||(e[i]=[]),e[i].push({from:i,to:r,type:s,id:l,metadata:c}),e[r]||(e[r]=[]),e[r].push({from:r,to:i,type:s,id:l,metadata:c})};return t.relationships?.forEach((i,r)=>{n(i.from.table,i.to.table,"er",`e-${r}`,i)}),t.tables.forEach(i=>{i.lineage?.upstream&&i.lineage.upstream.forEach((r,s)=>{n(r,i.id,"lineage",`lin-${r}-${i.id}-${s}`,{direction:"upstream"})})}),e},_se=(t,e,n)=>{if(e===n)return[];const i=Ase(t),r=[e],s=new Set([e]),l={};for(;r.length>0;){const c=r.shift();if(c===n){const h=[];let d=n;for(;d!==e;){const m=l[d];h.unshift(m),d=m.from}return h}const u=i[c]||[];for(const h of u)s.has(h.to)||(s.add(h.to),l[h.to]={from:c,to:h.to,edge:h},r.push(h.to))}return null},Ose=()=>{const{schema:t,theme:e,setPathFinderResult:n,setFocusNodeId:i}=en(),[r,s]=Y.useState(""),[l,c]=Y.useState(""),[u,h]=Y.useState(null),[d,m]=Y.useState(!1),g=Y.useMemo(()=>t?.tables||[],[t]),v=()=>{if(!t||!r||!l)return;const w=_se(t,r,l);if(h(w),m(!0),w){const C=Array.from(new Set([r,...w.map(A=>A.to)])),k=w.map(A=>A.edge.id);n({nodeIds:C,edgeIds:k})}else n(null)},x=()=>{h(null),m(!1),n(null)};return S.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[S.jsxs("div",{className:"space-y-4 mb-6",children:[S.jsxs("div",{children:[S.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-widest block mb-1.5",children:"From Table"}),S.jsxs("select",{value:r,onChange:w=>s(w.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:[S.jsx("option",{value:"",children:"Select source..."}),g.map(w=>S.jsx("option",{value:w.id,children:w.name},w.id))]})]}),S.jsxs("div",{children:[S.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-widest block mb-1.5",children:"To Table"}),S.jsxs("select",{value:l,onChange:w=>c(w.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:[S.jsx("option",{value:"",children:"Select target..."}),g.map(w=>S.jsx("option",{value:w.id,children:w.name},w.id))]})]}),S.jsxs("div",{className:"flex gap-2 pt-2",children:[S.jsxs("button",{onClick:v,disabled:!r||!l,className:`flex-1 flex items-center justify-center gap-2 py-2 rounded-md text-xs font-bold transition-all ${!r||!l?"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:[S.jsx(q2,{size:14}),"FIND PATH"]}),d&&S.jsx("button",{onClick:x,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:S.jsx(Vu,{size:14})})]})]}),S.jsxs("div",{className:"flex-1 overflow-auto pr-1",children:[d&&!u&&S.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center",children:[S.jsx(td,{size:32,className:"text-slate-300 mb-2"}),S.jsx("p",{className:"text-sm text-slate-500 italic",children:"No path found between these tables."})]}),u&&S.jsxs("div",{className:"space-y-1",children:[S.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:S.jsxs("p",{className:"text-xs font-medium text-slate-500",children:["Path found with ",S.jsx("span",{className:"font-bold text-blue-500",children:u.length})," steps"]})}),S.jsxs("div",{className:"relative pl-4 space-y-0",children:[S.jsx("div",{className:"absolute left-1 top-2 bottom-2 w-0.5 bg-slate-200 dark:bg-slate-800"}),S.jsxs("div",{className:"relative mb-4",children:[S.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"}),S.jsx("button",{onClick:()=>i(r),className:"text-xs font-bold hover:text-blue-500 transition-colors",children:g.find(w=>w.id===r)?.name})]}),u.map((w,C)=>S.jsxs("div",{className:"mb-4",children:[S.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":w.edge.type==="er"?"bg-emerald-50 border-emerald-100 text-emerald-700":"bg-blue-50 border-blue-100 text-blue-700"}`,children:[w.edge.type==="er"?S.jsx(Ba,{size:10,className:e==="dark"?"text-emerald-500":"text-emerald-600"}):S.jsx(z2,{size:10,className:e==="dark"?"text-blue-400":"text-blue-600"}),S.jsx("span",{className:"text-[9px] font-bold uppercase tracking-tighter",children:w.edge.type==="er"?`ER (${w.edge.metadata.type})`:"Lineage"})]}),S.jsxs("div",{className:"relative",children:[S.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"}),S.jsx("button",{onClick:()=>i(w.to),className:"text-xs font-bold hover:text-blue-500 transition-colors",children:g.find(k=>k.id===w.to)?.name})]})]},C))]})]})]})]})},Ese=()=>{const{schema:t,theme:e,setSelectedAnnotationId:n,setFocusNodeId:i}=en(),[r,s]=Y.useState(""),l=Y.useMemo(()=>t?.annotations?t.annotations.filter(u=>u.text.toLowerCase().includes(r.toLowerCase())):[],[t,r]),c=u=>{n(u),i(u)};return S.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[S.jsxs("div",{className:"relative mb-4 shrink-0",children:[S.jsx(q2,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),S.jsx("input",{type:"text",value:r,onChange:u=>s(u.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"}`})]}),S.jsxs("div",{className:"flex-1 space-y-2 overflow-auto pr-1",children:[l.length===0&&r&&S.jsxs("div",{className:"text-center py-10 text-slate-500 italic text-sm",children:['No notes matching "',r,'"']}),l.map(u=>S.jsxs("button",{onClick:()=>c(u.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:[S.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[S.jsx(ko,{size:12,className:u.type==="callout"?"text-blue-400":"text-amber-400"}),S.jsx("span",{className:"text-[10px] font-bold uppercase tracking-tighter text-slate-500",children:u.type==="callout"?"Callout":"Sticky Note"}),S.jsx(ed,{size:12,className:"ml-auto opacity-0 group-hover:opacity-100 transition-opacity text-blue-500"})]}),S.jsx("p",{className:`text-xs line-clamp-3 leading-relaxed ${e==="dark"?"text-slate-300":"text-slate-600"}`,children:u.text}),u.targetId&&S.jsxs("div",{className:"mt-2 flex items-center gap-1.5 opacity-60",children:[S.jsx("div",{className:"w-1 h-1 rounded-full bg-slate-400"}),S.jsxs("span",{className:"text-[9px] font-medium truncate italic",children:["Attached to ",u.targetId]})]})]},u.id)),!r&&l.length===0&&S.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center opacity-40",children:[S.jsx(kz,{size:48,className:"mb-4 text-slate-400"}),S.jsx("p",{className:"text-sm font-medium",children:"No annotations in this model yet."})]})]})]})},Tse=()=>{const{isRightPanelOpen:t,setIsRightPanelOpen:e,activeRightPanelTab:n,setActiveRightPanelTab:i,theme:r}=en(),s=c=>`
55
55
  flex items-center justify-center w-10 h-10 rounded-xl transition-all relative group
56
56
  ${c?"bg-blue-600/10 text-blue-500 shadow-inner":r==="dark"?"text-slate-500 hover:text-slate-300 hover:bg-slate-800/30":"text-slate-400 hover:text-slate-600 hover:bg-slate-100"}
57
57
  `,l=({text:c})=>S.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:[c,S.jsx("div",{className:"absolute top-1/2 -right-1 -translate-y-1/2 border-4 border-transparent border-l-slate-800"})]});return S.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:[S.jsxs("div",{className:`w-14 h-full flex flex-col items-center py-4 border-l transition-colors z-50 ${r==="dark"?"bg-slate-950 border-slate-800":"bg-slate-50 border-slate-200"}`,children:[S.jsx("button",{onClick:()=>e(!t),className:`mb-6 p-2 rounded-xl transition-all ${r==="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?S.jsx(Vw,{size:20}):S.jsx(Sz,{size:20})}),S.jsxs("div",{className:"flex flex-col gap-2 mb-6",children:[S.jsxs("button",{onClick:()=>{i("tables"),e(!0)},className:s(n==="tables"&&t),children:[S.jsx(_W,{size:20}),S.jsx(l,{text:"Tables & Entities"})]}),S.jsxs("button",{onClick:()=>{i("path"),e(!0)},className:s(n==="path"&&t),children:[S.jsx($W,{size:20}),S.jsx(l,{text:"Path Finder"})]}),S.jsxs("button",{onClick:()=>{i("notes"),e(!0)},className:s(n==="notes"&&t),children:[S.jsx(kz,{size:20}),S.jsx(l,{text:"Note Search"})]})]})]}),S.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:[S.jsx("div",{className:`p-4 border-b flex items-center justify-between ${r==="dark"?"border-slate-800":"border-slate-100"}`,children:S.jsxs("h2",{className:`text-sm font-bold tracking-tight uppercase ${r==="dark"?"text-white":"text-slate-900"}`,children:[n==="tables"&&"Tables",n==="path"&&"Path Finder",n==="notes"&&"Note Search"]})}),n==="tables"&&S.jsx(kse,{}),n==="path"&&S.jsx(Ose,{}),n==="notes"&&S.jsx(Ese,{})]})]})};function Mse(t,e){if(t.match(/^[a-z]+:\/\//i))return t;if(t.match(/^\/\//))return window.location.protocol+t;if(t.match(/^[a-z]+:/i))return t;const n=document.implementation.createHTMLDocument(),i=n.createElement("base"),r=n.createElement("a");return n.head.appendChild(i),n.body.appendChild(r),e&&(i.href=e),r.href=t,r.href}const Nse=(()=>{let t=0;const e=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${e()}${t}`)})();function Gs(t){const e=[];for(let n=0,i=t.length;n<i;n++)e.push(t[n]);return e}let Yl=null;function NB(t={}){return Yl||(t.includeStyleProperties?(Yl=t.includeStyleProperties,Yl):(Yl=Gs(window.getComputedStyle(document.documentElement)),Yl))}function ip(t,e){const i=(t.ownerDocument.defaultView||window).getComputedStyle(t).getPropertyValue(e);return i?parseFloat(i.replace("px","")):0}function Rse(t){const e=ip(t,"border-left-width"),n=ip(t,"border-right-width");return t.clientWidth+e+n}function Dse(t){const e=ip(t,"border-top-width"),n=ip(t,"border-bottom-width");return t.clientHeight+e+n}function RB(t,e={}){const n=e.width||Rse(t),i=e.height||Dse(t);return{width:n,height:i}}function Lse(){let t,e;try{e=process}catch{}const n=e&&e.env?e.env.devicePixelRatio:null;return n&&(t=parseInt(n,10),Number.isNaN(t)&&(t=1)),t||window.devicePixelRatio||1}const di=16384;function zse(t){(t.width>di||t.height>di)&&(t.width>di&&t.height>di?t.width>t.height?(t.height*=di/t.width,t.width=di):(t.width*=di/t.height,t.height=di):t.width>di?(t.height*=di/t.width,t.width=di):(t.width*=di/t.height,t.height=di))}function rp(t){return new Promise((e,n)=>{const i=new Image;i.onload=()=>{i.decode().then(()=>{requestAnimationFrame(()=>e(i))})},i.onerror=n,i.crossOrigin="anonymous",i.decoding="async",i.src=t})}async function qse(t){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then(e=>`data:image/svg+xml;charset=utf-8,${e}`)}async function Bse(t,e,n){const i="http://www.w3.org/2000/svg",r=document.createElementNS(i,"svg"),s=document.createElementNS(i,"foreignObject");return r.setAttribute("width",`${e}`),r.setAttribute("height",`${n}`),r.setAttribute("viewBox",`0 0 ${e} ${n}`),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("externalResourcesRequired","true"),r.appendChild(s),s.appendChild(t),qse(r)}const Zn=(t,e)=>{if(t instanceof e)return!0;const n=Object.getPrototypeOf(t);return n===null?!1:n.constructor.name===e.name||Zn(n,e)};function jse(t){const e=t.getPropertyValue("content");return`${t.cssText} content: '${e.replace(/'|"/g,"")}';`}function Ise(t,e){return NB(e).map(n=>{const i=t.getPropertyValue(n),r=t.getPropertyPriority(n);return`${n}: ${i}${r?" !important":""};`}).join(" ")}function Pse(t,e,n,i){const r=`.${t}:${e}`,s=n.cssText?jse(n):Ise(n,i);return document.createTextNode(`${r}{${s}}`)}function t4(t,e,n,i){const r=window.getComputedStyle(t,n),s=r.getPropertyValue("content");if(s===""||s==="none")return;const l=Nse();try{e.className=`${e.className} ${l}`}catch{return}const c=document.createElement("style");c.appendChild(Pse(l,n,r,i)),e.appendChild(c)}function Hse(t,e,n){t4(t,e,":before",n),t4(t,e,":after",n)}const n4="application/font-woff",i4="image/jpeg",Use={woff:n4,woff2:n4,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:i4,jpeg:i4,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function Vse(t){const e=/\.([^./]*?)$/g.exec(t);return e?e[1]:""}function CC(t){const e=Vse(t).toLowerCase();return Use[e]||""}function Fse(t){return t.split(/,/)[1]}function VS(t){return t.search(/^(data:)/)!==-1}function $se(t,e){return`data:${e};base64,${t}`}async function DB(t,e,n){const i=await fetch(t,e);if(i.status===404)throw new Error(`Resource "${i.url}" not found`);const r=await i.blob();return new Promise((s,l)=>{const c=new FileReader;c.onerror=l,c.onloadend=()=>{try{s(n({res:i,result:c.result}))}catch(u){l(u)}},c.readAsDataURL(r)})}const ww={};function Gse(t,e,n){let i=t.replace(/\?.*/,"");return n&&(i=t),/ttf|otf|eot|woff2?/i.test(i)&&(i=i.replace(/.*\//,"")),e?`[${e}]${i}`:i}async function kC(t,e,n){const i=Gse(t,e,n.includeQueryParams);if(ww[i]!=null)return ww[i];n.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());let r;try{const s=await DB(t,n.fetchRequestInit,({res:l,result:c})=>(e||(e=l.headers.get("Content-Type")||""),Fse(c)));r=$se(s,e)}catch(s){r=n.imagePlaceholder||"";let l=`Failed to fetch resource: ${t}`;s&&(l=typeof s=="string"?s:s.message),l&&console.warn(l)}return ww[i]=r,r}async function Yse(t){const e=t.toDataURL();return e==="data:,"?t.cloneNode(!1):rp(e)}async function Qse(t,e){if(t.currentSrc){const s=document.createElement("canvas"),l=s.getContext("2d");s.width=t.clientWidth,s.height=t.clientHeight,l?.drawImage(t,0,0,s.width,s.height);const c=s.toDataURL();return rp(c)}const n=t.poster,i=CC(n),r=await kC(n,i,e);return rp(r)}async function Xse(t,e){var n;try{if(!((n=t?.contentDocument)===null||n===void 0)&&n.body)return await Gp(t.contentDocument.body,e,!0)}catch{}return t.cloneNode(!1)}async function Wse(t,e){return Zn(t,HTMLCanvasElement)?Yse(t):Zn(t,HTMLVideoElement)?Qse(t,e):Zn(t,HTMLIFrameElement)?Xse(t,e):t.cloneNode(LB(t))}const Kse=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SLOT",LB=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SVG";async function Zse(t,e,n){var i,r;if(LB(e))return e;let s=[];return Kse(t)&&t.assignedNodes?s=Gs(t.assignedNodes()):Zn(t,HTMLIFrameElement)&&(!((i=t.contentDocument)===null||i===void 0)&&i.body)?s=Gs(t.contentDocument.body.childNodes):s=Gs(((r=t.shadowRoot)!==null&&r!==void 0?r:t).childNodes),s.length===0||Zn(t,HTMLVideoElement)||await s.reduce((l,c)=>l.then(()=>Gp(c,n)).then(u=>{u&&e.appendChild(u)}),Promise.resolve()),e}function Jse(t,e,n){const i=e.style;if(!i)return;const r=window.getComputedStyle(t);r.cssText?(i.cssText=r.cssText,i.transformOrigin=r.transformOrigin):NB(n).forEach(s=>{let l=r.getPropertyValue(s);s==="font-size"&&l.endsWith("px")&&(l=`${Math.floor(parseFloat(l.substring(0,l.length-2)))-.1}px`),Zn(t,HTMLIFrameElement)&&s==="display"&&l==="inline"&&(l="block"),s==="d"&&e.getAttribute("d")&&(l=`path(${e.getAttribute("d")})`),i.setProperty(s,l,r.getPropertyPriority(s))})}function eae(t,e){Zn(t,HTMLTextAreaElement)&&(e.innerHTML=t.value),Zn(t,HTMLInputElement)&&e.setAttribute("value",t.value)}function tae(t,e){if(Zn(t,HTMLSelectElement)){const i=Array.from(e.children).find(r=>t.value===r.getAttribute("value"));i&&i.setAttribute("selected","")}}function nae(t,e,n){return Zn(e,Element)&&(Jse(t,e,n),Hse(t,e,n),eae(t,e),tae(t,e)),e}async function iae(t,e){const n=t.querySelectorAll?t.querySelectorAll("use"):[];if(n.length===0)return t;const i={};for(let s=0;s<n.length;s++){const c=n[s].getAttribute("xlink:href");if(c){const u=t.querySelector(c),h=document.querySelector(c);!u&&h&&!i[c]&&(i[c]=await Gp(h,e,!0))}}const r=Object.values(i);if(r.length){const s="http://www.w3.org/1999/xhtml",l=document.createElementNS(s,"svg");l.setAttribute("xmlns",s),l.style.position="absolute",l.style.width="0",l.style.height="0",l.style.overflow="hidden",l.style.display="none";const c=document.createElementNS(s,"defs");l.appendChild(c);for(let u=0;u<r.length;u++)c.appendChild(r[u]);t.appendChild(l)}return t}async function Gp(t,e,n){return!n&&e.filter&&!e.filter(t)?null:Promise.resolve(t).then(i=>Wse(i,e)).then(i=>Zse(t,i,e)).then(i=>nae(t,i,e)).then(i=>iae(i,e))}const zB=/url\((['"]?)([^'"]+?)\1\)/g,rae=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,sae=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function aae(t){const e=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`,"g")}function lae(t){const e=[];return t.replace(zB,(n,i,r)=>(e.push(r),n)),e.filter(n=>!VS(n))}async function oae(t,e,n,i,r){try{const s=n?Mse(e,n):e,l=CC(e);let c;return r||(c=await kC(s,l,i)),t.replace(aae(e),`$1${c}$3`)}catch{}return t}function cae(t,{preferredFontFormat:e}){return e?t.replace(sae,n=>{for(;;){const[i,,r]=rae.exec(n)||[];if(!r)return"";if(r===e)return`src: ${i};`}}):t}function qB(t){return t.search(zB)!==-1}async function BB(t,e,n){if(!qB(t))return t;const i=cae(t,n);return lae(i).reduce((s,l)=>s.then(c=>oae(c,l,e,n)),Promise.resolve(i))}async function Ql(t,e,n){var i;const r=(i=e.style)===null||i===void 0?void 0:i.getPropertyValue(t);if(r){const s=await BB(r,null,n);return e.style.setProperty(t,s,e.style.getPropertyPriority(t)),!0}return!1}async function uae(t,e){await Ql("background",t,e)||await Ql("background-image",t,e),await Ql("mask",t,e)||await Ql("-webkit-mask",t,e)||await Ql("mask-image",t,e)||await Ql("-webkit-mask-image",t,e)}async function fae(t,e){const n=Zn(t,HTMLImageElement);if(!(n&&!VS(t.src))&&!(Zn(t,SVGImageElement)&&!VS(t.href.baseVal)))return;const i=n?t.src:t.href.baseVal,r=await kC(i,CC(i),e);await new Promise((s,l)=>{t.onload=s,t.onerror=e.onImageErrorHandler?(...u)=>{try{s(e.onImageErrorHandler(...u))}catch(h){l(h)}}:l;const c=t;c.decode&&(c.decode=s),c.loading==="lazy"&&(c.loading="eager"),n?(t.srcset="",t.src=r):t.href.baseVal=r})}async function hae(t,e){const i=Gs(t.childNodes).map(r=>jB(r,e));await Promise.all(i).then(()=>t)}async function jB(t,e){Zn(t,Element)&&(await uae(t,e),await fae(t,e),await hae(t,e))}function dae(t,e){const{style:n}=t;e.backgroundColor&&(n.backgroundColor=e.backgroundColor),e.width&&(n.width=`${e.width}px`),e.height&&(n.height=`${e.height}px`);const i=e.style;return i!=null&&Object.keys(i).forEach(r=>{n[r]=i[r]}),t}const r4={};async function s4(t){let e=r4[t];if(e!=null)return e;const i=await(await fetch(t)).text();return e={url:t,cssText:i},r4[t]=e,e}async function a4(t,e){let n=t.cssText;const i=/url\(["']?([^"')]+)["']?\)/g,s=(n.match(/url\([^)]+\)/g)||[]).map(async l=>{let c=l.replace(i,"$1");return c.startsWith("https://")||(c=new URL(c,t.url).href),DB(c,e.fetchRequestInit,({result:u})=>(n=n.replace(l,`url(${u})`),[l,u]))});return Promise.all(s).then(()=>n)}function l4(t){if(t==null)return[];const e=[],n=/(\/\*[\s\S]*?\*\/)/gi;let i=t.replace(n,"");const r=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const u=r.exec(i);if(u===null)break;e.push(u[0])}i=i.replace(r,"");const s=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,l="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",c=new RegExp(l,"gi");for(;;){let u=s.exec(i);if(u===null){if(u=c.exec(i),u===null)break;s.lastIndex=c.lastIndex}else c.lastIndex=s.lastIndex;e.push(u[0])}return e}async function pae(t,e){const n=[],i=[];return t.forEach(r=>{if("cssRules"in r)try{Gs(r.cssRules||[]).forEach((s,l)=>{if(s.type===CSSRule.IMPORT_RULE){let c=l+1;const u=s.href,h=s4(u).then(d=>a4(d,e)).then(d=>l4(d).forEach(m=>{try{r.insertRule(m,m.startsWith("@import")?c+=1:r.cssRules.length)}catch(g){console.error("Error inserting rule from remote css",{rule:m,error:g})}})).catch(d=>{console.error("Error loading remote css",d.toString())});i.push(h)}})}catch(s){const l=t.find(c=>c.href==null)||document.styleSheets[0];r.href!=null&&i.push(s4(r.href).then(c=>a4(c,e)).then(c=>l4(c).forEach(u=>{l.insertRule(u,l.cssRules.length)})).catch(c=>{console.error("Error loading remote stylesheet",c)})),console.error("Error inlining remote css file",s)}}),Promise.all(i).then(()=>(t.forEach(r=>{if("cssRules"in r)try{Gs(r.cssRules||[]).forEach(s=>{n.push(s)})}catch(s){console.error(`Error while reading CSS rules from ${r.href}`,s)}}),n))}function mae(t){return t.filter(e=>e.type===CSSRule.FONT_FACE_RULE).filter(e=>qB(e.style.getPropertyValue("src")))}async function gae(t,e){if(t.ownerDocument==null)throw new Error("Provided element is not within a Document");const n=Gs(t.ownerDocument.styleSheets),i=await pae(n,e);return mae(i)}function IB(t){return t.trim().replace(/["']/g,"")}function yae(t){const e=new Set;function n(i){(i.style.fontFamily||getComputedStyle(i).fontFamily).split(",").forEach(s=>{e.add(IB(s))}),Array.from(i.children).forEach(s=>{s instanceof HTMLElement&&n(s)})}return n(t),e}async function vae(t,e){const n=await gae(t,e),i=yae(t);return(await Promise.all(n.filter(s=>i.has(IB(s.style.fontFamily))).map(s=>{const l=s.parentStyleSheet?s.parentStyleSheet.href:null;return BB(s.cssText,l,e)}))).join(`
@@ -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-Djua-v4W.js"></script>
8
+ <script type="module" crossorigin src="./assets/index-BwrOSMO8.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="./assets/index-BRGvsqv2.css">
10
10
  </head>
11
11
  <body>