@guidelytech/shared 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -22,6 +22,7 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  ADVANCE_ON: () => ADVANCE_ON,
24
24
  ANNOTATION_COLORS: () => ANNOTATION_COLORS,
25
+ ARTICLE_VISIBILITIES: () => ARTICLE_VISIBILITIES,
25
26
  AUTOCAPTURE_EVENTS: () => AUTOCAPTURE_EVENTS,
26
27
  AppearanceSchema: () => AppearanceSchema,
27
28
  AuthoringPickSchema: () => AuthoringPickSchema,
@@ -30,6 +31,9 @@ __export(index_exports, {
30
31
  ButtonSchema: () => ButtonSchema,
31
32
  CAPTURE_PARAM: () => CAPTURE_PARAM,
32
33
  CAPTURE_SCREENSHOT_MAX_BYTES: () => CAPTURE_SCREENSHOT_MAX_BYTES,
34
+ COMPLAINT_EVENTS: () => COMPLAINT_EVENTS,
35
+ COMPLAINT_FIELD_TYPES: () => COMPLAINT_FIELD_TYPES,
36
+ COMPLAINT_STATUSES: () => COMPLAINT_STATUSES,
33
37
  CaptureStepSchema: () => CaptureStepSchema,
34
38
  CapturedElementSchema: () => CapturedElementSchema,
35
39
  ChecklistConfigSchema: () => ChecklistConfigSchema,
@@ -44,12 +48,14 @@ __export(index_exports, {
44
48
  ErrorTrackingSettingsSchema: () => ErrorTrackingSettingsSchema,
45
49
  EventBatchSchema: () => EventBatchSchema,
46
50
  FILE_LINK_CLASS: () => FILE_LINK_CLASS,
51
+ FileComplaintSchema: () => FileComplaintSchema,
47
52
  FrequencySchema: () => FrequencySchema,
48
53
  GUIDELY_ID_ATTRIBUTE: () => GUIDELY_ID_ATTRIBUTE,
49
54
  GUIDE_KINDS: () => GUIDE_KINDS,
50
55
  GUIDE_LIFECYCLE_EVENTS: () => GUIDE_LIFECYCLE_EVENTS,
51
56
  GUIDE_STATUSES: () => GUIDE_STATUSES,
52
57
  GUIDE_TEMPLATES: () => GUIDE_TEMPLATES,
58
+ GUIDE_VISIBILITIES: () => GUIDE_VISIBILITIES,
53
59
  GuideConfigSchema: () => GuideConfigSchema,
54
60
  GuideStateUpdateSchema: () => GuideStateUpdateSchema,
55
61
  HEATMAP_VIEWPORTS: () => HEATMAP_VIEWPORTS,
@@ -57,8 +63,14 @@ __export(index_exports, {
57
63
  HOWTO_STEP_KINDS: () => HOWTO_STEP_KINDS,
58
64
  HowToAnnotationSchema: () => HowToAnnotationSchema,
59
65
  IdentifyRequestSchema: () => IdentifyRequestSchema,
66
+ LOGGED_IN_AUDIENCE: () => LOGGED_IN_AUDIENCE,
60
67
  MAX_ANNOTATIONS: () => MAX_ANNOTATIONS,
61
68
  MAX_COLLECTION_DEPTH: () => MAX_COLLECTION_DEPTH,
69
+ MAX_COMPLAINT_ANSWER_LENGTH: () => MAX_COMPLAINT_ANSWER_LENGTH,
70
+ MAX_COMPLAINT_ATTACHMENT_BYTES: () => MAX_COMPLAINT_ATTACHMENT_BYTES,
71
+ MAX_COMPLAINT_CHOICES: () => MAX_COMPLAINT_CHOICES,
72
+ MAX_COMPLAINT_FIELDS: () => MAX_COMPLAINT_FIELDS,
73
+ MAX_COMPLAINT_LENGTH: () => MAX_COMPLAINT_LENGTH,
62
74
  MAX_MESSAGE_LENGTH: () => MAX_MESSAGE_LENGTH,
63
75
  MAX_PROPERTY_BYTES: () => MAX_PROPERTY_BYTES,
64
76
  MAX_STACK_FRAMES: () => MAX_STACK_FRAMES,
@@ -92,6 +104,8 @@ __export(index_exports, {
92
104
  ReplaySettingsSchema: () => ReplaySettingsSchema,
93
105
  RuleGroupSchema: () => RuleGroupSchema,
94
106
  RuleSchema: () => RuleSchema,
107
+ SCRIPT_STUB: () => SCRIPT_STUB,
108
+ SCRIPT_STUB_METHODS: () => SCRIPT_STUB_METHODS,
95
109
  SDK_API_VERSION: () => SDK_API_VERSION,
96
110
  SELECTOR_KINDS: () => SELECTOR_KINDS,
97
111
  SENSITIVE_HEADER_PATTERN: () => SENSITIVE_HEADER_PATTERN,
@@ -99,6 +113,8 @@ __export(index_exports, {
99
113
  SENSITIVE_PROPERTY_PATTERN: () => SENSITIVE_PROPERTY_PATTERN,
100
114
  SERVER_ASSISTED_FIELDS: () => SERVER_ASSISTED_FIELDS,
101
115
  SHARED_VERSION: () => SHARED_VERSION,
116
+ SHOW_ME_CLASS: () => SHOW_ME_CLASS,
117
+ SHOW_ME_HREF_PREFIX: () => SHOW_ME_HREF_PREFIX,
102
118
  SOURCEMAP_MAX_FILES_PER_UPLOAD: () => SOURCEMAP_MAX_FILES_PER_UPLOAD,
103
119
  SOURCEMAP_MAX_FILE_BYTES: () => SOURCEMAP_MAX_FILE_BYTES,
104
120
  STATUS_LEVELS: () => STATUS_LEVELS,
@@ -122,6 +138,7 @@ __export(index_exports, {
122
138
  cleanLabel: () => cleanLabel,
123
139
  compare: () => compare,
124
140
  compareVersions: () => compareVersions,
141
+ complaintReference: () => complaintReference,
125
142
  defaultGuideConfig: () => defaultGuideConfig,
126
143
  defaultStep: () => defaultStep,
127
144
  describeCaptureStep: () => describeCaptureStep,
@@ -136,6 +153,7 @@ __export(index_exports, {
136
153
  getPath: () => getPath,
137
154
  guidePlatforms: () => guidePlatforms,
138
155
  guidelyIdFromSelector: () => guidelyIdFromSelector,
156
+ hasVideoMedia: () => hasVideoMedia,
139
157
  isAllowedEmbedSrc: () => isAllowedEmbedSrc,
140
158
  isArticleListed: () => isArticleListed,
141
159
  isChecklistComplete: () => isChecklistComplete,
@@ -148,6 +166,7 @@ __export(index_exports, {
148
166
  isVideoContentType: () => isVideoContentType,
149
167
  matchUrlPattern: () => matchUrlPattern,
150
168
  matchesAudiences: () => matchesAudiences,
169
+ matchesHelpQuery: () => matchesHelpQuery,
151
170
  mediaKind: () => mediaKind,
152
171
  mediaMaxBytes: () => mediaMaxBytes,
153
172
  normalizeErrorMessage: () => normalizeErrorMessage,
@@ -163,6 +182,11 @@ __export(index_exports, {
163
182
  safeRegExp: () => safeRegExp,
164
183
  sanitizeProperties: () => sanitizeProperties,
165
184
  screenPath: () => screenPath,
185
+ scriptSnippet: () => scriptSnippet,
186
+ servedArticleAudiences: () => servedArticleAudiences,
187
+ showMeHref: () => showMeHref,
188
+ showMeKeyFromHref: () => showMeKeyFromHref,
189
+ showMeKeys: () => showMeKeys,
166
190
  slugify: () => slugify,
167
191
  stripOrigin: () => stripOrigin,
168
192
  supportsPlatform: () => supportsPlatform,
@@ -170,7 +194,9 @@ __export(index_exports, {
170
194
  toEmbedUrl: () => toEmbedUrl,
171
195
  validateGuideConfig: () => validateGuideConfig,
172
196
  visibleArticleIds: () => visibleArticleIds,
173
- visibleButtons: () => visibleButtons
197
+ visibleButtons: () => visibleButtons,
198
+ visitorAudiences: () => visitorAudiences,
199
+ withVisibility: () => withVisibility
174
200
  });
175
201
  module.exports = __toCommonJS(index_exports);
176
202
 
@@ -345,6 +371,7 @@ var RULE_FIELDS = [
345
371
  "account.attribute",
346
372
  "user.role",
347
373
  "user.plan",
374
+ "user.identified",
348
375
  "url.path",
349
376
  "url.full",
350
377
  "url.query",
@@ -389,6 +416,8 @@ function resolveField(rule, ctx) {
389
416
  return ctx.userAttributes.role;
390
417
  case "user.plan":
391
418
  return ctx.userAttributes.plan ?? ctx.accountAttributes.plan;
419
+ case "user.identified":
420
+ return !!ctx.userId;
392
421
  case "url.path":
393
422
  return ctx.path;
394
423
  case "url.full":
@@ -535,6 +564,11 @@ function evaluateRules(group, ctx) {
535
564
  return group.negate ? !value : value;
536
565
  }
537
566
  var SERVER_ASSISTED_FIELDS = ["audience.member", "guide.completed", "guide.dismissed", "guide.seen", "checklist.completed"];
567
+ var GUIDE_VISIBILITIES = ["everyone", "identified", "anonymous"];
568
+ function withVisibility(targeting, visibility) {
569
+ if (!visibility || visibility === "everyone") return targeting;
570
+ return { id: "visibility", op: "and", rules: [{ id: "visibility-rule", field: "user.identified", op: visibility === "identified" ? "is_true" : "is_false" }, targeting] };
571
+ }
538
572
  function describeRule(rule) {
539
573
  const subject = rule.key ? `${rule.field}[${rule.key}]` : rule.field;
540
574
  const v = Array.isArray(rule.value) ? rule.value.join(", ") : rule.value === void 0 ? "" : String(rule.value);
@@ -684,7 +718,7 @@ var ChecklistTaskSchema = import_zod2.z.object({
684
718
  required: import_zod2.z.boolean().default(true)
685
719
  });
686
720
  var ChecklistConfigSchema = import_zod2.z.object({
687
- tasks: import_zod2.z.array(ChecklistTaskSchema).min(1).max(30),
721
+ tasks: import_zod2.z.array(ChecklistTaskSchema).min(1),
688
722
  ordered: import_zod2.z.boolean().default(false),
689
723
  launcherLabel: import_zod2.z.string().max(60).default("Getting started"),
690
724
  position: import_zod2.z.enum(["bottom-right", "bottom-left"]).default("bottom-right"),
@@ -718,6 +752,8 @@ var SurveyConfigSchema = import_zod2.z.object({
718
752
  });
719
753
  var GuideConfigSchema = import_zod2.z.object({
720
754
  steps: import_zod2.z.array(StepSchema).max(50).default([]),
755
+ /** Everyone, only identified (logged-in) users, or only anonymous visitors; applied on top of `targeting`. */
756
+ visibility: import_zod2.z.enum(GUIDE_VISIBILITIES).default("everyone"),
721
757
  targeting: RuleGroupSchema.default(() => emptyRuleGroup()),
722
758
  trigger: TriggerSchema.default({}),
723
759
  frequency: FrequencySchema.default({}),
@@ -1018,19 +1054,53 @@ var ConversationRatingSchema = import_zod5.z.object({
1018
1054
  comment: import_zod5.z.string().max(1e3).optional()
1019
1055
  });
1020
1056
 
1021
- // src/capture.ts
1057
+ // src/complaints.ts
1022
1058
  var import_zod6 = require("zod");
1023
- var AutocaptureSettingsSchema = import_zod6.z.object({ pageviews: import_zod6.z.boolean(), pageLeave: import_zod6.z.boolean(), clicks: import_zod6.z.boolean(), rageClicks: import_zod6.z.boolean(), heatmaps: import_zod6.z.boolean(), mouseMovement: import_zod6.z.boolean() }).partial();
1024
- var ErrorTrackingSettingsSchema = import_zod6.z.object({ enabled: import_zod6.z.boolean() }).partial();
1025
- var ReplaySettingsSchema = import_zod6.z.object({
1026
- enabled: import_zod6.z.boolean(),
1027
- sampleRate: import_zod6.z.number().int().min(0).max(100),
1028
- recordConsole: import_zod6.z.boolean(),
1029
- recordNetwork: import_zod6.z.boolean(),
1030
- recordNetworkPayloads: import_zod6.z.boolean(),
1031
- maskAllText: import_zod6.z.boolean(),
1032
- blockSelectors: import_zod6.z.array(import_zod6.z.string().min(1).max(200)).max(50),
1033
- retentionDays: import_zod6.z.number().int().min(1).max(365)
1059
+
1060
+ // src/complaints-limits.ts
1061
+ var COMPLAINT_STATUSES = ["open", "in_review", "resolved"];
1062
+ var COMPLAINT_EVENTS = ["complaint.filed", "complaint.status_changed", "complaint.replied", "complaint.resolved"];
1063
+ var COMPLAINT_FIELD_TYPES = ["text", "choice"];
1064
+ var MAX_COMPLAINT_FIELDS = 8;
1065
+ var MAX_COMPLAINT_CHOICES = 12;
1066
+ var MAX_COMPLAINT_LENGTH = 4e3;
1067
+ var MAX_COMPLAINT_ANSWER_LENGTH = 500;
1068
+ var MAX_COMPLAINT_ATTACHMENT_BYTES = 2 * 1024 * 1024;
1069
+ var complaintReference = (number) => `CMP-${number}`;
1070
+
1071
+ // src/complaints.ts
1072
+ var FileComplaintSchema = import_zod6.z.object({
1073
+ anonymousId: import_zod6.z.string().min(1).max(128),
1074
+ userId: import_zod6.z.string().max(256).optional().nullable(),
1075
+ categoryId: import_zod6.z.string().min(1).max(64),
1076
+ description: import_zod6.z.string().trim().min(1).max(MAX_COMPLAINT_LENGTH),
1077
+ /** Answers to the category's extra questions, by field id. */
1078
+ answers: import_zod6.z.record(import_zod6.z.string().max(64), import_zod6.z.string().trim().max(MAX_COMPLAINT_ANSWER_LENGTH)).default({}),
1079
+ /** Required from visitors the app hasn't identified. */
1080
+ email: import_zod6.z.string().trim().toLowerCase().email().max(254).optional().nullable(),
1081
+ pageUrl: import_zod6.z.string().max(2e3).optional(),
1082
+ /** File it in this conversation (send its token in `X-Guidely-Conversation`); otherwise a new one is started. */
1083
+ conversationId: import_zod6.z.string().min(1).max(64).optional().nullable(),
1084
+ /** One screenshot, base64-encoded (png, jpeg, webp or gif). */
1085
+ attachment: import_zod6.z.object({
1086
+ fileName: import_zod6.z.string().trim().min(1).max(200),
1087
+ data: import_zod6.z.string().max(Math.ceil(MAX_COMPLAINT_ATTACHMENT_BYTES * 4 / 3) + 4)
1088
+ }).optional().nullable()
1089
+ });
1090
+
1091
+ // src/capture.ts
1092
+ var import_zod7 = require("zod");
1093
+ var AutocaptureSettingsSchema = import_zod7.z.object({ pageviews: import_zod7.z.boolean(), pageLeave: import_zod7.z.boolean(), clicks: import_zod7.z.boolean(), rageClicks: import_zod7.z.boolean(), heatmaps: import_zod7.z.boolean(), mouseMovement: import_zod7.z.boolean() }).partial();
1094
+ var ErrorTrackingSettingsSchema = import_zod7.z.object({ enabled: import_zod7.z.boolean() }).partial();
1095
+ var ReplaySettingsSchema = import_zod7.z.object({
1096
+ enabled: import_zod7.z.boolean(),
1097
+ sampleRate: import_zod7.z.number().int().min(0).max(100),
1098
+ recordConsole: import_zod7.z.boolean(),
1099
+ recordNetwork: import_zod7.z.boolean(),
1100
+ recordNetworkPayloads: import_zod7.z.boolean(),
1101
+ maskAllText: import_zod7.z.boolean(),
1102
+ blockSelectors: import_zod7.z.array(import_zod7.z.string().min(1).max(200)).max(50),
1103
+ retentionDays: import_zod7.z.number().int().min(1).max(365)
1034
1104
  }).partial();
1035
1105
  var DEFAULT_CAPTURE_SETTINGS = {
1036
1106
  autocapture: { pageviews: true, pageLeave: true, clicks: true, rageClicks: true, heatmaps: true, mouseMovement: true },
@@ -1051,18 +1121,18 @@ function resolveCaptureSettings(settings) {
1051
1121
  };
1052
1122
  }
1053
1123
  var HEATMAP_VIEWPORTS = { mobile: [0, 767], tablet: [768, 1279], desktop: [1280, 1e5] };
1054
- var ReplayChunkSchema = import_zod6.z.object({
1055
- sessionId: import_zod6.z.string().min(1).max(128),
1056
- windowId: import_zod6.z.string().min(1).max(64),
1057
- seq: import_zod6.z.number().int().min(0).max(1e6),
1058
- anonymousId: import_zod6.z.string().min(1).max(128),
1059
- userId: import_zod6.z.string().max(256).optional().nullable(),
1124
+ var ReplayChunkSchema = import_zod7.z.object({
1125
+ sessionId: import_zod7.z.string().min(1).max(128),
1126
+ windowId: import_zod7.z.string().min(1).max(64),
1127
+ seq: import_zod7.z.number().int().min(0).max(1e6),
1128
+ anonymousId: import_zod7.z.string().min(1).max(128),
1129
+ userId: import_zod7.z.string().max(256).optional().nullable(),
1060
1130
  /** rrweb `eventWithTime` objects, in order. */
1061
- events: import_zod6.z.array(import_zod6.z.object({ type: import_zod6.z.number().int(), timestamp: import_zod6.z.number() }).passthrough()).min(1).max(5e4),
1062
- url: import_zod6.z.string().max(2e3).optional(),
1063
- device: import_zod6.z.object({ type: import_zod6.z.string().max(20), browser: import_zod6.z.string().max(40).optional(), os: import_zod6.z.string().max(40).optional() }).optional(),
1064
- viewport: import_zod6.z.object({ width: import_zod6.z.number().int().min(0).max(1e5), height: import_zod6.z.number().int().min(0).max(1e5) }).optional(),
1065
- sdk: import_zod6.z.object({ name: import_zod6.z.string().max(60), version: import_zod6.z.string().max(30) }).optional()
1131
+ events: import_zod7.z.array(import_zod7.z.object({ type: import_zod7.z.number().int(), timestamp: import_zod7.z.number() }).passthrough()).min(1).max(5e4),
1132
+ url: import_zod7.z.string().max(2e3).optional(),
1133
+ device: import_zod7.z.object({ type: import_zod7.z.string().max(20), browser: import_zod7.z.string().max(40).optional(), os: import_zod7.z.string().max(40).optional() }).optional(),
1134
+ viewport: import_zod7.z.object({ width: import_zod7.z.number().int().min(0).max(1e5), height: import_zod7.z.number().int().min(0).max(1e5) }).optional(),
1135
+ sdk: import_zod7.z.object({ name: import_zod7.z.string().max(60), version: import_zod7.z.string().max(30) }).optional()
1066
1136
  });
1067
1137
  var REPLAY_MAX_COMPRESSED_BYTES = 2 * 1024 * 1024;
1068
1138
  var REPLAY_MAX_RAW_BYTES = 16 * 1024 * 1024;
@@ -1433,12 +1503,51 @@ function isArticleListed(collections, article, member) {
1433
1503
  }
1434
1504
  return true;
1435
1505
  }
1506
+ var ARTICLE_VISIBILITIES = ["everyone", "identified"];
1507
+ var LOGGED_IN_AUDIENCE = "$identified";
1508
+ function servedArticleAudiences(audienceIds, visibility) {
1509
+ return visibility === "identified" && audienceIds.length === 0 ? [LOGGED_IN_AUDIENCE] : [...audienceIds];
1510
+ }
1511
+ function visitorAudiences(audienceIds, identified) {
1512
+ const ids = audienceIds.filter((id) => id !== LOGGED_IN_AUDIENCE);
1513
+ return identified ? [...ids, LOGGED_IN_AUDIENCE] : ids;
1514
+ }
1436
1515
  function visibleArticleIds(collections, articles, member) {
1437
1516
  return new Set(resourceCenterSections(collections, articles, member).flatMap((s) => s.articles.map((a) => a.id)));
1438
1517
  }
1518
+ var SHOW_ME_CLASS = "gd-show-me";
1519
+ var SHOW_ME_HREF_PREFIX = "#guidely-show-me:";
1520
+ var SHOW_ME_KEY = /^[A-Za-z0-9_-]{1,64}$/;
1521
+ function showMeHref(guideKey) {
1522
+ return `${SHOW_ME_HREF_PREFIX}${guideKey}`;
1523
+ }
1524
+ function showMeKeyFromHref(href) {
1525
+ if (!href || !href.startsWith(SHOW_ME_HREF_PREFIX)) return null;
1526
+ const key = href.slice(SHOW_ME_HREF_PREFIX.length);
1527
+ return SHOW_ME_KEY.test(key) ? key : null;
1528
+ }
1529
+ function showMeKeys(html) {
1530
+ const out = [];
1531
+ for (const m of (html ?? "").matchAll(/href="#guidely-show-me:([A-Za-z0-9_-]{1,64})"/g)) if (!out.includes(m[1])) out.push(m[1]);
1532
+ return out.slice(0, 10);
1533
+ }
1534
+ function hasVideoMedia(html) {
1535
+ return /<(video|iframe)\b/i.test(html ?? "");
1536
+ }
1537
+ var words = (s) => s.toLowerCase().match(/[\p{L}\p{N}]+/gu) ?? [];
1538
+ function matchesHelpQuery(text, query) {
1539
+ const q = query.trim().toLowerCase();
1540
+ if (!q) return true;
1541
+ const hay = text.toLowerCase();
1542
+ if (hay.includes(q)) return true;
1543
+ const terms = words(q);
1544
+ if (!terms.length) return false;
1545
+ const have = words(hay);
1546
+ return terms.every((t) => have.some((w) => w.startsWith(t) || t.length > 3 && t.endsWith("s") && w.startsWith(t.slice(0, -1))));
1547
+ }
1439
1548
 
1440
1549
  // src/howto.ts
1441
- var import_zod7 = require("zod");
1550
+ var import_zod8 = require("zod");
1442
1551
 
1443
1552
  // src/howto-limits.ts
1444
1553
  var CAPTURE_PARAM = "guidely_capture";
@@ -1447,36 +1556,36 @@ var CAPTURE_SCREENSHOT_MAX_BYTES = 8 * 1024 * 1024;
1447
1556
  // src/howto.ts
1448
1557
  var HOWTO_STEP_KINDS = ["action", "text", "heading", "tip", "alert"];
1449
1558
  var HOWTO_ACTIONS = ["click", "type", "select", "navigate"];
1450
- var NormalizedRectSchema = import_zod7.z.object({
1451
- x: import_zod7.z.number().min(0).max(1),
1452
- y: import_zod7.z.number().min(0).max(1),
1453
- width: import_zod7.z.number().min(0).max(1),
1454
- height: import_zod7.z.number().min(0).max(1)
1559
+ var NormalizedRectSchema = import_zod8.z.object({
1560
+ x: import_zod8.z.number().min(0).max(1),
1561
+ y: import_zod8.z.number().min(0).max(1),
1562
+ width: import_zod8.z.number().min(0).max(1),
1563
+ height: import_zod8.z.number().min(0).max(1)
1455
1564
  });
1456
- var CapturedElementSchema = import_zod7.z.object({
1565
+ var CapturedElementSchema = import_zod8.z.object({
1457
1566
  /** Visible name: aria-label, associated label, text, placeholder, alt or title. */
1458
- label: import_zod7.z.string().max(200).default(""),
1567
+ label: import_zod8.z.string().max(200).default(""),
1459
1568
  /** button, link, tab, menuitem, checkbox, radio, field, dropdown, option, element… */
1460
- role: import_zod7.z.string().max(40).default("element"),
1461
- tag: import_zod7.z.string().max(40).default("")
1569
+ role: import_zod8.z.string().max(40).default("element"),
1570
+ tag: import_zod8.z.string().max(40).default("")
1462
1571
  });
1463
- var CaptureStepSchema = import_zod7.z.object({
1572
+ var CaptureStepSchema = import_zod8.z.object({
1464
1573
  /** Random id from the SDK; a retried upload with the same id is stored once. */
1465
- clientId: import_zod7.z.string().min(1).max(64),
1466
- action: import_zod7.z.enum(HOWTO_ACTIONS),
1467
- url: import_zod7.z.string().max(2e3),
1468
- pageTitle: import_zod7.z.string().max(300).default(""),
1574
+ clientId: import_zod8.z.string().min(1).max(64),
1575
+ action: import_zod8.z.enum(HOWTO_ACTIONS),
1576
+ url: import_zod8.z.string().max(2e3),
1577
+ pageTitle: import_zod8.z.string().max(300).default(""),
1469
1578
  element: CapturedElementSchema.optional(),
1470
1579
  /** Typed text or chosen option; absent when it was sensitive (`valueRedacted`). */
1471
- value: import_zod7.z.string().max(200).optional(),
1472
- valueRedacted: import_zod7.z.boolean().default(false),
1580
+ value: import_zod8.z.string().max(200).optional(),
1581
+ valueRedacted: import_zod8.z.boolean().default(false),
1473
1582
  /** Selectors for the element, so the step can later become an interactive tour step. */
1474
- selectors: import_zod7.z.array(SelectorStrategySchema).max(10).default([]),
1583
+ selectors: import_zod8.z.array(SelectorStrategySchema).max(10).default([]),
1475
1584
  /** Where the element sits in the screenshot. */
1476
1585
  highlight: NormalizedRectSchema.optional(),
1477
1586
  /** Number of regions the SDK blurred in the screenshot before upload. */
1478
- redactions: import_zod7.z.number().int().min(0).max(1e3).default(0),
1479
- occurredAt: import_zod7.z.string().datetime().optional()
1587
+ redactions: import_zod8.z.number().int().min(0).max(1e3).default(0),
1588
+ occurredAt: import_zod8.z.string().datetime().optional()
1480
1589
  });
1481
1590
  function quoted(s) {
1482
1591
  const t = (s ?? "").replace(/\s+/g, " ").trim();
@@ -1490,8 +1599,8 @@ function cleanLabel(label) {
1490
1599
  var SEPARATORS = /\s+[·|•–—-]\s+|\s*[|·•]\s*/;
1491
1600
  var ID_SEGMENT = /^(?:\d+|[0-9a-f]{8,}(?:-[0-9a-f]{4,})*|[A-Za-z0-9_-]{20,})$/i;
1492
1601
  function humanize(segment) {
1493
- const words = decodeURIComponent(segment).replace(/[-_+]+/g, " ").trim();
1494
- return words ? words.charAt(0).toUpperCase() + words.slice(1) : "";
1602
+ const words2 = decodeURIComponent(segment).replace(/[-_+]+/g, " ").trim();
1603
+ return words2 ? words2.charAt(0).toUpperCase() + words2.slice(1) : "";
1495
1604
  }
1496
1605
  function pageName(url, pageTitle) {
1497
1606
  const title = (pageTitle ?? "").replace(/\s+/g, " ").trim();
@@ -1547,17 +1656,17 @@ function hostAndPath(url) {
1547
1656
  return url.slice(0, 80);
1548
1657
  }
1549
1658
  }
1550
- var NormalizedPointSchema = import_zod7.z.object({ x: import_zod7.z.number().min(0).max(1), y: import_zod7.z.number().min(0).max(1) });
1659
+ var NormalizedPointSchema = import_zod8.z.object({ x: import_zod8.z.number().min(0).max(1), y: import_zod8.z.number().min(0).max(1) });
1551
1660
  var ANNOTATION_COLORS = ["brand", "red", "amber", "green", "black", "white"];
1552
- var HowToAnnotationSchema = import_zod7.z.discriminatedUnion("type", [
1553
- import_zod7.z.object({ id: import_zod7.z.string().min(1).max(32), type: import_zod7.z.literal("arrow"), from: NormalizedPointSchema, to: NormalizedPointSchema, color: import_zod7.z.enum(ANNOTATION_COLORS).default("brand") }),
1554
- import_zod7.z.object({ id: import_zod7.z.string().min(1).max(32), type: import_zod7.z.literal("text"), at: NormalizedPointSchema, text: import_zod7.z.string().trim().min(1).max(120), color: import_zod7.z.enum(ANNOTATION_COLORS).default("brand") }),
1555
- import_zod7.z.object({ id: import_zod7.z.string().min(1).max(32), type: import_zod7.z.literal("box"), rect: NormalizedRectSchema, color: import_zod7.z.enum(ANNOTATION_COLORS).default("brand") })
1661
+ var HowToAnnotationSchema = import_zod8.z.discriminatedUnion("type", [
1662
+ import_zod8.z.object({ id: import_zod8.z.string().min(1).max(32), type: import_zod8.z.literal("arrow"), from: NormalizedPointSchema, to: NormalizedPointSchema, color: import_zod8.z.enum(ANNOTATION_COLORS).default("brand") }),
1663
+ import_zod8.z.object({ id: import_zod8.z.string().min(1).max(32), type: import_zod8.z.literal("text"), at: NormalizedPointSchema, text: import_zod8.z.string().trim().min(1).max(120), color: import_zod8.z.enum(ANNOTATION_COLORS).default("brand") }),
1664
+ import_zod8.z.object({ id: import_zod8.z.string().min(1).max(32), type: import_zod8.z.literal("box"), rect: NormalizedRectSchema, color: import_zod8.z.enum(ANNOTATION_COLORS).default("brand") })
1556
1665
  ]);
1557
1666
  var MAX_ANNOTATIONS = 30;
1558
1667
 
1559
1668
  // src/page.ts
1560
- var PATH_ID_PATTERN = "/([0-9]+|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|[0-9a-f]{12,})(?=/|$)";
1669
+ var PATH_ID_PATTERN = "/([0-9]+|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|[0-9a-f]{12,})(?=[/?]|$)";
1561
1670
  function foldPathIds(path) {
1562
1671
  return path.replace(new RegExp(PATH_ID_PATTERN, "gi"), "/:id");
1563
1672
  }
@@ -1567,15 +1676,15 @@ function segmentsOf(path) {
1567
1676
  return clean.split("/").map((s) => s.replace(/\.(html?|php|aspx?)$/, "")).filter((s) => !GENERIC_SEGMENTS.has(s) && /[a-z]/.test(s) && s.length <= 40);
1568
1677
  }
1569
1678
  function pageTerms(path) {
1570
- const words = segmentsOf(path).flatMap((s) => s.split(/[-_.+\s]+/).filter((w) => w.length > 1 && /[a-z]/.test(w)));
1571
- return [...new Set(words)].slice(0, 8);
1679
+ const words2 = segmentsOf(path).flatMap((s) => s.split(/[-_.+\s]+/).filter((w) => w.length > 1 && /[a-z]/.test(w)));
1680
+ return [...new Set(words2)].slice(0, 8);
1572
1681
  }
1573
1682
  function pageLabel(path) {
1574
1683
  const last = segmentsOf(path).at(-1);
1575
1684
  if (!last) return null;
1576
- const words = last.split(/[-_.+\s]+/).filter(Boolean);
1577
- if (!words.length) return null;
1578
- const label = words.join(" ");
1685
+ const words2 = last.split(/[-_.+\s]+/).filter(Boolean);
1686
+ if (!words2.length) return null;
1687
+ const label = words2.join(" ");
1579
1688
  return label.charAt(0).toUpperCase() + label.slice(1);
1580
1689
  }
1581
1690
  function firstNameFromTraits(traits) {
@@ -1586,13 +1695,47 @@ function firstNameFromTraits(traits) {
1586
1695
  return first;
1587
1696
  }
1588
1697
 
1698
+ // src/snippet.ts
1699
+ var SCRIPT_STUB_METHODS = [
1700
+ "identify",
1701
+ "track",
1702
+ "page",
1703
+ "reset",
1704
+ "setAccount",
1705
+ "updateTraits",
1706
+ "setConsent",
1707
+ "startGuide",
1708
+ "stopGuide",
1709
+ "dismissGuide",
1710
+ "openMessenger",
1711
+ "closeMessenger",
1712
+ "showNewMessage",
1713
+ "openResourceCenter",
1714
+ "closeResourceCenter",
1715
+ "openChecklist",
1716
+ "closeChecklist",
1717
+ "completeChecklistTask",
1718
+ "openComplaint",
1719
+ "captureException",
1720
+ "on"
1721
+ ];
1722
+ var SCRIPT_STUB = `!function(w){if(w.Guidely)return;var g=w.Guidely={_q:[]},c=g._c={};function q(o,k){o[k]=function(){g._q.push([o===c?1:0,k,[].slice.call(arguments)])}}q(g,"init");"${SCRIPT_STUB_METHODS.join(" ")}".split(" ").forEach(function(k){q(c,k)});c.isFeatureEnabled=function(k,f){return!!f};c.getFeatureValue=function(k,f){return f};g.get=function(){return c}}(window);`;
1723
+ function scriptSnippet(scriptUrl, initOptions) {
1724
+ return `<script>
1725
+ ${SCRIPT_STUB}
1726
+ Guidely.init(${initOptions});
1727
+ </script>
1728
+ <script src="${scriptUrl}" async></script>`;
1729
+ }
1730
+
1589
1731
  // src/index.ts
1590
1732
  var SDK_API_VERSION = "v1";
1591
- var SHARED_VERSION = "0.8.0";
1733
+ var SHARED_VERSION = "0.10.0";
1592
1734
  // Annotate the CommonJS export names for ESM import in node:
1593
1735
  0 && (module.exports = {
1594
1736
  ADVANCE_ON,
1595
1737
  ANNOTATION_COLORS,
1738
+ ARTICLE_VISIBILITIES,
1596
1739
  AUTOCAPTURE_EVENTS,
1597
1740
  AppearanceSchema,
1598
1741
  AuthoringPickSchema,
@@ -1601,6 +1744,9 @@ var SHARED_VERSION = "0.8.0";
1601
1744
  ButtonSchema,
1602
1745
  CAPTURE_PARAM,
1603
1746
  CAPTURE_SCREENSHOT_MAX_BYTES,
1747
+ COMPLAINT_EVENTS,
1748
+ COMPLAINT_FIELD_TYPES,
1749
+ COMPLAINT_STATUSES,
1604
1750
  CaptureStepSchema,
1605
1751
  CapturedElementSchema,
1606
1752
  ChecklistConfigSchema,
@@ -1615,12 +1761,14 @@ var SHARED_VERSION = "0.8.0";
1615
1761
  ErrorTrackingSettingsSchema,
1616
1762
  EventBatchSchema,
1617
1763
  FILE_LINK_CLASS,
1764
+ FileComplaintSchema,
1618
1765
  FrequencySchema,
1619
1766
  GUIDELY_ID_ATTRIBUTE,
1620
1767
  GUIDE_KINDS,
1621
1768
  GUIDE_LIFECYCLE_EVENTS,
1622
1769
  GUIDE_STATUSES,
1623
1770
  GUIDE_TEMPLATES,
1771
+ GUIDE_VISIBILITIES,
1624
1772
  GuideConfigSchema,
1625
1773
  GuideStateUpdateSchema,
1626
1774
  HEATMAP_VIEWPORTS,
@@ -1628,8 +1776,14 @@ var SHARED_VERSION = "0.8.0";
1628
1776
  HOWTO_STEP_KINDS,
1629
1777
  HowToAnnotationSchema,
1630
1778
  IdentifyRequestSchema,
1779
+ LOGGED_IN_AUDIENCE,
1631
1780
  MAX_ANNOTATIONS,
1632
1781
  MAX_COLLECTION_DEPTH,
1782
+ MAX_COMPLAINT_ANSWER_LENGTH,
1783
+ MAX_COMPLAINT_ATTACHMENT_BYTES,
1784
+ MAX_COMPLAINT_CHOICES,
1785
+ MAX_COMPLAINT_FIELDS,
1786
+ MAX_COMPLAINT_LENGTH,
1633
1787
  MAX_MESSAGE_LENGTH,
1634
1788
  MAX_PROPERTY_BYTES,
1635
1789
  MAX_STACK_FRAMES,
@@ -1663,6 +1817,8 @@ var SHARED_VERSION = "0.8.0";
1663
1817
  ReplaySettingsSchema,
1664
1818
  RuleGroupSchema,
1665
1819
  RuleSchema,
1820
+ SCRIPT_STUB,
1821
+ SCRIPT_STUB_METHODS,
1666
1822
  SDK_API_VERSION,
1667
1823
  SELECTOR_KINDS,
1668
1824
  SENSITIVE_HEADER_PATTERN,
@@ -1670,6 +1826,8 @@ var SHARED_VERSION = "0.8.0";
1670
1826
  SENSITIVE_PROPERTY_PATTERN,
1671
1827
  SERVER_ASSISTED_FIELDS,
1672
1828
  SHARED_VERSION,
1829
+ SHOW_ME_CLASS,
1830
+ SHOW_ME_HREF_PREFIX,
1673
1831
  SOURCEMAP_MAX_FILES_PER_UPLOAD,
1674
1832
  SOURCEMAP_MAX_FILE_BYTES,
1675
1833
  STATUS_LEVELS,
@@ -1693,6 +1851,7 @@ var SHARED_VERSION = "0.8.0";
1693
1851
  cleanLabel,
1694
1852
  compare,
1695
1853
  compareVersions,
1854
+ complaintReference,
1696
1855
  defaultGuideConfig,
1697
1856
  defaultStep,
1698
1857
  describeCaptureStep,
@@ -1707,6 +1866,7 @@ var SHARED_VERSION = "0.8.0";
1707
1866
  getPath,
1708
1867
  guidePlatforms,
1709
1868
  guidelyIdFromSelector,
1869
+ hasVideoMedia,
1710
1870
  isAllowedEmbedSrc,
1711
1871
  isArticleListed,
1712
1872
  isChecklistComplete,
@@ -1719,6 +1879,7 @@ var SHARED_VERSION = "0.8.0";
1719
1879
  isVideoContentType,
1720
1880
  matchUrlPattern,
1721
1881
  matchesAudiences,
1882
+ matchesHelpQuery,
1722
1883
  mediaKind,
1723
1884
  mediaMaxBytes,
1724
1885
  normalizeErrorMessage,
@@ -1734,6 +1895,11 @@ var SHARED_VERSION = "0.8.0";
1734
1895
  safeRegExp,
1735
1896
  sanitizeProperties,
1736
1897
  screenPath,
1898
+ scriptSnippet,
1899
+ servedArticleAudiences,
1900
+ showMeHref,
1901
+ showMeKeyFromHref,
1902
+ showMeKeys,
1737
1903
  slugify,
1738
1904
  stripOrigin,
1739
1905
  supportsPlatform,
@@ -1741,6 +1907,8 @@ var SHARED_VERSION = "0.8.0";
1741
1907
  toEmbedUrl,
1742
1908
  validateGuideConfig,
1743
1909
  visibleArticleIds,
1744
- visibleButtons
1910
+ visibleButtons,
1911
+ visitorAudiences,
1912
+ withVisibility
1745
1913
  });
1746
1914
  //# sourceMappingURL=index.cjs.map