@picked/client 0.0.1-dev.1778561735098 → 0.0.1-dev.1780446300503

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 (87) hide show
  1. package/dist/{api-XV6bcv_D.cjs → api-Cqg2gPbP.cjs} +1 -1
  2. package/dist/{api-Bzb9pR2r.js → api-qqBYwjhT.js} +1 -1
  3. package/dist/cjs/index.js +2 -2
  4. package/dist/cjs/plugins/create-experience/index.js +1 -1
  5. package/dist/cjs/plugins/dom-observer/index.js +1 -0
  6. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
  7. package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
  8. package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
  9. package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
  10. package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
  11. package/dist/cjs/plugins/single-page-app/index.js +1 -1
  12. package/dist/cjs/plugins/web-components/index.js +1 -1
  13. package/dist/cjs/plugins/window-object/index.js +1 -1
  14. package/dist/cjs/server/index.js +1 -1
  15. package/dist/docs/image-optimisation-service.md +6 -6
  16. package/dist/docs/sdk/content-security-policy.md +8 -7
  17. package/dist/docs/sdk/fields.md +2 -2
  18. package/dist/docs/workspaces.mdx +1 -1
  19. package/dist/dom-DjfSrkpp.js +84 -0
  20. package/dist/dom-sqnnO-CT.cjs +1 -0
  21. package/dist/esm/index.js +360 -349
  22. package/dist/esm/plugins/create-experience/index.js +1 -1
  23. package/dist/esm/plugins/dom-observer/index.js +87 -0
  24. package/dist/esm/plugins/dynamic-experiences/index.js +3 -163
  25. package/dist/esm/plugins/experience-browser-storage/index.js +2 -2
  26. package/dist/esm/plugins/history-browser-storage/index.js +15 -54
  27. package/dist/esm/plugins/responses-browser-storage/index.js +2 -2
  28. package/dist/esm/plugins/responses-indexeddb/index.js +1 -1
  29. package/dist/esm/plugins/single-page-app/index.js +14 -14
  30. package/dist/esm/plugins/web-components/index.js +2 -2
  31. package/dist/esm/plugins/window-object/index.js +1 -1
  32. package/dist/esm/server/index.js +84 -51
  33. package/dist/experience-instance-B2Xb6TAm.cjs +1 -0
  34. package/dist/experience-instance-Brph8SaR.js +512 -0
  35. package/dist/plugin-7rlBjq6t.js +240 -0
  36. package/dist/plugin-D1FIRtEo.cjs +1 -0
  37. package/dist/preview-bridge-Cv-Fu5Y1.cjs +1 -0
  38. package/dist/preview-bridge-eBbZClad.js +33 -0
  39. package/dist/supports-34OzZK5j.cjs +1 -0
  40. package/dist/{supports-0XIfd4-R.js → supports-BgjwyijI.js} +11 -4
  41. package/dist/types/entities/content/content.d.ts +37 -0
  42. package/dist/types/entities/content/content.d.ts.map +1 -0
  43. package/dist/types/entities/experience/experience.d.ts +22 -2
  44. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  45. package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
  46. package/dist/types/entities/history/history.d.ts +16 -28
  47. package/dist/types/entities/history/history.d.ts.map +1 -1
  48. package/dist/types/entities/step/step.d.ts +17 -2
  49. package/dist/types/entities/step/step.d.ts.map +1 -1
  50. package/dist/types/index.d.ts +2 -0
  51. package/dist/types/index.d.ts.map +1 -1
  52. package/dist/types/lifecycle/condition-selection.d.ts +98 -0
  53. package/dist/types/lifecycle/condition-selection.d.ts.map +1 -0
  54. package/dist/types/lifecycle/lifecycle.d.ts.map +1 -1
  55. package/dist/types/lifecycle/state-snapshot.d.ts.map +1 -1
  56. package/dist/types/picked.d.ts +72 -8
  57. package/dist/types/picked.d.ts.map +1 -1
  58. package/dist/types/plugins/dom-observer/index.d.ts +3 -0
  59. package/dist/types/plugins/dom-observer/index.d.ts.map +1 -0
  60. package/dist/types/plugins/dom-observer/plugin.d.ts +50 -0
  61. package/dist/types/plugins/dom-observer/plugin.d.ts.map +1 -0
  62. package/dist/types/plugins/dynamic-experiences/index.d.ts +2 -1
  63. package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
  64. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +41 -1
  65. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
  66. package/dist/types/plugins/dynamic-experiences/types.d.ts +67 -1
  67. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
  68. package/dist/types/plugins/history-browser-storage/plugin.d.ts +0 -16
  69. package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
  70. package/dist/types/preview-bridge/index.d.ts +14 -0
  71. package/dist/types/preview-bridge/index.d.ts.map +1 -0
  72. package/dist/types/server/index.d.ts +8 -0
  73. package/dist/types/server/index.d.ts.map +1 -1
  74. package/dist/types/server/serialize.d.ts +67 -0
  75. package/dist/types/server/serialize.d.ts.map +1 -0
  76. package/dist/types/utils/dom.d.ts +0 -27
  77. package/dist/types/utils/dom.d.ts.map +1 -1
  78. package/dist/types/utils/supports.d.ts +8 -0
  79. package/dist/types/utils/supports.d.ts.map +1 -1
  80. package/package.json +12 -2
  81. package/dist/experience-instance-B16NqD7y.cjs +0 -1
  82. package/dist/experience-instance-CZC0uPuv.js +0 -513
  83. package/dist/supports-Dsjg-82e.cjs +0 -1
  84. /package/dist/{id-Bv44ilEo.cjs → id-Cg7fVl1O.cjs} +0 -0
  85. /package/dist/{id-CRqy981z.js → id-n2yrHvNo.js} +0 -0
  86. /package/dist/{storage-B6lQtc4-.cjs → storage-BXSlLTRa.cjs} +0 -0
  87. /package/dist/{storage-6Xk0uAxB.js → storage-hOHCCXvP.js} +0 -0
