Files

1 line
5.2 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use strict";(globalThis.webpackChunkcomplianz_gdpr=globalThis.webpackChunkcomplianz_gdpr||[]).push([[4078,2489,4759,2921],{32489:(e,t,s)=>{s.r(t),s.d(t,{default:()=>c});var r=s(51609);const c=(0,r.memo)((({value:e,onChange:t,required:s,disabled:c,id:i,name:n,placeholder:l})=>{const a=i||n,[o,p]=(0,r.useState)("");return(0,r.useEffect)((()=>{p(e||"")}),[e]),(0,r.useEffect)((()=>{if(e===o)return;const s=setTimeout((()=>{t(o)}),400);return()=>{clearTimeout(s)}}),[o]),(0,r.createElement)("div",{className:"cmplz-input-group cmplz-text-input-group"},(0,r.createElement)("input",{type:"text",id:a,name:n,value:o,onChange:e=>(e=>{p(e)})(e.target.value),required:s,disabled:c,className:"cmplz-text-input-group__input",placeholder:l}))}))},34759:(e,t,s)=>{s.r(t),s.d(t,{default:()=>n});var r=s(81621),c=s(16535),i=s(9588);const n=(0,r.vt)(((e,t)=>({integrationsLoaded:!1,fetching:!1,services:[],plugins:[],scripts:[],placeholders:[],blockedScripts:[],setScript:(t,s)=>{e((0,c.Ay)((e=>{if("block_script"===s){let s=e.blockedScripts;if(t.urls){for(const[e,r]of Object.entries(t.urls)){if(!r||0===r.length)continue;let e=!1;for(const[t,c]of Object.entries(s))r===t&&(e=!0);e||(s[r]=r)}e.blockedScripts=s}}const r=e.scripts[s].findIndex((e=>e.id===t.id));-1!==r&&(e.scripts[s][r]=t)})))},fetchIntegrationsData:async()=>{if(t().fetching)return;e({fetching:!0});const{services:s,plugins:r,scripts:c,placeholders:i,blocked_scripts:n}=await l();let a=c;a.block_script&&a.block_script.length>0&&a.block_script.forEach(((e,t)=>{e.id=t})),a.add_script&&a.add_script.length>0&&a.add_script.forEach(((e,t)=>{e.id=t})),a.whitelist_script&&a.whitelist_script.length>0&&a.whitelist_script.forEach(((e,t)=>{e.id=t})),e((()=>({integrationsLoaded:!0,services:s,plugins:r,scripts:a,fetching:!1,placeholders:i,blockedScripts:n})))},addScript:s=>{e({fetching:!0}),t().scripts[s]&&Array.isArray(t().scripts[s])||e((0,c.Ay)((e=>{e.scripts[s]=[]}))),e((0,c.Ay)((e=>{e.scripts[s].push({name:"general",id:e.scripts[s].length,enable:!0})})));let r=t().scripts;return i.doAction("update_scripts",{scripts:r}).then((t=>(e({fetching:!1}),t))).catch((e=>{console.error(e)}))},saveScript:(s,r)=>{e({fetching:!0}),t().scripts[r]&&Array.isArray(t().scripts[r])||e((0,c.Ay)((e=>{e.scripts[r]=[]}))),e((0,c.Ay)((e=>{const t=e.scripts[r].findIndex((e=>e.id===s.id));-1!==t&&(e.scripts[r][t]=s)})));let n=t().scripts;return i.doAction("update_scripts",{scripts:n}).then((t=>(e({fetching:!1}),t))).catch((e=>{console.error(e)}))},deleteScript:(s,r)=>{e({fetching:!0}),t().scripts[r]&&Array.isArray(t().scripts[r])||e((0,c.Ay)((e=>{e.scripts[r]=[]}))),e((0,c.Ay)((e=>{const t=e.scripts[r].findIndex((e=>e.id===s.id));-1!==t&&e.scripts[r].splice(t,1)})));let n=t().scripts;return i.doAction("update_scripts",{scripts:n}).then((t=>(e({fetching:!1}),t))).catch((e=>{console.error(e)}))},updatePluginStatus:async(t,s)=>{e({fetching:!0}),e((0,c.Ay)((e=>{const r=e.plugins.findIndex((e=>e.id===t));-1!==r&&(e.plugins[r].enabled=s)})));const r=await i.doAction("update_plugin_status",{plugin:t,enabled:s}).then((e=>e)).catch((e=>{console.error(e)}));return e({fetching:!1}),r},updatePlaceholderStatus:async(t,s,r)=>{e({fetching:!0}),r&&e((0,c.Ay)((e=>{const r=e.plugins.findIndex((e=>e.id===t));-1!==r&&(e.plugins[r].placeholder=s?"enabled":"disabled")})));const n=await i.doAction("update_placeholder_status",{id:t,enabled:s}).then((e=>e)).catch((e=>{console.error(e)}));return e({fetching:!1}),n}}))),l=()=>i.doAction("get_integrations_data",{}).then((e=>e)).catch((e=>{console.error(e)}))},44078:(e,t,s)=>{s.r(t),s.d(t,{default:()=>o});var r=s(51609),c=s(27723),i=s(32921),n=s(32489),l=s(45111),a=s(34759);const o=e=>{const{setScript:t,fetching:s}=(0,a.default)(),[o,p]=(0,r.useState)(!1),d=e.script,u=e.type;(0,r.useEffect)((()=>{(d.hasOwnProperty("urls")?Object.values(d.urls):[""]).includes("")?p(!0):p(!1)}),[d]);let h=d.hasOwnProperty("urls")?Object.entries(d.urls):[""];return(0,r.createElement)("div",{className:"cmplz-details-row"},(0,r.createElement)("label",null,"block_script"===u&&(0,c.__)("URLs that should be blocked before consent.","complianz-gdpr"),"whitelist_script"===u&&(0,r.createElement)(r.Fragment,null,(0,c.__)("URLs that should be whitelisted.","complianz-gdpr"),(0,i.default)("https://complianz.io/whitelisting-inline-script/"))),h.map((([c,i],a)=>(0,r.createElement)("div",{key:a,className:"cmplz-scriptcenter-url"},(0,r.createElement)(n.default,{disabled:s,value:i||"",onChange:s=>((s,r)=>{let c={...d},i={...c.urls};i[s]=r,c.urls=i,t(c,e.type)})(c,s),id:a+"_url",name:"url"}),0===a&&!o&&(0,r.createElement)("button",{className:"button button-default",onClick:()=>(()=>{let s={...d},r=s.hasOwnProperty("urls")?{...s.urls}:[""];r[Object.keys(r).length+1]="",s.urls=r,t(s,e.type)})()}," ",(0,r.createElement)(l.default,{name:"plus",size:14})),0!==a&&(0,r.createElement)("button",{className:"button button-default",onClick:()=>(s=>{let r={...d},c={...r.urls};delete c[s],r.urls=c,t(r,e.type)})(c)}," ",(0,r.createElement)(l.default,{name:"minus",size:14}))))))}},32921:(e,t,s)=>{s.r(t),s.d(t,{default:()=>n});var r=s(51609),c=s(27723),i=s(44124);const n=e=>(0,r.createElement)(r.Fragment,null," ",(0,r.createElement)(i.default,{url:e,target:"_blank",rel:"noopener noreferrer",text:(0,c.__)("For more information, please read this %sarticle%s.","complianz-gdpr")})," ")}}]);