@oneclick.dev/cms-core-modules 0.0.83 → 0.0.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/{ContentEditor-CxKirDdL.mjs → ContentEditor-C5ydvk8b.mjs} +7067 -5886
  2. package/dist/{ContentEditor-CRFkD4tE.js → ContentEditor-DiveHwSJ.js} +43 -43
  3. package/dist/{Create-CsqVYhPO.mjs → Create-6uT9HWar.mjs} +35 -35
  4. package/dist/{Create-ip0MnS0o.js → Create-DuZ5nZrX.js} +1 -1
  5. package/dist/{DateFormatter-CvOfaUnU.mjs → DateFormatter-2B0R-DY4.mjs} +204 -400
  6. package/dist/DateFormatter-DbtOLV0L.js +1 -0
  7. package/dist/{Detail-RMXFuSRQ.js → Detail-BZ-iE9vf.js} +1 -1
  8. package/dist/{Detail-B4b_FLDa.mjs → Detail-C1Blq61w.mjs} +90 -90
  9. package/dist/{Detail-BayNaAg9.js → Detail-C8wQiDcv.js} +1 -1
  10. package/dist/{Detail-CbLk1v37.mjs → Detail-CJVMJDP7.mjs} +17 -17
  11. package/dist/{Detail-CnK-qbhE.js → Detail-CPqug27l.js} +1 -1
  12. package/dist/Detail-CjuhjPby.js +1 -0
  13. package/dist/{Detail-U0mgLKt6.mjs → Detail-CtItxMX4.mjs} +62 -63
  14. package/dist/{Detail-CVgWHbMC.mjs → Detail-Dnpnmy4-.mjs} +158 -158
  15. package/dist/{Entries-D7MHylQE.mjs → Entries-BkOPae4R.mjs} +49 -49
  16. package/dist/Entries-CcEW98F5.js +1 -0
  17. package/dist/{Find-XPcJxeRH.mjs → Find-Bd1uLqSa.mjs} +55 -55
  18. package/dist/Find-D4Qa45qC.js +1 -0
  19. package/dist/{NewReservationDialog.vue_vue_type_script_setup_true_lang-CDc8MIq2.mjs → NewReservationDialog.vue_vue_type_script_setup_true_lang-Bc946oSc.mjs} +1 -1
  20. package/dist/{NewReservationDialog.vue_vue_type_script_setup_true_lang-StaNp-3y.js → NewReservationDialog.vue_vue_type_script_setup_true_lang-CqERfyYb.js} +1 -1
  21. package/dist/{Overview-CwCAeBnX.js → Overview-CA8wh_BI.js} +1 -1
  22. package/dist/{Overview-CgViRnNc.mjs → Overview-D4MFwRI_.mjs} +67 -68
  23. package/dist/{Overview-B2bFNGhH.js → Overview-Da0XexiT.js} +1 -1
  24. package/dist/Overview-DeQQ0FY3.js +1 -0
  25. package/dist/{Overview--XpvBbqz.mjs → Overview-DoOASlNz.mjs} +1 -3
  26. package/dist/{Overview-Cczt_dcE.mjs → Overview-gJSvftdE.mjs} +34 -34
  27. package/dist/{ReservationDetailDialog.vue_vue_type_script_setup_true_lang-B7ks5mbf.mjs → ReservationDetailDialog.vue_vue_type_script_setup_true_lang-Cohhnd5x.mjs} +0 -1
  28. package/dist/{ReservationDetailDialog.vue_vue_type_script_setup_true_lang-Vxubki_v.js → ReservationDetailDialog.vue_vue_type_script_setup_true_lang-VWVIxIr6.js} +1 -1
  29. package/dist/{SeoHealth-ZpvB7CS2.mjs → SeoHealth-Bc5chnaa.mjs} +14 -14
  30. package/dist/{SeoHealth-DFZ0LLBH.js → SeoHealth-BkpJ1F2Y.js} +1 -1
  31. package/dist/TableView-Ei_w_-bn.mjs +5745 -0
  32. package/dist/TableView-klOTPJKZ.js +4 -0
  33. package/dist/View-BaFlMcM6.js +1 -0
  34. package/dist/View-C4MBWRlA.mjs +28 -0
  35. package/dist/{agenda-Cl3s_FIE.mjs → agenda-C5grvzSa.mjs} +166 -169
  36. package/dist/agenda-DXMwVWpN.js +1 -0
  37. package/dist/{availability-B-tRp8hB.mjs → availability-C1NqOFsQ.mjs} +81 -81
  38. package/dist/{availability-BiBbzEIM.js → availability-D_wnfLsH.js} +1 -1
  39. package/dist/cms-core-modules.css +1 -1
  40. package/dist/{exceptions-DQPSFSj7.mjs → exceptions-BIwMhYa4.mjs} +1 -1
  41. package/dist/{exceptions-BA3PsW4n.js → exceptions-Cn7zooEu.js} +1 -1
  42. package/dist/{index-CBC9dWZ9.js → index-C9pSS15N.js} +2 -2
  43. package/dist/{index-YOOlBEZB.mjs → index-MwjeLHPP.mjs} +3 -3
  44. package/dist/index.cjs.js +1 -1
  45. package/dist/index.mjs +23 -23
  46. package/dist/{orders-DZzdsHOW.mjs → orders-DhQ2EFXS.mjs} +157 -157
  47. package/dist/orders-V1pch_ih.js +1 -0
  48. package/dist/server-handlers.cjs.js +1 -1
  49. package/dist/server-handlers.mjs +142 -147
  50. package/package.json +2 -2
  51. package/dist/DateFormatter-ls6HfWpS.js +0 -1
  52. package/dist/Detail-BcboL7NF.js +0 -1
  53. package/dist/Entries-BPkZ7Jg5.js +0 -1
  54. package/dist/Find-Ds6OvuH6.js +0 -1
  55. package/dist/Overview-B-8TLLjh.js +0 -1
  56. package/dist/TableView-BUPPcHUW.mjs +0 -89505
  57. package/dist/TableView-CksiPsTL.js +0 -586
  58. package/dist/View-DDXN0tKD.mjs +0 -25
  59. package/dist/View-DfzaVOzS.js +0 -1
  60. package/dist/agenda-rlFma_wn.js +0 -1
  61. package/dist/floating-ui.dom-B9WYoHj2.js +0 -1
  62. package/dist/floating-ui.dom-fpIfhXTZ.mjs +0 -1291
  63. package/dist/index-DYpruS-A-Cw57iwdY.mjs +0 -4210
  64. package/dist/index-DYpruS-A-DwDXo9Tq.js +0 -88
  65. package/dist/index-YMaY4uuk-BgpTtr73.js +0 -1
  66. package/dist/index-YMaY4uuk-C_xV5K9Z.mjs +0 -1300
  67. package/dist/orders-tP4WdF5q.js +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),F=require("@oneclick.dev/cms-kit");require("./index-BuzLn4Km.js");const D=require("./index-DYpruS-A-DwDXo9Tq.js"),a=require("lucide-vue-next"),c=require("./index-DQYBP8Js.js"),N=require("./index-C4YUVWzJ.js"),Y={class:"w-full max-w-7xl mx-auto py-8 px-4 space-y-6"},Z={class:"flex items-center justify-between"},J={class:"text-muted-foreground text-sm mt-1"},Q={key:0,class:"flex items-center gap-2"},ee={class:"flex items-center border rounded-lg overflow-hidden"},te=["onClick"],oe={class:"text-sm text-destructive font-medium"},se={key:2,class:"flex items-center justify-center py-20"},ae={class:"flex items-start justify-between"},ne={class:"flex items-center gap-2"},le={class:"text-sm font-medium"},re={class:"grid grid-cols-2 @sm:grid-cols-4 gap-4"},ce={class:"flex items-center gap-1.5 text-muted-foreground mb-2"},ie={class:"text-xs font-medium uppercase tracking-wide"},de={class:"text-2xl font-semibold tabular-nums"},ue={key:0,class:"flex items-center gap-1 mt-1"},me={class:"grid @lg:grid-cols-2 gap-6"},pe={class:"grid @lg:grid-cols-2 gap-6"},fe={class:"divide-y"},xe={class:"flex items-center gap-3 min-w-0"},ve={class:"text-muted-foreground w-5 text-right shrink-0"},ge={class:"truncate font-mono text-xs"},he={class:"flex items-center gap-4 shrink-0 tabular-nums"},Ve={class:"text-muted-foreground text-xs w-16 text-right"},Ne={class:"text-muted-foreground text-xs w-16 text-right"},_e={key:0,class:"px-6 py-8 text-center text-muted-foreground text-sm"},ye={class:"divide-y"},Ce={class:"flex items-center gap-3 min-w-0"},we={class:"text-muted-foreground w-5 text-right shrink-0"},ke={class:"truncate"},be={class:"flex items-center gap-4 shrink-0 tabular-nums"},Ee={class:"text-muted-foreground text-xs w-20 text-right"},Be={key:0,class:"px-6 py-8 text-center text-muted-foreground text-sm"},De={class:"grid @lg:grid-cols-2 gap-6"},Se={class:"space-y-3"},Te={class:"text-sm capitalize flex-1"},$e={class:"flex-1 h-2 bg-muted rounded-full overflow-hidden"},Pe={class:"text-xs tabular-nums text-muted-foreground w-16 text-right"},Ue={key:0,class:"py-4 text-center text-muted-foreground text-sm"},Fe={class:"space-y-3"},ze={class:"text-sm flex-1"},Re={class:"flex-1 h-2 bg-muted rounded-full overflow-hidden"},Me={class:"text-xs tabular-nums text-muted-foreground w-16 text-right"},Ae={key:0,class:"py-4 text-center text-muted-foreground text-sm"},Le=e.defineComponent({__name:"Overview",setup(qe){const{config:S}=F.useModule(),{moduleId:G}=F.useModuleRoute();F.useModuleBreadcrumbs(()=>[{label:"Overview"}]);const x=e.ref(!0),_=e.ref(null),y=e.ref("30"),h=e.ref([]),r=e.ref({}),I=e.ref({}),i=e.ref({}),z=e.ref(0),T=e.ref([]),$=e.ref([]),C=e.ref([]),w=e.ref([]),k=e.computed(()=>!!(S.serviceAccount&&S.propertyId));function v(s){return`/api/v1/modules/${G}${s}`}const O=[{label:"7 days",value:"7"},{label:"14 days",value:"14"},{label:"30 days",value:"30"},{label:"90 days",value:"90"}],m={sessions:"#3b82f6",users:"#8b5cf6",pageViews:"#10b981"},P={sessions:{label:"Sessions",color:m.sessions},totalUsers:{label:"Users",color:m.users}},U={screenPageViews:{label:"Page Views",color:m.pageViews}},V=(s,t)=>t,R=s=>s.sessions||0,X=s=>s.totalUsers||0,M=s=>s.screenPageViews||0,A=s=>{const t=h.value[Math.round(s)];if(!t)return"";const l=new Date(t.date);return`${l.getDate()}/${l.getMonth()+1}`},L=s=>{const t=h.value[Math.round(Number(s))];return t?new Date(t.date).toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"}):""},W=e.computed(()=>[{label:"Sessions",value:d(r.value.sessions||0),icon:a.MousePointerClick,change:i.value.sessions},{label:"Users",value:d(r.value.totalUsers||0),icon:a.Users,change:i.value.totalUsers},{label:"Page Views",value:d(r.value.screenPageViews||0),icon:a.Eye,change:i.value.screenPageViews},{label:"Avg. Duration",value:H(r.value.averageSessionDuration||0),icon:a.Clock,change:i.value.averageSessionDuration},{label:"Engagement",value:`${((r.value.engagementRate||0)*100).toFixed(1)}%`,icon:a.Zap,change:i.value.engagementRate,positive:!0},{label:"Bounce Rate",value:`${((r.value.bounceRate||0)*100).toFixed(1)}%`,icon:(r.value.bounceRate||0)>.5?a.TrendingDown:a.TrendingUp,change:i.value.bounceRate,positive:!1},{label:"New Users",value:d(r.value.newUsers||0),icon:a.UserPlus,change:i.value.newUsers},{label:"Pages / Session",value:(r.value.screenPageViewsPerSession||0).toFixed(1),icon:a.Activity,change:i.value.screenPageViewsPerSession}]);function d(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:Math.round(s).toString()}function H(s){const t=Math.floor(s/60),l=Math.round(s%60);return t>0?`${t}m ${l}s`:`${l}s`}function b(s,t=!0){if(s==null)return{text:"—",cls:"text-muted-foreground",icon:a.Minus};const n=`${Math.abs(s).toFixed(1)}%`,f=s>0;return{text:n,cls:(t?f:!f)?"text-emerald-600 dark:text-emerald-400":"text-red-500 dark:text-red-400",icon:f?a.TrendingUp:a.TrendingDown}}function K(s){const t=s.toLowerCase();return t==="mobile"?a.Smartphone:t==="tablet"?a.Tablet:a.Monitor}async function E(){if(!k.value)return;x.value=!0,_.value=null;const s=`${y.value}daysAgo`;try{const[t,l,n,f,u,p]=await Promise.all([$fetch(v(`/report?startDate=${s}&endDate=today`)),$fetch(v("/realtime")).catch(()=>({activeUsers:0})),$fetch(v(`/top-pages?startDate=${s}&endDate=today&limit=10`)),$fetch(v(`/top-sources?startDate=${s}&endDate=today`)),$fetch(v(`/devices?startDate=${s}&endDate=today`)),$fetch(v(`/countries?startDate=${s}&endDate=today`))]);h.value=t.rows||[],r.value=t.totals||{},I.value=t.previousTotals||{},i.value=t.changes||{},z.value=l.activeUsers||0,T.value=n.rows||[],$.value=f.rows||[],C.value=u.rows||[],w.value=p.rows||[]}catch(t){console.error("Failed to fetch analytics data:",t),_.value=t?.data?.statusMessage||t?.message||"Failed to load analytics data"}finally{x.value=!1}}return e.watch(y,()=>E()),e.onMounted(()=>{k.value?E():x.value=!1}),(s,t)=>{const l=e.resolveComponent("Button"),n=e.resolveComponent("Card"),f=e.resolveComponent("Badge"),u=e.resolveComponent("CardTitle"),p=e.resolveComponent("CardHeader"),q=e.resolveComponent("ChartLegendContent"),j=e.resolveComponent("ChartContainer"),g=e.resolveComponent("CardContent");return e.openBlock(),e.createElementBlock("div",Y,[e.createElementVNode("div",Z,[e.createElementVNode("div",null,[t[0]||(t[0]=e.createElementVNode("h1",{class:"text-2xl font-semibold"},"Analytics Overview",-1)),e.createElementVNode("p",J,"Property "+e.toDisplayString(e.unref(S).propertyId||"—"),1)]),k.value?(e.openBlock(),e.createElementBlock("div",Q,[e.createElementVNode("div",ee,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(O,o=>e.createElementVNode("button",{key:o.value,class:e.normalizeClass(["px-3 py-1.5 text-xs font-medium transition-colors",y.value===o.value?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"]),onClick:B=>y.value=o.value},e.toDisplayString(o.label),11,te)),64))]),e.createVNode(l,{variant:"outline",size:"icon",onClick:E,disabled:x.value},{default:e.withCtx(()=>[e.createVNode(e.unref(a.RefreshCw),{class:e.normalizeClass(["size-4",{"animate-spin":x.value}])},null,8,["class"])]),_:1},8,["disabled"])])):e.createCommentVNode("",!0)]),k.value?_.value?(e.openBlock(),e.createBlock(n,{key:1,class:"p-6 border-destructive/50 bg-destructive/5"},{default:e.withCtx(()=>[e.createElementVNode("p",oe,e.toDisplayString(_.value),1),e.createVNode(l,{variant:"outline",size:"sm",class:"mt-3",onClick:E},{default:e.withCtx(()=>[...t[2]||(t[2]=[e.createTextVNode("Retry",-1)])]),_:1})]),_:1})):x.value?(e.openBlock(),e.createElementBlock("div",se,[e.createVNode(e.unref(a.Loader2),{class:"size-8 animate-spin text-muted-foreground"})])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createVNode(n,{class:"p-4"},{default:e.withCtx(()=>[e.createElementVNode("div",ae,[e.createElementVNode("div",ne,[t[3]||(t[3]=e.createElementVNode("span",{class:"relative flex h-2.5 w-2.5"},[e.createElementVNode("span",{class:"animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"}),e.createElementVNode("span",{class:"relative inline-flex rounded-full h-2.5 w-2.5 bg-green-500"})],-1)),e.createElementVNode("span",le,e.toDisplayString(z.value)+" visitors",1),t[4]||(t[4]=e.createElementVNode("span",{class:"text-xs text-muted-foreground translate-y-0.25"},"in the last 30 minutes",-1))]),e.createVNode(f,{variant:"outline",class:"text-xs"},{default:e.withCtx(()=>[...t[5]||(t[5]=[e.createTextVNode("Live",-1)])]),_:1})])]),_:1}),e.createElementVNode("div",re,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(W.value,o=>(e.openBlock(),e.createBlock(n,{key:o.label,class:"p-4"},{default:e.withCtx(()=>[e.createElementVNode("div",ce,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.icon),{class:"size-3.5"})),e.createElementVNode("span",ie,e.toDisplayString(o.label),1)]),e.createElementVNode("p",de,e.toDisplayString(o.value),1),o.change!==void 0?(e.openBlock(),e.createElementBlock("div",ue,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(b(o.change,o.positive!==!1).icon),{class:e.normalizeClass(["size-3",b(o.change,o.positive!==!1).cls])},null,8,["class"])),e.createElementVNode("span",{class:e.normalizeClass(["text-xs font-medium",b(o.change,o.positive!==!1).cls])},e.toDisplayString(b(o.change,o.positive!==!1).text),3),t[6]||(t[6]=e.createElementVNode("span",{class:"text-xs text-muted-foreground"},"vs prev.",-1))])):e.createCommentVNode("",!0)]),_:2},1024))),128))]),e.createElementVNode("div",me,[e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[7]||(t[7]=[e.createTextVNode("Sessions & Users",-1)])]),_:1})]),_:1}),e.createVNode(g,null,{default:e.withCtx(()=>[e.createVNode(j,{config:P,class:"h-[240px] w-full"},{default:e.withCtx(()=>[e.createVNode(e.unref(c.S),{data:h.value,margin:{top:8,right:8,bottom:24,left:40}},{default:e.withCtx(()=>[e.createVNode(e.unref(N.C),{x:V,y:R,color:m.sessions,opacity:.1,curveType:"monotoneX"},null,8,["color"]),e.createVNode(e.unref(N.C$1),{x:V,y:R,color:m.sessions,lineWidth:2,curveType:"monotoneX"},null,8,["color"]),e.createVNode(e.unref(N.C$1),{x:V,y:X,color:m.users,lineWidth:2,curveType:"monotoneX"},null,8,["color"]),e.createVNode(e.unref(c.C),{type:"x",tickFormat:A,numTicks:6}),e.createVNode(e.unref(c.C),{type:"y",numTicks:4}),e.createVNode(e.unref(c.A),{template:e.unref(D.st)(P,e.unref(D.Ue),{labelFormatter:L})},null,8,["template"]),e.createVNode(e.unref(c.z))]),_:1},8,["data"]),e.createVNode(q,{config:P})]),_:1})]),_:1})]),_:1}),e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[8]||(t[8]=[e.createTextVNode("Page Views",-1)])]),_:1})]),_:1}),e.createVNode(g,null,{default:e.withCtx(()=>[e.createVNode(j,{config:U,class:"h-[240px] w-full"},{default:e.withCtx(()=>[e.createVNode(e.unref(c.S),{data:h.value,margin:{top:8,right:8,bottom:24,left:40}},{default:e.withCtx(()=>[e.createVNode(e.unref(N.C),{x:V,y:M,color:m.pageViews,opacity:.15,curveType:"monotoneX"},null,8,["color"]),e.createVNode(e.unref(N.C$1),{x:V,y:M,color:m.pageViews,lineWidth:2,curveType:"monotoneX"},null,8,["color"]),e.createVNode(e.unref(c.C),{type:"x",tickFormat:A,numTicks:6}),e.createVNode(e.unref(c.C),{type:"y",numTicks:4}),e.createVNode(e.unref(c.A),{template:e.unref(D.st)(U,e.unref(D.Ue),{labelFormatter:L})},null,8,["template"]),e.createVNode(e.unref(c.z))]),_:1},8,["data"]),e.createVNode(q,{config:U})]),_:1})]),_:1})]),_:1})]),e.createElementVNode("div",pe,[e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[9]||(t[9]=[e.createTextVNode("Top Pages",-1)])]),_:1})]),_:1}),e.createVNode(g,{class:"p-0"},{default:e.withCtx(()=>[e.createElementVNode("div",fe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.value,(o,B)=>(e.openBlock(),e.createElementBlock("div",{key:o.pagePath,class:"flex items-center justify-between px-6 py-3 text-sm"},[e.createElementVNode("div",xe,[e.createElementVNode("span",ve,e.toDisplayString(B+1),1),e.createElementVNode("span",ge,e.toDisplayString(o.pagePath),1)]),e.createElementVNode("div",he,[e.createElementVNode("span",Ve,e.toDisplayString(d(o.screenPageViews))+" views",1),e.createElementVNode("span",Ne,e.toDisplayString(d(o.totalUsers))+" users",1)])]))),128)),T.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",_e,"No data available"))])]),_:1})]),_:1}),e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[10]||(t[10]=[e.createTextVNode("Traffic Sources",-1)])]),_:1})]),_:1}),e.createVNode(g,{class:"p-0"},{default:e.withCtx(()=>[e.createElementVNode("div",ye,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList($.value,(o,B)=>(e.openBlock(),e.createElementBlock("div",{key:o.sessionSource,class:"flex items-center justify-between px-6 py-3 text-sm"},[e.createElementVNode("div",Ce,[e.createElementVNode("span",we,e.toDisplayString(B+1),1),e.createVNode(e.unref(a.ArrowUpRight),{class:"size-3.5 text-muted-foreground shrink-0"}),e.createElementVNode("span",ke,e.toDisplayString(o.sessionSource||"(direct)"),1)]),e.createElementVNode("div",be,[e.createElementVNode("span",Ee,e.toDisplayString(d(o.sessions))+" sessions",1)])]))),128)),$.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Be,"No data available"))])]),_:1})]),_:1})]),e.createElementVNode("div",De,[e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[11]||(t[11]=[e.createTextVNode("Devices",-1)])]),_:1})]),_:1}),e.createVNode(g,null,{default:e.withCtx(()=>[e.createElementVNode("div",Se,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(C.value,o=>(e.openBlock(),e.createElementBlock("div",{key:o.deviceCategory,class:"flex items-center gap-3"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(K(o.deviceCategory)),{class:"size-4 text-muted-foreground shrink-0"})),e.createElementVNode("span",Te,e.toDisplayString(o.deviceCategory),1),e.createElementVNode("div",$e,[e.createElementVNode("div",{class:"h-full bg-primary rounded-full transition-all",style:e.normalizeStyle({width:`${o.sessions/(C.value[0]?.sessions||1)*100}%`})},null,4)]),e.createElementVNode("span",Pe,e.toDisplayString(d(o.sessions)),1)]))),128)),C.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ue,"No data available"))])]),_:1})]),_:1}),e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[12]||(t[12]=[e.createTextVNode("Top Countries",-1)])]),_:1})]),_:1}),e.createVNode(g,null,{default:e.withCtx(()=>[e.createElementVNode("div",Fe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.value,o=>(e.openBlock(),e.createElementBlock("div",{key:o.country,class:"flex items-center gap-3"},[e.createVNode(e.unref(a.Globe),{class:"size-4 text-muted-foreground shrink-0"}),e.createElementVNode("span",ze,e.toDisplayString(o.country),1),e.createElementVNode("div",Re,[e.createElementVNode("div",{class:"h-full bg-primary rounded-full transition-all",style:e.normalizeStyle({width:`${o.sessions/(w.value[0]?.sessions||1)*100}%`})},null,4)]),e.createElementVNode("span",Me,e.toDisplayString(d(o.sessions)),1)]))),128)),w.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ae,"No data available"))])]),_:1})]),_:1})])],64)):(e.openBlock(),e.createBlock(n,{key:0,class:"p-8 text-center"},{default:e.withCtx(()=>[...t[1]||(t[1]=[e.createElementVNode("div",{class:"mx-auto max-w-md space-y-3"},[e.createElementVNode("p",{class:"text-lg font-medium"},"Setup required"),e.createElementVNode("p",{class:"text-sm text-muted-foreground"},"Connect a Google Service Account and enter your GA4 Property ID in the module settings to start seeing analytics.")],-1)])]),_:1}))])}}});exports.default=Le;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),U=require("@oneclick.dev/cms-kit");require("./index-BuzLn4Km.js");const D=require("@oneclick.dev/cms-kit/charts"),a=require("lucide-vue-next"),c=require("./index-DQYBP8Js.js"),N=require("./index-C4YUVWzJ.js"),Z={class:"w-full max-w-7xl mx-auto py-8 px-4 space-y-6"},J={class:"flex items-center justify-between"},Q={class:"text-muted-foreground text-sm mt-1"},Y={key:0,class:"flex items-center gap-2"},ee={class:"flex items-center border rounded-lg overflow-hidden"},te=["onClick"],oe={class:"text-sm text-destructive font-medium"},se={key:2,class:"flex items-center justify-center py-20"},ae={class:"flex items-start justify-between"},ne={class:"flex items-center gap-2"},le={class:"text-sm font-medium"},re={class:"grid grid-cols-2 @sm:grid-cols-4 gap-4"},ce={class:"flex items-center gap-1.5 text-muted-foreground mb-2"},ie={class:"text-xs font-medium uppercase tracking-wide"},de={class:"text-2xl font-semibold tabular-nums"},ue={key:0,class:"flex items-center gap-1 mt-1"},me={class:"grid @lg:grid-cols-2 gap-6"},pe={class:"grid @lg:grid-cols-2 gap-6"},fe={class:"divide-y"},xe={class:"flex items-center gap-3 min-w-0"},ge={class:"text-muted-foreground w-5 text-right shrink-0"},ve={class:"truncate font-mono text-xs"},he={class:"flex items-center gap-4 shrink-0 tabular-nums"},Ve={class:"text-muted-foreground text-xs w-16 text-right"},Ne={class:"text-muted-foreground text-xs w-16 text-right"},_e={key:0,class:"px-6 py-8 text-center text-muted-foreground text-sm"},ye={class:"divide-y"},Ce={class:"flex items-center gap-3 min-w-0"},we={class:"text-muted-foreground w-5 text-right shrink-0"},ke={class:"truncate"},be={class:"flex items-center gap-4 shrink-0 tabular-nums"},Ee={class:"text-muted-foreground text-xs w-20 text-right"},Be={key:0,class:"px-6 py-8 text-center text-muted-foreground text-sm"},De={class:"grid @lg:grid-cols-2 gap-6"},Se={class:"space-y-3"},Te={class:"text-sm capitalize flex-1"},$e={class:"flex-1 h-2 bg-muted rounded-full overflow-hidden"},Pe={class:"text-xs tabular-nums text-muted-foreground w-16 text-right"},Fe={key:0,class:"py-4 text-center text-muted-foreground text-sm"},Ue={class:"space-y-3"},ze={class:"text-sm flex-1"},Re={class:"flex-1 h-2 bg-muted rounded-full overflow-hidden"},Me={class:"text-xs tabular-nums text-muted-foreground w-16 text-right"},Ae={key:0,class:"py-4 text-center text-muted-foreground text-sm"},Le=e.defineComponent({__name:"Overview",setup(qe){const{config:S}=U.useModule(),{moduleId:G}=U.useModuleRoute();U.useModuleBreadcrumbs(()=>[{label:"Overview"}]);const x=e.ref(!0),_=e.ref(null),y=e.ref("30"),h=e.ref([]),r=e.ref({}),I=e.ref({}),i=e.ref({}),z=e.ref(0),T=e.ref([]),$=e.ref([]),C=e.ref([]),w=e.ref([]),k=e.computed(()=>!!(S.serviceAccount&&S.propertyId));function g(s){return`/api/v1/modules/${G}${s}`}const O=[{label:"7 days",value:"7"},{label:"14 days",value:"14"},{label:"30 days",value:"30"},{label:"90 days",value:"90"}],m={sessions:"#3b82f6",users:"#8b5cf6",pageViews:"#10b981"},P={sessions:{label:"Sessions",color:m.sessions},totalUsers:{label:"Users",color:m.users}},F={screenPageViews:{label:"Page Views",color:m.pageViews}},V=(s,t)=>t,R=s=>s.sessions||0,X=s=>s.totalUsers||0,M=s=>s.screenPageViews||0,A=s=>{const t=h.value[Math.round(s)];if(!t)return"";const l=new Date(t.date);return`${l.getDate()}/${l.getMonth()+1}`},L=s=>{const t=h.value[Math.round(Number(s))];return t?new Date(t.date).toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"}):""},W=e.computed(()=>[{label:"Sessions",value:d(r.value.sessions||0),icon:a.MousePointerClick,change:i.value.sessions},{label:"Users",value:d(r.value.totalUsers||0),icon:a.Users,change:i.value.totalUsers},{label:"Page Views",value:d(r.value.screenPageViews||0),icon:a.Eye,change:i.value.screenPageViews},{label:"Avg. Duration",value:H(r.value.averageSessionDuration||0),icon:a.Clock,change:i.value.averageSessionDuration},{label:"Engagement",value:`${((r.value.engagementRate||0)*100).toFixed(1)}%`,icon:a.Zap,change:i.value.engagementRate,positive:!0},{label:"Bounce Rate",value:`${((r.value.bounceRate||0)*100).toFixed(1)}%`,icon:(r.value.bounceRate||0)>.5?a.TrendingDown:a.TrendingUp,change:i.value.bounceRate,positive:!1},{label:"New Users",value:d(r.value.newUsers||0),icon:a.UserPlus,change:i.value.newUsers},{label:"Pages / Session",value:(r.value.screenPageViewsPerSession||0).toFixed(1),icon:a.Activity,change:i.value.screenPageViewsPerSession}]);function d(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:Math.round(s).toString()}function H(s){const t=Math.floor(s/60),l=Math.round(s%60);return t>0?`${t}m ${l}s`:`${l}s`}function b(s,t=!0){if(s==null)return{text:"—",cls:"text-muted-foreground",icon:a.Minus};const n=`${Math.abs(s).toFixed(1)}%`,f=s>0;return{text:n,cls:(t?f:!f)?"text-emerald-600 dark:text-emerald-400":"text-red-500 dark:text-red-400",icon:f?a.TrendingUp:a.TrendingDown}}function K(s){const t=s.toLowerCase();return t==="mobile"?a.Smartphone:t==="tablet"?a.Tablet:a.Monitor}async function E(){if(!k.value)return;x.value=!0,_.value=null;const s=`${y.value}daysAgo`;try{const[t,l,n,f,u,p]=await Promise.all([$fetch(g(`/report?startDate=${s}&endDate=today`)),$fetch(g("/realtime")).catch(()=>({activeUsers:0})),$fetch(g(`/top-pages?startDate=${s}&endDate=today&limit=10`)),$fetch(g(`/top-sources?startDate=${s}&endDate=today`)),$fetch(g(`/devices?startDate=${s}&endDate=today`)),$fetch(g(`/countries?startDate=${s}&endDate=today`))]);h.value=t.rows||[],r.value=t.totals||{},I.value=t.previousTotals||{},i.value=t.changes||{},z.value=l.activeUsers||0,T.value=n.rows||[],$.value=f.rows||[],C.value=u.rows||[],w.value=p.rows||[]}catch(t){console.error("Failed to fetch analytics data:",t),_.value=t?.data?.statusMessage||t?.message||"Failed to load analytics data"}finally{x.value=!1}}return e.watch(y,()=>E()),e.onMounted(()=>{k.value?E():x.value=!1}),(s,t)=>{const l=e.resolveComponent("Button"),n=e.resolveComponent("Card"),f=e.resolveComponent("Badge"),u=e.resolveComponent("CardTitle"),p=e.resolveComponent("CardHeader"),q=e.resolveComponent("ChartLegendContent"),j=e.resolveComponent("ChartContainer"),v=e.resolveComponent("CardContent");return e.openBlock(),e.createElementBlock("div",Z,[e.createElementVNode("div",J,[e.createElementVNode("div",null,[t[0]||(t[0]=e.createElementVNode("h1",{class:"text-2xl font-semibold"},"Analytics Overview",-1)),e.createElementVNode("p",Q,"Property "+e.toDisplayString(e.unref(S).propertyId||"—"),1)]),k.value?(e.openBlock(),e.createElementBlock("div",Y,[e.createElementVNode("div",ee,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(O,o=>e.createElementVNode("button",{key:o.value,class:e.normalizeClass(["px-3 py-1.5 text-xs font-medium transition-colors",y.value===o.value?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted"]),onClick:B=>y.value=o.value},e.toDisplayString(o.label),11,te)),64))]),e.createVNode(l,{variant:"outline",size:"icon",onClick:E,disabled:x.value},{default:e.withCtx(()=>[e.createVNode(e.unref(a.RefreshCw),{class:e.normalizeClass(["size-4",{"animate-spin":x.value}])},null,8,["class"])]),_:1},8,["disabled"])])):e.createCommentVNode("",!0)]),k.value?_.value?(e.openBlock(),e.createBlock(n,{key:1,class:"p-6 border-destructive/50 bg-destructive/5"},{default:e.withCtx(()=>[e.createElementVNode("p",oe,e.toDisplayString(_.value),1),e.createVNode(l,{variant:"outline",size:"sm",class:"mt-3",onClick:E},{default:e.withCtx(()=>[...t[2]||(t[2]=[e.createTextVNode("Retry",-1)])]),_:1})]),_:1})):x.value?(e.openBlock(),e.createElementBlock("div",se,[e.createVNode(e.unref(a.Loader2),{class:"size-8 animate-spin text-muted-foreground"})])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createVNode(n,{class:"p-4"},{default:e.withCtx(()=>[e.createElementVNode("div",ae,[e.createElementVNode("div",ne,[t[3]||(t[3]=e.createElementVNode("span",{class:"relative flex h-2.5 w-2.5"},[e.createElementVNode("span",{class:"animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"}),e.createElementVNode("span",{class:"relative inline-flex rounded-full h-2.5 w-2.5 bg-green-500"})],-1)),e.createElementVNode("span",le,e.toDisplayString(z.value)+" visitors",1),t[4]||(t[4]=e.createElementVNode("span",{class:"text-xs text-muted-foreground translate-y-0.25"},"in the last 30 minutes",-1))]),e.createVNode(f,{variant:"outline",class:"text-xs"},{default:e.withCtx(()=>[...t[5]||(t[5]=[e.createTextVNode("Live",-1)])]),_:1})])]),_:1}),e.createElementVNode("div",re,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(W.value,o=>(e.openBlock(),e.createBlock(n,{key:o.label,class:"p-4"},{default:e.withCtx(()=>[e.createElementVNode("div",ce,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.icon),{class:"size-3.5"})),e.createElementVNode("span",ie,e.toDisplayString(o.label),1)]),e.createElementVNode("p",de,e.toDisplayString(o.value),1),o.change!==void 0?(e.openBlock(),e.createElementBlock("div",ue,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(b(o.change,o.positive!==!1).icon),{class:e.normalizeClass(["size-3",b(o.change,o.positive!==!1).cls])},null,8,["class"])),e.createElementVNode("span",{class:e.normalizeClass(["text-xs font-medium",b(o.change,o.positive!==!1).cls])},e.toDisplayString(b(o.change,o.positive!==!1).text),3),t[6]||(t[6]=e.createElementVNode("span",{class:"text-xs text-muted-foreground"},"vs prev.",-1))])):e.createCommentVNode("",!0)]),_:2},1024))),128))]),e.createElementVNode("div",me,[e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[7]||(t[7]=[e.createTextVNode("Sessions & Users",-1)])]),_:1})]),_:1}),e.createVNode(v,null,{default:e.withCtx(()=>[e.createVNode(j,{config:P,class:"h-[240px] w-full"},{default:e.withCtx(()=>[e.createVNode(e.unref(c.S),{data:h.value,margin:{top:8,right:8,bottom:24,left:40}},{default:e.withCtx(()=>[e.createVNode(e.unref(N.C),{x:V,y:R,color:m.sessions,opacity:.1,curveType:"monotoneX"},null,8,["color"]),e.createVNode(e.unref(N.C$1),{x:V,y:R,color:m.sessions,lineWidth:2,curveType:"monotoneX"},null,8,["color"]),e.createVNode(e.unref(N.C$1),{x:V,y:X,color:m.users,lineWidth:2,curveType:"monotoneX"},null,8,["color"]),e.createVNode(e.unref(c.C),{type:"x",tickFormat:A,numTicks:6}),e.createVNode(e.unref(c.C),{type:"y",numTicks:4}),e.createVNode(e.unref(c.A),{template:e.unref(D.componentToString)(P,e.unref(D.ChartTooltipContent),{labelFormatter:L})},null,8,["template"]),e.createVNode(e.unref(c.z))]),_:1},8,["data"]),e.createVNode(q,{config:P})]),_:1})]),_:1})]),_:1}),e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[8]||(t[8]=[e.createTextVNode("Page Views",-1)])]),_:1})]),_:1}),e.createVNode(v,null,{default:e.withCtx(()=>[e.createVNode(j,{config:F,class:"h-[240px] w-full"},{default:e.withCtx(()=>[e.createVNode(e.unref(c.S),{data:h.value,margin:{top:8,right:8,bottom:24,left:40}},{default:e.withCtx(()=>[e.createVNode(e.unref(N.C),{x:V,y:M,color:m.pageViews,opacity:.15,curveType:"monotoneX"},null,8,["color"]),e.createVNode(e.unref(N.C$1),{x:V,y:M,color:m.pageViews,lineWidth:2,curveType:"monotoneX"},null,8,["color"]),e.createVNode(e.unref(c.C),{type:"x",tickFormat:A,numTicks:6}),e.createVNode(e.unref(c.C),{type:"y",numTicks:4}),e.createVNode(e.unref(c.A),{template:e.unref(D.componentToString)(F,e.unref(D.ChartTooltipContent),{labelFormatter:L})},null,8,["template"]),e.createVNode(e.unref(c.z))]),_:1},8,["data"]),e.createVNode(q,{config:F})]),_:1})]),_:1})]),_:1})]),e.createElementVNode("div",pe,[e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[9]||(t[9]=[e.createTextVNode("Top Pages",-1)])]),_:1})]),_:1}),e.createVNode(v,{class:"p-0"},{default:e.withCtx(()=>[e.createElementVNode("div",fe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.value,(o,B)=>(e.openBlock(),e.createElementBlock("div",{key:o.pagePath,class:"flex items-center justify-between px-6 py-3 text-sm"},[e.createElementVNode("div",xe,[e.createElementVNode("span",ge,e.toDisplayString(B+1),1),e.createElementVNode("span",ve,e.toDisplayString(o.pagePath),1)]),e.createElementVNode("div",he,[e.createElementVNode("span",Ve,e.toDisplayString(d(o.screenPageViews))+" views",1),e.createElementVNode("span",Ne,e.toDisplayString(d(o.totalUsers))+" users",1)])]))),128)),T.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",_e,"No data available"))])]),_:1})]),_:1}),e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[10]||(t[10]=[e.createTextVNode("Traffic Sources",-1)])]),_:1})]),_:1}),e.createVNode(v,{class:"p-0"},{default:e.withCtx(()=>[e.createElementVNode("div",ye,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList($.value,(o,B)=>(e.openBlock(),e.createElementBlock("div",{key:o.sessionSource,class:"flex items-center justify-between px-6 py-3 text-sm"},[e.createElementVNode("div",Ce,[e.createElementVNode("span",we,e.toDisplayString(B+1),1),e.createVNode(e.unref(a.ArrowUpRight),{class:"size-3.5 text-muted-foreground shrink-0"}),e.createElementVNode("span",ke,e.toDisplayString(o.sessionSource||"(direct)"),1)]),e.createElementVNode("div",be,[e.createElementVNode("span",Ee,e.toDisplayString(d(o.sessions))+" sessions",1)])]))),128)),$.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Be,"No data available"))])]),_:1})]),_:1})]),e.createElementVNode("div",De,[e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[11]||(t[11]=[e.createTextVNode("Devices",-1)])]),_:1})]),_:1}),e.createVNode(v,null,{default:e.withCtx(()=>[e.createElementVNode("div",Se,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(C.value,o=>(e.openBlock(),e.createElementBlock("div",{key:o.deviceCategory,class:"flex items-center gap-3"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(K(o.deviceCategory)),{class:"size-4 text-muted-foreground shrink-0"})),e.createElementVNode("span",Te,e.toDisplayString(o.deviceCategory),1),e.createElementVNode("div",$e,[e.createElementVNode("div",{class:"h-full bg-primary rounded-full transition-all",style:e.normalizeStyle({width:`${o.sessions/(C.value[0]?.sessions||1)*100}%`})},null,4)]),e.createElementVNode("span",Pe,e.toDisplayString(d(o.sessions)),1)]))),128)),C.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Fe,"No data available"))])]),_:1})]),_:1}),e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"pb-2"},{default:e.withCtx(()=>[e.createVNode(u,{class:"text-base"},{default:e.withCtx(()=>[...t[12]||(t[12]=[e.createTextVNode("Top Countries",-1)])]),_:1})]),_:1}),e.createVNode(v,null,{default:e.withCtx(()=>[e.createElementVNode("div",Ue,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.value,o=>(e.openBlock(),e.createElementBlock("div",{key:o.country,class:"flex items-center gap-3"},[e.createVNode(e.unref(a.Globe),{class:"size-4 text-muted-foreground shrink-0"}),e.createElementVNode("span",ze,e.toDisplayString(o.country),1),e.createElementVNode("div",Re,[e.createElementVNode("div",{class:"h-full bg-primary rounded-full transition-all",style:e.normalizeStyle({width:`${o.sessions/(w.value[0]?.sessions||1)*100}%`})},null,4)]),e.createElementVNode("span",Me,e.toDisplayString(d(o.sessions)),1)]))),128)),w.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ae,"No data available"))])]),_:1})]),_:1})])],64)):(e.openBlock(),e.createBlock(n,{key:0,class:"p-8 text-center"},{default:e.withCtx(()=>[...t[1]||(t[1]=[e.createElementVNode("div",{class:"mx-auto max-w-md space-y-3"},[e.createElementVNode("p",{class:"text-lg font-medium"},"Setup required"),e.createElementVNode("p",{class:"text-sm text-muted-foreground"},"Connect a Google Service Account and enter your GA4 Property ID in the module settings to start seeing analytics.")],-1)])]),_:1}))])}}});exports.default=Le;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),B=require("lucide-vue-next"),_=require("@oneclick.dev/cms-kit"),X=require("./index-CxETuRsG.js"),j=require("./utils-D6CaKJbp.js"),y=require("./index-ijdf0d9-.js"),J={class:"grid @md:grid-cols-2 @2xl:grid-cols-3 @3xl:grid-cols-4 @4xl:grid-cols-5 @5xl:grid-cols-6 gap-6"},Y=["onClick","onContextmenu"],Z=["src"],ee={class:"font-semibold"},te={class:"text-sm text-muted-foreground flex items-center gap-2"},oe={class:"flex items-center gap-2"},ne={key:0},le=e.defineComponent({__name:"GridView",props:{products:{type:Array,required:!0}},setup(T){const o=e.inject("selection"),{navigateTo:f}=_.useModuleRoute(),{hasPermission:g}=_.useModulePermissions(),v=(i,l)=>{const u=l.ctrlKey||l.metaKey;if(!l.shiftKey)if(u||o.value.length>0){const x=o.value.indexOf(i.id);x>-1?o.value.splice(x,1):o.value.push(i.id)}else o.value=[],f(i.id)},n=i=>{i.target.closest(".GRID_ITEM")||(o.value=[])},d=(i,l)=>{l.ctrlKey||l.metaKey?o.value.includes(i.id)?o.value.splice(o.value.indexOf(i.id),1):o.value.push(i.id):o.value.includes(i.id)||(o.value=[i.id])};return(i,l)=>(e.openBlock(),e.createElementBlock("div",{class:"@container mb-4 flex-1 select-none",onClick:l[0]||(l[0]=u=>o.value=[]),onContextmenu:n},[e.createElementVNode("div",J,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.products,u=>(e.openBlock(),e.createElementBlock("div",{key:u.id,onClick:e.withModifiers(k=>v(u,k),["stop"]),onContextmenu:k=>d(u,k),class:"GRID_ITEM cursor-pointer"},[e.createElementVNode("div",{class:e.normalizeClass(["aspect-square bg-muted rounded-xl overflow-hidden mb-2 transition-all duration-200",{"outline outline-4 outline-primary/50":e.unref(o).includes(u.id)}])},[u.featuredMedia?(e.openBlock(),e.createElementBlock("img",{key:0,src:u.featuredMedia,class:"w-full h-full object-cover pointer-events-none",draggable:"false"},null,8,Z)):e.createCommentVNode("",!0)],2),e.createElementVNode("div",null,[e.createElementVNode("p",ee,e.toDisplayString(u.title),1),e.createElementVNode("p",te,[e.createElementVNode("span",oe,[u.status==="published"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[l[1]||(l[1]=e.createElementVNode("span",{class:"block shrink-0 size-3 rounded-full bg-green-500"},null,-1)),l[2]||(l[2]=e.createTextVNode(" Published ",-1))],64)):u.status==="draft"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[l[3]||(l[3]=e.createElementVNode("span",{class:"block shrink-0 size-3 rounded-full bg-blue-500"},null,-1)),l[4]||(l[4]=e.createTextVNode(" Draft ",-1))],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[l[5]||(l[5]=e.createElementVNode("span",{class:"block shrink-0 size-3 rounded-full bg-gray-300"},null,-1)),l[6]||(l[6]=e.createTextVNode(" Archived ",-1))],64))]),u.variantsTotal>1?(e.openBlock(),e.createElementBlock("span",ne,"| "+e.toDisplayString(u.variantsTotal)+" variants",1)):e.createCommentVNode("",!0)])])],40,Y))),128))])],32))}}),re={class:"flex items-center gap-2"},se={key:0,class:"bg-green-500 text-green-950 px-2 py-1 rounded-lg text-xs"},ae={key:1,class:"bg-blue-500 text-blue-950 px-2 py-1 rounded-lg text-xs"},ie={key:2,class:"bg-gray-500 text-gray-950 px-2 py-1 rounded-lg text-xs"},ce=e.defineComponent({__name:"ListView",props:{products:{type:Array,required:!0}},setup(T){const o=e.inject("selection"),{navigateTo:f}=_.useModuleRoute(),{hasPermission:g}=_.useModulePermissions(),v=(n,d)=>{n?o.value.push(d):o.value=o.value.filter(i=>i!==d)};return(n,d)=>{const i=e.resolveComponent("TableHead"),l=e.resolveComponent("TableRow"),u=e.resolveComponent("TableHeader"),k=e.resolveComponent("Checkbox"),x=e.resolveComponent("TableCell"),m=e.resolveComponent("AvatarImage"),t=e.resolveComponent("AvatarFallback"),p=e.resolveComponent("Avatar"),C=e.resolveComponent("TableBody"),V=e.resolveComponent("Table"),N=e.resolveComponent("Card");return e.openBlock(),e.createBlock(N,{class:"w-full py-4 px-4"},{default:e.withCtx(()=>[e.createVNode(V,{class:"rounded overflow-hidden"},{default:e.withCtx(()=>[e.createVNode(u,null,{default:e.withCtx(()=>[e.createVNode(l,null,{default:e.withCtx(()=>[e.unref(o)?.length>0?(e.openBlock(),e.createBlock(i,{key:0})):e.createCommentVNode("",!0),e.createVNode(i,null,{default:e.withCtx(()=>[...d[1]||(d[1]=[e.createTextVNode("Title",-1)])]),_:1}),e.createVNode(i,null,{default:e.withCtx(()=>[...d[2]||(d[2]=[e.createTextVNode("Status",-1)])]),_:1}),e.createVNode(i,null,{default:e.withCtx(()=>[...d[3]||(d[3]=[e.createTextVNode(" Variants",-1)])]),_:1}),e.createVNode(i,null,{default:e.withCtx(()=>[...d[4]||(d[4]=[e.createTextVNode("Price",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(C,null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.products,c=>(e.openBlock(),e.createBlock(l,{key:c.id,onClick:w=>e.unref(f)(c.id),class:"cursor-pointer"},{default:e.withCtx(()=>[e.unref(o)?.length>0?(e.openBlock(),e.createBlock(x,{key:0},{default:e.withCtx(()=>[e.createVNode(k,{"model-value":e.unref(o)?.includes(c.id),"onUpdate:modelValue":w=>v(w,c.id),onClick:d[0]||(d[0]=e.withModifiers(()=>{},["prevent","stop"]))},null,8,["model-value","onUpdate:modelValue"])]),_:2},1024)):e.createCommentVNode("",!0),e.createVNode(x,{class:"font-medium"},{default:e.withCtx(()=>[e.createElementVNode("div",re,[e.createVNode(p,{class:"size-12 rounded-xl"},{default:e.withCtx(()=>[e.createVNode(m,{src:c.media?.[0],class:"object-cover"},null,8,["src"]),e.createVNode(t,{class:"rounded-xl"})]),_:2},1024),e.createElementVNode("span",null,e.toDisplayString(c.title),1)])]),_:2},1024),e.createVNode(x,null,{default:e.withCtx(()=>[c.status==="published"?(e.openBlock(),e.createElementBlock("span",se,"Published")):c.status==="draft"?(e.openBlock(),e.createElementBlock("span",ae,"Draft")):c.status==="archived"?(e.openBlock(),e.createElementBlock("span",ie,"Archived")):e.createCommentVNode("",!0)]),_:2},1024),e.createVNode(x,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(c.variantsTotal),1)]),_:2},1024),e.createVNode(x,{class:"text-right"},{default:e.withCtx(()=>[e.createTextVNode(" € "+e.toDisplayString(c.price||0),1)]),_:2},1024)]),_:2},1032,["onClick"]))),128))]),_:1})]),_:1})]),_:1})}}}),de={class:"truncate"},ue={key:0},me={key:1},pe={key:2},fe={key:3},ve={class:"relative w-full max-w-sm items-center"},Ce={class:"truncate"},xe={class:"truncate"},ge={class:"flex items-center space-x-2 mb-4"},Ve={class:"flex items-center space-x-2 mb-4"},Ne={class:"flex items-center space-x-2 mb-4"},ke=e.defineComponent({__name:"FilterPopover",setup(T){const o=e.inject("filter"),f=e.inject("collections"),g=()=>{o.value={collections:[],published:!0,draft:!0,archived:!1}};return(v,n)=>{const d=e.resolveComponent("Button"),i=e.resolveComponent("PopoverTrigger"),l=e.resolveComponent("ComboboxTrigger"),u=e.resolveComponent("ComboboxAnchor"),k=e.resolveComponent("ComboboxInput"),x=e.resolveComponent("ComboboxEmpty"),m=e.resolveComponent("ComboboxItemIndicator"),t=e.resolveComponent("ComboboxItem"),p=e.resolveComponent("ScrollArea"),C=e.resolveComponent("ComboboxGroup"),V=e.resolveComponent("ComboboxList"),N=e.resolveComponent("Combobox"),c=e.resolveComponent("Checkbox"),w=e.resolveComponent("PopoverContent"),h=e.resolveComponent("Popover");return e.openBlock(),e.createBlock(h,null,{default:e.withCtx(()=>[e.createVNode(i,{asChild:""},{default:e.withCtx(()=>[e.createVNode(d,{variant:"outline"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.Filter),{class:"size-4"}),n[4]||(n[4]=e.createTextVNode(" Filter ",-1))]),_:1})]),_:1}),e.createVNode(w,{class:"w-64"},{default:e.withCtx(()=>[n[14]||(n[14]=e.createElementVNode("p",{class:"text-sm font-medium text-muted-foreground mb-4"}," Filter by Collection ",-1)),e.createVNode(N,{modelValue:e.unref(o).collections,"onUpdate:modelValue":n[0]||(n[0]=s=>e.unref(o).collections=s),by:"id",multiple:!0,class:"mb-6"},{default:e.withCtx(()=>[e.createVNode(u,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(l,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(d,{variant:"outline",class:"justify-between w-full"},{default:e.withCtx(()=>[e.createElementVNode("span",de,[e.unref(o).collections.length===1?(e.openBlock(),e.createElementBlock("span",ue,e.toDisplayString(e.unref(f).find(s=>s.id===e.unref(o).collections[0])?.title),1)):e.unref(o).collections.length===2?(e.openBlock(),e.createElementBlock("span",me,e.toDisplayString(e.unref(f).find(s=>s.id===e.unref(o).collections[0])?.title)+", "+e.toDisplayString(e.unref(f).find(s=>s.id===e.unref(o).collections[1])?.title),1)):e.unref(o).collections.length>2?(e.openBlock(),e.createElementBlock("span",pe,e.toDisplayString(e.unref(f).find(s=>s.id===e.unref(o).collections[0])?.title)+", "+e.toDisplayString(e.unref(f).find(s=>s.id===e.unref(o).collections[1])?.title)+" + "+e.toDisplayString(e.unref(o).collections.length-2),1)):(e.openBlock(),e.createElementBlock("span",fe,"Select collection"))]),e.createVNode(e.unref(B.ChevronsUpDown),{class:"ml-2 size-4 shrink-0 opacity-50"})]),_:1})]),_:1})]),_:1}),e.createVNode(V,null,{default:e.withCtx(()=>[e.createElementVNode("div",ve,[e.createVNode(k,{placeholder:"Select category..."})]),e.createVNode(x,null,{default:e.withCtx(()=>[...n[5]||(n[5]=[e.createTextVNode(" No category found. ",-1)])]),_:1}),e.unref(f)?.filter(s=>s.status==="published")?.length>0?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[n[7]||(n[7]=e.createElementVNode("p",{class:"px-2 py-1.5 text-sm font-medium mt-2"},"Published",-1)),e.createVNode(C,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"max-h-[200px] overflow-y-auto"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(f).filter(s=>s.status==="published"),s=>(e.openBlock(),e.createBlock(t,{key:s.id,value:s.id},{default:e.withCtx(()=>[n[6]||(n[6]=e.createElementVNode("span",{class:"size-2 rounded-full bg-green-500"},null,-1)),e.createElementVNode("span",Ce,e.toDisplayString(s.title),1),e.createVNode(m,null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.Check),{class:e.normalizeClass(e.unref(j.classNames)("ml-auto size-4"))},null,8,["class"])]),_:1})]),_:2},1032,["value"]))),128))]),_:1})]),_:1})],64)):e.createCommentVNode("",!0),e.unref(f)?.filter(s=>s.status==="draft")?.length>0?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[n[9]||(n[9]=e.createElementVNode("p",{class:"px-2 py-1.5 text-sm font-medium"},"Drafts",-1)),e.createVNode(C,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"max-h-[200px] overflow-y-auto"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(f).filter(s=>s.status==="draft"),s=>(e.openBlock(),e.createBlock(t,{key:s.id,value:s.id},{default:e.withCtx(()=>[n[8]||(n[8]=e.createElementVNode("span",{class:"size-2 rounded-full bg-blue-500"},null,-1)),e.createElementVNode("span",xe,e.toDisplayString(s.title),1),e.createVNode(m,null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.Check),{class:e.normalizeClass(e.unref(j.classNames)("ml-auto size-4"))},null,8,["class"])]),_:1})]),_:2},1032,["value"]))),128))]),_:1})]),_:1})],64)):e.createCommentVNode("",!0)]),_:1})]),_:1},8,["modelValue"]),n[15]||(n[15]=e.createElementVNode("p",{class:"text-sm font-medium text-muted-foreground mb-4"}," Filter by Status ",-1)),e.createElementVNode("div",ge,[e.createVNode(c,{id:"chk_published_products",modelValue:e.unref(o).published,"onUpdate:modelValue":n[1]||(n[1]=s=>e.unref(o).published=s)},null,8,["modelValue"]),n[10]||(n[10]=e.createElementVNode("label",{for:"chk_published_products",class:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"}," Show published products ",-1))]),e.createElementVNode("div",Ve,[e.createVNode(c,{id:"chk_draft_products",modelValue:e.unref(o).draft,"onUpdate:modelValue":n[2]||(n[2]=s=>e.unref(o).draft=s)},null,8,["modelValue"]),n[11]||(n[11]=e.createElementVNode("label",{for:"chk_draft_products",class:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"}," Show draft products ",-1))]),e.createElementVNode("div",Ne,[e.createVNode(c,{id:"chk_archived_products",modelValue:e.unref(o).archived,"onUpdate:modelValue":n[3]||(n[3]=s=>e.unref(o).archived=s)},null,8,["modelValue"]),n[12]||(n[12]=e.createElementVNode("label",{for:"chk_archived_products",class:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"}," Show archived products ",-1))]),e.unref(o).collections.length>0||!e.unref(o).published||!e.unref(o).draft||e.unref(o).archived?(e.openBlock(),e.createBlock(d,{key:0,variant:"secondary",class:"ml-auto my-2",size:"sm",onClick:g},{default:e.withCtx(()=>[e.createVNode(e.unref(B.RotateCcw),{class:"size-3"}),n[13]||(n[13]=e.createElementVNode("span",{class:"ml-0.5 text-xs"},"Reset filters",-1))]),_:1})):e.createCommentVNode("",!0)]),_:1})]),_:1})}}}),be=e.defineComponent({__name:"ProductContextMenu",emits:["selectAll","duplicateProduct","deleteProduct","deleteSelection"],setup(T,{emit:o}){const f=o,g=e.inject("products"),v=e.inject("selection"),n=e.inject("config"),{hasPermission:d}=_.useModulePermissions(),{navigateTo:i}=_.useModuleRoute(),l=e.computed(()=>v.value?.length!==1?null:g.value?.find(m=>m.id===v.value[0])),u=m=>{let t=n.previewUrl;t=t.replace("{{ id","{{id"),t=t.replace("id }}","id}}"),t=t.replace("{{id}}",m.id),t=t.replace("{{ slug","{{slug"),t=t.replace("slug }}","slug}}"),t=t.replace("{{slug}}",m.slug),window.open(t,"_blank")},k=async(m,t)=>{try{if(!["draft","published","archived"].includes(t))return;await _.useFirebaseIntegration(n.project).update(n.productCollection,m.id,{status:t}),m.status=t,y.toast.success("Product status changed")}catch{y.toast.error("Failed to change product status")}},x=async m=>{try{if(!["draft","published","archived"].includes(m))return;const t=_.useFirebaseIntegration(n.project),p=[];v.value.forEach(async C=>{p.push(t.update(n.productCollection,C,{status:m}))}),y.toast.promise(Promise.all(p),{loading:`Changing status of ${v.value.length} products...`,success:()=>{const C=v.value.length;return v.value.forEach(V=>{g.value.find(N=>N.id==V).status=m}),v.value=[],`Product status changed for ${C} products`},error:C=>"Failed to change product status"})}catch{y.toast.error("Failed to change product status")}};return(m,t)=>{const p=e.resolveComponent("ContextMenuTrigger"),C=e.resolveComponent("ContextMenuShortcut"),V=e.resolveComponent("ContextMenuItem"),N=e.resolveComponent("ContextMenuContent"),c=e.resolveComponent("ContextMenuSeparator"),w=e.resolveComponent("ContextMenuSubTrigger"),h=e.resolveComponent("ContextMenuCheckboxItem"),s=e.resolveComponent("ContextMenuSubContent"),$=e.resolveComponent("ContextMenuSub"),z=e.resolveComponent("ContextMenu");return e.openBlock(),e.createBlock(z,null,{default:e.withCtx(()=>[e.createVNode(p,{class:"flex flex-1"},{default:e.withCtx(()=>[e.renderSlot(m.$slots,"default")]),_:3}),e.unref(v).length===0?(e.openBlock(),e.createBlock(N,{key:0,class:"w-64"},{default:e.withCtx(()=>[e.createVNode(V,{inset:"",onClick:t[0]||(t[0]=b=>f("selectAll"))},{default:e.withCtx(()=>[t[13]||(t[13]=e.createTextVNode(" Select all ",-1)),e.createVNode(C,null,{default:e.withCtx(()=>[...t[12]||(t[12]=[e.createTextVNode("⌘ + A",-1)])]),_:1})]),_:1})]),_:1})):e.createCommentVNode("",!0),e.unref(v).length===1&&l.value?(e.openBlock(),e.createBlock(N,{key:1,class:"w-64"},{default:e.withCtx(()=>[e.createVNode(V,{inset:"",onClick:t[1]||(t[1]=b=>e.unref(i)(l.value.id))},{default:e.withCtx(()=>[...t[14]||(t[14]=[e.createTextVNode(" Edit product ",-1)])]),_:1}),e.createVNode(c),e.unref(n).previewUrl?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(V,{inset:"",onClick:t[2]||(t[2]=b=>u(l.value))},{default:e.withCtx(()=>[t[15]||(t[15]=e.createTextVNode(" Preview product ",-1)),e.createVNode(C,null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.ExternalLink),{class:"size-4"})]),_:1})]),_:1}),e.createVNode(c)],64)):e.createCommentVNode("",!0),e.createVNode(V,{inset:"",onClick:t[3]||(t[3]=b=>f("duplicateProduct",l.value))},{default:e.withCtx(()=>[...t[16]||(t[16]=[e.createTextVNode(" Duplicate product ",-1)])]),_:1}),e.createVNode($,null,{default:e.withCtx(()=>[e.createVNode(w,{inset:""},{default:e.withCtx(()=>[...t[17]||(t[17]=[e.createTextVNode(" Change status ",-1)])]),_:1}),e.createVNode(s,{class:"w-48"},{default:e.withCtx(()=>[e.createVNode(h,{onClick:t[4]||(t[4]=b=>k(l.value,"draft")),modelValue:l.value.status==="draft"},{default:e.withCtx(()=>[...t[18]||(t[18]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-blue-500"},null,-1),e.createTextVNode(" Draft ",-1)])]),_:1},8,["modelValue"]),e.createVNode(h,{onClick:t[5]||(t[5]=b=>k(l.value,"published")),modelValue:l.value.status==="published"},{default:e.withCtx(()=>[...t[19]||(t[19]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-green-500"},null,-1),e.createTextVNode(" Published ",-1)])]),_:1},8,["modelValue"]),e.createVNode(h,{onClick:t[6]||(t[6]=b=>k(l.value,"archived")),modelValue:l.value.status==="archived"},{default:e.withCtx(()=>[...t[20]||(t[20]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-gray-300"},null,-1),e.createTextVNode(" Archived ",-1)])]),_:1},8,["modelValue"])]),_:1})]),_:1}),e.createVNode(V,{inset:"",variant:"destructive",onClick:t[7]||(t[7]=b=>f("deleteProduct",l.value))},{default:e.withCtx(()=>[...t[21]||(t[21]=[e.createTextVNode(" Delete product ",-1)])]),_:1})]),_:1})):e.createCommentVNode("",!0),e.unref(v).length>1?(e.openBlock(),e.createBlock(N,{key:2,class:"w-64"},{default:e.withCtx(()=>[e.createVNode($,null,{default:e.withCtx(()=>[e.createVNode(w,{inset:""},{default:e.withCtx(()=>[e.createTextVNode(" Change status ("+e.toDisplayString(e.unref(v).length)+") ",1)]),_:1}),e.createVNode(s,{class:"w-48"},{default:e.withCtx(()=>[e.createVNode(h,{onClick:t[8]||(t[8]=b=>x("draft"))},{default:e.withCtx(()=>[...t[22]||(t[22]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-blue-500"},null,-1),e.createTextVNode(" Draft ",-1)])]),_:1}),e.createVNode(h,{onClick:t[9]||(t[9]=b=>x("published"))},{default:e.withCtx(()=>[...t[23]||(t[23]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-green-500"},null,-1),e.createTextVNode(" Published ",-1)])]),_:1}),e.createVNode(h,{onClick:t[10]||(t[10]=b=>x("archived"))},{default:e.withCtx(()=>[...t[24]||(t[24]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-gray-300"},null,-1),e.createTextVNode(" Archived ",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(V,{inset:"",variant:"destructive",onClick:t[11]||(t[11]=b=>f("deleteSelection"))},{default:e.withCtx(()=>[e.createTextVNode(" Delete products ("+e.toDisplayString(e.unref(v).length)+") ",1)]),_:1})]),_:1})):e.createCommentVNode("",!0)]),_:3})}}}),_e={class:"relative flex flex-col flex-1"},we={ref:"container",class:"flex items-center justify-between gap-4 w-full mt-12 mb-8"},he={class:"flex items-center gap-4"},ye={class:"text-lg whitespace-nowrap"},Be={class:"relative w-full max-w-sm items-center"},Ee={class:"absolute start-0 inset-y-0 flex items-center justify-center px-2"},Pe={class:"flex items-center gap-4"},Te={class:"flex flex-1"},Se=e.defineComponent({__name:"Overview",props:{config:{type:Object,required:!0}},async setup(T){let o,f;const g=T,{hasPermission:v}=_.useModulePermissions(),{navigateTo:n}=_.useModuleRoute(),{confirm:d}=_.useConfirmation();_.useModuleBreadcrumbs(()=>[]);const i=_.useFirebaseIntegration(g.config.project),l=e.ref([]),u=async()=>{const a=await i.find(g.config.productCollection);l.value=a||[]},k=e.useTemplateRef("container"),{width:x}=X.useElementSize(k),m=e.ref("grid"),t=e.ref(1),p=e.ref([]),C=e.ref(""),V=e.ref([]);V.value=([o,f]=e.withAsyncContext(()=>h()),o=await o,f(),o);const N=e.computed(()=>m.value==="grid"?x.value<768?6:x.value<896?8:x.value<1024?10:12:10),c=e.computed(()=>l.value.filter(a=>!(S.value.collections.length>0&&!a.collections?.some(r=>S.value.collections.includes(r))||!S.value.published&&a.status==="published"||!S.value.draft&&a.status==="draft"||!S.value.archived&&a.status==="archived")).filter(a=>a.title.toLowerCase().includes(C.value.toLowerCase())||a.slug.toLowerCase().includes(C.value.toLowerCase())||a.id.toLowerCase().includes(C.value.toLowerCase()))),w=e.computed(()=>{if(c.value.length<=N.value)return c.value;const a=(t.value-1)*N.value,r=a+N.value;return c.value.slice(a,r)});async function h(){if(!g.config.collectionsCollection)return[];const a=g.config.collectionsCollection.split(":");return a.length!==2?[]:(await i.get(a[0]))?.[a[1]]||[]}async function s(a){return(await i.find(g.config.productCollection,{filters:[{field:"slug",operator:"==",value:a}]})).length>0}const $=()=>{p.value=w.value.map(a=>a.id)},z=async a=>{try{let r={...a},P=r.slug+"-copy",M=2;for(;await s(P);)P=r.slug+"-copy-"+M,M++;r.id=void 0,r.createdAt=new Date,r.updatedAt=new Date,r.slug=P,r.status="draft",r.title=r.title+" (copy)";const F=await i.add(g.config.productCollection,r);n(F.id),y.toast.success("Product duplicated")}catch{y.toast.error("Failed to duplicate product")}},b=async a=>{if(await d(`Are you sure you want to delete "${a.title}"?`))try{await i.remove(g.config.productCollection,a.id),l.value=l.value.filter(P=>P.id!==a.id),p.value=[],y.toast.success("Product deleted")}catch{y.toast.error("Failed to delete product")}},A=async()=>{if(await d(`Are you sure you want to delete all selected products (${p.value.length})?`))try{p.value.forEach(async r=>{await i.remove(g.config.productCollection,r)}),l.value=l.value.filter(r=>!p.value.includes(r.id)),p.value=[],y.toast.success("Products deleted")}catch{y.toast.error("Failed to delete products")}},S=e.ref({collections:[],published:!0,draft:!0,archived:!1});e.watch(S,()=>{t.value=1});const I=a=>{a.target?.matches("input, textarea")||a.target?.isContentEditable||(a.key==="Escape"&&(p.value=[]),(a.metaKey||a.ctrlKey)&&a.key.toLowerCase()==="a"&&(a.preventDefault(),$()))};return e.onMounted(()=>{u(),window.addEventListener("keydown",I)}),e.onUnmounted(()=>{window.removeEventListener("keydown",I)}),e.provide("config",g.config),e.provide("filter",S),e.provide("products",l),e.provide("collections",V),e.provide("selection",p),(a,r)=>{const P=e.resolveComponent("Input"),M=e.resolveComponent("Button"),F=e.resolveComponent("SegmentedControlButton"),R=e.resolveComponent("SegmentedControl"),U=e.resolveComponent("PaginationFirst"),K=e.resolveComponent("PaginationPrev"),q=e.resolveComponent("PaginationListItem"),G=e.resolveComponent("PaginationEllipsis"),O=e.resolveComponent("PaginationNext"),H=e.resolveComponent("PaginationLast"),Q=e.resolveComponent("PaginationList"),W=e.resolveComponent("Pagination");return e.openBlock(),e.createElementBlock("div",_e,[e.createElementVNode("div",we,[e.createElementVNode("div",he,[e.createElementVNode("p",ye,e.toDisplayString(c.value?.length)+" products",1),e.createElementVNode("div",Be,[e.createVNode(P,{id:"search",type:"text",placeholder:"Search...",class:"pl-8",onKeydown:r[0]||(r[0]=e.withKeys(E=>C.value="",["escape"])),modelValue:C.value,"onUpdate:modelValue":r[1]||(r[1]=E=>C.value=E)},null,8,["modelValue"]),e.createElementVNode("span",Ee,[e.createVNode(e.unref(B.Search),{class:"size-4 text-muted-foreground"})])])]),e.createElementVNode("div",Pe,[p.value.length>0?(e.openBlock(),e.createBlock(M,{key:0,variant:"destructive",onClick:A},{default:e.withCtx(()=>[e.createTextVNode(" Delete Selection ("+e.toDisplayString(p.value.length)+") ",1)]),_:1})):e.createCommentVNode("",!0),e.unref(v)("create-product")?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(M,{variant:"outline",onClick:r[2]||(r[2]=E=>e.unref(n)("new"))},{default:e.withCtx(()=>[e.createVNode(e.unref(B.Plus),{class:"size-4"}),r[5]||(r[5]=e.createTextVNode(" New Product ",-1))]),_:1}),r[6]||(r[6]=e.createElementVNode("div",{class:"w-[1px] h-8 bg-border"},null,-1))],64)):e.createCommentVNode("",!0),e.createVNode(ke),r[7]||(r[7]=e.createElementVNode("div",{class:"w-[1px] h-8 bg-border"},null,-1)),e.createElementVNode("div",null,[e.createVNode(R,{modelValue:m.value,"onUpdate:modelValue":r[3]||(r[3]=E=>m.value=E),"aria-label":"View mode"},{default:e.withCtx(()=>[e.createVNode(F,{value:"grid"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.LayoutGrid),{class:"size-4"})]),_:1}),e.createVNode(F,{value:"list"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.List),{class:"size-4"})]),_:1})]),_:1},8,["modelValue"])])])],512),e.createElementVNode("div",Te,[e.createVNode(be,{onSelectAll:$,onDuplicateProduct:z,onDeleteProduct:b,onDeleteSelection:A},{default:e.withCtx(()=>[m.value==="grid"?(e.openBlock(),e.createBlock(le,{key:0,products:w.value},null,8,["products"])):(e.openBlock(),e.createBlock(ce,{key:1,products:w.value},null,8,["products"]))]),_:1})]),c.value?.length>N.value?(e.openBlock(),e.createBlock(W,{key:0,page:t.value,"onUpdate:page":r[4]||(r[4]=E=>t.value=E),"items-per-page":N.value,total:c.value?.length,"sibling-count":1,"show-edges":""},{default:e.withCtx(()=>[e.createVNode(Q,{class:"flex items-center gap-1"},{default:e.withCtx(({items:E})=>[e.createVNode(U),e.createVNode(K),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E,(D,L)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[D.type==="page"?(e.openBlock(),e.createBlock(q,{key:L,value:D.value,"as-child":""},{default:e.withCtx(()=>[e.createVNode(M,{class:"size-10 p-0",variant:D.value===t.value?"default":"outline"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(D.value),1)]),_:2},1032,["variant"])]),_:2},1032,["value"])):(e.openBlock(),e.createBlock(G,{key:D.type,index:L},null,8,["index"]))],64))),256)),e.createVNode(O),e.createVNode(H)]),_:1})]),_:1},8,["page","items-per-page","total"])):e.createCommentVNode("",!0)])}}});exports.default=Se;
@@ -15,9 +15,7 @@ const Ee = { class: "grid @md:grid-cols-2 @2xl:grid-cols-3 @3xl:grid-cols-4 @4xl
15
15
  setup(U) {
16
16
  const n = K("selection"), { navigateTo: y } = J(), { hasPermission: S } = Y(), w = (f, u) => {
17
17
  const b = u.ctrlKey || u.metaKey;
18
- if (u.shiftKey)
19
- console.log("range");
20
- else if (b || n.value.length > 0) {
18
+ if (!u.shiftKey) if (b || n.value.length > 0) {
21
19
  const h = n.value.indexOf(f.id);
22
20
  h > -1 ? n.value.splice(h, 1) : n.value.push(f.id);
23
21
  } else
@@ -1,8 +1,8 @@
1
- import { defineComponent as _e, ref as m, computed as te, watch as he, onMounted as ye, resolveComponent as h, openBlock as n, createElementBlock as i, createElementVNode as s, toDisplayString as u, unref as r, Fragment as w, renderList as D, normalizeClass as L, createVNode as t, withCtx as l, createCommentVNode as P, createBlock as T, createTextVNode as y, resolveDynamicComponent as W, normalizeStyle as se } from "vue";
1
+ import { defineComponent as _e, ref as m, computed as te, watch as he, onMounted as ye, resolveComponent as h, openBlock as n, createElementBlock as i, createElementVNode as s, toDisplayString as u, unref as r, Fragment as w, renderList as D, normalizeClass as L, createVNode as t, withCtx as l, createCommentVNode as T, createBlock as P, createTextVNode as y, resolveDynamicComponent as W, normalizeStyle as se } from "vue";
2
2
  import { useModule as be, useModuleRoute as we, useModuleBreadcrumbs as Ce } from "@oneclick.dev/cms-kit";
3
3
  import "./index-CMk3uhUt.mjs";
4
- import { g as oe, h as ae } from "./index-DYpruS-A-Cw57iwdY.mjs";
5
- import { MousePointerClick as ke, Users as $e, Eye as De, Clock as Pe, Zap as Te, TrendingDown as le, TrendingUp as ne, UserPlus as Ue, Activity as Se, RefreshCw as Ve, Loader2 as Re, ArrowUpRight as Me, Globe as Fe, Minus as Ae, Smartphone as ze, Tablet as Ne, Monitor as Be } from "lucide-vue-next";
4
+ import { componentToString as oe, ChartTooltipContent as ae } from "@oneclick.dev/cms-kit/charts";
5
+ import { MousePointerClick as ke, Users as $e, Eye as De, Clock as Te, Zap as Pe, TrendingDown as le, TrendingUp as ne, UserPlus as Se, Activity as Ue, RefreshCw as Ve, Loader2 as Re, ArrowUpRight as Me, Globe as Fe, Minus as Ae, Smartphone as ze, Tablet as Ne, Monitor as Be } from "lucide-vue-next";
6
6
  import { S as re, C as j, A as ie, z as ue } from "./index-_2lRVt_k.mjs";
7
7
  import { C as ce, a as H } from "./index-p5Uqu8c2.mjs";
8
8
  const Le = { class: "w-full max-w-7xl mx-auto py-8 px-4 space-y-6" }, je = { class: "flex items-center justify-between" }, Ge = { class: "text-muted-foreground text-sm mt-1" }, Ie = {
@@ -23,15 +23,15 @@ const Le = { class: "w-full max-w-7xl mx-auto py-8 px-4 space-y-6" }, je = { cla
23
23
  }, _t = { class: "grid @lg:grid-cols-2 gap-6" }, ht = { class: "space-y-3" }, yt = { class: "text-sm capitalize flex-1" }, bt = { class: "flex-1 h-2 bg-muted rounded-full overflow-hidden" }, wt = { class: "text-xs tabular-nums text-muted-foreground w-16 text-right" }, Ct = {
24
24
  key: 0,
25
25
  class: "py-4 text-center text-muted-foreground text-sm"
26
- }, kt = { class: "space-y-3" }, $t = { class: "text-sm flex-1" }, Dt = { class: "flex-1 h-2 bg-muted rounded-full overflow-hidden" }, Pt = { class: "text-xs tabular-nums text-muted-foreground w-16 text-right" }, Tt = {
26
+ }, kt = { class: "space-y-3" }, $t = { class: "text-sm flex-1" }, Dt = { class: "flex-1 h-2 bg-muted rounded-full overflow-hidden" }, Tt = { class: "text-xs tabular-nums text-muted-foreground w-16 text-right" }, Pt = {
27
27
  key: 0,
28
28
  class: "py-4 text-center text-muted-foreground text-sm"
29
29
  }, Nt = /* @__PURE__ */ _e({
30
30
  __name: "Overview",
31
- setup(Ut) {
31
+ setup(St) {
32
32
  const { config: G } = be(), { moduleId: de } = we();
33
33
  Ce(() => [{ label: "Overview" }]);
34
- const C = m(!0), V = m(null), R = m("30"), U = m([]), f = m({}), me = m({}), v = m({}), q = m(0), I = m([]), X = m([]), M = m([]), F = m([]), A = te(() => !!(G.serviceAccount && G.propertyId));
34
+ const C = m(!0), V = m(null), R = m("30"), S = m([]), f = m({}), me = m({}), v = m({}), q = m(0), I = m([]), X = m([]), M = m([]), F = m([]), A = te(() => !!(G.serviceAccount && G.propertyId));
35
35
  function k(a) {
36
36
  return `/api/v1/modules/${de}${a}`;
37
37
  }
@@ -49,13 +49,13 @@ const Le = { class: "w-full max-w-7xl mx-auto py-8 px-4 space-y-6" }, je = { cla
49
49
  totalUsers: { label: "Users", color: x.users }
50
50
  }, O = {
51
51
  screenPageViews: { label: "Page Views", color: x.pageViews }
52
- }, S = (a, e) => e, K = (a) => a.sessions || 0, ve = (a) => a.totalUsers || 0, Z = (a) => a.screenPageViews || 0, J = (a) => {
53
- const e = U.value[Math.round(a)];
52
+ }, U = (a, e) => e, K = (a) => a.sessions || 0, ve = (a) => a.totalUsers || 0, Z = (a) => a.screenPageViews || 0, J = (a) => {
53
+ const e = S.value[Math.round(a)];
54
54
  if (!e) return "";
55
55
  const d = new Date(e.date);
56
56
  return `${d.getDate()}/${d.getMonth() + 1}`;
57
57
  }, Q = (a) => {
58
- const e = U.value[Math.round(Number(a))];
58
+ const e = S.value[Math.round(Number(a))];
59
59
  return e ? new Date(e.date).toLocaleDateString(void 0, { weekday: "short", month: "short", day: "numeric" }) : "";
60
60
  }, pe = te(() => [
61
61
  {
@@ -79,13 +79,13 @@ const Le = { class: "w-full max-w-7xl mx-auto py-8 px-4 space-y-6" }, je = { cla
79
79
  {
80
80
  label: "Avg. Duration",
81
81
  value: ge(f.value.averageSessionDuration || 0),
82
- icon: Pe,
82
+ icon: Te,
83
83
  change: v.value.averageSessionDuration
84
84
  },
85
85
  {
86
86
  label: "Engagement",
87
87
  value: `${((f.value.engagementRate || 0) * 100).toFixed(1)}%`,
88
- icon: Te,
88
+ icon: Pe,
89
89
  change: v.value.engagementRate,
90
90
  positive: !0
91
91
  },
@@ -99,13 +99,13 @@ const Le = { class: "w-full max-w-7xl mx-auto py-8 px-4 space-y-6" }, je = { cla
99
99
  {
100
100
  label: "New Users",
101
101
  value: p(f.value.newUsers || 0),
102
- icon: Ue,
102
+ icon: Se,
103
103
  change: v.value.newUsers
104
104
  },
105
105
  {
106
106
  label: "Pages / Session",
107
107
  value: (f.value.screenPageViewsPerSession || 0).toFixed(1),
108
- icon: Se,
108
+ icon: Ue,
109
109
  change: v.value.screenPageViewsPerSession
110
110
  }
111
111
  ]);
@@ -143,7 +143,7 @@ const Le = { class: "w-full max-w-7xl mx-auto py-8 px-4 space-y-6" }, je = { cla
143
143
  $fetch(k(`/devices?startDate=${a}&endDate=today`)),
144
144
  $fetch(k(`/countries?startDate=${a}&endDate=today`))
145
145
  ]);
146
- U.value = e.rows || [], f.value = e.totals || {}, me.value = e.previousTotals || {}, v.value = e.changes || {}, q.value = d.activeUsers || 0, I.value = c.rows || [], X.value = b.rows || [], M.value = g.rows || [], F.value = _.rows || [];
146
+ S.value = e.rows || [], f.value = e.totals || {}, me.value = e.previousTotals || {}, v.value = e.changes || {}, q.value = d.activeUsers || 0, I.value = c.rows || [], X.value = b.rows || [], M.value = g.rows || [], F.value = _.rows || [];
147
147
  } catch (e) {
148
148
  console.error("Failed to fetch analytics data:", e), V.value = e?.data?.statusMessage || e?.message || "Failed to load analytics data";
149
149
  } finally {
@@ -181,9 +181,9 @@ const Le = { class: "w-full max-w-7xl mx-auto py-8 px-4 space-y-6" }, je = { cla
181
181
  ]),
182
182
  _: 1
183
183
  }, 8, ["disabled"])
184
- ])) : P("", !0)
184
+ ])) : T("", !0)
185
185
  ]),
186
- A.value ? V.value ? (n(), T(c, {
186
+ A.value ? V.value ? (n(), P(c, {
187
187
  key: 1,
188
188
  class: "p-6 border-destructive/50 bg-destructive/5"
189
189
  }, {
@@ -230,25 +230,25 @@ const Le = { class: "w-full max-w-7xl mx-auto py-8 px-4 space-y-6" }, je = { cla
230
230
  _: 1
231
231
  }),
232
232
  s("div", Ze, [
233
- (n(!0), i(w, null, D(pe.value, (o) => (n(), T(c, {
233
+ (n(!0), i(w, null, D(pe.value, (o) => (n(), P(c, {
234
234
  key: o.label,
235
235
  class: "p-4"
236
236
  }, {
237
237
  default: l(() => [
238
238
  s("div", Je, [
239
- (n(), T(W(o.icon), { class: "size-3.5" })),
239
+ (n(), P(W(o.icon), { class: "size-3.5" })),
240
240
  s("span", Qe, u(o.label), 1)
241
241
  ]),
242
242
  s("p", Ye, u(o.value), 1),
243
243
  o.change !== void 0 ? (n(), i("div", et, [
244
- (n(), T(W(z(o.change, o.positive !== !1).icon), {
244
+ (n(), P(W(z(o.change, o.positive !== !1).icon), {
245
245
  class: L(["size-3", z(o.change, o.positive !== !1).cls])
246
246
  }, null, 8, ["class"])),
247
247
  s("span", {
248
248
  class: L(["text-xs font-medium", z(o.change, o.positive !== !1).cls])
249
249
  }, u(z(o.change, o.positive !== !1).text), 3),
250
250
  e[6] || (e[6] = s("span", { class: "text-xs text-muted-foreground" }, "vs prev.", -1))
251
- ])) : P("", !0)
251
+ ])) : T("", !0)
252
252
  ]),
253
253
  _: 2
254
254
  }, 1024))), 128))
@@ -275,26 +275,26 @@ const Le = { class: "w-full max-w-7xl mx-auto py-8 px-4 space-y-6" }, je = { cla
275
275
  }, {
276
276
  default: l(() => [
277
277
  t(r(re), {
278
- data: U.value,
278
+ data: S.value,
279
279
  margin: { top: 8, right: 8, bottom: 24, left: 40 }
280
280
  }, {
281
281
  default: l(() => [
282
282
  t(r(ce), {
283
- x: S,
283
+ x: U,
284
284
  y: K,
285
285
  color: x.sessions,
286
286
  opacity: 0.1,
287
287
  curveType: "monotoneX"
288
288
  }, null, 8, ["color"]),
289
289
  t(r(H), {
290
- x: S,
290
+ x: U,
291
291
  y: K,
292
292
  color: x.sessions,
293
293
  lineWidth: 2,
294
294
  curveType: "monotoneX"
295
295
  }, null, 8, ["color"]),
296
296
  t(r(H), {
297
- x: S,
297
+ x: U,
298
298
  y: ve,
299
299
  color: x.users,
300
300
  lineWidth: 2,
@@ -347,19 +347,19 @@ const Le = { class: "w-full max-w-7xl mx-auto py-8 px-4 space-y-6" }, je = { cla
347
347
  }, {
348
348
  default: l(() => [
349
349
  t(r(re), {
350
- data: U.value,
350
+ data: S.value,
351
351
  margin: { top: 8, right: 8, bottom: 24, left: 40 }
352
352
  }, {
353
353
  default: l(() => [
354
354
  t(r(ce), {
355
- x: S,
355
+ x: U,
356
356
  y: Z,
357
357
  color: x.pageViews,
358
358
  opacity: 0.15,
359
359
  curveType: "monotoneX"
360
360
  }, null, 8, ["color"]),
361
361
  t(r(H), {
362
- x: S,
362
+ x: U,
363
363
  y: Z,
364
364
  color: x.pageViews,
365
365
  lineWidth: 2,
@@ -422,7 +422,7 @@ const Le = { class: "w-full max-w-7xl mx-auto py-8 px-4 space-y-6" }, je = { cla
422
422
  s("span", ut, u(p(o.totalUsers)) + " users", 1)
423
423
  ])
424
424
  ]))), 128)),
425
- I.value.length ? P("", !0) : (n(), i("div", ct, "No data available"))
425
+ I.value.length ? T("", !0) : (n(), i("div", ct, "No data available"))
426
426
  ])
427
427
  ]),
428
428
  _: 1
@@ -459,7 +459,7 @@ const Le = { class: "w-full max-w-7xl mx-auto py-8 px-4 space-y-6" }, je = { cla
459
459
  s("span", gt, u(p(o.sessions)) + " sessions", 1)
460
460
  ])
461
461
  ]))), 128)),
462
- X.value.length ? P("", !0) : (n(), i("div", xt, "No data available"))
462
+ X.value.length ? T("", !0) : (n(), i("div", xt, "No data available"))
463
463
  ])
464
464
  ]),
465
465
  _: 1
@@ -489,7 +489,7 @@ const Le = { class: "w-full max-w-7xl mx-auto py-8 px-4 space-y-6" }, je = { cla
489
489
  key: o.deviceCategory,
490
490
  class: "flex items-center gap-3"
491
491
  }, [
492
- (n(), T(W(xe(o.deviceCategory)), { class: "size-4 text-muted-foreground shrink-0" })),
492
+ (n(), P(W(xe(o.deviceCategory)), { class: "size-4 text-muted-foreground shrink-0" })),
493
493
  s("span", yt, u(o.deviceCategory), 1),
494
494
  s("div", bt, [
495
495
  s("div", {
@@ -499,7 +499,7 @@ const Le = { class: "w-full max-w-7xl mx-auto py-8 px-4 space-y-6" }, je = { cla
499
499
  ]),
500
500
  s("span", wt, u(p(o.sessions)), 1)
501
501
  ]))), 128)),
502
- M.value.length ? P("", !0) : (n(), i("div", Ct, "No data available"))
502
+ M.value.length ? T("", !0) : (n(), i("div", Ct, "No data available"))
503
503
  ])
504
504
  ]),
505
505
  _: 1
@@ -535,9 +535,9 @@ const Le = { class: "w-full max-w-7xl mx-auto py-8 px-4 space-y-6" }, je = { cla
535
535
  style: se({ width: `${o.sessions / (F.value[0]?.sessions || 1) * 100}%` })
536
536
  }, null, 4)
537
537
  ]),
538
- s("span", Pt, u(p(o.sessions)), 1)
538
+ s("span", Tt, u(p(o.sessions)), 1)
539
539
  ]))), 128)),
