@sparkvault/sdk-js 17.0.2 → 18.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -12
- package/dist/index.cjs +881 -349
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +16 -11
- package/dist/index.mjs +881 -349
- package/dist/index.mjs.map +1 -1
- package/dist/products/help-desk/client.d.ts +0 -4
- package/dist/products/help-desk/form-types.d.ts +3 -0
- package/dist/products/help-desk/kb-types.d.ts +1 -2
- package/dist/products/help-desk/styles.d.ts +8 -1
- package/dist/products/help-desk/support-brand.d.ts +49 -2
- package/dist/products/help-desk/support-launcher.d.ts +8 -2
- package/dist/products/help-desk/support-styles.d.ts +8 -1
- package/dist/products/help-desk/support-view.d.ts +3 -1
- package/dist/products/help-desk/types.d.ts +1 -5
- package/dist/products/help-desk/widget-identity.d.ts +2 -2
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1159,6 +1159,18 @@ const SPARKVAULT_FILES_HOST = 'files.sv';
|
|
|
1159
1159
|
*/
|
|
1160
1160
|
const SPARKVAULT_HELP_DESK_DOMAIN = 'help.sv';
|
|
1161
1161
|
|
|
1162
|
+
/**
|
|
1163
|
+
* The Help Desk sign-in host (`https://signin.help.sv`): the one fixed host of
|
|
1164
|
+
* the window Help Desk's own sign-in opens (`/{desk_id}/{challenge_id}`) and
|
|
1165
|
+
* of the one redirect URI its Identity client registers (`/callback`). Its
|
|
1166
|
+
* label is a reserved organization handle (organization-handle.js), so no desk
|
|
1167
|
+
* can hold it, and the help.sv Worker serves the portal's shell on it as on
|
|
1168
|
+
* every host of the domain. Like every host under the help-desk domain it is
|
|
1169
|
+
* reserved and not owned (isSparkVaultOwnedHostname). Core takes the window's
|
|
1170
|
+
* steps only from exactly this origin.
|
|
1171
|
+
*/
|
|
1172
|
+
const SPARKVAULT_HELP_DESK_SIGN_IN_HOST = `signin.${SPARKVAULT_HELP_DESK_DOMAIN}`;
|
|
1173
|
+
|
|
1162
1174
|
/**
|
|
1163
1175
|
* Notify's mail domain: each organization's Notify mail goes from a host under
|
|
1164
1176
|
* it, as its help desk's goes from one under the help-desk domain. On the web
|
|
@@ -14741,8 +14753,8 @@ Array.from({ length: 1 << BRAND_BITS.size }, (_, mask) =>
|
|
|
14741
14753
|
* presets, size limits, the operator display and desk mode choices, the
|
|
14742
14754
|
* operator queue's views and orders, the reply review list's views and
|
|
14743
14755
|
* states, the response-time histogram's bucket edges, the sections of a
|
|
14744
|
-
* desk's settings an address names, and the messages
|
|
14745
|
-
* sign-in posts between the website and its
|
|
14756
|
+
* desk's settings an address names, and the messages Help Desk's own
|
|
14757
|
+
* sign-in posts between the website and its sign-in window live here for
|
|
14746
14758
|
* the same reason. So does the one rule a typed or pasted sign-in code is
|
|
14747
14759
|
* read by (helpDeskPinDigits), which every sign-in form applies. So does the
|
|
14748
14760
|
* one way a client names a message it sends (newMessageId), which the
|
|
@@ -14770,14 +14782,15 @@ const HELP_DESK_CLOSE_REASONS = Object.freeze(['resolved', 'duplicate', 'spam'])
|
|
|
14770
14782
|
Object.freeze(HELP_DESK_CLOSE_REASONS.filter((reason) => reason !== 'duplicate'));
|
|
14771
14783
|
|
|
14772
14784
|
/**
|
|
14773
|
-
* The messages
|
|
14774
|
-
* window (the JS SDK's openWidgetIdentity) and the
|
|
14775
|
-
*
|
|
14776
|
-
*
|
|
14777
|
-
*
|
|
14778
|
-
* sign-in's code
|
|
14779
|
-
*
|
|
14780
|
-
*
|
|
14785
|
+
* The messages Help Desk's own sign-in exchanges between the website's
|
|
14786
|
+
* window (the JS SDK's openWidgetIdentity) and the sign-in window it opens on
|
|
14787
|
+
* the Help Desk sign-in host (the portal's sign-in window page): the window
|
|
14788
|
+
* asks its opener for the challenge's state (`ready`), the opener answers its
|
|
14789
|
+
* own popup alone, at the sign-in origin (`state`), and the window reports
|
|
14790
|
+
* the sign-in's code, only once the person confirms it, or its cancellation
|
|
14791
|
+
* (`result`) to the website's origin alone. Every message names its
|
|
14792
|
+
* challenge, and the state is never in the window's URL, so only the window
|
|
14793
|
+
* that started a challenge can complete it.
|
|
14781
14794
|
*/
|
|
14782
14795
|
const HELP_DESK_WIDGET_IDENTITY_MESSAGES = Object.freeze({
|
|
14783
14796
|
ready: 'sparkvault:help-desk:identity-ready',
|
|
@@ -17953,22 +17966,24 @@ function mapInvitation(wire) {
|
|
|
17953
17966
|
};
|
|
17954
17967
|
}
|
|
17955
17968
|
|
|
17956
|
-
/** The native support ceremony. Identity
|
|
17969
|
+
/** The native support ceremony. Identity's answer stays inside the Help Desk sign-in window. */
|
|
17957
17970
|
const VALUE = /^[A-Za-z0-9_-]{43}$/;
|
|
17971
|
+
/** The one origin the sign-in window runs on. Never read from the challenge's sign-in URL, which is checked against it. */
|
|
17972
|
+
const SIGN_IN_ORIGIN = `https://${SPARKVAULT_HELP_DESK_SIGN_IN_HOST}`;
|
|
17958
17973
|
/** The website's own opener policy cut the window off: no retry on this page can work, only its owner can fix it. */
|
|
17959
17974
|
const SEVERED_MESSAGE = 'This website stops the support sign-in window from reporting back, so sign-in cannot finish here. Let the website\'s owner know.';
|
|
17960
|
-
/** How often the sign-in window's handle is checked once it leaves for
|
|
17975
|
+
/** How often the sign-in window's handle is checked once it leaves for its start page. */
|
|
17961
17976
|
const HANDLE_CHECK_MS = 500;
|
|
17962
17977
|
/**
|
|
17963
17978
|
* What a sign-in window's handle reading `closed` before its page's ready
|
|
17964
17979
|
* message means. A website serving `Cross-Origin-Opener-Policy: same-origin`
|
|
17965
|
-
* severs the window the moment its
|
|
17980
|
+
* severs the window the moment its start page loads: the handle reads
|
|
17966
17981
|
* `closed` while the window stays open in front of the person, showing that
|
|
17967
17982
|
* page's own "not connected" notice. So:
|
|
17968
17983
|
* - the website's page holding focus again means the person closed the
|
|
17969
17984
|
* window and is back on it: a cancellation;
|
|
17970
17985
|
* - a handle that reads `closed` at the first check after the window left
|
|
17971
|
-
* for
|
|
17986
|
+
* for its start page, while the website's page still lacks focus, is a
|
|
17972
17987
|
* severance: the window is still in front of the person, for no person
|
|
17973
17988
|
* closes it that fast and then leaves the website;
|
|
17974
17989
|
* - anything else cannot be told apart (a severance on a slow load, or a
|
|
@@ -17985,6 +18000,19 @@ function closedBeforeReady(firstCheck) {
|
|
|
17985
18000
|
return new PopupSeveredError(SEVERED_MESSAGE);
|
|
17986
18001
|
return new SparkVaultError('Support sign-in did not start. Try again.', 'HELP_DESK_WIDGET_SIGN_IN_INTERRUPTED');
|
|
17987
18002
|
}
|
|
18003
|
+
/**
|
|
18004
|
+
* The challenge's start page, `https://signin.help.sv/{desk_id}/{challenge_id}`:
|
|
18005
|
+
* its sign-in URL when that is exactly the sign-in window's page for this
|
|
18006
|
+
* desk and this challenge, and the challenge's other values have their
|
|
18007
|
+
* shapes; else null.
|
|
18008
|
+
*/
|
|
18009
|
+
function startPage(value, deskId) {
|
|
18010
|
+
if (!value || ![value.challenge_id, value.verifier, value.state].every((part) => typeof part === 'string' && VALUE.test(part)) ||
|
|
18011
|
+
!Number.isSafeInteger(value.expires_at))
|
|
18012
|
+
return null;
|
|
18013
|
+
const expected = `${SIGN_IN_ORIGIN}/${deskId}/${value.challenge_id}`;
|
|
18014
|
+
return value.sign_in_url === expected ? expected : null;
|
|
18015
|
+
}
|
|
17988
18016
|
/**
|
|
17989
18017
|
* Open synchronously inside the user's gesture, before preparing the server
|
|
17990
18018
|
* challenge. A session redeemed after the sign-in already ended (cancelled,
|
|
@@ -18007,7 +18035,6 @@ function openWidgetIdentity(options, prepare, ready, redeem, discard, deskId) {
|
|
|
18007
18035
|
catch { /* The popup may already have navigated. */ }
|
|
18008
18036
|
return new Promise((resolve, reject) => {
|
|
18009
18037
|
let challenge = null;
|
|
18010
|
-
let firstPartyOrigin = null;
|
|
18011
18038
|
let settled = false;
|
|
18012
18039
|
let checking = false;
|
|
18013
18040
|
let interval;
|
|
@@ -18052,19 +18079,19 @@ function openWidgetIdentity(options, prepare, ready, redeem, discard, deskId) {
|
|
|
18052
18079
|
finish(null, session);
|
|
18053
18080
|
};
|
|
18054
18081
|
const receive = (event) => {
|
|
18055
|
-
if (!challenge || event.source !== popup || event.origin !==
|
|
18082
|
+
if (!challenge || event.source !== popup || event.origin !== SIGN_IN_ORIGIN)
|
|
18056
18083
|
return;
|
|
18057
18084
|
const data = event.data;
|
|
18058
18085
|
if (!data || data.challenge_id !== challenge.challenge_id)
|
|
18059
18086
|
return;
|
|
18060
|
-
// The
|
|
18061
|
-
//
|
|
18062
|
-
//
|
|
18063
|
-
//
|
|
18087
|
+
// The sign-in window this page opened asks for the challenge's state,
|
|
18088
|
+
// without which Core takes none of its steps: only this popup, at the
|
|
18089
|
+
// sign-in origin, is ever answered, so a sign-in link opened in any
|
|
18090
|
+
// other window or browser completes nothing.
|
|
18064
18091
|
if (data.type === HELP_DESK_WIDGET_IDENTITY_MESSAGES.ready) {
|
|
18065
18092
|
if (watch)
|
|
18066
18093
|
clearInterval(watch);
|
|
18067
|
-
popup.postMessage({ type: HELP_DESK_WIDGET_IDENTITY_MESSAGES.state, challenge_id: challenge.challenge_id, state: challenge.state },
|
|
18094
|
+
popup.postMessage({ type: HELP_DESK_WIDGET_IDENTITY_MESSAGES.state, challenge_id: challenge.challenge_id, state: challenge.state }, SIGN_IN_ORIGIN);
|
|
18068
18095
|
return;
|
|
18069
18096
|
}
|
|
18070
18097
|
if (data.type !== HELP_DESK_WIDGET_IDENTITY_MESSAGES.result || data.state !== challenge.state)
|
|
@@ -18081,10 +18108,8 @@ function openWidgetIdentity(options, prepare, ready, redeem, discard, deskId) {
|
|
|
18081
18108
|
void prepare().then((value) => {
|
|
18082
18109
|
if (settled)
|
|
18083
18110
|
return;
|
|
18084
|
-
const url =
|
|
18085
|
-
if (!
|
|
18086
|
-
url.protocol !== 'https:' || url.origin !== 'https://auth.sv' || url.username || url.password || url.search || url.hash ||
|
|
18087
|
-
url.pathname !== `/help-desk/${deskId}/${value.challenge_id}`)
|
|
18111
|
+
const url = startPage(value, deskId);
|
|
18112
|
+
if (!url)
|
|
18088
18113
|
throw new SparkVaultError('The support sign-in address is invalid.', 'HELP_DESK_INVALID_RESPONSE');
|
|
18089
18114
|
// The window still holds this page's own placeholder, which no opener
|
|
18090
18115
|
// policy severs: closed now, the person closed it.
|
|
@@ -18093,8 +18118,7 @@ function openWidgetIdentity(options, prepare, ready, redeem, discard, deskId) {
|
|
|
18093
18118
|
return;
|
|
18094
18119
|
}
|
|
18095
18120
|
challenge = value;
|
|
18096
|
-
|
|
18097
|
-
popup.location.replace(url.href);
|
|
18121
|
+
popup.location.replace(url);
|
|
18098
18122
|
// A window whose handle dies before its page asks for the state can
|
|
18099
18123
|
// never be handed it, so the sign-in ends at once (closedBeforeReady)
|
|
18100
18124
|
// rather than polling until the challenge expires.
|
|
@@ -18105,8 +18129,8 @@ function openWidgetIdentity(options, prepare, ready, redeem, discard, deskId) {
|
|
|
18105
18129
|
finish(closedBeforeReady(checks === 1));
|
|
18106
18130
|
}, HANDLE_CHECK_MS);
|
|
18107
18131
|
// Code delivery must survive a browser severing window.opener during
|
|
18108
|
-
// the
|
|
18109
|
-
// challenge and verifier; no Identity
|
|
18132
|
+
// the window's Identity round trip. Polling knows only the original
|
|
18133
|
+
// challenge and verifier; no Identity token ever reaches this page.
|
|
18110
18134
|
interval = setInterval(() => {
|
|
18111
18135
|
if (settled || checking || !challenge)
|
|
18112
18136
|
return;
|
|
@@ -18248,7 +18272,7 @@ class HelpDeskClient {
|
|
|
18248
18272
|
this.releasedTokens = new Map();
|
|
18249
18273
|
this.ownsSession = false;
|
|
18250
18274
|
// Frozen copies of the records this client reads, so a page changing the desk it handed in (`HelpDeskConnectOptions.desk`) changes nothing here.
|
|
18251
|
-
this.desk = Object.freeze({ ...desk, branding: Object.freeze({ ...desk.branding }),
|
|
18275
|
+
this.desk = Object.freeze({ ...desk, branding: Object.freeze({ ...desk.branding }),
|
|
18252
18276
|
external_identity: desk.external_identity ? Object.freeze({ ...desk.external_identity }) : undefined,
|
|
18253
18277
|
ticket_access_control: desk.ticket_access_control ? Object.freeze({ ...desk.ticket_access_control }) : undefined });
|
|
18254
18278
|
this.http = http;
|
|
@@ -18630,10 +18654,6 @@ class HelpDeskClient {
|
|
|
18630
18654
|
challenge_id: options.challengeId, binding_secret: options.bindingSecret, code: options.code,
|
|
18631
18655
|
});
|
|
18632
18656
|
}
|
|
18633
|
-
/** Identity completion still requires a server-approved desk portal origin. */
|
|
18634
|
-
completeIdentity(options) {
|
|
18635
|
-
return this.establish(apiPath `/v1/hd/desks/${this.desk.desk_id}/auth/identity/complete`, { token: options.token });
|
|
18636
|
-
}
|
|
18637
18657
|
/** Uninstalled result: the owning form/controller decides when the new requester becomes current. */
|
|
18638
18658
|
signInWidgetIdentity(options = {}) {
|
|
18639
18659
|
const revision = this.revision;
|
|
@@ -18652,8 +18672,8 @@ class HelpDeskClient {
|
|
|
18652
18672
|
const result = await this.send('POST', apiPath `/v1/hd/desks/${this.desk.desk_id}/auth/widget/redeem`, {
|
|
18653
18673
|
challenge_id: challenge.challenge_id, verifier: challenge.verifier, ...(code && { code }),
|
|
18654
18674
|
}, undefined, false);
|
|
18655
|
-
// A native sign-in opens a session at
|
|
18656
|
-
//
|
|
18675
|
+
// A native sign-in opens a session at SparkVault's Identity: an email sign-in's customer carries
|
|
18676
|
+
// the `identity` assurance; a sign-in by the organization's own identity provider carries
|
|
18657
18677
|
// the `federated` mark and the `federated` assurance together, never one without the other.
|
|
18658
18678
|
const customer = result?.customer;
|
|
18659
18679
|
const nativeIdentity = customer?.federated === true ? customer.assurance === 'federated' : customer?.assurance === 'identity';
|
|
@@ -18829,7 +18849,657 @@ class HelpDeskClient {
|
|
|
18829
18849
|
}
|
|
18830
18850
|
}
|
|
18831
18851
|
|
|
18832
|
-
/**
|
|
18852
|
+
/**
|
|
18853
|
+
* A tenant's brand color and the WCAG contrast rules that decide how it may be
|
|
18854
|
+
* used: the one hex rule the server stores, the console checks and the portal
|
|
18855
|
+
* paints, the one contrast reading the console's readouts, the portal's
|
|
18856
|
+
* accent and the portal's reading of a help center's ground share, and the
|
|
18857
|
+
* one way a readout writes that reading.
|
|
18858
|
+
*
|
|
18859
|
+
* A brand color is tenant-controlled, so it is used only when it is a
|
|
18860
|
+
* six-digit hex color, read case-insensitively and held in lowercase; anything
|
|
18861
|
+
* else (a color name, a CSS function, a value that runs on into more CSS) is
|
|
18862
|
+
* no color at all.
|
|
18863
|
+
*
|
|
18864
|
+
* A brand color can be any lightness, so whatever shows it picks what goes
|
|
18865
|
+
* with it, in one pairing per scheme that every surface painting the color
|
|
18866
|
+
* shares (the customer portal, the SDK's support journey, the desk's email,
|
|
18867
|
+
* the console's sample):
|
|
18868
|
+
*
|
|
18869
|
+
* light (lightAccent) the fill, moved in lightness away from its label
|
|
18870
|
+
* only where neither white nor ink reads on it at
|
|
18871
|
+
* 4.5:1; white or ink on it, whichever reads more
|
|
18872
|
+
* strongly; the color itself as text only where it
|
|
18873
|
+
* reaches 4.5:1 on both grounds accent text stands on,
|
|
18874
|
+
* the white surface and the canvas tone, ink otherwise
|
|
18875
|
+
* dark (darkAccent) a color with a hue a reader sees, lifted in
|
|
18876
|
+
* lightness at its own hue and the saturation it shows
|
|
18877
|
+
* where it would not read: as text until it reads at
|
|
18878
|
+
* 4.5:1 on every dark ground accent text stands on
|
|
18879
|
+
* (darkAccentInk), as a fill until it stands at 3:1 on
|
|
18880
|
+
* the dark page and its cards under a label at 4.5:1,
|
|
18881
|
+
* its hover too (darkAccentFill); a grey or black, the
|
|
18882
|
+
* dark scheme's ink, as fill and as text, under ink
|
|
18883
|
+
*
|
|
18884
|
+
* A hue is the one a reader sees (shownChroma): a black whose OKLCH chroma
|
|
18885
|
+
* names a hue no reader sees there, such as #000001, pairs as black in both
|
|
18886
|
+
* schemes. Under the pointer each fill moves a step a reader sees, away from
|
|
18887
|
+
* its label wherever there is room, and on dark grounds wherever that step
|
|
18888
|
+
* still stands there (hoverOf). schemePairings gives both pairings at once,
|
|
18889
|
+
* DEFAULT_PAIRINGS the ones a desk with no brand color paints, and
|
|
18890
|
+
* accentProperties says either as the accent custom properties the customer
|
|
18891
|
+
* portal paints with.
|
|
18892
|
+
*
|
|
18893
|
+
* BROWSER-SAFE: data only, no imports.
|
|
18894
|
+
*/
|
|
18895
|
+
|
|
18896
|
+
const HEX_COLOR = /^#[0-9a-f]{6}$/;
|
|
18897
|
+
|
|
18898
|
+
/** WCAG AA's floor for normal-size text. */
|
|
18899
|
+
const AA_TEXT_CONTRAST = 4.5;
|
|
18900
|
+
|
|
18901
|
+
/**
|
|
18902
|
+
* The canvas tone, the design system's `--canvas` (`--color-slate-50`): the
|
|
18903
|
+
* page ground the customer portal (its pages and a customer's own messages)
|
|
18904
|
+
* and the knowledge base's default theme set accent text on, beside the white
|
|
18905
|
+
* surface. The design system publishes its tokens only as CSS, which this
|
|
18906
|
+
* import-free module cannot read, so the value is mirrored here once, and
|
|
18907
|
+
* tests/brand-color.test.js holds it to packages/design-system/tokens/colors.css.
|
|
18908
|
+
*/
|
|
18909
|
+
const CANVAS_COLOR = '#f7fafb';
|
|
18910
|
+
|
|
18911
|
+
/**
|
|
18912
|
+
* The ink, the design system's `--ink` (`--color-slate-900`): the dark text a
|
|
18913
|
+
* pairing paints on a fill and in place of a color too light to stand as
|
|
18914
|
+
* text. Mirrored here once for the same reason as CANVAS_COLOR, and held to
|
|
18915
|
+
* packages/design-system/tokens/colors.css by tests/brand-color.test.js.
|
|
18916
|
+
*/
|
|
18917
|
+
const INK_COLOR = '#0d1a20';
|
|
18918
|
+
|
|
18919
|
+
/**
|
|
18920
|
+
* The design system's dark app grounds accent colors stand on, mirrored for
|
|
18921
|
+
* the same reason as CANVAS_COLOR and held to the tokens the same way: the
|
|
18922
|
+
* page (`--dark-app-canvas`), its cards (`--dark-app-surface`) and the
|
|
18923
|
+
* ground of selected text and of the composer's drop prompt
|
|
18924
|
+
* (`--dark-app-selection`), the lightest ground accent text stands on there.
|
|
18925
|
+
*/
|
|
18926
|
+
const DARK_CANVAS_COLOR = '#071217';
|
|
18927
|
+
const DARK_SURFACE_COLOR = '#0d1a20';
|
|
18928
|
+
const DARK_SELECTION_COLOR = '#1b2e4c';
|
|
18929
|
+
|
|
18930
|
+
/**
|
|
18931
|
+
* The dark app ramp's ink, `--dark-app-ink`: the text on its grounds, and the
|
|
18932
|
+
* accent a grey or black brand color takes there. Mirrored and held to the
|
|
18933
|
+
* tokens as CANVAS_COLOR is.
|
|
18934
|
+
*/
|
|
18935
|
+
const DARK_INK_COLOR = '#f0f5f7';
|
|
18936
|
+
|
|
18937
|
+
/**
|
|
18938
|
+
* The pairings a desk with no brand color paints, in the shape a brand
|
|
18939
|
+
* color's take (schemePairings), so every surface that paints a desk's accent
|
|
18940
|
+
* (the customer portal, the SDK's support journey, the desk's email, the
|
|
18941
|
+
* console's sample) paints this one default: on light grounds the design
|
|
18942
|
+
* system's primary button (`--color-btn-primary`, under the pointer
|
|
18943
|
+
* `--color-btn-primary-hover`) under white, with `--color-action` as text; on
|
|
18944
|
+
* the dark app grounds its action fill (`--dark-app-action`, under the
|
|
18945
|
+
* pointer `--dark-app-action-hover`) under white, with
|
|
18946
|
+
* `--color-action-on-dark` as text. Each color is its token's value,
|
|
18947
|
+
* mirrored and held to the tokens as CANVAS_COLOR is.
|
|
18948
|
+
*/
|
|
18949
|
+
const DEFAULT_PAIRINGS = Object.freeze({
|
|
18950
|
+
light: Object.freeze({ fill: '#0a4eb1', onAccent: 'white', ink: '#216bde', hover: '#03439f' }),
|
|
18951
|
+
dark: Object.freeze({ fill: '#226ee3', onAccent: 'white', ink: '#72a8ff', hover: '#1d60c8' })
|
|
18952
|
+
});
|
|
18953
|
+
|
|
18954
|
+
/**
|
|
18955
|
+
* The chroma a reader sees (shownChroma) under which a color is a grey rather
|
|
18956
|
+
* than a hue: the neutral greys a brand picks (a pure, warm or cool grey,
|
|
18957
|
+
* stone, zinc) sit at 0 to 0.019, and the least saturated colors still named
|
|
18958
|
+
* by their hue (a desaturated olive, a charcoal navy, a taupe, a brown) at
|
|
18959
|
+
* 0.028 to 0.035.
|
|
18960
|
+
*/
|
|
18961
|
+
const CHROMA_FLOOR = 0.02;
|
|
18962
|
+
|
|
18963
|
+
/**
|
|
18964
|
+
* The OKLCH lightness under which OKLCH's chroma names a hue a reader does
|
|
18965
|
+
* not see: CIE L*a*b*'s 6/29, under which L*a*b* weighs light linearly where
|
|
18966
|
+
* OKLab keeps its cube root to black. Near black that cube root finds a hue
|
|
18967
|
+
* in what little light there is (a chroma of 0.021 in #000001, 0.045 in
|
|
18968
|
+
* #00000a) in a color a reader sees as black.
|
|
18969
|
+
*/
|
|
18970
|
+
const LINEAR_LIGHTNESS = 6 / 29;
|
|
18971
|
+
|
|
18972
|
+
/** WCAG AA's floor for a control's parts and a state's mark (1.4.11). */
|
|
18973
|
+
const AA_NON_TEXT_CONTRAST = 3;
|
|
18974
|
+
|
|
18975
|
+
/** sRGB's transfer function: an encoded channel, from 0 to 1, as linear light, and back. */
|
|
18976
|
+
const toLinear = (channel) => (channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4);
|
|
18977
|
+
const toGamma = (channel) => (channel <= 0.0031308 ? 12.92 * channel : 1.055 * channel ** (1 / 2.4) - 0.055);
|
|
18978
|
+
|
|
18979
|
+
/** A validated `#rrggbb` color's red, green and blue channels, each from 0 to 1. */
|
|
18980
|
+
const channelsOf = (color) => [1, 3, 5].map((offset) => Number.parseInt(color.slice(offset, offset + 2), 16) / 255);
|
|
18981
|
+
|
|
18982
|
+
/** Relative luminance (WCAG 2) of an sRGB color's red, green and blue channels, each from 0 to 1. */
|
|
18983
|
+
function channelLuminance(channels) {
|
|
18984
|
+
const [red, green, blue] = channels.map(toLinear);
|
|
18985
|
+
return 0.2126 * red + 0.7152 * green + 0.0722 * blue;
|
|
18986
|
+
}
|
|
18987
|
+
|
|
18988
|
+
/** Relative luminance (WCAG 2) of a validated `#rrggbb` color. */
|
|
18989
|
+
function relativeLuminance(color) {
|
|
18990
|
+
return channelLuminance(channelsOf(color));
|
|
18991
|
+
}
|
|
18992
|
+
|
|
18993
|
+
/** The contrast ratio of two relative luminances. */
|
|
18994
|
+
function contrastRatio(first, second) {
|
|
18995
|
+
return (Math.max(first, second) + 0.05) / (Math.min(first, second) + 0.05);
|
|
18996
|
+
}
|
|
18997
|
+
|
|
18998
|
+
/** The relative luminance of the ink a fill's text is weighed in, the real ink rather than pure black. */
|
|
18999
|
+
const INK_LUMINANCE = relativeLuminance(INK_COLOR);
|
|
19000
|
+
|
|
19001
|
+
/** The relative luminances of the grounds accent text stands on: the white surface and the canvas tone. */
|
|
19002
|
+
const TEXT_GROUNDS = Object.freeze([1, relativeLuminance(CANVAS_COLOR)]);
|
|
19003
|
+
|
|
19004
|
+
/** The dark app ramp's grounds accent text stands on, as sRGB channels: the dark page, its cards and the selection. */
|
|
19005
|
+
const DARK_TEXT_GROUNDS = Object.freeze([DARK_CANVAS_COLOR, DARK_SURFACE_COLOR, DARK_SELECTION_COLOR].map((color) => Object.freeze(channelsOf(color))));
|
|
19006
|
+
|
|
19007
|
+
/** The dark app ramp's grounds an accent fill stands on, as sRGB channels: the dark page and its cards. */
|
|
19008
|
+
const DARK_FILL_GROUNDS = Object.freeze([DARK_CANVAS_COLOR, DARK_SURFACE_COLOR].map((color) => Object.freeze(channelsOf(color))));
|
|
19009
|
+
|
|
19010
|
+
/** How strongly a color of this luminance reads on the one of `grounds` it reads least on. */
|
|
19011
|
+
function lowestContrast(luminance, grounds) {
|
|
19012
|
+
return Math.min(...grounds.map((ground) => contrastRatio(luminance, ground)));
|
|
19013
|
+
}
|
|
19014
|
+
|
|
19015
|
+
/** The text a fill of this luminance takes: white or ink, whichever reads more strongly on it. */
|
|
19016
|
+
function labelOf(luminance) {
|
|
19017
|
+
return contrastRatio(luminance, 1) >= contrastRatio(luminance, INK_LUMINANCE) ? 'white' : 'ink';
|
|
19018
|
+
}
|
|
19019
|
+
|
|
19020
|
+
/** How strongly that text reads on a fill of this luminance. */
|
|
19021
|
+
function labelContrast(luminance) {
|
|
19022
|
+
return contrastRatio(luminance, labelOf(luminance) === 'white' ? 1 : INK_LUMINANCE);
|
|
19023
|
+
}
|
|
19024
|
+
|
|
19025
|
+
/** How strongly a color of this luminance reads as text on the light ground it reads least on. */
|
|
19026
|
+
function textContrast(luminance) {
|
|
19027
|
+
return lowestContrast(luminance, TEXT_GROUNDS);
|
|
19028
|
+
}
|
|
19029
|
+
|
|
19030
|
+
/**
|
|
19031
|
+
* A validated `#rrggbb` color in OKLCH (lightness from 0 to 1, chroma, hue in
|
|
19032
|
+
* radians), by the same transform the design system derives its palette with
|
|
19033
|
+
* (packages/design-system/scripts/token-css.mjs oklchOfRgb, by which
|
|
19034
|
+
* tests/brand-color.test.js measures every lift).
|
|
19035
|
+
*/
|
|
19036
|
+
function oklchOf(color) {
|
|
19037
|
+
const [r, g, b] = channelsOf(color).map(toLinear);
|
|
19038
|
+
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
|
|
19039
|
+
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
|
|
19040
|
+
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
|
|
19041
|
+
const a = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s;
|
|
19042
|
+
const bAxis = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s;
|
|
19043
|
+
return { L: 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s, C: Math.hypot(a, bAxis), H: Math.atan2(bAxis, a) };
|
|
19044
|
+
}
|
|
19045
|
+
|
|
19046
|
+
/** An OKLCH color's linear red, green and blue; a channel outside 0 to 1 is one sRGB cannot draw. */
|
|
19047
|
+
function linearOfOklch(L, C, H) {
|
|
19048
|
+
const [a, b] = [C * Math.cos(H), C * Math.sin(H)];
|
|
19049
|
+
const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
|
19050
|
+
const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
|
19051
|
+
const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
|
19052
|
+
return [
|
|
19053
|
+
4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
|
|
19054
|
+
-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
|
|
19055
|
+
-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s
|
|
19056
|
+
];
|
|
19057
|
+
}
|
|
19058
|
+
|
|
19059
|
+
/**
|
|
19060
|
+
* The chroma a reader sees in a color (its OKLCH lightness and chroma): its
|
|
19061
|
+
* OKLCH chroma, under LINEAR_LIGHTNESS faded by the square of the color's
|
|
19062
|
+
* share of that lightness, as L*a*b*'s linear weighing scales chroma against
|
|
19063
|
+
* the cube root there.
|
|
19064
|
+
*/
|
|
19065
|
+
const shownChroma = ({ L, C }) => C * Math.min(1, (L / LINEAR_LIGHTNESS) ** 2);
|
|
19066
|
+
|
|
19067
|
+
/** Whether a color (its OKLCH lightness and chroma) has a hue a reader sees: its shown chroma at CHROMA_FLOOR or more. */
|
|
19068
|
+
const hasHue = (oklch) => shownChroma(oklch) >= CHROMA_FLOOR;
|
|
19069
|
+
|
|
19070
|
+
/**
|
|
19071
|
+
* The saturation a walk from a color keeps (shiftedUntil): its shown chroma
|
|
19072
|
+
* for its lightness. A color darker than LINEAR_LIGHTNESS with no hue a
|
|
19073
|
+
* reader sees keeps none, so it walks as a grey: a walk toward the light
|
|
19074
|
+
* would grow its trace into a hue. A lighter grey keeps its faint tint, which
|
|
19075
|
+
* its short walks barely move.
|
|
19076
|
+
*/
|
|
19077
|
+
function saturationOf(oklch) {
|
|
19078
|
+
if (oklch.L <= 0 || (oklch.L < LINEAR_LIGHTNESS && !hasHue(oklch))) return 0;
|
|
19079
|
+
return shownChroma(oklch) / oklch.L;
|
|
19080
|
+
}
|
|
19081
|
+
|
|
19082
|
+
const drawable = (channels) => channels.every((channel) => channel >= 0 && channel <= 1);
|
|
19083
|
+
|
|
19084
|
+
/** The `#rrggbb` color at OKLCH lightness L and hue H, with as much of chroma C as sRGB holds there. */
|
|
19085
|
+
function colorAt(L, C, H) {
|
|
19086
|
+
let chroma = C;
|
|
19087
|
+
if (!drawable(linearOfOklch(L, chroma, H))) {
|
|
19088
|
+
let [low, high] = [0, C];
|
|
19089
|
+
for (let halving = 0; halving < 24; halving += 1) {
|
|
19090
|
+
const middle = (low + high) / 2;
|
|
19091
|
+
if (drawable(linearOfOklch(L, middle, H))) low = middle;
|
|
19092
|
+
else high = middle;
|
|
19093
|
+
}
|
|
19094
|
+
chroma = low;
|
|
19095
|
+
}
|
|
19096
|
+
return `#${linearOfOklch(L, chroma, H).map((channel) => Math.round(toGamma(Math.min(1, Math.max(0, channel))) * 255).toString(16).padStart(2, '0')).join('')}`;
|
|
19097
|
+
}
|
|
19098
|
+
|
|
19099
|
+
/** How far each step of a shift moves a color's OKLCH lightness. */
|
|
19100
|
+
const SHIFT_STEP = 0.005;
|
|
19101
|
+
|
|
19102
|
+
/**
|
|
19103
|
+
* A color as it stands where `reads` asks more of it: itself where it reads,
|
|
19104
|
+
* else moved in OKLCH lightness (up for `direction` 1, down for -1) at its
|
|
19105
|
+
* own hue, one step at a time, to the first step that reads, white or black
|
|
19106
|
+
* at the end. Its saturation (saturationOf), the chroma a reader sees for its
|
|
19107
|
+
* lightness, stays as it is, so a navy lifts to a clear blue of its own
|
|
19108
|
+
* family rather than greying out, with as much of that chroma as sRGB holds
|
|
19109
|
+
* at each step. Null where not even the end reads.
|
|
19110
|
+
*
|
|
19111
|
+
* @param {string} color - A validated brand color
|
|
19112
|
+
* @param {1|-1} direction
|
|
19113
|
+
* @param {(candidate: string) => boolean} reads
|
|
19114
|
+
* @returns {string|null}
|
|
19115
|
+
*/
|
|
19116
|
+
function shiftedUntil(color, direction, reads) {
|
|
19117
|
+
if (reads(color)) return color;
|
|
19118
|
+
const oklch = oklchOf(color);
|
|
19119
|
+
const { L, H } = oklch;
|
|
19120
|
+
const saturation = saturationOf(oklch);
|
|
19121
|
+
for (let lightness = L + direction * SHIFT_STEP; lightness > 0 && lightness < 1; lightness += direction * SHIFT_STEP) {
|
|
19122
|
+
const shifted = colorAt(lightness, saturation * lightness, H);
|
|
19123
|
+
if (reads(shifted)) return shifted;
|
|
19124
|
+
}
|
|
19125
|
+
const end = direction > 0 ? '#ffffff' : '#000000';
|
|
19126
|
+
return reads(end) ? end : null;
|
|
19127
|
+
}
|
|
19128
|
+
|
|
19129
|
+
/**
|
|
19130
|
+
* A brand color as it may be stored and shown, or null when the value is not
|
|
19131
|
+
* one: a `#rrggbb` hex value, read case-insensitively.
|
|
19132
|
+
*
|
|
19133
|
+
* @param {unknown} value
|
|
19134
|
+
* @returns {string|null} The color in lowercase
|
|
19135
|
+
*/
|
|
19136
|
+
function brandColor(value) {
|
|
19137
|
+
if (typeof value !== 'string') return null;
|
|
19138
|
+
const color = value.toLowerCase();
|
|
19139
|
+
return HEX_COLOR.test(color) ? color : null;
|
|
19140
|
+
}
|
|
19141
|
+
|
|
19142
|
+
/** How far a fill under the pointer moves at least, in OKLCH lightness. */
|
|
19143
|
+
const HOVER_SHIFT = 0.05;
|
|
19144
|
+
|
|
19145
|
+
/**
|
|
19146
|
+
* How far a fill under the pointer stands from the fill at least, as a
|
|
19147
|
+
* contrast ratio: where HOVER_SHIFT moves a very dark fill too little for a
|
|
19148
|
+
* reader to see (black's step is a 1.0:1 change), the hover moves on until
|
|
19149
|
+
* it stands this far apart.
|
|
19150
|
+
*/
|
|
19151
|
+
const HOVER_CONTRAST = 1.1;
|
|
19152
|
+
|
|
19153
|
+
/**
|
|
19154
|
+
* A fill under the pointer: the first step in OKLCH lightness at its own hue
|
|
19155
|
+
* (shiftedUntil) at least HOVER_SHIFT from the fill that stands
|
|
19156
|
+
* HOVER_CONTRAST from it, away from its label (darker under white, lighter
|
|
19157
|
+
* under ink), so the label reads more strongly on it still, where that step
|
|
19158
|
+
* `stands` (for a dark fill, standsWhere: on the grounds it stands on, under
|
|
19159
|
+
* its label). Where it does not (a fill too near that end of the range, black
|
|
19160
|
+
* and its nearest neighbors under white or white under ink, or a dark fill
|
|
19161
|
+
* whose step away sinks into its grounds), the first such step toward its
|
|
19162
|
+
* label, where that one stands; a step further either way only moves further
|
|
19163
|
+
* from the fill. Null where neither stands.
|
|
19164
|
+
*
|
|
19165
|
+
* @param {string} fill - A `#rrggbb` color
|
|
19166
|
+
* @param {'white'|'ink'} onAccent - Its label
|
|
19167
|
+
* @param {(candidate: string) => boolean} [stands]
|
|
19168
|
+
* @returns {string|null}
|
|
19169
|
+
*/
|
|
19170
|
+
function hoverOf(fill, onAccent, stands = () => true) {
|
|
19171
|
+
const { L } = oklchOf(fill);
|
|
19172
|
+
const luminance = relativeLuminance(fill);
|
|
19173
|
+
const apart = (candidate) => Math.abs(oklchOf(candidate).L - L) >= HOVER_SHIFT - Number.EPSILON
|
|
19174
|
+
&& contrastRatio(relativeLuminance(candidate), luminance) >= HOVER_CONTRAST;
|
|
19175
|
+
const away = onAccent === 'white' ? -1 : 1;
|
|
19176
|
+
return [away, -away].map((direction) => shiftedUntil(fill, direction, apart)).find((step) => step !== null && stands(step)) ?? null;
|
|
19177
|
+
}
|
|
19178
|
+
|
|
19179
|
+
/**
|
|
19180
|
+
* Whether a dark fill's hover stands where the fill does: at
|
|
19181
|
+
* AA_NON_TEXT_CONTRAST on each of the grounds (their relative luminances),
|
|
19182
|
+
* under the fill's label at AA_TEXT_CONTRAST.
|
|
19183
|
+
*
|
|
19184
|
+
* @param {number[]} luminances
|
|
19185
|
+
* @param {'white'|'ink'} onAccent
|
|
19186
|
+
* @returns {(candidate: string) => boolean}
|
|
19187
|
+
*/
|
|
19188
|
+
const standsWhere = (luminances, onAccent) => (candidate) => {
|
|
19189
|
+
const luminance = relativeLuminance(candidate);
|
|
19190
|
+
return lowestContrast(luminance, luminances) >= AA_NON_TEXT_CONTRAST
|
|
19191
|
+
&& contrastRatio(luminance, onAccent === 'white' ? 1 : INK_LUMINANCE) >= AA_TEXT_CONTRAST;
|
|
19192
|
+
};
|
|
19193
|
+
|
|
19194
|
+
/**
|
|
19195
|
+
* @typedef {Object} AccentPairing
|
|
19196
|
+
* @property {string} fill - The fill of a primary action, `#rrggbb`
|
|
19197
|
+
* @property {'white'|'ink'} onAccent - The text on it: white, or the light ink (INK_COLOR)
|
|
19198
|
+
* @property {string} ink - The accent as text on the scheme's grounds, `#rrggbb`
|
|
19199
|
+
* @property {string} hover - The fill under the pointer, `#rrggbb`
|
|
19200
|
+
*/
|
|
19201
|
+
|
|
19202
|
+
/**
|
|
19203
|
+
* What a brand color becomes on the light grounds (the white surface and the
|
|
19204
|
+
* canvas tone): its label, white or ink, whichever reads more strongly on
|
|
19205
|
+
* it; its fill, itself where that label reads on it at AA_TEXT_CONTRAST,
|
|
19206
|
+
* else moved in lightness away from the label (shiftedUntil) to the first
|
|
19207
|
+
* step where it does; the color itself as text where it reads at
|
|
19208
|
+
* AA_TEXT_CONTRAST on both grounds (accentTextContrast), INK_COLOR otherwise;
|
|
19209
|
+
* and its fill under the pointer (hoverOf).
|
|
19210
|
+
*
|
|
19211
|
+
* @param {unknown} value
|
|
19212
|
+
* @returns {AccentPairing|null} Null when the value is not a brand color
|
|
19213
|
+
*/
|
|
19214
|
+
function lightAccent(value) {
|
|
19215
|
+
const color = brandColor(value);
|
|
19216
|
+
if (!color) return null;
|
|
19217
|
+
const luminance = relativeLuminance(color);
|
|
19218
|
+
const onAccent = labelOf(luminance);
|
|
19219
|
+
const fill = shiftedUntil(color, onAccent === 'white' ? -1 : 1, (candidate) => labelContrast(relativeLuminance(candidate)) >= AA_TEXT_CONTRAST);
|
|
19220
|
+
return { fill, onAccent, ink: textContrast(luminance) >= AA_TEXT_CONTRAST ? color : INK_COLOR, hover: hoverOf(fill, onAccent) };
|
|
19221
|
+
}
|
|
19222
|
+
|
|
19223
|
+
/**
|
|
19224
|
+
* The color a brand color starts its dark lift from: itself where it has a
|
|
19225
|
+
* hue a reader sees (hasHue), kept as it lifts; the dark scheme's ink
|
|
19226
|
+
* (DARK_INK_COLOR) for a grey or black, which has no hue to keep and lifted
|
|
19227
|
+
* would read as a disabled control.
|
|
19228
|
+
*/
|
|
19229
|
+
const darkSource = (color) => (hasHue(oklchOf(color)) ? color : DARK_INK_COLOR);
|
|
19230
|
+
|
|
19231
|
+
/** The relative luminances of grounds given as sRGB channels. */
|
|
19232
|
+
const luminancesOf = (grounds) => grounds.map(channelLuminance);
|
|
19233
|
+
|
|
19234
|
+
/**
|
|
19235
|
+
* A brand color's fill on dark grounds: the color (darkSource) lifted
|
|
19236
|
+
* (shiftedUntil) until it stands at AA_NON_TEXT_CONTRAST on each of `grounds`,
|
|
19237
|
+
* white or ink, whichever reads more strongly on it, reads at
|
|
19238
|
+
* AA_TEXT_CONTRAST, and it has a fill under the pointer that stands there
|
|
19239
|
+
* too (hoverOf, standsWhere); that label; and that hover. A color that
|
|
19240
|
+
* already stands there is itself.
|
|
19241
|
+
*
|
|
19242
|
+
* @param {unknown} value
|
|
19243
|
+
* @param {number[][]} [grounds] - sRGB channels from 0 to 1; the dark app ramp's page and cards unless given
|
|
19244
|
+
* @returns {{ fill: string, onAccent: 'white'|'ink', hover: string }|null} Null when the value is not a brand color, or no lift stands on `grounds`
|
|
19245
|
+
*/
|
|
19246
|
+
function darkAccentFill(value, grounds = DARK_FILL_GROUNDS) {
|
|
19247
|
+
const color = brandColor(value);
|
|
19248
|
+
if (!color) return null;
|
|
19249
|
+
const luminances = luminancesOf(grounds);
|
|
19250
|
+
// The step that stands, with its label and hover, kept from the walk that found it.
|
|
19251
|
+
let found = null;
|
|
19252
|
+
shiftedUntil(darkSource(color), 1, (candidate) => {
|
|
19253
|
+
const luminance = relativeLuminance(candidate);
|
|
19254
|
+
if (lowestContrast(luminance, luminances) < AA_NON_TEXT_CONTRAST || labelContrast(luminance) < AA_TEXT_CONTRAST) return false;
|
|
19255
|
+
const onAccent = labelOf(luminance);
|
|
19256
|
+
const hover = hoverOf(candidate, onAccent, standsWhere(luminances, onAccent));
|
|
19257
|
+
found = hover && { fill: candidate, onAccent, hover };
|
|
19258
|
+
return found !== null;
|
|
19259
|
+
});
|
|
19260
|
+
return found;
|
|
19261
|
+
}
|
|
19262
|
+
|
|
19263
|
+
/**
|
|
19264
|
+
* A brand color as text on dark grounds: the color (darkSource) lifted
|
|
19265
|
+
* (shiftedUntil) until it reads at AA_TEXT_CONTRAST on each of `grounds`. A
|
|
19266
|
+
* color that already reads there is itself.
|
|
19267
|
+
*
|
|
19268
|
+
* @param {unknown} value
|
|
19269
|
+
* @param {number[][]} [grounds] - sRGB channels from 0 to 1; the dark app ramp's page, cards and selection unless given
|
|
19270
|
+
* @returns {string|null} Null when the value is not a brand color, or no lift reads on `grounds`
|
|
19271
|
+
*/
|
|
19272
|
+
function darkAccentInk(value, grounds = DARK_TEXT_GROUNDS) {
|
|
19273
|
+
const color = brandColor(value);
|
|
19274
|
+
if (!color) return null;
|
|
19275
|
+
const luminances = luminancesOf(grounds);
|
|
19276
|
+
return shiftedUntil(darkSource(color), 1, (candidate) => lowestContrast(relativeLuminance(candidate), luminances) >= AA_TEXT_CONTRAST);
|
|
19277
|
+
}
|
|
19278
|
+
|
|
19279
|
+
/**
|
|
19280
|
+
* What a brand color becomes on the design system's dark app grounds: its
|
|
19281
|
+
* fill and label (darkAccentFill) and its text (darkAccentInk), each lifted
|
|
19282
|
+
* at the color's own hue until it reads there. On a help center's own dark
|
|
19283
|
+
* ground the customer portal lifts this pairing again, with the same two,
|
|
19284
|
+
* against that ground and the grounds it draws from it.
|
|
19285
|
+
*
|
|
19286
|
+
* @param {unknown} value
|
|
19287
|
+
* @returns {AccentPairing|null} Null when the value is not a brand color
|
|
19288
|
+
*/
|
|
19289
|
+
function darkAccent(value) {
|
|
19290
|
+
const fill = darkAccentFill(value);
|
|
19291
|
+
return fill && { ...fill, ink: darkAccentInk(value) };
|
|
19292
|
+
}
|
|
19293
|
+
|
|
19294
|
+
/**
|
|
19295
|
+
* A brand color's pairing in each scheme, derived once for whatever writes
|
|
19296
|
+
* them and weighs them together: on the light grounds (lightAccent) and on
|
|
19297
|
+
* the dark app grounds (darkAccent).
|
|
19298
|
+
*
|
|
19299
|
+
* @param {unknown} value
|
|
19300
|
+
* @returns {Readonly<{ light: AccentPairing, dark: AccentPairing }>|null} Null when the value is not a brand color
|
|
19301
|
+
*/
|
|
19302
|
+
function schemePairings(value) {
|
|
19303
|
+
const light = lightAccent(value);
|
|
19304
|
+
return light && Object.freeze({ light, dark: darkAccent(value) });
|
|
19305
|
+
}
|
|
19306
|
+
|
|
19307
|
+
/**
|
|
19308
|
+
* How accentProperties writes white and each scheme's ink, the colors a
|
|
19309
|
+
* design-system token names: as those tokens (`tokens`), for a page whose
|
|
19310
|
+
* stylesheet declares them (the customer portal, the console's sample), or as
|
|
19311
|
+
* the colors themselves (`colors`), for a page that declares none (the SDK's
|
|
19312
|
+
* widget on a customer's website). Each token holds the color beside it.
|
|
19313
|
+
*/
|
|
19314
|
+
const WRITINGS = Object.freeze({
|
|
19315
|
+
tokens: Object.freeze({ white: 'var(--color-white)', ink: 'var(--ink)', darkInk: 'var(--dark-app-ink)' }),
|
|
19316
|
+
colors: Object.freeze({ white: '#ffffff', ink: INK_COLOR, darkInk: DARK_INK_COLOR })
|
|
19317
|
+
});
|
|
19318
|
+
|
|
19319
|
+
/**
|
|
19320
|
+
* The accent custom properties for a desk's pairings (a brand color's,
|
|
19321
|
+
* schemePairings, or DEFAULT_PAIRINGS), for each scheme a help desk surface
|
|
19322
|
+
* paints in: on light grounds the fill (`--hd-light-accent`), the text on it
|
|
19323
|
+
* (`--hd-light-on-accent`), the accent as text (`--hd-light-accent-ink`) and
|
|
19324
|
+
* the fill under the pointer (`--hd-light-accent-hover`); on the dark app
|
|
19325
|
+
* grounds the same four (`--hd-dark-*`). The one place these names are
|
|
19326
|
+
* spelled: the customer portal's root, the console's sample and every element
|
|
19327
|
+
* of the SDK's widget carry what it returns.
|
|
19328
|
+
*
|
|
19329
|
+
* @param {{ light: AccentPairing, dark: AccentPairing }} pairings
|
|
19330
|
+
* @param {'tokens'|'colors'} [writing] - How white and each scheme's ink are written (WRITINGS)
|
|
19331
|
+
* @returns {Record<`--hd-${'light'|'dark'}-${'accent'|'on-accent'|'accent-ink'|'accent-hover'}`, string>}
|
|
19332
|
+
*/
|
|
19333
|
+
function accentProperties(pairings, writing = 'tokens') {
|
|
19334
|
+
const { white, ink, darkInk } = WRITINGS[writing];
|
|
19335
|
+
const label = { white, ink };
|
|
19336
|
+
const { light, dark } = pairings;
|
|
19337
|
+
return {
|
|
19338
|
+
'--hd-light-accent': light.fill,
|
|
19339
|
+
'--hd-light-on-accent': label[light.onAccent],
|
|
19340
|
+
'--hd-light-accent-ink': light.ink === INK_COLOR ? ink : light.ink,
|
|
19341
|
+
'--hd-light-accent-hover': light.hover,
|
|
19342
|
+
'--hd-dark-accent': dark.fill === DARK_INK_COLOR ? darkInk : dark.fill,
|
|
19343
|
+
'--hd-dark-on-accent': label[dark.onAccent],
|
|
19344
|
+
'--hd-dark-accent-ink': dark.ink === DARK_INK_COLOR ? darkInk : dark.ink,
|
|
19345
|
+
'--hd-dark-accent-hover': dark.hover
|
|
19346
|
+
};
|
|
19347
|
+
}
|
|
19348
|
+
|
|
19349
|
+
/**
|
|
19350
|
+
* The help desk's color roles as every customer-facing piece of its UI reads
|
|
19351
|
+
* them, written once: the SDK's support launcher, its panel, the request
|
|
19352
|
+
* form and its modal (sdk-js products/help-desk) and the composer both share
|
|
19353
|
+
* (help-desk-composer.js). Each reads the customer portal's color role of the
|
|
19354
|
+
* same meaning (`--hd-*`, which the portal's root maps to its scheme's color
|
|
19355
|
+
* set), else the design system's light value, the one the portal's own light
|
|
19356
|
+
* set maps the role to, so on a page that sets none, a customer's own website
|
|
19357
|
+
* among them, the UI stays light.
|
|
19358
|
+
*
|
|
19359
|
+
* The accent reads the page's accent roles (`--hd-accent*`, which the portal's
|
|
19360
|
+
* root sets to the pairing its scheme paints), else the light pairing the
|
|
19361
|
+
* element it paints in carries (`--hd-light-accent*`: the SDK's launcher,
|
|
19362
|
+
* panel, form container and modal each carry the desk's), else the light
|
|
19363
|
+
* half of brand-color.js' DEFAULT_PAIRINGS, the pairing a desk without a
|
|
19364
|
+
* brand color takes.
|
|
19365
|
+
*
|
|
19366
|
+
* BROWSER-SAFE: data only; imports only brand-color.js.
|
|
19367
|
+
*/
|
|
19368
|
+
|
|
19369
|
+
|
|
19370
|
+
/**
|
|
19371
|
+
* The light value of each design-system token a role falls back to, keyed by
|
|
19372
|
+
* that token (tests/help-desk-colors.test.js holds each to
|
|
19373
|
+
* packages/design-system/tokens). The canvas tone and the ink are
|
|
19374
|
+
* brand-color.js' mirrors of those tokens.
|
|
19375
|
+
*/
|
|
19376
|
+
const HELP_DESK_LIGHT_COLORS = Object.freeze({
|
|
19377
|
+
'--surface': '#ffffff',
|
|
19378
|
+
'--canvas': CANVAS_COLOR,
|
|
19379
|
+
'--color-slate-100': '#f0f5f7',
|
|
19380
|
+
'--color-slate-200': '#e0e9ed',
|
|
19381
|
+
'--color-slate-300': '#c9d6dc',
|
|
19382
|
+
'--ink': INK_COLOR,
|
|
19383
|
+
'--text-body': '#425761',
|
|
19384
|
+
'--text-muted': '#5e757f',
|
|
19385
|
+
'--color-action-bg': '#eef4fe',
|
|
19386
|
+
'--color-error': '#b02b27'
|
|
19387
|
+
});
|
|
19388
|
+
|
|
19389
|
+
const LIGHT = HELP_DESK_LIGHT_COLORS;
|
|
19390
|
+
|
|
19391
|
+
/** The default pairings (DEFAULT_PAIRINGS) as the properties an element carries, written as colors: a page that declares none of the design system's tokens reads them. */
|
|
19392
|
+
const DEFAULT = accentProperties(DEFAULT_PAIRINGS, 'colors');
|
|
19393
|
+
|
|
19394
|
+
/** The neutral and error roles, each the page's `--hd-*` role, else its light value. */
|
|
19395
|
+
const HELP_DESK_COLORS = Object.freeze({
|
|
19396
|
+
/** A panel and its cards. */
|
|
19397
|
+
surface: `var(--hd-surface,${LIGHT['--surface']})`,
|
|
19398
|
+
/** A field's ground. */
|
|
19399
|
+
field: `var(--hd-field,${LIGHT['--surface']})`,
|
|
19400
|
+
/** A quiet ground: a question's recap, a note, code, a disabled field. */
|
|
19401
|
+
canvas: `var(--hd-canvas,${LIGHT['--canvas']})`,
|
|
19402
|
+
/** A raised row or control under the pointer. */
|
|
19403
|
+
hover: `var(--hd-hover,${LIGHT['--canvas']})`,
|
|
19404
|
+
/** An icon control under the pointer, and the quietest rules. */
|
|
19405
|
+
fill: `var(--hd-fill,${LIGHT['--color-slate-100']})`,
|
|
19406
|
+
/** Rules and edges. */
|
|
19407
|
+
fillStrong: `var(--hd-fill-strong,${LIGHT['--color-slate-200']})`,
|
|
19408
|
+
/** A field's and a secondary action's edge. */
|
|
19409
|
+
lineStrong: `var(--hd-line-strong,${LIGHT['--color-slate-300']})`,
|
|
19410
|
+
ink: `var(--hd-ink,${LIGHT['--ink']})`,
|
|
19411
|
+
body: `var(--hd-text-body,${LIGHT['--text-body']})`,
|
|
19412
|
+
muted: `var(--hd-text-muted,${LIGHT['--text-muted']})`,
|
|
19413
|
+
/** Selected text, and the composer's drop prompt. */
|
|
19414
|
+
selection: `var(--hd-selection,${LIGHT['--color-action-bg']})`,
|
|
19415
|
+
error: `var(--hd-error,${LIGHT['--color-error']})`
|
|
19416
|
+
});
|
|
19417
|
+
|
|
19418
|
+
/** The accent roles: the fill of a primary action, the text on it, the accent as text, and the fill under the pointer. */
|
|
19419
|
+
const HELP_DESK_ACCENT = Object.freeze({
|
|
19420
|
+
fill: `var(--hd-accent,var(--hd-light-accent,${DEFAULT['--hd-light-accent']}))`,
|
|
19421
|
+
onAccent: `var(--hd-on-accent,var(--hd-light-on-accent,${DEFAULT['--hd-light-on-accent']}))`,
|
|
19422
|
+
ink: `var(--hd-accent-ink,var(--hd-light-accent-ink,${DEFAULT['--hd-light-accent-ink']}))`,
|
|
19423
|
+
hover: `var(--hd-accent-hover,var(--hd-light-accent-hover,${DEFAULT['--hd-light-accent-hover']}))`
|
|
19424
|
+
});
|
|
19425
|
+
|
|
19426
|
+
/** The focus ring's color: the page's `--hd-focus` where it sets one, else the accent as text. */
|
|
19427
|
+
const HELP_DESK_FOCUS = `var(--hd-focus,${HELP_DESK_ACCENT.ink})`;
|
|
19428
|
+
|
|
19429
|
+
/**
|
|
19430
|
+
* Both schemes' pairings as the custom properties an element carries them
|
|
19431
|
+
* under (@sparkvault/app-sdk/brand-color accentProperties: `--hd-light-accent*`,
|
|
19432
|
+
* `--hd-dark-accent*`), written as colors, since a customer's website declares
|
|
19433
|
+
* none of the design system's tokens.
|
|
19434
|
+
*/
|
|
19435
|
+
function pairingProperties(pairings) {
|
|
19436
|
+
return Object.freeze(accentProperties(pairings, 'colors'));
|
|
19437
|
+
}
|
|
19438
|
+
/** The default pairings (@sparkvault/app-sdk/brand-color DEFAULT_PAIRINGS) as the custom properties, every one an element can carry. */
|
|
19439
|
+
const DEFAULT_PROPERTIES = pairingProperties(DEFAULT_PAIRINGS);
|
|
19440
|
+
/**
|
|
19441
|
+
* The default pairings (@sparkvault/app-sdk/brand-color DEFAULT_PAIRINGS, the
|
|
19442
|
+
* ones the customer portal, the console's sample and the desk's email paint
|
|
19443
|
+
* for a desk without a brand color) as stylesheet declarations, which a
|
|
19444
|
+
* desk's brand color replaces (applySupportBrand). The launcher, the support
|
|
19445
|
+
* panel, the request form's container and its modal each carry them, so the
|
|
19446
|
+
* accent roles (@sparkvault/app-sdk/help-desk-colors HELP_DESK_ACCENT) read
|
|
19447
|
+
* the light pairing the element carries, and a website may point those roles
|
|
19448
|
+
* at the dark one.
|
|
19449
|
+
*/
|
|
19450
|
+
const DEFAULT_PAIRING_DECLARATIONS = Object.entries(DEFAULT_PROPERTIES).map(([name, value]) => `${name}:${value}`).join(';');
|
|
19451
|
+
const NO_BRAND = Object.freeze({ color: null, properties: null });
|
|
19452
|
+
/**
|
|
19453
|
+
* Pairs a desk's brand color for every carrier, once: both of its pairings
|
|
19454
|
+
* (@sparkvault/app-sdk/brand-color schemePairings, the ones the customer
|
|
19455
|
+
* portal and the desk's email paint too), under each scheme's names: the
|
|
19456
|
+
* fill, white or the ink on it, the accent as text, and the fill under the
|
|
19457
|
+
* pointer. Whoever learns the desk's color derives it and hands the one brand
|
|
19458
|
+
* to each element it paints (applySupportBrand), so a desk's color is paired
|
|
19459
|
+
* once however often its elements render. A value that is no brand color is
|
|
19460
|
+
* none.
|
|
19461
|
+
*/
|
|
19462
|
+
function supportBrand(value) {
|
|
19463
|
+
const color = brandColor(value);
|
|
19464
|
+
const pairings = color === null ? null : schemePairings(color);
|
|
19465
|
+
return pairings ? Object.freeze({ color, properties: pairingProperties(pairings) }) : NO_BRAND;
|
|
19466
|
+
}
|
|
19467
|
+
/**
|
|
19468
|
+
* The brand for a desk's color: `held` where it pairs that same color, so a
|
|
19469
|
+
* color learned again (a held desk's, then connect's answer for it) is paired
|
|
19470
|
+
* once and stays the one object every element compares.
|
|
19471
|
+
*/
|
|
19472
|
+
function brandFor(value, held) {
|
|
19473
|
+
return brandColor(value) === held.color ? held : supportBrand(value);
|
|
19474
|
+
}
|
|
19475
|
+
/**
|
|
19476
|
+
* Sets a desk's brand (supportBrand) on the launcher, the support panel, the
|
|
19477
|
+
* request form's container or the form's modal. The stylesheet paints the
|
|
19478
|
+
* light pairing wherever the accent roles (`--hd-accent*`) are not set, so on
|
|
19479
|
+
* a website the widget's accent is the pairing the portal paints on light
|
|
19480
|
+
* pages until the page points the roles at the dark pairing, and inside the
|
|
19481
|
+
* customer portal each takes the portal's roles. Scoped to the element, so it
|
|
19482
|
+
* works on a hosted page and on any website the widget stands on; a brand
|
|
19483
|
+
* with no color clears them, and the stylesheet's default pairings return.
|
|
19484
|
+
*/
|
|
19485
|
+
function applySupportBrand(target, brand) {
|
|
19486
|
+
for (const name of Object.keys(DEFAULT_PROPERTIES)) {
|
|
19487
|
+
const value = brand.properties?.[name];
|
|
19488
|
+
if (value)
|
|
19489
|
+
target.style.setProperty(name, value);
|
|
19490
|
+
else
|
|
19491
|
+
target.style.removeProperty(name);
|
|
19492
|
+
}
|
|
19493
|
+
}
|
|
19494
|
+
|
|
19495
|
+
/**
|
|
19496
|
+
* Scoped styles for the optional inline help desk form and its modal, in the
|
|
19497
|
+
* help desk's color roles (@sparkvault/app-sdk/help-desk-colors): their
|
|
19498
|
+
* neutrals the page's roles where it sets them (HOST), their accent the
|
|
19499
|
+
* page's accent roles, else the desk's light pairing, which the form's
|
|
19500
|
+
* container and the modal each carry (ACCENT, DEFAULT_PAIRING_DECLARATIONS),
|
|
19501
|
+
* as the support panel does.
|
|
19502
|
+
*/
|
|
18833
19503
|
function injectHelpDeskFormStyles() {
|
|
18834
19504
|
if (document.getElementById('sparkvault-help-desk-styles'))
|
|
18835
19505
|
return;
|
|
@@ -18838,33 +19508,33 @@ function injectHelpDeskFormStyles() {
|
|
|
18838
19508
|
style.textContent = `
|
|
18839
19509
|
.svhd-overlay{position:fixed;inset:0;z-index:2147483000;display:flex;align-items:center;justify-content:center;padding:16px;background:${DS.modalOverlay};overflow:auto}
|
|
18840
19510
|
.svhd-blur{backdrop-filter:blur(5px)}
|
|
18841
|
-
.svhd-modal{width:100%;max-width:36rem;max-height:calc(100dvh - 32px);overflow:auto;border-radius:12px;background:${
|
|
19511
|
+
.svhd-modal{width:100%;max-width:36rem;max-height:calc(100dvh - 32px);overflow:auto;border-radius:12px;background:${HELP_DESK_COLORS.surface};box-shadow:${DS.shadowPopover};${DEFAULT_PAIRING_DECLARATIONS}}
|
|
18842
19512
|
.svhd-modal-header{display:flex;justify-content:flex-end;padding:12px 16px 0}
|
|
18843
|
-
.svhd-modal-close{border:0;border-radius:4px;background:transparent;color:${
|
|
18844
|
-
.svhd-modal-close:hover{color:${
|
|
18845
|
-
.svhd-modal-close:focus-visible{outline:3px solid ${
|
|
19513
|
+
.svhd-modal-close{border:0;border-radius:4px;background:transparent;color:${HELP_DESK_COLORS.body};cursor:pointer;font:600 14px/1.5 system-ui,sans-serif;padding:6px 8px;min-height:44px}
|
|
19514
|
+
.svhd-modal-close:hover{color:${HELP_DESK_COLORS.ink}}
|
|
19515
|
+
.svhd-modal-close:focus-visible{outline:3px solid ${HELP_DESK_FOCUS};outline-offset:2px}
|
|
18846
19516
|
.svhd-modal .svhd-container{max-width:none;border:0;border-radius:0;padding-top:8px}
|
|
18847
|
-
.svhd-container{box-sizing:border-box;max-width:36rem;border:1px solid ${
|
|
19517
|
+
.svhd-container{box-sizing:border-box;max-width:36rem;border:1px solid ${HELP_DESK_COLORS.fillStrong};border-radius:12px;background:${HELP_DESK_COLORS.surface};color:${HELP_DESK_COLORS.ink};font:400 15px/1.5 system-ui,sans-serif;padding:24px;${DEFAULT_PAIRING_DECLARATIONS}}
|
|
18848
19518
|
.svhd-container *{box-sizing:border-box}
|
|
18849
19519
|
.svhd-container h2{font-size:22px;line-height:1.25;margin:0}
|
|
18850
19520
|
.svhd-step-head h2:focus{outline:none}
|
|
18851
19521
|
.svhd-form{display:grid;gap:16px}
|
|
18852
19522
|
.svhd-field{display:grid;gap:6px}
|
|
18853
19523
|
.svhd-label{font-weight:600}
|
|
18854
|
-
.svhd-input{width:100%;border:1px solid ${
|
|
18855
|
-
.svhd-input:focus-visible,.svhd-button:focus-visible,.svhd-link:focus-visible{outline:3px solid ${
|
|
18856
|
-
.svhd-input:disabled{background:${
|
|
19524
|
+
.svhd-input{width:100%;border:1px solid ${HELP_DESK_COLORS.lineStrong};border-radius:6px;padding:10px 12px;color:${HELP_DESK_COLORS.ink};background:${HELP_DESK_COLORS.field};font:inherit;font-size:16px}
|
|
19525
|
+
.svhd-input:focus-visible,.svhd-button:focus-visible,.svhd-link:focus-visible{outline:3px solid ${HELP_DESK_FOCUS};outline-offset:2px}
|
|
19526
|
+
.svhd-input:disabled{background:${HELP_DESK_COLORS.canvas}}
|
|
18857
19527
|
.svhd-auth{display:grid;gap:16px;border:0;padding:0;margin:0}
|
|
18858
19528
|
.svhd-form[hidden],.svhd-step[hidden],.svhd-auth[hidden],.svhd-field[hidden],.svhd-field-error[hidden],.svhd-status[hidden],.svhd-link[hidden],.svhd-actions[hidden],.svhd-confirm[hidden],.svhd-widget-account[hidden],.svhd-text-button[hidden]{display:none}
|
|
18859
19529
|
.svhd-actions{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
|
|
18860
|
-
.svhd-button{border:0;border-radius:6px;padding:10px 16px;min-height:44px;font:600 15px/1.5 system-ui,sans-serif;background:${
|
|
18861
|
-
.svhd-button:hover{background:${
|
|
19530
|
+
.svhd-button{border:0;border-radius:6px;padding:10px 16px;min-height:44px;font:600 15px/1.5 system-ui,sans-serif;background:${HELP_DESK_ACCENT.fill};color:${HELP_DESK_ACCENT.onAccent};cursor:pointer}
|
|
19531
|
+
.svhd-button:hover{background:${HELP_DESK_ACCENT.hover}}
|
|
18862
19532
|
.svhd-button:disabled{opacity:.6;cursor:default}
|
|
18863
|
-
.svhd-secondary{background:transparent;color:${
|
|
18864
|
-
.svhd-secondary:hover{background:transparent;color:${
|
|
18865
|
-
.svhd-status{margin:0;color:${
|
|
18866
|
-
.svhd-error{color:${
|
|
18867
|
-
.svhd-field-error{margin:0;font-size:14px;color:${
|
|
19533
|
+
.svhd-secondary{background:transparent;color:${HELP_DESK_COLORS.body};padding:10px 4px}
|
|
19534
|
+
.svhd-secondary:hover{background:transparent;color:${HELP_DESK_COLORS.ink}}
|
|
19535
|
+
.svhd-status{margin:0;color:${HELP_DESK_COLORS.body}}
|
|
19536
|
+
.svhd-error{color:${HELP_DESK_COLORS.error}}
|
|
19537
|
+
.svhd-field-error{margin:0;font-size:14px;color:${HELP_DESK_COLORS.error}}
|
|
18868
19538
|
.svhd-code-links{display:flex;flex-wrap:wrap;gap:4px 16px}
|
|
18869
19539
|
.svhd-confirm{display:grid;gap:8px}
|
|
18870
19540
|
.svhd-confirm-title{font-weight:600;margin:0}
|
|
@@ -18872,26 +19542,26 @@ function injectHelpDeskFormStyles() {
|
|
|
18872
19542
|
.svhd-done-title{font-size:18px;line-height:1.3;margin:0}
|
|
18873
19543
|
.svhd-done-title:focus{outline:none}
|
|
18874
19544
|
.svhd-confirmation-message{white-space:pre-wrap;overflow-wrap:anywhere}
|
|
18875
|
-
.svhd-link{display:inline-flex;align-items:center;justify-self:start;min-height:44px;color:${
|
|
18876
|
-
.svhd-hint{font-size:13px;color:${
|
|
19545
|
+
.svhd-link{display:inline-flex;align-items:center;justify-self:start;min-height:44px;color:${HELP_DESK_ACCENT.ink};text-decoration:underline}
|
|
19546
|
+
.svhd-hint{font-size:13px;color:${HELP_DESK_COLORS.body};margin:0}
|
|
18877
19547
|
.svhd-step{display:grid;gap:16px;min-width:0}
|
|
18878
19548
|
.svhd-step-head{display:grid;gap:4px;margin-bottom:4px}
|
|
18879
|
-
.svhd-step-label{margin:0;font-size:13px;font-weight:600;line-height:1.4;color:${
|
|
18880
|
-
.svhd-text-button{display:inline-flex;align-items:center;min-height:44px;padding:0 4px;border:0;border-radius:6px;background:transparent;color:${
|
|
18881
|
-
.svhd-text-button:hover{
|
|
18882
|
-
.svhd-text-button:focus-visible{outline:3px solid ${
|
|
18883
|
-
.svhd-text-button:disabled{color:${
|
|
19549
|
+
.svhd-step-label{margin:0;font-size:13px;font-weight:600;line-height:1.4;color:${HELP_DESK_COLORS.body}}
|
|
19550
|
+
.svhd-text-button{display:inline-flex;align-items:center;min-height:44px;padding:0 4px;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_ACCENT.ink};font:inherit;font-size:14px;font-weight:600;text-decoration:underline;text-underline-offset:2px;cursor:pointer}
|
|
19551
|
+
.svhd-text-button:not(:disabled):hover{text-decoration-thickness:2px}
|
|
19552
|
+
.svhd-text-button:focus-visible{outline:3px solid ${HELP_DESK_FOCUS};outline-offset:2px}
|
|
19553
|
+
.svhd-text-button:disabled{color:${HELP_DESK_COLORS.muted};cursor:default}
|
|
18884
19554
|
.svhd-widget-account{display:flex;align-items:center;flex-wrap:wrap;gap:0 16px;min-width:0}
|
|
18885
|
-
.svhd-posting-as{margin:0;color:${
|
|
18886
|
-
.svhd-note{display:flex;align-items:flex-start;gap:10px;margin:0;padding:12px 14px;border:1px solid ${
|
|
18887
|
-
.svhd-step .svhd-note svg{display:block;width:18px;height:18px;flex:none;margin-top:2px;color:${
|
|
18888
|
-
.svhd-recap{display:flex;align-items:center;gap:12px;padding:6px 6px 6px 14px;border:1px solid ${
|
|
19555
|
+
.svhd-posting-as{margin:0;color:${HELP_DESK_COLORS.body};font-size:14px;line-height:1.5;overflow-wrap:anywhere}
|
|
19556
|
+
.svhd-note{display:flex;align-items:flex-start;gap:10px;margin:0;padding:12px 14px;border:1px solid ${HELP_DESK_COLORS.fillStrong};border-radius:8px;background:${HELP_DESK_COLORS.canvas};color:${HELP_DESK_COLORS.ink};font-size:14px;line-height:1.5}
|
|
19557
|
+
.svhd-step .svhd-note svg{display:block;width:18px;height:18px;flex:none;margin-top:2px;color:${HELP_DESK_ACCENT.ink}}
|
|
19558
|
+
.svhd-recap{display:flex;align-items:center;gap:12px;padding:6px 6px 6px 14px;border:1px solid ${HELP_DESK_COLORS.fillStrong};border-radius:8px}
|
|
18889
19559
|
.svhd-recap-request{flex:1;min-width:0}
|
|
18890
|
-
.svhd-recap-label{display:block;color:${
|
|
18891
|
-
.svhd-recap-text{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0;color:${
|
|
19560
|
+
.svhd-recap-label{display:block;color:${HELP_DESK_COLORS.body};font-size:12px;font-weight:600;line-height:1.4}
|
|
19561
|
+
.svhd-recap-text{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0;color:${HELP_DESK_COLORS.ink};font-size:14px;line-height:1.5;overflow-wrap:anywhere}
|
|
18892
19562
|
.svhd-recap .svhd-text-button{flex:none}
|
|
18893
19563
|
.svhd-live{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
|
|
18894
|
-
.svhd-footer{margin-top:20px;font-size:12px;color:${
|
|
19564
|
+
.svhd-footer{margin-top:20px;font-size:12px;color:${HELP_DESK_COLORS.muted}}
|
|
18895
19565
|
`;
|
|
18896
19566
|
document.head.appendChild(style);
|
|
18897
19567
|
}
|
|
@@ -19510,123 +20180,6 @@ function refusalCopy(refusal, maxBytes) {
|
|
|
19510
20180
|
return REFUSAL_COPY[refusal] ?? "This file can't be attached.";
|
|
19511
20181
|
}
|
|
19512
20182
|
|
|
19513
|
-
/**
|
|
19514
|
-
* A tenant's brand color and the WCAG contrast rules that decide how it may be
|
|
19515
|
-
* used: the one hex rule the server stores, the console checks and the portal
|
|
19516
|
-
* paints, the one contrast reading the console's readouts, the portal's
|
|
19517
|
-
* accent and the portal's reading of a help center's ground share, and the
|
|
19518
|
-
* one way a readout writes that reading.
|
|
19519
|
-
*
|
|
19520
|
-
* A brand color is tenant-controlled, so it is used only when it is a
|
|
19521
|
-
* six-digit hex color, read case-insensitively and held in lowercase; anything
|
|
19522
|
-
* else (a color name, a CSS function, a value that runs on into more CSS) is
|
|
19523
|
-
* no color at all.
|
|
19524
|
-
*
|
|
19525
|
-
* A brand color can be any lightness, so whatever shows it picks what goes
|
|
19526
|
-
* with it: white or ink as the text on its fill, whichever reads more
|
|
19527
|
-
* strongly (at least 4.2:1 on any fill, as far as two inks reach on a
|
|
19528
|
-
* mid-tone), and the color itself as text only where it reaches 4.5:1 on
|
|
19529
|
-
* both grounds accent text stands on, the white surface and the canvas
|
|
19530
|
-
* tone, ink otherwise. accentProperties says that as the accent
|
|
19531
|
-
* custom properties the customer portal paints with and the console's sample
|
|
19532
|
-
* of it shows, in the design system's own tokens.
|
|
19533
|
-
*
|
|
19534
|
-
* BROWSER-SAFE: data only, no imports.
|
|
19535
|
-
*/
|
|
19536
|
-
|
|
19537
|
-
const HEX_COLOR = /^#[0-9a-f]{6}$/;
|
|
19538
|
-
|
|
19539
|
-
/** WCAG AA's floor for normal-size text. */
|
|
19540
|
-
const AA_TEXT_CONTRAST = 4.5;
|
|
19541
|
-
|
|
19542
|
-
/**
|
|
19543
|
-
* The canvas tone, the design system's `--canvas` (`--color-slate-50`): the
|
|
19544
|
-
* page ground the customer portal (its pages and a customer's own messages)
|
|
19545
|
-
* and the knowledge base's default theme set accent text on, beside the white
|
|
19546
|
-
* surface. The design system publishes its tokens only as CSS, which this
|
|
19547
|
-
* import-free module cannot read, so the value is mirrored here once, and
|
|
19548
|
-
* tests/brand-color.test.js holds it to packages/design-system/tokens/colors.css.
|
|
19549
|
-
*/
|
|
19550
|
-
const CANVAS_COLOR = '#f7fafb';
|
|
19551
|
-
|
|
19552
|
-
/**
|
|
19553
|
-
* The ink, the design system's `--ink` (`--color-slate-900`): the dark text a
|
|
19554
|
-
* pairing paints on a fill and in place of a color too light to stand as
|
|
19555
|
-
* text. Mirrored here once for the same reason as CANVAS_COLOR, and held to
|
|
19556
|
-
* packages/design-system/tokens/colors.css by tests/brand-color.test.js.
|
|
19557
|
-
*/
|
|
19558
|
-
const INK_COLOR = '#0d1a20';
|
|
19559
|
-
|
|
19560
|
-
/** Relative luminance (WCAG 2) of an sRGB color's red, green and blue channels, each from 0 to 1. */
|
|
19561
|
-
function channelLuminance(channels) {
|
|
19562
|
-
const [red, green, blue] = channels.map((channel) => (channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4));
|
|
19563
|
-
return 0.2126 * red + 0.7152 * green + 0.0722 * blue;
|
|
19564
|
-
}
|
|
19565
|
-
|
|
19566
|
-
/** Relative luminance (WCAG 2) of a validated `#rrggbb` color. */
|
|
19567
|
-
function relativeLuminance(color) {
|
|
19568
|
-
return channelLuminance([1, 3, 5].map((offset) => Number.parseInt(color.slice(offset, offset + 2), 16) / 255));
|
|
19569
|
-
}
|
|
19570
|
-
|
|
19571
|
-
/** The contrast ratio of two relative luminances. */
|
|
19572
|
-
function contrastRatio(first, second) {
|
|
19573
|
-
return (Math.max(first, second) + 0.05) / (Math.min(first, second) + 0.05);
|
|
19574
|
-
}
|
|
19575
|
-
|
|
19576
|
-
/** The relative luminance of the ink a fill's text is weighed in, the real ink rather than pure black. */
|
|
19577
|
-
const INK_LUMINANCE = relativeLuminance(INK_COLOR);
|
|
19578
|
-
|
|
19579
|
-
/** The relative luminances of the grounds accent text stands on: the white surface and the canvas tone. */
|
|
19580
|
-
const TEXT_GROUNDS = Object.freeze([1, relativeLuminance(CANVAS_COLOR)]);
|
|
19581
|
-
|
|
19582
|
-
/** How strongly a color of this luminance reads as text on the ground it reads least on. */
|
|
19583
|
-
function textContrast(luminance) {
|
|
19584
|
-
return Math.min(...TEXT_GROUNDS.map((ground) => contrastRatio(luminance, ground)));
|
|
19585
|
-
}
|
|
19586
|
-
|
|
19587
|
-
/**
|
|
19588
|
-
* A brand color as it may be stored and shown, or null when the value is not
|
|
19589
|
-
* one: a `#rrggbb` hex value, read case-insensitively.
|
|
19590
|
-
*
|
|
19591
|
-
* @param {unknown} value
|
|
19592
|
-
* @returns {string|null} The color in lowercase
|
|
19593
|
-
*/
|
|
19594
|
-
function brandColor(value) {
|
|
19595
|
-
if (typeof value !== 'string') return null;
|
|
19596
|
-
const color = value.toLowerCase();
|
|
19597
|
-
return HEX_COLOR.test(color) ? color : null;
|
|
19598
|
-
}
|
|
19599
|
-
|
|
19600
|
-
/**
|
|
19601
|
-
* What goes with a brand color: the text on its fill (white or ink,
|
|
19602
|
-
* whichever reads more strongly, at least 4.2:1 on any fill) and the ink for
|
|
19603
|
-
* it as text
|
|
19604
|
-
* (the color itself where it reaches AA_TEXT_CONTRAST on both the white
|
|
19605
|
-
* surface and the canvas tone, ink otherwise).
|
|
19606
|
-
*
|
|
19607
|
-
* @param {unknown} value
|
|
19608
|
-
* @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)
|
|
19609
|
-
*/
|
|
19610
|
-
function accentPairing(value) {
|
|
19611
|
-
const color = brandColor(value);
|
|
19612
|
-
if (!color) return null;
|
|
19613
|
-
const luminance = relativeLuminance(color);
|
|
19614
|
-
const ratio = textContrast(luminance);
|
|
19615
|
-
return {
|
|
19616
|
-
onAccent: contrastRatio(luminance, 1) >= contrastRatio(luminance, INK_LUMINANCE) ? 'white' : 'ink',
|
|
19617
|
-
accentInk: ratio >= AA_TEXT_CONTRAST ? 'accent' : 'ink',
|
|
19618
|
-
ratio
|
|
19619
|
-
};
|
|
19620
|
-
}
|
|
19621
|
-
|
|
19622
|
-
/** Contrast between a brand fill and the label selected by accentPairing. */
|
|
19623
|
-
function accentFillContrast(value) {
|
|
19624
|
-
const color = brandColor(value);
|
|
19625
|
-
if (!color) return null;
|
|
19626
|
-
const pairing = accentPairing(color);
|
|
19627
|
-
return contrastRatio(relativeLuminance(color), pairing.onAccent === 'white' ? 1 : INK_LUMINANCE);
|
|
19628
|
-
}
|
|
19629
|
-
|
|
19630
20183
|
/**
|
|
19631
20184
|
* Files brought to a message's composer by drag, drop and paste, handled
|
|
19632
20185
|
* alike by every composer that takes them: the console's reply composer and
|
|
@@ -19910,11 +20463,14 @@ function helpDeskIcon(name) {
|
|
|
19910
20463
|
* and whether trying again can mend it.
|
|
19911
20464
|
*
|
|
19912
20465
|
* The composer draws its own stylesheet (one unlayered `<style>` per
|
|
19913
|
-
* document), in the
|
|
19914
|
-
*
|
|
19915
|
-
*
|
|
19916
|
-
*
|
|
19917
|
-
*
|
|
20466
|
+
* document), in the help desk's color roles (help-desk-colors.js): the
|
|
20467
|
+
* host's where it sets them, else the design system's light values, with the
|
|
20468
|
+
* help desk's accent as text, the light pairing of the SDK's panel, form
|
|
20469
|
+
* container or modal it stands in where the host sets no accent role. Its
|
|
20470
|
+
* focus ring is the one the host's fields wear: its color, width and offset
|
|
20471
|
+
* are the host's `--hd-focus`, `--hd-focus-width` and `--hd-focus-offset`,
|
|
20472
|
+
* the color else that accent, the width and offset else the SDK's field
|
|
20473
|
+
* ring's (3px, 2px out).
|
|
19918
20474
|
*
|
|
19919
20475
|
* BROWSER-SAFE: builds its DOM through the page's `document`, and imports
|
|
19920
20476
|
* only app-sdk's browser-safe modules.
|
|
@@ -19924,34 +20480,11 @@ function helpDeskIcon(name) {
|
|
|
19924
20480
|
/** The id of the composer's one `<style>` element in a document. */
|
|
19925
20481
|
const HELP_DESK_COMPOSER_STYLE_ID = 'sparkvault-help-desk-composer-styles';
|
|
19926
20482
|
|
|
19927
|
-
/**
|
|
19928
|
-
* The design-system colors the composer is drawn in, each the value of the
|
|
19929
|
-
* token it names (tests/help-desk-composer.test.js holds them to
|
|
19930
|
-
* packages/design-system/tokens). The canvas tone and the ink are
|
|
19931
|
-
* brand-color.js' mirrors of those tokens.
|
|
19932
|
-
*/
|
|
19933
|
-
const COMPOSER_COLORS = Object.freeze({
|
|
19934
|
-
'--color-white': '#ffffff',
|
|
19935
|
-
'--canvas': CANVAS_COLOR,
|
|
19936
|
-
'--color-slate-100': '#f0f5f7',
|
|
19937
|
-
'--color-slate-200': '#e0e9ed',
|
|
19938
|
-
'--color-slate-300': '#c9d6dc',
|
|
19939
|
-
'--color-slate-600': '#425761',
|
|
19940
|
-
'--ink': INK_COLOR,
|
|
19941
|
-
'--color-action': '#216bde',
|
|
19942
|
-
'--color-action-bg': '#eef4fe',
|
|
19943
|
-
'--color-error': '#b02b27'
|
|
19944
|
-
});
|
|
19945
|
-
|
|
19946
|
-
const C = COMPOSER_COLORS;
|
|
19947
|
-
/** The help desk's accent ink where the host sets one, Action Blue where none does. */
|
|
19948
|
-
const ACCENT_INK = `var(--hd-accent-ink,${C['--color-action']})`;
|
|
19949
|
-
/** The focus ring of the host's fields: the SDK's field ring (`.svhd-input`) where the host sets none. */
|
|
19950
|
-
const FOCUS = `var(--hd-focus,${C['--color-action']})`;
|
|
20483
|
+
/** The focus ring's width and offset: the host's where it sets them, else the SDK's field ring (`.svhd-input`). */
|
|
19951
20484
|
const FOCUS_WIDTH = 'var(--hd-focus-width,3px)';
|
|
19952
20485
|
const FOCUS_OFFSET = 'var(--hd-focus-offset,2px)';
|
|
19953
20486
|
/** A control inside the frame wears the ring within its own hit area. */
|
|
19954
|
-
const INSET_RING = `outline:${FOCUS_WIDTH} solid ${
|
|
20487
|
+
const INSET_RING = `outline:${FOCUS_WIDTH} solid ${HELP_DESK_FOCUS};outline-offset:calc(-1 * ${FOCUS_WIDTH});box-shadow:none`;
|
|
19955
20488
|
|
|
19956
20489
|
/**
|
|
19957
20490
|
* The composer's stylesheet. Every rule but the notice's sits under
|
|
@@ -19961,41 +20494,41 @@ const INSET_RING = `outline:${FOCUS_WIDTH} solid ${FOCUS};outline-offset:calc(-1
|
|
|
19961
20494
|
*/
|
|
19962
20495
|
const COMPOSER_CSS = `
|
|
19963
20496
|
.svhd-composer,.svhd-composer *{box-sizing:border-box}
|
|
19964
|
-
.svhd-composer{position:relative;display:flex;flex-direction:column;min-width:0;border:1px solid ${
|
|
19965
|
-
.svhd-composer:has(.svhd-composer-input:focus-visible){outline:${FOCUS_WIDTH} solid ${
|
|
19966
|
-
@supports not selector(:has(*)){.svhd-composer:focus-within{outline:${FOCUS_WIDTH} solid ${
|
|
19967
|
-
.svhd-composer:has(.svhd-composer-input[aria-invalid=true]){border-color:${
|
|
19968
|
-
.svhd-composer.svhd-composer-dragging{border-style:dashed;border-color:${
|
|
19969
|
-
.svhd-composer .svhd-composer-input{display:block;width:100%;min-height:140px;margin:0;resize:vertical;border:0;border-radius:6px 6px 0 0;padding:10px 12px;background:transparent;color:${
|
|
20497
|
+
.svhd-composer{position:relative;display:flex;flex-direction:column;min-width:0;border:1px solid ${HELP_DESK_COLORS.lineStrong};border-radius:6px;background:${HELP_DESK_COLORS.field};color:${HELP_DESK_COLORS.ink}}
|
|
20498
|
+
.svhd-composer:has(.svhd-composer-input:focus-visible){outline:${FOCUS_WIDTH} solid ${HELP_DESK_FOCUS};outline-offset:${FOCUS_OFFSET}}
|
|
20499
|
+
@supports not selector(:has(*)){.svhd-composer:focus-within{outline:${FOCUS_WIDTH} solid ${HELP_DESK_FOCUS};outline-offset:${FOCUS_OFFSET}}}
|
|
20500
|
+
.svhd-composer:has(.svhd-composer-input[aria-invalid=true]){border-color:${HELP_DESK_COLORS.error}}
|
|
20501
|
+
.svhd-composer.svhd-composer-dragging{border-style:dashed;border-color:${HELP_DESK_ACCENT.ink}}
|
|
20502
|
+
.svhd-composer .svhd-composer-input{display:block;width:100%;min-height:140px;margin:0;resize:vertical;border:0;border-radius:6px 6px 0 0;padding:10px 12px;background:transparent;color:${HELP_DESK_COLORS.ink};font-family:inherit;font-size:16px;line-height:1.5}
|
|
19970
20503
|
.svhd-composer .svhd-composer-input:focus,.svhd-composer .svhd-composer-input:focus-visible{outline:none;box-shadow:none}
|
|
19971
|
-
.svhd-composer .svhd-composer-input:disabled{background:${
|
|
19972
|
-
.svhd-composer .svhd-composer-drop{position:absolute;inset:0;z-index:1;display:flex;align-items:center;justify-content:center;margin:0;padding:12px;border-radius:5px;background:${
|
|
19973
|
-
.svhd-composer .svhd-composer-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:0 4px;padding:0 4px;border-top:1px solid ${
|
|
19974
|
-
.svhd-composer .svhd-composer-attach{display:inline-flex;align-items:center;gap:6px;min-height:44px;margin:0;padding:0 8px;border:0;border-radius:6px;background:transparent;color:${
|
|
19975
|
-
.svhd-composer .svhd-composer-attach:hover,.svhd-composer .svhd-composer-help:hover{background:${
|
|
20504
|
+
.svhd-composer .svhd-composer-input:disabled{background:${HELP_DESK_COLORS.canvas}}
|
|
20505
|
+
.svhd-composer .svhd-composer-drop{position:absolute;inset:0;z-index:1;display:flex;align-items:center;justify-content:center;margin:0;padding:12px;border-radius:5px;background:${HELP_DESK_COLORS.selection};color:${HELP_DESK_ACCENT.ink};font-size:15px;font-weight:600;line-height:1.4;text-align:center;pointer-events:none}
|
|
20506
|
+
.svhd-composer .svhd-composer-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:0 4px;padding:0 4px;border-top:1px solid ${HELP_DESK_COLORS.fillStrong}}
|
|
20507
|
+
.svhd-composer .svhd-composer-attach{display:inline-flex;align-items:center;gap:6px;min-height:44px;margin:0;padding:0 8px;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_COLORS.body};font-family:inherit;font-size:14px;font-weight:600;line-height:1.4;cursor:pointer}
|
|
20508
|
+
.svhd-composer .svhd-composer-attach:hover,.svhd-composer .svhd-composer-help:hover{background:${HELP_DESK_COLORS.fill};color:${HELP_DESK_COLORS.ink}}
|
|
19976
20509
|
.svhd-composer .svhd-composer-attach:disabled{opacity:.6;cursor:default}
|
|
19977
20510
|
.svhd-composer .svhd-composer-attach svg{display:block;width:18px;height:18px}
|
|
19978
|
-
.svhd-composer .svhd-composer-help{display:inline-grid;place-items:center;width:44px;height:44px;margin:0;padding:0;border:0;border-radius:6px;background:transparent;color:${
|
|
20511
|
+
.svhd-composer .svhd-composer-help{display:inline-grid;place-items:center;width:44px;height:44px;margin:0;padding:0;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_COLORS.body};font-family:inherit;cursor:pointer}
|
|
19979
20512
|
.svhd-composer .svhd-composer-help-glyph{display:inline-grid;place-items:center;width:20px;height:20px;border:1px solid currentColor;border-radius:50%;font-size:13px;font-weight:600;line-height:1}
|
|
19980
|
-
.svhd-composer .svhd-composer-help-panel{display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:8px;align-items:start;flex:1 1 100%;min-width:0;margin:0 0 8px;padding:10px 12px;border:1px solid ${
|
|
20513
|
+
.svhd-composer .svhd-composer-help-panel{display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:8px;align-items:start;flex:1 1 100%;min-width:0;margin:0 0 8px;padding:10px 12px;border:1px solid ${HELP_DESK_COLORS.fillStrong};border-radius:6px;background:${HELP_DESK_COLORS.canvas};color:${HELP_DESK_COLORS.body};font-size:13px;line-height:1.5}
|
|
19981
20514
|
.svhd-composer .svhd-composer-help-copy{grid-column:1;min-width:0;overflow-wrap:anywhere}
|
|
19982
20515
|
.svhd-composer .svhd-composer-help-copy p{margin:0}
|
|
19983
20516
|
.svhd-composer .svhd-composer-help-copy p+p{margin-top:6px}
|
|
19984
|
-
.svhd-composer .svhd-composer-help-close{grid-row:1;grid-column:2;display:grid;place-items:center;width:44px;height:44px;margin:-10px -12px 0 0;padding:0;border:0;border-radius:6px;background:transparent;color:${
|
|
19985
|
-
.svhd-composer .svhd-composer-help-close:hover,.svhd-composer .svhd-attachment-remove:hover{background:${
|
|
20517
|
+
.svhd-composer .svhd-composer-help-close{grid-row:1;grid-column:2;display:grid;place-items:center;width:44px;height:44px;margin:-10px -12px 0 0;padding:0;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_COLORS.body};cursor:pointer}
|
|
20518
|
+
.svhd-composer .svhd-composer-help-close:hover,.svhd-composer .svhd-attachment-remove:hover{background:${HELP_DESK_COLORS.fillStrong};color:${HELP_DESK_COLORS.ink}}
|
|
19986
20519
|
.svhd-composer .svhd-composer-help-close svg,.svhd-composer .svhd-attachment-remove svg{display:block;width:16px;height:16px}
|
|
19987
|
-
.svhd-composer .svhd-attachment-chips{display:flex;flex-wrap:wrap;gap:8px;list-style:none;margin:0;padding:8px;border-top:1px solid ${
|
|
20520
|
+
.svhd-composer .svhd-attachment-chips{display:flex;flex-wrap:wrap;gap:8px;list-style:none;margin:0;padding:8px;border-top:1px solid ${HELP_DESK_COLORS.fillStrong}}
|
|
19988
20521
|
.svhd-composer .svhd-attachment-chips:empty{display:none}
|
|
19989
|
-
.svhd-composer .svhd-attachment-chip{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;align-content:start;flex:0 1 280px;min-width:0;max-width:100%;margin:0;padding:0 0 8px 10px;border:1px solid ${
|
|
19990
|
-
.svhd-composer .svhd-attachment-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600;color:${
|
|
19991
|
-
.svhd-composer .svhd-attachment-status{grid-column:1;padding-right:8px;color:${
|
|
19992
|
-
.svhd-composer .svhd-attachment-status.svhd-composer-problem{color:${
|
|
19993
|
-
.svhd-composer .svhd-attachment-progress{grid-column:1/-1;width:calc(100% - 10px);height:6px;margin-top:6px;accent-color:${
|
|
19994
|
-
.svhd-composer .svhd-attachment-remove{display:grid;place-items:center;width:44px;height:44px;min-height:44px;margin:0;padding:0;border:0;border-radius:6px;background:transparent;color:${
|
|
19995
|
-
.svhd-composer .svhd-attachment-retry{grid-column:2;min-height:44px;margin:0;padding:0 10px;border:0;border-radius:6px;background:transparent;color:${
|
|
20522
|
+
.svhd-composer .svhd-attachment-chip{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;align-content:start;flex:0 1 280px;min-width:0;max-width:100%;margin:0;padding:0 0 8px 10px;border:1px solid ${HELP_DESK_COLORS.fillStrong};border-radius:6px;background:${HELP_DESK_COLORS.canvas};font-size:13px;line-height:1.4}
|
|
20523
|
+
.svhd-composer .svhd-attachment-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600;color:${HELP_DESK_COLORS.ink}}
|
|
20524
|
+
.svhd-composer .svhd-attachment-status{grid-column:1;padding-right:8px;color:${HELP_DESK_COLORS.body};font-size:12px;overflow-wrap:anywhere}
|
|
20525
|
+
.svhd-composer .svhd-attachment-status.svhd-composer-problem{color:${HELP_DESK_COLORS.error}}
|
|
20526
|
+
.svhd-composer .svhd-attachment-progress{grid-column:1/-1;width:calc(100% - 10px);height:6px;margin-top:6px;accent-color:${HELP_DESK_ACCENT.ink}}
|
|
20527
|
+
.svhd-composer .svhd-attachment-remove{display:grid;place-items:center;width:44px;height:44px;min-height:44px;margin:0;padding:0;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_COLORS.body};cursor:pointer}
|
|
20528
|
+
.svhd-composer .svhd-attachment-retry{grid-column:2;min-height:44px;margin:0;padding:0 10px;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_ACCENT.ink};font-family:inherit;font-size:13px;font-weight:600;line-height:1.4;text-decoration:underline;cursor:pointer}
|
|
19996
20529
|
.svhd-composer .svhd-attachment-remove:disabled,.svhd-composer .svhd-attachment-retry:disabled{opacity:.6;cursor:default}
|
|
19997
20530
|
.svhd-composer .svhd-composer-attach:focus-visible,.svhd-composer .svhd-composer-help:focus-visible,.svhd-composer .svhd-composer-help-close:focus-visible,.svhd-composer .svhd-attachment-remove:focus-visible,.svhd-composer .svhd-attachment-retry:focus-visible{${INSET_RING}}
|
|
19998
|
-
.svhd-composer-notice{margin:0;color:${
|
|
20531
|
+
.svhd-composer-notice{margin:0;color:${HELP_DESK_COLORS.error};font-size:14px;line-height:1.5}
|
|
19999
20532
|
.svhd-composer [hidden],.svhd-composer-notice[hidden]{display:none!important}
|
|
20000
20533
|
`;
|
|
20001
20534
|
|
|
@@ -20917,6 +21450,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
20917
21450
|
// The page that lays the support wizard out carries the attribution itself.
|
|
20918
21451
|
footer: options.hostShowsAttribution ? null : createSecuredByFooter('svhd'),
|
|
20919
21452
|
});
|
|
21453
|
+
applySupportBrand(shell.container, options.brand ?? supportBrand(client.desk.branding?.color));
|
|
20920
21454
|
const prefix = `svhd-${++formSequence}`;
|
|
20921
21455
|
const form = document.createElement('form');
|
|
20922
21456
|
form.className = 'svhd-form';
|
|
@@ -21788,9 +22322,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
21788
22322
|
return;
|
|
21789
22323
|
}
|
|
21790
22324
|
hosted.hidden = newRequestUrl === null;
|
|
21791
|
-
message(
|
|
21792
|
-
? 'This help desk cannot sign you in right now. Try again later.'
|
|
21793
|
-
: 'This help desk requires sign-in. Open it in a new tab to sign in and submit your request there.');
|
|
22325
|
+
message('This help desk requires sign-in. Open it in a new tab to sign in and submit your request there.');
|
|
21794
22326
|
}
|
|
21795
22327
|
async function submit() {
|
|
21796
22328
|
if (pending || completed || destroyed)
|
|
@@ -22531,9 +23063,12 @@ function openHelpDeskForm(client, options = {}) {
|
|
|
22531
23063
|
close.addEventListener('click', requestDismiss);
|
|
22532
23064
|
header.append(title, close);
|
|
22533
23065
|
const body = document.createElement('div');
|
|
23066
|
+
// Paired once for the modal and the form inside it.
|
|
23067
|
+
const brand = options.brand ?? supportBrand(client.desk.branding?.color);
|
|
23068
|
+
applySupportBrand(shell.modal, brand);
|
|
22534
23069
|
shell.modal.append(header, body);
|
|
22535
23070
|
try {
|
|
22536
|
-
inner = mountHelpDeskForm(client, { ...options, target: body, onCancel: cancel });
|
|
23071
|
+
inner = mountHelpDeskForm(client, { ...options, brand, target: body, onCancel: cancel });
|
|
22537
23072
|
// State observers run while the inner form mounts. They can dismiss the
|
|
22538
23073
|
// shell before mountHelpDeskForm hands us its cleanup handle.
|
|
22539
23074
|
if (destroyed)
|
|
@@ -24590,8 +25125,12 @@ function createSupportAnalytics({ deskId, post }) {
|
|
|
24590
25125
|
}
|
|
24591
25126
|
|
|
24592
25127
|
let launcherSequence = 0;
|
|
24593
|
-
/**
|
|
24594
|
-
|
|
25128
|
+
/**
|
|
25129
|
+
* A convenience path only: it never owns a second support flow. It carries
|
|
25130
|
+
* the desk's brand (`brand`, then setBrand), so its focus ring is the desk's,
|
|
25131
|
+
* as the panel's are.
|
|
25132
|
+
*/
|
|
25133
|
+
function createSupportLauncher(options, brand, open) {
|
|
24595
25134
|
const button = document.createElement('button');
|
|
24596
25135
|
button.type = 'button';
|
|
24597
25136
|
button.className = 'sv-support-launcher';
|
|
@@ -24600,7 +25139,7 @@ function createSupportLauncher(options, open) {
|
|
|
24600
25139
|
button.setAttribute('aria-haspopup', 'dialog');
|
|
24601
25140
|
button.setAttribute('aria-expanded', 'false');
|
|
24602
25141
|
const offset = (value, fallback) => typeof value === 'number' && Number.isFinite(value) ? Math.min(240, Math.max(12, value)) : fallback;
|
|
24603
|
-
button.style.cssText = `position:fixed;right:calc(${offset(options.right, 24)}px + env(safe-area-inset-right,0px));bottom:calc(${offset(options.bottom, 24)}px + env(safe-area-inset-bottom,0px));z-index:2147482800;width:56px;height:56px;border-radius:50%;border:1px solid ${withAlpha(DS.white, .22)};background:${DS.slate900};color:${DS.white};
|
|
25142
|
+
button.style.cssText = `position:fixed;right:calc(${offset(options.right, 24)}px + env(safe-area-inset-right,0px));bottom:calc(${offset(options.bottom, 24)}px + env(safe-area-inset-bottom,0px));z-index:2147482800;width:56px;height:56px;border-radius:50%;border:1px solid ${withAlpha(DS.white, .22)};background:${DS.slate900};color:${DS.white};display:grid;place-items:center;cursor:pointer;padding:0;overflow:hidden;`;
|
|
24604
25143
|
if (options.imageUrl) {
|
|
24605
25144
|
let url;
|
|
24606
25145
|
try {
|
|
@@ -24626,19 +25165,37 @@ function createSupportLauncher(options, open) {
|
|
|
24626
25165
|
mark.style.cssText = 'display:grid;place-items:center;width:26px;height:26px;border:1.8px solid currentColor;border-radius:50%;font:600 20px/1 system-ui,sans-serif';
|
|
24627
25166
|
button.append(mark);
|
|
24628
25167
|
}
|
|
25168
|
+
applySupportBrand(button, brand);
|
|
24629
25169
|
button.addEventListener('click', open);
|
|
24630
25170
|
document.body.append(button);
|
|
24631
25171
|
return {
|
|
24632
25172
|
setExpanded(expanded) { button.setAttribute('aria-expanded', String(expanded)); },
|
|
25173
|
+
setBrand(next) { applySupportBrand(button, next); },
|
|
24633
25174
|
destroy() { button.removeEventListener('click', open); button.remove(); },
|
|
24634
25175
|
};
|
|
24635
25176
|
}
|
|
24636
25177
|
|
|
25178
|
+
/**
|
|
25179
|
+
* The launcher's focus ring. The launcher floats over whatever the website
|
|
25180
|
+
* draws beneath it, so its ring opens with two bands no page color hides
|
|
25181
|
+
* (WCAG technique C40): white, then slate-950, which stand over 9:1 apart, so
|
|
25182
|
+
* one of them stands at 3:1 or more on any ground. It is the design system's
|
|
25183
|
+
* focus ring (`--focus-ring`: a surface gap, then the ring) with the darkest
|
|
25184
|
+
* slate as its ring, and the desk's focus color rings outside both.
|
|
25185
|
+
*/
|
|
25186
|
+
const LAUNCHER_RING = `0 0 0 2px ${DS.white},0 0 0 4px ${DS.slate950}`;
|
|
24637
25187
|
/**
|
|
24638
25188
|
* The support journey's only skin. Customer content stays in the product register.
|
|
24639
25189
|
* The panel's focus ring is 2px, 3px out, in the desk's focus color: its width and
|
|
24640
25190
|
* offset are the panel's custom properties, which the help desk composer inside
|
|
24641
|
-
* its request form reads, so the composer rings as the fields beside it do.
|
|
25191
|
+
* its request form reads, so the composer rings as the fields beside it do. It
|
|
25192
|
+
* paints in the help desk's color roles (@sparkvault/app-sdk/help-desk-colors):
|
|
25193
|
+
* its neutrals read the page's roles (HOST), so in the customer portal they
|
|
25194
|
+
* follow the portal's scheme, and stay light anywhere else; its accent reads
|
|
25195
|
+
* the page's accent roles, else the desk's light pairing (ACCENT), which the
|
|
25196
|
+
* panel and the launcher each carry (DEFAULT_PAIRING_DECLARATIONS), so the
|
|
25197
|
+
* launcher rings in the desk's color, as every control in the panel does,
|
|
25198
|
+
* outside a ring of its own that reads on any page (LAUNCHER_RING).
|
|
24642
25199
|
*/
|
|
24643
25200
|
function injectHelpDeskSupportStyles() {
|
|
24644
25201
|
if (document.getElementById('sparkvault-help-desk-support-styles'))
|
|
@@ -24647,8 +25204,8 @@ function injectHelpDeskSupportStyles() {
|
|
|
24647
25204
|
style.id = 'sparkvault-help-desk-support-styles';
|
|
24648
25205
|
style.textContent = `
|
|
24649
25206
|
.svhs-panel,.svhs-panel *{box-sizing:border-box}
|
|
24650
|
-
.svhs-panel{--hd-focus-width:2px;--hd-focus-offset:3px}
|
|
24651
|
-
.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 ${
|
|
25207
|
+
.svhs-panel{--hd-focus-width:2px;--hd-focus-offset:3px;${DEFAULT_PAIRING_DECLARATIONS}}
|
|
25208
|
+
.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 ${HELP_DESK_COLORS.fillStrong};border-radius:12px;background:${HELP_DESK_COLORS.surface};color:${HELP_DESK_COLORS.ink};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)}
|
|
24652
25209
|
.svhs-panel[hidden],.svhs-panel [hidden]{display:none!important}
|
|
24653
25210
|
.svhs-panel[data-stage=results]{height:680px}
|
|
24654
25211
|
.svhs-panel[data-stage=article]{width:704px;height:700px}
|
|
@@ -24659,99 +25216,99 @@ function injectHelpDeskSupportStyles() {
|
|
|
24659
25216
|
.svhs-panel button,.svhs-panel a{touch-action:manipulation;-webkit-tap-highlight-color:transparent}
|
|
24660
25217
|
.svhs-panel button{appearance:none;cursor:pointer;margin:0}
|
|
24661
25218
|
.svhs-panel button:active{transform:translateY(1px)}
|
|
24662
|
-
.svhs-panel button:focus-visible,.svhs-panel a:focus-visible,.svhs-panel input:focus-visible,.svhs-panel textarea:focus-visible{outline:var(--hd-focus-width) solid
|
|
25219
|
+
.svhs-panel button:focus-visible,.svhs-panel a:focus-visible,.svhs-panel input:focus-visible,.svhs-panel textarea:focus-visible{outline:var(--hd-focus-width) solid ${HELP_DESK_FOCUS};outline-offset:var(--hd-focus-offset);box-shadow:none}
|
|
24663
25220
|
.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}
|
|
24664
|
-
.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 ${
|
|
24665
|
-
.svhs-desk-name{font-size:14px;font-weight:600;line-height:1.35;color:${
|
|
25221
|
+
.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 ${HELP_DESK_COLORS.fillStrong}}
|
|
25222
|
+
.svhs-desk-name{font-size:14px;font-weight:600;line-height:1.35;color:${HELP_DESK_COLORS.body};overflow-wrap:anywhere;min-width:0}
|
|
24666
25223
|
.svhs-toolbar-actions{display:flex;align-items:center;gap:4px;margin-left:auto;flex:none}
|
|
24667
|
-
.svhs-identity-notice{display:flex;align-items:center;justify-content:space-between;gap:8px;flex:none;padding:8px 24px;border-bottom:1px solid ${
|
|
25224
|
+
.svhs-identity-notice{display:flex;align-items:center;justify-content:space-between;gap:8px;flex:none;padding:8px 24px;border-bottom:1px solid ${HELP_DESK_COLORS.fillStrong};background:${HELP_DESK_COLORS.canvas}}
|
|
24668
25225
|
.svhs-identity-notice .svhs-status{margin:0;font-size:13px}
|
|
24669
25226
|
.svhs-identity-notice .svhs-text-button{flex:none;font-size:13px!important}
|
|
24670
|
-
.svhs-icon-button{display:grid;place-items:center;width:40px;height:40px;flex:none;padding:0;border:0;border-radius:6px;background:transparent;color:${
|
|
24671
|
-
.svhs-icon-button:hover{background:${
|
|
24672
|
-
.svhs-back{display:flex;align-items:center;gap:4px;flex:none;min-height:40px;margin-left:-10px!important;padding:8px;border:0;border-radius:6px;background:transparent;color:${
|
|
24673
|
-
.svhs-back:hover{background:${
|
|
24674
|
-
.svhs-back:disabled{background:transparent;color:${
|
|
25227
|
+
.svhs-icon-button{display:grid;place-items:center;width:40px;height:40px;flex:none;padding:0;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_COLORS.muted};text-decoration:none}
|
|
25228
|
+
.svhs-icon-button:hover{background:${HELP_DESK_COLORS.fill};color:${HELP_DESK_COLORS.ink}}
|
|
25229
|
+
.svhs-back{display:flex;align-items:center;gap:4px;flex:none;min-height:40px;margin-left:-10px!important;padding:8px;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_COLORS.body};font-size:14px!important;font-weight:500!important;line-height:1.4}
|
|
25230
|
+
.svhs-back:hover{background:${HELP_DESK_COLORS.hover}}
|
|
25231
|
+
.svhs-back:disabled{background:transparent;color:${HELP_DESK_COLORS.muted};cursor:default;transform:none}
|
|
24675
25232
|
.svhs-screen{display:flex;flex-direction:column;min-height:0;flex:1}
|
|
24676
25233
|
.svhs-scroll{padding:26px 24px;overflow:auto;overscroll-behavior:contain;min-height:0;flex:1;scrollbar-gutter:stable}
|
|
24677
|
-
.svhs-heading{margin:0 0 8px;padding:0;color:${
|
|
25234
|
+
.svhs-heading{margin:0 0 8px;padding:0;color:${HELP_DESK_COLORS.ink};font-size:24px;font-weight:600;line-height:1.3;letter-spacing:-.6px;overflow-wrap:anywhere}
|
|
24678
25235
|
.svhs-heading:focus,.svhs-article-title:focus{outline:none;box-shadow:none}
|
|
24679
|
-
.svhs-copy{margin:0 0 24px;color:${
|
|
24680
|
-
.svhs-label{display:block;margin:0 0 7px;font-size:13px;font-weight:600;color:${
|
|
24681
|
-
.svhs-issue{display:block;width:100%;min-height:120px;max-height:200px;resize:none;overflow-y:auto;border:1px solid ${
|
|
25236
|
+
.svhs-copy{margin:0 0 24px;color:${HELP_DESK_COLORS.body};font-size:14px;line-height:1.55}
|
|
25237
|
+
.svhs-label{display:block;margin:0 0 7px;font-size:13px;font-weight:600;color:${HELP_DESK_COLORS.body}}
|
|
25238
|
+
.svhs-issue{display:block;width:100%;min-height:120px;max-height:200px;resize:none;overflow-y:auto;border:1px solid ${HELP_DESK_COLORS.lineStrong};border-radius:8px;padding:12px 14px;background:${HELP_DESK_COLORS.field};color:${HELP_DESK_COLORS.ink};font-size:16px!important;line-height:1.5!important;box-shadow:none}
|
|
24682
25239
|
/* The heading is the field's label, so the field follows it at a label's distance from a question this large. */
|
|
24683
25240
|
.svhs-heading+.svhs-issue{margin-top:16px}
|
|
24684
|
-
.svhs-issue::placeholder{color:${
|
|
24685
|
-
.svhs-issue:focus{border-color
|
|
25241
|
+
.svhs-issue::placeholder{color:${HELP_DESK_COLORS.muted};opacity:1}
|
|
25242
|
+
.svhs-issue:focus{border-color:${HELP_DESK_FOCUS}}
|
|
24686
25243
|
.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)}
|
|
24687
|
-
.svhs-primary{background
|
|
24688
|
-
.svhs-primary:hover{background
|
|
25244
|
+
.svhs-primary{background:${HELP_DESK_ACCENT.fill};color:${HELP_DESK_ACCENT.onAccent}}
|
|
25245
|
+
.svhs-primary:hover{background:${HELP_DESK_ACCENT.hover}}
|
|
24689
25246
|
.svhs-primary[aria-disabled=true]{cursor:progress}
|
|
24690
|
-
.svhs-secondary{border-color:${
|
|
24691
|
-
.svhs-secondary:hover{background:${
|
|
24692
|
-
.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
|
|
25247
|
+
.svhs-secondary{border-color:${HELP_DESK_COLORS.lineStrong};background:${HELP_DESK_COLORS.surface};color:${HELP_DESK_COLORS.body}}
|
|
25248
|
+
.svhs-secondary:hover{background:${HELP_DESK_COLORS.hover}}
|
|
25249
|
+
.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:${HELP_DESK_ACCENT.ink};font-size:14px!important;line-height:1.4!important;text-decoration:none}
|
|
24693
25250
|
.svhs-text-button:hover{text-decoration:underline}
|
|
24694
25251
|
.svhs-full{width:100%}
|
|
24695
|
-
.svhs-bottom{padding:16px 24px 18px;flex:none;border-top:1px solid ${
|
|
25252
|
+
.svhs-bottom{padding:16px 24px 18px;flex:none;border-top:1px solid ${HELP_DESK_COLORS.fill}}
|
|
24696
25253
|
.svhs-start-bottom{display:flex;flex-direction:column;align-items:center;gap:6px;padding-top:0;border-top:0}
|
|
24697
25254
|
.svhs-start-bottom .svhs-primary{width:100%}
|
|
24698
|
-
.svhs-query{display:flex;align-items:center;gap:12px;margin:0 0 24px;padding:12px 14px;border:1px solid ${
|
|
25255
|
+
.svhs-query{display:flex;align-items:center;gap:12px;margin:0 0 24px;padding:12px 14px;border:1px solid ${HELP_DESK_COLORS.fillStrong};border-radius:8px;background:${HELP_DESK_COLORS.canvas}}
|
|
24699
25256
|
.svhs-question{flex:1;min-width:0}
|
|
24700
|
-
.svhs-question-label{display:block;margin-bottom:3px;color:${
|
|
24701
|
-
.svhs-query-text{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0;color:${
|
|
25257
|
+
.svhs-question-label{display:block;margin-bottom:3px;color:${HELP_DESK_COLORS.muted};font-size:12px;font-weight:500;line-height:1.4}
|
|
25258
|
+
.svhs-query-text{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0;color:${HELP_DESK_COLORS.ink};font-size:14px;line-height:1.5;overflow-wrap:anywhere;white-space:pre-wrap}
|
|
24702
25259
|
.svhs-query .svhs-text-button{flex:none;min-width:44px;padding:8px 0}
|
|
24703
25260
|
.svhs-results{display:flex;flex-direction:column;margin:0;padding:0;list-style:none}
|
|
24704
|
-
.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 ${
|
|
24705
|
-
.svhs-results li:first-child .svhs-result{border-top:1px solid ${
|
|
25261
|
+
.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 ${HELP_DESK_COLORS.fillStrong};border-radius:0;background:${HELP_DESK_COLORS.surface};color:${HELP_DESK_COLORS.ink};text-align:left}
|
|
25262
|
+
.svhs-results li:first-child .svhs-result{border-top:1px solid ${HELP_DESK_COLORS.fillStrong}}
|
|
24706
25263
|
.svhs-results li:last-child .svhs-result{border-bottom:0}
|
|
24707
25264
|
.svhs-result-copy{display:block;min-width:0}
|
|
24708
|
-
.svhs-result-icon{margin-top:2px;color:${
|
|
24709
|
-
.svhs-result-chevron{width:16px!important;height:16px!important;margin-top:4px;color:${
|
|
25265
|
+
.svhs-result-icon{margin-top:2px;color:${HELP_DESK_COLORS.muted}}
|
|
25266
|
+
.svhs-result-chevron{width:16px!important;height:16px!important;margin-top:4px;color:${HELP_DESK_COLORS.muted}}
|
|
24710
25267
|
.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}
|
|
24711
|
-
.svhs-result:hover{background:${
|
|
24712
|
-
.svhs-result:hover .svhs-result-title{color
|
|
24713
|
-
.svhs-result-excerpt{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0;color:${
|
|
24714
|
-
.svhs-result-category{display:block;margin-top:6px;color:${
|
|
24715
|
-
.svhs-results-bottom{display:flex;flex-wrap:wrap;align-items:center;gap:8px 16px;background:${
|
|
25268
|
+
.svhs-result:hover{background:${HELP_DESK_COLORS.hover}}
|
|
25269
|
+
.svhs-result:hover .svhs-result-title{color:${HELP_DESK_ACCENT.ink};text-decoration:underline}
|
|
25270
|
+
.svhs-result-excerpt{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0;color:${HELP_DESK_COLORS.body};font-size:14px;line-height:1.5;overflow-wrap:anywhere}
|
|
25271
|
+
.svhs-result-category{display:block;margin-top:6px;color:${HELP_DESK_COLORS.muted};font-size:12px;line-height:1.4}
|
|
25272
|
+
.svhs-results-bottom{display:flex;flex-wrap:wrap;align-items:center;gap:8px 16px;background:${HELP_DESK_COLORS.canvas};border-top-color:${HELP_DESK_COLORS.fillStrong}}
|
|
24716
25273
|
/* Wraps below the ticket button when less than 200px remain beside it, as under the panel's full-width button. */
|
|
24717
|
-
.svhs-contact-note{flex:1 1 200px;min-width:0;margin:0;color:${
|
|
24718
|
-
.svhs-error{margin:12px 0 0;color:${
|
|
24719
|
-
.svhs-status{margin:16px 0;color:${
|
|
25274
|
+
.svhs-contact-note{flex:1 1 200px;min-width:0;margin:0;color:${HELP_DESK_COLORS.muted};font-size:13px;line-height:1.5;overflow-wrap:anywhere}
|
|
25275
|
+
.svhs-error{margin:12px 0 0;color:${HELP_DESK_COLORS.error};font-size:14px;line-height:1.5;overflow-wrap:anywhere}
|
|
25276
|
+
.svhs-status{margin:16px 0;color:${HELP_DESK_COLORS.body};font-size:14px;line-height:1.5}
|
|
24720
25277
|
.svhs-empty{padding:12px 0 4px}
|
|
24721
25278
|
.svhs-empty .svhs-heading{font-size:18px;letter-spacing:-.3px}
|
|
24722
25279
|
.svhs-spinner{width:15px;height:15px;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:svhs-spin .7s linear infinite;flex:none}
|
|
24723
25280
|
@keyframes svhs-spin{to{transform:rotate(360deg)}}
|
|
24724
25281
|
.svhs-article-scroll{padding:34px 48px 28px}
|
|
24725
|
-
.svhs-category{margin:0 0 12px;color:${
|
|
24726
|
-
.svhs-article-title{margin:0 0 18px;color:${
|
|
24727
|
-
.svhs-article-content{color:${
|
|
25282
|
+
.svhs-category{margin:0 0 12px;color:${HELP_DESK_COLORS.muted};font-size:13px;line-height:1.5;overflow-wrap:anywhere}
|
|
25283
|
+
.svhs-article-title{margin:0 0 18px;color:${HELP_DESK_COLORS.ink};font-size:28px;font-weight:600;line-height:1.2;letter-spacing:-.8px;overflow-wrap:anywhere}
|
|
25284
|
+
.svhs-article-content{color:${HELP_DESK_COLORS.body};font-size:15px;line-height:1.65;overflow-wrap:anywhere}
|
|
24728
25285
|
.svhs-article-content>*:first-child{margin-top:0}
|
|
24729
25286
|
.svhs-article-content p{margin:0 0 18px;font:inherit;color:inherit}
|
|
24730
|
-
.svhs-article-content h1,.svhs-article-content h2,.svhs-article-content h3,.svhs-article-content h4,.svhs-article-content h5,.svhs-article-content h6{margin:28px 0 12px;color:${
|
|
25287
|
+
.svhs-article-content h1,.svhs-article-content h2,.svhs-article-content h3,.svhs-article-content h4,.svhs-article-content h5,.svhs-article-content h6{margin:28px 0 12px;color:${HELP_DESK_COLORS.ink};font-size:18px;font-weight:600;line-height:1.35;letter-spacing:-.3px;scroll-margin-top:24px}
|
|
24731
25288
|
.svhs-article-content h3,.svhs-article-content h4,.svhs-article-content h5,.svhs-article-content h6{font-size:16px}
|
|
24732
25289
|
.svhs-article-content ul,.svhs-article-content ol{margin:0 0 22px;padding-left:22px}
|
|
24733
25290
|
.svhs-article-content li{margin:8px 0;padding-left:5px}
|
|
24734
|
-
.svhs-article-content strong{font-weight:600;color:${
|
|
24735
|
-
.svhs-article-content a{color
|
|
25291
|
+
.svhs-article-content strong{font-weight:600;color:${HELP_DESK_COLORS.ink}}
|
|
25292
|
+
.svhs-article-content a{color:${HELP_DESK_ACCENT.ink};text-decoration:underline;text-underline-offset:2px}
|
|
24736
25293
|
.svhs-article-content img,.svhs-article-content video{display:block;max-width:100%;height:auto;margin:20px 0}
|
|
24737
25294
|
.svhs-reader-asset{display:block;max-width:100%;margin:20px 0}
|
|
24738
25295
|
.svhs-reader-asset img{margin:0}
|
|
24739
|
-
.svhs-reader-asset-status{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:4px;min-height:140px;padding:20px;border:1px solid ${
|
|
25296
|
+
.svhs-reader-asset-status{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:4px;min-height:140px;padding:20px;border:1px solid ${HELP_DESK_COLORS.fillStrong};border-radius:6px;background:${HELP_DESK_COLORS.canvas};color:${HELP_DESK_COLORS.muted};font-size:13px;text-align:center}
|
|
24740
25297
|
.svhs-reader-asset-status[style]{min-height:0}
|
|
24741
|
-
.svhs-article-content blockquote{margin:22px 0;padding:0 0 0 16px;border-left:2px solid ${
|
|
24742
|
-
.svhs-article-content pre{margin:20px 0;padding:14px;border:1px solid ${
|
|
25298
|
+
.svhs-article-content blockquote{margin:22px 0;padding:0 0 0 16px;border-left:2px solid ${HELP_DESK_COLORS.lineStrong};font-size:14px}
|
|
25299
|
+
.svhs-article-content pre{margin:20px 0;padding:14px;border:1px solid ${HELP_DESK_COLORS.fillStrong};border-radius:6px;background:${HELP_DESK_COLORS.canvas};overflow:auto;overscroll-behavior:contain;font:13px/1.6 ui-monospace,SFMono-Regular,Consolas,monospace}
|
|
24743
25300
|
.svhs-article-content code{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:.9em}
|
|
24744
25301
|
.svhs-article-content table{display:block;max-width:100%;border-collapse:collapse;overflow:auto;overscroll-behavior:contain;margin:20px 0;font-size:14px}
|
|
24745
|
-
.svhs-article-content th,.svhs-article-content td{padding:10px 12px;border:1px solid ${
|
|
24746
|
-
.svhs-article-content hr{margin:24px 0;border:0;border-top:1px solid ${
|
|
24747
|
-
.svhs-article-footer{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:14px 24px;border-top:1px solid ${
|
|
25302
|
+
.svhs-article-content th,.svhs-article-content td{padding:10px 12px;border:1px solid ${HELP_DESK_COLORS.fillStrong};text-align:left}
|
|
25303
|
+
.svhs-article-content hr{margin:24px 0;border:0;border-top:1px solid ${HELP_DESK_COLORS.fillStrong}}
|
|
25304
|
+
.svhs-article-footer{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:14px 24px;border-top:1px solid ${HELP_DESK_COLORS.fill};flex:none}
|
|
24748
25305
|
.svhs-article-footer .svhs-primary{min-width:110px}
|
|
24749
25306
|
.svhs-article-footer .svhs-text-button{white-space:nowrap;font-size:13px!important}
|
|
24750
|
-
.svhs-article-question{color:${
|
|
25307
|
+
.svhs-article-question{color:${HELP_DESK_COLORS.muted};font-size:13px;line-height:1.5}
|
|
24751
25308
|
.svhs-reader-actions{display:flex;align-items:stretch;gap:12px;flex:none}
|
|
24752
25309
|
.svhs-feedback-scroll{padding-top:30px}
|
|
24753
25310
|
.svhs-feedback-actions{display:flex;flex-direction:column;gap:9px;margin-top:24px}
|
|
24754
|
-
.svhs-feedback-actions .svhs-text-button{align-self:center;color:${
|
|
25311
|
+
.svhs-feedback-actions .svhs-text-button{align-self:center;color:${HELP_DESK_COLORS.muted}}
|
|
24755
25312
|
.svhs-review{margin-top:24px}
|
|
24756
25313
|
.svhs-review .svhs-primary{width:fit-content}
|
|
24757
25314
|
.svhs-contact-scroll{padding:0;scrollbar-gutter:auto}
|
|
@@ -24760,8 +25317,8 @@ function injectHelpDeskSupportStyles() {
|
|
|
24760
25317
|
.svhs-contact-prelude{padding:24px}
|
|
24761
25318
|
.svhs-contact-prelude .svhs-secondary{margin-top:16px}
|
|
24762
25319
|
.svhs-ticket-gate{padding:0 24px 24px}
|
|
24763
|
-
.svhs-unlock-input{display:block;box-sizing:border-box;width:100%;min-height:46px;margin:0 0 16px;border:1px solid ${
|
|
24764
|
-
.svhs-unlock-input:focus{border-color
|
|
25320
|
+
.svhs-unlock-input{display:block;box-sizing:border-box;width:100%;min-height:46px;margin:0 0 16px;border:1px solid ${HELP_DESK_COLORS.lineStrong};border-radius:6px;padding:11px 12px;background:${HELP_DESK_COLORS.field};color:${HELP_DESK_COLORS.ink};font-size:16px!important;line-height:1.5!important}
|
|
25321
|
+
.svhs-unlock-input:focus{border-color:${HELP_DESK_FOCUS}}
|
|
24765
25322
|
.svhs-unlock-form{margin:0}
|
|
24766
25323
|
.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}
|
|
24767
25324
|
.svhs-contact-target .svhd-body{display:flex;flex:1;flex-direction:column;min-height:0}
|
|
@@ -24770,44 +25327,39 @@ function injectHelpDeskSupportStyles() {
|
|
|
24770
25327
|
.svhs-contact-target .svhd-label{font-size:13px;line-height:1.5}
|
|
24771
25328
|
.svhs-contact-target .svhd-input{font-size:16px;line-height:1.5}
|
|
24772
25329
|
.svhs-contact-target .svhd-actions{gap:10px}
|
|
24773
|
-
.svhs-contact-target .svhd-button:not(.svhd-secondary){background:var(--hd-accent,${DS.action});color:var(--hd-on-accent,${DS.white})}
|
|
24774
|
-
.svhs-contact-target .svhd-button:not(.svhd-secondary):hover{background:var(--hd-accent-hover,${DS.actionHover})}
|
|
24775
|
-
.svhs-contact-target .svhd-link{color:var(--hd-accent-ink,${DS.action})}
|
|
24776
25330
|
.svhs-contact-target .svhd-actions>.svhd-button:first-child{flex:1}
|
|
24777
25331
|
.svhs-contact-target .svhd-status{font-size:14px}
|
|
24778
25332
|
.svhs-contact-target .svhd-auth{gap:14px}
|
|
24779
|
-
.svhs-contact-target .svhd-text-button{color:var(--hd-accent-ink,${DS.action})}
|
|
24780
|
-
.svhs-contact-target .svhd-text-button:disabled{color:${DS.slate500}}
|
|
24781
25333
|
.svhs-contact-target .svhd-widget-form{display:flex;flex:1;flex-direction:column;gap:16px}
|
|
24782
25334
|
/* The request fills the panel: the details step, and in it the composer and its text, take the height the fields leave. */
|
|
24783
25335
|
.svhs-contact-target .svhd-widget-form>[data-contact-step=details]{display:flex;flex:1;flex-direction:column;gap:16px}
|
|
24784
25336
|
.svhs-contact-target .svhd-widget-form .svhd-composer-field{display:flex;flex:1;flex-direction:column;gap:6px;min-height:164px}
|
|
24785
25337
|
.svhs-contact-target .svhd-widget-form .svhd-composer{flex:1}
|
|
24786
25338
|
.svhs-contact-target .svhd-widget-form .svhd-composer-input{flex:1;min-height:120px}
|
|
24787
|
-
.svhs-contact-target .svhd-widget-form>.svhd-actions{position:sticky;bottom:0;z-index:1;margin:auto -24px 0;padding:16px 24px 0;border-top:1px solid ${
|
|
25339
|
+
.svhs-contact-target .svhd-widget-form>.svhd-actions{position:sticky;bottom:0;z-index:1;margin:auto -24px 0;padding:16px 24px 0;border-top:1px solid ${HELP_DESK_COLORS.fill};background:${HELP_DESK_COLORS.surface}}
|
|
24788
25340
|
.svhs-contact-target .svhd-widget-form>.svhd-actions>.svhd-secondary{display:none}
|
|
24789
25341
|
.svhs-contact-target .svhd-widget-form .svhd-actions>.svhd-button{font-size:14px}
|
|
24790
|
-
.svhs-contact-target .svhd-widget-form>.svhd-confirm{position:sticky;bottom:-24px;z-index:2;margin:0 -24px -24px;padding:16px 24px 24px;border-top:1px solid ${
|
|
25342
|
+
.svhs-contact-target .svhd-widget-form>.svhd-confirm{position:sticky;bottom:-24px;z-index:2;margin:0 -24px -24px;padding:16px 24px 24px;border-top:1px solid ${HELP_DESK_COLORS.fillStrong};background:${HELP_DESK_COLORS.surface}}
|
|
24791
25343
|
.svhs-contact-target .svhd-widget-form>.svhd-confirm .svhd-actions{flex-wrap:nowrap}
|
|
24792
25344
|
.svhs-contact-target .svhd-widget-form>.svhd-confirm .svhd-button{flex:1}
|
|
24793
25345
|
.svhs-contact-target .svhd-footer{margin-top:16px;text-align:center;font-size:11px}
|
|
24794
25346
|
.svhs-receipt-scroll{padding-top:36px}
|
|
24795
|
-
.svhs-receipt-mark{width:30px!important;height:30px!important;margin-bottom:20px;color
|
|
24796
|
-
.svhs-ticket-link{display:inline-flex;align-items:center;min-height:44px;margin:0 0 10px;color
|
|
25347
|
+
.svhs-receipt-mark{width:30px!important;height:30px!important;margin-bottom:20px;color:${HELP_DESK_ACCENT.ink}}
|
|
25348
|
+
.svhs-ticket-link{display:inline-flex;align-items:center;min-height:44px;margin:0 0 10px;color:${HELP_DESK_ACCENT.ink};font-size:14px;font-weight:600;text-decoration:underline}
|
|
24797
25349
|
.svhs-receipt-note{white-space:pre-wrap;overflow-wrap:anywhere}
|
|
24798
25350
|
.svhs-receipt-actions{display:flex;flex-direction:column;align-items:center;gap:4px}
|
|
24799
25351
|
.svhs-toast{box-sizing:border-box;position:fixed;right:24px;bottom:calc(96px + var(--svhs-toast-offset,0px) + env(safe-area-inset-bottom));z-index:2147482901;display:flex;align-items:center;gap:10px;max-width:calc(100vw - 36px);padding:14px 18px;border:1px solid transparent;border-radius:8px;background:${DS.slate900};color:${DS.white};box-shadow:${DS.shadowPopover};font:400 14px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',sans-serif;overflow-wrap:anywhere}
|
|
24800
25352
|
.svhs-toast svg{width:18px;height:18px;flex:none;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
|
|
24801
|
-
.svhs-overlay{position:fixed;inset:0;z-index:2147482900;display:flex;background:${
|
|
25353
|
+
.svhs-overlay{position:fixed;inset:0;z-index:2147482900;display:flex;background:${HELP_DESK_COLORS.surface};padding:0;overflow:hidden}
|
|
24802
25354
|
.svhs-modal{width:100%;height:100%;min-width:0;outline:none}
|
|
24803
25355
|
.svhs-overlay .svhs-panel{position:relative;inset:auto;width:100%;height:100%;max-width:none;max-height:none;border:0;border-radius:0;box-shadow:none;padding-top:env(safe-area-inset-top);transition:none}
|
|
24804
|
-
.sv-support-launcher{touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition:background 120ms cubic-bezier(.2,0,0,1)}
|
|
25356
|
+
.sv-support-launcher{touch-action:manipulation;-webkit-tap-highlight-color:transparent;transition:background 120ms cubic-bezier(.2,0,0,1);box-shadow:${DS.shadowPopover};${DEFAULT_PAIRING_DECLARATIONS}}
|
|
24805
25357
|
.sv-support-launcher:hover{filter:brightness(1.12)}
|
|
24806
25358
|
.sv-support-launcher:active{transform:translateY(1px)}
|
|
24807
|
-
.sv-support-launcher:focus-visible{outline:3px solid
|
|
25359
|
+
.sv-support-launcher:focus-visible{outline:3px solid ${HELP_DESK_FOCUS};outline-offset:4px;box-shadow:${LAUNCHER_RING},${DS.shadowPopover}}
|
|
24808
25360
|
@media(max-width:640px){
|
|
24809
25361
|
.svhs-panel{right:0;bottom:0;width:100%;height:100dvh;max-width:none;max-height:none;border:0;border-radius:0}
|
|
24810
|
-
.svhs-toolbar{min-height:60px;padding:8px 16px 8px 24px;border-bottom-color:${
|
|
25362
|
+
.svhs-toolbar{min-height:60px;padding:8px 16px 8px 24px;border-bottom-color:${HELP_DESK_COLORS.fillStrong}}
|
|
24811
25363
|
.svhs-icon-button{width:44px;height:44px}
|
|
24812
25364
|
.svhs-back{min-height:44px;max-width:42%}
|
|
24813
25365
|
.svhs-scroll{padding:24px}
|
|
@@ -24839,7 +25391,7 @@ function injectHelpDeskSupportStyles() {
|
|
|
24839
25391
|
@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}}
|
|
24840
25392
|
@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}}
|
|
24841
25393
|
@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}}
|
|
24842
|
-
.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 ${
|
|
25394
|
+
.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 ${HELP_DESK_COLORS.fillStrong};border-radius:12px;box-shadow:none;transition:none}
|
|
24843
25395
|
.svhs-page .svhs-toolbar{min-height:52px;padding:4px 24px}
|
|
24844
25396
|
.svhs-page .svhs-back{max-width:none;white-space:nowrap}
|
|
24845
25397
|
.svhs-page .svhs-desk-name{display:none}
|
|
@@ -25036,35 +25588,6 @@ class SupportPhoneHistory {
|
|
|
25036
25588
|
}
|
|
25037
25589
|
}
|
|
25038
25590
|
|
|
25039
|
-
/** Darken only the narrow range where neither white nor the product ink reaches AA. */
|
|
25040
|
-
function accessibleFill(color) {
|
|
25041
|
-
let fill = color;
|
|
25042
|
-
while ((accentFillContrast(fill) ?? 0) < AA_TEXT_CONTRAST) {
|
|
25043
|
-
fill = `#${[1, 3, 5].map(offset => Math.floor(Number.parseInt(fill.slice(offset, offset + 2), 16) * 0.98).toString(16).padStart(2, '0')).join('')}`;
|
|
25044
|
-
}
|
|
25045
|
-
return fill;
|
|
25046
|
-
}
|
|
25047
|
-
/** Scoped brand properties work in both a hosted page and an unrelated widget host. */
|
|
25048
|
-
function applySupportBrand(target, value) {
|
|
25049
|
-
const color = brandColor(value);
|
|
25050
|
-
if (!color) {
|
|
25051
|
-
for (const name of ['--hd-accent', '--hd-on-accent', '--hd-accent-ink', '--hd-accent-hover', '--hd-focus'])
|
|
25052
|
-
target.style.removeProperty(name);
|
|
25053
|
-
return;
|
|
25054
|
-
}
|
|
25055
|
-
const fill = accessibleFill(color);
|
|
25056
|
-
const pairing = accentPairing(fill);
|
|
25057
|
-
const ink = pairing.accentInk === 'accent' ? fill : DS.slate900;
|
|
25058
|
-
const label = pairing.onAccent === 'white' ? DS.white : DS.slate900;
|
|
25059
|
-
// Dark fills deepen on hover; light fills stay unchanged to preserve label contrast.
|
|
25060
|
-
const hover = pairing.onAccent === 'white'
|
|
25061
|
-
? `#${[1, 3, 5].map(offset => Math.floor(Number.parseInt(fill.slice(offset, offset + 2), 16) * 0.9).toString(16).padStart(2, '0')).join('')}`
|
|
25062
|
-
: fill;
|
|
25063
|
-
const properties = { '--hd-accent': fill, '--hd-on-accent': label, '--hd-accent-ink': ink, '--hd-accent-hover': hover, '--hd-focus': ink };
|
|
25064
|
-
for (const [name, content] of Object.entries(properties))
|
|
25065
|
-
target.style.setProperty(name, content);
|
|
25066
|
-
}
|
|
25067
|
-
|
|
25068
25591
|
/* global MediaQueryList, HTMLImageElement, HTMLAnchorElement, Element */
|
|
25069
25592
|
let sequence = 0;
|
|
25070
25593
|
function element(tag, className, text) {
|
|
@@ -25351,7 +25874,8 @@ class SupportView {
|
|
|
25351
25874
|
if (previous)
|
|
25352
25875
|
this.saveScroll(previous);
|
|
25353
25876
|
this.state = next;
|
|
25354
|
-
|
|
25877
|
+
if (next.brand !== previous?.brand)
|
|
25878
|
+
applySupportBrand(this.panel, next.brand);
|
|
25355
25879
|
this.panel.dataset.stage = next.stage;
|
|
25356
25880
|
const inset = (value, fallback) => typeof value === 'number' && Number.isFinite(value) ? Math.min(480, Math.max(0, value)) : fallback;
|
|
25357
25881
|
this.panel.style.setProperty('--svhs-right', `${inset(next.position?.right, 24)}px`);
|
|
@@ -26054,7 +26578,11 @@ function createHelpDeskSupport(config, options) {
|
|
|
26054
26578
|
let sourceArticleId;
|
|
26055
26579
|
const lifetime = new AbortController();
|
|
26056
26580
|
const bindings = new Set();
|
|
26057
|
-
|
|
26581
|
+
// A desk the page already holds brands the journey from the start, the
|
|
26582
|
+
// launcher included. Any other desk's brand arrives with connect, which the
|
|
26583
|
+
// first open, search or contact makes, never creation: connecting here would
|
|
26584
|
+
// add a desk lookup to every page load of a website that shows the launcher.
|
|
26585
|
+
let state = { visible: false, stage: 'issue', deskName: 'Support', issue: '', brand: supportBrand(options.desk?.branding?.color) };
|
|
26058
26586
|
if (typeof options.launcher === 'object') {
|
|
26059
26587
|
const offset = (value, fallback) => typeof value === 'number' && Number.isFinite(value) ? Math.min(240, Math.max(12, value)) : fallback;
|
|
26060
26588
|
state.position = { right: offset(options.launcher.right, 24), bottom: offset(options.launcher.bottom, 24) + 72 };
|
|
@@ -26128,7 +26656,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
26128
26656
|
}, options.target === undefined ? undefined : resolveTarget(options.target));
|
|
26129
26657
|
const launcher = (() => {
|
|
26130
26658
|
try {
|
|
26131
|
-
return options.launcher ? createSupportLauncher(typeof options.launcher === 'object' ? options.launcher : {}, () => { void open(); }) : null;
|
|
26659
|
+
return options.launcher ? createSupportLauncher(typeof options.launcher === 'object' ? options.launcher : {}, state.brand, () => { void open(); }) : null;
|
|
26132
26660
|
}
|
|
26133
26661
|
catch (error) {
|
|
26134
26662
|
view.destroy();
|
|
@@ -26139,9 +26667,12 @@ function createHelpDeskSupport(config, options) {
|
|
|
26139
26667
|
function update(change) {
|
|
26140
26668
|
if (destroyed)
|
|
26141
26669
|
return;
|
|
26670
|
+
const rebranded = change.brand !== undefined && change.brand !== state.brand;
|
|
26142
26671
|
state = { ...state, ...change };
|
|
26143
26672
|
view.render(state);
|
|
26144
26673
|
launcher?.setExpanded(state.visible);
|
|
26674
|
+
if (rebranded)
|
|
26675
|
+
launcher?.setBrand(state.brand);
|
|
26145
26676
|
notify(options.onStateChange, snapshot());
|
|
26146
26677
|
}
|
|
26147
26678
|
async function connect() {
|
|
@@ -26168,7 +26699,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
26168
26699
|
return (await http.request(path, { method: 'POST', body, credentials: 'omit', headers: { 'X-SV-Client': 'help-desk-portal', ...headers } })).data;
|
|
26169
26700
|
},
|
|
26170
26701
|
});
|
|
26171
|
-
update({ deskName: answer.desk.organization_name || 'Support',
|
|
26702
|
+
update({ deskName: answer.desk.organization_name || 'Support', brand: brandFor(answer.desk.branding?.color, state.brand), contactNote: answer.desk.ticket_contact_note ?? undefined });
|
|
26172
26703
|
return answer;
|
|
26173
26704
|
}).catch((error) => { connected = null; throw error; });
|
|
26174
26705
|
return connected;
|
|
@@ -26559,6 +27090,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
26559
27090
|
persist: options.persist,
|
|
26560
27091
|
pageLayout: options.target !== undefined,
|
|
26561
27092
|
hostShowsAttribution: options.hostShowsAttribution === true,
|
|
27093
|
+
brand: state.brand,
|
|
26562
27094
|
onSession: (session) => {
|
|
26563
27095
|
anonymous = false;
|
|
26564
27096
|
if (options.persist)
|
|
@@ -26801,7 +27333,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
26801
27333
|
sourceArticleId = undefined;
|
|
26802
27334
|
}
|
|
26803
27335
|
/**
|
|
26804
|
-
* Switch account from the contact form:
|
|
27336
|
+
* Switch account from the contact form: the window's chooser opens in this
|
|
26805
27337
|
* gesture, the current session staying current until another account's is
|
|
26806
27338
|
* redeemed. A window that closes or fails rejects, nothing changed, for the
|
|
26807
27339
|
* form to say so; a redeemed session takes the old one's place.
|
|
@@ -26991,7 +27523,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
26991
27523
|
client?.clearTicketAccess();
|
|
26992
27524
|
client?.setSession(null);
|
|
26993
27525
|
client = null;
|
|
26994
|
-
state = { visible: false, stage: 'issue', deskName: 'Support', issue: '' };
|
|
27526
|
+
state = { visible: false, stage: 'issue', deskName: 'Support', issue: '', brand: state.brand };
|
|
26995
27527
|
},
|
|
26996
27528
|
};
|
|
26997
27529
|
}
|
|
@@ -31760,7 +32292,7 @@ class SparkVault {
|
|
|
31760
32292
|
}
|
|
31761
32293
|
/** Get the SDK version */
|
|
31762
32294
|
static get version() {
|
|
31763
|
-
return '
|
|
32295
|
+
return '18.0.1';
|
|
31764
32296
|
}
|
|
31765
32297
|
}
|
|
31766
32298
|
if (typeof window !== 'undefined') {
|