{"version":3,"sources":["../src/components/Switch/useSwitch.ts"],"sourcesContent":["'use client';\n\nimport type * as React from 'react';\nimport { useSwitchBase_unstable } from '@fluentui/react-switch';\n\nimport type { SwitchProps, SwitchState } from './Switch.types';\nimport { stringifyDataAttribute } from '../../utils';\n\n/**\n * Returns the state for a Switch component, given its props and ref.\n * The returned state can be modified with hooks before being passed to `renderSwitch`.\n */\nexport const useSwitch = (props: SwitchProps, ref: React.Ref<HTMLInputElement>): SwitchState => {\n  const state: SwitchState = useSwitchBase_unstable(props, ref);\n\n  // Set data attributes for disabled, disabledFocusable, and checked states to simplify styling.\n  // eslint-disable-next-line react-hooks/immutability\n  state.root['data-disabled'] = stringifyDataAttribute(state.input.disabled || state.disabledFocusable);\n  // eslint-disable-next-line react-hooks/immutability\n  state.root['data-disabled-focusable'] = stringifyDataAttribute(state.disabledFocusable);\n  // eslint-disable-next-line react-hooks/immutability\n  state.root['data-checked'] = stringifyDataAttribute(state.input.checked);\n  // eslint-disable-next-line react-hooks/immutability\n  state.root['data-label-position'] = state.labelPosition;\n\n  return state;\n};\n"],"names":["useSwitch","props","ref","state","useSwitchBase_unstable","root","stringifyDataAttribute","input","disabled","disabledFocusable","checked","labelPosition"],"mappings":"AAAA;;;;;+BAYaA;;;eAAAA;;;6BAT0B;uBAGA;AAMhC,MAAMA,YAAY,CAACC,OAAoBC;IAC5C,MAAMC,QAAqBC,IAAAA,mCAAsB,EAACH,OAAOC;IAEzD,+FAA+F;IAC/F,oDAAoD;IACpDC,MAAME,IAAI,CAAC,gBAAgB,GAAGC,IAAAA,6BAAsB,EAACH,MAAMI,KAAK,CAACC,QAAQ,IAAIL,MAAMM,iBAAiB;IACpG,oDAAoD;IACpDN,MAAME,IAAI,CAAC,0BAA0B,GAAGC,IAAAA,6BAAsB,EAACH,MAAMM,iBAAiB;IACtF,oDAAoD;IACpDN,MAAME,IAAI,CAAC,eAAe,GAAGC,IAAAA,6BAAsB,EAACH,MAAMI,KAAK,CAACG,OAAO;IACvE,oDAAoD;IACpDP,MAAME,IAAI,CAAC,sBAAsB,GAAGF,MAAMQ,aAAa;IAEvD,OAAOR;AACT"}