"use strict";(globalThis.webpackChunkcomplianz_gdpr=globalThis.webpackChunkcomplianz_gdpr||[]).push([[5074],{35074:(e,t,c)=>{c.r(t),c.d(t,{default:()=>_});var a=c(51280),r=c(88496),n=c(45072),l=c(3608),o=c(40304),s=c(59016),d=c(84664),u=c(37408),i=c(15920),p=c(61480);const h="Switch",[b,m]=(0,s._)(h),[k,f]=b(h),v=(0,a.forwardRef)(((e,t)=>{const{__scopeSwitch:c,name:r,checked:s,defaultChecked:u,required:i,disabled:h,value:b="on",onCheckedChange:m,...f}=e,[v,E]=(0,a.useState)(null),C=(0,o.q)(t,(e=>E(e))),y=(0,a.useRef)(!1),_=!v||Boolean(v.closest("form")),[q=!1,z]=(0,d.W)({prop:s,defaultProp:u,onChange:m});return(0,a.createElement)(k,{scope:c,checked:q,disabled:h},(0,a.createElement)(p.K0.button,(0,n.c)({type:"button",role:"switch","aria-checked":q,"aria-required":i,"data-state":w(q),"data-disabled":h?"":void 0,disabled:h,value:b},f,{ref:C,onClick:(0,l.K)(e.onClick,(e=>{z((e=>!e)),_&&(y.current=e.isPropagationStopped(),y.current||e.stopPropagation())}))})),_&&(0,a.createElement)(g,{control:v,bubbles:!y.current,name:r,value:b,checked:q,required:i,disabled:h,style:{transform:"translateX(-100%)"}}))})),g=e=>{const{control:t,checked:c,bubbles:r=!0,...l}=e,o=(0,a.useRef)(null),s=(0,u.i)(c),d=(0,i.k)(t);return(0,a.useEffect)((()=>{const e=o.current,t=window.HTMLInputElement.prototype,a=Object.getOwnPropertyDescriptor(t,"checked").set;if(s!==c&&a){const t=new Event("click",{bubbles:r});a.call(e,c),e.dispatchEvent(t)}}),[s,c,r]),(0,a.createElement)("input",(0,n.c)({type:"checkbox","aria-hidden":!0,defaultChecked:c},l,{tabIndex:-1,ref:o,style:{...e.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function w(e){return e?"checked":"unchecked"}const E=v,C=(0,a.forwardRef)(((e,t)=>{const{__scopeSwitch:c,...r}=e,l=f("SwitchThumb",c);return(0,a.createElement)(p.K0.span,(0,n.c)({"data-state":w(l.checked),"data-disabled":l.disabled?"":void 0},r,{ref:t}))}));var y=c(25536);const _=(0,r.memo)((({value:e,onChange:t,required:c,disabled:r,className:n,label:l,id:o})=>{const{getField:s}=(0,y.default)();let d=e;return"0"!==e&&"1"!==e||(d="1"===e),(0,a.createElement)("div",{className:"cmplz-input-group cmplz-switch-group"},(0,a.createElement)(E,{className:"cmplz-switch-root "+n,checked:d,onCheckedChange:e=>{"banner"===s(o).data_target&&(e=e?"1":"0"),t(e)},disabled:r,required:c},(0,a.createElement)(C,{className:"cmplz-switch-thumb"})))}))},37408:(e,t,c)=>{c.d(t,{i:()=>r});var a=c(51280);function r(e){const t=(0,a.useRef)({value:e,previous:e});return(0,a.useMemo)((()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous)),[e])}}}]);