orcaq 1.0.21 → 1.0.23

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.
Files changed (211) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/_nuxt/{CrgoNCm2.js → 0fpkWcbi.js} +2 -2
  3. package/.output/public/_nuxt/{DL3T5jYo.js → B6lwWVI5.js} +1 -1
  4. package/.output/public/_nuxt/BGEWnlhd.js +1 -0
  5. package/.output/public/_nuxt/BUePl0lK.js +1 -0
  6. package/.output/public/_nuxt/BWeOEh4Z.js +14 -0
  7. package/.output/public/_nuxt/BXECqniz.js +1 -0
  8. package/.output/public/_nuxt/BYa7Vkmx.js +1 -0
  9. package/.output/public/_nuxt/BeC_ewNB.js +47 -0
  10. package/.output/public/_nuxt/BeL_GfX-.js +39 -0
  11. package/.output/public/_nuxt/{CuBKbBH_.js → BkhEpKzy.js} +1 -1
  12. package/.output/public/_nuxt/{BH83_dXo.js → C26aAkUg.js} +1 -1
  13. package/.output/public/_nuxt/C81RYsqJ.js +26 -0
  14. package/.output/public/_nuxt/CFtLQlpa.js +1 -0
  15. package/.output/public/_nuxt/CHae0Jiv.js +1 -0
  16. package/.output/public/_nuxt/{9lJACZIQ.js → CJER2x4r.js} +1 -1
  17. package/.output/public/_nuxt/{ICwM1E4-.js → CYqdSIe6.js} +3 -3
  18. package/.output/public/_nuxt/CcN517Ci.js +1 -0
  19. package/.output/public/_nuxt/CfqyI4g1.js +4 -0
  20. package/.output/public/_nuxt/CnIhd9IM.js +9 -0
  21. package/.output/public/_nuxt/Co87DPdr.js +18 -0
  22. package/.output/public/_nuxt/{pAheHeBV.js → CouqeYue.js} +8 -8
  23. package/.output/public/_nuxt/Cv3wRRZy.js +31 -0
  24. package/.output/public/_nuxt/{DXV2HFBA.js → CvXDjqNF.js} +1 -1
  25. package/.output/public/_nuxt/D0LmHvgn.js +13 -0
  26. package/.output/public/_nuxt/{ivUnXl9B.js → D2Hot6Qz.js} +1 -1
  27. package/.output/public/_nuxt/D5XzVg8o.js +1 -0
  28. package/.output/public/_nuxt/{Bq3cyzOD.js → DCGzl5t1.js} +1 -1
  29. package/.output/public/_nuxt/DGE1UZv7.js +1 -0
  30. package/.output/public/_nuxt/{BNjPC06x.js → DNVnfTwM.js} +1 -1
  31. package/.output/public/_nuxt/DV-vuGJt.js +1 -0
  32. package/.output/public/_nuxt/DVwaLKvw.js +5 -0
  33. package/.output/public/_nuxt/{C2HlI1ss.js → DcIs4zDC.js} +1 -1
  34. package/.output/public/_nuxt/{Bh6RgYlO.js → DcoZ0u0V.js} +1 -1
  35. package/.output/public/_nuxt/Dduxqd2M.js +1 -0
  36. package/.output/public/_nuxt/DroUt-ok.js +1 -0
  37. package/.output/public/_nuxt/{D8vj6kFe.js → DyUmhpWC.js} +11 -11
  38. package/.output/public/_nuxt/JGp8ZHkv.js +257 -0
  39. package/.output/public/_nuxt/KoN09pZ5.js +1 -0
  40. package/.output/public/_nuxt/builds/latest.json +1 -1
  41. package/.output/public/_nuxt/builds/meta/bbd2d18d-c265-48d2-a51b-1d563b817934.json +1 -0
  42. package/.output/public/_nuxt/cX_8SODe.js +1 -0
  43. package/.output/public/_nuxt/entry.SsrkN9_U.css +1 -0
  44. package/.output/public/_nuxt/{C25Tmn1m.js → jEcGO2vg.js} +1 -1
  45. package/.output/public/_nuxt/vt077W6w.js +1 -0
  46. package/.output/public/_nuxt/yruHU3cQ.js +1 -0
  47. package/.output/public/_nuxt/zeVrAOTr.js +8 -0
  48. package/.output/server/chunks/build/client.manifest.mjs +305 -296
  49. package/.output/server/chunks/build/client.manifest.mjs.map +1 -1
  50. package/.output/server/chunks/nitro/nitro.mjs +255 -241
  51. package/.output/server/node_modules/aws-ssl-profiles/lib/index.js +13 -0
  52. package/.output/server/node_modules/aws-ssl-profiles/lib/profiles/ca/defaults.js +2888 -0
  53. package/.output/server/node_modules/aws-ssl-profiles/lib/profiles/ca/proxies.js +111 -0
  54. package/.output/server/node_modules/aws-ssl-profiles/package.json +52 -0
  55. package/.output/server/node_modules/generate-function/index.js +181 -0
  56. package/.output/server/node_modules/generate-function/package.json +32 -0
  57. package/.output/server/node_modules/iconv-lite/encodings/dbcs-codec.js +597 -0
  58. package/.output/server/node_modules/iconv-lite/encodings/dbcs-data.js +188 -0
  59. package/.output/server/node_modules/iconv-lite/encodings/index.js +23 -0
  60. package/.output/server/node_modules/iconv-lite/encodings/internal.js +198 -0
  61. package/.output/server/node_modules/iconv-lite/encodings/sbcs-codec.js +72 -0
  62. package/.output/server/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
  63. package/.output/server/node_modules/iconv-lite/encodings/sbcs-data.js +179 -0
  64. package/.output/server/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
  65. package/.output/server/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
  66. package/.output/server/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
  67. package/.output/server/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
  68. package/.output/server/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
  69. package/.output/server/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
  70. package/.output/server/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
  71. package/.output/server/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
  72. package/.output/server/node_modules/iconv-lite/encodings/utf16.js +197 -0
  73. package/.output/server/node_modules/iconv-lite/encodings/utf32.js +319 -0
  74. package/.output/server/node_modules/iconv-lite/encodings/utf7.js +290 -0
  75. package/.output/server/node_modules/iconv-lite/lib/bom-handling.js +52 -0
  76. package/.output/server/node_modules/iconv-lite/lib/index.js +180 -0
  77. package/.output/server/node_modules/iconv-lite/lib/streams.js +109 -0
  78. package/.output/server/node_modules/iconv-lite/package.json +44 -0
  79. package/.output/server/node_modules/is-property/is-property.js +5 -0
  80. package/.output/server/node_modules/is-property/package.json +36 -0
  81. package/.output/server/node_modules/long/package.json +58 -0
  82. package/.output/server/node_modules/long/umd/index.js +1622 -0
  83. package/.output/server/node_modules/long/umd/package.json +3 -0
  84. package/.output/server/node_modules/lru.min/lib/index.js +231 -0
  85. package/.output/server/node_modules/lru.min/package.json +87 -0
  86. package/.output/server/node_modules/mysql2/index.js +77 -0
  87. package/.output/server/node_modules/mysql2/lib/auth_41.js +95 -0
  88. package/.output/server/node_modules/mysql2/lib/auth_plugins/caching_sha2_password.js +108 -0
  89. package/.output/server/node_modules/mysql2/lib/auth_plugins/index.js +8 -0
  90. package/.output/server/node_modules/mysql2/lib/auth_plugins/mysql_clear_password.js +17 -0
  91. package/.output/server/node_modules/mysql2/lib/auth_plugins/mysql_native_password.js +34 -0
  92. package/.output/server/node_modules/mysql2/lib/auth_plugins/sha256_password.js +68 -0
  93. package/.output/server/node_modules/mysql2/lib/base/connection.js +978 -0
  94. package/.output/server/node_modules/mysql2/lib/base/pool.js +237 -0
  95. package/.output/server/node_modules/mysql2/lib/base/pool_connection.js +70 -0
  96. package/.output/server/node_modules/mysql2/lib/commands/auth_switch.js +111 -0
  97. package/.output/server/node_modules/mysql2/lib/commands/binlog_dump.js +109 -0
  98. package/.output/server/node_modules/mysql2/lib/commands/change_user.js +68 -0
  99. package/.output/server/node_modules/mysql2/lib/commands/client_handshake.js +241 -0
  100. package/.output/server/node_modules/mysql2/lib/commands/close_statement.js +18 -0
  101. package/.output/server/node_modules/mysql2/lib/commands/command.js +54 -0
  102. package/.output/server/node_modules/mysql2/lib/commands/execute.js +112 -0
  103. package/.output/server/node_modules/mysql2/lib/commands/index.js +27 -0
  104. package/.output/server/node_modules/mysql2/lib/commands/ping.js +36 -0
  105. package/.output/server/node_modules/mysql2/lib/commands/prepare.js +143 -0
  106. package/.output/server/node_modules/mysql2/lib/commands/query.js +366 -0
  107. package/.output/server/node_modules/mysql2/lib/commands/quit.js +29 -0
  108. package/.output/server/node_modules/mysql2/lib/commands/register_slave.js +27 -0
  109. package/.output/server/node_modules/mysql2/lib/commands/server_handshake.js +203 -0
  110. package/.output/server/node_modules/mysql2/lib/compressed_protocol.js +127 -0
  111. package/.output/server/node_modules/mysql2/lib/connection.js +12 -0
  112. package/.output/server/node_modules/mysql2/lib/connection_config.js +294 -0
  113. package/.output/server/node_modules/mysql2/lib/constants/charset_encodings.js +316 -0
  114. package/.output/server/node_modules/mysql2/lib/constants/charsets.js +317 -0
  115. package/.output/server/node_modules/mysql2/lib/constants/client.js +39 -0
  116. package/.output/server/node_modules/mysql2/lib/constants/commands.js +36 -0
  117. package/.output/server/node_modules/mysql2/lib/constants/cursor.js +8 -0
  118. package/.output/server/node_modules/mysql2/lib/constants/encoding_charset.js +50 -0
  119. package/.output/server/node_modules/mysql2/lib/constants/errors.js +3973 -0
  120. package/.output/server/node_modules/mysql2/lib/constants/field_flags.js +20 -0
  121. package/.output/server/node_modules/mysql2/lib/constants/server_status.js +44 -0
  122. package/.output/server/node_modules/mysql2/lib/constants/session_track.js +11 -0
  123. package/.output/server/node_modules/mysql2/lib/constants/ssl_profiles.js +11 -0
  124. package/.output/server/node_modules/mysql2/lib/constants/types.js +64 -0
  125. package/.output/server/node_modules/mysql2/lib/create_connection.js +10 -0
  126. package/.output/server/node_modules/mysql2/lib/create_pool.js +10 -0
  127. package/.output/server/node_modules/mysql2/lib/create_pool_cluster.js +9 -0
  128. package/.output/server/node_modules/mysql2/lib/helpers.js +86 -0
  129. package/.output/server/node_modules/mysql2/lib/packet_parser.js +195 -0
  130. package/.output/server/node_modules/mysql2/lib/packets/auth_next_factor.js +35 -0
  131. package/.output/server/node_modules/mysql2/lib/packets/auth_switch_request.js +38 -0
  132. package/.output/server/node_modules/mysql2/lib/packets/auth_switch_request_more_data.js +33 -0
  133. package/.output/server/node_modules/mysql2/lib/packets/auth_switch_response.js +30 -0
  134. package/.output/server/node_modules/mysql2/lib/packets/binary_row.js +95 -0
  135. package/.output/server/node_modules/mysql2/lib/packets/binlog_dump.js +33 -0
  136. package/.output/server/node_modules/mysql2/lib/packets/binlog_query_statusvars.js +115 -0
  137. package/.output/server/node_modules/mysql2/lib/packets/change_user.js +97 -0
  138. package/.output/server/node_modules/mysql2/lib/packets/close_statement.js +21 -0
  139. package/.output/server/node_modules/mysql2/lib/packets/column_definition.js +291 -0
  140. package/.output/server/node_modules/mysql2/lib/packets/execute.js +214 -0
  141. package/.output/server/node_modules/mysql2/lib/packets/handshake.js +112 -0
  142. package/.output/server/node_modules/mysql2/lib/packets/handshake_response.js +144 -0
  143. package/.output/server/node_modules/mysql2/lib/packets/index.js +152 -0
  144. package/.output/server/node_modules/mysql2/lib/packets/packet.js +931 -0
  145. package/.output/server/node_modules/mysql2/lib/packets/prepare_statement.js +27 -0
  146. package/.output/server/node_modules/mysql2/lib/packets/prepared_statement_header.js +16 -0
  147. package/.output/server/node_modules/mysql2/lib/packets/query.js +27 -0
  148. package/.output/server/node_modules/mysql2/lib/packets/register_slave.js +46 -0
  149. package/.output/server/node_modules/mysql2/lib/packets/resultset_header.js +124 -0
  150. package/.output/server/node_modules/mysql2/lib/packets/ssl_request.js +25 -0
  151. package/.output/server/node_modules/mysql2/lib/packets/text_row.js +47 -0
  152. package/.output/server/node_modules/mysql2/lib/parsers/binary_parser.js +235 -0
  153. package/.output/server/node_modules/mysql2/lib/parsers/parser_cache.js +68 -0
  154. package/.output/server/node_modules/mysql2/lib/parsers/static_binary_parser.js +213 -0
  155. package/.output/server/node_modules/mysql2/lib/parsers/static_text_parser.js +152 -0
  156. package/.output/server/node_modules/mysql2/lib/parsers/string.js +50 -0
  157. package/.output/server/node_modules/mysql2/lib/parsers/text_parser.js +214 -0
  158. package/.output/server/node_modules/mysql2/lib/pool.js +12 -0
  159. package/.output/server/node_modules/mysql2/lib/pool_cluster.js +369 -0
  160. package/.output/server/node_modules/mysql2/lib/pool_config.js +30 -0
  161. package/.output/server/node_modules/mysql2/lib/pool_connection.js +12 -0
  162. package/.output/server/node_modules/mysql2/lib/promise/connection.js +222 -0
  163. package/.output/server/node_modules/mysql2/lib/promise/inherit_events.js +27 -0
  164. package/.output/server/node_modules/mysql2/lib/promise/make_done_cb.js +19 -0
  165. package/.output/server/node_modules/mysql2/lib/promise/pool.js +112 -0
  166. package/.output/server/node_modules/mysql2/lib/promise/pool_cluster.js +54 -0
  167. package/.output/server/node_modules/mysql2/lib/promise/pool_connection.js +19 -0
  168. package/.output/server/node_modules/mysql2/lib/promise/prepared_statement_info.js +32 -0
  169. package/.output/server/node_modules/mysql2/lib/server.js +37 -0
  170. package/.output/server/node_modules/mysql2/package.json +80 -0
  171. package/.output/server/node_modules/mysql2/promise.js +202 -0
  172. package/.output/server/node_modules/named-placeholders/index.js +179 -0
  173. package/.output/server/node_modules/named-placeholders/package.json +36 -0
  174. package/.output/server/node_modules/safer-buffer/package.json +34 -0
  175. package/.output/server/node_modules/safer-buffer/safer.js +77 -0
  176. package/.output/server/node_modules/seq-queue/index.js +1 -0
  177. package/.output/server/node_modules/seq-queue/lib/seq-queue.js +199 -0
  178. package/.output/server/node_modules/seq-queue/package.json +16 -0
  179. package/.output/server/node_modules/sqlstring/index.js +1 -0
  180. package/.output/server/node_modules/sqlstring/lib/SqlString.js +237 -0
  181. package/.output/server/node_modules/sqlstring/package.json +47 -0
  182. package/.output/server/package.json +12 -1
  183. package/package.json +1 -1
  184. package/.output/public/_nuxt/8qASMGdV.js +0 -1
  185. package/.output/public/_nuxt/B2DnNiWd.js +0 -1
  186. package/.output/public/_nuxt/BIKqrFbQ.js +0 -1
  187. package/.output/public/_nuxt/BPQ-Pz1w.js +0 -39
  188. package/.output/public/_nuxt/BRpgKkVT.js +0 -51
  189. package/.output/public/_nuxt/BTCLPbPY.js +0 -4
  190. package/.output/public/_nuxt/BUV-RarV.js +0 -1
  191. package/.output/public/_nuxt/Bt9sU68B.js +0 -9
  192. package/.output/public/_nuxt/BwpH2ZxJ.js +0 -1
  193. package/.output/public/_nuxt/CU3ZV9iV.js +0 -1
  194. package/.output/public/_nuxt/CbcyysXi.js +0 -1
  195. package/.output/public/_nuxt/CepyvMhE.js +0 -1
  196. package/.output/public/_nuxt/CulD8qYQ.js +0 -193
  197. package/.output/public/_nuxt/CylkLpwm.js +0 -1
  198. package/.output/public/_nuxt/D-bWLYHw.js +0 -1
  199. package/.output/public/_nuxt/D-zecHND.js +0 -1
  200. package/.output/public/_nuxt/DIETYtCL.js +0 -1
  201. package/.output/public/_nuxt/DJ4vUzxS.js +0 -1
  202. package/.output/public/_nuxt/DK-itzXx.js +0 -8
  203. package/.output/public/_nuxt/Dh2zppOR.js +0 -1
  204. package/.output/public/_nuxt/DlmSeCnw.js +0 -5
  205. package/.output/public/_nuxt/DswTpYG4.js +0 -1
  206. package/.output/public/_nuxt/G830WtVn.js +0 -1
  207. package/.output/public/_nuxt/QZbJy9YW.js +0 -31
  208. package/.output/public/_nuxt/UXhX8z2W.js +0 -1
  209. package/.output/public/_nuxt/builds/meta/03cede5c-c45c-41b3-ac1a-73756bb8cff0.json +0 -1
  210. package/.output/public/_nuxt/entry.GqPNPe1e.css +0 -1
  211. package/.output/public/_nuxt/s5fCn4j5.js +0 -1
