@freshjuice/zest 0.1.0 → 2.0.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/README.md +216 -70
- package/dist/zest.de.js +776 -286
- package/dist/zest.de.js.map +1 -1
- package/dist/zest.de.min.js +1 -1
- package/dist/zest.en.js +776 -286
- package/dist/zest.en.js.map +1 -1
- package/dist/zest.en.min.js +1 -1
- package/dist/zest.es.js +776 -286
- package/dist/zest.es.js.map +1 -1
- package/dist/zest.es.min.js +1 -1
- package/dist/zest.esm.js +776 -286
- package/dist/zest.esm.js.map +1 -1
- package/dist/zest.esm.min.js +1 -1
- package/dist/zest.fr.js +776 -286
- package/dist/zest.fr.js.map +1 -1
- package/dist/zest.fr.min.js +1 -1
- package/dist/zest.headless.esm.js +2299 -0
- package/dist/zest.headless.esm.js.map +1 -0
- package/dist/zest.headless.esm.min.js +1 -0
- package/dist/zest.it.js +776 -286
- package/dist/zest.it.js.map +1 -1
- package/dist/zest.it.min.js +1 -1
- package/dist/zest.ja.js +776 -286
- package/dist/zest.ja.js.map +1 -1
- package/dist/zest.ja.min.js +1 -1
- package/dist/zest.js +776 -286
- package/dist/zest.js.map +1 -1
- package/dist/zest.min.js +1 -1
- package/dist/zest.nl.js +776 -286
- package/dist/zest.nl.js.map +1 -1
- package/dist/zest.nl.min.js +1 -1
- package/dist/zest.pl.js +776 -286
- package/dist/zest.pl.js.map +1 -1
- package/dist/zest.pl.min.js +1 -1
- package/dist/zest.pt.js +776 -286
- package/dist/zest.pt.js.map +1 -1
- package/dist/zest.pt.min.js +1 -1
- package/dist/zest.ru.js +776 -286
- package/dist/zest.ru.js.map +1 -1
- package/dist/zest.ru.min.js +1 -1
- package/dist/zest.uk.js +776 -286
- package/dist/zest.uk.js.map +1 -1
- package/dist/zest.uk.min.js +1 -1
- package/dist/zest.zh.js +776 -286
- package/dist/zest.zh.js.map +1 -1
- package/dist/zest.zh.min.js +1 -1
- package/package.json +17 -4
- package/src/api/public-api.js +97 -0
- package/src/config/defaults.js +150 -0
- package/src/config/parser.js +104 -0
- package/src/core/categories.js +52 -0
- package/src/core/cookie-interceptor.js +131 -0
- package/src/core/dnt.js +56 -0
- package/src/core/known-trackers.js +195 -0
- package/src/core/pattern-matcher.js +111 -0
- package/src/core/script-blocker.js +314 -0
- package/src/core/security.js +204 -0
- package/src/core/storage-interceptor.js +173 -0
- package/src/core-lifecycle.js +192 -0
- package/src/headless.js +133 -0
- package/src/i18n/lang-en.js +54 -0
- package/src/i18n/single/lang-de.js +55 -0
- package/src/i18n/single/lang-en.js +55 -0
- package/src/i18n/single/lang-es.js +55 -0
- package/src/i18n/single/lang-fr.js +55 -0
- package/src/i18n/single/lang-it.js +55 -0
- package/src/i18n/single/lang-ja.js +55 -0
- package/src/i18n/single/lang-nl.js +55 -0
- package/src/i18n/single/lang-pl.js +55 -0
- package/src/i18n/single/lang-pt.js +55 -0
- package/src/i18n/single/lang-ru.js +55 -0
- package/src/i18n/single/lang-uk.js +55 -0
- package/src/i18n/single/lang-zh.js +55 -0
- package/src/i18n/translations.js +546 -0
- package/src/index.js +266 -0
- package/src/integrations/consent-signals.js +71 -0
- package/src/storage/consent-store.js +201 -0
- package/src/storage/events.js +84 -0
- package/src/ui/banner.js +134 -0
- package/src/ui/modal.js +215 -0
- package/src/ui/styles.js +519 -0
- package/src/ui/widget.js +105 -0
package/dist/zest.zh.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Zest=function(){"use strict";const t={essential:[/^zest_/,/^csrf/i,/^xsrf/i,/^session/i,/^__host-/i,/^__secure-/i],functional:[/^lang/i,/^locale/i,/^theme/i,/^preferences/i,/^ui_/i],analytics:[/^_ga/,/^_gid/,/^_gat/,/^_utm/,/^__utm/,/^plausible/i,/^_pk_/,/^matomo/i,/^_hj/,/^ajs_/],marketing:[/^_fbp/,/^_fbc/,/^_gcl/,/^_ttp/,/^ads/i,/^doubleclick/i,/^__gads/,/^__gpi/,/^_pin_/,/^li_/]};let n={...t};function e(t){for(const[e,o]of Object.entries(n))if(o.some(n=>n.test(t)))return e;return"marketing"}let o=null;const a=[];let s=()=>!1;function r(){return o}let i=null,c=null;const l=[],d=[];let u=()=>!1;function p(t,n,o){return new Proxy(t,{get(t,o){if("setItem"===o)return(o,a)=>{const s=e(o);u(s)?t.setItem(o,a):n.push({key:o,value:a,category:s,timestamp:Date.now()})};const a=t[o];return"function"==typeof a?a.bind(t):a}})}const m={analytics:["google-analytics.com","www.google-analytics.com","analytics.google.com","googletagmanager.com","www.googletagmanager.com","plausible.io","cloudflareinsights.com","static.cloudflareinsights.com"],marketing:["connect.facebook.net","www.facebook.com/tr","ads.google.com","www.googleadservices.com","googleads.g.doubleclick.net","pagead2.googlesyndication.com"]},g={analytics:[...m.analytics,"analytics.tiktok.com","matomo.","hotjar.com","static.hotjar.com","script.hotjar.com","clarity.ms","www.clarity.ms","heapanalytics.com","cdn.heapanalytics.com","mixpanel.com","cdn.mxpnl.com","segment.com","cdn.segment.com","api.segment.io","fullstory.com","rs.fullstory.com","amplitude.com","cdn.amplitude.com","mouseflow.com","cdn.mouseflow.com","luckyorange.com","cdn.luckyorange.net","crazyegg.com","script.crazyegg.com"],marketing:[...m.marketing,"snap.licdn.com","px.ads.linkedin.com","ads.linkedin.com","analytics.twitter.com","static.ads-twitter.com","t.co","analytics.tiktok.com","ads.tiktok.com","sc-static.net","tr.snapchat.com","ct.pinterest.com","pintrk.com","s.pinimg.com","widgets.pinterest.com","bat.bing.com","ads.yahoo.com","sp.analytics.yahoo.com","amazon-adsystem.com","z-na.amazon-adsystem.com","criteo.com","static.criteo.net","dis.criteo.com","taboola.com","cdn.taboola.com","trc.taboola.com","outbrain.com","widgets.outbrain.com","adroll.com","s.adroll.com"],functional:["cdn.onesignal.com","onesignal.com","pusher.com","js.pusher.com","intercom.io","widget.intercom.io","js.intercomcdn.com","crisp.chat","client.crisp.chat","cdn.livechatinc.com","livechatinc.com","tawk.to","embed.tawk.to","zendesk.com","static.zdassets.com"]};function f(t,n){try{const e=new URL(t).hostname.toLowerCase(),o=t.toLowerCase();for(const t of n)if(t.endsWith(".")){if(e.includes(t.slice(0,-1)))return!0}else{if(e===t||e.endsWith("."+t))return!0;if(o.includes(t))return!0}}catch(t){}return!1}function b(t,n="safe"){const e="strict"===n?g:m;for(const[n,o]of Object.entries(e))if(f(t,o))return n;return null}const y=[];let z=null,h="safe",x=[],w=()=>!1;function v(t){const n=t.getAttribute("data-consent-category");if(n)return n;if(t.hasAttribute("data-zest-allow"))return null;const e=t.src;if(!e)return null;const o=function(t){if(!t||0===x.length)return null;try{const n=new URL(t).hostname.toLowerCase();for(const t of x){const e="string"==typeof t?t:t.domain,o="string"==typeof t?"marketing":t.category||"marketing";if(n===e||n.endsWith("."+e))return o}}catch(t){}return null}(e);if(o)return o;switch(h){case"manual":default:return null;case"safe":case"strict":return b(e,h);case"doomsday":return function(t){try{const n=new URL(t).hostname,e=window.location.hostname,o=t=>t.replace(/^www\./,"");return o(n)!==o(e)}catch(t){return!1}}(e)?b(e,"strict")||"marketing":null}}function k(t){if(t.hasAttribute("data-zest-processed"))return!1;const n=v(t);if(!n)return t.setAttribute("data-zest-processed","allowed"),!1;if(w(n))return t.setAttribute("data-zest-processed","allowed"),!1;const e={category:n,src:t.src,inline:t.textContent,type:t.type,async:t.async,defer:t.defer,timestamp:Date.now()};return t.setAttribute("data-zest-processed","blocked"),t.setAttribute("data-consent-category",n),t.type="text/plain",t.src&&(t.setAttribute("data-blocked-src",t.src),t.removeAttribute("src")),y.push(e),!0}function _(t){const n=document.createElement("script");t.src?n.src=t.src:t.inline&&(n.textContent=t.inline),t.async&&(n.async=!0),t.defer&&(n.defer=!0),n.setAttribute("data-zest-processed","executed"),n.setAttribute("data-consent-executed","true"),document.head.appendChild(n)}function A(t){for(const n of t)for(const t of n.addedNodes)if("SCRIPT"!==t.nodeName||t.hasAttribute("data-zest-processed")||k(t),t.querySelectorAll){t.querySelectorAll("script:not([data-zest-processed])").forEach(k)}}function C(t="safe",n=[]){return h=t,x=n,document.querySelectorAll("script:not([data-zest-processed])").forEach(k),z=new MutationObserver(A),z.observe(document.documentElement,{childList:!0,subtree:!0}),!0}const S={essential:{id:"essential",label:"Essential",description:"Required for the website to function properly. Cannot be disabled.",required:!0,default:!0},functional:{id:"functional",label:"Functional",description:"Enable personalized features like language preferences and themes.",required:!1,default:!1},analytics:{id:"analytics",label:"Analytics",description:"Help us understand how visitors interact with our website.",required:!1,default:!1},marketing:{id:"marketing",label:"Marketing",description:"Used to deliver relevant advertisements and track campaign performance.",required:!1,default:!1}};function E(){if("undefined"==typeof navigator)return!1;const t=navigator.doNotTrack||window.doNotTrack||navigator.msDoNotTrack;return"1"===t||"yes"===t||!0===t||!0===navigator.globalPrivacyControl}const j={labels:{banner:{title:"我们重视您的隐私",description:'我们使用Cookie来改善您的浏览体验、提供个性化内容并分析我们的流量。点击"全部接受"即表示您同意我们使用Cookie。',acceptAll:"全部接受",rejectAll:"全部拒绝",settings:"设置"},modal:{title:"隐私设置",description:"管理您的Cookie偏好设置。您可以在下方启用或禁用不同类型的Cookie。",save:"保存设置",acceptAll:"全部接受",rejectAll:"全部拒绝"},widget:{label:"Cookie设置"}},categories:{essential:{label:"必要",description:"网站正常运行所必需的。无法禁用。"},functional:{label:"功能性",description:"启用个性化功能,如语言偏好和主题设置。"},analytics:{label:"分析",description:"帮助我们了解访问者如何与网站互动。"},marketing:{label:"营销",description:"用于展示相关广告并衡量营销活动效果。"}}};const R={lang:"auto",position:"bottom",theme:"auto",accentColor:"#0071e3",categories:S,labels:{banner:{title:"We value your privacy",description:'We use cookies to enhance your browsing experience, serve personalized content, and analyze our traffic. By clicking "Accept All", you consent to our use of cookies.',acceptAll:"Accept All",rejectAll:"Reject All",settings:"Settings"},modal:{title:"Privacy Settings",description:"Manage your cookie preferences. You can enable or disable different types of cookies below.",save:"Save Preferences",acceptAll:"Accept All",rejectAll:"Reject All"},widget:{label:"Cookie Settings"}},autoInit:!0,showWidget:!0,expiration:365,respectDNT:!0,dntBehavior:"reject",customStyles:"",mode:"safe",blockedDomains:[],policyUrl:null,imprintUrl:null,callbacks:{onAccept:null,onReject:null,onChange:null,onReady:null}};function $(t){const n={...R};t||(t={});const e=["lang","position","theme","accentColor","autoInit","showWidget","expiration","policyUrl","imprintUrl","customStyles","mode","blockedDomains","respectDNT","dntBehavior"];for(const o of e)void 0!==t[o]&&(n[o]=t[o]);n.lang="zh";const o=j,a=o.labels||{},s=t.labels||{};n.labels={banner:{...R.labels.banner,...a.banner,...s.banner},modal:{...R.labels.modal,...a.modal,...s.modal},widget:{...R.labels.widget,...a.widget,...s.widget}};const r=o.categories||{},i=t.categories||{};n.categories={...R.categories};for(const t of Object.keys(R.categories))n.categories[t]={...R.categories[t],...r[t],...i[t]};return t.callbacks&&(n.callbacks={...R.callbacks,...t.callbacks}),t.patterns&&(n.patterns=t.patterns),n}function N(){const t="undefined"!=typeof window&&window.ZestConfig?window.ZestConfig:{},n=function(){const t=document.currentScript||document.querySelector("script[data-zest]")||document.querySelector('script[src*="zest"]');if(!t)return{};const n={},e=t.getAttribute("data-position");e&&(n.position=e);const o=t.getAttribute("data-theme");o&&(n.theme=o);const a=t.getAttribute("data-accent")||t.getAttribute("data-accent-color");a&&(n.accentColor=a);const s=t.getAttribute("data-policy-url")||t.getAttribute("data-privacy-url");s&&(n.policyUrl=s);const r=t.getAttribute("data-imprint-url");r&&(n.imprintUrl=r);const i=t.getAttribute("data-show-widget");null!==i&&(n.showWidget="false"!==i);const c=t.getAttribute("data-auto-init");null!==c&&(n.autoInit="false"!==c);const l=t.getAttribute("data-expiration");return l&&(n.expiration=parseInt(l,10)),n}();return $({...t,...n})}let D=null;function T(){return D||(D=N()),D}const O="zest_consent";let q=null;function L(t){const n=r();n?.set?n.set.call(document,t):document.cookie=t}function M(){const t=r();return t?.get?t.get.call(document):document.cookie}function I(){try{const t=M().match(RegExp(O+"=([^;]+)"));if(t){const n=JSON.parse(decodeURIComponent(t[1]));return q=n.categories||{essential:!0,functional:!1,analytics:!1,marketing:!1},{...q}}}catch(t){}return q={essential:!0,functional:!1,analytics:!1,marketing:!1},{...q}}function U(){return q||(q=I()),{...q}}function W(t,n=365){const e=q?{...q}:{essential:!0,functional:!1,analytics:!1,marketing:!1};return q={essential:!0,functional:!!t.functional,analytics:!!t.analytics,marketing:!!t.marketing},function(t=365){q||(q={essential:!0,functional:!1,analytics:!1,marketing:!1});const n={version:"1.0",timestamp:Date.now(),categories:q},e=new Date(Date.now()+24*t*60*60*1e3).toUTCString();L(`${O}=${encodeURIComponent(JSON.stringify(n))}; expires=${e}; path=/; SameSite=Lax`)}(n),{current:{...q},previous:e}}function Z(t){return q||(q=I()),!0===q[t]}function P(t=365){return W({functional:!1,analytics:!1,marketing:!1},t)}function Y(){try{return M().includes(O)}catch(t){return!1}}const H={READY:"zest:ready",CONSENT:"zest:consent",REJECT:"zest:reject",CHANGE:"zest:change",SHOW:"zest:show",HIDE:"zest:hide"};function B(t,n={}){const e=new CustomEvent(t,{detail:n,bubbles:!0,cancelable:!0});return document.dispatchEvent(e),e}function J(t,n){return B(H.CONSENT,{consent:t,previous:n})}function F(t){return B(H.REJECT,{consent:t})}function X(t,n){return B(H.CHANGE,{consent:t,previous:n})}function G(t="banner"){return B(H.SHOW,{type:t})}function V(t="banner"){return B(H.HIDE,{type:t})}function K(t){const n=t.accentColor||"#4F46E5";return`\n:host {\n --zest-accent: ${n};\n --zest-accent-hover: ${function(t,n){const e=parseInt(t.replace("#",""),16),o=Math.round(2.55*n);return"#"+(16777216+65536*Math.min(255,Math.max(0,(e>>16)+o))+256*Math.min(255,Math.max(0,(e>>8&255)+o))+Math.min(255,Math.max(0,(255&e)+o))).toString(16).slice(1)}(n,-15)};\n --zest-bg: #ffffff;\n --zest-bg-secondary: #f3f4f6;\n --zest-text: #1f2937;\n --zest-text-secondary: #6b7280;\n --zest-border: #e5e7eb;\n --zest-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);\n --zest-radius: 12px;\n --zest-radius-sm: 8px;\n --zest-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;\n\n font-family: var(--zest-font);\n font-size: 14px;\n line-height: 1.5;\n color: var(--zest-text);\n box-sizing: border-box;\n}\n\n:host([data-theme="dark"]) {\n --zest-bg: #1f2937;\n --zest-bg-secondary: #374151;\n --zest-text: #f9fafb;\n --zest-text-secondary: #9ca3af;\n --zest-border: #4b5563;\n --zest-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);\n}\n\n@media (prefers-color-scheme: dark) {\n :host([data-theme="auto"]) {\n --zest-bg: #1f2937;\n --zest-bg-secondary: #374151;\n --zest-text: #f9fafb;\n --zest-text-secondary: #9ca3af;\n --zest-border: #4b5563;\n --zest-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);\n }\n}\n\n*, *::before, *::after {\n box-sizing: border-box;\n}\n\n/* Banner */\n.zest-banner {\n position: fixed;\n z-index: 999999;\n max-width: 480px;\n padding: 20px;\n background: var(--zest-bg);\n border-radius: var(--zest-radius);\n box-shadow: var(--zest-shadow);\n animation: zest-slide-in 0.3s ease-out;\n}\n\n.zest-banner--bottom {\n bottom: 20px;\n left: 50%;\n transform: translateX(-50%);\n}\n\n.zest-banner--bottom-left {\n bottom: 20px;\n left: 20px;\n}\n\n.zest-banner--bottom-right {\n bottom: 20px;\n right: 20px;\n}\n\n.zest-banner--top {\n top: 20px;\n left: 50%;\n transform: translateX(-50%);\n}\n\n@keyframes zest-slide-in {\n from {\n opacity: 0;\n transform: translateX(-50%) translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateX(-50%) translateY(0);\n }\n}\n\n.zest-banner--bottom-left {\n animation-name: zest-slide-in-left;\n}\n\n@keyframes zest-slide-in-left {\n from {\n opacity: 0;\n transform: translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n.zest-banner--bottom-right {\n animation-name: zest-slide-in-right;\n}\n\n@keyframes zest-slide-in-right {\n from {\n opacity: 0;\n transform: translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .zest-banner,\n .zest-modal {\n animation: none;\n }\n}\n\n.zest-banner__title {\n margin: 0 0 8px 0;\n font-size: 16px;\n font-weight: 600;\n color: var(--zest-text);\n}\n\n.zest-banner__description {\n margin: 0 0 16px 0;\n font-size: 14px;\n color: var(--zest-text-secondary);\n}\n\n.zest-banner__buttons {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n}\n\n/* Buttons */\n.zest-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n padding: 10px 16px;\n font-size: 14px;\n font-weight: 500;\n font-family: inherit;\n border: none;\n border-radius: var(--zest-radius-sm);\n cursor: pointer;\n transition: background-color 0.15s ease, transform 0.1s ease;\n}\n\n.zest-btn:hover {\n transform: translateY(-1px);\n}\n\n.zest-btn:active {\n transform: translateY(0);\n}\n\n.zest-btn:focus-visible {\n outline: 2px solid var(--zest-accent);\n outline-offset: 2px;\n}\n\n.zest-btn--primary {\n background: var(--zest-accent);\n color: #ffffff;\n}\n\n.zest-btn--primary:hover {\n background: var(--zest-accent-hover);\n}\n\n.zest-btn--secondary {\n background: var(--zest-bg-secondary);\n color: var(--zest-text);\n}\n\n.zest-btn--secondary:hover {\n background: var(--zest-border);\n}\n\n.zest-btn--ghost {\n background: transparent;\n color: var(--zest-text-secondary);\n}\n\n.zest-btn--ghost:hover {\n background: var(--zest-bg-secondary);\n color: var(--zest-text);\n}\n\n/* Modal */\n.zest-modal-overlay {\n position: fixed;\n inset: 0;\n z-index: 999998;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px;\n background: rgba(0, 0, 0, 0.5);\n animation: zest-fade-in 0.2s ease-out;\n}\n\n@keyframes zest-fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n\n.zest-modal {\n width: 100%;\n max-width: 500px;\n max-height: 90vh;\n overflow-y: auto;\n background: var(--zest-bg);\n border-radius: var(--zest-radius);\n box-shadow: var(--zest-shadow);\n animation: zest-modal-in 0.3s ease-out;\n}\n\n@keyframes zest-modal-in {\n from {\n opacity: 0;\n transform: scale(0.95);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n\n.zest-modal__header {\n padding: 20px 20px 0;\n}\n\n.zest-modal__title {\n margin: 0 0 8px 0;\n font-size: 18px;\n font-weight: 600;\n color: var(--zest-text);\n}\n\n.zest-modal__description {\n margin: 0;\n font-size: 14px;\n color: var(--zest-text-secondary);\n}\n\n.zest-modal__body {\n padding: 20px;\n}\n\n.zest-modal__footer {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n padding: 0 20px 20px;\n}\n\n/* Categories */\n.zest-category {\n padding: 16px;\n margin-bottom: 12px;\n background: var(--zest-bg-secondary);\n border-radius: var(--zest-radius-sm);\n}\n\n.zest-category:last-child {\n margin-bottom: 0;\n}\n\n.zest-category__header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n}\n\n.zest-category__info {\n flex: 1;\n}\n\n.zest-category__label {\n display: block;\n font-size: 14px;\n font-weight: 600;\n color: var(--zest-text);\n}\n\n.zest-category__description {\n margin: 4px 0 0;\n font-size: 13px;\n color: var(--zest-text-secondary);\n}\n\n/* Toggle Switch */\n.zest-toggle {\n position: relative;\n width: 44px;\n height: 24px;\n flex-shrink: 0;\n}\n\n.zest-toggle__input {\n position: absolute;\n opacity: 0;\n width: 100%;\n height: 100%;\n cursor: pointer;\n margin: 0;\n}\n\n.zest-toggle__input:disabled {\n cursor: not-allowed;\n}\n\n.zest-toggle__slider {\n position: absolute;\n inset: 0;\n background: var(--zest-border);\n border-radius: 12px;\n transition: background-color 0.2s ease;\n pointer-events: none;\n}\n\n.zest-toggle__slider::before {\n content: '';\n position: absolute;\n top: 2px;\n left: 2px;\n width: 20px;\n height: 20px;\n background: #ffffff;\n border-radius: 50%;\n transition: transform 0.2s ease;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);\n}\n\n.zest-toggle__input:checked + .zest-toggle__slider {\n background: var(--zest-accent);\n}\n\n.zest-toggle__input:checked + .zest-toggle__slider::before {\n transform: translateX(20px);\n}\n\n.zest-toggle__input:focus-visible + .zest-toggle__slider {\n outline: 2px solid var(--zest-accent);\n outline-offset: 2px;\n}\n\n.zest-toggle__input:disabled + .zest-toggle__slider {\n opacity: 0.6;\n}\n\n/* Widget */\n.zest-widget {\n position: fixed;\n z-index: 999997;\n bottom: 20px;\n left: 20px;\n}\n\n.zest-widget__btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 48px;\n height: 48px;\n padding: 0;\n background: var(--zest-bg);\n border: 1px solid var(--zest-border);\n border-radius: 50%;\n box-shadow: var(--zest-shadow);\n cursor: pointer;\n transition: transform 0.2s ease, box-shadow 0.2s ease;\n}\n\n.zest-widget__btn:hover {\n transform: scale(1.05);\n box-shadow: 0 12px 28px -5px rgba(0, 0, 0, 0.15);\n}\n\n.zest-widget__btn:focus-visible {\n outline: 2px solid var(--zest-accent);\n outline-offset: 2px;\n}\n\n.zest-widget__icon {\n width: 24px;\n height: 24px;\n fill: var(--zest-text);\n}\n\n/* Link */\n.zest-link {\n color: var(--zest-accent);\n text-decoration: none;\n}\n\n.zest-link:hover {\n text-decoration: underline;\n}\n\n/* Mobile */\n@media (max-width: 480px) {\n .zest-banner {\n left: 10px;\n right: 10px;\n max-width: none;\n transform: none;\n }\n\n .zest-banner--bottom,\n .zest-banner--bottom-left,\n .zest-banner--bottom-right {\n bottom: 10px;\n }\n\n .zest-banner--top {\n top: 10px;\n transform: none;\n }\n\n @keyframes zest-slide-in {\n from {\n opacity: 0;\n transform: translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n\n .zest-banner__buttons {\n flex-direction: column;\n }\n\n .zest-btn {\n width: 100%;\n }\n\n .zest-modal-overlay {\n padding: 10px;\n }\n\n .zest-widget {\n bottom: 10px;\n left: 10px;\n }\n}\n\n/* Hidden utility */\n.zest-hidden {\n display: none !important;\n}\n${t.customStyles||""}\n`}let Q=null,tt=null;function nt(t={}){Q?Q.classList.remove("zest-hidden"):function(t={}){if(Q)return Q;const n=T();Q=document.createElement("zest-banner"),Q.setAttribute("data-theme",n.theme||"light"),tt=Q.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=K(n),tt.appendChild(e);const o=document.createElement("div");o.innerHTML=function(t){const n=t.labels.banner;return`\n <div class="zest-banner zest-banner--${t.position||"bottom"}" role="dialog" aria-modal="false" aria-label="${n.title}">\n <h2 class="zest-banner__title">${n.title}</h2>\n <p class="zest-banner__description">${n.description}</p>\n <div class="zest-banner__buttons">\n <button type="button" class="zest-btn zest-btn--primary" data-action="accept-all">\n ${n.acceptAll}\n </button>\n <button type="button" class="zest-btn zest-btn--secondary" data-action="reject-all">\n ${n.rejectAll}\n </button>\n <button type="button" class="zest-btn zest-btn--ghost" data-action="settings">\n ${n.settings}\n </button>\n </div>\n </div>\n `}(n),tt.appendChild(o.firstElementChild);const a=tt.querySelector(".zest-banner");a.addEventListener("click",n=>{const e=n.target.dataset.action;if(e)switch(e){case"accept-all":t.onAcceptAll?.();break;case"reject-all":t.onRejectAll?.();break;case"settings":t.onSettings?.()}}),a.addEventListener("keydown",n=>{"Escape"===n.key&&t.onSettings?.()}),document.body.appendChild(Q),requestAnimationFrame(()=>{const t=tt.querySelector("button");t?.focus()})}(t)}function et(){Q&&(Q.remove(),Q=null,tt=null)}let ot=null,at=null,st={};function rt(){if(!at)return st;const t=at.querySelectorAll(".zest-toggle__input"),n={essential:!0};return t.forEach(t=>{const e=t.dataset.category;e&&"essential"!==e&&(n[e]=t.checked)}),n}function it(t={},n={}){if(ot)return ot;const e=T();st={...t},ot=document.createElement("zest-modal"),ot.setAttribute("data-theme",e.theme||"light"),at=ot.attachShadow({mode:"open"});const o=document.createElement("style");o.textContent=K(e),at.appendChild(o);const a=document.createElement("div");a.innerHTML=function(t,n){const e=t.labels.modal,o=Object.values(t.categories||S).map(t=>{return`\n <div class="zest-category">\n <div class="zest-category__header">\n <div class="zest-category__info">\n <span class="zest-category__label">${(e=t).label}</span>\n <p class="zest-category__description">${e.description}</p>\n </div>\n <label class="zest-toggle">\n <input\n type="checkbox"\n class="zest-toggle__input"\n data-category="${e.id}"\n ${n[t.id]??t.default?"checked":""}\n ${t.required?"disabled":""}\n aria-label="${e.label}"\n >\n <span class="zest-toggle__slider"></span>\n </label>\n </div>\n </div>\n `;var e}).join("");return`\n <div class="zest-modal-overlay" role="dialog" aria-modal="true" aria-label="${e.title}">\n <div class="zest-modal">\n <div class="zest-modal__header">\n <h2 class="zest-modal__title">${e.title}</h2>\n <p class="zest-modal__description">${e.description} ${t.policyUrl?`<a href="${t.policyUrl}" class="zest-link" target="_blank" rel="noopener">Privacy Policy</a>`:""}</p>\n </div>\n <div class="zest-modal__body">\n ${o}\n </div>\n <div class="zest-modal__footer">\n <button type="button" class="zest-btn zest-btn--primary" data-action="save">\n ${e.save}\n </button>\n <button type="button" class="zest-btn zest-btn--secondary" data-action="accept-all">\n ${e.acceptAll}\n </button>\n <button type="button" class="zest-btn zest-btn--ghost" data-action="reject-all">\n ${e.rejectAll}\n </button>\n </div>\n </div>\n </div>\n `}(e,t),at.appendChild(a.firstElementChild);const s=at.querySelector(".zest-modal-overlay");return s.addEventListener("click",t=>{const e=t.target.dataset.action;if(e)switch(e){case"save":n.onSave?.(rt());break;case"accept-all":n.onAcceptAll?.();break;case"reject-all":n.onRejectAll?.()}else t.target===s&&n.onClose?.()}),s.addEventListener("keydown",t=>{"Escape"===t.key&&n.onClose?.()}),at.querySelectorAll(".zest-toggle__input").forEach(t=>{t.addEventListener("change",()=>{st=rt()})}),document.body.appendChild(ot),requestAnimationFrame(()=>{const t=at.querySelector("button");t?.focus()}),ot}function ct(){ot&&(ot.remove(),ot=null,at=null)}let lt=null,dt=null;function ut(t={}){lt?lt.style.display="":function(t={}){if(lt)return lt;const n=T();lt=document.createElement("zest-widget"),lt.setAttribute("data-theme",n.theme||"light"),dt=lt.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=K(n),dt.appendChild(e);const o=document.createElement("div");o.innerHTML=function(t){const n=t.labels.widget;return`\n <div class="zest-widget">\n <button type="button" class="zest-widget__btn" aria-label="${n.label}" title="${n.label}">\n <span class="zest-widget__icon"><svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10c0-.728-.078-1.437-.225-2.12a1 1 0 0 0-1.482-.63 3 3 0 0 1-4.086-3.72 1 1 0 0 0-.793-1.263A10.05 10.05 0 0 0 12 2zm0 2c.178 0 .354.006.528.017a5 5 0 0 0 5.955 5.955c.011.174.017.35.017.528 0 4.418-3.582 8-8 8s-8-3.582-8-8 3.582-8 8-8zm-4 6a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm5 0a1 1 0 1 0 0 2 1 1 0 0 0 0-2zm-2 4a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3z"/></svg></span>\n </button>\n </div>\n `}(n),dt.appendChild(o.firstElementChild),dt.querySelector(".zest-widget__btn").addEventListener("click",()=>{t.onClick?.()}),document.body.appendChild(lt)}(t)}function pt(){lt&&(lt.style.display="none")}let mt=!1,gt=null;function ft(t){return Z(t)}function bt(t){!function(t){const n=[];for(const e of a)t.includes(e.category)?o?.set&&o.set.call(document,e.value):n.push(e);a.length=0,a.push(...n)}(t),function(t){const n=[];for(const e of l)t.includes(e.category)?i?.setItem(e.key,e.value):n.push(e);l.length=0,l.push(...n);const e=[];for(const n of d)t.includes(n.category)?c?.setItem(n.key,n.value):e.push(n);d.length=0,d.push(...e)}(t),function(t){const n=[];for(const e of y)t.includes(e.category)?_(e):n.push(e);y.length=0,y.push(...n),document.querySelectorAll('script[data-zest-processed="blocked"]').forEach(n=>{const e=n.getAttribute("data-consent-category");if(t.includes(e)){const t=document.createElement("script"),e=n.getAttribute("data-blocked-src");e?t.src=e:t.textContent=n.textContent,n.async&&(t.async=!0),n.defer&&(t.defer=!0),t.setAttribute("data-zest-processed","executed"),t.setAttribute("data-consent-executed","true"),n.parentNode?.replaceChild(t,n)}})}(t)}function yt(){const t=function(t=365){return W({functional:!0,analytics:!0,marketing:!0},t)}(gt.expiration),n=Object.keys(S);et(),ct(),bt(n),gt.showWidget&&ut({onClick:xt}),J(t.current,t.previous),X(t.current,t.previous),gt.callbacks?.onAccept?.(t.current),gt.callbacks?.onChange?.(t.current)}function zt(){const t=P(gt.expiration);et(),ct(),gt.showWidget&&ut({onClick:xt}),F(t.current),X(t.current,t.previous),gt.callbacks?.onReject?.(),gt.callbacks?.onChange?.(t.current)}function ht(t){const n=W(t,gt.expiration),e=Object.keys(n.current).filter(t=>n.current[t]&&!n.previous[t]);e.length>0&&bt(e),ct(),gt.showWidget&&ut({onClick:xt});Object.entries(t).some(([t,n])=>"essential"!==t&&n)?J(n.current,n.previous):F(n.current),X(n.current,n.previous),gt.callbacks?.onChange?.(n.current)}function xt(){et(),pt(),it(U(),{onSave:ht,onAcceptAll:yt,onRejectAll:zt,onClose:wt}),G("modal")}function wt(){ct(),V("modal"),Y()&>.showWidget?ut({onClick:xt}):nt({onAcceptAll:yt,onRejectAll:zt,onSettings:xt})}function vt(r={}){if(mt)return console.warn("[Zest] Already initialized"),kt;gt=function(t){return D=$(t),D}(r),gt.patterns&&function(e){n={...t};for(const[t,o]of Object.entries(e))Array.isArray(o)&&(n[t]=o.map(t=>t instanceof RegExp?t:RegExp(t)))}(gt.patterns),s=ft,function(t){u=t}(ft),function(t){w=t}(ft),o=Object.getOwnPropertyDescriptor(Document.prototype,"cookie"),o?Object.defineProperty(document,"cookie",{get:()=>o.get.call(document),set(t){const n=function(t){const n=t.match(/^([^=]+)/);return n?n[1].trim():null}(t);if(!n)return;const r=e(n);s(r)?o.set.call(document,t):a.push({value:t,name:n,category:r,timestamp:Date.now()})},configurable:!0}):console.warn("[Zest] Could not get cookie descriptor"),function(){try{return i=window.localStorage,c=window.sessionStorage,Object.defineProperty(window,"localStorage",{value:p(i,l),configurable:!0,writable:!1}),Object.defineProperty(window,"sessionStorage",{value:p(c,d),configurable:!0,writable:!1}),!0}catch(t){return console.warn("[Zest] Could not intercept storage APIs:",t),!1}}(),C(gt.mode,gt.blockedDomains);const m=I();mt=!0;let g=!1;if(E()&>.respectDNT&&"ignore"!==gt.dntBehavior&&"reject"===gt.dntBehavior&&!Y()){const t=P(gt.expiration);g=!0,F(t.current),X(t.current,t.previous),gt.callbacks?.onReject?.(),gt.callbacks?.onChange?.(t.current)}return function(t){B(H.READY,{consent:t})}(m),gt.callbacks?.onReady?.(m),Y()||g?gt.showWidget&&ut({onClick:xt}):(nt({onAcceptAll:yt,onRejectAll:zt,onSettings:xt}),G("banner")),kt}const kt={init:vt,show(){mt?(ct(),pt(),nt({onAcceptAll:yt,onRejectAll:zt,onSettings:xt}),G("banner")):console.warn("[Zest] Not initialized. Call Zest.init() first.")},hide(){et(),V("banner")},showSettings(){mt?xt():console.warn("[Zest] Not initialized. Call Zest.init() first.")},hideSettings(){ct(),V("modal")},getConsent:U,hasConsent:Z,hasConsentDecision:Y,getConsentProof:function(){try{const t=M().match(RegExp(O+"=([^;]+)"));if(t)return JSON.parse(decodeURIComponent(t[1]))}catch(t){}return null},isDoNotTrackEnabled:E,getDNTDetails:function(){if("undefined"==typeof navigator)return{enabled:!1,source:null};const t=navigator.doNotTrack||window.doNotTrack||navigator.msDoNotTrack;return"1"===t||"yes"===t||!0===t?{enabled:!0,source:"dnt"}:!0===navigator.globalPrivacyControl?{enabled:!0,source:"gpc"}:{enabled:!1,source:null}},acceptAll(){mt?yt():console.warn("[Zest] Not initialized. Call Zest.init() first.")},rejectAll(){mt?zt():console.warn("[Zest] Not initialized. Call Zest.init() first.")},reset(){L(O+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/"),q=null,ct(),lt&&(lt.remove(),lt=null,dt=null),mt&&(nt({onAcceptAll:yt,onRejectAll:zt,onSettings:xt}),G("banner"))},getConfig:T,EVENTS:H};if("undefined"!=typeof window){window.Zest=kt;const t=()=>{!1!==N().autoInit&&vt(window.ZestConfig)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t):t()}return kt}();
|
|
1
|
+
var Zest=function(){"use strict";const t={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"};function n(n){if(null==n)return"";return("string"==typeof n?n:n+"").replace(/[&<>"'`]/g,n=>t[n])}const e=new Set(["transparent","black","white","red","green","blue","yellow","orange","purple","pink","gray","grey","brown","cyan","magenta","silver","gold","navy","teal","maroon","olive","lime","aqua","fuchsia","indigo","violet","crimson","coral","salmon","tomato"]);const o=[/(\([^)]*[+*][^)]*\)|\[[^\]]*\]|\\w|\\d|\\s)\s*[+*]/,/\(\?[=!][^)]*[+*][^)]*\)[+*]/];function a(t,n){if(t instanceof RegExp)return t;if("string"!=typeof t)return null;if(t.length>500)return null;for(const n of o)if(n.test(t))return null;try{return RegExp(t,n)}catch(t){return null}}const s=new Set(["__proto__","constructor","prototype"]);function r(t,n){if(!t||"object"!=typeof t||Array.isArray(t))return null;const e={version:"string"==typeof t.version?t.version:null,timestamp:"number"==typeof t.timestamp&&Number.isFinite(t.timestamp)?t.timestamp:null,categories:{}},o=t.categories;if(!o||"object"!=typeof o||Array.isArray(o))return null;for(const t of n)s.has(t)||Object.prototype.hasOwnProperty.call(o,t)&&(e.categories[t]=!0===o[t]);return n.includes("essential")&&(e.categories.essential=!0),e}function i(t,...n){if("function"==typeof t)try{return t(...n)}catch(t){try{console.error("[Zest] User callback threw:",t)}catch(t){}return}}const c={essential:[/^zest_/,/^csrf/i,/^xsrf/i,/^session/i,/^__host-/i,/^__secure-/i],functional:[/^lang/i,/^locale/i,/^theme/i,/^preferences/i,/^ui_/i],analytics:[/^_ga/,/^_gid/,/^_gat/,/^_utm/,/^__utm/,/^plausible/i,/^_pk_/,/^matomo/i,/^_hj/,/^ajs_/],marketing:[/^_fbp/,/^_fbc/,/^_gcl/,/^_ttp/,/^ads/i,/^doubleclick/i,/^__gads/,/^__gpi/,/^_pin_/,/^li_/]};let l={...c};function d(t){for(const[n,e]of Object.entries(l))if(e.some(n=>n.test(t)))return n;return"marketing"}let u=null;const p=[];let f=()=>!1;function g(){return u}let m=null,b=null;const h=[],y=[];let z=()=>!1;function w(t,n,e){return new Proxy(t,{get(t,e){if("setItem"===e)return(e,o)=>{const a=d(e);z(a)?t.setItem(e,o):200>n.length&&n.push({key:e,value:o,category:a,timestamp:Date.now()})};const o=t[e];return"function"==typeof o?o.bind(t):o}})}const x={analytics:["google-analytics.com","www.google-analytics.com","analytics.google.com","googletagmanager.com","www.googletagmanager.com","plausible.io","cloudflareinsights.com","static.cloudflareinsights.com"],marketing:["connect.facebook.net","www.facebook.com/tr","ads.google.com","www.googleadservices.com","googleads.g.doubleclick.net","pagead2.googlesyndication.com"]},v={analytics:[...x.analytics,"analytics.tiktok.com","matomo.","hotjar.com","static.hotjar.com","script.hotjar.com","clarity.ms","www.clarity.ms","heapanalytics.com","cdn.heapanalytics.com","mixpanel.com","cdn.mxpnl.com","segment.com","cdn.segment.com","api.segment.io","fullstory.com","rs.fullstory.com","amplitude.com","cdn.amplitude.com","mouseflow.com","cdn.mouseflow.com","luckyorange.com","cdn.luckyorange.net","crazyegg.com","script.crazyegg.com"],marketing:[...x.marketing,"snap.licdn.com","px.ads.linkedin.com","ads.linkedin.com","analytics.twitter.com","static.ads-twitter.com","t.co","analytics.tiktok.com","ads.tiktok.com","sc-static.net","tr.snapchat.com","ct.pinterest.com","pintrk.com","s.pinimg.com","widgets.pinterest.com","bat.bing.com","ads.yahoo.com","sp.analytics.yahoo.com","amazon-adsystem.com","z-na.amazon-adsystem.com","criteo.com","static.criteo.net","dis.criteo.com","taboola.com","cdn.taboola.com","trc.taboola.com","outbrain.com","widgets.outbrain.com","adroll.com","s.adroll.com"],functional:["cdn.onesignal.com","onesignal.com","pusher.com","js.pusher.com","intercom.io","widget.intercom.io","js.intercomcdn.com","crisp.chat","client.crisp.chat","cdn.livechatinc.com","livechatinc.com","tawk.to","embed.tawk.to","zendesk.com","static.zdassets.com"]};function k(t,n){let e;try{e=new URL(t)}catch(t){return!1}const o=e.hostname.toLowerCase(),a=e.pathname.toLowerCase();for(const t of n){if("string"!=typeof t)continue;const n=t.toLowerCase();if(n.endsWith(".")){const t=n.slice(0,-1);if(o.split(".").some(n=>n===t)||o.startsWith(n))return!0;continue}const e=n.indexOf("/");if(-1!==e){const t=n.slice(0,e),s=n.slice(e);if((o===t||o.endsWith("."+t))&&a.startsWith(s))return!0;continue}if(o===n||o.endsWith("."+n))return!0}return!1}function _(t,n="safe"){const e="strict"===n?v:x;for(const[n,o]of Object.entries(e))if(k(t,o))return n;return null}const A=new Set(["functional","analytics","marketing"]),C=[];let S=null,j="safe",E=[],$=()=>!1;function L(t){if(t.hasAttribute("data-zest-allow"))return null;const n=t.getAttribute("data-consent-category"),e=n&&A.has(n)?n:null,o=t.src;if(!o)return e;const a=function(t){if(!t||0===E.length)return null;try{const n=new URL(t).hostname.toLowerCase();for(const t of E){const e="string"==typeof t?t:t.domain,o="string"==typeof t?"marketing":t.category||"marketing";if(n===e||n.endsWith("."+e))return o}}catch(t){}return null}(o);let s=null;switch(j){case"manual":break;case"safe":case"strict":s=_(o,j);break;case"doomsday":(function(t){try{const n=new URL(t).hostname,e=window.location.hostname,o=t=>t.replace(/^www\./,"");return o(n)!==o(e)}catch(t){return!1}})(o)&&(s=_(o,"strict")||"marketing")}return s||a||e}function R(t){if(t.hasAttribute("data-zest-processed"))return!1;const n=L(t);if(!n)return t.setAttribute("data-zest-processed","allowed"),!1;if($(n))return t.setAttribute("data-zest-processed","allowed"),!1;const e={category:n,src:t.src||"",inline:t.textContent,type:t.type,async:t.async,defer:t.defer,element:t,timestamp:Date.now()};return t.setAttribute("data-zest-processed","blocked"),t.setAttribute("data-consent-category",n),t.type="text/plain",t.src&&t.removeAttribute("src"),500>C.length&&C.push(e),!0}function M(t){for(const n of t)for(const t of n.addedNodes)if("SCRIPT"!==t.nodeName||t.hasAttribute("data-zest-processed")||R(t),t.querySelectorAll){t.querySelectorAll("script:not([data-zest-processed])").forEach(R)}}function N(t="safe",n=[]){return j=t,E=n,document.querySelectorAll("script:not([data-zest-processed])").forEach(R),S=new MutationObserver(M),S.observe(document.documentElement,{childList:!0,subtree:!0}),!0}const D={essential:{id:"essential",label:"Essential",description:"Required for the website to function properly. Cannot be disabled.",required:!0,default:!0},functional:{id:"functional",label:"Functional",description:"Enable personalized features like language preferences and themes.",required:!1,default:!1},analytics:{id:"analytics",label:"Analytics",description:"Help us understand how visitors interact with our website.",required:!1,default:!1},marketing:{id:"marketing",label:"Marketing",description:"Used to deliver relevant advertisements and track campaign performance.",required:!1,default:!1}};function O(){return Object.keys(D)}function q(){if("undefined"==typeof navigator)return!1;const t=navigator.doNotTrack||window.doNotTrack||navigator.msDoNotTrack;return"1"===t||"yes"===t||!0===t||!0===navigator.globalPrivacyControl}function T(t,n,e){const o=e?"default":"update";n.consentModeGoogle&&function(t,n){if(window.dataLayer=window.dataLayer||[],"function"==typeof window.gtag)window.gtag("consent",t,n);else{function e(){window.dataLayer.push(arguments)}e("consent",t,n)}}(o,function(t){const n=t=>t?"granted":"denied";return{ad_storage:n(t.marketing),ad_user_data:n(t.marketing),ad_personalization:n(t.marketing),analytics_storage:n(t.analytics),functionality_storage:"granted",personalization_storage:n(t.functional)}}(t)),n.consentModeMicrosoft&&function(t,n){window.uetq=window.uetq||[],window.uetq.push("consent",t,n)}(o,function(t){return{ad_storage:t.marketing?"granted":"denied"}}(t))}const W={labels:{banner:{title:"我们重视您的隐私",description:'我们使用Cookie来改善您的浏览体验、提供个性化内容并分析我们的流量。点击"全部接受"即表示您同意我们使用Cookie。',acceptAll:"全部接受",rejectAll:"全部拒绝",settings:"设置"},modal:{title:"隐私设置",description:"管理您的Cookie偏好设置。您可以在下方启用或禁用不同类型的Cookie。",save:"保存设置",acceptAll:"全部接受",rejectAll:"全部拒绝"},widget:{label:"Cookie设置"}},categories:{essential:{label:"必要",description:"网站正常运行所必需的。无法禁用。"},functional:{label:"功能性",description:"启用个性化功能,如语言偏好和主题设置。"},analytics:{label:"分析",description:"帮助我们了解访问者如何与网站互动。"},marketing:{label:"营销",description:"用于展示相关广告并衡量营销活动效果。"}}};const I={lang:"auto",position:"bottom",theme:"auto",accentColor:"#0071e3",categories:D,labels:{banner:{title:"We value your privacy",description:'We use cookies to enhance your browsing experience, serve personalized content, and analyze our traffic. By clicking "Accept All", you consent to our use of cookies.',acceptAll:"Accept All",rejectAll:"Reject All",settings:"Settings"},modal:{title:"Privacy Settings",description:"Manage your cookie preferences. You can enable or disable different types of cookies below.",save:"Save Preferences",acceptAll:"Accept All",rejectAll:"Reject All"},widget:{label:"Cookie Settings"}},autoInit:!0,showWidget:!0,expiration:365,respectDNT:!0,dntBehavior:"reject",customStyles:"",consentModeGoogle:!1,consentModeMicrosoft:!1,mode:"safe",blockedDomains:[],policyUrl:null,imprintUrl:null,callbacks:{onAccept:null,onReject:null,onChange:null,onReady:null}};function Z(t){const n={...I};t||(t={});const e=["lang","position","theme","accentColor","autoInit","showWidget","expiration","policyUrl","imprintUrl","customStyles","mode","blockedDomains","respectDNT","dntBehavior","consentModeGoogle","consentModeMicrosoft"];for(const o of e)void 0!==t[o]&&(n[o]=t[o]);n.lang="zh";const o=W,a=o.labels||{},s=t.labels||{};n.labels={banner:{...I.labels.banner,...a.banner,...s.banner},modal:{...I.labels.modal,...a.modal,...s.modal},widget:{...I.labels.widget,...a.widget,...s.widget}};const r=o.categories||{},i=t.categories||{};n.categories={...I.categories};for(const t of Object.keys(I.categories))n.categories[t]={...I.categories[t],...r[t],...i[t]};return t.callbacks&&(n.callbacks={...I.callbacks,...t.callbacks}),t.patterns&&(n.patterns=t.patterns),n}function U(){const t="undefined"!=typeof window&&window.ZestConfig?window.ZestConfig:{},n=function(){const t=document.currentScript||document.querySelector("script[data-zest]")||document.querySelector('script[src*="zest"]');if(!t)return{};const n={},e=t.getAttribute("data-position");e&&(n.position=e);const o=t.getAttribute("data-theme");o&&(n.theme=o);const a=t.getAttribute("data-accent")||t.getAttribute("data-accent-color");a&&(n.accentColor=a);const s=t.getAttribute("data-policy-url")||t.getAttribute("data-privacy-url");s&&(n.policyUrl=s);const r=t.getAttribute("data-imprint-url");r&&(n.imprintUrl=r);const i=t.getAttribute("data-show-widget");null!==i&&(n.showWidget="false"!==i);const c=t.getAttribute("data-auto-init");null!==c&&(n.autoInit="false"!==c);const l=t.getAttribute("data-expiration");l&&(n.expiration=parseInt(l,10));const d=t.getAttribute("data-consent-mode-google");null!==d&&(n.consentModeGoogle="false"!==d);const u=t.getAttribute("data-consent-mode-microsoft");return null!==u&&(n.consentModeMicrosoft="false"!==u),n}();return Z({...t,...n})}let P=null;function Y(){return P||(P=U()),P}const H="zest_consent";function B(){try{return"undefined"!=typeof location&&"https:"===location.protocol?"; Secure":""}catch(t){return""}}let F=null;function G(t){const n=g();n?.set?n.set.call(document,t):document.cookie=t}function J(){const t=g();return t?.get?t.get.call(document):document.cookie}function X(){try{const t=J().match(RegExp(H+"=([^;]+)"));if(t){const n=r(JSON.parse(decodeURIComponent(t[1])),O());if(n&&n.categories)return F={essential:!0,functional:!1,analytics:!1,marketing:!1,...n.categories},{...F}}}catch(t){}return F={essential:!0,functional:!1,analytics:!1,marketing:!1},{...F}}function V(){return F||(F=X()),{...F}}function K(t,n=365){const e=F?{...F}:{essential:!0,functional:!1,analytics:!1,marketing:!1};return F={essential:!0,functional:!!t.functional,analytics:!!t.analytics,marketing:!!t.marketing},function(t=365){F||(F={essential:!0,functional:!1,analytics:!1,marketing:!1});const n={version:"1.0",timestamp:Date.now(),categories:F},e=new Date(Date.now()+24*t*60*60*1e3).toUTCString();G(`${H}=${encodeURIComponent(JSON.stringify(n))}; expires=${e}; path=/; SameSite=Lax${B()}`)}(n),{current:{...F},previous:e}}function Q(t){return F||(F=X()),!0===F[t]}function tt(t=365){return K({functional:!1,analytics:!1,marketing:!1},t)}function nt(){try{return J().includes(H)}catch(t){return!1}}const et={READY:"zest:ready",CONSENT:"zest:consent",REJECT:"zest:reject",CHANGE:"zest:change",SHOW:"zest:show",HIDE:"zest:hide"};function ot(t,n={}){const e=new CustomEvent(t,{detail:n,bubbles:!0,cancelable:!0});return document.dispatchEvent(e),e}function at(t,n){return ot(et.CONSENT,{consent:t,previous:n})}function st(t){return ot(et.REJECT,{consent:t})}function rt(t,n){return ot(et.CHANGE,{consent:t,previous:n})}function it(t="banner"){return ot(et.SHOW,{type:t})}function ct(t="banner"){return ot(et.HIDE,{type:t})}let lt=!1,dt=null;function ut(t){return Q(t)}function pt(t){!function(t){const n=[];for(const e of p)t.includes(e.category)?u?.set&&u.set.call(document,e.value):n.push(e);p.length=0,p.push(...n)}(t),function(t){const n=[];for(const e of h)t.includes(e.category)?m?.setItem(e.key,e.value):n.push(e);h.length=0,h.push(...n);const e=[];for(const n of y)t.includes(n.category)?b?.setItem(n.key,n.value):e.push(n);y.length=0,y.push(...e)}(t),function(t){const n=[];for(const e of C){if(!t.includes(e.category)){n.push(e);continue}const o=document.createElement("script");e.src?o.src=e.src:e.inline&&(o.textContent=e.inline),e.async&&(o.async=!0),e.defer&&(o.defer=!0),e.type&&"text/plain"!==e.type&&(o.type=e.type),o.setAttribute("data-zest-processed","executed"),o.setAttribute("data-consent-executed","true");const a=e.element;a&&a.isConnected&&a.parentNode?a.parentNode.replaceChild(o,a):document.head.appendChild(o)}C.length=0,C.push(...n)}(t)}function ft(t={}){if(lt)return{alreadyInitialized:!0,config:dt,consent:X(),hasDecision:nt(),dntApplied:!1};P=Z(t),dt=P,T({functional:!1,analytics:!1,marketing:!1},dt,!0),dt.patterns&&function(t){if(l={...c},t&&"object"==typeof t)for(const[n,e]of Object.entries(t)){if(!Array.isArray(e))continue;const t=[];for(const n of e){const e=a(n);if(e)t.push(e);else try{console.warn("[Zest] Rejected unsafe pattern:",n)}catch(t){}}l[n]=t}}(dt.patterns),f=ut,function(t){z=t}(ut),function(t){$=t}(ut),u=Object.getOwnPropertyDescriptor(Document.prototype,"cookie"),u?Object.defineProperty(document,"cookie",{get:()=>u.get.call(document),set(t){const n=function(t){const n=t.match(/^([^=]+)/);return n?n[1].trim():null}(t);if(!n)return;const e=d(n);f(e)?u.set.call(document,t):100>p.length&&p.push({value:t,name:n,category:e,timestamp:Date.now()})},configurable:!1}):console.warn("[Zest] Could not get cookie descriptor"),function(){try{return m=window.localStorage,b=window.sessionStorage,Object.defineProperty(window,"localStorage",{value:w(m,h),configurable:!0,writable:!1}),Object.defineProperty(window,"sessionStorage",{value:w(b,y),configurable:!0,writable:!1}),!0}catch(t){return console.warn("[Zest] Could not intercept storage APIs:",t),!1}}(),N(dt.mode,dt.blockedDomains);const n=X();lt=!0,nt()&&T(n,dt,!1);let e=!1;if(q()&&dt.respectDNT&&"ignore"!==dt.dntBehavior&&"reject"===dt.dntBehavior&&!nt()){const t=tt(dt.expiration);e=!0,T(t.current,dt,!1),st(t.current),rt(t.current,t.previous),i(dt.callbacks?.onReject),i(dt.callbacks?.onChange,t.current)}return function(t){ot(et.READY,{consent:t})}(n),i(dt.callbacks?.onReady,n),{alreadyInitialized:!1,config:dt,consent:n,hasDecision:nt(),dntApplied:e}}function gt(){if(!lt)return null;const t=function(t=365){return K({functional:!0,analytics:!0,marketing:!0},t)}(dt.expiration);return T(t.current,dt,!1),pt(O()),at(t.current,t.previous),rt(t.current,t.previous),i(dt.callbacks?.onAccept,t.current),i(dt.callbacks?.onChange,t.current),t}function mt(){G(`${H}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; SameSite=Lax${B()}`),F=null}function bt(){return lt}function ht(){return dt}const yt="#4F46E5";function zt(t){const n=function(t){if("string"!=typeof t)return null;const n=t.trim();return/^#[0-9a-fA-F]{3,8}$/.test(n)||e.has(n.toLowerCase())||/^(rgb|rgba|hsl|hsla)\(\s*[\d.,%\s/]+\s*\)$/i.test(n)?n:null}(t.accentColor)||yt,o=function(t){if("string"!=typeof t||0===t.length)return"";if(t.length>2e4)return"";let n=t.replace(/\/\*[\s\S]*?\*\//g,"");return n=n.replace(/@import\s+[^;]+;?/gi,""),n=n.replace(/@charset\s+[^;]+;?/gi,""),n=n.replace(/url\(\s*(['"]?)([^)'"]+)\1\s*\)/gi,(t,n,e)=>{const o=e.trim().toLowerCase();return o.startsWith("https:")||o.startsWith("data:image/")||o.startsWith("/")||o.startsWith("#")?t:"url(#)"}),n=n.replace(/\.zest-btn--secondary\s*\{[^}]*\}/gi,""),n=n.replace(/\[data-action\s*=\s*["']reject-all["']\]\s*\{[^}]*\}/gi,""),n=n.replace(/\[data-action\s*=\s*["']accept-all["']\]\s*\{[^}]*\}/gi,""),n=n.replace(/expression\s*\([^)]*\)/gi,""),n=n.replace(/-moz-binding\s*:[^;}]*/gi,""),n}(t.customStyles);return`\n:host {\n --zest-accent: ${n};\n --zest-accent-hover: ${function(t,n){"string"==typeof t&&/^#[0-9a-fA-F]{3,8}$/.test(t.trim())||(t=yt);let e=t.trim().replace("#","");3===e.length&&(e=e.split("").map(t=>t+t).join(""));8===e.length&&(e=e.slice(0,6));6!==e.length&&(e="4F46E5");const o=parseInt(e,16),a=Math.round(2.55*n);return"#"+(16777216+65536*Math.min(255,Math.max(0,(o>>16)+a))+256*Math.min(255,Math.max(0,(o>>8&255)+a))+Math.min(255,Math.max(0,(255&o)+a))).toString(16).slice(1)}(n,-15)};\n --zest-bg: #ffffff;\n --zest-bg-secondary: #f3f4f6;\n --zest-text: #1f2937;\n --zest-text-secondary: #6b7280;\n --zest-border: #e5e7eb;\n --zest-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);\n --zest-radius: 12px;\n --zest-radius-sm: 8px;\n --zest-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;\n\n font-family: var(--zest-font);\n font-size: 14px;\n line-height: 1.5;\n color: var(--zest-text);\n box-sizing: border-box;\n}\n\n:host([data-theme="dark"]) {\n --zest-bg: #1f2937;\n --zest-bg-secondary: #374151;\n --zest-text: #f9fafb;\n --zest-text-secondary: #9ca3af;\n --zest-border: #4b5563;\n --zest-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);\n}\n\n@media (prefers-color-scheme: dark) {\n :host([data-theme="auto"]) {\n --zest-bg: #1f2937;\n --zest-bg-secondary: #374151;\n --zest-text: #f9fafb;\n --zest-text-secondary: #9ca3af;\n --zest-border: #4b5563;\n --zest-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);\n }\n}\n\n*, *::before, *::after {\n box-sizing: border-box;\n}\n\n/* Banner */\n.zest-banner {\n position: fixed;\n z-index: 999999;\n max-width: 480px;\n padding: 20px;\n background: var(--zest-bg);\n border-radius: var(--zest-radius);\n box-shadow: var(--zest-shadow);\n animation: zest-slide-in 0.3s ease-out;\n}\n\n.zest-banner--bottom {\n bottom: 20px;\n left: 50%;\n transform: translateX(-50%);\n}\n\n.zest-banner--bottom-left {\n bottom: 20px;\n left: 20px;\n}\n\n.zest-banner--bottom-right {\n bottom: 20px;\n right: 20px;\n}\n\n.zest-banner--top {\n top: 20px;\n left: 50%;\n transform: translateX(-50%);\n}\n\n@keyframes zest-slide-in {\n from {\n opacity: 0;\n transform: translateX(-50%) translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateX(-50%) translateY(0);\n }\n}\n\n.zest-banner--bottom-left {\n animation-name: zest-slide-in-left;\n}\n\n@keyframes zest-slide-in-left {\n from {\n opacity: 0;\n transform: translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n.zest-banner--bottom-right {\n animation-name: zest-slide-in-right;\n}\n\n@keyframes zest-slide-in-right {\n from {\n opacity: 0;\n transform: translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .zest-banner,\n .zest-modal {\n animation: none;\n }\n}\n\n.zest-banner__title {\n margin: 0 0 8px 0;\n font-size: 16px;\n font-weight: 600;\n color: var(--zest-text);\n}\n\n.zest-banner__description {\n margin: 0 0 16px 0;\n font-size: 14px;\n color: var(--zest-text-secondary);\n}\n\n.zest-banner__buttons {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n}\n\n/* Buttons */\n.zest-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n padding: 10px 16px;\n font-size: 14px;\n font-weight: 500;\n font-family: inherit;\n border: none;\n border-radius: var(--zest-radius-sm);\n cursor: pointer;\n transition: background-color 0.15s ease, transform 0.1s ease;\n}\n\n.zest-btn:hover {\n transform: translateY(-1px);\n}\n\n.zest-btn:active {\n transform: translateY(0);\n}\n\n.zest-btn:focus-visible {\n outline: 2px solid var(--zest-accent);\n outline-offset: 2px;\n}\n\n.zest-btn--primary {\n background: var(--zest-accent);\n color: #ffffff;\n}\n\n.zest-btn--primary:hover {\n background: var(--zest-accent-hover);\n}\n\n.zest-btn--secondary {\n background: var(--zest-bg-secondary);\n color: var(--zest-text);\n}\n\n.zest-btn--secondary:hover {\n background: var(--zest-border);\n}\n\n.zest-btn--ghost {\n background: transparent;\n color: var(--zest-text-secondary);\n}\n\n.zest-btn--ghost:hover {\n background: var(--zest-bg-secondary);\n color: var(--zest-text);\n}\n\n/* Modal */\n.zest-modal-overlay {\n position: fixed;\n inset: 0;\n z-index: 999998;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px;\n background: rgba(0, 0, 0, 0.5);\n animation: zest-fade-in 0.2s ease-out;\n}\n\n@keyframes zest-fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n\n.zest-modal {\n width: 100%;\n max-width: 500px;\n max-height: 90vh;\n overflow-y: auto;\n background: var(--zest-bg);\n border-radius: var(--zest-radius);\n box-shadow: var(--zest-shadow);\n animation: zest-modal-in 0.3s ease-out;\n}\n\n@keyframes zest-modal-in {\n from {\n opacity: 0;\n transform: scale(0.95);\n }\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n\n.zest-modal__header {\n padding: 20px 20px 0;\n}\n\n.zest-modal__title {\n margin: 0 0 8px 0;\n font-size: 18px;\n font-weight: 600;\n color: var(--zest-text);\n}\n\n.zest-modal__description {\n margin: 0;\n font-size: 14px;\n color: var(--zest-text-secondary);\n}\n\n.zest-modal__body {\n padding: 20px;\n}\n\n.zest-modal__footer {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n padding: 0 20px 20px;\n}\n\n/* Categories */\n.zest-category {\n padding: 16px;\n margin-bottom: 12px;\n background: var(--zest-bg-secondary);\n border-radius: var(--zest-radius-sm);\n}\n\n.zest-category:last-child {\n margin-bottom: 0;\n}\n\n.zest-category__header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n}\n\n.zest-category__info {\n flex: 1;\n}\n\n.zest-category__label {\n display: block;\n font-size: 14px;\n font-weight: 600;\n color: var(--zest-text);\n}\n\n.zest-category__description {\n margin: 4px 0 0;\n font-size: 13px;\n color: var(--zest-text-secondary);\n}\n\n/* Toggle Switch */\n.zest-toggle {\n position: relative;\n width: 44px;\n height: 24px;\n flex-shrink: 0;\n}\n\n.zest-toggle__input {\n position: absolute;\n opacity: 0;\n width: 100%;\n height: 100%;\n cursor: pointer;\n margin: 0;\n}\n\n.zest-toggle__input:disabled {\n cursor: not-allowed;\n}\n\n.zest-toggle__slider {\n position: absolute;\n inset: 0;\n background: var(--zest-border);\n border-radius: 12px;\n transition: background-color 0.2s ease;\n pointer-events: none;\n}\n\n.zest-toggle__slider::before {\n content: '';\n position: absolute;\n top: 2px;\n left: 2px;\n width: 20px;\n height: 20px;\n background: #ffffff;\n border-radius: 50%;\n transition: transform 0.2s ease;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);\n}\n\n.zest-toggle__input:checked + .zest-toggle__slider {\n background: var(--zest-accent);\n}\n\n.zest-toggle__input:checked + .zest-toggle__slider::before {\n transform: translateX(20px);\n}\n\n.zest-toggle__input:focus-visible + .zest-toggle__slider {\n outline: 2px solid var(--zest-accent);\n outline-offset: 2px;\n}\n\n.zest-toggle__input:disabled + .zest-toggle__slider {\n opacity: 0.6;\n}\n\n/* Widget */\n.zest-widget {\n position: fixed;\n z-index: 999997;\n bottom: 20px;\n left: 20px;\n}\n\n.zest-widget__btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 48px;\n height: 48px;\n padding: 0;\n background: var(--zest-bg);\n border: 1px solid var(--zest-border);\n border-radius: 50%;\n box-shadow: var(--zest-shadow);\n cursor: pointer;\n transition: transform 0.2s ease, box-shadow 0.2s ease;\n}\n\n.zest-widget__btn:hover {\n transform: scale(1.05);\n box-shadow: 0 12px 28px -5px rgba(0, 0, 0, 0.15);\n}\n\n.zest-widget__btn:focus-visible {\n outline: 2px solid var(--zest-accent);\n outline-offset: 2px;\n}\n\n.zest-widget__icon {\n width: 24px;\n height: 24px;\n fill: var(--zest-text);\n}\n\n/* Link */\n.zest-link {\n color: var(--zest-accent);\n text-decoration: none;\n}\n\n.zest-link:hover {\n text-decoration: underline;\n}\n\n/* Mobile */\n@media (max-width: 480px) {\n .zest-banner {\n left: 10px;\n right: 10px;\n max-width: none;\n transform: none;\n }\n\n .zest-banner--bottom,\n .zest-banner--bottom-left,\n .zest-banner--bottom-right {\n bottom: 10px;\n }\n\n .zest-banner--top {\n top: 10px;\n transform: none;\n }\n\n @keyframes zest-slide-in {\n from {\n opacity: 0;\n transform: translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n\n .zest-banner__buttons {\n flex-direction: column;\n }\n\n .zest-btn {\n width: 100%;\n }\n\n .zest-modal-overlay {\n padding: 10px;\n }\n\n .zest-widget {\n bottom: 10px;\n left: 10px;\n }\n}\n\n/* Hidden utility */\n.zest-hidden {\n display: none !important;\n}\n${o}\n`}let wt=null,xt=null;const vt=new Set(["bottom","bottom-left","bottom-right","top"]);function kt(t={}){if(wt)return wt;const e=Y();wt=document.createElement("zest-banner"),wt.setAttribute("data-theme",e.theme||"light"),xt=wt.attachShadow({mode:"open"});const o=document.createElement("style");o.textContent=zt(e),xt.appendChild(o);const a=document.createElement("div");a.innerHTML=function(t){const e=t.labels.banner,o=t.position||"bottom";return`\n <div class="zest-banner zest-banner--${vt.has(o)?o:"bottom"}" role="dialog" aria-modal="false" aria-label="${n(e.title)}">\n <h2 class="zest-banner__title">${n(e.title)}</h2>\n <p class="zest-banner__description">${n(e.description)}</p>\n <div class="zest-banner__buttons">\n <button type="button" class="zest-btn zest-btn--primary" data-action="accept-all">\n ${n(e.acceptAll)}\n </button>\n <button type="button" class="zest-btn zest-btn--secondary" data-action="reject-all">\n ${n(e.rejectAll)}\n </button>\n <button type="button" class="zest-btn zest-btn--ghost" data-action="settings">\n ${n(e.settings)}\n </button>\n </div>\n </div>\n `}(e),xt.appendChild(a.firstElementChild);const s=xt.querySelector(".zest-banner");return s.addEventListener("click",n=>{const e=n.target.dataset.action;if(e)switch(e){case"accept-all":t.onAcceptAll?.();break;case"reject-all":t.onRejectAll?.();break;case"settings":t.onSettings?.()}}),s.addEventListener("keydown",n=>{"Escape"===n.key&&t.onSettings?.()}),document.body.appendChild(wt),requestAnimationFrame(()=>{const t=xt.querySelector("button");t?.focus()}),wt}function _t(t={}){wt?wt.classList.remove("zest-hidden"):kt(t)}function At(){wt&&(wt.remove(),wt=null,xt=null)}let Ct=null,St=null,jt={};function Et(t,e){const o=t.labels.modal,a=Object.values(t.categories||D).map(t=>function(t,e,o){const a=o?"disabled":"",s=e?"checked":"",r=n(t.id),i=n(t.label);return`\n <div class="zest-category">\n <div class="zest-category__header">\n <div class="zest-category__info">\n <span class="zest-category__label">${i}</span>\n <p class="zest-category__description">${n(t.description)}</p>\n </div>\n <label class="zest-toggle">\n <input\n type="checkbox"\n class="zest-toggle__input"\n data-category="${r}"\n ${s}\n ${a}\n aria-label="${i}"\n >\n <span class="zest-toggle__slider"></span>\n </label>\n </div>\n </div>\n `}(t,e[t.id]??t.default,t.required)).join(""),s=t.policyUrl?function(t){if("string"!=typeof t||0===t.length)return null;const n=t.trim();if(0===n.length)return null;if(/^[/?#]/.test(n))return n;const e=n.match(/^([a-z][a-z0-9+.-]*):/i);if(!e)return n;const o=e[1].toLowerCase();return"http"===o||"https"===o||"mailto"===o||"tel"===o?n:null}(t.policyUrl):null,r=s?`<a href="${n(s)}" class="zest-link" target="_blank" rel="noopener noreferrer">Privacy Policy</a>`:"";return`\n <div class="zest-modal-overlay" role="dialog" aria-modal="true" aria-label="${n(o.title)}">\n <div class="zest-modal">\n <div class="zest-modal__header">\n <h2 class="zest-modal__title">${n(o.title)}</h2>\n <p class="zest-modal__description">${n(o.description)} ${r}</p>\n </div>\n <div class="zest-modal__body">\n ${a}\n </div>\n <div class="zest-modal__footer">\n <button type="button" class="zest-btn zest-btn--primary" data-action="save">\n ${n(o.save)}\n </button>\n <button type="button" class="zest-btn zest-btn--secondary" data-action="accept-all">\n ${n(o.acceptAll)}\n </button>\n <button type="button" class="zest-btn zest-btn--ghost" data-action="reject-all">\n ${n(o.rejectAll)}\n </button>\n </div>\n </div>\n </div>\n `}function $t(){if(!St)return jt;const t=St.querySelectorAll(".zest-toggle__input"),n={essential:!0};return t.forEach(t=>{const e=t.dataset.category;e&&"essential"!==e&&(n[e]=t.checked)}),n}function Lt(){Ct&&(Ct.remove(),Ct=null,St=null)}let Rt=null,Mt=null;function Nt(t={}){if(Rt)return Rt;const e=Y();Rt=document.createElement("zest-widget"),Rt.setAttribute("data-theme",e.theme||"light"),Mt=Rt.attachShadow({mode:"open"});const o=document.createElement("style");o.textContent=zt(e),Mt.appendChild(o);const a=document.createElement("div");a.innerHTML=function(t){const e=n(t.labels.widget.label);return`\n <div class="zest-widget">\n <button type="button" class="zest-widget__btn" aria-label="${e}" title="${e}">\n <span class="zest-widget__icon"><svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10c0-.728-.078-1.437-.225-2.12a1 1 0 0 0-1.482-.63 3 3 0 0 1-4.086-3.72 1 1 0 0 0-.793-1.263A10.05 10.05 0 0 0 12 2zm0 2c.178 0 .354.006.528.017a5 5 0 0 0 5.955 5.955c.011.174.017.35.017.528 0 4.418-3.582 8-8 8s-8-3.582-8-8 3.582-8 8-8zm-4 6a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm5 0a1 1 0 1 0 0 2 1 1 0 0 0 0-2zm-2 4a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3z"/></svg></span>\n </button>\n </div>\n `}(e),Mt.appendChild(a.firstElementChild);return Mt.querySelector(".zest-widget__btn").addEventListener("click",()=>{t.onClick?.()}),document.body.appendChild(Rt),Rt}function Dt(t={}){Rt?Rt.style.display="":Nt(t)}function Ot(){Rt&&(Rt.style.display="none")}function qt(){gt();const t=ht();At(),Lt(),t?.showWidget&&Dt({onClick:It})}function Tt(){!function(){if(!lt)return null;const t=tt(dt.expiration);T(t.current,dt,!1),st(t.current),rt(t.current,t.previous),i(dt.callbacks?.onReject),i(dt.callbacks?.onChange,t.current)}();const t=ht();At(),Lt(),t?.showWidget&&Dt({onClick:It})}function Wt(t){!function(t){if(!lt)return null;const n=K(t,dt.expiration);T(n.current,dt,!1);const e=Object.keys(n.current).filter(t=>n.current[t]&&!n.previous[t]);e.length>0&&pt(e),Object.entries(t||{}).some(([t,n])=>"essential"!==t&&n)?at(n.current,n.previous):st(n.current),rt(n.current,n.previous),i(dt.callbacks?.onChange,n.current)}(t);const n=ht();Lt(),n?.showWidget&&Dt({onClick:It})}function It(){At(),Ot(),function(t={},n={}){if(Ct)return Ct;const e=Y();jt={...t},Ct=document.createElement("zest-modal"),Ct.setAttribute("data-theme",e.theme||"light"),St=Ct.attachShadow({mode:"open"});const o=document.createElement("style");o.textContent=zt(e),St.appendChild(o);const a=document.createElement("div");a.innerHTML=Et(e,t),St.appendChild(a.firstElementChild);const s=St.querySelector(".zest-modal-overlay");s.addEventListener("click",t=>{const e=t.target.dataset.action;if(e)switch(e){case"save":n.onSave?.($t());break;case"accept-all":n.onAcceptAll?.();break;case"reject-all":n.onRejectAll?.()}else t.target===s&&n.onClose?.()}),s.addEventListener("keydown",t=>{"Escape"===t.key&&n.onClose?.()}),St.querySelectorAll(".zest-toggle__input").forEach(t=>{t.addEventListener("change",()=>{jt=$t()})}),document.body.appendChild(Ct),requestAnimationFrame(()=>{const t=St.querySelector("button");t?.focus()})}(V(),{onSave:Wt,onAcceptAll:qt,onRejectAll:Tt,onClose:Zt}),it("modal")}function Zt(){Lt(),ct("modal");const t=ht();nt()&&t?.showWidget?Dt({onClick:It}):_t({onAcceptAll:qt,onRejectAll:Tt,onSettings:It})}function Ut(t={}){const{alreadyInitialized:n,hasDecision:e,dntApplied:o}=ft(t);if(n)return console.warn("[Zest] Already initialized"),Pt;const a=ht();return e||o?a?.showWidget&&Dt({onClick:It}):(_t({onAcceptAll:qt,onRejectAll:Tt,onSettings:It}),it("banner")),Pt}const Pt={init:Ut,show(){bt()?(Lt(),Ot(),_t({onAcceptAll:qt,onRejectAll:Tt,onSettings:It}),it("banner")):console.warn("[Zest] Not initialized. Call Zest.init() first.")},hide(){At(),ct("banner")},showSettings(){bt()?It():console.warn("[Zest] Not initialized. Call Zest.init() first.")},hideSettings(){Lt(),ct("modal")},getConsent:V,hasConsent:Q,hasConsentDecision:nt,getConsentProof:function(){try{const t=J().match(RegExp(H+"=([^;]+)"));if(t){return r(JSON.parse(decodeURIComponent(t[1])),O())}}catch(t){}return null},isDoNotTrackEnabled:q,getDNTDetails:function(){if("undefined"==typeof navigator)return{enabled:!1,source:null};const t=navigator.doNotTrack||window.doNotTrack||navigator.msDoNotTrack;return"1"===t||"yes"===t||!0===t?{enabled:!0,source:"dnt"}:!0===navigator.globalPrivacyControl?{enabled:!0,source:"gpc"}:{enabled:!1,source:null}},acceptAll(){bt()?qt():console.warn("[Zest] Not initialized. Call Zest.init() first.")},rejectAll(){bt()?Tt():console.warn("[Zest] Not initialized. Call Zest.init() first.")},reset(){mt(),Lt(),Rt&&(Rt.remove(),Rt=null,Mt=null),bt()&&(_t({onAcceptAll:qt,onRejectAll:Tt,onSettings:It}),it("banner"))},getConfig:Y,on:function(t,n){return document.addEventListener(t,n),()=>document.removeEventListener(t,n)},once:function(t,n){document.addEventListener(t,n,{once:!0})},EVENTS:et};if("undefined"!=typeof window){try{Object.defineProperty(window,"Zest",{value:Object.freeze(Pt),writable:!1,configurable:!1,enumerable:!0})}catch(t){window.Zest=Pt}const t=()=>{!1!==U().autoInit&&Ut(window.ZestConfig)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t):t()}return Pt}();
|
package/package.json
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@freshjuice/zest",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Lightweight cookie consent toolkit for GDPR/CCPA compliance",
|
|
6
6
|
"main": "dist/zest.min.js",
|
|
7
7
|
"module": "dist/zest.esm.min.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/zest.esm.min.js",
|
|
11
|
+
"default": "./dist/zest.min.js"
|
|
12
|
+
},
|
|
13
|
+
"./headless": {
|
|
14
|
+
"import": "./dist/zest.headless.esm.min.js",
|
|
15
|
+
"default": "./dist/zest.headless.esm.min.js"
|
|
16
|
+
},
|
|
17
|
+
"./src/headless": "./src/headless.js",
|
|
18
|
+
"./src/*": "./src/*.js"
|
|
19
|
+
},
|
|
8
20
|
"files": [
|
|
9
21
|
"dist",
|
|
22
|
+
"src",
|
|
10
23
|
"locales",
|
|
11
24
|
"zest.config.schema.json"
|
|
12
25
|
],
|
|
@@ -56,8 +69,8 @@
|
|
|
56
69
|
"devDependencies": {
|
|
57
70
|
"@rollup/plugin-alias": "^6.0.0",
|
|
58
71
|
"@rollup/plugin-terser": "^0.4.4",
|
|
59
|
-
"eslint": "^
|
|
60
|
-
"rollup": "^4.
|
|
61
|
-
"vitest": "^4.
|
|
72
|
+
"eslint": "^10.2.1",
|
|
73
|
+
"rollup": "^4.60.2",
|
|
74
|
+
"vitest": "^4.1.5"
|
|
62
75
|
}
|
|
63
76
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public API - Exposes Zest methods to consumers
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { showBanner, hideBanner, isBannerVisible } from '../ui/banner.js';
|
|
6
|
+
import { showModal, hideModal, isModalVisible } from '../ui/modal.js';
|
|
7
|
+
import { showWidget, hideWidget, removeWidget } from '../ui/widget.js';
|
|
8
|
+
import {
|
|
9
|
+
getConsent,
|
|
10
|
+
hasConsent,
|
|
11
|
+
acceptAll,
|
|
12
|
+
rejectAll,
|
|
13
|
+
updateConsent,
|
|
14
|
+
resetConsent,
|
|
15
|
+
hasConsentDecision,
|
|
16
|
+
getConsentProof
|
|
17
|
+
} from '../storage/consent-store.js';
|
|
18
|
+
import { getCurrentConfig } from '../config/parser.js';
|
|
19
|
+
import { emitShow, emitHide } from '../storage/events.js';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Show the consent banner
|
|
23
|
+
*/
|
|
24
|
+
export function show() {
|
|
25
|
+
if (isModalVisible()) {
|
|
26
|
+
hideModal();
|
|
27
|
+
}
|
|
28
|
+
emitShow('banner');
|
|
29
|
+
// Return internal showBanner but don't expose callbacks
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Hide the consent banner
|
|
35
|
+
*/
|
|
36
|
+
export function hide() {
|
|
37
|
+
hideBanner();
|
|
38
|
+
emitHide('banner');
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Show the settings modal
|
|
44
|
+
*/
|
|
45
|
+
export function showSettings() {
|
|
46
|
+
if (isBannerVisible()) {
|
|
47
|
+
hideBanner();
|
|
48
|
+
}
|
|
49
|
+
emitShow('modal');
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Hide the settings modal
|
|
55
|
+
*/
|
|
56
|
+
export function hideSettings() {
|
|
57
|
+
hideModal();
|
|
58
|
+
emitHide('modal');
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Reset consent and show banner again
|
|
64
|
+
*/
|
|
65
|
+
export function reset() {
|
|
66
|
+
resetConsent();
|
|
67
|
+
hideModal();
|
|
68
|
+
removeWidget();
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Get complete consent state
|
|
74
|
+
*/
|
|
75
|
+
export { getConsent };
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Check if a specific category has consent
|
|
79
|
+
*/
|
|
80
|
+
export { hasConsent };
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Check if user has made any consent decision
|
|
84
|
+
*/
|
|
85
|
+
export { hasConsentDecision };
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Get consent proof for compliance
|
|
89
|
+
*/
|
|
90
|
+
export { getConsentProof };
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Get current configuration
|
|
94
|
+
*/
|
|
95
|
+
export function getConfig() {
|
|
96
|
+
return getCurrentConfig();
|
|
97
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default configuration values
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { DEFAULT_CATEGORIES } from '../core/categories.js';
|
|
6
|
+
import { detectLanguage, getTranslation } from '../i18n/translations.js';
|
|
7
|
+
|
|
8
|
+
export const DEFAULTS = {
|
|
9
|
+
// Language: 'auto' | 'en' | 'de' | 'es' | 'fr' | 'it' | 'pt' | 'nl' | 'pl' | 'uk' | 'ru' | 'ja' | 'zh'
|
|
10
|
+
lang: 'auto',
|
|
11
|
+
|
|
12
|
+
// UI positioning
|
|
13
|
+
position: 'bottom', // 'bottom' | 'bottom-left' | 'bottom-right' | 'top'
|
|
14
|
+
|
|
15
|
+
// Theming
|
|
16
|
+
theme: 'auto', // 'light' | 'dark' | 'auto'
|
|
17
|
+
accentColor: '#0071e3',
|
|
18
|
+
|
|
19
|
+
// Categories
|
|
20
|
+
categories: DEFAULT_CATEGORIES,
|
|
21
|
+
|
|
22
|
+
// UI Labels
|
|
23
|
+
labels: {
|
|
24
|
+
banner: {
|
|
25
|
+
title: 'We value your privacy',
|
|
26
|
+
description: 'We use cookies to enhance your browsing experience, serve personalized content, and analyze our traffic. By clicking "Accept All", you consent to our use of cookies.',
|
|
27
|
+
acceptAll: 'Accept All',
|
|
28
|
+
rejectAll: 'Reject All',
|
|
29
|
+
settings: 'Settings'
|
|
30
|
+
},
|
|
31
|
+
modal: {
|
|
32
|
+
title: 'Privacy Settings',
|
|
33
|
+
description: 'Manage your cookie preferences. You can enable or disable different types of cookies below.',
|
|
34
|
+
save: 'Save Preferences',
|
|
35
|
+
acceptAll: 'Accept All',
|
|
36
|
+
rejectAll: 'Reject All'
|
|
37
|
+
},
|
|
38
|
+
widget: {
|
|
39
|
+
label: 'Cookie Settings'
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
// Behavior
|
|
44
|
+
autoInit: true,
|
|
45
|
+
showWidget: true,
|
|
46
|
+
expiration: 365,
|
|
47
|
+
|
|
48
|
+
// Do Not Track / Global Privacy Control
|
|
49
|
+
// respectDNT: true = respect DNT/GPC signals
|
|
50
|
+
// dntBehavior: 'reject' | 'preselect' | 'ignore'
|
|
51
|
+
// - 'reject': auto-reject non-essential, don't show banner
|
|
52
|
+
// - 'preselect': show banner with non-essential unchecked (same as normal)
|
|
53
|
+
// - 'ignore': ignore DNT completely
|
|
54
|
+
respectDNT: true,
|
|
55
|
+
dntBehavior: 'reject',
|
|
56
|
+
|
|
57
|
+
// Custom styles to inject into Shadow DOM
|
|
58
|
+
customStyles: '',
|
|
59
|
+
|
|
60
|
+
// Vendor consent mode integrations (optional)
|
|
61
|
+
consentModeGoogle: false,
|
|
62
|
+
consentModeMicrosoft: false,
|
|
63
|
+
|
|
64
|
+
// Blocking mode: 'manual' | 'safe' | 'strict' | 'doomsday'
|
|
65
|
+
mode: 'safe',
|
|
66
|
+
|
|
67
|
+
// Custom domains to block (in addition to mode-based blocking)
|
|
68
|
+
blockedDomains: [], // days
|
|
69
|
+
|
|
70
|
+
// Links
|
|
71
|
+
policyUrl: null,
|
|
72
|
+
imprintUrl: null,
|
|
73
|
+
|
|
74
|
+
// Callbacks
|
|
75
|
+
callbacks: {
|
|
76
|
+
onAccept: null,
|
|
77
|
+
onReject: null,
|
|
78
|
+
onChange: null,
|
|
79
|
+
onReady: null
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Merge user config with defaults (deep merge)
|
|
85
|
+
*/
|
|
86
|
+
export function mergeConfig(userConfig) {
|
|
87
|
+
const config = { ...DEFAULTS };
|
|
88
|
+
|
|
89
|
+
if (!userConfig) {
|
|
90
|
+
userConfig = {};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Simple properties
|
|
94
|
+
const simpleKeys = ['lang', 'position', 'theme', 'accentColor', 'autoInit', 'showWidget', 'expiration', 'policyUrl', 'imprintUrl', 'customStyles', 'mode', 'blockedDomains', 'respectDNT', 'dntBehavior', 'consentModeGoogle', 'consentModeMicrosoft'];
|
|
95
|
+
for (const key of simpleKeys) {
|
|
96
|
+
if (userConfig[key] !== undefined) {
|
|
97
|
+
config[key] = userConfig[key];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Detect language and get translations
|
|
102
|
+
const detectedLang = detectLanguage(config.lang);
|
|
103
|
+
config.lang = detectedLang;
|
|
104
|
+
const translation = getTranslation(detectedLang);
|
|
105
|
+
|
|
106
|
+
// Deep merge labels (translation < user config)
|
|
107
|
+
const translationLabels = translation.labels || {};
|
|
108
|
+
const userLabels = userConfig.labels || {};
|
|
109
|
+
config.labels = {
|
|
110
|
+
banner: {
|
|
111
|
+
...DEFAULTS.labels.banner,
|
|
112
|
+
...translationLabels.banner,
|
|
113
|
+
...userLabels.banner
|
|
114
|
+
},
|
|
115
|
+
modal: {
|
|
116
|
+
...DEFAULTS.labels.modal,
|
|
117
|
+
...translationLabels.modal,
|
|
118
|
+
...userLabels.modal
|
|
119
|
+
},
|
|
120
|
+
widget: {
|
|
121
|
+
...DEFAULTS.labels.widget,
|
|
122
|
+
...translationLabels.widget,
|
|
123
|
+
...userLabels.widget
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// Deep merge categories (translation < user config)
|
|
128
|
+
const translationCategories = translation.categories || {};
|
|
129
|
+
const userCategories = userConfig.categories || {};
|
|
130
|
+
config.categories = { ...DEFAULTS.categories };
|
|
131
|
+
for (const key of Object.keys(DEFAULTS.categories)) {
|
|
132
|
+
config.categories[key] = {
|
|
133
|
+
...DEFAULTS.categories[key],
|
|
134
|
+
...translationCategories[key],
|
|
135
|
+
...userCategories[key]
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Merge callbacks
|
|
140
|
+
if (userConfig.callbacks) {
|
|
141
|
+
config.callbacks = { ...DEFAULTS.callbacks, ...userConfig.callbacks };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Patterns (for pattern matcher)
|
|
145
|
+
if (userConfig.patterns) {
|
|
146
|
+
config.patterns = userConfig.patterns;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return config;
|
|
150
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration Parser - Reads config from various sources
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { mergeConfig } from './defaults.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Parse data attributes from script tag
|
|
9
|
+
*/
|
|
10
|
+
function parseDataAttributes() {
|
|
11
|
+
// Find the Zest script tag
|
|
12
|
+
const script = document.currentScript ||
|
|
13
|
+
document.querySelector('script[data-zest]') ||
|
|
14
|
+
document.querySelector('script[src*="zest"]');
|
|
15
|
+
|
|
16
|
+
if (!script) {
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const config = {};
|
|
21
|
+
|
|
22
|
+
// Position
|
|
23
|
+
const position = script.getAttribute('data-position');
|
|
24
|
+
if (position) config.position = position;
|
|
25
|
+
|
|
26
|
+
// Theme
|
|
27
|
+
const theme = script.getAttribute('data-theme');
|
|
28
|
+
if (theme) config.theme = theme;
|
|
29
|
+
|
|
30
|
+
// Accent color
|
|
31
|
+
const accent = script.getAttribute('data-accent') || script.getAttribute('data-accent-color');
|
|
32
|
+
if (accent) config.accentColor = accent;
|
|
33
|
+
|
|
34
|
+
// Policy URL
|
|
35
|
+
const policyUrl = script.getAttribute('data-policy-url') || script.getAttribute('data-privacy-url');
|
|
36
|
+
if (policyUrl) config.policyUrl = policyUrl;
|
|
37
|
+
|
|
38
|
+
// Imprint URL
|
|
39
|
+
const imprintUrl = script.getAttribute('data-imprint-url');
|
|
40
|
+
if (imprintUrl) config.imprintUrl = imprintUrl;
|
|
41
|
+
|
|
42
|
+
// Show widget
|
|
43
|
+
const showWidget = script.getAttribute('data-show-widget');
|
|
44
|
+
if (showWidget !== null) config.showWidget = showWidget !== 'false';
|
|
45
|
+
|
|
46
|
+
// Auto init
|
|
47
|
+
const autoInit = script.getAttribute('data-auto-init');
|
|
48
|
+
if (autoInit !== null) config.autoInit = autoInit !== 'false';
|
|
49
|
+
|
|
50
|
+
// Expiration
|
|
51
|
+
const expiration = script.getAttribute('data-expiration');
|
|
52
|
+
if (expiration) config.expiration = parseInt(expiration, 10);
|
|
53
|
+
|
|
54
|
+
// Consent mode integrations
|
|
55
|
+
const consentModeGoogle = script.getAttribute('data-consent-mode-google');
|
|
56
|
+
if (consentModeGoogle !== null) config.consentModeGoogle = consentModeGoogle !== 'false';
|
|
57
|
+
|
|
58
|
+
const consentModeMicrosoft = script.getAttribute('data-consent-mode-microsoft');
|
|
59
|
+
if (consentModeMicrosoft !== null) config.consentModeMicrosoft = consentModeMicrosoft !== 'false';
|
|
60
|
+
|
|
61
|
+
return config;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Parse window.ZestConfig object
|
|
66
|
+
*/
|
|
67
|
+
function parseWindowConfig() {
|
|
68
|
+
if (typeof window !== 'undefined' && window.ZestConfig) {
|
|
69
|
+
return window.ZestConfig;
|
|
70
|
+
}
|
|
71
|
+
return {};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Get final merged configuration
|
|
76
|
+
* Priority: data attributes > window.ZestConfig > defaults
|
|
77
|
+
*/
|
|
78
|
+
export function getConfig() {
|
|
79
|
+
const windowConfig = parseWindowConfig();
|
|
80
|
+
const dataConfig = parseDataAttributes();
|
|
81
|
+
|
|
82
|
+
// Merge: defaults < windowConfig < dataConfig
|
|
83
|
+
return mergeConfig({
|
|
84
|
+
...windowConfig,
|
|
85
|
+
...dataConfig
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Update configuration at runtime
|
|
91
|
+
*/
|
|
92
|
+
let currentConfig = null;
|
|
93
|
+
|
|
94
|
+
export function setConfig(config) {
|
|
95
|
+
currentConfig = mergeConfig(config);
|
|
96
|
+
return currentConfig;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function getCurrentConfig() {
|
|
100
|
+
if (!currentConfig) {
|
|
101
|
+
currentConfig = getConfig();
|
|
102
|
+
}
|
|
103
|
+
return currentConfig;
|
|
104
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default consent categories
|
|
3
|
+
*/
|
|
4
|
+
export const DEFAULT_CATEGORIES = {
|
|
5
|
+
essential: {
|
|
6
|
+
id: 'essential',
|
|
7
|
+
label: 'Essential',
|
|
8
|
+
description: 'Required for the website to function properly. Cannot be disabled.',
|
|
9
|
+
required: true,
|
|
10
|
+
default: true
|
|
11
|
+
},
|
|
12
|
+
functional: {
|
|
13
|
+
id: 'functional',
|
|
14
|
+
label: 'Functional',
|
|
15
|
+
description: 'Enable personalized features like language preferences and themes.',
|
|
16
|
+
required: false,
|
|
17
|
+
default: false
|
|
18
|
+
},
|
|
19
|
+
analytics: {
|
|
20
|
+
id: 'analytics',
|
|
21
|
+
label: 'Analytics',
|
|
22
|
+
description: 'Help us understand how visitors interact with our website.',
|
|
23
|
+
required: false,
|
|
24
|
+
default: false
|
|
25
|
+
},
|
|
26
|
+
marketing: {
|
|
27
|
+
id: 'marketing',
|
|
28
|
+
label: 'Marketing',
|
|
29
|
+
description: 'Used to deliver relevant advertisements and track campaign performance.',
|
|
30
|
+
required: false,
|
|
31
|
+
default: false
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Default consent state
|
|
37
|
+
*/
|
|
38
|
+
export function getDefaultConsent() {
|
|
39
|
+
return {
|
|
40
|
+
essential: true,
|
|
41
|
+
functional: false,
|
|
42
|
+
analytics: false,
|
|
43
|
+
marketing: false
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Get all category IDs
|
|
49
|
+
*/
|
|
50
|
+
export function getCategoryIds() {
|
|
51
|
+
return Object.keys(DEFAULT_CATEGORIES);
|
|
52
|
+
}
|