@webority/support-react 0.137.0 → 0.137.1

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.
@@ -2,7 +2,7 @@
2
2
  "format": "webority-guidance/1",
3
3
  "package": {
4
4
  "name": "@webority/support-react",
5
- "version": "0.137.0"
5
+ "version": "0.137.1"
6
6
  },
7
7
  "components": [
8
8
  {
@@ -1 +1 @@
1
- import{createContext as e,useCallback as t,useContext as n,useEffect as r,useId as i,useMemo as a,useRef as o,useState as s}from"react";import{IST_TIME_ZONE as c,formatDateTime as l,formatFileSize as u,timeZoneLabel as d}from"@webority/ui-elements/helpers";import{Fragment as f,jsx as p,jsxs as m}from"react/jsx-runtime";import{AppActionIcon as h,AppAlert as g,AppAvatar as _,AppBadge as v,AppButton as y,AppCard as b,AppChip as x,AppChipGroup as S,AppChoiceChip as C,AppConfirmDialog as w,AppCopyButton as T,AppDataTable as E,AppDescriptions as D,AppEmptyState as O,AppFileAttachment as k,AppFloatingButton as A,AppFormActions as j,AppIcon as M,AppInput as N,AppLink as P,AppMarkdown as F,AppMetricStrip as I,AppModal as L,AppRadioGroup as R,AppSearch as z,AppSelect as B,AppSkeleton as ee,AppSpinner as V,AppStatusBadge as te,AppTabs as H,AppTextarea as U,warnInvalidValue as ne}from"@webority/ui-react";import{toBlob as re}from"html-to-image";var W=`Something went wrong. Please try again.`,G=class extends Error{constructor(e,t,n){super(t),this.name=`SupportApiError`,this.code=e,this.status=n}};async function ie(e){if(e&&typeof Blob<`u`&&e instanceof Blob)try{return JSON.parse(await e.text())}catch{return null}if(typeof e==`string`)try{return JSON.parse(e)}catch{return null}return e??null}async function K(e){if(e instanceof G)return e;let t=e?.response;if(!t)return new G(`network`,W);let n=await ie(t.data);return new G(typeof n?.code==`string`&&n.code?n.code:`unknown`,typeof n?.detail==`string`&&n.detail.trim()?n.detail:W,t.status)}async function q(e){try{return(await e()).data}catch(e){throw await K(e)}}function J(e,t,n){n!=null&&String(n).trim()!==``&&e.append(t,String(n))}function ae(e,t,n,r){(n??[]).forEach((n,i)=>{let a=n?.name||`${r}-${i+1}.png`;e.append(t,n,a)})}var oe=20;function se(e,t){return(e??[]).map((e,n)=>e?.name||`${t}-${n+1}.png`).join(`|`)}function ce(e){return e instanceof G&&typeof e.status==`number`&&e.status>=400&&e.status<=499&&e.status!==408&&e.status!==429}function le(e,t=`/api/support`){let n=(typeof t==`string`?t:t?.base??`/api/support`).replace(/\/+$/,``),r=e=>`${n}/tickets/${encodeURIComponent(e)}`,i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map;function o(){for(let e of i.keys()){if(i.size<=oe)return;a.has(e)||i.delete(e)}}async function s(e,t){let n=i.get(e)||crypto.randomUUID();i.delete(e),i.set(e,n),a.set(e,(a.get(e)??0)+1),o();try{let r=await t(n);return i.delete(e),r}catch(t){throw ce(t)&&i.delete(e),t}finally{let t=a.get(e)-1;t>0?a.set(e,t):a.delete(e)}}return{getConfig:()=>q(()=>e.get(`${n}/settings`)),listTickets:({status:t,search:r,page:i,pageSize:a}={})=>{let o=new URLSearchParams;J(o,`status`,t),J(o,`search`,r?.trim()),J(o,`page`,i),J(o,`pageSize`,a);let s=o.toString();return q(()=>e.get(`${n}/tickets${s?`?${s}`:``}`))},getTicketCounts:()=>q(()=>e.get(`${n}/tickets/counts`)),getTicket:t=>q(()=>e.get(r(t))),createTicket:({category:t,subject:r,body:i,pageUrl:a,userAgent:o,appVersion:c,files:l,screenshots:u})=>{let d=new FormData;return d.append(`category`,t??``),d.append(`subject`,r??``),d.append(`body`,i??``),J(d,`pageUrl`,a),J(d,`userAgent`,o),J(d,`appVersion`,c),ae(d,`files`,l,`file`),ae(d,`screenshots`,u,`screenshot`),s([`ticket`,t,r,i,se(l,`file`),se(u,`screenshot`)].join(`\0`),t=>q(()=>e.post(`${n}/tickets`,d,{headers:{"Idempotency-Key":t}})))},getSuggestions:async(t,{signal:r}={})=>{try{return await q(()=>e.get(`${n}/suggestions`,{params:{subject:t},signal:r}))}catch(e){if(e instanceof G&&e.status===404)return[];throw e}},reply:(t,{body:n,files:i,screenshots:a})=>{let o=new FormData;return o.append(`body`,n??``),ae(o,`files`,i,`file`),ae(o,`screenshots`,a,`screenshot`),s([`reply`,t,n,se(i,`file`),se(a,`screenshot`)].join(`\0`),n=>q(()=>e.post(`${r(t)}/replies`,o,{headers:{"Idempotency-Key":n}})))},reopen:t=>q(()=>e.post(`${r(t)}/reopen`)),cancel:t=>q(()=>e.post(`${r(t)}/cancel`)),rate:(t,{satisfaction:n,comment:i})=>{let a={satisfaction:n};return i!=null&&i.trim()!==``&&(a.comment=i.trim()),q(()=>e.post(`${r(t)}/rating`,a))},fetchAttachment:t=>q(()=>e.get(`${n}/attachments/${encodeURIComponent(t)}`,{responseType:`blob`})),confirmAction:t=>q(()=>e.post(`${n}/actions/confirm`,{token:t}))}}var ue=6e4;function de(e,{basePath:t=`/api/support/agent`}={}){let n=t.replace(/\/+$/,``),r=e=>`${n}/tickets/${encodeURIComponent(e)}`,i=(e,t)=>`${r(e)}/attachments/${encodeURIComponent(t)}`;return{getSettings:()=>q(()=>e.get(`${n}/settings`)),listTickets:(t={})=>{let r=new URLSearchParams;for(let[e,n]of Object.entries(t))n!=null&&String(n).trim()!==``&&r.append(e,String(n));let i=r.toString();return q(()=>e.get(`${n}/tickets${i?`?${i}`:``}`))},countTickets:()=>q(()=>e.get(`${n}/tickets/counts`)),getTicket:t=>q(()=>e.get(r(t))),reply:(t,{version:n,body:i,isInternal:a,files:o})=>{let s=new FormData;return s.append(`version`,n??``),s.append(`body`,i??``),s.append(`isInternal`,String(!!a)),ae(s,`files`,o,`file`),q(()=>e.post(`${r(t)}/replies`,s))},changeStatus:(t,{version:n,status:i})=>q(()=>e.post(`${r(t)}/status`,{version:n,status:i})),changePriority:(t,{version:n,priority:i})=>q(()=>e.post(`${r(t)}/priority`,{version:n,priority:i})),changeCategory:(t,{version:n,category:i})=>q(()=>e.post(`${r(t)}/category`,{version:n,category:i})),assign:(t,{version:n,agentUserId:i})=>q(()=>e.post(`${r(t)}/assignee`,{version:n,agentUserId:i})),listAgents:()=>q(()=>e.get(`${n}/agents`)),listRealms:()=>q(()=>e.get(`${n}/realms`)),attachmentUrl:i,openAttachment:async(t,n)=>{let r=await q(()=>e.get(i(t,n),{responseType:`blob`})),a=URL.createObjectURL(r);window.open(a,`_blank`,`noopener`),setTimeout(()=>URL.revokeObjectURL(a),ue)}}}var fe=3e4,pe=e(null);function me(){let e=n(pe);if(!e)throw Error(`Support agent components and hooks must be used inside <SupportAgentProvider>.`);return e}function he(){return me().client}function ge(){return me().timeZone}function _e(){return me().renderTime??null}function ve(e,t){let n=me().labels?.[e];return a(()=>n?{...t,...n}:t,[n,t])}function ye(e,n,i=!0){let[a,c]=s({data:null,loading:i,error:null}),[l,u]=s(0),d=o(e);d.current=e;let f=o(n);r(()=>{let e=f.current!==n;if(f.current=n,!i){c({data:null,loading:!1,error:null});return}let t=!0;return c(t=>({data:e?null:t.data,loading:!0,error:null})),d.current(l>0).then(e=>t&&c({data:e,loading:!1,error:null}),e=>t&&c(t=>({...t,loading:!1,error:e}))),()=>{t=!1}},[n,i,l]);let p=t(()=>u(e=>e+1),[]),m=t(e=>c(t=>({...t,data:typeof e==`function`?e(t.data):e})),[]);return{...a,reload:p,setData:m}}function be(e={}){let t=he(),{data:n,loading:r,error:i,reload:a}=ye(()=>t.listTickets(e),JSON.stringify(e));return{tickets:n?.items??[],totalCount:n?.totalCount??0,totalPages:n?.totalPages??0,loading:r,error:i,reload:a}}function xe(){let e=he(),{data:t,loading:n,error:r,reload:i}=ye(()=>e.countTickets(),`queue-counts`);return{counts:t,loading:n,error:r,reload:i}}function Se(e){let n=he(),{data:i,loading:a,error:s,reload:c,setData:l}=ye(()=>n.getTicket(e),e??``,!!e),u=o(0),d=o(e);d.current=e;let f=t(async e=>{u.current+=1;try{let t=await e();return l(t),t}finally{--u.current}},[l]),p=t(async()=>{if(u.current>0)return;let t=e;try{let e=await n.getTicket(t);if(d.current!==t)return;l(t=>t?Date.parse(e.updatedDateTimeUtc)>=Date.parse(t.updatedDateTimeUtc)?e:t:e)}catch{}},[n,e,l]);return r(()=>{if(!e)return;let t=null,n=()=>{t===null&&(t=setInterval(p,fe))},r=()=>{t!==null&&clearInterval(t),t=null},i=()=>{document.hidden?r():(p(),n())};return document.addEventListener(`visibilitychange`,i),document.hidden||n(),()=>{r(),document.removeEventListener(`visibilitychange`,i)}},[e,p]),{ticket:i,loading:a,error:s,reload:c,reply:t(t=>f(()=>n.reply(e,t)),[f,n,e]),changeStatus:t(t=>f(()=>n.changeStatus(e,t)),[f,n,e]),changePriority:t(t=>f(()=>n.changePriority(e,t)),[f,n,e]),changeCategory:t(t=>f(()=>n.changeCategory(e,t)),[f,n,e]),assign:t(t=>f(()=>n.assign(e,t)),[f,n,e])}}function Ce(){let{client:e,loadOnce:t}=me(),{data:n,loading:r,error:i,reload:a}=ye(n=>t(`agents`,()=>e.listAgents(),n),`agents`);return{agents:n??[],loading:r,error:i,reload:a}}function we(){let{client:e,loadOnce:t}=me(),{data:n,loading:r,error:i,reload:a}=ye(n=>t(`settings`,()=>e.getSettings(),n),`settings`);return{settings:n,loading:r,error:i,reload:a}}function Te({client:e,timeZone:n=c,renderTime:r,labels:i,children:s}){let l=o(/* @__PURE__ */ new Map),u=t((t,n,r=!1)=>{let i=l.current.get(t);if(!r&&i&&i.client===e)return i.pending;let a=n(),o={client:e,pending:a};return l.current.set(t,o),a.catch(()=>{l.current.get(t)===o&&l.current.delete(t)}),a},[e]),d=a(()=>({client:e,loadOnce:u,timeZone:n,renderTime:r,labels:i}),[e,u,n,r,i]);return/* @__PURE__ */ p(pe.Provider,{value:d,children:s})}function Y(e,t){return String(e).replace(/[{]([A-Za-z0-9_]+)[}]/g,(e,n)=>n in t?String(t[n]):e)}var X={offline:`We could not reach support. Check your connection and try again.`,attachOne:`You can attach one file.`,attachMany:`You can attach up to {count} files.`,typeNotAccepted:`{name} is a file type we cannot accept.`,tooLarge:`{name} is larger than {size}.`,thisFile:`This file`,alreadyAttached:`{name} is already attached.`};function Z(e,t,n=X.offline){if(e instanceof G){if(e.code===`network`)return n;if(e.code!==`unknown`)return e.message}return t}function Ee(e){return(e?.allowedContentTypes??[]).join(`,`)}function De(e,t){if(t.length===0)return!0;let n=(e||``).toLowerCase();return t.some(e=>{let t=e.toLowerCase();return t.endsWith(`/*`)?n.startsWith(t.slice(0,-1)):n===t})}function Oe(e,t,n=X){let r=e??[],i=t?.maxAttachmentsPerMessage??0,a=t?.maxAttachmentBytes??0,o=t?.allowedContentTypes??[];if(i>0&&r.length>i)return i===1?n.attachOne:Y(n.attachMany,{count:i});for(let e of r){let t=e.name||n.thisFile;if(!De(e.type,o))return Y(n.typeNotAccepted,{name:t});if(a>0&&e.size>a)return Y(n.tooLarge,{name:t,size:u(a)})}return null}var ke=(e,t)=>e===1?t.attachOne:Y(t.attachMany,{count:e});function Ae(e){return`${e.name}|${e.size}|${e.lastModified}`}function je(e,t,n,r=X){let i=n?.maxAttachmentsPerMessage??0,a=new Set(e.map(Ae)),o=[],s=null;for(let e of t){let t=Ae(e);a.has(t)?s??=e.name:(a.add(t),o.push(e))}let c=i>0?Math.max(0,i-e.length):o.length,l=[...e,...o.slice(0,c)];return{files:l,notice:(o.length>c?ke(i,r):null)??Oe(l,n,r)??(s?Y(r.alreadyAttached,{name:s}):``)}}function Me(e){let t=Array.from(e.clipboardData?.items??[]),n=Date.now();return t.filter(e=>e.kind===`file`&&e.type.startsWith(`image/`)).map(e=>e.getAsFile()).filter(Boolean).map((e,t)=>{let r=(e.type.split(`/`)[1]||`png`).replace(`jpeg`,`jpg`);return new File([e],`pasted-image-${n}-${t+1}.${r}`,{type:e.type})})}var Ne={Open:`info`,InProgress:`info`,WaitingOnCustomer:`warning`,Resolved:`success`,Closed:`success`,Cancelled:`neutral`};function Pe(e){return Ne[e]??`neutral`}var Fe={supportQueue:{countOpen:`Open`,countInProgress:`In progress`,countWaiting:`Waiting`,countOverdue:`Overdue`,countUnassigned:`Unassigned`,filterStatus:`Status`,filterPriority:`Priority`,filterCategory:`Category`,filterPlace:`Place`,filterAssignee:`Assignee`,filterUnassignedOnly:`Unassigned only`,filterOverdueOnly:`Overdue only`,filterSearch:`Search`,filterAny:`All`,columnNumber:`Number`,columnPlace:`Place`,columnSubject:`Subject`,columnCategory:`Category`,columnStatus:`Status`,columnPriority:`Priority`,columnAssignee:`Assignee`,columnDue:`Due`,loading:`Loading tickets...`,empty:`No tickets match these filters.`,error:`We could not load the tickets. Try again.`,retry:`Try again`,heading:`Ticket queue`,tableLabel:`Tickets in this queue`,settingsError:`We could not load the queue settings.`,overdueMark:`Overdue`,noAssignee:`Unassigned`,emptyUnfiltered:`No tickets in this queue yet.`},agentTicket:{reply:`Reply`,internalNote:`Internal note`,send:`Send`,savedReplies:`Saved replies`,attachFiles:`Attach files`,status:`Status`,priority:`Priority`,category:`Category`,assignee:`Assignee`,unassigned:`Unassigned`,internal:`Internal`,backToQueue:`Back to queue`,stale:`Someone else changed this ticket just now. Reload it and try again.`,reload:`Reload`,loading:`Loading ticket...`,empty:`No messages yet.`,error:`We could not load this ticket. Try again.`,retry:`Try again`,emptyReply:`Write a message before you send it.`,actionFailed:`The change was not saved. Please try again.`,attachmentFailed:`This file could not be opened. Try again.`,none:`None`,customer:`Customer`,supportTeam:`Support team`,overdue:`Overdue`,detailsLabel:`Ticket details`,controlsLabel:`Ticket controls`,fieldTicket:`Ticket`,fieldAccount:`Account`,fieldRealm:`Realm`,fieldReporter:`Reporter`,fieldEmail:`Email`,fieldRaised:`Raised`,fieldUpdated:`Updated`,fieldReplyDue:`Reply due`,fieldResolutionDue:`Resolution due`,mode:`Reply or internal note`,replyHint:`The customer sees this reply.`,noteHint:`Only the support team sees an internal note.`,body:`Message`,insertSaved:`Insert a saved reply`,attachedFiles:`Attached files`,removeFile:`Remove {name}`,formLabel:`Reply to this ticket`,conversation:`Conversation`}},Ie=[`InProgress`,`WaitingOnCustomer`,`Resolved`,`Closed`],Le=`support-agent-draft:`;function Re(e){try{return sessionStorage.getItem(Le+e)??``}catch{return``}}function ze(e,t){try{t?sessionStorage.setItem(Le+e,t):sessionStorage.removeItem(Le+e)}catch{}}function Be({iso:e,className:t}){let n=_e(),r=ge();return n?n(e):/* @__PURE__ */ p(`time`,{dateTime:e,className:t,children:l(e,{timeZone:r})})}function Ve({ticketId:e,onBack:t,labels:n}){let a=ve(`agentTicket`,Fe.agentTicket),o=n?{...a,...n}:a,c=i(),l=he(),{ticket:u,loading:d,error:f,reload:_,reply:C,changeStatus:w,changePriority:T,changeCategory:E,assign:O}=Se(e),{settings:k}=we(),{agents:A}=Ce(),[j,M]=s(`reply`),[N,P]=s(()=>Re(e)),[F,I]=s([]),[L,z]=s(``),[V,H]=s(``),[ne,re]=s(!1),[W,G]=s(!1);r(()=>{P(Re(e)),I([]),z(``),H(``),re(!1)},[e]);let ie=/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,leftIcon:`arrow-left`,onClick:t,className:`align-self-start`,children:o.backToQueue});if(!u)return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3`,"aria-busy":d||void 0,children:[ie,f?/* @__PURE__ */ m(g,{tone:`danger`,children:[Z(f,o.error,X.offline),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:_,children:o.retry})]}):/* @__PURE__ */ p(ee,{height:160})]});async function K(e){H(``),re(!1),G(!0);try{return await e(),!0}catch(e){return e?.status===409?re(!0):H(Z(e,o.actionFailed,X.offline)),!1}finally{G(!1)}}let q=t=>{P(t),H(``),ze(e,t)},J=e=>{let t=je(F,e,k,X);I(t.files),z(t.notice)},ae=e=>{let t=F.filter((t,n)=>n!==e);I(t),z(Oe(t,k,X)??``)},oe=e=>{let t=Me(e);t.length>0&&J(t)};async function se(t){t.preventDefault();let n=N.trim();if(!n){H(o.emptyReply);return}let r=Oe(F,k,X);r?z(r):await K(()=>C({version:u.version,body:n,isInternal:j===`note`,files:F}))&&(P(``),I([]),z(``),ze(e,``))}let ce=t=>{H(``),l.openAttachment(e,t).catch(e=>{H(Z(e,o.attachmentFailed,X.offline))})},le=e=>{let t=(k?.savedReplies??[])[Number(e)];t&&q(N?`${N}\n${t.body}`:t.body)},ue=k?.queues??[],de=ue.find(e=>e.key===u.queue),fe=de?de.categories:ue.flatMap(e=>e.categories??[]),pe=(k?.statuses??[]).filter(e=>Ie.includes(e.value)).map(e=>({value:e.value,label:e.label})),me=(k?.priorities??[]).map(e=>({value:e.value,label:e.label})),ge=[...new Set(fe??[])].map(e=>({value:e,label:e})),_e=[{value:``,label:o.unassigned},...(A??[]).map(e=>({value:String(e.userId),label:e.name}))],ye=(e,t)=>e?/* @__PURE__ */ m(`span`,{className:`d-inline-flex flex-wrap align-items-center gap-2`,children:[/* @__PURE__ */ p(Be,{iso:e}),t&&/* @__PURE__ */ p(v,{tone:`danger`,children:o.overdue})]}):o.none,be=[{key:`ticket`,label:o.fieldTicket,value:u.number},{key:`account`,label:o.fieldAccount,value:u.accountId??o.none},{key:`realm`,label:o.fieldRealm,value:u.realm?k?.realmLabels?.[u.realm]??u.realm:o.none},{key:`reporter`,label:o.fieldReporter,value:u.reporterName||o.none},{key:`email`,label:o.fieldEmail,value:u.reporterEmail||o.none},{key:`raised`,label:o.fieldRaised,value:/* @__PURE__ */ p(Be,{iso:u.raisedDateTimeUtc??u.createdDateTimeUtc})},{key:`updated`,label:o.fieldUpdated,value:/* @__PURE__ */ p(Be,{iso:u.updatedDateTimeUtc})},{key:`replyDue`,label:o.fieldReplyDue,value:ye(u.replyDueDateTimeUtc,u.isOverdue)},{key:`resolutionDue`,label:o.fieldResolutionDue,value:ye(u.resolutionDueDateTimeUtc,u.isResolutionOverdue)}],xe=V||L;return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3`,"aria-labelledby":`${c}-subject`,children:[ie,/* @__PURE__ */ m(`div`,{className:`row g-3`,children:[/* @__PURE__ */ m(`div`,{className:`col-12 col-lg-8 d-flex flex-column gap-3`,children:[/* @__PURE__ */ m(`header`,{className:`d-flex flex-wrap align-items-center gap-2`,children:[/* @__PURE__ */ p(`h2`,{id:`${c}-subject`,className:`h5 mb-0 text-break`,children:u.subject}),/* @__PURE__ */ p(te,{label:u.statusLabel??u.status,tone:Pe(u.status)})]}),ne&&/* @__PURE__ */ m(g,{tone:`warning`,children:[o.stale,` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:_,children:o.reload})]}),/* @__PURE__ */ m(`ol`,{className:`list-unstyled d-flex flex-column gap-3 mb-0`,"aria-label":o.conversation,children:[(u.messages??[]).length===0&&/* @__PURE__ */ p(`p`,{className:`wui-text-sm text-body-secondary mb-0`,children:o.empty}),(u.messages??[]).map(e=>{if(e.authorKind===`System`)return/* @__PURE__ */ m(`li`,{className:`text-center wui-text-xs text-body-secondary`,"data-author":`system`,children:[/* @__PURE__ */ p(`span`,{className:`d-block`,children:e.body}),/* @__PURE__ */ p(Be,{iso:e.createdDateTimeUtc})]},e.id);let t=e.authorKind===`Customer`,n=e.authorName||(t?o.customer:o.supportTeam);return/* @__PURE__ */ p(`li`,{"data-author":t?`customer`:`agent`,"data-internal":e.isInternal?`true`:void 0,children:/* @__PURE__ */ m(b,{padding:`sm`,variant:e.isInternal?`accent`:`flat`,className:`border`,children:[/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2 mb-2`,children:[/* @__PURE__ */ m(`span`,{className:`d-inline-flex flex-wrap align-items-center gap-2 fw-semibold wui-text-sm text-break`,children:[n,e.isInternal&&/* @__PURE__ */ p(v,{tone:`warning`,children:o.internal})]}),/* @__PURE__ */ p(`span`,{className:`wui-text-xs text-body-secondary text-nowrap`,children:/* @__PURE__ */ p(Be,{iso:e.createdDateTimeUtc})})]}),/* @__PURE__ */ p(`div`,{className:`wui-text-sm`,style:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:e.body}),e.attachments?.length>0&&/* @__PURE__ */ p(`div`,{className:`d-flex flex-wrap gap-2 mt-2`,children:e.attachments.map(e=>/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,leftIcon:`paperclip`,onClick:()=>ce(e.id),children:e.fileName},e.id))})]})},e.id)})]}),/* @__PURE__ */ m(`form`,{onSubmit:se,noValidate:!0,className:`d-flex flex-column gap-2 min-w-0`,"aria-label":o.formLabel,children:[xe&&/* @__PURE__ */ p(g,{tone:`danger`,children:xe}),/* @__PURE__ */ p(R,{label:o.mode,options:[{value:`reply`,label:o.reply},{value:`note`,label:o.internalNote}],value:j,onChange:M,inline:!0}),/* @__PURE__ */ p(B,{label:o.savedReplies,placeholder:o.insertSaved,options:(k?.savedReplies??[]).map((e,t)=>({value:String(t),label:e.title})),value:``,onChange:le,disabled:W}),/* @__PURE__ */ p(U,{id:`${c}-body`,label:o.body,rows:3,autoGrow:!0,maxLength:k?.bodyMaxLength,value:N,onChange:e=>q(e.target.value),onPaste:oe,helperText:j===`note`?o.noteHint:o.replyHint,required:!0}),F.length>0&&/* @__PURE__ */ p(S,{label:o.attachedFiles,children:F.map((e,t)=>/* @__PURE__ */ p(x,{leadingIcon:`paperclip`,label:e.name,removeLabel:Y(o.removeFile,{name:e.name}),onRemove:()=>ae(t)},Ae(e)))}),/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2`,children:[/* @__PURE__ */ p(h,{iconVariant:`bulk`,icon:`paperclip`,label:o.attachFiles,multiple:k?.maxAttachmentsPerMessage!==1,accept:Ee(k),onFiles:J}),/* @__PURE__ */ p(y,{type:`submit`,leftIcon:`send`,loading:W,children:o.send})]})]})]}),/* @__PURE__ */ m(`aside`,{"aria-label":o.detailsLabel,className:`col-12 col-lg-4 d-flex flex-column gap-3`,children:[/* @__PURE__ */ p(b,{padding:`sm`,className:`border`,children:/* @__PURE__ */ p(D,{columns:1,items:be})}),/* @__PURE__ */ p(b,{padding:`sm`,className:`border`,"aria-label":o.controlsLabel,children:/* @__PURE__ */ m(`div`,{className:`d-flex flex-column gap-3`,children:[/* @__PURE__ */ p(B,{label:o.status,value:u.status,options:pe,disabled:W,onChange:e=>K(()=>w({version:u.version,status:e}))}),/* @__PURE__ */ p(B,{label:o.priority,value:u.priority??``,options:me,disabled:W,onChange:e=>K(()=>T({version:u.version,priority:e}))}),/* @__PURE__ */ p(B,{label:o.category,value:u.category,options:ge,disabled:W,onChange:e=>K(()=>E({version:u.version,category:e}))}),/* @__PURE__ */ p(B,{label:o.assignee,value:u.assignedAgentUserId==null?``:String(u.assignedAgentUserId),options:_e,disabled:W,onChange:e=>K(()=>O({version:u.version,agentUserId:e?Number(e):null}))})]})})]})]})]})}function He(e,t){let[n,i]=s(e);return r(()=>{let n=setTimeout(()=>i(e),t);return()=>clearTimeout(n)},[e,t]),n}var Ue=10,We=300,Q=`all`,Ge=e=>e===Q?void 0:e,Ke=e=>[...new Set(e.flatMap(e=>e.categories??[]))];function qe({onOpenTicket:e,getTicketHref:t,status:n,onStatusChange:i,defaultStatus:a=Q,queue:o,pageSize:c=Ue}){let u=ve(`supportQueue`,Fe.supportQueue),d=_e(),f=ge(),{settings:h,error:_}=we(),{agents:b}=Ce(),{counts:x}=xe(),[S,w]=s(a),T=n!==void 0,D=T?n:S,k=e=>{T||w(e),i?.(e)},[A,j]=s(Q),[M,N]=s(Q),[F,L]=s(Q),[R,ee]=s(Q),[V,H]=s(!1),[U,ne]=s(!1),[re,W]=s(``),G=He(re.trim(),We),[ie,K]=s(c),q=JSON.stringify([o,D,A,M,F,R,V,U,G,ie]),[J,ae]=s({key:q,page:1}),oe=J.key===q?J.page:1,se=e=>ae({key:q,page:e}),ce=be({queue:o,status:Ge(D),priority:Ge(A),category:Ge(M),realm:Ge(F),assignedAgentUserId:Ge(R),unassignedOnly:V||void 0,overdueOnly:U||void 0,includeSettled:D===Q||void 0,search:G||void 0,page:oe,pageSize:ie}),le=ce.totalPages;r(()=>{le>0&&oe>le&&ae({key:q,page:le})},[le,oe,q]);let ue=h?.queues??[],de=o?ue.filter(e=>e.key===o):ue,fe=[{value:Q,label:u.filterAny},...h?.statuses??[]],pe=[{value:Q,label:u.filterAny},...h?.priorities??[]],me=[{value:Q,label:u.filterAny},...Ke(de).map(e=>({value:e,label:e}))],he=[{value:Q,label:u.filterAny},...Object.entries(h?.realmLabels??{}).map(([e,t])=>({value:e,label:t}))],ye=[{value:Q,label:u.filterAny},...b.map(e=>({value:String(e.userId),label:e.name}))],Se=h?.realmLabels??{},Te=e=>d?d(e):/* @__PURE__ */ p(`time`,{dateTime:e,children:l(e,{timeZone:f})}),Y=(t,n)=>{e&&(t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),e(n)))},X=[{key:`number`,label:u.columnNumber,nowrap:!0,render:n=>{let r=t?.(n.id);return!r&&!e?/* @__PURE__ */ p(`span`,{className:`fw-semibold text-nowrap`,children:n.number}):r?/* @__PURE__ */ p(P,{href:r,animation:`none`,className:`fw-semibold text-nowrap`,onClick:e=>Y(e,n.id),children:n.number}):/* @__PURE__ */ p(y,{variant:`link`,size:`sm`,className:`fw-semibold text-nowrap`,onClick:()=>e(n.id),children:n.number})}},{key:`place`,label:u.columnPlace,render:e=>/* @__PURE__ */ m(`div`,{className:`d-flex flex-column`,style:{minWidth:0},children:[/* @__PURE__ */ p(`span`,{className:`text-break`,children:e.accountName}),/* @__PURE__ */ p(`span`,{className:`wui-text-xs text-body-secondary`,children:Se[e.realm]??`-`})]})},{key:`subject`,label:u.columnSubject,render:e=>/* @__PURE__ */ p(`span`,{className:`text-break`,children:e.subject})},{key:`category`,label:u.columnCategory,render:e=>e.category},{key:`status`,label:u.columnStatus,render:e=>/* @__PURE__ */ p(te,{label:e.statusLabel,tone:Pe(e.status)})},{key:`priority`,label:u.columnPriority,render:e=>/* @__PURE__ */ p(v,{children:e.priorityLabel})},{key:`assignee`,label:u.columnAssignee,render:e=>e.assignedAgentName??u.noAssignee},{key:`due`,label:u.columnDue,cellClassName:`wui-text-sm text-nowrap`,render:e=>{let t=e.resolutionDueDateTimeUtc,n=e.isOverdue||e.isResolutionOverdue;return/* @__PURE__ */ m(`span`,{className:`d-inline-flex gap-2 align-items-center`,children:[t?Te(t):`-`,n&&/* @__PURE__ */ p(v,{tone:`danger`,children:u.overdueMark})]})}}],Ee=[{label:u.countOpen,value:x?.open??`-`},{label:u.countInProgress,value:x?.inProgress??`-`},{label:u.countWaiting,value:x?.waitingOnCustomer??`-`},{label:u.countOverdue,value:x?.overdue??`-`,tone:`danger`},{label:u.countUnassigned,value:x?.unassigned??`-`}],De=[D,A,M,F,R].some(e=>e!==Q)||V||U||!!G,Oe={page:oe,totalPages:Math.max(1,ce.totalPages),pageSize:ie,total:ce.totalCount,setPage:se,setPageSize:K};return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3 min-w-0`,"aria-labelledby":`support-queue-title`,children:[/* @__PURE__ */ p(`h2`,{id:`support-queue-title`,className:`h5 mb-0`,children:u.heading}),_&&/* @__PURE__ */ p(g,{tone:`warning`,children:Z(_,u.settingsError)}),/* @__PURE__ */ p(I,{items:Ee,columns:5,size:`sm`}),ce.error&&/* @__PURE__ */ m(g,{tone:`danger`,children:[Z(ce.error,u.error),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:ce.reload,children:u.retry})]}),/* @__PURE__ */ m(`div`,{className:`d-flex flex-column flex-xl-row flex-wrap gap-2 align-items-xl-end`,children:[/* @__PURE__ */ p(B,{label:u.filterStatus,value:D,onChange:k,options:fe,fieldClassName:`flex-shrink-0`}),/* @__PURE__ */ p(B,{label:u.filterPriority,value:A,onChange:j,options:pe,fieldClassName:`flex-shrink-0`}),/* @__PURE__ */ p(B,{label:u.filterCategory,value:M,onChange:N,options:me,fieldClassName:`flex-shrink-0`}),/* @__PURE__ */ p(B,{label:u.filterPlace,value:F,onChange:L,options:he,fieldClassName:`flex-shrink-0`}),/* @__PURE__ */ p(B,{label:u.filterAssignee,value:R,onChange:ee,options:ye,fieldClassName:`flex-shrink-0`}),/* @__PURE__ */ p(C,{multiple:!0,checked:V,onChange:()=>H(e=>!e),children:u.filterUnassignedOnly}),/* @__PURE__ */ p(C,{multiple:!0,checked:U,onChange:()=>ne(e=>!e),children:u.filterOverdueOnly}),/* @__PURE__ */ p(z,{value:re,onChange:W,placeholder:u.filterSearch,ariaLabel:u.filterSearch})]}),/* @__PURE__ */ p(E,{columns:X,rows:ce.tickets,loading:ce.loading,skeletonRows:4,ariaLabel:u.tableLabel,pagination:Oe,empty:/* @__PURE__ */ p(O,{variant:`table`,icon:`message-square`,title:De?u.empty:u.emptyUnfiltered})})]})}var Je=3e4,Ye=e(null);function Xe(){let e=n(Ye);if(!e)throw Error(`Support components and hooks must be used inside <SupportProvider>.`);return e}function Ze(){return Xe().client}function Qe(){return Xe().timeZone}function $e(){return Xe().renderTime??null}function $(e,t){let n=Xe().labels?.[e];return a(()=>n?{...t,...n}:t,[n,t])}function et(e,n,i=!0){let[a,c]=s({data:null,loading:i,error:null}),[l,u]=s(0),d=o(e);d.current=e;let f=o(n);r(()=>{let e=f.current!==n;if(f.current=n,!i){c({data:null,loading:!1,error:null});return}let t=!0;return c(t=>({data:e?null:t.data,loading:!0,error:null})),d.current(l>0).then(e=>t&&c({data:e,loading:!1,error:null}),e=>t&&c(t=>({...t,loading:!1,error:e}))),()=>{t=!1}},[n,i,l]);let p=t(()=>u(e=>e+1),[]),m=t(e=>c(t=>({...t,data:typeof e==`function`?e(t.data):e})),[]);return{...a,reload:p,setData:m}}function tt(){let{loadConfig:e}=Xe(),{data:t,loading:n,error:r,reload:i}=et(e,`config`);return{config:t,loading:n,error:r,reload:i}}function nt(e={}){let t=Ze(),{status:n,search:r,page:i,pageSize:a}=e,{data:o,loading:s,error:c,reload:l}=et(()=>t.listTickets({status:n,search:r,page:i,pageSize:a}),JSON.stringify([`tickets`,n??null,r??null,i??null,a??null]));return{tickets:o?.items??[],totalCount:o?.totalCount??0,totalPages:o?.totalPages??0,loading:s,error:c,reload:l}}function rt(){let e=Ze(),{data:t,loading:n,error:r,reload:i}=et(()=>e.getTicketCounts(),`ticket-counts`);return{counts:t,loading:n,error:r,reload:i}}function it(e){let n=Ze(),{data:i,loading:a,error:s,reload:c,setData:l}=et(()=>n.getTicket(e),e??``,!!e),u=o(0),d=o(e);d.current=e;let f=t(async e=>{u.current+=1;try{let t=await e();return l(t),t}finally{--u.current}},[l]),p=t(async()=>{if(u.current>0)return;let t=e;try{let e=await n.getTicket(t);if(d.current!==t)return;l(t=>t?Date.parse(e.updatedDateTimeUtc)>=Date.parse(t.updatedDateTimeUtc)?e:t:e)}catch{}},[n,e,l]);return r(()=>{if(!e)return;let t=null,n=()=>{t===null&&(t=setInterval(p,Je))},r=()=>{t!==null&&clearInterval(t),t=null},i=()=>{document.hidden?r():(p(),n())};return document.addEventListener(`visibilitychange`,i),document.hidden||n(),()=>{r(),document.removeEventListener(`visibilitychange`,i)}},[e,p]),{ticket:i,loading:a,error:s,reload:c,reply:t(t=>f(()=>n.reply(e,t)),[f,n,e]),reopen:t(()=>f(()=>n.reopen(e)),[f,n,e]),cancel:t(()=>f(()=>n.cancel(e)),[f,n,e]),rate:t(t=>f(()=>n.rate(e,t)),[f,n,e])}}function at({baseUrl:e,http:t}){if(typeof e!=`string`||e.trim()===``)throw TypeError(`createHelpCentreClient needs a baseUrl.`);if(typeof t?.get!=`function`)throw TypeError(`createHelpCentreClient needs an http client with get().`);let n=e.trim().replace(/\/+$/,``),r=async e=>{try{return(await e()).data}catch(e){throw await K(e)}};return{settings:e=>r(()=>t.get(`${n}/settings`,{signal:e?.signal})),list:({page:e,pageSize:i}={},a)=>{let o=new URLSearchParams;e!=null&&o.set(`page`,String(e)),i!=null&&o.set(`pageSize`,String(i));let s=o.toString();return r(()=>t.get(`${n}/articles${s?`?${s}`:``}`,{signal:a?.signal}))},get:(e,i)=>r(()=>t.get(`${n}/articles/${encodeURIComponent(e)}`,{signal:i?.signal})),search:(e,i)=>r(()=>t.get(`${n}/search?${new URLSearchParams({q:String(e??``)}).toString()}`,{signal:i?.signal}))}}function ot({iso:e,className:t}){let n=$e(),r=Qe();return n?n(e):/* @__PURE__ */ p(`time`,{dateTime:e,className:t,children:l(e,{timeZone:r})})}var st={heading:`Help centre`,searchPlaceholder:`Search help articles`,searchLabel:`Search help articles`,tableLabel:`Help articles`,columnArticle:`Article`,columnUpdated:`Last updated`,listError:`We could not load the help articles.`,settingsError:`We could not load the help centre.`,retry:`Try again`,emptyTitle:`No articles yet`,emptyText:`Help articles from the support team show here.`,noMatchTitle:`No articles match`,noMatchText:`Try other words.`},ct={back:`Back to help`,published:`Published {date}`,updated:`Updated {date}`,loadError:`We could not load this article.`,notFoundTitle:`This article could not be found.`,retry:`Try again`},lt=`article_not_found`,ut=`{date}`;function dt({template:e,iso:t}){let n=e.indexOf(ut);return n===-1?/* @__PURE__ */ m(f,{children:[e,` `,/* @__PURE__ */ p(ot,{iso:t})]}):/* @__PURE__ */ m(f,{children:[e.slice(0,n),/* @__PURE__ */ p(ot,{iso:t}),e.slice(n+6)]})}function ft({client:e,slug:n,onBack:i}){let a=$(`helpArticle`,ct),c=$(`shared`,X),[l,u]=s({article:null,loading:!0,error:null}),d=o(null),f=t(()=>{d.current?.abort();let t=new AbortController;d.current=t,u({article:null,loading:!0,error:null}),e.get(n,{signal:t.signal}).then(e=>{t.signal.aborted||u({article:e,loading:!1,error:null})},e=>{t.signal.aborted||u({article:null,loading:!1,error:e})})},[e,n]);r(()=>(f(),()=>d.current?.abort()),[f]);let{article:h,loading:_,error:v}=l,b=v?.code===lt;return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3 min-w-0`,"aria-busy":_||void 0,children:[i&&/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,leftIcon:`arrow-left`,onClick:i,className:`align-self-start`,children:a.back}),_&&/* @__PURE__ */ p(ee,{height:160}),b&&/* @__PURE__ */ p(O,{variant:`card`,icon:`search`,title:a.notFoundTitle}),v&&!b&&/* @__PURE__ */ m(g,{tone:`danger`,children:[Z(v,a.loadError,c.offline),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:f,children:a.retry})]}),h&&/* @__PURE__ */ m(`article`,{className:`d-flex flex-column gap-3`,children:[/* @__PURE__ */ p(`h2`,{className:`h4 mb-0`,children:h.title}),/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap gap-3 wui-text-sm text-body-secondary`,children:[h.publishedDateTimeUtc!=null&&/* @__PURE__ */ p(`span`,{children:/* @__PURE__ */ p(dt,{template:a.published,iso:h.publishedDateTimeUtc})}),/* @__PURE__ */ p(`span`,{children:/* @__PURE__ */ p(dt,{template:a.updated,iso:h.updatedDateTimeUtc})})]}),/* @__PURE__ */ p(F,{value:h.bodyMarkdown})]})]})}var pt=10,mt=300,ht=2;function gt(){let e=o(null),n=t(()=>{e.current?.abort(),e.current=null},[]);r(()=>n,[n]);let i=t((t,n,r)=>{e.current?.abort();let i=new AbortController;e.current=i,t(i.signal).then(e=>{i.signal.aborted||n(e)},e=>{i.signal.aborted||r(e)})},[]);return a(()=>({run:i,cancel:n}),[i,n])}function _t(e){let[n,i]=s({data:null,loading:!0,error:null}),[a,o]=s({page:1,pageSize:pt}),[c,l]=s({data:null,loading:!0,error:null}),[u,d]=s(``),[f,p]=s({term:``,data:[],loading:!1,error:null}),m=He(u.trim(),mt),h=gt(),g=gt(),_=gt(),{page:v,pageSize:y}=a,b=n.data?.searchAvailable===!0,x=b&&m.length>=ht,S=c.data?.totalPages??0,C=t(()=>{i(e=>({...e,loading:!0,error:null})),h.run(t=>e.settings({signal:t}),e=>i({data:e,loading:!1,error:null}),e=>i({data:null,loading:!1,error:e}))},[e,h]),w=t(()=>{l(e=>({...e,loading:!0,error:null})),g.run(t=>e.list({page:v,pageSize:y},{signal:t}),e=>l({data:e,loading:!1,error:null}),e=>l(t=>({...t,loading:!1,error:e})))},[e,v,y,g]),T=t(()=>{p(e=>({term:m,data:e.data,loading:!0,error:null})),_.run(t=>e.search(m,{signal:t}),e=>p({term:m,data:e,loading:!1,error:null}),e=>p({term:m,data:[],loading:!1,error:e}))},[e,m,_]);r(()=>{C()},[C]),r(()=>{w()},[w]),r(()=>{x?T():_.cancel()},[T,x,_]);let E=t(e=>{d(e),e.trim()===``&&_.cancel()},[_]);r(()=>{S>0&&v>S&&o(e=>({...e,page:S}))},[v,S]);let D=t(e=>o(t=>({...t,page:e})),[]),O=t(e=>o({page:1,pageSize:e}),[]);return{settings:{data:n.data,loading:n.loading,error:n.error,reload:C},articles:{items:c.data?.items??[],page:v,pageSize:y,totalCount:c.data?.totalCount??0,totalPages:S,loading:c.loading,error:c.error,setPage:D,setPageSize:O,reload:w},search:{enabled:b,query:u,setQuery:E,active:x,results:f.data,loading:x&&(f.loading||f.term!==m),error:x?f.error:null,reload:T}}}function vt({client:e,onOpen:t,linkTo:n}){let r=$(`helpCentre`,st),i=$(`shared`,X),{settings:a,articles:o,search:s}=_t(e),c=s.active,l=c?s.results:o.items,u=c?s.loading:o.loading,d=c?s.error:o.error,f=c?s.reload:o.reload,h=(e,n)=>{t&&(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),t(n)))},_=[{key:`title`,label:r.columnArticle,render:e=>/* @__PURE__ */ m(`div`,{className:`d-flex flex-column min-w-0`,children:[n?/* @__PURE__ */ p(P,{href:n(e.slug),animation:`none`,className:`fw-semibold text-break`,onClick:t=>h(t,e.slug),children:e.title}):/* @__PURE__ */ p(y,{variant:`link`,size:`sm`,className:`fw-semibold text-break text-start p-0`,onClick:()=>t?.(e.slug),children:e.title}),/* @__PURE__ */ p(`span`,{className:`wui-text-sm text-body-secondary`,children:e.summary})]})},{key:`updatedDateTimeUtc`,label:r.columnUpdated,cellClassName:`wui-text-sm text-body-secondary text-nowrap`,render:e=>/* @__PURE__ */ p(ot,{iso:e.updatedDateTimeUtc})}],v={page:o.page,totalPages:Math.max(1,o.totalPages),pageSize:o.pageSize,total:o.totalCount,setPage:o.setPage,setPageSize:o.setPageSize};return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3 min-w-0`,"aria-labelledby":`help-centre-title`,children:[/* @__PURE__ */ p(`h2`,{id:`help-centre-title`,className:`h5 mb-0`,children:r.heading}),a.error&&/* @__PURE__ */ m(g,{tone:`warning`,children:[Z(a.error,r.settingsError,i.offline),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:a.reload,children:r.retry})]}),s.enabled&&/* @__PURE__ */ p(z,{value:s.query,onChange:s.setQuery,placeholder:r.searchPlaceholder,ariaLabel:r.searchLabel}),d&&/* @__PURE__ */ m(g,{tone:`danger`,children:[Z(d,r.listError,i.offline),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:f,children:r.retry})]}),/* @__PURE__ */ p(E,{columns:_,rows:l,loading:u,skeletonRows:4,ariaLabel:r.tableLabel,stackOnMobile:!0,pagination:c?void 0:v,empty:c?/* @__PURE__ */ p(O,{variant:`table`,icon:`search`,title:r.noMatchTitle,description:r.noMatchText}):/* @__PURE__ */ p(O,{variant:`table`,icon:`message-square`,title:r.emptyTitle,description:r.emptyText})})]})}var yt=80;function bt(e,t){let n=Math.min(t,yt),r=(e??``).split(/\r?\n/).find(e=>e.trim()!==``);if(r===void 0)return``;let i=r.replace(/\s+/g,` `).trim();if(i.length<=n)return i;let a=i.slice(0,n+1).lastIndexOf(` `);return(a>0?i.slice(0,a):i.slice(0,n)).replace(/[ ,;:.-]+$/,``)}function xt({id:e,label:t=`Attachments`,files:n,onChange:r,config:i,error:a}){let o=i?.maxAttachmentBytes??0,s=o>0?Math.max(.1,Math.round(o/1048576*10)/10):0;return/* @__PURE__ */ p(k,{id:e,label:t,optional:!0,multiple:!0,value:n,onChange:r,accept:Ee(i),maxSizeMb:s,validate:!1,error:a||void 0})}var St={title:`These may already answer your question`};function Ct({items:e}){let t=$(`suggestedAnswers`,St);return e.length===0?null:/* @__PURE__ */ p(b,{variant:`filled`,padding:`sm`,title:t.title,children:/* @__PURE__ */ p(`ul`,{className:`list-unstyled mb-0 d-flex flex-column gap-2`,children:e.map(e=>/* @__PURE__ */ m(`li`,{children:[/* @__PURE__ */ p(`div`,{className:`fw-semibold`,children:e.title}),/* @__PURE__ */ p(`div`,{className:`small text-body-secondary`,children:e.summary})]},e.title))})})}var wt={bodyRequired:`Enter what happened.`,sendFailed:`Your ticket did not send. Please try again.`,messageLabel:`Message`,messagePlaceholder:`What happened, and what did you expect to happen?`,messageHint:`You can paste an image into the message.`,subjectLabel:`Subject`,subjectPlaceholder:`A short summary`,subjectHint:`Filled in from your message. You can change it.`,categoryLabel:`Category (optional)`,categoryPlaceholder:`Choose a category`,categoryHint:`Not sure? Leave it empty and we will sort it.`},Tt=500,Et=3,Dt=5;function Ot(e,t){return t&&e.includes(t)?t:``}function kt({id:e,config:t,defaultCategory:n,initialValues:i,onValuesChange:a,extraFiles:o=[],onSubmit:c,onBusyChange:l,children:u}){let d=$(`ticketForm`,wt),f=$(`shared`,X),h=t?.categories??[],_=t?.subjectMaxLength??1/0,[v,y]=s(()=>i?.category??Ot(h,n)),[b,x]=s(i?.body??``),[S,C]=s(()=>i?.subject||bt(i?.body??``,_)),[w,T]=s(()=>{let e=(i?.subject??``).trim();return e!==``&&e!==bt(i?.body??``,_)}),[E,D]=s(i?.files??[]),[O,k]=s({}),[A,j]=s(``),M=Ze(),[P,F]=s(``),[I,L]=s([]),R=He(S.trim(),Tt);r(()=>{a?.({category:v,subject:S,body:b,files:E})},[v,S,b,E,a]),r(()=>{F(R)},[R]),r(()=>{if(P.length<Et){L([]);return}let e=!0,t=new AbortController;return L([]),M.getSuggestions(P,{signal:t.signal}).then(t=>{e&&L(Array.isArray(t)?t.slice(0,Dt):[])},()=>{e&&L([])}),()=>{e=!1,t.abort()}},[M,P]);let z=e=>{D(e),k(n=>({...n,files:Oe([...o,...e],t,f)??void 0}))},ee=e=>{let t=Me(e);t.length>0&&z([...E,...t])},V=e=>{let t=e.target.value;x(t),w||C(bt(t,_)),O.body&&k(e=>({...e,body:t.trim()?void 0:d.bodyRequired}))},te=e=>{let t=e.target.value;C(t),T(t.trim()!==``)};function H(){let e={};b.trim()||(e.body=d.bodyRequired);let n=Oe([...o,...E],t,f);return n&&(e.files=n),k(e),Object.keys(e).length===0}async function ne(e){if(e.preventDefault(),j(``),H()){l?.(!0);try{await c({category:v,subject:S.trim()||bt(b,_),body:b.trim(),files:E})}catch(e){j(Z(e,d.sendFailed,f.offline))}finally{l?.(!1)}}}return/* @__PURE__ */ m(`form`,{id:e,onSubmit:ne,noValidate:!0,className:`d-flex flex-column gap-3`,children:[A&&/* @__PURE__ */ p(g,{tone:`danger`,children:A}),/* @__PURE__ */ p(U,{id:`${e}-body`,label:d.messageLabel,required:!0,rows:6,maxLength:t?.bodyMaxLength,showCount:!0,placeholder:d.messagePlaceholder,value:b,onChange:V,onPaste:ee,helperText:d.messageHint,error:O.body}),/* @__PURE__ */ p(N,{id:`${e}-subject`,label:d.subjectLabel,maxLength:t?.subjectMaxLength,showCount:!0,placeholder:d.subjectPlaceholder,helperText:d.subjectHint,value:S,onChange:te,onBlur:()=>F(S.trim())}),/* @__PURE__ */ p(Ct,{items:I}),/* @__PURE__ */ p(B,{id:`${e}-category`,label:d.categoryLabel,value:v,onChange:y,options:h.map(e=>({value:e,label:e})),placeholder:d.categoryPlaceholder,helperText:d.categoryHint,error:O.category}),u,/* @__PURE__ */ p(xt,{id:`${e}-files`,files:E,onChange:z,config:t,error:O.files})]})}var At={captureEmpty:`The page capture came back empty.`,retake:`Retake`,removeScreenshot:`Remove screenshot`,addScreenshot:`Add a screenshot`,screenshotNote:`Only what is on your screen now. You can remove it before sending.`,screenshotFailed:`We could not take a screenshot of this page. You can attach an image instead, or send the report without one.`,screenshotTitle:`Screenshot`,screenshotLabel:`Screenshot of the page you were on`,viewTicket:`View ticket`,close:`Close`,cancel:`Cancel`,submit:`Submit`,takingScreenshot:`Taking a screenshot`,title:`Report an issue`,subtitle:`Tell us what went wrong. You can add a screenshot of this page if it helps.`,confirmDiscard:`Discard this report?`,createdTitle:`Ticket {number} is with the support team`,createdText:`We reply by email. You can follow the ticket on your support page.`,configError:`We could not load the support settings.`,loading:`Loading the form.`},jt=`supportCapture`,Mt={zIndex:`var(--wui-z-fixed)`,bottom:0,insetInlineEnd:0},Nt={zIndex:`var(--wui-z-fixed)`},Pt={maxWidth:`20rem`},Ft=e=>e.dataset?.[jt]===`exclude`||e.matches?.(`.modal-backdrop`)?!1:!(e.matches?.(`.modal`)&&e.querySelector?.(`[data-support-capture="exclude"]`)),It=()=>new Promise(e=>requestAnimationFrame(()=>e()));async function Lt(e){let t=await re(document.body,{filter:Ft,pixelRatio:Math.min(window.devicePixelRatio||1,2),style:{overflow:`visible`,paddingRight:`0px`}});if(!t)throw Error(e);return new File([t],`screenshot.png`,{type:`image/png`})}function Rt({t:e,file:t,failed:n,disabled:i,hintId:a,controlRef:o,onAdd:c,onRemove:l}){let[u,d]=s(null);return r(()=>{if(!t)return;let e=URL.createObjectURL(t);return d(e),()=>URL.revokeObjectURL(e)},[t]),/* @__PURE__ */ m(`div`,{className:`d-flex flex-column gap-2`,children:[/* @__PURE__ */ p(`span`,{className:`wui-text-sm fw-semibold`,children:e.screenshotTitle}),t&&u&&/* @__PURE__ */ p(`img`,{src:u,alt:e.screenshotLabel,className:`d-block w-100 border rounded`,style:Pt}),/* @__PURE__ */ p(`div`,{ref:o,className:`d-flex flex-wrap gap-2`,children:t?/* @__PURE__ */ m(f,{children:[/* @__PURE__ */ p(y,{variant:`outline`,size:`sm`,leftIcon:`refresh-cw`,onClick:c,disabled:i,"aria-describedby":a,children:e.retake}),/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,leftIcon:`x`,onClick:l,disabled:i,children:e.removeScreenshot})]}):/* @__PURE__ */ p(y,{variant:`outline`,size:`sm`,leftIcon:`camera`,onClick:c,disabled:i,"aria-describedby":a,children:e.addScreenshot})}),/* @__PURE__ */ p(`span`,{id:a,className:`wui-text-sm text-body-secondary`,children:e.screenshotNote}),n&&/* @__PURE__ */ p(g,{tone:`info`,children:e.screenshotFailed})]})}function zt({label:e=`Report an issue`,floating:t=!1,compact:n=!1,defaultCategory:a=`Bug report`,appVersion:c,getTicketHref:l,onOpenTicket:u,onCreated:d,className:h,style:_}){let v=$(`reportIssue`,At),b=$(`shared`,X),x=Ze(),{config:S,error:C}=tt(),w=`support-report-${i().replace(/[^a-zA-Z0-9-]/g,``)}`,[T,E]=s(!1),[D,O]=s(!1),[k,j]=s(null),[M,N]=s(!1),[P,F]=s(!1),[I,R]=s(null),[z,B]=s(null),ee=o(null),V=o(!1);r(()=>{!D&&V.current&&(V.current=!1,ee.current?.querySelector(`button`)?.focus())},[D]);function te(){R(null),j(null),N(!1),B(null),E(!0)}async function H(){O(!0),N(!1),await It(),await It();try{j(await Lt(v.captureEmpty))}catch{j(null),N(!0)}finally{V.current=!0,O(!1)}}let U=()=>{P||(E(!1),j(null),N(!1),R(null),B(null))};async function ne(e){let t=await x.createTicket({...e,pageUrl:window.location.href,userAgent:navigator.userAgent,appVersion:c,screenshots:k?[k]:[]});R(t),j(null),d?.(t)}let re=!I&&(!!k||!!z&&(z.subject.trim()!==``||z.body.trim()!==``||z.files.length>0)),W=I&&l?l(I.id):void 0,G=I&&(W||u)?/* @__PURE__ */ p(y,{href:W,onClick:W?void 0:()=>{E(!1),R(null),u(I)},children:v.viewTicket}):null,ie=I?/* @__PURE__ */ m(`div`,{className:`d-flex justify-content-end gap-2 w-100`,children:[/* @__PURE__ */ p(y,{variant:`soft`,onClick:U,children:v.close}),G]}):/* @__PURE__ */ m(`div`,{className:`d-flex justify-content-end gap-2 w-100`,children:[/* @__PURE__ */ p(y,{variant:`soft`,onClick:U,disabled:P,children:v.cancel}),/* @__PURE__ */ p(y,{type:`submit`,form:w,loading:P,disabled:!S,children:v.submit})]}),K=n?/* @__PURE__ */ p(A,{icon:`bug`,label:e,order:`secondary`,size:`sm`,variant:`soft`,stacked:t,className:t?h:void 0,style:t?_:void 0,disabled:D,onClick:te,"aria-haspopup":`dialog`}):/* @__PURE__ */ p(y,{leftIcon:`bug`,variant:t?`solid`:`outline`,disabled:D,onClick:te,"aria-haspopup":`dialog`,children:e});return/* @__PURE__ */ m(f,{children:[t&&n?K:/* @__PURE__ */ p(`span`,{"data-support-capture":`exclude`,className:[t?`position-fixed m-3`:`d-inline-block`,h].filter(Boolean).join(` `),style:t?{...Mt,..._}:_,children:K}),D&&/* @__PURE__ */ m(`div`,{"data-support-capture":`exclude`,role:`status`,className:`position-fixed top-0 start-50 translate-middle-x mt-3 d-flex align-items-center gap-2 px-3 py-2 bg-body border rounded-pill shadow-sm wui-text-sm`,style:Nt,children:[/* @__PURE__ */ p(`span`,{className:`spinner-border spinner-border-sm`,"aria-hidden":`true`}),v.takingScreenshot]}),/* @__PURE__ */ p(L,{open:T,size:`lg`,title:v.title,subtitle:v.subtitle,headerIcon:`bug`,confirmDiscard:v.confirmDiscard,dirty:re&&!P,onClose:U,footer:ie,"data-support-capture":`exclude`,children:I?/* @__PURE__ */ p(g,{tone:`success`,role:`status`,title:Y(v.createdTitle,{number:I.number}),children:v.createdText}):S?/* @__PURE__ */ p(kt,{id:w,config:S,defaultCategory:a,initialValues:z,onValuesChange:B,extraFiles:k?[k]:[],onSubmit:ne,onBusyChange:F,children:/* @__PURE__ */ p(Rt,{t:v,file:k,failed:M,disabled:P||D,hintId:`${w}-screenshot-hint`,controlRef:ee,onAdd:H,onRemove:()=>j(null)})}):/* @__PURE__ */ p(g,{tone:C?`danger`:`info`,children:C?Z(C,v.configError,b.offline):v.loading})})]})}var Bt={title:`New ticket`,subtitle:`Tell us what you need. We reply by email and on this page.`,confirmDiscard:`Discard this ticket?`,cancel:`Cancel`,send:`Send ticket`};function Vt({open:e,onClose:t,onCreated:n,config:r,defaultCategory:a,appVersion:o}){let c=$(`newTicketModal`,Bt),l=Ze(),u=`support-new-${i().replace(/[^a-zA-Z0-9-]/g,``)}`,[d,f]=s(!1),[h,g]=s(null),_=!!h&&(h.subject.trim()!==``||h.body.trim()!==``||h.files.length>0);async function v(e){n(await l.createTicket({...e,userAgent:typeof navigator>`u`?void 0:navigator.userAgent,appVersion:o}))}return/* @__PURE__ */ p(L,{open:e,size:`lg`,title:c.title,subtitle:c.subtitle,headerIcon:`message-square`,confirmDiscard:c.confirmDiscard,dirty:_&&!d,onClose:()=>{d||t()},footer:/* @__PURE__ */ m(`div`,{className:`d-flex justify-content-end gap-2 w-100`,children:[/* @__PURE__ */ p(y,{variant:`soft`,onClick:t,disabled:d,children:c.cancel}),/* @__PURE__ */ p(y,{type:`submit`,form:u,loading:d,children:c.send})]}),children:e&&/* @__PURE__ */ p(kt,{id:u,config:r,defaultCategory:a,onSubmit:v,onBusyChange:f,onValuesChange:g})})}var Ht={loading:`Loading {name}`,failed:`Could not load this file. Click to try again.`},Ut=6e4,Wt=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`application/pdf`];function Gt({attachment:e}){let t=$(`attachmentThumb`,Ht),n=Ze(),[r,i]=s(!1),[a,o]=s(!1);async function c(){i(!0),o(!1);let t=Wt.includes(e.contentType)?window.open(``,`_blank`):null;t&&(t.opener=null);try{let r=await n.fetchAttachment(e.id),i=URL.createObjectURL(r);if(setTimeout(()=>URL.revokeObjectURL(i),Ut),t)t.location.href=i;else{let t=document.createElement(`a`);t.href=i,t.download=e.fileName,t.click()}}catch{t?.close(),o(!0)}finally{i(!1)}}let l=Number.isFinite(e.sizeBytes)?u(e.sizeBytes):`-`;return/* @__PURE__ */ m(f,{children:[/* @__PURE__ */ p(x,{leadingIcon:a?`x-circle`:`paperclip`,label:r?/* @__PURE__ */ m(f,{children:[/* @__PURE__ */ p(V,{size:`sm`,label:Y(t.loading,{name:e.fileName})}),` `,e.fileName]}):e.fileName,onClick:c,disabled:r,"aria-busy":r||void 0,title:`${e.fileName}, ${l}`}),a&&/* @__PURE__ */ p(`span`,{role:`status`,className:`wui-text-xs text-danger align-self-center`,children:t.failed})]})}var Kt={conversation:`Conversation`,you:`You`,supportTeam:`Support team`,supportBadge:`Support`},qt={whiteSpace:`pre-wrap`,overflowWrap:`anywhere`};function Jt({messages:e}){let t=$(`messageThread`,Kt);return/* @__PURE__ */ p(`ol`,{className:`list-unstyled d-flex flex-column gap-3 mb-0`,"aria-label":t.conversation,children:e.map(e=>{let n=/* @__PURE__ */ p(ot,{iso:e.createdDateTimeUtc,className:`wui-text-xs text-body-secondary text-nowrap`});if(e.authorKind===`System`)return/* @__PURE__ */ m(`li`,{className:`text-center wui-text-xs text-body-secondary`,"data-author":`system`,children:[/* @__PURE__ */ p(`span`,{className:`d-block`,children:e.body}),n]},e.id);let r=e.authorKind===`Customer`,i=e.authorName||(r?t.you:t.supportTeam);return/* @__PURE__ */ m(`li`,{className:`d-flex align-items-start gap-2${r?` flex-row-reverse`:``}`,"data-author":r?`customer`:`agent`,children:[/* @__PURE__ */ p(_,{name:i,size:32,tone:r?`neutral`:`primary`}),/* @__PURE__ */ m(b,{className:`flex-grow-1 border`,padding:`sm`,variant:r?`flat`:`accent`,style:{minWidth:0},children:[/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2 mb-2`,children:[/* @__PURE__ */ m(`span`,{className:`d-inline-flex flex-wrap align-items-center gap-2 fw-semibold wui-text-sm text-break`,children:[i,!r&&/* @__PURE__ */ p(v,{tone:`primary`,children:t.supportBadge})]}),n]}),/* @__PURE__ */ p(`div`,{className:`wui-text-sm`,style:qt,children:e.body}),e.attachments?.length>0&&/* @__PURE__ */ p(`div`,{className:`d-flex flex-wrap gap-2 mt-2`,children:e.attachments.map(e=>/* @__PURE__ */ p(Gt,{attachment:e},e.id))})]})]},e.id)})})}var Yt={solved:`You told us this solved your problem.`,notSolved:`You told us this did not solve your problem.`,sendFailed:`Your rating did not send. Please try again.`,commentLabel:`Anything to add?`,commentHint:`Optional. Your comment goes to the support team.`,yes:`Yes, it is solved`,no:`No, it is not`,heading:`Did this solve your problem?`,yourComment:`Your comment:`};function Xt({satisfaction:e,comment:t,canRate:n=!1,commentMaxLength:r,onRate:a}){let o=$(`ratingPanel`,Yt),c=$(`shared`,X),l=i(),[u,d]=s(``),[f,h]=s(null),[_,v]=s(``);if(e)return/* @__PURE__ */ m(g,{tone:e===`Satisfied`?`success`:`info`,role:`status`,children:[e===`Satisfied`?o.solved:o.notSolved,t?/* @__PURE__ */ m(`span`,{className:`d-block mt-1`,children:[o.yourComment,` `,t]}):null]});if(!n)return null;async function x(e){v(``),h(e);try{await a({satisfaction:e,comment:u})}catch(e){v(Z(e,o.sendFailed,c.offline))}finally{h(null)}}return/* @__PURE__ */ p(b,{padding:`sm`,className:`border`,title:o.heading,children:/* @__PURE__ */ m(`div`,{className:`d-flex flex-column gap-2`,children:[_&&/* @__PURE__ */ p(g,{tone:`danger`,children:_}),/* @__PURE__ */ p(U,{id:`${l}-comment`,label:o.commentLabel,rows:2,maxLength:r,value:u,onChange:e=>d(e.target.value),helperText:o.commentHint}),/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap gap-2`,children:[/* @__PURE__ */ p(y,{variant:`outline`,leftIcon:`check-circle`,loading:f===`Satisfied`,disabled:f!==null,onClick:()=>x(`Satisfied`),children:o.yes}),/* @__PURE__ */ p(y,{variant:`outline`,leftIcon:`x-circle`,loading:f===`Unsatisfied`,disabled:f!==null,onClick:()=>x(`Unsatisfied`),children:o.no})]})]})})}var Zt={emptyReply:`Write a message before you send it.`,sendFailed:`Your reply did not send. Please try again.`,replyLabel:`Your reply`,hintReopens:`Sending a reply reopens this ticket. You can paste an image into the message.`,hint:`You can paste an image into the message.`,attachedFiles:`Attached files`,removeFile:`Remove {name}`,attach:`Attach a file`,send:`Send reply`,formLabel:`Reply to this ticket`};function Qt({onSend:e,config:t,reopens:n=!1}){let r=$(`replyBox`,Zt),a=$(`shared`,X),o=i(),[c,l]=s(``),[u,d]=s([]),[f,_]=s(``),[v,b]=s(``),[C,w]=s(!1),T=e=>{let n=je(u,e,t,a);d(n.files),_(n.notice)},E=e=>{let n=u.filter((t,n)=>n!==e);d(n),_(Oe(n,t,a)??``)},D=e=>{let t=Me(e);t.length>0&&T(t)};async function O(n){n.preventDefault();let i=c.trim();if(!i){b(r.emptyReply);return}let o=Oe(u,t,a);if(o)_(o);else{b(``),w(!0);try{await e({body:i,files:u}),l(``),d([]),_(``)}catch(e){b(Z(e,r.sendFailed,a.offline))}finally{w(!1)}}}let k=v||f;return/* @__PURE__ */ m(`form`,{onSubmit:O,noValidate:!0,className:`d-flex flex-column gap-2 flex-grow-1 min-w-0`,"aria-label":r.formLabel,children:[k&&/* @__PURE__ */ p(g,{tone:`danger`,children:k}),/* @__PURE__ */ p(U,{id:`${o}-body`,label:r.replyLabel,rows:2,autoGrow:!0,maxLength:t?.bodyMaxLength,value:c,onChange:e=>{l(e.target.value),b(``)},onPaste:D,helperText:n?r.hintReopens:r.hint,required:!0}),u.length>0&&/* @__PURE__ */ p(S,{label:r.attachedFiles,children:u.map((e,t)=>/* @__PURE__ */ p(x,{leadingIcon:`paperclip`,label:e.name,removeLabel:Y(r.removeFile,{name:e.name}),onRemove:()=>E(t)},Ae(e)))}),/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2`,children:[/* @__PURE__ */ p(h,{iconVariant:`bulk`,icon:`paperclip`,label:r.attach,multiple:t?.maxAttachmentsPerMessage!==1,accept:Ee(t),onFiles:T}),/* @__PURE__ */ p(y,{type:`submit`,leftIcon:`send`,loading:C,children:r.send})]})]})}var $t={reopenFailed:`The ticket did not reopen. Please try again.`,withdrawFailed:`The request was not withdrawn. Please try again.`,back:`Back to tickets`,loadError:`We could not load this ticket.`,retry:`Try again`,fieldStatus:`Status`,fieldCategory:`Category`,fieldTicket:`Ticket`,fieldOpened:`Opened`,fieldUpdated:`Last update`,openedLabel:`Opened`,summaryLabel:`Ticket summary`,detailsLabel:`Ticket details`,detailsTitle:`Ticket details`,timeZoneNote:`Times are shown in {zone}.`,mergedText:`This ticket was merged into {number}. The conversation carries on there.`,openMerged:`Open {number}`,resolvedHint:`If you still need help, reopen the ticket or send a reply.`,waitingHint:`We need your answer to carry on. Reply below and the ticket goes back to our team.`,openHint:`Our team marks this resolved once your question is answered. Replying reopens it.`,reopen:`Reopen ticket`,withdraw:`Withdraw request`,withdrawTitle:`Withdraw this request?`,withdrawMessage:`Our team will stop working on this ticket. You can open a new ticket later if you still need help.`,withdrawConfirm:`Withdraw request`,withdrawCancel:`Keep request`,merged:`Merged into this ticket`};function en({ticketId:e,onBack:t,onChanged:n,onOpenTicket:r}){let{config:i}=tt(),a=$(`ticketDetail`,$t),o=$(`shared`,X),c=Qe(),l=$e(),{ticket:u,loading:f,error:h,reload:_,reply:v,reopen:x,cancel:S,rate:C}=it(e),[T,E]=s(!1),[O,k]=s(!1),[A,N]=s(!1),[P,F]=s(``),I=async e=>{let t=await e();return n?.(),t};async function L(){F(``),E(!0);try{await I(x)}catch(e){F(Z(e,a.reopenFailed,o.offline))}finally{E(!1)}}async function R(){F(``),N(!0);try{await I(S)}catch(e){F(Z(e,a.withdrawFailed,o.offline))}finally{N(!1),k(!1)}}let z=/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,leftIcon:`arrow-left`,onClick:t,className:`align-self-start`,children:a.back});if(!u)return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3`,"aria-busy":f||void 0,children:[z,h?/* @__PURE__ */ m(g,{tone:`danger`,children:[Z(h,a.loadError,o.offline),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:_,children:a.retry})]}):/* @__PURE__ */ p(ee,{height:160})]});let B=Pe(u.status),V=[{key:`status`,label:a.fieldStatus,value:u.statusLabel?/* @__PURE__ */ p(te,{label:u.statusLabel,tone:B}):`-`},{key:`category`,label:a.fieldCategory,value:u.category||`-`},{key:`ticket`,label:a.fieldTicket,value:u.number},{key:`opened`,label:a.fieldOpened,value:/* @__PURE__ */ p(ot,{iso:u.createdDateTimeUtc})},{key:`updated`,label:a.fieldUpdated,value:/* @__PURE__ */ p(ot,{iso:u.updatedDateTimeUtc})}];return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3`,"aria-labelledby":`support-ticket-${u.id}`,children:[z,/* @__PURE__ */ m(`div`,{className:`row g-3`,children:[/* @__PURE__ */ m(`div`,{className:`col-12 col-lg-8 d-flex flex-column gap-3`,children:[/* @__PURE__ */ m(`header`,{className:`d-flex flex-column gap-2`,children:[/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap align-items-center gap-2`,children:[/* @__PURE__ */ p(`h2`,{id:`support-ticket-${u.id}`,className:`h5 mb-0 text-break`,children:u.subject}),u.statusLabel&&/* @__PURE__ */ p(te,{label:u.statusLabel,tone:B})]}),/* @__PURE__ */ m(`ul`,{className:`list-unstyled d-flex flex-wrap gap-3 mb-0 wui-text-sm text-body-secondary`,"aria-label":a.summaryLabel,children:[u.number&&/* @__PURE__ */ m(`li`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ p(M,{variant:`bulk`,name:`receipt-text`,size:16}),u.number]}),u.category&&/* @__PURE__ */ m(`li`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ p(M,{variant:`bulk`,name:`folder-2`,size:16}),u.category]}),/* @__PURE__ */ m(`li`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ p(M,{variant:`bulk`,name:`calendar-1`,size:16}),a.openedLabel,` `,/* @__PURE__ */ p(ot,{iso:u.createdDateTimeUtc})]})]}),l===null&&/* @__PURE__ */ p(`p`,{className:`wui-text-xs text-body-secondary mb-0`,children:Y(a.timeZoneNote,{zone:d(c)})})]}),P&&/* @__PURE__ */ p(g,{tone:`danger`,children:P}),u.mergedInto&&/* @__PURE__ */ m(g,{tone:`info`,role:`status`,children:[Y(a.mergedText,{number:u.mergedInto.number}),` `,r&&/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:()=>r(u.mergedInto.id),children:Y(a.openMerged,{number:u.mergedInto.number})})]}),u.canReopen&&/* @__PURE__ */ p(g,{tone:`success`,role:`status`,children:a.resolvedHint}),u.status===`WaitingOnCustomer`&&/* @__PURE__ */ p(g,{tone:`warning`,role:`status`,children:a.waitingHint}),!u.canReopen&&/* @__PURE__ */ p(`p`,{className:`wui-text-sm text-body-secondary mb-0`,children:a.openHint}),u.canReopen&&/* @__PURE__ */ p(y,{variant:`soft`,leftIcon:`history`,loading:T,onClick:L,className:`align-self-start`,children:a.reopen}),u.canCancel&&/* @__PURE__ */ p(y,{variant:`soft`,onClick:()=>k(!0),className:`align-self-start`,children:a.withdraw}),/* @__PURE__ */ p(w,{open:O,title:a.withdrawTitle,description:a.withdrawMessage,confirmLabel:a.withdrawConfirm,cancelLabel:a.withdrawCancel,tone:`danger`,loading:A,onConfirm:R,onClose:()=>k(!1)}),/* @__PURE__ */ p(Xt,{satisfaction:u.satisfaction,comment:u.satisfactionComment,canRate:u.canRate,commentMaxLength:i?.satisfactionCommentMaxLength,onRate:e=>I(()=>C(e))}),/* @__PURE__ */ p(Jt,{messages:u.messages??[]}),u.mergedTickets?.length>0&&/* @__PURE__ */ m(`section`,{"aria-labelledby":`support-merged-${u.id}`,className:`d-flex flex-column gap-1`,children:[/* @__PURE__ */ p(`h3`,{id:`support-merged-${u.id}`,className:`h6 mb-0`,children:a.merged}),/* @__PURE__ */ p(`ul`,{className:`list-unstyled d-flex flex-column gap-1 mb-0 wui-text-sm`,children:u.mergedTickets.map(e=>/* @__PURE__ */ p(`li`,{children:r?/* @__PURE__ */ m(y,{variant:`ghost`,size:`sm`,onClick:()=>r(e.id),children:[e.number,`: `,e.subject]}):`${e.number}: ${e.subject}`},e.id))})]}),!u.mergedInto&&/* @__PURE__ */ p(j,{sticky:!0,align:`start`,children:/* @__PURE__ */ p(Qt,{config:i,reopens:u.canReopen,onSend:e=>I(()=>v(e))})})]}),/* @__PURE__ */ p(`aside`,{"aria-label":a.detailsLabel,className:`col-12 col-lg-4`,children:/* @__PURE__ */ m(b,{padding:`sm`,className:`border`,children:[/* @__PURE__ */ p(`h3`,{className:`h6`,children:a.detailsTitle}),/* @__PURE__ */ p(D,{columns:1,items:V})]})})]})]})}var tn=`ticket`;function nn(){return typeof window>`u`?null:new URLSearchParams(window.location.search).get(tn)}function rn(e){if(typeof window>`u`)return e?`?${tn}=${encodeURIComponent(e)}`:`?`;let t=new URL(window.location.href);return e?t.searchParams.set(tn,e):t.searchParams.delete(tn),`${t.pathname}${t.search}${t.hash}`}function an(e){if(typeof window>`u`)return;let t=rn(e);t!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,t)}var on={tabAll:`All`,tabOpen:`Open`,tabNeedsReply:`Needs your reply`,tabResolved:`Resolved`,tabWithdrawn:`Withdrawn`,columnSubject:`Subject`,columnStatus:`Status`,columnMessages:`Messages`,columnLastUpdate:`Last update`,loadError:`We could not load your tickets.`,retry:`Try again`,statusSelect:`Status`,filterByStatus:`Filter tickets by status`,searchPlaceholder:`Search tickets`,searchLabel:`Search tickets`,tableLabel:`Support tickets`,actions:`Actions`,openTicket:`Open ticket {subject}`,emptyTitle:`No tickets yet`,emptyText:`When you raise a ticket, it shows here with its status.`,noMatchTitle:`No tickets match`,noMatchText:`Try another search or status.`},sn=[`tabs`,`select`,`none`];function cn({tickets:e,loading:t,error:n,onRetry:r,onOpen:i,status:a,onStatusChange:o,statusFilter:s=`tabs`,counts:c,search:l,onSearchChange:u,pagination:d}){let f=$(`ticketList`,on),_=$(`shared`,X);ne(`SupportCenter`,`statusFilter`,s,sn);let v=[{key:`all`,label:f.tabAll,countKey:`total`},{key:`Open`,label:f.tabOpen,countKey:`open`},{key:`NeedsReply`,label:f.tabNeedsReply,countKey:`needsReply`},{key:`Resolved`,label:f.tabResolved,countKey:`resolved`},{key:`Withdrawn`,label:f.tabWithdrawn,countKey:`withdrawn`}],b=v.map(({key:e,label:t,countKey:n})=>{let r=c?.[n];return{value:e,label:r==null?t:`${t} (${r})`}}),x=(e,t)=>{e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),i(t))},S=[{key:`subject`,label:f.columnSubject,render:e=>/* @__PURE__ */ m(`div`,{className:`d-flex flex-column`,style:{minWidth:0},children:[/* @__PURE__ */ p(P,{href:rn(e.id),animation:`none`,className:`fw-semibold text-break`,onClick:t=>x(t,e.id),children:e.subject}),/* @__PURE__ */ m(`span`,{className:`wui-text-xs text-body-secondary`,children:[e.number,`, `,e.category]})]})},{key:`status`,label:f.columnStatus,render:e=>e.statusLabel?/* @__PURE__ */ p(te,{label:e.statusLabel,tone:Pe(e.status)}):`-`},{key:`messageCount`,label:f.columnMessages,cellClassName:`wui-text-sm text-body-secondary`,render:e=>e.messageCount},{key:`updatedDateTimeUtc`,label:f.columnLastUpdate,cellClassName:`wui-text-sm text-body-secondary text-nowrap`,render:e=>/* @__PURE__ */ p(ot,{iso:e.updatedDateTimeUtc})}];return/* @__PURE__ */ m(`div`,{className:`d-flex flex-column gap-3`,children:[n&&/* @__PURE__ */ m(g,{tone:`danger`,children:[Z(n,f.loadError,_.offline),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:r,children:f.retry})]}),/* @__PURE__ */ m(`div`,{className:`d-flex flex-column flex-md-row gap-2 align-items-md-center justify-content-between`,children:[s===`none`?null:s===`select`?/* @__PURE__ */ p(B,{label:f.statusSelect,value:a,onChange:o,options:b,fieldClassName:`flex-shrink-0`}):/* @__PURE__ */ p(H,{tabs:v.map(({key:e,label:t,countKey:n})=>({key:e,label:t,count:c?.[n]})),value:a,onChange:o,ariaLabel:f.filterByStatus,overflow:`menu`,className:`flex-grow-1`}),/* @__PURE__ */ p(z,{value:l,onChange:u,placeholder:f.searchPlaceholder,ariaLabel:f.searchLabel})]}),/* @__PURE__ */ p(E,{columns:S,rows:e,loading:t,skeletonRows:4,ariaLabel:f.tableLabel,rowActionsLabel:f.actions,rowActions:e=>/* @__PURE__ */ p(h,{icon:`eye`,label:Y(f.openTicket,{subject:e.subject}),href:rn(e.id),onClick:t=>x(t,e.id)}),stickyActions:!0,stackOnMobile:!0,sourceCount:c?.total??0,pagination:d,empty:/* @__PURE__ */ p(O,{variant:`table`,icon:`message-square`,title:f.emptyTitle,description:f.emptyText}),emptyFiltered:/* @__PURE__ */ p(O,{variant:`table`,icon:`search`,title:f.noMatchTitle,description:f.noMatchText})})]})}var ln=300,un=10,dn={heading:`Your tickets`,newTicket:`New ticket`,configError:`We could not load the support settings.`,retry:`Try again`};function fn({initialTicketId:e,defaultCategory:t,appVersion:n,status:i,defaultStatus:a=`all`,onStatusChange:o,statusFilter:c=`tabs`}){let l=$(`supportCenter`,dn),u=$(`shared`,X),{config:d,error:f,reload:h}=tt(),[_,v]=s(a),b=i!==void 0,x=b?i:_,S=e=>{b||v(e),o?.(e)},[C,w]=s(``),T=He(C.trim(),ln),[E,D]=s(un),O=`${x}|${T}|${E}`,[k,A]=s({key:O,page:1}),j=k.key===O?k.page:1,M=e=>A({key:O,page:e}),N=nt({status:x===`all`?void 0:x,search:T||void 0,page:j,pageSize:E}),{counts:P,reload:F}=rt(),[I,L]=s(()=>e||nn()),[R,z]=s(!1),B=N.totalPages;r(()=>{B>0&&j>B&&A({key:O,page:B})},[B,j,O]);let ee=()=>{N.reload(),F()},V=e=>{L(e),an(e)};if(I)return/* @__PURE__ */ p(en,{ticketId:I,onBack:()=>V(null),onChanged:ee,onOpenTicket:V},I);let te={page:j,totalPages:Math.max(1,N.totalPages),pageSize:E,total:N.totalCount,setPage:M,setPageSize:D};return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3 min-w-0`,"aria-labelledby":`support-center-title`,children:[/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2`,children:[/* @__PURE__ */ p(`h2`,{id:`support-center-title`,className:`h5 mb-0`,children:l.heading}),/* @__PURE__ */ p(y,{leftIcon:`plus`,onClick:()=>z(!0),disabled:!d,children:l.newTicket})]}),f&&/* @__PURE__ */ m(g,{tone:`warning`,children:[Z(f,l.configError,u.offline),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:h,children:l.retry})]}),/* @__PURE__ */ p(cn,{tickets:N.tickets,loading:N.loading,error:N.error,onRetry:ee,onOpen:V,status:x,onStatusChange:S,statusFilter:c,counts:P,search:C,onSearchChange:w,pagination:te}),d&&/* @__PURE__ */ p(Vt,{open:R,onClose:()=>z(!1),config:d,defaultCategory:t,appVersion:n,onCreated:e=>{z(!1),ee(),V(e.id)}})]})}var pn={copyEmail:`Copy email`,emailCopied:`Email copied`,contactNamed:`Contact {name}`,contactSupport:`Contact support`},mn=e=>typeof e==`string`&&e.trim()!==``;function hn({className:e}){let t=$(`supportContact`,pn),{config:n}=tt();if(!n)return null;let r=mn(n.supportEmail),i=mn(n.supportPhone),a=mn(n.supportHours),o=[`d-flex flex-wrap align-items-center gap-2 wui-text-sm`,e].filter(Boolean).join(` `);return/* @__PURE__ */ m(`section`,{className:o,"aria-label":mn(n.supportName)?Y(t.contactNamed,{name:n.supportName}):t.contactSupport,children:[/* @__PURE__ */ p(`span`,{className:`fw-semibold`,children:mn(n.supportName)?n.supportName:t.contactSupport}),r&&/* @__PURE__ */ m(`span`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ p(`a`,{href:`mailto:${n.supportEmail}`,className:`text-break`,children:n.supportEmail}),/* @__PURE__ */ p(T,{text:n.supportEmail,iconOnly:!0,label:t.copyEmail,copiedLabel:t.emailCopied})]}),i&&/* @__PURE__ */ p(`a`,{href:`tel:${n.supportPhone.replace(/[^\d+]/g,``)}`,children:n.supportPhone}),a&&/* @__PURE__ */ p(`span`,{className:`text-body-secondary`,children:n.supportHours})]})}function gn({client:e,timeZone:n=c,renderTime:r,labels:i,children:s}){let l=o(null),u=t((t=!1)=>{let n=l.current;if(t||!n||n.client!==e){let t=e.getConfig(),n={client:e,pending:t};return l.current=n,t.catch(()=>{l.current===n&&(l.current=null)}),t}return n.pending},[e]),d=a(()=>({client:e,loadConfig:u,timeZone:n,renderTime:r,labels:i}),[e,u,n,r,i]);return/* @__PURE__ */ p(Ye.Provider,{value:d,children:s})}export{ft as HelpArticle,vt as HelpCentre,zt as ReportIssue,Te as SupportAgentProvider,Ve as SupportAgentTicket,G as SupportApiError,fn as SupportCenter,hn as SupportContact,gn as SupportProvider,qe as SupportQueue,at as createHelpCentreClient,de as createSupportAgentClient,le as createSupportClient,_t as useHelpCentre,he as useSupportAgentClient,ve as useSupportAgentLabels,_e as useSupportAgentRenderTime,we as useSupportAgentSettings,Se as useSupportAgentTicket,ge as useSupportAgentTimeZone,Ce as useSupportAgents,Ze as useSupportClient,tt as useSupportConfig,be as useSupportQueue,xe as useSupportQueueCounts,it as useSupportTicket,rt as useSupportTicketCounts,nt as useSupportTickets};
1
+ import{createContext as e,useCallback as t,useContext as n,useEffect as r,useId as i,useMemo as a,useRef as o,useState as s}from"react";import{IST_TIME_ZONE as c,formatDateTime as l,formatFileSize as u,timeZoneLabel as d}from"@webority/ui-elements/helpers";import{Fragment as f,jsx as p,jsxs as m}from"react/jsx-runtime";import{AppActionIcon as h,AppAlert as g,AppAvatar as _,AppBadge as v,AppButton as y,AppCard as b,AppChip as x,AppChipGroup as S,AppChoiceChip as C,AppConfirmDialog as w,AppCopyButton as T,AppDataTable as E,AppDescriptions as D,AppEmptyState as O,AppFileAttachment as k,AppFloatingButton as A,AppFormActions as j,AppIcon as M,AppInput as N,AppLink as P,AppMarkdown as F,AppMetricStrip as I,AppModal as L,AppRadioGroup as R,AppSearch as z,AppSelect as B,AppSkeleton as ee,AppSpinner as V,AppStatusBadge as te,AppTabs as H,AppTextarea as U,warnInvalidValue as ne}from"@webority/ui-react";import{toBlob as re}from"html-to-image";var W=`Something went wrong. Please try again.`,G=class extends Error{constructor(e,t,n){super(t),this.name=`SupportApiError`,this.code=e,this.status=n}};async function ie(e){if(e&&typeof Blob<`u`&&e instanceof Blob)try{return JSON.parse(await e.text())}catch{return null}if(typeof e==`string`)try{return JSON.parse(e)}catch{return null}return e??null}async function K(e){if(e instanceof G)return e;let t=e?.response;if(!t)return new G(`network`,W);let n=await ie(t.data);return new G(typeof n?.code==`string`&&n.code?n.code:`unknown`,typeof n?.detail==`string`&&n.detail.trim()?n.detail:W,t.status)}async function q(e){try{return(await e()).data}catch(e){throw await K(e)}}function J(e,t,n){n!=null&&String(n).trim()!==``&&e.append(t,String(n))}function ae(e,t,n,r){(n??[]).forEach((n,i)=>{let a=n?.name||`${r}-${i+1}.png`;e.append(t,n,a)})}var oe=20;function se(e,t){return(e??[]).map((e,n)=>e?.name||`${t}-${n+1}.png`).join(`|`)}function ce(e){return e instanceof G&&typeof e.status==`number`&&e.status>=400&&e.status<=499&&e.status!==408&&e.status!==429}function le(e,t=`/api/support`){let n=(typeof t==`string`?t:t?.base??`/api/support`).replace(/\/+$/,``),r=e=>`${n}/tickets/${encodeURIComponent(e)}`,i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map;function o(){for(let e of i.keys()){if(i.size<=oe)return;a.has(e)||i.delete(e)}}async function s(e,t){let n=i.get(e)||crypto.randomUUID();i.delete(e),i.set(e,n),a.set(e,(a.get(e)??0)+1),o();try{let r=await t(n);return i.delete(e),r}catch(t){throw ce(t)&&i.delete(e),t}finally{let t=a.get(e)-1;t>0?a.set(e,t):a.delete(e)}}return{getConfig:()=>q(()=>e.get(`${n}/settings`)),listTickets:({status:t,search:r,page:i,pageSize:a}={})=>{let o=new URLSearchParams;J(o,`status`,t),J(o,`search`,r?.trim()),J(o,`page`,i),J(o,`pageSize`,a);let s=o.toString();return q(()=>e.get(`${n}/tickets${s?`?${s}`:``}`))},getTicketCounts:()=>q(()=>e.get(`${n}/tickets/counts`)),getTicket:t=>q(()=>e.get(r(t))),createTicket:({category:t,subject:r,body:i,pageUrl:a,userAgent:o,appVersion:c,files:l,screenshots:u})=>{let d=new FormData;return d.append(`category`,t??``),d.append(`subject`,r??``),d.append(`body`,i??``),J(d,`pageUrl`,a),J(d,`userAgent`,o),J(d,`appVersion`,c),ae(d,`files`,l,`file`),ae(d,`screenshots`,u,`screenshot`),s([`ticket`,t,r,i,se(l,`file`),se(u,`screenshot`)].join(`\0`),t=>q(()=>e.post(`${n}/tickets`,d,{headers:{"Idempotency-Key":t}})))},getSuggestions:async(t,{signal:r}={})=>{try{return await q(()=>e.get(`${n}/suggestions`,{params:{subject:t},signal:r}))}catch(e){if(e instanceof G&&e.status===404)return[];throw e}},reply:(t,{body:n,files:i,screenshots:a})=>{let o=new FormData;return o.append(`body`,n??``),ae(o,`files`,i,`file`),ae(o,`screenshots`,a,`screenshot`),s([`reply`,t,n,se(i,`file`),se(a,`screenshot`)].join(`\0`),n=>q(()=>e.post(`${r(t)}/replies`,o,{headers:{"Idempotency-Key":n}})))},reopen:t=>q(()=>e.post(`${r(t)}/reopen`)),cancel:t=>q(()=>e.post(`${r(t)}/cancel`)),rate:(t,{satisfaction:n,comment:i})=>{let a={satisfaction:n};return i!=null&&i.trim()!==``&&(a.comment=i.trim()),q(()=>e.post(`${r(t)}/rating`,a))},fetchAttachment:t=>q(()=>e.get(`${n}/attachments/${encodeURIComponent(t)}`,{responseType:`blob`})),confirmAction:t=>q(()=>e.post(`${n}/actions/confirm`,{token:t}))}}var ue=6e4;function de(e,{basePath:t=`/api/support/agent`}={}){let n=t.replace(/\/+$/,``),r=e=>`${n}/tickets/${encodeURIComponent(e)}`,i=(e,t)=>`${r(e)}/attachments/${encodeURIComponent(t)}`;return{getSettings:()=>q(()=>e.get(`${n}/settings`)),listTickets:(t={})=>{let r=new URLSearchParams;for(let[e,n]of Object.entries(t))n!=null&&String(n).trim()!==``&&r.append(e,String(n));let i=r.toString();return q(()=>e.get(`${n}/tickets${i?`?${i}`:``}`))},countTickets:()=>q(()=>e.get(`${n}/tickets/counts`)),getTicket:t=>q(()=>e.get(r(t))),reply:(t,{version:n,body:i,isInternal:a,files:o})=>{let s=new FormData;return s.append(`version`,n??``),s.append(`body`,i??``),s.append(`isInternal`,String(!!a)),ae(s,`files`,o,`file`),q(()=>e.post(`${r(t)}/replies`,s))},changeStatus:(t,{version:n,status:i})=>q(()=>e.post(`${r(t)}/status`,{version:n,status:i})),changePriority:(t,{version:n,priority:i})=>q(()=>e.post(`${r(t)}/priority`,{version:n,priority:i})),changeCategory:(t,{version:n,category:i})=>q(()=>e.post(`${r(t)}/category`,{version:n,category:i})),assign:(t,{version:n,agentUserId:i})=>q(()=>e.post(`${r(t)}/assignee`,{version:n,agentUserId:i})),listAgents:()=>q(()=>e.get(`${n}/agents`)),listRealms:()=>q(()=>e.get(`${n}/realms`)),attachmentUrl:i,openAttachment:async(t,n)=>{let r=await q(()=>e.get(i(t,n),{responseType:`blob`})),a=URL.createObjectURL(r);window.open(a,`_blank`,`noopener`),setTimeout(()=>URL.revokeObjectURL(a),ue)}}}var fe=3e4,pe=e(null);function me(){let e=n(pe);if(!e)throw Error(`Support agent components and hooks must be used inside <SupportAgentProvider>.`);return e}function he(){return me().client}function ge(){return me().timeZone}function _e(){return me().renderTime??null}function ve(e,t){let n=me().labels?.[e];return a(()=>n?{...t,...n}:t,[n,t])}function ye(e,n,i=!0){let[a,c]=s({data:null,loading:i,error:null}),[l,u]=s(0),d=o(e);d.current=e;let f=o(n);r(()=>{let e=f.current!==n;if(f.current=n,!i){c({data:null,loading:!1,error:null});return}let t=!0;return c(t=>({data:e?null:t.data,loading:!0,error:null})),d.current(l>0).then(e=>t&&c({data:e,loading:!1,error:null}),e=>t&&c(t=>({...t,loading:!1,error:e}))),()=>{t=!1}},[n,i,l]);let p=t(()=>u(e=>e+1),[]),m=t(e=>c(t=>({...t,data:typeof e==`function`?e(t.data):e})),[]);return{...a,reload:p,setData:m}}function be(e={}){let t=he(),{data:n,loading:r,error:i,reload:a}=ye(()=>t.listTickets(e),JSON.stringify(e));return{tickets:n?.items??[],totalCount:n?.totalCount??0,totalPages:n?.totalPages??0,loading:r,error:i,reload:a}}function xe(){let e=he(),{data:t,loading:n,error:r,reload:i}=ye(()=>e.countTickets(),`queue-counts`);return{counts:t,loading:n,error:r,reload:i}}function Se(e){let n=he(),{data:i,loading:a,error:s,reload:c,setData:l}=ye(()=>n.getTicket(e),e??``,!!e),u=o(0),d=o(e);d.current=e;let f=t(async e=>{u.current+=1;try{let t=await e();return l(t),t}finally{--u.current}},[l]),p=t(async()=>{if(u.current>0)return;let t=e;try{let e=await n.getTicket(t);if(d.current!==t)return;l(t=>t?Date.parse(e.updatedDateTimeUtc)>=Date.parse(t.updatedDateTimeUtc)?e:t:e)}catch{}},[n,e,l]);return r(()=>{if(!e)return;let t=null,n=()=>{t===null&&(t=setInterval(p,fe))},r=()=>{t!==null&&clearInterval(t),t=null},i=()=>{document.hidden?r():(p(),n())};return document.addEventListener(`visibilitychange`,i),document.hidden||n(),()=>{r(),document.removeEventListener(`visibilitychange`,i)}},[e,p]),{ticket:i,loading:a,error:s,reload:c,reply:t(t=>f(()=>n.reply(e,t)),[f,n,e]),changeStatus:t(t=>f(()=>n.changeStatus(e,t)),[f,n,e]),changePriority:t(t=>f(()=>n.changePriority(e,t)),[f,n,e]),changeCategory:t(t=>f(()=>n.changeCategory(e,t)),[f,n,e]),assign:t(t=>f(()=>n.assign(e,t)),[f,n,e])}}function Ce(){let{client:e,loadOnce:t}=me(),{data:n,loading:r,error:i,reload:a}=ye(n=>t(`agents`,()=>e.listAgents(),n),`agents`);return{agents:n??[],loading:r,error:i,reload:a}}function we(){let{client:e,loadOnce:t}=me(),{data:n,loading:r,error:i,reload:a}=ye(n=>t(`settings`,()=>e.getSettings(),n),`settings`);return{settings:n,loading:r,error:i,reload:a}}function Te({client:e,timeZone:n=c,renderTime:r,labels:i,children:s}){let l=o(/* @__PURE__ */ new Map),u=t((t,n,r=!1)=>{let i=l.current.get(t);if(!r&&i&&i.client===e)return i.pending;let a=n(),o={client:e,pending:a};return l.current.set(t,o),a.catch(()=>{l.current.get(t)===o&&l.current.delete(t)}),a},[e]),d=a(()=>({client:e,loadOnce:u,timeZone:n,renderTime:r,labels:i}),[e,u,n,r,i]);return/* @__PURE__ */ p(pe.Provider,{value:d,children:s})}function Y(e,t){return String(e).replace(/[{]([A-Za-z0-9_]+)[}]/g,(e,n)=>n in t?String(t[n]):e)}var X={offline:`We could not reach support. Check your connection and try again.`,attachOne:`You can attach one file.`,attachMany:`You can attach up to {count} files.`,typeNotAccepted:`{name} is a file type we cannot accept.`,tooLarge:`{name} is larger than {size}.`,thisFile:`This file`,alreadyAttached:`{name} is already attached.`};function Z(e,t,n=X.offline){if(e instanceof G){if(e.code===`network`)return n;if(e.code!==`unknown`)return e.message}return t}function Ee(e){return(e?.allowedContentTypes??[]).join(`,`)}function De(e,t){if(t.length===0)return!0;let n=(e||``).toLowerCase();return t.some(e=>{let t=e.toLowerCase();return t.endsWith(`/*`)?n.startsWith(t.slice(0,-1)):n===t})}function Oe(e,t,n=X){let r=e??[],i=t?.maxAttachmentsPerMessage??0,a=t?.maxAttachmentBytes??0,o=t?.allowedContentTypes??[];if(i>0&&r.length>i)return i===1?n.attachOne:Y(n.attachMany,{count:i});for(let e of r){let t=e.name||n.thisFile;if(!De(e.type,o))return Y(n.typeNotAccepted,{name:t});if(a>0&&e.size>a)return Y(n.tooLarge,{name:t,size:u(a)})}return null}var ke=(e,t)=>e===1?t.attachOne:Y(t.attachMany,{count:e});function Ae(e){return`${e.name}|${e.size}|${e.lastModified}`}function je(e,t,n,r=X){let i=n?.maxAttachmentsPerMessage??0,a=new Set(e.map(Ae)),o=[],s=null;for(let e of t){let t=Ae(e);a.has(t)?s??=e.name:(a.add(t),o.push(e))}let c=i>0?Math.max(0,i-e.length):o.length,l=[...e,...o.slice(0,c)];return{files:l,notice:(o.length>c?ke(i,r):null)??Oe(l,n,r)??(s?Y(r.alreadyAttached,{name:s}):``)}}function Me(e){let t=Array.from(e.clipboardData?.items??[]),n=Date.now();return t.filter(e=>e.kind===`file`&&e.type.startsWith(`image/`)).map(e=>e.getAsFile()).filter(Boolean).map((e,t)=>{let r=(e.type.split(`/`)[1]||`png`).replace(`jpeg`,`jpg`);return new File([e],`pasted-image-${n}-${t+1}.${r}`,{type:e.type})})}var Ne={Open:`info`,InProgress:`info`,WaitingOnCustomer:`warning`,Resolved:`success`,Closed:`success`,Cancelled:`neutral`};function Pe(e){return Ne[e]??`neutral`}var Fe={supportQueue:{countOpen:`Open`,countInProgress:`In progress`,countWaiting:`Waiting`,countOverdue:`Overdue`,countUnassigned:`Unassigned`,filterStatus:`Status`,filterPriority:`Priority`,filterCategory:`Category`,filterPlace:`Place`,filterAssignee:`Assignee`,filterUnassignedOnly:`Unassigned only`,filterOverdueOnly:`Overdue only`,filterSearch:`Search`,filterAny:`All`,columnNumber:`Number`,columnPlace:`Place`,columnSubject:`Subject`,columnCategory:`Category`,columnStatus:`Status`,columnPriority:`Priority`,columnAssignee:`Assignee`,columnDue:`Due`,loading:`Loading tickets...`,empty:`No tickets match these filters.`,error:`We could not load the tickets. Try again.`,retry:`Try again`,heading:`Ticket queue`,tableLabel:`Tickets in this queue`,settingsError:`We could not load the queue settings.`,overdueMark:`Overdue`,noAssignee:`Unassigned`,emptyUnfiltered:`No tickets in this queue yet.`},agentTicket:{reply:`Reply`,internalNote:`Internal note`,send:`Send`,savedReplies:`Saved replies`,attachFiles:`Attach files`,status:`Status`,priority:`Priority`,category:`Category`,assignee:`Assignee`,unassigned:`Unassigned`,internal:`Internal`,backToQueue:`Back to queue`,stale:`Someone else changed this ticket just now. Reload it and try again.`,reload:`Reload`,loading:`Loading ticket...`,empty:`No messages yet.`,error:`We could not load this ticket. Try again.`,retry:`Try again`,emptyReply:`Write a message before you send it.`,actionFailed:`The change was not saved. Please try again.`,attachmentFailed:`This file could not be opened. Try again.`,none:`None`,customer:`Customer`,supportTeam:`Support team`,overdue:`Overdue`,detailsLabel:`Ticket details`,controlsLabel:`Ticket controls`,fieldTicket:`Ticket`,fieldAccount:`Account`,fieldRealm:`Realm`,fieldReporter:`Reporter`,fieldEmail:`Email`,fieldRaised:`Raised`,fieldUpdated:`Updated`,fieldReplyDue:`Reply due`,fieldResolutionDue:`Resolution due`,mode:`Reply or internal note`,replyHint:`The customer sees this reply.`,noteHint:`Only the support team sees an internal note.`,body:`Message`,insertSaved:`Insert a saved reply`,attachedFiles:`Attached files`,removeFile:`Remove {name}`,formLabel:`Reply to this ticket`,conversation:`Conversation`}},Ie=[`InProgress`,`WaitingOnCustomer`,`Resolved`,`Closed`],Le=`support-agent-draft:`;function Re(e){try{return sessionStorage.getItem(Le+e)??``}catch{return``}}function ze(e,t){try{t?sessionStorage.setItem(Le+e,t):sessionStorage.removeItem(Le+e)}catch{}}function Be({iso:e,className:t}){let n=_e(),r=ge();return n?n(e):/* @__PURE__ */ p(`time`,{dateTime:e,className:t,children:l(e,{timeZone:r})})}function Ve({ticketId:e,onBack:t,labels:n}){let a=ve(`agentTicket`,Fe.agentTicket),o=n?{...a,...n}:a,c=i(),l=he(),{ticket:u,loading:d,error:f,reload:_,reply:C,changeStatus:w,changePriority:T,changeCategory:E,assign:O}=Se(e),{settings:k}=we(),{agents:A}=Ce(),[j,M]=s(`reply`),[N,P]=s(()=>Re(e)),[F,I]=s([]),[L,z]=s(``),[V,H]=s(``),[ne,re]=s(!1),[W,G]=s(!1);r(()=>{P(Re(e)),I([]),z(``),H(``),re(!1)},[e]);let ie=/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,leftIcon:`arrow-left`,onClick:t,className:`align-self-start`,children:o.backToQueue});if(!u)return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3`,"aria-busy":d||void 0,children:[ie,f?/* @__PURE__ */ m(g,{tone:`danger`,children:[Z(f,o.error,X.offline),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:_,children:o.retry})]}):/* @__PURE__ */ p(ee,{height:160})]});async function K(e){H(``),re(!1),G(!0);try{return await e(),!0}catch(e){return e?.status===409?re(!0):H(Z(e,o.actionFailed,X.offline)),!1}finally{G(!1)}}let q=t=>{P(t),H(``),ze(e,t)},J=e=>{let t=je(F,e,k,X);I(t.files),z(t.notice)},ae=e=>{let t=F.filter((t,n)=>n!==e);I(t),z(Oe(t,k,X)??``)},oe=e=>{let t=Me(e);t.length>0&&J(t)};async function se(t){t.preventDefault();let n=N.trim();if(!n){H(o.emptyReply);return}let r=Oe(F,k,X);r?z(r):await K(()=>C({version:u.version,body:n,isInternal:j===`note`,files:F}))&&(P(``),I([]),z(``),ze(e,``))}let ce=t=>{H(``),l.openAttachment(e,t).catch(e=>{H(Z(e,o.attachmentFailed,X.offline))})},le=e=>{let t=(k?.savedReplies??[])[Number(e)];t&&q(N?`${N}\n${t.body}`:t.body)},ue=k?.queues??[],de=ue.find(e=>e.key===u.queue),fe=de?de.categories:ue.flatMap(e=>e.categories??[]),pe=(k?.statuses??[]).filter(e=>Ie.includes(e.value)).map(e=>({value:e.value,label:e.label})),me=(k?.priorities??[]).map(e=>({value:e.value,label:e.label})),ge=[...new Set(fe??[])].map(e=>({value:e,label:e})),_e=[{value:``,label:o.unassigned},...(A??[]).map(e=>({value:String(e.userId),label:e.name}))],ye=(e,t)=>e?/* @__PURE__ */ m(`span`,{className:`d-inline-flex flex-wrap align-items-center gap-2`,children:[/* @__PURE__ */ p(Be,{iso:e}),t&&/* @__PURE__ */ p(v,{tone:`danger`,children:o.overdue})]}):o.none,be=[{key:`ticket`,label:o.fieldTicket,value:u.number},{key:`account`,label:o.fieldAccount,value:u.accountId??o.none},{key:`realm`,label:o.fieldRealm,value:u.realm?k?.realmLabels?.[u.realm]??u.realm:o.none},{key:`reporter`,label:o.fieldReporter,value:u.reporterName||o.none},{key:`email`,label:o.fieldEmail,value:u.reporterEmail||o.none},{key:`raised`,label:o.fieldRaised,value:/* @__PURE__ */ p(Be,{iso:u.raisedDateTimeUtc??u.createdDateTimeUtc})},{key:`updated`,label:o.fieldUpdated,value:/* @__PURE__ */ p(Be,{iso:u.updatedDateTimeUtc})},{key:`replyDue`,label:o.fieldReplyDue,value:ye(u.replyDueDateTimeUtc,u.isOverdue)},{key:`resolutionDue`,label:o.fieldResolutionDue,value:ye(u.resolutionDueDateTimeUtc,u.isResolutionOverdue)}],xe=V||L;return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3`,"aria-labelledby":`${c}-subject`,children:[ie,/* @__PURE__ */ m(`div`,{className:`row g-3`,children:[/* @__PURE__ */ m(`div`,{className:`col-12 col-lg-8 d-flex flex-column gap-3`,children:[/* @__PURE__ */ m(`header`,{className:`d-flex flex-wrap align-items-center gap-2`,children:[/* @__PURE__ */ p(`h2`,{id:`${c}-subject`,className:`h5 mb-0 text-break`,children:u.subject}),/* @__PURE__ */ p(te,{label:u.statusLabel??u.status,tone:Pe(u.status)})]}),ne&&/* @__PURE__ */ m(g,{tone:`warning`,children:[o.stale,` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:_,children:o.reload})]}),/* @__PURE__ */ m(`ol`,{className:`list-unstyled d-flex flex-column gap-3 mb-0`,"aria-label":o.conversation,children:[(u.messages??[]).length===0&&/* @__PURE__ */ p(`p`,{className:`wui-text-sm text-body-secondary mb-0`,children:o.empty}),(u.messages??[]).map(e=>{if(e.authorKind===`System`)return/* @__PURE__ */ m(`li`,{className:`text-center wui-text-xs text-body-secondary`,"data-author":`system`,children:[/* @__PURE__ */ p(`span`,{className:`d-block`,children:e.body}),/* @__PURE__ */ p(Be,{iso:e.createdDateTimeUtc})]},e.id);let t=e.authorKind===`Customer`,n=e.authorName||(t?o.customer:o.supportTeam);return/* @__PURE__ */ p(`li`,{"data-author":t?`customer`:`agent`,"data-internal":e.isInternal?`true`:void 0,children:/* @__PURE__ */ m(b,{padding:`sm`,variant:e.isInternal?`accent`:`flat`,className:`border`,children:[/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2 mb-2`,children:[/* @__PURE__ */ m(`span`,{className:`d-inline-flex flex-wrap align-items-center gap-2 fw-semibold wui-text-sm text-break`,children:[n,e.isInternal&&/* @__PURE__ */ p(v,{tone:`warning`,children:o.internal})]}),/* @__PURE__ */ p(`span`,{className:`wui-text-xs text-body-secondary text-nowrap`,children:/* @__PURE__ */ p(Be,{iso:e.createdDateTimeUtc})})]}),/* @__PURE__ */ p(`div`,{className:`wui-text-sm`,style:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:e.body}),e.attachments?.length>0&&/* @__PURE__ */ p(`div`,{className:`d-flex flex-wrap gap-2 mt-2`,children:e.attachments.map(e=>/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,leftIcon:`paperclip`,onClick:()=>ce(e.id),children:e.fileName},e.id))})]})},e.id)})]}),/* @__PURE__ */ m(`form`,{onSubmit:se,noValidate:!0,className:`d-flex flex-column gap-2 min-w-0`,"aria-label":o.formLabel,children:[xe&&/* @__PURE__ */ p(g,{tone:`danger`,children:xe}),/* @__PURE__ */ p(R,{label:o.mode,options:[{value:`reply`,label:o.reply},{value:`note`,label:o.internalNote}],value:j,onChange:M,inline:!0}),/* @__PURE__ */ p(B,{label:o.savedReplies,placeholder:o.insertSaved,options:(k?.savedReplies??[]).map((e,t)=>({value:String(t),label:e.title})),value:``,onChange:le,disabled:W}),/* @__PURE__ */ p(U,{id:`${c}-body`,label:o.body,rows:3,autoGrow:!0,maxLength:k?.bodyMaxLength,value:N,onChange:e=>q(e.target.value),onPaste:oe,helperText:j===`note`?o.noteHint:o.replyHint,required:!0}),F.length>0&&/* @__PURE__ */ p(S,{label:o.attachedFiles,children:F.map((e,t)=>/* @__PURE__ */ p(x,{leadingIcon:`paperclip`,label:e.name,removeLabel:Y(o.removeFile,{name:e.name}),onRemove:()=>ae(t)},Ae(e)))}),/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2`,children:[/* @__PURE__ */ p(h,{iconVariant:`bulk`,icon:`paperclip`,label:o.attachFiles,multiple:k?.maxAttachmentsPerMessage!==1,accept:Ee(k),onFiles:J}),/* @__PURE__ */ p(y,{type:`submit`,leftIcon:`send`,loading:W,children:o.send})]})]})]}),/* @__PURE__ */ m(`aside`,{"aria-label":o.detailsLabel,className:`col-12 col-lg-4 d-flex flex-column gap-3`,children:[/* @__PURE__ */ p(b,{padding:`sm`,className:`border`,children:/* @__PURE__ */ p(D,{columns:1,items:be})}),/* @__PURE__ */ p(b,{padding:`sm`,className:`border`,"aria-label":o.controlsLabel,children:/* @__PURE__ */ m(`div`,{className:`d-flex flex-column gap-3`,children:[/* @__PURE__ */ p(B,{label:o.status,value:u.status,options:pe,disabled:W,onChange:e=>K(()=>w({version:u.version,status:e}))}),/* @__PURE__ */ p(B,{label:o.priority,value:u.priority??``,options:me,disabled:W,onChange:e=>K(()=>T({version:u.version,priority:e}))}),/* @__PURE__ */ p(B,{label:o.category,value:u.category,options:ge,disabled:W,onChange:e=>K(()=>E({version:u.version,category:e}))}),/* @__PURE__ */ p(B,{label:o.assignee,value:u.assignedAgentUserId==null?``:String(u.assignedAgentUserId),options:_e,disabled:W,onChange:e=>K(()=>O({version:u.version,agentUserId:e?Number(e):null}))})]})})]})]})]})}function He(e,t){let[n,i]=s(e);return r(()=>{let n=setTimeout(()=>i(e),t);return()=>clearTimeout(n)},[e,t]),n}var Ue=10,We=300,Q=`all`,Ge=e=>e===Q?void 0:e,Ke=e=>[...new Set(e.flatMap(e=>e.categories??[]))];function qe({onOpenTicket:e,getTicketHref:t,status:n,onStatusChange:i,defaultStatus:a=Q,queue:o,pageSize:c=Ue}){let u=ve(`supportQueue`,Fe.supportQueue),d=_e(),f=ge(),{settings:h,error:_}=we(),{agents:b}=Ce(),{counts:x}=xe(),[S,w]=s(a),T=n!==void 0,D=T?n:S,k=e=>{T||w(e),i?.(e)},[A,j]=s(Q),[M,N]=s(Q),[F,L]=s(Q),[R,ee]=s(Q),[V,H]=s(!1),[U,ne]=s(!1),[re,W]=s(``),G=He(re.trim(),We),[ie,K]=s(c),q=JSON.stringify([o,D,A,M,F,R,V,U,G,ie]),[J,ae]=s({key:q,page:1}),oe=J.key===q?J.page:1,se=e=>ae({key:q,page:e}),ce=be({queue:o,status:Ge(D),priority:Ge(A),category:Ge(M),realm:Ge(F),assignedAgentUserId:Ge(R),unassignedOnly:V||void 0,overdueOnly:U||void 0,includeSettled:D===Q||void 0,search:G||void 0,page:oe,pageSize:ie}),le=ce.totalPages;r(()=>{le>0&&oe>le&&ae({key:q,page:le})},[le,oe,q]);let ue=h?.queues??[],de=o?ue.filter(e=>e.key===o):ue,fe=[{value:Q,label:u.filterAny},...h?.statuses??[]],pe=[{value:Q,label:u.filterAny},...h?.priorities??[]],me=[{value:Q,label:u.filterAny},...Ke(de).map(e=>({value:e,label:e}))],he=[{value:Q,label:u.filterAny},...Object.entries(h?.realmLabels??{}).map(([e,t])=>({value:e,label:t}))],ye=[{value:Q,label:u.filterAny},...b.map(e=>({value:String(e.userId),label:e.name}))],Se=h?.realmLabels??{},Te=e=>d?d(e):/* @__PURE__ */ p(`time`,{dateTime:e,children:l(e,{timeZone:f})}),Y=(t,n)=>{e&&(t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),e(n)))},X=[{key:`number`,label:u.columnNumber,nowrap:!0,render:n=>{let r=t?.(n.id);return!r&&!e?/* @__PURE__ */ p(`span`,{className:`fw-semibold text-nowrap`,children:n.number}):r?/* @__PURE__ */ p(P,{href:r,animation:`none`,className:`fw-semibold text-nowrap`,onClick:e=>Y(e,n.id),children:n.number}):/* @__PURE__ */ p(y,{variant:`link`,size:`sm`,className:`fw-semibold text-nowrap`,onClick:()=>e(n.id),children:n.number})}},{key:`place`,label:u.columnPlace,render:e=>{let t=Se[e.realm]??`-`,n=t.trim().toLowerCase()===(e.accountName??``).trim().toLowerCase();return/* @__PURE__ */ m(`div`,{className:`d-flex flex-column`,style:{minWidth:0},children:[/* @__PURE__ */ p(`span`,{className:`text-break`,children:e.accountName}),!n&&/* @__PURE__ */ p(`span`,{className:`wui-text-xs text-body-secondary`,children:t})]})}},{key:`subject`,label:u.columnSubject,render:e=>/* @__PURE__ */ p(`span`,{className:`text-break`,children:e.subject})},{key:`category`,label:u.columnCategory,render:e=>e.category},{key:`status`,label:u.columnStatus,render:e=>/* @__PURE__ */ p(te,{label:e.statusLabel,tone:Pe(e.status)})},{key:`priority`,label:u.columnPriority,render:e=>/* @__PURE__ */ p(v,{children:e.priorityLabel})},{key:`assignee`,label:u.columnAssignee,render:e=>e.assignedAgentName??u.noAssignee},{key:`due`,label:u.columnDue,cellClassName:`wui-text-sm text-nowrap`,render:e=>{let t=e.resolutionDueDateTimeUtc,n=e.isOverdue||e.isResolutionOverdue;return/* @__PURE__ */ m(`span`,{className:`d-inline-flex gap-2 align-items-center`,children:[t?Te(t):`-`,n&&/* @__PURE__ */ p(v,{tone:`danger`,children:u.overdueMark})]})}}],Ee=[{label:u.countOpen,value:x?.open??`-`},{label:u.countInProgress,value:x?.inProgress??`-`},{label:u.countWaiting,value:x?.waitingOnCustomer??`-`},{label:u.countOverdue,value:x?.overdue??`-`,tone:`danger`},{label:u.countUnassigned,value:x?.unassigned??`-`}],De=[D,A,M,F,R].some(e=>e!==Q)||V||U||!!G,Oe={page:oe,totalPages:Math.max(1,ce.totalPages),pageSize:ie,total:ce.totalCount,setPage:se,setPageSize:K};return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3 min-w-0`,"aria-labelledby":`support-queue-title`,children:[/* @__PURE__ */ p(`h2`,{id:`support-queue-title`,className:`h5 mb-0`,children:u.heading}),_&&/* @__PURE__ */ p(g,{tone:`warning`,children:Z(_,u.settingsError)}),/* @__PURE__ */ p(I,{items:Ee,columns:5,size:`sm`}),ce.error&&/* @__PURE__ */ m(g,{tone:`danger`,children:[Z(ce.error,u.error),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:ce.reload,children:u.retry})]}),/* @__PURE__ */ m(`div`,{className:`d-flex flex-column flex-xl-row flex-wrap gap-2 align-items-xl-end`,children:[/* @__PURE__ */ p(B,{label:u.filterStatus,value:D,onChange:k,options:fe,fieldClassName:`flex-shrink-0`}),/* @__PURE__ */ p(B,{label:u.filterPriority,value:A,onChange:j,options:pe,fieldClassName:`flex-shrink-0`}),/* @__PURE__ */ p(B,{label:u.filterCategory,value:M,onChange:N,options:me,fieldClassName:`flex-shrink-0`}),/* @__PURE__ */ p(B,{label:u.filterPlace,value:F,onChange:L,options:he,fieldClassName:`flex-shrink-0`}),/* @__PURE__ */ p(B,{label:u.filterAssignee,value:R,onChange:ee,options:ye,fieldClassName:`flex-shrink-0`}),/* @__PURE__ */ p(C,{multiple:!0,checked:V,onChange:()=>H(e=>!e),children:u.filterUnassignedOnly}),/* @__PURE__ */ p(C,{multiple:!0,checked:U,onChange:()=>ne(e=>!e),children:u.filterOverdueOnly}),/* @__PURE__ */ p(z,{value:re,onChange:W,placeholder:u.filterSearch,ariaLabel:u.filterSearch})]}),/* @__PURE__ */ p(E,{columns:X,rows:ce.tickets,loading:ce.loading,skeletonRows:4,ariaLabel:u.tableLabel,pagination:Oe,empty:/* @__PURE__ */ p(O,{variant:`table`,icon:`message-square`,title:De?u.empty:u.emptyUnfiltered})})]})}var Je=3e4,Ye=e(null);function Xe(){let e=n(Ye);if(!e)throw Error(`Support components and hooks must be used inside <SupportProvider>.`);return e}function Ze(){return Xe().client}function Qe(){return Xe().timeZone}function $e(){return Xe().renderTime??null}function $(e,t){let n=Xe().labels?.[e];return a(()=>n?{...t,...n}:t,[n,t])}function et(e,n,i=!0){let[a,c]=s({data:null,loading:i,error:null}),[l,u]=s(0),d=o(e);d.current=e;let f=o(n);r(()=>{let e=f.current!==n;if(f.current=n,!i){c({data:null,loading:!1,error:null});return}let t=!0;return c(t=>({data:e?null:t.data,loading:!0,error:null})),d.current(l>0).then(e=>t&&c({data:e,loading:!1,error:null}),e=>t&&c(t=>({...t,loading:!1,error:e}))),()=>{t=!1}},[n,i,l]);let p=t(()=>u(e=>e+1),[]),m=t(e=>c(t=>({...t,data:typeof e==`function`?e(t.data):e})),[]);return{...a,reload:p,setData:m}}function tt(){let{loadConfig:e}=Xe(),{data:t,loading:n,error:r,reload:i}=et(e,`config`);return{config:t,loading:n,error:r,reload:i}}function nt(e={}){let t=Ze(),{status:n,search:r,page:i,pageSize:a}=e,{data:o,loading:s,error:c,reload:l}=et(()=>t.listTickets({status:n,search:r,page:i,pageSize:a}),JSON.stringify([`tickets`,n??null,r??null,i??null,a??null]));return{tickets:o?.items??[],totalCount:o?.totalCount??0,totalPages:o?.totalPages??0,loading:s,error:c,reload:l}}function rt(){let e=Ze(),{data:t,loading:n,error:r,reload:i}=et(()=>e.getTicketCounts(),`ticket-counts`);return{counts:t,loading:n,error:r,reload:i}}function it(e){let n=Ze(),{data:i,loading:a,error:s,reload:c,setData:l}=et(()=>n.getTicket(e),e??``,!!e),u=o(0),d=o(e);d.current=e;let f=t(async e=>{u.current+=1;try{let t=await e();return l(t),t}finally{--u.current}},[l]),p=t(async()=>{if(u.current>0)return;let t=e;try{let e=await n.getTicket(t);if(d.current!==t)return;l(t=>t?Date.parse(e.updatedDateTimeUtc)>=Date.parse(t.updatedDateTimeUtc)?e:t:e)}catch{}},[n,e,l]);return r(()=>{if(!e)return;let t=null,n=()=>{t===null&&(t=setInterval(p,Je))},r=()=>{t!==null&&clearInterval(t),t=null},i=()=>{document.hidden?r():(p(),n())};return document.addEventListener(`visibilitychange`,i),document.hidden||n(),()=>{r(),document.removeEventListener(`visibilitychange`,i)}},[e,p]),{ticket:i,loading:a,error:s,reload:c,reply:t(t=>f(()=>n.reply(e,t)),[f,n,e]),reopen:t(()=>f(()=>n.reopen(e)),[f,n,e]),cancel:t(()=>f(()=>n.cancel(e)),[f,n,e]),rate:t(t=>f(()=>n.rate(e,t)),[f,n,e])}}function at({baseUrl:e,http:t}){if(typeof e!=`string`||e.trim()===``)throw TypeError(`createHelpCentreClient needs a baseUrl.`);if(typeof t?.get!=`function`)throw TypeError(`createHelpCentreClient needs an http client with get().`);let n=e.trim().replace(/\/+$/,``),r=async e=>{try{return(await e()).data}catch(e){throw await K(e)}};return{settings:e=>r(()=>t.get(`${n}/settings`,{signal:e?.signal})),list:({page:e,pageSize:i}={},a)=>{let o=new URLSearchParams;e!=null&&o.set(`page`,String(e)),i!=null&&o.set(`pageSize`,String(i));let s=o.toString();return r(()=>t.get(`${n}/articles${s?`?${s}`:``}`,{signal:a?.signal}))},get:(e,i)=>r(()=>t.get(`${n}/articles/${encodeURIComponent(e)}`,{signal:i?.signal})),search:(e,i)=>r(()=>t.get(`${n}/search?${new URLSearchParams({q:String(e??``)}).toString()}`,{signal:i?.signal}))}}function ot({iso:e,className:t}){let n=$e(),r=Qe();return n?n(e):/* @__PURE__ */ p(`time`,{dateTime:e,className:t,children:l(e,{timeZone:r})})}var st={heading:`Help centre`,searchPlaceholder:`Search help articles`,searchLabel:`Search help articles`,tableLabel:`Help articles`,columnArticle:`Article`,columnUpdated:`Last updated`,listError:`We could not load the help articles.`,settingsError:`We could not load the help centre.`,retry:`Try again`,emptyTitle:`No articles yet`,emptyText:`Help articles from the support team show here.`,noMatchTitle:`No articles match`,noMatchText:`Try other words.`},ct={back:`Back to help`,published:`Published {date}`,updated:`Updated {date}`,loadError:`We could not load this article.`,notFoundTitle:`This article could not be found.`,retry:`Try again`},lt=`article_not_found`,ut=`{date}`;function dt({template:e,iso:t}){let n=e.indexOf(ut);return n===-1?/* @__PURE__ */ m(f,{children:[e,` `,/* @__PURE__ */ p(ot,{iso:t})]}):/* @__PURE__ */ m(f,{children:[e.slice(0,n),/* @__PURE__ */ p(ot,{iso:t}),e.slice(n+6)]})}function ft({client:e,slug:n,onBack:i}){let a=$(`helpArticle`,ct),c=$(`shared`,X),[l,u]=s({article:null,loading:!0,error:null}),d=o(null),f=t(()=>{d.current?.abort();let t=new AbortController;d.current=t,u({article:null,loading:!0,error:null}),e.get(n,{signal:t.signal}).then(e=>{t.signal.aborted||u({article:e,loading:!1,error:null})},e=>{t.signal.aborted||u({article:null,loading:!1,error:e})})},[e,n]);r(()=>(f(),()=>d.current?.abort()),[f]);let{article:h,loading:_,error:v}=l,b=v?.code===lt;return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3 min-w-0`,"aria-busy":_||void 0,children:[i&&/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,leftIcon:`arrow-left`,onClick:i,className:`align-self-start`,children:a.back}),_&&/* @__PURE__ */ p(ee,{height:160}),b&&/* @__PURE__ */ p(O,{variant:`card`,icon:`search`,title:a.notFoundTitle}),v&&!b&&/* @__PURE__ */ m(g,{tone:`danger`,children:[Z(v,a.loadError,c.offline),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:f,children:a.retry})]}),h&&/* @__PURE__ */ m(`article`,{className:`d-flex flex-column gap-3`,children:[/* @__PURE__ */ p(`h2`,{className:`h4 mb-0`,children:h.title}),/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap gap-3 wui-text-sm text-body-secondary`,children:[h.publishedDateTimeUtc!=null&&/* @__PURE__ */ p(`span`,{children:/* @__PURE__ */ p(dt,{template:a.published,iso:h.publishedDateTimeUtc})}),/* @__PURE__ */ p(`span`,{children:/* @__PURE__ */ p(dt,{template:a.updated,iso:h.updatedDateTimeUtc})})]}),/* @__PURE__ */ p(F,{value:h.bodyMarkdown})]})]})}var pt=10,mt=300,ht=2;function gt(){let e=o(null),n=t(()=>{e.current?.abort(),e.current=null},[]);r(()=>n,[n]);let i=t((t,n,r)=>{e.current?.abort();let i=new AbortController;e.current=i,t(i.signal).then(e=>{i.signal.aborted||n(e)},e=>{i.signal.aborted||r(e)})},[]);return a(()=>({run:i,cancel:n}),[i,n])}function _t(e){let[n,i]=s({data:null,loading:!0,error:null}),[a,o]=s({page:1,pageSize:pt}),[c,l]=s({data:null,loading:!0,error:null}),[u,d]=s(``),[f,p]=s({term:``,data:[],loading:!1,error:null}),m=He(u.trim(),mt),h=gt(),g=gt(),_=gt(),{page:v,pageSize:y}=a,b=n.data?.searchAvailable===!0,x=b&&m.length>=ht,S=c.data?.totalPages??0,C=t(()=>{i(e=>({...e,loading:!0,error:null})),h.run(t=>e.settings({signal:t}),e=>i({data:e,loading:!1,error:null}),e=>i({data:null,loading:!1,error:e}))},[e,h]),w=t(()=>{l(e=>({...e,loading:!0,error:null})),g.run(t=>e.list({page:v,pageSize:y},{signal:t}),e=>l({data:e,loading:!1,error:null}),e=>l(t=>({...t,loading:!1,error:e})))},[e,v,y,g]),T=t(()=>{p(e=>({term:m,data:e.data,loading:!0,error:null})),_.run(t=>e.search(m,{signal:t}),e=>p({term:m,data:e,loading:!1,error:null}),e=>p({term:m,data:[],loading:!1,error:e}))},[e,m,_]);r(()=>{C()},[C]),r(()=>{w()},[w]),r(()=>{x?T():_.cancel()},[T,x,_]);let E=t(e=>{d(e),e.trim()===``&&_.cancel()},[_]);r(()=>{S>0&&v>S&&o(e=>({...e,page:S}))},[v,S]);let D=t(e=>o(t=>({...t,page:e})),[]),O=t(e=>o({page:1,pageSize:e}),[]);return{settings:{data:n.data,loading:n.loading,error:n.error,reload:C},articles:{items:c.data?.items??[],page:v,pageSize:y,totalCount:c.data?.totalCount??0,totalPages:S,loading:c.loading,error:c.error,setPage:D,setPageSize:O,reload:w},search:{enabled:b,query:u,setQuery:E,active:x,results:f.data,loading:x&&(f.loading||f.term!==m),error:x?f.error:null,reload:T}}}function vt({client:e,onOpen:t,linkTo:n}){let r=$(`helpCentre`,st),i=$(`shared`,X),{settings:a,articles:o,search:s}=_t(e),c=s.active,l=c?s.results:o.items,u=c?s.loading:o.loading,d=c?s.error:o.error,f=c?s.reload:o.reload,h=(e,n)=>{t&&(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),t(n)))},_=[{key:`title`,label:r.columnArticle,render:e=>/* @__PURE__ */ m(`div`,{className:`d-flex flex-column min-w-0`,children:[n?/* @__PURE__ */ p(P,{href:n(e.slug),animation:`none`,className:`fw-semibold text-break`,onClick:t=>h(t,e.slug),children:e.title}):/* @__PURE__ */ p(y,{variant:`link`,size:`sm`,className:`fw-semibold text-break text-start p-0`,onClick:()=>t?.(e.slug),children:e.title}),/* @__PURE__ */ p(`span`,{className:`wui-text-sm text-body-secondary`,children:e.summary})]})},{key:`updatedDateTimeUtc`,label:r.columnUpdated,cellClassName:`wui-text-sm text-body-secondary text-nowrap`,render:e=>/* @__PURE__ */ p(ot,{iso:e.updatedDateTimeUtc})}],v={page:o.page,totalPages:Math.max(1,o.totalPages),pageSize:o.pageSize,total:o.totalCount,setPage:o.setPage,setPageSize:o.setPageSize};return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3 min-w-0`,"aria-labelledby":`help-centre-title`,children:[/* @__PURE__ */ p(`h2`,{id:`help-centre-title`,className:`h5 mb-0`,children:r.heading}),a.error&&/* @__PURE__ */ m(g,{tone:`warning`,children:[Z(a.error,r.settingsError,i.offline),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:a.reload,children:r.retry})]}),s.enabled&&/* @__PURE__ */ p(z,{value:s.query,onChange:s.setQuery,placeholder:r.searchPlaceholder,ariaLabel:r.searchLabel}),d&&/* @__PURE__ */ m(g,{tone:`danger`,children:[Z(d,r.listError,i.offline),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:f,children:r.retry})]}),/* @__PURE__ */ p(E,{columns:_,rows:l,loading:u,skeletonRows:4,ariaLabel:r.tableLabel,stackOnMobile:!0,pagination:c?void 0:v,empty:c?/* @__PURE__ */ p(O,{variant:`table`,icon:`search`,title:r.noMatchTitle,description:r.noMatchText}):/* @__PURE__ */ p(O,{variant:`table`,icon:`message-square`,title:r.emptyTitle,description:r.emptyText})})]})}var yt=80;function bt(e,t){let n=Math.min(t,yt),r=(e??``).split(/\r?\n/).find(e=>e.trim()!==``);if(r===void 0)return``;let i=r.replace(/\s+/g,` `).trim();if(i.length<=n)return i;let a=i.slice(0,n+1).lastIndexOf(` `);return(a>0?i.slice(0,a):i.slice(0,n)).replace(/[ ,;:.-]+$/,``)}function xt({id:e,label:t=`Attachments`,files:n,onChange:r,config:i,error:a}){let o=i?.maxAttachmentBytes??0,s=o>0?Math.max(.1,Math.round(o/1048576*10)/10):0;return/* @__PURE__ */ p(k,{id:e,label:t,optional:!0,multiple:!0,value:n,onChange:r,accept:Ee(i),maxSizeMb:s,validate:!1,error:a||void 0})}var St={title:`These may already answer your question`};function Ct({items:e}){let t=$(`suggestedAnswers`,St);return e.length===0?null:/* @__PURE__ */ p(b,{variant:`filled`,padding:`sm`,title:t.title,children:/* @__PURE__ */ p(`ul`,{className:`list-unstyled mb-0 d-flex flex-column gap-2`,children:e.map(e=>/* @__PURE__ */ m(`li`,{children:[/* @__PURE__ */ p(`div`,{className:`fw-semibold`,children:e.title}),/* @__PURE__ */ p(`div`,{className:`small text-body-secondary`,children:e.summary})]},e.title))})})}var wt={bodyRequired:`Enter what happened.`,sendFailed:`Your ticket did not send. Please try again.`,messageLabel:`Message`,messagePlaceholder:`What happened, and what did you expect to happen?`,messageHint:`You can paste an image into the message.`,subjectLabel:`Subject`,subjectPlaceholder:`A short summary`,subjectHint:`Filled in from your message. You can change it.`,categoryLabel:`Category (optional)`,categoryPlaceholder:`Choose a category`,categoryHint:`Not sure? Leave it empty and we will sort it.`},Tt=500,Et=3,Dt=5;function Ot(e,t){return t&&e.includes(t)?t:``}function kt({id:e,config:t,defaultCategory:n,initialValues:i,onValuesChange:a,extraFiles:o=[],onSubmit:c,onBusyChange:l,children:u}){let d=$(`ticketForm`,wt),f=$(`shared`,X),h=t?.categories??[],_=t?.subjectMaxLength??1/0,[v,y]=s(()=>i?.category??Ot(h,n)),[b,x]=s(i?.body??``),[S,C]=s(()=>i?.subject||bt(i?.body??``,_)),[w,T]=s(()=>{let e=(i?.subject??``).trim();return e!==``&&e!==bt(i?.body??``,_)}),[E,D]=s(i?.files??[]),[O,k]=s({}),[A,j]=s(``),M=Ze(),[P,F]=s(``),[I,L]=s([]),R=He(S.trim(),Tt);r(()=>{a?.({category:v,subject:S,body:b,files:E})},[v,S,b,E,a]),r(()=>{F(R)},[R]),r(()=>{if(P.length<Et){L([]);return}let e=!0,t=new AbortController;return L([]),M.getSuggestions(P,{signal:t.signal}).then(t=>{e&&L(Array.isArray(t)?t.slice(0,Dt):[])},()=>{e&&L([])}),()=>{e=!1,t.abort()}},[M,P]);let z=e=>{D(e),k(n=>({...n,files:Oe([...o,...e],t,f)??void 0}))},ee=e=>{let t=Me(e);t.length>0&&z([...E,...t])},V=e=>{let t=e.target.value;x(t),w||C(bt(t,_)),O.body&&k(e=>({...e,body:t.trim()?void 0:d.bodyRequired}))},te=e=>{let t=e.target.value;C(t),T(t.trim()!==``)};function H(){let e={};b.trim()||(e.body=d.bodyRequired);let n=Oe([...o,...E],t,f);return n&&(e.files=n),k(e),Object.keys(e).length===0}async function ne(e){if(e.preventDefault(),j(``),H()){l?.(!0);try{await c({category:v,subject:S.trim()||bt(b,_),body:b.trim(),files:E})}catch(e){j(Z(e,d.sendFailed,f.offline))}finally{l?.(!1)}}}return/* @__PURE__ */ m(`form`,{id:e,onSubmit:ne,noValidate:!0,className:`d-flex flex-column gap-3`,children:[A&&/* @__PURE__ */ p(g,{tone:`danger`,children:A}),/* @__PURE__ */ p(U,{id:`${e}-body`,label:d.messageLabel,required:!0,rows:6,maxLength:t?.bodyMaxLength,showCount:!0,placeholder:d.messagePlaceholder,value:b,onChange:V,onPaste:ee,helperText:d.messageHint,error:O.body}),/* @__PURE__ */ p(N,{id:`${e}-subject`,label:d.subjectLabel,maxLength:t?.subjectMaxLength,showCount:!0,placeholder:d.subjectPlaceholder,helperText:d.subjectHint,value:S,onChange:te,onBlur:()=>F(S.trim())}),/* @__PURE__ */ p(Ct,{items:I}),/* @__PURE__ */ p(B,{id:`${e}-category`,label:d.categoryLabel,value:v,onChange:y,options:h.map(e=>({value:e,label:e})),placeholder:d.categoryPlaceholder,helperText:d.categoryHint,error:O.category}),u,/* @__PURE__ */ p(xt,{id:`${e}-files`,files:E,onChange:z,config:t,error:O.files})]})}var At={captureEmpty:`The page capture came back empty.`,retake:`Retake`,removeScreenshot:`Remove screenshot`,addScreenshot:`Add a screenshot`,screenshotNote:`Only what is on your screen now. You can remove it before sending.`,screenshotFailed:`We could not take a screenshot of this page. You can attach an image instead, or send the report without one.`,screenshotTitle:`Screenshot`,screenshotLabel:`Screenshot of the page you were on`,viewTicket:`View ticket`,close:`Close`,cancel:`Cancel`,submit:`Submit`,takingScreenshot:`Taking a screenshot`,title:`Report an issue`,subtitle:`Tell us what went wrong. You can add a screenshot of this page if it helps.`,confirmDiscard:`Discard this report?`,createdTitle:`Ticket {number} is with the support team`,createdText:`We reply by email. You can follow the ticket on your support page.`,createdTextNoEmail:`You can follow the ticket and our reply on your support page.`,configError:`We could not load the support settings.`,loading:`Loading the form.`},jt=`supportCapture`,Mt={zIndex:`var(--wui-z-fixed)`,bottom:0,insetInlineEnd:0},Nt={zIndex:`var(--wui-z-fixed)`},Pt={maxWidth:`20rem`},Ft=e=>e.dataset?.[jt]===`exclude`||e.matches?.(`.modal-backdrop`)?!1:!(e.matches?.(`.modal`)&&e.querySelector?.(`[data-support-capture="exclude"]`)),It=()=>new Promise(e=>requestAnimationFrame(()=>e()));async function Lt(e){let t=await re(document.body,{filter:Ft,pixelRatio:Math.min(window.devicePixelRatio||1,2),style:{overflow:`visible`,paddingRight:`0px`}});if(!t)throw Error(e);return new File([t],`screenshot.png`,{type:`image/png`})}function Rt({t:e,file:t,failed:n,disabled:i,hintId:a,controlRef:o,onAdd:c,onRemove:l}){let[u,d]=s(null);return r(()=>{if(!t)return;let e=URL.createObjectURL(t);return d(e),()=>URL.revokeObjectURL(e)},[t]),/* @__PURE__ */ m(`div`,{className:`d-flex flex-column gap-2`,children:[/* @__PURE__ */ p(`span`,{className:`wui-text-sm fw-semibold`,children:e.screenshotTitle}),t&&u&&/* @__PURE__ */ p(`img`,{src:u,alt:e.screenshotLabel,className:`d-block w-100 border rounded`,style:Pt}),/* @__PURE__ */ p(`div`,{ref:o,className:`d-flex flex-wrap gap-2`,children:t?/* @__PURE__ */ m(f,{children:[/* @__PURE__ */ p(y,{variant:`outline`,size:`sm`,leftIcon:`refresh-cw`,onClick:c,disabled:i,"aria-describedby":a,children:e.retake}),/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,leftIcon:`x`,onClick:l,disabled:i,children:e.removeScreenshot})]}):/* @__PURE__ */ p(y,{variant:`outline`,size:`sm`,leftIcon:`camera`,onClick:c,disabled:i,"aria-describedby":a,children:e.addScreenshot})}),/* @__PURE__ */ p(`span`,{id:a,className:`wui-text-sm text-body-secondary`,children:e.screenshotNote}),n&&/* @__PURE__ */ p(g,{tone:`info`,children:e.screenshotFailed})]})}function zt({label:e=`Report an issue`,floating:t=!1,compact:n=!1,defaultCategory:a=`Bug report`,appVersion:c,getTicketHref:l,onOpenTicket:u,onCreated:d,className:h,style:_}){let v=$(`reportIssue`,At),b=$(`shared`,X),x=Ze(),{config:S,error:C}=tt(),w=`support-report-${i().replace(/[^a-zA-Z0-9-]/g,``)}`,[T,E]=s(!1),[D,O]=s(!1),[k,j]=s(null),[M,N]=s(!1),[P,F]=s(!1),[I,R]=s(null),[z,B]=s(null),ee=o(null),V=o(!1);r(()=>{!D&&V.current&&(V.current=!1,ee.current?.querySelector(`button`)?.focus())},[D]);function te(){R(null),j(null),N(!1),B(null),E(!0)}async function H(){O(!0),N(!1),await It(),await It();try{j(await Lt(v.captureEmpty))}catch{j(null),N(!0)}finally{V.current=!0,O(!1)}}let U=()=>{P||(E(!1),j(null),N(!1),R(null),B(null))};async function ne(e){let t=await x.createTicket({...e,pageUrl:window.location.href,userAgent:navigator.userAgent,appVersion:c,screenshots:k?[k]:[]});R(t),j(null),d?.(t)}let re=!I&&(!!k||!!z&&(z.subject.trim()!==``||z.body.trim()!==``||z.files.length>0)),W=I&&l?l(I.id):void 0,G=I&&(W||u)?/* @__PURE__ */ p(y,{href:W,onClick:W?void 0:()=>{E(!1),R(null),u(I)},children:v.viewTicket}):null,ie=I?/* @__PURE__ */ m(`div`,{className:`d-flex justify-content-end gap-2 w-100`,children:[/* @__PURE__ */ p(y,{variant:`soft`,onClick:U,children:v.close}),G]}):/* @__PURE__ */ m(`div`,{className:`d-flex justify-content-end gap-2 w-100`,children:[/* @__PURE__ */ p(y,{variant:`soft`,onClick:U,disabled:P,children:v.cancel}),/* @__PURE__ */ p(y,{type:`submit`,form:w,loading:P,disabled:!S,children:v.submit})]}),K=n?/* @__PURE__ */ p(A,{icon:`bug`,label:e,order:`secondary`,size:`sm`,variant:`soft`,stacked:t,className:t?h:void 0,style:t?_:void 0,disabled:D,onClick:te,"aria-haspopup":`dialog`}):/* @__PURE__ */ p(y,{leftIcon:`bug`,variant:t?`solid`:`outline`,disabled:D,onClick:te,"aria-haspopup":`dialog`,children:e});return/* @__PURE__ */ m(f,{children:[t&&n?K:/* @__PURE__ */ p(`span`,{"data-support-capture":`exclude`,className:[t?`position-fixed m-3`:`d-inline-block`,h].filter(Boolean).join(` `),style:t?{...Mt,..._}:_,children:K}),D&&/* @__PURE__ */ m(`div`,{"data-support-capture":`exclude`,role:`status`,className:`position-fixed top-0 start-50 translate-middle-x mt-3 d-flex align-items-center gap-2 px-3 py-2 bg-body border rounded-pill shadow-sm wui-text-sm`,style:Nt,children:[/* @__PURE__ */ p(`span`,{className:`spinner-border spinner-border-sm`,"aria-hidden":`true`}),v.takingScreenshot]}),/* @__PURE__ */ p(L,{open:T,size:`lg`,title:v.title,subtitle:v.subtitle,headerIcon:`bug`,confirmDiscard:v.confirmDiscard,dirty:re&&!P,onClose:U,footer:ie,"data-support-capture":`exclude`,children:I?/* @__PURE__ */ p(g,{tone:`success`,role:`status`,title:Y(v.createdTitle,{number:I.number}),children:S?.emailEnabled===!1?v.createdTextNoEmail:v.createdText}):S?/* @__PURE__ */ p(kt,{id:w,config:S,defaultCategory:a,initialValues:z,onValuesChange:B,extraFiles:k?[k]:[],onSubmit:ne,onBusyChange:F,children:/* @__PURE__ */ p(Rt,{t:v,file:k,failed:M,disabled:P||D,hintId:`${w}-screenshot-hint`,controlRef:ee,onAdd:H,onRemove:()=>j(null)})}):/* @__PURE__ */ p(g,{tone:C?`danger`:`info`,children:C?Z(C,v.configError,b.offline):v.loading})})]})}var Bt={title:`New ticket`,subtitle:`Tell us what you need. We reply by email and on this page.`,subtitleNoEmail:`Tell us what you need. We reply on this page.`,confirmDiscard:`Discard this ticket?`,cancel:`Cancel`,send:`Send ticket`};function Vt({open:e,onClose:t,onCreated:n,config:r,defaultCategory:a,appVersion:o,emailEnabled:c=!0}){let l=$(`newTicketModal`,Bt),u=Ze(),d=`support-new-${i().replace(/[^a-zA-Z0-9-]/g,``)}`,[f,h]=s(!1),[g,_]=s(null),v=!!g&&(g.subject.trim()!==``||g.body.trim()!==``||g.files.length>0);async function b(e){n(await u.createTicket({...e,userAgent:typeof navigator>`u`?void 0:navigator.userAgent,appVersion:o}))}return/* @__PURE__ */ p(L,{open:e,size:`lg`,title:l.title,subtitle:c===!1?l.subtitleNoEmail:l.subtitle,headerIcon:`message-square`,confirmDiscard:l.confirmDiscard,dirty:v&&!f,onClose:()=>{f||t()},footer:/* @__PURE__ */ m(`div`,{className:`d-flex justify-content-end gap-2 w-100`,children:[/* @__PURE__ */ p(y,{variant:`soft`,onClick:t,disabled:f,children:l.cancel}),/* @__PURE__ */ p(y,{type:`submit`,form:d,loading:f,children:l.send})]}),children:e&&/* @__PURE__ */ p(kt,{id:d,config:r,defaultCategory:a,onSubmit:b,onBusyChange:h,onValuesChange:_})})}var Ht={loading:`Loading {name}`,failed:`Could not load this file. Click to try again.`},Ut=6e4,Wt=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`application/pdf`];function Gt({attachment:e}){let t=$(`attachmentThumb`,Ht),n=Ze(),[r,i]=s(!1),[a,o]=s(!1);async function c(){i(!0),o(!1);let t=Wt.includes(e.contentType)?window.open(``,`_blank`):null;t&&(t.opener=null);try{let r=await n.fetchAttachment(e.id),i=URL.createObjectURL(r);if(setTimeout(()=>URL.revokeObjectURL(i),Ut),t)t.location.href=i;else{let t=document.createElement(`a`);t.href=i,t.download=e.fileName,t.click()}}catch{t?.close(),o(!0)}finally{i(!1)}}let l=Number.isFinite(e.sizeBytes)?u(e.sizeBytes):`-`;return/* @__PURE__ */ m(f,{children:[/* @__PURE__ */ p(x,{leadingIcon:a?`x-circle`:`paperclip`,label:r?/* @__PURE__ */ m(f,{children:[/* @__PURE__ */ p(V,{size:`sm`,label:Y(t.loading,{name:e.fileName})}),` `,e.fileName]}):e.fileName,onClick:c,disabled:r,"aria-busy":r||void 0,title:`${e.fileName}, ${l}`}),a&&/* @__PURE__ */ p(`span`,{role:`status`,className:`wui-text-xs text-danger align-self-center`,children:t.failed})]})}var Kt={conversation:`Conversation`,you:`You`,supportTeam:`Support team`,supportBadge:`Support`},qt={whiteSpace:`pre-wrap`,overflowWrap:`anywhere`};function Jt({messages:e}){let t=$(`messageThread`,Kt);return/* @__PURE__ */ p(`ol`,{className:`list-unstyled d-flex flex-column gap-3 mb-0`,"aria-label":t.conversation,children:e.map(e=>{let n=/* @__PURE__ */ p(ot,{iso:e.createdDateTimeUtc,className:`wui-text-xs text-body-secondary text-nowrap`});if(e.authorKind===`System`)return/* @__PURE__ */ m(`li`,{className:`text-center wui-text-xs text-body-secondary`,"data-author":`system`,children:[/* @__PURE__ */ p(`span`,{className:`d-block`,children:e.body}),n]},e.id);let r=e.authorKind===`Customer`,i=e.authorName||(r?t.you:t.supportTeam);return/* @__PURE__ */ m(`li`,{className:`d-flex align-items-start gap-2${r?` flex-row-reverse`:``}`,"data-author":r?`customer`:`agent`,children:[/* @__PURE__ */ p(_,{name:i,size:32,tone:r?`neutral`:`primary`}),/* @__PURE__ */ m(b,{className:`flex-grow-1 border`,padding:`sm`,variant:r?`flat`:`accent`,style:{minWidth:0},children:[/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2 mb-2`,children:[/* @__PURE__ */ m(`span`,{className:`d-inline-flex flex-wrap align-items-center gap-2 fw-semibold wui-text-sm text-break`,children:[i,!r&&/* @__PURE__ */ p(v,{tone:`primary`,children:t.supportBadge})]}),n]}),/* @__PURE__ */ p(`div`,{className:`wui-text-sm`,style:qt,children:e.body}),e.attachments?.length>0&&/* @__PURE__ */ p(`div`,{className:`d-flex flex-wrap gap-2 mt-2`,children:e.attachments.map(e=>/* @__PURE__ */ p(Gt,{attachment:e},e.id))})]})]},e.id)})})}var Yt={solved:`You told us this solved your problem.`,notSolved:`You told us this did not solve your problem.`,sendFailed:`Your rating did not send. Please try again.`,commentLabel:`Anything to add?`,commentHint:`Optional. Your comment goes to the support team.`,yes:`Yes, it is solved`,no:`No, it is not`,heading:`Did this solve your problem?`,yourComment:`Your comment:`};function Xt({satisfaction:e,comment:t,canRate:n=!1,commentMaxLength:r,onRate:a}){let o=$(`ratingPanel`,Yt),c=$(`shared`,X),l=i(),[u,d]=s(``),[f,h]=s(null),[_,v]=s(``);if(e)return/* @__PURE__ */ m(g,{tone:e===`Satisfied`?`success`:`info`,role:`status`,children:[e===`Satisfied`?o.solved:o.notSolved,t?/* @__PURE__ */ m(`span`,{className:`d-block mt-1`,children:[o.yourComment,` `,t]}):null]});if(!n)return null;async function x(e){v(``),h(e);try{await a({satisfaction:e,comment:u})}catch(e){v(Z(e,o.sendFailed,c.offline))}finally{h(null)}}return/* @__PURE__ */ p(b,{padding:`sm`,className:`border`,title:o.heading,children:/* @__PURE__ */ m(`div`,{className:`d-flex flex-column gap-2`,children:[_&&/* @__PURE__ */ p(g,{tone:`danger`,children:_}),/* @__PURE__ */ p(U,{id:`${l}-comment`,label:o.commentLabel,rows:2,maxLength:r,value:u,onChange:e=>d(e.target.value),helperText:o.commentHint}),/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap gap-2`,children:[/* @__PURE__ */ p(y,{variant:`outline`,leftIcon:`check-circle`,loading:f===`Satisfied`,disabled:f!==null,onClick:()=>x(`Satisfied`),children:o.yes}),/* @__PURE__ */ p(y,{variant:`outline`,leftIcon:`x-circle`,loading:f===`Unsatisfied`,disabled:f!==null,onClick:()=>x(`Unsatisfied`),children:o.no})]})]})})}var Zt={emptyReply:`Write a message before you send it.`,sendFailed:`Your reply did not send. Please try again.`,replyLabel:`Your reply`,hintReopens:`Sending a reply reopens this ticket. You can paste an image into the message.`,hint:`You can paste an image into the message.`,attachedFiles:`Attached files`,removeFile:`Remove {name}`,attach:`Attach a file`,send:`Send reply`,formLabel:`Reply to this ticket`};function Qt({onSend:e,config:t,reopens:n=!1}){let r=$(`replyBox`,Zt),a=$(`shared`,X),o=i(),[c,l]=s(``),[u,d]=s([]),[f,_]=s(``),[v,b]=s(``),[C,w]=s(!1),T=e=>{let n=je(u,e,t,a);d(n.files),_(n.notice)},E=e=>{let n=u.filter((t,n)=>n!==e);d(n),_(Oe(n,t,a)??``)},D=e=>{let t=Me(e);t.length>0&&T(t)};async function O(n){n.preventDefault();let i=c.trim();if(!i){b(r.emptyReply);return}let o=Oe(u,t,a);if(o)_(o);else{b(``),w(!0);try{await e({body:i,files:u}),l(``),d([]),_(``)}catch(e){b(Z(e,r.sendFailed,a.offline))}finally{w(!1)}}}let k=v||f;return/* @__PURE__ */ m(`form`,{onSubmit:O,noValidate:!0,className:`d-flex flex-column gap-2 flex-grow-1 min-w-0`,"aria-label":r.formLabel,children:[k&&/* @__PURE__ */ p(g,{tone:`danger`,children:k}),/* @__PURE__ */ p(U,{id:`${o}-body`,label:r.replyLabel,rows:2,autoGrow:!0,maxLength:t?.bodyMaxLength,value:c,onChange:e=>{l(e.target.value),b(``)},onPaste:D,helperText:n?r.hintReopens:r.hint,required:!0}),u.length>0&&/* @__PURE__ */ p(S,{label:r.attachedFiles,children:u.map((e,t)=>/* @__PURE__ */ p(x,{leadingIcon:`paperclip`,label:e.name,removeLabel:Y(r.removeFile,{name:e.name}),onRemove:()=>E(t)},Ae(e)))}),/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2`,children:[/* @__PURE__ */ p(h,{iconVariant:`bulk`,icon:`paperclip`,label:r.attach,multiple:t?.maxAttachmentsPerMessage!==1,accept:Ee(t),onFiles:T}),/* @__PURE__ */ p(y,{type:`submit`,leftIcon:`send`,loading:C,children:r.send})]})]})}var $t={reopenFailed:`The ticket did not reopen. Please try again.`,withdrawFailed:`The request was not withdrawn. Please try again.`,back:`Back to tickets`,loadError:`We could not load this ticket.`,retry:`Try again`,fieldStatus:`Status`,fieldCategory:`Category`,fieldTicket:`Ticket`,fieldOpened:`Opened`,fieldUpdated:`Last update`,openedLabel:`Opened`,summaryLabel:`Ticket summary`,detailsLabel:`Ticket details`,detailsTitle:`Ticket details`,timeZoneNote:`Times are shown in {zone}.`,mergedText:`This ticket was merged into {number}. The conversation carries on there.`,openMerged:`Open {number}`,resolvedHint:`If you still need help, reopen the ticket or send a reply.`,waitingHint:`We need your answer to carry on. Reply below and the ticket goes back to our team.`,openHint:`Our team marks this resolved once your question is answered. Replying reopens it.`,reopen:`Reopen ticket`,withdraw:`Withdraw request`,withdrawTitle:`Withdraw this request?`,withdrawMessage:`Our team will stop working on this ticket. You can open a new ticket later if you still need help.`,withdrawConfirm:`Withdraw request`,withdrawCancel:`Keep request`,merged:`Merged into this ticket`};function en({ticketId:e,onBack:t,onChanged:n,onOpenTicket:r}){let{config:i}=tt(),a=$(`ticketDetail`,$t),o=$(`shared`,X),c=Qe(),l=$e(),{ticket:u,loading:f,error:h,reload:_,reply:v,reopen:x,cancel:S,rate:C}=it(e),[T,E]=s(!1),[O,k]=s(!1),[A,N]=s(!1),[P,F]=s(``),I=async e=>{let t=await e();return n?.(),t};async function L(){F(``),E(!0);try{await I(x)}catch(e){F(Z(e,a.reopenFailed,o.offline))}finally{E(!1)}}async function R(){F(``),N(!0);try{await I(S)}catch(e){F(Z(e,a.withdrawFailed,o.offline))}finally{N(!1),k(!1)}}let z=/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,leftIcon:`arrow-left`,onClick:t,className:`align-self-start`,children:a.back});if(!u)return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3`,"aria-busy":f||void 0,children:[z,h?/* @__PURE__ */ m(g,{tone:`danger`,children:[Z(h,a.loadError,o.offline),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:_,children:a.retry})]}):/* @__PURE__ */ p(ee,{height:160})]});let B=Pe(u.status),V=[{key:`status`,label:a.fieldStatus,value:u.statusLabel?/* @__PURE__ */ p(te,{label:u.statusLabel,tone:B}):`-`},{key:`category`,label:a.fieldCategory,value:u.category||`-`},{key:`ticket`,label:a.fieldTicket,value:u.number},{key:`opened`,label:a.fieldOpened,value:/* @__PURE__ */ p(ot,{iso:u.createdDateTimeUtc})},{key:`updated`,label:a.fieldUpdated,value:/* @__PURE__ */ p(ot,{iso:u.updatedDateTimeUtc})}];return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3`,"aria-labelledby":`support-ticket-${u.id}`,children:[z,/* @__PURE__ */ m(`div`,{className:`row g-3`,children:[/* @__PURE__ */ m(`div`,{className:`col-12 col-lg-8 d-flex flex-column gap-3`,children:[/* @__PURE__ */ m(`header`,{className:`d-flex flex-column gap-2`,children:[/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap align-items-center gap-2`,children:[/* @__PURE__ */ p(`h2`,{id:`support-ticket-${u.id}`,className:`h5 mb-0 text-break`,children:u.subject}),u.statusLabel&&/* @__PURE__ */ p(te,{label:u.statusLabel,tone:B})]}),/* @__PURE__ */ m(`ul`,{className:`list-unstyled d-flex flex-wrap gap-3 mb-0 wui-text-sm text-body-secondary`,"aria-label":a.summaryLabel,children:[u.number&&/* @__PURE__ */ m(`li`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ p(M,{variant:`bulk`,name:`receipt-text`,size:16}),u.number]}),u.category&&/* @__PURE__ */ m(`li`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ p(M,{variant:`bulk`,name:`folder-2`,size:16}),u.category]}),/* @__PURE__ */ m(`li`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ p(M,{variant:`bulk`,name:`calendar-1`,size:16}),a.openedLabel,` `,/* @__PURE__ */ p(ot,{iso:u.createdDateTimeUtc})]})]}),l===null&&/* @__PURE__ */ p(`p`,{className:`wui-text-xs text-body-secondary mb-0`,children:Y(a.timeZoneNote,{zone:d(c)})})]}),P&&/* @__PURE__ */ p(g,{tone:`danger`,children:P}),u.mergedInto&&/* @__PURE__ */ m(g,{tone:`info`,role:`status`,children:[Y(a.mergedText,{number:u.mergedInto.number}),` `,r&&/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:()=>r(u.mergedInto.id),children:Y(a.openMerged,{number:u.mergedInto.number})})]}),u.canReopen&&/* @__PURE__ */ p(g,{tone:`success`,role:`status`,children:a.resolvedHint}),u.status===`WaitingOnCustomer`&&/* @__PURE__ */ p(g,{tone:`warning`,role:`status`,children:a.waitingHint}),!u.canReopen&&/* @__PURE__ */ p(`p`,{className:`wui-text-sm text-body-secondary mb-0`,children:a.openHint}),u.canReopen&&/* @__PURE__ */ p(y,{variant:`soft`,leftIcon:`history`,loading:T,onClick:L,className:`align-self-start`,children:a.reopen}),u.canCancel&&/* @__PURE__ */ p(y,{variant:`soft`,onClick:()=>k(!0),className:`align-self-start`,children:a.withdraw}),/* @__PURE__ */ p(w,{open:O,title:a.withdrawTitle,description:a.withdrawMessage,confirmLabel:a.withdrawConfirm,cancelLabel:a.withdrawCancel,tone:`danger`,loading:A,onConfirm:R,onClose:()=>k(!1)}),/* @__PURE__ */ p(Xt,{satisfaction:u.satisfaction,comment:u.satisfactionComment,canRate:u.canRate,commentMaxLength:i?.satisfactionCommentMaxLength,onRate:e=>I(()=>C(e))}),/* @__PURE__ */ p(Jt,{messages:u.messages??[]}),u.mergedTickets?.length>0&&/* @__PURE__ */ m(`section`,{"aria-labelledby":`support-merged-${u.id}`,className:`d-flex flex-column gap-1`,children:[/* @__PURE__ */ p(`h3`,{id:`support-merged-${u.id}`,className:`h6 mb-0`,children:a.merged}),/* @__PURE__ */ p(`ul`,{className:`list-unstyled d-flex flex-column gap-1 mb-0 wui-text-sm`,children:u.mergedTickets.map(e=>/* @__PURE__ */ p(`li`,{children:r?/* @__PURE__ */ m(y,{variant:`ghost`,size:`sm`,onClick:()=>r(e.id),children:[e.number,`: `,e.subject]}):`${e.number}: ${e.subject}`},e.id))})]}),!u.mergedInto&&/* @__PURE__ */ p(j,{sticky:!0,align:`start`,children:/* @__PURE__ */ p(Qt,{config:i,reopens:u.canReopen,onSend:e=>I(()=>v(e))})})]}),/* @__PURE__ */ p(`aside`,{"aria-label":a.detailsLabel,className:`col-12 col-lg-4`,children:/* @__PURE__ */ m(b,{padding:`sm`,className:`border`,children:[/* @__PURE__ */ p(`h3`,{className:`h6`,children:a.detailsTitle}),/* @__PURE__ */ p(D,{columns:1,items:V})]})})]})]})}var tn=`ticket`;function nn(){return typeof window>`u`?null:new URLSearchParams(window.location.search).get(tn)}function rn(e){if(typeof window>`u`)return e?`?${tn}=${encodeURIComponent(e)}`:`?`;let t=new URL(window.location.href);return e?t.searchParams.set(tn,e):t.searchParams.delete(tn),`${t.pathname}${t.search}${t.hash}`}function an(e){if(typeof window>`u`)return;let t=rn(e);t!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,t)}var on={tabAll:`All`,tabOpen:`Open`,tabNeedsReply:`Needs your reply`,tabResolved:`Resolved`,tabWithdrawn:`Withdrawn`,columnSubject:`Subject`,columnStatus:`Status`,columnMessages:`Messages`,columnLastUpdate:`Last update`,loadError:`We could not load your tickets.`,retry:`Try again`,statusSelect:`Status`,filterByStatus:`Filter tickets by status`,searchPlaceholder:`Search tickets`,searchLabel:`Search tickets`,tableLabel:`Support tickets`,actions:`Actions`,openTicket:`Open ticket {subject}`,emptyTitle:`No tickets yet`,emptyText:`When you raise a ticket, it shows here with its status.`,noMatchTitle:`No tickets match`,noMatchText:`Try another search or status.`},sn=[`tabs`,`select`,`none`];function cn({tickets:e,loading:t,error:n,onRetry:r,onOpen:i,status:a,onStatusChange:o,statusFilter:s=`tabs`,counts:c,search:l,onSearchChange:u,pagination:d}){let f=$(`ticketList`,on),_=$(`shared`,X);ne(`SupportCenter`,`statusFilter`,s,sn);let v=[{key:`all`,label:f.tabAll,countKey:`total`},{key:`Open`,label:f.tabOpen,countKey:`open`},{key:`NeedsReply`,label:f.tabNeedsReply,countKey:`needsReply`},{key:`Resolved`,label:f.tabResolved,countKey:`resolved`},{key:`Withdrawn`,label:f.tabWithdrawn,countKey:`withdrawn`}],b=v.map(({key:e,label:t,countKey:n})=>{let r=c?.[n];return{value:e,label:r==null?t:`${t} (${r})`}}),x=(e,t)=>{e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),i(t))},S=[{key:`subject`,label:f.columnSubject,render:e=>/* @__PURE__ */ m(`div`,{className:`d-flex flex-column`,style:{minWidth:0},children:[/* @__PURE__ */ p(P,{href:rn(e.id),animation:`none`,className:`fw-semibold text-break`,onClick:t=>x(t,e.id),children:e.subject}),/* @__PURE__ */ m(`span`,{className:`wui-text-xs text-body-secondary`,children:[e.number,`, `,e.category]})]})},{key:`status`,label:f.columnStatus,render:e=>e.statusLabel?/* @__PURE__ */ p(te,{label:e.statusLabel,tone:Pe(e.status)}):`-`},{key:`messageCount`,label:f.columnMessages,cellClassName:`wui-text-sm text-body-secondary`,render:e=>e.messageCount},{key:`updatedDateTimeUtc`,label:f.columnLastUpdate,cellClassName:`wui-text-sm text-body-secondary text-nowrap`,render:e=>/* @__PURE__ */ p(ot,{iso:e.updatedDateTimeUtc})}];return/* @__PURE__ */ m(`div`,{className:`d-flex flex-column gap-3`,children:[n&&/* @__PURE__ */ m(g,{tone:`danger`,children:[Z(n,f.loadError,_.offline),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:r,children:f.retry})]}),/* @__PURE__ */ m(`div`,{className:`d-flex flex-column flex-md-row gap-2 align-items-md-center justify-content-between`,children:[s===`none`?null:s===`select`?/* @__PURE__ */ p(B,{label:f.statusSelect,value:a,onChange:o,options:b,fieldClassName:`flex-shrink-0`}):/* @__PURE__ */ p(H,{tabs:v.map(({key:e,label:t,countKey:n})=>({key:e,label:t,count:c?.[n]})),value:a,onChange:o,ariaLabel:f.filterByStatus,overflow:`menu`,className:`flex-grow-1`}),/* @__PURE__ */ p(z,{value:l,onChange:u,placeholder:f.searchPlaceholder,ariaLabel:f.searchLabel})]}),/* @__PURE__ */ p(E,{columns:S,rows:e,loading:t,skeletonRows:4,ariaLabel:f.tableLabel,rowActionsLabel:f.actions,rowActions:e=>/* @__PURE__ */ p(h,{icon:`eye`,label:Y(f.openTicket,{subject:e.subject}),href:rn(e.id),onClick:t=>x(t,e.id)}),stickyActions:!0,stackOnMobile:!0,sourceCount:c?.total??0,pagination:d,empty:/* @__PURE__ */ p(O,{variant:`table`,icon:`message-square`,title:f.emptyTitle,description:f.emptyText}),emptyFiltered:/* @__PURE__ */ p(O,{variant:`table`,icon:`search`,title:f.noMatchTitle,description:f.noMatchText})})]})}var ln=300,un=10,dn={heading:`Your tickets`,newTicket:`New ticket`,configError:`We could not load the support settings.`,retry:`Try again`};function fn({initialTicketId:e,defaultCategory:t,appVersion:n,status:i,defaultStatus:a=`all`,onStatusChange:o,statusFilter:c=`tabs`}){let l=$(`supportCenter`,dn),u=$(`shared`,X),{config:d,error:f,reload:h}=tt(),[_,v]=s(a),b=i!==void 0,x=b?i:_,S=e=>{b||v(e),o?.(e)},[C,w]=s(``),T=He(C.trim(),ln),[E,D]=s(un),O=`${x}|${T}|${E}`,[k,A]=s({key:O,page:1}),j=k.key===O?k.page:1,M=e=>A({key:O,page:e}),N=nt({status:x===`all`?void 0:x,search:T||void 0,page:j,pageSize:E}),{counts:P,reload:F}=rt(),[I,L]=s(()=>e||nn()),[R,z]=s(!1),B=N.totalPages;r(()=>{B>0&&j>B&&A({key:O,page:B})},[B,j,O]);let ee=()=>{N.reload(),F()},V=e=>{L(e),an(e)};if(I)return/* @__PURE__ */ p(en,{ticketId:I,onBack:()=>V(null),onChanged:ee,onOpenTicket:V},I);let te={page:j,totalPages:Math.max(1,N.totalPages),pageSize:E,total:N.totalCount,setPage:M,setPageSize:D};return/* @__PURE__ */ m(`section`,{className:`d-flex flex-column gap-3 min-w-0`,"aria-labelledby":`support-center-title`,children:[/* @__PURE__ */ m(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2`,children:[/* @__PURE__ */ p(`h2`,{id:`support-center-title`,className:`h5 mb-0`,children:l.heading}),/* @__PURE__ */ p(y,{leftIcon:`plus`,onClick:()=>z(!0),disabled:!d,children:l.newTicket})]}),f&&/* @__PURE__ */ m(g,{tone:`warning`,children:[Z(f,l.configError,u.offline),` `,/* @__PURE__ */ p(y,{variant:`ghost`,size:`sm`,onClick:h,children:l.retry})]}),/* @__PURE__ */ p(cn,{tickets:N.tickets,loading:N.loading,error:N.error,onRetry:ee,onOpen:V,status:x,onStatusChange:S,statusFilter:c,counts:P,search:C,onSearchChange:w,pagination:te}),d&&/* @__PURE__ */ p(Vt,{open:R,onClose:()=>z(!1),config:d,emailEnabled:d.emailEnabled!==!1,defaultCategory:t,appVersion:n,onCreated:e=>{z(!1),ee(),V(e.id)}})]})}var pn={copyEmail:`Copy email`,emailCopied:`Email copied`,contactNamed:`Contact {name}`,contactSupport:`Contact support`},mn=e=>typeof e==`string`&&e.trim()!==``;function hn({className:e}){let t=$(`supportContact`,pn),{config:n}=tt();if(!n)return null;let r=mn(n.supportEmail),i=mn(n.supportPhone),a=mn(n.supportHours),o=[`d-flex flex-wrap align-items-center gap-2 wui-text-sm`,e].filter(Boolean).join(` `);return/* @__PURE__ */ m(`section`,{className:o,"aria-label":mn(n.supportName)?Y(t.contactNamed,{name:n.supportName}):t.contactSupport,children:[/* @__PURE__ */ p(`span`,{className:`fw-semibold`,children:mn(n.supportName)?n.supportName:t.contactSupport}),r&&/* @__PURE__ */ m(`span`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ p(`a`,{href:`mailto:${n.supportEmail}`,className:`text-break`,children:n.supportEmail}),/* @__PURE__ */ p(T,{text:n.supportEmail,iconOnly:!0,label:t.copyEmail,copiedLabel:t.emailCopied})]}),i&&/* @__PURE__ */ p(`a`,{href:`tel:${n.supportPhone.replace(/[^\d+]/g,``)}`,children:n.supportPhone}),a&&/* @__PURE__ */ p(`span`,{className:`text-body-secondary`,children:n.supportHours})]})}function gn({client:e,timeZone:n=c,renderTime:r,labels:i,children:s}){let l=o(null),u=t((t=!1)=>{let n=l.current;if(t||!n||n.client!==e){let t=e.getConfig(),n={client:e,pending:t};return l.current=n,t.catch(()=>{l.current===n&&(l.current=null)}),t}return n.pending},[e]),d=a(()=>({client:e,loadConfig:u,timeZone:n,renderTime:r,labels:i}),[e,u,n,r,i]);return/* @__PURE__ */ p(Ye.Provider,{value:d,children:s})}export{ft as HelpArticle,vt as HelpCentre,zt as ReportIssue,Te as SupportAgentProvider,Ve as SupportAgentTicket,G as SupportApiError,fn as SupportCenter,hn as SupportContact,gn as SupportProvider,qe as SupportQueue,at as createHelpCentreClient,de as createSupportAgentClient,le as createSupportClient,_t as useHelpCentre,he as useSupportAgentClient,ve as useSupportAgentLabels,_e as useSupportAgentRenderTime,we as useSupportAgentSettings,Se as useSupportAgentTicket,ge as useSupportAgentTimeZone,Ce as useSupportAgents,Ze as useSupportClient,tt as useSupportConfig,be as useSupportQueue,xe as useSupportQueueCounts,it as useSupportTicket,rt as useSupportTicketCounts,nt as useSupportTickets};
@@ -8,12 +8,14 @@
8
8
  * @param {any} props.config
9
9
  * @param {string} [props.defaultCategory]
10
10
  * @param {string} [props.appVersion] Recorded on the ticket so support knows which build you were on.
11
+ * @param {boolean} [props.emailEnabled=true] False when the desk does not reply by email.
11
12
  */
12
- export default function NewTicketModal({ open, onClose, onCreated, config, defaultCategory, appVersion }: {
13
+ export default function NewTicketModal({ open, onClose, onCreated, config, defaultCategory, appVersion, emailEnabled }: {
13
14
  open: boolean;
14
15
  onClose: () => void;
15
16
  onCreated: (ticket: any) => void;
16
17
  config: any;
17
18
  defaultCategory?: string;
18
19
  appVersion?: string;
20
+ emailEnabled?: boolean;
19
21
  }): import("react").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/support-react",
3
- "version": "0.137.0",
3
+ "version": "0.137.1",
4
4
  "description": "Webority customer support for React portals: ticket centre, help centre with articles and search, report-an-issue with an optional page screenshot, and support contact details, built on @webority/ui-react.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -27,8 +27,8 @@
27
27
  },
28
28
  "sideEffects": false,
29
29
  "peerDependencies": {
30
- "@webority/ui-elements": "0.137.0",
31
- "@webority/ui-react": "0.137.0",
30
+ "@webority/ui-elements": "0.137.1",
31
+ "@webority/ui-react": "0.137.1",
32
32
  "bootstrap": "5.3.3",
33
33
  "react": "^19.0.0",
34
34
  "react-bootstrap": "^2.10.0",
@@ -42,9 +42,9 @@
42
42
  "@types/react": "^19.2.17",
43
43
  "@vitejs/plugin-react": "^6.0.1",
44
44
  "@vitest/coverage-v8": "5.0.1",
45
- "@webority/canvas-kit": "0.137.0",
46
- "@webority/ui-elements": "0.137.0",
47
- "@webority/ui-react": "0.137.0",
45
+ "@webority/canvas-kit": "0.137.1",
46
+ "@webority/ui-elements": "0.137.1",
47
+ "@webority/ui-react": "0.137.1",
48
48
  "bootstrap": "5.3.3",
49
49
  "jsdom": "30.1.1",
50
50
  "react": "^19.2.6",