react-lgpd-consent 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,23 +3,32 @@ import {
3
3
  CookieBanner,
4
4
  DEFAULT_PROJECT_CATEGORIES,
5
5
  FloatingPreferencesButton,
6
+ GUIDANCE_PRESETS,
6
7
  LogLevel,
7
8
  PreferencesModal,
8
9
  analyzeDeveloperConfiguration,
10
+ categorizeDiscoveredCookies,
9
11
  createProjectPreferences,
10
12
  defaultTexts,
13
+ detectConsentCookieName,
14
+ discoverRuntimeCookies,
11
15
  getAllProjectCategories,
16
+ getCookiesInfoForCategory,
17
+ logDeveloperGuidance,
12
18
  logger,
13
19
  openPreferencesModal,
20
+ setCookieCatalogOverrides,
21
+ setCookieCategoryOverrides,
14
22
  setDebugLogging,
15
23
  useCategories,
16
24
  useCategoryStatus,
17
25
  useConsent,
18
26
  useConsentHydration,
19
27
  useConsentTexts,
28
+ useDeveloperGuidance,
20
29
  useOpenPreferencesModal,
21
30
  validateProjectPreferences
22
- } from "./chunk-B5FNONG3.js";
31
+ } from "./chunk-VOQUCGOA.js";
23
32
 
24
33
  // src/utils/ConsentGate.tsx
25
34
  import { Fragment, jsx } from "react/jsx-runtime";
@@ -139,12 +148,230 @@ var defaultConsentTheme = () => createDefaultConsentTheme();
139
148
 
140
149
  // src/utils/ConsentScriptLoader.tsx
141
150
  import * as React from "react";
