// ../shared/dist/index.js
var idCounter = 0;
function generateId(prefix = "rfr") {
  idCounter++;
  return `${prefix}-${idCounter}`;
}
var Keys = {
  Enter: "Enter",
  Space: " ",
  Escape: "Escape",
  Tab: "Tab",
  ArrowUp: "ArrowUp",
  ArrowDown: "ArrowDown",
  ArrowLeft: "ArrowLeft",
  ArrowRight: "ArrowRight",
  Home: "Home",
  End: "End",
  PageUp: "PageUp",
  PageDown: "PageDown",
  Backspace: "Backspace",
  Delete: "Delete"
};
function createKeyboardHandler(handlers) {
  return (event) => {
    const handler = handlers[event.key];
    if (handler) {
      handler(event);
    }
  };
}
function createMachine(config) {
  let current = config.initial;
  const listeners = /* @__PURE__ */ new Set();
  return {
    get state() {
      return current;
    },
    send(event) {
      const stateConfig = config.states[current];
      const next = stateConfig?.on?.[event];
      if (next && next !== current) {
        current = next;
        for (const fn of listeners) {
          fn(current);
        }
      }
    },
    subscribe(fn) {
      listeners.add(fn);
      return () => {
        listeners.delete(fn);
      };
    },
    matches(state) {
      return current === state;
    }
  };
}
function cn(...inputs) {
  const classes = [];
  for (const input of inputs) {
    if (!input) continue;
    if (typeof input === "string") {
      classes.push(input);
    } else if (typeof input === "number") {
      classes.push(String(input));
    } else if (Array.isArray(input)) {
      const nested = cn(...input);
      if (nested) classes.push(nested);
    } else if (typeof input === "object") {
      for (const [key, value] of Object.entries(input)) {
        if (value) classes.push(key);
      }
    }
  }
  return classes.join(" ");
}
function cva(config) {
  return (props) => {
    const classes = [];
    if (config.base) {
      classes.push(config.base);
    }
    if (config.variants) {
      for (const [variantKey, variantOptions] of Object.entries(config.variants)) {
        const selectedValue = props?.[variantKey] ?? config.defaultVariants?.[variantKey];
        if (selectedValue != null) {
          const variantClass = variantOptions[selectedValue];
          if (variantClass) {
            classes.push(variantClass);
          }
        }
      }
    }
    if (config.compoundVariants) {
      for (const compound of config.compoundVariants) {
        const { class: compoundClass, ...conditions } = compound;
        let matches = true;
        for (const [key, value] of Object.entries(conditions)) {
          const propValue = props?.[key] ?? config.defaultVariants?.[key];
          if (propValue !== value) {
            matches = false;
            break;
          }
        }
        if (matches) {
          classes.push(compoundClass);
        }
      }
    }
    if (props?.className) {
      classes.push(props.className);
    }
    return classes.filter(Boolean).join(" ");
  };
}
var seen = /* @__PURE__ */ new Set();
function isDev() {
  return typeof process === "undefined" || process.env?.NODE_ENV !== "production";
}
function emit(level, code, message, detail) {
  if (!isDev()) return;
  const key = `${level}:${code}`;
  if (seen.has(key)) return;
  seen.add(key);
  const text = `[refraction-ui] ${code}: ${message}`;
  {
    console.warn(text, detail ?? "");
  }
}
function devWarn(code, message, detail) {
  emit("warn", code, message, detail);
}

export { Keys, cn, createKeyboardHandler, createMachine, cva, devWarn, generateId };
//# sourceMappingURL=chunk-VZLV27H2.js.map
//# sourceMappingURL=chunk-VZLV27H2.js.map