{"version":3,"file":"utils.mjs","names":["isClient"],"sources":["../../../../../../packages/components/popper/src/utils.ts"],"sourcesContent":["import { unrefElement } from '@vueuse/core'\nimport { isClient } from '@element-plus/utils'\n\nimport type { ComponentPublicInstance } from 'vue'\nimport type { MaybeRef } from '@vueuse/core'\nimport type { Modifier } from '@popperjs/core'\nimport type { Measurable } from './constants'\nimport type { PopperCoreConfigProps } from './content'\n\nexport const buildPopperOptions = (\n  props: PopperCoreConfigProps,\n  modifiers: Modifier<any, any>[] = []\n) => {\n  const { placement, strategy, popperOptions } = props\n  const options = {\n    placement,\n    strategy,\n    ...popperOptions,\n    modifiers: [...genModifiers(props), ...modifiers],\n  }\n\n  deriveExtraModifiers(options, popperOptions?.modifiers)\n  return options\n}\n\nexport const unwrapMeasurableEl = (\n  $el: MaybeRef<Measurable | undefined | ComponentPublicInstance>\n) => {\n  if (!isClient) return\n  return unrefElement($el as HTMLElement)\n}\n\nfunction genModifiers(options: PopperCoreConfigProps) {\n  const { offset, gpuAcceleration, fallbackPlacements } = options\n  return [\n    {\n      name: 'offset',\n      options: {\n        offset: [0, offset ?? 12],\n      },\n    },\n    {\n      name: 'preventOverflow',\n      options: {\n        padding: {\n          top: 0,\n          bottom: 0,\n          left: 0,\n          right: 0,\n        },\n      },\n    },\n    {\n      name: 'flip',\n      options: {\n        padding: 5,\n        fallbackPlacements,\n      },\n    },\n    {\n      name: 'computeStyles',\n      options: {\n        gpuAcceleration,\n      },\n    },\n  ]\n}\n\nfunction deriveExtraModifiers(\n  options: any,\n  modifiers: NonNullable<PopperCoreConfigProps['popperOptions']>['modifiers']\n) {\n  if (modifiers) {\n    options.modifiers = [...options.modifiers, ...(modifiers ?? [])]\n  }\n}\n"],"mappings":";;;;AASA,MAAa,sBACX,OACA,YAAkC,EAAE,KACjC;CACH,MAAM,EAAE,WAAW,UAAU,kBAAkB;CAC/C,MAAM,UAAU;EACd;EACA;EACA,GAAG;EACH,WAAW,CAAC,GAAG,aAAa,MAAM,EAAE,GAAG,UAAU;EAClD;AAED,sBAAqB,SAAS,eAAe,UAAU;AACvD,QAAO;;AAGT,MAAa,sBACX,QACG;AACH,KAAI,CAACA,WAAU;AACf,QAAO,aAAa,IAAmB;;AAGzC,SAAS,aAAa,SAAgC;CACpD,MAAM,EAAE,QAAQ,iBAAiB,uBAAuB;AACxD,QAAO;EACL;GACE,MAAM;GACN,SAAS,EACP,QAAQ,CAAC,GAAG,UAAU,GAAG,EAC1B;GACF;EACD;GACE,MAAM;GACN,SAAS,EACP,SAAS;IACP,KAAK;IACL,QAAQ;IACR,MAAM;IACN,OAAO;IACR,EACF;GACF;EACD;GACE,MAAM;GACN,SAAS;IACP,SAAS;IACT;IACD;GACF;EACD;GACE,MAAM;GACN,SAAS,EACP,iBACD;GACF;EACF;;AAGH,SAAS,qBACP,SACA,WACA;AACA,KAAI,UACF,SAAQ,YAAY,CAAC,GAAG,QAAQ,WAAW,GAAI,aAAa,EAAE,CAAE"}