1import{_ as de}from"./CM2C2V57.js";import{_ as me}from"./B0DsJqWt.js";import{_ as fe}from"./D0rm-pGk.js";import{_ as be}from"./C4_TKTuz.js";import{_ as pe}from"./DZN_r56V.js";import{b as ge,ae as ke,a9 as B,U as ve,L as m,b9 as _e,e as he,u as xe,i as ye,o as we,f as u,g as y,k as s,w as a,V as d,h as l,n as i,ar as P,p as E,q as r,j as $,r as N,t as v,l as L,F as Z,D as ee,I as Se,x as Fe,y as Te,m as Ve,d1 as Ce,s as W,B as qe,R as Ie,E as De,z as $e,M as p,C as Le,X as ze}from"./BsIkG1OG.js";import{u as Be}from"./Dek6Ww68.js";import{V as Ee,a as Re,b as Ae,c as je}from"./CyE212cX.js";(function(){try{var g=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},h=new g.Error().stack;h&&(g._sentryDebugIds=g._sentryDebugIds||{},g._sentryDebugIds[h]="5a0e7bd3-48ab-4d73-a004-7f38a598d101",g._sentryDebugIdIdentifier="sentry-dbid-5a0e7bd3-48ab-4d73-a004-7f38a598d101")}catch{}})();const Pe=()=>{const{$apiFetch:g}=ge(),h=ke(),f=m(!1),C=m(!1),x=m(null),q=m(null),w=m(null),I=async(S,n)=>{f.value=!0,x.value=null;try{const b=new URLSearchParams({id:S,c:n}),o=await g(`/api/tickets/feedback?${b.toString()}`,{method:"GET"});return o.result==="success"?(q.value=o.status||null,w.value=o.data&&o.status==="ready"?o.data:null,o):(x.value=o.message||"Failed to load ticket feedback",q.value=null,w.value=null,o)}catch(b){const o=b.data?.message||b.message||"Failed to load ticket feedback";return x.value=o,q.value=null,w.value=null,{result:"error",message:o,error_code:b.data?.error_code}}finally{f.value=!1}},c=async S=>{C.value=!0;try{const n=await g("/api/tickets/feedback",{method:"POST",body:S});return n.result==="success",n}catch(n){return{result:"error",message:n.data?.statusMessage||n.data?.message||n.statusMessage||n.message||"Failed to submit feedback",error_code:n.data?.error_code||n.data?.data?.error_code}}finally{C.value=!1}},M=async(S,n,b)=>{f.value=!0,x.value=null;try{const o=await g("/api/user/switch-client",{method:"POST",body:{client_id:S}});if(!o.success)throw new Error(o.error||o.message||"Failed to switch client");await h.clearAllStoresExceptAuth(),await h.initializeClientDetails(),ve(F=>F.startsWith("ticket-feedback-"))}catch(o){const F=o.data?.message||o.message||"Failed to switch client";return x.value=F,f.value=!1,{result:"error",message:F,error_code:o.data?.error_code}}return I(n,b)};return{isLoading:B(f),isSubmitting:B(C),error:B(x),feedbackState:B(q),feedbackData:B(w),fetchTicketFeedback:I,submitTicketFeedback:c,switchToFeedbackClient:M}},Ne={class:"ticket-feedback-page fill-height d-flex align-center justify-center"},Me={key:0,class:"d-flex flex-column align-center text-center"},He={key:1,class:"d-flex flex-column align-center text-center"},Ue={key:3,class:"d-flex flex-column align-center text-center"},Oe={class:"text-body-1 text-medium-emphasis"},We={key:4,class:"d-flex flex-column align-center text-center"},Ge={class:"text-h5 font-weight-medium text-on-surface mb-3"},Ke={class:"text-body-1 text-medium-emphasis mb-0"},Xe={key:5,class:"d-flex flex-column align-center text-center"},Ye={class:"text-body-1 text-medium-emphasis mb-0"},Je={class:"d-flex justify-center mb-5"},Qe={class:"text-h5 font-weight-medium text-on-surface mb-0"},Ze={class:"d-flex flex-column ga-3 mt-2"},et=_e({__name:"ticket-feedback",setup(g){he({title:"Ticket Feedback"});const h=xe(),f=ye("showSnackbar"),{formatDate:C}=Be(),{isLoading:x,isSubmitting:q,error:w,feedbackState:I,feedbackData:c,fetchTicketFeedback:M,submitTicketFeedback:S,switchToFeedbackClient:n}=Pe(),b=m(null),o=m(""),F=m(!1),H=m(!1),T=m(null),R=m(""),z=m({}),A=p(()=>{const e=h.query.tid;return Array.isArray(e)?e[0]||"":String(e||"")}),j=p(()=>{const e=h.query.c;return Array.isArray(e)?e[0]||"":String(e||"")}),G=p(()=>!A.value||!j.value),te=p(()=>F.value||I.value==="already_submitted"),K=p(()=>T.value?`${T.value.firstname} ${T.value.lastname}`.trim():""),V=p(()=>{const e=c.value?.staff_ratings||[];return e.length>0?e.map((t,_)=>Y(t,_)):(c.value?.staff_involved||[]).map((t,_)=>Y({id:t,name:t,role:"Support specialist"},_))}),ae=p(()=>
1{if(!c.value)return[];const e=[];return c.value.subject&&e.push({label:"Subject",value:c.value.subject}),e.push({label:"Opened",value:C(c.value.opened_at)},{label:"Last reply",value:C(c.value.last_replied_at)},{label:"Staff",value:V.value.map(t=>t.name).join(", ")||"None"},{label:"Duration",value:c.value.total_duration}),e}),X=p(()=>V.value.map(e=>({staff_id:e.id,name:e.name,rating:z.value[e.id]||0}))),U=p(()=>V.value.length===0),se=p(()=>U.value?[Le.requiredField,e=>e.trim().length>0||"Feedback is required",e=>e.trim().length>=5||"Feedback must be at least 5 characters"]:[e=>!e.trim()||e.trim().length>=5||"Feedback must be at least 5 characters"]),Y=(e,t)=>({id:String(e.id||e.name||t),name:e.name||`Support staff ${t+1}`,role:e.role||"Support specialist",rating:e.rating||0}),le=()=>{z.value=V.value.reduce((e,t)=>(e[t.id]=t.rating||0,e),{})},D=p(()=>{const e=I.value;if(!e||e==="ready"||e==="wrong_client"||e==="already_submitted")return null;switch(e){case"not_closed":return{type:"warning",avatarColor:"amber-lighten-5",icon:"$clockIcon",title:"Ticket still open",message:R.value||"Feedback can be provided once this ticket is closed."};case"feedback_disabled":return{type:"info",avatarColor:"blue-lighten-5",icon:"$infoIcon",title:"Feedback unavailable",message:R.value||"Feedback is not enabled for this ticket department."};case"no_access":case"not_found":return{type:"error",avatarColor:"red-lighten-5",icon:"$errorIcon",title:"Feedback request not found",message:R.value||"We could not find a feedback request for this account."};default:return e}}),J=e=>{R.value=e.message||"",T.value=e.status==="wrong_client"&&e.data?.required_client?e.data.required_client:null,e.status==="ready"&&le(),e.result==="error"&&e.message&&f?.(e.message,"error")},oe=async()=>{if(G.value)return;const e=await M(A.value,j.value);J(e)},ne=async()=>{if(!T.value)return;H.value=!0;const e=await n(T.value.id,A.value,j.value);J(e),H.value=!1},Q=async()=>{if(!(await b.value?.validate())?.valid)return;if(V.value.length>0&&X.value.some(O=>O.rating<1)){f?.("Please rate each support staff member","error");return}const _=await S({tid:A.value,c:j.value,feedback_text:o.value.trim(),staff_ratings:X.value});if(_.result==="success"){F.value=!0,o.value="",z.value={},f?.(_.message||"Feedback submitted successfully","success");return}f?.(_.message||"Failed to submit feedback","error")};return we(oe),(e,t)=>{const _=de,O=me,re=fe,ie=be,ue=pe;return u(),y("div",Ne,[s(L,{class:"w-100",justify:"center",align:"center"},{default:a(()=>[s(d,{cols:"12",md:"8",lg:"6",xl:"5"},{default:a(()=>[l(x)?(u(),y("div",Me,[s(_,{name:"loader",width:"180px",height:"180px"}),t[1]||(t[1]=i("h3",{class:"text-h5 font-weight-medium mb-2 mt-4"},"Loading feedback request",-1)),t[2]||(t[2]=i("p",{class:"text-subtitle-2 text-medium-emphasis mb-0"},"Checking your ticket and account access.",-1))])):l(G)?(u(),y("div",He,[s(P,{size:"80",color:"red-lighten-5",class:"mb-4"},{default:a(()=>[s(E,{size:"40",color:"error"},{default:a(()=>[...t[3]||(t[3]=[r(" $errorIcon ",-1)])]),_:1})]),_:1}),t[4]||(t[4]=i("h1",{class:"text-h5 font-weight-medium text-on-surface mb-3"},"Feedback link unavailable",-1)),t[5]||(t[5]=i("p",{class:"text-body-1 text-medium-emphasis mb-0"},"This feedback link is invalid or incomplete.",-1))])):l(te)?(u(),$(O,{key:2,title:"Thank you for your feedback",description:"Your response has been submitted successfully."},{actions:a(()=>[s(N,{to:"/support/tickets",height:"44",color:"secondary",class:"px-12"},{default:a(()=>[...t[6]||(t[6]=[r(" Back to Tickets ",-1)])]),_:1})]),_:1})):l(I)==="wrong_client"&&l(T)?(u(),y("div",Ue,[s(P,{size:"80",color:"blue-lighten-5",class:"mb-4"},{default:a(()=>[s(E,{size:"40",color:"info"},{default:a(()=>[...t[7]||(t[7]=[r(" $accountIcon ",-1)])]),_:1})]),_:1}),t[8]||(t[8]=i("h1",{class:"text-h5 font-weight-medium text-on-surface mb-3"},"Switch client account",-1)),i("p",Oe,"This feedback request belongs to "+v(l(K))+".",1),t[9]||(t[9]=i("p",{class:"text-body-1 text-medium-emphasis mb-6"},"Switch to associated client to continue.",-1)),s(N,{color:"primaryButtons",height:"44",class:"px-8",loading:l(H),onClick:ne},{default:a(()=>[r(" Switch to "+v(l(K)),1)]),_:1},8,["loading"])])):l(D)?(u(),y("div",We,[s(P,{size:"80",color:l(D).avatarColor,class:"mb-4"},{default:a(()=>[s(E,{size:"40",color:l(D).type},{default:a(()=>[r(v(l(D).icon),1)]),_:1},8,["color"])]),_:1},8,["color"]),i("h1",Ge,v(l(D).title),1),i("p",Ke,v(l(D).message),1)])):l(w)&&!l(c)?(u(),y("div",Xe,[s(P,{size:"80",color:"red-lighten-5",class:"mb-4"},{default:a(()=>[s(E,{size:"40",color:"error"},{default:a(()=>[...t[10]||(t[10]=[r(" $errorIcon ",-1)])]),_:1})]),_:1}),t[11]||(t[11]=i("h1",{class:"text-h5 font-weight-medium text-on-surface mb-3"},"Feedback request failed",-1)),i("p",Ye,v(l(w)),1)])):l(c)?(u(),$(L,{key:6,dense:""},{default:a(()=>[s(d,{cols:"12",class:"text-center mb-7"},{default:a(()=>[i("div",Je,[s(re,{icon:"$feedbackIcon",color:"primary"})]),i("h1",Qe,"Share feedback for ticket #"+v(l(c).tid),1)]),_:1}),s(d,{cols:"12",class:"mb-7"},{default:a(()=>[s(Ee,{flat:"",class:"transaction-panels"},{default:a(()=>[s(Re,{class:"bg-grey-lighten-5 rounded-lg"},{default:a(()=>[s(Ae,{class:"text-subtitle-2 text-medium-emphasis py-4"},{default:a(()=>[...t[12]||(t[12]=[r("Ticket Details",-1)])]),_:1}),s(je,null,{default:a(()=>[s(L,{dense:"",class:"text-left"},{default:a(()=>[(u(!0),y(Z,null,ee(l(ae),k=>(u(),$(d,{key:k.label,cols:"12"},{default:a(()=>[s(L,{dense:""},{default:a(()=>[s(d,{cols:"6",class:"text-subtitle-2 text-medium-emphasis"},{default:a(()=>[r(v(k.label),1)]),_:2},1024),s(d,{cols:"6",class:"text-subtitle-2 font-weight-medium text-right text-truncate"},{default:a(()=>[r(v(k.value),1)]),_:2},1024),s(d,{cols:"12"},{default:a(()=>[s(Se,{class:"my-1"})]),_:1})]),_:2},1024)]),_:2},1024))),128))]),_:1})]),_:1})]),_:1})]),_:1})]),_:1}),s(d,{cols:"12"},{default:a(()=>[s(Fe,{ref_key:"feedbackForm",ref:b,onSubmit:Te(Q,["prevent"])},{default:a(()=>[l(V).length?(u(),$(L,{key:0,dense:"",class:"mb-6"},{default:a(()=>[s(d,{cols:"12"},{default:a(()=>[s(ie,null,{default:a(()=>[...t[13]||(t[13]=[r("Rate the support staff",-1)])]),_:1}),t[14]||(t[14]=i("p",{class:"text-subtitle-2 text-medium-emphasis mt-1 mb-0"},"Score each person who worked on this ticket.",-1))]),_:1}),(u(!0),y(Z,null,ee(l(V),k=>(u(),$(d,{key:k.id,cols:"12"},{default:a(()=>
1[s(Ve,{rounded:"lg",border:"thin",class:"dotted-background d-flex flex-column align-start ga-3 pa-4"},{default:a(()=>[s(ue,{class:"d-flex align-center ga-2"},{default:a(()=>[s(E,null,{default:a(()=>[...t[15]||(t[15]=[r("$supportAgentIcon",-1)])]),_:1}),r(" "+v(k.name),1)]),_:2},1024),s(Ce,{modelValue:l(z)[k.id],"onUpdate:modelValue":ce=>l(z)[k.id]=ce,density:"compact",hover:"",length:10,"active-color":"primary"},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024)]),_:2},1024))),128))]),_:1})):W("",!0),s(L,{dense:""},{default:a(()=>[s(d,{cols:"12",class:"d-flex align-center ga-2"},{default:a(()=>[s(qe,null,{default:a(()=>[...t[16]||(t[16]=[r("Tell us about your support experience",-1)])]),_:1}),l(U)?W("",!0):(u(),$(Ie,{key:0,size:"small",density:"compact",variant:"flat",color:"secondary",label:""},{default:a(()=>[...t[17]||(t[17]=[r(" Optional ",-1)])]),_:1}))]),_:1}),s(d,{cols:"12"},{default:a(()=>[s(De,{modelValue:l(o),"onUpdate:modelValue":t[0]||(t[0]=k=>$e(o)?o.value=k:null),rules:l(se),placeholder:"What went well? What could we improve next time?",rows:"5","auto-grow":"",counter:"1000",maxlength:"1000",required:l(U)},null,8,["modelValue","rules","required"])]),_:1}),s(d,{cols:"12"},{default:a(()=>[i("div",Ze,[s(N,{block:"",color:"primaryButtons",height:"40",loading:l(q),onClick:Q},{default:a(()=>[...t[18]||(t[18]=[r(" Submit Feedback ",-1)])]),_:1},8,["loading"]),s(N,{block:"",height:"40",variant:"outlined",color:"secondaryButtons","prepend-icon":"$chevronLeftIcon",to:"/support/tickets"},{default:a(()=>[...t[19]||(t[19]=[r(" Back to Tickets ",-1)])]),_:1})])]),_:1})]),_:1})]),_:1},512)]),_:1})]),_:1})):W("",!0)]),_:1})]),_:1})])}}}),ut=ze(et,[["__scopeId","data-v-d9687a16"]]);export{ut 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.