@c15t/scripts 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -25,6 +25,7 @@ Connect analytics, advertising, maps, media, and other third-party tools behind
25
25
  - [Crisp](./docs/integrations/crisp.md): Load Crisp live chat with website ID, runtime, cookie, and session options.
26
26
  - [Databuddy](./docs/integrations/databuddy.md): Databuddy is a privacy-focused analytics platform that helps you understand user behavior and track events. It supports cookieless tracking and manages consent automatically through c15t's consent state synchronization.
27
27
  - [Fathom Analytics](./docs/integrations/fathom-analytics.md): Privacy-friendly cookieless analytics with a prebuilt helper that maps Fathom's data attributes into a c15t-managed script.
28
+ - [Front Chat](./docs/integrations/front-chat.md): Load Front Chat after functionality consent and initialize the widget when its SDK is ready.
28
29
  - [Google Maps](./docs/integrations/google-maps.md): Render Google Maps only after consent with one shared Maps JavaScript API loader and independently managed map instances.
29
30
  - [GA4 + Google Ads (gtag.js)](./docs/integrations/google-tag.md): Send data to Google Analytics 4 and Google Ads with automatic Consent Mode v2 support.
30
31
  - [Google Tag Manager](./docs/integrations/google-tag-manager.md): Deploy and manage marketing tags centrally with automatic consent state synchronization.
@@ -39,7 +40,9 @@ Connect analytics, advertising, maps, media, and other third-party tools behind
39
40
  - [Microsoft Clarity](./docs/integrations/microsoft-clarity.md): Session replay and behavior analytics with a prebuilt helper that keeps Clarity consent synchronized with c15t measurement state.
40
41
  - [Microsoft UET](./docs/integrations/microsoft-uet.md): Track conversions and measure performance for Microsoft Advertising and Bing Ads.
41
42
  - [Mixpanel Analytics](./docs/integrations/mixpanel-analytics.md): Load Mixpanel with c15t and let Mixpanel's own opt-in and opt-out APIs follow measurement consent.
43
+ - [OneDollarStats](./docs/integrations/one-dollar-stats.md): Load OneDollarStats after measurement consent with optional tracker data attributes.
42
44
  - [Integrations](./docs/integrations/overview.md): Load analytics, pixels, tag managers, and widgets through c15t so consent state controls when they run, update, and appear in your consent UI.
45
+ - [Pinterest Tag](./docs/integrations/pinterest-tag.md): Track conversions and build audiences for Pinterest advertising campaigns.
43
46
  - [Pirsch](./docs/integrations/pirsch.md): Privacy-friendly, cookieless analytics loaded with Pirsch's fixed script id and identification-code attributes.
44
47
  - [Plausible Analytics](./docs/integrations/plausible-analytics.md): Privacy-friendly cookieless analytics with a prebuilt helper that preserves Plausible's queue bootstrap and loader attributes.
45
48
  - [PostHog](./docs/integrations/posthog.md): PostHog is an open-source product analytics platform for tracking user behavior, session replays, feature flags, and A/B testing. It supports cookieless tracking, allowing analytics to continue even without cookie consent.
