"use strict";(globalThis.webpackChunkcomplianz_gdpr=globalThis.webpackChunkcomplianz_gdpr||[]).push([[5080],{35080:(t,c,s)=>{s.r(c),s.d(c,{default:()=>n});var i=s(30809),e=s(524),r=s(61744);const n=(0,i.Su)(((t,c)=>({integrationsLoaded:!1,fetching:!1,services:[],plugins:[],scripts:[],placeholders:[],blockedScripts:[],setScript:(c,s)=>{t((0,e.cp)((t=>{if("block_script"===s){let s=t.blockedScripts;if(c.urls){for(const[t,i]of Object.entries(c.urls)){if(!i||0===i.length)continue;let t=!1;for(const[c,e]of Object.entries(s))i===c&&(t=!0);t||(s[i]=i)}t.blockedScripts=s}}const i=t.scripts[s].findIndex((t=>t.id===c.id));-1!==i&&(t.scripts[s][i]=c)})))},fetchIntegrationsData:async()=>{if(c().fetching)return;t({fetching:!0});const{services:s,plugins:i,scripts:e,placeholders:r,blocked_scripts:n}=await p();let o=e;o.block_script&&o.block_script.length>0&&o.block_script.forEach(((t,c)=>{t.id=c})),o.add_script&&o.add_script.length>0&&o.add_script.forEach(((t,c)=>{t.id=c})),o.whitelist_script&&o.whitelist_script.length>0&&o.whitelist_script.forEach(((t,c)=>{t.id=c})),t((()=>({integrationsLoaded:!0,services:s,plugins:i,scripts:o,fetching:!1,placeholders:r,blockedScripts:n})))},addScript:s=>{t({fetching:!0}),c().scripts[s]&&Array.isArray(c().scripts[s])||t((0,e.cp)((t=>{t.scripts[s]=[]}))),t((0,e.cp)((t=>{t.scripts[s].push({name:"general",id:t.scripts[s].length,enable:!0})})));let i=c().scripts;return r.doAction("update_scripts",{scripts:i}).then((c=>(t({fetching:!1}),c))).catch((t=>{console.error(t)}))},saveScript:(s,i)=>{t({fetching:!0}),c().scripts[i]&&Array.isArray(c().scripts[i])||t((0,e.cp)((t=>{t.scripts[i]=[]}))),t((0,e.cp)((t=>{const c=t.scripts[i].findIndex((t=>t.id===s.id));-1!==c&&(t.scripts[i][c]=s)})));let n=c().scripts;return r.doAction("update_scripts",{scripts:n}).then((c=>(t({fetching:!1}),c))).catch((t=>{console.error(t)}))},deleteScript:(s,i)=>{t({fetching:!0}),c().scripts[i]&&Array.isArray(c().scripts[i])||t((0,e.cp)((t=>{t.scripts[i]=[]}))),t((0,e.cp)((t=>{const c=t.scripts[i].findIndex((t=>t.id===s.id));-1!==c&&t.scripts[i].splice(c,1)})));let n=c().scripts;return r.doAction("update_scripts",{scripts:n}).then((c=>(t({fetching:!1}),c))).catch((t=>{console.error(t)}))},updatePluginStatus:async(c,s)=>{t({fetching:!0}),t((0,e.cp)((t=>{const i=t.plugins.findIndex((t=>t.id===c));-1!==i&&(t.plugins[i].enabled=s)})));const i=await r.doAction("update_plugin_status",{plugin:c,enabled:s}).then((t=>t)).catch((t=>{console.error(t)}));return t({fetching:!1}),i},updatePlaceholderStatus:async(c,s,i)=>{t({fetching:!0}),i&&t((0,e.cp)((t=>{const i=t.plugins.findIndex((t=>t.id===c));-1!==i&&(t.plugins[i].placeholder=s?"enabled":"disabled")})));const n=await r.doAction("update_placeholder_status",{id:c,enabled:s}).then((t=>t)).catch((t=>{console.error(t)}));return t({fetching:!1}),n}}))),p=()=>r.doAction("get_integrations_data",{}).then((t=>t)).catch((t=>{console.error(t)}))}}]);