540
- F.value.length ? P("", !0) : (n(), i("div", Tt, "No data available"))
540
+ F.value.length ? T("", !0) : (n(), i("div", Pt, "No data available"))
541
541
  ])
542
542
  ]),
543
543
  _: 1
@@ -546,7 +546,7 @@ const Le = { class: "w-full max-w-7xl mx-auto py-8 px-4 space-y-6" }, je = { cla
546
546
  _: 1
547
547
  })
548
548
  ])
549
- ], 64)) : (n(), T(c, {
549
+ ], 64)) : (n(), P(c, {
550
550
  key: 0,
551
551
  class: "p-8 text-center"
552
552
  }, {
@@ -2008,7 +2008,6 @@ We would love to see you another time!`);
2008
2008
  p.value = !1;
2009
2009
  }
2010
2010
  }, be = () => {
2011
- console.log("Cancel with coupon:", s.value?.id);
2012
2011
  };
2013
2012
  return e({
2014
2013
  openDialog: x
@@ -346,4 +346,4 @@ We've got everything ready for you and look forward to your visit! If you need t
346
346
 
347
347
  Thank you for your interest in booking with us. Unfortunately, we are unable to confirm your request for ${new Date(f.date)?.toDateString()} at ${f.startTime}.
348
348
 
349
- We would love to see you another time!`)},x=()=>{if(!c.value){if(!d.value||!s.value||!p.value)return alert("Please fill in all the fields.");i({to:d.value,subject:s.value,body:p.value})}r.value=!1;const{$confetti:f}=useNuxtApp();f(),l("confirm")};return t({openDialog:v}),(f,u)=>{const g=e.resolveComponent("DialogTitle"),b=e.resolveComponent("DialogDescription"),E=e.resolveComponent("DialogHeader"),w=e.resolveComponent("Checkbox"),D=e.resolveComponent("Label"),V=e.resolveComponent("Input"),S=e.resolveComponent("Textarea"),$=e.resolveComponent("Button"),y=e.resolveComponent("DialogFooter"),A=e.resolveComponent("DialogScrollContent"),k=e.resolveComponent("Dialog");return e.openBlock(),e.createBlock(k,{open:r.value,"onUpdate:open":u[5]||(u[5]=N=>r.value=N)},{default:e.withCtx(()=>[e.createVNode(A,{class:"sm:max-w-3xl"},{default:e.withCtx(()=>[e.createVNode(E,null,{default:e.withCtx(()=>[e.createVNode(g,null,{default:e.withCtx(()=>[...u[6]||(u[6]=[e.createTextVNode(" Reject Reservation Request ",-1)])]),_:1}),e.createVNode(b)]),_:1}),e.createElementVNode("div",Mt,[e.createVNode(w,{modelValue:c.value,"onUpdate:modelValue":u[0]||(u[0]=N=>c.value=N),id:"reject-dialog-skip-mail",class:"border-black/80 dark:border-gray-200",disabled:!e.unref(a).mailAccount},null,8,["modelValue","disabled"]),e.createVNode(D,{for:"reject-dialog-skip-mail",class:"py-4 pl-2 pr-4"},{default:e.withCtx(()=>[...u[7]||(u[7]=[e.createTextVNode("Do not send email to customer",-1)])]),_:1})]),e.createElementVNode("div",{class:e.normalizeClass(["grid gap-4 py-4",{"opacity-50":c.value}])},[e.createElementVNode("div",$t,[e.createVNode(D,{for:"reject-dialog-email"},{default:e.withCtx(()=>[...u[8]||(u[8]=[e.createTextVNode("To:",-1)])]),_:1}),e.createVNode(V,{modelValue:d.value,"onUpdate:modelValue":u[1]||(u[1]=N=>d.value=N),disabled:c.value,id:"reject-dialog-email"},null,8,["modelValue","disabled"])]),e.createElementVNode("div",Ft,[e.createVNode(D,{for:"reject-dialog-subject"},{default:e.withCtx(()=>[...u[9]||(u[9]=[e.createTextVNode("Subject:",-1)])]),_:1}),e.createVNode(V,{modelValue:s.value,"onUpdate:modelValue":u[2]||(u[2]=N=>s.value=N),disabled:c.value,id:"reject-dialog-subject"},null,8,["modelValue","disabled"])]),e.createElementVNode("div",St,[e.createVNode(D,{for:"reject-dialog-body"},{default:e.withCtx(()=>[...u[10]||(u[10]=[e.createTextVNode("Body:",-1)])]),_:1}),e.createVNode(S,{modelValue:p.value,"onUpdate:modelValue":u[3]||(u[3]=N=>p.value=N),disabled:c.value,id:"reject-dialog-body"},null,8,["modelValue","disabled"])])],2),e.createVNode(y,null,{default:e.withCtx(()=>[e.createVNode($,{variant:"outline",onClick:u[4]||(u[4]=N=>r.value=!1)},{default:e.withCtx(()=>[...u[11]||(u[11]=[e.createTextVNode("Close",-1)])]),_:1}),e.createVNode($,{variant:"destructive",onClick:x},{default:e.withCtx(()=>[...u[12]||(u[12]=[e.createTextVNode("Reject reservation",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["open"])}}}),It={key:0,class:"space-y-6 py-4"},Tt={class:"space-y-3"},jt={class:"bg-muted/30 rounded-lg p-4 space-y-3"},Ot={class:"flex items-center gap-3"},Lt={class:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center"},Pt={class:"font-medium"},zt={class:"grid gap-2 text-sm"},Ut={key:0,class:"flex items-center gap-2 text-muted-foreground"},Ht=["href"],Wt={key:1,class:"flex items-center gap-2 text-muted-foreground"},Kt=["href"],Gt={class:"space-y-3"},Yt={class:"grid grid-cols-2 gap-3"},Qt={class:"bg-muted/30 rounded-lg p-3"},Jt={class:"flex items-center gap-2 text-muted-foreground mb-1"},Xt={class:"font-medium"},Zt={class:"bg-muted/30 rounded-lg p-3"},qt={class:"flex items-center gap-2 text-muted-foreground mb-1"},eo={class:"font-medium"},to={key:0,class:"space-y-3"},oo={class:"bg-muted/30 rounded-lg p-4"},no={class:"flex items-start justify-between"},so={class:"flex items-start gap-3"},ao={class:"h-9 w-9 rounded-lg bg-primary/10 flex items-center justify-center mt-0.5"},ro={class:"font-medium"},io={class:"text-sm text-muted-foreground"},lo={class:"font-semibold"},co={class:"space-y-3"},uo={class:"bg-muted/30 rounded-lg p-4 space-y-3"},po={class:"space-y-2 text-sm"},mo={class:"flex justify-between"},fo={key:0,class:"flex justify-between"},vo={key:1,class:"flex justify-between text-green-600 dark:text-green-400"},go={class:"flex justify-between font-semibold"},ho={key:1,class:"space-y-2 text-sm"},xo={key:0,class:"flex justify-between"},Co={class:"text-muted-foreground flex items-center gap-1.5"},No={class:"text-green-600 dark:text-green-400"},Do={key:1,class:"flex justify-between"},yo={class:"text-muted-foreground flex items-center gap-1.5"},_o={class:"text-orange-600 dark:text-orange-400 font-medium"},Vo=e.defineComponent({__name:"ReservationDetailDialog",emits:["cancelled","confirmed","rejected"],setup(o,{expose:t,emit:n}){const{hasPermission:a}=I.useModulePermissions(),{config:i}=I.useModule(),l=I.useFirebaseIntegration(i.project),r=e.inject("event",e.ref(null)),c=n,d=e.ref(!1),s=e.ref(null),p=e.ref(!1),v=e.useTemplateRef("cancelReservationDialog"),x=e.useTemplateRef("approveReservationDialog"),f=e.useTemplateRef("rejectReservationDialog"),u=e.useTemplateRef("transferReservationDialog"),g=C=>{s.value=C,d.value=!0},b=e.computed(()=>s.value?.customerInfo&&`${s.value.customerInfo.firstName} ${s.value.customerInfo.lastName}`.trim()||"Unknown Customer"),E=e.computed(()=>{let C=s.value?.status;const m=s.value?.reservationStatus;switch(["needs_approval","rejected","approved","cancelled"].includes(m)&&(C=m),C){case"needs_approval":return{label:"Needs Approval",class:"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400"};case"rejected":return{label:"Rejected",class:"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400"};case"approved":return{label:"Approved",class:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400"};case"pending":return{label:"Pending",class:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400"};case"cancelled":return{label:"Cancelled",class:"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400"};default:return{label:C||"Unknown",class:"bg-muted text-muted-foreground"}}}),w=e.computed(()=>s.value?.status==="cancelled"),D=C=>C==null||typeof C!="number"?"—":`€${C?.toFixed(2)}`,V=C=>{if(!C)return"—";if(C<60)return`${C} min`;const m=Math.floor(C/60),_=C%60;return _>0?`${m}h ${_}min`:`${m}h`},S=()=>{if(!s.value)return;let C="";const m=r?.value?.date;if(m)try{C=new Date(m).toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"})}catch{C=m}const _={date:C,resourceName:r?.value?.resource?.name};Ct(s.value,_)},$=()=>{x.value?.openDialog(s.value)},y=()=>{f.value?.openDialog(s.value)},A=()=>{x.value?.openDialog(s.value)},k=()=>{v.value?.openDialog(s.value)},N=async()=>{try{if(p.value||!s.value?.id)throw new Error("Invalid state");p.value=!0;let m=(await l.get(i.reservationsCollection,s.value.id))?.reservations||[];if(!m.find(_=>_.id===s.value.res_id))throw new Error("Reservation not found");m.find(_=>_.id===s.value.res_id).status="cancelled",await l.update(i.reservationsCollection,s.value.id,{reservations:m}),s.value.status="cancelled",z.toast.success("Reservation cancelled successfully"),c("cancelled"),d.value=!1}catch(C){console.error("Error cancelling reservation:",C),z.toast.error("Failed to cancel reservation")}finally{p.value=!1}},B=async()=>{try{if(p.value||!s.value?.id)throw new Error("Invalid state");p.value=!0;let m=(await l.get(i.reservationsCollection,s.value.id))?.reservations||[];if(!m.find(_=>_.id===s.value.res_id))throw new Error("Reservation not found");m.find(_=>_.id===s.value.res_id).status="approved",await l.update(i.reservationsCollection,s.value.id,{reservations:m}),s.value.status="approved",z.toast.success("Reservation approved successfully"),c("confirmed"),d.value=!1}catch(C){console.error("Error approving reservation:",C),z.toast.error("Failed to approve reservation")}finally{p.value=!1}},j=async()=>{try{if(p.value||!s.value?.id)throw new Error("Invalid state");p.value=!0;let m=(await l.get(i.reservationsCollection,s.value.id))?.reservations||[];if(!m.find(_=>_.id===s.value.res_id))throw new Error("Reservation not found");m.find(_=>_.id===s.value.res_id).status="rejected",await l.update(i.reservationsCollection,s.value.id,{reservations:m}),s.value.status="rejected",z.toast.success("Reservation rejected successfully"),c("rejected"),d.value=!1}catch(C){console.error("Error rejecting reservation:",C),z.toast.error("Failed to reject reservation")}finally{p.value=!1}},re=()=>{console.log("Cancel with coupon:",s.value?.id)};return t({openDialog:g}),(C,m)=>{const _=e.resolveComponent("DialogTitle"),Y=e.resolveComponent("DialogDescription"),Ve=e.resolveComponent("DialogHeader"),ie=e.resolveComponent("Separator"),Q=e.resolveComponent("Button"),be=e.resolveComponent("DropdownMenuTrigger"),J=e.resolveComponent("DropdownMenuLabel"),H=e.resolveComponent("DropdownMenuItem"),X=e.resolveComponent("DropdownMenuGroup"),le=e.resolveComponent("DropdownMenuSeparator"),we=e.resolveComponent("DropdownMenuContent"),Ee=e.resolveComponent("DropdownMenu"),Ae=e.resolveComponent("DialogFooter"),ke=e.resolveComponent("DialogScrollContent"),Be=e.resolveComponent("Dialog");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(Be,{open:d.value,"onUpdate:open":m[0]||(m[0]=Me=>d.value=Me)},{default:e.withCtx(()=>[e.createVNode(ke,{class:"sm:max-w-xl"},{default:e.withCtx(()=>[e.createVNode(Ve,null,{default:e.withCtx(()=>[e.createVNode(_,{class:"flex items-center gap-3"},{default:e.withCtx(()=>[m[1]||(m[1]=e.createElementVNode("span",null,"Reservation Details",-1)),e.createElementVNode("span",{class:e.normalizeClass(["px-2.5 py-1 text-xs font-medium rounded-full",E.value.class])},e.toDisplayString(E.value.label),3)]),_:1}),e.createVNode(Y,null,{default:e.withCtx(()=>[e.createTextVNode(" Booking #"+e.toDisplayString(s.value?.id?.slice(0,8)||"—"),1)]),_:1})]),_:1}),s.value?(e.openBlock(),e.createElementBlock("div",It,[e.createElementVNode("div",Tt,[m[2]||(m[2]=e.createElementVNode("h3",{class:"text-sm font-semibold text-muted-foreground uppercase tracking-wide"},"Customer",-1)),e.createElementVNode("div",jt,[e.createElementVNode("div",Ot,[e.createElementVNode("div",Lt,[e.createVNode(e.unref(M.User),{size:20,class:"text-primary"})]),e.createElementVNode("div",null,[e.createElementVNode("p",Pt,e.toDisplayString(b.value),1)])]),e.createElementVNode("div",zt,[s.value.customerInfo?.email?(e.openBlock(),e.createElementBlock("div",Ut,[e.createVNode(e.unref(M.Mail),{size:14}),e.createElementVNode("a",{href:`mailto:${s.value.customerInfo.email}`,class:"hover:text-foreground transition-colors"},e.toDisplayString(s.value.customerInfo.email),9,Ht)])):e.createCommentVNode("",!0),s.value.customerInfo?.phone?(e.openBlock(),e.createElementBlock("div",Wt,[e.createVNode(e.unref(M.Phone),{size:14}),e.createElementVNode("a",{href:`tel:${s.value.customerInfo.phone}`,class:"hover:text-foreground transition-colors"},e.toDisplayString(s.value.customerInfo.phone),9,Kt)])):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",Gt,[m[5]||(m[5]=e.createElementVNode("h3",{class:"text-sm font-semibold text-muted-foreground uppercase tracking-wide"},"Reservation",-1)),e.createElementVNode("div",Yt,[e.createElementVNode("div",Qt,[e.createElementVNode("div",Jt,[e.createVNode(e.unref(M.Clock),{size:14}),m[3]||(m[3]=e.createElementVNode("span",{class:"text-xs"},"Time",-1))]),e.createElementVNode("p",Xt,e.toDisplayString(s.value.startTime)+" - "+e.toDisplayString(s.value.endTime),1)]),e.createElementVNode("div",Zt,[e.createElementVNode("div",qt,[e.createVNode(e.unref(M.Users),{size:14}),m[4]||(m[4]=e.createElementVNode("span",{class:"text-xs"},"Spots",-1))]),e.createElementVNode("p",eo,e.toDisplayString(s.value.spots||1)+" "+e.toDisplayString(s.value.spots===1?"person":"people"),1)])])]),s.value.pricingOption?(e.openBlock(),e.createElementBlock("div",to,[m[6]||(m[6]=e.createElementVNode("h3",{class:"text-sm font-semibold text-muted-foreground uppercase tracking-wide"},"Package",-1)),e.createElementVNode("div",oo,[e.createElementVNode("div",no,[e.createElementVNode("div",so,[e.createElementVNode("div",ao,[e.createVNode(e.unref(M.Tag),{size:18,class:"text-primary"})]),e.createElementVNode("div",null,[e.createElementVNode("p",ro,e.toDisplayString(s.value.pricingOption.name),1),e.createElementVNode("p",io,e.toDisplayString(V(s.value.pricingOption.duration)),1)])]),e.createElementVNode("p",lo,e.toDisplayString(D(s.value.pricingOption.price)),1)])])])):e.createCommentVNode("",!0),e.createElementVNode("div",co,[m[13]||(m[13]=e.createElementVNode("h3",{class:"text-sm font-semibold text-muted-foreground uppercase tracking-wide"},"Payment",-1)),e.createElementVNode("div",uo,[e.createElementVNode("div",po,[e.createElementVNode("div",mo,[m[7]||(m[7]=e.createElementVNode("span",{class:"text-muted-foreground"},"Base price",-1)),e.createElementVNode("span",null,e.toDisplayString(D(s.value.reservationBasePrice)),1)]),s.value.reservationAddOnsPrice?(e.openBlock(),e.createElementBlock("div",fo,[m[8]||(m[8]=e.createElementVNode("span",{class:"text-muted-foreground"},"Add-ons",-1)),e.createElementVNode("span",null,e.toDisplayString(D(s.value.reservationAddOnsPrice)),1)])):e.createCommentVNode("",!0),s.value.discount?(e.openBlock(),e.createElementBlock("div",vo,[m[9]||(m[9]=e.createElementVNode("span",null,"Discount",-1)),e.createElementVNode("span",null,"-"+e.toDisplayString(D(s.value.discount)),1)])):e.createCommentVNode("",!0)]),e.createVNode(ie),e.createElementVNode("div",go,[m[10]||(m[10]=e.createElementVNode("span",null,"Reservation Total",-1)),e.createElementVNode("span",null,e.toDisplayString(D(s.value.reservationPrice)),1)]),s.value.amountPaid!==void 0||s.value.amountDue!==void 0?(e.openBlock(),e.createBlock(ie,{key:0})):e.createCommentVNode("",!0),s.value.amountPaid!==void 0||s.value.amountDue!==void 0?(e.openBlock(),e.createElementBlock("div",ho,[s.value.amountPaid!==void 0?(e.openBlock(),e.createElementBlock("div",xo,[e.createElementVNode("span",Co,[e.createVNode(e.unref(M.CreditCard),{size:14}),m[11]||(m[11]=e.createTextVNode(" Amount paid ",-1))]),e.createElementVNode("span",No,e.toDisplayString(D(s.value.amountPaid)),1)])):e.createCommentVNode("",!0),s.value.amountDue!==void 0&&s.value.amountDue>0?(e.openBlock(),e.createElementBlock("div",Do,[e.createElementVNode("span",yo,[e.createVNode(e.unref(M.Receipt),{size:14}),m[12]||(m[12]=e.createTextVNode(" Amount due ",-1))]),e.createElementVNode("span",_o,e.toDisplayString(D(s.value.amountDue)),1)])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])])])):e.createCommentVNode("",!0),e.createVNode(Ae,{class:"gap-2 sm:justify-between"},{default:e.withCtx(()=>[s.value.reservationStatus==="needs_approval"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(Q,{variant:"destructive",onClick:y},{default:e.withCtx(()=>[e.createVNode(e.unref(M.Ban),{size:16}),m[14]||(m[14]=e.createTextVNode(" Reject Reservation ",-1))]),_:1}),e.createVNode(Q,{onClick:$},{default:e.withCtx(()=>[e.createVNode(e.unref(M.ClockCheck),{size:16}),m[15]||(m[15]=e.createTextVNode(" Approve Reservation ",-1))]),_:1})],64)):s.value.reservationStatus==="approved"?(e.openBlock(),e.createBlock(Ee,{key:1},{default:e.withCtx(()=>[e.createVNode(be,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(Q,{variant:"outline",class:"gap-2"},{default:e.withCtx(()=>[e.createVNode(e.unref(M.MoreHorizontal),{size:16}),m[16]||(m[16]=e.createTextVNode(" Actions ",-1))]),_:1})]),_:1}),e.createVNode(we,{class:"w-60",align:"start"},{default:e.withCtx(()=>[e.createVNode(J,{class:"text-xs text-muted-foreground font-normal"},{default:e.withCtx(()=>[...m[17]||(m[17]=[e.createTextVNode(" Reservation Actions ",-1)])]),_:1}),e.createVNode(X,null,{default:e.withCtx(()=>[e.createVNode(H,{onClick:S,class:"gap-2 cursor-pointer"},{default:e.withCtx(()=>[e.createVNode(e.unref(M.Download),{size:16,class:"text-muted-foreground"}),m[18]||(m[18]=e.createElementVNode("span",null,"Download PDF",-1))]),_:1})]),_:1}),e.createVNode(le),e.createVNode(X,null,{default:e.withCtx(()=>[e.createVNode(J,{class:"text-xs text-muted-foreground font-normal"},{default:e.withCtx(()=>[...m[19]||(m[19]=[e.createTextVNode(" Communication ",-1)])]),_:1}),e.createVNode(H,{onClick:A,class:"gap-2 cursor-pointer"},{default:e.withCtx(()=>[e.createVNode(e.unref(M.MailCheck),{size:16,class:"text-muted-foreground"}),m[20]||(m[20]=e.createElementVNode("span",null,"(Re)send Confirmation Mail",-1))]),_:1})]),_:1}),e.unref(a)("manage-reservations")?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(le),e.createVNode(X,null,{default:e.withCtx(()=>[e.createVNode(J,{class:"text-xs text-muted-foreground font-normal"},{default:e.withCtx(()=>[...m[21]||(m[21]=[e.createTextVNode(" Cancellation ",-1)])]),_:1}),e.createVNode(H,{onClick:k,class:"gap-2 cursor-pointer",variant:"destructive",disabled:w.value},{default:e.withCtx(()=>[e.createVNode(e.unref(M.XCircle),{size:16}),m[22]||(m[22]=e.createElementVNode("span",null,"Cancel Reservation",-1))]),_:1},8,["disabled"]),s.value?.reservationPrice&&s.value.reservationPrice>0?(e.openBlock(),e.createBlock(H,{key:0,onClick:re,class:"gap-2 cursor-pointer text-orange-600 dark:text-orange-400 focus:text-orange-600 dark:focus:text-orange-400",disabled:w.value},{default:e.withCtx(()=>[e.createVNode(e.unref(M.Gift),{class:"text-inherit",size:16}),m[23]||(m[23]=e.createElementVNode("span",null,"Cancel & Send Coupon",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0)]),_:1})],64)):e.createCommentVNode("",!0)]),_:1})]),_:1})):e.createCommentVNode("",!0)]),_:1})]),_:1})]),_:1},8,["open"]),e.createVNode(Vt,{ref_key:"cancelReservationDialog",ref:v,onConfirm:N},null,512),e.createVNode(Bt,{ref_key:"approveReservationDialog",ref:x,onConfirm:B},null,512),e.createVNode(Rt,{ref_key:"rejectReservationDialog",ref:f,onConfirm:j},null,512),e.createVNode(bt,{ref_key:"transferReservationDialog",ref:u},null,512)],64)}}});exports.Fuse=U;exports._sfc_main=Vo;
349
+ We would love to see you another time!`)},x=()=>{if(!c.value){if(!d.value||!s.value||!p.value)return alert("Please fill in all the fields.");i({to:d.value,subject:s.value,body:p.value})}r.value=!1;const{$confetti:f}=useNuxtApp();f(),l("confirm")};return t({openDialog:v}),(f,u)=>{const g=e.resolveComponent("DialogTitle"),b=e.resolveComponent("DialogDescription"),E=e.resolveComponent("DialogHeader"),w=e.resolveComponent("Checkbox"),D=e.resolveComponent("Label"),V=e.resolveComponent("Input"),S=e.resolveComponent("Textarea"),$=e.resolveComponent("Button"),y=e.resolveComponent("DialogFooter"),A=e.resolveComponent("DialogScrollContent"),k=e.resolveComponent("Dialog");return e.openBlock(),e.createBlock(k,{open:r.value,"onUpdate:open":u[5]||(u[5]=N=>r.value=N)},{default:e.withCtx(()=>[e.createVNode(A,{class:"sm:max-w-3xl"},{default:e.withCtx(()=>[e.createVNode(E,null,{default:e.withCtx(()=>[e.createVNode(g,null,{default:e.withCtx(()=>[...u[6]||(u[6]=[e.createTextVNode(" Reject Reservation Request ",-1)])]),_:1}),e.createVNode(b)]),_:1}),e.createElementVNode("div",Mt,[e.createVNode(w,{modelValue:c.value,"onUpdate:modelValue":u[0]||(u[0]=N=>c.value=N),id:"reject-dialog-skip-mail",class:"border-black/80 dark:border-gray-200",disabled:!e.unref(a).mailAccount},null,8,["modelValue","disabled"]),e.createVNode(D,{for:"reject-dialog-skip-mail",class:"py-4 pl-2 pr-4"},{default:e.withCtx(()=>[...u[7]||(u[7]=[e.createTextVNode("Do not send email to customer",-1)])]),_:1})]),e.createElementVNode("div",{class:e.normalizeClass(["grid gap-4 py-4",{"opacity-50":c.value}])},[e.createElementVNode("div",$t,[e.createVNode(D,{for:"reject-dialog-email"},{default:e.withCtx(()=>[...u[8]||(u[8]=[e.createTextVNode("To:",-1)])]),_:1}),e.createVNode(V,{modelValue:d.value,"onUpdate:modelValue":u[1]||(u[1]=N=>d.value=N),disabled:c.value,id:"reject-dialog-email"},null,8,["modelValue","disabled"])]),e.createElementVNode("div",Ft,[e.createVNode(D,{for:"reject-dialog-subject"},{default:e.withCtx(()=>[...u[9]||(u[9]=[e.createTextVNode("Subject:",-1)])]),_:1}),e.createVNode(V,{modelValue:s.value,"onUpdate:modelValue":u[2]||(u[2]=N=>s.value=N),disabled:c.value,id:"reject-dialog-subject"},null,8,["modelValue","disabled"])]),e.createElementVNode("div",St,[e.createVNode(D,{for:"reject-dialog-body"},{default:e.withCtx(()=>[...u[10]||(u[10]=[e.createTextVNode("Body:",-1)])]),_:1}),e.createVNode(S,{modelValue:p.value,"onUpdate:modelValue":u[3]||(u[3]=N=>p.value=N),disabled:c.value,id:"reject-dialog-body"},null,8,["modelValue","disabled"])])],2),e.createVNode(y,null,{default:e.withCtx(()=>[e.createVNode($,{variant:"outline",onClick:u[4]||(u[4]=N=>r.value=!1)},{default:e.withCtx(()=>[...u[11]||(u[11]=[e.createTextVNode("Close",-1)])]),_:1}),e.createVNode($,{variant:"destructive",onClick:x},{default:e.withCtx(()=>[...u[12]||(u[12]=[e.createTextVNode("Reject reservation",-1)])]),_:1})]),_:1})]),_:1})]),_:1},8,["open"])}}}),It={key:0,class:"space-y-6 py-4"},Tt={class:"space-y-3"},jt={class:"bg-muted/30 rounded-lg p-4 space-y-3"},Ot={class:"flex items-center gap-3"},Lt={class:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center"},Pt={class:"font-medium"},zt={class:"grid gap-2 text-sm"},Ut={key:0,class:"flex items-center gap-2 text-muted-foreground"},Ht=["href"],Wt={key:1,class:"flex items-center gap-2 text-muted-foreground"},Kt=["href"],Gt={class:"space-y-3"},Yt={class:"grid grid-cols-2 gap-3"},Qt={class:"bg-muted/30 rounded-lg p-3"},Jt={class:"flex items-center gap-2 text-muted-foreground mb-1"},Xt={class:"font-medium"},Zt={class:"bg-muted/30 rounded-lg p-3"},qt={class:"flex items-center gap-2 text-muted-foreground mb-1"},eo={class:"font-medium"},to={key:0,class:"space-y-3"},oo={class:"bg-muted/30 rounded-lg p-4"},no={class:"flex items-start justify-between"},so={class:"flex items-start gap-3"},ao={class:"h-9 w-9 rounded-lg bg-primary/10 flex items-center justify-center mt-0.5"},ro={class:"font-medium"},io={class:"text-sm text-muted-foreground"},lo={class:"font-semibold"},co={class:"space-y-3"},uo={class:"bg-muted/30 rounded-lg p-4 space-y-3"},po={class:"space-y-2 text-sm"},mo={class:"flex justify-between"},fo={key:0,class:"flex justify-between"},vo={key:1,class:"flex justify-between text-green-600 dark:text-green-400"},go={class:"flex justify-between font-semibold"},ho={key:1,class:"space-y-2 text-sm"},xo={key:0,class:"flex justify-between"},Co={class:"text-muted-foreground flex items-center gap-1.5"},No={class:"text-green-600 dark:text-green-400"},Do={key:1,class:"flex justify-between"},yo={class:"text-muted-foreground flex items-center gap-1.5"},_o={class:"text-orange-600 dark:text-orange-400 font-medium"},Vo=e.defineComponent({__name:"ReservationDetailDialog",emits:["cancelled","confirmed","rejected"],setup(o,{expose:t,emit:n}){const{hasPermission:a}=I.useModulePermissions(),{config:i}=I.useModule(),l=I.useFirebaseIntegration(i.project),r=e.inject("event",e.ref(null)),c=n,d=e.ref(!1),s=e.ref(null),p=e.ref(!1),v=e.useTemplateRef("cancelReservationDialog"),x=e.useTemplateRef("approveReservationDialog"),f=e.useTemplateRef("rejectReservationDialog"),u=e.useTemplateRef("transferReservationDialog"),g=C=>{s.value=C,d.value=!0},b=e.computed(()=>s.value?.customerInfo&&`${s.value.customerInfo.firstName} ${s.value.customerInfo.lastName}`.trim()||"Unknown Customer"),E=e.computed(()=>{let C=s.value?.status;const m=s.value?.reservationStatus;switch(["needs_approval","rejected","approved","cancelled"].includes(m)&&(C=m),C){case"needs_approval":return{label:"Needs Approval",class:"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400"};case"rejected":return{label:"Rejected",class:"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400"};case"approved":return{label:"Approved",class:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400"};case"pending":return{label:"Pending",class:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400"};case"cancelled":return{label:"Cancelled",class:"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400"};default:return{label:C||"Unknown",class:"bg-muted text-muted-foreground"}}}),w=e.computed(()=>s.value?.status==="cancelled"),D=C=>C==null||typeof C!="number"?"—":`€${C?.toFixed(2)}`,V=C=>{if(!C)return"—";if(C<60)return`${C} min`;const m=Math.floor(C/60),_=C%60;return _>0?`${m}h ${_}min`:`${m}h`},S=()=>{if(!s.value)return;let C="";const m=r?.value?.date;if(m)try{C=new Date(m).toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"})}catch{C=m}const _={date:C,resourceName:r?.value?.resource?.name};Ct(s.value,_)},$=()=>{x.value?.openDialog(s.value)},y=()=>{f.value?.openDialog(s.value)},A=()=>{x.value?.openDialog(s.value)},k=()=>{v.value?.openDialog(s.value)},N=async()=>{try{if(p.value||!s.value?.id)throw new Error("Invalid state");p.value=!0;let m=(await l.get(i.reservationsCollection,s.value.id))?.reservations||[];if(!m.find(_=>_.id===s.value.res_id))throw new Error("Reservation not found");m.find(_=>_.id===s.value.res_id).status="cancelled",await l.update(i.reservationsCollection,s.value.id,{reservations:m}),s.value.status="cancelled",z.toast.success("Reservation cancelled successfully"),c("cancelled"),d.value=!1}catch(C){console.error("Error cancelling reservation:",C),z.toast.error("Failed to cancel reservation")}finally{p.value=!1}},B=async()=>{try{if(p.value||!s.value?.id)throw new Error("Invalid state");p.value=!0;let m=(await l.get(i.reservationsCollection,s.value.id))?.reservations||[];if(!m.find(_=>_.id===s.value.res_id))throw new Error("Reservation not found");m.find(_=>_.id===s.value.res_id).status="approved",await l.update(i.reservationsCollection,s.value.id,{reservations:m}),s.value.status="approved",z.toast.success("Reservation approved successfully"),c("confirmed"),d.value=!1}catch(C){console.error("Error approving reservation:",C),z.toast.error("Failed to approve reservation")}finally{p.value=!1}},j=async()=>{try{if(p.value||!s.value?.id)throw new Error("Invalid state");p.value=!0;let m=(await l.get(i.reservationsCollection,s.value.id))?.reservations||[];if(!m.find(_=>_.id===s.value.res_id))throw new Error("Reservation not found");m.find(_=>_.id===s.value.res_id).status="rejected",await l.update(i.reservationsCollection,s.value.id,{reservations:m}),s.value.status="rejected",z.toast.success("Reservation rejected successfully"),c("rejected"),d.value=!1}catch(C){console.error("Error rejecting reservation:",C),z.toast.error("Failed to reject reservation")}finally{p.value=!1}},re=()=>{};return t({openDialog:g}),(C,m)=>{const _=e.resolveComponent("DialogTitle"),Y=e.resolveComponent("DialogDescription"),Ve=e.resolveComponent("DialogHeader"),ie=e.resolveComponent("Separator"),Q=e.resolveComponent("Button"),be=e.resolveComponent("DropdownMenuTrigger"),J=e.resolveComponent("DropdownMenuLabel"),H=e.resolveComponent("DropdownMenuItem"),X=e.resolveComponent("DropdownMenuGroup"),le=e.resolveComponent("DropdownMenuSeparator"),we=e.resolveComponent("DropdownMenuContent"),Ee=e.resolveComponent("DropdownMenu"),Ae=e.resolveComponent("DialogFooter"),ke=e.resolveComponent("DialogScrollContent"),Be=e.resolveComponent("Dialog");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(Be,{open:d.value,"onUpdate:open":m[0]||(m[0]=Me=>d.value=Me)},{default:e.withCtx(()=>[e.createVNode(ke,{class:"sm:max-w-xl"},{default:e.withCtx(()=>[e.createVNode(Ve,null,{default:e.withCtx(()=>[e.createVNode(_,{class:"flex items-center gap-3"},{default:e.withCtx(()=>[m[1]||(m[1]=e.createElementVNode("span",null,"Reservation Details",-1)),e.createElementVNode("span",{class:e.normalizeClass(["px-2.5 py-1 text-xs font-medium rounded-full",E.value.class])},e.toDisplayString(E.value.label),3)]),_:1}),e.createVNode(Y,null,{default:e.withCtx(()=>[e.createTextVNode(" Booking #"+e.toDisplayString(s.value?.id?.slice(0,8)||"—"),1)]),_:1})]),_:1}),s.value?(e.openBlock(),e.createElementBlock("div",It,[e.createElementVNode("div",Tt,[m[2]||(m[2]=e.createElementVNode("h3",{class:"text-sm font-semibold text-muted-foreground uppercase tracking-wide"},"Customer",-1)),e.createElementVNode("div",jt,[e.createElementVNode("div",Ot,[e.createElementVNode("div",Lt,[e.createVNode(e.unref(M.User),{size:20,class:"text-primary"})]),e.createElementVNode("div",null,[e.createElementVNode("p",Pt,e.toDisplayString(b.value),1)])]),e.createElementVNode("div",zt,[s.value.customerInfo?.email?(e.openBlock(),e.createElementBlock("div",Ut,[e.createVNode(e.unref(M.Mail),{size:14}),e.createElementVNode("a",{href:`mailto:${s.value.customerInfo.email}`,class:"hover:text-foreground transition-colors"},e.toDisplayString(s.value.customerInfo.email),9,Ht)])):e.createCommentVNode("",!0),s.value.customerInfo?.phone?(e.openBlock(),e.createElementBlock("div",Wt,[e.createVNode(e.unref(M.Phone),{size:14}),e.createElementVNode("a",{href:`tel:${s.value.customerInfo.phone}`,class:"hover:text-foreground transition-colors"},e.toDisplayString(s.value.customerInfo.phone),9,Kt)])):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",Gt,[m[5]||(m[5]=e.createElementVNode("h3",{class:"text-sm font-semibold text-muted-foreground uppercase tracking-wide"},"Reservation",-1)),e.createElementVNode("div",Yt,[e.createElementVNode("div",Qt,[e.createElementVNode("div",Jt,[e.createVNode(e.unref(M.Clock),{size:14}),m[3]||(m[3]=e.createElementVNode("span",{class:"text-xs"},"Time",-1))]),e.createElementVNode("p",Xt,e.toDisplayString(s.value.startTime)+" - "+e.toDisplayString(s.value.endTime),1)]),e.createElementVNode("div",Zt,[e.createElementVNode("div",qt,[e.createVNode(e.unref(M.Users),{size:14}),m[4]||(m[4]=e.createElementVNode("span",{class:"text-xs"},"Spots",-1))]),e.createElementVNode("p",eo,e.toDisplayString(s.value.spots||1)+" "+e.toDisplayString(s.value.spots===1?"person":"people"),1)])])]),s.value.pricingOption?(e.openBlock(),e.createElementBlock("div",to,[m[6]||(m[6]=e.createElementVNode("h3",{class:"text-sm font-semibold text-muted-foreground uppercase tracking-wide"},"Package",-1)),e.createElementVNode("div",oo,[e.createElementVNode("div",no,[e.createElementVNode("div",so,[e.createElementVNode("div",ao,[e.createVNode(e.unref(M.Tag),{size:18,class:"text-primary"})]),e.createElementVNode("div",null,[e.createElementVNode("p",ro,e.toDisplayString(s.value.pricingOption.name),1),e.createElementVNode("p",io,e.toDisplayString(V(s.value.pricingOption.duration)),1)])]),e.createElementVNode("p",lo,e.toDisplayString(D(s.value.pricingOption.price)),1)])])])):e.createCommentVNode("",!0),e.createElementVNode("div",co,[m[13]||(m[13]=e.createElementVNode("h3",{class:"text-sm font-semibold text-muted-foreground uppercase tracking-wide"},"Payment",-1)),e.createElementVNode("div",uo,[e.createElementVNode("div",po,[e.createElementVNode("div",mo,[m[7]||(m[7]=e.createElementVNode("span",{class:"text-muted-foreground"},"Base price",-1)),e.createElementVNode("span",null,e.toDisplayString(D(s.value.reservationBasePrice)),1)]),s.value.reservationAddOnsPrice?(e.openBlock(),e.createElementBlock("div",fo,[m[8]||(m[8]=e.createElementVNode("span",{class:"text-muted-foreground"},"Add-ons",-1)),e.createElementVNode("span",null,e.toDisplayString(D(s.value.reservationAddOnsPrice)),1)])):e.createCommentVNode("",!0),s.value.discount?(e.openBlock(),e.createElementBlock("div",vo,[m[9]||(m[9]=e.createElementVNode("span",null,"Discount",-1)),e.createElementVNode("span",null,"-"+e.toDisplayString(D(s.value.discount)),1)])):e.createCommentVNode("",!0)]),e.createVNode(ie),e.createElementVNode("div",go,[m[10]||(m[10]=e.createElementVNode("span",null,"Reservation Total",-1)),e.createElementVNode("span",null,e.toDisplayString(D(s.value.reservationPrice)),1)]),s.value.amountPaid!==void 0||s.value.amountDue!==void 0?(e.openBlock(),e.createBlock(ie,{key:0})):e.createCommentVNode("",!0),s.value.amountPaid!==void 0||s.value.amountDue!==void 0?(e.openBlock(),e.createElementBlock("div",ho,[s.value.amountPaid!==void 0?(e.openBlock(),e.createElementBlock("div",xo,[e.createElementVNode("span",Co,[e.createVNode(e.unref(M.CreditCard),{size:14}),m[11]||(m[11]=e.createTextVNode(" Amount paid ",-1))]),e.createElementVNode("span",No,e.toDisplayString(D(s.value.amountPaid)),1)])):e.createCommentVNode("",!0),s.value.amountDue!==void 0&&s.value.amountDue>0?(e.openBlock(),e.createElementBlock("div",Do,[e.createElementVNode("span",yo,[e.createVNode(e.unref(M.Receipt),{size:14}),m[12]||(m[12]=e.createTextVNode(" Amount due ",-1))]),e.createElementVNode("span",_o,e.toDisplayString(D(s.value.amountDue)),1)])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])])])):e.createCommentVNode("",!0),e.createVNode(Ae,{class:"gap-2 sm:justify-between"},{default:e.withCtx(()=>[s.value.reservationStatus==="needs_approval"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(Q,{variant:"destructive",onClick:y},{default:e.withCtx(()=>[e.createVNode(e.unref(M.Ban),{size:16}),m[14]||(m[14]=e.createTextVNode(" Reject Reservation ",-1))]),_:1}),e.createVNode(Q,{onClick:$},{default:e.withCtx(()=>[e.createVNode(e.unref(M.ClockCheck),{size:16}),m[15]||(m[15]=e.createTextVNode(" Approve Reservation ",-1))]),_:1})],64)):s.value.reservationStatus==="approved"?(e.openBlock(),e.createBlock(Ee,{key:1},{default:e.withCtx(()=>[e.createVNode(be,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(Q,{variant:"outline",class:"gap-2"},{default:e.withCtx(()=>[e.createVNode(e.unref(M.MoreHorizontal),{size:16}),m[16]||(m[16]=e.createTextVNode(" Actions ",-1))]),_:1})]),_:1}),e.createVNode(we,{class:"w-60",align:"start"},{default:e.withCtx(()=>[e.createVNode(J,{class:"text-xs text-muted-foreground font-normal"},{default:e.withCtx(()=>[...m[17]||(m[17]=[e.createTextVNode(" Reservation Actions ",-1)])]),_:1}),e.createVNode(X,null,{default:e.withCtx(()=>[e.createVNode(H,{onClick:S,class:"gap-2 cursor-pointer"},{default:e.withCtx(()=>[e.createVNode(e.unref(M.Download),{size:16,class:"text-muted-foreground"}),m[18]||(m[18]=e.createElementVNode("span",null,"Download PDF",-1))]),_:1})]),_:1}),e.createVNode(le),e.createVNode(X,null,{default:e.withCtx(()=>[e.createVNode(J,{class:"text-xs text-muted-foreground font-normal"},{default:e.withCtx(()=>[...m[19]||(m[19]=[e.createTextVNode(" Communication ",-1)])]),_:1}),e.createVNode(H,{onClick:A,class:"gap-2 cursor-pointer"},{default:e.withCtx(()=>[e.createVNode(e.unref(M.MailCheck),{size:16,class:"text-muted-foreground"}),m[20]||(m[20]=e.createElementVNode("span",null,"(Re)send Confirmation Mail",-1))]),_:1})]),_:1}),e.unref(a)("manage-reservations")?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(le),e.createVNode(X,null,{default:e.withCtx(()=>[e.createVNode(J,{class:"text-xs text-muted-foreground font-normal"},{default:e.withCtx(()=>[...m[21]||(m[21]=[e.createTextVNode(" Cancellation ",-1)])]),_:1}),e.createVNode(H,{onClick:k,class:"gap-2 cursor-pointer",variant:"destructive",disabled:w.value},{default:e.withCtx(()=>[e.createVNode(e.unref(M.XCircle),{size:16}),m[22]||(m[22]=e.createElementVNode("span",null,"Cancel Reservation",-1))]),_:1},8,["disabled"]),s.value?.reservationPrice&&s.value.reservationPrice>0?(e.openBlock(),e.createBlock(H,{key:0,onClick:re,class:"gap-2 cursor-pointer text-orange-600 dark:text-orange-400 focus:text-orange-600 dark:focus:text-orange-400",disabled:w.value},{default:e.withCtx(()=>[e.createVNode(e.unref(M.Gift),{class:"text-inherit",size:16}),m[23]||(m[23]=e.createElementVNode("span",null,"Cancel & Send Coupon",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0)]),_:1})],64)):e.createCommentVNode("",!0)]),_:1})]),_:1})):e.createCommentVNode("",!0)]),_:1})]),_:1})]),_:1},8,["open"]),e.createVNode(Vt,{ref_key:"cancelReservationDialog",ref:v,onConfirm:N},null,512),e.createVNode(Bt,{ref_key:"approveReservationDialog",ref:x,onConfirm:B},null,512),e.createVNode(Rt,{ref_key:"rejectReservationDialog",ref:f,onConfirm:j},null,512),e.createVNode(bt,{ref_key:"transferReservationDialog",ref:u},null,512)],64)}}});exports.Fuse=U;exports._sfc_main=Vo;