solid-intlayer 9.5.2 → 9.5.4-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,35 +1,35 @@
1
1
  import { compileMarkdown as e } from "./compiler.mjs";
2
- import { createComponent as t } from "solid-js/web";
3
- import { createContext as n, useContext as r } from "solid-js";
2
+ import { createContext as t, useContext as n } from "solid-js";
3
+ import { createComponent as r } from "solid-js/web";
4
4
  //#region src/markdown/MarkdownProvider.tsx
5
- var i = n(), a = (n) => {
6
- let r = (t, r, i, a) => {
7
- if (n.renderMarkdown) return n.renderMarkdown(t, r, i, a);
5
+ var i = t(), a = (t) => {
6
+ let n = (n, r, i, a) => {
7
+ if (t.renderMarkdown) return t.renderMarkdown(n, r, i, a);
8
8
  let o = {
9
- forceBlock: r?.forceBlock ?? n.forceBlock,
10
- preserveFrontmatter: r?.preserveFrontmatter ?? n.preserveFrontmatter,
11
- tagfilter: r?.tagfilter ?? n.tagfilter,
12
- wrapper: a || n.wrapper,
9
+ forceBlock: r?.forceBlock ?? t.forceBlock,
10
+ preserveFrontmatter: r?.preserveFrontmatter ?? t.preserveFrontmatter,
11
+ tagfilter: r?.tagfilter ?? t.tagfilter,
12
+ wrapper: a || t.wrapper,
13
13
  components: {
14
- ...n.components,
14
+ ...t.components,
15
15
  ...i ?? {}
16
16
  }
17
17
  };
18
- return e(t, o);
18
+ return e(n, o);
19
19
  };
20
- return t(i.Provider, {
20
+ return r(i.Provider, {
21
21
  get value() {
22
22
  return {
23
- components: n.components,
24
- renderMarkdown: r
23
+ components: t.components,
24
+ renderMarkdown: n
25
25
  };
26
26
  },
27
27
  get children() {
28
- return n.children;
28
+ return t.children;
29
29
  }
30
30
  });
31
31
  }, o = () => {
32
- let e = r(i);
32
+ let e = n(i);
33
33
  if (!e) throw Error("useMarkdown must be used within a MarkdownProvider. To fix this error, wrap your component with <MarkdownProvider>.");
34
34
  return e;
35
35
  };
@@ -1,39 +1,39 @@
1
1
  import { compileMarkdown as e } from "./compiler.mjs";
2
2
  import { MarkdownContext as t, useMarkdown as n } from "./MarkdownProvider.mjs";
3
- import { createComponent as r } from "solid-js/web";
4
- import { getMarkdownMetadata as i } from "@intlayer/core/markdown";
5
- import { Suspense as a, createMemo as o, createResource as s, useContext as c } from "solid-js";
6
- import { getContentNodeByKeyPath as l } from "@intlayer/core/dictionaryManipulator";
3
+ import { Suspense as r, createMemo as i, createResource as a, useContext as o } from "solid-js";
4
+ import { createComponent as s } from "solid-js/web";
5
+ import { getContentNodeByKeyPath as c } from "@intlayer/core/dictionaryManipulator";
6
+ import { getMarkdownMetadata as l } from "@intlayer/core/markdown";
7
7
  //#region src/markdown/MarkdownRenderer.tsx
8
8
  var u = (t, n = {}) => e(t, n), d = (e = {}) => {
9
- let n = c(t);
9
+ let n = o(t);
10
10
  return (t) => n ? n.renderMarkdown(t, {
11
11
  forceBlock: e.forceBlock,
12
12
  preserveFrontmatter: e.preserveFrontmatter,
13
13
  tagfilter: e.tagfilter
14
14
  }, e.components, e.wrapper) : u(t, e);
15
15
  }, f = (e) => {
16
- let i = c(t), { renderMarkdown: o } = n(), [l] = s(() => [
16
+ let i = o(t), { renderMarkdown: c } = n(), [l] = a(() => [
17
17
  e.children,
18
18
  e.forceBlock,
19
19
  e.preserveFrontmatter,
20
20
  e.tagfilter,
21
21
  e.components,
22
22
  e.wrapper
23
- ], ([e, t, n, r, a, s]) => o(e, {
23
+ ], ([e, t, n, r, a, o]) => c(e, {
24
24
  forceBlock: t,
25
25
  preserveFrontmatter: n,
26
26
  tagfilter: r
27
27
  }, {
28
28
  ...i?.components ?? {},
29
29
  ...a ?? {}
30
- }, s));
31
- return r(a, { get children() {
30
+ }, o));
31
+ return s(r, { get children() {
32
32
  return l();
33
33
  } });
34
34
  }, p = (e) => {
35
- let t = o(() => i(e.children));
36
- return o(() => l(t(), e.metadataKeyPath))();
35
+ let t = i(() => l(e.children));
36
+ return i(() => c(t(), e.metadataKeyPath))();
37
37
  };
38
38
  //#endregion
39
39
  export { p as MarkdownMetadataRenderer, f as MarkdownRenderer, u as renderMarkdown, d as useMarkdownRenderer };
@@ -1,14 +1,14 @@
1
1
  import { reportExposure as e } from "./analytics/exposureSink.mjs";
2
2
  import { renderIntlayerNode as t } from "./IntlayerNode.mjs";
3
3
  import { renderSolidElement as n } from "./solidElement/renderSolidElement.mjs";
4
- import { createComponent as r, mergeProps as i } from "solid-js/web";
5
- import { editor as a, internationalization as o } from "@intlayer/config/built";
6
- import { conditionPlugin as s, enumerationPlugin as c, fallbackPlugin as l, filePlugin as u, genderPlugin as d, isInterpolableWrapperNode as f, nestedPlugin as p, pluralPlugin as m, selectPlugin as h, splitInsertionTemplate as g, transformInterpolableNode as _, translationPlugin as v } from "@intlayer/core/interpreter";
7
- import { getMarkdownMetadata as y } from "@intlayer/core/markdown";
8
- import * as b from "@intlayer/types/nodeType";
9
- import { Suspense as x, lazy as S } from "solid-js";
4
+ import { editor as r, internationalization as i } from "@intlayer/config/built";
5
+ import { Suspense as a, lazy as o } from "solid-js";
6
+ import { createComponent as s, mergeProps as c } from "solid-js/web";
7
+ import { conditionPlugin as l, enumerationPlugin as u, fallbackPlugin as d, filePlugin as f, genderPlugin as p, isInterpolableWrapperNode as m, nestedPlugin as h, pluralPlugin as g, selectPlugin as _, splitInsertionTemplate as v, transformInterpolableNode as y, translationPlugin as b } from "@intlayer/core/interpreter";
8
+ import { getMarkdownMetadata as x } from "@intlayer/core/markdown";
9
+ import * as S from "@intlayer/types/nodeType";
10
10
  //#region src/plugins.tsx
11
- var C = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : S(() => import("./editor/ContentSelector.mjs").then((e) => ({ default: e.ContentSelector }))), w = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? null : import("./markdown/MarkdownRenderer.mjs").then((e) => ({
11
+ var C = process.env.INTLAYER_EDITOR_ENABLED === "false" ? null : o(() => import("./editor/ContentSelector.mjs").then((e) => ({ default: e.ContentSelector }))), w = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? null : import("./markdown/MarkdownRenderer.mjs").then((e) => ({
12
12
  MarkdownRenderer: e.MarkdownRenderer,
13
13
  MarkdownMetadataRenderer: e.MarkdownMetadataRenderer
14
14
  })), T = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? null : import("./html/HTMLRenderer.mjs").then((e) => e.HTMLRenderer);
@@ -16,61 +16,61 @@ w?.catch(() => {}), T?.catch(() => {});
16
16
  var E = {
17
17
  id: "intlayer-node-plugin",
18
18
  canHandle: (e) => typeof e == "bigint" || typeof e == "string" || typeof e == "number",
19
- transform: (n, { plugins: o, ...s }) => (process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && e({
20
- dictionaryKey: s.dictionaryKey,
21
- keyPath: s.keyPath,
22
- locale: s.locale,
19
+ transform: (n, { plugins: i, ...o }) => (process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && e({
20
+ dictionaryKey: o.dictionaryKey,
21
+ keyPath: o.keyPath,
22
+ locale: o.locale,
23
23
  nodeType: "text"
24
24
  }), t({
25
- ...s,
26
- value: s.children,
27
- children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && a.enabled ? r(x, {
25
+ ...o,
26
+ value: o.children,
27
+ children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && r.enabled ? s(a, {
28
28
  get fallback() {
29
- return s.children;
29
+ return o.children;
30
30
  },
31
31
  get children() {
32
- return r(C, i(s, { get children() {
33
- return s.children;
32
+ return s(C, c(o, { get children() {
33
+ return o.children;
34
34
  } }));
35
35
  }
36
- }) : s.children
36
+ }) : o.children
37
37
  }))
38
- }, D = process.env.INTLAYER_NODE_TYPE_SOLID_NODE === "false" ? l : {
38
+ }, D = process.env.INTLAYER_NODE_TYPE_SOLID_NODE === "false" ? d : {
39
39
  id: "solid-node-plugin",
40
40
  canHandle: (e) => typeof e == "object" && e?.props !== void 0 || typeof Node < "u" && e instanceof Node,
41
- transform: (o, { plugins: s, ...c }) => (process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && e({
42
- dictionaryKey: c.dictionaryKey,
43
- keyPath: c.keyPath,
44
- locale: c.locale,
41
+ transform: (i, { plugins: o, ...l }) => (process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && e({
42
+ dictionaryKey: l.dictionaryKey,
43
+ keyPath: l.keyPath,
44
+ locale: l.locale,
45
45
  nodeType: "solid-node"
46
46
  }), t({
47
- ...c,
47
+ ...l,
48
48
  value: "[[solid-element]]",
49
- children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && a.enabled ? r(x, {
49
+ children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && r.enabled ? s(a, {
50
50
  get fallback() {
51
- return typeof Node < "u" && o instanceof Node ? o : n(o);
51
+ return typeof Node < "u" && i instanceof Node ? i : n(i);
52
52
  },
53
53
  get children() {
54
- return r(C, i(c, { get children() {
55
- return typeof Node < "u" && o instanceof Node ? o : n(o);
54
+ return s(C, c(l, { get children() {
55
+ return typeof Node < "u" && i instanceof Node ? i : n(i);
56
56
  } }));
57
57
  }
58
- }) : typeof Node < "u" && o instanceof Node ? o : n(o)
58
+ }) : typeof Node < "u" && i instanceof Node ? i : n(i)
59
59
  }))
60
60
  }, O = (e, t) => {
61
- let n = g(e, t);
61
+ let n = v(e, t);
62
62
  return n.isSimple, n.parts;
63
- }, k = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ? l : {
63
+ }, k = process.env.INTLAYER_NODE_TYPE_INSERTION === "false" ? d : {
64
64
  id: "insertion-plugin",
65
- canHandle: (e) => typeof e == "object" && e?.nodeType === b.INSERTION,
65
+ canHandle: (e) => typeof e == "object" && e?.nodeType === S.INSERTION,
66
66
  transform: (e, t, n) => {
67
- let r = [...t.keyPath, { type: b.INSERTION }], i = e[b.INSERTION];
67
+ let r = [...t.keyPath, { type: S.INSERTION }], i = e[S.INSERTION];
68
68
  return (e) => {
69
69
  let a = {
70
70
  id: "insertion-string-plugin",
71
- canHandle: (e) => typeof e == "string" || f(e),
71
+ canHandle: (e) => typeof e == "string" || m(e),
72
72
  transform: (n, r, i) => {
73
- if (f(n)) return _(n, e, r, t.plugins, i);
73
+ if (m(n)) return y(n, e, r, t.plugins, i);
74
74
  let a = O(i(n, {
75
75
  ...r,
76
76
  children: n,
@@ -91,67 +91,67 @@ var E = {
91
91
  });
92
92
  };
93
93
  }
94
- }, A = S(() => w.then((e) => ({ default: e.MarkdownRenderer }))), j = S(() => w.then((e) => ({ default: e.MarkdownMetadataRenderer }))), M = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? l : {
94
+ }, A = o(() => w.then((e) => ({ default: e.MarkdownRenderer }))), j = o(() => w.then((e) => ({ default: e.MarkdownMetadataRenderer }))), M = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? d : {
95
95
  id: "markdown-string-plugin",
96
96
  canHandle: (e) => typeof e == "string",
97
- transform: (e, n, o) => {
98
- let { plugins: s, ...c } = n, l = o(y(e) ?? {}, {
97
+ transform: (e, n, i) => {
98
+ let { plugins: o, ...l } = n, u = i(x(e) ?? {}, {
99
99
  plugins: [{
100
100
  id: "markdown-metadata-plugin",
101
101
  canHandle: (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || !e,
102
- transform: (n, o) => t({
103
- ...o,
102
+ transform: (n, i) => t({
103
+ ...i,
104
104
  value: n,
105
- children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && a.enabled ? r(x, { get children() {
106
- return r(C, i(c, { get children() {
107
- return r(j, i(c, {
105
+ children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && r.enabled ? s(a, { get children() {
106
+ return s(C, c(l, { get children() {
107
+ return s(j, c(l, {
108
108
  get metadataKeyPath() {
109
- return o.keyPath;
109
+ return i.keyPath;
110
110
  },
111
111
  children: e
112
112
  }));
113
113
  } }));
114
- } }) : r(j, i(c, {
114
+ } }) : s(j, c(l, {
115
115
  get metadataKeyPath() {
116
- return o.keyPath;
116
+ return i.keyPath;
117
117
  },
118
118
  children: e
119
119
  }))
120
120
  })
121
121
  }],
122
- dictionaryKey: c.dictionaryKey,
122
+ dictionaryKey: l.dictionaryKey,
123
123
  keyPath: []
124
- }), u = (o) => t({
124
+ }), d = (i) => t({
125
125
  ...n,
126
126
  value: e,
127
- children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && a.enabled ? r(x, { get children() {
128
- return r(C, i(c, { get children() {
129
- return r(A, i(c, {
130
- components: o,
127
+ children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && r.enabled ? s(a, { get children() {
128
+ return s(C, c(l, { get children() {
129
+ return s(A, c(l, {
130
+ components: i,
131
131
  children: e
132
132
  }));
133
133
  } }));
134
- } }) : r(A, i(c, {
135
- components: o,
134
+ } }) : s(A, c(l, {
135
+ components: i,
136
136
  children: e
137
137
  })),
138
- additionalProps: { metadata: l }
139
- }), d = u();
140
- return new Proxy(d, { get(t, n, r) {
138
+ additionalProps: { metadata: u }
139
+ }), f = d();
140
+ return new Proxy(f, { get(t, n, r) {
141
141
  if (n === "value") return e;
142
142
  if (n === Symbol.toPrimitive || n === "toString" || n === "valueOf") return () => e;
143
143
  if (typeof n == "string" && n !== "constructor") {
144
144
  let t = String.prototype[n];
145
145
  if (typeof t == "function") return t.bind(e);
146
146
  }
147
- return n === "metadata" ? l : n === "use" ? (e) => u(e) : Reflect.get(t, n, r);
147
+ return n === "metadata" ? u : n === "use" ? (e) => d(e) : Reflect.get(t, n, r);
148
148
  } });
149
149
  }
150
- }, N = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? l : {
150
+ }, N = process.env.INTLAYER_NODE_TYPE_MARKDOWN === "false" ? d : {
151
151
  id: "markdown-plugin",
152
- canHandle: (e) => typeof e == "object" && e?.nodeType === b.MARKDOWN,
152
+ canHandle: (e) => typeof e == "object" && e?.nodeType === S.MARKDOWN,
153
153
  transform: (e, t, n) => {
154
- let r = [...t.keyPath, { type: b.MARKDOWN }], i = e[b.MARKDOWN];
154
+ let r = [...t.keyPath, { type: S.MARKDOWN }], i = e[S.MARKDOWN];
155
155
  return n(i, {
156
156
  ...t,
157
157
  children: i,
@@ -159,47 +159,47 @@ var E = {
159
159
  plugins: [M, ...t.plugins ?? []]
160
160
  });
161
161
  }
162
- }, P = S(() => T.then((e) => ({ default: e }))), F = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? l : {
162
+ }, P = o(() => T.then((e) => ({ default: e }))), F = process.env.INTLAYER_NODE_TYPE_HTML === "false" ? d : {
163
163
  id: "html-plugin",
164
- canHandle: (e) => typeof e == "object" && e?.nodeType === b.HTML,
164
+ canHandle: (e) => typeof e == "object" && e?.nodeType === S.HTML,
165
165
  transform: (e, n) => {
166
- let o = e[b.HTML], { plugins: s, children: c, ...l } = n, u = (e) => t({
167
- ...l,
168
- value: o,
169
- children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && a.enabled ? r(x, { get children() {
170
- return r(C, i(l, { get children() {
171
- return r(P, i(l, {
172
- html: o,
166
+ let i = e[S.HTML], { plugins: o, children: l, ...u } = n, d = (e) => t({
167
+ ...u,
168
+ value: i,
169
+ children: process.env.INTLAYER_EDITOR_ENABLED !== "false" && r.enabled ? s(a, { get children() {
170
+ return s(C, c(u, { get children() {
171
+ return s(P, c(u, {
172
+ html: i,
173
173
  components: e
174
174
  }));
175
175
  } }));
176
- } }) : r(P, i(l, {
177
- html: o,
176
+ } }) : s(P, c(u, {
177
+ html: i,
178
178
  components: e
179
179
  }))
180
- }), d = [u()];
181
- return new Proxy(d, { get(e, t, n) {
182
- if (t === "value") return o;
183
- if (t === Symbol.toPrimitive || t === "toString" || t === "valueOf") return () => o;
180
+ }), f = [d()];
181
+ return new Proxy(f, { get(e, t, n) {
182
+ if (t === "value") return i;
183
+ if (t === Symbol.toPrimitive || t === "toString" || t === "valueOf") return () => i;
184
184
  if (typeof t == "string" && t !== "constructor") {
185
185
  let e = String.prototype[t];
186
- if (typeof e == "function") return e.bind(o);
186
+ if (typeof e == "function") return e.bind(i);
187
187
  }
188
- return t === "use" ? (e) => u(e) : Reflect.get(e, t, n);
188
+ return t === "use" ? (e) => d(e) : Reflect.get(e, t, n);
189
189
  } });
190
190
  }
191
191
  }, I = /* @__PURE__ */ new Map(), L = (e, t = !0) => {
192
- let n = `${e ?? o.defaultLocale}_${t}`;
192
+ let n = `${e ?? i.defaultLocale}_${t}`;
193
193
  if (I.has(n)) return I.get(n);
194
194
  let r = [
195
- v(e ?? o.defaultLocale, t ? o.defaultLocale : void 0),
196
- c,
197
- m(e ?? o.defaultLocale),
198
- s,
199
- p(e ?? o.defaultLocale),
195
+ b(e ?? i.defaultLocale, t ? i.defaultLocale : void 0),
200
196
  u,
201
- d,
202
- h,
197
+ g(e ?? i.defaultLocale),
198
+ l,
199
+ h(e ?? i.defaultLocale),
200
+ f,
201
+ p,
202
+ _,
203
203
  E,
204
204
  D,
205
205
  k,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-intlayer",
3
- "version": "9.5.2",
3
+ "version": "9.5.4-canary.0",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your Solid applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -107,17 +107,18 @@
107
107
  "prepublish": "cp -f ../../README.md ./README.md",
108
108
  "publish": "bun publish || true",
109
109
  "publish:canary": "bun publish --access public --tag canary || true",
110
+ "publish:ci": "bun ../../scripts/publish-package.mjs",
110
111
  "publish:latest": "bun publish --access public --tag latest || true",
111
112
  "test": "bun --bun vitest run",
112
113
  "test:watch": "bun --bun vitest",
113
114
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
114
115
  },
115
116
  "dependencies": {
116
- "@intlayer/api": "9.5.2",
117
- "@intlayer/config": "9.5.2",
118
- "@intlayer/core": "9.5.2",
119
- "@intlayer/editor": "9.5.2",
120
- "@intlayer/types": "9.5.2"
117
+ "@intlayer/api": "9.5.4-canary.0",
118
+ "@intlayer/config": "9.5.4-canary.0",
119
+ "@intlayer/core": "9.5.4-canary.0",
120
+ "@intlayer/editor": "9.5.4-canary.0",
121
+ "@intlayer/types": "9.5.4-canary.0"
121
122
  },
122
123
  "devDependencies": {
123
124
  "@solidjs/testing-library": "0.8.10",
@@ -128,20 +129,20 @@
128
129
  "@utils/ts-config": "1.0.4",
129
130
  "@utils/ts-config-types": "1.0.4",
130
131
  "@utils/tsdown-config": "1.0.4",
131
- "jsdom": "30.0.1",
132
+ "jsdom": "30.1.0",
132
133
  "rimraf": "6.1.3",
133
134
  "tsdown": "0.23.0",
134
135
  "typescript": "7.0.2",
135
136
  "vite": "8.3.0",
136
137
  "vite-plugin-dts": "5.1.0",
137
138
  "vite-plugin-solid": "2.11.14",
138
- "vitest": "5.0.0"
139
+ "vitest": "5.0.1"
139
140
  },
140
141
  "peerDependencies": {
141
142
  "solid-js": ">=1.0.0"
142
143
  },
143
144
  "optionalDependencies": {
144
- "@intlayer/analytics": "9.5.2"
145
+ "@intlayer/analytics": "9.5.4-canary.0"
145
146
  },
146
147
  "engines": {
147
148
  "node": ">=14.18"
@@ -1 +0,0 @@
1
- const e=require("./isEnabled-CuTKz0YA.js");let t=require("@intlayer/config/built");var n=e=>{let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0},r=(e,t,r,i)=>{if(r.length===0)throw Error(`assignVariant requires at least one variant`);if(r.length===1)return r[0];let a=n(`${e}:${t}`)/4294967296;if(!i||i.length!==r.length){let e=Math.floor(a*r.length);return r[Math.min(e,r.length-1)]}let o=i.reduce((e,t)=>e+t,0);if(o<=0)return r[Math.floor(a*r.length)];let s=0,c=a*o;for(let e=0;e<r.length;e++)if(s+=i[e],c<s)return r[e];return r[r.length-1]},i=``,a=e=>[e.url,e.dictionaryKey,e.keyPath,e.locale,e.experimentKey??``,e.variant??``].join(i),o=({max:e})=>{let t=[],n=new Map,r=()=>t.length+n.size,i=()=>{for(;r()>e&&n.size>0;){let e=n.keys().next().value;n.delete(e)}r()>e&&(t=t.slice(r()-e))};return{push:e=>{if(e.type===`content_exposure`){let t=a(e),r=n.get(t);r?(r.count=(r.count??1)+(e.count??1),r.t=e.t):n.set(t,{...e,count:e.count??1})}else t.push(e);return i(),r()},drain:()=>{let e=[...t,...n.values()];return t=[],n.clear(),e},size:r}},s=(e,t)=>t>=1?!0:t<=0?!1:n(e)/4294967295<t,c=`__intlayer_analytics_sid__`,l=()=>{let e=typeof globalThis<`u`?globalThis.crypto:void 0;return e?.randomUUID?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`},u=()=>{if(typeof window>`u`||!window.sessionStorage)return l();try{let e=window.sessionStorage.getItem(c);if(e)return e;let t=l();return window.sessionStorage.setItem(c,t),t}catch{return l()}},d=(e,t,{useBeacon:n=!1,token:r}={})=>{try{let i=JSON.stringify(t);return n&&typeof navigator<`u`&&typeof navigator.sendBeacon==`function`?navigator.sendBeacon(e,i):typeof fetch==`function`&&(fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`,...r?{Authorization:`Bearer ${r}`}:{}},body:i,keepalive:!0,credentials:`omit`,mode:`cors`}).catch(()=>{}),!0)}catch{return!1}},f=e=>{if(typeof window>`u`)return;let t=window.requestIdleCallback;if(typeof t==`function`){t(()=>e());return}setTimeout(e,1)},p=`__intlayer_public_token__`,m=6e4,h=()=>{try{let e=window.sessionStorage?.getItem(p);if(!e)return null;let t=JSON.parse(e);return typeof t?.token!=`string`||typeof t?.expiresAt!=`number`?null:t}catch{return null}},g=e=>{try{window.sessionStorage?.setItem(p,JSON.stringify(e))}catch{}},_=({backendURL:e,clientId:t})=>{let n=`${e.replace(/\/$/,``)}/api/public/token`,r=null,i=null,a=e=>e!==null&&e.expiresAt-m>Date.now(),o=()=>{if(a(r))return r.token;if(typeof window<`u`){let e=h();if(a(e))return r=e,e.token}},s=async()=>{try{let e=await fetch(n,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clientId:t}),credentials:`omit`,mode:`cors`});if(!e.ok)return;let i=await e.json(),a=i?.data?.token,o=i?.data?.expiresIn??0;if(!a||o<=0)return;r={token:a,expiresAt:Date.now()+o*1e3},typeof window<`u`&&g(r)}catch{}finally{i=null}};return{getToken:o,prime:()=>{!t||typeof fetch!=`function`||o()||(i||=s())}}},v=`intlayer-analytics/1`,y=()=>typeof window>`u`||!window.location?``:window.location.pathname,b=()=>{if(!(typeof document>`u`||!document.referrer))try{return new URL(document.referrer).host}catch{return}},x=t=>{let n=u(),i=e.r(),a=!i&&s(n,t.sampleRate),c=o({max:t.maxBufferSize}),l=`${t.backendURL.replace(/\/$/,``)}/api/analytics/events`,p=_({backendURL:t.backendURL,clientId:t.clientId}),m=``,h=null,g=!1,x=null,S=null,C=new Set,w=(e=!1)=>{let r=c.drain(),i=p.getToken();for(let a=0;a<r.length;a+=200)d(l,{token:i,clientId:i?void 0:t.clientId,sessionId:n,sdkVersion:v,events:r.slice(a,a+200)},{useBeacon:e,token:i})},T=e=>{c.push(e)>=t.maxBufferSize&&w()},E=e=>{m=e},D=(e={})=>{if(!a)return;let t=e.url??y(),n=e.reason??`initial`;(n!==`route_change`||t!==S)&&(S=t,C=new Set,T({type:`page_view`,t:Date.now(),url:t,locale:e.locale??m,ref:e.ref??b(),vw:e.vw??(typeof window<`u`?window.innerWidth:void 0),vh:e.vh??(typeof window<`u`?window.innerHeight:void 0),reason:n}))},O=e=>{if(!a)return;let t=e.locale??m,n=[e.dictionaryKey,e.keyPath,t,e.experimentKey??``,e.variant??``].join(``);C.has(n)||(C.add(n),T({...e,type:`content_exposure`,t:Date.now(),url:y(),locale:t}))},k=e=>{i||(T({...e,type:`conversion`,t:Date.now(),url:y(),locale:e.locale??m}),w())},A=(e,t,i)=>r(n,e,t,i),j=()=>{if(typeof window>`u`)return;let e=()=>{document.visibilityState===`hidden`&&w(!0)},t=()=>w(!0),n=()=>D({reason:`route_change`});document.addEventListener(`visibilitychange`,e),window.addEventListener(`pagehide`,t,{capture:!0}),window.addEventListener(`popstate`,n);let r=window.history,i=r.pushState,a=function(...e){let t=i.apply(this,e);return D({reason:`route_change`}),t};r.pushState=a,x=()=>{document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`pagehide`,t,{capture:!0}),window.removeEventListener(`popstate`,n),r.pushState===a&&(r.pushState=i)}};return{setLocale:E,trackPageView:D,trackContentExposure:O,trackConversion:k,getVariant:A,flush:w,start:()=>{g||i||(g=!0,p.prime(),h=setInterval(w,t.flushInterval),h?.unref?.(),f(j))},stop:()=>{g&&(g=!1,h&&=(clearInterval(h),null),x?.(),x=null,w(!0))}}},S=`__intlayer_analytics_client__`,C=`__intlayer_analytics_ref_count__`,w=()=>typeof window>`u`?null:window[S]??null,T=e=>{typeof window>`u`||(window[S]=e)},E=()=>{if(typeof window>`u`)return 0;let e=window;return e[C]=(e[C]??0)+1,e[C]},D=()=>{if(typeof window>`u`)return 0;let e=window;return e[C]=Math.max(0,(e[C]??0)-1),e[C]},O=()=>{E();let e=w();if(e)return e;let n=x({backendURL:t.editor?.backendURL??``,clientId:t.editor?.clientId,flushInterval:t.analytics?.flushInterval??2e4,maxBufferSize:500,sampleRate:t.analytics?.sampleRate??1});return T(n),n.start(),n},k=()=>{D()>0||(w()?.stop(),T(null))},A=e=>e.map(e=>e.key===void 0?`*`:String(e.key)).join(`.`),j=e=>({dictionaryKey:e.dictionaryKey,keyPath:A(e.keyPath),locale:e.locale,nodeType:e.nodeType,experimentKey:e.experimentKey,variant:e.variant});exports.buildContentExposure=j,exports.getGlobalAnalyticsClient=w,exports.initAnalyticsClient=O,exports.stopAnalyticsClient=k;