@knocklabs/react 0.11.11 → 0.11.13

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/cjs/index.css +1 -1
  3. package/dist/cjs/index.js +1 -1
  4. package/dist/cjs/modules/guide/components/Toolbar/V2/FocusChin.js +2 -0
  5. package/dist/cjs/modules/guide/components/Toolbar/V2/FocusChin.js.map +1 -0
  6. package/dist/cjs/modules/guide/components/Toolbar/V2/GuideAnnotatedStatusDot.js +1 -1
  7. package/dist/cjs/modules/guide/components/Toolbar/V2/GuideAnnotatedStatusDot.js.map +1 -1
  8. package/dist/cjs/modules/guide/components/Toolbar/V2/GuideContextDetails.js +1 -1
  9. package/dist/cjs/modules/guide/components/Toolbar/V2/GuideContextDetails.js.map +1 -1
  10. package/dist/cjs/modules/guide/components/Toolbar/V2/GuideRow.js +1 -1
  11. package/dist/cjs/modules/guide/components/Toolbar/V2/GuideRow.js.map +1 -1
  12. package/dist/cjs/modules/guide/components/Toolbar/V2/GuideRowDetails.js +1 -1
  13. package/dist/cjs/modules/guide/components/Toolbar/V2/GuideRowDetails.js.map +1 -1
  14. package/dist/cjs/modules/guide/components/Toolbar/V2/V2.js +1 -1
  15. package/dist/cjs/modules/guide/components/Toolbar/V2/V2.js.map +1 -1
  16. package/dist/cjs/modules/guide/components/Toolbar/V2/helpers.js +1 -1
  17. package/dist/cjs/modules/guide/components/Toolbar/V2/helpers.js.map +1 -1
  18. package/dist/cjs/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.js +1 -1
  19. package/dist/cjs/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.js.map +1 -1
  20. package/dist/cjs/modules/guide/providers/KnockGuideProvider.js +1 -1
  21. package/dist/cjs/modules/guide/providers/KnockGuideProvider.js.map +1 -1
  22. package/dist/esm/index.mjs +99 -98
  23. package/dist/esm/index.mjs.map +1 -1
  24. package/dist/esm/modules/guide/components/Toolbar/V2/FocusChin.mjs +80 -0
  25. package/dist/esm/modules/guide/components/Toolbar/V2/FocusChin.mjs.map +1 -0
  26. package/dist/esm/modules/guide/components/Toolbar/V2/GuideAnnotatedStatusDot.mjs +6 -5
  27. package/dist/esm/modules/guide/components/Toolbar/V2/GuideAnnotatedStatusDot.mjs.map +1 -1
  28. package/dist/esm/modules/guide/components/Toolbar/V2/GuideContextDetails.mjs +30 -10
  29. package/dist/esm/modules/guide/components/Toolbar/V2/GuideContextDetails.mjs.map +1 -1
  30. package/dist/esm/modules/guide/components/Toolbar/V2/GuideRow.mjs +69 -97
  31. package/dist/esm/modules/guide/components/Toolbar/V2/GuideRow.mjs.map +1 -1
  32. package/dist/esm/modules/guide/components/Toolbar/V2/GuideRowDetails.mjs +49 -31
  33. package/dist/esm/modules/guide/components/Toolbar/V2/GuideRowDetails.mjs.map +1 -1
  34. package/dist/esm/modules/guide/components/Toolbar/V2/V2.mjs +119 -103
  35. package/dist/esm/modules/guide/components/Toolbar/V2/V2.mjs.map +1 -1
  36. package/dist/esm/modules/guide/components/Toolbar/V2/helpers.mjs +8 -46
  37. package/dist/esm/modules/guide/components/Toolbar/V2/helpers.mjs.map +1 -1
  38. package/dist/esm/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.mjs +106 -83
  39. package/dist/esm/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.mjs.map +1 -1
  40. package/dist/esm/modules/guide/providers/KnockGuideProvider.mjs +12 -10
  41. package/dist/esm/modules/guide/providers/KnockGuideProvider.mjs.map +1 -1
  42. package/dist/index.css +1 -1
  43. package/dist/types/modules/guide/components/Toolbar/V2/FocusChin.d.ts +9 -0
  44. package/dist/types/modules/guide/components/Toolbar/V2/FocusChin.d.ts.map +1 -0
  45. package/dist/types/modules/guide/components/Toolbar/V2/GuideAnnotatedStatusDot.d.ts.map +1 -1
  46. package/dist/types/modules/guide/components/Toolbar/V2/GuideContextDetails.d.ts.map +1 -1
  47. package/dist/types/modules/guide/components/Toolbar/V2/GuideHoverCard.d.ts +2 -2
  48. package/dist/types/modules/guide/components/Toolbar/V2/GuideHoverCard.d.ts.map +1 -1
  49. package/dist/types/modules/guide/components/Toolbar/V2/GuideRow.d.ts +3 -2
  50. package/dist/types/modules/guide/components/Toolbar/V2/GuideRow.d.ts.map +1 -1
  51. package/dist/types/modules/guide/components/Toolbar/V2/GuideRowDetails.d.ts +9 -2
  52. package/dist/types/modules/guide/components/Toolbar/V2/GuideRowDetails.d.ts.map +1 -1
  53. package/dist/types/modules/guide/components/Toolbar/V2/V2.d.ts +5 -1
  54. package/dist/types/modules/guide/components/Toolbar/V2/V2.d.ts.map +1 -1
  55. package/dist/types/modules/guide/components/Toolbar/V2/helpers.d.ts +8 -6
  56. package/dist/types/modules/guide/components/Toolbar/V2/helpers.d.ts.map +1 -1
  57. package/dist/types/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.d.ts +11 -7
  58. package/dist/types/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.d.ts.map +1 -1
  59. package/dist/types/modules/guide/providers/KnockGuideProvider.d.ts.map +1 -1
  60. package/package.json +5 -4
@@ -1,165 +1,188 @@
1
1
  import { checkStateIfThrottled as p, checkActivatable as y } from "@knocklabs/client";
