studiograph 1.3.48-next.48 → 1.3.48-next.49
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/dist/agent/followups.d.ts +34 -0
- package/dist/agent/followups.js +52 -0
- package/dist/agent/followups.js.map +1 -0
- package/dist/agent/orchestrator.js +1 -1
- package/dist/agent/orchestrator.js.map +1 -1
- package/dist/agent/skill-loader.js +3 -1
- package/dist/agent/skill-loader.js.map +1 -1
- package/dist/agent/tools/graph-tools.js +35 -9
- package/dist/agent/tools/graph-tools.js.map +1 -1
- package/dist/agent/tools/message-tools.d.ts +2 -1
- package/dist/agent/tools/message-tools.js +8 -6
- package/dist/agent/tools/message-tools.js.map +1 -1
- package/dist/cli/commands/start.js +122 -45
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/core/graph.js +14 -4
- package/dist/core/graph.js.map +1 -1
- package/dist/mcp/tools.js +11 -11
- package/dist/mcp/tools.js.map +1 -1
- package/dist/server/chrome/chrome.js +17 -1
- package/dist/server/index.js +2 -2
- package/dist/server/index.js.map +1 -1
- package/dist/server/routes/asset-api.js +46 -34
- package/dist/server/routes/asset-api.js.map +1 -1
- package/dist/server/routes/auth-api.js +91 -2
- package/dist/server/routes/auth-api.js.map +1 -1
- package/dist/server/routes/chat.js +4 -12
- package/dist/server/routes/chat.js.map +1 -1
- package/dist/server/routes/git-http.js +10 -16
- package/dist/server/routes/git-http.js.map +1 -1
- package/dist/server/routes/graph-api.js +80 -28
- package/dist/server/routes/graph-api.js.map +1 -1
- package/dist/server/routes/insights-api.js +6 -4
- package/dist/server/routes/insights-api.js.map +1 -1
- package/dist/server/routes/meeting-ingest-api.js +14 -1
- package/dist/server/routes/meeting-ingest-api.js.map +1 -1
- package/dist/server/routes/messages-api.js +15 -13
- package/dist/server/routes/messages-api.js.map +1 -1
- package/dist/server/routes/permissions-api.d.ts +5 -4
- package/dist/server/routes/permissions-api.js +14 -14
- package/dist/server/routes/permissions-api.js.map +1 -1
- package/dist/server/routes/workspace-api.d.ts +2 -1
- package/dist/server/routes/workspace-api.js +17 -1
- package/dist/server/routes/workspace-api.js.map +1 -1
- package/dist/server/routes/ws.d.ts +2 -1
- package/dist/server/routes/ws.js +52 -9
- package/dist/server/routes/ws.js.map +1 -1
- package/dist/server/yjs-manager.js +37 -0
- package/dist/server/yjs-manager.js.map +1 -1
- package/dist/services/access-control.d.ts +7 -3
- package/dist/services/access-control.js +30 -3
- package/dist/services/access-control.js.map +1 -1
- package/dist/services/auth-service.d.ts +16 -0
- package/dist/services/auth-service.js +45 -5
- package/dist/services/auth-service.js.map +1 -1
- package/dist/services/personal-folder.d.ts +25 -0
- package/dist/services/personal-folder.js +70 -0
- package/dist/services/personal-folder.js.map +1 -1
- package/dist/web/_app/immutable/assets/0.D03EHRDg.css +1 -0
- package/dist/web/_app/immutable/assets/11.VuZ0yuu4.css +1 -0
- package/dist/web/_app/immutable/assets/12.CBEP3aNg.css +1 -0
- package/dist/web/_app/immutable/assets/2.aJMJyx3M.css +1 -0
- package/dist/web/_app/immutable/assets/3.BbA-zR0F.css +1 -0
- package/dist/web/_app/immutable/assets/{4.Bw-eH9Xv.css → 4.BsFe8Ecx.css} +1 -1
- package/dist/web/_app/immutable/assets/ChevronLeft.DJHXltBB.css +1 -0
- package/dist/web/_app/immutable/assets/StopFilledAlt.kEJgOmBk.css +1 -0
- package/dist/web/_app/immutable/assets/ViewToolbar.CV6Us0fJ.css +1 -0
- package/dist/web/_app/immutable/assets/WorkspaceView.CFKNfZSY.css +1 -0
- package/dist/web/_app/immutable/chunks/{BJVJpWzz.js → 24nU6DRU.js} +1 -1
- package/dist/web/_app/immutable/chunks/B24A6jAy.js +6 -0
- package/dist/web/_app/immutable/chunks/B8CgkcYZ.js +1 -0
- package/dist/web/_app/immutable/chunks/{Bw_Pp-Pz.js → B9qwNmSf.js} +1 -1
- package/dist/web/_app/immutable/chunks/BXIcKgYy.js +1 -0
- package/dist/web/_app/immutable/chunks/{C7PgRgxX.js → BiMb3uU3.js} +1 -1
- package/dist/web/_app/immutable/chunks/C-KRPd1f.js +1 -0
- package/dist/web/_app/immutable/chunks/{Ckiai0LF.js → C3QX_pgn.js} +2 -2
- package/dist/web/_app/immutable/chunks/C3rmQoP5.js +4 -0
- package/dist/web/_app/immutable/chunks/C6NT3aAi.js +2 -0
- package/dist/web/_app/immutable/chunks/CBFBKav7.js +1 -0
- package/dist/web/_app/immutable/chunks/CH1XwVFs.js +5 -0
- package/dist/web/_app/immutable/chunks/{BCJtO6Up.js → CKD7VXBr.js} +1 -1
- package/dist/web/_app/immutable/chunks/CLJcKDW0.js +1 -0
- package/dist/web/_app/immutable/chunks/CS21N7mS.js +2 -0
- package/dist/web/_app/immutable/chunks/CawK5k-Y.js +13 -0
- package/dist/web/_app/immutable/chunks/CbhBH-Pr.js +1 -0
- package/dist/web/_app/immutable/chunks/CdRP-PQd.js +1 -0
- package/dist/web/_app/immutable/chunks/CgtGEUwG.js +1 -0
- package/dist/web/_app/immutable/chunks/{Bz0ZjVQE.js → ChqmDGF0.js} +1 -1
- package/dist/web/_app/immutable/chunks/CjyOT5ru.js +1 -0
- package/dist/web/_app/immutable/chunks/Cm3t5Lw_.js +1 -0
- package/dist/web/_app/immutable/chunks/Cq78Q8ao.js +1 -0
- package/dist/web/_app/immutable/chunks/CqJvlJ5e.js +1 -0
- package/dist/web/_app/immutable/chunks/D-eQH68P.js +1 -0
- package/dist/web/_app/immutable/chunks/D6uxAoMD.js +1 -0
- package/dist/web/_app/immutable/chunks/{UPEqhJHW.js → D78L3NHT.js} +1 -1
- package/dist/web/_app/immutable/chunks/D8l98jpc.js +1 -0
- package/dist/web/_app/immutable/chunks/D98nKNS8.js +5 -0
- package/dist/web/_app/immutable/chunks/{oIb8yPFh.js → DBrWPzSo.js} +4 -4
- package/dist/web/_app/immutable/chunks/DHBDhuM5.js +1 -0
- package/dist/web/_app/immutable/chunks/DHZ8iEPd.js +1 -0
- package/dist/web/_app/immutable/chunks/DODkJf9W.js +1 -0
- package/dist/web/_app/immutable/chunks/DZynkbIh.js +1 -0
- package/dist/web/_app/immutable/chunks/Dc-pYwK_.js +1 -0
- package/dist/web/_app/immutable/chunks/DiVMY2ie.js +1 -0
- package/dist/web/_app/immutable/chunks/DjYhk3V-.js +1 -0
- package/dist/web/_app/immutable/chunks/Dk4o-8uR.js +1 -0
- package/dist/web/_app/immutable/chunks/QvIJHVST.js +1 -0
- package/dist/web/_app/immutable/chunks/VHoDNwgF.js +1 -0
- package/dist/web/_app/immutable/chunks/{gZfO0DkI.js → _LqPzIoq.js} +1 -1
- package/dist/web/_app/immutable/chunks/{BDtxhI5r.js → _rGNAZ2T.js} +1 -1
- package/dist/web/_app/immutable/chunks/bBh4-vdc.js +1 -0
- package/dist/web/_app/immutable/chunks/iRhbt-db.js +2 -0
- package/dist/web/_app/immutable/chunks/ouoe_5n-.js +3 -0
- package/dist/web/_app/immutable/chunks/xUpz_Ego.js +1 -0
- package/dist/web/_app/immutable/entry/app.tgSpN2zy.js +2 -0
- package/dist/web/_app/immutable/entry/start.CYDu1-na.js +1 -0
- package/dist/web/_app/immutable/nodes/0.O_BpuEVv.js +2 -0
- package/dist/web/_app/immutable/nodes/1.BCH0rc1N.js +1 -0
- package/dist/web/_app/immutable/nodes/10.BdAZrtUP.js +1 -0
- package/dist/web/_app/immutable/nodes/11.Dh4nuff7.js +1 -0
- package/dist/web/_app/immutable/nodes/12.DRrTb8yT.js +1 -0
- package/dist/web/_app/immutable/nodes/2.DhSERXR4.js +268 -0
- package/dist/web/_app/immutable/nodes/3.CEgK5MQt.js +5 -0
- package/dist/web/_app/immutable/nodes/4.BKj4xQOT.js +11 -0
- package/dist/web/_app/immutable/nodes/5.Be1XlKLD.js +1 -0
- package/dist/web/_app/immutable/nodes/6.Cen-Be5t.js +1 -0
- package/dist/web/_app/immutable/nodes/7.BiEGRqIm.js +1 -0
- package/dist/web/_app/immutable/nodes/8.Be00K7Ga.js +1 -0
- package/dist/web/_app/immutable/nodes/9.CnZz8P2s.js +1 -0
- package/dist/web/_app/version.json +1 -1
- package/dist/web/favicon.png +0 -0
- package/dist/web/index.html +12 -12
- package/package.json +1 -1
- package/dist/web/_app/immutable/assets/0.C5UfMb0y.css +0 -1
- package/dist/web/_app/immutable/assets/11.BysgAqqA.css +0 -1
- package/dist/web/_app/immutable/assets/12.Cv7_3lm3.css +0 -1
- package/dist/web/_app/immutable/assets/2.DF2alPoJ.css +0 -1
- package/dist/web/_app/immutable/assets/3.K3A_7PML.css +0 -1
- package/dist/web/_app/immutable/assets/ChevronLeft.DkKx6zzU.css +0 -1
- package/dist/web/_app/immutable/assets/ViewToolbar.SyuJrtFp.css +0 -1
- package/dist/web/_app/immutable/assets/WorkspaceView.CFCGULVf.css +0 -1
- package/dist/web/_app/immutable/chunks/B-8WiidI.js +0 -1
- package/dist/web/_app/immutable/chunks/B0UhiMeL.js +0 -1
- package/dist/web/_app/immutable/chunks/B1f42VKu.js +0 -1
- package/dist/web/_app/immutable/chunks/B584Plw_.js +0 -2
- package/dist/web/_app/immutable/chunks/B9rnDSMy.js +0 -1
- package/dist/web/_app/immutable/chunks/BK42PcDI.js +0 -1
- package/dist/web/_app/immutable/chunks/BMB60CtO.js +0 -1
- package/dist/web/_app/immutable/chunks/BQiOMhgK.js +0 -1
- package/dist/web/_app/immutable/chunks/BT1EtT-T.js +0 -4
- package/dist/web/_app/immutable/chunks/BUzEKAuP.js +0 -1
- package/dist/web/_app/immutable/chunks/BVXp0xQD.js +0 -1
- package/dist/web/_app/immutable/chunks/BaMdMBD6.js +0 -1
- package/dist/web/_app/immutable/chunks/Bjbdko8J.js +0 -1
- package/dist/web/_app/immutable/chunks/BvVwTRB5.js +0 -1
- package/dist/web/_app/immutable/chunks/CBiBLuiK.js +0 -1
- package/dist/web/_app/immutable/chunks/CH2ArZqX.js +0 -18
- package/dist/web/_app/immutable/chunks/COSWCWJc.js +0 -1
- package/dist/web/_app/immutable/chunks/CTh3LGxI.js +0 -1
- package/dist/web/_app/immutable/chunks/CVWN0my4.js +0 -5
- package/dist/web/_app/immutable/chunks/CXKVCl01.js +0 -2
- package/dist/web/_app/immutable/chunks/Ca1DAtQh.js +0 -2
- package/dist/web/_app/immutable/chunks/CcmvIPLE.js +0 -1
- package/dist/web/_app/immutable/chunks/CdbeIqEu.js +0 -1
- package/dist/web/_app/immutable/chunks/ChL9MLYT.js +0 -1
- package/dist/web/_app/immutable/chunks/CmQUXR-Q.js +0 -1
- package/dist/web/_app/immutable/chunks/D3dgfs75.js +0 -1
- package/dist/web/_app/immutable/chunks/D4zk90z_.js +0 -1
- package/dist/web/_app/immutable/chunks/DFYOFE3o.js +0 -1
- package/dist/web/_app/immutable/chunks/DGvzULxd.js +0 -2
- package/dist/web/_app/immutable/chunks/DXlELvfC.js +0 -1
- package/dist/web/_app/immutable/chunks/DckX78C-.js +0 -1
- package/dist/web/_app/immutable/chunks/Derf2KR0.js +0 -1
- package/dist/web/_app/immutable/chunks/IWO0A1w9.js +0 -1
- package/dist/web/_app/immutable/chunks/PHw7Ht7D.js +0 -1
- package/dist/web/_app/immutable/chunks/QtcHHeRi.js +0 -1
- package/dist/web/_app/immutable/chunks/_FGjjD9P.js +0 -1
- package/dist/web/_app/immutable/chunks/hXfpX92g.js +0 -1
- package/dist/web/_app/immutable/chunks/xNAOqGHi.js +0 -3
- package/dist/web/_app/immutable/entry/app.DZZk9FhL.js +0 -2
- package/dist/web/_app/immutable/entry/start.7xpU_KlK.js +0 -1
- package/dist/web/_app/immutable/nodes/0.BoP7EznM.js +0 -2
- package/dist/web/_app/immutable/nodes/1.D88C7B3J.js +0 -1
- package/dist/web/_app/immutable/nodes/10.-ZvCdP8I.js +0 -1
- package/dist/web/_app/immutable/nodes/11.BykVkP_y.js +0 -1
- package/dist/web/_app/immutable/nodes/12.D3wEsz-7.js +0 -1
- package/dist/web/_app/immutable/nodes/2.CIsXawC1.js +0 -266
- package/dist/web/_app/immutable/nodes/3.gLLCp7pi.js +0 -5
- package/dist/web/_app/immutable/nodes/4.DBRtBuw0.js +0 -11
- package/dist/web/_app/immutable/nodes/5.Cl_maDlW.js +0 -1
- package/dist/web/_app/immutable/nodes/6.BcAq3XZ9.js +0 -1
- package/dist/web/_app/immutable/nodes/7.BkUvTb7i.js +0 -1
- package/dist/web/_app/immutable/nodes/8.C1Hsaxzw.js +0 -1
- package/dist/web/_app/immutable/nodes/9.SeWvoOCo.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{StateField as ze,Transaction as P,Facet as oe,combineConfig as He,EditorSelection as h,StateEffect as le,ChangeSet as qe,ChangeDesc as Ke,Annotation as ce,countColumn as $,Text as se,findClusterBreak as E}from"./CX_61fY8.js";import{E as x,D as $e}from"./Dmcboreb.js";import{IndentContext as ie,getIndentation as ue,indentString as v,syntaxTree as W,matchBrackets as D,getIndentUnit as G,indentUnit as We}from"./C7PgRgxX.js";import{N as F}from"./Bz0ZjVQE.js";const Qe=e=>{let{state:t}=e,r=t.doc.lineAt(t.selection.main.from),n=X(e.state,r.from);return n.line?Xe(e):n.block?Ze(e):!1};function Q(e,t){return({state:r,dispatch:n})=>{if(r.readOnly)return!1;let l=e(t,r);return l?(n(r.update(l)),!0):!1}}const Xe=Q(we,0),Ye=Q(fe,0),Ze=Q((e,t)=>fe(e,t,_e(t)),0);function X(e,t){let r=e.languageDataAt("commentTokens",t,1);return r.length?r[0]:{}}const M=50;function je(e,{open:t,close:r},n,l){let o=e.sliceDoc(n-M,n),c=e.sliceDoc(l,l+M),s=/\s*$/.exec(o)[0].length,i=/^\s*/.exec(c)[0].length,f=o.length-s;if(o.slice(f-t.length,f)==t&&c.slice(i,i+r.length)==r)return{open:{pos:n-s,margin:s&&1},close:{pos:l+i,margin:i&&1}};let u,a;l-n<=2*M?u=a=e.sliceDoc(n,l):(u=e.sliceDoc(n,n+M),a=e.sliceDoc(l-M,l));let p=/^\s*/.exec(u)[0].length,T=/\s*$/.exec(a)[0].length,L=a.length-T-r.length;return u.slice(p,p+t.length)==t&&a.slice(L,L+r.length)==r?{open:{pos:n+p+t.length,margin:/\s/.test(u.charAt(p+t.length))?1:0},close:{pos:l-T-r.length,margin:/\s/.test(a.charAt(L-1))?1:0}}:null}function _e(e){let t=[];for(let r of e.selection.ranges){let n=e.doc.lineAt(r.from),l=r.to<=n.to?n:e.doc.lineAt(r.to);l.from>n.from&&l.from==r.to&&(l=r.to==n.to+1?n:e.doc.lineAt(r.to-1));let o=t.length-1;o>=0&&t[o].to>n.from?t[o].to=l.to:t.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:l.to})}return t}function fe(e,t,r=t.selection.ranges){let n=r.map(o=>X(t,o.from).block);if(!n.every(o=>o))return null;let l=r.map((o,c)=>je(t,n[c],o.from,o.to));if(e!=2&&!l.every(o=>o))return{changes:t.changes(r.map((o,c)=>l[c]?[]:[{from:o.from,insert:n[c].open+" "},{from:o.to,insert:" "+n[c].close}]))};if(e!=1&&l.some(o=>o)){let o=[];for(let c=0,s;c<l.length;c++)if(s=l[c]){let i=n[c],{open:f,close:u}=s;o.push({from:f.pos-i.open.length,to:f.pos+f.margin},{from:u.pos-u.margin,to:u.pos+i.close.length})}return{changes:o}}return null}function we(e,t,r=t.selection.ranges){let n=[],l=-1;e:for(let{from:o,to:c}of r){let s=n.length,i=1e9,f;for(let u=o;u<=c;){let a=t.doc.lineAt(u);if(f==null&&(f=X(t,a.from).line,!f))continue e;if(a.from>l&&(o==c||c>a.from)){l=a.from;let p=/^\s*/.exec(a.text)[0].length,T=p==a.length,L=a.text.slice(p,p+f.length)==f?p:-1;p<a.text.length&&p<i&&(i=p),n.push({line:a,comment:L,token:f,indent:p,empty:T,single:!1})}u=a.to+1}if(i<1e9)for(let u=s;u<n.length;u++)n[u].indent<n[u].line.text.length&&(n[u].indent=i);n.length==s+1&&(n[s].single=!0)}if(e!=2&&n.some(o=>o.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:s,token:i,indent:f,empty:u,single:a}of n)(a||!u)&&o.push({from:s.from+f,insert:i+" "});let c=t.changes(o);return{changes:c,selection:t.selection.map(c,1)}}else if(e!=1&&n.some(o=>o.comment>=0)){let o=[];for(let{line:c,comment:s,token:i}of n)if(s>=0){let f=c.from+s,u=f+i.length;c.text[u-c.from]==" "&&u++,o.push({from:f,to:u})}return{changes:o}}return null}const z=ce.define(),et=ce.define(),tt=oe.define(),ae=oe.define({combine(e){return He(e,{minDepth:100,newGroupDelay:500,joinToEvent:(t,r)=>r},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,r)=>(n,l)=>t(n,l)||r(n,l)})}}),he=ze.define({create(){return B.empty},update(e,t){let r=t.state.facet(ae),n=t.annotation(z);if(n){let i=m.fromTransaction(t,n.selection),f=n.side,u=f==0?e.undone:e.done;return i?u=R(u,u.length,r.minDepth,i):u=pe(u,t.startState.selection),new B(f==0?n.rest:u,f==0?u:n.rest)}let l=t.annotation(et);if((l=="full"||l=="before")&&(e=e.isolate()),t.annotation(P.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let o=m.fromTransaction(t),c=t.annotation(P.time),s=t.annotation(P.userEvent);return o?e=e.addChanges(o,c,s,r,t):t.selection&&(e=e.addSelection(t.startState.selection,c,s,r.newGroupDelay)),(l=="full"||l=="after")&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(t=>t.toJSON()),undone:e.undone.map(t=>t.toJSON())}},fromJSON(e){return new B(e.done.map(m.fromJSON),e.undone.map(m.fromJSON))}});function un(e={}){return[he,ae.of(e),x.domEventHandlers({beforeinput(t,r){let n=t.inputType=="historyUndo"?de:t.inputType=="historyRedo"?H:null;return n?(t.preventDefault(),n(r)):!1}})]}function I(e,t){return function({state:r,dispatch:n}){if(!t&&r.readOnly)return!1;let l=r.field(he,!1);if(!l)return!1;let o=l.pop(e,r,t);return o?(n(o),!0):!1}}const de=I(0,!1),H=I(1,!1),nt=I(0,!0),rt=I(1,!0);class m{constructor(t,r,n,l,o){this.changes=t,this.effects=r,this.mapped=n,this.startSelection=l,this.selectionsAfter=o}setSelAfter(t){return new m(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,r,n;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(r=this.mapped)===null||r===void 0?void 0:r.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(l=>l.toJSON())}}static fromJSON(t){return new m(t.changes&&qe.fromJSON(t.changes),[],t.mapped&&Ke.fromJSON(t.mapped),t.startSelection&&h.fromJSON(t.startSelection),t.selectionsAfter.map(h.fromJSON))}static fromTransaction(t,r){let n=g;for(let l of t.startState.facet(tt)){let o=l(t);o.length&&(n=n.concat(o))}return!n.length&&t.changes.empty?null:new m(t.changes.invert(t.startState.doc),n,void 0,r||t.startState.selection,g)}static selection(t){return new m(void 0,g,void 0,void 0,t)}}function R(e,t,r,n){let l=t+1>r+20?t-r-1:0,o=e.slice(l,t);return o.push(n),o}function ot(e,t){let r=[],n=!1;return e.iterChangedRanges((l,o)=>r.push(l,o)),t.iterChangedRanges((l,o,c,s)=>{for(let i=0;i<r.length;){let f=r[i++],u=r[i++];s>=f&&c<=u&&(n=!0)}}),n}function lt(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((r,n)=>r.empty!=t.ranges[n].empty).length===0}function me(e,t){return e.length?t.length?e.concat(t):e:t}const g=[],ct=200;function pe(e,t){if(e.length){let r=e[e.length-1],n=r.selectionsAfter.slice(Math.max(0,r.selectionsAfter.length-ct));return n.length&&n[n.length-1].eq(t)?e:(n.push(t),R(e,e.length-1,1e9,r.setSelAfter(n)))}else return[m.selection([t])]}function st(e){let t=e[e.length-1],r=e.slice();return r[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),r}function J(e,t){if(!e.length)return e;let r=e.length,n=g;for(;r;){let l=it(e[r-1],t,n);if(l.changes&&!l.changes.empty||l.effects.length){let o=e.slice(0,r);return o[r-1]=l,o}else t=l.mapped,r--,n=l.selectionsAfter}return n.length?[m.selection(n)]:g}function it(e,t,r){let n=me(e.selectionsAfter.length?e.selectionsAfter.map(s=>s.map(t)):g,r);if(!e.changes)return m.selection(n);let l=e.changes.map(t),o=t.mapDesc(e.changes,!0),c=e.mapped?e.mapped.composeDesc(o):o;return new m(l,le.mapEffects(e.effects,t),c,e.startSelection.map(o),n)}const ut=/^(input\.type|delete)($|\.)/;class B{constructor(t,r,n=0,l=void 0){this.done=t,this.undone=r,this.prevTime=n,this.prevUserEvent=l}isolate(){return this.prevTime?new B(this.done,this.undone):this}addChanges(t,r,n,l,o){let c=this.done,s=c[c.length-1];return s&&s.changes&&!s.changes.empty&&t.changes&&(!n||ut.test(n))&&(!s.selectionsAfter.length&&r-this.prevTime<l.newGroupDelay&&l.joinToEvent(o,ot(s.changes,t.changes))||n=="input.type.compose")?c=R(c,c.length-1,l.minDepth,new m(t.changes.compose(s.changes),me(le.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,g)):c=R(c,c.length,l.minDepth,t),new B(c,g,r,n)}addSelection(t,r,n,l){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:g;return o.length>0&&r-this.prevTime<l&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&<(o[o.length-1],t)?this:new B(pe(this.done,t),this.undone,r,n)}addMapping(t){return new B(J(this.done,t),J(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,r,n){let l=t==0?this.done:this.undone;if(l.length==0)return null;let o=l[l.length-1],c=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):r.selection);if(n&&o.selectionsAfter.length)return r.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:z.of({side:t,rest:st(l),selection:c}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let s=l.length==1?g:l.slice(0,l.length-1);return o.mapped&&(s=J(s,o.mapped)),r.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:z.of({side:t,rest:s,selection:c}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}}B.empty=new B(g,g);const fn=[{key:"Mod-z",run:de,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:H,preventDefault:!0},{linux:"Ctrl-Shift-z",run:H,preventDefault:!0},{key:"Mod-u",run:nt,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:rt,preventDefault:!0}];function C(e,t){return h.create(e.ranges.map(t),e.mainIndex)}function k(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function A({state:e,dispatch:t},r){let n=C(e.selection,r);return n.eq(e.selection,!0)?!1:(t(k(e,n)),!0)}function N(e,t){return h.cursor(t?e.to:e.from)}function ge(e,t){return A(e,r=>r.empty?e.moveByChar(r,t):N(r,t))}function d(e){return e.textDirectionAt(e.state.selection.main.head)==$e.LTR}const ye=e=>ge(e,!d(e)),ke=e=>ge(e,d(e));function Ae(e,t){return A(e,r=>r.empty?e.moveByGroup(r,t):N(r,t))}const ft=e=>Ae(e,!d(e)),at=e=>Ae(e,d(e));function ht(e,t,r){if(t.type.prop(r))return!0;let n=t.to-t.from;return n&&(n>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function U(e,t,r){let n=W(e).resolveInner(t.head),l=r?F.closedBy:F.openedBy;for(let i=t.head;;){let f=r?n.childAfter(i):n.childBefore(i);if(!f)break;ht(e,f,l)?n=f:i=r?f.to:f.from}let o=n.type.prop(l),c,s;return o&&(c=r?D(e,n.from,1):D(e,n.to,-1))&&c.matched?s=r?c.end.to:c.end.from:s=r?n.to:n.from,h.cursor(s,r?-1:1)}const dt=e=>A(e,t=>U(e.state,t,!d(e))),mt=e=>A(e,t=>U(e.state,t,d(e)));function Be(e,t){return A(e,r=>{if(!r.empty)return N(r,t);let n=e.moveVertically(r,t);return n.head!=r.head?n:e.moveToLineBoundary(r,t)})}const Se=e=>Be(e,!1),De=e=>Be(e,!0);function xe(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,r=0,n=0,l;if(t){for(let o of e.state.facet(x.scrollMargins)){let c=o(e);c?.top&&(r=Math.max(c?.top,r)),c?.bottom&&(n=Math.max(c?.bottom,n))}l=e.scrollDOM.clientHeight-r-n}else l=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:n,selfScroll:t,height:Math.max(e.defaultLineHeight,l-5)}}function Ce(e,t){let r=xe(e),{state:n}=e,l=C(n.selection,c=>c.empty?e.moveVertically(c,t,r.height):N(c,t));if(l.eq(n.selection))return!1;let o;if(r.selfScroll){let c=e.coordsAtPos(n.selection.main.head),s=e.scrollDOM.getBoundingClientRect(),i=s.top+r.marginTop,f=s.bottom-r.marginBottom;c&&c.top>i&&c.bottom<f&&(o=x.scrollIntoView(l.main.head,{y:"start",yMargin:c.top-i}))}return e.dispatch(k(n,l),{effects:o}),!0}const Z=e=>Ce(e,!1),q=e=>Ce(e,!0);function S(e,t,r){let n=e.lineBlockAt(t.head),l=e.moveToLineBoundary(t,r);if(l.head==t.head&&l.head!=(r?n.to:n.from)&&(l=e.moveToLineBoundary(t,r,!1)),!r&&l.head==n.from&&n.length){let o=/^\s*/.exec(e.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;o&&t.head!=n.from+o&&(l=h.cursor(n.from+o))}return l}const pt=e=>A(e,t=>S(e,t,!0)),gt=e=>A(e,t=>S(e,t,!1)),yt=e=>A(e,t=>S(e,t,!d(e))),kt=e=>A(e,t=>S(e,t,d(e))),At=e=>A(e,t=>h.cursor(e.lineBlockAt(t.head).from,1)),Bt=e=>A(e,t=>h.cursor(e.lineBlockAt(t.head).to,-1));function St(e,t,r){let n=!1,l=C(e.selection,o=>{let c=D(e,o.head,-1)||D(e,o.head,1)||o.head>0&&D(e,o.head-1,1)||o.head<e.doc.length&&D(e,o.head+1,-1);if(!c||!c.end)return o;n=!0;let s=c.start.from==o.head?c.end.to:c.end.from;return h.cursor(s)});return n?(t(k(e,l)),!0):!1}const Dt=({state:e,dispatch:t})=>St(e,t);function y(e,t){let r=C(e.state.selection,n=>{let l=t(n);return h.range(n.anchor,l.head,l.goalColumn,l.bidiLevel||void 0,l.assoc)});return r.eq(e.state.selection)?!1:(e.dispatch(k(e.state,r)),!0)}function Le(e,t){return y(e,r=>e.moveByChar(r,t))}const Me=e=>Le(e,!d(e)),Ee=e=>Le(e,d(e));function Oe(e,t){return y(e,r=>e.moveByGroup(r,t))}const xt=e=>Oe(e,!d(e)),Ct=e=>Oe(e,d(e)),Lt=e=>y(e,t=>U(e.state,t,!d(e))),Mt=e=>y(e,t=>U(e.state,t,d(e)));function Te(e,t){return y(e,r=>e.moveVertically(r,t))}const be=e=>Te(e,!1),ve=e=>Te(e,!0);function Re(e,t){return y(e,r=>e.moveVertically(r,t,xe(e).height))}const j=e=>Re(e,!1),_=e=>Re(e,!0),Et=e=>y(e,t=>S(e,t,!0)),Ot=e=>y(e,t=>S(e,t,!1)),Tt=e=>y(e,t=>S(e,t,!d(e))),bt=e=>y(e,t=>S(e,t,d(e))),vt=e=>y(e,t=>h.cursor(e.lineBlockAt(t.head).from)),Rt=e=>y(e,t=>h.cursor(e.lineBlockAt(t.head).to)),w=({state:e,dispatch:t})=>(t(k(e,{anchor:0})),!0),ee=({state:e,dispatch:t})=>(t(k(e,{anchor:e.doc.length})),!0),te=({state:e,dispatch:t})=>(t(k(e,{anchor:e.selection.main.anchor,head:0})),!0),ne=({state:e,dispatch:t})=>(t(k(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),It=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),Nt=({state:e,dispatch:t})=>{let r=V(e).map(({from:n,to:l})=>h.range(n,Math.min(l+1,e.doc.length)));return t(e.update({selection:h.create(r),userEvent:"select"})),!0},Ut=({state:e,dispatch:t})=>{let r=C(e.selection,n=>{let l=W(e),o=l.resolveStack(n.from,1);if(n.empty){let c=l.resolveStack(n.from,-1);c.node.from>=o.node.from&&c.node.to<=o.node.to&&(o=c)}for(let c=o;c;c=c.next){let{node:s}=c;if((s.from<n.from&&s.to>=n.to||s.to>n.to&&s.from<=n.from)&&c.next)return h.range(s.to,s.from)}return n});return r.eq(e.selection)?!1:(t(k(e,r)),!0)};function Ie(e,t){let{state:r}=e,n=r.selection,l=r.selection.ranges.slice();for(let o of r.selection.ranges){let c=r.doc.lineAt(o.head);if(t?c.to<e.state.doc.length:c.from>0)for(let s=o;;){let i=e.moveVertically(s,t);if(i.head<c.from||i.head>c.to){l.some(f=>f.head==i.head)||l.push(i);break}else{if(i.head==s.head)break;s=i}}}return l.length==n.ranges.length?!1:(e.dispatch(k(r,h.create(l,l.length-1))),!0)}const Vt=e=>Ie(e,!1),Pt=e=>Ie(e,!0),Jt=({state:e,dispatch:t})=>{let r=e.selection,n=null;return r.ranges.length>1?n=h.create([r.main]):r.main.empty||(n=h.create([h.cursor(r.main.head)])),n?(t(k(e,n)),!0):!1};function O(e,t){if(e.state.readOnly)return!1;let r="delete.selection",{state:n}=e,l=n.changeByRange(o=>{let{from:c,to:s}=o;if(c==s){let i=t(o);i<c?(r="delete.backward",i=b(e,i,!1)):i>c&&(r="delete.forward",i=b(e,i,!0)),c=Math.min(c,i),s=Math.max(s,i)}else c=b(e,c,!1),s=b(e,s,!0);return c==s?{range:o}:{changes:{from:c,to:s},range:h.cursor(c,c<o.head?-1:1)}});return l.changes.empty?!1:(e.dispatch(n.update(l,{scrollIntoView:!0,userEvent:r,effects:r=="delete.selection"?x.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function b(e,t,r){if(e instanceof x)for(let n of e.state.facet(x.atomicRanges).map(l=>l(e)))n.between(t,t,(l,o)=>{l<t&&o>t&&(t=r?o:l)});return t}const Ne=(e,t,r)=>O(e,n=>{let l=n.from,{state:o}=e,c=o.doc.lineAt(l),s,i;if(r&&!t&&l>c.from&&l<c.from+200&&!/[^ \t]/.test(s=c.text.slice(0,l-c.from))){if(s[s.length-1]==" ")return l-1;let f=$(s,o.tabSize),u=f%G(o)||G(o);for(let a=0;a<u&&s[s.length-1-a]==" ";a++)l--;i=l}else i=E(c.text,l-c.from,t,t)+c.from,i==l&&c.number!=(t?o.doc.lines:1)?i+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(c.text.slice(i-c.from,l-c.from))&&(i=E(c.text,i-c.from,!1,!1)+c.from);return i}),K=e=>Ne(e,!1,!0),Ue=e=>Ne(e,!0,!1),Ve=(e,t)=>O(e,r=>{let n=r.head,{state:l}=e,o=l.doc.lineAt(n),c=l.charCategorizer(n);for(let s=null;;){if(n==(t?o.to:o.from)){n==r.head&&o.number!=(t?l.doc.lines:1)&&(n+=t?1:-1);break}let i=E(o.text,n-o.from,t)+o.from,f=o.text.slice(Math.min(n,i)-o.from,Math.max(n,i)-o.from),u=c(f);if(s!=null&&u!=s)break;(f!=" "||n!=r.head)&&(s=u),n=i}return n}),Pe=e=>Ve(e,!1),Gt=e=>Ve(e,!0),Ft=e=>O(e,t=>{let r=e.lineBlockAt(t.head).to;return t.head<r?r:Math.min(e.state.doc.length,t.head+1)}),zt=e=>O(e,t=>{let r=e.moveToLineBoundary(t,!1).head;return t.head>r?r:Math.max(0,t.head-1)}),Ht=e=>O(e,t=>{let r=e.moveToLineBoundary(t,!0).head;return t.head<r?r:Math.min(e.state.doc.length,t.head+1)}),qt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=e.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:se.of(["",""])},range:h.cursor(n.from)}));return t(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0},Kt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=e.changeByRange(n=>{if(!n.empty||n.from==0||n.from==e.doc.length)return{range:n};let l=n.from,o=e.doc.lineAt(l),c=l==o.from?l-1:E(o.text,l-o.from,!1)+o.from,s=l==o.to?l+1:E(o.text,l-o.from,!0)+o.from;return{changes:{from:c,to:s,insert:e.doc.slice(l,s).append(e.doc.slice(c,l))},range:h.cursor(s)}});return r.changes.empty?!1:(t(e.update(r,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function V(e){let t=[],r=-1;for(let n of e.selection.ranges){let l=e.doc.lineAt(n.from),o=e.doc.lineAt(n.to);if(!n.empty&&n.to==o.from&&(o=e.doc.lineAt(n.to-1)),r>=l.number){let c=t[t.length-1];c.to=o.to,c.ranges.push(n)}else t.push({from:l.from,to:o.to,ranges:[n]});r=o.number+1}return t}function Je(e,t,r){if(e.readOnly)return!1;let n=[],l=[];for(let o of V(e)){if(r?o.to==e.doc.length:o.from==0)continue;let c=e.doc.lineAt(r?o.to+1:o.from-1),s=c.length+1;if(r){n.push({from:o.to,to:c.to},{from:o.from,insert:c.text+e.lineBreak});for(let i of o.ranges)l.push(h.range(Math.min(e.doc.length,i.anchor+s),Math.min(e.doc.length,i.head+s)))}else{n.push({from:c.from,to:o.from},{from:o.to,insert:e.lineBreak+c.text});for(let i of o.ranges)l.push(h.range(i.anchor-s,i.head-s))}}return n.length?(t(e.update({changes:n,scrollIntoView:!0,selection:h.create(l,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}const $t=({state:e,dispatch:t})=>Je(e,t,!1),Wt=({state:e,dispatch:t})=>Je(e,t,!0);function Ge(e,t,r){if(e.readOnly)return!1;let n=[];for(let o of V(e))r?n.push({from:o.from,insert:e.doc.slice(o.from,o.to)+e.lineBreak}):n.push({from:o.to,insert:e.lineBreak+e.doc.slice(o.from,o.to)});let l=e.changes(n);return t(e.update({changes:l,selection:e.selection.map(l,r?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Qt=({state:e,dispatch:t})=>Ge(e,t,!1),Xt=({state:e,dispatch:t})=>Ge(e,t,!0),Yt=e=>{if(e.state.readOnly)return!1;let{state:t}=e,r=t.changes(V(t).map(({from:l,to:o})=>(l>0?l--:o<t.doc.length&&o++,{from:l,to:o}))),n=C(t.selection,l=>{let o;if(e.lineWrapping){let c=e.lineBlockAt(l.head),s=e.coordsAtPos(l.head,l.assoc||1);s&&(o=c.bottom+e.documentTop-s.bottom+e.defaultLineHeight/2)}return e.moveVertically(l,!0,o)}).map(r);return e.dispatch({changes:r,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Zt(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let r=W(e).resolveInner(t),n=r.childBefore(t),l=r.childAfter(t),o;return n&&l&&n.to<=t&&l.from>=t&&(o=n.type.prop(F.closedBy))&&o.indexOf(l.name)>-1&&e.doc.lineAt(n.to).from==e.doc.lineAt(l.from).from&&!/\S/.test(e.sliceDoc(n.to,l.from))?{from:n.to,to:l.from}:null}const re=Fe(!1),jt=Fe(!0);function Fe(e){return({state:t,dispatch:r})=>{if(t.readOnly)return!1;let n=t.changeByRange(l=>{let{from:o,to:c}=l,s=t.doc.lineAt(o),i=!e&&o==c&&Zt(t,o);e&&(o=c=(c<=s.to?s:t.doc.lineAt(c)).to);let f=new ie(t,{simulateBreak:o,simulateDoubleBreak:!!i}),u=ue(f,o);for(u==null&&(u=$(/^\s*/.exec(t.doc.lineAt(o).text)[0],t.tabSize));c<s.to&&/\s/.test(s.text[c-s.from]);)c++;i?{from:o,to:c}=i:o>s.from&&o<s.from+100&&!/\S/.test(s.text.slice(0,o))&&(o=s.from);let a=["",v(t,u)];return i&&a.push(v(t,f.lineIndent(s.from,-1))),{changes:{from:o,to:c,insert:se.of(a)},range:h.cursor(o+1+a[1].length)}});return r(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function Y(e,t){let r=-1;return e.changeByRange(n=>{let l=[];for(let c=n.from;c<=n.to;){let s=e.doc.lineAt(c);s.number>r&&(n.empty||n.to>s.from)&&(t(s,l,n),r=s.number),c=s.to+1}let o=e.changes(l);return{changes:l,range:h.range(o.mapPos(n.anchor,1),o.mapPos(n.head,1))}})}const _t=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Object.create(null),n=new ie(e,{overrideIndentation:o=>{let c=r[o];return c??-1}}),l=Y(e,(o,c,s)=>{let i=ue(n,o.from);if(i==null)return;/\S/.test(o.text)||(i=0);let f=/^\s*/.exec(o.text)[0],u=v(e,i);(f!=u||s.from<o.from+f.length)&&(r[o.from]=i,c.push({from:o.from,to:o.from+f.length,insert:u}))});return l.changes.empty||t(e.update(l,{userEvent:"indent"})),!0},wt=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Y(e,(r,n)=>{n.push({from:r.from,insert:e.facet(We)})}),{userEvent:"input.indent"})),!0),en=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Y(e,(r,n)=>{let l=/^\s*/.exec(r.text)[0];if(!l)return;let o=$(l,e.tabSize),c=0,s=v(e,Math.max(0,o-G(e)));for(;c<l.length&&c<s.length&&l.charCodeAt(c)==s.charCodeAt(c);)c++;n.push({from:r.from+c,to:r.from+l.length,insert:s.slice(c)})}),{userEvent:"delete.dedent"})),!0),tn=e=>(e.setTabFocusMode(),!0),nn=[{key:"Ctrl-b",run:ye,shift:Me,preventDefault:!0},{key:"Ctrl-f",run:ke,shift:Ee},{key:"Ctrl-p",run:Se,shift:be},{key:"Ctrl-n",run:De,shift:ve},{key:"Ctrl-a",run:At,shift:vt},{key:"Ctrl-e",run:Bt,shift:Rt},{key:"Ctrl-d",run:Ue},{key:"Ctrl-h",run:K},{key:"Ctrl-k",run:Ft},{key:"Ctrl-Alt-h",run:Pe},{key:"Ctrl-o",run:qt},{key:"Ctrl-t",run:Kt},{key:"Ctrl-v",run:q}],rn=[{key:"ArrowLeft",run:ye,shift:Me,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:ft,shift:xt,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:yt,shift:Tt,preventDefault:!0},{key:"ArrowRight",run:ke,shift:Ee,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:at,shift:Ct,preventDefault:!0},{mac:"Cmd-ArrowRight",run:kt,shift:bt,preventDefault:!0},{key:"ArrowUp",run:Se,shift:be,preventDefault:!0},{mac:"Cmd-ArrowUp",run:w,shift:te},{mac:"Ctrl-ArrowUp",run:Z,shift:j},{key:"ArrowDown",run:De,shift:ve,preventDefault:!0},{mac:"Cmd-ArrowDown",run:ee,shift:ne},{mac:"Ctrl-ArrowDown",run:q,shift:_},{key:"PageUp",run:Z,shift:j},{key:"PageDown",run:q,shift:_},{key:"Home",run:gt,shift:Ot,preventDefault:!0},{key:"Mod-Home",run:w,shift:te},{key:"End",run:pt,shift:Et,preventDefault:!0},{key:"Mod-End",run:ee,shift:ne},{key:"Enter",run:re,shift:re},{key:"Mod-a",run:It},{key:"Backspace",run:K,shift:K,preventDefault:!0},{key:"Delete",run:Ue,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Pe,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Gt,preventDefault:!0},{mac:"Mod-Backspace",run:zt,preventDefault:!0},{mac:"Mod-Delete",run:Ht,preventDefault:!0}].concat(nn.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),an=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:dt,shift:Lt},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:mt,shift:Mt},{key:"Alt-ArrowUp",run:$t},{key:"Shift-Alt-ArrowUp",run:Qt},{key:"Alt-ArrowDown",run:Wt},{key:"Shift-Alt-ArrowDown",run:Xt},{key:"Mod-Alt-ArrowUp",run:Vt},{key:"Mod-Alt-ArrowDown",run:Pt},{key:"Escape",run:Jt},{key:"Mod-Enter",run:jt},{key:"Alt-l",mac:"Ctrl-l",run:Nt},{key:"Mod-i",run:Ut,preventDefault:!0},{key:"Mod-[",run:en},{key:"Mod-]",run:wt},{key:"Mod-Alt-\\",run:_t},{key:"Shift-Mod-k",run:Yt},{key:"Shift-Mod-\\",run:Dt},{key:"Mod-/",run:Qe},{key:"Alt-A",run:Ye},{key:"Ctrl-m",mac:"Shift-Alt-m",run:tn}].concat(rn);export{Vt as addCursorAbove,Pt as addCursorBelow,Xt as copyLineDown,Qt as copyLineUp,ye as cursorCharLeft,ke as cursorCharRight,ee as cursorDocEnd,w as cursorDocStart,ft as cursorGroupLeft,at as cursorGroupRight,gt as cursorLineBoundaryBackward,pt as cursorLineBoundaryForward,yt as cursorLineBoundaryLeft,kt as cursorLineBoundaryRight,De as cursorLineDown,Bt as cursorLineEnd,At as cursorLineStart,Se as cursorLineUp,Dt as cursorMatchingBracket,q as cursorPageDown,Z as cursorPageUp,dt as cursorSyntaxLeft,mt as cursorSyntaxRight,an as defaultKeymap,K as deleteCharBackward,Ue as deleteCharForward,Pe as deleteGroupBackward,Gt as deleteGroupForward,Yt as deleteLine,zt as deleteLineBoundaryBackward,Ht as deleteLineBoundaryForward,Ft as deleteToLineEnd,nn as emacsStyleKeymap,un as history,fn as historyKeymap,en as indentLess,wt as indentMore,_t as indentSelection,jt as insertBlankLine,re as insertNewlineAndIndent,tt as invertedEffects,et as isolateHistory,Wt as moveLineDown,$t as moveLineUp,H as redo,rt as redoSelection,It as selectAll,Me as selectCharLeft,Ee as selectCharRight,ne as selectDocEnd,te as selectDocStart,xt as selectGroupLeft,Ct as selectGroupRight,Nt as selectLine,Ot as selectLineBoundaryBackward,Et as selectLineBoundaryForward,Tt as selectLineBoundaryLeft,bt as selectLineBoundaryRight,ve as selectLineDown,Rt as selectLineEnd,vt as selectLineStart,be as selectLineUp,_ as selectPageDown,j as selectPageUp,Ut as selectParentSyntax,Lt as selectSyntaxLeft,Mt as selectSyntaxRight,Jt as simplifySelection,qt as splitLine,rn as standardKeymap,Ye as toggleBlockComment,Ze as toggleBlockCommentByLine,Qe as toggleComment,Xe as toggleLineComment,tn as toggleTabFocusMode,Kt as transposeChars,de as undo,nt as undoSelection};
|
|
1
|
+
import{StateField as ze,Transaction as P,Facet as oe,combineConfig as He,EditorSelection as h,StateEffect as le,ChangeSet as qe,ChangeDesc as Ke,Annotation as ce,countColumn as $,Text as se,findClusterBreak as E}from"./CX_61fY8.js";import{E as x,D as $e}from"./Dmcboreb.js";import{IndentContext as ie,getIndentation as ue,indentString as v,syntaxTree as W,matchBrackets as D,getIndentUnit as G,indentUnit as We}from"./BiMb3uU3.js";import{a as F}from"./ChqmDGF0.js";const Qe=e=>{let{state:t}=e,r=t.doc.lineAt(t.selection.main.from),n=X(e.state,r.from);return n.line?Xe(e):n.block?Ze(e):!1};function Q(e,t){return({state:r,dispatch:n})=>{if(r.readOnly)return!1;let l=e(t,r);return l?(n(r.update(l)),!0):!1}}const Xe=Q(we,0),Ye=Q(fe,0),Ze=Q((e,t)=>fe(e,t,_e(t)),0);function X(e,t){let r=e.languageDataAt("commentTokens",t,1);return r.length?r[0]:{}}const M=50;function je(e,{open:t,close:r},n,l){let o=e.sliceDoc(n-M,n),c=e.sliceDoc(l,l+M),s=/\s*$/.exec(o)[0].length,i=/^\s*/.exec(c)[0].length,f=o.length-s;if(o.slice(f-t.length,f)==t&&c.slice(i,i+r.length)==r)return{open:{pos:n-s,margin:s&&1},close:{pos:l+i,margin:i&&1}};let u,a;l-n<=2*M?u=a=e.sliceDoc(n,l):(u=e.sliceDoc(n,n+M),a=e.sliceDoc(l-M,l));let p=/^\s*/.exec(u)[0].length,T=/\s*$/.exec(a)[0].length,L=a.length-T-r.length;return u.slice(p,p+t.length)==t&&a.slice(L,L+r.length)==r?{open:{pos:n+p+t.length,margin:/\s/.test(u.charAt(p+t.length))?1:0},close:{pos:l-T-r.length,margin:/\s/.test(a.charAt(L-1))?1:0}}:null}function _e(e){let t=[];for(let r of e.selection.ranges){let n=e.doc.lineAt(r.from),l=r.to<=n.to?n:e.doc.lineAt(r.to);l.from>n.from&&l.from==r.to&&(l=r.to==n.to+1?n:e.doc.lineAt(r.to-1));let o=t.length-1;o>=0&&t[o].to>n.from?t[o].to=l.to:t.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:l.to})}return t}function fe(e,t,r=t.selection.ranges){let n=r.map(o=>X(t,o.from).block);if(!n.every(o=>o))return null;let l=r.map((o,c)=>je(t,n[c],o.from,o.to));if(e!=2&&!l.every(o=>o))return{changes:t.changes(r.map((o,c)=>l[c]?[]:[{from:o.from,insert:n[c].open+" "},{from:o.to,insert:" "+n[c].close}]))};if(e!=1&&l.some(o=>o)){let o=[];for(let c=0,s;c<l.length;c++)if(s=l[c]){let i=n[c],{open:f,close:u}=s;o.push({from:f.pos-i.open.length,to:f.pos+f.margin},{from:u.pos-u.margin,to:u.pos+i.close.length})}return{changes:o}}return null}function we(e,t,r=t.selection.ranges){let n=[],l=-1;e:for(let{from:o,to:c}of r){let s=n.length,i=1e9,f;for(let u=o;u<=c;){let a=t.doc.lineAt(u);if(f==null&&(f=X(t,a.from).line,!f))continue e;if(a.from>l&&(o==c||c>a.from)){l=a.from;let p=/^\s*/.exec(a.text)[0].length,T=p==a.length,L=a.text.slice(p,p+f.length)==f?p:-1;p<a.text.length&&p<i&&(i=p),n.push({line:a,comment:L,token:f,indent:p,empty:T,single:!1})}u=a.to+1}if(i<1e9)for(let u=s;u<n.length;u++)n[u].indent<n[u].line.text.length&&(n[u].indent=i);n.length==s+1&&(n[s].single=!0)}if(e!=2&&n.some(o=>o.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:s,token:i,indent:f,empty:u,single:a}of n)(a||!u)&&o.push({from:s.from+f,insert:i+" "});let c=t.changes(o);return{changes:c,selection:t.selection.map(c,1)}}else if(e!=1&&n.some(o=>o.comment>=0)){let o=[];for(let{line:c,comment:s,token:i}of n)if(s>=0){let f=c.from+s,u=f+i.length;c.text[u-c.from]==" "&&u++,o.push({from:f,to:u})}return{changes:o}}return null}const z=ce.define(),et=ce.define(),tt=oe.define(),ae=oe.define({combine(e){return He(e,{minDepth:100,newGroupDelay:500,joinToEvent:(t,r)=>r},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,r)=>(n,l)=>t(n,l)||r(n,l)})}}),he=ze.define({create(){return B.empty},update(e,t){let r=t.state.facet(ae),n=t.annotation(z);if(n){let i=m.fromTransaction(t,n.selection),f=n.side,u=f==0?e.undone:e.done;return i?u=R(u,u.length,r.minDepth,i):u=pe(u,t.startState.selection),new B(f==0?n.rest:u,f==0?u:n.rest)}let l=t.annotation(et);if((l=="full"||l=="before")&&(e=e.isolate()),t.annotation(P.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let o=m.fromTransaction(t),c=t.annotation(P.time),s=t.annotation(P.userEvent);return o?e=e.addChanges(o,c,s,r,t):t.selection&&(e=e.addSelection(t.startState.selection,c,s,r.newGroupDelay)),(l=="full"||l=="after")&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(t=>t.toJSON()),undone:e.undone.map(t=>t.toJSON())}},fromJSON(e){return new B(e.done.map(m.fromJSON),e.undone.map(m.fromJSON))}});function un(e={}){return[he,ae.of(e),x.domEventHandlers({beforeinput(t,r){let n=t.inputType=="historyUndo"?de:t.inputType=="historyRedo"?H:null;return n?(t.preventDefault(),n(r)):!1}})]}function I(e,t){return function({state:r,dispatch:n}){if(!t&&r.readOnly)return!1;let l=r.field(he,!1);if(!l)return!1;let o=l.pop(e,r,t);return o?(n(o),!0):!1}}const de=I(0,!1),H=I(1,!1),nt=I(0,!0),rt=I(1,!0);class m{constructor(t,r,n,l,o){this.changes=t,this.effects=r,this.mapped=n,this.startSelection=l,this.selectionsAfter=o}setSelAfter(t){return new m(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,r,n;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(r=this.mapped)===null||r===void 0?void 0:r.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(l=>l.toJSON())}}static fromJSON(t){return new m(t.changes&&qe.fromJSON(t.changes),[],t.mapped&&Ke.fromJSON(t.mapped),t.startSelection&&h.fromJSON(t.startSelection),t.selectionsAfter.map(h.fromJSON))}static fromTransaction(t,r){let n=g;for(let l of t.startState.facet(tt)){let o=l(t);o.length&&(n=n.concat(o))}return!n.length&&t.changes.empty?null:new m(t.changes.invert(t.startState.doc),n,void 0,r||t.startState.selection,g)}static selection(t){return new m(void 0,g,void 0,void 0,t)}}function R(e,t,r,n){let l=t+1>r+20?t-r-1:0,o=e.slice(l,t);return o.push(n),o}function ot(e,t){let r=[],n=!1;return e.iterChangedRanges((l,o)=>r.push(l,o)),t.iterChangedRanges((l,o,c,s)=>{for(let i=0;i<r.length;){let f=r[i++],u=r[i++];s>=f&&c<=u&&(n=!0)}}),n}function lt(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((r,n)=>r.empty!=t.ranges[n].empty).length===0}function me(e,t){return e.length?t.length?e.concat(t):e:t}const g=[],ct=200;function pe(e,t){if(e.length){let r=e[e.length-1],n=r.selectionsAfter.slice(Math.max(0,r.selectionsAfter.length-ct));return n.length&&n[n.length-1].eq(t)?e:(n.push(t),R(e,e.length-1,1e9,r.setSelAfter(n)))}else return[m.selection([t])]}function st(e){let t=e[e.length-1],r=e.slice();return r[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),r}function J(e,t){if(!e.length)return e;let r=e.length,n=g;for(;r;){let l=it(e[r-1],t,n);if(l.changes&&!l.changes.empty||l.effects.length){let o=e.slice(0,r);return o[r-1]=l,o}else t=l.mapped,r--,n=l.selectionsAfter}return n.length?[m.selection(n)]:g}function it(e,t,r){let n=me(e.selectionsAfter.length?e.selectionsAfter.map(s=>s.map(t)):g,r);if(!e.changes)return m.selection(n);let l=e.changes.map(t),o=t.mapDesc(e.changes,!0),c=e.mapped?e.mapped.composeDesc(o):o;return new m(l,le.mapEffects(e.effects,t),c,e.startSelection.map(o),n)}const ut=/^(input\.type|delete)($|\.)/;class B{constructor(t,r,n=0,l=void 0){this.done=t,this.undone=r,this.prevTime=n,this.prevUserEvent=l}isolate(){return this.prevTime?new B(this.done,this.undone):this}addChanges(t,r,n,l,o){let c=this.done,s=c[c.length-1];return s&&s.changes&&!s.changes.empty&&t.changes&&(!n||ut.test(n))&&(!s.selectionsAfter.length&&r-this.prevTime<l.newGroupDelay&&l.joinToEvent(o,ot(s.changes,t.changes))||n=="input.type.compose")?c=R(c,c.length-1,l.minDepth,new m(t.changes.compose(s.changes),me(le.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,g)):c=R(c,c.length,l.minDepth,t),new B(c,g,r,n)}addSelection(t,r,n,l){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:g;return o.length>0&&r-this.prevTime<l&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&<(o[o.length-1],t)?this:new B(pe(this.done,t),this.undone,r,n)}addMapping(t){return new B(J(this.done,t),J(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,r,n){let l=t==0?this.done:this.undone;if(l.length==0)return null;let o=l[l.length-1],c=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):r.selection);if(n&&o.selectionsAfter.length)return r.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:z.of({side:t,rest:st(l),selection:c}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let s=l.length==1?g:l.slice(0,l.length-1);return o.mapped&&(s=J(s,o.mapped)),r.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:z.of({side:t,rest:s,selection:c}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}}B.empty=new B(g,g);const fn=[{key:"Mod-z",run:de,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:H,preventDefault:!0},{linux:"Ctrl-Shift-z",run:H,preventDefault:!0},{key:"Mod-u",run:nt,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:rt,preventDefault:!0}];function C(e,t){return h.create(e.ranges.map(t),e.mainIndex)}function k(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function A({state:e,dispatch:t},r){let n=C(e.selection,r);return n.eq(e.selection,!0)?!1:(t(k(e,n)),!0)}function U(e,t){return h.cursor(t?e.to:e.from)}function ge(e,t){return A(e,r=>r.empty?e.moveByChar(r,t):U(r,t))}function d(e){return e.textDirectionAt(e.state.selection.main.head)==$e.LTR}const ye=e=>ge(e,!d(e)),ke=e=>ge(e,d(e));function Ae(e,t){return A(e,r=>r.empty?e.moveByGroup(r,t):U(r,t))}const ft=e=>Ae(e,!d(e)),at=e=>Ae(e,d(e));function ht(e,t,r){if(t.type.prop(r))return!0;let n=t.to-t.from;return n&&(n>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function V(e,t,r){let n=W(e).resolveInner(t.head),l=r?F.closedBy:F.openedBy;for(let i=t.head;;){let f=r?n.childAfter(i):n.childBefore(i);if(!f)break;ht(e,f,l)?n=f:i=r?f.to:f.from}let o=n.type.prop(l),c,s;return o&&(c=r?D(e,n.from,1):D(e,n.to,-1))&&c.matched?s=r?c.end.to:c.end.from:s=r?n.to:n.from,h.cursor(s,r?-1:1)}const dt=e=>A(e,t=>V(e.state,t,!d(e))),mt=e=>A(e,t=>V(e.state,t,d(e)));function Be(e,t){return A(e,r=>{if(!r.empty)return U(r,t);let n=e.moveVertically(r,t);return n.head!=r.head?n:e.moveToLineBoundary(r,t)})}const Se=e=>Be(e,!1),De=e=>Be(e,!0);function xe(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,r=0,n=0,l;if(t){for(let o of e.state.facet(x.scrollMargins)){let c=o(e);c?.top&&(r=Math.max(c?.top,r)),c?.bottom&&(n=Math.max(c?.bottom,n))}l=e.scrollDOM.clientHeight-r-n}else l=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:n,selfScroll:t,height:Math.max(e.defaultLineHeight,l-5)}}function Ce(e,t){let r=xe(e),{state:n}=e,l=C(n.selection,c=>c.empty?e.moveVertically(c,t,r.height):U(c,t));if(l.eq(n.selection))return!1;let o;if(r.selfScroll){let c=e.coordsAtPos(n.selection.main.head),s=e.scrollDOM.getBoundingClientRect(),i=s.top+r.marginTop,f=s.bottom-r.marginBottom;c&&c.top>i&&c.bottom<f&&(o=x.scrollIntoView(l.main.head,{y:"start",yMargin:c.top-i}))}return e.dispatch(k(n,l),{effects:o}),!0}const Z=e=>Ce(e,!1),q=e=>Ce(e,!0);function S(e,t,r){let n=e.lineBlockAt(t.head),l=e.moveToLineBoundary(t,r);if(l.head==t.head&&l.head!=(r?n.to:n.from)&&(l=e.moveToLineBoundary(t,r,!1)),!r&&l.head==n.from&&n.length){let o=/^\s*/.exec(e.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;o&&t.head!=n.from+o&&(l=h.cursor(n.from+o))}return l}const pt=e=>A(e,t=>S(e,t,!0)),gt=e=>A(e,t=>S(e,t,!1)),yt=e=>A(e,t=>S(e,t,!d(e))),kt=e=>A(e,t=>S(e,t,d(e))),At=e=>A(e,t=>h.cursor(e.lineBlockAt(t.head).from,1)),Bt=e=>A(e,t=>h.cursor(e.lineBlockAt(t.head).to,-1));function St(e,t,r){let n=!1,l=C(e.selection,o=>{let c=D(e,o.head,-1)||D(e,o.head,1)||o.head>0&&D(e,o.head-1,1)||o.head<e.doc.length&&D(e,o.head+1,-1);if(!c||!c.end)return o;n=!0;let s=c.start.from==o.head?c.end.to:c.end.from;return h.cursor(s)});return n?(t(k(e,l)),!0):!1}const Dt=({state:e,dispatch:t})=>St(e,t);function y(e,t){let r=C(e.state.selection,n=>{let l=t(n);return h.range(n.anchor,l.head,l.goalColumn,l.bidiLevel||void 0,l.assoc)});return r.eq(e.state.selection)?!1:(e.dispatch(k(e.state,r)),!0)}function Le(e,t){return y(e,r=>e.moveByChar(r,t))}const Me=e=>Le(e,!d(e)),Ee=e=>Le(e,d(e));function Oe(e,t){return y(e,r=>e.moveByGroup(r,t))}const xt=e=>Oe(e,!d(e)),Ct=e=>Oe(e,d(e)),Lt=e=>y(e,t=>V(e.state,t,!d(e))),Mt=e=>y(e,t=>V(e.state,t,d(e)));function Te(e,t){return y(e,r=>e.moveVertically(r,t))}const be=e=>Te(e,!1),ve=e=>Te(e,!0);function Re(e,t){return y(e,r=>e.moveVertically(r,t,xe(e).height))}const j=e=>Re(e,!1),_=e=>Re(e,!0),Et=e=>y(e,t=>S(e,t,!0)),Ot=e=>y(e,t=>S(e,t,!1)),Tt=e=>y(e,t=>S(e,t,!d(e))),bt=e=>y(e,t=>S(e,t,d(e))),vt=e=>y(e,t=>h.cursor(e.lineBlockAt(t.head).from)),Rt=e=>y(e,t=>h.cursor(e.lineBlockAt(t.head).to)),w=({state:e,dispatch:t})=>(t(k(e,{anchor:0})),!0),ee=({state:e,dispatch:t})=>(t(k(e,{anchor:e.doc.length})),!0),te=({state:e,dispatch:t})=>(t(k(e,{anchor:e.selection.main.anchor,head:0})),!0),ne=({state:e,dispatch:t})=>(t(k(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),It=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),Ut=({state:e,dispatch:t})=>{let r=N(e).map(({from:n,to:l})=>h.range(n,Math.min(l+1,e.doc.length)));return t(e.update({selection:h.create(r),userEvent:"select"})),!0},Vt=({state:e,dispatch:t})=>{let r=C(e.selection,n=>{let l=W(e),o=l.resolveStack(n.from,1);if(n.empty){let c=l.resolveStack(n.from,-1);c.node.from>=o.node.from&&c.node.to<=o.node.to&&(o=c)}for(let c=o;c;c=c.next){let{node:s}=c;if((s.from<n.from&&s.to>=n.to||s.to>n.to&&s.from<=n.from)&&c.next)return h.range(s.to,s.from)}return n});return r.eq(e.selection)?!1:(t(k(e,r)),!0)};function Ie(e,t){let{state:r}=e,n=r.selection,l=r.selection.ranges.slice();for(let o of r.selection.ranges){let c=r.doc.lineAt(o.head);if(t?c.to<e.state.doc.length:c.from>0)for(let s=o;;){let i=e.moveVertically(s,t);if(i.head<c.from||i.head>c.to){l.some(f=>f.head==i.head)||l.push(i);break}else{if(i.head==s.head)break;s=i}}}return l.length==n.ranges.length?!1:(e.dispatch(k(r,h.create(l,l.length-1))),!0)}const Nt=e=>Ie(e,!1),Pt=e=>Ie(e,!0),Jt=({state:e,dispatch:t})=>{let r=e.selection,n=null;return r.ranges.length>1?n=h.create([r.main]):r.main.empty||(n=h.create([h.cursor(r.main.head)])),n?(t(k(e,n)),!0):!1};function O(e,t){if(e.state.readOnly)return!1;let r="delete.selection",{state:n}=e,l=n.changeByRange(o=>{let{from:c,to:s}=o;if(c==s){let i=t(o);i<c?(r="delete.backward",i=b(e,i,!1)):i>c&&(r="delete.forward",i=b(e,i,!0)),c=Math.min(c,i),s=Math.max(s,i)}else c=b(e,c,!1),s=b(e,s,!0);return c==s?{range:o}:{changes:{from:c,to:s},range:h.cursor(c,c<o.head?-1:1)}});return l.changes.empty?!1:(e.dispatch(n.update(l,{scrollIntoView:!0,userEvent:r,effects:r=="delete.selection"?x.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function b(e,t,r){if(e instanceof x)for(let n of e.state.facet(x.atomicRanges).map(l=>l(e)))n.between(t,t,(l,o)=>{l<t&&o>t&&(t=r?o:l)});return t}const Ue=(e,t,r)=>O(e,n=>{let l=n.from,{state:o}=e,c=o.doc.lineAt(l),s,i;if(r&&!t&&l>c.from&&l<c.from+200&&!/[^ \t]/.test(s=c.text.slice(0,l-c.from))){if(s[s.length-1]==" ")return l-1;let f=$(s,o.tabSize),u=f%G(o)||G(o);for(let a=0;a<u&&s[s.length-1-a]==" ";a++)l--;i=l}else i=E(c.text,l-c.from,t,t)+c.from,i==l&&c.number!=(t?o.doc.lines:1)?i+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(c.text.slice(i-c.from,l-c.from))&&(i=E(c.text,i-c.from,!1,!1)+c.from);return i}),K=e=>Ue(e,!1,!0),Ve=e=>Ue(e,!0,!1),Ne=(e,t)=>O(e,r=>{let n=r.head,{state:l}=e,o=l.doc.lineAt(n),c=l.charCategorizer(n);for(let s=null;;){if(n==(t?o.to:o.from)){n==r.head&&o.number!=(t?l.doc.lines:1)&&(n+=t?1:-1);break}let i=E(o.text,n-o.from,t)+o.from,f=o.text.slice(Math.min(n,i)-o.from,Math.max(n,i)-o.from),u=c(f);if(s!=null&&u!=s)break;(f!=" "||n!=r.head)&&(s=u),n=i}return n}),Pe=e=>Ne(e,!1),Gt=e=>Ne(e,!0),Ft=e=>O(e,t=>{let r=e.lineBlockAt(t.head).to;return t.head<r?r:Math.min(e.state.doc.length,t.head+1)}),zt=e=>O(e,t=>{let r=e.moveToLineBoundary(t,!1).head;return t.head>r?r:Math.max(0,t.head-1)}),Ht=e=>O(e,t=>{let r=e.moveToLineBoundary(t,!0).head;return t.head<r?r:Math.min(e.state.doc.length,t.head+1)}),qt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=e.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:se.of(["",""])},range:h.cursor(n.from)}));return t(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0},Kt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=e.changeByRange(n=>{if(!n.empty||n.from==0||n.from==e.doc.length)return{range:n};let l=n.from,o=e.doc.lineAt(l),c=l==o.from?l-1:E(o.text,l-o.from,!1)+o.from,s=l==o.to?l+1:E(o.text,l-o.from,!0)+o.from;return{changes:{from:c,to:s,insert:e.doc.slice(l,s).append(e.doc.slice(c,l))},range:h.cursor(s)}});return r.changes.empty?!1:(t(e.update(r,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function N(e){let t=[],r=-1;for(let n of e.selection.ranges){let l=e.doc.lineAt(n.from),o=e.doc.lineAt(n.to);if(!n.empty&&n.to==o.from&&(o=e.doc.lineAt(n.to-1)),r>=l.number){let c=t[t.length-1];c.to=o.to,c.ranges.push(n)}else t.push({from:l.from,to:o.to,ranges:[n]});r=o.number+1}return t}function Je(e,t,r){if(e.readOnly)return!1;let n=[],l=[];for(let o of N(e)){if(r?o.to==e.doc.length:o.from==0)continue;let c=e.doc.lineAt(r?o.to+1:o.from-1),s=c.length+1;if(r){n.push({from:o.to,to:c.to},{from:o.from,insert:c.text+e.lineBreak});for(let i of o.ranges)l.push(h.range(Math.min(e.doc.length,i.anchor+s),Math.min(e.doc.length,i.head+s)))}else{n.push({from:c.from,to:o.from},{from:o.to,insert:e.lineBreak+c.text});for(let i of o.ranges)l.push(h.range(i.anchor-s,i.head-s))}}return n.length?(t(e.update({changes:n,scrollIntoView:!0,selection:h.create(l,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}const $t=({state:e,dispatch:t})=>Je(e,t,!1),Wt=({state:e,dispatch:t})=>Je(e,t,!0);function Ge(e,t,r){if(e.readOnly)return!1;let n=[];for(let o of N(e))r?n.push({from:o.from,insert:e.doc.slice(o.from,o.to)+e.lineBreak}):n.push({from:o.to,insert:e.lineBreak+e.doc.slice(o.from,o.to)});let l=e.changes(n);return t(e.update({changes:l,selection:e.selection.map(l,r?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Qt=({state:e,dispatch:t})=>Ge(e,t,!1),Xt=({state:e,dispatch:t})=>Ge(e,t,!0),Yt=e=>{if(e.state.readOnly)return!1;let{state:t}=e,r=t.changes(N(t).map(({from:l,to:o})=>(l>0?l--:o<t.doc.length&&o++,{from:l,to:o}))),n=C(t.selection,l=>{let o;if(e.lineWrapping){let c=e.lineBlockAt(l.head),s=e.coordsAtPos(l.head,l.assoc||1);s&&(o=c.bottom+e.documentTop-s.bottom+e.defaultLineHeight/2)}return e.moveVertically(l,!0,o)}).map(r);return e.dispatch({changes:r,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Zt(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let r=W(e).resolveInner(t),n=r.childBefore(t),l=r.childAfter(t),o;return n&&l&&n.to<=t&&l.from>=t&&(o=n.type.prop(F.closedBy))&&o.indexOf(l.name)>-1&&e.doc.lineAt(n.to).from==e.doc.lineAt(l.from).from&&!/\S/.test(e.sliceDoc(n.to,l.from))?{from:n.to,to:l.from}:null}const re=Fe(!1),jt=Fe(!0);function Fe(e){return({state:t,dispatch:r})=>{if(t.readOnly)return!1;let n=t.changeByRange(l=>{let{from:o,to:c}=l,s=t.doc.lineAt(o),i=!e&&o==c&&Zt(t,o);e&&(o=c=(c<=s.to?s:t.doc.lineAt(c)).to);let f=new ie(t,{simulateBreak:o,simulateDoubleBreak:!!i}),u=ue(f,o);for(u==null&&(u=$(/^\s*/.exec(t.doc.lineAt(o).text)[0],t.tabSize));c<s.to&&/\s/.test(s.text[c-s.from]);)c++;i?{from:o,to:c}=i:o>s.from&&o<s.from+100&&!/\S/.test(s.text.slice(0,o))&&(o=s.from);let a=["",v(t,u)];return i&&a.push(v(t,f.lineIndent(s.from,-1))),{changes:{from:o,to:c,insert:se.of(a)},range:h.cursor(o+1+a[1].length)}});return r(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function Y(e,t){let r=-1;return e.changeByRange(n=>{let l=[];for(let c=n.from;c<=n.to;){let s=e.doc.lineAt(c);s.number>r&&(n.empty||n.to>s.from)&&(t(s,l,n),r=s.number),c=s.to+1}let o=e.changes(l);return{changes:l,range:h.range(o.mapPos(n.anchor,1),o.mapPos(n.head,1))}})}const _t=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Object.create(null),n=new ie(e,{overrideIndentation:o=>{let c=r[o];return c??-1}}),l=Y(e,(o,c,s)=>{let i=ue(n,o.from);if(i==null)return;/\S/.test(o.text)||(i=0);let f=/^\s*/.exec(o.text)[0],u=v(e,i);(f!=u||s.from<o.from+f.length)&&(r[o.from]=i,c.push({from:o.from,to:o.from+f.length,insert:u}))});return l.changes.empty||t(e.update(l,{userEvent:"indent"})),!0},wt=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Y(e,(r,n)=>{n.push({from:r.from,insert:e.facet(We)})}),{userEvent:"input.indent"})),!0),en=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Y(e,(r,n)=>{let l=/^\s*/.exec(r.text)[0];if(!l)return;let o=$(l,e.tabSize),c=0,s=v(e,Math.max(0,o-G(e)));for(;c<l.length&&c<s.length&&l.charCodeAt(c)==s.charCodeAt(c);)c++;n.push({from:r.from+c,to:r.from+l.length,insert:s.slice(c)})}),{userEvent:"delete.dedent"})),!0),tn=e=>(e.setTabFocusMode(),!0),nn=[{key:"Ctrl-b",run:ye,shift:Me,preventDefault:!0},{key:"Ctrl-f",run:ke,shift:Ee},{key:"Ctrl-p",run:Se,shift:be},{key:"Ctrl-n",run:De,shift:ve},{key:"Ctrl-a",run:At,shift:vt},{key:"Ctrl-e",run:Bt,shift:Rt},{key:"Ctrl-d",run:Ve},{key:"Ctrl-h",run:K},{key:"Ctrl-k",run:Ft},{key:"Ctrl-Alt-h",run:Pe},{key:"Ctrl-o",run:qt},{key:"Ctrl-t",run:Kt},{key:"Ctrl-v",run:q}],rn=[{key:"ArrowLeft",run:ye,shift:Me,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:ft,shift:xt,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:yt,shift:Tt,preventDefault:!0},{key:"ArrowRight",run:ke,shift:Ee,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:at,shift:Ct,preventDefault:!0},{mac:"Cmd-ArrowRight",run:kt,shift:bt,preventDefault:!0},{key:"ArrowUp",run:Se,shift:be,preventDefault:!0},{mac:"Cmd-ArrowUp",run:w,shift:te},{mac:"Ctrl-ArrowUp",run:Z,shift:j},{key:"ArrowDown",run:De,shift:ve,preventDefault:!0},{mac:"Cmd-ArrowDown",run:ee,shift:ne},{mac:"Ctrl-ArrowDown",run:q,shift:_},{key:"PageUp",run:Z,shift:j},{key:"PageDown",run:q,shift:_},{key:"Home",run:gt,shift:Ot,preventDefault:!0},{key:"Mod-Home",run:w,shift:te},{key:"End",run:pt,shift:Et,preventDefault:!0},{key:"Mod-End",run:ee,shift:ne},{key:"Enter",run:re,shift:re},{key:"Mod-a",run:It},{key:"Backspace",run:K,shift:K,preventDefault:!0},{key:"Delete",run:Ve,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Pe,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Gt,preventDefault:!0},{mac:"Mod-Backspace",run:zt,preventDefault:!0},{mac:"Mod-Delete",run:Ht,preventDefault:!0}].concat(nn.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),an=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:dt,shift:Lt},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:mt,shift:Mt},{key:"Alt-ArrowUp",run:$t},{key:"Shift-Alt-ArrowUp",run:Qt},{key:"Alt-ArrowDown",run:Wt},{key:"Shift-Alt-ArrowDown",run:Xt},{key:"Mod-Alt-ArrowUp",run:Nt},{key:"Mod-Alt-ArrowDown",run:Pt},{key:"Escape",run:Jt},{key:"Mod-Enter",run:jt},{key:"Alt-l",mac:"Ctrl-l",run:Ut},{key:"Mod-i",run:Vt,preventDefault:!0},{key:"Mod-[",run:en},{key:"Mod-]",run:wt},{key:"Mod-Alt-\\",run:_t},{key:"Shift-Mod-k",run:Yt},{key:"Shift-Mod-\\",run:Dt},{key:"Mod-/",run:Qe},{key:"Alt-A",run:Ye},{key:"Ctrl-m",mac:"Shift-Alt-m",run:tn}].concat(rn);export{Nt as addCursorAbove,Pt as addCursorBelow,Xt as copyLineDown,Qt as copyLineUp,ye as cursorCharLeft,ke as cursorCharRight,ee as cursorDocEnd,w as cursorDocStart,ft as cursorGroupLeft,at as cursorGroupRight,gt as cursorLineBoundaryBackward,pt as cursorLineBoundaryForward,yt as cursorLineBoundaryLeft,kt as cursorLineBoundaryRight,De as cursorLineDown,Bt as cursorLineEnd,At as cursorLineStart,Se as cursorLineUp,Dt as cursorMatchingBracket,q as cursorPageDown,Z as cursorPageUp,dt as cursorSyntaxLeft,mt as cursorSyntaxRight,an as defaultKeymap,K as deleteCharBackward,Ve as deleteCharForward,Pe as deleteGroupBackward,Gt as deleteGroupForward,Yt as deleteLine,zt as deleteLineBoundaryBackward,Ht as deleteLineBoundaryForward,Ft as deleteToLineEnd,nn as emacsStyleKeymap,un as history,fn as historyKeymap,en as indentLess,wt as indentMore,_t as indentSelection,jt as insertBlankLine,re as insertNewlineAndIndent,tt as invertedEffects,et as isolateHistory,Wt as moveLineDown,$t as moveLineUp,H as redo,rt as redoSelection,It as selectAll,Me as selectCharLeft,Ee as selectCharRight,ne as selectDocEnd,te as selectDocStart,xt as selectGroupLeft,Ct as selectGroupRight,Ut as selectLine,Ot as selectLineBoundaryBackward,Et as selectLineBoundaryForward,Tt as selectLineBoundaryLeft,bt as selectLineBoundaryRight,ve as selectLineDown,Rt as selectLineEnd,vt as selectLineStart,be as selectLineUp,_ as selectPageDown,j as selectPageUp,Vt as selectParentSyntax,Lt as selectSyntaxLeft,Mt as selectSyntaxRight,Jt as simplifySelection,qt as splitLine,rn as standardKeymap,Ye as toggleBlockComment,Ze as toggleBlockCommentByLine,Qe as toggleComment,Xe as toggleLineComment,tn as toggleTabFocusMode,Kt as transposeChars,de as undo,nt as undoSelection};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./DsnmJJEf.js";import{i as A}from"./24nU6DRU.js";import{p as M,l as p,s as c,d as n,g as i,a as k,c as _,n as B,r as m,b as u,e as C,m as v,t as N,f as P,h}from"./iRhbt-db.js";import{l as g,p as b,i as R}from"./Cm3t5Lw_.js";import{a as U}from"./C6NT3aAi.js";var Y=h("<title> </title>"),j=h('<svg><!><path d="M16 4 6 14 7.41 15.41 15 7.83 15 28 17 28 17 7.83 24.59 15.41 26 14 16 4z"></path></svg>');function H(x,t){const e=g(t,["children","$$slots","$$events","$$legacy"]),w=g(e,["size","title"]);M(t,!1);const a=v(),d=v();let f=b(t,"size",8,16),s=b(t,"title",8,void 0);p(()=>(n(e),n(s())),()=>{c(a,e["aria-label"]||e["aria-labelledby"]||s())}),p(()=>(i(a),n(e)),()=>{c(d,{"aria-hidden":i(a)?void 0:!0,role:i(a)?"img":void 0,focusable:Number(e.tabindex)===0?!0:void 0})}),k(),A();var r=j();U(r,()=>({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",fill:"currentColor",preserveAspectRatio:"xMidYMid meet",width:f(),height:f(),...i(d),...w}));var y=_(r);{var z=l=>{var o=Y(),$=_(o,!0);m(o),N(()=>P($,s())),u(l,o)};R(y,l=>{s()&&l(z)})}B(),m(r),u(x,r),C()}export{H as A};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{N as y,t as ee,T as g,a as W,P as Tt,b as u,I as ft,c as j,d as ne,s as re,h as se}from"./Bz0ZjVQE.js";import{countColumn as ie,EditorState as O,Facet as v,StateEffect as z,RangeSetBuilder as nt,RangeSet as xt,StateField as St,Prec as Pt,combineConfig as Ct}from"./CX_61fY8.js";import{V as R,g as oe,a as p,E as b,S as ut,D as H,G as le,W as At,l as ae}from"./Dmcboreb.js";var J;const S=new y;function It(n){return v.define({combine:n?t=>t.concat(n):void 0})}const he=new y;class d{constructor(t,e,r=[],s=""){this.data=t,this.name=s,O.prototype.hasOwnProperty("tree")||Object.defineProperty(O.prototype,"tree",{get(){return m(this)}}),this.parser=e,this.extension=[T.of(this),O.languageData.of((i,o,a)=>{let l=ct(i,o,a),h=l.type.prop(S);if(!h)return[];let f=i.facet(h),c=l.type.prop(he);if(c){let w=l.resolve(o-l.from,a);for(let k of c)if(k.test(w,i)){let P=i.facet(k.facet);return k.type=="replace"?P:P.concat(f)}}return f})].concat(r)}isActiveAt(t,e,r=-1){return ct(t,e,r).type.prop(S)==this.data}findRegions(t){let e=t.facet(T);if(e?.data==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let r=[],s=(i,o)=>{if(i.prop(S)==this.data){r.push({from:o,to:o+i.length});return}let a=i.prop(y.mounted);if(a){if(a.tree.prop(S)==this.data){if(a.overlay)for(let l of a.overlay)r.push({from:l.from+o,to:l.to+o});else r.push({from:o,to:o+i.length});return}else if(a.overlay){let l=r.length;if(s(a.tree,a.overlay[0].from+o),r.length>l)return}}for(let l=0;l<i.children.length;l++){let h=i.children[l];h instanceof g&&s(h,i.positions[l]+o)}};return s(m(t),0),r}get allowsNesting(){return!0}}d.setState=z.define();function ct(n,t,e){let r=n.facet(T),s=m(n).topNode;if(!r||r.allowsNesting)for(let i=s;i;i=i.enter(t,e,ft.ExcludeBuffers|ft.EnterBracketed))i.type.isTop&&(s=i);return s}class X extends d{constructor(t,e,r){super(t,e,[],r),this.parser=e}static define(t){let e=It(t.languageData);return new X(e,t.parser.configure({props:[S.add(r=>r.isTop?e:void 0)]}),t.name)}configure(t,e){return new X(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function m(n){let t=n.field(d.state,!1);return t?t.tree:g.empty}function fe(n,t,e=50){var r;let s=(r=n.field(d.state,!1))===null||r===void 0?void 0:r.context;if(!s)return null;let i=s.viewport;s.updateViewport({from:0,to:t});let o=s.isDone(t)||s.work(e,t)?s.tree:null;return s.updateViewport(i),o}function on(n,t=n.doc.length){var e;return((e=n.field(d.state,!1))===null||e===void 0?void 0:e.context.isDone(t))||!1}function ln(n,t=n.viewport.to,e=100){let r=fe(n.state,t,e);return r!=m(n.state)&&n.dispatch({}),!!r}function an(n){var t;return((t=n.plugin(Mt))===null||t===void 0?void 0:t.isWorking())||!1}class ue{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let r=this.cursorPos-this.string.length;return t<r||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-r,e-r)}}let M=null;class A{constructor(t,e,r=[],s,i,o,a,l){this.parser=t,this.state=e,this.fragments=r,this.tree=s,this.treeLen=i,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,e,r){return new A(t,e,[],g.empty,0,r,[],null)}startParse(){return this.parser.startParse(new ue(this.state.doc),this.fragments)}work(t,e){return e!=null&&e>=this.state.doc.length&&(e=void 0),this.tree!=g.empty&&this.isDone(e??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof t=="number"){let s=Date.now()+t;t=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),e!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let s=this.parse.advance();if(s)if(this.fragments=this.withoutTempSkipped(W.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=s,this.parse=null,this.treeLen<(e??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(W.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=M;M=this;try{return t()}finally{M=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=dt(t,e.from,e.to);return t}changes(t,e){let{fragments:r,tree:s,treeLen:i,viewport:o,skipped:a}=this;if(this.takeTree(),!t.empty){let l=[];if(t.iterChangedRanges((h,f,c,w)=>l.push({fromA:h,toA:f,fromB:c,toB:w})),r=W.applyChanges(r,l),s=g.empty,i=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){a=[];for(let h of this.skipped){let f=t.mapPos(h.from,1),c=t.mapPos(h.to,-1);f<c&&a.push({from:f,to:c})}}}return new A(this.parser,e,r,s,i,o,a,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:s,to:i}=this.skipped[r];s<t.to&&i>t.from&&(this.fragments=dt(this.fragments,s,i),this.skipped.splice(r--,1))}return this.skipped.length>=e?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends Tt{createParse(e,r,s){let i=s[0].from,o=s[s.length-1].to;return{parsedPos:i,advance(){let l=M;if(l){for(let h of s)l.tempSkipped.push(h);t&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,t]):t)}return this.parsedPos=o,new g(j.none,[],[],o-i)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&e[0].from==0&&e[0].to>=t}static get(){return M}}function dt(n,t,e){return W.applyChanges(n,[{fromA:t,toA:e,fromB:t,toB:e}])}class I{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,r)||e.takeTree(),new I(e)}static init(t){let e=Math.min(3e3,t.doc.length),r=A.create(t.facet(T).parser,t,{from:0,to:e});return r.work(20,e)||r.takeTree(),new I(r)}}d.state=St.define({create:I.init,update(n,t){for(let e of t.effects)if(e.is(d.setState))return e.value;return t.startState.facet(T)!=t.state.facet(T)?I.init(t.state):n.apply(t)}});let Dt=n=>{let t=setTimeout(()=>n(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(Dt=n=>{let t=-1,e=setTimeout(()=>{t=requestIdleCallback(n,{timeout:400})},100);return()=>t<0?clearTimeout(e):cancelIdleCallback(t)});const _=typeof navigator<"u"&&(!((J=navigator.scheduling)===null||J===void 0)&&J.isInputPending)?()=>navigator.scheduling.isInputPending():null,Mt=R.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(d.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(d.state);(e.tree!=e.context.tree||!e.context.isDone(t.doc.length))&&(this.working=Dt(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:s}}=this.view,i=r.field(d.state);if(i.tree==i.context.tree&&i.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!_?Math.max(25,t.timeRemaining()-5):1e9),a=i.context.treeLen<s&&r.doc.length>s+1e3,l=i.context.work(()=>_&&_()||Date.now()>o,s+(a?0:1e5));this.chunkBudget-=Date.now()-e,(l||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:d.setState.of(new I(i.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(e=>ae(this.view.state,e)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),T=v.define({combine(n){return n.length?n[0]:null},enables:n=>[d.state,Mt,b.contentAttributes.compute([n],t=>{let e=t.facet(n);return e&&e.name?{"data-language":e.name}:{}})]});class fn{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}class Ot{constructor(t,e,r,s,i,o=void 0){this.name=t,this.alias=e,this.extensions=r,this.filename=s,this.loadFunc=i,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(t=>this.support=t,t=>{throw this.loading=null,t}))}static of(t){let{load:e,support:r}=t;if(!e){if(!r)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");e=()=>Promise.resolve(r)}return new Ot(t.name,(t.alias||[]).concat(t.name).map(s=>s.toLowerCase()),t.extensions||[],t.filename,e,r)}static matchFilename(t,e){for(let s of t)if(s.filename&&s.filename.test(e))return s;let r=/\.([^.]+)$/.exec(e);if(r){for(let s of t)if(s.extensions.indexOf(r[1])>-1)return s}return null}static matchLanguageName(t,e,r=!0){e=e.toLowerCase();for(let s of t)if(s.alias.some(i=>i==e))return s;if(r)for(let s of t)for(let i of s.alias){let o=e.indexOf(i);if(o>-1&&(i.length>2||!/\w/.test(e[o-1])&&!/\w/.test(e[o+i.length])))return s}return null}}const ce=v.define(),Bt=v.define({combine:n=>{if(!n.length)return" ";let t=n[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return t}});function V(n){let t=n.facet(Bt);return t.charCodeAt(0)==9?n.tabSize*t.length:t.length}function Lt(n,t){let e="",r=n.tabSize,s=n.facet(Bt)[0];if(s==" "){for(;t>=r;)e+=" ",t-=r;s=" "}for(let i=0;i<t;i++)e+=s;return e}function Nt(n,t){n instanceof O&&(n=new rt(n));for(let r of n.state.facet(ce)){let s=r(n,t);if(s!==void 0)return s}let e=m(n.state);return e.length>=t?de(n,e,t):null}function un(n,t,e){let r=Object.create(null),s=new rt(n,{overrideIndentation:o=>{var a;return(a=r[o])!==null&&a!==void 0?a:-1}}),i=[];for(let o=t;o<=e;){let a=n.doc.lineAt(o);o=a.to+1;let l=Nt(s,a.from);if(l==null)continue;/\S/.test(a.text)||(l=0);let h=/^\s*/.exec(a.text)[0],f=Lt(n,l);h!=f&&(r[a.from]=l,i.push({from:a.from,to:a.from+h.length,insert:f}))}return n.changes(i)}class rt{constructor(t,e={}){this.state=t,this.options=e,this.unit=V(t)}lineAt(t,e=1){let r=this.state.doc.lineAt(t),{simulateBreak:s,simulateDoubleBreak:i}=this.options;return s!=null&&s>=r.from&&s<=r.to?i&&s==t?{text:"",from:t}:(e<0?s<t:s<=t)?{text:r.text.slice(s-r.from),from:s}:{text:r.text.slice(0,s-r.from),from:r.from}:r}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:r,from:s}=this.lineAt(t,e);return r.slice(t-s,Math.min(r.length,t+100-s))}column(t,e=1){let{text:r,from:s}=this.lineAt(t,e),i=this.countColumn(r,t-s),o=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return o>-1&&(i+=o-this.countColumn(r,r.search(/\S|$/))),i}countColumn(t,e=t.length){return ie(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:r,from:s}=this.lineAt(t,e),i=this.options.overrideIndentation;if(i){let o=i(s);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Rt=new y;function de(n,t,e){let r=t.resolveStack(e),s=t.resolveInner(e,-1).resolve(e,0).enterUnfinishedNodesBefore(e);if(s!=r.node){let i=[];for(let o=s;o&&!(o.from<r.node.from||o.to>r.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)i.push(o);for(let o=i.length-1;o>=0;o--)r={node:i[o],next:r}}return Et(r,n,e)}function Et(n,t,e){for(let r=n;r;r=r.next){let s=ge(r.node);if(s)return s(st.create(t,e,r))}return 0}function pe(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function ge(n){let t=n.type.prop(Rt);if(t)return t;let e=n.firstChild,r;if(e&&(r=e.type.prop(y.closedBy))){let s=n.lastChild,i=s&&r.indexOf(s.name)>-1;return o=>Ft(o,!0,1,void 0,i&&!pe(o)?s.from:void 0)}return n.parent==null?me:null}function me(){return 0}class st extends rt{constructor(t,e,r){super(t.state,t.options),this.base=t,this.pos=e,this.context=r}get node(){return this.context.node}static create(t,e,r){return new st(t,e,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let r=t.resolve(e.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(ke(r,t))break;e=this.state.doc.lineAt(r.from)}return this.lineIndent(e.from)}continue(){return Et(this.context.next,this.base,this.pos)}}function ke(n,t){for(let e=t;e;e=e.parent)if(n==e)return!0;return!1}function be(n){let t=n.node,e=t.childAfter(t.from),r=t.lastChild;if(!e)return null;let s=n.options.simulateBreak,i=n.state.doc.lineAt(e.from),o=s==null||s<=i.from?i.to:Math.min(i.to,s);for(let a=e.to;;){let l=t.childAfter(a);if(!l||l==r)return null;if(!l.type.isSkipped){if(l.from>=o)return null;let h=/^ */.exec(i.text.slice(e.to-i.from))[0].length;return{from:e.from,to:e.to+h}}a=l.to}}function cn({closing:n,align:t=!0,units:e=1}){return r=>Ft(r,t,e,n)}function Ft(n,t,e,r,s){let i=n.textAfter,o=i.match(/^\s*/)[0].length,a=r&&i.slice(o,o+r.length)==r||s==n.pos+o,l=t?be(n):null;return l?a?n.column(l.from):n.column(l.to):n.baseIndent+(a?0:n.unit*e)}const dn=n=>n.baseIndent;function pn({except:n,units:t=1}={}){return e=>{let r=n&&n.test(e.textAfter);return e.baseIndent+(r?0:t*e.unit)}}const we=200;function gn(){return O.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let t=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!t.length)return n;let e=n.newDoc,{head:r}=n.newSelection.main,s=e.lineAt(r);if(r>s.from+we)return n;let i=e.sliceString(s.from,r);if(!t.some(h=>h.test(i)))return n;let{state:o}=n,a=-1,l=[];for(let{head:h}of o.selection.ranges){let f=o.doc.lineAt(h);if(f.from==a)continue;a=f.from;let c=Nt(o,f.from);if(c==null)continue;let w=/^\s*/.exec(f.text)[0],k=Lt(o,c);w!=k&&l.push({from:f.from,to:f.from+w.length,insert:k})}return l.length?[n,{changes:l,sequential:!0}]:n})}const ye=v.define(),ve=new y;function mn(n){let t=n.firstChild,e=n.lastChild;return t&&t.to<e.from?{from:t.to,to:e.type.isError?n.to:e.from}:null}function Te(n,t,e){let r=m(n);if(r.length<e)return null;let s=r.resolveStack(e,1),i=null;for(let o=s;o;o=o.next){let a=o.node;if(a.to<=e||a.from>e)continue;if(i&&a.from<t)break;let l=a.type.prop(ve);if(l&&(a.to<r.length-50||r.length==n.doc.length||!xe(a))){let h=l(a,n);h&&h.from<=e&&h.from>=t&&h.to>e&&(i=h)}}return i}function xe(n){let t=n.lastChild;return t&&t.to==n.to&&t.type.isError}function B(n,t,e){for(let r of n.facet(ye)){let s=r(n,t,e);if(s)return s}return Te(n,t,e)}function Wt(n,t){let e=t.mapPos(n.from,1),r=t.mapPos(n.to,-1);return e>=r?void 0:{from:e,to:r}}const E=z.define({map:Wt}),D=z.define({map:Wt});function it(n){let t=[];for(let{head:e}of n.state.selection.ranges)t.some(r=>r.from<=e&&r.to>=e)||t.push(n.lineBlockAt(e));return t}const x=St.define({create(){return p.none},update(n,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((e,r)=>n=pt(n,e,r)),n=n.map(t.changes);for(let e of t.effects)if(e.is(E)&&!Se(n,e.value.from,e.value.to)){let{preparePlaceholder:r}=t.state.facet(lt),s=r?p.replace({widget:new Oe(r(t.state,e.value))}):gt;n=n.update({add:[s.range(e.value.from,e.value.to)]})}else e.is(D)&&(n=n.update({filter:(r,s)=>e.value.from!=r||e.value.to!=s,filterFrom:e.value.from,filterTo:e.value.to}));return t.selection&&(n=pt(n,t.selection.main.head)),n},provide:n=>b.decorations.from(n),toJSON(n,t){let e=[];return n.between(0,t.doc.length,(r,s)=>{e.push(r,s)}),e},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let e=0;e<n.length;){let r=n[e++],s=n[e++];if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid JSON for fold state");t.push(gt.range(r,s))}return p.set(t,!0)}});function pt(n,t,e=t){let r=!1;return n.between(t,e,(s,i)=>{s<e&&i>t&&(r=!0)}),r?n.update({filterFrom:t,filterTo:e,filter:(s,i)=>s>=e||i<=t}):n}function kn(n){return n.field(x,!1)||xt.empty}function L(n,t,e){var r;let s=null;return(r=n.field(x,!1))===null||r===void 0||r.between(t,e,(i,o)=>{(!s||s.from>i)&&(s={from:i,to:o})}),s}function Se(n,t,e){let r=!1;return n.between(t,t,(s,i)=>{s==t&&i==e&&(r=!0)}),r}function ot(n,t){return n.field(x,!1)?t:t.concat(z.appendConfig.of(Ut()))}const Pe=n=>{for(let t of it(n)){let e=B(n.state,t.from,t.to);if(e)return n.dispatch({effects:ot(n.state,[E.of(e),$(n,e)])}),!0}return!1},Ce=n=>{if(!n.state.field(x,!1))return!1;let t=[];for(let e of it(n)){let r=L(n.state,e.from,e.to);r&&t.push(D.of(r),$(n,r,!1))}return t.length&&n.dispatch({effects:t}),t.length>0};function $(n,t,e=!0){let r=n.state.doc.lineAt(t.from).number,s=n.state.doc.lineAt(t.to).number;return b.announce.of(`${n.state.phrase(e?"Folded lines":"Unfolded lines")} ${r} ${n.state.phrase("to")} ${s}.`)}const Ae=n=>{let{state:t}=n,e=[];for(let r=0;r<t.doc.length;){let s=n.lineBlockAt(r),i=B(t,s.from,s.to);i&&e.push(E.of(i)),r=(i?n.lineBlockAt(i.to):s).to+1}return e.length&&n.dispatch({effects:ot(n.state,e)}),!!e.length},Ie=n=>{let t=n.state.field(x,!1);if(!t||!t.size)return!1;let e=[];return t.between(0,n.state.doc.length,(r,s)=>{e.push(D.of({from:r,to:s}))}),n.dispatch({effects:e}),!0};function De(n,t){for(let e=t;;){let r=B(n.state,e.from,e.to);if(r&&r.to>t.from)return r;if(!e.from)return null;e=n.lineBlockAt(e.from-1)}}const bn=n=>{let t=[];for(let e of it(n)){let r=L(n.state,e.from,e.to);if(r)t.push(D.of(r),$(n,r,!1));else{let s=De(n,e);s&&t.push(E.of(s),$(n,s))}}return t.length>0&&n.dispatch({effects:ot(n.state,t)}),!!t.length},wn=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Pe},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Ce},{key:"Ctrl-Alt-[",run:Ae},{key:"Ctrl-Alt-]",run:Ie}],Me={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},lt=v.define({combine(n){return Ct(n,Me)}});function Ut(n){let t=[x,Le];return n&&t.push(lt.of(n)),t}function Ht(n,t){let{state:e}=n,r=e.facet(lt),s=o=>{let a=n.lineBlockAt(n.posAtDOM(o.target)),l=L(n.state,a.from,a.to);l&&n.dispatch({effects:D.of(l)}),o.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(n,s,t);let i=document.createElement("span");return i.textContent=r.placeholderText,i.setAttribute("aria-label",e.phrase("folded code")),i.title=e.phrase("unfold"),i.className="cm-foldPlaceholder",i.onclick=s,i}const gt=p.replace({widget:new class extends At{toDOM(n){return Ht(n,null)}}});class Oe extends At{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Ht(t,this.value)}}const Be={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class K extends le{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function yn(n={}){let t={...Be,...n},e=new K(t,!0),r=new K(t,!1),s=R.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(T)!=o.state.facet(T)||o.startState.field(x,!1)!=o.state.field(x,!1)||m(o.startState)!=m(o.state)||t.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let a=new nt;for(let l of o.viewportLineBlocks){let h=L(o.state,l.from,l.to)?r:B(o.state,l.from,l.to)?e:null;h&&a.add(l.from,l.from,h)}return a.finish()}}),{domEventHandlers:i}=t;return[s,oe({class:"cm-foldGutter",markers(o){var a;return((a=o.plugin(s))===null||a===void 0?void 0:a.markers)||xt.empty},initialSpacer(){return new K(t,!1)},domEventHandlers:{...i,click:(o,a,l)=>{if(i.click&&i.click(o,a,l))return!0;let h=L(o.state,a.from,a.to);if(h)return o.dispatch({effects:D.of(h)}),!0;let f=B(o.state,a.from,a.to);return f?(o.dispatch({effects:E.of(f)}),!0):!1}}}),Ut()]}const Le=b.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class G{constructor(t,e){this.specs=t;let r;function s(a){let l=ut.newName();return(r||(r=Object.create(null)))["."+l]=a,l}const i=typeof e.all=="string"?e.all:e.all?s(e.all):void 0,o=e.scope;this.scope=o instanceof d?a=>a.prop(S)==o.data:o?a=>a==o:void 0,this.style=ee(t.map(a=>({tag:a.tag,class:a.class||s(Object.assign({},a,{tag:null}))})),{all:i}).style,this.module=r?new ut(r):null,this.themeType=e.themeType}static define(t,e){return new G(t,e||{})}}const Y=v.define(),Vt=v.define({combine(n){return n.length?[n[0]]:null}});function U(n){let t=n.facet(Y);return t.length?t:n.facet(Vt)}function vn(n,t){let e=[Re],r;return n instanceof G&&(n.module&&e.push(b.styleModule.of(n.module)),r=n.themeType),t?.fallback?e.push(Vt.of(n)):r?e.push(Y.computeN([b.darkTheme],s=>s.facet(b.darkTheme)==(r=="dark")?[n]:[])):e.push(Y.of(n)),e}function Tn(n,t,e){let r=U(n),s=null;if(r){for(let i of r)if(!i.scope||e&&i.scope(e)){let o=i.style(t);o&&(s=s?s+" "+o:o)}}return s}class Ne{constructor(t){this.markCache=Object.create(null),this.tree=m(t.state),this.decorations=this.buildDeco(t,U(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=m(t.state),r=U(t.state),s=r!=U(t.startState),{viewport:i}=t.view,o=t.changes.mapPos(this.decoratedTo,1);e.length<i.to&&!s&&e.type==this.tree.type&&o>=i.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=o):(e!=this.tree||t.viewportChanged||s)&&(this.tree=e,this.decorations=this.buildDeco(t.view,r),this.decoratedTo=i.to)}buildDeco(t,e){if(!e||!this.tree.length)return p.none;let r=new nt;for(let{from:s,to:i}of t.visibleRanges)se(this.tree,e,(o,a,l)=>{r.add(o,a,this.markCache[l]||(this.markCache[l]=p.mark({class:l})))},s,i);return r.finish()}}const Re=Pt.high(R.fromClass(Ne,{decorations:n=>n.decorations})),xn=G.define([{tag:u.meta,color:"#404740"},{tag:u.link,textDecoration:"underline"},{tag:u.heading,textDecoration:"underline",fontWeight:"bold"},{tag:u.emphasis,fontStyle:"italic"},{tag:u.strong,fontWeight:"bold"},{tag:u.strikethrough,textDecoration:"line-through"},{tag:u.keyword,color:"#708"},{tag:[u.atom,u.bool,u.url,u.contentSeparator,u.labelName],color:"#219"},{tag:[u.literal,u.inserted],color:"#164"},{tag:[u.string,u.deleted],color:"#a11"},{tag:[u.regexp,u.escape,u.special(u.string)],color:"#e40"},{tag:u.definition(u.variableName),color:"#00f"},{tag:u.local(u.variableName),color:"#30a"},{tag:[u.typeName,u.namespace],color:"#085"},{tag:u.className,color:"#167"},{tag:[u.special(u.variableName),u.macroName],color:"#256"},{tag:u.definition(u.propertyName),color:"#00c"},{tag:u.comment,color:"#940"},{tag:u.invalid,color:"#f00"}]),Ee=b.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),$t=1e4,jt="()[]{}",zt=v.define({combine(n){return Ct(n,{afterCursor:!0,brackets:jt,maxScanDistance:$t,renderMatch:Ue})}}),Fe=p.mark({class:"cm-matchingBracket"}),We=p.mark({class:"cm-nonmatchingBracket"});function Ue(n){let t=[],e=n.matched?Fe:We;return t.push(e.range(n.start.from,n.start.to)),n.end&&t.push(e.range(n.end.from,n.end.to)),t}function mt(n){let t=[],e=n.facet(zt);for(let r of n.selection.ranges){if(!r.empty)continue;let s=F(n,r.head,-1,e)||r.head>0&&F(n,r.head-1,1,e)||e.afterCursor&&(F(n,r.head,1,e)||r.head<n.doc.length&&F(n,r.head+1,-1,e));s&&(t=t.concat(e.renderMatch(s,n)))}return p.set(t,!0)}const He=R.fromClass(class{constructor(n){this.paused=!1,this.decorations=mt(n.state)}update(n){(n.docChanged||n.selectionSet||this.paused)&&(n.view.composing?(this.decorations=this.decorations.map(n.changes),this.paused=!0):(this.decorations=mt(n.state),this.paused=!1))}},{decorations:n=>n.decorations}),Ve=[He,Ee];function Sn(n={}){return[zt.of(n),Ve]}const $e=new y;function Z(n,t,e){let r=n.prop(t<0?y.openedBy:y.closedBy);if(r)return r;if(n.name.length==1){let s=e.indexOf(n.name);if(s>-1&&s%2==(t<0?1:0))return[e[s+t]]}return null}function tt(n){let t=n.type.prop($e);return t?t(n.node):n}function F(n,t,e,r={}){let s=r.maxScanDistance||$t,i=r.brackets||jt,o=m(n),a=o.resolveInner(t,e);for(let l=a;l;l=l.parent){let h=Z(l.type,e,i);if(h&&l.from<l.to){let f=tt(l);if(f&&(e>0?t>=f.from&&t<f.to:t>f.from&&t<=f.to))return je(n,t,e,l,f,h,i)}}return ze(n,t,e,o,a.type,s,i)}function je(n,t,e,r,s,i,o){let a=r.parent,l={from:s.from,to:s.to},h=0,f=a?.cursor();if(f&&(e<0?f.childBefore(r.from):f.childAfter(r.to)))do if(e<0?f.to<=r.from:f.from>=r.to){if(h==0&&i.indexOf(f.type.name)>-1&&f.from<f.to){let c=tt(f);return{start:l,end:c?{from:c.from,to:c.to}:void 0,matched:!0}}else if(Z(f.type,e,o))h++;else if(Z(f.type,-e,o)){if(h==0){let c=tt(f);return{start:l,end:c&&c.from<c.to?{from:c.from,to:c.to}:void 0,matched:!1}}h--}}while(e<0?f.prevSibling():f.nextSibling());return{start:l,matched:!1}}function ze(n,t,e,r,s,i,o){let a=e<0?n.sliceDoc(t-1,t):n.sliceDoc(t,t+1),l=o.indexOf(a);if(l<0||l%2==0!=e>0)return null;let h={from:e<0?t-1:t,to:e>0?t+1:t},f=n.doc.iterRange(t,e>0?n.doc.length:0),c=0;for(let w=0;!f.next().done&&w<=i;){let k=f.value;e<0&&(w+=k.length);let P=t+w*e;for(let C=e>0?0:k.length-1,te=e>0?k.length:-1;C!=te;C+=e){let q=o.indexOf(k[C]);if(!(q<0||r.resolveInner(P+C,1).type!=s))if(q%2==0==e>0)c++;else{if(c==1)return{start:h,end:{from:P+C,to:P+C+1},matched:q>>1==l>>1};c--}}e>0&&(w+=k.length)}return f.done?{start:h,matched:!1}:null}function kt(n,t,e,r=0,s=0){t==null&&(t=n.search(/[^\s\u00a0]/),t==-1&&(t=n.length));let i=s;for(let o=r;o<t;o++)n.charCodeAt(o)==9?i+=e-i%e:i++;return i}class Gt{constructor(t,e,r,s){this.string=t,this.tabSize=e,this.indentUnit=r,this.overrideIndent=s,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let e=this.string.charAt(this.pos),r;if(typeof t=="string"?r=e==t:r=e&&(t instanceof RegExp?t.test(e):t(e)),r)return++this.pos,e}eatWhile(t){let e=this.pos;for(;this.eat(t););return this.pos>e}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=kt(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var t;return(t=this.overrideIndent)!==null&&t!==void 0?t:kt(this.string,null,this.tabSize)}match(t,e,r){if(typeof t=="string"){let s=o=>r?o.toLowerCase():o,i=this.string.substr(this.pos,t.length);return s(i)==s(t)?(e!==!1&&(this.pos+=t.length),!0):null}else{let s=this.string.slice(this.pos).match(t);return s&&s.index>0?null:(s&&e!==!1&&(this.pos+=s[0].length),s)}}current(){return this.string.slice(this.start,this.pos)}}function Ge(n){return{name:n.name||"",token:n.token,blankLine:n.blankLine||(()=>{}),startState:n.startState||(()=>!0),copyState:n.copyState||qe,indent:n.indent||(()=>null),languageData:n.languageData||{},tokenTable:n.tokenTable||ht,mergeTokens:n.mergeTokens!==!1}}function qe(n){if(typeof n!="object")return n;let t={};for(let e in n){let r=n[e];t[e]=r instanceof Array?r.slice():r}return t}const bt=new WeakMap;class qt extends d{constructor(t){let e=It(t.languageData),r=Ge(t),s,i=new class extends Tt{createParse(o,a,l){return new _e(s,o,a,l)}};super(e,i,[],t.name),this.topNode=Xe(e,this),s=this,this.streamParser=r,this.stateAfter=new y({perNode:!0}),this.tokenTable=t.tokenTable?new Qt(r.tokenTable):Qe}static define(t){return new qt(t)}getIndent(t){let e,{overrideIndentation:r}=t.options;r&&(e=bt.get(t.state),e!=null&&e<t.pos-1e4&&(e=void 0));let s=at(this,t.node.tree,t.node.from,t.node.from,e??t.pos),i,o;if(s?(o=s.state,i=s.pos+1):(o=this.streamParser.startState(t.unit),i=t.node.from),t.pos-i>1e4)return null;for(;i<t.pos;){let l=t.state.doc.lineAt(i),h=Math.min(t.pos,l.to);if(l.length){let f=r?r(l.from):-1,c=new Gt(l.text,t.state.tabSize,t.unit,f<0?void 0:f);for(;c.pos<h-l.from;)_t(this.streamParser.token,c,o)}else this.streamParser.blankLine(o,t.unit);if(h==t.pos)break;i=l.to+1}let a=t.lineAt(t.pos);return r&&e==null&&bt.set(t.state,a.from),this.streamParser.indent(o,/^\s*(.*)/.exec(a.text)[1],t)}get allowsNesting(){return!1}}function at(n,t,e,r,s){let i=e>=r&&e+t.length<=s&&t.prop(n.stateAfter);if(i)return{state:n.streamParser.copyState(i),pos:e+t.length};for(let o=t.children.length-1;o>=0;o--){let a=t.children[o],l=e+t.positions[o],h=a instanceof g&&l<s&&at(n,a,l,r,s);if(h)return h}return null}function Jt(n,t,e,r,s){if(s&&e<=0&&r>=t.length)return t;!s&&e==0&&t.type==n.topNode&&(s=!0);for(let i=t.children.length-1;i>=0;i--){let o=t.positions[i],a=t.children[i],l;if(o<r&&a instanceof g){if(!(l=Jt(n,a,e-o,r-o,s)))break;return s?new g(t.type,t.children.slice(0,i).concat(l),t.positions.slice(0,i+1),o+l.length):l}}return null}function Je(n,t,e,r,s){for(let i of t){let o=i.from+(i.openStart?25:0),a=i.to-(i.openEnd?25:0),l=o<=e&&a>e&&at(n,i.tree,0-i.offset,e,a),h;if(l&&l.pos<=r&&(h=Jt(n,i.tree,e+i.offset,l.pos+i.offset,!1)))return{state:l.state,tree:h}}return{state:n.streamParser.startState(s?V(s):4),tree:g.empty}}class _e{constructor(t,e,r,s){this.lang=t,this.input=e,this.fragments=r,this.ranges=s,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=s[s.length-1].to;let i=A.get(),o=s[0].from,{state:a,tree:l}=Je(t,r,o,this.to,i?.state);this.state=a,this.parsedPos=this.chunkStart=o+l.length;for(let h=0;h<l.children.length;h++)this.chunks.push(l.children[h]),this.chunkPos.push(l.positions[h]);i&&this.parsedPos<i.viewport.from-1e5&&s.some(h=>h.from<=i.viewport.from&&h.to>=i.viewport.from)&&(this.state=this.lang.streamParser.startState(V(i.state)),i.skipUntilInView(this.parsedPos,i.viewport.from),this.parsedPos=i.viewport.from),this.moveRangeIndex()}advance(){let t=A.get(),e=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),r=Math.min(e,this.chunkStart+512);for(t&&(r=Math.min(r,t.viewport.to));this.parsedPos<r;)this.parseLine(t);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=e?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,e),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let e=this.input.chunk(t);if(this.input.lineChunks)e==`
|
|
1
|
+
import{a as y,d as ee,c as g,e as W,P as Tt,t as u,I as ft,N as j,b as ne,s as re,h as se}from"./ChqmDGF0.js";import{countColumn as ie,EditorState as O,Facet as v,StateEffect as z,RangeSetBuilder as nt,RangeSet as xt,StateField as St,Prec as Pt,combineConfig as Ct}from"./CX_61fY8.js";import{V as R,g as oe,a as p,E as b,S as ut,D as H,G as le,W as At,l as ae}from"./Dmcboreb.js";var J;const S=new y;function It(n){return v.define({combine:n?t=>t.concat(n):void 0})}const he=new y;class d{constructor(t,e,r=[],s=""){this.data=t,this.name=s,O.prototype.hasOwnProperty("tree")||Object.defineProperty(O.prototype,"tree",{get(){return m(this)}}),this.parser=e,this.extension=[T.of(this),O.languageData.of((i,o,a)=>{let l=ct(i,o,a),h=l.type.prop(S);if(!h)return[];let f=i.facet(h),c=l.type.prop(he);if(c){let w=l.resolve(o-l.from,a);for(let k of c)if(k.test(w,i)){let P=i.facet(k.facet);return k.type=="replace"?P:P.concat(f)}}return f})].concat(r)}isActiveAt(t,e,r=-1){return ct(t,e,r).type.prop(S)==this.data}findRegions(t){let e=t.facet(T);if(e?.data==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let r=[],s=(i,o)=>{if(i.prop(S)==this.data){r.push({from:o,to:o+i.length});return}let a=i.prop(y.mounted);if(a){if(a.tree.prop(S)==this.data){if(a.overlay)for(let l of a.overlay)r.push({from:l.from+o,to:l.to+o});else r.push({from:o,to:o+i.length});return}else if(a.overlay){let l=r.length;if(s(a.tree,a.overlay[0].from+o),r.length>l)return}}for(let l=0;l<i.children.length;l++){let h=i.children[l];h instanceof g&&s(h,i.positions[l]+o)}};return s(m(t),0),r}get allowsNesting(){return!0}}d.setState=z.define();function ct(n,t,e){let r=n.facet(T),s=m(n).topNode;if(!r||r.allowsNesting)for(let i=s;i;i=i.enter(t,e,ft.ExcludeBuffers|ft.EnterBracketed))i.type.isTop&&(s=i);return s}class X extends d{constructor(t,e,r){super(t,e,[],r),this.parser=e}static define(t){let e=It(t.languageData);return new X(e,t.parser.configure({props:[S.add(r=>r.isTop?e:void 0)]}),t.name)}configure(t,e){return new X(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function m(n){let t=n.field(d.state,!1);return t?t.tree:g.empty}function fe(n,t,e=50){var r;let s=(r=n.field(d.state,!1))===null||r===void 0?void 0:r.context;if(!s)return null;let i=s.viewport;s.updateViewport({from:0,to:t});let o=s.isDone(t)||s.work(e,t)?s.tree:null;return s.updateViewport(i),o}function on(n,t=n.doc.length){var e;return((e=n.field(d.state,!1))===null||e===void 0?void 0:e.context.isDone(t))||!1}function ln(n,t=n.viewport.to,e=100){let r=fe(n.state,t,e);return r!=m(n.state)&&n.dispatch({}),!!r}function an(n){var t;return((t=n.plugin(Mt))===null||t===void 0?void 0:t.isWorking())||!1}class ue{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let r=this.cursorPos-this.string.length;return t<r||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-r,e-r)}}let M=null;class A{constructor(t,e,r=[],s,i,o,a,l){this.parser=t,this.state=e,this.fragments=r,this.tree=s,this.treeLen=i,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,e,r){return new A(t,e,[],g.empty,0,r,[],null)}startParse(){return this.parser.startParse(new ue(this.state.doc),this.fragments)}work(t,e){return e!=null&&e>=this.state.doc.length&&(e=void 0),this.tree!=g.empty&&this.isDone(e??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof t=="number"){let s=Date.now()+t;t=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),e!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let s=this.parse.advance();if(s)if(this.fragments=this.withoutTempSkipped(W.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=s,this.parse=null,this.treeLen<(e??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(W.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=M;M=this;try{return t()}finally{M=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=dt(t,e.from,e.to);return t}changes(t,e){let{fragments:r,tree:s,treeLen:i,viewport:o,skipped:a}=this;if(this.takeTree(),!t.empty){let l=[];if(t.iterChangedRanges((h,f,c,w)=>l.push({fromA:h,toA:f,fromB:c,toB:w})),r=W.applyChanges(r,l),s=g.empty,i=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){a=[];for(let h of this.skipped){let f=t.mapPos(h.from,1),c=t.mapPos(h.to,-1);f<c&&a.push({from:f,to:c})}}}return new A(this.parser,e,r,s,i,o,a,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:s,to:i}=this.skipped[r];s<t.to&&i>t.from&&(this.fragments=dt(this.fragments,s,i),this.skipped.splice(r--,1))}return this.skipped.length>=e?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends Tt{createParse(e,r,s){let i=s[0].from,o=s[s.length-1].to;return{parsedPos:i,advance(){let l=M;if(l){for(let h of s)l.tempSkipped.push(h);t&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,t]):t)}return this.parsedPos=o,new g(j.none,[],[],o-i)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&e[0].from==0&&e[0].to>=t}static get(){return M}}function dt(n,t,e){return W.applyChanges(n,[{fromA:t,toA:e,fromB:t,toB:e}])}class I{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,r)||e.takeTree(),new I(e)}static init(t){let e=Math.min(3e3,t.doc.length),r=A.create(t.facet(T).parser,t,{from:0,to:e});return r.work(20,e)||r.takeTree(),new I(r)}}d.state=St.define({create:I.init,update(n,t){for(let e of t.effects)if(e.is(d.setState))return e.value;return t.startState.facet(T)!=t.state.facet(T)?I.init(t.state):n.apply(t)}});let Dt=n=>{let t=setTimeout(()=>n(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(Dt=n=>{let t=-1,e=setTimeout(()=>{t=requestIdleCallback(n,{timeout:400})},100);return()=>t<0?clearTimeout(e):cancelIdleCallback(t)});const _=typeof navigator<"u"&&(!((J=navigator.scheduling)===null||J===void 0)&&J.isInputPending)?()=>navigator.scheduling.isInputPending():null,Mt=R.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(d.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(d.state);(e.tree!=e.context.tree||!e.context.isDone(t.doc.length))&&(this.working=Dt(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:s}}=this.view,i=r.field(d.state);if(i.tree==i.context.tree&&i.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!_?Math.max(25,t.timeRemaining()-5):1e9),a=i.context.treeLen<s&&r.doc.length>s+1e3,l=i.context.work(()=>_&&_()||Date.now()>o,s+(a?0:1e5));this.chunkBudget-=Date.now()-e,(l||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:d.setState.of(new I(i.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(e=>ae(this.view.state,e)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),T=v.define({combine(n){return n.length?n[0]:null},enables:n=>[d.state,Mt,b.contentAttributes.compute([n],t=>{let e=t.facet(n);return e&&e.name?{"data-language":e.name}:{}})]});class fn{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}class Ot{constructor(t,e,r,s,i,o=void 0){this.name=t,this.alias=e,this.extensions=r,this.filename=s,this.loadFunc=i,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(t=>this.support=t,t=>{throw this.loading=null,t}))}static of(t){let{load:e,support:r}=t;if(!e){if(!r)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");e=()=>Promise.resolve(r)}return new Ot(t.name,(t.alias||[]).concat(t.name).map(s=>s.toLowerCase()),t.extensions||[],t.filename,e,r)}static matchFilename(t,e){for(let s of t)if(s.filename&&s.filename.test(e))return s;let r=/\.([^.]+)$/.exec(e);if(r){for(let s of t)if(s.extensions.indexOf(r[1])>-1)return s}return null}static matchLanguageName(t,e,r=!0){e=e.toLowerCase();for(let s of t)if(s.alias.some(i=>i==e))return s;if(r)for(let s of t)for(let i of s.alias){let o=e.indexOf(i);if(o>-1&&(i.length>2||!/\w/.test(e[o-1])&&!/\w/.test(e[o+i.length])))return s}return null}}const ce=v.define(),Bt=v.define({combine:n=>{if(!n.length)return" ";let t=n[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return t}});function V(n){let t=n.facet(Bt);return t.charCodeAt(0)==9?n.tabSize*t.length:t.length}function Lt(n,t){let e="",r=n.tabSize,s=n.facet(Bt)[0];if(s==" "){for(;t>=r;)e+=" ",t-=r;s=" "}for(let i=0;i<t;i++)e+=s;return e}function Nt(n,t){n instanceof O&&(n=new rt(n));for(let r of n.state.facet(ce)){let s=r(n,t);if(s!==void 0)return s}let e=m(n.state);return e.length>=t?de(n,e,t):null}function un(n,t,e){let r=Object.create(null),s=new rt(n,{overrideIndentation:o=>{var a;return(a=r[o])!==null&&a!==void 0?a:-1}}),i=[];for(let o=t;o<=e;){let a=n.doc.lineAt(o);o=a.to+1;let l=Nt(s,a.from);if(l==null)continue;/\S/.test(a.text)||(l=0);let h=/^\s*/.exec(a.text)[0],f=Lt(n,l);h!=f&&(r[a.from]=l,i.push({from:a.from,to:a.from+h.length,insert:f}))}return n.changes(i)}class rt{constructor(t,e={}){this.state=t,this.options=e,this.unit=V(t)}lineAt(t,e=1){let r=this.state.doc.lineAt(t),{simulateBreak:s,simulateDoubleBreak:i}=this.options;return s!=null&&s>=r.from&&s<=r.to?i&&s==t?{text:"",from:t}:(e<0?s<t:s<=t)?{text:r.text.slice(s-r.from),from:s}:{text:r.text.slice(0,s-r.from),from:r.from}:r}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:r,from:s}=this.lineAt(t,e);return r.slice(t-s,Math.min(r.length,t+100-s))}column(t,e=1){let{text:r,from:s}=this.lineAt(t,e),i=this.countColumn(r,t-s),o=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return o>-1&&(i+=o-this.countColumn(r,r.search(/\S|$/))),i}countColumn(t,e=t.length){return ie(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:r,from:s}=this.lineAt(t,e),i=this.options.overrideIndentation;if(i){let o=i(s);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Rt=new y;function de(n,t,e){let r=t.resolveStack(e),s=t.resolveInner(e,-1).resolve(e,0).enterUnfinishedNodesBefore(e);if(s!=r.node){let i=[];for(let o=s;o&&!(o.from<r.node.from||o.to>r.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)i.push(o);for(let o=i.length-1;o>=0;o--)r={node:i[o],next:r}}return Et(r,n,e)}function Et(n,t,e){for(let r=n;r;r=r.next){let s=ge(r.node);if(s)return s(st.create(t,e,r))}return 0}function pe(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function ge(n){let t=n.type.prop(Rt);if(t)return t;let e=n.firstChild,r;if(e&&(r=e.type.prop(y.closedBy))){let s=n.lastChild,i=s&&r.indexOf(s.name)>-1;return o=>Ft(o,!0,1,void 0,i&&!pe(o)?s.from:void 0)}return n.parent==null?me:null}function me(){return 0}class st extends rt{constructor(t,e,r){super(t.state,t.options),this.base=t,this.pos=e,this.context=r}get node(){return this.context.node}static create(t,e,r){return new st(t,e,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let r=t.resolve(e.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(ke(r,t))break;e=this.state.doc.lineAt(r.from)}return this.lineIndent(e.from)}continue(){return Et(this.context.next,this.base,this.pos)}}function ke(n,t){for(let e=t;e;e=e.parent)if(n==e)return!0;return!1}function be(n){let t=n.node,e=t.childAfter(t.from),r=t.lastChild;if(!e)return null;let s=n.options.simulateBreak,i=n.state.doc.lineAt(e.from),o=s==null||s<=i.from?i.to:Math.min(i.to,s);for(let a=e.to;;){let l=t.childAfter(a);if(!l||l==r)return null;if(!l.type.isSkipped){if(l.from>=o)return null;let h=/^ */.exec(i.text.slice(e.to-i.from))[0].length;return{from:e.from,to:e.to+h}}a=l.to}}function cn({closing:n,align:t=!0,units:e=1}){return r=>Ft(r,t,e,n)}function Ft(n,t,e,r,s){let i=n.textAfter,o=i.match(/^\s*/)[0].length,a=r&&i.slice(o,o+r.length)==r||s==n.pos+o,l=t?be(n):null;return l?a?n.column(l.from):n.column(l.to):n.baseIndent+(a?0:n.unit*e)}const dn=n=>n.baseIndent;function pn({except:n,units:t=1}={}){return e=>{let r=n&&n.test(e.textAfter);return e.baseIndent+(r?0:t*e.unit)}}const we=200;function gn(){return O.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let t=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!t.length)return n;let e=n.newDoc,{head:r}=n.newSelection.main,s=e.lineAt(r);if(r>s.from+we)return n;let i=e.sliceString(s.from,r);if(!t.some(h=>h.test(i)))return n;let{state:o}=n,a=-1,l=[];for(let{head:h}of o.selection.ranges){let f=o.doc.lineAt(h);if(f.from==a)continue;a=f.from;let c=Nt(o,f.from);if(c==null)continue;let w=/^\s*/.exec(f.text)[0],k=Lt(o,c);w!=k&&l.push({from:f.from,to:f.from+w.length,insert:k})}return l.length?[n,{changes:l,sequential:!0}]:n})}const ye=v.define(),ve=new y;function mn(n){let t=n.firstChild,e=n.lastChild;return t&&t.to<e.from?{from:t.to,to:e.type.isError?n.to:e.from}:null}function Te(n,t,e){let r=m(n);if(r.length<e)return null;let s=r.resolveStack(e,1),i=null;for(let o=s;o;o=o.next){let a=o.node;if(a.to<=e||a.from>e)continue;if(i&&a.from<t)break;let l=a.type.prop(ve);if(l&&(a.to<r.length-50||r.length==n.doc.length||!xe(a))){let h=l(a,n);h&&h.from<=e&&h.from>=t&&h.to>e&&(i=h)}}return i}function xe(n){let t=n.lastChild;return t&&t.to==n.to&&t.type.isError}function B(n,t,e){for(let r of n.facet(ye)){let s=r(n,t,e);if(s)return s}return Te(n,t,e)}function Wt(n,t){let e=t.mapPos(n.from,1),r=t.mapPos(n.to,-1);return e>=r?void 0:{from:e,to:r}}const E=z.define({map:Wt}),D=z.define({map:Wt});function it(n){let t=[];for(let{head:e}of n.state.selection.ranges)t.some(r=>r.from<=e&&r.to>=e)||t.push(n.lineBlockAt(e));return t}const x=St.define({create(){return p.none},update(n,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((e,r)=>n=pt(n,e,r)),n=n.map(t.changes);for(let e of t.effects)if(e.is(E)&&!Se(n,e.value.from,e.value.to)){let{preparePlaceholder:r}=t.state.facet(lt),s=r?p.replace({widget:new Oe(r(t.state,e.value))}):gt;n=n.update({add:[s.range(e.value.from,e.value.to)]})}else e.is(D)&&(n=n.update({filter:(r,s)=>e.value.from!=r||e.value.to!=s,filterFrom:e.value.from,filterTo:e.value.to}));return t.selection&&(n=pt(n,t.selection.main.head)),n},provide:n=>b.decorations.from(n),toJSON(n,t){let e=[];return n.between(0,t.doc.length,(r,s)=>{e.push(r,s)}),e},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let e=0;e<n.length;){let r=n[e++],s=n[e++];if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid JSON for fold state");t.push(gt.range(r,s))}return p.set(t,!0)}});function pt(n,t,e=t){let r=!1;return n.between(t,e,(s,i)=>{s<e&&i>t&&(r=!0)}),r?n.update({filterFrom:t,filterTo:e,filter:(s,i)=>s>=e||i<=t}):n}function kn(n){return n.field(x,!1)||xt.empty}function L(n,t,e){var r;let s=null;return(r=n.field(x,!1))===null||r===void 0||r.between(t,e,(i,o)=>{(!s||s.from>i)&&(s={from:i,to:o})}),s}function Se(n,t,e){let r=!1;return n.between(t,t,(s,i)=>{s==t&&i==e&&(r=!0)}),r}function ot(n,t){return n.field(x,!1)?t:t.concat(z.appendConfig.of(Ut()))}const Pe=n=>{for(let t of it(n)){let e=B(n.state,t.from,t.to);if(e)return n.dispatch({effects:ot(n.state,[E.of(e),$(n,e)])}),!0}return!1},Ce=n=>{if(!n.state.field(x,!1))return!1;let t=[];for(let e of it(n)){let r=L(n.state,e.from,e.to);r&&t.push(D.of(r),$(n,r,!1))}return t.length&&n.dispatch({effects:t}),t.length>0};function $(n,t,e=!0){let r=n.state.doc.lineAt(t.from).number,s=n.state.doc.lineAt(t.to).number;return b.announce.of(`${n.state.phrase(e?"Folded lines":"Unfolded lines")} ${r} ${n.state.phrase("to")} ${s}.`)}const Ae=n=>{let{state:t}=n,e=[];for(let r=0;r<t.doc.length;){let s=n.lineBlockAt(r),i=B(t,s.from,s.to);i&&e.push(E.of(i)),r=(i?n.lineBlockAt(i.to):s).to+1}return e.length&&n.dispatch({effects:ot(n.state,e)}),!!e.length},Ie=n=>{let t=n.state.field(x,!1);if(!t||!t.size)return!1;let e=[];return t.between(0,n.state.doc.length,(r,s)=>{e.push(D.of({from:r,to:s}))}),n.dispatch({effects:e}),!0};function De(n,t){for(let e=t;;){let r=B(n.state,e.from,e.to);if(r&&r.to>t.from)return r;if(!e.from)return null;e=n.lineBlockAt(e.from-1)}}const bn=n=>{let t=[];for(let e of it(n)){let r=L(n.state,e.from,e.to);if(r)t.push(D.of(r),$(n,r,!1));else{let s=De(n,e);s&&t.push(E.of(s),$(n,s))}}return t.length>0&&n.dispatch({effects:ot(n.state,t)}),!!t.length},wn=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Pe},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Ce},{key:"Ctrl-Alt-[",run:Ae},{key:"Ctrl-Alt-]",run:Ie}],Me={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},lt=v.define({combine(n){return Ct(n,Me)}});function Ut(n){let t=[x,Le];return n&&t.push(lt.of(n)),t}function Ht(n,t){let{state:e}=n,r=e.facet(lt),s=o=>{let a=n.lineBlockAt(n.posAtDOM(o.target)),l=L(n.state,a.from,a.to);l&&n.dispatch({effects:D.of(l)}),o.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(n,s,t);let i=document.createElement("span");return i.textContent=r.placeholderText,i.setAttribute("aria-label",e.phrase("folded code")),i.title=e.phrase("unfold"),i.className="cm-foldPlaceholder",i.onclick=s,i}const gt=p.replace({widget:new class extends At{toDOM(n){return Ht(n,null)}}});class Oe extends At{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Ht(t,this.value)}}const Be={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class K extends le{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function yn(n={}){let t={...Be,...n},e=new K(t,!0),r=new K(t,!1),s=R.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(T)!=o.state.facet(T)||o.startState.field(x,!1)!=o.state.field(x,!1)||m(o.startState)!=m(o.state)||t.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let a=new nt;for(let l of o.viewportLineBlocks){let h=L(o.state,l.from,l.to)?r:B(o.state,l.from,l.to)?e:null;h&&a.add(l.from,l.from,h)}return a.finish()}}),{domEventHandlers:i}=t;return[s,oe({class:"cm-foldGutter",markers(o){var a;return((a=o.plugin(s))===null||a===void 0?void 0:a.markers)||xt.empty},initialSpacer(){return new K(t,!1)},domEventHandlers:{...i,click:(o,a,l)=>{if(i.click&&i.click(o,a,l))return!0;let h=L(o.state,a.from,a.to);if(h)return o.dispatch({effects:D.of(h)}),!0;let f=B(o.state,a.from,a.to);return f?(o.dispatch({effects:E.of(f)}),!0):!1}}}),Ut()]}const Le=b.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class G{constructor(t,e){this.specs=t;let r;function s(a){let l=ut.newName();return(r||(r=Object.create(null)))["."+l]=a,l}const i=typeof e.all=="string"?e.all:e.all?s(e.all):void 0,o=e.scope;this.scope=o instanceof d?a=>a.prop(S)==o.data:o?a=>a==o:void 0,this.style=ee(t.map(a=>({tag:a.tag,class:a.class||s(Object.assign({},a,{tag:null}))})),{all:i}).style,this.module=r?new ut(r):null,this.themeType=e.themeType}static define(t,e){return new G(t,e||{})}}const Y=v.define(),Vt=v.define({combine(n){return n.length?[n[0]]:null}});function U(n){let t=n.facet(Y);return t.length?t:n.facet(Vt)}function vn(n,t){let e=[Re],r;return n instanceof G&&(n.module&&e.push(b.styleModule.of(n.module)),r=n.themeType),t?.fallback?e.push(Vt.of(n)):r?e.push(Y.computeN([b.darkTheme],s=>s.facet(b.darkTheme)==(r=="dark")?[n]:[])):e.push(Y.of(n)),e}function Tn(n,t,e){let r=U(n),s=null;if(r){for(let i of r)if(!i.scope||e&&i.scope(e)){let o=i.style(t);o&&(s=s?s+" "+o:o)}}return s}class Ne{constructor(t){this.markCache=Object.create(null),this.tree=m(t.state),this.decorations=this.buildDeco(t,U(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=m(t.state),r=U(t.state),s=r!=U(t.startState),{viewport:i}=t.view,o=t.changes.mapPos(this.decoratedTo,1);e.length<i.to&&!s&&e.type==this.tree.type&&o>=i.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=o):(e!=this.tree||t.viewportChanged||s)&&(this.tree=e,this.decorations=this.buildDeco(t.view,r),this.decoratedTo=i.to)}buildDeco(t,e){if(!e||!this.tree.length)return p.none;let r=new nt;for(let{from:s,to:i}of t.visibleRanges)se(this.tree,e,(o,a,l)=>{r.add(o,a,this.markCache[l]||(this.markCache[l]=p.mark({class:l})))},s,i);return r.finish()}}const Re=Pt.high(R.fromClass(Ne,{decorations:n=>n.decorations})),xn=G.define([{tag:u.meta,color:"#404740"},{tag:u.link,textDecoration:"underline"},{tag:u.heading,textDecoration:"underline",fontWeight:"bold"},{tag:u.emphasis,fontStyle:"italic"},{tag:u.strong,fontWeight:"bold"},{tag:u.strikethrough,textDecoration:"line-through"},{tag:u.keyword,color:"#708"},{tag:[u.atom,u.bool,u.url,u.contentSeparator,u.labelName],color:"#219"},{tag:[u.literal,u.inserted],color:"#164"},{tag:[u.string,u.deleted],color:"#a11"},{tag:[u.regexp,u.escape,u.special(u.string)],color:"#e40"},{tag:u.definition(u.variableName),color:"#00f"},{tag:u.local(u.variableName),color:"#30a"},{tag:[u.typeName,u.namespace],color:"#085"},{tag:u.className,color:"#167"},{tag:[u.special(u.variableName),u.macroName],color:"#256"},{tag:u.definition(u.propertyName),color:"#00c"},{tag:u.comment,color:"#940"},{tag:u.invalid,color:"#f00"}]),Ee=b.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),$t=1e4,jt="()[]{}",zt=v.define({combine(n){return Ct(n,{afterCursor:!0,brackets:jt,maxScanDistance:$t,renderMatch:Ue})}}),Fe=p.mark({class:"cm-matchingBracket"}),We=p.mark({class:"cm-nonmatchingBracket"});function Ue(n){let t=[],e=n.matched?Fe:We;return t.push(e.range(n.start.from,n.start.to)),n.end&&t.push(e.range(n.end.from,n.end.to)),t}function mt(n){let t=[],e=n.facet(zt);for(let r of n.selection.ranges){if(!r.empty)continue;let s=F(n,r.head,-1,e)||r.head>0&&F(n,r.head-1,1,e)||e.afterCursor&&(F(n,r.head,1,e)||r.head<n.doc.length&&F(n,r.head+1,-1,e));s&&(t=t.concat(e.renderMatch(s,n)))}return p.set(t,!0)}const He=R.fromClass(class{constructor(n){this.paused=!1,this.decorations=mt(n.state)}update(n){(n.docChanged||n.selectionSet||this.paused)&&(n.view.composing?(this.decorations=this.decorations.map(n.changes),this.paused=!0):(this.decorations=mt(n.state),this.paused=!1))}},{decorations:n=>n.decorations}),Ve=[He,Ee];function Sn(n={}){return[zt.of(n),Ve]}const $e=new y;function Z(n,t,e){let r=n.prop(t<0?y.openedBy:y.closedBy);if(r)return r;if(n.name.length==1){let s=e.indexOf(n.name);if(s>-1&&s%2==(t<0?1:0))return[e[s+t]]}return null}function tt(n){let t=n.type.prop($e);return t?t(n.node):n}function F(n,t,e,r={}){let s=r.maxScanDistance||$t,i=r.brackets||jt,o=m(n),a=o.resolveInner(t,e);for(let l=a;l;l=l.parent){let h=Z(l.type,e,i);if(h&&l.from<l.to){let f=tt(l);if(f&&(e>0?t>=f.from&&t<f.to:t>f.from&&t<=f.to))return je(n,t,e,l,f,h,i)}}return ze(n,t,e,o,a.type,s,i)}function je(n,t,e,r,s,i,o){let a=r.parent,l={from:s.from,to:s.to},h=0,f=a?.cursor();if(f&&(e<0?f.childBefore(r.from):f.childAfter(r.to)))do if(e<0?f.to<=r.from:f.from>=r.to){if(h==0&&i.indexOf(f.type.name)>-1&&f.from<f.to){let c=tt(f);return{start:l,end:c?{from:c.from,to:c.to}:void 0,matched:!0}}else if(Z(f.type,e,o))h++;else if(Z(f.type,-e,o)){if(h==0){let c=tt(f);return{start:l,end:c&&c.from<c.to?{from:c.from,to:c.to}:void 0,matched:!1}}h--}}while(e<0?f.prevSibling():f.nextSibling());return{start:l,matched:!1}}function ze(n,t,e,r,s,i,o){let a=e<0?n.sliceDoc(t-1,t):n.sliceDoc(t,t+1),l=o.indexOf(a);if(l<0||l%2==0!=e>0)return null;let h={from:e<0?t-1:t,to:e>0?t+1:t},f=n.doc.iterRange(t,e>0?n.doc.length:0),c=0;for(let w=0;!f.next().done&&w<=i;){let k=f.value;e<0&&(w+=k.length);let P=t+w*e;for(let C=e>0?0:k.length-1,te=e>0?k.length:-1;C!=te;C+=e){let q=o.indexOf(k[C]);if(!(q<0||r.resolveInner(P+C,1).type!=s))if(q%2==0==e>0)c++;else{if(c==1)return{start:h,end:{from:P+C,to:P+C+1},matched:q>>1==l>>1};c--}}e>0&&(w+=k.length)}return f.done?{start:h,matched:!1}:null}function kt(n,t,e,r=0,s=0){t==null&&(t=n.search(/[^\s\u00a0]/),t==-1&&(t=n.length));let i=s;for(let o=r;o<t;o++)n.charCodeAt(o)==9?i+=e-i%e:i++;return i}class Gt{constructor(t,e,r,s){this.string=t,this.tabSize=e,this.indentUnit=r,this.overrideIndent=s,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let e=this.string.charAt(this.pos),r;if(typeof t=="string"?r=e==t:r=e&&(t instanceof RegExp?t.test(e):t(e)),r)return++this.pos,e}eatWhile(t){let e=this.pos;for(;this.eat(t););return this.pos>e}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=kt(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var t;return(t=this.overrideIndent)!==null&&t!==void 0?t:kt(this.string,null,this.tabSize)}match(t,e,r){if(typeof t=="string"){let s=o=>r?o.toLowerCase():o,i=this.string.substr(this.pos,t.length);return s(i)==s(t)?(e!==!1&&(this.pos+=t.length),!0):null}else{let s=this.string.slice(this.pos).match(t);return s&&s.index>0?null:(s&&e!==!1&&(this.pos+=s[0].length),s)}}current(){return this.string.slice(this.start,this.pos)}}function Ge(n){return{name:n.name||"",token:n.token,blankLine:n.blankLine||(()=>{}),startState:n.startState||(()=>!0),copyState:n.copyState||qe,indent:n.indent||(()=>null),languageData:n.languageData||{},tokenTable:n.tokenTable||ht,mergeTokens:n.mergeTokens!==!1}}function qe(n){if(typeof n!="object")return n;let t={};for(let e in n){let r=n[e];t[e]=r instanceof Array?r.slice():r}return t}const bt=new WeakMap;class qt extends d{constructor(t){let e=It(t.languageData),r=Ge(t),s,i=new class extends Tt{createParse(o,a,l){return new _e(s,o,a,l)}};super(e,i,[],t.name),this.topNode=Xe(e,this),s=this,this.streamParser=r,this.stateAfter=new y({perNode:!0}),this.tokenTable=t.tokenTable?new Qt(r.tokenTable):Qe}static define(t){return new qt(t)}getIndent(t){let e,{overrideIndentation:r}=t.options;r&&(e=bt.get(t.state),e!=null&&e<t.pos-1e4&&(e=void 0));let s=at(this,t.node.tree,t.node.from,t.node.from,e??t.pos),i,o;if(s?(o=s.state,i=s.pos+1):(o=this.streamParser.startState(t.unit),i=t.node.from),t.pos-i>1e4)return null;for(;i<t.pos;){let l=t.state.doc.lineAt(i),h=Math.min(t.pos,l.to);if(l.length){let f=r?r(l.from):-1,c=new Gt(l.text,t.state.tabSize,t.unit,f<0?void 0:f);for(;c.pos<h-l.from;)_t(this.streamParser.token,c,o)}else this.streamParser.blankLine(o,t.unit);if(h==t.pos)break;i=l.to+1}let a=t.lineAt(t.pos);return r&&e==null&&bt.set(t.state,a.from),this.streamParser.indent(o,/^\s*(.*)/.exec(a.text)[1],t)}get allowsNesting(){return!1}}function at(n,t,e,r,s){let i=e>=r&&e+t.length<=s&&t.prop(n.stateAfter);if(i)return{state:n.streamParser.copyState(i),pos:e+t.length};for(let o=t.children.length-1;o>=0;o--){let a=t.children[o],l=e+t.positions[o],h=a instanceof g&&l<s&&at(n,a,l,r,s);if(h)return h}return null}function Jt(n,t,e,r,s){if(s&&e<=0&&r>=t.length)return t;!s&&e==0&&t.type==n.topNode&&(s=!0);for(let i=t.children.length-1;i>=0;i--){let o=t.positions[i],a=t.children[i],l;if(o<r&&a instanceof g){if(!(l=Jt(n,a,e-o,r-o,s)))break;return s?new g(t.type,t.children.slice(0,i).concat(l),t.positions.slice(0,i+1),o+l.length):l}}return null}function Je(n,t,e,r,s){for(let i of t){let o=i.from+(i.openStart?25:0),a=i.to-(i.openEnd?25:0),l=o<=e&&a>e&&at(n,i.tree,0-i.offset,e,a),h;if(l&&l.pos<=r&&(h=Jt(n,i.tree,e+i.offset,l.pos+i.offset,!1)))return{state:l.state,tree:h}}return{state:n.streamParser.startState(s?V(s):4),tree:g.empty}}class _e{constructor(t,e,r,s){this.lang=t,this.input=e,this.fragments=r,this.ranges=s,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=s[s.length-1].to;let i=A.get(),o=s[0].from,{state:a,tree:l}=Je(t,r,o,this.to,i?.state);this.state=a,this.parsedPos=this.chunkStart=o+l.length;for(let h=0;h<l.children.length;h++)this.chunks.push(l.children[h]),this.chunkPos.push(l.positions[h]);i&&this.parsedPos<i.viewport.from-1e5&&s.some(h=>h.from<=i.viewport.from&&h.to>=i.viewport.from)&&(this.state=this.lang.streamParser.startState(V(i.state)),i.skipUntilInView(this.parsedPos,i.viewport.from),this.parsedPos=i.viewport.from),this.moveRangeIndex()}advance(){let t=A.get(),e=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),r=Math.min(e,this.chunkStart+512);for(t&&(r=Math.min(r,t.viewport.to));this.parsedPos<r;)this.parseLine(t);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=e?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,e),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let e=this.input.chunk(t);if(this.input.lineChunks)e==`
|
|
2
2
|
`&&(e="");else{let r=e.indexOf(`
|
|
3
3
|
`);r>-1&&(e=e.slice(0,r))}return t+e.length<=this.to?e:e.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,e=this.lineAfter(t),r=t+e.length;for(let s=this.rangeIndex;;){let i=this.ranges[s].to;if(i>=r||(e=e.slice(0,i-(r-e.length)),s++,s==this.ranges.length))break;let o=this.ranges[s].from,a=this.lineAfter(o);e+=a,r=o+a.length}return{line:e,end:r}}skipGapsTo(t,e,r){for(;;){let s=this.ranges[this.rangeIndex].to,i=t+e;if(r>0?s>i:s>=i)break;let o=this.ranges[++this.rangeIndex].from;e+=o-s}return e}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,e,r,s){let i=4;if(this.ranges.length>1){s=this.skipGapsTo(e,s,1),e+=s;let a=this.chunk.length;s=this.skipGapsTo(r,s,-1),r+=s,i+=this.chunk.length-a}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&i==4&&o>=0&&this.chunk[o]==t&&this.chunk[o+2]==e?this.chunk[o+2]=r:this.chunk.push(t,e,r,i),s}parseLine(t){let{line:e,end:r}=this.nextLine(),s=0,{streamParser:i}=this.lang,o=new Gt(e,t?t.state.tabSize:4,t?V(t.state):2);if(o.eol())i.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let a=_t(i.token,o,this.state);if(a&&(s=this.emitToken(this.lang.tokenTable.resolve(a),this.parsedPos+o.start,this.parsedPos+o.pos,s)),o.start>1e4)break}this.parsedPos=r,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=g.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Ke,topID:0,maxBufferLength:512,reused:this.chunkReused});t=new g(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new g(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function _t(n,t,e){t.start=t.pos;for(let r=0;r<10;r++){let s=n(t,e);if(t.pos>t.start)return s}throw new Error("Stream parser failed to advance stream.")}const ht=Object.create(null),N=[j.none],Ke=new ne(N),wt=[],yt=Object.create(null),Kt=Object.create(null);for(let[n,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Kt[n]=Xt(ht,t);class Qt{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Kt)}resolve(t){return t?this.table[t]||(this.table[t]=Xt(this.extra,t)):0}}const Qe=new Qt(ht);function Q(n,t){wt.indexOf(n)>-1||(wt.push(n),console.warn(t))}function Xt(n,t){let e=[];for(let a of t.split(" ")){let l=[];for(let h of a.split(".")){let f=n[h]||u[h];f?typeof f=="function"?l.length?l=l.map(f):Q(h,`Modifier ${h} used at start of tag`):l.length?Q(h,`Tag ${h} used as modifier`):l=Array.isArray(f)?f:[f]:Q(h,`Unknown highlighting tag ${h}`)}for(let h of l)e.push(h)}if(!e.length)return 0;let r=t.replace(/ /g,"_"),s=r+" "+e.map(a=>a.id),i=yt[s];if(i)return i.id;let o=yt[s]=j.define({id:N.length,name:r,props:[re({[r]:e})]});return N.push(o),o.id}function Xe(n,t){let e=j.define({id:N.length,name:"Document",props:[S.add(()=>n),Rt.add(()=>r=>t.getIndent(r))],top:!0});return N.push(e),e}function Yt(n){return n.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(n)}function Zt(n){for(let t=n.iter();!t.next().done;)if(Yt(t.value))return!0;return!1}function Ye(n){let t=!1;return n.iterChanges((e,r,s,i,o)=>{!t&&Zt(o)&&(t=!0)}),t}const et=v.define({combine:n=>n.some(t=>t)});function Pn(n={}){let t=[Ze];return n.alwaysIsolate&&t.push(et.of(!0)),t}const Ze=R.fromClass(class{constructor(n){this.always=n.state.facet(et)||n.textDirection!=H.LTR||n.state.facet(b.perLineTextDirection),this.hasRTL=!this.always&&Zt(n.state.doc),this.tree=m(n.state),this.decorations=this.always||this.hasRTL?vt(n,this.tree,this.always):p.none}update(n){let t=n.state.facet(et)||n.view.textDirection!=H.LTR||n.state.facet(b.perLineTextDirection);if(!t&&!this.hasRTL&&Ye(n.changes)&&(this.hasRTL=!0),!t&&!this.hasRTL)return;let e=m(n.state);(t!=this.always||e!=this.tree||n.docChanged||n.viewportChanged)&&(this.tree=e,this.always=t,this.decorations=vt(n.view,e,t))}},{provide:n=>{function t(e){var r,s;return(s=(r=e.plugin(n))===null||r===void 0?void 0:r.decorations)!==null&&s!==void 0?s:p.none}return[b.outerDecorations.of(t),Pt.lowest(b.bidiIsolatedRanges.of(t))]}});function vt(n,t,e){let r=new nt,s=n.visibleRanges;e||(s=tn(s,n.state.doc));for(let{from:i,to:o}of s)t.iterate({enter:a=>{let l=a.type.prop(y.isolate);l&&r.add(a.from,a.to,en[l])},from:i,to:o});return r.finish()}function tn(n,t){let e=t.iter(),r=0,s=[],i=null;for(let{from:o,to:a}of n)if(!(i&&i.to>o&&(o=i.to,o>=a)))for(r+e.value.length<o&&(e.next(o-(r+e.value.length)),r=o);;){let l=r,h=r+e.value.length;if(!e.lineBreak&&Yt(e.value)&&(i&&i.to>l-10?i.to=Math.min(a,h):s.push(i={from:l,to:Math.min(a,h)})),h>=a)break;r=h,e.next()}return s}const en={rtl:p.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:H.RTL}),ltr:p.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:H.LTR}),auto:p.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};export{ue as DocInput,G as HighlightStyle,rt as IndentContext,X as LRLanguage,d as Language,Ot as LanguageDescription,fn as LanguageSupport,A as ParseContext,qt as StreamLanguage,Gt as StringStream,st as TreeIndentContext,Pn as bidiIsolates,Sn as bracketMatching,$e as bracketMatchingHandle,Ut as codeFolding,pn as continuedIndent,xn as defaultHighlightStyle,It as defineLanguageFacet,cn as delimitedIndent,fe as ensureSyntaxTree,dn as flatIndent,Ae as foldAll,Pe as foldCode,E as foldEffect,yn as foldGutter,mn as foldInside,wn as foldKeymap,ve as foldNodeProp,ye as foldService,x as foldState,B as foldable,kn as foldedRanges,ln as forceParsing,V as getIndentUnit,Nt as getIndentation,Tn as highlightingFor,Rt as indentNodeProp,gn as indentOnInput,un as indentRange,ce as indentService,Lt as indentString,Bt as indentUnit,T as language,S as languageDataProp,F as matchBrackets,he as sublanguageProp,vn as syntaxHighlighting,an as syntaxParserRunning,m as syntaxTree,on as syntaxTreeAvailable,bn as toggleFold,Ie as unfoldAll,Ce as unfoldCode,D as unfoldEffect};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./DsnmJJEf.js";import{aD as X,i as D,s as C,g as h,u as O,aE as gt,p as rt,S as A,j as F,b as P,e as it,c as Y,N as Q,r as j,k as ht}from"./iRhbt-db.js";import{s as H,a as B}from"./C6NT3aAi.js";import{p as u,i as G,s as dt,r as Ct}from"./Cm3t5Lw_.js";import{w as at,g as Tt,i as k,C as Ot,a as yt,D as _t,b as U,E as xt,S as It,c as bt,d as Dt,e as At,P as ft,f,h as Ft,j as wt,n as E,k as Mt,l as Ht,m as J,o as mt,F as kt,p as Et}from"./DBrWPzSo.js";function ot(p,t){const[e,s]=p;let n=!1;const o=t.length;for(let i=0,r=o-1;i<o;r=i++){const[v,y]=t[i]??[0,0],[_,m]=t[r]??[0,0];y>=s!=m>=s&&e<=(_-v)*(s-y)/(m-y)+v&&(n=!n)}return n}function nt(p,t){return p[0]>=t.left&&p[0]<=t.right&&p[1]>=t.top&&p[1]<=t.bottom}function vt(p,t){const e=p.left+p.width/2,s=p.top+p.height/2,n=t.left+t.width/2,o=t.top+t.height/2,i=n-e,r=o-s;return Math.abs(i)>Math.abs(r)?i>0?"right":"left":r>0?"bottom":"top"}class St{#t;#n;#r;#s=null;#e=null;#a=[];#l=null;#o=null;#i=null;#h(){this.#o!==null&&(cancelAnimationFrame(this.#o),this.#o=null)}#p(){this.#h(),this.#o=requestAnimationFrame(()=>{this.#o=null,!(!this.#s||!this.#e)&&(this.#u(),this.#t.onPointerExit())})}#c(){this.#i!==null&&(clearTimeout(this.#i),this.#i=null)}#f(){this.#r!==null&&(this.#c(),this.#i=window.setTimeout(()=>{this.#i=null,!(!this.#s||!this.#e)&&(this.#u(),this.#t.onPointerExit())},this.#r))}constructor(t){this.#t=t,this.#n=t.buffer??1;const e=t.transitIntentTimeout;this.#r=typeof e=="number"&&e>0?e:null,at([t.triggerNode,t.contentNode,t.enabled],([s,n,o])=>{if(!s||!n||!o){this.#l=null,this.#u();return}this.#l&&this.#l!==s&&this.#u(),this.#l=s;const i=Tt(s),r=a=>{this.#m([a.clientX,a.clientY],s,n)},v=a=>{const l=a.relatedTarget;if(k(l)&&n.contains(l))return;const c=this.#t.ignoredTargets?.()??[];k(l)&&c.some(T=>T===l||T.contains(l))||(this.#a=k(l)&&c.length>0?c.filter(T=>l.contains(T)):[],this.#s=[a.clientX,a.clientY],this.#e="content",this.#p())},y=()=>{this.#u()},_=()=>{this.#u()},m=a=>{const l=a.relatedTarget;k(l)&&s.contains(l)||(this.#s=[a.clientX,a.clientY],this.#e="trigger",this.#p())};return[X(i,"pointermove",r),X(s,"pointerleave",v),X(s,"pointerenter",y),X(n,"pointerenter",_),X(n,"pointerleave",m)].reduce((a,l)=>()=>{a(),l()},()=>{})})}#m(t,e,s){if(!this.#s||!this.#e)return;this.#h(),this.#f();const n=e.getBoundingClientRect(),o=s.getBoundingClientRect();if(this.#e==="content"&&nt(t,o)){this.#u();return}if(this.#e==="trigger"&&nt(t,n)){this.#u();return}if(this.#e==="content"&&this.#a.length>0)for(const _ of this.#a){const m=_.getBoundingClientRect();if(nt(t,m))return;const a=vt(n,m),l=this.#d(n,m,a);if(l&&ot(t,l))return}const i=vt(n,o),r=this.#d(n,o,i);if(r&&ot(t,r))return;const v=this.#e==="content"?o:n,y=this.#v(this.#s,v,i,this.#e);ot(t,y)||(this.#u(),this.#t.onPointerExit())}#u(){this.#s=null,this.#e=null,this.#a=[],this.#h(),this.#c()}#d(t,e,s){const n=this.#n;switch(s){case"top":return[[Math.min(t.left,e.left)-n,t.top],[Math.min(t.left,e.left)-n,e.bottom],[Math.max(t.right,e.right)+n,e.bottom],[Math.max(t.right,e.right)+n,t.top]];case"bottom":return[[Math.min(t.left,e.left)-n,t.bottom],[Math.min(t.left,e.left)-n,e.top],[Math.max(t.right,e.right)+n,e.top],[Math.max(t.right,e.right)+n,t.bottom]];case"left":return[[t.left,Math.min(t.top,e.top)-n],[e.right,Math.min(t.top,e.top)-n],[e.right,Math.max(t.bottom,e.bottom)+n],[t.left,Math.max(t.bottom,e.bottom)+n]];case"right":return[[t.right,Math.min(t.top,e.top)-n],[e.left,Math.min(t.top,e.top)-n],[e.left,Math.max(t.bottom,e.bottom)+n],[t.right,Math.max(t.bottom,e.bottom)+n]]}}#v(t,e,s,n){const o=this.#n*4,[i,r]=t;switch(n==="trigger"?this.#g(s):s){case"top":return[[i-o,r+o],[i+o,r+o],[e.right+o,e.bottom],[e.right+o,e.top],[e.left-o,e.top],[e.left-o,e.bottom]];case"bottom":return[[i-o,r-o],[i+o,r-o],[e.right+o,e.top],[e.right+o,e.bottom],[e.left-o,e.bottom],[e.left-o,e.top]];case"left":return[[i+o,r-o],[i+o,r+o],[e.right,e.bottom+o],[e.left,e.bottom+o],[e.left,e.top-o],[e.right,e.top-o]];case"right":return[[i-o,r-o],[i-o,r+o],[e.left,e.bottom+o],[e.right,e.bottom+o],[e.right,e.top-o],[e.left,e.top-o]]}}#g(t){switch(t){case"top":return"bottom";case"bottom":return"top";case"left":return"right";case"right":return"left"}}}const st=Ft({component:"popover",parts:["root","trigger","content","close","overlay"]}),lt=new Ot("Popover.Root");class ut{static create(t){return lt.set(new ut(t))}opts;#t=D(null);get contentNode(){return h(this.#t)}set contentNode(t){C(this.#t,t,!0)}contentPresence;#n=D(null);get triggerNode(){return h(this.#n)}set triggerNode(t){C(this.#n,t,!0)}#r=D(null);get overlayNode(){return h(this.#r)}set overlayNode(t){C(this.#r,t,!0)}overlayPresence;#s=D(!1);get openedViaHover(){return h(this.#s)}set openedViaHover(t){C(this.#s,t,!0)}#e=D(!1);get hasInteractedWithContent(){return h(this.#e)}set hasInteractedWithContent(t){C(this.#e,t,!0)}#a=D(!1);get hoverCooldown(){return h(this.#a)}set hoverCooldown(t){C(this.#a,t,!0)}#l=D(0);get closeDelay(){return h(this.#l)}set closeDelay(t){C(this.#l,t,!0)}#o=null;#i=null;constructor(t){this.opts=t,this.contentPresence=new ft({ref:f(()=>this.contentNode),open:this.opts.open,onComplete:()=>{this.opts.onOpenChangeComplete.current(this.opts.open.current)}}),this.overlayPresence=new ft({ref:f(()=>this.overlayNode),open:this.opts.open}),at(()=>this.opts.open.current,e=>{e||(this.openedViaHover=!1,this.hasInteractedWithContent=!1,this.#h())})}setDomContext(t){this.#i=t}#h(){this.#o!==null&&this.#i&&(this.#i.clearTimeout(this.#o),this.#o=null)}toggleOpen(){this.#h(),this.opts.open.current=!this.opts.open.current}handleClose(){this.#h(),this.opts.open.current&&(this.opts.open.current=!1)}handleHoverOpen(){this.#h(),!this.opts.open.current&&(this.openedViaHover=!0,this.opts.open.current=!0)}handleHoverClose(){this.opts.open.current&&this.openedViaHover&&!this.hasInteractedWithContent&&(this.opts.open.current=!1)}handleDelayedHoverClose(){this.opts.open.current&&(!this.openedViaHover||this.hasInteractedWithContent||(this.#h(),this.closeDelay<=0?this.opts.open.current=!1:this.#i&&(this.#o=this.#i.setTimeout(()=>{this.openedViaHover&&!this.hasInteractedWithContent&&(this.opts.open.current=!1),this.#o=null},this.closeDelay))))}cancelDelayedClose(){this.#h()}markInteraction(){this.hasInteractedWithContent=!0,this.#h()}}class pt{static create(t){return new pt(t,lt.get())}opts;root;attachment;domContext;#t=null;#n=null;#r=D(!1);constructor(t,e){this.opts=t,this.root=e,this.attachment=yt(this.opts.ref,s=>this.root.triggerNode=s),this.domContext=new _t(t.ref),this.root.setDomContext(this.domContext),this.onclick=this.onclick.bind(this),this.onkeydown=this.onkeydown.bind(this),this.onpointerenter=this.onpointerenter.bind(this),this.onpointerleave=this.onpointerleave.bind(this),at(()=>this.opts.closeDelay.current,s=>{this.root.closeDelay=s})}#s(){this.#t!==null&&(this.domContext.clearTimeout(this.#t),this.#t=null)}#e(){this.#n!==null&&(this.domContext.clearTimeout(this.#n),this.#n=null)}#a(){this.#s(),this.#e()}onpointerenter(t){if(this.opts.disabled.current||!this.opts.openOnHover.current||U(t)||(C(this.#r,!0),this.#e(),this.root.cancelDelayedClose(),this.root.opts.open.current||this.root.hoverCooldown))return;const e=this.opts.openDelay.current;e<=0?this.root.handleHoverOpen():this.#t=this.domContext.setTimeout(()=>{this.root.handleHoverOpen(),this.#t=null},e)}onpointerleave(t){this.opts.disabled.current||this.opts.openOnHover.current&&(U(t)||(C(this.#r,!1),this.#s(),this.root.hoverCooldown=!1))}onclick(t){if(!this.opts.disabled.current&&t.button===0){if(this.#a(),h(this.#r)&&this.root.opts.open.current&&this.root.openedViaHover){this.root.openedViaHover=!1,this.root.hasInteractedWithContent=!0;return}h(this.#r)&&this.opts.openOnHover.current&&this.root.opts.open.current&&(this.root.hoverCooldown=!0),this.root.hoverCooldown&&!this.root.opts.open.current&&(this.root.hoverCooldown=!1),this.root.toggleOpen()}}onkeydown(t){this.opts.disabled.current||(t.key===xt||t.key===It)&&(t.preventDefault(),this.#a(),this.root.toggleOpen())}#l(){if(this.root.opts.open.current&&this.root.contentNode?.id)return this.root.contentNode?.id}#o=O(()=>({id:this.opts.id.current,"aria-haspopup":"dialog","aria-expanded":Dt(this.root.opts.open.current),"data-state":bt(this.root.opts.open.current),"aria-controls":this.#l(),[st.trigger]:"",disabled:this.opts.disabled.current,onkeydown:this.onkeydown,onclick:this.onclick,onpointerenter:this.onpointerenter,onpointerleave:this.onpointerleave,...this.attachment}));get props(){return h(this.#o)}set props(t){C(this.#o,t)}}class ct{static create(t){return new ct(t,lt.get())}opts;root;attachment;constructor(t,e){this.opts=t,this.root=e,this.attachment=yt(this.opts.ref,s=>this.root.contentNode=s),this.onpointerdown=this.onpointerdown.bind(this),this.onfocusin=this.onfocusin.bind(this),this.onpointerenter=this.onpointerenter.bind(this),this.onpointerleave=this.onpointerleave.bind(this),new St({triggerNode:()=>this.root.triggerNode,contentNode:()=>this.root.contentNode,enabled:()=>this.root.opts.open.current&&this.root.openedViaHover&&!this.root.hasInteractedWithContent,onPointerExit:()=>{this.root.handleDelayedHoverClose()}})}onpointerdown(t){this.root.markInteraction()}onfocusin(t){const e=t.target;k(e)&&At(e)&&this.root.markInteraction()}onpointerenter(t){U(t)||this.root.cancelDelayedClose()}onpointerleave(t){U(t)}onInteractOutside=t=>{if(this.opts.onInteractOutside.current(t),t.defaultPrevented||!k(t.target))return;const e=t.target.closest(st.selector("trigger"));if(!(e&&e===this.root.triggerNode)){if(this.opts.customAnchor.current){if(k(this.opts.customAnchor.current)){if(this.opts.customAnchor.current.contains(t.target))return}else if(typeof this.opts.customAnchor.current=="string"){const s=document.querySelector(this.opts.customAnchor.current);if(s&&s.contains(t.target))return}}this.root.handleClose()}};onEscapeKeydown=t=>{this.opts.onEscapeKeydown.current(t),!t.defaultPrevented&&this.root.handleClose()};get shouldRender(){return this.root.contentPresence.shouldRender}get shouldTrapFocus(){return!(this.root.openedViaHover&&!this.root.hasInteractedWithContent)}#t=O(()=>({open:this.root.opts.open.current}));get snippetProps(){return h(this.#t)}set snippetProps(t){C(this.#t,t)}#n=O(()=>({id:this.opts.id.current,tabindex:-1,"data-state":bt(this.root.opts.open.current),[st.content]:"",style:{pointerEvents:"auto",contain:"layout style"},onpointerdown:this.onpointerdown,onfocusin:this.onfocusin,onpointerenter:this.onpointerenter,onpointerleave:this.onpointerleave,...this.attachment}));get props(){return h(this.#n)}set props(t){C(this.#n,t)}popperProps={onInteractOutside:this.onInteractOutside,onEscapeKeydown:this.onEscapeKeydown}}var Nt=ht("<div><div><!></div></div>"),Vt=ht("<div><div><!></div></div>");function Wt(p,t){const e=gt();rt(t,!0);let s=u(t,"ref",15,null),n=u(t,"id",19,()=>wt(e)),o=u(t,"forceMount",3,!1),i=u(t,"onOpenAutoFocus",3,E),r=u(t,"onCloseAutoFocus",3,E),v=u(t,"onEscapeKeydown",3,E),y=u(t,"onInteractOutside",3,E),_=u(t,"trapFocus",3,!0),m=u(t,"preventScroll",3,!1),a=u(t,"customAnchor",3,null),l=Ct(t,["$$slots","$$events","$$legacy","child","children","ref","id","forceMount","onOpenAutoFocus","onCloseAutoFocus","onEscapeKeydown","onInteractOutside","trapFocus","preventScroll","customAnchor","style"]);const c=ct.create({id:f(()=>n()),ref:f(()=>s(),b=>s(b)),onInteractOutside:f(()=>y()),onEscapeKeydown:f(()=>v()),customAnchor:f(()=>a())}),T=O(()=>J(l,c.props)),L=O(()=>_()&&c.shouldTrapFocus);function q(b){c.shouldTrapFocus||b.preventDefault(),i()(b)}var z=A(),I=F(z);{var x=b=>{Mt(b,dt(()=>h(T),()=>c.popperProps,{get ref(){return c.opts.ref},get enabled(){return c.root.opts.open.current},get id(){return n()},get trapFocus(){return h(L)},get preventScroll(){return m()},loop:!0,forceMount:!0,get customAnchor(){return a()},onOpenAutoFocus:q,get onCloseAutoFocus(){return r()},get shouldRender(){return c.shouldRender},popper:(Z,N)=>{let $=()=>N?.().props,V=()=>N?.().wrapperProps;const W=O(()=>J($(),{style:mt("popover")},{style:t.style}));var K=A(),R=F(K);{var tt=g=>{var d=A(),w=F(d);{let M=O(()=>({props:h(W),wrapperProps:V(),...c.snippetProps}));H(w,()=>t.child,()=>h(M))}P(g,d)},et=g=>{var d=Nt();B(d,()=>({...V()}));var w=Y(d);B(w,()=>({...h(W)}));var M=Y(w);H(M,()=>t.children??Q),j(w),j(d),P(g,d)};G(R,g=>{t.child?g(tt):g(et,!1)})}P(Z,K)},$$slots:{popper:!0}}))},S=b=>{Ht(b,dt(()=>h(T),()=>c.popperProps,{get ref(){return c.opts.ref},get open(){return c.root.opts.open.current},get id(){return n()},get trapFocus(){return h(L)},get preventScroll(){return m()},loop:!0,forceMount:!1,get customAnchor(){return a()},onOpenAutoFocus:q,get onCloseAutoFocus(){return r()},get shouldRender(){return c.shouldRender},popper:(Z,N)=>{let $=()=>N?.().props,V=()=>N?.().wrapperProps;const W=O(()=>J($(),{style:mt("popover")},{style:t.style}));var K=A(),R=F(K);{var tt=g=>{var d=A(),w=F(d);{let M=O(()=>({props:h(W),wrapperProps:V(),...c.snippetProps}));H(w,()=>t.child,()=>h(M))}P(g,d)},et=g=>{var d=Vt();B(d,()=>({...V()}));var w=Y(d);B(w,()=>({...h(W)}));var M=Y(w);H(M,()=>t.children??Q),j(w),j(d),P(g,d)};G(R,g=>{t.child?g(tt):g(et,!1)})}P(Z,K)},$$slots:{popper:!0}}))};G(I,b=>{o()?b(x):o()||b(S,1)})}P(p,z),it()}var Kt=ht("<button><!></button>");function Xt(p,t){const e=gt();rt(t,!0);let s=u(t,"id",19,()=>wt(e)),n=u(t,"ref",15,null),o=u(t,"type",3,"button"),i=u(t,"disabled",3,!1),r=u(t,"openOnHover",3,!1),v=u(t,"openDelay",3,700),y=u(t,"closeDelay",3,300),_=Ct(t,["$$slots","$$events","$$legacy","children","child","id","ref","type","disabled","openOnHover","openDelay","closeDelay"]);const m=pt.create({id:f(()=>s()),ref:f(()=>n(),l=>n(l)),disabled:f(()=>!!i()),openOnHover:f(()=>r()),openDelay:f(()=>v()),closeDelay:f(()=>y())}),a=O(()=>J(_,m.props,{type:o()}));kt(p,{get id(){return s()},get ref(){return m.opts.ref},children:(l,c)=>{var T=A(),L=F(T);{var q=I=>{var x=A(),S=F(x);H(S,()=>t.child,()=>({props:h(a)})),P(I,x)},z=I=>{var x=Kt();B(x,()=>({...h(a)}));var S=Y(x);H(S,()=>t.children??Q),j(x),P(I,x)};G(L,I=>{t.child?I(q):I(z,!1)})}P(l,T)},$$slots:{default:!0}}),it()}function Yt(p,t){rt(t,!0);let e=u(t,"open",15,!1),s=u(t,"onOpenChange",3,E),n=u(t,"onOpenChangeComplete",3,E);ut.create({open:f(()=>e(),o=>{e(o),s()(o)}),onOpenChangeComplete:f(()=>n())}),Et(p,{children:(o,i)=>{var r=A(),v=F(r);H(v,()=>t.children??Q),P(o,r)},$$slots:{default:!0}}),it()}const Gt=Yt,Jt=Xt,Qt=Wt;export{Qt as C,Gt as R,Jt as T};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./
|
|
2
|
-
import{_ as V}from"./PPVm8Dsz.js";import{g as T,s as a,
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Cq78Q8ao.js","./iRhbt-db.js","./D98nKNS8.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as V}from"./PPVm8Dsz.js";import{g as T,s as a,i as S}from"./iRhbt-db.js";import{i as Y}from"./xUpz_Ego.js";import{w as u}from"./C6NT3aAi.js";import{a as Z}from"./CbhBH-Pr.js";import{n as h}from"./DHBDhuM5.js";import{u as U}from"./D98nKNS8.js";import{t as s}from"./C3rmQoP5.js";const q=800;function K(){let e=S(!1),n=S(null),r=S(null),t=null,o=null,l=!1;function J(d,y,f,c){t&&t.repo===d&&t.type===y&&t.id===f?(c.data!==void 0&&(t.payload.data=c.data),c.content!==void 0&&(t.payload.content=c.content)):t={repo:d,type:y,id:f,payload:{...c}},j()}function j(){o&&clearTimeout(o),o=setTimeout(E,q)}async function E(){if(o=null,!l&&t){const{repo:d,type:y,id:f,payload:c}=t;t=null,l=!0,a(e,!0),a(r,null);try{if(await U(d,y,f,c),a(n,new Date,!0),c.data?.name){const g=u.repos.find(H=>H.name===d)?.entities.find(H=>H.id===f);g&&(g.title=c.data.name)}}catch(p){a(r,p.message??"Save failed",!0);const g=p.status??p.statusCode;(!g||g>=500)&&(t={repo:d,type:y,id:f,payload:c})}finally{a(e,!1),l=!1,t&&E()}}}function z(){return o&&(clearTimeout(o),o=null),t?E():Promise.resolve()}async function G(d,y,f,c){a(e,!0),a(r,null);try{const p=await U(d,y,f,c);return a(n,new Date,!0),p}catch(p){return a(r,p.message??"Save failed",!0),null}finally{a(e,!1)}}function L(){a(r,null),a(n,null),t=null,o&&(clearTimeout(o),o=null)}return{get saving(){return T(e)},get lastSaved(){return T(n)},get error(){return T(r)},get hasPending(){return!!(t||l)},scheduleAutoSave:J,flush:z,saveEntity:G,reset:L}}const Q=K();let i=null,I=null,O=null,M=null,C=null,D=null,N=null,P=null,W=null,R=null,F=[],$=null,w=1e3,k=S(!1),B=S(null);const m=new Map,_={},A={};function b(e,n){m.delete(e);const r=n.entities.length,t=r===1?`${e} updated ${n.entities[0]}`:`${e} updated ${r} entities`;s(t)}function X(e){for(const[n,r]of m)r.repo===e&&(clearTimeout(r.timer),m.delete(n))}function v(e){const n=Z.user?.displayName;if(e.type==="sync_progress"){const r=_[e.repo];if(r){const t=e.message.trim(),o=t.match(/^Syncing from source:\s*(.+)$/i);o&&(A[e.repo]=`Syncing ${o[1].trim()}…`);const l=A[e.repo]??`Syncing ${e.repo}…`;s.loading(l,{id:r,description:t,duration:36e5})}return}if(e.type==="entity_change"){if(n&&e.actor===n&&e.source==="api"){u.refreshEntities(e.repo);return}if(u.refreshEntities(e.repo),h.selectedRepo===e.repo&&h.selectedType===e.entityType&&h.selectedId===e.entityId){Q.hasPending?s(`${e.actor} also saved changes to this entity`):Y();return}const t=m.get(e.actor);if(t)clearTimeout(t.timer),t.entities.includes(e.entityId)||t.entities.push(e.entityId),t.timer=setTimeout(()=>b(e.actor,t),1e4);else{const o={entities:[e.entityId],repo:e.repo,timer:setTimeout(()=>b(e.actor,o),1e4)};m.set(e.actor,o)}return}if(e.type==="session_commit"){if(n&&e.actor===n){a(B,e.timestamp,!0);return}const r=e.entities.length,t=r===1?`${e.actor} saved changes to ${e.entities[0]}`:`${e.actor} saved ${r} changes in ${e.repo}`;s(t),u.refreshEntities(e.repo);return}if(e.type==="sync_complete"){if(X(e.repo),!_[e.repo]){const r=e.created+e.updated+e.deleted,t=r===0?`Sync complete · no changes in ${e.repo}`:`Sync complete · ${r} ${r===1?"entity":"entities"} from ${e.source}`;s.success(t)}u.refreshEntities(e.repo);return}if(e.type==="folder_created"){s(`${e.actor} created folder ${e.repo}`),u.refreshEntities(e.repo);return}if(e.type==="folder_deleted"){s(`${e.actor} deleted folder ${e.repo}`);return}if(e.type==="repo_sync"){s(`${e.actor} pushed to ${e.repo}`),u.refreshEntities(e.repo);return}if(e.type==="folder_message"){M?.(e);return}if(e.type==="message_update"){C?.(e);return}if(e.type==="folder_agent_thinking"){D?.(e);return}if(e.type==="workspace_message"){P?.(e);return}if(e.type==="workspace_message_update"){W?.(e);return}if(e.type==="workspace_agent_thinking"){R?.(e);return}if(e.type==="user_mention"){N?.(e);return}if(e.type==="presence"){I?.(e);return}if(e.type==="online"){O?.(e);return}if(e.type==="insights_updated"||e.type==="briefing_updated"){V(()=>import("./Cq78Q8ao.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(r=>r.insightsStore.load());return}if(e.type==="access_granted"){u.onFolderAccessGranted(e.repo);return}if(e.type==="access_revoked"){h.selectedRepo===e.repo&&h.deselect(),u.onFolderAccessRevoked(e.repo);return}}function x(){if(typeof window>"u"||i&&(i.readyState===WebSocket.OPEN||i.readyState===WebSocket.CONNECTING))return;const e=window.location.protocol==="https:"?"wss:":"ws:",n=(()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}})(),r=`${e}//${window.location.host}/ws?tz=${encodeURIComponent(n)}`;i=new WebSocket(r),i.binaryType="arraybuffer",i.onopen=()=>{a(k,!0),w=1e3,u.refreshAll();for(const t of F)t()},i.onmessage=t=>{if(!(t.data instanceof ArrayBuffer))try{const o=JSON.parse(t.data);if(o?.type==="ping"){i?.send(JSON.stringify({type:"pong"}));return}const l=o;l.type&&l.type!=="toast"&&v(l)}catch{}},i.onclose=()=>{a(k,!1),i=null,$=setTimeout(()=>{w=Math.min(w*2,1e4),x()},w)},i.onerror=()=>{}}function ee(){$&&(clearTimeout($),$=null),i&&(i.close(),i=null),a(k,!1);for(const[,e]of m)clearTimeout(e.timer);m.clear()}function te(e,n=4e3){s(e,{duration:n})}function re(e,n){const r=crypto.randomUUID();return n?.loading?s.loading(e,{id:r,duration:36e5}):s(e,{id:r}),r}function ne(e,n,r){if(r?.loading){s.loading(n,{id:e});return}/failed|error/i.test(n)?s.error(n,{id:e,duration:r?.duration??6e3}):s.success(n,{id:e,duration:r?.duration??4e3})}function oe(e){const n=crypto.randomUUID();_[e]=n,s.loading(`Syncing ${e}…`,{id:n,duration:36e5})}function ie(e,n,r){const t=_[e];t&&(delete _[e],delete A[e],r?s.error(n,{id:t,duration:6e3}):s.success(n,{id:t,duration:4e3}))}function se(e){I=e}function ae(e){O=e}function ce(e){M=e}function le(e){C=e}function ue(e){D=e}function de(e){N=e}function fe(e){P=e}function pe(e){W=e}function ye(e){R=e}function me(e){F.push(e)}function ge(e){i?.readyState===WebSocket.OPEN&&i.send(JSON.stringify(e))}const He={get connected(){return T(k)},get lastAutoSaved(){return T(B)},get ws(){return i},connect:x,disconnect:ee,showToast:te,showPersistentToast:re,updateToast:ne,startSyncToast:oe,finishSyncToast:ie,send:ge,setPresenceHandler:se,setOnlineHandler:ae,setMessagesHandler:ce,setMessageUpdateHandler:le,setAgentThinkingHandler:ue,setUserMentionHandler:de,setWorkspaceMessagesHandler:fe,setWorkspaceMessageUpdateHandler:pe,setWorkspaceAgentThinkingHandler:ye,addConnectHandler:me};export{Q as e,He as r};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{G as Z,w as Ee,x as P,B as j,M as xe,y as Ce,g as c,z as ke,ad as Oe,A as ce,C as Q,D as Y,K as $e,a$ as Ne,b0 as ue,aa as De,b1 as N,a9 as se,b2 as Re,ac as Fe,at as Me,aJ as He,b3 as ae,b4 as Ue,b5 as Pe,m as Le,ao as fe,b6 as ze,a6 as ve,a8 as Ie,b7 as ee,b8 as Je,b9 as Be,a7 as Ke,ag as qe,L as Ve,ba as be,bb as Ye,i as A,a2 as L,s as m,F as G,bc as Ge,aD as de,bd as We,a5 as ge,aH as Xe,T as he,u as Ze}from"./iRhbt-db.js";import{i as je}from"./xUpz_Ego.js";import{n as k}from"./DHBDhuM5.js";import{w as B}from"./C6NT3aAi.js";import{a as q}from"./CbhBH-Pr.js";import{a as Qe}from"./D98nKNS8.js";function Et(s,e){return e}function et(s,e,t){for(var n=[],o=e.length,i,r=e.length,h=0;h<o;h++){let T=e[h];Ie(T,()=>{if(i){if(i.pending.delete(T),i.done.add(T),i.pending.size===0){var p=s.outrogroups;ne(ae(i.done)),p.delete(i),p.size===0&&(s.outrogroups=null)}}else r-=1},!1)}if(r===0){var f=n.length===0&&t!==null;if(f){var y=t,u=y.parentNode;Be(u),u.append(y),s.items.clear()}ne(e,!f)}else i={pending:new Set(e),done:new Set},(s.outrogroups??=new Set).add(i)}function ne(s,e=!0){for(var t=0;t<s.length;t++)Ke(s[t],e)}var pe;function xt(s,e,t,n,o,i=null){var r=s,h=new Map,f=(e&be)!==0;if(f){var y=s;r=P?j(xe(y)):y.appendChild(Z())}P&&Ce();var u=null,T=Me(()=>{var g=t();return He(g)?g:g==null?[]:ae(g)}),p,w=!0;function $(){a.fallback=u,tt(a,p,r,e,n),u!==null&&(p.length===0?(u.f&N)===0?ve(u):(u.f^=N,K(u,null,r)):Ie(u,()=>{u=null}))}var D=Ee(()=>{p=c(T);var g=p.length;let R=!1;if(P){var F=ke(r)===Oe;F!==(g===0)&&(r=ce(),j(r),Q(!1),R=!0)}for(var l=new Set,I=De,v=Fe(),S=0;S<g;S+=1){P&&Y.nodeType===$e&&Y.data===Ne&&(r=Y,R=!0,Q(!1));var E=p[S],O=n(E,S),b=w?null:h.get(O);b?(b.v&&ue(b.v,E),b.i&&ue(b.i,S),v&&I.unskip_effect(b.e)):(b=st(h,w?r:pe??=Z(),E,O,S,o,e,t),w||(b.e.f|=N),h.set(O,b)),l.add(O)}if(g===0&&i&&!u&&(w?u=se(()=>i(r)):(u=se(()=>i(pe??=Z())),u.f|=N)),g>l.size&&Re(),P&&g>0&&j(ce()),!w)if(v){for(const[W,V]of h)l.has(W)||I.skip_effect(V.e);I.oncommit($),I.ondiscard(()=>{})}else $();R&&Q(!0),c(T)}),a={effect:D,items:h,outrogroups:null,fallback:u};w=!1,P&&(r=Y)}function z(s){for(;s!==null&&(s.f&Je)===0;)s=s.next;return s}function tt(s,e,t,n,o){var i=(n&Ye)!==0,r=e.length,h=s.items,f=z(s.effect.first),y,u=null,T,p=[],w=[],$,D,a,g;if(i)for(g=0;g<r;g+=1)$=e[g],D=o($,g),a=h.get(D).e,(a.f&N)===0&&(a.nodes?.a?.measure(),(T??=new Set).add(a));for(g=0;g<r;g+=1){if($=e[g],D=o($,g),a=h.get(D).e,s.outrogroups!==null)for(const b of s.outrogroups)b.pending.delete(a),b.done.delete(a);if((a.f&N)!==0)if(a.f^=N,a===f)K(a,null,t);else{var R=u?u.next:f;a===s.effect.last&&(s.effect.last=a.prev),a.prev&&(a.prev.next=a.next),a.next&&(a.next.prev=a.prev),H(s,u,a),H(s,a,R),K(a,R,t),u=a,p=[],w=[],f=z(u.next);continue}if((a.f&ee)!==0&&(ve(a),i&&(a.nodes?.a?.unfix(),(T??=new Set).delete(a))),a!==f){if(y!==void 0&&y.has(a)){if(p.length<w.length){var F=w[0],l;u=F.prev;var I=p[0],v=p[p.length-1];for(l=0;l<p.length;l+=1)K(p[l],F,t);for(l=0;l<w.length;l+=1)y.delete(w[l]);H(s,I.prev,v.next),H(s,u,I),H(s,v,F),f=F,u=v,g-=1,p=[],w=[]}else y.delete(a),K(a,f,t),H(s,a.prev,a.next),H(s,a,u===null?s.effect.first:u.next),H(s,u,a),u=a;continue}for(p=[],w=[];f!==null&&f!==a;)(y??=new Set).add(f),w.push(f),f=z(f.next);if(f===null)continue}(a.f&N)===0&&p.push(a),u=a,f=z(a.next)}if(s.outrogroups!==null){for(const b of s.outrogroups)b.pending.size===0&&(ne(ae(b.done)),s.outrogroups?.delete(b));s.outrogroups.size===0&&(s.outrogroups=null)}if(f!==null||y!==void 0){var S=[];if(y!==void 0)for(a of y)(a.f&ee)===0&&S.push(a);for(;f!==null;)(f.f&ee)===0&&f!==s.fallback&&S.push(f),f=z(f.next);var E=S.length;if(E>0){var O=(n&be)!==0&&r===0?t:null;if(i){for(g=0;g<E;g+=1)S[g].nodes?.a?.measure();for(g=0;g<E;g+=1)S[g].nodes?.a?.fix()}et(s,S,O)}}i&&qe(()=>{if(T!==void 0)for(a of T)a.nodes?.a?.apply()})}function st(s,e,t,n,o,i,r,h){var f=(r&Ue)!==0?(r&Pe)===0?Le(t,!1,!1):fe(t):null,y=(r&ze)!==0?fe(o):null;return{v:f,i:y,e:se(()=>(i(e,f??t,y??o,h),()=>{s.delete(n)}))}}function K(s,e,t){if(s.nodes)for(var n=s.nodes.start,o=s.nodes.end,i=e&&(e.f&N)===0?e.nodes.start:t;n!==null;){var r=Ve(n);if(i.before(n),n===o)return;n=r}}function H(s,e,t){e===null?s.effect.first=t:e.next=t,t===null?s.effect.last=e:t.prev=e}function nt(s,e,t){fetch("/api/chat/stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s),signal:t}).then(async n=>{if(!n.ok){e({type:"error",message:`HTTP ${n.status}`});return}const o=n.body?.getReader();if(!o){e({type:"error",message:"No response body"});return}const i=new TextDecoder;let r="";for(;;){const{done:h,value:f}=await o.read();if(h)break;r+=i.decode(f,{stream:!0});const y=r.split(`
|
|
2
|
+
`);r=y.pop()??"";for(const u of y)if(u.startsWith("data: "))try{const T=JSON.parse(u.slice(6));e(T)}catch{}}}).catch(n=>{n.name!=="AbortError"&&e({type:"error",message:n.message})})}function we(){const s=B.name;return s&&s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"default"}function re(){const s=q.user?.id;return s?`sg-chat-sessions-${we()}-${s}`:"sg-chat-sessions"}function oe(){const s=q.user?.id;return s?`sg-chat-version-${we()}-${s}`:"sg-chat-version"}const rt=14;function ot(){try{if(q.user?.id){localStorage.getItem("sg-chat-sessions")&&(localStorage.removeItem("sg-chat-sessions"),localStorage.removeItem("sg-chat-version"));const s=`sg-chat-sessions-${q.user.id}`;localStorage.getItem(s)&&(localStorage.removeItem(s),localStorage.removeItem(`sg-chat-version-${q.user.id}`))}}catch{}}function U(){ot();try{const s=localStorage.getItem(re());if(!s)return[];if(localStorage.getItem(oe())==="2")return JSON.parse(s);const n=JSON.parse(s).map(o=>({id:crypto.randomUUID(),createdAt:o.date+"T00:00:00.000Z",updatedAt:o.date+"T00:00:00.000Z",title:o.messages.find(i=>i.role==="user")?.content.slice(0,50)||"New chat",messages:o.messages}));return localStorage.setItem(re(),JSON.stringify(n)),localStorage.setItem(oe(),"2"),n}catch{return[]}}function ie(s){const t=[...s].sort((n,o)=>o.updatedAt.localeCompare(n.updatedAt)).slice(0,rt);try{localStorage.setItem(re(),JSON.stringify(t)),localStorage.setItem(oe(),"2")}catch{}}function J(s,e){const t=U(),n=e.map(({streaming:i,...r})=>r),o=t.findIndex(i=>i.id===s);o>=0&&(t[o].messages=n,t[o].updatedAt=new Date().toISOString()),ie(t)}function me(s){const e=s.getFullYear(),t=String(s.getMonth()+1).padStart(2,"0"),n=String(s.getDate()).padStart(2,"0");return`${e}-${t}-${n}`}function ye(s){return me(new Date(s.updatedAt))===me(new Date)}function it(){const t=U().sort((l,I)=>I.updatedAt.localeCompare(l.updatedAt)).find(ye)??null;let n=A(L(t?t.messages.map(l=>({...l,streaming:!1})):[])),o=A(L(t?.id??null)),i=A(!1),r=A(0),h=A(0),f=A(0),y=A(null),u=null,T=A(""),p=A(L(!!t));const w=new Set(["create_entity","update_entity","delete_entity","move_entity"]);function $(){g();const l=crypto.randomUUID();m(o,l,!0),m(n,[],!0),m(p,!1)}function D(){if(c(o)&&c(p))return c(o);const l=c(o)||crypto.randomUUID();m(o,l,!0);const I=new Date().toISOString(),v=U();return v.push({id:l,createdAt:I,updatedAt:I,title:"New chat",messages:[]}),ie(v),m(p,!0),l}function a(l,I){if(!l.trim()||c(i))return;m(y,null);const v=D();I?.silent||c(n).push({role:"user",content:l}),c(n).push({role:"agent",content:"",segments:[],streaming:!0}),m(i,!0);const S=U(),E=S.find(d=>d.id===v);E&&E.title==="New chat"&&(E.title=l.slice(0,50),ie(S)),J(v,c(n));let O=!1,b=null;u=new AbortController;const W=k.selectedSubPath?`${k.selectedRepo}/${k.selectedType}/${k.selectedId}/${k.selectedSubPath}`:k.selectedId?`${k.selectedRepo}/${k.selectedType}/${k.selectedId}`:k.selectedRepo?`folder:${k.selectedRepo}`:null,V=c(n).slice(0,-2).map(d=>({role:d.role==="agent"?"assistant":d.role,content:d.content})),_e={message:l,context:W??void 0,sessionId:v,history:V.length>0?V:void 0};nt(_e,d=>{if(!c(i))return;const _=c(n)[c(n).length-1];if(!_||_.role!=="agent")return;const M=_.segments;switch(d.type){case"token":{_.content+=d.text??"";const C=M[M.length-1];C&&C.type==="text"?C.content+=d.text??"":M.push({type:"text",content:d.text??""}),_.segments=M,G(h);break}case"tool_start":if(d.name){w.has(d.name)&&(O=!0);const C=M[M.length-1];C&&C.type==="tools"?C.names=[...C.names,d.name]:M.push({type:"tools",names:[d.name]}),_.segments=M,G(h)}break;case"mutation":O=!0,d.action==="created"&&d.repo&&d.entityType&&d.entityId&&(b={repo:d.repo,entityType:d.entityType,entityId:d.entityId}),d.repo==="_conversation"&&setTimeout(()=>{m(n,[],!0),c(o)&&c(p)&&J(c(o),c(n))},100),d.repo==="_workspace"&&B.load(),window.StudioChrome?.emitMutation?.({action:d.action,repo:d.repo,entityType:d.entityType,entityId:d.entityId});break;case"highlight":m(y,d.entityIds&&d.entityIds.length>0?new Set(d.entityIds):null,!0);break;case"done":{d.message&&!_.content&&(_.content=d.message,_.segments=[{type:"text",content:d.message}]);const C=/<!--\s*followups:\s*\[.*?\]\s*-->\s*$/s;_.content&&(_.content=_.content.replace(C,"").trimEnd());const le=_.segments??[],X=le[le.length-1];if(X?.type==="text"&&(X.content=X.content.replace(C,"").trimEnd()),d.suggestions?.length&&(_.suggestions=d.suggestions),_.streaming=!1,m(i,!1),J(v,c(n)),O){je().then(()=>{G(r)});const Te=new Set(B.repos.map(Ae=>Ae.name));b&&!Te.has(b.repo)?B.load():B.refreshAll()}break}case"error":_.content+=`
|
|
3
|
+
|
|
4
|
+
Error: ${d.message}`,_.streaming=!1,m(i,!1),J(v,c(n));break}},u.signal)}function g(){if(!c(i))return;fetch("/api/chat/abort",{method:"POST",credentials:"include"}).catch(()=>{}),u?.abort(),u=null,m(i,!1);const l=c(n)[c(n).length-1];l?.streaming&&(l.streaming=!1,c(o)&&J(c(o),c(n)))}function R(l){const v=U().find(S=>S.id===l);v&&(g(),m(o,v.id,!0),m(n,v.messages.map(S=>({...S,streaming:!1})),!0),m(p,!0))}function F(){return U().sort((l,I)=>I.updatedAt.localeCompare(l.updatedAt)).map(l=>({id:l.id,title:l.title,createdAt:l.createdAt,updatedAt:l.updatedAt,preview:l.messages.find(I=>I.role==="user")?.content.slice(0,80)||"",count:l.messages.length,active:l.id===c(o)}))}return{get messages(){return c(n)},get streaming(){return c(i)},get mutationCount(){return c(r)},get scrollTick(){return c(h)},get forceScroll(){return c(f)},triggerScroll(){G(f)},get highlightedIds(){return c(y)},get activeSessionId(){return c(o)},get draftInput(){return c(T)},set draftInput(l){m(T,l,!0)},send:a,stop:g,newSession:$,loadSession:R,getSessions:F,reinitialize(){g();const v=U().sort((S,E)=>E.updatedAt.localeCompare(S.updatedAt)).find(ye)??null;m(o,v?.id??null,!0),m(n,v?.messages.map(S=>({...S,streaming:!1}))??[],!0),m(p,!!v)}}}const at=it(),Ct=Object.freeze(Object.defineProperty({__proto__:null,chatStore:at},Symbol.toStringTag,{value:"Module"}));function kt(...s){return s.filter(Boolean).join(" ")}const lt=typeof document<"u",ct=typeof window<"u"?window:void 0;function ut(s){let e=s.activeElement;for(;e?.shadowRoot;){const t=e.shadowRoot.activeElement;if(t===e)break;e=t}return e}class ft{#t;#e;constructor(e={}){const{window:t=ct,document:n=t?.document}=e;t!==void 0&&(this.#t=n,this.#e=Ge(o=>{const i=de(t,"focusin",o),r=de(t,"focusout",o);return()=>{i(),r()}}))}get current(){return this.#e?.(),this.#t?ut(this.#t):null}}new ft;class dt{#t;#e;constructor(e){this.#t=e,this.#e=Symbol(e)}get key(){return this.#e}exists(){return We(this.#e)}get(){const e=ge(this.#e);if(e===void 0)throw new Error(`Context "${this.#t}" not found`);return e}getOr(e){const t=ge(this.#e);return t===void 0?e:t}set(e){return Xe(this.#e,e)}}const gt=new dt("<Toaster/>");let Se=0;class ht{#t=A(L([]));get toasts(){return c(this.#t)}set toasts(e){m(this.#t,e,!0)}#e=A(L([]));get heights(){return c(this.#e)}set heights(e){m(this.#e,e,!0)}#s=e=>{const t=this.toasts.findIndex(n=>n.id===e);return t===-1?null:t};addToast=e=>{lt&&this.toasts.unshift(e)};updateToast=({id:e,data:t,type:n,message:o})=>{const i=this.toasts.findIndex(h=>h.id===e),r=this.toasts[i];this.toasts[i]={...r,...t,id:e,title:o,type:n,updated:!0}};create=e=>{const{message:t,...n}=e,o=typeof e?.id=="number"||e.id&&e.id?.length>0?e.id:Se++,i=e.dismissible!==void 0?e.dismissible:e.dismissable!==void 0?e.dismissable:!0,r=e.type===void 0?"default":e.type;return he(()=>{this.toasts.find(f=>f.id===o)?this.updateToast({id:o,data:e,type:r,message:t,dismissible:i}):this.addToast({...n,id:o,title:t,dismissible:i,type:r})}),o};dismiss=e=>(he(()=>{if(e===void 0){this.toasts=this.toasts.map(n=>({...n,dismiss:!0}));return}const t=this.toasts.findIndex(n=>n.id===e);this.toasts[t]&&(this.toasts[t]={...this.toasts[t],dismiss:!0})}),e);remove=e=>{if(e===void 0){this.toasts=[];return}const t=this.#s(e);if(t!==null)return this.toasts.splice(t,1),e};message=(e,t)=>this.create({...t,type:"default",message:e});error=(e,t)=>this.create({...t,type:"error",message:e});success=(e,t)=>this.create({...t,type:"success",message:e});info=(e,t)=>this.create({...t,type:"info",message:e});warning=(e,t)=>this.create({...t,type:"warning",message:e});loading=(e,t)=>this.create({...t,type:"loading",message:e});promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:typeof t.loading=="string"?t.loading:t.loading()}));const o=e instanceof Promise?e:e();let i=n!==void 0;return o.then(r=>{if(typeof r=="object"&&r&&"ok"in r&&typeof r.ok=="boolean"&&!r.ok){i=!1;const h=pt(r);this.create({id:n,type:"error",message:h})}else if(t.success!==void 0){i=!1;const h=typeof t.success=="function"?t.success(r):t.success;this.create({id:n,type:"success",message:h})}}).catch(r=>{if(t.error!==void 0){i=!1;const h=typeof t.error=="function"?t.error(r):t.error;this.create({id:n,type:"error",message:h})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally?.()}),n};custom=(e,t)=>{const n=t?.id||Se++;return this.create({component:e,id:n,...t}),n};removeHeight=e=>{this.heights=this.heights.filter(t=>t.toastId!==e)};setHeight=e=>{const t=this.#s(e.toastId);if(t===null){this.heights.push(e);return}this.heights[t]=e};reset=()=>{this.toasts=[],this.heights=[]}}function pt(s){return s&&typeof s=="object"&&"status"in s?`HTTP error! Status: ${s.status}`:`Error! ${s}`}const x=new ht;function mt(s,e){return x.create({message:s,...e})}class Ot{#t=Ze(()=>x.toasts.filter(e=>!e.dismiss));get toasts(){return c(this.#t)}}function $t(){return gt.get()}const yt=mt,Nt=Object.assign(yt,{success:x.success,info:x.info,warning:x.warning,error:x.error,custom:x.custom,message:x.message,promise:x.promise,dismiss:x.dismiss,loading:x.loading,getActiveToasts:()=>x.toasts.filter(s=>!s.dismiss)}),te={meetingCapture:!1};function St(){let s=A(L({...te})),e=A(!1),t=A(!1),n=null;async function o(){if(!c(t))return n||(m(e,!0),n=(async()=>{try{const r=await Qe("/api/features");m(s,{...te,...r.flags},!0)}catch(r){console.error("Failed to load feature flags:",r),m(s,{...te},!0)}finally{m(e,!1),m(t,!0),n=null}})(),n)}function i(r){return c(s)[r]}return{get flags(){return c(s)},get loading(){return c(e)},get loaded(){return c(t)},get meetingCapture(){return c(s).meetingCapture},load:o,isEnabled:i}}const Dt=St();export{Ot as S,x as a,kt as b,at as c,Ct as d,xt as e,Dt as f,Et as i,gt as s,Nt as t,$t as u};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{w as ke,E as Le,aI as ie,a7 as J,a9 as oe,ae as x,x as O,aJ as Ie,aK as Fe,aL as Me,Q as Pe,aF as Oe,aa as Q,aG as Re,aM as Ne,aN as $e,aO as je,aP as Ge,g as d,aQ as Ue,aR as We,aS as W,C as te,aT as De,a4 as Ke,a3 as Ye,aU as qe,aV as Be,aW as Ve,aX as He,ag as Qe,aY as Xe,aZ as Ze,a2 as R,i as L,s as _,u as ze}from"./iRhbt-db.js";import{B as Je}from"./Cm3t5Lw_.js";import{e as X,g as xe,h as et,r as tt,i as rt,j as at,k as nt,l as st}from"./D98nKNS8.js";function Pt(e,r,...a){var s=new Je(e);ke(()=>{const n=r()??null;s.ensure(n,n&&(c=>n(c,...a)))},Le)}function it(e,r){var a=void 0,s;ie(()=>{a!==(a=r())&&(s&&(J(s),s=null),a&&(s=oe(()=>{x(()=>a(e))})))})}function le(e){var r,a,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var n=e.length;for(r=0;r<n;r++)e[r]&&(a=le(e[r]))&&(s&&(s+=" "),s+=a)}else for(a in e)e[a]&&(s&&(s+=" "),s+=a);return s}function ot(){for(var e,r,a=0,s="",n=arguments.length;a<n;a++)(e=arguments[a])&&(r=le(e))&&(s&&(s+=" "),s+=r);return s}function lt(e){return typeof e=="object"?ot(e):e??""}const re=[...`
|
|
2
|
+
\r\f \v\uFEFF`];function ct(e,r,a){var s=e==null?"":""+e;if(r&&(s=s?s+" "+r:r),a){for(var n of Object.keys(a))if(a[n])s=s?s+" "+n:n;else if(s.length)for(var c=n.length,f=0;(f=s.indexOf(n,f))>=0;){var g=f+c;(f===0||re.includes(s[f-1]))&&(g===s.length||re.includes(s[g]))?s=(f===0?"":s.substring(0,f))+s.substring(g+1):f=g}}return s===""?null:s}function ae(e,r=!1){var a=r?" !important;":";",s="";for(var n of Object.keys(e)){var c=e[n];c!=null&&c!==""&&(s+=" "+n+": "+c+a)}return s}function Z(e){return e[0]!=="-"||e[1]!=="-"?e.toLowerCase():e}function ut(e,r){if(r){var a="",s,n;if(Array.isArray(r)?(s=r[0],n=r[1]):s=r,e){e=String(e).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var c=!1,f=0,g=!1,p=[];s&&p.push(...Object.keys(s).map(Z)),n&&p.push(...Object.keys(n).map(Z));var h=0,T=-1;const I=e.length;for(var m=0;m<I;m++){var y=e[m];if(g?y==="/"&&e[m-1]==="*"&&(g=!1):c?c===y&&(c=!1):y==="/"&&e[m+1]==="*"?g=!0:y==='"'||y==="'"?c=y:y==="("?f++:y===")"&&f--,!g&&c===!1&&f===0){if(y===":"&&T===-1)T=m;else if(y===";"||m===I-1){if(T!==-1){var M=Z(e.substring(h,T).trim());if(!p.includes(M)){y!==";"&&m++;var S=e.substring(h,m).trim();a+=" "+S+";"}}h=m+1,T=-1}}}}return s&&(a+=ae(s)),n&&(a+=ae(n,!0)),a=a.trim(),a===""?null:a}return e==null?null:String(e)}function ft(e,r,a,s,n,c){var f=e.__className;if(O||f!==a||f===void 0){var g=ct(a,s,c);(!O||g!==e.getAttribute("class"))&&(g==null?e.removeAttribute("class"):r?e.className=g:e.setAttribute("class",g)),e.__className=a}else if(c&&n!==c)for(var p in c){var h=!!c[p];(n==null||h!==!!n[p])&&e.classList.toggle(p,h)}return c}function z(e,r={},a,s){for(var n in a){var c=a[n];r[n]!==c&&(a[n]==null?e.style.removeProperty(n):e.style.setProperty(n,c,s))}}function dt(e,r,a,s){var n=e.__style;if(O||n!==r){var c=ut(r,s);(!O||c!==e.getAttribute("style"))&&(c==null?e.removeAttribute("style"):e.style.cssText=c),e.__style=r}else s&&(Array.isArray(s)?(z(e,a?.[0],s[0]),z(e,a?.[1],s[1],"important")):z(e,a,s));return s}function q(e,r,a=!1){if(e.multiple){if(r==null)return;if(!Ie(r))return Fe();for(var s of e.options)s.selected=r.includes(U(s));return}for(s of e.options){var n=U(s);if(Me(n,r)){s.selected=!0;return}}(!a||r!==void 0)&&(e.selectedIndex=-1)}function ce(e){var r=new MutationObserver(()=>{q(e,e.__value)});r.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Pe(()=>{r.disconnect()})}function Ot(e,r,a=r){var s=new WeakSet,n=!0;Oe(e,"change",c=>{var f=c?"[selected]":":checked",g;if(e.multiple)g=[].map.call(e.querySelectorAll(f),U);else{var p=e.querySelector(f)??e.querySelector("option:not([disabled])");g=p&&U(p)}a(g),Q!==null&&s.add(Q)}),x(()=>{var c=r();if(e===document.activeElement){var f=Re??Q;if(s.has(f))return}if(q(e,c,n),n&&c===void 0){var g=e.querySelector(":checked");g!==null&&(c=U(g),a(c))}e.__value=c,n=!1}),ce(e)}function U(e){return"__value"in e?e.__value:e.value}const $=Symbol("class"),j=Symbol("style"),ue=Symbol("is custom element"),fe=Symbol("is html"),pt=W?"link":"LINK",yt=W?"input":"INPUT",gt=W?"option":"OPTION",vt=W?"select":"SELECT",bt=W?"progress":"PROGRESS";function ht(e){if(O){var r=!1,a=()=>{if(!r){if(r=!0,e.hasAttribute("value")){var s=e.value;B(e,"value",null),e.value=s}if(e.hasAttribute("checked")){var n=e.checked;B(e,"checked",null),e.checked=n}}};e.__on_r=a,Qe(a),Xe()}}function Rt(e,r){var a=ee(e);a.value===(a.value=r??void 0)||e.value===r&&(r!==0||e.nodeName!==bt)||(e.value=r??"")}function mt(e,r){r?e.hasAttribute("selected")||e.setAttribute("selected",""):e.removeAttribute("selected")}function B(e,r,a,s){var n=ee(e);O&&(n[r]=e.getAttribute(r),r==="src"||r==="srcset"||r==="href"&&e.nodeName===pt)||n[r]!==(n[r]=a)&&(r==="loading"&&(e[Ge]=a),a==null?e.removeAttribute(r):typeof a!="string"&&de(e).includes(r)?e[r]=a:e.setAttribute(r,a))}function _t(e,r,a,s,n=!1,c=!1){if(O&&n&&e.nodeName===yt){var f=e,g=f.type==="checkbox"?"defaultChecked":"defaultValue";g in a||ht(f)}var p=ee(e),h=p[ue],T=!p[fe];let m=O&&h;m&&te(!1);var y=r||{},M=e.nodeName===gt;for(var S in r)S in a||(a[S]=null);a.class?a.class=lt(a.class):(s||a[$])&&(a.class=null),a[j]&&(a.style??=null);var I=de(e);for(const v in a){let b=a[v];if(M&&v==="value"&&b==null){e.value=e.__value="",y[v]=b;continue}if(v==="class"){var F=e.namespaceURI==="http://www.w3.org/1999/xhtml";ft(e,F,b,s,r?.[$],a[$]),y[v]=b,y[$]=a[$];continue}if(v==="style"){dt(e,b,r?.[j],a[j]),y[v]=b,y[j]=a[j];continue}var C=y[v];if(!(b===C&&!(b===void 0&&e.hasAttribute(v)))){y[v]=b;var N=v[0]+v[1];if(N!=="$$")if(N==="on"){const k={},P="$$"+v;let A=v.slice(2);var D=Ze(A);if(De(A)&&(A=A.slice(0,-7),k.capture=!0),!D&&C){if(b!=null)continue;e.removeEventListener(A,y[P],k),y[P]=null}if(D)Ke(A,e,b),Ye([A]);else if(b!=null){let V=function(H){y[v].call(this,H)};y[P]=qe(A,e,V,k)}}else if(v==="style")B(e,v,b);else if(v==="autofocus")Be(e,!!b);else if(!h&&(v==="__value"||v==="value"&&b!=null))e.value=e.__value=b;else if(v==="selected"&&M)mt(e,b);else{var w=v;T||(w=Ve(w));var K=w==="defaultValue"||w==="defaultChecked";if(b==null&&!h&&!K)if(p[v]=null,w==="value"||w==="checked"){let k=e;const P=r===void 0;if(w==="value"){let A=k.defaultValue;k.removeAttribute(w),k.defaultValue=A,k.value=k.__value=P?A:null}else{let A=k.defaultChecked;k.removeAttribute(w),k.defaultChecked=A,k.checked=P?A:!1}}else e.removeAttribute(v);else K||I.includes(w)&&(h||typeof b!="string")?(e[w]=b,w in p&&(p[w]=He)):typeof b!="function"&&B(e,w,b)}}}return m&&te(!0),y}function Nt(e,r,a=[],s=[],n=[],c,f=!1,g=!1){Ne(n,a,s,p=>{var h=void 0,T={},m=e.nodeName===vt,y=!1;if(ie(()=>{var S=r(...p.map(d)),I=_t(e,h,S,c,f,g);y&&m&&"value"in S&&q(e,S.value);for(let C of Object.getOwnPropertySymbols(T))S[C]||J(T[C]);for(let C of Object.getOwnPropertySymbols(S)){var F=S[C];C.description===Ue&&(!h||F!==h[C])&&(T[C]&&J(T[C]),T[C]=oe(()=>it(e,()=>F))),I[C]=F}h=I}),m){var M=e;x(()=>{q(M,h.value,!0),ce(M)})}y=!0})}function ee(e){return e.__attributes??={[ue]:e.nodeName.includes("-"),[fe]:e.namespaceURI===$e}}var ne=new Map;function de(e){var r=e.getAttribute("is")||e.nodeName,a=ne.get(r);if(a)return a;ne.set(r,a=[]);for(var s,n=e,c=Element.prototype;c!==n;){s=We(n);for(var f in s)s[f].set&&a.push(f);n=je(n)}return a}const At=new Set(["name","created_at","updated_at"]);function Et(e){return e.replace(/-/g," ").replace(/\b\w/g,r=>r.toUpperCase())}function St(e,r){return{id:e.id,title:e.data?.name??Et(e.id),entityType:e.entityType,repo:r,hasSubContent:!!e.hasSubContent,wikilinks:e.document?.wikilinks??[],createdAt:e.data?.created_at??null,updatedAt:e.data?.updated_at??null,fields:Object.fromEntries(Object.entries(e.data??{}).filter(([a])=>!At.has(a))),status:e.data?.status??void 0,priority:e.data?.priority??void 0,assignee:e.data?.assignee??void 0,dueDate:e.data?.due_date??void 0}}function $t(e){return e.split("/")[0]}const Ct=new Set(["meeting","decision","note","deal","proposal","brief"]);function G(e,r){return r||e.split("-").map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}const Tt="#FE3C3C",pe="sg-accent";function ye(e){if(typeof document>"u")return;const r=e||Tt,a=parseInt(r.slice(1,3),16),s=parseInt(r.slice(3,5),16),n=parseInt(r.slice(5,7),16),c=document.documentElement;c.style.setProperty("--color-accent",r),c.style.setProperty("--color-accent-hover",se(r,15)),c.style.setProperty("--color-accent-fg-light",se(r,22)),c.style.setProperty("--color-accent-fg-dark",wt(r,18)),c.style.setProperty("--color-accent-bg",r),c.style.setProperty("--color-accent-muted",`rgba(${a}, ${s}, ${n}, 0.08)`),c.style.setProperty("--color-badge-bg",`rgba(${a}, ${s}, ${n}, 0.1)`),c.style.setProperty("--color-badge-text",r);try{localStorage.setItem(pe,r)}catch{}}function jt(){if(!(typeof document>"u"))try{const e=localStorage.getItem(pe);e&&ye(e)}catch{}}function se(e,r){const a=Math.max(0,Math.round(parseInt(e.slice(1,3),16)*(1-r/100))),s=Math.max(0,Math.round(parseInt(e.slice(3,5),16)*(1-r/100))),n=Math.max(0,Math.round(parseInt(e.slice(5,7),16)*(1-r/100)));return`#${a.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function wt(e,r){const a=f=>Math.min(255,Math.round(f+(255-f)*(r/100))),s=a(parseInt(e.slice(1,3),16)),n=a(parseInt(e.slice(3,5),16)),c=a(parseInt(e.slice(5,7),16));return`#${s.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}${c.toString(16).padStart(2,"0")}`}function kt(){let e=L(""),r=L(null),a=L(!1),s=L(!1),n=R([]);const c={};let f=L(!1),g=L(null),p=L(R({})),h=R({}),T=R({}),m=R({}),y=L(0),M=L(null),S=L(""),I=null,F=L(0),C=L(0),N=L(R(typeof localStorage<"u"?localStorage.getItem("sg-sidebar-sort")??"recent":"recent"));async function D(){_(f,!0),_(g,null),_(F,0),_(C,0);try{const t=await nt().catch(()=>({name:""}));_(e,t.name,!0),_(r,t.about??null,!0),_(a,!0);const l=await X(),o=new Map(n.map(i=>[i.name,i])),u=new Set;for(const i of l){u.add(i.name);const E=o.get(i.name);E?(E.displayName=G(i.name,i.display_name),E.type=i.type,E.personal=i.personal,E.sync=i.sync,E.callerRole=i.caller_role??null,E.memberCount=i.member_count??1,E.entityTypes=i.entity_types??[]):n.push({name:i.name,displayName:G(i.name,i.display_name),type:i.type,personal:i.personal,sync:i.sync,count:null,entities:[],loading:!1,loaded:!1,callerRole:i.caller_role??null,memberCount:i.member_count??1,entityTypes:i.entity_types??[]})}for(let i=n.length-1;i>=0;i--)u.has(n[i].name)||n.splice(i,1);_(s,!0),V().catch(()=>{})}catch(t){_(g,t.message,!0)}finally{_(f,!1)}}function w(t,l,o){const u=n.find(i=>i.name===t);u&&(u.entities=u.entities.filter(i=>!(i.id===o&&i.entityType===l)),u.count=u.entities.length)}function K(t,l){const o=n.find(u=>u.name===t);o&&(o.memberCount=l)}async function v(t){n.find(o=>o.name===t)&&await A(t,!0)}function b(t,l){const o=n.find(i=>i.name===t);if(!o||o.entityTypes.includes(l))return;const u=[...o.entityTypes,l].sort();o.entityTypes=u}async function k(){_(F,0),_(C,0),await Promise.all(n.map(t=>A(t.name,!0)))}function P(t,l){let o=0,u=0;for(const i of l)o+=i.document?.wikilinks?.length??0,u+=i.subContentCount??0;_(F,d(F)+o),_(C,d(C)+u),t.entities=l.filter(i=>!i.id.toLowerCase().startsWith("readme")).map(i=>St(i,t.name)).sort((i,E)=>{if(Ct.has(i.entityType)){const we=i.fields.date??i.createdAt??"";return(E.fields.date??E.createdAt??"").localeCompare(we)}return i.title.localeCompare(E.title)}),t.count=t.entities.length,t.loaded=!0}async function A(t,l=!1){const o=n.find(i=>i.name===t);if(!o||o.loading||!l&&o.loaded)return;const u=(c[t]??0)+1;c[t]=u,l||(o.loading=!0);try{const i=await at(t);if(c[t]!==u)return;P(o,i)}catch(i){console.error(`Failed to load entities for ${t}:`,i)}finally{o.loading=!1}}async function V(){for(const t of n)c[t.name]=(c[t.name]??0)+1,t.loaded||(t.loading=!0);try{const t=await st();for(const l of n){const o=t[l.name];o&&P(l,o)}}catch(t){console.error("Bulk loadAllEntities failed:",t)}finally{for(const t of n)t.loading=!1}}function H(t){d(p)[t]=!d(p)[t]}function ge(t){return d(p)[t]??!1}function Y(t,l,o){return`${t}/${l}/${o}`}function ve(t,l,o){const u=Y(t,l,o),i=h[u]??!1;h[u]=!i,!i&&!T[u]?.loaded&&me(t,l,o)}function be(t,l,o){return h[Y(t,l,o)]??!1}function he(t,l,o){return T[Y(t,l,o)]??{entries:[],loading:!1,loaded:!1}}async function me(t,l,o){const u=Y(t,l,o);T[u]={entries:[],loading:!1,loaded:!0}}function _e(t){const l=d(S).trim().toLowerCase();if(!l)return t;const o=[];for(const u of t){const i=u.entities.filter(E=>E.title.toLowerCase().includes(l)||E.id.toLowerCase().includes(l));i.length>0&&o.push({...u,entities:i,count:i.length})}return o}function Ae(t){if(t&&!d(S)?I={...d(p)}:!t&&d(S)&&I&&(_(p,I,!0),I=null),_(S,t,!0),t){const l=t.trim().toLowerCase();for(const o of n){const u=o.entities.some(i=>i.title.toLowerCase().includes(l)||i.id.toLowerCase().includes(l));d(p)[o.name]=u}}}function Ee(t){const l=t.startsWith("type:");m[t]=!(m[t]??l)}function Se(t){return m[t]??!1}function Ce(t){return m[t]===!1}const Te=ze(()=>n.reduce((t,l)=>t+(l.count??0),0));return{get name(){return d(e)},get about(){return d(r)},get nameLoaded(){return d(a)},get entriesLoaded(){return d(s)},async updateWorkspace(t){await rt(t),t.name?.trim()&&_(e,t.name.trim(),!0),typeof t.about=="string"&&_(r,t.about,!0)},get repos(){return n},get loading(){return d(f)},get error(){return d(g)},get totalEntities(){return d(Te)},get totalLinks(){return d(F)},get totalFiles(){return d(C)},get hasTasks(){return n.some(t=>t.entities.some(l=>l.entityType==="task"))},get sortedRepos(){const t=[...n].sort((l,o)=>l.displayName.localeCompare(o.displayName));return _e(t)},get filteredIds(){const t=d(S).trim().toLowerCase();if(!t)return null;const l=new Set;for(const o of n)for(const u of o.entities)(u.title.toLowerCase().includes(t)||u.id.toLowerCase().includes(t))&&l.add(u.id);return l},get filterQuery(){return d(S)},setFilterQuery:Ae,get sortMode(){return d(N)},set sortMode(t){_(N,t,!0),typeof localStorage<"u"&&localStorage.setItem("sg-sidebar-sort",t)},get recentEntities(){const t=d(S).trim().toLowerCase();let l=[];for(const o of n)for(const u of o.entities)t&&!u.title.toLowerCase().includes(t)&&!u.id.toLowerCase().includes(t)||l.push(u);return l.sort((o,u)=>{const i=o.updatedAt??"";return(u.updatedAt??"").localeCompare(i)})},get sidebarScrollTop(){return d(y)},set sidebarScrollTop(t){_(y,t,!0)},get lastAutoExpandedFor(){return d(M)},set lastAutoExpandedFor(t){_(M,t,!0)},load:D,loadEntities:A,removeEntity:w,setFolderMemberCount:K,refreshEntities:v,ensureEntityType:b,refreshAll:k,toggleRepo:H,isExpanded:ge,toggleEntity:ve,isEntityExpanded:be,getEntityContents:he,toggleFolder:Ee,isFolderExpanded:Se,isFolderCollapsed:Ce,applyAccentColor:ye,async renameFolderTo(t,l,o){await tt(t,o,l);const u=n.find(i=>i.name===t);u&&(u.displayName=l||G(o??t),o&&o!==t&&(u.name=o,d(p)[t]&&(d(p)[o]=!0,delete d(p)[t])))},async removeFolder(t){await et(t);const l=n.findIndex(o=>o.name===t);l>=0&&n.splice(l,1),delete d(p)[t]},async addFolder(t,l,o){await xe(t,l,o);const i=(await X()).find(E=>E.name===t);i&&!n.some(E=>E.name===i.name)&&n.push({name:i.name,displayName:G(i.name,i.display_name),type:i.type,personal:i.personal,sync:i.sync,count:null,entities:[],loading:!1,loaded:!1,callerRole:i.caller_role??null,memberCount:i.member_count??1,entityTypes:i.entity_types??[]}),d(p)[t]=!0,await A(t)},async onFolderAccessGranted(t){if(n.some(u=>u.name===t))return;const o=(await X()).find(u=>u.name===t);o&&(n.push({name:o.name,displayName:G(o.name,o.display_name),type:o.type,personal:o.personal,sync:o.sync,count:null,entities:[],loading:!1,loaded:!1,callerRole:o.caller_role??null,memberCount:o.member_count??1,entityTypes:o.entity_types??[]}),await A(t))},onFolderAccessRevoked(t){const l=n.findIndex(o=>o.name===t);l>=0&&n.splice(l,1),delete d(p)[t]}}}const Gt=kt();export{j as S,Nt as a,ft as b,ot as c,B as d,ht as e,dt as f,lt as g,jt as h,Rt as i,Ot as j,$t as r,Pt as s,St as t,Gt as w};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{V as d}from"./Dmcboreb.js";import{a2 as k}from"./iRhbt-db.js";const e=k({open:!1,query:"",from:0,to:0,rect:null,view:null,selectedIdx:0});function c(){e.open=!1,e.query="",e.rect=null,e.view=null,e.selectedIdx=0}const w=/\[\[([^\[\]\n]*)$/,h=d.fromClass(class{constructor(t){this.update({view:t,docChanged:!0,selectionSet:!0})}update(t){if(!t.docChanged&&!t.selectionSet&&!t.viewportChanged)return;const n=t.view,r=n.state.selection.main;if(r.from!==r.to){e.open&&c();return}const o=r.from,u=Math.max(0,o-256),s=n.state.sliceDoc(u,o),i=w.exec(s);if(!i){e.open&&c();return}const p=u+i.index+2,f=s.slice(i.index+2),m=!e.open||e.query!==f;e.open=!0,e.query=f,e.from=p,e.to=o,e.view=n,m&&(e.selectedIdx=0),queueMicrotask(()=>{if(!e.open)return;const l=n.coordsAtPos(e.to);l&&(e.rect={left:l.left,top:l.top,bottom:l.bottom})})}destroy(){e.open&&c()}}),v=[{key:"ArrowDown",run:t=>e.open?(t.dom.dispatchEvent(new CustomEvent("sg-wikilink-nav",{detail:1})),!0):!1},{key:"ArrowUp",run:t=>e.open?(t.dom.dispatchEvent(new CustomEvent("sg-wikilink-nav",{detail:-1})),!0):!1},{key:"Enter",run:t=>e.open?(t.dom.dispatchEvent(new CustomEvent("sg-wikilink-apply")),!0):!1},{key:"Escape",run:()=>e.open?(c(),!0):!1}];function y(t){const{view:n,from:r,to:o}=e;if(!n)return;const s=n.state.sliceDoc(o,Math.min(o+2,n.state.doc.length))!=="]]",i=s?`${t}]]`:t,a=r+i.length+(s?0:2);n.dispatch({changes:{from:r,to:o,insert:i},selection:{anchor:a},userEvent:"input.complete"}),c(),n.focus()}const x=Object.freeze(Object.defineProperty({__proto__:null,applyWikilinkPick:y,wikilinkKeymap:v,wikilinkPlugin:h},Symbol.toStringTag,{value:"Module"}));export{y as a,x as b,c,e as w};
|