import{C as y,E,G as A,u as _,a as r,r as o,j as s,N as T,M,A as G,J as F,S as D,a9 as O,F as h,at as C,I as v,au as P,s as B,av as L,aw as H,B as N,f as V,ax as z}from"./index-B_eahVWI.js";import{C as $}from"./CheckboxField-CzUa3ISp.js";import{D as q}from"./DebouncedInput-oq8bX0s-.js";import{S as p}from"./SelectField-JWPpuidh.js";import{u as R}from"./useSearch-BuVIcQ48.js";import"./envs-CRUy-_iG.js";const U={error:"bg-error text-error-content",warning:"bg-warning text-warning-content",info:"bg-info text-info-content",debug:"bg-accent text-accent-content opacity-50"},J=o.memo(({sourceIdx:l})=>{const{t:a}=_(["logs","common"]),x=r(v(e=>e.bridgeInfo[l].config.advanced.log_level)),t=r(v(e=>e.logs[l])),c=r(e=>e.logsLimit),u=r(e=>e.setLogsLimit),n=r(e=>e.clearLogs),[m,i,j]=R(),[d,w]=o.useState("all"),[f,S]=o.useState(!1),b=o.useMemo(()=>t.filter(e=>(d==="all"||e.level===d)&&(f||i.length===0||e.message.toLowerCase().includes(i))),[i,f,d,t]),I=o.useCallback((e,g)=>i.length>0&&e.toLowerCase().includes(i)?U[g]:P[g],[i]),k=o.useCallback(async e=>{await B(l,"bridge/request/options",{options:{advanced:{log_level:e}}})},[l]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-row flex-wrap gap-3 items-top",children:[s.jsxs(p,{name:"log_level",label:a(e=>e.show_only,{ns:"common"}),value:d,onChange:e=>w(e.target.value),className:"select select-sm",children:[s.jsx("option",{value:"all",children:"all"},"all"),L.map(e=>s.jsx("option",{value:e,children:e},e))]}),s.jsxs("fieldset",{className:"fieldset",children:[s.jsx("legend",{className:"fieldset-legend",children:a(e=>e.filter_by_text)}),s.jsxs("div",{className:"join",children:[s.jsxs("label",{className:"input input-sm w-64 join-item",children:[s.jsx(h,{icon:H}),s.jsx(q,{onChange:j,placeholder:a(e=>e.search,{ns:"common"}),value:m})]}),s.jsx(N,{item:"",onClick:j,className:"btn btn-sm btn-square btn-warning btn-outline join-item",title:a(e=>e.clear,{ns:"common"}),disabled:m.length===0,children:s.jsx(h,{icon:V})})]})]}),s.jsx($,{name:"highlight_only",label:a(e=>e.highlight_only),checked:f,onChange:e=>S(e.target.checked),className:"checkbox checkbox-sm"}),s.jsx("fieldset",{className:"fieldset self-end",children:s.jsxs(N,{item:l,onClick:n,className:"btn btn-sm btn-outline btn-warning",disabled:t.length===0,children:[s.jsx(h,{icon:C}),a(e=>e.clear,{ns:"common"})]})}),s.jsxs("div",{className:"ml-auto flex flex-row gap-3",children:[s.jsx(p,{name:"log_limit",label:a(e=>e.logs_limit),onChange:e=>{u(Number.parseInt(e.target.value,10))},value:c,className:"select select-sm",children:z.map(e=>s.jsx("option",{value:e,children:e},e))}),s.jsx(p,{name:"log_level_config",label:a(e=>e.log_level_config),value:x,onChange:e=>!e.target.validationMessage&&k(e.target.value),className:"select select-sm",children:L.map(e=>s.jsx("option",{value:e,children:e},e))})]})]}),s.jsx("div",{className:"mockup-code w-full mt-1 mb-3 before:content-none",children:b.length>0?b.map((e,g)=>s.jsx("pre",{"data-prefix":g,className:I(e.message,e.level),children:s.jsxs("code",{children:["[",e.timestamp,"] ",e.message]})},`${g}-${e.timestamp}`)):s.jsx("pre",{"data-prefix":"~",children:s.jsxs("code",{children:["[",new Date().toLocaleString(),"] ",a(e=>e.empty_logs_message)]})})})]})}),K=({isActive:l})=>l?"menu-active":void 0;function se(){const l=y(),{sourceIdx:a}=E(),[x,t]=A(a),{t:c}=_(["logs","common"]),u=r(n=>n.clearAllLogs);return o.useEffect(()=>{(!a||!t)&&l("/logs/0",{replace:!0})},[a,t,l]),s.jsxs(s.Fragment,{children:[s.jsx(T,{children:M&&s.jsxs("div",{className:"flex-1 flex flex-col",children:[s.jsx("div",{className:"menu menu-horizontal flex-1 pb-0",children:G.map((n,m)=>s.jsx("li",{children:s.jsx(F,{to:`/logs/${m}`,className:K,children:s.jsx(D,{idx:m,alwaysShowName:!0})})},n))}),s.jsx("div",{className:"menu menu-horizontal justify-end",children:s.jsxs(O,{onClick:u,className:"btn btn-sm btn-outline btn-warning",title:c(n=>n.clear_all,{ns:"common"}),modalDescription:c(n=>n.dialog_confirmation_prompt,{ns:"common"}),modalCancelLabel:c(n=>n.cancel,{ns:"common"}),children:[s.jsx(h,{icon:C}),c(n=>n.clear_all,{ns:"common"})]})})]})}),s.jsx(J,{sourceIdx:x},a)]})}export{se as default};