151
+
152
+ // src/utils/autoConfigureCategories.ts
153
+ var FORBIDDEN_NECESSARY_SCRIPTS = /* @__PURE__ */ new Set([
154
+ // Analytics & Performance
155
+ "google-analytics",
156
+ "google-tag-manager",
157
+ "hotjar",
158
+ "mixpanel",
159
+ "clarity",
160
+ "amplitude",
161
+ "segment",
162
+ // Marketing & Advertising
163
+ "facebook-pixel",
164
+ "twitter-pixel",
165
+ "linkedin-insight",
166
+ "pinterest-tag",
167
+ "snapchat-pixel",
168
+ "tiktok-pixel",
169
+ "reddit-pixel",
170
+ // Communication & Support
171
+ "intercom",
172
+ "zendesk-chat",
173
+ "drift",
174
+ "crisp",
175
+ "freshchat",
176
+ // A/B Testing & Optimization
177
+ "optimizely",
178
+ "vwo",
179
+ "google-optimize",
180
+ "unbounce",
181
+ // Social & Content
182
+ "youtube-embed",
183
+ "vimeo-embed",
184
+ "twitter-widget",
185
+ "facebook-widget",
186
+ "instagram-widget",
187
+ // Accessibility (exceto scripts críticos)
188
+ "userway"
189
+ ]);
190
+ function analyzeIntegrationCategories(integrations) {
191
+ const categoryMap = {};
192
+ integrations.forEach((integration) => {
193
+ const category = integration.category;
194
+ if (!categoryMap[category]) {
195
+ categoryMap[category] = [];
196
+ }
197
+ categoryMap[category].push(integration.id);
198
+ });
199
+ return categoryMap;
200
+ }
201
+ function autoConfigureCategories(originalConfig, integrations, options = {}) {
202
+ const { warningOnly = false, silent = false } = options;
203
+ const config = originalConfig || { enabledCategories: ["analytics"] };
204
+ const categoryIntegrations = analyzeIntegrationCategories(integrations);
205
+ const requiredCategories = Object.keys(categoryIntegrations);
206
+ const currentCategories = new Set(config.enabledCategories || []);
207
+ const missingCategories = requiredCategories.filter((cat) => !currentCategories.has(cat));
208
+ let adjustedConfig = { ...config };
209
+ let autoEnabledCategories = [];
210
+ if (missingCategories.length > 0) {
211
+ if (warningOnly) {
212
+ if (!silent) {
213
+ logMissingCategoriesWarning(missingCategories, categoryIntegrations);
214
+ }
215
+ } else {
216
+ autoEnabledCategories = [...missingCategories];
217
+ adjustedConfig = {
218
+ ...config,
219
+ enabledCategories: [...currentCategories, ...missingCategories]
220
+ };
221
+ if (!silent) {
222
+ logAutoEnabledCategories(autoEnabledCategories, categoryIntegrations);
223
+ }
224
+ }
225
+ }
226
+ return {
227
+ originalConfig: config,
228
+ adjustedConfig,
229
+ autoEnabledCategories,
230
+ missingCategories,
231
+ wasAdjusted: autoEnabledCategories.length > 0,
232
+ categoryIntegrations
233
+ };
234
+ }
235
+ function logMissingCategoriesWarning(missingCategories, categoryIntegrations) {
236
+ const isDev = process.env.NODE_ENV !== "production";
237
+ if (!isDev) return;
238
+ const PREFIX = "[\u{1F36A} LGPD-CONSENT AUTO-CONFIG]";
239
+ console.group(`${PREFIX} \u26A0\uFE0F Categorias Requeridas N\xE3o Habilitadas`);
240
+ missingCategories.forEach((category) => {
241
+ const integrations = categoryIntegrations[category] || [];
242
+ console.warn(
243
+ `${PREFIX} Categoria '${category}' requerida por integra\xE7\xF5es: ${integrations.join(", ")}`
244
+ );
245
+ });
246
+ const categoriesCode = missingCategories.map((c) => `'${c}'`).join(", ");
247
+ console.warn(
248
+ `${PREFIX} Para corrigir, adicione estas categorias ao ConsentProvider:`,
249
+ `categories={{ enabledCategories: [...existingCategories, ${categoriesCode}] }}`
250
+ );
251
+ console.groupEnd();
252
+ }
253
+ function logAutoEnabledCategories(autoEnabledCategories, categoryIntegrations) {
254
+ const isDev = process.env.NODE_ENV !== "production";
255
+ if (!isDev) return;
256
+ const PREFIX = "[\u{1F36A} LGPD-CONSENT AUTO-CONFIG]";
257
+ console.group(`${PREFIX} \u2705 Categorias Auto-Habilitadas`);
258
+ autoEnabledCategories.forEach((category) => {
259
+ const integrations = categoryIntegrations[category] || [];
260
+ console.info(
261
+ `${PREFIX} Categoria '${category}' auto-habilitada para integra\xE7\xF5es: ${integrations.join(", ")}`
262
+ );
263
+ });
264
+ console.info(`${PREFIX} \u{1F4A1} Essas categorias foram automaticamente adicionadas \xE0 configura\xE7\xE3o.`);
265
+ console.info(`${PREFIX} \u{1F527} Para controle manual, especifique explicitamente no ConsentProvider.`);
266
+ console.groupEnd();
267
+ }
268
+ function validateIntegrationCategories(integrations, enabledCategories) {
269
+ const requiredCategories = integrations.map((i) => i.category);
270
+ const enabledSet = new Set(enabledCategories);
271
+ return requiredCategories.every((category) => enabledSet.has(category));
272
+ }
273
+ function extractCategoriesFromIntegrations(integrations) {
274
+ const categories = /* @__PURE__ */ new Set();
275
+ integrations.forEach((integration) => {
276
+ categories.add(integration.category);
277
+ });
278
+ return Array.from(categories);
279
+ }
280
+ function validateNecessaryClassification(integrations, enabledCategories) {
281
+ const warnings = [];
282
+ const hasNecessaryCategory = enabledCategories.includes("necessary");
283
+ if (!hasNecessaryCategory) {
284
+ return warnings;
285
+ }
286
+ const problematicIntegrations = integrations.filter(
287
+ (integration) => integration.category === "necessary" && FORBIDDEN_NECESSARY_SCRIPTS.has(integration.id)
288
+ );
289
+ if (problematicIntegrations.length > 0) {
290
+ warnings.push(
291
+ `\u26A0\uFE0F ATEN\xC7\xC3O GDPR/LGPD: As seguintes integra\xE7\xF5es NUNCA devem ser classificadas como 'necessary':`
292
+ );
293
+ problematicIntegrations.forEach((integration) => {
294
+ warnings.push(
295
+ ` \u2022 '${integration.id}' (categoria: ${integration.category}) - Requer consentimento expl\xEDcito`
296
+ );
297
+ });
298
+ warnings.push(
299
+ `\u{1F4A1} Scripts 'necessary' executam SEM consentimento e podem resultar em multas.`,
300
+ `\u{1F4DA} Apenas scripts de seguran\xE7a, autentica\xE7\xE3o ou core do site se qualificam.`,
301
+ `\u{1F527} Mova estes scripts para categorias apropriadas (analytics, marketing, etc.)`
302
+ );
303
+ }
304
+ return warnings;
305
+ }
306
+
307
+ // src/utils/ConsentScriptLoader.tsx
142
308
  function ConsentScriptLoader({
143
309
  integrations,
144
310
  reloadOnChange = false
145
311
  }) {
146
312
  const { preferences, consented } = useConsent();
313
+ const categories = useCategories();
147
314
  const loadedScripts = React.useRef(/* @__PURE__ */ new Set());
315
+ React.useEffect(() => {
316
+ try {
317
+ const ids = (integrations || []).map((i) => i.id);
318
+ const gt = globalThis;
319
+ const current = Array.isArray(gt.__LGPD_USED_INTEGRATIONS__) ? gt.__LGPD_USED_INTEGRATIONS__ : [];
320
+ const merged = Array.from(/* @__PURE__ */ new Set([...current, ...ids]));
321
+ gt.__LGPD_USED_INTEGRATIONS__ = merged;
322
+ try {
323
+ const gmap = globalThis;
324
+ const map = gmap.__LGPD_INTEGRATIONS_MAP__ || {};
325
+ (integrations || []).forEach((i) => {
326
+ map[i.id] = i.category;
327
+ });
328
+ gmap.__LGPD_INTEGRATIONS_MAP__ = map;
329
+ } catch {
330
+ }
331
+ } catch {
332
+ }
333
+ }, [integrations]);
334
+ React.useEffect(() => {
335
+ try {
336
+ const required = Array.from(new Set((integrations || []).map((i) => i.category))).filter(
337
+ Boolean
338
+ );
339
+ const gt = globalThis;
340
+ const current = Array.isArray(gt.__LGPD_REQUIRED_CATEGORIES__) ? gt.__LGPD_REQUIRED_CATEGORIES__ : [];
341
+ const merged = Array.from(/* @__PURE__ */ new Set([...current, ...required]));
342
+ gt.__LGPD_REQUIRED_CATEGORIES__ = merged;
343
+ if (typeof window !== "undefined" && typeof window.dispatchEvent === "function") {
344
+ window.dispatchEvent(new CustomEvent("lgpd:requiredCategories"));
345
+ }
346
+ } catch {
347
+ }
348
+ }, [integrations]);
349
+ React.useEffect(() => {
350
+ const isDev = process.env.NODE_ENV !== "production";
351
+ if (!isDev || integrations.length === 0) return;
352
+ const enabledCategories = categories.allCategories.map((cat) => cat.id);
353
+ const isValid = validateIntegrationCategories(integrations, enabledCategories);
354
+ if (!isValid) {
355
+ autoConfigureCategories({ enabledCategories }, integrations, {
356
+ warningOnly: true,
357
+ silent: false
358
+ });
359
+ }
360
+ const necessaryWarnings = validateNecessaryClassification(integrations, enabledCategories);
361
+ if (necessaryWarnings.length > 0) {
362
+ console.group("\u{1F6A8} [LGPD-CONSENT] VALIDA\xC7\xC3O DE COMPLIANCE");
363
+ necessaryWarnings.forEach((warning) => {
364
+ if (warning.startsWith("\u26A0\uFE0F")) {
365
+ console.error(warning);
366
+ } else if (warning.startsWith("\u{1F4A1}") || warning.startsWith("\u{1F4DA}") || warning.startsWith("\u{1F527}")) {
367
+ console.warn(warning);
368
+ } else {
369
+ console.log(warning);
370
+ }
371
+ });
372
+ console.groupEnd();
373
+ }
374
+ }, [integrations, categories]);
148
375
  React.useEffect(() => {
149
376
  if (!consented) return;
150
377
  integrations.forEach(async (integration) => {
@@ -197,10 +424,32 @@ function useConsentScriptLoader() {
197
424
 
198
425
  // src/utils/scriptIntegrations.ts
199
426
  function createGoogleAnalyticsIntegration(config) {
427
+ const src = config.scriptUrl ?? `https://www.googletagmanager.com/gtag/js?id=${config.measurementId}`;
200
428
  return {
201
429
  id: "google-analytics",
202
430
  category: "analytics",
203
- src: `https://www.googletagmanager.com/gtag/js?id=${config.measurementId}`,
431
+ src,
432
+ cookies: ["_ga", "_ga_*", "_gid"],
433
+ cookiesInfo: [
434
+ {
435
+ name: "_ga",
436
+ purpose: "Identifica\xE7\xE3o \xFAnica de visitantes para an\xE1lise de tr\xE1fego",
437
+ duration: "2 anos",
438
+ provider: "Google Analytics"
439
+ },
440
+ {
441
+ name: "_ga_*",
442
+ purpose: "Rastreamento de sess\xF5es e eventos espec\xEDficos do stream GA4",
443
+ duration: "2 anos",
444
+ provider: "Google Analytics"
445
+ },
446
+ {
447
+ name: "_gid",
448
+ purpose: "Distin\xE7\xE3o de visitantes \xFAnicos em per\xEDodo de 24h",
449
+ duration: "24 horas",
450
+ provider: "Google Analytics"
451
+ }
452
+ ],
204
453
  init: () => {
205
454
  if (typeof window !== "undefined") {
206
455
  const w = window;
@@ -217,29 +466,30 @@ function createGoogleAnalyticsIntegration(config) {
217
466
  };
218
467
  }
219
468
  function createGoogleTagManagerIntegration(config) {
469
+ const src = config.scriptUrl ?? `https://www.googletagmanager.com/gtm.js?id=${config.containerId}`;
220
470
  return {
221
471
  id: "google-tag-manager",
222
472
  category: "analytics",
223
- src: `https://www.googletagmanager.com/gtm.js?id=${config.containerId}`,
473
+ src,
474
+ cookies: ["_gcl_au"],
224
475
  init: () => {
225
476
  if (typeof window !== "undefined") {
226
477
  const dataLayerName = config.dataLayerName || "dataLayer";
227
478
  const w = window;
228
479
  const layer = w[dataLayerName] ?? [];
229
480
  w[dataLayerName] = layer;
230
- layer.push({
231
- "gtm.start": (/* @__PURE__ */ new Date()).getTime(),
232
- event: "gtm.js"
233
- });
481
+ layer.push({ "gtm.start": (/* @__PURE__ */ new Date()).getTime(), event: "gtm.js" });
234
482
  }
235
483
  }
236
484
  };
237
485
  }
238
486
  function createUserWayIntegration(config) {
487
+ const src = config.scriptUrl ?? "https://cdn.userway.org/widget.js";
239
488
  return {
240
489
  id: "userway",
241
490
  category: "functional",
242
- src: "https://cdn.userway.org/widget.js",
491
+ src,
492
+ cookies: ["_userway_*"],
243
493
  init: () => {
244
494
  if (typeof window !== "undefined") {
245
495
  const w = window;
@@ -255,6 +505,458 @@ var COMMON_INTEGRATIONS = {
255
505
  googleTagManager: createGoogleTagManagerIntegration,
256
506
  userway: createUserWayIntegration
257
507
  };
508
+ function createFacebookPixelIntegration(config) {
509
+ const src = config.scriptUrl ?? "https://connect.facebook.net/en_US/fbevents.js";
510
+ return {
511
+ id: "facebook-pixel",
512
+ category: "marketing",
513
+ src,
514
+ cookies: ["_fbp", "fr"],
515
+ init: () => {
516
+ if (typeof window !== "undefined") {
517
+ const w = window;
518
+ if (!w.fbq) {
519
+ const fbq = (...args) => {
520
+ if (w.fbq && typeof w.fbq.callMethod === "function") {
521
+ w.fbq.callMethod(...args);
522
+ } else {
523
+ fbq.queue = fbq.queue || [];
524
+ fbq.queue.push(args);
525
+ }
526
+ };
527
+ fbq.loaded = true;
528
+ w.fbq = fbq;
529
+ }
530
+ w.fbq("init", config.pixelId, config.advancedMatching ?? {});
531
+ if (config.autoTrack !== false) w.fbq("track", "PageView");
532
+ }
533
+ }
534
+ };
535
+ }
536
+ function createHotjarIntegration(config) {
537
+ const v = config.version ?? 6;
538
+ const src = config.scriptUrl ?? `https://static.hotjar.com/c/hotjar-${config.siteId}.js?sv=${v}`;
539
+ return {
540
+ id: "hotjar",
541
+ category: "analytics",
542
+ src,
543
+ cookies: [
544
+ "_hjSession_*",
545
+ "_hjSessionUser_*",
546
+ "_hjFirstSeen",
547
+ "_hjIncludedInSessionSample",
548
+ "_hjAbsoluteSessionInProgress"
549
+ ],
550
+ cookiesInfo: [
551
+ {
552
+ name: "_hjSession_*",
553
+ purpose: "Identifica\xE7\xE3o \xFAnica da sess\xE3o de grava\xE7\xE3o e heatmaps",
554
+ duration: "30 minutos",
555
+ provider: "Hotjar"
556
+ },
557
+ {
558
+ name: "_hjSessionUser_*",
559
+ purpose: "Identifica\xE7\xE3o persistente do usu\xE1rio entre sess\xF5es",
560
+ duration: "365 dias",
561
+ provider: "Hotjar"
562
+ },
563
+ {
564
+ name: "_hjFirstSeen",
565
+ purpose: "Detec\xE7\xE3o de primeira visita do usu\xE1rio ao site",
566
+ duration: "Sess\xE3o",
567
+ provider: "Hotjar"
568
+ },
569
+ {
570
+ name: "_hjIncludedInSessionSample",
571
+ purpose: "Indica se a sess\xE3o est\xE1 inclu\xEDda na amostra de grava\xE7\xE3o",
572
+ duration: "30 minutos",
573
+ provider: "Hotjar"
574
+ },
575
+ {
576
+ name: "_hjAbsoluteSessionInProgress",
577
+ purpose: "Detecta se uma sess\xE3o absoluta est\xE1 em progresso",
578
+ duration: "30 minutos",
579
+ provider: "Hotjar"
580
+ }
581
+ ],
582
+ init: () => {
583
+ if (typeof window !== "undefined") {
584
+ const w = window;
585
+ w._hjSettings = { hjid: config.siteId, hjsv: v };
586
+ if (!w.hj) {
587
+ const hj = (...args) => {
588
+ hj.q = hj.q || [];
589
+ hj.q.push(args);
590
+ };
591
+ w.hj = hj;
592
+ }
593
+ if (config.debug && typeof console !== "undefined" && typeof console.info === "function") {
594
+ console.info("[Hotjar] initialized with siteId", config.siteId);
595
+ }
596
+ }
597
+ }
598
+ };
599
+ }
600
+ function createMixpanelIntegration(config) {
601
+ const src = config.scriptUrl ?? "https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";
602
+ return {
603
+ id: "mixpanel",
604
+ category: "analytics",
605
+ src,
606
+ cookies: ["mp_*"],
607
+ cookiesInfo: [
608
+ {
609
+ name: "mp_*",
610
+ purpose: "Rastreamento de eventos e propriedades do usu\xE1rio para analytics",
611
+ duration: "1 ano",
612
+ provider: "Mixpanel"
613
+ }
614
+ ],
615
+ init: () => {
616
+ if (typeof window !== "undefined") {
617
+ const w = window;
618
+ w.mixpanel = w.mixpanel || { init: () => void 0 };
619
+ if (w.mixpanel && typeof w.mixpanel.init === "function") {
620
+ try {
621
+ w.mixpanel.init(config.token, config.config ?? {}, config.api_host);
622
+ } catch (error) {
623
+ if (typeof console !== "undefined" && typeof console.warn === "function") {
624
+ console.warn("[Mixpanel] Failed to initialize:", error);
625
+ }
626
+ }
627
+ }
628
+ }
629
+ }
630
+ };
631
+ }
632
+ function createClarityIntegration(config) {
633
+ const src = config.scriptUrl ?? `https://www.clarity.ms/tag/${config.projectId}`;
634
+ return {
635
+ id: "clarity",
636
+ category: "analytics",
637
+ src,
638
+ cookies: ["_clck", "_clsk", "CLID", "ANONCHK", "MR", "MUID", "SM"],
639
+ init: () => {
640
+ if (typeof window !== "undefined" && typeof config.upload !== "undefined") {
641
+ const w = window;
642
+ if (typeof w.clarity === "function") {
643
+ try {
644
+ w.clarity("set", "upload", config.upload);
645
+ } catch (error) {
646
+ if (typeof console !== "undefined" && typeof console.warn === "function") {
647
+ console.warn("[Clarity] Failed to configure upload setting:", error);
648
+ }
649
+ }
650
+ }
651
+ }
652
+ }
653
+ };
654
+ }
655
+ function createIntercomIntegration(config) {
656
+ const src = config.scriptUrl ?? `https://widget.intercom.io/widget/${config.app_id}`;
657
+ return {
658
+ id: "intercom",
659
+ category: "functional",
660
+ src,
661
+ cookies: ["intercom-id-*", "intercom-session-*"],
662
+ init: () => {
663
+ if (typeof window !== "undefined") {
664
+ const w = window;
665
+ if (typeof w.Intercom === "function") {
666
+ try {
667
+ w.Intercom("boot", { app_id: config.app_id });
668
+ } catch (error) {
669
+ if (typeof console !== "undefined" && typeof console.warn === "function") {
670
+ console.warn("[Intercom] Failed to boot:", error);
671
+ }
672
+ }
673
+ }
674
+ }
675
+ }
676
+ };
677
+ }
678
+ function createZendeskChatIntegration(config) {
679
+ const src = config.scriptUrl ?? `https://static.zdassets.com/ekr/snippet.js?key=${config.key}`;
680
+ return {
681
+ id: "zendesk-chat",
682
+ category: "functional",
683
+ src,
684
+ cookies: ["__zlcmid", "_zendesk_shared_session"],
685
+ init: () => {
686
+ if (typeof window !== "undefined") {
687
+ const w = window;
688
+ if (typeof w.zE === "function") {
689
+ try {
690
+ w.zE("webWidget", "identify", { key: config.key });
691
+ } catch (error) {
692
+ if (typeof console !== "undefined" && typeof console.warn === "function") {
693
+ console.warn("[Zendesk] Failed to identify:", error);
694
+ }
695
+ }
696
+ }
697
+ }
698
+ }
699
+ };
700
+ }
701
+ function createECommerceIntegrations(cfg) {
702
+ const list = [];
703
+ if (cfg.googleAnalytics) list.push(createGoogleAnalyticsIntegration(cfg.googleAnalytics));
704
+ if (cfg.facebookPixel) list.push(createFacebookPixelIntegration(cfg.facebookPixel));
705
+ if (cfg.hotjar) list.push(createHotjarIntegration(cfg.hotjar));
706
+ if (cfg.userway) list.push(createUserWayIntegration(cfg.userway));
707
+ return list;
708
+ }
709
+ function createSaaSIntegrations(cfg) {
710
+ const list = [];
711
+ if (cfg.googleAnalytics) list.push(createGoogleAnalyticsIntegration(cfg.googleAnalytics));
712
+ if (cfg.mixpanel) list.push(createMixpanelIntegration(cfg.mixpanel));
713
+ if (cfg.intercom) list.push(createIntercomIntegration(cfg.intercom));
714
+ if (cfg.hotjar) list.push(createHotjarIntegration(cfg.hotjar));
715
+ return list;
716
+ }
717
+ function createCorporateIntegrations(cfg) {
718
+ const list = [];
719
+ if (cfg.googleAnalytics) list.push(createGoogleAnalyticsIntegration(cfg.googleAnalytics));
720
+ if (cfg.clarity) list.push(createClarityIntegration(cfg.clarity));
721
+ if (cfg.zendesk) list.push(createZendeskChatIntegration(cfg.zendesk));
722
+ if (cfg.userway) list.push(createUserWayIntegration(cfg.userway));
723
+ return list;
724
+ }
725
+ var INTEGRATION_TEMPLATES = {
726
+ ecommerce: {
727
+ essential: ["google-analytics", "facebook-pixel"],
728
+ optional: ["hotjar", "userway"],
729
+ categories: ["analytics", "marketing", "functional"]
730
+ },
731
+ saas: {
732
+ essential: ["google-analytics", "mixpanel"],
733
+ optional: ["intercom", "hotjar"],
734
+ categories: ["analytics", "functional"]
735
+ },
736
+ corporate: {
737
+ essential: ["google-analytics"],
738
+ optional: ["userway", "zendesk-chat", "clarity"],
739
+ categories: ["analytics", "functional"]
740
+ }
741
+ };
742
+ function suggestCategoryForScript(name) {
743
+ const n = name.toLowerCase();
744
+ if (n.includes("facebook") || n.includes("pixel") || n.includes("ads")) return ["marketing"];
745
+ if (n.includes("hotjar") || n.includes("mixpanel") || n.includes("clarity")) return ["analytics"];
746
+ if (n.includes("intercom") || n.includes("zendesk") || n.includes("chat")) return ["functional"];
747
+ return ["analytics"];
748
+ }
749
+
750
+ // src/types/advancedTexts.ts
751
+ var EXPANDED_DEFAULT_TEXTS = {
752
+ // Textos adicionais
753
+ confirm: "Confirmar",
754
+ cancel: "Cancelar",
755
+ loading: "Carregando...",
756
+ // Feedback
757
+ feedback: {
758
+ saveSuccess: "Prefer\xEAncias salvas com sucesso!",
759
+ saveError: "Erro ao salvar prefer\xEAncias. Tente novamente.",
760
+ consentUpdated: "Consentimento atualizado.",
761
+ cookiesRejected: "Cookies opcionais rejeitados.",
762
+ settingsReset: "Configura\xE7\xF5es resetadas."
763
+ },
764
+ // Acessibilidade
765
+ accessibility: {
766
+ bannerLabel: "Banner de consentimento de cookies",
767
+ modalLabel: "Modal de prefer\xEAncias de cookies",
768
+ keyboardNavigation: "Use Tab para navegar, Enter para selecionar",
769
+ toggleState: {
770
+ enabled: "Habilitado",
771
+ disabled: "Desabilitado"
772
+ },
773
+ liveRegion: "Regi\xE3o de an\xFAncios din\xE2micos"
774
+ },
775
+ // Categorias
776
+ categories: {
777
+ necessary: {
778
+ name: "Cookies Necess\xE1rios",
779
+ description: "Essenciais para o funcionamento b\xE1sico do site",
780
+ examples: "Sess\xE3o, seguran\xE7a, prefer\xEAncias de idioma"
781
+ },
782
+ analytics: {
783
+ name: "Cookies de Analytics",
784
+ description: "Ajudam a entender como os visitantes usam o site",
785
+ examples: "Google Analytics, contadores de p\xE1gina"
786
+ },
787
+ marketing: {
788
+ name: "Cookies de Marketing",
789
+ description: "Usados para personalizar an\xFAncios e ofertas",
790
+ examples: "Facebook Pixel, Google Ads, remarketing"
791
+ },
792
+ functional: {
793
+ name: "Cookies Funcionais",
794
+ description: "Melhoram a funcionalidade e personaliza\xE7\xE3o",
795
+ examples: "Chat, mapas, v\xEDdeos embarcados"
796
+ },
797
+ performance: {
798
+ name: "Cookies de Performance",
799
+ description: "Coletam informa\xE7\xF5es sobre velocidade e estabilidade",
800
+ examples: "Monitoramento de erro, otimiza\xE7\xE3o de velocidade"
801
+ }
802
+ },
803
+ // Contextos específicos
804
+ contexts: {
805
+ ecommerce: {
806
+ cartAbandonment: "Lembramos dos produtos no seu carrinho",
807
+ personalizedOffers: "Ofertas personalizadas baseadas no seu hist\xF3rico",
808
+ paymentSecurity: "Seguran\xE7a adicional no processo de pagamento",
809
+ productRecommendations: "Sugest\xF5es de produtos relevantes"
810
+ },
811
+ saas: {
812
+ userAnalytics: "An\xE1lise de uso para melhorar funcionalidades",
813
+ performanceMonitoring: "Monitoramento de performance da aplica\xE7\xE3o",
814
+ featureUsage: "Estat\xEDsticas de uso de recursos",
815
+ customerSupport: "Suporte ao cliente mais eficiente"
816
+ },
817
+ government: {
818
+ citizenServices: "Melhoria dos servi\xE7os ao cidad\xE3o",
819
+ dataProtection: "Prote\xE7\xE3o rigorosa dos dados pessoais",
820
+ transparency: "Transpar\xEAncia no uso de dados",
821
+ accessibility: "Recursos de acessibilidade digital"
822
+ },
823
+ education: {
824
+ studentProgress: "Acompanhamento do progresso educacional",
825
+ learningAnalytics: "Analytics para melhorar o aprendizado",
826
+ accessibility: "Recursos educacionais acess\xEDveis",
827
+ parentalConsent: "Consentimento parental quando necess\xE1rio"
828
+ }
829
+ },
830
+ // Variações de tom
831
+ variants: {
832
+ formal: {
833
+ bannerMessage: "Este s\xEDtio eletr\xF4nico utiliza cookies para otimizar a experi\xEAncia de navega\xE7\xE3o.",
834
+ acceptAll: "Concordar com todos os cookies",
835
+ declineAll: "Recusar cookies opcionais",
836
+ modalTitle: "Configura\xE7\xE3o de Cookies"
837
+ },
838
+ casual: {
839
+ bannerMessage: "\u{1F36A} Ei! Usamos cookies para tornar sua experi\xEAncia ainda melhor!",
840
+ acceptAll: "Aceitar tudo",
841
+ declineAll: "S\xF3 o essencial",
842
+ modalTitle: "Seus Cookies"
843
+ },
844
+ concise: {
845
+ bannerMessage: "Usamos cookies. Voc\xEA aceita?",
846
+ acceptAll: "Sim",
847
+ declineAll: "N\xE3o",
848
+ modalTitle: "Cookies"
849
+ },
850
+ detailed: {
851
+ bannerMessage: "Utilizamos cookies e tecnologias similares para melhorar sua experi\xEAncia de navega\xE7\xE3o, personalizar conte\xFAdo, analisar tr\xE1fego e oferecer funcionalidades de redes sociais.",
852
+ acceptAll: "Aceitar todos os cookies e tecnologias",
853
+ declineAll: "Recusar todos os cookies opcionais",
854
+ modalTitle: "Centro de Prefer\xEAncias de Privacidade"
855
+ }
856
+ },
857
+ // Internacionalização simplificada (apenas textos básicos)
858
+ i18n: {
859
+ en: {
860
+ bannerMessage: "We use cookies to enhance your experience.",
861
+ acceptAll: "Accept All",
862
+ declineAll: "Decline",
863
+ preferences: "Preferences",
864
+ modalTitle: "Cookie Preferences",
865
+ modalIntro: "Customize your cookie preferences below.",
866
+ save: "Save Preferences",
867
+ necessaryAlwaysOn: "Necessary cookies (always active)"
868
+ },
869
+ es: {
870
+ bannerMessage: "Utilizamos cookies para mejorar su experiencia.",
871
+ acceptAll: "Aceptar Todo",
872
+ declineAll: "Rechazar",
873
+ preferences: "Preferencias",
874
+ modalTitle: "Preferencias de Cookies",
875
+ modalIntro: "Personalice sus preferencias de cookies a continuaci\xF3n.",
876
+ save: "Guardar Preferencias",
877
+ necessaryAlwaysOn: "Cookies necess\xE1rias (sempre ativas)"
878
+ },
879
+ fr: {
880
+ bannerMessage: "Nous utilisons des cookies pour am\xE9liorer votre exp\xE9rience.",
881
+ acceptAll: "Tout Accepter",
882
+ declineAll: "Refuser",
883
+ preferences: "Pr\xE9f\xE9rences",
884
+ modalTitle: "Pr\xE9f\xE9rences des Cookies",
885
+ modalIntro: "Personnalisez vos pr\xE9f\xE9rences de cookies ci-dessous.",
886
+ save: "Enregistrer les Pr\xE9f\xE9rences",
887
+ necessaryAlwaysOn: "Cookies n\xE9cessaires (toujours actifs)"
888
+ }
889
+ },
890
+ // Textos técnicos
891
+ technical: {
892
+ sessionCookies: "Cookies de sess\xE3o s\xE3o tempor\xE1rios e expiram quando voc\xEA fecha o navegador.",
893
+ persistentCookies: "Cookies persistentes permanecem no seu dispositivo at\xE9 expirarem ou serem removidos.",
894
+ thirdPartyCookies: "Cookies de terceiros s\xE3o definidos por dom\xEDnios diferentes do site que voc\xEA est\xE1 visitando.",
895
+ browserSettings: "Voc\xEA pode gerenciar cookies nas configura\xE7\xF5es do seu navegador.",
896
+ disablingImpact: "Desabilitar cookies pode afetar a funcionalidade do site."
897
+ },
898
+ // Cookie details
899
+ cookieDetails: {
900
+ tableHeaders: {
901
+ name: "Nome",
902
+ purpose: "Finalidade",
903
+ duration: "Dura\xE7\xE3o",
904
+ provider: "Fornecedor",
905
+ type: "Tipo"
906
+ },
907
+ noCookies: "Nenhum cookie encontrado para esta categoria.",
908
+ toggleDetails: {
909
+ expand: "Ver detalhes",
910
+ collapse: "Ocultar detalhes"
911
+ }
912
+ }
913
+ };
914
+ function resolveTexts(texts, options = {}) {
915
+ const { language = "pt", variant } = options;
916
+ let resolved = { ...texts };
917
+ if (variant && texts.variants?.[variant]) {
918
+ resolved = { ...resolved, ...texts.variants[variant] };
919
+ }
920
+ if (language !== "pt" && texts.i18n?.[language]) {
921
+ resolved = { ...resolved, ...texts.i18n[language] };
922
+ }
923
+ return resolved;
924
+ }
925
+ var TEXT_TEMPLATES = {
926
+ ecommerce: {
927
+ ...EXPANDED_DEFAULT_TEXTS,
928
+ bannerMessage: "Utilizamos cookies para personalizar ofertas e melhorar sua experi\xEAncia de compra.",
929
+ acceptAll: "Aceitar e continuar",
930
+ variants: {
931
+ casual: {
932
+ bannerMessage: "\u{1F6D2} Usamos cookies para encontrar as melhores ofertas para voc\xEA!",
933
+ acceptAll: "Quero ofertas personalizadas!"
934
+ }
935
+ }
936
+ },
937
+ saas: {
938
+ ...EXPANDED_DEFAULT_TEXTS,
939
+ bannerMessage: "Utilizamos cookies para otimizar o desempenho da aplica\xE7\xE3o e sua experi\xEAncia.",
940
+ acceptAll: "Aceitar e otimizar",
941
+ variants: {
942
+ formal: {
943
+ bannerMessage: "Esta aplica\xE7\xE3o utiliza cookies para an\xE1lise de performance e melhoria cont\xEDnua da experi\xEAncia do usu\xE1rio.",
944
+ acceptAll: "Autorizar coleta de dados de uso"
945
+ }
946
+ }
947
+ },
948
+ government: {
949
+ ...EXPANDED_DEFAULT_TEXTS,
950
+ bannerMessage: "Este portal utiliza cookies em conformidade com a LGPD para melhorar os servi\xE7os p\xFAblicos.",
951
+ acceptAll: "Aceitar em conformidade",
952
+ variants: {
953
+ formal: {
954
+ bannerMessage: "Este s\xEDtio eletr\xF4nico do governo utiliza cookies estritamente necess\xE1rios e opcionais, em conformidade com a Lei Geral de Prote\xE7\xE3o de Dados.",
955
+ acceptAll: "Concordar com o uso de cookies"
956
+ }
957
+ }
958
+ }
959
+ };
258
960
  export {
259
961
  COMMON_INTEGRATIONS,
260
962
  ConsentGate,
@@ -262,27 +964,55 @@ export {
262
964
  ConsentScriptLoader,
263
965
  CookieBanner,
264
966
  DEFAULT_PROJECT_CATEGORIES,
967
+ EXPANDED_DEFAULT_TEXTS,
265
968
  FloatingPreferencesButton,
969
+ GUIDANCE_PRESETS,
970
+ INTEGRATION_TEMPLATES,
266
971
  LogLevel,
267
972
  PreferencesModal,
973
+ TEXT_TEMPLATES,
268
974
  analyzeDeveloperConfiguration,
975
+ analyzeIntegrationCategories,
976
+ autoConfigureCategories,
977
+ categorizeDiscoveredCookies,
978
+ createClarityIntegration,
979
+ createCorporateIntegrations,
269
980
  createDefaultConsentTheme,
981
+ createECommerceIntegrations,
982
+ createFacebookPixelIntegration,
270
983
  createGoogleAnalyticsIntegration,
271
984
  createGoogleTagManagerIntegration,
985
+ createHotjarIntegration,
986
+ createIntercomIntegration,
987
+ createMixpanelIntegration,
272
988
  createProjectPreferences,
989
+ createSaaSIntegrations,
273
990
  createUserWayIntegration,
991
+ createZendeskChatIntegration,
274
992
  defaultConsentTheme,
275
993
  defaultTexts,
994
+ detectConsentCookieName,
995
+ discoverRuntimeCookies,
996
+ extractCategoriesFromIntegrations,
276
997
  getAllProjectCategories,
998
+ getCookiesInfoForCategory,
277
999
  loadScript,
1000
+ logDeveloperGuidance,
278
1001
  openPreferencesModal,
1002
+ resolveTexts,
1003
+ setCookieCatalogOverrides,
1004
+ setCookieCategoryOverrides,
279
1005
  setDebugLogging,
1006
+ suggestCategoryForScript,
280
1007
  useCategories,
281
1008
  useCategoryStatus,
282
1009
  useConsent,
283
1010
  useConsentHydration,
284
1011
  useConsentScriptLoader,
285
1012
  useConsentTexts,
1013
+ useDeveloperGuidance,
286
1014
  useOpenPreferencesModal,
1015
+ validateIntegrationCategories,
1016
+ validateNecessaryClassification,
287
1017
  validateProjectPreferences
288
1018
  };