@@ -0,0 +1,98 @@
1
+ import { Store } from 'effector';
2
+ import { LogicObject, LogicRule, LogicValue } from '../logic-engine';
3
+ import { Picked } from '../picked';
4
+ /** A condition rule that may be json-logic, a raw logic value, or unset. */
5
+ type ConditionRule = LogicRule | LogicValue | undefined;
6
+ /**
7
+ * Produces a stable, key-order-independent string hash of a logic rule for use as a cache key.
8
+ *
9
+ * Object keys are sorted recursively, arrays preserve their order, and `undefined` is
10
+ * normalised to `null`. Equivalent rules with reordered keys hash identically; rules that
11
+ * differ in any value or array order hash differently.
12
+ *
13
+ * @param {ConditionRule} rule - The rule to hash.
14
+ * @returns {string} A deterministic string key for the rule.
15
+ * @example
16
+ * hashRule({ '==': [1, 1] }) // '{"==":[1,1]}'
17
+ */
18
+ export declare function hashRule(rule: ConditionRule): string;
19
+ /**
20
+ * Reactive store of memoized condition-evaluation results, keyed by rule hash.
21
+ */
22
+ export interface ConditionResults {
23
+ /** Reactive store mapping rule hashes to their boolean evaluation result. */
24
+ store: Store<Record<string, boolean>>;
25
+ /** Writes a single hash-to-result entry into the store. */
26
+ set: (payload: {
27
+ hash: string;
28
+ result: boolean;
29
+ }) => void;
30
+ /** Bulk-seeds the store from a snapshot of hash-to-result entries, such as the server snapshot. */
31
+ seed: (results: Record<string, boolean>) => void;
32
+ /** Returns a derived store for a single hash, resolving reactively to late writes. */
33
+ getResult: (hash: string) => Store<boolean | undefined>;
34
+ /** Synchronously reads the current result for a hash, or `undefined` when absent. */
35
+ peek: (hash: string) => boolean | undefined;
36
+ }
37
+ /**
38
+ * Creates a reactive condition-results store keyed by rule hash, mirroring the entity-index
39
+ * factory pattern.
40
+ *
41
+ * @returns {ConditionResults} A condition-results store with set, seed, getResult, and peek.
42
+ * @example
43
+ * const results = createConditionResults()
44
+ * results.set({ hash: 'h1', result: true })
45
+ * results.peek('h1') // true
46
+ */
47
+ export declare function createConditionResults(): ConditionResults;
48
+ /**
49
+ * Evaluates a condition rule with memoization against the client's `conditionResults` store.
50
+ *
51
+ * Every rule (including `undefined`/`null`, empty, and boolean gates) is hashed and its result
52
+ * cached, so callers can read it synchronously via `conditionResults.peek(hashRule(rule))` (which
53
+ * `<Experience>` relies on for slot selection, such as an experience with no condition). A cache hit
54
+ * returns the stored value; a miss resolves the gate (evaluating non-empty logic rules via
55
+ * `evaluateRuleLogic`), writes the result back to the store (propagating reactively), and returns it.
56
+ *
57
+ * Rules that reference an action (a `var` under the `actions` namespace) are never read from or
58
+ * written to the cache: actions have side effects that must re-run on every evaluation, so caching
59
+ * their result would suppress those effects.
60
+ *
61
+ * @param {Picked} client - The Picked client providing the evaluation context and results store.
62
+ * @param {ConditionRule} rule - The condition rule to evaluate.
63
+ * @param {object} [options] - Optional evaluation options.
64
+ * @param {LogicObject} [options.context] - Context overrides merged into the evaluation (e.g. URL location).
65
+ * @returns {Promise<boolean>} Whether the condition resolves truthy.
66
+ * @example
67
+ * const active = await evaluateConditionMemo(client, { '==': [1, 1] })
68
+ */
69
+ export declare function evaluateConditionMemo(client: Picked, rule: ConditionRule, options?: {
70
+ context?: LogicObject;
71
+ }): Promise<boolean>;
72
+ /**
73
+ * Determines whether an experience is active by AND-ing the optional client precondition, the
74
+ * optional client condition, and the experience's own condition through the memoized evaluator.
75
+ *
76
+ * This is the DOM-free analogue of `shouldInitialiseFx` used for slot-based and server-side
77
+ * selection: each unset gate is treated as passing.
78
+ *
79
+ * @param {Picked} client - The Picked client providing the evaluation context and results store.
80
+ * @param {object} experience - The experience to test.
81
+ * @param {LogicRule | LogicValue} [experience.condition] - The experience's decision logic.
82
+ * @param {object} [options] - Optional gate inputs.
83
+ * @param {LogicObject} [options.context] - Context overrides merged into every evaluation.
84
+ * @param {LogicRule | LogicValue} [options.precondition] - The client-level precondition gate.
85
+ * @param {LogicRule | LogicValue} [options.condition] - The client-level condition gate.
86
+ * @returns {Promise<boolean>} Whether the experience is active for the given context.
87
+ * @example
88
+ * const active = await isExperienceActive(client, { condition: exp.condition }, { context })
89
+ */
90
+ export declare function isExperienceActive(client: Picked, experience: {
91
+ condition?: LogicRule | LogicValue;
92
+ }, options?: {
93
+ context?: LogicObject;
94
+ precondition?: LogicRule | LogicValue;
95
+ condition?: LogicRule | LogicValue;
96
+ }): Promise<boolean>;
97
+ export {};
98
+ //# sourceMappingURL=condition-selection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"condition-selection.d.ts","sourceRoot":"","sources":["../../../src/lifecycle/condition-selection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;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,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAA;IAEjE,iFAAiF;IACjF,eAAe,EAAE,aAAa,CAAC,UAAU,CAAC,CAAA;IAC1C,8EAA8E;IAC9E,YAAY,EAAE,aAAa,CAAC,UAAU,CAAC,CAAA;CACxC;AAyOD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAErE"}
@@ -1 +1 @@
1
- {"version":3,"file":"state-snapshot.d.ts","sourceRoot":"","sources":["../../../src/lifecycle/state-snapshot.ts"],"names":[],"mappings":"AAAA,gIAAgI;AAChI,OAAO,EAAW,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAE9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEhE,sIAAsI;AACtI,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAA;IACzC,YAAY,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC,CAAA;IACrC,SAAS,EAAE;QACT,QAAQ,EAAE,MAAM,CAAA;QAChB,KAAK,EAAE,UAAU,GAAG,SAAS,CAAA;KAC9B,EAAE,CAAA;IACH,MAAM,EAAE,KAAK,EAAE,CAAA;CAChB;AA0BD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,KAAK,CAAC,aAAa,CAAC,CAEzF"}
1
+ {"version":3,"file":"state-snapshot.d.ts","sourceRoot":"","sources":["../../../src/lifecycle/state-snapshot.ts"],"names":[],"mappings":"AAAA,gIAAgI;AAChI,OAAO,EAAW,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAE9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEhE,sIAAsI;AACtI,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAA;IACzC,YAAY,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC,CAAA;IACrC,SAAS,EAAE;QACT,QAAQ,EAAE,MAAM,CAAA;QAChB,KAAK,EAAE,UAAU,GAAG,SAAS,CAAA;KAC9B,EAAE,CAAA;IACH,MAAM,EAAE,KAAK,EAAE,CAAA;CAChB;AA4BD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,KAAK,CAAC,aAAa,CAAC,CAEzF"}
@@ -6,18 +6,49 @@ import { AdaptedComponent } from './entities/component/component';
6
6
  import { Framework } from './entities/framework/framework';