@@ -1,2 +1,2 @@
1
- import{ck as y,cn as ve,co as V,cp as H,d0 as bt,d1 as S,cA as m,d2 as me,cm as b,cq as X,d3 as vt,d4 as R,d5 as U,d6 as St,d7 as w,cR as Ct,c8 as Bi,d8 as Y,d9 as Pi,cQ as ge,da as xn,db as yn,dc as At,dd as Ee,de as kn,cT as wt,cz as it,ci as Z,df as ce,cW as Ri,dg as Ii,dh as bn,di as se,cX as Oi,dj as vn,dk as Sn,dl as Je,dm as Ne,az as Ei,dn as Ni,dp as Fi,dq as zi,dr as Wi,cj as $i,cl as qi,ds as Ui,dt as ji,du as Gi,dv as Vi,dw as Re,dx as Hi}from"./CulD8qYQ.js";function x(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var s=t[i];typeof s=="string"?n.setAttribute(i,s):s!=null&&(n[i]=s)}e++}for(;e<arguments.length;e++)Cn(n,arguments[e]);return n}function Cn(n,e){if(typeof e=="string")n.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)n.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)Cn(n,e[t]);else throw new RangeError("Unsupported child node: "+e)}const zt=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n;class he{constructor(e,t,i=0,s=e.length,r,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,s),this.bufferStart=i,this.normalize=r?l=>r(zt(l)):zt,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 R(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=St(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=U(e);let s=this.normalize(t);if(s.length)for(let r=0,o=i;;r++){let l=s.charCodeAt(r),a=this.match(l,o,this.bufferPos+this.bufferStart);if(r==s.length-1){if(a)return this.value=a,this;break}o==i&&r<t.length&&t.charCodeAt(r)==l&&o++}}}match(e,t,i){let s=null;for(let r=0;r<this.matches.length;r+=2){let o=this.matches[r],l=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?s={from:this.matches[r+1],to:i}:(this.matches[r]++,l=!0)),l||(this.matches.splice(r,2),r-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?s={from:t,to:i}:this.matches.push(1,t)),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}typeof Symbol<"u"&&(he.prototype[Symbol.iterator]=function(){return this});const An={from:-1,to:-1,match:/.*/.exec("")},Mt="gm"+(/x/.unicode==null?"":"u");class wn{constructor(e,t,i,s=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=An,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Mn(e,t,i,s,r);this.re=new RegExp(t,Mt+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.iter=e.iter();let o=e.lineAt(s);this.curLineStart=o.from,this.matchPos=Fe(e,s),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,s=i+t[0].length;if(this.matchPos=Fe(this.text,s+(i==s?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<s||i>this.value.to)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,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 st=new WeakMap;class oe{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let s=st.get(e);if(!s||s.from>=i||s.to<=t){let l=new oe(t,e.sliceString(t,i));return st.set(e,l),l}if(s.from==t&&s.to==i)return s;let{text:r,from:o}=s;return o>t&&(r=e.sliceString(t,o)+r,o=t),s.to<i&&(r+=e.sliceString(s.to,i)),st.set(e,new oe(o,r)),new oe(t,r.slice(t-o,i-o))}}class Mn{constructor(e,t,i,s,r){this.text=e,this.to=r,this.done=!1,this.value=An,this.matchPos=Fe(e,s),this.re=new RegExp(t,Mt+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.flat=oe.get(e,s,this.chunkEnd(s+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,s=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,s,t)))return this.value={from:i,to:s,match:t},this.matchPos=Fe(this.text,s+(i==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=oe.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(wn.prototype[Symbol.iterator]=Mn.prototype[Symbol.iterator]=function(){return this});function Ki(n){try{return new RegExp(n,Mt),!0}catch{return!1}}function Fe(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e<t.to&&(i=t.text.charCodeAt(e-t.from))>=56320&&i<57344;)e++;return e}function ht(n){let e=String(n.state.doc.lineAt(n.state.selection.main.head).number),t=x("input",{class:"cm-textfield",name:"line",value:e}),i=x("form",{class:"cm-gotoLine",onkeydown:r=>{r.keyCode==27?(r.preventDefault(),n.dispatch({effects:pe.of(!1)}),n.focus()):r.keyCode==13&&(r.preventDefault(),s())},onsubmit:r=>{r.preventDefault(),s()}},x("label",n.state.phrase("Go to line"),": ",t)," ",x("button",{class:"cm-button",type:"submit"},n.state.phrase("go")),x("button",{name:"close",onclick:()=>{n.dispatch({effects:pe.of(!1)}),n.focus()},"aria-label":n.state.phrase("close"),type:"button"},["×"]));function s(){let r=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!r)return;let{state:o}=n,l=o.doc.lineAt(o.selection.main.head),[,a,c,h,f]=r,u=h?+h.slice(1):0,d=c?+c:l.number;if(c&&f){let C=d/100;a&&(C=C*(a=="-"?-1:1)+l.number/o.doc.lines),d=Math.round(o.doc.lines*C)}else c&&a&&(d=d*(a=="-"?-1:1)+l.number);let p=o.doc.line(Math.max(1,Math.min(o.doc.lines,d))),g=m.cursor(p.from+Math.max(0,Math.min(u,p.length)));n.dispatch({effects:[pe.of(!1),y.scrollIntoView(g.from,{y:"center"})],selection:g}),n.focus()}return{dom:i}}const pe=S.define(),Wt=H.define({create(){return!0},update(n,e){for(let t of e.effects)t.is(pe)&&(n=t.value);return n},provide:n=>vt.from(n,e=>e?ht:null)}),Ji=n=>{let e=me(n,ht);if(!e){let t=[pe.of(!0)];n.state.field(Wt,!1)==null&&t.push(S.appendConfig.of([Wt,Qi])),n.dispatch({effects:t}),e=me(n,ht)}return e&&e.dom.querySelector("input").select(),!0},Qi=y.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),_i={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Yi=V.define({combine(n){return X(n,_i,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function $o(n){return[ns,ts]}const Xi=b.mark({class:"cm-selectionMatch"}),Zi=b.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function $t(n,e,t,i){return(t==0||n(e.sliceDoc(t-1,t))!=w.Word)&&(i==e.doc.length||n(e.sliceDoc(i,i+1))!=w.Word)}function es(n,e,t,i){return n(e.sliceDoc(t,t+1))==w.Word&&n(e.sliceDoc(i-1,i))==w.Word}const ts=ve.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(Yi),{state:t}=n,i=t.selection;if(i.ranges.length>1)return b.none;let s=i.main,r,o=null;if(s.empty){if(!e.highlightWordAroundCursor)return b.none;let a=t.wordAt(s.head);if(!a)return b.none;o=t.charCategorizer(s.head),r=t.sliceDoc(a.from,a.to)}else{let a=s.to-s.from;if(a<e.minSelectionLength||a>200)return b.none;if(e.wholeWords){if(r=t.sliceDoc(s.from,s.to),o=t.charCategorizer(s.head),!($t(o,t,s.from,s.to)&&es(o,t,s.from,s.to)))return b.none}else if(r=t.sliceDoc(s.from,s.to),!r)return b.none}let l=[];for(let a of n.visibleRanges){let c=new he(t.doc,r,a.from,a.to);for(;!c.next().done;){let{from:h,to:f}=c.value;if((!o||$t(o,t,h,f))&&(s.empty&&h<=s.from&&f>=s.to?l.push(Zi.range(h,f)):(h>=s.to||f<=s.from)&&l.push(Xi.range(h,f)),l.length>e.maxMatches))return b.none}}return b.set(l)}},{decorations:n=>n.decorations}),ns=y.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),is=({state:n,dispatch:e})=>{let{selection:t}=n,i=m.create(t.ranges.map(s=>n.wordAt(s.head)||m.cursor(s.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function ss(n,e){let{main:t,ranges:i}=n.selection,s=n.wordAt(t.head),r=s&&s.from==t.from&&s.to==t.to;for(let o=!1,l=new he(n.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new he(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(a=>a.from==l.value.from))continue;if(r){let a=n.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}const rs=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(r=>r.from===r.to))return is({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(r=>n.sliceDoc(r.from,r.to)!=i))return!1;let s=ss(n,i);return s?(e(n.update({selection:n.selection.addRange(m.range(s.from,s.to),!1),effects:y.scrollIntoView(s.to)})),!0):!1},ee=V.define({combine(n){return X(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new gs(e),scrollToMatch:e=>y.scrollIntoView(e)})}});function qo(n){return n?[ee.of(n),ut]:ut}class Tn{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||Ki(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?`
2
- `: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}create(){return this.regexp?new cs(this):new ls(this)}getCursor(e,t=0,i){let s=e.doc?e:Bi.create({doc:e});return i==null&&(i=s.doc.length),this.regexp?ie(this,s,t,i):ne(this,s,t,i)}}class Ln{constructor(e){this.spec=e}}function ne(n,e,t,i){return new he(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:s=>s.toLowerCase(),n.wholeWord?os(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function os(n,e){return(t,i,s,r)=>((r>t||r+s.length<i)&&(r=Math.max(0,t-2),s=n.sliceString(r,Math.min(n.length,i+2))),(e(ze(s,t-r))!=w.Word||e(We(s,t-r))!=w.Word)&&(e(We(s,i-r))!=w.Word||e(ze(s,i-r))!=w.Word))}class ls extends Ln{constructor(e){super(e)}nextMatch(e,t,i){let s=ne(this.spec,e,i,e.doc.length).nextOverlapping();if(s.done){let r=Math.min(e.doc.length,t+this.spec.unquoted.length);s=ne(this.spec,e,0,r).nextOverlapping()}return s.done||s.value.from==t&&s.value.to==i?null:s.value}prevMatchInRange(e,t,i){for(let s=i;;){let r=Math.max(t,s-1e4-this.spec.unquoted.length),o=ne(this.spec,e,r,s),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(r==t)return null;s-=1e4}}prevMatch(e,t,i){let s=this.prevMatchInRange(e,0,t);return s||(s=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),s&&(s.from!=t||s.to!=i)?s:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=ne(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=ne(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}function ie(n,e,t,i){return new wn(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:n.wholeWord?as(e.charCategorizer(e.selection.main.head)):void 0},t,i)}function ze(n,e){return n.slice(Y(n,e,!1),e)}function We(n,e){return n.slice(e,Y(n,e))}function as(n){return(e,t,i)=>!i[0].length||(n(ze(i.input,i.index))!=w.Word||n(We(i.input,i.index))!=w.Word)&&(n(We(i.input,i.index+i[0].length))!=w.Word||n(ze(i.input,i.index+i[0].length))!=w.Word)}class cs extends Ln{nextMatch(e,t,i){let s=ie(this.spec,e,i,e.doc.length).next();return s.done&&(s=ie(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=1;;s++){let r=Math.max(t,i-s*1e4),o=ie(this.spec,e,r,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(r==t||l.from>r+10))return l;if(r==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 s=i.length;s>0;s--){let r=+i.slice(0,s);if(r>0&&r<e.match.length)return e.match[r]+i.slice(s)}return t})}matchAll(e,t){let i=ie(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=ie(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}const xe=S.define(),Tt=S.define(),G=H.define({create(n){return new rt(ft(n).create(),null)},update(n,e){for(let t of e.effects)t.is(xe)?n=new rt(t.value.create(),n.panel):t.is(Tt)&&(n=new rt(n.query,t.value?Lt:null));return n},provide:n=>vt.from(n,e=>e.panel)});class rt{constructor(e,t){this.query=e,this.panel=t}}const hs=b.mark({class:"cm-searchMatch"}),fs=b.mark({class:"cm-searchMatch cm-searchMatch-selected"}),us=ve.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(G))}update(n){let e=n.state.field(G);(e!=n.startState.field(G)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return b.none;let{view:t}=this,i=new Ct;for(let s=0,r=t.visibleRanges,o=r.length;s<o;s++){let{from:l,to:a}=r[s];for(;s<o-1&&a>r[s+1].from-2*250;)a=r[++s].to;n.highlight(t.state,l,a,(c,h)=>{let f=t.state.selection.ranges.some(u=>u.from==c&&u.to==h);i.add(c,h,f?fs:hs)})}return i.finish()}},{decorations:n=>n.decorations});function Se(n){return e=>{let t=e.state.field(G,!1);return t&&t.query.spec.valid?n(e,t):Pn(e)}}const $e=Se((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let s=m.single(i.from,i.to),r=n.state.facet(ee);return n.dispatch({selection:s,effects:[Dt(n,i),r.scrollToMatch(s.main,n)],userEvent:"select.search"}),Bn(n),!0}),qe=Se((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,s=e.prevMatch(t,i,i);if(!s)return!1;let r=m.single(s.from,s.to),o=n.state.facet(ee);return n.dispatch({selection:r,effects:[Dt(n,s),o.scrollToMatch(r.main,n)],userEvent:"select.search"}),Bn(n),!0}),ds=Se((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:m.create(t.map(i=>m.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),ps=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:s}=t.main,r=[],o=0;for(let l=new he(n.doc,n.sliceDoc(i,s));!l.next().done;){if(r.length>1e3)return!1;l.value.from==i&&(o=r.length),r.push(m.range(l.value.from,l.value.to))}return e(n.update({selection:m.create(r,o),userEvent:"select.search.matches"})),!0},qt=Se((n,{query:e})=>{let{state:t}=n,{from:i,to:s}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,i,i);if(!r)return!1;let o=r,l=[],a,c,h=[];if(o.from==i&&o.to==s&&(c=t.toText(e.getReplacement(o)),l.push({from:o.from,to:o.to,insert:c}),o=e.nextMatch(t,o.from,o.to),h.push(y.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))),o){let f=l.length==0||l[0].from>=r.to?0:r.to-r.from-c.length;a=m.single(o.from-f,o.to-f),h.push(Dt(n,o)),h.push(t.facet(ee).scrollToMatch(a.main,n))}return n.dispatch({changes:l,selection:a,effects:h,userEvent:"input.replace"}),!0}),ms=Se((n,{query:e})=>{if(n.state.readOnly)return!1;let t=e.matchAll(n.state,1e9).map(s=>{let{from:r,to:o}=s;return{from:r,to:o,insert:e.getReplacement(s)}});if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:y.announce.of(i),userEvent:"input.replace.all"}),!0});function Lt(n){return n.state.facet(ee).createPanel(n)}function ft(n,e){var t,i,s,r,o;let l=n.selection.main,a=l.empty||l.to>l.from+100?"":n.sliceDoc(l.from,l.to);if(e&&!a)return e;let c=n.facet(ee);return new Tn({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:c.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=e==null?void 0:e.caseSensitive)!==null&&i!==void 0?i:c.caseSensitive,literal:(s=e==null?void 0:e.literal)!==null&&s!==void 0?s:c.literal,regexp:(r=e==null?void 0:e.regexp)!==null&&r!==void 0?r:c.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:c.wholeWord})}function Dn(n){let e=me(n,Lt);return e&&e.dom.querySelector("[main-field]")}function Bn(n){let e=Dn(n);e&&e==n.root.activeElement&&e.select()}const Pn=n=>{let e=n.state.field(G,!1);if(e&&e.panel){let t=Dn(n);if(t&&t!=n.root.activeElement){let i=ft(n.state,e.query.spec);i.valid&&n.dispatch({effects:xe.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[Tt.of(!0),e?xe.of(ft(n.state,e.query.spec)):S.appendConfig.of(ut)]});return!0},Rn=n=>{let e=n.state.field(G,!1);if(!e||!e.panel)return!1;let t=me(n,Lt);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Tt.of(!1)}),!0},Uo=[{key:"Mod-f",run:Pn,scope:"editor search-panel"},{key:"F3",run:$e,shift:qe,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:$e,shift:qe,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Rn,scope:"editor search-panel"},{key:"Mod-Shift-l",run:ps},{key:"Mod-Alt-g",run:Ji},{key:"Mod-d",run:rs,preventDefault:!0}];class gs{constructor(e){this.view=e;let t=this.query=e.state.field(G).query.spec;this.commit=this.commit.bind(this),this.searchField=x("input",{value:t.search,placeholder:B(e,"Find"),"aria-label":B(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=x("input",{value:t.replace,placeholder:B(e,"Replace"),"aria-label":B(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=x("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=x("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=x("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(s,r,o){return x("button",{class:"cm-button",name:s,onclick:r,type:"button"},o)}this.dom=x("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,i("next",()=>$e(e),[B(e,"next")]),i("prev",()=>qe(e),[B(e,"previous")]),i("select",()=>ds(e),[B(e,"all")]),x("label",null,[this.caseField,B(e,"match case")]),x("label",null,[this.reField,B(e,"regexp")]),x("label",null,[this.wordField,B(e,"by word")]),...e.state.readOnly?[]:[x("br"),this.replaceField,i("replace",()=>qt(e),[B(e,"replace")]),i("replaceAll",()=>ms(e),[B(e,"replace all")])],x("button",{name:"close",onclick:()=>Rn(e),"aria-label":B(e,"close"),type:"button"},["×"])])}commit(){let e=new Tn({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:xe.of(e)}))}keydown(e){Pi(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?qe:$e)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),qt(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(xe)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(ee).top}}function B(n,e){return n.state.phrase(e)}const we=30,Me=/[\s\.,:;?!]/;function Dt(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),s=n.state.doc.lineAt(t).to,r=Math.max(i.from,e-we),o=Math.min(s,t+we),l=n.state.sliceDoc(r,o);if(r!=i.from){for(let a=0;a<we;a++)if(!Me.test(l[a+1])&&Me.test(l[a])){l=l.slice(a);break}}if(o!=s){for(let a=l.length-1;a>l.length-we;a--)if(!Me.test(l[a-1])&&Me.test(l[a])){l=l.slice(0,a);break}}return y.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}const xs=y.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),ut=[G,bt.low(us),xs];function ys(n,e=n.state){const t=new Set;for(const{from:i,to:s}of n.visibleRanges){let r=i;for(;r<=s;){const o=e.doc.lineAt(r);t.has(o)||t.add(o),r=o.to+1}}return t}function dt(n){const e=n.selection.main.head;return n.doc.lineAt(e)}function Ut(n,e){let t=0;e:for(let i=0;i<n.length;i++)switch(n[i]){case" ":case" ":{t+=1;continue e}case" ":{t+=e-t%e;continue e}case"\r":continue e;default:break e}return t}const Ue=V.define({combine(n){return X(n,{highlightActiveBlock:!0,hideFirstIndent:!1,markerType:"fullScope",thickness:1})}});class ks{constructor(e,t,i,s){this.lines=e,this.state=t,this.map=new Map,this.unitWidth=i,this.markerType=s;for(const r of this.lines)this.add(r);this.state.facet(Ue).highlightActiveBlock&&this.findAndSetActiveLines()}has(e){return this.map.has(typeof e=="number"?e:e.number)}get(e){const t=this.map.get(typeof e=="number"?e:e.number);if(!t)throw new Error("Line not found in indentation map");return t}set(e,t,i){const s=!e.text.trim().length,r={line:e,col:t,level:i,empty:s};return this.map.set(r.line.number,r),r}add(e){if(this.has(e))return this.get(e);if(!e.length||!e.text.trim().length){if(e.number===1)return this.set(e,0,0);if(e.number===this.state.doc.lines){const o=this.closestNonEmpty(e,-1);return this.set(e,0,o.level)}const s=this.closestNonEmpty(e,-1),r=this.closestNonEmpty(e,1);return s.level>=r.level&&this.markerType!=="codeOnly"?this.set(e,0,s.level):s.empty&&s.level===0&&r.level!==0?this.set(e,0,0):r.level>s.level?this.set(e,0,s.level+1):this.set(e,0,r.level)}const t=Ut(e.text,this.state.tabSize),i=Math.floor(t/this.unitWidth);return this.set(e,t,i)}closestNonEmpty(e,t){let i=e.number+t;for(;t===-1?i>=1:i<=this.state.doc.lines;){if(this.has(i)){const o=this.get(i);if(!o.empty)return o}const r=this.state.doc.line(i);if(r.text.trim().length){const o=Ut(r.text,this.state.tabSize),l=Math.floor(o/this.unitWidth);return this.set(r,o,l)}i+=t}const s=this.state.doc.line(t===-1?1:this.state.doc.lines);return this.set(s,0,0)}findAndSetActiveLines(){const e=dt(this.state);if(!this.has(e))return;let t=this.get(e);if(this.has(t.line.number+1)){const r=this.get(t.line.number+1);r.level>t.level&&(t=r)}if(this.has(t.line.number-1)){const r=this.get(t.line.number-1);r.level>t.level&&(t=r)}if(t.level===0)return;t.active=t.level;let i,s;for(i=t.line.number;i>1;i--){if(!this.has(i-1))continue;const r=this.get(i-1);if(r.level<t.level)break;r.active=t.level}for(s=t.line.number;s<this.state.doc.lines;s++){if(!this.has(s+1))continue;const r=this.get(s+1);if(r.level<t.level)break;r.active=t.level}}}function bs(n){const e={light:"#F0F1F2",dark:"#2B3245",activeLight:"#E4E5E6",activeDark:"#3C445C"};let t=e;return n&&(t=Object.assign(Object.assign({},e),n)),y.baseTheme({"&light":{"--indent-marker-bg-color":t.light,"--indent-marker-active-bg-color":t.activeLight},"&dark":{"--indent-marker-bg-color":t.dark,"--indent-marker-active-bg-color":t.activeDark},".cm-line":{position:"relative"},".cm-indent-markers::before":{content:'""',position:"absolute",top:0,left:"2px",right:0,bottom:0,background:"var(--indent-markers)",pointerEvents:"none",zIndex:"-1"}})}function Te(n,e,t,i,s){return`${`repeating-linear-gradient(to right, var(${n}) 0 ${e}px, transparent ${e}px ${t}ch)`} ${i*t}.5ch/calc(${t*s}ch - 1px) no-repeat`}function vs(n,e,t,i,s){const{level:r,active:o}=n;if(s=s??i,t&&r===0)return[];const l=t?1:0,a=[];if(o!==void 0){const c=o-l-1;c>0&&a.push(Te("--indent-marker-bg-color",i,e,l,c)),a.push(Te("--indent-marker-active-bg-color",s,e,o-1,1)),o!==r&&a.push(Te("--indent-marker-bg-color",i,e,o,r-o))}else a.push(Te("--indent-marker-bg-color",i,e,l,r-l));return a.join(",")}class Ss{constructor(e){this.view=e,this.unitWidth=ge(e.state),this.currentLineNumber=dt(e.state).number,this.generate(e.state)}update(e){const t=ge(e.state),i=t!==this.unitWidth;i&&(this.unitWidth=t);const s=dt(e.state).number,r=s!==this.currentLineNumber;this.currentLineNumber=s;const o=e.state.facet(Ue).highlightActiveBlock&&r;(e.docChanged||e.viewportChanged||i||o)&&this.generate(e.state)}generate(e){const t=new Ct,i=ys(this.view,e),{hideFirstIndent:s,markerType:r,thickness:o,activeThickness:l}=e.facet(Ue),a=new ks(i,e,this.unitWidth,r);for(const c of i){const h=a.get(c.number);if(!(h!=null&&h.level))continue;const f=vs(h,this.unitWidth,s,o,l);t.add(c.from,c.from,b.line({class:"cm-indent-markers",attributes:{style:`--indent-markers: ${f}`}}))}this.decorations=t.finish()}}function jo(n={}){return[Ue.of(n),bs(n.colors),ve.fromClass(Ss,{decorations:e=>e.decorations})]}const Cs=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=Pt(n.state,t.from);return i.line?As(n):i.block?Ms(n):!1};function Bt(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let s=n(e,t);return s?(i(t.update(s)),!0):!1}}const As=Bt(Ds,0),ws=Bt(In,0),Ms=Bt((n,e)=>In(n,e,Ls(e)),0);function Pt(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const de=50;function Ts(n,{open:e,close:t},i,s){let r=n.sliceDoc(i-de,i),o=n.sliceDoc(s,s+de),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,c=r.length-l;if(r.slice(c-e.length,c)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:s+a,margin:a&&1}};let h,f;s-i<=2*de?h=f=n.sliceDoc(i,s):(h=n.sliceDoc(i,i+de),f=n.sliceDoc(s-de,s));let u=/^\s*/.exec(h)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-t.length;return h.slice(u,u+e.length)==e&&f.slice(p,p+t.length)==t?{open:{pos:i+u+e.length,margin:/\s/.test(h.charAt(u+e.length))?1:0},close:{pos:s-d-t.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function Ls(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),s=t.to<=i.to?i:n.doc.lineAt(t.to);s.from>i.from&&s.from==t.to&&(s=t.to==i.to+1?i:n.doc.lineAt(t.to-1));let r=e.length-1;r>=0&&e[r].to>i.from?e[r].to=s.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:s.to})}return e}function In(n,e,t=e.selection.ranges){let i=t.map(r=>Pt(e,r.from).block);if(!i.every(r=>r))return null;let s=t.map((r,o)=>Ts(e,i[o],r.from,r.to));if(n!=2&&!s.every(r=>r))return{changes:e.changes(t.map((r,o)=>s[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(n!=1&&s.some(r=>r)){let r=[];for(let o=0,l;o<s.length;o++)if(l=s[o]){let a=i[o],{open:c,close:h}=l;r.push({from:c.pos-a.open.length,to:c.pos+c.margin},{from:h.pos-h.margin,to:h.pos+a.close.length})}return{changes:r}}return null}function Ds(n,e,t=e.selection.ranges){let i=[],s=-1;for(let{from:r,to:o}of t){let l=i.length,a=1e9,c=Pt(e,r).line;if(c){for(let h=r;h<=o;){let f=e.doc.lineAt(h);if(f.from>s&&(r==o||o>f.from)){s=f.from;let u=/^\s*/.exec(f.text)[0].length,d=u==f.length,p=f.text.slice(u,u+c.length)==c?u:-1;u<f.text.length&&u<a&&(a=u),i.push({line:f,comment:p,token:c,indent:u,empty:d,single:!1})}h=f.to+1}if(a<1e9)for(let h=l;h<i.length;h++)i[h].indent<i[h].line.text.length&&(i[h].indent=a);i.length==l+1&&(i[l].single=!0)}}if(n!=2&&i.some(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:c,empty:h,single:f}of i)(f||!h)&&r.push({from:l.from+c,insert:a+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let c=o.from+l,h=c+a.length;o.text[h-o.from]==" "&&h++,r.push({from:c,to:h})}return{changes:r}}return null}const pt=wt.define(),Bs=wt.define(),Ps=V.define(),On=V.define({combine(n){return X(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,s)=>e(i,s)||t(i,s)})}}),En=H.define({create(){return F.empty},update(n,e){let t=e.state.facet(On),i=e.annotation(pt);if(i){let a=D.fromTransaction(e,i.selection),c=i.side,h=c==0?n.undone:n.done;return a?h=je(h,h.length,t.minDepth,a):h=zn(h,e.startState.selection),new F(c==0?i.rest:h,c==0?h:i.rest)}let s=e.annotation(Bs);if((s=="full"||s=="before")&&(n=n.isolate()),e.annotation(it.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let r=D.fromTransaction(e),o=e.annotation(it.time),l=e.annotation(it.userEvent);return r?n=n.addChanges(r,o,l,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(s=="full"||s=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new F(n.done.map(D.fromJSON),n.undone.map(D.fromJSON))}});function Go(n={}){return[En,On.of(n),y.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?Nn:e.inputType=="historyRedo"?mt:null;return i?(e.preventDefault(),i(t)):!1}})]}function Qe(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let s=t.field(En,!1);if(!s)return!1;let r=s.pop(n,t,e);return r?(i(r),!0):!1}}const Nn=Qe(0,!1),mt=Qe(1,!1),Rs=Qe(0,!0),Is=Qe(1,!0);class D{constructor(e,t,i,s,r){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=s,this.selectionsAfter=r}setSelAfter(e){return new D(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(s=>s.toJSON())}}static fromJSON(e){return new D(e.changes&&Ri.fromJSON(e.changes),[],e.mapped&&Ii.fromJSON(e.mapped),e.startSelection&&m.fromJSON(e.startSelection),e.selectionsAfter.map(m.fromJSON))}static fromTransaction(e,t){let i=I;for(let s of e.startState.facet(Ps)){let r=s(e);r.length&&(i=i.concat(r))}return!i.length&&e.changes.empty?null:new D(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,I)}static selection(e){return new D(void 0,I,void 0,void 0,e)}}function je(n,e,t,i){let s=e+1>t+20?e-t-1:0,r=n.slice(s,e);return r.push(i),r}function Os(n,e){let t=[],i=!1;return n.iterChangedRanges((s,r)=>t.push(s,r)),e.iterChangedRanges((s,r,o,l)=>{for(let a=0;a<t.length;){let c=t[a++],h=t[a++];l>=c&&o<=h&&(i=!0)}}),i}function Es(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function Fn(n,e){return n.length?e.length?n.concat(e):n:e}const I=[],Ns=200;function zn(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-Ns));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),je(n,n.length-1,1e9,t.setSelAfter(i)))}else return[D.selection([e])]}function Fs(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function ot(n,e){if(!n.length)return n;let t=n.length,i=I;for(;t;){let s=zs(n[t-1],e,i);if(s.changes&&!s.changes.empty||s.effects.length){let r=n.slice(0,t);return r[t-1]=s,r}else e=s.mapped,t--,i=s.selectionsAfter}return i.length?[D.selection(i)]:I}function zs(n,e,t){let i=Fn(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):I,t);if(!n.changes)return D.selection(i);let s=n.changes.map(e),r=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(r):r;return new D(s,S.mapEffects(n.effects,e),o,n.startSelection.map(r),i)}const Ws=/^(input\.type|delete)($|\.)/;class F{constructor(e,t,i=0,s=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=s}isolate(){return this.prevTime?new F(this.done,this.undone):this}addChanges(e,t,i,s,r){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||Ws.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<s.newGroupDelay&&s.joinToEvent(r,Os(l.changes,e.changes))||i=="input.type.compose")?o=je(o,o.length-1,s.minDepth,new D(e.changes.compose(l.changes),Fn(S.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,I)):o=je(o,o.length,s.minDepth,e),new F(o,I,t,i)}addSelection(e,t,i,s){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:I;return r.length>0&&t-this.prevTime<s&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&Es(r[r.length-1],e)?this:new F(zn(this.done,e),this.undone,t,i)}addMapping(e){return new F(ot(this.done,e),ot(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let s=e==0?this.done:this.undone;if(s.length==0)return null;let r=s[s.length-1],o=r.selectionsAfter[0]||t.selection;if(i&&r.selectionsAfter.length)return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:pt.of({side:e,rest:Fs(s),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let l=s.length==1?I:s.slice(0,s.length-1);return r.mapped&&(l=ot(l,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:pt.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}F.empty=new F(I,I);const Vo=[{key:"Mod-z",run:Nn,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:mt,preventDefault:!0},{linux:"Ctrl-Shift-z",run:mt,preventDefault:!0},{key:"Mod-u",run:Rs,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Is,preventDefault:!0}];function ue(n,e){return m.create(n.ranges.map(e),n.mainIndex)}function W(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function N({state:n,dispatch:e},t){let i=ue(n.selection,t);return i.eq(n.selection,!0)?!1:(e(W(n,i)),!0)}function _e(n,e){return m.cursor(e?n.to:n.from)}function Wn(n,e){return N(n,t=>t.empty?n.moveByChar(t,e):_e(t,e))}function A(n){return n.textDirectionAt(n.state.selection.main.head)==bn.LTR}const $n=n=>Wn(n,!A(n)),qn=n=>Wn(n,A(n));function Un(n,e){return N(n,t=>t.empty?n.moveByGroup(t,e):_e(t,e))}const $s=n=>Un(n,!A(n)),qs=n=>Un(n,A(n));function Us(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function Ye(n,e,t){let i=Z(n).resolveInner(e.head),s=t?ce.closedBy:ce.openedBy;for(let a=e.head;;){let c=t?i.childAfter(a):i.childBefore(a);if(!c)break;Us(n,c,s)?i=c:a=t?c.to:c.from}let r=i.type.prop(s),o,l;return r&&(o=t?se(n,i.from,1):se(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,m.cursor(l,t?-1:1)}const js=n=>N(n,e=>Ye(n.state,e,!A(n))),Gs=n=>N(n,e=>Ye(n.state,e,A(n)));function jn(n,e){return N(n,t=>{if(!t.empty)return _e(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}const Gn=n=>jn(n,!1),Vn=n=>jn(n,!0);function Hn(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,i=0,s;if(e){for(let r of n.state.facet(y.scrollMargins)){let o=r(n);o!=null&&o.top&&(t=Math.max(o==null?void 0:o.top,t)),o!=null&&o.bottom&&(i=Math.max(o==null?void 0:o.bottom,i))}s=n.scrollDOM.clientHeight-t-i}else s=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(n.defaultLineHeight,s-5)}}function Kn(n,e){let t=Hn(n),{state:i}=n,s=ue(i.selection,o=>o.empty?n.moveVertically(o,e,t.height):_e(o,e));if(s.eq(i.selection))return!1;let r;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),l=n.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,c=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<c&&(r=y.scrollIntoView(s.main.head,{y:"start",yMargin:o.top-a}))}return n.dispatch(W(i,s),{effects:r}),!0}const jt=n=>Kn(n,!1),gt=n=>Kn(n,!0);function K(n,e,t){let i=n.lineBlockAt(e.head),s=n.moveToLineBoundary(e,t);if(s.head==e.head&&s.head!=(t?i.to:i.from)&&(s=n.moveToLineBoundary(e,t,!1)),!t&&s.head==i.from&&i.length){let r=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&e.head!=i.from+r&&(s=m.cursor(i.from+r))}return s}const Vs=n=>N(n,e=>K(n,e,!0)),Hs=n=>N(n,e=>K(n,e,!1)),Ks=n=>N(n,e=>K(n,e,!A(n))),Js=n=>N(n,e=>K(n,e,A(n))),Qs=n=>N(n,e=>m.cursor(n.lineBlockAt(e.head).from,1)),_s=n=>N(n,e=>m.cursor(n.lineBlockAt(e.head).to,-1));function Ys(n,e,t){let i=!1,s=ue(n.selection,r=>{let o=se(n,r.head,-1)||se(n,r.head,1)||r.head>0&&se(n,r.head-1,1)||r.head<n.doc.length&&se(n,r.head+1,-1);if(!o||!o.end)return r;i=!0;let l=o.start.from==r.head?o.end.to:o.end.from;return m.cursor(l)});return i?(e(W(n,s)),!0):!1}const Xs=({state:n,dispatch:e})=>Ys(n,e);function E(n,e){let t=ue(n.state.selection,i=>{let s=e(i);return m.range(i.anchor,s.head,s.goalColumn,s.bidiLevel||void 0)});return t.eq(n.state.selection)?!1:(n.dispatch(W(n.state,t)),!0)}function Jn(n,e){return E(n,t=>n.moveByChar(t,e))}const Qn=n=>Jn(n,!A(n)),_n=n=>Jn(n,A(n));function Yn(n,e){return E(n,t=>n.moveByGroup(t,e))}const Zs=n=>Yn(n,!A(n)),er=n=>Yn(n,A(n)),tr=n=>E(n,e=>Ye(n.state,e,!A(n))),nr=n=>E(n,e=>Ye(n.state,e,A(n)));function Xn(n,e){return E(n,t=>n.moveVertically(t,e))}const Zn=n=>Xn(n,!1),ei=n=>Xn(n,!0);function ti(n,e){return E(n,t=>n.moveVertically(t,e,Hn(n).height))}const Gt=n=>ti(n,!1),Vt=n=>ti(n,!0),ir=n=>E(n,e=>K(n,e,!0)),sr=n=>E(n,e=>K(n,e,!1)),rr=n=>E(n,e=>K(n,e,!A(n))),or=n=>E(n,e=>K(n,e,A(n))),lr=n=>E(n,e=>m.cursor(n.lineBlockAt(e.head).from)),ar=n=>E(n,e=>m.cursor(n.lineBlockAt(e.head).to)),Ht=({state:n,dispatch:e})=>(e(W(n,{anchor:0})),!0),Kt=({state:n,dispatch:e})=>(e(W(n,{anchor:n.doc.length})),!0),Jt=({state:n,dispatch:e})=>(e(W(n,{anchor:n.selection.main.anchor,head:0})),!0),Qt=({state:n,dispatch:e})=>(e(W(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),cr=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),hr=({state:n,dispatch:e})=>{let t=Xe(n).map(({from:i,to:s})=>m.range(i,Math.min(s+1,n.doc.length)));return e(n.update({selection:m.create(t),userEvent:"select"})),!0},fr=({state:n,dispatch:e})=>{let t=ue(n.selection,i=>{let s=Z(n),r=s.resolveStack(i.from,1);if(i.empty){let o=s.resolveStack(i.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;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 m.range(l.to,l.from)}return i});return t.eq(n.selection)?!1:(e(W(n,t)),!0)},ur=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=m.create([t.main]):t.main.empty||(i=m.create([m.cursor(t.main.head)])),i?(e(W(n,i)),!0):!1};function Ce(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,s=i.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=e(r);a<o?(t="delete.backward",a=Le(n,a,!1)):a>o&&(t="delete.forward",a=Le(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Le(n,o,!1),l=Le(n,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:m.cursor(o,o<r.head?-1:1)}});return s.changes.empty?!1:(n.dispatch(i.update(s,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?y.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Le(n,e,t){if(n instanceof y)for(let i of n.state.facet(y.atomicRanges).map(s=>s(n)))i.between(e,e,(s,r)=>{s<e&&r>e&&(e=t?r:s)});return e}const ni=(n,e,t)=>Ce(n,i=>{let s=i.from,{state:r}=n,o=r.doc.lineAt(s),l,a;if(t&&!e&&s>o.from&&s<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,s-o.from))){if(l[l.length-1]==" ")return s-1;let c=At(l,r.tabSize),h=c%ge(r)||ge(r);for(let f=0;f<h&&l[l.length-1-f]==" ";f++)s--;a=s}else a=Y(o.text,s-o.from,e,e)+o.from,a==s&&o.number!=(e?r.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,s-o.from))&&(a=Y(o.text,a-o.from,!1,!1)+o.from);return a}),xt=n=>ni(n,!1,!0),ii=n=>ni(n,!0,!1),si=(n,e)=>Ce(n,t=>{let i=t.head,{state:s}=n,r=s.doc.lineAt(i),o=s.charCategorizer(i);for(let l=null;;){if(i==(e?r.to:r.from)){i==t.head&&r.number!=(e?s.doc.lines:1)&&(i+=e?1:-1);break}let a=Y(r.text,i-r.from,e)+r.from,c=r.text.slice(Math.min(i,a)-r.from,Math.max(i,a)-r.from),h=o(c);if(l!=null&&h!=l)break;(c!=" "||i!=t.head)&&(l=h),i=a}return i}),ri=n=>si(n,!1),dr=n=>si(n,!0),pr=n=>Ce(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)}),mr=n=>Ce(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),gr=n=>Ce(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)}),xr=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:kn.of(["",""])},range:m.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},yr=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let s=i.from,r=n.doc.lineAt(s),o=s==r.from?s-1:Y(r.text,s-r.from,!1)+r.from,l=s==r.to?s+1:Y(r.text,s-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:n.doc.slice(s,l).append(n.doc.slice(o,s))},range:m.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Xe(n){let e=[],t=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.from),r=n.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=n.doc.lineAt(i.to-1)),t>=s.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(i)}else e.push({from:s.from,to:r.to,ranges:[i]});t=r.number+1}return e}function oi(n,e,t){if(n.readOnly)return!1;let i=[],s=[];for(let r of Xe(n)){if(t?r.to==n.doc.length:r.from==0)continue;let o=n.doc.lineAt(t?r.to+1:r.from-1),l=o.length+1;if(t){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+n.lineBreak});for(let a of r.ranges)s.push(m.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:n.lineBreak+o.text});for(let a of r.ranges)s.push(m.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:m.create(s,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const kr=({state:n,dispatch:e})=>oi(n,e,!1),br=({state:n,dispatch:e})=>oi(n,e,!0);function li(n,e,t){if(n.readOnly)return!1;let i=[];for(let s of Xe(n))t?i.push({from:s.from,insert:n.doc.slice(s.from,s.to)+n.lineBreak}):i.push({from:s.to,insert:n.lineBreak+n.doc.slice(s.from,s.to)});return e(n.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const vr=({state:n,dispatch:e})=>li(n,e,!1),Sr=({state:n,dispatch:e})=>li(n,e,!0),Cr=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(Xe(e).map(({from:s,to:r})=>(s>0?s--:r<e.doc.length&&r++,{from:s,to:r}))),i=ue(e.selection,s=>{let r;if(n.lineWrapping){let o=n.lineBlockAt(s.head),l=n.coordsAtPos(s.head,s.assoc||1);l&&(r=o.bottom+n.documentTop-l.bottom+n.defaultLineHeight/2)}return n.moveVertically(s,!0,r)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Ar(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Z(n).resolveInner(e),i=t.childBefore(e),s=t.childAfter(e),r;return i&&s&&i.to<=e&&s.from>=e&&(r=i.type.prop(ce.closedBy))&&r.indexOf(s.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(s.from).from&&!/\S/.test(n.sliceDoc(i.to,s.from))?{from:i.to,to:s.from}:null}const _t=ai(!1),wr=ai(!0);function ai(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(s=>{let{from:r,to:o}=s,l=e.doc.lineAt(r),a=!n&&r==o&&Ar(e,r);n&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let c=new xn(e,{simulateBreak:r,simulateDoubleBreak:!!a}),h=yn(c,r);for(h==null&&(h=At(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:r,to:o}=a:r>l.from&&r<l.from+100&&!/\S/.test(l.text.slice(0,r))&&(r=l.from);let f=["",Ee(e,h)];return a&&f.push(Ee(e,c.lineIndent(l.from,-1))),{changes:{from:r,to:o,insert:kn.of(f)},range:m.cursor(r+1+f[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Rt(n,e){let t=-1;return n.changeByRange(i=>{let s=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,s,i),t=l.number),o=l.to+1}let r=n.changes(s);return{changes:s,range:m.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}const Mr=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new xn(n,{overrideIndentation:r=>{let o=t[r];return o??-1}}),s=Rt(n,(r,o,l)=>{let a=yn(i,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let c=/^\s*/.exec(r.text)[0],h=Ee(n,a);(c!=h||l.from<r.from+c.length)&&(t[r.from]=a,o.push({from:r.from,to:r.from+c.length,insert:h}))});return s.changes.empty||e(n.update(s,{userEvent:"indent"})),!0},ci=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Rt(n,(t,i)=>{i.push({from:t.from,insert:n.facet(Oi)})}),{userEvent:"input.indent"})),!0),hi=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Rt(n,(t,i)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let r=At(s,n.tabSize),o=0,l=Ee(n,Math.max(0,r-ge(n)));for(;o<s.length&&o<l.length&&s.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+s.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),Tr=n=>(n.setTabFocusMode(),!0),Lr=[{key:"Ctrl-b",run:$n,shift:Qn,preventDefault:!0},{key:"Ctrl-f",run:qn,shift:_n},{key:"Ctrl-p",run:Gn,shift:Zn},{key:"Ctrl-n",run:Vn,shift:ei},{key:"Ctrl-a",run:Qs,shift:lr},{key:"Ctrl-e",run:_s,shift:ar},{key:"Ctrl-d",run:ii},{key:"Ctrl-h",run:xt},{key:"Ctrl-k",run:pr},{key:"Ctrl-Alt-h",run:ri},{key:"Ctrl-o",run:xr},{key:"Ctrl-t",run:yr},{key:"Ctrl-v",run:gt}],Dr=[{key:"ArrowLeft",run:$n,shift:Qn,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:$s,shift:Zs,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Ks,shift:rr,preventDefault:!0},{key:"ArrowRight",run:qn,shift:_n,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:qs,shift:er,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Js,shift:or,preventDefault:!0},{key:"ArrowUp",run:Gn,shift:Zn,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Ht,shift:Jt},{mac:"Ctrl-ArrowUp",run:jt,shift:Gt},{key:"ArrowDown",run:Vn,shift:ei,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Kt,shift:Qt},{mac:"Ctrl-ArrowDown",run:gt,shift:Vt},{key:"PageUp",run:jt,shift:Gt},{key:"PageDown",run:gt,shift:Vt},{key:"Home",run:Hs,shift:sr,preventDefault:!0},{key:"Mod-Home",run:Ht,shift:Jt},{key:"End",run:Vs,shift:ir,preventDefault:!0},{key:"Mod-End",run:Kt,shift:Qt},{key:"Enter",run:_t,shift:_t},{key:"Mod-a",run:cr},{key:"Backspace",run:xt,shift:xt},{key:"Delete",run:ii},{key:"Mod-Backspace",mac:"Alt-Backspace",run:ri},{key:"Mod-Delete",mac:"Alt-Delete",run:dr},{mac:"Mod-Backspace",run:mr},{mac:"Mod-Delete",run:gr}].concat(Lr.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),Ho=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:js,shift:tr},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Gs,shift:nr},{key:"Alt-ArrowUp",run:kr},{key:"Shift-Alt-ArrowUp",run:vr},{key:"Alt-ArrowDown",run:br},{key:"Shift-Alt-ArrowDown",run:Sr},{key:"Escape",run:ur},{key:"Mod-Enter",run:wr},{key:"Alt-l",mac:"Ctrl-l",run:hr},{key:"Mod-i",run:fr,preventDefault:!0},{key:"Mod-[",run:hi},{key:"Mod-]",run:ci},{key:"Mod-Alt-\\",run:Mr},{key:"Shift-Mod-k",run:Cr},{key:"Shift-Mod-\\",run:Xs},{key:"Mod-/",run:Cs},{key:"Alt-A",run:ws},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Tr}].concat(Dr),Ko={key:"Tab",run:ci,shift:hi};class fi{constructor(e,t,i,s){this.state=e,this.pos=t,this.explicit=i,this.view=s,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Z(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),s=t.text.slice(i-t.from,this.pos-t.from),r=s.search(ui(e,!1));return r<0?null:{from:i+r,to:this.pos,text:s.slice(r)}}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 Yt(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function Br(n){let e=Object.create(null),t=Object.create(null);for(let{label:s}of n){e[s[0]]=!0;for(let r=1;r<s.length;r++)t[s[r]]=!0}let i=Yt(e)+Yt(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function Pr(n){let e=n.map(s=>typeof s=="string"?{label:s}:s),[t,i]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:Br(e);return s=>{let r=s.matchBefore(i);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}function Jo(n,e){return t=>{for(let i=Z(t.state).resolveInner(t.pos,-1);i;i=i.parent){if(n.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(t)}}class Xt{constructor(e,t,i,s){this.completion=e,this.source=t,this.match=i,this.score=s}}function _(n){return n.selection.main.from}function ui(n,e){var t;let{source:i}=n,s=e&&i[0]!="^",r=i[i.length-1]!="$";return!s&&!r?n:new RegExp(`${s?"^":""}(?:${i})${r?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}const di=wt.define();function Rr(n,e,t,i){let{main:s}=n.selection,r=t-s.from,o=i-s.from;return Object.assign(Object.assign({},n.changeByRange(l=>{if(l!=s&&t!=i&&n.sliceDoc(l.from+r,l.from+o)!=n.sliceDoc(t,i))return{range:l};let a=n.toText(e);return{changes:{from:l.from+r,to:i==s.from?l.to:l.from+o,insert:a},range:m.cursor(l.from+r+a.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const Zt=new WeakMap;function Ir(n){if(!Array.isArray(n))return n;let e=Zt.get(n);return e||Zt.set(n,e=Pr(n)),e}const Ge=S.define(),ye=S.define();class Or{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let i=R(e,t),s=U(i);this.chars.push(i);let r=e.slice(t,t+s),o=r.toUpperCase();this.folded.push(R(o==r?r.toLowerCase():o,0)),t+=s}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:i,any:s,precise:r,byWord:o}=this;if(t.length==1){let k=R(e,0),te=U(k),$=te==e.length?0:-100;if(k!=t[0])if(k==i[0])$+=-200;else return null;return this.ret($,[0,te])}let l=e.indexOf(this.pattern);if(l==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,c=0;if(l<0){for(let k=0,te=Math.min(e.length,200);k<te&&c<a;){let $=R(e,k);($==t[c]||$==i[c])&&(s[c++]=k),k+=U($)}if(c<a)return null}let h=0,f=0,u=!1,d=0,p=-1,g=-1,C=/[a-z]/.test(e),j=!0;for(let k=0,te=Math.min(e.length,200),$=0;k<te&&f<a;){let T=R(e,k);l<0&&(h<a&&T==t[h]&&(r[h++]=k),d<a&&(T==t[d]||T==i[d]?(d==0&&(p=k),g=k+1,d++):d=0));let Ae,nt=T<255?T>=48&&T<=57||T>=97&&T<=122?2:T>=65&&T<=90?1:0:(Ae=St(T))!=Ae.toLowerCase()?1:Ae!=Ae.toUpperCase()?2:0;(!k||nt==1&&C||$==0&&nt!=0)&&(t[f]==T||i[f]==T&&(u=!0)?o[f++]=k:o.length&&(j=!1)),$=nt,k+=U(T)}return f==a&&o[0]==0&&j?this.result(-100+(u?-200:0),o,e):d==a&&p==0?this.ret(-200-e.length+(g==e.length?0:-100),[0,g]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):d==a?this.ret(-900-e.length,[p,g]):f==a?this.result(-100+(u?-200:0)+-700+(j?0:-1100),o,e):t.length==2?null:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,i){let s=[],r=0;for(let o of t){let l=o+(this.astral?U(R(i,o)):1);r&&s[r-1]==o?s[r-1]=l:(s[r++]=o,s[r++]=l)}return this.ret(e-i.length,s)}}class Er{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),i=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return i==null?null:(this.matched=[0,t.length],this.score=i+(e.length==this.pattern.length?0:-100),this)}}const v=V.define({combine(n){return X(n,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Nr,filterStrict:!1,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>en(e(i),t(i)),optionClass:(e,t)=>i=>en(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function en(n,e){return n?e?n+" "+e:n:e}function Nr(n,e,t,i,s,r){let o=n.textDirection==bn.RTL,l=o,a=!1,c="top",h,f,u=e.left-s.left,d=s.right-e.right,p=i.right-i.left,g=i.bottom-i.top;if(l&&u<Math.min(p,d)?l=!1:!l&&d<Math.min(p,u)&&(l=!0),p<=(l?u:d))h=Math.max(s.top,Math.min(t.top,s.bottom-g))-e.top,f=Math.min(400,l?u:d);else{a=!0,f=Math.min(400,(o?e.right:s.right-e.left)-30);let k=s.bottom-e.bottom;k>=g||k>e.top?h=t.bottom-e.top:(c="bottom",h=e.bottom-t.top)}let C=(e.bottom-e.top)/r.offsetHeight,j=(e.right-e.left)/r.offsetWidth;return{style:`${c}: ${h/C}px; max-width: ${f/j}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}function Fr(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,s,r){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let c=0;c<r.length;){let h=r[c++],f=r[c++];h>a&&o.appendChild(document.createTextNode(l.slice(a,h)));let u=o.appendChild(document.createElement("span"));u.appendChild(document.createTextNode(l.slice(h,f))),u.className="cm-completionMatchedText",a=f}return a<l.length&&o.appendChild(document.createTextNode(l.slice(a))),o},position:50},{render(t){if(!t.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=t.detail,i},position:80}),e.sort((t,i)=>t.position-i.position).map(t=>t.render)}function lt(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let i=Math.floor((n-e)/t);return{from:n-(i+1)*t,to:n-i*t}}class zr{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let s=e.state.field(t),{options:r,selected:o}=s.open,l=e.state.facet(v);this.optionContent=Fr(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=lt(r.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:c}=e.state.field(t).open;for(let h=a.target,f;h&&h!=this.dom;h=h.parentNode)if(h.nodeName=="LI"&&(f=/-(\d+)$/.exec(h.id))&&+f[1]<c.length){this.applyCompletion(e,c[+f[1]]),a.preventDefault();return}}),this.dom.addEventListener("focusout",a=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(v).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:ye.of(null)})}),this.showOptions(r,s.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=s){let{options:r,selected:o,disabled:l}=i.open;(!s.open||s.open.options!=r)&&(this.range=lt(r.length,o,e.state.facet(v).maxRenderedOptions),this.showOptions(r,i.id)),this.updateSel(),l!=((t=s.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=lt(t.options.length,t.selected,this.view.state.facet(v).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:i}=t.options[t.selected],{info:s}=i;if(!s)return;let r=typeof s=="string"?document.createTextNode(s):s(i);if(!r)return;"then"in r?r.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,i)}).catch(o=>Ne(this.view.state,o,"completion info")):this.addInfoPane(r,i)}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:s,destroy:r}=e;i.appendChild(s),this.infoDestroy=r||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,s=this.range.from;i;i=i.nextSibling,s++)i.nodeName!="LI"||!i.id?s--:s==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected");return t&&$r(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),s=e.getBoundingClientRect(),r=this.space;if(!r){let o=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return s.top>Math.min(r.bottom,t.bottom)-10||s.bottom<Math.max(r.top,t.top)+10?null:this.view.state.facet(v).positionInfo(this.view,t,s,i,r,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,i){const s=document.createElement("ul");s.id=t,s.setAttribute("role","listbox"),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-label",this.view.state.phrase("Completions")),s.addEventListener("mousedown",o=>{o.target==s&&o.preventDefault()});let r=null;for(let o=i.from;o<i.to;o++){let{completion:l,match:a}=e[o],{section:c}=l;if(c){let u=typeof c=="string"?c:c.name;if(u!=r&&(o>i.from||i.from==0))if(r=u,typeof c!="string"&&c.header)s.appendChild(c.header(c));else{let d=s.appendChild(document.createElement("completion-section"));d.textContent=u}}const h=s.appendChild(document.createElement("li"));h.id=t+"-"+o,h.setAttribute("role","option");let f=this.optionClass(l);f&&(h.className=f);for(let u of this.optionContent){let d=u(l,this.view.state,this.view,a);d&&h.appendChild(d)}}return i.from&&s.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&s.classList.add("cm-completionListIncompleteBottom"),s}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function Wr(n,e){return t=>new zr(t,n,e)}function $r(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),s=t.height/n.offsetHeight;i.top<t.top?n.scrollTop-=(t.top-i.top)/s:i.bottom>t.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/s)}function tn(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function qr(n,e){let t=[],i=null,s=c=>{t.push(c);let{section:h}=c.completion;if(h){i||(i=[]);let f=typeof h=="string"?h:h.name;i.some(u=>u.name==f)||i.push(typeof h=="string"?{name:f}:h)}},r=e.facet(v);for(let c of n)if(c.hasResult()){let h=c.result.getMatch;if(c.result.filter===!1)for(let f of c.result.options)s(new Xt(f,c.source,h?h(f):[],1e9-t.length));else{let f=e.sliceDoc(c.from,c.to),u,d=r.filterStrict?new Er(f):new Or(f);for(let p of c.result.options)if(u=d.match(p.label)){let g=p.displayLabel?h?h(p,u.matched):[]:u.matched;s(new Xt(p,c.source,g,u.score+(p.boost||0)))}}}if(i){let c=Object.create(null),h=0,f=(u,d)=>{var p,g;return((p=u.rank)!==null&&p!==void 0?p:1e9)-((g=d.rank)!==null&&g!==void 0?g:1e9)||(u.name<d.name?-1:1)};for(let u of i.sort(f))h-=1e5,c[u.name]=h;for(let u of t){let{section:d}=u.completion;d&&(u.score+=c[typeof d=="string"?d:d.name])}}let o=[],l=null,a=r.compareCompletions;for(let c of t.sort((h,f)=>f.score-h.score||a(h.completion,f.completion))){let h=c.completion;!l||l.label!=h.label||l.detail!=h.detail||l.type!=null&&h.type!=null&&l.type!=h.type||l.apply!=h.apply||l.boost!=h.boost?o.push(c):tn(c.completion)>tn(l)&&(o[o.length-1]=c),l=c.completion}return o}class re{constructor(e,t,i,s,r,o){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=s,this.selected=r,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new re(this.options,nn(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,s,r,o){if(s&&!o&&e.some(c=>c.isPending))return s.setDisabled();let l=qr(e,t);if(!l.length)return s&&e.some(c=>c.isPending)?s.setDisabled():null;let a=t.facet(v).selectOnOpen?0:-1;if(s&&s.selected!=a&&s.selected!=-1){let c=s.options[s.selected].completion;for(let h=0;h<l.length;h++)if(l[h].completion==c){a=h;break}}return new re(l,nn(i,a),{pos:e.reduce((c,h)=>h.hasResult()?Math.min(c,h.from):c,1e8),create:Kr,above:r.aboveCursor},s?s.timestamp:Date.now(),a,!1)}map(e){return new re(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new re(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Ve{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new Ve(Vr,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(v),r=(i.override||t.languageDataAt("autocomplete",_(t)).map(Ir)).map(a=>(this.active.find(h=>h.source==a)||new O(a,this.active.some(h=>h.state!=0)?1:0)).update(e,i));r.length==this.active.length&&r.every((a,c)=>a==this.active[c])&&(r=this.active);let o=this.open,l=e.effects.some(a=>a.is(It));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||r.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!Ur(r,this.active)||l?o=re.build(r,t,this.id,o,i,l):o&&o.disabled&&!r.some(a=>a.isPending)&&(o=null),!o&&r.every(a=>!a.isPending)&&r.some(a=>a.hasResult())&&(r=r.map(a=>a.hasResult()?new O(a.source,0):a));for(let a of e.effects)a.is(mi)&&(o=o&&o.setSelected(a.value,this.id));return r==this.active&&o==this.open?this:new Ve(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?jr:Gr}}function Ur(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t<n.length&&!n[t].hasResult();)t++;for(;i<e.length&&!e[i].hasResult();)i++;let s=t==n.length,r=i==e.length;if(s||r)return s==r;if(n[t++].result!=e[i++].result)return!1}}const jr={"aria-autocomplete":"list"},Gr={};function nn(n,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":n};return e>-1&&(t["aria-activedescendant"]=n+"-"+e),t}const Vr=[];function pi(n,e){if(n.isUserEvent("input.complete")){let i=n.annotation(di);if(i&&e.activateOnCompletion(i))return 12}let t=n.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}class O{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let i=pi(e,t),s=this;(i&8||i&16&&this.touches(e))&&(s=new O(s.source,0)),i&4&&s.state==0&&(s=new O(this.source,1)),s=s.updateFor(e,i);for(let r of e.effects)if(r.is(Ge))s=new O(s.source,1,r.value);else if(r.is(ye))s=new O(s.source,0);else if(r.is(It))for(let o of r.value)o.source==s.source&&(s=o);return s}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(_(e.state))}}class le extends O{constructor(e,t,i,s,r,o){super(e,3,t),this.limit=i,this.result=s,this.from=r,this.to=o}hasResult(){return!0}updateFor(e,t){var i;if(!(t&3))return this.map(e.changes);let s=this.result;s.map&&!e.changes.empty&&(s=s.map(s,e.changes));let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=_(e.state);if(l>o||!s||t&2&&(_(e.startState)==this.from||l<this.limit))return new O(this.source,t&4?1:0);let a=e.changes.mapPos(this.limit);return Hr(s.validFor,e.state,r,o)?new le(this.source,this.explicit,a,s,r,o):s.update&&(s=s.update(s,r,o,new fi(e.state,l,!1)))?new le(this.source,this.explicit,a,s,s.from,(i=s.to)!==null&&i!==void 0?i:_(e.state)):new O(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new le(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new O(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function Hr(n,e,t,i){if(!n)return!1;let s=e.sliceDoc(t,i);return typeof n=="function"?n(s,t,i,e):ui(n,!0).test(s)}const It=S.define({map(n,e){return n.map(t=>t.map(e))}}),mi=S.define(),L=H.define({create(){return Ve.start()},update(n,e){return n.update(e)},provide:n=>[vn.from(n,e=>e.tooltip),y.contentAttributes.from(n,e=>e.attrs)]});function Ot(n,e){const t=e.completion.apply||e.completion.label;let i=n.state.field(L).active.find(s=>s.source==e.source);return i instanceof le?(typeof t=="string"?n.dispatch(Object.assign(Object.assign({},Rr(n.state,t,i.from,i.to)),{annotations:di.of(e.completion)})):t(n,e.completion,i.from,i.to),!0):!1}const Kr=Wr(L,Ot);function De(n,e="option"){return t=>{let i=t.state.field(L,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<t.state.facet(v).interactionDelay)return!1;let s=1,r;e=="page"&&(r=Sn(t,i.open.tooltip))&&(s=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,l=i.open.selected>-1?i.open.selected+s*(n?1:-1):n?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:mi.of(l)}),!0}}const Jr=n=>{let e=n.state.field(L,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<n.state.facet(v).interactionDelay?!1:Ot(n,e.open.options[e.open.selected])},sn=n=>n.state.field(L,!1)?(n.dispatch({effects:Ge.of(!0)}),!0):!1,Qr=n=>{let e=n.state.field(L,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:ye.of(null)}),!0)};class _r{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const Yr=50,Xr=1e3,Zr=ve.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(L).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(L),t=n.state.facet(v);if(!n.selectionSet&&!n.docChanged&&n.startState.field(L)==e)return;let i=n.transactions.some(r=>{let o=pi(r,t);return o&8||(r.selection||r.docChanged)&&!(o&3)});for(let r=0;r<this.running.length;r++){let o=this.running[r];if(i||o.context.abortOnDocChange&&n.docChanged||o.updates.length+n.transactions.length>Yr&&Date.now()-o.time>Xr){for(let l of o.context.abortListeners)try{l()}catch(a){Ne(this.view.state,a)}o.context.abortListeners=null,this.running.splice(r--,1)}else o.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(r=>r.effects.some(o=>o.is(Ge)))&&(this.pendingStart=!0);let s=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(r=>r.isPending&&!this.running.some(o=>o.active.source==r.source))?setTimeout(()=>this.startUpdate(),s):-1,this.composing!=0)for(let r of n.transactions)r.isUserEvent("input.type")?this.composing=2:this.composing==2&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(L);for(let t of e.active)t.isPending&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(v).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=_(e),i=new fi(e,t,n.explicit,this.view),s=new _r(n,i);this.running.push(s),Promise.resolve(n.source(i)).then(r=>{s.context.aborted||(s.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:ye.of(null)}),Ne(this.view.state,r)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(v).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(v),i=this.view.state.field(L);for(let s=0;s<this.running.length;s++){let r=this.running[s];if(r.done===void 0)continue;if(this.running.splice(s--,1),r.done){let l=_(r.updates.length?r.updates[0].startState:this.view.state),a=Math.min(l,r.done.from+(r.active.explicit?0:1)),c=new le(r.active.source,r.active.explicit,a,r.done,r.done.from,(n=r.done.to)!==null&&n!==void 0?n:l);for(let h of r.updates)c=c.update(h,t);if(c.hasResult()){e.push(c);continue}}let o=i.active.find(l=>l.source==r.active.source);if(o&&o.isPending)if(r.done==null){let l=new O(r.active.source,0);for(let a of r.updates)l=l.update(a,t);l.isPending||e.push(l)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:It.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(L,!1);if(e&&e.tooltip&&this.view.state.facet(v).closeOnBlur){let t=e.open&&Sn(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:ye.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Ge.of(!1)}),20),this.composing=0}}}),eo=typeof navigator=="object"&&/Win/.test(navigator.platform),to=bt.highest(y.domEventHandlers({keydown(n,e){let t=e.state.field(L,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||n.key.length>1||n.ctrlKey&&!(eo&&n.altKey)||n.metaKey)return!1;let i=t.open.options[t.open.selected],s=t.active.find(o=>o.source==i.source),r=i.completion.commitCharacters||s.result.commitCharacters;return r&&r.indexOf(n.key)>-1&&Ot(e,i),!1}})),no=y.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),ke={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Q=S.define({map(n,e){let t=e.mapPos(n,-1,Ni.TrackAfter);return t??void 0}}),Et=new class extends Fi{};Et.startSide=1;Et.endSide=-1;const gi=H.define({create(){return Je.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(Q)&&(n=n.update({add:[Et.range(t.value,t.value+1)]}));return n}});function Qo(){return[so,gi]}const at="()[]{}<>«»»«[]{}";function xi(n){for(let e=0;e<at.length;e+=2)if(at.charCodeAt(e)==n)return at.charAt(e+1);return St(n<128?n:n+1)}function yi(n,e){return n.languageDataAt("closeBrackets",e)[0]||ke}const io=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),so=y.inputHandler.of((n,e,t,i)=>{if((io?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let s=n.state.selection.main;if(i.length>2||i.length==2&&U(R(i,0))==1||e!=s.from||t!=s.to)return!1;let r=oo(n.state,i);return r?(n.dispatch(r),!0):!1}),ro=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=yi(n,n.selection.main.head).brackets||ke.brackets,s=null,r=n.changeByRange(o=>{if(o.empty){let l=lo(n.doc,o.head);for(let a of i)if(a==l&&Ze(n.doc,o.head)==xi(R(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:m.cursor(o.head-a.length)}}return{range:s=o}});return s||e(n.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},_o=[{key:"Backspace",run:ro}];function oo(n,e){let t=yi(n,n.selection.main.head),i=t.brackets||ke.brackets;for(let s of i){let r=xi(R(s,0));if(e==s)return r==s?ho(n,s,i.indexOf(s+s+s)>-1,t):ao(n,s,r,t.before||ke.before);if(e==r&&ki(n,n.selection.main.from))return co(n,s,r)}return null}function ki(n,e){let t=!1;return n.field(gi).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function Ze(n,e){let t=n.sliceString(e,e+2);return t.slice(0,U(R(t,0)))}function lo(n,e){let t=n.sliceString(e-2,e);return U(R(t,0))==t.length?t:t.slice(1)}function ao(n,e,t,i){let s=null,r=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:Q.of(o.to+e.length),range:m.range(o.anchor+e.length,o.head+e.length)};let l=Ze(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:Q.of(o.head+e.length),range:m.cursor(o.head+e.length)}:{range:s=o}});return s?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function co(n,e,t){let i=null,s=n.changeByRange(r=>r.empty&&Ze(n.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:m.cursor(r.head+t.length)}:i={range:r});return i?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function ho(n,e,t,i){let s=i.stringPrefixes||ke.stringPrefixes,r=null,o=n.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:Q.of(l.to+e.length),range:m.range(l.anchor+e.length,l.head+e.length)};let a=l.head,c=Ze(n.doc,a),h;if(c==e){if(rn(n,a))return{changes:{insert:e+e,from:a},effects:Q.of(a+e.length),range:m.cursor(a+e.length)};if(ki(n,a)){let u=t&&n.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+u.length,insert:u},range:m.cursor(a+u.length)}}}else{if(t&&n.sliceDoc(a-2*e.length,a)==e+e&&(h=on(n,a-2*e.length,s))>-1&&rn(n,h))return{changes:{insert:e+e+e+e,from:a},effects:Q.of(a+e.length),range:m.cursor(a+e.length)};if(n.charCategorizer(a)(c)!=w.Word&&on(n,a,s)>-1&&!fo(n,a,e,s))return{changes:{insert:e+e,from:a},effects:Q.of(a+e.length),range:m.cursor(a+e.length)}}return{range:r=l}});return r?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function rn(n,e){let t=Z(n).resolveInner(e+1);return t.parent&&t.from==e}function fo(n,e,t,i){let s=Z(n).resolveInner(e,-1),r=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=n.sliceDoc(s.from,Math.min(s.to,s.from+t.length+r)),a=l.indexOf(t);if(!a||a>-1&&i.indexOf(l.slice(0,a))>-1){let h=s.firstChild;for(;h&&h.from==s.from&&h.to-h.from>t.length+a;){if(n.sliceDoc(h.to-t.length,h.to)==t)return!1;h=h.firstChild}return!0}let c=s.to==e&&s.parent;if(!c)break;s=c}return!1}function on(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=w.Word)return e;for(let s of t){let r=e-s.length;if(n.sliceDoc(r,e)==s&&i(n.sliceDoc(r-1,r))!=w.Word)return r}return-1}function Yo(n={}){return[to,L,v.of(n),Zr,po,no]}const uo=[{key:"Ctrl-Space",run:sn},{mac:"Alt-`",run:sn},{key:"Escape",run:Qr},{key:"ArrowDown",run:De(!0)},{key:"ArrowUp",run:De(!1)},{key:"PageDown",run:De(!0,"page")},{key:"PageUp",run:De(!1,"page")},{key:"Enter",run:Jr}],po=bt.highest(Ei.computeN([v],n=>n.facet(v).defaultKeymap?[uo]:[]));class ln{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class J{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let s=i.facet(z).markerFilter;s&&(e=s(e,i));let r=e.slice().sort((h,f)=>h.from-f.from||h.to-f.to),o=new Ct,l=[],a=0;for(let h=0;;){let f=h==r.length?null:r[h];if(!f&&!l.length)break;let u,d;for(l.length?(u=a,d=l.reduce((g,C)=>Math.min(g,C.to),f&&f.from>u?f.from:1e8)):(u=f.from,d=f.to,l.push(f),h++);h<r.length;){let g=r[h];if(g.from==u&&(g.to>g.from||g.to==u))l.push(g),h++,d=Math.min(g.to,d);else{d=Math.min(g.from,d);break}}let p=Mi(l);if(l.some(g=>g.from==g.to||g.from==g.to-1&&i.doc.lineAt(g.from).to==g.from))o.add(u,u,b.widget({widget:new So(p),diagnostics:l.slice()}));else{let g=l.reduce((C,j)=>j.markClass?C+" "+j.markClass:C,"");o.add(u,d,b.mark({class:"cm-lintRange cm-lintRange-"+p+g,diagnostics:l.slice(),inclusiveEnd:l.some(C=>C.to>d)}))}a=d;for(let g=0;g<l.length;g++)l[g].to<=a&&l.splice(g--,1)}let c=o.finish();return new J(c,t,fe(c))}}function fe(n,e=null,t=0){let i=null;return n.between(t,1e9,(s,r,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!i)i=new ln(s,r,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new ln(i.from,r,i.diagnostic)}}),i}function bi(n,e){let t=e.pos,i=e.end||t,s=n.state.facet(z).hideOn(n,t,i);if(s!=null)return s;let r=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(o=>o.is(et))||n.changes.touchesRange(r.from,Math.max(r.to,i)))}function vi(n,e){return n.field(M,!1)?e:e.concat(S.appendConfig.of(Di))}function mo(n,e){return{effects:vi(n,[et.of(e)])}}const et=S.define(),Nt=S.define(),Si=S.define(),M=H.define({create(){return new J(b.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),i=null,s=n.panel;if(n.selected){let r=e.changes.mapPos(n.selected.from,1);i=fe(t,n.selected.diagnostic,r)||fe(t,null,r)}!t.size&&s&&e.state.facet(z).autoPanel&&(s=null),n=new J(t,s,i)}for(let t of e.effects)if(t.is(et)){let i=e.state.facet(z).autoPanel?t.value.length?be.open:null:n.panel;n=J.init(t.value,i,e.state)}else t.is(Nt)?n=new J(n.diagnostics,t.value?be.open:null,n.selected):t.is(Si)&&(n=new J(n.diagnostics,n.panel,t.value));return n},provide:n=>[vt.from(n,e=>e.panel),y.decorations.from(n,e=>e.diagnostics)]});function Xo(n){let e=n.field(M,!1);return e?e.diagnostics.size:0}const go=b.mark({class:"cm-lintRange cm-lintRange-active"});function xo(n,e,t){let{diagnostics:i}=n.state.field(M),s,r=-1,o=-1;i.between(e-(t<0?1:0),e+(t>0?1:0),(a,c,{spec:h})=>{if(e>=a&&e<=c&&(a==c||(e>a||t>0)&&(e<c||t<0)))return s=h.diagnostics,r=a,o=c,!1});let l=n.state.facet(z).tooltipFilter;return s&&l&&(s=l(s,n.state)),s?{pos:r,end:o,above:n.state.doc.lineAt(r).to<o,create(){return{dom:Ci(n,s)}}}:null}function Ci(n,e){return x("ul",{class:"cm-tooltip-lint"},e.map(t=>wi(n,t,!1)))}const yo=n=>{let e=n.state.field(M,!1);(!e||!e.panel)&&n.dispatch({effects:vi(n.state,[Nt.of(!0)])});let t=me(n,be.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},an=n=>{let e=n.state.field(M,!1);return!e||!e.panel?!1:(n.dispatch({effects:Nt.of(!1)}),!0)},ko=n=>{let e=n.state.field(M,!1);if(!e)return!1;let t=n.state.selection.main,i=e.diagnostics.iter(t.to+1);return!i.value&&(i=e.diagnostics.iter(0),!i.value||i.from==t.from&&i.to==t.to)?!1:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)},Zo=[{key:"Mod-Shift-m",run:yo,preventDefault:!0},{key:"F8",run:ko}],bo=ve.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(z);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let n=Date.now();if(n<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-n);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(z);t.length&&vo(t.map(i=>Promise.resolve(i(this.view))),i=>{this.view.state.doc==e.doc&&this.view.dispatch(mo(this.view.state,i.reduce((s,r)=>s.concat(r))))},i=>{Ne(this.view.state,i)})}}update(n){let e=n.state.facet(z);(n.docChanged||e!=n.startState.facet(z)||e.needsRefresh&&e.needsRefresh(n))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function vo(n,e,t){let i=[],s=-1;for(let r of n)r.then(o=>{i.push(o),clearTimeout(s),i.length==n.length?e(i):s=setTimeout(()=>e(i),200)},t)}const z=V.define({combine(n){return Object.assign({sources:n.map(e=>e.source).filter(e=>e!=null)},X(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t}))}});function el(n,e={}){return[z.of({source:n,config:e}),bo,Di]}function Ai(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;i<t.length;i++){let s=t[i];if(/[a-zA-Z]/.test(s)&&!e.some(r=>r.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function wi(n,e,t){var i;let s=t?Ai(e.actions):[];return x("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},x("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((r,o)=>{let l=!1,a=u=>{if(u.preventDefault(),l)return;l=!0;let d=fe(n.state.field(M).diagnostics,e);d&&r.apply(n,d.from,d.to)},{name:c}=r,h=s[o]?c.indexOf(s[o]):-1,f=h<0?c:[c.slice(0,h),x("u",c.slice(h,h+1)),c.slice(h+1)];return x("button",{type:"button",class:"cm-diagnosticAction",onclick:a,onmousedown:a,"aria-label":` Action: ${c}${h<0?"":` (access key "${s[o]})"`}.`},f)}),e.source&&x("div",{class:"cm-diagnosticSource"},e.source))}class So extends Wi{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return x("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class cn{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=wi(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class be{constructor(e){this.view=e,this.items=[];let t=s=>{if(s.keyCode==27)an(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=Ai(r.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==s.keyCode){let a=fe(this.view.state.field(M).diagnostics,r);a&&r.actions[l].apply(e,a.from,a.to)}}else return;s.preventDefault()},i=s=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(s.target)&&this.moveSelection(r)};this.list=x("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=x("div",{class:"cm-panel-lint"},this.list,x("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>an(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(M).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(M),i=0,s=!1,r=null,o=new Set;for(e.between(0,this.view.state.doc.length,(l,a,{spec:c})=>{for(let h of c.diagnostics){if(o.has(h))continue;o.add(h);let f=-1,u;for(let d=i;d<this.items.length;d++)if(this.items[d].diagnostic==h){f=d;break}f<0?(u=new cn(this.view,h),this.items.splice(i,0,u),s=!0):(u=this.items[f],f>i&&(this.items.splice(i,f-i),s=!0)),t&&u.diagnostic==t.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),r=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();this.items.length==0&&(this.items.push(new cn(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let c=a.height/this.list.offsetHeight;l.top<a.top?this.list.scrollTop-=(a.top-l.top)/c:l.bottom>a.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(M),i=fe(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:Si.of(i)})}static open(e){return new be(e)}}function Ie(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function Be(n){return Ie(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Co=y.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Be("#d11")},".cm-lintRange-warning":{backgroundImage:Be("orange")},".cm-lintRange-info":{backgroundImage:Be("#999")},".cm-lintRange-hint":{backgroundImage:Be("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function Ao(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function Mi(n){let e="hint",t=1;for(let i of n){let s=Ao(i.severity);s>t&&(t=s,e=i.severity)}return e}class Ti extends qi{constructor(e){super(),this.diagnostics=e,this.severity=Mi(e)}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,s=e.state.facet(tt).tooltipFilter;return s&&(i=s(i,e.state)),i.length&&(t.onmouseover=()=>Mo(e,t,i)),t}}function wo(n,e){let t=i=>{let s=e.getBoundingClientRect();if(!(i.clientX>s.left-10&&i.clientX<s.right+10&&i.clientY>s.top-10&&i.clientY<s.bottom+10)){for(let r=i.target;r;r=r.parentNode)if(r.nodeType==1&&r.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",t),n.state.field(Li)&&n.dispatch({effects:Ft.of(null)})}};window.addEventListener("mousemove",t)}function Mo(n,e,t){function i(){let o=n.elementAtHeight(e.getBoundingClientRect().top+5-n.documentTop);n.coordsAtPos(o.from)&&n.dispatch({effects:Ft.of({pos:o.from,above:!1,clip:!1,create(){return{dom:Ci(n,t),getCoords:()=>e.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,wo(n,e)}let{hoverTime:s}=n.state.facet(tt),r=setTimeout(i,s);e.onmouseout=()=>{clearTimeout(r),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(r),r=setTimeout(i,s)}}function To(n,e){let t=Object.create(null);for(let s of e){let r=n.lineAt(s.from);(t[r.from]||(t[r.from]=[])).push(s)}let i=[];for(let s in t)i.push(new Ti(t[s]).range(+s));return Je.of(i,!0)}const Lo=$i({class:"cm-gutter-lint",markers:n=>n.state.field(yt),widgetMarker:(n,e,t)=>{let i=[];return n.state.field(yt).between(t.from,t.to,(s,r,o)=>{s>t.from&&s<t.to&&i.push(...o.diagnostics)}),i.length?new Ti(i):null}}),yt=H.define({create(){return Je.empty},update(n,e){n=n.map(e.changes);let t=e.state.facet(tt).markerFilter;for(let i of e.effects)if(i.is(et)){let s=i.value;t&&(s=t(s||[],e.state)),n=To(e.state.doc,s.slice(0))}return n}}),Ft=S.define(),Li=H.define({create(){return null},update(n,e){return n&&e.docChanged&&(n=bi(e,n)?null:Object.assign(Object.assign({},n),{pos:e.changes.mapPos(n.pos)})),e.effects.reduce((t,i)=>i.is(Ft)?i.value:t,n)},provide:n=>vn.from(n)}),Do=y.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:Ie('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:Ie('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:Ie('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),Di=[M,y.decorations.compute([M],n=>{let{selected:e,panel:t}=n.field(M);return!e||!t||e.from==e.to?b.none:b.set([go.range(e.from,e.to)])}),zi(xo,{hideOn:bi}),Co],tt=V.define({combine(n){return X(n,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function tl(n={}){return[tt.of(n),yt,Lo,Do,Li]}function nl(n,e){let t=n.field(M,!1);if(t&&t.diagnostics.size){let i=[],s=[],r=-1;for(let o=Je.iter([t.diagnostics]);;o.next()){for(let l=0;l<i.length;l++)(!o.value||o.value.spec.diagnostics.indexOf(i[l])<0)&&(e(i[l],s[l],r),i.splice(l,1),s.splice(l--,1));if(!o.value)break;for(let l of o.value.spec.diagnostics)i.indexOf(l)<0&&(i.push(l),s.push(o.from));r=o.to}}}var hn={};class He{constructor(e,t,i,s,r,o,l,a,c,h=0,f){this.p=e,this.stack=t,this.state=i,this.reducePos=s,this.pos=r,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=c,this.lookAhead=h,this.parent=f}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 s=e.parser.context;return new He(e,[],t,i,i,0,[],0,s?new fn(s,s.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,s=e&65535,{parser:r}=this.p,o=this.reducePos<this.pos-25;o&&this.setLookAhead(this.pos);let l=r.dynamicPrecedence(s);if(l&&(this.score+=l),i==0){this.pushState(r.getGoto(this.state,s,!0),this.reducePos),s<r.minRepeatTerm&&this.storeNode(s,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(s,this.reducePos);return}let a=this.stack.length-(i-1)*3-(e&262144?6:0),c=a?this.stack[a-2]:this.p.ranges[0].from,h=this.reducePos-c;h>=2e3&&!(!((t=this.p.parser.nodeSet.types[s])===null||t===void 0)&&t.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=h):this.p.lastBigReductionSize<h&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=c,this.p.lastBigReductionSize=h));let f=a?this.stack[a-1]:0,u=this.bufferBase+this.buffer.length-f;if(s<r.minRepeatTerm||e&131072){let d=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(s,c,d,u+4,!0)}if(e&262144)this.state=this.stack[a];else{let d=this.stack[a-3];this.state=r.getGoto(d,s,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(s,c)}storeNode(e,t,i,s=4,r=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,l=this.buffer.length;if(l==0&&o.parent&&(l=o.bufferBase-o.parent.bufferBase,o=o.parent),l>0&&o.buffer[l-4]==0&&o.buffer[l-1]>-1){if(t==i)return;if(o.buffer[l-2]>=t){o.buffer[l-2]=i;return}}}if(!r||this.pos==i)this.buffer.push(e,t,i,s);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>i;a-=4)if(this.buffer[a-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,s>4&&(s-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=i,this.buffer[o+3]=s}}shift(e,t,i,s){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let r=e,{parser:o}=this.p;(s>this.pos||t<=o.maxNode)&&(this.pos=s,o.stateFlag(r,1)||(this.reducePos=s)),this.pushState(r,i),this.shiftContext(t,i),t<=o.maxNode&&this.buffer.push(t,i,s,4)}else this.pos=s,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,s,4)}apply(e,t,i,s){e&65536?this.reduce(e):this.shift(e,t,i,s)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let s=this.pos;this.reducePos=this.pos=s+e.length,this.pushState(t,s),this.buffer.push(i,s,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>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),s=e.bufferBase+t;for(;e&&s==e.bufferBase;)e=e.parent;return new He(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,s,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 Bo(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 s=[];for(let r=0,o;r<t.length;r+=2)(o=t[r+1])!=this.state&&this.p.parser.hasAction(o,e)&&s.push(t[r],o);if(this.stack.length<120)for(let r=0;s.length<8&&r<t.length;r+=2){let o=t[r+1];s.some((l,a)=>a&1&&l==o)||s.push(t[r],o)}t=s}let i=[];for(let s=0;s<t.length&&i.length<4;s+=2){let r=t[s+1];if(r==this.state)continue;let o=this.split();o.pushState(r,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(t[s],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,s=t&65535,r=this.stack.length-i*3;if(r<0||e.getGoto(this.stack[r],s,!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=(s,r)=>{if(!t.includes(s))return t.push(s),e.allActions(s,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-r;if(l>1){let a=o&65535,c=this.stack.length-l*3;if(c>=0&&e.getGoto(this.stack[c],a,!1)>=0)return l<<19|65536|a}}else{let l=i(o,r+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 fn(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class fn{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class Bo{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 s=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=s}}class Ke{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 Ke(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 Ke(this.stack,this.pos,this.index)}}function Pe(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,s=0;i<n.length;){let r=0;for(;;){let o=n.charCodeAt(i++),l=!1;if(o==126){r=65535;break}o>=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),r+=a,l)break;r*=46}t?t[s++]=r:t=new e(r)}return t}class Oe{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const un=new Oe;class Po{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=un,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,s=this.rangeIndex,r=this.pos+e;for(;r<i.from;){if(!s)return null;let o=this.ranges[--s];r-=i.from-o.to,i=o}for(;t<0?r>i.to:r>=i.to;){if(s==this.ranges.length-1)return null;let o=this.ranges[++s];r+=o.from-i.to,i=o}return r}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,s;if(t>=0&&t<this.chunk.length)i=this.pos+e,s=this.chunk.charCodeAt(t);else{let r=this.resolveOffset(e,1);if(r==null)return-1;if(i=r,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)s=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)),s=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),s}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=un,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 s of this.ranges){if(s.from>=t)break;s.to>e&&(i+=this.input.read(Math.max(s.from,e),Math.min(s.to,t)))}return i}}class ae{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;Ro(this.data,e,t,this.id,i.data,i.tokenPrecTable)}}ae.prototype.contextual=ae.prototype.fallback=ae.prototype.extend=!1;ae.prototype.fallback=ae.prototype.extend=!1;class il{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function Ro(n,e,t,i,s,r){let o=0,l=1<<i,{dialect:a}=t.p.parser;e:for(;(l&n[o])!=0;){let c=n[o+1];for(let d=o+3;d<c;d+=2)if((n[d+1]&l)>0){let p=n[d];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||Io(p,e.token.value,s,r))){e.acceptToken(p);break}}let h=e.next,f=0,u=n[o+2];if(e.next<0&&u>f&&n[c+u*3-3]==65535){o=n[c+u*3-1];continue e}for(;f<u;){let d=f+u>>1,p=c+d+(d<<1),g=n[p],C=n[p+1]||65536;if(h<g)u=d;else if(h>=C)f=d+1;else{o=n[p+2],e.advance();continue e}}break}}function dn(n,e,t){for(let i=e,s;(s=n[i])!=65535;i++)if(s==t)return i-e;return-1}function Io(n,e,t,i){let s=dn(t,i,e);return s<0||dn(t,i,n)<s}const P=typeof process<"u"&&hn&&/\bparse\b/.test(hn.LOG);let ct=null;function pn(n,e,t){let i=n.cursor(Hi.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(n.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:n.length}}class Oo{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?pn(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?pn(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],s=this.index[t];if(s==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let r=i.children[s],o=this.start[t]+i.positions[s];if(o>e)return this.nextStart=o,null;if(r instanceof Re){if(o==e){if(o<this.safeFrom)return null;let l=o+r.length;if(l<=this.safeTo){let a=r.prop(ce.lookAhead);if(!a||l+a<this.fragment.to)return r}}this.index[t]++,o+r.length>=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+r.length}}}class Eo{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new Oe)}getActions(e){let t=0,i=null,{parser:s}=e.p,{tokenizers:r}=s,o=s.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let c=0;c<r.length;c++){if((1<<c&o)==0)continue;let h=r[c],f=this.tokens[c];if(!(i&&!h.fallback)&&((h.contextual||f.start!=e.pos||f.mask!=o||f.context!=l)&&(this.updateCachedToken(f,h,e),f.mask=o,f.context=l),f.lookAhead>f.end+25&&(a=Math.max(f.lookAhead,a)),f.value!=0)){let u=t;if(f.extended>-1&&(t=this.addActions(e,f.extended,f.end,t)),t=this.addActions(e,f.value,f.end,t),!h.extend&&(i=f,t>u))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!i&&e.pos==this.stream.end&&(i=new Oe,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 Oe,{pos:i,p:s}=e;return t.start=i,t.end=Math.min(i+1,s.stream.end),t.value=i==s.stream.end?s.parser.eofTerm:0,t}updateCachedToken(e,t,i){let s=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(s,e),i),e.value>-1){let{parser:r}=i.p;for(let o=0;o<r.specialized.length;o++)if(r.specialized[o]==e.value){let l=r.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(s+1)}putAction(e,t,i,s){for(let r=0;r<s;r+=3)if(this.actions[r]==e)return s;return this.actions[s++]=e,this.actions[s++]=t,this.actions[s++]=i,s}addActions(e,t,i,s){let{state:r}=e,{parser:o}=e.p,{data:l}=o;for(let a=0;a<2;a++)for(let c=o.stateSlot(r,a?2:1);;c+=3){if(l[c]==65535)if(l[c+1]==1)c=q(l,c+2);else{s==0&&l[c+1]==2&&(s=this.putAction(q(l,c+2),t,i,s));break}l[c]==t&&(s=this.putAction(q(l,c+1),t,i,s))}return s}}class No{constructor(e,t,i,s){this.parser=e,this.input=t,this.ranges=s,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 Po(t,s),this.tokens=new Eo(e,this.stream),this.topTerm=e.top[1];let{from:r}=s[0];this.stacks=[He.start(this,e.top[0],r)],this.fragments=i.length&&this.stream.end-r>e.bufferLength*4?new Oo(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],s,r;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;{s||(s=[],r=[]),s.push(l);let a=this.tokens.getMainToken(l);r.push(a.value,a.end)}}break}}if(!i.length){let o=s&&zo(s);if(o)return P&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw P&&s&&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&&s){let o=this.stoppedAt!=null&&s[0].pos>this.stoppedAt?s[0]:this.runRecovery(s,r,i);if(o)return P&&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,a)=>a.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 a=o+1;a<i.length;a++){let c=i[a];if(l.sameState(c)||l.buffer.length>500&&c.buffer.length>500)if((l.score-c.score||l.buffer.length-c.buffer.length)>0)i.splice(a--,1);else{i.splice(o--,1);continue e}}}i.length>12&&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 s=e.pos,{parser:r}=this,o=P?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&s>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,h=c?e.curContext.hash:0;for(let f=this.fragments.nodeAt(s);f;){let u=this.parser.nodeSet.types[f.type.id]==f.type?r.getGoto(e.state,f.type.id):-1;if(u>-1&&f.length&&(!c||(f.prop(ce.contextHash)||0)==h))return e.useNode(f,u),P&&console.log(o+this.stackID(e)+` (via reuse of ${r.getName(f.type.id)})`),!0;if(!(f instanceof Re)||f.children.length==0||f.positions[0]>0)break;let d=f.children[0];if(d instanceof Re&&f.positions[0]==0)f=d;else break}}let l=r.stateSlot(e.state,4);if(l>0)return e.reduce(l),P&&console.log(o+this.stackID(e)+` (via always-reduce ${r.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let c=0;c<a.length;){let h=a[c++],f=a[c++],u=a[c++],d=c==a.length||!i,p=d?e:e.split(),g=this.tokens.mainToken;if(p.apply(h,f,g?g.start:p.pos,u),P&&console.log(o+this.stackID(p)+` (via ${(h&65536)==0?"shift":`reduce of ${r.getName(h&65535)}`} for ${r.getName(f)} @ ${s}${p==e?"":", split"})`),d)return!0;p.pos>s?t.push(p):i.push(p)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return mn(e,t),!0}}runRecovery(e,t,i){let s=null,r=!1;for(let o=0;o<e.length;o++){let l=e[o],a=t[o<<1],c=t[(o<<1)+1],h=P?this.stackID(l)+" -> ":"";if(l.deadEnd&&(r||(r=!0,l.restart(),P&&console.log(h+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let f=l.split(),u=h;for(let d=0;f.forceReduce()&&d<10&&(P&&console.log(u+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,i));d++)P&&(u=this.stackID(f)+" -> ");for(let d of l.recoverByInsert(a))P&&console.log(h+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>l.pos?(c==l.pos&&(c++,a=0),l.recoverByDelete(a,c),P&&console.log(h+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),mn(l,i)):(!s||s.score<l.score)&&(s=l)}return s}stackToTree(e){return e.close(),Re.build({buffer:Ke.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=(ct||(ct=new WeakMap)).get(e);return t||ct.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function mn(n,e){for(let t=0;t<e.length;t++){let i=e[t];if(i.pos==n.pos&&i.sameState(n)){e[t].score<n.score&&(e[t]=n);return}}e.push(n)}class Fo{constructor(e,t,i){this.source=e,this.flags=t,this.disabled=i}allows(e){return!this.disabled||this.disabled[e]==0}}class kt extends Ui{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]),s=[];for(let l=0;l<t.length;l++)s.push([]);function r(l,a,c){s[l].push([a,a.deserialize(String(c))])}if(e.nodeProps)for(let l of e.nodeProps){let a=l[0];typeof a=="string"&&(a=ce[a]);for(let c=1;c<l.length;){let h=l[c++];if(h>=0)r(h,a,l[c++]);else{let f=l[c+-h];for(let u=-h;u>0;u--)r(l[c++],a,f);c++}}}this.nodeSet=new ji(t.map((l,a)=>Gi.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:s[a],top:i.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Vi;let o=Pe(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(gn),this.states=Pe(e.states,Uint32Array),this.data=Pe(e.stateData),this.goto=Pe(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new ae(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 s=new No(this,e,t,i);for(let r of this.wrappers)s=r(s,e,t,i);return s}getGoto(e,t,i=!1){let s=this.goto;if(t>=s[0])return-1;for(let r=s[t+1];;){let o=s[r++],l=o&1,a=s[r++];if(l&&i)return a;for(let c=r+(o>>1);r<c;r++)if(s[r]==e)return a;if(l)return-1}}hasAction(e,t){let i=this.data;for(let s=0;s<2;s++)for(let r=this.stateSlot(e,s?2:1),o;;r+=3){if((o=i[r])==65535)if(i[r+1]==1)o=i[r=q(i,r+2)];else{if(i[r+1]==2)return q(i,r+2);break}if(o==t||o==0)return q(i,r+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),s=i?t(i):void 0;for(let r=this.stateSlot(e,1);s==null;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=q(this.data,r+2);else break;s=t(q(this.data,r+1))}return s}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=q(this.data,i+2);else break;if((this.data[i+2]&1)==0){let s=this.data[i+1];t.some((r,o)=>o&1&&r==s)||t.push(this.data[i],s)}}return t}configure(e){let t=Object.assign(Object.create(kt.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 s=e.tokenizers.find(r=>r.from==i);return s?s.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,s)=>{let r=e.specializers.find(l=>l.from==i.external);if(!r)return i;let o=Object.assign(Object.assign({},i),{external:r.to});return t.specializers[s]=gn(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 r of e.split(" ")){let o=t.indexOf(r);o>=0&&(i[o]=!0)}let s=null;for(let r=0;r<t.length;r++)if(!i[r])for(let o=this.dialects[t[r]],l;(l=this.data[o++])!=65535;)(s||(s=new Uint8Array(this.maxTerm+1)))[l]=1;return new Fo(e,i,s)}static deserialize(e){return new kt(e)}}function q(n,e){return n[e]|n[e+1]<<16}function zo(n){let e=null;for(let t of n){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 gn(n){if(n.external){let e=n.extend?1:0;return(t,i)=>n.external(t,i)<<1|e}return n.get}export{il as E,kt as L,el as a,Jr as b,Qo as c,Yo as d,$o as e,_o as f,Ho as g,Go as h,Uo as i,Vo as j,uo as k,tl as l,Zo as m,x as n,et as o,Xo as p,nl as q,qo as r,sn as s,jo as t,Jo as u,Pr as v,Ko as w,Rn as x,Pn as y};
1
+ import{ci as y,cl as ve,cm as V,cn as H,c_ as bt,c$ as S,cy as m,d0 as me,ck as b,co as X,d1 as vt,d2 as R,d3 as U,d4 as St,d5 as w,cP as Ct,c6 as Bi,d6 as Y,d7 as Pi,cO as ge,d8 as xn,d9 as yn,da as At,db as Ee,dc as kn,cR as wt,cx as it,cg as Z,dd as ce,cU as Ri,de as Ii,df as bn,dg as se,cV as Oi,dh as vn,di as Sn,dj as Je,dk as Ne,ap as Ei,dl as Ni,dm as Fi,dn as zi,dp as $i,ch as Wi,cj as qi,dq as Ui,dr as ji,ds as Gi,dt as Vi,du as Re,dv as Hi}from"./JGp8ZHkv.js";function x(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var s=t[i];typeof s=="string"?n.setAttribute(i,s):s!=null&&(n[i]=s)}e++}for(;e<arguments.length;e++)Cn(n,arguments[e]);return n}function Cn(n,e){if(typeof e=="string")n.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)n.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)Cn(n,e[t]);else throw new RangeError("Unsupported child node: "+e)}const zt=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n;class he{constructor(e,t,i=0,s=e.length,r,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,s),this.bufferStart=i,this.normalize=r?l=>r(zt(l)):zt,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 R(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=St(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=U(e);let s=this.normalize(t);if(s.length)for(let r=0,o=i;;r++){let l=s.charCodeAt(r),a=this.match(l,o,this.bufferPos+this.bufferStart);if(r==s.length-1){if(a)return this.value=a,this;break}o==i&&r<t.length&&t.charCodeAt(r)==l&&o++}}}match(e,t,i){let s=null;for(let r=0;r<this.matches.length;r+=2){let o=this.matches[r],l=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?s={from:this.matches[r+1],to:i}:(this.matches[r]++,l=!0)),l||(this.matches.splice(r,2),r-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?s={from:t,to:i}:this.matches.push(1,t)),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}typeof Symbol<"u"&&(he.prototype[Symbol.iterator]=function(){return this});const An={from:-1,to:-1,match:/.*/.exec("")},Mt="gm"+(/x/.unicode==null?"":"u");class wn{constructor(e,t,i,s=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=An,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Mn(e,t,i,s,r);this.re=new RegExp(t,Mt+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.iter=e.iter();let o=e.lineAt(s);this.curLineStart=o.from,this.matchPos=Fe(e,s),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,s=i+t[0].length;if(this.matchPos=Fe(this.text,s+(i==s?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<s||i>this.value.to)&&(!this.test||this.test(i,s,t)))return this.value={from:i,to:s,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 st=new WeakMap;class oe{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let s=st.get(e);if(!s||s.from>=i||s.to<=t){let l=new oe(t,e.sliceString(t,i));return st.set(e,l),l}if(s.from==t&&s.to==i)return s;let{text:r,from:o}=s;return o>t&&(r=e.sliceString(t,o)+r,o=t),s.to<i&&(r+=e.sliceString(s.to,i)),st.set(e,new oe(o,r)),new oe(t,r.slice(t-o,i-o))}}class Mn{constructor(e,t,i,s,r){this.text=e,this.to=r,this.done=!1,this.value=An,this.matchPos=Fe(e,s),this.re=new RegExp(t,Mt+(i!=null&&i.ignoreCase?"i":"")),this.test=i==null?void 0:i.test,this.flat=oe.get(e,s,this.chunkEnd(s+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,s=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,s,t)))return this.value={from:i,to:s,match:t},this.matchPos=Fe(this.text,s+(i==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=oe.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(wn.prototype[Symbol.iterator]=Mn.prototype[Symbol.iterator]=function(){return this});function Ki(n){try{return new RegExp(n,Mt),!0}catch{return!1}}function Fe(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e<t.to&&(i=t.text.charCodeAt(e-t.from))>=56320&&i<57344;)e++;return e}function ht(n){let e=String(n.state.doc.lineAt(n.state.selection.main.head).number),t=x("input",{class:"cm-textfield",name:"line",value:e}),i=x("form",{class:"cm-gotoLine",onkeydown:r=>{r.keyCode==27?(r.preventDefault(),n.dispatch({effects:pe.of(!1)}),n.focus()):r.keyCode==13&&(r.preventDefault(),s())},onsubmit:r=>{r.preventDefault(),s()}},x("label",n.state.phrase("Go to line"),": ",t)," ",x("button",{class:"cm-button",type:"submit"},n.state.phrase("go")),x("button",{name:"close",onclick:()=>{n.dispatch({effects:pe.of(!1)}),n.focus()},"aria-label":n.state.phrase("close"),type:"button"},["×"]));function s(){let r=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!r)return;let{state:o}=n,l=o.doc.lineAt(o.selection.main.head),[,a,c,h,f]=r,u=h?+h.slice(1):0,d=c?+c:l.number;if(c&&f){let C=d/100;a&&(C=C*(a=="-"?-1:1)+l.number/o.doc.lines),d=Math.round(o.doc.lines*C)}else c&&a&&(d=d*(a=="-"?-1:1)+l.number);let p=o.doc.line(Math.max(1,Math.min(o.doc.lines,d))),g=m.cursor(p.from+Math.max(0,Math.min(u,p.length)));n.dispatch({effects:[pe.of(!1),y.scrollIntoView(g.from,{y:"center"})],selection:g}),n.focus()}return{dom:i}}const pe=S.define(),$t=H.define({create(){return!0},update(n,e){for(let t of e.effects)t.is(pe)&&(n=t.value);return n},provide:n=>vt.from(n,e=>e?ht:null)}),Ji=n=>{let e=me(n,ht);if(!e){let t=[pe.of(!0)];n.state.field($t,!1)==null&&t.push(S.appendConfig.of([$t,Qi])),n.dispatch({effects:t}),e=me(n,ht)}return e&&e.dom.querySelector("input").select(),!0},Qi=y.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),_i={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Yi=V.define({combine(n){return X(n,_i,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Wo(n){return[ns,ts]}const Xi=b.mark({class:"cm-selectionMatch"}),Zi=b.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Wt(n,e,t,i){return(t==0||n(e.sliceDoc(t-1,t))!=w.Word)&&(i==e.doc.length||n(e.sliceDoc(i,i+1))!=w.Word)}function es(n,e,t,i){return n(e.sliceDoc(t,t+1))==w.Word&&n(e.sliceDoc(i-1,i))==w.Word}const ts=ve.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(Yi),{state:t}=n,i=t.selection;if(i.ranges.length>1)return b.none;let s=i.main,r,o=null;if(s.empty){if(!e.highlightWordAroundCursor)return b.none;let a=t.wordAt(s.head);if(!a)return b.none;o=t.charCategorizer(s.head),r=t.sliceDoc(a.from,a.to)}else{let a=s.to-s.from;if(a<e.minSelectionLength||a>200)return b.none;if(e.wholeWords){if(r=t.sliceDoc(s.from,s.to),o=t.charCategorizer(s.head),!(Wt(o,t,s.from,s.to)&&es(o,t,s.from,s.to)))return b.none}else if(r=t.sliceDoc(s.from,s.to),!r)return b.none}let l=[];for(let a of n.visibleRanges){let c=new he(t.doc,r,a.from,a.to);for(;!c.next().done;){let{from:h,to:f}=c.value;if((!o||Wt(o,t,h,f))&&(s.empty&&h<=s.from&&f>=s.to?l.push(Zi.range(h,f)):(h>=s.to||f<=s.from)&&l.push(Xi.range(h,f)),l.length>e.maxMatches))return b.none}}return b.set(l)}},{decorations:n=>n.decorations}),ns=y.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),is=({state:n,dispatch:e})=>{let{selection:t}=n,i=m.create(t.ranges.map(s=>n.wordAt(s.head)||m.cursor(s.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function ss(n,e){let{main:t,ranges:i}=n.selection,s=n.wordAt(t.head),r=s&&s.from==t.from&&s.to==t.to;for(let o=!1,l=new he(n.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new he(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(a=>a.from==l.value.from))continue;if(r){let a=n.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}const rs=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(r=>r.from===r.to))return is({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(r=>n.sliceDoc(r.from,r.to)!=i))return!1;let s=ss(n,i);return s?(e(n.update({selection:n.selection.addRange(m.range(s.from,s.to),!1),effects:y.scrollIntoView(s.to)})),!0):!1},ee=V.define({combine(n){return X(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new gs(e),scrollToMatch:e=>y.scrollIntoView(e)})}});function qo(n){return n?[ee.of(n),ut]:ut}class Tn{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||Ki(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?`
2
+ `: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}create(){return this.regexp?new cs(this):new ls(this)}getCursor(e,t=0,i){let s=e.doc?e:Bi.create({doc:e});return i==null&&(i=s.doc.length),this.regexp?ie(this,s,t,i):ne(this,s,t,i)}}class Ln{constructor(e){this.spec=e}}function ne(n,e,t,i){return new he(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:s=>s.toLowerCase(),n.wholeWord?os(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function os(n,e){return(t,i,s,r)=>((r>t||r+s.length<i)&&(r=Math.max(0,t-2),s=n.sliceString(r,Math.min(n.length,i+2))),(e(ze(s,t-r))!=w.Word||e($e(s,t-r))!=w.Word)&&(e($e(s,i-r))!=w.Word||e(ze(s,i-r))!=w.Word))}class ls extends Ln{constructor(e){super(e)}nextMatch(e,t,i){let s=ne(this.spec,e,i,e.doc.length).nextOverlapping();if(s.done){let r=Math.min(e.doc.length,t+this.spec.unquoted.length);s=ne(this.spec,e,0,r).nextOverlapping()}return s.done||s.value.from==t&&s.value.to==i?null:s.value}prevMatchInRange(e,t,i){for(let s=i;;){let r=Math.max(t,s-1e4-this.spec.unquoted.length),o=ne(this.spec,e,r,s),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(r==t)return null;s-=1e4}}prevMatch(e,t,i){let s=this.prevMatchInRange(e,0,t);return s||(s=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),s&&(s.from!=t||s.to!=i)?s:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=ne(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=ne(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}function ie(n,e,t,i){return new wn(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:n.wholeWord?as(e.charCategorizer(e.selection.main.head)):void 0},t,i)}function ze(n,e){return n.slice(Y(n,e,!1),e)}function $e(n,e){return n.slice(e,Y(n,e))}function as(n){return(e,t,i)=>!i[0].length||(n(ze(i.input,i.index))!=w.Word||n($e(i.input,i.index))!=w.Word)&&(n($e(i.input,i.index+i[0].length))!=w.Word||n(ze(i.input,i.index+i[0].length))!=w.Word)}class cs extends Ln{nextMatch(e,t,i){let s=ie(this.spec,e,i,e.doc.length).next();return s.done&&(s=ie(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,i){for(let s=1;;s++){let r=Math.max(t,i-s*1e4),o=ie(this.spec,e,r,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(r==t||l.from>r+10))return l;if(r==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 s=i.length;s>0;s--){let r=+i.slice(0,s);if(r>0&&r<e.match.length)return e.match[r]+i.slice(s)}return t})}matchAll(e,t){let i=ie(this.spec,e,0,e.doc.length),s=[];for(;!i.next().done;){if(s.length>=t)return null;s.push(i.value)}return s}highlight(e,t,i,s){let r=ie(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}const xe=S.define(),Tt=S.define(),G=H.define({create(n){return new rt(ft(n).create(),null)},update(n,e){for(let t of e.effects)t.is(xe)?n=new rt(t.value.create(),n.panel):t.is(Tt)&&(n=new rt(n.query,t.value?Lt:null));return n},provide:n=>vt.from(n,e=>e.panel)});class rt{constructor(e,t){this.query=e,this.panel=t}}const hs=b.mark({class:"cm-searchMatch"}),fs=b.mark({class:"cm-searchMatch cm-searchMatch-selected"}),us=ve.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(G))}update(n){let e=n.state.field(G);(e!=n.startState.field(G)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return b.none;let{view:t}=this,i=new Ct;for(let s=0,r=t.visibleRanges,o=r.length;s<o;s++){let{from:l,to:a}=r[s];for(;s<o-1&&a>r[s+1].from-2*250;)a=r[++s].to;n.highlight(t.state,l,a,(c,h)=>{let f=t.state.selection.ranges.some(u=>u.from==c&&u.to==h);i.add(c,h,f?fs:hs)})}return i.finish()}},{decorations:n=>n.decorations});function Se(n){return e=>{let t=e.state.field(G,!1);return t&&t.query.spec.valid?n(e,t):Pn(e)}}const We=Se((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let s=m.single(i.from,i.to),r=n.state.facet(ee);return n.dispatch({selection:s,effects:[Dt(n,i),r.scrollToMatch(s.main,n)],userEvent:"select.search"}),Bn(n),!0}),qe=Se((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,s=e.prevMatch(t,i,i);if(!s)return!1;let r=m.single(s.from,s.to),o=n.state.facet(ee);return n.dispatch({selection:r,effects:[Dt(n,s),o.scrollToMatch(r.main,n)],userEvent:"select.search"}),Bn(n),!0}),ds=Se((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:m.create(t.map(i=>m.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),ps=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:s}=t.main,r=[],o=0;for(let l=new he(n.doc,n.sliceDoc(i,s));!l.next().done;){if(r.length>1e3)return!1;l.value.from==i&&(o=r.length),r.push(m.range(l.value.from,l.value.to))}return e(n.update({selection:m.create(r,o),userEvent:"select.search.matches"})),!0},qt=Se((n,{query:e})=>{let{state:t}=n,{from:i,to:s}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,i,i);if(!r)return!1;let o=r,l=[],a,c,h=[];if(o.from==i&&o.to==s&&(c=t.toText(e.getReplacement(o)),l.push({from:o.from,to:o.to,insert:c}),o=e.nextMatch(t,o.from,o.to),h.push(y.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))),o){let f=l.length==0||l[0].from>=r.to?0:r.to-r.from-c.length;a=m.single(o.from-f,o.to-f),h.push(Dt(n,o)),h.push(t.facet(ee).scrollToMatch(a.main,n))}return n.dispatch({changes:l,selection:a,effects:h,userEvent:"input.replace"}),!0}),ms=Se((n,{query:e})=>{if(n.state.readOnly)return!1;let t=e.matchAll(n.state,1e9).map(s=>{let{from:r,to:o}=s;return{from:r,to:o,insert:e.getReplacement(s)}});if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:y.announce.of(i),userEvent:"input.replace.all"}),!0});function Lt(n){return n.state.facet(ee).createPanel(n)}function ft(n,e){var t,i,s,r,o;let l=n.selection.main,a=l.empty||l.to>l.from+100?"":n.sliceDoc(l.from,l.to);if(e&&!a)return e;let c=n.facet(ee);return new Tn({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:c.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=e==null?void 0:e.caseSensitive)!==null&&i!==void 0?i:c.caseSensitive,literal:(s=e==null?void 0:e.literal)!==null&&s!==void 0?s:c.literal,regexp:(r=e==null?void 0:e.regexp)!==null&&r!==void 0?r:c.regexp,wholeWord:(o=e==null?void 0:e.wholeWord)!==null&&o!==void 0?o:c.wholeWord})}function Dn(n){let e=me(n,Lt);return e&&e.dom.querySelector("[main-field]")}function Bn(n){let e=Dn(n);e&&e==n.root.activeElement&&e.select()}const Pn=n=>{let e=n.state.field(G,!1);if(e&&e.panel){let t=Dn(n);if(t&&t!=n.root.activeElement){let i=ft(n.state,e.query.spec);i.valid&&n.dispatch({effects:xe.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[Tt.of(!0),e?xe.of(ft(n.state,e.query.spec)):S.appendConfig.of(ut)]});return!0},Rn=n=>{let e=n.state.field(G,!1);if(!e||!e.panel)return!1;let t=me(n,Lt);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Tt.of(!1)}),!0},Uo=[{key:"Mod-f",run:Pn,scope:"editor search-panel"},{key:"F3",run:We,shift:qe,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:We,shift:qe,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Rn,scope:"editor search-panel"},{key:"Mod-Shift-l",run:ps},{key:"Mod-Alt-g",run:Ji},{key:"Mod-d",run:rs,preventDefault:!0}];class gs{constructor(e){this.view=e;let t=this.query=e.state.field(G).query.spec;this.commit=this.commit.bind(this),this.searchField=x("input",{value:t.search,placeholder:B(e,"Find"),"aria-label":B(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=x("input",{value:t.replace,placeholder:B(e,"Replace"),"aria-label":B(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=x("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=x("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=x("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(s,r,o){return x("button",{class:"cm-button",name:s,onclick:r,type:"button"},o)}this.dom=x("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,i("next",()=>We(e),[B(e,"next")]),i("prev",()=>qe(e),[B(e,"previous")]),i("select",()=>ds(e),[B(e,"all")]),x("label",null,[this.caseField,B(e,"match case")]),x("label",null,[this.reField,B(e,"regexp")]),x("label",null,[this.wordField,B(e,"by word")]),...e.state.readOnly?[]:[x("br"),this.replaceField,i("replace",()=>qt(e),[B(e,"replace")]),i("replaceAll",()=>ms(e),[B(e,"replace all")])],x("button",{name:"close",onclick:()=>Rn(e),"aria-label":B(e,"close"),type:"button"},["×"])])}commit(){let e=new Tn({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:xe.of(e)}))}keydown(e){Pi(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?qe:We)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),qt(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(xe)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(ee).top}}function B(n,e){return n.state.phrase(e)}const we=30,Me=/[\s\.,:;?!]/;function Dt(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),s=n.state.doc.lineAt(t).to,r=Math.max(i.from,e-we),o=Math.min(s,t+we),l=n.state.sliceDoc(r,o);if(r!=i.from){for(let a=0;a<we;a++)if(!Me.test(l[a+1])&&Me.test(l[a])){l=l.slice(a);break}}if(o!=s){for(let a=l.length-1;a>l.length-we;a--)if(!Me.test(l[a-1])&&Me.test(l[a])){l=l.slice(0,a);break}}return y.announce.of(`${n.state.phrase("current match")}. ${l} ${n.state.phrase("on line")} ${i.number}.`)}const xs=y.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),ut=[G,bt.low(us),xs];function ys(n,e=n.state){const t=new Set;for(const{from:i,to:s}of n.visibleRanges){let r=i;for(;r<=s;){const o=e.doc.lineAt(r);t.has(o)||t.add(o),r=o.to+1}}return t}function dt(n){const e=n.selection.main.head;return n.doc.lineAt(e)}function Ut(n,e){let t=0;e:for(let i=0;i<n.length;i++)switch(n[i]){case" ":case" ":{t+=1;continue e}case" ":{t+=e-t%e;continue e}case"\r":continue e;default:break e}return t}const Ue=V.define({combine(n){return X(n,{highlightActiveBlock:!0,hideFirstIndent:!1,markerType:"fullScope",thickness:1})}});class ks{constructor(e,t,i,s){this.lines=e,this.state=t,this.map=new Map,this.unitWidth=i,this.markerType=s;for(const r of this.lines)this.add(r);this.state.facet(Ue).highlightActiveBlock&&this.findAndSetActiveLines()}has(e){return this.map.has(typeof e=="number"?e:e.number)}get(e){const t=this.map.get(typeof e=="number"?e:e.number);if(!t)throw new Error("Line not found in indentation map");return t}set(e,t,i){const s=!e.text.trim().length,r={line:e,col:t,level:i,empty:s};return this.map.set(r.line.number,r),r}add(e){if(this.has(e))return this.get(e);if(!e.length||!e.text.trim().length){if(e.number===1)return this.set(e,0,0);if(e.number===this.state.doc.lines){const o=this.closestNonEmpty(e,-1);return this.set(e,0,o.level)}const s=this.closestNonEmpty(e,-1),r=this.closestNonEmpty(e,1);return s.level>=r.level&&this.markerType!=="codeOnly"?this.set(e,0,s.level):s.empty&&s.level===0&&r.level!==0?this.set(e,0,0):r.level>s.level?this.set(e,0,s.level+1):this.set(e,0,r.level)}const t=Ut(e.text,this.state.tabSize),i=Math.floor(t/this.unitWidth);return this.set(e,t,i)}closestNonEmpty(e,t){let i=e.number+t;for(;t===-1?i>=1:i<=this.state.doc.lines;){if(this.has(i)){const o=this.get(i);if(!o.empty)return o}const r=this.state.doc.line(i);if(r.text.trim().length){const o=Ut(r.text,this.state.tabSize),l=Math.floor(o/this.unitWidth);return this.set(r,o,l)}i+=t}const s=this.state.doc.line(t===-1?1:this.state.doc.lines);return this.set(s,0,0)}findAndSetActiveLines(){const e=dt(this.state);if(!this.has(e))return;let t=this.get(e);if(this.has(t.line.number+1)){const r=this.get(t.line.number+1);r.level>t.level&&(t=r)}if(this.has(t.line.number-1)){const r=this.get(t.line.number-1);r.level>t.level&&(t=r)}if(t.level===0)return;t.active=t.level;let i,s;for(i=t.line.number;i>1;i--){if(!this.has(i-1))continue;const r=this.get(i-1);if(r.level<t.level)break;r.active=t.level}for(s=t.line.number;s<this.state.doc.lines;s++){if(!this.has(s+1))continue;const r=this.get(s+1);if(r.level<t.level)break;r.active=t.level}}}function bs(n){const e={light:"#F0F1F2",dark:"#2B3245",activeLight:"#E4E5E6",activeDark:"#3C445C"};let t=e;return n&&(t=Object.assign(Object.assign({},e),n)),y.baseTheme({"&light":{"--indent-marker-bg-color":t.light,"--indent-marker-active-bg-color":t.activeLight},"&dark":{"--indent-marker-bg-color":t.dark,"--indent-marker-active-bg-color":t.activeDark},".cm-line":{position:"relative"},".cm-indent-markers::before":{content:'""',position:"absolute",top:0,left:"2px",right:0,bottom:0,background:"var(--indent-markers)",pointerEvents:"none",zIndex:"-1"}})}function Te(n,e,t,i,s){return`${`repeating-linear-gradient(to right, var(${n}) 0 ${e}px, transparent ${e}px ${t}ch)`} ${i*t}.5ch/calc(${t*s}ch - 1px) no-repeat`}function vs(n,e,t,i,s){const{level:r,active:o}=n;if(s=s??i,t&&r===0)return[];const l=t?1:0,a=[];if(o!==void 0){const c=o-l-1;c>0&&a.push(Te("--indent-marker-bg-color",i,e,l,c)),a.push(Te("--indent-marker-active-bg-color",s,e,o-1,1)),o!==r&&a.push(Te("--indent-marker-bg-color",i,e,o,r-o))}else a.push(Te("--indent-marker-bg-color",i,e,l,r-l));return a.join(",")}class Ss{constructor(e){this.view=e,this.unitWidth=ge(e.state),this.currentLineNumber=dt(e.state).number,this.generate(e.state)}update(e){const t=ge(e.state),i=t!==this.unitWidth;i&&(this.unitWidth=t);const s=dt(e.state).number,r=s!==this.currentLineNumber;this.currentLineNumber=s;const o=e.state.facet(Ue).highlightActiveBlock&&r;(e.docChanged||e.viewportChanged||i||o)&&this.generate(e.state)}generate(e){const t=new Ct,i=ys(this.view,e),{hideFirstIndent:s,markerType:r,thickness:o,activeThickness:l}=e.facet(Ue),a=new ks(i,e,this.unitWidth,r);for(const c of i){const h=a.get(c.number);if(!(h!=null&&h.level))continue;const f=vs(h,this.unitWidth,s,o,l);t.add(c.from,c.from,b.line({class:"cm-indent-markers",attributes:{style:`--indent-markers: ${f}`}}))}this.decorations=t.finish()}}function jo(n={}){return[Ue.of(n),bs(n.colors),ve.fromClass(Ss,{decorations:e=>e.decorations})]}const Cs=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=Pt(n.state,t.from);return i.line?As(n):i.block?Ms(n):!1};function Bt(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let s=n(e,t);return s?(i(t.update(s)),!0):!1}}const As=Bt(Ds,0),ws=Bt(In,0),Ms=Bt((n,e)=>In(n,e,Ls(e)),0);function Pt(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const de=50;function Ts(n,{open:e,close:t},i,s){let r=n.sliceDoc(i-de,i),o=n.sliceDoc(s,s+de),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,c=r.length-l;if(r.slice(c-e.length,c)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:s+a,margin:a&&1}};let h,f;s-i<=2*de?h=f=n.sliceDoc(i,s):(h=n.sliceDoc(i,i+de),f=n.sliceDoc(s-de,s));let u=/^\s*/.exec(h)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-t.length;return h.slice(u,u+e.length)==e&&f.slice(p,p+t.length)==t?{open:{pos:i+u+e.length,margin:/\s/.test(h.charAt(u+e.length))?1:0},close:{pos:s-d-t.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function Ls(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),s=t.to<=i.to?i:n.doc.lineAt(t.to);s.from>i.from&&s.from==t.to&&(s=t.to==i.to+1?i:n.doc.lineAt(t.to-1));let r=e.length-1;r>=0&&e[r].to>i.from?e[r].to=s.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:s.to})}return e}function In(n,e,t=e.selection.ranges){let i=t.map(r=>Pt(e,r.from).block);if(!i.every(r=>r))return null;let s=t.map((r,o)=>Ts(e,i[o],r.from,r.to));if(n!=2&&!s.every(r=>r))return{changes:e.changes(t.map((r,o)=>s[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(n!=1&&s.some(r=>r)){let r=[];for(let o=0,l;o<s.length;o++)if(l=s[o]){let a=i[o],{open:c,close:h}=l;r.push({from:c.pos-a.open.length,to:c.pos+c.margin},{from:h.pos-h.margin,to:h.pos+a.close.length})}return{changes:r}}return null}function Ds(n,e,t=e.selection.ranges){let i=[],s=-1;for(let{from:r,to:o}of t){let l=i.length,a=1e9,c=Pt(e,r).line;if(c){for(let h=r;h<=o;){let f=e.doc.lineAt(h);if(f.from>s&&(r==o||o>f.from)){s=f.from;let u=/^\s*/.exec(f.text)[0].length,d=u==f.length,p=f.text.slice(u,u+c.length)==c?u:-1;u<f.text.length&&u<a&&(a=u),i.push({line:f,comment:p,token:c,indent:u,empty:d,single:!1})}h=f.to+1}if(a<1e9)for(let h=l;h<i.length;h++)i[h].indent<i[h].line.text.length&&(i[h].indent=a);i.length==l+1&&(i[l].single=!0)}}if(n!=2&&i.some(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:c,empty:h,single:f}of i)(f||!h)&&r.push({from:l.from+c,insert:a+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let c=o.from+l,h=c+a.length;o.text[h-o.from]==" "&&h++,r.push({from:c,to:h})}return{changes:r}}return null}const pt=wt.define(),Bs=wt.define(),Ps=V.define(),On=V.define({combine(n){return X(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,s)=>e(i,s)||t(i,s)})}}),En=H.define({create(){return F.empty},update(n,e){let t=e.state.facet(On),i=e.annotation(pt);if(i){let a=D.fromTransaction(e,i.selection),c=i.side,h=c==0?n.undone:n.done;return a?h=je(h,h.length,t.minDepth,a):h=zn(h,e.startState.selection),new F(c==0?i.rest:h,c==0?h:i.rest)}let s=e.annotation(Bs);if((s=="full"||s=="before")&&(n=n.isolate()),e.annotation(it.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let r=D.fromTransaction(e),o=e.annotation(it.time),l=e.annotation(it.userEvent);return r?n=n.addChanges(r,o,l,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(s=="full"||s=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new F(n.done.map(D.fromJSON),n.undone.map(D.fromJSON))}});function Go(n={}){return[En,On.of(n),y.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?Nn:e.inputType=="historyRedo"?mt:null;return i?(e.preventDefault(),i(t)):!1}})]}function Qe(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let s=t.field(En,!1);if(!s)return!1;let r=s.pop(n,t,e);return r?(i(r),!0):!1}}const Nn=Qe(0,!1),mt=Qe(1,!1),Rs=Qe(0,!0),Is=Qe(1,!0);class D{constructor(e,t,i,s,r){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=s,this.selectionsAfter=r}setSelAfter(e){return new D(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(s=>s.toJSON())}}static fromJSON(e){return new D(e.changes&&Ri.fromJSON(e.changes),[],e.mapped&&Ii.fromJSON(e.mapped),e.startSelection&&m.fromJSON(e.startSelection),e.selectionsAfter.map(m.fromJSON))}static fromTransaction(e,t){let i=I;for(let s of e.startState.facet(Ps)){let r=s(e);r.length&&(i=i.concat(r))}return!i.length&&e.changes.empty?null:new D(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,I)}static selection(e){return new D(void 0,I,void 0,void 0,e)}}function je(n,e,t,i){let s=e+1>t+20?e-t-1:0,r=n.slice(s,e);return r.push(i),r}function Os(n,e){let t=[],i=!1;return n.iterChangedRanges((s,r)=>t.push(s,r)),e.iterChangedRanges((s,r,o,l)=>{for(let a=0;a<t.length;){let c=t[a++],h=t[a++];l>=c&&o<=h&&(i=!0)}}),i}function Es(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function Fn(n,e){return n.length?e.length?n.concat(e):n:e}const I=[],Ns=200;function zn(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-Ns));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),je(n,n.length-1,1e9,t.setSelAfter(i)))}else return[D.selection([e])]}function Fs(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function ot(n,e){if(!n.length)return n;let t=n.length,i=I;for(;t;){let s=zs(n[t-1],e,i);if(s.changes&&!s.changes.empty||s.effects.length){let r=n.slice(0,t);return r[t-1]=s,r}else e=s.mapped,t--,i=s.selectionsAfter}return i.length?[D.selection(i)]:I}function zs(n,e,t){let i=Fn(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):I,t);if(!n.changes)return D.selection(i);let s=n.changes.map(e),r=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(r):r;return new D(s,S.mapEffects(n.effects,e),o,n.startSelection.map(r),i)}const $s=/^(input\.type|delete)($|\.)/;class F{constructor(e,t,i=0,s=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=s}isolate(){return this.prevTime?new F(this.done,this.undone):this}addChanges(e,t,i,s,r){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||$s.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<s.newGroupDelay&&s.joinToEvent(r,Os(l.changes,e.changes))||i=="input.type.compose")?o=je(o,o.length-1,s.minDepth,new D(e.changes.compose(l.changes),Fn(S.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,I)):o=je(o,o.length,s.minDepth,e),new F(o,I,t,i)}addSelection(e,t,i,s){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:I;return r.length>0&&t-this.prevTime<s&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&Es(r[r.length-1],e)?this:new F(zn(this.done,e),this.undone,t,i)}addMapping(e){return new F(ot(this.done,e),ot(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let s=e==0?this.done:this.undone;if(s.length==0)return null;let r=s[s.length-1],o=r.selectionsAfter[0]||t.selection;if(i&&r.selectionsAfter.length)return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:pt.of({side:e,rest:Fs(s),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let l=s.length==1?I:s.slice(0,s.length-1);return r.mapped&&(l=ot(l,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:pt.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}F.empty=new F(I,I);const Vo=[{key:"Mod-z",run:Nn,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:mt,preventDefault:!0},{linux:"Ctrl-Shift-z",run:mt,preventDefault:!0},{key:"Mod-u",run:Rs,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Is,preventDefault:!0}];function ue(n,e){return m.create(n.ranges.map(e),n.mainIndex)}function $(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function N({state:n,dispatch:e},t){let i=ue(n.selection,t);return i.eq(n.selection,!0)?!1:(e($(n,i)),!0)}function _e(n,e){return m.cursor(e?n.to:n.from)}function $n(n,e){return N(n,t=>t.empty?n.moveByChar(t,e):_e(t,e))}function A(n){return n.textDirectionAt(n.state.selection.main.head)==bn.LTR}const Wn=n=>$n(n,!A(n)),qn=n=>$n(n,A(n));function Un(n,e){return N(n,t=>t.empty?n.moveByGroup(t,e):_e(t,e))}const Ws=n=>Un(n,!A(n)),qs=n=>Un(n,A(n));function Us(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function Ye(n,e,t){let i=Z(n).resolveInner(e.head),s=t?ce.closedBy:ce.openedBy;for(let a=e.head;;){let c=t?i.childAfter(a):i.childBefore(a);if(!c)break;Us(n,c,s)?i=c:a=t?c.to:c.from}let r=i.type.prop(s),o,l;return r&&(o=t?se(n,i.from,1):se(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,m.cursor(l,t?-1:1)}const js=n=>N(n,e=>Ye(n.state,e,!A(n))),Gs=n=>N(n,e=>Ye(n.state,e,A(n)));function jn(n,e){return N(n,t=>{if(!t.empty)return _e(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}const Gn=n=>jn(n,!1),Vn=n=>jn(n,!0);function Hn(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,i=0,s;if(e){for(let r of n.state.facet(y.scrollMargins)){let o=r(n);o!=null&&o.top&&(t=Math.max(o==null?void 0:o.top,t)),o!=null&&o.bottom&&(i=Math.max(o==null?void 0:o.bottom,i))}s=n.scrollDOM.clientHeight-t-i}else s=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(n.defaultLineHeight,s-5)}}function Kn(n,e){let t=Hn(n),{state:i}=n,s=ue(i.selection,o=>o.empty?n.moveVertically(o,e,t.height):_e(o,e));if(s.eq(i.selection))return!1;let r;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),l=n.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,c=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<c&&(r=y.scrollIntoView(s.main.head,{y:"start",yMargin:o.top-a}))}return n.dispatch($(i,s),{effects:r}),!0}const jt=n=>Kn(n,!1),gt=n=>Kn(n,!0);function K(n,e,t){let i=n.lineBlockAt(e.head),s=n.moveToLineBoundary(e,t);if(s.head==e.head&&s.head!=(t?i.to:i.from)&&(s=n.moveToLineBoundary(e,t,!1)),!t&&s.head==i.from&&i.length){let r=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&e.head!=i.from+r&&(s=m.cursor(i.from+r))}return s}const Vs=n=>N(n,e=>K(n,e,!0)),Hs=n=>N(n,e=>K(n,e,!1)),Ks=n=>N(n,e=>K(n,e,!A(n))),Js=n=>N(n,e=>K(n,e,A(n))),Qs=n=>N(n,e=>m.cursor(n.lineBlockAt(e.head).from,1)),_s=n=>N(n,e=>m.cursor(n.lineBlockAt(e.head).to,-1));function Ys(n,e,t){let i=!1,s=ue(n.selection,r=>{let o=se(n,r.head,-1)||se(n,r.head,1)||r.head>0&&se(n,r.head-1,1)||r.head<n.doc.length&&se(n,r.head+1,-1);if(!o||!o.end)return r;i=!0;let l=o.start.from==r.head?o.end.to:o.end.from;return m.cursor(l)});return i?(e($(n,s)),!0):!1}const Xs=({state:n,dispatch:e})=>Ys(n,e);function E(n,e){let t=ue(n.state.selection,i=>{let s=e(i);return m.range(i.anchor,s.head,s.goalColumn,s.bidiLevel||void 0)});return t.eq(n.state.selection)?!1:(n.dispatch($(n.state,t)),!0)}function Jn(n,e){return E(n,t=>n.moveByChar(t,e))}const Qn=n=>Jn(n,!A(n)),_n=n=>Jn(n,A(n));function Yn(n,e){return E(n,t=>n.moveByGroup(t,e))}const Zs=n=>Yn(n,!A(n)),er=n=>Yn(n,A(n)),tr=n=>E(n,e=>Ye(n.state,e,!A(n))),nr=n=>E(n,e=>Ye(n.state,e,A(n)));function Xn(n,e){return E(n,t=>n.moveVertically(t,e))}const Zn=n=>Xn(n,!1),ei=n=>Xn(n,!0);function ti(n,e){return E(n,t=>n.moveVertically(t,e,Hn(n).height))}const Gt=n=>ti(n,!1),Vt=n=>ti(n,!0),ir=n=>E(n,e=>K(n,e,!0)),sr=n=>E(n,e=>K(n,e,!1)),rr=n=>E(n,e=>K(n,e,!A(n))),or=n=>E(n,e=>K(n,e,A(n))),lr=n=>E(n,e=>m.cursor(n.lineBlockAt(e.head).from)),ar=n=>E(n,e=>m.cursor(n.lineBlockAt(e.head).to)),Ht=({state:n,dispatch:e})=>(e($(n,{anchor:0})),!0),Kt=({state:n,dispatch:e})=>(e($(n,{anchor:n.doc.length})),!0),Jt=({state:n,dispatch:e})=>(e($(n,{anchor:n.selection.main.anchor,head:0})),!0),Qt=({state:n,dispatch:e})=>(e($(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),cr=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),hr=({state:n,dispatch:e})=>{let t=Xe(n).map(({from:i,to:s})=>m.range(i,Math.min(s+1,n.doc.length)));return e(n.update({selection:m.create(t),userEvent:"select"})),!0},fr=({state:n,dispatch:e})=>{let t=ue(n.selection,i=>{let s=Z(n),r=s.resolveStack(i.from,1);if(i.empty){let o=s.resolveStack(i.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;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 m.range(l.to,l.from)}return i});return t.eq(n.selection)?!1:(e($(n,t)),!0)},ur=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=m.create([t.main]):t.main.empty||(i=m.create([m.cursor(t.main.head)])),i?(e($(n,i)),!0):!1};function Ce(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,s=i.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=e(r);a<o?(t="delete.backward",a=Le(n,a,!1)):a>o&&(t="delete.forward",a=Le(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Le(n,o,!1),l=Le(n,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:m.cursor(o,o<r.head?-1:1)}});return s.changes.empty?!1:(n.dispatch(i.update(s,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?y.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Le(n,e,t){if(n instanceof y)for(let i of n.state.facet(y.atomicRanges).map(s=>s(n)))i.between(e,e,(s,r)=>{s<e&&r>e&&(e=t?r:s)});return e}const ni=(n,e,t)=>Ce(n,i=>{let s=i.from,{state:r}=n,o=r.doc.lineAt(s),l,a;if(t&&!e&&s>o.from&&s<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,s-o.from))){if(l[l.length-1]==" ")return s-1;let c=At(l,r.tabSize),h=c%ge(r)||ge(r);for(let f=0;f<h&&l[l.length-1-f]==" ";f++)s--;a=s}else a=Y(o.text,s-o.from,e,e)+o.from,a==s&&o.number!=(e?r.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,s-o.from))&&(a=Y(o.text,a-o.from,!1,!1)+o.from);return a}),xt=n=>ni(n,!1,!0),ii=n=>ni(n,!0,!1),si=(n,e)=>Ce(n,t=>{let i=t.head,{state:s}=n,r=s.doc.lineAt(i),o=s.charCategorizer(i);for(let l=null;;){if(i==(e?r.to:r.from)){i==t.head&&r.number!=(e?s.doc.lines:1)&&(i+=e?1:-1);break}let a=Y(r.text,i-r.from,e)+r.from,c=r.text.slice(Math.min(i,a)-r.from,Math.max(i,a)-r.from),h=o(c);if(l!=null&&h!=l)break;(c!=" "||i!=t.head)&&(l=h),i=a}return i}),ri=n=>si(n,!1),dr=n=>si(n,!0),pr=n=>Ce(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)}),mr=n=>Ce(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),gr=n=>Ce(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)}),xr=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:kn.of(["",""])},range:m.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},yr=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let s=i.from,r=n.doc.lineAt(s),o=s==r.from?s-1:Y(r.text,s-r.from,!1)+r.from,l=s==r.to?s+1:Y(r.text,s-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:n.doc.slice(s,l).append(n.doc.slice(o,s))},range:m.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Xe(n){let e=[],t=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.from),r=n.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=n.doc.lineAt(i.to-1)),t>=s.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(i)}else e.push({from:s.from,to:r.to,ranges:[i]});t=r.number+1}return e}function oi(n,e,t){if(n.readOnly)return!1;let i=[],s=[];for(let r of Xe(n)){if(t?r.to==n.doc.length:r.from==0)continue;let o=n.doc.lineAt(t?r.to+1:r.from-1),l=o.length+1;if(t){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+n.lineBreak});for(let a of r.ranges)s.push(m.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:n.lineBreak+o.text});for(let a of r.ranges)s.push(m.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:m.create(s,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const kr=({state:n,dispatch:e})=>oi(n,e,!1),br=({state:n,dispatch:e})=>oi(n,e,!0);function li(n,e,t){if(n.readOnly)return!1;let i=[];for(let s of Xe(n))t?i.push({from:s.from,insert:n.doc.slice(s.from,s.to)+n.lineBreak}):i.push({from:s.to,insert:n.lineBreak+n.doc.slice(s.from,s.to)});return e(n.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const vr=({state:n,dispatch:e})=>li(n,e,!1),Sr=({state:n,dispatch:e})=>li(n,e,!0),Cr=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(Xe(e).map(({from:s,to:r})=>(s>0?s--:r<e.doc.length&&r++,{from:s,to:r}))),i=ue(e.selection,s=>{let r;if(n.lineWrapping){let o=n.lineBlockAt(s.head),l=n.coordsAtPos(s.head,s.assoc||1);l&&(r=o.bottom+n.documentTop-l.bottom+n.defaultLineHeight/2)}return n.moveVertically(s,!0,r)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Ar(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Z(n).resolveInner(e),i=t.childBefore(e),s=t.childAfter(e),r;return i&&s&&i.to<=e&&s.from>=e&&(r=i.type.prop(ce.closedBy))&&r.indexOf(s.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(s.from).from&&!/\S/.test(n.sliceDoc(i.to,s.from))?{from:i.to,to:s.from}:null}const _t=ai(!1),wr=ai(!0);function ai(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(s=>{let{from:r,to:o}=s,l=e.doc.lineAt(r),a=!n&&r==o&&Ar(e,r);n&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let c=new xn(e,{simulateBreak:r,simulateDoubleBreak:!!a}),h=yn(c,r);for(h==null&&(h=At(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:r,to:o}=a:r>l.from&&r<l.from+100&&!/\S/.test(l.text.slice(0,r))&&(r=l.from);let f=["",Ee(e,h)];return a&&f.push(Ee(e,c.lineIndent(l.from,-1))),{changes:{from:r,to:o,insert:kn.of(f)},range:m.cursor(r+1+f[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Rt(n,e){let t=-1;return n.changeByRange(i=>{let s=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,s,i),t=l.number),o=l.to+1}let r=n.changes(s);return{changes:s,range:m.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}const Mr=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new xn(n,{overrideIndentation:r=>{let o=t[r];return o??-1}}),s=Rt(n,(r,o,l)=>{let a=yn(i,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let c=/^\s*/.exec(r.text)[0],h=Ee(n,a);(c!=h||l.from<r.from+c.length)&&(t[r.from]=a,o.push({from:r.from,to:r.from+c.length,insert:h}))});return s.changes.empty||e(n.update(s,{userEvent:"indent"})),!0},ci=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Rt(n,(t,i)=>{i.push({from:t.from,insert:n.facet(Oi)})}),{userEvent:"input.indent"})),!0),hi=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Rt(n,(t,i)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let r=At(s,n.tabSize),o=0,l=Ee(n,Math.max(0,r-ge(n)));for(;o<s.length&&o<l.length&&s.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+s.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),Tr=n=>(n.setTabFocusMode(),!0),Lr=[{key:"Ctrl-b",run:Wn,shift:Qn,preventDefault:!0},{key:"Ctrl-f",run:qn,shift:_n},{key:"Ctrl-p",run:Gn,shift:Zn},{key:"Ctrl-n",run:Vn,shift:ei},{key:"Ctrl-a",run:Qs,shift:lr},{key:"Ctrl-e",run:_s,shift:ar},{key:"Ctrl-d",run:ii},{key:"Ctrl-h",run:xt},{key:"Ctrl-k",run:pr},{key:"Ctrl-Alt-h",run:ri},{key:"Ctrl-o",run:xr},{key:"Ctrl-t",run:yr},{key:"Ctrl-v",run:gt}],Dr=[{key:"ArrowLeft",run:Wn,shift:Qn,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Ws,shift:Zs,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Ks,shift:rr,preventDefault:!0},{key:"ArrowRight",run:qn,shift:_n,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:qs,shift:er,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Js,shift:or,preventDefault:!0},{key:"ArrowUp",run:Gn,shift:Zn,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Ht,shift:Jt},{mac:"Ctrl-ArrowUp",run:jt,shift:Gt},{key:"ArrowDown",run:Vn,shift:ei,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Kt,shift:Qt},{mac:"Ctrl-ArrowDown",run:gt,shift:Vt},{key:"PageUp",run:jt,shift:Gt},{key:"PageDown",run:gt,shift:Vt},{key:"Home",run:Hs,shift:sr,preventDefault:!0},{key:"Mod-Home",run:Ht,shift:Jt},{key:"End",run:Vs,shift:ir,preventDefault:!0},{key:"Mod-End",run:Kt,shift:Qt},{key:"Enter",run:_t,shift:_t},{key:"Mod-a",run:cr},{key:"Backspace",run:xt,shift:xt},{key:"Delete",run:ii},{key:"Mod-Backspace",mac:"Alt-Backspace",run:ri},{key:"Mod-Delete",mac:"Alt-Delete",run:dr},{mac:"Mod-Backspace",run:mr},{mac:"Mod-Delete",run:gr}].concat(Lr.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),Ho=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:js,shift:tr},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Gs,shift:nr},{key:"Alt-ArrowUp",run:kr},{key:"Shift-Alt-ArrowUp",run:vr},{key:"Alt-ArrowDown",run:br},{key:"Shift-Alt-ArrowDown",run:Sr},{key:"Escape",run:ur},{key:"Mod-Enter",run:wr},{key:"Alt-l",mac:"Ctrl-l",run:hr},{key:"Mod-i",run:fr,preventDefault:!0},{key:"Mod-[",run:hi},{key:"Mod-]",run:ci},{key:"Mod-Alt-\\",run:Mr},{key:"Shift-Mod-k",run:Cr},{key:"Shift-Mod-\\",run:Xs},{key:"Mod-/",run:Cs},{key:"Alt-A",run:ws},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Tr}].concat(Dr),Ko={key:"Tab",run:ci,shift:hi};class fi{constructor(e,t,i,s){this.state=e,this.pos=t,this.explicit=i,this.view=s,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Z(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),s=t.text.slice(i-t.from,this.pos-t.from),r=s.search(ui(e,!1));return r<0?null:{from:i+r,to:this.pos,text:s.slice(r)}}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 Yt(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function Br(n){let e=Object.create(null),t=Object.create(null);for(let{label:s}of n){e[s[0]]=!0;for(let r=1;r<s.length;r++)t[s[r]]=!0}let i=Yt(e)+Yt(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function Pr(n){let e=n.map(s=>typeof s=="string"?{label:s}:s),[t,i]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:Br(e);return s=>{let r=s.matchBefore(i);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}function Jo(n,e){return t=>{for(let i=Z(t.state).resolveInner(t.pos,-1);i;i=i.parent){if(n.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(t)}}class Xt{constructor(e,t,i,s){this.completion=e,this.source=t,this.match=i,this.score=s}}function _(n){return n.selection.main.from}function ui(n,e){var t;let{source:i}=n,s=e&&i[0]!="^",r=i[i.length-1]!="$";return!s&&!r?n:new RegExp(`${s?"^":""}(?:${i})${r?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}const di=wt.define();function Rr(n,e,t,i){let{main:s}=n.selection,r=t-s.from,o=i-s.from;return Object.assign(Object.assign({},n.changeByRange(l=>{if(l!=s&&t!=i&&n.sliceDoc(l.from+r,l.from+o)!=n.sliceDoc(t,i))return{range:l};let a=n.toText(e);return{changes:{from:l.from+r,to:i==s.from?l.to:l.from+o,insert:a},range:m.cursor(l.from+r+a.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const Zt=new WeakMap;function Ir(n){if(!Array.isArray(n))return n;let e=Zt.get(n);return e||Zt.set(n,e=Pr(n)),e}const Ge=S.define(),ye=S.define();class Or{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let i=R(e,t),s=U(i);this.chars.push(i);let r=e.slice(t,t+s),o=r.toUpperCase();this.folded.push(R(o==r?r.toLowerCase():o,0)),t+=s}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:i,any:s,precise:r,byWord:o}=this;if(t.length==1){let k=R(e,0),te=U(k),W=te==e.length?0:-100;if(k!=t[0])if(k==i[0])W+=-200;else return null;return this.ret(W,[0,te])}let l=e.indexOf(this.pattern);if(l==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,c=0;if(l<0){for(let k=0,te=Math.min(e.length,200);k<te&&c<a;){let W=R(e,k);(W==t[c]||W==i[c])&&(s[c++]=k),k+=U(W)}if(c<a)return null}let h=0,f=0,u=!1,d=0,p=-1,g=-1,C=/[a-z]/.test(e),j=!0;for(let k=0,te=Math.min(e.length,200),W=0;k<te&&f<a;){let T=R(e,k);l<0&&(h<a&&T==t[h]&&(r[h++]=k),d<a&&(T==t[d]||T==i[d]?(d==0&&(p=k),g=k+1,d++):d=0));let Ae,nt=T<255?T>=48&&T<=57||T>=97&&T<=122?2:T>=65&&T<=90?1:0:(Ae=St(T))!=Ae.toLowerCase()?1:Ae!=Ae.toUpperCase()?2:0;(!k||nt==1&&C||W==0&&nt!=0)&&(t[f]==T||i[f]==T&&(u=!0)?o[f++]=k:o.length&&(j=!1)),W=nt,k+=U(T)}return f==a&&o[0]==0&&j?this.result(-100+(u?-200:0),o,e):d==a&&p==0?this.ret(-200-e.length+(g==e.length?0:-100),[0,g]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):d==a?this.ret(-900-e.length,[p,g]):f==a?this.result(-100+(u?-200:0)+-700+(j?0:-1100),o,e):t.length==2?null:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,i){let s=[],r=0;for(let o of t){let l=o+(this.astral?U(R(i,o)):1);r&&s[r-1]==o?s[r-1]=l:(s[r++]=o,s[r++]=l)}return this.ret(e-i.length,s)}}class Er{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),i=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return i==null?null:(this.matched=[0,t.length],this.score=i+(e.length==this.pattern.length?0:-100),this)}}const v=V.define({combine(n){return X(n,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Nr,filterStrict:!1,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>en(e(i),t(i)),optionClass:(e,t)=>i=>en(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function en(n,e){return n?e?n+" "+e:n:e}function Nr(n,e,t,i,s,r){let o=n.textDirection==bn.RTL,l=o,a=!1,c="top",h,f,u=e.left-s.left,d=s.right-e.right,p=i.right-i.left,g=i.bottom-i.top;if(l&&u<Math.min(p,d)?l=!1:!l&&d<Math.min(p,u)&&(l=!0),p<=(l?u:d))h=Math.max(s.top,Math.min(t.top,s.bottom-g))-e.top,f=Math.min(400,l?u:d);else{a=!0,f=Math.min(400,(o?e.right:s.right-e.left)-30);let k=s.bottom-e.bottom;k>=g||k>e.top?h=t.bottom-e.top:(c="bottom",h=e.bottom-t.top)}let C=(e.bottom-e.top)/r.offsetHeight,j=(e.right-e.left)/r.offsetWidth;return{style:`${c}: ${h/C}px; max-width: ${f/j}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}function Fr(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,s,r){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let c=0;c<r.length;){let h=r[c++],f=r[c++];h>a&&o.appendChild(document.createTextNode(l.slice(a,h)));let u=o.appendChild(document.createElement("span"));u.appendChild(document.createTextNode(l.slice(h,f))),u.className="cm-completionMatchedText",a=f}return a<l.length&&o.appendChild(document.createTextNode(l.slice(a))),o},position:50},{render(t){if(!t.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=t.detail,i},position:80}),e.sort((t,i)=>t.position-i.position).map(t=>t.render)}function lt(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let i=Math.floor((n-e)/t);return{from:n-(i+1)*t,to:n-i*t}}class zr{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let s=e.state.field(t),{options:r,selected:o}=s.open,l=e.state.facet(v);this.optionContent=Fr(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=lt(r.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:c}=e.state.field(t).open;for(let h=a.target,f;h&&h!=this.dom;h=h.parentNode)if(h.nodeName=="LI"&&(f=/-(\d+)$/.exec(h.id))&&+f[1]<c.length){this.applyCompletion(e,c[+f[1]]),a.preventDefault();return}}),this.dom.addEventListener("focusout",a=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(v).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:ye.of(null)})}),this.showOptions(r,s.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=s){let{options:r,selected:o,disabled:l}=i.open;(!s.open||s.open.options!=r)&&(this.range=lt(r.length,o,e.state.facet(v).maxRenderedOptions),this.showOptions(r,i.id)),this.updateSel(),l!=((t=s.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=lt(t.options.length,t.selected,this.view.state.facet(v).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:i}=t.options[t.selected],{info:s}=i;if(!s)return;let r=typeof s=="string"?document.createTextNode(s):s(i);if(!r)return;"then"in r?r.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,i)}).catch(o=>Ne(this.view.state,o,"completion info")):this.addInfoPane(r,i)}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:s,destroy:r}=e;i.appendChild(s),this.infoDestroy=r||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,s=this.range.from;i;i=i.nextSibling,s++)i.nodeName!="LI"||!i.id?s--:s==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected");return t&&Wr(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),s=e.getBoundingClientRect(),r=this.space;if(!r){let o=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return s.top>Math.min(r.bottom,t.bottom)-10||s.bottom<Math.max(r.top,t.top)+10?null:this.view.state.facet(v).positionInfo(this.view,t,s,i,r,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,i){const s=document.createElement("ul");s.id=t,s.setAttribute("role","listbox"),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-label",this.view.state.phrase("Completions")),s.addEventListener("mousedown",o=>{o.target==s&&o.preventDefault()});let r=null;for(let o=i.from;o<i.to;o++){let{completion:l,match:a}=e[o],{section:c}=l;if(c){let u=typeof c=="string"?c:c.name;if(u!=r&&(o>i.from||i.from==0))if(r=u,typeof c!="string"&&c.header)s.appendChild(c.header(c));else{let d=s.appendChild(document.createElement("completion-section"));d.textContent=u}}const h=s.appendChild(document.createElement("li"));h.id=t+"-"+o,h.setAttribute("role","option");let f=this.optionClass(l);f&&(h.className=f);for(let u of this.optionContent){let d=u(l,this.view.state,this.view,a);d&&h.appendChild(d)}}return i.from&&s.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&s.classList.add("cm-completionListIncompleteBottom"),s}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function $r(n,e){return t=>new zr(t,n,e)}function Wr(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),s=t.height/n.offsetHeight;i.top<t.top?n.scrollTop-=(t.top-i.top)/s:i.bottom>t.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/s)}function tn(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function qr(n,e){let t=[],i=null,s=c=>{t.push(c);let{section:h}=c.completion;if(h){i||(i=[]);let f=typeof h=="string"?h:h.name;i.some(u=>u.name==f)||i.push(typeof h=="string"?{name:f}:h)}},r=e.facet(v);for(let c of n)if(c.hasResult()){let h=c.result.getMatch;if(c.result.filter===!1)for(let f of c.result.options)s(new Xt(f,c.source,h?h(f):[],1e9-t.length));else{let f=e.sliceDoc(c.from,c.to),u,d=r.filterStrict?new Er(f):new Or(f);for(let p of c.result.options)if(u=d.match(p.label)){let g=p.displayLabel?h?h(p,u.matched):[]:u.matched;s(new Xt(p,c.source,g,u.score+(p.boost||0)))}}}if(i){let c=Object.create(null),h=0,f=(u,d)=>{var p,g;return((p=u.rank)!==null&&p!==void 0?p:1e9)-((g=d.rank)!==null&&g!==void 0?g:1e9)||(u.name<d.name?-1:1)};for(let u of i.sort(f))h-=1e5,c[u.name]=h;for(let u of t){let{section:d}=u.completion;d&&(u.score+=c[typeof d=="string"?d:d.name])}}let o=[],l=null,a=r.compareCompletions;for(let c of t.sort((h,f)=>f.score-h.score||a(h.completion,f.completion))){let h=c.completion;!l||l.label!=h.label||l.detail!=h.detail||l.type!=null&&h.type!=null&&l.type!=h.type||l.apply!=h.apply||l.boost!=h.boost?o.push(c):tn(c.completion)>tn(l)&&(o[o.length-1]=c),l=c.completion}return o}class re{constructor(e,t,i,s,r,o){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=s,this.selected=r,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new re(this.options,nn(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,s,r,o){if(s&&!o&&e.some(c=>c.isPending))return s.setDisabled();let l=qr(e,t);if(!l.length)return s&&e.some(c=>c.isPending)?s.setDisabled():null;let a=t.facet(v).selectOnOpen?0:-1;if(s&&s.selected!=a&&s.selected!=-1){let c=s.options[s.selected].completion;for(let h=0;h<l.length;h++)if(l[h].completion==c){a=h;break}}return new re(l,nn(i,a),{pos:e.reduce((c,h)=>h.hasResult()?Math.min(c,h.from):c,1e8),create:Kr,above:r.aboveCursor},s?s.timestamp:Date.now(),a,!1)}map(e){return new re(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new re(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Ve{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new Ve(Vr,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(v),r=(i.override||t.languageDataAt("autocomplete",_(t)).map(Ir)).map(a=>(this.active.find(h=>h.source==a)||new O(a,this.active.some(h=>h.state!=0)?1:0)).update(e,i));r.length==this.active.length&&r.every((a,c)=>a==this.active[c])&&(r=this.active);let o=this.open,l=e.effects.some(a=>a.is(It));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||r.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!Ur(r,this.active)||l?o=re.build(r,t,this.id,o,i,l):o&&o.disabled&&!r.some(a=>a.isPending)&&(o=null),!o&&r.every(a=>!a.isPending)&&r.some(a=>a.hasResult())&&(r=r.map(a=>a.hasResult()?new O(a.source,0):a));for(let a of e.effects)a.is(mi)&&(o=o&&o.setSelected(a.value,this.id));return r==this.active&&o==this.open?this:new Ve(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?jr:Gr}}function Ur(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t<n.length&&!n[t].hasResult();)t++;for(;i<e.length&&!e[i].hasResult();)i++;let s=t==n.length,r=i==e.length;if(s||r)return s==r;if(n[t++].result!=e[i++].result)return!1}}const jr={"aria-autocomplete":"list"},Gr={};function nn(n,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":n};return e>-1&&(t["aria-activedescendant"]=n+"-"+e),t}const Vr=[];function pi(n,e){if(n.isUserEvent("input.complete")){let i=n.annotation(di);if(i&&e.activateOnCompletion(i))return 12}let t=n.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}class O{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let i=pi(e,t),s=this;(i&8||i&16&&this.touches(e))&&(s=new O(s.source,0)),i&4&&s.state==0&&(s=new O(this.source,1)),s=s.updateFor(e,i);for(let r of e.effects)if(r.is(Ge))s=new O(s.source,1,r.value);else if(r.is(ye))s=new O(s.source,0);else if(r.is(It))for(let o of r.value)o.source==s.source&&(s=o);return s}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(_(e.state))}}class le extends O{constructor(e,t,i,s,r,o){super(e,3,t),this.limit=i,this.result=s,this.from=r,this.to=o}hasResult(){return!0}updateFor(e,t){var i;if(!(t&3))return this.map(e.changes);let s=this.result;s.map&&!e.changes.empty&&(s=s.map(s,e.changes));let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=_(e.state);if(l>o||!s||t&2&&(_(e.startState)==this.from||l<this.limit))return new O(this.source,t&4?1:0);let a=e.changes.mapPos(this.limit);return Hr(s.validFor,e.state,r,o)?new le(this.source,this.explicit,a,s,r,o):s.update&&(s=s.update(s,r,o,new fi(e.state,l,!1)))?new le(this.source,this.explicit,a,s,s.from,(i=s.to)!==null&&i!==void 0?i:_(e.state)):new O(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new le(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new O(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function Hr(n,e,t,i){if(!n)return!1;let s=e.sliceDoc(t,i);return typeof n=="function"?n(s,t,i,e):ui(n,!0).test(s)}const It=S.define({map(n,e){return n.map(t=>t.map(e))}}),mi=S.define(),L=H.define({create(){return Ve.start()},update(n,e){return n.update(e)},provide:n=>[vn.from(n,e=>e.tooltip),y.contentAttributes.from(n,e=>e.attrs)]});function Ot(n,e){const t=e.completion.apply||e.completion.label;let i=n.state.field(L).active.find(s=>s.source==e.source);return i instanceof le?(typeof t=="string"?n.dispatch(Object.assign(Object.assign({},Rr(n.state,t,i.from,i.to)),{annotations:di.of(e.completion)})):t(n,e.completion,i.from,i.to),!0):!1}const Kr=$r(L,Ot);function De(n,e="option"){return t=>{let i=t.state.field(L,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<t.state.facet(v).interactionDelay)return!1;let s=1,r;e=="page"&&(r=Sn(t,i.open.tooltip))&&(s=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,l=i.open.selected>-1?i.open.selected+s*(n?1:-1):n?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:mi.of(l)}),!0}}const Jr=n=>{let e=n.state.field(L,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<n.state.facet(v).interactionDelay?!1:Ot(n,e.open.options[e.open.selected])},sn=n=>n.state.field(L,!1)?(n.dispatch({effects:Ge.of(!0)}),!0):!1,Qr=n=>{let e=n.state.field(L,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:ye.of(null)}),!0)};class _r{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const Yr=50,Xr=1e3,Zr=ve.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(L).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(L),t=n.state.facet(v);if(!n.selectionSet&&!n.docChanged&&n.startState.field(L)==e)return;let i=n.transactions.some(r=>{let o=pi(r,t);return o&8||(r.selection||r.docChanged)&&!(o&3)});for(let r=0;r<this.running.length;r++){let o=this.running[r];if(i||o.context.abortOnDocChange&&n.docChanged||o.updates.length+n.transactions.length>Yr&&Date.now()-o.time>Xr){for(let l of o.context.abortListeners)try{l()}catch(a){Ne(this.view.state,a)}o.context.abortListeners=null,this.running.splice(r--,1)}else o.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(r=>r.effects.some(o=>o.is(Ge)))&&(this.pendingStart=!0);let s=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(r=>r.isPending&&!this.running.some(o=>o.active.source==r.source))?setTimeout(()=>this.startUpdate(),s):-1,this.composing!=0)for(let r of n.transactions)r.isUserEvent("input.type")?this.composing=2:this.composing==2&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(L);for(let t of e.active)t.isPending&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(v).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=_(e),i=new fi(e,t,n.explicit,this.view),s=new _r(n,i);this.running.push(s),Promise.resolve(n.source(i)).then(r=>{s.context.aborted||(s.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:ye.of(null)}),Ne(this.view.state,r)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(v).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(v),i=this.view.state.field(L);for(let s=0;s<this.running.length;s++){let r=this.running[s];if(r.done===void 0)continue;if(this.running.splice(s--,1),r.done){let l=_(r.updates.length?r.updates[0].startState:this.view.state),a=Math.min(l,r.done.from+(r.active.explicit?0:1)),c=new le(r.active.source,r.active.explicit,a,r.done,r.done.from,(n=r.done.to)!==null&&n!==void 0?n:l);for(let h of r.updates)c=c.update(h,t);if(c.hasResult()){e.push(c);continue}}let o=i.active.find(l=>l.source==r.active.source);if(o&&o.isPending)if(r.done==null){let l=new O(r.active.source,0);for(let a of r.updates)l=l.update(a,t);l.isPending||e.push(l)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:It.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(L,!1);if(e&&e.tooltip&&this.view.state.facet(v).closeOnBlur){let t=e.open&&Sn(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:ye.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Ge.of(!1)}),20),this.composing=0}}}),eo=typeof navigator=="object"&&/Win/.test(navigator.platform),to=bt.highest(y.domEventHandlers({keydown(n,e){let t=e.state.field(L,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||n.key.length>1||n.ctrlKey&&!(eo&&n.altKey)||n.metaKey)return!1;let i=t.open.options[t.open.selected],s=t.active.find(o=>o.source==i.source),r=i.completion.commitCharacters||s.result.commitCharacters;return r&&r.indexOf(n.key)>-1&&Ot(e,i),!1}})),no=y.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),ke={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Q=S.define({map(n,e){let t=e.mapPos(n,-1,Ni.TrackAfter);return t??void 0}}),Et=new class extends Fi{};Et.startSide=1;Et.endSide=-1;const gi=H.define({create(){return Je.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(Q)&&(n=n.update({add:[Et.range(t.value,t.value+1)]}));return n}});function Qo(){return[so,gi]}const at="()[]{}<>«»»«[]{}";function xi(n){for(let e=0;e<at.length;e+=2)if(at.charCodeAt(e)==n)return at.charAt(e+1);return St(n<128?n:n+1)}function yi(n,e){return n.languageDataAt("closeBrackets",e)[0]||ke}const io=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),so=y.inputHandler.of((n,e,t,i)=>{if((io?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let s=n.state.selection.main;if(i.length>2||i.length==2&&U(R(i,0))==1||e!=s.from||t!=s.to)return!1;let r=oo(n.state,i);return r?(n.dispatch(r),!0):!1}),ro=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=yi(n,n.selection.main.head).brackets||ke.brackets,s=null,r=n.changeByRange(o=>{if(o.empty){let l=lo(n.doc,o.head);for(let a of i)if(a==l&&Ze(n.doc,o.head)==xi(R(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:m.cursor(o.head-a.length)}}return{range:s=o}});return s||e(n.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},_o=[{key:"Backspace",run:ro}];function oo(n,e){let t=yi(n,n.selection.main.head),i=t.brackets||ke.brackets;for(let s of i){let r=xi(R(s,0));if(e==s)return r==s?ho(n,s,i.indexOf(s+s+s)>-1,t):ao(n,s,r,t.before||ke.before);if(e==r&&ki(n,n.selection.main.from))return co(n,s,r)}return null}function ki(n,e){let t=!1;return n.field(gi).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function Ze(n,e){let t=n.sliceString(e,e+2);return t.slice(0,U(R(t,0)))}function lo(n,e){let t=n.sliceString(e-2,e);return U(R(t,0))==t.length?t:t.slice(1)}function ao(n,e,t,i){let s=null,r=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:Q.of(o.to+e.length),range:m.range(o.anchor+e.length,o.head+e.length)};let l=Ze(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:Q.of(o.head+e.length),range:m.cursor(o.head+e.length)}:{range:s=o}});return s?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function co(n,e,t){let i=null,s=n.changeByRange(r=>r.empty&&Ze(n.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:m.cursor(r.head+t.length)}:i={range:r});return i?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function ho(n,e,t,i){let s=i.stringPrefixes||ke.stringPrefixes,r=null,o=n.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:Q.of(l.to+e.length),range:m.range(l.anchor+e.length,l.head+e.length)};let a=l.head,c=Ze(n.doc,a),h;if(c==e){if(rn(n,a))return{changes:{insert:e+e,from:a},effects:Q.of(a+e.length),range:m.cursor(a+e.length)};if(ki(n,a)){let u=t&&n.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+u.length,insert:u},range:m.cursor(a+u.length)}}}else{if(t&&n.sliceDoc(a-2*e.length,a)==e+e&&(h=on(n,a-2*e.length,s))>-1&&rn(n,h))return{changes:{insert:e+e+e+e,from:a},effects:Q.of(a+e.length),range:m.cursor(a+e.length)};if(n.charCategorizer(a)(c)!=w.Word&&on(n,a,s)>-1&&!fo(n,a,e,s))return{changes:{insert:e+e,from:a},effects:Q.of(a+e.length),range:m.cursor(a+e.length)}}return{range:r=l}});return r?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function rn(n,e){let t=Z(n).resolveInner(e+1);return t.parent&&t.from==e}function fo(n,e,t,i){let s=Z(n).resolveInner(e,-1),r=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=n.sliceDoc(s.from,Math.min(s.to,s.from+t.length+r)),a=l.indexOf(t);if(!a||a>-1&&i.indexOf(l.slice(0,a))>-1){let h=s.firstChild;for(;h&&h.from==s.from&&h.to-h.from>t.length+a;){if(n.sliceDoc(h.to-t.length,h.to)==t)return!1;h=h.firstChild}return!0}let c=s.to==e&&s.parent;if(!c)break;s=c}return!1}function on(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=w.Word)return e;for(let s of t){let r=e-s.length;if(n.sliceDoc(r,e)==s&&i(n.sliceDoc(r-1,r))!=w.Word)return r}return-1}function Yo(n={}){return[to,L,v.of(n),Zr,po,no]}const uo=[{key:"Ctrl-Space",run:sn},{mac:"Alt-`",run:sn},{key:"Escape",run:Qr},{key:"ArrowDown",run:De(!0)},{key:"ArrowUp",run:De(!1)},{key:"PageDown",run:De(!0,"page")},{key:"PageUp",run:De(!1,"page")},{key:"Enter",run:Jr}],po=bt.highest(Ei.computeN([v],n=>n.facet(v).defaultKeymap?[uo]:[]));class ln{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class J{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let s=i.facet(z).markerFilter;s&&(e=s(e,i));let r=e.slice().sort((h,f)=>h.from-f.from||h.to-f.to),o=new Ct,l=[],a=0;for(let h=0;;){let f=h==r.length?null:r[h];if(!f&&!l.length)break;let u,d;for(l.length?(u=a,d=l.reduce((g,C)=>Math.min(g,C.to),f&&f.from>u?f.from:1e8)):(u=f.from,d=f.to,l.push(f),h++);h<r.length;){let g=r[h];if(g.from==u&&(g.to>g.from||g.to==u))l.push(g),h++,d=Math.min(g.to,d);else{d=Math.min(g.from,d);break}}let p=Mi(l);if(l.some(g=>g.from==g.to||g.from==g.to-1&&i.doc.lineAt(g.from).to==g.from))o.add(u,u,b.widget({widget:new So(p),diagnostics:l.slice()}));else{let g=l.reduce((C,j)=>j.markClass?C+" "+j.markClass:C,"");o.add(u,d,b.mark({class:"cm-lintRange cm-lintRange-"+p+g,diagnostics:l.slice(),inclusiveEnd:l.some(C=>C.to>d)}))}a=d;for(let g=0;g<l.length;g++)l[g].to<=a&&l.splice(g--,1)}let c=o.finish();return new J(c,t,fe(c))}}function fe(n,e=null,t=0){let i=null;return n.between(t,1e9,(s,r,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!i)i=new ln(s,r,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new ln(i.from,r,i.diagnostic)}}),i}function bi(n,e){let t=e.pos,i=e.end||t,s=n.state.facet(z).hideOn(n,t,i);if(s!=null)return s;let r=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(o=>o.is(et))||n.changes.touchesRange(r.from,Math.max(r.to,i)))}function vi(n,e){return n.field(M,!1)?e:e.concat(S.appendConfig.of(Di))}function mo(n,e){return{effects:vi(n,[et.of(e)])}}const et=S.define(),Nt=S.define(),Si=S.define(),M=H.define({create(){return new J(b.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),i=null,s=n.panel;if(n.selected){let r=e.changes.mapPos(n.selected.from,1);i=fe(t,n.selected.diagnostic,r)||fe(t,null,r)}!t.size&&s&&e.state.facet(z).autoPanel&&(s=null),n=new J(t,s,i)}for(let t of e.effects)if(t.is(et)){let i=e.state.facet(z).autoPanel?t.value.length?be.open:null:n.panel;n=J.init(t.value,i,e.state)}else t.is(Nt)?n=new J(n.diagnostics,t.value?be.open:null,n.selected):t.is(Si)&&(n=new J(n.diagnostics,n.panel,t.value));return n},provide:n=>[vt.from(n,e=>e.panel),y.decorations.from(n,e=>e.diagnostics)]});function Xo(n){let e=n.field(M,!1);return e?e.diagnostics.size:0}const go=b.mark({class:"cm-lintRange cm-lintRange-active"});function xo(n,e,t){let{diagnostics:i}=n.state.field(M),s,r=-1,o=-1;i.between(e-(t<0?1:0),e+(t>0?1:0),(a,c,{spec:h})=>{if(e>=a&&e<=c&&(a==c||(e>a||t>0)&&(e<c||t<0)))return s=h.diagnostics,r=a,o=c,!1});let l=n.state.facet(z).tooltipFilter;return s&&l&&(s=l(s,n.state)),s?{pos:r,end:o,above:n.state.doc.lineAt(r).to<o,create(){return{dom:Ci(n,s)}}}:null}function Ci(n,e){return x("ul",{class:"cm-tooltip-lint"},e.map(t=>wi(n,t,!1)))}const yo=n=>{let e=n.state.field(M,!1);(!e||!e.panel)&&n.dispatch({effects:vi(n.state,[Nt.of(!0)])});let t=me(n,be.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},an=n=>{let e=n.state.field(M,!1);return!e||!e.panel?!1:(n.dispatch({effects:Nt.of(!1)}),!0)},ko=n=>{let e=n.state.field(M,!1);if(!e)return!1;let t=n.state.selection.main,i=e.diagnostics.iter(t.to+1);return!i.value&&(i=e.diagnostics.iter(0),!i.value||i.from==t.from&&i.to==t.to)?!1:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)},Zo=[{key:"Mod-Shift-m",run:yo,preventDefault:!0},{key:"F8",run:ko}],bo=ve.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(z);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let n=Date.now();if(n<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-n);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(z);t.length&&vo(t.map(i=>Promise.resolve(i(this.view))),i=>{this.view.state.doc==e.doc&&this.view.dispatch(mo(this.view.state,i.reduce((s,r)=>s.concat(r))))},i=>{Ne(this.view.state,i)})}}update(n){let e=n.state.facet(z);(n.docChanged||e!=n.startState.facet(z)||e.needsRefresh&&e.needsRefresh(n))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function vo(n,e,t){let i=[],s=-1;for(let r of n)r.then(o=>{i.push(o),clearTimeout(s),i.length==n.length?e(i):s=setTimeout(()=>e(i),200)},t)}const z=V.define({combine(n){return Object.assign({sources:n.map(e=>e.source).filter(e=>e!=null)},X(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t}))}});function el(n,e={}){return[z.of({source:n,config:e}),bo,Di]}function Ai(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;i<t.length;i++){let s=t[i];if(/[a-zA-Z]/.test(s)&&!e.some(r=>r.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function wi(n,e,t){var i;let s=t?Ai(e.actions):[];return x("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},x("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((r,o)=>{let l=!1,a=u=>{if(u.preventDefault(),l)return;l=!0;let d=fe(n.state.field(M).diagnostics,e);d&&r.apply(n,d.from,d.to)},{name:c}=r,h=s[o]?c.indexOf(s[o]):-1,f=h<0?c:[c.slice(0,h),x("u",c.slice(h,h+1)),c.slice(h+1)];return x("button",{type:"button",class:"cm-diagnosticAction",onclick:a,onmousedown:a,"aria-label":` Action: ${c}${h<0?"":` (access key "${s[o]})"`}.`},f)}),e.source&&x("div",{class:"cm-diagnosticSource"},e.source))}class So extends $i{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return x("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class cn{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=wi(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class be{constructor(e){this.view=e,this.items=[];let t=s=>{if(s.keyCode==27)an(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=Ai(r.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==s.keyCode){let a=fe(this.view.state.field(M).diagnostics,r);a&&r.actions[l].apply(e,a.from,a.to)}}else return;s.preventDefault()},i=s=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(s.target)&&this.moveSelection(r)};this.list=x("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=x("div",{class:"cm-panel-lint"},this.list,x("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>an(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(M).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(M),i=0,s=!1,r=null,o=new Set;for(e.between(0,this.view.state.doc.length,(l,a,{spec:c})=>{for(let h of c.diagnostics){if(o.has(h))continue;o.add(h);let f=-1,u;for(let d=i;d<this.items.length;d++)if(this.items[d].diagnostic==h){f=d;break}f<0?(u=new cn(this.view,h),this.items.splice(i,0,u),s=!0):(u=this.items[f],f>i&&(this.items.splice(i,f-i),s=!0)),t&&u.diagnostic==t.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),r=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();this.items.length==0&&(this.items.push(new cn(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let c=a.height/this.list.offsetHeight;l.top<a.top?this.list.scrollTop-=(a.top-l.top)/c:l.bottom>a.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(M),i=fe(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:Si.of(i)})}static open(e){return new be(e)}}function Ie(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function Be(n){return Ie(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Co=y.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Be("#d11")},".cm-lintRange-warning":{backgroundImage:Be("orange")},".cm-lintRange-info":{backgroundImage:Be("#999")},".cm-lintRange-hint":{backgroundImage:Be("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function Ao(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function Mi(n){let e="hint",t=1;for(let i of n){let s=Ao(i.severity);s>t&&(t=s,e=i.severity)}return e}class Ti extends qi{constructor(e){super(),this.diagnostics=e,this.severity=Mi(e)}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,s=e.state.facet(tt).tooltipFilter;return s&&(i=s(i,e.state)),i.length&&(t.onmouseover=()=>Mo(e,t,i)),t}}function wo(n,e){let t=i=>{let s=e.getBoundingClientRect();if(!(i.clientX>s.left-10&&i.clientX<s.right+10&&i.clientY>s.top-10&&i.clientY<s.bottom+10)){for(let r=i.target;r;r=r.parentNode)if(r.nodeType==1&&r.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",t),n.state.field(Li)&&n.dispatch({effects:Ft.of(null)})}};window.addEventListener("mousemove",t)}function Mo(n,e,t){function i(){let o=n.elementAtHeight(e.getBoundingClientRect().top+5-n.documentTop);n.coordsAtPos(o.from)&&n.dispatch({effects:Ft.of({pos:o.from,above:!1,clip:!1,create(){return{dom:Ci(n,t),getCoords:()=>e.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,wo(n,e)}let{hoverTime:s}=n.state.facet(tt),r=setTimeout(i,s);e.onmouseout=()=>{clearTimeout(r),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(r),r=setTimeout(i,s)}}function To(n,e){let t=Object.create(null);for(let s of e){let r=n.lineAt(s.from);(t[r.from]||(t[r.from]=[])).push(s)}let i=[];for(let s in t)i.push(new Ti(t[s]).range(+s));return Je.of(i,!0)}const Lo=Wi({class:"cm-gutter-lint",markers:n=>n.state.field(yt),widgetMarker:(n,e,t)=>{let i=[];return n.state.field(yt).between(t.from,t.to,(s,r,o)=>{s>t.from&&s<t.to&&i.push(...o.diagnostics)}),i.length?new Ti(i):null}}),yt=H.define({create(){return Je.empty},update(n,e){n=n.map(e.changes);let t=e.state.facet(tt).markerFilter;for(let i of e.effects)if(i.is(et)){let s=i.value;t&&(s=t(s||[],e.state)),n=To(e.state.doc,s.slice(0))}return n}}),Ft=S.define(),Li=H.define({create(){return null},update(n,e){return n&&e.docChanged&&(n=bi(e,n)?null:Object.assign(Object.assign({},n),{pos:e.changes.mapPos(n.pos)})),e.effects.reduce((t,i)=>i.is(Ft)?i.value:t,n)},provide:n=>vn.from(n)}),Do=y.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:Ie('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:Ie('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:Ie('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),Di=[M,y.decorations.compute([M],n=>{let{selected:e,panel:t}=n.field(M);return!e||!t||e.from==e.to?b.none:b.set([go.range(e.from,e.to)])}),zi(xo,{hideOn:bi}),Co],tt=V.define({combine(n){return X(n,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function tl(n={}){return[tt.of(n),yt,Lo,Do,Li]}function nl(n,e){let t=n.field(M,!1);if(t&&t.diagnostics.size){let i=[],s=[],r=-1;for(let o=Je.iter([t.diagnostics]);;o.next()){for(let l=0;l<i.length;l++)(!o.value||o.value.spec.diagnostics.indexOf(i[l])<0)&&(e(i[l],s[l],r),i.splice(l,1),s.splice(l--,1));if(!o.value)break;for(let l of o.value.spec.diagnostics)i.indexOf(l)<0&&(i.push(l),s.push(o.from));r=o.to}}}var hn={};class He{constructor(e,t,i,s,r,o,l,a,c,h=0,f){this.p=e,this.stack=t,this.state=i,this.reducePos=s,this.pos=r,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=c,this.lookAhead=h,this.parent=f}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 s=e.parser.context;return new He(e,[],t,i,i,0,[],0,s?new fn(s,s.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,s=e&65535,{parser:r}=this.p,o=this.reducePos<this.pos-25;o&&this.setLookAhead(this.pos);let l=r.dynamicPrecedence(s);if(l&&(this.score+=l),i==0){this.pushState(r.getGoto(this.state,s,!0),this.reducePos),s<r.minRepeatTerm&&this.storeNode(s,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(s,this.reducePos);return}let a=this.stack.length-(i-1)*3-(e&262144?6:0),c=a?this.stack[a-2]:this.p.ranges[0].from,h=this.reducePos-c;h>=2e3&&!(!((t=this.p.parser.nodeSet.types[s])===null||t===void 0)&&t.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=h):this.p.lastBigReductionSize<h&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=c,this.p.lastBigReductionSize=h));let f=a?this.stack[a-1]:0,u=this.bufferBase+this.buffer.length-f;if(s<r.minRepeatTerm||e&131072){let d=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(s,c,d,u+4,!0)}if(e&262144)this.state=this.stack[a];else{let d=this.stack[a-3];this.state=r.getGoto(d,s,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(s,c)}storeNode(e,t,i,s=4,r=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,l=this.buffer.length;if(l==0&&o.parent&&(l=o.bufferBase-o.parent.bufferBase,o=o.parent),l>0&&o.buffer[l-4]==0&&o.buffer[l-1]>-1){if(t==i)return;if(o.buffer[l-2]>=t){o.buffer[l-2]=i;return}}}if(!r||this.pos==i)this.buffer.push(e,t,i,s);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>i;a-=4)if(this.buffer[a-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,s>4&&(s-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=i,this.buffer[o+3]=s}}shift(e,t,i,s){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let r=e,{parser:o}=this.p;(s>this.pos||t<=o.maxNode)&&(this.pos=s,o.stateFlag(r,1)||(this.reducePos=s)),this.pushState(r,i),this.shiftContext(t,i),t<=o.maxNode&&this.buffer.push(t,i,s,4)}else this.pos=s,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,s,4)}apply(e,t,i,s){e&65536?this.reduce(e):this.shift(e,t,i,s)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let s=this.pos;this.reducePos=this.pos=s+e.length,this.pushState(t,s),this.buffer.push(i,s,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>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),s=e.bufferBase+t;for(;e&&s==e.bufferBase;)e=e.parent;return new He(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,s,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 Bo(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 s=[];for(let r=0,o;r<t.length;r+=2)(o=t[r+1])!=this.state&&this.p.parser.hasAction(o,e)&&s.push(t[r],o);if(this.stack.length<120)for(let r=0;s.length<8&&r<t.length;r+=2){let o=t[r+1];s.some((l,a)=>a&1&&l==o)||s.push(t[r],o)}t=s}let i=[];for(let s=0;s<t.length&&i.length<4;s+=2){let r=t[s+1];if(r==this.state)continue;let o=this.split();o.pushState(r,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(t[s],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,s=t&65535,r=this.stack.length-i*3;if(r<0||e.getGoto(this.stack[r],s,!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=(s,r)=>{if(!t.includes(s))return t.push(s),e.allActions(s,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-r;if(l>1){let a=o&65535,c=this.stack.length-l*3;if(c>=0&&e.getGoto(this.stack[c],a,!1)>=0)return l<<19|65536|a}}else{let l=i(o,r+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 fn(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class fn{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class Bo{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 s=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=s}}class Ke{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 Ke(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 Ke(this.stack,this.pos,this.index)}}function Pe(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,s=0;i<n.length;){let r=0;for(;;){let o=n.charCodeAt(i++),l=!1;if(o==126){r=65535;break}o>=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),r+=a,l)break;r*=46}t?t[s++]=r:t=new e(r)}return t}class Oe{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const un=new Oe;class Po{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=un,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,s=this.rangeIndex,r=this.pos+e;for(;r<i.from;){if(!s)return null;let o=this.ranges[--s];r-=i.from-o.to,i=o}for(;t<0?r>i.to:r>=i.to;){if(s==this.ranges.length-1)return null;let o=this.ranges[++s];r+=o.from-i.to,i=o}return r}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,s;if(t>=0&&t<this.chunk.length)i=this.pos+e,s=this.chunk.charCodeAt(t);else{let r=this.resolveOffset(e,1);if(r==null)return-1;if(i=r,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)s=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)),s=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),s}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=un,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 s of this.ranges){if(s.from>=t)break;s.to>e&&(i+=this.input.read(Math.max(s.from,e),Math.min(s.to,t)))}return i}}class ae{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;Ro(this.data,e,t,this.id,i.data,i.tokenPrecTable)}}ae.prototype.contextual=ae.prototype.fallback=ae.prototype.extend=!1;ae.prototype.fallback=ae.prototype.extend=!1;class il{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function Ro(n,e,t,i,s,r){let o=0,l=1<<i,{dialect:a}=t.p.parser;e:for(;(l&n[o])!=0;){let c=n[o+1];for(let d=o+3;d<c;d+=2)if((n[d+1]&l)>0){let p=n[d];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||Io(p,e.token.value,s,r))){e.acceptToken(p);break}}let h=e.next,f=0,u=n[o+2];if(e.next<0&&u>f&&n[c+u*3-3]==65535){o=n[c+u*3-1];continue e}for(;f<u;){let d=f+u>>1,p=c+d+(d<<1),g=n[p],C=n[p+1]||65536;if(h<g)u=d;else if(h>=C)f=d+1;else{o=n[p+2],e.advance();continue e}}break}}function dn(n,e,t){for(let i=e,s;(s=n[i])!=65535;i++)if(s==t)return i-e;return-1}function Io(n,e,t,i){let s=dn(t,i,e);return s<0||dn(t,i,n)<s}const P=typeof process<"u"&&hn&&/\bparse\b/.test(hn.LOG);let ct=null;function pn(n,e,t){let i=n.cursor(Hi.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(n.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:n.length}}class Oo{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?pn(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?pn(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],s=this.index[t];if(s==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let r=i.children[s],o=this.start[t]+i.positions[s];if(o>e)return this.nextStart=o,null;if(r instanceof Re){if(o==e){if(o<this.safeFrom)return null;let l=o+r.length;if(l<=this.safeTo){let a=r.prop(ce.lookAhead);if(!a||l+a<this.fragment.to)return r}}this.index[t]++,o+r.length>=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+r.length}}}class Eo{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new Oe)}getActions(e){let t=0,i=null,{parser:s}=e.p,{tokenizers:r}=s,o=s.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let c=0;c<r.length;c++){if((1<<c&o)==0)continue;let h=r[c],f=this.tokens[c];if(!(i&&!h.fallback)&&((h.contextual||f.start!=e.pos||f.mask!=o||f.context!=l)&&(this.updateCachedToken(f,h,e),f.mask=o,f.context=l),f.lookAhead>f.end+25&&(a=Math.max(f.lookAhead,a)),f.value!=0)){let u=t;if(f.extended>-1&&(t=this.addActions(e,f.extended,f.end,t)),t=this.addActions(e,f.value,f.end,t),!h.extend&&(i=f,t>u))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!i&&e.pos==this.stream.end&&(i=new Oe,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 Oe,{pos:i,p:s}=e;return t.start=i,t.end=Math.min(i+1,s.stream.end),t.value=i==s.stream.end?s.parser.eofTerm:0,t}updateCachedToken(e,t,i){let s=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(s,e),i),e.value>-1){let{parser:r}=i.p;for(let o=0;o<r.specialized.length;o++)if(r.specialized[o]==e.value){let l=r.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(s+1)}putAction(e,t,i,s){for(let r=0;r<s;r+=3)if(this.actions[r]==e)return s;return this.actions[s++]=e,this.actions[s++]=t,this.actions[s++]=i,s}addActions(e,t,i,s){let{state:r}=e,{parser:o}=e.p,{data:l}=o;for(let a=0;a<2;a++)for(let c=o.stateSlot(r,a?2:1);;c+=3){if(l[c]==65535)if(l[c+1]==1)c=q(l,c+2);else{s==0&&l[c+1]==2&&(s=this.putAction(q(l,c+2),t,i,s));break}l[c]==t&&(s=this.putAction(q(l,c+1),t,i,s))}return s}}class No{constructor(e,t,i,s){this.parser=e,this.input=t,this.ranges=s,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 Po(t,s),this.tokens=new Eo(e,this.stream),this.topTerm=e.top[1];let{from:r}=s[0];this.stacks=[He.start(this,e.top[0],r)],this.fragments=i.length&&this.stream.end-r>e.bufferLength*4?new Oo(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],s,r;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;{s||(s=[],r=[]),s.push(l);let a=this.tokens.getMainToken(l);r.push(a.value,a.end)}}break}}if(!i.length){let o=s&&zo(s);if(o)return P&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw P&&s&&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&&s){let o=this.stoppedAt!=null&&s[0].pos>this.stoppedAt?s[0]:this.runRecovery(s,r,i);if(o)return P&&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,a)=>a.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 a=o+1;a<i.length;a++){let c=i[a];if(l.sameState(c)||l.buffer.length>500&&c.buffer.length>500)if((l.score-c.score||l.buffer.length-c.buffer.length)>0)i.splice(a--,1);else{i.splice(o--,1);continue e}}}i.length>12&&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 s=e.pos,{parser:r}=this,o=P?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&s>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,h=c?e.curContext.hash:0;for(let f=this.fragments.nodeAt(s);f;){let u=this.parser.nodeSet.types[f.type.id]==f.type?r.getGoto(e.state,f.type.id):-1;if(u>-1&&f.length&&(!c||(f.prop(ce.contextHash)||0)==h))return e.useNode(f,u),P&&console.log(o+this.stackID(e)+` (via reuse of ${r.getName(f.type.id)})`),!0;if(!(f instanceof Re)||f.children.length==0||f.positions[0]>0)break;let d=f.children[0];if(d instanceof Re&&f.positions[0]==0)f=d;else break}}let l=r.stateSlot(e.state,4);if(l>0)return e.reduce(l),P&&console.log(o+this.stackID(e)+` (via always-reduce ${r.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let c=0;c<a.length;){let h=a[c++],f=a[c++],u=a[c++],d=c==a.length||!i,p=d?e:e.split(),g=this.tokens.mainToken;if(p.apply(h,f,g?g.start:p.pos,u),P&&console.log(o+this.stackID(p)+` (via ${(h&65536)==0?"shift":`reduce of ${r.getName(h&65535)}`} for ${r.getName(f)} @ ${s}${p==e?"":", split"})`),d)return!0;p.pos>s?t.push(p):i.push(p)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return mn(e,t),!0}}runRecovery(e,t,i){let s=null,r=!1;for(let o=0;o<e.length;o++){let l=e[o],a=t[o<<1],c=t[(o<<1)+1],h=P?this.stackID(l)+" -> ":"";if(l.deadEnd&&(r||(r=!0,l.restart(),P&&console.log(h+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let f=l.split(),u=h;for(let d=0;f.forceReduce()&&d<10&&(P&&console.log(u+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,i));d++)P&&(u=this.stackID(f)+" -> ");for(let d of l.recoverByInsert(a))P&&console.log(h+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>l.pos?(c==l.pos&&(c++,a=0),l.recoverByDelete(a,c),P&&console.log(h+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),mn(l,i)):(!s||s.score<l.score)&&(s=l)}return s}stackToTree(e){return e.close(),Re.build({buffer:Ke.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=(ct||(ct=new WeakMap)).get(e);return t||ct.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function mn(n,e){for(let t=0;t<e.length;t++){let i=e[t];if(i.pos==n.pos&&i.sameState(n)){e[t].score<n.score&&(e[t]=n);return}}e.push(n)}class Fo{constructor(e,t,i){this.source=e,this.flags=t,this.disabled=i}allows(e){return!this.disabled||this.disabled[e]==0}}class kt extends Ui{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]),s=[];for(let l=0;l<t.length;l++)s.push([]);function r(l,a,c){s[l].push([a,a.deserialize(String(c))])}if(e.nodeProps)for(let l of e.nodeProps){let a=l[0];typeof a=="string"&&(a=ce[a]);for(let c=1;c<l.length;){let h=l[c++];if(h>=0)r(h,a,l[c++]);else{let f=l[c+-h];for(let u=-h;u>0;u--)r(l[c++],a,f);c++}}}this.nodeSet=new ji(t.map((l,a)=>Gi.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:s[a],top:i.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Vi;let o=Pe(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(gn),this.states=Pe(e.states,Uint32Array),this.data=Pe(e.stateData),this.goto=Pe(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new ae(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 s=new No(this,e,t,i);for(let r of this.wrappers)s=r(s,e,t,i);return s}getGoto(e,t,i=!1){let s=this.goto;if(t>=s[0])return-1;for(let r=s[t+1];;){let o=s[r++],l=o&1,a=s[r++];if(l&&i)return a;for(let c=r+(o>>1);r<c;r++)if(s[r]==e)return a;if(l)return-1}}hasAction(e,t){let i=this.data;for(let s=0;s<2;s++)for(let r=this.stateSlot(e,s?2:1),o;;r+=3){if((o=i[r])==65535)if(i[r+1]==1)o=i[r=q(i,r+2)];else{if(i[r+1]==2)return q(i,r+2);break}if(o==t||o==0)return q(i,r+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),s=i?t(i):void 0;for(let r=this.stateSlot(e,1);s==null;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=q(this.data,r+2);else break;s=t(q(this.data,r+1))}return s}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=q(this.data,i+2);else break;if((this.data[i+2]&1)==0){let s=this.data[i+1];t.some((r,o)=>o&1&&r==s)||t.push(this.data[i],s)}}return t}configure(e){let t=Object.assign(Object.create(kt.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 s=e.tokenizers.find(r=>r.from==i);return s?s.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,s)=>{let r=e.specializers.find(l=>l.from==i.external);if(!r)return i;let o=Object.assign(Object.assign({},i),{external:r.to});return t.specializers[s]=gn(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 r of e.split(" ")){let o=t.indexOf(r);o>=0&&(i[o]=!0)}let s=null;for(let r=0;r<t.length;r++)if(!i[r])for(let o=this.dialects[t[r]],l;(l=this.data[o++])!=65535;)(s||(s=new Uint8Array(this.maxTerm+1)))[l]=1;return new Fo(e,i,s)}static deserialize(e){return new kt(e)}}function q(n,e){return n[e]|n[e+1]<<16}function zo(n){let e=null;for(let t of n){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 gn(n){if(n.external){let e=n.extend?1:0;return(t,i)=>n.external(t,i)<<1|e}return n.get}export{il as E,kt as L,el as a,Jr as b,Qo as c,Yo as d,Wo as e,_o as f,Ho as g,Go as h,Uo as i,Vo as j,uo as k,tl as l,Zo as m,x as n,et as o,Xo as p,nl as q,qo as r,sn as s,jo as t,Jo as u,Pr as v,Ko as w,Rn as x,Pn as y};