2
- import { useGuideContext as _, useStore as b } from "@knocklabs/react-core";
3
- const g = (e) => e.reduce((t, s) => ({
2
+ import { useGuideContext as b, useStore as g } from "@knocklabs/react-core";
3
+ import { FOCUS_ERRORS as _ } from "./helpers.mjs";
4
+ const v = (e) => e.reduce((t, s) => ({
4
5
  ...t,
5
6
  [s.key]: s
6
- }), {}), v = (e, t, s, n) => {
7
- var r, o, i, d, u, l, c, f;
8
- const a = !!((d = (i = (o = (r = n.key) == null ? void 0 : r.one) == null ? void 0 : o.metadata) == null ? void 0 : i.opts) != null && d.includeThrottled) || !!((f = (c = (l = (u = n.key) == null ? void 0 : u.all) == null ? void 0 : l.metadata) == null ? void 0 : c.opts) != null && f.includeThrottled);
9
- return e.bypass_global_group_limit ? "returned" : e.key === s.resolved ? t.throttled && !a ? "throttled" : "returned" : "queried";
10
- }, h = (e, t, s, n) => {
11
- var o, i, d, u;
12
- const a = !!((u = (d = (i = (o = n.type) == null ? void 0 : o.one) == null ? void 0 : i.metadata) == null ? void 0 : d.opts) != null && u.includeThrottled), r = n.type.one;
13
- if (r.size === 0)
7
+ }), {}), h = (e, t, s, r) => {
8
+ var u, a, n, l, o, d, c, f;
9
+ const i = !!((l = (n = (a = (u = r.key) == null ? void 0 : u.one) == null ? void 0 : a.metadata) == null ? void 0 : n.opts) != null && l.includeThrottled) || !!((f = (c = (d = (o = r.key) == null ? void 0 : o.all) == null ? void 0 : d.metadata) == null ? void 0 : c.opts) != null && f.includeThrottled);
10
+ return e.bypass_global_group_limit ? "returned" : e.key === s.resolved ? t.throttled && !i ? "throttled" : "returned" : "queried";
11
+ }, G = (e, t, s, r) => {
12
+ var a, n, l, o;
13
+ const i = !!((o = (l = (n = (a = r.type) == null ? void 0 : a.one) == null ? void 0 : n.metadata) == null ? void 0 : l.opts) != null && o.includeThrottled), u = r.type.one;
14
+ if (u.size === 0)
14
15
  return "queried";
15
16
  if (e.bypass_global_group_limit) {
16
- const c = [...r.values()][0];
17
+ const c = [...u.values()][0];
17
18
  return e.key !== c.key ? "queried" : "returned";
18
19
  }
19
- return e.key === s.resolved ? t.throttled && !a ? "throttled" : "returned" : "queried";
20
- }, G = (e, t, s, n) => {
21
- var u, l, c, f;
22
- const a = n.type.all;
23
- if (a.size === 0)
20
+ return e.key === s.resolved ? t.throttled && !i ? "throttled" : "returned" : "queried";
21
+ }, m = (e, t, s, r) => {
22
+ var o, d, c, f;
23
+ const i = r.type.all;
24
+ if (i.size === 0)
24
25
  return "queried";
25
- const r = [...a.values()], o = r[0], i = g(r);
26
- return (f = (c = (l = (u = n.type) == null ? void 0 : u.all) == null ? void 0 : l.metadata) == null ? void 0 : c.opts) != null && f.includeThrottled ? i[e.key] ? "returned" : "queried" : (o.bypass_global_group_limit || o.key === s.resolved) && i[e.key] ? t.throttled ? e.bypass_global_group_limit ? "returned" : "throttled" : "returned" : "queried";
27
- }, S = (e, t, s, n) => {
28
- var a, r;
29
- if (n.key)
30
- return v(e, t, s, n);
31
- if ((a = n.type) != null && a.all)
32
- return G(e, t, s, n);
33
- if ((r = n.type) != null && r.one)
34
- return h(e, t, s, n);
26
+ const u = [...i.values()], a = u[0], n = v(u);
27
+ return (f = (c = (d = (o = r.type) == null ? void 0 : o.all) == null ? void 0 : d.metadata) == null ? void 0 : c.opts) != null && f.includeThrottled ? n[e.key] ? "returned" : "queried" : (a.bypass_global_group_limit || a.key === s.resolved) && n[e.key] ? t.throttled ? e.bypass_global_group_limit ? "returned" : "throttled" : "returned" : "queried";
28
+ }, S = (e, t, s, r) => {
29
+ var i, u;
30
+ if (r.key)
31
+ return h(e, t, s, r);
32
+ if ((i = r.type) != null && i.all)
33
+ return m(e, t, s, r);
34
+ if ((u = r.type) != null && u.one)
35
+ return G(e, t, s, r);
35
36
  }, T = (e, t, s) => {
36
37
  if (!s || s.status === "open")
37
38
  return {
38
39
  status: void 0
39
40
  };
40
- const n = {
41
+ const r = {
41
42
  key: (s.results.key || {})[e.key],
42
43
  type: (s.results.type || {})[e.type]
43
44
  };
44
- if (!!!(n.key || n.type))
45
+ if (!!!(r.key || r.type))
45
46
  return {
46
47
  status: void 0
47
48
  };
48
- const r = S(e, t, s, n);
49
- return r ? {
50
- status: r,
51
- query: n
49
+ const u = S(e, t, s, r);
50
+ return u ? {
51
+ status: u,
52
+ query: r
52
53
  } : {
53
54
  status: void 0
54
55
  };
55
- }, q = (e, t) => {
56
+ }, U = (e, t) => {
56
57
  const s = {};
57
58
  return ((t == null ? void 0 : t.reason) === "not_in_target_audience" || (t == null ? void 0 : t.reason) === "target_conditions_not_met") && (s.targetable = {
58
59
  status: !1,
59
60
  reason: t.reason,
60
61
  message: t.message
61
- }), ((t == null ? void 0 : t.reason) === "marked_as_archived" || (e.steps || []).every((n) => !!n.message.archived_at)) && (s.archived = {
62
+ }), ((t == null ? void 0 : t.reason) === "marked_as_archived" || (e.steps || []).every((r) => !!r.message.archived_at)) && (s.archived = {
62
63
  status: !0
63
64
  }), (t == null ? void 0 : t.reason) === "guide_not_active" && (s.active = {
64
65
  status: !1
65
66
  }), s;
66
- }, k = ({
67
+ }, q = ({
67
68
  active: e,
68
69
  targetable: t,
69
70
  archived: s
70
- }) => !(!e.status || !t.status || s.status), w = ({
71
+ }) => !(!e.status || !t.status || s.status), R = ({
71
72
  activatable: e,
72
73
  selectable: t
73
- }) => !(!e.status || !t.status), m = (e, t, s) => {
74
+ }) => !(!e.status || !t.status), w = (e, t, s, r) => {
74
75
  const {
75
- ineligibleGuides: n,
76
- location: a
77
- } = t, r = n[e.key], o = q(e, r), i = {
76
+ ineligibleGuides: i,
77
+ location: u
78
+ } = s, a = i[e.key], n = U(e, a), l = {
78
79
  // isEligible:
79
- active: (o == null ? void 0 : o.active) || {
80
+ active: (n == null ? void 0 : n.active) || {
80
81
  status: !0
81
82
  },
82
- targetable: (o == null ? void 0 : o.targetable) || {
83
+ targetable: (n == null ? void 0 : n.targetable) || {
83
84
  status: !0
84
85
  },
85
- archived: (o == null ? void 0 : o.archived) || {
86
+ archived: (n == null ? void 0 : n.archived) || {
86
87
  status: !1
87
88
  },
88
89
  // isQualified:
89
90
  activatable: {
90
- status: y(e, a)
91
+ status: y(e, u)
91
92
  },
92
- selectable: T(e, t, s)
93
- }, d = {
94
- ...i,
95
- isEligible: k(i),
96
- isQualified: w(i)
93
+ selectable: T(e, s, r)
94
+ }, o = {
95
+ ...l,
96
+ isEligible: q(l),
97
+ isQualified: R(l)
97
98
  };
98
99
  return {
99
100
  ...e,
100
- annotation: d
101
+ orderIndex: t,
102
+ annotation: o
101
103
  };
102
- }, B = (e) => ({
103
- __typename: "UnknownGuide",
104
+ }, C = (e, t) => ({
105
+ __typename: "UncommittedGuide",
104
106
  key: e,
107
+ orderIndex: t,
105
108
  active: !1,
106
109
  bypass_global_group_limit: !1,
107
110
  annotation: {
108
111
  isEligible: !1,
109
112
  isQualified: !1,
113
+ active: {
114
+ status: !1
115
+ },
110
116
  selectable: {
111
117
  status: void 0
112
118
  }
113
119
  }
114
- }), R = (e) => {
115
- var d;
120
+ }), k = (e) => {
121
+ var l;
116
122
  const {
117
123
  client: t
118
- } = _(), s = b(t.store, (u) => {
119
- const l = p(u);
124
+ } = b(), s = g(t.store, (o) => {
125
+ const d = p(o);
120
126
  return {
121
- location: u.location,
122
- guides: u.guides,
123
- guideGroups: u.guideGroups,
124
- ineligibleGuides: u.ineligibleGuides,
125
- debug: u.debug,
126
- counter: u.counter,
127
- queries: u.queries,
128
- throttled: l
127
+ location: o.location,
128
+ guides: o.guides,
129
+ guideGroups: o.guideGroups,
130
+ ineligibleGuides: o.ineligibleGuides,
131
+ debug: o.debug,
132
+ counter: o.counter,
133
+ queries: o.queries,
134
+ throttled: d
129
135
  };
130
136
  });
131
- if (!((d = s.debug) != null && d.debugging))
137
+ if (!((l = s.debug) != null && l.debugging))
132
138
  return;
133
- const n = Object.entries(s.queries)[0];
134
- if (!n || n[1].status === "loading")
139
+ const r = Object.entries(s.queries)[0];
140
+ if (!r || r[1].status === "loading")
135
141
  return {
136
142
  status: "error",
137
143
  error: "no_guides_fetched",
138
144
  message: "Loading..."
139
145
  };
140
- const a = s.guideGroups[0];
141
- if (!a)
146
+ const i = s.guideGroups[0];
147
+ if (!i)
142
148
  return {
143
149
  status: "error",
144
150
  error: "no_guide_group",
145
151
  message: "No guide group found"
146
152
  };
147
- const r = t.getStage(), o = a.display_sequence.map((u) => {
148
- const l = s.guides[u];
149
- return l ? m(l, s, r) : B(u);
150
- }), i = Object.keys(e.focusedGuideKeys || {})[0];
151
- return (r == null ? void 0 : r.status) === "closed" && i && !o.find((l) => l.key === i && l.annotation.selectable.status) ? {
152
- status: "error",
153
- error: "no_guide_present",
154
- message: `No component that can render \`${i}\` was found`
155
- } : {
153
+ const u = t.getStage(), a = i.display_sequence.map((o, d) => {
154
+ const c = s.guides[o];
155
+ return c ? w(c, d, s, u) : C(o, d);
156
+ }), n = Object.keys(e.focusedGuideKeys || {})[0];
157
+ if ((u == null ? void 0 : u.status) === "closed" && n) {
158
+ const o = a.find((d) => d.key === n);
159
+ if (!o)
160
+ return {
161
+ status: "error",
162
+ error: "focus_unknown_guide",
163
+ message: `Unable to display \`${n}\`, ${_.focusUnknownGuide.toLowerCase()}.`
164
+ };
165
+ if ($(o))
166
+ return {
167
+ status: "error",
168
+ error: "focus_uncommitted_guide",
169
+ message: `Unable to display \`${n}\`, ${_.focusUncommittedGuide.toLowerCase()}.`
170
+ };
171
+ if (!o.annotation.selectable.status)
172
+ return {
173
+ status: "error",
174
+ error: "focus_unselectable_guide",
175
+ message: `Unable to display \`${n}\`, ${_.focusUnselectableGuide.toLowerCase()}.`
176
+ };
177
+ }
178
+ return {
156
179
  status: "ok",
157
- guides: o
180
+ guides: a
158
181
  };
159
- }, U = (e) => typeof e == "object" && e !== null && "__typename" in e && e.__typename === "UnknownGuide";
182
+ }, $ = (e) => typeof e == "object" && e !== null && "__typename" in e && e.__typename === "UncommittedGuide";
160
183
  export {
161
- U as isUnknownGuide,
162
- w as resolveIsQualified,
163
- R as useInspectGuideClientStore
184
+ $ as isUncommittedGuide,
185
+ R as resolveIsQualified,
186
+ k as useInspectGuideClientStore
164
187
  };
165
188
  //# sourceMappingURL=useInspectGuideClientStore.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useInspectGuideClientStore.mjs","sources":["../../../../../../../src/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.ts"],"sourcesContent":["import {\n KnockGuide,\n KnockGuideClientGroupStage,\n KnockGuideClientStoreState,\n KnockGuideIneligibilityMarker,\n KnockGuideSelectionResult,\n checkActivatable,\n checkStateIfThrottled,\n} from \"@knocklabs/client\";\nimport { useGuideContext, useStore } from \"@knocklabs/react-core\";\n\nimport { ToolbarV2RunConfig } from \"./helpers\";\n\nconst byKey = <T extends { key: string }>(items: T[]) => {\n return items.reduce((acc, item) => ({ ...acc, [item.key]: item }), {});\n};\n\n/**\n * This is the main module that will house core logic for the toolbar. It hooks\n * into the guide client state store, extracts relevant data for debugging, and\n * transforms it into easily consumable data for the toolbar - namely\n * \"annotating\" guides for its various statuses to display.\n */\n\n// Active: `true` status = good\ntype ActiveStatus = {\n status: boolean;\n};\n\n// Targetable: `true` status = good\ntype TargetableStatusTrue = {\n status: true;\n};\ntype TargetableStatusFalse = {\n status: false;\n reason: string;\n message: string;\n};\ntype TargetableStatus = TargetableStatusTrue | TargetableStatusFalse;\n\ntype ActivatableStatus = {\n status: boolean;\n};\n\n// Archived: `false` status = good\ntype ArchivedStatus = {\n status: boolean;\n};\n\n// Selectable:\n// - \"returned\": Queried and resolved to return the guide from useGuide(s).\n// - \"throttled\": Queried and resolved but being throttled, so not yet returned.\n// - \"queried\": Queried but not resolved, because there are other higher\n// priority guides that are ahead of this guide in the query result.\n// - undefined: Not reachable with any of the given queries and filters.\ntype SelectionResultByLimit = {\n one?: KnockGuideSelectionResult;\n all?: KnockGuideSelectionResult;\n};\ntype SelectionResultByQuery = {\n key?: SelectionResultByLimit;\n type?: SelectionResultByLimit;\n};\ntype SelectableStatusPresent = {\n status: \"returned\" | \"throttled\" | \"queried\";\n query: SelectionResultByQuery;\n};\ntype SelectableStatusAbsent = {\n status: undefined;\n};\ntype SelectableStatus = SelectableStatusPresent | SelectableStatusAbsent;\n\nexport type AnnotatedStatuses = {\n // Individual eligibility statuses:\n active: ActiveStatus;\n targetable: TargetableStatus;\n archived: ArchivedStatus;\n // Individual qualified statuses:\n activatable: ActivatableStatus;\n selectable: SelectableStatus;\n};\n\ntype GuideAnnotation = AnnotatedStatuses & {\n // Resolved eligibility based on active, targetable and archived statuses,\n // which are backend driven evaluation results that are exposed for debugging.\n isEligible: boolean;\n\n // Resolved display qualification based on an activatable status, which\n // informs \"when\" and \"where\" an eligible guide can be displayed to user.\n isQualified: boolean;\n};\n\nexport type AnnotatedGuide = KnockGuide & {\n annotation: GuideAnnotation;\n\n // Legacy fields, typed only to make tsc happy when we prune these out.\n activation_location_rules?: KnockGuide[\"activation_url_patterns\"];\n priority?: number;\n};\n\n// Exists and ordered in control but absent in switchboard (therefore not\n// included in the api response), which implies a newly created guide that has\n// never been published to switchboard.\nexport type UnknownGuide = {\n __typename: \"UnknownGuide\";\n key: KnockGuide[\"key\"];\n active: false;\n bypass_global_group_limit: false;\n annotation: {\n isEligible: false;\n isQualified: false;\n selectable: {\n status: undefined;\n };\n };\n};\n\nexport type InspectionResultOk = {\n status: \"ok\";\n guides: (AnnotatedGuide | UnknownGuide)[];\n};\ntype InspectionResultError = {\n status: \"error\";\n error: \"no_guides_fetched\" | \"no_guide_group\" | \"no_guide_present\";\n message: string;\n};\ntype InspectionResult = InspectionResultOk | InspectionResultError;\n\ntype StoreStateSnapshot = Pick<\n KnockGuideClientStoreState,\n | \"location\"\n | \"guides\"\n | \"guideGroups\"\n | \"ineligibleGuides\"\n | \"debug\"\n | \"counter\"\n | \"queries\"\n> & {\n throttled: boolean;\n};\n\nconst inferSelectByKeyReturnStatus = (\n guide: KnockGuide,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage,\n query: SelectionResultByQuery,\n): SelectableStatusPresent[\"status\"] => {\n const includeThrottled =\n !!query.key?.one?.metadata?.opts?.includeThrottled ||\n !!query.key?.all?.metadata?.opts?.includeThrottled;\n\n // If unthrottled, then it should always be returned.\n if (guide.bypass_global_group_limit) {\n return \"returned\";\n }\n\n // If resolved, expect this guide to be returned unless being throttled.\n if (guide.key === stage.resolved) {\n if (snapshot.throttled && !includeThrottled) {\n return \"throttled\";\n }\n return \"returned\";\n }\n\n // If queried but not resolved, it means this guide is being shadowed by\n // another guide with higher priority because throttled guides can be\n // displayed only one at a time.\n return \"queried\";\n};\n\nconst inferSelectOneByTypeReturnStatus = (\n guide: KnockGuide,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage,\n query: SelectionResultByQuery,\n): SelectableStatusPresent[\"status\"] => {\n const includeThrottled = !!query.type?.one?.metadata?.opts?.includeThrottled;\n\n const result = query.type!.one!;\n if (result.size === 0) {\n return \"queried\";\n }\n\n // There may be multiple unthrottled guides of the same type, being queried\n // by type to return a single guide, for example: useGuide({ type: \"card\" }).\n //\n // So it is possible for an unthrottled guide to be shadowed by another\n // unthrottled guide of the same type with higher priority, so we need to\n // look at the query result to determine its return status.\n if (guide.bypass_global_group_limit) {\n const guides = [...result.values()];\n const first = guides[0]!;\n\n if (guide.key !== first.key) {\n // Being shadowed by another guide with higher priority.\n return \"queried\";\n }\n return \"returned\";\n }\n\n // If resolved, expect this guide to be returned unless being throttled.\n if (guide.key === stage.resolved) {\n if (snapshot.throttled && !includeThrottled) {\n return \"throttled\";\n }\n return \"returned\";\n }\n\n // If queried but not resolved, it means this guide is being shadowed by\n // another guide with higher priority because throttled guides can be\n // displayed only one at a time.\n return \"queried\";\n};\n\nconst inferSelectAllByTypeReturnStatus = (\n guide: KnockGuide,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage,\n query: SelectionResultByQuery,\n): SelectableStatusPresent[\"status\"] => {\n const result = query.type!.all!;\n if (result.size === 0) {\n return \"queried\";\n }\n\n const guides = [...result.values()];\n const first = guides[0]!;\n\n // Might want to consider moving this up to do once.\n const guidesByKey: Record<KnockGuide[\"key\"], KnockGuide> = byKey(guides);\n\n // If includeThrottled given, then expect all selected guides to be returned.\n const includeThrottled = !!query.type?.all?.metadata?.opts?.includeThrottled;\n if (includeThrottled) {\n return guidesByKey[guide.key] ? \"returned\" : \"queried\";\n }\n\n // If the first selected guide is unthrottled or resolved, then we should\n // have at minimum one guide to return, and potentially more based on whether\n // we are throttling currently and which other guides are unthrottled.\n if (first.bypass_global_group_limit || first.key === stage.resolved) {\n if (!guidesByKey[guide.key]) {\n return \"queried\";\n }\n if (snapshot.throttled) {\n return guide.bypass_global_group_limit ? \"returned\" : \"throttled\";\n }\n return \"returned\";\n }\n\n return \"queried\";\n};\n\nconst inferSelectReturnStatus = (\n guide: KnockGuide,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage,\n query: SelectionResultByQuery,\n) => {\n // Querying by key can only return up to a max of one guide, regardless of\n // useGuide or useGuides, and should take precedence in status designation.\n if (query.key) {\n return inferSelectByKeyReturnStatus(guide, snapshot, stage, query);\n }\n\n if (query.type?.all) {\n return inferSelectAllByTypeReturnStatus(guide, snapshot, stage, query);\n }\n if (query.type?.one) {\n return inferSelectOneByTypeReturnStatus(guide, snapshot, stage, query);\n }\n\n // Should not happen but just for completeness.\n return undefined;\n};\n\nconst toSelectableStatus = (\n guide: KnockGuide,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage | undefined,\n): SelectableStatus => {\n if (!stage || stage.status === \"open\") {\n return { status: undefined };\n }\n\n const query = {\n key: (stage.results.key || {})[guide.key],\n type: (stage.results.type || {})[guide.type],\n };\n\n const queried = Boolean(query.key || query.type);\n if (!queried) {\n // No present query in the current location can select this guide.\n return { status: undefined };\n }\n\n const status = inferSelectReturnStatus(guide, snapshot, stage, query);\n if (!status) {\n return { status: undefined };\n }\n\n return { status, query };\n};\n\nconst toIneligibilityStatus = (\n guide: KnockGuide,\n marker?: KnockGuideIneligibilityMarker,\n): Partial<AnnotatedStatuses> => {\n const statuses: Partial<AnnotatedStatuses> = {};\n\n if (\n marker?.reason === \"not_in_target_audience\" ||\n marker?.reason === \"target_conditions_not_met\"\n ) {\n statuses.targetable = {\n status: false,\n reason: marker.reason,\n message: marker.message,\n };\n }\n\n if (\n marker?.reason === \"marked_as_archived\" ||\n (guide.steps || []).every((s) => !!s.message.archived_at)\n ) {\n statuses.archived = {\n status: true,\n };\n }\n\n if (marker?.reason === \"guide_not_active\") {\n statuses.active = {\n status: false,\n };\n }\n\n return statuses;\n};\n\nconst resolveIsEligible = ({\n active,\n targetable,\n archived,\n}: AnnotatedStatuses) => {\n if (!active.status) return false;\n if (!targetable.status) return false;\n if (archived.status) return false;\n return true;\n};\n\nexport const resolveIsQualified = ({\n activatable,\n selectable,\n}: AnnotatedStatuses) => {\n if (!activatable.status) return false;\n if (!selectable.status) return false;\n return true;\n};\n\nconst annotateGuide = (\n guide: KnockGuide,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage | undefined,\n): AnnotatedGuide => {\n const { ineligibleGuides, location } = snapshot;\n const marker = ineligibleGuides[guide.key];\n const ineligiblity = toIneligibilityStatus(guide, marker);\n\n const statuses: AnnotatedStatuses = {\n // isEligible:\n active: ineligiblity?.active || { status: true },\n targetable: ineligiblity?.targetable || { status: true },\n archived: ineligiblity?.archived || { status: false },\n // isQualified:\n activatable: { status: checkActivatable(guide, location) },\n selectable: toSelectableStatus(guide, snapshot, stage),\n };\n\n const annotation: GuideAnnotation = {\n ...statuses,\n isEligible: resolveIsEligible(statuses),\n isQualified: resolveIsQualified(statuses),\n };\n\n return {\n ...guide,\n annotation,\n };\n};\n\nconst newUnknownGuide = (key: KnockGuide[\"key\"]) =>\n ({\n __typename: \"UnknownGuide\",\n key,\n active: false,\n bypass_global_group_limit: false,\n annotation: {\n isEligible: false,\n isQualified: false,\n selectable: {\n status: undefined,\n },\n },\n }) as UnknownGuide;\n\nexport const useInspectGuideClientStore = (\n runConfig: ToolbarV2RunConfig,\n): InspectionResult | undefined => {\n const { client } = useGuideContext();\n\n // Extract a snapshot of the client store state for debugging.\n const snapshot: StoreStateSnapshot = useStore(client.store, (state) => {\n const throttled = checkStateIfThrottled(state);\n\n return {\n location: state.location,\n guides: state.guides,\n guideGroups: state.guideGroups,\n ineligibleGuides: state.ineligibleGuides,\n debug: state.debug,\n counter: state.counter,\n queries: state.queries,\n throttled,\n };\n });\n\n // Not in debugging session, so noop.\n if (!snapshot.debug?.debugging) {\n return undefined;\n }\n\n // No recorded fetch requests, which implies an inflight request loading.\n const req = Object.entries(snapshot.queries)[0];\n if (!req || req[1].status === \"loading\") {\n return {\n status: \"error\",\n error: \"no_guides_fetched\",\n message: \"Loading...\",\n };\n }\n\n // Should always be a default group so this should never happen.\n const defaultGroup = snapshot.guideGroups[0];\n if (!defaultGroup) {\n return {\n status: \"error\",\n error: \"no_guide_group\",\n message: \"No guide group found\",\n };\n }\n\n const groupStage = client.getStage();\n\n // Annotate guides for various eligibility, activation and query statuses\n // that are useful for debugging purposes.\n const orderedGuides = defaultGroup.display_sequence.map((guideKey) => {\n const guide = snapshot.guides[guideKey];\n if (!guide) {\n return newUnknownGuide(guideKey);\n }\n\n return annotateGuide(guide, snapshot, groupStage);\n });\n\n // Check if the focused guide actually exists and is selectable on the page.\n const focusedGuideKey = Object.keys(runConfig.focusedGuideKeys || {})[0];\n if (groupStage?.status === \"closed\" && focusedGuideKey) {\n const focusableGuide = orderedGuides.find(\n (g) => g.key === focusedGuideKey && g.annotation.selectable.status,\n );\n if (!focusableGuide) {\n return {\n status: \"error\",\n error: \"no_guide_present\",\n message: `No component that can render \\`${focusedGuideKey}\\` was found`,\n };\n }\n }\n\n return {\n status: \"ok\",\n guides: orderedGuides,\n };\n};\n\nexport const isUnknownGuide = (input: unknown): input is UnknownGuide =>\n typeof input === \"object\" &&\n input !== null &&\n \"__typename\" in input &&\n (input as UnknownGuide).__typename === \"UnknownGuide\";\n"],"names":["byKey","items","reduce","acc","item","key","inferSelectByKeyReturnStatus","guide","snapshot","stage","query","includeThrottled","one","metadata","opts","all","bypass_global_group_limit","resolved","throttled","inferSelectOneByTypeReturnStatus","type","result","size","first","values","inferSelectAllByTypeReturnStatus","guides","guidesByKey","inferSelectReturnStatus","toSelectableStatus","status","undefined","results","Boolean","toIneligibilityStatus","marker","statuses","reason","targetable","message","steps","every","s","archived_at","archived","active","resolveIsEligible","resolveIsQualified","activatable","selectable","annotateGuide","ineligibleGuides","location","ineligiblity","checkActivatable","annotation","isEligible","isQualified","newUnknownGuide","__typename","useInspectGuideClientStore","runConfig","client","useGuideContext","useStore","store","state","checkStateIfThrottled","guideGroups","debug","counter","queries","debugging","req","Object","entries","error","defaultGroup","groupStage","getStage","orderedGuides","display_sequence","map","guideKey","focusedGuideKey","keys","focusedGuideKeys","find","g","isUnknownGuide","input"],"mappings":";;AAaA,MAAMA,IAAQ,CAA4BC,MACjCA,EAAMC,OAAO,CAACC,GAAKC,OAAU;AAAA,EAAE,GAAGD;AAAAA,EAAK,CAACC,EAAKC,GAAG,GAAGD;AAAK,IAAI,CAAA,CAAE,GA+HjEE,IAA+BA,CACnCC,GACAC,GACAC,GACAC,MACsC;;AACtC,QAAMC,IACJ,CAAC,GAACD,KAAAA,KAAAA,KAAAA,IAAAA,EAAML,QAANK,gBAAAA,EAAWE,QAAXF,gBAAAA,EAAgBG,aAAhBH,gBAAAA,EAA0BI,SAA1BJ,QAAAA,EAAgCC,qBAClC,CAAC,GAACD,KAAAA,KAAAA,KAAAA,IAAAA,EAAML,QAANK,gBAAAA,EAAWK,QAAXL,gBAAAA,EAAgBG,aAAhBH,gBAAAA,EAA0BI,SAA1BJ,QAAAA,EAAgCC;AAGpC,SAAIJ,EAAMS,4BACD,aAILT,EAAMF,QAAQI,EAAMQ,WAClBT,EAASU,aAAa,CAACP,IAClB,cAEF,aAMF;AACT,GAEMQ,IAAmCA,CACvCZ,GACAC,GACAC,GACAC,MACsC;;AACtC,QAAMC,IAAmB,CAAC,GAACD,KAAAA,KAAAA,KAAAA,IAAAA,EAAMU,SAANV,gBAAAA,EAAYE,QAAZF,gBAAAA,EAAiBG,aAAjBH,gBAAAA,EAA2BI,SAA3BJ,QAAAA,EAAiCC,mBAEtDU,IAASX,EAAMU,KAAMR;AACvBS,MAAAA,EAAOC,SAAS;AACX,WAAA;AAST,MAAIf,EAAMS,2BAA2B;AAE7BO,UAAAA,IADS,CAAC,GAAGF,EAAOG,QAAQ,EACb,CAAC;AAElBjB,WAAAA,EAAMF,QAAQkB,EAAMlB,MAEf,YAEF;AAAA,EAAA;AAILE,SAAAA,EAAMF,QAAQI,EAAMQ,WAClBT,EAASU,aAAa,CAACP,IAClB,cAEF,aAMF;AACT,GAEMc,IAAmCA,CACvCl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A;AAAAA,IACF;AAAA,EAAA,CACD;AAGG,MAAA,GAACV,IAAAA,EAAS6D,UAAT7D,QAAAA,EAAgBgE;AACZzC;AAIT,QAAM0C,IAAMC,OAAOC,QAAQnE,EAAS+D,OAAO,EAAE,CAAC;AAC9C,MAAI,CAACE,KAAOA,EAAI,CAAC,EAAE3C,WAAW;AACrB,WAAA;AAAA,MACLA,QAAQ;AAAA,MACR8C,OAAO;AAAA,MACPrC,SAAS;AAAA,IACX;AAIIsC,QAAAA,IAAerE,EAAS4D,YAAY,CAAC;AAC3C,MAAI,CAACS;AACI,WAAA;AAAA,MACL/C,QAAQ;AAAA,MACR8C,OAAO;AAAA,MACPrC,SAAS;AAAA,IACX;AAGIuC,QAAAA,IAAahB,EAAOiB,SAAS,GAI7BC,IAAgBH,EAAaI,iBAAiBC,IAAKC,CAAaA,MAAA;AAC9D5E,UAAAA,IAAQC,EAASkB,OAAOyD,CAAQ;AACtC,WAAK5E,IAIE2C,EAAc3C,GAAOC,GAAUsE,CAAU,IAHvCpB,EAAgByB,CAAQ;AAAA,EAGe,CACjD,GAGKC,IAAkBV,OAAOW,KAAKxB,EAAUyB,oBAAoB,CAAA,CAAE,EAAE,CAAC;AACnER,UAAAA,KAAAA,gBAAAA,EAAYhD,YAAW,YAAYsD,KAIjC,CAHmBJ,EAAcO,KAClCC,CAAMA,MAAAA,EAAEnF,QAAQ+E,KAAmBI,EAAEjC,WAAWN,WAAWnB,MAC9D,IAES;AAAA,IACLA,QAAQ;AAAA,IACR8C,OAAO;AAAA,IACPrC,SAAS,kCAAkC6C,CAAe;AAAA,EAC5D,IAIG;AAAA,IACLtD,QAAQ;AAAA,IACRJ,QAAQsD;AAAAA,EACV;AACF,GAEaS,IAAiBA,CAACC,MAC7B,OAAOA,KAAU,YACjBA,MAAU,QACV,gBAAgBA,KACfA,EAAuB/B,eAAe;"}
1
+ {"version":3,"file":"useInspectGuideClientStore.mjs","sources":["../../../../../../../src/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.ts"],"sourcesContent":["import {\n KnockGuide,\n KnockGuideClientGroupStage,\n KnockGuideClientStoreState,\n KnockGuideIneligibilityMarker,\n KnockGuideSelectionResult,\n type ToolbarV2RunConfig,\n checkActivatable,\n checkStateIfThrottled,\n} from \"@knocklabs/client\";\nimport { useGuideContext, useStore } from \"@knocklabs/react-core\";\n\nimport { FOCUS_ERRORS } from \"./helpers\";\n\nconst byKey = <T extends { key: string }>(items: T[]) => {\n return items.reduce((acc, item) => ({ ...acc, [item.key]: item }), {});\n};\n\n/**\n * This is the main module that will house core logic for the toolbar. It hooks\n * into the guide client state store, extracts relevant data for debugging, and\n * transforms it into easily consumable data for the toolbar - namely\n * \"annotating\" guides for its various statuses to display.\n */\n\n// Active: `true` status = good\ntype ActiveStatus = {\n status: boolean;\n};\n\n// Targetable: `true` status = good\ntype TargetableStatusTrue = {\n status: true;\n};\ntype TargetableStatusFalse = {\n status: false;\n reason: string;\n message: string;\n};\ntype TargetableStatus = TargetableStatusTrue | TargetableStatusFalse;\n\ntype ActivatableStatus = {\n status: boolean;\n};\n\n// Archived: `false` status = good\ntype ArchivedStatus = {\n status: boolean;\n};\n\n// Selectable:\n// - \"returned\": Queried and resolved to return the guide from useGuide(s).\n// - \"throttled\": Queried and resolved but being throttled, so not yet returned.\n// - \"queried\": Queried but not resolved, because there are other higher\n// priority guides that are ahead of this guide in the query result.\n// - undefined: Not reachable with any of the given queries and filters.\ntype SelectionResultByLimit = {\n one?: KnockGuideSelectionResult;\n all?: KnockGuideSelectionResult;\n};\ntype SelectionResultByQuery = {\n key?: SelectionResultByLimit;\n type?: SelectionResultByLimit;\n};\ntype SelectableStatusPresent = {\n status: \"returned\" | \"throttled\" | \"queried\";\n query: SelectionResultByQuery;\n};\ntype SelectableStatusAbsent = {\n status: undefined;\n};\ntype SelectableStatus = SelectableStatusPresent | SelectableStatusAbsent;\n\nexport type AnnotatedStatuses = {\n // Individual eligibility statuses:\n active: ActiveStatus;\n targetable: TargetableStatus;\n archived: ArchivedStatus;\n // Individual qualified statuses:\n activatable: ActivatableStatus;\n selectable: SelectableStatus;\n};\n\ntype GuideAnnotation = AnnotatedStatuses & {\n // Resolved eligibility based on active, targetable and archived statuses,\n // which are backend driven evaluation results that are exposed for debugging.\n isEligible: boolean;\n\n // Resolved display qualification based on an activatable status, which\n // informs \"when\" and \"where\" an eligible guide can be displayed to user.\n isQualified: boolean;\n};\n\nexport type AnnotatedGuide = KnockGuide & {\n orderIndex: number;\n annotation: GuideAnnotation;\n\n // Legacy fields, typed only to make tsc happy when we prune these out.\n activation_location_rules?: KnockGuide[\"activation_url_patterns\"];\n priority?: number;\n};\n\n// Exists and ordered in control but absent in switchboard (therefore not\n// included in the api response), which implies a newly created guide that has\n// never been published to switchboard.\nexport type UncommittedGuide = {\n __typename: \"UncommittedGuide\";\n orderIndex: number;\n key: KnockGuide[\"key\"];\n active: false;\n bypass_global_group_limit: false;\n annotation: {\n isEligible: false;\n isQualified: false;\n active: {\n status: false;\n };\n selectable: {\n status: undefined;\n };\n };\n};\n\nexport type InspectionResultOk = {\n status: \"ok\";\n guides: (AnnotatedGuide | UncommittedGuide)[];\n};\ntype InspectionResultError = {\n status: \"error\";\n error:\n | \"no_guides_fetched\"\n | \"no_guide_group\"\n | \"focus_unknown_guide\"\n | \"focus_uncommitted_guide\"\n | \"focus_unselectable_guide\";\n message: string;\n};\ntype InspectionResult = InspectionResultOk | InspectionResultError;\n\ntype StoreStateSnapshot = Pick<\n KnockGuideClientStoreState,\n | \"location\"\n | \"guides\"\n | \"guideGroups\"\n | \"ineligibleGuides\"\n | \"debug\"\n | \"counter\"\n | \"queries\"\n> & {\n throttled: boolean;\n};\n\nconst inferSelectByKeyReturnStatus = (\n guide: KnockGuide,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage,\n query: SelectionResultByQuery,\n): SelectableStatusPresent[\"status\"] => {\n const includeThrottled =\n !!query.key?.one?.metadata?.opts?.includeThrottled ||\n !!query.key?.all?.metadata?.opts?.includeThrottled;\n\n // If unthrottled, then it should always be returned.\n if (guide.bypass_global_group_limit) {\n return \"returned\";\n }\n\n // If resolved, expect this guide to be returned unless being throttled.\n if (guide.key === stage.resolved) {\n if (snapshot.throttled && !includeThrottled) {\n return \"throttled\";\n }\n return \"returned\";\n }\n\n // If queried but not resolved, it means this guide is being shadowed by\n // another guide with higher priority because throttled guides can be\n // displayed only one at a time.\n return \"queried\";\n};\n\nconst inferSelectOneByTypeReturnStatus = (\n guide: KnockGuide,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage,\n query: SelectionResultByQuery,\n): SelectableStatusPresent[\"status\"] => {\n const includeThrottled = !!query.type?.one?.metadata?.opts?.includeThrottled;\n\n const result = query.type!.one!;\n if (result.size === 0) {\n return \"queried\";\n }\n\n // There may be multiple unthrottled guides of the same type, being queried\n // by type to return a single guide, for example: useGuide({ type: \"card\" }).\n //\n // So it is possible for an unthrottled guide to be shadowed by another\n // unthrottled guide of the same type with higher priority, so we need to\n // look at the query result to determine its return status.\n if (guide.bypass_global_group_limit) {\n const guides = [...result.values()];\n const first = guides[0]!;\n\n if (guide.key !== first.key) {\n // Being shadowed by another guide with higher priority.\n return \"queried\";\n }\n return \"returned\";\n }\n\n // If resolved, expect this guide to be returned unless being throttled.\n if (guide.key === stage.resolved) {\n if (snapshot.throttled && !includeThrottled) {\n return \"throttled\";\n }\n return \"returned\";\n }\n\n // If queried but not resolved, it means this guide is being shadowed by\n // another guide with higher priority because throttled guides can be\n // displayed only one at a time.\n return \"queried\";\n};\n\nconst inferSelectAllByTypeReturnStatus = (\n guide: KnockGuide,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage,\n query: SelectionResultByQuery,\n): SelectableStatusPresent[\"status\"] => {\n const result = query.type!.all!;\n if (result.size === 0) {\n return \"queried\";\n }\n\n const guides = [...result.values()];\n const first = guides[0]!;\n\n // Might want to consider moving this up to do once.\n const guidesByKey: Record<KnockGuide[\"key\"], KnockGuide> = byKey(guides);\n\n // If includeThrottled given, then expect all selected guides to be returned.\n const includeThrottled = !!query.type?.all?.metadata?.opts?.includeThrottled;\n if (includeThrottled) {\n return guidesByKey[guide.key] ? \"returned\" : \"queried\";\n }\n\n // If the first selected guide is unthrottled or resolved, then we should\n // have at minimum one guide to return, and potentially more based on whether\n // we are throttling currently and which other guides are unthrottled.\n if (first.bypass_global_group_limit || first.key === stage.resolved) {\n if (!guidesByKey[guide.key]) {\n return \"queried\";\n }\n if (snapshot.throttled) {\n return guide.bypass_global_group_limit ? \"returned\" : \"throttled\";\n }\n return \"returned\";\n }\n\n return \"queried\";\n};\n\nconst inferSelectReturnStatus = (\n guide: KnockGuide,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage,\n query: SelectionResultByQuery,\n) => {\n // Querying by key can only return up to a max of one guide, regardless of\n // useGuide or useGuides, and should take precedence in status designation.\n if (query.key) {\n return inferSelectByKeyReturnStatus(guide, snapshot, stage, query);\n }\n\n if (query.type?.all) {\n return inferSelectAllByTypeReturnStatus(guide, snapshot, stage, query);\n }\n if (query.type?.one) {\n return inferSelectOneByTypeReturnStatus(guide, snapshot, stage, query);\n }\n\n // Should not happen but just for completeness.\n return undefined;\n};\n\nconst toSelectableStatus = (\n guide: KnockGuide,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage | undefined,\n): SelectableStatus => {\n if (!stage || stage.status === \"open\") {\n return { status: undefined };\n }\n\n const query = {\n key: (stage.results.key || {})[guide.key],\n type: (stage.results.type || {})[guide.type],\n };\n\n const queried = Boolean(query.key || query.type);\n if (!queried) {\n // No present query in the current location can select this guide.\n return { status: undefined };\n }\n\n const status = inferSelectReturnStatus(guide, snapshot, stage, query);\n if (!status) {\n return { status: undefined };\n }\n\n return { status, query };\n};\n\nconst toIneligibilityStatus = (\n guide: KnockGuide,\n marker?: KnockGuideIneligibilityMarker,\n): Partial<AnnotatedStatuses> => {\n const statuses: Partial<AnnotatedStatuses> = {};\n\n if (\n marker?.reason === \"not_in_target_audience\" ||\n marker?.reason === \"target_conditions_not_met\"\n ) {\n statuses.targetable = {\n status: false,\n reason: marker.reason,\n message: marker.message,\n };\n }\n\n if (\n marker?.reason === \"marked_as_archived\" ||\n (guide.steps || []).every((s) => !!s.message.archived_at)\n ) {\n statuses.archived = {\n status: true,\n };\n }\n\n if (marker?.reason === \"guide_not_active\") {\n statuses.active = {\n status: false,\n };\n }\n\n return statuses;\n};\n\nconst resolveIsEligible = ({\n active,\n targetable,\n archived,\n}: AnnotatedStatuses) => {\n if (!active.status) return false;\n if (!targetable.status) return false;\n if (archived.status) return false;\n return true;\n};\n\nexport const resolveIsQualified = ({\n activatable,\n selectable,\n}: AnnotatedStatuses) => {\n if (!activatable.status) return false;\n if (!selectable.status) return false;\n return true;\n};\n\nconst annotateGuide = (\n guide: KnockGuide,\n orderIndex: number,\n snapshot: StoreStateSnapshot,\n stage: KnockGuideClientGroupStage | undefined,\n): AnnotatedGuide => {\n const { ineligibleGuides, location } = snapshot;\n const marker = ineligibleGuides[guide.key];\n const ineligiblity = toIneligibilityStatus(guide, marker);\n\n const statuses: AnnotatedStatuses = {\n // isEligible:\n active: ineligiblity?.active || { status: true },\n targetable: ineligiblity?.targetable || { status: true },\n archived: ineligiblity?.archived || { status: false },\n // isQualified:\n activatable: { status: checkActivatable(guide, location) },\n selectable: toSelectableStatus(guide, snapshot, stage),\n };\n\n const annotation: GuideAnnotation = {\n ...statuses,\n isEligible: resolveIsEligible(statuses),\n isQualified: resolveIsQualified(statuses),\n };\n\n return {\n ...guide,\n orderIndex,\n annotation,\n };\n};\n\nconst newUncommittedGuide = (key: KnockGuide[\"key\"], orderIndex: number) =>\n ({\n __typename: \"UncommittedGuide\",\n key,\n orderIndex,\n active: false,\n bypass_global_group_limit: false,\n annotation: {\n isEligible: false,\n isQualified: false,\n active: {\n status: false,\n },\n selectable: {\n status: undefined,\n },\n },\n }) as UncommittedGuide;\n\nexport const useInspectGuideClientStore = (\n runConfig: ToolbarV2RunConfig,\n): InspectionResult | undefined => {\n const { client } = useGuideContext();\n\n // Extract a snapshot of the client store state for debugging.\n const snapshot: StoreStateSnapshot = useStore(client.store, (state) => {\n const throttled = checkStateIfThrottled(state);\n\n return {\n location: state.location,\n guides: state.guides,\n guideGroups: state.guideGroups,\n ineligibleGuides: state.ineligibleGuides,\n debug: state.debug,\n counter: state.counter,\n queries: state.queries,\n throttled,\n };\n });\n\n // Not in debugging session, so noop.\n if (!snapshot.debug?.debugging) {\n return undefined;\n }\n\n // No recorded fetch requests, which implies an inflight request loading.\n const req = Object.entries(snapshot.queries)[0];\n if (!req || req[1].status === \"loading\") {\n return {\n status: \"error\",\n error: \"no_guides_fetched\",\n message: \"Loading...\",\n };\n }\n\n // Should always be a default group so this should never happen.\n const defaultGroup = snapshot.guideGroups[0];\n if (!defaultGroup) {\n return {\n status: \"error\",\n error: \"no_guide_group\",\n message: \"No guide group found\",\n };\n }\n\n const groupStage = client.getStage();\n\n // Annotate guides for various eligibility, activation and query statuses\n // that are useful for debugging purposes.\n const orderedGuides = defaultGroup.display_sequence.map((guideKey, index) => {\n const guide = snapshot.guides[guideKey];\n if (!guide) {\n return newUncommittedGuide(guideKey, index);\n }\n\n return annotateGuide(guide, index, snapshot, groupStage);\n });\n\n // Check if the focused guide actually exists and is selectable on the page.\n const focusedGuideKey = Object.keys(runConfig.focusedGuideKeys || {})[0];\n if (groupStage?.status === \"closed\" && focusedGuideKey) {\n const foundGuide = orderedGuides.find((g) => g.key === focusedGuideKey);\n\n // No such guide exists for the given focused guide key.\n if (!foundGuide) {\n return {\n status: \"error\",\n error: \"focus_unknown_guide\",\n message: `Unable to display \\`${focusedGuideKey}\\`, ${FOCUS_ERRORS.focusUnknownGuide.toLowerCase()}.`,\n };\n }\n\n // This guide exists but has never been committed and published, so it is\n // not present in the API response.\n if (isUncommittedGuide(foundGuide)) {\n return {\n status: \"error\",\n error: \"focus_uncommitted_guide\",\n message: `Unable to display \\`${focusedGuideKey}\\`, ${FOCUS_ERRORS.focusUncommittedGuide.toLowerCase()}.`,\n };\n }\n\n // This guide exists and is present in the response, but it is not queried\n // in the current page so it is impossible to force render this guide.\n if (!foundGuide.annotation.selectable.status) {\n return {\n status: \"error\",\n error: \"focus_unselectable_guide\",\n message: `Unable to display \\`${focusedGuideKey}\\`, ${FOCUS_ERRORS.focusUnselectableGuide.toLowerCase()}.`,\n };\n }\n }\n\n return {\n status: \"ok\",\n guides: orderedGuides,\n };\n};\n\nexport const isUncommittedGuide = (input: unknown): input is UncommittedGuide =>\n typeof input === \"object\" &&\n input !== null &&\n \"__typename\" in input &&\n (input as UncommittedGuide).__typename === \"UncommittedGuide\";\n"],"names":["byKey","items","reduce","acc","item","key","inferSelectByKeyReturnStatus","guide","snapshot","stage","query","includeThrottled","one","metadata","opts","all","bypass_global_group_limit","resolved","throttled","inferSelectOneByTypeReturnStatus","type","result","size","first","values","inferSelectAllByTypeReturnStatus","guides","guidesByKey","inferSelectReturnStatus","toSelectableStatus","status","undefined","results","Boolean","toIneligibilityStatus","marker","statuses","reason","targetable","message","steps","every","s","archived_at","archived","active","resolveIsEligible","resolveIsQualified","activatable","selectable","annotateGuide","orderIndex","ineligibleGuides","location","ineligiblity","checkActivatable","annotation","isEligible","isQualified","newUncommittedGuide","__typename","useInspectGuideClientStore","runConfig","client","useGuideContext","useStore","store","state","checkStateIfThrottled","guideGroups","debug","counter","queries","debugging","req","Object","entries","error","defaultGroup","groupStage","getStage","orderedGuides","display_sequence","map","guideKey","index","focusedGuideKey","keys","focusedGuideKeys","foundGuide","find","g","FOCUS_ERRORS","focusUnknownGuide","toLowerCase","isUncommittedGuide","focusUncommittedGuide","focusUnselectableGuide","input"],"mappings":";;;AAcA,MAAMA,IAAQ,CAA4BC,MACjCA,EAAMC,OAAO,CAACC,GAAKC,OAAU;AAAA,EAAE,GAAGD;AAAAA,EAAK,CAACC,EAAKC,GAAG,GAAGD;AAAK,IAAI,CAAA,CAAE,GAyIjEE,IAA+BA,CACnCC,GACAC,GACAC,G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AGK,SAAA;AAAA,IACLhE,QAAQ;AAAA,IACRJ,QAAQuD;AAAAA,EACV;AACF,GAEac,IAAqBA,CAACG,MACjC,OAAOA,KAAU,YACjBA,MAAU,QACV,gBAAgBA,KACfA,EAA2BtC,eAAe;"}
@@ -1,24 +1,26 @@
1
- import { KnockGuideProvider as m } from "@knocklabs/react-core";
1
+ import { KnockGuideProvider as i } from "@knocklabs/react-core";
2
2
  import r from "react";
3
3
  import "../components/Banner/Banner.mjs";
4
4
  import "../components/Card/Card.mjs";
5
- import { V1 as i } from "../components/Toolbar/V1/V1.mjs";
5
+ import { V1 as c } from "../components/Toolbar/V1/V1.mjs";
6
6
  import { V2 as n } from "../components/Toolbar/V2/V2.mjs";
7
7
  import "../components/Modal/Modal.mjs";
8
- const f = ({
9
- children: t,
8
+ const k = ({
9
+ children: o,
10
10
  toolbar: e = "v2",
11
- ...o
11
+ readyToTarget: t,
12
+ ...m
12
13
  }) => /* @__PURE__ */ r.createElement(
13
- m,
14
+ i,
14
15
  {
15
- ...o,
16
+ ...m,
17
+ readyToTarget: t,
16
18
  trackDebugParams: e === "v1"
17
19
  },
18
- t,
19
- e === "v2" ? /* @__PURE__ */ r.createElement(n, null) : /* @__PURE__ */ r.createElement(i, null)
20
+ o,
21
+ e === "v2" ? /* @__PURE__ */ r.createElement(n, { readyToTarget: t }) : /* @__PURE__ */ r.createElement(c, null)
20
22
  );
21
23
  export {
22
- f as KnockGuideProvider
24
+ k as KnockGuideProvider
23
25
  };
24
26
  //# sourceMappingURL=KnockGuideProvider.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"KnockGuideProvider.mjs","sources":["../../../../../src/modules/guide/providers/KnockGuideProvider.tsx"],"sourcesContent":["import {\n KnockGuideProvider as KnockGuideProviderCore,\n type KnockGuideProviderProps,\n} from \"@knocklabs/react-core\";\nimport React from \"react\";\n\nimport { ToolbarV1, ToolbarV2 } from \"../components\";\n\ntype Props = KnockGuideProviderProps & {\n toolbar?: \"v1\" | \"v2\";\n};\n\n// Re-export the core KnockGuideProvider, so we can add React specific\n// functionality like the Toolbar component which shouldn't be included in other\n// contexts (e.g. React Native).\nexport const KnockGuideProvider: React.FC<React.PropsWithChildren<Props>> = ({\n children,\n toolbar = \"v2\",\n ...props\n}) => {\n return (\n <KnockGuideProviderCore\n {...props}\n // For backward compatibility with toolbar v1. Remove once v2 ships.\n trackDebugParams={toolbar === \"v1\"}\n >\n {children}\n {toolbar === \"v2\" ? <ToolbarV2 /> : <ToolbarV1 />}\n </KnockGuideProviderCore>\n );\n};\n"],"names":["KnockGuideProvider","children","toolbar","props","React","KnockGuideProviderCore","ToolbarV2","ToolbarV1"],"mappings":";;;;;;;AAeO,MAAMA,IAA+DA,CAAC;AAAA,EAC3EC,UAAAA;AAAAA,EACAC,SAAAA,IAAU;AAAA,EACV,GAAGC;AACL,MAEIC,gBAAAA,EAAA;AAAA,EAACC;AAAAA,EAAA;AAAA,IACC,GAAIF;AAAAA,IAEJ,kBAAkBD,MAAY;AAAA,EAAA;AAAA,EAE7BD;AAAAA,EACAC,MAAY,OAAOE,gBAAAA,EAAA,cAACE,GAAY,IAAA,oCAAIC,GAAY,IAAA;AACnD;"}
1
+ {"version":3,"file":"KnockGuideProvider.mjs","sources":["../../../../../src/modules/guide/providers/KnockGuideProvider.tsx"],"sourcesContent":["import {\n KnockGuideProvider as KnockGuideProviderCore,\n type KnockGuideProviderProps,\n} from \"@knocklabs/react-core\";\nimport React from \"react\";\n\nimport { ToolbarV1, ToolbarV2 } from \"../components\";\n\ntype Props = KnockGuideProviderProps & {\n toolbar?: \"v1\" | \"v2\";\n};\n\n// Re-export the core KnockGuideProvider, so we can add React specific\n// functionality like the Toolbar component which shouldn't be included in other\n// contexts (e.g. React Native).\nexport const KnockGuideProvider: React.FC<React.PropsWithChildren<Props>> = ({\n children,\n toolbar = \"v2\",\n readyToTarget,\n ...props\n}) => {\n return (\n <KnockGuideProviderCore\n {...props}\n readyToTarget={readyToTarget}\n // For backward compatibility with toolbar v1. Remove once v2 ships.\n trackDebugParams={toolbar === \"v1\"}\n >\n {children}\n {toolbar === \"v2\" ? (\n <ToolbarV2 readyToTarget={readyToTarget} />\n ) : (\n <ToolbarV1 />\n )}\n </KnockGuideProviderCore>\n );\n};\n"],"names":["KnockGuideProvider","children","toolbar","readyToTarget","props","React","KnockGuideProviderCore","ToolbarV2","ToolbarV1"],"mappings":";;;;;;;AAeO,MAAMA,IAA+DA,CAAC;AAAA,EAC3EC,UAAAA;AAAAA,EACAC,SAAAA,IAAU;AAAA,EACVC,eAAAA;AAAAA,EACA,GAAGC;AACL,MAEIC,gBAAAA,EAAA;AAAA,EAACC;AAAAA,EAAA;AAAA,IACKF,GAAAA;AAAAA,IACJ,eAAAD;AAAA,IAEA,kBAAkBD,MAAY;AAAA,EAAA;AAAA,EAE7BD;AAAAA,EACAC,MAAY,OACXG,gBAAAA,EAAA,cAACE,KAAU,eAAAJ,uCAEVK,GACF,IAAA;AACH;"}