import{j as a,D as x,e as u,B as g,S as h,f,h as j,i as b,k as w,I as D,r as d}from"./main-C5rJoLCl.js";import"./separator-CJhMgss0.js";import{D as k}from"./layout-2E7L6V5j.js";import{D as t}from"./data-table-column-header-Bzq2hgMJ.js";import{X as C}from"./dialog-DoT6WXg8.js";import{D as S}from"./data-table-C_-HmCg7.js";import{F as y}from"./FetchWrapper-DZ79aYT8.js";import"./table-C_lg7wFA.js";import"./chevrons-up-down-DCCBwKIg.js";import"./spinner-zDOxBldC.js";const N=[{accessorKey:"date",header:({column:s})=>a.jsx(t,{column:s,title:"Date"}),cell:({row:s})=>a.jsx("div",{children:s.getValue("date")}),enableSorting:!1,enableHiding:!1},{accessorKey:"clickId",header:({column:s})=>a.jsx(t,{column:s,title:"Click ID"}),cell:({row:s})=>a.jsx("div",{className:"w-[80px]",children:s.getValue("clickId")}),enableSorting:!1,enableHiding:!1},{accessorKey:"campaign_name",header:({column:s})=>a.jsx(t,{column:s,title:"Campaign"}),cell:({row:s})=>a.jsx("div",{children:s.getValue("campaign_name")}),enableSorting:!1,enableHiding:!1},{accessorKey:"device_info",header:({column:s})=>a.jsx(t,{column:s,title:"Device"}),cell:({row:s})=>{const e=s.getValue("device_info");return a.jsx("div",{children:(e==null?void 0:e.device)||"Unknown"})},enableSorting:!1,enableHiding:!1},{accessorKey:"device_os",header:({column:s})=>a.jsx(t,{column:s,title:"OS"}),cell:({row:s})=>{const e=s.getValue("device_info");return a.jsx("div",{className:"flex items-center gap-2",children:a.jsx("img",{className:"w-[32px]",src:`/wp-content/plugins/linkfiliate/assets/icons/os/${e==null?void 0:e.os}.png`,alt:(e==null?void 0:e.os)||"Unknown",title:`${e==null?void 0:e.os} ${e==null?void 0:e.os_version}`})})},enableSorting:!1,enableHiding:!1},{accessorKey:"device_browser",header:({column:s})=>a.jsx(t,{column:s,title:"Browser"}),cell:({row:s})=>{const e=s.getValue("device_info");return a.jsx("div",{className:"flex items-center gap-2",children:a.jsx("img",{className:"w-[32px]",src:`/wp-content/plugins/linkfiliate/assets/icons/browsers/${e==null?void 0:e.browser}.png`,alt:(e==null?void 0:e.browser)||"Unknown",title:`${e==null?void 0:e.browser} ${e==null?void 0:e.browser_version}`})})},enableSorting:!1,enableHiding:!1},{accessorKey:"ip_address",header:({column:s})=>a.jsx(t,{column:s,title:"IP Address"}),cell:({row:s})=>a.jsx("div",{className:"w-[80px]",children:s.getValue("ip_address")}),enableSorting:!1,enableHiding:!1}];function V({table:s}){return a.jsxs(x,{children:[a.jsx(u,{asChild:!0,children:a.jsxs(g,{variant:"outline",size:"sm",className:"ml-auto hidden h-8 lg:flex",children:[a.jsx(h,{}),"View"]})}),a.jsxs(f,{align:"end",className:"w-[150px]",children:[a.jsx(j,{children:"Toggle columns"}),a.jsx(b,{}),s.getAllColumns().filter(e=>typeof e.accessorFn<"u"&&e.getCanHide()).map(e=>a.jsx(w,{className:"capitalize",checked:e.getIsVisible(),onCheckedChange:l=>e.toggleVisibility(!!l),children:e.id},e.id))]})]})}function v({table:s}){var l;const e=s.getState().columnFilters.length>0;return a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[a.jsx(D,{placeholder:"Filter Click ID...",value:((l=s.getColumn("clickId"))==null?void 0:l.getFilterValue())??"",onChange:r=>{var n;return(n=s.getColumn("clickId"))==null?void 0:n.setFilterValue(r.target.value)},className:"h-8 w-[150px] lg:w-[250px]"}),e&&a.jsxs(g,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:["Reset",a.jsx(C,{})]})]}),a.jsx(V,{table:s})]})}function A(){const[s,e]=d.useState([]),[l,r]=d.useState(!0);d.useEffect(()=>{document.title="ClickLog";const i=async()=>{r(!0);const m=new y(linkfiliate==null?void 0:linkfiliate.pluginApiUrl,linkfiliate==null?void 0:linkfiliate.nonce);try{const o=new URLSearchParams;m.post("/clicklog",o.toString(),{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}).then(c=>{e(c.data),r(!1)}).catch(c=>{console.error("Error fetching data:",c),r(!1)})}catch(o){console.error("Error:",o),r(!1)}};i();const p=setInterval(i,2e4);return()=>clearInterval(p)},[]);const n=[{name:"Dashboard",href:"#/dashboard"},{name:"Clicklog"}];return a.jsx(k,{breadcrumb:n,children:a.jsx("div",{className:"space-y-6 p-4",children:a.jsx(S,{data:s,columns:N,toolbar:i=>a.jsx(v,{table:i}),isLoading:l})})})}export{A as default};
//# sourceMappingURL=index-MY31hnEH.js.map
