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;AAAA,EACF;AACF","file":"index.cjs","sourcesContent":["/**\n * This package contains the official themes for FormKit. Read the\n * {@link https://formkit.com/getting-started/installation |\n * installation documentation} for more information.\n *\n * @packageDocumentation\n */\n\nimport {\n  FORMKIT_VERSION,\n  FormKitNode,\n  FormKitClasses,\n  FormKitEvent,\n} from '@formkit/core'\n\n/**\n * A function that returns a class list string\n * @internal\n */\ntype ClassFunction = (node: FormKitNode, sectionKey: string) => string\n\n/**\n * A function that returns an icon SVG string.\n * @public\n */\nexport interface FormKitIconLoader {\n  (iconName: string): string | undefined | Promise<string | undefined>\n}\n\n/**\n * A function that returns a remote URL for retrieving an SVG icon by name.\n * @public\n */\nexport interface FormKitIconLoaderUrl {\n  (iconName: string): string | undefined\n}\n\n/**\n * A function to generate FormKit class functions from a JavaScript object.\n * @param classes - An object of input types with nested objects of sectionKeys and class lists.\n * @returns An object of sectionKeys with class functions.\n * @public\n */\nexport function generateClasses(\n  classes: Record<string, Record<string, string>>\n): Record<string, string | FormKitClasses | Record<string, boolean>> {\n  const classesBySectionKey: Record<string, Record<string, any>> = {}\n  Object.keys(classes).forEach((type) => {\n    Object.keys(classes[type]).forEach((sectionKey) => {\n      if (!classesBySectionKey[sectionKey]) {\n        classesBySectionKey[sectionKey] = {\n          [type]: classes[type][sectionKey],\n        }\n      } else {\n        classesBySectionKey[sectionKey][type] = classes[type][sectionKey]\n      }\n    })\n  })\n\n  Object.keys(classesBySectionKey).forEach((sectionKey) => {\n    const classesObject = classesBySectionKey[sectionKey]\n    classesBySectionKey[sectionKey] = function (node, sectionKey) {\n      return addClassesBySection(node, sectionKey, classesObject)\n    } as ClassFunction\n  })\n\n  return classesBySectionKey\n}\n\n/**\n * Updates a class list for a given sectionKey\n * @param node - the FormKit node being operated on\n * @param sectionKey - The section key to which the class list will be applied\n * @param classByType - Object containing mappings of class lists to section keys\n * @returns\n * @public\n */\nfunction addClassesBySection(\n  node: FormKitNode,\n  _sectionKey: string,\n  classesByType: Record<string, () => string>\n): string {\n  const type = node.props.type\n  const family = node.props.family\n  let classList = ''\n  if (classesByType.global) {\n    classList += classesByType.global + ' '\n  }\n  if (classesByType[`family:${family}`]) {\n    classList += classesByType[`family:${family}`] + ' '\n  }\n  if (classesByType[type]) {\n    classList += classesByType[type]\n  }\n  const listParts = classList.split('$reset')\n  if (listParts.length > 1) {\n    return `$reset ${listParts[listParts.length - 1].trim()}`\n  }\n  return listParts[0].trim()\n}\n\n/**\n * The document's computed CSS styles\n */\nlet documentStyles: Record<any, any> | undefined = undefined\nlet documentThemeLinkTag: HTMLElement | null = null\n\n/**\n * Stores the state of theme loading\n */\nlet themeDidLoad: (value?: unknown) => void\nlet themeHasLoaded = false\nlet themeWasRequested = false\n\nconst themeLoaded = /* #__PURE__ */ new Promise<void>((res) => {\n  themeDidLoad = () => {\n    themeHasLoaded = true\n    res()\n  }\n})\n\n/**\n * Check if we are client-side\n */\nconst isClient = typeof window !== 'undefined' && typeof fetch !== 'undefined'\ndocumentStyles = isClient\n  ? /* #__PURE__ */ getComputedStyle(document.documentElement)\n  : undefined\n\n/**\n * The FormKit icon Registry - a global record of loaded icons.\n * @public\n */\nexport const iconRegistry: Record<string, string | undefined> = {}\n\n/**\n * A collection of existing icon requests to avoid duplicate fetching\n */\nconst iconRequests: Record<string, any> = {}\n\n/**\n * Creates the theme plugin based on a given theme name.\n * @param theme - The name or id of the theme to apply.\n * @param icons - Icons you want to add to the global icon registry.\n * @param iconLoaderUrl - A function that returns a remote url for retrieving an\n * SVG icon by name.\n * @param iconLoader - A function that handles loading an icon when it is not\n * found in the registry.\n * @public\n */\nexport function createThemePlugin(\n  theme?: string,\n  icons?: Record<string, string | undefined>,\n  iconLoaderUrl?: FormKitIconLoaderUrl,\n  iconLoader?: FormKitIconLoader\n): (node: FormKitNode) => any {\n  if (icons) {\n    // add any user-provided icons to the registry\n    Object.assign(iconRegistry, icons)\n  }\n\n  // if we have a theme declared, request it\n  if (\n    isClient &&\n    !themeWasRequested &&\n    documentStyles?.getPropertyValue('--formkit-theme')\n  ) {\n    // we have the theme loaded locally\n    themeDidLoad()\n    themeWasRequested = true\n  } else if (theme && !themeWasRequested && isClient) {\n    // we have the theme name but need to request it remotely\n    loadTheme(theme)\n  } else if (!themeWasRequested && isClient) {\n    // we don't have a discoverable theme, so don't wait for it\n    themeDidLoad()\n  }\n\n  const themePlugin = function themePlugin(node: FormKitNode) {\n    // register the icon handler, and override with local prop value if it exists\n    node.addProps(['iconLoader', 'iconLoaderUrl'])\n    node.props.iconHandler = createIconHandler(\n      node.props?.iconLoader ? node.props.iconLoader : iconLoader,\n      node.props?.iconLoaderUrl ? node.props.iconLoaderUrl : iconLoaderUrl\n    )\n    loadIconPropIcons(node, node.props.iconHandler)\n\n    node.on('created', () => {\n      // set up the `-icon` click handlers\n      if (node?.context?.handlers) {\n        node.context.handlers.iconClick = (\n          sectionKey: string\n        ): ((e: MouseEvent) => void) | void => {\n          const clickHandlerProp = `on${sectionKey\n            .charAt(0)\n            .toUpperCase()}${sectionKey.slice(1)}IconClick`\n          const handlerFunction = node.props[clickHandlerProp]\n          if (handlerFunction && typeof handlerFunction === 'function') {\n            return (e: MouseEvent) => {\n              return handlerFunction(node, e)\n            }\n          }\n          return undefined\n        }\n      }\n      if (node?.context?.fns) {\n        node.context.fns.iconRole = (sectionKey: string): string | null => {\n          const clickHandlerProp = `on${sectionKey\n            .charAt(0)\n            .toUpperCase()}${sectionKey.slice(1)}IconClick`\n          return typeof node.props[clickHandlerProp] === 'function'\n            ? 'button'\n            : null\n        }\n      }\n    })\n  }\n\n  themePlugin.iconHandler = createIconHandler(iconLoader, iconLoaderUrl)\n  return themePlugin\n}\n\n/**\n * Loads a FormKit theme\n */\nfunction loadTheme(theme: string) {\n  if (!theme || !isClient || typeof getComputedStyle !== 'function') {\n    // if we're not client-side then bail\n    return\n  }\n\n  // since we're client-side, flag that we've requested the theme\n  themeWasRequested = true\n\n  documentThemeLinkTag = document.getElementById('formkit-theme')\n\n  // retrieve document styles on plugin creation when the window object exists\n\n  if (\n    theme &&\n    // if we have a window object\n    isClient &&\n    // we don't have an existing theme OR the theme being set up is different\n    ((!documentStyles?.getPropertyValue('--formkit-theme') &&\n      !documentThemeLinkTag) ||\n      (documentThemeLinkTag?.getAttribute('data-theme') &&\n        documentThemeLinkTag?.getAttribute('data-theme') !== theme))\n  ) {\n    // if for some reason we didn't overwrite the __FKV__ token during publish\n    // then use the `latest` tag for CDN fetching. (this applies to local dev as well)\n    const formkitVersion = FORMKIT_VERSION.startsWith('__')\n      ? 'latest'\n      : FORMKIT_VERSION\n    const themeUrl = `https://cdn.jsdelivr.net/npm/@formkit/themes@${formkitVersion}/dist/${theme}/theme.css`\n    const link = document.createElement('link')\n    link.type = 'text/css'\n    link.rel = 'stylesheet'\n    link.id = 'formkit-theme'\n    link.setAttribute('data-theme', theme)\n    link.onload = () => {\n      documentStyles = getComputedStyle(document.documentElement) // grab new variables from theme\n      themeDidLoad()\n    }\n    document.head.appendChild(link)\n    link.href = themeUrl\n    // if we had an existing theme being loaded, remove it.\n    if (documentThemeLinkTag) {\n      documentThemeLinkTag.remove()\n    }\n  }\n}\n\n/**\n * Returns a function responsible for loading an icon by name.\n * @param iconLoader - a function for loading an icon when it's not found in the\n * iconRegistry.\n * @param iconLoaderUrl - a function that returns a remote URL for retrieving an\n * SVG icon by name.\n * @public\n */\nexport function createIconHandler(\n  iconLoader?: FormKitIconLoader,\n  iconLoaderUrl?: FormKitIconLoaderUrl\n): FormKitIconLoader {\n  return (\n    iconName: string | boolean\n  ): string | undefined | Promise<string | undefined> => {\n    // bail if we got something that wasn't string\n    if (typeof iconName !== 'string') return\n    // if we're dealing with an inline SVG, just use it as-is\n    if (iconName.startsWith('<svg')) {\n      return iconName\n    }\n\n    // is this a default icon that should only load from a stylesheet?\n    const isDefault = iconName.startsWith('default:')\n    iconName = isDefault ? iconName.split(':')[1] : iconName\n\n    // check if we've already loaded the icon before\n    const iconWasAlreadyLoaded = iconName in iconRegistry\n\n    let loadedIcon: string | undefined | Promise<string | undefined> = undefined\n\n    if (iconWasAlreadyLoaded) {\n      return iconRegistry[iconName]\n    } else if (!iconRequests[iconName]) {\n      loadedIcon = getIconFromStylesheet(iconName)\n      loadedIcon =\n        isClient && typeof loadedIcon === 'undefined'\n          ? Promise.resolve(loadedIcon)\n          : loadedIcon\n      if (loadedIcon instanceof Promise) {\n        iconRequests[iconName] = loadedIcon\n          .then((iconValue) => {\n            if (!iconValue && typeof iconName === 'string' && !isDefault) {\n              return (loadedIcon =\n                typeof iconLoader === 'function'\n                  ? iconLoader(iconName)\n                  : getRemoteIcon(iconName, iconLoaderUrl))\n            }\n            return iconValue\n          })\n          .then((finalIcon) => {\n            if (typeof iconName === 'string') {\n              iconRegistry[isDefault ? `default:${iconName}` : iconName] =\n                finalIcon\n            }\n            return finalIcon\n          })\n      } else if (typeof loadedIcon === 'string') {\n        iconRegistry[isDefault ? `default:${iconName}` : iconName] = loadedIcon\n        return loadedIcon\n      }\n    }\n    return iconRequests[iconName]\n  }\n}\n\nfunction getIconFromStylesheet(\n  iconName: string\n): string | undefined | Promise<string | undefined> {\n  if (!isClient) return\n  if (themeHasLoaded) {\n    return loadStylesheetIcon(iconName)\n  } else {\n    return themeLoaded.then(() => {\n      return loadStylesheetIcon(iconName)\n    })\n  }\n}\n\nfunction loadStylesheetIcon(iconName: string) {\n  const cssVarIcon = documentStyles?.getPropertyValue(`--fk-icon-${iconName}`)\n  if (cssVarIcon) {\n    // if we have a matching icon in the CSS properties, then decode it\n    const icon: string = atob(cssVarIcon)\n    if (icon.startsWith('<svg')) {\n      iconRegistry[iconName] = icon\n      return icon\n    }\n  }\n  return undefined\n}\n\n/**\n * Attempts to fetch a remote icon from the FormKit CDN\n * @param iconName - The string name of the icon\n * @public\n */\nfunction getRemoteIcon(\n  iconName: string,\n  iconLoaderUrl?: FormKitIconLoaderUrl\n): Promise<string | undefined> | undefined {\n  const formkitVersion = FORMKIT_VERSION.startsWith('__')\n    ? 'latest'\n    : FORMKIT_VERSION\n  const fetchUrl =\n    typeof iconLoaderUrl === 'function'\n      ? iconLoaderUrl(iconName)\n      : `https://cdn.jsdelivr.net/npm/@formkit/icons@${formkitVersion}/dist/icons/${iconName}.svg`\n  if (!isClient) return undefined\n  return fetch(`${fetchUrl}`)\n    .then(async (r) => {\n      const icon = await r.text()\n      if (icon.startsWith('<svg')) {\n        return icon\n      }\n      return undefined\n    })\n    .catch((e) => {\n      console.error(e)\n      return undefined\n    })\n}\n\n/**\n * Loads icons for the matching `-icon` props on a given node\n */\nfunction loadIconPropIcons(\n  node: FormKitNode,\n  iconHandler: FormKitIconLoader\n): void {\n  const iconRegex = /^[a-zA-Z-]+(?:-icon|Icon)$/\n  const iconProps = Object.keys(node.props).filter((prop) => {\n    return iconRegex.test(prop)\n  })\n  iconProps.forEach((sectionKey) => {\n    return loadPropIcon(node, iconHandler, sectionKey)\n  })\n}\n\n/**\n * Loads an icon from an icon-prop declaration eg. suffix-icon=\"settings\"\n */\nfunction loadPropIcon(\n  node: FormKitNode,\n  iconHandler: FormKitIconLoader,\n  sectionKey: string\n): Promise<void> | void {\n  const iconName = node.props[sectionKey]\n  const loadedIcon = iconHandler(iconName)\n  const rawIconProp = `_raw${sectionKey\n    .charAt(0)\n    .toUpperCase()}${sectionKey.slice(1)}`\n  const clickHandlerProp = `on${sectionKey\n    .charAt(0)\n    .toUpperCase()}${sectionKey.slice(1)}Click`\n  node.addProps([rawIconProp, clickHandlerProp])\n  // listen for changes to the icon prop\n  node.on(`prop:${sectionKey}`, reloadIcon)\n  if (loadedIcon instanceof Promise) {\n    return loadedIcon.then((svg) => {\n      node.props[rawIconProp] = svg\n    })\n  } else {\n    node.props[rawIconProp] = loadedIcon\n  }\n  return\n}\n\n/**\n * reloads an icon when the prop value changes\n */\nfunction reloadIcon(event: FormKitEvent): void | Promise<void> {\n  const node = event.origin\n  const iconName = event.payload\n  const iconHandler = node?.props?.iconHandler\n  const sectionKey = event.name.split(':')[1]\n  const rawIconProp = `_raw${sectionKey\n    .charAt(0)\n    .toUpperCase()}${sectionKey.slice(1)}`\n\n  if (iconHandler && typeof iconHandler === 'function') {\n    const loadedIcon = iconHandler(iconName)\n\n    if (loadedIcon instanceof Promise) {\n      return loadedIcon.then((svg) => {\n        node.props[rawIconProp] = svg\n      })\n    } else {\n      node.props[rawIconProp] = loadedIcon\n    }\n  }\n}\n"]}