@solvenza/cookies-compliance 1.0.0 → 1.2.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/LICENSE +21 -0
- package/dist/{chunk-LIWFUVWY.js → chunk-FBRP4MSA.js} +59 -10
- package/dist/chunk-FBRP4MSA.js.map +1 -0
- package/dist/{consent-engine-BvsH_wqV.d.cts → consent-engine-DOMyEKfk.d.cts} +2 -0
- package/dist/{consent-engine-BvsH_wqV.d.ts → consent-engine-DOMyEKfk.d.ts} +2 -0
- package/dist/consent.esm.cjs +58 -9
- package/dist/consent.esm.cjs.map +1 -1
- package/dist/consent.esm.d.cts +7 -5
- package/dist/consent.esm.d.ts +7 -5
- package/dist/consent.esm.js +1 -1
- package/dist/consent.min.js +16 -16
- package/dist/consent.min.js.map +1 -1
- package/dist/wrappers/angular.cjs +56 -7
- package/dist/wrappers/angular.cjs.map +1 -1
- package/dist/wrappers/angular.d.cts +1 -1
- package/dist/wrappers/angular.d.ts +1 -1
- package/dist/wrappers/angular.js +1 -1
- package/dist/wrappers/next.cjs +56 -7
- package/dist/wrappers/next.cjs.map +1 -1
- package/dist/wrappers/next.js +1 -1
- package/dist/wrappers/react.cjs +56 -7
- package/dist/wrappers/react.cjs.map +1 -1
- package/dist/wrappers/react.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-LIWFUVWY.js.map +0 -1
package/dist/consent.esm.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CategoryConfig, S as ServiceConfig, a as ConsentConfig, b as ConsentChoices, c as ConsentReceipt, D as DiagnosticReport } from './consent-engine-
|
|
2
|
-
export { d as Consent, e as ConsentEngine, f as ConsentEvent, g as ConsentEventDetailMap, h as ConsentEventHandler, i as ConsentSDKInterface, j as ConsentState } from './consent-engine-
|
|
1
|
+
import { C as CategoryConfig, S as ServiceConfig, a as ConsentConfig, b as ConsentChoices, c as ConsentReceipt, D as DiagnosticReport } from './consent-engine-DOMyEKfk.js';
|
|
2
|
+
export { d as Consent, e as ConsentEngine, f as ConsentEvent, g as ConsentEventDetailMap, h as ConsentEventHandler, i as ConsentSDKInterface, j as ConsentState } from './consent-engine-DOMyEKfk.js';
|
|
3
3
|
|
|
4
4
|
declare class ConsentConfigBuilder {
|
|
5
5
|
private config;
|
|
@@ -28,11 +28,12 @@ interface CookieOptions {
|
|
|
28
28
|
maxAgeDays?: number;
|
|
29
29
|
sameSite?: "Lax" | "Strict" | "None";
|
|
30
30
|
secure?: boolean;
|
|
31
|
+
domain?: string;
|
|
31
32
|
}
|
|
32
33
|
interface IStorageProvider {
|
|
33
34
|
get(key: string): string | null;
|
|
34
35
|
set(key: string, value: string, options?: CookieOptions): void;
|
|
35
|
-
remove(key: string, path?: string): void;
|
|
36
|
+
remove(key: string, path?: string, domain?: string): void;
|
|
36
37
|
clear?(): void;
|
|
37
38
|
}
|
|
38
39
|
|
|
@@ -43,12 +44,13 @@ declare class StorageFactory {
|
|
|
43
44
|
declare class CookieStorageProvider implements IStorageProvider {
|
|
44
45
|
get(key: string): string | null;
|
|
45
46
|
set(key: string, value: string, options?: CookieOptions): void;
|
|
46
|
-
remove(key: string, path?: string): void;
|
|
47
|
+
remove(key: string, path?: string, domain?: string): void;
|
|
47
48
|
}
|
|
48
49
|
declare class CookieStore {
|
|
49
50
|
static get(name: string): string | null;
|
|
50
51
|
static set(name: string, value: string, options?: CookieOptions): void;
|
|
51
|
-
static remove(name: string, path?: string): void;
|
|
52
|
+
static remove(name: string, path?: string, domain?: string): void;
|
|
53
|
+
static clearServiceCookies(config: ConsentConfig, revokedCategory: string): void;
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
declare class MemoryStorageProvider implements IStorageProvider {
|
package/dist/consent.esm.js
CHANGED
package/dist/consent.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ConsentSDK=(()=>{var G=Object.defineProperty,Se=Object.defineProperties,Ee=Object.getOwnPropertyDescriptor,Ae=Object.getOwnPropertyDescriptors,Ie=Object.getOwnPropertyNames,be=Object.getOwnPropertySymbols;var ve=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable;var ye=(r,e,t)=>e in r?G(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,y=(r,e)=>{for(var t in e||(e={}))ve.call(e,t)&&ye(r,t,e[t]);if(be)for(var t of be(e))je.call(e,t)&&ye(r,t,e[t]);return r},xe=(r,e)=>Se(r,Ae(e));var Re=(r,e)=>{for(var t in e)G(r,t,{get:e[t],enumerable:!0})},Me=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ie(e))!ve.call(r,s)&&s!==t&&G(r,s,{get:()=>e[s],enumerable:!(n=Ee(e,s))||n.enumerable});return r};var Le=r=>Me(G({},"__esModule",{value:!0}),r);var Pe={};Re(Pe,{ConfigValidationError:()=>m,Consent:()=>N,ConsentConfigBuilder:()=>U,ConsentEngine:()=>V,CookieStorageProvider:()=>D,CookieStore:()=>C,GoogleConsentAdapter:()=>E,I18nEngine:()=>ce,IframeGate:()=>M,IframeResourceBlocker:()=>ee,ImageResourceBlocker:()=>te,MemoryStorageProvider:()=>S,MemoryStore:()=>O,PolicyGenerator:()=>B,ResourceGate:()=>_,ResourceScanner:()=>q,ScriptGate:()=>R,ScriptResourceBlocker:()=>Z,StorageFactory:()=>ae,computeReceiptSignature:()=>z,createReceipt:()=>Y,isReceiptExpired:()=>X,parseReceipt:()=>Q,sanitizeHtml:()=>g,validateConfig:()=>P,verifyReceiptIntegrity:()=>Ce});var m=class extends Error{constructor(e){super(`[ConsentSDK Config Error] ${e}`),this.name="ConfigValidationError"}};function P(r){if(!r)throw new m("Configuration object is null or undefined.");if(typeof r.schemaVersion!="number"||r.schemaVersion<1)throw new m("Invalid or missing 'schemaVersion'. Expected integer >= 1.");if(!r.policyVersion||typeof r.policyVersion!="string")throw new m("Invalid or missing 'policyVersion'. String required.");if(!r.categories||typeof r.categories!="object")throw new m("Missing 'categories' map in configuration.");if(Object.keys(r.categories).length===0)throw new m("At least one category must be defined in 'categories'.");let t=r.categories.necessary;if(!t)throw new m("Category 'necessary' must be defined.");if(t.required!==!0)throw new m("Category 'necessary' must have 'required: true'.");for(let[n,s]of Object.entries(r.categories))if(n!=="necessary"&&!s.required&&s.default===!0)throw new m(`Legal violation (AEPD): Optional category '${n}' cannot have default: true. All optional categories must be opt-in (default: false).`);if(r.services&&typeof r.services=="object")for(let[n,s]of Object.entries(r.services)){if(!s.category)throw new m(`Service '${n}' missing 'category' reference.`);if(!r.categories[s.category])throw new m(`Service '${n}' references non-existent category '${s.category}'.`)}}var W=class{constructor(){this.state={initialized:!1,policyVersion:"",locale:"es",receipt:null,choices:{}};this.config=null}init(e,t,n){var s;this.config=e,this.state={initialized:!0,policyVersion:e.policyVersion,locale:((s=e.locale)==null?void 0:s.default)||"es",receipt:n,choices:t}}getConfig(){return this.config}getState(){return y({},this.state)}getChoices(){return y({},this.state.choices)}getReceipt(){return this.state.receipt}hasCategory(e){return this.state.choices[e]===!0}hasService(e){if(!this.config||!this.config.services)return!1;let t=this.config.services[e];return t?this.hasCategory(t.category):!1}updateChoices(e){this.state.receipt=e,this.state.choices=y({},e.choices)}clearChoices(){if(!this.config)return;let e={};for(let[t,n]of Object.entries(this.config.categories))e[t]=n.required===!0;this.state.choices=e,this.state.receipt=null}};var J=class{constructor(){this.handlers=new Map}on(e,t){this.handlers.has(e)||this.handlers.set(e,new Set);let n=this.handlers.get(e);return n.add(t),()=>{n.delete(t)}}emit(e,t){let n=this.handlers.get(e);if(n)for(let s of n)try{s(t)}catch(o){console.error(`[ConsentSDK Event Error] Handler for '${e}' failed:`,o)}}clear(){this.handlers.clear()}};function $e(r){let e,t,n="",s=r.length*8,o=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],i=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],c=[];for(e=0;e<r.length;e++)c[e>>2]|=r.charCodeAt(e)<<24-e%4*8;for(c[s>>5]|=128<<24-s%32,c[(s+64>>9<<4)+15]=s,e=0;e<c.length;e+=16){let a=c.slice(e,e+16),p=[...o];for(t=0;t<64;t++){let d=a[t-15],l=a[t-2],f=(d>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,v=(l>>>17|l<<15)^(l>>>19|l<<13)^l>>>10;a[t]=t<16?a[t]||0:a[t-16]+f+a[t-7]+v|0;let u=o[4]&o[5]^~o[4]&o[6],w=o[0]&o[1]^o[0]&o[2]^o[1]&o[2],h=(o[0]>>>2|o[0]<<30)^(o[0]>>>13|o[0]<<19)^(o[0]>>>22|o[0]<<10),L=(o[4]>>>6|o[4]<<26)^(o[4]>>>11|o[4]<<21)^(o[4]>>>25|o[4]<<7),j=o[7]+L+u+i[t]+(a[t]|0),K=h+w;o[7]=o[6],o[6]=o[5],o[5]=o[4],o[4]=o[3]+j|0,o[3]=o[2],o[2]=o[1],o[1]=o[0],o[0]=j+K|0}for(t=0;t<8;t++)o[t]=o[t]+p[t]|0}for(e=0;e<8;e++)for(t=3;t>=0;t--){let a=o[e]>>t*8&255;n+=(a<16?"0":"")+a.toString(16)}return n}function z(r,e){if(e)return $e(`${e}:${r}:${e}`);let t=2166136261;for(let n=0;n<r.length;n++)t^=r.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16)}function Ce(r,e,t){return e?z(r,t)===e:!1}function g(r){return r?r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):""}function le(r){if(!r)return"#";let e=r.trim().toLowerCase();return e.startsWith("javascript:")||e.startsWith("data:")||e.startsWith("vbscript:")?"#":r}function Te(){return typeof crypto!="undefined"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function Y(r,e,t,n,s){let o=new Date().toISOString(),i=(n==null?void 0:n.receiptId)||Te(),c=(n==null?void 0:n.decidedAt)||o,a=`${i}:${r}:${JSON.stringify(e)}`,p=z(a,s);return{schema:1,receiptId:i,policyVersion:r,decidedAt:c,updatedAt:o,source:t,choices:e,signature:p}}function Q(r){try{let e=JSON.parse(r);return typeof e=="object"&&e!==null&&typeof e.receiptId=="string"&&typeof e.policyVersion=="string"&&typeof e.choices=="object"?e:null}catch(e){return null}}function X(r,e=365){if(!r.updatedAt)return!0;let t=new Date(r.updatedAt).getTime(),n=Date.now(),s=e*86400*1e3;return n-t>s}function we(r,e){var o,i,c;let t={};for(let[a,p]of Object.entries(r.categories))t[a]=p.required===!0;if(!e)return{isValid:!1,reason:"missing",choices:t};if(e.policyVersion!==r.policyVersion)return{isValid:!1,reason:"policy_version_changed",choices:t};let n=(i=(o=r.consent)==null?void 0:o.maxAgeDays)!=null?i:365;if(X(e,n))return{isValid:!1,reason:"expired",choices:t};if(e.signature){let a=`${e.receiptId}:${e.policyVersion}:${JSON.stringify(e.choices)}`,p=z(a,(c=r.security)==null?void 0:c.secretKey);if(e.signature!==p)return{isValid:!1,reason:"tampered",choices:t}}let s=y({},t);for(let a of Object.keys(r.categories))a==="necessary"?s[a]=!0:typeof e.choices[a]=="boolean"&&(s[a]=e.choices[a]);return{isValid:!0,reason:"valid",choices:s}}var D=class{get(e){return C.get(e)}set(e,t,n){C.set(e,t,n)}remove(e,t="/"){C.remove(e,t)}},C=class{static get(e){if(typeof document=="undefined")return null;let t=encodeURIComponent(e)+"=",n=document.cookie.split(";");for(let s=0;s<n.length;s++){let o=n[s];for(;o.charAt(0)===" ";)o=o.substring(1,o.length);if(o.indexOf(t)===0)return decodeURIComponent(o.substring(t.length,o.length))}return null}static set(e,t,n={}){var l,f;if(typeof document=="undefined")return;let s=n.path||"/",o=(l=n.maxAgeDays)!=null?l:365,i=Math.floor(o*86400),c=n.sameSite||"Lax",a=typeof window!="undefined"&&window.location.protocol==="https:",p=(f=n.secure)!=null?f:a,d=`${encodeURIComponent(e)}=${encodeURIComponent(t)}; Path=${s}; Max-Age=${i}; SameSite=${c}`;p&&(d+="; Secure"),document.cookie=d}static remove(e,t="/"){typeof document!="undefined"&&(document.cookie=`${encodeURIComponent(e)}=; Path=${t}; Max-Age=0; SameSite=Lax`)}};var H=class H{get(e){var t;return(t=H.store.get(e))!=null?t:null}set(e,t){H.store.set(e,t)}remove(e){H.store.delete(e)}clear(){H.store.clear()}};H.store=new Map;var S=H,O={get:r=>new S().get(r),set:(r,e)=>new S().set(r,e),remove:r=>new S().remove(r),clear:()=>new S().clear()};var Z=class{constructor(){this.type="script"}process(e,t){R.scanAndActivate(e,t)}},R=class{static scanAndActivate(e,t,n){var o;if(typeof document=="undefined")return;let s=Array.from(document.querySelectorAll('script[type="text/plain"][data-consent], script[type="text/plain"][data-service]'));for(let i of s){if(this.executedScripts.has(i))continue;let c=i.getAttribute("data-consent"),a=i.getAttribute("data-service"),p=!1;if(a?p=t(a):c&&(p=e(c)),!p)continue;this.executedScripts.add(i);let d=document.createElement("script");for(let l=0;l<i.attributes.length;l++){let f=i.attributes[l];if(f.name!=="type"){if(f.name==="data-src"){d.src=f.value;continue}d.setAttribute(f.name,f.value)}}d.type="text/javascript",!d.src&&i.textContent&&(d.textContent=i.textContent),(o=i.parentNode)==null||o.replaceChild(d,i),(a||c)&&(n==null||n(a||c,c||"custom"))}}};R.executedScripts=new Set;var ee=class{constructor(){this.type="iframe"}process(e,t){M.processIframes(e,t)}},M=class{static processIframes(e,t,n={}){if(typeof document=="undefined")return;let s=Array.from(document.querySelectorAll("iframe[data-consent], iframe[data-service]"));for(let o of s){let i=o.getAttribute("data-consent"),c=o.getAttribute("data-service"),a=!1;c?a=t(c):i&&(a=e(i));let p=o.getAttribute("data-src")||o.getAttribute("src");p&&(o.getAttribute("data-src")||o.setAttribute("data-src",p),a?this.unlockIframe(o,p):this.lockIframe(o,i||"marketing",c||void 0,n))}}static lockIframe(e,t,n,s){var p;if(e.hasAttribute("src")&&e.removeAttribute("src"),this.placeholders.has(e))return;let o=document.createElement("div");o.className="consent-iframe-placeholder",o.style.cssText=`
|
|
1
|
+
"use strict";var ConsentSDK=(()=>{var G=Object.defineProperty,Se=Object.defineProperties,Ee=Object.getOwnPropertyDescriptor,Ae=Object.getOwnPropertyDescriptors,Ie=Object.getOwnPropertyNames,be=Object.getOwnPropertySymbols;var ye=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable;var ve=(r,e,t)=>e in r?G(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,y=(r,e)=>{for(var t in e||(e={}))ye.call(e,t)&&ve(r,t,e[t]);if(be)for(var t of be(e))je.call(e,t)&&ve(r,t,e[t]);return r},xe=(r,e)=>Se(r,Ae(e));var Re=(r,e)=>{for(var t in e)G(r,t,{get:e[t],enumerable:!0})},Me=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ie(e))!ye.call(r,s)&&s!==t&&G(r,s,{get:()=>e[s],enumerable:!(n=Ee(e,s))||n.enumerable});return r};var Le=r=>Me(G({},"__esModule",{value:!0}),r);var De={};Re(De,{ConfigValidationError:()=>h,Consent:()=>N,ConsentConfigBuilder:()=>U,ConsentEngine:()=>V,CookieStorageProvider:()=>z,CookieStore:()=>v,GoogleConsentAdapter:()=>I,I18nEngine:()=>ce,IframeGate:()=>L,IframeResourceBlocker:()=>ee,ImageResourceBlocker:()=>te,MemoryStorageProvider:()=>A,MemoryStore:()=>O,PolicyGenerator:()=>B,ResourceGate:()=>_,ResourceScanner:()=>q,ScriptGate:()=>M,ScriptResourceBlocker:()=>Z,StorageFactory:()=>ae,computeReceiptSignature:()=>P,createReceipt:()=>Y,isReceiptExpired:()=>X,parseReceipt:()=>Q,sanitizeHtml:()=>g,validateConfig:()=>D,verifyReceiptIntegrity:()=>Ce});var h=class extends Error{constructor(e){super(`[ConsentSDK Config Error] ${e}`),this.name="ConfigValidationError"}};function D(r){if(!r)throw new h("Configuration object is null or undefined.");if(typeof r.schemaVersion!="number"||r.schemaVersion<1)throw new h("Invalid or missing 'schemaVersion'. Expected integer >= 1.");if(!r.policyVersion||typeof r.policyVersion!="string")throw new h("Invalid or missing 'policyVersion'. String required.");if(!r.categories||typeof r.categories!="object")throw new h("Missing 'categories' map in configuration.");if(Object.keys(r.categories).length===0)throw new h("At least one category must be defined in 'categories'.");let t=r.categories.necessary;if(!t)throw new h("Category 'necessary' must be defined.");if(t.required!==!0)throw new h("Category 'necessary' must have 'required: true'.");for(let[n,s]of Object.entries(r.categories))if(n!=="necessary"&&!s.required&&s.default===!0)throw new h(`Legal violation (AEPD): Optional category '${n}' cannot have default: true. All optional categories must be opt-in (default: false).`);if(r.services&&typeof r.services=="object")for(let[n,s]of Object.entries(r.services)){if(!s.category)throw new h(`Service '${n}' missing 'category' reference.`);if(!r.categories[s.category])throw new h(`Service '${n}' references non-existent category '${s.category}'.`)}}var W=class{constructor(){this.state={initialized:!1,policyVersion:"",locale:"es",receipt:null,choices:{}};this.config=null}init(e,t,n){var s;this.config=e,this.state={initialized:!0,policyVersion:e.policyVersion,locale:((s=e.locale)==null?void 0:s.default)||"es",receipt:n,choices:t}}getConfig(){return this.config}getState(){return y({},this.state)}getChoices(){return y({},this.state.choices)}getReceipt(){return this.state.receipt}hasCategory(e){return this.state.choices[e]===!0}hasService(e){if(!this.config||!this.config.services)return!1;let t=this.config.services[e];return t?this.hasCategory(t.category):!1}updateChoices(e){this.state.receipt=e,this.state.choices=y({},e.choices)}clearChoices(){if(!this.config)return;let e={};for(let[t,n]of Object.entries(this.config.categories))e[t]=n.required===!0;this.state.choices=e,this.state.receipt=null}};var J=class{constructor(){this.handlers=new Map}on(e,t){this.handlers.has(e)||this.handlers.set(e,new Set);let n=this.handlers.get(e);return n.add(t),()=>{n.delete(t)}}emit(e,t){let n=this.handlers.get(e);if(n)for(let s of n)try{s(t)}catch(o){console.error(`[ConsentSDK Event Error] Handler for '${e}' failed:`,o)}}clear(){this.handlers.clear()}};function $e(r){let e,t,n="",s=r.length*8,o=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],i=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],c=[];for(e=0;e<r.length;e++)c[e>>2]|=r.charCodeAt(e)<<24-e%4*8;for(c[s>>5]|=128<<24-s%32,c[(s+64>>9<<4)+15]=s,e=0;e<c.length;e+=16){let a=c.slice(e,e+16),f=[...o];for(t=0;t<64;t++){let l=a[t-15],d=a[t-2],p=(l>>>7|l<<25)^(l>>>18|l<<14)^l>>>3,x=(d>>>17|d<<15)^(d>>>19|d<<13)^d>>>10;a[t]=t<16?a[t]||0:a[t-16]+p+a[t-7]+x|0;let u=o[4]&o[5]^~o[4]&o[6],k=o[0]&o[1]^o[0]&o[2]^o[1]&o[2],C=(o[0]>>>2|o[0]<<30)^(o[0]>>>13|o[0]<<19)^(o[0]>>>22|o[0]<<10),m=(o[4]>>>6|o[4]<<26)^(o[4]>>>11|o[4]<<21)^(o[4]>>>25|o[4]<<7),S=o[7]+m+u+i[t]+(a[t]|0),K=C+k;o[7]=o[6],o[6]=o[5],o[5]=o[4],o[4]=o[3]+S|0,o[3]=o[2],o[2]=o[1],o[1]=o[0],o[0]=S+K|0}for(t=0;t<8;t++)o[t]=o[t]+f[t]|0}for(e=0;e<8;e++)for(t=3;t>=0;t--){let a=o[e]>>t*8&255;n+=(a<16?"0":"")+a.toString(16)}return n}function P(r,e){if(e)return $e(`${e}:${r}:${e}`);let t=2166136261;for(let n=0;n<r.length;n++)t^=r.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16)}function Ce(r,e,t){return e?P(r,t)===e:!1}function g(r){return r?r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):""}function de(r){if(!r)return"#";let e=r.trim().toLowerCase();return e.startsWith("javascript:")||e.startsWith("data:")||e.startsWith("vbscript:")?"#":r}function Te(){return typeof crypto!="undefined"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function Y(r,e,t,n,s){let o=new Date().toISOString(),i=(n==null?void 0:n.receiptId)||Te(),c=(n==null?void 0:n.decidedAt)||o,a=`${i}:${r}:${JSON.stringify(e)}`,f=P(a,s);return{schema:1,receiptId:i,policyVersion:r,decidedAt:c,updatedAt:o,source:t,choices:e,signature:f}}function Q(r){try{let e=JSON.parse(r);return typeof e=="object"&&e!==null&&typeof e.receiptId=="string"&&typeof e.policyVersion=="string"&&typeof e.choices=="object"?e:null}catch(e){return null}}function X(r,e=365){if(!r.updatedAt)return!0;let t=new Date(r.updatedAt).getTime(),n=Date.now(),s=e*86400*1e3;return n-t>s}function we(r,e){var o,i,c;let t={};for(let[a,f]of Object.entries(r.categories))t[a]=f.required===!0;if(!e)return{isValid:!1,reason:"missing",choices:t};if(e.policyVersion!==r.policyVersion)return{isValid:!1,reason:"policy_version_changed",choices:t};let n=(i=(o=r.consent)==null?void 0:o.maxAgeDays)!=null?i:365;if(X(e,n))return{isValid:!1,reason:"expired",choices:t};if(e.signature){let a=`${e.receiptId}:${e.policyVersion}:${JSON.stringify(e.choices)}`,f=P(a,(c=r.security)==null?void 0:c.secretKey);if(e.signature!==f)return{isValid:!1,reason:"tampered",choices:t}}let s=y({},t);for(let a of Object.keys(r.categories))a==="necessary"?s[a]=!0:typeof e.choices[a]=="boolean"&&(s[a]=e.choices[a]);return{isValid:!0,reason:"valid",choices:s}}var z=class{get(e){return v.get(e)}set(e,t,n){v.set(e,t,n)}remove(e,t="/",n){v.remove(e,t,n)}},v=class{static get(e){if(typeof document=="undefined")return null;let t=encodeURIComponent(e)+"=",n=document.cookie.split(";");for(let s=0;s<n.length;s++){let o=n[s];for(;o.charAt(0)===" ";)o=o.substring(1,o.length);if(o.indexOf(t)===0)return decodeURIComponent(o.substring(t.length,o.length))}return null}static set(e,t,n={}){var d,p;if(typeof document=="undefined")return;let s=n.path||"/",o=(d=n.maxAgeDays)!=null?d:365,i=Math.floor(o*86400),c=n.sameSite||"Lax",a=typeof window!="undefined"&&window.location.protocol==="https:",f=(p=n.secure)!=null?p:a,l=`${encodeURIComponent(e)}=${encodeURIComponent(t)}; Path=${s}; Max-Age=${i}; SameSite=${c}`;n.domain&&(l+=`; Domain=${n.domain}`),f&&(l+="; Secure"),document.cookie=l}static remove(e,t="/",n){if(typeof document=="undefined")return;let s=`${encodeURIComponent(e)}=; Path=${t}; Max-Age=0; SameSite=Lax`;n&&(s+=`; Domain=${n}`),document.cookie=s}static clearServiceCookies(e,t){var o,i;if(typeof document=="undefined"||!e.services)return;let n=((o=e.storage)==null?void 0:o.path)||"/",s=(i=e.storage)==null?void 0:i.domain;for(let c of Object.values(e.services))if(c.category===t&&c.cookies)for(let a of c.cookies)this.remove(a.name,n,s||a.domain)}};var H=class H{get(e){var t;return(t=H.store.get(e))!=null?t:null}set(e,t){H.store.set(e,t)}remove(e){H.store.delete(e)}clear(){H.store.clear()}};H.store=new Map;var A=H,O={get:r=>new A().get(r),set:(r,e)=>new A().set(r,e),remove:r=>new A().remove(r),clear:()=>new A().clear()};var Z=class{constructor(){this.type="script"}process(e,t){M.scanAndActivate(e,t)}},M=class{static scanAndActivate(e,t,n){var o;if(typeof document=="undefined")return;let s=Array.from(document.querySelectorAll('script[type="text/plain"][data-consent], script[type="text/plain"][data-service]'));for(let i of s){if(this.executedScripts.has(i))continue;let c=i.getAttribute("data-consent"),a=i.getAttribute("data-service"),f=!1;if(a?f=t(a):c&&(f=e(c)),!f)continue;this.executedScripts.add(i);let l=document.createElement("script");for(let d=0;d<i.attributes.length;d++){let p=i.attributes[d];if(p.name!=="type"){if(p.name==="data-src"){l.src=p.value;continue}l.setAttribute(p.name,p.value)}}l.type="text/javascript",!l.src&&i.textContent&&(l.textContent=i.textContent),(o=i.parentNode)==null||o.replaceChild(l,i),(a||c)&&(n==null||n(a||c,c||"custom"))}}};M.executedScripts=new Set;var ee=class{constructor(){this.type="iframe"}process(e,t){L.processIframes(e,t)}},L=class{static processIframes(e,t,n={}){if(typeof document=="undefined")return;let s=Array.from(document.querySelectorAll("iframe[data-consent], iframe[data-service]"));for(let o of s){let i=o.getAttribute("data-consent"),c=o.getAttribute("data-service"),a=!1;c?a=t(c):i&&(a=e(i));let f=o.getAttribute("data-src")||o.getAttribute("src");f&&(o.getAttribute("data-src")||o.setAttribute("data-src",f),a?this.unlockIframe(o,f):this.lockIframe(o,i||"marketing",c||void 0,n))}}static lockIframe(e,t,n,s){var f;if(e.hasAttribute("src")&&e.removeAttribute("src"),this.placeholders.has(e))return;let o=document.createElement("div");o.className="consent-iframe-placeholder",o.style.cssText=`
|
|
2
2
|
width: ${e.width?e.width.endsWith("%")||e.width.endsWith("px")?e.width:e.width+"px":"100%"};
|
|
3
3
|
height: ${e.height?e.height.endsWith("%")||e.height.endsWith("px")?e.height:e.height+"px":"315px"};
|
|
4
4
|
min-height: 200px;
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
">
|
|
34
34
|
Permitir y mostrar contenido
|
|
35
35
|
</button>
|
|
36
|
-
`;let a=o.querySelector(".consent-placeholder-allow-btn");a==null||a.addEventListener("click",()=>{var
|
|
36
|
+
`;let a=o.querySelector(".consent-placeholder-allow-btn");a==null||a.addEventListener("click",()=>{var l;(l=s.onAllowClick)==null||l.call(s,t,n)}),e.style.display="none",(f=e.parentNode)==null||f.insertBefore(o,e),this.placeholders.set(e,o)}static unlockIframe(e,t){var s;e.getAttribute("src")!==t&&e.setAttribute("src",t),e.style.display="";let n=this.placeholders.get(e);n&&((s=n.parentNode)==null||s.removeChild(n),this.placeholders.delete(e))}};L.placeholders=new Map;var te=class{constructor(){this.type="image"}process(e,t){_.processImages(e,t)}},_=class{static processImages(e,t){if(typeof document=="undefined")return;let n=Array.from(document.querySelectorAll("img[data-consent], img[data-service]"));for(let s of n){let o=s.getAttribute("data-consent"),i=s.getAttribute("data-service"),c=!1;i?c=t(i):o&&(c=e(o));let a=s.getAttribute("data-src")||s.getAttribute("src");a&&(s.getAttribute("data-src")||s.setAttribute("data-src",a),c?s.getAttribute("src")!==a&&s.setAttribute("src",a):s.hasAttribute("src")&&s.removeAttribute("src"))}}};var ne=class{constructor(){this.observer=null}init(e,t,n,s){let o=()=>{M.scanAndActivate(e,t,s),L.processIframes(e,t,n),_.processImages(e,t)};o(),typeof MutationObserver!="undefined"&&typeof document!="undefined"&&(this.observer=new MutationObserver(()=>{o()}),this.observer.observe(document.documentElement||document.body,{childList:!0,subtree:!0}))}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null)}};var I=class{static initDefault(e){typeof window!="undefined"&&(window.dataLayer=window.dataLayer||[],window.gtag||(window.gtag=function(){var t;(t=window.dataLayer)==null||t.push(arguments)}),this.initialized||(window.gtag("consent","default",{analytics_storage:"denied",ad_storage:"denied",ad_user_data:"denied",ad_personalization:"denied",wait_for_update:500}),this.initialized=!0))}static update(e,t){if(typeof window=="undefined")return;this.initDefault(t);let n=(t==null?void 0:t.analytics_storage)||"analytics",s=(t==null?void 0:t.ad_storage)||"marketing",o=e[n]===!0,i=e[s]===!0;window.gtag("consent","update",{analytics_storage:o?"granted":"denied",ad_storage:i?"granted":"denied",ad_user_data:i?"granted":"denied",ad_personalization:i?"granted":"denied"})}};I.initialized=!1;var oe=class{static createWhen(e,t,n){return function(o,i){if(t(o)||n(o))try{i()}catch(c){console.error("[ConsentSDK when()] Callback execution failed:",c)}return e.on("consent:changed",({choices:c})=>{if(c[o]===!0||n(o))try{i()}catch(a){console.error("[ConsentSDK when()] Callback execution failed:",a)}})}}};function re(r){if(typeof document=="undefined")return;let e=document.getElementById("consent-sdk-styles");e&&e.remove();let t=document.createElement("style");t.id="consent-sdk-styles",r&&t.setAttribute("nonce",r),t.textContent=`
|
|
37
37
|
:root {
|
|
38
38
|
--consent-bg: #ffffff;
|
|
39
39
|
--consent-fg: #0f172a;
|
|
@@ -471,7 +471,7 @@
|
|
|
471
471
|
flex-direction: row;
|
|
472
472
|
}
|
|
473
473
|
}
|
|
474
|
-
`,document.head.appendChild(t)}var se=class{constructor(){this.element=null}render(e,t){var
|
|
474
|
+
`,document.head.appendChild(t)}var se=class{constructor(){this.element=null}render(e,t){var p,x,u,k,C,m,S;if(typeof document=="undefined")return;this.remove(),re((p=e.csp)==null?void 0:p.nonce);let n=((x=e.ui)==null?void 0:x.banner)||{},s=g(n.title||"Tu privacidad, bajo tu control"),o=g(n.description||"Usamos tecnolog\xEDas necesarias para el funcionamiento del sitio. Con tu permiso, tambi\xE9n podemos utilizar anal\xEDtica y marketing."),i=g(n.accept||"Aceptar todas"),c=g(n.reject||"Rechazar todas"),a=g(n.configure||"Configurar"),f=de(((u=e.policy)==null?void 0:u.privacyUrl)||"/politica-privacidad"),l=de(((k=e.policy)==null?void 0:k.cookiesUrl)||"/politica-cookies"),d=document.createElement("div");d.className="consent-banner-wrapper",d.setAttribute("role","region"),d.setAttribute("aria-label","Gesti\xF3n de consentimiento de privacidad"),d.innerHTML=`
|
|
475
475
|
<div class="consent-banner-container">
|
|
476
476
|
<div class="consent-banner-text">
|
|
477
477
|
<h2 class="consent-banner-title">
|
|
@@ -484,8 +484,8 @@
|
|
|
484
484
|
</h2>
|
|
485
485
|
<p class="consent-banner-desc">${o}</p>
|
|
486
486
|
<div class="consent-banner-links">
|
|
487
|
-
<a href="${
|
|
488
|
-
<a href="${
|
|
487
|
+
<a href="${l}" target="_blank" rel="noopener">Pol\xEDtica de cookies</a>
|
|
488
|
+
<a href="${f}" target="_blank" rel="noopener">Pol\xEDtica de privacidad</a>
|
|
489
489
|
</div>
|
|
490
490
|
</div>
|
|
491
491
|
<div class="consent-banner-actions">
|
|
@@ -500,7 +500,7 @@
|
|
|
500
500
|
</button>
|
|
501
501
|
</div>
|
|
502
502
|
</div>
|
|
503
|
-
`,(
|
|
503
|
+
`,(C=d.querySelector("#consent-btn-reject"))==null||C.addEventListener("click",()=>{t.onRejectAll(),this.remove()}),(m=d.querySelector("#consent-btn-configure"))==null||m.addEventListener("click",()=>{t.onConfigure()}),(S=d.querySelector("#consent-btn-accept"))==null||S.addEventListener("click",()=>{t.onAcceptAll(),this.remove()}),document.body.appendChild(d),this.element=d}remove(){this.element&&this.element.parentNode&&(this.element.parentNode.removeChild(this.element),this.element=null)}};var ie=class{constructor(){this.backdrop=null;this.lastFocusedElement=null}render(e,t,n){var m,S,K,fe,pe,ge,ue;if(typeof document=="undefined")return;this.close(),re((m=e.csp)==null?void 0:m.nonce),this.lastFocusedElement=document.activeElement;let s=((S=e.ui)==null?void 0:S.preferences)||{},o=g(s.title||"Preferencias de privacidad"),i=g(s.save||"Guardar selecci\xF3n"),c=g(s.acceptAll||"Permitir todas"),a=g(s.rejectAll||"Rechazar opcionales"),f=document.createElement("div");f.className="consent-dialog-backdrop";let l=document.createElement("div");l.className="consent-dialog",l.setAttribute("role","dialog"),l.setAttribute("aria-modal","true"),l.setAttribute("aria-labelledby","consent-dialog-title-id");let d=document.createElement("div");d.className="consent-dialog-header",d.innerHTML=`
|
|
504
504
|
<div>
|
|
505
505
|
<h2 class="consent-dialog-title" id="consent-dialog-title-id">${o}</h2>
|
|
506
506
|
<p style="margin: 0.2rem 0 0 0; font-size: 0.84rem; color: var(--consent-muted); font-weight: 400;">
|
|
@@ -513,26 +513,26 @@
|
|
|
513
513
|
<line x1="6" y1="6" x2="18" y2="18"></line>
|
|
514
514
|
</svg>
|
|
515
515
|
</button>
|
|
516
|
-
`;let
|
|
516
|
+
`;let p=document.createElement("div");p.className="consent-dialog-body";let x=y({},t);for(let[b,$]of Object.entries(e.categories)){let w=document.createElement("div");w.className="consent-category-row";let j=$.required===!0,ke=j?!0:(K=x[b])!=null?K:!1,T=e.services?Object.entries(e.services).filter(([R,E])=>E.category===b):[],me="";if(T.length>0&&(me=`
|
|
517
517
|
<div class="consent-category-services" id="cat-services-${b}" style="display: none; margin-top: 0.75rem; padding-top: 0.6rem; border-top: 1px dashed var(--consent-divider); font-size: 0.82rem;">
|
|
518
518
|
<div style="font-weight: 600; color: var(--consent-muted); margin-bottom: 0.4rem; font-size: 0.75rem; letter-spacing: 0.02em;">
|
|
519
519
|
Servicios incluidos (${T.length})
|
|
520
520
|
</div>
|
|
521
521
|
<div style="display: flex; flex-direction: column; gap: 0.3rem;">
|
|
522
|
-
${T.map(([
|
|
522
|
+
${T.map(([R,E])=>`
|
|
523
523
|
<div style="display: flex; justify-content: space-between; align-items: center; padding: 0.2rem 0;">
|
|
524
|
-
<span style="font-weight: 500;">${g(
|
|
525
|
-
<span style="color: var(--consent-muted); font-size: 0.78rem;">${g(
|
|
524
|
+
<span style="font-weight: 500;">${g(E.label||R)}</span>
|
|
525
|
+
<span style="color: var(--consent-muted); font-size: 0.78rem;">${g(E.provider||"Terceros")}</span>
|
|
526
526
|
</div>
|
|
527
527
|
`).join("")}
|
|
528
528
|
</div>
|
|
529
529
|
</div>
|
|
530
|
-
`),
|
|
530
|
+
`),w.innerHTML=`
|
|
531
531
|
<div class="consent-category-header">
|
|
532
532
|
<div style="flex: 1; padding-right: 1rem;">
|
|
533
533
|
<div style="display: flex; align-items: center; gap: 0.4rem;">
|
|
534
534
|
<span class="consent-category-name">${g($.label)}</span>
|
|
535
|
-
${
|
|
535
|
+
${j?'<span class="consent-badge consent-badge-required">Requerida</span>':'<span class="consent-badge consent-badge-optional">Opcional</span>'}
|
|
536
536
|
</div>
|
|
537
537
|
<p class="consent-category-desc">${g($.description)}</p>
|
|
538
538
|
${T.length>0?`<button type="button" class="consent-toggle-services-btn" data-target="cat-services-${b}">
|
|
@@ -540,12 +540,12 @@
|
|
|
540
540
|
</button>`:""}
|
|
541
541
|
</div>
|
|
542
542
|
<label class="consent-toggle">
|
|
543
|
-
<input type="checkbox" id="cat-toggle-${b}" ${ke?"checked":""} ${
|
|
543
|
+
<input type="checkbox" id="cat-toggle-${b}" ${ke?"checked":""} ${j?"disabled":""}>
|
|
544
544
|
<span class="consent-toggle-slider"></span>
|
|
545
545
|
</label>
|
|
546
546
|
</div>
|
|
547
547
|
${me}
|
|
548
|
-
`,!
|
|
548
|
+
`,!j){let R=w.querySelector(`#cat-toggle-${b}`);R==null||R.addEventListener("change",E=>{x[b]=E.target.checked})}let F=w.querySelector(".consent-toggle-services-btn");F&&F.addEventListener("click",()=>{let R=F.getAttribute("data-target");if(R){let E=w.querySelector(`#${R}`);if(E){let he=E.style.display==="none";E.style.display=he?"block":"none",F.textContent=he?`Ocultar servicios (${T.length}) \u25B4`:`Ver servicios (${T.length}) \u25BE`}}}),p.appendChild(w)}let u=document.createElement("div");u.className="consent-dialog-footer",u.innerHTML=`
|
|
549
549
|
<button type="button" class="consent-btn consent-btn-reject" id="consent-pref-reject">
|
|
550
550
|
${a}
|
|
551
551
|
</button>
|
|
@@ -557,7 +557,7 @@
|
|
|
557
557
|
${i}
|
|
558
558
|
</button>
|
|
559
559
|
</div>
|
|
560
|
-
`,
|
|
560
|
+
`,l.appendChild(d),l.appendChild(p),l.appendChild(u),f.appendChild(l),(fe=d.querySelector(".consent-dialog-close"))==null||fe.addEventListener("click",()=>{n.onClose(),this.close()}),(pe=u.querySelector("#consent-pref-reject"))==null||pe.addEventListener("click",()=>{n.onRejectAll(),this.close()}),(ge=u.querySelector("#consent-pref-accept"))==null||ge.addEventListener("click",()=>{n.onAcceptAll(),this.close()}),(ue=u.querySelector("#consent-pref-save"))==null||ue.addEventListener("click",()=>{n.onSave(x),this.close()});let k=b=>{if(b.key==="Escape"){n.onClose(),this.close();return}if(b.key==="Tab"){let $=l.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),w=$[0],j=$[$.length-1];b.shiftKey?document.activeElement===w&&(j==null||j.focus(),b.preventDefault()):document.activeElement===j&&(w==null||w.focus(),b.preventDefault())}};document.addEventListener("keydown",k),this._keyListener=k,document.body.appendChild(f),this.backdrop=f;let C=l.querySelector("button");C==null||C.focus()}close(){this._keyListener&&(document.removeEventListener("keydown",this._keyListener),delete this._keyListener),this.backdrop&&this.backdrop.parentNode&&(this.backdrop.parentNode.removeChild(this.backdrop),this.backdrop=null),this.lastFocusedElement&&typeof this.lastFocusedElement.focus=="function"&&(this.lastFocusedElement.focus(),this.lastFocusedElement=null)}};var q=class r{static runDiagnostic(e,t){let n=[];return typeof document!="undefined"&&document.querySelectorAll("script[src]").forEach(o=>{let i=o.getAttribute("src");i&&(i.startsWith("http://")||i.startsWith("https://"))&&n.push(i)}),{timestamp:new Date().toISOString(),unblockedThirdPartyScripts:t?[]:n,compliant:t||n.length===0}}scanThirdPartyResources(){return r.runDiagnostic({},!0).unblockedThirdPartyScripts}};var B=class{static renderTable(e){let t=`
|
|
561
561
|
<div class="consent-policy-table-wrapper" style="margin: 1.5rem 0; font-family: system-ui, sans-serif;">
|
|
562
562
|
<table style="width: 100%; border-collapse: collapse; text-align: left; border: 1px solid #e2e8f0;">
|
|
563
563
|
<thead>
|
|
@@ -585,5 +585,5 @@
|
|
|
585
585
|
</tbody>
|
|
586
586
|
</table>
|
|
587
587
|
</div>
|
|
588
|
-
`,t}};var V=class{constructor(){this.stateManager=new W;this.eventBus=new J;this.blockerRegistry=new ne;this.banner=new se;this.preferencesModal=new ie;this.initPromise=null;this.resolveReady=null;this.readyPromise=new Promise(e=>{this.resolveReady=e})}async init(e){return this.initPromise?this.initPromise:(this.initPromise=(async()=>{var a,
|
|
588
|
+
`,t}};var V=class{constructor(){this.stateManager=new W;this.eventBus=new J;this.blockerRegistry=new ne;this.banner=new se;this.preferencesModal=new ie;this.initPromise=null;this.resolveReady=null;this.readyPromise=new Promise(e=>{this.resolveReady=e})}async init(e){return this.initPromise?this.initPromise:(this.initPromise=(async()=>{var a,f,l;let t;if(typeof e=="string"){let d=await fetch(e);if(!d.ok)throw new Error(`[ConsentSDK] Failed to fetch consent configuration from '${e}' (HTTP ${d.status})`);t=await d.json()}else t=e;D(t);let n=((a=t.storage)==null?void 0:a.name)||"site_consent",s=((f=t.storage)==null?void 0:f.type)==="memory"?O.get(n):v.get(n),o=s?Q(s):null,i=we(t,o),c=i.isValid?o:null;this.stateManager.init(t,i.choices,c),I.initDefault(),i.isValid&&(I.update(i.choices),this.dispatchDomEvent("solvenza:restored",{state:this.getConsent()})),this.blockerRegistry.init(d=>this.has(d),d=>this.hasService(d),{onAllowClick:d=>{let p=this.stateManager.getChoices();p[d]=!0,this.setPreferences(p)}},(d,p)=>{this.eventBus.emit("service:loaded",{serviceId:d,category:p})}),this.setupGlobalRevocationTrigger(),(l=this.resolveReady)==null||l.call(this),this.eventBus.emit("ready",{state:this.getConsent()}),i.isValid||this.showBanner()})(),this.initPromise)}async ready(){return this.readyPromise}getConsent(){return this.stateManager.getState()}has(e){return this.stateManager.hasCategory(e)}hasService(e){return this.stateManager.hasService(e)}acceptAll(){let e=this.stateManager.getConfig();if(!e)return;let t={};for(let n of Object.keys(e.categories))t[n]=!0;this.saveChoices(t,"banner"),this.eventBus.emit("consent:accepted",{choices:t,receipt:this.getReceipt()})}rejectAll(){let e=this.stateManager.getConfig();if(!e)return;let t={};for(let[n,s]of Object.entries(e.categories))t[n]=s.required===!0;this.saveChoices(t,"banner"),this.eventBus.emit("consent:rejected",{choices:t,receipt:this.getReceipt()})}setPreferences(e){if(!this.stateManager.getConfig())return;let n=y({},e);n.necessary=!0,this.saveChoices(n,"preferences")}openPreferences(){let e=this.stateManager.getConfig();e&&(this.preferencesModal.render(e,this.stateManager.getChoices(),{onSave:t=>this.setPreferences(t),onAcceptAll:()=>this.acceptAll(),onRejectAll:()=>this.rejectAll(),onClose:()=>{this.eventBus.emit("preferences:closed",void 0)}}),this.eventBus.emit("preferences:opened",void 0))}closePreferences(){this.preferencesModal.close()}withdraw(){var s,o,i,c;let e=this.stateManager.getChoices(),t=this.stateManager.getConfig();if(!t)return;let n=((s=t.storage)==null?void 0:s.name)||"site_consent";((o=t.storage)==null?void 0:o.type)==="memory"?O.remove(n):v.remove(n,((i=t.storage)==null?void 0:i.path)||"/",(c=t.storage)==null?void 0:c.domain);for(let a of Object.keys(t.categories))a!=="necessary"&&v.clearServiceCookies(t,a);this.stateManager.clearChoices(),I.update(this.stateManager.getChoices()),this.eventBus.emit("consent:withdrawn",{previousChoices:e}),this.dispatchDomEvent("solvenza:updated",{choices:this.stateManager.getChoices()}),this.showBanner()}when(e,t){return oe.createWhen(this.eventBus,n=>this.has(n),n=>this.hasService(n))(e,t)}on(e,t){return this.eventBus.on(e,t)}getReceipt(){return this.stateManager.getReceipt()}rescan(){let e=this.stateManager.getConfig();if(!e)throw new Error("[ConsentSDK] SDK not initialized.");let t=!!this.getReceipt();return q.runDiagnostic(e,t)}mountPolicy(e){let t=this.stateManager.getConfig();if(!t)throw new Error("[ConsentSDK] SDK not initialized.");let n=typeof e=="string"?document.querySelector(e):e;n&&(n.innerHTML=B.renderTable(t))}saveChoices(e,t){var c,a,f,l,d,p,x,u,k,C;let n=this.stateManager.getConfig();if(!n)return;let s=Y(n.policyVersion,e,t,this.stateManager.getReceipt(),(c=n.security)==null?void 0:c.secretKey);this.stateManager.updateChoices(s);for(let[m,S]of Object.entries(e))S||v.clearServiceCookies(n,m);let o=((a=n.storage)==null?void 0:a.name)||"site_consent",i=JSON.stringify(s);if(((f=n.storage)==null?void 0:f.type)==="memory"?O.set(o,i):v.set(o,i,{path:((l=n.storage)==null?void 0:l.path)||"/",maxAgeDays:(p=(d=n.consent)==null?void 0:d.maxAgeDays)!=null?p:365,sameSite:((x=n.storage)==null?void 0:x.sameSite)||"Lax",secure:(u=n.storage)==null?void 0:u.secure,domain:(k=n.storage)==null?void 0:k.domain}),I.update(e),this.blockerRegistry.init(m=>this.has(m),m=>this.hasService(m)),(C=n.logging)!=null&&C.enabled&&n.logging.endpoint)try{fetch(n.logging.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:i}).catch(()=>{})}catch(m){}this.banner.remove(),this.eventBus.emit("consent:changed",{choices:e,receipt:s}),this.dispatchDomEvent("solvenza:updated",{choices:e,receipt:s})}showBanner(){let e=this.stateManager.getConfig();e&&(this.banner.render(e,{onAcceptAll:()=>this.acceptAll(),onRejectAll:()=>this.rejectAll(),onConfigure:()=>this.openPreferences()}),this.eventBus.emit("banner:shown",void 0),this.dispatchDomEvent("solvenza:show",void 0))}setupGlobalRevocationTrigger(){typeof document!="undefined"&&(document.addEventListener("click",e=>{let t=e.target;t!=null&&t.closest("[data-consent-open]")&&(e.preventDefault(),this.openPreferences())}),document.addEventListener("solvenza:show",()=>{this.showBanner()}),document.addEventListener("solvenza:preferences",()=>{this.openPreferences()}))}dispatchDomEvent(e,t){if(typeof document!="undefined")try{let n=new CustomEvent(e,{detail:t,bubbles:!0});document.dispatchEvent(n)}catch(n){}}},le=typeof window!="undefined"?window:globalThis;le.__ConsentSDK_Instance__||(le.__ConsentSDK_Instance__=new V);var N=le.__ConsentSDK_Instance__;var U=class{constructor(e){this.config={schemaVersion:1,policyVersion:"1.0.0",categories:{},services:{}};e&&(this.config.policyVersion=e)}setSchemaVersion(e){return this.config.schemaVersion=e,this}setPolicyVersion(e){return this.config.policyVersion=e,this}setPolicyUrls(e,t){return this.config.policy={privacyUrl:e,cookiesUrl:t},this}setLocale(e,t=!0){return this.config.locale={default:e,autoDetect:t},this}addCategory(e,t){return this.config.categories||(this.config.categories={}),this.config.categories[e]=t,this}addService(e,t){return this.config.services||(this.config.services={}),this.config.services[e]=t,this}build(){var t;(t=this.config.categories)!=null&&t.necessary||(this.config.categories=xe(y({},this.config.categories),{necessary:{required:!0,default:!0,label:"Necesarias",description:"Cookies y almacenamiento imprescindible para el funcionamiento del sitio."}}));let e=this.config;return D(e),e}};var ae=class{static create(e){switch(e){case"cookie":return new z;case"memory":return new A;default:return new z}}};var ce=class{constructor(){this.locale="es"}setLocale(e){this.locale=e}getLocale(){return this.locale}detectBrowserLocale(){return typeof navigator!="undefined"&&navigator.language?navigator.language.split("-")[0].toLowerCase():"es"}};typeof window!="undefined"&&(window.Consent=N,window.ConsentSDK={Consent:N,ConsentEngine:V,ConsentConfigBuilder:U,validateConfig:D,PolicyGenerator:B,ResourceScanner:q});if(typeof document!="undefined"){let r=document.currentScript,e=r==null?void 0:r.getAttribute("data-config");if(e){let t=()=>{N.init(e).catch(n=>{console.warn("[ConsentSDK AutoInit Warning]",n)})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):t()}}return Le(De);})();
|
|
589
589
|
//# sourceMappingURL=consent.min.js.map
|