7
7
  import { StateSnapshot } from './lifecycle/state-snapshot';
8
8
  import { EvaluateRuleLogicParams } from './lifecycle/rules-logic';
9
+ import { ConditionResults } from './lifecycle/condition-selection';
9
10
  import { LifecycleStage } from './lifecycle/lifecycle';
10
11
  import { Predicate } from './entities/predicate/predicate';
11
12
  import { Feature } from './entities/feature/feature';
12
13
  import { EventBusPayload, EventHistoryStore } from './utils/events';
13
14
  import { Field } from './entities/field/field';
14
15
  import { ExperienceStep } from './entities/step/step';
16
+ import { Content } from './entities/content/content';
17
+ import { ContentLoader } from './plugins/dynamic-experiences/types';
15
18
  import { Action } from './entities/action/action';
16
19
  import { Condition } from './entities/condition/condition';
17
20
  import { SessionEntity } from './entities/session/session';
21
+ /**
22
+ * Provenance metadata describing where the Picked client's project config and
23
+ * content came from. Set by `dynamicExperiencesPlugin` when the Vite plugin's
24
+ * virtual data module is available; remains `null` otherwise.
25
+ */
26
+ export interface PickedDataSource {
27
+ /** `'build'` when build-mode prefetch JSON was used, `'dev'` when the dev-mode runtime fetch was used. */
28
+ mode: 'dev' | 'build';
29
+ /** ISO 8601 timestamp from the manifest. `null` in dev mode where no manifest is written. */
30
+ fetchedAt: string | null;
31
+ /** The `versionId` recorded by the source, when known. */
32
+ projectVersionId: string | null;
33
+ /** The `workspaceId` recorded by the source, when known. */
34
+ workspaceId: string | null;
35
+ }
18
36
  export declare class Picked {
19
37
  static readonly logger: (level: "log" | "warn" | "info" | "error", ...args: Parameters<Console["log"]>) => void;
20
38
  private readonly options;
39
+ /**
40
+ * Provenance metadata for the data backing this client. Populated by
41
+ * `dynamicExperiencesPlugin` when the Vite plugin's virtual data module is
42
+ * resolvable; remains `null` when the SDK is using the runtime API path.
43
+ */
44
+ dataSource: PickedDataSource | null;
45
+ /**
46
+ * Content fetcher selected by `dynamicExperiencesPlugin`'s resolution chain. Called
47
+ * by each experience's `prepareExperienceContentFx` (fired in parallel with
48
+ * `initialiseFx` by the per-experience sample graph). `undefined` when no plugin
49
+ * has registered one yet.
50
+ */
51
+ contentLoader?: ContentLoader;
21
52
  private readonly plugins;
22
53
  readonly eventBus: EventCallable<EventBusPayload>;
23
54
  readonly events: EventHistoryStore;
@@ -28,15 +59,21 @@ export declare class Picked {
28
59
  readonly session: SessionEntity;
29
60
  readonly searchParams: import('.').PickedSearchParams;
30
61
  readonly history: {
31
- push: EventCallable<import('.').InstanceNodeIntent>;
32
- replace: EventCallable<import('.').InstanceNodeIntent>;
33
- back: EventCallable<Pick<import('.').InstanceScope, "instanceId">>;
34
- restoreSnapshots: EventCallable<{
35
- snapshots: Record<string, import('.').HistoryEntry[]>;
62
+ push: EventCallable<{
63
+ experienceId: string;
64
+ node: import('.').ExperienceNode;
36
65
  }>;
37
- seedInstanceFromSnapshot: EventCallable<import('.').InstanceScope>;
38
- entriesStore: StoreWritable<import('.').HistoryEntry[]>;
39
- snapshotStore: Store<Record<string, import('.').HistoryEntry[]>>;
66
+ replace: EventCallable<{
67
+ experienceId: string;
68
+ node: import('.').ExperienceNode;
69
+ }>;
70
+ back: EventCallable<{
71
+ experienceId?: string;
72
+ }>;
73
+ restore: EventCallable<{
74
+ entries: import('.').HistoryEntry[];
75
+ }>;
76
+ entriesStore: Store<import('.').HistoryEntry[]>;
40
77
  };
41
78
  readonly components: {
42
79
  register: EventCallable<{
@@ -162,6 +199,14 @@ export declare class Picked {
162
199
  [id: string]: ExperienceStep;
163
200
  }>;
164
201
  };
202
+ readonly contents: {
203
+ register: (content: Content) => void;
204
+ getById: (id: Content["id"]) => Store<Content | null>;
205
+ listStore: Store<Content[]>;
206
+ indexStore: StoreWritable<{
207
+ [id: string]: Content;
208
+ }>;
209
+ };
165
210
  readonly actions: {
166
211
  register: EventCallable<{
167
212
  key: string;
@@ -173,6 +218,13 @@ export declare class Picked {
173
218
  experience: import('.').ExperienceInstance;
174
219
  }) => Store<() => ReturnType<Action>>;
175
220
  };
221
+ /**
222
+ * Memoized condition-evaluation results keyed by rule hash. Populated by the
223
+ * server `serialize` selection and the memoized evaluator (`evaluateConditionMemo`),
224
+ * and seeded on the client from the SSR snapshot so first paint reuses the server's
225
+ * selection without re-evaluating.
226
+ */
227
+ readonly conditionResults: ConditionResults;
176
228
  readonly stateSnapshotStore: Store<StateSnapshot>;
177
229
  readonly evaluateRuleLogicFx: Effect<EvaluateRuleLogicParams, unknown, Error>;
178
230
  /** Public trigger — fires the start chain. `await allSettled(client.start, { scope })` resolves once the chain has fully settled. */
@@ -199,6 +251,17 @@ export declare class Picked {
199
251
  context?: Record<string, unknown>;
200
252
  }, string, Error>;
201
253
  constructor(options: CreateClientOptions);
254
+ /**
255
+ * Lazily starts the preview bridge when the client runs inside an iframe in preview mode (a
256
+ * `preview-token` search param is present). The bridge is loaded via a dynamic `import()` so it is
257
+ * code-split out of production bundles and fetched only inside the dashboard preview; failures are
258
+ * swallowed so client creation never depends on it.
259
+ *
260
+ * @returns {void} Nothing.
261
+ * @example
262
+ * this.maybeStartPreviewBridge()
263
+ */
264
+ private maybeStartPreviewBridge;
202
265
  registerFramework: (framework: Framework) => void;
203
266
  registerComponent: (name: string, component: AdaptedComponent) => void;
204
267
  registerPlugin: (plugin: Plugin) => void;
@@ -207,6 +270,7 @@ export declare class Picked {
207
270
  registerCondition: (condition: Condition) => void;
208
271
  registerField: (field: Field) => void;
209
272
  registerStep: (step: ExperienceStep) => void;
273
+ registerContent: (content: Content) => void;
210
274
  registerAction: (key: string, action: Action) => void;
211
275
  registerExperience: (experience: Experience) => void;
212
276
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"picked.d.ts","sourceRoot":"","sources":["../../src/picked.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,KAAK,EACV,KAAK,aAAa,EACnB,MAAM,UAAU,CAAA;AACjB,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,uBAAuB,EAC7B,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,iBAAiB,EAAe,MAAM,0BAA0B,CAAA;AAC3F,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EACL,KAAK,gBAAgB,EAGtB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAEL,KAAK,SAAS,EAEf,MAAM,gCAAgC,CAAA;AAEvC,OAAO,EAA4B,KAAK,aAAa,EAAE,MAAM,4BAA4B,CAAA;AACzF,OAAO,EAA6B,KAAK,uBAAuB,EAAE,MAAM,yBAAyB,CAA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AAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE1F;CACF"}
@@ -0,0 +1,3 @@
1
+ /** @file Public entrypoint for the dom-observer plugin. */
2
+ export { domObserverPlugin } from './plugin';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dom-observer/index.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA"}
@@ -0,0 +1,50 @@
1
+ import { Plugin } from '../../entities/plugin/plugin';
2
+ /**
3
+ * Watches the document for `childList` mutations and reconciles experiences
4
+ * whose declared target selectors match newly added DOM subtrees. Each
5
+ * matching experience runs through its per-experience `shouldInitialiseFx`,
6
+ * and on `true` is handed to its `initialiseFx(undefined)`.
7
+ *
8
+ * Scope: lazy-mounted target hosts that arrive after the initial bulk init
9
+ * in `picked.ts`. Route-driven re-initialisation (decisionLogic depending
10
+ * on `location.pathname`, lifecycle event re-fires, plugin start hooks)
11
+ * is the responsibility of `singlePageAppPlugin`, which calls
12
+ * `client.start()` on history events. Pair the two plugins to cover both.
13
+ *
14
+ * Pipeline:
15
+ * - Each experience's `configStore.watch()` pushes its trimmed selectors
16
+ * into a reactive `Store<Map<id, string[]>>`. Empty / whitespace-only
17
+ * selectors are filtered out.
18
+ * - A single `MutationObserver` collects `Element` instances from
19
+ * `childList.addedNodes` across one animation frame, then fires a
20
+ * single `mutationObserved` event carrying the collected elements.
21
+ * - `sample` filters registered experiences to those whose selectors
22
+ * match at least one added element via `el.matches` or
23
+ * `el.querySelector`. Malformed selectors are skipped per-experience
24
+ * without poisoning the rest of the batch. The matched array is
25
+ * routed straight into `reconcileMatchedFx` via `sample.target`.
26
+ * - `reconcileMatchedFx` invokes each experience's
27
+ * `shouldInitialiseFx`, and on `true` its `initialiseFx(undefined)`.
28
+ * `initialiseFx` is idempotent: tagged target elements are skipped
29
+ * on subsequent passes.
30
+ *
31
+ * Setup is deferred until `document.body` is parsed, so SDKs loaded from
32
+ * `<head>` without `defer` (the standard Shopify-theme / GTM-template
33
+ * pattern) still install once the body becomes available.
34
+ *
35
+ * No-ops outside browser environments and on partial-DOM runtimes that
36
+ * lack `MutationObserver` or `requestAnimationFrame`. `MutationObserver`
37
+ * does not cross shadow root or iframe boundaries, so experiences whose
38
+ * target lives inside a shadow tree or a cross-origin frame are not
39
+ * reconciled by this plugin.
40
+ *
41
+ * @returns {Plugin} The plugin.
42
+ * @example
43
+ * ```typescript
44
+ * createClient({
45
+ * plugins: [domObserverPlugin()]
46
+ * })
47
+ * ```
48
+ */
49
+ export declare const domObserverPlugin: () => Plugin;
50
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dom-observer/plugin.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAK1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,eAAO,MAAM,iBAAiB,QAAO,MAiBpC,CAAA"}
@@ -1,4 +1,5 @@
1
- export { dynamicExperiencesPlugin, fetchProject } from './plugin';
1
+ /** @file Public exports for the dynamic-experiences plugin (project config + per-experience content resolution). */
2
+ export { dynamicExperiencesPlugin, fetchExperienceContent, fetchProject } from './plugin';
2
3
  export { createClientHeaders } from '../../utils/client-headers';
3
4
  export type * from './types';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,mBAAmB,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/index.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,mBAAmB,SAAS,CAAA"}
@@ -1,5 +1,28 @@
1
1
  import { Plugin } from '../../entities/plugin/plugin';
2
- import { DynamicExperiencesPluginOptions, FetchProjectOptions, ProjectConfig } from './types';
2
+ import { Picked } from '../../picked';
3
+ import { DynamicExperiencesPluginOptions, ExperienceContentResponse, FetchProjectOptions, ProjectConfig } from './types';
4
+ /**
5
+ * Synchronously registers a complete project config with the client: features, conditions,
6
+ * fields, steps, and experiences, in dependency order.
7
+ *
8
+ * Extracted from `dynamicExperiencesPlugin`'s `onStart` so the same registration runs outside
9
+ * the lifecycle (notably from the server `serialize` helper and the SSR provider), where the
10
+ * stores must be populated synchronously before selection or rendering.
11
+ *
12
+ * @param {Picked} client - Picked client instance.
13
+ * @param {ProjectConfig} config - Project configuration to register.
14
+ * @param {object} options - Registration options.
15
+ * @param {boolean} options.isPreview - Whether features use session storage instead of local storage.
16
+ * @param {string} options.sessionId - Current session id, used as the seed for stable feature allocation.
17
+ * @example
18
+ * ```typescript
19
+ * registerProjectConfig(client, config, { isPreview: false, sessionId: 's' })
20
+ * ```
21
+ */
22
+ export declare function registerProjectConfig(client: Picked, config: ProjectConfig, options: {
23
+ isPreview: boolean;
24
+ sessionId: string;
25
+ }): void;
3
26
  /**
4
27
  * Fetches the project configuration from the Picked REST API.
5
28
  *
@@ -16,6 +39,23 @@ import { DynamicExperiencesPluginOptions, FetchProjectOptions, ProjectConfig } f
16
39
  * ```
17
40
  */
18
41
  export declare function fetchProject(apiUrl: string, projectId: string, options?: FetchProjectOptions): Promise<ProjectConfig | null>;
42
+ /**
43
+ * Fetches per-experience content from the Picked API.
44
+ *
45
+ * Returns `null` on network failure, non-OK responses, or invalid JSON shape — preserving
46
+ * the failure-tolerant policy: experiences still render, layouts handle null defensively.
47
+ *
48
+ * @param {string} apiUrl - Base URL for the Picked API.
49
+ * @param {string} projectId - Project ID to fetch content for.
50
+ * @param {string} experienceId - Experience ID whose content to fetch.
51
+ * @param {FetchProjectOptions} [options] - Optional headers and preview token.
52
+ * @returns {Promise<ExperienceContentResponse | null>} Validated content response, or `null` on any failure.
53
+ * @example
54
+ * ```typescript
55
+ * const content = await fetchExperienceContent('https://api.picked.app', 'proj_1', 'exp_1')
56
+ * ```
57
+ */
58
+ export declare function fetchExperienceContent(apiUrl: string, projectId: string, experienceId: string, options?: FetchProjectOptions): Promise<ExperienceContentResponse | null>;
19
59
  /**
20
60
  * Plugin that fetches project configuration from the Picked REST API and registers
21
61
  * features, steps, fields, and experiences with the client.
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAK1D,OAAO,KAAK,EACV,+BAA+B,EAC/B,mBAAmB,EACnB,aAAa,EAGd,MAAM,SAAS,CAAA;AA2VhB;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAmC/B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE,+BAA+B,GAAG,MAAM,CAmD1F"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAoB,MAAM,cAAc,CAAA;AAI5D,OAAO,KAAK,EAEV,+BAA+B,EAC/B,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,EAId,MAAM,SAAS,CAAA;AA4JhB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACjD,IAAI,CAMN;AA4JD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAmC/B;AAoBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAsC3C;AAkPD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE,+BAA+B,GAAG,MAAM,CAgC1F"}
@@ -9,8 +9,14 @@ import { LogicRule, LogicValue } from '../../logic-engine';
9
9
  * keys against `ProjectConfig.fields` at registration time.
10
10
  *
11
11
  * `fieldIds` is optional: layout-only steps (driven purely by `layoutName`) omit it.
12
+ *
13
+ * `layoutContentId` is the wire-format reference to a CMS Content record. The actual
14
+ * content blob is delivered by `dynamicExperiencesPlugin`'s content resolution chain
15
+ * (virtual data module, preview-token API fetch, or direct API fetch) and registered
16
+ * via `client.registerContent`. Steps' derived `layoutContentStore` resolves reactively
17
+ * against the registry at render time.
12
18
  */
13
- export type ApiExperienceStep = Omit<ExperienceStep, 'fieldKeys'> & {
19
+ export type ApiExperienceStep = Omit<ExperienceStep, 'fieldKeys' | 'layoutContentStore'> & {
14
20
  fieldIds?: string[];
15
21
  };
16
22
  export interface ProjectConfigFeature {
@@ -66,9 +72,69 @@ export interface ProjectConfig {
66
72
  export interface DynamicExperiencesPluginOptions {
67
73
  apiUrl?: string;
68
74
  projectConfig?: ProjectConfig;
75
+ /**
76
+ * Customer-supplied content fetcher. When provided, supersedes both the virtual
77
+ * data module and the runtime API for per-experience content resolution.
78
+ * Customers using this override are responsible for project ↔ content version
79
+ * consistency. Receives the resolved experience and the current preview token
80
+ * (when present) so the customer can decide preview semantics themselves.
81
+ */
82
+ getContent?: (experience: {
83
+ id: string;
84
+ key: string;
85
+ }, options?: {
86
+ previewToken?: string;
87
+ }) => Promise<ExperienceContentResponse | null>;
69
88
  }
70
89
  export interface FetchProjectOptions {
71
90
  previewToken?: string;
72
91
  headers?: Record<string, string>;
73
92
  }
93
+ /**
94
+ * Wire-format content blob as returned by the Picked API content endpoint.
95
+ */
96
+ export interface ContentBlob {
97
+ id: string;
98
+ data: Record<string, unknown>;
99
+ }
100
+ /**
101
+ * Wire-format response shape for `GET /api/v1/projects/:projectId/experiences/:experienceId/content`.
102
+ * The response is agnostic of step structure — step ↔ content mapping is encoded in the
103
+ * project blob via `Step.layoutContentId`.
104
+ *
105
+ * `versionId` is the published workspace version id on the published surface and
106
+ * `null` on the preview surface, where there is no published version (mirroring
107
+ * how the preview project-config payload surfaces `versionId: null`).
108
+ */
109
+ export interface ExperienceContentResponse {
110
+ experienceId: string;
111
+ versionId: string | null;
112
+ content: ContentBlob[];
113
+ }
114
+ /**
115
+ * Function that resolves an experience's content blobs. Set on the Picked client by
116
+ * `dynamicExperiencesPlugin` (selecting from virtual module, getContent override, or API)
117
+ * and called by each experience's `prepareExperienceContentFx`, which is fired by the
118
+ * per-experience sample graph in parallel with `initialiseFx`.
119
+ */
120
+ export type ContentLoader = (experience: {
121
+ id: string;
122
+ key: string;
123
+ }, options?: {
124
+ previewToken?: string;
125
+ }) => Promise<ExperienceContentResponse | null>;
126
+ /**
127
+ * Optional-fields surface of the virtual data module exposed by `@picked/vite-plugin-picked`.
128
+ * The shape is identical between dev (`vite serve`) and build (`vite build`) modes.
129
+ */
130
+ export interface VirtualPickedData {
131
+ projectConfig: ProjectConfig;
132
+ experienceContent: ContentLoader;
133
+ manifestMetadata: {
134
+ mode: 'dev' | 'build';
135
+ fetchedAt: string | null;
136
+ projectVersionId: string | null;
137
+ workspaceId: string | null;
138
+ };
139
+ }
74
140
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,gBAAgB,EACjB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAA;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE/D;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,GAAG;IAClE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CACpB,CAAA;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAA;AAE9C;;;;;;GAMG;AACH,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MA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AE,CAAA;CACvB;AAED;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,CAC1B,UAAU,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EACvC,OAAO,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,KAChC,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAAA;AAE9C;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,aAAa,CAAA;IAC5B,iBAAiB,EAAE,aAAa,CAAA;IAChC,gBAAgB,EAAE;QAChB,IAAI,EAAE,KAAK,GAAG,OAAO,CAAA;QACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;QACxB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;QAC/B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;KAC3B,CAAA;CACF"}
@@ -1,23 +1,7 @@
1
1
  import { Plugin } from '../../entities/plugin/plugin';
2
- export declare const STORAGE_KEY: import('../..').StorageKey;
3
2
  /** @public */
4
3
  export interface HistoryBrowserStoragePlugin {
5
4
  storage?: 'local' | 'session';
6
5
  }
7
- /**
8
- * Picked plugin that persists per-experience history snapshots into
9
- * `localStorage` (default) or `sessionStorage` and restores them on plugin
10
- * setup and again on the client `load` event (restore is idempotent — the
11
- * history entity only fills experiences that have no live entries yet).
12
- *
13
- * Reads the v1 flat-array shape transparently and migrates it in place; the
14
- * next debounced save overwrites the v1 bytes with the v2 record shape.
15
- *
16
- * @param {HistoryBrowserStoragePlugin} [options] - Plugin options.
17
- * @param {'local' | 'session'} [options.storage] - Backing store.
18
- * @returns {Plugin} A Picked client plugin.
19
- * @example
20
- * client.use(historyBrowserStoragePlugin({ storage: 'session' }))
21
- */
22
6
  export declare const historyBrowserStoragePlugin: ({ storage, }?: HistoryBrowserStoragePlugin) => Plugin;
23
7
  //# sourceMappingURL=plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/history-browser-storage/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAK1D,eAAO,MAAM,WAAW,4BAAwC,CAAA;AA2DhE,cAAc;AACd,MAAM,WAAW,2BAA2B;IAC1C,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC9B;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,2BAA2B,GAAI,eAEzC,2BAAgC,KAAG,MA2ErC,CAAA"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/history-browser-storage/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAM1D,cAAc;AACd,MAAM,WAAW,2BAA2B;IAC1C,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC9B;AAED,eAAO,MAAM,2BAA2B,GAAI,eAEzC,2BAAgC,KAAG,MA8BrC,CAAA"}
@@ -0,0 +1,14 @@
1
+ /** The `postMessage` `type` discriminator for navigation reports sent to the embedding parent frame. */
2
+ export declare const PREVIEW_NAVIGATION_MESSAGE = "picked-preview:navigation";
3
+ /**
4
+ * Starts reporting this frame's URL to the embedding parent frame: posts immediately, then again on
5
+ * every SPA navigation (`history.pushState`/`replaceState` and `popstate`). Listeners are wired at
6
+ * most once per frame, so multiple Picked clients on the same page do not double-report.
7
+ *
8
+ * @returns {() => void} A teardown function that detaches the `popstate` listener and re-arms the bridge.
9
+ * @example
10
+ * const stop = initPreviewBridge()
11
+ * // later, e.g. in a test: stop()
12
+ */
13
+ export declare function initPreviewBridge(): () => void;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/preview-bridge/index.ts"],"names":[],"mappings":"AAUA,wGAAwG;AACxG,eAAO,MAAM,0BAA0B,8BAA8B,CAAA;AAmErE;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,IAAI,CAwB9C"}
@@ -1,6 +1,12 @@
1
1
  import { Picked } from '../picked';
2
2
  import { ExperienceInstance } from '../entities/experience-instance/experience-instance';
3
3
  import { AdaptedComponent } from '../entities/component/component';
4
+ export { serialize, type PickedSnapshot, type SerializeParams, type SerializeAttributes, type SerializeLocation, type SerializeGetContent, } from './serialize';
5
+ export { createExperienceInstance } from '../entities/experience-instance/experience-instance';
6
+ export type { ExperienceInstance } from '../entities/experience-instance/experience-instance';
7
+ export { registerProjectConfig } from '../plugins/dynamic-experiences/plugin';
8
+ export { hashRule, evaluateConditionMemo, isExperienceActive, } from '../lifecycle/condition-selection';
9
+ export type { ContentBlob, ProjectConfig, ProjectConfigExperience, ExperienceContentResponse, } from '../plugins/dynamic-experiences/types';
4
10
  export interface Renderer<T = AdaptedComponent<string, unknown>> {
5
11
  isValidComponent: (component: AdaptedComponent<string, unknown>) => boolean;
6
12
  render: (component: T, client: Picked, experience: ExperienceInstance) => Promise<{
@@ -14,6 +20,8 @@ export interface Renderer<T = AdaptedComponent<string, unknown>> {
14
20
  * @param {Picked} client - The Picked client instance.
15
21
  * @param {Renderer[]} renderers - Array of available renderers to use.
16
22
  * @returns {Promise<string[]>} A promise resolving to rendered experience HTML strings.
23
+ * @example
24
+ * const html = await render(client, [svelteRenderer])
17
25
  */
18
26
  export declare function render(client: Picked, renderers: Renderer[]): Promise<string[]>;
19
27
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAA;AAE7F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;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