(function(h,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],n):(h=typeof globalThis<"u"?globalThis:h||self,n(h.AtomThemeSwitch={},h["react/jsx-runtime"],h.React))})(this,function(h,n,l){"use strict";function _(r){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const d in r)if(d!=="default"){const t=Object.getOwnPropertyDescriptor(r,d);Object.defineProperty(s,d,t.get?t:{enumerable:!0,get:()=>r[d]})}}return s.default=r,Object.freeze(s)}const o=_(l),T=r=>o.createElement("svg",{className:"sun",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 496 496",style:{enableBackground:"new 0 0 496 496"},xmlSpace:"preserve",...r},o.createElement("rect",{x:152.994,y:58.921,transform:"matrix(0.3827 0.9239 -0.9239 0.3827 168.6176 -118.5145)",width:40.001,height:16}),o.createElement("rect",{x:46.9,y:164.979,transform:"matrix(0.9239 0.3827 -0.3827 0.9239 71.29 -12.4346)",width:40.001,height:16}),o.createElement("rect",{x:46.947,y:315.048,transform:"matrix(0.9239 -0.3827 0.3827 0.9239 -118.531 50.2116)",width:40.001,height:16}),o.createElement("rect",{x:164.966,y:409.112,transform:"matrix(-0.9238 -0.3828 0.3828 -0.9238 168.4872 891.7491)",width:16,height:39.999}),o.createElement("rect",{x:303.031,y:421.036,transform:"matrix(-0.3827 -0.9239 0.9239 -0.3827 50.2758 891.6655)",width:40.001,height:16}),o.createElement("rect",{x:409.088,y:315.018,transform:"matrix(-0.9239 -0.3827 0.3827 -0.9239 701.898 785.6559)",width:40.001,height:16}),o.createElement("rect",{x:409.054,y:165.011,transform:"matrix(-0.9239 0.3827 -0.3827 -0.9239 891.6585 168.6574)",width:40.001,height:16}),o.createElement("rect",{x:315.001,y:46.895,transform:"matrix(0.9238 0.3828 -0.3828 0.9238 50.212 -118.5529)",width:16,height:39.999}),o.createElement("path",{d:"M248,88c-88.224,0-160,71.776-160,160s71.776,160,160,160s160-71.776,160-160S336.224,88,248,88z M248,392 c-79.4,0-144-64.6-144-144s64.6-144,144-144s144,64.6,144,144S327.4,392,248,392z"}),o.createElement("rect",{x:240,width:16,height:72}),o.createElement("rect",{x:62.097,y:90.096,transform:"matrix(0.7071 0.7071 -0.7071 0.7071 98.0963 -40.6334)",width:71.999,height:16}),o.createElement("rect",{y:240,width:72,height:16}),o.createElement("rect",{x:90.091,y:361.915,transform:"matrix(-0.7071 -0.7071 0.7071 -0.7071 -113.9157 748.643)",width:16,height:71.999}),o.createElement("rect",{x:240,y:424,width:16,height:72}),o.createElement("rect",{x:361.881,y:389.915,transform:"matrix(-0.7071 -0.7071 0.7071 -0.7071 397.8562 960.6281)",width:71.999,height:16}),o.createElement("rect",{x:424,y:240,width:72,height:16}),o.createElement("rect",{x:389.911,y:62.091,transform:"matrix(0.7071 0.7071 -0.7071 0.7071 185.9067 -252.6357)",width:16,height:71.999})),v=r=>o.createElement("svg",{width:"800px",height:"800px",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},o.createElement("path",{d:"M3.32031 11.6835C3.32031 16.6541 7.34975 20.6835 12.3203 20.6835C16.1075 20.6835 19.3483 18.3443 20.6768 15.032C19.6402 15.4486 18.5059 15.6834 17.3203 15.6834C12.3497 15.6834 8.32031 11.654 8.32031 6.68342C8.32031 5.50338 8.55165 4.36259 8.96453 3.32996C5.65605 4.66028 3.32031 7.89912 3.32031 11.6835Z",stroke:"#000000",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}));var c=(r=>(r.LIGHT="light",r.DARK="dark",r))(c||{});const A=(r="theme",s)=>{typeof window<"u"&&window.localStorage.setItem(r,s)},y={theme:c.LIGHT},H=(r,s)=>{switch(s.type){case"TOGGLE_THEME":return{...r,theme:r.theme===c.LIGHT?c.DARK:c.LIGHT};default:return r}},C=l.createContext({state:y,dispatch:()=>null});function $(r){const{children:s}=r,[d,t]=l.useReducer(H,y);return n.jsx(C.Provider,{value:{state:d,dispatch:t},children:s})}const G="prefers-color-scheme",L="--switch-height",N=r=>{const{designType:s,shape:d,fixedPosition:t,selectedTheme:j,switchHeight:E,customMatTheme:i,onChanged:k,handleBrowserMode:p}=r,{state:m,dispatch:D}=l.useContext(C),[g,O]=l.useState({trackColor:"",thumbColor:""});l.useEffect(()=>{document.documentElement.style.setProperty(L,E||"32px")},[]),l.useEffect(()=>{const e=m.theme===c.DARK?{...i==null?void 0:i.checked}:{...i==null?void 0:i.unchecked},a=u(e);w(a.c1,a.c2)},[]),l.useEffect(()=>{const e=window.matchMedia,a=e!=null&&e(`(${G}: dark)`).matches?"dark":"light";p&&(a==="dark"?p({system:"dark"}):a==="light"&&p({system:"light"}))},[]);const P=e=>{var a,S;if(I((a=e==null?void 0:e.target)==null?void 0:a.checked),(S=e==null?void 0:e.target)!=null&&S.checked){const x={...i==null?void 0:i.checked},f=u(x);w(f.c1,f.c2),b(c.DARK)}else{const x={...i==null?void 0:i.unchecked},f=u(x);w(f.c1,f.c2),b(c.LIGHT)}},I=e=>{k&&(k(e?c.DARK:c.LIGHT),D({type:"TOGGLE_THEME"}))},b=e=>{typeof window<"u"&&A(j,e)},u=e=>({c1:e!=null&&e.trackColor?e==null?void 0:e.trackColor:"",c2:e!=null&&e.thumbColor?e==null?void 0:e.thumbColor:""}),w=(e,a)=>{O({trackColor:e,thumbColor:a})},K={position:`${t&&t.position?"fixed":"static"}`,top:`${t&&t.top?t.top:void 0}`,left:`${t&&t.left?t.left:void 0}`,right:`${t&&t.right?t.right:void 0}`,bottom:`${t&&t.bottom?t.bottom:void 0}`,margin:`${t&&t.margin?t.margin:void 0}`,transform:`${t&&t.transform?t.transform:void 0}`},B=`ats__switch ${s}`;return n.jsx(n.Fragment,{children:n.jsxs("label",{className:B,style:t&&t.position?K:{},title:`${m==null?void 0:m.theme} theme`,children:[n.jsx("input",{type:"checkbox",onChange:e=>P(e),checked:(m==null?void 0:m.theme)===c.DARK}),s&&s==="space"?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"ats__space-bg"}),n.jsx("span",{className:"sphere"}),n.jsx("span",{className:"ats__sun-icon",children:n.jsx(T,{})}),n.jsx("span",{className:"ats__moon-icon",children:n.jsx(v,{})})]}):n.jsx("span",{className:`ats__slider ${d}`,style:{backgroundColor:g.trackColor?g.trackColor:""},children:n.jsx("span",{className:"ats__slider-button",style:{backgroundColor:g.thumbColor?g.thumbColor:""}})})]})})};h.AtomThemeProvider=$,h.AtomThemeSwitch=N,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});