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