{"version":3,"file":"use-lifecycle.mjs","names":[],"sources":["../../../../../../../packages/components/slider/src/composables/use-lifecycle.ts"],"sourcesContent":["import { nextTick, onMounted, ref } from 'vue'\nimport { useEventListener } from '@vueuse/core'\nimport { isArray, isNumber } from '@element-plus/utils'\n\nimport type { SliderInitData, SliderProps } from '../slider'\n\nexport const useLifecycle = (\n  props: SliderProps,\n  initData: SliderInitData,\n  resetSize: () => void\n) => {\n  const sliderWrapper = ref<HTMLElement>()\n\n  onMounted(async () => {\n    if (props.range) {\n      if (isArray(props.modelValue)) {\n        initData.firstValue = Math.max(props.min, props.modelValue[0])\n        initData.secondValue = Math.min(props.max, props.modelValue[1])\n      } else {\n        initData.firstValue = props.min\n        initData.secondValue = props.max\n      }\n      initData.oldValue = [initData.firstValue, initData.secondValue]\n    } else {\n      if (!isNumber(props.modelValue) || Number.isNaN(props.modelValue)) {\n        initData.firstValue = props.min\n      } else {\n        initData.firstValue = Math.min(\n          props.max,\n          Math.max(props.min, props.modelValue)\n        )\n      }\n      initData.oldValue = initData.firstValue\n    }\n\n    useEventListener(window, 'resize', resetSize)\n\n    await nextTick()\n    resetSize()\n  })\n\n  return {\n    sliderWrapper,\n  }\n}\n"],"mappings":";;;;AAMA,MAAa,gBACX,OACA,UACA,cACG;CACH,MAAM,gBAAgB,IAAiB;CAEvC,UAAU,YAAY;EACpB,IAAI,MAAM,OAAO;GACf,IAAI,QAAQ,MAAM,UAAU,GAAG;IAC7B,SAAS,aAAa,KAAK,IAAI,MAAM,KAAK,MAAM,WAAW,EAAE;IAC7D,SAAS,cAAc,KAAK,IAAI,MAAM,KAAK,MAAM,WAAW,EAAE;GAChE,OAAO;IACL,SAAS,aAAa,MAAM;IAC5B,SAAS,cAAc,MAAM;GAC/B;GACA,SAAS,WAAW,CAAC,SAAS,YAAY,SAAS,WAAW;EAChE,OAAO;GACL,IAAI,CAAC,SAAS,MAAM,UAAU,KAAK,OAAO,MAAM,MAAM,UAAU,GAC9D,SAAS,aAAa,MAAM;QAE5B,SAAS,aAAa,KAAK,IACzB,MAAM,KACN,KAAK,IAAI,MAAM,KAAK,MAAM,UAAU,CACtC;GAEF,SAAS,WAAW,SAAS;EAC/B;EAEA,iBAAiB,QAAQ,UAAU,SAAS;EAE5C,MAAM,SAAS;EACf,UAAU;CACZ,CAAC;CAED,OAAO,EACL,cACF;AACF"}