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