import{c,I as z,_ as H,aK as M,a as P,u as N,r as p,d as C,E,e as T,o as s,f as d,g as I,w as n,i as f,t as i,j as A,R,aP as q,n as F,v as G,B as J,m as Q,av as U,cm as W}from"./app-DNXD_-wA.js";import{L as X}from"./LogoutOutlined-C9o9EtfT.js";var Y={icon:{tag:"svg",attrs:{viewBox:"0 0 1024 1024",focusable:"false"},children:[{tag:"path",attrs:{d:"M275 281c19.9 0 36-16.1 36-36V36c0-19.9-16.1-36-36-36s-36 16.1-36 36v209c0 19.9 16.1 36 36 36zm613 144H768c0-39.8-32.2-72-72-72H200c-39.8 0-72 32.2-72 72v248c0 3.4.2 6.7.7 9.9-.5 7-.7 14-.7 21.1 0 176.7 143.3 320 320 320 160.1 0 292.7-117.5 316.3-271H888c39.8 0 72-32.2 72-72V497c0-39.8-32.2-72-72-72zM696 681h-1.1c.7 7.6 1.1 15.2 1.1 23 0 137-111 248-248 248S200 841 200 704c0-7.8.4-15.4 1.1-23H200V425h496v256zm192-8H776V497h112v176zM613 281c19.9 0 36-16.1 36-36V36c0-19.9-16.1-36-36-36s-36 16.1-36 36v209c0 19.9 16.1 36 36 36zm-170 0c19.9 0 36-16.1 36-36V36c0-19.9-16.1-36-36-36s-36 16.1-36 36v209c0 19.9 16.1 36 36 36z"}}]},name:"coffee",theme:"outlined"};function L(e){for(var a=1;a<arguments.length;a++){var l=arguments[a]!=null?Object(arguments[a]):{},t=Object.keys(l);typeof Object.getOwnPropertySymbols=="function"&&(t=t.concat(Object.getOwnPropertySymbols(l).filter(function(m){return Object.getOwnPropertyDescriptor(l,m).enumerable}))),t.forEach(function(m){Z(e,m,l[m])})}return e}function Z(e,a,l){return a in e?Object.defineProperty(e,a,{value:l,enumerable:!0,configurable:!0,writable:!0}):e[a]=l,e}var x=function(a,l){var t=L({},a,l.attrs);return c(z,L({},t,{icon:Y}),null)};x.displayName="CoffeeOutlined";x.inheritAttrs=!1;const $={components:{ClockCircleOutlined:M,LogoutOutlined:X},setup(e,{emit:a}){const{permsArray:l,dayjs:t,formatTime:m}=P(),r=N(),g=p(""),v=p(""),k=p({}),u=p(!1),_=p(!1),y=p(!1),h=C(()=>r.state.hrm.isSelfClocking),O=C(()=>r.state.hrm.showClockInButton),b=C(()=>r.state.hrm.showClockOutButton),w=C(()=>r.state.hrm.clockInDateTime),B=C(()=>r.state.hrm.clockOutDateTime);E(()=>{setInterval(j,1e3),y.value=!0,axiosAdmin.get("/hrm/today-attendance-details").then(o=>{k.value=o.data,g.value=o.data.ip_address,D(o),y.value=!1})});const V=o=>{o=="clock-in"?u.value=!0:o=="clock-out"&&(_.value=!0),axiosAdmin.post("/hrm/mark-attendance",{type:o}).then(S=>{g.value=S.data.ip_address,k.value=S.data,o=="clock-in"?u.value=!1:o=="clock-out"&&(_.value=!1),D(S)})},D=o=>{r.commit("hrm/updateSelfClocking",o.data.self_clocking),r.commit("hrm/updateShowClockInButton",o.data.show_clock_in_button),r.commit("hrm/updateShowClockOutButton",o.data.show_clock_out_button),r.commit("hrm/updateClockInDateTime",o.data.clock_in_date_time),r.commit("hrm/updateClockOutDateTime",o.data.clock_out_date_time)},j=()=>{v.value=t().format("hh:mm:ss a")};return{pageLoading:y,attendanceData:k,ipAddress:g,currentTime:v,markAttendance:V,clockInLoading:u,clockOutLoading:_,formatTime:m,isSelfClocking:h,showClockInButton:O,showClockOutButton:b,clockInDateTime:w,clockOutDateTime:B}}},K={key:1},tt={key:2};function et(e,a,l,t,m,r){const g=W,v=R,k=q,u=F,_=G,y=T("ClockCircleOutlined"),h=J,O=T("LogoutOutlined"),b=Q,w=U;return t.pageLoading?(s(),d(g,{key:0,active:""})):(s(),I("div",K,[t.attendanceData.is_on_full_day_leave?(s(),d(v,{key:0,title:e.$t("hrm_dashboard.you_are_on_leave")},null,8,["title"])):t.attendanceData.office_hours_expired?(s(),d(v,{key:1,title:e.$t("hrm_dashboard.office_hours_expired")},null,8,["title"])):(s(),I("div",tt,[c(_,null,{default:n(()=>[c(u,{xs:12,sm:12,md:12,lg:12,xl:12},{default:n(()=>[c(k,{level:5},{default:n(()=>[f(i(e.$t("hrm_dashboard.current_ip_address")),1)]),_:1}),A("p",null,i(t.ipAddress),1)]),_:1}),c(u,{xs:12,sm:12,md:12,lg:12,xl:12},{default:n(()=>[c(k,{level:5},{default:n(()=>[f(i(e.$t("hrm_dashboard.current_time")),1)]),_:1}),A("p",null,i(t.currentTime),1)]),_:1})]),_:1}),t.isSelfClocking?(s(),d(_,{key:0,class:"mt-30",style:{textAlign:"center"}},{default:n(()=>[c(u,{span:24},{default:n(()=>[c(b,null,{default:n(()=>[t.showClockInButton?(s(),d(h,{key:0,type:"primary",onClick:a[0]||(a[0]=B=>t.markAttendance("clock-in")),loading:t.clockInLoading},{default:n(()=>[c(y),f(" "+i(e.$t("hrm_dashboard.clock_in")),1)]),_:1},8,["loading"])):(s(),d(h,{key:1,type:"primary",disabled:!0},{default:n(()=>[f(i(e.$t("hrm_dashboard.clocked_in"))+" : "+i(t.formatTime(t.clockInDateTime)),1)]),_:1})),t.showClockOutButton?(s(),d(h,{key:2,type:"primary",onClick:a[1]||(a[1]=B=>t.markAttendance("clock-out")),loading:t.clockOutLoading},{default:n(()=>[c(O),f(" "+i(e.$t("hrm_dashboard.clock_out")),1)]),_:1},8,["loading"])):(s(),d(h,{key:3,type:"primary",disabled:!0},{default:n(()=>[f(i(e.$t("hrm_dashboard.clocked_out"))+" : "+i(t.formatTime(t.clockOutDateTime)),1)]),_:1}))]),_:1})]),_:1})]),_:1})):(s(),d(_,{key:1,class:"mt-30",style:{textAlign:"center"}},{default:n(()=>[c(u,{span:24},{default:n(()=>[c(w,{type:"danger",strong:""},{default:n(()=>[f(i(e.$t("hrm_dashboard.self_clocking_is_disabled")),1)]),_:1})]),_:1})]),_:1}))]))]))}const nt=H($,[["render",et]]);export{x as C,nt as M};
