diff --git a/frontends/server/frontend/dist/assets/index-BqmNs24i.js b/frontends/server/frontend/dist/assets/index-DkE9_tVc.js similarity index 62% rename from frontends/server/frontend/dist/assets/index-BqmNs24i.js rename to frontends/server/frontend/dist/assets/index-DkE9_tVc.js index 7fdcbec55..392d4699e 100644 --- a/frontends/server/frontend/dist/assets/index-BqmNs24i.js +++ b/frontends/server/frontend/dist/assets/index-DkE9_tVc.js @@ -1 +1 @@ -(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))i(o);new MutationObserver(o=>{for(const n of o)if(n.type==="childList")for(const s of n.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&i(s)}).observe(document,{childList:!0,subtree:!0});function t(o){const n={};return o.integrity&&(n.integrity=o.integrity),o.referrerPolicy&&(n.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?n.credentials="include":o.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function i(o){if(o.ep)return;o.ep=!0;const n=t(o);fetch(o.href,n)}})();var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},dist={},client={},models={};(function(r){var e=commonjsGlobal&&commonjsGlobal.__extends||function(){var d=function(f,p){return d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,y){m.__proto__=y}||function(m,y){for(var v in y)Object.prototype.hasOwnProperty.call(y,v)&&(m[v]=y[v])},d(f,p)};return function(f,p){if(typeof p!="function"&&p!==null)throw new TypeError("Class extends value "+String(p)+" is not a constructor or null");d(f,p);function m(){this.constructor=f}f.prototype=p===null?Object.create(p):(m.prototype=p.prototype,new m)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.createJSONRPCNotification=r.createJSONRPCRequest=r.createJSONRPCSuccessResponse=r.createJSONRPCErrorResponse=r.JSONRPCErrorCode=r.JSONRPCErrorException=r.isJSONRPCResponses=r.isJSONRPCResponse=r.isJSONRPCRequests=r.isJSONRPCRequest=r.isJSONRPCID=r.JSONRPC=void 0,r.JSONRPC="2.0";var t=function(d){return typeof d=="string"||typeof d=="number"||d===null};r.isJSONRPCID=t;var i=function(d){return d.jsonrpc===r.JSONRPC&&d.method!==void 0&&d.result===void 0&&d.error===void 0};r.isJSONRPCRequest=i;var o=function(d){return Array.isArray(d)&&d.every(r.isJSONRPCRequest)};r.isJSONRPCRequests=o;var n=function(d){return d.jsonrpc===r.JSONRPC&&d.id!==void 0&&(d.result!==void 0||d.error!==void 0)};r.isJSONRPCResponse=n;var s=function(d){return Array.isArray(d)&&d.every(r.isJSONRPCResponse)};r.isJSONRPCResponses=s;var l=function(d,f,p){var m={code:d,message:f};return p!=null&&(m.data=p),m},c=function(d){e(f,d);function f(p,m,y){var v=d.call(this,p)||this;return Object.setPrototypeOf(v,f.prototype),v.code=m,v.data=y,v}return f.prototype.toObject=function(){return l(this.code,this.message,this.data)},f}(Error);r.JSONRPCErrorException=c,function(d){d[d.ParseError=-32700]="ParseError",d[d.InvalidRequest=-32600]="InvalidRequest",d[d.MethodNotFound=-32601]="MethodNotFound",d[d.InvalidParams=-32602]="InvalidParams",d[d.InternalError=-32603]="InternalError"}(r.JSONRPCErrorCode||(r.JSONRPCErrorCode={}));var a=function(d,f,p,m){return{jsonrpc:r.JSONRPC,id:d,error:l(f,p,m)}};r.createJSONRPCErrorResponse=a;var u=function(d,f){return{jsonrpc:r.JSONRPC,id:d,result:f??null}};r.createJSONRPCSuccessResponse=u;var h=function(d,f,p){return{jsonrpc:r.JSONRPC,id:d,method:f,params:p}};r.createJSONRPCRequest=h;var N=function(d,f){return{jsonrpc:r.JSONRPC,method:d,params:f}};r.createJSONRPCNotification=N})(models);var internal={};Object.defineProperty(internal,"__esModule",{value:!0});internal.DefaultErrorCode=void 0;internal.DefaultErrorCode=0;var __awaiter$2=commonjsGlobal&&commonjsGlobal.__awaiter||function(r,e,t,i){function o(n){return n instanceof t?n:new t(function(s){s(n)})}return new(t||(t=Promise))(function(n,s){function l(u){try{a(i.next(u))}catch(h){s(h)}}function c(u){try{a(i.throw(u))}catch(h){s(h)}}function a(u){u.done?n(u.value):o(u.value).then(l,c)}a((i=i.apply(r,e||[])).next())})},__generator$2=commonjsGlobal&&commonjsGlobal.__generator||function(r,e){var t={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},i,o,n,s;return s={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function l(a){return function(u){return c([a,u])}}function c(a){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(t=0)),t;)try{if(i=1,o&&(n=a[0]&2?o.return:a[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,a[1])).done)return n;switch(o=0,n&&(a=[a[0]&2,n.value]),a[0]){case 0:case 1:n=a;break;case 4:return t.label++,{value:a[1],done:!1};case 5:t.label++,o=a[1],a=[0];continue;case 7:a=t.ops.pop(),t.trys.pop();continue;default:if(n=t.trys,!(n=n.length>0&&n[n.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!n||a[1]>n[0]&&a[1]0&&n[n.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!n||a[1]>n[0]&&a[1]0&&n[n.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!n||a[1]>n[0]&&a[1]{const[t,i,o]=e;this.requestInternal(t,i,o)}),this.messageQueue=[]}request(e,t,i){this.webSocket.readyState===WebSocket.OPEN?this.requestInternal(e,t,i):this.messageQueue.push([e,t,i])}notify(e,t){switch(this.webSocket.readyState){case WebSocket.OPEN:this.serverAndClient.notify(e,t);break}}connect(e){this.closed||(console.log("connect",this.url),this.webSocket=new WebSocket(this.url),this.serverAndClient||(this.serverAndClient=new dist.JSONRPCServerAndClient(new dist.JSONRPCServer,new dist.JSONRPCClient(t=>{try{return this.webSocket.send(JSON.stringify(t)),Promise.resolve()}catch(i){return Promise.reject(i)}}))),this.webSocket.onmessage=t=>{this.serverAndClient.receiveAndSend(JSON.parse(t.data.toString()))},this.webSocket.onopen=()=>{console.log("WebSocket connection established"),this.connectionEstablished=!0,this.onConnected&&this.onConnected(),this.requestMessageQueue()},this.webSocket.onclose=t=>{console.error("WebScoket closed",t),this.serverAndClient.rejectAllPendingRequests(`Connection is closed (${t.reason}).`),this.connectionEstablished&&this.onClosed(),this.timerId=setTimeout(()=>{this.connect()},3e3)},this.webSocket.onerror=t=>{console.error("WebSocket error:",t),this.webSocket.close()})}}const modifierKeys=["Shift","Control","Alt","Meta"],convertKeyTable={Enter:"Return",ArrowRight:"Right",ArrowLeft:"Left",ArrowUp:"Up",ArrowDown:"Down","¡":"1","™":"2","£":"3","¢":"4","∞":"5","§":"6","¶":"7","•":"8",ª:"9",º:"0","–":"-","≠":"=","“":"[","‘":"]","«":"\\","…":";",æ:"'","≤":",","≥":".","÷":"/","⁄":"!","€":"@","‹":"#","›":"$",fi:"%",fl:"^","‡":"&","°":"*","·":"(","‚":")","—":"_","±":"+","”":"{","’":"}","»":"|",Ú:":",Æ:'"',"¯":"<","˘":">","¿":"?",œ:"q","∑":"w","´":"e","®":"r","†":"t","¥":"y","¨":"u","ˆ":"i",ø:"o",π:"p",å:"a",ß:"s","∂":"d",ƒ:"f","©":"g","˙":"h","∆":"j","˚":"k","¬":"l",Ω:"z","≈":"x",ç:"c","√":"v","∫":"b","˜":"n",µ:"m",Œ:"Q","„":"W","´":"E","‰":"R","ˇ":"T",Á:"Y","¨":"U","ˆ":"I",Ø:"O","∏":"P",Å:"A",Í:"S",Î:"D",Ï:"F","˝":"G",Ó:"H",Ô:"J","":"K",Ò:"L","¸":"Z","˛":"X",Ç:"C","◊":"V",ı:"B","˜":"N",Â:"M"};function getKey(r){return r.altKey?convertKeyTable[r.key]||(r.code.startsWith("Key")?r.code[3].toLowerCase():null)||r.key:convertKeyTable[r.key]||r.key}function convertKeyEvent(r){return modifierKeys.indexOf(r.key)!==-1?null:{key:getKey(r),ctrl:r.ctrlKey,meta:r.altKey,super:r.metaKey,shift:r.shiftKey}}var defs=[[0,31,"N"],[32,126,"Na"],[127,160,"N"],[161,161,"A"],[162,163,"Na"],[164,164,"A"],[165,166,"Na"],[167,168,"A"],[169,169,"N"],[170,170,"A"],[171,171,"N"],[172,172,"Na"],[173,174,"A"],[175,175,"Na"],[176,180,"A"],[181,181,"N"],[182,186,"A"],[187,187,"N"],[188,191,"A"],[192,197,"N"],[198,198,"A"],[199,207,"N"],[208,208,"A"],[209,214,"N"],[215,216,"A"],[217,221,"N"],[222,225,"A"],[226,229,"N"],[230,230,"A"],[231,231,"N"],[232,234,"A"],[235,235,"N"],[236,237,"A"],[238,239,"N"],[240,240,"A"],[241,241,"N"],[242,243,"A"],[244,246,"N"],[247,250,"A"],[251,251,"N"],[252,252,"A"],[253,253,"N"],[254,254,"A"],[255,256,"N"],[257,257,"A"],[258,272,"N"],[273,273,"A"],[274,274,"N"],[275,275,"A"],[276,282,"N"],[283,283,"A"],[284,293,"N"],[294,295,"A"],[296,298,"N"],[299,299,"A"],[300,304,"N"],[305,307,"A"],[308,311,"N"],[312,312,"A"],[313,318,"N"],[319,322,"A"],[323,323,"N"],[324,324,"A"],[325,327,"N"],[328,331,"A"],[332,332,"N"],[333,333,"A"],[334,337,"N"],[338,339,"A"],[340,357,"N"],[358,359,"A"],[360,362,"N"],[363,363,"A"],[364,461,"N"],[462,462,"A"],[463,463,"N"],[464,464,"A"],[465,465,"N"],[466,466,"A"],[467,467,"N"],[468,468,"A"],[469,469,"N"],[470,470,"A"],[471,471,"N"],[472,472,"A"],[473,473,"N"],[474,474,"A"],[475,475,"N"],[476,476,"A"],[477,592,"N"],[593,593,"A"],[594,608,"N"],[609,609,"A"],[610,707,"N"],[708,708,"A"],[709,710,"N"],[711,711,"A"],[712,712,"N"],[713,715,"A"],[716,716,"N"],[717,717,"A"],[718,719,"N"],[720,720,"A"],[721,727,"N"],[728,731,"A"],[732,732,"N"],[733,733,"A"],[734,734,"N"],[735,735,"A"],[736,767,"N"],[768,879,"A"],[880,912,"N"],[913,929,"A"],[930,930,"N"],[931,937,"A"],[938,944,"N"],[945,961,"A"],[962,962,"N"],[963,969,"A"],[970,1024,"N"],[1025,1025,"A"],[1026,1039,"N"],[1040,1103,"A"],[1104,1104,"N"],[1105,1105,"A"],[1106,4351,"N"],[4352,4447,"W"],[4448,8207,"N"],[8208,8208,"A"],[8209,8210,"N"],[8211,8214,"A"],[8215,8215,"N"],[8216,8217,"A"],[8218,8219,"N"],[8220,8221,"A"],[8222,8223,"N"],[8224,8226,"A"],[8227,8227,"N"],[8228,8231,"A"],[8232,8239,"N"],[8240,8240,"A"],[8241,8241,"N"],[8242,8243,"A"],[8244,8244,"N"],[8245,8245,"A"],[8246,8250,"N"],[8251,8251,"A"],[8252,8253,"N"],[8254,8254,"A"],[8255,8307,"N"],[8308,8308,"A"],[8309,8318,"N"],[8319,8319,"A"],[8320,8320,"N"],[8321,8324,"A"],[8325,8360,"N"],[8361,8361,"H"],[8362,8363,"N"],[8364,8364,"A"],[8365,8450,"N"],[8451,8451,"A"],[8452,8452,"N"],[8453,8453,"A"],[8454,8456,"N"],[8457,8457,"A"],[8458,8466,"N"],[8467,8467,"A"],[8468,8469,"N"],[8470,8470,"A"],[8471,8480,"N"],[8481,8482,"A"],[8483,8485,"N"],[8486,8486,"A"],[8487,8490,"N"],[8491,8491,"A"],[8492,8530,"N"],[8531,8532,"A"],[8533,8538,"N"],[8539,8542,"A"],[8543,8543,"N"],[8544,8555,"A"],[8556,8559,"N"],[8560,8569,"A"],[8570,8584,"N"],[8585,8585,"A"],[8586,8591,"N"],[8592,8601,"A"],[8602,8631,"N"],[8632,8633,"A"],[8634,8657,"N"],[8658,8658,"A"],[8659,8659,"N"],[8660,8660,"A"],[8661,8678,"N"],[8679,8679,"A"],[8680,8703,"N"],[8704,8704,"A"],[8705,8705,"N"],[8706,8707,"A"],[8708,8710,"N"],[8711,8712,"A"],[8713,8714,"N"],[8715,8715,"A"],[8716,8718,"N"],[8719,8719,"A"],[8720,8720,"N"],[8721,8721,"A"],[8722,8724,"N"],[8725,8725,"A"],[8726,8729,"N"],[8730,8730,"A"],[8731,8732,"N"],[8733,8736,"A"],[8737,8738,"N"],[8739,8739,"A"],[8740,8740,"N"],[8741,8741,"A"],[8742,8742,"N"],[8743,8748,"A"],[8749,8749,"N"],[8750,8750,"A"],[8751,8755,"N"],[8756,8759,"A"],[8760,8763,"N"],[8764,8765,"A"],[8766,8775,"N"],[8776,8776,"A"],[8777,8779,"N"],[8780,8780,"A"],[8781,8785,"N"],[8786,8786,"A"],[8787,8799,"N"],[8800,8801,"A"],[8802,8803,"N"],[8804,8807,"A"],[8808,8809,"N"],[8810,8811,"A"],[8812,8813,"N"],[8814,8815,"A"],[8816,8833,"N"],[8834,8835,"A"],[8836,8837,"N"],[8838,8839,"A"],[8840,8852,"N"],[8853,8853,"A"],[8854,8856,"N"],[8857,8857,"A"],[8858,8868,"N"],[8869,8869,"A"],[8870,8894,"N"],[8895,8895,"A"],[8896,8977,"N"],[8978,8978,"A"],[8979,8985,"N"],[8986,8987,"W"],[8988,9e3,"N"],[9001,9002,"W"],[9003,9192,"N"],[9193,9196,"W"],[9197,9199,"N"],[9200,9200,"W"],[9201,9202,"N"],[9203,9203,"W"],[9204,9311,"N"],[9312,9449,"A"],[9450,9450,"N"],[9451,9547,"A"],[9548,9551,"N"],[9552,9587,"A"],[9588,9599,"N"],[9600,9615,"A"],[9616,9617,"N"],[9618,9621,"A"],[9622,9631,"N"],[9632,9633,"A"],[9634,9634,"N"],[9635,9641,"A"],[9642,9649,"N"],[9650,9651,"A"],[9652,9653,"N"],[9654,9655,"A"],[9656,9659,"N"],[9660,9661,"A"],[9662,9663,"N"],[9664,9665,"A"],[9666,9669,"N"],[9670,9672,"A"],[9673,9674,"N"],[9675,9675,"A"],[9676,9677,"N"],[9678,9681,"A"],[9682,9697,"N"],[9698,9701,"A"],[9702,9710,"N"],[9711,9711,"A"],[9712,9724,"N"],[9725,9726,"W"],[9727,9732,"N"],[9733,9734,"A"],[9735,9736,"N"],[9737,9737,"A"],[9738,9741,"N"],[9742,9743,"A"],[9744,9747,"N"],[9748,9749,"W"],[9750,9755,"N"],[9756,9756,"A"],[9757,9757,"N"],[9758,9758,"A"],[9759,9791,"N"],[9792,9792,"A"],[9793,9793,"N"],[9794,9794,"A"],[9795,9799,"N"],[9800,9811,"W"],[9812,9823,"N"],[9824,9825,"A"],[9826,9826,"N"],[9827,9829,"A"],[9830,9830,"N"],[9831,9834,"A"],[9835,9835,"N"],[9836,9837,"A"],[9838,9838,"N"],[9839,9839,"A"],[9840,9854,"N"],[9855,9855,"W"],[9856,9874,"N"],[9875,9875,"W"],[9876,9885,"N"],[9886,9887,"A"],[9888,9888,"N"],[9889,9889,"W"],[9890,9897,"N"],[9898,9899,"W"],[9900,9916,"N"],[9917,9918,"W"],[9919,9919,"A"],[9920,9923,"N"],[9924,9925,"W"],[9926,9933,"A"],[9934,9934,"W"],[9935,9939,"A"],[9940,9940,"W"],[9941,9953,"A"],[9954,9954,"N"],[9955,9955,"A"],[9956,9959,"N"],[9960,9961,"A"],[9962,9962,"W"],[9963,9969,"A"],[9970,9971,"W"],[9972,9972,"A"],[9973,9973,"W"],[9974,9977,"A"],[9978,9978,"W"],[9979,9980,"A"],[9981,9981,"W"],[9982,9983,"A"],[9984,9988,"N"],[9989,9989,"W"],[9990,9993,"N"],[9994,9995,"W"],[9996,10023,"N"],[10024,10024,"W"],[10025,10044,"N"],[10045,10045,"A"],[10046,10059,"N"],[10060,10060,"W"],[10061,10061,"N"],[10062,10062,"W"],[10063,10066,"N"],[10067,10069,"W"],[10070,10070,"N"],[10071,10071,"W"],[10072,10101,"N"],[10102,10111,"A"],[10112,10132,"N"],[10133,10135,"W"],[10136,10159,"N"],[10160,10160,"W"],[10161,10174,"N"],[10175,10175,"W"],[10176,10213,"N"],[10214,10221,"Na"],[10222,10628,"N"],[10629,10630,"Na"],[10631,11034,"N"],[11035,11036,"W"],[11037,11087,"N"],[11088,11088,"W"],[11089,11092,"N"],[11093,11093,"W"],[11094,11097,"A"],[11098,11903,"N"],[11904,11929,"W"],[11930,11930,"N"],[11931,12019,"W"],[12020,12031,"N"],[12032,12245,"W"],[12246,12271,"N"],[12272,12287,"W"],[12288,12288,"F"],[12289,12350,"W"],[12351,12352,"N"],[12353,12438,"W"],[12439,12440,"N"],[12441,12543,"W"],[12544,12548,"N"],[12549,12591,"W"],[12592,12592,"N"],[12593,12686,"W"],[12687,12687,"N"],[12688,12771,"W"],[12772,12782,"N"],[12783,12830,"W"],[12831,12831,"N"],[12832,12871,"W"],[12872,12879,"A"],[12880,19903,"W"],[19904,19967,"N"],[19968,42124,"W"],[42125,42127,"N"],[42128,42182,"W"],[42183,43359,"N"],[43360,43388,"W"],[43389,44031,"N"],[44032,55203,"W"],[55204,57343,"N"],[57344,63743,"A"],[63744,64255,"W"],[64256,65023,"N"],[65024,65039,"A"],[65040,65049,"W"],[65050,65071,"N"],[65072,65106,"W"],[65107,65107,"N"],[65108,65126,"W"],[65127,65127,"N"],[65128,65131,"W"],[65132,65280,"N"],[65281,65376,"F"],[65377,65470,"H"],[65471,65473,"N"],[65474,65479,"H"],[65480,65481,"N"],[65482,65487,"H"],[65488,65489,"N"],[65490,65495,"H"],[65496,65497,"N"],[65498,65500,"H"],[65501,65503,"N"],[65504,65510,"F"],[65511,65511,"N"],[65512,65518,"H"],[65519,65532,"N"],[65533,65533,"A"],[65534,94175,"N"],[94176,94180,"W"],[94181,94191,"N"],[94192,94193,"W"],[94194,94207,"N"],[94208,100343,"W"],[100344,100351,"N"],[100352,101589,"W"],[101590,101631,"N"],[101632,101640,"W"],[101641,110575,"N"],[110576,110579,"W"],[110580,110580,"N"],[110581,110587,"W"],[110588,110588,"N"],[110589,110590,"W"],[110591,110591,"N"],[110592,110882,"W"],[110883,110897,"N"],[110898,110898,"W"],[110899,110927,"N"],[110928,110930,"W"],[110931,110932,"N"],[110933,110933,"W"],[110934,110947,"N"],[110948,110951,"W"],[110952,110959,"N"],[110960,111355,"W"],[111356,126979,"N"],[126980,126980,"W"],[126981,127182,"N"],[127183,127183,"W"],[127184,127231,"N"],[127232,127242,"A"],[127243,127247,"N"],[127248,127277,"A"],[127278,127279,"N"],[127280,127337,"A"],[127338,127343,"N"],[127344,127373,"A"],[127374,127374,"W"],[127375,127376,"A"],[127377,127386,"W"],[127387,127404,"A"],[127405,127487,"N"],[127488,127490,"W"],[127491,127503,"N"],[127504,127547,"W"],[127548,127551,"N"],[127552,127560,"W"],[127561,127567,"N"],[127568,127569,"W"],[127570,127583,"N"],[127584,127589,"W"],[127590,127743,"N"],[127744,127776,"W"],[127777,127788,"N"],[127789,127797,"W"],[127798,127798,"N"],[127799,127868,"W"],[127869,127869,"N"],[127870,127891,"W"],[127892,127903,"N"],[127904,127946,"W"],[127947,127950,"N"],[127951,127955,"W"],[127956,127967,"N"],[127968,127984,"W"],[127985,127987,"N"],[127988,127988,"W"],[127989,127991,"N"],[127992,128062,"W"],[128063,128063,"N"],[128064,128064,"W"],[128065,128065,"N"],[128066,128252,"W"],[128253,128254,"N"],[128255,128317,"W"],[128318,128330,"N"],[128331,128334,"W"],[128335,128335,"N"],[128336,128359,"W"],[128360,128377,"N"],[128378,128378,"W"],[128379,128404,"N"],[128405,128406,"W"],[128407,128419,"N"],[128420,128420,"W"],[128421,128506,"N"],[128507,128591,"W"],[128592,128639,"N"],[128640,128709,"W"],[128710,128715,"N"],[128716,128716,"W"],[128717,128719,"N"],[128720,128722,"W"],[128723,128724,"N"],[128725,128727,"W"],[128728,128731,"N"],[128732,128735,"W"],[128736,128746,"N"],[128747,128748,"W"],[128749,128755,"N"],[128756,128764,"W"],[128765,128991,"N"],[128992,129003,"W"],[129004,129007,"N"],[129008,129008,"W"],[129009,129291,"N"],[129292,129338,"W"],[129339,129339,"N"],[129340,129349,"W"],[129350,129350,"N"],[129351,129535,"W"],[129536,129647,"N"],[129648,129660,"W"],[129661,129663,"N"],[129664,129672,"W"],[129673,129679,"N"],[129680,129725,"W"],[129726,129726,"N"],[129727,129733,"W"],[129734,129741,"N"],[129742,129755,"W"],[129756,129759,"N"],[129760,129768,"W"],[129769,129775,"N"],[129776,129784,"W"],[129785,131071,"N"],[131072,196605,"W"],[196606,196607,"N"],[196608,262141,"W"],[262142,917759,"N"],[917760,917999,"A"],[918e3,983039,"N"],[983040,1048573,"A"],[1048574,1048575,"N"],[1048576,1114109,"A"],[1114110,1114111,"N"]];function getEAWOfCodePoint(r){let e=0,t=defs.length-1;for(;e!==t;){const i=e+(t-e>>1),[o,n,s]=defs[i];if(rn)e=i+1;else return s}return defs[e][2]}function getEAW(r,e=0){const t=r.codePointAt(e);if(t!==void 0)return getEAWOfCodePoint(t)}const textOffsetY=0;function isWideChar(r){switch(getEAW(r)){case"A":case"F":case"W":return!0;default:return!1}}function isMacOS(){return window.navigator.userAgent.indexOf("Mac OS X")!==-1}function computeFontSize(r){const t=document.createElement("canvas").getContext("2d");t.font=r;const i=t.measureText("W");return[Math.floor(i.width),Math.round(i.fontBoundingBoxAscent+textOffsetY+0)]}function drawBlock({ctx:r,x:e,y:t,width:i,height:o,style:n}){r.fillStyle=n,r.fillRect(e,t,i,o)}function drawText({ctx:r,x:e,y:t,text:i,font:o,style:n,option:s}){t+=Math.round(textOffsetY),r.fillStyle=n,r.font=o,r.textBaseline="top";for(const l of i)isWideChar(l)?(r.fillText(l,e,t,s.fontWidth*2),e+=s.fontWidth*2):(r.fillText(l,e,t,s.fontWidth),e+=s.fontWidth)}function drawHorizontalLine({ctx:r,x:e,y:t,width:i,style:o,lineWidth:n=1}){r.strokeStyle=o,r.lineWidth=n,r.setLineDash=[],r.beginPath(),r.moveTo(e,t),r.lineTo(e+i,t),r.stroke()}class Option{constructor({fontName:e,fontSize:t}){const i=t+"px "+e;this.font=i;const[o,n]=computeFontSize(i);this.fontWidth=o,this.fontHeight=n,this.foreground="#333",this.background="#ccc"}}function getLemEditorElement(){return document.getElementById("lem-editor")}class Cursor{constructor(e,t,i){this.editor=e,this.name=t,this.color=i,this.span=document.createElement("span"),this.span.style.all="none",this.span.style.position="absolute",this.span.style.zIndex="",this.span.style.top="0",this.span.style.left="0",this.span.style.fontFamily=e.option.font,this.span.style.backgroundColor=i,this.span.style.color="white",this.span.innerHTML="",document.body.appendChild(this.span),this.timerId=null}move(e,t){const[i,o]=this.editor.getDisplayRectangle();this.span.style.visibility="visible",this.span.textContent=this.name,this.span.style.left=e+i+"px",this.span.style.top=t+o+"px",this.span.style.padding="3px 1%",this.timerId&&clearTimeout(this.timerId),this.timerId=setTimeout(()=>{this.span.style.visibility="hidden"},500)}}function addMouseEventListeners({dom:r,editor:e,isDraggable:t,draggableStyle:i}){r.addEventListener("contextmenu",s=>{s.preventDefault()});const o=(s,l)=>{s.preventDefault();const[c,a]=e.getDisplayRectangle(),u=s.clientX-c,h=s.clientY-a,N=Math.floor(u/e.option.fontWidth),d=Math.floor(h/e.option.fontHeight);e.jsonrpc.notify("input",{kind:l,value:{x:N,y:d,pixelX:u,pixelY:h,button:s.button,clicks:s.detail}})};r.addEventListener("mousedown",s=>{t&&(document.body.style.cursor=i),o(s,"mousedown")}),r.addEventListener("mouseup",s=>{t&&(document.body.style.cursor="default"),o(s,"mouseup")});let n=0;r.addEventListener("mousemove",s=>{s.preventDefault();const l=Date.now();if(l-n>50){n=l;const[c,a]=e.getDisplayRectangle(),u=s.clientX-c,h=s.clientY-a,N=Math.floor(u/e.option.fontWidth),d=Math.floor(h/e.option.fontHeight);e.jsonrpc.notify("input",{kind:"mousemove",value:{x:N,y:d,pixelX:u,pixelY:h,button:s.buttons===0?null:s.buttons-1}})}}),t&&(r.addEventListener("mouseover",()=>{document.body.style.cursor=i}),r.addEventListener("mouseout",s=>{s.buttons!==1&&(document.body.style.cursor="default")})),r.addEventListener("wheel",s=>{s.preventDefault();const[l,c]=e.getDisplayRectangle(),a=s.clientX-l,u=s.clientY-c,h=Math.floor(a/e.option.fontWidth),N=Math.floor(u/e.option.fontHeight);e.jsonrpc.notify("input",{kind:"wheel",value:{pixelX:a,pixelY:u,x:h,y:N,wheelX:-Math.round(s.deltaX*.01),wheelY:-Math.round(s.deltaY*.01)}})})}const borderOffsetX=5,borderOffsetY=10;class BaseSurface{constructor({editor:r}){this.editor=r,this.mainDOM=null,this.wrapper=null}delete(){this.wrapper?getLemEditorElement().removeChild(this.wrapper):getLemEditorElement().removeChild(this.mainDOM)}setupDOM({dom:r,isFloating:e,border:t}){this.mainDOM=r,e&&t?(this.wrapper=document.createElement("div"),this.wrapper.style.position="absolute",this.wrapper.style.padding="10px",this.wrapper.style.border="1px solid",this.wrapper.style.borderColor=this.editor.option.foreground,this.wrapper.style.backgroundColor=this.editor.option.background,this.wrapper.appendChild(r),getLemEditorElement().appendChild(this.wrapper)):getLemEditorElement().appendChild(r)}move(r,e){const[t,i]=this.editor.getDisplayRectangle(),o=Math.floor(t+r*this.editor.option.fontWidth),n=Math.floor(i+e*this.editor.option.fontHeight);this.wrapper?(this.wrapper.style.left=o-borderOffsetX+"px",this.wrapper.style.top=n-borderOffsetY+"px",this.mainDOM.style.left=borderOffsetX+"px",this.mainDOM.style.top=borderOffsetY+"px"):(this.mainDOM.style.left=o+"px",this.mainDOM.style.top=n+"px")}resize(r,e){const t=window.devicePixelRatio||1;this.mainDOM.width=r*this.editor.option.fontWidth*t,this.mainDOM.height=e*this.editor.option.fontHeight*t,this.mainDOM.style.width=r*this.editor.option.fontWidth+"px",this.mainDOM.style.height=e*this.editor.option.fontHeight+"px",this.mainDOM.getContext("2d").scale(t,t),this.wrapper&&(this.wrapper.style.width=r*this.editor.option.fontWidth+borderOffsetX*2+"px",this.wrapper.style.height=e*this.editor.option.fontHeight+borderOffsetY*2+"px")}drawBlock(r,e,t,i,o){}drawText(r,e,t,i,o){}touch(){}evalIn(code){eval(code)}}class CanvasSurface extends BaseSurface{constructor({editor:e,view:t,x:i,y:o,width:n,height:s,styles:l,isFloating:c,border:a}){super({editor:e});const u=this.setupCanvas(l);this.setupDOM({dom:u,isFloating:c,border:a}),this.move(i,o),this.resize(n,s),this.drawingQueue=[],addMouseEventListeners({dom:u,editor:e})}setupCanvas(e){const t=document.createElement("canvas");if(t.style.position="absolute",e)for(let i in e)t.style[i]=e[i];return t}drawBlock(e,t,i,o,n){const s=this.editor.option;this.drawingQueue.push(function(l){drawBlock({ctx:l,x:e*s.fontWidth,y:t*s.fontHeight,width:i*s.fontWidth,height:o*s.fontHeight,style:n})})}drawText(e,t,i,o,n){const s=this.editor.option;this.drawingQueue.push(function(l){if(!n)drawBlock({ctx:l,x:e*s.fontWidth,y:t*s.fontHeight,width:o*s.fontWidth,height:s.fontHeight,style:s.background}),drawText({ctx:l,x:e*s.fontWidth,y:t*s.fontHeight,text:i,style:s.foreground,font:s.font,option:s});else{let{foreground:c,background:a,bold:u,reverse:h,underline:N}=n;if(c||(c=s.foreground),a||(a=s.background),h){const p=a;a=c,c=p}const d=e*s.fontWidth,f=t*s.fontHeight;drawBlock({ctx:l,x:d,y:f,width:o*s.fontWidth,height:s.fontHeight,style:a}),drawText({ctx:l,x:d,y:f,text:i,style:c,font:u?"bold "+s.font:s.font,option:s}),N&&drawHorizontalLine({ctx:l,x:d,y:f+s.fontHeight-2,width:o*s.fontWidth,style:typeof N=="string"?N:c,lineWidth:2})}})}touch(){const e=this.mainDOM.getContext("2d");for(let t of this.drawingQueue)t(e);this.drawingQueue=[]}}class HTMLSurface extends BaseSurface{constructor({editor:e,x:t,y:i,width:o,height:n,styles:s,isFloating:l,border:c,html:a}){super({editor:e});const u=document.createElement("iframe");this.setupDOM({dom:u,isFloating:l,border:c}),u.style.position="absolute",u.style.backgroundColor="white",u.setAttribute("sandbox","allow-scripts allow-same-origin"),u.srcdoc=a,this.iframe=u,this.move(t,i),this.resize(o,n)}update(e){const t=this.iframe.contentWindow.scrollY;this.iframe.srcdoc=e,this.iframe.onload=()=>{this.iframe.onload=null,this.iframe.contentWindow.scrollTo(0,t)}}evalIn(e){this.iframe.contentWindow.eval(e)}}class VerticalBorder{constructor({x:e,y:t,height:i,option:o,editor:n}){this.option=o,this.editor=n,this.line=document.createElement("div"),this.line.style.backgroundColor=o.foreground,this.line.style.width="5px",this.line.style.height=i*o.fontHeight+"px",this.line.style.position="absolute",getLemEditorElement().appendChild(this.line),this.move(e,t),addMouseEventListeners({dom:this.line,editor:n,isDraggable:!0,draggableStyle:"col-resize"})}delete(){this.line.parentNode.removeChild(this.line)}move(e,t){const[i,o]=this.editor.getDisplayRectangle();this.line.style.left=Math.floor(i+e*this.option.fontWidth-this.option.fontWidth/2)+"px",this.line.style.top=o+t*this.option.fontHeight+"px"}resize(e){this.line.style.height=e*this.option.fontHeight+"px"}}const viewStyles={tile:()=>{},floating:r=>({boxSizing:"border-box",borderColor:r.foreground,backgroundColor:r.background})};function getViewStyle(r,e){return viewStyles[r](e)||{}}class View{constructor({id:e,x:t,y:i,width:o,height:n,useModeline:s,kind:l,type:c,content:a,border:u,option:h,editor:N}){switch(this.option=h,this.id=e,this.x=t,this.y=i,this.width=o,this.height=n,this.useModeline=s,this.kind=l,this.type=c,this.border=u,this.editor=N,this.leftsideBar=null,l){case"tile":this.mainSurface=this.makeSurface(c,a),this.leftSideBar=new VerticalBorder({x:t,y:i,height:n+(s?1:0),option:h,editor:N});break;case"floating":this.mainSurface=this.makeSurface(c,a);break}this.modelineSurface=s?this.makeModelineSurface():null}delete(){this.mainSurface.delete(),this.modelineSurface&&this.modelineSurface.delete(),this.leftSideBar&&this.leftSideBar.delete()}move(e,t){this.x=e,this.y=t,this.mainSurface.move(e,t),this.modelineSurface&&this.modelineSurface.move(e,t+this.height),this.leftSideBar&&this.leftSideBar.move(e,t)}resize(e,t){this.width=e,this.height=t,this.mainSurface.resize(e,t),this.modelineSurface&&(this.modelineSurface.move(this.x,this.y+this.height),this.modelineSurface.resize(e,1)),this.leftSideBar&&this.leftSideBar.resize(t+1)}clear(){this.mainSurface.drawBlock(0,0,this.width,this.height,this.option.background)}clearEol(e,t){this.mainSurface.drawBlock(e,t,this.width-e,1,this.option.background)}clearEob(e,t){this.mainSurface.drawBlock(e,t,this.width,this.height-t,this.option.background)}print(e,t,i,o,n){this.mainSurface.drawText(e,t,i,o,n)}printToModeline(e,t,i,o,n){this.modelineSurface&&this.modelineSurface.drawText(e,t,i,o,n)}touch(){this.mainSurface.touch(),this.modelineSurface&&this.modelineSurface.touch()}makeSurface(e,t){switch(e){case"html":return this.makeHTMLSurface(t);case"editor":return this.makeEditorSurface();default:console.error(`unknown type: ${e}`)}}makeHTMLSurface(e){return new HTMLSurface({editor:this.editor,x:this.x,y:this.y,width:this.width,height:this.height,styles:getViewStyle(this.kind,this.option),isFloating:this.kind==="floating",border:this.border,html:e})}makeEditorSurface(){return new CanvasSurface({option:this.editor.option,x:this.x,y:this.y,width:this.width,height:this.height,styles:getViewStyle(this.kind,this.option),editor:this.editor,border:this.border,isFloating:this.kind==="floating",view:this})}makeModelineSurface(){const e=new CanvasSurface({option:this.editor.option,x:this.x,y:this.y+this.height,width:this.width,height:1,editor:this.editor,view:this});return addMouseEventListeners({dom:e.mainDOM,editor:this.editor,isDraggable:!0,draggableStyle:"row-resize"}),e}changeToHTMLContent(e){this.mainSurface.constructor.name==="HTMLSurface"?this.mainSurface.update(e):(this.mainSurface.delete(),this.mainSurface=this.makeHTMLSurface(e))}changeToEditorContent(){this.mainSurface.delete(),this.mainSurface=this.makeEditorSurface()}evalIn(e){this.mainSurface.evalIn(e)}}function isPasteKeyEvent(r){return isMacOS()?!1:r.ctrlKey&&r.shiftKey&&r.key==="V"}class Input{constructor(e){const t=e.option;this.editor=e,this.composition=!1,this.span=document.createElement("span"),this.span.style.color=t.foreground,this.span.style.backgroundColor=t.background,this.span.style.position="absolute",this.span.style.zIndex="",this.span.style.top="0",this.span.style.left="0",this.span.style.font=t.font,this.input=document.createElement("input"),this.input.style.backgroundColor="transparent",this.input.style.color="transparent",this.input.style.width="0",this.input.style.padding="0",this.input.style.margin="0",this.input.style.border="none",this.input.style.position="absolute",this.input.style.zIndex="-10",this.input.style.top="0",this.input.style.left="0",this.input.style.font=t.font,this.input.addEventListener("blur",i=>{this.editor.inputEnabled&&this.input.focus()}),this.input.addEventListener("input",i=>{this.editor.inputEnabled&&this.composition===!1&&(this.input.value="",this.span.innerHTML="",this.input.style.width="0",this.editor.emitInputString(i.data))}),this.input.addEventListener("keydown",i=>{if(this.editor.inputEnabled){if(isPasteKeyEvent(i)){this.editor.jsonrpc.notify("input",{kind:"clipboard-paste"});return}if(i.isComposing||this.composition||i.key==="Process"||!isMacOS()&&!i.ctrlKey&&!i.altKey&&i.key.length===1)return;if(i.preventDefault(),i.isComposing!==!0&&i.code!=="")return this.editor.emitInput(i),this.input.value="",!1}}),this.input.addEventListener("compositionstart",i=>{this.editor.inputEnabled&&(this.composition=!0,this.span.innerHTML=this.input.value,this.input.style.width=this.span.offsetWidth+"px")}),this.input.addEventListener("compositionupdate",i=>{this.editor.inputEnabled&&(this.span.innerHTML=i.data,this.input.style.width=this.span.offsetWidth+"px")}),this.input.addEventListener("compositionend",i=>{this.editor.inputEnabled&&(this.composition=!1,this.editor.emitInputString(this.input.value),this.input.value="",this.span.innerHTML=this.input.value,this.input.style.width="0")}),document.body.appendChild(this.input),document.body.appendChild(this.span),this.input.focus()}finalize(){document.body.removeChild(this.input),document.body.removeChild(this.span)}move(e,t){const[i,o]=this.editor.getDisplayRectangle();this.span.style.top=o+t+"px",this.span.style.left=i+e+"px",this.input.style.top=this.span.offsetTop+"px",this.input.style.left=this.span.offsetLeft+"px"}updateForeground(e){this.span.style.color=e}updateBackground(e){this.span.style.backgroundColor=e}}class MessageTable{constructor(){this.map=new Map}register(e,t){for(const i in t){const o=t[i];this.map.set(i,o),e.on(i,o)}}get(e){return this.map.get(e)}}function getDisplayRectangleDefault(){return[0,0,window.innerWidth,window.innerHeight]}class Editor{constructor({getDisplayRectangle:e=getDisplayRectangleDefault,fontName:t,fontSize:i,onLoaded:o,url:n,onExit:s,onClosed:l,onRestart:c,onUserInput:a,onSwitchFile:u}){this.getDisplayRectangle=e,this.option=new Option({fontName:t,fontSize:i}),this.onExit=s,this.onLoaded=o,this.onRestart=c,this.onUserInput=a,this.onSwitchFile=u,this.inputEnabled=!0,this.input=new Input(this),this.cursors=new Map,this.viewMap=new Map,this.jsonrpc=new JSONRPC(n,{onClosed:()=>{l()}}),this.messageTable=new MessageTable,this.messageTable.register(this.jsonrpc,{startup:this.startup.bind(this),"update-foreground":this.updateForeground.bind(this),"update-background":this.updateBackground.bind(this),"make-view":this.makeView.bind(this),"delete-view":this.deleteView.bind(this),"resize-view":this.resize.bind(this),"move-view":this.move.bind(this),"redraw-view-after":this.redrawViewAfter.bind(this),clear:this.clear.bind(this),"clear-eol":this.clearEol.bind(this),"clear-eob":this.clearEob.bind(this),put:this.put.bind(this),"modeline-put":this.modelinePut.bind(this),"update-display":this.updateDisplay.bind(this),"move-cursor":this.moveCursor.bind(this),"change-view":this.changeView.bind(this),"resize-display":this.resizeDisplay.bind(this),bulk:this.bulk.bind(this),exit:this.exitEditor.bind(this),"user-input":this.userInput.bind(this),"switch-file":this.switchFile.bind(this),"get-clipboard-text":this.getClipboardText.bind(this),"set-clipboard-text":this.setClipboardText.bind(this),"js-eval":this.jsEval.bind(this)}),this.login(),this.boundedHandleResize=this.handleResize.bind(this)}init(){window.addEventListener("resize",this.boundedHandleResize),document.getElementsByTagName("html")[0].style["background-color"]="#333"}finalize(){window.removeEventListener("resize",this.boundedHandleResize),this.input.finalize()}closeConnection(){this.jsonrpc.close()}emitInput(e){const t=convertKeyEvent(e);if(t){if(t.key==="]"&&t.ctrl&&!t.meta&&!t.super&&!t.shift){this.jsonrpc.notify("input",{kind:"abort"});return}this.jsonrpc.notify("input",{kind:"key",value:t})}}emitInputString(e){e?this.jsonrpc.notify("input",{kind:"input-string",value:e}):console.error("unexpected argument",e)}handleResize(e){this.jsonrpc.notify("redraw",{size:this.getDisplaySize()})}enableInput(){this.inputEnabled=!0}disableInput(){this.inputEnabled=!1}sendNotification(e,t){this.jsonrpc.notify(e,t)}request(e,t,i){this.jsonrpc.request(e,t,i)}getDisplaySize(){const[e,t,i,o]=this.getDisplayRectangle(),n=Math.round(i/this.option.fontWidth),s=Math.round(o/this.option.fontHeight);return{width:n,height:s}}callMessage(e,t){this.messageTable.get(e)(t)}findViewById(e){return this.viewMap.get(e)}login(){this.jsonrpc.request("login",{size:this.getDisplaySize(),foreground:this.option.foreground,background:this.option.background},e=>{if(this.updateForeground(e.foreground),this.updateBackground(e.background),e.views)for(const t of e.views)this.makeView(t);this.jsonrpc.notify("redraw",{size:this.getDisplaySize()}),this.jsonrpc.request("user-file-map",{},t=>{this.onSwitchFile(t)})})}startup(){this.onRestart&&this.onRestart()}updateForeground(e){this.option.foreground=e,this.input.updateForeground(e)}updateBackground(e){this.option.background=e,this.input.updateBackground(e);const t=getLemEditorElement();t.style.backgroundColor=e}makeView({id:e,x:t,y:i,width:o,height:n,use_modeline:s,kind:l,type:c,content:a,border:u}){const h=new View({option:this.option,id:e,x:t,y:i,width:o,height:n,useModeline:s,kind:l,type:c,content:a,border:u,editor:this});this.viewMap.set(e,h)}deleteView({viewInfo:{id:e}}){this.findViewById(e).delete(),this.viewMap.delete(e)}resize({viewInfo:{id:e},width:t,height:i}){this.findViewById(e).resize(t,i)}move({viewInfo:{id:e},x:t,y:i}){this.findViewById(e).move(t,i)}redrawViewAfter({viewInfo:{id:e},html:t}){this.findViewById(e).touch()}clear({viewInfo:{id:e}}){this.findViewById(e).clear()}clearEol({viewInfo:{id:e},x:t,y:i}){this.findViewById(e).clearEol(t,i)}clearEob({viewInfo:{id:e},x:t,y:i}){this.findViewById(e).clearEob(t,i)}put({viewInfo:{id:e},x:t,y:i,text:o,textWidth:n,attribute:s,cursorInfo:l}){const c=this.findViewById(e);if(c.print(t,i,o,n,s),l){const{name:a,color:u}=l;let h=this.cursors.get(a);h||(h=new Cursor(this,a,u),this.cursors.set(a,h)),h.move((c.x+t)*this.option.fontWidth,(c.y+i-1)*this.option.fontHeight)}}modelinePut({viewInfo:{id:e},x:t,y:i,text:o,textWidth:n,attribute:s}){this.findViewById(e).printToModeline(t,i,o,n,s)}updateDisplay(){}moveCursor({viewInfo:{id:e},x:t,y:i}){const o=this.findViewById(e),n=o.x*this.option.fontWidth+t*this.option.fontWidth,s=o.y*this.option.fontHeight+i*this.option.fontHeight;this.input.move(n,s)}changeView({viewInfo:{id:e},type:t,content:i}){const o=this.findViewById(e);switch(t){case"html":o.changeToHTMLContent(i);break;case"editor":o.changeToEditorContent();break}}resizeDisplay({width:e,height:t}){const i=getLemEditorElement();i.style.width=Math.floor(e*this.option.fontWidth)+"px",i.style.height=Math.floor(t*this.option.fontHeight)+"px"}bulk(e){this.onLoaded&&(this.onLoaded(),this.onLoaded=null);for(const{method:t,argument:i}of e)this.callMessage(t,i)}exitEditor(){this.onExit&&this.onExit()}userInput({value:e}){this.onUserInput&&this.onUserInput(e)}switchFile(e){this.onSwitchFile&&this.onSwitchFile(e)}getClipboardText(){navigator.clipboard.readText().then(e=>{this.jsonrpc.notify("got-clipboard-text",{text:e})})}setClipboardText({text:e}){navigator.clipboard&&navigator.clipboard.writeText(e)}jsEval({viewInfo:{id:e},code:t}){this.findViewById(e).evalIn(t)}}const canvas=document.querySelector("#editor");function main(){document.fonts.ready.then(()=>{new Editor({canvas,fontName:"Monospace",fontSize:19,onLoaded:null,url:`ws://${window.location.hostname}:50000`,onExit:null,onClosed:null,onRestart:null,onUserInput:null}).init()})}main(); +(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))i(o);new MutationObserver(o=>{for(const n of o)if(n.type==="childList")for(const s of n.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&i(s)}).observe(document,{childList:!0,subtree:!0});function t(o){const n={};return o.integrity&&(n.integrity=o.integrity),o.referrerPolicy&&(n.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?n.credentials="include":o.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function i(o){if(o.ep)return;o.ep=!0;const n=t(o);fetch(o.href,n)}})();var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},dist={},client={},models={};(function(r){var e=commonjsGlobal&&commonjsGlobal.__extends||function(){var d=function(f,p){return d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,y){m.__proto__=y}||function(m,y){for(var v in y)Object.prototype.hasOwnProperty.call(y,v)&&(m[v]=y[v])},d(f,p)};return function(f,p){if(typeof p!="function"&&p!==null)throw new TypeError("Class extends value "+String(p)+" is not a constructor or null");d(f,p);function m(){this.constructor=f}f.prototype=p===null?Object.create(p):(m.prototype=p.prototype,new m)}}();Object.defineProperty(r,"__esModule",{value:!0}),r.createJSONRPCNotification=r.createJSONRPCRequest=r.createJSONRPCSuccessResponse=r.createJSONRPCErrorResponse=r.JSONRPCErrorCode=r.JSONRPCErrorException=r.isJSONRPCResponses=r.isJSONRPCResponse=r.isJSONRPCRequests=r.isJSONRPCRequest=r.isJSONRPCID=r.JSONRPC=void 0,r.JSONRPC="2.0";var t=function(d){return typeof d=="string"||typeof d=="number"||d===null};r.isJSONRPCID=t;var i=function(d){return d.jsonrpc===r.JSONRPC&&d.method!==void 0&&d.result===void 0&&d.error===void 0};r.isJSONRPCRequest=i;var o=function(d){return Array.isArray(d)&&d.every(r.isJSONRPCRequest)};r.isJSONRPCRequests=o;var n=function(d){return d.jsonrpc===r.JSONRPC&&d.id!==void 0&&(d.result!==void 0||d.error!==void 0)};r.isJSONRPCResponse=n;var s=function(d){return Array.isArray(d)&&d.every(r.isJSONRPCResponse)};r.isJSONRPCResponses=s;var l=function(d,f,p){var m={code:d,message:f};return p!=null&&(m.data=p),m},c=function(d){e(f,d);function f(p,m,y){var v=d.call(this,p)||this;return Object.setPrototypeOf(v,f.prototype),v.code=m,v.data=y,v}return f.prototype.toObject=function(){return l(this.code,this.message,this.data)},f}(Error);r.JSONRPCErrorException=c,function(d){d[d.ParseError=-32700]="ParseError",d[d.InvalidRequest=-32600]="InvalidRequest",d[d.MethodNotFound=-32601]="MethodNotFound",d[d.InvalidParams=-32602]="InvalidParams",d[d.InternalError=-32603]="InternalError"}(r.JSONRPCErrorCode||(r.JSONRPCErrorCode={}));var a=function(d,f,p,m){return{jsonrpc:r.JSONRPC,id:d,error:l(f,p,m)}};r.createJSONRPCErrorResponse=a;var u=function(d,f){return{jsonrpc:r.JSONRPC,id:d,result:f??null}};r.createJSONRPCSuccessResponse=u;var h=function(d,f,p){return{jsonrpc:r.JSONRPC,id:d,method:f,params:p}};r.createJSONRPCRequest=h;var N=function(d,f){return{jsonrpc:r.JSONRPC,method:d,params:f}};r.createJSONRPCNotification=N})(models);var internal={};Object.defineProperty(internal,"__esModule",{value:!0});internal.DefaultErrorCode=void 0;internal.DefaultErrorCode=0;var __awaiter$2=commonjsGlobal&&commonjsGlobal.__awaiter||function(r,e,t,i){function o(n){return n instanceof t?n:new t(function(s){s(n)})}return new(t||(t=Promise))(function(n,s){function l(u){try{a(i.next(u))}catch(h){s(h)}}function c(u){try{a(i.throw(u))}catch(h){s(h)}}function a(u){u.done?n(u.value):o(u.value).then(l,c)}a((i=i.apply(r,e||[])).next())})},__generator$2=commonjsGlobal&&commonjsGlobal.__generator||function(r,e){var t={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},i,o,n,s;return s={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function l(a){return function(u){return c([a,u])}}function c(a){if(i)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(t=0)),t;)try{if(i=1,o&&(n=a[0]&2?o.return:a[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,a[1])).done)return n;switch(o=0,n&&(a=[a[0]&2,n.value]),a[0]){case 0:case 1:n=a;break;case 4:return t.label++,{value:a[1],done:!1};case 5:t.label++,o=a[1],a=[0];continue;case 7:a=t.ops.pop(),t.trys.pop();continue;default:if(n=t.trys,!(n=n.length>0&&n[n.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!n||a[1]>n[0]&&a[1]0&&n[n.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!n||a[1]>n[0]&&a[1]0&&n[n.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!n||a[1]>n[0]&&a[1]{const[t,i,o]=e;this.requestInternal(t,i,o)}),this.messageQueue=[]}request(e,t,i){this.webSocket.readyState===WebSocket.OPEN?this.requestInternal(e,t,i):this.messageQueue.push([e,t,i])}notify(e,t){switch(this.webSocket.readyState){case WebSocket.OPEN:this.serverAndClient.notify(e,t);break}}connect(e){this.closed||(console.log("connect",this.url),this.webSocket=new WebSocket(this.url),this.serverAndClient||(this.serverAndClient=new dist.JSONRPCServerAndClient(new dist.JSONRPCServer,new dist.JSONRPCClient(t=>{try{return this.webSocket.send(JSON.stringify(t)),Promise.resolve()}catch(i){return Promise.reject(i)}}))),this.webSocket.onmessage=t=>{this.serverAndClient.receiveAndSend(JSON.parse(t.data.toString()))},this.webSocket.onopen=()=>{console.log("WebSocket connection established"),this.connectionEstablished=!0,this.onConnected&&this.onConnected(),this.requestMessageQueue()},this.webSocket.onclose=t=>{console.error("WebScoket closed",t),this.serverAndClient.rejectAllPendingRequests(`Connection is closed (${t.reason}).`),this.connectionEstablished&&this.onClosed(),this.timerId=setTimeout(()=>{this.connect()},3e3)},this.webSocket.onerror=t=>{console.error("WebSocket error:",t),this.webSocket.close()})}}const modifierKeys=["Shift","Control","Alt","Meta"],convertKeyTable={Enter:"Return",ArrowRight:"Right",ArrowLeft:"Left",ArrowUp:"Up",ArrowDown:"Down","¡":"1","™":"2","£":"3","¢":"4","∞":"5","§":"6","¶":"7","•":"8",ª:"9",º:"0","–":"-","≠":"=","“":"[","‘":"]","«":"\\","…":";",æ:"'","≤":",","≥":".","÷":"/","⁄":"!","€":"@","‹":"#","›":"$",fi:"%",fl:"^","‡":"&","°":"*","·":"(","‚":")","—":"_","±":"+","”":"{","’":"}","»":"|",Ú:":",Æ:'"',"¯":"<","˘":">","¿":"?",œ:"q","∑":"w","´":"e","®":"r","†":"t","¥":"y","¨":"u","ˆ":"i",ø:"o",π:"p",å:"a",ß:"s","∂":"d",ƒ:"f","©":"g","˙":"h","∆":"j","˚":"k","¬":"l",Ω:"z","≈":"x",ç:"c","√":"v","∫":"b","˜":"n",µ:"m",Œ:"Q","„":"W","´":"E","‰":"R","ˇ":"T",Á:"Y","¨":"U","ˆ":"I",Ø:"O","∏":"P",Å:"A",Í:"S",Î:"D",Ï:"F","˝":"G",Ó:"H",Ô:"J","":"K",Ò:"L","¸":"Z","˛":"X",Ç:"C","◊":"V",ı:"B","˜":"N",Â:"M"};function getKey(r){return r.altKey?convertKeyTable[r.key]||(r.code.startsWith("Key")?r.code[3].toLowerCase():null)||r.key:convertKeyTable[r.key]||r.key}function convertKeyEvent(r){return modifierKeys.indexOf(r.key)!==-1?null:{key:getKey(r),ctrl:r.ctrlKey,meta:r.altKey,super:r.metaKey,shift:r.shiftKey}}var defs=[[0,31,"N"],[32,126,"Na"],[127,160,"N"],[161,161,"A"],[162,163,"Na"],[164,164,"A"],[165,166,"Na"],[167,168,"A"],[169,169,"N"],[170,170,"A"],[171,171,"N"],[172,172,"Na"],[173,174,"A"],[175,175,"Na"],[176,180,"A"],[181,181,"N"],[182,186,"A"],[187,187,"N"],[188,191,"A"],[192,197,"N"],[198,198,"A"],[199,207,"N"],[208,208,"A"],[209,214,"N"],[215,216,"A"],[217,221,"N"],[222,225,"A"],[226,229,"N"],[230,230,"A"],[231,231,"N"],[232,234,"A"],[235,235,"N"],[236,237,"A"],[238,239,"N"],[240,240,"A"],[241,241,"N"],[242,243,"A"],[244,246,"N"],[247,250,"A"],[251,251,"N"],[252,252,"A"],[253,253,"N"],[254,254,"A"],[255,256,"N"],[257,257,"A"],[258,272,"N"],[273,273,"A"],[274,274,"N"],[275,275,"A"],[276,282,"N"],[283,283,"A"],[284,293,"N"],[294,295,"A"],[296,298,"N"],[299,299,"A"],[300,304,"N"],[305,307,"A"],[308,311,"N"],[312,312,"A"],[313,318,"N"],[319,322,"A"],[323,323,"N"],[324,324,"A"],[325,327,"N"],[328,331,"A"],[332,332,"N"],[333,333,"A"],[334,337,"N"],[338,339,"A"],[340,357,"N"],[358,359,"A"],[360,362,"N"],[363,363,"A"],[364,461,"N"],[462,462,"A"],[463,463,"N"],[464,464,"A"],[465,465,"N"],[466,466,"A"],[467,467,"N"],[468,468,"A"],[469,469,"N"],[470,470,"A"],[471,471,"N"],[472,472,"A"],[473,473,"N"],[474,474,"A"],[475,475,"N"],[476,476,"A"],[477,592,"N"],[593,593,"A"],[594,608,"N"],[609,609,"A"],[610,707,"N"],[708,708,"A"],[709,710,"N"],[711,711,"A"],[712,712,"N"],[713,715,"A"],[716,716,"N"],[717,717,"A"],[718,719,"N"],[720,720,"A"],[721,727,"N"],[728,731,"A"],[732,732,"N"],[733,733,"A"],[734,734,"N"],[735,735,"A"],[736,767,"N"],[768,879,"A"],[880,912,"N"],[913,929,"A"],[930,930,"N"],[931,937,"A"],[938,944,"N"],[945,961,"A"],[962,962,"N"],[963,969,"A"],[970,1024,"N"],[1025,1025,"A"],[1026,1039,"N"],[1040,1103,"A"],[1104,1104,"N"],[1105,1105,"A"],[1106,4351,"N"],[4352,4447,"W"],[4448,8207,"N"],[8208,8208,"A"],[8209,8210,"N"],[8211,8214,"A"],[8215,8215,"N"],[8216,8217,"A"],[8218,8219,"N"],[8220,8221,"A"],[8222,8223,"N"],[8224,8226,"A"],[8227,8227,"N"],[8228,8231,"A"],[8232,8239,"N"],[8240,8240,"A"],[8241,8241,"N"],[8242,8243,"A"],[8244,8244,"N"],[8245,8245,"A"],[8246,8250,"N"],[8251,8251,"A"],[8252,8253,"N"],[8254,8254,"A"],[8255,8307,"N"],[8308,8308,"A"],[8309,8318,"N"],[8319,8319,"A"],[8320,8320,"N"],[8321,8324,"A"],[8325,8360,"N"],[8361,8361,"H"],[8362,8363,"N"],[8364,8364,"A"],[8365,8450,"N"],[8451,8451,"A"],[8452,8452,"N"],[8453,8453,"A"],[8454,8456,"N"],[8457,8457,"A"],[8458,8466,"N"],[8467,8467,"A"],[8468,8469,"N"],[8470,8470,"A"],[8471,8480,"N"],[8481,8482,"A"],[8483,8485,"N"],[8486,8486,"A"],[8487,8490,"N"],[8491,8491,"A"],[8492,8530,"N"],[8531,8532,"A"],[8533,8538,"N"],[8539,8542,"A"],[8543,8543,"N"],[8544,8555,"A"],[8556,8559,"N"],[8560,8569,"A"],[8570,8584,"N"],[8585,8585,"A"],[8586,8591,"N"],[8592,8601,"A"],[8602,8631,"N"],[8632,8633,"A"],[8634,8657,"N"],[8658,8658,"A"],[8659,8659,"N"],[8660,8660,"A"],[8661,8678,"N"],[8679,8679,"A"],[8680,8703,"N"],[8704,8704,"A"],[8705,8705,"N"],[8706,8707,"A"],[8708,8710,"N"],[8711,8712,"A"],[8713,8714,"N"],[8715,8715,"A"],[8716,8718,"N"],[8719,8719,"A"],[8720,8720,"N"],[8721,8721,"A"],[8722,8724,"N"],[8725,8725,"A"],[8726,8729,"N"],[8730,8730,"A"],[8731,8732,"N"],[8733,8736,"A"],[8737,8738,"N"],[8739,8739,"A"],[8740,8740,"N"],[8741,8741,"A"],[8742,8742,"N"],[8743,8748,"A"],[8749,8749,"N"],[8750,8750,"A"],[8751,8755,"N"],[8756,8759,"A"],[8760,8763,"N"],[8764,8765,"A"],[8766,8775,"N"],[8776,8776,"A"],[8777,8779,"N"],[8780,8780,"A"],[8781,8785,"N"],[8786,8786,"A"],[8787,8799,"N"],[8800,8801,"A"],[8802,8803,"N"],[8804,8807,"A"],[8808,8809,"N"],[8810,8811,"A"],[8812,8813,"N"],[8814,8815,"A"],[8816,8833,"N"],[8834,8835,"A"],[8836,8837,"N"],[8838,8839,"A"],[8840,8852,"N"],[8853,8853,"A"],[8854,8856,"N"],[8857,8857,"A"],[8858,8868,"N"],[8869,8869,"A"],[8870,8894,"N"],[8895,8895,"A"],[8896,8977,"N"],[8978,8978,"A"],[8979,8985,"N"],[8986,8987,"W"],[8988,9e3,"N"],[9001,9002,"W"],[9003,9192,"N"],[9193,9196,"W"],[9197,9199,"N"],[9200,9200,"W"],[9201,9202,"N"],[9203,9203,"W"],[9204,9311,"N"],[9312,9449,"A"],[9450,9450,"N"],[9451,9547,"A"],[9548,9551,"N"],[9552,9587,"A"],[9588,9599,"N"],[9600,9615,"A"],[9616,9617,"N"],[9618,9621,"A"],[9622,9631,"N"],[9632,9633,"A"],[9634,9634,"N"],[9635,9641,"A"],[9642,9649,"N"],[9650,9651,"A"],[9652,9653,"N"],[9654,9655,"A"],[9656,9659,"N"],[9660,9661,"A"],[9662,9663,"N"],[9664,9665,"A"],[9666,9669,"N"],[9670,9672,"A"],[9673,9674,"N"],[9675,9675,"A"],[9676,9677,"N"],[9678,9681,"A"],[9682,9697,"N"],[9698,9701,"A"],[9702,9710,"N"],[9711,9711,"A"],[9712,9724,"N"],[9725,9726,"W"],[9727,9732,"N"],[9733,9734,"A"],[9735,9736,"N"],[9737,9737,"A"],[9738,9741,"N"],[9742,9743,"A"],[9744,9747,"N"],[9748,9749,"W"],[9750,9755,"N"],[9756,9756,"A"],[9757,9757,"N"],[9758,9758,"A"],[9759,9791,"N"],[9792,9792,"A"],[9793,9793,"N"],[9794,9794,"A"],[9795,9799,"N"],[9800,9811,"W"],[9812,9823,"N"],[9824,9825,"A"],[9826,9826,"N"],[9827,9829,"A"],[9830,9830,"N"],[9831,9834,"A"],[9835,9835,"N"],[9836,9837,"A"],[9838,9838,"N"],[9839,9839,"A"],[9840,9854,"N"],[9855,9855,"W"],[9856,9874,"N"],[9875,9875,"W"],[9876,9885,"N"],[9886,9887,"A"],[9888,9888,"N"],[9889,9889,"W"],[9890,9897,"N"],[9898,9899,"W"],[9900,9916,"N"],[9917,9918,"W"],[9919,9919,"A"],[9920,9923,"N"],[9924,9925,"W"],[9926,9933,"A"],[9934,9934,"W"],[9935,9939,"A"],[9940,9940,"W"],[9941,9953,"A"],[9954,9954,"N"],[9955,9955,"A"],[9956,9959,"N"],[9960,9961,"A"],[9962,9962,"W"],[9963,9969,"A"],[9970,9971,"W"],[9972,9972,"A"],[9973,9973,"W"],[9974,9977,"A"],[9978,9978,"W"],[9979,9980,"A"],[9981,9981,"W"],[9982,9983,"A"],[9984,9988,"N"],[9989,9989,"W"],[9990,9993,"N"],[9994,9995,"W"],[9996,10023,"N"],[10024,10024,"W"],[10025,10044,"N"],[10045,10045,"A"],[10046,10059,"N"],[10060,10060,"W"],[10061,10061,"N"],[10062,10062,"W"],[10063,10066,"N"],[10067,10069,"W"],[10070,10070,"N"],[10071,10071,"W"],[10072,10101,"N"],[10102,10111,"A"],[10112,10132,"N"],[10133,10135,"W"],[10136,10159,"N"],[10160,10160,"W"],[10161,10174,"N"],[10175,10175,"W"],[10176,10213,"N"],[10214,10221,"Na"],[10222,10628,"N"],[10629,10630,"Na"],[10631,11034,"N"],[11035,11036,"W"],[11037,11087,"N"],[11088,11088,"W"],[11089,11092,"N"],[11093,11093,"W"],[11094,11097,"A"],[11098,11903,"N"],[11904,11929,"W"],[11930,11930,"N"],[11931,12019,"W"],[12020,12031,"N"],[12032,12245,"W"],[12246,12271,"N"],[12272,12287,"W"],[12288,12288,"F"],[12289,12350,"W"],[12351,12352,"N"],[12353,12438,"W"],[12439,12440,"N"],[12441,12543,"W"],[12544,12548,"N"],[12549,12591,"W"],[12592,12592,"N"],[12593,12686,"W"],[12687,12687,"N"],[12688,12771,"W"],[12772,12782,"N"],[12783,12830,"W"],[12831,12831,"N"],[12832,12871,"W"],[12872,12879,"A"],[12880,19903,"W"],[19904,19967,"N"],[19968,42124,"W"],[42125,42127,"N"],[42128,42182,"W"],[42183,43359,"N"],[43360,43388,"W"],[43389,44031,"N"],[44032,55203,"W"],[55204,57343,"N"],[57344,63743,"A"],[63744,64255,"W"],[64256,65023,"N"],[65024,65039,"A"],[65040,65049,"W"],[65050,65071,"N"],[65072,65106,"W"],[65107,65107,"N"],[65108,65126,"W"],[65127,65127,"N"],[65128,65131,"W"],[65132,65280,"N"],[65281,65376,"F"],[65377,65470,"H"],[65471,65473,"N"],[65474,65479,"H"],[65480,65481,"N"],[65482,65487,"H"],[65488,65489,"N"],[65490,65495,"H"],[65496,65497,"N"],[65498,65500,"H"],[65501,65503,"N"],[65504,65510,"F"],[65511,65511,"N"],[65512,65518,"H"],[65519,65532,"N"],[65533,65533,"A"],[65534,94175,"N"],[94176,94180,"W"],[94181,94191,"N"],[94192,94193,"W"],[94194,94207,"N"],[94208,100343,"W"],[100344,100351,"N"],[100352,101589,"W"],[101590,101631,"N"],[101632,101640,"W"],[101641,110575,"N"],[110576,110579,"W"],[110580,110580,"N"],[110581,110587,"W"],[110588,110588,"N"],[110589,110590,"W"],[110591,110591,"N"],[110592,110882,"W"],[110883,110897,"N"],[110898,110898,"W"],[110899,110927,"N"],[110928,110930,"W"],[110931,110932,"N"],[110933,110933,"W"],[110934,110947,"N"],[110948,110951,"W"],[110952,110959,"N"],[110960,111355,"W"],[111356,126979,"N"],[126980,126980,"W"],[126981,127182,"N"],[127183,127183,"W"],[127184,127231,"N"],[127232,127242,"A"],[127243,127247,"N"],[127248,127277,"A"],[127278,127279,"N"],[127280,127337,"A"],[127338,127343,"N"],[127344,127373,"A"],[127374,127374,"W"],[127375,127376,"A"],[127377,127386,"W"],[127387,127404,"A"],[127405,127487,"N"],[127488,127490,"W"],[127491,127503,"N"],[127504,127547,"W"],[127548,127551,"N"],[127552,127560,"W"],[127561,127567,"N"],[127568,127569,"W"],[127570,127583,"N"],[127584,127589,"W"],[127590,127743,"N"],[127744,127776,"W"],[127777,127788,"N"],[127789,127797,"W"],[127798,127798,"N"],[127799,127868,"W"],[127869,127869,"N"],[127870,127891,"W"],[127892,127903,"N"],[127904,127946,"W"],[127947,127950,"N"],[127951,127955,"W"],[127956,127967,"N"],[127968,127984,"W"],[127985,127987,"N"],[127988,127988,"W"],[127989,127991,"N"],[127992,128062,"W"],[128063,128063,"N"],[128064,128064,"W"],[128065,128065,"N"],[128066,128252,"W"],[128253,128254,"N"],[128255,128317,"W"],[128318,128330,"N"],[128331,128334,"W"],[128335,128335,"N"],[128336,128359,"W"],[128360,128377,"N"],[128378,128378,"W"],[128379,128404,"N"],[128405,128406,"W"],[128407,128419,"N"],[128420,128420,"W"],[128421,128506,"N"],[128507,128591,"W"],[128592,128639,"N"],[128640,128709,"W"],[128710,128715,"N"],[128716,128716,"W"],[128717,128719,"N"],[128720,128722,"W"],[128723,128724,"N"],[128725,128727,"W"],[128728,128731,"N"],[128732,128735,"W"],[128736,128746,"N"],[128747,128748,"W"],[128749,128755,"N"],[128756,128764,"W"],[128765,128991,"N"],[128992,129003,"W"],[129004,129007,"N"],[129008,129008,"W"],[129009,129291,"N"],[129292,129338,"W"],[129339,129339,"N"],[129340,129349,"W"],[129350,129350,"N"],[129351,129535,"W"],[129536,129647,"N"],[129648,129660,"W"],[129661,129663,"N"],[129664,129672,"W"],[129673,129679,"N"],[129680,129725,"W"],[129726,129726,"N"],[129727,129733,"W"],[129734,129741,"N"],[129742,129755,"W"],[129756,129759,"N"],[129760,129768,"W"],[129769,129775,"N"],[129776,129784,"W"],[129785,131071,"N"],[131072,196605,"W"],[196606,196607,"N"],[196608,262141,"W"],[262142,917759,"N"],[917760,917999,"A"],[918e3,983039,"N"],[983040,1048573,"A"],[1048574,1048575,"N"],[1048576,1114109,"A"],[1114110,1114111,"N"]];function getEAWOfCodePoint(r){let e=0,t=defs.length-1;for(;e!==t;){const i=e+(t-e>>1),[o,n,s]=defs[i];if(rn)e=i+1;else return s}return defs[e][2]}function getEAW(r,e=0){const t=r.codePointAt(e);if(t!==void 0)return getEAWOfCodePoint(t)}const textOffsetY=0;function isWideChar(r){switch(getEAW(r)){case"A":case"F":case"W":return!0;default:return!1}}function isMacOS(){return window.navigator.userAgent.indexOf("Mac OS X")!==-1}function computeFontSize(r){const t=document.createElement("canvas").getContext("2d");t.font=r;const i=t.measureText("W");return[Math.floor(i.width),Math.round(i.fontBoundingBoxAscent+textOffsetY+(i.emHeightDescent||0))]}function drawBlock({ctx:r,x:e,y:t,width:i,height:o,style:n}){r.fillStyle=n,r.fillRect(e,t,i,o)}function drawText({ctx:r,x:e,y:t,text:i,font:o,style:n,option:s}){t+=Math.round(textOffsetY),r.fillStyle=n,r.font=o,r.textBaseline="top";for(const l of i)isWideChar(l)?(r.fillText(l,e,t,s.fontWidth*2),e+=s.fontWidth*2):(r.fillText(l,e,t,s.fontWidth),e+=s.fontWidth)}function drawHorizontalLine({ctx:r,x:e,y:t,width:i,style:o,lineWidth:n=1}){r.strokeStyle=o,r.lineWidth=n,r.setLineDash=[],r.beginPath(),r.moveTo(e,t),r.lineTo(e+i,t),r.stroke()}class Option{constructor({fontName:e,fontSize:t}){const i=t+"px "+e;this.font=i;const[o,n]=computeFontSize(i);this.fontWidth=o,this.fontHeight=n,this.foreground="#333",this.background="#ccc"}}function getLemEditorElement(){return document.getElementById("lem-editor")}class Cursor{constructor(e,t,i){this.editor=e,this.name=t,this.color=i,this.span=document.createElement("span"),this.span.style.all="none",this.span.style.position="absolute",this.span.style.zIndex="",this.span.style.top="0",this.span.style.left="0",this.span.style.fontFamily=e.option.font,this.span.style.backgroundColor=i,this.span.style.color="white",this.span.innerHTML="",document.body.appendChild(this.span),this.timerId=null}move(e,t){const[i,o]=this.editor.getDisplayRectangle();this.span.style.visibility="visible",this.span.textContent=this.name,this.span.style.left=e+i+"px",this.span.style.top=t+o+"px",this.span.style.padding="3px 1%",this.timerId&&clearTimeout(this.timerId),this.timerId=setTimeout(()=>{this.span.style.visibility="hidden"},500)}}function addMouseEventListeners({dom:r,editor:e,isDraggable:t,draggableStyle:i}){r.addEventListener("contextmenu",s=>{s.preventDefault()});const o=(s,l)=>{s.preventDefault();const[c,a]=e.getDisplayRectangle(),u=s.clientX-c,h=s.clientY-a,N=Math.floor(u/e.option.fontWidth),d=Math.floor(h/e.option.fontHeight);e.jsonrpc.notify("input",{kind:l,value:{x:N,y:d,pixelX:u,pixelY:h,button:s.button,clicks:s.detail}})};r.addEventListener("mousedown",s=>{t&&(document.body.style.cursor=i),o(s,"mousedown")}),r.addEventListener("mouseup",s=>{t&&(document.body.style.cursor="default"),o(s,"mouseup")});let n=0;r.addEventListener("mousemove",s=>{s.preventDefault();const l=Date.now();if(l-n>50){n=l;const[c,a]=e.getDisplayRectangle(),u=s.clientX-c,h=s.clientY-a,N=Math.floor(u/e.option.fontWidth),d=Math.floor(h/e.option.fontHeight);e.jsonrpc.notify("input",{kind:"mousemove",value:{x:N,y:d,pixelX:u,pixelY:h,button:s.buttons===0?null:s.buttons-1}})}}),t&&(r.addEventListener("mouseover",()=>{document.body.style.cursor=i}),r.addEventListener("mouseout",s=>{s.buttons!==1&&(document.body.style.cursor="default")})),r.addEventListener("wheel",s=>{s.preventDefault();const[l,c]=e.getDisplayRectangle(),a=s.clientX-l,u=s.clientY-c,h=Math.floor(a/e.option.fontWidth),N=Math.floor(u/e.option.fontHeight);e.jsonrpc.notify("input",{kind:"wheel",value:{pixelX:a,pixelY:u,x:h,y:N,wheelX:-Math.round(s.deltaX*.01),wheelY:-Math.round(s.deltaY*.01)}})})}const borderOffsetX=5,borderOffsetY=10;class BaseSurface{constructor({editor:r}){this.editor=r,this.mainDOM=null,this.wrapper=null}delete(){this.wrapper?getLemEditorElement().removeChild(this.wrapper):getLemEditorElement().removeChild(this.mainDOM)}setupDOM({dom:r,isFloating:e,border:t}){this.mainDOM=r,e&&t?(this.wrapper=document.createElement("div"),this.wrapper.style.position="absolute",this.wrapper.style.padding="10px",this.wrapper.style.border="1px solid",this.wrapper.style.borderColor=this.editor.option.foreground,this.wrapper.style.backgroundColor=this.editor.option.background,this.wrapper.appendChild(r),getLemEditorElement().appendChild(this.wrapper)):getLemEditorElement().appendChild(r)}move(r,e){const[t,i]=this.editor.getDisplayRectangle(),o=Math.floor(t+r*this.editor.option.fontWidth),n=Math.floor(i+e*this.editor.option.fontHeight);this.wrapper?(this.wrapper.style.left=o-borderOffsetX+"px",this.wrapper.style.top=n-borderOffsetY+"px",this.mainDOM.style.left=borderOffsetX+"px",this.mainDOM.style.top=borderOffsetY+"px"):(this.mainDOM.style.left=o+"px",this.mainDOM.style.top=n+"px")}resize(r,e){const t=window.devicePixelRatio||1;this.mainDOM.width=r*this.editor.option.fontWidth*t,this.mainDOM.height=e*this.editor.option.fontHeight*t,this.mainDOM.style.width=r*this.editor.option.fontWidth+"px",this.mainDOM.style.height=e*this.editor.option.fontHeight+"px",this.mainDOM.getContext("2d").scale(t,t),this.wrapper&&(this.wrapper.style.width=r*this.editor.option.fontWidth+borderOffsetX*2+"px",this.wrapper.style.height=e*this.editor.option.fontHeight+borderOffsetY*2+"px")}drawBlock(r,e,t,i,o){}drawText(r,e,t,i,o){}touch(){}evalIn(code){eval(code)}}class CanvasSurface extends BaseSurface{constructor({editor:e,view:t,x:i,y:o,width:n,height:s,styles:l,isFloating:c,border:a}){super({editor:e});const u=this.setupCanvas(l);this.setupDOM({dom:u,isFloating:c,border:a}),this.move(i,o),this.resize(n,s),this.drawingQueue=[],addMouseEventListeners({dom:u,editor:e})}setupCanvas(e){const t=document.createElement("canvas");if(t.style.position="absolute",e)for(let i in e)t.style[i]=e[i];return t}drawBlock(e,t,i,o,n){const s=this.editor.option;this.drawingQueue.push(function(l){drawBlock({ctx:l,x:e*s.fontWidth,y:t*s.fontHeight,width:i*s.fontWidth,height:o*s.fontHeight,style:n})})}drawText(e,t,i,o,n){const s=this.editor.option;this.drawingQueue.push(function(l){if(!n)drawBlock({ctx:l,x:e*s.fontWidth,y:t*s.fontHeight,width:o*s.fontWidth,height:s.fontHeight,style:s.background}),drawText({ctx:l,x:e*s.fontWidth,y:t*s.fontHeight,text:i,style:s.foreground,font:s.font,option:s});else{let{foreground:c,background:a,bold:u,reverse:h,underline:N}=n;if(c||(c=s.foreground),a||(a=s.background),h){const p=a;a=c,c=p}const d=e*s.fontWidth,f=t*s.fontHeight;drawBlock({ctx:l,x:d,y:f,width:o*s.fontWidth,height:s.fontHeight,style:a}),drawText({ctx:l,x:d,y:f,text:i,style:c,font:u?"bold "+s.font:s.font,option:s}),N&&drawHorizontalLine({ctx:l,x:d,y:f+s.fontHeight-2,width:o*s.fontWidth,style:typeof N=="string"?N:c,lineWidth:2})}})}touch(){const e=this.mainDOM.getContext("2d");for(let t of this.drawingQueue)t(e);this.drawingQueue=[]}}class HTMLSurface extends BaseSurface{constructor({editor:e,x:t,y:i,width:o,height:n,styles:s,isFloating:l,border:c,html:a}){super({editor:e});const u=document.createElement("iframe");this.setupDOM({dom:u,isFloating:l,border:c}),u.style.position="absolute",u.style.backgroundColor="white",u.setAttribute("sandbox","allow-scripts allow-same-origin"),u.srcdoc=a,this.iframe=u,this.move(t,i),this.resize(o,n)}update(e){const t=this.iframe.contentWindow.scrollY;this.iframe.srcdoc=e,this.iframe.onload=()=>{this.iframe.onload=null,this.iframe.contentWindow.scrollTo(0,t)}}evalIn(e){this.iframe.contentWindow.eval(e)}}class VerticalBorder{constructor({x:e,y:t,height:i,option:o,editor:n}){this.option=o,this.editor=n,this.line=document.createElement("div"),this.line.style.backgroundColor=o.foreground,this.line.style.width="5px",this.line.style.height=i*o.fontHeight+"px",this.line.style.position="absolute",getLemEditorElement().appendChild(this.line),this.move(e,t),addMouseEventListeners({dom:this.line,editor:n,isDraggable:!0,draggableStyle:"col-resize"})}delete(){this.line.parentNode.removeChild(this.line)}move(e,t){const[i,o]=this.editor.getDisplayRectangle();this.line.style.left=Math.floor(i+e*this.option.fontWidth-this.option.fontWidth/2)+"px",this.line.style.top=o+t*this.option.fontHeight+"px"}resize(e){this.line.style.height=e*this.option.fontHeight+"px"}}const viewStyles={tile:()=>{},floating:r=>({boxSizing:"border-box",borderColor:r.foreground,backgroundColor:r.background})};function getViewStyle(r,e){return viewStyles[r](e)||{}}class View{constructor({id:e,x:t,y:i,width:o,height:n,useModeline:s,kind:l,type:c,content:a,border:u,option:h,editor:N}){switch(this.option=h,this.id=e,this.x=t,this.y=i,this.width=o,this.height=n,this.useModeline=s,this.kind=l,this.type=c,this.border=u,this.editor=N,this.leftsideBar=null,l){case"tile":this.mainSurface=this.makeSurface(c,a),this.leftSideBar=new VerticalBorder({x:t,y:i,height:n+(s?1:0),option:h,editor:N});break;case"floating":this.mainSurface=this.makeSurface(c,a);break}this.modelineSurface=s?this.makeModelineSurface():null}delete(){this.mainSurface.delete(),this.modelineSurface&&this.modelineSurface.delete(),this.leftSideBar&&this.leftSideBar.delete()}move(e,t){this.x=e,this.y=t,this.mainSurface.move(e,t),this.modelineSurface&&this.modelineSurface.move(e,t+this.height),this.leftSideBar&&this.leftSideBar.move(e,t)}resize(e,t){this.width=e,this.height=t,this.mainSurface.resize(e,t),this.modelineSurface&&(this.modelineSurface.move(this.x,this.y+this.height),this.modelineSurface.resize(e,1)),this.leftSideBar&&this.leftSideBar.resize(t+1)}clear(){this.mainSurface.drawBlock(0,0,this.width,this.height,this.option.background)}clearEol(e,t){this.mainSurface.drawBlock(e,t,this.width-e,1,this.option.background)}clearEob(e,t){this.mainSurface.drawBlock(e,t,this.width,this.height-t,this.option.background)}print(e,t,i,o,n){this.mainSurface.drawText(e,t,i,o,n)}printToModeline(e,t,i,o,n){this.modelineSurface&&this.modelineSurface.drawText(e,t,i,o,n)}touch(){this.mainSurface.touch(),this.modelineSurface&&this.modelineSurface.touch()}makeSurface(e,t){switch(e){case"html":return this.makeHTMLSurface(t);case"editor":return this.makeEditorSurface();default:console.error(`unknown type: ${e}`)}}makeHTMLSurface(e){return new HTMLSurface({editor:this.editor,x:this.x,y:this.y,width:this.width,height:this.height,styles:getViewStyle(this.kind,this.option),isFloating:this.kind==="floating",border:this.border,html:e})}makeEditorSurface(){return new CanvasSurface({option:this.editor.option,x:this.x,y:this.y,width:this.width,height:this.height,styles:getViewStyle(this.kind,this.option),editor:this.editor,border:this.border,isFloating:this.kind==="floating",view:this})}makeModelineSurface(){const e=new CanvasSurface({option:this.editor.option,x:this.x,y:this.y+this.height,width:this.width,height:1,editor:this.editor,view:this});return addMouseEventListeners({dom:e.mainDOM,editor:this.editor,isDraggable:!0,draggableStyle:"row-resize"}),e}changeToHTMLContent(e){this.mainSurface.constructor.name==="HTMLSurface"?this.mainSurface.update(e):(this.mainSurface.delete(),this.mainSurface=this.makeHTMLSurface(e))}changeToEditorContent(){this.mainSurface.delete(),this.mainSurface=this.makeEditorSurface()}evalIn(e){this.mainSurface.evalIn(e)}}function isPasteKeyEvent(r){return isMacOS()?!1:r.ctrlKey&&r.shiftKey&&r.key==="V"}class Input{constructor(e){const t=e.option;this.editor=e,this.composition=!1,this.span=document.createElement("span"),this.span.style.color=t.foreground,this.span.style.backgroundColor=t.background,this.span.style.position="absolute",this.span.style.zIndex="",this.span.style.top="0",this.span.style.left="0",this.span.style.font=t.font,this.input=document.createElement("input"),this.input.style.backgroundColor="transparent",this.input.style.color="transparent",this.input.style.width="0",this.input.style.padding="0",this.input.style.margin="0",this.input.style.border="none",this.input.style.position="absolute",this.input.style.zIndex="-10",this.input.style.top="0",this.input.style.left="0",this.input.style.font=t.font,this.input.addEventListener("blur",i=>{this.editor.inputEnabled&&this.input.focus()}),this.input.addEventListener("input",i=>{this.editor.inputEnabled&&this.composition===!1&&(this.input.value="",this.span.innerHTML="",this.input.style.width="0",this.editor.emitInputString(i.data))}),this.input.addEventListener("keydown",i=>{if(this.editor.inputEnabled){if(isPasteKeyEvent(i)){this.editor.jsonrpc.notify("input",{kind:"clipboard-paste"});return}if(i.isComposing||this.composition||i.key==="Process"||!isMacOS()&&!i.ctrlKey&&!i.altKey&&i.key.length===1)return;if(i.preventDefault(),i.isComposing!==!0&&i.code!=="")return this.editor.emitInput(i),this.input.value="",!1}}),this.input.addEventListener("compositionstart",i=>{this.editor.inputEnabled&&(this.composition=!0,this.span.innerHTML=this.input.value,this.input.style.width=this.span.offsetWidth+"px")}),this.input.addEventListener("compositionupdate",i=>{this.editor.inputEnabled&&(this.span.innerHTML=i.data,this.input.style.width=this.span.offsetWidth+"px")}),this.input.addEventListener("compositionend",i=>{this.editor.inputEnabled&&(this.composition=!1,this.editor.emitInputString(this.input.value),this.input.value="",this.span.innerHTML=this.input.value,this.input.style.width="0")}),document.body.appendChild(this.input),document.body.appendChild(this.span),this.input.focus()}finalize(){document.body.removeChild(this.input),document.body.removeChild(this.span)}move(e,t){const[i,o]=this.editor.getDisplayRectangle();this.span.style.top=o+t+"px",this.span.style.left=i+e+"px",this.input.style.top=this.span.offsetTop+"px",this.input.style.left=this.span.offsetLeft+"px"}updateForeground(e){this.span.style.color=e}updateBackground(e){this.span.style.backgroundColor=e}}class MessageTable{constructor(){this.map=new Map}register(e,t){for(const i in t){const o=t[i];this.map.set(i,o),e.on(i,o)}}get(e){return this.map.get(e)}}function getDisplayRectangleDefault(){return[0,0,window.innerWidth,window.innerHeight]}class Editor{constructor({getDisplayRectangle:e=getDisplayRectangleDefault,fontName:t,fontSize:i,onLoaded:o,url:n,onExit:s,onClosed:l,onRestart:c,onUserInput:a,onSwitchFile:u}){this.getDisplayRectangle=e,this.option=new Option({fontName:t,fontSize:i}),this.onExit=s,this.onLoaded=o,this.onRestart=c,this.onUserInput=a,this.onSwitchFile=u,this.inputEnabled=!0,this.input=new Input(this),this.cursors=new Map,this.viewMap=new Map,this.jsonrpc=new JSONRPC(n,{onClosed:()=>{l()}}),this.messageTable=new MessageTable,this.messageTable.register(this.jsonrpc,{startup:this.startup.bind(this),"update-foreground":this.updateForeground.bind(this),"update-background":this.updateBackground.bind(this),"make-view":this.makeView.bind(this),"delete-view":this.deleteView.bind(this),"resize-view":this.resize.bind(this),"move-view":this.move.bind(this),"redraw-view-after":this.redrawViewAfter.bind(this),clear:this.clear.bind(this),"clear-eol":this.clearEol.bind(this),"clear-eob":this.clearEob.bind(this),put:this.put.bind(this),"modeline-put":this.modelinePut.bind(this),"update-display":this.updateDisplay.bind(this),"move-cursor":this.moveCursor.bind(this),"change-view":this.changeView.bind(this),"resize-display":this.resizeDisplay.bind(this),bulk:this.bulk.bind(this),exit:this.exitEditor.bind(this),"user-input":this.userInput.bind(this),"switch-file":this.switchFile.bind(this),"get-clipboard-text":this.getClipboardText.bind(this),"set-clipboard-text":this.setClipboardText.bind(this),"js-eval":this.jsEval.bind(this)}),this.login(),this.boundedHandleResize=this.handleResize.bind(this)}init(){window.addEventListener("resize",this.boundedHandleResize),document.getElementsByTagName("html")[0].style["background-color"]="#333"}finalize(){window.removeEventListener("resize",this.boundedHandleResize),this.input.finalize()}closeConnection(){this.jsonrpc.close()}emitInput(e){const t=convertKeyEvent(e);if(t){if(t.key==="]"&&t.ctrl&&!t.meta&&!t.super&&!t.shift){this.jsonrpc.notify("input",{kind:"abort"});return}this.jsonrpc.notify("input",{kind:"key",value:t})}}emitInputString(e){e?this.jsonrpc.notify("input",{kind:"input-string",value:e}):console.error("unexpected argument",e)}handleResize(e){this.jsonrpc.notify("redraw",{size:this.getDisplaySize()})}enableInput(){this.inputEnabled=!0}disableInput(){this.inputEnabled=!1}sendNotification(e,t){this.jsonrpc.notify(e,t)}request(e,t,i){this.jsonrpc.request(e,t,i)}getDisplaySize(){const[e,t,i,o]=this.getDisplayRectangle(),n=Math.round(i/this.option.fontWidth),s=Math.round(o/this.option.fontHeight);return{width:n,height:s}}callMessage(e,t){this.messageTable.get(e)(t)}findViewById(e){return this.viewMap.get(e)}login(){this.jsonrpc.request("login",{size:this.getDisplaySize(),foreground:this.option.foreground,background:this.option.background},e=>{if(this.updateForeground(e.foreground),this.updateBackground(e.background),e.views)for(const t of e.views)this.makeView(t);this.jsonrpc.notify("redraw",{size:this.getDisplaySize()}),this.jsonrpc.request("user-file-map",{},t=>{this.onSwitchFile(t)})})}startup(){this.onRestart&&this.onRestart()}updateForeground(e){this.option.foreground=e,this.input.updateForeground(e)}updateBackground(e){this.option.background=e,this.input.updateBackground(e);const t=getLemEditorElement();t.style.backgroundColor=e}makeView({id:e,x:t,y:i,width:o,height:n,use_modeline:s,kind:l,type:c,content:a,border:u}){const h=new View({option:this.option,id:e,x:t,y:i,width:o,height:n,useModeline:s,kind:l,type:c,content:a,border:u,editor:this});this.viewMap.set(e,h)}deleteView({viewInfo:{id:e}}){this.findViewById(e).delete(),this.viewMap.delete(e)}resize({viewInfo:{id:e},width:t,height:i}){this.findViewById(e).resize(t,i)}move({viewInfo:{id:e},x:t,y:i}){this.findViewById(e).move(t,i)}redrawViewAfter({viewInfo:{id:e},html:t}){this.findViewById(e).touch()}clear({viewInfo:{id:e}}){this.findViewById(e).clear()}clearEol({viewInfo:{id:e},x:t,y:i}){this.findViewById(e).clearEol(t,i)}clearEob({viewInfo:{id:e},x:t,y:i}){this.findViewById(e).clearEob(t,i)}put({viewInfo:{id:e},x:t,y:i,text:o,textWidth:n,attribute:s,cursorInfo:l}){const c=this.findViewById(e);if(c.print(t,i,o,n,s),l){const{name:a,color:u}=l;let h=this.cursors.get(a);h||(h=new Cursor(this,a,u),this.cursors.set(a,h)),h.move((c.x+t)*this.option.fontWidth,(c.y+i-1)*this.option.fontHeight)}}modelinePut({viewInfo:{id:e},x:t,y:i,text:o,textWidth:n,attribute:s}){this.findViewById(e).printToModeline(t,i,o,n,s)}updateDisplay(){}moveCursor({viewInfo:{id:e},x:t,y:i}){const o=this.findViewById(e),n=o.x*this.option.fontWidth+t*this.option.fontWidth,s=o.y*this.option.fontHeight+i*this.option.fontHeight;this.input.move(n,s)}changeView({viewInfo:{id:e},type:t,content:i}){const o=this.findViewById(e);switch(t){case"html":o.changeToHTMLContent(i);break;case"editor":o.changeToEditorContent();break}}resizeDisplay({width:e,height:t}){const i=getLemEditorElement();i.style.width=Math.floor(e*this.option.fontWidth)+"px",i.style.height=Math.floor(t*this.option.fontHeight)+"px"}bulk(e){this.onLoaded&&(this.onLoaded(),this.onLoaded=null);for(const{method:t,argument:i}of e)this.callMessage(t,i)}exitEditor(){this.onExit&&this.onExit()}userInput({value:e}){this.onUserInput&&this.onUserInput(e)}switchFile(e){this.onSwitchFile&&this.onSwitchFile(e)}getClipboardText(){navigator.clipboard.readText().then(e=>{this.jsonrpc.notify("got-clipboard-text",{text:e})})}setClipboardText({text:e}){navigator.clipboard&&navigator.clipboard.writeText(e)}jsEval({viewInfo:{id:e},code:t}){this.findViewById(e).evalIn(t)}}const canvas=document.querySelector("#editor");function main(){document.fonts.ready.then(()=>{new Editor({canvas,fontName:"Monospace",fontSize:19,onLoaded:null,url:`ws://${window.location.hostname}:50000`,onExit:null,onClosed:null,onRestart:null,onUserInput:null}).init()})}main(); diff --git a/frontends/server/frontend/dist/index.html b/frontends/server/frontend/dist/index.html index 7de459bdc..32653e0f8 100644 --- a/frontends/server/frontend/dist/index.html +++ b/frontends/server/frontend/dist/index.html @@ -15,7 +15,7 @@ } - +
diff --git a/frontends/server/frontend/editor.js b/frontends/server/frontend/editor.js index 0020b065d..68cff2c91 100644 --- a/frontends/server/frontend/editor.js +++ b/frontends/server/frontend/editor.js @@ -31,7 +31,7 @@ function computeFontSize(font) { return [ Math.floor(textMetrics.width), - Math.round(textMetrics.fontBoundingBoxAscent + textOffsetY + 0 /*(textMetrics.emHeightDescent || 0)*/) + Math.round(textMetrics.fontBoundingBoxAscent + textOffsetY + (textMetrics.emHeightDescent || 0)), ]; }