@@ -116,6 +116,7 @@ function resetVendorGlobals() {
116
116
  'pirschClearSession',
117
117
  'pirschInit',
118
118
  'pirschNotFound',
119
+ 'pintrk',
119
120
  'plausible',
120
121
  'posthog',
121
122
  'rdt',
@@ -75,6 +75,7 @@ function resetVendorGlobals() {
75
75
  'pirschClearSession',
76
76
  'pirschInit',
77
77
  'pirschNotFound',
78
+ 'pintrk',
78
79
  'plausible',
79
80
  'posthog',
80
81
  'rdt',
package/dist/registry.cjs CHANGED
@@ -216,6 +216,16 @@ const builtInScriptIntegrations = [
216
216
  integrationCategory: 'analytics',
217
217
  consentCategory: 'measurement'
218
218
  },
219
+ {
220
+ key: 'oneDollarStats',
221
+ vendor: 'one-dollar-stats',
222
+ label: 'OneDollarStats',
223
+ hint: 'Website analytics with no API key',
224
+ docsSlug: 'one-dollar-stats',
225
+ packageSubpath: 'one-dollar-stats',
226
+ integrationCategory: 'analytics',
227
+ consentCategory: 'measurement'
228
+ },
219
229
  {
220
230
  key: 'posthog',
221
231
  vendor: 'posthog',
@@ -306,6 +316,16 @@ const builtInScriptIntegrations = [
306
316
  integrationCategory: 'functional',
307
317
  consentCategory: 'functionality'
308
318
  },
319
+ {
320
+ key: 'frontChat',
321
+ vendor: 'front-chat',
322
+ label: 'Front Chat',
323
+ hint: 'Live chat widget',
324
+ docsSlug: 'front-chat',
325
+ packageSubpath: 'front-chat',
326
+ integrationCategory: 'functional',
327
+ consentCategory: 'functionality'
328
+ },
309
329
  {
310
330
  key: 'intercom',
311
331
  vendor: 'intercom',
@@ -385,6 +405,16 @@ const builtInScriptIntegrations = [
385
405
  packageSubpath: 'x-pixel',
386
406
  integrationCategory: 'ads-and-pixels',
387
407
  consentCategory: 'marketing'
408
+ },
409
+ {
410
+ key: 'pinterestTag',
411
+ vendor: 'pinterest-tag',
412
+ label: 'Pinterest Tag',
413
+ hint: 'Pinterest ads tracking',
414
+ docsSlug: 'pinterest-tag',
415
+ packageSubpath: 'pinterest-tag',
416
+ integrationCategory: 'ads-and-pixels',
417
+ consentCategory: 'marketing'
388
418
  }
389
419
  ];
390
420
  function getBuiltInScriptIntegration(key) {
package/dist/registry.js CHANGED
@@ -187,6 +187,16 @@ const builtInScriptIntegrations = [
187
187
  integrationCategory: 'analytics',
188
188
  consentCategory: 'measurement'
189
189
  },
190
+ {
191
+ key: 'oneDollarStats',
192
+ vendor: 'one-dollar-stats',
193
+ label: 'OneDollarStats',
194
+ hint: 'Website analytics with no API key',
195
+ docsSlug: 'one-dollar-stats',
196
+ packageSubpath: 'one-dollar-stats',
197
+ integrationCategory: 'analytics',
198
+ consentCategory: 'measurement'
199
+ },
190
200
  {
191
201
  key: 'posthog',
192
202
  vendor: 'posthog',
@@ -277,6 +287,16 @@ const builtInScriptIntegrations = [
277
287
  integrationCategory: 'functional',
278
288
  consentCategory: 'functionality'
279
289
  },
290
+ {
291
+ key: 'frontChat',
292
+ vendor: 'front-chat',
293
+ label: 'Front Chat',
294
+ hint: 'Live chat widget',
295
+ docsSlug: 'front-chat',
296
+ packageSubpath: 'front-chat',
297
+ integrationCategory: 'functional',
298
+ consentCategory: 'functionality'
299
+ },
280
300
  {
281
301
  key: 'intercom',
282
302
  vendor: 'intercom',
@@ -356,6 +376,16 @@ const builtInScriptIntegrations = [
356
376
  packageSubpath: 'x-pixel',
357
377
  integrationCategory: 'ads-and-pixels',
358
378
  consentCategory: 'marketing'
379
+ },
380
+ {
381
+ key: 'pinterestTag',
382
+ vendor: 'pinterest-tag',
383
+ label: 'Pinterest Tag',
384
+ hint: 'Pinterest ads tracking',
385
+ docsSlug: 'pinterest-tag',
386
+ packageSubpath: 'pinterest-tag',
387
+ integrationCategory: 'ads-and-pixels',
388
+ consentCategory: 'marketing'
359
389
  }
360
390
  ];
361
391
  function getBuiltInScriptIntegration(key) {
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ pinterestTag: ()=>pinterestTag,
32
+ pinterestTagEvent: ()=>pinterestTagEvent,
33
+ pinterestTagManifest: ()=>pinterestTagManifest
34
+ });
35
+ const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
36
+ const external_types_cjs_namespaceObject = require("../../types.cjs");
37
+ const script_url_cjs_namespaceObject = require("../_shared/script-url.cjs");
38
+ const pinterestTagManifest = {
39
+ ...external_types_cjs_namespaceObject.vendorManifestContract,
40
+ vendor: 'pinterest-tag',
41
+ category: 'marketing',
42
+ persistAfterConsentRevoked: true,
43
+ bootstrap: [
44
+ {
45
+ type: 'defineStubFunction',
46
+ name: 'pintrk',
47
+ queue: {
48
+ property: 'queue'
49
+ },
50
+ queueFormat: 'array',
51
+ properties: {
52
+ version: '3.0'
53
+ },
54
+ ifUndefined: true
55
+ }
56
+ ],
57
+ install: [
58
+ {
59
+ type: 'callGlobal',
60
+ global: 'pintrk',
61
+ args: [
62
+ 'load',
63
+ '{{tagId}}'
64
+ ]
65
+ },
66
+ {
67
+ type: 'callGlobal',
68
+ global: 'pintrk',
69
+ args: [
70
+ 'setconsent',
71
+ true
72
+ ]
73
+ },
74
+ {
75
+ type: 'callGlobal',
76
+ global: 'pintrk',
77
+ args: [
78
+ 'page'
79
+ ]
80
+ },
81
+ {
82
+ type: 'loadScript',
83
+ src: "{{scriptUrl}}",
84
+ async: true
85
+ }
86
+ ],
87
+ onConsentGranted: [
88
+ {
89
+ type: 'callGlobal',
90
+ global: 'pintrk',
91
+ args: [
92
+ 'setconsent',
93
+ true
94
+ ]
95
+ }
96
+ ],
97
+ onConsentDenied: [
98
+ {
99
+ type: 'callGlobal',
100
+ global: 'pintrk',
101
+ args: [
102
+ 'setconsent',
103
+ false
104
+ ]
105
+ }
106
+ ]
107
+ };
108
+ function pinterestTag({ tagId, loadOptions, trackPageVisit = true, scriptUrl }) {
109
+ const loadArgs = [
110
+ 'load',
111
+ '{{tagId}}'
112
+ ];
113
+ if (void 0 !== loadOptions) loadArgs.push('{{loadOptions}}');
114
+ const install = [
115
+ {
116
+ type: 'callGlobal',
117
+ global: 'pintrk',
118
+ args: loadArgs
119
+ },
120
+ {
121
+ type: 'callGlobal',
122
+ global: 'pintrk',
123
+ args: [
124
+ 'setconsent',
125
+ true
126
+ ]
127
+ }
128
+ ];
129
+ if (trackPageVisit) install.push({
130
+ type: 'callGlobal',
131
+ global: 'pintrk',
132
+ args: [
133
+ 'page'
134
+ ]
135
+ });
136
+ install.push({
137
+ type: 'loadScript',
138
+ src: "{{scriptUrl}}",
139
+ async: true
140
+ });
141
+ const manifest = {
142
+ ...pinterestTagManifest,
143
+ install
144
+ };
145
+ return (0, external_resolve_cjs_namespaceObject.resolveManifest)(manifest, {
146
+ tagId,
147
+ loadOptions,
148
+ scriptUrl: (0, script_url_cjs_namespaceObject.resolveScriptUrl)(scriptUrl, 'https://s.pinimg.com/ct/core.js')
149
+ });
150
+ }
151
+ const pinterestTagEvent = (eventName, eventData, callback)=>{
152
+ if ("u" < typeof window || 'function' != typeof window.pintrk) return;
153
+ if (void 0 !== callback) return void window.pintrk('track', eventName, eventData ?? {}, callback);
154
+ if (void 0 === eventData) return void window.pintrk('track', eventName);
155
+ window.pintrk('track', eventName, eventData);
156
+ };
157
+ exports.pinterestTag = __webpack_exports__.pinterestTag;
158
+ exports.pinterestTagEvent = __webpack_exports__.pinterestTagEvent;
159
+ exports.pinterestTagManifest = __webpack_exports__.pinterestTagManifest;
160
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
161
+ "pinterestTag",
162
+ "pinterestTagEvent",
163
+ "pinterestTagManifest"
164
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
165
+ Object.defineProperty(exports, '__esModule', {
166
+ value: true
167
+ });
@@ -0,0 +1,123 @@
1
+ import { resolveManifest } from "../../resolve.js";
2
+ import { vendorManifestContract } from "../../types.js";
3
+ import { resolveScriptUrl } from "../_shared/script-url.js";
4
+ const pinterestTagManifest = {
5
+ ...vendorManifestContract,
6
+ vendor: 'pinterest-tag',
7
+ category: 'marketing',
8
+ persistAfterConsentRevoked: true,
9
+ bootstrap: [
10
+ {
11
+ type: 'defineStubFunction',
12
+ name: 'pintrk',
13
+ queue: {
14
+ property: 'queue'
15
+ },
16
+ queueFormat: 'array',
17
+ properties: {
18
+ version: '3.0'
19
+ },
20
+ ifUndefined: true
21
+ }
22
+ ],
23
+ install: [
24
+ {
25
+ type: 'callGlobal',
26
+ global: 'pintrk',
27
+ args: [
28
+ 'load',
29
+ '{{tagId}}'
30
+ ]
31
+ },
32
+ {
33
+ type: 'callGlobal',
34
+ global: 'pintrk',
35
+ args: [
36
+ 'setconsent',
37
+ true
38
+ ]
39
+ },
40
+ {
41
+ type: 'callGlobal',
42
+ global: 'pintrk',
43
+ args: [
44
+ 'page'
45
+ ]
46
+ },
47
+ {
48
+ type: 'loadScript',
49
+ src: "{{scriptUrl}}",
50
+ async: true
51
+ }
52
+ ],
53
+ onConsentGranted: [
54
+ {
55
+ type: 'callGlobal',
56
+ global: 'pintrk',
57
+ args: [
58
+ 'setconsent',
59
+ true
60
+ ]
61
+ }
62
+ ],
63
+ onConsentDenied: [
64
+ {
65
+ type: 'callGlobal',
66
+ global: 'pintrk',
67
+ args: [
68
+ 'setconsent',
69
+ false
70
+ ]
71
+ }
72
+ ]
73
+ };
74
+ function pinterestTag({ tagId, loadOptions, trackPageVisit = true, scriptUrl }) {
75
+ const loadArgs = [
76
+ 'load',
77
+ '{{tagId}}'
78
+ ];
79
+ if (void 0 !== loadOptions) loadArgs.push('{{loadOptions}}');
80
+ const install = [
81
+ {
82
+ type: 'callGlobal',
83
+ global: 'pintrk',
84
+ args: loadArgs
85
+ },
86
+ {
87
+ type: 'callGlobal',
88
+ global: 'pintrk',
89
+ args: [
90
+ 'setconsent',
91
+ true
92
+ ]
93
+ }
94
+ ];
95
+ if (trackPageVisit) install.push({
96
+ type: 'callGlobal',
97
+ global: 'pintrk',
98
+ args: [
99
+ 'page'
100
+ ]
101
+ });
102
+ install.push({
103
+ type: 'loadScript',
104
+ src: "{{scriptUrl}}",
105
+ async: true
106
+ });
107
+ const manifest = {
108
+ ...pinterestTagManifest,
109
+ install
110
+ };
111
+ return resolveManifest(manifest, {
112
+ tagId,
113
+ loadOptions,
114
+ scriptUrl: resolveScriptUrl(scriptUrl, 'https://s.pinimg.com/ct/core.js')
115
+ });
116
+ }
117
+ const pinterestTagEvent = (eventName, eventData, callback)=>{
118
+ if ("u" < typeof window || 'function' != typeof window.pintrk) return;
119
+ if (void 0 !== callback) return void window.pintrk('track', eventName, eventData ?? {}, callback);
120
+ if (void 0 === eventData) return void window.pintrk('track', eventName);
121
+ window.pintrk('track', eventName, eventData);
122
+ };
123
+ export { pinterestTag, pinterestTagEvent, pinterestTagManifest };
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ ONE_DOLLAR_STATS_SCRIPT_SRC: ()=>ONE_DOLLAR_STATS_SCRIPT_SRC,
32
+ oneDollarStats: ()=>oneDollarStats,
33
+ oneDollarStatsManifest: ()=>oneDollarStatsManifest
34
+ });
35
+ const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
36
+ const external_types_cjs_namespaceObject = require("../../types.cjs");
37
+ const ONE_DOLLAR_STATS_SCRIPT_SRC = 'https://assets.onedollarstats.com/stonks.js';
38
+ const oneDollarStatsManifest = {
39
+ ...external_types_cjs_namespaceObject.vendorManifestContract,
40
+ vendor: 'one-dollar-stats',
41
+ category: 'measurement',
42
+ install: [
43
+ {
44
+ type: 'loadScript',
45
+ src: ONE_DOLLAR_STATS_SCRIPT_SRC,
46
+ defer: true
47
+ }
48
+ ]
49
+ };
50
+ function oneDollarStats(options = {}) {
51
+ if (void 0 !== options.hostname && ('string' != typeof options.hostname || !/^[\p{L}\p{N}-]+(?:\.[\p{L}\p{N}-]+)*(?::\d+)?$/u.test(options.hostname))) throw new Error('oneDollarStats: hostname must be a bare host name like docs.example.com, without a scheme, path, query, or fragment');
52
+ const attributes = {};
53
+ for (const [setting, value] of Object.entries(options))if (void 0 !== value) {
54
+ if ('string' != typeof value) throw new Error(`oneDollarStats: ${setting} must be a string`);
55
+ if ('hash-routing' !== setting || 'false' !== value) attributes[`data-${setting}`] = value;
56
+ }
57
+ return {
58
+ ...(0, external_resolve_cjs_namespaceObject.resolveManifest)(oneDollarStatsManifest),
59
+ attributes
60
+ };
61
+ }
62
+ exports.ONE_DOLLAR_STATS_SCRIPT_SRC = __webpack_exports__.ONE_DOLLAR_STATS_SCRIPT_SRC;
63
+ exports.oneDollarStats = __webpack_exports__.oneDollarStats;
64
+ exports.oneDollarStatsManifest = __webpack_exports__.oneDollarStatsManifest;
65
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
66
+ "ONE_DOLLAR_STATS_SCRIPT_SRC",
67
+ "oneDollarStats",
68
+ "oneDollarStatsManifest"
69
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
70
+ Object.defineProperty(exports, '__esModule', {
71
+ value: true
72
+ });
@@ -0,0 +1,28 @@
1
+ import { resolveManifest } from "../../resolve.js";
2
+ import { vendorManifestContract } from "../../types.js";
3
+ const ONE_DOLLAR_STATS_SCRIPT_SRC = 'https://assets.onedollarstats.com/stonks.js';
4
+ const oneDollarStatsManifest = {
5
+ ...vendorManifestContract,
6
+ vendor: 'one-dollar-stats',
7
+ category: 'measurement',
8
+ install: [
9
+ {
10
+ type: 'loadScript',
11
+ src: ONE_DOLLAR_STATS_SCRIPT_SRC,
12
+ defer: true
13
+ }
14
+ ]
15
+ };
16
+ function oneDollarStats(options = {}) {
17
+ if (void 0 !== options.hostname && ('string' != typeof options.hostname || !/^[\p{L}\p{N}-]+(?:\.[\p{L}\p{N}-]+)*(?::\d+)?$/u.test(options.hostname))) throw new Error('oneDollarStats: hostname must be a bare host name like docs.example.com, without a scheme, path, query, or fragment');
18
+ const attributes = {};
19
+ for (const [setting, value] of Object.entries(options))if (void 0 !== value) {
20
+ if ('string' != typeof value) throw new Error(`oneDollarStats: ${setting} must be a string`);
21
+ if ('hash-routing' !== setting || 'false' !== value) attributes[`data-${setting}`] = value;
22
+ }
23
+ return {
24
+ ...resolveManifest(oneDollarStatsManifest),
25
+ attributes
26
+ };
27
+ }
28
+ export { ONE_DOLLAR_STATS_SCRIPT_SRC, oneDollarStats, oneDollarStatsManifest };
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ frontChat: ()=>frontChat,
32
+ frontChatManifest: ()=>frontChatManifest,
33
+ shutdownFrontChat: ()=>shutdownFrontChat
34
+ });
35
+ const external_resolve_cjs_namespaceObject = require("../../resolve.cjs");
36
+ const external_types_cjs_namespaceObject = require("../../types.cjs");
37
+ const script_url_cjs_namespaceObject = require("../_shared/script-url.cjs");
38
+ const FRONT_CHAT_SCRIPT_SRC = 'https://chat-assets.frontapp.com/v1/chat.bundle.js';
39
+ const frontChatManifest = {
40
+ ...external_types_cjs_namespaceObject.vendorManifestContract,
41
+ vendor: 'front-chat',
42
+ category: 'functionality',
43
+ install: [
44
+ {
45
+ type: 'loadScript',
46
+ src: "{{scriptSrc}}",
47
+ async: true
48
+ }
49
+ ],
50
+ onLoadGranted: [
51
+ {
52
+ type: 'callGlobal',
53
+ global: 'FrontChat',
54
+ args: [
55
+ 'init',
56
+ '{{initOptions}}'
57
+ ]
58
+ }
59
+ ]
60
+ };
61
+ function frontChat(options) {
62
+ const chatId = 'string' == typeof options?.chatId ? options.chatId.trim() : '';
63
+ if (!chatId) throw new Error('frontChat: chatId must be a non-empty string.');
64
+ const scriptSrc = (0, script_url_cjs_namespaceObject.resolveScriptUrl)((0, script_url_cjs_namespaceObject.trimToUndefined)(options.scriptSrc), FRONT_CHAT_SCRIPT_SRC);
65
+ const nonce = (0, script_url_cjs_namespaceObject.trimToUndefined)(options.nonce);
66
+ const initOptions = {
67
+ chatId,
68
+ useDefaultLauncher: options.useDefaultLauncher ?? true,
69
+ ...nonce ? {
70
+ nonce
71
+ } : {}
72
+ };
73
+ const script = (0, external_resolve_cjs_namespaceObject.resolveManifest)(frontChatManifest, {
74
+ scriptSrc,
75
+ initOptions
76
+ });
77
+ return {
78
+ ...script,
79
+ target: 'body',
80
+ nonce,
81
+ onLoad (info) {
82
+ if (!info.hasConsent || !info.element?.isConnected) return;
83
+ const loadedNonce = info.element.nonce;
84
+ const resolved = loadedNonce ? (0, external_resolve_cjs_namespaceObject.resolveManifest)(frontChatManifest, {
85
+ scriptSrc,
86
+ initOptions: {
87
+ ...initOptions,
88
+ nonce: loadedNonce
89
+ }
90
+ }) : script;
91
+ resolved.onLoad?.(info);
92
+ }
93
+ };
94
+ }
95
+ function shutdownFrontChat() {
96
+ if ("u" > typeof window && 'function' == typeof window.FrontChat) window.FrontChat('shutdown', {
97
+ clearSession: true
98
+ });
99
+ }
100
+ exports.frontChat = __webpack_exports__.frontChat;
101
+ exports.frontChatManifest = __webpack_exports__.frontChatManifest;
102
+ exports.shutdownFrontChat = __webpack_exports__.shutdownFrontChat;
103
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
104
+ "frontChat",
105
+ "frontChatManifest",
106
+ "shutdownFrontChat"
107
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
108
+ Object.defineProperty(exports, '__esModule', {
109
+ value: true
110
+ });