import{v,Q as u,G as x,j as e,b,y as _,c as N,a as y,w as L,r as w,J as g}from"./index-d7144f09.js";import{w as C,T as S}from"./bootstrap-5.esm-0e1737e0.js";import{_ as E}from"./_baseSet-0628f112.js";var F=u,j=/[\\^$.*+?()[\]{}|]/g,R=RegExp(j.source);function T(s){return s=F(s),s&&R.test(s)?s.replace(j,"\\$&"):s}var $=T;const D=v($);var K=E;function P(s,o,a){return s==null?s:K(s,o,a)}var I=P;const k=v(I),z={"hide-description":"_hide-description_19xm6_1"},A=C(S);function H(s){const{schema:o={},schemaKey:a="",config:c={},configKey:t="",onChange:r}=s,n=x(c,t,{}),d=x(o,a,{}),l=i=>{const h={};k(h,t,i.formData),r(h)};return e.jsx(A,{schema:d,className:z["hide-description"],formData:n,onChange:l,children:e.jsx("div",{})})}const m="all",p=({text:s})=>e.jsx(e.Fragment,{children:s}),O=({text:s="",highlight:o=""})=>{if(!o.trim())return e.jsx(p,{text:s});const a=new RegExp(`(${D(o)})`,"gi"),c=s.split(a);return e.jsx(e.Fragment,{children:c.filter(t=>t).map((t,r)=>a.test(t)?e.jsx("mark",{children:t},r):e.jsx(p,{text:t},r))})};function f(s){const{logLevel:o,log:a,search:c}=s,t=o===m&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{width:"60px"},className:b("badge",{"bg-danger":a.level==="error","bg-warning":a.level==="warning","bg-info":a.level==="info","bg-secondary":!["error","warning","info"].includes(a.level)},"text-capitalize"),children:a.level})," "]});return e.jsxs("div",{children:[t,e.jsx("small",{className:"pe-1",children:_(a.timestamp)}),e.jsx("code",{children:e.jsx(O,{text:a.message,highlight:c})})]})}const B=[m,"debug","info","warning","error"],G=[100,200,500,1e3];class J extends w.Component{constructor(){super(...arguments),this.state={search:"",logLevel:m}}renderSearch(){const{clearLogs:o,bridgeInfo:{config_schema:a,config:c},updateBridgeConfig:t,t:r}=this.props,{search:n}=this.state,{logsLimit:d}=g.getState();return e.jsx("div",{className:"card",children:e.jsx("div",{className:"card-body",children:e.jsxs("div",{className:"row row-cols-lg-auto g-3 align-items-center",children:[e.jsxs("div",{className:"col-12 col-sm-4 col-xxl-4",children:[e.jsx("label",{htmlFor:"log-level",className:"form-label",children:r("show_only")}),e.jsx("select",{id:"log-level",className:"form-select",onChange:l=>this.setState({logLevel:l.target.value}),children:B.map(l=>e.jsx("option",{value:l,children:l},l))})]}),e.jsxs("div",{className:"col-12 col-sm-4 col-xxl-4",children:[e.jsx("label",{htmlFor:"search-filter",className:"form-label",children:r("filter_by_text")}),e.jsx("input",{id:"search-filter",className:"form-control col-10",placeholder:r("common:enter_search_criteria"),value:n,onChange:l=>this.setState({search:l.target.value}),type:"text"})]}),e.jsx("div",{className:"col-12 col-sm-4 col-xxl-4",children:e.jsx(H,{schema:a,schemaKey:"properties.advanced.properties.log_level",config:c,configKey:"advanced.log_level",onChange:t})}),e.jsxs("div",{className:"col-12 col-sm-4 col-xxl-4",children:[e.jsx("label",{htmlFor:"logs-limit",className:"form-label",children:r("logs_limit")}),e.jsx("select",{id:"logs-limit",className:"form-select",onChange:l=>{const i=parseInt(l.target.value);g.setState({logsLimit:i,logs:[...g.getState().logs.slice(-i)]})},children:G.map(l=>e.jsx("option",{value:l,selected:l==d,children:l},l))})]}),e.jsxs("div",{className:"col-12",children:[e.jsx("label",{htmlFor:"reset",children:" "}),e.jsx("input",{id:"reset",type:"button",onClick:o,className:"btn btn-primary form-control",value:r("common:clear")})]})]})})})}render(){let{logs:o}=this.props;const{t:a}=this.props,{search:c,logLevel:t}=this.state;return o=o.filter(r=>(t===m||r.level===t)&&(!c||r.message.toLowerCase().includes(c.toLowerCase()))).sort(),e.jsxs(e.Fragment,{children:[this.renderSearch(),e.jsx("div",{className:"card",children:e.jsxs("div",{className:"card-body",children:[o.length==0?e.jsx("h1",{children:a("empty_logs_message")}):null,e.jsx("div",{className:"overflow-auto",children:o.map((r,n)=>e.jsx(f,{log:r,search:c,logLevel:t},n))})]})})]})}}const M=["logs","bridgeInfo"],Q=N(M,y)(L(["logs","common"])(J)),V=Object.freeze(Object.defineProperty({__proto__:null,ConnectedLogsPage:Q,LogRow:f},Symbol.toStringTag,{value:"Module"}));export{m as A,f as L,V as i};
