@theruansilva/omp-web 2.2.2 → 2.3.0
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/client/assets/{CodeViewer-DFvO6hY8.js → CodeViewer-DHlYSlFA.js} +2 -2
- package/dist/client/assets/TerminalPanel-B7ErBads.js +126 -0
- package/dist/client/assets/{UnifiedDiffViewer-BjuD29RQ.js → UnifiedDiffViewer-Bsxe8vEO.js} +1 -1
- package/dist/client/assets/{abnfDiagram-O67JEVCF-SLRtz9OB.js → abnfDiagram-O67JEVCF-Bd6-T6CG.js} +1 -1
- package/dist/client/assets/{arc-CUNKbxyw.js → arc-Cx4UzFEe.js} +1 -1
- package/dist/client/assets/{architectureDiagram-NJMV4G6O-Cg80o9g4.js → architectureDiagram-NJMV4G6O-DNZZOJHJ.js} +1 -1
- package/dist/client/assets/{blockDiagram-BEXU5L5S-nZRhUgoO.js → blockDiagram-BEXU5L5S-DLGMX1ky.js} +2 -2
- package/dist/client/assets/{c4Diagram-YGBWAQC7-B2q8gSrU.js → c4Diagram-YGBWAQC7-ZicrYBFE.js} +1 -1
- package/dist/client/assets/channel-Cy0oVDAk.js +1 -0
- package/dist/client/assets/{chunk-2Q5K7J3B-flkpXKt7.js → chunk-2Q5K7J3B-BTdneniS.js} +1 -1
- package/dist/client/assets/{chunk-3FUC2YCW-kMKg81Pk.js → chunk-3FUC2YCW-DClqbl7t.js} +2 -2
- package/dist/client/assets/{chunk-5VM5RSS4-3Lib-uGP.js → chunk-5VM5RSS4-xVtxN_Sa.js} +1 -1
- package/dist/client/assets/{chunk-GTNCS2PH-CdX8cblt.js → chunk-GTNCS2PH-Da56Sthk.js} +1 -1
- package/dist/client/assets/{chunk-GWA4HPMP-CwHQm4wS.js → chunk-GWA4HPMP-D40kcLEo.js} +1 -1
- package/dist/client/assets/{chunk-JWPE2WC7-BsqVo0Tf.js → chunk-JWPE2WC7-CVgZV6Wp.js} +1 -1
- package/dist/client/assets/{chunk-NETBCI7D-p3q1dAb3.js → chunk-NETBCI7D-DNI4Nu1k.js} +1 -1
- package/dist/client/assets/{chunk-WEXAMYUT-Bv_MfOEM.js → chunk-WEXAMYUT-IVsvOCJJ.js} +1 -1
- package/dist/client/assets/{chunk-XXDRQBXY-w71UKmME.js → chunk-XXDRQBXY-ByZI65OQ.js} +1 -1
- package/dist/client/assets/{classDiagram-v2-NBCMYWYE-Ch9Lx94A.js → classDiagram-v2-NBCMYWYE-CT9N6_lF.js} +1 -1
- package/dist/client/assets/{cose-bilkent-JH36ORCC-BrpIQScu.js → cose-bilkent-JH36ORCC-CBJJYOd5.js} +1 -1
- package/dist/client/assets/{cynefin-OW5HDTMX-CRiWF9ki.js → cynefin-OW5HDTMX-BUpMG_46.js} +1 -1
- package/dist/client/assets/{cynefinDiagram-VND7K2PF-qbMIgfpH.js → cynefinDiagram-VND7K2PF-otEJqM7K.js} +1 -1
- package/dist/client/assets/dagre-6A5THRUB-qquzH4Ev.js +4 -0
- package/dist/client/assets/{diagram-22UHCM2B-B8hKRE_o.js → diagram-22UHCM2B-HDLtgJRK.js} +1 -1
- package/dist/client/assets/{diagram-3UASUU5V-B4uZ3GNA.js → diagram-3UASUU5V-Bc2_UO5k.js} +1 -1
- package/dist/client/assets/{diagram-ATOU4E4O-CzGwlb-Y.js → diagram-ATOU4E4O-DR72H135.js} +1 -1
- package/dist/client/assets/{diagram-CDSNMT55-BXiuQ_UO.js → diagram-CDSNMT55-hNm66Cr9.js} +1 -1
- package/dist/client/assets/{diagram-MLGK6HIB-Dsw8Iqaq.js → diagram-MLGK6HIB-ChaEhVd4.js} +1 -1
- package/dist/client/assets/{diagram-MPIPVDR6-T4zPzapt.js → diagram-MPIPVDR6-gYxYar4V.js} +1 -1
- package/dist/client/assets/{ebnfDiagram-ZINNZB2B-CnvJApL-.js → ebnfDiagram-ZINNZB2B-CRQjE5YW.js} +1 -1
- package/dist/client/assets/{elk-276RUBZZ-C0qbqSzX.js → elk-276RUBZZ-OZ3Zw5zt.js} +3 -3
- package/dist/client/assets/{erDiagram-OPXOYQCR-CPCRCRVW.js → erDiagram-OPXOYQCR-CB71jEyA.js} +1 -1
- package/dist/client/assets/{flowDiagram-KWPJA3E3-CRR5EuoG.js → flowDiagram-KWPJA3E3-CYfjFu_3.js} +1 -1
- package/dist/client/assets/{ganttDiagram-FUAMR5RP-CCJy4INc.js → ganttDiagram-FUAMR5RP-BE7B_UzV.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-X574FWY7-BiGivFUj.js → gitGraphDiagram-X574FWY7-HBid3FDo.js} +1 -1
- package/dist/client/assets/graph-D8UmR1vK.js +1 -0
- package/dist/client/assets/{index-DqFyJdiT.js → index-C-cQEbCY.js} +358 -333
- package/dist/client/assets/{infoDiagram-VRGFBTTK-BdSqUdzZ.js → infoDiagram-VRGFBTTK-4JprhzHA.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-OU5B5YK6-Bto15O_-.js → ishikawaDiagram-OU5B5YK6-UAP9bqUn.js} +1 -1
- package/dist/client/assets/{journeyDiagram-ZHPQQLJL-C1FkG7_Y.js → journeyDiagram-ZHPQQLJL-j9c9R8jU.js} +1 -1
- package/dist/client/assets/{kanban-definition-PNTS6WVX-7Og64Ylp.js → kanban-definition-PNTS6WVX-DWQBxist.js} +1 -1
- package/dist/client/assets/{linear-CYEx6yMl.js → linear-T6d_7ZeJ.js} +1 -1
- package/dist/client/assets/{mindmap-definition-NLK3R4M7-BDi04G8P.js → mindmap-definition-NLK3R4M7-CvMFAKuS.js} +1 -1
- package/dist/client/assets/{pegDiagram-GJSIUBJH-niwxJYhI.js → pegDiagram-GJSIUBJH-hvF632kF.js} +1 -1
- package/dist/client/assets/{pieDiagram-5QR66LMP-DUKBH1DT.js → pieDiagram-5QR66LMP-BXICkLn_.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-O4NWA36T-DA4vON7R.js → quadrantDiagram-O4NWA36T-CnFY0fxq.js} +1 -1
- package/dist/client/assets/{railroadDiagram-XR7U4H2S-CHDT9c0L.js → railroadDiagram-XR7U4H2S-BeRVo7yu.js} +1 -1
- package/dist/client/assets/{requirementDiagram-PLB6GJNP-D8QwjsX7.js → requirementDiagram-PLB6GJNP-DmnKxfFp.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-IPEJSGJF-DWGxFQm3.js → sankeyDiagram-IPEJSGJF-Bz1YIaMr.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-PO4LG4MO-_ejeE6EX.js → sequenceDiagram-PO4LG4MO-4cmBIYSV.js} +1 -1
- package/dist/client/assets/{sizeCapture-INFHLROL-QLEMuHkm.js → sizeCapture-INFHLROL-B6mTYfgL.js} +1 -1
- package/dist/client/assets/{stateDiagram-v2-GCMORJYK-Gd_SeXN9.js → stateDiagram-v2-GCMORJYK-BKkiHc4R.js} +1 -1
- package/dist/client/assets/swimlanes-2SLR337P-CBONvDhF.js +1 -0
- package/dist/client/assets/swimlanesDiagram-TC7HE7FX-DUA_t92u.js +8 -0
- package/dist/client/assets/{timeline-definition-EJHVYXUP-DYl9dUjO.js → timeline-definition-EJHVYXUP-BG9z7YWj.js} +1 -1
- package/dist/client/assets/usecaseDiagram-POWQR4AR--yXc6tgF.js +370 -0
- package/dist/client/assets/{vendor-editor-core-D-5q2tVX.js → vendor-editor-core-DbsheCh1.js} +30 -29
- package/dist/client/assets/vendor-editor-languages-B1l-thbw.js +26 -0
- package/dist/client/assets/{vennDiagram-UO4OBE2U-Ded7JPVG.js → vennDiagram-UO4OBE2U-DYr42cwJ.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-VNRHLVJA-losDIeQr.js → wardleyDiagram-VNRHLVJA-DksCy2aR.js} +1 -1
- package/dist/client/assets/{xychartDiagram-PMCCYNJV-B7_BBfaW.js → xychartDiagram-PMCCYNJV-DPxnNxcI.js} +1 -1
- package/dist/client/index.html +3 -3
- package/dist/config.js +10 -0
- package/dist/config.js.map +1 -1
- package/dist/omp-web-plugins/usage/omp-web-plugin.js +41 -0
- package/dist/omp-web-plugins/usage/package.json +9 -0
- package/dist/omp-web-plugins/usage/types.js +2 -0
- package/dist/omp-web-plugins/usage/usageLogic.js +162 -0
- package/dist/omp-web-plugins/usage/usagePanelElement.js +442 -0
- package/dist/server/app.js +36 -1
- package/dist/server/app.js.map +1 -1
- package/dist/server/index.js +11 -3
- package/dist/server/index.js.map +1 -1
- package/dist/server/machines/machineProxyRoutes.js +16 -1
- package/dist/server/machines/machineProxyRoutes.js.map +1 -1
- package/dist/server/machines/machineService.js +5 -5
- package/dist/server/machines/machineService.js.map +1 -1
- package/dist/server/mcpRoutes.js +11 -1
- package/dist/server/mcpRoutes.js.map +1 -1
- package/dist/server/projects/projectService.js +23 -0
- package/dist/server/projects/projectService.js.map +1 -1
- package/dist/server/security.js +110 -7
- package/dist/server/security.js.map +1 -1
- package/dist/server/sessions/authService.js +23 -3
- package/dist/server/sessions/authService.js.map +1 -1
- package/dist/server/sessions/piAgentSession.js +46 -1
- package/dist/server/sessions/piAgentSession.js.map +1 -1
- package/dist/server/sessions/sessionCommandService.js +20 -9
- package/dist/server/sessions/sessionCommandService.js.map +1 -1
- package/dist/server/terminalProxyRoutes.js +16 -1
- package/dist/server/terminalProxyRoutes.js.map +1 -1
- package/dist/server/usageRoutes.js +202 -0
- package/dist/server/usageRoutes.js.map +1 -0
- package/dist/server/webSocketBridge.js +15 -0
- package/dist/server/webSocketBridge.js.map +1 -1
- package/dist/shared/apiTypes.d.ts +2 -0
- package/dist/shared/federatedRoutes.js +2 -0
- package/dist/shared/federatedRoutes.js.map +1 -1
- package/package.json +1 -1
- package/dist/client/assets/TerminalPanel-zgTnfKO5.js +0 -126
- package/dist/client/assets/_basePickBy-vr4256UX.js +0 -1
- package/dist/client/assets/_baseUniq-CHc60b6y.js +0 -1
- package/dist/client/assets/channel-CI4_doFA.js +0 -1
- package/dist/client/assets/dagre-6A5THRUB-CNLq2-K8.js +0 -4
- package/dist/client/assets/graph-C2De1HlQ.js +0 -1
- package/dist/client/assets/swimlanes-2SLR337P-BOtWDtXR.js +0 -1
- package/dist/client/assets/swimlanesDiagram-TC7HE7FX-CMZDG2D-.js +0 -8
- package/dist/client/assets/usecaseDiagram-POWQR4AR-B_DlB3UM.js +0 -370
- package/dist/client/assets/vendor-editor-languages-B6WRt0aC.js +0 -26
package/dist/client/assets/{vendor-editor-core-D-5q2tVX.js → vendor-editor-core-DbsheCh1.js}
RENAMED
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
let Ds=[],yh=[];(()=>{let r="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<r.length;e++)(e%2?yh:Ds).push(t=t+r[e])})();function qc(r){if(r<768)return!1;for(let e=0,t=Ds.length;;){let i=e+t>>1;if(r<Ds[i])t=i;else if(r>=yh[i])e=i+1;else return!0;if(e==t)return!1}}function Hl(r){return r>=127462&&r<=127487}const Wl=8205;function Uc(r,e,t=!0,i=!0){return(t?kh:Jc)(r,e,i)}function kh(r,e,t){if(e==r.length)return e;e&&xh(r.charCodeAt(e))&&wh(r.charCodeAt(e-1))&&e--;let i=as(r,e);for(e+=Vl(i);e<r.length;){let n=as(r,e);if(i==Wl||n==Wl||t&&qc(n))e+=Vl(n),i=n;else if(Hl(n)){let s=0,o=e-2;for(;o>=0&&Hl(as(r,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function Jc(r,e,t){for(;e>1;){let i=kh(r,e-2,t);if(i<e)return i;e--}return 0}function as(r,e){let t=r.charCodeAt(e);if(!wh(t)||e+1==r.length)return t;let i=r.charCodeAt(e+1);return xh(i)?(t-55296<<10)+(i-56320)+65536:t}function xh(r){return r>=56320&&r<57344}function wh(r){return r>=55296&&r<56320}function Vl(r){return r<65536?1:2}let ce=class bh{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Yi(this,e,t);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(t,this.length,n,1),Vt.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Yi(this,e,t);let i=[];return this.decompose(e,t,i,0),Vt.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new kn(this),s=new kn(e);for(let o=t,l=t;;){if(n.next(o),s.next(o),o=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(l+=n.value.length,n.done||l>=i)return!0}}iter(e=1){return new kn(this,e)}iterRange(e,t=this.length){return new Sh(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Ch(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?bh.empty:e.length<=32?new Be(e):Vt.from(Be.split(e,[]))}};class Be extends ce{constructor(e,t=Gc(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let s=0;;s++){let o=this.text[s],l=n+o.length;if((t?i:l)>=e)return new Yc(n,l,i,o);n=l+1,i++}}decompose(e,t,i,n){let s=e<=0&&t>=this.length?this:new Be(Kl(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(n&1){let o=i.pop(),l=lr(s.text,o.text.slice(),0,s.length);if(l.length<=32)i.push(new Be(l,o.length+s.length));else{let h=l.length>>1;i.push(new Be(l.slice(0,h)),new Be(l.slice(h)))}}else i.push(s)}replace(e,t,i){if(!(i instanceof Be))return super.replace(e,t,i);[e,t]=Yi(this,e,t);let n=lr(this.text,lr(i.text,Kl(this.text,0,e)),t),s=this.length+i.length-(t-e);return n.length<=32?new Be(n,s):Vt.from(Be.split(n,[]),s)}sliceString(e,t=this.length,i=`
|
|
1
|
+
let jc=0,vt=class{constructor(e,t){this.from=e,this.to=t}};class se{constructor(e={}){this.id=jc++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=nt.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}se.closedBy=new se({deserialize:r=>r.split(" ")});se.openedBy=new se({deserialize:r=>r.split(" ")});se.group=new se({deserialize:r=>r.split(" ")});se.isolate=new se({deserialize:r=>{if(r&&r!="rtl"&&r!="ltr"&&r!="auto")throw new RangeError("Invalid value for isolate: "+r);return r||"auto"}});se.contextHash=new se({perNode:!0});se.lookAhead=new se({perNode:!0});se.mounted=new se({perNode:!0});class $i{constructor(e,t,i,n=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=n}static get(e){return e&&e.props&&e.props[se.mounted.id]}}const qc=Object.create(null);class nt{constructor(e,t,i,n=0){this.name=e,this.props=t,this.id=i,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):qc,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),n=new nt(e.name||"",t,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(n)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return n}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(se.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let n of i.split(" "))t[n]=e[i];return i=>{for(let n=i.prop(se.group),s=-1;s<(n?n.length:0);s++){let o=t[s<0?i.name:n[s]];if(o)return o}}}}nt.none=new nt("",Object.create(null),0,8);class Ao{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let n=null;for(let s of e){let o=s(i);if(o){n||(n=Object.assign({},i.props));let l=o[1],h=o[0];h.combine&&h.id in n&&(l=h.combine(n[h.id],l)),n[h.id]=l}}t.push(n?new nt(i.name,n,i.id,i.flags):i)}return new Ao(t)}}const jn=new WeakMap,Hl=new WeakMap;var ye;(function(r){r[r.ExcludeBuffers=1]="ExcludeBuffers",r[r.IncludeAnonymous=2]="IncludeAnonymous",r[r.IgnoreMounts=4]="IgnoreMounts",r[r.IgnoreOverlays=8]="IgnoreOverlays",r[r.EnterBracketed=16]="EnterBracketed"})(ye||(ye={}));class Ae{constructor(e,t,i,n,s){if(this.type=e,this.children=t,this.positions=i,this.length=n,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,l]of s)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=$i.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let n=i.toString();n&&(t&&(t+=","),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new gr(this.topNode,e)}cursorAt(e,t=0,i=0){let n=jn.get(this)||this.topNode,s=new gr(n);return s.moveTo(e,t),jn.set(this,s._tree),s}get topNode(){return new Ye(this,0,0,null)}resolve(e,t=0){let i=An(jn.get(this)||this.topNode,e,t,!1);return jn.set(this,i),i}resolveInner(e,t=0){let i=An(Hl.get(this)||this.topNode,e,t,!0);return Hl.set(this,i),i}resolveStack(e,t=0){return Gc(this,e,t)}iterate(e){let{enter:t,leave:i,from:n=0,to:s=this.length}=e,o=e.mode||0,l=(o&ye.IncludeAnonymous)>0;for(let h=this.cursor(o|ye.IncludeAnonymous);;){let u=!1;if(h.from<=s&&h.to>=n&&(!l&&h.type.isAnonymous||t(h)!==!1)){if(h.firstChild())continue;u=!0}for(;u&&i&&(l||!h.type.isAnonymous)&&i(h),!h.nextSibling();){if(!h.parent())return;u=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Oo(nt.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,n)=>new Ae(this.type,t,i,n,this.propValues),e.makeTree||((t,i,n)=>new Ae(nt.none,t,i,n)))}static build(e){return Yc(e)}}Ae.empty=new Ae(nt.none,[],[],0);class Mo{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Mo(this.buffer,this.index)}}class hi{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return nt.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],n=this.set.types[t],s=n.name;if(/\W/.test(s)&&!n.isError&&(s=JSON.stringify(s)),e+=4,i==e)return s;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,t,i,n,s){let{buffer:o}=this,l=-1;for(let h=e;h!=t&&!(yh(s,n,o[h+1],o[h+2])&&(l=h,i>0));h=o[h+3]);return l}slice(e,t,i){let n=this.buffer,s=new Uint16Array(t-e),o=0;for(let l=e,h=0;l<t;){s[h++]=n[l++],s[h++]=n[l++]-i;let u=s[h++]=n[l++]-i;s[h++]=n[l++]-e,o=Math.max(o,u)}return new hi(s,o,this.set)}}function yh(r,e,t,i){switch(r){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function An(r,e,t,i){for(var n;r.from==r.to||(t<1?r.from>=e:r.from>e)||(t>-1?r.to<=e:r.to<e);){let o=!i&&r instanceof Ye&&r.index<0?null:r.parent;if(!o)return r;r=o}let s=i?0:ye.IgnoreOverlays;if(i)for(let o=r,l=o.parent;l;o=l,l=o.parent)o instanceof Ye&&o.index<0&&((n=l.enter(e,t,s))===null||n===void 0?void 0:n.from)!=o.from&&(r=l);for(;;){let o=r.enter(e,t,s);if(!o)return r;r=o}}class kh{cursor(e=0){return new gr(this,e)}getChild(e,t=null,i=null){let n=Wl(this,e,t,i);return n.length?n[0]:null}getChildren(e,t=null,i=null){return Wl(this,e,t,i)}resolve(e,t=0){return An(this,e,t,!1)}resolveInner(e,t=0){return An(this,e,t,!0)}matchContext(e){return Rs(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let n=t.lastChild;if(!n||n.to!=t.to)break;n.type.isError&&n.from==n.to?(i=t,t=n.prevSibling):t=n}return i}get node(){return this}get next(){return this.parent}}class Ye extends kh{constructor(e,t,i,n){super(),this._tree=e,this.from=t,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,n,s=0){for(let o=this;;){for(let{children:l,positions:h}=o._tree,u=t>0?l.length:-1;e!=u;e+=t){let p=l[e],m=h[e]+o.from,y;if(!(!(s&ye.EnterBracketed&&p instanceof Ae&&(y=$i.get(p))&&!y.overlay&&y.bracketed&&i>=m&&i<=m+p.length)&&!yh(n,i,m,m+p.length))){if(p instanceof hi){if(s&ye.ExcludeBuffers)continue;let x=p.findChild(0,p.buffer.length,t,i-m,n);if(x>-1)return new zt(new Uc(o,p,e,m),null,x)}else if(s&ye.IncludeAnonymous||!p.type.isAnonymous||To(p)){let x;if(!(s&ye.IgnoreMounts)&&(x=$i.get(p))&&!x.overlay)return new Ye(x.tree,m,e,o);let S=new Ye(p,m,e,o);return s&ye.IncludeAnonymous||!S.type.isAnonymous?S:S.nextChild(t<0?p.children.length-1:0,t,i,n,s)}}}if(s&ye.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let n;if(!(i&ye.IgnoreOverlays)&&(n=$i.get(this._tree))&&n.overlay){let s=e-this.from,o=i&ye.EnterBracketed&&n.bracketed;for(let{from:l,to:h}of n.overlay)if((t>0||o?l<=s:l<s)&&(t<0||o?h>=s:h>s))return new Ye(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function Wl(r,e,t,i){let n=r.cursor(),s=[];if(!n.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=n.type.is(t),!n.nextSibling())return s}for(;;){if(i!=null&&n.type.is(i))return s;if(n.type.is(e)&&s.push(n.node),!n.nextSibling())return i==null?s:[]}}function Rs(r,e,t=e.length-1){for(let i=r;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}class Uc{constructor(e,t,i,n){this.parent=e,this.buffer=t,this.index=i,this.start=n}}class zt extends kh{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,i);return s<0?null:new zt(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&ye.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new zt(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new zt(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new zt(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,n=this.index+4,s=i.buffer[this.index+3];if(s>n){let o=i.buffer[this.index+1];e.push(i.slice(n,s,o)),t.push(0)}return new Ae(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function xh(r){if(!r.length)return null;let e=0,t=r[0];for(let s=1;s<r.length;s++){let o=r[s];(o.from>t.from||o.to<t.to)&&(t=o,e=s)}let i=t instanceof Ye&&t.index<0?null:t.parent,n=r.slice();return i?n[e]=i:n.splice(e,1),new Jc(n,t)}class Jc{constructor(e,t){this.heads=e,this.node=t}get next(){return xh(this.heads)}}function Gc(r,e,t){let i=r.resolveInner(e,t),n=null;for(let s=i instanceof Ye?i:i.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(n||(n=[i])).push(o.resolve(e,t)),s=o}else{let o=$i.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new Ye(o.tree,o.overlay[0].from+s.from,-1,s);(n||(n=[i])).push(An(l,e,t,!1))}}return n?xh(n):i}class gr{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~ye.EnterBracketed,e instanceof Ye)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=i+n.buffer[e+1],this.to=i+n.buffer[e+2],!0}yield(e){return e?e instanceof Ye?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:n}=this.buffer,s=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&ye.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ye.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ye.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let n=i<0?0:this.stack[i]+4;if(this.index!=n)return this.yieldBuf(t.findChild(n,this.index,-1,0,4))}else{let n=t.buffer[this.index+3];if(n<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(n)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:n}=this;if(n){if(e>0){if(this.index<n.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(n.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:i}=n)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let s=t+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let l=i._tree.children[s];if(this.mode&ye.IncludeAnonymous||l instanceof hi||!l.type.isAnonymous||To(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let n=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==n){if(n==this.index)return o;t=o,i=s+1;break e}n=this.stack[--s]}for(let n=i;n<this.stack.length;n++)t=new zt(this.buffer,t,this.stack[n]);return this.bufferNode=new zt(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let n=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;;){if(n&&t&&t(this),n=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,n=!0}}}matchContext(e){if(!this.buffer)return Rs(this.node.parent,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let n=e.length-1,s=this.stack.length-1;n>=0;s--){if(s<0)return Rs(this._tree,e,n);let o=i[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[n]&&e[n]!=o.name)return!1;n--}}return!0}}function To(r){return r.children.some(e=>e instanceof hi||!e.type.isAnonymous||To(e))}function Yc(r){var e;let{buffer:t,nodeSet:i,maxBufferLength:n=1024,reused:s=[],minRepeatType:o=i.types.length}=r,l=Array.isArray(t)?new Mo(t,t.length):t,h=i.types,u=0,p=0;function m(W,V,N,re,oe,ae){let{id:Z,start:Y,end:ee,size:fe}=l,ge=p,Fe=u;if(fe<0)if(l.next(),fe==-1){let Xe=s[Z];N.push(Xe),re.push(Y-W);return}else if(fe==-3){u=Z;return}else if(fe==-4){p=Z;return}else throw new RangeError(`Unrecognized record size: ${fe}`);let De=h[Z],z,Re,Ue=Y-W;if(ee-Y<=n&&(Re=O(l.pos-V,oe))){let Xe=new Uint16Array(Re.size-Re.skip),xe=l.pos-Re.size,He=Xe.length;for(;l.pos>xe;)He=B(Re.start,Xe,He);z=new hi(Xe,ee-Re.start,i),Ue=Re.start-W}else{let Xe=l.pos-fe;l.next();let xe=[],He=[],dt=Z>=o?Z:-1,ve=0,Di=ee;for(;l.pos>Xe;)dt>=0&&l.id==dt&&l.size>=0?(l.end<=Di-n&&(S(xe,He,Y,ve,l.end,Di,dt,ge,Fe),ve=xe.length,Di=l.end),l.next()):ae>2500?y(Y,Xe,xe,He):m(Y,Xe,xe,He,dt,ae+1);if(dt>=0&&ve>0&&ve<xe.length&&S(xe,He,Y,ve,Y,Di,dt,ge,Fe),xe.reverse(),He.reverse(),dt>-1&&ve>0){let ei=x(De,Fe);z=Oo(De,xe,He,0,xe.length,0,ee-Y,ei,ei)}else z=C(De,xe,He,ee-Y,ge-ee,Fe)}N.push(z),re.push(Ue)}function y(W,V,N,re){let oe=[],ae=0,Z=-1;for(;l.pos>V;){let{id:Y,start:ee,end:fe,size:ge}=l;if(ge>4)l.next();else{if(Z>-1&&ee<Z)break;Z<0&&(Z=fe-n),oe.push(Y,ee,fe),ae++,l.next()}}if(ae){let Y=new Uint16Array(ae*4),ee=oe[oe.length-2];for(let fe=oe.length-3,ge=0;fe>=0;fe-=3)Y[ge++]=oe[fe],Y[ge++]=oe[fe+1]-ee,Y[ge++]=oe[fe+2]-ee,Y[ge++]=ge;N.push(new hi(Y,oe[2]-ee,i)),re.push(ee-W)}}function x(W,V){return(N,re,oe)=>{let ae=0,Z=N.length-1,Y,ee;if(Z>=0&&(Y=N[Z])instanceof Ae){if(!Z&&Y.type==W&&Y.length==oe)return Y;(ee=Y.prop(se.lookAhead))&&(ae=re[Z]+Y.length+ee)}return C(W,N,re,oe,ae,V)}}function S(W,V,N,re,oe,ae,Z,Y,ee){let fe=[],ge=[];for(;W.length>re;)fe.push(W.pop()),ge.push(V.pop()+N-oe);W.push(C(i.types[Z],fe,ge,ae-oe,Y-ae,ee)),V.push(oe-N)}function C(W,V,N,re,oe,ae,Z){if(ae){let Y=[se.contextHash,ae];Z=Z?[Y].concat(Z):[Y]}if(oe>25){let Y=[se.lookAhead,oe];Z=Z?[Y].concat(Z):[Y]}return new Ae(W,V,N,re,Z)}function O(W,V){let N=l.fork(),re=0,oe=0,ae=0,Z=N.end-n,Y={size:0,start:0,skip:0};e:for(let ee=N.pos-W;N.pos>ee;){let fe=N.size;if(N.id==V&&fe>=0){Y.size=re,Y.start=oe,Y.skip=ae,ae+=4,re+=4,N.next();continue}let ge=N.pos-fe;if(fe<0||ge<ee||N.start<Z)break;let Fe=N.id>=o?4:0,De=N.start;for(N.next();N.pos>ge;){if(N.size<0)if(N.size==-3||N.size==-4)Fe+=4;else break e;else N.id>=o&&(Fe+=4);N.next()}oe=De,re+=fe,ae+=Fe}return(V<0||re==W)&&(Y.size=re,Y.start=oe,Y.skip=ae),Y.size>4?Y:void 0}function B(W,V,N){let{id:re,start:oe,end:ae,size:Z}=l;if(l.next(),Z>=0&&re<o){let Y=N;if(Z>4){let ee=l.pos-(Z-4);for(;l.pos>ee;)N=B(W,V,N)}V[--N]=Y,V[--N]=ae-W,V[--N]=oe-W,V[--N]=re}else Z==-3?u=re:Z==-4&&(p=re);return N}let F=[],P=[];for(;l.pos>0;)m(r.start||0,r.bufferStart||0,F,P,-1,0);let Q=(e=r.length)!==null&&e!==void 0?e:F.length?P[0]+F[0].length:0;return new Ae(h[r.topID],F.reverse(),P.reverse(),Q)}const Vl=new WeakMap;function ar(r,e){if(!r.isAnonymous||e instanceof hi||e.type!=r)return 1;let t=Vl.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=r||!(i instanceof Ae)){t=1;break}t+=ar(r,i)}Vl.set(e,t)}return t}function Oo(r,e,t,i,n,s,o,l,h){let u=0;for(let S=i;S<n;S++)u+=ar(r,e[S]);let p=Math.ceil(u*1.5/8),m=[],y=[];function x(S,C,O,B,F){for(let P=O;P<B;){let Q=P,W=C[P],V=ar(r,S[P]);for(P++;P<B;P++){let N=ar(r,S[P]);if(V+N>=p)break;V+=N}if(P==Q+1){if(V>p){let N=S[Q];x(N.children,N.positions,0,N.children.length,C[Q]+F);continue}m.push(S[Q])}else{let N=C[P-1]+S[P-1].length-W;m.push(Oo(r,S,C,Q,P,W,N,null,h))}y.push(W+F-s)}}return x(e,t,i,n,0),(l||h)(m,y,o)}class Hv{constructor(){this.map=new WeakMap}setBuffer(e,t,i){let n=this.map.get(e);n||this.map.set(e,n=new Map),n.set(t,i)}getBuffer(e,t){let i=this.map.get(e);return i&&i.get(t)}set(e,t){e instanceof zt?this.setBuffer(e.context.buffer,e.index,t):e instanceof Ye&&this.map.set(e.tree,t)}get(e){return e instanceof zt?this.getBuffer(e.context.buffer,e.index):e instanceof Ye?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class Yt{constructor(e,t,i,n,s=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=n,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let n=[new Yt(0,e.length,e,0,!1,i)];for(let s of t)s.to>e.length&&n.push(s);return n}static applyChanges(e,t,i=128){if(!t.length)return e;let n=[],s=1,o=e.length?e[0]:null;for(let l=0,h=0,u=0;;l++){let p=l<t.length?t[l]:null,m=p?p.fromA:1e9;if(m-h>=i)for(;o&&o.from<m;){let y=o;if(h>=y.from||m<=y.to||u){let x=Math.max(y.from,h)-u,S=Math.min(y.to,m)-u;y=x>=S?null:new Yt(x,S,y.tree,y.offset+u,l>0,!!p)}if(y&&n.push(y),o.to>m)break;o=s<e.length?e[s++]:null}if(!p)break;h=p.toA,u=p.toA-p.toB}return n}}class wh{startParse(e,t,i){return typeof e=="string"&&(e=new Qc(e)),i=i?i.length?i.map(n=>new vt(n.from,n.to)):[new vt(0,0)]:[new vt(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let n=this.startParse(e,t,i);for(;;){let s=n.advance();if(s)return s}}}class Qc{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}function Wv(r){return(e,t,i,n)=>new Zc(e,r,t,i,n)}class Kl{constructor(e,t,i,n,s,o){this.parser=e,this.parse=t,this.overlay=i,this.bracketed=n,this.target=s,this.from=o}}function zl(r){if(!r.length||r.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(r))}class Xc{constructor(e,t,i,n,s,o,l,h){this.parser=e,this.predicate=t,this.mounts=i,this.index=n,this.start=s,this.bracketed=o,this.target=l,this.prev=h,this.depth=0,this.ranges=[]}}const Es=new se({perNode:!0});class Zc{constructor(e,t,i,n,s){this.nest=t,this.input=i,this.fragments=n,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let n of this.inner)n.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new Ae(i.type,i.children,i.positions,i.length,i.propValues.concat([[Es,this.stoppedAt]]))),i}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let i=Object.assign(Object.create(null),e.target.props);i[se.mounted.id]=new $i(t,e.overlay,e.parser,e.bracketed),e.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new id(this.fragments),t=null,i=null,n=new gr(new Ye(this.baseTree,this.ranges[0].from,0,null),ye.IncludeAnonymous|ye.IgnoreMounts);e:for(let s,o;;){let l=!0,h;if(this.stoppedAt!=null&&n.from>=this.stoppedAt)l=!1;else if(e.hasNode(n)){if(t){let u=t.mounts.find(p=>p.frag.from<=n.from&&p.frag.to>=n.to&&p.mount.overlay);if(u)for(let p of u.mount.overlay){let m=p.from+u.pos,y=p.to+u.pos;m>=n.from&&y<=n.to&&!t.ranges.some(x=>x.from<y&&x.to>m)&&t.ranges.push({from:m,to:y})}}l=!1}else if(i&&(o=ed(i.ranges,n.from,n.to)))l=o!=2;else if(!n.type.isAnonymous&&(s=this.nest(n,this.input))&&(n.from<n.to||!s.overlay)){n.tree||(td(n),t&&t.depth++,i&&i.depth++);let u=e.findMounts(n.from,s.parser);if(typeof s.overlay=="function")t=new Xc(s.parser,s.overlay,u,this.inner.length,n.from,!!s.bracketed,n.tree,t);else{let p=jl(this.ranges,s.overlay||(n.from<n.to?[new vt(n.from,n.to)]:[]));p.length&&zl(p),(p.length||!s.overlay)&&this.inner.push(new Kl(s.parser,p.length?s.parser.startParse(this.input,ql(u,p),p):s.parser.startParse(""),s.overlay?s.overlay.map(m=>new vt(m.from-n.from,m.to-n.from)):null,!!s.bracketed,n.tree,p.length?p[0].from:n.from)),s.overlay?p.length&&(i={ranges:p,depth:0,prev:i}):l=!1}}else if(t&&(h=t.predicate(n))&&(h===!0&&(h=new vt(n.from,n.to)),h.from<h.to)){let u=t.ranges.length-1;u>=0&&t.ranges[u].to==h.from?t.ranges[u]={from:t.ranges[u].from,to:h.to}:t.ranges.push(h)}if(l&&n.firstChild())t&&t.depth++,i&&i.depth++;else for(;!n.nextSibling();){if(!n.parent())break e;if(t&&!--t.depth){let u=jl(this.ranges,t.ranges);u.length&&(zl(u),this.inner.splice(t.index,0,new Kl(t.parser,t.parser.startParse(this.input,ql(t.mounts,u),u),t.ranges.map(p=>new vt(p.from-t.start,p.to-t.start)),t.bracketed,t.target,u[0].from))),t=t.prev}i&&!--i.depth&&(i=i.prev)}}}}function ed(r,e,t){for(let i of r){if(i.from>=t)break;if(i.to>e)return i.from<=e&&i.to>=t?2:1}return 0}function $l(r,e,t,i,n,s){if(e<t){let o=r.buffer[e+1];i.push(r.slice(e,t,o)),n.push(o-s)}}function td(r){let{node:e}=r,t=[],i=e.context.buffer;do t.push(r.index),r.parent();while(!r.tree);let n=r.tree,s=n.children.indexOf(i),o=n.children[s],l=o.buffer,h=[s];function u(p,m,y,x,S,C){let O=t[C],B=[],F=[];$l(o,p,O,B,F,x);let P=l[O+1],Q=l[O+2];h.push(B.length);let W=C?u(O+4,l[O+3],o.set.types[l[O]],P,Q-P,C-1):e.toTree();return B.push(W),F.push(P-x),$l(o,l[O+3],m,B,F,x),new Ae(y,B,F,S)}n.children[s]=u(0,l.length,nt.none,0,o.length,t.length-1);for(let p of h){let m=r.tree.children[p],y=r.tree.positions[p];r.yield(new Ye(m,y+r.from,p,r._tree))}}class _l{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(ye.IncludeAnonymous|ye.IgnoreMounts)}moveTo(e){let{cursor:t}=this,i=e-this.offset;for(;!this.done&&t.from<i;)if(!(t.to>=e&&t.enter(i,1,ye.IgnoreOverlays|ye.ExcludeBuffers)))if(t.to<=e)t.next(!1)||(this.done=!0);else break}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof Ae)t=t.children[0];else break}return!1}}let id=class{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let i=this.curFrag=e[0];this.curTo=(t=i.tree.prop(Es))!==null&&t!==void 0?t:i.to,this.inner=new _l(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=(e=t.tree.prop(Es))!==null&&e!==void 0?e:t.to,this.inner=new _l(t.tree,-t.offset)}}findMounts(e,t){var i;let n=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let s=this.inner.cursor.node;s;s=s.parent){let o=(i=s.tree)===null||i===void 0?void 0:i.prop(se.mounted);if(o&&o.parser==t)for(let l=this.fragI;l<this.fragments.length;l++){let h=this.fragments[l];if(h.from>=s.to)break;h.tree==this.curFrag.tree&&n.push({frag:h,pos:s.from-h.offset,mount:o})}}}return n}};function jl(r,e){let t=null,i=e;for(let n=1,s=0;n<r.length;n++){let o=r[n-1].to,l=r[n].from;for(;s<i.length;s++){let h=i[s];if(h.from>=l)break;h.to<=o||(t||(i=t=e.slice()),h.from<o?(t[s]=new vt(h.from,o),h.to>l&&t.splice(s+1,0,new vt(l,h.to))):h.to>l?t[s--]=new vt(l,h.to):t.splice(s--,1))}}return i}function nd(r,e,t,i){let n=0,s=0,o=!1,l=!1,h=-1e9,u=[];for(;;){let p=n==r.length?1e9:o?r[n].to:r[n].from,m=s==e.length?1e9:l?e[s].to:e[s].from;if(o!=l){let y=Math.max(h,t),x=Math.min(p,m,i);y<x&&u.push(new vt(y,x))}if(h=Math.min(p,m),h==1e9)break;p==h&&(o?(o=!1,n++):o=!0),m==h&&(l?(l=!1,s++):l=!0)}return u}function ql(r,e){let t=[];for(let{pos:i,mount:n,frag:s}of r){let o=i+(n.overlay?n.overlay[0].from:0),l=o+n.tree.length,h=Math.max(s.from,o),u=Math.min(s.to,l);if(n.overlay){let p=n.overlay.map(y=>new vt(y.from+i,y.to+i)),m=nd(e,p,h,u);for(let y=0,x=h;;y++){let S=y==m.length,C=S?u:m[y].from;if(C>x&&t.push(new Yt(x,C,n.tree,-o,s.from>=x||s.openStart,s.to<=C||s.openEnd)),S)break;x=m[y].to}}else t.push(new Yt(h,u,n.tree,-o,s.from>=o||s.openStart,s.to<=l||s.openEnd))}return t}let rd=0;class mt{constructor(e,t,i,n){this.name=e,this.set=t,this.base=i,this.modified=n,this.id=rd++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof mt&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let n=new mt(i,[],null,[]);if(n.set.push(n),t)for(let s of t.set)n.set.push(s);return n}static defineModifier(e){let t=new mr(e);return i=>i.modified.indexOf(t)>-1?i:mr.get(i.base||i,i.modified.concat(t).sort((n,s)=>n.id-s.id))}}let sd=0;class mr{constructor(e){this.name=e,this.instances=[],this.id=sd++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&od(t,l.modified));if(i)return i;let n=[],s=new mt(e.name,n,e,t);for(let l of t)l.instances.push(s);let o=ld(t);for(let l of e.set)if(!l.modified.length)for(let h of o)n.push(mr.get(l,h));return s}}function od(r,e){return r.length==e.length&&r.every((t,i)=>t==e[i])}function ld(r){let e=[[]];for(let t=0;t<r.length;t++)for(let i=0,n=e.length;i<n;i++)e.push(e[i].concat(r[t]));return e.sort((t,i)=>i.length-t.length)}function ad(r){let e=Object.create(null);for(let t in r){let i=r[t];Array.isArray(i)||(i=[i]);for(let n of t.split(" "))if(n){let s=[],o=2,l=n;for(let m=0;;){if(l=="..."&&m>0&&m+3==n.length){o=1;break}let y=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!y)throw new RangeError("Invalid path: "+n);if(s.push(y[0]=="*"?"":y[0][0]=='"'?JSON.parse(y[0]):y[0]),m+=y[0].length,m==n.length)break;let x=n[m++];if(m==n.length&&x=="!"){o=0;break}if(x!="/")throw new RangeError("Invalid path: "+n);l=n.slice(m)}let h=s.length-1,u=s[h];if(!u)throw new RangeError("Invalid path: "+n);let p=new Mn(i,o,h>0?s.slice(0,h):null);e[u]=p.sort(e[u])}}return bh.add(e)}const bh=new se({combine(r,e){let t,i,n;for(;r||e;){if(!r||e&&r.depth>=e.depth?(n=e,e=e.next):(n=r,r=r.next),t&&t.mode==n.mode&&!n.context&&!t.context)continue;let s=new Mn(n.tags,n.mode,n.context);t?t.next=s:i=s,t=s}return i}});class Mn{constructor(e,t,i,n){this.tags=e,this.mode=t,this.context=i,this.next=n}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}Mn.empty=new Mn([],2,null);function Sh(r,e){let t=Object.create(null);for(let s of r)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let o of s.tag)t[o.id]=s.class;let{scope:i,all:n=null}=e||{};return{style:s=>{let o=n;for(let l of s)for(let h of l.set){let u=t[h.id];if(u){o=o?o+" "+u:u;break}}return o},scope:i}}function hd(r,e){let t=null;for(let i of r){let n=i.style(e);n&&(t=t?t+" "+n:n)}return t}function Ch(r,e,t,i=0,n=r.length){let s=new fd(i,Array.isArray(e)?e:[e],t);s.highlightRange(r.cursor(),i,n,"",s.highlighters),s.flush(n)}function Kv(r,e,t,i,n,s=0,o=r.length){let l=s;function h(u,p){if(!(u<=l)){for(let m=r.slice(l,u),y=0;;){let x=m.indexOf(`
|
|
2
|
+
`,y),S=x<0?m.length:x;if(S>y&&i(m.slice(y,S),p),x<0)break;n(),y=x+1}l=u}}Ch(e,t,(u,p,m)=>{h(u,""),h(p,m)},s,o),h(o,"")}class fd{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,n,s){let{type:o,from:l,to:h}=e;if(l>=i||h<=t)return;o.isTop&&(s=this.highlighters.filter(x=>!x.scope||x.scope(o)));let u=n,p=ud(e)||Mn.empty,m=hd(s,p.tags);if(m&&(u&&(u+=" "),u+=m,p.mode==1&&(n+=(n?" ":"")+m)),this.startSpan(Math.max(t,l),u),p.opaque)return;let y=e.tree&&e.tree.prop(se.mounted);if(y&&y.overlay){let x=e.node.enter(y.overlay[0].from+l,1),S=this.highlighters.filter(O=>!O.scope||O.scope(y.tree.type)),C=e.firstChild();for(let O=0,B=l;;O++){let F=O<y.overlay.length?y.overlay[O]:null,P=F?F.from+l:h,Q=Math.max(t,B),W=Math.min(i,P);if(Q<W&&C)for(;e.from<W&&(this.highlightRange(e,Q,W,n,s),this.startSpan(Math.min(W,e.to),u),!(e.to>=P||!e.nextSibling())););if(!F||P>i)break;B=F.to+l,B>t&&(this.highlightRange(x.cursor(),Math.max(t,F.from+l),Math.min(i,B),"",S),this.startSpan(Math.min(i,B),u))}C&&e.parent()}else if(e.firstChild()){y&&(n="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,n,s),this.startSpan(Math.min(i,e.to),u)}while(e.nextSibling());e.parent()}}}function ud(r){let e=r.type.prop(bh);for(;e&&e.context&&!r.matchContext(e.context);)e=e.next;return e||null}const K=mt.define,qn=K(),ni=K(),Ul=K(ni),Jl=K(ni),ri=K(),Un=K(ri),hs=K(ri),Ht=K(),ki=K(Ht),Pt=K(),Nt=K(),Is=K(),fn=K(Is),Jn=K(),$={comment:qn,lineComment:K(qn),blockComment:K(qn),docComment:K(qn),name:ni,variableName:K(ni),typeName:Ul,tagName:K(Ul),propertyName:Jl,attributeName:K(Jl),className:K(ni),labelName:K(ni),namespace:K(ni),macroName:K(ni),literal:ri,string:Un,docString:K(Un),character:K(Un),attributeValue:K(Un),number:hs,integer:K(hs),float:K(hs),bool:K(ri),regexp:K(ri),escape:K(ri),color:K(ri),url:K(ri),keyword:Pt,self:K(Pt),null:K(Pt),atom:K(Pt),unit:K(Pt),modifier:K(Pt),operatorKeyword:K(Pt),controlKeyword:K(Pt),definitionKeyword:K(Pt),moduleKeyword:K(Pt),operator:Nt,derefOperator:K(Nt),arithmeticOperator:K(Nt),logicOperator:K(Nt),bitwiseOperator:K(Nt),compareOperator:K(Nt),updateOperator:K(Nt),definitionOperator:K(Nt),typeOperator:K(Nt),controlOperator:K(Nt),punctuation:Is,separator:K(Is),bracket:fn,angleBracket:K(fn),squareBracket:K(fn),paren:K(fn),brace:K(fn),content:Ht,heading:ki,heading1:K(ki),heading2:K(ki),heading3:K(ki),heading4:K(ki),heading5:K(ki),heading6:K(ki),contentSeparator:K(Ht),list:K(Ht),quote:K(Ht),emphasis:K(Ht),strong:K(Ht),link:K(Ht),monospace:K(Ht),strikethrough:K(Ht),inserted:K(),deleted:K(),changed:K(),invalid:K(),meta:Jn,documentMeta:K(Jn),annotation:K(Jn),processingInstruction:K(Jn),definition:mt.defineModifier("definition"),constant:mt.defineModifier("constant"),function:mt.defineModifier("function"),standard:mt.defineModifier("standard"),local:mt.defineModifier("local"),special:mt.defineModifier("special")};for(let r in $){let e=$[r];e instanceof mt&&(e.name=r)}const zv=Sh([{tag:$.link,class:"tok-link"},{tag:$.heading,class:"tok-heading"},{tag:$.emphasis,class:"tok-emphasis"},{tag:$.strong,class:"tok-strong"},{tag:$.keyword,class:"tok-keyword"},{tag:$.atom,class:"tok-atom"},{tag:$.bool,class:"tok-bool"},{tag:$.url,class:"tok-url"},{tag:$.labelName,class:"tok-labelName"},{tag:$.inserted,class:"tok-inserted"},{tag:$.deleted,class:"tok-deleted"},{tag:$.literal,class:"tok-literal"},{tag:$.string,class:"tok-string"},{tag:$.number,class:"tok-number"},{tag:[$.regexp,$.escape,$.special($.string)],class:"tok-string2"},{tag:$.variableName,class:"tok-variableName"},{tag:$.local($.variableName),class:"tok-variableName tok-local"},{tag:$.definition($.variableName),class:"tok-variableName tok-definition"},{tag:$.special($.variableName),class:"tok-variableName2"},{tag:$.definition($.propertyName),class:"tok-propertyName tok-definition"},{tag:$.typeName,class:"tok-typeName"},{tag:$.namespace,class:"tok-namespace"},{tag:$.className,class:"tok-className"},{tag:$.macroName,class:"tok-macroName"},{tag:$.propertyName,class:"tok-propertyName"},{tag:$.operator,class:"tok-operator"},{tag:$.comment,class:"tok-comment"},{tag:$.meta,class:"tok-meta"},{tag:$.invalid,class:"tok-invalid"},{tag:$.punctuation,class:"tok-punctuation"}]);var Gl={};class vr{constructor(e,t,i,n,s,o,l,h,u,p=0,m){this.p=e,this.stack=t,this.state=i,this.reducePos=n,this.pos=s,this.score=o,this.buffer=l,this.bufferBase=h,this.curContext=u,this.lookAhead=p,this.parent=m}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let n=e.parser.context;return new vr(e,[],t,i,i,0,[],0,n?new Yl(n,n.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let i=e>>19,n=e&65535,{parser:s}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),l=s.dynamicPrecedence(n);if(l&&(this.score+=l),i==0){n<s.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(s.getGoto(this.state,n,!0),this.reducePos),n<s.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(n,this.reducePos);return}let h=this.stack.length-(i-1)*3-(e&262144?6:0),u=h?this.stack[h-2]:this.p.ranges[0].from;n<s.minRepeatTerm&&u==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let p=this.reducePos-u;p>=2e3&&!(!((t=this.p.parser.nodeSet.types[n])===null||t===void 0)&&t.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=p):this.p.lastBigReductionSize<p&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=u,this.p.lastBigReductionSize=p));let m=h?this.stack[h-1]:0,y=this.bufferBase+this.buffer.length-m;if(n<s.minRepeatTerm||e&131072){let x=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,u,x,y+4,!0)}if(e&262144)this.state=this.stack[h];else{let x=this.stack[h-3];this.state=s.getGoto(x,n,!0)}for(;this.stack.length>h;)this.stack.pop();this.reduceContext(n,u)}storeNode(e,t,i,n=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this.buffer.length;if(o>0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(t==i)return;if(this.buffer[o-2]>=t){this.buffer[o-2]=i;return}}}if(!s||this.pos==i)this.buffer.push(e,t,i,n);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let h=o;h>0&&this.buffer[h-2]>i;h-=4)if(this.buffer[h-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,n>4&&(n-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=i,this.buffer[o+3]=n}}shift(e,t,i,n){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let s=e,{parser:o}=this.p;this.pos=n;let l=o.stateFlag(s,1);!l&&(n>i||t<=o.maxNode)&&(this.reducePos=n),this.pushState(s,l?i:Math.min(i,this.reducePos)),this.shiftContext(t,i),t<=o.maxNode&&this.buffer.push(t,i,n,4)}else this.pos=n,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,n,4)}apply(e,t,i,n){e&65536?this.reduce(e):this.shift(e,t,i,n)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let n=this.pos;this.reducePos=this.pos=n+e.length,this.pushState(t,n),this.buffer.push(i,n,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(t&&e.buffer[t-4]==0&&(t-=4);t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),n=e.bufferBase+t;for(;e&&n==e.bufferBase;)e=e.parent;return new vr(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,n,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new cd(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if((i&65536)==0)return!0;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let s=0,o;s<t.length;s+=2)(o=t[s+1])!=this.state&&this.p.parser.hasAction(o,e)&&n.push(t[s],o);if(this.stack.length<120)for(let s=0;n.length<8&&s<t.length;s+=2){let o=t[s+1];n.some((l,h)=>h&1&&l==o)||n.push(t[s],o)}t=n}let i=[];for(let n=0;n<t.length&&i.length<4;n+=2){let s=t[n+1];if(s==this.state)continue;let o=this.split();o.pushState(s,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(t[n],this.pos),o.reducePos=this.pos,o.score-=200,i.push(o)}return i}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if((t&65536)==0)return!1;if(!e.validAction(this.state,t)){let i=t>>19,n=t&65535,s=this.stack.length-i*3;if(s<0||e.getGoto(this.stack[s],n,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],i=(n,s)=>{if(!t.includes(n))return t.push(n),e.allActions(n,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-s;if(l>1){let h=o&65535,u=this.stack.length-l*3;if(u>=0&&e.getGoto(this.stack[u],h,!1)>=0)return l<<19|65536|h}}else{let l=i(o,s+1);if(l!=null)return l}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new Yl(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class Yl{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class cd{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let n=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=n}}class yr{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new yr(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new yr(this.stack,this.pos,this.index)}}function gn(r,e=Uint16Array){if(typeof r!="string")return r;let t=null;for(let i=0,n=0;i<r.length;){let s=0;for(;;){let o=r.charCodeAt(i++),l=!1;if(o==126){s=65535;break}o>=92&&o--,o>=34&&o--;let h=o-32;if(h>=46&&(h-=46,l=!0),s+=h,l)break;s*=46}t?t[n++]=s:t=new e(s)}return t}class hr{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const Ql=new hr;class dd{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=Ql,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,n=this.rangeIndex,s=this.pos+e;for(;s<i.from;){if(!n)return null;let o=this.ranges[--n];s-=i.from-o.to,i=o}for(;t<0?s>i.to:s>=i.to;){if(n==this.ranges.length-1)return null;let o=this.ranges[++n];s+=o.from-i.to,i=o}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,n;if(t>=0&&t<this.chunk.length)i=this.pos+e,n=this.chunk.charCodeAt(t);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(i=s,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)n=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,l=this.range;for(;l.to<=i;)l=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),n=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),n}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=i}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=Ql,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let n of this.ranges){if(n.from>=t)break;n.to>e&&(i+=this.input.read(Math.max(n.from,e),Math.min(n.to,t)))}return i}}class _i{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;Ah(this.data,e,t,this.id,i.data,i.tokenPrecTable)}}_i.prototype.contextual=_i.prototype.fallback=_i.prototype.extend=!1;class pd{constructor(e,t,i){this.precTable=t,this.elseToken=i,this.data=typeof e=="string"?gn(e):e}token(e,t){let i=e.pos,n=0;for(;;){let s=e.next<0,o=e.resolveOffset(1,1);if(Ah(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(s||n++,o==null)break;e.reset(o,e.token)}n&&(e.reset(i,e.token),e.acceptToken(this.elseToken,n))}}pd.prototype.contextual=_i.prototype.fallback=_i.prototype.extend=!1;class $v{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function Ah(r,e,t,i,n,s){let o=0,l=1<<i,{dialect:h}=t.p.parser;e:for(;(l&r[o])!=0;){let u=r[o+1];for(let x=o+3;x<u;x+=2)if((r[x+1]&l)>0){let S=r[x];if(h.allows(S)&&(e.token.value==-1||e.token.value==S||gd(S,e.token.value,n,s))){e.acceptToken(S);break}}let p=e.next,m=0,y=r[o+2];if(e.next<0&&y>m&&r[u+y*3-3]==65535){o=r[u+y*3-1];continue e}for(;m<y;){let x=m+y>>1,S=u+x+(x<<1),C=r[S],O=r[S+1]||65536;if(p<C)y=x;else if(p>=O)m=x+1;else{o=r[S+2],e.advance();continue e}}break}}function Xl(r,e,t){for(let i=e,n;(n=r[i])!=65535;i++)if(n==t)return i-e;return-1}function gd(r,e,t,i){let n=Xl(t,i,e);return n<0||Xl(t,i,r)<n}const ht=typeof process<"u"&&Gl&&/\bparse\b/.test(Gl.LOG);let fs=null;function Zl(r,e,t){let i=r.cursor(ye.IncludeAnonymous);for(i.moveTo(e);;)if(!(t<0?i.childBefore(e):i.childAfter(e)))for(;;){if((t<0?i.to<e:i.from>e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(r.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:r.length}}class md{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Zl(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Zl(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let i=this.trees[t],n=this.index[t];if(n==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=i.children[n],o=this.start[t]+i.positions[n];if(o>e)return this.nextStart=o,null;if(s instanceof Ae){if(o==e){if(o<this.safeFrom)return null;let l=o+s.length;if(l<=this.safeTo){let h=s.prop(se.lookAhead);if(!h||l+h<this.fragment.to)return s}}this.index[t]++,o+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+s.length}}}class vd{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new hr)}getActions(e){let t=0,i=null,{parser:n}=e.p,{tokenizers:s}=n,o=n.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,h=0;for(let u=0;u<s.length;u++){if((1<<u&o)==0)continue;let p=s[u],m=this.tokens[u];if(!(i&&!p.fallback)&&((p.contextual||m.start!=e.pos||m.mask!=o||m.context!=l)&&(this.updateCachedToken(m,p,e),m.mask=o,m.context=l),m.lookAhead>m.end+25&&(h=Math.max(m.lookAhead,h)),m.value!=0)){let y=t;if(m.extended>-1&&(t=this.addActions(e,m.extended,m.end,t)),t=this.addActions(e,m.value,m.end,t),!p.extend&&(i=m,t>y))break}}for(;this.actions.length>t;)this.actions.pop();return h&&e.setLookAhead(h),!i&&e.pos==this.stream.end&&(i=new hr,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new hr,{pos:i,p:n}=e;return t.start=i,t.end=Math.min(i+1,n.stream.end),t.value=i==n.stream.end?n.parser.eofTerm:0,t}updateCachedToken(e,t,i){let n=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(n,e),i),e.value>-1){let{parser:s}=i.p;for(let o=0;o<s.specialized.length;o++)if(s.specialized[o]==e.value){let l=s.specializers[o](this.stream.read(e.start,e.end),i);if(l>=0&&i.p.parser.dialect.allows(l>>1)){(l&1)==0?e.value=l>>1:e.extended=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(n+1)}putAction(e,t,i,n){for(let s=0;s<n;s+=3)if(this.actions[s]==e)return n;return this.actions[n++]=e,this.actions[n++]=t,this.actions[n++]=i,n}addActions(e,t,i,n){let{state:s}=e,{parser:o}=e.p,{data:l}=o;for(let h=0;h<2;h++)for(let u=o.stateSlot(s,h?2:1);;u+=3){if(l[u]==65535)if(l[u+1]==1)u=Jt(l,u+2);else{n==0&&l[u+1]==2&&(n=this.putAction(Jt(l,u+2),t,i,n));break}l[u]==t&&(n=this.putAction(Jt(l,u+1),t,i,n))}return n}}class yd{constructor(e,t,i,n){this.parser=e,this.input=t,this.ranges=n,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new dd(t,n),this.tokens=new vd(e,this.stream),this.topTerm=e.top[1];let{from:s}=n[0];this.stacks=[vr.start(this,e.top[0],s)],this.fragments=i.length&&this.stream.end-s>e.bufferLength*4?new md(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],n,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let l=e[o];for(;;){if(this.tokens.mainToken=null,l.pos>t)i.push(l);else{if(this.advanceStack(l,i,e))continue;{n||(n=[],s=[]),n.push(l);let h=this.tokens.getMainToken(l);s.push(h.value,h.end)}}break}}if(!i.length){let o=n&&xd(n);if(o)return ht&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw ht&&n&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&n){let o=this.stoppedAt!=null&&n[0].pos>this.stoppedAt?n[0]:this.runRecovery(n,s,i);if(o)return ht&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,h)=>h.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let o=0;o<i.length-1;o++){let l=i[o];for(let h=o+1;h<i.length;h++){let u=i[h];if(l.sameState(u)||l.buffer.length>500&&u.buffer.length>500)if((l.score-u.score||l.buffer.length-u.buffer.length)>0)i.splice(h--,1);else{i.splice(o--,1);continue e}}}i.length>12&&(i.sort((o,l)=>l.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,i){let n=e.pos,{parser:s}=this,o=ht?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&n>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let u=e.curContext&&e.curContext.tracker.strict,p=u?e.curContext.hash:0;for(let m=this.fragments.nodeAt(n);m;){let y=this.parser.nodeSet.types[m.type.id]==m.type?s.getGoto(e.state,m.type.id):-1;if(y>-1&&m.length&&(!u||(m.prop(se.contextHash)||0)==p))return e.useNode(m,y),ht&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(m.type.id)})`),!0;if(!(m instanceof Ae)||m.children.length==0||m.positions[0]>0)break;let x=m.children[0];if(x instanceof Ae&&m.positions[0]==0)m=x;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),ht&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let h=this.tokens.getActions(e);for(let u=0;u<h.length;){let p=h[u++],m=h[u++],y=h[u++],x=u==h.length||!i,S=x?e:e.split(),C=this.tokens.mainToken;if(S.apply(p,m,C?C.start:S.pos,y),ht&&console.log(o+this.stackID(S)+` (via ${(p&65536)==0?"shift":`reduce of ${s.getName(p&65535)}`} for ${s.getName(m)} @ ${n}${S==e?"":", split"})`),x)return!0;S.pos>n?t.push(S):i.push(S)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return ea(e,t),!0}}runRecovery(e,t,i){let n=null,s=!1;for(let o=0;o<e.length;o++){let l=e[o],h=t[o<<1],u=t[(o<<1)+1],p=ht?this.stackID(l)+" -> ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),ht&&console.log(p+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let m=l.split(),y=p;for(let x=0;x<10&&m.forceReduce()&&(ht&&console.log(y+this.stackID(m)+" (via force-reduce)"),!this.advanceFully(m,i));x++)ht&&(y=this.stackID(m)+" -> ");for(let x of l.recoverByInsert(h))ht&&console.log(p+this.stackID(x)+" (via recover-insert)"),this.advanceFully(x,i);this.stream.end>l.pos?(u==l.pos&&(u++,h=0),l.recoverByDelete(h,u),ht&&console.log(p+this.stackID(l)+` (via recover-delete ${this.parser.getName(h)})`),ea(l,i)):(!n||n.score<m.score)&&(n=m)}return n}stackToTree(e){return e.close(),Ae.build({buffer:yr.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(fs||(fs=new WeakMap)).get(e);return t||fs.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function ea(r,e){for(let t=0;t<e.length;t++){let i=e[t];if(i.pos==r.pos&&i.sameState(r)){e[t].score<r.score&&(e[t]=r);return}}e.push(r)}class kd{constructor(e,t,i){this.source=e,this.flags=t,this.disabled=i}allows(e){return!this.disabled||this.disabled[e]==0}}const us=r=>r;class _v{constructor(e){this.start=e.start,this.shift=e.shift||us,this.reduce=e.reduce||us,this.reuse=e.reuse||us,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class Ps extends wh{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let l=0;l<e.repeatNodeCount;l++)t.push("");let i=Object.keys(e.topRules).map(l=>e.topRules[l][1]),n=[];for(let l=0;l<t.length;l++)n.push([]);function s(l,h,u){n[l].push([h,h.deserialize(String(u))])}if(e.nodeProps)for(let l of e.nodeProps){let h=l[0];typeof h=="string"&&(h=se[h]);for(let u=1;u<l.length;){let p=l[u++];if(p>=0)s(p,h,l[u++]);else{let m=l[u+-p];for(let y=-p;y>0;y--)s(l[u++],h,m);u++}}}this.nodeSet=new Ao(t.map((l,h)=>nt.define({name:h>=this.minRepeatTerm?void 0:l,id:h,props:n[h],top:i.indexOf(h)>-1,error:h==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(h)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let o=gn(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(ta),this.states=gn(e.states,Uint32Array),this.data=gn(e.stateData),this.goto=gn(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new _i(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let n=new yd(this,e,t,i);for(let s of this.wrappers)n=s(n,e,t,i);return n}getGoto(e,t,i=!1){let n=this.goto;if(t>=n[0])return-1;for(let s=n[t+1];;){let o=n[s++],l=o&1,h=n[s++];if(l&&i)return h;for(let u=s+(o>>1);s<u;s++)if(n[s]==e)return h;if(l)return-1}}hasAction(e,t){let i=this.data;for(let n=0;n<2;n++)for(let s=this.stateSlot(e,n?2:1),o;;s+=3){if((o=i[s])==65535)if(i[s+1]==1)o=i[s=Jt(i,s+2)];else{if(i[s+1]==2)return Jt(i,s+2);break}if(o==t||o==0)return Jt(i,s+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,i=>i==t?!0:null)}allActions(e,t){let i=this.stateSlot(e,4),n=i?t(i):void 0;for(let s=this.stateSlot(e,1);n==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Jt(this.data,s+2);else break;n=t(Jt(this.data,s+1))}return n}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Jt(this.data,i+2);else break;if((this.data[i+2]&1)==0){let n=this.data[i+1];t.some((s,o)=>o&1&&s==n)||t.push(this.data[i],n)}}return t}configure(e){let t=Object.assign(Object.create(Ps.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let n=e.tokenizers.find(s=>s.from==i);return n?n.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,n)=>{let s=e.specializers.find(l=>l.from==i.external);if(!s)return i;let o=Object.assign(Object.assign({},i),{external:s.to});return t.specializers[n]=ta(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let s of e.split(" ")){let o=t.indexOf(s);o>=0&&(i[o]=!0)}let n=null;for(let s=0;s<t.length;s++)if(!i[s])for(let o=this.dialects[t[s]],l;(l=this.data[o++])!=65535;)(n||(n=new Uint8Array(this.maxTerm+1)))[l]=1;return new kd(e,i,n)}static deserialize(e){return new Ps(e)}}function Jt(r,e){return r[e]|r[e+1]<<16}function xd(r){let e=null;for(let t of r){let i=t.p.stoppedAt;(t.pos==t.p.stream.end||i!=null&&t.pos>i)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function ta(r){if(r.external){let e=r.extend?1:0;return(t,i)=>r.external(t,i)<<1|e}return r.get}let Ns=[],Mh=[];(()=>{let r="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<r.length;e++)(e%2?Mh:Ns).push(t=t+r[e])})();function wd(r){if(r<768)return!1;for(let e=0,t=Ns.length;;){let i=e+t>>1;if(r<Ns[i])t=i;else if(r>=Mh[i])e=i+1;else return!0;if(e==t)return!1}}function ia(r){return r>=127462&&r<=127487}const na=8205;function bd(r,e,t=!0,i=!0){return(t?Th:Sd)(r,e,i)}function Th(r,e,t){if(e==r.length)return e;e&&Oh(r.charCodeAt(e))&&Lh(r.charCodeAt(e-1))&&e--;let i=cs(r,e);for(e+=ra(i);e<r.length;){let n=cs(r,e);if(i==na||n==na||t&&wd(n))e+=ra(n),i=n;else if(ia(n)){let s=0,o=e-2;for(;o>=0&&ia(cs(r,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function Sd(r,e,t){for(;e>1;){let i=Th(r,e-2,t);if(i<e)return i;e--}return 0}function cs(r,e){let t=r.charCodeAt(e);if(!Lh(t)||e+1==r.length)return t;let i=r.charCodeAt(e+1);return Oh(i)?(t-55296<<10)+(i-56320)+65536:t}function Oh(r){return r>=56320&&r<57344}function Lh(r){return r>=55296&&r<56320}function ra(r){return r<65536?1:2}let ce=class Bh{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Yi(this,e,t);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(t,this.length,n,1),Vt.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Yi(this,e,t);let i=[];return this.decompose(e,t,i,0),Vt.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new kn(this),s=new kn(e);for(let o=t,l=t;;){if(n.next(o),s.next(o),o=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(l+=n.value.length,n.done||l>=i)return!0}}iter(e=1){return new kn(this,e)}iterRange(e,t=this.length){return new Dh(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Rh(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Bh.empty:e.length<=32?new Be(e):Vt.from(Be.split(e,[]))}};class Be extends ce{constructor(e,t=Cd(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let s=0;;s++){let o=this.text[s],l=n+o.length;if((t?i:l)>=e)return new Ad(n,l,i,o);n=l+1,i++}}decompose(e,t,i,n){let s=e<=0&&t>=this.length?this:new Be(sa(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(n&1){let o=i.pop(),l=fr(s.text,o.text.slice(),0,s.length);if(l.length<=32)i.push(new Be(l,o.length+s.length));else{let h=l.length>>1;i.push(new Be(l.slice(0,h)),new Be(l.slice(h)))}}else i.push(s)}replace(e,t,i){if(!(i instanceof Be))return super.replace(e,t,i);[e,t]=Yi(this,e,t);let n=fr(this.text,fr(i.text,sa(this.text,0,e)),t),s=this.length+i.length-(t-e);return n.length<=32?new Be(n,s):Vt.from(Be.split(n,[]),s)}sliceString(e,t=this.length,i=`
|
|
2
3
|
`){[e,t]=Yi(this,e,t);let n="";for(let s=0,o=0;s<=t&&o<this.text.length;o++){let l=this.text[o],h=s+l.length;s>e&&o&&(n+=i),e<h&&t>s&&(n+=l.slice(Math.max(0,e-s),t-s)),s=h+1}return n}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],n=-1;for(let s of e)i.push(s),n+=s.length+1,i.length==32&&(t.push(new Be(i,n)),i=[],n=-1);return n>-1&&t.push(new Be(i,n)),t}}class Vt extends ce{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,n){for(let s=0;;s++){let o=this.children[s],l=n+o.length,h=i+o.lines-1;if((t?h:l)>=e)return o.lineInner(e,t,i,n);n=l+1,i=h+1}}decompose(e,t,i,n){for(let s=0,o=0;o<=t&&s<this.children.length;s++){let l=this.children[s],h=o+l.length;if(e<=h&&t>=o){let u=n&((o<=e?1:0)|(h>=t?2:0));o>=e&&h<=t&&!u?i.push(l):l.decompose(e-o,t-o,i,u)}o=h+1}}replace(e,t,i){if([e,t]=Yi(this,e,t),i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let o=this.children[n],l=s+o.length;if(e>=s&&t<=l){let h=o.replace(e-s,t-s,i),u=this.lines-o.lines+h.lines;if(h.lines<u>>4&&h.lines>u>>6){let p=this.children.slice();return p[n]=h,new Vt(p,this.length-(t-e)+i.length)}return super.replace(s,l,h)}s=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
|
|
3
|
-
`){[e,t]=Yi(this,e,t);let n="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let l=this.children[s],h=o+l.length;o>e&&s&&(n+=i),e<h&&t>o&&(n+=l.sliceString(e-o,t-o,i)),o=h+1}return n}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Vt))return 0;let i=0,[n,s,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=t,s+=t){if(n==o||s==l)return i;let h=this.children[n],u=e.children[s];if(h!=u)return i+h.scanIdentical(u,t);i+=h.length+1}}static from(e,t=e.reduce((i,n)=>i+n.length+1,-1)){let i=0;for(let x of e)i+=x.lines;if(i<32){let x=[];for(let S of e)S.flatten(x);return new Be(x,t)}let n=Math.max(32,i>>5),s=n<<1,o=n>>1,l=[],h=0,u=-1,p=[];function m(x){let S;if(x.lines>s&&x instanceof Vt)for(let C of x.children)m(C);else x.lines>o&&(h>o||!h)?(y(),l.push(x)):x instanceof Be&&h&&(S=p[p.length-1])instanceof Be&&x.lines+S.lines<=32?(h+=x.lines,u+=x.length+1,p[p.length-1]=new Be(S.text.concat(x.text),S.length+1+x.length)):(h+x.lines>n&&y(),h+=x.lines,u+=x.length+1,p.push(x))}function y(){h!=0&&(l.push(p.length==1?p[0]:Vt.from(p,u)),u=-1,h=p.length=0)}for(let x of e)m(x);return y(),l.length==1?l[0]:new Vt(l,t)}}ce.empty=new Be([""],0);function
|
|
4
|
-
`,this;e--}else if(n instanceof Be){let h=n.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,h.length>Math.max(0,e))return this.value=e==0?h:t>0?h.slice(e):h.slice(0,h.length-e),this;e-=h.length}else{let h=n.children[o+(t<0?-1:0)];e>h.length?(e-=h.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(h),this.offsets.push(t>0?1:(h instanceof Be?h.text.length:h.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Sh{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new kn(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:n}=this.cursor.next(e);return this.pos+=(n.length+e)*t,this.value=n.length<=i?n:t<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Ch{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:n}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(ce.prototype[Symbol.iterator]=function(){return this.iter()},kn.prototype[Symbol.iterator]=Sh.prototype[Symbol.iterator]=Ch.prototype[Symbol.iterator]=function(){return this});class Yc{constructor(e,t,i,n){this.from=e,this.to=t,this.number=i,this.text=n}get length(){return this.to-this.from}}function Yi(r,e,t){return e=Math.max(0,Math.min(r.length,e)),[e,Math.max(e,Math.min(r.length,t))]}function Ne(r,e,t=!0,i=!0){return Uc(r,e,t,i)}function Qc(r){return r>=56320&&r<57344}function Xc(r){return r>=55296&&r<56320}function Ah(r,e){let t=r.charCodeAt(e);if(!Xc(t)||e+1==r.length)return t;let i=r.charCodeAt(e+1);return Qc(i)?(t-55296<<10)+(i-56320)+65536:t}function Zc(r){return r<=65535?String.fromCharCode(r):(r-=65536,String.fromCharCode((r>>10)+55296,(r&1023)+56320))}function Mh(r){return r<65536?1:2}const Rs=/\r\n?|\n/;var _e=(function(r){return r[r.Simple=0]="Simple",r[r.TrackDel=1]="TrackDel",r[r.TrackBefore=2]="TrackBefore",r[r.TrackAfter=3]="TrackAfter",r})(_e||(_e={}));class qt{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,n=0;t<this.sections.length;){let s=this.sections[t++],o=this.sections[t++];o<0?(e(i,n,s),n+=s):n+=o,i+=s}}iterChangedRanges(e,t=!1){Es(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];n<0?e.push(i,n):e.push(n,i)}return new qt(e)}composeDesc(e){return this.empty?e:e.empty?this:Th(this,e)}mapDesc(e,t=!1){return e.empty?this:Is(this,e,t)}mapPos(e,t=-1,i=_e.Simple){let n=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],h=this.sections[o++],u=n+l;if(h<0){if(u>e)return s+(e-n);s+=l}else{if(i!=_e.Simple&&u>=e&&(i==_e.TrackDel&&n<e&&u>e||i==_e.TrackBefore&&n<e||i==_e.TrackAfter&&u>e))return null;if(u>e||u==e&&t<0&&!l)return e==n||t<0?s:s+h;s+=h}n=u}if(e>n)throw new RangeError(`Position ${e} is out of range for changeset of length ${n}`);return s}touchesRange(e,t=e){for(let i=0,n=0;i<this.sections.length&&n<=t;){let s=this.sections[i++],o=this.sections[i++],l=n+s;if(o>=0&&n<=t&&l>=e)return n<e&&l>t?"cover":!0;n=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];e+=(e?" ":"")+i+(n>=0?":"+n:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new qt(e)}static create(e){return new qt(e)}}class Ie extends qt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Es(this,(t,i,n,s,o)=>e=e.replace(n,n+(i-t),o),!1),e}mapDesc(e,t=!1){return Is(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let n=0,s=0;n<t.length;n+=2){let o=t[n],l=t[n+1];if(l>=0){t[n]=l,t[n+1]=o;let h=n>>1;for(;i.length<h;)i.push(ce.empty);i.push(o?e.slice(s,s+o):ce.empty)}s+=o}return new Ie(t,i)}compose(e){return this.empty?e:e.empty?this:Th(this,e,!0)}map(e,t=!1){return e.empty?this:Is(this,e,t,!0)}iterChanges(e,t=!1){Es(this,e,t)}get desc(){return qt.create(this.sections)}filter(e){let t=[],i=[],n=[],s=new An(this);e:for(let o=0,l=0;;){let h=o==e.length?1e9:e[o++];for(;l<h||l==h&&s.len==0;){if(s.done)break e;let p=Math.min(s.len,h-l);Ge(n,p,-1);let m=s.ins==-1?-1:s.off==0?s.ins:0;Ge(t,p,m),m>0&&li(i,t,s.text),s.forward(p),l+=p}let u=e[o++];for(;l<u;){if(s.done)break e;let p=Math.min(s.len,u-l);Ge(t,p,-1),Ge(n,p,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(p),l+=p}}return{changes:new Ie(t,i),filtered:qt.create(n)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],n=this.sections[t+1];n<0?e.push(i):n==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let n=[],s=[],o=0,l=null;function h(p=!1){if(!p&&!n.length)return;o<t&&Ge(n,t-o,-1);let m=new Ie(n,s);l=l?l.compose(m.map(l)):m,n=[],s=[],o=0}function u(p){if(Array.isArray(p))for(let m of p)u(m);else if(p instanceof Ie){if(p.length!=t)throw new RangeError(`Mismatched change set length (got ${p.length}, expected ${t})`);h(),l=l?l.compose(p.map(l)):p}else{let{from:m,to:y=m,insert:x}=p;if(m>y||m<0||y>t)throw new RangeError(`Invalid change range ${m} to ${y} (in doc of length ${t})`);let S=x?typeof x=="string"?ce.of(x.split(i||Rs)):x:ce.empty,C=S.length;if(m==y&&C==0)return;m<o&&h(),m>o&&Ge(n,m-o,-1),Ge(n,y-m,C),li(s,n,S),o=y}}return u(e),h(!l),l}static empty(e){return new Ie(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let n=0;n<e.length;n++){let s=e[n];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;i.length<n;)i.push(ce.empty);i[n]=ce.of(s.slice(1)),t.push(s[0],i[n].length)}}}return new Ie(t,i)}static createSet(e,t){return new Ie(e,t)}}function Ge(r,e,t,i=!1){if(e==0&&t<=0)return;let n=r.length-2;n>=0&&t<=0&&t==r[n+1]?r[n]+=e:n>=0&&e==0&&r[n]==0?r[n+1]+=t:i?(r[n]+=e,r[n+1]+=t):r.push(e,t)}function li(r,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<r.length)r[r.length-1]=r[r.length-1].append(t);else{for(;r.length<i;)r.push(ce.empty);r.push(t)}}function Es(r,e,t){let i=r.inserted;for(let n=0,s=0,o=0;o<r.sections.length;){let l=r.sections[o++],h=r.sections[o++];if(h<0)n+=l,s+=l;else{let u=n,p=s,m=ce.empty;for(;u+=l,p+=h,h&&i&&(m=m.append(i[o-2>>1])),!(t||o==r.sections.length||r.sections[o+1]<0);)l=r.sections[o++],h=r.sections[o++];e(n,u,s,p,m),n=u,s=p}}}function Is(r,e,t,i=!1){let n=[],s=i?[]:null,o=new An(r),l=new An(e);for(let h=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let u=Math.min(o.len,l.len);Ge(n,u,-1),o.forward(u),l.forward(u)}else if(l.ins>=0&&(o.ins<0||h==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let u=l.len;for(Ge(n,l.ins,-1);u;){let p=Math.min(o.len,u);o.ins>=0&&h<o.i&&o.len<=p&&(Ge(n,0,o.ins),s&&li(s,n,o.text),h=o.i),o.forward(p),u-=p}l.next()}else if(o.ins>=0){let u=0,p=o.len;for(;p;)if(l.ins==-1){let m=Math.min(p,l.len);u+=m,p-=m,l.forward(m)}else if(l.ins==0&&l.len<p)p-=l.len,l.next();else break;Ge(n,u,h<o.i?o.ins:0),s&&h<o.i&&li(s,n,o.text),h=o.i,o.forward(o.len-p)}else{if(o.done&&l.done)return s?Ie.createSet(n,s):qt.create(n);throw new Error("Mismatched change set lengths")}}}function Th(r,e,t=!1){let i=[],n=t?[]:null,s=new An(r),o=new An(e);for(let l=!1;;){if(s.done&&o.done)return n?Ie.createSet(i,n):qt.create(i);if(s.ins==0)Ge(i,s.len,0,l),s.next();else if(o.len==0&&!o.done)Ge(i,0,o.ins,l),n&&li(n,i,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let h=Math.min(s.len2,o.len),u=i.length;if(s.ins==-1){let p=o.ins==-1?-1:o.off?0:o.ins;Ge(i,h,p,l),n&&p&&li(n,i,o.text)}else o.ins==-1?(Ge(i,s.off?0:s.len,h,l),n&&li(n,i,s.textBit(h))):(Ge(i,s.off?0:s.len,o.off?0:o.ins,l),n&&!o.off&&li(n,i,o.text));l=(s.ins>h||o.ins>=0&&o.len>h)&&(l||i.length>u),s.forward2(h),o.forward(h)}}}}class An{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?ce.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?ce.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class si{constructor(e,t,i,n){this.from=e,this.to=t,this.flags=i,this.goalColumn=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let i,n;return this.empty?i=n=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new si(i,n,this.flags,this.goalColumn)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return I.range(e,t,void 0,void 0,i);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return I.range(this.anchor,n,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return I.range(e.anchor,e.head)}static create(e,t,i,n){return new si(e,t,i,n)}}class I{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:I.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new I([this.main],0)}addRange(e,t=!0){return I.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,I.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new I(e.ranges.map(t=>si.fromJSON(t)),e.main)}static single(e,t=e){return new I([I.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<e.length;n++){let s=e[n];if(s.empty?s.from<=i:s.from<i)return I.normalized(e.slice(),t);i=s.to}return new I(e,t)}static cursor(e,t=0,i,n){return si.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i)),n)}static range(e,t,i,n,s){let o=n==null?7:Math.min(6,n);return!s&&e!=t&&(s=t<e?1:-1),s&&(o|=s<0?8:16),t<e?si.create(t,e,o|32,i):si.create(e,t,o,i)}static undirectionalRange(e,t){return si.create(e,t,64,void 0)}static normalized(e,t=0){let i=e[t];e.sort((n,s)=>n.from-s.from),t=e.indexOf(i);for(let n=1;n<e.length;n++){let s=e[n],o=e[n-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,h=Math.max(s.to,o.to);n<=t&&t--,e.splice(--n,2,s.anchor>s.head?I.range(h,l):I.range(l,h))}}return new I(e,t)}}function Oh(r,e){for(let t of r.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let Ao=0;class j{constructor(e,t,i,n,s){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=n,this.id=Ao++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new j(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Mo),!!e.static,e.enables)}of(e){return new ar([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new ar(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new ar(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function Mo(r,e){return r==e||r.length==e.length&&r.every((t,i)=>t===e[i])}class ar{constructor(e,t,i,n){this.dependencies=e,this.facet=t,this.type=i,this.value=n,this.id=Ao++}dynamicSlot(e){var t;let i=this.value,n=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,h=!1,u=!1,p=[];for(let m of this.dependencies)m=="doc"?h=!0:m=="selection"?u=!0:(((t=e[m.id])!==null&&t!==void 0?t:1)&1)==0&&p.push(e[m.id]);return{create(m){return m.values[o]=i(m),1},update(m,y){if(h&&y.docChanged||u&&(y.docChanged||y.selection)||Ps(m,p)){let x=i(m);if(l?!zl(x,m.values[o],n):!n(x,m.values[o]))return m.values[o]=x,1}return 0},reconfigure:(m,y)=>{let x,S=y.config.address[s];if(S!=null){let C=gr(y,S);if(this.dependencies.every(O=>O instanceof j?y.facet(O)===m.facet(O):O instanceof Ot?y.field(O,!1)==m.field(O,!1):!0)||(l?zl(x=i(m),C,n):n(x=i(m),C)))return m.values[o]=C,0}else x=i(m);return m.values[o]=x,1}}}get extension(){return this}}function zl(r,e,t){if(r.length!=e.length)return!1;for(let i=0;i<r.length;i++)if(!t(r[i],e[i]))return!1;return!0}function Ps(r,e){let t=!1;for(let i of e)xn(r,i)&1&&(t=!0);return t}function ed(r,e,t){let i=t.map(h=>r[h.id]),n=t.map(h=>h.type),s=i.filter(h=>!(h&1)),o=r[e.id]>>1;function l(h){let u=[];for(let p=0;p<i.length;p++){let m=gr(h,i[p]);if(n[p]==2)for(let y of m)u.push(y);else u.push(m)}return e.combine(u)}return{create(h){for(let u of i)xn(h,u);return h.values[o]=l(h),1},update(h,u){if(!Ps(h,s))return 0;let p=l(h);return e.compare(p,h.values[o])?0:(h.values[o]=p,1)},reconfigure(h,u){let p=Ps(h,i),m=u.config.facets[e.id],y=u.facet(e);if(m&&!p&&Mo(t,m))return h.values[o]=y,0;let x=l(h);return e.compare(x,y)?(h.values[o]=y,0):(h.values[o]=x,1)}}}const _n=j.define({static:!0});class Ot{constructor(e,t,i,n,s){this.id=e,this.createF=t,this.updateF=i,this.compareF=n,this.spec=s,this.provides=void 0}static define(e){let t=new Ot(Ao++,e.create,e.update,e.compare||((i,n)=>i===n),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(_n).find(i=>i.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,n)=>{let s=i.values[t],o=this.updateF(s,n);return this.compareF(s,o)?0:(i.values[t]=o,1)},reconfigure:(i,n)=>{let s=i.facet(_n),o=n.facet(_n),l;return(l=s.find(h=>h.field==this))&&l!=o.find(h=>h.field==this)?(i.values[t]=l.create(i),1):n.config.address[this.id]!=null?(i.values[t]=n.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,_n.of({field:this,create:e})]}get extension(){return this}}const bi={lowest:4,low:3,default:2,high:1,highest:0};function fn(r){return e=>new Lh(e,r)}const rn={highest:fn(bi.highest),high:fn(bi.high),default:fn(bi.default),low:fn(bi.low),lowest:fn(bi.lowest)};class Lh{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class Nr{of(e){return new Ns(this,e)}reconfigure(e){return Nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Ns{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class pr{constructor(e,t,i,n,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let n=[],s=Object.create(null),o=new Map;for(let y of td(e,t,o))y instanceof Ot?n.push(y):(s[y.facet.id]||(s[y.facet.id]=[])).push(y);let l=Object.create(null),h=[],u=[];for(let y of n)l[y.id]=u.length<<1,u.push(x=>y.slot(x));let p=i?.config.facets;for(let y in s){let x=s[y],S=x[0].facet,C=p&&p[y]||[];if(x.every(O=>O.type==0))if(l[S.id]=h.length<<1|1,Mo(C,x))h.push(i.facet(S));else{let O=S.combine(x.map(B=>B.value));h.push(i&&S.compare(O,i.facet(S))?i.facet(S):O)}else{for(let O of x)O.type==0?(l[O.id]=h.length<<1|1,h.push(O.value)):(l[O.id]=u.length<<1,u.push(B=>O.dynamicSlot(B)));l[S.id]=u.length<<1,u.push(O=>ed(O,S,x))}}let m=u.map(y=>y(l));return new pr(e,o,m,l,h,s)}}function td(r,e,t){let i=[[],[],[],[],[]],n=new Map;function s(o,l){let h=n.get(o);if(h!=null){if(h<=l)return;let u=i[h].indexOf(o);u>-1&&i[h].splice(u,1),o instanceof Ns&&t.delete(o.compartment)}if(n.set(o,l),Array.isArray(o))for(let u of o)s(u,l);else if(o instanceof Ns){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(o.compartment)||o.inner;t.set(o.compartment,u),s(u,l)}else if(o instanceof Lh)s(o.inner,o.prec);else if(o instanceof Ot)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof ar)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,bi.default);else{let u=o.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(u==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(u,l)}}return s(r,bi.default),i.reduce((o,l)=>o.concat(l))}function xn(r,e){if(e&1)return 2;let t=e>>1,i=r.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;r.status[t]=4;let n=r.computeSlot(r,r.config.dynamicSlots[t]);return r.status[t]=2|n}function gr(r,e){return e&1?r.config.staticValues[e>>1]:r.values[e>>1]}const Bh=j.define(),Fs=j.define({combine:r=>r.some(e=>e),static:!0}),Dh=j.define({combine:r=>r.length?r[0]:void 0,static:!0}),Rh=j.define(),Eh=j.define(),Ih=j.define(),Ph=j.define({combine:r=>r.length?r[0]:!1});class Zt{constructor(e,t){this.type=e,this.value=t}static define(){return new id}}class id{of(e){return new Zt(this,e)}}class nd{constructor(e){this.map=e}of(e){return new me(this,e)}}class me{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new me(this.type,t)}is(e){return this.type==e}static define(e={}){return new nd(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let n of e){let s=n.map(t);s&&i.push(s)}return i}}me.reconfigure=me.define();me.appendConfig=me.define();class Ee{constructor(e,t,i,n,s,o){this.startState=e,this.changes=t,this.selection=i,this.effects=n,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Oh(i,t.newLength),s.some(l=>l.type==Ee.time)||(this.annotations=s.concat(Ee.time.of(Date.now())))}static create(e,t,i,n,s,o){return new Ee(e,t,i,n,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Ee.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}Ee.time=Zt.define();Ee.userEvent=Zt.define();Ee.addToHistory=Zt.define();Ee.remote=Zt.define();function rd(r,e){let t=[];for(let i=0,n=0;;){let s,o;if(i<r.length&&(n==e.length||e[n]>=r[i]))s=r[i++],o=r[i++];else if(n<e.length)s=e[n++],o=e[n++];else return t;!t.length||t[t.length-1]<s?t.push(s,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function Nh(r,e,t){var i;let n,s,o;return t?(n=e.changes,s=Ie.empty(e.changes.length),o=r.changes.compose(e.changes)):(n=e.changes.map(r.changes),s=r.changes.mapDesc(e.changes,!0),o=r.changes.compose(n)),{changes:o,selection:e.selection?e.selection.map(s):(i=r.selection)===null||i===void 0?void 0:i.map(n),effects:me.mapEffects(r.effects,n).concat(me.mapEffects(e.effects,s)),annotations:r.annotations.length?r.annotations.concat(e.annotations):e.annotations,scrollIntoView:r.scrollIntoView||e.scrollIntoView}}function Hs(r,e,t){let i=e.selection,n=$i(e.annotations);return e.userEvent&&(n=n.concat(Ee.userEvent.of(e.userEvent))),{changes:e.changes instanceof Ie?e.changes:Ie.of(e.changes||[],t,r.facet(Dh)),selection:i&&(i instanceof I?i:I.single(i.anchor,i.head)),effects:$i(e.effects),annotations:n,scrollIntoView:!!e.scrollIntoView}}function Fh(r,e,t){let i=Hs(r,e.length?e[0]:{},r.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let o=!!e[s].sequential;i=Nh(i,Hs(r,e[s],o?i.changes.newLength:r.doc.length),o)}let n=Ee.create(r,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return od(t?sd(n):n)}function sd(r){let e=r.startState,t=!0;for(let n of e.facet(Rh)){let s=n(r);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:rd(t,s))}if(t!==!0){let n,s;if(t===!1)s=r.changes.invertedDesc,n=Ie.empty(e.doc.length);else{let o=r.changes.filter(t);n=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}r=Ee.create(e,n,r.selection&&r.selection.map(s),me.mapEffects(r.effects,s),r.annotations,r.scrollIntoView)}let i=e.facet(Eh);for(let n=i.length-1;n>=0;n--){let s=i[n](r);s instanceof Ee?r=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Ee?r=s[0]:r=Fh(e,$i(s),!1)}return r}function od(r){let e=r.startState,t=e.facet(Ih),i=r;for(let n=t.length-1;n>=0;n--){let s=t[n](r);s&&Object.keys(s).length&&(i=Nh(i,Hs(e,s,r.changes.newLength),!0))}return i==r?r:Ee.create(e,r.changes,r.selection,i.effects,i.annotations,i.scrollIntoView)}const ld=[];function $i(r){return r==null?ld:Array.isArray(r)?r:[r]}var je=(function(r){return r[r.Word=0]="Word",r[r.Space=1]="Space",r[r.Other=2]="Other",r})(je||(je={}));const ad=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Ws;try{Ws=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function hd(r){if(Ws)return Ws.test(r);for(let e=0;e<r.length;e++){let t=r[e];if(/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||ad.test(t)))return!0}return!1}function fd(r){return e=>{if(!/\S/.test(e))return je.Space;if(hd(e))return je.Word;for(let t=0;t<r.length;t++)if(e.indexOf(r[t])>-1)return je.Word;return je.Other}}class pe{constructor(e,t,i,n,s,o){this.config=e,this.doc=t,this.selection=i,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)xn(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return xn(this,i),gr(this,i)}update(...e){return Fh(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:n}=t;for(let l of e.effects)l.is(Nr.reconfigure)?(t&&(n=new Map,t.compartments.forEach((h,u)=>n.set(u,h)),t=null),n.set(l.value.compartment,l.value.extension)):l.is(me.reconfigure)?(t=null,i=l.value):l.is(me.appendConfig)&&(t=null,i=$i(i).concat(l.value));let s;t?s=e.startState.values.slice():(t=pr.resolve(i,n,this),s=new pe(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(h,u)=>u.reconfigure(h,this),null).values);let o=e.startState.facet(Fs)?e.newSelection:e.newSelection.asSingle();new pe(t,e.newDoc,o,s,(l,h)=>h.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:I.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),n=this.changes(i.changes),s=[i.range],o=$i(i.effects);for(let l=1;l<t.ranges.length;l++){let h=e(t.ranges[l]),u=this.changes(h.changes),p=u.map(n);for(let y=0;y<l;y++)s[y]=s[y].map(p);let m=n.mapDesc(u,!0);s.push(h.range.map(m)),n=n.compose(p),o=me.mapEffects(o,p).concat(me.mapEffects($i(h.effects),m))}return{changes:n,selection:I.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof Ie?e:Ie.of(e,this.doc.length,this.facet(pe.lineSeparator))}toText(e){return ce.of(e.split(this.facet(pe.lineSeparator)||Rs))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(xn(this,t),gr(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let n=e[i];n instanceof Ot&&this.config.address[n.id]!=null&&(t[i]=n.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i){for(let s in i)if(Object.prototype.hasOwnProperty.call(e,s)){let o=i[s],l=e[s];n.push(o.init(h=>o.spec.fromJSON(l,h)))}}return pe.create({doc:e.doc,selection:I.fromJSON(e.selection),extensions:t.extensions?n.concat([t.extensions]):n})}static create(e={}){let t=pr.resolve(e.extensions||[],new Map),i=e.doc instanceof ce?e.doc:ce.of((e.doc||"").split(t.staticFacet(pe.lineSeparator)||Rs)),n=e.selection?e.selection instanceof I?e.selection:I.single(e.selection.anchor,e.selection.head):I.single(0);return Oh(n,i.length),t.staticFacet(Fs)||(n=n.asSingle()),new pe(t,i,n,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(pe.tabSize)}get lineBreak(){return this.facet(pe.lineSeparator)||`
|
|
5
|
-
`}get readOnly(){return this.facet(Ph)}phrase(e,...t){for(let i of this.facet(pe.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,n)=>{if(n=="$")return"$";let s=+(n||1);return!s||s>t.length?i:t[s-1]})),e}languageDataAt(e,t,i=-1){let n=[];for(let s of this.facet(Bh))for(let o of s(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&n.push(o[e]);return n}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return fd(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:n}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let h=Ne(t,o,!1);if(s(t.slice(h,o))!=je.Word)break;o=h}for(;l<n;){let h=Ne(t,l);if(s(t.slice(l,h))!=je.Word)break;l=h}return o==l?null:I.range(o+i,l+i)}}pe.allowMultipleSelections=Fs;pe.tabSize=j.define({combine:r=>r.length?r[0]:4});pe.lineSeparator=Dh;pe.readOnly=Ph;pe.phrases=j.define({compare(r,e){let t=Object.keys(r),i=Object.keys(e);return t.length==i.length&&t.every(n=>r[n]==e[n])}});pe.languageData=Bh;pe.changeFilter=Rh;pe.transactionFilter=Eh;pe.transactionExtender=Ih;Nr.reconfigure=me.define();function Fr(r,e,t={}){let i={};for(let n of r)for(let s of Object.keys(n)){let o=n[s],l=i[s];if(l===void 0)i[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,s))i[s]=t[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let n in e)i[n]===void 0&&(i[n]=e[n]);return i}class hi{eq(e){return this==e}range(e,t=e){return Vs.create(e,t,this)}}hi.prototype.startSide=hi.prototype.endSide=0;hi.prototype.point=!1;hi.prototype.mapMode=_e.TrackDel;function To(r,e){return r==e||r.constructor==e.constructor&&r.eq(e)}let Vs=class Hh{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new Hh(e,t,i)}};function Ks(r,e){return r.from-e.from||r.value.startSide-e.value.startSide}class Oo{constructor(e,t,i,n){this.from=e,this.to=t,this.value=i,this.maxPoint=n}get length(){return Ni(this.to)}findIndex(e,t,i,n=0){let s=i?this.to:this.from;for(let o=n,l=s.length;;){if(o==l)return o;let h=o+l>>1,u=s[h]-e||(i?this.value[h].endSide:this.value[h].startSide)-t;if(h==o)return u>=0?o:l;u>=0?l=h:o=h+1}}between(e,t,i,n){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,s);s<o;s++)if(n(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t,i,n,s){let o=[],l=[],h=[],u=-1,p=-1;e:for(let m=0;m<this.value.length;m++){let y=this.value[m],x=this.from[m]+e,S=this.to[m]+e,C,O;if(x==S){let B=t.mapPos(x,y.startSide,y.mapMode);if(B==null||(C=O=B,y.startSide!=y.endSide&&(O=t.mapPos(x,y.endSide),O<C)))continue}else if(C=t.mapPos(x,y.startSide),O=t.mapPos(S,y.endSide),C>O||C==O&&y.startSide>0&&y.endSide<=0)continue;if(!((O-C||y.endSide-y.startSide)<0))if(u<0&&(u=C),y.point&&(p=Math.max(p,O-C)),(C-i||y.startSide-n)>=0)o.push(y),l.push(C-u),h.push(O-u),i=O,n=y.endSide;else{if(C==O)for(let B=o.length;B>0;B--){if((C-(h[B-1]+u)||y.startSide-o[B-1].endSide)>=0){o.splice(B,0,y),l.splice(B,0,C-u),h.splice(B,0,O-u);continue e}if((C-(l[B-1]+u)||y.endSide-o[B-1].startSide)>0)break}s(C,O,y)}}return{mapped:o.length?new Oo(l,h,o,p):null,pos:u}}}class ue{constructor(e,t,i,n){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=n}static create(e,t,i,n){return new ue(e,t,i,n)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:n=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(Ks)),this.isEmpty)return t.length?ue.of(t):this;let l=new Wh(this,null,-1).goto(0),h=0,u=[],p=new Ci;for(;l.value||h<t.length;)if(h<t.length&&(l.from-t[h].from||l.startSide-t[h].value.startSide)>=0){let m=t[h++];p.addInner(m.from,m.to,m.value,!1)||u.push(m)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(h==t.length||this.chunkEnd(l.chunkIndex)<t[h].from)&&(!o||n>this.chunkEnd(l.chunkIndex)||s<this.chunkPos[l.chunkIndex])&&p.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||n>l.to||s<l.from||o(l.from,l.to,l.value))&&(p.addInner(l.from,l.to,l.value,!1)||u.push(Vs.create(l.from,l.to,l.value))),l.next());return p.finishInner(this.nextLayer.isEmpty&&!u.length?ue.empty:this.nextLayer.update({add:u,filter:o,filterFrom:n,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],n=-1,s,o=(h,u,p)=>{s||(s=new Ci),s.addRange(h,u,p,!1)};for(let h=0;h<this.chunk.length;h++){let u=this.chunkPos[h],p=this.chunk[h],m=e.touchesRange(u,u+p.length);if(m===!1)n=Math.max(n,p.maxPoint),t.push(p),i.push(e.mapPos(u));else if(m===!0){let[y,x]=t.length?[Ni(i)+Ni(t).length,Ni(Ni(t).value).endSide]:[-1,-1],{mapped:S,pos:C}=p.map(u,e,y,x,o);S&&(n=Math.max(n,S.maxPoint),t.push(S),i.push(C))}}let l=this.nextLayer.map(e);return s&&(l=s.finishInner(l)),t.length==0?l:new ue(i,t,l||ue.empty,n)}between(e,t,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let s=this.chunkPos[n],o=this.chunk[n];if(t>=s&&e<=s+o.length&&o.between(s,e-s,t-s,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return Mn.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Mn.from(e).goto(t)}static compare(e,t,i,n,s=-1){let o=e.filter(m=>m.maxPoint>0||!m.isEmpty&&m.maxPoint>=s),l=t.filter(m=>m.maxPoint>0||!m.isEmpty&&m.maxPoint>=s),h=$l(o,l,i),u=new un(o,h,s),p=new un(l,h,s);i.iterGaps((m,y,x)=>_l(u,m,p,y,x,n)),i.empty&&i.length==0&&_l(u,0,p,0,0,n)}static eq(e,t,i=0,n){n==null&&(n=999999999);let s=e.filter(p=>!p.isEmpty&&t.indexOf(p)<0),o=t.filter(p=>!p.isEmpty&&e.indexOf(p)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=$l(s,o),h=new un(s,l,0).goto(i),u=new un(o,l,0).goto(i);for(;;){if(h.to!=u.to||!zs(h.active,u.active)||h.point&&(!u.point||!To(h.point,u.point)))return!1;if(h.to>n)return!0;h.next(),u.next()}}static spans(e,t,i,n,s=-1){let o=new un(e,null,s).goto(t),l=t,h=o.openStart;for(;;){let u=Math.min(o.to,i);if(o.point){let p=o.activeForPoint(o.to),m=o.pointFrom<t?p.length+1:o.point.startSide<0?p.length:Math.min(p.length,h);n.point(l,u,o.point,p,m,o.pointRank),h=Math.min(o.openEnd(u),p.length)}else u>l&&(n.span(l,u,o.active,h),h=o.openEnd(u));if(o.to>i)return h+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,t=!1){let i=new Ci;for(let n of e instanceof Vs?[e]:t?ud(e):e)i.add(n.from,n.to,n.value);return i.finish()}static join(e){if(!e.length)return ue.empty;let t=Ni(e);for(let i=e.length-2;i>=0;i--)for(let n=e[i];n!=ue.empty;n=n.nextLayer)t=new ue(n.chunkPos,n.chunk,t,Math.max(n.maxPoint,t.maxPoint));return t}}ue.empty=new ue([],[],null,-1);function Ni(r){return r[r.length-1]}function ud(r){if(r.length>1)for(let e=r[0],t=1;t<r.length;t++){let i=r[t];if(Ks(e,i)>0)return r.slice().sort(Ks);e=i}return r}ue.empty.nextLayer=ue.empty;class Ci{finishChunk(e){this.chunks.push(new Oo(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addRange(e,t,i,!0)}addRange(e,t,i,n){this.addInner(e,t,i,n)||(this.nextLayer||(this.nextLayer=new Ci)).addRange(e,t,i,n)}addInner(e,t,i,n){let s=e-this.lastTo||i.startSide-this.last.endSide;if(n&&s<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(ue.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=ue.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function $l(r,e,t){let i=new Map;for(let s of r)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&i.set(s.chunk[o],s.chunkPos[o]);let n=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let l=i.get(s.chunk[o]);l!=null&&(t?t.mapPos(l):l)==s.chunkPos[o]&&!t?.touchesRange(l,l+s.chunk[o].length)&&n.add(s.chunk[o])}return n}class Wh{constructor(e,t,i,n=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,i){for(;this.chunkIndex<this.layer.chunk.length;){let n=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(n)||this.layer.chunkEnd(this.chunkIndex)<e||n.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class Mn{constructor(e){this.heap=e}static from(e,t=null,i=-1){let n=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&n.push(new Wh(o,t,i,s));return n.length==1?n[0]:new Mn(n)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)hs(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)hs(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),hs(this.heap,0)}}}function hs(r,e){for(let t=r[e];;){let i=(e<<1)+1;if(i>=r.length)break;let n=r[i];if(i+1<r.length&&n.compare(r[i+1])>=0&&(n=r[i+1],i++),t.compare(n)<0)break;r[i]=t,r[e]=n,e=i}}class un{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Mn.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){jn(this.active,e),jn(this.activeTo,e),jn(this.activeRank,e),this.minActive=jl(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:n,rank:s}=this.cursor;for(;t<this.activeRank.length&&(s-this.activeRank[t]||n-this.activeTo[t])>0;)t++;qn(this.active,t,i),qn(this.activeTo,t,n),qn(this.activeRank,t,s),e&&qn(e,t,this.cursor.from),this.minActive=jl(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>e){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&jn(i,n)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let n=i.length-1;n>=0&&i[n]<e;n--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function _l(r,e,t,i,n,s){r.goto(e),t.goto(i);let o=i+n,l=i,h=i-e,u=!!s.boundChange;for(let p=!1;;){let m=r.to+h-t.to,y=m||r.endSide-t.endSide,x=y<0?r.to+h:t.to,S=Math.min(x,o);if(r.point||t.point?(r.point&&t.point&&To(r.point,t.point)&&zs(r.activeForPoint(r.to),t.activeForPoint(t.to))||s.comparePoint(l,S,r.point,t.point),p=!1):(p&&(s.boundChange(l),p=!1),S>l&&!zs(r.active,t.active)&&s.compareRange(l,S,r.active,t.active),u&&S<o&&(m||r.openEnd(x)!=t.openEnd(x))&&(p=!0)),x>o)break;l=x,y<=0&&r.next(),y>=0&&t.next()}}function zs(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!=e[t]&&!To(r[t],e[t]))return!1;return!0}function jn(r,e){for(let t=e,i=r.length-1;t<i;t++)r[t]=r[t+1];r.pop()}function qn(r,e,t){for(let i=r.length-1;i>=e;i--)r[i+1]=r[i];r[e]=t}function jl(r,e){let t=-1,i=1e9;for(let n=0;n<e.length;n++)(e[n]-i||r[n].endSide-r[t].endSide)<0&&(t=n,i=e[n]);return t}function Hr(r,e,t=r.length){let i=0;for(let n=0;n<t&&n<r.length;)r.charCodeAt(n)==9?(i+=e-i%e,n++):(i++,n=Ne(r,n));return i}function cd(r,e,t,i){for(let n=0,s=0;;){if(s>=e)return n;if(n==r.length)break;s+=r.charCodeAt(n)==9?t-s%t:1,n=Ne(r,n)}return r.length}const $s="ͼ",ql=typeof Symbol>"u"?"__"+$s:Symbol.for($s),_s=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Ul=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class fi{constructor(e,t){this.rules=[];let{finish:i}=t||{};function n(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,h,u){let p=[],m=/^@(\w+)\b/.exec(o[0]),y=m&&m[1]=="keyframes";if(m&&l==null)return h.push(o[0]+";");for(let x in l){let S=l[x];if(/&/.test(x))s(x.split(/,\s*/).map(C=>o.map(O=>C.replace(/&/,O))).reduce((C,O)=>C.concat(O)),S,h);else if(S&&typeof S=="object"){if(!m)throw new RangeError("The value of a property ("+x+") should be a primitive value.");s(n(x),S,p,y)}else S!=null&&p.push(x.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+S+";")}(p.length||y)&&h.push((i&&!m&&!u?o.map(i):o).join(", ")+" {"+p.join(" ")+"}")}for(let o in e)s(n(o),e[o],this.rules)}getRules(){return this.rules.join(`
|
|
6
|
-
`)}static newName(){let e=
|
|
7
|
-
`;this.styleTag.textContent=o;let l=t.head||t;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var ui={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Tn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},pd=typeof navigator<"u"&&/Mac/.test(navigator.platform),gd=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var $e=0;$e<10;$e++)ui[48+$e]=ui[96+$e]=String($e);for(var $e=1;$e<=24;$e++)ui[$e+111]="F"+$e;for(var $e=65;$e<=90;$e++)ui[$e]=String.fromCharCode($e+32),Tn[$e]=String.fromCharCode($e);for(var fs in ui)Tn.hasOwnProperty(fs)||(Tn[fs]=ui[fs]);function md(r){var e=pd&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||gd&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",t=!e&&r.key||(r.shiftKey?Tn:ui)[r.keyCode]||r.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}let tt=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},js=typeof document<"u"?document:{documentElement:{style:{}}};const qs=/Edge\/(\d+)/.exec(tt.userAgent),Vh=/MSIE \d/.test(tt.userAgent),Us=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(tt.userAgent),Wr=!!(Vh||Us||qs),Gl=!Wr&&/gecko\/(\d+)/i.test(tt.userAgent),us=!Wr&&/Chrome\/(\d+)/.exec(tt.userAgent),Yl="webkitFontSmoothing"in js.documentElement.style,Js=!Wr&&/Apple Computer/.test(tt.vendor),Ql=Js&&(/Mobile\/\w+/.test(tt.userAgent)||tt.maxTouchPoints>2);var _={mac:Ql||/Mac/.test(tt.platform),windows:/Win/.test(tt.platform),linux:/Linux|X11/.test(tt.platform),ie:Wr,ie_version:Vh?js.documentMode||6:Us?+Us[1]:qs?+qs[1]:0,gecko:Gl,gecko_version:Gl?+(/Firefox\/(\d+)/.exec(tt.userAgent)||[0,0])[1]:0,chrome:!!us,chrome_version:us?+us[1]:0,ios:Ql,android:/Android\b/.test(tt.userAgent),webkit:Yl,webkit_version:Yl?+(/\bAppleWebKit\/(\d+)/.exec(tt.userAgent)||[0,0])[1]:0,safari:Js,safari_version:Js?+(/\bVersion\/(\d+(\.\d+)?)/.exec(tt.userAgent)||[0,0])[1]:0,tabSize:js.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Lo(r,e){for(let t in r)t=="class"&&e.class?e.class+=" "+r.class:t=="style"&&e.style?e.style+=";"+r.style:e[t]=r[t];return e}const mr=Object.create(null);function Bo(r,e,t){if(r==e)return!0;r||(r=mr),e||(e=mr);let i=Object.keys(r),n=Object.keys(e);if(i.length-0!=n.length-0)return!1;for(let s of i)if(s!=t&&(n.indexOf(s)==-1||r[s]!==e[s]))return!1;return!0}function vd(r,e){for(let t=r.attributes.length-1;t>=0;t--){let i=r.attributes[t].name;e[i]==null&&r.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?r.style.cssText=i:r.getAttribute(t)!=i&&r.setAttribute(t,i)}}function Xl(r,e,t){let i=!1;if(e)for(let n in e)t&&n in t||(i=!0,n=="style"?r.style.cssText="":r.removeAttribute(n));if(t)for(let n in t)e&&e[n]==t[n]||(i=!0,n=="style"?r.style.cssText=t[n]:r.setAttribute(n,t[n]));return i}function yd(r){let e=Object.create(null);for(let t=0;t<r.attributes.length;t++){let i=r.attributes[t];e[i.name]=i.value}return e}class pi{eq(e){return!1}updateDOM(e,t,i){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var qe=(function(r){return r[r.Text=0]="Text",r[r.WidgetBefore=1]="WidgetBefore",r[r.WidgetAfter=2]="WidgetAfter",r[r.WidgetRange=3]="WidgetRange",r})(qe||(qe={}));class de extends hi{constructor(e,t,i,n){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(e){return new Nn(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Mi(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,n;if(e.isBlockGap)i=-5e8,n=4e8;else{let{start:s,end:o}=Kh(e,t);i=(s?t?-3e8:-1:5e8)-1,n=(o?t?2e8:1:-6e8)+1}return new Mi(e,i,n,t,e.widget||null,!0)}static line(e){return new Fn(e)}static set(e,t=!1){return ue.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}de.none=ue.empty;class Nn extends de{constructor(e){let{start:t,end:i}=Kh(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Lo(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||mr}eq(e){return this==e||e instanceof Nn&&this.tagName==e.tagName&&Bo(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Nn.prototype.point=!1;class Fn extends de{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Fn&&this.spec.class==e.spec.class&&Bo(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}Fn.prototype.mapMode=_e.TrackBefore;Fn.prototype.point=!0;class Mi extends de{constructor(e,t,i,n,s,o){super(t,i,s,e),this.block=n,this.isReplace=o,this.mapMode=n?t<=0?_e.TrackBefore:_e.TrackAfter:_e.TrackDel}get type(){return this.startSide!=this.endSide?qe.WidgetRange:this.startSide<=0?qe.WidgetBefore:qe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Mi&&kd(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}Mi.prototype.point=!0;function Kh(r,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=r;return t==null&&(t=r.inclusive),i==null&&(i=r.inclusive),{start:t??e,end:i??e}}function kd(r,e){return r==e||!!(r&&e&&r.compare(e))}function _i(r,e,t,i=0){let n=t.length-1;n>=0&&t[n]+i>=r?t[n]=Math.max(t[n],e):t.push(r,e)}class On extends hi{constructor(e,t,i){super(),this.tagName=e,this.attributes=t,this.rank=i}eq(e){return e==this||e instanceof On&&this.tagName==e.tagName&&Bo(this.attributes,e.attributes)}static create(e){return new On(e.tagName,e.attributes||mr,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return ue.of(e,t)}}On.prototype.startSide=On.prototype.endSide=-1;function Ln(r){let e;return r.nodeType==11?e=r.getSelection?r:r.ownerDocument:e=r,e.getSelection()}function Gs(r,e){return e?r==e||r.contains(e.nodeType!=1?e.parentNode:e):!1}function wn(r,e){if(!e.anchorNode)return!1;try{return Gs(r,e.anchorNode)}catch{return!1}}function bn(r){return r.nodeType==3?Dn(r,0,r.nodeValue.length).getClientRects():r.nodeType==1?r.getClientRects():[]}function Sn(r,e,t,i){return t?Zl(r,e,t,i,-1)||Zl(r,e,t,i,1):!1}function ci(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e}function vr(r){return r.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(r.nodeName)}function Zl(r,e,t,i,n){for(;;){if(r==t&&e==i)return!0;if(e==(n<0?0:Xt(r))){if(r.nodeName=="DIV")return!1;let s=r.parentNode;if(!s||s.nodeType!=1)return!1;e=ci(r)+(n<0?0:1),r=s}else if(r.nodeType==1){if(r=r.childNodes[e+(n<0?-1:0)],r.nodeType==1&&r.contentEditable=="false")return!1;e=n<0?Xt(r):0}else return!1}}function Xt(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function Bn(r,e){let{left:t,right:i}=r;if(t==i)return r;let n=e?t:i;return{left:n,right:n,top:r.top,bottom:r.bottom}}function xd(r){let e=r.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:r.innerWidth,top:0,bottom:r.innerHeight}}function zh(r,e){let t=e.width/r.offsetWidth,i=e.height/r.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-r.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-r.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function wd(r,e,t,i,n,s,o,l){let h=r.ownerDocument,u=h.defaultView||window;for(let p=r,m=!1;p&&!m;)if(p.nodeType==1){let y,x=p==h.body,S=1,C=1;if(x)y=xd(u);else{if(/^(fixed|sticky)$/.test(getComputedStyle(p).position)&&(m=!0),p.scrollHeight<=p.clientHeight&&p.scrollWidth<=p.clientWidth){p=p.assignedSlot||p.parentNode;continue}let F=p.getBoundingClientRect();({scaleX:S,scaleY:C}=zh(p,F)),y={left:F.left,right:F.left+p.clientWidth*S,top:F.top,bottom:F.top+p.clientHeight*C}}let O=0,B=0;if(n=="nearest")e.top<y.top+o?(B=e.top-(y.top+o),t>0&&e.bottom>y.bottom+B&&(B=e.bottom-y.bottom+o)):e.bottom>y.bottom-o&&(B=e.bottom-y.bottom+o,t<0&&e.top-B<y.top&&(B=e.top-(y.top+o)));else{let F=e.bottom-e.top,P=y.bottom-y.top;B=(n=="center"&&F<=P?e.top+F/2-P/2:n=="start"||n=="center"&&t<0?e.top-o:e.bottom-P+o)-y.top}if(i=="nearest"?e.left<y.left+s?(O=e.left-(y.left+s),t>0&&e.right>y.right+O&&(O=e.right-y.right+s)):e.right>y.right-s&&(O=e.right-y.right+s,t<0&&e.left<y.left+O&&(O=e.left-(y.left+s))):O=(i=="center"?e.left+(e.right-e.left)/2-(y.right-y.left)/2:i=="start"==l?e.left-s:e.right-(y.right-y.left)+s)-y.left,O||B)if(x)u.scrollBy(O,B);else{let F=0,P=0;if(B){let Q=p.scrollTop;p.scrollTop+=B/C,P=(p.scrollTop-Q)*C}if(O){let Q=p.scrollLeft;p.scrollLeft+=O/S,F=(p.scrollLeft-Q)*S}e={left:e.left-F,top:e.top-P,right:e.right-F,bottom:e.bottom-P},F&&Math.abs(F-O)<1&&(i="nearest"),P&&Math.abs(P-B)<1&&(n="nearest")}if(x)break;(e.top<y.top||e.bottom>y.bottom||e.left<y.left||e.right>y.right)&&(e={left:Math.max(e.left,y.left),right:Math.min(e.right,y.right),top:Math.max(e.top,y.top),bottom:Math.min(e.bottom,y.bottom)}),p=p.assignedSlot||p.parentNode}else if(p.nodeType==11)p=p.host;else break}function $h(r,e=!0){let t=r.ownerDocument,i=null,n=null;for(let s=r.parentNode;s&&!(s==t.body||(!e||i)&&n);)if(s.nodeType==1)!n&&s.scrollHeight>s.clientHeight&&(n=s),e&&!i&&s.scrollWidth>s.clientWidth&&(i=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:i,y:n}}class bd{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?Xt(t):0),i,Math.min(e.focusOffset,i?Xt(i):0))}set(e,t,i,n){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=n}}function _h(r){let e=[];for(let t=r;t;t=t.nodeType==11?t.host:t.parentNode)t.nodeType==1&&e.push({node:t,left:t.scrollLeft,top:t.scrollTop});return e}function jh(r,e=!0){for(let{node:t,left:i,top:n}of r)e&&t.scrollTop!=n&&(t.scrollTop=n),t.scrollLeft!=i&&(t.scrollLeft=i)}let wi=null;_.safari&&_.safari_version>=26&&(wi=!1);function qh(r){if(r.setActive)return r.setActive();if(wi)return r.focus(wi);let e=_h(r);r.focus(wi==null?{get preventScroll(){return wi={preventScroll:!0},!0}}:void 0),wi||(wi=!1,jh(e))}let ea;function Dn(r,e,t=e){let i=ea||(ea=document.createRange());return i.setEnd(r,t),i.setStart(r,e),i}function ji(r,e,t,i){let n={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:n.altKey,ctrlKey:n.ctrlKey,shiftKey:n.shiftKey,metaKey:n.metaKey}=i);let s=new KeyboardEvent("keydown",n);s.synthetic=!0,r.dispatchEvent(s);let o=new KeyboardEvent("keyup",n);return o.synthetic=!0,r.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function Sd(r){for(;r;){if(r&&(r.nodeType==9||r.nodeType==11&&r.host))return r;r=r.assignedSlot||r.parentNode}return null}function Cd(r,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,Xt(t));;)if(i){if(t.nodeType!=1)return!1;let n=t.childNodes[i-1];n.contentEditable=="false"?i--:(t=n,i=Xt(t))}else{if(t==r)return!0;i=ci(t),t=t.parentNode}}function Uh(r){return r instanceof Window?r.pageYOffset>Math.max(0,r.document.documentElement.scrollHeight-r.innerHeight-4):r.scrollTop>Math.max(1,r.scrollHeight-r.clientHeight-4)}function Jh(r,e){for(let t=r,i=e;;){if(t.nodeType==3&&i>0)return{node:t,offset:i};if(t.nodeType==1&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=Xt(t)}else if(t.parentNode&&!vr(t))i=ci(t),t=t.parentNode;else return null}}function Gh(r,e){for(let t=r,i=e;;){if(t.nodeType==3&&i<t.nodeValue.length)return{node:t,offset:i};if(t.nodeType==1&&i<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[i],i=0}else if(t.parentNode&&!vr(t))i=ci(t)+1,t=t.parentNode;else return null}}class Mt{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new Mt(e.parentNode,ci(e),t)}static after(e,t){return new Mt(e.parentNode,ci(e)+1,t)}}var Ce=(function(r){return r[r.LTR=0]="LTR",r[r.RTL=1]="RTL",r})(Ce||(Ce={}));const Ti=Ce.LTR,Do=Ce.RTL;function Yh(r){let e=[];for(let t=0;t<r.length;t++)e.push(1<<+r[t]);return e}const Ad=Yh("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Md=Yh("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Ys=Object.create(null),Pt=[];for(let r of["()","[]","{}"]){let e=r.charCodeAt(0),t=r.charCodeAt(1);Ys[e]=t,Ys[t]=-e}function Qh(r){return r<=247?Ad[r]:1424<=r&&r<=1524?2:1536<=r&&r<=1785?Md[r-1536]:1774<=r&&r<=2220?4:8192<=r&&r<=8204?256:64336<=r&&r<=65023?4:1}const Td=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class zt{get dir(){return this.level%2?Do:Ti}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,i,n){let s=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==i)return o;(s<0||(n!=0?n<0?l.from<t:l.to>t:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function Xh(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++){let i=r[t],n=e[t];if(i.from!=n.from||i.to!=n.to||i.direction!=n.direction||!Xh(i.inner,n.inner))return!1}return!0}const ke=[];function Od(r,e,t,i,n){for(let s=0;s<=i.length;s++){let o=s?i[s-1].to:e,l=s<i.length?i[s].from:t,h=s?256:n;for(let u=o,p=h,m=h;u<l;u++){let y=Qh(r.charCodeAt(u));y==512?y=p:y==8&&m==4&&(y=16),ke[u]=y==4?2:y,y&7&&(m=y),p=y}for(let u=o,p=h,m=h;u<l;u++){let y=ke[u];if(y==128)u<l-1&&p==ke[u+1]&&p&24?y=ke[u]=p:ke[u]=256;else if(y==64){let x=u+1;for(;x<l&&ke[x]==64;)x++;let S=u&&p==8||x<t&&ke[x]==8?m==1?1:8:256;for(let C=u;C<x;C++)ke[C]=S;u=x-1}else y==8&&m==1&&(ke[u]=1);p=y,y&7&&(m=y)}}}function Ld(r,e,t,i,n){let s=n==1?2:1;for(let o=0,l=0,h=0;o<=i.length;o++){let u=o?i[o-1].to:e,p=o<i.length?i[o].from:t;for(let m=u,y,x,S;m<p;m++)if(x=Ys[y=r.charCodeAt(m)])if(x<0){for(let C=l-3;C>=0;C-=3)if(Pt[C+1]==-x){let O=Pt[C+2],B=O&2?n:O&4?O&1?s:n:0;B&&(ke[m]=ke[Pt[C]]=B),l=C;break}}else{if(Pt.length==189)break;Pt[l++]=m,Pt[l++]=y,Pt[l++]=h}else if((S=ke[m])==2||S==1){let C=S==n;h=C?0:1;for(let O=l-3;O>=0;O-=3){let B=Pt[O+2];if(B&2)break;if(C)Pt[O+2]|=2;else{if(B&4)break;Pt[O+2]|=4}}}}}function Bd(r,e,t,i){for(let n=0,s=i;n<=t.length;n++){let o=n?t[n-1].to:r,l=n<t.length?t[n].from:e;for(let h=o;h<l;){let u=ke[h];if(u==256){let p=h+1;for(;;)if(p==l){if(n==t.length)break;p=t[n++].to,l=n<t.length?t[n].from:e}else if(ke[p]==256)p++;else break;let m=s==1,y=(p<e?ke[p]:i)==1,x=m==y?m?1:2:i;for(let S=p,C=n,O=C?t[C-1].to:r;S>h;)S==O&&(S=t[--C].from,O=C?t[C-1].to:r),ke[--S]=x;h=p}else s=u,h++}}}function Qs(r,e,t,i,n,s,o){let l=i%2?2:1;if(i%2==n%2)for(let h=e,u=0;h<t;){let p=!0,m=!1;if(u==s.length||h<s[u].from){let C=ke[h];C!=l&&(p=!1,m=C==16)}let y=!p&&l==1?[]:null,x=p?i:i+1,S=h;e:for(;;)if(u<s.length&&S==s[u].from){if(m)break e;let C=s[u];if(!p)for(let O=C.to,B=u+1;;){if(O==t)break e;if(B<s.length&&s[B].from==O)O=s[B++].to;else{if(ke[O]==l)break e;break}}if(u++,y)y.push(C);else{C.from>h&&o.push(new zt(h,C.from,x));let O=C.direction==Ti!=!(x%2);Xs(r,O?i+1:i,n,C.inner,C.from,C.to,o),h=C.to}S=C.to}else{if(S==t||(p?ke[S]!=l:ke[S]==l))break;S++}y?Qs(r,h,S,i+1,n,y,o):h<S&&o.push(new zt(h,S,x)),h=S}else for(let h=t,u=s.length;h>e;){let p=!0,m=!1;if(!u||h>s[u-1].to){let C=ke[h-1];C!=l&&(p=!1,m=C==16)}let y=!p&&l==1?[]:null,x=p?i:i+1,S=h;e:for(;;)if(u&&S==s[u-1].to){if(m)break e;let C=s[--u];if(!p)for(let O=C.from,B=u;;){if(O==e)break e;if(B&&s[B-1].to==O)O=s[--B].from;else{if(ke[O-1]==l)break e;break}}if(y)y.push(C);else{C.to<h&&o.push(new zt(C.to,h,x));let O=C.direction==Ti!=!(x%2);Xs(r,O?i+1:i,n,C.inner,C.from,C.to,o),h=C.from}S=C.from}else{if(S==e||(p?ke[S-1]!=l:ke[S-1]==l))break;S--}y?Qs(r,S,h,i+1,n,y,o):S<h&&o.push(new zt(S,h,x)),h=S}}function Xs(r,e,t,i,n,s,o){let l=e%2?2:1;Od(r,n,s,i,l),Ld(r,n,s,i,l),Bd(n,s,i,l),Qs(r,n,s,e,t,i,o)}function Dd(r,e,t){if(!r)return[new zt(0,0,e==Do?1:0)];if(e==Ti&&!t.length&&!Td.test(r))return Zh(r.length);if(t.length)for(;r.length>ke.length;)ke[ke.length]=256;let i=[],n=e==Ti?0:1;return Xs(r,n,n,t,0,r.length,i),i}function Zh(r){return[new zt(0,r,0)]}let ef="";function Rd(r,e,t,i,n){var s;let o=i.head-r.from,l=zt.find(e,o,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc),h=e[l],u=h.side(n,t);if(o==u){let y=l+=n?1:-1;if(y<0||y>=e.length)return null;h=e[l=y],o=h.side(!n,t),u=h.side(n,t)}let p=Ne(r.text,o,h.forward(n,t));(p<h.from||p>h.to)&&(p=u),ef=r.text.slice(Math.min(o,p),Math.max(o,p));let m=l==(n?e.length-1:0)?null:e[l+(n?1:-1)];return m&&p==u&&m.level+(n?0:1)<h.level?I.cursor(m.side(!n,t)+r.from,m.forward(n,t)?1:-1,m.level):I.cursor(p+r.from,h.forward(n,t)?-1:1,h.level)}function Ed(r,e,t){for(let i=e;i<t;i++){let n=Qh(r.charCodeAt(i));if(n==1)return Ti;if(n==2||n==4)return Do}return Ti}const tf=j.define(),nf=j.define(),rf=j.define(),sf=j.define(),Zs=j.define(),of=j.define(),lf=j.define(),Ro=j.define(),Eo=j.define(),af=j.define({combine:r=>r.some(e=>e)}),hf=j.define({combine:r=>r.some(e=>e)}),ff=j.define();class qi{constructor(e,t,i,n,s,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=n,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new qi(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new qi(I.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Un=me.define({map:(r,e)=>r.map(e)}),uf=me.define();function $t(r,e,t){let i=r.facet(sf);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const Gt=j.define({combine:r=>r.length?r[0]:!0});let Id=0;const Vi=j.define({combine(r){return r.filter((e,t)=>{for(let i=0;i<t;i++)if(r[i].plugin==e.plugin)return!1;return!0})}});class wt{constructor(e,t,i,n,s){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=n,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(Vi.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(Vi.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:i,eventObservers:n,provide:s,decorations:o}=t||{};return new wt(Id++,e,i,n,l=>{let h=[];return o&&h.push(Vr.of(u=>{let p=u.plugin(l);return p?o(p):de.none})),s&&h.push(s(l)),h})}static fromClass(e,t){return wt.define((i,n)=>new e(i,n),t)}}class cs{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if($t(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){$t(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){$t(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const cf=j.define(),Io=j.define(),Vr=j.define(),df=j.define(),Po=j.define(),Hn=j.define(),pf=j.define();function ta(r,e){let t=r.state.facet(pf);if(!t.length)return t;let i=t.map(s=>s instanceof Function?s(r):s),n=[];return ue.spans(i,e.from,e.to,{point(){},span(s,o,l,h){let u=s-e.from,p=o-e.from,m=n;for(let y=l.length-1;y>=0;y--,h--){let x=l[y].spec.bidiIsolate,S;if(x==null&&(x=Ed(e.text,u,p)),h>0&&m.length&&(S=m[m.length-1]).to==u&&S.direction==x)S.to=p,m=S.inner;else{let C={from:u,to:p,direction:x,inner:[]};m.push(C),m=C.inner}}}}),n}const gf=j.define();function mf(r){let e=0,t=0,i=0,n=0;for(let s of r.state.facet(gf)){let o=s(r);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(n=Math.max(n,o.bottom)))}return{left:e,right:t,top:i,bottom:n}}const gn=j.define();class vt{constructor(e,t,i,n){this.fromA=e,this.toA=t,this.fromB=i,this.toB=n}join(e){return new vt(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let n=e[t-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(t.length==0)return e;let i=[];for(let n=0,s=0,o=0;;){let l=n<e.length?e[n].fromB:1e9,h=s<t.length?t[s]:1e9,u=Math.min(l,h);if(u==1e9)break;let p=u+o,m=u,y=p;for(;;)if(s<t.length&&t[s]<=m){let x=t[s+1];s+=2,m=Math.max(m,x);for(let S=n;S<e.length&&e[S].fromB<=m;S++)o=e[S].toA-e[S].toB;y=Math.max(y,x+o)}else if(n<e.length&&e[n].fromB<=m){let x=e[n++];m=Math.max(m,x.toB),y=Math.max(y,x.toA),o=x.toA-x.toB}else break;i.push(new vt(p,y,u,m))}return i}}class yr{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=Ie.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let n=[];this.changes.iterChangedRanges((s,o,l,h)=>n.push(new vt(s,o,l,h))),this.changedRanges=n}static create(e,t,i){return new yr(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const Pd=[];class Te{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Pd}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&vd(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;for(let n of this.children){if(n==e)return i;i+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,i){return null}domPosFor(e,t){let i=ci(this.dom),n=this.length?e>0:t>0;return new Mt(this.parent.dom,i+(n?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof zr)return e;return null}static get(e){return e.cmTile}}class Kr extends Te{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,i=null,n,s=e?.node==t?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,n=i?i.nextSibling:t.firstChild,s&&n!=l.dom&&(s.written=!0),l.dom.parentNode==t)for(;n&&n!=l.dom;)n=ia(n);else t.insertBefore(l.dom,n);i=l.dom}for(n=i?i.nextSibling:t.firstChild,s&&n&&(s.written=!0);n;)n=ia(n);this.length=o}}function ia(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}class zr extends Kr{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=Te.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,n=0,s=0;;)if(n==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&s++,n=t.pop()}else{let o=i.children[n++];if(o instanceof Yt)t.push(n),i=o,n=0;else{let l=s+o.length,h=e(o,s);if(h!==void 0)return h;s=l+o.breakAfter}}}resolveBlock(e,t){let i,n=-1,s,o=-1;if(this.blockTiles((l,h)=>{let u=h+l.length;if(e>=h&&e<=u){if(l.isWidget()&&t>=-1&&t<=1){if(l.flags&32)return!0;l.flags&16&&(i=void 0)}(h<e||e==u&&(t<-1?l.length:l.covers(1)))&&(!i||!l.isWidget()&&i.isWidget())&&(i=l,n=e-h),(u>e||e==h&&(t>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-h)}}),!i&&!s)throw new Error("No tile at position "+e);return i&&t<0||!s?{tile:i,offset:n}:{tile:s,offset:o}}}class Yt extends Kr{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new Yt(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class Qi extends Kr{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let n=new Qi(t||document.createElement("div"),e);return(!t||!i)&&(n.flags|=4),n}get domAttrs(){return this.attrs}resolveInline(e,t,i){let n=null,s=-1,o=null,l=-1;function h(p,m){for(let y=0,x=0;y<p.children.length&&x<=m;y++){let S=p.children[y],C=x+S.length;C>=m&&(S.isComposite()?h(S,m-x):(!o||o.isHidden&&(t>0&&!(o.flags&32)||i&&Fd(o,S)))&&(C>m||S.flags&32&&t<=1)?(o=S,l=m-x):(x<m||S.flags&16&&!S.isHidden&&t>=-1)&&(n=S,s=m-x)),x=C}}h(this,e);let u=(t<0?n:o)||n||o;return u?{tile:u,offset:u==n?s:l}:null}coordsIn(e,t,i){let n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t,i):Nd(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:n,offset:s}=i;if(this.dom.contains(n.dom))return n.isText()?new Mt(n.dom,Math.min(n.dom.nodeValue.length,s)):n.domPosFor(s,n.flags&16?1:n.flags&32?-1:t);let o=i.tile.parent,l=!1;for(let h of o.children){if(l)return new Mt(h.dom,0);h==i.tile&&(l=!0)}}return new Mt(this.dom,0)}}function Nd(r){let e=r.dom.lastChild;if(!e)return r.dom.getBoundingClientRect();let t=bn(e);return t[t.length-1]||null}function Fd(r,e){let t=r.coordsIn(0,1),i=e.coordsIn(0,1);return t&&i&&i.top<t.bottom}class lt extends Kr{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let i=new lt(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class Si extends Te{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t,i){let n=this.dom.nodeValue.length;e>n&&(e=n);let s=e,o=e,l=0;e==0&&t<0||e==n&&t>=0?_.chrome||_.gecko||(e?(s--,l=1):o<n&&(o++,l=-1)):t<0?s--:o<n&&o++;let h=Dn(this.dom,s,o).getClientRects();if(!h.length)return null;let u=h[(l?l<0:t>=0)?0:h.length-1];return _.safari&&!l&&u.width==0&&(u=Array.prototype.find.call(h,p=>p.width)||u),i==null?u:Bn(u,(l?l>0:t<0)==i)}static of(e,t){let i=new Si(t||document.createTextNode(e),e);return t||(i.flags|=2),i}}class Oi extends Te{constructor(e,t,i,n){super(e,t,n),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;if(i)return Bn(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let h=l?s.length-1:0;o=s[h],!(e>0?h==0:h==s.length-1||o.top<o.bottom);h+=l?-1:1);return Bn(o,!l)}}get overrideDOMText(){if(!this.length)return ce.empty;let{root:e}=this;if(!e)return ce.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,i,n,s){return s||(s=e.toDOM(t),e.editable||(s.contentEditable="false")),new Oi(s,i,e,n)}}class kr extends Te{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return ce.empty}coordsIn(e,t,i){let n=this.dom.getBoundingClientRect();return i==null?n:Bn(n,t>0==i)}}class Hd{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:n,index:s,beforeBreak:o,parents:l}=this;for(;e||t>0;)if(n.isComposite())if(o){if(!e)break;i&&i.break(),e--,o=!1}else if(s==n.children.length){if(!e&&!l.length)break;i&&i.leave(n),o=!!n.breakAfter,{tile:n,index:s}=l.pop(),s++}else{let h=n.children[s],u=h.breakAfter;(t>0?h.length<=e:h.length<e)&&(!i||i.skip(h,0,h.length)!==!1||!h.isComposite)?(o=!!u,s++,e-=h.length):(l.push({tile:n,index:s}),n=h,s=0,i&&h.isComposite()&&i.enter(h))}else{let h=n.length;if(s<h&&e){let u=Math.min(e,h-s);i&&i.skip(n,s,s+u),e-=u,s+=u}if(s==h)o=!!n.breakAfter,{tile:n,index:s}=l.pop(),s++;else if(!e)break}return this.tile=n,this.index=s,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class Wd{constructor(e,t,i,n){this.from=e,this.to=t,this.wrapper=i,this.rank=n}}class Vd{constructor(e,t,i){this.cache=e,this.root=t,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,i,n){var s;this.flushBuffer();let o=this.ensureMarks(t,i),l=o.lastChild;if(l&&l.isText()&&!(l.flags&8)&&l.length+e.length<512){this.cache.reused.set(l,2);let h=o.children[o.children.length-1]=new Si(l.dom,l.text+e);h.parent=o}else o.append(n||Si.of(e,(s=this.cache.find(Si))===null||s===void 0?void 0:s.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let i=this.curLine;i.dom!=t.line.dom&&(i.setDOM(this.cache.reused.has(t.line)?ds(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let n=i;for(let l=t.marks.length-1;l>=0;l--){let h=t.marks[l],u=n.lastChild;if(u instanceof lt&&u.mark.eq(h.mark))u.dom!=h.dom&&u.setDOM(ds(h.dom)),n=u;else{let{dom:p}=h;this.cache.reused.get(h)&&Te.get(h.dom)&&(p=ds(h.dom));let m=lt.of(h.mark,p);n.append(m),n=m}this.cache.reused.set(h,2)}let s=Te.get(e.text);s&&this.cache.reused.set(s,2);let o=new Si(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,n.append(o)}addInlineWidget(e,t,i){let n=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);n||this.flushBuffer();let s=this.ensureMarks(t,i);!n&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=vf);let n=Qi.start(e,t||((i=this.cache.find(Qi))===null||i===void 0?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=n)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var i;let n=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(t>0&&(l=n.lastChild)&&l instanceof lt&&l.mark.eq(o))n=l,t--;else{let h=lt.of(o,(i=this.cache.find(lt,u=>u.mark.eq(o)))===null||i===void 0?void 0:i.dom);n.append(h),n=h,t=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!na(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(_.ios&&na(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(ps,0,32)||new Oi(ps.toDOM(),0,ps,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=e.rank*102+e.value.rank,i=new Wd(e.from,e.to,e.value,t),n=this.wrappers.length;for(;n>0&&(this.wrappers[n-1].rank-i.rank||this.wrappers[n-1].to-i.to)<0;)n--;this.wrappers.splice(n,0,i)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let n=t.lastChild;if(i.from<this.pos&&n instanceof Yt&&n.wrapper.eq(i.wrapper))t=n;else{let s=Yt.of(i.wrapper,(e=this.cache.find(Yt,o=>o.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(s),t=s}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(kr,void 0,1);return i&&(i.flags=t),i||new kr(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class Kd{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:n,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=n;let l=this.textOff=Math.min(e,n.length);return s?null:n.slice(0,l)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}}const xr=[Oi,Qi,Si,lt,kr,Yt,zr];for(let r=0;r<xr.length;r++)xr[r].bucket=r;class zd{constructor(e){this.view=e,this.buckets=xr.map(()=>[]),this.index=xr.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let n=e.bucket,s=this.buckets[n],o=this.index[n];for(let l=0;l<s.length;l++){let h=(l+o)%s.length,u=s[h];if((!t||t(u))&&!this.reused.has(u))return s.splice(h,1),h<o&&this.index[n]--,this.reused.set(u,i),u}return null}findWidget(e,t,i){let n=this.buckets[0];if(n.length)for(let s=0,o=0;;s++){if(s==n.length){if(o)return null;o=1,s=0}let l=n[s];if(!this.reused.has(l)&&(o==0?l.widget.compare(e):l.widget.constructor==e.constructor&&e.updateDOM(l.dom,this.view,l.widget)))return n.splice(s,1),s<this.index[0]&&this.index[0]--,l.widget==e&&l.length==t&&(l.flags&497)==i?(this.reused.set(l,1),l):(this.reused.set(l,2),new Oi(l.dom,t,e,l.flags&-498|i))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class $d{constructor(e,t,i,n,s){this.view=e,this.decorations=n,this.disallowBlockEffectsFor=s,this.openWidget=!1,this.openMarks=0,this.cache=new zd(e),this.text=new Kd(e.state.doc),this.builder=new Vd(this.cache,new zr(e,e.contentDOM),ue.iter(i)),this.cache.reused.set(t,2),this.old=new Hd(t),this.reuseWalker={skip:(o,l,h)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let n=0,s=0,o=0;;){let l=o<e.length?e[o++]:null,h=l?l.fromA:this.old.root.length;if(h>n){let u=h-n;this.preserve(u,!o,!l),n=h,s+=u}if(!l)break;t&&l.fromA<=t.range.fromA&&l.toA>=t.range.toA?(this.forward(l.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(s,t.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(t,i),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,l.toA),this.emit(t.range.toB,l.toB)):(this.forward(l.fromA,l.toA),this.emit(s,l.toB)),s=l.toB,n=l.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,i){let n=qd(this.old),s=this.openMarks;this.old.advance(e,i?1:-1,{skip:(o,l,h)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(h-l);else{let u=h>0||l<o.length?Oi.of(o.widget,this.view,h-l,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);u.flags&256?(u.flags&=-2,this.builder.addBlockWidget(u)):(this.builder.ensureLine(null),this.builder.addInlineWidget(u,n,s),s=n.length)}else if(o.isText())this.builder.ensureLine(null),!l&&h==o.length&&!this.cache.reused.has(o)?this.builder.addText(o.text,n,s,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(l,h),n,s)),s=n.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof kr)this.cache.add(o);else if(o instanceof lt)this.builder.ensureLine(null),this.builder.addMark(o,n,s),this.cache.reused.set(o,1),s=n.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof lt&&n.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?n.length&&(n.length=s=0):o instanceof lt&&(n.shift(),s=Math.min(s,n.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,n=this.builder,s=-1,o=ue.spans(this.decorations,e,t,{point:(l,h,u,p,m,y)=>{if(u instanceof Mi){if(this.disallowBlockEffectsFor[y]){if(u.block)throw new RangeError("Block decorations may not be specified via plugins");if(h>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=p.length,m>p.length)n.continueWidget(h-l);else{let x=u.widget||(u.block?Xi.block:Xi.inline),S=_d(u),C=this.cache.findWidget(x,h-l,S)||Oi.of(x,this.view,h-l,S);u.block?(u.startSide>0&&n.addLineStartIfNotCovered(i),n.addBlockWidget(C)):(n.ensureLine(i),n.addInlineWidget(C,p,m))}i=null}else i=jd(i,u);h>l&&this.text.skip(h-l)},span:(l,h,u,p)=>{for(let m=l;m<h;){let y=this.text.next(Math.min(512,h-m));y==null?(n.addLineStartIfNotCovered(i),n.addBreak(),m++):(n.ensureLine(i),n.addText(y,u,m==l?p:u.length),m+=y.length),i=null}s=u.length}});s>-1&&(this.openWidget=o>s),this.openWidget||n.addLineStartIfNotCovered(i),this.openMarks=o}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let n=e.parentNode;;n=n.parentNode){let s=Te.get(n);if(n==this.view.contentDOM)break;s instanceof lt?t.push(s):s?.isLine()?i=s:s instanceof Yt||(n.nodeName=="DIV"&&!i?i=new Qi(n,vf):i||t.push(lt.of(new Nn({tagName:n.nodeName.toLowerCase(),attributes:yd(n)}),n)))}return i?{line:i,marks:t}:null}}function na(r,e){let t=i=>{for(let n of i.children)if((e?n.isText():n.length)||t(n))return!0;return!1};return t(r)}function _d(r){let e=r.isReplace?(r.startSide<0?64:0)|(r.endSide>0?128:0):r.startSide>0?32:16;return r.block&&(e|=256),e}const vf={class:"cm-line"};function jd(r,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(r||(r={class:"cm-line"}),t&&Lo(t,r),i&&(r.class+=" "+i)),r}function qd(r){let e=[];for(let t=r.parents.length;t>1;t--){let i=t==r.parents.length?r.tile:r.parents[t].tile;i instanceof lt&&e.push(i.mark)}return e}function ds(r){let e=Te.get(r);return e&&e.setDOM(r.cloneNode()),r}class Xi extends pi{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Xi.inline=new Xi("span");Xi.block=new Xi("div");const ps=new class extends pi{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class ra{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=de.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new zr(e,e.contentDOM),this.updateInner([new vt(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:p,toA:m})=>m<this.minWidthFrom||p>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?n=this.domChanged.newSel.head:!tp(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let s=n>-1?Jd(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:p,to:m}=this.hasComposition;i=new vt(p,m,e.changes.mapPos(p,-1),e.changes.mapPos(m,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(_.ie||_.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let h=Qd(o,this.decorations,e.changes);h.length&&(i=vt.extendWithRanges(i,h));let u=Zd(l,this.blockWrappers,e.changes);return u.length&&(i=vt.extendWithRanges(i,u)),s&&!i.some(p=>p.fromA<=s.range.fromA&&p.toA>=s.range.toA)&&(i=s.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let o=this.tile,l=new $d(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&Te.get(t.text)&&l.cache.reused.set(Te.get(t.text),2),this.tile=l.run(e,t),eo(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=_.chrome||_.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||i.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let n=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let s of this.tile.children)s.isWidget()&&s.widget instanceof gs&&n.push(s.dom);i.updateGaps(n)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let i of t.effects)i.is(uf)&&(this.editContextFormatting=i.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:i}=this.tile,n=this.view.root.activeElement,s=n==i,o=!s&&!(this.view.state.facet(Gt)||i.tabIndex>-1)&&wn(i,this.view.observer.selectionRange)&&!(n&&i.contains(n));if(!(s||t||o))return;let l=this.forceSelection;this.forceSelection=!1;let h=this.view.state.selection.main,u,p;if(h.empty?p=u=this.inlineDOMNearPos(h.anchor,h.assoc||1):(p=this.inlineDOMNearPos(h.head,h.head==h.from?1:-1),u=this.inlineDOMNearPos(h.anchor,h.anchor==h.from?1:-1)),_.gecko&&h.empty&&!this.hasComposition&&Ud(u)){let y=document.createTextNode("");this.view.observer.ignore(()=>u.node.insertBefore(y,u.node.childNodes[u.offset]||null)),u=p=new Mt(y,0),l=!0}let m=this.view.observer.selectionRange;(l||!m.focusNode||(!Sn(u.node,u.offset,m.anchorNode,m.anchorOffset)||!Sn(p.node,p.offset,m.focusNode,m.focusOffset))&&!this.suppressWidgetCursorChange(m,h))&&(this.view.observer.ignore(()=>{_.android&&_.chrome&&i.contains(m.focusNode)&&ep(m.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let y=Ln(this.view.root);if(y)if(h.empty){if(_.gecko){let x=Gd(u.node,u.offset);if(x&&x!=3){let S=(x==1?Jh:Gh)(u.node,u.offset);S&&(u=new Mt(S.node,S.offset))}}y.collapse(u.node,u.offset),h.bidiLevel!=null&&y.caretBidiLevel!==void 0&&(y.caretBidiLevel=h.bidiLevel)}else if(y.extend){y.collapse(u.node,u.offset);try{y.extend(p.node,p.offset)}catch{}}else{let x=document.createRange();h.anchor>h.head&&([u,p]=[p,u]),x.setEnd(p.node,p.offset),x.setStart(u.node,u.offset),y.removeAllRanges(),y.addRange(x)}o&&this.view.root.activeElement==i&&(i.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(u,p)),this.impreciseAnchor=u.precise?null:new Mt(m.anchorNode,m.anchorOffset),this.impreciseHead=p.precise?null:new Mt(m.focusNode,m.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Sn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=Ln(e.root),{anchorNode:n,anchorOffset:s}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let h=this.coordsAt(t.head,-1),u=this.coordsAt(t.head,1);if(!h||!u||h.bottom>u.top)return;let p=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(p.node,p.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let m=e.observer.selectionRange;e.docView.posFromDOM(m.anchorNode,m.anchorOffset)!=t.from&&i.collapse(n,s)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let n=i.posAtStart;if(i.isComposite()){let s;if(e==i.dom)s=i.dom.childNodes[t];else{let o=Xt(e)==0?0:t==0?-1:1;for(;;){let l=e.parentNode;if(l==i.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==i.dom.firstChild)return n;for(;s&&!Te.get(s);)s=s.nextSibling;if(!s)return n+i.length;for(let o=0,l=n;;o++){let h=i.children[o];if(h.dom==s)return l;l+=h.length+h.breakAfter}}else return i.isText()?e==i.dom?n+t:n+(t?i.length:0):n}domAtPos(e,t){let{tile:i,offset:n}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(n,t):i.domIn(n,t)}inlineDOMNearPos(e,t){let i,n=-1,s=!1,o,l=-1,h=!1;return this.tile.blockTiles((u,p)=>{if(u.isWidget()){if(u.flags&32&&p>=e)return!0;u.flags&16&&(s=!0)}else{let m=p+u.length;if(p<=e&&(i=u,n=e-p,s=m<e),m>=e&&!o&&(o=u,l=e-p,h=p>e),p>e&&o)return!0}}),!i&&!o?this.domAtPos(e,t):(s&&o?i=null:h&&i&&(o=null),i&&t<0||!o?i.domIn(n,t):o.domIn(l,t))}coordsAt(e,t,i){let{tile:n,offset:s}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof gs?null:n.coordsInWidget(s,t,!0):n.coordsIn(s,t,i)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function n(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let h=n(l,o);if(h)return h}if(o-=l.length,o<0)break}else if(s.isText()&&o<s.length){let l=Ne(s.text,o);if(l==o)return null;let h=Dn(s.dom,o,l).getClientRects();for(let u=0;u<h.length;u++){let p=h[u];if(u==h.length-1||p.top<p.bottom&&p.left<p.right)return p}}return null}return n(t,i)}measureVisibleLineHeights(e){let t=[],{from:i,to:n}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,h=this.view.textDirection==Ce.LTR,u=0,p=(m,y,x)=>{for(let S=0;S<m.children.length&&!(y>n);S++){let C=m.children[S],O=y+C.length,B=C.dom.getBoundingClientRect(),{height:F}=B;if(x&&!S&&(u+=B.top-x.top),C instanceof Yt)O>i&&p(C,y,B);else if(y>=i&&(u>0&&t.push(-u),t.push(F+u),u=0,o)){let P=C.dom.lastChild,Q=P?bn(P):[];if(Q.length){let W=Q[Q.length-1],V=h?W.right-B.left:B.right-W.left;V>l&&(l=V,this.minWidth=s,this.minWidthFrom=y,this.minWidthTo=O)}}x&&S==m.children.length-1&&(u+=x.bottom-B.bottom),y=O+C.breakAfter}};return p(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?Ce.RTL:Ce.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,h;for(let u of o.children){if(!u.isText()||/[^ -~]/.test(u.text))return;let p=bn(u.dom);if(p.length!=1)return;l+=p[0].width,h=p[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:h}}});if(e)return e;let t=document.createElement("div"),i,n,s;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=bn(t.firstChild)[0];i=t.getBoundingClientRect().height,n=o&&o.width?o.width/27:7,s=o&&o.height?o.height:i,t.remove()}),{lineHeight:i,charWidth:n,textHeight:s}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,n=0;;n++){let s=n==t.viewports.length?null:t.viewports[n],o=s?s.from-1:this.view.state.doc.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(de.replace({widget:new gs(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return de.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Vr).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),i=!1,n=this.view.state.facet(Po).map((s,o)=>{let l=typeof s=="function";return l&&(i=!0),l?s(this.view):s});for(n.length&&(this.dynamicDecorationMap[e++]=i,t.push(ue.join(n))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(df).map(s=>typeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let u=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=u.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let u of this.view.state.facet(ff))try{if(u(this.view,e.range,e))return!0}catch(p){$t(this.view.state,p,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),n;if(!i)return;!t.empty&&(n=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,n.left),top:Math.min(i.top,n.top),right:Math.max(i.right,n.right),bottom:Math.max(i.bottom,n.bottom)});let s=mf(this.view),o={left:i.left-s.left,top:i.top-s.top,right:i.right+s.right,bottom:i.bottom+s.bottom},{offsetWidth:l,offsetHeight:h}=this.view.scrollDOM;if(wd(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,h),-h),this.view.textDirection==Ce.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(i.top>window.visualViewport.offsetTop+window.visualViewport.height||i.bottom<window.visualViewport.offsetTop)){let u=this.view.docView.lineAt(t.head,1);if(u){let p=_h(u.dom);u.dom.scrollIntoView({block:"nearest"}),jh(p,!1)}}}lineHasWidget(e){let t=i=>i.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){eo(this.tile)}}function eo(r,e){let t=e?.get(r);if(t!=1){t==null&&r.destroy();for(let i of r.children)eo(i,e)}}function Ud(r){return r.node.nodeType==1&&r.node.firstChild&&(r.offset==0||r.node.childNodes[r.offset-1].contentEditable=="false")&&(r.offset==r.node.childNodes.length||r.node.childNodes[r.offset].contentEditable=="false")}function yf(r,e){let t=r.observer.selectionRange;if(!t.focusNode)return null;let i=Jh(t.focusNode,t.focusOffset),n=Gh(t.focusNode,t.focusOffset),s=i||n;if(n&&i&&n.node!=i.node){let l=Te.get(n.node);if(!l||l.isText()&&l.text!=n.node.nodeValue)s=n;else if(r.docView.lastCompositionAfterCursor){let h=Te.get(i.node);!h||h.isText()&&h.text!=i.node.nodeValue||(s=n)}}if(r.docView.lastCompositionAfterCursor=s!=i,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function Jd(r,e,t){let i=yf(r,t);if(!i)return null;let{node:n,from:s,to:o}=i,l=n.nodeValue;if(/[\n\r]/.test(l)||r.state.doc.sliceString(i.from,i.to)!=l)return null;let h=e.invertedDesc;return{range:new vt(h.mapPos(s),h.mapPos(o),s,o),text:n}}function Gd(r,e){return r.nodeType!=1?0:(e&&r.childNodes[e-1].contentEditable=="false"?1:0)|(e<r.childNodes.length&&r.childNodes[e].contentEditable=="false"?2:0)}let Yd=class{constructor(){this.changes=[]}compareRange(e,t){_i(e,t,this.changes)}comparePoint(e,t){_i(e,t,this.changes)}boundChange(e){_i(e,e,this.changes)}};function Qd(r,e,t){let i=new Yd;return ue.compare(r,e,t,i),i.changes}class Xd{constructor(){this.changes=[]}compareRange(e,t){_i(e,t,this.changes)}comparePoint(){}boundChange(e){_i(e,e,this.changes)}}function Zd(r,e,t){let i=new Xd;return ue.compare(r,e,t,i),i.changes}function ep(r,e){for(let t=r;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function tp(r,e){let t=!1;return e&&r.iterChangedRanges((i,n)=>{i<e.to&&n>e.from&&(t=!0)}),t}class gs extends pi{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function ip(r,e,t=1){let i=r.charCategorizer(e),n=r.doc.lineAt(e),s=e-n.from;if(n.length==0)return I.cursor(e);s==0?t=1:s==n.length&&(t=-1);let o=s,l=s;t<0?o=Ne(n.text,s,!1):l=Ne(n.text,s);let h=i(n.text.slice(o,l));for(;o>0;){let u=Ne(n.text,o,!1);if(i(n.text.slice(u,o))!=h)break;o=u}for(;l<n.length;){let u=Ne(n.text,l);if(i(n.text.slice(l,u))!=h)break;l=u}return I.undirectionalRange(o+n.from,l+n.from)}function np(r,e,t,i,n){let s=Math.round((i-e.left)*r.defaultCharacterWidth);if(r.lineWrapping&&t.height>r.defaultLineHeight*1.5){let l=r.viewState.heightOracle.textHeight,h=Math.floor((n-t.top-(r.defaultLineHeight-l)*.5)/l);s+=h*r.viewState.heightOracle.lineLength}let o=r.state.sliceDoc(t.from,t.to);return t.from+cd(o,s,r.state.tabSize)}function to(r,e,t){let i=r.lineBlockAt(e);if(Array.isArray(i.type)){let n;for(let s of i.type){if(s.from>e)break;if(!(s.to<e)){if(s.from<e&&s.to>e)return s;(!n||s.type==qe.Text&&(n.type!=s.type||(t<0?s.from<e:s.to>e)))&&(n=s)}}return n||i}return i}function rp(r,e,t,i){let n=to(r,e.head,e.assoc||-1),s=!i||n.type!=qe.Text||!(r.lineWrapping||n.widgetLineBreaks)?null:r.coordsAtPos(e.assoc<0&&e.head>n.from?e.head-1:e.head);if(s){let l=r.dom.getBoundingClientRect(),h=r.textDirectionAt(n.from),u=r.posAtCoords({x:t==(h==Ce.LTR)?l.right-1:l.left+1,y:(s.top+s.bottom)/2});if(u!=null)return I.cursor(u,t?-1:1)}let o=r.state.doc.lineAt(e.head);return(t?o.to==n.to:o.from==n.from)?r.visualLineSide(o,t):I.cursor(t?n.to:n.from,t?-1:1)}function sa(r,e,t,i){let n=r.state.doc.lineAt(e.head),s=r.bidiSpans(n),o=r.textDirectionAt(n.from);for(let l=e,h=null;;){let u=Rd(n,s,o,l,t),p=ef;if(!u){if(n.number==(t?r.state.doc.lines:1))return l;p=`
|
|
8
|
-
`,n=r.state.doc.line(n.number+(t?1:-1)),s=r.bidiSpans(n),u=r.visualLineSide(n,!t)}if(h){if(!h(p))return l}else{if(!i)return u;h=i(p)}l=u}}function sp(r,e,t){let i=r.state.charCategorizer(e),n=i(t);return s=>{let o=i(s);return n==je.Space&&(n=o),n==o}}function op(r,e,t,i){let n=e.head,s=t?1:-1;if(n==(t?r.state.doc.length:0))return I.cursor(n,e.assoc);let o=e.goalColumn,l,h=r.contentDOM.getBoundingClientRect(),u=r.coordsAtPos(n,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),p=r.documentTop;if(u)o==null&&(o=u.left-h.left),l=s<0?u.top:u.bottom;else{let S=r.viewState.lineBlockAt(n);o==null&&(o=Math.min(h.right-h.left,r.defaultCharacterWidth*(n-S.from))),l=(s<0?S.top:S.bottom)+p}let m=h.left+o,y=r.viewState.heightOracle.textHeight>>1,x=i??y;for(let S=0;;S+=y){let C=l+(x+S)*s,O=io(r,{x:m,y:C},!1,s);if(t?C>h.bottom:C<h.top)return I.cursor(O.pos,O.assoc);let B=r.coordsAtPos(O.pos,O.assoc),F=B?(B.top+B.bottom)/2:0;if(!B||(t?F>l:F<l))return I.cursor(O.pos,O.assoc,void 0,o)}}function Cn(r,e,t){for(;;){let i=0;for(let n of r)n.between(e-1,e+1,(s,o,l)=>{if(e>s&&e<o){let h=i||t||(e-s<o-e?-1:1);e=h<0?s:o,i=h}});if(!i)return e}}function kf(r,e){let t=null;for(let i=0;i<e.ranges.length;i++){let n=e.ranges[i],s=null;if(n.empty){let o=Cn(r,n.from,0);o!=n.from&&(s=I.cursor(o,-1))}else{let o=Cn(r,n.from,-1),l=Cn(r,n.to,1);(o!=n.from||l!=n.to)&&(n.undirectional?s=I.undirectionalRange(n.from,n.to):s=I.range(n.from==n.anchor?o:l,n.from==n.head?o:l))}s&&(t||(t=e.ranges.slice()),t[i]=s)}return t?I.create(t,e.mainIndex):e}function ms(r,e,t){let i=Cn(r.state.facet(Hn).map(n=>n(r)),t.from,e.head>t.from?-1:1);return i==t.from?t:I.cursor(i,i<t.from?1:-1)}class Kt{constructor(e,t){this.pos=e,this.assoc=t}}function io(r,e,t,i){let n=r.contentDOM.getBoundingClientRect(),s=n.top+r.viewState.paddingTop,{x:o,y:l}=e,h=l-s,u;for(;;){if(h<0)return new Kt(0,1);if(h>r.viewState.docHeight)return new Kt(r.state.doc.length,-1);if(u=r.elementAtHeight(h),i==null)break;if(u.type==qe.Text){if(i<0?u.to<r.viewport.from:u.from>r.viewport.to)break;let y=r.docView.coordsAt(i<0?u.from:u.to,i>0?-1:1);if(y&&(i<0?y.top<=h+s:y.bottom>=h+s))break}let m=r.viewState.heightOracle.textHeight/2;h=i>0?u.bottom+m:u.top-m}if(r.viewport.from>=u.to||r.viewport.to<=u.from){if(t)return null;if(u.type==qe.Text){let m=np(r,n,u,o,l);return new Kt(m,m==u.from?1:-1)}}if(u.type!=qe.Text)return h<(u.top+u.bottom)/2?new Kt(u.from,1):new Kt(u.to,-1);let p=r.docView.lineAt(u.from,2);return(!p||p.length!=u.length)&&(p=r.docView.lineAt(u.from,-2)),new lp(r,o,l,r.textDirectionAt(u.from)).scanTile(p,u.from)}class lp{constructor(e,t,i,n){this.view=e,this.x=t,this.y=i,this.baseDir=n,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:i,spans:n}=this.bidiSpansAt(e);return n[zt.find(n,e-i.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:i,spans:n}=this.bidiSpansAt(e);return n[zt.find(n,e-i.from,-1,t)].dir}bidiIn(e,t){let{spans:i,line:n}=this.bidiSpansAt(e);return i.length>1||i.length&&(i[0].level!=this.baseDir||i[0].to+n.from<t)}scan(e,t,i=!1){let n=0,s=e.length-1,o=new Set,l=this.bidiIn(e[0],e[s]),h,u,p=-1,m=1e9,y;e:for(;n<s;){let S=s-n,C=n+s>>1;t:if(o.has(C)){for(let F=1;F<S;F++){let P=C+F;if(P>=s&&(P-=S),!o.has(P)){C=P;break t}}break e}o.add(C);let O=t(C),B=0;if(O)for(let F=0;F<O.length;F++){let P=O[F];if(!(P.width==0&&O.length>1))if(P.bottom<this.y)(!h||h.bottom<P.bottom)&&(h=P),B=1;else if(P.top>this.y)(!u||u.top>P.top)&&(u=P),B=-1;else{let Q=P.left>this.x?this.x-P.left:P.right<this.x?this.x-P.right:0,W=Math.abs(Q);W<m&&(p=C,m=W,y=P),Q&&(B=Q<0==(this.baseDir==Ce.LTR)?-1:1)}}B==-1&&(!l||this.baseDirAt(e[C],1))?s=C:B==1&&(!l||this.baseDirAt(e[C+1],-1))&&(n=C+1)}if(!y){if(!u&&!h)return{i:0,after:!1};let S=h&&(!u||this.y-h.bottom<u.top-this.y)?h:u;return this.y=(S.top+S.bottom)/2,this.scan(e,t,!0)}if(m&&!i){let{top:S,bottom:C}=y;if(h&&h.bottom>(S+S+C)/3)return this.y=h.bottom-1,this.scan(e,t,!0);if(u&&u.top<(S+C+C)/3)return this.y=u.top+1,this.scan(e,t,!0)}let x=(l?this.dirAt(e[p],1):this.baseDir)==Ce.LTR;return{i:p,after:this.x>(y.left+y.right)/2==x}}scanText(e,t){let i=[];for(let s=0;s<e.length;s=Ne(e.text,s))i.push(t+s);i.push(t+e.length);let n=this.scan(i,s=>{let o=i[s]-t,l=i[s+1]-t;return Dn(e.dom,o,l).getClientRects()});return n.after?new Kt(i[n.i+1],-1):new Kt(i[n.i],1)}scanTile(e,t){if(!e.length)return new Kt(t,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,t);if(l.isComposite())return this.scanTile(l,t)}let i=[t];for(let l=0,h=t;l<e.children.length;l++)i.push(h+=e.children[l].length);let n=this.scan(i,l=>{let h=e.children[l];return h.flags&48?null:(h.dom.nodeType==1?h.dom:Dn(h.dom,0,h.length)).getClientRects()}),s=e.children[n.i],o=i[n.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):n.after?new Kt(i[n.i+1],-1):new Kt(o,1)}}const Fi="";class ap{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(pe.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Fi}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let n=e;;){this.findPointBefore(i,n);let s=this.text.length;this.readNode(n);let o=Te.get(n),l=n.nextSibling;if(l==t){o?.breakAfter&&!l&&i!=this.view.contentDOM&&this.lineBreak();break}let h=Te.get(l);(o&&h?o.breakAfter:(o?o.breakAfter:vr(n))||vr(l)&&(n.nodeName!="BR"||o?.isWidget())&&this.text.length>s)&&!fp(l,t)&&this.lineBreak(),n=l}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=n.exec(t))&&(s=l.index,o=l[0].length),this.append(t.slice(i,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let h of this.points)h.node==e&&h.pos>this.text.length&&(h.pos-=o-1);i=s+o}}readNode(e){let t=Te.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let n=i.iter();!n.next().done;)n.lineBreak?this.lineBreak():this.append(n.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(hp(e,i.node,i.offset)?t:0))}}function hp(r,e,t){for(;;){if(!e||t<Xt(e))return!1;if(e==r)return!0;t=ci(e)+1,e=e.parentNode}}function fp(r,e){let t;for(;!(r==e||!r);r=r.nextSibling){let i=Te.get(r);if(!i?.isWidget())return!1;i&&(t||(t=[])).push(i)}if(t)for(let i of t){let n=i.overrideDOMText;if(n?.length)return!1}return!0}class oa{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class up{constructor(e,t,i,n){this.typeOver=n,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=xf(e.docView.tile,t,i,0))){let h=s||o?[]:dp(e),u=new ap(h,e);u.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=u.text,this.newSel=pp(h,this.bounds.from)}else{let h=e.observer.selectionRange,u=s&&s.node==h.focusNode&&s.offset==h.focusOffset||!Gs(e.contentDOM,h.focusNode)?l.main.head:e.docView.posFromDOM(h.focusNode,h.focusOffset),p=o&&o.node==h.anchorNode&&o.offset==h.anchorOffset||!Gs(e.contentDOM,h.anchorNode)?l.main.anchor:e.docView.posFromDOM(h.anchorNode,h.anchorOffset),m=e.viewport;if((_.ios||_.chrome)&&u!=p&&Math.min(u,p)<=l.main.from&&Math.max(u,p)>=l.main.to&&(m.from>0||m.to<e.state.doc.length)){let y=Math.min(u,p),x=Math.max(u,p),S=m.from-y,C=m.to-x;(S==0||S==1||y==0)&&(C==0||C==-1||x==e.state.doc.length)&&(u=0,p=e.state.doc.length)}if(e.inputState.composing>-1&&l.ranges.length>1)this.newSel=l.replaceRange(I.range(p,u));else if(e.lineWrapping&&p==u&&!(l.main.empty&&l.main.head==u)&&e.inputState.lastTouchTime>Date.now()-100){let y=e.coordsAtPos(u,-1),x=0;y&&(x=e.inputState.lastTouchY<=y.bottom?-1:1),this.newSel=I.create([I.cursor(u,x)])}else this.newSel=I.single(p,u)}}}function xf(r,e,t,i){if(r.isComposite()){let n=-1,s=-1,o=-1,l=-1;for(let h=0,u=i,p=i;h<r.children.length;h++){let m=r.children[h],y=u+m.length;if(u<e&&y>t)return xf(m,e,t,u);if(y>=e&&n==-1&&(n=h,s=u),u>t&&m.dom.parentNode==r.dom){o=h,l=p;break}p=y,u=y+m.breakAfter}return{from:s,to:l<0?i+r.length:l,startDOM:(n?r.children[n-1].dom.nextSibling:null)||r.dom.firstChild,endDOM:o<r.children.length&&o>=0?r.children[o].dom:null}}else return r.isText()?{from:i,to:i+r.length,startDOM:r.dom,endDOM:r.dom.nextSibling}:null}function wf(r,e){let t,{newSel:i}=e,{state:n}=r,s=n.selection.main,o=r.inputState.lastKeyTime>Date.now()-100?r.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:h}=e.bounds,u=s.from,p=null;(o===8||_.android&&e.text.length<h-l)&&(u=s.to,p="end");let m=n.doc.sliceString(l,h,Fi),y,x;!s.empty&&s.from>=l&&s.to<=h&&(e.typeOver||m!=e.text)&&m.slice(0,s.from-l)==e.text.slice(0,s.from-l)&&m.slice(s.to-l)==e.text.slice(y=e.text.length-(m.length-(s.to-l)))?t={from:s.from,to:s.to,insert:ce.of(e.text.slice(s.from-l,y).split(Fi))}:(x=bf(m,e.text,u-l,p))&&(_.chrome&&o==13&&x.toB==x.from+2&&e.text.slice(x.from,x.toB)==Fi+Fi&&x.toB--,t={from:l+x.from,to:l+x.toA,insert:ce.of(e.text.slice(x.from,x.toB).split(Fi))})}else i&&(!r.hasFocus&&n.facet(Gt)||wr(i,s))&&(i=null);if(!t&&!i)return!1;if((_.mac||_.android)&&t&&t.from==t.to&&t.from==s.head-1&&/^\. ?$/.test(t.insert.toString())&&r.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=I.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:ce.of([t.insert.toString().replace("."," ")])}):n.doc.lineAt(s.from).to<s.to&&r.docView.lineHasWidget(s.to)&&r.inputState.insertingTextAt>Date.now()-50?t={from:s.from,to:s.to,insert:n.toText(r.inputState.insertingText)}:_.chrome&&t&&t.from==t.to&&t.from==s.head&&t.insert.toString()==`
|
|
9
|
-
`&&r.lineWrapping&&(i&&(i=I.single(i.main.anchor-1,i.main.head-1)),t={from:s.from,to:s.to,insert:ce.of([" "])}),t)return No(r,t,i,o);if(i&&!wr(i,s)){let l=!1,h="select";return r.inputState.lastSelectionTime>Date.now()-50&&(r.inputState.lastSelectionOrigin=="select"&&(l=!0),h=r.inputState.lastSelectionOrigin,h=="select.pointer"&&(i=kf(n.facet(Hn).map(u=>u(r)),i))),r.dispatch({selection:i,scrollIntoView:l,userEvent:h}),!0}else return!1}function No(r,e,t,i=-1){if(_.ios&&r.inputState.flushIOSKey(e))return!0;let n=r.state.selection.main;if(_.android&&(e.to==n.to&&(e.from==n.from||e.from==n.from-1&&r.state.sliceDoc(e.from,n.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&ji(r.contentDOM,"Enter",13)||(e.from==n.from-1&&e.to==n.to&&e.insert.length==0||i==8&&e.insert.length<e.to-e.from&&e.to>n.head)&&ji(r.contentDOM,"Backspace",8)||e.from==n.from&&e.to==n.to+1&&e.insert.length==0&&ji(r.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();r.inputState.composing>=0&&r.inputState.composing++;let o,l=()=>o||(o=cp(r,e,t));return r.state.facet(of).some(h=>h(r,e.from,e.to,s,l))||r.dispatch(l()),!0}function cp(r,e,t){let i,n=r.state,s=n.selection.main,o=-1;if(e.from==e.to&&e.from<s.from||e.from>s.to){let h=e.from<s.from?-1:1,u=h<0?s.from:s.to,p=Cn(n.facet(Hn).map(m=>m(r)),u,h);e.from==p&&(o=p)}if(o>-1)i={changes:e,selection:I.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&r.inputState.composing<0){let h=s.from<e.from?n.sliceDoc(s.from,e.from):"",u=s.to>e.to?n.sliceDoc(e.to,s.to):"";i=n.replaceSelection(r.state.toText(h+e.insert.sliceString(0,void 0,r.state.lineBreak)+u))}else{let h=n.changes(e),u=t&&t.main.to<=h.newLength?t.main:void 0;if(n.selection.ranges.length>1&&(r.inputState.composing>=0||r.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let p=r.state.sliceDoc(e.from,e.to),m,y=t&&yf(r,t.main.head);if(y){let S=e.insert.length-(e.to-e.from);m={from:y.from,to:y.to-S}}else m=r.state.doc.lineAt(s.head);let x=s.to-e.to;i=n.changeByRange(S=>{if(S.from==s.from&&S.to==s.to)return{changes:h,range:u||S.map(h)};let C=S.to-x,O=C-p.length;if(r.state.sliceDoc(O,C)!=p||C>=m.from&&O<=m.to)return{range:S};let B=n.changes({from:O,to:C,insert:e.insert}),F=S.to-s.to;return{changes:B,range:u?I.range(Math.max(0,u.anchor+F),Math.max(0,u.head+F)):S.map(B)}})}else i={changes:h,selection:u&&n.selection.replaceRange(u)}}let l="input.type";return(r.composing||r.inputState.compositionPendingChange&&r.inputState.compositionEndedAt>Date.now()-50)&&(r.inputState.compositionPendingChange=!1,l+=".compose",r.inputState.compositionFirstChange&&(l+=".start",r.inputState.compositionFirstChange=!1)),n.update(i,{userEvent:l,scrollIntoView:!0})}function bf(r,e,t,i){let n=Math.min(r.length,e.length),s=0;for(;s<n&&r.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==n&&r.length==e.length)return null;let o=r.length,l=e.length;for(;o>0&&l>0&&r.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let h=Math.max(0,s-Math.min(o,l));t-=o+h-s}if(o<s&&r.length<e.length){let h=t<=s&&t>=o?s-t:0;s-=h,l=s+(l-o),o=s}else if(l<s){let h=t<=s&&t>=l?s-t:0;s-=h,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function dp(r){let e=[];if(r.root.activeElement!=r.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:n,focusOffset:s}=r.observer.selectionRange;return t&&(e.push(new oa(t,i)),(n!=t||s!=i)&&e.push(new oa(n,s))),e}function pp(r,e){if(r.length==0)return null;let t=r[0].pos,i=r.length==2?r[1].pos:t;return t>-1&&i>-1?I.single(t+e,i+e):null}function wr(r,e){return e.head==r.main.head&&e.anchor==r.main.anchor}class gp{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,_.safari&&e.contentDOM.addEventListener("input",()=>null),_.gecko&&Dp(e.contentDOM.ownerDocument)}handleEvent(e){!Cp(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let n of i.observers)n(this.view,t);for(let n of i.handlers){if(t.defaultPrevented)break;if(n(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=vp(e),i=this.handlers,n=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,l=i[s];l&&o!=!l.handlers.length&&(n.removeEventListener(s,this.handleEvent),l=null),l||n.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!t[s]&&n.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Cf.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),_.android&&_.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(_.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Sf.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||yp.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return t.shiftKey&&_.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&mp(this.view.win)&&(t.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||this.view.observer.pendingRecords().length||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,ji(this.view.contentDOM,t.key,t.keyCode,t.mods))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:_.safari&&!_.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function mp(r){return r.visualViewport?r.visualViewport.height*r.visualViewport.scale/r.document.documentElement.clientHeight<.85:!1}function la(r,e){return(t,i)=>{try{return e.call(r,i,t)}catch(n){$t(t.state,n)}}}function vp(r){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of r){let n=i.spec,s=n&&n.plugin.domEventHandlers,o=n&&n.plugin.domEventObservers;if(s)for(let l in s){let h=s[l];h&&t(l).handlers.push(la(i.value,h))}if(o)for(let l in o){let h=o[l];h&&t(l).observers.push(la(i.value,h))}}for(let i in Tt)t(i).handlers.push(Tt[i]);for(let i in nt)t(i).observers.push(nt[i]);return e}const Sf=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],yp="dthko",Cf=[16,17,18,20,91,92,224,225],Jn=6;function Gn(r){return Math.max(0,r)*.7+8}function kp(r,e){return Math.max(Math.abs(r.clientX-e.clientX),Math.abs(r.clientY-e.clientY))}class xp{constructor(e,t,i,n){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=$h(e.contentDOM),this.atoms=e.state.facet(Hn).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(pe.allowMultipleSelections)&&wp(e,t),this.dragging=Sp(e,t)&&Tf(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&kp(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,n=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:n,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let h=mf(this.view);e.clientX-h.left<=n+Jn?t=-Gn(n-e.clientX):e.clientX+h.right>=o-Jn&&(t=Gn(e.clientX-o)),e.clientY-h.top<=s+Jn?i=-Gn(s-e.clientY):e.clientY+h.bottom>=l-Jn&&(i=Gn(e.clientY-l)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=kf(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function wp(r,e){let t=r.state.facet(tf);return t.length?t[0](e):_.mac?e.metaKey:e.ctrlKey}function bp(r,e){let t=r.state.facet(nf);return t.length?t[0](e):_.mac?!e.altKey:!e.ctrlKey}function Sp(r,e){let{main:t}=r.state.selection;if(t.empty)return!1;let i=Ln(r.root);if(!i||i.rangeCount==0)return!0;let n=i.getRangeAt(0).getClientRects();for(let s=0;s<n.length;s++){let o=n[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Cp(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=r.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=Te.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}const Tt=Object.create(null),nt=Object.create(null),Af=_.ie&&_.ie_version<15||_.ios&&_.webkit_version<604;function Ap(r){let e=r.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{r.focus(),t.remove(),Mf(r,t.value)},50)}function $r(r,e,t){for(let i of r.facet(e))t=i(t,r);return t}function Mf(r,e){e=$r(r.state,Ro,e);let{state:t}=r,i,n=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(no!=null&&t.selection.ranges.every(h=>h.empty)&&no==s.toString()){let h=-1;i=t.changeByRange(u=>{let p=t.doc.lineAt(u.from);if(p.from==h)return{range:u};h=p.from;let m=t.toText((o?s.line(n++).text:e)+t.lineBreak);return{changes:{from:p.from,insert:m},range:I.cursor(u.from+m.length)}})}else o?i=t.changeByRange(h=>{let u=s.line(n++);return{changes:{from:h.from,to:h.to,insert:u.text},range:I.cursor(h.from+u.length)}}):i=t.replaceSelection(s);r.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}nt.scroll=r=>{let e=r.inputState;e.lastScrollTop=r.scrollDOM.scrollTop,e.lastScrollLeft=r.scrollDOM.scrollLeft,_.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};nt.wheel=nt.mousewheel=r=>{r.inputState.lastWheelEvent=Date.now()};Tt.keydown=(r,e)=>(r.inputState.setSelectionOrigin("select"),e.keyCode==27&&r.inputState.tabFocusMode!=0&&(r.inputState.tabFocusMode=Date.now()+2e3),!1);nt.touchstart=(r,e)=>{let t=r.inputState,i=e.targetTouches[0];t.touchActive=!0,t.lastTouchTime=Date.now(),i&&(t.lastTouchX=i.clientX,t.lastTouchY=i.clientY),t.setSelectionOrigin("select.pointer")};nt.touchmove=r=>{r.inputState.setSelectionOrigin("select.pointer")};nt.touchend=(r,e)=>{r.inputState.touchActive=!1};Tt.mousedown=(r,e)=>{if(r.observer.flush(),r.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of r.state.facet(rf))if(t=i(r,e),t)break;if(!t&&e.button==0&&(t=Tp(r,e)),t){let i=!r.hasFocus;r.inputState.startMouseSelection(new xp(r,e,t,i)),i&&r.observer.ignore(()=>{qh(r.contentDOM);let s=r.root.activeElement;s&&!s.contains(r.contentDOM)&&s.blur()});let n=r.inputState.mouseSelection;if(n)return n.start(e),n.dragging===!1}else r.inputState.setSelectionOrigin("select.pointer");return!1};function aa(r,e,t,i){if(i==1)return I.cursor(e,t);if(i==2)return ip(r.state,e,t);{let n=r.docView.lineAt(e,t),s=r.state.doc.lineAt(n?n.posAtEnd:e),o=n?n.posAtStart:s.from,l=n?n.posAtEnd:s.to;return l<r.state.doc.length&&l==s.to&&l++,I.undirectionalRange(o,l)}}const Mp=_.ie&&_.ie_version<=11;let ha=null,fa=0,ua=0;function Tf(r){if(!Mp)return r.detail;let e=ha,t=ua;return ha=r,ua=Date.now(),fa=!e||t>Date.now()-400&&Math.abs(e.clientX-r.clientX)<2&&Math.abs(e.clientY-r.clientY)<2?(fa+1)%3:1}function Tp(r,e){let t=r.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=Tf(e),n=r.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),n=n.map(s.changes))},get(s,o,l){let h=r.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),u,p=aa(r,h.pos,h.assoc,i);if(t.pos!=h.pos&&!o){let m=aa(r,t.pos,t.assoc,i),y=Math.min(m.from,p.from),x=Math.max(m.to,p.to);p=y<p.from?I.range(y,x,p.assoc):I.range(x,y,p.assoc)}return o?n.replaceRange(n.main.extend(p.from,p.to,p.assoc)):l&&i==1&&n.ranges.length>1&&(u=Op(n,h.pos))?u:l?n.addRange(p):I.create([p])}}}function Op(r,e){for(let t=0;t<r.ranges.length;t++){let{from:i,to:n}=r.ranges[t];if(i<=e&&n>=e)return I.create(r.ranges.slice(0,t).concat(r.ranges.slice(t+1)),r.mainIndex==t?0:r.mainIndex-(r.mainIndex>t?1:0))}return null}Tt.dragstart=(r,e)=>{let{selection:{main:t}}=r.state;if(e.target.draggable){let n=r.docView.tile.nearest(e.target);if(n&&n.isWidget()){let s=n.posAtStart,o=s+n.length;(s>=t.to||o<=t.from)&&(t=I.undirectionalRange(s,o))}}let{inputState:i}=r;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",$r(r.state,Eo,r.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Tt.dragend=r=>(r.inputState.draggedContent=null,!1);function ca(r,e,t,i){if(t=$r(r.state,Ro,t),!t)return;let n=r.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=r.inputState,o=i&&s&&bp(r,e)?{from:s.from,to:s.to}:null,l={from:n,insert:t},h=r.state.changes(o?[o,l]:l);r.focus(),r.dispatch({changes:h,selection:{anchor:h.mapPos(n,-1),head:h.mapPos(n,1)},userEvent:o?"move.drop":"input.drop"}),r.inputState.draggedContent=null}Tt.drop=(r,e)=>{if(!e.dataTransfer)return!1;if(r.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),n=0,s=()=>{++n==t.length&&ca(r,e,i.filter(o=>o!=null).join(r.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),s()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return ca(r,e,i,!0),!0}return!1};Tt.paste=(r,e)=>{if(r.state.readOnly)return!0;r.observer.flush();let t=Af?null:e.clipboardData;return t?(Mf(r,t.getData("text/plain")||t.getData("text/uri-list")),!0):(Ap(r),!1)};function Lp(r,e){let t=r.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),r.focus()},50)}function Bp(r){let e=[],t=[],i=!1;for(let n of r.selection.ranges)n.empty||(e.push(r.sliceDoc(n.from,n.to)),t.push(n));if(!e.length){let n=-1;for(let{from:s}of r.selection.ranges){let o=r.doc.lineAt(s);o.number>n&&(e.push(o.text),t.push({from:o.from,to:Math.min(r.doc.length,o.to+1)})),n=o.number}i=!0}return{text:$r(r,Eo,e.join(r.lineBreak)),ranges:t,linewise:i}}let no=null;Tt.copy=Tt.cut=(r,e)=>{if(!wn(r.contentDOM,r.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:n}=Bp(r.state);if(!t&&!n)return!1;no=n?t:null,e.type=="cut"&&!r.state.readOnly&&r.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=Af?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(Lp(r,t),!1)};const Of=Zt.define();function Lf(r,e){let t=[];for(let i of r.facet(lf)){let n=i(r,e);n&&t.push(n)}return t.length?r.update({effects:t,annotations:Of.of(!0)}):null}function Bf(r){setTimeout(()=>{let e=r.hasFocus;if(e!=r.inputState.notifiedFocused){let t=Lf(r.state,e);t?r.dispatch(t):r.update([])}},10)}nt.focus=r=>{r.inputState.lastFocusTime=Date.now(),!r.scrollDOM.scrollTop&&(r.inputState.lastScrollTop||r.inputState.lastScrollLeft)&&(r.scrollDOM.scrollTop=r.inputState.lastScrollTop,r.scrollDOM.scrollLeft=r.inputState.lastScrollLeft),Bf(r)};nt.blur=r=>{r.observer.clearSelectionRange(),Bf(r)};nt.compositionstart=nt.compositionupdate=r=>{if(!r.observer.editContext&&(r.inputState.compositionFirstChange==null&&(r.inputState.compositionFirstChange=!0),r.inputState.composing<0)){let{main:e}=r.state.selection;!e.empty&&r.lineBlockAt(e.from).from!=r.lineBlockAt(e.to).from&&r.dispatch({changes:r.state.selection.ranges.filter(t=>!t.empty).map(t=>({from:t.from,to:t.to})),userEvent:"input"}),r.inputState.composing=0}};nt.compositionend=r=>{r.observer.editContext||(r.inputState.composing=-1,r.inputState.compositionEndedAt=Date.now(),r.inputState.compositionPendingKey=!0,r.inputState.compositionPendingChange=r.observer.pendingRecords().length>0,r.inputState.compositionFirstChange=null,_.chrome&&_.android?r.observer.flushSoon():r.inputState.compositionPendingChange?Promise.resolve().then(()=>r.observer.flush()):setTimeout(()=>{r.inputState.composing<0&&r.docView.hasComposition&&r.update([])},50))};nt.contextmenu=r=>{r.inputState.lastContextMenu=Date.now()};Tt.beforeinput=(r,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(r.inputState.insertingText=e.data,r.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&r.observer.editContext){let s=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],h=r.posAtDOM(l.startContainer,l.startOffset),u=r.posAtDOM(l.endContainer,l.endOffset);return No(r,{from:h,to:u,insert:r.state.toText(s)},null),!0}}let n;if(_.chrome&&_.android&&(n=Sf.find(s=>s.inputType==e.inputType))&&(r.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let s=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&r.hasFocus&&(r.contentDOM.blur(),r.focus())},100)}return _.ios&&e.inputType=="deleteContentForward"&&r.observer.flushSoon(),_.safari&&e.inputType=="insertText"&&r.inputState.composing>=0&&setTimeout(()=>nt.compositionend(r,e),20),!1};const da=new Set;function Dp(r){da.has(r)||(da.add(r),r.addEventListener("copy",()=>{}),r.addEventListener("cut",()=>{}))}const pa=["pre-wrap","normal","pre-line","break-spaces"];let Zi=!1;function ga(){Zi=!1}class Rp{constructor(e){this.lineWrapping=e,this.doc=ce.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return pa.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let n=e[i];n<0?i++:this.heightSamples[Math.floor(n*10)]||(t=!0,this.heightSamples[Math.floor(n*10)]=!0)}return t}refresh(e,t,i,n,s,o){let l=pa.indexOf(e)>-1,h=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=n,this.lineLength=s,h){this.heightSamples={};for(let u=0;u<o.length;u++){let p=o[u];p<0?u++:this.heightSamples[Math.floor(p*10)]=!0}}return h}}class Ep{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class At{constructor(e,t,i,n,s){this.from=e,this.length=t,this.top=i,this.height=n,this._content=s}get type(){return typeof this._content=="number"?qe.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Mi?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new At(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var we=(function(r){return r[r.ByPos=0]="ByPos",r[r.ByHeight=1]="ByHeight",r[r.ByPosNoHeight=2]="ByPosNoHeight",r})(we||(we={}));const hr=.001;class it{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>hr&&(Zi=!0),this.height=e)}replace(e,t,i){return it.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,n){let s=this,o=i.doc;for(let l=n.length-1;l>=0;l--){let{fromA:h,toA:u,fromB:p,toB:m}=n[l],y=s.lineAt(h,we.ByPosNoHeight,i.setDoc(t),0,0),x=y.to>=u?y:s.lineAt(u,we.ByPosNoHeight,i,0,0);for(m+=x.to-u,u=x.to;l>0&&y.from<=n[l-1].toA;)h=n[l-1].fromA,p=n[l-1].fromB,l--,h<y.from&&(y=s.lineAt(h,we.ByPosNoHeight,i,0,0));p+=y.from-h,h=y.from;let S=Fo.build(i.setDoc(o),e,p,m);s=br(s,s.replace(h,u,S))}return s.updateHeight(i,0)}static empty(){return new ut(0,0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,n=0,s=0;for(;;)if(t==i)if(n>s*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,n-=l.size}else if(s>n*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,s-=l.size}else break;else if(n<s){let l=e[t++];l&&(n+=l.size)}else{let l=e[--i];l&&(s+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,i++),new Pp(it.of(e.slice(0,t)),o,it.of(e.slice(i)))}}function br(r,e){return r==e?r:(r.constructor!=e.constructor&&(Zi=!0),e)}it.prototype.size=1;const Ip=de.replace({});class Df extends it{constructor(e,t,i){super(e,t),this.deco=i,this.spaceAbove=0}mainBlock(e,t){return new At(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,i,n){return this.spaceAbove&&e<i+this.spaceAbove?new At(n,0,i,this.spaceAbove,Ip):this.mainBlock(i,n)}lineAt(e,t,i,n,s){let o=this.mainBlock(n,s);return this.spaceAbove?this.blockAt(0,i,n,s).join(o):o}forEachLine(e,t,i,n,s,o){e<=s+this.length&&t>=s&&o(this.lineAt(0,we.ByPos,i,n,s))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more&&this.setMeasuredHeight(n),this.outdated=!1,this}toString(){return`block(${this.length})`}}class ut extends Df{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new At(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let n=i[0];return i.length==1&&(n instanceof ut||n instanceof ze&&n.flags&4)&&Math.abs(this.length-n.length)<10?(n instanceof ze?n=new ut(n.length,this.height,this.spaceAbove):n.height=this.height,this.outdated||(n.outdated=!1),n):it.of(i)}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more?this.setMeasuredHeight(n):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class ze extends it{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,n=e.doc.lineAt(t+this.length).number,s=n-i+1,o,l=0;if(e.lineWrapping){let h=Math.min(this.height,e.lineHeight*s);o=h/s,this.length>s+1&&(l=(this.height-h)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:n,perLine:o,perChar:l}}blockAt(e,t,i,n){let{firstLine:s,lastLine:o,perLine:l,perChar:h}=this.heightMetrics(t,n);if(t.lineWrapping){let u=n+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),p=t.doc.lineAt(u),m=l+p.length*h,y=Math.max(i,e-m/2);return new At(p.from,p.length,y,m,0)}else{let u=Math.max(0,Math.min(o-s,Math.floor((e-i)/l))),{from:p,length:m}=t.doc.line(s+u);return new At(p,m,i+l*u,l,0)}}lineAt(e,t,i,n,s){if(t==we.ByHeight)return this.blockAt(e,i,n,s);if(t==we.ByPosNoHeight){let{from:x,to:S}=i.doc.lineAt(e);return new At(x,S-x,0,0,0)}let{firstLine:o,perLine:l,perChar:h}=this.heightMetrics(i,s),u=i.doc.lineAt(e),p=l+u.length*h,m=u.number-o,y=n+l*m+h*(u.from-s-m);return new At(u.from,u.length,Math.max(n,Math.min(y,n+this.height-p)),p,0)}forEachLine(e,t,i,n,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:l,perLine:h,perChar:u}=this.heightMetrics(i,s);for(let p=e,m=n;p<=t;){let y=i.doc.lineAt(p);if(p==e){let S=y.number-l;m+=h*S+u*(e-s-S)}let x=h+u*y.length;o(new At(y.from,y.length,m,x,0)),m+=x,p=y.to+1}}replace(e,t,i){let n=this.length-t;if(n>0){let s=i[i.length-1];s instanceof ze?i[i.length-1]=new ze(s.length+n):i.push(null,new ze(n-1))}if(e>0){let s=i[0];s instanceof ze?i[0]=new ze(e+s.length):i.unshift(new ze(e-1),null)}return it.of(i)}decomposeLeft(e,t){t.push(new ze(e-1),null)}decomposeRight(e,t){t.push(null,new ze(this.length-e-1))}updateHeight(e,t=0,i=!1,n){let s=t+this.length;if(n&&n.from<=t+this.length&&n.more){let o=[],l=Math.max(t,n.from),h=-1;for(n.from>t&&o.push(new ze(n.from-t-1).updateHeight(e,t));l<=s&&n.more;){let p=e.doc.lineAt(l).length;o.length&&o.push(null);let m=n.heights[n.index++],y=0;m<0&&(y=-m,m=n.heights[n.index++]),h==-1?h=m:Math.abs(m-h)>=hr&&(h=-2);let x=new ut(p,m,y);x.outdated=!1,o.push(x),l+=p+1}l<=s&&o.push(null,new ze(s-l).updateHeight(e,l));let u=it.of(o);return(h<0||Math.abs(u.height-this.height)>=hr||Math.abs(h-this.heightMetrics(e,t).perLine)>=hr)&&(Zi=!0),br(this,u)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Pp extends it{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,n){let s=i+this.left.height;return e<s?this.left.blockAt(e,t,i,n):this.right.blockAt(e,t,s,n+this.left.length+this.break)}lineAt(e,t,i,n,s){let o=n+this.left.height,l=s+this.left.length+this.break,h=t==we.ByHeight?e<o:e<l,u=h?this.left.lineAt(e,t,i,n,s):this.right.lineAt(e,t,i,o,l);if(this.break||(h?u.to<l:u.from>l))return u;let p=t==we.ByPosNoHeight?we.ByPosNoHeight:we.ByPos;return h?u.join(this.right.lineAt(l,p,i,o,l)):this.left.lineAt(l,p,i,n,s).join(u)}forEachLine(e,t,i,n,s,o){let l=n+this.left.height,h=s+this.left.length+this.break;if(this.break)e<h&&this.left.forEachLine(e,t,i,n,s,o),t>=h&&this.right.forEachLine(e,t,i,l,h,o);else{let u=this.lineAt(h,we.ByPos,i,n,s);e<u.from&&this.left.forEachLine(e,u.from-1,i,n,s,o),u.to>=e&&u.from<=t&&o(u),t>u.to&&this.right.forEachLine(u.to+1,t,i,l,h,o)}}replace(e,t,i){let n=this.left.length+this.break;if(t<n)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-n,t-n,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of i)s.push(l);if(e>0&&ma(s,o-1),t<this.length){let l=s.length;this.decomposeRight(t,s),ma(s,l)}return it.of(s)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,n=i+this.break;if(e>=n)return this.right.decomposeRight(e-n,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<n&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?it.of(this.break?[e,null,t]:[e,t]):(this.left=br(this.left,e),this.right=br(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,n){let{left:s,right:o}=this,l=t+s.length+this.break,h=null;return n&&n.from<=t+s.length&&n.more?h=s=s.updateHeight(e,t,i,n):s.updateHeight(e,t,i),n&&n.from<=l+o.length&&n.more?h=o=o.updateHeight(e,l,i,n):o.updateHeight(e,l,i),h?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function ma(r,e){let t,i;r[e]==null&&(t=r[e-1])instanceof ze&&(i=r[e+1])instanceof ze&&r.splice(e-1,3,new ze(t.length+1+i.length))}const Np=5;class Fo{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof ut?n.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new ut(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let o=t-e;i.block?this.addBlock(new Df(o,n,i)):(o||s||n>=Np)&&this.addLineDeco(n,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new ut(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new ze(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof ut)return e;let t=new ut(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,e),n.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof ut)&&!this.isCovered?this.nodes.push(new ut(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let n of this.nodes)n instanceof ut&&n.updateHeight(this.oracle,i),i+=n?n.length:1;return this.nodes}static build(e,t,i,n){let s=new Fo(i,e);return ue.spans(t,i,n,s,0),s.finish(i)}}function Fp(r,e,t){let i=new Hp;return ue.compare(r,e,t,i,0),i.changes}class Hp{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,n){(e<t||i&&i.heightRelevant||n&&n.heightRelevant)&&_i(e,t,this.changes,5)}}function Wp(r,e){let t=r.getBoundingClientRect(),i=r.ownerDocument,n=i.defaultView||window,s=Math.max(0,t.left),o=Math.min(n.innerWidth,t.right),l=Math.max(0,t.top),h=Math.min(n.innerHeight,t.bottom);for(let u=r.parentNode;u&&u!=i.body;)if(u.nodeType==1){let p=u,m=window.getComputedStyle(p);if((p.scrollHeight>p.clientHeight||p.scrollWidth>p.clientWidth)&&m.overflow!="visible"){let y=p.getBoundingClientRect();s=Math.max(s,y.left),o=Math.min(o,y.right),l=Math.max(l,y.top),h=Math.min(u==r.parentNode?n.innerHeight:h,y.bottom)}u=m.position=="absolute"||m.position=="fixed"?p.offsetParent:p.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,h)-(t.top+e)}}function Vp(r){let e=r.getBoundingClientRect(),t=r.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function Kp(r,e){let t=r.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class vs{constructor(e,t,i,n){this.from=e,this.to=t,this.size=i,this.displaySize=n}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let n=e[i],s=t[i];if(n.from!=s.from||n.to!=s.to||n.size!=s.size)return!1}return!0}draw(e,t){return de.replace({widget:new zp(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class zp extends pi{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class va{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=ya,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Ce.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let i=t.facet(Io).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new Rp(i),this.stateDeco=ka(t),this.heightMap=it.empty().applyChanges(this.stateDeco,ce.empty,this.heightOracle.setDoc(t.doc),[new vt(0,0,0,t.doc.length)]);for(let n=0;n<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());n++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=de.set(this.lineGaps.map(n=>n.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let n=i?t.head:t.anchor;if(!e.some(({from:s,to:o})=>n>=s&&n<=o)){let{from:s,to:o}=this.lineBlockAt(n);e.push(new Yn(s,o))}}return this.viewports=e.sort((i,n)=>i.from-n.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?ya:new Ho(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(mn(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=ka(this.state);let n=e.changedRanges,s=vt.extendWithRanges(n,Fp(i,this.stateDeco,e?e.changes:Ie.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ga(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||Zi)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let h=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<h.from||t.range.head>h.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,t));let u=h.from!=this.viewport.from||h.to!=this.viewport.to;this.viewport=h,e.flags|=this.updateForViewport(),(u||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(hf)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,i=window.getComputedStyle(t),n=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?Ce.RTL:Ce.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=t.getBoundingClientRect(),h=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let u=0,p=0;if(l.width&&l.height){let{scaleX:W,scaleY:V}=zh(t,l);(W>.005&&Math.abs(this.scaleX-W)>.005||V>.005&&Math.abs(this.scaleY-V)>.005)&&(this.scaleX=W,this.scaleY=V,u|=16,o=h=!0)}let m=(parseInt(i.paddingTop)||0)*this.scaleY,y=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=m||this.paddingBottom!=y)&&(this.paddingTop=m,this.paddingBottom=y,u|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(n.lineWrapping&&(h=!0),this.editorWidth=e.scrollDOM.clientWidth,u|=16);let x=$h(this.view.contentDOM,!1).y;x!=this.scrollParent&&(this.scrollParent=x,this.scrollAnchorHeight=-1,this.scrollOffset=0);let S=this.getScrollOffset();this.scrollOffset!=S&&(this.scrollAnchorHeight=-1,this.scrollOffset=S),this.scrolledToBottom=Uh(this.scrollParent||e.win);let C=(this.printing?Kp:Wp)(t,this.paddingTop),O=C.top-this.pixelViewport.top,B=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let F=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(F!=this.inView&&(this.inView=F,F&&(h=!0)),!this.inView&&!this.scrollTarget&&!Vp(e.dom))return 0;let P=l.width;if((this.contentDOMWidth!=P||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,u|=16),h){let W=e.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(W)&&(o=!0),o||n.lineWrapping&&Math.abs(P-this.contentDOMWidth)>n.charWidth){let{lineHeight:V,charWidth:N,textHeight:re}=e.docView.measureTextSize();o=V>0&&n.refresh(s,V,N,re,Math.max(5,P/N),W),o&&(e.docView.minWidth=0,u|=16)}O>0&&B>0?p=Math.max(O,B):O<0&&B<0&&(p=Math.min(O,B)),ga();for(let V of this.viewports){let N=V.from==this.viewport.from?W:e.docView.measureVisibleLineHeights(V);this.heightMap=(o?it.empty().applyChanges(this.stateDeco,ce.empty,this.heightOracle,[new vt(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new Ep(V.from,N))}Zi&&(u|=2)}let Q=!this.viewportIsAppropriate(this.viewport,p)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return Q&&(u&2&&(u|=this.updateScaler()),this.viewport=this.getViewport(p,this.scrollTarget),u|=this.updateForViewport()),(u&2||Q)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,h=new Yn(n.lineAt(o-i*1e3,we.ByHeight,s,0,0).from,n.lineAt(l+(1-i)*1e3,we.ByHeight,s,0,0).to);if(t){let{head:u}=t.range;if(u<h.from||u>h.to){let p=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),m=n.lineAt(u,we.ByPos,s,0,0),y;t.y=="center"?y=(m.top+m.bottom)/2-p/2:t.y=="start"||t.y=="nearest"&&u<h.from?y=m.top:y=m.bottom-p,h=new Yn(n.lineAt(y-1e3/2,we.ByHeight,s,0,0).from,n.lineAt(y+p+1e3/2,we.ByHeight,s,0,0).to)}}return h}mapViewport(e,t){let i=t.mapPos(e.from,-1),n=t.mapPos(e.to,1);return new Yn(this.heightMap.lineAt(i,we.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,we.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(e,we.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,we.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||n<=o-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||s>=l+Math.max(10,Math.min(i,250)))&&n>o-2*1e3&&s<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let n of e)t.touchesRange(n.from,n.to)||i.push(new vs(t.mapPos(n.from),t.mapPos(n.to),n.size,n.displaySize));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,s=n>>1,o=n<<1;if(this.defaultTextDirection!=Ce.LTR&&!i)return[];let l=[],h=(p,m,y,x)=>{if(m-p<s)return;let S=this.state.selection.main,C=[S.from];S.empty||C.push(S.to);for(let B of C)if(B>p&&B<m){h(p,B-10,y,x),h(B+10,m,y,x);return}let O=_p(e,B=>B.from>=y.from&&B.to<=y.to&&Math.abs(B.from-p)<s&&Math.abs(B.to-m)<s&&!C.some(F=>B.from<F&&B.to>F));if(!O){if(m<y.to&&t&&i&&t.visibleRanges.some(P=>P.from<=m&&P.to>=m)){let P=t.moveToLineBoundary(I.cursor(m),!1,!0).head;P>p&&(m=P)}let B=this.gapSize(y,p,m,x),F=i||B<2e6?B:2e6;O=new vs(p,m,B,F)}l.push(O)},u=p=>{if(p.length<o||p.type!=qe.Text)return;let m=$p(p.from,p.to,this.stateDeco);if(m.total<o)return;let y=this.scrollTarget?this.scrollTarget.range.head:null,x,S;if(i){let C=n/this.heightOracle.lineLength*this.heightOracle.lineHeight,O,B;if(y!=null){let F=Xn(m,y),P=((this.visibleBottom-this.visibleTop)/2+C)/p.height;O=F-P,B=F+P}else O=(this.visibleTop-p.top-C)/p.height,B=(this.visibleBottom-p.top+C)/p.height;x=Qn(m,O),S=Qn(m,B)}else{let C=m.total*this.heightOracle.charWidth,O=n*this.heightOracle.charWidth,B=0;if(C>2e6)for(let V of e)V.from>=p.from&&V.from<p.to&&V.size!=V.displaySize&&V.from*this.heightOracle.charWidth+B<this.pixelViewport.left&&(B=V.size-V.displaySize);let F=this.pixelViewport.left+B,P=this.pixelViewport.right+B,Q,W;if(y!=null){let V=Xn(m,y),N=((P-F)/2+O)/C;Q=V-N,W=V+N}else Q=(F-O)/C,W=(P+O)/C;x=Qn(m,Q),S=Qn(m,W)}x>p.from&&h(p.from,x,p,m),S<p.to&&h(S,p.to,p,m)};for(let p of this.viewportLines)Array.isArray(p.type)?p.type.forEach(u):u(p);return l}gapSize(e,t,i,n){let s=Xn(n,i)-Xn(n,t);return this.heightOracle.lineWrapping?e.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(e){vs.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=de.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];ue.spans(t,this.viewport.from,this.viewport.to,{span(s,o){i.push({from:s,to:o})},point(){}},20);let n=0;if(i.length!=this.visibleRanges.length)n=12;else for(let s=0;s<i.length&&!(n&8);s++){let o=this.visibleRanges[s],l=i[s];(o.from!=l.from||o.to!=l.to)&&(n|=4,e&&e.mapPos(o.from,-1)==l.from&&e.mapPos(o.to,1)==l.to||(n|=8))}return this.visibleRanges=i,n}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||mn(this.heightMap.lineAt(e,we.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||mn(this.heightMap.lineAt(this.scaler.fromDOM(e),we.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return mn(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Yn{constructor(e,t){this.from=e,this.to=t}}function $p(r,e,t){let i=[],n=r,s=0;return ue.spans(t,r,e,{span(){},point(o,l){o>n&&(i.push({from:n,to:o}),s+=o-n),n=l}},20),n<e&&(i.push({from:n,to:e}),s+=e-n),{total:s,ranges:i}}function Qn({total:r,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(r*t);for(let n=0;;n++){let{from:s,to:o}=e[n],l=o-s;if(i<=l)return s+i;i-=l}}function Xn(r,e){let t=0;for(let{from:i,to:n}of r.ranges){if(e<=n){t+=e-i;break}t+=n-i}return t/r.total}function _p(r,e){for(let t of r)if(e(t))return t}const ya={toDOM(r){return r},fromDOM(r){return r},scale:1,eq(r){return r==this}};function ka(r){let e=r.facet(Vr).filter(i=>typeof i!="function"),t=r.facet(Po).filter(i=>typeof i!="function");return t.length&&e.push(ue.join(t)),e}class Ho{constructor(e,t,i){let n=0,s=0,o=0;this.viewports=i.map(({from:l,to:h})=>{let u=t.lineAt(l,we.ByPos,e,0,0).top,p=t.lineAt(h,we.ByPos,e,0,0).bottom;return n+=p-u,{from:l,to:h,top:u,bottom:p,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(t.height-n);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let t=0,i=0,n=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return n+(e-i)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);i=s.bottom,n=s.domBottom}}fromDOM(e){for(let t=0,i=0,n=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return i+(e-n)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);i=s.bottom,n=s.domBottom}}eq(e){return e instanceof Ho?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,i)=>t.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}}function mn(r,e){if(e.scale==1)return r;let t=e.toDOM(r.top),i=e.toDOM(r.bottom);return new At(r.from,r.length,t,i-t,Array.isArray(r._content)?r._content.map(n=>mn(n,e)):r._content)}const Zn=j.define({combine:r=>r.join(" ")}),ro=j.define({combine:r=>r.indexOf(!0)>-1}),so=fi.newName(),Rf=fi.newName(),Ef=fi.newName(),If={"&light":"."+Rf,"&dark":"."+Ef};function oo(r,e,t){return new fi(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,n=>{if(n=="&")return r;if(!t||!t[n])throw new RangeError(`Unsupported selector: ${n}`);return t[n]}):r+" "+i}})}const jp=oo("."+so,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},If),qp={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},ys=_.ie&&_.ie_version<=11;class Up{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new bd,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(_.ie&&_.ie_version<=11||_.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&_.android&&e.constructor.EDIT_CONTEXT!==!1&&!(_.chrome&&_.chrome_version<126)&&(this.editContext=new Gp(e),e.state.facet(Gt)&&(e.contentDOM.editContext=this.editContext.editContext)),ys&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(Gt)?i.root.activeElement!=this.dom:!wn(this.dom,n))return;let s=n.anchorNode&&i.docView.tile.nearest(n.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(_.ie&&_.ie_version<=11||_.android&&_.chrome)&&!i.state.selection.main.empty&&n.focusNode&&Sn(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Ln(e.root);if(!t)return!1;let i=_.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Jp(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let n=wn(this.dom,i);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&Cd(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),n&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(i.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=t)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,qp),ys&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),ys&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;if(!this.delayedAndroidKey){let n=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&ji(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(n)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,n=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(n=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:n}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),n=this.selectionChanged&&wn(this.dom,this.selectionRange);if(e<0&&!n)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new up(this.view,e,t,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,n=wf(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!wr(this.view.state.selection,t.newSel.main))&&this.view.update([]),n}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let i=xa(t,e.previousSibling||e.target.previousSibling,-1),n=xa(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:n?t.posBefore(n):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Gt)!=e.state.facet(Gt)&&(e.view.contentDOM.editContext=e.state.facet(Gt)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function xa(r,e,t){for(;e;){let i=Te.get(e);if(i&&i.parent==r)return i;let n=e.parentNode;e=n!=r.dom?n:t>0?e.nextSibling:e.previousSibling}return null}function wa(r,e){let t=e.startContainer,i=e.startOffset,n=e.endContainer,s=e.endOffset,o=r.docView.domAtPos(r.state.selection.main.anchor,1);return Sn(o.node,o.offset,n,s)&&([t,i,n,s]=[n,s,t,i]),{anchorNode:t,anchorOffset:i,focusNode:n,focusOffset:s}}function Jp(r,e){if(e.getComposedRanges){let n=e.getComposedRanges(r.root)[0];if(n)return wa(r,n)}let t=null;function i(n){n.preventDefault(),n.stopImmediatePropagation(),t=n.getTargetRanges()[0]}return r.contentDOM.addEventListener("beforeinput",i,!0),r.dom.ownerDocument.execCommand("indent"),r.contentDOM.removeEventListener("beforeinput",i,!0),t?wa(r,t):null}class Gp{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let n=e.state.selection.main,{anchor:s,head:o}=n,l=this.toEditorPos(i.updateRangeStart),h=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let u=h-l>i.text.length;l==this.from&&s<this.from?l=s:h==this.to&&s>this.to&&(h=s);let p=bf(e.state.sliceDoc(l,h),i.text,(u?n.from:n.to)-l,u?"end":null);if(!p){let y=I.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));wr(y,n)||e.dispatch({selection:y,userEvent:"select"});return}let m={from:p.from+l,to:p.toA+l,insert:ce.of(i.text.slice(p.from,p.toB).split(`
|
|
10
|
-
`))};if((_.mac||_.android)&&m.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(m={from:l,to:h,insert:ce.of([i.text.replace("."," ")])}),this.pendingContextChange=m,!e.state.readOnly){let y=this.to-this.from+(m.to-m.from+m.insert.length);No(e,m,I.single(this.toEditorPos(i.selectionStart,y),this.toEditorPos(i.selectionEnd,y)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),m.from<m.to&&!m.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let n=[],s=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o<l;o++){let h=e.coordsForChar(o);s=h&&new DOMRect(h.left,h.top,h.right-h.left,h.bottom-h.top)||s||new DOMRect,n.push(s)}t.updateCharacterBounds(i.rangeStart,n)},this.handlers.textformatupdate=i=>{let n=[];for(let s of i.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let h=this.toEditorPos(s.rangeStart),u=this.toEditorPos(s.rangeEnd);if(h<u){let p=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;n.push(de.mark({attributes:{style:p}}).range(h,u))}}}e.dispatch({effects:uf.of(de.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let n=Ln(i.root);n&&n.rangeCount&&this.editContext.updateSelectionBounds(n.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,n=this.pendingContextChange;return e.changes.iterChanges((s,o,l,h,u)=>{if(i)return;let p=u.length-(o-s);if(n&&o>=n.to)if(n.from==s&&n.to==o&&n.insert.eq(u)){n=this.pendingContextChange=null,t+=p,this.to+=p;return}else n=null,this.revertPending(e.state);if(s+=t,o+=t,o<=this.from)this.from+=p,this.to+=p;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+u.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),u.toString()),this.to+=p}t+=p}),n&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(n=>!n.isUserEvent("input.type")&&n.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),n=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=n)&&this.editContext.updateSelection(i,n)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class G{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.clearAnnouncement=-1,this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(n=>n.forEach(s=>i(s,this)))||(n=>this.update(n)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Sd(e.parent)||document,this.viewState=new va(this,e.state||pe.create(e)),e.scrollTo&&e.scrollTo.is(Un)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Vi).map(n=>new cs(n));for(let n of this.plugins)n.update(this);this.observer=new Up(this),this.inputState=new gp(this),this.inputState.ensureHandlers(this.plugins),this.docView=new ra(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof Ee?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,n,s=this.state;for(let y of e){if(y.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=y.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,h=null;e.some(y=>y.annotation(Of))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,h=Lf(s,o),h||(l=1));let u=this.observer.delayedAndroidKey,p=null;if(u?(this.observer.clearDelayedAndroidKey(),p=this.observer.readChange(),(p&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(p=null)):this.observer.clear(),s.facet(pe.phrases)!=this.state.facet(pe.phrases))return this.setState(s);n=yr.create(this,s,e),n.flags|=l;let m=this.viewState.scrollTarget;try{this.updateState=2;for(let y of e){if(m&&(m=m.map(y.changes)),y.scrollIntoView){let{main:x}=y.state.selection,{x:S,y:C}=this.state.facet(G.cursorScrollMargin);m=new qi(x.empty?x:I.cursor(x.head,x.head>x.anchor?-1:1),"nearest","nearest",C,S)}for(let x of y.effects)x.is(Un)&&(m=x.value.clip(this.state))}this.viewState.update(n,m),this.bidiCache=Sr.update(this.bidiCache,n.changes),n.empty||(this.updatePlugins(n),this.inputState.update(n)),t=this.docView.update(n),this.state.facet(gn)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(y=>y.isUserEvent("select.pointer")))}finally{this.updateState=0}if(n.startState.facet(Zn)!=n.state.facet(Zn)&&(this.viewState.mustMeasureContent=!0),(t||i||m||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!n.empty)for(let y of this.state.facet(Zs))try{y(n)}catch(x){$t(this.state,x,"update listener")}(h||p)&&Promise.resolve().then(()=>{h&&this.state==h.startState&&this.dispatch(h),p&&!wf(this,p)&&u.force&&ji(this.contentDOM,u.key,u.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new va(this,e),this.plugins=e.facet(Vi).map(i=>new cs(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new ra(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Vi),i=e.state.facet(Vi);if(t!=i){let n=[];for(let s of i){let o=t.indexOf(s);if(o<0)n.push(new cs(s));else{let l=this.plugins[o];l.mustUpdate=e,n.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let n of this.plugins)n.mustUpdate=e;for(let n=0;n<this.plugins.length;n++)this.plugins[n].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(i){$t(this.state,i,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.viewState.scrollParent,n=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o,scaleY:l}=this.viewState;Math.abs(n-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let h=0;;h++){if(o<0){if(Uh(i||this.win))s=-1,o=this.viewState.heightMap.height/this.viewState.scaleY;else{let S=this.viewState.scrollAnchorAt(n);s=S.from,o=S.top}l=this.viewState.scaleY}this.updateState=1;let u=this.viewState.measure();if(!u&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(h>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let p=[];u&4||([this.measureRequests,p]=[p,this.measureRequests]);let m=p.map(S=>{try{return S.read(this)}catch(C){return $t(this.state,C),ba}}),y=yr.create(this,this.state,[]),x=!1;y.flags|=u,t?t.flags|=u:t=y,this.updateState=2,y.empty||(this.updatePlugins(y),this.inputState.update(y),this.updateAttrs(),x=this.docView.update(y),x&&this.docViewUpdate());for(let S=0;S<p.length;S++)if(m[S]!=ba)try{let C=p[S];C.write&&C.write(m[S],this)}catch(C){$t(this.state,C)}if(x&&this.docView.updateSelection(!0),!y.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let C=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)/this.viewState.scaleY-o/l;if((C>1||C<-1)&&!(_.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){n=n+C,i?s<0?i.scrollTop=i.scrollHeight:i.scrollTop+=C:this.win.scrollBy(0,C),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let h of this.state.facet(Zs))h(t)}get themeClasses(){return so+" "+(this.state.facet(ro)?Ef:Rf)+" "+this.state.facet(Zn)}updateAttrs(){let e=Sa(this,cf,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Gt)?"true":"false",class:"cm-content",style:`${_.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Sa(this,Io,t);let i=this.observer.ignore(()=>{let n=Xl(this.contentDOM,this.contentAttrs,t),s=Xl(this.dom,this.editorAttrs,e);return n||s});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let n of i.effects)if(n.is(G.announce)){t&&(this.announceDOM.textContent="",this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout(()=>{this.announceDOM.textContent=" "},200),t=!1);let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=n.value}}mountStyles(){this.styleModules=this.state.facet(gn);let e=this.state.facet(G.cspNonce);fi.mount(this.root,this.styleModules.concat(jp).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return ms(this,e,sa(this,e,t,i))}moveByGroup(e,t){return ms(this,e,sa(this,e,t,i=>sp(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),n=this.textDirectionAt(e.from),s=i[t?i.length-1:0];return I.cursor(s.side(t,n)+e.from,s.forward(!t,n)?1:-1)}moveToLineBoundary(e,t,i=!0){return rp(this,e,t,i)}moveVertically(e,t,i){return ms(this,e,op(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=io(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),io(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.state.doc.lineAt(e),n=this.bidiSpans(i),s=n[zt.find(n,e-i.from,-1,t)];return this.docView.coordsAt(e,t,s.dir==Ce.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(af)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Yp)return Zh(e.length);let t=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||Xh(s.isolates,i=ta(this,e))))return s.order;i||(i=ta(this,e));let n=Dd(e.text,t,i);return this.bidiCache.push(new Sr(e.from,e.to,t,i,!0,n)),n}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||_.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{qh(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.win.clearTimeout(this.clearAnnouncement),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var i,n,s,o;return Un.of(new qi(typeof e=="number"?I.cursor(e):e,(i=t.y)!==null&&i!==void 0?i:"nearest",(n=t.x)!==null&&n!==void 0?n:"nearest",(s=t.yMargin)!==null&&s!==void 0?s:5,(o=t.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return Un.of(new qi(I.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return wt.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return wt.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=fi.newName(),n=[Zn.of(i),gn.of(oo(`.${i}`,e))];return t&&t.dark&&n.push(ro.of(!0)),n}static baseTheme(e){return rn.lowest(gn.of(oo("."+so,e,If)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),n=i&&Te.get(i)||Te.get(e);return((t=n?.root)===null||t===void 0?void 0:t.view)||null}}G.styleModule=gn;G.inputHandler=of;G.clipboardInputFilter=Ro;G.clipboardOutputFilter=Eo;G.scrollHandler=ff;G.focusChangeEffect=lf;G.perLineTextDirection=af;G.exceptionSink=sf;G.updateListener=Zs;G.editable=Gt;G.mouseSelectionStyle=rf;G.dragMovesSelection=nf;G.clickAddsSelectionRange=tf;G.decorations=Vr;G.blockWrappers=df;G.outerDecorations=Po;G.atomicRanges=Hn;G.bidiIsolatedRanges=pf;G.cursorScrollMargin=j.define({combine:r=>{let e=5,t=5;for(let i of r)typeof i=="number"?e=t=i:{x:e,y:t}=i;return{x:e,y:t}}});G.scrollMargins=gf;G.darkTheme=ro;G.cspNonce=j.define({combine:r=>r.length?r[0]:""});G.contentAttributes=Io;G.editorAttributes=cf;G.lineWrapping=G.contentAttributes.of({class:"cm-lineWrapping"});G.announce=me.define();const Yp=4096,ba={};class Sr{constructor(e,t,i,n,s,o){this.from=e,this.to=t,this.dir=i,this.isolates=n,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let i=[],n=e.length?e[e.length-1].dir:Ce.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==n&&!t.touchesRange(o.from,o.to)&&i.push(new Sr(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function Sa(r,e,t){for(let i=r.state.facet(e),n=i.length-1;n>=0;n--){let s=i[n],o=typeof s=="function"?s(r):s;o&&Lo(o,t)}return t}const Qp=_.mac?"mac":_.windows?"win":_.linux?"linux":"key";function Xp(r,e){const t=r.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let n,s,o,l;for(let h=0;h<t.length-1;++h){const u=t[h];if(/^(cmd|meta|m)$/i.test(u))l=!0;else if(/^a(lt)?$/i.test(u))n=!0;else if(/^(c|ctrl|control)$/i.test(u))s=!0;else if(/^s(hift)?$/i.test(u))o=!0;else if(/^mod$/i.test(u))e=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+u)}return n&&(i="Alt-"+i),s&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function er(r,e,t){return e.altKey&&(r="Alt-"+r),e.ctrlKey&&(r="Ctrl-"+r),e.metaKey&&(r="Meta-"+r),t!==!1&&e.shiftKey&&(r="Shift-"+r),r}const Zp=rn.default(G.domEventHandlers({keydown(r,e){return Ff(Nf(e.state),r,e,"editor")}})),Pf=j.define({enables:Zp}),Ca=new WeakMap;function Nf(r){let e=r.facet(Pf),t=Ca.get(e);return t||Ca.set(e,t=tg(e.reduce((i,n)=>i.concat(n),[]))),t}function Pi(r,e,t){return Ff(Nf(r.state),e,r,t)}let oi=null;const eg=4e3;function tg(r,e=Qp){let t=Object.create(null),i=Object.create(null),n=(o,l)=>{let h=i[o];if(h==null)i[o]=l;else if(h!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,h,u,p)=>{var m,y;let x=t[o]||(t[o]=Object.create(null)),S=l.split(/ (?!$)/).map(B=>Xp(B,e));for(let B=1;B<S.length;B++){let F=S.slice(0,B).join(" ");n(F,!0),x[F]||(x[F]={preventDefault:!0,stopPropagation:!1,run:[P=>{let Q=oi={view:P,prefix:F,scope:o};return setTimeout(()=>{oi==Q&&(oi=null)},eg),!0}]})}let C=S.join(" ");n(C,!1);let O=x[C]||(x[C]={preventDefault:!1,stopPropagation:!1,run:((y=(m=x._any)===null||m===void 0?void 0:m.run)===null||y===void 0?void 0:y.slice())||[]});h&&O.run.push(h),u&&(O.preventDefault=!0),p&&(O.stopPropagation=!0)};for(let o of r){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let u of l){let p=t[u]||(t[u]=Object.create(null));p._any||(p._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:m}=o;for(let y in p)p[y].run.push(x=>m(x,lo))}let h=o[e]||o.key;if(h)for(let u of l)s(u,h,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(u,"Shift-"+h,o.shift,o.preventDefault,o.stopPropagation)}return t}let lo=null;function Ff(r,e,t,i){lo=e;let n=md(e),s=Ah(n,0),o=Mh(s)==n.length&&n!=" ",l="",h=!1,u=!1,p=!1;oi&&oi.view==t&&oi.scope==i&&(l=oi.prefix+" ",Cf.indexOf(e.keyCode)<0&&(u=!0,oi=null));let m=new Set,y=O=>{if(O){for(let B of O.run)if(!m.has(B)&&(m.add(B),B(t)))return O.stopPropagation&&(p=!0),!0;O.preventDefault&&(O.stopPropagation&&(p=!0),u=!0)}return!1},x=r[i],S,C;return x&&(y(x[l+er(n,e,!o)])?h=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(_.windows&&e.ctrlKey&&e.altKey)&&!(_.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(S=ui[e.keyCode])&&S!=n?(y(x[l+er(S,e,!0)])||e.shiftKey&&(C=Tn[e.keyCode])!=n&&C!=S&&y(x[l+er(C,e,!1)]))&&(h=!0):o&&e.shiftKey&&y(x[l+er(n,e,!0)])&&(h=!0),!h&&y(x._any)&&(h=!0)),u&&(h=!0),h&&p&&e.stopPropagation(),lo=null,h}class Ai{constructor(e,t,i,n,s){this.className=e,this.left=t,this.top=i,this.width=n,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let n=e.coordsAtPos(i.head,i.assoc||1);if(!n)return[];let s=Hf(e);return[new Ai(t,n.left-s.left,n.top-s.top,null,n.bottom-n.top)]}else return ig(e,t,i)}}function Hf(r){let e=r.scrollDOM.getBoundingClientRect();return{left:(r.textDirection==Ce.LTR?e.left:e.right-r.scrollDOM.clientWidth*r.scaleX)-r.scrollDOM.scrollLeft*r.scaleX,top:e.top-r.scrollDOM.scrollTop*r.scaleY}}function Aa(r,e,t,i){let n=r.coordsAtPos(e,t*2);if(!n)return i;let s=r.dom.getBoundingClientRect(),o=(n.top+n.bottom)/2,l=r.posAtCoords({x:s.left+1,y:o}),h=r.posAtCoords({x:s.right-1,y:o});return l==null||h==null?i:{from:Math.max(i.from,Math.min(l,h)),to:Math.min(i.to,Math.max(l,h))}}function ig(r,e,t){if(t.to<=r.viewport.from||t.from>=r.viewport.to)return[];let i=Math.max(t.from,r.viewport.from),n=Math.min(t.to,r.viewport.to),s=r.textDirection==Ce.LTR,o=r.contentDOM,l=o.getBoundingClientRect(),h=Hf(r),u=o.querySelector(".cm-line"),p=u&&window.getComputedStyle(u),m=l.left+(p?parseInt(p.paddingLeft)+Math.min(0,parseInt(p.textIndent)):0),y=l.right-(p?parseInt(p.paddingRight):0),x=to(r,i,1),S=to(r,n,-1),C=x.type==qe.Text?x:null,O=S.type==qe.Text?S:null;if(C&&(r.lineWrapping||x.widgetLineBreaks)&&(C=Aa(r,i,1,C)),O&&(r.lineWrapping||S.widgetLineBreaks)&&(O=Aa(r,n,-1,O)),C&&O&&C.from==O.from&&C.to==O.to)return F(P(t.from,t.to,C));{let W=C?P(t.from,null,C):Q(x,!1),V=O?P(null,t.to,O):Q(S,!0),N=[];return(C||x).to<(O||S).from-(C&&O?1:0)||x.widgetLineBreaks>1&&W.bottom+r.defaultLineHeight/2<V.top?N.push(B(m,W.bottom,y,V.top)):W.bottom<V.top&&r.elementAtHeight((W.bottom+V.top)/2).type==qe.Text&&(W.bottom=V.top=(W.bottom+V.top)/2),F(W).concat(N).concat(F(V))}function B(W,V,N,re){return new Ai(e,W-h.left,V-h.top,Math.max(0,N-W),re-V)}function F({top:W,bottom:V,horizontal:N}){let re=[];for(let oe=0;oe<N.length;oe+=2)re.push(B(N[oe],W,N[oe+1],V));return re}function P(W,V,N){let re=1e9,oe=-1e9,ae=[];function Z(fe,ge,Fe,De,z){let Re=r.coordsAtPos(fe,fe==N.to?-2:2),Ue=r.coordsAtPos(Fe,Fe==N.from?2:-2);!Re||!Ue||(re=Math.min(Re.top,Ue.top,re),oe=Math.max(Re.bottom,Ue.bottom,oe),z==Ce.LTR?ae.push(s&&ge?m:Re.left,s&&De?y:Ue.right):ae.push(!s&&De?m:Ue.left,!s&&ge?y:Re.right))}let Y=W??N.from,ee=V??N.to;for(let fe of r.visibleRanges)if(fe.to>Y&&fe.from<ee)for(let ge=Math.max(fe.from,Y),Fe=Math.min(fe.to,ee);;){let De=r.state.doc.lineAt(ge);for(let z of r.bidiSpans(De)){let Re=z.from+De.from,Ue=z.to+De.from;if(Re>=Fe)break;Ue>ge&&Z(Math.max(Re,ge),W==null&&Re<=Y,Math.min(Ue,Fe),V==null&&Ue>=ee,z.dir)}if(ge=De.to+1,ge>=Fe)break}return ae.length==0&&Z(Y,W==null,ee,V==null,r.textDirection),{top:re,bottom:oe,horizontal:ae}}function Q(W,V){let N=l.top+(V?W.top:W.bottom);return{top:N,bottom:N,horizontal:[]}}}function ng(r,e){return r.constructor==e.constructor&&r.eq(e)}class rg{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(fr)!=e.state.facet(fr)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(fr);for(;t<i.length&&i[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,i)=>!ng(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let n of e)n.update&&t&&n.constructor&&this.drawn[i].constructor&&n.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(n.draw(),t);for(;t;){let n=t.nextSibling;t.remove(),t=n}this.drawn=e,_.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const fr=j.define();function Wf(r){return[wt.define(e=>new rg(e,r)),fr.of(r)]}const Li=j.define({combine(r){return Fr(r,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function Vv(r={}){return[Li.of(r),og,lg,hg,hf.of(!0)]}function sg(r){return r.facet(Li)}function Vf(r){return r.startState.facet(Li)!=r.state.facet(Li)}const og=Wf({above:!0,markers(r){let{state:e}=r,t=e.facet(Li),i=[];for(let n of e.selection.ranges){let s=n==e.selection.main;if(n.empty||t.drawRangeCursor&&!(s&&_.ios&&t.iosSelectionHandles)){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=n.empty?n:I.cursor(n.head,n.assoc);for(let h of Ai.forRange(r,o,l))i.push(h)}}return i},update(r,e){r.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Vf(r);return t&&Ma(r.state,e),r.docChanged||r.selectionSet||t},mount(r,e){Ma(e.state,r)},class:"cm-cursorLayer"});function Ma(r,e){e.style.animationDuration=r.facet(Li).cursorBlinkRate+"ms"}const lg=Wf({above:!1,markers(r){let e=[],{main:t,ranges:i}=r.state.selection;for(let n of i)if(!n.empty)for(let s of Ai.forRange(r,"cm-selectionBackground",n))e.push(s);if(_.ios&&!t.empty&&r.state.facet(Li).iosSelectionHandles){for(let n of Ai.forRange(r,"cm-selectionHandle cm-selectionHandle-start",I.cursor(t.from,1)))e.push(n);for(let n of Ai.forRange(r,"cm-selectionHandle cm-selectionHandle-end",I.cursor(t.to,1)))e.push(n)}return e},update(r,e){return r.docChanged||r.selectionSet||r.viewportChanged||Vf(r)},class:"cm-selectionLayer"}),ag=_.gecko&&_.gecko_version==153?"#ffffff01":"transparent",hg=rn.highest(G.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${ag} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));class fg extends pi{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?bn(e.firstChild):[];if(!t.length)return null;let i=window.getComputedStyle(e.parentNode),n=Bn(t[0],i.direction!="rtl"),s=parseInt(i.lineHeight);return n.bottom-n.top>s*1.5?{left:n.left,right:n.right,top:n.top,bottom:n.top+s}:n}ignoreEvent(){return!1}}function Kv(r){return[wt.fromClass(class{constructor(t){this.view=t,this.placeholder=de.set([de.widget({widget:new fg(r),side:1}).range(0)])}get decorations(){return this.view.state.doc.length?de.none:this.placeholder}},{decorations:t=>t.decorations}),G.contentAttributes.of({"aria-placeholder":r})]}const Ta=j.define({combine(r){let e,t;for(let i of r)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}}),ug=wt.fromClass(class{constructor(r){this.input=r.state.facet(Cr),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(r));let e=r.state.facet(Ta);this.top=new tr(r,!0,e.topContainer),this.bottom=new tr(r,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(r){let e=r.state.facet(Ta);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new tr(r.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new tr(r.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=r.state.facet(Cr);if(t!=this.input){let i=t.filter(h=>h),n=[],s=[],o=[],l=[];for(let h of i){let u=this.specs.indexOf(h),p;u<0?(p=h(r.view),l.push(p)):(p=this.panels[u],p.update&&p.update(r)),n.push(p),(p.top?s:o).push(p)}this.specs=i,this.panels=n,this.top.sync(s),this.bottom.sync(o);for(let h of l)h.dom.classList.add("cm-panel"),h.mount&&h.mount()}else for(let i of this.panels)i.update&&i.update(r)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:r=>G.scrollMargins.of(e=>{let t=e.plugin(r);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class tr{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=Oa(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Oa(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function Oa(r){let e=r.nextSibling;return r.remove(),e}const Cr=j.define({enables:ug});class Bi extends hi{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Bi.prototype.elementClass="";Bi.prototype.toDOM=void 0;Bi.prototype.mapMode=_e.TrackBefore;Bi.prototype.startSide=Bi.prototype.endSide=-1;Bi.prototype.point=!0;const ks=j.define(),cg=j.define(),ur=j.define(),La=j.define({combine:r=>r.some(e=>e)});function dg(r){return[pg]}const pg=wt.fromClass(class{constructor(r){this.view=r,this.domAfter=null,this.prevViewport=r.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=r.state.facet(ur).map(e=>new Da(r,e)),this.fixed=!r.state.facet(La);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),r.scrollDOM.insertBefore(this.dom,r.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(r){if(this.updateGutters(r)){let e=this.prevViewport,t=r.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(r.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(La)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=r.view.viewport}syncGutters(r){let e=this.dom.nextSibling;r&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=ue.iter(this.view.state.facet(ks),this.view.viewport.from),i=[],n=this.gutters.map(s=>new gg(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let o=!0;for(let l of s.type)if(l.type==qe.Text&&o){ao(t,i,l.from);for(let h of n)h.line(this.view,l,i);o=!1}else if(l.widget)for(let h of n)h.widget(this.view,l)}else if(s.type==qe.Text){ao(t,i,s.from);for(let o of n)o.line(this.view,s,i)}else if(s.widget)for(let o of n)o.widget(this.view,s);for(let s of n)s.finish();r&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(r){let e=r.startState.facet(ur),t=r.state.facet(ur),i=r.docChanged||r.heightChanged||r.viewportChanged||!ue.eq(r.startState.facet(ks),r.state.facet(ks),r.view.viewport.from,r.view.viewport.to);if(e==t)for(let n of this.gutters)n.update(r)&&(i=!0);else{i=!0;let n=[];for(let s of t){let o=e.indexOf(s);o<0?n.push(new Da(this.view,s)):(this.gutters[o].update(r),n.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),n.indexOf(s)<0&&s.destroy();for(let s of n)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=n}return i}destroy(){for(let r of this.gutters)r.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:r=>G.scrollMargins.of(e=>{let t=e.plugin(r);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,n=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Ce.LTR?{left:i,right:n}:{right:i,left:n}})});function Ba(r){return Array.isArray(r)?r:[r]}function ao(r,e,t){for(;r.value&&r.from<=t;)r.from==t&&e.push(r.value),r.next()}class gg{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=ue.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:n}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==n.elements.length){let l=new Kf(e,o,s,i);n.elements.push(l),n.dom.appendChild(l.dom)}else n.elements[this.i].update(e,o,s,i);this.height=t.bottom,this.i++}line(e,t,i){let n=[];ao(this.cursor,n,t.from),i.length&&(n=n.concat(i));let s=this.gutter.config.lineMarker(e,t,n);s&&n.unshift(s);let o=this.gutter;n.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,n)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),n=i?[i]:null;for(let s of e.state.facet(cg)){let o=s(e,t.widget,t);o&&(n||(n=[])).push(o)}n&&this.addElement(e,t,n)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Da{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,n=>{let s=n.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let h=s.getBoundingClientRect();o=(h.top+h.bottom)/2}else o=n.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,n)&&n.preventDefault()});this.markers=Ba(t.markers(e)),t.initialSpacer&&(this.spacer=new Kf(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=Ba(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let n=this.config.updateSpacer(this.spacer.markers[0],e);n!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[n])}let i=e.view.viewport;return!ue.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Kf{constructor(e,t,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,n)}update(e,t,i,n){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),mg(this.markers,n)||this.setMarkers(e,n)}setMarkers(e,t){let i="cm-gutterElement",n=this.dom.firstChild;for(let s=0,o=0;;){let l=o,h=s<t.length?t[s++]:null,u=!1;if(h){let p=h.elementClass;p&&(i+=" "+p);for(let m=o;m<this.markers.length;m++)if(this.markers[m].compare(h)){l=m,u=!0;break}}else l=this.markers.length;for(;o<l;){let p=this.markers[o++];if(p.toDOM){p.destroy(n);let m=n.nextSibling;n.remove(),n=m}}if(!h)break;h.toDOM&&(u?n=n.nextSibling:this.dom.insertBefore(h.toDOM(e),n)),u&&o++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}}function mg(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(!r[t].compare(e[t]))return!1;return!0}const vg=j.define(),yg=j.define(),Ki=j.define({combine(r){return Fr(r,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let n in t){let s=i[n],o=t[n];i[n]=s?(l,h,u)=>s(l,h,u)||o(l,h,u):o}return i}})}});class xs extends Bi{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function ws(r,e){return r.state.facet(Ki).formatNumber(e,r.state)}const kg=ur.compute([Ki],r=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(vg)},lineMarker(e,t,i){return i.some(n=>n.toDOM)?null:new xs(ws(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let n of e.state.facet(yg)){let s=n(e,t,i);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(Ki)!=e.state.facet(Ki),initialSpacer(e){return new xs(ws(e,Ra(e.state.doc.lines)))},updateSpacer(e,t){let i=ws(t.view,Ra(t.view.state.doc.lines));return i==e.number?e:new xs(i)},domEventHandlers:r.facet(Ki).domEventHandlers,side:"before"}));function zv(r={}){return[Ki.of(r),dg(),kg]}function Ra(r){let e=9;for(;e<r;)e=e*10+9;return e}const zf=1024;let xg=0;class yt{constructor(e,t){this.from=e,this.to=t}}class se{constructor(e={}){this.id=xg++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=rt.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}se.closedBy=new se({deserialize:r=>r.split(" ")});se.openedBy=new se({deserialize:r=>r.split(" ")});se.group=new se({deserialize:r=>r.split(" ")});se.isolate=new se({deserialize:r=>{if(r&&r!="rtl"&&r!="ltr"&&r!="auto")throw new RangeError("Invalid value for isolate: "+r);return r||"auto"}});se.contextHash=new se({perNode:!0});se.lookAhead=new se({perNode:!0});se.mounted=new se({perNode:!0});class Ui{constructor(e,t,i,n=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=n}static get(e){return e&&e.props&&e.props[se.mounted.id]}}const wg=Object.create(null);class rt{constructor(e,t,i,n=0){this.name=e,this.props=t,this.id=i,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):wg,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),n=new rt(e.name||"",t,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(n)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return n}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(se.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let n of i.split(" "))t[n]=e[i];return i=>{for(let n=i.prop(se.group),s=-1;s<(n?n.length:0);s++){let o=t[s<0?i.name:n[s]];if(o)return o}}}}rt.none=new rt("",Object.create(null),0,8);class Wo{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let n=null;for(let s of e){let o=s(i);if(o){n||(n=Object.assign({},i.props));let l=o[1],h=o[0];h.combine&&h.id in n&&(l=h.combine(n[h.id],l)),n[h.id]=l}}t.push(n?new rt(i.name,n,i.id,i.flags):i)}return new Wo(t)}}const ir=new WeakMap,Ea=new WeakMap;var ye;(function(r){r[r.ExcludeBuffers=1]="ExcludeBuffers",r[r.IncludeAnonymous=2]="IncludeAnonymous",r[r.IgnoreMounts=4]="IgnoreMounts",r[r.IgnoreOverlays=8]="IgnoreOverlays",r[r.EnterBracketed=16]="EnterBracketed"})(ye||(ye={}));class Ae{constructor(e,t,i,n,s){if(this.type=e,this.children=t,this.positions=i,this.length=n,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,l]of s)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=Ui.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let n=i.toString();n&&(t&&(t+=","),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new Ar(this.topNode,e)}cursorAt(e,t=0,i=0){let n=ir.get(this)||this.topNode,s=new Ar(n);return s.moveTo(e,t),ir.set(this,s._tree),s}get topNode(){return new Ye(this,0,0,null)}resolve(e,t=0){let i=Rn(ir.get(this)||this.topNode,e,t,!1);return ir.set(this,i),i}resolveInner(e,t=0){let i=Rn(Ea.get(this)||this.topNode,e,t,!0);return Ea.set(this,i),i}resolveStack(e,t=0){return Cg(this,e,t)}iterate(e){let{enter:t,leave:i,from:n=0,to:s=this.length}=e,o=e.mode||0,l=(o&ye.IncludeAnonymous)>0;for(let h=this.cursor(o|ye.IncludeAnonymous);;){let u=!1;if(h.from<=s&&h.to>=n&&(!l&&h.type.isAnonymous||t(h)!==!1)){if(h.firstChild())continue;u=!0}for(;u&&i&&(l||!h.type.isAnonymous)&&i(h),!h.nextSibling();){if(!h.parent())return;u=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:zo(rt.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,n)=>new Ae(this.type,t,i,n,this.propValues),e.makeTree||((t,i,n)=>new Ae(rt.none,t,i,n)))}static build(e){return Ag(e)}}Ae.empty=new Ae(rt.none,[],[],0);class Vo{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Vo(this.buffer,this.index)}}class di{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return rt.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],n=this.set.types[t],s=n.name;if(/\W/.test(s)&&!n.isError&&(s=JSON.stringify(s)),e+=4,i==e)return s;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,t,i,n,s){let{buffer:o}=this,l=-1;for(let h=e;h!=t&&!($f(s,n,o[h+1],o[h+2])&&(l=h,i>0));h=o[h+3]);return l}slice(e,t,i){let n=this.buffer,s=new Uint16Array(t-e),o=0;for(let l=e,h=0;l<t;){s[h++]=n[l++],s[h++]=n[l++]-i;let u=s[h++]=n[l++]-i;s[h++]=n[l++]-e,o=Math.max(o,u)}return new di(s,o,this.set)}}function $f(r,e,t,i){switch(r){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function Rn(r,e,t,i){for(var n;r.from==r.to||(t<1?r.from>=e:r.from>e)||(t>-1?r.to<=e:r.to<e);){let o=!i&&r instanceof Ye&&r.index<0?null:r.parent;if(!o)return r;r=o}let s=i?0:ye.IgnoreOverlays;if(i)for(let o=r,l=o.parent;l;o=l,l=o.parent)o instanceof Ye&&o.index<0&&((n=l.enter(e,t,s))===null||n===void 0?void 0:n.from)!=o.from&&(r=l);for(;;){let o=r.enter(e,t,s);if(!o)return r;r=o}}class _f{cursor(e=0){return new Ar(this,e)}getChild(e,t=null,i=null){let n=Ia(this,e,t,i);return n.length?n[0]:null}getChildren(e,t=null,i=null){return Ia(this,e,t,i)}resolve(e,t=0){return Rn(this,e,t,!1)}resolveInner(e,t=0){return Rn(this,e,t,!0)}matchContext(e){return ho(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let n=t.lastChild;if(!n||n.to!=t.to)break;n.type.isError&&n.from==n.to?(i=t,t=n.prevSibling):t=n}return i}get node(){return this}get next(){return this.parent}}class Ye extends _f{constructor(e,t,i,n){super(),this._tree=e,this.from=t,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,n,s=0){for(let o=this;;){for(let{children:l,positions:h}=o._tree,u=t>0?l.length:-1;e!=u;e+=t){let p=l[e],m=h[e]+o.from,y;if(!(!(s&ye.EnterBracketed&&p instanceof Ae&&(y=Ui.get(p))&&!y.overlay&&y.bracketed&&i>=m&&i<=m+p.length)&&!$f(n,i,m,m+p.length))){if(p instanceof di){if(s&ye.ExcludeBuffers)continue;let x=p.findChild(0,p.buffer.length,t,i-m,n);if(x>-1)return new _t(new bg(o,p,e,m),null,x)}else if(s&ye.IncludeAnonymous||!p.type.isAnonymous||Ko(p)){let x;if(!(s&ye.IgnoreMounts)&&(x=Ui.get(p))&&!x.overlay)return new Ye(x.tree,m,e,o);let S=new Ye(p,m,e,o);return s&ye.IncludeAnonymous||!S.type.isAnonymous?S:S.nextChild(t<0?p.children.length-1:0,t,i,n,s)}}}if(s&ye.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let n;if(!(i&ye.IgnoreOverlays)&&(n=Ui.get(this._tree))&&n.overlay){let s=e-this.from,o=i&ye.EnterBracketed&&n.bracketed;for(let{from:l,to:h}of n.overlay)if((t>0||o?l<=s:l<s)&&(t<0||o?h>=s:h>s))return new Ye(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function Ia(r,e,t,i){let n=r.cursor(),s=[];if(!n.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=n.type.is(t),!n.nextSibling())return s}for(;;){if(i!=null&&n.type.is(i))return s;if(n.type.is(e)&&s.push(n.node),!n.nextSibling())return i==null?s:[]}}function ho(r,e,t=e.length-1){for(let i=r;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}class bg{constructor(e,t,i,n){this.parent=e,this.buffer=t,this.index=i,this.start=n}}class _t extends _f{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,i);return s<0?null:new _t(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&ye.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new _t(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new _t(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new _t(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,n=this.index+4,s=i.buffer[this.index+3];if(s>n){let o=i.buffer[this.index+1];e.push(i.slice(n,s,o)),t.push(0)}return new Ae(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function jf(r){if(!r.length)return null;let e=0,t=r[0];for(let s=1;s<r.length;s++){let o=r[s];(o.from>t.from||o.to<t.to)&&(t=o,e=s)}let i=t instanceof Ye&&t.index<0?null:t.parent,n=r.slice();return i?n[e]=i:n.splice(e,1),new Sg(n,t)}class Sg{constructor(e,t){this.heads=e,this.node=t}get next(){return jf(this.heads)}}function Cg(r,e,t){let i=r.resolveInner(e,t),n=null;for(let s=i instanceof Ye?i:i.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(n||(n=[i])).push(o.resolve(e,t)),s=o}else{let o=Ui.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new Ye(o.tree,o.overlay[0].from+s.from,-1,s);(n||(n=[i])).push(Rn(l,e,t,!1))}}return n?jf(n):i}class Ar{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~ye.EnterBracketed,e instanceof Ye)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=i+n.buffer[e+1],this.to=i+n.buffer[e+2],!0}yield(e){return e?e instanceof Ye?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:n}=this.buffer,s=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&ye.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ye.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ye.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let n=i<0?0:this.stack[i]+4;if(this.index!=n)return this.yieldBuf(t.findChild(n,this.index,-1,0,4))}else{let n=t.buffer[this.index+3];if(n<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(n)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:n}=this;if(n){if(e>0){if(this.index<n.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(n.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:i}=n)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let s=t+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let l=i._tree.children[s];if(this.mode&ye.IncludeAnonymous||l instanceof di||!l.type.isAnonymous||Ko(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let n=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==n){if(n==this.index)return o;t=o,i=s+1;break e}n=this.stack[--s]}for(let n=i;n<this.stack.length;n++)t=new _t(this.buffer,t,this.stack[n]);return this.bufferNode=new _t(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let n=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;;){if(n&&t&&t(this),n=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,n=!0}}}matchContext(e){if(!this.buffer)return ho(this.node.parent,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let n=e.length-1,s=this.stack.length-1;n>=0;s--){if(s<0)return ho(this._tree,e,n);let o=i[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[n]&&e[n]!=o.name)return!1;n--}}return!0}}function Ko(r){return r.children.some(e=>e instanceof di||!e.type.isAnonymous||Ko(e))}function Ag(r){var e;let{buffer:t,nodeSet:i,maxBufferLength:n=zf,reused:s=[],minRepeatType:o=i.types.length}=r,l=Array.isArray(t)?new Vo(t,t.length):t,h=i.types,u=0,p=0;function m(W,V,N,re,oe,ae){let{id:Z,start:Y,end:ee,size:fe}=l,ge=p,Fe=u;if(fe<0)if(l.next(),fe==-1){let Xe=s[Z];N.push(Xe),re.push(Y-W);return}else if(fe==-3){u=Z;return}else if(fe==-4){p=Z;return}else throw new RangeError(`Unrecognized record size: ${fe}`);let De=h[Z],z,Re,Ue=Y-W;if(ee-Y<=n&&(Re=O(l.pos-V,oe))){let Xe=new Uint16Array(Re.size-Re.skip),xe=l.pos-Re.size,He=Xe.length;for(;l.pos>xe;)He=B(Re.start,Xe,He);z=new di(Xe,ee-Re.start,i),Ue=Re.start-W}else{let Xe=l.pos-fe;l.next();let xe=[],He=[],dt=Z>=o?Z:-1,ve=0,Di=ee;for(;l.pos>Xe;)dt>=0&&l.id==dt&&l.size>=0?(l.end<=Di-n&&(S(xe,He,Y,ve,l.end,Di,dt,ge,Fe),ve=xe.length,Di=l.end),l.next()):ae>2500?y(Y,Xe,xe,He):m(Y,Xe,xe,He,dt,ae+1);if(dt>=0&&ve>0&&ve<xe.length&&S(xe,He,Y,ve,Y,Di,dt,ge,Fe),xe.reverse(),He.reverse(),dt>-1&&ve>0){let ei=x(De,Fe);z=zo(De,xe,He,0,xe.length,0,ee-Y,ei,ei)}else z=C(De,xe,He,ee-Y,ge-ee,Fe)}N.push(z),re.push(Ue)}function y(W,V,N,re){let oe=[],ae=0,Z=-1;for(;l.pos>V;){let{id:Y,start:ee,end:fe,size:ge}=l;if(ge>4)l.next();else{if(Z>-1&&ee<Z)break;Z<0&&(Z=fe-n),oe.push(Y,ee,fe),ae++,l.next()}}if(ae){let Y=new Uint16Array(ae*4),ee=oe[oe.length-2];for(let fe=oe.length-3,ge=0;fe>=0;fe-=3)Y[ge++]=oe[fe],Y[ge++]=oe[fe+1]-ee,Y[ge++]=oe[fe+2]-ee,Y[ge++]=ge;N.push(new di(Y,oe[2]-ee,i)),re.push(ee-W)}}function x(W,V){return(N,re,oe)=>{let ae=0,Z=N.length-1,Y,ee;if(Z>=0&&(Y=N[Z])instanceof Ae){if(!Z&&Y.type==W&&Y.length==oe)return Y;(ee=Y.prop(se.lookAhead))&&(ae=re[Z]+Y.length+ee)}return C(W,N,re,oe,ae,V)}}function S(W,V,N,re,oe,ae,Z,Y,ee){let fe=[],ge=[];for(;W.length>re;)fe.push(W.pop()),ge.push(V.pop()+N-oe);W.push(C(i.types[Z],fe,ge,ae-oe,Y-ae,ee)),V.push(oe-N)}function C(W,V,N,re,oe,ae,Z){if(ae){let Y=[se.contextHash,ae];Z=Z?[Y].concat(Z):[Y]}if(oe>25){let Y=[se.lookAhead,oe];Z=Z?[Y].concat(Z):[Y]}return new Ae(W,V,N,re,Z)}function O(W,V){let N=l.fork(),re=0,oe=0,ae=0,Z=N.end-n,Y={size:0,start:0,skip:0};e:for(let ee=N.pos-W;N.pos>ee;){let fe=N.size;if(N.id==V&&fe>=0){Y.size=re,Y.start=oe,Y.skip=ae,ae+=4,re+=4,N.next();continue}let ge=N.pos-fe;if(fe<0||ge<ee||N.start<Z)break;let Fe=N.id>=o?4:0,De=N.start;for(N.next();N.pos>ge;){if(N.size<0)if(N.size==-3||N.size==-4)Fe+=4;else break e;else N.id>=o&&(Fe+=4);N.next()}oe=De,re+=fe,ae+=Fe}return(V<0||re==W)&&(Y.size=re,Y.start=oe,Y.skip=ae),Y.size>4?Y:void 0}function B(W,V,N){let{id:re,start:oe,end:ae,size:Z}=l;if(l.next(),Z>=0&&re<o){let Y=N;if(Z>4){let ee=l.pos-(Z-4);for(;l.pos>ee;)N=B(W,V,N)}V[--N]=Y,V[--N]=ae-W,V[--N]=oe-W,V[--N]=re}else Z==-3?u=re:Z==-4&&(p=re);return N}let F=[],P=[];for(;l.pos>0;)m(r.start||0,r.bufferStart||0,F,P,-1,0);let Q=(e=r.length)!==null&&e!==void 0?e:F.length?P[0]+F[0].length:0;return new Ae(h[r.topID],F.reverse(),P.reverse(),Q)}const Pa=new WeakMap;function cr(r,e){if(!r.isAnonymous||e instanceof di||e.type!=r)return 1;let t=Pa.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=r||!(i instanceof Ae)){t=1;break}t+=cr(r,i)}Pa.set(e,t)}return t}function zo(r,e,t,i,n,s,o,l,h){let u=0;for(let S=i;S<n;S++)u+=cr(r,e[S]);let p=Math.ceil(u*1.5/8),m=[],y=[];function x(S,C,O,B,F){for(let P=O;P<B;){let Q=P,W=C[P],V=cr(r,S[P]);for(P++;P<B;P++){let N=cr(r,S[P]);if(V+N>=p)break;V+=N}if(P==Q+1){if(V>p){let N=S[Q];x(N.children,N.positions,0,N.children.length,C[Q]+F);continue}m.push(S[Q])}else{let N=C[P-1]+S[P-1].length-W;m.push(zo(r,S,C,Q,P,W,N,null,h))}y.push(W+F-s)}}return x(e,t,i,n,0),(l||h)(m,y,o)}class $v{constructor(){this.map=new WeakMap}setBuffer(e,t,i){let n=this.map.get(e);n||this.map.set(e,n=new Map),n.set(t,i)}getBuffer(e,t){let i=this.map.get(e);return i&&i.get(t)}set(e,t){e instanceof _t?this.setBuffer(e.context.buffer,e.index,t):e instanceof Ye&&this.map.set(e.tree,t)}get(e){return e instanceof _t?this.getBuffer(e.context.buffer,e.index):e instanceof Ye?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class Qt{constructor(e,t,i,n,s=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=n,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let n=[new Qt(0,e.length,e,0,!1,i)];for(let s of t)s.to>e.length&&n.push(s);return n}static applyChanges(e,t,i=128){if(!t.length)return e;let n=[],s=1,o=e.length?e[0]:null;for(let l=0,h=0,u=0;;l++){let p=l<t.length?t[l]:null,m=p?p.fromA:1e9;if(m-h>=i)for(;o&&o.from<m;){let y=o;if(h>=y.from||m<=y.to||u){let x=Math.max(y.from,h)-u,S=Math.min(y.to,m)-u;y=x>=S?null:new Qt(x,S,y.tree,y.offset+u,l>0,!!p)}if(y&&n.push(y),o.to>m)break;o=s<e.length?e[s++]:null}if(!p)break;h=p.toA,u=p.toA-p.toB}return n}}class qf{startParse(e,t,i){return typeof e=="string"&&(e=new Mg(e)),i=i?i.length?i.map(n=>new yt(n.from,n.to)):[new yt(0,0)]:[new yt(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let n=this.startParse(e,t,i);for(;;){let s=n.advance();if(s)return s}}}class Mg{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}function _v(r){return(e,t,i,n)=>new Og(e,r,t,i,n)}class Na{constructor(e,t,i,n,s,o){this.parser=e,this.parse=t,this.overlay=i,this.bracketed=n,this.target=s,this.from=o}}function Fa(r){if(!r.length||r.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(r))}class Tg{constructor(e,t,i,n,s,o,l,h){this.parser=e,this.predicate=t,this.mounts=i,this.index=n,this.start=s,this.bracketed=o,this.target=l,this.prev=h,this.depth=0,this.ranges=[]}}const fo=new se({perNode:!0});class Og{constructor(e,t,i,n,s){this.nest=t,this.input=i,this.fragments=n,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let n of this.inner)n.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new Ae(i.type,i.children,i.positions,i.length,i.propValues.concat([[fo,this.stoppedAt]]))),i}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let i=Object.assign(Object.create(null),e.target.props);i[se.mounted.id]=new Ui(t,e.overlay,e.parser,e.bracketed),e.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new Dg(this.fragments),t=null,i=null,n=new Ar(new Ye(this.baseTree,this.ranges[0].from,0,null),ye.IncludeAnonymous|ye.IgnoreMounts);e:for(let s,o;;){let l=!0,h;if(this.stoppedAt!=null&&n.from>=this.stoppedAt)l=!1;else if(e.hasNode(n)){if(t){let u=t.mounts.find(p=>p.frag.from<=n.from&&p.frag.to>=n.to&&p.mount.overlay);if(u)for(let p of u.mount.overlay){let m=p.from+u.pos,y=p.to+u.pos;m>=n.from&&y<=n.to&&!t.ranges.some(x=>x.from<y&&x.to>m)&&t.ranges.push({from:m,to:y})}}l=!1}else if(i&&(o=Lg(i.ranges,n.from,n.to)))l=o!=2;else if(!n.type.isAnonymous&&(s=this.nest(n,this.input))&&(n.from<n.to||!s.overlay)){n.tree||(Bg(n),t&&t.depth++,i&&i.depth++);let u=e.findMounts(n.from,s.parser);if(typeof s.overlay=="function")t=new Tg(s.parser,s.overlay,u,this.inner.length,n.from,!!s.bracketed,n.tree,t);else{let p=Va(this.ranges,s.overlay||(n.from<n.to?[new yt(n.from,n.to)]:[]));p.length&&Fa(p),(p.length||!s.overlay)&&this.inner.push(new Na(s.parser,p.length?s.parser.startParse(this.input,Ka(u,p),p):s.parser.startParse(""),s.overlay?s.overlay.map(m=>new yt(m.from-n.from,m.to-n.from)):null,!!s.bracketed,n.tree,p.length?p[0].from:n.from)),s.overlay?p.length&&(i={ranges:p,depth:0,prev:i}):l=!1}}else if(t&&(h=t.predicate(n))&&(h===!0&&(h=new yt(n.from,n.to)),h.from<h.to)){let u=t.ranges.length-1;u>=0&&t.ranges[u].to==h.from?t.ranges[u]={from:t.ranges[u].from,to:h.to}:t.ranges.push(h)}if(l&&n.firstChild())t&&t.depth++,i&&i.depth++;else for(;!n.nextSibling();){if(!n.parent())break e;if(t&&!--t.depth){let u=Va(this.ranges,t.ranges);u.length&&(Fa(u),this.inner.splice(t.index,0,new Na(t.parser,t.parser.startParse(this.input,Ka(t.mounts,u),u),t.ranges.map(p=>new yt(p.from-t.start,p.to-t.start)),t.bracketed,t.target,u[0].from))),t=t.prev}i&&!--i.depth&&(i=i.prev)}}}}function Lg(r,e,t){for(let i of r){if(i.from>=t)break;if(i.to>e)return i.from<=e&&i.to>=t?2:1}return 0}function Ha(r,e,t,i,n,s){if(e<t){let o=r.buffer[e+1];i.push(r.slice(e,t,o)),n.push(o-s)}}function Bg(r){let{node:e}=r,t=[],i=e.context.buffer;do t.push(r.index),r.parent();while(!r.tree);let n=r.tree,s=n.children.indexOf(i),o=n.children[s],l=o.buffer,h=[s];function u(p,m,y,x,S,C){let O=t[C],B=[],F=[];Ha(o,p,O,B,F,x);let P=l[O+1],Q=l[O+2];h.push(B.length);let W=C?u(O+4,l[O+3],o.set.types[l[O]],P,Q-P,C-1):e.toTree();return B.push(W),F.push(P-x),Ha(o,l[O+3],m,B,F,x),new Ae(y,B,F,S)}n.children[s]=u(0,l.length,rt.none,0,o.length,t.length-1);for(let p of h){let m=r.tree.children[p],y=r.tree.positions[p];r.yield(new Ye(m,y+r.from,p,r._tree))}}class Wa{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(ye.IncludeAnonymous|ye.IgnoreMounts)}moveTo(e){let{cursor:t}=this,i=e-this.offset;for(;!this.done&&t.from<i;)if(!(t.to>=e&&t.enter(i,1,ye.IgnoreOverlays|ye.ExcludeBuffers)))if(t.to<=e)t.next(!1)||(this.done=!0);else break}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof Ae)t=t.children[0];else break}return!1}}let Dg=class{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let i=this.curFrag=e[0];this.curTo=(t=i.tree.prop(fo))!==null&&t!==void 0?t:i.to,this.inner=new Wa(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=(e=t.tree.prop(fo))!==null&&e!==void 0?e:t.to,this.inner=new Wa(t.tree,-t.offset)}}findMounts(e,t){var i;let n=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let s=this.inner.cursor.node;s;s=s.parent){let o=(i=s.tree)===null||i===void 0?void 0:i.prop(se.mounted);if(o&&o.parser==t)for(let l=this.fragI;l<this.fragments.length;l++){let h=this.fragments[l];if(h.from>=s.to)break;h.tree==this.curFrag.tree&&n.push({frag:h,pos:s.from-h.offset,mount:o})}}}return n}};function Va(r,e){let t=null,i=e;for(let n=1,s=0;n<r.length;n++){let o=r[n-1].to,l=r[n].from;for(;s<i.length;s++){let h=i[s];if(h.from>=l)break;h.to<=o||(t||(i=t=e.slice()),h.from<o?(t[s]=new yt(h.from,o),h.to>l&&t.splice(s+1,0,new yt(l,h.to))):h.to>l?t[s--]=new yt(l,h.to):t.splice(s--,1))}}return i}function Rg(r,e,t,i){let n=0,s=0,o=!1,l=!1,h=-1e9,u=[];for(;;){let p=n==r.length?1e9:o?r[n].to:r[n].from,m=s==e.length?1e9:l?e[s].to:e[s].from;if(o!=l){let y=Math.max(h,t),x=Math.min(p,m,i);y<x&&u.push(new yt(y,x))}if(h=Math.min(p,m),h==1e9)break;p==h&&(o?(o=!1,n++):o=!0),m==h&&(l?(l=!1,s++):l=!0)}return u}function Ka(r,e){let t=[];for(let{pos:i,mount:n,frag:s}of r){let o=i+(n.overlay?n.overlay[0].from:0),l=o+n.tree.length,h=Math.max(s.from,o),u=Math.min(s.to,l);if(n.overlay){let p=n.overlay.map(y=>new yt(y.from+i,y.to+i)),m=Rg(e,p,h,u);for(let y=0,x=h;;y++){let S=y==m.length,C=S?u:m[y].from;if(C>x&&t.push(new Qt(x,C,n.tree,-o,s.from>=x||s.openStart,s.to<=C||s.openEnd)),S)break;x=m[y].to}}else t.push(new Qt(h,u,n.tree,-o,s.from>=o||s.openStart,s.to<=l||s.openEnd))}return t}let Eg=0;class mt{constructor(e,t,i,n){this.name=e,this.set=t,this.base=i,this.modified=n,this.id=Eg++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof mt&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let n=new mt(i,[],null,[]);if(n.set.push(n),t)for(let s of t.set)n.set.push(s);return n}static defineModifier(e){let t=new Mr(e);return i=>i.modified.indexOf(t)>-1?i:Mr.get(i.base||i,i.modified.concat(t).sort((n,s)=>n.id-s.id))}}let Ig=0;class Mr{constructor(e){this.name=e,this.instances=[],this.id=Ig++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&Pg(t,l.modified));if(i)return i;let n=[],s=new mt(e.name,n,e,t);for(let l of t)l.instances.push(s);let o=Ng(t);for(let l of e.set)if(!l.modified.length)for(let h of o)n.push(Mr.get(l,h));return s}}function Pg(r,e){return r.length==e.length&&r.every((t,i)=>t==e[i])}function Ng(r){let e=[[]];for(let t=0;t<r.length;t++)for(let i=0,n=e.length;i<n;i++)e.push(e[i].concat(r[t]));return e.sort((t,i)=>i.length-t.length)}function Fg(r){let e=Object.create(null);for(let t in r){let i=r[t];Array.isArray(i)||(i=[i]);for(let n of t.split(" "))if(n){let s=[],o=2,l=n;for(let m=0;;){if(l=="..."&&m>0&&m+3==n.length){o=1;break}let y=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!y)throw new RangeError("Invalid path: "+n);if(s.push(y[0]=="*"?"":y[0][0]=='"'?JSON.parse(y[0]):y[0]),m+=y[0].length,m==n.length)break;let x=n[m++];if(m==n.length&&x=="!"){o=0;break}if(x!="/")throw new RangeError("Invalid path: "+n);l=n.slice(m)}let h=s.length-1,u=s[h];if(!u)throw new RangeError("Invalid path: "+n);let p=new En(i,o,h>0?s.slice(0,h):null);e[u]=p.sort(e[u])}}return Uf.add(e)}const Uf=new se({combine(r,e){let t,i,n;for(;r||e;){if(!r||e&&r.depth>=e.depth?(n=e,e=e.next):(n=r,r=r.next),t&&t.mode==n.mode&&!n.context&&!t.context)continue;let s=new En(n.tags,n.mode,n.context);t?t.next=s:i=s,t=s}return i}});class En{constructor(e,t,i,n){this.tags=e,this.mode=t,this.context=i,this.next=n}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}En.empty=new En([],2,null);function Jf(r,e){let t=Object.create(null);for(let s of r)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let o of s.tag)t[o.id]=s.class;let{scope:i,all:n=null}=e||{};return{style:s=>{let o=n;for(let l of s)for(let h of l.set){let u=t[h.id];if(u){o=o?o+" "+u:u;break}}return o},scope:i}}function Hg(r,e){let t=null;for(let i of r){let n=i.style(e);n&&(t=t?t+" "+n:n)}return t}function Wg(r,e,t,i=0,n=r.length){let s=new Vg(i,Array.isArray(e)?e:[e],t);s.highlightRange(r.cursor(),i,n,"",s.highlighters),s.flush(n)}class Vg{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,n,s){let{type:o,from:l,to:h}=e;if(l>=i||h<=t)return;o.isTop&&(s=this.highlighters.filter(x=>!x.scope||x.scope(o)));let u=n,p=Kg(e)||En.empty,m=Hg(s,p.tags);if(m&&(u&&(u+=" "),u+=m,p.mode==1&&(n+=(n?" ":"")+m)),this.startSpan(Math.max(t,l),u),p.opaque)return;let y=e.tree&&e.tree.prop(se.mounted);if(y&&y.overlay){let x=e.node.enter(y.overlay[0].from+l,1),S=this.highlighters.filter(O=>!O.scope||O.scope(y.tree.type)),C=e.firstChild();for(let O=0,B=l;;O++){let F=O<y.overlay.length?y.overlay[O]:null,P=F?F.from+l:h,Q=Math.max(t,B),W=Math.min(i,P);if(Q<W&&C)for(;e.from<W&&(this.highlightRange(e,Q,W,n,s),this.startSpan(Math.min(W,e.to),u),!(e.to>=P||!e.nextSibling())););if(!F||P>i)break;B=F.to+l,B>t&&(this.highlightRange(x.cursor(),Math.max(t,F.from+l),Math.min(i,B),"",S),this.startSpan(Math.min(i,B),u))}C&&e.parent()}else if(e.firstChild()){y&&(n="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,n,s),this.startSpan(Math.min(i,e.to),u)}while(e.nextSibling());e.parent()}}}function Kg(r){let e=r.type.prop(Uf);for(;e&&e.context&&!r.matchContext(e.context);)e=e.next;return e||null}const K=mt.define,nr=K(),ni=K(),za=K(ni),$a=K(ni),ri=K(),rr=K(ri),bs=K(ri),Ht=K(),ki=K(Ht),Nt=K(),Ft=K(),uo=K(),cn=K(uo),sr=K(),$={comment:nr,lineComment:K(nr),blockComment:K(nr),docComment:K(nr),name:ni,variableName:K(ni),typeName:za,tagName:K(za),propertyName:$a,attributeName:K($a),className:K(ni),labelName:K(ni),namespace:K(ni),macroName:K(ni),literal:ri,string:rr,docString:K(rr),character:K(rr),attributeValue:K(rr),number:bs,integer:K(bs),float:K(bs),bool:K(ri),regexp:K(ri),escape:K(ri),color:K(ri),url:K(ri),keyword:Nt,self:K(Nt),null:K(Nt),atom:K(Nt),unit:K(Nt),modifier:K(Nt),operatorKeyword:K(Nt),controlKeyword:K(Nt),definitionKeyword:K(Nt),moduleKeyword:K(Nt),operator:Ft,derefOperator:K(Ft),arithmeticOperator:K(Ft),logicOperator:K(Ft),bitwiseOperator:K(Ft),compareOperator:K(Ft),updateOperator:K(Ft),definitionOperator:K(Ft),typeOperator:K(Ft),controlOperator:K(Ft),punctuation:uo,separator:K(uo),bracket:cn,angleBracket:K(cn),squareBracket:K(cn),paren:K(cn),brace:K(cn),content:Ht,heading:ki,heading1:K(ki),heading2:K(ki),heading3:K(ki),heading4:K(ki),heading5:K(ki),heading6:K(ki),contentSeparator:K(Ht),list:K(Ht),quote:K(Ht),emphasis:K(Ht),strong:K(Ht),link:K(Ht),monospace:K(Ht),strikethrough:K(Ht),inserted:K(),deleted:K(),changed:K(),invalid:K(),meta:sr,documentMeta:K(sr),annotation:K(sr),processingInstruction:K(sr),definition:mt.defineModifier("definition"),constant:mt.defineModifier("constant"),function:mt.defineModifier("function"),standard:mt.defineModifier("standard"),local:mt.defineModifier("local"),special:mt.defineModifier("special")};for(let r in $){let e=$[r];e instanceof mt&&(e.name=r)}Jf([{tag:$.link,class:"tok-link"},{tag:$.heading,class:"tok-heading"},{tag:$.emphasis,class:"tok-emphasis"},{tag:$.strong,class:"tok-strong"},{tag:$.keyword,class:"tok-keyword"},{tag:$.atom,class:"tok-atom"},{tag:$.bool,class:"tok-bool"},{tag:$.url,class:"tok-url"},{tag:$.labelName,class:"tok-labelName"},{tag:$.inserted,class:"tok-inserted"},{tag:$.deleted,class:"tok-deleted"},{tag:$.literal,class:"tok-literal"},{tag:$.string,class:"tok-string"},{tag:$.number,class:"tok-number"},{tag:[$.regexp,$.escape,$.special($.string)],class:"tok-string2"},{tag:$.variableName,class:"tok-variableName"},{tag:$.local($.variableName),class:"tok-variableName tok-local"},{tag:$.definition($.variableName),class:"tok-variableName tok-definition"},{tag:$.special($.variableName),class:"tok-variableName2"},{tag:$.definition($.propertyName),class:"tok-propertyName tok-definition"},{tag:$.typeName,class:"tok-typeName"},{tag:$.namespace,class:"tok-namespace"},{tag:$.className,class:"tok-className"},{tag:$.macroName,class:"tok-macroName"},{tag:$.propertyName,class:"tok-propertyName"},{tag:$.operator,class:"tok-operator"},{tag:$.comment,class:"tok-comment"},{tag:$.meta,class:"tok-meta"},{tag:$.invalid,class:"tok-invalid"},{tag:$.punctuation,class:"tok-punctuation"}]);var Ss;const zi=new se;function zg(r){return j.define({combine:r?e=>e.concat(r):void 0})}const $g=new se;class kt{constructor(e,t,i=[],n=""){this.data=e,this.name=n,pe.prototype.hasOwnProperty("tree")||Object.defineProperty(pe.prototype,"tree",{get(){return ct(this)}}),this.parser=t,this.extension=[tn.of(this),pe.languageData.of((s,o,l)=>{let h=_a(s,o,l),u=h.type.prop(zi);if(!u)return[];let p=s.facet(u),m=h.type.prop($g);if(m){let y=h.resolve(o-h.from,l);for(let x of m)if(x.test(y,s)){let S=s.facet(x.facet);return x.type=="replace"?S:S.concat(p)}}return p})].concat(i)}isActiveAt(e,t,i=-1){return _a(e,t,i).type.prop(zi)==this.data}findRegions(e){let t=e.facet(tn);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],n=(s,o)=>{if(s.prop(zi)==this.data){i.push({from:o,to:o+s.length});return}let l=s.prop(se.mounted);if(l){if(l.tree.prop(zi)==this.data){if(l.overlay)for(let h of l.overlay)i.push({from:h.from+o,to:h.to+o});else i.push({from:o,to:o+s.length});return}else if(l.overlay){let h=i.length;if(n(l.tree,l.overlay[0].from+o),i.length>h)return}}for(let h=0;h<s.children.length;h++){let u=s.children[h];u instanceof Ae&&n(u,s.positions[h]+o)}};return n(ct(e),0),i}get allowsNesting(){return!0}}kt.setState=me.define();function _a(r,e,t){let i=r.facet(tn),n=ct(r).topNode;if(!i||i.allowsNesting)for(let s=n;s;s=s.enter(e,t,ye.ExcludeBuffers|ye.EnterBracketed))s.type.isTop&&(n=s);return n}class co extends kt{constructor(e,t,i){super(e,t,[],i),this.parser=t}static define(e){let t=zg(e.languageData);return new co(t,e.parser.configure({props:[zi.add(i=>i.isTop?t:void 0)]}),e.name)}configure(e,t){return new co(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function ct(r){let e=r.field(kt.state,!1);return e?e.tree:Ae.empty}function Gf(r,e,t=50){var i;let n=(i=r.field(kt.state,!1))===null||i===void 0?void 0:i.context;if(!n)return null;let s=n.viewport;n.updateViewport({from:0,to:e});let o=n.isDone(e)||n.work(t,e)?n.tree:null;return n.updateViewport(s),o}class _g{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let dn=null;class Tr{constructor(e,t,i=[],n,s,o,l,h){this.parser=e,this.state=t,this.fragments=i,this.tree=n,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=h,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new Tr(e,t,[],Ae.empty,0,i,[],null)}startParse(){return this.parser.startParse(new _g(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Ae.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let n=Date.now()+e;e=()=>Date.now()>n}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n)if(this.fragments=this.withoutTempSkipped(Qt.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Qt.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=dn;dn=this;try{return e()}finally{dn=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=ja(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:n,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let h=[];if(e.iterChangedRanges((u,p,m,y)=>h.push({fromA:u,toA:p,fromB:m,toB:y})),i=Qt.applyChanges(i,h),n=Ae.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let p=e.mapPos(u.from,1),m=e.mapPos(u.to,-1);p<m&&l.push({from:p,to:m})}}}return new Tr(this.parser,t,i,n,s,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:n,to:s}=this.skipped[i];n<e.to&&s>e.from&&(this.fragments=ja(this.fragments,n,s),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends qf{createParse(t,i,n){let s=n[0].from,o=n[n.length-1].to;return{parsedPos:s,advance(){let h=dn;if(h){for(let u of n)h.tempSkipped.push(u);e&&(h.scheduleOn=h.scheduleOn?Promise.all([h.scheduleOn,e]):e)}return this.parsedPos=o,new Ae(rt.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return dn}}function ja(r,e,t){return Qt.applyChanges(r,[{fromA:e,toA:t,fromB:e,toB:t}])}class en{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new en(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Tr.create(e.facet(tn).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new en(i)}}kt.state=Ot.define({create:en.init,update(r,e){for(let t of e.effects)if(t.is(kt.setState))return t.value;return e.startState.facet(tn)!=e.state.facet(tn)?en.init(e.state):r.apply(e)}});let Yf=r=>{let e=setTimeout(()=>r(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Yf=r=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(r,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const Cs=typeof navigator<"u"&&(!((Ss=navigator.scheduling)===null||Ss===void 0)&&Ss.isInputPending)?()=>navigator.scheduling.isInputPending():null,jg=wt.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(kt.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(kt.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Yf(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:n}}=this.view,s=i.field(kt.state);if(s.tree==s.context.tree&&s.context.isDone(n+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!Cs?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<n&&i.doc.length>n+1e3,h=s.context.work(()=>Cs&&Cs()||Date.now()>o,n+(l?0:1e5));this.chunkBudget-=Date.now()-t,(h||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:kt.setState.of(new en(s.context))})),this.chunkBudget>0&&!(h&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>$t(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),tn=j.define({combine(r){return r.length?r[0]:null},enables:r=>[kt.state,jg,G.contentAttributes.compute([r],e=>{let t=e.facet(r);return t&&t.name?{"data-language":t.name}:{}})]});class Uv{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}class Qf{constructor(e,t,i,n,s,o=void 0){this.name=e,this.alias=t,this.extensions=i,this.filename=n,this.loadFunc=s,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:t,support:i}=e;if(!t){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");t=()=>Promise.resolve(i)}return new Qf(e.name,(e.alias||[]).concat(e.name).map(n=>n.toLowerCase()),e.extensions||[],e.filename,t,i)}static matchFilename(e,t){for(let n of e)if(n.filename&&n.filename.test(t))return n;let i=/\.([^.]+)$/.exec(t);if(i){for(let n of e)if(n.extensions.indexOf(i[1])>-1)return n}return null}static matchLanguageName(e,t,i=!0){t=t.toLowerCase();for(let n of e)if(n.alias.some(s=>s==t))return n;if(i)for(let n of e)for(let s of n.alias){let o=t.indexOf(s);if(o>-1&&(s.length>2||!/\w/.test(t[o-1])&&!/\w/.test(t[o+s.length])))return n}return null}}const qg=j.define(),nn=j.define({combine:r=>{if(!r.length)return" ";let e=r[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(r[0]));return e}});function Or(r){let e=r.facet(nn);return e.charCodeAt(0)==9?r.tabSize*e.length:e.length}function In(r,e){let t="",i=r.tabSize,n=r.facet(nn)[0];if(n==" "){for(;e>=i;)t+=" ",e-=i;n=" "}for(let s=0;s<e;s++)t+=n;return t}function $o(r,e){r instanceof pe&&(r=new _r(r));for(let i of r.state.facet(qg)){let n=i(r,e);if(n!==void 0)return n}let t=ct(r.state);return t.length>=e?Jg(r,t,e):null}class _r{constructor(e,t={}){this.state=e,this.options=t,this.unit=Or(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:n,simulateDoubleBreak:s}=this.options;return n!=null&&n>=i.from&&n<=i.to?s&&n==e?{text:"",from:e}:(t<0?n<e:n<=e)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(e,t);return i.slice(e-n,Math.min(i.length,e+100-n))}column(e,t=1){let{text:i,from:n}=this.lineAt(e,t),s=this.countColumn(i,e-n),o=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return o>-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,t=e.length){return Hr(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:n}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(n);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Ug=new se;function Jg(r,e,t){let i=e.resolveStack(t),n=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(n!=i.node){let s=[];for(let o=n;o&&!(o.from<i.node.from||o.to>i.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return Xf(i,r,t)}function Xf(r,e,t){for(let i=r;i;i=i.next){let n=Yg(i.node);if(n)return n(_o.create(e,t,i))}return 0}function Gg(r){return r.pos==r.options.simulateBreak&&r.options.simulateDoubleBreak}function Yg(r){let e=r.type.prop(Ug);if(e)return e;let t=r.firstChild,i;if(t&&(i=t.type.prop(se.closedBy))){let n=r.lastChild,s=n&&i.indexOf(n.name)>-1;return o=>Zf(o,!0,1,void 0,s&&!Gg(o)?n.from:void 0)}return r.parent==null?Qg:null}function Qg(){return 0}class _o extends _r{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new _o(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(Xg(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return Xf(this.context.next,this.base,this.pos)}}function Xg(r,e){for(let t=e;t;t=t.parent)if(r==t)return!0;return!1}function Zg(r){let e=r.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let n=r.options.simulateBreak,s=r.state.doc.lineAt(t.from),o=n==null||n<=s.from?s.to:Math.min(s.to,n);for(let l=t.to;;){let h=e.childAfter(l);if(!h||h==i)return null;if(!h.type.isSkipped){if(h.from>=o)return null;let u=/^ */.exec(s.text.slice(t.to-s.from))[0].length;return{from:t.from,to:t.to+u}}l=h.to}}function Jv({closing:r,align:e=!0,units:t=1}){return i=>Zf(i,e,t,r)}function Zf(r,e,t,i,n){let s=r.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||n==r.pos+o,h=e?Zg(r):null;return h?l?r.column(h.from):r.column(h.to):r.baseIndent+(l?0:r.unit*t)}const Gv=r=>r.baseIndent;function Yv({except:r,units:e=1}={}){return t=>{let i=r&&r.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}const em=200;function Qv(){return pe.transactionFilter.of(r=>{if(!r.docChanged||!r.isUserEvent("input.type")&&!r.isUserEvent("input.complete"))return r;let e=r.startState.languageDataAt("indentOnInput",r.startState.selection.main.head);if(!e.length)return r;let t=r.newDoc,{head:i}=r.newSelection.main,n=t.lineAt(i);if(i>n.from+em)return r;let s=t.sliceString(n.from,i);if(!e.some(u=>u.test(s)))return r;let{state:o}=r,l=-1,h=[];for(let{head:u}of o.selection.ranges){let p=o.doc.lineAt(u);if(p.from==l)continue;l=p.from;let m=$o(o,p.from);if(m==null)continue;let y=/^\s*/.exec(p.text)[0],x=In(o,m);y!=x&&h.push({from:p.from,to:p.from+y.length,insert:x})}return h.length?[r,{changes:h,sequential:!0}]:r})}const tm=j.define(),im=new se;function Xv(r){let e=r.firstChild,t=r.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?r.to:t.from}:null}function nm(r,e,t){let i=ct(r);if(i.length<t)return null;let n=i.resolveStack(t,1),s=null;for(let o=n;o;o=o.next){let l=o.node;if(l.to<=t||l.from>t)continue;if(s&&l.from<e)break;let h=l.type.prop(im);if(h&&(l.to<i.length-50||i.length==r.doc.length||!rm(l))){let u=h(l,r);u&&u.from<=t&&u.from>=e&&u.to>t&&(s=u)}}return s}function rm(r){let e=r.lastChild;return e&&e.to==r.to&&e.type.isError}function sm(r,e,t){for(let i of r.facet(tm)){let n=i(r,e,t);if(n)return n}return nm(r,e,t)}function eu(r,e){let t=e.mapPos(r.from,1),i=e.mapPos(r.to,-1);return t>=i?void 0:{from:t,to:i}}const tu=me.define({map:eu}),iu=me.define({map:eu});function om(r){let e=[];for(let{head:t}of r.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(r.lineBlockAt(t));return e}const jo=Ot.define({create(){return de.none},update(r,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((i,n)=>r=qa(r,i,n)),r=r.map(e.changes);let t=[];for(let i of e.effects)i.is(tu)&&!am(r,i.value.from,i.value.to)?t.push(i.value):i.is(iu)&&(r=r.update({filter:(n,s)=>i.value.from!=n||i.value.to!=s,filterFrom:i.value.from,filterTo:i.value.to}));if(t.length){let{preparePlaceholder:i}=e.state.facet(nu),n=t.map(s=>(i?de.replace({widget:new pm(i(e.state,s))}):Ua).range(s.from,s.to));r=r.update({add:n})}return e.selection&&(r=qa(r,e.selection.main.head)),r},provide:r=>G.decorations.from(r),toJSON(r,e){let t=[];return r.between(0,e.doc.length,(i,n)=>{t.push(i,n)}),t},fromJSON(r){if(!Array.isArray(r)||r.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<r.length;){let i=r[t++],n=r[t++];if(typeof i!="number"||typeof n!="number")throw new RangeError("Invalid JSON for fold state");e.push(Ua.range(i,n))}return de.set(e,!0)}});function qa(r,e,t=e){let i=!1;return r.between(e,t,(n,s)=>{n<t&&s>e&&(i=!0)}),i?r.update({filterFrom:e,filterTo:t,filter:(n,s)=>n>=t||s<=e}):r}function lm(r,e,t){var i;let n=null;return(i=r.field(jo,!1))===null||i===void 0||i.between(e,t,(s,o)=>{(!n||n.from>s)&&(n={from:s,to:o})}),n}function am(r,e,t){let i=!1;return r.between(e,e,(n,s)=>{n==e&&s==t&&(i=!0)}),i}function hm(r,e){return r.field(jo,!1)?e:e.concat(me.appendConfig.of(dm()))}const fm=r=>{for(let e of om(r)){let t=sm(r.state,e.from,e.to);if(t)return r.dispatch({effects:hm(r.state,[tu.of(t),um(r,t)])}),!0}return!1};function um(r,e,t=!0){let i=r.state.doc.lineAt(e.from).number,n=r.state.doc.lineAt(e.to).number;return G.announce.of(`${r.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${r.state.phrase("to")} ${n}.`)}const cm={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},nu=j.define({combine(r){return Fr(r,cm)}});function dm(r){return[jo,gm]}function ru(r,e){let{state:t}=r,i=t.facet(nu),n=o=>{let l=r.lineBlockAt(r.posAtDOM(o.target)),h=lm(r.state,l.from,l.to);h&&r.dispatch({effects:iu.of(h)}),o.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(r,n,e);let s=document.createElement("span");return s.textContent=i.placeholderText,s.setAttribute("aria-label",t.phrase("folded code")),s.title=t.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=n,s}const Ua=de.replace({widget:new class extends pi{toDOM(r){return ru(r,null)}}});class pm extends pi{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return ru(e,this.value)}}const gm=G.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 jr{constructor(e,t){this.specs=e;let i;function n(l){let h=fi.newName();return(i||(i=Object.create(null)))["."+h]=l,h}const s=typeof t.all=="string"?t.all:t.all?n(t.all):void 0,o=t.scope;this.scope=o instanceof kt?l=>l.prop(zi)==o.data:o?l=>l==o:void 0,this.style=Jf(e.map(l=>({tag:l.tag,class:l.class||n(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=i?new fi(i):null,this.themeType=t.themeType}static define(e,t){return new jr(e,t||{})}}const po=j.define(),su=j.define({combine(r){return r.length?[r[0]]:null}});function As(r){let e=r.facet(po);return e.length?e:r.facet(su)}function Zv(r,e){let t=[vm],i;return r instanceof jr&&(r.module&&t.push(G.styleModule.of(r.module)),i=r.themeType),e?.fallback?t.push(su.of(r)):i?t.push(po.computeN([G.darkTheme],n=>n.facet(G.darkTheme)==(i=="dark")?[r]:[])):t.push(po.of(r)),t}class mm{constructor(e){this.markCache=Object.create(null),this.tree=ct(e.state),this.decorations=this.buildDeco(e,As(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=ct(e.state),i=As(e.state),n=i!=As(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<s.to&&!n&&t.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||n)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return de.none;let i=new Ci;for(let{from:n,to:s}of e.visibleRanges)Wg(this.tree,t,(o,l,h)=>{i.add(o,l,this.markCache[h]||(this.markCache[h]=de.mark({class:h})))},n,s);return i.finish()}}const vm=rn.high(wt.fromClass(mm,{decorations:r=>r.decorations})),ey=jr.define([{tag:$.meta,color:"#404740"},{tag:$.link,textDecoration:"underline"},{tag:$.heading,textDecoration:"underline",fontWeight:"bold"},{tag:$.emphasis,fontStyle:"italic"},{tag:$.strong,fontWeight:"bold"},{tag:$.strikethrough,textDecoration:"line-through"},{tag:$.keyword,color:"#708"},{tag:[$.atom,$.bool,$.url,$.contentSeparator,$.labelName],color:"#219"},{tag:[$.literal,$.inserted],color:"#164"},{tag:[$.string,$.deleted],color:"#a11"},{tag:[$.regexp,$.escape,$.special($.string)],color:"#e40"},{tag:$.definition($.variableName),color:"#00f"},{tag:$.local($.variableName),color:"#30a"},{tag:[$.typeName,$.namespace],color:"#085"},{tag:$.className,color:"#167"},{tag:[$.special($.variableName),$.macroName],color:"#256"},{tag:$.definition($.propertyName),color:"#00c"},{tag:$.comment,color:"#940"},{tag:$.invalid,color:"#f00"}]),ym=1e4,km="()[]{}",xm=new se;function go(r,e,t){let i=r.prop(e<0?se.openedBy:se.closedBy);if(i)return i;if(r.name.length==1){let n=t.indexOf(r.name);if(n>-1&&n%2==(e<0?1:0))return[t[n+e]]}return null}function mo(r){let e=r.type.prop(xm);return e?e(r.node):r}function ai(r,e,t,i={}){let n=i.maxScanDistance||ym,s=i.brackets||km,o=ct(r),l=o.resolveInner(e,t);for(let h=l;h;h=h.parent){let u=go(h.type,t,s);if(u&&h.from<h.to){let p=mo(h);if(p&&(t>0?e>=p.from&&e<p.to:e>p.from&&e<=p.to))return wm(r,e,t,h,p,u,s)}}return bm(r,e,t,o,l.type,n,s)}function wm(r,e,t,i,n,s,o){let l=i.parent,h={from:n.from,to:n.to},u=0,p=l?.cursor();if(p&&(t<0?p.childBefore(i.from):p.childAfter(i.to)))do if(t<0?p.to<=i.from:p.from>=i.to){if(u==0&&s.indexOf(p.type.name)>-1&&p.from<p.to){let m=mo(p);return{start:h,end:m?{from:m.from,to:m.to}:void 0,matched:!0}}else if(go(p.type,t,o))u++;else if(go(p.type,-t,o)){if(u==0){let m=mo(p);return{start:h,end:m&&m.from<m.to?{from:m.from,to:m.to}:void 0,matched:!1}}u--}}while(t<0?p.prevSibling():p.nextSibling());return{start:h,matched:!1}}function bm(r,e,t,i,n,s,o){if(t<0?!e:e==r.doc.length)return null;let l=t<0?r.sliceDoc(e-1,e):r.sliceDoc(e,e+1),h=o.indexOf(l);if(h<0||h%2==0!=t>0)return null;let u={from:t<0?e-1:e,to:t>0?e+1:e},p=r.doc.iterRange(e,t>0?r.doc.length:0),m=0;for(let y=0;!p.next().done&&y<=s;){let x=p.value;t<0&&(y+=x.length);let S=e+y*t;for(let C=t>0?0:x.length-1,O=t>0?x.length:-1;C!=O;C+=t){let B=o.indexOf(x[C]);if(!(B<0||i.resolveInner(S+C,1).type!=n))if(B%2==0==t>0)m++;else{if(m==1)return{start:u,end:{from:S+C,to:S+C+1},matched:B>>1==h>>1};m--}}t>0&&(y+=x.length)}return p.done?{start:u,matched:!1}:null}function Ja(r,e,t,i=0,n=0){e==null&&(e=r.search(/[^\s\u00a0]/),e==-1&&(e=r.length));let s=n;for(let o=i;o<e;o++)r.charCodeAt(o)==9?s+=t-s%t:s++;return s}class Sm{constructor(e,t,i,n){this.string=e,this.tabSize=t,this.indentUnit=i,this.overrideIndent=n,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(e){let t=this.string.charAt(this.pos),i;if(typeof e=="string"?i=t==e:i=t&&(e instanceof RegExp?e.test(t):e(t)),i)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Ja(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var e;return(e=this.overrideIndent)!==null&&e!==void 0?e:Ja(this.string,null,this.tabSize)}match(e,t,i){if(typeof e=="string"){let n=o=>i?o.toLowerCase():o,s=this.string.substr(this.pos,e.length);return n(s)==n(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}}current(){return this.string.slice(this.start,this.pos)}}const Cm=Object.create(null),Ga=[rt.none],Ya=[],Qa=Object.create(null),Am=Object.create(null);for(let[r,e]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"]])Am[r]=Mm(Cm,e);function Ms(r,e){Ya.indexOf(r)>-1||(Ya.push(r),console.warn(e))}function Mm(r,e){let t=[];for(let l of e.split(" ")){let h=[];for(let u of l.split(".")){let p=r[u]||$[u];p?typeof p=="function"?h.length?h=h.map(p):Ms(u,`Modifier ${u} used at start of tag`):h.length?Ms(u,`Tag ${u} used as modifier`):h=Array.isArray(p)?p:[p]:Ms(u,`Unknown highlighting tag ${u}`)}for(let u of h)t.push(u)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),n=i+" "+t.map(l=>l.id),s=Qa[n];if(s)return s.id;let o=Qa[n]=rt.define({id:Ga.length,name:i,props:[Fg({[i]:t})]});return Ga.push(o),o.id}Ce.RTL,Ce.LTR;const Tm=r=>{let{state:e}=r,t=e.doc.lineAt(e.selection.main.from),i=Uo(r.state,t.from);return i.line?ou(r):i.block?Lm(r):!1};function qo(r,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let n=r(e,t);return n?(i(t.update(n)),!0):!1}}const ou=qo(Rm,0),Om=qo(lu,0),Lm=qo((r,e)=>lu(r,e,Dm(e)),0);function Uo(r,e){let t=r.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const pn=50;function Bm(r,{open:e,close:t},i,n){let s=r.sliceDoc(i-pn,i),o=r.sliceDoc(n,n+pn),l=/\s*$/.exec(s)[0].length,h=/^\s*/.exec(o)[0].length,u=s.length-l;if(s.slice(u-e.length,u)==e&&o.slice(h,h+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:n+h,margin:h&&1}};let p,m;n-i<=2*pn?p=m=r.sliceDoc(i,n):(p=r.sliceDoc(i,i+pn),m=r.sliceDoc(n-pn,n));let y=/^\s*/.exec(p)[0].length,x=/\s*$/.exec(m)[0].length,S=m.length-x-t.length;return p.slice(y,y+e.length)==e&&m.slice(S,S+t.length)==t?{open:{pos:i+y+e.length,margin:/\s/.test(p.charAt(y+e.length))?1:0},close:{pos:n-x-t.length,margin:/\s/.test(m.charAt(S-1))?1:0}}:null}function Dm(r){let e=[];for(let t of r.selection.ranges){let i=r.doc.lineAt(t.from),n=t.to<=i.to?i:r.doc.lineAt(t.to);n.from>i.from&&n.from==t.to&&(n=t.to==i.to+1?i:r.doc.lineAt(t.to-1));let s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=n.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:n.to})}return e}function lu(r,e,t=e.selection.ranges){let i=t.map(s=>Uo(e,s.from).block);if(!i.every(s=>s))return null;let n=t.map((s,o)=>Bm(e,i[o],s.from,s.to));if(r!=2&&!n.every(s=>s))return{changes:e.changes(t.map((s,o)=>n[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(r!=1&&n.some(s=>s)){let s=[];for(let o=0,l;o<n.length;o++)if(l=n[o]){let h=i[o],{open:u,close:p}=l;s.push({from:u.pos-h.open.length,to:u.pos+u.margin},{from:p.pos-p.margin,to:p.pos+h.close.length})}return{changes:s}}return null}function Rm(r,e,t=e.selection.ranges){let i=[],n=-1;e:for(let{from:s,to:o}of t){let l=i.length,h=1e9,u;for(let p=s;p<=o;){let m=e.doc.lineAt(p);if(u==null&&(u=Uo(e,m.from).line,!u))continue e;if(m.from>n&&(s==o||o>m.from)){n=m.from;let y=/^\s*/.exec(m.text)[0].length,x=y==m.length,S=m.text.slice(y,y+u.length)==u?y:-1;y<m.text.length&&y<h&&(h=y),i.push({line:m,comment:S,token:u,indent:y,empty:x,single:!1})}p=m.to+1}if(h<1e9)for(let p=l;p<i.length;p++)i[p].indent<i[p].line.text.length&&(i[p].indent=h);i.length==l+1&&(i[l].single=!0)}if(r!=2&&i.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:h,indent:u,empty:p,single:m}of i)(m||!p)&&s.push({from:l.from+u,insert:h+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(r!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:h}of i)if(l>=0){let u=o.from+l,p=u+h.length;o.text[p-o.from]==" "&&p++,s.push({from:u,to:p})}return{changes:s}}return null}const vo=Zt.define(),Em=Zt.define(),Im=j.define(),au=j.define({combine(r){return Fr(r,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,n)=>e(i,n)||t(i,n)})}}),hu=Ot.define({create(){return jt.empty},update(r,e){let t=e.state.facet(au),i=e.annotation(vo);if(i){let h=at.fromTransaction(e,i.selection),u=i.side,p=u==0?r.undone:r.done;return h?p=Br(p,p.length,t.minDepth,h):p=uu(p,e.startState.selection),new jt(u==0?i.rest:p,u==0?p:i.rest)}let n=e.annotation(Em);if((n=="full"||n=="before")&&(r=r.isolate()),e.annotation(Ee.addToHistory)===!1)return e.changes.empty?r:r.addMapping(e.changes.desc);let s=at.fromTransaction(e),o=e.annotation(Ee.time),l=e.annotation(Ee.userEvent);return s?r=r.addChanges(s,o,l,t,e):e.selection&&(r=r.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(n=="full"||n=="after")&&(r=r.isolate()),r},toJSON(r){return{done:r.done.map(e=>e.toJSON()),undone:r.undone.map(e=>e.toJSON())}},fromJSON(r){return new jt(r.done.map(at.fromJSON),r.undone.map(at.fromJSON))}});function ty(r={}){return[hu,au.of(r),G.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?Jo:e.inputType=="historyRedo"?Lr:null;return i?(e.preventDefault(),i(t)):!1}})]}function qr(r,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let n=t.field(hu,!1);if(!n)return!1;let s=n.pop(r,t,e);return s?(i(s),!0):!1}}const Jo=qr(0,!1),Lr=qr(1,!1),Pm=qr(0,!0),Nm=qr(1,!0);class at{constructor(e,t,i,n,s){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=n,this.selectionsAfter=s}setSelAfter(e){return new at(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(n=>n.toJSON())}}static fromJSON(e){return new at(e.changes&&Ie.fromJSON(e.changes),[],e.mapped&&qt.fromJSON(e.mapped),e.startSelection&&I.fromJSON(e.startSelection),e.selectionsAfter.map(I.fromJSON))}static fromTransaction(e,t){let i=xt;for(let n of e.startState.facet(Im)){let s=n(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new at(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,xt)}static selection(e){return new at(void 0,xt,void 0,void 0,e)}}function Br(r,e,t,i){let n=e+1>t+20?e-t-1:0,s=r.slice(n,e);return s.push(i),s}function Fm(r,e){let t=[],i=!1;return r.iterChangedRanges((n,s)=>t.push(n,s)),e.iterChangedRanges((n,s,o,l)=>{for(let h=0;h<t.length;){let u=t[h++],p=t[h++];l>=u&&o<=p&&(i=!0)}}),i}function Hm(r,e){return r.ranges.length==e.ranges.length&&r.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function fu(r,e){return r.length?e.length?r.concat(e):r:e}const xt=[],Wm=200;function uu(r,e){if(r.length){let t=r[r.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-Wm));return i.length&&i[i.length-1].eq(e)?r:(i.push(e),Br(r,r.length-1,1e9,t.setSelAfter(i)))}else return[at.selection([e])]}function Vm(r){let e=r[r.length-1],t=r.slice();return t[r.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Ts(r,e){if(!r.length)return r;let t=r.length,i=xt;for(;t;){let n=Km(r[t-1],e,i);if(n.changes&&!n.changes.empty||n.effects.length){let s=r.slice(0,t);return s[t-1]=n,s}else e=n.mapped,t--,i=n.selectionsAfter}return i.length?[at.selection(i)]:xt}function Km(r,e,t){let i=fu(r.selectionsAfter.length?r.selectionsAfter.map(l=>l.map(e)):xt,t);if(!r.changes)return at.selection(i);let n=r.changes.map(e),s=e.mapDesc(r.changes,!0),o=r.mapped?r.mapped.composeDesc(s):s;return new at(n,me.mapEffects(r.effects,e),o,r.startSelection.map(s),i)}const zm=/^(input\.type|delete)($|\.)/;class jt{constructor(e,t,i=0,n=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new jt(this.done,this.undone):this}addChanges(e,t,i,n,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||zm.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<n.newGroupDelay&&n.joinToEvent(s,Fm(l.changes,e.changes))||i=="input.type.compose")?o=Br(o,o.length-1,n.minDepth,new at(e.changes.compose(l.changes),fu(me.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,xt)):o=Br(o,o.length,n.minDepth,e),new jt(o,xt,t,i)}addSelection(e,t,i,n){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:xt;return s.length>0&&t-this.prevTime<n&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&Hm(s[s.length-1],e)?this:new jt(uu(this.done,e),this.undone,t,i)}addMapping(e){return new jt(Ts(this.done,e),Ts(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let n=e==0?this.done:this.undone;if(n.length==0)return null;let s=n[n.length-1],o=s.selectionsAfter[0]||(s.startSelection?s.startSelection.map(s.changes.invertedDesc,1):t.selection);if(i&&s.selectionsAfter.length)return t.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:vo.of({side:e,rest:Vm(n),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=n.length==1?xt:n.slice(0,n.length-1);return s.mapped&&(l=Ts(l,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:vo.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}jt.empty=new jt(xt,xt);const iy=[{key:"Mod-z",run:Jo,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Lr,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Lr,preventDefault:!0},{key:"Mod-u",run:Pm,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Nm,preventDefault:!0}];function sn(r,e){return I.create(r.ranges.map(e),r.mainIndex)}function Lt(r,e){return r.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Bt({state:r,dispatch:e},t){let i=sn(r.selection,t);return i.eq(r.selection,!0)?!1:(e(Lt(r,i)),!0)}function Ur(r,e){return I.cursor(e?r.to:r.from)}function Go(r,e){return Bt(r,t=>t.empty?r.moveByChar(t,e):Ur(t,e))}function Qe(r){return r.textDirectionAt(r.state.selection.main.head)==Ce.LTR}const Yo=r=>Go(r,!Qe(r)),cu=r=>Go(r,Qe(r)),$m=r=>Go(r,!1);function du(r,e){return Bt(r,t=>t.empty?r.moveByGroup(t,e):Ur(t,e))}const _m=r=>du(r,!Qe(r)),jm=r=>du(r,Qe(r));function qm(r,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(r.sliceDoc(e.from,e.to)))||e.firstChild}function Jr(r,e,t){let i=ct(r).resolveInner(e.head),n=t?se.closedBy:se.openedBy;for(let h=e.head;;){let u=t?i.childAfter(h):i.childBefore(h);if(!u)break;qm(r,u,n)?i=u:h=t?u.to:u.from}let s=i.type.prop(n),o,l;return s&&(o=t?ai(r,i.from,1):ai(r,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,I.cursor(l,t?-1:1)}const Um=r=>Bt(r,e=>Jr(r.state,e,!Qe(r))),Jm=r=>Bt(r,e=>Jr(r.state,e,Qe(r)));function pu(r,e){return Bt(r,t=>{if(!t.empty)return Ur(t,e);let i=r.moveVertically(t,e);return i.head!=t.head?i:r.moveToLineBoundary(t,e)})}const gu=r=>pu(r,!1),mu=r=>pu(r,!0);function vu(r){let e=r.scrollDOM.clientHeight<r.scrollDOM.scrollHeight-2,t=0,i=0,n;if(e){for(let s of r.state.facet(G.scrollMargins)){let o=s(r);o?.top&&(t=Math.max(o?.top,t)),o?.bottom&&(i=Math.max(o?.bottom,i))}n=r.scrollDOM.clientHeight-t-i}else n=(r.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(r.defaultLineHeight,n-5)}}function yu(r,e){let t=vu(r),{state:i}=r,n=sn(i.selection,o=>o.empty?r.moveVertically(o,e,t.height):Ur(o,e));if(n.eq(i.selection))return!1;let s;if(t.selfScroll){let o=r.coordsAtPos(i.selection.main.head),l=r.scrollDOM.getBoundingClientRect(),h=l.top+t.marginTop,u=l.bottom-t.marginBottom;o&&o.top>h&&o.bottom<u&&(s=G.scrollIntoView(n.main.head,{y:"start",yMargin:o.top-h}))}return r.dispatch(Lt(i,n),{effects:s}),!0}const Xa=r=>yu(r,!1),yo=r=>yu(r,!0);function gi(r,e,t){let i=r.lineBlockAt(e.head),n=r.moveToLineBoundary(e,t);if(n.head==e.head&&n.head!=(t?i.to:i.from)&&(n=r.moveToLineBoundary(e,t,!1)),!t&&n.head==i.from&&i.length){let s=/^\s*/.exec(r.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(n=I.cursor(i.from+s))}return n}const ku=r=>Bt(r,e=>gi(r,e,!0)),xu=r=>Bt(r,e=>gi(r,e,!1)),Gm=r=>Bt(r,e=>gi(r,e,!Qe(r))),Ym=r=>Bt(r,e=>gi(r,e,Qe(r))),Qm=r=>Bt(r,e=>r.moveToLineBoundary(e,!1,!1)),Xm=r=>Bt(r,e=>r.moveToLineBoundary(e,!0,!1));function Zm(r,e,t){let i=!1,n=sn(r.selection,s=>{let o=ai(r,s.head,-1)||ai(r,s.head,1)||s.head>0&&ai(r,s.head-1,1)||s.head<r.doc.length&&ai(r,s.head+1,-1);if(!o||!o.end)return s;i=!0;let l=o.start.from==s.head?o.end.to:o.end.from;return I.cursor(l)});return i?(e(Lt(r,n)),!0):!1}const e0=({state:r,dispatch:e})=>Zm(r,e);function bt(r,e,t){let i=sn(r.state.selection,n=>{n.undirectional&&n.head>=n.anchor!=e&&(n=I.range(n.head,n.anchor));let s=t(n);return I.range(n.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return i.eq(r.state.selection)?!1:(r.dispatch(Lt(r.state,i)),!0)}function wu(r,e){return bt(r,e,t=>r.moveByChar(t,e))}const bu=r=>wu(r,!Qe(r)),Su=r=>wu(r,Qe(r));function Cu(r,e){return bt(r,e,t=>r.moveByGroup(t,e))}const t0=r=>Cu(r,!Qe(r)),i0=r=>Cu(r,Qe(r)),n0=r=>{let e=!Qe(r);return bt(r,e,t=>Jr(r.state,t,e))},r0=r=>{let e=Qe(r);return bt(r,e,t=>Jr(r.state,t,e))};function Au(r,e){return bt(r,e,t=>r.moveVertically(t,e))}const Mu=r=>Au(r,!1),Tu=r=>Au(r,!0);function Ou(r,e){return bt(r,e,t=>r.moveVertically(t,e,vu(r).height))}const Za=r=>Ou(r,!1),eh=r=>Ou(r,!0),s0=r=>bt(r,!0,e=>gi(r,e,!0)),o0=r=>bt(r,!1,e=>gi(r,e,!1)),l0=r=>{let e=!Qe(r);return bt(r,e,t=>gi(r,t,e))},a0=r=>{let e=Qe(r);return bt(r,e,t=>gi(r,t,e))},h0=r=>bt(r,!1,e=>I.cursor(r.lineBlockAt(e.head).from)),f0=r=>bt(r,!0,e=>I.cursor(r.lineBlockAt(e.head).to)),th=({state:r,dispatch:e})=>(e(Lt(r,{anchor:0})),!0),ih=({state:r,dispatch:e})=>(e(Lt(r,{anchor:r.doc.length})),!0),nh=({state:r,dispatch:e})=>(e(Lt(r,{anchor:r.selection.main.anchor,head:0})),!0),rh=({state:r,dispatch:e})=>(e(Lt(r,{anchor:r.selection.main.anchor,head:r.doc.length})),!0),u0=({state:r,dispatch:e})=>(e(r.update({selection:{anchor:0,head:r.doc.length},userEvent:"select"})),!0),c0=({state:r,dispatch:e})=>{let t=Gr(r).map(({from:i,to:n})=>I.undirectionalRange(i,Math.min(n+1,r.doc.length)));return e(r.update({selection:I.create(t),userEvent:"select"})),!0},d0=({state:r,dispatch:e})=>{let t=sn(r.selection,i=>{let n=ct(r),s=n.resolveStack(i.from,1);if(i.empty){let o=n.resolveStack(i.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&o.next)return I.undirectionalRange(l.from,l.to)}return i});return t.eq(r.selection)?!1:(e(Lt(r,t)),!0)};function Lu(r,e){let{state:t}=r,i=t.selection,n=t.selection.ranges.slice();for(let s of t.selection.ranges){let o=t.doc.lineAt(s.head);if(e?o.to<r.state.doc.length:o.from>0)for(let l=s;;){let h=r.moveVertically(l,e);if(h.head<o.from||h.head>o.to){n.some(u=>u.head==h.head)||n.push(h);break}else{if(h.head==l.head)break;l=h}}}return n.length==i.ranges.length?!1:(r.dispatch(Lt(t,I.create(n,n.length-1))),!0)}const p0=r=>Lu(r,!1),g0=r=>Lu(r,!0),m0=({state:r,dispatch:e})=>{let t=r.selection,i=null;return t.ranges.length>1?i=I.create([t.main]):t.main.empty||(i=I.create([I.cursor(t.main.head)])),i?(e(Lt(r,i)),!0):!1};function Wn(r,e){if(r.state.readOnly)return!1;let t="delete.selection",{state:i}=r,n=i.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let h=e(s);h<o?(t="delete.backward",h=or(r,h,!1)):h>o&&(t="delete.forward",h=or(r,h,!0)),o=Math.min(o,h),l=Math.max(l,h)}else o=or(r,o,!1),l=or(r,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:I.cursor(o,o<s.head?-1:1)}});return n.changes.empty?!1:(r.dispatch(i.update(n,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?G.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function or(r,e,t){if(r instanceof G)for(let i of r.state.facet(G.atomicRanges).map(n=>n(r)))i.between(e,e,(n,s)=>{n<e&&s>e&&(e=t?s:n)});return e}const Bu=(r,e,t)=>Wn(r,i=>{let n=i.from,{state:s}=r,o=s.doc.lineAt(n),l,h;if(t&&!e&&n>o.from&&n<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,n-o.from))){if(l[l.length-1]==" ")return n-1;let u=Hr(l,s.tabSize),p=u%Or(s)||Or(s);for(let m=0;m<p&&l[l.length-1-m]==" ";m++)n--;h=n}else h=Ne(o.text,n-o.from,e,e)+o.from,h==n&&o.number!=(e?s.doc.lines:1)?h+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(h-o.from,n-o.from))&&(h=Ne(o.text,h-o.from,!1,!1)+o.from);return h}),ko=r=>Bu(r,!1,!0),Du=r=>Bu(r,!0,!1),Ru=(r,e)=>Wn(r,t=>{let i=t.head,{state:n}=r,s=n.doc.lineAt(i),o=n.charCategorizer(i);for(let l=null;;){if(i==(e?s.to:s.from)){i==t.head&&s.number!=(e?n.doc.lines:1)&&(i+=e?1:-1);break}let h=Ne(s.text,i-s.from,e)+s.from,u=s.text.slice(Math.min(i,h)-s.from,Math.max(i,h)-s.from),p=o(u);if(l!=null&&p!=l)break;(u!=" "||i!=t.head)&&(l=p),i=h}return i}),Eu=r=>Ru(r,!1),v0=r=>Ru(r,!0),y0=r=>Wn(r,e=>{let t=r.lineBlockAt(e.head).to;return e.head<t?t:Math.min(r.state.doc.length,e.head+1)}),k0=r=>Wn(r,e=>{let t=r.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),x0=r=>Wn(r,e=>{let t=r.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(r.state.doc.length,e.head+1)}),w0=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=r.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:ce.of(["",""])},range:I.cursor(i.from)}));return e(r.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},b0=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=r.changeByRange(i=>{if(!i.empty||i.from==0||i.from==r.doc.length)return{range:i};let n=i.from,s=r.doc.lineAt(n),o=n==s.from?n-1:Ne(s.text,n-s.from,!1)+s.from,l=n==s.to?n+1:Ne(s.text,n-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:r.doc.slice(n,l).append(r.doc.slice(o,n))},range:I.cursor(l)}});return t.changes.empty?!1:(e(r.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Gr(r){let e=[],t=-1;for(let i of r.selection.ranges){let n=r.doc.lineAt(i.from),s=r.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=r.doc.lineAt(i.to-1)),t>=n.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:n.from,to:s.to,ranges:[i]});t=s.number+1}return e}function Iu(r,e,t){if(r.readOnly)return!1;let i=[],n=[];for(let s of Gr(r)){if(t?s.to==r.doc.length:s.from==0)continue;let o=r.doc.lineAt(t?s.to+1:s.from-1),l=o.length+1;if(t){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+r.lineBreak});for(let h of s.ranges)n.push(I.range(Math.min(r.doc.length,h.anchor+l),Math.min(r.doc.length,h.head+l)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:r.lineBreak+o.text});for(let h of s.ranges)n.push(I.range(h.anchor-l,h.head-l))}}return i.length?(e(r.update({changes:i,scrollIntoView:!0,selection:I.create(n,r.selection.mainIndex),userEvent:"move.line"})),!0):!1}const S0=({state:r,dispatch:e})=>Iu(r,e,!1),C0=({state:r,dispatch:e})=>Iu(r,e,!0);function Pu(r,e,t){if(r.readOnly)return!1;let i=[];for(let s of Gr(r))t?i.push({from:s.from,insert:r.doc.slice(s.from,s.to)+r.lineBreak}):i.push({from:s.to,insert:r.lineBreak+r.doc.slice(s.from,s.to)});let n=r.changes(i);return e(r.update({changes:n,selection:r.selection.map(n,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const A0=({state:r,dispatch:e})=>Pu(r,e,!1),M0=({state:r,dispatch:e})=>Pu(r,e,!0),T0=r=>{if(r.state.readOnly)return!1;let{state:e}=r,t=e.changes(Gr(e).map(({from:n,to:s})=>(n>0?n--:s<e.doc.length&&s++,{from:n,to:s}))),i=sn(e.selection,n=>{let s;if(r.lineWrapping){let o=r.lineBlockAt(n.head),l=r.coordsAtPos(n.head,n.assoc||1);l&&(s=o.bottom+r.documentTop-l.bottom+r.defaultLineHeight/2)}return r.moveVertically(n,!0,s)}).map(t);return r.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function O0(r,e){if(/\(\)|\[\]|\{\}/.test(r.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=ct(r).resolveInner(e),i=t.childBefore(e),n=t.childAfter(e),s;return i&&n&&i.to<=e&&n.from>=e&&(s=i.type.prop(se.closedBy))&&s.indexOf(n.name)>-1&&r.doc.lineAt(i.to).from==r.doc.lineAt(n.from).from&&!/\S/.test(r.sliceDoc(i.to,n.from))?{from:i.to,to:n.from}:null}const xo=Nu(!1),L0=Nu(!0);function Nu(r){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(n=>{let{from:s,to:o}=n,l=e.doc.lineAt(s),h=!r&&s==o&&O0(e,s);r&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let u=new _r(e,{simulateBreak:s,simulateDoubleBreak:!!h}),p=$o(u,s);for(p==null&&(p=Hr(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;h?{from:s,to:o}=h:s>l.from&&s<l.from+100&&!/\S/.test(l.text.slice(0,s))&&(s=l.from);let m=["",In(e,p)];return h&&m.push(In(e,u.lineIndent(l.from,-1))),{changes:{from:s,to:o,insert:ce.of(m)},range:I.cursor(s+1+m[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Qo(r,e){let t=-1;return r.changeByRange(i=>{let n=[];for(let o=i.from;o<=i.to;){let l=r.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,n,i),t=l.number),o=l.to+1}let s=r.changes(n);return{changes:n,range:I.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}const Fu=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=Object.create(null),i=new _r(r,{overrideIndentation:s=>{let o=t[s];return o??-1}}),n=Qo(r,(s,o,l)=>{let h=$o(i,s.from);if(h==null)return;/\S/.test(s.text)||(h=0);let u=/^\s*/.exec(s.text)[0],p=In(r,h);(u!=p||l.from<s.from+u.length)&&(t[s.from]=h,o.push({from:s.from,to:s.from+u.length,insert:p}))});return n.changes.empty||e(r.update(n,{userEvent:"indent"})),!0},Xo=({state:r,dispatch:e})=>r.readOnly?!1:(e(r.update(Qo(r,(t,i)=>{i.push({from:t.from,insert:r.facet(nn)})}),{userEvent:"input.indent"})),!0),Zo=({state:r,dispatch:e})=>r.readOnly?!1:(e(r.update(Qo(r,(t,i)=>{let n=/^\s*/.exec(t.text)[0];if(!n)return;let s=Hr(n,r.tabSize),o=0,l=In(r,Math.max(0,s-Or(r)));for(;o<n.length&&o<l.length&&n.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+n.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),B0=r=>(r.setTabFocusMode(),!0),D0=[{key:"Ctrl-b",run:Yo,shift:bu,preventDefault:!0},{key:"Ctrl-f",run:cu,shift:Su},{key:"Ctrl-p",run:gu,shift:Mu},{key:"Ctrl-n",run:mu,shift:Tu},{key:"Ctrl-a",run:Qm,shift:h0},{key:"Ctrl-e",run:Xm,shift:f0},{key:"Ctrl-d",run:Du},{key:"Ctrl-h",run:ko},{key:"Ctrl-k",run:y0},{key:"Ctrl-Alt-h",run:Eu},{key:"Ctrl-o",run:w0},{key:"Ctrl-t",run:b0},{key:"Ctrl-v",run:yo}],R0=[{key:"ArrowLeft",run:Yo,shift:bu,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:_m,shift:t0,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Gm,shift:l0,preventDefault:!0},{key:"ArrowRight",run:cu,shift:Su,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:jm,shift:i0,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Ym,shift:a0,preventDefault:!0},{key:"ArrowUp",run:gu,shift:Mu,preventDefault:!0},{mac:"Cmd-ArrowUp",run:th,shift:nh},{mac:"Ctrl-ArrowUp",run:Xa,shift:Za},{key:"ArrowDown",run:mu,shift:Tu,preventDefault:!0},{mac:"Cmd-ArrowDown",run:ih,shift:rh},{mac:"Ctrl-ArrowDown",run:yo,shift:eh},{key:"PageUp",run:Xa,shift:Za},{key:"PageDown",run:yo,shift:eh},{key:"Home",run:xu,shift:o0,preventDefault:!0},{key:"Mod-Home",run:th,shift:nh},{key:"End",run:ku,shift:s0,preventDefault:!0},{key:"Mod-End",run:ih,shift:rh},{key:"Enter",run:xo,shift:xo},{key:"Mod-a",run:u0},{key:"Backspace",run:ko,shift:ko,preventDefault:!0},{key:"Delete",run:Du,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Eu,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:v0,preventDefault:!0},{mac:"Mod-Backspace",run:k0,preventDefault:!0},{mac:"Mod-Delete",run:x0,preventDefault:!0}].concat(D0.map(r=>({mac:r.key,run:r.run,shift:r.shift}))),ny=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Um,shift:n0},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Jm,shift:r0},{key:"Alt-ArrowUp",run:S0},{key:"Shift-Alt-ArrowUp",run:A0},{key:"Alt-ArrowDown",run:C0},{key:"Shift-Alt-ArrowDown",run:M0},{key:"Mod-Alt-ArrowUp",run:p0},{key:"Mod-Alt-ArrowDown",run:g0},{key:"Escape",run:m0},{key:"Mod-Enter",run:L0},{key:"Alt-l",mac:"Ctrl-l",run:c0},{key:"Mod-i",run:d0,preventDefault:!0},{key:"Mod-[",run:Zo},{key:"Mod-]",run:Xo},{key:"Mod-Alt-\\",run:Fu},{key:"Shift-Mod-k",run:T0},{key:"Shift-Mod-\\",run:e0},{key:"Mod-/",run:Tm},{key:"Alt-A",mac:"Ctrl-A",run:Om},{key:"Ctrl-m",mac:"Shift-Alt-m",run:B0}].concat(R0),ry={key:"Tab",run:Xo,shift:Zo};class sy{constructor(e,t,i,n){this.state=e,this.pos=t,this.explicit=i,this.view=n,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=ct(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),n=t.text.slice(i-t.from,this.pos-t.from),s=n.search(I0(e));return s<0?null:{from:i+s,to:this.pos,text:n.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function sh(r){let e=Object.keys(r).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function E0(r){let e=Object.create(null),t=Object.create(null);for(let{label:n}of r){e[n[0]]=!0;for(let s=1;s<n.length;s++)t[n[s]]=!0}let i=sh(e)+sh(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function oy(r){let e=r.map(n=>typeof n=="string"?{label:n}:n),[t,i]=e.every(n=>/^\w+$/.test(n.label))?[/\w*$/,/\w+$/]:E0(e);return n=>{let s=n.matchBefore(i);return s||n.explicit?{from:s?s.from:n.pos,options:e,validFor:t}:null}}function ly(r,e){return t=>{for(let i=ct(t.state).resolveInner(t.pos,-1);i;i=i.parent){if(r.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(t)}}function I0(r,e){var t;let{source:i}=r,n=i[i.length-1]!="$";return n?new RegExp(`(?:${i})${n?"$":""}`,(t=r.flags)!==null&&t!==void 0?t:r.ignoreCase?"i":""):r}const P0=Zt.define(),N0=G.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class F0{constructor(e,t,i,n){this.field=e,this.line=t,this.from=i,this.to=n}}class el{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,_e.TrackDel),i=e.mapPos(this.to,1,_e.TrackDel);return t==null||i==null?null:new el(this.field,t,i)}}class tl{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],n=[t],s=e.doc.lineAt(t),o=/^\s*/.exec(s.text)[0];for(let h of this.lines){if(i.length){let u=o,p=/^\t*/.exec(h)[0].length;for(let m=0;m<p;m++)u+=e.facet(nn);n.push(t+u.length-p),h=u+h.slice(p)}i.push(h),t+=h.length+1}let l=this.fieldPositions.map(h=>new el(h.field,n[h.line]+h.from,n[h.line]+h.to));return{text:i,ranges:l}}static parse(e){let t=[],i=[],n=[],s;for(let o of e.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o);){let l=s[1]?+s[1]:null,h=s[2]||s[3]||"",u=-1;l===0&&(l=1e9);let p=h.replace(/\\[{}]/g,m=>m[1]);for(let m=0;m<t.length;m++)(l!=null?t[m].seq==l:p&&t[m].name==p)&&(u=m);if(u<0){let m=0;for(;m<t.length&&(l==null||t[m].seq!=null&&t[m].seq<l);)m++;t.splice(m,0,{seq:l,name:p}),u=m;for(let y of n)y.field>=u&&y.field++}for(let m of n)if(m.line==i.length&&m.from>s.index){let y=s[2]?3+(s[1]||"").length:2;m.from-=y,m.to-=y}n.push(new F0(u,i.length,s.index,s.index+p.length)),o=o.slice(0,s.index)+h+o.slice(s.index+s[0].length)}o=o.replace(/\\([{}])/g,(l,h,u)=>{for(let p of n)p.line==i.length&&p.from>u&&(p.from--,p.to--);return h}),i.push(o)}return new tl(i,n)}}let H0=de.widget({widget:new class extends pi{toDOM(){let r=document.createElement("span");return r.className="cm-snippetFieldPosition",r}ignoreEvent(){return!1}}}),W0=de.mark({class:"cm-snippetField"});class on{constructor(e,t){this.ranges=e,this.active=t,this.deco=de.set(e.map(i=>(i.from==i.to?H0:W0).range(i.from,i.to)),!0)}map(e){let t=[];for(let i of this.ranges){let n=i.map(e);if(!n)return null;t.push(n)}return new on(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}}const Vn=me.define({map(r,e){return r&&r.map(e)}}),V0=me.define(),Pn=Ot.define({create(){return null},update(r,e){for(let t of e.effects){if(t.is(Vn))return t.value;if(t.is(V0)&&r)return new on(r.ranges,t.value)}return r&&e.docChanged&&(r=r.map(e.changes)),r&&e.selection&&!r.selectionInsideField(e.selection)&&(r=null),r},provide:r=>G.decorations.from(r,e=>e?e.deco:de.none)});function il(r,e){return I.create(r.filter(t=>t.field==e).map(t=>I.range(t.from,t.to)))}function K0(r){let e=tl.parse(r);return(t,i,n,s)=>{let{text:o,ranges:l}=e.instantiate(t.state,n),{main:h}=t.state.selection,u={changes:{from:n,to:s==h.from?h.to:s,insert:ce.of(o)},scrollIntoView:!0,annotations:i?[P0.of(i),Ee.userEvent.of("input.complete")]:void 0};if(l.length&&(u.selection=il(l,0)),l.some(p=>p.field>0)){let p=new on(l,0),m=u.effects=[Vn.of(p)];t.state.field(Pn,!1)===void 0&&m.push(me.appendConfig.of([Pn,q0,U0,N0]))}t.dispatch(t.state.update(u))}}function Hu(r){return({state:e,dispatch:t})=>{let i=e.field(Pn,!1);if(!i||r<0&&i.active==0)return!1;let n=i.active+r,s=r>0&&!i.ranges.some(o=>o.field==n+r);return t(e.update({selection:il(i.ranges,n),effects:Vn.of(s?null:new on(i.ranges,n)),scrollIntoView:!0})),!0}}const z0=({state:r,dispatch:e})=>r.field(Pn,!1)?(e(r.update({effects:Vn.of(null)})),!0):!1,$0=Hu(1),_0=Hu(-1),j0=[{key:"Tab",run:$0,shift:_0},{key:"Escape",run:z0}],oh=j.define({combine(r){return r.length?r[0]:j0}}),q0=rn.highest(Pf.compute([oh],r=>r.facet(oh)));function ay(r,e){return{...e,apply:K0(r)}}const U0=G.domEventHandlers({mousedown(r,e){let t=e.state.field(Pn,!1),i;if(!t||(i=e.posAtCoords({x:r.clientX,y:r.clientY}))==null)return!1;let n=t.ranges.find(s=>s.from<=i&&s.to>=i);return!n||n.field==t.active?!1:(e.dispatch({selection:il(t.ranges,n.field),effects:Vn.of(t.ranges.some(s=>s.field>n.field)?new on(t.ranges,n.field):null),scrollIntoView:!0}),!0)}}),Wu=new class extends hi{};Wu.startSide=1;Wu.endSide=-1;var lh={};class Dr{constructor(e,t,i,n,s,o,l,h,u,p=0,m){this.p=e,this.stack=t,this.state=i,this.reducePos=n,this.pos=s,this.score=o,this.buffer=l,this.bufferBase=h,this.curContext=u,this.lookAhead=p,this.parent=m}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let n=e.parser.context;return new Dr(e,[],t,i,i,0,[],0,n?new ah(n,n.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let i=e>>19,n=e&65535,{parser:s}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),l=s.dynamicPrecedence(n);if(l&&(this.score+=l),i==0){n<s.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(s.getGoto(this.state,n,!0),this.reducePos),n<s.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(n,this.reducePos);return}let h=this.stack.length-(i-1)*3-(e&262144?6:0),u=h?this.stack[h-2]:this.p.ranges[0].from;n<s.minRepeatTerm&&u==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let p=this.reducePos-u;p>=2e3&&!(!((t=this.p.parser.nodeSet.types[n])===null||t===void 0)&&t.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=p):this.p.lastBigReductionSize<p&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=u,this.p.lastBigReductionSize=p));let m=h?this.stack[h-1]:0,y=this.bufferBase+this.buffer.length-m;if(n<s.minRepeatTerm||e&131072){let x=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,u,x,y+4,!0)}if(e&262144)this.state=this.stack[h];else{let x=this.stack[h-3];this.state=s.getGoto(x,n,!0)}for(;this.stack.length>h;)this.stack.pop();this.reduceContext(n,u)}storeNode(e,t,i,n=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this.buffer.length;if(o>0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(t==i)return;if(this.buffer[o-2]>=t){this.buffer[o-2]=i;return}}}if(!s||this.pos==i)this.buffer.push(e,t,i,n);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let h=o;h>0&&this.buffer[h-2]>i;h-=4)if(this.buffer[h-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,n>4&&(n-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=i,this.buffer[o+3]=n}}shift(e,t,i,n){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let s=e,{parser:o}=this.p;this.pos=n;let l=o.stateFlag(s,1);!l&&(n>i||t<=o.maxNode)&&(this.reducePos=n),this.pushState(s,l?i:Math.min(i,this.reducePos)),this.shiftContext(t,i),t<=o.maxNode&&this.buffer.push(t,i,n,4)}else this.pos=n,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,n,4)}apply(e,t,i,n){e&65536?this.reduce(e):this.shift(e,t,i,n)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let n=this.pos;this.reducePos=this.pos=n+e.length,this.pushState(t,n),this.buffer.push(i,n,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(t&&e.buffer[t-4]==0&&(t-=4);t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),n=e.bufferBase+t;for(;e&&n==e.bufferBase;)e=e.parent;return new Dr(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,n,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new J0(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if((i&65536)==0)return!0;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let s=0,o;s<t.length;s+=2)(o=t[s+1])!=this.state&&this.p.parser.hasAction(o,e)&&n.push(t[s],o);if(this.stack.length<120)for(let s=0;n.length<8&&s<t.length;s+=2){let o=t[s+1];n.some((l,h)=>h&1&&l==o)||n.push(t[s],o)}t=n}let i=[];for(let n=0;n<t.length&&i.length<4;n+=2){let s=t[n+1];if(s==this.state)continue;let o=this.split();o.pushState(s,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(t[n],this.pos),o.reducePos=this.pos,o.score-=200,i.push(o)}return i}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if((t&65536)==0)return!1;if(!e.validAction(this.state,t)){let i=t>>19,n=t&65535,s=this.stack.length-i*3;if(s<0||e.getGoto(this.stack[s],n,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],i=(n,s)=>{if(!t.includes(n))return t.push(n),e.allActions(n,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-s;if(l>1){let h=o&65535,u=this.stack.length-l*3;if(u>=0&&e.getGoto(this.stack[u],h,!1)>=0)return l<<19|65536|h}}else{let l=i(o,s+1);if(l!=null)return l}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new ah(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class ah{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class J0{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let n=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=n}}class Rr{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Rr(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Rr(this.stack,this.pos,this.index)}}function vn(r,e=Uint16Array){if(typeof r!="string")return r;let t=null;for(let i=0,n=0;i<r.length;){let s=0;for(;;){let o=r.charCodeAt(i++),l=!1;if(o==126){s=65535;break}o>=92&&o--,o>=34&&o--;let h=o-32;if(h>=46&&(h-=46,l=!0),s+=h,l)break;s*=46}t?t[n++]=s:t=new e(s)}return t}class dr{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const hh=new dr;class G0{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=hh,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,n=this.rangeIndex,s=this.pos+e;for(;s<i.from;){if(!n)return null;let o=this.ranges[--n];s-=i.from-o.to,i=o}for(;t<0?s>i.to:s>=i.to;){if(n==this.ranges.length-1)return null;let o=this.ranges[++n];s+=o.from-i.to,i=o}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,n;if(t>=0&&t<this.chunk.length)i=this.pos+e,n=this.chunk.charCodeAt(t);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(i=s,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)n=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,l=this.range;for(;l.to<=i;)l=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),n=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),n}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=i}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=hh,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let n of this.ranges){if(n.from>=t)break;n.to>e&&(i+=this.input.read(Math.max(n.from,e),Math.min(n.to,t)))}return i}}class Ji{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;Vu(this.data,e,t,this.id,i.data,i.tokenPrecTable)}}Ji.prototype.contextual=Ji.prototype.fallback=Ji.prototype.extend=!1;class Y0{constructor(e,t,i){this.precTable=t,this.elseToken=i,this.data=typeof e=="string"?vn(e):e}token(e,t){let i=e.pos,n=0;for(;;){let s=e.next<0,o=e.resolveOffset(1,1);if(Vu(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(s||n++,o==null)break;e.reset(o,e.token)}n&&(e.reset(i,e.token),e.acceptToken(this.elseToken,n))}}Y0.prototype.contextual=Ji.prototype.fallback=Ji.prototype.extend=!1;class hy{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function Vu(r,e,t,i,n,s){let o=0,l=1<<i,{dialect:h}=t.p.parser;e:for(;(l&r[o])!=0;){let u=r[o+1];for(let x=o+3;x<u;x+=2)if((r[x+1]&l)>0){let S=r[x];if(h.allows(S)&&(e.token.value==-1||e.token.value==S||Q0(S,e.token.value,n,s))){e.acceptToken(S);break}}let p=e.next,m=0,y=r[o+2];if(e.next<0&&y>m&&r[u+y*3-3]==65535){o=r[u+y*3-1];continue e}for(;m<y;){let x=m+y>>1,S=u+x+(x<<1),C=r[S],O=r[S+1]||65536;if(p<C)y=x;else if(p>=O)m=x+1;else{o=r[S+2],e.advance();continue e}}break}}function fh(r,e,t){for(let i=e,n;(n=r[i])!=65535;i++)if(n==t)return i-e;return-1}function Q0(r,e,t,i){let n=fh(t,i,e);return n<0||fh(t,i,r)<n}const ht=typeof process<"u"&&lh&&/\bparse\b/.test(lh.LOG);let Os=null;function uh(r,e,t){let i=r.cursor(ye.IncludeAnonymous);for(i.moveTo(e);;)if(!(t<0?i.childBefore(e):i.childAfter(e)))for(;;){if((t<0?i.to<e:i.from>e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(r.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:r.length}}class X0{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?uh(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?uh(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let i=this.trees[t],n=this.index[t];if(n==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=i.children[n],o=this.start[t]+i.positions[n];if(o>e)return this.nextStart=o,null;if(s instanceof Ae){if(o==e){if(o<this.safeFrom)return null;let l=o+s.length;if(l<=this.safeTo){let h=s.prop(se.lookAhead);if(!h||l+h<this.fragment.to)return s}}this.index[t]++,o+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+s.length}}}class Z0{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new dr)}getActions(e){let t=0,i=null,{parser:n}=e.p,{tokenizers:s}=n,o=n.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,h=0;for(let u=0;u<s.length;u++){if((1<<u&o)==0)continue;let p=s[u],m=this.tokens[u];if(!(i&&!p.fallback)&&((p.contextual||m.start!=e.pos||m.mask!=o||m.context!=l)&&(this.updateCachedToken(m,p,e),m.mask=o,m.context=l),m.lookAhead>m.end+25&&(h=Math.max(m.lookAhead,h)),m.value!=0)){let y=t;if(m.extended>-1&&(t=this.addActions(e,m.extended,m.end,t)),t=this.addActions(e,m.value,m.end,t),!p.extend&&(i=m,t>y))break}}for(;this.actions.length>t;)this.actions.pop();return h&&e.setLookAhead(h),!i&&e.pos==this.stream.end&&(i=new dr,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new dr,{pos:i,p:n}=e;return t.start=i,t.end=Math.min(i+1,n.stream.end),t.value=i==n.stream.end?n.parser.eofTerm:0,t}updateCachedToken(e,t,i){let n=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(n,e),i),e.value>-1){let{parser:s}=i.p;for(let o=0;o<s.specialized.length;o++)if(s.specialized[o]==e.value){let l=s.specializers[o](this.stream.read(e.start,e.end),i);if(l>=0&&i.p.parser.dialect.allows(l>>1)){(l&1)==0?e.value=l>>1:e.extended=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(n+1)}putAction(e,t,i,n){for(let s=0;s<n;s+=3)if(this.actions[s]==e)return n;return this.actions[n++]=e,this.actions[n++]=t,this.actions[n++]=i,n}addActions(e,t,i,n){let{state:s}=e,{parser:o}=e.p,{data:l}=o;for(let h=0;h<2;h++)for(let u=o.stateSlot(s,h?2:1);;u+=3){if(l[u]==65535)if(l[u+1]==1)u=Jt(l,u+2);else{n==0&&l[u+1]==2&&(n=this.putAction(Jt(l,u+2),t,i,n));break}l[u]==t&&(n=this.putAction(Jt(l,u+1),t,i,n))}return n}}class ev{constructor(e,t,i,n){this.parser=e,this.input=t,this.ranges=n,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new G0(t,n),this.tokens=new Z0(e,this.stream),this.topTerm=e.top[1];let{from:s}=n[0];this.stacks=[Dr.start(this,e.top[0],s)],this.fragments=i.length&&this.stream.end-s>e.bufferLength*4?new X0(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],n,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let l=e[o];for(;;){if(this.tokens.mainToken=null,l.pos>t)i.push(l);else{if(this.advanceStack(l,i,e))continue;{n||(n=[],s=[]),n.push(l);let h=this.tokens.getMainToken(l);s.push(h.value,h.end)}}break}}if(!i.length){let o=n&&iv(n);if(o)return ht&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw ht&&n&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&n){let o=this.stoppedAt!=null&&n[0].pos>this.stoppedAt?n[0]:this.runRecovery(n,s,i);if(o)return ht&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,h)=>h.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let o=0;o<i.length-1;o++){let l=i[o];for(let h=o+1;h<i.length;h++){let u=i[h];if(l.sameState(u)||l.buffer.length>500&&u.buffer.length>500)if((l.score-u.score||l.buffer.length-u.buffer.length)>0)i.splice(h--,1);else{i.splice(o--,1);continue e}}}i.length>12&&(i.sort((o,l)=>l.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,i){let n=e.pos,{parser:s}=this,o=ht?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&n>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let u=e.curContext&&e.curContext.tracker.strict,p=u?e.curContext.hash:0;for(let m=this.fragments.nodeAt(n);m;){let y=this.parser.nodeSet.types[m.type.id]==m.type?s.getGoto(e.state,m.type.id):-1;if(y>-1&&m.length&&(!u||(m.prop(se.contextHash)||0)==p))return e.useNode(m,y),ht&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(m.type.id)})`),!0;if(!(m instanceof Ae)||m.children.length==0||m.positions[0]>0)break;let x=m.children[0];if(x instanceof Ae&&m.positions[0]==0)m=x;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),ht&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let h=this.tokens.getActions(e);for(let u=0;u<h.length;){let p=h[u++],m=h[u++],y=h[u++],x=u==h.length||!i,S=x?e:e.split(),C=this.tokens.mainToken;if(S.apply(p,m,C?C.start:S.pos,y),ht&&console.log(o+this.stackID(S)+` (via ${(p&65536)==0?"shift":`reduce of ${s.getName(p&65535)}`} for ${s.getName(m)} @ ${n}${S==e?"":", split"})`),x)return!0;S.pos>n?t.push(S):i.push(S)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return ch(e,t),!0}}runRecovery(e,t,i){let n=null,s=!1;for(let o=0;o<e.length;o++){let l=e[o],h=t[o<<1],u=t[(o<<1)+1],p=ht?this.stackID(l)+" -> ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),ht&&console.log(p+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let m=l.split(),y=p;for(let x=0;x<10&&m.forceReduce()&&(ht&&console.log(y+this.stackID(m)+" (via force-reduce)"),!this.advanceFully(m,i));x++)ht&&(y=this.stackID(m)+" -> ");for(let x of l.recoverByInsert(h))ht&&console.log(p+this.stackID(x)+" (via recover-insert)"),this.advanceFully(x,i);this.stream.end>l.pos?(u==l.pos&&(u++,h=0),l.recoverByDelete(h,u),ht&&console.log(p+this.stackID(l)+` (via recover-delete ${this.parser.getName(h)})`),ch(l,i)):(!n||n.score<m.score)&&(n=m)}return n}stackToTree(e){return e.close(),Ae.build({buffer:Rr.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(Os||(Os=new WeakMap)).get(e);return t||Os.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function ch(r,e){for(let t=0;t<e.length;t++){let i=e[t];if(i.pos==r.pos&&i.sameState(r)){e[t].score<r.score&&(e[t]=r);return}}e.push(r)}class tv{constructor(e,t,i){this.source=e,this.flags=t,this.disabled=i}allows(e){return!this.disabled||this.disabled[e]==0}}const Ls=r=>r;class fy{constructor(e){this.start=e.start,this.shift=e.shift||Ls,this.reduce=e.reduce||Ls,this.reuse=e.reuse||Ls,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class wo extends qf{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let l=0;l<e.repeatNodeCount;l++)t.push("");let i=Object.keys(e.topRules).map(l=>e.topRules[l][1]),n=[];for(let l=0;l<t.length;l++)n.push([]);function s(l,h,u){n[l].push([h,h.deserialize(String(u))])}if(e.nodeProps)for(let l of e.nodeProps){let h=l[0];typeof h=="string"&&(h=se[h]);for(let u=1;u<l.length;){let p=l[u++];if(p>=0)s(p,h,l[u++]);else{let m=l[u+-p];for(let y=-p;y>0;y--)s(l[u++],h,m);u++}}}this.nodeSet=new Wo(t.map((l,h)=>rt.define({name:h>=this.minRepeatTerm?void 0:l,id:h,props:n[h],top:i.indexOf(h)>-1,error:h==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(h)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=zf;let o=vn(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(dh),this.states=vn(e.states,Uint32Array),this.data=vn(e.stateData),this.goto=vn(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new Ji(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let n=new ev(this,e,t,i);for(let s of this.wrappers)n=s(n,e,t,i);return n}getGoto(e,t,i=!1){let n=this.goto;if(t>=n[0])return-1;for(let s=n[t+1];;){let o=n[s++],l=o&1,h=n[s++];if(l&&i)return h;for(let u=s+(o>>1);s<u;s++)if(n[s]==e)return h;if(l)return-1}}hasAction(e,t){let i=this.data;for(let n=0;n<2;n++)for(let s=this.stateSlot(e,n?2:1),o;;s+=3){if((o=i[s])==65535)if(i[s+1]==1)o=i[s=Jt(i,s+2)];else{if(i[s+1]==2)return Jt(i,s+2);break}if(o==t||o==0)return Jt(i,s+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,i=>i==t?!0:null)}allActions(e,t){let i=this.stateSlot(e,4),n=i?t(i):void 0;for(let s=this.stateSlot(e,1);n==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Jt(this.data,s+2);else break;n=t(Jt(this.data,s+1))}return n}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Jt(this.data,i+2);else break;if((this.data[i+2]&1)==0){let n=this.data[i+1];t.some((s,o)=>o&1&&s==n)||t.push(this.data[i],n)}}return t}configure(e){let t=Object.assign(Object.create(wo.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let n=e.tokenizers.find(s=>s.from==i);return n?n.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,n)=>{let s=e.specializers.find(l=>l.from==i.external);if(!s)return i;let o=Object.assign(Object.assign({},i),{external:s.to});return t.specializers[n]=dh(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let s of e.split(" ")){let o=t.indexOf(s);o>=0&&(i[o]=!0)}let n=null;for(let s=0;s<t.length;s++)if(!i[s])for(let o=this.dialects[t[s]],l;(l=this.data[o++])!=65535;)(n||(n=new Uint8Array(this.maxTerm+1)))[l]=1;return new tv(e,i,n)}static deserialize(e){return new wo(e)}}function Jt(r,e){return r[e]|r[e+1]<<16}function iv(r){let e=null;for(let t of r){let i=t.p.stoppedAt;(t.pos==t.p.stream.end||i!=null&&t.pos>i)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function dh(r){if(r.external){let e=r.extend?1:0;return(t,i)=>r.external(t,i)<<1|e}return r.get}function nv(r){var e=r.Pos;function t(a,f,c){if(f.line===c.line&&f.ch>=c.ch-1){var d=a.getLine(f.line),g=d.charCodeAt(f.ch);55296<=g&&g<=55551&&(c.ch+=1)}return{start:f,end:c}}var i=[{keys:"<Left>",type:"keyToKey",toKeys:"h"},{keys:"<Right>",type:"keyToKey",toKeys:"l"},{keys:"<Up>",type:"keyToKey",toKeys:"k"},{keys:"<Down>",type:"keyToKey",toKeys:"j"},{keys:"g<Up>",type:"keyToKey",toKeys:"gk"},{keys:"g<Down>",type:"keyToKey",toKeys:"gj"},{keys:"<Space>",type:"keyToKey",toKeys:"l"},{keys:"<BS>",type:"keyToKey",toKeys:"h"},{keys:"<Del>",type:"keyToKey",toKeys:"x"},{keys:"<C-Space>",type:"keyToKey",toKeys:"W"},{keys:"<C-BS>",type:"keyToKey",toKeys:"B"},{keys:"<S-Space>",type:"keyToKey",toKeys:"w"},{keys:"<S-BS>",type:"keyToKey",toKeys:"b"},{keys:"<C-n>",type:"keyToKey",toKeys:"j"},{keys:"<C-p>",type:"keyToKey",toKeys:"k"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"c",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"VdO",context:"visual"},{keys:"<Home>",type:"keyToKey",toKeys:"0"},{keys:"<End>",type:"keyToKey",toKeys:"$"},{keys:"<PageUp>",type:"keyToKey",toKeys:"<C-b>"},{keys:"<PageDown>",type:"keyToKey",toKeys:"<C-f>"},{keys:"<CR>",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"<Ins>",type:"keyToKey",toKeys:"i",context:"normal"},{keys:"<Ins>",type:"action",action:"toggleOverwrite",context:"insert"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"h",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!1}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!0}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!1}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:"ge",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!1,toJumplist:!0}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!0,toJumplist:!0}},{keys:"(",type:"motion",motion:"moveBySentence",motionArgs:{forward:!1}},{keys:")",type:"motion",motion:"moveBySentence",motionArgs:{forward:!0}},{keys:"<C-f>",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"<C-b>",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"<C-d>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"<C-u>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!1,explicitRepeat:!0}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"g$",type:"motion",motion:"moveToEndOfDisplayLine"},{keys:"g^",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"g0",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,toFirstChar:!0}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0,toJumplist:!0}},{keys:"f<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'<register>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`<register>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0,linewise:!0}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1,linewise:!0}},{keys:"]p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0,matchIndent:!0}},{keys:"[p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:"]<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!1,toJumplist:!0}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:!0},context:"visual"},{keys:"d",type:"operator",operator:"delete"},{keys:"y",type:"operator",operator:"yank"},{keys:"c",type:"operator",operator:"change"},{keys:"=",type:"operator",operator:"indentAuto"},{keys:">",type:"operator",operator:"indent",operatorArgs:{indentRight:!0}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:"g~",type:"operator",operator:"changeCase"},{keys:"gu",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},isEdit:!0},{keys:"gU",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},isEdit:!0},{keys:"gc",type:"operator",operator:"toggleComment",isEdit:!0},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:!0}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:!1,toJumplist:!0}},{keys:"gn",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!0}},{keys:"gN",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!1}},{keys:"gq",type:"operator",operator:"hardWrap"},{keys:"gw",type:"operator",operator:"hardWrap",operatorArgs:{keepCursor:!0}},{keys:"g?",type:"operator",operator:"rot13"},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"D",type:"operator",operator:"delete",operatorArgs:{linewise:!0},context:"visual"},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"expandToLine",motionArgs:{linewise:!0},context:"normal"},{keys:"Y",type:"operator",operator:"yank",operatorArgs:{linewise:!0},context:"visual"},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"C",type:"operator",operator:"change",operatorArgs:{linewise:!0},context:"visual"},{keys:"~",type:"operatorMotion",operator:"changeCase",motion:"moveByCharacters",motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:"normal"},{keys:"~",type:"operator",operator:"changeCase",context:"visual"},{keys:"<C-u>",type:"operatorMotion",operator:"delete",motion:"moveToStartOfLine",context:"insert"},{keys:"<C-w>",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"<C-w>",type:"idle",context:"normal"},{keys:"<C-i>",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"<C-o>",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"<C-e>",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"<C-y>",type:"action",action:"scroll",actionArgs:{forward:!1,linewise:!0}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"endOfSelectedArea"},context:"visual"},{keys:"i",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"gi",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"lastEdit"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"firstNonBlank"},context:"normal"},{keys:"gI",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"bol"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"startOfSelectedArea"},context:"visual"},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:"<C-v>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"<C-q>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:!0},{keys:"gJ",type:"action",action:"joinLines",actionArgs:{keepSpaces:!0},isEdit:!0},{keys:"p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:"P",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:"r<character>",type:"action",action:"replace",isEdit:!0},{keys:"@<register>",type:"action",action:"replayMacro"},{keys:"q<register>",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{replace:!0},context:"normal"},{keys:"R",type:"operator",operator:"change",operatorArgs:{linewise:!0,fullLine:!0},context:"visual",exitVisualBlock:!0},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},context:"visual",isEdit:!0},{keys:"U",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},context:"visual",isEdit:!0},{keys:"<C-r>",type:"action",action:"redo"},{keys:"m<register>",type:"action",action:"setMark"},{keys:'"<register>',type:"action",action:"setRegister"},{keys:"<C-r><register>",type:"action",action:"insertRegister",context:"insert",isEdit:!0},{keys:"<C-o>",type:"action",action:"oneNormalCommand",context:"insert"},{keys:"zz",type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:"z.",type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zt",type:"action",action:"scrollToCursor",actionArgs:{position:"top"}},{keys:"z<CR>",type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zb",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:"z-",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:".",type:"action",action:"repeatLastEdit"},{keys:"<C-a>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"<C-x>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"<C-t>",type:"action",action:"indent",actionArgs:{indentRight:!0},context:"insert"},{keys:"<C-d>",type:"action",action:"indent",actionArgs:{indentRight:!1},context:"insert"},{keys:"a<register>",type:"motion",motion:"textObjectManipulation"},{keys:"i<register>",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:"/",type:"search",searchArgs:{forward:!0,querySrc:"prompt",toJumplist:!0}},{keys:"?",type:"search",searchArgs:{forward:!1,querySrc:"prompt",toJumplist:!0}},{keys:"*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"g*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:"g#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:":",type:"ex"}],n=Object.create(null),s=i.length,o=[{name:"colorscheme",shortName:"colo"},{name:"map"},{name:"imap",shortName:"im"},{name:"nmap",shortName:"nm"},{name:"vmap",shortName:"vm"},{name:"omap",shortName:"om"},{name:"noremap",shortName:"no"},{name:"nnoremap",shortName:"nn"},{name:"vnoremap",shortName:"vn"},{name:"inoremap",shortName:"ino"},{name:"onoremap",shortName:"ono"},{name:"unmap"},{name:"mapclear",shortName:"mapc"},{name:"nmapclear",shortName:"nmapc"},{name:"vmapclear",shortName:"vmapc"},{name:"imapclear",shortName:"imapc"},{name:"omapclear",shortName:"omapc"},{name:"write",shortName:"w"},{name:"undo",shortName:"u"},{name:"redo",shortName:"red"},{name:"set",shortName:"se"},{name:"setlocal",shortName:"setl"},{name:"setglobal",shortName:"setg"},{name:"sort",shortName:"sor"},{name:"substitute",shortName:"s",possiblyAsync:!0},{name:"startinsert",shortName:"start"},{name:"nohlsearch",shortName:"noh"},{name:"yank",shortName:"y"},{name:"put",shortName:"pu"},{name:"delmarks",shortName:"delm"},{name:"marks",excludeFromCommandHistory:!0},{name:"registers",shortName:"reg",excludeFromCommandHistory:!0},{name:"vglobal",shortName:"v"},{name:"delete",shortName:"d"},{name:"join",shortName:"j"},{name:"normal",shortName:"norm"},{name:"global",shortName:"g"}],l=ol("");function h(a){a.setOption("disableInput",!0),a.setOption("showCursorWhenSelecting",!1),r.signal(a,"vim-mode-change",{mode:"normal"}),a.on("cursorActivity",Rl),De(a),r.on(a.getInputField(),"paste",p(a))}function u(a){a.setOption("disableInput",!1),a.off("cursorActivity",Rl),r.off(a.getInputField(),"paste",p(a)),a.state.vim=null,hn&&clearTimeout(hn)}function p(a){var f=a.state.vim;return f.onPasteFn||(f.onPasteFn=function(){f.insertMode||(a.setCursor(Oe(a.getCursor(),0,1)),vi.enterInsertMode(a,{},f))}),f.onPasteFn}var m=/[\d]/,y=[r.isWordChar,function(a){return a&&!r.isWordChar(a)&&!/\s/.test(a)}],x=[function(a){return/\S/.test(a)}],S=["<",">"],C=["-",'"',".",":","_","/","+"],O=/^\w$/,B=/^[A-Z]$/;try{B=new RegExp("^[\\p{Lu}]$","u")}catch{}function F(a,f){return f>=a.firstLine()&&f<=a.lastLine()}function P(a){return/^[a-z]$/.test(a)}function Q(a){return"()[]{}".indexOf(a)!=-1}function W(a){return m.test(a)}function V(a){return B.test(a)}function N(a){return/^\s*$/.test(a)}function re(a){return".?!".indexOf(a)!=-1}function oe(a,f){for(var c=0;c<f.length;c++)if(f[c]==a)return!0;return!1}var ae={};function Z(a,f,c,d,g){if(f===void 0&&!g)throw Error("defaultValue is required unless callback is provided");if(c||(c="string"),ae[a]={type:c,defaultValue:f,callback:g},d)for(var v=0;v<d.length;v++)ae[d[v]]=ae[a];f&&Y(a,f)}function Y(a,f,c,d){var g=ae[a];d=d||{};var v=d.scope;if(!g)return new Error("Unknown option: "+a);if(g.type=="boolean"){if(f&&f!==!0)return new Error("Invalid argument: "+a+"="+f);f!==!1&&(f=!0)}g.callback?(v!=="local"&&g.callback(f,void 0),v!=="global"&&c&&g.callback(f,c)):(v!=="local"&&(g.value=g.type=="boolean"?!!f:f),v!=="global"&&c&&(c.state.vim.options[a]={value:f}))}function ee(a,f,c){var d=ae[a];c=c||{};var g=c.scope;if(!d)return new Error("Unknown option: "+a);if(d.callback){let v=f&&d.callback(void 0,f);return g!=="global"&&v!==void 0?v:g!=="local"?d.callback():void 0}else return(g!=="global"&&f&&f.state.vim.options[a]||g!=="local"&&d||{}).value}Z("filetype",void 0,"string",["ft"],function(a,f){if(f!==void 0)if(a===void 0){let c=f.getOption("mode");return c=="null"?"":c}else{let c=a==""?"null":a;f.setOption("mode",c)}}),Z("textwidth",80,"number",["tw"],function(a,f){if(f!==void 0)if(a===void 0){var c=f.getOption("textwidth");return c}else{var d=Math.round(a);d>1&&f.setOption("textwidth",d)}});var fe=function(){var a=100,f=-1,c=0,d=0,g=new Array(a);function v(b,A,M){var L=f%a,D=g[L];function R(E){var H=++f%a,J=g[H];J&&J.clear(),g[H]=b.setBookmark(E)}if(D){var T=D.find();T&&!pt(T,A)&&R(A)}else R(A);R(M),c=f,d=f-a+1,d<0&&(d=0)}function k(b,A){f+=A,f>c?f=c:f<d&&(f=d);var M=g[(a+f)%a];if(M&&!M.find()){var L=A>0?1:-1,D,R=b.getCursor();do if(f+=L,M=g[(a+f)%a],M&&(D=M.find())&&!pt(R,D))break;while(f<c&&f>d)}return M}function w(b,A){var M=f,L=k(b,A);return f=M,L&&L.find()}return{cachedCursor:void 0,add:v,find:w,move:k}},ge=function(a){return a?{changes:a.changes,expectCursorActivityForChange:a.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};class Fe{constructor(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=ge()}exitMacroRecordMode(){var f=z.macroModeState;f.onRecordingDone&&f.onRecordingDone(),f.onRecordingDone=void 0,f.isRecording=!1}enterMacroRecordMode(f,c){var d=z.registerController.getRegister(c);if(d){if(d.clear(),this.latestRegister=c,f.openDialog){var g=Ct("span",{class:"cm-vim-message"},"recording @"+c);this.onRecordingDone=f.openDialog(g,function(){},{bottom:!0})}this.isRecording=!0}}}function De(a){return a.state.vim||(a.state.vim={inputState:new ll,lastEditInputState:void 0,lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},insertMode:!1,insertModeReturn:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:void 0,sel:{anchor:new e(0,0),head:new e(0,0)},options:{},expectLiteralNext:!1,status:""}),a.state.vim}var z;function Re(){z={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:fe(),macroModeState:new Fe,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new ic({}),searchHistoryController:new al,exCommandHistoryController:new al};for(var a in ae){var f=ae[a];f.value=f.defaultValue}}class Ue{constructor(f,c){this.keyName=f,this.key=c.key,this.ctrlKey=c.ctrlKey,this.altKey=c.altKey,this.metaKey=c.metaKey,this.shiftKey=c.shiftKey}}var Xe,xe={enterVimMode:h,leaveVimMode:u,buildKeyMap:function(){},getRegisterController:function(){return z.registerController},resetVimGlobalState_:Re,getVimGlobalState_:function(){return z},maybeInitVimState_:De,suppressErrorLogging:!1,InsertModeKey:Ue,map:function(a,f,c){st.map(a,f,c)},unmap:function(a,f){return st.unmap(a,f)},noremap:function(a,f,c){st.map(a,f,c,!0)},mapclear:function(a){var f=i.length,c=s,d=i.slice(0,f-c);if(i=i.slice(f-c),a)for(var g=d.length-1;g>=0;g--){var v=d[g];if(a!==v.context)if(v.context)this._mapCommand(v);else{var k=["normal","insert","visual"];for(var w in k)if(k[w]!==a){var b=Object.assign({},v);b.context=k[w],this._mapCommand(b)}}}},langmap:sl,vimKeyFromEvent:ln,setOption:Y,getOption:ee,defineOption:Z,defineEx:function(a,f,c){if(!f)f=a;else if(a.indexOf(f)!==0)throw new Error('(Vim.defineEx) "'+f+'" is not a prefix of "'+a+'", command not registered');Bl[a]=c,st.commandMap_[f]={name:a,shortName:f,type:"api"}},handleKey:function(a,f,c){var d=this.findKey(a,f,c);if(typeof d=="function")return d()},multiSelectHandleKey:jc,findKey:function(a,f,c){var d=De(a),g=a;function v(){var M=z.macroModeState;if(M.isRecording){if(f=="q")return M.exitMacroRecordMode(),Pe(g),!0;c!="mapping"&&zc(M,f)}}function k(){if(f=="<Esc>"){if(d.visualMode)Et(g);else if(d.insertMode)ii(g);else return;return Pe(g),!0}}function w(){if(k())return!0;d.inputState.keyBuffer.push(f);var M=d.inputState.keyBuffer.join(""),L=f.length==1,D=mi.matchCommand(M,i,d.inputState,"insert"),R=d.inputState.changeQueue;if(D.type=="none")return Pe(g),!1;if(D.type=="partial"){if(D.expectLiteralNext&&(d.expectLiteralNext=!0),Xe&&window.clearTimeout(Xe),Xe=L&&window.setTimeout(function(){d.insertMode&&d.inputState.keyBuffer.length&&Pe(g)},ee("insertModeEscKeysTimeout")),L){var T=g.listSelections();(!R||R.removed.length!=T.length)&&(R=d.inputState.changeQueue=new ec),R.inserted+=f;for(var E=0;E<T.length;E++){var H=et(T[E].anchor,T[E].head),J=ti(T[E].anchor,T[E].head),q=g.getRange(H,g.state.overwrite?Oe(J,0,1):J);R.removed[E]=(R.removed[E]||"")+q}}return!L}else D.type=="full"&&(d.inputState.keyBuffer.length=0);if(d.expectLiteralNext=!1,Xe&&window.clearTimeout(Xe),D.command&&R){for(var T=g.listSelections(),E=0;E<T.length;E++){var U=T[E].head;g.replaceRange(R.removed[E]||"",Oe(U,0,-R.inserted.length),U,"+input")}z.macroModeState.lastInsertModeChanges.changes.pop()}return D.command||Pe(g),D.command}function b(){if(v()||k())return!0;d.inputState.keyBuffer.push(f);var M=d.inputState.keyBuffer.join("");if(/^[1-9]\d*$/.test(M))return!0;var L=/^(\d*)(.*)$/.exec(M);if(!L)return Pe(g),!1;var D=d.visualMode?"visual":"normal",R=L[2]||L[1];d.inputState.operatorShortcut&&d.inputState.operatorShortcut.slice(-1)==R&&(R=d.inputState.operatorShortcut);var T=mi.matchCommand(R,i,d.inputState,D);return T.type=="none"?(Pe(g),!1):T.type=="partial"?(T.expectLiteralNext&&(d.expectLiteralNext=!0),!0):T.type=="clear"?(Pe(g),!0):(d.expectLiteralNext=!1,d.inputState.keyBuffer.length=0,L=/^(\d*)(.*)$/.exec(M),L&&L[1]&&L[1]!="0"&&d.inputState.pushRepeatDigit(L[1]),T.command)}var A=d.insertMode?w():b();if(A===!1)return!d.insertMode&&(f.length===1||r.isMac&&/<A-.>/.test(f))?function(){return!0}:void 0;if(A===!0)return function(){return!0};if(A)return function(){return g.operation(function(){g.curOp.isVimOp=!0;try{if(typeof A!="object")return;A.type=="keyToKey"?ei(g,A.toKeys,A):mi.processCommand(g,d,A)}catch(M){throw g.state.vim=void 0,De(g),xe.suppressErrorLogging||console.log(M),M}return!0})}},handleEx:function(a,f){st.processCommand(a,f)},defineMotion:nc,defineAction:sc,defineOperator:rc,mapCommand:Vc,_mapCommand:rs,defineRegister:tc,exitVisualMode:Et,exitInsertMode:ii},He=[],dt=!1,ve;function Di(a){if(!ve)throw new Error("No prompt to send key to");if(a[0]=="<"){var f=a.toLowerCase().slice(1,-1),c=f.split("-");if(f=c.pop()||"",f=="lt")a="<";else if(f=="space")a=" ";else if(f=="cr")a=`
|
|
4
|
+
`){[e,t]=Yi(this,e,t);let n="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let l=this.children[s],h=o+l.length;o>e&&s&&(n+=i),e<h&&t>o&&(n+=l.sliceString(e-o,t-o,i)),o=h+1}return n}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Vt))return 0;let i=0,[n,s,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=t,s+=t){if(n==o||s==l)return i;let h=this.children[n],u=e.children[s];if(h!=u)return i+h.scanIdentical(u,t);i+=h.length+1}}static from(e,t=e.reduce((i,n)=>i+n.length+1,-1)){let i=0;for(let x of e)i+=x.lines;if(i<32){let x=[];for(let S of e)S.flatten(x);return new Be(x,t)}let n=Math.max(32,i>>5),s=n<<1,o=n>>1,l=[],h=0,u=-1,p=[];function m(x){let S;if(x.lines>s&&x instanceof Vt)for(let C of x.children)m(C);else x.lines>o&&(h>o||!h)?(y(),l.push(x)):x instanceof Be&&h&&(S=p[p.length-1])instanceof Be&&x.lines+S.lines<=32?(h+=x.lines,u+=x.length+1,p[p.length-1]=new Be(S.text.concat(x.text),S.length+1+x.length)):(h+x.lines>n&&y(),h+=x.lines,u+=x.length+1,p.push(x))}function y(){h!=0&&(l.push(p.length==1?p[0]:Vt.from(p,u)),u=-1,h=p.length=0)}for(let x of e)m(x);return y(),l.length==1?l[0]:new Vt(l,t)}}ce.empty=new Be([""],0);function Cd(r){let e=-1;for(let t of r)e+=t.length+1;return e}function fr(r,e,t=0,i=1e9){for(let n=0,s=0,o=!0;s<r.length&&n<=i;s++){let l=r[s],h=n+l.length;h>=t&&(h>i&&(l=l.slice(0,i-n)),n<t&&(l=l.slice(t-n)),o?(e[e.length-1]+=l,o=!1):e.push(l)),n=h+1}return e}function sa(r,e,t){return fr(r,[""],e,t)}class kn{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof Be?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],s=this.offsets[i],o=s>>1,l=n instanceof Be?n.text.length:n.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
5
|
+
`,this;e--}else if(n instanceof Be){let h=n.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,h.length>Math.max(0,e))return this.value=e==0?h:t>0?h.slice(e):h.slice(0,h.length-e),this;e-=h.length}else{let h=n.children[o+(t<0?-1:0)];e>h.length?(e-=h.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(h),this.offsets.push(t>0?1:(h instanceof Be?h.text.length:h.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Dh{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new kn(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:n}=this.cursor.next(e);return this.pos+=(n.length+e)*t,this.value=n.length<=i?n:t<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Rh{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:n}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(ce.prototype[Symbol.iterator]=function(){return this.iter()},kn.prototype[Symbol.iterator]=Dh.prototype[Symbol.iterator]=Rh.prototype[Symbol.iterator]=function(){return this});class Ad{constructor(e,t,i,n){this.from=e,this.to=t,this.number=i,this.text=n}get length(){return this.to-this.from}}function Yi(r,e,t){return e=Math.max(0,Math.min(r.length,e)),[e,Math.max(e,Math.min(r.length,t))]}function Ne(r,e,t=!0,i=!0){return bd(r,e,t,i)}function Md(r){return r>=56320&&r<57344}function Td(r){return r>=55296&&r<56320}function Eh(r,e){let t=r.charCodeAt(e);if(!Td(t)||e+1==r.length)return t;let i=r.charCodeAt(e+1);return Md(i)?(t-55296<<10)+(i-56320)+65536:t}function Od(r){return r<=65535?String.fromCharCode(r):(r-=65536,String.fromCharCode((r>>10)+55296,(r&1023)+56320))}function Ih(r){return r<65536?1:2}const Fs=/\r\n?|\n/;var _e=(function(r){return r[r.Simple=0]="Simple",r[r.TrackDel=1]="TrackDel",r[r.TrackBefore=2]="TrackBefore",r[r.TrackAfter=3]="TrackAfter",r})(_e||(_e={}));class qt{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,n=0;t<this.sections.length;){let s=this.sections[t++],o=this.sections[t++];o<0?(e(i,n,s),n+=s):n+=o,i+=s}}iterChangedRanges(e,t=!1){Hs(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];n<0?e.push(i,n):e.push(n,i)}return new qt(e)}composeDesc(e){return this.empty?e:e.empty?this:Ph(this,e)}mapDesc(e,t=!1){return e.empty?this:Ws(this,e,t)}mapPos(e,t=-1,i=_e.Simple){let n=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],h=this.sections[o++],u=n+l;if(h<0){if(u>e)return s+(e-n);s+=l}else{if(i!=_e.Simple&&u>=e&&(i==_e.TrackDel&&n<e&&u>e||i==_e.TrackBefore&&n<e||i==_e.TrackAfter&&u>e))return null;if(u>e||u==e&&t<0&&!l)return e==n||t<0?s:s+h;s+=h}n=u}if(e>n)throw new RangeError(`Position ${e} is out of range for changeset of length ${n}`);return s}touchesRange(e,t=e){for(let i=0,n=0;i<this.sections.length&&n<=t;){let s=this.sections[i++],o=this.sections[i++],l=n+s;if(o>=0&&n<=t&&l>=e)return n<e&&l>t?"cover":!0;n=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];e+=(e?" ":"")+i+(n>=0?":"+n:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new qt(e)}static create(e){return new qt(e)}}class Ie extends qt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Hs(this,(t,i,n,s,o)=>e=e.replace(n,n+(i-t),o),!1),e}mapDesc(e,t=!1){return Ws(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let n=0,s=0;n<t.length;n+=2){let o=t[n],l=t[n+1];if(l>=0){t[n]=l,t[n+1]=o;let h=n>>1;for(;i.length<h;)i.push(ce.empty);i.push(o?e.slice(s,s+o):ce.empty)}s+=o}return new Ie(t,i)}compose(e){return this.empty?e:e.empty?this:Ph(this,e,!0)}map(e,t=!1){return e.empty?this:Ws(this,e,t,!0)}iterChanges(e,t=!1){Hs(this,e,t)}get desc(){return qt.create(this.sections)}filter(e){let t=[],i=[],n=[],s=new Tn(this);e:for(let o=0,l=0;;){let h=o==e.length?1e9:e[o++];for(;l<h||l==h&&s.len==0;){if(s.done)break e;let p=Math.min(s.len,h-l);Ge(n,p,-1);let m=s.ins==-1?-1:s.off==0?s.ins:0;Ge(t,p,m),m>0&&li(i,t,s.text),s.forward(p),l+=p}let u=e[o++];for(;l<u;){if(s.done)break e;let p=Math.min(s.len,u-l);Ge(t,p,-1),Ge(n,p,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(p),l+=p}}return{changes:new Ie(t,i),filtered:qt.create(n)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],n=this.sections[t+1];n<0?e.push(i):n==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let n=[],s=[],o=0,l=null;function h(p=!1){if(!p&&!n.length)return;o<t&&Ge(n,t-o,-1);let m=new Ie(n,s);l=l?l.compose(m.map(l)):m,n=[],s=[],o=0}function u(p){if(Array.isArray(p))for(let m of p)u(m);else if(p instanceof Ie){if(p.length!=t)throw new RangeError(`Mismatched change set length (got ${p.length}, expected ${t})`);h(),l=l?l.compose(p.map(l)):p}else{let{from:m,to:y=m,insert:x}=p;if(m>y||m<0||y>t)throw new RangeError(`Invalid change range ${m} to ${y} (in doc of length ${t})`);let S=x?typeof x=="string"?ce.of(x.split(i||Fs)):x:ce.empty,C=S.length;if(m==y&&C==0)return;m<o&&h(),m>o&&Ge(n,m-o,-1),Ge(n,y-m,C),li(s,n,S),o=y}}return u(e),h(!l),l}static empty(e){return new Ie(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let n=0;n<e.length;n++){let s=e[n];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;i.length<n;)i.push(ce.empty);i[n]=ce.of(s.slice(1)),t.push(s[0],i[n].length)}}}return new Ie(t,i)}static createSet(e,t){return new Ie(e,t)}}function Ge(r,e,t,i=!1){if(e==0&&t<=0)return;let n=r.length-2;n>=0&&t<=0&&t==r[n+1]?r[n]+=e:n>=0&&e==0&&r[n]==0?r[n+1]+=t:i?(r[n]+=e,r[n+1]+=t):r.push(e,t)}function li(r,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<r.length)r[r.length-1]=r[r.length-1].append(t);else{for(;r.length<i;)r.push(ce.empty);r.push(t)}}function Hs(r,e,t){let i=r.inserted;for(let n=0,s=0,o=0;o<r.sections.length;){let l=r.sections[o++],h=r.sections[o++];if(h<0)n+=l,s+=l;else{let u=n,p=s,m=ce.empty;for(;u+=l,p+=h,h&&i&&(m=m.append(i[o-2>>1])),!(t||o==r.sections.length||r.sections[o+1]<0);)l=r.sections[o++],h=r.sections[o++];e(n,u,s,p,m),n=u,s=p}}}function Ws(r,e,t,i=!1){let n=[],s=i?[]:null,o=new Tn(r),l=new Tn(e);for(let h=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let u=Math.min(o.len,l.len);Ge(n,u,-1),o.forward(u),l.forward(u)}else if(l.ins>=0&&(o.ins<0||h==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let u=l.len;for(Ge(n,l.ins,-1);u;){let p=Math.min(o.len,u);o.ins>=0&&h<o.i&&o.len<=p&&(Ge(n,0,o.ins),s&&li(s,n,o.text),h=o.i),o.forward(p),u-=p}l.next()}else if(o.ins>=0){let u=0,p=o.len;for(;p;)if(l.ins==-1){let m=Math.min(p,l.len);u+=m,p-=m,l.forward(m)}else if(l.ins==0&&l.len<p)p-=l.len,l.next();else break;Ge(n,u,h<o.i?o.ins:0),s&&h<o.i&&li(s,n,o.text),h=o.i,o.forward(o.len-p)}else{if(o.done&&l.done)return s?Ie.createSet(n,s):qt.create(n);throw new Error("Mismatched change set lengths")}}}function Ph(r,e,t=!1){let i=[],n=t?[]:null,s=new Tn(r),o=new Tn(e);for(let l=!1;;){if(s.done&&o.done)return n?Ie.createSet(i,n):qt.create(i);if(s.ins==0)Ge(i,s.len,0,l),s.next();else if(o.len==0&&!o.done)Ge(i,0,o.ins,l),n&&li(n,i,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let h=Math.min(s.len2,o.len),u=i.length;if(s.ins==-1){let p=o.ins==-1?-1:o.off?0:o.ins;Ge(i,h,p,l),n&&p&&li(n,i,o.text)}else o.ins==-1?(Ge(i,s.off?0:s.len,h,l),n&&li(n,i,s.textBit(h))):(Ge(i,s.off?0:s.len,o.off?0:o.ins,l),n&&!o.off&&li(n,i,o.text));l=(s.ins>h||o.ins>=0&&o.len>h)&&(l||i.length>u),s.forward2(h),o.forward(h)}}}}class Tn{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?ce.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?ce.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class si{constructor(e,t,i,n){this.from=e,this.to=t,this.flags=i,this.goalColumn=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let i,n;return this.empty?i=n=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new si(i,n,this.flags,this.goalColumn)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return I.range(e,t,void 0,void 0,i);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return I.range(this.anchor,n,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return I.range(e.anchor,e.head)}static create(e,t,i,n){return new si(e,t,i,n)}}class I{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:I.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new I([this.main],0)}addRange(e,t=!0){return I.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,I.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new I(e.ranges.map(t=>si.fromJSON(t)),e.main)}static single(e,t=e){return new I([I.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<e.length;n++){let s=e[n];if(s.empty?s.from<=i:s.from<i)return I.normalized(e.slice(),t);i=s.to}return new I(e,t)}static cursor(e,t=0,i,n){return si.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i)),n)}static range(e,t,i,n,s){let o=n==null?7:Math.min(6,n);return!s&&e!=t&&(s=t<e?1:-1),s&&(o|=s<0?8:16),t<e?si.create(t,e,o|32,i):si.create(e,t,o,i)}static undirectionalRange(e,t){return si.create(e,t,64,void 0)}static normalized(e,t=0){let i=e[t];e.sort((n,s)=>n.from-s.from),t=e.indexOf(i);for(let n=1;n<e.length;n++){let s=e[n],o=e[n-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,h=Math.max(s.to,o.to);n<=t&&t--,e.splice(--n,2,s.anchor>s.head?I.range(h,l):I.range(l,h))}}return new I(e,t)}}function Nh(r,e){for(let t of r.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let Lo=0;class j{constructor(e,t,i,n,s){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=n,this.id=Lo++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new j(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Bo),!!e.static,e.enables)}of(e){return new ur([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new ur(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new ur(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function Bo(r,e){return r==e||r.length==e.length&&r.every((t,i)=>t===e[i])}class ur{constructor(e,t,i,n){this.dependencies=e,this.facet=t,this.type=i,this.value=n,this.id=Lo++}dynamicSlot(e){var t;let i=this.value,n=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,h=!1,u=!1,p=[];for(let m of this.dependencies)m=="doc"?h=!0:m=="selection"?u=!0:(((t=e[m.id])!==null&&t!==void 0?t:1)&1)==0&&p.push(e[m.id]);return{create(m){return m.values[o]=i(m),1},update(m,y){if(h&&y.docChanged||u&&(y.docChanged||y.selection)||Vs(m,p)){let x=i(m);if(l?!oa(x,m.values[o],n):!n(x,m.values[o]))return m.values[o]=x,1}return 0},reconfigure:(m,y)=>{let x,S=y.config.address[s];if(S!=null){let C=xr(y,S);if(this.dependencies.every(O=>O instanceof j?y.facet(O)===m.facet(O):O instanceof Ot?y.field(O,!1)==m.field(O,!1):!0)||(l?oa(x=i(m),C,n):n(x=i(m),C)))return m.values[o]=C,0}else x=i(m);return m.values[o]=x,1}}}get extension(){return this}}function oa(r,e,t){if(r.length!=e.length)return!1;for(let i=0;i<r.length;i++)if(!t(r[i],e[i]))return!1;return!0}function Vs(r,e){let t=!1;for(let i of e)xn(r,i)&1&&(t=!0);return t}function Ld(r,e,t){let i=t.map(h=>r[h.id]),n=t.map(h=>h.type),s=i.filter(h=>!(h&1)),o=r[e.id]>>1;function l(h){let u=[];for(let p=0;p<i.length;p++){let m=xr(h,i[p]);if(n[p]==2)for(let y of m)u.push(y);else u.push(m)}return e.combine(u)}return{create(h){for(let u of i)xn(h,u);return h.values[o]=l(h),1},update(h,u){if(!Vs(h,s))return 0;let p=l(h);return e.compare(p,h.values[o])?0:(h.values[o]=p,1)},reconfigure(h,u){let p=Vs(h,i),m=u.config.facets[e.id],y=u.facet(e);if(m&&!p&&Bo(t,m))return h.values[o]=y,0;let x=l(h);return e.compare(x,y)?(h.values[o]=y,0):(h.values[o]=x,1)}}}const Gn=j.define({static:!0});class Ot{constructor(e,t,i,n,s){this.id=e,this.createF=t,this.updateF=i,this.compareF=n,this.spec=s,this.provides=void 0}static define(e){let t=new Ot(Lo++,e.create,e.update,e.compare||((i,n)=>i===n),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Gn).find(i=>i.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,n)=>{let s=i.values[t],o=this.updateF(s,n);return this.compareF(s,o)?0:(i.values[t]=o,1)},reconfigure:(i,n)=>{let s=i.facet(Gn),o=n.facet(Gn),l;return(l=s.find(h=>h.field==this))&&l!=o.find(h=>h.field==this)?(i.values[t]=l.create(i),1):n.config.address[this.id]!=null?(i.values[t]=n.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,Gn.of({field:this,create:e})]}get extension(){return this}}const bi={lowest:4,low:3,default:2,high:1,highest:0};function un(r){return e=>new Fh(e,r)}const rn={highest:un(bi.highest),high:un(bi.high),default:un(bi.default),low:un(bi.low),lowest:un(bi.lowest)};class Fh{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class Fr{of(e){return new Ks(this,e)}reconfigure(e){return Fr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Ks{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class kr{constructor(e,t,i,n,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let n=[],s=Object.create(null),o=new Map;for(let y of Bd(e,t,o))y instanceof Ot?n.push(y):(s[y.facet.id]||(s[y.facet.id]=[])).push(y);let l=Object.create(null),h=[],u=[];for(let y of n)l[y.id]=u.length<<1,u.push(x=>y.slot(x));let p=i?.config.facets;for(let y in s){let x=s[y],S=x[0].facet,C=p&&p[y]||[];if(x.every(O=>O.type==0))if(l[S.id]=h.length<<1|1,Bo(C,x))h.push(i.facet(S));else{let O=S.combine(x.map(B=>B.value));h.push(i&&S.compare(O,i.facet(S))?i.facet(S):O)}else{for(let O of x)O.type==0?(l[O.id]=h.length<<1|1,h.push(O.value)):(l[O.id]=u.length<<1,u.push(B=>O.dynamicSlot(B)));l[S.id]=u.length<<1,u.push(O=>Ld(O,S,x))}}let m=u.map(y=>y(l));return new kr(e,o,m,l,h,s)}}function Bd(r,e,t){let i=[[],[],[],[],[]],n=new Map;function s(o,l){let h=n.get(o);if(h!=null){if(h<=l)return;let u=i[h].indexOf(o);u>-1&&i[h].splice(u,1),o instanceof Ks&&t.delete(o.compartment)}if(n.set(o,l),Array.isArray(o))for(let u of o)s(u,l);else if(o instanceof Ks){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(o.compartment)||o.inner;t.set(o.compartment,u),s(u,l)}else if(o instanceof Fh)s(o.inner,o.prec);else if(o instanceof Ot)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof ur)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,bi.default);else{let u=o.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(u==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(u,l)}}return s(r,bi.default),i.reduce((o,l)=>o.concat(l))}function xn(r,e){if(e&1)return 2;let t=e>>1,i=r.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;r.status[t]=4;let n=r.computeSlot(r,r.config.dynamicSlots[t]);return r.status[t]=2|n}function xr(r,e){return e&1?r.config.staticValues[e>>1]:r.values[e>>1]}const Hh=j.define(),zs=j.define({combine:r=>r.some(e=>e),static:!0}),Wh=j.define({combine:r=>r.length?r[0]:void 0,static:!0}),Vh=j.define(),Kh=j.define(),zh=j.define(),$h=j.define({combine:r=>r.length?r[0]:!1});class Zt{constructor(e,t){this.type=e,this.value=t}static define(){return new Dd}}class Dd{of(e){return new Zt(this,e)}}class Rd{constructor(e){this.map=e}of(e){return new me(this,e)}}class me{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new me(this.type,t)}is(e){return this.type==e}static define(e={}){return new Rd(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let n of e){let s=n.map(t);s&&i.push(s)}return i}}me.reconfigure=me.define();me.appendConfig=me.define();class Ee{constructor(e,t,i,n,s,o){this.startState=e,this.changes=t,this.selection=i,this.effects=n,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Nh(i,t.newLength),s.some(l=>l.type==Ee.time)||(this.annotations=s.concat(Ee.time.of(Date.now())))}static create(e,t,i,n,s,o){return new Ee(e,t,i,n,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Ee.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}Ee.time=Zt.define();Ee.userEvent=Zt.define();Ee.addToHistory=Zt.define();Ee.remote=Zt.define();function Ed(r,e){let t=[];for(let i=0,n=0;;){let s,o;if(i<r.length&&(n==e.length||e[n]>=r[i]))s=r[i++],o=r[i++];else if(n<e.length)s=e[n++],o=e[n++];else return t;!t.length||t[t.length-1]<s?t.push(s,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function _h(r,e,t){var i;let n,s,o;return t?(n=e.changes,s=Ie.empty(e.changes.length),o=r.changes.compose(e.changes)):(n=e.changes.map(r.changes),s=r.changes.mapDesc(e.changes,!0),o=r.changes.compose(n)),{changes:o,selection:e.selection?e.selection.map(s):(i=r.selection)===null||i===void 0?void 0:i.map(n),effects:me.mapEffects(r.effects,n).concat(me.mapEffects(e.effects,s)),annotations:r.annotations.length?r.annotations.concat(e.annotations):e.annotations,scrollIntoView:r.scrollIntoView||e.scrollIntoView}}function $s(r,e,t){let i=e.selection,n=ji(e.annotations);return e.userEvent&&(n=n.concat(Ee.userEvent.of(e.userEvent))),{changes:e.changes instanceof Ie?e.changes:Ie.of(e.changes||[],t,r.facet(Wh)),selection:i&&(i instanceof I?i:I.single(i.anchor,i.head)),effects:ji(e.effects),annotations:n,scrollIntoView:!!e.scrollIntoView}}function jh(r,e,t){let i=$s(r,e.length?e[0]:{},r.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let o=!!e[s].sequential;i=_h(i,$s(r,e[s],o?i.changes.newLength:r.doc.length),o)}let n=Ee.create(r,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return Pd(t?Id(n):n)}function Id(r){let e=r.startState,t=!0;for(let n of e.facet(Vh)){let s=n(r);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:Ed(t,s))}if(t!==!0){let n,s;if(t===!1)s=r.changes.invertedDesc,n=Ie.empty(e.doc.length);else{let o=r.changes.filter(t);n=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}r=Ee.create(e,n,r.selection&&r.selection.map(s),me.mapEffects(r.effects,s),r.annotations,r.scrollIntoView)}let i=e.facet(Kh);for(let n=i.length-1;n>=0;n--){let s=i[n](r);s instanceof Ee?r=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Ee?r=s[0]:r=jh(e,ji(s),!1)}return r}function Pd(r){let e=r.startState,t=e.facet(zh),i=r;for(let n=t.length-1;n>=0;n--){let s=t[n](r);s&&Object.keys(s).length&&(i=_h(i,$s(e,s,r.changes.newLength),!0))}return i==r?r:Ee.create(e,r.changes,r.selection,i.effects,i.annotations,i.scrollIntoView)}const Nd=[];function ji(r){return r==null?Nd:Array.isArray(r)?r:[r]}var je=(function(r){return r[r.Word=0]="Word",r[r.Space=1]="Space",r[r.Other=2]="Other",r})(je||(je={}));const Fd=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let _s;try{_s=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Hd(r){if(_s)return _s.test(r);for(let e=0;e<r.length;e++){let t=r[e];if(/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||Fd.test(t)))return!0}return!1}function Wd(r){return e=>{if(!/\S/.test(e))return je.Space;if(Hd(e))return je.Word;for(let t=0;t<r.length;t++)if(e.indexOf(r[t])>-1)return je.Word;return je.Other}}class pe{constructor(e,t,i,n,s,o){this.config=e,this.doc=t,this.selection=i,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)xn(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return xn(this,i),xr(this,i)}update(...e){return jh(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:n}=t;for(let l of e.effects)l.is(Fr.reconfigure)?(t&&(n=new Map,t.compartments.forEach((h,u)=>n.set(u,h)),t=null),n.set(l.value.compartment,l.value.extension)):l.is(me.reconfigure)?(t=null,i=l.value):l.is(me.appendConfig)&&(t=null,i=ji(i).concat(l.value));let s;t?s=e.startState.values.slice():(t=kr.resolve(i,n,this),s=new pe(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(h,u)=>u.reconfigure(h,this),null).values);let o=e.startState.facet(zs)?e.newSelection:e.newSelection.asSingle();new pe(t,e.newDoc,o,s,(l,h)=>h.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:I.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),n=this.changes(i.changes),s=[i.range],o=ji(i.effects);for(let l=1;l<t.ranges.length;l++){let h=e(t.ranges[l]),u=this.changes(h.changes),p=u.map(n);for(let y=0;y<l;y++)s[y]=s[y].map(p);let m=n.mapDesc(u,!0);s.push(h.range.map(m)),n=n.compose(p),o=me.mapEffects(o,p).concat(me.mapEffects(ji(h.effects),m))}return{changes:n,selection:I.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof Ie?e:Ie.of(e,this.doc.length,this.facet(pe.lineSeparator))}toText(e){return ce.of(e.split(this.facet(pe.lineSeparator)||Fs))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(xn(this,t),xr(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let n=e[i];n instanceof Ot&&this.config.address[n.id]!=null&&(t[i]=n.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i){for(let s in i)if(Object.prototype.hasOwnProperty.call(e,s)){let o=i[s],l=e[s];n.push(o.init(h=>o.spec.fromJSON(l,h)))}}return pe.create({doc:e.doc,selection:I.fromJSON(e.selection),extensions:t.extensions?n.concat([t.extensions]):n})}static create(e={}){let t=kr.resolve(e.extensions||[],new Map),i=e.doc instanceof ce?e.doc:ce.of((e.doc||"").split(t.staticFacet(pe.lineSeparator)||Fs)),n=e.selection?e.selection instanceof I?e.selection:I.single(e.selection.anchor,e.selection.head):I.single(0);return Nh(n,i.length),t.staticFacet(zs)||(n=n.asSingle()),new pe(t,i,n,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(pe.tabSize)}get lineBreak(){return this.facet(pe.lineSeparator)||`
|
|
6
|
+
`}get readOnly(){return this.facet($h)}phrase(e,...t){for(let i of this.facet(pe.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,n)=>{if(n=="$")return"$";let s=+(n||1);return!s||s>t.length?i:t[s-1]})),e}languageDataAt(e,t,i=-1){let n=[];for(let s of this.facet(Hh))for(let o of s(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&n.push(o[e]);return n}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return Wd(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:n}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let h=Ne(t,o,!1);if(s(t.slice(h,o))!=je.Word)break;o=h}for(;l<n;){let h=Ne(t,l);if(s(t.slice(l,h))!=je.Word)break;l=h}return o==l?null:I.range(o+i,l+i)}}pe.allowMultipleSelections=zs;pe.tabSize=j.define({combine:r=>r.length?r[0]:4});pe.lineSeparator=Wh;pe.readOnly=$h;pe.phrases=j.define({compare(r,e){let t=Object.keys(r),i=Object.keys(e);return t.length==i.length&&t.every(n=>r[n]==e[n])}});pe.languageData=Hh;pe.changeFilter=Vh;pe.transactionFilter=Kh;pe.transactionExtender=zh;Fr.reconfigure=me.define();function Hr(r,e,t={}){let i={};for(let n of r)for(let s of Object.keys(n)){let o=n[s],l=i[s];if(l===void 0)i[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,s))i[s]=t[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let n in e)i[n]===void 0&&(i[n]=e[n]);return i}class fi{eq(e){return this==e}range(e,t=e){return On.create(e,t,this)}}fi.prototype.startSide=fi.prototype.endSide=0;fi.prototype.point=!1;fi.prototype.mapMode=_e.TrackDel;function Do(r,e){return r==e||r.constructor==e.constructor&&r.eq(e)}class On{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new On(e,t,i)}}function js(r,e){return r.from-e.from||r.value.startSide-e.value.startSide}class Ro{constructor(e,t,i,n){this.from=e,this.to=t,this.value=i,this.maxPoint=n}get length(){return Ni(this.to)}findIndex(e,t,i,n=0){let s=i?this.to:this.from;for(let o=n,l=s.length;;){if(o==l)return o;let h=o+l>>1,u=s[h]-e||(i?this.value[h].endSide:this.value[h].startSide)-t;if(h==o)return u>=0?o:l;u>=0?l=h:o=h+1}}between(e,t,i,n){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,s);s<o;s++)if(n(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t,i,n,s){let o=[],l=[],h=[],u=-1,p=-1;e:for(let m=0;m<this.value.length;m++){let y=this.value[m],x=this.from[m]+e,S=this.to[m]+e,C,O;if(x==S){let B=t.mapPos(x,y.startSide,y.mapMode);if(B==null||(C=O=B,y.startSide!=y.endSide&&(O=t.mapPos(x,y.endSide),O<C)))continue}else if(C=t.mapPos(x,y.startSide),O=t.mapPos(S,y.endSide),C>O||C==O&&y.startSide>0&&y.endSide<=0)continue;if(!((O-C||y.endSide-y.startSide)<0))if(u<0&&(u=C),y.point&&(p=Math.max(p,O-C)),(C-i||y.startSide-n)>=0)o.push(y),l.push(C-u),h.push(O-u),i=O,n=y.endSide;else{if(C==O)for(let B=o.length;B>0;B--){if((C-(h[B-1]+u)||y.startSide-o[B-1].endSide)>=0){o.splice(B,0,y),l.splice(B,0,C-u),h.splice(B,0,O-u);continue e}if((C-(l[B-1]+u)||y.endSide-o[B-1].startSide)>0)break}s(C,O,y)}}return{mapped:o.length?new Ro(l,h,o,p):null,pos:u}}}class ue{constructor(e,t,i,n){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=n}static create(e,t,i,n){return new ue(e,t,i,n)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:n=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(js)),this.isEmpty)return t.length?ue.of(t):this;let l=new qh(this,null,-1).goto(0),h=0,u=[],p=new Ci;for(;l.value||h<t.length;)if(h<t.length&&(l.from-t[h].from||l.startSide-t[h].value.startSide)>=0){let m=t[h++];p.addInner(m.from,m.to,m.value,!1)||u.push(m)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(h==t.length||this.chunkEnd(l.chunkIndex)<t[h].from)&&(!o||n>this.chunkEnd(l.chunkIndex)||s<this.chunkPos[l.chunkIndex])&&p.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||n>l.to||s<l.from||o(l.from,l.to,l.value))&&(p.addInner(l.from,l.to,l.value,!1)||u.push(On.create(l.from,l.to,l.value))),l.next());return p.finishInner(this.nextLayer.isEmpty&&!u.length?ue.empty:this.nextLayer.update({add:u,filter:o,filterFrom:n,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],n=-1,s,o=(h,u,p)=>{s||(s=new Ci),s.addRange(h,u,p,!1)};for(let h=0;h<this.chunk.length;h++){let u=this.chunkPos[h],p=this.chunk[h],m=e.touchesRange(u,u+p.length);if(m===!1)n=Math.max(n,p.maxPoint),t.push(p),i.push(e.mapPos(u));else if(m===!0){let[y,x]=t.length?[Ni(i)+Ni(t).length,Ni(Ni(t).value).endSide]:[-1,-1],{mapped:S,pos:C}=p.map(u,e,y,x,o);S&&(n=Math.max(n,S.maxPoint),t.push(S),i.push(C))}}let l=this.nextLayer.map(e);return s&&(l=s.finishInner(l)),t.length==0?l:new ue(i,t,l||ue.empty,n)}between(e,t,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let s=this.chunkPos[n],o=this.chunk[n];if(t>=s&&e<=s+o.length&&o.between(s,e-s,t-s,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return Ln.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Ln.from(e).goto(t)}static compare(e,t,i,n,s=-1){let o=e.filter(m=>m.maxPoint>0||!m.isEmpty&&m.maxPoint>=s),l=t.filter(m=>m.maxPoint>0||!m.isEmpty&&m.maxPoint>=s),h=la(o,l,i),u=new cn(o,h,s),p=new cn(l,h,s);i.iterGaps((m,y,x)=>aa(u,m,p,y,x,n)),i.empty&&i.length==0&&aa(u,0,p,0,0,n)}static eq(e,t,i=0,n){n==null&&(n=999999999);let s=e.filter(p=>!p.isEmpty&&t.indexOf(p)<0),o=t.filter(p=>!p.isEmpty&&e.indexOf(p)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=la(s,o),h=new cn(s,l,0).goto(i),u=new cn(o,l,0).goto(i);for(;;){if(h.to!=u.to||!qs(h.active,u.active)||h.point&&(!u.point||!Do(h.point,u.point)))return!1;if(h.to>n)return!0;h.next(),u.next()}}static spans(e,t,i,n,s=-1){let o=new cn(e,null,s).goto(t),l=t,h=o.openStart;for(;;){let u=Math.min(o.to,i);if(o.point){let p=o.activeForPoint(o.to),m=o.pointFrom<t?p.length+1:o.point.startSide<0?p.length:Math.min(p.length,h);n.point(l,u,o.point,p,m,o.pointRank),h=Math.min(o.openEnd(u),p.length)}else u>l&&(n.span(l,u,o.active,h),h=o.openEnd(u));if(o.to>i)return h+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,t=!1){let i=new Ci;for(let n of e instanceof On?[e]:t?Vd(e):e)i.add(n.from,n.to,n.value);return i.finish()}static join(e){if(!e.length)return ue.empty;let t=Ni(e);for(let i=e.length-2;i>=0;i--)for(let n=e[i];n!=ue.empty;n=n.nextLayer)t=new ue(n.chunkPos,n.chunk,t,Math.max(n.maxPoint,t.maxPoint));return t}}ue.empty=new ue([],[],null,-1);function Ni(r){return r[r.length-1]}function Vd(r){if(r.length>1)for(let e=r[0],t=1;t<r.length;t++){let i=r[t];if(js(e,i)>0)return r.slice().sort(js);e=i}return r}ue.empty.nextLayer=ue.empty;class Ci{finishChunk(e){this.chunks.push(new Ro(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addRange(e,t,i,!0)}addRange(e,t,i,n){this.addInner(e,t,i,n)||(this.nextLayer||(this.nextLayer=new Ci)).addRange(e,t,i,n)}addInner(e,t,i,n){let s=e-this.lastTo||i.startSide-this.last.endSide;if(n&&s<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(ue.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=ue.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function la(r,e,t){let i=new Map;for(let s of r)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&i.set(s.chunk[o],s.chunkPos[o]);let n=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let l=i.get(s.chunk[o]);l!=null&&(t?t.mapPos(l):l)==s.chunkPos[o]&&!t?.touchesRange(l,l+s.chunk[o].length)&&n.add(s.chunk[o])}return n}class qh{constructor(e,t,i,n=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,i){for(;this.chunkIndex<this.layer.chunk.length;){let n=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(n)||this.layer.chunkEnd(this.chunkIndex)<e||n.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class Ln{constructor(e){this.heap=e}static from(e,t=null,i=-1){let n=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&n.push(new qh(o,t,i,s));return n.length==1?n[0]:new Ln(n)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)ds(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)ds(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),ds(this.heap,0)}}}function ds(r,e){for(let t=r[e];;){let i=(e<<1)+1;if(i>=r.length)break;let n=r[i];if(i+1<r.length&&n.compare(r[i+1])>=0&&(n=r[i+1],i++),t.compare(n)<0)break;r[i]=t,r[e]=n,e=i}}class cn{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Ln.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Yn(this.active,e),Yn(this.activeTo,e),Yn(this.activeRank,e),this.minActive=ha(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:n,rank:s}=this.cursor;for(;t<this.activeRank.length&&(s-this.activeRank[t]||n-this.activeTo[t])>0;)t++;Qn(this.active,t,i),Qn(this.activeTo,t,n),Qn(this.activeRank,t,s),e&&Qn(e,t,this.cursor.from),this.minActive=ha(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>e){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&Yn(i,n)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let n=i.length-1;n>=0&&i[n]<e;n--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function aa(r,e,t,i,n,s){r.goto(e),t.goto(i);let o=i+n,l=i,h=i-e,u=!!s.boundChange;for(let p=!1;;){let m=r.to+h-t.to,y=m||r.endSide-t.endSide,x=y<0?r.to+h:t.to,S=Math.min(x,o);if(r.point||t.point?(r.point&&t.point&&Do(r.point,t.point)&&qs(r.activeForPoint(r.to),t.activeForPoint(t.to))||s.comparePoint(l,S,r.point,t.point),p=!1):(p&&(s.boundChange(l),p=!1),S>l&&!qs(r.active,t.active)&&s.compareRange(l,S,r.active,t.active),u&&S<o&&(m||r.openEnd(x)!=t.openEnd(x))&&(p=!0)),x>o)break;l=x,y<=0&&r.next(),y>=0&&t.next()}}function qs(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!=e[t]&&!Do(r[t],e[t]))return!1;return!0}function Yn(r,e){for(let t=e,i=r.length-1;t<i;t++)r[t]=r[t+1];r.pop()}function Qn(r,e,t){for(let i=r.length-1;i>=e;i--)r[i+1]=r[i];r[e]=t}function ha(r,e){let t=-1,i=1e9;for(let n=0;n<e.length;n++)(e[n]-i||r[n].endSide-r[t].endSide)<0&&(t=n,i=e[n]);return t}function Wr(r,e,t=r.length){let i=0;for(let n=0;n<t&&n<r.length;)r.charCodeAt(n)==9?(i+=e-i%e,n++):(i++,n=Ne(r,n));return i}function Kd(r,e,t,i){for(let n=0,s=0;;){if(s>=e)return n;if(n==r.length)break;s+=r.charCodeAt(n)==9?t-s%t:1,n=Ne(r,n)}return r.length}const Us="ͼ",fa=typeof Symbol>"u"?"__"+Us:Symbol.for(Us),Js=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),ua=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class ui{constructor(e,t){this.rules=[];let{finish:i}=t||{};function n(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,h,u){let p=[],m=/^@(\w+)\b/.exec(o[0]),y=m&&m[1]=="keyframes";if(m&&l==null)return h.push(o[0]+";");for(let x in l){let S=l[x];if(/&/.test(x))s(x.split(/,\s*/).map(C=>o.map(O=>C.replace(/&/,O))).reduce((C,O)=>C.concat(O)),S,h);else if(S&&typeof S=="object"){if(!m)throw new RangeError("The value of a property ("+x+") should be a primitive value.");s(n(x),S,p,y)}else S!=null&&p.push(x.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+S+";")}(p.length||y)&&h.push((i&&!m&&!u?o.map(i):o).join(", ")+" {"+p.join(" ")+"}")}for(let o in e)s(n(o),e[o],this.rules)}getRules(){return this.rules.join(`
|
|
7
|
+
`)}static newName(){let e=ua[fa]||1;return ua[fa]=e+1,Us+e.toString(36)}static mount(e,t,i){let n=e[Js],s=i&&i.nonce;n?s&&n.setNonce(s):n=new zd(e,s),n.mount(Array.isArray(t)?t:[t],e)}}let ca=new Map;class zd{constructor(e,t){let i=e.ownerDocument||e,n=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&n.CSSStyleSheet){let s=ca.get(i);if(s)return e[Js]=s;this.sheet=new n.CSSStyleSheet,ca.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Js]=this}mount(e,t){let i=this.sheet,n=0,s=0;for(let o=0;o<e.length;o++){let l=e[o],h=this.modules.indexOf(l);if(h<s&&h>-1&&(this.modules.splice(h,1),s--,h=-1),h==-1){if(this.modules.splice(s++,0,l),i)for(let u=0;u<l.rules.length;u++)i.insertRule(l.rules[u],n++)}else{for(;s<h;)n+=this.modules[s++].rules.length;n+=l.rules.length,s++}}if(i)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let o="";for(let h=0;h<this.modules.length;h++)o+=this.modules[h].getRules()+`
|
|
8
|
+
`;this.styleTag.textContent=o;let l=t.head||t;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var ci={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Bn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},$d=typeof navigator<"u"&&/Mac/.test(navigator.platform),_d=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var $e=0;$e<10;$e++)ci[48+$e]=ci[96+$e]=String($e);for(var $e=1;$e<=24;$e++)ci[$e+111]="F"+$e;for(var $e=65;$e<=90;$e++)ci[$e]=String.fromCharCode($e+32),Bn[$e]=String.fromCharCode($e);for(var ps in ci)Bn.hasOwnProperty(ps)||(Bn[ps]=ci[ps]);function jd(r){var e=$d&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||_d&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",t=!e&&r.key||(r.shiftKey?Bn:ci)[r.keyCode]||r.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}let tt=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Gs=typeof document<"u"?document:{documentElement:{style:{}}};const Ys=/Edge\/(\d+)/.exec(tt.userAgent),Uh=/MSIE \d/.test(tt.userAgent),Qs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(tt.userAgent),Vr=!!(Uh||Qs||Ys),da=!Vr&&/gecko\/(\d+)/i.test(tt.userAgent),gs=!Vr&&/Chrome\/(\d+)/.exec(tt.userAgent),pa="webkitFontSmoothing"in Gs.documentElement.style,Xs=!Vr&&/Apple Computer/.test(tt.vendor),ga=Xs&&(/Mobile\/\w+/.test(tt.userAgent)||tt.maxTouchPoints>2);var _={mac:ga||/Mac/.test(tt.platform),windows:/Win/.test(tt.platform),linux:/Linux|X11/.test(tt.platform),ie:Vr,ie_version:Uh?Gs.documentMode||6:Qs?+Qs[1]:Ys?+Ys[1]:0,gecko:da,gecko_version:da?+(/Firefox\/(\d+)/.exec(tt.userAgent)||[0,0])[1]:0,chrome:!!gs,chrome_version:gs?+gs[1]:0,ios:ga,android:/Android\b/.test(tt.userAgent),webkit:pa,webkit_version:pa?+(/\bAppleWebKit\/(\d+)/.exec(tt.userAgent)||[0,0])[1]:0,safari:Xs,safari_version:Xs?+(/\bVersion\/(\d+(\.\d+)?)/.exec(tt.userAgent)||[0,0])[1]:0,tabSize:Gs.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Eo(r,e){for(let t in r)t=="class"&&e.class?e.class+=" "+r.class:t=="style"&&e.style?e.style+=";"+r.style:e[t]=r[t];return e}const wr=Object.create(null);function Io(r,e,t){if(r==e)return!0;r||(r=wr),e||(e=wr);let i=Object.keys(r),n=Object.keys(e);if(i.length-0!=n.length-0)return!1;for(let s of i)if(s!=t&&(n.indexOf(s)==-1||r[s]!==e[s]))return!1;return!0}function qd(r,e){for(let t=r.attributes.length-1;t>=0;t--){let i=r.attributes[t].name;e[i]==null&&r.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?r.style.cssText=i:r.getAttribute(t)!=i&&r.setAttribute(t,i)}}function ma(r,e,t){let i=!1;if(e)for(let n in e)t&&n in t||(i=!0,n=="style"?r.style.cssText="":r.removeAttribute(n));if(t)for(let n in t)e&&e[n]==t[n]||(i=!0,n=="style"?r.style.cssText=t[n]:r.setAttribute(n,t[n]));return i}function Ud(r){let e=Object.create(null);for(let t=0;t<r.attributes.length;t++){let i=r.attributes[t];e[i.name]=i.value}return e}class pi{eq(e){return!1}updateDOM(e,t,i){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var qe=(function(r){return r[r.Text=0]="Text",r[r.WidgetBefore=1]="WidgetBefore",r[r.WidgetAfter=2]="WidgetAfter",r[r.WidgetRange=3]="WidgetRange",r})(qe||(qe={}));class de extends fi{constructor(e,t,i,n){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(e){return new Fn(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Mi(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,n;if(e.isBlockGap)i=-5e8,n=4e8;else{let{start:s,end:o}=Jh(e,t);i=(s?t?-3e8:-1:5e8)-1,n=(o?t?2e8:1:-6e8)+1}return new Mi(e,i,n,t,e.widget||null,!0)}static line(e){return new Hn(e)}static set(e,t=!1){return ue.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}de.none=ue.empty;class Fn extends de{constructor(e){let{start:t,end:i}=Jh(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Eo(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||wr}eq(e){return this==e||e instanceof Fn&&this.tagName==e.tagName&&Io(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Fn.prototype.point=!1;class Hn extends de{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Hn&&this.spec.class==e.spec.class&&Io(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}Hn.prototype.mapMode=_e.TrackBefore;Hn.prototype.point=!0;class Mi extends de{constructor(e,t,i,n,s,o){super(t,i,s,e),this.block=n,this.isReplace=o,this.mapMode=n?t<=0?_e.TrackBefore:_e.TrackAfter:_e.TrackDel}get type(){return this.startSide!=this.endSide?qe.WidgetRange:this.startSide<=0?qe.WidgetBefore:qe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Mi&&Jd(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}Mi.prototype.point=!0;function Jh(r,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=r;return t==null&&(t=r.inclusive),i==null&&(i=r.inclusive),{start:t??e,end:i??e}}function Jd(r,e){return r==e||!!(r&&e&&r.compare(e))}function qi(r,e,t,i=0){let n=t.length-1;n>=0&&t[n]+i>=r?t[n]=Math.max(t[n],e):t.push(r,e)}class Dn extends fi{constructor(e,t,i){super(),this.tagName=e,this.attributes=t,this.rank=i}eq(e){return e==this||e instanceof Dn&&this.tagName==e.tagName&&Io(this.attributes,e.attributes)}static create(e){return new Dn(e.tagName,e.attributes||wr,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return ue.of(e,t)}}Dn.prototype.startSide=Dn.prototype.endSide=-1;function Rn(r){let e;return r.nodeType==11?e=r.getSelection?r:r.ownerDocument:e=r,e.getSelection()}function Zs(r,e){return e?r==e||r.contains(e.nodeType!=1?e.parentNode:e):!1}function wn(r,e){if(!e.anchorNode)return!1;try{return Zs(r,e.anchorNode)}catch{return!1}}function bn(r){return r.nodeType==3?In(r,0,r.nodeValue.length).getClientRects():r.nodeType==1?r.getClientRects():[]}function Sn(r,e,t,i){return t?va(r,e,t,i,-1)||va(r,e,t,i,1):!1}function di(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e}function br(r){return r.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(r.nodeName)}function va(r,e,t,i,n){for(;;){if(r==t&&e==i)return!0;if(e==(n<0?0:Xt(r))){if(r.nodeName=="DIV")return!1;let s=r.parentNode;if(!s||s.nodeType!=1)return!1;e=di(r)+(n<0?0:1),r=s}else if(r.nodeType==1){if(r=r.childNodes[e+(n<0?-1:0)],r.nodeType==1&&r.contentEditable=="false")return!1;e=n<0?Xt(r):0}else return!1}}function Xt(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function En(r,e){let{left:t,right:i}=r;if(t==i)return r;let n=e?t:i;return{left:n,right:n,top:r.top,bottom:r.bottom}}function Gd(r){let e=r.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:r.innerWidth,top:0,bottom:r.innerHeight}}function Gh(r,e){let t=e.width/r.offsetWidth,i=e.height/r.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-r.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-r.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function Yd(r,e,t,i,n,s,o,l){let h=r.ownerDocument,u=h.defaultView||window;for(let p=r,m=!1;p&&!m;)if(p.nodeType==1){let y,x=p==h.body,S=1,C=1;if(x)y=Gd(u);else{if(/^(fixed|sticky)$/.test(getComputedStyle(p).position)&&(m=!0),p.scrollHeight<=p.clientHeight&&p.scrollWidth<=p.clientWidth){p=p.assignedSlot||p.parentNode;continue}let F=p.getBoundingClientRect();({scaleX:S,scaleY:C}=Gh(p,F)),y={left:F.left,right:F.left+p.clientWidth*S,top:F.top,bottom:F.top+p.clientHeight*C}}let O=0,B=0;if(n=="nearest")e.top<y.top+o?(B=e.top-(y.top+o),t>0&&e.bottom>y.bottom+B&&(B=e.bottom-y.bottom+o)):e.bottom>y.bottom-o&&(B=e.bottom-y.bottom+o,t<0&&e.top-B<y.top&&(B=e.top-(y.top+o)));else{let F=e.bottom-e.top,P=y.bottom-y.top;B=(n=="center"&&F<=P?e.top+F/2-P/2:n=="start"||n=="center"&&t<0?e.top-o:e.bottom-P+o)-y.top}if(i=="nearest"?e.left<y.left+s?(O=e.left-(y.left+s),t>0&&e.right>y.right+O&&(O=e.right-y.right+s)):e.right>y.right-s&&(O=e.right-y.right+s,t<0&&e.left<y.left+O&&(O=e.left-(y.left+s))):O=(i=="center"?e.left+(e.right-e.left)/2-(y.right-y.left)/2:i=="start"==l?e.left-s:e.right-(y.right-y.left)+s)-y.left,O||B)if(x)u.scrollBy(O,B);else{let F=0,P=0;if(B){let Q=p.scrollTop;p.scrollTop+=B/C,P=(p.scrollTop-Q)*C}if(O){let Q=p.scrollLeft;p.scrollLeft+=O/S,F=(p.scrollLeft-Q)*S}e={left:e.left-F,top:e.top-P,right:e.right-F,bottom:e.bottom-P},F&&Math.abs(F-O)<1&&(i="nearest"),P&&Math.abs(P-B)<1&&(n="nearest")}if(x)break;(e.top<y.top||e.bottom>y.bottom||e.left<y.left||e.right>y.right)&&(e={left:Math.max(e.left,y.left),right:Math.min(e.right,y.right),top:Math.max(e.top,y.top),bottom:Math.min(e.bottom,y.bottom)}),p=p.assignedSlot||p.parentNode}else if(p.nodeType==11)p=p.host;else break}function Yh(r,e=!0){let t=r.ownerDocument,i=null,n=null;for(let s=r.parentNode;s&&!(s==t.body||(!e||i)&&n);)if(s.nodeType==1)!n&&s.scrollHeight>s.clientHeight&&(n=s),e&&!i&&s.scrollWidth>s.clientWidth&&(i=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:i,y:n}}class Qd{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?Xt(t):0),i,Math.min(e.focusOffset,i?Xt(i):0))}set(e,t,i,n){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=n}}function Qh(r){let e=[];for(let t=r;t;t=t.nodeType==11?t.host:t.parentNode)t.nodeType==1&&e.push({node:t,left:t.scrollLeft,top:t.scrollTop});return e}function Xh(r,e=!0){for(let{node:t,left:i,top:n}of r)e&&t.scrollTop!=n&&(t.scrollTop=n),t.scrollLeft!=i&&(t.scrollLeft=i)}let wi=null;_.safari&&_.safari_version>=26&&(wi=!1);function Zh(r){if(r.setActive)return r.setActive();if(wi)return r.focus(wi);let e=Qh(r);r.focus(wi==null?{get preventScroll(){return wi={preventScroll:!0},!0}}:void 0),wi||(wi=!1,Xh(e))}let ya;function In(r,e,t=e){let i=ya||(ya=document.createRange());return i.setEnd(r,t),i.setStart(r,e),i}function Ui(r,e,t,i){let n={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:n.altKey,ctrlKey:n.ctrlKey,shiftKey:n.shiftKey,metaKey:n.metaKey}=i);let s=new KeyboardEvent("keydown",n);s.synthetic=!0,r.dispatchEvent(s);let o=new KeyboardEvent("keyup",n);return o.synthetic=!0,r.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function Xd(r){for(;r;){if(r&&(r.nodeType==9||r.nodeType==11&&r.host))return r;r=r.assignedSlot||r.parentNode}return null}function Zd(r,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,Xt(t));;)if(i){if(t.nodeType!=1)return!1;let n=t.childNodes[i-1];n.contentEditable=="false"?i--:(t=n,i=Xt(t))}else{if(t==r)return!0;i=di(t),t=t.parentNode}}function ef(r){return r instanceof Window?r.pageYOffset>Math.max(0,r.document.documentElement.scrollHeight-r.innerHeight-4):r.scrollTop>Math.max(1,r.scrollHeight-r.clientHeight-4)}function tf(r,e){for(let t=r,i=e;;){if(t.nodeType==3&&i>0)return{node:t,offset:i};if(t.nodeType==1&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=Xt(t)}else if(t.parentNode&&!br(t))i=di(t),t=t.parentNode;else return null}}function nf(r,e){for(let t=r,i=e;;){if(t.nodeType==3&&i<t.nodeValue.length)return{node:t,offset:i};if(t.nodeType==1&&i<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[i],i=0}else if(t.parentNode&&!br(t))i=di(t)+1,t=t.parentNode;else return null}}class Mt{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new Mt(e.parentNode,di(e),t)}static after(e,t){return new Mt(e.parentNode,di(e)+1,t)}}var Ce=(function(r){return r[r.LTR=0]="LTR",r[r.RTL=1]="RTL",r})(Ce||(Ce={}));const Ti=Ce.LTR,Po=Ce.RTL;function rf(r){let e=[];for(let t=0;t<r.length;t++)e.push(1<<+r[t]);return e}const ep=rf("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),tp=rf("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),eo=Object.create(null),Ft=[];for(let r of["()","[]","{}"]){let e=r.charCodeAt(0),t=r.charCodeAt(1);eo[e]=t,eo[t]=-e}function sf(r){return r<=247?ep[r]:1424<=r&&r<=1524?2:1536<=r&&r<=1785?tp[r-1536]:1774<=r&&r<=2220?4:8192<=r&&r<=8204?256:64336<=r&&r<=65023?4:1}const ip=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class $t{get dir(){return this.level%2?Po:Ti}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,i,n){let s=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==i)return o;(s<0||(n!=0?n<0?l.from<t:l.to>t:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function of(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++){let i=r[t],n=e[t];if(i.from!=n.from||i.to!=n.to||i.direction!=n.direction||!of(i.inner,n.inner))return!1}return!0}const ke=[];function np(r,e,t,i,n){for(let s=0;s<=i.length;s++){let o=s?i[s-1].to:e,l=s<i.length?i[s].from:t,h=s?256:n;for(let u=o,p=h,m=h;u<l;u++){let y=sf(r.charCodeAt(u));y==512?y=p:y==8&&m==4&&(y=16),ke[u]=y==4?2:y,y&7&&(m=y),p=y}for(let u=o,p=h,m=h;u<l;u++){let y=ke[u];if(y==128)u<l-1&&p==ke[u+1]&&p&24?y=ke[u]=p:ke[u]=256;else if(y==64){let x=u+1;for(;x<l&&ke[x]==64;)x++;let S=u&&p==8||x<t&&ke[x]==8?m==1?1:8:256;for(let C=u;C<x;C++)ke[C]=S;u=x-1}else y==8&&m==1&&(ke[u]=1);p=y,y&7&&(m=y)}}}function rp(r,e,t,i,n){let s=n==1?2:1;for(let o=0,l=0,h=0;o<=i.length;o++){let u=o?i[o-1].to:e,p=o<i.length?i[o].from:t;for(let m=u,y,x,S;m<p;m++)if(x=eo[y=r.charCodeAt(m)])if(x<0){for(let C=l-3;C>=0;C-=3)if(Ft[C+1]==-x){let O=Ft[C+2],B=O&2?n:O&4?O&1?s:n:0;B&&(ke[m]=ke[Ft[C]]=B),l=C;break}}else{if(Ft.length==189)break;Ft[l++]=m,Ft[l++]=y,Ft[l++]=h}else if((S=ke[m])==2||S==1){let C=S==n;h=C?0:1;for(let O=l-3;O>=0;O-=3){let B=Ft[O+2];if(B&2)break;if(C)Ft[O+2]|=2;else{if(B&4)break;Ft[O+2]|=4}}}}}function sp(r,e,t,i){for(let n=0,s=i;n<=t.length;n++){let o=n?t[n-1].to:r,l=n<t.length?t[n].from:e;for(let h=o;h<l;){let u=ke[h];if(u==256){let p=h+1;for(;;)if(p==l){if(n==t.length)break;p=t[n++].to,l=n<t.length?t[n].from:e}else if(ke[p]==256)p++;else break;let m=s==1,y=(p<e?ke[p]:i)==1,x=m==y?m?1:2:i;for(let S=p,C=n,O=C?t[C-1].to:r;S>h;)S==O&&(S=t[--C].from,O=C?t[C-1].to:r),ke[--S]=x;h=p}else s=u,h++}}}function to(r,e,t,i,n,s,o){let l=i%2?2:1;if(i%2==n%2)for(let h=e,u=0;h<t;){let p=!0,m=!1;if(u==s.length||h<s[u].from){let C=ke[h];C!=l&&(p=!1,m=C==16)}let y=!p&&l==1?[]:null,x=p?i:i+1,S=h;e:for(;;)if(u<s.length&&S==s[u].from){if(m)break e;let C=s[u];if(!p)for(let O=C.to,B=u+1;;){if(O==t)break e;if(B<s.length&&s[B].from==O)O=s[B++].to;else{if(ke[O]==l)break e;break}}if(u++,y)y.push(C);else{C.from>h&&o.push(new $t(h,C.from,x));let O=C.direction==Ti!=!(x%2);io(r,O?i+1:i,n,C.inner,C.from,C.to,o),h=C.to}S=C.to}else{if(S==t||(p?ke[S]!=l:ke[S]==l))break;S++}y?to(r,h,S,i+1,n,y,o):h<S&&o.push(new $t(h,S,x)),h=S}else for(let h=t,u=s.length;h>e;){let p=!0,m=!1;if(!u||h>s[u-1].to){let C=ke[h-1];C!=l&&(p=!1,m=C==16)}let y=!p&&l==1?[]:null,x=p?i:i+1,S=h;e:for(;;)if(u&&S==s[u-1].to){if(m)break e;let C=s[--u];if(!p)for(let O=C.from,B=u;;){if(O==e)break e;if(B&&s[B-1].to==O)O=s[--B].from;else{if(ke[O-1]==l)break e;break}}if(y)y.push(C);else{C.to<h&&o.push(new $t(C.to,h,x));let O=C.direction==Ti!=!(x%2);io(r,O?i+1:i,n,C.inner,C.from,C.to,o),h=C.from}S=C.from}else{if(S==e||(p?ke[S-1]!=l:ke[S-1]==l))break;S--}y?to(r,S,h,i+1,n,y,o):S<h&&o.push(new $t(S,h,x)),h=S}}function io(r,e,t,i,n,s,o){let l=e%2?2:1;np(r,n,s,i,l),rp(r,n,s,i,l),sp(n,s,i,l),to(r,n,s,e,t,i,o)}function op(r,e,t){if(!r)return[new $t(0,0,e==Po?1:0)];if(e==Ti&&!t.length&&!ip.test(r))return lf(r.length);if(t.length)for(;r.length>ke.length;)ke[ke.length]=256;let i=[],n=e==Ti?0:1;return io(r,n,n,t,0,r.length,i),i}function lf(r){return[new $t(0,r,0)]}let af="";function lp(r,e,t,i,n){var s;let o=i.head-r.from,l=$t.find(e,o,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc),h=e[l],u=h.side(n,t);if(o==u){let y=l+=n?1:-1;if(y<0||y>=e.length)return null;h=e[l=y],o=h.side(!n,t),u=h.side(n,t)}let p=Ne(r.text,o,h.forward(n,t));(p<h.from||p>h.to)&&(p=u),af=r.text.slice(Math.min(o,p),Math.max(o,p));let m=l==(n?e.length-1:0)?null:e[l+(n?1:-1)];return m&&p==u&&m.level+(n?0:1)<h.level?I.cursor(m.side(!n,t)+r.from,m.forward(n,t)?1:-1,m.level):I.cursor(p+r.from,h.forward(n,t)?-1:1,h.level)}function ap(r,e,t){for(let i=e;i<t;i++){let n=sf(r.charCodeAt(i));if(n==1)return Ti;if(n==2||n==4)return Po}return Ti}const hf=j.define(),ff=j.define(),uf=j.define(),cf=j.define(),no=j.define(),df=j.define(),pf=j.define(),No=j.define(),Fo=j.define(),gf=j.define({combine:r=>r.some(e=>e)}),mf=j.define({combine:r=>r.some(e=>e)}),vf=j.define();class Ji{constructor(e,t,i,n,s,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=n,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new Ji(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new Ji(I.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Xn=me.define({map:(r,e)=>r.map(e)}),yf=me.define();function _t(r,e,t){let i=r.facet(cf);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const Gt=j.define({combine:r=>r.length?r[0]:!0});let hp=0;const Vi=j.define({combine(r){return r.filter((e,t)=>{for(let i=0;i<t;i++)if(r[i].plugin==e.plugin)return!1;return!0})}});class wt{constructor(e,t,i,n,s){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=n,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(Vi.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(Vi.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:i,eventObservers:n,provide:s,decorations:o}=t||{};return new wt(hp++,e,i,n,l=>{let h=[];return o&&h.push(Kr.of(u=>{let p=u.plugin(l);return p?o(p):de.none})),s&&h.push(s(l)),h})}static fromClass(e,t){return wt.define((i,n)=>new e(i,n),t)}}class ms{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(_t(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){_t(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){_t(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const kf=j.define(),Ho=j.define(),Kr=j.define(),xf=j.define(),Wo=j.define(),Wn=j.define(),wf=j.define();function ka(r,e){let t=r.state.facet(wf);if(!t.length)return t;let i=t.map(s=>s instanceof Function?s(r):s),n=[];return ue.spans(i,e.from,e.to,{point(){},span(s,o,l,h){let u=s-e.from,p=o-e.from,m=n;for(let y=l.length-1;y>=0;y--,h--){let x=l[y].spec.bidiIsolate,S;if(x==null&&(x=ap(e.text,u,p)),h>0&&m.length&&(S=m[m.length-1]).to==u&&S.direction==x)S.to=p,m=S.inner;else{let C={from:u,to:p,direction:x,inner:[]};m.push(C),m=C.inner}}}}),n}const bf=j.define();function Sf(r){let e=0,t=0,i=0,n=0;for(let s of r.state.facet(bf)){let o=s(r);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(n=Math.max(n,o.bottom)))}return{left:e,right:t,top:i,bottom:n}}const mn=j.define();class yt{constructor(e,t,i,n){this.fromA=e,this.toA=t,this.fromB=i,this.toB=n}join(e){return new yt(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let n=e[t-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(t.length==0)return e;let i=[];for(let n=0,s=0,o=0;;){let l=n<e.length?e[n].fromB:1e9,h=s<t.length?t[s]:1e9,u=Math.min(l,h);if(u==1e9)break;let p=u+o,m=u,y=p;for(;;)if(s<t.length&&t[s]<=m){let x=t[s+1];s+=2,m=Math.max(m,x);for(let S=n;S<e.length&&e[S].fromB<=m;S++)o=e[S].toA-e[S].toB;y=Math.max(y,x+o)}else if(n<e.length&&e[n].fromB<=m){let x=e[n++];m=Math.max(m,x.toB),y=Math.max(y,x.toA),o=x.toA-x.toB}else break;i.push(new yt(p,y,u,m))}return i}}class Sr{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=Ie.empty(this.startState.doc.length);for(let s of i)this.changes=this.changes.compose(s.changes);let n=[];this.changes.iterChangedRanges((s,o,l,h)=>n.push(new yt(s,o,l,h))),this.changedRanges=n}static create(e,t,i){return new Sr(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const fp=[];class Te{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return fp}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&qd(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;for(let n of this.children){if(n==e)return i;i+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,i){return null}domPosFor(e,t){let i=di(this.dom),n=this.length?e>0:t>0;return new Mt(this.parent.dom,i+(n?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof $r)return e;return null}static get(e){return e.cmTile}}class zr extends Te{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,i=null,n,s=e?.node==t?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,n=i?i.nextSibling:t.firstChild,s&&n!=l.dom&&(s.written=!0),l.dom.parentNode==t)for(;n&&n!=l.dom;)n=xa(n);else t.insertBefore(l.dom,n);i=l.dom}for(n=i?i.nextSibling:t.firstChild,s&&n&&(s.written=!0);n;)n=xa(n);this.length=o}}function xa(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}class $r extends zr{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=Te.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,n=0,s=0;;)if(n==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&s++,n=t.pop()}else{let o=i.children[n++];if(o instanceof Qt)t.push(n),i=o,n=0;else{let l=s+o.length,h=e(o,s);if(h!==void 0)return h;s=l+o.breakAfter}}}resolveBlock(e,t){let i,n=-1,s,o=-1;if(this.blockTiles((l,h)=>{let u=h+l.length;if(e>=h&&e<=u){if(l.isWidget()&&t>=-1&&t<=1){if(l.flags&32)return!0;l.flags&16&&(i=void 0)}(h<e||e==u&&(t<-1?l.length:l.covers(1)))&&(!i||!l.isWidget()&&i.isWidget())&&(i=l,n=e-h),(u>e||e==h&&(t>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-h)}}),!i&&!s)throw new Error("No tile at position "+e);return i&&t<0||!s?{tile:i,offset:n}:{tile:s,offset:o}}}class Qt extends zr{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new Qt(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class Qi extends zr{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let n=new Qi(t||document.createElement("div"),e);return(!t||!i)&&(n.flags|=4),n}get domAttrs(){return this.attrs}resolveInline(e,t,i){let n=null,s=-1,o=null,l=-1;function h(p,m){for(let y=0,x=0;y<p.children.length&&x<=m;y++){let S=p.children[y],C=x+S.length;C>=m&&(S.isComposite()?h(S,m-x):(!o||o.isHidden&&(t>0&&!(o.flags&32)||i&&cp(o,S)))&&(C>m||S.flags&32&&t<=1)?(o=S,l=m-x):(x<m||S.flags&16&&!S.isHidden&&t>=-1)&&(n=S,s=m-x)),x=C}}h(this,e);let u=(t<0?n:o)||n||o;return u?{tile:u,offset:u==n?s:l}:null}coordsIn(e,t,i){let n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t,i):up(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:n,offset:s}=i;if(this.dom.contains(n.dom))return n.isText()?new Mt(n.dom,Math.min(n.dom.nodeValue.length,s)):n.domPosFor(s,n.flags&16?1:n.flags&32?-1:t);let o=i.tile.parent,l=!1;for(let h of o.children){if(l)return new Mt(h.dom,0);h==i.tile&&(l=!0)}}return new Mt(this.dom,0)}}function up(r){let e=r.dom.lastChild;if(!e)return r.dom.getBoundingClientRect();let t=bn(e);return t[t.length-1]||null}function cp(r,e){let t=r.coordsIn(0,1),i=e.coordsIn(0,1);return t&&i&&i.top<t.bottom}class lt extends zr{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let i=new lt(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class Si extends Te{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t,i){let n=this.dom.nodeValue.length;e>n&&(e=n);let s=e,o=e,l=0;e==0&&t<0||e==n&&t>=0?_.chrome||_.gecko||(e?(s--,l=1):o<n&&(o++,l=-1)):t<0?s--:o<n&&o++;let h=In(this.dom,s,o).getClientRects();if(!h.length)return null;let u=h[(l?l<0:t>=0)?0:h.length-1];return _.safari&&!l&&u.width==0&&(u=Array.prototype.find.call(h,p=>p.width)||u),i==null?u:En(u,(l?l>0:t<0)==i)}static of(e,t){let i=new Si(t||document.createTextNode(e),e);return t||(i.flags|=2),i}}class Oi extends Te{constructor(e,t,i,n){super(e,t,n),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;if(i)return En(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let h=l?s.length-1:0;o=s[h],!(e>0?h==0:h==s.length-1||o.top<o.bottom);h+=l?-1:1);return En(o,!l)}}get overrideDOMText(){if(!this.length)return ce.empty;let{root:e}=this;if(!e)return ce.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,i,n,s){return s||(s=e.toDOM(t),e.editable||(s.contentEditable="false")),new Oi(s,i,e,n)}}class Cr extends Te{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return ce.empty}coordsIn(e,t,i){let n=this.dom.getBoundingClientRect();return i==null?n:En(n,t>0==i)}}class dp{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:n,index:s,beforeBreak:o,parents:l}=this;for(;e||t>0;)if(n.isComposite())if(o){if(!e)break;i&&i.break(),e--,o=!1}else if(s==n.children.length){if(!e&&!l.length)break;i&&i.leave(n),o=!!n.breakAfter,{tile:n,index:s}=l.pop(),s++}else{let h=n.children[s],u=h.breakAfter;(t>0?h.length<=e:h.length<e)&&(!i||i.skip(h,0,h.length)!==!1||!h.isComposite)?(o=!!u,s++,e-=h.length):(l.push({tile:n,index:s}),n=h,s=0,i&&h.isComposite()&&i.enter(h))}else{let h=n.length;if(s<h&&e){let u=Math.min(e,h-s);i&&i.skip(n,s,s+u),e-=u,s+=u}if(s==h)o=!!n.breakAfter,{tile:n,index:s}=l.pop(),s++;else if(!e)break}return this.tile=n,this.index=s,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class pp{constructor(e,t,i,n){this.from=e,this.to=t,this.wrapper=i,this.rank=n}}class gp{constructor(e,t,i){this.cache=e,this.root=t,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,i,n){var s;this.flushBuffer();let o=this.ensureMarks(t,i),l=o.lastChild;if(l&&l.isText()&&!(l.flags&8)&&l.length+e.length<512){this.cache.reused.set(l,2);let h=o.children[o.children.length-1]=new Si(l.dom,l.text+e);h.parent=o}else o.append(n||Si.of(e,(s=this.cache.find(Si))===null||s===void 0?void 0:s.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let i=this.curLine;i.dom!=t.line.dom&&(i.setDOM(this.cache.reused.has(t.line)?vs(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let n=i;for(let l=t.marks.length-1;l>=0;l--){let h=t.marks[l],u=n.lastChild;if(u instanceof lt&&u.mark.eq(h.mark))u.dom!=h.dom&&u.setDOM(vs(h.dom)),n=u;else{let{dom:p}=h;this.cache.reused.get(h)&&Te.get(h.dom)&&(p=vs(h.dom));let m=lt.of(h.mark,p);n.append(m),n=m}this.cache.reused.set(h,2)}let s=Te.get(e.text);s&&this.cache.reused.set(s,2);let o=new Si(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,n.append(o)}addInlineWidget(e,t,i){let n=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);n||this.flushBuffer();let s=this.ensureMarks(t,i);!n&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=Cf);let n=Qi.start(e,t||((i=this.cache.find(Qi))===null||i===void 0?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=n)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var i;let n=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(t>0&&(l=n.lastChild)&&l instanceof lt&&l.mark.eq(o))n=l,t--;else{let h=lt.of(o,(i=this.cache.find(lt,u=>u.mark.eq(o)))===null||i===void 0?void 0:i.dom);n.append(h),n=h,t=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!wa(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(_.ios&&wa(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(ys,0,32)||new Oi(ys.toDOM(),0,ys,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=e.rank*102+e.value.rank,i=new pp(e.from,e.to,e.value,t),n=this.wrappers.length;for(;n>0&&(this.wrappers[n-1].rank-i.rank||this.wrappers[n-1].to-i.to)<0;)n--;this.wrappers.splice(n,0,i)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let n=t.lastChild;if(i.from<this.pos&&n instanceof Qt&&n.wrapper.eq(i.wrapper))t=n;else{let s=Qt.of(i.wrapper,(e=this.cache.find(Qt,o=>o.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(s),t=s}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(Cr,void 0,1);return i&&(i.flags=t),i||new Cr(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class mp{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:n,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=n;let l=this.textOff=Math.min(e,n.length);return s?null:n.slice(0,l)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}}const Ar=[Oi,Qi,Si,lt,Cr,Qt,$r];for(let r=0;r<Ar.length;r++)Ar[r].bucket=r;class vp{constructor(e){this.view=e,this.buckets=Ar.map(()=>[]),this.index=Ar.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let n=e.bucket,s=this.buckets[n],o=this.index[n];for(let l=0;l<s.length;l++){let h=(l+o)%s.length,u=s[h];if((!t||t(u))&&!this.reused.has(u))return s.splice(h,1),h<o&&this.index[n]--,this.reused.set(u,i),u}return null}findWidget(e,t,i){let n=this.buckets[0];if(n.length)for(let s=0,o=0;;s++){if(s==n.length){if(o)return null;o=1,s=0}let l=n[s];if(!this.reused.has(l)&&(o==0?l.widget.compare(e):l.widget.constructor==e.constructor&&e.updateDOM(l.dom,this.view,l.widget)))return n.splice(s,1),s<this.index[0]&&this.index[0]--,l.widget==e&&l.length==t&&(l.flags&497)==i?(this.reused.set(l,1),l):(this.reused.set(l,2),new Oi(l.dom,t,e,l.flags&-498|i))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class yp{constructor(e,t,i,n,s){this.view=e,this.decorations=n,this.disallowBlockEffectsFor=s,this.openWidget=!1,this.openMarks=0,this.cache=new vp(e),this.text=new mp(e.state.doc),this.builder=new gp(this.cache,new $r(e,e.contentDOM),ue.iter(i)),this.cache.reused.set(t,2),this.old=new dp(t),this.reuseWalker={skip:(o,l,h)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let n=0,s=0,o=0;;){let l=o<e.length?e[o++]:null,h=l?l.fromA:this.old.root.length;if(h>n){let u=h-n;this.preserve(u,!o,!l),n=h,s+=u}if(!l)break;t&&l.fromA<=t.range.fromA&&l.toA>=t.range.toA?(this.forward(l.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(s,t.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(t,i),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,l.toA),this.emit(t.range.toB,l.toB)):(this.forward(l.fromA,l.toA),this.emit(s,l.toB)),s=l.toB,n=l.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,i){let n=wp(this.old),s=this.openMarks;this.old.advance(e,i?1:-1,{skip:(o,l,h)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(h-l);else{let u=h>0||l<o.length?Oi.of(o.widget,this.view,h-l,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);u.flags&256?(u.flags&=-2,this.builder.addBlockWidget(u)):(this.builder.ensureLine(null),this.builder.addInlineWidget(u,n,s),s=n.length)}else if(o.isText())this.builder.ensureLine(null),!l&&h==o.length&&!this.cache.reused.has(o)?this.builder.addText(o.text,n,s,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(l,h),n,s)),s=n.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof Cr)this.cache.add(o);else if(o instanceof lt)this.builder.ensureLine(null),this.builder.addMark(o,n,s),this.cache.reused.set(o,1),s=n.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof lt&&n.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?n.length&&(n.length=s=0):o instanceof lt&&(n.shift(),s=Math.min(s,n.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,n=this.builder,s=-1,o=ue.spans(this.decorations,e,t,{point:(l,h,u,p,m,y)=>{if(u instanceof Mi){if(this.disallowBlockEffectsFor[y]){if(u.block)throw new RangeError("Block decorations may not be specified via plugins");if(h>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=p.length,m>p.length)n.continueWidget(h-l);else{let x=u.widget||(u.block?Xi.block:Xi.inline),S=kp(u),C=this.cache.findWidget(x,h-l,S)||Oi.of(x,this.view,h-l,S);u.block?(u.startSide>0&&n.addLineStartIfNotCovered(i),n.addBlockWidget(C)):(n.ensureLine(i),n.addInlineWidget(C,p,m))}i=null}else i=xp(i,u);h>l&&this.text.skip(h-l)},span:(l,h,u,p)=>{for(let m=l;m<h;){let y=this.text.next(Math.min(512,h-m));y==null?(n.addLineStartIfNotCovered(i),n.addBreak(),m++):(n.ensureLine(i),n.addText(y,u,m==l?p:u.length),m+=y.length),i=null}s=u.length}});s>-1&&(this.openWidget=o>s),this.openWidget||n.addLineStartIfNotCovered(i),this.openMarks=o}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let n=e.parentNode;;n=n.parentNode){let s=Te.get(n);if(n==this.view.contentDOM)break;s instanceof lt?t.push(s):s?.isLine()?i=s:s instanceof Qt||(n.nodeName=="DIV"&&!i?i=new Qi(n,Cf):i||t.push(lt.of(new Fn({tagName:n.nodeName.toLowerCase(),attributes:Ud(n)}),n)))}return i?{line:i,marks:t}:null}}function wa(r,e){let t=i=>{for(let n of i.children)if((e?n.isText():n.length)||t(n))return!0;return!1};return t(r)}function kp(r){let e=r.isReplace?(r.startSide<0?64:0)|(r.endSide>0?128:0):r.startSide>0?32:16;return r.block&&(e|=256),e}const Cf={class:"cm-line"};function xp(r,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(r||(r={class:"cm-line"}),t&&Eo(t,r),i&&(r.class+=" "+i)),r}function wp(r){let e=[];for(let t=r.parents.length;t>1;t--){let i=t==r.parents.length?r.tile:r.parents[t].tile;i instanceof lt&&e.push(i.mark)}return e}function vs(r){let e=Te.get(r);return e&&e.setDOM(r.cloneNode()),r}class Xi extends pi{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Xi.inline=new Xi("span");Xi.block=new Xi("div");const ys=new class extends pi{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class ba{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=de.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new $r(e,e.contentDOM),this.updateInner([new yt(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:p,toA:m})=>m<this.minWidthFrom||p>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?n=this.domChanged.newSel.head:!Bp(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let s=n>-1?Sp(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:p,to:m}=this.hasComposition;i=new yt(p,m,e.changes.mapPos(p,-1),e.changes.mapPos(m,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(_.ie||_.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let h=Mp(o,this.decorations,e.changes);h.length&&(i=yt.extendWithRanges(i,h));let u=Op(l,this.blockWrappers,e.changes);return u.length&&(i=yt.extendWithRanges(i,u)),s&&!i.some(p=>p.fromA<=s.range.fromA&&p.toA>=s.range.toA)&&(i=s.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let o=this.tile,l=new yp(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&Te.get(t.text)&&l.cache.reused.set(Te.get(t.text),2),this.tile=l.run(e,t),ro(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=_.chrome||_.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||i.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let n=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let s of this.tile.children)s.isWidget()&&s.widget instanceof ks&&n.push(s.dom);i.updateGaps(n)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let i of t.effects)i.is(yf)&&(this.editContextFormatting=i.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:i}=this.tile,n=this.view.root.activeElement,s=n==i,o=!s&&!(this.view.state.facet(Gt)||i.tabIndex>-1)&&wn(i,this.view.observer.selectionRange)&&!(n&&i.contains(n));if(!(s||t||o))return;let l=this.forceSelection;this.forceSelection=!1;let h=this.view.state.selection.main,u,p;if(h.empty?p=u=this.inlineDOMNearPos(h.anchor,h.assoc||1):(p=this.inlineDOMNearPos(h.head,h.head==h.from?1:-1),u=this.inlineDOMNearPos(h.anchor,h.anchor==h.from?1:-1)),_.gecko&&h.empty&&!this.hasComposition&&bp(u)){let y=document.createTextNode("");this.view.observer.ignore(()=>u.node.insertBefore(y,u.node.childNodes[u.offset]||null)),u=p=new Mt(y,0),l=!0}let m=this.view.observer.selectionRange;(l||!m.focusNode||(!Sn(u.node,u.offset,m.anchorNode,m.anchorOffset)||!Sn(p.node,p.offset,m.focusNode,m.focusOffset))&&!this.suppressWidgetCursorChange(m,h))&&(this.view.observer.ignore(()=>{_.android&&_.chrome&&i.contains(m.focusNode)&&Lp(m.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let y=Rn(this.view.root);if(y)if(h.empty){if(_.gecko){let x=Cp(u.node,u.offset);if(x&&x!=3){let S=(x==1?tf:nf)(u.node,u.offset);S&&(u=new Mt(S.node,S.offset))}}y.collapse(u.node,u.offset),h.bidiLevel!=null&&y.caretBidiLevel!==void 0&&(y.caretBidiLevel=h.bidiLevel)}else if(y.extend){y.collapse(u.node,u.offset);try{y.extend(p.node,p.offset)}catch{}}else{let x=document.createRange();h.anchor>h.head&&([u,p]=[p,u]),x.setEnd(p.node,p.offset),x.setStart(u.node,u.offset),y.removeAllRanges(),y.addRange(x)}o&&this.view.root.activeElement==i&&(i.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(u,p)),this.impreciseAnchor=u.precise?null:new Mt(m.anchorNode,m.anchorOffset),this.impreciseHead=p.precise?null:new Mt(m.focusNode,m.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Sn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=Rn(e.root),{anchorNode:n,anchorOffset:s}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let h=this.coordsAt(t.head,-1),u=this.coordsAt(t.head,1);if(!h||!u||h.bottom>u.top)return;let p=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(p.node,p.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let m=e.observer.selectionRange;e.docView.posFromDOM(m.anchorNode,m.anchorOffset)!=t.from&&i.collapse(n,s)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let n=i.posAtStart;if(i.isComposite()){let s;if(e==i.dom)s=i.dom.childNodes[t];else{let o=Xt(e)==0?0:t==0?-1:1;for(;;){let l=e.parentNode;if(l==i.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==i.dom.firstChild)return n;for(;s&&!Te.get(s);)s=s.nextSibling;if(!s)return n+i.length;for(let o=0,l=n;;o++){let h=i.children[o];if(h.dom==s)return l;l+=h.length+h.breakAfter}}else return i.isText()?e==i.dom?n+t:n+(t?i.length:0):n}domAtPos(e,t){let{tile:i,offset:n}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(n,t):i.domIn(n,t)}inlineDOMNearPos(e,t){let i,n=-1,s=!1,o,l=-1,h=!1;return this.tile.blockTiles((u,p)=>{if(u.isWidget()){if(u.flags&32&&p>=e)return!0;u.flags&16&&(s=!0)}else{let m=p+u.length;if(p<=e&&(i=u,n=e-p,s=m<e),m>=e&&!o&&(o=u,l=e-p,h=p>e),p>e&&o)return!0}}),!i&&!o?this.domAtPos(e,t):(s&&o?i=null:h&&i&&(o=null),i&&t<0||!o?i.domIn(n,t):o.domIn(l,t))}coordsAt(e,t,i){let{tile:n,offset:s}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof ks?null:n.coordsInWidget(s,t,!0):n.coordsIn(s,t,i)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function n(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let h=n(l,o);if(h)return h}if(o-=l.length,o<0)break}else if(s.isText()&&o<s.length){let l=Ne(s.text,o);if(l==o)return null;let h=In(s.dom,o,l).getClientRects();for(let u=0;u<h.length;u++){let p=h[u];if(u==h.length-1||p.top<p.bottom&&p.left<p.right)return p}}return null}return n(t,i)}measureVisibleLineHeights(e){let t=[],{from:i,to:n}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,h=this.view.textDirection==Ce.LTR,u=0,p=(m,y,x)=>{for(let S=0;S<m.children.length&&!(y>n);S++){let C=m.children[S],O=y+C.length,B=C.dom.getBoundingClientRect(),{height:F}=B;if(x&&!S&&(u+=B.top-x.top),C instanceof Qt)O>i&&p(C,y,B);else if(y>=i&&(u>0&&t.push(-u),t.push(F+u),u=0,o)){let P=C.dom.lastChild,Q=P?bn(P):[];if(Q.length){let W=Q[Q.length-1],V=h?W.right-B.left:B.right-W.left;V>l&&(l=V,this.minWidth=s,this.minWidthFrom=y,this.minWidthTo=O)}}x&&S==m.children.length-1&&(u+=x.bottom-B.bottom),y=O+C.breakAfter}};return p(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?Ce.RTL:Ce.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,h;for(let u of o.children){if(!u.isText()||/[^ -~]/.test(u.text))return;let p=bn(u.dom);if(p.length!=1)return;l+=p[0].width,h=p[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:h}}});if(e)return e;let t=document.createElement("div"),i,n,s;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=bn(t.firstChild)[0];i=t.getBoundingClientRect().height,n=o&&o.width?o.width/27:7,s=o&&o.height?o.height:i,t.remove()}),{lineHeight:i,charWidth:n,textHeight:s}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,n=0;;n++){let s=n==t.viewports.length?null:t.viewports[n],o=s?s.from-1:this.view.state.doc.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(de.replace({widget:new ks(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return de.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Kr).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),i=!1,n=this.view.state.facet(Wo).map((s,o)=>{let l=typeof s=="function";return l&&(i=!0),l?s(this.view):s});for(n.length&&(this.dynamicDecorationMap[e++]=i,t.push(ue.join(n))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(xf).map(s=>typeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let u=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=u.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let u of this.view.state.facet(vf))try{if(u(this.view,e.range,e))return!0}catch(p){_t(this.view.state,p,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),n;if(!i)return;!t.empty&&(n=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,n.left),top:Math.min(i.top,n.top),right:Math.max(i.right,n.right),bottom:Math.max(i.bottom,n.bottom)});let s=Sf(this.view),o={left:i.left-s.left,top:i.top-s.top,right:i.right+s.right,bottom:i.bottom+s.bottom},{offsetWidth:l,offsetHeight:h}=this.view.scrollDOM;if(Yd(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,h),-h),this.view.textDirection==Ce.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(i.top>window.visualViewport.offsetTop+window.visualViewport.height||i.bottom<window.visualViewport.offsetTop)){let u=this.view.docView.lineAt(t.head,1);if(u){let p=Qh(u.dom);u.dom.scrollIntoView({block:"nearest"}),Xh(p,!1)}}}lineHasWidget(e){let t=i=>i.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){ro(this.tile)}}function ro(r,e){let t=e?.get(r);if(t!=1){t==null&&r.destroy();for(let i of r.children)ro(i,e)}}function bp(r){return r.node.nodeType==1&&r.node.firstChild&&(r.offset==0||r.node.childNodes[r.offset-1].contentEditable=="false")&&(r.offset==r.node.childNodes.length||r.node.childNodes[r.offset].contentEditable=="false")}function Af(r,e){let t=r.observer.selectionRange;if(!t.focusNode)return null;let i=tf(t.focusNode,t.focusOffset),n=nf(t.focusNode,t.focusOffset),s=i||n;if(n&&i&&n.node!=i.node){let l=Te.get(n.node);if(!l||l.isText()&&l.text!=n.node.nodeValue)s=n;else if(r.docView.lastCompositionAfterCursor){let h=Te.get(i.node);!h||h.isText()&&h.text!=i.node.nodeValue||(s=n)}}if(r.docView.lastCompositionAfterCursor=s!=i,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function Sp(r,e,t){let i=Af(r,t);if(!i)return null;let{node:n,from:s,to:o}=i,l=n.nodeValue;if(/[\n\r]/.test(l)||r.state.doc.sliceString(i.from,i.to)!=l)return null;let h=e.invertedDesc;return{range:new yt(h.mapPos(s),h.mapPos(o),s,o),text:n}}function Cp(r,e){return r.nodeType!=1?0:(e&&r.childNodes[e-1].contentEditable=="false"?1:0)|(e<r.childNodes.length&&r.childNodes[e].contentEditable=="false"?2:0)}let Ap=class{constructor(){this.changes=[]}compareRange(e,t){qi(e,t,this.changes)}comparePoint(e,t){qi(e,t,this.changes)}boundChange(e){qi(e,e,this.changes)}};function Mp(r,e,t){let i=new Ap;return ue.compare(r,e,t,i),i.changes}class Tp{constructor(){this.changes=[]}compareRange(e,t){qi(e,t,this.changes)}comparePoint(){}boundChange(e){qi(e,e,this.changes)}}function Op(r,e,t){let i=new Tp;return ue.compare(r,e,t,i),i.changes}function Lp(r,e){for(let t=r;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function Bp(r,e){let t=!1;return e&&r.iterChangedRanges((i,n)=>{i<e.to&&n>e.from&&(t=!0)}),t}class ks extends pi{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function Dp(r,e,t=1){let i=r.charCategorizer(e),n=r.doc.lineAt(e),s=e-n.from;if(n.length==0)return I.cursor(e);s==0?t=1:s==n.length&&(t=-1);let o=s,l=s;t<0?o=Ne(n.text,s,!1):l=Ne(n.text,s);let h=i(n.text.slice(o,l));for(;o>0;){let u=Ne(n.text,o,!1);if(i(n.text.slice(u,o))!=h)break;o=u}for(;l<n.length;){let u=Ne(n.text,l);if(i(n.text.slice(l,u))!=h)break;l=u}return I.undirectionalRange(o+n.from,l+n.from)}function Rp(r,e,t,i,n){let s=Math.round((i-e.left)*r.defaultCharacterWidth);if(r.lineWrapping&&t.height>r.defaultLineHeight*1.5){let l=r.viewState.heightOracle.textHeight,h=Math.floor((n-t.top-(r.defaultLineHeight-l)*.5)/l);s+=h*r.viewState.heightOracle.lineLength}let o=r.state.sliceDoc(t.from,t.to);return t.from+Kd(o,s,r.state.tabSize)}function so(r,e,t){let i=r.lineBlockAt(e);if(Array.isArray(i.type)){let n;for(let s of i.type){if(s.from>e)break;if(!(s.to<e)){if(s.from<e&&s.to>e)return s;(!n||s.type==qe.Text&&(n.type!=s.type||(t<0?s.from<e:s.to>e)))&&(n=s)}}return n||i}return i}function Ep(r,e,t,i){let n=so(r,e.head,e.assoc||-1),s=!i||n.type!=qe.Text||!(r.lineWrapping||n.widgetLineBreaks)?null:r.coordsAtPos(e.assoc<0&&e.head>n.from?e.head-1:e.head);if(s){let l=r.dom.getBoundingClientRect(),h=r.textDirectionAt(n.from),u=r.posAtCoords({x:t==(h==Ce.LTR)?l.right-1:l.left+1,y:(s.top+s.bottom)/2});if(u!=null)return I.cursor(u,t?-1:1)}let o=r.state.doc.lineAt(e.head);return(t?o.to==n.to:o.from==n.from)?r.visualLineSide(o,t):I.cursor(t?n.to:n.from,t?-1:1)}function Sa(r,e,t,i){let n=r.state.doc.lineAt(e.head),s=r.bidiSpans(n),o=r.textDirectionAt(n.from);for(let l=e,h=null;;){let u=lp(n,s,o,l,t),p=af;if(!u){if(n.number==(t?r.state.doc.lines:1))return l;p=`
|
|
9
|
+
`,n=r.state.doc.line(n.number+(t?1:-1)),s=r.bidiSpans(n),u=r.visualLineSide(n,!t)}if(h){if(!h(p))return l}else{if(!i)return u;h=i(p)}l=u}}function Ip(r,e,t){let i=r.state.charCategorizer(e),n=i(t);return s=>{let o=i(s);return n==je.Space&&(n=o),n==o}}function Pp(r,e,t,i){let n=e.head,s=t?1:-1;if(n==(t?r.state.doc.length:0))return I.cursor(n,e.assoc);let o=e.goalColumn,l,h=r.contentDOM.getBoundingClientRect(),u=r.coordsAtPos(n,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),p=r.documentTop;if(u)o==null&&(o=u.left-h.left),l=s<0?u.top:u.bottom;else{let S=r.viewState.lineBlockAt(n);o==null&&(o=Math.min(h.right-h.left,r.defaultCharacterWidth*(n-S.from))),l=(s<0?S.top:S.bottom)+p}let m=h.left+o,y=r.viewState.heightOracle.textHeight>>1,x=i??y;for(let S=0;;S+=y){let C=l+(x+S)*s,O=oo(r,{x:m,y:C},!1,s);if(t?C>h.bottom:C<h.top)return I.cursor(O.pos,O.assoc);let B=r.coordsAtPos(O.pos,O.assoc),F=B?(B.top+B.bottom)/2:0;if(!B||(t?F>l:F<l))return I.cursor(O.pos,O.assoc,void 0,o)}}function Cn(r,e,t){for(;;){let i=0;for(let n of r)n.between(e-1,e+1,(s,o,l)=>{if(e>s&&e<o){let h=i||t||(e-s<o-e?-1:1);e=h<0?s:o,i=h}});if(!i)return e}}function Mf(r,e){let t=null;for(let i=0;i<e.ranges.length;i++){let n=e.ranges[i],s=null;if(n.empty){let o=Cn(r,n.from,0);o!=n.from&&(s=I.cursor(o,-1))}else{let o=Cn(r,n.from,-1),l=Cn(r,n.to,1);(o!=n.from||l!=n.to)&&(n.undirectional?s=I.undirectionalRange(n.from,n.to):s=I.range(n.from==n.anchor?o:l,n.from==n.head?o:l))}s&&(t||(t=e.ranges.slice()),t[i]=s)}return t?I.create(t,e.mainIndex):e}function xs(r,e,t){let i=Cn(r.state.facet(Wn).map(n=>n(r)),t.from,e.head>t.from?-1:1);return i==t.from?t:I.cursor(i,i<t.from?1:-1)}class Kt{constructor(e,t){this.pos=e,this.assoc=t}}function oo(r,e,t,i){let n=r.contentDOM.getBoundingClientRect(),s=n.top+r.viewState.paddingTop,{x:o,y:l}=e,h=l-s,u;for(;;){if(h<0)return new Kt(0,1);if(h>r.viewState.docHeight)return new Kt(r.state.doc.length,-1);if(u=r.elementAtHeight(h),i==null)break;if(u.type==qe.Text){if(i<0?u.to<r.viewport.from:u.from>r.viewport.to)break;let y=r.docView.coordsAt(i<0?u.from:u.to,i>0?-1:1);if(y&&(i<0?y.top<=h+s:y.bottom>=h+s))break}let m=r.viewState.heightOracle.textHeight/2;h=i>0?u.bottom+m:u.top-m}if(r.viewport.from>=u.to||r.viewport.to<=u.from){if(t)return null;if(u.type==qe.Text){let m=Rp(r,n,u,o,l);return new Kt(m,m==u.from?1:-1)}}if(u.type!=qe.Text)return h<(u.top+u.bottom)/2?new Kt(u.from,1):new Kt(u.to,-1);let p=r.docView.lineAt(u.from,2);return(!p||p.length!=u.length)&&(p=r.docView.lineAt(u.from,-2)),new Np(r,o,l,r.textDirectionAt(u.from)).scanTile(p,u.from)}class Np{constructor(e,t,i,n){this.view=e,this.x=t,this.y=i,this.baseDir=n,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:i,spans:n}=this.bidiSpansAt(e);return n[$t.find(n,e-i.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:i,spans:n}=this.bidiSpansAt(e);return n[$t.find(n,e-i.from,-1,t)].dir}bidiIn(e,t){let{spans:i,line:n}=this.bidiSpansAt(e);return i.length>1||i.length&&(i[0].level!=this.baseDir||i[0].to+n.from<t)}scan(e,t,i=!1){let n=0,s=e.length-1,o=new Set,l=this.bidiIn(e[0],e[s]),h,u,p=-1,m=1e9,y;e:for(;n<s;){let S=s-n,C=n+s>>1;t:if(o.has(C)){for(let F=1;F<S;F++){let P=C+F;if(P>=s&&(P-=S),!o.has(P)){C=P;break t}}break e}o.add(C);let O=t(C),B=0;if(O)for(let F=0;F<O.length;F++){let P=O[F];if(!(P.width==0&&O.length>1))if(P.bottom<this.y)(!h||h.bottom<P.bottom)&&(h=P),B=1;else if(P.top>this.y)(!u||u.top>P.top)&&(u=P),B=-1;else{let Q=P.left>this.x?this.x-P.left:P.right<this.x?this.x-P.right:0,W=Math.abs(Q);W<m&&(p=C,m=W,y=P),Q&&(B=Q<0==(this.baseDir==Ce.LTR)?-1:1)}}B==-1&&(!l||this.baseDirAt(e[C],1))?s=C:B==1&&(!l||this.baseDirAt(e[C+1],-1))&&(n=C+1)}if(!y){if(!u&&!h)return{i:0,after:!1};let S=h&&(!u||this.y-h.bottom<u.top-this.y)?h:u;return this.y=(S.top+S.bottom)/2,this.scan(e,t,!0)}if(m&&!i){let{top:S,bottom:C}=y;if(h&&h.bottom>(S+S+C)/3)return this.y=h.bottom-1,this.scan(e,t,!0);if(u&&u.top<(S+C+C)/3)return this.y=u.top+1,this.scan(e,t,!0)}let x=(l?this.dirAt(e[p],1):this.baseDir)==Ce.LTR;return{i:p,after:this.x>(y.left+y.right)/2==x}}scanText(e,t){let i=[];for(let s=0;s<e.length;s=Ne(e.text,s))i.push(t+s);i.push(t+e.length);let n=this.scan(i,s=>{let o=i[s]-t,l=i[s+1]-t;return In(e.dom,o,l).getClientRects()});return n.after?new Kt(i[n.i+1],-1):new Kt(i[n.i],1)}scanTile(e,t){if(!e.length)return new Kt(t,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,t);if(l.isComposite())return this.scanTile(l,t)}let i=[t];for(let l=0,h=t;l<e.children.length;l++)i.push(h+=e.children[l].length);let n=this.scan(i,l=>{let h=e.children[l];return h.flags&48?null:(h.dom.nodeType==1?h.dom:In(h.dom,0,h.length)).getClientRects()}),s=e.children[n.i],o=i[n.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):n.after?new Kt(i[n.i+1],-1):new Kt(o,1)}}const Fi="";class Fp{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(pe.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Fi}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let n=e;;){this.findPointBefore(i,n);let s=this.text.length;this.readNode(n);let o=Te.get(n),l=n.nextSibling;if(l==t){o?.breakAfter&&!l&&i!=this.view.contentDOM&&this.lineBreak();break}let h=Te.get(l);(o&&h?o.breakAfter:(o?o.breakAfter:br(n))||br(l)&&(n.nodeName!="BR"||o?.isWidget())&&this.text.length>s)&&!Wp(l,t)&&this.lineBreak(),n=l}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=n.exec(t))&&(s=l.index,o=l[0].length),this.append(t.slice(i,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let h of this.points)h.node==e&&h.pos>this.text.length&&(h.pos-=o-1);i=s+o}}readNode(e){let t=Te.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let n=i.iter();!n.next().done;)n.lineBreak?this.lineBreak():this.append(n.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(Hp(e,i.node,i.offset)?t:0))}}function Hp(r,e,t){for(;;){if(!e||t<Xt(e))return!1;if(e==r)return!0;t=di(e)+1,e=e.parentNode}}function Wp(r,e){let t;for(;!(r==e||!r);r=r.nextSibling){let i=Te.get(r);if(!i?.isWidget())return!1;i&&(t||(t=[])).push(i)}if(t)for(let i of t){let n=i.overrideDOMText;if(n?.length)return!1}return!0}class Ca{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class Vp{constructor(e,t,i,n){this.typeOver=n,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=Tf(e.docView.tile,t,i,0))){let h=s||o?[]:zp(e),u=new Fp(h,e);u.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=u.text,this.newSel=$p(h,this.bounds.from)}else{let h=e.observer.selectionRange,u=s&&s.node==h.focusNode&&s.offset==h.focusOffset||!Zs(e.contentDOM,h.focusNode)?l.main.head:e.docView.posFromDOM(h.focusNode,h.focusOffset),p=o&&o.node==h.anchorNode&&o.offset==h.anchorOffset||!Zs(e.contentDOM,h.anchorNode)?l.main.anchor:e.docView.posFromDOM(h.anchorNode,h.anchorOffset),m=e.viewport;if((_.ios||_.chrome)&&u!=p&&Math.min(u,p)<=l.main.from&&Math.max(u,p)>=l.main.to&&(m.from>0||m.to<e.state.doc.length)){let y=Math.min(u,p),x=Math.max(u,p),S=m.from-y,C=m.to-x;(S==0||S==1||y==0)&&(C==0||C==-1||x==e.state.doc.length)&&(u=0,p=e.state.doc.length)}if(e.inputState.composing>-1&&l.ranges.length>1)this.newSel=l.replaceRange(I.range(p,u));else if(e.lineWrapping&&p==u&&!(l.main.empty&&l.main.head==u)&&e.inputState.lastTouchTime>Date.now()-100){let y=e.coordsAtPos(u,-1),x=0;y&&(x=e.inputState.lastTouchY<=y.bottom?-1:1),this.newSel=I.create([I.cursor(u,x)])}else this.newSel=I.single(p,u)}}}function Tf(r,e,t,i){if(r.isComposite()){let n=-1,s=-1,o=-1,l=-1;for(let h=0,u=i,p=i;h<r.children.length;h++){let m=r.children[h],y=u+m.length;if(u<e&&y>t)return Tf(m,e,t,u);if(y>=e&&n==-1&&(n=h,s=u),u>t&&m.dom.parentNode==r.dom){o=h,l=p;break}p=y,u=y+m.breakAfter}return{from:s,to:l<0?i+r.length:l,startDOM:(n?r.children[n-1].dom.nextSibling:null)||r.dom.firstChild,endDOM:o<r.children.length&&o>=0?r.children[o].dom:null}}else return r.isText()?{from:i,to:i+r.length,startDOM:r.dom,endDOM:r.dom.nextSibling}:null}function Of(r,e){let t,{newSel:i}=e,{state:n}=r,s=n.selection.main,o=r.inputState.lastKeyTime>Date.now()-100?r.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:h}=e.bounds,u=s.from,p=null;(o===8||_.android&&e.text.length<h-l)&&(u=s.to,p="end");let m=n.doc.sliceString(l,h,Fi),y,x;!s.empty&&s.from>=l&&s.to<=h&&(e.typeOver||m!=e.text)&&m.slice(0,s.from-l)==e.text.slice(0,s.from-l)&&m.slice(s.to-l)==e.text.slice(y=e.text.length-(m.length-(s.to-l)))?t={from:s.from,to:s.to,insert:ce.of(e.text.slice(s.from-l,y).split(Fi))}:(x=Lf(m,e.text,u-l,p))&&(_.chrome&&o==13&&x.toB==x.from+2&&e.text.slice(x.from,x.toB)==Fi+Fi&&x.toB--,t={from:l+x.from,to:l+x.toA,insert:ce.of(e.text.slice(x.from,x.toB).split(Fi))})}else i&&(!r.hasFocus&&n.facet(Gt)||Mr(i,s))&&(i=null);if(!t&&!i)return!1;if((_.mac||_.android)&&t&&t.from==t.to&&t.from==s.head-1&&/^\. ?$/.test(t.insert.toString())&&r.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=I.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:ce.of([t.insert.toString().replace("."," ")])}):n.doc.lineAt(s.from).to<s.to&&r.docView.lineHasWidget(s.to)&&r.inputState.insertingTextAt>Date.now()-50?t={from:s.from,to:s.to,insert:n.toText(r.inputState.insertingText)}:_.chrome&&t&&t.from==t.to&&t.from==s.head&&t.insert.toString()==`
|
|
10
|
+
`&&r.lineWrapping&&(i&&(i=I.single(i.main.anchor-1,i.main.head-1)),t={from:s.from,to:s.to,insert:ce.of([" "])}),t)return Vo(r,t,i,o);if(i&&!Mr(i,s)){let l=!1,h="select";return r.inputState.lastSelectionTime>Date.now()-50&&(r.inputState.lastSelectionOrigin=="select"&&(l=!0),h=r.inputState.lastSelectionOrigin,h=="select.pointer"&&(i=Mf(n.facet(Wn).map(u=>u(r)),i))),r.dispatch({selection:i,scrollIntoView:l,userEvent:h}),!0}else return!1}function Vo(r,e,t,i=-1){if(_.ios&&r.inputState.flushIOSKey(e))return!0;let n=r.state.selection.main;if(_.android&&(e.to==n.to&&(e.from==n.from||e.from==n.from-1&&r.state.sliceDoc(e.from,n.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Ui(r.contentDOM,"Enter",13)||(e.from==n.from-1&&e.to==n.to&&e.insert.length==0||i==8&&e.insert.length<e.to-e.from&&e.to>n.head)&&Ui(r.contentDOM,"Backspace",8)||e.from==n.from&&e.to==n.to+1&&e.insert.length==0&&Ui(r.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();r.inputState.composing>=0&&r.inputState.composing++;let o,l=()=>o||(o=Kp(r,e,t));return r.state.facet(df).some(h=>h(r,e.from,e.to,s,l))||r.dispatch(l()),!0}function Kp(r,e,t){let i,n=r.state,s=n.selection.main,o=-1;if(e.from==e.to&&e.from<s.from||e.from>s.to){let h=e.from<s.from?-1:1,u=h<0?s.from:s.to,p=Cn(n.facet(Wn).map(m=>m(r)),u,h);e.from==p&&(o=p)}if(o>-1)i={changes:e,selection:I.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&r.inputState.composing<0){let h=s.from<e.from?n.sliceDoc(s.from,e.from):"",u=s.to>e.to?n.sliceDoc(e.to,s.to):"";i=n.replaceSelection(r.state.toText(h+e.insert.sliceString(0,void 0,r.state.lineBreak)+u))}else{let h=n.changes(e),u=t&&t.main.to<=h.newLength?t.main:void 0;if(n.selection.ranges.length>1&&(r.inputState.composing>=0||r.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let p=r.state.sliceDoc(e.from,e.to),m,y=t&&Af(r,t.main.head);if(y){let S=e.insert.length-(e.to-e.from);m={from:y.from,to:y.to-S}}else m=r.state.doc.lineAt(s.head);let x=s.to-e.to;i=n.changeByRange(S=>{if(S.from==s.from&&S.to==s.to)return{changes:h,range:u||S.map(h)};let C=S.to-x,O=C-p.length;if(r.state.sliceDoc(O,C)!=p||C>=m.from&&O<=m.to)return{range:S};let B=n.changes({from:O,to:C,insert:e.insert}),F=S.to-s.to;return{changes:B,range:u?I.range(Math.max(0,u.anchor+F),Math.max(0,u.head+F)):S.map(B)}})}else i={changes:h,selection:u&&n.selection.replaceRange(u)}}let l="input.type";return(r.composing||r.inputState.compositionPendingChange&&r.inputState.compositionEndedAt>Date.now()-50)&&(r.inputState.compositionPendingChange=!1,l+=".compose",r.inputState.compositionFirstChange&&(l+=".start",r.inputState.compositionFirstChange=!1)),n.update(i,{userEvent:l,scrollIntoView:!0})}function Lf(r,e,t,i){let n=Math.min(r.length,e.length),s=0;for(;s<n&&r.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==n&&r.length==e.length)return null;let o=r.length,l=e.length;for(;o>0&&l>0&&r.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let h=Math.max(0,s-Math.min(o,l));t-=o+h-s}if(o<s&&r.length<e.length){let h=t<=s&&t>=o?s-t:0;s-=h,l=s+(l-o),o=s}else if(l<s){let h=t<=s&&t>=l?s-t:0;s-=h,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function zp(r){let e=[];if(r.root.activeElement!=r.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:n,focusOffset:s}=r.observer.selectionRange;return t&&(e.push(new Ca(t,i)),(n!=t||s!=i)&&e.push(new Ca(n,s))),e}function $p(r,e){if(r.length==0)return null;let t=r[0].pos,i=r.length==2?r[1].pos:t;return t>-1&&i>-1?I.single(t+e,i+e):null}function Mr(r,e){return e.head==r.main.head&&e.anchor==r.main.anchor}class _p{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,_.safari&&e.contentDOM.addEventListener("input",()=>null),_.gecko&&og(e.contentDOM.ownerDocument)}handleEvent(e){!Zp(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let n of i.observers)n(this.view,t);for(let n of i.handlers){if(t.defaultPrevented)break;if(n(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=qp(e),i=this.handlers,n=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,l=i[s];l&&o!=!l.handlers.length&&(n.removeEventListener(s,this.handleEvent),l=null),l||n.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!t[s]&&n.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Df.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),_.android&&_.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(_.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Bf.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||Up.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return t.shiftKey&&_.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&jp(this.view.win)&&(t.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||this.view.observer.pendingRecords().length||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Ui(this.view.contentDOM,t.key,t.keyCode,t.mods))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:_.safari&&!_.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function jp(r){return r.visualViewport?r.visualViewport.height*r.visualViewport.scale/r.document.documentElement.clientHeight<.85:!1}function Aa(r,e){return(t,i)=>{try{return e.call(r,i,t)}catch(n){_t(t.state,n)}}}function qp(r){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of r){let n=i.spec,s=n&&n.plugin.domEventHandlers,o=n&&n.plugin.domEventObservers;if(s)for(let l in s){let h=s[l];h&&t(l).handlers.push(Aa(i.value,h))}if(o)for(let l in o){let h=o[l];h&&t(l).observers.push(Aa(i.value,h))}}for(let i in Tt)t(i).handlers.push(Tt[i]);for(let i in rt)t(i).observers.push(rt[i]);return e}const Bf=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Up="dthko",Df=[16,17,18,20,91,92,224,225],Zn=6;function er(r){return Math.max(0,r)*.7+8}function Jp(r,e){return Math.max(Math.abs(r.clientX-e.clientX),Math.abs(r.clientY-e.clientY))}class Gp{constructor(e,t,i,n){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Yh(e.contentDOM),this.atoms=e.state.facet(Wn).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(pe.allowMultipleSelections)&&Yp(e,t),this.dragging=Xp(e,t)&&If(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Jp(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,n=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:n,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let h=Sf(this.view);e.clientX-h.left<=n+Zn?t=-er(n-e.clientX):e.clientX+h.right>=o-Zn&&(t=er(e.clientX-o)),e.clientY-h.top<=s+Zn?i=-er(s-e.clientY):e.clientY+h.bottom>=l-Zn&&(i=er(e.clientY-l)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=Mf(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function Yp(r,e){let t=r.state.facet(hf);return t.length?t[0](e):_.mac?e.metaKey:e.ctrlKey}function Qp(r,e){let t=r.state.facet(ff);return t.length?t[0](e):_.mac?!e.altKey:!e.ctrlKey}function Xp(r,e){let{main:t}=r.state.selection;if(t.empty)return!1;let i=Rn(r.root);if(!i||i.rangeCount==0)return!0;let n=i.getRangeAt(0).getClientRects();for(let s=0;s<n.length;s++){let o=n[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Zp(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=r.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=Te.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}const Tt=Object.create(null),rt=Object.create(null),Rf=_.ie&&_.ie_version<15||_.ios&&_.webkit_version<604;function eg(r){let e=r.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{r.focus(),t.remove(),Ef(r,t.value)},50)}function _r(r,e,t){for(let i of r.facet(e))t=i(t,r);return t}function Ef(r,e){e=_r(r.state,No,e);let{state:t}=r,i,n=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(lo!=null&&t.selection.ranges.every(h=>h.empty)&&lo==s.toString()){let h=-1;i=t.changeByRange(u=>{let p=t.doc.lineAt(u.from);if(p.from==h)return{range:u};h=p.from;let m=t.toText((o?s.line(n++).text:e)+t.lineBreak);return{changes:{from:p.from,insert:m},range:I.cursor(u.from+m.length)}})}else o?i=t.changeByRange(h=>{let u=s.line(n++);return{changes:{from:h.from,to:h.to,insert:u.text},range:I.cursor(h.from+u.length)}}):i=t.replaceSelection(s);r.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}rt.scroll=r=>{let e=r.inputState;e.lastScrollTop=r.scrollDOM.scrollTop,e.lastScrollLeft=r.scrollDOM.scrollLeft,_.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};rt.wheel=rt.mousewheel=r=>{r.inputState.lastWheelEvent=Date.now()};Tt.keydown=(r,e)=>(r.inputState.setSelectionOrigin("select"),e.keyCode==27&&r.inputState.tabFocusMode!=0&&(r.inputState.tabFocusMode=Date.now()+2e3),!1);rt.touchstart=(r,e)=>{let t=r.inputState,i=e.targetTouches[0];t.touchActive=!0,t.lastTouchTime=Date.now(),i&&(t.lastTouchX=i.clientX,t.lastTouchY=i.clientY),t.setSelectionOrigin("select.pointer")};rt.touchmove=r=>{r.inputState.setSelectionOrigin("select.pointer")};rt.touchend=(r,e)=>{r.inputState.touchActive=!1};Tt.mousedown=(r,e)=>{if(r.observer.flush(),r.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of r.state.facet(uf))if(t=i(r,e),t)break;if(!t&&e.button==0&&(t=ig(r,e)),t){let i=!r.hasFocus;r.inputState.startMouseSelection(new Gp(r,e,t,i)),i&&r.observer.ignore(()=>{Zh(r.contentDOM);let s=r.root.activeElement;s&&!s.contains(r.contentDOM)&&s.blur()});let n=r.inputState.mouseSelection;if(n)return n.start(e),n.dragging===!1}else r.inputState.setSelectionOrigin("select.pointer");return!1};function Ma(r,e,t,i){if(i==1)return I.cursor(e,t);if(i==2)return Dp(r.state,e,t);{let n=r.docView.lineAt(e,t),s=r.state.doc.lineAt(n?n.posAtEnd:e),o=n?n.posAtStart:s.from,l=n?n.posAtEnd:s.to;return l<r.state.doc.length&&l==s.to&&l++,I.undirectionalRange(o,l)}}const tg=_.ie&&_.ie_version<=11;let Ta=null,Oa=0,La=0;function If(r){if(!tg)return r.detail;let e=Ta,t=La;return Ta=r,La=Date.now(),Oa=!e||t>Date.now()-400&&Math.abs(e.clientX-r.clientX)<2&&Math.abs(e.clientY-r.clientY)<2?(Oa+1)%3:1}function ig(r,e){let t=r.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=If(e),n=r.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),n=n.map(s.changes))},get(s,o,l){let h=r.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),u,p=Ma(r,h.pos,h.assoc,i);if(t.pos!=h.pos&&!o){let m=Ma(r,t.pos,t.assoc,i),y=Math.min(m.from,p.from),x=Math.max(m.to,p.to);p=y<p.from?I.range(y,x,p.assoc):I.range(x,y,p.assoc)}return o?n.replaceRange(n.main.extend(p.from,p.to,p.assoc)):l&&i==1&&n.ranges.length>1&&(u=ng(n,h.pos))?u:l?n.addRange(p):I.create([p])}}}function ng(r,e){for(let t=0;t<r.ranges.length;t++){let{from:i,to:n}=r.ranges[t];if(i<=e&&n>=e)return I.create(r.ranges.slice(0,t).concat(r.ranges.slice(t+1)),r.mainIndex==t?0:r.mainIndex-(r.mainIndex>t?1:0))}return null}Tt.dragstart=(r,e)=>{let{selection:{main:t}}=r.state;if(e.target.draggable){let n=r.docView.tile.nearest(e.target);if(n&&n.isWidget()){let s=n.posAtStart,o=s+n.length;(s>=t.to||o<=t.from)&&(t=I.undirectionalRange(s,o))}}let{inputState:i}=r;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",_r(r.state,Fo,r.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Tt.dragend=r=>(r.inputState.draggedContent=null,!1);function Ba(r,e,t,i){if(t=_r(r.state,No,t),!t)return;let n=r.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=r.inputState,o=i&&s&&Qp(r,e)?{from:s.from,to:s.to}:null,l={from:n,insert:t},h=r.state.changes(o?[o,l]:l);r.focus(),r.dispatch({changes:h,selection:{anchor:h.mapPos(n,-1),head:h.mapPos(n,1)},userEvent:o?"move.drop":"input.drop"}),r.inputState.draggedContent=null}Tt.drop=(r,e)=>{if(!e.dataTransfer)return!1;if(r.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),n=0,s=()=>{++n==t.length&&Ba(r,e,i.filter(o=>o!=null).join(r.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),s()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return Ba(r,e,i,!0),!0}return!1};Tt.paste=(r,e)=>{if(r.state.readOnly)return!0;r.observer.flush();let t=Rf?null:e.clipboardData;return t?(Ef(r,t.getData("text/plain")||t.getData("text/uri-list")),!0):(eg(r),!1)};function rg(r,e){let t=r.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),r.focus()},50)}function sg(r){let e=[],t=[],i=!1;for(let n of r.selection.ranges)n.empty||(e.push(r.sliceDoc(n.from,n.to)),t.push(n));if(!e.length){let n=-1;for(let{from:s}of r.selection.ranges){let o=r.doc.lineAt(s);o.number>n&&(e.push(o.text),t.push({from:o.from,to:Math.min(r.doc.length,o.to+1)})),n=o.number}i=!0}return{text:_r(r,Fo,e.join(r.lineBreak)),ranges:t,linewise:i}}let lo=null;Tt.copy=Tt.cut=(r,e)=>{if(!wn(r.contentDOM,r.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:n}=sg(r.state);if(!t&&!n)return!1;lo=n?t:null,e.type=="cut"&&!r.state.readOnly&&r.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=Rf?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(rg(r,t),!1)};const Pf=Zt.define();function Nf(r,e){let t=[];for(let i of r.facet(pf)){let n=i(r,e);n&&t.push(n)}return t.length?r.update({effects:t,annotations:Pf.of(!0)}):null}function Ff(r){setTimeout(()=>{let e=r.hasFocus;if(e!=r.inputState.notifiedFocused){let t=Nf(r.state,e);t?r.dispatch(t):r.update([])}},10)}rt.focus=r=>{r.inputState.lastFocusTime=Date.now(),!r.scrollDOM.scrollTop&&(r.inputState.lastScrollTop||r.inputState.lastScrollLeft)&&(r.scrollDOM.scrollTop=r.inputState.lastScrollTop,r.scrollDOM.scrollLeft=r.inputState.lastScrollLeft),Ff(r)};rt.blur=r=>{r.observer.clearSelectionRange(),Ff(r)};rt.compositionstart=rt.compositionupdate=r=>{if(!r.observer.editContext&&(r.inputState.compositionFirstChange==null&&(r.inputState.compositionFirstChange=!0),r.inputState.composing<0)){let{main:e}=r.state.selection;!e.empty&&r.lineBlockAt(e.from).from!=r.lineBlockAt(e.to).from&&r.dispatch({changes:r.state.selection.ranges.filter(t=>!t.empty).map(t=>({from:t.from,to:t.to})),userEvent:"input"}),r.inputState.composing=0}};rt.compositionend=r=>{r.observer.editContext||(r.inputState.composing=-1,r.inputState.compositionEndedAt=Date.now(),r.inputState.compositionPendingKey=!0,r.inputState.compositionPendingChange=r.observer.pendingRecords().length>0,r.inputState.compositionFirstChange=null,_.chrome&&_.android?r.observer.flushSoon():r.inputState.compositionPendingChange?Promise.resolve().then(()=>r.observer.flush()):setTimeout(()=>{r.inputState.composing<0&&r.docView.hasComposition&&r.update([])},50))};rt.contextmenu=r=>{r.inputState.lastContextMenu=Date.now()};Tt.beforeinput=(r,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(r.inputState.insertingText=e.data,r.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&r.observer.editContext){let s=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],h=r.posAtDOM(l.startContainer,l.startOffset),u=r.posAtDOM(l.endContainer,l.endOffset);return Vo(r,{from:h,to:u,insert:r.state.toText(s)},null),!0}}let n;if(_.chrome&&_.android&&(n=Bf.find(s=>s.inputType==e.inputType))&&(r.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let s=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&r.hasFocus&&(r.contentDOM.blur(),r.focus())},100)}return _.ios&&e.inputType=="deleteContentForward"&&r.observer.flushSoon(),_.safari&&e.inputType=="insertText"&&r.inputState.composing>=0&&setTimeout(()=>rt.compositionend(r,e),20),!1};const Da=new Set;function og(r){Da.has(r)||(Da.add(r),r.addEventListener("copy",()=>{}),r.addEventListener("cut",()=>{}))}const Ra=["pre-wrap","normal","pre-line","break-spaces"];let Zi=!1;function Ea(){Zi=!1}class lg{constructor(e){this.lineWrapping=e,this.doc=ce.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Ra.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let n=e[i];n<0?i++:this.heightSamples[Math.floor(n*10)]||(t=!0,this.heightSamples[Math.floor(n*10)]=!0)}return t}refresh(e,t,i,n,s,o){let l=Ra.indexOf(e)>-1,h=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=n,this.lineLength=s,h){this.heightSamples={};for(let u=0;u<o.length;u++){let p=o[u];p<0?u++:this.heightSamples[Math.floor(p*10)]=!0}}return h}}class ag{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class At{constructor(e,t,i,n,s){this.from=e,this.length=t,this.top=i,this.height=n,this._content=s}get type(){return typeof this._content=="number"?qe.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Mi?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new At(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var we=(function(r){return r[r.ByPos=0]="ByPos",r[r.ByHeight=1]="ByHeight",r[r.ByPosNoHeight=2]="ByPosNoHeight",r})(we||(we={}));const cr=.001;class it{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>cr&&(Zi=!0),this.height=e)}replace(e,t,i){return it.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,n){let s=this,o=i.doc;for(let l=n.length-1;l>=0;l--){let{fromA:h,toA:u,fromB:p,toB:m}=n[l],y=s.lineAt(h,we.ByPosNoHeight,i.setDoc(t),0,0),x=y.to>=u?y:s.lineAt(u,we.ByPosNoHeight,i,0,0);for(m+=x.to-u,u=x.to;l>0&&y.from<=n[l-1].toA;)h=n[l-1].fromA,p=n[l-1].fromB,l--,h<y.from&&(y=s.lineAt(h,we.ByPosNoHeight,i,0,0));p+=y.from-h,h=y.from;let S=Ko.build(i.setDoc(o),e,p,m);s=Tr(s,s.replace(h,u,S))}return s.updateHeight(i,0)}static empty(){return new ut(0,0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,n=0,s=0;for(;;)if(t==i)if(n>s*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,n-=l.size}else if(s>n*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,s-=l.size}else break;else if(n<s){let l=e[t++];l&&(n+=l.size)}else{let l=e[--i];l&&(s+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,i++),new fg(it.of(e.slice(0,t)),o,it.of(e.slice(i)))}}function Tr(r,e){return r==e?r:(r.constructor!=e.constructor&&(Zi=!0),e)}it.prototype.size=1;const hg=de.replace({});class Hf extends it{constructor(e,t,i){super(e,t),this.deco=i,this.spaceAbove=0}mainBlock(e,t){return new At(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,i,n){return this.spaceAbove&&e<i+this.spaceAbove?new At(n,0,i,this.spaceAbove,hg):this.mainBlock(i,n)}lineAt(e,t,i,n,s){let o=this.mainBlock(n,s);return this.spaceAbove?this.blockAt(0,i,n,s).join(o):o}forEachLine(e,t,i,n,s,o){e<=s+this.length&&t>=s&&o(this.lineAt(0,we.ByPos,i,n,s))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more&&this.setMeasuredHeight(n),this.outdated=!1,this}toString(){return`block(${this.length})`}}class ut extends Hf{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new At(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let n=i[0];return i.length==1&&(n instanceof ut||n instanceof ze&&n.flags&4)&&Math.abs(this.length-n.length)<10?(n instanceof ze?n=new ut(n.length,this.height,this.spaceAbove):n.height=this.height,this.outdated||(n.outdated=!1),n):it.of(i)}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more?this.setMeasuredHeight(n):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class ze extends it{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,n=e.doc.lineAt(t+this.length).number,s=n-i+1,o,l=0;if(e.lineWrapping){let h=Math.min(this.height,e.lineHeight*s);o=h/s,this.length>s+1&&(l=(this.height-h)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:n,perLine:o,perChar:l}}blockAt(e,t,i,n){let{firstLine:s,lastLine:o,perLine:l,perChar:h}=this.heightMetrics(t,n);if(t.lineWrapping){let u=n+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),p=t.doc.lineAt(u),m=l+p.length*h,y=Math.max(i,e-m/2);return new At(p.from,p.length,y,m,0)}else{let u=Math.max(0,Math.min(o-s,Math.floor((e-i)/l))),{from:p,length:m}=t.doc.line(s+u);return new At(p,m,i+l*u,l,0)}}lineAt(e,t,i,n,s){if(t==we.ByHeight)return this.blockAt(e,i,n,s);if(t==we.ByPosNoHeight){let{from:x,to:S}=i.doc.lineAt(e);return new At(x,S-x,0,0,0)}let{firstLine:o,perLine:l,perChar:h}=this.heightMetrics(i,s),u=i.doc.lineAt(e),p=l+u.length*h,m=u.number-o,y=n+l*m+h*(u.from-s-m);return new At(u.from,u.length,Math.max(n,Math.min(y,n+this.height-p)),p,0)}forEachLine(e,t,i,n,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:l,perLine:h,perChar:u}=this.heightMetrics(i,s);for(let p=e,m=n;p<=t;){let y=i.doc.lineAt(p);if(p==e){let S=y.number-l;m+=h*S+u*(e-s-S)}let x=h+u*y.length;o(new At(y.from,y.length,m,x,0)),m+=x,p=y.to+1}}replace(e,t,i){let n=this.length-t;if(n>0){let s=i[i.length-1];s instanceof ze?i[i.length-1]=new ze(s.length+n):i.push(null,new ze(n-1))}if(e>0){let s=i[0];s instanceof ze?i[0]=new ze(e+s.length):i.unshift(new ze(e-1),null)}return it.of(i)}decomposeLeft(e,t){t.push(new ze(e-1),null)}decomposeRight(e,t){t.push(null,new ze(this.length-e-1))}updateHeight(e,t=0,i=!1,n){let s=t+this.length;if(n&&n.from<=t+this.length&&n.more){let o=[],l=Math.max(t,n.from),h=-1;for(n.from>t&&o.push(new ze(n.from-t-1).updateHeight(e,t));l<=s&&n.more;){let p=e.doc.lineAt(l).length;o.length&&o.push(null);let m=n.heights[n.index++],y=0;m<0&&(y=-m,m=n.heights[n.index++]),h==-1?h=m:Math.abs(m-h)>=cr&&(h=-2);let x=new ut(p,m,y);x.outdated=!1,o.push(x),l+=p+1}l<=s&&o.push(null,new ze(s-l).updateHeight(e,l));let u=it.of(o);return(h<0||Math.abs(u.height-this.height)>=cr||Math.abs(h-this.heightMetrics(e,t).perLine)>=cr)&&(Zi=!0),Tr(this,u)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class fg extends it{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,n){let s=i+this.left.height;return e<s?this.left.blockAt(e,t,i,n):this.right.blockAt(e,t,s,n+this.left.length+this.break)}lineAt(e,t,i,n,s){let o=n+this.left.height,l=s+this.left.length+this.break,h=t==we.ByHeight?e<o:e<l,u=h?this.left.lineAt(e,t,i,n,s):this.right.lineAt(e,t,i,o,l);if(this.break||(h?u.to<l:u.from>l))return u;let p=t==we.ByPosNoHeight?we.ByPosNoHeight:we.ByPos;return h?u.join(this.right.lineAt(l,p,i,o,l)):this.left.lineAt(l,p,i,n,s).join(u)}forEachLine(e,t,i,n,s,o){let l=n+this.left.height,h=s+this.left.length+this.break;if(this.break)e<h&&this.left.forEachLine(e,t,i,n,s,o),t>=h&&this.right.forEachLine(e,t,i,l,h,o);else{let u=this.lineAt(h,we.ByPos,i,n,s);e<u.from&&this.left.forEachLine(e,u.from-1,i,n,s,o),u.to>=e&&u.from<=t&&o(u),t>u.to&&this.right.forEachLine(u.to+1,t,i,l,h,o)}}replace(e,t,i){let n=this.left.length+this.break;if(t<n)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-n,t-n,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of i)s.push(l);if(e>0&&Ia(s,o-1),t<this.length){let l=s.length;this.decomposeRight(t,s),Ia(s,l)}return it.of(s)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,n=i+this.break;if(e>=n)return this.right.decomposeRight(e-n,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<n&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?it.of(this.break?[e,null,t]:[e,t]):(this.left=Tr(this.left,e),this.right=Tr(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,n){let{left:s,right:o}=this,l=t+s.length+this.break,h=null;return n&&n.from<=t+s.length&&n.more?h=s=s.updateHeight(e,t,i,n):s.updateHeight(e,t,i),n&&n.from<=l+o.length&&n.more?h=o=o.updateHeight(e,l,i,n):o.updateHeight(e,l,i),h?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Ia(r,e){let t,i;r[e]==null&&(t=r[e-1])instanceof ze&&(i=r[e+1])instanceof ze&&r.splice(e-1,3,new ze(t.length+1+i.length))}const ug=5;class Ko{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof ut?n.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new ut(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let o=t-e;i.block?this.addBlock(new Hf(o,n,i)):(o||s||n>=ug)&&this.addLineDeco(n,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new ut(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new ze(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof ut)return e;let t=new ut(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,e),n.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof ut)&&!this.isCovered?this.nodes.push(new ut(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let n of this.nodes)n instanceof ut&&n.updateHeight(this.oracle,i),i+=n?n.length:1;return this.nodes}static build(e,t,i,n){let s=new Ko(i,e);return ue.spans(t,i,n,s,0),s.finish(i)}}function cg(r,e,t){let i=new dg;return ue.compare(r,e,t,i,0),i.changes}class dg{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,n){(e<t||i&&i.heightRelevant||n&&n.heightRelevant)&&qi(e,t,this.changes,5)}}function pg(r,e){let t=r.getBoundingClientRect(),i=r.ownerDocument,n=i.defaultView||window,s=Math.max(0,t.left),o=Math.min(n.innerWidth,t.right),l=Math.max(0,t.top),h=Math.min(n.innerHeight,t.bottom);for(let u=r.parentNode;u&&u!=i.body;)if(u.nodeType==1){let p=u,m=window.getComputedStyle(p);if((p.scrollHeight>p.clientHeight||p.scrollWidth>p.clientWidth)&&m.overflow!="visible"){let y=p.getBoundingClientRect();s=Math.max(s,y.left),o=Math.min(o,y.right),l=Math.max(l,y.top),h=Math.min(u==r.parentNode?n.innerHeight:h,y.bottom)}u=m.position=="absolute"||m.position=="fixed"?p.offsetParent:p.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,h)-(t.top+e)}}function gg(r){let e=r.getBoundingClientRect(),t=r.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function mg(r,e){let t=r.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class ws{constructor(e,t,i,n){this.from=e,this.to=t,this.size=i,this.displaySize=n}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let n=e[i],s=t[i];if(n.from!=s.from||n.to!=s.to||n.size!=s.size)return!1}return!0}draw(e,t){return de.replace({widget:new vg(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class vg extends pi{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class Pa{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Na,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Ce.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let i=t.facet(Ho).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new lg(i),this.stateDeco=Fa(t),this.heightMap=it.empty().applyChanges(this.stateDeco,ce.empty,this.heightOracle.setDoc(t.doc),[new yt(0,0,0,t.doc.length)]);for(let n=0;n<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());n++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=de.set(this.lineGaps.map(n=>n.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let n=i?t.head:t.anchor;if(!e.some(({from:s,to:o})=>n>=s&&n<=o)){let{from:s,to:o}=this.lineBlockAt(n);e.push(new tr(s,o))}}return this.viewports=e.sort((i,n)=>i.from-n.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Na:new zo(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(vn(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=Fa(this.state);let n=e.changedRanges,s=yt.extendWithRanges(n,cg(i,this.stateDeco,e?e.changes:Ie.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Ea(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||Zi)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let h=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<h.from||t.range.head>h.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,t));let u=h.from!=this.viewport.from||h.to!=this.viewport.to;this.viewport=h,e.flags|=this.updateForViewport(),(u||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(mf)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,i=window.getComputedStyle(t),n=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?Ce.RTL:Ce.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=t.getBoundingClientRect(),h=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let u=0,p=0;if(l.width&&l.height){let{scaleX:W,scaleY:V}=Gh(t,l);(W>.005&&Math.abs(this.scaleX-W)>.005||V>.005&&Math.abs(this.scaleY-V)>.005)&&(this.scaleX=W,this.scaleY=V,u|=16,o=h=!0)}let m=(parseInt(i.paddingTop)||0)*this.scaleY,y=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=m||this.paddingBottom!=y)&&(this.paddingTop=m,this.paddingBottom=y,u|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(n.lineWrapping&&(h=!0),this.editorWidth=e.scrollDOM.clientWidth,u|=16);let x=Yh(this.view.contentDOM,!1).y;x!=this.scrollParent&&(this.scrollParent=x,this.scrollAnchorHeight=-1,this.scrollOffset=0);let S=this.getScrollOffset();this.scrollOffset!=S&&(this.scrollAnchorHeight=-1,this.scrollOffset=S),this.scrolledToBottom=ef(this.scrollParent||e.win);let C=(this.printing?mg:pg)(t,this.paddingTop),O=C.top-this.pixelViewport.top,B=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let F=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(F!=this.inView&&(this.inView=F,F&&(h=!0)),!this.inView&&!this.scrollTarget&&!gg(e.dom))return 0;let P=l.width;if((this.contentDOMWidth!=P||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,u|=16),h){let W=e.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(W)&&(o=!0),o||n.lineWrapping&&Math.abs(P-this.contentDOMWidth)>n.charWidth){let{lineHeight:V,charWidth:N,textHeight:re}=e.docView.measureTextSize();o=V>0&&n.refresh(s,V,N,re,Math.max(5,P/N),W),o&&(e.docView.minWidth=0,u|=16)}O>0&&B>0?p=Math.max(O,B):O<0&&B<0&&(p=Math.min(O,B)),Ea();for(let V of this.viewports){let N=V.from==this.viewport.from?W:e.docView.measureVisibleLineHeights(V);this.heightMap=(o?it.empty().applyChanges(this.stateDeco,ce.empty,this.heightOracle,[new yt(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new ag(V.from,N))}Zi&&(u|=2)}let Q=!this.viewportIsAppropriate(this.viewport,p)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return Q&&(u&2&&(u|=this.updateScaler()),this.viewport=this.getViewport(p,this.scrollTarget),u|=this.updateForViewport()),(u&2||Q)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,h=new tr(n.lineAt(o-i*1e3,we.ByHeight,s,0,0).from,n.lineAt(l+(1-i)*1e3,we.ByHeight,s,0,0).to);if(t){let{head:u}=t.range;if(u<h.from||u>h.to){let p=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),m=n.lineAt(u,we.ByPos,s,0,0),y;t.y=="center"?y=(m.top+m.bottom)/2-p/2:t.y=="start"||t.y=="nearest"&&u<h.from?y=m.top:y=m.bottom-p,h=new tr(n.lineAt(y-1e3/2,we.ByHeight,s,0,0).from,n.lineAt(y+p+1e3/2,we.ByHeight,s,0,0).to)}}return h}mapViewport(e,t){let i=t.mapPos(e.from,-1),n=t.mapPos(e.to,1);return new tr(this.heightMap.lineAt(i,we.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,we.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(e,we.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,we.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||n<=o-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||s>=l+Math.max(10,Math.min(i,250)))&&n>o-2*1e3&&s<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let n of e)t.touchesRange(n.from,n.to)||i.push(new ws(t.mapPos(n.from),t.mapPos(n.to),n.size,n.displaySize));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,s=n>>1,o=n<<1;if(this.defaultTextDirection!=Ce.LTR&&!i)return[];let l=[],h=(p,m,y,x)=>{if(m-p<s)return;let S=this.state.selection.main,C=[S.from];S.empty||C.push(S.to);for(let B of C)if(B>p&&B<m){h(p,B-10,y,x),h(B+10,m,y,x);return}let O=kg(e,B=>B.from>=y.from&&B.to<=y.to&&Math.abs(B.from-p)<s&&Math.abs(B.to-m)<s&&!C.some(F=>B.from<F&&B.to>F));if(!O){if(m<y.to&&t&&i&&t.visibleRanges.some(P=>P.from<=m&&P.to>=m)){let P=t.moveToLineBoundary(I.cursor(m),!1,!0).head;P>p&&(m=P)}let B=this.gapSize(y,p,m,x),F=i||B<2e6?B:2e6;O=new ws(p,m,B,F)}l.push(O)},u=p=>{if(p.length<o||p.type!=qe.Text)return;let m=yg(p.from,p.to,this.stateDeco);if(m.total<o)return;let y=this.scrollTarget?this.scrollTarget.range.head:null,x,S;if(i){let C=n/this.heightOracle.lineLength*this.heightOracle.lineHeight,O,B;if(y!=null){let F=nr(m,y),P=((this.visibleBottom-this.visibleTop)/2+C)/p.height;O=F-P,B=F+P}else O=(this.visibleTop-p.top-C)/p.height,B=(this.visibleBottom-p.top+C)/p.height;x=ir(m,O),S=ir(m,B)}else{let C=m.total*this.heightOracle.charWidth,O=n*this.heightOracle.charWidth,B=0;if(C>2e6)for(let V of e)V.from>=p.from&&V.from<p.to&&V.size!=V.displaySize&&V.from*this.heightOracle.charWidth+B<this.pixelViewport.left&&(B=V.size-V.displaySize);let F=this.pixelViewport.left+B,P=this.pixelViewport.right+B,Q,W;if(y!=null){let V=nr(m,y),N=((P-F)/2+O)/C;Q=V-N,W=V+N}else Q=(F-O)/C,W=(P+O)/C;x=ir(m,Q),S=ir(m,W)}x>p.from&&h(p.from,x,p,m),S<p.to&&h(S,p.to,p,m)};for(let p of this.viewportLines)Array.isArray(p.type)?p.type.forEach(u):u(p);return l}gapSize(e,t,i,n){let s=nr(n,i)-nr(n,t);return this.heightOracle.lineWrapping?e.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(e){ws.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=de.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];ue.spans(t,this.viewport.from,this.viewport.to,{span(s,o){i.push({from:s,to:o})},point(){}},20);let n=0;if(i.length!=this.visibleRanges.length)n=12;else for(let s=0;s<i.length&&!(n&8);s++){let o=this.visibleRanges[s],l=i[s];(o.from!=l.from||o.to!=l.to)&&(n|=4,e&&e.mapPos(o.from,-1)==l.from&&e.mapPos(o.to,1)==l.to||(n|=8))}return this.visibleRanges=i,n}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||vn(this.heightMap.lineAt(e,we.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||vn(this.heightMap.lineAt(this.scaler.fromDOM(e),we.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return vn(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class tr{constructor(e,t){this.from=e,this.to=t}}function yg(r,e,t){let i=[],n=r,s=0;return ue.spans(t,r,e,{span(){},point(o,l){o>n&&(i.push({from:n,to:o}),s+=o-n),n=l}},20),n<e&&(i.push({from:n,to:e}),s+=e-n),{total:s,ranges:i}}function ir({total:r,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(r*t);for(let n=0;;n++){let{from:s,to:o}=e[n],l=o-s;if(i<=l)return s+i;i-=l}}function nr(r,e){let t=0;for(let{from:i,to:n}of r.ranges){if(e<=n){t+=e-i;break}t+=n-i}return t/r.total}function kg(r,e){for(let t of r)if(e(t))return t}const Na={toDOM(r){return r},fromDOM(r){return r},scale:1,eq(r){return r==this}};function Fa(r){let e=r.facet(Kr).filter(i=>typeof i!="function"),t=r.facet(Wo).filter(i=>typeof i!="function");return t.length&&e.push(ue.join(t)),e}class zo{constructor(e,t,i){let n=0,s=0,o=0;this.viewports=i.map(({from:l,to:h})=>{let u=t.lineAt(l,we.ByPos,e,0,0).top,p=t.lineAt(h,we.ByPos,e,0,0).bottom;return n+=p-u,{from:l,to:h,top:u,bottom:p,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(t.height-n);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let t=0,i=0,n=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return n+(e-i)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);i=s.bottom,n=s.domBottom}}fromDOM(e){for(let t=0,i=0,n=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return i+(e-n)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);i=s.bottom,n=s.domBottom}}eq(e){return e instanceof zo?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,i)=>t.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}}function vn(r,e){if(e.scale==1)return r;let t=e.toDOM(r.top),i=e.toDOM(r.bottom);return new At(r.from,r.length,t,i-t,Array.isArray(r._content)?r._content.map(n=>vn(n,e)):r._content)}const rr=j.define({combine:r=>r.join(" ")}),ao=j.define({combine:r=>r.indexOf(!0)>-1}),ho=ui.newName(),Wf=ui.newName(),Vf=ui.newName(),Kf={"&light":"."+Wf,"&dark":"."+Vf};function fo(r,e,t){return new ui(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,n=>{if(n=="&")return r;if(!t||!t[n])throw new RangeError(`Unsupported selector: ${n}`);return t[n]}):r+" "+i}})}const xg=fo("."+ho,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Kf),wg={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},bs=_.ie&&_.ie_version<=11;class bg{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Qd,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(_.ie&&_.ie_version<=11||_.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&_.android&&e.constructor.EDIT_CONTEXT!==!1&&!(_.chrome&&_.chrome_version<126)&&(this.editContext=new Cg(e),e.state.facet(Gt)&&(e.contentDOM.editContext=this.editContext.editContext)),bs&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(Gt)?i.root.activeElement!=this.dom:!wn(this.dom,n))return;let s=n.anchorNode&&i.docView.tile.nearest(n.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(_.ie&&_.ie_version<=11||_.android&&_.chrome)&&!i.state.selection.main.empty&&n.focusNode&&Sn(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Rn(e.root);if(!t)return!1;let i=_.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Sg(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let n=wn(this.dom,i);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&Zd(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),n&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(i.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=t)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,wg),bs&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),bs&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;if(!this.delayedAndroidKey){let n=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Ui(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(n)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,n=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(n=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:n}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),n=this.selectionChanged&&wn(this.dom,this.selectionRange);if(e<0&&!n)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new Vp(this.view,e,t,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,n=Of(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!Mr(this.view.state.selection,t.newSel.main))&&this.view.update([]),n}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let i=Ha(t,e.previousSibling||e.target.previousSibling,-1),n=Ha(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:n?t.posBefore(n):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Gt)!=e.state.facet(Gt)&&(e.view.contentDOM.editContext=e.state.facet(Gt)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Ha(r,e,t){for(;e;){let i=Te.get(e);if(i&&i.parent==r)return i;let n=e.parentNode;e=n!=r.dom?n:t>0?e.nextSibling:e.previousSibling}return null}function Wa(r,e){let t=e.startContainer,i=e.startOffset,n=e.endContainer,s=e.endOffset,o=r.docView.domAtPos(r.state.selection.main.anchor,1);return Sn(o.node,o.offset,n,s)&&([t,i,n,s]=[n,s,t,i]),{anchorNode:t,anchorOffset:i,focusNode:n,focusOffset:s}}function Sg(r,e){if(e.getComposedRanges){let n=e.getComposedRanges(r.root)[0];if(n)return Wa(r,n)}let t=null;function i(n){n.preventDefault(),n.stopImmediatePropagation(),t=n.getTargetRanges()[0]}return r.contentDOM.addEventListener("beforeinput",i,!0),r.dom.ownerDocument.execCommand("indent"),r.contentDOM.removeEventListener("beforeinput",i,!0),t?Wa(r,t):null}class Cg{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let n=e.state.selection.main,{anchor:s,head:o}=n,l=this.toEditorPos(i.updateRangeStart),h=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let u=h-l>i.text.length;l==this.from&&s<this.from?l=s:h==this.to&&s>this.to&&(h=s);let p=Lf(e.state.sliceDoc(l,h),i.text,(u?n.from:n.to)-l,u?"end":null);if(!p){let y=I.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));Mr(y,n)||e.dispatch({selection:y,userEvent:"select"});return}let m={from:p.from+l,to:p.toA+l,insert:ce.of(i.text.slice(p.from,p.toB).split(`
|
|
11
|
+
`))};if((_.mac||_.android)&&m.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(m={from:l,to:h,insert:ce.of([i.text.replace("."," ")])}),this.pendingContextChange=m,!e.state.readOnly){let y=this.to-this.from+(m.to-m.from+m.insert.length);Vo(e,m,I.single(this.toEditorPos(i.selectionStart,y),this.toEditorPos(i.selectionEnd,y)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),m.from<m.to&&!m.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let n=[],s=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o<l;o++){let h=e.coordsForChar(o);s=h&&new DOMRect(h.left,h.top,h.right-h.left,h.bottom-h.top)||s||new DOMRect,n.push(s)}t.updateCharacterBounds(i.rangeStart,n)},this.handlers.textformatupdate=i=>{let n=[];for(let s of i.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let h=this.toEditorPos(s.rangeStart),u=this.toEditorPos(s.rangeEnd);if(h<u){let p=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;n.push(de.mark({attributes:{style:p}}).range(h,u))}}}e.dispatch({effects:yf.of(de.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let n=Rn(i.root);n&&n.rangeCount&&this.editContext.updateSelectionBounds(n.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,n=this.pendingContextChange;return e.changes.iterChanges((s,o,l,h,u)=>{if(i)return;let p=u.length-(o-s);if(n&&o>=n.to)if(n.from==s&&n.to==o&&n.insert.eq(u)){n=this.pendingContextChange=null,t+=p,this.to+=p;return}else n=null,this.revertPending(e.state);if(s+=t,o+=t,o<=this.from)this.from+=p,this.to+=p;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+u.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),u.toString()),this.to+=p}t+=p}),n&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(n=>!n.isUserEvent("input.type")&&n.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),n=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=n)&&this.editContext.updateSelection(i,n)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class G{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.clearAnnouncement=-1,this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(n=>n.forEach(s=>i(s,this)))||(n=>this.update(n)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Xd(e.parent)||document,this.viewState=new Pa(this,e.state||pe.create(e)),e.scrollTo&&e.scrollTo.is(Xn)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Vi).map(n=>new ms(n));for(let n of this.plugins)n.update(this);this.observer=new bg(this),this.inputState=new _p(this),this.inputState.ensureHandlers(this.plugins),this.docView=new ba(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof Ee?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,n,s=this.state;for(let y of e){if(y.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=y.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,h=null;e.some(y=>y.annotation(Pf))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,h=Nf(s,o),h||(l=1));let u=this.observer.delayedAndroidKey,p=null;if(u?(this.observer.clearDelayedAndroidKey(),p=this.observer.readChange(),(p&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(p=null)):this.observer.clear(),s.facet(pe.phrases)!=this.state.facet(pe.phrases))return this.setState(s);n=Sr.create(this,s,e),n.flags|=l;let m=this.viewState.scrollTarget;try{this.updateState=2;for(let y of e){if(m&&(m=m.map(y.changes)),y.scrollIntoView){let{main:x}=y.state.selection,{x:S,y:C}=this.state.facet(G.cursorScrollMargin);m=new Ji(x.empty?x:I.cursor(x.head,x.head>x.anchor?-1:1),"nearest","nearest",C,S)}for(let x of y.effects)x.is(Xn)&&(m=x.value.clip(this.state))}this.viewState.update(n,m),this.bidiCache=Or.update(this.bidiCache,n.changes),n.empty||(this.updatePlugins(n),this.inputState.update(n)),t=this.docView.update(n),this.state.facet(mn)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(y=>y.isUserEvent("select.pointer")))}finally{this.updateState=0}if(n.startState.facet(rr)!=n.state.facet(rr)&&(this.viewState.mustMeasureContent=!0),(t||i||m||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!n.empty)for(let y of this.state.facet(no))try{y(n)}catch(x){_t(this.state,x,"update listener")}(h||p)&&Promise.resolve().then(()=>{h&&this.state==h.startState&&this.dispatch(h),p&&!Of(this,p)&&u.force&&Ui(this.contentDOM,u.key,u.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Pa(this,e),this.plugins=e.facet(Vi).map(i=>new ms(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new ba(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Vi),i=e.state.facet(Vi);if(t!=i){let n=[];for(let s of i){let o=t.indexOf(s);if(o<0)n.push(new ms(s));else{let l=this.plugins[o];l.mustUpdate=e,n.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let n of this.plugins)n.mustUpdate=e;for(let n=0;n<this.plugins.length;n++)this.plugins[n].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(i){_t(this.state,i,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.viewState.scrollParent,n=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o,scaleY:l}=this.viewState;Math.abs(n-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let h=0;;h++){if(o<0){if(ef(i||this.win))s=-1,o=this.viewState.heightMap.height/this.viewState.scaleY;else{let S=this.viewState.scrollAnchorAt(n);s=S.from,o=S.top}l=this.viewState.scaleY}this.updateState=1;let u=this.viewState.measure();if(!u&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(h>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let p=[];u&4||([this.measureRequests,p]=[p,this.measureRequests]);let m=p.map(S=>{try{return S.read(this)}catch(C){return _t(this.state,C),Va}}),y=Sr.create(this,this.state,[]),x=!1;y.flags|=u,t?t.flags|=u:t=y,this.updateState=2,y.empty||(this.updatePlugins(y),this.inputState.update(y),this.updateAttrs(),x=this.docView.update(y),x&&this.docViewUpdate());for(let S=0;S<p.length;S++)if(m[S]!=Va)try{let C=p[S];C.write&&C.write(m[S],this)}catch(C){_t(this.state,C)}if(x&&this.docView.updateSelection(!0),!y.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let C=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)/this.viewState.scaleY-o/l;if((C>1||C<-1)&&!(_.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){n=n+C,i?s<0?i.scrollTop=i.scrollHeight:i.scrollTop+=C:this.win.scrollBy(0,C),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let h of this.state.facet(no))h(t)}get themeClasses(){return ho+" "+(this.state.facet(ao)?Vf:Wf)+" "+this.state.facet(rr)}updateAttrs(){let e=Ka(this,kf,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Gt)?"true":"false",class:"cm-content",style:`${_.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Ka(this,Ho,t);let i=this.observer.ignore(()=>{let n=ma(this.contentDOM,this.contentAttrs,t),s=ma(this.dom,this.editorAttrs,e);return n||s});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let n of i.effects)if(n.is(G.announce)){t&&(this.announceDOM.textContent="",this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout(()=>{this.announceDOM.textContent=" "},200),t=!1);let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=n.value}}mountStyles(){this.styleModules=this.state.facet(mn);let e=this.state.facet(G.cspNonce);ui.mount(this.root,this.styleModules.concat(xg).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return xs(this,e,Sa(this,e,t,i))}moveByGroup(e,t){return xs(this,e,Sa(this,e,t,i=>Ip(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),n=this.textDirectionAt(e.from),s=i[t?i.length-1:0];return I.cursor(s.side(t,n)+e.from,s.forward(!t,n)?1:-1)}moveToLineBoundary(e,t,i=!0){return Ep(this,e,t,i)}moveVertically(e,t,i){return xs(this,e,Pp(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=oo(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),oo(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.state.doc.lineAt(e),n=this.bidiSpans(i),s=n[$t.find(n,e-i.from,-1,t)];return this.docView.coordsAt(e,t,s.dir==Ce.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(gf)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Ag)return lf(e.length);let t=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||of(s.isolates,i=ka(this,e))))return s.order;i||(i=ka(this,e));let n=op(e.text,t,i);return this.bidiCache.push(new Or(e.from,e.to,t,i,!0,n)),n}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||_.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Zh(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.win.clearTimeout(this.clearAnnouncement),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var i,n,s,o;return Xn.of(new Ji(typeof e=="number"?I.cursor(e):e,(i=t.y)!==null&&i!==void 0?i:"nearest",(n=t.x)!==null&&n!==void 0?n:"nearest",(s=t.yMargin)!==null&&s!==void 0?s:5,(o=t.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return Xn.of(new Ji(I.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return wt.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return wt.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=ui.newName(),n=[rr.of(i),mn.of(fo(`.${i}`,e))];return t&&t.dark&&n.push(ao.of(!0)),n}static baseTheme(e){return rn.lowest(mn.of(fo("."+ho,e,Kf)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),n=i&&Te.get(i)||Te.get(e);return((t=n?.root)===null||t===void 0?void 0:t.view)||null}}G.styleModule=mn;G.inputHandler=df;G.clipboardInputFilter=No;G.clipboardOutputFilter=Fo;G.scrollHandler=vf;G.focusChangeEffect=pf;G.perLineTextDirection=gf;G.exceptionSink=cf;G.updateListener=no;G.editable=Gt;G.mouseSelectionStyle=uf;G.dragMovesSelection=ff;G.clickAddsSelectionRange=hf;G.decorations=Kr;G.blockWrappers=xf;G.outerDecorations=Wo;G.atomicRanges=Wn;G.bidiIsolatedRanges=wf;G.cursorScrollMargin=j.define({combine:r=>{let e=5,t=5;for(let i of r)typeof i=="number"?e=t=i:{x:e,y:t}=i;return{x:e,y:t}}});G.scrollMargins=bf;G.darkTheme=ao;G.cspNonce=j.define({combine:r=>r.length?r[0]:""});G.contentAttributes=Ho;G.editorAttributes=kf;G.lineWrapping=G.contentAttributes.of({class:"cm-lineWrapping"});G.announce=me.define();const Ag=4096,Va={};class Or{constructor(e,t,i,n,s,o){this.from=e,this.to=t,this.dir=i,this.isolates=n,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let i=[],n=e.length?e[e.length-1].dir:Ce.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==n&&!t.touchesRange(o.from,o.to)&&i.push(new Or(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function Ka(r,e,t){for(let i=r.state.facet(e),n=i.length-1;n>=0;n--){let s=i[n],o=typeof s=="function"?s(r):s;o&&Eo(o,t)}return t}const Mg=_.mac?"mac":_.windows?"win":_.linux?"linux":"key";function Tg(r,e){const t=r.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let n,s,o,l;for(let h=0;h<t.length-1;++h){const u=t[h];if(/^(cmd|meta|m)$/i.test(u))l=!0;else if(/^a(lt)?$/i.test(u))n=!0;else if(/^(c|ctrl|control)$/i.test(u))s=!0;else if(/^s(hift)?$/i.test(u))o=!0;else if(/^mod$/i.test(u))e=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+u)}return n&&(i="Alt-"+i),s&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function sr(r,e,t){return e.altKey&&(r="Alt-"+r),e.ctrlKey&&(r="Ctrl-"+r),e.metaKey&&(r="Meta-"+r),t!==!1&&e.shiftKey&&(r="Shift-"+r),r}const Og=rn.default(G.domEventHandlers({keydown(r,e){return _f($f(e.state),r,e,"editor")}})),zf=j.define({enables:Og}),za=new WeakMap;function $f(r){let e=r.facet(zf),t=za.get(e);return t||za.set(e,t=Bg(e.reduce((i,n)=>i.concat(n),[]))),t}function Pi(r,e,t){return _f($f(r.state),e,r,t)}let oi=null;const Lg=4e3;function Bg(r,e=Mg){let t=Object.create(null),i=Object.create(null),n=(o,l)=>{let h=i[o];if(h==null)i[o]=l;else if(h!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,h,u,p)=>{var m,y;let x=t[o]||(t[o]=Object.create(null)),S=l.split(/ (?!$)/).map(B=>Tg(B,e));for(let B=1;B<S.length;B++){let F=S.slice(0,B).join(" ");n(F,!0),x[F]||(x[F]={preventDefault:!0,stopPropagation:!1,run:[P=>{let Q=oi={view:P,prefix:F,scope:o};return setTimeout(()=>{oi==Q&&(oi=null)},Lg),!0}]})}let C=S.join(" ");n(C,!1);let O=x[C]||(x[C]={preventDefault:!1,stopPropagation:!1,run:((y=(m=x._any)===null||m===void 0?void 0:m.run)===null||y===void 0?void 0:y.slice())||[]});h&&O.run.push(h),u&&(O.preventDefault=!0),p&&(O.stopPropagation=!0)};for(let o of r){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let u of l){let p=t[u]||(t[u]=Object.create(null));p._any||(p._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:m}=o;for(let y in p)p[y].run.push(x=>m(x,uo))}let h=o[e]||o.key;if(h)for(let u of l)s(u,h,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(u,"Shift-"+h,o.shift,o.preventDefault,o.stopPropagation)}return t}let uo=null;function _f(r,e,t,i){uo=e;let n=jd(e),s=Eh(n,0),o=Ih(s)==n.length&&n!=" ",l="",h=!1,u=!1,p=!1;oi&&oi.view==t&&oi.scope==i&&(l=oi.prefix+" ",Df.indexOf(e.keyCode)<0&&(u=!0,oi=null));let m=new Set,y=O=>{if(O){for(let B of O.run)if(!m.has(B)&&(m.add(B),B(t)))return O.stopPropagation&&(p=!0),!0;O.preventDefault&&(O.stopPropagation&&(p=!0),u=!0)}return!1},x=r[i],S,C;return x&&(y(x[l+sr(n,e,!o)])?h=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(_.windows&&e.ctrlKey&&e.altKey)&&!(_.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(S=ci[e.keyCode])&&S!=n?(y(x[l+sr(S,e,!0)])||e.shiftKey&&(C=Bn[e.keyCode])!=n&&C!=S&&y(x[l+sr(C,e,!1)]))&&(h=!0):o&&e.shiftKey&&y(x[l+sr(n,e,!0)])&&(h=!0),!h&&y(x._any)&&(h=!0)),u&&(h=!0),h&&p&&e.stopPropagation(),uo=null,h}class Ai{constructor(e,t,i,n,s){this.className=e,this.left=t,this.top=i,this.width=n,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let n=e.coordsAtPos(i.head,i.assoc||1);if(!n)return[];let s=jf(e);return[new Ai(t,n.left-s.left,n.top-s.top,null,n.bottom-n.top)]}else return Dg(e,t,i)}}function jf(r){let e=r.scrollDOM.getBoundingClientRect();return{left:(r.textDirection==Ce.LTR?e.left:e.right-r.scrollDOM.clientWidth*r.scaleX)-r.scrollDOM.scrollLeft*r.scaleX,top:e.top-r.scrollDOM.scrollTop*r.scaleY}}function $a(r,e,t,i){let n=r.coordsAtPos(e,t*2);if(!n)return i;let s=r.dom.getBoundingClientRect(),o=(n.top+n.bottom)/2,l=r.posAtCoords({x:s.left+1,y:o}),h=r.posAtCoords({x:s.right-1,y:o});return l==null||h==null?i:{from:Math.max(i.from,Math.min(l,h)),to:Math.min(i.to,Math.max(l,h))}}function Dg(r,e,t){if(t.to<=r.viewport.from||t.from>=r.viewport.to)return[];let i=Math.max(t.from,r.viewport.from),n=Math.min(t.to,r.viewport.to),s=r.textDirection==Ce.LTR,o=r.contentDOM,l=o.getBoundingClientRect(),h=jf(r),u=o.querySelector(".cm-line"),p=u&&window.getComputedStyle(u),m=l.left+(p?parseInt(p.paddingLeft)+Math.min(0,parseInt(p.textIndent)):0),y=l.right-(p?parseInt(p.paddingRight):0),x=so(r,i,1),S=so(r,n,-1),C=x.type==qe.Text?x:null,O=S.type==qe.Text?S:null;if(C&&(r.lineWrapping||x.widgetLineBreaks)&&(C=$a(r,i,1,C)),O&&(r.lineWrapping||S.widgetLineBreaks)&&(O=$a(r,n,-1,O)),C&&O&&C.from==O.from&&C.to==O.to)return F(P(t.from,t.to,C));{let W=C?P(t.from,null,C):Q(x,!1),V=O?P(null,t.to,O):Q(S,!0),N=[];return(C||x).to<(O||S).from-(C&&O?1:0)||x.widgetLineBreaks>1&&W.bottom+r.defaultLineHeight/2<V.top?N.push(B(m,W.bottom,y,V.top)):W.bottom<V.top&&r.elementAtHeight((W.bottom+V.top)/2).type==qe.Text&&(W.bottom=V.top=(W.bottom+V.top)/2),F(W).concat(N).concat(F(V))}function B(W,V,N,re){return new Ai(e,W-h.left,V-h.top,Math.max(0,N-W),re-V)}function F({top:W,bottom:V,horizontal:N}){let re=[];for(let oe=0;oe<N.length;oe+=2)re.push(B(N[oe],W,N[oe+1],V));return re}function P(W,V,N){let re=1e9,oe=-1e9,ae=[];function Z(fe,ge,Fe,De,z){let Re=r.coordsAtPos(fe,fe==N.to?-2:2),Ue=r.coordsAtPos(Fe,Fe==N.from?2:-2);!Re||!Ue||(re=Math.min(Re.top,Ue.top,re),oe=Math.max(Re.bottom,Ue.bottom,oe),z==Ce.LTR?ae.push(s&&ge?m:Re.left,s&&De?y:Ue.right):ae.push(!s&&De?m:Ue.left,!s&&ge?y:Re.right))}let Y=W??N.from,ee=V??N.to;for(let fe of r.visibleRanges)if(fe.to>Y&&fe.from<ee)for(let ge=Math.max(fe.from,Y),Fe=Math.min(fe.to,ee);;){let De=r.state.doc.lineAt(ge);for(let z of r.bidiSpans(De)){let Re=z.from+De.from,Ue=z.to+De.from;if(Re>=Fe)break;Ue>ge&&Z(Math.max(Re,ge),W==null&&Re<=Y,Math.min(Ue,Fe),V==null&&Ue>=ee,z.dir)}if(ge=De.to+1,ge>=Fe)break}return ae.length==0&&Z(Y,W==null,ee,V==null,r.textDirection),{top:re,bottom:oe,horizontal:ae}}function Q(W,V){let N=l.top+(V?W.top:W.bottom);return{top:N,bottom:N,horizontal:[]}}}function Rg(r,e){return r.constructor==e.constructor&&r.eq(e)}class Eg{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(dr)!=e.state.facet(dr)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(dr);for(;t<i.length&&i[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,i)=>!Rg(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let n of e)n.update&&t&&n.constructor&&this.drawn[i].constructor&&n.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(n.draw(),t);for(;t;){let n=t.nextSibling;t.remove(),t=n}this.drawn=e,_.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const dr=j.define();function qf(r){return[wt.define(e=>new Eg(e,r)),dr.of(r)]}const Li=j.define({combine(r){return Hr(r,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function qv(r={}){return[Li.of(r),Pg,Ng,Hg,mf.of(!0)]}function Ig(r){return r.facet(Li)}function Uf(r){return r.startState.facet(Li)!=r.state.facet(Li)}const Pg=qf({above:!0,markers(r){let{state:e}=r,t=e.facet(Li),i=[];for(let n of e.selection.ranges){let s=n==e.selection.main;if(n.empty||t.drawRangeCursor&&!(s&&_.ios&&t.iosSelectionHandles)){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=n.empty?n:I.cursor(n.head,n.assoc);for(let h of Ai.forRange(r,o,l))i.push(h)}}return i},update(r,e){r.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Uf(r);return t&&_a(r.state,e),r.docChanged||r.selectionSet||t},mount(r,e){_a(e.state,r)},class:"cm-cursorLayer"});function _a(r,e){e.style.animationDuration=r.facet(Li).cursorBlinkRate+"ms"}const Ng=qf({above:!1,markers(r){let e=[],{main:t,ranges:i}=r.state.selection;for(let n of i)if(!n.empty)for(let s of Ai.forRange(r,"cm-selectionBackground",n))e.push(s);if(_.ios&&!t.empty&&r.state.facet(Li).iosSelectionHandles){for(let n of Ai.forRange(r,"cm-selectionHandle cm-selectionHandle-start",I.cursor(t.from,1)))e.push(n);for(let n of Ai.forRange(r,"cm-selectionHandle cm-selectionHandle-end",I.cursor(t.to,1)))e.push(n)}return e},update(r,e){return r.docChanged||r.selectionSet||r.viewportChanged||Uf(r)},class:"cm-selectionLayer"}),Fg=_.gecko&&_.gecko_version==153?"#ffffff01":"transparent",Hg=rn.highest(G.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${Fg} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));class Wg extends pi{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?bn(e.firstChild):[];if(!t.length)return null;let i=window.getComputedStyle(e.parentNode),n=En(t[0],i.direction!="rtl"),s=parseInt(i.lineHeight);return n.bottom-n.top>s*1.5?{left:n.left,right:n.right,top:n.top,bottom:n.top+s}:n}ignoreEvent(){return!1}}function Uv(r){let e=wt.fromClass(class{constructor(t){this.view=t,this.placeholder=de.set([de.widget({widget:new Wg(r),side:1}).range(0)])}get decorations(){return this.view.state.doc.length?de.none:this.placeholder}},{decorations:t=>t.decorations});return typeof r=="string"?[e,G.contentAttributes.of({"aria-placeholder":r})]:e}const ja=j.define({combine(r){let e,t;for(let i of r)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}}),Vg=wt.fromClass(class{constructor(r){this.input=r.state.facet(Lr),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(r));let e=r.state.facet(ja);this.top=new or(r,!0,e.topContainer),this.bottom=new or(r,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(r){let e=r.state.facet(ja);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new or(r.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new or(r.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=r.state.facet(Lr);if(t!=this.input){let i=t.filter(h=>h),n=[],s=[],o=[],l=[];for(let h of i){let u=this.specs.indexOf(h),p;u<0?(p=h(r.view),l.push(p)):(p=this.panels[u],p.update&&p.update(r)),n.push(p),(p.top?s:o).push(p)}this.specs=i,this.panels=n,this.top.sync(s),this.bottom.sync(o);for(let h of l)h.dom.classList.add("cm-panel"),h.mount&&h.mount()}else for(let i of this.panels)i.update&&i.update(r)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:r=>G.scrollMargins.of(e=>{let t=e.plugin(r);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class or{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=qa(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=qa(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function qa(r){let e=r.nextSibling;return r.remove(),e}const Lr=j.define({enables:Vg});class Bi extends fi{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Bi.prototype.elementClass="";Bi.prototype.toDOM=void 0;Bi.prototype.mapMode=_e.TrackBefore;Bi.prototype.startSide=Bi.prototype.endSide=-1;Bi.prototype.point=!0;const Ss=j.define(),Kg=j.define(),pr=j.define(),Ua=j.define({combine:r=>r.some(e=>e)});function zg(r){return[$g]}const $g=wt.fromClass(class{constructor(r){this.view=r,this.domAfter=null,this.prevViewport=r.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=r.state.facet(pr).map(e=>new Ga(r,e)),this.fixed=!r.state.facet(Ua);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),r.scrollDOM.insertBefore(this.dom,r.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(r){if(this.updateGutters(r)){let e=this.prevViewport,t=r.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(r.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(Ua)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=r.view.viewport}syncGutters(r){let e=this.dom.nextSibling;r&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=ue.iter(this.view.state.facet(Ss),this.view.viewport.from),i=[],n=this.gutters.map(s=>new _g(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let o=!0;for(let l of s.type)if(l.type==qe.Text&&o){co(t,i,l.from);for(let h of n)h.line(this.view,l,i);o=!1}else if(l.widget)for(let h of n)h.widget(this.view,l)}else if(s.type==qe.Text){co(t,i,s.from);for(let o of n)o.line(this.view,s,i)}else if(s.widget)for(let o of n)o.widget(this.view,s);for(let s of n)s.finish();r&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(r){let e=r.startState.facet(pr),t=r.state.facet(pr),i=r.docChanged||r.heightChanged||r.viewportChanged||!ue.eq(r.startState.facet(Ss),r.state.facet(Ss),r.view.viewport.from,r.view.viewport.to);if(e==t)for(let n of this.gutters)n.update(r)&&(i=!0);else{i=!0;let n=[];for(let s of t){let o=e.indexOf(s);o<0?n.push(new Ga(this.view,s)):(this.gutters[o].update(r),n.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),n.indexOf(s)<0&&s.destroy();for(let s of n)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=n}return i}destroy(){for(let r of this.gutters)r.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:r=>G.scrollMargins.of(e=>{let t=e.plugin(r);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,n=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Ce.LTR?{left:i,right:n}:{right:i,left:n}})});function Ja(r){return Array.isArray(r)?r:[r]}function co(r,e,t){for(;r.value&&r.from<=t;)r.from==t&&e.push(r.value),r.next()}class _g{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=ue.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:n}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==n.elements.length){let l=new Jf(e,o,s,i);n.elements.push(l),n.dom.appendChild(l.dom)}else n.elements[this.i].update(e,o,s,i);this.height=t.bottom,this.i++}line(e,t,i){let n=[];co(this.cursor,n,t.from),i.length&&(n=n.concat(i));let s=this.gutter.config.lineMarker(e,t,n);s&&n.unshift(s);let o=this.gutter;n.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,n)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),n=i?[i]:null;for(let s of e.state.facet(Kg)){let o=s(e,t.widget,t);o&&(n||(n=[])).push(o)}n&&this.addElement(e,t,n)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Ga{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,n=>{let s=n.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let h=s.getBoundingClientRect();o=(h.top+h.bottom)/2}else o=n.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,n)&&n.preventDefault()});this.markers=Ja(t.markers(e)),t.initialSpacer&&(this.spacer=new Jf(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=Ja(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let n=this.config.updateSpacer(this.spacer.markers[0],e);n!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[n])}let i=e.view.viewport;return!ue.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Jf{constructor(e,t,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,n)}update(e,t,i,n){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),jg(this.markers,n)||this.setMarkers(e,n)}setMarkers(e,t){let i="cm-gutterElement",n=this.dom.firstChild;for(let s=0,o=0;;){let l=o,h=s<t.length?t[s++]:null,u=!1;if(h){let p=h.elementClass;p&&(i+=" "+p);for(let m=o;m<this.markers.length;m++)if(this.markers[m].compare(h)){l=m,u=!0;break}}else l=this.markers.length;for(;o<l;){let p=this.markers[o++];if(p.toDOM){p.destroy(n);let m=n.nextSibling;n.remove(),n=m}}if(!h)break;h.toDOM&&(u?n=n.nextSibling:this.dom.insertBefore(h.toDOM(e),n)),u&&o++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}}function jg(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(!r[t].compare(e[t]))return!1;return!0}const qg=j.define(),Ug=j.define(),Ki=j.define({combine(r){return Hr(r,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let n in t){let s=i[n],o=t[n];i[n]=s?(l,h,u)=>s(l,h,u)||o(l,h,u):o}return i}})}});class Cs extends Bi{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function As(r,e){return r.state.facet(Ki).formatNumber(e,r.state)}const Jg=pr.compute([Ki],r=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(qg)},lineMarker(e,t,i){return i.some(n=>n.toDOM)?null:new Cs(As(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let n of e.state.facet(Ug)){let s=n(e,t,i);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(Ki)!=e.state.facet(Ki),initialSpacer(e){return new Cs(As(e,Ya(e.state.doc.lines)))},updateSpacer(e,t){let i=As(t.view,Ya(t.view.state.doc.lines));return i==e.number?e:new Cs(i)},domEventHandlers:r.facet(Ki).domEventHandlers,side:"before"}));function Jv(r={}){return[Ki.of(r),zg(),Jg]}function Ya(r){let e=9;for(;e<r;)e=e*10+9;return e}var Ms;const zi=new se;function Gg(r){return j.define({combine:r?e=>e.concat(r):void 0})}const Yg=new se;class kt{constructor(e,t,i=[],n=""){this.data=e,this.name=n,pe.prototype.hasOwnProperty("tree")||Object.defineProperty(pe.prototype,"tree",{get(){return ct(this)}}),this.parser=t,this.extension=[tn.of(this),pe.languageData.of((s,o,l)=>{let h=Qa(s,o,l),u=h.type.prop(zi);if(!u)return[];let p=s.facet(u),m=h.type.prop(Yg);if(m){let y=h.resolve(o-h.from,l);for(let x of m)if(x.test(y,s)){let S=s.facet(x.facet);return x.type=="replace"?S:S.concat(p)}}return p})].concat(i)}isActiveAt(e,t,i=-1){return Qa(e,t,i).type.prop(zi)==this.data}findRegions(e){let t=e.facet(tn);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],n=(s,o)=>{if(s.prop(zi)==this.data){i.push({from:o,to:o+s.length});return}let l=s.prop(se.mounted);if(l){if(l.tree.prop(zi)==this.data){if(l.overlay)for(let h of l.overlay)i.push({from:h.from+o,to:h.to+o});else i.push({from:o,to:o+s.length});return}else if(l.overlay){let h=i.length;if(n(l.tree,l.overlay[0].from+o),i.length>h)return}}for(let h=0;h<s.children.length;h++){let u=s.children[h];u instanceof Ae&&n(u,s.positions[h]+o)}};return n(ct(e),0),i}get allowsNesting(){return!0}}kt.setState=me.define();function Qa(r,e,t){let i=r.facet(tn),n=ct(r).topNode;if(!i||i.allowsNesting)for(let s=n;s;s=s.enter(e,t,ye.ExcludeBuffers|ye.EnterBracketed))s.type.isTop&&(n=s);return n}class po extends kt{constructor(e,t,i){super(e,t,[],i),this.parser=t}static define(e){let t=Gg(e.languageData);return new po(t,e.parser.configure({props:[zi.add(i=>i.isTop?t:void 0)]}),e.name)}configure(e,t){return new po(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function ct(r){let e=r.field(kt.state,!1);return e?e.tree:Ae.empty}function Gf(r,e,t=50){var i;let n=(i=r.field(kt.state,!1))===null||i===void 0?void 0:i.context;if(!n)return null;let s=n.viewport;n.updateViewport({from:0,to:e});let o=n.isDone(e)||n.work(t,e)?n.tree:null;return n.updateViewport(s),o}class Qg{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let dn=null;class Br{constructor(e,t,i=[],n,s,o,l,h){this.parser=e,this.state=t,this.fragments=i,this.tree=n,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=h,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new Br(e,t,[],Ae.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Qg(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Ae.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let n=Date.now()+e;e=()=>Date.now()>n}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n)if(this.fragments=this.withoutTempSkipped(Yt.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Yt.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=dn;dn=this;try{return e()}finally{dn=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Xa(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:n,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let h=[];if(e.iterChangedRanges((u,p,m,y)=>h.push({fromA:u,toA:p,fromB:m,toB:y})),i=Yt.applyChanges(i,h),n=Ae.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let p=e.mapPos(u.from,1),m=e.mapPos(u.to,-1);p<m&&l.push({from:p,to:m})}}}return new Br(this.parser,t,i,n,s,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:n,to:s}=this.skipped[i];n<e.to&&s>e.from&&(this.fragments=Xa(this.fragments,n,s),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends wh{createParse(t,i,n){let s=n[0].from,o=n[n.length-1].to;return{parsedPos:s,advance(){let h=dn;if(h){for(let u of n)h.tempSkipped.push(u);e&&(h.scheduleOn=h.scheduleOn?Promise.all([h.scheduleOn,e]):e)}return this.parsedPos=o,new Ae(nt.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return dn}}function Xa(r,e,t){return Yt.applyChanges(r,[{fromA:e,toA:t,fromB:e,toB:t}])}class en{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new en(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Br.create(e.facet(tn).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new en(i)}}kt.state=Ot.define({create:en.init,update(r,e){for(let t of e.effects)if(t.is(kt.setState))return t.value;return e.startState.facet(tn)!=e.state.facet(tn)?en.init(e.state):r.apply(e)}});let Yf=r=>{let e=setTimeout(()=>r(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Yf=r=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(r,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const Ts=typeof navigator<"u"&&(!((Ms=navigator.scheduling)===null||Ms===void 0)&&Ms.isInputPending)?()=>navigator.scheduling.isInputPending():null,Xg=wt.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(kt.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(kt.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Yf(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:n}}=this.view,s=i.field(kt.state);if(s.tree==s.context.tree&&s.context.isDone(n+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!Ts?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<n&&i.doc.length>n+1e3,h=s.context.work(()=>Ts&&Ts()||Date.now()>o,n+(l?0:1e5));this.chunkBudget-=Date.now()-t,(h||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:kt.setState.of(new en(s.context))})),this.chunkBudget>0&&!(h&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>_t(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),tn=j.define({combine(r){return r.length?r[0]:null},enables:r=>[kt.state,Xg,G.contentAttributes.compute([r],e=>{let t=e.facet(r);return t&&t.name?{"data-language":t.name}:{}})]});class Yv{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}class Qf{constructor(e,t,i,n,s,o=void 0){this.name=e,this.alias=t,this.extensions=i,this.filename=n,this.loadFunc=s,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:t,support:i}=e;if(!t){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");t=()=>Promise.resolve(i)}return new Qf(e.name,(e.alias||[]).concat(e.name).map(n=>n.toLowerCase()),e.extensions||[],e.filename,t,i)}static matchFilename(e,t){for(let n of e)if(n.filename&&n.filename.test(t))return n;let i=/\.([^.]+)$/.exec(t);if(i){for(let n of e)if(n.extensions.indexOf(i[1])>-1)return n}return null}static matchLanguageName(e,t,i=!0){t=t.toLowerCase();for(let n of e)if(n.alias.some(s=>s==t))return n;if(i)for(let n of e)for(let s of n.alias){let o=t.indexOf(s);if(o>-1&&(s.length>2||!/\w/.test(t[o-1])&&!/\w/.test(t[o+s.length])))return n}return null}}const Zg=j.define(),nn=j.define({combine:r=>{if(!r.length)return" ";let e=r[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(r[0]));return e}});function Dr(r){let e=r.facet(nn);return e.charCodeAt(0)==9?r.tabSize*e.length:e.length}function Pn(r,e){let t="",i=r.tabSize,n=r.facet(nn)[0];if(n==" "){for(;e>=i;)t+=" ",e-=i;n=" "}for(let s=0;s<e;s++)t+=n;return t}function $o(r,e){r instanceof pe&&(r=new jr(r));for(let i of r.state.facet(Zg)){let n=i(r,e);if(n!==void 0)return n}let t=ct(r.state);return t.length>=e?tm(r,t,e):null}class jr{constructor(e,t={}){this.state=e,this.options=t,this.unit=Dr(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:n,simulateDoubleBreak:s}=this.options;return n!=null&&n>=i.from&&n<=i.to?s&&n==e?{text:"",from:e}:(t<0?n<e:n<=e)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(e,t);return i.slice(e-n,Math.min(i.length,e+100-n))}column(e,t=1){let{text:i,from:n}=this.lineAt(e,t),s=this.countColumn(i,e-n),o=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return o>-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,t=e.length){return Wr(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:n}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(n);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const em=new se;function tm(r,e,t){let i=e.resolveStack(t),n=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(n!=i.node){let s=[];for(let o=n;o&&!(o.from<i.node.from||o.to>i.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return Xf(i,r,t)}function Xf(r,e,t){for(let i=r;i;i=i.next){let n=nm(i.node);if(n)return n(_o.create(e,t,i))}return 0}function im(r){return r.pos==r.options.simulateBreak&&r.options.simulateDoubleBreak}function nm(r){let e=r.type.prop(em);if(e)return e;let t=r.firstChild,i;if(t&&(i=t.type.prop(se.closedBy))){let n=r.lastChild,s=n&&i.indexOf(n.name)>-1;return o=>Zf(o,!0,1,void 0,s&&!im(o)?n.from:void 0)}return r.parent==null?rm:null}function rm(){return 0}class _o extends jr{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new _o(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(sm(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return Xf(this.context.next,this.base,this.pos)}}function sm(r,e){for(let t=e;t;t=t.parent)if(r==t)return!0;return!1}function om(r){let e=r.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let n=r.options.simulateBreak,s=r.state.doc.lineAt(t.from),o=n==null||n<=s.from?s.to:Math.min(s.to,n);for(let l=t.to;;){let h=e.childAfter(l);if(!h||h==i)return null;if(!h.type.isSkipped){if(h.from>=o)return null;let u=/^ */.exec(s.text.slice(t.to-s.from))[0].length;return{from:t.from,to:t.to+u}}l=h.to}}function Qv({closing:r,align:e=!0,units:t=1}){return i=>Zf(i,e,t,r)}function Zf(r,e,t,i,n){let s=r.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||n==r.pos+o,h=e?om(r):null;return h?l?r.column(h.from):r.column(h.to):r.baseIndent+(l?0:r.unit*t)}const Xv=r=>r.baseIndent;function Zv({except:r,units:e=1}={}){return t=>{let i=r&&r.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}const lm=200;function ey(){return pe.transactionFilter.of(r=>{if(!r.docChanged||!r.isUserEvent("input.type")&&!r.isUserEvent("input.complete"))return r;let e=r.startState.languageDataAt("indentOnInput",r.startState.selection.main.head);if(!e.length)return r;let t=r.newDoc,{head:i}=r.newSelection.main,n=t.lineAt(i);if(i>n.from+lm)return r;let s=t.sliceString(n.from,i);if(!e.some(u=>u.test(s)))return r;let{state:o}=r,l=-1,h=[];for(let{head:u}of o.selection.ranges){let p=o.doc.lineAt(u);if(p.from==l)continue;l=p.from;let m=$o(o,p.from);if(m==null)continue;let y=/^\s*/.exec(p.text)[0],x=Pn(o,m);y!=x&&h.push({from:p.from,to:p.from+y.length,insert:x})}return h.length?[r,{changes:h,sequential:!0}]:r})}const am=j.define(),hm=new se;function ty(r){let e=r.firstChild,t=r.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?r.to:t.from}:null}function fm(r,e,t){let i=ct(r);if(i.length<t)return null;let n=i.resolveStack(t,1),s=null;for(let o=n;o;o=o.next){let l=o.node;if(l.to<=t||l.from>t)continue;if(s&&l.from<e)break;let h=l.type.prop(hm);if(h&&(l.to<i.length-50||i.length==r.doc.length||!um(l))){let u=h(l,r);u&&u.from<=t&&u.from>=e&&u.to>t&&(s=u)}}return s}function um(r){let e=r.lastChild;return e&&e.to==r.to&&e.type.isError}function cm(r,e,t){for(let i of r.facet(am)){let n=i(r,e,t);if(n)return n}return fm(r,e,t)}function eu(r,e){let t=e.mapPos(r.from,1),i=e.mapPos(r.to,-1);return t>=i?void 0:{from:t,to:i}}const tu=me.define({map:eu}),iu=me.define({map:eu});function dm(r){let e=[];for(let{head:t}of r.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(r.lineBlockAt(t));return e}const jo=Ot.define({create(){return de.none},update(r,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((i,n)=>r=Za(r,i,n)),r=r.map(e.changes);let t=[];for(let i of e.effects)i.is(tu)&&!gm(r,i.value.from,i.value.to)?t.push(i.value):i.is(iu)&&(r=r.update({filter:(n,s)=>i.value.from!=n||i.value.to!=s,filterFrom:i.value.from,filterTo:i.value.to}));if(t.length){let{preparePlaceholder:i}=e.state.facet(nu),n=t.map(s=>(i?de.replace({widget:new wm(i(e.state,s))}):eh).range(s.from,s.to));r=r.update({add:n})}return e.selection&&(r=Za(r,e.selection.main.head)),r},provide:r=>G.decorations.from(r),toJSON(r,e){let t=[];return r.between(0,e.doc.length,(i,n)=>{t.push(i,n)}),t},fromJSON(r){if(!Array.isArray(r)||r.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<r.length;){let i=r[t++],n=r[t++];if(typeof i!="number"||typeof n!="number")throw new RangeError("Invalid JSON for fold state");e.push(eh.range(i,n))}return de.set(e,!0)}});function Za(r,e,t=e){let i=!1;return r.between(e,t,(n,s)=>{n<t&&s>e&&(i=!0)}),i?r.update({filterFrom:e,filterTo:t,filter:(n,s)=>n>=t||s<=e}):r}function pm(r,e,t){var i;let n=null;return(i=r.field(jo,!1))===null||i===void 0||i.between(e,t,(s,o)=>{(!n||n.from>s)&&(n={from:s,to:o})}),n}function gm(r,e,t){let i=!1;return r.between(e,e,(n,s)=>{n==e&&s==t&&(i=!0)}),i}function mm(r,e){return r.field(jo,!1)?e:e.concat(me.appendConfig.of(xm()))}const vm=r=>{for(let e of dm(r)){let t=cm(r.state,e.from,e.to);if(t)return r.dispatch({effects:mm(r.state,[tu.of(t),ym(r,t)])}),!0}return!1};function ym(r,e,t=!0){let i=r.state.doc.lineAt(e.from).number,n=r.state.doc.lineAt(e.to).number;return G.announce.of(`${r.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${r.state.phrase("to")} ${n}.`)}const km={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},nu=j.define({combine(r){return Hr(r,km)}});function xm(r){return[jo,bm]}function ru(r,e){let{state:t}=r,i=t.facet(nu),n=o=>{let l=r.lineBlockAt(r.posAtDOM(o.target)),h=pm(r.state,l.from,l.to);h&&r.dispatch({effects:iu.of(h)}),o.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(r,n,e);let s=document.createElement("span");return s.textContent=i.placeholderText,s.setAttribute("aria-label",t.phrase("folded code")),s.title=t.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=n,s}const eh=de.replace({widget:new class extends pi{toDOM(r){return ru(r,null)}}});class wm extends pi{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return ru(e,this.value)}}const bm=G.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 qr{constructor(e,t){this.specs=e;let i;function n(l){let h=ui.newName();return(i||(i=Object.create(null)))["."+h]=l,h}const s=typeof t.all=="string"?t.all:t.all?n(t.all):void 0,o=t.scope;this.scope=o instanceof kt?l=>l.prop(zi)==o.data:o?l=>l==o:void 0,this.style=Sh(e.map(l=>({tag:l.tag,class:l.class||n(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=i?new ui(i):null,this.themeType=t.themeType}static define(e,t){return new qr(e,t||{})}}const go=j.define(),su=j.define({combine(r){return r.length?[r[0]]:null}});function Os(r){let e=r.facet(go);return e.length?e:r.facet(su)}function iy(r,e){let t=[Cm],i;return r instanceof qr&&(r.module&&t.push(G.styleModule.of(r.module)),i=r.themeType),e?.fallback?t.push(su.of(r)):i?t.push(go.computeN([G.darkTheme],n=>n.facet(G.darkTheme)==(i=="dark")?[r]:[])):t.push(go.of(r)),t}class Sm{constructor(e){this.markCache=Object.create(null),this.tree=ct(e.state),this.decorations=this.buildDeco(e,Os(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=ct(e.state),i=Os(e.state),n=i!=Os(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<s.to&&!n&&t.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||n)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return de.none;let i=new Ci;for(let{from:n,to:s}of e.visibleRanges)Ch(this.tree,t,(o,l,h)=>{i.add(o,l,this.markCache[h]||(this.markCache[h]=de.mark({class:h})))},n,s);return i.finish()}}const Cm=rn.high(wt.fromClass(Sm,{decorations:r=>r.decorations})),ny=qr.define([{tag:$.meta,color:"#404740"},{tag:$.link,textDecoration:"underline"},{tag:$.heading,textDecoration:"underline",fontWeight:"bold"},{tag:$.emphasis,fontStyle:"italic"},{tag:$.strong,fontWeight:"bold"},{tag:$.strikethrough,textDecoration:"line-through"},{tag:$.keyword,color:"#708"},{tag:[$.atom,$.bool,$.url,$.contentSeparator,$.labelName],color:"#219"},{tag:[$.literal,$.inserted],color:"#164"},{tag:[$.string,$.deleted],color:"#a11"},{tag:[$.regexp,$.escape,$.special($.string)],color:"#e40"},{tag:$.definition($.variableName),color:"#00f"},{tag:$.local($.variableName),color:"#30a"},{tag:[$.typeName,$.namespace],color:"#085"},{tag:$.className,color:"#167"},{tag:[$.special($.variableName),$.macroName],color:"#256"},{tag:$.definition($.propertyName),color:"#00c"},{tag:$.comment,color:"#940"},{tag:$.invalid,color:"#f00"}]),Am=1e4,Mm="()[]{}",Tm=new se;function mo(r,e,t){let i=r.prop(e<0?se.openedBy:se.closedBy);if(i)return i;if(r.name.length==1){let n=t.indexOf(r.name);if(n>-1&&n%2==(e<0?1:0))return[t[n+e]]}return null}function vo(r){let e=r.type.prop(Tm);return e?e(r.node):r}function ai(r,e,t,i={}){let n=i.maxScanDistance||Am,s=i.brackets||Mm,o=ct(r),l=o.resolveInner(e,t);for(let h=l;h;h=h.parent){let u=mo(h.type,t,s);if(u&&h.from<h.to){let p=vo(h);if(p&&(t>0?e>=p.from&&e<p.to:e>p.from&&e<=p.to))return Om(r,e,t,h,p,u,s)}}return Lm(r,e,t,o,l.type,n,s)}function Om(r,e,t,i,n,s,o){let l=i.parent,h={from:n.from,to:n.to},u=0,p=l?.cursor();if(p&&(t<0?p.childBefore(i.from):p.childAfter(i.to)))do if(t<0?p.to<=i.from:p.from>=i.to){if(u==0&&s.indexOf(p.type.name)>-1&&p.from<p.to){let m=vo(p);return{start:h,end:m?{from:m.from,to:m.to}:void 0,matched:!0}}else if(mo(p.type,t,o))u++;else if(mo(p.type,-t,o)){if(u==0){let m=vo(p);return{start:h,end:m&&m.from<m.to?{from:m.from,to:m.to}:void 0,matched:!1}}u--}}while(t<0?p.prevSibling():p.nextSibling());return{start:h,matched:!1}}function Lm(r,e,t,i,n,s,o){if(t<0?!e:e==r.doc.length)return null;let l=t<0?r.sliceDoc(e-1,e):r.sliceDoc(e,e+1),h=o.indexOf(l);if(h<0||h%2==0!=t>0)return null;let u={from:t<0?e-1:e,to:t>0?e+1:e},p=r.doc.iterRange(e,t>0?r.doc.length:0),m=0;for(let y=0;!p.next().done&&y<=s;){let x=p.value;t<0&&(y+=x.length);let S=e+y*t;for(let C=t>0?0:x.length-1,O=t>0?x.length:-1;C!=O;C+=t){let B=o.indexOf(x[C]);if(!(B<0||i.resolveInner(S+C,1).type!=n))if(B%2==0==t>0)m++;else{if(m==1)return{start:u,end:{from:S+C,to:S+C+1},matched:B>>1==h>>1};m--}}t>0&&(y+=x.length)}return p.done?{start:u,matched:!1}:null}function th(r,e,t,i=0,n=0){e==null&&(e=r.search(/[^\s\u00a0]/),e==-1&&(e=r.length));let s=n;for(let o=i;o<e;o++)r.charCodeAt(o)==9?s+=t-s%t:s++;return s}class Bm{constructor(e,t,i,n){this.string=e,this.tabSize=t,this.indentUnit=i,this.overrideIndent=n,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(e){let t=this.string.charAt(this.pos),i;if(typeof e=="string"?i=t==e:i=t&&(e instanceof RegExp?e.test(t):e(t)),i)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=th(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var e;return(e=this.overrideIndent)!==null&&e!==void 0?e:th(this.string,null,this.tabSize)}match(e,t,i){if(typeof e=="string"){let n=o=>i?o.toLowerCase():o,s=this.string.substr(this.pos,e.length);return n(s)==n(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}}current(){return this.string.slice(this.start,this.pos)}}const Dm=Object.create(null),ih=[nt.none],nh=[],rh=Object.create(null),Rm=Object.create(null);for(let[r,e]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"]])Rm[r]=Em(Dm,e);function Ls(r,e){nh.indexOf(r)>-1||(nh.push(r),console.warn(e))}function Em(r,e){let t=[];for(let l of e.split(" ")){let h=[];for(let u of l.split(".")){let p=r[u]||$[u];p?typeof p=="function"?h.length?h=h.map(p):Ls(u,`Modifier ${u} used at start of tag`):h.length?Ls(u,`Tag ${u} used as modifier`):h=Array.isArray(p)?p:[p]:Ls(u,`Unknown highlighting tag ${u}`)}for(let u of h)t.push(u)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),n=i+" "+t.map(l=>l.id),s=rh[n];if(s)return s.id;let o=rh[n]=nt.define({id:ih.length,name:i,props:[ad({[i]:t})]});return ih.push(o),o.id}Ce.RTL,Ce.LTR;class ry{constructor(e,t,i,n){this.state=e,this.pos=t,this.explicit=i,this.view=n,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=ct(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),n=t.text.slice(i-t.from,this.pos-t.from),s=n.search(Pm(e));return s<0?null:{from:i+s,to:this.pos,text:n.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function sh(r){let e=Object.keys(r).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function Im(r){let e=Object.create(null),t=Object.create(null);for(let{label:n}of r){e[n[0]]=!0;for(let s=1;s<n.length;s++)t[n[s]]=!0}let i=sh(e)+sh(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function sy(r){let e=r.map(n=>typeof n=="string"?{label:n}:n),[t,i]=e.every(n=>/^\w+$/.test(n.label))?[/\w*$/,/\w+$/]:Im(e);return n=>{let s=n.matchBefore(i);return s||n.explicit?{from:s?s.from:n.pos,options:e,validFor:t}:null}}function oy(r,e){return t=>{for(let i=ct(t.state).resolveInner(t.pos,-1);i;i=i.parent){if(r.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(t)}}function Pm(r,e){var t;let{source:i}=r,n=i[i.length-1]!="$";return n?new RegExp(`(?:${i})${n?"$":""}`,(t=r.flags)!==null&&t!==void 0?t:r.ignoreCase?"i":""):r}const Nm=Zt.define(),Fm=G.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Hm{constructor(e,t,i,n){this.field=e,this.line=t,this.from=i,this.to=n}}class qo{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,_e.TrackDel),i=e.mapPos(this.to,1,_e.TrackDel);return t==null||i==null?null:new qo(this.field,t,i)}}class Uo{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],n=[t],s=e.doc.lineAt(t),o=/^\s*/.exec(s.text)[0];for(let h of this.lines){if(i.length){let u=o,p=/^\t*/.exec(h)[0].length;for(let m=0;m<p;m++)u+=e.facet(nn);n.push(t+u.length-p),h=u+h.slice(p)}i.push(h),t+=h.length+1}let l=this.fieldPositions.map(h=>new qo(h.field,n[h.line]+h.from,n[h.line]+h.to));return{text:i,ranges:l}}static parse(e){let t=[],i=[],n=[],s;for(let o of e.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o);){let l=s[1]?+s[1]:null,h=s[2]||s[3]||"",u=-1;l===0&&(l=1e9);let p=h.replace(/\\[{}]/g,m=>m[1]);for(let m=0;m<t.length;m++)(l!=null?t[m].seq==l:p&&t[m].name==p)&&(u=m);if(u<0){let m=0;for(;m<t.length&&(l==null||t[m].seq!=null&&t[m].seq<l);)m++;t.splice(m,0,{seq:l,name:p}),u=m;for(let y of n)y.field>=u&&y.field++}for(let m of n)if(m.line==i.length&&m.from>s.index){let y=s[2]?3+(s[1]||"").length:2;m.from-=y,m.to-=y}n.push(new Hm(u,i.length,s.index,s.index+p.length)),o=o.slice(0,s.index)+h+o.slice(s.index+s[0].length)}o=o.replace(/\\([{}])/g,(l,h,u)=>{for(let p of n)p.line==i.length&&p.from>u&&(p.from--,p.to--);return h}),i.push(o)}return new Uo(i,n)}}let Wm=de.widget({widget:new class extends pi{toDOM(){let r=document.createElement("span");return r.className="cm-snippetFieldPosition",r}ignoreEvent(){return!1}}}),Vm=de.mark({class:"cm-snippetField"});class sn{constructor(e,t){this.ranges=e,this.active=t,this.deco=de.set(e.map(i=>(i.from==i.to?Wm:Vm).range(i.from,i.to)),!0)}map(e){let t=[];for(let i of this.ranges){let n=i.map(e);if(!n)return null;t.push(n)}return new sn(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}}const Vn=me.define({map(r,e){return r&&r.map(e)}}),Km=me.define(),Nn=Ot.define({create(){return null},update(r,e){for(let t of e.effects){if(t.is(Vn))return t.value;if(t.is(Km)&&r)return new sn(r.ranges,t.value)}return r&&e.docChanged&&(r=r.map(e.changes)),r&&e.selection&&!r.selectionInsideField(e.selection)&&(r=null),r},provide:r=>G.decorations.from(r,e=>e?e.deco:de.none)});function Jo(r,e){return I.create(r.filter(t=>t.field==e).map(t=>I.range(t.from,t.to)))}function zm(r){let e=Uo.parse(r);return(t,i,n,s)=>{let{text:o,ranges:l}=e.instantiate(t.state,n),{main:h}=t.state.selection,u={changes:{from:n,to:s==h.from?h.to:s,insert:ce.of(o)},scrollIntoView:!0,annotations:i?[Nm.of(i),Ee.userEvent.of("input.complete")]:void 0};if(l.length&&(u.selection=Jo(l,0)),l.some(p=>p.field>0)){let p=new sn(l,0),m=u.effects=[Vn.of(p)];t.state.field(Nn,!1)===void 0&&m.push(me.appendConfig.of([Nn,Um,Jm,Fm]))}t.dispatch(t.state.update(u))}}function ou(r){return({state:e,dispatch:t})=>{let i=e.field(Nn,!1);if(!i||r<0&&i.active==0)return!1;let n=i.active+r,s=r>0&&!i.ranges.some(o=>o.field==n+r);return t(e.update({selection:Jo(i.ranges,n),effects:Vn.of(s?null:new sn(i.ranges,n)),scrollIntoView:!0})),!0}}const $m=({state:r,dispatch:e})=>r.field(Nn,!1)?(e(r.update({effects:Vn.of(null)})),!0):!1,_m=ou(1),jm=ou(-1),qm=[{key:"Tab",run:_m,shift:jm},{key:"Escape",run:$m}],oh=j.define({combine(r){return r.length?r[0]:qm}}),Um=rn.highest(zf.compute([oh],r=>r.facet(oh)));function ly(r,e){return{...e,apply:zm(r)}}const Jm=G.domEventHandlers({mousedown(r,e){let t=e.state.field(Nn,!1),i;if(!t||(i=e.posAtCoords({x:r.clientX,y:r.clientY}))==null)return!1;let n=t.ranges.find(s=>s.from<=i&&s.to>=i);return!n||n.field==t.active?!1:(e.dispatch({selection:Jo(t.ranges,n.field),effects:Vn.of(t.ranges.some(s=>s.field>n.field)?new sn(t.ranges,n.field):null),scrollIntoView:!0}),!0)}}),lu=new class extends fi{};lu.startSide=1;lu.endSide=-1;const Gm=r=>{let{state:e}=r,t=e.doc.lineAt(e.selection.main.from),i=Yo(r.state,t.from);return i.line?au(r):i.block?Qm(r):!1};function Go(r,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let n=r(e,t);return n?(i(t.update(n)),!0):!1}}const au=Go(e0,0),Ym=Go(hu,0),Qm=Go((r,e)=>hu(r,e,Zm(e)),0);function Yo(r,e){let t=r.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const pn=50;function Xm(r,{open:e,close:t},i,n){let s=r.sliceDoc(i-pn,i),o=r.sliceDoc(n,n+pn),l=/\s*$/.exec(s)[0].length,h=/^\s*/.exec(o)[0].length,u=s.length-l;if(s.slice(u-e.length,u)==e&&o.slice(h,h+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:n+h,margin:h&&1}};let p,m;n-i<=2*pn?p=m=r.sliceDoc(i,n):(p=r.sliceDoc(i,i+pn),m=r.sliceDoc(n-pn,n));let y=/^\s*/.exec(p)[0].length,x=/\s*$/.exec(m)[0].length,S=m.length-x-t.length;return p.slice(y,y+e.length)==e&&m.slice(S,S+t.length)==t?{open:{pos:i+y+e.length,margin:/\s/.test(p.charAt(y+e.length))?1:0},close:{pos:n-x-t.length,margin:/\s/.test(m.charAt(S-1))?1:0}}:null}function Zm(r){let e=[];for(let t of r.selection.ranges){let i=r.doc.lineAt(t.from),n=t.to<=i.to?i:r.doc.lineAt(t.to);n.from>i.from&&n.from==t.to&&(n=t.to==i.to+1?i:r.doc.lineAt(t.to-1));let s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=n.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:n.to})}return e}function hu(r,e,t=e.selection.ranges){let i=t.map(s=>Yo(e,s.from).block);if(!i.every(s=>s))return null;let n=t.map((s,o)=>Xm(e,i[o],s.from,s.to));if(r!=2&&!n.every(s=>s))return{changes:e.changes(t.map((s,o)=>n[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(r!=1&&n.some(s=>s)){let s=[];for(let o=0,l;o<n.length;o++)if(l=n[o]){let h=i[o],{open:u,close:p}=l;s.push({from:u.pos-h.open.length,to:u.pos+u.margin},{from:p.pos-p.margin,to:p.pos+h.close.length})}return{changes:s}}return null}function e0(r,e,t=e.selection.ranges){let i=[],n=-1;e:for(let{from:s,to:o}of t){let l=i.length,h=1e9,u;for(let p=s;p<=o;){let m=e.doc.lineAt(p);if(u==null&&(u=Yo(e,m.from).line,!u))continue e;if(m.from>n&&(s==o||o>m.from)){n=m.from;let y=/^\s*/.exec(m.text)[0].length,x=y==m.length,S=m.text.slice(y,y+u.length)==u?y:-1;y<m.text.length&&y<h&&(h=y),i.push({line:m,comment:S,token:u,indent:y,empty:x,single:!1})}p=m.to+1}if(h<1e9)for(let p=l;p<i.length;p++)i[p].indent<i[p].line.text.length&&(i[p].indent=h);i.length==l+1&&(i[l].single=!0)}if(r!=2&&i.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:h,indent:u,empty:p,single:m}of i)(m||!p)&&s.push({from:l.from+u,insert:h+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(r!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:h}of i)if(l>=0){let u=o.from+l,p=u+h.length;o.text[p-o.from]==" "&&p++,s.push({from:u,to:p})}return{changes:s}}return null}const yo=Zt.define(),t0=Zt.define(),i0=j.define(),fu=j.define({combine(r){return Hr(r,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,n)=>e(i,n)||t(i,n)})}}),uu=Ot.define({create(){return jt.empty},update(r,e){let t=e.state.facet(fu),i=e.annotation(yo);if(i){let h=at.fromTransaction(e,i.selection),u=i.side,p=u==0?r.undone:r.done;return h?p=Er(p,p.length,t.minDepth,h):p=du(p,e.startState.selection),new jt(u==0?i.rest:p,u==0?p:i.rest)}let n=e.annotation(t0);if((n=="full"||n=="before")&&(r=r.isolate()),e.annotation(Ee.addToHistory)===!1)return e.changes.empty?r:r.addMapping(e.changes.desc);let s=at.fromTransaction(e),o=e.annotation(Ee.time),l=e.annotation(Ee.userEvent);return s?r=r.addChanges(s,o,l,t,e):e.selection&&(r=r.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(n=="full"||n=="after")&&(r=r.isolate()),r},toJSON(r){return{done:r.done.map(e=>e.toJSON()),undone:r.undone.map(e=>e.toJSON())}},fromJSON(r){return new jt(r.done.map(at.fromJSON),r.undone.map(at.fromJSON))}});function ay(r={}){return[uu,fu.of(r),G.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?Qo:e.inputType=="historyRedo"?Rr:null;return i?(e.preventDefault(),i(t)):!1}})]}function Ur(r,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let n=t.field(uu,!1);if(!n)return!1;let s=n.pop(r,t,e);return s?(i(s),!0):!1}}const Qo=Ur(0,!1),Rr=Ur(1,!1),n0=Ur(0,!0),r0=Ur(1,!0);class at{constructor(e,t,i,n,s){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=n,this.selectionsAfter=s}setSelAfter(e){return new at(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(n=>n.toJSON())}}static fromJSON(e){return new at(e.changes&&Ie.fromJSON(e.changes),[],e.mapped&&qt.fromJSON(e.mapped),e.startSelection&&I.fromJSON(e.startSelection),e.selectionsAfter.map(I.fromJSON))}static fromTransaction(e,t){let i=xt;for(let n of e.startState.facet(i0)){let s=n(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new at(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,xt)}static selection(e){return new at(void 0,xt,void 0,void 0,e)}}function Er(r,e,t,i){let n=e+1>t+20?e-t-1:0,s=r.slice(n,e);return s.push(i),s}function s0(r,e){let t=[],i=!1;return r.iterChangedRanges((n,s)=>t.push(n,s)),e.iterChangedRanges((n,s,o,l)=>{for(let h=0;h<t.length;){let u=t[h++],p=t[h++];l>=u&&o<=p&&(i=!0)}}),i}function o0(r,e){return r.ranges.length==e.ranges.length&&r.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function cu(r,e){return r.length?e.length?r.concat(e):r:e}const xt=[],l0=200;function du(r,e){if(r.length){let t=r[r.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-l0));return i.length&&i[i.length-1].eq(e)?r:(i.push(e),Er(r,r.length-1,1e9,t.setSelAfter(i)))}else return[at.selection([e])]}function a0(r){let e=r[r.length-1],t=r.slice();return t[r.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function Bs(r,e){if(!r.length)return r;let t=r.length,i=xt;for(;t;){let n=h0(r[t-1],e,i);if(n.changes&&!n.changes.empty||n.effects.length){let s=r.slice(0,t);return s[t-1]=n,s}else e=n.mapped,t--,i=n.selectionsAfter}return i.length?[at.selection(i)]:xt}function h0(r,e,t){let i=cu(r.selectionsAfter.length?r.selectionsAfter.map(l=>l.map(e)):xt,t);if(!r.changes)return at.selection(i);let n=r.changes.map(e),s=e.mapDesc(r.changes,!0),o=r.mapped?r.mapped.composeDesc(s):s;return new at(n,me.mapEffects(r.effects,e),o,r.startSelection.map(s),i)}const f0=/^(input\.type|delete)($|\.)/;class jt{constructor(e,t,i=0,n=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new jt(this.done,this.undone):this}addChanges(e,t,i,n,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||f0.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<n.newGroupDelay&&n.joinToEvent(s,s0(l.changes,e.changes))||i=="input.type.compose")?o=Er(o,o.length-1,n.minDepth,new at(e.changes.compose(l.changes),cu(me.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,xt)):o=Er(o,o.length,n.minDepth,e),new jt(o,xt,t,i)}addSelection(e,t,i,n){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:xt;return s.length>0&&t-this.prevTime<n&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&o0(s[s.length-1],e)?this:new jt(du(this.done,e),this.undone,t,i)}addMapping(e){return new jt(Bs(this.done,e),Bs(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let n=e==0?this.done:this.undone;if(n.length==0)return null;let s=n[n.length-1],o=s.selectionsAfter[0]||(s.startSelection?s.startSelection.map(s.changes.invertedDesc,1):t.selection);if(i&&s.selectionsAfter.length)return t.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:yo.of({side:e,rest:a0(n),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=n.length==1?xt:n.slice(0,n.length-1);return s.mapped&&(l=Bs(l,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:yo.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}jt.empty=new jt(xt,xt);const hy=[{key:"Mod-z",run:Qo,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Rr,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Rr,preventDefault:!0},{key:"Mod-u",run:n0,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:r0,preventDefault:!0}];function on(r,e){return I.create(r.ranges.map(e),r.mainIndex)}function Lt(r,e){return r.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Bt({state:r,dispatch:e},t){let i=on(r.selection,t);return i.eq(r.selection,!0)?!1:(e(Lt(r,i)),!0)}function Jr(r,e){return I.cursor(e?r.to:r.from)}function Xo(r,e){return Bt(r,t=>t.empty?r.moveByChar(t,e):Jr(t,e))}function Qe(r){return r.textDirectionAt(r.state.selection.main.head)==Ce.LTR}const Zo=r=>Xo(r,!Qe(r)),pu=r=>Xo(r,Qe(r)),u0=r=>Xo(r,!1);function gu(r,e){return Bt(r,t=>t.empty?r.moveByGroup(t,e):Jr(t,e))}const c0=r=>gu(r,!Qe(r)),d0=r=>gu(r,Qe(r));function p0(r,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(r.sliceDoc(e.from,e.to)))||e.firstChild}function Gr(r,e,t){let i=ct(r).resolveInner(e.head),n=t?se.closedBy:se.openedBy;for(let h=e.head;;){let u=t?i.childAfter(h):i.childBefore(h);if(!u)break;p0(r,u,n)?i=u:h=t?u.to:u.from}let s=i.type.prop(n),o,l;return s&&(o=t?ai(r,i.from,1):ai(r,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,I.cursor(l,t?-1:1)}const g0=r=>Bt(r,e=>Gr(r.state,e,!Qe(r))),m0=r=>Bt(r,e=>Gr(r.state,e,Qe(r)));function mu(r,e){return Bt(r,t=>{if(!t.empty)return Jr(t,e);let i=r.moveVertically(t,e);return i.head!=t.head?i:r.moveToLineBoundary(t,e)})}const vu=r=>mu(r,!1),yu=r=>mu(r,!0);function ku(r){let e=r.scrollDOM.clientHeight<r.scrollDOM.scrollHeight-2,t=0,i=0,n;if(e){for(let s of r.state.facet(G.scrollMargins)){let o=s(r);o?.top&&(t=Math.max(o?.top,t)),o?.bottom&&(i=Math.max(o?.bottom,i))}n=r.scrollDOM.clientHeight-t-i}else n=(r.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(r.defaultLineHeight,n-5)}}function xu(r,e){let t=ku(r),{state:i}=r,n=on(i.selection,o=>o.empty?r.moveVertically(o,e,t.height):Jr(o,e));if(n.eq(i.selection))return!1;let s;if(t.selfScroll){let o=r.coordsAtPos(i.selection.main.head),l=r.scrollDOM.getBoundingClientRect(),h=l.top+t.marginTop,u=l.bottom-t.marginBottom;o&&o.top>h&&o.bottom<u&&(s=G.scrollIntoView(n.main.head,{y:"start",yMargin:o.top-h}))}return r.dispatch(Lt(i,n),{effects:s}),!0}const lh=r=>xu(r,!1),ko=r=>xu(r,!0);function gi(r,e,t){let i=r.lineBlockAt(e.head),n=r.moveToLineBoundary(e,t);if(n.head==e.head&&n.head!=(t?i.to:i.from)&&(n=r.moveToLineBoundary(e,t,!1)),!t&&n.head==i.from&&i.length){let s=/^\s*/.exec(r.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(n=I.cursor(i.from+s))}return n}const wu=r=>Bt(r,e=>gi(r,e,!0)),bu=r=>Bt(r,e=>gi(r,e,!1)),v0=r=>Bt(r,e=>gi(r,e,!Qe(r))),y0=r=>Bt(r,e=>gi(r,e,Qe(r))),k0=r=>Bt(r,e=>r.moveToLineBoundary(e,!1,!1)),x0=r=>Bt(r,e=>r.moveToLineBoundary(e,!0,!1));function w0(r,e,t){let i=!1,n=on(r.selection,s=>{let o=ai(r,s.head,-1)||ai(r,s.head,1)||s.head>0&&ai(r,s.head-1,1)||s.head<r.doc.length&&ai(r,s.head+1,-1);if(!o||!o.end)return s;i=!0;let l=o.start.from==s.head?o.end.to:o.end.from;return I.cursor(l)});return i?(e(Lt(r,n)),!0):!1}const b0=({state:r,dispatch:e})=>w0(r,e);function bt(r,e,t){let i=on(r.state.selection,n=>{n.undirectional&&n.head>=n.anchor!=e&&(n=I.range(n.head,n.anchor));let s=t(n);return I.range(n.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return i.eq(r.state.selection)?!1:(r.dispatch(Lt(r.state,i)),!0)}function Su(r,e){return bt(r,e,t=>r.moveByChar(t,e))}const Cu=r=>Su(r,!Qe(r)),Au=r=>Su(r,Qe(r));function Mu(r,e){return bt(r,e,t=>r.moveByGroup(t,e))}const S0=r=>Mu(r,!Qe(r)),C0=r=>Mu(r,Qe(r)),A0=r=>{let e=!Qe(r);return bt(r,e,t=>Gr(r.state,t,e))},M0=r=>{let e=Qe(r);return bt(r,e,t=>Gr(r.state,t,e))};function Tu(r,e){return bt(r,e,t=>r.moveVertically(t,e))}const Ou=r=>Tu(r,!1),Lu=r=>Tu(r,!0);function Bu(r,e){return bt(r,e,t=>r.moveVertically(t,e,ku(r).height))}const ah=r=>Bu(r,!1),hh=r=>Bu(r,!0),T0=r=>bt(r,!0,e=>gi(r,e,!0)),O0=r=>bt(r,!1,e=>gi(r,e,!1)),L0=r=>{let e=!Qe(r);return bt(r,e,t=>gi(r,t,e))},B0=r=>{let e=Qe(r);return bt(r,e,t=>gi(r,t,e))},D0=r=>bt(r,!1,e=>I.cursor(r.lineBlockAt(e.head).from)),R0=r=>bt(r,!0,e=>I.cursor(r.lineBlockAt(e.head).to)),fh=({state:r,dispatch:e})=>(e(Lt(r,{anchor:0})),!0),uh=({state:r,dispatch:e})=>(e(Lt(r,{anchor:r.doc.length})),!0),ch=({state:r,dispatch:e})=>(e(Lt(r,{anchor:r.selection.main.anchor,head:0})),!0),dh=({state:r,dispatch:e})=>(e(Lt(r,{anchor:r.selection.main.anchor,head:r.doc.length})),!0),E0=({state:r,dispatch:e})=>(e(r.update({selection:{anchor:0,head:r.doc.length},userEvent:"select"})),!0),I0=({state:r,dispatch:e})=>{let t=Yr(r).map(({from:i,to:n})=>I.undirectionalRange(i,Math.min(n+1,r.doc.length)));return e(r.update({selection:I.create(t),userEvent:"select"})),!0},P0=({state:r,dispatch:e})=>{let t=on(r.selection,i=>{let n=ct(r),s=n.resolveStack(i.from,1);if(i.empty){let o=n.resolveStack(i.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&o.next)return I.undirectionalRange(l.from,l.to)}return i});return t.eq(r.selection)?!1:(e(Lt(r,t)),!0)};function Du(r,e){let{state:t}=r,i=t.selection,n=t.selection.ranges.slice();for(let s of t.selection.ranges){let o=t.doc.lineAt(s.head);if(e?o.to<r.state.doc.length:o.from>0)for(let l=s;;){let h=r.moveVertically(l,e);if(h.head<o.from||h.head>o.to){n.some(u=>u.head==h.head)||n.push(h);break}else{if(h.head==l.head)break;l=h}}}return n.length==i.ranges.length?!1:(r.dispatch(Lt(t,I.create(n,n.length-1))),!0)}const N0=r=>Du(r,!1),F0=r=>Du(r,!0),H0=({state:r,dispatch:e})=>{let t=r.selection,i=null;return t.ranges.length>1?i=I.create([t.main]):t.main.empty||(i=I.create([I.cursor(t.main.head)])),i?(e(Lt(r,i)),!0):!1};function Kn(r,e){if(r.state.readOnly)return!1;let t="delete.selection",{state:i}=r,n=i.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let h=e(s);h<o?(t="delete.backward",h=lr(r,h,!1)):h>o&&(t="delete.forward",h=lr(r,h,!0)),o=Math.min(o,h),l=Math.max(l,h)}else o=lr(r,o,!1),l=lr(r,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:I.cursor(o,o<s.head?-1:1)}});return n.changes.empty?!1:(r.dispatch(i.update(n,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?G.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function lr(r,e,t){if(r instanceof G)for(let i of r.state.facet(G.atomicRanges).map(n=>n(r)))i.between(e,e,(n,s)=>{n<e&&s>e&&(e=t?s:n)});return e}const Ru=(r,e,t)=>Kn(r,i=>{let n=i.from,{state:s}=r,o=s.doc.lineAt(n),l,h;if(t&&!e&&n>o.from&&n<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,n-o.from))){if(l[l.length-1]==" ")return n-1;let u=Wr(l,s.tabSize),p=u%Dr(s)||Dr(s);for(let m=0;m<p&&l[l.length-1-m]==" ";m++)n--;h=n}else h=Ne(o.text,n-o.from,e,e)+o.from,h==n&&o.number!=(e?s.doc.lines:1)?h+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(h-o.from,n-o.from))&&(h=Ne(o.text,h-o.from,!1,!1)+o.from);return h}),xo=r=>Ru(r,!1,!0),Eu=r=>Ru(r,!0,!1),Iu=(r,e)=>Kn(r,t=>{let i=t.head,{state:n}=r,s=n.doc.lineAt(i),o=n.charCategorizer(i);for(let l=null;;){if(i==(e?s.to:s.from)){i==t.head&&s.number!=(e?n.doc.lines:1)&&(i+=e?1:-1);break}let h=Ne(s.text,i-s.from,e)+s.from,u=s.text.slice(Math.min(i,h)-s.from,Math.max(i,h)-s.from),p=o(u);if(l!=null&&p!=l)break;(u!=" "||i!=t.head)&&(l=p),i=h}return i}),Pu=r=>Iu(r,!1),W0=r=>Iu(r,!0),V0=r=>Kn(r,e=>{let t=r.lineBlockAt(e.head).to;return e.head<t?t:Math.min(r.state.doc.length,e.head+1)}),K0=r=>Kn(r,e=>{let t=r.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),z0=r=>Kn(r,e=>{let t=r.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(r.state.doc.length,e.head+1)}),$0=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=r.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:ce.of(["",""])},range:I.cursor(i.from)}));return e(r.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},_0=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=r.changeByRange(i=>{if(!i.empty||i.from==0||i.from==r.doc.length)return{range:i};let n=i.from,s=r.doc.lineAt(n),o=n==s.from?n-1:Ne(s.text,n-s.from,!1)+s.from,l=n==s.to?n+1:Ne(s.text,n-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:r.doc.slice(n,l).append(r.doc.slice(o,n))},range:I.cursor(l)}});return t.changes.empty?!1:(e(r.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Yr(r){let e=[],t=-1;for(let i of r.selection.ranges){let n=r.doc.lineAt(i.from),s=r.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=r.doc.lineAt(i.to-1)),t>=n.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:n.from,to:s.to,ranges:[i]});t=s.number+1}return e}function Nu(r,e,t){if(r.readOnly)return!1;let i=[],n=[];for(let s of Yr(r)){if(t?s.to==r.doc.length:s.from==0)continue;let o=r.doc.lineAt(t?s.to+1:s.from-1),l=o.length+1;if(t){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+r.lineBreak});for(let h of s.ranges)n.push(I.range(Math.min(r.doc.length,h.anchor+l),Math.min(r.doc.length,h.head+l)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:r.lineBreak+o.text});for(let h of s.ranges)n.push(I.range(h.anchor-l,h.head-l))}}return i.length?(e(r.update({changes:i,scrollIntoView:!0,selection:I.create(n,r.selection.mainIndex),userEvent:"move.line"})),!0):!1}const j0=({state:r,dispatch:e})=>Nu(r,e,!1),q0=({state:r,dispatch:e})=>Nu(r,e,!0);function Fu(r,e,t){if(r.readOnly)return!1;let i=[];for(let s of Yr(r))t?i.push({from:s.from,insert:r.doc.slice(s.from,s.to)+r.lineBreak}):i.push({from:s.to,insert:r.lineBreak+r.doc.slice(s.from,s.to)});let n=r.changes(i);return e(r.update({changes:n,selection:r.selection.map(n,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const U0=({state:r,dispatch:e})=>Fu(r,e,!1),J0=({state:r,dispatch:e})=>Fu(r,e,!0),G0=r=>{if(r.state.readOnly)return!1;let{state:e}=r,t=e.changes(Yr(e).map(({from:n,to:s})=>(n>0?n--:s<e.doc.length&&s++,{from:n,to:s}))),i=on(e.selection,n=>{let s;if(r.lineWrapping){let o=r.lineBlockAt(n.head),l=r.coordsAtPos(n.head,n.assoc||1);l&&(s=o.bottom+r.documentTop-l.bottom+r.defaultLineHeight/2)}return r.moveVertically(n,!0,s)}).map(t);return r.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Y0(r,e){if(/\(\)|\[\]|\{\}/.test(r.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=ct(r).resolveInner(e),i=t.childBefore(e),n=t.childAfter(e),s;return i&&n&&i.to<=e&&n.from>=e&&(s=i.type.prop(se.closedBy))&&s.indexOf(n.name)>-1&&r.doc.lineAt(i.to).from==r.doc.lineAt(n.from).from&&!/\S/.test(r.sliceDoc(i.to,n.from))?{from:i.to,to:n.from}:null}const wo=Hu(!1),Q0=Hu(!0);function Hu(r){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(n=>{let{from:s,to:o}=n,l=e.doc.lineAt(s),h=!r&&s==o&&Y0(e,s);r&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let u=new jr(e,{simulateBreak:s,simulateDoubleBreak:!!h}),p=$o(u,s);for(p==null&&(p=Wr(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;h?{from:s,to:o}=h:s>l.from&&s<l.from+100&&!/\S/.test(l.text.slice(0,s))&&(s=l.from);let m=["",Pn(e,p)];return h&&m.push(Pn(e,u.lineIndent(l.from,-1))),{changes:{from:s,to:o,insert:ce.of(m)},range:I.cursor(s+1+m[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function el(r,e){let t=-1;return r.changeByRange(i=>{let n=[];for(let o=i.from;o<=i.to;){let l=r.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,n,i),t=l.number),o=l.to+1}let s=r.changes(n);return{changes:n,range:I.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}const Wu=({state:r,dispatch:e})=>{if(r.readOnly)return!1;let t=Object.create(null),i=new jr(r,{overrideIndentation:s=>{let o=t[s];return o??-1}}),n=el(r,(s,o,l)=>{let h=$o(i,s.from);if(h==null)return;/\S/.test(s.text)||(h=0);let u=/^\s*/.exec(s.text)[0],p=Pn(r,h);(u!=p||l.from<s.from+u.length)&&(t[s.from]=h,o.push({from:s.from,to:s.from+u.length,insert:p}))});return n.changes.empty||e(r.update(n,{userEvent:"indent"})),!0},tl=({state:r,dispatch:e})=>r.readOnly?!1:(e(r.update(el(r,(t,i)=>{i.push({from:t.from,insert:r.facet(nn)})}),{userEvent:"input.indent"})),!0),il=({state:r,dispatch:e})=>r.readOnly?!1:(e(r.update(el(r,(t,i)=>{let n=/^\s*/.exec(t.text)[0];if(!n)return;let s=Wr(n,r.tabSize),o=0,l=Pn(r,Math.max(0,s-Dr(r)));for(;o<n.length&&o<l.length&&n.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+n.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),X0=r=>(r.setTabFocusMode(),!0),Z0=[{key:"Ctrl-b",run:Zo,shift:Cu,preventDefault:!0},{key:"Ctrl-f",run:pu,shift:Au},{key:"Ctrl-p",run:vu,shift:Ou},{key:"Ctrl-n",run:yu,shift:Lu},{key:"Ctrl-a",run:k0,shift:D0},{key:"Ctrl-e",run:x0,shift:R0},{key:"Ctrl-d",run:Eu},{key:"Ctrl-h",run:xo},{key:"Ctrl-k",run:V0},{key:"Ctrl-Alt-h",run:Pu},{key:"Ctrl-o",run:$0},{key:"Ctrl-t",run:_0},{key:"Ctrl-v",run:ko}],ev=[{key:"ArrowLeft",run:Zo,shift:Cu,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:c0,shift:S0,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:v0,shift:L0,preventDefault:!0},{key:"ArrowRight",run:pu,shift:Au,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:d0,shift:C0,preventDefault:!0},{mac:"Cmd-ArrowRight",run:y0,shift:B0,preventDefault:!0},{key:"ArrowUp",run:vu,shift:Ou,preventDefault:!0},{mac:"Cmd-ArrowUp",run:fh,shift:ch},{mac:"Ctrl-ArrowUp",run:lh,shift:ah},{key:"ArrowDown",run:yu,shift:Lu,preventDefault:!0},{mac:"Cmd-ArrowDown",run:uh,shift:dh},{mac:"Ctrl-ArrowDown",run:ko,shift:hh},{key:"PageUp",run:lh,shift:ah},{key:"PageDown",run:ko,shift:hh},{key:"Home",run:bu,shift:O0,preventDefault:!0},{key:"Mod-Home",run:fh,shift:ch},{key:"End",run:wu,shift:T0,preventDefault:!0},{key:"Mod-End",run:uh,shift:dh},{key:"Enter",run:wo,shift:wo},{key:"Mod-a",run:E0},{key:"Backspace",run:xo,shift:xo,preventDefault:!0},{key:"Delete",run:Eu,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Pu,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:W0,preventDefault:!0},{mac:"Mod-Backspace",run:K0,preventDefault:!0},{mac:"Mod-Delete",run:z0,preventDefault:!0}].concat(Z0.map(r=>({mac:r.key,run:r.run,shift:r.shift}))),fy=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:g0,shift:A0},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:m0,shift:M0},{key:"Alt-ArrowUp",run:j0},{key:"Shift-Alt-ArrowUp",run:U0},{key:"Alt-ArrowDown",run:q0},{key:"Shift-Alt-ArrowDown",run:J0},{key:"Mod-Alt-ArrowUp",run:N0},{key:"Mod-Alt-ArrowDown",run:F0},{key:"Escape",run:H0},{key:"Mod-Enter",run:Q0},{key:"Alt-l",mac:"Ctrl-l",run:I0},{key:"Mod-i",run:P0,preventDefault:!0},{key:"Mod-[",run:il},{key:"Mod-]",run:tl},{key:"Mod-Alt-\\",run:Wu},{key:"Shift-Mod-k",run:G0},{key:"Shift-Mod-\\",run:b0},{key:"Mod-/",run:Gm},{key:"Alt-A",mac:"Ctrl-A",run:Ym},{key:"Ctrl-m",mac:"Shift-Alt-m",run:X0}].concat(ev),uy={key:"Tab",run:tl,shift:il};function tv(r){var e=r.Pos;function t(a,f,c){if(f.line===c.line&&f.ch>=c.ch-1){var d=a.getLine(f.line),g=d.charCodeAt(f.ch);55296<=g&&g<=55551&&(c.ch+=1)}return{start:f,end:c}}var i=[{keys:"<Left>",type:"keyToKey",toKeys:"h"},{keys:"<Right>",type:"keyToKey",toKeys:"l"},{keys:"<Up>",type:"keyToKey",toKeys:"k"},{keys:"<Down>",type:"keyToKey",toKeys:"j"},{keys:"g<Up>",type:"keyToKey",toKeys:"gk"},{keys:"g<Down>",type:"keyToKey",toKeys:"gj"},{keys:"<Space>",type:"keyToKey",toKeys:"l"},{keys:"<BS>",type:"keyToKey",toKeys:"h"},{keys:"<Del>",type:"keyToKey",toKeys:"x"},{keys:"<C-Space>",type:"keyToKey",toKeys:"W"},{keys:"<C-BS>",type:"keyToKey",toKeys:"B"},{keys:"<S-Space>",type:"keyToKey",toKeys:"w"},{keys:"<S-BS>",type:"keyToKey",toKeys:"b"},{keys:"<C-n>",type:"keyToKey",toKeys:"j"},{keys:"<C-p>",type:"keyToKey",toKeys:"k"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"c",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"VdO",context:"visual"},{keys:"<Home>",type:"keyToKey",toKeys:"0"},{keys:"<End>",type:"keyToKey",toKeys:"$"},{keys:"<PageUp>",type:"keyToKey",toKeys:"<C-b>"},{keys:"<PageDown>",type:"keyToKey",toKeys:"<C-f>"},{keys:"<CR>",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"<Ins>",type:"keyToKey",toKeys:"i",context:"normal"},{keys:"<Ins>",type:"action",action:"toggleOverwrite",context:"insert"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"h",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!1}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!0}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!1}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:"ge",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!1,toJumplist:!0}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!0,toJumplist:!0}},{keys:"(",type:"motion",motion:"moveBySentence",motionArgs:{forward:!1}},{keys:")",type:"motion",motion:"moveBySentence",motionArgs:{forward:!0}},{keys:"<C-f>",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"<C-b>",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"<C-d>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"<C-u>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!1,explicitRepeat:!0}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"g$",type:"motion",motion:"moveToEndOfDisplayLine"},{keys:"g^",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"g0",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,toFirstChar:!0}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0,toJumplist:!0}},{keys:"f<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'<register>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`<register>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0,linewise:!0}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1,linewise:!0}},{keys:"]p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0,matchIndent:!0}},{keys:"[p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:"]<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!1,toJumplist:!0}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:!0},context:"visual"},{keys:"d",type:"operator",operator:"delete"},{keys:"y",type:"operator",operator:"yank"},{keys:"c",type:"operator",operator:"change"},{keys:"=",type:"operator",operator:"indentAuto"},{keys:">",type:"operator",operator:"indent",operatorArgs:{indentRight:!0}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:"g~",type:"operator",operator:"changeCase"},{keys:"gu",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},isEdit:!0},{keys:"gU",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},isEdit:!0},{keys:"gc",type:"operator",operator:"toggleComment",isEdit:!0},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:!0}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:!1,toJumplist:!0}},{keys:"gn",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!0}},{keys:"gN",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!1}},{keys:"gq",type:"operator",operator:"hardWrap"},{keys:"gw",type:"operator",operator:"hardWrap",operatorArgs:{keepCursor:!0}},{keys:"g?",type:"operator",operator:"rot13"},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"D",type:"operator",operator:"delete",operatorArgs:{linewise:!0},context:"visual"},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"expandToLine",motionArgs:{linewise:!0},context:"normal"},{keys:"Y",type:"operator",operator:"yank",operatorArgs:{linewise:!0},context:"visual"},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"C",type:"operator",operator:"change",operatorArgs:{linewise:!0},context:"visual"},{keys:"~",type:"operatorMotion",operator:"changeCase",motion:"moveByCharacters",motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:"normal"},{keys:"~",type:"operator",operator:"changeCase",context:"visual"},{keys:"<C-u>",type:"operatorMotion",operator:"delete",motion:"moveToStartOfLine",context:"insert"},{keys:"<C-w>",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"<C-w>",type:"idle",context:"normal"},{keys:"<C-i>",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"<C-o>",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"<C-e>",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"<C-y>",type:"action",action:"scroll",actionArgs:{forward:!1,linewise:!0}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"endOfSelectedArea"},context:"visual"},{keys:"i",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"gi",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"lastEdit"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"firstNonBlank"},context:"normal"},{keys:"gI",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"bol"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"startOfSelectedArea"},context:"visual"},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:"<C-v>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"<C-q>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:!0},{keys:"gJ",type:"action",action:"joinLines",actionArgs:{keepSpaces:!0},isEdit:!0},{keys:"p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:"P",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:"r<character>",type:"action",action:"replace",isEdit:!0},{keys:"@<register>",type:"action",action:"replayMacro"},{keys:"q<register>",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{replace:!0},context:"normal"},{keys:"R",type:"operator",operator:"change",operatorArgs:{linewise:!0,fullLine:!0},context:"visual",exitVisualBlock:!0},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},context:"visual",isEdit:!0},{keys:"U",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},context:"visual",isEdit:!0},{keys:"<C-r>",type:"action",action:"redo"},{keys:"m<register>",type:"action",action:"setMark"},{keys:'"<register>',type:"action",action:"setRegister"},{keys:"<C-r><register>",type:"action",action:"insertRegister",context:"insert",isEdit:!0},{keys:"<C-o>",type:"action",action:"oneNormalCommand",context:"insert"},{keys:"zz",type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:"z.",type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zt",type:"action",action:"scrollToCursor",actionArgs:{position:"top"}},{keys:"z<CR>",type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zb",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:"z-",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:".",type:"action",action:"repeatLastEdit"},{keys:"<C-a>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"<C-x>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"<C-t>",type:"action",action:"indent",actionArgs:{indentRight:!0},context:"insert"},{keys:"<C-d>",type:"action",action:"indent",actionArgs:{indentRight:!1},context:"insert"},{keys:"a<register>",type:"motion",motion:"textObjectManipulation"},{keys:"i<register>",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:"/",type:"search",searchArgs:{forward:!0,querySrc:"prompt",toJumplist:!0}},{keys:"?",type:"search",searchArgs:{forward:!1,querySrc:"prompt",toJumplist:!0}},{keys:"*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"g*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:"g#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:":",type:"ex"}],n=Object.create(null),s=i.length,o=[{name:"colorscheme",shortName:"colo"},{name:"map"},{name:"imap",shortName:"im"},{name:"nmap",shortName:"nm"},{name:"vmap",shortName:"vm"},{name:"omap",shortName:"om"},{name:"noremap",shortName:"no"},{name:"nnoremap",shortName:"nn"},{name:"vnoremap",shortName:"vn"},{name:"inoremap",shortName:"ino"},{name:"onoremap",shortName:"ono"},{name:"unmap"},{name:"mapclear",shortName:"mapc"},{name:"nmapclear",shortName:"nmapc"},{name:"vmapclear",shortName:"vmapc"},{name:"imapclear",shortName:"imapc"},{name:"omapclear",shortName:"omapc"},{name:"write",shortName:"w"},{name:"undo",shortName:"u"},{name:"redo",shortName:"red"},{name:"set",shortName:"se"},{name:"setlocal",shortName:"setl"},{name:"setglobal",shortName:"setg"},{name:"sort",shortName:"sor"},{name:"substitute",shortName:"s",possiblyAsync:!0},{name:"startinsert",shortName:"start"},{name:"nohlsearch",shortName:"noh"},{name:"yank",shortName:"y"},{name:"put",shortName:"pu"},{name:"delmarks",shortName:"delm"},{name:"marks",excludeFromCommandHistory:!0},{name:"registers",shortName:"reg",excludeFromCommandHistory:!0},{name:"vglobal",shortName:"v"},{name:"delete",shortName:"d"},{name:"join",shortName:"j"},{name:"normal",shortName:"norm"},{name:"global",shortName:"g"}],l=ol("");function h(a){a.setOption("disableInput",!0),a.setOption("showCursorWhenSelecting",!1),r.signal(a,"vim-mode-change",{mode:"normal"}),a.on("cursorActivity",Rl),De(a),r.on(a.getInputField(),"paste",p(a))}function u(a){a.setOption("disableInput",!1),a.off("cursorActivity",Rl),r.off(a.getInputField(),"paste",p(a)),a.state.vim=null,hn&&clearTimeout(hn)}function p(a){var f=a.state.vim;return f.onPasteFn||(f.onPasteFn=function(){f.insertMode||(a.setCursor(Oe(a.getCursor(),0,1)),vi.enterInsertMode(a,{},f))}),f.onPasteFn}var m=/[\d]/,y=[r.isWordChar,function(a){return a&&!r.isWordChar(a)&&!/\s/.test(a)}],x=[function(a){return/\S/.test(a)}],S=["<",">"],C=["-",'"',".",":","_","/","+"],O=/^\w$/,B=/^[A-Z]$/;try{B=new RegExp("^[\\p{Lu}]$","u")}catch{}function F(a,f){return f>=a.firstLine()&&f<=a.lastLine()}function P(a){return/^[a-z]$/.test(a)}function Q(a){return"()[]{}".indexOf(a)!=-1}function W(a){return m.test(a)}function V(a){return B.test(a)}function N(a){return/^\s*$/.test(a)}function re(a){return".?!".indexOf(a)!=-1}function oe(a,f){for(var c=0;c<f.length;c++)if(f[c]==a)return!0;return!1}var ae={};function Z(a,f,c,d,g){if(f===void 0&&!g)throw Error("defaultValue is required unless callback is provided");if(c||(c="string"),ae[a]={type:c,defaultValue:f,callback:g},d)for(var v=0;v<d.length;v++)ae[d[v]]=ae[a];f&&Y(a,f)}function Y(a,f,c,d){var g=ae[a];d=d||{};var v=d.scope;if(!g)return new Error("Unknown option: "+a);if(g.type=="boolean"){if(f&&f!==!0)return new Error("Invalid argument: "+a+"="+f);f!==!1&&(f=!0)}g.callback?(v!=="local"&&g.callback(f,void 0),v!=="global"&&c&&g.callback(f,c)):(v!=="local"&&(g.value=g.type=="boolean"?!!f:f),v!=="global"&&c&&(c.state.vim.options[a]={value:f}))}function ee(a,f,c){var d=ae[a];c=c||{};var g=c.scope;if(!d)return new Error("Unknown option: "+a);if(d.callback){let v=f&&d.callback(void 0,f);return g!=="global"&&v!==void 0?v:g!=="local"?d.callback():void 0}else return(g!=="global"&&f&&f.state.vim.options[a]||g!=="local"&&d||{}).value}Z("filetype",void 0,"string",["ft"],function(a,f){if(f!==void 0)if(a===void 0){let c=f.getOption("mode");return c=="null"?"":c}else{let c=a==""?"null":a;f.setOption("mode",c)}}),Z("textwidth",80,"number",["tw"],function(a,f){if(f!==void 0)if(a===void 0){var c=f.getOption("textwidth");return c}else{var d=Math.round(a);d>1&&f.setOption("textwidth",d)}});var fe=function(){var a=100,f=-1,c=0,d=0,g=new Array(a);function v(b,A,M){var L=f%a,D=g[L];function R(E){var H=++f%a,J=g[H];J&&J.clear(),g[H]=b.setBookmark(E)}if(D){var T=D.find();T&&!pt(T,A)&&R(A)}else R(A);R(M),c=f,d=f-a+1,d<0&&(d=0)}function k(b,A){f+=A,f>c?f=c:f<d&&(f=d);var M=g[(a+f)%a];if(M&&!M.find()){var L=A>0?1:-1,D,R=b.getCursor();do if(f+=L,M=g[(a+f)%a],M&&(D=M.find())&&!pt(R,D))break;while(f<c&&f>d)}return M}function w(b,A){var M=f,L=k(b,A);return f=M,L&&L.find()}return{cachedCursor:void 0,add:v,find:w,move:k}},ge=function(a){return a?{changes:a.changes,expectCursorActivityForChange:a.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};class Fe{constructor(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=ge()}exitMacroRecordMode(){var f=z.macroModeState;f.onRecordingDone&&f.onRecordingDone(),f.onRecordingDone=void 0,f.isRecording=!1}enterMacroRecordMode(f,c){var d=z.registerController.getRegister(c);if(d){if(d.clear(),this.latestRegister=c,f.openDialog){var g=Ct("span",{class:"cm-vim-message"},"recording @"+c);this.onRecordingDone=f.openDialog(g,function(){},{bottom:!0})}this.isRecording=!0}}}function De(a){return a.state.vim||(a.state.vim={inputState:new ll,lastEditInputState:void 0,lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},insertMode:!1,insertModeReturn:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:void 0,sel:{anchor:new e(0,0),head:new e(0,0)},options:{},expectLiteralNext:!1,status:""}),a.state.vim}var z;function Re(){z={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:fe(),macroModeState:new Fe,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new tc({}),searchHistoryController:new al,exCommandHistoryController:new al};for(var a in ae){var f=ae[a];f.value=f.defaultValue}}class Ue{constructor(f,c){this.keyName=f,this.key=c.key,this.ctrlKey=c.ctrlKey,this.altKey=c.altKey,this.metaKey=c.metaKey,this.shiftKey=c.shiftKey}}var Xe,xe={enterVimMode:h,leaveVimMode:u,buildKeyMap:function(){},getRegisterController:function(){return z.registerController},resetVimGlobalState_:Re,getVimGlobalState_:function(){return z},maybeInitVimState_:De,suppressErrorLogging:!1,InsertModeKey:Ue,map:function(a,f,c){st.map(a,f,c)},unmap:function(a,f){return st.unmap(a,f)},noremap:function(a,f,c){st.map(a,f,c,!0)},mapclear:function(a){var f=i.length,c=s,d=i.slice(0,f-c);if(i=i.slice(f-c),a)for(var g=d.length-1;g>=0;g--){var v=d[g];if(a!==v.context)if(v.context)this._mapCommand(v);else{var k=["normal","insert","visual"];for(var w in k)if(k[w]!==a){var b=Object.assign({},v);b.context=k[w],this._mapCommand(b)}}}},langmap:sl,vimKeyFromEvent:ln,setOption:Y,getOption:ee,defineOption:Z,defineEx:function(a,f,c){if(!f)f=a;else if(a.indexOf(f)!==0)throw new Error('(Vim.defineEx) "'+f+'" is not a prefix of "'+a+'", command not registered');Bl[a]=c,st.commandMap_[f]={name:a,shortName:f,type:"api"}},handleKey:function(a,f,c){var d=this.findKey(a,f,c);if(typeof d=="function")return d()},multiSelectHandleKey:_c,findKey:function(a,f,c){var d=De(a),g=a;function v(){var M=z.macroModeState;if(M.isRecording){if(f=="q")return M.exitMacroRecordMode(),Pe(g),!0;c!="mapping"&&Kc(M,f)}}function k(){if(f=="<Esc>"){if(d.visualMode)Et(g);else if(d.insertMode)ii(g);else return;return Pe(g),!0}}function w(){if(k())return!0;d.inputState.keyBuffer.push(f);var M=d.inputState.keyBuffer.join(""),L=f.length==1,D=mi.matchCommand(M,i,d.inputState,"insert"),R=d.inputState.changeQueue;if(D.type=="none")return Pe(g),!1;if(D.type=="partial"){if(D.expectLiteralNext&&(d.expectLiteralNext=!0),Xe&&window.clearTimeout(Xe),Xe=L&&window.setTimeout(function(){d.insertMode&&d.inputState.keyBuffer.length&&Pe(g)},ee("insertModeEscKeysTimeout")),L){var T=g.listSelections();(!R||R.removed.length!=T.length)&&(R=d.inputState.changeQueue=new Zu),R.inserted+=f;for(var E=0;E<T.length;E++){var H=et(T[E].anchor,T[E].head),J=ti(T[E].anchor,T[E].head),q=g.getRange(H,g.state.overwrite?Oe(J,0,1):J);R.removed[E]=(R.removed[E]||"")+q}}return!L}else D.type=="full"&&(d.inputState.keyBuffer.length=0);if(d.expectLiteralNext=!1,Xe&&window.clearTimeout(Xe),D.command&&R){for(var T=g.listSelections(),E=0;E<T.length;E++){var U=T[E].head;g.replaceRange(R.removed[E]||"",Oe(U,0,-R.inserted.length),U,"+input")}z.macroModeState.lastInsertModeChanges.changes.pop()}return D.command||Pe(g),D.command}function b(){if(v()||k())return!0;d.inputState.keyBuffer.push(f);var M=d.inputState.keyBuffer.join("");if(/^[1-9]\d*$/.test(M))return!0;var L=/^(\d*)(.*)$/.exec(M);if(!L)return Pe(g),!1;var D=d.visualMode?"visual":"normal",R=L[2]||L[1];d.inputState.operatorShortcut&&d.inputState.operatorShortcut.slice(-1)==R&&(R=d.inputState.operatorShortcut);var T=mi.matchCommand(R,i,d.inputState,D);return T.type=="none"?(Pe(g),!1):T.type=="partial"?(T.expectLiteralNext&&(d.expectLiteralNext=!0),!0):T.type=="clear"?(Pe(g),!0):(d.expectLiteralNext=!1,d.inputState.keyBuffer.length=0,L=/^(\d*)(.*)$/.exec(M),L&&L[1]&&L[1]!="0"&&d.inputState.pushRepeatDigit(L[1]),T.command)}var A=d.insertMode?w():b();if(A===!1)return!d.insertMode&&(f.length===1||r.isMac&&/<A-.>/.test(f))?function(){return!0}:void 0;if(A===!0)return function(){return!0};if(A)return function(){return g.operation(function(){g.curOp.isVimOp=!0;try{if(typeof A!="object")return;A.type=="keyToKey"?ei(g,A.toKeys,A):mi.processCommand(g,d,A)}catch(M){throw g.state.vim=void 0,De(g),xe.suppressErrorLogging||console.log(M),M}return!0})}},handleEx:function(a,f){st.processCommand(a,f)},defineMotion:ic,defineAction:rc,defineOperator:nc,mapCommand:Wc,_mapCommand:ss,defineRegister:ec,exitVisualMode:Et,exitInsertMode:ii},He=[],dt=!1,ve;function Di(a){if(!ve)throw new Error("No prompt to send key to");if(a[0]=="<"){var f=a.toLowerCase().slice(1,-1),c=f.split("-");if(f=c.pop()||"",f=="lt")a="<";else if(f=="space")a=" ";else if(f=="cr")a=`
|
|
11
12
|
`;else if(Ri[f]){var d=ve.value||"",g={key:Ri[f],target:{value:d,selectionEnd:d.length,selectionStart:d.length}};ve.onKeyDown&&ve.onKeyDown(g,ve.value,k),ve&&ve.onKeyUp&&ve.onKeyUp(g,ve.value,k);return}}if(a==`
|
|
12
13
|
`){var v=ve;ve=null,v.onClose&&v.onClose(v.value)}else ve.value=(ve.value||"")+a;function k(w){ve&&(typeof w=="string"?ve.value=w:ve=null)}}function ei(a,f,c){var d=dt;if(c){if(He.indexOf(c)!=-1)return;He.push(c),dt=c.noremap!=!1}try{for(var g=De(a),v=/<(?:[CSMA]-)*\w+>|./gi,k;k=v.exec(f);){var w=k[0],b=g.insertMode;if(ve){Di(w);continue}var A=xe.handleKey(a,w,"mapping");if(!A&&b&&g.insertMode){if(w[0]=="<"){var M=w.toLowerCase().slice(1,-1),L=M.split("-");if(M=L.pop()||"",M=="lt")w="<";else if(M=="space")w=" ";else if(M=="cr")w=`
|
|
13
|
-
`;else if(Ri.hasOwnProperty(M)){w=Ri[M],Nl(a,w);continue}else w=w[0],v.lastIndex=k.index+1}a.replaceSelection(w)}}}finally{if(He.pop(),dt=He.length?d:!1,!He.length&&ve){var D=ve;ve=null
|
|
14
|
-
`),this.linewise=!0),this.keyBuffer.push(f)}pushInsertModeChanges(f){this.insertModeChanges.push(ge(f))}pushSearchQuery(f){this.searchQueries.push(f)}clear(){this.keyBuffer=[],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!1}toString(){return this.keyBuffer.join("")}}function
|
|
14
|
+
`;else if(Ri.hasOwnProperty(M)){w=Ri[M],Nl(a,w);continue}else w=w[0],v.lastIndex=k.index+1}a.replaceSelection(w)}}}finally{if(He.pop(),dt=He.length?d:!1,!He.length&&ve){var D=ve;ve=null,$n(a,D)}}}var Qr={Return:"CR",Backspace:"BS",Delete:"Del",Escape:"Esc",Insert:"Ins",ArrowLeft:"Left",ArrowRight:"Right",ArrowUp:"Up",ArrowDown:"Down",Enter:"CR"," ":"Space"},Xu={Shift:1,Alt:1,Command:1,Control:1,CapsLock:1,AltGraph:1,Dead:1,Unidentified:1},Ri={};"Left|Right|Up|Down|End|Home".split("|").concat(Object.keys(Qr)).forEach(function(a){Ri[(Qr[a]||"").toLowerCase()]=Ri[a.toLowerCase()]=a});function ln(a,f){var c=a.key;if(!Xu[c]){c.length>1&&c[0]=="n"&&(c=c.replace("Numpad","")),c=Qr[c]||c;var d="";if(a.ctrlKey&&(d+="C-"),a.altKey&&(d+="A-"),a.metaKey&&(d+="M-"),r.isMac&&d=="A-"&&c.length==1&&(d=d.slice(2)),(d||c.length>1)&&a.shiftKey&&(d+="S-"),f&&!f.expectLiteralNext&&c.length==1){if(l.keymap&&c in l.keymap)(l.remapCtrl!=!1||!d)&&(c=l.keymap[c]);else if(c.charCodeAt(0)>128&&!n[c]){var g=a.code?.slice(-1)||"";a.shiftKey||(g=g.toLowerCase()),g&&(c=g,!d&&a.altKey&&(d="A-"))}}return d+=c,d.length>1&&(d="<"+d+">"),d}}function sl(a,f){l.string!==a&&(l=ol(a)),l.remapCtrl=f}function ol(a){let f={};if(!a)return{keymap:f,string:""};function c(d){return d.split(/\\?(.)/).filter(Boolean)}return a.split(/((?:[^\\,]|\\.)+),/).map(d=>{if(!d)return;const g=d.split(/((?:[^\\;]|\\.)+);/);if(g.length==3){const v=c(g[1]),k=c(g[2]);if(v.length!==k.length)return;for(let w=0;w<v.length;++w)f[v[w]]=k[w]}else if(g.length==1){const v=c(d);if(v.length%2!==0)return;for(let k=0;k<v.length;k+=2)f[v[k]]=v[k+1]}}),{keymap:f,string:a}}Z("langmap",void 0,"string",["lmap"],function(a,f){if(a===void 0)return l.string;sl(a)});class ll{constructor(){this.prefixRepeat=[],this.motionRepeat=[],this.operator=null,this.operatorArgs=null,this.motion=null,this.motionArgs=null,this.keyBuffer=[],this.registerName=void 0,this.changeQueue=null}pushRepeatDigit(f){this.operator?this.motionRepeat=this.motionRepeat.concat(f):this.prefixRepeat=this.prefixRepeat.concat(f)}getRepeat(){var f=0;return(this.prefixRepeat.length>0||this.motionRepeat.length>0)&&(f=1,this.prefixRepeat.length>0&&(f*=parseInt(this.prefixRepeat.join(""),10)),this.motionRepeat.length>0&&(f*=parseInt(this.motionRepeat.join(""),10))),f}}function Pe(a,f){a.state.vim.inputState=new ll,a.state.vim.expectLiteralNext=!1,r.signal(a,"vim-command-done",f)}function Zu(){this.removed=[],this.inserted=""}class Dt{constructor(f,c,d){this.clear(),this.keyBuffer=[f||""],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!!c,this.blockwise=!!d}setText(f,c,d){this.keyBuffer=[f||""],this.linewise=!!c,this.blockwise=!!d}pushText(f,c){c&&(this.linewise||this.keyBuffer.push(`
|
|
15
|
+
`),this.linewise=!0),this.keyBuffer.push(f)}pushInsertModeChanges(f){this.insertModeChanges.push(ge(f))}pushSearchQuery(f){this.searchQueries.push(f)}clear(){this.keyBuffer=[],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!1}toString(){return this.keyBuffer.join("")}}function ec(a,f){var c=z.registerController.registers;if(!a||a.length!=1)throw Error("Register name must be 1 character");if(c[a])throw Error("Register already defined "+a);c[a]=f,C.push(a)}class tc{constructor(f){this.registers=f,this.unnamedRegister=f['"']=new Dt,f["."]=new Dt,f[":"]=new Dt,f["/"]=new Dt,f["+"]=new Dt}pushText(f,c,d,g,v){if(f!=="_"){g&&d.charAt(d.length-1)!==`
|
|
15
16
|
`&&(d+=`
|
|
16
17
|
`);var k=this.isValidRegister(f)?this.getRegister(f):null;if(!k||!f){switch(c){case"yank":this.registers[0]=new Dt(d,g,v);break;case"delete":case"change":d.indexOf(`
|
|
17
|
-
`)==-1?this.registers["-"]=new Dt(d,g):(this.shiftNumericRegisters_(),this.registers[1]=new Dt(d,g));break}this.unnamedRegister.setText(d,g,v);return}var w=V(f);w?k.pushText(d,g):k.setText(d,g,v),f==="+"&&navigator.clipboard.writeText(d),this.unnamedRegister.setText(k.toString(),g)}}getRegister(f){return this.isValidRegister(f)?(f=f.toLowerCase(),this.registers[f]||(this.registers[f]=new Dt),this.registers[f]):this.unnamedRegister}isValidRegister(f){return f&&(oe(f,C)||O.test(f))}shiftNumericRegisters_(){for(var f=9;f>=2;f--)this.registers[f]=this.getRegister(""+(f-1))}}class al{constructor(){this.historyBuffer=[],this.iterator=0,this.initialPrefix=null}nextMatch(f,c){var d=this.historyBuffer,g=c?-1:1;this.initialPrefix===null&&(this.initialPrefix=f);for(var v=this.iterator+g;c?v>=0:v<d.length;v+=g)for(var k=d[v],w=0;w<=k.length;w++)if(this.initialPrefix==k.substring(0,w))return this.iterator=v,k;if(v>=d.length)return this.iterator=d.length,this.initialPrefix;if(v<0)return f}pushInput(f){var c=this.historyBuffer.indexOf(f);c>-1&&this.historyBuffer.splice(c,1),f.length&&this.historyBuffer.push(f)}reset(){this.initialPrefix=null,this.iterator=this.historyBuffer.length}}var mi={matchCommand:function(a,f,c,d){var g=oc(a,f,d,c),v=g.full[0];if(!v)return g.partial.length?{type:"partial",expectLiteralNext:g.partial.length==1&&g.partial[0].keys.slice(-11)=="<character>"}:{type:"none"};if(v.keys.slice(-11)=="<character>"||v.keys.slice(-10)=="<register>"){var k=ac(a);if(!k||k.length>1)return{type:"clear"};c.selectedCharacter=k}return{type:"full",command:v}},processCommand:function(a,f,c){switch(f.inputState.repeatOverride=c.repeatOverride,c.type){case"motion":this.processMotion(a,f,c);break;case"operator":this.processOperator(a,f,c);break;case"operatorMotion":this.processOperatorMotion(a,f,c);break;case"action":this.processAction(a,f,c);break;case"search":this.processSearch(a,f,c);break;case"ex":case"keyToEx":this.processEx(a,f,c);break}},processMotion:function(a,f,c){f.inputState.motion=c.motion,f.inputState.motionArgs=Kn(c.motionArgs),this.evalInput(a,f)},processOperator:function(a,f,c){var d=f.inputState;if(d.operator)if(d.operator==c.operator){d.motion="expandToLine",d.motionArgs={linewise:!0,repeat:1},this.evalInput(a,f);return}else Pe(a);d.operator=c.operator,d.operatorArgs=Kn(c.operatorArgs),c.keys.length>1&&(d.operatorShortcut=c.keys),c.exitVisualBlock&&(f.visualBlock=!1,Ei(a)),f.visualMode&&this.evalInput(a,f)},processOperatorMotion:function(a,f,c){var d=f.visualMode,g=Kn(c.operatorMotionArgs);g&&d&&g.visualLine&&(f.visualLine=!0),this.processOperator(a,f,c),d||this.processMotion(a,f,c)},processAction:function(a,f,c){var d=f.inputState,g=d.getRepeat(),v=!!g,k=Kn(c.actionArgs)||{repeat:1};d.selectedCharacter&&(k.selectedCharacter=d.selectedCharacter),c.operator&&this.processOperator(a,f,c),c.motion&&this.processMotion(a,f,c),(c.motion||c.operator)&&this.evalInput(a,f),k.repeat=g||1,k.repeatIsExplicit=v,k.registerName=d.registerName,Pe(a),f.lastMotion=null,c.isEdit&&this.recordLastEdit(f,d,c),vi[c.action](a,k,f)},processSearch:function(a,f,c){if(!a.getSearchCursor)return;var d=c.searchArgs.forward,g=c.searchArgs.wholeWordOnly;St(a).setReversed(!d);var v=d?"/":"?",k=St(a).getQuery(),w=a.getScrollInfo(),b="";function A(q,U,X){z.searchHistoryController.pushInput(q),z.searchHistoryController.reset();try{an(a,q,U,X)}catch{he(a,"Invalid regex: "+q),Pe(a);return}mi.processMotion(a,f,{keys:"",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:c.searchArgs.toJumplist}})}function M(q){a.scrollTo(w.left,w.top),A(q,!0,!0);var U=z.macroModeState;U.isRecording&&_c(U,q)}function L(){return ee("pcre")?"(JavaScript regexp: set pcre)":"(Vim regexp: set nopcre)"}function D(q,U,X){var ie=ln(q),Le,Se;ie=="<Up>"||ie=="<Down>"?(Le=ie=="<Up>",Se=q.target?q.target.selectionEnd:0,U=z.searchHistoryController.nextMatch(U,Le)||"",X(U),Se&&q.target&&(q.target.selectionEnd=q.target.selectionStart=Math.min(Se,q.target.value.length))):ie&&ie!="<Left>"&&ie!="<Right>"&&z.searchHistoryController.reset(),b=U,R()}function R(){var q;try{q=an(a,b,!0,!0)}catch{}q?a.scrollIntoView(Ol(a,!d,q),30):(Ii(a),a.scrollTo(w.left,w.top))}function T(q,U,X){var ie=ln(q);ie=="<Esc>"||ie=="<C-c>"||ie=="<C-[>"||ie=="<BS>"&&U==""?(z.searchHistoryController.pushInput(U),z.searchHistoryController.reset(),an(a,k?.source||""),Ii(a),a.scrollTo(w.left,w.top),r.e_stop(q),Pe(a),X(),a.focus()):ie=="<Up>"||ie=="<Down>"?r.e_stop(q):ie=="<C-u>"&&(r.e_stop(q),X(""))}switch(c.searchArgs.querySrc){case"prompt":var E=z.macroModeState;if(E.isPlaying){let U=E.replaySearchQueries.shift();A(U||"",!0,!1)}else zn(a,{onClose:M,prefix:v,desc:Ct("span",{$cursor:"pointer",onmousedown:function(U){U.preventDefault(),Y("pcre",!ee("pcre")),this.textContent=L(),R()}},L()),onKeyUp:D,onKeyDown:T});break;case"wordUnderCursor":var H=es(a,{noSymbol:!0}),J=!0;if(H||(H=es(a,{noSymbol:!1}),J=!1),!H){he(a,"No word under cursor"),Pe(a);return}let q=a.getLine(H.start.line).substring(H.start.ch,H.end.ch);J&&g?q="\\b"+q+"\\b":q=hc(q),z.jumpList.cachedCursor=a.getCursor(),a.setCursor(H.start),A(q,!0,!1);break}},processEx:function(a,f,c){function d(b){z.exCommandHistoryController.pushInput(b),z.exCommandHistoryController.reset(),st.processCommand(a,b),a.state.vim&&Pe(a),Ii(a)}function g(b,A,M){var L=ln(b),D,R;(L=="<Esc>"||L=="<C-c>"||L=="<C-[>"||L=="<BS>"&&A=="")&&(z.exCommandHistoryController.pushInput(A),z.exCommandHistoryController.reset(),r.e_stop(b),Pe(a),Ii(a),M(),a.focus()),L=="<Up>"||L=="<Down>"?(r.e_stop(b),D=L=="<Up>",R=b.target?b.target.selectionEnd:0,A=z.exCommandHistoryController.nextMatch(A,D)||"",M(A),R&&b.target&&(b.target.selectionEnd=b.target.selectionStart=Math.min(R,b.target.value.length))):L=="<C-u>"?(r.e_stop(b),M("")):L&&L!="<Left>"&&L!="<Right>"&&z.exCommandHistoryController.reset()}function v(b,A){var M=new r.StringStream(A),L={};try{if(st.parseInput_(a,M,L),L.commandName!="s"){Ii(a);return}var D=st.matchCommand_(L.commandName);if(!D||(st.parseCommandArgs_(M,L,D),!L.argString))return;var R=Tl(L.argString.slice(1),!0,!0);R&&is(a,R)}catch{}}if(c.type=="keyToEx")st.processCommand(a,c.exArgs.input);else{var k={onClose:d,onKeyDown:g,onKeyUp:v,prefix:":"};if(f.visualMode)k.value="'<,'>",k.selectValueOnOpen=!1;else{var w=f.inputState.getRepeat();w>1&&(k.value=".,.+"+(w-1),k.selectValueOnOpen=!1)}zn(a,k)}},evalInput:function(a,f){var c=f.inputState,d=c.motion,g=c.motionArgs||{repeat:1},v=c.operator,k=c.operatorArgs||{},w=c.registerName,b=f.sel,A=be(f.visualMode?Ze(a,b.head):a.getCursor("head")),M=be(f.visualMode?Ze(a,b.anchor):a.getCursor("anchor")),L=be(A),D=be(M),R,T,E;if(v&&this.recordLastEdit(f,c),c.repeatOverride!==void 0?E=c.repeatOverride:E=c.getRepeat(),E>0&&g.explicitRepeat?g.repeatIsExplicit=!0:(g.noRepeat||!g.explicitRepeat&&E===0)&&(E=1,g.repeatIsExplicit=!1),c.selectedCharacter&&(g.selectedCharacter=k.selectedCharacter=c.selectedCharacter),g.repeat=E,Pe(a),d){var H=Rt[d](a,A,g,f,c);if(f.lastMotion=Rt[d],!H)return;if(g.toJumplist){var J=z.jumpList,q=J.cachedCursor;q?(gl(a,q,H),delete J.cachedCursor):gl(a,A,H)}H instanceof Array?(T=H[0],R=H[1]):R=H,R||(R=be(A)),f.visualMode?(f.visualBlock&&R.ch===1/0||(R=Ze(a,R,L)),T&&(T=Ze(a,T)),T=T||D,b.anchor=T,b.head=R,Ei(a),Ut(a,f,"<",Me(T,R)?T:R),Ut(a,f,">",Me(T,R)?R:T)):v||(R=Ze(a,R,L),a.setCursor(R.line,R.ch))}if(v){if(k.lastSel){T=D;var U=k.lastSel,X=Math.abs(U.head.line-U.anchor.line),ie=Math.abs(U.head.ch-U.anchor.ch);U.visualLine?R=new e(D.line+X,D.ch):U.visualBlock?R=new e(D.line+X,D.ch+ie):U.head.line==U.anchor.line?R=new e(D.line,D.ch+ie):R=new e(D.line+X,D.ch),f.visualMode=!0,f.visualLine=U.visualLine,f.visualBlock=U.visualBlock,b=f.sel={anchor:T,head:R},Ei(a)}else f.visualMode&&(k.lastSel={anchor:be(b.anchor),head:be(b.head),visualBlock:f.visualBlock,visualLine:f.visualLine});var Le,Se,We,le,te;if(f.visualMode){Le=et(b.head,b.anchor),Se=ti(b.head,b.anchor),We=f.visualLine||k.linewise,le=f.visualBlock?"block":We?"line":"char";var ot=t(a,Le,Se);if(te=Zr(a,{anchor:ot.start,head:ot.end},le),We){var Ve=te.ranges;if(le=="block")for(var Ke=0;Ke<Ve.length;Ke++)Ve[Ke].head.ch=Je(a,Ve[Ke].head.line);else le=="line"&&(Ve[0].head=new e(Ve[0].head.line+1,0))}}else{if(Le=be(T||D),Se=be(R||L),Me(Se,Le)){var yi=Le;Le=Se,Se=yi}We=g.linewise||k.linewise,We?mc(a,Le,Se):g.forward&&gc(a,Le,Se),le="char";var os=!g.inclusive||We,ot=t(a,Le,Se);te=Zr(a,{anchor:ot.start,head:ot.end},le,os)}a.setSelections(te.ranges,te.primary),f.lastMotion=null,k.repeat=E,k.registerName=w,k.linewise=We;var ls=Qr[v](a,k,te.ranges,D,R);f.visualMode&&Et(a,ls!=null),ls&&a.setCursor(ls)}},recordLastEdit:function(a,f,c){var d=z.macroModeState;d.isPlaying||(a.lastEditInputState=f,a.lastEditActionCommand=c,d.lastInsertModeChanges.changes=[],d.lastInsertModeChanges.expectCursorActivityForChange=!1,d.lastInsertModeChanges.visualBlock=a.visualBlock?a.sel.head.line-a.sel.anchor.line:0)}},Rt={moveToTopLine:function(a,f,c){var d=ns(a).top+c.repeat-1;return new e(d,It(a.getLine(d)))},moveToMiddleLine:function(a){var f=ns(a),c=Math.floor((f.top+f.bottom)*.5);return new e(c,It(a.getLine(c)))},moveToBottomLine:function(a,f,c){var d=ns(a).bottom-c.repeat+1;return new e(d,It(a.getLine(d)))},expandToLine:function(a,f,c){var d=f;return new e(d.line+c.repeat-1,1/0)},findNext:function(a,f,c){var d=St(a),g=d.getQuery();if(g){var v=!c.forward;v=d.isReversed()?!v:v,is(a,g);var k=Ol(a,v,g,c.repeat);return k||he(a,"No match found "+g+(ee("pcre")?" (set nopcre to use Vim regexps)":"")),k}},findAndSelectNextInclusive:function(a,f,c,d,g){var v=St(a),k=v.getQuery();if(k){var w=!c.forward;w=v.isReversed()?!w:w;var b=Ic(a,w,k,c.repeat,d);if(b){if(g.operator)return b;var A=b[0],M=new e(b[1].line,b[1].ch-1);if(d.visualMode){(d.visualLine||d.visualBlock)&&(d.visualLine=!1,d.visualBlock=!1,r.signal(a,"vim-mode-change",{mode:"visual",subMode:""}));var L=d.sel.anchor;if(L)return v.isReversed()?c.forward?[L,A]:[L,M]:c.forward?[L,M]:[L,A]}else d.visualMode=!0,d.visualLine=!1,d.visualBlock=!1,r.signal(a,"vim-mode-change",{mode:"visual",subMode:""});return w?[M,A]:[A,M]}}},goToMark:function(a,f,c,d){var g=$n(a,d,c.selectedCharacter||"");return g?c.linewise?{line:g.line,ch:It(a.getLine(g.line))}:g:null},moveToOtherHighlightedEnd:function(a,f,c,d){var g=d.sel;return d.visualBlock&&c.sameLine?[Ze(a,new e(g.anchor.line,g.head.ch)),Ze(a,new e(g.head.line,g.anchor.ch))]:[g.head,g.anchor]},jumpToMark:function(a,f,c,d){for(var g=f,v=0;v<c.repeat;v++){var k=g;for(var w in d.marks)if(P(w)){var b=d.marks[w].find(),A=c.forward?Me(b,k):Me(k,b);if(!A&&!(c.linewise&&b.line==k.line)){var M=pt(k,g),L=c.forward?ul(k,b,g):ul(g,b,k);(M||L)&&(g=b)}}}return c.linewise&&(g=new e(g.line,It(a.getLine(g.line)))),g},moveByCharacters:function(a,f,c){var d=f,g=c.repeat,v=c.forward?d.ch+g:d.ch-g;return new e(d.line,v)},moveByLines:function(a,f,c,d){var g=f,v=g.ch;switch(d.lastMotion){case this.moveByLines:case this.moveByDisplayLines:case this.moveByScroll:case this.moveToColumn:case this.moveToEol:v=d.lastHPos;break;default:d.lastHPos=v}var k=c.repeat+(c.repeatOffset||0),w=c.forward?g.line+k:g.line-k,b=a.firstLine(),A=a.lastLine(),M=a.findPosV(g,c.forward?k:-k,"line",d.lastHSPos),L=c.forward?M.line>w:M.line<w;return L&&(w=M.line,v=M.ch),w<b&&g.line==b?this.moveToStartOfLine(a,f,c,d):w>A&&g.line==A?kl(a,f,c,d,!0):(c.toFirstChar&&(v=It(a.getLine(w)),d.lastHPos=v),d.lastHSPos=a.charCoords(new e(w,v),"div").left,new e(w,v))},moveByDisplayLines:function(a,f,c,d){var g=f;switch(d.lastMotion){case this.moveByDisplayLines:case this.moveByScroll:case this.moveByLines:case this.moveToColumn:case this.moveToEol:break;default:d.lastHSPos=a.charCoords(g,"div").left}for(var v=Math.round(c.repeat),k=0;k<v;k++){var w=a.findPosV(g,c.forward?1:-1,"line",d.lastHSPos);if(w.hitSide)break;g=w}return g!=f&&(d.lastHPos=g.ch),g},moveByPage:function(a,f,c){var d=f,g=c.repeat;return a.findPosV(d,c.forward?g:-g,"page")},moveByParagraph:function(a,f,c){var d=c.forward?1:-1;return xl(a,f,c.repeat,d).start},moveBySentence:function(a,f,c){var d=c.forward?1:-1;return Sc(a,f,c.repeat,d)},moveByScroll:function(a,f,c,d){var g=a.getScrollInfo(),v=null,k=c.repeat;k||(k=g.clientHeight/(2*a.defaultTextHeight()));var w=a.charCoords(f,"local");if(c.repeat=k,v=Rt.moveByDisplayLines(a,f,c,d),!v)return null;var b=a.charCoords(v,"local");return a.scrollTo(null,g.top+b.top-w.top),v},moveByWords:function(a,f,c){return xc(a,f,c.repeat,!!c.forward,!!c.wordEnd,!!c.bigWord)},moveTillCharacter:function(a,f,c){var d=c.repeat,g=ts(a,d,c.forward,c.selectedCharacter,f),v=c.forward?-1:1;return ml(v,c),g?(g.ch+=v,g):null},moveToCharacter:function(a,f,c){var d=c.repeat;return ml(0,c),ts(a,d,c.forward,c.selectedCharacter,f)||f},moveToSymbol:function(a,f,c){var d=c.repeat;return c.selectedCharacter&&kc(a,d,c.forward,c.selectedCharacter)||f},moveToColumn:function(a,f,c,d){var g=c.repeat;return d.lastHPos=g-1,d.lastHSPos=a.charCoords(f,"div").left,wc(a,g)},moveToEol:function(a,f,c,d){return kl(a,f,c,d,!1)},moveToFirstNonWhiteSpaceCharacter:function(a,f){var c=f;return new e(c.line,It(a.getLine(c.line)))},moveToMatchedSymbol:function(a,f){for(var c=f,d=c.line,g=c.ch,v=a.getLine(d),k;g<v.length;g++)if(k=v.charAt(g),k&&Q(k)){var w=a.getTokenTypeAt(new e(d,g+1));if(w!=="string"&&w!=="comment")break}if(g<v.length){var b=k==="<"||k===">"?/[(){}[\]<>]/:/[(){}[\]]/,A=a.findMatchingBracket(new e(d,g),{bracketRegex:b});return A.to}else return c},moveToStartOfLine:function(a,f){return new e(f.line,0)},moveToLineOrEdgeOfDocument:function(a,f,c){var d=c.forward?a.lastLine():a.firstLine();return c.repeatIsExplicit&&(d=c.repeat-a.getOption("firstLineNumber")),new e(d,It(a.getLine(d)))},moveToStartOfDisplayLine:function(a){return a.execCommand("goLineLeft"),a.getCursor()},moveToEndOfDisplayLine:function(a){a.execCommand("goLineRight");var f=a.getCursor();return f.sticky=="before"&&f.ch--,f},textObjectManipulation:function(a,f,c,d){var g={"(":")",")":"(","{":"}","}":"{","[":"]","]":"[","<":">",">":"<"},v={"'":!0,'"':!0,"`":!0},k=c.selectedCharacter||"";k=="b"?k="(":k=="B"&&(k="{");var w=!c.textObjectInner,b,A;if(g[k]){if(A=!0,b=bl(a,f,k,w),!b){var M=a.getSearchCursor(new RegExp("\\"+k,"g"),f);M.find()&&(b=bl(a,M.from(),k,w))}}else if(v[k])A=!0,b=Cc(a,f,k,w);else if(k==="W"||k==="w")for(var L=c.repeat||1;L-- >0;){var D=es(a,{inclusive:w,innerWord:!w,bigWord:k==="W",noSymbol:k==="W",multiline:!0},b&&b.end);D&&(b||(b=D),b.end=D.end)}else if(k==="p")if(b=xl(a,f,c.repeat,0,w),c.linewise=!0,d.visualMode)d.visualLine||(d.visualLine=!0);else{var R=d.inputState.operatorArgs;R&&(R.linewise=!0),b.end.line--}else if(k==="t")b=vc(a,f,w);else if(k==="s"){var T=a.getLine(f.line);f.ch>0&&re(T[f.ch])&&(f.ch-=1);var E=wl(a,f,c.repeat,1,w),H=wl(a,f,c.repeat,-1,w);N(a.getLine(H.line)[H.ch])&&N(a.getLine(E.line)[E.ch-1])&&(H={line:H.line,ch:H.ch+1}),b={start:H,end:E}}return b?a.state.vim.visualMode?dc(a,b.start,b.end,A):[b.start,b.end]:null},repeatLastCharacterSearch:function(a,f,c){var d=z.lastCharacterSearch,g=c.repeat,v=c.forward===d.forward,k=(d.increment?1:0)*(v?-1:1);c.inclusive=!!v;var w=ts(a,g,v,d.selectedCharacter,Oe(f,0,-k));return w?(w.ch+=k,w):f}};function nc(a,f){Rt[a]=f}function hl(a,f){for(var c=[],d=0;d<f;d++)c.push(a);return c}var Qr={change:function(a,f,c){var d,g,v=a.state.vim,k=c[0].anchor,w=c[0].head;if(v.visualMode)if(f.fullLine)w.ch=Number.MAX_VALUE,w.line--,a.setSelection(k,w),g=a.getSelection(),a.replaceSelection(""),d=k;else{g=a.getSelection();var M=hl("",c.length);a.replaceSelections(M),d=et(c[0].head,c[0].anchor)}else{g=a.getRange(k,w);var b=v.lastEditInputState;if(b?.motion=="moveByWords"&&!N(g)){var A=/\s+$/.exec(g);A&&b.motionArgs&&b.motionArgs.forward&&(w=Oe(w,0,-A[0].length),g=g.slice(0,-A[0].length))}f.linewise&&(k=new e(k.line,It(a.getLine(k.line))),w.line>k.line&&(w=new e(w.line-1,Number.MAX_VALUE))),a.replaceRange("",k,w),d=k}z.registerController.pushText(f.registerName,"change",g,f.linewise,c.length>1),vi.enterInsertMode(a,{head:d},a.state.vim)},delete:function(a,f,c){var d,g,v=a.state.vim;if(v.visualBlock){g=a.getSelection();var b=hl("",c.length);a.replaceSelections(b),d=et(c[0].head,c[0].anchor)}else{var k=c[0].anchor,w=c[0].head;f.linewise&&w.line!=a.firstLine()&&k.line==a.lastLine()&&k.line==w.line-1&&(k.line==a.firstLine()?k.ch=0:k=new e(k.line-1,Je(a,k.line-1))),g=a.getRange(k,w),a.replaceRange("",k,w),d=k,f.linewise&&(d=Rt.moveToFirstNonWhiteSpaceCharacter(a,k))}return z.registerController.pushText(f.registerName,"delete",g,f.linewise,v.visualBlock),Ze(a,d)},indent:function(a,f,c){var d=a.state.vim,g=d.visualMode&&f.repeat||1;if(d.visualBlock){for(var v=a.getOption("tabSize"),k=a.getOption("indentWithTabs")?" ":" ".repeat(v),w,b=c.length-1;b>=0;b--)if(w=et(c[b].anchor,c[b].head),f.indentRight)a.replaceRange(k.repeat(g),w,w);else{for(var A=a.getLine(w.line),M=0,L=0;L<g;L++){var D=A[w.ch+M];if(D==" ")M++;else if(D==" "){M++;for(var R=1;R<k.length&&(D=A[w.ch+M],D===" ");R++)M++}else break}a.replaceRange("",w,Oe(w,0,M))}return w}else if(a.indentMore)for(var L=0;L<g;L++)f.indentRight?a.indentMore():a.indentLess();else{var T=c[0].anchor.line,E=d.visualBlock?c[c.length-1].anchor.line:c[0].head.line;f.linewise&&E--;for(var b=T;b<=E;b++)for(var L=0;L<g;L++)a.indentLine(b,f.indentRight)}return Rt.moveToFirstNonWhiteSpaceCharacter(a,c[0].anchor)},indentAuto:function(a,f,c){return a.execCommand("indentAuto"),Rt.moveToFirstNonWhiteSpaceCharacter(a,c[0].anchor)},hardWrap:function(a,f,c,d){if(a.hardWrap){var g=c[0].anchor.line,v=c[0].head.line;f.linewise&&v--;var k=a.hardWrap({from:g,to:v});return k>g&&f.linewise&&k--,f.keepCursor?d:new e(k,0)}},toggleComment:function(a,f,c,d,g){return a.execCommand("toggleLineComment"),g},changeCase:function(a,f,c,d,g){for(var v=a.getSelections(),k=[],w=f.toLower,b=0;b<v.length;b++){var A=v[b],M="";if(w===!0)M=A.toLowerCase();else if(w===!1)M=A.toUpperCase();else for(var L=0;L<A.length;L++){var D=A.charAt(L);M+=V(D)?D.toLowerCase():D.toUpperCase()}k.push(M)}return a.replaceSelections(k),f.shouldMoveCursor?g:!a.state.vim.visualMode&&f.linewise&&c[0].anchor.line+1==c[0].head.line?Rt.moveToFirstNonWhiteSpaceCharacter(a,d):f.linewise?d:et(c[0].anchor,c[0].head)},yank:function(a,f,c,d){var g=a.state.vim,v=a.getSelection(),k=g.visualMode?et(g.sel.anchor,g.sel.head,c[0].head,c[0].anchor):d;z.registerController.pushText(f.registerName,"yank",v,f.linewise,g.visualBlock);var w=Math.abs(a.getCursor("end").line-a.getCursor("start").line)||1;return he(a,w+" lines yanked"+(f.registerName?' into "'+f.registerName:""),!1,1500),k},rot13:function(a,f,c,d,g){for(var v=a.getSelections(),k=[],w=0;w<v.length;w++){const b=v[w].split("").map(A=>{const M=A.charCodeAt(0);return M>=65&&M<=90?String.fromCharCode(65+(M-65+13)%26):M>=97&&M<=122?String.fromCharCode(97+(M-97+13)%26):A}).join("");k.push(b)}return a.replaceSelections(k),f.shouldMoveCursor?g:!a.state.vim.visualMode&&f.linewise&&c[0].anchor.line+1==c[0].head.line?Rt.moveToFirstNonWhiteSpaceCharacter(a,d):f.linewise?d:et(c[0].anchor,c[0].head)}};function rc(a,f){Qr[a]=f}var vi={jumpListWalk:function(a,f,c){if(!c.visualMode){var d=f.repeat||1,g=f.forward,v=z.jumpList,k=v.move(a,g?d:-d),w=k?k.find():void 0;w=w||a.getCursor(),a.setCursor(w)}},scroll:function(a,f,c){if(!c.visualMode){var d=f.repeat||1,g=a.defaultTextHeight(),v=a.getScrollInfo().top,k=g*d,w=f.forward?v+k:v-k,b=be(a.getCursor()),A=a.charCoords(b,"local");if(f.forward)w>A.top?(b.line+=(w-A.top)/g,b.line=Math.ceil(b.line),a.setCursor(b),A=a.charCoords(b,"local"),a.scrollTo(null,A.top)):a.scrollTo(null,w);else{var M=w+a.getScrollInfo().clientHeight;M<A.bottom?(b.line-=(A.bottom-M)/g,b.line=Math.floor(b.line),a.setCursor(b),A=a.charCoords(b,"local"),a.scrollTo(null,A.bottom-a.getScrollInfo().clientHeight)):a.scrollTo(null,w)}}},scrollToCursor:function(a,f){var c=a.getCursor().line,d=a.charCoords(new e(c,0),"local"),g=a.getScrollInfo().clientHeight,v=d.top;switch(f.position){case"center":v=d.bottom-g/2;break;case"bottom":var k=new e(c,a.getLine(c).length-1),w=a.charCoords(k,"local"),b=w.bottom-v;v=v-g+b;break}a.scrollTo(null,v)},replayMacro:function(a,f,c){var d=f.selectedCharacter||"",g=f.repeat||1,v=z.macroModeState;for(d=="@"?d=v.latestRegister||"":v.latestRegister=d;g--;)Kc(a,c,v,d)},enterMacroRecordMode:function(a,f){var c=z.macroModeState,d=f.selectedCharacter;z.registerController.isValidRegister(d)&&c.enterMacroRecordMode(a,d)},toggleOverwrite:function(a){a.state.overwrite?(a.toggleOverwrite(!1),a.setOption("keyMap","vim-insert"),r.signal(a,"vim-mode-change",{mode:"insert"})):(a.toggleOverwrite(!0),a.setOption("keyMap","vim-replace"),r.signal(a,"vim-mode-change",{mode:"replace"}))},enterInsertMode:function(a,f,c){if(!a.getOption("readOnly")){c.insertMode=!0,c.insertModeRepeat=f&&f.repeat||1;var d=f?f.insertAt:null,g=c.sel,v=f.head||a.getCursor("head"),k=a.listSelections().length;if(d=="eol")v=new e(v.line,Je(a,v.line));else if(d=="bol")v=new e(v.line,0);else if(d=="charAfter"){var w=t(a,v,Oe(v,0,1));v=w.end}else if(d=="firstNonBlank"){var w=t(a,v,Rt.moveToFirstNonWhiteSpaceCharacter(a,v));v=w.end}else if(d=="startOfSelectedArea"){if(!c.visualMode)return;c.visualBlock?(v=new e(Math.min(g.head.line,g.anchor.line),Math.min(g.head.ch,g.anchor.ch)),k=Math.abs(g.head.line-g.anchor.line)+1):g.head.line<g.anchor.line?v=g.head:v=new e(g.anchor.line,0)}else if(d=="endOfSelectedArea"){if(!c.visualMode)return;c.visualBlock?(v=new e(Math.min(g.head.line,g.anchor.line),Math.max(g.head.ch,g.anchor.ch)+1),k=Math.abs(g.head.line-g.anchor.line)+1):g.head.line>=g.anchor.line?v=Oe(g.head,0,1):v=new e(g.anchor.line,0)}else if(d=="inplace"){if(c.visualMode)return}else d=="lastEdit"&&(v=Ll(a)||v);a.setOption("disableInput",!1),f&&f.replace?(a.toggleOverwrite(!0),a.setOption("keyMap","vim-replace"),r.signal(a,"vim-mode-change",{mode:"replace"})):(a.toggleOverwrite(!1),a.setOption("keyMap","vim-insert"),r.signal(a,"vim-mode-change",{mode:"insert"})),z.macroModeState.isPlaying||(a.on("change",Dl),c.insertEnd&&c.insertEnd.clear(),c.insertEnd=a.setBookmark(v,{insertLeft:!0}),r.on(a.getInputField(),"keydown",Il)),c.visualMode&&Et(a),dl(a,v,k)}},toggleVisualMode:function(a,f,c){var d=f.repeat,g=a.getCursor(),v;if(c.visualMode)c.visualLine!=!!f.linewise||c.visualBlock!=!!f.blockwise?(c.visualLine=!!f.linewise,c.visualBlock=!!f.blockwise,r.signal(a,"vim-mode-change",{mode:"visual",subMode:c.visualLine?"linewise":c.visualBlock?"blockwise":""}),Ei(a)):Et(a);else{c.visualMode=!0,c.visualLine=!!f.linewise,c.visualBlock=!!f.blockwise,v=Ze(a,new e(g.line,g.ch+d-1));var k=t(a,g,v);c.sel={anchor:k.start,head:k.end},r.signal(a,"vim-mode-change",{mode:"visual",subMode:c.visualLine?"linewise":c.visualBlock?"blockwise":""}),Ei(a),Ut(a,c,"<",et(g,v)),Ut(a,c,">",ti(g,v))}},reselectLastSelection:function(a,f,c){var d=c.lastSelection;if(c.visualMode&&pl(a,c),d){var g=d.anchorMark.find(),v=d.headMark.find();if(!g||!v)return;c.sel={anchor:g,head:v},c.visualMode=!0,c.visualLine=d.visualLine,c.visualBlock=d.visualBlock,Ei(a),Ut(a,c,"<",et(g,v)),Ut(a,c,">",ti(g,v)),r.signal(a,"vim-mode-change",{mode:"visual",subMode:c.visualLine?"linewise":c.visualBlock?"blockwise":""})}},joinLines:function(a,f,c){var d,g;if(c.visualMode){if(d=a.getCursor("anchor"),g=a.getCursor("head"),Me(g,d)){var v=g;g=d,d=v}g.ch=Je(a,g.line)-1}else{var k=Math.max(f.repeat,2);d=a.getCursor(),g=Ze(a,new e(d.line+k-1,1/0))}for(var w=0,b=d.line;b<g.line;b++){w=Je(a,d.line);var A="",M=0;if(!f.keepSpaces){var L=a.getLine(d.line+1);M=L.search(/\S/),M==-1?M=L.length:A=" "}a.replaceRange(A,new e(d.line,w),new e(d.line+1,M))}var D=Ze(a,new e(d.line,w));c.visualMode&&Et(a,!1),a.setCursor(D)},newLineAndEnterInsertMode:function(a,f,c){c.insertMode=!0;var d=be(a.getCursor());if(d.line===a.firstLine()&&!f.after)a.replaceRange(`
|
|
18
|
+
`)==-1?this.registers["-"]=new Dt(d,g):(this.shiftNumericRegisters_(),this.registers[1]=new Dt(d,g));break}this.unnamedRegister.setText(d,g,v);return}var w=V(f);w?k.pushText(d,g):k.setText(d,g,v),f==="+"&&navigator.clipboard.writeText(d),this.unnamedRegister.setText(k.toString(),g)}}getRegister(f){return this.isValidRegister(f)?(f=f.toLowerCase(),this.registers[f]||(this.registers[f]=new Dt),this.registers[f]):this.unnamedRegister}isValidRegister(f){return f&&(oe(f,C)||O.test(f))}shiftNumericRegisters_(){for(var f=9;f>=2;f--)this.registers[f]=this.getRegister(""+(f-1))}}class al{constructor(){this.historyBuffer=[],this.iterator=0,this.initialPrefix=null}nextMatch(f,c){var d=this.historyBuffer,g=c?-1:1;this.initialPrefix===null&&(this.initialPrefix=f);for(var v=this.iterator+g;c?v>=0:v<d.length;v+=g)for(var k=d[v],w=0;w<=k.length;w++)if(this.initialPrefix==k.substring(0,w))return this.iterator=v,k;if(v>=d.length)return this.iterator=d.length,this.initialPrefix;if(v<0)return f}pushInput(f){var c=this.historyBuffer.indexOf(f);c>-1&&this.historyBuffer.splice(c,1),f.length&&this.historyBuffer.push(f)}reset(){this.initialPrefix=null,this.iterator=this.historyBuffer.length}}var mi={matchCommand:function(a,f,c,d){var g=sc(a,f,d,c),v=g.full[0];if(!v)return g.partial.length?{type:"partial",expectLiteralNext:g.partial.length==1&&g.partial[0].keys.slice(-11)=="<character>"}:{type:"none"};if(v.keys.slice(-11)=="<character>"||v.keys.slice(-10)=="<register>"){var k=lc(a);if(!k||k.length>1)return{type:"clear"};c.selectedCharacter=k}return{type:"full",command:v}},processCommand:function(a,f,c){switch(f.inputState.repeatOverride=c.repeatOverride,c.type){case"motion":this.processMotion(a,f,c);break;case"operator":this.processOperator(a,f,c);break;case"operatorMotion":this.processOperatorMotion(a,f,c);break;case"action":this.processAction(a,f,c);break;case"search":this.processSearch(a,f,c);break;case"ex":case"keyToEx":this.processEx(a,f,c);break}},processMotion:function(a,f,c){f.inputState.motion=c.motion,f.inputState.motionArgs=zn(c.motionArgs),this.evalInput(a,f)},processOperator:function(a,f,c){var d=f.inputState;if(d.operator)if(d.operator==c.operator){d.motion="expandToLine",d.motionArgs={linewise:!0,repeat:1},this.evalInput(a,f);return}else Pe(a);d.operator=c.operator,d.operatorArgs=zn(c.operatorArgs),c.keys.length>1&&(d.operatorShortcut=c.keys),c.exitVisualBlock&&(f.visualBlock=!1,Ei(a)),f.visualMode&&this.evalInput(a,f)},processOperatorMotion:function(a,f,c){var d=f.visualMode,g=zn(c.operatorMotionArgs);g&&d&&g.visualLine&&(f.visualLine=!0),this.processOperator(a,f,c),d||this.processMotion(a,f,c)},processAction:function(a,f,c){var d=f.inputState,g=d.getRepeat(),v=!!g,k=zn(c.actionArgs)||{repeat:1};d.selectedCharacter&&(k.selectedCharacter=d.selectedCharacter),c.operator&&this.processOperator(a,f,c),c.motion&&this.processMotion(a,f,c),(c.motion||c.operator)&&this.evalInput(a,f),k.repeat=g||1,k.repeatIsExplicit=v,k.registerName=d.registerName,Pe(a),f.lastMotion=null,c.isEdit&&this.recordLastEdit(f,d,c),vi[c.action](a,k,f)},processSearch:function(a,f,c){if(!a.getSearchCursor)return;var d=c.searchArgs.forward,g=c.searchArgs.wholeWordOnly;St(a).setReversed(!d);var v=d?"/":"?",k=St(a).getQuery(),w=a.getScrollInfo(),b="";function A(q,U,X){z.searchHistoryController.pushInput(q),z.searchHistoryController.reset();try{an(a,q,U,X)}catch{he(a,"Invalid regex: "+q),Pe(a);return}mi.processMotion(a,f,{keys:"",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:c.searchArgs.toJumplist}})}function M(q){a.scrollTo(w.left,w.top),A(q,!0,!0);var U=z.macroModeState;U.isRecording&&$c(U,q)}function L(){return ee("pcre")?"(JavaScript regexp: set pcre)":"(Vim regexp: set nopcre)"}function D(q,U,X){var ie=ln(q),Le,Se;ie=="<Up>"||ie=="<Down>"?(Le=ie=="<Up>",Se=q.target?q.target.selectionEnd:0,U=z.searchHistoryController.nextMatch(U,Le)||"",X(U),Se&&q.target&&(q.target.selectionEnd=q.target.selectionStart=Math.min(Se,q.target.value.length))):ie&&ie!="<Left>"&&ie!="<Right>"&&z.searchHistoryController.reset(),b=U,R()}function R(){var q;try{q=an(a,b,!0,!0)}catch{}q?a.scrollIntoView(Ol(a,!d,q),30):(Ii(a),a.scrollTo(w.left,w.top))}function T(q,U,X){var ie=ln(q);ie=="<Esc>"||ie=="<C-c>"||ie=="<C-[>"||ie=="<BS>"&&U==""?(z.searchHistoryController.pushInput(U),z.searchHistoryController.reset(),an(a,k?.source||""),Ii(a),a.scrollTo(w.left,w.top),r.e_stop(q),Pe(a),X(),a.focus()):ie=="<Up>"||ie=="<Down>"?r.e_stop(q):ie=="<C-u>"&&(r.e_stop(q),X(""))}switch(c.searchArgs.querySrc){case"prompt":var E=z.macroModeState;if(E.isPlaying){let U=E.replaySearchQueries.shift();A(U||"",!0,!1)}else $n(a,{onClose:M,prefix:v,desc:Ct("span",{$cursor:"pointer",onmousedown:function(U){U.preventDefault(),Y("pcre",!ee("pcre")),this.textContent=L(),R()}},L()),onKeyUp:D,onKeyDown:T});break;case"wordUnderCursor":var H=ts(a,{noSymbol:!0}),J=!0;if(H||(H=ts(a,{noSymbol:!1}),J=!1),!H){he(a,"No word under cursor"),Pe(a);return}let q=a.getLine(H.start.line).substring(H.start.ch,H.end.ch);J&&g?q="\\b"+q+"\\b":q=ac(q),z.jumpList.cachedCursor=a.getCursor(),a.setCursor(H.start),A(q,!0,!1);break}},processEx:function(a,f,c){function d(b){z.exCommandHistoryController.pushInput(b),z.exCommandHistoryController.reset(),st.processCommand(a,b),a.state.vim&&Pe(a),Ii(a)}function g(b,A,M){var L=ln(b),D,R;(L=="<Esc>"||L=="<C-c>"||L=="<C-[>"||L=="<BS>"&&A=="")&&(z.exCommandHistoryController.pushInput(A),z.exCommandHistoryController.reset(),r.e_stop(b),Pe(a),Ii(a),M(),a.focus()),L=="<Up>"||L=="<Down>"?(r.e_stop(b),D=L=="<Up>",R=b.target?b.target.selectionEnd:0,A=z.exCommandHistoryController.nextMatch(A,D)||"",M(A),R&&b.target&&(b.target.selectionEnd=b.target.selectionStart=Math.min(R,b.target.value.length))):L=="<C-u>"?(r.e_stop(b),M("")):L&&L!="<Left>"&&L!="<Right>"&&z.exCommandHistoryController.reset()}function v(b,A){var M=new r.StringStream(A),L={};try{if(st.parseInput_(a,M,L),L.commandName!="s"){Ii(a);return}var D=st.matchCommand_(L.commandName);if(!D||(st.parseCommandArgs_(M,L,D),!L.argString))return;var R=Tl(L.argString.slice(1),!0,!0);R&&ns(a,R)}catch{}}if(c.type=="keyToEx")st.processCommand(a,c.exArgs.input);else{var k={onClose:d,onKeyDown:g,onKeyUp:v,prefix:":"};if(f.visualMode)k.value="'<,'>",k.selectValueOnOpen=!1;else{var w=f.inputState.getRepeat();w>1&&(k.value=".,.+"+(w-1),k.selectValueOnOpen=!1)}$n(a,k)}},evalInput:function(a,f){var c=f.inputState,d=c.motion,g=c.motionArgs||{repeat:1},v=c.operator,k=c.operatorArgs||{},w=c.registerName,b=f.sel,A=be(f.visualMode?Ze(a,b.head):a.getCursor("head")),M=be(f.visualMode?Ze(a,b.anchor):a.getCursor("anchor")),L=be(A),D=be(M),R,T,E;if(v&&this.recordLastEdit(f,c),c.repeatOverride!==void 0?E=c.repeatOverride:E=c.getRepeat(),E>0&&g.explicitRepeat?g.repeatIsExplicit=!0:(g.noRepeat||!g.explicitRepeat&&E===0)&&(E=1,g.repeatIsExplicit=!1),c.selectedCharacter&&(g.selectedCharacter=k.selectedCharacter=c.selectedCharacter),g.repeat=E,Pe(a),d){var H=Rt[d](a,A,g,f,c);if(f.lastMotion=Rt[d],!H)return;if(g.toJumplist){var J=z.jumpList,q=J.cachedCursor;q?(gl(a,q,H),delete J.cachedCursor):gl(a,A,H)}H instanceof Array?(T=H[0],R=H[1]):R=H,R||(R=be(A)),f.visualMode?(f.visualBlock&&R.ch===1/0||(R=Ze(a,R,L)),T&&(T=Ze(a,T)),T=T||D,b.anchor=T,b.head=R,Ei(a),Ut(a,f,"<",Me(T,R)?T:R),Ut(a,f,">",Me(T,R)?R:T)):v||(R=Ze(a,R,L),a.setCursor(R.line,R.ch))}if(v){if(k.lastSel){T=D;var U=k.lastSel,X=Math.abs(U.head.line-U.anchor.line),ie=Math.abs(U.head.ch-U.anchor.ch);U.visualLine?R=new e(D.line+X,D.ch):U.visualBlock?R=new e(D.line+X,D.ch+ie):U.head.line==U.anchor.line?R=new e(D.line,D.ch+ie):R=new e(D.line+X,D.ch),f.visualMode=!0,f.visualLine=U.visualLine,f.visualBlock=U.visualBlock,b=f.sel={anchor:T,head:R},Ei(a)}else f.visualMode&&(k.lastSel={anchor:be(b.anchor),head:be(b.head),visualBlock:f.visualBlock,visualLine:f.visualLine});var Le,Se,We,le,te;if(f.visualMode){Le=et(b.head,b.anchor),Se=ti(b.head,b.anchor),We=f.visualLine||k.linewise,le=f.visualBlock?"block":We?"line":"char";var ot=t(a,Le,Se);if(te=es(a,{anchor:ot.start,head:ot.end},le),We){var Ve=te.ranges;if(le=="block")for(var Ke=0;Ke<Ve.length;Ke++)Ve[Ke].head.ch=Je(a,Ve[Ke].head.line);else le=="line"&&(Ve[0].head=new e(Ve[0].head.line+1,0))}}else{if(Le=be(T||D),Se=be(R||L),Me(Se,Le)){var yi=Le;Le=Se,Se=yi}We=g.linewise||k.linewise,We?gc(a,Le,Se):g.forward&&pc(a,Le,Se),le="char";var ls=!g.inclusive||We,ot=t(a,Le,Se);te=es(a,{anchor:ot.start,head:ot.end},le,ls)}a.setSelections(te.ranges,te.primary),f.lastMotion=null,k.repeat=E,k.registerName=w,k.linewise=We;var as=Xr[v](a,k,te.ranges,D,R);f.visualMode&&Et(a,as!=null),as&&a.setCursor(as)}},recordLastEdit:function(a,f,c){var d=z.macroModeState;d.isPlaying||(a.lastEditInputState=f,a.lastEditActionCommand=c,d.lastInsertModeChanges.changes=[],d.lastInsertModeChanges.expectCursorActivityForChange=!1,d.lastInsertModeChanges.visualBlock=a.visualBlock?a.sel.head.line-a.sel.anchor.line:0)}},Rt={moveToTopLine:function(a,f,c){var d=rs(a).top+c.repeat-1;return new e(d,It(a.getLine(d)))},moveToMiddleLine:function(a){var f=rs(a),c=Math.floor((f.top+f.bottom)*.5);return new e(c,It(a.getLine(c)))},moveToBottomLine:function(a,f,c){var d=rs(a).bottom-c.repeat+1;return new e(d,It(a.getLine(d)))},expandToLine:function(a,f,c){var d=f;return new e(d.line+c.repeat-1,1/0)},findNext:function(a,f,c){var d=St(a),g=d.getQuery();if(g){var v=!c.forward;v=d.isReversed()?!v:v,ns(a,g);var k=Ol(a,v,g,c.repeat);return k||he(a,"No match found "+g+(ee("pcre")?" (set nopcre to use Vim regexps)":"")),k}},findAndSelectNextInclusive:function(a,f,c,d,g){var v=St(a),k=v.getQuery();if(k){var w=!c.forward;w=v.isReversed()?!w:w;var b=Ec(a,w,k,c.repeat,d);if(b){if(g.operator)return b;var A=b[0],M=new e(b[1].line,b[1].ch-1);if(d.visualMode){(d.visualLine||d.visualBlock)&&(d.visualLine=!1,d.visualBlock=!1,r.signal(a,"vim-mode-change",{mode:"visual",subMode:""}));var L=d.sel.anchor;if(L)return v.isReversed()?c.forward?[L,A]:[L,M]:c.forward?[L,M]:[L,A]}else d.visualMode=!0,d.visualLine=!1,d.visualBlock=!1,r.signal(a,"vim-mode-change",{mode:"visual",subMode:""});return w?[M,A]:[A,M]}}},goToMark:function(a,f,c,d){var g=_n(a,d,c.selectedCharacter||"");return g?c.linewise?{line:g.line,ch:It(a.getLine(g.line))}:g:null},moveToOtherHighlightedEnd:function(a,f,c,d){var g=d.sel;return d.visualBlock&&c.sameLine?[Ze(a,new e(g.anchor.line,g.head.ch)),Ze(a,new e(g.head.line,g.anchor.ch))]:[g.head,g.anchor]},jumpToMark:function(a,f,c,d){for(var g=f,v=0;v<c.repeat;v++){var k=g;for(var w in d.marks)if(P(w)){var b=d.marks[w].find(),A=c.forward?Me(b,k):Me(k,b);if(!A&&!(c.linewise&&b.line==k.line)){var M=pt(k,g),L=c.forward?ul(k,b,g):ul(g,b,k);(M||L)&&(g=b)}}}return c.linewise&&(g=new e(g.line,It(a.getLine(g.line)))),g},moveByCharacters:function(a,f,c){var d=f,g=c.repeat,v=c.forward?d.ch+g:d.ch-g;return new e(d.line,v)},moveByLines:function(a,f,c,d){var g=f,v=g.ch;switch(d.lastMotion){case this.moveByLines:case this.moveByDisplayLines:case this.moveByScroll:case this.moveToColumn:case this.moveToEol:v=d.lastHPos;break;default:d.lastHPos=v}var k=c.repeat+(c.repeatOffset||0),w=c.forward?g.line+k:g.line-k,b=a.firstLine(),A=a.lastLine(),M=a.findPosV(g,c.forward?k:-k,"line",d.lastHSPos),L=c.forward?M.line>w:M.line<w;return L&&(w=M.line,v=M.ch),w<b&&g.line==b?this.moveToStartOfLine(a,f,c,d):w>A&&g.line==A?kl(a,f,c,d,!0):(c.toFirstChar&&(v=It(a.getLine(w)),d.lastHPos=v),d.lastHSPos=a.charCoords(new e(w,v),"div").left,new e(w,v))},moveByDisplayLines:function(a,f,c,d){var g=f;switch(d.lastMotion){case this.moveByDisplayLines:case this.moveByScroll:case this.moveByLines:case this.moveToColumn:case this.moveToEol:break;default:d.lastHSPos=a.charCoords(g,"div").left}for(var v=Math.round(c.repeat),k=0;k<v;k++){var w=a.findPosV(g,c.forward?1:-1,"line",d.lastHSPos);if(w.hitSide)break;g=w}return g!=f&&(d.lastHPos=g.ch),g},moveByPage:function(a,f,c){var d=f,g=c.repeat;return a.findPosV(d,c.forward?g:-g,"page")},moveByParagraph:function(a,f,c){var d=c.forward?1:-1;return xl(a,f,c.repeat,d).start},moveBySentence:function(a,f,c){var d=c.forward?1:-1;return bc(a,f,c.repeat,d)},moveByScroll:function(a,f,c,d){var g=a.getScrollInfo(),v=null,k=c.repeat;k||(k=g.clientHeight/(2*a.defaultTextHeight()));var w=a.charCoords(f,"local");if(c.repeat=k,v=Rt.moveByDisplayLines(a,f,c,d),!v)return null;var b=a.charCoords(v,"local");return a.scrollTo(null,g.top+b.top-w.top),v},moveByWords:function(a,f,c){return kc(a,f,c.repeat,!!c.forward,!!c.wordEnd,!!c.bigWord)},moveTillCharacter:function(a,f,c){var d=c.repeat,g=is(a,d,c.forward,c.selectedCharacter,f),v=c.forward?-1:1;return ml(v,c),g?(g.ch+=v,g):null},moveToCharacter:function(a,f,c){var d=c.repeat;return ml(0,c),is(a,d,c.forward,c.selectedCharacter,f)||f},moveToSymbol:function(a,f,c){var d=c.repeat;return c.selectedCharacter&&yc(a,d,c.forward,c.selectedCharacter)||f},moveToColumn:function(a,f,c,d){var g=c.repeat;return d.lastHPos=g-1,d.lastHSPos=a.charCoords(f,"div").left,xc(a,g)},moveToEol:function(a,f,c,d){return kl(a,f,c,d,!1)},moveToFirstNonWhiteSpaceCharacter:function(a,f){var c=f;return new e(c.line,It(a.getLine(c.line)))},moveToMatchedSymbol:function(a,f){for(var c=f,d=c.line,g=c.ch,v=a.getLine(d),k;g<v.length;g++)if(k=v.charAt(g),k&&Q(k)){var w=a.getTokenTypeAt(new e(d,g+1));if(w!=="string"&&w!=="comment")break}if(g<v.length){var b=k==="<"||k===">"?/[(){}[\]<>]/:/[(){}[\]]/,A=a.findMatchingBracket(new e(d,g),{bracketRegex:b});return A.to}else return c},moveToStartOfLine:function(a,f){return new e(f.line,0)},moveToLineOrEdgeOfDocument:function(a,f,c){var d=c.forward?a.lastLine():a.firstLine();return c.repeatIsExplicit&&(d=c.repeat-a.getOption("firstLineNumber")),new e(d,It(a.getLine(d)))},moveToStartOfDisplayLine:function(a){return a.execCommand("goLineLeft"),a.getCursor()},moveToEndOfDisplayLine:function(a){a.execCommand("goLineRight");var f=a.getCursor();return f.sticky=="before"&&f.ch--,f},textObjectManipulation:function(a,f,c,d){var g={"(":")",")":"(","{":"}","}":"{","[":"]","]":"[","<":">",">":"<"},v={"'":!0,'"':!0,"`":!0},k=c.selectedCharacter||"";k=="b"?k="(":k=="B"&&(k="{");var w=!c.textObjectInner,b,A;if(g[k]){if(A=!0,b=bl(a,f,k,w),!b){var M=a.getSearchCursor(new RegExp("\\"+k,"g"),f);M.find()&&(b=bl(a,M.from(),k,w))}}else if(v[k])A=!0,b=Sc(a,f,k,w);else if(k==="W"||k==="w")for(var L=c.repeat||1;L-- >0;){var D=ts(a,{inclusive:w,innerWord:!w,bigWord:k==="W",noSymbol:k==="W",multiline:!0},b&&b.end);D&&(b||(b=D),b.end=D.end)}else if(k==="p")if(b=xl(a,f,c.repeat,0,w),c.linewise=!0,d.visualMode)d.visualLine||(d.visualLine=!0);else{var R=d.inputState.operatorArgs;R&&(R.linewise=!0),b.end.line--}else if(k==="t")b=mc(a,f,w);else if(k==="s"){var T=a.getLine(f.line);f.ch>0&&re(T[f.ch])&&(f.ch-=1);var E=wl(a,f,c.repeat,1,w),H=wl(a,f,c.repeat,-1,w);N(a.getLine(H.line)[H.ch])&&N(a.getLine(E.line)[E.ch-1])&&(H={line:H.line,ch:H.ch+1}),b={start:H,end:E}}return b?a.state.vim.visualMode?cc(a,b.start,b.end,A):[b.start,b.end]:null},repeatLastCharacterSearch:function(a,f,c){var d=z.lastCharacterSearch,g=c.repeat,v=c.forward===d.forward,k=(d.increment?1:0)*(v?-1:1);c.inclusive=!!v;var w=is(a,g,v,d.selectedCharacter,Oe(f,0,-k));return w?(w.ch+=k,w):f}};function ic(a,f){Rt[a]=f}function hl(a,f){for(var c=[],d=0;d<f;d++)c.push(a);return c}var Xr={change:function(a,f,c){var d,g,v=a.state.vim,k=c[0].anchor,w=c[0].head;if(v.visualMode)if(f.fullLine)w.ch=Number.MAX_VALUE,w.line--,a.setSelection(k,w),g=a.getSelection(),a.replaceSelection(""),d=k;else{g=a.getSelection();var M=hl("",c.length);a.replaceSelections(M),d=et(c[0].head,c[0].anchor)}else{g=a.getRange(k,w);var b=v.lastEditInputState;if(b?.motion=="moveByWords"&&!N(g)){var A=/\s+$/.exec(g);A&&b.motionArgs&&b.motionArgs.forward&&(w=Oe(w,0,-A[0].length),g=g.slice(0,-A[0].length))}f.linewise&&(k=new e(k.line,It(a.getLine(k.line))),w.line>k.line&&(w=new e(w.line-1,Number.MAX_VALUE))),a.replaceRange("",k,w),d=k}z.registerController.pushText(f.registerName,"change",g,f.linewise,c.length>1),vi.enterInsertMode(a,{head:d},a.state.vim)},delete:function(a,f,c){var d,g,v=a.state.vim;if(v.visualBlock){g=a.getSelection();var b=hl("",c.length);a.replaceSelections(b),d=et(c[0].head,c[0].anchor)}else{var k=c[0].anchor,w=c[0].head;f.linewise&&w.line!=a.firstLine()&&k.line==a.lastLine()&&k.line==w.line-1&&(k.line==a.firstLine()?k.ch=0:k=new e(k.line-1,Je(a,k.line-1))),g=a.getRange(k,w),a.replaceRange("",k,w),d=k,f.linewise&&(d=Rt.moveToFirstNonWhiteSpaceCharacter(a,k))}return z.registerController.pushText(f.registerName,"delete",g,f.linewise,v.visualBlock),Ze(a,d)},indent:function(a,f,c){var d=a.state.vim,g=d.visualMode&&f.repeat||1;if(d.visualBlock){for(var v=a.getOption("tabSize"),k=a.getOption("indentWithTabs")?" ":" ".repeat(v),w,b=c.length-1;b>=0;b--)if(w=et(c[b].anchor,c[b].head),f.indentRight)a.replaceRange(k.repeat(g),w,w);else{for(var A=a.getLine(w.line),M=0,L=0;L<g;L++){var D=A[w.ch+M];if(D==" ")M++;else if(D==" "){M++;for(var R=1;R<k.length&&(D=A[w.ch+M],D===" ");R++)M++}else break}a.replaceRange("",w,Oe(w,0,M))}return w}else if(a.indentMore)for(var L=0;L<g;L++)f.indentRight?a.indentMore():a.indentLess();else{var T=c[0].anchor.line,E=d.visualBlock?c[c.length-1].anchor.line:c[0].head.line;f.linewise&&E--;for(var b=T;b<=E;b++)for(var L=0;L<g;L++)a.indentLine(b,f.indentRight)}return Rt.moveToFirstNonWhiteSpaceCharacter(a,c[0].anchor)},indentAuto:function(a,f,c){return a.execCommand("indentAuto"),Rt.moveToFirstNonWhiteSpaceCharacter(a,c[0].anchor)},hardWrap:function(a,f,c,d){if(a.hardWrap){var g=c[0].anchor.line,v=c[0].head.line;f.linewise&&v--;var k=a.hardWrap({from:g,to:v});return k>g&&f.linewise&&k--,f.keepCursor?d:new e(k,0)}},toggleComment:function(a,f,c,d,g){return a.execCommand("toggleLineComment"),g},changeCase:function(a,f,c,d,g){for(var v=a.getSelections(),k=[],w=f.toLower,b=0;b<v.length;b++){var A=v[b],M="";if(w===!0)M=A.toLowerCase();else if(w===!1)M=A.toUpperCase();else for(var L=0;L<A.length;L++){var D=A.charAt(L);M+=V(D)?D.toLowerCase():D.toUpperCase()}k.push(M)}return a.replaceSelections(k),f.shouldMoveCursor?g:!a.state.vim.visualMode&&f.linewise&&c[0].anchor.line+1==c[0].head.line?Rt.moveToFirstNonWhiteSpaceCharacter(a,d):f.linewise?d:et(c[0].anchor,c[0].head)},yank:function(a,f,c,d){var g=a.state.vim,v=a.getSelection(),k=g.visualMode?et(g.sel.anchor,g.sel.head,c[0].head,c[0].anchor):d;z.registerController.pushText(f.registerName,"yank",v,f.linewise,g.visualBlock);var w=Math.abs(a.getCursor("end").line-a.getCursor("start").line)||1;return he(a,w+" lines yanked"+(f.registerName?' into "'+f.registerName:""),!1,1500),k},rot13:function(a,f,c,d,g){for(var v=a.getSelections(),k=[],w=0;w<v.length;w++){const b=v[w].split("").map(A=>{const M=A.charCodeAt(0);return M>=65&&M<=90?String.fromCharCode(65+(M-65+13)%26):M>=97&&M<=122?String.fromCharCode(97+(M-97+13)%26):A}).join("");k.push(b)}return a.replaceSelections(k),f.shouldMoveCursor?g:!a.state.vim.visualMode&&f.linewise&&c[0].anchor.line+1==c[0].head.line?Rt.moveToFirstNonWhiteSpaceCharacter(a,d):f.linewise?d:et(c[0].anchor,c[0].head)}};function nc(a,f){Xr[a]=f}var vi={jumpListWalk:function(a,f,c){if(!c.visualMode){var d=f.repeat||1,g=f.forward,v=z.jumpList,k=v.move(a,g?d:-d),w=k?k.find():void 0;w=w||a.getCursor(),a.setCursor(w)}},scroll:function(a,f,c){if(!c.visualMode){var d=f.repeat||1,g=a.defaultTextHeight(),v=a.getScrollInfo().top,k=g*d,w=f.forward?v+k:v-k,b=be(a.getCursor()),A=a.charCoords(b,"local");if(f.forward)w>A.top?(b.line+=(w-A.top)/g,b.line=Math.ceil(b.line),a.setCursor(b),A=a.charCoords(b,"local"),a.scrollTo(null,A.top)):a.scrollTo(null,w);else{var M=w+a.getScrollInfo().clientHeight;M<A.bottom?(b.line-=(A.bottom-M)/g,b.line=Math.floor(b.line),a.setCursor(b),A=a.charCoords(b,"local"),a.scrollTo(null,A.bottom-a.getScrollInfo().clientHeight)):a.scrollTo(null,w)}}},scrollToCursor:function(a,f){var c=a.getCursor().line,d=a.charCoords(new e(c,0),"local"),g=a.getScrollInfo().clientHeight,v=d.top;switch(f.position){case"center":v=d.bottom-g/2;break;case"bottom":var k=new e(c,a.getLine(c).length-1),w=a.charCoords(k,"local"),b=w.bottom-v;v=v-g+b;break}a.scrollTo(null,v)},replayMacro:function(a,f,c){var d=f.selectedCharacter||"",g=f.repeat||1,v=z.macroModeState;for(d=="@"?d=v.latestRegister||"":v.latestRegister=d;g--;)Vc(a,c,v,d)},enterMacroRecordMode:function(a,f){var c=z.macroModeState,d=f.selectedCharacter;z.registerController.isValidRegister(d)&&c.enterMacroRecordMode(a,d)},toggleOverwrite:function(a){a.state.overwrite?(a.toggleOverwrite(!1),a.setOption("keyMap","vim-insert"),r.signal(a,"vim-mode-change",{mode:"insert"})):(a.toggleOverwrite(!0),a.setOption("keyMap","vim-replace"),r.signal(a,"vim-mode-change",{mode:"replace"}))},enterInsertMode:function(a,f,c){if(!a.getOption("readOnly")){c.insertMode=!0,c.insertModeRepeat=f&&f.repeat||1;var d=f?f.insertAt:null,g=c.sel,v=f.head||a.getCursor("head"),k=a.listSelections().length;if(d=="eol")v=new e(v.line,Je(a,v.line));else if(d=="bol")v=new e(v.line,0);else if(d=="charAfter"){var w=t(a,v,Oe(v,0,1));v=w.end}else if(d=="firstNonBlank"){var w=t(a,v,Rt.moveToFirstNonWhiteSpaceCharacter(a,v));v=w.end}else if(d=="startOfSelectedArea"){if(!c.visualMode)return;c.visualBlock?(v=new e(Math.min(g.head.line,g.anchor.line),Math.min(g.head.ch,g.anchor.ch)),k=Math.abs(g.head.line-g.anchor.line)+1):g.head.line<g.anchor.line?v=g.head:v=new e(g.anchor.line,0)}else if(d=="endOfSelectedArea"){if(!c.visualMode)return;c.visualBlock?(v=new e(Math.min(g.head.line,g.anchor.line),Math.max(g.head.ch,g.anchor.ch)+1),k=Math.abs(g.head.line-g.anchor.line)+1):g.head.line>=g.anchor.line?v=Oe(g.head,0,1):v=new e(g.anchor.line,0)}else if(d=="inplace"){if(c.visualMode)return}else d=="lastEdit"&&(v=Ll(a)||v);a.setOption("disableInput",!1),f&&f.replace?(a.toggleOverwrite(!0),a.setOption("keyMap","vim-replace"),r.signal(a,"vim-mode-change",{mode:"replace"})):(a.toggleOverwrite(!1),a.setOption("keyMap","vim-insert"),r.signal(a,"vim-mode-change",{mode:"insert"})),z.macroModeState.isPlaying||(a.on("change",Dl),c.insertEnd&&c.insertEnd.clear(),c.insertEnd=a.setBookmark(v,{insertLeft:!0}),r.on(a.getInputField(),"keydown",Il)),c.visualMode&&Et(a),dl(a,v,k)}},toggleVisualMode:function(a,f,c){var d=f.repeat,g=a.getCursor(),v;if(c.visualMode)c.visualLine!=!!f.linewise||c.visualBlock!=!!f.blockwise?(c.visualLine=!!f.linewise,c.visualBlock=!!f.blockwise,r.signal(a,"vim-mode-change",{mode:"visual",subMode:c.visualLine?"linewise":c.visualBlock?"blockwise":""}),Ei(a)):Et(a);else{c.visualMode=!0,c.visualLine=!!f.linewise,c.visualBlock=!!f.blockwise,v=Ze(a,new e(g.line,g.ch+d-1));var k=t(a,g,v);c.sel={anchor:k.start,head:k.end},r.signal(a,"vim-mode-change",{mode:"visual",subMode:c.visualLine?"linewise":c.visualBlock?"blockwise":""}),Ei(a),Ut(a,c,"<",et(g,v)),Ut(a,c,">",ti(g,v))}},reselectLastSelection:function(a,f,c){var d=c.lastSelection;if(c.visualMode&&pl(a,c),d){var g=d.anchorMark.find(),v=d.headMark.find();if(!g||!v)return;c.sel={anchor:g,head:v},c.visualMode=!0,c.visualLine=d.visualLine,c.visualBlock=d.visualBlock,Ei(a),Ut(a,c,"<",et(g,v)),Ut(a,c,">",ti(g,v)),r.signal(a,"vim-mode-change",{mode:"visual",subMode:c.visualLine?"linewise":c.visualBlock?"blockwise":""})}},joinLines:function(a,f,c){var d,g;if(c.visualMode){if(d=a.getCursor("anchor"),g=a.getCursor("head"),Me(g,d)){var v=g;g=d,d=v}g.ch=Je(a,g.line)-1}else{var k=Math.max(f.repeat,2);d=a.getCursor(),g=Ze(a,new e(d.line+k-1,1/0))}for(var w=0,b=d.line;b<g.line;b++){w=Je(a,d.line);var A="",M=0;if(!f.keepSpaces){var L=a.getLine(d.line+1);M=L.search(/\S/),M==-1?M=L.length:A=" "}a.replaceRange(A,new e(d.line,w),new e(d.line+1,M))}var D=Ze(a,new e(d.line,w));c.visualMode&&Et(a,!1),a.setCursor(D)},newLineAndEnterInsertMode:function(a,f,c){c.insertMode=!0;var d=be(a.getCursor());if(d.line===a.firstLine()&&!f.after)a.replaceRange(`
|
|
18
19
|
`,new e(a.firstLine(),0)),a.setCursor(a.firstLine(),0);else{d.line=f.after?d.line:d.line-1,d.ch=Je(a,d.line),a.setCursor(d);var g=r.commands.newlineAndIndentContinueComment||r.commands.newlineAndIndent;g(a)}this.enterInsertMode(a,{repeat:f.repeat},c)},paste:function(a,f,c){var d=z.registerController.getRegister(f.registerName);if(f.registerName==="+")navigator.clipboard.readText().then(v=>{this.continuePaste(a,f,c,v,d)});else{var g=d.toString();this.continuePaste(a,f,c,g,d)}},continuePaste:function(a,f,c,d,g){var v=be(a.getCursor());if(d){if(f.matchIndent){var k=a.getOption("tabSize"),w=function(Ve){var Ke=Ve.split(" ").length-1,yi=Ve.split(" ").length-1;return Ke*k+yi*1},b=a.getLine(a.getCursor().line),A=w(b.match(/^\s*/)[0]),M=d.replace(/\n$/,""),L=d!==M,D=w(d.match(/^\s*/)[0]),d=M.replace(/^\s*/gm,function(Ve){var Ke=A+(w(Ve)-D);if(Ke<0)return"";if(a.getOption("indentWithTabs")){var yi=Math.floor(Ke/k);return Array(yi+1).join(" ")}else return Array(Ke+1).join(" ")});d+=L?`
|
|
19
20
|
`:""}f.repeat>1&&(d=Array(f.repeat+1).join(d));var R=f.linewise==null?g.linewise:f.linewise,T=g.blockwise,E=T?d.split(`
|
|
20
21
|
`):void 0;if(E){R&&E.pop();for(var H=0;H<E.length;H++)E[H]=E[H]==""?" ":E[H];v.ch+=f.after?1:0,v.ch=Math.min(Je(a,v.line),v.ch)}else R?c.visualMode?d=c.visualLine?d.slice(0,-1):`
|
|
21
22
|
`+d.slice(0,d.length-1)+`
|
|
22
23
|
`:f.after?(d=`
|
|
23
|
-
`+d.slice(0,d.length-1),v.ch=Je(a,v.line)):v.ch=0:v.ch+=f.after?1:0;var J;if(c.visualMode){c.lastPastedText=d;var q,U=
|
|
24
|
-
`,new e(le,0));var te=Je(a,le);te<v.ch&&
|
|
24
|
+
`+d.slice(0,d.length-1),v.ch=Je(a,v.line)):v.ch=0:v.ch+=f.after?1:0;var J;if(c.visualMode){c.lastPastedText=d;var q,U=uc(a),X=U[0],ie=U[1],Le=a.getSelection(),Se=a.listSelections(),We=new Array(Se.length).join("1").split("1");c.lastSelection&&(q=c.lastSelection.headMark.find()),z.registerController.unnamedRegister.setText(Le),T?(a.replaceSelections(We),ie=new e(X.line+d.length-1,X.ch),a.setCursor(X),cl(a,ie),a.replaceSelections(d),J=X):c.visualBlock?(a.replaceSelections(We),a.setCursor(X),a.replaceRange(d,X,X),J=X):(a.replaceRange(d,X,ie),J=a.posFromIndex(a.indexFromPos(X)+d.length-1)),q&&(c.lastSelection.headMark=a.setBookmark(q)),R&&(J.ch=0)}else if(T&&E){a.setCursor(v);for(var H=0;H<E.length;H++){var le=v.line+H;le>a.lastLine()&&a.replaceRange(`
|
|
25
|
+
`,new e(le,0));var te=Je(a,le);te<v.ch&&hc(a,le,v.ch)}a.setCursor(v),cl(a,new e(v.line+E.length-1,v.ch)),a.replaceSelections(E),J=v}else if(a.replaceRange(d,v),R){var le=f.after?v.line+1:v.line;J=new e(le,It(a.getLine(le)))}else J=be(v),/\n/.test(d)||(J.ch+=d.length-(f.after?1:0));c.visualMode&&Et(a,!1),a.setCursor(J)}},undo:function(a,f){a.operation(function(){fl(a,r.commands.undo,f.repeat)(),a.setCursor(Ze(a,a.getCursor("start")))})},redo:function(a,f){fl(a,r.commands.redo,f.repeat)()},setRegister:function(a,f,c){c.inputState.registerName=f.selectedCharacter},insertRegister:function(a,f,c){var d=f.selectedCharacter,g=z.registerController.getRegister(d),v=g&&g.toString();v&&a.replaceSelection(v)},oneNormalCommand:function(a,f,c){ii(a,!0),c.insertModeReturn=!0,r.on(a,"vim-command-done",function d(){c.visualMode||(c.insertModeReturn&&(c.insertModeReturn=!1,c.insertMode||vi.enterInsertMode(a,{},c)),r.off(a,"vim-command-done",d))})},setMark:function(a,f,c){var d=f.selectedCharacter;d&&Ut(a,c,d,a.getCursor())},replace:function(a,f,c){var d=f.selectedCharacter||"",g=a.getCursor(),v,k,w=a.listSelections();if(c.visualMode)g=a.getCursor("start"),k=a.getCursor("end");else{var b=a.getLine(g.line);v=g.ch+f.repeat,v>b.length&&(v=b.length),k=new e(g.line,v)}var A=t(a,g,k);if(g=A.start,k=A.end,d==`
|
|
25
26
|
`)c.visualMode||a.replaceRange("",g,k),(r.commands.newlineAndIndentContinueComment||r.commands.newlineAndIndent)(a);else{var M=a.getRange(g,k);if(M=M.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,d),M=M.replace(/[^\n]/g,d),c.visualBlock){var L=new Array(a.getOption("tabSize")+1).join(" ");M=a.getSelection(),M=M.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,d);var D=M.replace(/\t/g,L).replace(/[^\n]/g,d).split(`
|
|
26
|
-
`);a.replaceSelections(D)}else a.replaceRange(M,g,k);c.visualMode?(g=Me(w[0].anchor,w[0].head)?w[0].anchor:w[0].head,a.setCursor(g),Et(a,!1)):a.setCursor(Oe(k,0,-1))}},incrementNumberToken:function(a,f){for(var c=a.getCursor(),d=a.getLine(c.line),g=/(-?)(?:(0x)([\da-f]+)|(0b|0|)(\d+))/gi,v,k,w,b;(v=g.exec(d))!==null&&(k=v.index,w=k+v[0].length,!(c.ch<w)););if(!(!f.backtrack&&w<=c.ch)){if(v){var A=v[2]||v[4],M=v[3]||v[5],L=f.increase?1:-1,D={"0b":2,0:8,"":10,"0x":16}[A.toLowerCase()],R=parseInt(v[1]+M,D)+L*f.repeat;b=R.toString(D);var T=A?new Array(M.length-b.length+1+v[1].length).join("0"):"";b.charAt(0)==="-"?b="-"+A+T+b.substr(1):b=A+T+b;var E=new e(c.line,k),H=new e(c.line,w);a.replaceRange(b,E,H)}else return;a.setCursor(new e(c.line,k+b.length-1))}},repeatLastEdit:function(a,f,c){var d=c.lastEditInputState;if(d){var g=f.repeat;g&&f.repeatIsExplicit?d.repeatOverride=g:g=d.repeatOverride||g,Pl(a,c,g,!1)}},indent:function(a,f){a.indentLine(a.getCursor().line,f.indentRight)},exitInsertMode:function(a,f){ii(a)}};function
|
|
27
|
-
`;break;case"<Space>":case"<S-Space>":c=" ";break;default:c="";break}return c}function fl(a,f,c){return function(){for(var d=0;d<c;d++)f(a)}}function be(a){return new e(a.line,a.ch)}function pt(a,f){return a.ch==f.ch&&a.line==f.line}function Me(a,f){return a.line<f.line||a.line==f.line&&a.ch<f.ch}function et(a,f){return arguments.length>2&&(f=et.apply(void 0,Array.prototype.slice.call(arguments,1))),Me(a,f)?a:f}function ti(a,f){return arguments.length>2&&(f=ti.apply(void 0,Array.prototype.slice.call(arguments,1))),Me(a,f)?f:a}function ul(a,f,c){var d=Me(a,f),g=Me(f,c);return d&&g}function Je(a,f){return a.getLine(f).length}function
|
|
28
|
-
`);g.pop();for(var v=g.pop();g.length>0&&v&&N(v);v=g.pop())c.line--,c.ch=0;v?(c.line--,c.ch=Je(a,c.line)):c.ch=0}}function
|
|
29
|
-
`,"\\r":"\r","\\t":" "};function
|
|
30
|
-
`,"\\r":"\r","\\t":" ","\\&":"&"};function Bc(a){for(var f=new r.StringStream(a),c=[];!f.eol();){for(;f.peek()&&f.peek()!="\\";)c.push(f.next());var d=!1;for(var g in Ml)if(f.match(g,!0)){d=!0,c.push(Ml[g]);break}d||c.push(f.next())}return c.join("")}function Tl(a,f,c){var d=z.registerController.getRegister("/");d.setText(a);var g=Tc(a),v,k;if(!g.length)v=a;else{v=a.substring(0,g[0]);var w=a.substring(g[0]);k=w.indexOf("i")!=-1}if(!v)return null;ee("pcre")||(v=Oc(v)),c&&(f=/^[^A-Z]*$/.test(v));var b=new RegExp(v,f||k?"im":"m");return b}function Ct(a){typeof a=="string"&&(a=document.createElement(a));for(var f=1;f<arguments.length;f++){var c=arguments[f];if(c)if(typeof c!="object"&&(c=document.createTextNode(c)),c.nodeType)a.appendChild(c);else for(var d in c)Object.prototype.hasOwnProperty.call(c,d)&&(d[0]==="$"?a.style[d.slice(1)]=c[d]:typeof c[d]=="function"?a[d]=c[d]:a.setAttribute(d,c[d]))}return a}function he(a,f,c,d){var g=Ct("div",{$color:"red",$whiteSpace:"pre",class:"cm-vim-message"},f);a.openNotification?c?(g=Ct("div",{},g,Ct("div",{},"Press ENTER or type command to continue")),a.state.closeVimNotification&&a.state.closeVimNotification(),a.state.closeVimNotification=a.openNotification(g,{bottom:!0,duration:0})):a.openNotification(g,{bottom:!0,duration:d||15e3}):d||alert(g.innerText)}function Dc(a,f){return Ct("div",{$display:"flex",$flex:1},Ct("span",{$fontFamily:"monospace",$whiteSpace:"pre",$flex:1,$display:"flex"},a,Ct("input",{type:"text",autocorrect:"off",autocapitalize:"off",spellcheck:"false",$flex:1})),f&&Ct("span",{$color:"#888"},f))}function zn(a,f){if(He.length){f.value||(f.value=""),ve=f;return}var c=Dc(f.prefix,f.desc);if(a.openDialog)a.openDialog(c,f.onClose,{onKeyDown:f.onKeyDown,onKeyUp:f.onKeyUp,bottom:!0,selectValueOnOpen:!1,value:f.value});else{var d="";typeof f.prefix!="string"&&f.prefix&&(d+=f.prefix.textContent),f.desc&&(d+=" "+f.desc),f.onClose?.(prompt(d,""))}}function Rc(a,f){return a instanceof RegExp&&f instanceof RegExp?a.flags==f.flags&&a.source==f.source:!1}function an(a,f,c,d){if(f){var g=St(a),v=Tl(f,!!c,!!d);if(v)return is(a,v),Rc(v,g.getQuery())||g.setQuery(v),v}}function Ec(a){if(a.source.charAt(0)=="^")var f=!0;return{token:function(c){if(f&&!c.sol()){c.skipToEnd();return}var d=c.match(a,!1);if(d)return d[0].length==0?(c.next(),"searching"):!c.sol()&&(c.backUp(1),!a.exec(c.next()+d[0]))?(c.next(),null):(c.match(a),"searching");for(;!c.eol()&&(c.next(),!c.match(a,!1)););},query:a}}var hn=0;function is(a,f){clearTimeout(hn);var c=St(a);c.highlightTimeout=hn,hn=setTimeout(function(){if(a.state.vim){var d=St(a);d.highlightTimeout=void 0;var g=d.getOverlay();(!g||f!=g.query)&&(g&&a.removeOverlay(g),g=Ec(f),a.addOverlay(g),a.showMatchesOnScrollbar&&(d.getScrollbarAnnotate()&&d.getScrollbarAnnotate().clear(),d.setScrollbarAnnotate(a.showMatchesOnScrollbar(f))),d.setOverlay(g))}},50)}function Ol(a,f,c,d){return a.operation(function(){d===void 0&&(d=1);for(var g=a.getCursor(),v=a.getSearchCursor(c,g),k=0;k<d;k++){var w=v.find(f);if(k==0&&w&&pt(v.from(),g)){var b=f?v.from():v.to();w=v.find(f),w&&!w[0]&&pt(v.from(),b)&&a.getLine(b.line).length==b.ch&&(w=v.find(f))}if(!w&&(v=a.getSearchCursor(c,f?new e(a.lastLine()):new e(a.firstLine(),0)),!v.find(f)))return}return v.from()})}function Ic(a,f,c,d,g){return a.operation(function(){d===void 0&&(d=1);var v=a.getCursor(),k=a.getSearchCursor(c,v),w=k.find(!f);!g.visualMode&&w&&pt(k.from(),v)&&k.find(!f);for(var b=0;b<d;b++)if(w=k.find(f),!w&&(k=a.getSearchCursor(c,f?new e(a.lastLine()):new e(a.firstLine(),0)),!k.find(f)))return;var A=k.from(),M=k.to();return A&&M&&[A,M]})}function Ii(a){var f=St(a);f.highlightTimeout&&(clearTimeout(f.highlightTimeout),f.highlightTimeout=void 0),a.removeOverlay(St(a).getOverlay()),f.setOverlay(null),f.getScrollbarAnnotate()&&(f.getScrollbarAnnotate().clear(),f.setScrollbarAnnotate(null))}function Pc(a,f,c){return typeof a!="number"&&(a=a.line),f instanceof Array?oe(a,f):typeof c=="number"?a>=f&&a<=c:a==f}function ns(a){var f=a.getScrollInfo(),c=6,d=10,g=a.coordsChar({left:0,top:c+f.top},"local"),v=f.clientHeight-d+f.top,k=a.coordsChar({left:0,top:v},"local");return{top:g.line,bottom:k.line}}function $n(a,f,c){if(c=="'"||c=="`")return z.jumpList.find(a,-1)||new e(0,0);if(c==".")return Ll(a);var d=f.marks[c];return d&&d.find()}function Ll(a){if(a.getLastEditEnd)return a.getLastEditEnd();for(var f=a.doc.history.done,c=f.length;c--;)if(f[c].changes)return be(f[c].changes[0].to)}class Nc{constructor(){this.commandMap_,this.buildCommandMap_()}processCommand(f,c,d){var g=this;f.operation(function(){f.curOp&&(f.curOp.isVimOp=!0),g._processCommand(f,c,d)})}_processCommand(f,c,d){var g=f.state.vim,v=z.registerController.getRegister(":"),k=v.toString(),w=new r.StringStream(c);v.setText(c);var b=d||{};b.input=c;try{this.parseInput_(f,w,b)}catch(L){he(f,L+"");return}g.visualMode&&Et(f);var A,M;if(!b.commandName)b.line!==void 0&&(M="move");else if(A=this.matchCommand_(b.commandName),A){if(M=A.name,A.excludeFromCommandHistory&&v.setText(k),this.parseCommandArgs_(w,b,A),A.type=="exToKey"){ei(f,A.toKeys||"",A);return}else if(A.type=="exToEx"){this.processCommand(f,A.toInput||"");return}}if(!M){he(f,'Not an editor command ":'+c+'"');return}try{Bl[M](f,b),(!A||!A.possiblyAsync)&&b.callback&&b.callback()}catch(L){throw he(f,L+""),L}}parseInput_(f,c,d){if(c.eatWhile(":"),c.eat("%"))d.line=f.firstLine(),d.lineEnd=f.lastLine();else if(c.eat("*")){var g=f.state.vim.lastSelection,v=g?.anchorMark.find()?.line||0,k=g?.headMark.find()?.line||0;d.line=Math.max(v,k),d.lineEnd=Math.min(v,k)}else d.line=this.parseLineSpec_(f,c),d.line!==void 0&&c.eat(",")&&(d.lineEnd=this.parseLineSpec_(f,c));d.line==null?f.state.vim.visualMode?(d.selectionLine=$n(f,f.state.vim,"<")?.line,d.selectionLineEnd=$n(f,f.state.vim,">")?.line):d.selectionLine=f.getCursor().line:(d.selectionLine=d.line,d.selectionLineEnd=d.lineEnd),c.eatSpace();var w=c.match(/^(\w+|!!|@@|[!#&*<=>@~])/);return w?d.commandName=w[1]:d.commandName=(c.match(/.*/)||[""])[0],d}parseLineSpec_(f,c){var d=c.match(/^([\d]+)/);if(d)return this.parseLineSpecOffset_(f,c,parseInt(d[1],10)-1);switch(c.next()){case".":return this.parseLineSpecOffset_(f,c,f.getCursor().line);case"$":return this.parseLineSpecOffset_(f,c,f.lastLine());case"'":var g=c.next()||"",v=$n(f,f.state.vim,g);if(!v)throw new Error("Mark not set");return this.parseLineSpecOffset_(f,c,v.line);case"-":case"+":case"/":case"?":return c.backUp(1),this.parseLineSpecOffset_(f,c,f.getCursor().line);default:c.backUp(1);return}}parseLineSpecOffset_(f,c,d){for(;;){var g=c.match(/^([\/\?]|\\[\?\/])|([+-]?)(\d*)/);if(!g||!g[0])break;if(g[1]){var v="",k=!g[1].endsWith("?");if(g[1].length==1){var w=c.match(k?/^([^\/\\]|\\\/)*/:/^([^\/\?]|\\\?)*/);c.match(k?/^\/?/:/^\??/),v=w&&w[0]}v||(v=z.registerController.getRegister("/")?.toString()||"");var b=new RegExp(v),A=f.getSearchCursor(b,new e(d+(k?1:0),0));k?A.findNext():A.findPrevious();var M=A.from();if(!M)throw new Error("Pattern not found"+b);d=M.line}else{var L=parseInt(g[2]+(g[3]||"1"),10);d+=L}}return d}parseCommandArgs_(f,c,d){if(!f.eol()){c.argString=f.match(/.*/)?.[0];var g=d.argDelimiter||/\s+/,v=Xr(c.argString||"").split(g);v.length&&v[0]&&(c.args=v)}}matchCommand_(f){for(var c=f.length;c>0;c--){var d=f.substring(0,c);if(this.commandMap_[d]){var g=this.commandMap_[d];if(g.name.indexOf(f)===0)return g}}}buildCommandMap_(){this.commandMap_={};for(var f=0;f<o.length;f++){var c=o[f],d=c.shortName||c.name;this.commandMap_[d]=c}}map(f,c,d,g){if(f!=":"&&f.charAt(0)==":"){if(d)throw Error("Mode not supported for ex mappings");var v=f.substring(1);c!=":"&&c.charAt(0)==":"?this.commandMap_[v]={name:v,type:"exToEx",toInput:c.substring(1),user:!0}:this.commandMap_[v]={name:v,type:"exToKey",toKeys:c,user:!0}}else{var k={keys:f,type:"keyToKey",toKeys:c,noremap:!!g};d&&(k.context=d),rs(k)}}unmap(f,c){if(f!=":"&&f.charAt(0)==":"){if(c)throw Error("Mode not supported for ex mappings");var d=f.substring(1);if(this.commandMap_[d]&&this.commandMap_[d].user)return delete this.commandMap_[d],!0}else for(var g=f,v=0;v<i.length;v++)if(g==i[v].keys&&i[v].context===c)return i.splice(v,1),Wc(g),!0}}var Bl={colorscheme:function(a,f){if(!f.args||f.args.length<1){he(a,a.getOption("theme"));return}a.setOption("theme",f.args[0])},map:function(a,f,c,d){var g=f.args;if(!g||g.length<2){a&&he(a,"Invalid mapping: "+f.input);return}st.map(g[0],g[1],c,d)},imap:function(a,f){this.map(a,f,"insert")},nmap:function(a,f){this.map(a,f,"normal")},vmap:function(a,f){this.map(a,f,"visual")},omap:function(a,f){this.map(a,f,"operatorPending")},noremap:function(a,f){this.map(a,f,void 0,!0)},inoremap:function(a,f){this.map(a,f,"insert",!0)},nnoremap:function(a,f){this.map(a,f,"normal",!0)},vnoremap:function(a,f){this.map(a,f,"visual",!0)},onoremap:function(a,f){this.map(a,f,"operatorPending",!0)},unmap:function(a,f,c){var d=f.args;(!d||d.length<1||!st.unmap(d[0],c))&&a&&he(a,"No such mapping: "+f.input)},mapclear:function(a,f){xe.mapclear()},imapclear:function(a,f){xe.mapclear("insert")},nmapclear:function(a,f){xe.mapclear("normal")},vmapclear:function(a,f){xe.mapclear("visual")},omapclear:function(a,f){xe.mapclear("operatorPending")},move:function(a,f){mi.processCommand(a,a.state.vim,{keys:"",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0},repeatOverride:f.line+1})},set:function(a,f){var c=f.args,d=f.setCfg||{};if(!c||c.length<1){a&&he(a,"Invalid mapping: "+f.input);return}var g=c[0].split("="),v=g.shift()||"",k=g.length>0?g.join("="):void 0,w=!1,b=!1;if(v.charAt(v.length-1)=="?"){if(k)throw Error("Trailing characters: "+f.argString);v=v.substring(0,v.length-1),w=!0}else v.charAt(v.length-1)=="!"&&(v=v.substring(0,v.length-1),b=!0);k===void 0&&v.substring(0,2)=="no"&&(v=v.substring(2),k=!1);var A=ae[v]&&ae[v].type=="boolean";if(A&&(b?k=!ee(v,a,d):k==null&&(k=!0)),!A&&k===void 0||w){var M=ee(v,a,d);M instanceof Error?he(a,M.message):M===!0||M===!1?he(a," "+(M?"":"no")+v):he(a," "+v+"="+M)}else{var L=Y(v,k,a,d);L instanceof Error&&he(a,L.message)}},setlocal:function(a,f){f.setCfg={scope:"local"},this.set(a,f)},setglobal:function(a,f){f.setCfg={scope:"global"},this.set(a,f)},registers:function(a,f){var c=f.args,d=z.registerController.registers,g=`----------Registers----------
|
|
27
|
+
`);a.replaceSelections(D)}else a.replaceRange(M,g,k);c.visualMode?(g=Me(w[0].anchor,w[0].head)?w[0].anchor:w[0].head,a.setCursor(g),Et(a,!1)):a.setCursor(Oe(k,0,-1))}},incrementNumberToken:function(a,f){for(var c=a.getCursor(),d=a.getLine(c.line),g=/(-?)(?:(0x)([\da-f]+)|(0b|0|)(\d+))/gi,v,k,w,b;(v=g.exec(d))!==null&&(k=v.index,w=k+v[0].length,!(c.ch<w)););if(!(!f.backtrack&&w<=c.ch)){if(v){var A=v[2]||v[4],M=v[3]||v[5],L=f.increase?1:-1,D={"0b":2,0:8,"":10,"0x":16}[A.toLowerCase()],R=parseInt(v[1]+M,D)+L*f.repeat;b=R.toString(D);var T=A?new Array(M.length-b.length+1+v[1].length).join("0"):"";b.charAt(0)==="-"?b="-"+A+T+b.substr(1):b=A+T+b;var E=new e(c.line,k),H=new e(c.line,w);a.replaceRange(b,E,H)}else return;a.setCursor(new e(c.line,k+b.length-1))}},repeatLastEdit:function(a,f,c){var d=c.lastEditInputState;if(d){var g=f.repeat;g&&f.repeatIsExplicit?d.repeatOverride=g:g=d.repeatOverride||g,Pl(a,c,g,!1)}},indent:function(a,f){a.indentLine(a.getCursor().line,f.indentRight)},exitInsertMode:function(a,f){ii(a)}};function rc(a,f){vi[a]=f}function Ze(a,f,c){var d=a.state.vim,g=d.insertMode||d.visualMode,v=Math.min(Math.max(a.firstLine(),f.line),a.lastLine()),k=a.getLine(v),w=k.length-1+ +!!g,b=Math.min(Math.max(0,f.ch),w),A=k.charCodeAt(b);if(56320<=A&&A<=57343){var M=1;c&&c.line==v&&c.ch>b&&(M=-1),b+=M,b>w&&(b-=2)}return new e(v,b)}function zn(a){var f={};for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(f[c]=a[c]);return f}function Oe(a,f,c){return typeof f=="object"&&(c=f.ch,f=f.line),new e(a.line+f,a.ch+c)}function sc(a,f,c,d){d.operator&&(c="operatorPending");for(var g,v=[],k=[],w=dt?f.length-s:0,b=w;b<f.length;b++){var A=f[b];c=="insert"&&A.context!="insert"||A.context&&A.context!=c||d.operator&&A.type=="action"||!(g=oc(a,A.keys))||(g=="partial"&&v.push(A),g=="full"&&k.push(A))}return{partial:v,full:k}}function oc(a,f){const c=f.slice(-11)=="<character>",d=f.slice(-10)=="<register>";if(c||d){var g=f.length-(c?11:10),v=a.slice(0,g),k=f.slice(0,g);return v==k&&a.length>g?"full":k.indexOf(v)==0?"partial":!1}else return a==f?"full":f.indexOf(a)==0?"partial":!1}function lc(a){var f=/^.*(<[^>]+>)$/.exec(a),c=f?f[1]:a.slice(-1);if(c.length>1)switch(c){case"<CR>":case"<S-CR>":c=`
|
|
28
|
+
`;break;case"<Space>":case"<S-Space>":c=" ";break;default:c="";break}return c}function fl(a,f,c){return function(){for(var d=0;d<c;d++)f(a)}}function be(a){return new e(a.line,a.ch)}function pt(a,f){return a.ch==f.ch&&a.line==f.line}function Me(a,f){return a.line<f.line||a.line==f.line&&a.ch<f.ch}function et(a,f){return arguments.length>2&&(f=et.apply(void 0,Array.prototype.slice.call(arguments,1))),Me(a,f)?a:f}function ti(a,f){return arguments.length>2&&(f=ti.apply(void 0,Array.prototype.slice.call(arguments,1))),Me(a,f)?f:a}function ul(a,f,c){var d=Me(a,f),g=Me(f,c);return d&&g}function Je(a,f){return a.getLine(f).length}function Zr(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function ac(a){return a.replace(/([.?*+$\[\]\/\\(){}|\-])/g,"\\$1")}function hc(a,f,c){var d=Je(a,f),g=new Array(c-d+1).join(" ");a.setCursor(new e(f,d)),a.replaceRange(g,a.getCursor())}function cl(a,f){var c=[],d=a.listSelections(),g=be(a.clipPos(f)),v=!pt(f,g),k=a.getCursor("head"),w=fc(d,k),b=pt(d[w].head,d[w].anchor),A=d.length-1,M=A-w>w?A:0,L=d[M].anchor,D=Math.min(L.line,g.line),R=Math.max(L.line,g.line),T=L.ch,E=g.ch,H=d[M].head.ch-T,J=E-T;H>0&&J<=0?(T++,v||E--):H<0&&J>=0?(T--,b||E++):H<0&&J==-1&&(T--,E++);for(var q=D;q<=R;q++){var U={anchor:new e(q,T),head:new e(q,E)};c.push(U)}return a.setSelections(c),f.ch=E,L.ch=T,L}function dl(a,f,c){for(var d=[],g=0;g<c;g++){var v=Oe(f,g,0);d.push({anchor:v,head:v})}a.setSelections(d,0)}function fc(a,f,c){for(var d=0;d<a.length;d++){var g=pt(a[d].anchor,f),v=pt(a[d].head,f);if(g||v)return d}return-1}function uc(a,f){var c=a.listSelections(),d=c[0],g=c[c.length-1],v=Me(d.anchor,d.head)?d.anchor:d.head,k=Me(g.anchor,g.head)?g.head:g.anchor;return[v,k]}function pl(a,f){var c=f.sel.anchor,d=f.sel.head;f.lastPastedText&&(d=a.posFromIndex(a.indexFromPos(c)+f.lastPastedText.length),f.lastPastedText=void 0),f.lastSelection={anchorMark:a.setBookmark(c),headMark:a.setBookmark(d),anchor:be(c),head:be(d),visualMode:f.visualMode,visualLine:f.visualLine,visualBlock:f.visualBlock}}function cc(a,f,c,d){var g=a.state.vim.sel,v=d?f:g.head,k=d?f:g.anchor,w;return Me(c,f)&&(w=c,c=f,f=w),Me(v,k)?(v=et(f,v),k=ti(k,c)):(k=et(f,k),v=ti(v,c),v=Oe(v,0,-1),v.ch==-1&&v.line!=a.firstLine()&&(v=new e(v.line-1,Je(a,v.line-1)))),[k,v]}function Ei(a,f,c){var d=a.state.vim;f=f||d.sel,c||(c=d.visualLine?"line":d.visualBlock?"block":"char");var g=es(a,f,c);a.setSelections(g.ranges,g.primary)}function es(a,f,c,d){var g=be(f.head),v=be(f.anchor);if(c=="char"){var k=!d&&!Me(f.head,f.anchor)?1:0,w=Me(f.head,f.anchor)?1:0;return g=Oe(f.head,0,k),v=Oe(f.anchor,0,w),{ranges:[{anchor:v,head:g}],primary:0}}else if(c=="line"){if(Me(f.head,f.anchor))g.ch=0,v.ch=Je(a,v.line);else{v.ch=0;var b=a.lastLine();g.line>b&&(g.line=b),g.ch=Je(a,g.line)}return{ranges:[{anchor:v,head:g}],primary:0}}else if(c=="block"){var A=Math.min(v.line,g.line),M=v.ch,L=Math.max(v.line,g.line),D=g.ch;M<D?D+=1:M+=1;for(var R=L-A+1,T=g.line==A?0:R-1,E=[],H=0;H<R;H++)E.push({anchor:new e(A+H,M),head:new e(A+H,D)});return{ranges:E,primary:T}}throw"never happens"}function dc(a){var f=a.getCursor("head");return a.getSelection().length==1&&(f=et(f,a.getCursor("anchor"))),f}function Et(a,f){var c=a.state.vim;f!==!1&&a.setCursor(Ze(a,c.sel.head)),pl(a,c),c.visualMode=!1,c.visualLine=!1,c.visualBlock=!1,c.insertMode||r.signal(a,"vim-mode-change",{mode:"normal"})}function pc(a,f,c){var d=a.getRange(f,c);if(/\n\s*$/.test(d)){var g=d.split(`
|
|
29
|
+
`);g.pop();for(var v=g.pop();g.length>0&&v&&N(v);v=g.pop())c.line--,c.ch=0;v?(c.line--,c.ch=Je(a,c.line)):c.ch=0}}function gc(a,f,c){f.ch=0,c.ch=0,c.line++}function It(a){if(!a)return 0;var f=a.search(/\S/);return f==-1?a.length:f}function ts(a,{inclusive:f,innerWord:c,bigWord:d,noSymbol:g,multiline:v},k){var w=k||dc(a),b=a.getLine(w.line),A=b,M=w.line,L=M,D=w.ch,R,T=g?y[0]:x[0];if(c&&/\s/.test(b.charAt(D)))T=function(X){return/\s/.test(X)};else{for(;!T(b.charAt(D));)if(D++,D>=b.length){if(!v)return null;D--,R=yl(a,w,!0,d,!0);break}d?T=x[0]:(T=y[0],T(b.charAt(D))||(T=y[1]))}for(var E=D,H=D;T(b.charAt(H))&&H>=0;)H--;if(H++,R)E=R.to,L=R.line,A=a.getLine(L),!A&&E==0&&E++;else for(;T(b.charAt(E))&&E<b.length;)E++;if(f){var J=E,q=w.ch<=H&&/\s/.test(b.charAt(w.ch));if(!q)for(;/\s/.test(A.charAt(E))&&E<A.length;)E++;if(J==E||q){for(var U=H;/\s/.test(b.charAt(H-1))&&H>0;)H--;!H&&!q&&(H=U)}}return{start:new e(M,H),end:new e(L,E)}}function mc(a,f,c){var d=f;if(!r.findMatchingTag||!r.findEnclosingTag)return{start:d,end:d};var g=r.findMatchingTag(a,f)||r.findEnclosingTag(a,f);return!g||!g.open||!g.close?{start:d,end:d}:c?{start:g.open.from,end:g.close.to}:{start:g.open.to,end:g.close.from}}function gl(a,f,c){pt(f,c)||z.jumpList.add(a,f,c)}function ml(a,f){z.lastCharacterSearch.increment=a,z.lastCharacterSearch.forward=f.forward,z.lastCharacterSearch.selectedCharacter=f.selectedCharacter}var vc={"(":"bracket",")":"bracket","{":"bracket","}":"bracket","[":"section","]":"section","*":"comment","/":"comment",m:"method",M:"method","#":"preprocess"},vl={bracket:{isComplete:function(a){if(a.nextCh===a.symb){if(a.depth++,a.depth>=1)return!0}else a.nextCh===a.reverseSymb&&a.depth--;return!1}},section:{init:function(a){a.curMoveThrough=!0,a.symb=(a.forward?"]":"[")===a.symb?"{":"}"},isComplete:function(a){return a.index===0&&a.nextCh===a.symb}},comment:{isComplete:function(a){var f=a.lastCh==="*"&&a.nextCh==="/";return a.lastCh=a.nextCh,f}},method:{init:function(a){a.symb=a.symb==="m"?"{":"}",a.reverseSymb=a.symb==="{"?"}":"{"},isComplete:function(a){return a.nextCh===a.symb}},preprocess:{init:function(a){a.index=0},isComplete:function(a){if(a.nextCh==="#"){var f=a.lineText.match(/^#(\w+)/)?.[1];if(f==="endif"){if(a.forward&&a.depth===0)return!0;a.depth++}else if(f==="if"){if(!a.forward&&a.depth===0)return!0;a.depth--}if(f==="else"&&a.depth===0)return!0}return!1}}};function yc(a,f,c,d){var g=be(a.getCursor()),v=c?1:-1,k=c?a.lineCount():-1,w=g.ch,b=g.line,A=a.getLine(b),M={lineText:A,nextCh:A.charAt(w),lastCh:null,index:w,symb:d,reverseSymb:(c?{")":"(","}":"{"}:{"(":")","{":"}"})[d],forward:c,depth:0,curMoveThrough:!1},L=vc[d];if(!L)return g;var D=vl[L].init,R=vl[L].isComplete;for(D&&D(M);b!==k&&f;){if(M.index+=v,M.nextCh=M.lineText.charAt(M.index),!M.nextCh){if(b+=v,M.lineText=a.getLine(b)||"",v>0)M.index=0;else{var T=M.lineText.length;M.index=T>0?T-1:0}M.nextCh=M.lineText.charAt(M.index)}R(M)&&(g.line=b,g.ch=M.index,f--)}return M.nextCh||M.curMoveThrough?new e(b,M.index):g}function yl(a,f,c,d,g){var v=f.line,k=f.ch,w=a.getLine(v),b=c?1:-1,A=d?x:y;if(g&&w==""){if(v+=b,w=a.getLine(v),!F(a,v))return null;k=c?0:w.length}for(;;){if(g&&w=="")return{from:0,to:0,line:v};for(var M=b>0?w.length:-1,L=M,D=M;k!=M;){for(var R=!1,T=0;T<A.length&&!R;++T)if(A[T](w.charAt(k))){for(L=k;k!=M&&A[T](w.charAt(k));)k+=b;if(D=k,R=L!=D,L==f.ch&&v==f.line&&D==L+b)continue;return{from:Math.min(L,D+1),to:Math.max(L,D),line:v}}R||(k+=b)}if(v+=b,!F(a,v))return null;w=a.getLine(v),k=b>0?0:w.length}}function kc(a,f,c,d,g,v){var k=be(f),w=[];(d&&!g||!d&&g)&&c++;for(var b=!(d&&g),A=0;A<c;A++){var M=yl(a,f,d,v,b);if(!M){var L=Je(a,a.lastLine());w.push(d?{line:a.lastLine(),from:L,to:L}:{line:0,from:0,to:0});break}w.push(M),f=new e(M.line,d?M.to-1:M.from)}var D=w.length!=c,R=w[0],T=w.pop();return d&&!g?(!D&&(R.from!=k.ch||R.line!=k.line)&&(T=w.pop()),T&&new e(T.line,T.from)):d&&g?T&&new e(T.line,T.to-1):!d&&g?(!D&&(R.to!=k.ch||R.line!=k.line)&&(T=w.pop()),T&&new e(T.line,T.to)):T&&new e(T.line,T.from)}function kl(a,f,c,d,g){var v=f,k=new e(v.line+c.repeat-1,1/0),w=a.clipPos(k);return w.ch--,g||(d.lastHPos=1/0,d.lastHSPos=a.charCoords(w,"div").left),k}function is(a,f,c,d,g){if(d){for(var v=g||a.getCursor(),k=v.ch,w,b=0;b<f;b++){var A=a.getLine(v.line);if(w=wc(k,A,d,c),w==-1)return;k=w}if(w!=null)return new e(a.getCursor().line,w)}}function xc(a,f){var c=a.getCursor().line;return Ze(a,new e(c,f-1))}function Ut(a,f,c,d){!oe(c,S)&&!O.test(c)||(f.marks[c]&&f.marks[c].clear(),f.marks[c]=a.setBookmark(d))}function wc(a,f,c,d,g){var v;return d?v=f.indexOf(c,a+1):v=f.lastIndexOf(c,a-1),v}function xl(a,f,c,d,g){var v=f.line,k=a.firstLine(),w=a.lastLine(),b,A,M=v;function L(H){return!a.getLine(H)}function D(H,J,q){return q?L(H)!=L(H+J):!L(H)&&L(H+J)}if(d){for(;k<=M&&M<=w&&c>0;)D(M,d)&&c--,M+=d;return{start:new e(M,0),end:f}}var R=a.state.vim;if(R.visualLine&&D(v,1,!0)){var T=R.sel.anchor;D(T.line,-1,!0)&&(!g||T.line!=v)&&(v+=1)}var E=L(v);for(M=v;M<=w&&c;M++)D(M,1,!0)&&(!g||L(M)!=E)&&c--;for(A=new e(M,0),M>w&&!E?E=!0:g=!1,M=v;M>k&&!((!g||L(M)==E||M==v)&&D(M,-1,!0));M--);return b=new e(M,0),{start:b,end:A}}function wl(a,f,c,d,g){function v(A){A.line!==null&&(A.pos+A.dir<0||A.pos+A.dir>=A.line.length?A.line=null:A.pos+=A.dir)}function k(A,M,L,D){var R=A.getLine(M),T={line:R,ln:M,pos:L,dir:D};if(T.line==="")return{ln:T.ln,pos:T.pos};var E=T.pos;for(v(T);T.line!==null;){if(E=T.pos,re(T.line[T.pos]))if(g){for(v(T);T.line!==null&&N(T.line[T.pos]);)E=T.pos,v(T);return{ln:T.ln,pos:E+1}}else return{ln:T.ln,pos:T.pos+1};v(T)}return{ln:T.ln,pos:E+1}}function w(A,M,L,D){var R=A.getLine(M),T={line:R,ln:M,pos:L,dir:D};if(T.line==="")return{ln:T.ln,pos:T.pos};var E=T.pos;for(v(T);T.line!==null;){if(!N(T.line[T.pos])&&!re(T.line[T.pos]))E=T.pos;else if(re(T.line[T.pos]))return g?N(T.line[T.pos+1])?{ln:T.ln,pos:T.pos+1}:{ln:T.ln,pos:E}:{ln:T.ln,pos:E};v(T)}return T.line=R,g&&N(T.line[T.pos])?{ln:T.ln,pos:T.pos}:{ln:T.ln,pos:E}}for(var b={ln:f.line,pos:f.ch};c>0;)d<0?b=w(a,b.ln,b.pos,d):b=k(a,b.ln,b.pos,d),c--;return new e(b.ln,b.pos)}function bc(a,f,c,d){function g(b,A){if(A.line!==null)if(A.pos+A.dir<0||A.pos+A.dir>=A.line.length){if(A.ln+=A.dir,!F(b,A.ln)){A.line=null;return}A.line=b.getLine(A.ln),A.pos=A.dir>0?0:A.line.length-1}else A.pos+=A.dir}function v(b,A,M,L){var H=b.getLine(A),D=H==="",R={line:H,ln:A,pos:M,dir:L},T={ln:R.ln,pos:R.pos},E=R.line==="";for(g(b,R);R.line!==null;){if(T.ln=R.ln,T.pos=R.pos,R.line===""&&!E)return{ln:R.ln,pos:R.pos};if(D&&R.line!==""&&!N(R.line[R.pos]))return{ln:R.ln,pos:R.pos};re(R.line[R.pos])&&!D&&(R.pos===R.line.length-1||N(R.line[R.pos+1]))&&(D=!0),g(b,R)}var H=b.getLine(T.ln);T.pos=0;for(var J=H.length-1;J>=0;--J)if(!N(H[J])){T.pos=J;break}return T}function k(b,A,M,L){var H=b.getLine(A),D={line:H,ln:A,pos:M,dir:L},R=D.ln,T=null,E=D.line==="";for(g(b,D);D.line!==null;){if(D.line===""&&!E)return T!==null?{ln:R,pos:T}:{ln:D.ln,pos:D.pos};if(re(D.line[D.pos])&&T!==null&&!(D.ln===R&&D.pos+1===T))return{ln:R,pos:T};D.line!==""&&!N(D.line[D.pos])&&(E=!1,R=D.ln,T=D.pos),g(b,D)}var H=b.getLine(R);T=0;for(var J=0;J<H.length;++J)if(!N(H[J])){T=J;break}return{ln:R,pos:T}}for(var w={ln:f.line,pos:f.ch};c>0;)d<0?w=k(a,w.ln,w.pos,d):w=v(a,w.ln,w.pos,d),c--;return new e(w.ln,w.pos)}function bl(a,f,c,d){var g=f,v={"(":/[()]/,")":/[()]/,"[":/[[\]]/,"]":/[[\]]/,"{":/[{}]/,"}":/[{}]/,"<":/[<>]/,">":/[<>]/}[c],k={"(":"(",")":"(","[":"[","]":"[","{":"{","}":"{","<":"<",">":"<"}[c],w=a.getLine(g.line).charAt(g.ch),b=w===k?1:0,A=a.scanForBracket(new e(g.line,g.ch+b),-1,void 0,{bracketRegex:v}),M=a.scanForBracket(new e(g.line,g.ch+b),1,void 0,{bracketRegex:v});if(!A||!M)return null;var L=A.pos,D=M.pos;if(L.line==D.line&&L.ch>D.ch||L.line>D.line){var R=L;L=D,D=R}return d?D.ch+=1:L.ch+=1,{start:L,end:D}}function Sc(a,f,c,d){var g=be(f),v=a.getLine(g.line),k=v.split(""),w,b,A,M,L=k.indexOf(c);if(g.ch<L)g.ch=L;else if(L<g.ch&&k[g.ch]==c){var D=/string/.test(a.getTokenTypeAt(Oe(f,0,1))),R=/string/.test(a.getTokenTypeAt(f)),T=D&&!R;T||(b=g.ch,--g.ch)}if(k[g.ch]==c&&!b)w=g.ch+1;else for(A=g.ch;A>-1&&!w;A--)k[A]==c&&(w=A+1);if(w&&!b)for(A=w,M=k.length;A<M&&!b;A++)k[A]==c&&(b=A);return!w||!b?{start:g,end:g}:(d&&(--w,++b),{start:new e(g.line,w),end:new e(g.line,b)})}Z("pcre",!0,"boolean");class Cc{constructor(){this.highlightTimeout}getQuery(){return z.query}setQuery(f){z.query=f}getOverlay(){return this.searchOverlay}setOverlay(f){this.searchOverlay=f}isReversed(){return z.isReversed}setReversed(f){z.isReversed=f}getScrollbarAnnotate(){return this.annotate}setScrollbarAnnotate(f){this.annotate=f}}function St(a){var f=a.state.vim;return f.searchState_||(f.searchState_=new Cc)}function Ac(a){return Sl(a,"/")}function Mc(a){return Cl(a,"/")}function Sl(a,f){var c=Cl(a,f)||[];if(!c.length)return[];var d=[];if(c[0]===0){for(var g=0;g<c.length;g++)typeof c[g]=="number"&&d.push(a.substring(c[g]+1,c[g+1]));return d}}function Cl(a,f){f||(f="/");for(var c=!1,d=[],g=0;g<a.length;g++){var v=a.charAt(g);!c&&v==f&&d.push(g),c=!c&&v=="\\"}return d}function Tc(a){var f={V:"|(){+?*.[$^",M:"|(){+?*.[",m:"|(){+?",v:"<>"},c={">":"(?<=[\\w])(?=[^\\w]|$)","<":"(?<=[^\\w]|^)(?=[\\w])"},d=f.m,g=a.replace(/\\.|[\[|(){+*?.$^<>]/g,function(k){if(k[0]==="\\"){var w=k[1];return w==="}"||d.indexOf(w)!=-1?w:w in f?(d=f[w],""):w in c?c[w]:k}else return d.indexOf(k)!=-1?c[k]||"\\"+k:k}),v=g.indexOf("\\zs");return v!=-1&&(g="(?<="+g.slice(0,v)+")"+g.slice(v+3)),v=g.indexOf("\\ze"),v!=-1&&(g=g.slice(0,v)+"(?="+g.slice(v+3)+")"),g}var Al={"\\n":`
|
|
30
|
+
`,"\\r":"\r","\\t":" "};function Oc(a){for(var f=!1,c=[],d=-1;d<a.length;d++){var g=a.charAt(d)||"",v=a.charAt(d+1)||"";Al[g+v]?(c.push(Al[g+v]),d++):f?(c.push(g),f=!1):g==="\\"?(f=!0,W(v)||v==="$"?c.push("$"):v!=="/"&&v!=="\\"&&c.push("\\")):(g==="$"&&c.push("$"),c.push(g),v==="/"&&c.push("\\"))}return c.join("")}var Ml={"\\/":"/","\\\\":"\\","\\n":`
|
|
31
|
+
`,"\\r":"\r","\\t":" ","\\&":"&"};function Lc(a){for(var f=new r.StringStream(a),c=[];!f.eol();){for(;f.peek()&&f.peek()!="\\";)c.push(f.next());var d=!1;for(var g in Ml)if(f.match(g,!0)){d=!0,c.push(Ml[g]);break}d||c.push(f.next())}return c.join("")}function Tl(a,f,c){var d=z.registerController.getRegister("/");d.setText(a);var g=Mc(a),v,k;if(!g.length)v=a;else{v=a.substring(0,g[0]);var w=a.substring(g[0]);k=w.indexOf("i")!=-1}if(!v)return null;ee("pcre")||(v=Tc(v)),c&&(f=/^[^A-Z]*$/.test(v));var b=new RegExp(v,f||k?"im":"m");return b}function Ct(a){typeof a=="string"&&(a=document.createElement(a));for(var f=1;f<arguments.length;f++){var c=arguments[f];if(c)if(typeof c!="object"&&(c=document.createTextNode(c)),c.nodeType)a.appendChild(c);else for(var d in c)Object.prototype.hasOwnProperty.call(c,d)&&(d[0]==="$"?a.style[d.slice(1)]=c[d]:typeof c[d]=="function"?a[d]=c[d]:a.setAttribute(d,c[d]))}return a}function he(a,f,c,d){var g=Ct("div",{$color:"red",$whiteSpace:"pre",class:"cm-vim-message"},f);a.openNotification?c?(g=Ct("div",{},g,Ct("div",{},"Press ENTER or type command to continue")),a.state.closeVimNotification&&a.state.closeVimNotification(),a.state.closeVimNotification=a.openNotification(g,{bottom:!0,duration:0})):a.openNotification(g,{bottom:!0,duration:d||15e3}):d||alert(g.innerText)}function Bc(a,f){return Ct("div",{$display:"flex",$flex:1},Ct("span",{$fontFamily:"monospace",$whiteSpace:"pre",$flex:1,$display:"flex"},a,Ct("input",{type:"text",autocorrect:"off",autocapitalize:"off",spellcheck:"false",$flex:1})),f&&Ct("span",{$color:"#888"},f))}function $n(a,f){if(He.length){f.value||(f.value=""),ve=f;return}var c=Bc(f.prefix,f.desc);if(a.openDialog)a.openDialog(c,f.onClose,{onKeyDown:f.onKeyDown,onKeyUp:f.onKeyUp,bottom:!0,selectValueOnOpen:!1,value:f.value});else{var d="";typeof f.prefix!="string"&&f.prefix&&(d+=f.prefix.textContent),f.desc&&(d+=" "+f.desc),f.onClose?.(prompt(d,""))}}function Dc(a,f){return a instanceof RegExp&&f instanceof RegExp?a.flags==f.flags&&a.source==f.source:!1}function an(a,f,c,d){if(f){var g=St(a),v=Tl(f,!!c,!!d);if(v)return ns(a,v),Dc(v,g.getQuery())||g.setQuery(v),v}}function Rc(a){if(a.source.charAt(0)=="^")var f=!0;return{token:function(c){if(f&&!c.sol()){c.skipToEnd();return}var d=c.match(a,!1);if(d)return d[0].length==0?(c.next(),"searching"):!c.sol()&&(c.backUp(1),!a.exec(c.next()+d[0]))?(c.next(),null):(c.match(a),"searching");for(;!c.eol()&&(c.next(),!c.match(a,!1)););},query:a}}var hn=0;function ns(a,f){clearTimeout(hn);var c=St(a);c.highlightTimeout=hn,hn=setTimeout(function(){if(a.state.vim){var d=St(a);d.highlightTimeout=void 0;var g=d.getOverlay();(!g||f!=g.query)&&(g&&a.removeOverlay(g),g=Rc(f),a.addOverlay(g),a.showMatchesOnScrollbar&&(d.getScrollbarAnnotate()&&d.getScrollbarAnnotate().clear(),d.setScrollbarAnnotate(a.showMatchesOnScrollbar(f))),d.setOverlay(g))}},50)}function Ol(a,f,c,d){return a.operation(function(){d===void 0&&(d=1);for(var g=a.getCursor(),v=a.getSearchCursor(c,g),k=0;k<d;k++){var w=v.find(f);if(k==0&&w&&pt(v.from(),g)){var b=f?v.from():v.to();w=v.find(f),w&&!w[0]&&pt(v.from(),b)&&a.getLine(b.line).length==b.ch&&(w=v.find(f))}if(!w&&(v=a.getSearchCursor(c,f?new e(a.lastLine()):new e(a.firstLine(),0)),!v.find(f)))return}return v.from()})}function Ec(a,f,c,d,g){return a.operation(function(){d===void 0&&(d=1);var v=a.getCursor(),k=a.getSearchCursor(c,v),w=k.find(!f);!g.visualMode&&w&&pt(k.from(),v)&&k.find(!f);for(var b=0;b<d;b++)if(w=k.find(f),!w&&(k=a.getSearchCursor(c,f?new e(a.lastLine()):new e(a.firstLine(),0)),!k.find(f)))return;var A=k.from(),M=k.to();return A&&M&&[A,M]})}function Ii(a){var f=St(a);f.highlightTimeout&&(clearTimeout(f.highlightTimeout),f.highlightTimeout=void 0),a.removeOverlay(St(a).getOverlay()),f.setOverlay(null),f.getScrollbarAnnotate()&&(f.getScrollbarAnnotate().clear(),f.setScrollbarAnnotate(null))}function Ic(a,f,c){return typeof a!="number"&&(a=a.line),f instanceof Array?oe(a,f):typeof c=="number"?a>=f&&a<=c:a==f}function rs(a){var f=a.getScrollInfo(),c=6,d=10,g=a.coordsChar({left:0,top:c+f.top},"local"),v=f.clientHeight-d+f.top,k=a.coordsChar({left:0,top:v},"local");return{top:g.line,bottom:k.line}}function _n(a,f,c){if(c=="'"||c=="`")return z.jumpList.find(a,-1)||new e(0,0);if(c==".")return Ll(a);var d=f.marks[c];return d&&d.find()}function Ll(a){if(a.getLastEditEnd)return a.getLastEditEnd();for(var f=a.doc.history.done,c=f.length;c--;)if(f[c].changes)return be(f[c].changes[0].to)}class Pc{constructor(){this.commandMap_,this.buildCommandMap_()}processCommand(f,c,d){var g=this;f.operation(function(){f.curOp&&(f.curOp.isVimOp=!0),g._processCommand(f,c,d)})}_processCommand(f,c,d){var g=f.state.vim,v=z.registerController.getRegister(":"),k=v.toString(),w=new r.StringStream(c);v.setText(c);var b=d||{};b.input=c;try{this.parseInput_(f,w,b)}catch(L){he(f,L+"");return}g.visualMode&&Et(f);var A,M;if(!b.commandName)b.line!==void 0&&(M="move");else if(A=this.matchCommand_(b.commandName),A){if(M=A.name,A.excludeFromCommandHistory&&v.setText(k),this.parseCommandArgs_(w,b,A),A.type=="exToKey"){ei(f,A.toKeys||"",A);return}else if(A.type=="exToEx"){this.processCommand(f,A.toInput||"");return}}if(!M){he(f,'Not an editor command ":'+c+'"');return}try{Bl[M](f,b),(!A||!A.possiblyAsync)&&b.callback&&b.callback()}catch(L){throw he(f,L+""),L}}parseInput_(f,c,d){if(c.eatWhile(":"),c.eat("%"))d.line=f.firstLine(),d.lineEnd=f.lastLine();else if(c.eat("*")){var g=f.state.vim.lastSelection,v=g?.anchorMark.find()?.line||0,k=g?.headMark.find()?.line||0;d.line=Math.max(v,k),d.lineEnd=Math.min(v,k)}else d.line=this.parseLineSpec_(f,c),d.line!==void 0&&c.eat(",")&&(d.lineEnd=this.parseLineSpec_(f,c));d.line==null?f.state.vim.visualMode?(d.selectionLine=_n(f,f.state.vim,"<")?.line,d.selectionLineEnd=_n(f,f.state.vim,">")?.line):d.selectionLine=f.getCursor().line:(d.selectionLine=d.line,d.selectionLineEnd=d.lineEnd),c.eatSpace();var w=c.match(/^(\w+|!!|@@|[!#&*<=>@~])/);return w?d.commandName=w[1]:d.commandName=(c.match(/.*/)||[""])[0],d}parseLineSpec_(f,c){var d=c.match(/^([\d]+)/);if(d)return this.parseLineSpecOffset_(f,c,parseInt(d[1],10)-1);switch(c.next()){case".":return this.parseLineSpecOffset_(f,c,f.getCursor().line);case"$":return this.parseLineSpecOffset_(f,c,f.lastLine());case"'":var g=c.next()||"",v=_n(f,f.state.vim,g);if(!v)throw new Error("Mark not set");return this.parseLineSpecOffset_(f,c,v.line);case"-":case"+":case"/":case"?":return c.backUp(1),this.parseLineSpecOffset_(f,c,f.getCursor().line);default:c.backUp(1);return}}parseLineSpecOffset_(f,c,d){for(;;){var g=c.match(/^([\/\?]|\\[\?\/])|([+-]?)(\d*)/);if(!g||!g[0])break;if(g[1]){var v="",k=!g[1].endsWith("?");if(g[1].length==1){var w=c.match(k?/^([^\/\\]|\\\/)*/:/^([^\/\?]|\\\?)*/);c.match(k?/^\/?/:/^\??/),v=w&&w[0]}v||(v=z.registerController.getRegister("/")?.toString()||"");var b=new RegExp(v),A=f.getSearchCursor(b,new e(d+(k?1:0),0));k?A.findNext():A.findPrevious();var M=A.from();if(!M)throw new Error("Pattern not found"+b);d=M.line}else{var L=parseInt(g[2]+(g[3]||"1"),10);d+=L}}return d}parseCommandArgs_(f,c,d){if(!f.eol()){c.argString=f.match(/.*/)?.[0];var g=d.argDelimiter||/\s+/,v=Zr(c.argString||"").split(g);v.length&&v[0]&&(c.args=v)}}matchCommand_(f){for(var c=f.length;c>0;c--){var d=f.substring(0,c);if(this.commandMap_[d]){var g=this.commandMap_[d];if(g.name.indexOf(f)===0)return g}}}buildCommandMap_(){this.commandMap_={};for(var f=0;f<o.length;f++){var c=o[f],d=c.shortName||c.name;this.commandMap_[d]=c}}map(f,c,d,g){if(f!=":"&&f.charAt(0)==":"){if(d)throw Error("Mode not supported for ex mappings");var v=f.substring(1);c!=":"&&c.charAt(0)==":"?this.commandMap_[v]={name:v,type:"exToEx",toInput:c.substring(1),user:!0}:this.commandMap_[v]={name:v,type:"exToKey",toKeys:c,user:!0}}else{var k={keys:f,type:"keyToKey",toKeys:c,noremap:!!g};d&&(k.context=d),ss(k)}}unmap(f,c){if(f!=":"&&f.charAt(0)==":"){if(c)throw Error("Mode not supported for ex mappings");var d=f.substring(1);if(this.commandMap_[d]&&this.commandMap_[d].user)return delete this.commandMap_[d],!0}else for(var g=f,v=0;v<i.length;v++)if(g==i[v].keys&&i[v].context===c)return i.splice(v,1),Hc(g),!0}}var Bl={colorscheme:function(a,f){if(!f.args||f.args.length<1){he(a,a.getOption("theme"));return}a.setOption("theme",f.args[0])},map:function(a,f,c,d){var g=f.args;if(!g||g.length<2){a&&he(a,"Invalid mapping: "+f.input);return}st.map(g[0],g[1],c,d)},imap:function(a,f){this.map(a,f,"insert")},nmap:function(a,f){this.map(a,f,"normal")},vmap:function(a,f){this.map(a,f,"visual")},omap:function(a,f){this.map(a,f,"operatorPending")},noremap:function(a,f){this.map(a,f,void 0,!0)},inoremap:function(a,f){this.map(a,f,"insert",!0)},nnoremap:function(a,f){this.map(a,f,"normal",!0)},vnoremap:function(a,f){this.map(a,f,"visual",!0)},onoremap:function(a,f){this.map(a,f,"operatorPending",!0)},unmap:function(a,f,c){var d=f.args;(!d||d.length<1||!st.unmap(d[0],c))&&a&&he(a,"No such mapping: "+f.input)},mapclear:function(a,f){xe.mapclear()},imapclear:function(a,f){xe.mapclear("insert")},nmapclear:function(a,f){xe.mapclear("normal")},vmapclear:function(a,f){xe.mapclear("visual")},omapclear:function(a,f){xe.mapclear("operatorPending")},move:function(a,f){mi.processCommand(a,a.state.vim,{keys:"",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0},repeatOverride:f.line+1})},set:function(a,f){var c=f.args,d=f.setCfg||{};if(!c||c.length<1){a&&he(a,"Invalid mapping: "+f.input);return}var g=c[0].split("="),v=g.shift()||"",k=g.length>0?g.join("="):void 0,w=!1,b=!1;if(v.charAt(v.length-1)=="?"){if(k)throw Error("Trailing characters: "+f.argString);v=v.substring(0,v.length-1),w=!0}else v.charAt(v.length-1)=="!"&&(v=v.substring(0,v.length-1),b=!0);k===void 0&&v.substring(0,2)=="no"&&(v=v.substring(2),k=!1);var A=ae[v]&&ae[v].type=="boolean";if(A&&(b?k=!ee(v,a,d):k==null&&(k=!0)),!A&&k===void 0||w){var M=ee(v,a,d);M instanceof Error?he(a,M.message):M===!0||M===!1?he(a," "+(M?"":"no")+v):he(a," "+v+"="+M)}else{var L=Y(v,k,a,d);L instanceof Error&&he(a,L.message)}},setlocal:function(a,f){f.setCfg={scope:"local"},this.set(a,f)},setglobal:function(a,f){f.setCfg={scope:"global"},this.set(a,f)},registers:function(a,f){var c=f.args,d=z.registerController.registers,g=`----------Registers----------
|
|
31
32
|
|
|
32
33
|
`;if(c)for(var w=c.join(""),b=0;b<w.length;b++){var v=w.charAt(b);if(z.registerController.isValidRegister(v)){var A=d[v]||new Dt;g+='"'+v+" "+A.toString()+`
|
|
33
34
|
`}}else for(var v in d){var k=d[v].toString();k.length&&(g+='"'+v+" "+k+`
|
|
@@ -37,13 +38,13 @@ mark line col
|
|
|
37
38
|
`;if(c)for(var w=c.join(""),b=0;b<w.length;b++){var v=w.charAt(b),k=d[v]&&d[v].find();k&&(g+=v+" "+k.line+" "+k.ch+`
|
|
38
39
|
`)}else for(var v in d){var k=d[v]&&d[v].find();k&&(g+=v+" "+k.line+" "+k.ch+`
|
|
39
40
|
`)}he(a,g,!0)},sort:function(a,f){var c,d,g,v,k,w;function b(){if(f.argString){var le=new r.StringStream(f.argString);if(le.eat("!")&&(c=!0),le.eol())return;if(!le.eatSpace())return"Invalid arguments";var te=le.match(/([dinuoxr]+)?\s*(\/.+\/)?\s*/);if(!te||!le.eol())return"Invalid arguments";if(te[1]){w=te[1].indexOf("r")!=-1,d=te[1].indexOf("i")!=-1,g=te[1].indexOf("u")!=-1;var ot=te[1].indexOf("d")!=-1||te[1].indexOf("n")!=-1,Ve=te[1].indexOf("x")!=-1,Ke=te[1].indexOf("o")!=-1;if(Number(ot)+Number(Ve)+Number(Ke)>1)return"Invalid arguments";v=ot&&"decimal"||Ve&&"hex"||Ke&&"octal"}te[2]&&(k=new RegExp(te[2].substr(1,te[2].length-2),d?"i":""))}}var A=b();if(A){he(a,A+": "+f.argString);return}var M=f.line||a.firstLine(),L=f.lineEnd||f.line||a.lastLine();if(M==L)return;var D=new e(M,0),R=new e(L,Je(a,L)),T=a.getRange(D,R).split(`
|
|
40
|
-
`),E=v=="decimal"?/(-?)([\d]+)/:v=="hex"?/(-?)(?:0x)?([0-9a-f]+)/i:v=="octal"?/([0-7]+)/:null,H=v=="decimal"?10:v=="hex"?16:v=="octal"?8:void 0,J=[],q=[];if(v||k)for(var U=0;U<T.length;U++){var X=k?T[U].match(k):null;X&&X.index!=null&&!w&&(X[0]=T[U].slice(X.index+X[0].length)),X&&X[0]!=""?J.push(X):E&&E.exec(T[U])?J.push(T[U]):q.push(T[U])}else q=T;function ie(le,te){if(c){var ot;ot=le,le=te,te=ot}d&&(le=le.toLowerCase(),te=te.toLowerCase());var Ve=E&&E.exec(le),Ke=E&&E.exec(te);if(!Ve||!Ke)return le<te?-1:1;var yi=parseInt((Ve[1]+Ve[2]).toLowerCase(),H),
|
|
41
|
-
`),D,R)},vglobal:function(a,f){this.global(a,f)},normal:function(a,f){var c=!1,d=f.argString;if(d&&d[0]=="!"&&(d=d.slice(1),c=!0),d=d.trimStart(),!d){he(a,"Argument is required.");return}var g=f.line;if(typeof g=="number")for(var v=isNaN(f.lineEnd)?g:f.lineEnd,k=g;k<=v;k++)a.setCursor(k,0),ei(a,f.argString.trimStart(),{noremap:c}),a.state.vim.insertMode&&ii(a,!0);else ei(a,f.argString.trimStart(),{noremap:c}),a.state.vim.insertMode&&ii(a,!0)},global:function(a,f){var c=f.argString;if(!c){he(a,"Regular Expression missing from global");return}var d=f.commandName[0]==="v";c[0]==="!"&&f.commandName[0]==="g"&&(d=!0,c=c.slice(1));var g=f.line!==void 0?f.line:a.firstLine(),v=f.lineEnd||f.line||a.lastLine(),k=
|
|
42
|
-
`));return}var T=0,E=function(){if(T<M.length){var H=M[T++],J=a.getLineNumber(H);if(J==null){E();return}var q=J+1+b;st.processCommand(a,q,{callback:E})}else a.releaseLineHandles&&a.releaseLineHandles()};E()},substitute:function(a,f){if(!a.getSearchCursor)throw new Error("Search feature not available. Requires searchcursor.js or any other getSearchCursor implementation.");var c=f.argString,d=c?Sl(c,c[0]):[],g="",v="",k,w,b,A=!1,M=!1;if(d&&d.length)g=d[0],ee("pcre")&&g!==""&&(g=new RegExp(g).source),v=d[1],v!==void 0&&(ee("pcre")?v=
|
|
43
|
-
`);if(d.maybeReset&&(d.changes=[],d.maybeReset=!1),k)if(a.state.overwrite&&!/\n/.test(k))d.changes.push([k]);else{if(k.length>1){var w=g&&g.insertEnd&&g.insertEnd.find(),b=a.getCursor();if(w&&w.line==b.line){var A=w.ch-b.ch;A>0&&A<k.length&&(d.changes.push([k,A]),k="")}}k&&d.changes.push(k)}}f=f.next}}function Rl(a){var f=a.state.vim;if(f.insertMode){var c=z.macroModeState;if(c.isPlaying)return;var d=c.lastInsertModeChanges;d.expectCursorActivityForChange?d.expectCursorActivityForChange=!1:(d.maybeReset=!0,f.insertEnd&&f.insertEnd.clear(),f.insertEnd=a.setBookmark(a.getCursor(),{insertLeft:!0}))}else a.curOp?.isVimOp||El(a,f)}function El(a,f){var c=a.getCursor("anchor"),d=a.getCursor("head");if(f.visualMode&&!a.somethingSelected()?Et(a,!1):!f.visualMode&&!f.insertMode&&a.somethingSelected()&&(f.visualMode=!0,f.visualLine=!1,r.signal(a,"vim-mode-change",{mode:"visual"})),f.visualMode){var g=Me(d,c)?0:-1,v=Me(d,c)?-1:0;d=Oe(d,0,g),c=Oe(c,0,v),f.sel={anchor:c,head:d},Ut(a,f,"<",et(d,c)),Ut(a,f,">",ti(d,c))}else f.insertMode||(f.lastHPos=a.getCursor().ch)}function Il(a){var f=z.macroModeState,c=f.lastInsertModeChanges,d=r.keyName?r.keyName(a):a.key;d&&(d.indexOf("Delete")!=-1||d.indexOf("Backspace")!=-1)&&(c.maybeReset&&(c.changes=[],c.maybeReset=!1),c.changes.push(new Ue(d,a)))}function Pl(a,f,c,d){var g=z.macroModeState;g.isPlaying=!0;var v=f.lastEditActionCommand,k=f.inputState;function w(){v?mi.processAction(a,f,v):mi.evalInput(a,f)}function b(M){if(g.lastInsertModeChanges.changes.length>0){M=f.lastEditActionCommand?M:1;var L=g.lastInsertModeChanges;Fl(a,L.changes,M)}}if(f.inputState=f.lastEditInputState,v&&v.interlaceInsertRepeat)for(var A=0;A<c;A++)w(),b(1);else d||w(),b(c);f.inputState=k,f.insertMode&&!d&&ii(a),g.isPlaying=!1}function Nl(a,f){r.lookupKey(f,"vim-insert",function(d){return typeof d=="string"?r.commands[d](a):d(a),!0})}function Fl(a,f,c){var d=a.getCursor("head"),g=z.macroModeState.lastInsertModeChanges.visualBlock;g&&(dl(a,d,g+1),c=a.listSelections().length,a.setCursor(d));for(var v=0;v<c;v++){g&&a.setCursor(Oe(d,v,0));for(var k=0;k<f.length;k++){var w=f[k];if(w instanceof Ue)Nl(a,w.keyName);else if(typeof w=="string")a.replaceSelection(w);else{var b=a.getCursor(),A=Oe(b,0,w[0].length-(w[1]||0));a.replaceRange(w[0],b,w[1]?b:A),a.setCursor(A)}}}g&&a.setCursor(Oe(d,0,1))}function
|
|
44
|
-
`:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new
|
|
45
|
-
`)}getSelections(){var e=this.cm6;return e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to))}somethingSelected(){return this.cm6.state.selection.ranges.some(e=>!e.empty)}getInputField(){return this.cm6.contentDOM}clipPos(e){var t=this.cm6.state.doc,i=e.ch,n=e.line+1;n<1&&(n=1,i=0),n>t.lines&&(n=t.lines,i=Number.MAX_VALUE);var s=t.line(n);return i=Math.min(Math.max(0,i),s.to-s.from),new Wt(n-1,i)}getValue(){return this.cm6.state.doc.toString()}setValue(e){var t=this.cm6;return t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e},selection:I.range(0,0)})}focus(){return this.cm6.focus()}blur(){return this.cm6.contentDOM.blur()}defaultTextHeight(){return this.cm6.defaultLineHeight}findMatchingBracket(e,t){var i=this.cm6.state,n=ft(i.doc,e),s=ai(i,n+1,-1);return s&&s.end?{to:gt(i.doc,s.end.from)}:(s=ai(i,n,1),s&&s.end?{to:gt(i.doc,s.end.from)}:{to:void 0})}scanForBracket(e,t,i,n){return
|
|
46
|
-
|
|
47
|
-
`+u,new Wt(s,h.start),new Wt(s,h.end))}o++}else if(n&&/\S/.test(l)&&s!=o){var p=r.getLine(s+1);if(p&&/\S/.test(p)){var m=l.replace(/\s+$/,""),y=p.replace(/^\s+/,""),x=m+" "+y,h=S(x,i,5);h&&h.start>m.length||x.length<i?(r.replaceRange(" ",new Wt(s,m.length),new Wt(s+1,p.length-y.length)),s--,o--):m.length<l.length&&r.replaceRange("",new Wt(s,m.length),new Wt(s,l.length))}}s++}return s;function S(C,O,B){if(!(C.length<O)){var F=C.slice(0,O),P=C.slice(O),Q=/^(?:(\s+)|(\S+)(\s+))/.exec(P),W=/(?:(\s+)|(\s+)(\S+))$/.exec(F),V=0,N=0;if(W&&!W[2]&&(V=O-W[1].length,N=O),Q&&!Q[2]&&(V||(V=O),N=O+Q[1].length),V)return{start:V,end:N};if(W&&W[2]&&W.index>B)return{start:W.index,end:W.index+W[2].length};if(Q&&Q[2])return V=O+Q[2].length,{start:V,end:V+Q[3].length}}}}let Co=
|
|
48
|
-
`&&h--,r.state.overwrite?p=.2:m.status&&(p=.5)}if(u){let x=h<e.state.doc.length&&e.state.sliceDoc(h,h+1);x&&/[\uDC00-\uDFFF]/.test(x)&&h>1&&(h--,x=e.state.sliceDoc(h,h+1));let S=e.coordsAtPos(h,1);if(!S)return null;let C=
|
|
49
|
-
`||x=="\r")x=" ";else if(x==" "){x=" ";var y=e.coordsAtPos(h+1,-1);y&&(P=y.left-(y.left-S.left)/parseInt(F.tabSize))}else/[\uD800-\uDBFF]/.test(x)&&h<e.state.doc.length-1&&(x+=e.state.sliceDoc(h+1,h+2));let W=S.bottom-S.top;return new
|
|
41
|
+
`),E=v=="decimal"?/(-?)([\d]+)/:v=="hex"?/(-?)(?:0x)?([0-9a-f]+)/i:v=="octal"?/([0-7]+)/:null,H=v=="decimal"?10:v=="hex"?16:v=="octal"?8:void 0,J=[],q=[];if(v||k)for(var U=0;U<T.length;U++){var X=k?T[U].match(k):null;X&&X.index!=null&&!w&&(X[0]=T[U].slice(X.index+X[0].length)),X&&X[0]!=""?J.push(X):E&&E.exec(T[U])?J.push(T[U]):q.push(T[U])}else q=T;function ie(le,te){if(c){var ot;ot=le,le=te,te=ot}d&&(le=le.toLowerCase(),te=te.toLowerCase());var Ve=E&&E.exec(le),Ke=E&&E.exec(te);if(!Ve||!Ke)return le<te?-1:1;var yi=parseInt((Ve[1]+Ve[2]).toLowerCase(),H),ls=parseInt((Ke[1]+Ke[2]).toLowerCase(),H);return yi-ls}function Le(le,te){if(c){var ot;ot=le,le=te,te=ot}return d&&(le[0]=le[0].toLowerCase(),te[0]=te[0].toLowerCase()),le[0]<te[0]?-1:1}if(J.sort(k?Le:ie),k)for(var U=0;U<J.length;U++)J[U]=J[U].input;else v||q.sort(ie);if(T=c?J.concat(q):q.concat(J),g){var Se=T,We;T=[];for(var U=0;U<Se.length;U++)Se[U]!=We&&T.push(Se[U]),We=Se[U]}a.replaceRange(T.join(`
|
|
42
|
+
`),D,R)},vglobal:function(a,f){this.global(a,f)},normal:function(a,f){var c=!1,d=f.argString;if(d&&d[0]=="!"&&(d=d.slice(1),c=!0),d=d.trimStart(),!d){he(a,"Argument is required.");return}var g=f.line;if(typeof g=="number")for(var v=isNaN(f.lineEnd)?g:f.lineEnd,k=g;k<=v;k++)a.setCursor(k,0),ei(a,f.argString.trimStart(),{noremap:c}),a.state.vim.insertMode&&ii(a,!0);else ei(a,f.argString.trimStart(),{noremap:c}),a.state.vim.insertMode&&ii(a,!0)},global:function(a,f){var c=f.argString;if(!c){he(a,"Regular Expression missing from global");return}var d=f.commandName[0]==="v";c[0]==="!"&&f.commandName[0]==="g"&&(d=!0,c=c.slice(1));var g=f.line!==void 0?f.line:a.firstLine(),v=f.lineEnd||f.line||a.lastLine(),k=Ac(c),w=c,b="";if(k&&k.length&&(w=k[0],b=k.slice(1,k.length).join("/")),w)try{an(a,w,!0,!0)}catch{he(a,"Invalid regex: "+w);return}for(var A=St(a).getQuery(),M=[],L=g;L<=v;L++){var D=a.getLine(L),R=A.test(D);R!==d&&M.push(b?a.getLineHandle(L):D)}if(!b){he(a,M.join(`
|
|
43
|
+
`));return}var T=0,E=function(){if(T<M.length){var H=M[T++],J=a.getLineNumber(H);if(J==null){E();return}var q=J+1+b;st.processCommand(a,q,{callback:E})}else a.releaseLineHandles&&a.releaseLineHandles()};E()},substitute:function(a,f){if(!a.getSearchCursor)throw new Error("Search feature not available. Requires searchcursor.js or any other getSearchCursor implementation.");var c=f.argString,d=c?Sl(c,c[0]):[],g="",v="",k,w,b,A=!1,M=!1;if(d&&d.length)g=d[0],ee("pcre")&&g!==""&&(g=new RegExp(g).source),v=d[1],v!==void 0&&(ee("pcre")?v=Lc(v.replace(/([^\\])&/g,"$1$$&")):v=Oc(v),z.lastSubstituteReplacePart=v),k=d[2]?d[2].split(" "):[];else if(c&&c.length){he(a,"Substitutions should be of the form :s/pattern/replace/");return}if(k&&(w=k[0],b=parseInt(k[1]),w&&(w.indexOf("c")!=-1&&(A=!0),w.indexOf("g")!=-1&&(M=!0),ee("pcre")?g=g+"/"+w:g=g.replace(/\//g,"\\/")+"/"+w)),g)try{an(a,g,!0,!0)}catch{he(a,"Invalid regex: "+g);return}if(v=v||z.lastSubstituteReplacePart,v===void 0){he(a,"No previous substitute regular expression");return}var L=St(a),D=L.getQuery(),R=f.line!==void 0?f.line:a.getCursor().line,T=f.lineEnd||R;R==a.firstLine()&&T==a.lastLine()&&(T=1/0),b&&(R=T,T=R+b-1);var E=Ze(a,new e(R,0)),H=a.getSearchCursor(D,E);Nc(a,A,M,R,T,H,D,v,f.callback)},startinsert:function(a,f){ei(a,f.argString=="!"?"A":"i",{})},redo:r.commands.redo,undo:r.commands.undo,write:function(a){r.commands.save?r.commands.save(a):a.save&&a.save()},nohlsearch:function(a){Ii(a)},yank:function(a,f){var c=f.selectionLine,d=isNaN(f.selectionLineEnd)?c:f.selectionLineEnd;if(d<c){var g=d;d=c,c=g}var v=a.getRange(new e(c,0),new e(d+1,0)),k=f.args&&f.args[0]?f.args[0]:"0";z.registerController.pushText(k,"yank",v,!0,!1),he(a,d+1-c+" lines yanked"+(k?' into "'+k:""),!1,1500)},put:function(a,f,c){var d={after:!0,isEdit:!0,matchIndent:!!c,repeat:1,lineWise:!0,registerName:""},g=f.args||[];g[0]=="!"&&(d.after=!1,g.shift()),g[0]&&(d.registerName=g[0]);var v=f.selectionLine;v!=null&&a.setCursor(new e(v,0)),vi.paste(a,d,a.state.vim)},iput:function(a,f){this.put(a,f,!0)},delete:function(a,f){var c=f.selectionLine,d=isNaN(f.selectionLineEnd)?c:f.selectionLineEnd;Xr.delete(a,{linewise:!0},[{anchor:new e(c,0),head:new e(d+1,0)}])},join:function(a,f){var c=f.selectionLine,d=isNaN(f.selectionLineEnd)?c:f.selectionLineEnd;a.setCursor(new e(c,0)),vi.joinLines(a,{repeat:d-c},a.state.vim)},delmarks:function(a,f){if(!f.argString||!Zr(f.argString)){he(a,"Argument required");return}for(var c=a.state.vim,d=new r.StringStream(Zr(f.argString));!d.eol();){d.eatSpace();var g=d.pos;if(!d.match(/[a-zA-Z]/,!1)){he(a,"Invalid argument: "+f.argString.substring(g));return}var v=d.next();if(d.match("-",!0)){if(!d.match(/[a-zA-Z]/,!1)){he(a,"Invalid argument: "+f.argString.substring(g));return}var k=v,w=d.next();if(k&&w&&P(k)==P(w)){var b=k.charCodeAt(0),A=w.charCodeAt(0);if(b>=A){he(a,"Invalid argument: "+f.argString.substring(g));return}for(var M=0;M<=A-b;M++){var L=String.fromCharCode(b+M);delete c.marks[L]}}else{he(a,"Invalid argument: "+k+"-");return}}else v&&delete c.marks[v]}}},st=new Pc;xe.defineEx("version","ve",a=>{he(a,"Codemirror-vim version: <DEV>")});function Nc(a,f,c,d,g,v,k,w,b){a.state.vim.exMode=!0;var A=!1,M=0,L,D,R;function T(){a.operation(function(){for(;!A;)E(),J();q()})}function E(){var X="",ie=v.match||v.pos&&v.pos.match;if(ie)X=w.replace(/\$(\d{1,3}|[$&])/g,function(We,le){if(le=="$")return"$";if(le=="&")return ie[0];for(var te=le;parseInt(te)>=ie.length&&te.length>0;)te=te.slice(0,te.length-1);return te?ie[te]+le.slice(te.length,le.length):We});else{var Le=a.getRange(v.from(),v.to());X=Le.replace(k,w)}var Se=v.to().line;v.replace(X),D=v.to().line,g+=D-Se,R=D<Se}function H(){var X=L&&be(v.to()),ie=v.findNext();return ie&&!ie[0]&&X&&pt(v.from(),X)&&(ie=v.findNext()),ie&&M++,ie}function J(){for(;H()&&Ic(v.from(),d,g);)if(!(!c&&v.from().line==D&&!R)){a.scrollIntoView(v.from(),30),a.setSelection(v.from(),v.to()),L=v.from(),A=!1;return}A=!0}function q(X){if(X&&X(),a.focus(),L){a.setCursor(L);var ie=a.state.vim;ie.exMode=!1,ie.lastHPos=ie.lastHSPos=L.ch}b?b():A&&he(a,(M?"Found "+M+" matches":"No matches found")+" for pattern: "+k+(ee("pcre")?" (set nopcre to use Vim regexps)":""))}function U(X,ie,Le){r.e_stop(X);var Se=ln(X);switch(Se){case"y":E(),J();break;case"n":J();break;case"a":var We=b;b=void 0,a.operation(T),b=We;break;case"l":E();case"q":case"<Esc>":case"<C-c>":case"<C-[>":q(Le);break}return A&&q(Le),!0}if(J(),A){he(a,"No matches for "+k+(ee("pcre")?" (set nopcre to use vim regexps)":""));return}if(!f){T(),b&&b();return}$n(a,{prefix:Ct("span","replace with ",Ct("strong",w)," (y/n/a/q/l)"),onKeyDown:U})}function ii(a,f){var c=a.state.vim,d=z.macroModeState,g=z.registerController.getRegister("."),v=d.isPlaying,k=d.lastInsertModeChanges;v||(a.off("change",Dl),c.insertEnd&&c.insertEnd.clear(),c.insertEnd=void 0,r.off(a.getInputField(),"keydown",Il)),!v&&c.insertModeRepeat&&c.insertModeRepeat>1&&(Pl(a,c,c.insertModeRepeat-1,!0),c.lastEditInputState.repeatOverride=c.insertModeRepeat),delete c.insertModeRepeat,c.insertMode=!1,f||a.setCursor(a.getCursor().line,a.getCursor().ch-1),a.setOption("keyMap","vim"),a.setOption("disableInput",!0),a.toggleOverwrite(!1),g.setText(k.changes.join("")),r.signal(a,"vim-mode-change",{mode:"normal"}),d.isRecording&&zc(d)}function ss(a){i.unshift(a),a.keys&&Fc(a.keys)}function Fc(a){a.split(/(<(?:[CSMA]-)*\w+>|.)/i).forEach(function(f){f&&(n[f]||(n[f]=0),n[f]++)})}function Hc(a){a.split(/(<(?:[CSMA]-)*\w+>|.)/i).forEach(function(f){n[f]&&n[f]--})}function Wc(a,f,c,d,g){var v={keys:a,type:f};v[f]=c,v[f+"Args"]=d;for(var k in g)v[k]=g[k];ss(v)}Z("insertModeEscKeysTimeout",200,"number");function Vc(a,f,c,d){var g=z.registerController.getRegister(d);if(d==":"){g.keyBuffer[0]&&st.processCommand(a,g.keyBuffer[0]),c.isPlaying=!1;return}var v=g.keyBuffer,k=0;c.isPlaying=!0,c.replaySearchQueries=g.searchQueries.slice(0);for(var w=0;w<v.length;w++)for(var b=v[w],A,M,L=/<(?:[CSMA]-)*\w+>|./gi;A=L.exec(b);)if(M=A[0],xe.handleKey(a,M,"macro"),f.insertMode){var D=g.insertModeChanges[k++].changes;z.macroModeState.lastInsertModeChanges.changes=D,Fl(a,D,1),ii(a)}c.isPlaying=!1}function Kc(a,f){if(!a.isPlaying){var c=a.latestRegister,d=z.registerController.getRegister(c);d&&d.pushText(f)}}function zc(a){if(!a.isPlaying){var f=a.latestRegister,c=z.registerController.getRegister(f);c&&c.pushInsertModeChanges&&c.pushInsertModeChanges(a.lastInsertModeChanges)}}function $c(a,f){if(!a.isPlaying){var c=a.latestRegister,d=z.registerController.getRegister(c);d&&d.pushSearchQuery&&d.pushSearchQuery(f)}}function Dl(a,f){var c=z.macroModeState,d=c.lastInsertModeChanges;if(!c.isPlaying)for(var g=a.state.vim;f;){if(d.expectCursorActivityForChange=!0,d.ignoreCount>1)d.ignoreCount--;else if(f.origin=="+input"||f.origin=="paste"||f.origin===void 0){var v=a.listSelections().length;v>1&&(d.ignoreCount=v);var k=f.text.join(`
|
|
44
|
+
`);if(d.maybeReset&&(d.changes=[],d.maybeReset=!1),k)if(a.state.overwrite&&!/\n/.test(k))d.changes.push([k]);else{if(k.length>1){var w=g&&g.insertEnd&&g.insertEnd.find(),b=a.getCursor();if(w&&w.line==b.line){var A=w.ch-b.ch;A>0&&A<k.length&&(d.changes.push([k,A]),k="")}}k&&d.changes.push(k)}}f=f.next}}function Rl(a){var f=a.state.vim;if(f.insertMode){var c=z.macroModeState;if(c.isPlaying)return;var d=c.lastInsertModeChanges;d.expectCursorActivityForChange?d.expectCursorActivityForChange=!1:(d.maybeReset=!0,f.insertEnd&&f.insertEnd.clear(),f.insertEnd=a.setBookmark(a.getCursor(),{insertLeft:!0}))}else a.curOp?.isVimOp||El(a,f)}function El(a,f){var c=a.getCursor("anchor"),d=a.getCursor("head");if(f.visualMode&&!a.somethingSelected()?Et(a,!1):!f.visualMode&&!f.insertMode&&a.somethingSelected()&&(f.visualMode=!0,f.visualLine=!1,r.signal(a,"vim-mode-change",{mode:"visual"})),f.visualMode){var g=Me(d,c)?0:-1,v=Me(d,c)?-1:0;d=Oe(d,0,g),c=Oe(c,0,v),f.sel={anchor:c,head:d},Ut(a,f,"<",et(d,c)),Ut(a,f,">",ti(d,c))}else f.insertMode||(f.lastHPos=a.getCursor().ch)}function Il(a){var f=z.macroModeState,c=f.lastInsertModeChanges,d=r.keyName?r.keyName(a):a.key;d&&(d.indexOf("Delete")!=-1||d.indexOf("Backspace")!=-1)&&(c.maybeReset&&(c.changes=[],c.maybeReset=!1),c.changes.push(new Ue(d,a)))}function Pl(a,f,c,d){var g=z.macroModeState;g.isPlaying=!0;var v=f.lastEditActionCommand,k=f.inputState;function w(){v?mi.processAction(a,f,v):mi.evalInput(a,f)}function b(M){if(g.lastInsertModeChanges.changes.length>0){M=f.lastEditActionCommand?M:1;var L=g.lastInsertModeChanges;Fl(a,L.changes,M)}}if(f.inputState=f.lastEditInputState,v&&v.interlaceInsertRepeat)for(var A=0;A<c;A++)w(),b(1);else d||w(),b(c);f.inputState=k,f.insertMode&&!d&&ii(a),g.isPlaying=!1}function Nl(a,f){r.lookupKey(f,"vim-insert",function(d){return typeof d=="string"?r.commands[d](a):d(a),!0})}function Fl(a,f,c){var d=a.getCursor("head"),g=z.macroModeState.lastInsertModeChanges.visualBlock;g&&(dl(a,d,g+1),c=a.listSelections().length,a.setCursor(d));for(var v=0;v<c;v++){g&&a.setCursor(Oe(d,v,0));for(var k=0;k<f.length;k++){var w=f[k];if(w instanceof Ue)Nl(a,w.keyName);else if(typeof w=="string")a.replaceSelection(w);else{var b=a.getCursor(),A=Oe(b,0,w[0].length-(w[1]||0));a.replaceRange(w[0],b,w[1]?b:A),a.setCursor(A)}}}g&&a.setCursor(Oe(d,0,1))}function os(a){var f=new a.constructor;return Object.keys(a).forEach(function(c){if(c!="insertEnd"){var d=a[c];Array.isArray(d)?d=d.slice():d&&typeof d=="object"&&d.constructor!=Object&&(d=os(d)),f[c]=d}}),a.sel&&(f.sel={head:a.sel.head&&be(a.sel.head),anchor:a.sel.anchor&&be(a.sel.anchor)}),f}function _c(a,f,c){var v=De(a),d=a,g=!1,v=xe.maybeInitVimState_(d),k=v.visualBlock||v.wasInVisualBlock;if(d.state.closeVimNotification){var w=d.state.closeVimNotification;if(d.state.closeVimNotification=null,w(),f=="<CR>")return Pe(d),!0}var b=d.isInMultiSelectMode();if(v.wasInVisualBlock&&!b?v.wasInVisualBlock=!1:b&&v.visualBlock&&(v.wasInVisualBlock=!0),f=="<Esc>"&&!v.insertMode&&!v.visualMode&&b&&v.status=="<Esc>")Pe(d);else if(k||!b||d.inVirtualSelectionMode)g=xe.handleKey(d,f,c);else{var A=os(v),M=v.inputState.changeQueueList||[];d.operation(function(){d.curOp&&(d.curOp.isVimOp=!0);var L=0;d.forEachSelection(function(){d.state.vim.inputState.changeQueue=M[L];var D=d.getCursor("head"),R=d.getCursor("anchor"),T=Me(D,R)?0:-1,E=Me(D,R)?-1:0;D=Oe(D,0,T),R=Oe(R,0,E),d.state.vim.sel.head=D,d.state.vim.sel.anchor=R,g=xe.handleKey(d,f,c),d.virtualSelection&&(M[L]=d.state.vim.inputState.changeQueue,d.state.vim=os(A)),L++}),d.curOp?.cursorActivity&&!g&&(d.curOp.cursorActivity=!1),d.state.vim=v,v.inputState.changeQueueList=M,v.inputState.changeQueue=null},!0)}return g&&!v.visualMode&&!v.insertMode&&v.visualMode!=d.somethingSelected()&&El(d,v),g}return Re(),xe}const ph=typeof String.prototype.normalize=="function"?r=>r.normalize("NFKD"):r=>r;class Vu{constructor(e,t,i=0,n=e.length,s,o){this.test=o,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,n),this.bufferStart=i,this.normalize=s?l=>s(ph(l)):ph,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Eh(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=Od(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=Ih(e);let n=this.normalize(t);if(n.length)for(let s=0,o=i,l=!0;;s++){let h=n.charCodeAt(s),u=this.match(h,o,l,this.bufferPos+this.bufferStart,s==n.length-1);if(u)return this.value=u,this;if(s==n.length-1)break;l&&s<t.length&&t.charCodeAt(s)==h?o++:l=!1}}}match(e,t,i,n,s){let o=null;for(let l=0;l<this.matches.length;){let h=this.matches[l],u=!1;this.query.charCodeAt(h.index)==e&&(h.index==this.query.length-1?o={from:h.from,to:n,precise:s&&h.precise}:(h.index++,u=!0)),u?l++:this.matches.splice(l,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?o={from:t,to:n,precise:i&&s}:this.matches.push({from:t,index:1,precise:i})),o&&this.test&&!this.test(o.from,o.to,this.buffer,this.bufferStart)&&(o=null),o}}typeof Symbol<"u"&&(Vu.prototype[Symbol.iterator]=function(){return this});const Ku={from:-1,to:-1,match:/.*/.exec(""),precise:!0},nl="gm"+(/x/.unicode==null?"":"u");class rl{constructor(e,t,i,n=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=Ku,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new zu(e,t,i,n,s);this.re=new RegExp(t,nl+(i?.ignoreCase?"i":"")),this.test=i?.test,this.iter=e.iter();let o=e.lineAt(n);this.curLineStart=o.from,this.matchPos=Ir(e,n),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,n=i+t[0].length;if(this.matchPos=Ir(this.text,n+(i==n?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<n||i>this.value.to)&&(!this.test||this.test(i,n,t)))return this.value={from:i,to:n,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const Ds=new WeakMap;class Gi{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let n=Ds.get(e);if(!n||n.from>=i||n.to<=t){let l=new Gi(t,e.sliceString(t,i));return Ds.set(e,l),l}if(n.from==t&&n.to==i)return n;let{text:s,from:o}=n;return o>t&&(s=e.sliceString(t,o)+s,o=t),n.to<i&&(s+=e.sliceString(n.to,i)),Ds.set(e,new Gi(o,s)),new Gi(t,s.slice(t-o,i-o))}}class zu{constructor(e,t,i,n,s){this.text=e,this.to=s,this.done=!1,this.value=Ku,this.matchPos=Ir(e,n),this.re=new RegExp(t,nl+(i?.ignoreCase?"i":"")),this.test=i?.test,this.flat=Gi.get(e,n,this.chunkEnd(n+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,n=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,n,t)))return this.value={from:i,to:n,precise:!0,match:t},this.matchPos=Ir(this.text,n+(i==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Gi.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(rl.prototype[Symbol.iterator]=zu.prototype[Symbol.iterator]=function(){return this});function iv(r){try{return new RegExp(r,nl),!0}catch{return!1}}function Ir(r,e){if(e>=r.length)return e;let t=r.lineAt(e),i;for(;e<t.to&&(i=t.text.charCodeAt(e-t.from))>=56320&&i<57344;)e++;return e}class nv{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||iv(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?`
|
|
45
|
+
`:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new hv(this):new ov(this)}getCursor(e,t=0,i){let n=e.doc?e:pe.create({doc:e});return i==null&&(i=n.doc.length),this.regexp?Wi(this,n,t,i):Hi(this,n,t,i)}}class $u{constructor(e){this.spec=e}}function rv(r,e,t){return(i,n,s,o)=>{if(t&&!t(i,n,s,o))return!1;let l=i>=o&&n<=o+s.length?s.slice(i-o,n-o):e.doc.sliceString(i,n);return r(l,e,i,n)}}function Hi(r,e,t,i){let n;return r.wholeWord&&(n=sv(e.doc,e.charCategorizer(e.selection.main.head))),r.test&&(n=rv(r.test,e,n)),new Vu(e.doc,r.unquoted,t,i,r.caseSensitive?void 0:s=>s.toLowerCase(),n)}function sv(r,e){return(t,i,n,s)=>((s>t||s+n.length<i)&&(s=Math.max(0,t-2),n=r.sliceString(s,Math.min(r.length,i+2))),(e(Pr(n,t-s))!=je.Word||e(Nr(n,t-s))!=je.Word)&&(e(Nr(n,i-s))!=je.Word||e(Pr(n,i-s))!=je.Word))}class ov extends $u{constructor(e){super(e)}nextMatch(e,t,i){let n=Hi(this.spec,e,i,e.doc.length).nextOverlapping();if(n.done){let s=Math.min(e.doc.length,t+this.spec.unquoted.length);n=Hi(this.spec,e,0,s).nextOverlapping()}return n.done||n.value.from==t&&n.value.to==i?null:n.value}prevMatchInRange(e,t,i){for(let n=i;;){let s=Math.max(t,n-1e4-this.spec.unquoted.length),o=Hi(this.spec,e,s,n),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(s==t)return null;n-=1e4}}prevMatch(e,t,i){let n=this.prevMatchInRange(e,0,t);return n||(n=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),n&&(n.from!=t||n.to!=i)?n:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=Hi(this.spec,e,0,e.doc.length),n=[];for(;!i.next().done;){if(n.length>=t)return null;n.push(i.value)}return n}highlight(e,t,i,n){let s=Hi(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)n(s.value.from,s.value.to)}}function lv(r,e,t){return(i,n,s)=>(!t||t(i,n,s))&&r(s[0],e,i,n)}function Wi(r,e,t,i){let n;return r.wholeWord&&(n=av(e.charCategorizer(e.selection.main.head))),r.test&&(n=lv(r.test,e,n)),new rl(e.doc,r.search,{ignoreCase:!r.caseSensitive,test:n},t,i)}function Pr(r,e){return r.slice(Ne(r,e,!1),e)}function Nr(r,e){return r.slice(e,Ne(r,e))}function av(r){return(e,t,i)=>!i[0].length||(r(Pr(i.input,i.index))!=je.Word||r(Nr(i.input,i.index))!=je.Word)&&(r(Nr(i.input,i.index+i[0].length))!=je.Word||r(Pr(i.input,i.index+i[0].length))!=je.Word)}class hv extends $u{nextMatch(e,t,i){let n=Wi(this.spec,e,i,e.doc.length).next();return n.done&&(n=Wi(this.spec,e,0,t).next()),n.done?null:n.value}prevMatchInRange(e,t,i){for(let n=1;;n++){let s=Math.max(t,i-n*1e4),o=Wi(this.spec,e,s,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(s==t||l.from>s+10))return l;if(s==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let n=i.length;n>0;n--){let s=+i.slice(0,n);if(s>0&&s<e.match.length)return e.match[s]+i.slice(n)}return t})}matchAll(e,t){let i=Wi(this.spec,e,0,e.doc.length),n=[];for(;!i.next().done;){if(n.length>=t)return null;n.push(i.value)}return n}highlight(e,t,i,n){let s=Wi(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!s.next().done;)n(s.value.from,s.value.to)}}const bo=me.define();function ft(r,e){var t=e.ch,i=e.line+1;i<1&&(i=1,t=0),i>r.lines&&(i=r.lines,t=Number.MAX_VALUE);var n=r.line(i);return Math.min(n.from+Math.max(0,t),n.to)}function gt(r,e){let t=r.lineAt(e);return{line:t.number-1,ch:e-t.from}}class Wt{constructor(e,t){this.line=e,this.ch=t}}function _u(r,e,t){if(r.addEventListener)r.addEventListener(e,t,!1);else{var i=r._handlers||(r._handlers={});i[e]=(i[e]||[]).concat(t)}}function ju(r,e,t){if(r.removeEventListener)r.removeEventListener(e,t,!1);else{var i=r._handlers,n=i&&i[e];if(n){var s=n.indexOf(t);s>-1&&(i[e]=n.slice(0,s).concat(n.slice(s+1)))}}}function qu(r,e,...t){var i,n=(i=r._handlers)===null||i===void 0?void 0:i[e];if(n)for(var s=0;s<n.length;++s)n[s](...t)}function gh(r,...e){if(r)for(var t=0;t<r.length;++t)r[t](...e)}let So;try{So=new RegExp("[\\w\\p{Alphabetic}\\p{Number}_]","u")}catch{So=/[\w]/}function yn(r,e){var t=r.cm6;if(!t.state.readOnly){var i="input.type.compose";if(r.curOp&&(r.curOp.lastChange||(i="input.type.compose.start")),e.annotations)try{e.annotations.some(function(n){n.value=="input"&&(n.value=i)})}catch(n){console.error(n)}else e.userEvent=i;return t.dispatch(e)}}function mh(r,e){var t;r.curOp&&(r.curOp.$changeStart=void 0),(e?Qo:Rr)(r.cm6);let i=(t=r.curOp)===null||t===void 0?void 0:t.$changeStart;i!=null&&r.cm6.dispatch({selection:{anchor:i}})}var fv={Left:r=>Pi(r.cm6,{key:"Left"},"editor"),Right:r=>Pi(r.cm6,{key:"Right"},"editor"),Up:r=>Pi(r.cm6,{key:"Up"},"editor"),Down:r=>Pi(r.cm6,{key:"Down"},"editor"),Backspace:r=>Pi(r.cm6,{key:"Backspace"},"editor"),Delete:r=>Pi(r.cm6,{key:"Delete"},"editor")};class ne{openDialog(e,t,i){return cv(this,e,t,i)}openNotification(e,t){return uv(this,e,t)}constructor(e){this.state={},this.marks=Object.create(null),this.$mid=0,this.options={},this._handlers={},this.$lastChangeEndOffset=0,this.virtualSelection=null,this.cm6=e,this.onChange=this.onChange.bind(this),this.onSelectionChange=this.onSelectionChange.bind(this)}on(e,t){_u(this,e,t)}off(e,t){ju(this,e,t)}signal(e,t,i){qu(this,e,t,i)}indexFromPos(e){return ft(this.cm6.state.doc,e)}posFromIndex(e){return gt(this.cm6.state.doc,e)}foldCode(e){let t=this.cm6,i=t.state.selection.ranges,n=this.cm6.state.doc,s=ft(n,e),o=I.create([I.range(s,s)],0).ranges;t.state.selection.ranges=o,vm(t),t.state.selection.ranges=i}firstLine(){return 0}lastLine(){return this.cm6.state.doc.lines-1}lineCount(){return this.cm6.state.doc.lines}setCursor(e,t){typeof e=="object"&&(t=e.ch,e=e.line);var i=ft(this.cm6.state.doc,{line:e,ch:t||0});this.cm6.dispatch({selection:{anchor:i}},{scrollIntoView:!this.curOp}),this.curOp&&!this.curOp.isVimOp&&this.onBeforeEndOperation()}getCursor(e){var t=this.cm6.state.selection.main,i=e=="head"||!e?t.head:e=="anchor"?t.anchor:e=="start"?t.from:e=="end"?t.to:null;if(i==null)throw new Error("Invalid cursor type");return this.posFromIndex(i)}listSelections(){var e=this.cm6.state.doc;return this.cm6.state.selection.ranges.map(t=>({anchor:gt(e,t.anchor),head:gt(e,t.head)}))}setSelections(e,t){var i=this.cm6.state.doc,n=e.map(s=>{var o=ft(i,s.head),l=ft(i,s.anchor);return o==l?I.cursor(o,1):I.range(l,o)});this.cm6.dispatch({selection:I.create(n,t)})}setSelection(e,t,i){this.setSelections([{anchor:e,head:t}],0),i&&i.origin=="*mouse"&&this.onBeforeEndOperation()}getLine(e){var t=this.cm6.state.doc;return e<0||e>=t.lines?"":this.cm6.state.doc.line(e+1).text}getLineHandle(e){return this.$lineHandleChanges||(this.$lineHandleChanges=[]),{row:e,index:this.indexFromPos(new Wt(e,0))}}getLineNumber(e){var t=this.$lineHandleChanges;if(!t)return null;for(var i=e.index,n=0;n<t.length;n++)if(i=t[n].changes.mapPos(i,1,_e.TrackAfter),i==null)return null;var s=this.posFromIndex(i);return s.ch==0?s.line:null}releaseLineHandles(){this.$lineHandleChanges=void 0}getRange(e,t){var i=this.cm6.state.doc;return this.cm6.state.sliceDoc(ft(i,e),ft(i,t))}replaceRange(e,t,i,n){i||(i=t);var s=this.cm6.state.doc,o=ft(s,t),l=ft(s,i);yn(this,{changes:{from:o,to:l,insert:e}})}replaceSelection(e){yn(this,this.cm6.state.replaceSelection(e))}replaceSelections(e){var t=this.cm6.state.selection.ranges,i=t.map((n,s)=>({from:n.from,to:n.to,insert:e[s]||""}));yn(this,{changes:i})}getSelection(){return this.getSelections().join(`
|
|
46
|
+
`)}getSelections(){var e=this.cm6;return e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to))}somethingSelected(){return this.cm6.state.selection.ranges.some(e=>!e.empty)}getInputField(){return this.cm6.contentDOM}clipPos(e){var t=this.cm6.state.doc,i=e.ch,n=e.line+1;n<1&&(n=1,i=0),n>t.lines&&(n=t.lines,i=Number.MAX_VALUE);var s=t.line(n);return i=Math.min(Math.max(0,i),s.to-s.from),new Wt(n-1,i)}getValue(){return this.cm6.state.doc.toString()}setValue(e){var t=this.cm6;return t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e},selection:I.range(0,0)})}focus(){return this.cm6.focus()}blur(){return this.cm6.contentDOM.blur()}defaultTextHeight(){return this.cm6.defaultLineHeight}findMatchingBracket(e,t){var i=this.cm6.state,n=ft(i.doc,e),s=ai(i,n+1,-1);return s&&s.end?{to:gt(i.doc,s.end.from)}:(s=ai(i,n,1),s&&s.end?{to:gt(i.doc,s.end.from)}:{to:void 0})}scanForBracket(e,t,i,n){return gv(this,e,t,i,n)}indentLine(e,t){t?this.indentMore():this.indentLess()}indentMore(){tl(this.cm6)}indentLess(){il(this.cm6)}execCommand(e){if(ne.commands.hasOwnProperty(e))ne.commands[e](this);else if(e=="goLineLeft")bu(this.cm6);else if(e=="goLineRight"){wu(this.cm6);let t=this.cm6.state,i=t.selection.main.head;i<t.doc.length&&t.sliceDoc(i,i+1)!==`
|
|
47
|
+
`&&u0(this.cm6)}else console.log(e+" is not implemented")}setBookmark(e,t){var i=t?.insertLeft?1:-1,n=this.indexFromPos(e),s=new yv(this,n,i);return s}addOverlay({query:e}){let t=new nv({regexp:!0,search:e.source,caseSensitive:!/i/.test(e.flags)});if(t.valid){t.forVim=!0,this.cm6Query=t;let i=bo.of(t);return this.cm6.dispatch({effects:i}),t}}removeOverlay(e){if(!this.cm6Query)return;this.cm6Query.forVim=!1;let t=bo.of(this.cm6Query);this.cm6.dispatch({effects:t})}getSearchCursor(e,t){var i=this,n=null,s=null,o=!1;t.ch==null&&(t.ch=Number.MAX_VALUE);var l=ft(i.cm6.state.doc,t),h=e.source.replace(/(\\.|{(?:\d+(?:,\d*)?|,\d+)})|[{}]/g,function(x,S){return S||"\\"+x});function u(x,S=0,C=x.length){return new rl(x,h,{ignoreCase:e.ignoreCase},S,C)}function p(x){var S=i.cm6.state.doc;if(x>S.length)return null;let C=u(S,x).next();return C.done?null:C.value}var m=1e4;function y(x,S){var C=i.cm6.state.doc;for(let O=1;;O++){let B=Math.max(x,S-O*m),F=u(C,B,S),P=null;for(;!F.next().done;)P=F.value;if(P&&(B==x||P.from>B+10))return P;if(B==x)return null}}return{findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(x){var S=i.cm6.state.doc;if(x){let C=n?o?n.to-1:n.from:l;n=y(0,C)}else{let C=n?o?n.to+1:n.to:l;n=p(C)}return s=n&&{from:gt(S,n.from),to:gt(S,n.to),match:n.match},o=n?n.from==n.to:!1,n&&n.match},from:function(){return s?.from},to:function(){return s?.to},replace:function(x){n&&(yn(i,{changes:{from:n.from,to:n.to,insert:x}}),n.to=n.from+x.length,s&&(s.to=gt(i.cm6.state.doc,n.to)))},get match(){return s&&s.match}}}findPosV(e,t,i,n){let{cm6:s}=this;const o=s.state.doc;let l=i=="page"?s.dom.clientHeight:0;const h=ft(o,e);let u=I.cursor(h,1,void 0,n),p=Math.round(Math.abs(t));for(let y=0;y<p;y++)i=="page"?u=s.moveVertically(u,t>0,l):i=="line"&&(u=s.moveVertically(u,t>0));let m=gt(o,u.head);return(t<0&&u.head==0&&n!=0&&e.line==0&&e.ch!=0||t>0&&u.head==o.length&&m.ch!=n&&e.line==m.line)&&(m.hitSide=!0),m}charCoords(e,t){var i=this.cm6.contentDOM.getBoundingClientRect(),n=ft(this.cm6.state.doc,e),s=this.cm6.coordsAtPos(n),o=-i.top;return{left:(s?.left||0)-i.left,top:(s?.top||0)+o,bottom:(s?.bottom||0)+o}}coordsChar(e,t){var i=this.cm6.contentDOM.getBoundingClientRect(),n=this.cm6.posAtCoords({x:e.left+i.left,y:e.top+i.top})||0;return gt(this.cm6.state.doc,n)}getScrollInfo(){var e=this.cm6.scrollDOM;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight,width:e.scrollWidth,clientHeight:e.clientHeight,clientWidth:e.clientWidth}}scrollTo(e,t){e!=null&&(this.cm6.scrollDOM.scrollLeft=e),t!=null&&(this.cm6.scrollDOM.scrollTop=t)}scrollIntoView(e,t){if(e){var i=this.indexFromPos(e);this.cm6.dispatch({effects:G.scrollIntoView(i)})}else this.cm6.dispatch({scrollIntoView:!0,userEvent:"scroll"})}getWrapperElement(){return this.cm6.dom}getMode(){return{name:this.getOption("mode")}}setSize(e,t){this.cm6.dom.style.width=e+4+"px",this.cm6.dom.style.height=t+"px",this.refresh()}refresh(){this.cm6.measure()}destroy(){this.removeOverlay()}getLastEditEnd(){return this.posFromIndex(this.$lastChangeEndOffset)}onChange(e){this.$lineHandleChanges&&this.$lineHandleChanges.push(e);for(let i in this.marks)this.marks[i].update(e.changes);this.virtualSelection&&(this.virtualSelection.ranges=this.virtualSelection.ranges.map(i=>i.map(e.changes)));var t=this.curOp=this.curOp||{};e.changes.iterChanges((i,n,s,o,l)=>{(t.$changeStart==null||t.$changeStart>s)&&(t.$changeStart=s),this.$lastChangeEndOffset=o;var h={text:l.toJSON()};t.lastChange?t.lastChange.next=t.lastChange=h:t.lastChange=t.change=h},!0),t.changeHandlers||(t.changeHandlers=this._handlers.change&&this._handlers.change.slice())}onSelectionChange(){var e=this.curOp=this.curOp||{};e.cursorActivityHandlers||(e.cursorActivityHandlers=this._handlers.cursorActivity&&this._handlers.cursorActivity.slice()),this.curOp.cursorActivity=!0}operation(e,t){this.curOp||(this.curOp={$d:0}),this.curOp.$d++;try{var i=e()}finally{this.curOp&&(this.curOp.$d--,this.curOp.$d||this.onBeforeEndOperation())}return i}onBeforeEndOperation(){var e=this.curOp,t=!1;e&&(e.change&&gh(e.changeHandlers,this,e.change),e&&e.cursorActivity&&(gh(e.cursorActivityHandlers,this,null),e.isVimOp&&(t=!0)),this.curOp=null),t&&this.scrollIntoView()}moveH(e,t){if(t=="char"){var i=this.getCursor();this.setCursor(i.line,i.ch+e)}}setOption(e,t){switch(e){case"keyMap":this.state.keyMap=t;break;case"textwidth":this.state.textwidth=t;break}}getOption(e){switch(e){case"firstLineNumber":return 1;case"tabSize":return this.cm6.state.tabSize||4;case"readOnly":return this.cm6.state.readOnly;case"indentWithTabs":return this.cm6.state.facet(nn)==" ";case"indentUnit":return this.cm6.state.facet(nn).length||2;case"textwidth":return this.state.textwidth;case"keyMap":return this.state.keyMap||"vim"}}toggleOverwrite(e){this.state.overwrite=e}getTokenTypeAt(e){var t,i=this.indexFromPos(e),n=Gf(this.cm6.state,i),s=n?.resolve(i),o=((t=s?.type)===null||t===void 0?void 0:t.name)||"";return/comment/i.test(o)?"comment":/string/i.test(o)?"string":""}overWriteSelection(e){var t=this.cm6.state.doc,i=this.cm6.state.selection,n=i.ranges.map(s=>{if(s.empty){var o=s.to<t.length?t.sliceString(s.from,s.to+1):"";if(o&&!/\n/.test(o))return I.range(s.from,s.to+1)}return s});this.cm6.dispatch({selection:I.create(n,i.mainIndex)}),this.replaceSelection(e)}isInMultiSelectMode(){return this.cm6.state.selection.ranges.length>1}virtualSelectionMode(){return!!this.virtualSelection}forEachSelection(e){var t=this.cm6.state.selection;this.virtualSelection=I.create(t.ranges,t.mainIndex);for(var i=0;i<this.virtualSelection.ranges.length;i++){var n=this.virtualSelection.ranges[i];n&&(this.cm6.dispatch({selection:I.create([n])}),e(),this.virtualSelection.ranges[i]=this.cm6.state.selection.ranges[0])}this.cm6.dispatch({selection:this.virtualSelection}),this.virtualSelection=null}hardWrap(e){return kv(this,e)}}ne.isMac=typeof navigator<"u"&&/Mac/.test(navigator.platform);ne.Pos=Wt;ne.StringStream=Bm;ne.commands={toggleLineComment:function(r){au(r.cm6)},cursorCharLeft:function(r){Zo(r.cm6)},redo:function(r){mh(r,!1)},undo:function(r){mh(r,!0)},newlineAndIndent:function(r){wo({state:r.cm6.state,dispatch:e=>yn(r,e)})},indentAuto:function(r){Wu(r.cm6)},newlineAndIndentContinueComment:void 0,save:void 0};ne.isWordChar=function(r){return So.test(r)};ne.keys=fv;ne.addClass=function(r,e){};ne.rmClass=function(r,e){};ne.e_preventDefault=function(r){r.preventDefault()};ne.e_stop=function(r){var e,t;(e=r?.stopPropagation)===null||e===void 0||e.call(r),(t=r?.preventDefault)===null||t===void 0||t.call(r)};ne.lookupKey=function(e,t,i){var n=ne.keys[e];!n&&/^Arrow/.test(e)&&(n=ne.keys[e.slice(5)]),n&&i(n)};ne.on=_u;ne.off=ju;ne.signal=qu;ne.findMatchingTag=mv;ne.findEnclosingTag=vv;ne.keyName=void 0;function Uu(r,e,t){var i=document.createElement("div");return i.appendChild(e),i}function Ju(r,e){r.state.currentNotificationClose&&r.state.currentNotificationClose(),r.state.currentNotificationClose=e}function uv(r,e,t){Ju(r,l);var i=Uu(r,e,t&&t.bottom),n=!1,s,o=t&&typeof t.duration<"u"?t.duration:5e3;function l(){n||(n=!0,clearTimeout(s),i.remove(),Yu(r,i))}return i.onclick=function(h){h.preventDefault(),l()},Gu(r,i),o&&(s=setTimeout(l,o)),l}function Gu(r,e){var t=r.state.dialog;r.state.dialog=e,e.style.flex="1",e&&t!==e&&(t&&t.contains(document.activeElement)&&r.focus(),t&&t.parentElement?t.parentElement.replaceChild(e,t):t&&t.remove(),ne.signal(r,"dialog"))}function Yu(r,e){r.state.dialog==e&&(r.state.dialog=null,ne.signal(r,"dialog"))}function cv(r,e,t,i){i||(i={}),Ju(r,void 0);var n=Uu(r,e,i.bottom),s=!1;Gu(r,n);function o(h){if(typeof h=="string")l.value=h;else{if(s)return;s=!0,Yu(r,n),r.state.dialog||r.focus(),i.onClose&&i.onClose(n)}}var l=n.getElementsByTagName("input")[0];return l&&(i.value&&(l.value=i.value,i.selectValueOnOpen!==!1&&l.select()),i.onInput&&ne.on(l,"input",function(h){i.onInput(h,l.value,o)}),i.onKeyUp&&ne.on(l,"keyup",function(h){i.onKeyUp(h,l.value,o)}),ne.on(l,"keydown",function(h){i&&i.onKeyDown&&i.onKeyDown(h,l.value,o)||(h.keyCode==13&&t&&t(l.value),(h.keyCode==27||i.closeOnEnter!==!1&&h.keyCode==13)&&(l.blur(),ne.e_stop(h),o()))}),i.closeOnBlur!==!1&&ne.on(l,"blur",function(){setTimeout(function(){document.activeElement!==l&&o()})}),l.focus()),o}var dv={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<","<":">>",">":"<<"};function pv(r){return r&&r.bracketRegex||/[(){}[\]]/}function gv(r,e,t,i,n){for(var s=n&&n.maxScanLineLength||1e4,o=n&&n.maxScanLines||1e3,l=[],h=pv(n),u=t>0?Math.min(e.line+o,r.lastLine()+1):Math.max(r.firstLine()-1,e.line-o),p=e.line;p!=u;p+=t){var m=r.getLine(p);if(m){var y=t>0?0:m.length-1,x=t>0?m.length:-1;if(!(m.length>s))for(p==e.line&&(y=e.ch-(t<0?1:0));y!=x;y+=t){var S=m.charAt(y);if(h.test(S)){var C=dv[S];if(C&&C.charAt(1)==">"==t>0)l.push(S);else if(l.length)l.pop();else return{pos:new Wt(p,y),ch:S}}}}}return p-t==(t>0?r.lastLine():r.firstLine())?!1:null}function mv(r,e){return null}function vv(r,e){var t,i,n=r.cm6.state,s=r.indexFromPos(e);if(s<n.doc.length){var o=n.sliceDoc(s,s+1);o=="<"&&s++}for(var l=Gf(n,s),h=l?.resolve(s)||null;h;){if(((t=h.firstChild)===null||t===void 0?void 0:t.type.name)=="OpenTag"&&((i=h.lastChild)===null||i===void 0?void 0:i.type.name)=="CloseTag")return{open:vh(n.doc,h.firstChild),close:vh(n.doc,h.lastChild)};h=h.parent}}function vh(r,e){return{from:gt(r,e.from),to:gt(r,e.to)}}class yv{constructor(e,t,i){this.cm=e,this.id=e.$mid++,this.offset=t,this.assoc=i,e.marks[this.id]=this}clear(){delete this.cm.marks[this.id]}find(){return this.offset==null?null:this.cm.posFromIndex(this.offset)}update(e){this.offset!=null&&(this.offset=e.mapPos(this.offset,this.assoc,_e.TrackDel))}}function kv(r,e){for(var t,i=e.column||r.getOption("textwidth")||80,n=e.allowMerge!=!1,s=Math.min(e.from,e.to),o=Math.max(e.from,e.to);s<=o;){var l=r.getLine(s);if(l.length>i){var h=S(l,i,5);if(h){var u=(t=/^\s*/.exec(l))===null||t===void 0?void 0:t[0];r.replaceRange(`
|
|
48
|
+
`+u,new Wt(s,h.start),new Wt(s,h.end))}o++}else if(n&&/\S/.test(l)&&s!=o){var p=r.getLine(s+1);if(p&&/\S/.test(p)){var m=l.replace(/\s+$/,""),y=p.replace(/^\s+/,""),x=m+" "+y,h=S(x,i,5);h&&h.start>m.length||x.length<i?(r.replaceRange(" ",new Wt(s,m.length),new Wt(s+1,p.length-y.length)),s--,o--):m.length<l.length&&r.replaceRange("",new Wt(s,m.length),new Wt(s,l.length))}}s++}return s;function S(C,O,B){if(!(C.length<O)){var F=C.slice(0,O),P=C.slice(O),Q=/^(?:(\s+)|(\S+)(\s+))/.exec(P),W=/(?:(\s+)|(\s+)(\S+))$/.exec(F),V=0,N=0;if(W&&!W[2]&&(V=O-W[1].length,N=O),Q&&!Q[2]&&(V||(V=O),N=O+Q[1].length),V)return{start:V,end:N};if(W&&W[2]&&W.index>B)return{start:W.index,end:W.index+W[2].length};if(Q&&Q[2])return V=O+Q[2].length,{start:V,end:V+Q[3].length}}}}let Co=Ig||(function(){let r={cursorBlinkRate:1200};return function(){return r}})();class xv{constructor(e,t,i,n,s,o,l,h,u,p){this.left=e,this.top=t,this.height=i,this.fontFamily=n,this.fontSize=s,this.fontWeight=o,this.color=l,this.className=h,this.letter=u,this.partial=p}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",e.style.height=this.height+"px",e.style.lineHeight=this.height+"px",e.style.fontFamily=this.fontFamily,e.style.fontSize=this.fontSize,e.style.fontWeight=this.fontWeight,e.style.color=this.partial?"transparent":this.color,e.className=this.className,e.textContent=this.letter}eq(e){return this.left==e.left&&this.top==e.top&&this.height==e.height&&this.fontFamily==e.fontFamily&&this.fontSize==e.fontSize&&this.fontWeight==e.fontWeight&&this.color==e.color&&this.className==e.className&&this.letter==e.letter}}class wv{constructor(e,t){this.view=e,this.rangePieces=[],this.cursors=[],this.cm=t,this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)},this.cursorLayer=e.scrollDOM.appendChild(document.createElement("div")),this.cursorLayer.className="cm-cursorLayer cm-vimCursorLayer",this.cursorLayer.setAttribute("aria-hidden","true"),e.requestMeasure(this.measureReq),this.setBlinkRate()}setBlinkRate(){let t=Co(this.cm.cm6.state).cursorBlinkRate;this.cursorLayer.style.animationDuration=t+"ms"}update(e){(e.selectionSet||e.geometryChanged||e.viewportChanged)&&(this.view.requestMeasure(this.measureReq),this.cursorLayer.style.animationName=this.cursorLayer.style.animationName=="cm-blink"?"cm-blink2":"cm-blink"),bv(e)&&this.setBlinkRate()}scheduleRedraw(){this.view.requestMeasure(this.measureReq)}readPos(){let{state:e}=this.view,t=[];for(let i of e.selection.ranges){let n=i==e.selection.main,s=Mv(this.cm,this.view,i,n);s&&t.push(s)}return{cursors:t}}drawSel({cursors:e}){if(e.length!=this.cursors.length||e.some((t,i)=>!t.eq(this.cursors[i]))){let t=this.cursorLayer.children;if(t.length!==e.length){this.cursorLayer.textContent="";for(const i of e)this.cursorLayer.appendChild(i.draw())}else e.forEach((i,n)=>i.adjust(t[n]));this.cursors=e}}destroy(){this.cursorLayer.remove()}}function bv(r){return Co(r.startState)!=Co(r.state)}const Sv={".cm-vimMode .cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-fat-cursor":{position:"absolute",background:"#ff9696",border:"none",whiteSpace:"pre"},"&:not(.cm-focused) .cm-fat-cursor":{background:"none",outline:"solid 1px #ff9696",color:"transparent !important"}},Cv=rn.highest(G.theme(Sv));function Av(r){let e=r.scrollDOM.getBoundingClientRect();return{left:(r.textDirection==Ce.LTR?e.left:e.right-r.scrollDOM.clientWidth)-r.scrollDOM.scrollLeft*r.scaleX,top:e.top-r.scrollDOM.scrollTop*r.scaleY}}function Mv(r,e,t,i){var n,s,o,l;let h=t.head,u=!1,p=1,m=r.state.vim;if(m&&(!m.insertMode||r.state.overwrite)){if(u=!0,m.visualBlock&&!i)return null;t.anchor<t.head&&(h<e.state.doc.length&&e.state.sliceDoc(h,h+1))!=`
|
|
49
|
+
`&&h--,r.state.overwrite?p=.2:m.status&&(p=.5)}if(u){let x=h<e.state.doc.length&&e.state.sliceDoc(h,h+1);x&&/[\uDC00-\uDFFF]/.test(x)&&h>1&&(h--,x=e.state.sliceDoc(h,h+1));let S=e.coordsAtPos(h,1);if(!S)return null;let C=Av(e),O=e.domAtPos(h),B=O?O.node:e.contentDOM;for(B instanceof Text&&O.offset>=B.data.length&&!((n=B.parentElement)===null||n===void 0)&&n.nextSibling&&(B=(s=B.parentElement)===null||s===void 0?void 0:s.nextSibling,O={node:B,offset:0});O&&O.node instanceof HTMLElement;)B=O.node,O={node:O.node.childNodes[O.offset],offset:0};if(!(B instanceof HTMLElement)){if(!B.parentNode)return null;B=B.parentNode}let F=getComputedStyle(B),P=S.left,Q=(l=(o=e).coordsForChar)===null||l===void 0?void 0:l.call(o,h);if(Q&&(P=Q.left),!x||x==`
|
|
50
|
+
`||x=="\r")x=" ";else if(x==" "){x=" ";var y=e.coordsAtPos(h+1,-1);y&&(P=y.left-(y.left-S.left)/parseInt(F.tabSize))}else/[\uD800-\uDBFF]/.test(x)&&h<e.state.doc.length-1&&(x+=e.state.sliceDoc(h+1,h+2));let W=S.bottom-S.top;return new xv((P-C.left)/e.scaleX,(S.top-C.top+W*(1-p))/e.scaleY,W*p/e.scaleY,F.fontFamily,F.fontSize,F.fontWeight,F.color,i?"cm-fat-cursor cm-cursor-primary":"cm-fat-cursor cm-cursor-secondary",x,p!=1)}else return null}var Tv=typeof navigator<"u"&&/linux/i.test(navigator.platform)&&/ Gecko\/\d+/.exec(navigator.userAgent);const xi=tv(ne),Ov=250,Lv=G.baseTheme({".cm-vimMode .cm-cursorLayer:not(.cm-vimCursorLayer)":{display:"none"},".cm-vim-panel":{padding:"0px 10px",fontFamily:"monospace",minHeight:"1.3em",display:"flex"},".cm-vim-panel input":{border:"none",outline:"none",backgroundColor:"inherit"},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"}}),Bv=wt.fromClass(class{constructor(r){this.status="",this.query=null,this.decorations=de.none,this.waitForCopy=!1,this.lastKeydown="",this.useNextTextInput=!1,this.compositionText="",this.view=r;const e=this.cm=new ne(r);xi.enterVimMode(this.cm),this.view.cm=this.cm,this.cm.state.vimPlugin=this,this.blockCursor=new wv(r,e),this.updateClass(),this.cm.on("vim-command-done",()=>{e.state.vim&&(e.state.vim.status=""),this.blockCursor.scheduleRedraw(),this.updateStatus()}),this.cm.on("vim-mode-change",t=>{e.state.vim&&(e.state.vim.mode=t.mode,t.subMode&&(e.state.vim.mode+=t.subMode==="linewise"?" line":" block"),e.state.vim.status="",this.blockCursor.scheduleRedraw(),this.updateClass(),this.updateStatus())}),this.cm.on("dialog",()=>{this.cm.state.statusbar?this.updateStatus():r.dispatch({effects:Qu.of(!!this.cm.state.dialog)})}),this.dom=document.createElement("span"),this.spacer=document.createElement("span"),this.spacer.style.flex="1",this.statusButton=document.createElement("span"),this.statusButton.onclick=t=>{xi.handleKey(this.cm,"<Esc>","user"),this.cm.focus()},this.statusButton.style.cssText="cursor: pointer"}update(r){var e;if((r.viewportChanged||r.docChanged)&&this.query&&this.highlight(this.query),r.docChanged&&this.cm.onChange(r),r.selectionSet&&this.cm.onSelectionChange(),r.viewportChanged,this.cm.curOp&&!this.cm.curOp.isVimOp&&this.cm.onBeforeEndOperation(),r.transactions){for(let t of r.transactions)for(let i of t.effects)if(i.is(bo))if(!((e=i.value)===null||e===void 0?void 0:e.forVim))this.highlight(null);else{let s=i.value.create();this.highlight(s)}}this.blockCursor.update(r)}updateClass(){const r=this.cm.state;!r.vim||r.vim.insertMode&&!r.overwrite?this.view.scrollDOM.classList.remove("cm-vimMode"):this.view.scrollDOM.classList.add("cm-vimMode")}updateStatus(){let r=this.cm.state.statusbar,e=this.cm.state.vim;if(!r||!e)return;let t=this.cm.state.dialog;if(t)t.parentElement!=r&&(r.textContent="",r.appendChild(t));else{r.textContent="";var i=(e.mode||"normal").toUpperCase();e.insertModeReturn&&(i+="(C-O)"),this.statusButton.textContent=`--${i}--`,r.appendChild(this.statusButton),r.appendChild(this.spacer)}this.dom.textContent=e.status,r.appendChild(this.dom)}destroy(){xi.leaveVimMode(this.cm),this.updateClass(),this.blockCursor.destroy(),delete this.view.cm}highlight(r){if(this.query=r,!r)return this.decorations=de.none;let{view:e}=this,t=new Ci;for(let i=0,n=e.visibleRanges,s=n.length;i<s;i++){let{from:o,to:l}=n[i];for(;i<s-1&&l>n[i+1].from-2*Ov;)l=n[++i].to;r.highlight(e.state,o,l,(h,u)=>{t.add(h,u,Rv)})}return this.decorations=t.finish()}handleKey(r,e){const t=this.cm;let i=t.state.vim;if(!i)return;const n=xi.vimKeyFromEvent(r,i);if(ne.signal(this.cm,"inputEvent",{type:"handleKey",key:n}),!n)return;if(n=="<Esc>"&&!i.insertMode&&!i.visualMode&&this.query){const l=i.searchState_;l&&(t.removeOverlay(l.getOverlay()),l.setOverlay(null))}if(n==="<C-c>"&&!ne.isMac&&t.somethingSelected())return this.waitForCopy=!0,!0;i.status=(i.status||"")+n;let o=xi.multiSelectHandleKey(t,n,"user");return i=xi.maybeInitVimState_(t),!o&&i.insertMode&&t.state.overwrite&&(r.key&&r.key.length==1&&!/\n/.test(r.key)?(o=!0,t.overWriteSelection(r.key)):r.key=="Backspace"&&(o=!0,ne.commands.cursorCharLeft(t))),o&&(ne.signal(this.cm,"vim-keypress",n),r.preventDefault(),r.stopPropagation(),this.blockCursor.scheduleRedraw()),this.updateStatus(),!!o}},{eventHandlers:{copy:function(r,e){this.waitForCopy&&(this.waitForCopy=!1,Promise.resolve().then(()=>{var t=this.cm,i=t.state.vim;i&&(i.insertMode?t.setSelection(t.getCursor(),t.getCursor()):t.operation(()=>{t.curOp&&(t.curOp.isVimOp=!0),xi.handleKey(t,"<Esc>","user")}))}))},compositionstart:function(r,e){this.useNextTextInput=!0,ne.signal(this.cm,"inputEvent",r)},compositionupdate:function(r,e){ne.signal(this.cm,"inputEvent",r)},compositionend:function(r,e){ne.signal(this.cm,"inputEvent",r)},keypress:function(r,e){ne.signal(this.cm,"inputEvent",r),this.lastKeydown=="Dead"&&this.handleKey(r,e)},keydown:function(r,e){ne.signal(this.cm,"inputEvent",r),this.lastKeydown=r.key,this.lastKeydown=="Unidentified"||this.lastKeydown=="Process"||this.lastKeydown=="Dead"?this.useNextTextInput=!0:(this.useNextTextInput=!1,this.handleKey(r,e))}},provide:()=>[G.inputHandler.of((r,e,t,i)=>{var n,s,o=Nv(r);if(!o)return!1;var l=(n=o.state)===null||n===void 0?void 0:n.vim,h=o.state.vimPlugin;if(l&&!l.insertMode&&!(!((s=o.curOp)===null||s===void 0)&&s.isVimOp)){if(i==="\0\0")return!0;if(ne.signal(o,"inputEvent",{type:"text",text:i,from:e,to:t}),i.length==1&&h.useNextTextInput){if(l.expectLiteralNext&&r.composing)return h.compositionText=i,!1;if(h.compositionText){var u=h.compositionText;h.compositionText="";var p=r.state.selection.main.head,m=r.state.sliceDoc(p-u.length,p);if(u===m){var y=o.getCursor();o.replaceRange("",o.posFromIndex(p-u.length),y)}}return h.handleKey({key:i,preventDefault:()=>{},stopPropagation:()=>{}}),Dv(r),!0}}return!1})],decorations:r=>r.decorations});function Dv(r){var e=r.scrollDOM.parentElement;if(e){if(Tv){r.contentDOM.textContent="\0\0",r.contentDOM.dispatchEvent(new CustomEvent("compositionend"));return}var t=r.scrollDOM.nextSibling,i=window.getSelection(),n=i&&{anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset};r.scrollDOM.remove(),e.insertBefore(r.scrollDOM,t);try{n&&i&&(i.setPosition(n.anchorNode,n.anchorOffset),n.focusNode&&i.extend(n.focusNode,n.focusOffset))}catch(s){console.error(s)}r.focus(),r.contentDOM.dispatchEvent(new CustomEvent("compositionend"))}}const Rv=de.mark({class:"cm-searchMatch"}),Qu=me.define(),Ev=Ot.define({create:()=>!1,update(r,e){for(let t of e.effects)t.is(Qu)&&(r=t.value);return r},provide:r=>Lr.from(r,e=>e?Iv:null)});function Iv(r){let e=document.createElement("div");e.className="cm-vim-panel";let t=r.cm;return t.state.dialog&&e.appendChild(t.state.dialog),{top:!1,dom:e}}function Pv(r){let e=document.createElement("div");e.className="cm-vim-panel";let t=r.cm;return t.state.statusbar=e,t.state.vimPlugin.updateStatus(),{dom:e}}function cy(r={}){return[Lv,Bv,Cv,r.status?Lr.of(Pv):Ev]}function Nv(r){return r.cm||null}export{ey as $,zf as A,am as B,_v as C,Wr as D,$v as E,kt as F,nn as G,ry as H,ye as I,pe as J,zi as K,Ps as L,Qf as M,Hv as N,Br as O,wh as P,Jv as Q,fy as R,iy as S,mt as T,ny as U,Kv as V,zv as W,Fr as X,cy as Y,qv as Z,ay as _,pd as a,Uv as a0,hy as a1,uy as a2,wo as a3,Yv as b,sy as c,Yg as d,po as e,em as f,Xv as g,Zv as h,oy as i,Qv as j,hm as k,ty as l,ly as m,G as n,ct as o,I as p,Gg as q,nt as r,ad as s,$ as t,se as u,Ao as v,Ae as w,Wv as x,Tm as y,rn as z};
|