/** * Minified by jsDelivr using Terser v5.37.0. * Original file: /npm/clarinet@0.12.5/clarinet.js * * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files */ !function(e){"use strict";var t="object"==typeof process&&process.env?process.env:self;e.parser=function(e){return new F(e)},e.CParser=F,e.CStream=G,e.createStream=function(e){return new G(e)},e.MAX_BUFFER_LENGTH=65536,e.DEBUG="debug"===t.CDEBUG,e.INFO="debug"===t.CDEBUG||"info"===t.CDEBUG,e.EVENTS=["value","string","key","openobject","closeobject","openarray","closearray","error","end","ready"];var n,r={textNode:void 0,numberNode:""},o=e.EVENTS.filter((function(e){return"error"!==e&&"end"!==e})),i=0;for(var s in e.STATE={BEGIN:i++,VALUE:i++,OPEN_OBJECT:i++,CLOSE_OBJECT:i++,OPEN_ARRAY:i++,CLOSE_ARRAY:i++,TEXT_ESCAPE:i++,STRING:i++,BACKSLASH:i++,END:i++,OPEN_KEY:i++,CLOSE_KEY:i++,TRUE:i++,TRUE2:i++,TRUE3:i++,FALSE:i++,FALSE2:i++,FALSE3:i++,FALSE4:i++,NULL:i++,NULL2:i++,NULL3:i++,NUMBER_DECIMAL_POINT:i++,NUMBER_DIGIT:i++},e.STATE)e.STATE[e.STATE[s]]=s;i=e.STATE;const a=9,c=10,u=13,d=32,h=34,f=43,l=44,E=45,p=46,_=48,b=57,N=58,A=69,L=91,m=92,S=93,C=97,y=98,O=101,g=102,v=108,T=110,U=114,R=115,w=116,B=117,I=123,x=125;function k(e){for(var t in r)e[t]=r[t]}Object.create||(Object.create=function(e){function t(){this.__proto__=e}return t.prototype=e,new t}),Object.getPrototypeOf||(Object.getPrototypeOf=function(e){return e.__proto__}),Object.keys||(Object.keys=function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t});var P=/[\\"\n]/g;function F(t){if(!(this instanceof F))return new F(t);var n=this;k(n),n.bufferCheckPosition=e.MAX_BUFFER_LENGTH,n.q=n.c=n.p="",n.opt=t||{},n.closed=n.closedRoot=n.sawRoot=!1,n.tag=n.error=null,n.state=i.BEGIN,n.stack=new Array,n.position=n.column=0,n.line=1,n.slashed=!1,n.unicodeI=0,n.unicodeS=null,n.depth=0,j(n,"onready")}F.prototype={end:function(){D(this)},write:function(t){var n=this;if(this.error)throw this.error;if(n.closed)return q(n,"Cannot write after close. Assign an onready handler.");if(null===t)return D(n);var o=0,s=t.charCodeAt(0),a=n.p;e.DEBUG&&console.log("write -> ["+t+"]");for(;s&&(a=s,n.c=s=t.charCodeAt(o++),a!==s?n.p=a:a=n.p,s);)switch(e.DEBUG&&console.log(o,s,e.STATE[n.state]),n.position++,s===c?(n.line++,n.column=0):n.column++,n.state){case i.BEGIN:s===I?n.state=i.OPEN_OBJECT:s===L?n.state=i.OPEN_ARRAY:J(s)||q(n,"Non-whitespace before {[.");continue;case i.OPEN_KEY:case i.OPEN_OBJECT:if(J(s))continue;if(n.state===i.OPEN_KEY)n.stack.push(i.CLOSE_KEY);else{if(s===x){j(n,"onopenobject"),this.depth++,j(n,"oncloseobject"),this.depth--,n.state=n.stack.pop()||i.VALUE;continue}n.stack.push(i.CLOSE_OBJECT)}s===h?n.state=i.STRING:q(n,'Malformed object key should start with "');continue;case i.CLOSE_KEY:case i.CLOSE_OBJECT:if(J(s))continue;n.state,i.CLOSE_KEY;s===N?(n.state===i.CLOSE_OBJECT?(n.stack.push(i.CLOSE_OBJECT),Y(n,"onopenobject"),this.depth++):Y(n,"onkey"),n.state=i.VALUE):s===x?(V(n,"oncloseobject"),this.depth--,n.state=n.stack.pop()||i.VALUE):s===l?(n.state===i.CLOSE_OBJECT&&n.stack.push(i.CLOSE_OBJECT),Y(n),n.state=i.OPEN_KEY):q(n,"Bad object");continue;case i.OPEN_ARRAY:case i.VALUE:if(J(s))continue;if(n.state===i.OPEN_ARRAY){if(j(n,"onopenarray"),this.depth++,n.state=i.VALUE,s===S){j(n,"onclosearray"),this.depth--,n.state=n.stack.pop()||i.VALUE;continue}n.stack.push(i.CLOSE_ARRAY)}s===h?n.state=i.STRING:s===I?n.state=i.OPEN_OBJECT:s===L?n.state=i.OPEN_ARRAY:s===w?n.state=i.TRUE:s===g?n.state=i.FALSE:s===T?n.state=i.NULL:s===E?n.numberNode+="-":_<=s&&s<=b?(n.numberNode+=String.fromCharCode(s),n.state=i.NUMBER_DIGIT):q(n,"Bad value");continue;case i.CLOSE_ARRAY:if(s===l)n.stack.push(i.CLOSE_ARRAY),Y(n,"onvalue"),n.state=i.VALUE;else if(s===S)V(n,"onclosearray"),this.depth--,n.state=n.stack.pop()||i.VALUE;else{if(J(s))continue;q(n,"Bad array")}continue;case i.STRING:void 0===n.textNode&&(n.textNode="");var u=o-1,d=n.slashed,k=n.unicodeI;e:for(;;){for(e.DEBUG&&console.log(o,s,e.STATE[n.state],d);k>0;)if(n.unicodeS+=String.fromCharCode(s),s=t.charCodeAt(o++),n.position++,4===k?(n.textNode+=String.fromCharCode(parseInt(n.unicodeS,16)),k=0,u=o-1):k++,!s)break e;if(s===h&&!d){n.state=n.stack.pop()||i.VALUE,n.textNode+=t.substring(u,o-1),n.position+=o-1-u;break}if(s===m&&!d&&(d=!0,n.textNode+=t.substring(u,o-1),n.position+=o-1-u,s=t.charCodeAt(o++),n.position++,!s))break;if(d){if(d=!1,s===T?n.textNode+="\n":s===U?n.textNode+="\r":s===w?n.textNode+="\t":s===g?n.textNode+="\f":s===y?n.textNode+="\b":s===B?(k=1,n.unicodeS=""):n.textNode+=String.fromCharCode(s),s=t.charCodeAt(o++),n.position++,u=o-1,s)continue;break}P.lastIndex=o;var F=P.exec(t);if(null===F){o=t.length+1,n.textNode+=t.substring(u,o-1),n.position+=o-1-u;break}if(o=F.index+1,!(s=t.charCodeAt(F.index))){n.textNode+=t.substring(u,o-1),n.position+=o-1-u;break}}n.slashed=d,n.unicodeI=k;continue;case i.TRUE:s===U?n.state=i.TRUE2:q(n,"Invalid true started with t"+s);continue;case i.TRUE2:s===B?n.state=i.TRUE3:q(n,"Invalid true started with tr"+s);continue;case i.TRUE3:s===O?(j(n,"onvalue",!0),n.state=n.stack.pop()||i.VALUE):q(n,"Invalid true started with tru"+s);continue;case i.FALSE:s===C?n.state=i.FALSE2:q(n,"Invalid false started with f"+s);continue;case i.FALSE2:s===v?n.state=i.FALSE3:q(n,"Invalid false started with fa"+s);continue;case i.FALSE3:s===R?n.state=i.FALSE4:q(n,"Invalid false started with fal"+s);continue;case i.FALSE4:s===O?(j(n,"onvalue",!1),n.state=n.stack.pop()||i.VALUE):q(n,"Invalid false started with fals"+s);continue;case i.NULL:s===B?n.state=i.NULL2:q(n,"Invalid null started with n"+s);continue;case i.NULL2:s===v?n.state=i.NULL3:q(n,"Invalid null started with nu"+s);continue;case i.NULL3:s===v?(j(n,"onvalue",null),n.state=n.stack.pop()||i.VALUE):q(n,"Invalid null started with nul"+s);continue;case i.NUMBER_DECIMAL_POINT:s===p?(n.numberNode+=".",n.state=i.NUMBER_DIGIT):q(n,"Leading zero not followed by .");continue;case i.NUMBER_DIGIT:_<=s&&s<=b?n.numberNode+=String.fromCharCode(s):s===p?(-1!==n.numberNode.indexOf(".")&&q(n,"Invalid number has two dots"),n.numberNode+="."):s===O||s===A?(-1===n.numberNode.indexOf("e")&&-1===n.numberNode.indexOf("E")||q(n,"Invalid number has two exponential"),n.numberNode+="e"):s===f||s===E?(a!==O&&a!==A&&q(n,"Invalid symbol in number"),n.numberNode+=String.fromCharCode(s)):(M(n),o--,n.state=n.stack.pop()||i.VALUE);continue;default:q(n,"Unknown state: "+n.state)}n.position>=n.bufferCheckPosition&&function(t){var n=Math.max(e.MAX_BUFFER_LENGTH,10),o=0;for(var i in r){var s=void 0===t[i]?0:t[i].length;s>n&&("text"===i?closeText(t):q(t,"Max buffer length exceeded: "+i)),o=Math.max(o,s)}t.bufferCheckPosition=e.MAX_BUFFER_LENGTH-o+t.position}(n);return n},resume:function(){return this.error=null,this},close:function(){return this.write(null)}};try{n=require("stream").Stream}catch(e){n=function(){}}function G(e){if(!(this instanceof G))return new G(e);this._parser=new F(e),this.writable=!0,this.readable=!0,this.bytes_remaining=0,this.bytes_in_sequence=0,this.temp_buffs={2:new Buffer(2),3:new Buffer(3),4:new Buffer(4)},this.string="";var t=this;n.apply(t),this._parser.onend=function(){t.emit("end")},this._parser.onerror=function(e){t.emit("error",e),t._parser.error=null},o.forEach((function(e){Object.defineProperty(t,"on"+e,{get:function(){return t._parser["on"+e]},set:function(n){if(!n)return t.removeAllListeners(e),t._parser["on"+e]=n,n;t.on(e,n)},enumerable:!0,configurable:!1})}))}function j(t,n,r){e.INFO&&console.log("-- emit",n,r),t[n]&&t[n](r)}function V(e,t,n){Y(e),j(e,t,n)}function Y(e,t){e.textNode=function(e,t){if(void 0===t)return t;e.trim&&(t=t.trim());e.normalize&&(t=t.replace(/\s+/g," "));return t}(e.opt,e.textNode),void 0!==e.textNode&&j(e,t||"onvalue",e.textNode),e.textNode=void 0}function M(e){e.numberNode&&j(e,"onvalue",parseFloat(e.numberNode)),e.numberNode=""}function q(e,t){return Y(e),t+="\nLine: "+e.line+"\nColumn: "+e.column+"\nChar: "+e.c,t=new Error(t),e.error=t,j(e,"onerror",t),e}function D(e){return e.state===i.VALUE&&0===e.depth||q(e,"Unexpected end"),Y(e),e.c="",e.closed=!0,j(e,"onend"),F.call(e,e.opt),e}function J(e){return e===u||e===c||e===d||e===a}G.prototype=Object.create(n.prototype,{constructor:{value:G}}),G.prototype.write=function(e){e=new Buffer(e);for(var t=0;t0){for(var r=0;r=128){if(n>=194&&n<=223&&(this.bytes_in_sequence=2),n>=224&&n<=239&&(this.bytes_in_sequence=3),n>=240&&n<=244&&(this.bytes_in_sequence=4),this.bytes_in_sequence+t>e.length){for(var o=0;o<=e.length-1-t;o++)this.temp_buffs[this.bytes_in_sequence][o]=e[t+o];return this.bytes_remaining=t+this.bytes_in_sequence-e.length,!0}this.string=e.slice(t,t+this.bytes_in_sequence).toString(),t=t+this.bytes_in_sequence-1,this._parser.write(this.string),this.emit("data",this.string)}else{for(var i=t;i=128);i++);this.string=e.slice(t,i).toString(),this._parser.write(this.string),this.emit("data",this.string),t=i-1}}},G.prototype.end=function(e){return e&&e.length&&this._parser.write(e.toString()),this._parser.end(),!0},G.prototype.on=function(e,t){var r=this;return r._parser["on"+e]||-1===o.indexOf(e)||(r._parser["on"+e]=function(){var t=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);t.splice(0,0,e),r.emit.apply(r,t)}),n.prototype.on.call(r,e,t)},G.prototype.destroy=function(){k(this._parser),this.emit("close")}}("undefined"==typeof exports?clarinet={}:exports); //# sourceMappingURL=/sm/b56266f50ceb7872837113476907f28aa9450ab5eb7dac6f5c821d34dff0793c.map