import{_ as O}from"./SearchBox-CH3IEr_n.js";import{a as j,L as z,r as f,x as E,o as U,I as P,l as J,m as r,d as l,h as R,f as n,C as q,i as C,e as o,n as u,t as i,j as a,F as x,D as G,k as A,g as w,a8 as K,U as Q}from"./app-CzxRjCVM.js";import{S as W}from"./Spinner-C-V0HKYn.js";/*! 2FAuth version 5.4.3 - Copyright (c) 2024 Bubka - https://github.com/Bubka/2FAuth */const X={key:1,class:"level is-mobile mb-2"},Z={class:"level-item has-text-centered"},ee={class:"buttons"},te=["title"],se=["title"],oe=["title"],ne=["title"],re=["title"],ie=["title"],le={key:2},ae=["innerHTML"],de=["innerHTML"],ue=["innerHTML"],ce=["innerHTML"],he={class:"light-or-darker"},me={class:"light-or-darker"},_e={class:"light-or-darker"},ge={key:3,class:"mt-4"},fe={key:4,class:"mt-5 pl-3"},ve={__name:"AccessLogViewer",props:{userId:[Number,String],lastOnly:Boolean,showSearch:Boolean,period:{type:[Number,String],default:12}},emits:["has-more-entries"],setup(T,{emit:N}){const H=j(),I=z("2fauth"),h=T,d={aMonth:1,threeMonths:3,halfYear:6,aYear:12},c=f([]),b=f(!1),p=f(""),m=f(h.period),g=f(!0),B=N,$=E(()=>c.value.filter(e=>JSON.stringify(e).toString().toLowerCase().includes(p.value)));U(()=>{L()});function y(e){m.value=e,L()}function F(){g.value=!1,S()}function S(){c.value.sort((e,s)=>e.id>s.id?1:-1)}function V(){g.value=!0,M()}function M(){c.value.sort((e,s)=>e.id{c.value=s.data,c.value.length>3&&h.lastOnly&&(B("has-more-entries"),c.value.pop()),g.value==!0?M():S()}).catch(s=>{H.error(s)}).finally(()=>{b.value=!1})}const Y=e=>{switch(e){case"phone":return"mobile-screen";case"tablet":return"tablet-screen-button";default:return"display"}},D=e=>!e.login_at&&e.logout_at,v=e=>!e.login_successful&&!e.logout_at;return(e,s)=>{const _=J("FontAwesomeIcon");return r(),l(x,null,[h.showSearch?(r(),R(O,{key:0,keyword:n(p),"onUpdate:keyword":s[0]||(s[0]=t=>q(p)?p.value=t:null),hasNoBackground:!0},null,8,["keyword"])):C("",!0),h.showSearch?(r(),l("nav",X,[o("div",Z,[o("div",ee,[o("button",{id:"btnShowOneMonth",title:e.$t("admin.show_last_month_log"),onClick:s[1]||(s[1]=t=>y(d.aMonth)),class:u([{"has-text-grey":n(m)!==d.aMonth},"button is-ghost p-1"]),type:"button"},i(e.$t("commons.one_month")),11,te),o("button",{id:"btnShowThreeMonths",title:e.$t("admin.show_three_months_log"),onClick:s[2]||(s[2]=t=>y(d.threeMonths)),class:u([{"has-text-grey":n(m)!==d.threeMonths},"button is-ghost p-1"]),type:"button"},i(e.$t("commons.x_month",{x:"3"})),11,se),o("button",{id:"btnShowSixMonths",title:e.$t("admin.show_six_months_log"),onClick:s[3]||(s[3]=t=>y(d.halfYear)),class:u([{"has-text-grey":n(m)!==d.halfYear},"button is-ghost p-1"]),type:"button"},i(e.$t("commons.x_month",{x:"6"})),11,oe),o("button",{id:"btnShowOneYear",title:e.$t("admin.show_one_year_log"),onClick:s[4]||(s[4]=t=>y(d.aYear)),class:u([{"has-text-grey":n(m)!==d.aYear},"button is-ghost p-1 mr-5"]),type:"button"},i(e.$t("commons.one_year")),11,ne),o("button",{id:"btnSortLogDesc",onClick:V,title:e.$t("admin.sort_by_date_desc"),class:u([{"has-text-grey":!n(g)},"button p-1 is-ghost"]),type:"button"},[a(_,{icon:["fas","arrow-up-long"],flip:"vertical"}),a(_,{icon:["far","calendar"]})],10,re),o("button",{id:"btnSortLogAsc",onClick:F,title:e.$t("admin.sort_by_date_asc"),class:u([{"has-text-grey":n(g)},"button p-1 is-ghost"]),type:"button"},[a(_,{icon:["fas","arrow-up-long"]}),a(_,{icon:["far","calendar"]})],10,ie)])])])):C("",!0),n($).length>0?(r(),l("div",le,[(r(!0),l(x,null,G(n($),t=>(r(),l("div",{key:t.id,class:"list-item is-size-6 is-size-7-mobile has-text-grey is-flex is-justify-content-space-between"},[a(n(Q),null,{default:A(({mode:k})=>[o("div",null,[o("div",null,[v(t)?(r(),l("span",{key:0,innerHTML:e.$t("admin.failed_login_on",{login_at:t.login_at})},null,8,ae)):D(t)?(r(),l("span",{key:1,innerHTML:e.$t("admin.successful_logout_on",{login_at:t.logout_at})},null,8,de)):n(I).config.proxyAuth?(r(),l("span",{key:2,innerHTML:e.$t("admin.viewed_on",{login_at:t.login_at})},null,8,ue)):(r(),l("span",{key:3,innerHTML:e.$t("admin.successful_login_on",{login_at:t.login_at})},null,8,ce))]),o("div",null,[w(i(e.$t("commons.IP"))+": ",1),o("span",he,i(t.ip_address),1),w(" - "+i(e.$t("commons.browser"))+": ",1),o("span",me,i(t.browser),1),w(" - "+i(e.$t("commons.operating_system_short"))+": ",1),o("span",_e,i(t.platform),1)])]),o("div",{class:u([k=="dark"?"has-text-grey-darker":"has-text-grey-lighter","is-align-self-center"])},[a(n(K),{class:"fa-2x width-1-5x"},{default:A(()=>[a(_,{icon:["fas",Y(t.device)],transform:"grow-6","fixed-width":""},null,8,["icon"]),a(_,{icon:["fas",v(t)?"times":"check"],transform:"shrink-7"+(t.device=="desktop"?" up-2":""),class:u(v(t)?"has-text-danger"+(k=="dark"?"-dark":""):"has-text-success"+(k=="dark"?"-dark":"")),"fixed-width":""},null,8,["icon","transform","class"])]),_:2},1024)],2)]),_:2},1024)]))),128))])):n(c).length==0?(r(),l("div",ge,i(e.$t("commons.no_entry_yet")),1)):(r(),l("div",fe,i(e.$t("commons.no_result")),1)),a(W,{isVisible:n(b)},null,8,["isVisible"])],64)}}};export{ve as _}; //# sourceMappingURL=AccessLogViewer-DhKO22h5.js.map