@sparkvault/sdk-js 18.0.3 → 18.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -14949,6 +14949,21 @@ const HELP_DESK_WIDGET_IDENTITY_MESSAGES = Object.freeze({
14949
14949
  result: 'sparkvault:help-desk:identity'
14950
14950
  });
14951
14951
 
14952
+ /**
14953
+ * The one rule labelling a requester on a ticket's timeline, for every
14954
+ * audience, and in the console's inbox: the name they gave the desk, else
14955
+ * their address; null when it holds neither (an erased requester). An empty
14956
+ * name is no name, so their address stands in for it. Core's timeline
14957
+ * labels (help-desk/events.js) and the console's inbox (inbox/labels.js)
14958
+ * both read it.
14959
+ *
14960
+ * @param {{ display_name?: string|null, email?: string|null }|null|undefined} requester
14961
+ * @returns {string|null}
14962
+ */
14963
+ function requesterNameOrAddress(requester) {
14964
+ return requester?.display_name || requester?.email || null;
14965
+ }
14966
+
14952
14967
  /**
14953
14968
  * Mail local parts no queue may take as its alias: the role mailboxes RFC 2142
14954
14969
  * names, the addresses mail systems and their operators keep for themselves,
@@ -19558,6 +19573,8 @@ const HELP_DESK_COLORS = Object.freeze({
19558
19573
  fillStrong: `var(--hd-fill-strong,${LIGHT['--color-slate-200']})`,
19559
19574
  /** A field's and a secondary action's edge. */
19560
19575
  lineStrong: `var(--hd-line-strong,${LIGHT['--color-slate-300']})`,
19576
+ /** A modal's scrim stays dark in either scheme; the alpha belongs to the surface. */
19577
+ modalBackdrop: `var(--hd-modal-backdrop,${LIGHT['--ink']})`,
19561
19578
  ink: `var(--hd-ink,${LIGHT['--ink']})`,
19562
19579
  body: `var(--hd-text-body,${LIGHT['--text-body']})`,
19563
19580
  muted: `var(--hd-text-muted,${LIGHT['--text-muted']})`,
@@ -19697,7 +19714,6 @@ function injectHelpDeskFormStyles() {
19697
19714
  .svhd-hint{font-size:13px;color:${HELP_DESK_COLORS.body};margin:0}
19698
19715
  .svhd-step{display:grid;gap:16px;min-width:0}
19699
19716
  .svhd-step-head{display:grid;gap:4px;margin-bottom:4px}
19700
- .svhd-step-label{margin:0;font-size:13px;font-weight:600;line-height:1.4;color:${HELP_DESK_COLORS.body}}
19701
19717
  .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}
19702
19718
  .svhd-text-button:not(:disabled):hover{text-decoration-thickness:2px}
19703
19719
  .svhd-text-button:focus-visible{outline:3px solid ${HELP_DESK_FOCUS};outline-offset:2px}
