1import{b as i,g as P,w as l,f as n,t as _,bp as he,e as u,v as R,I as z,G as we,j as o,bf as be,c2 as ye,Y as k,c as F,r as B,u as ke,a4 as De,h as D,bY as Re,F as A,m as Z,bZ as xe,n as Ce,M as J,V as Ae,y as m,bl as w,O as Ye,aA as $e,at as Se,an as Ne,k as Ve,d as H}from"./index-DUWew8AW.js";import{R as Me}from"./ReportingResource-DVqEy9lw.js";import{R as Te}from"./ReportState-D-eTEtEn.js";import{_ as Be}from"./CsvExport-Bi2HZRvg.js";import{u as Pe}from"./useReporting-C_ILI5m4.js";import{_ as qe}from"./PdfCover-C-sFq0YP.js";import{u as Oe}from"./useChart-D3rrKuZG.js";import{V as Le}from"./VRating-BWqBPr2Z.js";import"./PartnerResource-CkZM66x5.js";import"./Chart-BU8UWJuK.js";const je={class:"text-sm text-gray-700"},Ee={class:"text-3xl font-bold"},Fe={key:0,class:"mt-1 text-xs text-gray-500"},Y={__name:"MetricBox",props:["metric","total","previous_total"],setup(b){return(f,q)=>(i(),P(z,{class:"h-full p-4"},{default:l(()=>[n("div",je,_(b.metric),1),n("div",Ee,_(b.total),1),he(f.$slots,"default"),b.previous_total!=null?(i(),u("div",Fe," Previous period: "+_(b.previous_total),1)):R("",!0)]),_:3}))}},ze=["width","height"],Ie={__name:"views-chart",props:{width:{type:[Number,String],default:400},height:{type:[Number,String],default:400},viewsData:{type:Object,required:!0},options:{type:Object,default:void 0}},setup(b){const f=b,{canvasEl:q}=Oe({type:"line",data:()=>f.viewsData,options:()=>({legend:{display:!0,position:"bottom"},tooltips:{mode:"label",positions:"nearest",intersect:!1,titleFontSize:16,bodyFontSize:16,footerFontSize:16,callbacks:{afterTitle:()=>{window.total=0},label($,O){const{label:W}=O.datasets[$.datasetIndex],h=O.datasets[$.datasetIndex].data[$.index];return window.total+=h,`${W} : ${h}`},footer:()=>`Total: ${window.total.toString()}`}},scales:{xAxes:[{stacked:!0,gridLines:{color:"rgba(0, 0, 0, 0)"}}],yAxes:[{type:"linear",display:!0,position:"left",id:"y-axis-0",ticks:{beginAtZero:!0},gridLines:{display:!0},labels:{show:!0}}]},responsive:!0,maintainAspectRatio:!1,...f.options})});return($,O)=>(i(),u("div",null,[n("canvas",{ref_key:"canvasEl",ref:q,width:b.
1width,height:b.height},null,8,ze)]))}},Ue={key:0},Ge={key:2,class:"my-3 mx-3 md:mx-4 lg:mx-6 bg-red-700 text-white p-3 font-bold rounded-sm animate-pulse text-lg uppercase"},He={class:"p-3 pb-12 md:p-4 lg:p-6"},We={key:0,class:"grid gap-4 md:grid-cols-2"},Ze={class:"grid grid-cols-[140px_1fr] gap-x-4 gap-y-2 text-sm"},Je={class:"font-semibold"},Ke=["href"],Qe={class:"break-all"},Xe={class:"grid grid-cols-[1fr_auto] gap-x-4 gap-y-2 text-sm"},et={class:"font-semibold"},tt={key:0},st={key:1},rt={key:2},it={class:"grid grid-cols-2 gap-4 md:grid-cols-3 lg:grid-cols-5"},at={class:"grid gap-4 md:grid-cols-2"},gt={__name:"ClientGoogleBusinessProfile",props:{client:{type:Object},startDate:{type:String},endDate:{type:String}},setup(b){const f=b,q=De(),{showErrorNotification:$}=ke(),{setReportDates:O}=Pe(),W=["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY","SUNDAY"],h=B([]),I=B(0),L=B(!1),S=B(null),ie={VCard:{variant:"flat",border:!0}};function K(t){return Number(t||0).toFixed(1)}const ae=B([{title:"Reviewer",key:"reviewer",width:200},{title:"Rating",key:"star_rating",width:100},{title:"Comment",key:"comment"},{title:"Replied",key:"replied",width:150,align:"center"},{title:"Review Date",key:"report_date",width:250}]),U=B(!1),Q=F(()=>S.value&&S.value!=="all"?h.value.filter(t=>t.id===S.value):S.value==="all"?[h.value[0]]:h.value),oe=F(()=>`${H(f.startDate).format("MMMM DD, YYYY")} to 2 ${H(f.endDate).format("MMMM DD, YYYY")}`),N=F(()=>{const{pdf:t}=q.query;return!!t}),le=F(()=>`GBP Report Reviews ${f.startDate} - ${f.endDate}`),ne={location:{title:"Location"},address:{title:"Address"},reviewer:{title:"Reviewer"},rating:{title:"Rating"},comment:{title:"Comment"},replied:{title:"Replied"},reviewDate:{title:"Review Date"}},X=F(()=>{const t=k.cloneDeep(Q.value),s=[];return t.forEach(e=>{let r=e.location_name,{address:a}=e;e.current_period.reviews.forEach(c=>{var g;if(e.id==="all"){const v=(g=h.value)==null?void 0:g.find(x=>x.location_id===c.location_id);r=(v==null?void 0:v.location_name)||"-",a=(v==null?void 0:v.address)||"-"}s.push({location:r,address:a,reviewer:c.reviewer,rating:c.star_rating,comment:c.comment,replied:c.replied?"Yes":"No",reviewDate:H(c.report_date).format("MM/DD/YYYY")})})}),s});function de(t,s){t.id&&(S.value=t.id,I.value=s)}function ue(t){return t.hours>12?t.minutes?`${t.hours-12}:${t.minutes}PM`:`${t.hours-12}PM`:t.minutes?`${t.hours}:${t.minutes}AM`:`${t.hours}AM`}async function ee(){var c;const{startDate:t,endDate:s}=f;L.value=!0,h.value=[];const e=await ye(f.client.id),r=await Me.getGoogleBusinessReport(e,t,s).then(g=>(U.value=!1,g.data)).catch(()=>{$(),L.value=!1,U.value=!0});if(U.value)return;const a=[];if(r&&r.length>1){const g=r.map(y=>y.current_period.reviews).flat(),v=r.reduce((y,d)=>y+d.current_period.total_reviews,0),x=r.reduce((y,d)=>y+d.current_period.total_stars,0);let j=5;g.length>0&&(j=x/v);const E=k.sumBy(r,"current_period.views_search"),G=k.sumBy(r,"current_period.views_maps"),M={},te=k.clone(r);for(const y of te)for(const d of y.current_period.insights)M[d.report_date]?(M[d.report_date].call_clicks+=d.call_clicks,M[d.report_date].website_clicks+=d.website_clicks,M[d.report_date].business_direction_requests+=d.business_direction_requests):M[d.report_date]={report_date:d.report_date,call_clicks:d.call_clicks,website_clicks:d.website_clicks,business_direction_requests:d.business_direction_requests};const _e=k.sortBy(Object.values(M),"report_date"),se={id:"all",current_period:{average_review_rating:j,insights:_e,views_search:E,total_reviews:v,reviews:g,views_maps:G}};if(r[0].previous_period){const y=r.map(C=>C.previous_period.reviews).flat(),d=r.reduce((C,p)=>C+p.previous_period.total_reviews,0),ve=r.reduce((C,p)=>C+p.previous_period.total_stars,0);let re=5;y.length>0&&(re=ve/d);const fe=k.sumBy(r,"previous_period.views_search"),ge=k.sumBy(r,"previous_period.views_maps"),T={};for(const C of te)for(const p of C.previous_period.insights)T[p.report_date]?(T[p.report_date].call_clicks+=p.call_clicks,T[p.report_date].website_clicks+=p.website_clicks,T[p.report_date].business_direction_requests+=p.business_direction_requests):T[p.report_date]={report_date:p.report_date,call_clicks:p.call_clicks,website_clicks:p.website_clicks,business_direction_requests:p.business_direction_requests};const me=k.sortBy(Object.values(T),"report_date");se.previous_period={reviews:y,total_reviews:d,average_review_rating:re,insights:me,views_search:fe,views_maps:ge}}a.push(se),I.value=1}for(const g of r){const v=JSON.parse(g.location.open_hours);let x=[];if(v){x=v.map(E=>
2E.openDay);for(const[E,G]of W.entries())(x.length===0||x.indexOf(G)===-1)&&v.splice(E,0,{openDay:G,closed:!0})}const j={...g.location,current_period:g.current_period,open_hours:v};g.previous_period&&(j.previous_period=g.previous_period),a.push(j)}h.value=a,a.length>0&&!N.value&&(S.value=(c=r[0].location)==null?void 0:c.id),L.value=!1}function V(t,s){return k.sumBy(Object.values(t.insights),s)}function ce(t){const s=[],e=[],r=[],a=[];for(const c of Object.values(t.insights))a.push(H(c.report_date).format("MM/DD/YYYY")),s.push(c.call_clicks),e.push(c.business_direction_requests),r.push(c.website_clicks);return{datasets:[{data:s,tooltipType:"integer",label:"Phone Calls",fill:!1,backgroundColor:"black",borderColor:"black",tension:.1},{data:e,label:"Directions",fill:!1,borderColor:"gray",backgroundColor:"gray",tension:.1,tooltipType:"integer"},{borderColor:"#36A3EB",backgroundColor:"#36A3EB",tension:.1,fill:!1,data:r,label:"Website Clicks",tooltipType:"integer"}],labels:a}}function pe(t,s){return t.openTime&&t.openTime.hours?`${s(t.openTime)} - ${s(t.closeTime)}`:"Open 24 Hours"}return we(()=>q.query,()=>{ee()}),O({startDate:f.startDate,endDate:f.endDate}),ee(),(t,s)=>(i(),u("section",null,[N.value?(i(),u("div",Ue,[o(qe,{title:"Google Business Profile Report"},{header:l(()=>[D(_(b.client.name),1)]),subheader:l(()=>[D(_(oe.value),1)]),_:1})])):R("",!0),L.value&&h.value.length===0?(i(),P(Te,{key:1,state:"loading"})):R("",!0),U.value?(i(),u("div",Ge," There was an error while getting the data. Please refresh this page and try again! ")):(i(),P(be,{key:3,defaults:ie},{default:l(()=>[n("div",He,[!N.value&&h.value.length>1?(i(),P(Re,{key:0,"show-arrows":"",grow:"",modelValue:I.value,"onUpdate:modelValue":s[0]||(s[0]=e=>I.value=e),class:"mb-4"},{default:l(()=>[(i(!0),u(A,null,Z(h.value,(e,r)=>(i(),P(xe,{key:r,onClick:a=>de(e,r)},{default:l(()=>[e.address?(i(),u(A,{key:0},[D(_(e.address.split(",")[0])+" ("+_(e.category?e.category:"N/A")+") ",1)],64)):(i(),u(A,{key:1},[D("All")],64))]),_:2},1032,["onClick"]))),128))]),_:1},8,["modelValue"])):R("",!0),(i(!0),u(A,null,Z(Q.value,(e,r)=>(i(),u("div",{key:r,class:Ce(["alwaysbreak space-y-4",{"p-6":N.value}])},[e&&e.id?(i(),u(A,{key:0},[e.id!=="all"?(i(),u("div",We,[o(z,{title:"Business Details"},{default:l(()=>[o(J,null,{default:l(()=>[n("dl",Ze,[s[3]||(s[3]=n("dt",{class:"font-semibold"},"Name",-1)),n("dd",null,_(e.location_name),1),s[4]||(s[4]=n("dt",{class:"font-semibold"},"Address",-1)),n("dd",null,_(e.address?e.address:"N/A"),1),n("dt",Je,[s[2]||(s[2]=D(" Website Url ",-1)),e.website_uri?(i(),u("a",{key:0,href:e.website_uri,target:"_blank"},[o(Ae,{color:"primary",class:"cursor-pointer",size:"small"},{default:l(()=>[...s[1]||(s[1]=[D(" fa fa-link ",-1)])]),_:1})],8,Ke)):R("",!0)]),n("dd",Qe,_(e.website_uri?e.website_uri:"N/A"),1),s[5]||(s[5]=n("dt",{class:"font-semibold"},"Phone Number",-1)),n("dd",null,_(e.phone_number?e.phone_number:"N/A"),1),s[6]||(s[6]=n("dt",{class:"font-semibold"},"Category",-1)),n("dd",null,_(e.category?e.category:"N/A"),1)])]),_:2},1024)]),_:2},1024),e.open_hours?(i(),P(z,{key:0,title:"Opening Hours"},{default:l(()=>[o(J,null,{default:l(()=>[n("dl",Xe,[(i(!0),u(A,null,Z(e.open_hours,(a,c)=>(i(),u(A,{key:c},[n("dt",et,_(a.openDay),1),a.openTime?(i(),u("dd",tt,_(pe(a,ue)),1)):a.closed?(i(),u("dd",st,"Closed")):(i(),u("dd",rt))],64))),128))])]),_:2},1024)]),_:2},1024)):R("",!0)])):R("",!0),n("div",it,[o(Y,{metric:"Views (Search)",total:m(w)(e.current_period.views_search),previous_total:e.previous_period?m(w)(e.previous_period.views_search):null},null,8,["total","previous_total"]),o(Y,{metric:"Views (Map)",total:m(w)(e.current_period.views_maps),previous_total:e.previous_period?m(w)(e.previous_period.views_maps):null},null,8,["total","previous_total"]),o(Y,{metric:"Clicks to Website",total:m(w)(V(e.current_period,"website_clicks")),previous_total:e.previous_period?m(w)(V(e.previous_period,"website_clicks")):null},null,8,["total","previous_total"]),o(Y,{metric:"Phone Calls",total:m(w)(V(e.current_period,"call_clicks")),previous_total:e.previous_period?m(w)(V(e.previous_period,"call_clicks")):null},null,8,["total","previous_total"]),o(Y,{metric:"Directions",total:m(w)(V(e.current_period,"business_direction_requests")),previous_total:e.previous_period?m(w)(V(e.previous_period,"business_direction_requests")):null},null,8,["total","previous_total"])]),o(z,{title:"Actions by Day"},{default:l(()=>[o(J,null,{default:l(()=>
2[n("div",{style:Ye({width:N.value?"1400px":"100%"})},[o(Ie,{"views-data":ce(e.current_period)},null,8,["views-data"])],4)]),_:2},1024)]),_:2},1024),n("div",at,[o(Y,{metric:"Total Reviews",total:m(w)(e.current_period.total_reviews),previous_total:e.previous_period?m(w)(e.previous_period.total_reviews):null},null,8,["total","previous_total"]),o(Y,{metric:"Average Rating",total:K(e.current_period.average_review_rating),previous_total:e.previous_period?K(e.previous_period.average_review_rating):null},{default:l(()=>[o(Le,{"model-value":e.current_period.average_review_rating,"active-color":"info",color:"grey-lighten-1","empty-icon":"$ratingFull","half-increments":"",readonly:"",density:"compact",size:"small"},null,8,["model-value"])]),_:2},1032,["total","previous_total"])]),o(z,{title:"Reviews"},$e({default:l(()=>[o(Se,{"sort-by":[{key:"report_date",order:"desc"}],items:e.current_period.reviews,loading:L.value,headers:ae.value,"hide-default-footer":"","items-per-page":-1},{"item.replied":l(({item:a})=>[D(_(a.replied?"Yes":"No"),1)]),"item.report_date":l(({item:a})=>[D(_(m(Ne)(a.report_date,"LLL")),1)]),_:1},8,["items","loading","headers"])]),_:2},[!N.value&&X.value.length?{name:"append",fn:l(()=>[o(Be,{"json-data":X.value,labels:ne,"csv-title":le.value},{default:l(()=>[o(Ve,{color:"secondary",variant:"outlined"},{default:l(()=>[...s[7]||(s[7]=[D("Download Reviews",-1)])]),_:1})]),_:1},8,["json-data","csv-title"])]),key:"0"}:void 0]),1024)],64)):R("",!0)],2))),128))])]),_:1}))]))}};export{gt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.