@sparkvault/sdk-js 15.14.1 → 15.14.3
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/README.md +9 -0
- package/dist/index.cjs +503 -84
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.mjs +503 -84
- package/dist/index.mjs.map +1 -1
- package/dist/products/help-desk/form-draft.d.ts +1 -0
- package/dist/products/help-desk/form-types.d.ts +2 -0
- package/dist/products/help-desk/kb-client.d.ts +11 -2
- package/dist/products/help-desk/kb-types.d.ts +6 -0
- package/dist/products/help-desk/support-brand.d.ts +2 -0
- package/dist/products/help-desk/support-types.d.ts +3 -1
- package/dist/products/help-desk/support-view.d.ts +17 -1
- package/dist/products/help-desk/types.d.ts +2 -0
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/dist/vaults/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -16838,6 +16838,7 @@ class HelpDeskClient {
|
|
|
16838
16838
|
ticket_id: ticket, subject: options.subject, body: options.body, attachments: options.attachments ?? [],
|
|
16839
16839
|
...(options.assistance_attempt_id && { assistance_attempt_id: options.assistance_attempt_id }),
|
|
16840
16840
|
...(options.assistance_visitor_id && { assistance_visitor_id: options.assistance_visitor_id }),
|
|
16841
|
+
...(options.source_article_id && { source_article_id: options.source_article_id }),
|
|
16841
16842
|
}, undefined, true, context);
|
|
16842
16843
|
}
|
|
16843
16844
|
listTickets(options = {}) {
|
|
@@ -17792,6 +17793,8 @@ const TTL_MS = 30 * 60 * 1000;
|
|
|
17792
17793
|
const storageKey = (deskId, requesterId) => isHelpDeskId(deskId) && isResourceIdOf('requester', requesterId) ? `sv-hd-draft:${deskId}:${requesterId}:new` : null;
|
|
17793
17794
|
const validBody = (value) => typeof value === 'string' && value.length <= MAX_BODY_BYTES && new TextEncoder().encode(value).length <= MAX_BODY_BYTES;
|
|
17794
17795
|
const validSubject = (value) => typeof value === 'string' && value.length <= MAX_SUBJECT_LEN;
|
|
17796
|
+
const validArticleId = (value) => typeof value === 'string' && value.length > 0 && value.length <= 256 &&
|
|
17797
|
+
!Array.from(value).some(character => character.charCodeAt(0) <= 32 || character === '\\');
|
|
17795
17798
|
/** The question before sign-in is tab-local and contains no customer identity. */
|
|
17796
17799
|
function clearSupportIssue(deskId) {
|
|
17797
17800
|
try {
|
|
@@ -17874,10 +17877,12 @@ function readFormDraft(deskId, requesterId) {
|
|
|
17874
17877
|
!Number.isFinite(row.expires_at) || row.expires_at <= Date.now() || row.expires_at > Date.now() + TTL_MS ||
|
|
17875
17878
|
!validSubject(row.subject) || !validBody(row.body) || (row.ticket_id !== null && !isResourceIdOf('ticket', row.ticket_id)) ||
|
|
17876
17879
|
(sent !== null && (!isResourceIdOf('ticket', sent?.ticket_id) || !validSubject(sent.subject) || !validBody(sent.body) ||
|
|
17880
|
+
(sent.source_article_id !== undefined && !validArticleId(sent.source_article_id)) ||
|
|
17877
17881
|
!Array.isArray(sent.attachments) || sent.attachments.length > MAX_ATTACHMENTS_PER_MESSAGE || sent.attachments.some((id) => !isResourceIdOf('attachment', id)))))
|
|
17878
17882
|
throw new Error('Invalid draft');
|
|
17879
17883
|
return { subject: row.subject, body: row.body, ticketId: row.ticket_id, hadFiles: row.had_files === true,
|
|
17880
|
-
uncertain: sent ? { ticketId: sent.ticket_id, subject: sent.subject, body: sent.body, attachments: [...sent.attachments]
|
|
17884
|
+
uncertain: sent ? { ticketId: sent.ticket_id, subject: sent.subject, body: sent.body, attachments: [...sent.attachments],
|
|
17885
|
+
...(sent.source_article_id !== undefined && { source_article_id: sent.source_article_id }) } : null };
|
|
17881
17886
|
}
|
|
17882
17887
|
catch {
|
|
17883
17888
|
removeFormDraft(deskId, requesterId);
|
|
@@ -17896,7 +17901,8 @@ function saveFormDraft(deskId, requesterId, value) {
|
|
|
17896
17901
|
const sent = value.uncertain;
|
|
17897
17902
|
sessionStorage.setItem(key, JSON.stringify({ version: 1, desk_id: deskId, requester_id: requesterId, kind: 'new',
|
|
17898
17903
|
expires_at: Date.now() + TTL_MS, subject: value.subject, body: value.body, ticket_id: value.ticketId,
|
|
17899
|
-
uncertain: sent ? { ticket_id: sent.ticketId, subject: sent.subject, body: sent.body, attachments: sent.attachments
|
|
17904
|
+
uncertain: sent ? { ticket_id: sent.ticketId, subject: sent.subject, body: sent.body, attachments: sent.attachments,
|
|
17905
|
+
...(validArticleId(sent.source_article_id) && { source_article_id: sent.source_article_id }) } : null,
|
|
17900
17906
|
had_files: value.hadFiles }));
|
|
17901
17907
|
}
|
|
17902
17908
|
catch { /* Storage is optional; the live form keeps its composition. */ }
|
|
@@ -18830,7 +18836,14 @@ function mountHelpDeskForm(client, options) {
|
|
|
18830
18836
|
const id = await ensureDraft(ownGeneration, token);
|
|
18831
18837
|
if (!alive(ownGeneration) || !(await tokenFor(ownGeneration)))
|
|
18832
18838
|
return;
|
|
18833
|
-
|
|
18839
|
+
let sourceArticleId;
|
|
18840
|
+
try {
|
|
18841
|
+
sourceArticleId = options.sourceArticleId?.();
|
|
18842
|
+
}
|
|
18843
|
+
catch { /* Optional context cannot prevent sending. */ }
|
|
18844
|
+
uncertainSubmission = { ticketId: id, subject: subjectText, body, attachments: attachments?.attachmentIds ?? [],
|
|
18845
|
+
...(typeof sourceArticleId === 'string' && sourceArticleId.length > 0 && sourceArticleId.length <= 256 &&
|
|
18846
|
+
!Array.from(sourceArticleId).some(character => character.charCodeAt(0) <= 32 || character === '\\') && { source_article_id: sourceArticleId }) };
|
|
18834
18847
|
}
|
|
18835
18848
|
persistDraft();
|
|
18836
18849
|
attachments?.lock(true);
|
|
@@ -19506,6 +19519,10 @@ function recommendKnowledgeBase(prepared, issue, { limit = 5, categoryId = null
|
|
|
19506
19519
|
].map(value => typeof value === 'function' ? value.toString() : value).join('\n') + '\nexport { prepareSearchIndex, searchKnowledgeBase, recommendKnowledgeBase };\n';
|
|
19507
19520
|
|
|
19508
19521
|
/** One published-KB transport and shared local search engine for support entry points. */
|
|
19522
|
+
const currentVisitor = (value) => value !== null && typeof value === 'object' &&
|
|
19523
|
+
'visitor_id' in value && typeof value.visitor_id === 'string' && /^[a-f0-9]{64}$/.test(value.visitor_id) &&
|
|
19524
|
+
'expires_at' in value && typeof value.expires_at === 'number' && Number.isSafeInteger(value.expires_at) &&
|
|
19525
|
+
value.expires_at * 1000 > Date.now() + 60000 && value.expires_at * 1000 <= Date.now() + 31 * 86400000;
|
|
19509
19526
|
const invalid = () => new SparkVaultError('The help center returned an invalid answer. Try again.', 'KB_INVALID_RESPONSE');
|
|
19510
19527
|
const changed = () => new SparkVaultError('The help center changed. Search again to see current answers.', 'KB_PUBLICATION_CHANGED', 409);
|
|
19511
19528
|
const validPath = (value) => typeof value === 'string' && value.startsWith('/') && !value.startsWith('//') &&
|
|
@@ -19521,6 +19538,9 @@ class HelpDeskKnowledgeBaseClient {
|
|
|
19521
19538
|
this.config = null;
|
|
19522
19539
|
this.index = null;
|
|
19523
19540
|
this.indexPending = null;
|
|
19541
|
+
this.visitorSession = null;
|
|
19542
|
+
this.visitorPending = null;
|
|
19543
|
+
this.voteQueues = new Map();
|
|
19524
19544
|
this.objectUrls = new Set();
|
|
19525
19545
|
this.generation = 0;
|
|
19526
19546
|
this.readerRevision = 0;
|
|
@@ -19540,7 +19560,8 @@ class HelpDeskKnowledgeBaseClient {
|
|
|
19540
19560
|
if (this.destroyed)
|
|
19541
19561
|
throw new SparkVaultError('This support session has closed.', 'KB_CLOSED');
|
|
19542
19562
|
const route = typeof suffix === 'object'
|
|
19543
|
-
? apiPath `/v1/hd/desks/${this.deskId}/kb/widget/
|
|
19563
|
+
? 'helpful' in suffix ? apiPath `/v1/hd/desks/${this.deskId}/kb/widget/articles/${suffix.helpful}/helpful`
|
|
19564
|
+
: apiPath `/v1/hd/desks/${this.deskId}/kb/widget/documents/${suffix.document}`
|
|
19544
19565
|
: apiPath `/v1/hd/desks/${this.deskId}/kb/widget/${suffix}`;
|
|
19545
19566
|
const url = new URL(`${this.sdkConfig.apiBaseUrl}${route}`);
|
|
19546
19567
|
if (options.release)
|
|
@@ -19682,6 +19703,87 @@ class HelpDeskKnowledgeBaseClient {
|
|
|
19682
19703
|
const row = index.articles.find(article => article.path === path || (!url.hash && article.path === url.pathname));
|
|
19683
19704
|
return row ? this.result(row, index) : null;
|
|
19684
19705
|
}
|
|
19706
|
+
/** Resolve a ticket's article reference only against the current authorized publication. */
|
|
19707
|
+
async resolveArticle(id) {
|
|
19708
|
+
if (typeof id !== 'string' || !id || id.length > 256)
|
|
19709
|
+
return null;
|
|
19710
|
+
const index = await this.currentIndex();
|
|
19711
|
+
const row = index.articles.find(article => article.id === id);
|
|
19712
|
+
return row ? this.result(row, index) : null;
|
|
19713
|
+
}
|
|
19714
|
+
async visitor(config) {
|
|
19715
|
+
const key = `kb-visitor:${new URL(config.canonical_origin).host}:${this.deskId}`;
|
|
19716
|
+
try {
|
|
19717
|
+
const saved = JSON.parse(globalThis.localStorage.getItem(key) ?? 'null');
|
|
19718
|
+
if (currentVisitor(saved))
|
|
19719
|
+
return saved;
|
|
19720
|
+
}
|
|
19721
|
+
catch { /* Storage can be unavailable in an embedded support surface. */ }
|
|
19722
|
+
if (this.visitorSession?.key === key && currentVisitor(this.visitorSession.value))
|
|
19723
|
+
return this.visitorSession.value;
|
|
19724
|
+
if (this.visitorPending?.key === key)
|
|
19725
|
+
return this.visitorPending.pending;
|
|
19726
|
+
const pending = (async () => {
|
|
19727
|
+
const value = await this.request('visitor', { body: { release_id: config.release_id } });
|
|
19728
|
+
if (!currentVisitor(value))
|
|
19729
|
+
throw invalid();
|
|
19730
|
+
this.visitorSession = { key, value };
|
|
19731
|
+
try {
|
|
19732
|
+
globalThis.localStorage.setItem(key, JSON.stringify(value));
|
|
19733
|
+
}
|
|
19734
|
+
catch { /* Keep the visitor in memory when persistence is blocked. */ }
|
|
19735
|
+
return value;
|
|
19736
|
+
})();
|
|
19737
|
+
this.visitorPending = { key, pending };
|
|
19738
|
+
try {
|
|
19739
|
+
return await pending;
|
|
19740
|
+
}
|
|
19741
|
+
finally {
|
|
19742
|
+
if (this.visitorPending?.pending === pending)
|
|
19743
|
+
this.visitorPending = null;
|
|
19744
|
+
}
|
|
19745
|
+
}
|
|
19746
|
+
/** Use the help center's browser visitor and vote receipt; ticket identity is never sent. */
|
|
19747
|
+
async vote(article, vote) {
|
|
19748
|
+
if (article?.kind !== 'article' || typeof article.id !== 'string' || !article.id || article.id.length > 256 || !['yes', 'no'].includes(vote)) {
|
|
19749
|
+
throw new ValidationError('Choose yes or no for a published article.');
|
|
19750
|
+
}
|
|
19751
|
+
const reference = { id: article.id, release_id: article.release_id };
|
|
19752
|
+
const previous = this.voteQueues.get(reference.id) ?? Promise.resolve();
|
|
19753
|
+
const pending = previous.then(() => this.saveVote(reference, vote));
|
|
19754
|
+
// Keep user choices in order even when an earlier vote is slow or fails.
|
|
19755
|
+
// The caller still receives its own failure; the next choice can proceed.
|
|
19756
|
+
const settled = pending.then(() => undefined, () => undefined);
|
|
19757
|
+
this.voteQueues.set(reference.id, settled);
|
|
19758
|
+
void settled.then(() => { if (this.voteQueues.get(reference.id) === settled)
|
|
19759
|
+
this.voteQueues.delete(reference.id); });
|
|
19760
|
+
return pending;
|
|
19761
|
+
}
|
|
19762
|
+
async saveVote(article, vote) {
|
|
19763
|
+
const config = await this.load();
|
|
19764
|
+
if (!config.available)
|
|
19765
|
+
throw new SparkVaultError('This help center is unavailable. Contact support to continue.', 'KB_UNAVAILABLE', 404);
|
|
19766
|
+
if (!config.authorized)
|
|
19767
|
+
throw new SparkVaultError('Sign in to this help center to send feedback.', config.access.mode === 'ip_allowlist' ? 'KB_IP_RESTRICTED' : 'KB_ACCESS_REQUIRED', config.access.mode === 'ip_allowlist' ? 403 : 401);
|
|
19768
|
+
if (config.release_id !== article.release_id)
|
|
19769
|
+
throw changed();
|
|
19770
|
+
const visitor = await this.visitor(config);
|
|
19771
|
+
const value = await this.request({ helpful: article.id }, {
|
|
19772
|
+
body: { visitor_id: visitor.visitor_id, release_id: article.release_id, vote }
|
|
19773
|
+
});
|
|
19774
|
+
if (value?.vote !== vote || !Number.isSafeInteger(value.version) || value.version < 1)
|
|
19775
|
+
throw invalid();
|
|
19776
|
+
let review;
|
|
19777
|
+
try {
|
|
19778
|
+
if (vote === 'yes' && typeof value.review_url === 'string' && value.review_url.length <= 2048) {
|
|
19779
|
+
const url = new URL(value.review_url);
|
|
19780
|
+
if (url.protocol === 'https:' && !url.username && !url.password)
|
|
19781
|
+
review = url;
|
|
19782
|
+
}
|
|
19783
|
+
}
|
|
19784
|
+
catch { /* A malformed review destination must not invalidate an acknowledged vote. */ }
|
|
19785
|
+
return { vote, version: value.version, ...(review && { review_url: review.href }) };
|
|
19786
|
+
}
|
|
19685
19787
|
async read(result) {
|
|
19686
19788
|
const config = await this.load();
|
|
19687
19789
|
if (config.release_id !== result.release_id)
|
|
@@ -20049,20 +20151,20 @@ function injectHelpDeskSupportStyles() {
|
|
|
20049
20151
|
style.id = 'sparkvault-help-desk-support-styles';
|
|
20050
20152
|
style.textContent = `
|
|
20051
20153
|
.svhs-panel,.svhs-panel *{box-sizing:border-box}
|
|
20052
|
-
.svhs-panel{position:fixed;right:calc(var(--svhs-right,24px) + env(safe-area-inset-right,0px));bottom:calc(var(--svhs-bottom,96px) + env(safe-area-inset-bottom,0px));z-index:2147482900;width:408px;height:
|
|
20154
|
+
.svhs-panel{position:fixed;right:calc(var(--svhs-right,24px) + env(safe-area-inset-right,0px));bottom:calc(var(--svhs-bottom,96px) + env(safe-area-inset-bottom,0px));z-index:2147482900;width:408px;height:422px;max-width:calc(100vw - 32px);max-height:calc(100dvh - var(--svhs-bottom,96px) - 24px);display:flex;flex-direction:column;overflow:hidden;border:1px solid ${DS.slate200};border-radius:12px;background:${DS.white};color:${DS.slate900};font:400 15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',sans-serif;text-align:left;box-shadow:${DS.shadowPopover};transform-origin:bottom right;transition:width 180ms cubic-bezier(.2,0,0,1),height 180ms cubic-bezier(.2,0,0,1)}
|
|
20053
20155
|
.svhs-panel[hidden],.svhs-panel [hidden]{display:none!important}
|
|
20054
20156
|
.svhs-panel[data-stage=results]{height:680px}
|
|
20055
20157
|
.svhs-panel[data-stage=article]{width:704px;height:700px}
|
|
20056
|
-
.svhs-panel[data-stage=feedback]{height:358px}
|
|
20158
|
+
.svhs-panel[data-stage=feedback],.svhs-panel[data-stage=resolved]{height:358px}
|
|
20057
20159
|
.svhs-panel[data-stage=contact]{height:720px}
|
|
20058
20160
|
.svhs-panel[data-stage=receipt]{height:430px}
|
|
20059
20161
|
.svhs-panel button,.svhs-panel input,.svhs-panel textarea{font:inherit;letter-spacing:normal;text-transform:none}
|
|
20060
20162
|
.svhs-panel button,.svhs-panel a{touch-action:manipulation;-webkit-tap-highlight-color:transparent}
|
|
20061
20163
|
.svhs-panel button{appearance:none;cursor:pointer;margin:0}
|
|
20062
20164
|
.svhs-panel button:active{transform:translateY(1px)}
|
|
20063
|
-
.svhs-panel button:focus-visible,.svhs-panel a:focus-visible,.svhs-panel input:focus-visible,.svhs-panel textarea:focus-visible{outline:2px solid
|
|
20165
|
+
.svhs-panel button:focus-visible,.svhs-panel a:focus-visible,.svhs-panel input:focus-visible,.svhs-panel textarea:focus-visible{outline:2px solid var(--hd-focus,var(--hd-accent-ink,${DS.action}));outline-offset:3px;box-shadow:none}
|
|
20064
20166
|
.svhs-panel svg{display:block;width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;flex:none;pointer-events:none}
|
|
20065
|
-
.svhs-toolbar{display:flex;align-items:center;justify-content:space-between;gap:
|
|
20167
|
+
.svhs-toolbar{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:60px;flex:none;padding:8px 14px 8px 24px;border-bottom:1px solid ${DS.slate200}}
|
|
20066
20168
|
.svhs-desk-name{font-size:14px;font-weight:600;line-height:1.35;color:${DS.slate600};overflow-wrap:anywhere;min-width:0}
|
|
20067
20169
|
.svhs-toolbar-actions{display:flex;align-items:center;gap:4px;margin-left:auto;flex:none}
|
|
20068
20170
|
.svhs-identity-notice{display:flex;align-items:center;justify-content:space-between;gap:8px;flex:none;padding:8px 24px;border-bottom:1px solid ${DS.slate200};background:${DS.slate50}}
|
|
@@ -20075,36 +20177,45 @@ function injectHelpDeskSupportStyles() {
|
|
|
20075
20177
|
.svhs-back:disabled{background:transparent;color:${DS.slate500};cursor:default;transform:none}
|
|
20076
20178
|
.svhs-screen{display:flex;flex-direction:column;min-height:0;flex:1}
|
|
20077
20179
|
.svhs-scroll{padding:26px 24px;overflow:auto;overscroll-behavior:contain;min-height:0;flex:1;scrollbar-gutter:stable}
|
|
20078
|
-
.svhs-heading{margin:0 0
|
|
20079
|
-
.svhs-heading:focus,.svhs-article-title:focus{outline:none}
|
|
20080
|
-
.svhs-copy{margin:0 0
|
|
20180
|
+
.svhs-heading{margin:0 0 8px;padding:0;color:${DS.slate900};font-size:24px;font-weight:600;line-height:1.3;letter-spacing:-.6px;overflow-wrap:anywhere}
|
|
20181
|
+
.svhs-heading:focus,.svhs-article-title:focus{outline:none;box-shadow:none}
|
|
20182
|
+
.svhs-copy{margin:0 0 24px;color:${DS.slate600};font-size:14px;line-height:1.55}
|
|
20081
20183
|
.svhs-label{display:block;margin:0 0 7px;font-size:13px;font-weight:600;color:${DS.slate600}}
|
|
20082
|
-
.svhs-issue{display:block;width:100%;min-height:
|
|
20184
|
+
.svhs-issue{display:block;width:100%;min-height:120px;max-height:200px;resize:none;overflow-y:auto;border:1px solid ${DS.slate300};border-radius:8px;padding:12px 14px;background:${DS.white};color:${DS.slate900};font-size:16px!important;line-height:1.5!important;box-shadow:none}
|
|
20083
20185
|
.svhs-issue::placeholder{color:${DS.slate500};opacity:1}
|
|
20084
|
-
.svhs-issue:focus{border-color
|
|
20186
|
+
.svhs-issue:focus{border-color:var(--hd-focus,var(--hd-accent-ink,${DS.action}))}
|
|
20085
20187
|
.svhs-primary,.svhs-secondary{display:flex;align-items:center;justify-content:center;gap:8px;min-height:44px;padding:10px 16px;border:1px solid transparent;border-radius:6px;font-size:14px!important;font-weight:600!important;line-height:1.4!important;text-decoration:none;transition:background 120ms cubic-bezier(.2,0,0,1)}
|
|
20086
|
-
.svhs-primary{background
|
|
20087
|
-
.svhs-primary:hover{background
|
|
20188
|
+
.svhs-primary{background:var(--hd-accent,${DS.action});color:var(--hd-on-accent,${DS.white})}
|
|
20189
|
+
.svhs-primary:hover{background:var(--hd-accent-hover,${DS.actionHover})}
|
|
20088
20190
|
.svhs-primary[aria-disabled=true]{cursor:progress}
|
|
20089
20191
|
.svhs-secondary{border-color:${DS.slate300};background:${DS.white};color:${DS.slate600}}
|
|
20090
20192
|
.svhs-secondary:hover{background:${DS.slate50}}
|
|
20091
|
-
.svhs-text-button{display:inline-flex;align-items:center;justify-content:center;min-height:44px;padding:9px 4px;border:0;border-radius:6px;background:transparent;color
|
|
20193
|
+
.svhs-text-button{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:44px;padding:9px 4px;border:0;border-radius:6px;background:transparent;color:var(--hd-accent-ink,${DS.action});font-size:14px!important;line-height:1.4!important;text-decoration:none}
|
|
20092
20194
|
.svhs-text-button:hover{text-decoration:underline}
|
|
20093
20195
|
.svhs-full{width:100%}
|
|
20094
20196
|
.svhs-bottom{padding:16px 24px 18px;flex:none;border-top:1px solid ${DS.slate100}}
|
|
20095
20197
|
.svhs-start-bottom{display:flex;flex-direction:column;align-items:center;gap:6px;padding-top:0;border-top:0}
|
|
20096
20198
|
.svhs-start-bottom .svhs-primary{width:100%}
|
|
20097
|
-
.svhs-query{display:flex;align-items:
|
|
20098
|
-
.svhs-
|
|
20099
|
-
.svhs-
|
|
20199
|
+
.svhs-query{display:flex;align-items:center;gap:12px;margin:0 0 24px;padding:12px 14px;border:1px solid ${DS.slate200};border-radius:8px;background:${DS.slate50}}
|
|
20200
|
+
.svhs-question{flex:1;min-width:0}
|
|
20201
|
+
.svhs-question-label{display:block;margin-bottom:3px;color:${DS.slate500};font-size:12px;font-weight:500;line-height:1.4}
|
|
20202
|
+
.svhs-query-text{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0;color:${DS.slate900};font-size:14px;line-height:1.5;overflow-wrap:anywhere;white-space:pre-wrap}
|
|
20203
|
+
.svhs-query .svhs-text-button{flex:none;min-width:44px;padding:8px 0}
|
|
20100
20204
|
.svhs-results{display:flex;flex-direction:column;margin:0;padding:0;list-style:none}
|
|
20101
|
-
.svhs-result{display:
|
|
20205
|
+
.svhs-result{display:grid;grid-template-columns:24px minmax(0,1fr) 16px;align-items:start;gap:12px;width:100%;padding:18px 0;border:0;border-bottom:1px solid ${DS.slate200};border-radius:0;background:${DS.white};color:${DS.slate900};text-align:left}
|
|
20206
|
+
.svhs-results li:first-child .svhs-result{border-top:1px solid ${DS.slate200}}
|
|
20102
20207
|
.svhs-results li:last-child .svhs-result{border-bottom:0}
|
|
20103
|
-
.svhs-result-
|
|
20104
|
-
.svhs-result
|
|
20105
|
-
.svhs-result-
|
|
20106
|
-
.svhs-result-
|
|
20107
|
-
.svhs-
|
|
20208
|
+
.svhs-result-copy{display:block;min-width:0}
|
|
20209
|
+
.svhs-result-icon{margin-top:2px;color:${DS.slate500}}
|
|
20210
|
+
.svhs-result-chevron{width:16px!important;height:16px!important;margin-top:4px;color:${DS.slate500}}
|
|
20211
|
+
.svhs-result-title{display:block;margin:0 0 4px;color:inherit;font-size:16px;font-weight:600;line-height:1.4;letter-spacing:-.15px;overflow-wrap:anywhere}
|
|
20212
|
+
.svhs-result:hover{background:${DS.slate50}}
|
|
20213
|
+
.svhs-result:hover .svhs-result-title{color:var(--hd-accent-ink,${DS.action});text-decoration:underline}
|
|
20214
|
+
.svhs-result-excerpt{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0;color:${DS.slate600};font-size:14px;line-height:1.5;overflow-wrap:anywhere}
|
|
20215
|
+
.svhs-result-category{display:block;margin-top:6px;color:${DS.slate500};font-size:12px;line-height:1.4}
|
|
20216
|
+
.svhs-results-bottom{background:${DS.slate50};border-top-color:${DS.slate200}}
|
|
20217
|
+
.svhs-footer-title{margin:0 0 3px;color:${DS.slate900};font-size:14px;font-weight:600;line-height:1.5}
|
|
20218
|
+
.svhs-footer-copy{margin:0 0 14px;color:${DS.slate600};font-size:13px;line-height:1.5}
|
|
20108
20219
|
.svhs-error{margin:12px 0 0;color:${DS.error};font-size:14px;line-height:1.5;overflow-wrap:anywhere}
|
|
20109
20220
|
.svhs-status{margin:16px 0;color:${DS.slate600};font-size:14px;line-height:1.5}
|
|
20110
20221
|
.svhs-empty{padding:12px 0 4px}
|
|
@@ -20122,7 +20233,7 @@ function injectHelpDeskSupportStyles() {
|
|
|
20122
20233
|
.svhs-article-content ul,.svhs-article-content ol{margin:0 0 22px;padding-left:22px}
|
|
20123
20234
|
.svhs-article-content li{margin:8px 0;padding-left:5px}
|
|
20124
20235
|
.svhs-article-content strong{font-weight:600;color:${DS.slate900}}
|
|
20125
|
-
.svhs-article-content a{color
|
|
20236
|
+
.svhs-article-content a{color:var(--hd-accent-ink,${DS.action});text-decoration:underline;text-underline-offset:2px}
|
|
20126
20237
|
.svhs-article-content img,.svhs-article-content video{display:block;max-width:100%;height:auto;margin:20px 0}
|
|
20127
20238
|
.svhs-reader-asset{display:block;max-width:100%;margin:20px 0}
|
|
20128
20239
|
.svhs-reader-asset img{margin:0}
|
|
@@ -20142,6 +20253,8 @@ function injectHelpDeskSupportStyles() {
|
|
|
20142
20253
|
.svhs-feedback-scroll{padding-top:30px}
|
|
20143
20254
|
.svhs-feedback-actions{display:flex;flex-direction:column;gap:9px;margin-top:24px}
|
|
20144
20255
|
.svhs-feedback-actions .svhs-text-button{align-self:center;color:${DS.slate500}}
|
|
20256
|
+
.svhs-review{margin-top:24px}
|
|
20257
|
+
.svhs-review .svhs-primary{width:fit-content}
|
|
20145
20258
|
.svhs-contact-scroll{padding:0;scrollbar-gutter:auto}
|
|
20146
20259
|
.svhs-contact-target{display:flex;flex-direction:column;min-height:100%}
|
|
20147
20260
|
.svhs-contact-target:empty{display:none;min-height:0}
|
|
@@ -20149,7 +20262,7 @@ function injectHelpDeskSupportStyles() {
|
|
|
20149
20262
|
.svhs-contact-prelude .svhs-secondary{margin-top:16px}
|
|
20150
20263
|
.svhs-ticket-gate{padding:0 24px 24px}
|
|
20151
20264
|
.svhs-unlock-input{display:block;box-sizing:border-box;width:100%;min-height:46px;margin:0 0 16px;border:1px solid ${DS.slate300};border-radius:6px;padding:11px 12px;background:${DS.white};color:${DS.slate900};font-size:16px!important;line-height:1.5!important}
|
|
20152
|
-
.svhs-unlock-input:focus{border-color
|
|
20265
|
+
.svhs-unlock-input:focus{border-color:var(--hd-focus,var(--hd-accent-ink,${DS.action}))}
|
|
20153
20266
|
.svhs-unlock-form{margin:0}
|
|
20154
20267
|
.svhs-contact-target>.svhd-container{display:flex;flex:1;flex-direction:column;min-height:100%;max-width:none;padding:24px;border:0;border-radius:0;box-shadow:none;background:transparent}
|
|
20155
20268
|
.svhs-contact-target .svhd-body{display:flex;flex:1;flex-direction:column;min-height:0}
|
|
@@ -20159,6 +20272,9 @@ function injectHelpDeskSupportStyles() {
|
|
|
20159
20272
|
.svhs-contact-target .svhd-input{font-size:16px;line-height:1.5}
|
|
20160
20273
|
.svhs-contact-target .svhd-description{min-height:138px}
|
|
20161
20274
|
.svhs-contact-target .svhd-actions{gap:10px}
|
|
20275
|
+
.svhs-contact-target .svhd-button:not(.svhd-secondary){background:var(--hd-accent,${DS.action});color:var(--hd-on-accent,${DS.white})}
|
|
20276
|
+
.svhs-contact-target .svhd-button:not(.svhd-secondary):hover{background:var(--hd-accent-hover,${DS.actionHover})}
|
|
20277
|
+
.svhs-contact-target .svhd-link{color:var(--hd-accent-ink,${DS.action})}
|
|
20162
20278
|
.svhs-contact-target .svhd-actions>.svhd-button:first-child{flex:1}
|
|
20163
20279
|
.svhs-contact-target .svhd-status{font-size:14px}
|
|
20164
20280
|
.svhs-contact-target .svhd-auth{gap:14px}
|
|
@@ -20166,9 +20282,9 @@ function injectHelpDeskSupportStyles() {
|
|
|
20166
20282
|
.svhs-contact-target .svhd-widget-identity{display:flex;flex:1;min-width:0;flex-direction:column;gap:2px;margin:0;line-height:1.4;overflow-wrap:anywhere}
|
|
20167
20283
|
.svhs-contact-target .svhd-widget-identity strong{color:${DS.slate900};font-size:14px;font-weight:600}
|
|
20168
20284
|
.svhs-contact-target .svhd-widget-identity span{color:${DS.slate500};font-size:13px}
|
|
20169
|
-
.svhs-contact-target .svhd-widget-account-link{display:inline-flex;align-items:center;justify-content:center;min-height:44px;max-width:100%;padding:8px 0;border:0;border-radius:6px;background:transparent;color
|
|
20285
|
+
.svhs-contact-target .svhd-widget-account-link{display:inline-flex;align-items:center;justify-content:center;min-height:44px;max-width:100%;padding:8px 0;border:0;border-radius:6px;background:transparent;color:var(--hd-accent-ink,${DS.action});font-size:13px;line-height:1.4}
|
|
20170
20286
|
.svhs-contact-target .svhd-widget-account-link:hover{text-decoration:underline}
|
|
20171
|
-
.svhs-contact-target .svhd-widget-account-link:focus-visible{outline:2px solid
|
|
20287
|
+
.svhs-contact-target .svhd-widget-account-link:focus-visible{outline:2px solid var(--hd-focus,var(--hd-accent-ink,${DS.action}));outline-offset:3px}
|
|
20172
20288
|
.svhs-contact-target .svhd-widget-account-link:disabled{cursor:progress;color:${DS.slate500}}
|
|
20173
20289
|
.svhs-contact-target .svhd-widget-names{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:12px}
|
|
20174
20290
|
.svhs-contact-target .svhd-widget-form{display:flex;flex:1;flex-direction:column;gap:16px}
|
|
@@ -20182,8 +20298,8 @@ function injectHelpDeskSupportStyles() {
|
|
|
20182
20298
|
.svhs-contact-target .svhd-widget-form>.svhd-confirm .svhd-button{flex:1}
|
|
20183
20299
|
.svhs-contact-target .svhd-footer{margin-top:16px;text-align:center;font-size:11px}
|
|
20184
20300
|
.svhs-receipt-scroll{padding-top:36px}
|
|
20185
|
-
.svhs-receipt-mark{width:30px!important;height:30px!important;margin-bottom:20px;color
|
|
20186
|
-
.svhs-ticket-link{display:inline-flex;align-items:center;min-height:44px;margin:0 0 10px;color
|
|
20301
|
+
.svhs-receipt-mark{width:30px!important;height:30px!important;margin-bottom:20px;color:var(--hd-accent-ink,${DS.action})}
|
|
20302
|
+
.svhs-ticket-link{display:inline-flex;align-items:center;min-height:44px;margin:0 0 10px;color:var(--hd-accent-ink,${DS.action});font-size:14px;font-weight:600;text-decoration:underline}
|
|
20187
20303
|
.svhs-receipt-note{white-space:pre-wrap;overflow-wrap:anywhere}
|
|
20188
20304
|
.svhs-receipt-actions{display:flex;flex-direction:column;align-items:center;gap:4px}
|
|
20189
20305
|
.svhs-live{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
|
|
@@ -20195,30 +20311,28 @@ function injectHelpDeskSupportStyles() {
|
|
|
20195
20311
|
.sv-support-launcher{touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition:background 120ms cubic-bezier(.2,0,0,1)}
|
|
20196
20312
|
.sv-support-launcher:hover{filter:brightness(1.12)}
|
|
20197
20313
|
.sv-support-launcher:active{transform:translateY(1px)}
|
|
20198
|
-
.sv-support-launcher:focus-visible{outline:3px solid
|
|
20314
|
+
.sv-support-launcher:focus-visible{outline:3px solid var(--hd-accent-ink,${DS.action});outline-offset:3px}
|
|
20199
20315
|
@media(max-width:640px){
|
|
20200
20316
|
.svhs-panel{right:0;bottom:0;width:100%;height:100dvh;max-width:none;max-height:none;border:0;border-radius:0}
|
|
20201
|
-
.svhs-toolbar{min-height:
|
|
20317
|
+
.svhs-toolbar{min-height:60px;padding:8px 16px 8px 24px;border-bottom-color:${DS.slate200}}
|
|
20202
20318
|
.svhs-icon-button{width:44px;height:44px}
|
|
20203
20319
|
.svhs-back{min-height:44px;max-width:42%}
|
|
20204
|
-
.svhs-scroll{padding:
|
|
20205
|
-
.svhs-heading{font-size:
|
|
20206
|
-
.svhs-issue{min-height:
|
|
20320
|
+
.svhs-scroll{padding:24px}
|
|
20321
|
+
.svhs-heading{font-size:24px}
|
|
20322
|
+
.svhs-issue{min-height:140px;max-height:260px}
|
|
20207
20323
|
.svhs-bottom{padding-bottom:calc(20px + env(safe-area-inset-bottom))}
|
|
20208
20324
|
.svhs-start-bottom{margin-top:0}
|
|
20209
20325
|
.svhs-panel[data-stage=issue] .svhs-scroll{flex:0}
|
|
20210
20326
|
.svhs-query .svhs-text-button{min-height:44px;min-width:44px}
|
|
20211
|
-
.svhs-query-text{font-size:
|
|
20212
|
-
.svhs-result{padding:
|
|
20213
|
-
.svhs-result-title{font-size:17px}
|
|
20214
|
-
.svhs-result-excerpt{font-size:14px}
|
|
20327
|
+
.svhs-query-text{font-size:14px}
|
|
20328
|
+
.svhs-result{padding:16px 0;gap:10px}
|
|
20215
20329
|
.svhs-article-scroll{padding:32px 25px}
|
|
20216
20330
|
.svhs-article-title{font-size:28px}
|
|
20217
20331
|
.svhs-article-content{font-size:16px}
|
|
20218
|
-
.svhs-article-footer{align-items:stretch;padding:
|
|
20219
|
-
.svhs-article-question{display:
|
|
20220
|
-
.svhs-reader-actions{
|
|
20221
|
-
.svhs-article-footer .svhs-primary,.svhs-article-footer .svhs-text-button{
|
|
20332
|
+
.svhs-article-footer{flex-direction:column;align-items:stretch;gap:10px;padding:16px 24px calc(12px + env(safe-area-inset-bottom))}
|
|
20333
|
+
.svhs-article-question{display:block}
|
|
20334
|
+
.svhs-reader-actions{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.3fr);gap:12px;width:100%}
|
|
20335
|
+
.svhs-article-footer .svhs-primary,.svhs-article-footer .svhs-text-button{min-width:0;min-height:48px;font-size:14px!important;white-space:normal}
|
|
20222
20336
|
.svhs-feedback-scroll{padding-top:50px}
|
|
20223
20337
|
.svhs-feedback-actions{margin-top:30px}
|
|
20224
20338
|
.svhs-feedback-actions .svhs-primary,.svhs-feedback-actions .svhs-secondary{min-height:48px}
|
|
@@ -20233,12 +20347,37 @@ function injectHelpDeskSupportStyles() {
|
|
|
20233
20347
|
@media(pointer:coarse){.svhs-icon-button{width:44px;height:44px}.svhs-back{min-height:44px}.svhs-query .svhs-text-button{min-height:44px;min-width:44px}}
|
|
20234
20348
|
@media(prefers-reduced-motion:reduce){.svhs-panel,.svhs-panel *,.sv-support-launcher{transition-duration:0s!important;animation-duration:.01ms!important;animation-iteration-count:1!important;scroll-behavior:auto!important}}
|
|
20235
20349
|
@media(forced-colors:active){.svhs-panel button:focus-visible,.svhs-panel a:focus-visible,.svhs-panel input:focus-visible,.svhs-panel textarea:focus-visible{outline:2px solid Highlight}.svhs-panel,.svhs-primary,.svhs-secondary{border:1px solid ButtonText}}
|
|
20236
|
-
.svhs-panel.svhs-page{position:static;inset:auto;z-index:auto;width:100%;height:auto;max-width:
|
|
20350
|
+
.svhs-panel.svhs-page{position:static;inset:auto;z-index:auto;width:100%;height:auto;max-width:720px;max-height:none;margin:0 auto;border:1px solid ${DS.slate200};border-radius:12px;box-shadow:none;transition:none}
|
|
20351
|
+
.svhs-page .svhs-toolbar{min-height:52px;padding:4px 24px}
|
|
20352
|
+
.svhs-page .svhs-back{max-width:none;white-space:nowrap}
|
|
20353
|
+
.svhs-page .svhs-desk-name{display:none}
|
|
20354
|
+
.svhs-page[data-stage=issue] .svhs-toolbar,.svhs-page[data-stage=resolved] .svhs-toolbar,.svhs-page[data-stage=receipt] .svhs-toolbar{display:none}
|
|
20237
20355
|
.svhs-page .svhs-screen{flex:none}
|
|
20238
|
-
.svhs-page .svhs-scroll{flex:none;overflow:visible;overscroll-behavior:auto;scrollbar-gutter:auto}
|
|
20356
|
+
.svhs-page .svhs-scroll{flex:none;padding:28px 32px;overflow:visible;overscroll-behavior:auto;scrollbar-gutter:auto}
|
|
20357
|
+
.svhs-page .svhs-bottom{padding:20px 32px 24px}
|
|
20358
|
+
.svhs-page .svhs-start-bottom{padding-top:0;align-items:flex-start}
|
|
20359
|
+
.svhs-page .svhs-start-bottom .svhs-primary{width:auto;min-width:160px}
|
|
20360
|
+
.svhs-page[data-stage=issue] .svhs-heading{font-size:28px}
|
|
20361
|
+
.svhs-page .svhs-results-bottom{display:flex;align-items:center;gap:24px}
|
|
20362
|
+
.svhs-page .svhs-results-bottom[hidden]{display:none}
|
|
20363
|
+
.svhs-page .svhs-escalation{flex:1;min-width:0}
|
|
20364
|
+
.svhs-page .svhs-footer-copy{margin:0}
|
|
20365
|
+
.svhs-page .svhs-results-bottom .svhs-secondary{width:auto;flex:none}
|
|
20239
20366
|
.svhs-page .svhs-contact-target,.svhs-page .svhs-contact-target>.svhd-container{min-height:0}
|
|
20367
|
+
.svhs-page .svhs-contact-scroll{padding:0}
|
|
20240
20368
|
.svhs-page .svhd-widget-form>.svhd-actions{position:static;margin:0;padding:16px 0 0}
|
|
20241
20369
|
.svhs-page .svhd-widget-form>.svhd-actions>.svhd-secondary{display:inline-flex}
|
|
20370
|
+
@media(max-width:640px){
|
|
20371
|
+
.svhs-page .svhs-toolbar{padding:4px 20px}
|
|
20372
|
+
.svhs-page .svhs-scroll{padding:24px 20px}
|
|
20373
|
+
.svhs-page .svhs-bottom{padding:20px}
|
|
20374
|
+
.svhs-page .svhs-start-bottom{padding-top:0}
|
|
20375
|
+
.svhs-page .svhs-start-bottom .svhs-primary{width:100%}
|
|
20376
|
+
.svhs-page[data-stage=issue] .svhs-heading{font-size:26px}
|
|
20377
|
+
.svhs-page .svhs-results-bottom{display:block}
|
|
20378
|
+
.svhs-page .svhs-results-bottom .svhs-secondary{width:100%;margin-top:14px}
|
|
20379
|
+
.svhs-page .svhs-contact-scroll{padding:0}
|
|
20380
|
+
}
|
|
20242
20381
|
`;
|
|
20243
20382
|
document.head.appendChild(style);
|
|
20244
20383
|
}
|
|
@@ -20410,6 +20549,149 @@ class SupportPhoneHistory {
|
|
|
20410
20549
|
}
|
|
20411
20550
|
}
|
|
20412
20551
|
|
|
20552
|
+
/**
|
|
20553
|
+
* A tenant's brand color and the WCAG contrast rules that decide how it may be
|
|
20554
|
+
* used: the one hex rule the server stores, the console checks and the portal
|
|
20555
|
+
* paints, the one contrast reading the console's readouts and the portal's
|
|
20556
|
+
* accent share, and the one way a readout writes that reading.
|
|
20557
|
+
*
|
|
20558
|
+
* A brand color is tenant-controlled, so it is used only when it is a
|
|
20559
|
+
* six-digit hex color, read case-insensitively and held in lowercase; anything
|
|
20560
|
+
* else (a color name, a CSS function, a value that runs on into more CSS) is
|
|
20561
|
+
* no color at all.
|
|
20562
|
+
*
|
|
20563
|
+
* A brand color can be any lightness, so whatever shows it picks what goes
|
|
20564
|
+
* with it: white or ink as the text on its fill, whichever reads more
|
|
20565
|
+
* strongly (at least 4.2:1 on any fill, as far as two inks reach on a
|
|
20566
|
+
* mid-tone), and the color itself as text only where it reaches 4.5:1 on
|
|
20567
|
+
* both grounds accent text stands on, the white surface and the canvas
|
|
20568
|
+
* tone, ink otherwise. accentProperties says that as the accent
|
|
20569
|
+
* custom properties the customer portal paints with and the console's sample
|
|
20570
|
+
* of it shows, in the design system's own tokens.
|
|
20571
|
+
*
|
|
20572
|
+
* BROWSER-SAFE: data only, no imports.
|
|
20573
|
+
*/
|
|
20574
|
+
|
|
20575
|
+
const HEX_COLOR = /^#[0-9a-f]{6}$/;
|
|
20576
|
+
|
|
20577
|
+
/** WCAG AA's floor for normal-size text. */
|
|
20578
|
+
const AA_TEXT_CONTRAST = 4.5;
|
|
20579
|
+
|
|
20580
|
+
/**
|
|
20581
|
+
* The canvas tone, the design system's `--canvas` (`--color-slate-50`): the
|
|
20582
|
+
* page ground the customer portal (its pages and a customer's own messages)
|
|
20583
|
+
* and the knowledge base's default theme set accent text on, beside the white
|
|
20584
|
+
* surface. The design system publishes its tokens only as CSS, which this
|
|
20585
|
+
* import-free module cannot read, so the value is mirrored here once, and
|
|
20586
|
+
* tests/brand-color.test.js holds it to packages/design-system/tokens/colors.css.
|
|
20587
|
+
*/
|
|
20588
|
+
const CANVAS_COLOR = '#f7fafb';
|
|
20589
|
+
|
|
20590
|
+
/**
|
|
20591
|
+
* The ink, the design system's `--ink` (`--color-slate-900`): the dark text a
|
|
20592
|
+
* pairing paints on a fill and in place of a color too light to stand as
|
|
20593
|
+
* text. Mirrored here once for the same reason as CANVAS_COLOR, and held to
|
|
20594
|
+
* packages/design-system/tokens/colors.css by tests/brand-color.test.js.
|
|
20595
|
+
*/
|
|
20596
|
+
const INK_COLOR = '#0d1a20';
|
|
20597
|
+
|
|
20598
|
+
/** Relative luminance (WCAG 2) of a validated `#rrggbb` color. */
|
|
20599
|
+
function relativeLuminance(color) {
|
|
20600
|
+
const [red, green, blue] = [1, 3, 5].map((offset) => {
|
|
20601
|
+
const channel = Number.parseInt(color.slice(offset, offset + 2), 16) / 255;
|
|
20602
|
+
return channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4;
|
|
20603
|
+
});
|
|
20604
|
+
return 0.2126 * red + 0.7152 * green + 0.0722 * blue;
|
|
20605
|
+
}
|
|
20606
|
+
|
|
20607
|
+
/** The contrast ratio of two relative luminances. */
|
|
20608
|
+
function contrastRatio(first, second) {
|
|
20609
|
+
return (Math.max(first, second) + 0.05) / (Math.min(first, second) + 0.05);
|
|
20610
|
+
}
|
|
20611
|
+
|
|
20612
|
+
/** The relative luminance of the ink a fill's text is weighed in, the real ink rather than pure black. */
|
|
20613
|
+
const INK_LUMINANCE = relativeLuminance(INK_COLOR);
|
|
20614
|
+
|
|
20615
|
+
/** The relative luminances of the grounds accent text stands on: the white surface and the canvas tone. */
|
|
20616
|
+
const TEXT_GROUNDS = Object.freeze([1, relativeLuminance(CANVAS_COLOR)]);
|
|
20617
|
+
|
|
20618
|
+
/** How strongly a color of this luminance reads as text on the ground it reads least on. */
|
|
20619
|
+
function textContrast(luminance) {
|
|
20620
|
+
return Math.min(...TEXT_GROUNDS.map((ground) => contrastRatio(luminance, ground)));
|
|
20621
|
+
}
|
|
20622
|
+
|
|
20623
|
+
/**
|
|
20624
|
+
* A brand color as it may be stored and shown, or null when the value is not
|
|
20625
|
+
* one: a `#rrggbb` hex value, read case-insensitively.
|
|
20626
|
+
*
|
|
20627
|
+
* @param {unknown} value
|
|
20628
|
+
* @returns {string|null} The color in lowercase
|
|
20629
|
+
*/
|
|
20630
|
+
function brandColor(value) {
|
|
20631
|
+
if (typeof value !== 'string') return null;
|
|
20632
|
+
const color = value.toLowerCase();
|
|
20633
|
+
return HEX_COLOR.test(color) ? color : null;
|
|
20634
|
+
}
|
|
20635
|
+
|
|
20636
|
+
/**
|
|
20637
|
+
* What goes with a brand color: the text on its fill (white or ink,
|
|
20638
|
+
* whichever reads more strongly, at least 4.2:1 on any fill) and the ink for
|
|
20639
|
+
* it as text
|
|
20640
|
+
* (the color itself where it reaches AA_TEXT_CONTRAST on both the white
|
|
20641
|
+
* surface and the canvas tone, ink otherwise).
|
|
20642
|
+
*
|
|
20643
|
+
* @param {unknown} value
|
|
20644
|
+
* @returns {{ onAccent: 'white'|'ink', accentInk: 'accent'|'ink', ratio: number }|null} Null when the value is not a brand color; `ratio` is its contrast as text (accentTextContrast)
|
|
20645
|
+
*/
|
|
20646
|
+
function accentPairing(value) {
|
|
20647
|
+
const color = brandColor(value);
|
|
20648
|
+
if (!color) return null;
|
|
20649
|
+
const luminance = relativeLuminance(color);
|
|
20650
|
+
const ratio = textContrast(luminance);
|
|
20651
|
+
return {
|
|
20652
|
+
onAccent: contrastRatio(luminance, 1) >= contrastRatio(luminance, INK_LUMINANCE) ? 'white' : 'ink',
|
|
20653
|
+
accentInk: ratio >= AA_TEXT_CONTRAST ? 'accent' : 'ink',
|
|
20654
|
+
ratio
|
|
20655
|
+
};
|
|
20656
|
+
}
|
|
20657
|
+
|
|
20658
|
+
/** Contrast between a brand fill and the label selected by accentPairing. */
|
|
20659
|
+
function accentFillContrast(value) {
|
|
20660
|
+
const color = brandColor(value);
|
|
20661
|
+
if (!color) return null;
|
|
20662
|
+
const pairing = accentPairing(color);
|
|
20663
|
+
return contrastRatio(relativeLuminance(color), pairing.onAccent === 'white' ? 1 : INK_LUMINANCE);
|
|
20664
|
+
}
|
|
20665
|
+
|
|
20666
|
+
/** Darken only the narrow range where neither white nor the product ink reaches AA. */
|
|
20667
|
+
function accessibleFill(color) {
|
|
20668
|
+
let fill = color;
|
|
20669
|
+
while ((accentFillContrast(fill) ?? 0) < AA_TEXT_CONTRAST) {
|
|
20670
|
+
fill = `#${[1, 3, 5].map(offset => Math.floor(Number.parseInt(fill.slice(offset, offset + 2), 16) * 0.98).toString(16).padStart(2, '0')).join('')}`;
|
|
20671
|
+
}
|
|
20672
|
+
return fill;
|
|
20673
|
+
}
|
|
20674
|
+
/** Scoped brand properties work in both a hosted page and an unrelated widget host. */
|
|
20675
|
+
function applySupportBrand(target, value) {
|
|
20676
|
+
const color = brandColor(value);
|
|
20677
|
+
if (!color) {
|
|
20678
|
+
for (const name of ['--hd-accent', '--hd-on-accent', '--hd-accent-ink', '--hd-accent-hover', '--hd-focus'])
|
|
20679
|
+
target.style.removeProperty(name);
|
|
20680
|
+
return;
|
|
20681
|
+
}
|
|
20682
|
+
const fill = accessibleFill(color);
|
|
20683
|
+
const pairing = accentPairing(fill);
|
|
20684
|
+
const ink = pairing.accentInk === 'accent' ? fill : DS.slate900;
|
|
20685
|
+
const label = pairing.onAccent === 'white' ? DS.white : DS.slate900;
|
|
20686
|
+
// Dark fills deepen on hover; light fills stay unchanged to preserve label contrast.
|
|
20687
|
+
const hover = pairing.onAccent === 'white'
|
|
20688
|
+
? `#${[1, 3, 5].map(offset => Math.floor(Number.parseInt(fill.slice(offset, offset + 2), 16) * 0.9).toString(16).padStart(2, '0')).join('')}`
|
|
20689
|
+
: fill;
|
|
20690
|
+
const properties = { '--hd-accent': fill, '--hd-on-accent': label, '--hd-accent-ink': ink, '--hd-accent-hover': hover, '--hd-focus': ink };
|
|
20691
|
+
for (const [name, content] of Object.entries(properties))
|
|
20692
|
+
target.style.setProperty(name, content);
|
|
20693
|
+
}
|
|
20694
|
+
|
|
20413
20695
|
/* global MediaQueryList, HTMLImageElement, HTMLAnchorElement, Element */
|
|
20414
20696
|
let sequence = 0;
|
|
20415
20697
|
function element(tag, className, text) {
|
|
@@ -20436,6 +20718,10 @@ function icon(name) {
|
|
|
20436
20718
|
close: 'm6 6 12 12M18 6 6 18',
|
|
20437
20719
|
external: 'M14 4h6v6m0-6L10 14M11 5H5a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h13a1 1 0 0 0 1-1v-6',
|
|
20438
20720
|
check: 'm5 12 4 4L19 6',
|
|
20721
|
+
article: 'M14 3H6a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8Zm0 0v5h5M8 12h8M8 16h6',
|
|
20722
|
+
chevron: 'm9 6 6 6-6 6',
|
|
20723
|
+
thumbUp: 'M7 10v11H3V10Zm0 1 5-8c2 0 3 1 2 4l-1 3h6a2 2 0 0 1 2 2l-2 7a2 2 0 0 1-2 2H7',
|
|
20724
|
+
thumbDown: 'M7 14V3H3v11Zm0-1 5 8c2 0 3-1 2-4l-1-3h6a2 2 0 0 0 2-2l-2-7a2 2 0 0 0-2-2H7',
|
|
20439
20725
|
}[name]);
|
|
20440
20726
|
svg.append(path);
|
|
20441
20727
|
return svg;
|
|
@@ -20485,6 +20771,11 @@ class SupportView {
|
|
|
20485
20771
|
this.articleStatus = element('p', 'svhs-status');
|
|
20486
20772
|
this.articleError = element('p', 'svhs-error');
|
|
20487
20773
|
this.articleFooter = element('div', 'svhs-article-footer');
|
|
20774
|
+
this.feedbackStatus = element('p', 'svhs-status');
|
|
20775
|
+
this.feedbackError = element('p', 'svhs-error');
|
|
20776
|
+
this.reviewPrompt = element('div', 'svhs-review');
|
|
20777
|
+
this.reviewLink = element('a', 'svhs-primary');
|
|
20778
|
+
this.sourceArticle = element('p', 'svhs-copy');
|
|
20488
20779
|
this.contactTitle = element('h2', 'svhs-heading');
|
|
20489
20780
|
this.contactStatus = element('p', 'svhs-status');
|
|
20490
20781
|
this.contactError = element('p', 'svhs-error');
|
|
@@ -20540,12 +20831,12 @@ class SupportView {
|
|
|
20540
20831
|
this.identityNotice.hidden = true;
|
|
20541
20832
|
this.panel.append(this.identityNotice);
|
|
20542
20833
|
const intro = this.screen('issue', 'How can we help?');
|
|
20543
|
-
intro.append(element('p', 'svhs-copy', '
|
|
20544
|
-
const issueLabel = element('label', 'svhs-
|
|
20834
|
+
intro.append(element('p', 'svhs-copy', 'Describe your question or issue.'));
|
|
20835
|
+
const issueLabel = element('label', 'svhs-label', 'What’s your question?');
|
|
20545
20836
|
issueLabel.htmlFor = `${this.prefix}-issue`;
|
|
20546
20837
|
this.issue.id = issueLabel.htmlFor;
|
|
20547
20838
|
this.issue.name = 'support_issue';
|
|
20548
|
-
this.issue.placeholder = 'Describe
|
|
20839
|
+
this.issue.placeholder = 'Describe what you need help with…';
|
|
20549
20840
|
this.issue.autocomplete = 'off';
|
|
20550
20841
|
this.issue.setAttribute('aria-describedby', `${this.prefix}-issue-error`);
|
|
20551
20842
|
this.issueError.id = `${this.prefix}-issue-error`;
|
|
@@ -20564,17 +20855,28 @@ class SupportView {
|
|
|
20564
20855
|
}
|
|
20565
20856
|
});
|
|
20566
20857
|
intro.append(issueLabel, this.issue, this.issueError);
|
|
20567
|
-
this.find = button('svhs-primary', '
|
|
20568
|
-
this.footer('issue', 'svhs-start-bottom').append(this.find
|
|
20569
|
-
const results = this.screen('results', 'These may help');
|
|
20858
|
+
this.find = button('svhs-primary', 'Continue', () => this.search());
|
|
20859
|
+
this.footer('issue', 'svhs-start-bottom').append(this.find);
|
|
20860
|
+
const results = this.screen('results', 'These articles may help');
|
|
20570
20861
|
const queryLine = element('div', 'svhs-query');
|
|
20571
|
-
|
|
20572
|
-
|
|
20862
|
+
const question = element('div', 'svhs-question');
|
|
20863
|
+
question.append(element('span', 'svhs-question-label', 'Your question'), this.query);
|
|
20864
|
+
const editQuestion = button('svhs-text-button', 'Edit', () => this.actions.onBack());
|
|
20865
|
+
editQuestion.setAttribute('aria-label', 'Edit your question');
|
|
20866
|
+
queryLine.append(question, editQuestion);
|
|
20867
|
+
results.prepend(queryLine);
|
|
20868
|
+
results.append(this.resultCopy, this.resultList, this.resultStatus, this.resultError);
|
|
20573
20869
|
this.resultError.setAttribute('role', 'alert');
|
|
20574
|
-
this.contactResults = button('svhs-secondary svhs-full', '
|
|
20575
|
-
|
|
20870
|
+
this.contactResults = button('svhs-secondary svhs-full', 'Create a support ticket', () => {
|
|
20871
|
+
if (this.state?.busy)
|
|
20872
|
+
return;
|
|
20873
|
+
this.actions.onContact(['locked', 'unavailable'].includes(this.state?.kbState || '') ? 'direct' : this.state?.results?.length ? 'none_match' : 'no_results');
|
|
20576
20874
|
});
|
|
20577
|
-
this.footer('results')
|
|
20875
|
+
this.resultsFooter = this.footer('results');
|
|
20876
|
+
this.resultsFooter.classList.add('svhs-results-bottom');
|
|
20877
|
+
const escalation = element('div', 'svhs-escalation');
|
|
20878
|
+
escalation.append(element('p', 'svhs-footer-title', 'Still need help?'), element('p', 'svhs-footer-copy', 'Send your question to our support team.'));
|
|
20879
|
+
this.resultsFooter.append(escalation, this.contactResults);
|
|
20578
20880
|
const article = this.screen('article');
|
|
20579
20881
|
article.classList.add('svhs-article-scroll');
|
|
20580
20882
|
this.articleTitle.tabIndex = -1;
|
|
@@ -20586,18 +20888,37 @@ class SupportView {
|
|
|
20586
20888
|
article.append(this.articleCategory, this.articleTitle, this.articleStatus, this.articleContent, this.articleError, this.articleRetry);
|
|
20587
20889
|
this.articleContent.addEventListener('click', (event) => this.articleLink(event));
|
|
20588
20890
|
const readerActions = element('div', 'svhs-reader-actions');
|
|
20589
|
-
|
|
20590
|
-
this.actions.onAnswered(); })
|
|
20591
|
-
|
|
20891
|
+
const yes = button('svhs-primary', 'Yes', () => { if (this.state?.article && !this.state.busy && !this.state.error)
|
|
20892
|
+
this.actions.onAnswered(); });
|
|
20893
|
+
yes.prepend(icon('thumbUp'));
|
|
20894
|
+
const no = button('svhs-text-button', 'No, create a ticket', () => this.actions.onContact('article_not_answered'));
|
|
20895
|
+
no.prepend(icon('thumbDown'));
|
|
20896
|
+
readerActions.append(yes, no);
|
|
20897
|
+
this.articleFooter.append(element('span', 'svhs-article-question', 'Did this resolve your question?'), readerActions);
|
|
20592
20898
|
this.screens.get('article').append(this.articleFooter);
|
|
20593
|
-
const feedback = this.screen('feedback', 'Did this
|
|
20899
|
+
const feedback = this.screen('feedback', 'Did this resolve your question?');
|
|
20594
20900
|
feedback.classList.add('svhs-feedback-scroll');
|
|
20595
20901
|
feedback.append(element('p', 'svhs-copy', 'Your feedback helps us improve our help articles.'));
|
|
20596
20902
|
const feedbackActions = element('div', 'svhs-feedback-actions');
|
|
20597
|
-
feedbackActions.append(button('svhs-primary', 'Yes
|
|
20903
|
+
feedbackActions.append(button('svhs-primary', 'Yes', () => this.actions.onAnswered()), button('svhs-secondary', 'No, create a ticket', () => this.actions.onContact('article_not_answered')));
|
|
20598
20904
|
if (!target)
|
|
20599
20905
|
feedbackActions.append(button('svhs-text-button', 'Not now', () => this.actions.onClose()));
|
|
20600
20906
|
feedback.append(feedbackActions);
|
|
20907
|
+
const resolved = this.screen('resolved', 'Thanks for letting us know');
|
|
20908
|
+
resolved.classList.add('svhs-feedback-scroll');
|
|
20909
|
+
this.feedbackStatus.setAttribute('role', 'status');
|
|
20910
|
+
this.feedbackError.setAttribute('role', 'alert');
|
|
20911
|
+
this.retryFeedback = button('svhs-secondary', 'Try saving feedback again', () => this.actions.onRetryFeedback?.());
|
|
20912
|
+
this.reviewLink.textContent = 'Leave a review';
|
|
20913
|
+
this.reviewLink.target = '_blank';
|
|
20914
|
+
this.reviewLink.rel = 'noopener noreferrer';
|
|
20915
|
+
this.reviewPrompt.append(element('p', 'svhs-copy', 'Would you like to share your experience in a review?'), this.reviewLink);
|
|
20916
|
+
resolved.append(this.feedbackStatus, this.feedbackError, this.retryFeedback, this.reviewPrompt);
|
|
20917
|
+
const resolvedActions = element('div', 'svhs-feedback-actions');
|
|
20918
|
+
resolvedActions.append(button('svhs-text-button', 'Ask another question', () => this.actions.onRestart?.()));
|
|
20919
|
+
if (!target)
|
|
20920
|
+
resolvedActions.append(button('svhs-secondary', 'Done', () => this.actions.onClose()));
|
|
20921
|
+
resolved.append(resolvedActions);
|
|
20601
20922
|
const contact = this.screen('contact');
|
|
20602
20923
|
contact.classList.add('svhs-contact-scroll');
|
|
20603
20924
|
const contactPrelude = element('div', 'svhs-contact-prelude');
|
|
@@ -20607,6 +20928,7 @@ class SupportView {
|
|
|
20607
20928
|
this.contactError.id = `${this.prefix}-contact-error`;
|
|
20608
20929
|
this.contactRetry = button('svhs-secondary', 'Try again', () => this.actions.onRetry?.());
|
|
20609
20930
|
contactPrelude.append(this.contactTitle, this.contactStatus, this.contactError, this.contactRetry);
|
|
20931
|
+
contactPrelude.append(this.sourceArticle);
|
|
20610
20932
|
contact.append(contactPrelude);
|
|
20611
20933
|
contact.append(this.ticketGate);
|
|
20612
20934
|
contact.append(this.contactTarget);
|
|
@@ -20652,6 +20974,7 @@ class SupportView {
|
|
|
20652
20974
|
if (previous)
|
|
20653
20975
|
this.saveScroll(previous);
|
|
20654
20976
|
this.state = next;
|
|
20977
|
+
applySupportBrand(this.panel, next.brandColor);
|
|
20655
20978
|
this.panel.dataset.stage = next.stage;
|
|
20656
20979
|
const inset = (value, fallback) => typeof value === 'number' && Number.isFinite(value) ? Math.min(480, Math.max(0, value)) : fallback;
|
|
20657
20980
|
this.panel.style.setProperty('--svhs-right', `${inset(next.position?.right, 24)}px`);
|
|
@@ -20663,7 +20986,10 @@ class SupportView {
|
|
|
20663
20986
|
this.back.disabled = Boolean(next.navigationLocked || next.identityPending);
|
|
20664
20987
|
this.back.lastChild.textContent = next.stage === 'article' ? 'All answers' : next.stage === 'feedback' ? 'Keep reading' : 'Back';
|
|
20665
20988
|
this.deskName.hidden = next.stage === 'article';
|
|
20666
|
-
this.
|
|
20989
|
+
const heading = this.headings.get(next.stage);
|
|
20990
|
+
if (heading && !heading.id)
|
|
20991
|
+
heading.id = `${this.prefix}-${next.stage}-title`;
|
|
20992
|
+
this.panel.setAttribute('aria-labelledby', this.target && heading ? heading.id : next.stage === 'article' ? this.articleTitle.id : this.deskName.id);
|
|
20667
20993
|
for (const [stage, screen] of this.screens)
|
|
20668
20994
|
screen.hidden = stage !== next.stage;
|
|
20669
20995
|
if (this.issue.value !== next.issue)
|
|
@@ -20674,7 +21000,7 @@ class SupportView {
|
|
|
20674
21000
|
this.find.replaceChildren();
|
|
20675
21001
|
if (next.busy)
|
|
20676
21002
|
this.find.append(element('span', 'svhs-spinner'));
|
|
20677
|
-
this.find.append(document.createTextNode(next.busy ? '
|
|
21003
|
+
this.find.append(document.createTextNode(next.busy ? 'Continuing…' : 'Continue'));
|
|
20678
21004
|
this.issueError.textContent = next.stage === 'issue' ? next.error || '' : '';
|
|
20679
21005
|
this.issueError.hidden = !this.issueError.textContent;
|
|
20680
21006
|
this.query.textContent = next.issue;
|
|
@@ -20687,7 +21013,20 @@ class SupportView {
|
|
|
20687
21013
|
this.contactError.textContent = next.stage === 'contact' ? next.error || '' : '';
|
|
20688
21014
|
this.contactError.hidden = !this.contactError.textContent;
|
|
20689
21015
|
this.contactRetry.hidden = Boolean(next.ticketAccessRequired) || !this.contactError.textContent || !this.actions.onRetry || Boolean(next.busy);
|
|
20690
|
-
this.
|
|
21016
|
+
this.sourceArticle.textContent = next.sourceArticle ? `Article you read: ${next.sourceArticle.title}` : '';
|
|
21017
|
+
this.sourceArticle.hidden = !next.sourceArticle;
|
|
21018
|
+
this.contactTitle.parentElement.hidden = this.contactTitle.hidden && this.contactStatus.hidden && this.contactError.hidden && this.sourceArticle.hidden;
|
|
21019
|
+
this.feedbackStatus.textContent = next.feedbackBusy ? 'Saving your feedback...' : next.feedbackError ? '' : next.article?.kind === 'faq' ? 'We are glad that helped.' : 'Your feedback has been saved.';
|
|
21020
|
+
this.feedbackError.textContent = next.feedbackError || '';
|
|
21021
|
+
this.feedbackError.hidden = !next.feedbackError;
|
|
21022
|
+
this.retryFeedback.hidden = !next.feedbackError || !this.actions.onRetryFeedback;
|
|
21023
|
+
const review = httpUrl(next.reviewUrl);
|
|
21024
|
+
const safeReview = review?.protocol === 'https:' ? review : null;
|
|
21025
|
+
this.reviewPrompt.hidden = !safeReview;
|
|
21026
|
+
if (safeReview)
|
|
21027
|
+
this.reviewLink.href = safeReview.href;
|
|
21028
|
+
else
|
|
21029
|
+
this.reviewLink.removeAttribute('href');
|
|
20691
21030
|
this.renderTicketGate(next);
|
|
20692
21031
|
this.renderReceipt(next);
|
|
20693
21032
|
this.syncPresentation();
|
|
@@ -20708,7 +21047,7 @@ class SupportView {
|
|
|
20708
21047
|
return;
|
|
20709
21048
|
const heading = this.contactTarget.querySelector('h1,h2,h3');
|
|
20710
21049
|
this.contactTitle.hidden = Boolean(heading);
|
|
20711
|
-
this.contactTitle.parentElement.hidden = this.contactTitle.hidden && this.contactStatus.hidden && this.contactError.hidden;
|
|
21050
|
+
this.contactTitle.parentElement.hidden = this.contactTitle.hidden && this.contactStatus.hidden && this.contactError.hidden && this.sourceArticle.hidden;
|
|
20712
21051
|
const target = heading ?? this.contactTarget;
|
|
20713
21052
|
target.tabIndex = -1;
|
|
20714
21053
|
target.focus({ preventScroll: !this.target });
|
|
@@ -20866,6 +21205,10 @@ class SupportView {
|
|
|
20866
21205
|
}
|
|
20867
21206
|
renderResults(state) {
|
|
20868
21207
|
const results = state.results ?? [];
|
|
21208
|
+
this.headings.get('results').textContent = state.busy ? 'Checking for helpful articles…'
|
|
21209
|
+
: state.kbState === 'locked' ? 'View helpful articles'
|
|
21210
|
+
: results.length && state.kbState !== 'unavailable' ? 'These articles may help'
|
|
21211
|
+
: 'Let’s get you some help';
|
|
20869
21212
|
const signature = JSON.stringify(results);
|
|
20870
21213
|
if (signature !== this.resultSignature) {
|
|
20871
21214
|
this.resultSignature = signature;
|
|
@@ -20873,16 +21216,22 @@ class SupportView {
|
|
|
20873
21216
|
for (const result of results) {
|
|
20874
21217
|
const item = element('li');
|
|
20875
21218
|
const open = button('svhs-result', '', () => this.actions.onOpenArticle(result.id));
|
|
20876
|
-
|
|
21219
|
+
const copy = element('span', 'svhs-result-copy');
|
|
21220
|
+
copy.append(element('span', 'svhs-result-title', result.title));
|
|
20877
21221
|
if (result.summary)
|
|
20878
|
-
|
|
21222
|
+
copy.append(element('span', 'svhs-result-excerpt', result.summary));
|
|
20879
21223
|
if (result.category)
|
|
20880
|
-
|
|
21224
|
+
copy.append(element('span', 'svhs-result-category', result.category));
|
|
21225
|
+
const documentIcon = icon('article');
|
|
21226
|
+
documentIcon.classList.add('svhs-result-icon');
|
|
21227
|
+
const chevron = icon('chevron');
|
|
21228
|
+
chevron.classList.add('svhs-result-chevron');
|
|
21229
|
+
open.append(documentIcon, copy, chevron);
|
|
20881
21230
|
item.append(open);
|
|
20882
21231
|
this.resultList.append(item);
|
|
20883
21232
|
}
|
|
20884
21233
|
}
|
|
20885
|
-
this.resultCopy.textContent =
|
|
21234
|
+
this.resultCopy.textContent = 'Choose an article to read the full answer.';
|
|
20886
21235
|
this.resultList.hidden = Boolean(state.busy) || state.kbState === 'locked' || state.kbState === 'unavailable';
|
|
20887
21236
|
this.resultCopy.hidden = this.resultList.hidden || results.length === 0;
|
|
20888
21237
|
this.resultError.textContent = state.stage === 'results' ? state.error || '' : '';
|
|
@@ -20892,7 +21241,8 @@ class SupportView {
|
|
|
20892
21241
|
control.setAttribute('aria-disabled', String(Boolean(state.busy)));
|
|
20893
21242
|
control.setAttribute('aria-busy', String(Boolean(state.busy)));
|
|
20894
21243
|
}
|
|
20895
|
-
this.
|
|
21244
|
+
this.resultsFooter.hidden = Boolean(state.busy);
|
|
21245
|
+
this.contactResults.disabled = Boolean(state.busy);
|
|
20896
21246
|
}
|
|
20897
21247
|
renderResultStatus(state, results) {
|
|
20898
21248
|
const signature = state.kbState === 'locked' ? `locked:${state.kbAccessMode}` : state.busy ? 'busy' : state.kbState === 'unavailable' ? 'unavailable' : results.length ? 'matches' : 'empty';
|
|
@@ -21280,6 +21630,8 @@ function createHelpDeskSupport(config, options) {
|
|
|
21280
21630
|
let cancelArticleAssets = null;
|
|
21281
21631
|
let stopSession = null;
|
|
21282
21632
|
let anonymous = false;
|
|
21633
|
+
let feedbackSequence = 0;
|
|
21634
|
+
let sourceArticleId;
|
|
21283
21635
|
const lifetime = new AbortController();
|
|
21284
21636
|
const bindings = new Set();
|
|
21285
21637
|
let state = { visible: false, stage: 'issue', deskName: 'Support', issue: '' };
|
|
@@ -21319,7 +21671,9 @@ function createHelpDeskSupport(config, options) {
|
|
|
21319
21671
|
update({ stage: 'issue', error: undefined });
|
|
21320
21672
|
},
|
|
21321
21673
|
onClose: () => {
|
|
21322
|
-
if (state.stage === '
|
|
21674
|
+
if (state.stage === 'resolved')
|
|
21675
|
+
resetJourney(false);
|
|
21676
|
+
else if (state.stage === 'article' && state.article)
|
|
21323
21677
|
update({ stage: 'feedback', error: undefined });
|
|
21324
21678
|
else {
|
|
21325
21679
|
if (state.stage === 'feedback')
|
|
@@ -21327,13 +21681,8 @@ function createHelpDeskSupport(config, options) {
|
|
|
21327
21681
|
minimize();
|
|
21328
21682
|
}
|
|
21329
21683
|
},
|
|
21330
|
-
onAnswered: () => {
|
|
21331
|
-
|
|
21332
|
-
return;
|
|
21333
|
-
void attempt?.then((active) => active?.solved());
|
|
21334
|
-
resetJourney(options.target !== undefined);
|
|
21335
|
-
view.showToast('We’re happy we could help.');
|
|
21336
|
-
},
|
|
21684
|
+
onAnswered: () => { void answerArticle(); },
|
|
21685
|
+
onRetryFeedback: () => { void answerArticle(); },
|
|
21337
21686
|
onRestart: () => {
|
|
21338
21687
|
resetJourney(state.visible);
|
|
21339
21688
|
},
|
|
@@ -21391,7 +21740,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
21391
21740
|
return (await http.request(path, { method: 'POST', body, credentials: 'omit', headers: { 'X-SV-Client': 'help-desk-portal', ...headers } })).data;
|
|
21392
21741
|
},
|
|
21393
21742
|
});
|
|
21394
|
-
update({ deskName: answer.desk.organization_name || 'Support' });
|
|
21743
|
+
update({ deskName: answer.desk.organization_name || 'Support', brandColor: answer.desk.branding?.color });
|
|
21395
21744
|
return answer;
|
|
21396
21745
|
}).catch((error) => { connected = null; throw error; });
|
|
21397
21746
|
return connected;
|
|
@@ -21404,6 +21753,10 @@ function createHelpDeskSupport(config, options) {
|
|
|
21404
21753
|
update({ visible: true });
|
|
21405
21754
|
try {
|
|
21406
21755
|
const active = await connect();
|
|
21756
|
+
if (input.articleId && state.stage === 'issue' && !contact) {
|
|
21757
|
+
await contactFromArticle(input.articleId);
|
|
21758
|
+
return;
|
|
21759
|
+
}
|
|
21407
21760
|
if (!options.persist || destroyed || state.stage !== 'issue')
|
|
21408
21761
|
return;
|
|
21409
21762
|
const token = await active.getSessionToken();
|
|
@@ -21441,6 +21794,57 @@ function createHelpDeskSupport(config, options) {
|
|
|
21441
21794
|
}
|
|
21442
21795
|
}
|
|
21443
21796
|
function minimize() { update({ visible: false }); }
|
|
21797
|
+
async function answerArticle() {
|
|
21798
|
+
const article = state.article;
|
|
21799
|
+
if (destroyed || !article || state.feedbackBusy)
|
|
21800
|
+
return;
|
|
21801
|
+
const ownFeedback = ++feedbackSequence;
|
|
21802
|
+
void attempt?.then((active) => active?.solved());
|
|
21803
|
+
update({ stage: 'resolved', feedbackBusy: article.kind === 'article', feedbackError: undefined, reviewUrl: undefined, error: undefined });
|
|
21804
|
+
if (article.kind !== 'article' || !kb)
|
|
21805
|
+
return;
|
|
21806
|
+
try {
|
|
21807
|
+
const saved = await kb.vote(article, 'yes');
|
|
21808
|
+
if (destroyed || ownFeedback !== feedbackSequence || state.stage !== 'resolved')
|
|
21809
|
+
return;
|
|
21810
|
+
update({ feedbackBusy: false, reviewUrl: saved.review_url || undefined });
|
|
21811
|
+
}
|
|
21812
|
+
catch (value) {
|
|
21813
|
+
if (destroyed || ownFeedback !== feedbackSequence || state.stage !== 'resolved')
|
|
21814
|
+
return;
|
|
21815
|
+
update({ feedbackBusy: false, feedbackError: failure(value).message });
|
|
21816
|
+
}
|
|
21817
|
+
}
|
|
21818
|
+
/** Article feedback has already happened in the help center; skip suggestions and preserve its trusted reference. */
|
|
21819
|
+
async function contactFromArticle(id) {
|
|
21820
|
+
const ownSequence = ++sequence;
|
|
21821
|
+
update({ busy: true, error: undefined });
|
|
21822
|
+
try {
|
|
21823
|
+
if (!kb || typeof id !== 'string' || !id || id.length > 256)
|
|
21824
|
+
throw new ValidationError('Choose a published article.');
|
|
21825
|
+
sourceArticleId = id;
|
|
21826
|
+
const result = await kb.resolveArticle(id);
|
|
21827
|
+
if (!result)
|
|
21828
|
+
throw new ValidationError('This article is no longer available.');
|
|
21829
|
+
const article = await kb.read(result);
|
|
21830
|
+
if (destroyed || ownSequence !== sequence)
|
|
21831
|
+
return;
|
|
21832
|
+
requestedArticle = result;
|
|
21833
|
+
kbConfig = await kb.load();
|
|
21834
|
+
if (destroyed || ownSequence !== sequence)
|
|
21835
|
+
return;
|
|
21836
|
+
update({ article, sourceArticle: { title: article.title, url: article.canonical_url }, busy: false });
|
|
21837
|
+
void startAttempt(true, article.release_id, 1).then((active) => active?.articleOpened(article.id, article.release_id));
|
|
21838
|
+
await showContact('article_not_answered');
|
|
21839
|
+
}
|
|
21840
|
+
catch {
|
|
21841
|
+
if (destroyed || ownSequence !== sequence)
|
|
21842
|
+
return;
|
|
21843
|
+
// A stale or protected article must not stop someone asking for help.
|
|
21844
|
+
update({ busy: false, article: undefined, sourceArticle: undefined });
|
|
21845
|
+
await showContact('direct');
|
|
21846
|
+
}
|
|
21847
|
+
}
|
|
21444
21848
|
/** Forget a finished journey: its form and the files it authorized, any composition held for it, its suggestions and article. */
|
|
21445
21849
|
function resetJourney(visible) {
|
|
21446
21850
|
contact?.destroy();
|
|
@@ -21453,10 +21857,13 @@ function createHelpDeskSupport(config, options) {
|
|
|
21453
21857
|
results = [];
|
|
21454
21858
|
requestedArticle = null;
|
|
21455
21859
|
pendingComposition = null;
|
|
21860
|
+
feedbackSequence += 1;
|
|
21861
|
+
sourceArticleId = undefined;
|
|
21456
21862
|
if (options.persist && client)
|
|
21457
21863
|
clearSupportIssue(client.desk.desk_id);
|
|
21458
21864
|
update({ visible, stage: 'issue', issue: '', results: [], article: undefined, articleUrl: undefined,
|
|
21459
|
-
receipt: undefined, error: undefined, busy: false, navigationLocked: false
|
|
21865
|
+
receipt: undefined, error: undefined, busy: false, navigationLocked: false, sourceArticle: undefined,
|
|
21866
|
+
feedbackBusy: false, feedbackError: undefined, reviewUrl: undefined });
|
|
21460
21867
|
}
|
|
21461
21868
|
function signIn(input = {}) {
|
|
21462
21869
|
if (!client)
|
|
@@ -21489,8 +21896,9 @@ function createHelpDeskSupport(config, options) {
|
|
|
21489
21896
|
async function search(issue) {
|
|
21490
21897
|
if (destroyed || !issue.trim())
|
|
21491
21898
|
return;
|
|
21899
|
+
sourceArticleId = undefined;
|
|
21492
21900
|
const ownSequence = ++sequence;
|
|
21493
|
-
update({ stage: 'results', issue, busy: true, error: undefined, results: [], article: undefined, kbState: undefined });
|
|
21901
|
+
update({ stage: 'results', issue, busy: true, error: undefined, results: [], article: undefined, kbState: undefined, sourceArticle: undefined });
|
|
21494
21902
|
results = [];
|
|
21495
21903
|
try {
|
|
21496
21904
|
const active = await connect();
|
|
@@ -21634,6 +22042,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
21634
22042
|
...(switchedAccount && (options.getSessionToken || options.getIdentityAssertion || options.identityEndpoint) ? { useWebsiteAccount: (safe) => { void useWebsiteAccount(safe); } } : {}),
|
|
21635
22043
|
},
|
|
21636
22044
|
assistanceContext: () => activeAttempt?.ticketContext(),
|
|
22045
|
+
sourceArticleId: () => sourceArticleId,
|
|
21637
22046
|
onError: (error) => {
|
|
21638
22047
|
notify(options.onError, error);
|
|
21639
22048
|
if (['HELP_DESK_ACCESS_REQUIRED', 'HELP_DESK_IP_DENIED'].includes(errorCode(error) ?? ''))
|
|
@@ -21679,6 +22088,14 @@ function createHelpDeskSupport(config, options) {
|
|
|
21679
22088
|
async function showContact(reason) {
|
|
21680
22089
|
if (destroyed || contactOpening === sequence)
|
|
21681
22090
|
return;
|
|
22091
|
+
if (reason === 'article_not_answered' && state.article) {
|
|
22092
|
+
const article = state.article;
|
|
22093
|
+
sourceArticleId = article.id;
|
|
22094
|
+
update({ sourceArticle: { title: article.title, url: article.canonical_url } });
|
|
22095
|
+
// The article vote and assistance outcome serve different reports. Neither may block contacting the team.
|
|
22096
|
+
if (article.kind === 'article' && kb)
|
|
22097
|
+
void kb.vote(article, 'no').catch(() => undefined);
|
|
22098
|
+
}
|
|
21682
22099
|
followIssue();
|
|
21683
22100
|
cancelArticleAssets?.();
|
|
21684
22101
|
cancelArticleAssets = null;
|
|
@@ -21787,6 +22204,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
21787
22204
|
results = [];
|
|
21788
22205
|
requestedArticle = null;
|
|
21789
22206
|
attempt = null;
|
|
22207
|
+
sourceArticleId = undefined;
|
|
21790
22208
|
update({ results: [], article: undefined, articleUrl: undefined, kbState: undefined });
|
|
21791
22209
|
switchedAccount = true;
|
|
21792
22210
|
const logout = active.switchSupportAccount();
|
|
@@ -21834,6 +22252,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
21834
22252
|
results = [];
|
|
21835
22253
|
requestedArticle = null;
|
|
21836
22254
|
attempt = null;
|
|
22255
|
+
sourceArticleId = undefined;
|
|
21837
22256
|
update({ busy: true, error: undefined, results: [], article: undefined, articleUrl: undefined, kbState: undefined });
|
|
21838
22257
|
try {
|
|
21839
22258
|
await client.useWebsiteAccount();
|
|
@@ -25817,7 +26236,7 @@ class VaultsModule {
|
|
|
25817
26236
|
* Update a vault's upload settings (max size, notification email).
|
|
25818
26237
|
*
|
|
25819
26238
|
* @example
|
|
25820
|
-
* await sv.vaults.updateUploadConfig('vlt_abc', { maxSizeBytes:
|
|
26239
|
+
* await sv.vaults.updateUploadConfig('vlt_abc', { maxSizeBytes: 5 * 1024 ** 4 });
|
|
25821
26240
|
*/
|
|
25822
26241
|
async updateUploadConfig(vaultId, config) {
|
|
25823
26242
|
const id = requireResourceId(vaultId, 'vaultId');
|
|
@@ -26662,7 +27081,7 @@ class SparkVault {
|
|
|
26662
27081
|
}
|
|
26663
27082
|
/** Get the SDK version */
|
|
26664
27083
|
static get version() {
|
|
26665
|
-
return '15.14.
|
|
27084
|
+
return '15.14.3';
|
|
26666
27085
|
}
|
|
26667
27086
|
}
|
|
26668
27087
|
if (typeof window !== 'undefined') {
|