@webority/support-react 0.130.1 → 0.130.2

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.130.1"
5
+ "version": "0.130.2"
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{AppActionIcon as c,AppAlert as l,AppAvatar as u,AppBadge as d,AppButton as f,AppCard as p,AppChip as m,AppChipGroup as h,AppConfirmDialog as g,AppCopyButton as _,AppDataTable as v,AppDescriptions as y,AppEmptyState as b,AppFileAttachment as x,AppFloatingButton as S,AppFormActions as C,AppIcon as w,AppInput as T,AppLink as E,AppMarkdown as D,AppModal as O,AppSearch as k,AppSelect as ee,AppSkeleton as A,AppSpinner as j,AppStatusBadge as M,AppTabs as N,AppTextarea as P,warnInvalidValue as F}from"@webority/ui-react";import{IST_TIME_ZONE as I,formatDateTime as L,formatFileSize as R,timeZoneLabel as z}from"@webority/ui-elements/helpers";import{Fragment as B,jsx as V,jsxs as H}from"react/jsx-runtime";import{toBlob as te}from"html-to-image";var U=`Something went wrong. Please try again.`,W=class extends Error{constructor(e,t,n){super(t),this.name=`SupportApiError`,this.code=e,this.status=n}};async function ne(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 re(e){if(e instanceof W)return e;let t=e?.response;if(!t)return new W(`network`,U);let n=await ne(t.data);return new W(typeof n?.code==`string`&&n.code?n.code:`unknown`,typeof n?.detail==`string`&&n.detail.trim()?n.detail:U,t.status)}async function G(e){try{return(await e()).data}catch(e){throw await re(e)}}function K(e,t,n){n!=null&&String(n).trim()!==``&&e.append(t,String(n))}function q(e,t,n,r){(n??[]).forEach((n,i)=>{let a=n?.name||`${r}-${i+1}.png`;e.append(t,n,a)})}var ie=20;function ae(e,t){return(e??[]).map((e,n)=>e?.name||`${t}-${n+1}.png`).join(`|`)}function oe(e){return e instanceof W&&typeof e.status==`number`&&e.status>=400&&e.status<=499&&e.status!==408&&e.status!==429}function se(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<=ie)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 oe(t)&&i.delete(e),t}finally{let t=a.get(e)-1;t>0?a.set(e,t):a.delete(e)}}return{getConfig:()=>G(()=>e.get(`${n}/settings`)),listTickets:({status:t,search:r,page:i,pageSize:a}={})=>{let o=new URLSearchParams;K(o,`status`,t),K(o,`search`,r?.trim()),K(o,`page`,i),K(o,`pageSize`,a);let s=o.toString();return G(()=>e.get(`${n}/tickets${s?`?${s}`:``}`))},getTicketCounts:()=>G(()=>e.get(`${n}/tickets/counts`)),getTicket:t=>G(()=>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??``),K(d,`pageUrl`,a),K(d,`userAgent`,o),K(d,`appVersion`,c),q(d,`files`,l,`file`),q(d,`screenshots`,u,`screenshot`),s([`ticket`,t,r,i,ae(l,`file`),ae(u,`screenshot`)].join(`\0`),t=>G(()=>e.post(`${n}/tickets`,d,{headers:{"Idempotency-Key":t}})))},getSuggestions:async(t,{signal:r}={})=>{try{return await G(()=>e.get(`${n}/suggestions`,{params:{subject:t},signal:r}))}catch(e){if(e instanceof W&&e.status===404)return[];throw e}},reply:(t,{body:n,files:i,screenshots:a})=>{let o=new FormData;return o.append(`body`,n??``),q(o,`files`,i,`file`),q(o,`screenshots`,a,`screenshot`),s([`reply`,t,n,ae(i,`file`),ae(a,`screenshot`)].join(`\0`),n=>G(()=>e.post(`${r(t)}/replies`,o,{headers:{"Idempotency-Key":n}})))},reopen:t=>G(()=>e.post(`${r(t)}/reopen`)),cancel:t=>G(()=>e.post(`${r(t)}/cancel`)),rate:(t,{satisfaction:n,comment:i})=>{let a={satisfaction:n};return i!=null&&i.trim()!==``&&(a.comment=i.trim()),G(()=>e.post(`${r(t)}/rating`,a))},fetchAttachment:t=>G(()=>e.get(`${n}/attachments/${encodeURIComponent(t)}`,{responseType:`blob`})),confirmAction:t=>G(()=>e.post(`${n}/actions/confirm`,{token:t}))}}var ce=3e4,le=e(null);function ue(){let e=n(le);if(!e)throw Error(`Support components and hooks must be used inside <SupportProvider>.`);return e}function J(){return ue().client}function de(){return ue().timeZone}function fe(){return ue().renderTime??null}function Y(e,t){let n=ue().labels?.[e];return a(()=>n?{...t,...n}:t,[n,t])}function pe(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 me(){let{loadConfig:e}=ue(),{data:t,loading:n,error:r,reload:i}=pe(e,`config`);return{config:t,loading:n,error:r,reload:i}}function he(e={}){let t=J(),{status:n,search:r,page:i,pageSize:a}=e,{data:o,loading:s,error:c,reload:l}=pe(()=>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 ge(){let e=J(),{data:t,loading:n,error:r,reload:i}=pe(()=>e.getTicketCounts(),`ticket-counts`);return{counts:t,loading:n,error:r,reload:i}}function _e(e){let n=J(),{data:i,loading:a,error:s,reload:c,setData:l}=pe(()=>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,ce))},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 ve({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 re(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 X({iso:e,className:t}){let n=fe(),r=de();return n?n(e):/* @__PURE__ */ V(`time`,{dateTime:e,className:t,children:L(e,{timeZone:r})})}function Z(e,t){return String(e).replace(/[{]([A-Za-z0-9_]+)[}]/g,(e,n)=>n in t?String(t[n]):e)}var Q={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 $(e,t,n=Q.offline){if(e instanceof W){if(e.code===`network`)return n;if(e.code!==`unknown`)return e.message}return t}var ye={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.`},be={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`},xe=`article_not_found`,Se=`{date}`;function Ce({template:e,iso:t}){let n=e.indexOf(Se);return n===-1?/* @__PURE__ */ H(B,{children:[e,` `,/* @__PURE__ */ V(X,{iso:t})]}):/* @__PURE__ */ H(B,{children:[e.slice(0,n),/* @__PURE__ */ V(X,{iso:t}),e.slice(n+6)]})}function we({client:e,slug:n,onBack:i}){let a=Y(`helpArticle`,be),c=Y(`shared`,Q),[u,d]=s({article:null,loading:!0,error:null}),p=o(null),m=t(()=>{p.current?.abort();let t=new AbortController;p.current=t,d({article:null,loading:!0,error:null}),e.get(n,{signal:t.signal}).then(e=>{t.signal.aborted||d({article:e,loading:!1,error:null})},e=>{t.signal.aborted||d({article:null,loading:!1,error:e})})},[e,n]);r(()=>(m(),()=>p.current?.abort()),[m]);let{article:h,loading:g,error:_}=u,v=_?.code===xe;return/* @__PURE__ */ H(`section`,{className:`d-flex flex-column gap-3 min-w-0`,"aria-busy":g||void 0,children:[i&&/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,leftIcon:`arrow-left`,onClick:i,className:`align-self-start`,children:a.back}),g&&/* @__PURE__ */ V(A,{height:160}),v&&/* @__PURE__ */ V(b,{variant:`card`,icon:`search`,title:a.notFoundTitle}),_&&!v&&/* @__PURE__ */ H(l,{tone:`danger`,children:[$(_,a.loadError,c.offline),` `,/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,onClick:m,children:a.retry})]}),h&&/* @__PURE__ */ H(`article`,{className:`d-flex flex-column gap-3`,children:[/* @__PURE__ */ V(`h2`,{className:`h4 mb-0`,children:h.title}),/* @__PURE__ */ H(`div`,{className:`d-flex flex-wrap gap-3 wui-text-sm text-body-secondary`,children:[h.publishedDateTimeUtc!=null&&/* @__PURE__ */ V(`span`,{children:/* @__PURE__ */ V(Ce,{template:a.published,iso:h.publishedDateTimeUtc})}),/* @__PURE__ */ V(`span`,{children:/* @__PURE__ */ V(Ce,{template:a.updated,iso:h.updatedDateTimeUtc})})]}),/* @__PURE__ */ V(D,{value:h.bodyMarkdown})]})]})}function Te(e,t){let[n,i]=s(e);return r(()=>{let n=setTimeout(()=>i(e),t);return()=>clearTimeout(n)},[e,t]),n}var Ee=10,De=300,Oe=2;function ke(){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 Ae(e){let[n,i]=s({data:null,loading:!0,error:null}),[a,o]=s({page:1,pageSize:Ee}),[c,l]=s({data:null,loading:!0,error:null}),[u,d]=s(``),[f,p]=s({term:``,data:[],loading:!1,error:null}),m=Te(u.trim(),De),h=ke(),g=ke(),_=ke(),{page:v,pageSize:y}=a,b=n.data?.searchAvailable===!0,x=b&&m.length>=Oe,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 je({client:e,onOpen:t,linkTo:n}){let r=Y(`helpCentre`,ye),i=Y(`shared`,Q),{settings:a,articles:o,search:s}=Ae(e),c=s.active,u=c?s.results:o.items,d=c?s.loading:o.loading,p=c?s.error:o.error,m=c?s.reload:o.reload,h=(e,n)=>{t&&(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),t(n)))},g=[{key:`title`,label:r.columnArticle,render:e=>/* @__PURE__ */ H(`div`,{className:`d-flex flex-column min-w-0`,children:[n?/* @__PURE__ */ V(E,{href:n(e.slug),animation:`none`,className:`fw-semibold text-break`,onClick:t=>h(t,e.slug),children:e.title}):/* @__PURE__ */ V(f,{variant:`link`,size:`sm`,className:`fw-semibold text-break text-start p-0`,onClick:()=>t?.(e.slug),children:e.title}),/* @__PURE__ */ V(`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__ */ V(X,{iso:e.updatedDateTimeUtc})}],_={page:o.page,totalPages:Math.max(1,o.totalPages),pageSize:o.pageSize,total:o.totalCount,setPage:o.setPage,setPageSize:o.setPageSize};return/* @__PURE__ */ H(`section`,{className:`d-flex flex-column gap-3 min-w-0`,"aria-labelledby":`help-centre-title`,children:[/* @__PURE__ */ V(`h2`,{id:`help-centre-title`,className:`h5 mb-0`,children:r.heading}),a.error&&/* @__PURE__ */ H(l,{tone:`warning`,children:[$(a.error,r.settingsError,i.offline),` `,/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,onClick:a.reload,children:r.retry})]}),s.enabled&&/* @__PURE__ */ V(k,{value:s.query,onChange:s.setQuery,placeholder:r.searchPlaceholder,ariaLabel:r.searchLabel}),p&&/* @__PURE__ */ H(l,{tone:`danger`,children:[$(p,r.listError,i.offline),` `,/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,onClick:m,children:r.retry})]}),/* @__PURE__ */ V(v,{columns:g,rows:u,loading:d,skeletonRows:4,ariaLabel:r.tableLabel,stackOnMobile:!0,pagination:c?void 0:_,empty:c?/* @__PURE__ */ V(b,{variant:`table`,icon:`search`,title:r.noMatchTitle,description:r.noMatchText}):/* @__PURE__ */ V(b,{variant:`table`,icon:`message-square`,title:r.emptyTitle,description:r.emptyText})})]})}function Me(e){return(e?.allowedContentTypes??[]).join(`,`)}function Ne(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 Pe(e,t,n=Q){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:Z(n.attachMany,{count:i});for(let e of r){let t=e.name||n.thisFile;if(!Ne(e.type,o))return Z(n.typeNotAccepted,{name:t});if(a>0&&e.size>a)return Z(n.tooLarge,{name:t,size:R(a)})}return null}var Fe=(e,t)=>e===1?t.attachOne:Z(t.attachMany,{count:e});function Ie(e){return`${e.name}|${e.size}|${e.lastModified}`}function Le(e,t,n,r=Q){let i=n?.maxAttachmentsPerMessage??0,a=new Set(e.map(Ie)),o=[],s=null;for(let e of t){let t=Ie(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?Fe(i,r):null)??Pe(l,n,r)??(s?Z(r.alreadyAttached,{name:s}):``)}}function Re(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 ze=80;function Be(e,t){let n=Math.min(t,ze),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 Ve({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__ */ V(x,{id:e,label:t,optional:!0,multiple:!0,value:n,onChange:r,accept:Me(i),maxSizeMb:s,validate:!1,error:a||void 0})}var He={title:`These may already answer your question`};function Ue({items:e}){let t=Y(`suggestedAnswers`,He);return e.length===0?null:/* @__PURE__ */ V(p,{variant:`filled`,padding:`sm`,title:t.title,children:/* @__PURE__ */ V(`ul`,{className:`list-unstyled mb-0 d-flex flex-column gap-2`,children:e.map(e=>/* @__PURE__ */ H(`li`,{children:[/* @__PURE__ */ V(`div`,{className:`fw-semibold`,children:e.title}),/* @__PURE__ */ V(`div`,{className:`small text-body-secondary`,children:e.summary})]},e.title))})})}var We={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.`},Ge=500,Ke=3,qe=5;function Je(e,t){return t&&e.includes(t)?t:``}function Ye({id:e,config:t,defaultCategory:n,initialValues:i,onValuesChange:a,extraFiles:o=[],onSubmit:c,onBusyChange:u,children:d}){let f=Y(`ticketForm`,We),p=Y(`shared`,Q),m=t?.categories??[],h=t?.subjectMaxLength??1/0,[g,_]=s(()=>i?.category??Je(m,n)),[v,y]=s(i?.body??``),[b,x]=s(()=>i?.subject||Be(i?.body??``,h)),[S,C]=s(()=>{let e=(i?.subject??``).trim();return e!==``&&e!==Be(i?.body??``,h)}),[w,E]=s(i?.files??[]),[D,O]=s({}),[k,A]=s(``),j=J(),[M,N]=s(``),[F,I]=s([]),L=Te(b.trim(),Ge);r(()=>{a?.({category:g,subject:b,body:v,files:w})},[g,b,v,w,a]),r(()=>{N(L)},[L]),r(()=>{if(M.length<Ke){I([]);return}let e=!0,t=new AbortController;return I([]),j.getSuggestions(M,{signal:t.signal}).then(t=>{e&&I(Array.isArray(t)?t.slice(0,qe):[])},()=>{e&&I([])}),()=>{e=!1,t.abort()}},[j,M]);let R=e=>{E(e),O(n=>({...n,files:Pe([...o,...e],t,p)??void 0}))},z=e=>{let t=Re(e);t.length>0&&R([...w,...t])},B=e=>{let t=e.target.value;y(t),S||x(Be(t,h)),D.body&&O(e=>({...e,body:t.trim()?void 0:f.bodyRequired}))},te=e=>{let t=e.target.value;x(t),C(t.trim()!==``)};function U(){let e={};v.trim()||(e.body=f.bodyRequired);let n=Pe([...o,...w],t,p);return n&&(e.files=n),O(e),Object.keys(e).length===0}async function W(e){if(e.preventDefault(),A(``),U()){u?.(!0);try{await c({category:g,subject:b.trim()||Be(v,h),body:v.trim(),files:w})}catch(e){A($(e,f.sendFailed,p.offline))}finally{u?.(!1)}}}return/* @__PURE__ */ H(`form`,{id:e,onSubmit:W,noValidate:!0,className:`d-flex flex-column gap-3`,children:[k&&/* @__PURE__ */ V(l,{tone:`danger`,children:k}),/* @__PURE__ */ V(P,{id:`${e}-body`,label:f.messageLabel,required:!0,rows:6,maxLength:t?.bodyMaxLength,showCount:!0,placeholder:f.messagePlaceholder,value:v,onChange:B,onPaste:z,helperText:f.messageHint,error:D.body}),/* @__PURE__ */ V(T,{id:`${e}-subject`,label:f.subjectLabel,maxLength:t?.subjectMaxLength,showCount:!0,placeholder:f.subjectPlaceholder,helperText:f.subjectHint,value:b,onChange:te,onBlur:()=>N(b.trim())}),/* @__PURE__ */ V(Ue,{items:F}),/* @__PURE__ */ V(ee,{id:`${e}-category`,label:f.categoryLabel,value:g,onChange:_,options:m.map(e=>({value:e,label:e})),placeholder:f.categoryPlaceholder,helperText:f.categoryHint,error:D.category}),d,/* @__PURE__ */ V(Ve,{id:`${e}-files`,files:w,onChange:R,config:t,error:D.files})]})}var Xe={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.`},Ze=`supportCapture`,Qe={zIndex:`var(--wui-z-fixed)`,bottom:0,insetInlineEnd:0},$e={zIndex:`var(--wui-z-fixed)`},et={maxWidth:`20rem`},tt=e=>e.dataset?.[Ze]===`exclude`||e.matches?.(`.modal-backdrop`)?!1:!(e.matches?.(`.modal`)&&e.querySelector?.(`[data-support-capture="exclude"]`)),nt=()=>new Promise(e=>requestAnimationFrame(()=>e()));async function rt(e){let t=await te(document.body,{filter:tt,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 it({t:e,file:t,failed:n,disabled:i,hintId:a,controlRef:o,onAdd:c,onRemove:u}){let[d,p]=s(null);return r(()=>{if(!t)return;let e=URL.createObjectURL(t);return p(e),()=>URL.revokeObjectURL(e)},[t]),/* @__PURE__ */ H(`div`,{className:`d-flex flex-column gap-2`,children:[/* @__PURE__ */ V(`span`,{className:`wui-text-sm fw-semibold`,children:e.screenshotTitle}),t&&d&&/* @__PURE__ */ V(`img`,{src:d,alt:e.screenshotLabel,className:`d-block w-100 border rounded`,style:et}),/* @__PURE__ */ V(`div`,{ref:o,className:`d-flex flex-wrap gap-2`,children:t?/* @__PURE__ */ H(B,{children:[/* @__PURE__ */ V(f,{variant:`outline`,size:`sm`,leftIcon:`refresh-cw`,onClick:c,disabled:i,"aria-describedby":a,children:e.retake}),/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,leftIcon:`x`,onClick:u,disabled:i,children:e.removeScreenshot})]}):/* @__PURE__ */ V(f,{variant:`outline`,size:`sm`,leftIcon:`camera`,onClick:c,disabled:i,"aria-describedby":a,children:e.addScreenshot})}),/* @__PURE__ */ V(`span`,{id:a,className:`wui-text-sm text-body-secondary`,children:e.screenshotNote}),n&&/* @__PURE__ */ V(l,{tone:`info`,children:e.screenshotFailed})]})}function at({label:e=`Report an issue`,floating:t=!1,compact:n=!1,defaultCategory:a=`Bug report`,appVersion:c,getTicketHref:u,onOpenTicket:d,onCreated:p,className:m,style:h}){let g=Y(`reportIssue`,Xe),_=Y(`shared`,Q),v=J(),{config:y,error:b}=me(),x=`support-report-${i().replace(/[^a-zA-Z0-9-]/g,``)}`,[C,w]=s(!1),[T,E]=s(!1),[D,k]=s(null),[ee,A]=s(!1),[j,M]=s(!1),[N,P]=s(null),[F,I]=s(null),L=o(null),R=o(!1);r(()=>{!T&&R.current&&(R.current=!1,L.current?.querySelector(`button`)?.focus())},[T]);function z(){P(null),k(null),A(!1),I(null),w(!0)}async function te(){E(!0),A(!1),await nt(),await nt();try{k(await rt(g.captureEmpty))}catch{k(null),A(!0)}finally{R.current=!0,E(!1)}}let U=()=>{j||(w(!1),k(null),A(!1),P(null),I(null))};async function W(e){let t=await v.createTicket({...e,pageUrl:window.location.href,userAgent:navigator.userAgent,appVersion:c,screenshots:D?[D]:[]});P(t),k(null),p?.(t)}let ne=!N&&(!!D||!!F&&(F.subject.trim()!==``||F.body.trim()!==``||F.files.length>0)),re=N&&u?u(N.id):void 0,G=N&&(re||d)?/* @__PURE__ */ V(f,{href:re,onClick:re?void 0:()=>{w(!1),P(null),d(N)},children:g.viewTicket}):null,K=N?/* @__PURE__ */ H(`div`,{className:`d-flex justify-content-end gap-2 w-100`,children:[/* @__PURE__ */ V(f,{variant:`soft`,onClick:U,children:g.close}),G]}):/* @__PURE__ */ H(`div`,{className:`d-flex justify-content-end gap-2 w-100`,children:[/* @__PURE__ */ V(f,{variant:`soft`,onClick:U,disabled:j,children:g.cancel}),/* @__PURE__ */ V(f,{type:`submit`,form:x,loading:j,disabled:!y,children:g.submit})]}),q=n?/* @__PURE__ */ V(S,{icon:`bug`,label:e,order:`secondary`,size:`sm`,variant:`soft`,stacked:t,className:t?m:void 0,style:t?h:void 0,disabled:T,onClick:z,"aria-haspopup":`dialog`}):/* @__PURE__ */ V(f,{leftIcon:`bug`,variant:t?`solid`:`outline`,disabled:T,onClick:z,"aria-haspopup":`dialog`,children:e});return/* @__PURE__ */ H(B,{children:[t&&n?q:/* @__PURE__ */ V(`span`,{"data-support-capture":`exclude`,className:[t?`position-fixed m-3`:`d-inline-block`,m].filter(Boolean).join(` `),style:t?{...Qe,...h}:h,children:q}),T&&/* @__PURE__ */ H(`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:$e,children:[/* @__PURE__ */ V(`span`,{className:`spinner-border spinner-border-sm`,"aria-hidden":`true`}),g.takingScreenshot]}),/* @__PURE__ */ V(O,{open:C,size:`lg`,title:g.title,subtitle:g.subtitle,headerIcon:`bug`,confirmDiscard:g.confirmDiscard,dirty:ne&&!j,onClose:U,footer:K,"data-support-capture":`exclude`,children:N?/* @__PURE__ */ V(l,{tone:`success`,role:`status`,title:Z(g.createdTitle,{number:N.number}),children:g.createdText}):y?/* @__PURE__ */ V(Ye,{id:x,config:y,defaultCategory:a,initialValues:F,onValuesChange:I,extraFiles:D?[D]:[],onSubmit:W,onBusyChange:M,children:/* @__PURE__ */ V(it,{t:g,file:D,failed:ee,disabled:j||T,hintId:`${x}-screenshot-hint`,controlRef:L,onAdd:te,onRemove:()=>k(null)})}):/* @__PURE__ */ V(l,{tone:b?`danger`:`info`,children:b?$(b,g.configError,_.offline):g.loading})})]})}var ot={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 st({open:e,onClose:t,onCreated:n,config:r,defaultCategory:a,appVersion:o}){let c=Y(`newTicketModal`,ot),l=J(),u=`support-new-${i().replace(/[^a-zA-Z0-9-]/g,``)}`,[d,p]=s(!1),[m,h]=s(null),g=!!m&&(m.subject.trim()!==``||m.body.trim()!==``||m.files.length>0);async function _(e){n(await l.createTicket({...e,userAgent:typeof navigator>`u`?void 0:navigator.userAgent,appVersion:o}))}return/* @__PURE__ */ V(O,{open:e,size:`lg`,title:c.title,subtitle:c.subtitle,headerIcon:`message-square`,confirmDiscard:c.confirmDiscard,dirty:g&&!d,onClose:()=>{d||t()},footer:/* @__PURE__ */ H(`div`,{className:`d-flex justify-content-end gap-2 w-100`,children:[/* @__PURE__ */ V(f,{variant:`soft`,onClick:t,disabled:d,children:c.cancel}),/* @__PURE__ */ V(f,{type:`submit`,form:u,loading:d,children:c.send})]}),children:e&&/* @__PURE__ */ V(Ye,{id:u,config:r,defaultCategory:a,onSubmit:_,onBusyChange:p,onValuesChange:h})})}var ct={Open:`info`,InProgress:`info`,WaitingOnCustomer:`warning`,Resolved:`success`,Closed:`success`,Cancelled:`neutral`};function lt(e){return ct[e]??`neutral`}var ut={loading:`Loading {name}`,failed:`Could not load this file. Click to try again.`},dt=6e4,ft=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`application/pdf`];function pt({attachment:e}){let t=Y(`attachmentThumb`,ut),n=J(),[r,i]=s(!1),[a,o]=s(!1);async function c(){i(!0),o(!1);let t=ft.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),dt),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)?R(e.sizeBytes):`-`;return/* @__PURE__ */ H(B,{children:[/* @__PURE__ */ V(m,{leadingIcon:a?`x-circle`:`paperclip`,label:r?/* @__PURE__ */ H(B,{children:[/* @__PURE__ */ V(j,{size:`sm`,label:Z(t.loading,{name:e.fileName})}),` `,e.fileName]}):e.fileName,onClick:c,disabled:r,"aria-busy":r||void 0,title:`${e.fileName}, ${l}`}),a&&/* @__PURE__ */ V(`span`,{role:`status`,className:`wui-text-xs text-danger align-self-center`,children:t.failed})]})}var mt={conversation:`Conversation`,you:`You`,supportTeam:`Support team`,supportBadge:`Support`},ht={whiteSpace:`pre-wrap`,overflowWrap:`anywhere`};function gt({messages:e}){let t=Y(`messageThread`,mt);return/* @__PURE__ */ V(`ol`,{className:`list-unstyled d-flex flex-column gap-3 mb-0`,"aria-label":t.conversation,children:e.map(e=>{let n=/* @__PURE__ */ V(X,{iso:e.createdDateTimeUtc,className:`wui-text-xs text-body-secondary text-nowrap`});if(e.authorKind===`System`)return/* @__PURE__ */ H(`li`,{className:`text-center wui-text-xs text-body-secondary`,"data-author":`system`,children:[/* @__PURE__ */ V(`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__ */ H(`li`,{className:`d-flex align-items-start gap-2${r?` flex-row-reverse`:``}`,"data-author":r?`customer`:`agent`,children:[/* @__PURE__ */ V(u,{name:i,size:32,tone:r?`neutral`:`primary`}),/* @__PURE__ */ H(p,{className:`flex-grow-1 border`,padding:`sm`,variant:r?`flat`:`accent`,style:{minWidth:0},children:[/* @__PURE__ */ H(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2 mb-2`,children:[/* @__PURE__ */ H(`span`,{className:`d-inline-flex flex-wrap align-items-center gap-2 fw-semibold wui-text-sm text-break`,children:[i,!r&&/* @__PURE__ */ V(d,{tone:`primary`,children:t.supportBadge})]}),n]}),/* @__PURE__ */ V(`div`,{className:`wui-text-sm`,style:ht,children:e.body}),e.attachments?.length>0&&/* @__PURE__ */ V(`div`,{className:`d-flex flex-wrap gap-2 mt-2`,children:e.attachments.map(e=>/* @__PURE__ */ V(pt,{attachment:e},e.id))})]})]},e.id)})})}var _t={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 vt({satisfaction:e,comment:t,canRate:n=!1,commentMaxLength:r,onRate:a}){let o=Y(`ratingPanel`,_t),c=Y(`shared`,Q),u=i(),[d,m]=s(``),[h,g]=s(null),[_,v]=s(``);if(e)return/* @__PURE__ */ H(l,{tone:e===`Satisfied`?`success`:`info`,role:`status`,children:[e===`Satisfied`?o.solved:o.notSolved,t?/* @__PURE__ */ H(`span`,{className:`d-block mt-1`,children:[o.yourComment,` `,t]}):null]});if(!n)return null;async function y(e){v(``),g(e);try{await a({satisfaction:e,comment:d})}catch(e){v($(e,o.sendFailed,c.offline))}finally{g(null)}}return/* @__PURE__ */ V(p,{padding:`sm`,className:`border`,title:o.heading,children:/* @__PURE__ */ H(`div`,{className:`d-flex flex-column gap-2`,children:[_&&/* @__PURE__ */ V(l,{tone:`danger`,children:_}),/* @__PURE__ */ V(P,{id:`${u}-comment`,label:o.commentLabel,rows:2,maxLength:r,value:d,onChange:e=>m(e.target.value),helperText:o.commentHint}),/* @__PURE__ */ H(`div`,{className:`d-flex flex-wrap gap-2`,children:[/* @__PURE__ */ V(f,{variant:`outline`,leftIcon:`check-circle`,loading:h===`Satisfied`,disabled:h!==null,onClick:()=>y(`Satisfied`),children:o.yes}),/* @__PURE__ */ V(f,{variant:`outline`,leftIcon:`x-circle`,loading:h===`Unsatisfied`,disabled:h!==null,onClick:()=>y(`Unsatisfied`),children:o.no})]})]})})}var yt={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 bt({onSend:e,config:t,reopens:n=!1}){let r=Y(`replyBox`,yt),a=Y(`shared`,Q),o=i(),[u,d]=s(``),[p,g]=s([]),[_,v]=s(``),[y,b]=s(``),[x,S]=s(!1),C=e=>{let n=Le(p,e,t,a);g(n.files),v(n.notice)},w=e=>{let n=p.filter((t,n)=>n!==e);g(n),v(Pe(n,t,a)??``)},T=e=>{let t=Re(e);t.length>0&&C(t)};async function E(n){n.preventDefault();let i=u.trim();if(!i){b(r.emptyReply);return}let o=Pe(p,t,a);if(o)v(o);else{b(``),S(!0);try{await e({body:i,files:p}),d(``),g([]),v(``)}catch(e){b($(e,r.sendFailed,a.offline))}finally{S(!1)}}}let D=y||_;return/* @__PURE__ */ H(`form`,{onSubmit:E,noValidate:!0,className:`d-flex flex-column gap-2 flex-grow-1 min-w-0`,"aria-label":r.formLabel,children:[D&&/* @__PURE__ */ V(l,{tone:`danger`,children:D}),/* @__PURE__ */ V(P,{id:`${o}-body`,label:r.replyLabel,rows:2,autoGrow:!0,maxLength:t?.bodyMaxLength,value:u,onChange:e=>{d(e.target.value),b(``)},onPaste:T,helperText:n?r.hintReopens:r.hint,required:!0}),p.length>0&&/* @__PURE__ */ V(h,{label:r.attachedFiles,children:p.map((e,t)=>/* @__PURE__ */ V(m,{leadingIcon:`paperclip`,label:e.name,removeLabel:Z(r.removeFile,{name:e.name}),onRemove:()=>w(t)},Ie(e)))}),/* @__PURE__ */ H(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2`,children:[/* @__PURE__ */ V(c,{iconVariant:`bulk`,icon:`paperclip`,label:r.attach,multiple:t?.maxAttachmentsPerMessage!==1,accept:Me(t),onFiles:C}),/* @__PURE__ */ V(f,{type:`submit`,leftIcon:`send`,loading:x,children:r.send})]})]})}var xt={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 St({ticketId:e,onBack:t,onChanged:n,onOpenTicket:r}){let{config:i}=me(),a=Y(`ticketDetail`,xt),o=Y(`shared`,Q),c=de(),u=fe(),{ticket:d,loading:m,error:h,reload:_,reply:v,reopen:b,cancel:x,rate:S}=_e(e),[T,E]=s(!1),[D,O]=s(!1),[k,ee]=s(!1),[j,N]=s(``),P=async e=>{let t=await e();return n?.(),t};async function F(){N(``),E(!0);try{await P(b)}catch(e){N($(e,a.reopenFailed,o.offline))}finally{E(!1)}}async function I(){N(``),ee(!0);try{await P(x)}catch(e){N($(e,a.withdrawFailed,o.offline))}finally{ee(!1),O(!1)}}let L=/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,leftIcon:`arrow-left`,onClick:t,className:`align-self-start`,children:a.back});if(!d)return/* @__PURE__ */ H(`section`,{className:`d-flex flex-column gap-3`,"aria-busy":m||void 0,children:[L,h?/* @__PURE__ */ H(l,{tone:`danger`,children:[$(h,a.loadError,o.offline),` `,/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,onClick:_,children:a.retry})]}):/* @__PURE__ */ V(A,{height:160})]});let R=lt(d.status),B=[{key:`status`,label:a.fieldStatus,value:d.statusLabel?/* @__PURE__ */ V(M,{label:d.statusLabel,tone:R}):`-`},{key:`category`,label:a.fieldCategory,value:d.category||`-`},{key:`ticket`,label:a.fieldTicket,value:d.number},{key:`opened`,label:a.fieldOpened,value:/* @__PURE__ */ V(X,{iso:d.createdDateTimeUtc})},{key:`updated`,label:a.fieldUpdated,value:/* @__PURE__ */ V(X,{iso:d.updatedDateTimeUtc})}];return/* @__PURE__ */ H(`section`,{className:`d-flex flex-column gap-3`,"aria-labelledby":`support-ticket-${d.id}`,children:[L,/* @__PURE__ */ H(`div`,{className:`row g-3`,children:[/* @__PURE__ */ H(`div`,{className:`col-12 col-lg-8 d-flex flex-column gap-3`,children:[/* @__PURE__ */ H(`header`,{className:`d-flex flex-column gap-2`,children:[/* @__PURE__ */ H(`div`,{className:`d-flex flex-wrap align-items-center gap-2`,children:[/* @__PURE__ */ V(`h2`,{id:`support-ticket-${d.id}`,className:`h5 mb-0 text-break`,children:d.subject}),d.statusLabel&&/* @__PURE__ */ V(M,{label:d.statusLabel,tone:R})]}),/* @__PURE__ */ H(`ul`,{className:`list-unstyled d-flex flex-wrap gap-3 mb-0 wui-text-sm text-body-secondary`,"aria-label":a.summaryLabel,children:[d.number&&/* @__PURE__ */ H(`li`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ V(w,{variant:`bulk`,name:`receipt-text`,size:16}),d.number]}),d.category&&/* @__PURE__ */ H(`li`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ V(w,{variant:`bulk`,name:`folder-2`,size:16}),d.category]}),/* @__PURE__ */ H(`li`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ V(w,{variant:`bulk`,name:`calendar-1`,size:16}),a.openedLabel,` `,/* @__PURE__ */ V(X,{iso:d.createdDateTimeUtc})]})]}),u===null&&/* @__PURE__ */ V(`p`,{className:`wui-text-xs text-body-secondary mb-0`,children:Z(a.timeZoneNote,{zone:z(c)})})]}),j&&/* @__PURE__ */ V(l,{tone:`danger`,children:j}),d.mergedInto&&/* @__PURE__ */ H(l,{tone:`info`,role:`status`,children:[Z(a.mergedText,{number:d.mergedInto.number}),` `,r&&/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,onClick:()=>r(d.mergedInto.id),children:Z(a.openMerged,{number:d.mergedInto.number})})]}),d.canReopen&&/* @__PURE__ */ V(l,{tone:`success`,role:`status`,children:a.resolvedHint}),d.status===`WaitingOnCustomer`&&/* @__PURE__ */ V(l,{tone:`warning`,role:`status`,children:a.waitingHint}),!d.canReopen&&/* @__PURE__ */ V(`p`,{className:`wui-text-sm text-body-secondary mb-0`,children:a.openHint}),d.canReopen&&/* @__PURE__ */ V(f,{variant:`soft`,leftIcon:`history`,loading:T,onClick:F,className:`align-self-start`,children:a.reopen}),d.canCancel&&/* @__PURE__ */ V(f,{variant:`soft`,onClick:()=>O(!0),className:`align-self-start`,children:a.withdraw}),/* @__PURE__ */ V(g,{open:D,title:a.withdrawTitle,description:a.withdrawMessage,confirmLabel:a.withdrawConfirm,cancelLabel:a.withdrawCancel,tone:`danger`,loading:k,onConfirm:I,onClose:()=>O(!1)}),/* @__PURE__ */ V(vt,{satisfaction:d.satisfaction,comment:d.satisfactionComment,canRate:d.canRate,commentMaxLength:i?.satisfactionCommentMaxLength,onRate:e=>P(()=>S(e))}),/* @__PURE__ */ V(gt,{messages:d.messages??[]}),d.mergedTickets?.length>0&&/* @__PURE__ */ H(`section`,{"aria-labelledby":`support-merged-${d.id}`,className:`d-flex flex-column gap-1`,children:[/* @__PURE__ */ V(`h3`,{id:`support-merged-${d.id}`,className:`h6 mb-0`,children:a.merged}),/* @__PURE__ */ V(`ul`,{className:`list-unstyled d-flex flex-column gap-1 mb-0 wui-text-sm`,children:d.mergedTickets.map(e=>/* @__PURE__ */ V(`li`,{children:r?/* @__PURE__ */ H(f,{variant:`ghost`,size:`sm`,onClick:()=>r(e.id),children:[e.number,`: `,e.subject]}):`${e.number}: ${e.subject}`},e.id))})]}),!d.mergedInto&&/* @__PURE__ */ V(C,{sticky:!0,align:`start`,children:/* @__PURE__ */ V(bt,{config:i,reopens:d.canReopen,onSend:e=>P(()=>v(e))})})]}),/* @__PURE__ */ V(`aside`,{"aria-label":a.detailsLabel,className:`col-12 col-lg-4`,children:/* @__PURE__ */ H(p,{padding:`sm`,className:`border`,children:[/* @__PURE__ */ V(`h3`,{className:`h6`,children:a.detailsTitle}),/* @__PURE__ */ V(y,{columns:1,items:B})]})})]})]})}var Ct=`ticket`;function wt(){return typeof window>`u`?null:new URLSearchParams(window.location.search).get(Ct)}function Tt(e){if(typeof window>`u`)return e?`?${Ct}=${encodeURIComponent(e)}`:`?`;let t=new URL(window.location.href);return e?t.searchParams.set(Ct,e):t.searchParams.delete(Ct),`${t.pathname}${t.search}${t.hash}`}function Et(e){if(typeof window>`u`)return;let t=Tt(e);t!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,t)}var Dt={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.`},Ot=[`tabs`,`select`,`none`];function kt({tickets:e,loading:t,error:n,onRetry:r,onOpen:i,status:a,onStatusChange:o,statusFilter:s=`tabs`,counts:u,search:d,onSearchChange:p,pagination:m}){let h=Y(`ticketList`,Dt),g=Y(`shared`,Q);F(`SupportCenter`,`statusFilter`,s,Ot);let _=[{key:`all`,label:h.tabAll,countKey:`total`},{key:`Open`,label:h.tabOpen,countKey:`open`},{key:`NeedsReply`,label:h.tabNeedsReply,countKey:`needsReply`},{key:`Resolved`,label:h.tabResolved,countKey:`resolved`},{key:`Withdrawn`,label:h.tabWithdrawn,countKey:`withdrawn`}],y=_.map(({key:e,label:t,countKey:n})=>{let r=u?.[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:h.columnSubject,render:e=>/* @__PURE__ */ H(`div`,{className:`d-flex flex-column`,style:{minWidth:0},children:[/* @__PURE__ */ V(E,{href:Tt(e.id),animation:`none`,className:`fw-semibold text-break`,onClick:t=>x(t,e.id),children:e.subject}),/* @__PURE__ */ H(`span`,{className:`wui-text-xs text-body-secondary`,children:[e.number,`, `,e.category]})]})},{key:`status`,label:h.columnStatus,render:e=>e.statusLabel?/* @__PURE__ */ V(M,{label:e.statusLabel,tone:lt(e.status)}):`-`},{key:`messageCount`,label:h.columnMessages,cellClassName:`wui-text-sm text-body-secondary`,render:e=>e.messageCount},{key:`updatedDateTimeUtc`,label:h.columnLastUpdate,cellClassName:`wui-text-sm text-body-secondary text-nowrap`,render:e=>/* @__PURE__ */ V(X,{iso:e.updatedDateTimeUtc})}];return/* @__PURE__ */ H(`div`,{className:`d-flex flex-column gap-3`,children:[n&&/* @__PURE__ */ H(l,{tone:`danger`,children:[$(n,h.loadError,g.offline),` `,/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,onClick:r,children:h.retry})]}),/* @__PURE__ */ H(`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__ */ V(ee,{label:h.statusSelect,value:a,onChange:o,options:y,fieldClassName:`flex-shrink-0`}):/* @__PURE__ */ V(N,{tabs:_.map(({key:e,label:t,countKey:n})=>({key:e,label:t,count:u?.[n]})),value:a,onChange:o,ariaLabel:h.filterByStatus,className:`flex-grow-1`}),/* @__PURE__ */ V(k,{value:d,onChange:p,placeholder:h.searchPlaceholder,ariaLabel:h.searchLabel})]}),/* @__PURE__ */ V(v,{columns:S,rows:e,loading:t,skeletonRows:4,ariaLabel:h.tableLabel,rowActionsLabel:h.actions,rowActions:e=>/* @__PURE__ */ V(c,{icon:`eye`,label:Z(h.openTicket,{subject:e.subject}),href:Tt(e.id),onClick:t=>x(t,e.id)}),stickyActions:!0,stackOnMobile:!0,sourceCount:u?.total??0,pagination:m,empty:/* @__PURE__ */ V(b,{variant:`table`,icon:`message-square`,title:h.emptyTitle,description:h.emptyText}),emptyFiltered:/* @__PURE__ */ V(b,{variant:`table`,icon:`search`,title:h.noMatchTitle,description:h.noMatchText})})]})}var At=300,jt=10,Mt={heading:`Your tickets`,newTicket:`New ticket`,configError:`We could not load the support settings.`,retry:`Try again`};function Nt({initialTicketId:e,defaultCategory:t,appVersion:n,status:i,defaultStatus:a=`all`,onStatusChange:o,statusFilter:c=`tabs`}){let u=Y(`supportCenter`,Mt),d=Y(`shared`,Q),{config:p,error:m,reload:h}=me(),[g,_]=s(a),v=i!==void 0,y=v?i:g,b=e=>{v||_(e),o?.(e)},[x,S]=s(``),C=Te(x.trim(),At),[w,T]=s(jt),E=`${y}|${C}|${w}`,[D,O]=s({key:E,page:1}),k=D.key===E?D.page:1,ee=e=>O({key:E,page:e}),A=he({status:y===`all`?void 0:y,search:C||void 0,page:k,pageSize:w}),{counts:j,reload:M}=ge(),[N,P]=s(()=>e||wt()),[F,I]=s(!1),L=A.totalPages;r(()=>{L>0&&k>L&&O({key:E,page:L})},[L,k,E]);let R=()=>{A.reload(),M()},z=e=>{P(e),Et(e)};if(N)return/* @__PURE__ */ V(St,{ticketId:N,onBack:()=>z(null),onChanged:R,onOpenTicket:z},N);let B={page:k,totalPages:Math.max(1,A.totalPages),pageSize:w,total:A.totalCount,setPage:ee,setPageSize:T};return/* @__PURE__ */ H(`section`,{className:`d-flex flex-column gap-3 min-w-0`,"aria-labelledby":`support-center-title`,children:[/* @__PURE__ */ H(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2`,children:[/* @__PURE__ */ V(`h2`,{id:`support-center-title`,className:`h5 mb-0`,children:u.heading}),/* @__PURE__ */ V(f,{leftIcon:`plus`,onClick:()=>I(!0),disabled:!p,children:u.newTicket})]}),m&&/* @__PURE__ */ H(l,{tone:`warning`,children:[$(m,u.configError,d.offline),` `,/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,onClick:h,children:u.retry})]}),/* @__PURE__ */ V(kt,{tickets:A.tickets,loading:A.loading,error:A.error,onRetry:R,onOpen:z,status:y,onStatusChange:b,statusFilter:c,counts:j,search:x,onSearchChange:S,pagination:B}),p&&/* @__PURE__ */ V(st,{open:F,onClose:()=>I(!1),config:p,defaultCategory:t,appVersion:n,onCreated:e=>{I(!1),R(),z(e.id)}})]})}var Pt={copyEmail:`Copy email`,emailCopied:`Email copied`,contactNamed:`Contact {name}`,contactSupport:`Contact support`},Ft=e=>typeof e==`string`&&e.trim()!==``;function It({className:e}){let t=Y(`supportContact`,Pt),{config:n}=me();if(!n)return null;let r=Ft(n.supportEmail),i=Ft(n.supportPhone),a=Ft(n.supportHours);if(!r&&!i&&!a)return null;let o=[`d-flex flex-wrap align-items-center gap-2 wui-text-sm`,e].filter(Boolean).join(` `);return/* @__PURE__ */ H(`section`,{className:o,"aria-label":Ft(n.supportName)?Z(t.contactNamed,{name:n.supportName}):t.contactSupport,children:[/* @__PURE__ */ V(`span`,{className:`fw-semibold`,children:Ft(n.supportName)?n.supportName:t.contactSupport}),r&&/* @__PURE__ */ H(`span`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ V(`a`,{href:`mailto:${n.supportEmail}`,className:`text-break`,children:n.supportEmail}),/* @__PURE__ */ V(_,{text:n.supportEmail,iconOnly:!0,label:t.copyEmail,copiedLabel:t.emailCopied})]}),i&&/* @__PURE__ */ V(`a`,{href:`tel:${n.supportPhone.replace(/[^\d+]/g,``)}`,children:n.supportPhone}),a&&/* @__PURE__ */ V(`span`,{className:`text-body-secondary`,children:n.supportHours})]})}function Lt({client:e,timeZone:n=I,renderTime:r,labels:i,children:s}){let c=o(null),l=t((t=!1)=>{let n=c.current;if(t||!n||n.client!==e){let t=e.getConfig(),n={client:e,pending:t};return c.current=n,t.catch(()=>{c.current===n&&(c.current=null)}),t}return n.pending},[e]),u=a(()=>({client:e,loadConfig:l,timeZone:n,renderTime:r,labels:i}),[e,l,n,r,i]);return/* @__PURE__ */ V(le.Provider,{value:u,children:s})}export{we as HelpArticle,je as HelpCentre,at as ReportIssue,W as SupportApiError,Nt as SupportCenter,It as SupportContact,Lt as SupportProvider,ve as createHelpCentreClient,se as createSupportClient,Ae as useHelpCentre,J as useSupportClient,me as useSupportConfig,_e as useSupportTicket,ge as useSupportTicketCounts,he 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{AppActionIcon as c,AppAlert as l,AppAvatar as u,AppBadge as d,AppButton as f,AppCard as p,AppChip as m,AppChipGroup as h,AppConfirmDialog as g,AppCopyButton as _,AppDataTable as v,AppDescriptions as y,AppEmptyState as b,AppFileAttachment as x,AppFloatingButton as S,AppFormActions as C,AppIcon as w,AppInput as T,AppLink as E,AppMarkdown as D,AppModal as O,AppSearch as k,AppSelect as ee,AppSkeleton as A,AppSpinner as j,AppStatusBadge as M,AppTabs as N,AppTextarea as P,warnInvalidValue as F}from"@webority/ui-react";import{IST_TIME_ZONE as I,formatDateTime as L,formatFileSize as R,timeZoneLabel as z}from"@webority/ui-elements/helpers";import{Fragment as B,jsx as V,jsxs as H}from"react/jsx-runtime";import{toBlob as te}from"html-to-image";var U=`Something went wrong. Please try again.`,W=class extends Error{constructor(e,t,n){super(t),this.name=`SupportApiError`,this.code=e,this.status=n}};async function ne(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 re(e){if(e instanceof W)return e;let t=e?.response;if(!t)return new W(`network`,U);let n=await ne(t.data);return new W(typeof n?.code==`string`&&n.code?n.code:`unknown`,typeof n?.detail==`string`&&n.detail.trim()?n.detail:U,t.status)}async function G(e){try{return(await e()).data}catch(e){throw await re(e)}}function K(e,t,n){n!=null&&String(n).trim()!==``&&e.append(t,String(n))}function q(e,t,n,r){(n??[]).forEach((n,i)=>{let a=n?.name||`${r}-${i+1}.png`;e.append(t,n,a)})}var ie=20;function ae(e,t){return(e??[]).map((e,n)=>e?.name||`${t}-${n+1}.png`).join(`|`)}function oe(e){return e instanceof W&&typeof e.status==`number`&&e.status>=400&&e.status<=499&&e.status!==408&&e.status!==429}function se(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<=ie)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 oe(t)&&i.delete(e),t}finally{let t=a.get(e)-1;t>0?a.set(e,t):a.delete(e)}}return{getConfig:()=>G(()=>e.get(`${n}/settings`)),listTickets:({status:t,search:r,page:i,pageSize:a}={})=>{let o=new URLSearchParams;K(o,`status`,t),K(o,`search`,r?.trim()),K(o,`page`,i),K(o,`pageSize`,a);let s=o.toString();return G(()=>e.get(`${n}/tickets${s?`?${s}`:``}`))},getTicketCounts:()=>G(()=>e.get(`${n}/tickets/counts`)),getTicket:t=>G(()=>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??``),K(d,`pageUrl`,a),K(d,`userAgent`,o),K(d,`appVersion`,c),q(d,`files`,l,`file`),q(d,`screenshots`,u,`screenshot`),s([`ticket`,t,r,i,ae(l,`file`),ae(u,`screenshot`)].join(`\0`),t=>G(()=>e.post(`${n}/tickets`,d,{headers:{"Idempotency-Key":t}})))},getSuggestions:async(t,{signal:r}={})=>{try{return await G(()=>e.get(`${n}/suggestions`,{params:{subject:t},signal:r}))}catch(e){if(e instanceof W&&e.status===404)return[];throw e}},reply:(t,{body:n,files:i,screenshots:a})=>{let o=new FormData;return o.append(`body`,n??``),q(o,`files`,i,`file`),q(o,`screenshots`,a,`screenshot`),s([`reply`,t,n,ae(i,`file`),ae(a,`screenshot`)].join(`\0`),n=>G(()=>e.post(`${r(t)}/replies`,o,{headers:{"Idempotency-Key":n}})))},reopen:t=>G(()=>e.post(`${r(t)}/reopen`)),cancel:t=>G(()=>e.post(`${r(t)}/cancel`)),rate:(t,{satisfaction:n,comment:i})=>{let a={satisfaction:n};return i!=null&&i.trim()!==``&&(a.comment=i.trim()),G(()=>e.post(`${r(t)}/rating`,a))},fetchAttachment:t=>G(()=>e.get(`${n}/attachments/${encodeURIComponent(t)}`,{responseType:`blob`})),confirmAction:t=>G(()=>e.post(`${n}/actions/confirm`,{token:t}))}}var ce=3e4,le=e(null);function ue(){let e=n(le);if(!e)throw Error(`Support components and hooks must be used inside <SupportProvider>.`);return e}function J(){return ue().client}function de(){return ue().timeZone}function fe(){return ue().renderTime??null}function Y(e,t){let n=ue().labels?.[e];return a(()=>n?{...t,...n}:t,[n,t])}function pe(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 me(){let{loadConfig:e}=ue(),{data:t,loading:n,error:r,reload:i}=pe(e,`config`);return{config:t,loading:n,error:r,reload:i}}function he(e={}){let t=J(),{status:n,search:r,page:i,pageSize:a}=e,{data:o,loading:s,error:c,reload:l}=pe(()=>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 ge(){let e=J(),{data:t,loading:n,error:r,reload:i}=pe(()=>e.getTicketCounts(),`ticket-counts`);return{counts:t,loading:n,error:r,reload:i}}function _e(e){let n=J(),{data:i,loading:a,error:s,reload:c,setData:l}=pe(()=>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,ce))},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 ve({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 re(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 X({iso:e,className:t}){let n=fe(),r=de();return n?n(e):/* @__PURE__ */ V(`time`,{dateTime:e,className:t,children:L(e,{timeZone:r})})}function Z(e,t){return String(e).replace(/[{]([A-Za-z0-9_]+)[}]/g,(e,n)=>n in t?String(t[n]):e)}var Q={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 $(e,t,n=Q.offline){if(e instanceof W){if(e.code===`network`)return n;if(e.code!==`unknown`)return e.message}return t}var ye={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.`},be={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`},xe=`article_not_found`,Se=`{date}`;function Ce({template:e,iso:t}){let n=e.indexOf(Se);return n===-1?/* @__PURE__ */ H(B,{children:[e,` `,/* @__PURE__ */ V(X,{iso:t})]}):/* @__PURE__ */ H(B,{children:[e.slice(0,n),/* @__PURE__ */ V(X,{iso:t}),e.slice(n+6)]})}function we({client:e,slug:n,onBack:i}){let a=Y(`helpArticle`,be),c=Y(`shared`,Q),[u,d]=s({article:null,loading:!0,error:null}),p=o(null),m=t(()=>{p.current?.abort();let t=new AbortController;p.current=t,d({article:null,loading:!0,error:null}),e.get(n,{signal:t.signal}).then(e=>{t.signal.aborted||d({article:e,loading:!1,error:null})},e=>{t.signal.aborted||d({article:null,loading:!1,error:e})})},[e,n]);r(()=>(m(),()=>p.current?.abort()),[m]);let{article:h,loading:g,error:_}=u,v=_?.code===xe;return/* @__PURE__ */ H(`section`,{className:`d-flex flex-column gap-3 min-w-0`,"aria-busy":g||void 0,children:[i&&/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,leftIcon:`arrow-left`,onClick:i,className:`align-self-start`,children:a.back}),g&&/* @__PURE__ */ V(A,{height:160}),v&&/* @__PURE__ */ V(b,{variant:`card`,icon:`search`,title:a.notFoundTitle}),_&&!v&&/* @__PURE__ */ H(l,{tone:`danger`,children:[$(_,a.loadError,c.offline),` `,/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,onClick:m,children:a.retry})]}),h&&/* @__PURE__ */ H(`article`,{className:`d-flex flex-column gap-3`,children:[/* @__PURE__ */ V(`h2`,{className:`h4 mb-0`,children:h.title}),/* @__PURE__ */ H(`div`,{className:`d-flex flex-wrap gap-3 wui-text-sm text-body-secondary`,children:[h.publishedDateTimeUtc!=null&&/* @__PURE__ */ V(`span`,{children:/* @__PURE__ */ V(Ce,{template:a.published,iso:h.publishedDateTimeUtc})}),/* @__PURE__ */ V(`span`,{children:/* @__PURE__ */ V(Ce,{template:a.updated,iso:h.updatedDateTimeUtc})})]}),/* @__PURE__ */ V(D,{value:h.bodyMarkdown})]})]})}function Te(e,t){let[n,i]=s(e);return r(()=>{let n=setTimeout(()=>i(e),t);return()=>clearTimeout(n)},[e,t]),n}var Ee=10,De=300,Oe=2;function ke(){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 Ae(e){let[n,i]=s({data:null,loading:!0,error:null}),[a,o]=s({page:1,pageSize:Ee}),[c,l]=s({data:null,loading:!0,error:null}),[u,d]=s(``),[f,p]=s({term:``,data:[],loading:!1,error:null}),m=Te(u.trim(),De),h=ke(),g=ke(),_=ke(),{page:v,pageSize:y}=a,b=n.data?.searchAvailable===!0,x=b&&m.length>=Oe,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 je({client:e,onOpen:t,linkTo:n}){let r=Y(`helpCentre`,ye),i=Y(`shared`,Q),{settings:a,articles:o,search:s}=Ae(e),c=s.active,u=c?s.results:o.items,d=c?s.loading:o.loading,p=c?s.error:o.error,m=c?s.reload:o.reload,h=(e,n)=>{t&&(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),t(n)))},g=[{key:`title`,label:r.columnArticle,render:e=>/* @__PURE__ */ H(`div`,{className:`d-flex flex-column min-w-0`,children:[n?/* @__PURE__ */ V(E,{href:n(e.slug),animation:`none`,className:`fw-semibold text-break`,onClick:t=>h(t,e.slug),children:e.title}):/* @__PURE__ */ V(f,{variant:`link`,size:`sm`,className:`fw-semibold text-break text-start p-0`,onClick:()=>t?.(e.slug),children:e.title}),/* @__PURE__ */ V(`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__ */ V(X,{iso:e.updatedDateTimeUtc})}],_={page:o.page,totalPages:Math.max(1,o.totalPages),pageSize:o.pageSize,total:o.totalCount,setPage:o.setPage,setPageSize:o.setPageSize};return/* @__PURE__ */ H(`section`,{className:`d-flex flex-column gap-3 min-w-0`,"aria-labelledby":`help-centre-title`,children:[/* @__PURE__ */ V(`h2`,{id:`help-centre-title`,className:`h5 mb-0`,children:r.heading}),a.error&&/* @__PURE__ */ H(l,{tone:`warning`,children:[$(a.error,r.settingsError,i.offline),` `,/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,onClick:a.reload,children:r.retry})]}),s.enabled&&/* @__PURE__ */ V(k,{value:s.query,onChange:s.setQuery,placeholder:r.searchPlaceholder,ariaLabel:r.searchLabel}),p&&/* @__PURE__ */ H(l,{tone:`danger`,children:[$(p,r.listError,i.offline),` `,/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,onClick:m,children:r.retry})]}),/* @__PURE__ */ V(v,{columns:g,rows:u,loading:d,skeletonRows:4,ariaLabel:r.tableLabel,stackOnMobile:!0,pagination:c?void 0:_,empty:c?/* @__PURE__ */ V(b,{variant:`table`,icon:`search`,title:r.noMatchTitle,description:r.noMatchText}):/* @__PURE__ */ V(b,{variant:`table`,icon:`message-square`,title:r.emptyTitle,description:r.emptyText})})]})}function Me(e){return(e?.allowedContentTypes??[]).join(`,`)}function Ne(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 Pe(e,t,n=Q){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:Z(n.attachMany,{count:i});for(let e of r){let t=e.name||n.thisFile;if(!Ne(e.type,o))return Z(n.typeNotAccepted,{name:t});if(a>0&&e.size>a)return Z(n.tooLarge,{name:t,size:R(a)})}return null}var Fe=(e,t)=>e===1?t.attachOne:Z(t.attachMany,{count:e});function Ie(e){return`${e.name}|${e.size}|${e.lastModified}`}function Le(e,t,n,r=Q){let i=n?.maxAttachmentsPerMessage??0,a=new Set(e.map(Ie)),o=[],s=null;for(let e of t){let t=Ie(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?Fe(i,r):null)??Pe(l,n,r)??(s?Z(r.alreadyAttached,{name:s}):``)}}function Re(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 ze=80;function Be(e,t){let n=Math.min(t,ze),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 Ve({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__ */ V(x,{id:e,label:t,optional:!0,multiple:!0,value:n,onChange:r,accept:Me(i),maxSizeMb:s,validate:!1,error:a||void 0})}var He={title:`These may already answer your question`};function Ue({items:e}){let t=Y(`suggestedAnswers`,He);return e.length===0?null:/* @__PURE__ */ V(p,{variant:`filled`,padding:`sm`,title:t.title,children:/* @__PURE__ */ V(`ul`,{className:`list-unstyled mb-0 d-flex flex-column gap-2`,children:e.map(e=>/* @__PURE__ */ H(`li`,{children:[/* @__PURE__ */ V(`div`,{className:`fw-semibold`,children:e.title}),/* @__PURE__ */ V(`div`,{className:`small text-body-secondary`,children:e.summary})]},e.title))})})}var We={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.`},Ge=500,Ke=3,qe=5;function Je(e,t){return t&&e.includes(t)?t:``}function Ye({id:e,config:t,defaultCategory:n,initialValues:i,onValuesChange:a,extraFiles:o=[],onSubmit:c,onBusyChange:u,children:d}){let f=Y(`ticketForm`,We),p=Y(`shared`,Q),m=t?.categories??[],h=t?.subjectMaxLength??1/0,[g,_]=s(()=>i?.category??Je(m,n)),[v,y]=s(i?.body??``),[b,x]=s(()=>i?.subject||Be(i?.body??``,h)),[S,C]=s(()=>{let e=(i?.subject??``).trim();return e!==``&&e!==Be(i?.body??``,h)}),[w,E]=s(i?.files??[]),[D,O]=s({}),[k,A]=s(``),j=J(),[M,N]=s(``),[F,I]=s([]),L=Te(b.trim(),Ge);r(()=>{a?.({category:g,subject:b,body:v,files:w})},[g,b,v,w,a]),r(()=>{N(L)},[L]),r(()=>{if(M.length<Ke){I([]);return}let e=!0,t=new AbortController;return I([]),j.getSuggestions(M,{signal:t.signal}).then(t=>{e&&I(Array.isArray(t)?t.slice(0,qe):[])},()=>{e&&I([])}),()=>{e=!1,t.abort()}},[j,M]);let R=e=>{E(e),O(n=>({...n,files:Pe([...o,...e],t,p)??void 0}))},z=e=>{let t=Re(e);t.length>0&&R([...w,...t])},B=e=>{let t=e.target.value;y(t),S||x(Be(t,h)),D.body&&O(e=>({...e,body:t.trim()?void 0:f.bodyRequired}))},te=e=>{let t=e.target.value;x(t),C(t.trim()!==``)};function U(){let e={};v.trim()||(e.body=f.bodyRequired);let n=Pe([...o,...w],t,p);return n&&(e.files=n),O(e),Object.keys(e).length===0}async function W(e){if(e.preventDefault(),A(``),U()){u?.(!0);try{await c({category:g,subject:b.trim()||Be(v,h),body:v.trim(),files:w})}catch(e){A($(e,f.sendFailed,p.offline))}finally{u?.(!1)}}}return/* @__PURE__ */ H(`form`,{id:e,onSubmit:W,noValidate:!0,className:`d-flex flex-column gap-3`,children:[k&&/* @__PURE__ */ V(l,{tone:`danger`,children:k}),/* @__PURE__ */ V(P,{id:`${e}-body`,label:f.messageLabel,required:!0,rows:6,maxLength:t?.bodyMaxLength,showCount:!0,placeholder:f.messagePlaceholder,value:v,onChange:B,onPaste:z,helperText:f.messageHint,error:D.body}),/* @__PURE__ */ V(T,{id:`${e}-subject`,label:f.subjectLabel,maxLength:t?.subjectMaxLength,showCount:!0,placeholder:f.subjectPlaceholder,helperText:f.subjectHint,value:b,onChange:te,onBlur:()=>N(b.trim())}),/* @__PURE__ */ V(Ue,{items:F}),/* @__PURE__ */ V(ee,{id:`${e}-category`,label:f.categoryLabel,value:g,onChange:_,options:m.map(e=>({value:e,label:e})),placeholder:f.categoryPlaceholder,helperText:f.categoryHint,error:D.category}),d,/* @__PURE__ */ V(Ve,{id:`${e}-files`,files:w,onChange:R,config:t,error:D.files})]})}var Xe={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.`},Ze=`supportCapture`,Qe={zIndex:`var(--wui-z-fixed)`,bottom:0,insetInlineEnd:0},$e={zIndex:`var(--wui-z-fixed)`},et={maxWidth:`20rem`},tt=e=>e.dataset?.[Ze]===`exclude`||e.matches?.(`.modal-backdrop`)?!1:!(e.matches?.(`.modal`)&&e.querySelector?.(`[data-support-capture="exclude"]`)),nt=()=>new Promise(e=>requestAnimationFrame(()=>e()));async function rt(e){let t=await te(document.body,{filter:tt,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 it({t:e,file:t,failed:n,disabled:i,hintId:a,controlRef:o,onAdd:c,onRemove:u}){let[d,p]=s(null);return r(()=>{if(!t)return;let e=URL.createObjectURL(t);return p(e),()=>URL.revokeObjectURL(e)},[t]),/* @__PURE__ */ H(`div`,{className:`d-flex flex-column gap-2`,children:[/* @__PURE__ */ V(`span`,{className:`wui-text-sm fw-semibold`,children:e.screenshotTitle}),t&&d&&/* @__PURE__ */ V(`img`,{src:d,alt:e.screenshotLabel,className:`d-block w-100 border rounded`,style:et}),/* @__PURE__ */ V(`div`,{ref:o,className:`d-flex flex-wrap gap-2`,children:t?/* @__PURE__ */ H(B,{children:[/* @__PURE__ */ V(f,{variant:`outline`,size:`sm`,leftIcon:`refresh-cw`,onClick:c,disabled:i,"aria-describedby":a,children:e.retake}),/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,leftIcon:`x`,onClick:u,disabled:i,children:e.removeScreenshot})]}):/* @__PURE__ */ V(f,{variant:`outline`,size:`sm`,leftIcon:`camera`,onClick:c,disabled:i,"aria-describedby":a,children:e.addScreenshot})}),/* @__PURE__ */ V(`span`,{id:a,className:`wui-text-sm text-body-secondary`,children:e.screenshotNote}),n&&/* @__PURE__ */ V(l,{tone:`info`,children:e.screenshotFailed})]})}function at({label:e=`Report an issue`,floating:t=!1,compact:n=!1,defaultCategory:a=`Bug report`,appVersion:c,getTicketHref:u,onOpenTicket:d,onCreated:p,className:m,style:h}){let g=Y(`reportIssue`,Xe),_=Y(`shared`,Q),v=J(),{config:y,error:b}=me(),x=`support-report-${i().replace(/[^a-zA-Z0-9-]/g,``)}`,[C,w]=s(!1),[T,E]=s(!1),[D,k]=s(null),[ee,A]=s(!1),[j,M]=s(!1),[N,P]=s(null),[F,I]=s(null),L=o(null),R=o(!1);r(()=>{!T&&R.current&&(R.current=!1,L.current?.querySelector(`button`)?.focus())},[T]);function z(){P(null),k(null),A(!1),I(null),w(!0)}async function te(){E(!0),A(!1),await nt(),await nt();try{k(await rt(g.captureEmpty))}catch{k(null),A(!0)}finally{R.current=!0,E(!1)}}let U=()=>{j||(w(!1),k(null),A(!1),P(null),I(null))};async function W(e){let t=await v.createTicket({...e,pageUrl:window.location.href,userAgent:navigator.userAgent,appVersion:c,screenshots:D?[D]:[]});P(t),k(null),p?.(t)}let ne=!N&&(!!D||!!F&&(F.subject.trim()!==``||F.body.trim()!==``||F.files.length>0)),re=N&&u?u(N.id):void 0,G=N&&(re||d)?/* @__PURE__ */ V(f,{href:re,onClick:re?void 0:()=>{w(!1),P(null),d(N)},children:g.viewTicket}):null,K=N?/* @__PURE__ */ H(`div`,{className:`d-flex justify-content-end gap-2 w-100`,children:[/* @__PURE__ */ V(f,{variant:`soft`,onClick:U,children:g.close}),G]}):/* @__PURE__ */ H(`div`,{className:`d-flex justify-content-end gap-2 w-100`,children:[/* @__PURE__ */ V(f,{variant:`soft`,onClick:U,disabled:j,children:g.cancel}),/* @__PURE__ */ V(f,{type:`submit`,form:x,loading:j,disabled:!y,children:g.submit})]}),q=n?/* @__PURE__ */ V(S,{icon:`bug`,label:e,order:`secondary`,size:`sm`,variant:`soft`,stacked:t,className:t?m:void 0,style:t?h:void 0,disabled:T,onClick:z,"aria-haspopup":`dialog`}):/* @__PURE__ */ V(f,{leftIcon:`bug`,variant:t?`solid`:`outline`,disabled:T,onClick:z,"aria-haspopup":`dialog`,children:e});return/* @__PURE__ */ H(B,{children:[t&&n?q:/* @__PURE__ */ V(`span`,{"data-support-capture":`exclude`,className:[t?`position-fixed m-3`:`d-inline-block`,m].filter(Boolean).join(` `),style:t?{...Qe,...h}:h,children:q}),T&&/* @__PURE__ */ H(`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:$e,children:[/* @__PURE__ */ V(`span`,{className:`spinner-border spinner-border-sm`,"aria-hidden":`true`}),g.takingScreenshot]}),/* @__PURE__ */ V(O,{open:C,size:`lg`,title:g.title,subtitle:g.subtitle,headerIcon:`bug`,confirmDiscard:g.confirmDiscard,dirty:ne&&!j,onClose:U,footer:K,"data-support-capture":`exclude`,children:N?/* @__PURE__ */ V(l,{tone:`success`,role:`status`,title:Z(g.createdTitle,{number:N.number}),children:g.createdText}):y?/* @__PURE__ */ V(Ye,{id:x,config:y,defaultCategory:a,initialValues:F,onValuesChange:I,extraFiles:D?[D]:[],onSubmit:W,onBusyChange:M,children:/* @__PURE__ */ V(it,{t:g,file:D,failed:ee,disabled:j||T,hintId:`${x}-screenshot-hint`,controlRef:L,onAdd:te,onRemove:()=>k(null)})}):/* @__PURE__ */ V(l,{tone:b?`danger`:`info`,children:b?$(b,g.configError,_.offline):g.loading})})]})}var ot={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 st({open:e,onClose:t,onCreated:n,config:r,defaultCategory:a,appVersion:o}){let c=Y(`newTicketModal`,ot),l=J(),u=`support-new-${i().replace(/[^a-zA-Z0-9-]/g,``)}`,[d,p]=s(!1),[m,h]=s(null),g=!!m&&(m.subject.trim()!==``||m.body.trim()!==``||m.files.length>0);async function _(e){n(await l.createTicket({...e,userAgent:typeof navigator>`u`?void 0:navigator.userAgent,appVersion:o}))}return/* @__PURE__ */ V(O,{open:e,size:`lg`,title:c.title,subtitle:c.subtitle,headerIcon:`message-square`,confirmDiscard:c.confirmDiscard,dirty:g&&!d,onClose:()=>{d||t()},footer:/* @__PURE__ */ H(`div`,{className:`d-flex justify-content-end gap-2 w-100`,children:[/* @__PURE__ */ V(f,{variant:`soft`,onClick:t,disabled:d,children:c.cancel}),/* @__PURE__ */ V(f,{type:`submit`,form:u,loading:d,children:c.send})]}),children:e&&/* @__PURE__ */ V(Ye,{id:u,config:r,defaultCategory:a,onSubmit:_,onBusyChange:p,onValuesChange:h})})}var ct={Open:`info`,InProgress:`info`,WaitingOnCustomer:`warning`,Resolved:`success`,Closed:`success`,Cancelled:`neutral`};function lt(e){return ct[e]??`neutral`}var ut={loading:`Loading {name}`,failed:`Could not load this file. Click to try again.`},dt=6e4,ft=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`application/pdf`];function pt({attachment:e}){let t=Y(`attachmentThumb`,ut),n=J(),[r,i]=s(!1),[a,o]=s(!1);async function c(){i(!0),o(!1);let t=ft.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),dt),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)?R(e.sizeBytes):`-`;return/* @__PURE__ */ H(B,{children:[/* @__PURE__ */ V(m,{leadingIcon:a?`x-circle`:`paperclip`,label:r?/* @__PURE__ */ H(B,{children:[/* @__PURE__ */ V(j,{size:`sm`,label:Z(t.loading,{name:e.fileName})}),` `,e.fileName]}):e.fileName,onClick:c,disabled:r,"aria-busy":r||void 0,title:`${e.fileName}, ${l}`}),a&&/* @__PURE__ */ V(`span`,{role:`status`,className:`wui-text-xs text-danger align-self-center`,children:t.failed})]})}var mt={conversation:`Conversation`,you:`You`,supportTeam:`Support team`,supportBadge:`Support`},ht={whiteSpace:`pre-wrap`,overflowWrap:`anywhere`};function gt({messages:e}){let t=Y(`messageThread`,mt);return/* @__PURE__ */ V(`ol`,{className:`list-unstyled d-flex flex-column gap-3 mb-0`,"aria-label":t.conversation,children:e.map(e=>{let n=/* @__PURE__ */ V(X,{iso:e.createdDateTimeUtc,className:`wui-text-xs text-body-secondary text-nowrap`});if(e.authorKind===`System`)return/* @__PURE__ */ H(`li`,{className:`text-center wui-text-xs text-body-secondary`,"data-author":`system`,children:[/* @__PURE__ */ V(`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__ */ H(`li`,{className:`d-flex align-items-start gap-2${r?` flex-row-reverse`:``}`,"data-author":r?`customer`:`agent`,children:[/* @__PURE__ */ V(u,{name:i,size:32,tone:r?`neutral`:`primary`}),/* @__PURE__ */ H(p,{className:`flex-grow-1 border`,padding:`sm`,variant:r?`flat`:`accent`,style:{minWidth:0},children:[/* @__PURE__ */ H(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2 mb-2`,children:[/* @__PURE__ */ H(`span`,{className:`d-inline-flex flex-wrap align-items-center gap-2 fw-semibold wui-text-sm text-break`,children:[i,!r&&/* @__PURE__ */ V(d,{tone:`primary`,children:t.supportBadge})]}),n]}),/* @__PURE__ */ V(`div`,{className:`wui-text-sm`,style:ht,children:e.body}),e.attachments?.length>0&&/* @__PURE__ */ V(`div`,{className:`d-flex flex-wrap gap-2 mt-2`,children:e.attachments.map(e=>/* @__PURE__ */ V(pt,{attachment:e},e.id))})]})]},e.id)})})}var _t={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 vt({satisfaction:e,comment:t,canRate:n=!1,commentMaxLength:r,onRate:a}){let o=Y(`ratingPanel`,_t),c=Y(`shared`,Q),u=i(),[d,m]=s(``),[h,g]=s(null),[_,v]=s(``);if(e)return/* @__PURE__ */ H(l,{tone:e===`Satisfied`?`success`:`info`,role:`status`,children:[e===`Satisfied`?o.solved:o.notSolved,t?/* @__PURE__ */ H(`span`,{className:`d-block mt-1`,children:[o.yourComment,` `,t]}):null]});if(!n)return null;async function y(e){v(``),g(e);try{await a({satisfaction:e,comment:d})}catch(e){v($(e,o.sendFailed,c.offline))}finally{g(null)}}return/* @__PURE__ */ V(p,{padding:`sm`,className:`border`,title:o.heading,children:/* @__PURE__ */ H(`div`,{className:`d-flex flex-column gap-2`,children:[_&&/* @__PURE__ */ V(l,{tone:`danger`,children:_}),/* @__PURE__ */ V(P,{id:`${u}-comment`,label:o.commentLabel,rows:2,maxLength:r,value:d,onChange:e=>m(e.target.value),helperText:o.commentHint}),/* @__PURE__ */ H(`div`,{className:`d-flex flex-wrap gap-2`,children:[/* @__PURE__ */ V(f,{variant:`outline`,leftIcon:`check-circle`,loading:h===`Satisfied`,disabled:h!==null,onClick:()=>y(`Satisfied`),children:o.yes}),/* @__PURE__ */ V(f,{variant:`outline`,leftIcon:`x-circle`,loading:h===`Unsatisfied`,disabled:h!==null,onClick:()=>y(`Unsatisfied`),children:o.no})]})]})})}var yt={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 bt({onSend:e,config:t,reopens:n=!1}){let r=Y(`replyBox`,yt),a=Y(`shared`,Q),o=i(),[u,d]=s(``),[p,g]=s([]),[_,v]=s(``),[y,b]=s(``),[x,S]=s(!1),C=e=>{let n=Le(p,e,t,a);g(n.files),v(n.notice)},w=e=>{let n=p.filter((t,n)=>n!==e);g(n),v(Pe(n,t,a)??``)},T=e=>{let t=Re(e);t.length>0&&C(t)};async function E(n){n.preventDefault();let i=u.trim();if(!i){b(r.emptyReply);return}let o=Pe(p,t,a);if(o)v(o);else{b(``),S(!0);try{await e({body:i,files:p}),d(``),g([]),v(``)}catch(e){b($(e,r.sendFailed,a.offline))}finally{S(!1)}}}let D=y||_;return/* @__PURE__ */ H(`form`,{onSubmit:E,noValidate:!0,className:`d-flex flex-column gap-2 flex-grow-1 min-w-0`,"aria-label":r.formLabel,children:[D&&/* @__PURE__ */ V(l,{tone:`danger`,children:D}),/* @__PURE__ */ V(P,{id:`${o}-body`,label:r.replyLabel,rows:2,autoGrow:!0,maxLength:t?.bodyMaxLength,value:u,onChange:e=>{d(e.target.value),b(``)},onPaste:T,helperText:n?r.hintReopens:r.hint,required:!0}),p.length>0&&/* @__PURE__ */ V(h,{label:r.attachedFiles,children:p.map((e,t)=>/* @__PURE__ */ V(m,{leadingIcon:`paperclip`,label:e.name,removeLabel:Z(r.removeFile,{name:e.name}),onRemove:()=>w(t)},Ie(e)))}),/* @__PURE__ */ H(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2`,children:[/* @__PURE__ */ V(c,{iconVariant:`bulk`,icon:`paperclip`,label:r.attach,multiple:t?.maxAttachmentsPerMessage!==1,accept:Me(t),onFiles:C}),/* @__PURE__ */ V(f,{type:`submit`,leftIcon:`send`,loading:x,children:r.send})]})]})}var xt={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 St({ticketId:e,onBack:t,onChanged:n,onOpenTicket:r}){let{config:i}=me(),a=Y(`ticketDetail`,xt),o=Y(`shared`,Q),c=de(),u=fe(),{ticket:d,loading:m,error:h,reload:_,reply:v,reopen:b,cancel:x,rate:S}=_e(e),[T,E]=s(!1),[D,O]=s(!1),[k,ee]=s(!1),[j,N]=s(``),P=async e=>{let t=await e();return n?.(),t};async function F(){N(``),E(!0);try{await P(b)}catch(e){N($(e,a.reopenFailed,o.offline))}finally{E(!1)}}async function I(){N(``),ee(!0);try{await P(x)}catch(e){N($(e,a.withdrawFailed,o.offline))}finally{ee(!1),O(!1)}}let L=/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,leftIcon:`arrow-left`,onClick:t,className:`align-self-start`,children:a.back});if(!d)return/* @__PURE__ */ H(`section`,{className:`d-flex flex-column gap-3`,"aria-busy":m||void 0,children:[L,h?/* @__PURE__ */ H(l,{tone:`danger`,children:[$(h,a.loadError,o.offline),` `,/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,onClick:_,children:a.retry})]}):/* @__PURE__ */ V(A,{height:160})]});let R=lt(d.status),B=[{key:`status`,label:a.fieldStatus,value:d.statusLabel?/* @__PURE__ */ V(M,{label:d.statusLabel,tone:R}):`-`},{key:`category`,label:a.fieldCategory,value:d.category||`-`},{key:`ticket`,label:a.fieldTicket,value:d.number},{key:`opened`,label:a.fieldOpened,value:/* @__PURE__ */ V(X,{iso:d.createdDateTimeUtc})},{key:`updated`,label:a.fieldUpdated,value:/* @__PURE__ */ V(X,{iso:d.updatedDateTimeUtc})}];return/* @__PURE__ */ H(`section`,{className:`d-flex flex-column gap-3`,"aria-labelledby":`support-ticket-${d.id}`,children:[L,/* @__PURE__ */ H(`div`,{className:`row g-3`,children:[/* @__PURE__ */ H(`div`,{className:`col-12 col-lg-8 d-flex flex-column gap-3`,children:[/* @__PURE__ */ H(`header`,{className:`d-flex flex-column gap-2`,children:[/* @__PURE__ */ H(`div`,{className:`d-flex flex-wrap align-items-center gap-2`,children:[/* @__PURE__ */ V(`h2`,{id:`support-ticket-${d.id}`,className:`h5 mb-0 text-break`,children:d.subject}),d.statusLabel&&/* @__PURE__ */ V(M,{label:d.statusLabel,tone:R})]}),/* @__PURE__ */ H(`ul`,{className:`list-unstyled d-flex flex-wrap gap-3 mb-0 wui-text-sm text-body-secondary`,"aria-label":a.summaryLabel,children:[d.number&&/* @__PURE__ */ H(`li`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ V(w,{variant:`bulk`,name:`receipt-text`,size:16}),d.number]}),d.category&&/* @__PURE__ */ H(`li`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ V(w,{variant:`bulk`,name:`folder-2`,size:16}),d.category]}),/* @__PURE__ */ H(`li`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ V(w,{variant:`bulk`,name:`calendar-1`,size:16}),a.openedLabel,` `,/* @__PURE__ */ V(X,{iso:d.createdDateTimeUtc})]})]}),u===null&&/* @__PURE__ */ V(`p`,{className:`wui-text-xs text-body-secondary mb-0`,children:Z(a.timeZoneNote,{zone:z(c)})})]}),j&&/* @__PURE__ */ V(l,{tone:`danger`,children:j}),d.mergedInto&&/* @__PURE__ */ H(l,{tone:`info`,role:`status`,children:[Z(a.mergedText,{number:d.mergedInto.number}),` `,r&&/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,onClick:()=>r(d.mergedInto.id),children:Z(a.openMerged,{number:d.mergedInto.number})})]}),d.canReopen&&/* @__PURE__ */ V(l,{tone:`success`,role:`status`,children:a.resolvedHint}),d.status===`WaitingOnCustomer`&&/* @__PURE__ */ V(l,{tone:`warning`,role:`status`,children:a.waitingHint}),!d.canReopen&&/* @__PURE__ */ V(`p`,{className:`wui-text-sm text-body-secondary mb-0`,children:a.openHint}),d.canReopen&&/* @__PURE__ */ V(f,{variant:`soft`,leftIcon:`history`,loading:T,onClick:F,className:`align-self-start`,children:a.reopen}),d.canCancel&&/* @__PURE__ */ V(f,{variant:`soft`,onClick:()=>O(!0),className:`align-self-start`,children:a.withdraw}),/* @__PURE__ */ V(g,{open:D,title:a.withdrawTitle,description:a.withdrawMessage,confirmLabel:a.withdrawConfirm,cancelLabel:a.withdrawCancel,tone:`danger`,loading:k,onConfirm:I,onClose:()=>O(!1)}),/* @__PURE__ */ V(vt,{satisfaction:d.satisfaction,comment:d.satisfactionComment,canRate:d.canRate,commentMaxLength:i?.satisfactionCommentMaxLength,onRate:e=>P(()=>S(e))}),/* @__PURE__ */ V(gt,{messages:d.messages??[]}),d.mergedTickets?.length>0&&/* @__PURE__ */ H(`section`,{"aria-labelledby":`support-merged-${d.id}`,className:`d-flex flex-column gap-1`,children:[/* @__PURE__ */ V(`h3`,{id:`support-merged-${d.id}`,className:`h6 mb-0`,children:a.merged}),/* @__PURE__ */ V(`ul`,{className:`list-unstyled d-flex flex-column gap-1 mb-0 wui-text-sm`,children:d.mergedTickets.map(e=>/* @__PURE__ */ V(`li`,{children:r?/* @__PURE__ */ H(f,{variant:`ghost`,size:`sm`,onClick:()=>r(e.id),children:[e.number,`: `,e.subject]}):`${e.number}: ${e.subject}`},e.id))})]}),!d.mergedInto&&/* @__PURE__ */ V(C,{sticky:!0,align:`start`,children:/* @__PURE__ */ V(bt,{config:i,reopens:d.canReopen,onSend:e=>P(()=>v(e))})})]}),/* @__PURE__ */ V(`aside`,{"aria-label":a.detailsLabel,className:`col-12 col-lg-4`,children:/* @__PURE__ */ H(p,{padding:`sm`,className:`border`,children:[/* @__PURE__ */ V(`h3`,{className:`h6`,children:a.detailsTitle}),/* @__PURE__ */ V(y,{columns:1,items:B})]})})]})]})}var Ct=`ticket`;function wt(){return typeof window>`u`?null:new URLSearchParams(window.location.search).get(Ct)}function Tt(e){if(typeof window>`u`)return e?`?${Ct}=${encodeURIComponent(e)}`:`?`;let t=new URL(window.location.href);return e?t.searchParams.set(Ct,e):t.searchParams.delete(Ct),`${t.pathname}${t.search}${t.hash}`}function Et(e){if(typeof window>`u`)return;let t=Tt(e);t!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,t)}var Dt={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.`},Ot=[`tabs`,`select`,`none`];function kt({tickets:e,loading:t,error:n,onRetry:r,onOpen:i,status:a,onStatusChange:o,statusFilter:s=`tabs`,counts:u,search:d,onSearchChange:p,pagination:m}){let h=Y(`ticketList`,Dt),g=Y(`shared`,Q);F(`SupportCenter`,`statusFilter`,s,Ot);let _=[{key:`all`,label:h.tabAll,countKey:`total`},{key:`Open`,label:h.tabOpen,countKey:`open`},{key:`NeedsReply`,label:h.tabNeedsReply,countKey:`needsReply`},{key:`Resolved`,label:h.tabResolved,countKey:`resolved`},{key:`Withdrawn`,label:h.tabWithdrawn,countKey:`withdrawn`}],y=_.map(({key:e,label:t,countKey:n})=>{let r=u?.[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:h.columnSubject,render:e=>/* @__PURE__ */ H(`div`,{className:`d-flex flex-column`,style:{minWidth:0},children:[/* @__PURE__ */ V(E,{href:Tt(e.id),animation:`none`,className:`fw-semibold text-break`,onClick:t=>x(t,e.id),children:e.subject}),/* @__PURE__ */ H(`span`,{className:`wui-text-xs text-body-secondary`,children:[e.number,`, `,e.category]})]})},{key:`status`,label:h.columnStatus,render:e=>e.statusLabel?/* @__PURE__ */ V(M,{label:e.statusLabel,tone:lt(e.status)}):`-`},{key:`messageCount`,label:h.columnMessages,cellClassName:`wui-text-sm text-body-secondary`,render:e=>e.messageCount},{key:`updatedDateTimeUtc`,label:h.columnLastUpdate,cellClassName:`wui-text-sm text-body-secondary text-nowrap`,render:e=>/* @__PURE__ */ V(X,{iso:e.updatedDateTimeUtc})}];return/* @__PURE__ */ H(`div`,{className:`d-flex flex-column gap-3`,children:[n&&/* @__PURE__ */ H(l,{tone:`danger`,children:[$(n,h.loadError,g.offline),` `,/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,onClick:r,children:h.retry})]}),/* @__PURE__ */ H(`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__ */ V(ee,{label:h.statusSelect,value:a,onChange:o,options:y,fieldClassName:`flex-shrink-0`}):/* @__PURE__ */ V(N,{tabs:_.map(({key:e,label:t,countKey:n})=>({key:e,label:t,count:u?.[n]})),value:a,onChange:o,ariaLabel:h.filterByStatus,overflow:`menu`,className:`flex-grow-1`}),/* @__PURE__ */ V(k,{value:d,onChange:p,placeholder:h.searchPlaceholder,ariaLabel:h.searchLabel})]}),/* @__PURE__ */ V(v,{columns:S,rows:e,loading:t,skeletonRows:4,ariaLabel:h.tableLabel,rowActionsLabel:h.actions,rowActions:e=>/* @__PURE__ */ V(c,{icon:`eye`,label:Z(h.openTicket,{subject:e.subject}),href:Tt(e.id),onClick:t=>x(t,e.id)}),stickyActions:!0,stackOnMobile:!0,sourceCount:u?.total??0,pagination:m,empty:/* @__PURE__ */ V(b,{variant:`table`,icon:`message-square`,title:h.emptyTitle,description:h.emptyText}),emptyFiltered:/* @__PURE__ */ V(b,{variant:`table`,icon:`search`,title:h.noMatchTitle,description:h.noMatchText})})]})}var At=300,jt=10,Mt={heading:`Your tickets`,newTicket:`New ticket`,configError:`We could not load the support settings.`,retry:`Try again`};function Nt({initialTicketId:e,defaultCategory:t,appVersion:n,status:i,defaultStatus:a=`all`,onStatusChange:o,statusFilter:c=`tabs`}){let u=Y(`supportCenter`,Mt),d=Y(`shared`,Q),{config:p,error:m,reload:h}=me(),[g,_]=s(a),v=i!==void 0,y=v?i:g,b=e=>{v||_(e),o?.(e)},[x,S]=s(``),C=Te(x.trim(),At),[w,T]=s(jt),E=`${y}|${C}|${w}`,[D,O]=s({key:E,page:1}),k=D.key===E?D.page:1,ee=e=>O({key:E,page:e}),A=he({status:y===`all`?void 0:y,search:C||void 0,page:k,pageSize:w}),{counts:j,reload:M}=ge(),[N,P]=s(()=>e||wt()),[F,I]=s(!1),L=A.totalPages;r(()=>{L>0&&k>L&&O({key:E,page:L})},[L,k,E]);let R=()=>{A.reload(),M()},z=e=>{P(e),Et(e)};if(N)return/* @__PURE__ */ V(St,{ticketId:N,onBack:()=>z(null),onChanged:R,onOpenTicket:z},N);let B={page:k,totalPages:Math.max(1,A.totalPages),pageSize:w,total:A.totalCount,setPage:ee,setPageSize:T};return/* @__PURE__ */ H(`section`,{className:`d-flex flex-column gap-3 min-w-0`,"aria-labelledby":`support-center-title`,children:[/* @__PURE__ */ H(`div`,{className:`d-flex flex-wrap align-items-center justify-content-between gap-2`,children:[/* @__PURE__ */ V(`h2`,{id:`support-center-title`,className:`h5 mb-0`,children:u.heading}),/* @__PURE__ */ V(f,{leftIcon:`plus`,onClick:()=>I(!0),disabled:!p,children:u.newTicket})]}),m&&/* @__PURE__ */ H(l,{tone:`warning`,children:[$(m,u.configError,d.offline),` `,/* @__PURE__ */ V(f,{variant:`ghost`,size:`sm`,onClick:h,children:u.retry})]}),/* @__PURE__ */ V(kt,{tickets:A.tickets,loading:A.loading,error:A.error,onRetry:R,onOpen:z,status:y,onStatusChange:b,statusFilter:c,counts:j,search:x,onSearchChange:S,pagination:B}),p&&/* @__PURE__ */ V(st,{open:F,onClose:()=>I(!1),config:p,defaultCategory:t,appVersion:n,onCreated:e=>{I(!1),R(),z(e.id)}})]})}var Pt={copyEmail:`Copy email`,emailCopied:`Email copied`,contactNamed:`Contact {name}`,contactSupport:`Contact support`},Ft=e=>typeof e==`string`&&e.trim()!==``;function It({className:e}){let t=Y(`supportContact`,Pt),{config:n}=me();if(!n)return null;let r=Ft(n.supportEmail),i=Ft(n.supportPhone),a=Ft(n.supportHours);if(!r&&!i&&!a)return null;let o=[`d-flex flex-wrap align-items-center gap-2 wui-text-sm`,e].filter(Boolean).join(` `);return/* @__PURE__ */ H(`section`,{className:o,"aria-label":Ft(n.supportName)?Z(t.contactNamed,{name:n.supportName}):t.contactSupport,children:[/* @__PURE__ */ V(`span`,{className:`fw-semibold`,children:Ft(n.supportName)?n.supportName:t.contactSupport}),r&&/* @__PURE__ */ H(`span`,{className:`d-inline-flex align-items-center gap-1`,children:[/* @__PURE__ */ V(`a`,{href:`mailto:${n.supportEmail}`,className:`text-break`,children:n.supportEmail}),/* @__PURE__ */ V(_,{text:n.supportEmail,iconOnly:!0,label:t.copyEmail,copiedLabel:t.emailCopied})]}),i&&/* @__PURE__ */ V(`a`,{href:`tel:${n.supportPhone.replace(/[^\d+]/g,``)}`,children:n.supportPhone}),a&&/* @__PURE__ */ V(`span`,{className:`text-body-secondary`,children:n.supportHours})]})}function Lt({client:e,timeZone:n=I,renderTime:r,labels:i,children:s}){let c=o(null),l=t((t=!1)=>{let n=c.current;if(t||!n||n.client!==e){let t=e.getConfig(),n={client:e,pending:t};return c.current=n,t.catch(()=>{c.current===n&&(c.current=null)}),t}return n.pending},[e]),u=a(()=>({client:e,loadConfig:l,timeZone:n,renderTime:r,labels:i}),[e,l,n,r,i]);return/* @__PURE__ */ V(le.Provider,{value:u,children:s})}export{we as HelpArticle,je as HelpCentre,at as ReportIssue,W as SupportApiError,Nt as SupportCenter,It as SupportContact,Lt as SupportProvider,ve as createHelpCentreClient,se as createSupportClient,Ae as useHelpCentre,J as useSupportClient,me as useSupportConfig,_e as useSupportTicket,ge as useSupportTicketCounts,he as useSupportTickets};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/support-react",
3
- "version": "0.130.1",
3
+ "version": "0.130.2",
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.130.1",
31
- "@webority/ui-react": "0.130.1",
30
+ "@webority/ui-elements": "0.130.2",
31
+ "@webority/ui-react": "0.130.2",
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.130.1",
46
- "@webority/ui-elements": "0.130.1",
47
- "@webority/ui-react": "0.130.1",
45
+ "@webority/canvas-kit": "0.130.2",
46
+ "@webority/ui-elements": "0.130.2",
47
+ "@webority/ui-react": "0.130.2",
48
48
  "bootstrap": "5.3.3",
49
49
  "jsdom": "30.1.1",
50
50
  "react": "^19.2.6",