Files
op-packages/luci-app-honk/root/etc/honk/dashboard/assets/DaeCode-STEiRZuV.js
T

4 lines
1.6 KiB
JavaScript

import{r as o}from"./vendor-react-Bf71BWbF.js";const h=/^(global|dns|upstream|routing|request|response|subscription|node|group|include|fallback)\b/,p=()=>({afterArrow:!1});function l(t,e){return t.sol()&&(e.afterArrow=!1),t.eatSpace()?null:t.match("#")?(t.skipToEnd(),"comment"):t.match(/^'[^']*'/)||t.match(/^"[^"]*"/)?"string":t.match("->")?(e.afterArrow=!0,"operator"):e.afterArrow&&t.match(/^[\w.-]+/)?(e.afterArrow=!1,"keyword"):(t.sol()||t.string.slice(0,t.pos).trim()==="")&&t.match(h)?"keyword":t.match(/^\d+(\.\d+)*(\/\d+)?[a-z]*/)?"number":t.match(/^[\w.-]+(?=\s*\()/)?"propertyName":t.match(/^[\w.-]+(?=\s*:)/)?"variableName":t.match(/^[A-Za-z_][\w.-]*/)?null:t.match(/^[{}()&|!,:]/)?"punctuation":(t.next(),null)}class f{pos=0;string;constructor(e){this.string=e}sol(){return this.pos===0}eatSpace(){const e=/^\s+/.exec(this.string.slice(this.pos));return e?(this.pos+=e[0].length,!0):!1}match(e){const s=typeof e=="string"?this.string.slice(this.pos).startsWith(e)&&e:e.exec(this.string.slice(this.pos));return s&&(this.pos+=typeof s=="string"?s.length:s[0].length),s}skipToEnd(){this.pos=this.string.length}next(){return this.pos<this.string.length?this.string[this.pos++]:void 0}}function g(t){const e=[],s=t.split(`
`),r=p();return s.forEach((n,c)=>{const i=new f(n);for(;i.pos<n.length;){const u=i.pos,a=l(i,r);e.push({text:n.slice(u,i.pos),type:a})}c<s.length-1&&e.push({text:`
`,type:null})}),e}function m({text:t,as:e="span",className:s=""}){return o.createElement(e,{className:`rp-code ${s}`.trim()},g(t).map((r,n)=>r.type?o.createElement("span",{key:n,className:`rp-dae-${r.type}`},r.text):r.text))}export{m as D,l as d,p as s};