diff --git a/src/convert.ts b/src/convert.ts index eba716f..659407f 100644 --- a/src/convert.ts +++ b/src/convert.ts @@ -130,8 +130,9 @@ class Analyzer { let index = 1; for (const [key, value] of Object.entries(json)) { + let sanitizeKey = this.sanitizeKey(key); // It is assumed that the key is either in camelCase or snake_case (see https://jsonapi.org/recommendations/). - const formattedKey = this.options.lowerSnakeCaseFieldNames ? key.replace(/([A-Z])/g, "_$1").toLowerCase() : key; + const formattedKey = this.options.lowerSnakeCaseFieldNames ? sanitizeKey.replace(/([A-Z])/g, "_$1").toLowerCase() : sanitizeKey; const typeName = this.analyzeProperty(formattedKey, value, collector, inlineShift) lines.push(` ${typeName} ${formattedKey} = ${index};`); @@ -142,6 +143,32 @@ class Analyzer { return render(collector.getImports(), collector.getMessages(), lines, this.options); } + sanitizeKey(key: string): string { + const keyArray = key.split(""); + let result = ""; + for (const { index, char } of keyArray.map((char, index) => ({ + char, + index, + }))) { + let newChar = char; + if (index === 0 && !char.match(/[a-zA-Z]/)) { + throw new Error( + `Invalid character: '${char}'. The first character must be a letter. Invalid key: "${key}".` + ); + } else if (char === "-") { + newChar = "_"; + } else if (char.match(/[a-zA-Z0-9]/)) newChar = char; + else + throw new Error( + `Invalid character in position ${ + index + 1 + }. The character "${char}" is not allowed. Invalid key: "${key}".` + ); + result += newChar; + } + return result; + } + analyzeArrayProperty(key: string, value: Array, collector: Collector, inlineShift: string): string { // [] -> any const length = value.length; @@ -323,8 +350,9 @@ class Analyzer { let index = 1; for (const [key, value] of Object.entries(source)) { + const sanitizeKey = this.sanitizeKey(key); // It is assumed that the key is either in camelCase or snake_case (see https://jsonapi.org/recommendations/). - const formattedKey = this.options.lowerSnakeCaseFieldNames ? key.replace(/([A-Z])/g, "_$1").toLowerCase() : key; + const formattedKey = this.options.lowerSnakeCaseFieldNames ? sanitizeKey.replace(/([A-Z])/g, "_$1").toLowerCase() : sanitizeKey; const typeName = this.analyzeProperty(formattedKey, value, collector, inlineShift) lines.push(`${inlineShift} ${typeName} ${formattedKey} = ${index};`); diff --git a/src/tests/convert.ts b/src/tests/convert.ts index 9bf3525..5cecf4f 100644 --- a/src/tests/convert.ts +++ b/src/tests/convert.ts @@ -335,5 +335,41 @@ message SomeMessage { } } + { + let json = `{ + "FirstName": "Hanna", + "w12-of": 43.21 +}`; + + assert(json, `syntax = "proto3"; + +message SomeMessage { + string FirstName = 1; + double w12_of = 2; +}`); + } + + t.end(); +}); + +test("convert test exceptions", (t) => { + const options = new Options(true, false, true, false); + function assert(json: string, message: string, overrideOptions?: Options) { + t.equal(convert(json, overrideOptions ?? options).error, message); + } + + { + let json = `{"1": "hello", "2": "world"}`; + assert(json, `Invalid character: '1'. The first character must be a letter. Invalid key: "1".`); + } + + { + let json = `{ + "FirstName": "Hanna", + "12-of": 43.21 +}`; + assert(json, `Invalid character: '1'. The first character must be a letter. Invalid key: "12-of".`); + } + t.end(); }); \ No newline at end of file diff --git a/static/js/app.js b/static/js/app.js index 41513f8..b75f7e5 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -1 +1 @@ -(()=>{var e={416:e=>{function t(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw new Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw new Error("set is read-only")}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach((n=>{const o=e[n],r=typeof o;"object"!==r&&"function"!==r||Object.isFrozen(o)||t(o)})),e}class n{constructor(e){void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function o(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function r(e,...t){const n=Object.create(null);for(const t in e)n[t]=e[t];return t.forEach((function(e){for(const t in e)n[t]=e[t]})),n}const s=e=>!!e.scope;class i{constructor(e,t){this.buffer="",this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=o(e)}openNode(e){if(!s(e))return;const t=((e,{prefix:t})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){const n=e.split(".");return[`${t}${n.shift()}`,...n.map(((e,t)=>`${e}${"_".repeat(t+1)}`))].join(" ")}return`${t}${e}`})(e.scope,{prefix:this.classPrefix});this.span(t)}closeNode(e){s(e)&&(this.buffer+="")}value(){return this.buffer}span(e){this.buffer+=``}}const a=(e={})=>{const t={children:[]};return Object.assign(t,e),t};class c{constructor(){this.rootNode=a(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){const t=a({scope:e});this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){return"string"==typeof t?e.addText(t):t.children&&(e.openNode(t),t.children.forEach((t=>this._walk(e,t))),e.closeNode(t)),e}static _collapse(e){"string"!=typeof e&&e.children&&(e.children.every((e=>"string"==typeof e))?e.children=[e.children.join("")]:e.children.forEach((e=>{c._collapse(e)})))}}class u extends c{constructor(e){super(),this.options=e}addText(e){""!==e&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,t){const n=e.root;t&&(n.scope=`language:${t}`),this.add(n)}toHTML(){return new i(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function l(e){return e?"string"==typeof e?e:e.source:null}function p(e){return f("(?=",e,")")}function g(e){return f("(?:",e,")*")}function h(e){return f("(?:",e,")?")}function f(...e){return e.map((e=>l(e))).join("")}function d(...e){const t=function(e){const t=e[e.length-1];return"object"==typeof t&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}(e);return"("+(t.capture?"":"?:")+e.map((e=>l(e))).join("|")+")"}function b(e){return new RegExp(e.toString()+"|").exec("").length-1}const m=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function _(e,{joinWith:t}){let n=0;return e.map((e=>{n+=1;const t=n;let o=l(e),r="";for(;o.length>0;){const e=m.exec(o);if(!e){r+=o;break}r+=o.substring(0,e.index),o=o.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?r+="\\"+String(Number(e[1])+t):(r+=e[0],"("===e[0]&&n++)}return r})).map((e=>`(${e})`)).join(t)}const y="[a-zA-Z]\\w*",w="[a-zA-Z_]\\w*",E="\\b\\d+(\\.\\d+)?",x="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",v="\\b(0b[01]+)",O={begin:"\\\\[\\s\\S]",relevance:0},k={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[O]},S={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[O]},M=function(e,t,n={}){const o=r({scope:"comment",begin:e,end:t,contains:[]},n);o.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const s=d("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return o.contains.push({begin:f(/[ ]+/,"(",s,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),o},N=M("//","$"),T=M("/\\*","\\*/"),j=M("#","$"),A={scope:"number",begin:E,relevance:0},I={scope:"number",begin:x,relevance:0},R={scope:"number",begin:v,relevance:0},L={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[O,{begin:/\[/,end:/\]/,relevance:0,contains:[O]}]},B={scope:"title",begin:y,relevance:0},P={scope:"title",begin:w,relevance:0},z={begin:"\\.\\s*"+w,relevance:0};var $=Object.freeze({__proto__:null,APOS_STRING_MODE:k,BACKSLASH_ESCAPE:O,BINARY_NUMBER_MODE:R,BINARY_NUMBER_RE:v,COMMENT:M,C_BLOCK_COMMENT_MODE:T,C_LINE_COMMENT_MODE:N,C_NUMBER_MODE:I,C_NUMBER_RE:x,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}})},HASH_COMMENT_MODE:j,IDENT_RE:y,MATCH_NOTHING_RE:/\b\B/,METHOD_GUARD:z,NUMBER_MODE:A,NUMBER_RE:E,PHRASAL_WORDS_MODE:{begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},QUOTE_STRING_MODE:S,REGEXP_MODE:L,RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",SHEBANG:(e={})=>{const t=/^#![ ]*\//;return e.binary&&(e.begin=f(t,/.*\b/,e.binary,/\b.*/)),r({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{0!==e.index&&t.ignoreMatch()}},e)},TITLE_MODE:B,UNDERSCORE_IDENT_RE:w,UNDERSCORE_TITLE_MODE:P});function C(e,t){"."===e.input[e.index-1]&&t.ignoreMatch()}function D(e,t){void 0!==e.className&&(e.scope=e.className,delete e.className)}function H(e,t){t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=C,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,void 0===e.relevance&&(e.relevance=0))}function U(e,t){Array.isArray(e.illegal)&&(e.illegal=d(...e.illegal))}function Z(e,t){if(e.match){if(e.begin||e.end)throw new Error("begin & end are not supported with match");e.begin=e.match,delete e.match}}function G(e,t){void 0===e.relevance&&(e.relevance=1)}const F=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw new Error("beforeMatch cannot be used with starts");const n=Object.assign({},e);Object.keys(e).forEach((t=>{delete e[t]})),e.keywords=n.keywords,e.begin=f(n.beforeMatch,p(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},W=["of","and","for","in","not","or","if","then","parent","list","value"],X="keyword";function K(e,t,n=X){const o=Object.create(null);return"string"==typeof e?r(n,e.split(" ")):Array.isArray(e)?r(n,e):Object.keys(e).forEach((function(n){Object.assign(o,K(e[n],t,n))})),o;function r(e,n){t&&(n=n.map((e=>e.toLowerCase()))),n.forEach((function(t){const n=t.split("|");o[n[0]]=[e,q(n[0],n[1])]}))}}function q(e,t){return t?Number(t):function(e){return W.includes(e.toLowerCase())}(e)?0:1}const J={},Q=e=>{console.error(e)},V=(e,...t)=>{console.log(`WARN: ${e}`,...t)},Y=(e,t)=>{J[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),J[`${e}/${t}`]=!0)},ee=new Error;function te(e,t,{key:n}){let o=0;const r=e[n],s={},i={};for(let e=1;e<=t.length;e++)i[e+o]=r[e],s[e+o]=!0,o+=b(t[e-1]);e[n]=i,e[n]._emit=s,e[n]._multi=!0}function ne(e){!function(e){e.scope&&"object"==typeof e.scope&&null!==e.scope&&(e.beginScope=e.scope,delete e.scope)}(e),"string"==typeof e.beginScope&&(e.beginScope={_wrap:e.beginScope}),"string"==typeof e.endScope&&(e.endScope={_wrap:e.endScope}),function(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw Q("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),ee;if("object"!=typeof e.beginScope||null===e.beginScope)throw Q("beginScope must be object"),ee;te(e,e.begin,{key:"beginScope"}),e.begin=_(e.begin,{joinWith:""})}}(e),function(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw Q("skip, excludeEnd, returnEnd not compatible with endScope: {}"),ee;if("object"!=typeof e.endScope||null===e.endScope)throw Q("endScope must be object"),ee;te(e,e.end,{key:"endScope"}),e.end=_(e.end,{joinWith:""})}}(e)}function oe(e){function t(t,n){return new RegExp(l(t),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(n?"g":""))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,t){t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),this.matchAt+=b(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null);const e=this.regexes.map((e=>e[1]));this.matcherRe=t(_(e,{joinWith:"|"}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;const t=this.matcherRe.exec(e);if(!t)return null;const n=t.findIndex(((e,t)=>t>0&&void 0!==e)),o=this.matchIndexes[n];return t.splice(0,n),Object.assign(t,o)}}class o{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];const t=new n;return this.rules.slice(e).forEach((([e,n])=>t.addRule(e,n))),t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,t){this.rules.push([e,t]),"begin"===t.type&&this.count++}exec(e){const t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex;let n=t.exec(e);if(this.resumingScanAtSamePosition())if(n&&n.index===this.lastIndex);else{const t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)}return n&&(this.regexIndex+=n.position+1,this.regexIndex===this.count&&this.considerAll()),n}}if(e.compilerExtensions||(e.compilerExtensions=[]),e.contains&&e.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=r(e.classNameAliases||{}),function n(s,i){const a=s;if(s.isCompiled)return a;[D,Z,ne,F].forEach((e=>e(s,i))),e.compilerExtensions.forEach((e=>e(s,i))),s.__beforeBegin=null,[H,U,G].forEach((e=>e(s,i))),s.isCompiled=!0;let c=null;return"object"==typeof s.keywords&&s.keywords.$pattern&&(s.keywords=Object.assign({},s.keywords),c=s.keywords.$pattern,delete s.keywords.$pattern),c=c||/\w+/,s.keywords&&(s.keywords=K(s.keywords,e.case_insensitive)),a.keywordPatternRe=t(c,!0),i&&(s.begin||(s.begin=/\B|\b/),a.beginRe=t(a.begin),s.end||s.endsWithParent||(s.end=/\B|\b/),s.end&&(a.endRe=t(a.end)),a.terminatorEnd=l(a.end)||"",s.endsWithParent&&i.terminatorEnd&&(a.terminatorEnd+=(s.end?"|":"")+i.terminatorEnd)),s.illegal&&(a.illegalRe=t(s.illegal)),s.contains||(s.contains=[]),s.contains=[].concat(...s.contains.map((function(e){return function(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((function(t){return r(e,{variants:null},t)}))),e.cachedVariants?e.cachedVariants:re(e)?r(e,{starts:e.starts?r(e.starts):null}):Object.isFrozen(e)?r(e):e}("self"===e?s:e)}))),s.contains.forEach((function(e){n(e,a)})),s.starts&&n(s.starts,i),a.matcher=function(e){const t=new o;return e.contains.forEach((e=>t.addRule(e.begin,{rule:e,type:"begin"}))),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:"end"}),e.illegal&&t.addRule(e.illegal,{type:"illegal"}),t}(a),a}(e)}function re(e){return!!e&&(e.endsWithParent||re(e.starts))}class se extends Error{constructor(e,t){super(e),this.name="HTMLInjectionError",this.html=t}}const ie=o,ae=r,ce=Symbol("nomatch"),ue=function(e){const o=Object.create(null),r=Object.create(null),s=[];let i=!0;const a="Could not find the language '{}', did you forget to load/include a language module?",c={disableAutodetect:!0,name:"Plain text",contains:[]};let l={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:u};function b(e){return l.noHighlightRe.test(e)}function m(e,t,n){let o="",r="";"object"==typeof t?(o=e,n=t.ignoreIllegals,r=t.language):(Y("10.7.0","highlight(lang, code, ...args) has been deprecated."),Y("10.7.0","Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"),r=e,o=t),void 0===n&&(n=!0);const s={code:o,language:r};S("before:highlight",s);const i=s.result?s.result:_(s.language,s.code,n);return i.code=s.code,S("after:highlight",i),i}function _(e,t,r,s){const c=Object.create(null);function u(){if(!S.keywords)return void N.addText(T);let e=0;S.keywordPatternRe.lastIndex=0;let t=S.keywordPatternRe.exec(T),n="";for(;t;){n+=T.substring(e,t.index);const r=x.case_insensitive?t[0].toLowerCase():t[0],s=(o=r,S.keywords[o]);if(s){const[e,o]=s;if(N.addText(n),n="",c[r]=(c[r]||0)+1,c[r]<=7&&(j+=o),e.startsWith("_"))n+=t[0];else{const n=x.classNameAliases[e]||e;g(t[0],n)}}else n+=t[0];e=S.keywordPatternRe.lastIndex,t=S.keywordPatternRe.exec(T)}var o;n+=T.substring(e),N.addText(n)}function p(){null!=S.subLanguage?function(){if(""===T)return;let e=null;if("string"==typeof S.subLanguage){if(!o[S.subLanguage])return void N.addText(T);e=_(S.subLanguage,T,!0,M[S.subLanguage]),M[S.subLanguage]=e._top}else e=y(T,S.subLanguage.length?S.subLanguage:null);S.relevance>0&&(j+=e.relevance),N.__addSublanguage(e._emitter,e.language)}():u(),T=""}function g(e,t){""!==e&&(N.startScope(t),N.addText(e),N.endScope())}function h(e,t){let n=1;const o=t.length-1;for(;n<=o;){if(!e._emit[n]){n++;continue}const o=x.classNameAliases[e[n]]||e[n],r=t[n];o?g(r,o):(T=r,u(),T=""),n++}}function f(e,t){return e.scope&&"string"==typeof e.scope&&N.openNode(x.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(g(T,x.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),T=""):e.beginScope._multi&&(h(e.beginScope,t),T="")),S=Object.create(e,{parent:{value:S}}),S}function d(e,t,o){let r=function(e,t){const n=e&&e.exec(t);return n&&0===n.index}(e.endRe,o);if(r){if(e["on:end"]){const o=new n(e);e["on:end"](t,o),o.isMatchIgnored&&(r=!1)}if(r){for(;e.endsParent&&e.parent;)e=e.parent;return e}}if(e.endsWithParent)return d(e.parent,t,o)}function b(e){return 0===S.matcher.regexIndex?(T+=e[0],1):(R=!0,0)}function m(e){const n=e[0],o=t.substring(e.index),r=d(S,e,o);if(!r)return ce;const s=S;S.endScope&&S.endScope._wrap?(p(),g(n,S.endScope._wrap)):S.endScope&&S.endScope._multi?(p(),h(S.endScope,e)):s.skip?T+=n:(s.returnEnd||s.excludeEnd||(T+=n),p(),s.excludeEnd&&(T=n));do{S.scope&&N.closeNode(),S.skip||S.subLanguage||(j+=S.relevance),S=S.parent}while(S!==r.parent);return r.starts&&f(r.starts,e),s.returnEnd?0:n.length}let w={};function E(o,s){const a=s&&s[0];if(T+=o,null==a)return p(),0;if("begin"===w.type&&"end"===s.type&&w.index===s.index&&""===a){if(T+=t.slice(s.index,s.index+1),!i){const t=new Error(`0 width match regex (${e})`);throw t.languageName=e,t.badRule=w.rule,t}return 1}if(w=s,"begin"===s.type)return function(e){const t=e[0],o=e.rule,r=new n(o),s=[o.__beforeBegin,o["on:begin"]];for(const n of s)if(n&&(n(e,r),r.isMatchIgnored))return b(t);return o.skip?T+=t:(o.excludeBegin&&(T+=t),p(),o.returnBegin||o.excludeBegin||(T=t)),f(o,e),o.returnBegin?0:t.length}(s);if("illegal"===s.type&&!r){const e=new Error('Illegal lexeme "'+a+'" for mode "'+(S.scope||"")+'"');throw e.mode=S,e}if("end"===s.type){const e=m(s);if(e!==ce)return e}if("illegal"===s.type&&""===a)return 1;if(I>1e5&&I>3*s.index)throw new Error("potential infinite loop, way more iterations than matches");return T+=a,a.length}const x=v(e);if(!x)throw Q(a.replace("{}",e)),new Error('Unknown language: "'+e+'"');const O=oe(x);let k="",S=s||O;const M={},N=new l.__emitter(l);!function(){const e=[];for(let t=S;t!==x;t=t.parent)t.scope&&e.unshift(t.scope);e.forEach((e=>N.openNode(e)))}();let T="",j=0,A=0,I=0,R=!1;try{if(x.__emitTokens)x.__emitTokens(t,N);else{for(S.matcher.considerAll();;){I++,R?R=!1:S.matcher.considerAll(),S.matcher.lastIndex=A;const e=S.matcher.exec(t);if(!e)break;const n=E(t.substring(A,e.index),e);A=e.index+n}E(t.substring(A))}return N.finalize(),k=N.toHTML(),{language:e,value:k,relevance:j,illegal:!1,_emitter:N,_top:S}}catch(n){if(n.message&&n.message.includes("Illegal"))return{language:e,value:ie(t),illegal:!0,relevance:0,_illegalBy:{message:n.message,index:A,context:t.slice(A-100,A+100),mode:n.mode,resultSoFar:k},_emitter:N};if(i)return{language:e,value:ie(t),illegal:!1,relevance:0,errorRaised:n,_emitter:N,_top:S};throw n}}function y(e,t){t=t||l.languages||Object.keys(o);const n=function(e){const t={value:ie(e),illegal:!1,relevance:0,_top:c,_emitter:new l.__emitter(l)};return t._emitter.addText(e),t}(e),r=t.filter(v).filter(k).map((t=>_(t,e,!1)));r.unshift(n);const s=r.sort(((e,t)=>{if(e.relevance!==t.relevance)return t.relevance-e.relevance;if(e.language&&t.language){if(v(e.language).supersetOf===t.language)return 1;if(v(t.language).supersetOf===e.language)return-1}return 0})),[i,a]=s,u=i;return u.secondBest=a,u}function w(e){let t=null;const n=function(e){let t=e.className+" ";t+=e.parentNode?e.parentNode.className:"";const n=l.languageDetectRe.exec(t);if(n){const t=v(n[1]);return t||(V(a.replace("{}",n[1])),V("Falling back to no-highlight mode for this block.",e)),t?n[1]:"no-highlight"}return t.split(/\s+/).find((e=>b(e)||v(e)))}(e);if(b(n))return;if(S("before:highlightElement",{el:e,language:n}),e.dataset.highlighted)return void console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e);if(e.children.length>0&&(l.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(e)),l.throwUnescapedHTML))throw new se("One of your code blocks includes unescaped HTML.",e.innerHTML);t=e;const o=t.textContent,s=n?m(o,{language:n,ignoreIllegals:!0}):y(o);e.innerHTML=s.value,e.dataset.highlighted="yes",function(e,t,n){const o=t&&r[t]||n;e.classList.add("hljs"),e.classList.add(`language-${o}`)}(e,n,s.language),e.result={language:s.language,re:s.relevance,relevance:s.relevance},s.secondBest&&(e.secondBest={language:s.secondBest.language,relevance:s.secondBest.relevance}),S("after:highlightElement",{el:e,result:s,text:o})}let E=!1;function x(){"loading"!==document.readyState?document.querySelectorAll(l.cssSelector).forEach(w):E=!0}function v(e){return e=(e||"").toLowerCase(),o[e]||o[r[e]]}function O(e,{languageName:t}){"string"==typeof e&&(e=[e]),e.forEach((e=>{r[e.toLowerCase()]=t}))}function k(e){const t=v(e);return t&&!t.disableAutodetect}function S(e,t){const n=e;s.forEach((function(e){e[n]&&e[n](t)}))}"undefined"!=typeof window&&window.addEventListener&&window.addEventListener("DOMContentLoaded",(function(){E&&x()}),!1),Object.assign(e,{highlight:m,highlightAuto:y,highlightAll:x,highlightElement:w,highlightBlock:function(e){return Y("10.7.0","highlightBlock will be removed entirely in v12.0"),Y("10.7.0","Please use highlightElement now."),w(e)},configure:function(e){l=ae(l,e)},initHighlighting:()=>{x(),Y("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")},initHighlightingOnLoad:function(){x(),Y("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")},registerLanguage:function(t,n){let r=null;try{r=n(e)}catch(e){if(Q("Language definition for '{}' could not be registered.".replace("{}",t)),!i)throw e;Q(e),r=c}r.name||(r.name=t),o[t]=r,r.rawDefinition=n.bind(null,e),r.aliases&&O(r.aliases,{languageName:t})},unregisterLanguage:function(e){delete o[e];for(const t of Object.keys(r))r[t]===e&&delete r[t]},listLanguages:function(){return Object.keys(o)},getLanguage:v,registerAliases:O,autoDetection:k,inherit:ae,addPlugin:function(e){!function(e){e["before:highlightBlock"]&&!e["before:highlightElement"]&&(e["before:highlightElement"]=t=>{e["before:highlightBlock"](Object.assign({block:t.el},t))}),e["after:highlightBlock"]&&!e["after:highlightElement"]&&(e["after:highlightElement"]=t=>{e["after:highlightBlock"](Object.assign({block:t.el},t))})}(e),s.push(e)},removePlugin:function(e){const t=s.indexOf(e);-1!==t&&s.splice(t,1)}}),e.debugMode=function(){i=!1},e.safeMode=function(){i=!0},e.versionString="11.9.0",e.regex={concat:f,lookahead:p,either:d,optional:h,anyNumberOfTimes:g};for(const e in $)"object"==typeof $[e]&&t($[e]);return Object.assign(e,$),e},le=ue({});le.newInstance=()=>ue({}),e.exports=le,le.HighlightJS=le,le.default=le}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var s=t[o]={exports:{}};return e[o](s,s.exports,n),s.exports}(()=>{"use strict";const e=n(416);e.registerLanguage("protobuf",(function(e){const t={match:[/(message|enum|service)\s+/,e.IDENT_RE],scope:{1:"keyword",2:"title.class"}};return{name:"Protocol Buffers",aliases:["proto"],keywords:{keyword:["package","import","option","optional","required","repeated","group","oneof"],type:["double","float","int32","int64","uint32","uint64","sint32","sint64","fixed32","fixed64","sfixed32","sfixed64","bool","string","bytes"],literal:["true","false"]},contains:[e.QUOTE_STRING_MODE,e.NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,t,{className:"function",beginKeywords:"rpc",end:/[{;]/,excludeEnd:!0,keywords:"rpc returns"},{begin:/^\s*[A-Z_]+(?=\s*=[^\n]+;$)/}]}}));const t="google/protobuf/any.proto",o="google.protobuf.Any",r="google.protobuf.Timestamp";class s{constructor(e,t){this.success=e,this.error=t}}class i{constructor(e,t,n){this.name=e,this.complex=t,this.merge=n}}const a=new i("bool",!1,!1),c=new i("string",!1,!1),u=new i("int64",!1,!0),l=new i(o,!0,!1),p=new i(r,!1,!1);class g{constructor(){this.imports=new Set,this.messages=[],this.messageNameSuffixCounter={}}addImport(e){this.imports.add(e)}generateUniqueName(e){if(this.messageNameSuffixCounter.hasOwnProperty(e)){const t=this.messageNameSuffixCounter[e];return this.messageNameSuffixCounter[e]=t+1,`${e}${t}`}return this.messageNameSuffixCounter[e]=1,e}addMessage(e){this.messages.push(e)}getImports(){return this.imports}getMessages(){return this.messages}}class h{constructor(e){this.options=e,this.mergeSimilarObjectMap={}}analyze(e){return this.directType(e)?this.analyzeObject({first:e}):Array.isArray(e)?this.analyzeArray(e):this.analyzeObject(e)}directType(e){switch(typeof e){case"string":case"number":case"boolean":return!0;case"object":return null===e}return!1}analyzeArray(e){const t=this.addShift(),n=new g,o=[],r=this.analyzeArrayProperty("nested",e,n,t);return o.push(` ${r} items = 1;`),d(n.getImports(),n.getMessages(),o,this.options)}analyzeObject(e){const t=this.addShift(),n=new g,o=[];let r=1;for(const[s,i]of Object.entries(e)){const e=this.options.lowerSnakeCaseFieldNames?s.replace(/([A-Z])/g,"_$1").toLowerCase():s,a=this.analyzeProperty(e,i,n,t);o.push(` ${a} ${e} = ${r};`),r+=1}return d(n.getImports(),n.getMessages(),o,this.options)}analyzeArrayProperty(e,n,r,s){const i=n.length;if(0===i)return r.addImport(t),`repeated ${o}`;const a=n[0];if(Array.isArray(a))return r.addImport(t),`repeated ${o}`;if(i>1){const e=this.samePrimitiveType(n);if(!1===e.complex)return`repeated ${e.name}`}return`repeated ${this.analyzeObjectProperty(e,a,r,s)}`}analyzeProperty(e,t,n,o){return Array.isArray(t)?this.analyzeArrayProperty(e,t,n,o):this.analyzeObjectProperty(e,t,n,o)}analyzeObjectProperty(e,t,n,o){const r=this.analyzeType(t,n);if("object"===r){if(this.options.mergeSimilarObjects){const[r,s]=this.mergeSimilarObjectKey(t);if(s){if(this.mergeSimilarObjectMap.hasOwnProperty(r))return this.mergeSimilarObjectMap[r];const s=n.generateUniqueName(f(e));return this.mergeSimilarObjectMap[r]=s,this.addNested(n,s,t,o),s}}const r=n.generateUniqueName(f(e));return this.addNested(n,r,t,o),r}return r}mergeSimilarObjectKey(e){const t=[];for(const[n,o]of Object.entries(e)){const[e,r]=this.mergeSimilarObjectType(o);if(!r)return["",!1];t.push([n,e])}return[JSON.stringify(t),!0]}mergeSimilarObjectType(e){if(Array.isArray(e))return["",!1];switch(typeof e){case"string":return this.options.googleProtobufTimestamp&&/\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(\+\d\d:\d\d|Z)/.test(e)?[r,!0]:["string",!0];case"number":return[m(e),!0];case"boolean":return["bool",!0]}return["",!1]}analyzeType(e,n){switch(typeof e){case"string":return this.options.googleProtobufTimestamp&&/\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(\+\d\d:\d\d|Z)/.test(e)?(n.addImport("google/protobuf/timestamp.proto"),r):"string";case"number":return m(e);case"boolean":return"bool";case"object":return null===e?(n.addImport(t),o):"object"}return n.addImport(t),o}toPrimitiveType(e){switch(typeof e){case"string":return this.options.googleProtobufTimestamp&&/\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(\+\d\d:\d\d|Z)/.test(e)?p:c;case"number":return new i(m(e),!1,!0);case"boolean":return a}return l}samePrimitiveType(e){let t=this.toPrimitiveType(e[0]);if(t.complex)return t;for(let n=1;n0){r.push("");for(const t of e)r.push(`import "${t}";`)}if(r.push(""),o.inline){if(r.push("message SomeMessage {"),t.length>0){r.push("");for(const e of t)r.push(...e),r.push("")}r.push(...n),r.push("}")}else{for(const e of t)r.push(...e),r.push("");r.push("message SomeMessage {"),r.push(...n),r.push("}")}return r.join("\n")}function b(e,t){if(e.name===t.name)return e;if(e.merge&&t.merge){if("double"===e.name)return e;if("double"===t.name)return t;if("int64"===e.name)return e;if("int64"===t.name)return t;if("uint64"===e.name){if("uint32"===t.name)return e}else if("uint64"===t.name&&"uint32"===e.name)return t;return u}return l}function m(e){return e%1==0?e<0?e<-2147483648?"int64":"int32":e>4294967295?"uint64":"uint32":"double"}const _=document.getElementById("input"),y=document.getElementById("output"),w=document.getElementById("sample"),E=document.getElementById("inline"),x=document.getElementById("google.protobuf.Timestamp"),v=document.getElementById("merge-similar-objects"),O=document.getElementById("lower-snake-case-field-names"),k=document.getElementById("copy-to-clipboard"),S=new class{constructor(e,t,n,o){this.inline=e,this.googleProtobufTimestamp=t,this.mergeSimilarObjects=n,this.lowerSnakeCaseFieldNames=o}}(E.checked,x.checked,v.checked,O.checked);function M(){const t=function(e,t){if(""===e)return new s("","");const n=e.replace(/\.0/g,".1");try{const e=JSON.parse(n),o=new h(t);return new s(o.analyze(e),"")}catch(e){return new s("",e.message)}}(_.innerText.trim(),S);var n;t.success?y.innerHTML=(n=t.success,e.highlight(n,{language:"protobuf"}).value):y.innerHTML=t.error}_.addEventListener("keyup",M),E.addEventListener("change",(function(){S.inline=E.checked,M()})),x.addEventListener("change",(function(){S.googleProtobufTimestamp=x.checked,M()})),v.addEventListener("change",(function(){S.mergeSimilarObjects=v.checked,M()})),O.addEventListener("change",(function(){S.lowerSnakeCaseFieldNames=O.checked,M()})),w.addEventListener("click",(function(){_.innerHTML=N,M()})),k.addEventListener("click",(function(){navigator.clipboard.writeText(y.innerText)}));const N='{\n "id": 23357588,\n "node_id": "MDEwOlJlcG9zaXRvcnkyMzM1NzU4OA==",\n "name": "protobuf",\n "full_name": "protocolbuffers/protobuf",\n "private": false,\n "owner": {\n "login": "protocolbuffers",\n "id": 26310541,\n "node_id": "MDEyOk9yZ2FuaXphdGlvbjI2MzEwNTQx",\n "avatar_url": "https://avatars1.githubusercontent.com/u/26310541?v=4",\n "gravatar_id": "",\n "url": "https://api.github.com/users/protocolbuffers",\n "html_url": "https://github.com/protocolbuffers",\n "followers_url": "https://api.github.com/users/protocolbuffers/followers",\n "following_url": "https://api.github.com/users/protocolbuffers/following{/other_user}",\n "gists_url": "https://api.github.com/users/protocolbuffers/gists{/gist_id}",\n "starred_url": "https://api.github.com/users/protocolbuffers/starred{/owner}{/repo}",\n "subscriptions_url": "https://api.github.com/users/protocolbuffers/subscriptions",\n "organizations_url": "https://api.github.com/users/protocolbuffers/orgs",\n "repos_url": "https://api.github.com/users/protocolbuffers/repos",\n "events_url": "https://api.github.com/users/protocolbuffers/events{/privacy}",\n "received_events_url": "https://api.github.com/users/protocolbuffers/received_events",\n "type": "Organization",\n "site_admin": false\n },\n "html_url": "https://github.com/protocolbuffers/protobuf",\n "description": "Protocol Buffers - Google\'s data interchange format",\n "fork": false,\n "url": "https://api.github.com/repos/protocolbuffers/protobuf",\n "forks_url": "https://api.github.com/repos/protocolbuffers/protobuf/forks",\n "keys_url": "https://api.github.com/repos/protocolbuffers/protobuf/keys{/key_id}",\n "collaborators_url": "https://api.github.com/repos/protocolbuffers/protobuf/collaborators{/collaborator}",\n "teams_url": "https://api.github.com/repos/protocolbuffers/protobuf/teams",\n "hooks_url": "https://api.github.com/repos/protocolbuffers/protobuf/hooks",\n "issue_events_url": "https://api.github.com/repos/protocolbuffers/protobuf/issues/events{/number}",\n "events_url": "https://api.github.com/repos/protocolbuffers/protobuf/events",\n "assignees_url": "https://api.github.com/repos/protocolbuffers/protobuf/assignees{/user}",\n "branches_url": "https://api.github.com/repos/protocolbuffers/protobuf/branches{/branch}",\n "tags_url": "https://api.github.com/repos/protocolbuffers/protobuf/tags",\n "blobs_url": "https://api.github.com/repos/protocolbuffers/protobuf/git/blobs{/sha}",\n "git_tags_url": "https://api.github.com/repos/protocolbuffers/protobuf/git/tags{/sha}",\n "git_refs_url": "https://api.github.com/repos/protocolbuffers/protobuf/git/refs{/sha}",\n "trees_url": "https://api.github.com/repos/protocolbuffers/protobuf/git/trees{/sha}",\n "statuses_url": "https://api.github.com/repos/protocolbuffers/protobuf/statuses/{sha}",\n "languages_url": "https://api.github.com/repos/protocolbuffers/protobuf/languages",\n "stargazers_url": "https://api.github.com/repos/protocolbuffers/protobuf/stargazers",\n "contributors_url": "https://api.github.com/repos/protocolbuffers/protobuf/contributors",\n "subscribers_url": "https://api.github.com/repos/protocolbuffers/protobuf/subscribers",\n "subscription_url": "https://api.github.com/repos/protocolbuffers/protobuf/subscription",\n "commits_url": "https://api.github.com/repos/protocolbuffers/protobuf/commits{/sha}",\n "git_commits_url": "https://api.github.com/repos/protocolbuffers/protobuf/git/commits{/sha}",\n "comments_url": "https://api.github.com/repos/protocolbuffers/protobuf/comments{/number}",\n "issue_comment_url": "https://api.github.com/repos/protocolbuffers/protobuf/issues/comments{/number}",\n "contents_url": "https://api.github.com/repos/protocolbuffers/protobuf/contents/{+path}",\n "compare_url": "https://api.github.com/repos/protocolbuffers/protobuf/compare/{base}...{head}",\n "merges_url": "https://api.github.com/repos/protocolbuffers/protobuf/merges",\n "archive_url": "https://api.github.com/repos/protocolbuffers/protobuf/{archive_format}{/ref}",\n "downloads_url": "https://api.github.com/repos/protocolbuffers/protobuf/downloads",\n "issues_url": "https://api.github.com/repos/protocolbuffers/protobuf/issues{/number}",\n "pulls_url": "https://api.github.com/repos/protocolbuffers/protobuf/pulls{/number}",\n "milestones_url": "https://api.github.com/repos/protocolbuffers/protobuf/milestones{/number}",\n "notifications_url": "https://api.github.com/repos/protocolbuffers/protobuf/notifications{?since,all,participating}",\n "labels_url": "https://api.github.com/repos/protocolbuffers/protobuf/labels{/name}",\n "releases_url": "https://api.github.com/repos/protocolbuffers/protobuf/releases{/id}",\n "deployments_url": "https://api.github.com/repos/protocolbuffers/protobuf/deployments",\n "created_at": "2014-08-26T15:52:15Z",\n "updated_at": "2020-04-21T23:33:50Z",\n "pushed_at": "2020-04-22T00:06:06Z",\n "git_url": "git://github.com/protocolbuffers/protobuf.git",\n "ssh_url": "git@github.com:protocolbuffers/protobuf.git",\n "clone_url": "https://github.com/protocolbuffers/protobuf.git",\n "svn_url": "https://github.com/protocolbuffers/protobuf",\n "homepage": "https://developers.google.com/protocol-buffers/",\n "size": 60901,\n "stargazers_count": 41099,\n "watchers_count": 41099,\n "language": "C++",\n "has_issues": true,\n "has_projects": true,\n "has_downloads": true,\n "has_wiki": true,\n "has_pages": true,\n "forks_count": 11124,\n "mirror_url": null,\n "archived": false,\n "disabled": false,\n "open_issues_count": 1009,\n "license": {\n "key": "other",\n "name": "Other",\n "spdx_id": "NOASSERTION",\n "url": null,\n "node_id": "MDc6TGljZW5zZTA="\n },\n "forks": 11124,\n "open_issues": 1009,\n "watchers": 41099,\n "default_branch": "master",\n "temp_clone_token": null,\n "organization": {\n "login": "protocolbuffers",\n "id": 26310541,\n "node_id": "MDEyOk9yZ2FuaXphdGlvbjI2MzEwNTQx",\n "avatar_url": "https://avatars1.githubusercontent.com/u/26310541?v=4",\n "gravatar_id": "",\n "url": "https://api.github.com/users/protocolbuffers",\n "html_url": "https://github.com/protocolbuffers",\n "followers_url": "https://api.github.com/users/protocolbuffers/followers",\n "following_url": "https://api.github.com/users/protocolbuffers/following{/other_user}",\n "gists_url": "https://api.github.com/users/protocolbuffers/gists{/gist_id}",\n "starred_url": "https://api.github.com/users/protocolbuffers/starred{/owner}{/repo}",\n "subscriptions_url": "https://api.github.com/users/protocolbuffers/subscriptions",\n "organizations_url": "https://api.github.com/users/protocolbuffers/orgs",\n "repos_url": "https://api.github.com/users/protocolbuffers/repos",\n "events_url": "https://api.github.com/users/protocolbuffers/events{/privacy}",\n "received_events_url": "https://api.github.com/users/protocolbuffers/received_events",\n "type": "Organization",\n "site_admin": false\n },\n "network_count": 11124,\n "subscribers_count": 2059\n}'})()})(); \ No newline at end of file +(()=>{var e={416:e=>{function t(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw new Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw new Error("set is read-only")}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach((n=>{const o=e[n],r=typeof o;"object"!==r&&"function"!==r||Object.isFrozen(o)||t(o)})),e}class n{constructor(e){void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function o(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function r(e,...t){const n=Object.create(null);for(const t in e)n[t]=e[t];return t.forEach((function(e){for(const t in e)n[t]=e[t]})),n}const s=e=>!!e.scope;class i{constructor(e,t){this.buffer="",this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=o(e)}openNode(e){if(!s(e))return;const t=((e,{prefix:t})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){const n=e.split(".");return[`${t}${n.shift()}`,...n.map(((e,t)=>`${e}${"_".repeat(t+1)}`))].join(" ")}return`${t}${e}`})(e.scope,{prefix:this.classPrefix});this.span(t)}closeNode(e){s(e)&&(this.buffer+="")}value(){return this.buffer}span(e){this.buffer+=``}}const a=(e={})=>{const t={children:[]};return Object.assign(t,e),t};class c{constructor(){this.rootNode=a(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){const t=a({scope:e});this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){return"string"==typeof t?e.addText(t):t.children&&(e.openNode(t),t.children.forEach((t=>this._walk(e,t))),e.closeNode(t)),e}static _collapse(e){"string"!=typeof e&&e.children&&(e.children.every((e=>"string"==typeof e))?e.children=[e.children.join("")]:e.children.forEach((e=>{c._collapse(e)})))}}class u extends c{constructor(e){super(),this.options=e}addText(e){""!==e&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,t){const n=e.root;t&&(n.scope=`language:${t}`),this.add(n)}toHTML(){return new i(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function l(e){return e?"string"==typeof e?e:e.source:null}function p(e){return f("(?=",e,")")}function g(e){return f("(?:",e,")*")}function h(e){return f("(?:",e,")?")}function f(...e){return e.map((e=>l(e))).join("")}function d(...e){const t=function(e){const t=e[e.length-1];return"object"==typeof t&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}(e);return"("+(t.capture?"":"?:")+e.map((e=>l(e))).join("|")+")"}function b(e){return new RegExp(e.toString()+"|").exec("").length-1}const m=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function _(e,{joinWith:t}){let n=0;return e.map((e=>{n+=1;const t=n;let o=l(e),r="";for(;o.length>0;){const e=m.exec(o);if(!e){r+=o;break}r+=o.substring(0,e.index),o=o.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?r+="\\"+String(Number(e[1])+t):(r+=e[0],"("===e[0]&&n++)}return r})).map((e=>`(${e})`)).join(t)}const y="[a-zA-Z]\\w*",w="[a-zA-Z_]\\w*",E="\\b\\d+(\\.\\d+)?",x="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",v="\\b(0b[01]+)",O={begin:"\\\\[\\s\\S]",relevance:0},k={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[O]},S={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[O]},M=function(e,t,n={}){const o=r({scope:"comment",begin:e,end:t,contains:[]},n);o.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const s=d("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return o.contains.push({begin:f(/[ ]+/,"(",s,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),o},N=M("//","$"),T=M("/\\*","\\*/"),j=M("#","$"),A={scope:"number",begin:E,relevance:0},I={scope:"number",begin:x,relevance:0},R={scope:"number",begin:v,relevance:0},L={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[O,{begin:/\[/,end:/\]/,relevance:0,contains:[O]}]},B={scope:"title",begin:y,relevance:0},z={scope:"title",begin:w,relevance:0},P={begin:"\\.\\s*"+w,relevance:0};var $=Object.freeze({__proto__:null,APOS_STRING_MODE:k,BACKSLASH_ESCAPE:O,BINARY_NUMBER_MODE:R,BINARY_NUMBER_RE:v,COMMENT:M,C_BLOCK_COMMENT_MODE:T,C_LINE_COMMENT_MODE:N,C_NUMBER_MODE:I,C_NUMBER_RE:x,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}})},HASH_COMMENT_MODE:j,IDENT_RE:y,MATCH_NOTHING_RE:/\b\B/,METHOD_GUARD:P,NUMBER_MODE:A,NUMBER_RE:E,PHRASAL_WORDS_MODE:{begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},QUOTE_STRING_MODE:S,REGEXP_MODE:L,RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",SHEBANG:(e={})=>{const t=/^#![ ]*\//;return e.binary&&(e.begin=f(t,/.*\b/,e.binary,/\b.*/)),r({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{0!==e.index&&t.ignoreMatch()}},e)},TITLE_MODE:B,UNDERSCORE_IDENT_RE:w,UNDERSCORE_TITLE_MODE:z});function C(e,t){"."===e.input[e.index-1]&&t.ignoreMatch()}function D(e,t){void 0!==e.className&&(e.scope=e.className,delete e.className)}function H(e,t){t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=C,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,void 0===e.relevance&&(e.relevance=0))}function U(e,t){Array.isArray(e.illegal)&&(e.illegal=d(...e.illegal))}function Z(e,t){if(e.match){if(e.begin||e.end)throw new Error("begin & end are not supported with match");e.begin=e.match,delete e.match}}function G(e,t){void 0===e.relevance&&(e.relevance=1)}const K=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw new Error("beforeMatch cannot be used with starts");const n=Object.assign({},e);Object.keys(e).forEach((t=>{delete e[t]})),e.keywords=n.keywords,e.begin=f(n.beforeMatch,p(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},F=["of","and","for","in","not","or","if","then","parent","list","value"];function W(e,t,n="keyword"){const o=Object.create(null);return"string"==typeof e?r(n,e.split(" ")):Array.isArray(e)?r(n,e):Object.keys(e).forEach((function(n){Object.assign(o,W(e[n],t,n))})),o;function r(e,n){t&&(n=n.map((e=>e.toLowerCase()))),n.forEach((function(t){const n=t.split("|");o[n[0]]=[e,X(n[0],n[1])]}))}}function X(e,t){return t?Number(t):function(e){return F.includes(e.toLowerCase())}(e)?0:1}const q={},J=e=>{console.error(e)},Q=(e,...t)=>{console.log(`WARN: ${e}`,...t)},V=(e,t)=>{q[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),q[`${e}/${t}`]=!0)},Y=new Error;function ee(e,t,{key:n}){let o=0;const r=e[n],s={},i={};for(let e=1;e<=t.length;e++)i[e+o]=r[e],s[e+o]=!0,o+=b(t[e-1]);e[n]=i,e[n]._emit=s,e[n]._multi=!0}function te(e){!function(e){e.scope&&"object"==typeof e.scope&&null!==e.scope&&(e.beginScope=e.scope,delete e.scope)}(e),"string"==typeof e.beginScope&&(e.beginScope={_wrap:e.beginScope}),"string"==typeof e.endScope&&(e.endScope={_wrap:e.endScope}),function(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw J("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Y;if("object"!=typeof e.beginScope||null===e.beginScope)throw J("beginScope must be object"),Y;ee(e,e.begin,{key:"beginScope"}),e.begin=_(e.begin,{joinWith:""})}}(e),function(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw J("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Y;if("object"!=typeof e.endScope||null===e.endScope)throw J("endScope must be object"),Y;ee(e,e.end,{key:"endScope"}),e.end=_(e.end,{joinWith:""})}}(e)}function ne(e){function t(t,n){return new RegExp(l(t),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(n?"g":""))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,t){t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),this.matchAt+=b(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null);const e=this.regexes.map((e=>e[1]));this.matcherRe=t(_(e,{joinWith:"|"}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;const t=this.matcherRe.exec(e);if(!t)return null;const n=t.findIndex(((e,t)=>t>0&&void 0!==e)),o=this.matchIndexes[n];return t.splice(0,n),Object.assign(t,o)}}class o{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];const t=new n;return this.rules.slice(e).forEach((([e,n])=>t.addRule(e,n))),t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,t){this.rules.push([e,t]),"begin"===t.type&&this.count++}exec(e){const t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex;let n=t.exec(e);if(this.resumingScanAtSamePosition())if(n&&n.index===this.lastIndex);else{const t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)}return n&&(this.regexIndex+=n.position+1,this.regexIndex===this.count&&this.considerAll()),n}}if(e.compilerExtensions||(e.compilerExtensions=[]),e.contains&&e.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=r(e.classNameAliases||{}),function n(s,i){const a=s;if(s.isCompiled)return a;[D,Z,te,K].forEach((e=>e(s,i))),e.compilerExtensions.forEach((e=>e(s,i))),s.__beforeBegin=null,[H,U,G].forEach((e=>e(s,i))),s.isCompiled=!0;let c=null;return"object"==typeof s.keywords&&s.keywords.$pattern&&(s.keywords=Object.assign({},s.keywords),c=s.keywords.$pattern,delete s.keywords.$pattern),c=c||/\w+/,s.keywords&&(s.keywords=W(s.keywords,e.case_insensitive)),a.keywordPatternRe=t(c,!0),i&&(s.begin||(s.begin=/\B|\b/),a.beginRe=t(a.begin),s.end||s.endsWithParent||(s.end=/\B|\b/),s.end&&(a.endRe=t(a.end)),a.terminatorEnd=l(a.end)||"",s.endsWithParent&&i.terminatorEnd&&(a.terminatorEnd+=(s.end?"|":"")+i.terminatorEnd)),s.illegal&&(a.illegalRe=t(s.illegal)),s.contains||(s.contains=[]),s.contains=[].concat(...s.contains.map((function(e){return function(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((function(t){return r(e,{variants:null},t)}))),e.cachedVariants?e.cachedVariants:oe(e)?r(e,{starts:e.starts?r(e.starts):null}):Object.isFrozen(e)?r(e):e}("self"===e?s:e)}))),s.contains.forEach((function(e){n(e,a)})),s.starts&&n(s.starts,i),a.matcher=function(e){const t=new o;return e.contains.forEach((e=>t.addRule(e.begin,{rule:e,type:"begin"}))),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:"end"}),e.illegal&&t.addRule(e.illegal,{type:"illegal"}),t}(a),a}(e)}function oe(e){return!!e&&(e.endsWithParent||oe(e.starts))}class re extends Error{constructor(e,t){super(e),this.name="HTMLInjectionError",this.html=t}}const se=o,ie=r,ae=Symbol("nomatch"),ce=function(e){const o=Object.create(null),r=Object.create(null),s=[];let i=!0;const a="Could not find the language '{}', did you forget to load/include a language module?",c={disableAutodetect:!0,name:"Plain text",contains:[]};let l={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:u};function b(e){return l.noHighlightRe.test(e)}function m(e,t,n){let o="",r="";"object"==typeof t?(o=e,n=t.ignoreIllegals,r=t.language):(V("10.7.0","highlight(lang, code, ...args) has been deprecated."),V("10.7.0","Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"),r=e,o=t),void 0===n&&(n=!0);const s={code:o,language:r};S("before:highlight",s);const i=s.result?s.result:_(s.language,s.code,n);return i.code=s.code,S("after:highlight",i),i}function _(e,t,r,s){const c=Object.create(null);function u(){if(!S.keywords)return void N.addText(T);let e=0;S.keywordPatternRe.lastIndex=0;let t=S.keywordPatternRe.exec(T),n="";for(;t;){n+=T.substring(e,t.index);const r=x.case_insensitive?t[0].toLowerCase():t[0],s=(o=r,S.keywords[o]);if(s){const[e,o]=s;if(N.addText(n),n="",c[r]=(c[r]||0)+1,c[r]<=7&&(j+=o),e.startsWith("_"))n+=t[0];else{const n=x.classNameAliases[e]||e;g(t[0],n)}}else n+=t[0];e=S.keywordPatternRe.lastIndex,t=S.keywordPatternRe.exec(T)}var o;n+=T.substring(e),N.addText(n)}function p(){null!=S.subLanguage?function(){if(""===T)return;let e=null;if("string"==typeof S.subLanguage){if(!o[S.subLanguage])return void N.addText(T);e=_(S.subLanguage,T,!0,M[S.subLanguage]),M[S.subLanguage]=e._top}else e=y(T,S.subLanguage.length?S.subLanguage:null);S.relevance>0&&(j+=e.relevance),N.__addSublanguage(e._emitter,e.language)}():u(),T=""}function g(e,t){""!==e&&(N.startScope(t),N.addText(e),N.endScope())}function h(e,t){let n=1;const o=t.length-1;for(;n<=o;){if(!e._emit[n]){n++;continue}const o=x.classNameAliases[e[n]]||e[n],r=t[n];o?g(r,o):(T=r,u(),T=""),n++}}function f(e,t){return e.scope&&"string"==typeof e.scope&&N.openNode(x.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(g(T,x.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),T=""):e.beginScope._multi&&(h(e.beginScope,t),T="")),S=Object.create(e,{parent:{value:S}}),S}function d(e,t,o){let r=function(e,t){const n=e&&e.exec(t);return n&&0===n.index}(e.endRe,o);if(r){if(e["on:end"]){const o=new n(e);e["on:end"](t,o),o.isMatchIgnored&&(r=!1)}if(r){for(;e.endsParent&&e.parent;)e=e.parent;return e}}if(e.endsWithParent)return d(e.parent,t,o)}function b(e){return 0===S.matcher.regexIndex?(T+=e[0],1):(R=!0,0)}function m(e){const n=e[0],o=t.substring(e.index),r=d(S,e,o);if(!r)return ae;const s=S;S.endScope&&S.endScope._wrap?(p(),g(n,S.endScope._wrap)):S.endScope&&S.endScope._multi?(p(),h(S.endScope,e)):s.skip?T+=n:(s.returnEnd||s.excludeEnd||(T+=n),p(),s.excludeEnd&&(T=n));do{S.scope&&N.closeNode(),S.skip||S.subLanguage||(j+=S.relevance),S=S.parent}while(S!==r.parent);return r.starts&&f(r.starts,e),s.returnEnd?0:n.length}let w={};function E(o,s){const a=s&&s[0];if(T+=o,null==a)return p(),0;if("begin"===w.type&&"end"===s.type&&w.index===s.index&&""===a){if(T+=t.slice(s.index,s.index+1),!i){const t=new Error(`0 width match regex (${e})`);throw t.languageName=e,t.badRule=w.rule,t}return 1}if(w=s,"begin"===s.type)return function(e){const t=e[0],o=e.rule,r=new n(o),s=[o.__beforeBegin,o["on:begin"]];for(const n of s)if(n&&(n(e,r),r.isMatchIgnored))return b(t);return o.skip?T+=t:(o.excludeBegin&&(T+=t),p(),o.returnBegin||o.excludeBegin||(T=t)),f(o,e),o.returnBegin?0:t.length}(s);if("illegal"===s.type&&!r){const e=new Error('Illegal lexeme "'+a+'" for mode "'+(S.scope||"")+'"');throw e.mode=S,e}if("end"===s.type){const e=m(s);if(e!==ae)return e}if("illegal"===s.type&&""===a)return T+="\n",1;if(I>1e5&&I>3*s.index)throw new Error("potential infinite loop, way more iterations than matches");return T+=a,a.length}const x=v(e);if(!x)throw J(a.replace("{}",e)),new Error('Unknown language: "'+e+'"');const O=ne(x);let k="",S=s||O;const M={},N=new l.__emitter(l);!function(){const e=[];for(let t=S;t!==x;t=t.parent)t.scope&&e.unshift(t.scope);e.forEach((e=>N.openNode(e)))}();let T="",j=0,A=0,I=0,R=!1;try{if(x.__emitTokens)x.__emitTokens(t,N);else{for(S.matcher.considerAll();;){I++,R?R=!1:S.matcher.considerAll(),S.matcher.lastIndex=A;const e=S.matcher.exec(t);if(!e)break;const n=E(t.substring(A,e.index),e);A=e.index+n}E(t.substring(A))}return N.finalize(),k=N.toHTML(),{language:e,value:k,relevance:j,illegal:!1,_emitter:N,_top:S}}catch(n){if(n.message&&n.message.includes("Illegal"))return{language:e,value:se(t),illegal:!0,relevance:0,_illegalBy:{message:n.message,index:A,context:t.slice(A-100,A+100),mode:n.mode,resultSoFar:k},_emitter:N};if(i)return{language:e,value:se(t),illegal:!1,relevance:0,errorRaised:n,_emitter:N,_top:S};throw n}}function y(e,t){t=t||l.languages||Object.keys(o);const n=function(e){const t={value:se(e),illegal:!1,relevance:0,_top:c,_emitter:new l.__emitter(l)};return t._emitter.addText(e),t}(e),r=t.filter(v).filter(k).map((t=>_(t,e,!1)));r.unshift(n);const s=r.sort(((e,t)=>{if(e.relevance!==t.relevance)return t.relevance-e.relevance;if(e.language&&t.language){if(v(e.language).supersetOf===t.language)return 1;if(v(t.language).supersetOf===e.language)return-1}return 0})),[i,a]=s,u=i;return u.secondBest=a,u}function w(e){let t=null;const n=function(e){let t=e.className+" ";t+=e.parentNode?e.parentNode.className:"";const n=l.languageDetectRe.exec(t);if(n){const t=v(n[1]);return t||(Q(a.replace("{}",n[1])),Q("Falling back to no-highlight mode for this block.",e)),t?n[1]:"no-highlight"}return t.split(/\s+/).find((e=>b(e)||v(e)))}(e);if(b(n))return;if(S("before:highlightElement",{el:e,language:n}),e.dataset.highlighted)return void console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e);if(e.children.length>0&&(l.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(e)),l.throwUnescapedHTML))throw new re("One of your code blocks includes unescaped HTML.",e.innerHTML);t=e;const o=t.textContent,s=n?m(o,{language:n,ignoreIllegals:!0}):y(o);e.innerHTML=s.value,e.dataset.highlighted="yes",function(e,t,n){const o=t&&r[t]||n;e.classList.add("hljs"),e.classList.add(`language-${o}`)}(e,n,s.language),e.result={language:s.language,re:s.relevance,relevance:s.relevance},s.secondBest&&(e.secondBest={language:s.secondBest.language,relevance:s.secondBest.relevance}),S("after:highlightElement",{el:e,result:s,text:o})}let E=!1;function x(){if("loading"===document.readyState)return E||window.addEventListener("DOMContentLoaded",(function(){x()}),!1),void(E=!0);document.querySelectorAll(l.cssSelector).forEach(w)}function v(e){return e=(e||"").toLowerCase(),o[e]||o[r[e]]}function O(e,{languageName:t}){"string"==typeof e&&(e=[e]),e.forEach((e=>{r[e.toLowerCase()]=t}))}function k(e){const t=v(e);return t&&!t.disableAutodetect}function S(e,t){const n=e;s.forEach((function(e){e[n]&&e[n](t)}))}Object.assign(e,{highlight:m,highlightAuto:y,highlightAll:x,highlightElement:w,highlightBlock:function(e){return V("10.7.0","highlightBlock will be removed entirely in v12.0"),V("10.7.0","Please use highlightElement now."),w(e)},configure:function(e){l=ie(l,e)},initHighlighting:()=>{x(),V("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")},initHighlightingOnLoad:function(){x(),V("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")},registerLanguage:function(t,n){let r=null;try{r=n(e)}catch(e){if(J("Language definition for '{}' could not be registered.".replace("{}",t)),!i)throw e;J(e),r=c}r.name||(r.name=t),o[t]=r,r.rawDefinition=n.bind(null,e),r.aliases&&O(r.aliases,{languageName:t})},unregisterLanguage:function(e){delete o[e];for(const t of Object.keys(r))r[t]===e&&delete r[t]},listLanguages:function(){return Object.keys(o)},getLanguage:v,registerAliases:O,autoDetection:k,inherit:ie,addPlugin:function(e){!function(e){e["before:highlightBlock"]&&!e["before:highlightElement"]&&(e["before:highlightElement"]=t=>{e["before:highlightBlock"](Object.assign({block:t.el},t))}),e["after:highlightBlock"]&&!e["after:highlightElement"]&&(e["after:highlightElement"]=t=>{e["after:highlightBlock"](Object.assign({block:t.el},t))})}(e),s.push(e)},removePlugin:function(e){const t=s.indexOf(e);-1!==t&&s.splice(t,1)}}),e.debugMode=function(){i=!1},e.safeMode=function(){i=!0},e.versionString="11.11.1",e.regex={concat:f,lookahead:p,either:d,optional:h,anyNumberOfTimes:g};for(const e in $)"object"==typeof $[e]&&t($[e]);return Object.assign(e,$),e},ue=ce({});ue.newInstance=()=>ce({}),e.exports=ue,ue.HighlightJS=ue,ue.default=ue}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var s=t[o]={exports:{}};return e[o](s,s.exports,n),s.exports}(()=>{"use strict";const e=n(416);e.registerLanguage("protobuf",(function(e){const t={match:[/(message|enum|service)\s+/,e.IDENT_RE],scope:{1:"keyword",2:"title.class"}};return{name:"Protocol Buffers",aliases:["proto"],keywords:{keyword:["package","import","option","optional","required","repeated","group","oneof"],type:["double","float","int32","int64","uint32","uint64","sint32","sint64","fixed32","fixed64","sfixed32","sfixed64","bool","string","bytes"],literal:["true","false"]},contains:[e.QUOTE_STRING_MODE,e.NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,t,{className:"function",beginKeywords:"rpc",end:/[{;]/,excludeEnd:!0,keywords:"rpc returns"},{begin:/^\s*[A-Z_]+(?=\s*=[^\n]+;$)/}]}}));const t="google/protobuf/any.proto",o="google.protobuf.Any",r="google.protobuf.Timestamp";class s{constructor(e,t){this.success=e,this.error=t}}class i{constructor(e,t,n){this.name=e,this.complex=t,this.merge=n}}const a=new i("bool",!1,!1),c=new i("string",!1,!1),u=new i("int64",!1,!0),l=new i(o,!0,!1),p=new i(r,!1,!1);class g{constructor(){this.imports=new Set,this.messages=[],this.messageNameSuffixCounter={}}addImport(e){this.imports.add(e)}generateUniqueName(e){if(this.messageNameSuffixCounter.hasOwnProperty(e)){const t=this.messageNameSuffixCounter[e];return this.messageNameSuffixCounter[e]=t+1,`${e}${t}`}return this.messageNameSuffixCounter[e]=1,e}addMessage(e){this.messages.push(e)}getImports(){return this.imports}getMessages(){return this.messages}}class h{constructor(e){this.options=e,this.mergeSimilarObjectMap={}}analyze(e){return this.directType(e)?this.analyzeObject({first:e}):Array.isArray(e)?this.analyzeArray(e):this.analyzeObject(e)}directType(e){switch(typeof e){case"string":case"number":case"boolean":return!0;case"object":return null===e}return!1}analyzeArray(e){const t=this.addShift(),n=new g,o=[],r=this.analyzeArrayProperty("nested",e,n,t);return o.push(` ${r} items = 1;`),d(n.getImports(),n.getMessages(),o,this.options)}analyzeObject(e){const t=this.addShift(),n=new g,o=[];let r=1;for(const[s,i]of Object.entries(e)){let e=this.sanitizeKey(s);const a=this.options.lowerSnakeCaseFieldNames?e.replace(/([A-Z])/g,"_$1").toLowerCase():e,c=this.analyzeProperty(a,i,n,t);o.push(` ${c} ${a} = ${r};`),r+=1}return d(n.getImports(),n.getMessages(),o,this.options)}sanitizeKey(e){const t=e.split("");let n="";for(const{index:o,char:r}of t.map(((e,t)=>({char:e,index:t})))){let t=r;if(0===o&&!r.match(/[a-zA-Z]/))throw new Error(`Invalid character: '${r}'. The first character must be a letter. Invalid key: "${e}".`);if("-"===r)t="_";else{if(!r.match(/[a-zA-Z0-9]/))throw new Error(`Invalid character in position ${o+1}. The character "${r}" is not allowed. Invalid key: "${e}".`);t=r}n+=t}return n}analyzeArrayProperty(e,n,r,s){const i=n.length;if(0===i)return r.addImport(t),`repeated ${o}`;const a=n[0];if(Array.isArray(a))return r.addImport(t),`repeated ${o}`;if(i>1){const e=this.samePrimitiveType(n);if(!1===e.complex)return`repeated ${e.name}`}return`repeated ${this.analyzeObjectProperty(e,a,r,s)}`}analyzeProperty(e,t,n,o){return Array.isArray(t)?this.analyzeArrayProperty(e,t,n,o):this.analyzeObjectProperty(e,t,n,o)}analyzeObjectProperty(e,t,n,o){const r=this.analyzeType(t,n);if("object"===r){if(this.options.mergeSimilarObjects){const[r,s]=this.mergeSimilarObjectKey(t);if(s){if(this.mergeSimilarObjectMap.hasOwnProperty(r))return this.mergeSimilarObjectMap[r];const s=n.generateUniqueName(f(e));return this.mergeSimilarObjectMap[r]=s,this.addNested(n,s,t,o),s}}const r=n.generateUniqueName(f(e));return this.addNested(n,r,t,o),r}return r}mergeSimilarObjectKey(e){const t=[];for(const[n,o]of Object.entries(e)){const[e,r]=this.mergeSimilarObjectType(o);if(!r)return["",!1];t.push([n,e])}return[JSON.stringify(t),!0]}mergeSimilarObjectType(e){if(Array.isArray(e))return["",!1];switch(typeof e){case"string":return this.options.googleProtobufTimestamp&&/\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(\+\d\d:\d\d|Z)/.test(e)?[r,!0]:["string",!0];case"number":return[m(e),!0];case"boolean":return["bool",!0]}return["",!1]}analyzeType(e,n){switch(typeof e){case"string":return this.options.googleProtobufTimestamp&&/\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(\+\d\d:\d\d|Z)/.test(e)?(n.addImport("google/protobuf/timestamp.proto"),r):"string";case"number":return m(e);case"boolean":return"bool";case"object":return null===e?(n.addImport(t),o):"object"}return n.addImport(t),o}toPrimitiveType(e){switch(typeof e){case"string":return this.options.googleProtobufTimestamp&&/\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(\+\d\d:\d\d|Z)/.test(e)?p:c;case"number":return new i(m(e),!1,!0);case"boolean":return a}return l}samePrimitiveType(e){let t=this.toPrimitiveType(e[0]);if(t.complex)return t;for(let n=1;n0){r.push("");for(const t of e)r.push(`import "${t}";`)}if(r.push(""),o.inline){if(r.push("message SomeMessage {"),t.length>0){r.push("");for(const e of t)r.push(...e),r.push("")}r.push(...n),r.push("}")}else{for(const e of t)r.push(...e),r.push("");r.push("message SomeMessage {"),r.push(...n),r.push("}")}return r.join("\n")}function b(e,t){if(e.name===t.name)return e;if(e.merge&&t.merge){if("double"===e.name)return e;if("double"===t.name)return t;if("int64"===e.name)return e;if("int64"===t.name)return t;if("uint64"===e.name){if("uint32"===t.name)return e}else if("uint64"===t.name&&"uint32"===e.name)return t;return u}return l}function m(e){return e%1==0?e<0?e<-2147483648?"int64":"int32":e>4294967295?"uint64":"uint32":"double"}const _=document.getElementById("input"),y=document.getElementById("output"),w=document.getElementById("sample"),E=document.getElementById("inline"),x=document.getElementById("google.protobuf.Timestamp"),v=document.getElementById("merge-similar-objects"),O=document.getElementById("lower-snake-case-field-names"),k=document.getElementById("copy-to-clipboard"),S=new class{constructor(e,t,n,o){this.inline=e,this.googleProtobufTimestamp=t,this.mergeSimilarObjects=n,this.lowerSnakeCaseFieldNames=o}}(E.checked,x.checked,v.checked,O.checked);function M(){const t=function(e,t){if(""===e)return new s("","");const n=e.replace(/\.0/g,".1");try{const e=JSON.parse(n),o=new h(t);return new s(o.analyze(e),"")}catch(e){return new s("",e.message)}}(_.innerText.trim(),S);var n;t.success?y.innerHTML=(n=t.success,e.highlight(n,{language:"protobuf"}).value):y.innerHTML=t.error}_.addEventListener("keyup",M),E.addEventListener("change",(function(){S.inline=E.checked,M()})),x.addEventListener("change",(function(){S.googleProtobufTimestamp=x.checked,M()})),v.addEventListener("change",(function(){S.mergeSimilarObjects=v.checked,M()})),O.addEventListener("change",(function(){S.lowerSnakeCaseFieldNames=O.checked,M()})),w.addEventListener("click",(function(){_.innerHTML=N,M()})),k.addEventListener("click",(function(){navigator.clipboard.writeText(y.innerText)}));const N='{\n "id": 23357588,\n "node_id": "MDEwOlJlcG9zaXRvcnkyMzM1NzU4OA==",\n "name": "protobuf",\n "full_name": "protocolbuffers/protobuf",\n "private": false,\n "owner": {\n "login": "protocolbuffers",\n "id": 26310541,\n "node_id": "MDEyOk9yZ2FuaXphdGlvbjI2MzEwNTQx",\n "avatar_url": "https://avatars1.githubusercontent.com/u/26310541?v=4",\n "gravatar_id": "",\n "url": "https://api.github.com/users/protocolbuffers",\n "html_url": "https://github.com/protocolbuffers",\n "followers_url": "https://api.github.com/users/protocolbuffers/followers",\n "following_url": "https://api.github.com/users/protocolbuffers/following{/other_user}",\n "gists_url": "https://api.github.com/users/protocolbuffers/gists{/gist_id}",\n "starred_url": "https://api.github.com/users/protocolbuffers/starred{/owner}{/repo}",\n "subscriptions_url": "https://api.github.com/users/protocolbuffers/subscriptions",\n "organizations_url": "https://api.github.com/users/protocolbuffers/orgs",\n "repos_url": "https://api.github.com/users/protocolbuffers/repos",\n "events_url": "https://api.github.com/users/protocolbuffers/events{/privacy}",\n "received_events_url": "https://api.github.com/users/protocolbuffers/received_events",\n "type": "Organization",\n "site_admin": false\n },\n "html_url": "https://github.com/protocolbuffers/protobuf",\n "description": "Protocol Buffers - Google\'s data interchange format",\n "fork": false,\n "url": "https://api.github.com/repos/protocolbuffers/protobuf",\n "forks_url": "https://api.github.com/repos/protocolbuffers/protobuf/forks",\n "keys_url": "https://api.github.com/repos/protocolbuffers/protobuf/keys{/key_id}",\n "collaborators_url": "https://api.github.com/repos/protocolbuffers/protobuf/collaborators{/collaborator}",\n "teams_url": "https://api.github.com/repos/protocolbuffers/protobuf/teams",\n "hooks_url": "https://api.github.com/repos/protocolbuffers/protobuf/hooks",\n "issue_events_url": "https://api.github.com/repos/protocolbuffers/protobuf/issues/events{/number}",\n "events_url": "https://api.github.com/repos/protocolbuffers/protobuf/events",\n "assignees_url": "https://api.github.com/repos/protocolbuffers/protobuf/assignees{/user}",\n "branches_url": "https://api.github.com/repos/protocolbuffers/protobuf/branches{/branch}",\n "tags_url": "https://api.github.com/repos/protocolbuffers/protobuf/tags",\n "blobs_url": "https://api.github.com/repos/protocolbuffers/protobuf/git/blobs{/sha}",\n "git_tags_url": "https://api.github.com/repos/protocolbuffers/protobuf/git/tags{/sha}",\n "git_refs_url": "https://api.github.com/repos/protocolbuffers/protobuf/git/refs{/sha}",\n "trees_url": "https://api.github.com/repos/protocolbuffers/protobuf/git/trees{/sha}",\n "statuses_url": "https://api.github.com/repos/protocolbuffers/protobuf/statuses/{sha}",\n "languages_url": "https://api.github.com/repos/protocolbuffers/protobuf/languages",\n "stargazers_url": "https://api.github.com/repos/protocolbuffers/protobuf/stargazers",\n "contributors_url": "https://api.github.com/repos/protocolbuffers/protobuf/contributors",\n "subscribers_url": "https://api.github.com/repos/protocolbuffers/protobuf/subscribers",\n "subscription_url": "https://api.github.com/repos/protocolbuffers/protobuf/subscription",\n "commits_url": "https://api.github.com/repos/protocolbuffers/protobuf/commits{/sha}",\n "git_commits_url": "https://api.github.com/repos/protocolbuffers/protobuf/git/commits{/sha}",\n "comments_url": "https://api.github.com/repos/protocolbuffers/protobuf/comments{/number}",\n "issue_comment_url": "https://api.github.com/repos/protocolbuffers/protobuf/issues/comments{/number}",\n "contents_url": "https://api.github.com/repos/protocolbuffers/protobuf/contents/{+path}",\n "compare_url": "https://api.github.com/repos/protocolbuffers/protobuf/compare/{base}...{head}",\n "merges_url": "https://api.github.com/repos/protocolbuffers/protobuf/merges",\n "archive_url": "https://api.github.com/repos/protocolbuffers/protobuf/{archive_format}{/ref}",\n "downloads_url": "https://api.github.com/repos/protocolbuffers/protobuf/downloads",\n "issues_url": "https://api.github.com/repos/protocolbuffers/protobuf/issues{/number}",\n "pulls_url": "https://api.github.com/repos/protocolbuffers/protobuf/pulls{/number}",\n "milestones_url": "https://api.github.com/repos/protocolbuffers/protobuf/milestones{/number}",\n "notifications_url": "https://api.github.com/repos/protocolbuffers/protobuf/notifications{?since,all,participating}",\n "labels_url": "https://api.github.com/repos/protocolbuffers/protobuf/labels{/name}",\n "releases_url": "https://api.github.com/repos/protocolbuffers/protobuf/releases{/id}",\n "deployments_url": "https://api.github.com/repos/protocolbuffers/protobuf/deployments",\n "created_at": "2014-08-26T15:52:15Z",\n "updated_at": "2020-04-21T23:33:50Z",\n "pushed_at": "2020-04-22T00:06:06Z",\n "git_url": "git://github.com/protocolbuffers/protobuf.git",\n "ssh_url": "git@github.com:protocolbuffers/protobuf.git",\n "clone_url": "https://github.com/protocolbuffers/protobuf.git",\n "svn_url": "https://github.com/protocolbuffers/protobuf",\n "homepage": "https://developers.google.com/protocol-buffers/",\n "size": 60901,\n "stargazers_count": 41099,\n "watchers_count": 41099,\n "language": "C++",\n "has_issues": true,\n "has_projects": true,\n "has_downloads": true,\n "has_wiki": true,\n "has_pages": true,\n "forks_count": 11124,\n "mirror_url": null,\n "archived": false,\n "disabled": false,\n "open_issues_count": 1009,\n "license": {\n "key": "other",\n "name": "Other",\n "spdx_id": "NOASSERTION",\n "url": null,\n "node_id": "MDc6TGljZW5zZTA="\n },\n "forks": 11124,\n "open_issues": 1009,\n "watchers": 41099,\n "default_branch": "master",\n "temp_clone_token": null,\n "organization": {\n "login": "protocolbuffers",\n "id": 26310541,\n "node_id": "MDEyOk9yZ2FuaXphdGlvbjI2MzEwNTQx",\n "avatar_url": "https://avatars1.githubusercontent.com/u/26310541?v=4",\n "gravatar_id": "",\n "url": "https://api.github.com/users/protocolbuffers",\n "html_url": "https://github.com/protocolbuffers",\n "followers_url": "https://api.github.com/users/protocolbuffers/followers",\n "following_url": "https://api.github.com/users/protocolbuffers/following{/other_user}",\n "gists_url": "https://api.github.com/users/protocolbuffers/gists{/gist_id}",\n "starred_url": "https://api.github.com/users/protocolbuffers/starred{/owner}{/repo}",\n "subscriptions_url": "https://api.github.com/users/protocolbuffers/subscriptions",\n "organizations_url": "https://api.github.com/users/protocolbuffers/orgs",\n "repos_url": "https://api.github.com/users/protocolbuffers/repos",\n "events_url": "https://api.github.com/users/protocolbuffers/events{/privacy}",\n "received_events_url": "https://api.github.com/users/protocolbuffers/received_events",\n "type": "Organization",\n "site_admin": false\n },\n "network_count": 11124,\n "subscribers_count": 2059\n}'})()})(); \ No newline at end of file