{"version":3,"file":"steps.mjs","names":[],"sources":["../../../../../../packages/components/tour/src/steps.ts"],"sourcesContent":["import { defineComponent } from 'vue'\nimport { flattedChildren, isArray } from '@element-plus/utils'\n\nimport type { FlattenVNodes } from '@element-plus/utils'\nimport type { Component, VNode } from 'vue'\n\nexport default defineComponent({\n  name: 'ElTourSteps',\n  props: {\n    current: {\n      type: Number,\n      default: 0,\n    },\n  },\n  emits: ['update-total'],\n  setup(props, { slots, emit }) {\n    let cacheTotal = 0\n\n    return () => {\n      const children = slots.default?.()!\n      const result: VNode[] = []\n      let total = 0\n\n      function filterSteps(children?: FlattenVNodes) {\n        if (!isArray(children)) return\n        ;(children as VNode[]).forEach((item) => {\n          const name = ((item?.type || {}) as Component)?.name\n\n          if (name === 'ElTourStep') {\n            result.push(item)\n            total += 1\n          }\n        })\n      }\n\n      if (children.length) {\n        filterSteps(flattedChildren(children![0]?.children))\n      }\n\n      if (cacheTotal !== total) {\n        cacheTotal = total\n        emit('update-total', total)\n      }\n\n      if (result.length) {\n        return result[props.current]\n      }\n      return null\n    }\n  },\n})\n"],"mappings":";;;;AAMA,IAAA,gBAAe,gBAAgB;CAC7B,MAAM;CACN,OAAO,EACL,SAAS;EACP,MAAM;EACN,SAAS;EACV,EACF;CACD,OAAO,CAAC,eAAe;CACvB,MAAM,OAAO,EAAE,OAAO,QAAQ;EAC5B,IAAI,aAAa;EAEjB,aAAa;GACX,MAAM,WAAW,MAAM,WAAW;GAClC,MAAM,SAAkB,EAAE;GAC1B,IAAI,QAAQ;GAEZ,SAAS,YAAY,UAA0B;IAC7C,IAAI,CAAC,QAAQ,SAAS,EAAE;IACvB,SAAsB,SAAS,SAAS;KAGvC,KAFe,MAAM,QAAQ,EAAE,GAAiB,SAEnC,cAAc;MACzB,OAAO,KAAK,KAAK;MACjB,SAAS;;MAEX;;GAGJ,IAAI,SAAS,QACX,YAAY,gBAAgB,SAAU,IAAI,SAAS,CAAC;GAGtD,IAAI,eAAe,OAAO;IACxB,aAAa;IACb,KAAK,gBAAgB,MAAM;;GAG7B,IAAI,OAAO,QACT,OAAO,OAAO,MAAM;GAEtB,OAAO;;;CAGZ,CAAC"}