@@ -20246,7 +20262,7 @@ function acceptedKindsCopy(kinds) {
20246
20262
  /**
20247
20263
  * The files a ticket accepts, in the one phrase every surface names them by,
20248
20264
  * built from the policy's own list (ACCEPTED_ATTACHMENT_KINDS): the help desk
20249
- * composer's (?) tip reads it, and so do the API reference
20265
+ * composer's refusal dialog reads it, and so do the API reference
20250
20266
  * (apps/api/openapi/overlay.mjs) and the help desk's page on the site
20251
20267
  * (apps/www/_data/helpDeskAttachments.js). A refused file's sentence names
20252
20268
  * only that its type can't be attached.
@@ -20254,10 +20270,9 @@ function acceptedKindsCopy(kinds) {
20254
20270
  const ACCEPTED_ATTACHMENTS_COPY = acceptedKindsCopy(ACCEPTED_ATTACHMENT_KINDS);
20255
20271
 
20256
20272
  /**
20257
- * What a customer's file picker says before any file is chosen: what to add,
20258
- * how many files a message takes and how large each may be. The help desk
20259
- * composer's (?) tip after its Attach button says it, and it describes
20260
- * Attach.
20273
+ * The attachment rules shown after a refusal: what to add, how many files a
20274
+ * message takes and how large each may be. The help desk composer's
20275
+ * validation dialog reads this without adding prose to accepted uploads.
20261
20276
  */
20262
20277
  const CUSTOMER_ATTACHMENTS_HINT =
20263
20278
  `Add screenshots, documents or recordings. Up to ${MAX_ATTACHMENTS_PER_MESSAGE} files, ${formatBytes(CUSTOMER_ATTACHMENT_MAX_BYTES)} each.`;
@@ -20331,6 +20346,386 @@ function refusalCopy(refusal, maxBytes) {
20331
20346
  return REFUSAL_COPY[refusal] ?? "This file can't be attached.";
20332
20347
  }
20333
20348
 
20349
+ /**
20350
+ * Strict single-value media type (MIME) parsing.
20351
+ *
20352
+ * The one parser for a stored ingot or spark `content_type`: Core validates
20353
+ * every ingested value with it, Forge derives both the served Content-Type and
20354
+ * the inline-render decision from it, the display rules the web console and
20355
+ * the x.sv pages share (display-content-type.js), the Spark payload rule
20356
+ * (`isTextMediaType`) and the server's registry readings (media-type-node.js)
20357
+ * read the essence through it, so no two readers can disagree about what a
20358
+ * value means. A page that cannot import an ES module runs this module's own
20359
+ * source (MEDIA_TYPE_SCRIPT).
20360
+ *
20361
+ * Grammar (RFC 9110 §8.3.1): `type "/" subtype *( OWS ";" OWS [ parameter ] )`
20362
+ * where type, subtype and parameter names are tokens and parameter values are
20363
+ * tokens or quoted-strings, ASCII only. One deliberate tightening: a comma
20364
+ * anywhere rejects the value. Browsers read Content-Type as a comma-separated
20365
+ * list and keep the LAST valid type (WHATWG Fetch "extract a MIME type"), so a
20366
+ * value that this parser would classify by its first type can render in a
20367
+ * browser as another: `image/png, text/html` executes as HTML.
20368
+ *
20369
+ * BROWSER-SAFE: pure string handling, no Node built-ins.
20370
+ */
20371
+
20372
+ /** Longest accepted value; RFC 6838 caps type and subtype at 127 chars each. */
20373
+ const MAX_MEDIA_TYPE_LENGTH = 255;
20374
+ const TOKEN_CHAR = /[!#$%&'*+.^_`|~0-9A-Za-z-]/;
20375
+ /** qdtext: HTAB, SP and visible ASCII except `"` and backslash. */
20376
+ const QUOTED_TEXT_CHAR = /[\t\x20\x21\x23-\x5b\x5d-\x7e]/;
20377
+ /** The character after the backslash of a quoted-pair: HTAB, SP or visible ASCII. */
20378
+ const QUOTED_PAIR_CHAR = /[\t\x20-\x7e]/;
20379
+
20380
+ /** Index just past the token starting at `start` (=== start when there is none). */
20381
+ function tokenEnd(value, start) {
20382
+ let end = start;
20383
+ while (end < value.length && TOKEN_CHAR.test(value[end])) end += 1;
20384
+ return end;
20385
+ }
20386
+
20387
+ /** Index just past the optional whitespace (SP / HTAB) starting at `start`. */
20388
+ function owsEnd(value, start) {
20389
+ let end = start;
20390
+ while (value[end] === ' ' || value[end] === '\t') end += 1;
20391
+ return end;
20392
+ }
20393
+
20394
+ /**
20395
+ * Read the quoted-string whose opening quote is at `start`.
20396
+ * @returns {{end: number, text: string} | null} The index past the closing
20397
+ * quote and the unescaped content; null when malformed or unterminated.
20398
+ */
20399
+ function readQuotedString(value, start) {
20400
+ let text = '';
20401
+ let index = start + 1;
20402
+ while (index < value.length) {
20403
+ const char = value[index];
20404
+ if (char === '"') return { end: index + 1, text };
20405
+ if (char === '\\') {
20406
+ const escaped = value[index + 1];
20407
+ if (escaped === undefined || !QUOTED_PAIR_CHAR.test(escaped)) return null;
20408
+ text += escaped;
20409
+ index += 2;
20410
+ } else if (QUOTED_TEXT_CHAR.test(char)) {
20411
+ text += char;
20412
+ index += 1;
20413
+ } else {
20414
+ return null;
20415
+ }
20416
+ }
20417
+ return null;
20418
+ }
20419
+
20420
+ /**
20421
+ * Parse one media type value.
20422
+ *
20423
+ * A single left-to-right scan: every character is examined a bounded number
20424
+ * of times, so the cost is linear in the (already length-capped) input. Core
20425
+ * runs this on untrusted request bodies, where a backtracking grammar would
20426
+ * let one crafted value stall the process.
20427
+ *
20428
+ * @param {unknown} value - A stored or submitted content type
20429
+ * @returns {{
20430
+ * type: string,
20431
+ * subtype: string,
20432
+ * essence: string,
20433
+ * parameters: Map<string, string>
20434
+ * } | null} Lowercased type/subtype/essence and parameter names, unquoted
20435
+ * parameter values (the first occurrence of a name wins); null when the
20436
+ * value is not exactly one well-formed media type.
20437
+ */
20438
+ function parseMediaType(value) {
20439
+ if (typeof value !== 'string' || value.length > MAX_MEDIA_TYPE_LENGTH || value.includes(',')) {
20440
+ return null;
20441
+ }
20442
+
20443
+ const typeEnd = tokenEnd(value, 0);
20444
+ if (typeEnd === 0 || value[typeEnd] !== '/') return null;
20445
+ const subtypeEnd = tokenEnd(value, typeEnd + 1);
20446
+ if (subtypeEnd === typeEnd + 1) return null;
20447
+
20448
+ const type = value.slice(0, typeEnd).toLowerCase();
20449
+ const subtype = value.slice(typeEnd + 1, subtypeEnd).toLowerCase();
20450
+ const parameters = new Map();
20451
+
20452
+ // parameters = *( OWS ";" OWS [ parameter ] )
20453
+ let index = subtypeEnd;
20454
+ while (index < value.length) {
20455
+ index = owsEnd(value, index);
20456
+ if (value[index] !== ';') return null;
20457
+ index = owsEnd(value, index + 1);
20458
+ if (index === value.length || value[index] === ';') continue; // empty slot
20459
+
20460
+ const nameEnd = tokenEnd(value, index);
20461
+ if (nameEnd === index || value[nameEnd] !== '=') return null;
20462
+ const name = value.slice(index, nameEnd).toLowerCase();
20463
+
20464
+ let parameterValue;
20465
+ if (value[nameEnd + 1] === '"') {
20466
+ const quoted = readQuotedString(value, nameEnd + 1);
20467
+ if (!quoted) return null;
20468
+ parameterValue = quoted.text;
20469
+ index = quoted.end;
20470
+ } else {
20471
+ const valueEnd = tokenEnd(value, nameEnd + 1);
20472
+ if (valueEnd === nameEnd + 1) return null;
20473
+ parameterValue = value.slice(nameEnd + 1, valueEnd);
20474
+ index = valueEnd;
20475
+ }
20476
+
20477
+ if (!parameters.has(name)) parameters.set(name, parameterValue);
20478
+ }
20479
+
20480
+ return { type, subtype, essence: `${type}/${subtype}`, parameters };
20481
+ }
20482
+
20483
+ /**
20484
+ * The essence of a content type: its lowercased `type/subtype`, parameters
20485
+ * dropped (`application/json` of `Application/JSON; charset=utf-8`). An exact
20486
+ * type filter matches an ingot on it.
20487
+ *
20488
+ * The x.sv page runs this function's source (MEDIA_TYPE_SCRIPT), so it keeps
20489
+ * to the ECMAScript 2018 the page parses as (docs/GOTCHAS.md).
20490
+ *
20491
+ * @param {unknown} value
20492
+ * @returns {string|null} null when the value is not exactly one well-formed
20493
+ * media type
20494
+ */
20495
+ function mediaTypeEssence(value) {
20496
+ const mediaType = parseMediaType(value);
20497
+ return mediaType === null ? null : mediaType.essence;
20498
+ }
20499
+
20500
+ /**
20501
+ * Sound formats platforms type outside the audio tree, each an essence: the
20502
+ * Ogg container, as Firefox types every `.ogg` file (any other platform's
20503
+ * audio/ogg), and WMA as Chrome on macOS types a `.wma` file (Firefox's
20504
+ * audio/x-ms-wma). Each is filed with the audio (mediaTypeFamily), and is
20505
+ * the audio kind's (./ingot-kind.js), so a file's icon and the type filter
20506
+ * that lists it agree.
20507
+ */
20508
+ const SOUND_TYPES_OUTSIDE_AUDIO = Object.freeze(['application/ogg', 'video/x-ms-wma']);
20509
+
20510
+ new Set(SOUND_TYPES_OUTSIDE_AUDIO);
20511
+
20512
+ /**
20513
+ * Content-type policy for vault and spark bytes a browser page displays or
20514
+ * saves.
20515
+ *
20516
+ * Every display blob becomes a blob: URL in the displaying page's own origin,
20517
+ * and a viewer can open one as a top-level document ("Open image in new tab",
20518
+ * dragging a thumbnail to the tab bar). A stored content_type is caller-supplied
20519
+ * (the public upload portal and any spark creator included), so a blob typed
20520
+ * image/svg+xml, text/html or any XML type would run that caller's script as
20521
+ * the page. Only types every browser renders inertly may therefore reach one,
20522
+ * decided by allowlist so an unknown or malformed type fails closed: the
20523
+ * essence is read by the platform's one media-type parser, and a declared value
20524
+ * that is not exactly one well-formed media type matches no entry.
20525
+ *
20526
+ * A save hands the browser a blob too, and a browser renames a saved copy by
20527
+ * the blob's type, by its own MIME table, refused extensions included:
20528
+ * Firefox saves `Invoice` handed as `application/x-javascript` as
20529
+ * `Invoice.js`, and `Invoice.pdf` handed as `image/svg+xml` as `Invoice.svg`,
20530
+ * and Chromium completes a name that has no extension from a blob's type
20531
+ * alike. Neither completes or replaces an extension by the type of a name
20532
+ * handed as application/octet-stream (docs/GOTCHAS.md). The name a file
20533
+ * saves under is completed by the MIME registry, which only the server
20534
+ * carries (Core answers it as `download_filename`, by ./media-type-node.js
20535
+ * downloadFilename), so a save hands the browser the display-safe type as
20536
+ * well: an inert type keeps its own, from which a browser completes a name
20537
+ * the registry left bare (`Recording` under `audio/flac` saves as
20538
+ * `Recording.flac`), and every other type goes as opaque bytes.
20539
+ *
20540
+ * The one rule for every surface that does this: the web console consumes these
20541
+ * functions directly (its file display path retypes through withDisplaySafeType,
20542
+ * as the one blob save does, saveBlob in ./browser-download.js), the x.sv pages
20543
+ * run this module's own source (DISPLAY_CONTENT_TYPE_SCRIPT), and Forge serves a
20544
+ * response inline on its own origin only when isInertDocumentType says so
20545
+ * (apps/forge/src/routes/decrypt.js). Forge and every client save hand an
20546
+ * inert type to the browser under its own type whatever the file's name, since
20547
+ * a browser renames a download by the type it is handed: an inert type is an
20548
+ * image, audio, video or PDF format, so whatever extension a browser gives its
20549
+ * copy opens it as what it is.
20550
+ *
20551
+ * BROWSER-SAFE: string handling and the platform's Blob, no Node built-ins.
20552
+ */
20553
+
20554
+ /**
20555
+ * Raster formats: decoded as pixels by <img>, never parsed as a document that
20556
+ * could carry script. HEIC/HEIF stay listed for the case where on-the-fly JPEG
20557
+ * conversion fails and the original bytes are shown as-is.
20558
+ */
20559
+ const INERT_IMAGE_TYPES = Object.freeze([
20560
+ 'image/jpeg',
20561
+ 'image/jpg',
20562
+ 'image/pjpeg',
20563
+ 'image/png',
20564
+ 'image/x-png',
20565
+ 'image/apng',
20566
+ 'image/gif',
20567
+ 'image/webp',
20568
+ 'image/avif',
20569
+ 'image/jxl',
20570
+ 'image/bmp',
20571
+ 'image/x-ms-bmp',
20572
+ 'image/x-icon',
20573
+ 'image/vnd.microsoft.icon',
20574
+ 'image/tiff',
20575
+ 'image/heic',
20576
+ 'image/heif'
20577
+ ]);
20578
+
20579
+ new Set(INERT_IMAGE_TYPES);
20580
+
20581
+ /**
20582
+ * The platform's one essence reader (./media-type.js), bound in this module's
20583
+ * own scope. The functions DISPLAY_CONTENT_TYPE_SCRIPT carries read it by this
20584
+ * name, which the page binds to the reader MEDIA_TYPE_SCRIPT declares, never
20585
+ * by its imported name: a module transform rewrites an imported name inside a
20586
+ * function's source (vitest's, which every suite runs this module under, turns
20587
+ * `mediaTypeEssence` into `__vite_ssr_import_0__.mediaTypeEssence`), a name no
20588
+ * page declares.
20589
+ */
20590
+ const essenceOf = mediaTypeEssence;
20591
+
20592
+ /*
20593
+ * Audio and video formats, each under the types the MIME registry files it
20594
+ * under and the ones browsers and Apple's platforms report for it
20595
+ * (`audio/flac`, `audio/vnd.wave`, `audio/aiff`, Chromium's `video/matroska`
20596
+ * and `audio/matroska`, Firefox's `application/ogg` for a `.ogg` file, and,
20597
+ * where Chromium asks the platform: on macOS `video/avi` for a `.avi` file,
20598
+ * `video/x-ms-wma` for a `.wma` one and `audio/x-m4r` for an iPhone ringtone,
20599
+ * and on Windows `audio/vnd.dlna.adts` for a `.aac` one):
20600
+ * encoded sound and pictures, which a browser plays in its own player, never
20601
+ * as a scriptable document, or downloads under the extension its table names
20602
+ * for the type (`.mp3`, `.mov`, `.avi`, `.ogg`), which a desktop opens in a
20603
+ * media player.
20604
+ *
20605
+ * Never a playlist or a stream redirector (`audio/x-mpegurl`,
20606
+ * `audio/x-scpls`, `video/x-ms-asx`, `audio/x-pn-realaudio`): it names media
20607
+ * a player then fetches, and a browser downloads it whatever name it is
20608
+ * handed, saving it as `.m3u`, `.pls`, `.asx` (which Outlook blocks) or
20609
+ * `.ram`; nor `video/x-ms-asf`, under which the registry files the `.asx`
20610
+ * redirector too. An allowlist, so an audio or video type no entry names
20611
+ * fails closed, one with a structured-syntax suffix among them (`video/x+xml`,
20612
+ * which a navigated browser renders as an XML document, script included).
20613
+ */
20614
+
20615
+ /** The audio formats: sound, which a browser plays in its player. */
20616
+ const INERT_AUDIO_TYPES = Object.freeze([
20617
+ 'audio/3gpp',
20618
+ 'audio/aac',
20619
+ 'audio/x-aac',
20620
+ 'audio/vnd.dlna.adts',
20621
+ 'audio/aiff',
20622
+ 'audio/x-aiff',
20623
+ 'audio/amr',
20624
+ 'audio/basic',
20625
+ 'audio/flac',
20626
+ 'audio/x-flac',
20627
+ 'audio/matroska',
20628
+ 'audio/x-matroska',
20629
+ 'audio/midi',
20630
+ 'audio/mp3',
20631
+ 'audio/mpeg',
20632
+ 'audio/mp4',
20633
+ 'audio/x-m4a',
20634
+ 'audio/x-m4r',
20635
+ 'audio/ogg',
20636
+ 'audio/wav',
20637
+ 'audio/wave',
20638
+ 'audio/vnd.wave',
20639
+ 'audio/x-wav',
20640
+ 'audio/webm',
20641
+ 'audio/x-caf',
20642
+ 'audio/x-ms-wma',
20643
+ 'video/x-ms-wma'
20644
+ ]);
20645
+
20646
+ /**
20647
+ * The Ogg container, as Firefox types a `.ogg` file: the one inert type that
20648
+ * does not say whether its files hold sound alone or pictures too. It renders
20649
+ * as a video, whose player plays either.
20650
+ */
20651
+ const OGG_CONTAINER_TYPE = 'application/ogg';
20652
+
20653
+ /**
20654
+ * The video formats: pictures and sound, which a browser plays in its player,
20655
+ * the Ogg container among them (OGG_CONTAINER_TYPE).
20656
+ */
20657
+ const INERT_VIDEO_TYPES = Object.freeze([
20658
+ 'video/3gpp',
20659
+ 'video/3gpp2',
20660
+ 'video/matroska',
20661
+ 'video/x-matroska',
20662
+ 'video/mp2t',
20663
+ 'video/mp4',
20664
+ 'video/x-m4v',
20665
+ 'video/mpeg',
20666
+ 'video/ogg',
20667
+ OGG_CONTAINER_TYPE,
20668
+ 'video/quicktime',
20669
+ 'video/webm',
20670
+ 'video/x-flv',
20671
+ 'video/x-msvideo',
20672
+ 'video/avi',
20673
+ 'video/x-ms-wmv'
20674
+ ]);
20675
+
20676
+ const PDF_TYPE = 'application/pdf';
20677
+
20678
+ /**
20679
+ * How each inert type renders as a top-level document, by essence
20680
+ * (inertRendering). The x.sv pages read it through
20681
+ * DISPLAY_CONTENT_TYPE_SCRIPT, which serializes it.
20682
+ */
20683
+ const INERT_RENDERING = new Map([
20684
+ ...INERT_IMAGE_TYPES.map((type) => [type, 'image']),
20685
+ ...INERT_AUDIO_TYPES.map((type) => [type, 'audio']),
20686
+ ...INERT_VIDEO_TYPES.map((type) => [type, 'video']),
20687
+ [PDF_TYPE, 'pdf']
20688
+ ]);
20689
+
20690
+ /**
20691
+ * Every type a browser renders inertly as a top-level document, as an essence:
20692
+ * a raster image (INERT_IMAGE_TYPES), an audio or video format, or a PDF,
20693
+ * which the browser's own PDF viewer renders.
20694
+ */
20695
+ Object.freeze([...INERT_RENDERING.keys()]);
20696
+
20697
+ const OPAQUE_CONTENT_TYPE = 'application/octet-stream';
20698
+
20699
+ /** isInertDocumentType over an essence already read (essenceOf), null for a value that is no media type. */
20700
+ function isInertDocumentEssence(type) {
20701
+ return INERT_RENDERING.has(type);
20702
+ }
20703
+
20704
+ /**
20705
+ * The type a blob a page hands the browser, to display or to save, may carry:
20706
+ * its own essence when the browser renders it inertly, otherwise
20707
+ * application/octet-stream, which a navigated blob URL downloads instead of
20708
+ * rendering and which no browser completes a saved name from.
20709
+ * @param {string|null|undefined} contentType
20710
+ * @returns {string}
20711
+ */
20712
+ function displaySafeContentType(contentType) {
20713
+ const type = essenceOf(contentType);
20714
+ return isInertDocumentEssence(type) ? type : OPAQUE_CONTENT_TYPE;
20715
+ }
20716
+
20717
+ /**
20718
+ * A blob as a page hands it to the browser, to display or to save: retyped to
20719
+ * displaySafeContentType of its own type, or the blob itself when it already
20720
+ * carries that type. slice() retypes without copying the bytes.
20721
+ * @param {Blob} blob
20722
+ * @returns {Blob}
20723
+ */
20724
+ function withDisplaySafeType(blob) {
20725
+ const safeType = displaySafeContentType(blob.type);
20726
+ return blob.type === safeType ? blob : blob.slice(0, blob.size, safeType);
20727
+ }
20728
+
20334
20729
  /**
20335
20730
  * Files brought to a message's composer by drag, drop and paste, handled
20336
20731
  * alike by every composer that takes them: the console's reply composer and
@@ -20532,6 +20927,7 @@ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
20532
20927
 
20533
20928
  const PATHS = Object.freeze({
20534
20929
  back: 'm14.5 6-6 6 6 6',
20930
+ arrowRight: 'M4 12h16m-6-6 6 6-6 6',
20535
20931
  close: 'm6 6 12 12M18 6 6 18',
20536
20932
  external: 'M14 4h6v6m0-6L10 14M11 5H5a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h13a1 1 0 0 0 1-1v-6',
20537
20933
  check: 'm5 12 4 4L19 6',
@@ -20588,10 +20984,10 @@ function helpDeskIcon(name) {
20588
20984
  * takes no files from its customers is refused in words
20589
20985
  * (NO_CUSTOMER_FILES_COPY), and one brought while files cannot join is
20590
20986
  * never the browser's to open in place of the unsent message.
20591
- * - **Help.** What a message takes (how many files, how large, which kinds)
20592
- * waits behind a (?) tip after Attach, a disclosure that closes by its
20593
- * trigger, by Escape, by its close button, by a press outside it or by
20594
- * focus leaving it; a refused file's chip names only why it was refused.
20987
+ * - **Requirements.** A rejected file opens one modal with its reason and
20988
+ * the attachment rules. A selection shares that modal, and dismissing it
20989
+ * leaves later refusals from the same selection in their chips. Accepted
20990
+ * images have local previews, including while waiting for sign-in.
20595
20991
  * - **Uploading.** The browser's check (attachmentRefusal) first, then the
20596
20992
  * host's transport: its target (the request a reply belongs to, or the
20597
20993
  * draft a new request uploads to, which may not exist yet: the file then
@@ -20656,21 +21052,27 @@ const COMPOSER_CSS = `
20656
21052
  .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}
20657
21053
  .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}}
20658
21054
  .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}
20659
- .svhd-composer .svhd-composer-attach:hover,.svhd-composer .svhd-composer-help:hover{background:${HELP_DESK_COLORS.fill};color:${HELP_DESK_COLORS.ink}}
21055
+ .svhd-composer .svhd-composer-attach:hover{background:${HELP_DESK_COLORS.fill};color:${HELP_DESK_COLORS.ink}}
20660
21056
  .svhd-composer .svhd-composer-attach:disabled{opacity:.6;cursor:default}
20661
21057
  .svhd-composer .svhd-composer-attach svg{display:block;width:18px;height:18px}
20662
- .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}
20663
- .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}
20664
- .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}
20665
- .svhd-composer .svhd-composer-help-copy{grid-column:1;min-width:0;overflow-wrap:anywhere}
20666
- .svhd-composer .svhd-composer-help-copy p{margin:0}
20667
- .svhd-composer .svhd-composer-help-copy p+p{margin-top:6px}
20668
- .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}
20669
- .svhd-composer .svhd-composer-help-close:hover,.svhd-composer .svhd-attachment-remove:hover{background:${HELP_DESK_COLORS.fillStrong};color:${HELP_DESK_COLORS.ink}}
20670
- .svhd-composer .svhd-composer-help-close svg,.svhd-composer .svhd-attachment-remove svg{display:block;width:16px;height:16px}
21058
+ .svhd-composer .svhd-composer-validation-dialog{position:fixed;inset:0;width:min(480px,calc(100vw - 32px));max-height:calc(100dvh - 32px);margin:auto;padding:0;overflow:auto;border:1px solid ${HELP_DESK_COLORS.lineStrong};border-radius:12px;background:${HELP_DESK_COLORS.surface};color:${HELP_DESK_COLORS.ink};font:400 15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;text-align:left;overscroll-behavior:contain}
21059
+ .svhd-composer .svhd-composer-validation-dialog::backdrop{background:color-mix(in srgb,${HELP_DESK_COLORS.modalBackdrop} 60%,transparent)}
21060
+ .svhd-composer .svhd-composer-validation-header{display:flex;align-items:center;gap:12px;padding:16px 16px 8px 24px}
21061
+ .svhd-composer .svhd-composer-validation-title{flex:1;min-width:0;margin:0;font-family:inherit;font-size:20px;font-weight:600;line-height:1.3;overflow-wrap:anywhere}
21062
+ .svhd-composer .svhd-composer-validation-close{display:grid;place-items:center;flex:none;width:44px;height:44px;margin:0;padding:0;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_COLORS.body};cursor:pointer}
21063
+ .svhd-composer .svhd-composer-validation-close:hover,.svhd-composer .svhd-attachment-remove:hover{background:${HELP_DESK_COLORS.fillStrong};color:${HELP_DESK_COLORS.ink}}
21064
+ .svhd-composer .svhd-composer-validation-close svg,.svhd-composer .svhd-attachment-remove svg{display:block;width:16px;height:16px}
21065
+ .svhd-composer .svhd-composer-refusals{display:grid;gap:12px;margin:0;padding:0 24px 24px;list-style:none;color:${HELP_DESK_COLORS.body};overflow-wrap:anywhere}
21066
+ .svhd-composer .svhd-composer-refusals strong{display:block;margin-bottom:2px;color:${HELP_DESK_COLORS.ink};font-weight:600}
21067
+ .svhd-composer .svhd-composer-requirements{padding:20px 24px;border-top:1px solid ${HELP_DESK_COLORS.fillStrong};background:${HELP_DESK_COLORS.canvas};color:${HELP_DESK_COLORS.body};font-size:13px;line-height:1.5}
21068
+ .svhd-composer .svhd-composer-requirements h3{margin:0 0 8px;color:${HELP_DESK_COLORS.ink};font-family:inherit;font-size:14px;font-weight:600}
21069
+ .svhd-composer .svhd-composer-requirements p{margin:0}
21070
+ .svhd-composer .svhd-composer-requirements p+p{margin-top:8px}
20671
21071
  .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}}
20672
21072
  .svhd-composer .svhd-attachment-chips:empty{display:none}
20673
21073
  .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}
21074
+ .svhd-composer .svhd-attachment-thumbnail{grid-column:1/-1;display:block;width:100%;height:96px;object-fit:contain;margin:8px 0;background:${HELP_DESK_COLORS.field};border-radius:4px}
21075
+ .svhd-composer .svhd-attachment-preview-unavailable{grid-column:1/-1;margin:8px 8px 0 0;color:${HELP_DESK_COLORS.muted};font-size:12px}
20674
21076
  .svhd-composer .svhd-attachment-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600;color:${HELP_DESK_COLORS.ink}}
20675
21077
  .svhd-composer .svhd-attachment-status{grid-column:1;padding-right:8px;color:${HELP_DESK_COLORS.body};font-size:12px;overflow-wrap:anywhere}
20676
21078
  .svhd-composer .svhd-attachment-status.svhd-composer-problem{color:${HELP_DESK_COLORS.error}}
@@ -20678,7 +21080,7 @@ const COMPOSER_CSS = `
20678
21080
  .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}
20679
21081
  .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}
20680
21082
  .svhd-composer .svhd-attachment-remove:disabled,.svhd-composer .svhd-attachment-retry:disabled{opacity:.6;cursor:default}
20681
- .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}}
21083
+ .svhd-composer .svhd-composer-attach:focus-visible,.svhd-composer .svhd-composer-validation-close:focus-visible,.svhd-composer .svhd-attachment-remove:focus-visible,.svhd-composer .svhd-attachment-retry:focus-visible{${INSET_RING}}
20682
21084
  .svhd-composer-notice{margin:0;color:${HELP_DESK_COLORS.error};font-size:14px;line-height:1.5}
20683
21085
  .svhd-composer [hidden],.svhd-composer-notice[hidden]{display:none!important}
20684
21086
  `;
@@ -20715,8 +21117,8 @@ const RECEIVED_COPY = 'File received. Waiting for storage confirmation.';
20715
21117
  const UPLOAD_FAILED_COPY = "This file couldn't be uploaded. Try again or remove it.";
20716
21118
  const UPLOADING_COPY = 'Uploading';
20717
21119
  const VERIFYING_COPY = 'Verifying stored file';
20718
- /** The (?) tip's name, and what it says a message takes. */
20719
- const HELP_TITLE = 'Attachment limits';
21120
+ /** Requirements appear only after a file is refused. */
21121
+ const VALIDATION_TITLE = 'Unable to attach files';
20720
21122
  const ACCEPTED_KINDS_COPY = `You can attach ${ACCEPTED_ATTACHMENTS_COPY}.`;
20721
21123
 
20722
21124
  /** What a message's files still need before it can be sent, from the most pressing. */
@@ -20855,9 +21257,7 @@ function createHelpDeskComposer(options) {
20855
21257
  const zone = dropZone ?? frame;
20856
21258
  const fields = [textarea, ...pasteFields];
20857
21259
 
20858
- // The Attach button, the chooser it opens (a filter that offers the
20859
- // extensions a request takes first, never the check), and its (?) tip,
20860
- // whose limits also describe Attach.
21260
+ // The chooser filters names; the canonical attachment check decides.
20861
21261
  const input = document.createElement('input');
20862
21262
  input.type = 'file';
20863
21263
  input.name = 'attachments';
@@ -20865,40 +21265,13 @@ function createHelpDeskComposer(options) {
20865
21265
  input.accept = ATTACHMENT_INPUT_ACCEPT;
20866
21266
  input.hidden = true;
20867
21267
  input.tabIndex = -1;
20868
- const hint = document.createElement('p');
20869
- hint.id = `${textarea.id}-attachment-hint`;
20870
- hint.textContent = CUSTOMER_ATTACHMENTS_HINT;
20871
- const kinds = document.createElement('p');
20872
- kinds.textContent = ACCEPTED_KINDS_COPY;
20873
21268
  const attach = button$1('svhd-composer-attach', 'Attach files');
20874
- attach.setAttribute('aria-describedby', hint.id);
20875
21269
  const attachText = document.createElement('span');
20876
21270
  attachText.textContent = 'Attach';
20877
21271
  attach.append(helpDeskIcon('paperclip'), attachText);
20878
- const helpPanel = document.createElement('div');
20879
- helpPanel.id = `${textarea.id}-attachment-help`;
20880
- helpPanel.className = 'svhd-composer-help-panel';
20881
- helpPanel.setAttribute('role', 'region');
20882
- helpPanel.setAttribute('aria-label', HELP_TITLE);
20883
- helpPanel.hidden = true;
20884
- const helpCopy = document.createElement('div');
20885
- helpCopy.className = 'svhd-composer-help-copy';
20886
- helpCopy.append(hint, kinds);
20887
- const helpClose = button$1('svhd-composer-help-close', 'Close');
20888
- helpClose.title = 'Close';
20889
- helpClose.append(helpDeskIcon('close'));
20890
- helpPanel.append(helpCopy, helpClose);
20891
- const helpTrigger = button$1('svhd-composer-help', `Help: ${HELP_TITLE}`);
20892
- helpTrigger.setAttribute('aria-expanded', 'false');
20893
- helpTrigger.setAttribute('aria-controls', helpPanel.id);
20894
- const glyph = document.createElement('span');
20895
- glyph.className = 'svhd-composer-help-glyph';
20896
- glyph.setAttribute('aria-hidden', 'true');
20897
- glyph.textContent = '?';
20898
- helpTrigger.append(glyph);
20899
21272
  const toolbar = document.createElement('div');
20900
21273
  toolbar.className = 'svhd-composer-toolbar';
20901
- toolbar.append(attach, helpTrigger, helpPanel, input);
21274
+ toolbar.append(attach, input);
20902
21275
  const list = document.createElement('ul');
20903
21276
  list.className = 'svhd-attachment-chips';
20904
21277
  list.setAttribute('aria-label', 'Attached files');
@@ -20910,10 +21283,151 @@ function createHelpDeskComposer(options) {
20910
21283
  let locked = false;
20911
21284
  let pickingDisabled = false;
20912
21285
  let destroyed = false;
21286
+ let validation = null;
20913
21287
  const accepting = () => transport !== null && !locked && !pickingDisabled && !destroyed;
20914
21288
  const current = (entry, ownRevision) =>
20915
21289
  !destroyed && revision === ownRevision && entries.includes(entry) && !entry.controller?.signal.aborted;
20916
21290
 
21291
+ /** A selection keeps its refusal lifecycle even when its files settle at different times. */
21292
+ const selection = () => ({
21293
+ dismissed: false,
21294
+ returnFocus: document.activeElement instanceof HTMLElement && document.activeElement !== document.body
21295
+ ? document.activeElement : textarea
21296
+ });
21297
+
21298
+ function dismissValidation() {
21299
+ const shown = validation;
21300
+ if (!shown) return;
21301
+ validation = null;
21302
+ for (const batch of shown.batches) batch.dismissed = true;
21303
+ if (shown.dialog.open) shown.dialog.close();
21304
+ shown.dialog.remove();
21305
+ document.documentElement.style.overflow = shown.overflow;
21306
+ if (!destroyed) {
21307
+ const target = shown.returnFocus.isConnected && !shown.returnFocus.disabled ? shown.returnFocus : textarea;
21308
+ target.focus();
21309
+ }
21310
+ }
21311
+
21312
+ /** Exact refusals share one top-layer dialog; later files never steal focus from its reader. */
21313
+ function reportRefusal(batch, key, filename, copy) {
21314
+ if (destroyed || batch.dismissed) return;
21315
+ let shown = validation;
21316
+ if (!shown) {
21317
+ const dialog = document.createElement('dialog');
21318
+ dialog.className = 'svhd-composer-validation-dialog';
21319
+ const title = document.createElement('h2');
21320
+ title.id = `${textarea.id}-attachment-validation-title`;
21321
+ title.className = 'svhd-composer-validation-title';
21322
+ title.textContent = VALIDATION_TITLE;
21323
+ dialog.setAttribute('aria-labelledby', title.id);
21324
+ const close = button$1('svhd-composer-validation-close', 'Close');
21325
+ close.title = 'Close';
21326
+ close.append(helpDeskIcon('close'));
21327
+ const header = document.createElement('div');
21328
+ header.className = 'svhd-composer-validation-header';
21329
+ header.append(title, close);
21330
+ const reasons = document.createElement('ul');
21331
+ reasons.className = 'svhd-composer-refusals';
21332
+ reasons.id = `${textarea.id}-attachment-refusals`;
21333
+ dialog.setAttribute('aria-describedby', reasons.id);
21334
+ reasons.setAttribute('aria-live', 'polite');
21335
+ const requirements = document.createElement('div');
21336
+ requirements.className = 'svhd-composer-requirements';
21337
+ const heading = document.createElement('h3');
21338
+ heading.textContent = 'What you can attach';
21339
+ const limits = document.createElement('p');
21340
+ limits.textContent = deskRefusesFiles ? NO_CUSTOMER_FILES_COPY : CUSTOMER_ATTACHMENTS_HINT;
21341
+ requirements.append(heading, limits);
21342
+ if (!deskRefusesFiles) {
21343
+ const kinds = document.createElement('p');
21344
+ kinds.textContent = ACCEPTED_KINDS_COPY;
21345
+ requirements.append(kinds);
21346
+ }
21347
+ dialog.append(header, reasons, requirements);
21348
+ shown = { dialog, reasons, close, issues: new Map(), batches: new Set(), returnFocus: batch.returnFocus, overflow: document.documentElement.style.overflow };
21349
+ validation = shown;
21350
+ close.addEventListener('click', () => dismissValidation());
21351
+ dialog.addEventListener('cancel', (event) => { event.preventDefault(); event.stopPropagation(); dismissValidation(); });
21352
+ dialog.addEventListener('close', () => { if (validation === shown) dismissValidation(); });
21353
+ dialog.addEventListener('keydown', (event) => {
21354
+ if (event.key === 'Escape') {
21355
+ event.preventDefault();
21356
+ event.stopPropagation();
21357
+ dismissValidation();
21358
+ } else if (event.key === 'Tab') {
21359
+ // Close is this dialog's one focusable control; keep keyboard focus with it.
21360
+ event.preventDefault();
21361
+ close.focus();
21362
+ }
21363
+ });
21364
+ const outside = (event) => {
21365
+ if (event.target !== dialog) return false;
21366
+ const bounds = dialog.getBoundingClientRect();
21367
+ return event.clientX < bounds.left || event.clientX > bounds.right || event.clientY < bounds.top || event.clientY > bounds.bottom;
21368
+ };
21369
+ let backdropPress = false;
21370
+ dialog.addEventListener('pointerdown', (event) => { backdropPress = outside(event); });
21371
+ dialog.addEventListener('click', (event) => { if (backdropPress && outside(event)) dismissValidation(); backdropPress = false; });
21372
+ frame.append(dialog);
21373
+ }
21374
+ shown.batches.add(batch);
21375
+ let reason = shown.issues.get(key);
21376
+ if (!reason) {
21377
+ reason = document.createElement('li');
21378
+ shown.issues.set(key, reason);
21379
+ shown.reasons.append(reason);
21380
+ }
21381
+ const text = document.createElement('span');
21382
+ text.textContent = copy;
21383
+ reason.replaceChildren();
21384
+ if (filename) {
21385
+ const name = document.createElement('strong');
21386
+ name.textContent = filename;
21387
+ reason.append(name);
21388
+ }
21389
+ reason.append(text);
21390
+ if (!shown.dialog.open) {
21391
+ shown.dialog.showModal();
21392
+ document.documentElement.style.overflow = 'hidden';
21393
+ shown.close.focus();
21394
+ }
21395
+ }
21396
+
21397
+ function releasePreview(entry) {
21398
+ if (!entry.previewUrl) return;
21399
+ URL.revokeObjectURL(entry.previewUrl);
21400
+ entry.previewUrl = null;
21401
+ }
21402
+
21403
+ /** Local validated images need no transfer; every blob is inert even if its declared MIME is hostile. */
21404
+ function preview(entry) {
21405
+ if (entry.previewAttempted || !ACCEPTED_ATTACHMENT_KINDS.images.includes(lastExtension(entry.file.name))) return;
21406
+ entry.previewAttempted = true;
21407
+ const image = document.createElement('img');
21408
+ image.className = 'svhd-attachment-thumbnail';
21409
+ image.alt = `Preview of ${entry.file.name}`;
21410
+ image.decoding = 'async';
21411
+ const unavailable = () => {
21412
+ releasePreview(entry);
21413
+ image.remove();
21414
+ if (destroyed || !entries.includes(entry)) return;
21415
+ const fallback = document.createElement('span');
21416
+ fallback.className = 'svhd-attachment-preview-unavailable';
21417
+ fallback.textContent = 'Preview unavailable';
21418
+ entry.row.prepend(fallback);
21419
+ };
21420
+ image.addEventListener('error', unavailable, { once: true });
21421
+ try {
21422
+ entry.previewUrl = URL.createObjectURL(withDisplaySafeType(entry.file));
21423
+ image.src = entry.previewUrl;
21424
+ entry.row.prepend(image);
21425
+ } catch {
21426
+ // A browser that cannot create a preview still uploads the original file.
21427
+ unavailable();
21428
+ }
21429
+ }
21430
+
20917
21431
  // A refusal of files is an alert only while it shows, as a field's error is.
20918
21432
  function setNotice(text) {
20919
21433
  notice.textContent = text ?? '';
@@ -20974,9 +21488,12 @@ function createHelpDeskComposer(options) {
20974
21488
  if (!stillCurrent()) return;
20975
21489
  if (refusal) {
20976
21490
  entry.retryable = false;
20977
- show(entry, FILE_STATE.REFUSED, refusalCopy(refusal, CUSTOMER_ATTACHMENT_MAX_BYTES));
21491
+ const copy = refusalCopy(refusal, CUSTOMER_ATTACHMENT_MAX_BYTES);
21492
+ show(entry, FILE_STATE.REFUSED, copy);
21493
+ reportRefusal(entry.batch, entry, entry.file.name, copy);
20978
21494
  return;
20979
21495
  }
21496
+ preview(entry);
20980
21497
  request = 'host';
20981
21498
  const target = await transport.target();
20982
21499
  if (!stillCurrent()) return;
@@ -21022,7 +21539,9 @@ function createHelpDeskComposer(options) {
21022
21539
  entry.attachmentId = upload.attachment_id;
21023
21540
  if (Number.isSafeInteger(upload.max_bytes) && upload.max_bytes > 0 && entry.file.size > upload.max_bytes) {
21024
21541
  entry.retryable = false;
21025
- show(entry, FILE_STATE.FAILED, tooLargeCopy(upload.max_bytes));
21542
+ const copy = tooLargeCopy(upload.max_bytes);
21543
+ show(entry, FILE_STATE.FAILED, copy);
21544
+ reportRefusal(entry.batch, entry, entry.file.name, copy);
21026
21545
  return;
21027
21546
  }
21028
21547
  entry.progress.value = 0;
@@ -21055,6 +21574,7 @@ function createHelpDeskComposer(options) {
21055
21574
  const problem = uploadProblem(refusalOf(request, error), organization);
21056
21575
  entry.retryable = problem.retryable;
21057
21576
  show(entry, FILE_STATE.FAILED, problem.copy);
21577
+ if (!problem.retryable) reportRefusal(entry.batch, entry, entry.file.name, problem.copy);
21058
21578
  } finally {
21059
21579
  if (entry.controller === controller) entry.controller = null;
21060
21580
  if (entry.operation === operation) entry.operation = null;
@@ -21087,6 +21607,7 @@ function createHelpDeskComposer(options) {
21087
21607
  const refocus = document.activeElement === entry.remove;
21088
21608
  const index = entries.indexOf(entry);
21089
21609
  entry.controller?.abort();
21610
+ releasePreview(entry);
21090
21611
  entries = entries.filter((candidate) => candidate !== entry);
21091
21612
  entry.row.remove();
21092
21613
  setNotice(null);
@@ -21096,13 +21617,14 @@ function createHelpDeskComposer(options) {
21096
21617
  if (refocus) (entries[Math.min(index, entries.length - 1)]?.remove ?? attach).focus();
21097
21618
  }
21098
21619
 
21099
- function add(files) {
21620
+ function add(files, batch = selection()) {
21100
21621
  if (!accepting()) return;
21101
21622
  const incoming = Array.from(files);
21102
21623
  if (incoming.length === 0) return;
21103
21624
  const counted = entries.filter((entry) => entry.state !== FILE_STATE.REFUSED).length;
21104
21625
  const room = Math.max(0, MAX_ATTACHMENTS_PER_MESSAGE - counted);
21105
21626
  setNotice(incoming.length > room ? LIMIT_COPY : null);
21627
+ if (incoming.length > room) reportRefusal(batch, batch, null, LIMIT_COPY);
21106
21628
  for (const file of incoming.slice(0, room)) {
21107
21629
  const row = document.createElement('li');
21108
21630
  row.className = 'svhd-attachment-chip';
@@ -21129,11 +21651,14 @@ function createHelpDeskComposer(options) {
21129
21651
  const entry = {
21130
21652
  file, row, status, progress, remove: removeButton, retry,
21131
21653
  state: FILE_STATE.QUEUED, retryable: false, controller: null, operation: null,
21132
- target: null, attachmentId: null, sessionUrl: null
21654
+ target: null, attachmentId: null, sessionUrl: null, batch, previewUrl: null, previewAttempted: false
21133
21655
  };
21134
21656
  removeButton.addEventListener('click', () => remove(entry));
21135
21657
  retry.addEventListener('click', () => {
21136
- if (!locked && entry.retryable) void run(entry);
21658
+ if (!locked && entry.retryable) {
21659
+ entry.batch = selection();
21660
+ void run(entry);
21661
+ }
21137
21662
  });
21138
21663
  row.append(name, removeButton, status, retry, progress);
21139
21664
  list.append(row);
@@ -21157,13 +21682,18 @@ function createHelpDeskComposer(options) {
21157
21682
  drop.hidden = !value;
21158
21683
  }
21159
21684
  function refuseFiles() {
21160
- if (!notice.hidden && notice.textContent === NO_CUSTOMER_FILES_COPY) return;
21161
21685
  setNotice(NO_CUSTOMER_FILES_COPY);
21686
+ const batch = selection();
21687
+ reportRefusal(batch, batch, null, NO_CUSTOMER_FILES_COPY);
21162
21688
  }
21163
21689
  // A dropped folder is left out, and said so beside any refusal the files with it met.
21164
21690
  function attachBrought(files, folders) {
21165
- if (files.length > 0) add(files);
21166
- if (folders > 0) setNotice(files.length > 0 && !notice.hidden ? `${FOLDER_REFUSAL_COPY} ${notice.textContent}` : FOLDER_REFUSAL_COPY);
21691
+ const batch = selection();
21692
+ if (files.length > 0) add(files, batch);
21693
+ if (folders > 0) {
21694
+ setNotice(files.length > 0 && !notice.hidden ? `${FOLDER_REFUSAL_COPY} ${notice.textContent}` : FOLDER_REFUSAL_COPY);
21695
+ reportRefusal(batch, 'folders', null, FOLDER_REFUSAL_COPY);
21696
+ }
21167
21697
  }
21168
21698
  const fileEvents = composerFileEvents({
21169
21699
  action: fileAction,
@@ -21174,33 +21704,6 @@ function createHelpDeskComposer(options) {
21174
21704
  refuse: refuseFiles
21175
21705
  });
21176
21706
 
21177
- // The (?) tip: a disclosure that closes by its trigger, Escape, its close
21178
- // button (focus back on the trigger), a press outside it, or focus leaving it.
21179
- const inTip = (node) => node instanceof Node && (helpTrigger.contains(node) || helpPanel.contains(node));
21180
- function setHelpOpen(open) {
21181
- helpPanel.hidden = !open;
21182
- helpTrigger.setAttribute('aria-expanded', String(open));
21183
- if (open) document.addEventListener('pointerdown', onPressOutsideHelp);
21184
- else document.removeEventListener('pointerdown', onPressOutsideHelp);
21185
- }
21186
- function onPressOutsideHelp(event) {
21187
- if (!inTip(event.target)) setHelpOpen(false);
21188
- }
21189
- const onHelpToggle = () => setHelpOpen(helpPanel.hidden);
21190
- const onHelpClose = () => {
21191
- setHelpOpen(false);
21192
- helpTrigger.focus();
21193
- };
21194
- // Escape is the tip's alone while it is open: a dialog the form sits in leaves a handled key alone.
21195
- const onHelpKey = (event) => {
21196
- if (event.key !== 'Escape' || helpPanel.hidden) return;
21197
- event.preventDefault();
21198
- onHelpClose();
21199
- };
21200
- const onHelpFocusOut = (event) => {
21201
- if (!helpPanel.hidden && event.relatedTarget && !inTip(event.relatedTarget)) setHelpOpen(false);
21202
- };
21203
-
21204
21707
  // A desk's refusal of files gives way once the customer writes on.
21205
21708
  const onInput = () => {
21206
21709
  if (!transport) setNotice(null);
@@ -21224,19 +21727,15 @@ function createHelpDeskComposer(options) {
21224
21727
  }
21225
21728
  input.addEventListener('change', onChoose);
21226
21729
  attach.addEventListener('click', onAttach);
21227
- helpTrigger.addEventListener('click', onHelpToggle);
21228
- helpClose.addEventListener('click', onHelpClose);
21229
- for (const part of [helpTrigger, helpPanel]) {
21230
- part.addEventListener('keydown', onHelpKey);
21231
- part.addEventListener('focusout', onHelpFocusOut);
21232
- }
21233
21730
 
21234
21731
  function clear(keepAttached = false) {
21235
21732
  revision += 1;
21733
+ dismissValidation();
21236
21734
  const previous = entries;
21237
21735
  entries = [];
21238
21736
  for (const entry of previous) {
21239
21737
  entry.controller?.abort();
21738
+ releasePreview(entry);
21240
21739
  if (!keepAttached || entry.state !== FILE_STATE.COMPLETE) void cancel(entry.target, entry.attachmentId);
21241
21740
  }
21242
21741
  list.replaceChildren();
@@ -21284,7 +21783,6 @@ function createHelpDeskComposer(options) {
21284
21783
  destroy(keepAttached = false) {
21285
21784
  destroyed = true;
21286
21785
  clear(keepAttached);
21287
- setHelpOpen(false);
21288
21786
  zone.removeEventListener('dragenter', fileEvents.dragOver);
21289
21787
  zone.removeEventListener('dragover', fileEvents.dragOver);
21290
21788
  zone.removeEventListener('dragleave', fileEvents.dragLeave);
@@ -21295,12 +21793,6 @@ function createHelpDeskComposer(options) {
21295
21793
  }
21296
21794
  input.removeEventListener('change', onChoose);
21297
21795
  attach.removeEventListener('click', onAttach);
21298
- helpTrigger.removeEventListener('click', onHelpToggle);
21299
- helpClose.removeEventListener('click', onHelpClose);
21300
- for (const part of [helpTrigger, helpPanel]) {
21301
- part.removeEventListener('keydown', onHelpKey);
21302
- part.removeEventListener('focusout', onHelpFocusOut);
21303
- }
21304
21796
  }
21305
21797
  };
21306
21798
  }
@@ -21448,6 +21940,7 @@ function saveFormDraft(deskId, requesterId, value) {
21448
21940
  catch { /* Storage is optional; the live form keeps its composition. */ }
21449
21941
  }
21450
21942
 
21943
+ const HELP_DESK_FORM_TITLE = 'Open a Support Ticket';
21451
21944
  let formSequence = 0;
21452
21945
  /**
21453
21946
  * The desk API's refusal of a file's draft or upload, as the composer reads
@@ -21586,10 +22079,9 @@ function companySignInUrl(value) {
21586
22079
  * A confirmed send replaces the form with its confirmation.
21587
22080
  *
21588
22081
  * The request is a summary and optional details, in a composer that also
21589
- * takes files. A signed-out widget customer writes it as step 1 of 2; step 2
21590
- * asks nothing, and its one button signs them in, in the native sign-in
21591
- * window, and sends it. A signed-in one can switch account or sign out
21592
- * beside the request.
22082
+ * takes files. A signed-out widget customer writes it before continuing to
22083
+ * sign-in, where one button opens the native sign-in window and sends it. A
22084
+ * signed-in customer can switch account or sign out beside the request.
21593
22085
  */
21594
22086
  function mountHelpDeskForm(client, options) {
21595
22087
  const target = resolveTarget(options.target);
@@ -21607,22 +22099,16 @@ function mountHelpDeskForm(client, options) {
21607
22099
  form.className = 'svhd-form';
21608
22100
  form.noValidate = true;
21609
22101
  shell.body.append(form);
21610
- /** A step's heading, which takes focus when the step is entered, under its "Step N of 2" label when it has one. */
21611
- function stepHead(id, title, label) {
22102
+ /** A step's heading takes focus when the customer enters it. */
22103
+ function stepHead(id, title) {
21612
22104
  const head = document.createElement('div');
21613
22105
  head.className = 'svhd-step-head';
21614
- const stepLabel = label === null ? null : document.createElement('p');
21615
- if (stepLabel) {
21616
- stepLabel.className = 'svhd-step-label';
21617
- stepLabel.textContent = label;
21618
- head.append(stepLabel);
21619
- }
21620
22106
  const stepHeading = document.createElement('h2');
21621
22107
  stepHeading.id = id;
21622
22108
  stepHeading.tabIndex = -1;
21623
22109
  stepHeading.textContent = title;
21624
22110
  head.append(stepHeading);
21625
- return { head, heading: stepHeading, label: stepLabel };
22111
+ return { head, heading: stepHeading };
21626
22112
  }
21627
22113
  function stepContainer(step) {
21628
22114
  const container = document.createElement('div');
@@ -21630,7 +22116,7 @@ function mountHelpDeskForm(client, options) {
21630
22116
  container.dataset.contactStep = step;
21631
22117
  return container;
21632
22118
  }
21633
- const request = stepHead(`${prefix}-heading`, widget ? `Contact ${client.desk.organization_name || 'support'}` : 'Contact support', widget ? 'Step 1 of 2' : null);
22119
+ const request = stepHead(`${prefix}-heading`, HELP_DESK_FORM_TITLE);
21634
22120
  const heading = request.heading;
21635
22121
  form.setAttribute('aria-labelledby', heading.id);
21636
22122
  const details = stepContainer('details');
@@ -21777,7 +22263,7 @@ function mountHelpDeskForm(client, options) {
21777
22263
  const widgetAccount = document.createElement('div');
21778
22264
  widgetAccount.className = 'svhd-widget-account';
21779
22265
  let widgetCustomer = widget?.customer ?? null;
21780
- const signInStep = widget ? stepHead(`${prefix}-signin-heading`, 'Sign in to send your request', 'Step 2 of 2') : null;
22266
+ const signInStep = widget ? stepHead(`${prefix}-signin-heading`, 'Sign in to send your request') : null;
21781
22267
  const identity = widget ? stepContainer('identity') : null;
21782
22268
  const recap = document.createElement('div');
21783
22269
  recap.className = 'svhd-recap';
@@ -21991,13 +22477,12 @@ function mountHelpDeskForm(client, options) {
21991
22477
  * The signed-in widget customer writes and sends in one step, posting as
21992
22478
  * the account named under it, beside Switch account and, but for a website
21993
22479
  * account's session, which the website ends, Sign out; a signed-out one
21994
- * writes the request as step 1 of 2. Either way the form shows the request.
22480
+ * writes the request before continuing to sign-in. Either way the form
22481
+ * shows the request.
21995
22482
  */
21996
22483
  function renderWidgetIdentity() {
21997
22484
  if (!widget)
21998
22485
  return;
21999
- if (request.label)
22000
- request.label.hidden = widgetCustomer !== null;
22001
22486
  auth.hidden = true;
22002
22487
  code.wrapper.hidden = true;
22003
22488
  name.wrapper.hidden = true;
@@ -23204,7 +23689,7 @@ function openHelpDeskForm(client, options = {}) {
23204
23689
  header.className = 'svhd-modal-header';
23205
23690
  const title = document.createElement('span');
23206
23691
  title.id = `${prefix}-title`;
23207
- title.textContent = 'Contact support';
23692
+ title.textContent = HELP_DESK_FORM_TITLE;
23208
23693
  title.hidden = true;
23209
23694
  const close = document.createElement('button');
23210
23695
  close.type = 'button';
@@ -25552,6 +26037,10 @@ function injectHelpDeskSupportStyles() {
25552
26037
  .svhs-page .svhs-bottom{padding:20px 32px 24px}
25553
26038
  .svhs-page .svhs-start-bottom{padding-top:0;align-items:flex-start}
25554
26039
  .svhs-page .svhs-start-bottom .svhs-primary{width:auto;min-width:160px}
26040
+ .svhs-page .svhs-start-bottom:has(>.svhs-requester-identity:not([hidden])){flex-direction:row;align-items:center;gap:16px}
26041
+ .svhs-page .svhs-start-bottom:has(>.svhs-requester-identity:not([hidden])) .svhs-primary{flex:none;width:auto}
26042
+ .svhs-requester-identity{flex:1;min-width:0;margin:0;color:${HELP_DESK_COLORS.body};font-size:13px;line-height:1.5;overflow-wrap:anywhere}
26043
+ .svhs-requester-name{font-weight:600}
25555
26044
  .svhs-page[data-stage=issue] .svhs-heading{font-size:28px}
25556
26045
  .svhs-page .svhs-results-bottom .svhs-secondary{width:auto;flex:none}
25557
26046
  .svhs-page .svhs-contact-target,.svhs-page .svhs-contact-target>.svhd-container{min-height:0}
@@ -25564,6 +26053,7 @@ function injectHelpDeskSupportStyles() {
25564
26053
  .svhs-page .svhs-bottom{padding:20px}
25565
26054
  .svhs-page .svhs-start-bottom{padding-top:0}
25566
26055
  .svhs-page .svhs-start-bottom .svhs-primary{width:100%}
26056
+ .svhs-page .svhs-start-bottom:has(>.svhs-requester-identity:not([hidden])) .svhs-primary{min-width:0}
25567
26057
  .svhs-page[data-stage=issue] .svhs-heading{font-size:26px}
25568
26058
  .svhs-page .svhs-results-bottom .svhs-secondary{width:100%}
25569
26059
  .svhs-page .svhs-contact-scroll{padding:0}
@@ -25788,6 +26278,8 @@ class SupportView {
25788
26278
  this.deskName = element('span', 'svhs-desk-name');
25789
26279
  this.external = element('a', 'svhs-icon-button');
25790
26280
  this.issue = element('textarea', 'svhs-issue');
26281
+ this.requesterIdentity = element('p', 'svhs-requester-identity');
26282
+ this.requesterName = element('span', 'svhs-requester-name');
25791
26283
  this.issueError = element('p', 'svhs-error');
25792
26284
  this.query = element('p', 'svhs-query-text');
25793
26285
  this.resultList = element('ul', 'svhs-results');
@@ -25881,11 +26373,8 @@ class SupportView {
25881
26373
  // The heading asks the question once, so it names the field too.
25882
26374
  const issueHeading = this.headings.get('issue');
25883
26375
  issueHeading.id = `${this.prefix}-issue-title`;
25884
- const helper = element('p', 'svhs-copy', 'What is your question? Tell us what is going on.');
25885
- helper.id = `${this.prefix}-issue-help`;
25886
26376
  this.issue.id = `${this.prefix}-issue`;
25887
26377
  this.issue.setAttribute('aria-labelledby', issueHeading.id);
25888
- this.issue.setAttribute('aria-describedby', helper.id);
25889
26378
  this.issue.name = 'support_issue';
25890
26379
  this.issue.placeholder = 'Describe your question or issue';
25891
26380
  this.issue.autocomplete = 'off';
@@ -25905,9 +26394,14 @@ class SupportView {
25905
26394
  this.search();
25906
26395
  }
25907
26396
  });
25908
- intro.append(helper, this.issue, this.issueError);
26397
+ intro.append(this.issue, this.issueError);
25909
26398
  this.find = button('svhs-primary', 'Continue', () => this.search());
25910
- this.footer('issue', 'svhs-start-bottom').append(this.find);
26399
+ const issueFooter = this.footer('issue', 'svhs-start-bottom');
26400
+ issueFooter.append(this.find);
26401
+ this.requesterIdentity.append(document.createTextNode('Signed in as '), this.requesterName);
26402
+ this.requesterIdentity.hidden = true;
26403
+ if (target)
26404
+ issueFooter.append(this.requesterIdentity);
25911
26405
  const results = this.screen('results', 'These articles may help');
25912
26406
  const queryLine = element('div', 'svhs-query');
25913
26407
  const question = element('div', 'svhs-question');
@@ -25918,11 +26412,12 @@ class SupportView {
25918
26412
  results.prepend(queryLine);
25919
26413
  results.append(this.resultList, this.resultStatus, this.resultError);
25920
26414
  this.resultError.setAttribute('role', 'alert');
25921
- this.contactResults = button('svhs-secondary svhs-full', 'Still need help? Open a ticket', () => {
26415
+ this.contactResults = button('svhs-secondary svhs-full', 'Still need help? Open a support ticket', () => {
25922
26416
  if (this.state?.busy)
25923
26417
  return;
25924
26418
  this.actions.onContact(['locked', 'unavailable'].includes(this.state?.kbState || '') ? 'direct' : this.state?.results?.length ? 'none_match' : 'no_results');
25925
26419
  });
26420
+ this.contactResults.append(helpDeskIcon('arrowRight'));
25926
26421
  this.contactNote.id = `${this.prefix}-contact-note`;
25927
26422
  this.contactNote.hidden = true;
25928
26423
  this.resultsFooter = this.footer('results');
@@ -26053,6 +26548,8 @@ class SupportView {
26053
26548
  if (next.busy)
26054
26549
  this.find.append(element('span', 'svhs-spinner'));
26055
26550
  this.find.append(document.createTextNode(next.busy ? 'Continuing...' : 'Continue'));
26551
+ this.requesterName.textContent = next.requesterLabel || '';
26552
+ this.requesterIdentity.hidden = !next.requesterLabel;
26056
26553
  this.issueError.textContent = next.stage === 'issue' ? next.error || '' : '';
26057
26554
  this.issueError.hidden = !this.issueError.textContent;
26058
26555
  this.query.textContent = next.issue;
@@ -26730,7 +27227,7 @@ function createHelpDeskSupport(config, options) {
26730
27227
  // launcher included. Any other desk's brand arrives with connect, which the
26731
27228
  // first open, search or contact makes, never creation: connecting here would
26732
27229
  // add a desk lookup to every page load of a website that shows the launcher.
26733
- let state = { visible: false, stage: 'issue', deskName: 'Support', issue: '', brand: supportBrand(options.desk?.branding?.color) };
27230
+ let state = { visible: false, stage: 'issue', deskName: 'Support', issue: '', requesterLabel: null, brand: supportBrand(options.desk?.branding?.color) };
26734
27231
  if (typeof options.launcher === 'object') {
26735
27232
  const offset = (value, fallback) => typeof value === 'number' && Number.isFinite(value) ? Math.min(240, Math.max(12, value)) : fallback;
26736
27233
  state.position = { right: offset(options.launcher.right, 24), bottom: offset(options.launcher.bottom, 24) + 72 };
@@ -26823,6 +27320,11 @@ function createHelpDeskSupport(config, options) {
26823
27320
  launcher?.setBrand(state.brand);
26824
27321
  notify(options.onStateChange, snapshot());
26825
27322
  }
27323
+ function identifyRequester(customer) {
27324
+ const requesterLabel = requesterNameOrAddress(customer);
27325
+ if (requesterLabel !== state.requesterLabel)
27326
+ update({ requesterLabel });
27327
+ }
26826
27328
  async function connect() {
26827
27329
  if (!connected)
26828
27330
  connected = HelpDeskClient.connect(config, { ...options, onDiscardError: reportLostRevocation }).then((answer) => {
@@ -26830,10 +27332,12 @@ function createHelpDeskSupport(config, options) {
26830
27332
  throw new Error('Support is closed.');
26831
27333
  client = answer;
26832
27334
  stopSession = answer.subscribeSession((change) => {
27335
+ if (change.source !== 'renew')
27336
+ identifyRequester(null);
26833
27337
  if (change.source !== 'clear' || replacingSession)
26834
27338
  return;
26835
27339
  if (lookupsInFlight === 0)
26836
- notify(options.onSession, null);
27340
+ tellHost(null);
26837
27341
  else
26838
27342
  heldClear = true;
26839
27343
  });
@@ -26873,6 +27377,7 @@ function createHelpDeskSupport(config, options) {
26873
27377
  return;
26874
27378
  anonymous = !token;
26875
27379
  if (!token) {
27380
+ identifyRequester(null);
26876
27381
  if (!state.issue)
26877
27382
  update({ issue: readSupportIssue(active.desk.desk_id) ?? '' });
26878
27383
  if (state.issue)
@@ -26882,7 +27387,10 @@ function createHelpDeskSupport(config, options) {
26882
27387
  }
26883
27388
  else if (active.hasTicketAccess) {
26884
27389
  const customer = await active.getMe();
26885
- if (destroyed || state.stage !== 'issue')
27390
+ if (destroyed)
27391
+ return;
27392
+ identifyRequester(customer);
27393
+ if (state.stage !== 'issue')
26886
27394
  return;
26887
27395
  const saved = readFormDraft(active.desk.desk_id, customer.requester_id);
26888
27396
  const composition = readAnonymousFormDraft(active.desk.desk_id);
@@ -27025,8 +27533,10 @@ function createHelpDeskSupport(config, options) {
27025
27533
  tellHost(session);
27026
27534
  }
27027
27535
  function tellHost(session) {
27028
- if (!destroyed)
27029
- notify(options.onSession, session);
27536
+ if (destroyed)
27537
+ return;
27538
+ identifyRequester(session?.customer ?? null);
27539
+ notify(options.onSession, session);
27030
27540
  }
27031
27541
  /**
27032
27542
  * Support's session lookup, with where support arrived (`arrival`) when the
@@ -27217,6 +27727,7 @@ function createHelpDeskSupport(config, options) {
27217
27727
  return;
27218
27728
  contactCustomer = customer;
27219
27729
  anonymous = !customer;
27730
+ identifyRequester(customer);
27220
27731
  // A customer the website gave back sees their own saved request; none keeps it hidden.
27221
27732
  const recovering = customer ? null : pendingRecovery;
27222
27733
  pendingRecovery = null;
@@ -27243,7 +27754,7 @@ function createHelpDeskSupport(config, options) {
27243
27754
  anonymous = false;
27244
27755
  if (options.persist)
27245
27756
  clearSupportIssue(client.desk.desk_id);
27246
- notify(options.onSession, session);
27757
+ tellHost(session);
27247
27758
  },
27248
27759
  widgetIdentity: {
27249
27760
  customer,
@@ -27523,7 +28034,7 @@ function createHelpDeskSupport(config, options) {
27523
28034
  // A refused or lost revocation leaves the chosen account in place.
27524
28035
  void released.catch(reportLostRevocation);
27525
28036
  active.setSession(session);
27526
- notify(options.onSession, session);
28037
+ tellHost(session);
27527
28038
  let refusal;
27528
28039
  if (active.ticketAccessPolicy?.mode === 'identity') {
27529
28040
  // Without this grant, contact's access check shows the employee gate
@@ -32441,7 +32952,7 @@ class SparkVault {
32441
32952
  }
32442
32953
  /** Get the SDK version */
32443
32954
  static get version() {
32444
- return '18.0.3';
32955
+ return '18.0.5';
32445
32956
  }
32446
32957
  }
32447
32958
  if (typeof window !== 'undefined') {