} */
+ value
+ );
+ }
+}
+function useDebounce(callback, wait = 250) {
+ let context = null;
+ function debounced(...args) {
+ if (context) {
+ if (context.timeout) {
+ clearTimeout(context.timeout);
+ }
+ } else {
+ let resolve;
+ let reject;
+ const promise = new Promise((res, rej) => {
+ resolve = res;
+ reject = rej;
+ });
+ context = {
+ timeout: null,
+ runner: null,
+ promise,
+ resolve,
+ reject
+ };
+ }
+ context.runner = async () => {
+ if (!context) return;
+ const ctx = context;
+ context = null;
+ try {
+ ctx.resolve(await callback.apply(this, args));
+ } catch (error) {
+ ctx.reject(error);
+ }
+ };
+ context.timeout = setTimeout(context.runner, typeof wait === "function" ? wait() : wait);
+ return context.promise;
+ }
+ debounced.cancel = async () => {
+ if (!context || context.timeout === null) {
+ await new Promise((resolve) => setTimeout(resolve, 0));
+ if (!context || context.timeout === null) return;
+ }
+ clearTimeout(context.timeout);
+ context.reject("Cancelled");
+ context = null;
+ };
+ debounced.runScheduledNow = async () => {
+ if (!context || !context.timeout) {
+ await new Promise((resolve) => setTimeout(resolve, 0));
+ if (!context || !context.timeout) return;
+ }
+ clearTimeout(context.timeout);
+ context.timeout = null;
+ await context.runner?.();
+ };
+ Object.defineProperty(debounced, "pending", {
+ enumerable: true,
+ get() {
+ return !!context?.timeout;
+ }
+ });
+ return debounced;
+}
+class ElementSize {
+ #size = { width: 0, height: 0 };
+ constructor(node, options = { box: "border-box" }) {
+ options.window ?? defaultWindow;
+ this.#size = {
+ width: options.initialSize?.width ?? 0,
+ height: options.initialSize?.height ?? 0
+ };
+ }
+ get current() {
+ return this.#size;
+ }
+ get width() {
+ return this.#size.width;
+ }
+ get height() {
+ return this.#size.height;
+ }
+}
+class IsMounted {
+ #isMounted = false;
+ constructor() {
+ }
+ get current() {
+ return this.#isMounted;
+ }
+}
+class Previous {
+ #previous = void 0;
+ #curr;
+ constructor(getter) {
+ }
+ get current() {
+ return this.#previous;
+ }
+}
+function afterSleep(ms, cb) {
+ return setTimeout(cb, ms);
+}
+function afterTick(fn) {
+ tick().then(fn);
+}
+function useStateMachine(initialState, machine) {
+ const state = box(initialState);
+ function reducer(event) {
+ const nextState = machine[state.current][event];
+ return nextState ?? state.current;
+ }
+ const dispatch = (event) => {
+ state.current = reducer(event);
+ };
+ return { state, dispatch };
+}
+function usePresence(present, id) {
+ let styles = {};
+ let prevAnimationNameState = "none";
+ const initialState = present.current ? "mounted" : "unmounted";
+ let node = null;
+ const prevPresent = new Previous(() => present.current);
+ watch([() => id.current, () => present.current], ([id2, present2]) => {
+ if (!id2 || !present2) return;
+ afterTick(() => {
+ node = document.getElementById(id2);
+ });
+ });
+ const { state, dispatch } = useStateMachine(initialState, {
+ mounted: {
+ UNMOUNT: "unmounted",
+ ANIMATION_OUT: "unmountSuspended"
+ },
+ unmountSuspended: { MOUNT: "mounted", ANIMATION_END: "unmounted" },
+ unmounted: { MOUNT: "mounted" }
+ });
+ watch(() => present.current, (currPresent) => {
+ if (!node) {
+ node = document.getElementById(id.current);
+ }
+ if (!node) return;
+ const hasPresentChanged = currPresent !== prevPresent.current;
+ if (!hasPresentChanged) return;
+ const prevAnimationName = prevAnimationNameState;
+ const currAnimationName = getAnimationName(node);
+ if (currPresent) {
+ dispatch("MOUNT");
+ } else if (currAnimationName === "none" || styles.display === "none") {
+ dispatch("UNMOUNT");
+ } else {
+ const isAnimating = prevAnimationName !== currAnimationName;
+ if (prevPresent && isAnimating) {
+ dispatch("ANIMATION_OUT");
+ } else {
+ dispatch("UNMOUNT");
+ }
+ }
+ });
+ function handleAnimationEnd(event) {
+ if (!node) node = document.getElementById(id.current);
+ if (!node) return;
+ const currAnimationName = getAnimationName(node);
+ const isCurrentAnimation = currAnimationName.includes(event.animationName) || currAnimationName === "none";
+ if (event.target === node && isCurrentAnimation) {
+ dispatch("ANIMATION_END");
+ }
+ }
+ function handleAnimationStart(event) {
+ if (!node) node = document.getElementById(id.current);
+ if (!node) return;
+ if (event.target === node) {
+ prevAnimationNameState = getAnimationName(node);
+ }
+ }
+ watch(() => state.current, () => {
+ if (!node) node = document.getElementById(id.current);
+ if (!node) return;
+ const currAnimationName = getAnimationName(node);
+ prevAnimationNameState = state.current === "mounted" ? currAnimationName : "none";
+ });
+ watch(() => node, (node2) => {
+ if (!node2) return;
+ styles = getComputedStyle(node2);
+ return executeCallbacks(on(node2, "animationstart", handleAnimationStart), on(node2, "animationcancel", handleAnimationEnd), on(node2, "animationend", handleAnimationEnd));
+ });
+ const isPresentDerived = ["mounted", "unmountSuspended"].includes(state.current);
+ return {
+ get current() {
+ return isPresentDerived;
+ }
+ };
+}
+function getAnimationName(node) {
+ return node ? getComputedStyle(node).animationName || "none" : "none";
+}
+function Presence_layer($$payload, $$props) {
+ push();
+ let { present, forceMount, presence, id } = $$props;
+ const isPresent = usePresence(box.with(() => present), box.with(() => id));
+ if (forceMount || present || isPresent.current) {
+ $$payload.out += "";
+ presence?.($$payload, { present: isPresent });
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ }
+ $$payload.out += ``;
+ pop();
+}
+function createAttrs(variant) {
+ return {
+ content: `data-${variant}-content`,
+ trigger: `data-${variant}-trigger`,
+ overlay: `data-${variant}-overlay`,
+ title: `data-${variant}-title`,
+ description: `data-${variant}-description`,
+ close: `data-${variant}-close`,
+ cancel: `data-${variant}-cancel`,
+ action: `data-${variant}-action`
+ };
+}
+class DialogRootState {
+ opts;
+ triggerNode = null;
+ contentNode = null;
+ descriptionNode = null;
+ contentId = void 0;
+ titleId = void 0;
+ triggerId = void 0;
+ descriptionId = void 0;
+ cancelNode = null;
+ #attrs = derived(() => createAttrs(this.opts.variant.current));
+ get attrs() {
+ return this.#attrs();
+ }
+ set attrs($$value) {
+ return this.#attrs($$value);
+ }
+ constructor(opts) {
+ this.opts = opts;
+ this.handleOpen = this.handleOpen.bind(this);
+ this.handleClose = this.handleClose.bind(this);
+ }
+ handleOpen() {
+ if (this.opts.open.current) return;
+ this.opts.open.current = true;
+ }
+ handleClose() {
+ if (!this.opts.open.current) return;
+ this.opts.open.current = false;
+ }
+ #sharedProps = derived(() => ({
+ "data-state": getDataOpenClosed(this.opts.open.current)
+ }));
+ get sharedProps() {
+ return this.#sharedProps();
+ }
+ set sharedProps($$value) {
+ return this.#sharedProps($$value);
+ }
+}
+class DialogTitleState {
+ opts;
+ root;
+ constructor(opts, root) {
+ this.opts = opts;
+ this.root = root;
+ useRefById({
+ ...opts,
+ onRefChange: (node) => {
+ this.root.titleId = node?.id;
+ },
+ deps: () => this.root.opts.open.current
+ });
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ role: "heading",
+ "aria-level": this.opts.level.current,
+ [this.root.attrs.title]: "",
+ ...this.root.sharedProps
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class DialogDescriptionState {
+ opts;
+ root;
+ constructor(opts, root) {
+ this.opts = opts;
+ this.root = root;
+ useRefById({
+ ...opts,
+ deps: () => this.root.opts.open.current,
+ onRefChange: (node) => {
+ this.root.descriptionNode = node;
+ this.root.descriptionId = node?.id;
+ }
+ });
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ [this.root.attrs.description]: "",
+ ...this.root.sharedProps
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class DialogContentState {
+ opts;
+ root;
+ constructor(opts, root) {
+ this.opts = opts;
+ this.root = root;
+ useRefById({
+ ...opts,
+ deps: () => this.root.opts.open.current,
+ onRefChange: (node) => {
+ this.root.contentNode = node;
+ this.root.contentId = node?.id;
+ }
+ });
+ }
+ #snippetProps = derived(() => ({ open: this.root.opts.open.current }));
+ get snippetProps() {
+ return this.#snippetProps();
+ }
+ set snippetProps($$value) {
+ return this.#snippetProps($$value);
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ role: this.root.opts.variant.current === "alert-dialog" ? "alertdialog" : "dialog",
+ "aria-modal": "true",
+ "aria-describedby": this.root.descriptionId,
+ "aria-labelledby": this.root.titleId,
+ [this.root.attrs.content]: "",
+ style: {
+ pointerEvents: "auto",
+ outline: this.root.opts.variant.current === "alert-dialog" ? "none" : void 0
+ },
+ tabindex: this.root.opts.variant.current === "alert-dialog" ? -1 : void 0,
+ ...this.root.sharedProps
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class DialogOverlayState {
+ opts;
+ root;
+ constructor(opts, root) {
+ this.opts = opts;
+ this.root = root;
+ useRefById({
+ ...opts,
+ deps: () => this.root.opts.open.current
+ });
+ }
+ #snippetProps = derived(() => ({ open: this.root.opts.open.current }));
+ get snippetProps() {
+ return this.#snippetProps();
+ }
+ set snippetProps($$value) {
+ return this.#snippetProps($$value);
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ [this.root.attrs.overlay]: "",
+ style: { pointerEvents: "auto" },
+ ...this.root.sharedProps
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+const DialogRootContext = new Context("Dialog.Root");
+function useDialogRoot(props) {
+ return DialogRootContext.set(new DialogRootState(props));
+}
+function useDialogTitle(props) {
+ return new DialogTitleState(props, DialogRootContext.get());
+}
+function useDialogContent(props) {
+ return new DialogContentState(props, DialogRootContext.get());
+}
+function useDialogOverlay(props) {
+ return new DialogOverlayState(props, DialogRootContext.get());
+}
+function useDialogDescription(props) {
+ return new DialogDescriptionState(props, DialogRootContext.get());
+}
+function Dialog_title($$payload, $$props) {
+ push();
+ let {
+ id = useId$1(),
+ ref = null,
+ child,
+ children,
+ level = 2,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const titleState = useDialogTitle({
+ id: box.with(() => id),
+ level: box.with(() => level),
+ ref: box.with(() => ref, (v) => ref = v)
+ });
+ const mergedProps = mergeProps(restProps, titleState.props);
+ if (child) {
+ $$payload.out += "";
+ child($$payload, { props: mergedProps });
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ $$payload.out += ``;
+ children?.($$payload);
+ $$payload.out += `
`;
+ }
+ $$payload.out += ``;
+ bind_props($$props, { ref });
+ pop();
+}
+function Portal($$payload, $$props) {
+ push();
+ let { to = "body", children, disabled } = $$props;
+ getAllContexts();
+ let target = getTarget();
+ function getTarget() {
+ if (!isBrowser$1 || disabled) return null;
+ let localTarget = null;
+ if (typeof to === "string") {
+ localTarget = document.querySelector(to);
+ } else if (to instanceof HTMLElement || to instanceof DocumentFragment) {
+ localTarget = to;
+ } else ;
+ return localTarget;
+ }
+ let instance;
+ function unmountInstance() {
+ if (instance) {
+ unmount();
+ instance = null;
+ }
+ }
+ watch([() => target, () => disabled], ([target2, disabled2]) => {
+ if (!target2 || disabled2) {
+ unmountInstance();
+ return;
+ }
+ instance = mount();
+ return () => {
+ unmountInstance();
+ };
+ });
+ if (disabled) {
+ $$payload.out += "";
+ children?.($$payload);
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ }
+ $$payload.out += ``;
+ pop();
+}
+function addEventListener(target, event, handler, options) {
+ const events = Array.isArray(event) ? event : [event];
+ events.forEach((_event) => target.addEventListener(_event, handler, options));
+ return () => {
+ events.forEach((_event) => target.removeEventListener(_event, handler, options));
+ };
+}
+class CustomEventDispatcher {
+ eventName;
+ options;
+ constructor(eventName, options = { bubbles: true, cancelable: true }) {
+ this.eventName = eventName;
+ this.options = options;
+ }
+ createEvent(detail) {
+ return new CustomEvent(this.eventName, {
+ ...this.options,
+ detail
+ });
+ }
+ dispatch(element2, detail) {
+ const event = this.createEvent(detail);
+ element2.dispatchEvent(event);
+ return event;
+ }
+ listen(element2, callback, options) {
+ const handler = (event) => {
+ callback(event);
+ };
+ return on(element2, this.eventName, handler, options);
+ }
+}
+function debounce(fn, wait = 500) {
+ let timeout = null;
+ const debounced = (...args) => {
+ if (timeout !== null) {
+ clearTimeout(timeout);
+ }
+ timeout = setTimeout(() => {
+ fn(...args);
+ }, wait);
+ };
+ debounced.destroy = () => {
+ if (timeout !== null) {
+ clearTimeout(timeout);
+ timeout = null;
+ }
+ };
+ return debounced;
+}
+function isOrContainsTarget(node, target) {
+ return node === target || node.contains(target);
+}
+function getOwnerDocument(el) {
+ return el?.ownerDocument ?? document;
+}
+function getFirstNonCommentChild(element2) {
+ if (!element2)
+ return null;
+ for (const child of element2.childNodes) {
+ if (child.nodeType !== Node.COMMENT_NODE) {
+ return child;
+ }
+ }
+ return null;
+}
+function isClickTrulyOutside(event, contentNode) {
+ const { clientX, clientY } = event;
+ const rect = contentNode.getBoundingClientRect();
+ return clientX < rect.left || clientX > rect.right || clientY < rect.top || clientY > rect.bottom;
+}
+globalThis.bitsDismissableLayers ??= /* @__PURE__ */ new Map();
+class DismissibleLayerState {
+ opts;
+ #interactOutsideProp;
+ #behaviorType;
+ #interceptedEvents = { pointerdown: false };
+ #isResponsibleLayer = false;
+ #isFocusInsideDOMTree = false;
+ node = box(null);
+ #documentObj = void 0;
+ #onFocusOutside;
+ currNode = null;
+ #unsubClickListener = noop$1;
+ constructor(opts) {
+ this.opts = opts;
+ useRefById({
+ id: opts.id,
+ ref: this.node,
+ deps: () => opts.enabled.current,
+ onRefChange: (node) => {
+ this.currNode = node;
+ }
+ });
+ this.#behaviorType = opts.interactOutsideBehavior;
+ this.#interactOutsideProp = opts.onInteractOutside;
+ this.#onFocusOutside = opts.onFocusOutside;
+ let unsubEvents = noop$1;
+ const cleanup = () => {
+ this.#resetState();
+ globalThis.bitsDismissableLayers.delete(this);
+ this.#handleInteractOutside.destroy();
+ unsubEvents();
+ };
+ watch(
+ [
+ () => this.opts.enabled.current,
+ () => this.currNode
+ ],
+ ([enabled, currNode]) => {
+ if (!enabled || !currNode) return;
+ afterSleep(1, () => {
+ if (!this.currNode) return;
+ globalThis.bitsDismissableLayers.set(this, this.#behaviorType);
+ unsubEvents();
+ unsubEvents = this.#addEventListeners();
+ });
+ return cleanup;
+ }
+ );
+ }
+ #handleFocus = (event) => {
+ if (event.defaultPrevented) return;
+ if (!this.currNode) return;
+ afterTick(() => {
+ if (!this.currNode || this.#isTargetWithinLayer(event.target)) return;
+ if (event.target && !this.#isFocusInsideDOMTree) {
+ this.#onFocusOutside.current?.(event);
+ }
+ });
+ };
+ #addEventListeners() {
+ return executeCallbacks(
+ /**
+ * CAPTURE INTERACTION START
+ * mark interaction-start event as intercepted.
+ * mark responsible layer during interaction start
+ * to avoid checking if is responsible layer during interaction end
+ * when a new floating element may have been opened.
+ */
+ on(this.#documentObj, "pointerdown", executeCallbacks(this.#markInterceptedEvent, this.#markResponsibleLayer), { capture: true }),
+ /**
+ * BUBBLE INTERACTION START
+ * Mark interaction-start event as non-intercepted. Debounce `onInteractOutsideStart`
+ * to avoid prematurely checking if other events were intercepted.
+ */
+ on(this.#documentObj, "pointerdown", executeCallbacks(this.#markNonInterceptedEvent, this.#handleInteractOutside)),
+ /**
+ * HANDLE FOCUS OUTSIDE
+ */
+ on(this.#documentObj, "focusin", this.#handleFocus)
+ );
+ }
+ #handleDismiss = (e) => {
+ let event = e;
+ if (event.defaultPrevented) {
+ event = createWrappedEvent(e);
+ }
+ this.#interactOutsideProp.current(e);
+ };
+ #handleInteractOutside = debounce(
+ (e) => {
+ if (!this.currNode) {
+ this.#unsubClickListener();
+ return;
+ }
+ const isEventValid = this.opts.isValidEvent.current(e, this.currNode) || isValidEvent(e, this.currNode);
+ if (!this.#isResponsibleLayer || this.#isAnyEventIntercepted() || !isEventValid) {
+ this.#unsubClickListener();
+ return;
+ }
+ let event = e;
+ if (event.defaultPrevented) {
+ event = createWrappedEvent(event);
+ }
+ if (this.#behaviorType.current !== "close" && this.#behaviorType.current !== "defer-otherwise-close") {
+ this.#unsubClickListener();
+ return;
+ }
+ if (e.pointerType === "touch") {
+ this.#unsubClickListener();
+ this.#unsubClickListener = addEventListener(this.#documentObj, "click", this.#handleDismiss, { once: true });
+ } else {
+ this.#interactOutsideProp.current(event);
+ }
+ },
+ 10
+ );
+ #markInterceptedEvent = (e) => {
+ this.#interceptedEvents[e.type] = true;
+ };
+ #markNonInterceptedEvent = (e) => {
+ this.#interceptedEvents[e.type] = false;
+ };
+ #markResponsibleLayer = () => {
+ if (!this.node.current) return;
+ this.#isResponsibleLayer = isResponsibleLayer(this.node.current);
+ };
+ #isTargetWithinLayer = (target) => {
+ if (!this.node.current) return false;
+ return isOrContainsTarget(this.node.current, target);
+ };
+ #resetState = debounce(
+ () => {
+ for (const eventType in this.#interceptedEvents) {
+ this.#interceptedEvents[eventType] = false;
+ }
+ this.#isResponsibleLayer = false;
+ },
+ 20
+ );
+ #isAnyEventIntercepted() {
+ const i = Object.values(this.#interceptedEvents).some(Boolean);
+ return i;
+ }
+ #onfocuscapture = () => {
+ this.#isFocusInsideDOMTree = true;
+ };
+ #onblurcapture = () => {
+ this.#isFocusInsideDOMTree = false;
+ };
+ props = {
+ onfocuscapture: this.#onfocuscapture,
+ onblurcapture: this.#onblurcapture
+ };
+}
+function useDismissibleLayer(props) {
+ return new DismissibleLayerState(props);
+}
+function getTopMostLayer(layersArr) {
+ return layersArr.findLast(([_, { current: behaviorType }]) => behaviorType === "close" || behaviorType === "ignore");
+}
+function isResponsibleLayer(node) {
+ const layersArr = [...globalThis.bitsDismissableLayers];
+ const topMostLayer = getTopMostLayer(layersArr);
+ if (topMostLayer) return topMostLayer[0].node.current === node;
+ const [firstLayerNode] = layersArr[0];
+ return firstLayerNode.node.current === node;
+}
+function isValidEvent(e, node) {
+ if ("button" in e && e.button > 0) return false;
+ const target = e.target;
+ if (!isElement(target)) return false;
+ const ownerDocument = getOwnerDocument(target);
+ const isValid = ownerDocument.documentElement.contains(target) && !isOrContainsTarget(node, target) && isClickTrulyOutside(e, node);
+ return isValid;
+}
+function createWrappedEvent(e) {
+ const capturedCurrentTarget = e.currentTarget;
+ const capturedTarget = e.target;
+ let newEvent;
+ if (e instanceof PointerEvent) {
+ newEvent = new PointerEvent(e.type, e);
+ } else {
+ newEvent = new PointerEvent("pointerdown", e);
+ }
+ let isPrevented = false;
+ const wrappedEvent = new Proxy(newEvent, {
+ get: (target, prop) => {
+ if (prop === "currentTarget") {
+ return capturedCurrentTarget;
+ }
+ if (prop === "target") {
+ return capturedTarget;
+ }
+ if (prop === "preventDefault") {
+ return () => {
+ isPrevented = true;
+ if (typeof target.preventDefault === "function") {
+ target.preventDefault();
+ }
+ };
+ }
+ if (prop === "defaultPrevented") {
+ return isPrevented;
+ }
+ if (prop in target) {
+ return target[prop];
+ }
+ return e[prop];
+ }
+ });
+ return wrappedEvent;
+}
+function Dismissible_layer($$payload, $$props) {
+ push();
+ let {
+ interactOutsideBehavior = "close",
+ onInteractOutside = noop$1,
+ onFocusOutside = noop$1,
+ id,
+ children,
+ enabled,
+ isValidEvent: isValidEvent2 = () => false
+ } = $$props;
+ const dismissibleLayerState = useDismissibleLayer({
+ id: box.with(() => id),
+ interactOutsideBehavior: box.with(() => interactOutsideBehavior),
+ onInteractOutside: box.with(() => onInteractOutside),
+ enabled: box.with(() => enabled),
+ onFocusOutside: box.with(() => onFocusOutside),
+ isValidEvent: box.with(() => isValidEvent2)
+ });
+ children?.($$payload, { props: dismissibleLayerState.props });
+ $$payload.out += ``;
+ pop();
+}
+globalThis.bitsEscapeLayers ??= /* @__PURE__ */ new Map();
+class EscapeLayerState {
+ opts;
+ constructor(opts) {
+ this.opts = opts;
+ let unsubEvents = noop$1;
+ watch(() => opts.enabled.current, (enabled) => {
+ if (enabled) {
+ globalThis.bitsEscapeLayers.set(this, opts.escapeKeydownBehavior);
+ unsubEvents = this.#addEventListener();
+ }
+ return () => {
+ unsubEvents();
+ globalThis.bitsEscapeLayers.delete(this);
+ };
+ });
+ }
+ #addEventListener = () => {
+ return on(document, "keydown", this.#onkeydown, { passive: false });
+ };
+ #onkeydown = (e) => {
+ if (e.key !== ESCAPE || !isResponsibleEscapeLayer(this)) return;
+ const clonedEvent = new KeyboardEvent(e.type, e);
+ e.preventDefault();
+ const behaviorType = this.opts.escapeKeydownBehavior.current;
+ if (behaviorType !== "close" && behaviorType !== "defer-otherwise-close") return;
+ this.opts.onEscapeKeydown.current(clonedEvent);
+ };
+}
+function useEscapeLayer(props) {
+ return new EscapeLayerState(props);
+}
+function isResponsibleEscapeLayer(instance) {
+ const layersArr = [...globalThis.bitsEscapeLayers];
+ const topMostLayer = layersArr.findLast(([_, { current: behaviorType }]) => behaviorType === "close" || behaviorType === "ignore");
+ if (topMostLayer) return topMostLayer[0] === instance;
+ const [firstLayerNode] = layersArr[0];
+ return firstLayerNode === instance;
+}
+function Escape_layer($$payload, $$props) {
+ push();
+ let {
+ escapeKeydownBehavior = "close",
+ onEscapeKeydown = noop$1,
+ children,
+ enabled
+ } = $$props;
+ useEscapeLayer({
+ escapeKeydownBehavior: box.with(() => escapeKeydownBehavior),
+ onEscapeKeydown: box.with(() => onEscapeKeydown),
+ enabled: box.with(() => enabled)
+ });
+ children?.($$payload);
+ $$payload.out += ``;
+ pop();
+}
+const focusStack = box([]);
+function createFocusScopeStack() {
+ return {
+ add(focusScope) {
+ const activeFocusScope = focusStack.current[0];
+ if (activeFocusScope && focusScope.id !== activeFocusScope.id) {
+ activeFocusScope.pause();
+ }
+ focusStack.current = removeFromFocusScopeArray(focusStack.current, focusScope);
+ focusStack.current.unshift(focusScope);
+ },
+ remove(focusScope) {
+ focusStack.current = removeFromFocusScopeArray(focusStack.current, focusScope);
+ focusStack.current[0]?.resume();
+ },
+ get current() {
+ return focusStack.current;
+ }
+ };
+}
+function createFocusScopeAPI() {
+ let paused = false;
+ let isHandlingFocus = false;
+ return {
+ id: useId$1(),
+ get paused() {
+ return paused;
+ },
+ get isHandlingFocus() {
+ return isHandlingFocus;
+ },
+ set isHandlingFocus(value) {
+ isHandlingFocus = value;
+ },
+ pause() {
+ paused = true;
+ },
+ resume() {
+ paused = false;
+ }
+ };
+}
+function removeFromFocusScopeArray(arr, item) {
+ return [...arr].filter((i) => i.id !== item.id);
+}
+function removeLinks(items) {
+ return items.filter((item) => item.tagName !== "A");
+}
+function focus(element2, { select = false } = {}) {
+ if (!(element2 && element2.focus))
+ return;
+ if (document.activeElement === element2)
+ return;
+ const previouslyFocusedElement = document.activeElement;
+ element2.focus({ preventScroll: true });
+ if (element2 !== previouslyFocusedElement && isSelectableInput(element2) && select) {
+ element2.select();
+ }
+}
+function focusFirst(candidates, { select = false } = {}) {
+ const previouslyFocusedElement = document.activeElement;
+ for (const candidate of candidates) {
+ focus(candidate, { select });
+ if (document.activeElement !== previouslyFocusedElement)
+ return true;
+ }
+}
+function findVisible(elements, container) {
+ for (const element2 of elements) {
+ if (!isElementHidden(element2, container))
+ return element2;
+ }
+}
+function getTabbableCandidates(container) {
+ const nodes = [];
+ const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ acceptNode: (node) => {
+ const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
+ if (node.disabled || node.hidden || isHiddenInput)
+ return NodeFilter.FILTER_SKIP;
+ return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
+ }
+ });
+ while (walker.nextNode())
+ nodes.push(walker.currentNode);
+ return nodes;
+}
+function getTabbableEdges(container) {
+ const candidates = getTabbableCandidates(container);
+ const first = findVisible(candidates, container);
+ const last = findVisible(candidates.reverse(), container);
+ return [first, last];
+}
+const AutoFocusOnMountEvent = new CustomEventDispatcher("focusScope.autoFocusOnMount", { bubbles: false, cancelable: true });
+const AutoFocusOnDestroyEvent = new CustomEventDispatcher("focusScope.autoFocusOnDestroy", { bubbles: false, cancelable: true });
+const FocusScopeContext = new Context("FocusScope");
+function useFocusScope({
+ id,
+ loop,
+ enabled,
+ onOpenAutoFocus,
+ onCloseAutoFocus,
+ forceMount
+}) {
+ const focusScopeStack = createFocusScopeStack();
+ const focusScope = createFocusScopeAPI();
+ const ref = box(null);
+ const ctx = FocusScopeContext.getOr({ ignoreCloseAutoFocus: false });
+ let lastFocusedElement = null;
+ useRefById({ id, ref, deps: () => enabled.current });
+ function manageFocus(event) {
+ if (focusScope.paused || !ref.current || focusScope.isHandlingFocus) return;
+ focusScope.isHandlingFocus = true;
+ try {
+ const target = event.target;
+ if (!isHTMLElement(target)) return;
+ const isWithinActiveScope = ref.current.contains(target);
+ if (event.type === "focusin") {
+ if (isWithinActiveScope) {
+ lastFocusedElement = target;
+ } else {
+ if (ctx.ignoreCloseAutoFocus) return;
+ focus(lastFocusedElement, { select: true });
+ }
+ } else if (event.type === "focusout") {
+ if (!isWithinActiveScope && !ctx.ignoreCloseAutoFocus) {
+ focus(lastFocusedElement, { select: true });
+ }
+ }
+ } finally {
+ focusScope.isHandlingFocus = false;
+ }
+ }
+ function handleMutations(mutations) {
+ if (!lastFocusedElement || !ref.current) return;
+ let elementWasRemoved = false;
+ for (const mutation of mutations) {
+ if (mutation.type === "childList" && mutation.removedNodes.length > 0) {
+ for (const removedNode of mutation.removedNodes) {
+ if (removedNode === lastFocusedElement) {
+ elementWasRemoved = true;
+ break;
+ }
+ if (removedNode.nodeType === Node.ELEMENT_NODE && removedNode.contains(lastFocusedElement)) {
+ elementWasRemoved = true;
+ break;
+ }
+ }
+ }
+ if (elementWasRemoved) break;
+ }
+ if (elementWasRemoved && ref.current && !ref.current.contains(document.activeElement)) {
+ focus(ref.current);
+ }
+ }
+ watch([() => ref.current, () => enabled.current], ([container, enabled2]) => {
+ if (!container || !enabled2) return;
+ const removeEvents = executeCallbacks(on(document, "focusin", manageFocus), on(document, "focusout", manageFocus));
+ const mutationObserver = new MutationObserver(handleMutations);
+ mutationObserver.observe(container, {
+ childList: true,
+ subtree: true,
+ attributes: false
+ });
+ return () => {
+ removeEvents();
+ mutationObserver.disconnect();
+ };
+ });
+ watch([() => forceMount.current, () => ref.current], ([forceMount2, container]) => {
+ if (forceMount2) return;
+ const prevFocusedElement = document.activeElement;
+ handleOpen(container, prevFocusedElement);
+ return () => {
+ if (!container) return;
+ handleClose(prevFocusedElement);
+ };
+ });
+ watch(
+ [
+ () => forceMount.current,
+ () => ref.current,
+ () => enabled.current
+ ],
+ ([forceMount2, container]) => {
+ if (!forceMount2) return;
+ const prevFocusedElement = document.activeElement;
+ handleOpen(container, prevFocusedElement);
+ return () => {
+ if (!container) return;
+ handleClose(prevFocusedElement);
+ };
+ }
+ );
+ function handleOpen(container, prevFocusedElement) {
+ if (!container) container = document.getElementById(id.current);
+ if (!container || !enabled.current) return;
+ focusScopeStack.add(focusScope);
+ const hasFocusedCandidate = container.contains(prevFocusedElement);
+ if (!hasFocusedCandidate) {
+ const mountEvent = AutoFocusOnMountEvent.createEvent();
+ onOpenAutoFocus.current(mountEvent);
+ if (!mountEvent.defaultPrevented) {
+ afterTick(() => {
+ if (!container) return;
+ const result = focusFirst(removeLinks(getTabbableCandidates(container)), { select: true });
+ if (!result) focus(container);
+ });
+ }
+ }
+ }
+ function handleClose(prevFocusedElement) {
+ const destroyEvent = AutoFocusOnDestroyEvent.createEvent();
+ onCloseAutoFocus.current?.(destroyEvent);
+ const shouldIgnore = ctx.ignoreCloseAutoFocus;
+ afterSleep(0, () => {
+ if (!destroyEvent.defaultPrevented && prevFocusedElement && !shouldIgnore) {
+ focus(isTabbable(prevFocusedElement) ? prevFocusedElement : document.body, { select: true });
+ }
+ focusScopeStack.remove(focusScope);
+ });
+ }
+ function handleKeydown(e) {
+ if (!enabled.current) return;
+ if (!loop.current && !enabled.current) return;
+ if (focusScope.paused) return;
+ const isTabKey = e.key === TAB && !e.ctrlKey && !e.altKey && !e.metaKey;
+ const focusedElement = document.activeElement;
+ if (!(isTabKey && focusedElement)) return;
+ const container = ref.current;
+ if (!container) return;
+ const [first, last] = getTabbableEdges(container);
+ const hasTabbableElementsInside = first && last;
+ if (!hasTabbableElementsInside) {
+ if (focusedElement === container) {
+ e.preventDefault();
+ }
+ } else {
+ if (!e.shiftKey && focusedElement === last) {
+ e.preventDefault();
+ if (loop.current) focus(first, { select: true });
+ } else if (e.shiftKey && focusedElement === first) {
+ e.preventDefault();
+ if (loop.current) focus(last, { select: true });
+ }
+ }
+ }
+ const props = (() => ({
+ id: id.current,
+ tabindex: -1,
+ onkeydown: handleKeydown
+ }))();
+ return {
+ get props() {
+ return props;
+ }
+ };
+}
+function Focus_scope($$payload, $$props) {
+ push();
+ let {
+ id,
+ trapFocus = false,
+ loop = false,
+ onCloseAutoFocus = noop$1,
+ onOpenAutoFocus = noop$1,
+ focusScope,
+ forceMount = false
+ } = $$props;
+ const focusScopeState = useFocusScope({
+ enabled: box.with(() => trapFocus),
+ loop: box.with(() => loop),
+ onCloseAutoFocus: box.with(() => onCloseAutoFocus),
+ onOpenAutoFocus: box.with(() => onOpenAutoFocus),
+ id: box.with(() => id),
+ forceMount: box.with(() => forceMount)
+ });
+ focusScope?.($$payload, { props: focusScopeState.props });
+ $$payload.out += ``;
+ pop();
+}
+globalThis.bitsTextSelectionLayers ??= /* @__PURE__ */ new Map();
+class TextSelectionLayerState {
+ opts;
+ #unsubSelectionLock = noop$1;
+ #ref = box(null);
+ constructor(opts) {
+ this.opts = opts;
+ useRefById({
+ id: opts.id,
+ ref: this.#ref,
+ deps: () => this.opts.enabled.current
+ });
+ let unsubEvents = noop$1;
+ watch(() => this.opts.enabled.current, (isEnabled) => {
+ if (isEnabled) {
+ globalThis.bitsTextSelectionLayers.set(this, this.opts.enabled);
+ unsubEvents();
+ unsubEvents = this.#addEventListeners();
+ }
+ return () => {
+ unsubEvents();
+ this.#resetSelectionLock();
+ globalThis.bitsTextSelectionLayers.delete(this);
+ };
+ });
+ }
+ #addEventListeners() {
+ return executeCallbacks(on(document, "pointerdown", this.#pointerdown), on(document, "pointerup", composeHandlers(this.#resetSelectionLock, this.opts.onPointerUp.current)));
+ }
+ #pointerdown = (e) => {
+ const node = this.#ref.current;
+ const target = e.target;
+ if (!isHTMLElement(node) || !isHTMLElement(target) || !this.opts.enabled.current) return;
+ if (!isHighestLayer(this) || !isOrContainsTarget(node, target)) return;
+ this.opts.onPointerDown.current(e);
+ if (e.defaultPrevented) return;
+ this.#unsubSelectionLock = preventTextSelectionOverflow(node);
+ };
+ #resetSelectionLock = () => {
+ this.#unsubSelectionLock();
+ this.#unsubSelectionLock = noop$1;
+ };
+}
+function useTextSelectionLayer(props) {
+ return new TextSelectionLayerState(props);
+}
+const getUserSelect = (node) => node.style.userSelect || node.style.webkitUserSelect;
+function preventTextSelectionOverflow(node) {
+ const body = document.body;
+ const originalBodyUserSelect = getUserSelect(body);
+ const originalNodeUserSelect = getUserSelect(node);
+ setUserSelect(body, "none");
+ setUserSelect(node, "text");
+ return () => {
+ setUserSelect(body, originalBodyUserSelect);
+ setUserSelect(node, originalNodeUserSelect);
+ };
+}
+function setUserSelect(node, value) {
+ node.style.userSelect = value;
+ node.style.webkitUserSelect = value;
+}
+function isHighestLayer(instance) {
+ const layersArr = [...globalThis.bitsTextSelectionLayers];
+ if (!layersArr.length) return false;
+ const highestLayer = layersArr.at(-1);
+ if (!highestLayer) return false;
+ return highestLayer[0] === instance;
+}
+function Text_selection_layer($$payload, $$props) {
+ push();
+ let {
+ preventOverflowTextSelection = true,
+ onPointerDown = noop$1,
+ onPointerUp = noop$1,
+ id,
+ children,
+ enabled
+ } = $$props;
+ useTextSelectionLayer({
+ id: box.with(() => id),
+ onPointerDown: box.with(() => onPointerDown),
+ onPointerUp: box.with(() => onPointerUp),
+ enabled: box.with(() => enabled && preventOverflowTextSelection)
+ });
+ children?.($$payload);
+ $$payload.out += ``;
+ pop();
+}
+function createSharedHook(factory) {
+ let state = void 0;
+ return (...args) => {
+ return state;
+ };
+}
+const useBodyLockStackCount = createSharedHook();
+function useBodyScrollLock(initialState, restoreScrollDelay = () => null) {
+ useId$1();
+ useBodyLockStackCount();
+ return;
+}
+function Scroll_lock($$payload, $$props) {
+ push();
+ let {
+ preventScroll = true,
+ restoreScrollDelay = null
+ } = $$props;
+ useBodyScrollLock(preventScroll, () => restoreScrollDelay);
+ pop();
+}
+function shouldTrapFocus({ forceMount, present, trapFocus, open }) {
+ if (forceMount) {
+ return open && trapFocus;
+ }
+ return present && trapFocus && open;
+}
+function Dialog_overlay($$payload, $$props) {
+ push();
+ let {
+ id = useId$1(),
+ forceMount = false,
+ child,
+ children,
+ ref = null,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const overlayState = useDialogOverlay({
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v)
+ });
+ const mergedProps = mergeProps(restProps, overlayState.props);
+ {
+ let presence = function($$payload2) {
+ if (child) {
+ $$payload2.out += "";
+ child($$payload2, {
+ props: mergeProps(mergedProps),
+ ...overlayState.snippetProps
+ });
+ $$payload2.out += ``;
+ } else {
+ $$payload2.out += "";
+ $$payload2.out += ``;
+ children?.($$payload2, overlayState.snippetProps);
+ $$payload2.out += `
`;
+ }
+ $$payload2.out += ``;
+ };
+ Presence_layer($$payload, {
+ id,
+ present: overlayState.root.opts.open.current || forceMount,
+ presence
+ });
+ }
+ bind_props($$props, { ref });
+ pop();
+}
+function Dialog_description($$payload, $$props) {
+ push();
+ let {
+ id = useId$1(),
+ children,
+ child,
+ ref = null,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const descriptionState = useDialogDescription({
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v)
+ });
+ const mergedProps = mergeProps(restProps, descriptionState.props);
+ if (child) {
+ $$payload.out += "";
+ child($$payload, { props: mergedProps });
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ $$payload.out += ``;
+ children?.($$payload);
+ $$payload.out += `
`;
+ }
+ $$payload.out += ``;
+ bind_props($$props, { ref });
+ pop();
+}
+function get(valueOrGetValue) {
+ return typeof valueOrGetValue === "function" ? valueOrGetValue() : valueOrGetValue;
+}
+function getDPR(element2) {
+ if (typeof window === "undefined") return 1;
+ const win = element2.ownerDocument.defaultView || window;
+ return win.devicePixelRatio || 1;
+}
+function roundByDPR(element2, value) {
+ const dpr = getDPR(element2);
+ return Math.round(value * dpr) / dpr;
+}
+function getFloatingContentCSSVars(name) {
+ return {
+ [`--bits-${name}-content-transform-origin`]: `var(--bits-floating-transform-origin)`,
+ [`--bits-${name}-content-available-width`]: `var(--bits-floating-available-width)`,
+ [`--bits-${name}-content-available-height`]: `var(--bits-floating-available-height)`,
+ [`--bits-${name}-anchor-width`]: `var(--bits-floating-anchor-width)`,
+ [`--bits-${name}-anchor-height`]: `var(--bits-floating-anchor-height)`
+ };
+}
+function useFloating(options) {
+ get(options.open) ?? true;
+ const middlewareOption = get(options.middleware);
+ const transformOption = get(options.transform) ?? true;
+ const placementOption = get(options.placement) ?? "bottom";
+ const strategyOption = get(options.strategy) ?? "absolute";
+ const reference = options.reference;
+ let x = 0;
+ let y = 0;
+ const floating = box(null);
+ let strategy = strategyOption;
+ let placement = placementOption;
+ let middlewareData = {};
+ let isPositioned = false;
+ const floatingStyles = (() => {
+ const initialStyles = { position: strategy, left: "0", top: "0" };
+ if (!floating.current) {
+ return initialStyles;
+ }
+ const xVal = roundByDPR(floating.current, x);
+ const yVal = roundByDPR(floating.current, y);
+ if (transformOption) {
+ return {
+ ...initialStyles,
+ transform: `translate(${xVal}px, ${yVal}px)`,
+ ...getDPR(floating.current) >= 1.5 && { willChange: "transform" }
+ };
+ }
+ return {
+ position: strategy,
+ left: `${xVal}px`,
+ top: `${yVal}px`
+ };
+ })();
+ function update() {
+ if (reference.current === null || floating.current === null) return;
+ computePosition(reference.current, floating.current, {
+ middleware: middlewareOption,
+ placement: placementOption,
+ strategy: strategyOption
+ }).then((position) => {
+ x = position.x;
+ y = position.y;
+ strategy = position.strategy;
+ placement = position.placement;
+ middlewareData = position.middlewareData;
+ isPositioned = true;
+ });
+ }
+ return {
+ floating,
+ reference,
+ get strategy() {
+ return strategy;
+ },
+ get placement() {
+ return placement;
+ },
+ get middlewareData() {
+ return middlewareData;
+ },
+ get isPositioned() {
+ return isPositioned;
+ },
+ get floatingStyles() {
+ return floatingStyles;
+ },
+ get update() {
+ return update;
+ }
+ };
+}
+const OPPOSITE_SIDE = {
+ top: "bottom",
+ right: "left",
+ bottom: "top",
+ left: "right"
+};
+class FloatingRootState {
+ anchorNode = box(null);
+ customAnchorNode = box(null);
+ triggerNode = box(null);
+ constructor() {
+ }
+}
+class FloatingContentState {
+ opts;
+ root;
+ // nodes
+ contentRef = box(null);
+ wrapperRef = box(null);
+ arrowRef = box(null);
+ // ids
+ arrowId = box(useId$1());
+ #transformedStyle = derived(() => {
+ if (typeof this.opts.style === "string") return cssToStyleObj(this.opts.style);
+ if (!this.opts.style) return {};
+ });
+ #updatePositionStrategy = void 0;
+ #arrowSize = new ElementSize(() => this.arrowRef.current ?? void 0);
+ #arrowWidth = derived(() => this.#arrowSize?.width ?? 0);
+ #arrowHeight = derived(() => this.#arrowSize?.height ?? 0);
+ #desiredPlacement = derived(() => this.opts.side?.current + (this.opts.align.current !== "center" ? `-${this.opts.align.current}` : ""));
+ #boundary = derived(() => Array.isArray(this.opts.collisionBoundary.current) ? this.opts.collisionBoundary.current : [this.opts.collisionBoundary.current]);
+ #hasExplicitBoundaries = derived(() => this.#boundary().length > 0);
+ get hasExplicitBoundaries() {
+ return this.#hasExplicitBoundaries();
+ }
+ set hasExplicitBoundaries($$value) {
+ return this.#hasExplicitBoundaries($$value);
+ }
+ #detectOverflowOptions = derived(() => ({
+ padding: this.opts.collisionPadding.current,
+ boundary: this.#boundary().filter(isNotNull),
+ altBoundary: this.hasExplicitBoundaries
+ }));
+ get detectOverflowOptions() {
+ return this.#detectOverflowOptions();
+ }
+ set detectOverflowOptions($$value) {
+ return this.#detectOverflowOptions($$value);
+ }
+ #availableWidth = void 0;
+ #availableHeight = void 0;
+ #anchorWidth = void 0;
+ #anchorHeight = void 0;
+ #middleware = derived(() => [
+ offset({
+ mainAxis: this.opts.sideOffset.current + this.#arrowHeight(),
+ alignmentAxis: this.opts.alignOffset.current
+ }),
+ this.opts.avoidCollisions.current && shift({
+ mainAxis: true,
+ crossAxis: false,
+ limiter: this.opts.sticky.current === "partial" ? limitShift() : void 0,
+ ...this.detectOverflowOptions
+ }),
+ this.opts.avoidCollisions.current && flip({ ...this.detectOverflowOptions }),
+ size({
+ ...this.detectOverflowOptions,
+ apply: ({ rects, availableWidth, availableHeight }) => {
+ const { width: anchorWidth, height: anchorHeight } = rects.reference;
+ this.#availableWidth = availableWidth;
+ this.#availableHeight = availableHeight;
+ this.#anchorWidth = anchorWidth;
+ this.#anchorHeight = anchorHeight;
+ }
+ }),
+ this.arrowRef.current && arrow({
+ element: this.arrowRef.current,
+ padding: this.opts.arrowPadding.current
+ }),
+ transformOrigin({
+ arrowWidth: this.#arrowWidth(),
+ arrowHeight: this.#arrowHeight()
+ }),
+ this.opts.hideWhenDetached.current && hide({
+ strategy: "referenceHidden",
+ ...this.detectOverflowOptions
+ })
+ ].filter(Boolean));
+ get middleware() {
+ return this.#middleware();
+ }
+ set middleware($$value) {
+ return this.#middleware($$value);
+ }
+ floating;
+ #placedSide = derived(() => getSideFromPlacement(this.floating.placement));
+ get placedSide() {
+ return this.#placedSide();
+ }
+ set placedSide($$value) {
+ return this.#placedSide($$value);
+ }
+ #placedAlign = derived(() => getAlignFromPlacement(this.floating.placement));
+ get placedAlign() {
+ return this.#placedAlign();
+ }
+ set placedAlign($$value) {
+ return this.#placedAlign($$value);
+ }
+ #arrowX = derived(() => this.floating.middlewareData.arrow?.x ?? 0);
+ get arrowX() {
+ return this.#arrowX();
+ }
+ set arrowX($$value) {
+ return this.#arrowX($$value);
+ }
+ #arrowY = derived(() => this.floating.middlewareData.arrow?.y ?? 0);
+ get arrowY() {
+ return this.#arrowY();
+ }
+ set arrowY($$value) {
+ return this.#arrowY($$value);
+ }
+ #cannotCenterArrow = derived(() => this.floating.middlewareData.arrow?.centerOffset !== 0);
+ get cannotCenterArrow() {
+ return this.#cannotCenterArrow();
+ }
+ set cannotCenterArrow($$value) {
+ return this.#cannotCenterArrow($$value);
+ }
+ contentZIndex;
+ #arrowBaseSide = derived(() => OPPOSITE_SIDE[this.placedSide]);
+ get arrowBaseSide() {
+ return this.#arrowBaseSide();
+ }
+ set arrowBaseSide($$value) {
+ return this.#arrowBaseSide($$value);
+ }
+ #wrapperProps = derived(() => ({
+ id: this.opts.wrapperId.current,
+ "data-bits-floating-content-wrapper": "",
+ style: {
+ ...this.floating.floatingStyles,
+ // keep off page when measuring
+ transform: this.floating.isPositioned ? this.floating.floatingStyles.transform : "translate(0, -200%)",
+ minWidth: "max-content",
+ zIndex: this.contentZIndex,
+ "--bits-floating-transform-origin": `${this.floating.middlewareData.transformOrigin?.x} ${this.floating.middlewareData.transformOrigin?.y}`,
+ "--bits-floating-available-width": `${this.#availableWidth}px`,
+ "--bits-floating-available-height": `${this.#availableHeight}px`,
+ "--bits-floating-anchor-width": `${this.#anchorWidth}px`,
+ "--bits-floating-anchor-height": `${this.#anchorHeight}px`,
+ // hide the content if using the hide middleware and should be hidden
+ ...this.floating.middlewareData.hide?.referenceHidden && {
+ visibility: "hidden",
+ "pointer-events": "none"
+ },
+ ...this.#transformedStyle()
+ },
+ // Floating UI calculates logical alignment based the `dir` attribute
+ dir: this.opts.dir.current
+ }));
+ get wrapperProps() {
+ return this.#wrapperProps();
+ }
+ set wrapperProps($$value) {
+ return this.#wrapperProps($$value);
+ }
+ #props = derived(() => ({
+ "data-side": this.placedSide,
+ "data-align": this.placedAlign,
+ style: styleToString({
+ ...this.#transformedStyle()
+ // if the FloatingContent hasn't been placed yet (not all measurements done)
+ })
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+ #arrowStyle = derived(() => ({
+ position: "absolute",
+ left: this.arrowX ? `${this.arrowX}px` : void 0,
+ top: this.arrowY ? `${this.arrowY}px` : void 0,
+ [this.arrowBaseSide]: 0,
+ "transform-origin": {
+ top: "",
+ right: "0 0",
+ bottom: "center 0",
+ left: "100% 0"
+ }[this.placedSide],
+ transform: {
+ top: "translateY(100%)",
+ right: "translateY(50%) rotate(90deg) translateX(-50%)",
+ bottom: "rotate(180deg)",
+ left: "translateY(50%) rotate(-90deg) translateX(50%)"
+ }[this.placedSide],
+ visibility: this.cannotCenterArrow ? "hidden" : void 0
+ }));
+ get arrowStyle() {
+ return this.#arrowStyle();
+ }
+ set arrowStyle($$value) {
+ return this.#arrowStyle($$value);
+ }
+ constructor(opts, root) {
+ this.opts = opts;
+ this.root = root;
+ if (opts.customAnchor) {
+ this.root.customAnchorNode.current = opts.customAnchor.current;
+ }
+ watch(() => opts.customAnchor.current, (customAnchor) => {
+ this.root.customAnchorNode.current = customAnchor;
+ });
+ useRefById({
+ id: this.opts.wrapperId,
+ ref: this.wrapperRef,
+ deps: () => this.opts.enabled.current
+ });
+ useRefById({
+ id: this.opts.id,
+ ref: this.contentRef,
+ deps: () => this.opts.enabled.current
+ });
+ this.floating = useFloating({
+ strategy: () => this.opts.strategy.current,
+ placement: () => this.#desiredPlacement(),
+ middleware: () => this.middleware,
+ reference: this.root.anchorNode,
+ open: () => this.opts.enabled.current
+ });
+ watch(() => this.contentRef.current, (contentNode) => {
+ if (!contentNode) return;
+ this.contentZIndex = window.getComputedStyle(contentNode).zIndex;
+ });
+ }
+}
+class FloatingAnchorState {
+ opts;
+ root;
+ ref = box(null);
+ constructor(opts, root) {
+ this.opts = opts;
+ this.root = root;
+ if (opts.virtualEl && opts.virtualEl.current) {
+ root.triggerNode = box.from(opts.virtualEl.current);
+ } else {
+ useRefById({
+ id: opts.id,
+ ref: this.ref,
+ onRefChange: (node) => {
+ root.triggerNode.current = node;
+ }
+ });
+ }
+ }
+}
+const FloatingRootContext = new Context("Floating.Root");
+const FloatingContentContext = new Context("Floating.Content");
+function useFloatingRootState() {
+ return FloatingRootContext.set(new FloatingRootState());
+}
+function useFloatingContentState(props) {
+ return FloatingContentContext.set(new FloatingContentState(props, FloatingRootContext.get()));
+}
+function useFloatingAnchorState(props) {
+ return new FloatingAnchorState(props, FloatingRootContext.get());
+}
+function transformOrigin(options) {
+ return {
+ name: "transformOrigin",
+ options,
+ fn(data) {
+ const { placement, rects, middlewareData } = data;
+ const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0;
+ const isArrowHidden = cannotCenterArrow;
+ const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
+ const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
+ const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
+ const noArrowAlign = { start: "0%", center: "50%", end: "100%" }[placedAlign];
+ const arrowXCenter = (middlewareData.arrow?.x ?? 0) + arrowWidth / 2;
+ const arrowYCenter = (middlewareData.arrow?.y ?? 0) + arrowHeight / 2;
+ let x = "";
+ let y = "";
+ if (placedSide === "bottom") {
+ x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
+ y = `${-arrowHeight}px`;
+ } else if (placedSide === "top") {
+ x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
+ y = `${rects.floating.height + arrowHeight}px`;
+ } else if (placedSide === "right") {
+ x = `${-arrowHeight}px`;
+ y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
+ } else if (placedSide === "left") {
+ x = `${rects.floating.width + arrowHeight}px`;
+ y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
+ }
+ return { data: { x, y } };
+ }
+ };
+}
+function getSideAndAlignFromPlacement(placement) {
+ const [side, align = "center"] = placement.split("-");
+ return [side, align];
+}
+function getSideFromPlacement(placement) {
+ return getSideAndAlignFromPlacement(placement)[0];
+}
+function getAlignFromPlacement(placement) {
+ return getSideAndAlignFromPlacement(placement)[1];
+}
+function Floating_layer($$payload, $$props) {
+ push();
+ let { children } = $$props;
+ useFloatingRootState();
+ children?.($$payload);
+ $$payload.out += ``;
+ pop();
+}
+function boxAutoReset(defaultValue, afterMs = 1e4, onChange = noop$1) {
+ let timeout = null;
+ let value = defaultValue;
+ function resetAfter() {
+ return window.setTimeout(
+ () => {
+ value = defaultValue;
+ onChange(defaultValue);
+ },
+ afterMs
+ );
+ }
+ return box.with(() => value, (v) => {
+ value = v;
+ onChange(v);
+ if (timeout) clearTimeout(timeout);
+ timeout = resetAfter();
+ });
+}
+function Floating_layer_anchor($$payload, $$props) {
+ push();
+ let { id, children, virtualEl } = $$props;
+ useFloatingAnchorState({
+ id: box.with(() => id),
+ virtualEl: box.with(() => virtualEl)
+ });
+ children?.($$payload);
+ $$payload.out += ``;
+ pop();
+}
+function Floating_layer_content($$payload, $$props) {
+ push();
+ let {
+ content,
+ side = "bottom",
+ sideOffset = 0,
+ align = "center",
+ alignOffset = 0,
+ id,
+ arrowPadding = 0,
+ avoidCollisions = true,
+ collisionBoundary = [],
+ collisionPadding = 0,
+ hideWhenDetached = false,
+ onPlaced = () => {
+ },
+ sticky = "partial",
+ updatePositionStrategy = "optimized",
+ strategy = "fixed",
+ dir = "ltr",
+ style = {},
+ wrapperId = useId$1(),
+ customAnchor = null,
+ enabled
+ } = $$props;
+ const contentState = useFloatingContentState({
+ side: box.with(() => side),
+ sideOffset: box.with(() => sideOffset),
+ align: box.with(() => align),
+ alignOffset: box.with(() => alignOffset),
+ id: box.with(() => id),
+ arrowPadding: box.with(() => arrowPadding),
+ avoidCollisions: box.with(() => avoidCollisions),
+ collisionBoundary: box.with(() => collisionBoundary),
+ collisionPadding: box.with(() => collisionPadding),
+ hideWhenDetached: box.with(() => hideWhenDetached),
+ onPlaced: box.with(() => onPlaced),
+ sticky: box.with(() => sticky),
+ updatePositionStrategy: box.with(() => updatePositionStrategy),
+ strategy: box.with(() => strategy),
+ dir: box.with(() => dir),
+ style: box.with(() => style),
+ enabled: box.with(() => enabled),
+ wrapperId: box.with(() => wrapperId),
+ customAnchor: box.with(() => customAnchor)
+ });
+ const mergedProps = mergeProps(contentState.wrapperProps, { style: { pointerEvents: "auto" } });
+ content?.($$payload, {
+ props: contentState.props,
+ wrapperProps: mergedProps
+ });
+ $$payload.out += ``;
+ pop();
+}
+function Floating_layer_content_static($$payload, $$props) {
+ push();
+ let { content } = $$props;
+ content?.($$payload, { props: {}, wrapperProps: {} });
+ $$payload.out += ``;
+ pop();
+}
+const SEPARATOR_ROOT_ATTR = "data-separator-root";
+class SeparatorRootState {
+ opts;
+ constructor(opts) {
+ this.opts = opts;
+ useRefById(opts);
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ role: this.opts.decorative.current ? "none" : "separator",
+ "aria-orientation": getAriaOrientation(this.opts.orientation.current),
+ "aria-hidden": getAriaHidden(this.opts.decorative.current),
+ "data-orientation": getDataOrientation(this.opts.orientation.current),
+ [SEPARATOR_ROOT_ATTR]: ""
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+function useSeparatorRoot(props) {
+ return new SeparatorRootState(props);
+}
+function Separator$1($$payload, $$props) {
+ push();
+ let {
+ id = useId$1(),
+ ref = null,
+ child,
+ children,
+ decorative = false,
+ orientation = "horizontal",
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const rootState = useSeparatorRoot({
+ ref: box.with(() => ref, (v) => ref = v),
+ id: box.with(() => id),
+ decorative: box.with(() => decorative),
+ orientation: box.with(() => orientation)
+ });
+ const mergedProps = mergeProps(restProps, rootState.props);
+ if (child) {
+ $$payload.out += "";
+ child($$payload, { props: mergedProps });
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ $$payload.out += ``;
+ children?.($$payload);
+ $$payload.out += `
`;
+ }
+ $$payload.out += ``;
+ bind_props($$props, { ref });
+ pop();
+}
+function Popper_content($$payload, $$props) {
+ let {
+ content,
+ isStatic = false,
+ onPlaced,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ if (isStatic) {
+ $$payload.out += "";
+ Floating_layer_content_static($$payload, { content });
+ } else {
+ $$payload.out += "";
+ Floating_layer_content($$payload, spread_props([{ content, onPlaced }, restProps]));
+ }
+ $$payload.out += ``;
+}
+function Popper_layer_inner($$payload, $$props) {
+ push();
+ let {
+ popper,
+ onEscapeKeydown,
+ escapeKeydownBehavior,
+ preventOverflowTextSelection,
+ id,
+ onPointerDown,
+ onPointerUp,
+ side,
+ sideOffset,
+ align,
+ alignOffset,
+ arrowPadding,
+ avoidCollisions,
+ collisionBoundary,
+ collisionPadding,
+ sticky,
+ hideWhenDetached,
+ updatePositionStrategy,
+ strategy,
+ dir,
+ preventScroll,
+ wrapperId,
+ style,
+ onPlaced,
+ onInteractOutside,
+ onCloseAutoFocus,
+ onOpenAutoFocus,
+ onFocusOutside,
+ interactOutsideBehavior = "close",
+ loop,
+ trapFocus = true,
+ isValidEvent: isValidEvent2 = () => false,
+ customAnchor = null,
+ isStatic = false,
+ enabled,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ {
+ let content = function($$payload2, { props: floatingProps, wrapperProps }) {
+ if (restProps.forceMount && enabled) {
+ $$payload2.out += "";
+ Scroll_lock($$payload2, { preventScroll });
+ } else if (!restProps.forceMount) {
+ $$payload2.out += "";
+ Scroll_lock($$payload2, { preventScroll });
+ } else {
+ $$payload2.out += "";
+ }
+ $$payload2.out += ` `;
+ {
+ let focusScope = function($$payload3, { props: focusScopeProps }) {
+ Escape_layer($$payload3, {
+ onEscapeKeydown,
+ escapeKeydownBehavior,
+ enabled,
+ children: ($$payload4) => {
+ {
+ let children = function($$payload5, { props: dismissibleProps }) {
+ Text_selection_layer($$payload5, {
+ id,
+ preventOverflowTextSelection,
+ onPointerDown,
+ onPointerUp,
+ enabled,
+ children: ($$payload6) => {
+ popper?.($$payload6, {
+ props: mergeProps(restProps, floatingProps, dismissibleProps, focusScopeProps, { style: { pointerEvents: "auto" } }),
+ wrapperProps
+ });
+ $$payload6.out += ``;
+ }
+ });
+ };
+ Dismissible_layer($$payload4, {
+ id,
+ onInteractOutside,
+ onFocusOutside,
+ interactOutsideBehavior,
+ isValidEvent: isValidEvent2,
+ enabled,
+ children
+ });
+ }
+ }
+ });
+ };
+ Focus_scope($$payload2, {
+ id,
+ onOpenAutoFocus,
+ onCloseAutoFocus,
+ loop,
+ trapFocus: enabled && trapFocus,
+ forceMount: restProps.forceMount,
+ focusScope
+ });
+ }
+ $$payload2.out += ``;
+ };
+ Popper_content($$payload, {
+ isStatic,
+ id,
+ side,
+ sideOffset,
+ align,
+ alignOffset,
+ arrowPadding,
+ avoidCollisions,
+ collisionBoundary,
+ collisionPadding,
+ sticky,
+ hideWhenDetached,
+ updatePositionStrategy,
+ strategy,
+ dir,
+ wrapperId,
+ style,
+ onPlaced,
+ customAnchor,
+ enabled,
+ content,
+ $$slots: { content: true }
+ });
+ }
+ pop();
+}
+function Popper_layer($$payload, $$props) {
+ let {
+ popper,
+ present,
+ onEscapeKeydown,
+ escapeKeydownBehavior,
+ preventOverflowTextSelection,
+ id,
+ onPointerDown,
+ onPointerUp,
+ side,
+ sideOffset,
+ align,
+ alignOffset,
+ arrowPadding,
+ avoidCollisions,
+ collisionBoundary,
+ collisionPadding,
+ sticky,
+ hideWhenDetached,
+ updatePositionStrategy,
+ strategy,
+ dir,
+ preventScroll,
+ wrapperId,
+ style,
+ onPlaced,
+ onInteractOutside,
+ onCloseAutoFocus,
+ onOpenAutoFocus,
+ onFocusOutside,
+ interactOutsideBehavior = "close",
+ loop,
+ trapFocus = true,
+ isValidEvent: isValidEvent2 = () => false,
+ customAnchor = null,
+ isStatic = false,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ {
+ let presence = function($$payload2) {
+ Popper_layer_inner($$payload2, spread_props([
+ {
+ popper,
+ onEscapeKeydown,
+ escapeKeydownBehavior,
+ preventOverflowTextSelection,
+ id,
+ onPointerDown,
+ onPointerUp,
+ side,
+ sideOffset,
+ align,
+ alignOffset,
+ arrowPadding,
+ avoidCollisions,
+ collisionBoundary,
+ collisionPadding,
+ sticky,
+ hideWhenDetached,
+ updatePositionStrategy,
+ strategy,
+ dir,
+ preventScroll,
+ wrapperId,
+ style,
+ onPlaced,
+ customAnchor,
+ isStatic,
+ enabled: present,
+ onInteractOutside,
+ onCloseAutoFocus,
+ onOpenAutoFocus,
+ interactOutsideBehavior,
+ loop,
+ trapFocus,
+ isValidEvent: isValidEvent2,
+ onFocusOutside,
+ forceMount: false
+ },
+ restProps
+ ]));
+ };
+ Presence_layer($$payload, spread_props([
+ { id, present },
+ restProps,
+ { presence, $$slots: { presence: true } }
+ ]));
+ }
+}
+function Popper_layer_force_mount($$payload, $$props) {
+ let {
+ popper,
+ onEscapeKeydown,
+ escapeKeydownBehavior,
+ preventOverflowTextSelection,
+ id,
+ onPointerDown,
+ onPointerUp,
+ side,
+ sideOffset,
+ align,
+ alignOffset,
+ arrowPadding,
+ avoidCollisions,
+ collisionBoundary,
+ collisionPadding,
+ sticky,
+ hideWhenDetached,
+ updatePositionStrategy,
+ strategy,
+ dir,
+ preventScroll,
+ wrapperId,
+ style,
+ onPlaced,
+ onInteractOutside,
+ onCloseAutoFocus,
+ onOpenAutoFocus,
+ onFocusOutside,
+ interactOutsideBehavior = "close",
+ loop,
+ trapFocus = true,
+ isValidEvent: isValidEvent2 = () => false,
+ customAnchor = null,
+ isStatic = false,
+ enabled,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ Popper_layer_inner($$payload, spread_props([
+ {
+ popper,
+ onEscapeKeydown,
+ escapeKeydownBehavior,
+ preventOverflowTextSelection,
+ id,
+ onPointerDown,
+ onPointerUp,
+ side,
+ sideOffset,
+ align,
+ alignOffset,
+ arrowPadding,
+ avoidCollisions,
+ collisionBoundary,
+ collisionPadding,
+ sticky,
+ hideWhenDetached,
+ updatePositionStrategy,
+ strategy,
+ dir,
+ preventScroll,
+ wrapperId,
+ style,
+ onPlaced,
+ customAnchor,
+ isStatic,
+ enabled,
+ onInteractOutside,
+ onCloseAutoFocus,
+ onOpenAutoFocus,
+ interactOutsideBehavior,
+ loop,
+ trapFocus,
+ isValidEvent: isValidEvent2,
+ onFocusOutside
+ },
+ restProps,
+ { forceMount: true }
+ ]));
+}
+function Mounted$1($$payload, $$props) {
+ push();
+ let { mounted = false, onMountedChange = noop$1 } = $$props;
+ bind_props($$props, { mounted });
+ pop();
+}
+function findNextSibling(el, selector) {
+ let sibling = el.nextElementSibling;
+ while (sibling) {
+ if (sibling.matches(selector))
+ return sibling;
+ sibling = sibling.nextElementSibling;
+ }
+}
+function findPreviousSibling(el, selector) {
+ let sibling = el.previousElementSibling;
+ while (sibling) {
+ if (sibling.matches(selector))
+ return sibling;
+ sibling = sibling.previousElementSibling;
+ }
+}
+const COMMAND_ROOT_ATTR = "data-command-root";
+const COMMAND_EMPTY_ATTR = "data-command-empty";
+const COMMAND_GROUP_ATTR = "data-command-group";
+const COMMAND_GROUP_ITEMS_ATTR = "data-command-group-items";
+const COMMAND_GROUP_HEADING_ATTR = "data-command-group-heading";
+const COMMAND_ITEM_ATTR = "data-command-item";
+const COMMAND_INPUT_LABEL_ATTR = "data-command-input-label";
+const COMMAND_VALUE_ATTR = "data-value";
+const COMMAND_GROUP_SELECTOR = `[${COMMAND_GROUP_ATTR}]`;
+const COMMAND_GROUP_ITEMS_SELECTOR = `[${COMMAND_GROUP_ITEMS_ATTR}]`;
+const COMMAND_GROUP_HEADING_SELECTOR = `[${COMMAND_GROUP_HEADING_ATTR}]`;
+const COMMAND_ITEM_SELECTOR = `[${COMMAND_ITEM_ATTR}]`;
+const COMMAND_VALID_ITEM_SELECTOR = `${COMMAND_ITEM_SELECTOR}:not([aria-disabled="true"])`;
+const CommandRootContext = new Context("Command.Root");
+const CommandGroupContainerContext = new Context("Command.Group");
+const defaultState = {
+ /** Value of the search query */
+ search: "",
+ /** Currently selected item value */
+ value: "",
+ filtered: {
+ /** The count of all visible items. */
+ count: 0,
+ /** Map from visible item id to its search store. */
+ items: /* @__PURE__ */ new Map(),
+ /** Set of groups with at least one visible item. */
+ groups: /* @__PURE__ */ new Set()
+ }
+};
+class CommandRootState {
+ opts;
+ #updateScheduled = false;
+ sortAfterTick = false;
+ sortAndFilterAfterTick = false;
+ allItems = /* @__PURE__ */ new Set();
+ allGroups = /* @__PURE__ */ new Map();
+ allIds = /* @__PURE__ */ new Map();
+ // attempt to prevent the harsh delay when user is typing fast
+ key = 0;
+ viewportNode = null;
+ inputNode = null;
+ labelNode = null;
+ // published state that the components and other things can react to
+ commandState = defaultState;
+ // internal state that we mutate in batches and publish to the `state` at once
+ _commandState = defaultState;
+ #snapshot() {
+ return snapshot(this._commandState);
+ }
+ #scheduleUpdate() {
+ if (this.#updateScheduled) return;
+ this.#updateScheduled = true;
+ afterTick(() => {
+ this.#updateScheduled = false;
+ const currentState = this.#snapshot();
+ const hasStateChanged = !Object.is(this.commandState, currentState);
+ if (hasStateChanged) {
+ this.commandState = currentState;
+ this.opts.onStateChange?.current?.(currentState);
+ }
+ });
+ }
+ setState(key, value, opts) {
+ if (Object.is(this._commandState[key], value)) return;
+ this._commandState[key] = value;
+ if (key === "search") {
+ this.#filterItems();
+ this.#sort();
+ } else if (key === "value") {
+ if (!opts) {
+ this.#scrollSelectedIntoView();
+ }
+ }
+ this.#scheduleUpdate();
+ }
+ constructor(opts) {
+ this.opts = opts;
+ const defaults = {
+ ...this._commandState,
+ value: this.opts.value.current ?? ""
+ };
+ this._commandState = defaults;
+ this.commandState = defaults;
+ useRefById(opts);
+ this.onkeydown = this.onkeydown.bind(this);
+ }
+ /**
+ * Calculates score for an item based on search text and keywords.
+ * Higher score = better match.
+ *
+ * @param value - Item's display text
+ * @param keywords - Optional keywords to boost scoring
+ * @returns Score from 0-1, where 0 = no match
+ */
+ #score(value, keywords) {
+ const filter = this.opts.filter.current ?? computeCommandScore;
+ const score = value ? filter(value, this._commandState.search, keywords) : 0;
+ return score;
+ }
+ /**
+ * Sorts items and groups based on search scores.
+ * Groups are sorted by their highest scoring item.
+ * When no search active, selects first item.
+ */
+ #sort() {
+ if (!this._commandState.search || this.opts.shouldFilter.current === false) {
+ this.#selectFirstItem();
+ return;
+ }
+ const scores = this._commandState.filtered.items;
+ const groups = [];
+ for (const value of this._commandState.filtered.groups) {
+ const items = this.allGroups.get(value);
+ let max = 0;
+ if (!items) {
+ groups.push([value, max]);
+ continue;
+ }
+ for (const item of items) {
+ const score = scores.get(item);
+ max = Math.max(score ?? 0, max);
+ }
+ groups.push([value, max]);
+ }
+ const listInsertionElement = this.viewportNode;
+ const sorted = this.getValidItems().sort((a, b) => {
+ const valueA = a.getAttribute("data-value");
+ const valueB = b.getAttribute("data-value");
+ const scoresA = scores.get(valueA) ?? 0;
+ const scoresB = scores.get(valueB) ?? 0;
+ return scoresB - scoresA;
+ });
+ for (const item of sorted) {
+ const group = item.closest(COMMAND_GROUP_ITEMS_SELECTOR);
+ if (group) {
+ const itemToAppend = item.parentElement === group ? item : item.closest(`${COMMAND_GROUP_ITEMS_SELECTOR} > *`);
+ if (itemToAppend) {
+ group.appendChild(itemToAppend);
+ }
+ } else {
+ const itemToAppend = item.parentElement === listInsertionElement ? item : item.closest(`${COMMAND_GROUP_ITEMS_SELECTOR} > *`);
+ if (itemToAppend) {
+ listInsertionElement?.appendChild(itemToAppend);
+ }
+ }
+ }
+ const sortedGroups = groups.sort((a, b) => b[1] - a[1]);
+ for (const group of sortedGroups) {
+ const element2 = listInsertionElement?.querySelector(`${COMMAND_GROUP_SELECTOR}[${COMMAND_VALUE_ATTR}="${cssesc(group[0])}"]`);
+ element2?.parentElement?.appendChild(element2);
+ }
+ this.#selectFirstItem();
+ }
+ /**
+ * Sets current value and triggers re-render if cleared.
+ *
+ * @param value - New value to set
+ */
+ setValue(value, opts) {
+ if (value !== this.opts.value.current && value === "") {
+ afterTick(() => {
+ this.key++;
+ });
+ }
+ this.setState("value", value, opts);
+ this.opts.value.current = value;
+ }
+ /**
+ * Selects first non-disabled item on next tick.
+ */
+ #selectFirstItem() {
+ afterTick(() => {
+ const item = this.getValidItems().find((item2) => item2.getAttribute("aria-disabled") !== "true");
+ const value = item?.getAttribute(COMMAND_VALUE_ATTR);
+ this.setValue(value || "");
+ });
+ }
+ /**
+ * Updates filtered items/groups based on search.
+ * Recalculates scores and filtered count.
+ */
+ #filterItems() {
+ if (!this._commandState.search || this.opts.shouldFilter.current === false) {
+ this._commandState.filtered.count = this.allItems.size;
+ return;
+ }
+ this._commandState.filtered.groups = /* @__PURE__ */ new Set();
+ let itemCount = 0;
+ for (const id of this.allItems) {
+ const value = this.allIds.get(id)?.value ?? "";
+ const keywords = this.allIds.get(id)?.keywords ?? [];
+ const rank = this.#score(value, keywords);
+ this._commandState.filtered.items.set(id, rank);
+ if (rank > 0) itemCount++;
+ }
+ for (const [groupId, group] of this.allGroups) {
+ for (const itemId of group) {
+ const currItem = this._commandState.filtered.items.get(itemId);
+ if (currItem && currItem > 0) {
+ this._commandState.filtered.groups.add(groupId);
+ break;
+ }
+ }
+ }
+ this._commandState.filtered.count = itemCount;
+ }
+ /**
+ * Gets all non-disabled, visible command items.
+ *
+ * @returns Array of valid item elements
+ * @remarks Exposed for direct item access and bound checking
+ */
+ getValidItems() {
+ const node = this.opts.ref.current;
+ if (!node) return [];
+ const validItems = Array.from(node.querySelectorAll(COMMAND_VALID_ITEM_SELECTOR)).filter((el) => !!el);
+ return validItems;
+ }
+ /**
+ * Gets currently selected command item.
+ *
+ * @returns Selected element or undefined
+ */
+ #getSelectedItem() {
+ const node = this.opts.ref.current;
+ if (!node) return;
+ const selectedNode = node.querySelector(`${COMMAND_VALID_ITEM_SELECTOR}[data-selected]`);
+ if (!selectedNode) return;
+ return selectedNode;
+ }
+ /**
+ * Scrolls selected item into view.
+ * Special handling for first items in groups.
+ */
+ #scrollSelectedIntoView() {
+ afterTick(() => {
+ const item = this.#getSelectedItem();
+ if (!item) return;
+ const grandparent = item.parentElement?.parentElement;
+ if (!grandparent) return;
+ const firstChildOfParent = getFirstNonCommentChild(grandparent);
+ if (firstChildOfParent && firstChildOfParent.dataset?.value === item.dataset?.value) {
+ const closestGroupHeader = item?.closest(COMMAND_GROUP_SELECTOR)?.querySelector(COMMAND_GROUP_HEADING_SELECTOR);
+ closestGroupHeader?.scrollIntoView({ block: "nearest" });
+ return;
+ }
+ item.scrollIntoView({ block: "nearest" });
+ });
+ }
+ /**
+ * Sets selection to item at specified index in valid items array.
+ * If index is out of bounds, does nothing.
+ *
+ * @param index - Zero-based index of item to select
+ * @remarks
+ * Uses `getValidItems()` to get selectable items, filtering out disabled/hidden ones.
+ * Access valid items directly via `getValidItems()` to check bounds before calling.
+ *
+ * @example
+ * // get valid items length for bounds check
+ * const items = getValidItems()
+ * if (index < items.length) {
+ * updateSelectedToIndex(index)
+ * }
+ */
+ updateSelectedToIndex(index) {
+ const items = this.getValidItems();
+ const item = items[index];
+ if (item) {
+ this.setValue(item.getAttribute(COMMAND_VALUE_ATTR) ?? "");
+ }
+ }
+ /**
+ * Updates selected item by moving up/down relative to current selection.
+ * Handles wrapping when loop option is enabled.
+ *
+ * @param change - Direction to move: 1 for next item, -1 for previous item
+ * @remarks
+ * The loop behavior wraps:
+ * - From last item to first when moving next
+ * - From first item to last when moving previous
+ *
+ * Uses `getValidItems()` to get all selectable items, which filters out disabled/hidden items.
+ * You can call `getValidItems()` directly to get the current valid items array.
+ *
+ * @example
+ * // select next item
+ * updateSelectedByItem(1)
+ *
+ * // get all valid items
+ * const items = getValidItems()
+ */
+ updateSelectedByItem(change) {
+ const selected = this.#getSelectedItem();
+ const items = this.getValidItems();
+ const index = items.findIndex((item) => item === selected);
+ let newSelected = items[index + change];
+ if (this.opts.loop.current) {
+ newSelected = index + change < 0 ? items[items.length - 1] : index + change === items.length ? items[0] : items[index + change];
+ }
+ if (newSelected) {
+ this.setValue(newSelected.getAttribute(COMMAND_VALUE_ATTR) ?? "");
+ }
+ }
+ /**
+ * Moves selection to the first valid item in the next/previous group.
+ * If no group is found, falls back to selecting the next/previous item globally.
+ *
+ * @param change - Direction to move: 1 for next group, -1 for previous group
+ * @example
+ * // move to first item in next group
+ * updateSelectedByGroup(1)
+ *
+ * // move to first item in previous group
+ * updateSelectedByGroup(-1)
+ */
+ updateSelectedByGroup(change) {
+ const selected = this.#getSelectedItem();
+ let group = selected?.closest(COMMAND_GROUP_SELECTOR);
+ let item;
+ while (group && !item) {
+ group = change > 0 ? findNextSibling(group, COMMAND_GROUP_SELECTOR) : findPreviousSibling(group, COMMAND_GROUP_SELECTOR);
+ item = group?.querySelector(COMMAND_VALID_ITEM_SELECTOR);
+ }
+ if (item) {
+ this.setValue(item.getAttribute(COMMAND_VALUE_ATTR) ?? "");
+ } else {
+ this.updateSelectedByItem(change);
+ }
+ }
+ /**
+ * Maps item id to display value and search keywords.
+ * Returns cleanup function to remove mapping.
+ *
+ * @param id - Unique item identifier
+ * @param value - Display text
+ * @param keywords - Optional search boost terms
+ * @returns Cleanup function
+ */
+ registerValue(value, keywords) {
+ if (!(value && value === this.allIds.get(value)?.value)) {
+ this.allIds.set(value, { value, keywords });
+ }
+ this._commandState.filtered.items.set(value, this.#score(value, keywords));
+ if (!this.sortAfterTick) {
+ this.sortAfterTick = true;
+ afterTick(() => {
+ this.#sort();
+ this.sortAfterTick = false;
+ });
+ }
+ return () => {
+ this.allIds.delete(value);
+ };
+ }
+ /**
+ * Registers item in command list and its group.
+ * Handles filtering, sorting and selection updates.
+ *
+ * @param id - Item identifier
+ * @param groupId - Optional group to add item to
+ * @returns Cleanup function that handles selection
+ */
+ registerItem(id, groupId) {
+ this.allItems.add(id);
+ if (groupId) {
+ if (!this.allGroups.has(groupId)) {
+ this.allGroups.set(groupId, /* @__PURE__ */ new Set([id]));
+ } else {
+ this.allGroups.get(groupId).add(id);
+ }
+ }
+ if (!this.sortAndFilterAfterTick) {
+ this.sortAndFilterAfterTick = true;
+ afterTick(() => {
+ this.#filterItems();
+ this.#sort();
+ this.sortAndFilterAfterTick = false;
+ });
+ }
+ this.#scheduleUpdate();
+ return () => {
+ const selectedItem = this.#getSelectedItem();
+ this.allIds.delete(id);
+ this.allItems.delete(id);
+ this.commandState.filtered.items.delete(id);
+ this.#filterItems();
+ if (selectedItem?.getAttribute("id") === id) {
+ this.#selectFirstItem();
+ }
+ this.#scheduleUpdate();
+ };
+ }
+ /**
+ * Creates empty group if not exists.
+ *
+ * @param id - Group identifier
+ * @returns Cleanup function
+ */
+ registerGroup(id) {
+ if (!this.allGroups.has(id)) {
+ this.allGroups.set(id, /* @__PURE__ */ new Set());
+ }
+ return () => {
+ this.allIds.delete(id);
+ this.allGroups.delete(id);
+ };
+ }
+ /**
+ * Selects last valid item.
+ */
+ #last() {
+ return this.updateSelectedToIndex(this.getValidItems().length - 1);
+ }
+ /**
+ * Handles next item selection:
+ * - Meta: Jump to last
+ * - Alt: Next group
+ * - Default: Next item
+ *
+ * @param e - Keyboard event
+ */
+ #next(e) {
+ e.preventDefault();
+ if (e.metaKey) {
+ this.#last();
+ } else if (e.altKey) {
+ this.updateSelectedByGroup(1);
+ } else {
+ this.updateSelectedByItem(1);
+ }
+ }
+ /**
+ * Handles previous item selection:
+ * - Meta: Jump to first
+ * - Alt: Previous group
+ * - Default: Previous item
+ *
+ * @param e - Keyboard event
+ */
+ #prev(e) {
+ e.preventDefault();
+ if (e.metaKey) {
+ this.updateSelectedToIndex(0);
+ } else if (e.altKey) {
+ this.updateSelectedByGroup(-1);
+ } else {
+ this.updateSelectedByItem(-1);
+ }
+ }
+ onkeydown(e) {
+ switch (e.key) {
+ case n:
+ case j: {
+ if (this.opts.vimBindings.current && e.ctrlKey) {
+ this.#next(e);
+ }
+ break;
+ }
+ case ARROW_DOWN:
+ this.#next(e);
+ break;
+ case p:
+ case k: {
+ if (this.opts.vimBindings.current && e.ctrlKey) {
+ this.#prev(e);
+ }
+ break;
+ }
+ case ARROW_UP:
+ this.#prev(e);
+ break;
+ case HOME:
+ e.preventDefault();
+ this.updateSelectedToIndex(0);
+ break;
+ case END:
+ e.preventDefault();
+ this.#last();
+ break;
+ case ENTER: {
+ if (!e.isComposing && e.keyCode !== 229) {
+ e.preventDefault();
+ const item = this.#getSelectedItem();
+ if (item) {
+ item?.click();
+ }
+ }
+ }
+ }
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ role: "application",
+ [COMMAND_ROOT_ATTR]: "",
+ tabindex: -1,
+ onkeydown: this.onkeydown
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class CommandEmptyState {
+ opts;
+ root;
+ #isInitialRender = true;
+ #shouldRender = derived(() => {
+ return this.root._commandState.filtered.count === 0 && this.#isInitialRender === false || this.opts.forceMount.current;
+ });
+ get shouldRender() {
+ return this.#shouldRender();
+ }
+ set shouldRender($$value) {
+ return this.#shouldRender($$value);
+ }
+ constructor(opts, root) {
+ this.opts = opts;
+ this.root = root;
+ useRefById({ ...opts, deps: () => this.shouldRender });
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ role: "presentation",
+ [COMMAND_EMPTY_ATTR]: ""
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class CommandGroupContainerState {
+ opts;
+ root;
+ headingNode = null;
+ trueValue = "";
+ #shouldRender = derived(() => {
+ if (this.opts.forceMount.current) return true;
+ if (this.root.opts.shouldFilter.current === false) return true;
+ if (!this.root.commandState.search) return true;
+ return this.root._commandState.filtered.groups.has(this.trueValue);
+ });
+ get shouldRender() {
+ return this.#shouldRender();
+ }
+ set shouldRender($$value) {
+ return this.#shouldRender($$value);
+ }
+ constructor(opts, root) {
+ this.opts = opts;
+ this.root = root;
+ this.trueValue = opts.value.current ?? opts.id.current;
+ useRefById({ ...opts, deps: () => this.shouldRender });
+ watch(() => this.trueValue, () => {
+ return this.root.registerGroup(this.trueValue);
+ });
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ role: "presentation",
+ hidden: this.shouldRender ? void 0 : true,
+ "data-value": this.trueValue,
+ [COMMAND_GROUP_ATTR]: ""
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class CommandGroupHeadingState {
+ opts;
+ group;
+ constructor(opts, group) {
+ this.opts = opts;
+ this.group = group;
+ useRefById({
+ ...opts,
+ onRefChange: (node) => {
+ this.group.headingNode = node;
+ }
+ });
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ [COMMAND_GROUP_HEADING_ATTR]: ""
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class CommandGroupItemsState {
+ opts;
+ group;
+ constructor(opts, group) {
+ this.opts = opts;
+ this.group = group;
+ useRefById(opts);
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ role: "group",
+ [COMMAND_GROUP_ITEMS_ATTR]: "",
+ "aria-labelledby": this.group.headingNode?.id ?? void 0
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class CommandItemState {
+ opts;
+ root;
+ #group = null;
+ #trueForceMount = derived(() => {
+ return this.opts.forceMount.current || this.#group?.opts.forceMount.current === true;
+ });
+ trueValue = "";
+ #shouldRender = derived(() => {
+ this.opts.ref.current;
+ if (this.#trueForceMount() || this.root.opts.shouldFilter.current === false || !this.root.commandState.search) {
+ return true;
+ }
+ const currentScore = this.root.commandState.filtered.items.get(this.trueValue);
+ if (currentScore === void 0) return false;
+ return currentScore > 0;
+ });
+ get shouldRender() {
+ return this.#shouldRender();
+ }
+ set shouldRender($$value) {
+ return this.#shouldRender($$value);
+ }
+ #isSelected = derived(() => this.root.opts.value.current === this.trueValue && this.trueValue !== "");
+ get isSelected() {
+ return this.#isSelected();
+ }
+ set isSelected($$value) {
+ return this.#isSelected($$value);
+ }
+ constructor(opts, root) {
+ this.opts = opts;
+ this.root = root;
+ this.#group = CommandGroupContainerContext.getOr(null);
+ this.trueValue = opts.value.current;
+ useRefById({
+ ...opts,
+ deps: () => Boolean(this.root.commandState.search)
+ });
+ watch(
+ [
+ () => this.trueValue,
+ () => this.#group?.trueValue,
+ () => this.opts.forceMount.current
+ ],
+ () => {
+ if (this.opts.forceMount.current) return;
+ return this.root.registerItem(this.trueValue, this.#group?.trueValue);
+ }
+ );
+ watch(
+ [
+ () => this.opts.value.current,
+ () => this.opts.ref.current
+ ],
+ () => {
+ if (!this.opts.value.current && this.opts.ref.current?.textContent) {
+ this.trueValue = this.opts.ref.current.textContent.trim();
+ }
+ this.root.registerValue(this.trueValue, opts.keywords.current.map((kw) => kw.trim()));
+ this.opts.ref.current?.setAttribute(COMMAND_VALUE_ATTR, this.trueValue);
+ }
+ );
+ this.onclick = this.onclick.bind(this);
+ this.onpointermove = this.onpointermove.bind(this);
+ }
+ #onSelect() {
+ if (this.opts.disabled.current) return;
+ this.#select();
+ this.opts.onSelect?.current();
+ }
+ #select() {
+ if (this.opts.disabled.current) return;
+ this.root.setValue(this.trueValue, true);
+ }
+ onpointermove(_) {
+ if (this.opts.disabled.current || this.root.opts.disablePointerSelection.current) return;
+ this.#select();
+ }
+ onclick(_) {
+ if (this.opts.disabled.current) return;
+ this.#onSelect();
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ "aria-disabled": getAriaDisabled(this.opts.disabled.current),
+ "aria-selected": getAriaSelected(this.isSelected),
+ "data-disabled": getDataDisabled(this.opts.disabled.current),
+ "data-selected": getDataSelected(this.isSelected),
+ "data-value": this.trueValue,
+ [COMMAND_ITEM_ATTR]: "",
+ role: "option",
+ onpointermove: this.onpointermove,
+ onclick: this.onclick
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class CommandLabelState {
+ opts;
+ root;
+ constructor(opts, root) {
+ this.opts = opts;
+ this.root = root;
+ useRefById({
+ ...opts,
+ onRefChange: (node) => {
+ this.root.labelNode = node;
+ }
+ });
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ [COMMAND_INPUT_LABEL_ATTR]: "",
+ for: this.opts.for?.current,
+ style: srOnlyStyles
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+function useCommandRoot(props) {
+ return CommandRootContext.set(new CommandRootState(props));
+}
+function useCommandEmpty(props) {
+ return new CommandEmptyState(props, CommandRootContext.get());
+}
+function useCommandItem(props) {
+ const group = CommandGroupContainerContext.getOr(null);
+ return new CommandItemState({ ...props, group }, CommandRootContext.get());
+}
+function useCommandGroupContainer(props) {
+ return CommandGroupContainerContext.set(new CommandGroupContainerState(props, CommandRootContext.get()));
+}
+function useCommandGroupHeading(props) {
+ return new CommandGroupHeadingState(props, CommandGroupContainerContext.get());
+}
+function useCommandGroupItems(props) {
+ return new CommandGroupItemsState(props, CommandGroupContainerContext.get());
+}
+function useCommandLabel(props) {
+ return new CommandLabelState(props, CommandRootContext.get());
+}
+function _command_label($$payload, $$props) {
+ push();
+ let {
+ id = useId$1(),
+ ref = null,
+ children,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const labelState = useCommandLabel({
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v)
+ });
+ const mergedProps = mergeProps(restProps, labelState.props);
+ $$payload.out += ``;
+ children?.($$payload);
+ $$payload.out += ` `;
+ bind_props($$props, { ref });
+ pop();
+}
+function Command$1($$payload, $$props) {
+ push();
+ let {
+ id = useId$1(),
+ ref = null,
+ value = "",
+ onValueChange = noop$1,
+ onStateChange = noop$1,
+ loop = false,
+ shouldFilter = true,
+ filter = computeCommandScore,
+ label = "",
+ vimBindings = true,
+ disablePointerSelection = false,
+ children,
+ child,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const rootState = useCommandRoot({
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v),
+ filter: box.with(() => filter),
+ shouldFilter: box.with(() => shouldFilter),
+ loop: box.with(() => loop),
+ value: box.with(() => value, (v) => {
+ if (value !== v) {
+ value = v;
+ onValueChange(v);
+ }
+ }),
+ vimBindings: box.with(() => vimBindings),
+ disablePointerSelection: box.with(() => disablePointerSelection),
+ onStateChange: box.with(() => onStateChange)
+ });
+ const updateSelectedToIndex = (i) => rootState.updateSelectedToIndex(i);
+ const updateSelectedByGroup = (c) => rootState.updateSelectedByGroup(c);
+ const updateSelectedByItem = (c) => rootState.updateSelectedByItem(c);
+ const getValidItems = () => rootState.getValidItems();
+ const mergedProps = mergeProps(restProps, rootState.props);
+ function Label2($$payload2) {
+ _command_label($$payload2, {
+ children: ($$payload3) => {
+ $$payload3.out += `${escape_html(label)}`;
+ },
+ $$slots: { default: true }
+ });
+ }
+ if (child) {
+ $$payload.out += "";
+ Label2($$payload);
+ $$payload.out += ` `;
+ child($$payload, { props: mergedProps });
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ $$payload.out += ``;
+ Label2($$payload);
+ $$payload.out += ` `;
+ children?.($$payload);
+ $$payload.out += `
`;
+ }
+ $$payload.out += ``;
+ bind_props($$props, {
+ ref,
+ value,
+ updateSelectedToIndex,
+ updateSelectedByGroup,
+ updateSelectedByItem,
+ getValidItems
+ });
+ pop();
+}
+function Command_empty$1($$payload, $$props) {
+ push();
+ let {
+ id = useId$1(),
+ ref = null,
+ children,
+ child,
+ forceMount = false,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const emptyState = useCommandEmpty({
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v),
+ forceMount: box.with(() => forceMount)
+ });
+ const mergedProps = mergeProps(emptyState.props, restProps);
+ if (emptyState.shouldRender) {
+ $$payload.out += "";
+ if (child) {
+ $$payload.out += "";
+ child($$payload, { props: mergedProps });
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ $$payload.out += ``;
+ children?.($$payload);
+ $$payload.out += `
`;
+ }
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ }
+ $$payload.out += ``;
+ bind_props($$props, { ref });
+ pop();
+}
+function Command_group$1($$payload, $$props) {
+ push();
+ let {
+ id = useId$1(),
+ ref = null,
+ value = "",
+ forceMount = false,
+ children,
+ child,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const groupState = useCommandGroupContainer({
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v),
+ forceMount: box.with(() => forceMount),
+ value: box.with(() => value)
+ });
+ const mergedProps = mergeProps(restProps, groupState.props);
+ if (child) {
+ $$payload.out += "";
+ child($$payload, { props: mergedProps });
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ $$payload.out += ``;
+ children?.($$payload);
+ $$payload.out += `
`;
+ }
+ $$payload.out += ``;
+ bind_props($$props, { ref });
+ pop();
+}
+function Command_group_heading($$payload, $$props) {
+ push();
+ let {
+ id = useId$1(),
+ ref = null,
+ children,
+ child,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const headingState = useCommandGroupHeading({
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v)
+ });
+ const mergedProps = mergeProps(restProps, headingState.props);
+ if (child) {
+ $$payload.out += "";
+ child($$payload, { props: mergedProps });
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ $$payload.out += ``;
+ children?.($$payload);
+ $$payload.out += `
`;
+ }
+ $$payload.out += ``;
+ bind_props($$props, { ref });
+ pop();
+}
+function Command_group_items($$payload, $$props) {
+ push();
+ let {
+ id = useId$1(),
+ ref = null,
+ children,
+ child,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const groupItemsState = useCommandGroupItems({
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v)
+ });
+ const mergedProps = mergeProps(restProps, groupItemsState.props);
+ $$payload.out += ``;
+ if (child) {
+ $$payload.out += "";
+ child($$payload, { props: mergedProps });
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ $$payload.out += `
`;
+ children?.($$payload);
+ $$payload.out += `
`;
+ }
+ $$payload.out += `
`;
+ bind_props($$props, { ref });
+ pop();
+}
+function Command_item$1($$payload, $$props) {
+ push();
+ let {
+ id = useId$1(),
+ ref = null,
+ value = "",
+ disabled = false,
+ children,
+ child,
+ onSelect = noop$1,
+ forceMount = false,
+ keywords = [],
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const itemState = useCommandItem({
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v),
+ value: box.with(() => value),
+ disabled: box.with(() => disabled),
+ onSelect: box.with(() => onSelect),
+ forceMount: box.with(() => forceMount),
+ keywords: box.with(() => keywords)
+ });
+ const mergedProps = mergeProps(restProps, itemState.props);
+ $$payload.out += ``;
+ {
+ $$payload.out += ``;
+ if (itemState.shouldRender) {
+ $$payload.out += "";
+ if (child) {
+ $$payload.out += "";
+ child($$payload, { props: mergedProps });
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ $$payload.out += `
`;
+ children?.($$payload);
+ $$payload.out += `
`;
+ }
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ }
+ $$payload.out += `
`;
+ }
+ $$payload.out += ``;
+ bind_props($$props, { ref });
+ pop();
+}
+const SCORE_CONTINUE_MATCH = 1;
+const SCORE_SPACE_WORD_JUMP = 0.9;
+const SCORE_NON_SPACE_WORD_JUMP = 0.8;
+const SCORE_CHARACTER_JUMP = 0.17;
+const SCORE_TRANSPOSITION = 0.1;
+const PENALTY_SKIPPED = 0.999;
+const PENALTY_CASE_MISMATCH = 0.9999;
+const PENALTY_NOT_COMPLETE = 0.99;
+const IS_GAP_REGEXP = /[\\/_+.#"@[({&]/;
+const COUNT_GAPS_REGEXP = /[\\/_+.#"@[({&]/g;
+const IS_SPACE_REGEXP = /[\s-]/;
+const COUNT_SPACE_REGEXP = /[\s-]/g;
+function computeCommandScoreInner(string, abbreviation, lowerString, lowerAbbreviation, stringIndex, abbreviationIndex, memoizedResults) {
+ if (abbreviationIndex === abbreviation.length) {
+ if (stringIndex === string.length)
+ return SCORE_CONTINUE_MATCH;
+ return PENALTY_NOT_COMPLETE;
+ }
+ const memoizeKey = `${stringIndex},${abbreviationIndex}`;
+ if (memoizedResults[memoizeKey] !== void 0)
+ return memoizedResults[memoizeKey];
+ const abbreviationChar = lowerAbbreviation.charAt(abbreviationIndex);
+ let index = lowerString.indexOf(abbreviationChar, stringIndex);
+ let highScore = 0;
+ let score, transposedScore, wordBreaks, spaceBreaks;
+ while (index >= 0) {
+ score = computeCommandScoreInner(string, abbreviation, lowerString, lowerAbbreviation, index + 1, abbreviationIndex + 1, memoizedResults);
+ if (score > highScore) {
+ if (index === stringIndex) {
+ score *= SCORE_CONTINUE_MATCH;
+ } else if (IS_GAP_REGEXP.test(string.charAt(index - 1))) {
+ score *= SCORE_NON_SPACE_WORD_JUMP;
+ wordBreaks = string.slice(stringIndex, index - 1).match(COUNT_GAPS_REGEXP);
+ if (wordBreaks && stringIndex > 0) {
+ score *= PENALTY_SKIPPED ** wordBreaks.length;
+ }
+ } else if (IS_SPACE_REGEXP.test(string.charAt(index - 1))) {
+ score *= SCORE_SPACE_WORD_JUMP;
+ spaceBreaks = string.slice(stringIndex, index - 1).match(COUNT_SPACE_REGEXP);
+ if (spaceBreaks && stringIndex > 0) {
+ score *= PENALTY_SKIPPED ** spaceBreaks.length;
+ }
+ } else {
+ score *= SCORE_CHARACTER_JUMP;
+ if (stringIndex > 0) {
+ score *= PENALTY_SKIPPED ** (index - stringIndex);
+ }
+ }
+ if (string.charAt(index) !== abbreviation.charAt(abbreviationIndex)) {
+ score *= PENALTY_CASE_MISMATCH;
+ }
+ }
+ if (score < SCORE_TRANSPOSITION && lowerString.charAt(index - 1) === lowerAbbreviation.charAt(abbreviationIndex + 1) || lowerAbbreviation.charAt(abbreviationIndex + 1) === lowerAbbreviation.charAt(abbreviationIndex) && lowerString.charAt(index - 1) !== lowerAbbreviation.charAt(abbreviationIndex)) {
+ transposedScore = computeCommandScoreInner(string, abbreviation, lowerString, lowerAbbreviation, index + 1, abbreviationIndex + 2, memoizedResults);
+ if (transposedScore * SCORE_TRANSPOSITION > score) {
+ score = transposedScore * SCORE_TRANSPOSITION;
+ }
+ }
+ if (score > highScore) {
+ highScore = score;
+ }
+ index = lowerString.indexOf(abbreviationChar, index + 1);
+ }
+ memoizedResults[memoizeKey] = highScore;
+ return highScore;
+}
+function formatInput(string) {
+ return string.toLowerCase().replace(COUNT_SPACE_REGEXP, " ");
+}
+function computeCommandScore(command, search, commandKeywords) {
+ command = commandKeywords && commandKeywords.length > 0 ? `${`${command} ${commandKeywords?.join(" ")}`}` : command;
+ return computeCommandScoreInner(command, search, formatInput(command), formatInput(search), 0, 0, {});
+}
+function useGraceArea(opts) {
+ const enabled = opts.enabled();
+ const isPointerInTransit = boxAutoReset(false, opts.transitTimeout ?? 300, (value) => {
+ if (enabled) {
+ opts.setIsPointerInTransit?.(value);
+ }
+ });
+ let pointerGraceArea = null;
+ function handleRemoveGraceArea() {
+ pointerGraceArea = null;
+ isPointerInTransit.current = false;
+ }
+ function handleCreateGraceArea(e, hoverTarget) {
+ const currentTarget = e.currentTarget;
+ if (!isHTMLElement(currentTarget)) return;
+ const exitPoint = { x: e.clientX, y: e.clientY };
+ const exitSide = getExitSideFromRect(exitPoint, currentTarget.getBoundingClientRect());
+ const paddedExitPoints = getPaddedExitPoints(exitPoint, exitSide);
+ const hoverTargetPoints = getPointsFromRect(hoverTarget.getBoundingClientRect());
+ const graceArea = getHull([...paddedExitPoints, ...hoverTargetPoints]);
+ pointerGraceArea = graceArea;
+ isPointerInTransit.current = true;
+ }
+ watch(
+ [
+ opts.triggerNode,
+ opts.contentNode,
+ opts.enabled
+ ],
+ ([triggerNode, contentNode, enabled2]) => {
+ if (!triggerNode || !contentNode || !enabled2) return;
+ const handleTriggerLeave = (e) => {
+ handleCreateGraceArea(e, contentNode);
+ };
+ const handleContentLeave = (e) => {
+ handleCreateGraceArea(e, triggerNode);
+ };
+ return executeCallbacks(on(triggerNode, "pointerleave", handleTriggerLeave), on(contentNode, "pointerleave", handleContentLeave));
+ }
+ );
+ watch(() => pointerGraceArea, () => {
+ const handleTrackPointerGrace = (e) => {
+ if (!pointerGraceArea) return;
+ const target = e.target;
+ if (!isElement(target)) return;
+ const pointerPosition = { x: e.clientX, y: e.clientY };
+ const hasEnteredTarget = opts.triggerNode()?.contains(target) || opts.contentNode()?.contains(target);
+ const isPointerOutsideGraceArea = !isPointInPolygon(pointerPosition, pointerGraceArea);
+ if (hasEnteredTarget) {
+ handleRemoveGraceArea();
+ } else if (isPointerOutsideGraceArea) {
+ handleRemoveGraceArea();
+ opts.onPointerExit();
+ }
+ };
+ return on(document, "pointermove", handleTrackPointerGrace);
+ });
+ return { isPointerInTransit };
+}
+function getExitSideFromRect(point, rect) {
+ const top = Math.abs(rect.top - point.y);
+ const bottom = Math.abs(rect.bottom - point.y);
+ const right = Math.abs(rect.right - point.x);
+ const left = Math.abs(rect.left - point.x);
+ switch (Math.min(top, bottom, right, left)) {
+ case left:
+ return "left";
+ case right:
+ return "right";
+ case top:
+ return "top";
+ case bottom:
+ return "bottom";
+ default:
+ throw new Error("unreachable");
+ }
+}
+function getPaddedExitPoints(exitPoint, exitSide, padding = 5) {
+ const tipPadding = padding * 1.5;
+ switch (exitSide) {
+ case "top":
+ return [
+ {
+ x: exitPoint.x - padding,
+ y: exitPoint.y + padding
+ },
+ { x: exitPoint.x, y: exitPoint.y - tipPadding },
+ {
+ x: exitPoint.x + padding,
+ y: exitPoint.y + padding
+ }
+ ];
+ case "bottom":
+ return [
+ {
+ x: exitPoint.x - padding,
+ y: exitPoint.y - padding
+ },
+ { x: exitPoint.x, y: exitPoint.y + tipPadding },
+ {
+ x: exitPoint.x + padding,
+ y: exitPoint.y - padding
+ }
+ ];
+ case "left":
+ return [
+ {
+ x: exitPoint.x + padding,
+ y: exitPoint.y - padding
+ },
+ { x: exitPoint.x - tipPadding, y: exitPoint.y },
+ {
+ x: exitPoint.x + padding,
+ y: exitPoint.y + padding
+ }
+ ];
+ case "right":
+ return [
+ {
+ x: exitPoint.x - padding,
+ y: exitPoint.y - padding
+ },
+ { x: exitPoint.x + tipPadding, y: exitPoint.y },
+ {
+ x: exitPoint.x - padding,
+ y: exitPoint.y + padding
+ }
+ ];
+ }
+}
+function getPointsFromRect(rect) {
+ const { top, right, bottom, left } = rect;
+ return [
+ { x: left, y: top },
+ { x: right, y: top },
+ { x: right, y: bottom },
+ { x: left, y: bottom }
+ ];
+}
+function isPointInPolygon(point, polygon) {
+ const { x, y } = point;
+ let inside = false;
+ for (let i = 0, j2 = polygon.length - 1; i < polygon.length; j2 = i++) {
+ const xi = polygon[i].x;
+ const yi = polygon[i].y;
+ const xj = polygon[j2].x;
+ const yj = polygon[j2].y;
+ const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
+ if (intersect) inside = !inside;
+ }
+ return inside;
+}
+function getHull(points) {
+ const newPoints = points.slice();
+ newPoints.sort((a, b) => {
+ if (a.x < b.x) return -1;
+ else if (a.x > b.x) return 1;
+ else if (a.y < b.y) return -1;
+ else if (a.y > b.y) return 1;
+ else return 0;
+ });
+ return getHullPresorted(newPoints);
+}
+function getHullPresorted(points) {
+ if (points.length <= 1) return points.slice();
+ const upperHull = [];
+ for (let i = 0; i < points.length; i++) {
+ const p2 = points[i];
+ while (upperHull.length >= 2) {
+ const q = upperHull[upperHull.length - 1];
+ const r = upperHull[upperHull.length - 2];
+ if ((q.x - r.x) * (p2.y - r.y) >= (q.y - r.y) * (p2.x - r.x)) upperHull.pop();
+ else break;
+ }
+ upperHull.push(p2);
+ }
+ upperHull.pop();
+ const lowerHull = [];
+ for (let i = points.length - 1; i >= 0; i--) {
+ const p2 = points[i];
+ while (lowerHull.length >= 2) {
+ const q = lowerHull[lowerHull.length - 1];
+ const r = lowerHull[lowerHull.length - 2];
+ if ((q.x - r.x) * (p2.y - r.y) >= (q.y - r.y) * (p2.x - r.x)) lowerHull.pop();
+ else break;
+ }
+ lowerHull.push(p2);
+ }
+ lowerHull.pop();
+ if (upperHull.length === 1 && lowerHull.length === 1 && upperHull[0].x === lowerHull[0].x && upperHull[0].y === lowerHull[0].y) return upperHull;
+ else return upperHull.concat(lowerHull);
+}
+class PopoverRootState {
+ opts;
+ contentNode = null;
+ triggerNode = null;
+ constructor(opts) {
+ this.opts = opts;
+ }
+ toggleOpen() {
+ this.opts.open.current = !this.opts.open.current;
+ }
+ handleClose() {
+ if (!this.opts.open.current) return;
+ this.opts.open.current = false;
+ }
+}
+class PopoverTriggerState {
+ opts;
+ root;
+ constructor(opts, root) {
+ this.opts = opts;
+ this.root = root;
+ useRefById({
+ ...opts,
+ onRefChange: (node) => {
+ this.root.triggerNode = node;
+ }
+ });
+ this.onclick = this.onclick.bind(this);
+ this.onkeydown = this.onkeydown.bind(this);
+ }
+ onclick(e) {
+ if (this.opts.disabled.current) return;
+ if (e.button !== 0) return;
+ this.root.toggleOpen();
+ }
+ onkeydown(e) {
+ if (this.opts.disabled.current) return;
+ if (!(e.key === ENTER || e.key === SPACE)) return;
+ e.preventDefault();
+ this.root.toggleOpen();
+ }
+ #getAriaControls() {
+ if (this.root.opts.open.current && this.root.contentNode?.id) {
+ return this.root.contentNode?.id;
+ }
+ return void 0;
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ "aria-haspopup": "dialog",
+ "aria-expanded": getAriaExpanded(this.root.opts.open.current),
+ "data-state": getDataOpenClosed(this.root.opts.open.current),
+ "aria-controls": this.#getAriaControls(),
+ "data-popover-trigger": "",
+ disabled: this.opts.disabled.current,
+ //
+ onkeydown: this.onkeydown,
+ onclick: this.onclick
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class PopoverContentState {
+ opts;
+ root;
+ constructor(opts, root) {
+ this.opts = opts;
+ this.root = root;
+ useRefById({
+ ...opts,
+ deps: () => this.root.opts.open.current,
+ onRefChange: (node) => {
+ this.root.contentNode = node;
+ }
+ });
+ }
+ onInteractOutside = (e) => {
+ this.opts.onInteractOutside.current(e);
+ if (e.defaultPrevented) return;
+ if (!isElement(e.target)) return;
+ const closestTrigger = e.target.closest(`[data-popover-trigger]`);
+ if (closestTrigger === this.root.triggerNode) return;
+ this.root.handleClose();
+ };
+ onEscapeKeydown = (e) => {
+ this.opts.onEscapeKeydown.current(e);
+ if (e.defaultPrevented) return;
+ this.root.handleClose();
+ };
+ onCloseAutoFocus = (e) => {
+ this.opts.onCloseAutoFocus.current(e);
+ if (e.defaultPrevented) return;
+ e.preventDefault();
+ this.root.triggerNode?.focus();
+ };
+ #snippetProps = derived(() => ({ open: this.root.opts.open.current }));
+ get snippetProps() {
+ return this.#snippetProps();
+ }
+ set snippetProps($$value) {
+ return this.#snippetProps($$value);
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ tabindex: -1,
+ "data-state": getDataOpenClosed(this.root.opts.open.current),
+ "data-popover-content": "",
+ style: { pointerEvents: "auto" }
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+ popperProps = {
+ onInteractOutside: this.onInteractOutside,
+ onEscapeKeydown: this.onEscapeKeydown,
+ onCloseAutoFocus: this.onCloseAutoFocus
+ };
+}
+const PopoverRootContext = new Context("Popover.Root");
+function usePopoverRoot(props) {
+ return PopoverRootContext.set(new PopoverRootState(props));
+}
+function usePopoverTrigger(props) {
+ return new PopoverTriggerState(props, PopoverRootContext.get());
+}
+function usePopoverContent(props) {
+ return new PopoverContentState(props, PopoverRootContext.get());
+}
+function Popover_content$1($$payload, $$props) {
+ push();
+ let {
+ child,
+ children,
+ ref = null,
+ id = useId$1(),
+ forceMount = false,
+ onCloseAutoFocus = noop$1,
+ onEscapeKeydown = noop$1,
+ onInteractOutside = noop$1,
+ trapFocus = true,
+ preventScroll = false,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const contentState = usePopoverContent({
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v),
+ onInteractOutside: box.with(() => onInteractOutside),
+ onEscapeKeydown: box.with(() => onEscapeKeydown),
+ onCloseAutoFocus: box.with(() => onCloseAutoFocus)
+ });
+ const mergedProps = mergeProps(restProps, contentState.props);
+ if (forceMount) {
+ $$payload.out += "";
+ {
+ let popper = function($$payload2, { props, wrapperProps }) {
+ const finalProps = mergeProps(props, {
+ style: getFloatingContentCSSVars("popover")
+ });
+ if (child) {
+ $$payload2.out += "";
+ child($$payload2, {
+ props: finalProps,
+ wrapperProps,
+ ...contentState.snippetProps
+ });
+ $$payload2.out += ``;
+ } else {
+ $$payload2.out += "";
+ $$payload2.out += ``;
+ children?.($$payload2);
+ $$payload2.out += `
`;
+ }
+ $$payload2.out += ``;
+ };
+ Popper_layer_force_mount($$payload, spread_props([
+ mergedProps,
+ contentState.popperProps,
+ {
+ enabled: contentState.root.opts.open.current,
+ id,
+ trapFocus,
+ preventScroll,
+ loop: true,
+ forceMount: true,
+ popper,
+ $$slots: { popper: true }
+ }
+ ]));
+ }
+ } else if (!forceMount) {
+ $$payload.out += "";
+ {
+ let popper = function($$payload2, { props, wrapperProps }) {
+ const finalProps = mergeProps(props, {
+ style: getFloatingContentCSSVars("popover")
+ });
+ if (child) {
+ $$payload2.out += "";
+ child($$payload2, {
+ props: finalProps,
+ wrapperProps,
+ ...contentState.snippetProps
+ });
+ $$payload2.out += ``;
+ } else {
+ $$payload2.out += "";
+ $$payload2.out += ``;
+ children?.($$payload2);
+ $$payload2.out += `
`;
+ }
+ $$payload2.out += ``;
+ };
+ Popper_layer($$payload, spread_props([
+ mergedProps,
+ contentState.popperProps,
+ {
+ present: contentState.root.opts.open.current,
+ id,
+ trapFocus,
+ preventScroll,
+ loop: true,
+ forceMount: false,
+ popper,
+ $$slots: { popper: true }
+ }
+ ]));
+ }
+ } else {
+ $$payload.out += "";
+ }
+ $$payload.out += ``;
+ bind_props($$props, { ref });
+ pop();
+}
+function Popover_trigger($$payload, $$props) {
+ push();
+ let {
+ children,
+ child,
+ id = useId$1(),
+ ref = null,
+ type = "button",
+ disabled = false,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const triggerState = usePopoverTrigger({
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v),
+ disabled: box.with(() => Boolean(disabled))
+ });
+ const mergedProps = mergeProps(restProps, triggerState.props, { type });
+ Floating_layer_anchor($$payload, {
+ id,
+ children: ($$payload2) => {
+ if (child) {
+ $$payload2.out += "";
+ child($$payload2, { props: mergedProps });
+ $$payload2.out += ``;
+ } else {
+ $$payload2.out += "";
+ $$payload2.out += ``;
+ children?.($$payload2);
+ $$payload2.out += ` `;
+ }
+ $$payload2.out += ``;
+ }
+ });
+ bind_props($$props, { ref });
+ pop();
+}
+function Dialog($$payload, $$props) {
+ push();
+ let { open = false, onOpenChange = noop$1, children } = $$props;
+ useDialogRoot({
+ variant: box.with(() => "dialog"),
+ open: box.with(() => open, (v) => {
+ open = v;
+ onOpenChange(v);
+ })
+ });
+ children?.($$payload);
+ $$payload.out += ``;
+ bind_props($$props, { open });
+ pop();
+}
+function Dialog_content($$payload, $$props) {
+ push();
+ let {
+ id = useId$1(),
+ children,
+ child,
+ ref = null,
+ forceMount = false,
+ onCloseAutoFocus = noop$1,
+ onOpenAutoFocus = noop$1,
+ onEscapeKeydown = noop$1,
+ onInteractOutside = noop$1,
+ trapFocus = true,
+ preventScroll = true,
+ restoreScrollDelay = null,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const contentState = useDialogContent({
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v)
+ });
+ const mergedProps = mergeProps(restProps, contentState.props);
+ {
+ let presence = function($$payload2) {
+ {
+ let focusScope = function($$payload3, { props: focusScopeProps }) {
+ Escape_layer($$payload3, spread_props([
+ mergedProps,
+ {
+ enabled: contentState.root.opts.open.current,
+ onEscapeKeydown: (e) => {
+ onEscapeKeydown(e);
+ if (e.defaultPrevented) return;
+ contentState.root.handleClose();
+ },
+ children: ($$payload4) => {
+ Dismissible_layer($$payload4, spread_props([
+ mergedProps,
+ {
+ enabled: contentState.root.opts.open.current,
+ onInteractOutside: (e) => {
+ onInteractOutside(e);
+ if (e.defaultPrevented) return;
+ contentState.root.handleClose();
+ },
+ children: ($$payload5) => {
+ Text_selection_layer($$payload5, spread_props([
+ mergedProps,
+ {
+ enabled: contentState.root.opts.open.current,
+ children: ($$payload6) => {
+ if (child) {
+ $$payload6.out += "";
+ if (contentState.root.opts.open.current) {
+ $$payload6.out += "";
+ Scroll_lock($$payload6, { preventScroll, restoreScrollDelay });
+ } else {
+ $$payload6.out += "";
+ }
+ $$payload6.out += ` `;
+ child($$payload6, {
+ props: mergeProps(mergedProps, focusScopeProps),
+ ...contentState.snippetProps
+ });
+ $$payload6.out += ``;
+ } else {
+ $$payload6.out += "";
+ Scroll_lock($$payload6, { preventScroll });
+ $$payload6.out += ` `;
+ children?.($$payload6);
+ $$payload6.out += `
`;
+ }
+ $$payload6.out += ``;
+ },
+ $$slots: { default: true }
+ }
+ ]));
+ },
+ $$slots: { default: true }
+ }
+ ]));
+ },
+ $$slots: { default: true }
+ }
+ ]));
+ };
+ Focus_scope($$payload2, {
+ loop: true,
+ trapFocus: shouldTrapFocus({
+ forceMount,
+ present: contentState.root.opts.open.current,
+ trapFocus,
+ open: contentState.root.opts.open.current
+ }),
+ onOpenAutoFocus,
+ id,
+ onCloseAutoFocus: (e) => {
+ onCloseAutoFocus(e);
+ if (e.defaultPrevented) return;
+ contentState.root.triggerNode?.focus();
+ },
+ focusScope
+ });
+ }
+ };
+ Presence_layer($$payload, spread_props([
+ mergedProps,
+ {
+ forceMount,
+ present: contentState.root.opts.open.current || forceMount,
+ presence,
+ $$slots: { presence: true }
+ }
+ ]));
+ }
+ bind_props($$props, { ref });
+ pop();
+}
+const ROOT_ATTR = "data-label-root";
+class LabelRootState {
+ opts;
+ constructor(opts) {
+ this.opts = opts;
+ this.onmousedown = this.onmousedown.bind(this);
+ useRefById(opts);
+ }
+ onmousedown(e) {
+ if (e.detail > 1) e.preventDefault();
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ [ROOT_ATTR]: "",
+ onmousedown: this.onmousedown
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+function setLabelRootState(props) {
+ return new LabelRootState(props);
+}
+function Label$1($$payload, $$props) {
+ push();
+ let {
+ children,
+ child,
+ id = useId$1(),
+ ref = null,
+ for: forProp,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const rootState = setLabelRootState({
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v)
+ });
+ const mergedProps = mergeProps(restProps, rootState.props, { for: forProp });
+ if (child) {
+ $$payload.out += "";
+ child($$payload, { props: mergedProps });
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ $$payload.out += ``;
+ children?.($$payload);
+ $$payload.out += ` `;
+ }
+ $$payload.out += ``;
+ bind_props($$props, { ref });
+ pop();
+}
+const LINK_PREVIEW_CONTENT_ATTR = "data-link-preview-content";
+const LINK_PREVIEW_TRIGGER_ATTR = "data-link-preview-trigger";
+class LinkPreviewRootState {
+ opts;
+ hasSelection = false;
+ isPointerDownOnContent = false;
+ containsSelection = false;
+ timeout = null;
+ contentNode = null;
+ contentMounted = false;
+ triggerNode = null;
+ isOpening = false;
+ constructor(opts) {
+ this.opts = opts;
+ watch(() => this.opts.open.current, (isOpen) => {
+ if (!isOpen) {
+ this.hasSelection = false;
+ return;
+ }
+ const handlePointerUp = () => {
+ this.containsSelection = false;
+ this.isPointerDownOnContent = false;
+ afterSleep(1, () => {
+ const isSelection = document.getSelection()?.toString() !== "";
+ if (isSelection) {
+ this.hasSelection = true;
+ } else {
+ this.hasSelection = false;
+ }
+ });
+ };
+ const unsubListener = on(document, "pointerup", handlePointerUp);
+ if (!this.contentNode) return;
+ const tabCandidates = getTabbableCandidates(this.contentNode);
+ for (const candidate of tabCandidates) {
+ candidate.setAttribute("tabindex", "-1");
+ }
+ return () => {
+ unsubListener();
+ this.hasSelection = false;
+ this.isPointerDownOnContent = false;
+ };
+ });
+ }
+ clearTimeout() {
+ if (this.timeout) {
+ window.clearTimeout(this.timeout);
+ this.timeout = null;
+ }
+ }
+ handleOpen() {
+ this.clearTimeout();
+ if (this.opts.open.current) return;
+ this.isOpening = true;
+ this.timeout = window.setTimeout(
+ () => {
+ if (this.isOpening) {
+ this.opts.open.current = true;
+ this.isOpening = false;
+ }
+ },
+ this.opts.openDelay.current
+ );
+ }
+ immediateClose() {
+ this.clearTimeout();
+ this.isOpening = false;
+ this.opts.open.current = false;
+ }
+ handleClose() {
+ this.isOpening = false;
+ this.clearTimeout();
+ if (!this.isPointerDownOnContent && !this.hasSelection) {
+ this.timeout = window.setTimeout(
+ () => {
+ this.opts.open.current = false;
+ },
+ this.opts.closeDelay.current
+ );
+ }
+ }
+}
+class LinkPreviewTriggerState {
+ opts;
+ root;
+ constructor(opts, root) {
+ this.opts = opts;
+ this.root = root;
+ this.onpointerenter = this.onpointerenter.bind(this);
+ this.onpointerleave = this.onpointerleave.bind(this);
+ this.onfocus = this.onfocus.bind(this);
+ this.onblur = this.onblur.bind(this);
+ useRefById({
+ ...opts,
+ onRefChange: (node) => {
+ this.root.triggerNode = node;
+ }
+ });
+ }
+ onpointerenter(e) {
+ if (isTouch(e)) return;
+ this.root.handleOpen();
+ }
+ onpointerleave(e) {
+ if (isTouch(e)) return;
+ if (!this.root.contentMounted) {
+ this.root.immediateClose();
+ }
+ }
+ onfocus(e) {
+ if (!isFocusVisible(e.currentTarget)) return;
+ this.root.handleOpen();
+ }
+ onblur(_) {
+ this.root.handleClose();
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ "aria-haspopup": "dialog",
+ "aria-expanded": getAriaExpanded(this.root.opts.open.current),
+ "data-state": getDataOpenClosed(this.root.opts.open.current),
+ "aria-controls": this.root.contentNode?.id,
+ role: "button",
+ [LINK_PREVIEW_TRIGGER_ATTR]: "",
+ onpointerenter: this.onpointerenter,
+ onfocus: this.onfocus,
+ onblur: this.onblur,
+ onpointerleave: this.onpointerleave
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class LinkPreviewContentState {
+ opts;
+ root;
+ constructor(opts, root) {
+ this.opts = opts;
+ this.root = root;
+ this.onpointerdown = this.onpointerdown.bind(this);
+ this.onpointerenter = this.onpointerenter.bind(this);
+ this.onfocusout = this.onfocusout.bind(this);
+ useRefById({
+ ...opts,
+ onRefChange: (node) => {
+ this.root.contentNode = node;
+ },
+ deps: () => this.root.opts.open.current
+ });
+ useGraceArea({
+ triggerNode: () => this.root.triggerNode,
+ contentNode: () => this.opts.ref.current,
+ enabled: () => this.root.opts.open.current,
+ onPointerExit: () => {
+ this.root.handleClose();
+ }
+ });
+ }
+ onpointerdown(e) {
+ const target = e.target;
+ if (!isElement(target)) return;
+ if (e.currentTarget.contains(target)) {
+ this.root.containsSelection = true;
+ }
+ this.root.hasSelection = true;
+ this.root.isPointerDownOnContent = true;
+ }
+ onpointerenter(e) {
+ if (isTouch(e)) return;
+ this.root.handleOpen();
+ }
+ onfocusout(e) {
+ e.preventDefault();
+ }
+ onInteractOutside = (e) => {
+ this.opts.onInteractOutside.current(e);
+ if (e.defaultPrevented) return;
+ this.root.handleClose();
+ };
+ onEscapeKeydown = (e) => {
+ this.opts.onEscapeKeydown.current?.(e);
+ if (e.defaultPrevented) return;
+ this.root.handleClose();
+ };
+ onOpenAutoFocus = (e) => {
+ e.preventDefault();
+ };
+ onCloseAutoFocus = (e) => {
+ e.preventDefault();
+ };
+ #snippetProps = derived(() => ({ open: this.root.opts.open.current }));
+ get snippetProps() {
+ return this.#snippetProps();
+ }
+ set snippetProps($$value) {
+ return this.#snippetProps($$value);
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ tabindex: -1,
+ "data-state": getDataOpenClosed(this.root.opts.open.current),
+ [LINK_PREVIEW_CONTENT_ATTR]: "",
+ onpointerdown: this.onpointerdown,
+ onpointerenter: this.onpointerenter,
+ onfocusout: this.onfocusout
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+ popperProps = {
+ onInteractOutside: this.onInteractOutside,
+ onEscapeKeydown: this.onEscapeKeydown,
+ onOpenAutoFocus: this.onOpenAutoFocus,
+ onCloseAutoFocus: this.onCloseAutoFocus
+ };
+}
+const LinkPreviewRootContext = new Context("LinkPreview.Root");
+function useLinkPreviewRoot(props) {
+ return LinkPreviewRootContext.set(new LinkPreviewRootState(props));
+}
+function useLinkPreviewTrigger(props) {
+ return new LinkPreviewTriggerState(props, LinkPreviewRootContext.get());
+}
+function useLinkPreviewContent(props) {
+ return new LinkPreviewContentState(props, LinkPreviewRootContext.get());
+}
+function Link_preview($$payload, $$props) {
+ push();
+ let {
+ open = false,
+ onOpenChange = noop$1,
+ openDelay = 700,
+ closeDelay = 300,
+ children
+ } = $$props;
+ useLinkPreviewRoot({
+ open: box.with(() => open, (v) => {
+ open = v;
+ onOpenChange(v);
+ }),
+ openDelay: box.with(() => openDelay),
+ closeDelay: box.with(() => closeDelay)
+ });
+ $$payload.out += ``;
+ Floating_layer($$payload, {
+ children: ($$payload2) => {
+ children?.($$payload2);
+ $$payload2.out += ``;
+ }
+ });
+ $$payload.out += ``;
+ bind_props($$props, { open });
+ pop();
+}
+function Link_preview_content($$payload, $$props) {
+ push();
+ let {
+ children,
+ child,
+ id = useId$1(),
+ ref = null,
+ side = "top",
+ sideOffset = 0,
+ align = "center",
+ avoidCollisions = true,
+ arrowPadding = 0,
+ sticky = "partial",
+ hideWhenDetached = false,
+ collisionPadding = 0,
+ onInteractOutside = noop$1,
+ onEscapeKeydown = noop$1,
+ forceMount = false,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const contentState = useLinkPreviewContent({
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v),
+ onInteractOutside: box.with(() => onInteractOutside),
+ onEscapeKeydown: box.with(() => onEscapeKeydown)
+ });
+ const floatingProps = {
+ side,
+ sideOffset,
+ align,
+ avoidCollisions,
+ arrowPadding,
+ sticky,
+ hideWhenDetached,
+ collisionPadding
+ };
+ const mergedProps = mergeProps(restProps, floatingProps, contentState.props);
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ if (forceMount) {
+ $$payload2.out += "";
+ {
+ let popper = function($$payload3, { props, wrapperProps }) {
+ const mergedProps2 = mergeProps(props, {
+ style: getFloatingContentCSSVars("link-preview")
+ });
+ if (child) {
+ $$payload3.out += "";
+ child($$payload3, {
+ props: mergedProps2,
+ wrapperProps,
+ ...contentState.snippetProps
+ });
+ $$payload3.out += ``;
+ } else {
+ $$payload3.out += "";
+ $$payload3.out += ``;
+ children?.($$payload3);
+ $$payload3.out += `
`;
+ }
+ $$payload3.out += ``;
+ };
+ Popper_layer_force_mount($$payload2, spread_props([
+ mergedProps,
+ contentState.popperProps,
+ {
+ enabled: contentState.root.opts.open.current,
+ id,
+ trapFocus: false,
+ loop: false,
+ preventScroll: false,
+ forceMount: true,
+ popper,
+ $$slots: { popper: true }
+ }
+ ]));
+ }
+ } else if (!forceMount) {
+ $$payload2.out += "";
+ {
+ let popper = function($$payload3, { props, wrapperProps }) {
+ const mergedProps2 = mergeProps(props, {
+ style: getFloatingContentCSSVars("link-preview")
+ });
+ if (child) {
+ $$payload3.out += "";
+ child($$payload3, {
+ props: mergedProps2,
+ wrapperProps,
+ ...contentState.snippetProps
+ });
+ $$payload3.out += ``;
+ } else {
+ $$payload3.out += "";
+ $$payload3.out += ``;
+ children?.($$payload3);
+ $$payload3.out += `
`;
+ }
+ $$payload3.out += ` `;
+ Mounted$1($$payload3, {
+ get mounted() {
+ return contentState.root.contentMounted;
+ },
+ set mounted($$value) {
+ contentState.root.contentMounted = $$value;
+ $$settled = false;
+ }
+ });
+ $$payload3.out += ``;
+ };
+ Popper_layer($$payload2, spread_props([
+ mergedProps,
+ contentState.popperProps,
+ {
+ present: contentState.root.opts.open.current,
+ id,
+ trapFocus: false,
+ loop: false,
+ preventScroll: false,
+ forceMount: false,
+ popper,
+ $$slots: { popper: true }
+ }
+ ]));
+ }
+ } else {
+ $$payload2.out += "";
+ }
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ bind_props($$props, { ref });
+ pop();
+}
+function Link_preview_trigger($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ id = useId$1(),
+ child,
+ children,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const triggerState = useLinkPreviewTrigger({
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v)
+ });
+ const mergedProps = mergeProps(restProps, triggerState.props);
+ $$payload.out += ``;
+ Floating_layer_anchor($$payload, {
+ id,
+ children: ($$payload2) => {
+ if (child) {
+ $$payload2.out += "";
+ child($$payload2, { props: mergedProps });
+ $$payload2.out += ``;
+ } else {
+ $$payload2.out += "";
+ $$payload2.out += ``;
+ children?.($$payload2);
+ $$payload2.out += ` `;
+ }
+ $$payload2.out += ``;
+ }
+ });
+ $$payload.out += ``;
+ bind_props($$props, { ref });
+ pop();
+}
+function useResizeObserver(node, onResize) {
+}
+function Popover($$payload, $$props) {
+ push();
+ let { open = false, onOpenChange = noop$1, children } = $$props;
+ usePopoverRoot({
+ open: box.with(() => open, (v) => {
+ open = v;
+ onOpenChange(v);
+ })
+ });
+ Floating_layer($$payload, {
+ children: ($$payload2) => {
+ children?.($$payload2);
+ $$payload2.out += ``;
+ }
+ });
+ bind_props($$props, { open });
+ pop();
+}
+function clamp(n2, min, max) {
+ return Math.min(max, Math.max(min, n2));
+}
+const SCROLL_AREA_ROOT_ATTR = "data-scroll-area-root";
+const SCROLL_AREA_VIEWPORT_ATTR = "data-scroll-area-viewport";
+const SCROLL_AREA_CORNER_ATTR = "data-scroll-area-corner";
+const SCROLL_AREA_THUMB_ATTR = "data-scroll-area-thumb";
+const SCROLL_AREA_SCROLLBAR_ATTR = "data-scroll-area-scrollbar";
+class ScrollAreaRootState {
+ opts;
+ scrollAreaNode = null;
+ viewportNode = null;
+ contentNode = null;
+ scrollbarXNode = null;
+ scrollbarYNode = null;
+ cornerWidth = 0;
+ cornerHeight = 0;
+ scrollbarXEnabled = false;
+ scrollbarYEnabled = false;
+ constructor(opts) {
+ this.opts = opts;
+ useRefById({
+ ...opts,
+ onRefChange: (node) => {
+ this.scrollAreaNode = node;
+ }
+ });
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ dir: this.opts.dir.current,
+ style: {
+ position: "relative",
+ "--bits-scroll-area-corner-height": `${this.cornerHeight}px`,
+ "--bits-scroll-area-corner-width": `${this.cornerWidth}px`
+ },
+ [SCROLL_AREA_ROOT_ATTR]: ""
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class ScrollAreaViewportState {
+ opts;
+ root;
+ #contentId = box(useId$1());
+ #contentRef = box(null);
+ constructor(opts, root) {
+ this.opts = opts;
+ this.root = root;
+ useRefById({
+ ...opts,
+ onRefChange: (node) => {
+ this.root.viewportNode = node;
+ }
+ });
+ useRefById({
+ id: this.#contentId,
+ ref: this.#contentRef,
+ onRefChange: (node) => {
+ this.root.contentNode = node;
+ }
+ });
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ style: {
+ overflowX: this.root.scrollbarXEnabled ? "scroll" : "hidden",
+ overflowY: this.root.scrollbarYEnabled ? "scroll" : "hidden"
+ },
+ [SCROLL_AREA_VIEWPORT_ATTR]: ""
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+ #contentProps = derived(() => ({
+ id: this.#contentId.current,
+ "data-scroll-area-content": "",
+ /**
+ * When horizontal scrollbar is visible: this element should be at least
+ * as wide as its children for size calculations to work correctly.
+ *
+ * When horizontal scrollbar is NOT visible: this element's width should
+ * be constrained by the parent container to enable `text-overflow: ellipsis`
+ */
+ style: {
+ minWidth: this.root.scrollbarXEnabled ? "fit-content" : void 0
+ }
+ }));
+ get contentProps() {
+ return this.#contentProps();
+ }
+ set contentProps($$value) {
+ return this.#contentProps($$value);
+ }
+}
+class ScrollAreaScrollbarState {
+ opts;
+ root;
+ #isHorizontal = derived(() => this.opts.orientation.current === "horizontal");
+ get isHorizontal() {
+ return this.#isHorizontal();
+ }
+ set isHorizontal($$value) {
+ return this.#isHorizontal($$value);
+ }
+ hasThumb = false;
+ constructor(opts, root) {
+ this.opts = opts;
+ this.root = root;
+ }
+}
+class ScrollAreaScrollbarHoverState {
+ scrollbar;
+ root;
+ isVisible = false;
+ constructor(scrollbar) {
+ this.scrollbar = scrollbar;
+ this.root = scrollbar.root;
+ }
+ #props = derived(() => ({
+ "data-state": this.isVisible ? "visible" : "hidden"
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class ScrollAreaScrollbarScrollState {
+ scrollbar;
+ root;
+ machine = useStateMachine("hidden", {
+ hidden: { SCROLL: "scrolling" },
+ scrolling: {
+ SCROLL_END: "idle",
+ POINTER_ENTER: "interacting"
+ },
+ interacting: { SCROLL: "interacting", POINTER_LEAVE: "idle" },
+ idle: {
+ HIDE: "hidden",
+ SCROLL: "scrolling",
+ POINTER_ENTER: "interacting"
+ }
+ });
+ #isHidden = derived(() => this.machine.state.current === "hidden");
+ get isHidden() {
+ return this.#isHidden();
+ }
+ set isHidden($$value) {
+ return this.#isHidden($$value);
+ }
+ constructor(scrollbar) {
+ this.scrollbar = scrollbar;
+ this.root = scrollbar.root;
+ useDebounce(() => this.machine.dispatch("SCROLL_END"), 100);
+ this.onpointerenter = this.onpointerenter.bind(this);
+ this.onpointerleave = this.onpointerleave.bind(this);
+ }
+ onpointerenter(_) {
+ this.machine.dispatch("POINTER_ENTER");
+ }
+ onpointerleave(_) {
+ this.machine.dispatch("POINTER_LEAVE");
+ }
+ #props = derived(() => ({
+ "data-state": this.machine.state.current === "hidden" ? "hidden" : "visible",
+ onpointerenter: this.onpointerenter,
+ onpointerleave: this.onpointerleave
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class ScrollAreaScrollbarAutoState {
+ scrollbar;
+ root;
+ isVisible = false;
+ constructor(scrollbar) {
+ this.scrollbar = scrollbar;
+ this.root = scrollbar.root;
+ useDebounce(
+ () => {
+ const viewportNode = this.root.viewportNode;
+ if (!viewportNode) return;
+ const isOverflowX = viewportNode.offsetWidth < viewportNode.scrollWidth;
+ const isOverflowY = viewportNode.offsetHeight < viewportNode.scrollHeight;
+ this.isVisible = this.scrollbar.isHorizontal ? isOverflowX : isOverflowY;
+ },
+ 10
+ );
+ }
+ #props = derived(() => ({
+ "data-state": this.isVisible ? "visible" : "hidden"
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class ScrollAreaScrollbarVisibleState {
+ scrollbar;
+ root;
+ thumbNode = null;
+ pointerOffset = 0;
+ sizes = {
+ content: 0,
+ viewport: 0,
+ scrollbar: { size: 0, paddingStart: 0, paddingEnd: 0 }
+ };
+ #thumbRatio = derived(() => getThumbRatio(this.sizes.viewport, this.sizes.content));
+ get thumbRatio() {
+ return this.#thumbRatio();
+ }
+ set thumbRatio($$value) {
+ return this.#thumbRatio($$value);
+ }
+ #hasThumb = derived(() => Boolean(this.thumbRatio > 0 && this.thumbRatio < 1));
+ get hasThumb() {
+ return this.#hasThumb();
+ }
+ set hasThumb($$value) {
+ return this.#hasThumb($$value);
+ }
+ // this needs to be a $state to properly restore the transform style when the scrollbar
+ // goes from a hidden to visible state, otherwise it will start at the beginning of the
+ // scrollbar and flicker to the correct position after
+ prevTransformStyle = "";
+ constructor(scrollbar) {
+ this.scrollbar = scrollbar;
+ this.root = scrollbar.root;
+ }
+ setSizes(sizes) {
+ this.sizes = sizes;
+ }
+ getScrollPosition(pointerPos, dir) {
+ return getScrollPositionFromPointer({
+ pointerPos,
+ pointerOffset: this.pointerOffset,
+ sizes: this.sizes,
+ dir
+ });
+ }
+ onThumbPointerUp() {
+ this.pointerOffset = 0;
+ }
+ onThumbPointerDown(pointerPos) {
+ this.pointerOffset = pointerPos;
+ }
+ xOnThumbPositionChange() {
+ if (!(this.root.viewportNode && this.thumbNode)) return;
+ const scrollPos = this.root.viewportNode.scrollLeft;
+ const offset2 = getThumbOffsetFromScroll({
+ scrollPos,
+ sizes: this.sizes,
+ dir: this.root.opts.dir.current
+ });
+ const transformStyle = `translate3d(${offset2}px, 0, 0)`;
+ this.thumbNode.style.transform = transformStyle;
+ this.prevTransformStyle = transformStyle;
+ }
+ xOnWheelScroll(scrollPos) {
+ if (!this.root.viewportNode) return;
+ this.root.viewportNode.scrollLeft = scrollPos;
+ }
+ xOnDragScroll(pointerPos) {
+ if (!this.root.viewportNode) return;
+ this.root.viewportNode.scrollLeft = this.getScrollPosition(pointerPos, this.root.opts.dir.current);
+ }
+ yOnThumbPositionChange() {
+ if (!(this.root.viewportNode && this.thumbNode)) return;
+ const scrollPos = this.root.viewportNode.scrollTop;
+ const offset2 = getThumbOffsetFromScroll({ scrollPos, sizes: this.sizes });
+ const transformStyle = `translate3d(0, ${offset2}px, 0)`;
+ this.thumbNode.style.transform = transformStyle;
+ this.prevTransformStyle = transformStyle;
+ }
+ yOnWheelScroll(scrollPos) {
+ if (!this.root.viewportNode) return;
+ this.root.viewportNode.scrollTop = scrollPos;
+ }
+ yOnDragScroll(pointerPos) {
+ if (!this.root.viewportNode) return;
+ this.root.viewportNode.scrollTop = this.getScrollPosition(pointerPos, this.root.opts.dir.current);
+ }
+}
+class ScrollAreaScrollbarXState {
+ opts;
+ scrollbarVis;
+ root;
+ computedStyle;
+ scrollbar;
+ constructor(opts, scrollbarVis) {
+ this.opts = opts;
+ this.scrollbarVis = scrollbarVis;
+ this.root = scrollbarVis.root;
+ this.scrollbar = scrollbarVis.scrollbar;
+ useRefById({
+ ...this.scrollbar.opts,
+ onRefChange: (node) => {
+ this.root.scrollbarXNode = node;
+ },
+ deps: () => this.opts.mounted.current
+ });
+ }
+ onThumbPointerDown = (pointerPos) => {
+ this.scrollbarVis.onThumbPointerDown(pointerPos.x);
+ };
+ onDragScroll = (pointerPos) => {
+ this.scrollbarVis.xOnDragScroll(pointerPos.x);
+ };
+ onThumbPointerUp = () => {
+ this.scrollbarVis.onThumbPointerUp();
+ };
+ onThumbPositionChange = () => {
+ this.scrollbarVis.xOnThumbPositionChange();
+ };
+ onWheelScroll = (e, maxScrollPos) => {
+ if (!this.root.viewportNode) return;
+ const scrollPos = this.root.viewportNode.scrollLeft + e.deltaX;
+ this.scrollbarVis.xOnWheelScroll(scrollPos);
+ if (isScrollingWithinScrollbarBounds(scrollPos, maxScrollPos)) {
+ e.preventDefault();
+ }
+ };
+ onResize = () => {
+ if (!(this.scrollbar.opts.ref.current && this.root.viewportNode && this.computedStyle)) return;
+ this.scrollbarVis.setSizes({
+ content: this.root.viewportNode.scrollWidth,
+ viewport: this.root.viewportNode.offsetWidth,
+ scrollbar: {
+ size: this.scrollbar.opts.ref.current.clientWidth,
+ paddingStart: toInt(this.computedStyle.paddingLeft),
+ paddingEnd: toInt(this.computedStyle.paddingRight)
+ }
+ });
+ };
+ #thumbSize = derived(() => {
+ return getThumbSize(this.scrollbarVis.sizes);
+ });
+ get thumbSize() {
+ return this.#thumbSize();
+ }
+ set thumbSize($$value) {
+ return this.#thumbSize($$value);
+ }
+ #props = derived(() => ({
+ id: this.scrollbar.opts.id.current,
+ "data-orientation": "horizontal",
+ style: {
+ bottom: 0,
+ left: this.root.opts.dir.current === "rtl" ? "var(--bits-scroll-area-corner-width)" : 0,
+ right: this.root.opts.dir.current === "ltr" ? "var(--bits-scroll-area-corner-width)" : 0,
+ "--bits-scroll-area-thumb-width": `${this.thumbSize}px`
+ }
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class ScrollAreaScrollbarYState {
+ opts;
+ scrollbarVis;
+ root;
+ scrollbar;
+ computedStyle;
+ constructor(opts, scrollbarVis) {
+ this.opts = opts;
+ this.scrollbarVis = scrollbarVis;
+ this.root = scrollbarVis.root;
+ this.scrollbar = scrollbarVis.scrollbar;
+ useRefById({
+ ...this.scrollbar.opts,
+ onRefChange: (node) => {
+ this.root.scrollbarYNode = node;
+ },
+ deps: () => this.opts.mounted.current
+ });
+ this.onThumbPointerDown = this.onThumbPointerDown.bind(this);
+ this.onDragScroll = this.onDragScroll.bind(this);
+ this.onThumbPointerUp = this.onThumbPointerUp.bind(this);
+ this.onThumbPositionChange = this.onThumbPositionChange.bind(this);
+ this.onWheelScroll = this.onWheelScroll.bind(this);
+ this.onResize = this.onResize.bind(this);
+ }
+ onThumbPointerDown(pointerPos) {
+ this.scrollbarVis.onThumbPointerDown(pointerPos.y);
+ }
+ onDragScroll(pointerPos) {
+ this.scrollbarVis.yOnDragScroll(pointerPos.y);
+ }
+ onThumbPointerUp() {
+ this.scrollbarVis.onThumbPointerUp();
+ }
+ onThumbPositionChange() {
+ this.scrollbarVis.yOnThumbPositionChange();
+ }
+ onWheelScroll(e, maxScrollPos) {
+ if (!this.root.viewportNode) return;
+ const scrollPos = this.root.viewportNode.scrollTop + e.deltaY;
+ this.scrollbarVis.yOnWheelScroll(scrollPos);
+ if (isScrollingWithinScrollbarBounds(scrollPos, maxScrollPos)) {
+ e.preventDefault();
+ }
+ }
+ onResize() {
+ if (!(this.scrollbar.opts.ref.current && this.root.viewportNode && this.computedStyle)) return;
+ this.scrollbarVis.setSizes({
+ content: this.root.viewportNode.scrollHeight,
+ viewport: this.root.viewportNode.offsetHeight,
+ scrollbar: {
+ size: this.scrollbar.opts.ref.current.clientHeight,
+ paddingStart: toInt(this.computedStyle.paddingTop),
+ paddingEnd: toInt(this.computedStyle.paddingBottom)
+ }
+ });
+ }
+ #thumbSize = derived(() => {
+ return getThumbSize(this.scrollbarVis.sizes);
+ });
+ get thumbSize() {
+ return this.#thumbSize();
+ }
+ set thumbSize($$value) {
+ return this.#thumbSize($$value);
+ }
+ #props = derived(() => ({
+ id: this.scrollbar.opts.id.current,
+ "data-orientation": "vertical",
+ style: {
+ top: 0,
+ right: this.root.opts.dir.current === "ltr" ? 0 : void 0,
+ left: this.root.opts.dir.current === "rtl" ? 0 : void 0,
+ bottom: "var(--bits-scroll-area-corner-height)",
+ "--bits-scroll-area-thumb-height": `${this.thumbSize}px`
+ }
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class ScrollAreaScrollbarSharedState {
+ scrollbarState;
+ root;
+ scrollbarVis;
+ scrollbar;
+ rect = null;
+ prevWebkitUserSelect = "";
+ handleResize;
+ handleThumbPositionChange;
+ handleWheelScroll;
+ handleThumbPointerDown;
+ handleThumbPointerUp;
+ #maxScrollPos = derived(() => this.scrollbarVis.sizes.content - this.scrollbarVis.sizes.viewport);
+ get maxScrollPos() {
+ return this.#maxScrollPos();
+ }
+ set maxScrollPos($$value) {
+ return this.#maxScrollPos($$value);
+ }
+ constructor(scrollbarState) {
+ this.scrollbarState = scrollbarState;
+ this.root = scrollbarState.root;
+ this.scrollbarVis = scrollbarState.scrollbarVis;
+ this.scrollbar = scrollbarState.scrollbarVis.scrollbar;
+ this.handleResize = useDebounce(() => this.scrollbarState.onResize(), 10);
+ this.handleThumbPositionChange = this.scrollbarState.onThumbPositionChange;
+ this.handleWheelScroll = this.scrollbarState.onWheelScroll;
+ this.handleThumbPointerDown = this.scrollbarState.onThumbPointerDown;
+ this.handleThumbPointerUp = this.scrollbarState.onThumbPointerUp;
+ useResizeObserver(() => this.scrollbar.opts.ref.current, this.handleResize);
+ useResizeObserver(() => this.root.contentNode, this.handleResize);
+ this.onpointerdown = this.onpointerdown.bind(this);
+ this.onpointermove = this.onpointermove.bind(this);
+ this.onpointerup = this.onpointerup.bind(this);
+ }
+ handleDragScroll(e) {
+ if (!this.rect) return;
+ const x = e.clientX - this.rect.left;
+ const y = e.clientY - this.rect.top;
+ this.scrollbarState.onDragScroll({ x, y });
+ }
+ onpointerdown(e) {
+ if (e.button !== 0) return;
+ const target = e.target;
+ target.setPointerCapture(e.pointerId);
+ this.rect = this.scrollbar.opts.ref.current?.getBoundingClientRect() ?? null;
+ this.prevWebkitUserSelect = document.body.style.webkitUserSelect;
+ document.body.style.webkitUserSelect = "none";
+ if (this.root.viewportNode) this.root.viewportNode.style.scrollBehavior = "auto";
+ this.handleDragScroll(e);
+ }
+ onpointermove(e) {
+ this.handleDragScroll(e);
+ }
+ onpointerup(e) {
+ const target = e.target;
+ if (target.hasPointerCapture(e.pointerId)) {
+ target.releasePointerCapture(e.pointerId);
+ }
+ document.body.style.webkitUserSelect = this.prevWebkitUserSelect;
+ if (this.root.viewportNode) this.root.viewportNode.style.scrollBehavior = "";
+ this.rect = null;
+ }
+ #props = derived(() => mergeProps({
+ ...this.scrollbarState.props,
+ style: {
+ position: "absolute",
+ ...this.scrollbarState.props.style
+ },
+ [SCROLL_AREA_SCROLLBAR_ATTR]: "",
+ onpointerdown: this.onpointerdown,
+ onpointermove: this.onpointermove,
+ onpointerup: this.onpointerup
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class ScrollAreaThumbImplState {
+ opts;
+ scrollbarState;
+ #root;
+ #removeUnlinkedScrollListener;
+ #debounceScrollEnd = useDebounce(
+ () => {
+ if (this.#removeUnlinkedScrollListener) {
+ this.#removeUnlinkedScrollListener();
+ this.#removeUnlinkedScrollListener = void 0;
+ }
+ },
+ 100
+ );
+ constructor(opts, scrollbarState) {
+ this.opts = opts;
+ this.scrollbarState = scrollbarState;
+ this.#root = scrollbarState.root;
+ useRefById({
+ ...opts,
+ onRefChange: (node) => {
+ this.scrollbarState.scrollbarVis.thumbNode = node;
+ },
+ deps: () => this.opts.mounted.current
+ });
+ this.onpointerdowncapture = this.onpointerdowncapture.bind(this);
+ this.onpointerup = this.onpointerup.bind(this);
+ }
+ onpointerdowncapture(e) {
+ const thumb = e.target;
+ if (!thumb) return;
+ const thumbRect = thumb.getBoundingClientRect();
+ const x = e.clientX - thumbRect.left;
+ const y = e.clientY - thumbRect.top;
+ this.scrollbarState.handleThumbPointerDown({ x, y });
+ }
+ onpointerup(_) {
+ this.scrollbarState.handleThumbPointerUp();
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ "data-state": this.scrollbarState.scrollbarVis.hasThumb ? "visible" : "hidden",
+ style: {
+ width: "var(--bits-scroll-area-thumb-width)",
+ height: "var(--bits-scroll-area-thumb-height)",
+ transform: this.scrollbarState.scrollbarVis.prevTransformStyle
+ },
+ onpointerdowncapture: this.onpointerdowncapture,
+ onpointerup: this.onpointerup,
+ [SCROLL_AREA_THUMB_ATTR]: ""
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class ScrollAreaCornerImplState {
+ opts;
+ root;
+ #width = 0;
+ #height = 0;
+ #hasSize = derived(() => Boolean(this.#width && this.#height));
+ get hasSize() {
+ return this.#hasSize();
+ }
+ set hasSize($$value) {
+ return this.#hasSize($$value);
+ }
+ constructor(opts, root) {
+ this.opts = opts;
+ this.root = root;
+ useRefById(opts);
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ style: {
+ width: this.#width,
+ height: this.#height,
+ position: "absolute",
+ right: this.root.opts.dir.current === "ltr" ? 0 : void 0,
+ left: this.root.opts.dir.current === "rtl" ? 0 : void 0,
+ bottom: 0
+ },
+ [SCROLL_AREA_CORNER_ATTR]: ""
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+const ScrollAreaRootContext = new Context("ScrollArea.Root");
+const ScrollAreaScrollbarContext = new Context("ScrollArea.Scrollbar");
+const ScrollAreaScrollbarVisibleContext = new Context("ScrollArea.ScrollbarVisible");
+const ScrollAreaScrollbarAxisContext = new Context("ScrollArea.ScrollbarAxis");
+const ScrollAreaScrollbarSharedContext = new Context("ScrollArea.ScrollbarShared");
+function useScrollAreaRoot(props) {
+ return ScrollAreaRootContext.set(new ScrollAreaRootState(props));
+}
+function useScrollAreaViewport(props) {
+ return new ScrollAreaViewportState(props, ScrollAreaRootContext.get());
+}
+function useScrollAreaScrollbar(props) {
+ return ScrollAreaScrollbarContext.set(new ScrollAreaScrollbarState(props, ScrollAreaRootContext.get()));
+}
+function useScrollAreaScrollbarVisible() {
+ return ScrollAreaScrollbarVisibleContext.set(new ScrollAreaScrollbarVisibleState(ScrollAreaScrollbarContext.get()));
+}
+function useScrollAreaScrollbarAuto() {
+ return new ScrollAreaScrollbarAutoState(ScrollAreaScrollbarContext.get());
+}
+function useScrollAreaScrollbarScroll() {
+ return new ScrollAreaScrollbarScrollState(ScrollAreaScrollbarContext.get());
+}
+function useScrollAreaScrollbarHover() {
+ return new ScrollAreaScrollbarHoverState(ScrollAreaScrollbarContext.get());
+}
+function useScrollAreaScrollbarX(props) {
+ return ScrollAreaScrollbarAxisContext.set(new ScrollAreaScrollbarXState(props, ScrollAreaScrollbarVisibleContext.get()));
+}
+function useScrollAreaScrollbarY(props) {
+ return ScrollAreaScrollbarAxisContext.set(new ScrollAreaScrollbarYState(props, ScrollAreaScrollbarVisibleContext.get()));
+}
+function useScrollAreaScrollbarShared() {
+ return ScrollAreaScrollbarSharedContext.set(new ScrollAreaScrollbarSharedState(ScrollAreaScrollbarAxisContext.get()));
+}
+function useScrollAreaThumb(props) {
+ return new ScrollAreaThumbImplState(props, ScrollAreaScrollbarSharedContext.get());
+}
+function useScrollAreaCorner(props) {
+ return new ScrollAreaCornerImplState(props, ScrollAreaRootContext.get());
+}
+function toInt(value) {
+ return value ? Number.parseInt(value, 10) : 0;
+}
+function getThumbRatio(viewportSize, contentSize) {
+ const ratio = viewportSize / contentSize;
+ return Number.isNaN(ratio) ? 0 : ratio;
+}
+function getThumbSize(sizes) {
+ const ratio = getThumbRatio(sizes.viewport, sizes.content);
+ const scrollbarPadding = sizes.scrollbar.paddingStart + sizes.scrollbar.paddingEnd;
+ const thumbSize = (sizes.scrollbar.size - scrollbarPadding) * ratio;
+ return Math.max(thumbSize, 18);
+}
+function getScrollPositionFromPointer({
+ pointerPos,
+ pointerOffset,
+ sizes,
+ dir = "ltr"
+}) {
+ const thumbSizePx = getThumbSize(sizes);
+ const thumbCenter = thumbSizePx / 2;
+ const offset2 = pointerOffset || thumbCenter;
+ const thumbOffsetFromEnd = thumbSizePx - offset2;
+ const minPointerPos = sizes.scrollbar.paddingStart + offset2;
+ const maxPointerPos = sizes.scrollbar.size - sizes.scrollbar.paddingEnd - thumbOffsetFromEnd;
+ const maxScrollPos = sizes.content - sizes.viewport;
+ const scrollRange = dir === "ltr" ? [0, maxScrollPos] : [maxScrollPos * -1, 0];
+ const interpolate = linearScale([minPointerPos, maxPointerPos], scrollRange);
+ return interpolate(pointerPos);
+}
+function getThumbOffsetFromScroll({ scrollPos, sizes, dir = "ltr" }) {
+ const thumbSizePx = getThumbSize(sizes);
+ const scrollbarPadding = sizes.scrollbar.paddingStart + sizes.scrollbar.paddingEnd;
+ const scrollbar = sizes.scrollbar.size - scrollbarPadding;
+ const maxScrollPos = sizes.content - sizes.viewport;
+ const maxThumbPos = scrollbar - thumbSizePx;
+ const scrollClampRange = dir === "ltr" ? [0, maxScrollPos] : [maxScrollPos * -1, 0];
+ const scrollWithoutMomentum = clamp(scrollPos, scrollClampRange[0], scrollClampRange[1]);
+ const interpolate = linearScale([0, maxScrollPos], [0, maxThumbPos]);
+ return interpolate(scrollWithoutMomentum);
+}
+function linearScale(input, output) {
+ return (value) => {
+ if (input[0] === input[1] || output[0] === output[1]) return output[0];
+ const ratio = (output[1] - output[0]) / (input[1] - input[0]);
+ return output[0] + ratio * (value - input[0]);
+ };
+}
+function isScrollingWithinScrollbarBounds(scrollPos, maxScrollPos) {
+ return scrollPos > 0 && scrollPos < maxScrollPos;
+}
+function Scroll_area$1($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ id = useId$1(),
+ type = "hover",
+ dir = "ltr",
+ scrollHideDelay = 600,
+ children,
+ child,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const rootState = useScrollAreaRoot({
+ type: box.with(() => type),
+ dir: box.with(() => dir),
+ scrollHideDelay: box.with(() => scrollHideDelay),
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v)
+ });
+ const mergedProps = mergeProps(restProps, rootState.props);
+ if (child) {
+ $$payload.out += "";
+ child($$payload, { props: mergedProps });
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ $$payload.out += ``;
+ children?.($$payload);
+ $$payload.out += `
`;
+ }
+ $$payload.out += ``;
+ bind_props($$props, { ref });
+ pop();
+}
+function Scroll_area_viewport($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ id = useId$1(),
+ children,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const viewportState = useScrollAreaViewport({
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v)
+ });
+ const mergedProps = mergeProps(restProps, viewportState.props);
+ const mergedContentProps = mergeProps({}, viewportState.contentProps);
+ $$payload.out += ``;
+ children?.($$payload);
+ $$payload.out += `
`;
+ bind_props($$props, { ref });
+ pop();
+}
+function Scroll_area_scrollbar_shared($$payload, $$props) {
+ push();
+ let {
+ child,
+ children,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const scrollbarSharedState = useScrollAreaScrollbarShared();
+ const mergedProps = mergeProps(restProps, scrollbarSharedState.props);
+ if (child) {
+ $$payload.out += "";
+ child($$payload, { props: mergedProps });
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ $$payload.out += ``;
+ children?.($$payload);
+ $$payload.out += `
`;
+ }
+ $$payload.out += ``;
+ pop();
+}
+function Scroll_area_scrollbar_x($$payload, $$props) {
+ push();
+ let { $$slots, $$events, ...restProps } = $$props;
+ const isMounted = new IsMounted();
+ const scrollbarXState = useScrollAreaScrollbarX({ mounted: box.with(() => isMounted.current) });
+ const mergedProps = mergeProps(restProps, scrollbarXState.props);
+ Scroll_area_scrollbar_shared($$payload, spread_props([mergedProps]));
+ pop();
+}
+function Scroll_area_scrollbar_y($$payload, $$props) {
+ push();
+ let { $$slots, $$events, ...restProps } = $$props;
+ const isMounted = new IsMounted();
+ const scrollbarYState = useScrollAreaScrollbarY({ mounted: box.with(() => isMounted.current) });
+ const mergedProps = mergeProps(restProps, scrollbarYState.props);
+ Scroll_area_scrollbar_shared($$payload, spread_props([mergedProps]));
+ pop();
+}
+function Scroll_area_scrollbar_visible($$payload, $$props) {
+ push();
+ let { $$slots, $$events, ...restProps } = $$props;
+ const scrollbarVisibleState = useScrollAreaScrollbarVisible();
+ if (scrollbarVisibleState.scrollbar.opts.orientation.current === "horizontal") {
+ $$payload.out += "";
+ Scroll_area_scrollbar_x($$payload, spread_props([restProps]));
+ } else {
+ $$payload.out += "";
+ Scroll_area_scrollbar_y($$payload, spread_props([restProps]));
+ }
+ $$payload.out += ``;
+ pop();
+}
+function Scroll_area_scrollbar_auto($$payload, $$props) {
+ push();
+ let {
+ forceMount = false,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const scrollbarAutoState = useScrollAreaScrollbarAuto();
+ const mergedProps = mergeProps(restProps, scrollbarAutoState.props);
+ {
+ let presence = function($$payload2) {
+ Scroll_area_scrollbar_visible($$payload2, spread_props([mergedProps]));
+ };
+ Presence_layer($$payload, spread_props([
+ {
+ present: forceMount || scrollbarAutoState.isVisible
+ },
+ mergedProps,
+ { presence, $$slots: { presence: true } }
+ ]));
+ }
+ pop();
+}
+function Scroll_area_scrollbar_scroll($$payload, $$props) {
+ push();
+ let {
+ forceMount = false,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const scrollbarScrollState = useScrollAreaScrollbarScroll();
+ const mergedProps = mergeProps(restProps, scrollbarScrollState.props);
+ {
+ let presence = function($$payload2) {
+ Scroll_area_scrollbar_visible($$payload2, spread_props([mergedProps]));
+ };
+ Presence_layer($$payload, spread_props([
+ mergedProps,
+ {
+ present: forceMount || !scrollbarScrollState.isHidden,
+ presence,
+ $$slots: { presence: true }
+ }
+ ]));
+ }
+ pop();
+}
+function Scroll_area_scrollbar_hover($$payload, $$props) {
+ push();
+ let {
+ forceMount = false,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const scrollbarHoverState = useScrollAreaScrollbarHover();
+ const scrollbarAutoState = useScrollAreaScrollbarAuto();
+ const mergedProps = mergeProps(restProps, scrollbarHoverState.props, scrollbarAutoState.props, {
+ "data-state": scrollbarHoverState.isVisible ? "visible" : "hidden"
+ });
+ const present = forceMount || scrollbarHoverState.isVisible && scrollbarAutoState.isVisible;
+ {
+ let presence = function($$payload2) {
+ Scroll_area_scrollbar_visible($$payload2, spread_props([mergedProps]));
+ };
+ Presence_layer($$payload, spread_props([
+ mergedProps,
+ {
+ present,
+ presence,
+ $$slots: { presence: true }
+ }
+ ]));
+ }
+ pop();
+}
+function Scroll_area_scrollbar$1($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ id = useId$1(),
+ orientation,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const scrollbarState = useScrollAreaScrollbar({
+ orientation: box.with(() => orientation),
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v)
+ });
+ const type = scrollbarState.root.opts.type.current;
+ if (type === "hover") {
+ $$payload.out += "";
+ Scroll_area_scrollbar_hover($$payload, spread_props([restProps, { id }]));
+ } else if (type === "scroll") {
+ $$payload.out += "";
+ Scroll_area_scrollbar_scroll($$payload, spread_props([restProps, { id }]));
+ } else if (type === "auto") {
+ $$payload.out += "";
+ Scroll_area_scrollbar_auto($$payload, spread_props([restProps, { id }]));
+ } else if (type === "always") {
+ $$payload.out += "";
+ Scroll_area_scrollbar_visible($$payload, spread_props([restProps, { id }]));
+ } else {
+ $$payload.out += "";
+ }
+ $$payload.out += ``;
+ bind_props($$props, { ref });
+ pop();
+}
+function Scroll_area_thumb_impl($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ id,
+ child,
+ children,
+ present,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const isMounted = new IsMounted();
+ const thumbState = useScrollAreaThumb({
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v),
+ mounted: box.with(() => isMounted.current)
+ });
+ const mergedProps = mergeProps(restProps, thumbState.props, { style: { hidden: !present } });
+ if (child) {
+ $$payload.out += "";
+ child($$payload, { props: mergedProps });
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ $$payload.out += ``;
+ children?.($$payload);
+ $$payload.out += `
`;
+ }
+ $$payload.out += ``;
+ bind_props($$props, { ref });
+ pop();
+}
+function Scroll_area_thumb($$payload, $$props) {
+ push();
+ let {
+ id = useId$1(),
+ ref = null,
+ forceMount = false,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const scrollbarState = ScrollAreaScrollbarVisibleContext.get();
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ {
+ let presence = function($$payload3, { present }) {
+ Scroll_area_thumb_impl($$payload3, spread_props([
+ restProps,
+ {
+ id,
+ present: present.current,
+ get ref() {
+ return ref;
+ },
+ set ref($$value) {
+ ref = $$value;
+ $$settled = false;
+ }
+ }
+ ]));
+ };
+ Presence_layer($$payload2, spread_props([
+ { present: forceMount || scrollbarState.hasThumb },
+ restProps,
+ { id, presence, $$slots: { presence: true } }
+ ]));
+ }
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ bind_props($$props, { ref });
+ pop();
+}
+function Scroll_area_corner_impl($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ id,
+ children,
+ child,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const cornerState = useScrollAreaCorner({
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v)
+ });
+ const mergedProps = mergeProps(restProps, cornerState.props);
+ if (child) {
+ $$payload.out += "";
+ child($$payload, { props: mergedProps });
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ $$payload.out += ``;
+ children?.($$payload);
+ $$payload.out += `
`;
+ }
+ $$payload.out += ``;
+ bind_props($$props, { ref });
+ pop();
+}
+function Scroll_area_corner($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ id = useId$1(),
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const scrollAreaState = ScrollAreaRootContext.get();
+ const hasBothScrollbarsVisible = Boolean(scrollAreaState.scrollbarXNode && scrollAreaState.scrollbarYNode);
+ const hasCorner = scrollAreaState.opts.type.current !== "scroll" && hasBothScrollbarsVisible;
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ if (hasCorner) {
+ $$payload2.out += "";
+ Scroll_area_corner_impl($$payload2, spread_props([
+ restProps,
+ {
+ id,
+ get ref() {
+ return ref;
+ },
+ set ref($$value) {
+ ref = $$value;
+ $$settled = false;
+ }
+ }
+ ]));
+ } else {
+ $$payload2.out += "";
+ }
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ bind_props($$props, { ref });
+ pop();
+}
+function useTimeoutFn(cb, interval, options = {}) {
+ const { immediate = true } = options;
+ const isPending = box(false);
+ let timer;
+ function clear() {
+ if (timer) {
+ clearTimeout(timer);
+ timer = null;
+ }
+ }
+ function stop() {
+ isPending.current = false;
+ clear();
+ }
+ function start(...args) {
+ clear();
+ isPending.current = true;
+ timer = setTimeout(
+ () => {
+ isPending.current = false;
+ timer = null;
+ cb(...args);
+ },
+ interval
+ );
+ }
+ if (immediate) {
+ isPending.current = true;
+ if (isBrowser$1) start();
+ }
+ return {
+ isPending: box.readonly(isPending),
+ start,
+ stop
+ };
+}
+const TOOLTIP_CONTENT_ATTR = "data-tooltip-content";
+const TOOLTIP_TRIGGER_ATTR = "data-tooltip-trigger";
+class TooltipProviderState {
+ opts;
+ isOpenDelayed = true;
+ isPointerInTransit = box(false);
+ #timerFn;
+ #openTooltip = null;
+ constructor(opts) {
+ this.opts = opts;
+ this.#timerFn = useTimeoutFn(
+ () => {
+ this.isOpenDelayed = true;
+ },
+ this.opts.skipDelayDuration.current,
+ { immediate: false }
+ );
+ }
+ #startTimer = () => {
+ const skipDuration = this.opts.skipDelayDuration.current;
+ if (skipDuration === 0) {
+ return;
+ } else {
+ this.#timerFn.start();
+ }
+ };
+ #clearTimer = () => {
+ this.#timerFn.stop();
+ };
+ onOpen = (tooltip) => {
+ if (this.#openTooltip && this.#openTooltip !== tooltip) {
+ this.#openTooltip.handleClose();
+ }
+ this.#clearTimer();
+ this.isOpenDelayed = false;
+ this.#openTooltip = tooltip;
+ };
+ onClose = (tooltip) => {
+ if (this.#openTooltip === tooltip) {
+ this.#openTooltip = null;
+ }
+ this.#startTimer();
+ };
+ isTooltipOpen = (tooltip) => {
+ return this.#openTooltip === tooltip;
+ };
+}
+class TooltipRootState {
+ opts;
+ provider;
+ #delayDuration = derived(() => this.opts.delayDuration.current ?? this.provider.opts.delayDuration.current);
+ get delayDuration() {
+ return this.#delayDuration();
+ }
+ set delayDuration($$value) {
+ return this.#delayDuration($$value);
+ }
+ #disableHoverableContent = derived(() => this.opts.disableHoverableContent.current ?? this.provider.opts.disableHoverableContent.current);
+ get disableHoverableContent() {
+ return this.#disableHoverableContent();
+ }
+ set disableHoverableContent($$value) {
+ return this.#disableHoverableContent($$value);
+ }
+ #disableCloseOnTriggerClick = derived(() => this.opts.disableCloseOnTriggerClick.current ?? this.provider.opts.disableCloseOnTriggerClick.current);
+ get disableCloseOnTriggerClick() {
+ return this.#disableCloseOnTriggerClick();
+ }
+ set disableCloseOnTriggerClick($$value) {
+ return this.#disableCloseOnTriggerClick($$value);
+ }
+ #disabled = derived(() => this.opts.disabled.current ?? this.provider.opts.disabled.current);
+ get disabled() {
+ return this.#disabled();
+ }
+ set disabled($$value) {
+ return this.#disabled($$value);
+ }
+ #ignoreNonKeyboardFocus = derived(() => this.opts.ignoreNonKeyboardFocus.current ?? this.provider.opts.ignoreNonKeyboardFocus.current);
+ get ignoreNonKeyboardFocus() {
+ return this.#ignoreNonKeyboardFocus();
+ }
+ set ignoreNonKeyboardFocus($$value) {
+ return this.#ignoreNonKeyboardFocus($$value);
+ }
+ contentNode = null;
+ triggerNode = null;
+ #wasOpenDelayed = false;
+ #timerFn;
+ #stateAttr = derived(() => {
+ if (!this.opts.open.current) return "closed";
+ return this.#wasOpenDelayed ? "delayed-open" : "instant-open";
+ });
+ get stateAttr() {
+ return this.#stateAttr();
+ }
+ set stateAttr($$value) {
+ return this.#stateAttr($$value);
+ }
+ constructor(opts, provider) {
+ this.opts = opts;
+ this.provider = provider;
+ this.#timerFn = useTimeoutFn(
+ () => {
+ this.#wasOpenDelayed = true;
+ this.opts.open.current = true;
+ },
+ this.delayDuration ?? 0,
+ { immediate: false }
+ );
+ watch(() => this.delayDuration, () => {
+ if (this.delayDuration === void 0) return;
+ this.#timerFn = useTimeoutFn(
+ () => {
+ this.#wasOpenDelayed = true;
+ this.opts.open.current = true;
+ },
+ this.delayDuration,
+ { immediate: false }
+ );
+ });
+ watch(() => this.opts.open.current, (isOpen) => {
+ if (isOpen) {
+ this.provider.onOpen(this);
+ } else {
+ this.provider.onClose(this);
+ }
+ });
+ }
+ handleOpen = () => {
+ this.#timerFn.stop();
+ this.#wasOpenDelayed = false;
+ this.opts.open.current = true;
+ };
+ handleClose = () => {
+ this.#timerFn.stop();
+ this.opts.open.current = false;
+ };
+ #handleDelayedOpen = () => {
+ this.#timerFn.stop();
+ const shouldSkipDelay = !this.provider.isOpenDelayed;
+ const delayDuration = this.delayDuration ?? 0;
+ if (shouldSkipDelay || delayDuration === 0) {
+ this.#wasOpenDelayed = delayDuration > 0 && shouldSkipDelay;
+ this.opts.open.current = true;
+ } else {
+ this.#timerFn.start();
+ }
+ };
+ onTriggerEnter = () => {
+ this.#handleDelayedOpen();
+ };
+ onTriggerLeave = () => {
+ if (this.disableHoverableContent) {
+ this.handleClose();
+ } else {
+ this.#timerFn.stop();
+ }
+ };
+}
+class TooltipTriggerState {
+ opts;
+ root;
+ #isPointerDown = box(false);
+ #hasPointerMoveOpened = false;
+ #isDisabled = derived(() => this.opts.disabled.current || this.root.disabled);
+ constructor(opts, root) {
+ this.opts = opts;
+ this.root = root;
+ useRefById({
+ ...opts,
+ onRefChange: (node) => {
+ this.root.triggerNode = node;
+ }
+ });
+ }
+ handlePointerUp = () => {
+ this.#isPointerDown.current = false;
+ };
+ #onpointerup = () => {
+ if (this.#isDisabled()) return;
+ this.#isPointerDown.current = false;
+ };
+ #onpointerdown = () => {
+ if (this.#isDisabled()) return;
+ this.#isPointerDown.current = true;
+ document.addEventListener(
+ "pointerup",
+ () => {
+ this.handlePointerUp();
+ },
+ { once: true }
+ );
+ };
+ #onpointermove = (e) => {
+ if (this.#isDisabled()) return;
+ if (e.pointerType === "touch") return;
+ if (this.#hasPointerMoveOpened) return;
+ if (this.root.provider.isPointerInTransit.current) return;
+ this.root.onTriggerEnter();
+ this.#hasPointerMoveOpened = true;
+ };
+ #onpointerleave = () => {
+ if (this.#isDisabled()) return;
+ this.root.onTriggerLeave();
+ this.#hasPointerMoveOpened = false;
+ };
+ #onfocus = (e) => {
+ if (this.#isPointerDown.current || this.#isDisabled()) return;
+ if (this.root.ignoreNonKeyboardFocus && !isFocusVisible(e.currentTarget)) return;
+ this.root.handleOpen();
+ };
+ #onblur = () => {
+ if (this.#isDisabled()) return;
+ this.root.handleClose();
+ };
+ #onclick = () => {
+ if (this.root.disableCloseOnTriggerClick || this.#isDisabled()) return;
+ this.root.handleClose();
+ };
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ "aria-describedby": this.root.opts.open.current ? this.root.contentNode?.id : void 0,
+ "data-state": this.root.stateAttr,
+ "data-disabled": getDataDisabled(this.#isDisabled()),
+ "data-delay-duration": `${this.root.delayDuration}`,
+ [TOOLTIP_TRIGGER_ATTR]: "",
+ tabindex: this.#isDisabled() ? void 0 : 0,
+ disabled: this.opts.disabled.current,
+ onpointerup: this.#onpointerup,
+ onpointerdown: this.#onpointerdown,
+ onpointermove: this.#onpointermove,
+ onpointerleave: this.#onpointerleave,
+ onfocus: this.#onfocus,
+ onblur: this.#onblur,
+ onclick: this.#onclick
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class TooltipContentState {
+ opts;
+ root;
+ constructor(opts, root) {
+ this.opts = opts;
+ this.root = root;
+ useRefById({
+ ...opts,
+ onRefChange: (node) => {
+ this.root.contentNode = node;
+ },
+ deps: () => this.root.opts.open.current
+ });
+ useGraceArea({
+ triggerNode: () => this.root.triggerNode,
+ contentNode: () => this.root.contentNode,
+ enabled: () => this.root.opts.open.current && !this.root.disableHoverableContent,
+ onPointerExit: () => {
+ if (this.root.provider.isTooltipOpen(this.root)) {
+ this.root.handleClose();
+ }
+ },
+ setIsPointerInTransit: (value) => {
+ this.root.provider.isPointerInTransit.current = value;
+ },
+ transitTimeout: this.root.provider.opts.skipDelayDuration.current
+ });
+ }
+ onInteractOutside = (e) => {
+ if (isElement(e.target) && this.root.triggerNode?.contains(e.target) && this.root.disableCloseOnTriggerClick) {
+ e.preventDefault();
+ return;
+ }
+ this.opts.onInteractOutside.current(e);
+ if (e.defaultPrevented) return;
+ this.root.handleClose();
+ };
+ onEscapeKeydown = (e) => {
+ this.opts.onEscapeKeydown.current?.(e);
+ if (e.defaultPrevented) return;
+ this.root.handleClose();
+ };
+ onOpenAutoFocus = (e) => {
+ e.preventDefault();
+ };
+ onCloseAutoFocus = (e) => {
+ e.preventDefault();
+ };
+ #snippetProps = derived(() => ({ open: this.root.opts.open.current }));
+ get snippetProps() {
+ return this.#snippetProps();
+ }
+ set snippetProps($$value) {
+ return this.#snippetProps($$value);
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ "data-state": this.root.stateAttr,
+ "data-disabled": getDataDisabled(this.root.disabled),
+ style: { pointerEvents: "auto", outline: "none" },
+ [TOOLTIP_CONTENT_ATTR]: ""
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+ popperProps = {
+ onInteractOutside: this.onInteractOutside,
+ onEscapeKeydown: this.onEscapeKeydown,
+ onOpenAutoFocus: this.onOpenAutoFocus,
+ onCloseAutoFocus: this.onCloseAutoFocus
+ };
+}
+const TooltipProviderContext = new Context("Tooltip.Provider");
+const TooltipRootContext = new Context("Tooltip.Root");
+function useTooltipProvider(props) {
+ return TooltipProviderContext.set(new TooltipProviderState(props));
+}
+function useTooltipRoot(props) {
+ return TooltipRootContext.set(new TooltipRootState(props, TooltipProviderContext.get()));
+}
+function useTooltipTrigger(props) {
+ return new TooltipTriggerState(props, TooltipRootContext.get());
+}
+function useTooltipContent(props) {
+ return new TooltipContentState(props, TooltipRootContext.get());
+}
+function Tooltip($$payload, $$props) {
+ push();
+ let {
+ open = false,
+ onOpenChange = noop$1,
+ disabled,
+ delayDuration,
+ disableCloseOnTriggerClick,
+ disableHoverableContent,
+ ignoreNonKeyboardFocus,
+ children
+ } = $$props;
+ useTooltipRoot({
+ open: box.with(() => open, (v) => {
+ open = v;
+ onOpenChange(v);
+ }),
+ delayDuration: box.with(() => delayDuration),
+ disableCloseOnTriggerClick: box.with(() => disableCloseOnTriggerClick),
+ disableHoverableContent: box.with(() => disableHoverableContent),
+ ignoreNonKeyboardFocus: box.with(() => ignoreNonKeyboardFocus),
+ disabled: box.with(() => disabled)
+ });
+ Floating_layer($$payload, {
+ children: ($$payload2) => {
+ children?.($$payload2);
+ $$payload2.out += ``;
+ }
+ });
+ bind_props($$props, { open });
+ pop();
+}
+function Tooltip_content$1($$payload, $$props) {
+ push();
+ let {
+ children,
+ child,
+ id = useId$1(),
+ ref = null,
+ side = "top",
+ sideOffset = 0,
+ align = "center",
+ avoidCollisions = true,
+ arrowPadding = 0,
+ sticky = "partial",
+ hideWhenDetached = false,
+ collisionPadding = 0,
+ onInteractOutside = noop$1,
+ onEscapeKeydown = noop$1,
+ forceMount = false,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const contentState = useTooltipContent({
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v),
+ onInteractOutside: box.with(() => onInteractOutside),
+ onEscapeKeydown: box.with(() => onEscapeKeydown)
+ });
+ const floatingProps = {
+ side,
+ sideOffset,
+ align,
+ avoidCollisions,
+ arrowPadding,
+ sticky,
+ hideWhenDetached,
+ collisionPadding
+ };
+ const mergedProps = mergeProps(restProps, floatingProps, contentState.props);
+ if (forceMount) {
+ $$payload.out += "";
+ {
+ let popper = function($$payload2, { props, wrapperProps }) {
+ const mergedProps2 = mergeProps(props, {
+ style: getFloatingContentCSSVars("tooltip")
+ });
+ if (child) {
+ $$payload2.out += "";
+ child($$payload2, {
+ props: mergedProps2,
+ wrapperProps,
+ ...contentState.snippetProps
+ });
+ $$payload2.out += ``;
+ } else {
+ $$payload2.out += "";
+ $$payload2.out += ``;
+ children?.($$payload2);
+ $$payload2.out += `
`;
+ }
+ $$payload2.out += ``;
+ };
+ Popper_layer_force_mount($$payload, spread_props([
+ mergedProps,
+ contentState.popperProps,
+ {
+ enabled: contentState.root.opts.open.current,
+ id,
+ trapFocus: false,
+ loop: false,
+ preventScroll: false,
+ forceMount: true,
+ popper,
+ $$slots: { popper: true }
+ }
+ ]));
+ }
+ } else if (!forceMount) {
+ $$payload.out += "";
+ {
+ let popper = function($$payload2, { props, wrapperProps }) {
+ const mergedProps2 = mergeProps(props, {
+ style: getFloatingContentCSSVars("tooltip")
+ });
+ if (child) {
+ $$payload2.out += "";
+ child($$payload2, {
+ props: mergedProps2,
+ wrapperProps,
+ ...contentState.snippetProps
+ });
+ $$payload2.out += ``;
+ } else {
+ $$payload2.out += "";
+ $$payload2.out += ``;
+ children?.($$payload2);
+ $$payload2.out += `
`;
+ }
+ $$payload2.out += ``;
+ };
+ Popper_layer($$payload, spread_props([
+ mergedProps,
+ contentState.popperProps,
+ {
+ present: contentState.root.opts.open.current,
+ id,
+ trapFocus: false,
+ loop: false,
+ preventScroll: false,
+ forceMount: false,
+ popper,
+ $$slots: { popper: true }
+ }
+ ]));
+ }
+ } else {
+ $$payload.out += "";
+ }
+ $$payload.out += ``;
+ bind_props($$props, { ref });
+ pop();
+}
+function Tooltip_trigger($$payload, $$props) {
+ push();
+ let {
+ children,
+ child,
+ id = useId$1(),
+ disabled = false,
+ type = "button",
+ ref = null,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const triggerState = useTooltipTrigger({
+ id: box.with(() => id),
+ disabled: box.with(() => disabled ?? false),
+ ref: box.with(() => ref, (v) => ref = v)
+ });
+ const mergedProps = mergeProps(restProps, triggerState.props, { type });
+ Floating_layer_anchor($$payload, {
+ id,
+ children: ($$payload2) => {
+ if (child) {
+ $$payload2.out += "";
+ child($$payload2, { props: mergedProps });
+ $$payload2.out += ``;
+ } else {
+ $$payload2.out += "";
+ $$payload2.out += ``;
+ children?.($$payload2);
+ $$payload2.out += ` `;
+ }
+ $$payload2.out += ``;
+ }
+ });
+ bind_props($$props, { ref });
+ pop();
+}
+function Tooltip_provider($$payload, $$props) {
+ push();
+ let {
+ children,
+ delayDuration = 700,
+ disableCloseOnTriggerClick = false,
+ disableHoverableContent = false,
+ disabled = false,
+ ignoreNonKeyboardFocus = false,
+ skipDelayDuration = 300
+ } = $$props;
+ useTooltipProvider({
+ delayDuration: box.with(() => delayDuration),
+ disableCloseOnTriggerClick: box.with(() => disableCloseOnTriggerClick),
+ disableHoverableContent: box.with(() => disableHoverableContent),
+ disabled: box.with(() => disabled),
+ ignoreNonKeyboardFocus: box.with(() => ignoreNonKeyboardFocus),
+ skipDelayDuration: box.with(() => skipDelayDuration)
+ });
+ children?.($$payload);
+ $$payload.out += ``;
+ pop();
+}
+function Command($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ value = "",
+ class: className,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ $$payload2.out += ``;
+ Command$1($$payload2, spread_props([
+ {
+ class: cn("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md", className)
+ },
+ restProps,
+ {
+ get value() {
+ return value;
+ },
+ set value($$value) {
+ value = $$value;
+ $$settled = false;
+ },
+ get ref() {
+ return ref;
+ },
+ set ref($$value) {
+ ref = $$value;
+ $$settled = false;
+ }
+ }
+ ]));
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ bind_props($$props, { ref, value });
+ pop();
+}
+function Arrow_left($$payload, $$props) {
+ const $$sanitized_props = sanitize_props($$props);
+ const iconNode = [
+ ["path", { "d": "m12 19-7-7 7-7" }],
+ ["path", { "d": "M19 12H5" }]
+ ];
+ Icon($$payload, spread_props([
+ { name: "arrow-left" },
+ $$sanitized_props,
+ {
+ iconNode,
+ children: ($$payload2) => {
+ $$payload2.out += ``;
+ slot($$payload2, $$props, "default", {});
+ $$payload2.out += ``;
+ },
+ $$slots: { default: true }
+ }
+ ]));
+}
+function Arrow_right($$payload, $$props) {
+ const $$sanitized_props = sanitize_props($$props);
+ const iconNode = [
+ ["path", { "d": "M5 12h14" }],
+ ["path", { "d": "m12 5 7 7-7 7" }]
+ ];
+ Icon($$payload, spread_props([
+ { name: "arrow-right" },
+ $$sanitized_props,
+ {
+ iconNode,
+ children: ($$payload2) => {
+ $$payload2.out += ``;
+ slot($$payload2, $$props, "default", {});
+ $$payload2.out += ``;
+ },
+ $$slots: { default: true }
+ }
+ ]));
+}
+function Check($$payload, $$props) {
+ const $$sanitized_props = sanitize_props($$props);
+ const iconNode = [["path", { "d": "M20 6 9 17l-5-5" }]];
+ Icon($$payload, spread_props([
+ { name: "check" },
+ $$sanitized_props,
+ {
+ iconNode,
+ children: ($$payload2) => {
+ $$payload2.out += ``;
+ slot($$payload2, $$props, "default", {});
+ $$payload2.out += ``;
+ },
+ $$slots: { default: true }
+ }
+ ]));
+}
+function Keyboard($$payload, $$props) {
+ const $$sanitized_props = sanitize_props($$props);
+ const iconNode = [
+ ["path", { "d": "M10 8h.01" }],
+ ["path", { "d": "M12 12h.01" }],
+ ["path", { "d": "M14 8h.01" }],
+ ["path", { "d": "M16 12h.01" }],
+ ["path", { "d": "M18 8h.01" }],
+ ["path", { "d": "M6 8h.01" }],
+ ["path", { "d": "M7 16h10" }],
+ ["path", { "d": "M8 12h.01" }],
+ [
+ "rect",
+ {
+ "width": "20",
+ "height": "16",
+ "x": "2",
+ "y": "4",
+ "rx": "2"
+ }
+ ]
+ ];
+ Icon($$payload, spread_props([
+ { name: "keyboard" },
+ $$sanitized_props,
+ {
+ iconNode,
+ children: ($$payload2) => {
+ $$payload2.out += ``;
+ slot($$payload2, $$props, "default", {});
+ $$payload2.out += ``;
+ },
+ $$slots: { default: true }
+ }
+ ]));
+}
+function Moon($$payload, $$props) {
+ const $$sanitized_props = sanitize_props($$props);
+ const iconNode = [
+ [
+ "path",
+ { "d": "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z" }
+ ]
+ ];
+ Icon($$payload, spread_props([
+ { name: "moon" },
+ $$sanitized_props,
+ {
+ iconNode,
+ children: ($$payload2) => {
+ $$payload2.out += ``;
+ slot($$payload2, $$props, "default", {});
+ $$payload2.out += ``;
+ },
+ $$slots: { default: true }
+ }
+ ]));
+}
+function Palette($$payload, $$props) {
+ const $$sanitized_props = sanitize_props($$props);
+ const iconNode = [
+ [
+ "path",
+ {
+ "d": "M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z"
+ }
+ ],
+ [
+ "circle",
+ {
+ "cx": "13.5",
+ "cy": "6.5",
+ "r": ".5",
+ "fill": "currentColor"
+ }
+ ],
+ [
+ "circle",
+ {
+ "cx": "17.5",
+ "cy": "10.5",
+ "r": ".5",
+ "fill": "currentColor"
+ }
+ ],
+ [
+ "circle",
+ {
+ "cx": "6.5",
+ "cy": "12.5",
+ "r": ".5",
+ "fill": "currentColor"
+ }
+ ],
+ [
+ "circle",
+ {
+ "cx": "8.5",
+ "cy": "7.5",
+ "r": ".5",
+ "fill": "currentColor"
+ }
+ ]
+ ];
+ Icon($$payload, spread_props([
+ { name: "palette" },
+ $$sanitized_props,
+ {
+ iconNode,
+ children: ($$payload2) => {
+ $$payload2.out += ``;
+ slot($$payload2, $$props, "default", {});
+ $$payload2.out += ``;
+ },
+ $$slots: { default: true }
+ }
+ ]));
+}
+function Search($$payload, $$props) {
+ const $$sanitized_props = sanitize_props($$props);
+ const iconNode = [
+ ["path", { "d": "m21 21-4.34-4.34" }],
+ [
+ "circle",
+ { "cx": "11", "cy": "11", "r": "8" }
+ ]
+ ];
+ Icon($$payload, spread_props([
+ { name: "search" },
+ $$sanitized_props,
+ {
+ iconNode,
+ children: ($$payload2) => {
+ $$payload2.out += ``;
+ slot($$payload2, $$props, "default", {});
+ $$payload2.out += ``;
+ },
+ $$slots: { default: true }
+ }
+ ]));
+}
+function Shuffle($$payload, $$props) {
+ const $$sanitized_props = sanitize_props($$props);
+ const iconNode = [
+ ["path", { "d": "m18 14 4 4-4 4" }],
+ ["path", { "d": "m18 2 4 4-4 4" }],
+ [
+ "path",
+ {
+ "d": "M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22"
+ }
+ ],
+ [
+ "path",
+ { "d": "M2 6h1.972a4 4 0 0 1 3.6 2.2" }
+ ],
+ [
+ "path",
+ {
+ "d": "M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45"
+ }
+ ]
+ ];
+ Icon($$payload, spread_props([
+ { name: "shuffle" },
+ $$sanitized_props,
+ {
+ iconNode,
+ children: ($$payload2) => {
+ $$payload2.out += ``;
+ slot($$payload2, $$props, "default", {});
+ $$payload2.out += ``;
+ },
+ $$slots: { default: true }
+ }
+ ]));
+}
+function Sun($$payload, $$props) {
+ const $$sanitized_props = sanitize_props($$props);
+ const iconNode = [
+ [
+ "circle",
+ { "cx": "12", "cy": "12", "r": "4" }
+ ],
+ ["path", { "d": "M12 2v2" }],
+ ["path", { "d": "M12 20v2" }],
+ ["path", { "d": "m4.93 4.93 1.41 1.41" }],
+ ["path", { "d": "m17.66 17.66 1.41 1.41" }],
+ ["path", { "d": "M2 12h2" }],
+ ["path", { "d": "M20 12h2" }],
+ ["path", { "d": "m6.34 17.66-1.41 1.41" }],
+ ["path", { "d": "m19.07 4.93-1.41 1.41" }]
+ ];
+ Icon($$payload, spread_props([
+ { name: "sun" },
+ $$sanitized_props,
+ {
+ iconNode,
+ children: ($$payload2) => {
+ $$payload2.out += ``;
+ slot($$payload2, $$props, "default", {});
+ $$payload2.out += ``;
+ },
+ $$slots: { default: true }
+ }
+ ]));
+}
+function Command_empty($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ class: className,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ $$payload.out += ``;
+ Command_empty$1($$payload, spread_props([
+ {
+ class: cn("py-6 text-center text-sm", className)
+ },
+ restProps
+ ]));
+ $$payload.out += ``;
+ bind_props($$props, { ref });
+ pop();
+}
+function Command_group($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ class: className,
+ children,
+ heading,
+ value,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ $$payload2.out += ``;
+ Command_group$1($$payload2, spread_props([
+ {
+ class: cn("text-foreground overflow-hidden p-1", className),
+ value: value ?? heading ?? `----${useId$1()}`
+ },
+ restProps,
+ {
+ get ref() {
+ return ref;
+ },
+ set ref($$value) {
+ ref = $$value;
+ $$settled = false;
+ },
+ children: ($$payload3) => {
+ if (heading) {
+ $$payload3.out += "";
+ $$payload3.out += ``;
+ Command_group_heading($$payload3, {
+ class: "text-muted-foreground px-2 py-1.5 text-xs font-medium",
+ children: ($$payload4) => {
+ $$payload4.out += `${escape_html(heading)}`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload3.out += ``;
+ } else {
+ $$payload3.out += "";
+ }
+ $$payload3.out += ` `;
+ Command_group_items($$payload3, { children });
+ $$payload3.out += ``;
+ },
+ $$slots: { default: true }
+ }
+ ]));
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ bind_props($$props, { ref });
+ pop();
+}
+function Command_item($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ class: className,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ $$payload2.out += ``;
+ Command_item$1($$payload2, spread_props([
+ {
+ class: cn("aria-selected:bg-accent aria-selected:text-accent-foreground relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", className)
+ },
+ restProps,
+ {
+ get ref() {
+ return ref;
+ },
+ set ref($$value) {
+ ref = $$value;
+ $$settled = false;
+ }
+ }
+ ]));
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ bind_props($$props, { ref });
+ pop();
+}
+function Popover_content($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ class: className,
+ sideOffset = 4,
+ align = "center",
+ portalProps,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ $$payload2.out += ``;
+ Portal($$payload2, spread_props([
+ portalProps,
+ {
+ children: ($$payload3) => {
+ $$payload3.out += ``;
+ Popover_content$1($$payload3, spread_props([
+ {
+ sideOffset,
+ align,
+ class: cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 rounded-md border p-4 shadow-md outline-none", className)
+ },
+ restProps,
+ {
+ get ref() {
+ return ref;
+ },
+ set ref($$value) {
+ ref = $$value;
+ $$settled = false;
+ }
+ }
+ ]));
+ $$payload3.out += ``;
+ },
+ $$slots: { default: true }
+ }
+ ]));
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ bind_props($$props, { ref });
+ pop();
+}
+const Root$2 = Popover;
+const Trigger$2 = Popover_trigger;
+function Separator($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ class: className,
+ orientation = "horizontal",
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ $$payload2.out += ``;
+ Separator$1($$payload2, spread_props([
+ {
+ class: cn("bg-border shrink-0", orientation === "horizontal" ? "h-[1px] w-full" : "min-h-full w-[1px]", className),
+ orientation
+ },
+ restProps,
+ {
+ get ref() {
+ return ref;
+ },
+ set ref($$value) {
+ ref = $$value;
+ $$settled = false;
+ }
+ }
+ ]));
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ bind_props($$props, { ref });
+ pop();
+}
+function Tooltip_content($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ class: className,
+ sideOffset = 4,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ $$payload2.out += ``;
+ Tooltip_content$1($$payload2, spread_props([
+ {
+ sideOffset,
+ class: cn("bg-popover text-popover-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 overflow-hidden rounded-md border px-3 py-1.5 text-sm shadow-md", className)
+ },
+ restProps,
+ {
+ get ref() {
+ return ref;
+ },
+ set ref($$value) {
+ ref = $$value;
+ $$settled = false;
+ }
+ }
+ ]));
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ bind_props($$props, { ref });
+ pop();
+}
+const Root$1 = Tooltip;
+const Trigger$1 = Tooltip_trigger;
+const Provider = Tooltip_provider;
+function ThemeSearch($$payload, $$props) {
+ push();
+ var $$store_subs;
+ let search = fallback($$props["search"], "");
+ let filteredThemes = fallback($$props["filteredThemes"], () => [], true);
+ let onSearchInput = $$props["onSearchInput"];
+ let onDarkModeToggle = $$props["onDarkModeToggle"];
+ let onRandomizeTheme = $$props["onRandomizeTheme"];
+ $$payload.out += ` ${escape_html(filteredThemes.length)} theme${escape_html(filteredThemes.length !== 1 ? "s" : "")}
`;
+ Root$1($$payload, {
+ children: ($$payload2) => {
+ Trigger$1($$payload2, {
+ children: ($$payload3) => {
+ $$payload3.out += `
`;
+ if (store_get($$store_subs ??= {}, "$isDarkMode", isDarkMode)) {
+ $$payload3.out += "";
+ Moon($$payload3, { class: "h-3.5 w-3.5" });
+ } else {
+ $$payload3.out += "";
+ Sun($$payload3, { class: "h-3.5 w-3.5" });
+ }
+ $$payload3.out += ` `;
+ },
+ $$slots: { default: true }
+ });
+ $$payload2.out += ` `;
+ Tooltip_content($$payload2, {
+ side: "bottom",
+ children: ($$payload3) => {
+ $$payload3.out += `
Toggle dark mode
`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload2.out += ``;
+ },
+ $$slots: { default: true }
+ });
+ $$payload.out += ` `;
+ Root$1($$payload, {
+ children: ($$payload2) => {
+ Trigger$1($$payload2, {
+ children: ($$payload3) => {
+ $$payload3.out += `
`;
+ Shuffle($$payload3, { class: "h-3.5 w-3.5" });
+ $$payload3.out += ` `;
+ },
+ $$slots: { default: true }
+ });
+ $$payload2.out += ` `;
+ Tooltip_content($$payload2, {
+ side: "bottom",
+ children: ($$payload3) => {
+ $$payload3.out += `
Random theme
`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload2.out += ``;
+ },
+ $$slots: { default: true }
+ });
+ $$payload.out += `
`;
+ Separator($$payload, {});
+ $$payload.out += ``;
+ if ($$store_subs) unsubscribe_stores($$store_subs);
+ bind_props($$props, {
+ search,
+ filteredThemes,
+ onSearchInput,
+ onDarkModeToggle,
+ onRandomizeTheme
+ });
+ pop();
+}
+function Scroll_area_scrollbar($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ class: className,
+ orientation = "vertical",
+ children,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ $$payload2.out += ``;
+ Scroll_area_scrollbar$1($$payload2, spread_props([
+ {
+ orientation,
+ class: cn("flex touch-none select-none transition-colors", orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-px", orientation === "horizontal" && "h-2.5 w-full border-t border-t-transparent p-px", className)
+ },
+ restProps,
+ {
+ get ref() {
+ return ref;
+ },
+ set ref($$value) {
+ ref = $$value;
+ $$settled = false;
+ },
+ children: ($$payload3) => {
+ children?.($$payload3);
+ $$payload3.out += ` `;
+ Scroll_area_thumb($$payload3, {
+ class: cn("bg-border relative rounded-full", orientation === "vertical" && "flex-1")
+ });
+ $$payload3.out += ``;
+ },
+ $$slots: { default: true }
+ }
+ ]));
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ bind_props($$props, { ref });
+ pop();
+}
+function Scroll_area($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ class: className,
+ orientation = "vertical",
+ scrollbarXClasses = "",
+ scrollbarYClasses = "",
+ children,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ $$payload2.out += ``;
+ Scroll_area$1($$payload2, spread_props([
+ restProps,
+ {
+ class: cn("relative overflow-hidden", className),
+ get ref() {
+ return ref;
+ },
+ set ref($$value) {
+ ref = $$value;
+ $$settled = false;
+ },
+ children: ($$payload3) => {
+ $$payload3.out += ``;
+ Scroll_area_viewport($$payload3, {
+ class: "h-full w-full rounded-[inherit]",
+ children: ($$payload4) => {
+ children?.($$payload4);
+ $$payload4.out += ``;
+ },
+ $$slots: { default: true }
+ });
+ $$payload3.out += ` `;
+ if (orientation === "vertical" || orientation === "both") {
+ $$payload3.out += "";
+ Scroll_area_scrollbar($$payload3, {
+ orientation: "vertical",
+ class: scrollbarYClasses
+ });
+ } else {
+ $$payload3.out += "";
+ }
+ $$payload3.out += ` `;
+ if (orientation === "horizontal" || orientation === "both") {
+ $$payload3.out += "";
+ Scroll_area_scrollbar($$payload3, {
+ orientation: "horizontal",
+ class: scrollbarXClasses
+ });
+ } else {
+ $$payload3.out += "";
+ }
+ $$payload3.out += ` `;
+ Scroll_area_corner($$payload3, {});
+ $$payload3.out += ``;
+ },
+ $$slots: { default: true }
+ }
+ ]));
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ bind_props($$props, { ref });
+ pop();
+}
+function ThemeGrid($$payload, $$props) {
+ push();
+ var $$store_subs;
+ let systemThemes = fallback($$props["systemThemes"], () => [], true);
+ let builtInThemes = fallback($$props["builtInThemes"], () => [], true);
+ let onThemeSelect = $$props["onThemeSelect"];
+ function getThemeColors(themeInfo) {
+ if (store_get($$store_subs ??= {}, "$isDarkMode", isDarkMode) && themeInfo.colorsDark) {
+ return themeInfo.colorsDark;
+ }
+ return themeInfo.colors;
+ }
+ function handleThemeSelect(themeValue) {
+ onThemeSelect(themeValue);
+ }
+ Scroll_area($$payload, {
+ class: "h-[400px] max-h-[70vh]",
+ children: ($$payload2) => {
+ Command_empty($$payload2, {
+ children: ($$payload3) => {
+ $$payload3.out += `No themes found.`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload2.out += ` `;
+ if (systemThemes.length > 0) {
+ $$payload2.out += "";
+ Command_group($$payload2, {
+ heading: "System",
+ children: ($$payload3) => {
+ const each_array = ensure_array_like(systemThemes);
+ $$payload3.out += ``;
+ for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
+ let themeOption = each_array[$$index];
+ if (themeOption) {
+ $$payload3.out += "";
+ const colors = getThemeColors(themeOption);
+ Command_item($$payload3, {
+ value: themeOption.value,
+ onSelect: () => handleThemeSelect(themeOption.value),
+ class: "data-[highlighted]:bg-secondary/50 flex items-center gap-2 py-2",
+ children: ($$payload4) => {
+ $$payload4.out += ` ${escape_html(themeOption.name)}
`;
+ if (store_get($$store_subs ??= {}, "$theme", theme) === themeOption.value) {
+ $$payload4.out += "";
+ Check($$payload4, { class: "h-4 w-4 shrink-0 opacity-70" });
+ } else {
+ $$payload4.out += "";
+ }
+ $$payload4.out += ``;
+ },
+ $$slots: { default: true }
+ });
+ } else {
+ $$payload3.out += "";
+ }
+ $$payload3.out += ``;
+ }
+ $$payload3.out += ``;
+ },
+ $$slots: { default: true }
+ });
+ $$payload2.out += ` `;
+ if (builtInThemes.length > 0) {
+ $$payload2.out += "";
+ Separator($$payload2, { class: "my-2" });
+ } else {
+ $$payload2.out += "";
+ }
+ $$payload2.out += ``;
+ } else {
+ $$payload2.out += "";
+ }
+ $$payload2.out += ` `;
+ if (builtInThemes.length > 0) {
+ $$payload2.out += "";
+ Command_group($$payload2, {
+ heading: "Built-in Themes",
+ children: ($$payload3) => {
+ const each_array_1 = ensure_array_like(builtInThemes);
+ $$payload3.out += ``;
+ for (let $$index_1 = 0, $$length = each_array_1.length; $$index_1 < $$length; $$index_1++) {
+ let themeOption = each_array_1[$$index_1];
+ if (themeOption) {
+ $$payload3.out += "";
+ const colors = getThemeColors(themeOption);
+ Command_item($$payload3, {
+ value: themeOption.value,
+ onSelect: () => handleThemeSelect(themeOption.value),
+ class: "data-[highlighted]:bg-secondary/50 flex items-center gap-2 py-2",
+ children: ($$payload4) => {
+ $$payload4.out += ` ${escape_html(themeOption.name)}
`;
+ if (store_get($$store_subs ??= {}, "$theme", theme) === themeOption.value) {
+ $$payload4.out += "";
+ Check($$payload4, { class: "h-4 w-4 shrink-0 opacity-70" });
+ } else {
+ $$payload4.out += "";
+ }
+ $$payload4.out += ``;
+ },
+ $$slots: { default: true }
+ });
+ } else {
+ $$payload3.out += "";
+ }
+ $$payload3.out += ``;
+ }
+ $$payload3.out += ``;
+ },
+ $$slots: { default: true }
+ });
+ } else {
+ $$payload2.out += "";
+ }
+ $$payload2.out += ``;
+ },
+ $$slots: { default: true }
+ });
+ if ($$store_subs) unsubscribe_stores($$store_subs);
+ bind_props($$props, { systemThemes, builtInThemes, onThemeSelect });
+ pop();
+}
+function ThemeSwitcher($$payload, $$props) {
+ push();
+ var $$store_subs;
+ let filteredThemes, builtInThemes, systemThemes;
+ let withCycleThemes = fallback($$props["withCycleThemes"], false);
+ let className = fallback($$props["className"], "");
+ let compact = fallback($$props["compact"], false);
+ let open = false;
+ let search = "";
+ function handleThemeSelect(themeValue) {
+ theme.setTheme(themeValue);
+ open = false;
+ search = "";
+ }
+ function handleDarkModeToggle() {
+ isDarkMode.toggle();
+ }
+ function randomizeTheme() {
+ const randomIndex = Math.floor(Math.random() * store_get($$store_subs ??= {}, "$themes", themes).length);
+ theme.setTheme(store_get($$store_subs ??= {}, "$themes", themes)[randomIndex].value);
+ }
+ function handleSearchInput(event) {
+ const target = event.target;
+ search = target.value;
+ }
+ store_get($$store_subs ??= {}, "$themes", themes).find((t) => t.value === store_get($$store_subs ??= {}, "$theme", theme)) || store_get($$store_subs ??= {}, "$themes", themes)[0];
+ filteredThemes = store_get($$store_subs ??= {}, "$themes", themes).filter((theme2) => search.trim() === "" || theme2.name.toLowerCase().includes(search.toLowerCase()));
+ builtInThemes = filteredThemes.filter((t) => t.value !== "system");
+ systemThemes = filteredThemes.filter((t) => t.value === "system");
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ if (compact) {
+ $$payload2.out += "";
+ Root$2($$payload2, {
+ get open() {
+ return open;
+ },
+ set open($$value) {
+ open = $$value;
+ $$settled = false;
+ },
+ children: ($$payload3) => {
+ Trigger$2($$payload3, {
+ children: ($$payload4) => {
+ $$payload4.out += ``;
+ Palette($$payload4, { class: "w-5 h-5" });
+ $$payload4.out += ` Change theme `;
+ },
+ $$slots: { default: true }
+ });
+ $$payload3.out += ` `;
+ Popover_content($$payload3, {
+ class: "w-[300px] p-0 border-0 bg-background shadow-2xl",
+ align: "end",
+ children: ($$payload4) => {
+ Command($$payload4, {
+ class: "h-100 w-full rounded-lg shadow-2xl bg-background",
+ children: ($$payload5) => {
+ ThemeSearch($$payload5, {
+ filteredThemes,
+ onSearchInput: handleSearchInput,
+ onDarkModeToggle: handleDarkModeToggle,
+ onRandomizeTheme: randomizeTheme,
+ get search() {
+ return search;
+ },
+ set search($$value) {
+ search = $$value;
+ $$settled = false;
+ }
+ });
+ $$payload5.out += ` `;
+ ThemeGrid($$payload5, {
+ systemThemes,
+ builtInThemes,
+ onThemeSelect: handleThemeSelect
+ });
+ $$payload5.out += ``;
+ },
+ $$slots: { default: true }
+ });
+ },
+ $$slots: { default: true }
+ });
+ $$payload3.out += ``;
+ },
+ $$slots: { default: true }
+ });
+ } else {
+ $$payload2.out += "";
+ $$payload2.out += ``;
+ if (withCycleThemes) {
+ $$payload2.out += "";
+ Separator($$payload2, { orientation: "vertical", class: "min-h-8" });
+ $$payload2.out += ` `;
+ Root$1($$payload2, {
+ children: ($$payload3) => {
+ Trigger$1($$payload3, {
+ children: ($$payload4) => {
+ $$payload4.out += ``;
+ Arrow_left($$payload4, { class: "h-4 w-4" });
+ $$payload4.out += ` `;
+ },
+ $$slots: { default: true }
+ });
+ $$payload3.out += ` `;
+ Tooltip_content($$payload3, {
+ children: ($$payload4) => {
+ $$payload4.out += `Previous theme`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload3.out += ``;
+ },
+ $$slots: { default: true }
+ });
+ $$payload2.out += ` `;
+ Separator($$payload2, { orientation: "vertical", class: "min-h-8" });
+ $$payload2.out += ``;
+ } else {
+ $$payload2.out += "";
+ }
+ $$payload2.out += ` `;
+ Root$2($$payload2, {
+ get open() {
+ return open;
+ },
+ set open($$value) {
+ open = $$value;
+ $$settled = false;
+ },
+ children: ($$payload3) => {
+ Trigger$2($$payload3, {
+ children: ($$payload4) => {
+ $$payload4.out += ``;
+ Palette($$payload4, { class: "w-5 h-5" });
+ $$payload4.out += ` Change theme `;
+ },
+ $$slots: { default: true }
+ });
+ $$payload3.out += ` `;
+ Popover_content($$payload3, {
+ class: "w-[300px] p-0 border-0 bg-background shadow-2xl",
+ align: "center",
+ children: ($$payload4) => {
+ Command($$payload4, {
+ class: "h-100 w-full rounded-lg shadow-2xl bg-background p-3",
+ children: ($$payload5) => {
+ ThemeSearch($$payload5, {
+ filteredThemes,
+ onSearchInput: handleSearchInput,
+ onDarkModeToggle: handleDarkModeToggle,
+ onRandomizeTheme: randomizeTheme,
+ get search() {
+ return search;
+ },
+ set search($$value) {
+ search = $$value;
+ $$settled = false;
+ }
+ });
+ $$payload5.out += ` `;
+ ThemeGrid($$payload5, {
+ systemThemes,
+ builtInThemes,
+ onThemeSelect: handleThemeSelect
+ });
+ $$payload5.out += ``;
+ },
+ $$slots: { default: true }
+ });
+ },
+ $$slots: { default: true }
+ });
+ $$payload3.out += ``;
+ },
+ $$slots: { default: true }
+ });
+ $$payload2.out += ` `;
+ if (withCycleThemes) {
+ $$payload2.out += "";
+ Separator($$payload2, { orientation: "vertical", class: "min-h-8" });
+ $$payload2.out += ` `;
+ Root$1($$payload2, {
+ children: ($$payload3) => {
+ Trigger$1($$payload3, {
+ children: ($$payload4) => {
+ $$payload4.out += ``;
+ Arrow_right($$payload4, { class: "h-4 w-4" });
+ $$payload4.out += ` `;
+ },
+ $$slots: { default: true }
+ });
+ $$payload3.out += ` `;
+ Tooltip_content($$payload3, {
+ children: ($$payload4) => {
+ $$payload4.out += `Next theme`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload3.out += ``;
+ },
+ $$slots: { default: true }
+ });
+ $$payload2.out += ``;
+ } else {
+ $$payload2.out += "";
+ }
+ $$payload2.out += `
`;
+ }
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ if ($$store_subs) unsubscribe_stores($$store_subs);
+ bind_props($$props, { withCycleThemes, className, compact });
+ pop();
+}
+function Hover_card_content($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ class: className,
+ align = "center",
+ sideOffset = 4,
+ portalProps,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ $$payload2.out += ``;
+ Portal($$payload2, spread_props([
+ portalProps,
+ {
+ children: ($$payload3) => {
+ $$payload3.out += ``;
+ Link_preview_content($$payload3, spread_props([
+ {
+ align,
+ sideOffset,
+ class: cn("bg-popover text-popover-foreground z-50 mt-3 w-64 rounded-md border p-4 shadow-md outline-none", className)
+ },
+ restProps,
+ {
+ get ref() {
+ return ref;
+ },
+ set ref($$value) {
+ ref = $$value;
+ $$settled = false;
+ }
+ }
+ ]));
+ $$payload3.out += ``;
+ },
+ $$slots: { default: true }
+ }
+ ]));
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ bind_props($$props, { ref });
+ pop();
+}
+const Root = Link_preview;
+const Trigger = Link_preview_trigger;
+const badgeVariants = tv({
+ base: "focus:ring-ring inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2",
+ variants: {
+ variant: {
+ default: "bg-primary text-primary-foreground hover:bg-secondary hover:text-secondary-foreground border-transparent",
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80 border-transparent",
+ destructive: "bg-destructive text-destructive-foreground hover:bg-secondary hover:text-secondary-foreground border-transparent",
+ outline: "text-foreground"
+ }
+ },
+ defaultVariants: { variant: "default" }
+});
+function Badge($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ href,
+ class: className,
+ variant = "default",
+ children,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ element(
+ $$payload,
+ href ? "a" : "span",
+ () => {
+ $$payload.out += `${spread_attributes(
+ {
+ href,
+ class: clsx(cn(badgeVariants({ variant }), className)),
+ ...restProps
+ }
+ )}`;
+ },
+ () => {
+ children?.($$payload);
+ $$payload.out += ``;
+ }
+ );
+ bind_props($$props, { ref });
+ pop();
+}
+function Label($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ class: className,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ $$payload2.out += ``;
+ Label$1($$payload2, spread_props([
+ {
+ class: cn("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", className)
+ },
+ restProps,
+ {
+ get ref() {
+ return ref;
+ },
+ set ref($$value) {
+ ref = $$value;
+ $$settled = false;
+ }
+ }
+ ]));
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ bind_props($$props, { ref });
+ pop();
+}
+function Navbar($$payload, $$props) {
+ push();
+ var $$store_subs;
+ let searchValue = "";
+ let hostValue = typeof window !== "undefined" ? localStorage.getItem("host") || "http://127.0.0.1:3000" : "http://127.0.0.1:3000";
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ $$payload2.out += `PassDB Search `;
+ ThemeSwitcher($$payload2, {});
+ $$payload2.out += `
`;
+ if (store_get($$store_subs ??= {}, "$page", page).route.id !== "/") {
+ $$payload2.out += "";
+ $$payload2.out += `
`;
+ Root($$payload2, {
+ children: ($$payload3) => {
+ $$payload3.out += ``;
+ Trigger($$payload3, {
+ children: ($$payload4) => {
+ $$payload4.out += `
`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload3.out += ` `;
+ Hover_card_content($$payload3, {
+ class: "w-80 bg-background border-0 shadow-2xl p-6",
+ children: ($$payload4) => {
+ $$payload4.out += `
Search Operators `;
+ Separator($$payload4, {});
+ $$payload4.out += `
`;
+ Badge($$payload4, {
+ variant: "default",
+ class: "font-mono",
+ children: ($$payload5) => {
+ $$payload5.out += `u:`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload4.out += ` Username search
`;
+ Badge($$payload4, {
+ variant: "default",
+ class: "font-mono",
+ children: ($$payload5) => {
+ $$payload5.out += `p:`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload4.out += ` Password check
`;
+ Badge($$payload4, {
+ variant: "default",
+ class: "font-mono",
+ children: ($$payload5) => {
+ $$payload5.out += `d:`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload4.out += ` Domain search
`;
+ Badge($$payload4, {
+ variant: "default",
+ class: "font-mono",
+ children: ($$payload5) => {
+ $$payload5.out += `e:`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload4.out += ` Email search
`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload3.out += ``;
+ },
+ $$slots: { default: true }
+ });
+ $$payload2.out += `
`;
+ } else {
+ $$payload2.out += "";
+ }
+ $$payload2.out += ` `;
+ Root$2($$payload2, {
+ children: ($$payload3) => {
+ $$payload3.out += ``;
+ Trigger$2($$payload3, {
+ class: "p-2 text-primary-foreground bg-primary hover:bg-secondary hover:text-secondary-foreground rounded-md transition-colors",
+ "aria-label": "Settings",
+ children: ($$payload4) => {
+ $$payload4.out += `
`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload3.out += ` `;
+ Popover_content($$payload3, {
+ class: "w-80 bg-background border-0 shadow-2xl p-6",
+ align: "end",
+ children: ($$payload4) => {
+ $$payload4.out += `
API Settings Configure the API endpoint for PassDB backend.
`;
+ Label($$payload4, {
+ for: "api-host",
+ children: ($$payload5) => {
+ $$payload5.out += `API Host`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload4.out += ` `;
+ Input($$payload4, {
+ id: "api-host",
+ placeholder: "http://127.0.0.1:3000",
+ class: "col-span-2 h-8 focus-visible:ring-0 focus-visible:ring-offset-0",
+ get value() {
+ return hostValue;
+ },
+ set value($$value) {
+ hostValue = $$value;
+ $$settled = false;
+ }
+ });
+ $$payload4.out += `
`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload3.out += ``;
+ },
+ $$slots: { default: true }
+ });
+ $$payload2.out += `
`;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ if ($$store_subs) unsubscribe_stores($$store_subs);
+ pop();
+}
+function ErrorBoundary($$payload, $$props) {
+ push();
+ let {
+ error = null,
+ reset: reset2 = () => window.location.reload(),
+ children
+ } = $$props;
+ if (error) {
+ $$payload.out += "";
+ $$payload.out += ` Oops! Something went wrong We encountered an unexpected error. Please try again.
Reload Page ${escape_html("Show")} Details
`;
+ {
+ $$payload.out += "";
+ }
+ $$payload.out += `
`;
+ } else {
+ $$payload.out += "";
+ children?.($$payload);
+ $$payload.out += ``;
+ }
+ $$payload.out += ``;
+ bind_props($$props, { error });
+ pop();
+}
+function noop() {
+}
+const TRANSITIONS = {
+ DURATION: 0.5,
+ EASE: [0.32, 0.72, 0, 1]
+};
+const VELOCITY_THRESHOLD = 0.4;
+const CLOSE_THRESHOLD = 0.25;
+const SCROLL_LOCK_TIMEOUT = 100;
+const BORDER_RADIUS = 8;
+const NESTED_DISPLACEMENT = 16;
+const WINDOW_TOP_OFFSET = 26;
+const DRAG_CLASS = "vaul-dragging";
+const cache = /* @__PURE__ */ new WeakMap();
+function set(el, styles, ignoreCache = false) {
+ if (!el || !(el instanceof HTMLElement))
+ return;
+ let originalStyles = {};
+ Object.entries(styles).forEach(([key, value]) => {
+ if (key.startsWith("--")) {
+ el.style.setProperty(key, value);
+ return;
+ }
+ originalStyles[key] = el.style[key];
+ el.style[key] = value;
+ });
+ if (ignoreCache)
+ return;
+ cache.set(el, originalStyles);
+}
+function reset(el, prop) {
+ if (!el || !(el instanceof HTMLElement))
+ return;
+ let originalStyles = cache.get(el);
+ if (!originalStyles)
+ return;
+ {
+ el.style[prop] = originalStyles[prop];
+ }
+}
+const isVertical = (direction) => {
+ switch (direction) {
+ case "top":
+ case "bottom":
+ return true;
+ case "left":
+ case "right":
+ return false;
+ default:
+ return direction;
+ }
+};
+function getTranslate(element2, direction) {
+ if (!element2) {
+ return null;
+ }
+ const style = window.getComputedStyle(element2);
+ const transform = (
+ // @ts-expect-error - shh
+ style.transform || style.webkitTransform || style.mozTransform
+ );
+ let mat = transform.match(/^matrix3d\((.+)\)$/);
+ if (mat) {
+ return parseFloat(mat[1].split(", ")[isVertical(direction) ? 13 : 12]);
+ }
+ mat = transform.match(/^matrix\((.+)\)$/);
+ return mat ? parseFloat(mat[1].split(", ")[isVertical(direction) ? 5 : 4]) : null;
+}
+function dampenValue(v) {
+ return 8 * (Math.log(v + 1) - 2);
+}
+function assignStyle(element2, style) {
+ if (!element2)
+ return () => {
+ };
+ const prevStyle = element2.style.cssText;
+ Object.assign(element2.style, style);
+ return () => {
+ element2.style.cssText = prevStyle;
+ };
+}
+function chain$1(...fns) {
+ return (...args) => {
+ for (const fn of fns) {
+ if (typeof fn === "function") {
+ fn(...args);
+ }
+ }
+ };
+}
+function useSnapPoints({
+ snapPoints,
+ drawerNode,
+ overlayNode,
+ fadeFromIndex,
+ setOpenTime,
+ direction,
+ container,
+ snapToSequentialPoint,
+ activeSnapPoint,
+ open,
+ isReleasing
+}) {
+ let windowDimensions = typeof window !== "undefined" ? {} : void 0;
+ const isLastSnapPoint = activeSnapPoint.current === snapPoints.current?.[snapPoints.current.length - 1] || null;
+ const activeSnapPointIndex = snapPoints.current?.findIndex((snapPoint) => snapPoint === activeSnapPoint.current);
+ const shouldFade = snapPoints.current && snapPoints.current.length > 0 && (fadeFromIndex.current || fadeFromIndex.current === 0) && !Number.isNaN(fadeFromIndex.current) && snapPoints.current[fadeFromIndex.current] === activeSnapPoint.current || !snapPoints.current;
+ const snapPointsOffset = (() => {
+ open.current;
+ const containerSize = container.current ? {
+ width: container.current.getBoundingClientRect().width,
+ height: container.current.getBoundingClientRect().height
+ } : typeof window !== "undefined" ? {
+ width: window.innerWidth,
+ height: window.innerHeight
+ } : { width: 0, height: 0 };
+ return snapPoints.current?.map((snapPoint) => {
+ const isPx = typeof snapPoint === "string";
+ let snapPointAsNumber = 0;
+ if (isPx) {
+ snapPointAsNumber = parseInt(snapPoint, 10);
+ }
+ if (isVertical(direction.current)) {
+ const height = isPx ? snapPointAsNumber : windowDimensions ? snapPoint * containerSize.height : 0;
+ if (windowDimensions) {
+ return direction.current === "bottom" ? containerSize.height - height : -containerSize.height + height;
+ }
+ return height;
+ }
+ const width = isPx ? snapPointAsNumber : windowDimensions ? snapPoint * containerSize.width : 0;
+ if (windowDimensions) {
+ return direction.current === "right" ? containerSize.width - width : -containerSize.width + width;
+ }
+ return width;
+ }) ?? [];
+ })();
+ const activeSnapPointOffset = (() => {
+ if (activeSnapPointIndex !== null) {
+ if (activeSnapPointIndex !== void 0) {
+ return snapPointsOffset[activeSnapPointIndex];
+ }
+ }
+ return null;
+ })();
+ function onSnapPointChange(activeSnapPointIndex2) {
+ if (snapPoints.current && activeSnapPointIndex2 === snapPointsOffset.length - 1) {
+ setOpenTime(/* @__PURE__ */ new Date());
+ }
+ }
+ function snapToPoint(dimension) {
+ const newSnapPointIndex = snapPointsOffset?.findIndex((snapPointDim) => snapPointDim === dimension) ?? null;
+ onSnapPointChange(newSnapPointIndex);
+ set(drawerNode(), {
+ transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`,
+ transform: isVertical(direction.current) ? `translate3d(0, ${dimension}px, 0)` : `translate3d(${dimension}px, 0, 0)`
+ });
+ if (snapPointsOffset && newSnapPointIndex !== snapPointsOffset.length - 1 && fadeFromIndex.current !== void 0 && newSnapPointIndex !== fadeFromIndex.current && newSnapPointIndex < fadeFromIndex.current) {
+ set(overlayNode(), {
+ transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`,
+ opacity: "0"
+ });
+ } else {
+ set(overlayNode(), {
+ transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`,
+ opacity: "1"
+ });
+ }
+ activeSnapPoint.current = snapPoints.current?.[Math.max(newSnapPointIndex, 0)];
+ }
+ watch(
+ [
+ () => activeSnapPoint.current,
+ () => open.current
+ ],
+ () => {
+ const releasing = isReleasing();
+ if (!activeSnapPoint.current || releasing) return;
+ const newIndex = snapPoints.current?.findIndex((snapPoint) => snapPoint === activeSnapPoint.current) ?? -1;
+ if (snapPointsOffset && newIndex !== -1 && typeof snapPointsOffset[newIndex] === "number") {
+ if (snapPointsOffset[newIndex] === activeSnapPoint.current) return;
+ snapToPoint(snapPointsOffset[newIndex]);
+ }
+ }
+ );
+ function onRelease({
+ draggedDistance,
+ closeDrawer,
+ velocity,
+ dismissible
+ }) {
+ if (fadeFromIndex.current === void 0) return;
+ const dir = direction.current;
+ const currentPosition = dir === "bottom" || dir === "right" ? (activeSnapPointOffset ?? 0) - draggedDistance : (activeSnapPointOffset ?? 0) + draggedDistance;
+ const isOverlaySnapPoint = activeSnapPointIndex === fadeFromIndex.current - 1;
+ const isFirst = activeSnapPointIndex === 0;
+ const hasDraggedUp = draggedDistance > 0;
+ if (isOverlaySnapPoint) {
+ set(overlayNode(), {
+ transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`
+ });
+ }
+ if (!snapToSequentialPoint.current && velocity > 2 && !hasDraggedUp) {
+ if (dismissible) {
+ closeDrawer();
+ } else {
+ snapToPoint(snapPointsOffset[0]);
+ }
+ return;
+ }
+ if (!snapToSequentialPoint.current && velocity > 2 && hasDraggedUp && snapPointsOffset && snapPoints.current) {
+ snapToPoint(snapPointsOffset[snapPoints.current.length - 1]);
+ return;
+ }
+ const closestSnapPoint = snapPointsOffset?.reduce((prev, curr) => {
+ if (typeof prev !== "number" || typeof curr !== "number") return prev;
+ return Math.abs(curr - currentPosition) < Math.abs(prev - currentPosition) ? curr : prev;
+ });
+ const dim = isVertical(dir) ? window.innerHeight : window.innerWidth;
+ if (velocity > VELOCITY_THRESHOLD && Math.abs(draggedDistance) < dim * 0.4) {
+ const dragDirection = hasDraggedUp ? 1 : -1;
+ if (dragDirection > 0 && isLastSnapPoint && snapPoints.current) {
+ snapToPoint(snapPointsOffset[snapPoints.current.length - 1]);
+ return;
+ }
+ if (isFirst && dragDirection < 0 && dismissible) {
+ closeDrawer();
+ }
+ if (activeSnapPointIndex === null) return;
+ snapToPoint(snapPointsOffset[activeSnapPointIndex + dragDirection]);
+ return;
+ }
+ snapToPoint(closestSnapPoint);
+ }
+ function onDrag({ draggedDistance }) {
+ if (activeSnapPointOffset === null) return;
+ const dir = direction.current;
+ const newValue = isBottomOrRight(dir) ? activeSnapPointOffset - draggedDistance : activeSnapPointOffset + draggedDistance;
+ const lastSnapPoint = snapPointsOffset[snapPointsOffset.length - 1];
+ if (isBottomOrRight(dir) && newValue < lastSnapPoint) return;
+ if (!isBottomOrRight(dir) && newValue > lastSnapPoint) return;
+ set(drawerNode(), {
+ transform: isVertical(dir) ? `translate3d(0, ${newValue}px, 0)` : `translate3d(${newValue}px, 0, 0)`
+ });
+ }
+ function getPercentageDragged(absDraggedDistance, isDraggingDown) {
+ if (!snapPoints.current || typeof activeSnapPointIndex !== "number" || !snapPointsOffset || fadeFromIndex.current === void 0) {
+ return null;
+ }
+ const isOverlaySnapPoint = activeSnapPointIndex === fadeFromIndex.current - 1;
+ const isOverlaySnapPointOrHigher = activeSnapPointIndex >= fadeFromIndex.current;
+ if (isOverlaySnapPointOrHigher && isDraggingDown) {
+ return 0;
+ }
+ if (isOverlaySnapPoint && !isDraggingDown) {
+ return 1;
+ }
+ if (!shouldFade && !isOverlaySnapPoint) {
+ return null;
+ }
+ const targetSnapPointIndex = isOverlaySnapPoint ? activeSnapPointIndex + 1 : activeSnapPointIndex - 1;
+ const snapPointDistance = isOverlaySnapPoint ? snapPointsOffset[targetSnapPointIndex] - snapPointsOffset[targetSnapPointIndex - 1] : snapPointsOffset[targetSnapPointIndex + 1] - snapPointsOffset[targetSnapPointIndex];
+ const percentageDragged = absDraggedDistance / Math.abs(snapPointDistance);
+ if (isOverlaySnapPoint) {
+ return 1 - percentageDragged;
+ } else {
+ return percentageDragged;
+ }
+ }
+ return {
+ get isLastSnapPoint() {
+ return isLastSnapPoint;
+ },
+ get shouldFade() {
+ return shouldFade;
+ },
+ get activeSnapPointIndex() {
+ return activeSnapPointIndex;
+ },
+ get snapPointsOffset() {
+ return snapshot(snapPointsOffset);
+ },
+ getPercentageDragged,
+ onRelease,
+ onDrag
+ };
+}
+function isBottomOrRight(direction) {
+ if (direction === "bottom" || direction === "right") return true;
+ return false;
+}
+const isBrowser = typeof document !== "undefined";
+function isMobileFirefox() {
+ const userAgent = navigator.userAgent;
+ return typeof window !== "undefined" && (/Firefox/.test(userAgent) && /Mobile/.test(userAgent) || // Android Firefox
+ /FxiOS/.test(userAgent));
+}
+function isMac() {
+ return testPlatform(/^Mac/);
+}
+function isIPhone() {
+ return testPlatform(/^iPhone/);
+}
+function isSafari() {
+ return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
+}
+function isIPad() {
+ return testPlatform(/^iPad/) || // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
+ isMac() && navigator.maxTouchPoints > 1;
+}
+function isIOS() {
+ return isIPhone() || isIPad();
+}
+function testPlatform(re) {
+ return typeof window !== "undefined" && window.navigator != null ? re.test(window.navigator.platform) : void 0;
+}
+const KEYBOARD_BUFFER = 24;
+function chain(...callbacks) {
+ return (...args) => {
+ for (let callback of callbacks) {
+ if (typeof callback === "function") {
+ callback(...args);
+ }
+ }
+ };
+}
+const visualViewport = isBrowser && window.visualViewport;
+function isScrollable(node) {
+ let style = window.getComputedStyle(node);
+ return /(auto|scroll)/.test(style.overflow + style.overflowX + style.overflowY);
+}
+function getScrollParent(node) {
+ if (isScrollable(node)) {
+ node = node.parentElement;
+ }
+ while (node && !isScrollable(node)) {
+ node = node.parentElement;
+ }
+ return node || document.scrollingElement || document.documentElement;
+}
+const nonTextInputTypes = /* @__PURE__ */ new Set([
+ "checkbox",
+ "radio",
+ "range",
+ "color",
+ "file",
+ "image",
+ "button",
+ "submit",
+ "reset"
+]);
+let preventScrollCount = 0;
+let restore;
+function usePreventScroll(opts) {
+ watch(opts.isDisabled, () => {
+ if (opts.isDisabled()) {
+ return;
+ }
+ preventScrollCount++;
+ if (preventScrollCount === 1) {
+ if (isIOS()) {
+ restore = preventScrollMobileSafari();
+ }
+ }
+ return () => {
+ preventScrollCount--;
+ if (preventScrollCount === 0) {
+ restore?.();
+ }
+ };
+ });
+}
+function preventScrollMobileSafari() {
+ let scrollable;
+ let lastY = 0;
+ const onTouchStart = (e) => {
+ scrollable = getScrollParent(e.target);
+ if (scrollable === document.documentElement && scrollable === document.body) {
+ return;
+ }
+ lastY = e.changedTouches[0].pageY;
+ };
+ let onTouchMove = (e) => {
+ if (!scrollable || scrollable === document.documentElement || scrollable === document.body) {
+ e.preventDefault();
+ return;
+ }
+ let y = e.changedTouches[0].pageY;
+ let scrollTop = scrollable.scrollTop;
+ let bottom = scrollable.scrollHeight - scrollable.clientHeight;
+ if (bottom === 0) {
+ return;
+ }
+ if (scrollTop <= 0 && y > lastY || scrollTop >= bottom && y < lastY) {
+ e.preventDefault();
+ }
+ lastY = y;
+ };
+ let onTouchEnd = (e) => {
+ let target = e.target;
+ if (isInput(target) && target !== document.activeElement) {
+ e.preventDefault();
+ target.style.transform = "translateY(-2000px)";
+ target.focus();
+ requestAnimationFrame(() => {
+ target.style.transform = "";
+ });
+ }
+ };
+ const onFocus = (e) => {
+ let target = e.target;
+ if (isInput(target)) {
+ target.style.transform = "translateY(-2000px)";
+ requestAnimationFrame(() => {
+ target.style.transform = "";
+ if (visualViewport) {
+ if (visualViewport.height < window.innerHeight) {
+ requestAnimationFrame(() => {
+ scrollIntoView(target);
+ });
+ } else {
+ visualViewport.addEventListener("resize", () => scrollIntoView(target), { once: true });
+ }
+ }
+ });
+ }
+ };
+ let onWindowScroll = () => {
+ window.scrollTo(0, 0);
+ };
+ let scrollX = window.pageXOffset;
+ let scrollY = window.pageYOffset;
+ let restoreStyles = chain(setStyle(document.documentElement, "paddingRight", `${window.innerWidth - document.documentElement.clientWidth}px`));
+ window.scrollTo(0, 0);
+ let removeEvents = chain(on(document, "touchstart", onTouchStart, { passive: false, capture: true }), on(document, "touchmove", onTouchMove, { passive: false, capture: true }), on(document, "touchend", onTouchEnd, { passive: false, capture: true }), on(document, "focus", onFocus, { capture: true }), on(window, "scroll", onWindowScroll));
+ return () => {
+ restoreStyles();
+ removeEvents();
+ window.scrollTo(scrollX, scrollY);
+ };
+}
+function setStyle(element2, style, value) {
+ let cur = element2.style[style];
+ element2.style[style] = value;
+ return () => {
+ element2.style[style] = cur;
+ };
+}
+function scrollIntoView(target) {
+ let root = document.scrollingElement || document.documentElement;
+ while (target && target !== root) {
+ let scrollable = getScrollParent(target);
+ if (scrollable !== document.documentElement && scrollable !== document.body && scrollable !== target) {
+ let scrollableTop = scrollable.getBoundingClientRect().top;
+ let targetTop = target.getBoundingClientRect().top;
+ let targetBottom = target.getBoundingClientRect().bottom;
+ const keyboardHeight = scrollable.getBoundingClientRect().bottom + KEYBOARD_BUFFER;
+ if (targetBottom > keyboardHeight) {
+ scrollable.scrollTop += targetTop - scrollableTop;
+ }
+ }
+ target = scrollable.parentElement;
+ }
+}
+function isInput(target) {
+ return target instanceof HTMLInputElement && !nonTextInputTypes.has(target.type) || target instanceof HTMLTextAreaElement || target instanceof HTMLElement && target.isContentEditable;
+}
+let previousBodyPosition = null;
+function usePositionFixed({
+ open,
+ modal,
+ nested,
+ hasBeenOpened,
+ preventScrollRestoration,
+ noBodyStyles
+}) {
+ let activeUrl = typeof window !== "undefined" ? window.location.href : "";
+ let scrollPos = 0;
+ function setPositionFixed() {
+ if (!isSafari()) return;
+ if (previousBodyPosition === null && open.current && !noBodyStyles.current) {
+ previousBodyPosition = {
+ position: document.body.style.position,
+ top: document.body.style.top,
+ left: document.body.style.left,
+ height: document.body.style.height,
+ right: "unset"
+ };
+ const { scrollX, innerHeight } = window;
+ document.body.style.setProperty("position", "fixed", "important");
+ Object.assign(document.body.style, {
+ top: `${-scrollPos}px`,
+ left: `${-scrollX}px`,
+ right: "0px",
+ height: "auto"
+ });
+ window.setTimeout(
+ () => window.requestAnimationFrame(() => {
+ const bottomBarHeight = innerHeight - window.innerHeight;
+ if (bottomBarHeight && scrollPos >= innerHeight) {
+ document.body.style.top = `${-(scrollPos + bottomBarHeight)}px`;
+ }
+ }),
+ 300
+ );
+ }
+ }
+ function restorePositionSetting() {
+ if (!isSafari()) return;
+ if (previousBodyPosition !== null && !noBodyStyles.current) {
+ const y = -parseInt(document.body.style.top, 10);
+ const x = -parseInt(document.body.style.left, 10);
+ Object.assign(document.body.style, previousBodyPosition);
+ window.requestAnimationFrame(() => {
+ if (preventScrollRestoration.current && activeUrl !== window.location.href) {
+ activeUrl = window.location.href;
+ return;
+ }
+ window.scrollTo(x, y);
+ });
+ previousBodyPosition = null;
+ }
+ }
+ watch([() => modal.current, () => activeUrl], () => {
+ if (!modal.current) return;
+ return () => {
+ if (typeof document === "undefined") return;
+ const hasDrawerOpened = !!document.querySelector("[data-vaul-drawer]");
+ if (hasDrawerOpened) return;
+ restorePositionSetting();
+ };
+ });
+ watch(
+ [
+ () => open.current,
+ () => hasBeenOpened(),
+ () => activeUrl,
+ () => modal.current,
+ () => nested.current
+ ],
+ () => {
+ if (nested.current || !hasBeenOpened()) return;
+ if (open.current) {
+ const isStandalone = window.matchMedia("(display-mode: standalone)").matches;
+ !isStandalone && setPositionFixed();
+ if (!modal.current) {
+ window.setTimeout(
+ () => {
+ restorePositionSetting();
+ },
+ 500
+ );
+ }
+ } else {
+ restorePositionSetting();
+ }
+ }
+ );
+ return { restorePositionSetting };
+}
+const DrawerContext = new Context("Drawer.Root");
+function useDrawerRoot(opts) {
+ let hasBeenOpened = false;
+ let isDragging = false;
+ let justReleased = false;
+ let overlayNode = null;
+ let drawerNode = null;
+ let openTime = null;
+ let dragStartTime = null;
+ let dragEndTime = null;
+ let lastTimeDragPrevented = null;
+ let isAllowedToDrag = false;
+ let nestedOpenChangeTimer = null;
+ let pointerStart = 0;
+ let keyboardIsOpen = box(false);
+ let shouldAnimate = !opts.open.current;
+ let previousDiffFromInitial = 0;
+ let drawerHeight = 0;
+ let drawerWidth = 0;
+ let initialDrawerHeight = 0;
+ let isReleasing = false;
+ const snapPointsState = useSnapPoints({
+ snapPoints: opts.snapPoints,
+ drawerNode: () => drawerNode,
+ activeSnapPoint: opts.activeSnapPoint,
+ container: opts.container,
+ direction: opts.direction,
+ fadeFromIndex: opts.fadeFromIndex,
+ overlayNode: () => overlayNode,
+ setOpenTime: (time) => {
+ openTime = time;
+ },
+ snapToSequentialPoint: opts.snapToSequentialPoint,
+ open: opts.open,
+ isReleasing: () => isReleasing
+ });
+ usePreventScroll({
+ isDisabled: () => !opts.open.current || isDragging || !opts.modal.current || justReleased || !hasBeenOpened || !opts.repositionInputs.current || !opts.disablePreventScroll.current
+ });
+ const { restorePositionSetting } = usePositionFixed({ ...opts, hasBeenOpened: () => hasBeenOpened });
+ function getScale() {
+ return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
+ }
+ function onPress(event) {
+ if (!opts.dismissible.current && !opts.snapPoints.current) return;
+ if (drawerNode && !drawerNode.contains(event.target)) return;
+ drawerHeight = drawerNode?.getBoundingClientRect().height || 0;
+ drawerWidth = drawerNode?.getBoundingClientRect().width || 0;
+ isDragging = true;
+ dragStartTime = /* @__PURE__ */ new Date();
+ if (isIOS()) {
+ on(window, "touchend", () => isAllowedToDrag = false, { once: true });
+ }
+ event.target.setPointerCapture(event.pointerId);
+ pointerStart = isVertical(opts.direction.current) ? event.pageY : event.pageX;
+ }
+ function shouldDrag(el, isDraggingInDirection) {
+ let element2 = el;
+ const highlightedText = window.getSelection()?.toString();
+ const swipeAmount = drawerNode ? getTranslate(drawerNode, opts.direction.current) : null;
+ const date = /* @__PURE__ */ new Date();
+ if (element2.tagName === "SELECT") return false;
+ if (element2.hasAttribute("data-vaul-no-drag") || element2.closest("[data-vaul-no-drag]")) {
+ return false;
+ }
+ if (opts.direction.current === "right" || opts.direction.current === "left") {
+ return true;
+ }
+ if (openTime && date.getTime() - openTime.getTime() < 500) {
+ return false;
+ }
+ if (swipeAmount !== null) {
+ if (opts.direction.current === "bottom" ? swipeAmount > 0 : swipeAmount < 0) {
+ return true;
+ }
+ }
+ if (highlightedText && highlightedText.length > 0) {
+ return false;
+ }
+ if (lastTimeDragPrevented && date.getTime() - lastTimeDragPrevented.getTime() < opts.scrollLockTimeout.current && swipeAmount === 0) {
+ lastTimeDragPrevented = date;
+ return false;
+ }
+ if (isDraggingInDirection) {
+ lastTimeDragPrevented = date;
+ return false;
+ }
+ while (element2) {
+ if (element2.scrollHeight > element2.clientHeight) {
+ if (element2.scrollTop !== 0) {
+ lastTimeDragPrevented = /* @__PURE__ */ new Date();
+ return false;
+ }
+ if (element2.getAttribute("role") === "dialog") {
+ return true;
+ }
+ }
+ element2 = element2.parentNode;
+ }
+ return true;
+ }
+ function onDrag(event) {
+ if (!drawerNode || !isDragging) return;
+ const directionMultiplier = opts.direction.current === "bottom" || opts.direction.current === "right" ? 1 : -1;
+ const draggedDistance = (pointerStart - (isVertical(opts.direction.current) ? event.pageY : event.pageX)) * directionMultiplier;
+ const isDraggingInDirection = draggedDistance > 0;
+ const noCloseSnapPointsPreCondition = opts.snapPoints.current && !opts.dismissible.current && !isDraggingInDirection;
+ if (noCloseSnapPointsPreCondition && snapPointsState.activeSnapPointIndex === 0) return;
+ const absDraggedDistance = Math.abs(draggedDistance);
+ const wrapper = document.querySelector("[data-vaul-drawer-wrapper]");
+ const drawerDimension = opts.direction.current === "bottom" || opts.direction.current === "top" ? drawerHeight : drawerWidth;
+ let percentageDragged = absDraggedDistance / drawerDimension;
+ const snapPointPercentageDragged = snapPointsState.getPercentageDragged(absDraggedDistance, isDraggingInDirection);
+ if (snapPointPercentageDragged !== null) {
+ percentageDragged = snapPointPercentageDragged;
+ }
+ if (noCloseSnapPointsPreCondition && percentageDragged >= 1) {
+ return;
+ }
+ if (!isAllowedToDrag && !shouldDrag(event.target, isDraggingInDirection)) return;
+ drawerNode.classList.add(DRAG_CLASS);
+ isAllowedToDrag = true;
+ set(drawerNode, { transition: "none" });
+ set(overlayNode, { transition: "none" });
+ if (opts.snapPoints.current) {
+ snapPointsState.onDrag({ draggedDistance });
+ }
+ if (isDraggingInDirection && !opts.snapPoints.current) {
+ const dampenedDraggedDistance = dampenValue(draggedDistance);
+ const translateValue = Math.min(dampenedDraggedDistance * -1, 0) * directionMultiplier;
+ set(drawerNode, {
+ transform: isVertical(opts.direction.current) ? `translate3d(0, ${translateValue}px, 0)` : `translate3d(${translateValue}px, 0, 0)`
+ });
+ return;
+ }
+ const opacityValue = 1 - percentageDragged;
+ if (snapPointsState.shouldFade || opts.fadeFromIndex.current && snapPointsState.activeSnapPointIndex === opts.fadeFromIndex.current - 1) {
+ opts.onDrag.current?.(event, percentageDragged);
+ set(
+ overlayNode,
+ {
+ opacity: `${opacityValue}`,
+ transition: "none"
+ },
+ true
+ );
+ }
+ if (wrapper && overlayNode && opts.shouldScaleBackground.current) {
+ const scaleValue = Math.min(getScale() + percentageDragged * (1 - getScale()), 1);
+ const borderRadiusValue = 8 - percentageDragged * 8;
+ const translateValue = Math.max(0, 14 - percentageDragged * 14);
+ set(
+ wrapper,
+ {
+ borderRadius: `${borderRadiusValue}px`,
+ transform: isVertical(opts.direction.current) ? `scale(${scaleValue}) translate3d(0, ${translateValue}px, 0)` : `scale(${scaleValue}) translate3d(${translateValue}px, 0, 0)`,
+ transition: "none"
+ },
+ true
+ );
+ }
+ if (!opts.snapPoints.current) {
+ const translateValue = absDraggedDistance * directionMultiplier;
+ set(drawerNode, {
+ transform: isVertical(opts.direction.current) ? `translate3d(0, ${translateValue}px, 0)` : `translate3d(${translateValue}px, 0, 0)`
+ });
+ }
+ }
+ function onDialogOpenChange(o) {
+ if (!opts.dismissible.current && !o) return;
+ if (o) {
+ hasBeenOpened = true;
+ } else {
+ closeDrawer(true);
+ }
+ opts.open.current = o;
+ }
+ function onVisualViewportChange() {
+ if (!drawerNode || !opts.repositionInputs.current) return;
+ const focusedElement = document.activeElement;
+ if (isInput(focusedElement) || keyboardIsOpen.current) {
+ const visualViewportHeight = window.visualViewport?.height || 0;
+ const totalHeight = window.innerHeight;
+ let diffFromInitial = totalHeight - visualViewportHeight;
+ const drawerHeight2 = drawerNode.getBoundingClientRect().height || 0;
+ const isTallEnough = drawerHeight2 > totalHeight * 0.8;
+ if (!initialDrawerHeight) {
+ initialDrawerHeight = drawerHeight2;
+ }
+ const offsetFromTop = drawerNode.getBoundingClientRect().top;
+ if (Math.abs(previousDiffFromInitial - diffFromInitial) > 60) {
+ keyboardIsOpen.current = !keyboardIsOpen.current;
+ }
+ if (opts.snapPoints.current && opts.snapPoints.current.length > 0 && snapPointsState.snapPointsOffset && snapPointsState.activeSnapPointIndex) {
+ const activeSnapPointHeight = snapPointsState.snapPointsOffset[snapPointsState.activeSnapPointIndex] || 0;
+ diffFromInitial += activeSnapPointHeight;
+ }
+ previousDiffFromInitial = diffFromInitial;
+ if (drawerHeight2 > visualViewportHeight || keyboardIsOpen.current) {
+ const height = drawerNode.getBoundingClientRect().height;
+ let newDrawerHeight = height;
+ if (height > visualViewportHeight) {
+ newDrawerHeight = visualViewportHeight - (isTallEnough ? offsetFromTop : WINDOW_TOP_OFFSET);
+ }
+ if (opts.fixed.current) {
+ drawerNode.style.height = `${height - Math.max(diffFromInitial, 0)}px`;
+ } else {
+ drawerNode.style.height = `${Math.max(newDrawerHeight, visualViewportHeight - offsetFromTop)}px`;
+ }
+ } else if (!isMobileFirefox()) {
+ drawerNode.style.height = `${initialDrawerHeight}px`;
+ }
+ if (opts.snapPoints.current && opts.snapPoints.current.length > 0 && !keyboardIsOpen.current) {
+ drawerNode.style.bottom = `0px`;
+ } else {
+ drawerNode.style.bottom = `${Math.max(diffFromInitial, 0)}px`;
+ }
+ }
+ }
+ watch(
+ [
+ () => snapPointsState.activeSnapPointIndex,
+ () => opts.snapPoints.current,
+ () => snapPointsState.snapPointsOffset,
+ () => drawerNode
+ ],
+ () => {
+ if (!window.visualViewport) return;
+ return on(window.visualViewport, "resize", onVisualViewportChange);
+ }
+ );
+ function cancelDrag() {
+ if (!isDragging || !drawerNode) return;
+ drawerNode.classList.remove(DRAG_CLASS);
+ isAllowedToDrag = false;
+ isDragging = false;
+ dragEndTime = /* @__PURE__ */ new Date();
+ }
+ function closeDrawer(fromWithin) {
+ cancelDrag();
+ opts.onClose?.current();
+ if (!fromWithin) {
+ handleOpenChange(false);
+ opts.open.current = false;
+ }
+ window.setTimeout(
+ () => {
+ if (opts.snapPoints.current && opts.snapPoints.current.length > 0) {
+ opts.activeSnapPoint.current = opts.snapPoints.current[0];
+ }
+ },
+ TRANSITIONS.DURATION * 1e3
+ );
+ }
+ function resetDrawer() {
+ if (!drawerNode) return;
+ const wrapper = document.querySelector("[data-vaul-drawer-wrapper]");
+ const currentSwipeAmount = getTranslate(drawerNode, opts.direction.current);
+ set(drawerNode, {
+ transform: "translate3d(0, 0, 0)",
+ transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`
+ });
+ set(overlayNode, {
+ transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`,
+ opacity: "1"
+ });
+ if (opts.shouldScaleBackground.current && currentSwipeAmount && currentSwipeAmount > 0 && opts.open.current) {
+ set(
+ wrapper,
+ {
+ borderRadius: `${BORDER_RADIUS}px`,
+ overflow: "hidden",
+ ...isVertical(opts.direction.current) ? {
+ transform: `scale(${getScale()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,
+ transformOrigin: "top"
+ } : {
+ transform: `scale(${getScale()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,
+ transformOrigin: "left"
+ },
+ transitionProperty: "transform, border-radius",
+ transitionDuration: `${TRANSITIONS.DURATION}s`,
+ transitionTimingFunction: `cubic-bezier(${TRANSITIONS.EASE.join(",")})`
+ },
+ true
+ );
+ }
+ }
+ function onRelease(event) {
+ isReleasing = true;
+ handleRelease(event);
+ afterTick(() => {
+ isReleasing = false;
+ });
+ }
+ function handleRelease(event) {
+ if (!isDragging || !drawerNode) return;
+ drawerNode.classList.remove(DRAG_CLASS);
+ isAllowedToDrag = false;
+ isDragging = false;
+ dragEndTime = /* @__PURE__ */ new Date();
+ const swipeAmount = getTranslate(drawerNode, opts.direction.current);
+ if (!event || event.target && !shouldDrag(event.target, false) || !swipeAmount || Number.isNaN(swipeAmount)) {
+ return;
+ }
+ if (dragStartTime === null) return;
+ const timeTaken = dragEndTime.getTime() - dragStartTime.getTime();
+ const distMoved = pointerStart - (isVertical(opts.direction.current) ? event.pageY : event.pageX);
+ const velocity = Math.abs(distMoved) / timeTaken;
+ if (velocity > 0.05) {
+ justReleased = true;
+ setTimeout(
+ () => {
+ justReleased = false;
+ },
+ 200
+ );
+ }
+ if (opts.snapPoints.current) {
+ const directionMultiplier = opts.direction.current === "bottom" || opts.direction.current === "right" ? 1 : -1;
+ snapPointsState.onRelease({
+ draggedDistance: distMoved * directionMultiplier,
+ closeDrawer,
+ velocity,
+ dismissible: opts.dismissible.current
+ });
+ opts.onRelease.current?.(event, true);
+ return;
+ }
+ if (opts.direction.current === "bottom" || opts.direction.current === "right" ? distMoved > 0 : distMoved < 0) {
+ resetDrawer();
+ opts.onRelease.current?.(event, true);
+ return;
+ }
+ if (velocity > VELOCITY_THRESHOLD) {
+ closeDrawer();
+ opts.onRelease.current?.(event, false);
+ return;
+ }
+ const visibleDrawerHeight = Math.min(drawerNode.getBoundingClientRect().height ?? 0, window.innerHeight);
+ const visibleDrawerWidth = Math.min(drawerNode.getBoundingClientRect().width ?? 0, window.innerWidth);
+ const isHorizontalSwipe = opts.direction.current === "left" || opts.direction.current === "right";
+ if (Math.abs(swipeAmount) >= (isHorizontalSwipe ? visibleDrawerWidth : visibleDrawerHeight) * opts.closeThreshold.current) {
+ closeDrawer();
+ opts.onRelease.current?.(event, false);
+ return;
+ }
+ opts.onRelease.current?.(event, true);
+ resetDrawer();
+ }
+ watch(() => opts.open.current, () => {
+ if (opts.open.current) {
+ set(document.documentElement, { scrollBehavior: "auto" });
+ openTime = /* @__PURE__ */ new Date();
+ }
+ return () => {
+ reset(document.documentElement, "scrollBehavior");
+ };
+ });
+ function onNestedOpenChange(o) {
+ const scale = o ? (window.innerWidth - NESTED_DISPLACEMENT) / window.innerWidth : 1;
+ const initialTranslate = o ? -NESTED_DISPLACEMENT : 0;
+ if (nestedOpenChangeTimer) {
+ window.clearTimeout(nestedOpenChangeTimer);
+ }
+ set(drawerNode, {
+ transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`,
+ transform: isVertical(opts.direction.current) ? `scale(${scale}) translate3d(0, ${initialTranslate}px, 0)` : `scale(${scale}) translate3d(${initialTranslate}px, 0, 0)`
+ });
+ if (!o && drawerNode) {
+ nestedOpenChangeTimer = window.setTimeout(
+ () => {
+ const translateValue = getTranslate(drawerNode, opts.direction.current);
+ set(drawerNode, {
+ transition: "none",
+ transform: isVertical(opts.direction.current) ? `translate3d(0, ${translateValue}px, 0)` : `translate3d(${translateValue}px, 0, 0)`
+ });
+ },
+ 500
+ );
+ }
+ }
+ function onNestedDrag(_event, percentageDragged) {
+ if (percentageDragged < 0) return;
+ const initialScale = (window.innerWidth - NESTED_DISPLACEMENT) / window.innerWidth;
+ const newScale = initialScale + percentageDragged * (1 - initialScale);
+ const newTranslate = -NESTED_DISPLACEMENT + percentageDragged * NESTED_DISPLACEMENT;
+ set(drawerNode, {
+ transform: isVertical(opts.direction.current) ? `scale(${newScale}) translate3d(0, ${newTranslate}px, 0)` : `scale(${newScale}) translate3d(${newTranslate}px, 0, 0)`,
+ transition: "none"
+ });
+ }
+ function onNestedRelease(_event, o) {
+ const dim = isVertical(opts.direction.current) ? window.innerHeight : window.innerWidth;
+ const scale = o ? (dim - NESTED_DISPLACEMENT) / dim : 1;
+ const translate = o ? -NESTED_DISPLACEMENT : 0;
+ if (o) {
+ set(drawerNode, {
+ transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`,
+ transform: isVertical(opts.direction.current) ? `scale(${scale}) translate3d(0, ${translate}px, 0)` : `scale(${scale}) translate3d(${translate}px, 0, 0)`
+ });
+ }
+ }
+ let bodyStyles;
+ function handleOpenChange(o) {
+ opts.onOpenChange.current?.(o);
+ if (o && !opts.nested.current) {
+ bodyStyles = document.body.style.cssText;
+ } else if (!o && !opts.nested.current) {
+ afterSleep(TRANSITIONS.DURATION * 1e3, () => {
+ document.body.style.cssText = bodyStyles;
+ });
+ }
+ if (!o && !opts.nested.current) {
+ restorePositionSetting();
+ }
+ setTimeout(
+ () => {
+ opts.onAnimationEnd.current?.(o);
+ },
+ TRANSITIONS.DURATION * 1e3
+ );
+ if (o && !opts.modal.current) {
+ if (typeof window !== "undefined") {
+ window.requestAnimationFrame(() => {
+ document.body.style.pointerEvents = "auto";
+ });
+ }
+ }
+ if (!o) {
+ document.body.style.pointerEvents = "auto";
+ }
+ }
+ watch(() => opts.modal.current, () => {
+ if (!opts.modal.current) {
+ window.requestAnimationFrame(() => {
+ document.body.style.pointerEvents = "auto";
+ });
+ }
+ });
+ function setOverlayNode(node) {
+ overlayNode = node;
+ }
+ function setDrawerNode(node) {
+ drawerNode = node;
+ }
+ return DrawerContext.set({
+ ...opts,
+ keyboardIsOpen,
+ closeDrawer,
+ setDrawerNode,
+ setOverlayNode,
+ onDrag,
+ onNestedDrag,
+ onNestedOpenChange,
+ onNestedRelease,
+ onRelease,
+ onPress,
+ onDialogOpenChange,
+ get shouldAnimate() {
+ return shouldAnimate;
+ },
+ get isDragging() {
+ return isDragging;
+ },
+ get overlayNode() {
+ return overlayNode;
+ },
+ get drawerNode() {
+ return drawerNode;
+ },
+ get snapPointsOffset() {
+ return snapPointsState.snapPointsOffset;
+ },
+ get shouldFade() {
+ return snapPointsState.shouldFade;
+ },
+ restorePositionSetting,
+ handleOpenChange
+ });
+}
+function Drawer$1($$payload, $$props) {
+ push();
+ let {
+ open = false,
+ onOpenChange = noop,
+ onDrag = noop,
+ onRelease = noop,
+ snapPoints,
+ shouldScaleBackground = false,
+ setBackgroundColorOnScale = true,
+ closeThreshold = CLOSE_THRESHOLD,
+ scrollLockTimeout = SCROLL_LOCK_TIMEOUT,
+ dismissible = true,
+ handleOnly = false,
+ fadeFromIndex = snapPoints && snapPoints.length - 1,
+ activeSnapPoint = null,
+ onActiveSnapPointChange = noop,
+ fixed = false,
+ modal = true,
+ onClose = noop,
+ nested = false,
+ noBodyStyles = false,
+ direction = "bottom",
+ snapToSequentialPoint = false,
+ preventScrollRestoration = false,
+ repositionInputs = true,
+ onAnimationEnd = noop,
+ container = null,
+ autoFocus = false,
+ disablePreventScroll = true,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const rootState = useDrawerRoot({
+ open: box.with(() => open, (o) => {
+ open = o;
+ rootState.handleOpenChange(o);
+ }),
+ closeThreshold: box.with(() => closeThreshold),
+ scrollLockTimeout: box.with(() => scrollLockTimeout),
+ snapPoints: box.with(() => snapPoints),
+ fadeFromIndex: box.with(() => fadeFromIndex),
+ nested: box.with(() => nested),
+ shouldScaleBackground: box.with(() => shouldScaleBackground),
+ activeSnapPoint: box.with(() => activeSnapPoint, (v) => {
+ activeSnapPoint = v;
+ onActiveSnapPointChange(v);
+ }),
+ onRelease: box.with(() => onRelease),
+ onDrag: box.with(() => onDrag),
+ onClose: box.with(() => onClose),
+ dismissible: box.with(() => dismissible),
+ direction: box.with(() => direction),
+ fixed: box.with(() => fixed),
+ modal: box.with(() => modal),
+ handleOnly: box.with(() => handleOnly),
+ noBodyStyles: box.with(() => noBodyStyles),
+ preventScrollRestoration: box.with(() => preventScrollRestoration),
+ setBackgroundColorOnScale: box.with(() => setBackgroundColorOnScale),
+ repositionInputs: box.with(() => repositionInputs),
+ autoFocus: box.with(() => autoFocus),
+ snapToSequentialPoint: box.with(() => snapToSequentialPoint),
+ container: box.with(() => container),
+ disablePreventScroll: box.with(() => disablePreventScroll),
+ onOpenChange: box.with(() => onOpenChange),
+ onAnimationEnd: box.with(() => onAnimationEnd)
+ });
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ var bind_get = () => rootState.open.current;
+ var bind_set = (o) => {
+ rootState.onDialogOpenChange(o);
+ };
+ $$payload2.out += ``;
+ Dialog($$payload2, spread_props([
+ {
+ get open() {
+ return bind_get();
+ },
+ set open($$value) {
+ bind_set($$value);
+ }
+ },
+ restProps
+ ]));
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ bind_props($$props, { open, activeSnapPoint });
+ pop();
+}
+globalThis.vaulIdCounter ??= { current: 0 };
+function useId(prefix = "vaul-svelte") {
+ globalThis.vaulIdCounter.current++;
+ return `${prefix}-${globalThis.vaulIdCounter.current}`;
+}
+function useScaleBackground() {
+ const ctx = DrawerContext.get();
+ let timeoutId = null;
+ const initialBackgroundColor = typeof document !== "undefined" ? document.body.style.backgroundColor : "";
+ function getScale() {
+ return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
+ }
+ watch(
+ [
+ () => ctx.open.current,
+ () => ctx.shouldScaleBackground.current,
+ () => ctx.setBackgroundColorOnScale.current
+ ],
+ () => {
+ if (ctx.open.current && ctx.shouldScaleBackground.current) {
+ if (timeoutId) clearTimeout(timeoutId);
+ const wrapper = document.querySelector("[data-vaul-drawer-wrapper]") || document.querySelector("[data-vaul-drawer-wrapper]");
+ if (!wrapper) return;
+ chain$1(ctx.setBackgroundColorOnScale.current && !ctx.noBodyStyles.current ? assignStyle(document.body, { background: "black" }) : noop, assignStyle(wrapper, {
+ transformOrigin: isVertical(ctx.direction.current) ? "top" : "left",
+ transitionProperty: "transform, border-radius",
+ transitionDuration: `${TRANSITIONS.DURATION}s`,
+ transitionTimingFunction: `cubic-bezier(${TRANSITIONS.EASE.join(",")})`
+ }));
+ const wrapperStylesCleanup = assignStyle(wrapper, {
+ borderRadius: `${BORDER_RADIUS}px`,
+ overflow: "hidden",
+ ...isVertical(ctx.direction.current) ? {
+ transform: `scale(${getScale()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`
+ } : {
+ transform: `scale(${getScale()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`
+ }
+ });
+ return () => {
+ wrapperStylesCleanup();
+ timeoutId = window.setTimeout(
+ () => {
+ if (initialBackgroundColor) {
+ document.body.style.background = initialBackgroundColor;
+ } else {
+ document.body.style.removeProperty("background");
+ }
+ },
+ TRANSITIONS.DURATION * 1e3
+ );
+ };
+ }
+ }
+ );
+}
+function useDrawerContent(opts) {
+ const ctx = DrawerContext.get();
+ let mounted = false;
+ useRefById({
+ id: opts.id,
+ ref: opts.ref,
+ deps: () => [mounted, ctx.open.current],
+ onRefChange: (node) => {
+ if (!mounted) {
+ ctx.setDrawerNode(null);
+ } else {
+ ctx.setDrawerNode(node);
+ }
+ }
+ });
+ let delayedSnapPoints = false;
+ let pointerStart = null;
+ let lastKnownPointerEvent = null;
+ let wasBeyondThePoint = false;
+ const hasSnapPoints = ctx.snapPoints.current && ctx.snapPoints.current.length > 0;
+ useScaleBackground();
+ function isDeltaInDirection(delta, direction, threshold = 0) {
+ if (wasBeyondThePoint) return true;
+ const deltaY = Math.abs(delta.y);
+ const deltaX = Math.abs(delta.x);
+ const isDeltaX = deltaX > deltaY;
+ const dFactor = ["bottom", "right"].includes(direction) ? 1 : -1;
+ if (direction === "left" || direction === "right") {
+ const isReverseDirection = delta.x * dFactor < 0;
+ if (!isReverseDirection && deltaX >= 0 && deltaX <= threshold) {
+ return isDeltaX;
+ }
+ } else {
+ const isReverseDirection = delta.y * dFactor < 0;
+ if (!isReverseDirection && deltaY >= 0 && deltaY <= threshold) {
+ return !isDeltaX;
+ }
+ }
+ wasBeyondThePoint = true;
+ return true;
+ }
+ watch([() => hasSnapPoints, () => ctx.open.current], () => {
+ if (hasSnapPoints && ctx.open.current) {
+ window.requestAnimationFrame(() => {
+ delayedSnapPoints = true;
+ });
+ } else {
+ delayedSnapPoints = false;
+ }
+ });
+ function handleOnPointerUp(e) {
+ pointerStart = null;
+ wasBeyondThePoint = false;
+ ctx.onRelease(e);
+ }
+ function onpointerdown(e) {
+ if (ctx.handleOnly.current) return;
+ opts.onpointerdown.current?.(e);
+ pointerStart = { x: e.pageX, y: e.pageY };
+ ctx.onPress(e);
+ }
+ function onOpenAutoFocus(e) {
+ opts.onOpenAutoFocus.current?.(e);
+ if (!ctx.autoFocus.current) {
+ e.preventDefault();
+ }
+ }
+ function onInteractOutside(e) {
+ opts.onInteractOutside.current?.(e);
+ if (!ctx.modal.current || e.defaultPrevented) {
+ e.preventDefault();
+ return;
+ }
+ if (ctx.keyboardIsOpen.current) {
+ ctx.keyboardIsOpen.current = false;
+ }
+ }
+ function onFocusOutside(e) {
+ if (!ctx.modal.current) {
+ e.preventDefault();
+ return;
+ }
+ }
+ function onpointermove(e) {
+ lastKnownPointerEvent = e;
+ if (ctx.handleOnly.current) return;
+ opts.onpointermove.current?.(e);
+ if (!pointerStart) return;
+ const yPosition = e.pageY - pointerStart.y;
+ const xPosition = e.pageX - pointerStart.x;
+ const swipeStartThreshold = e.pointerType === "touch" ? 10 : 2;
+ const delta = { x: xPosition, y: yPosition };
+ const isAllowedToSwipe = isDeltaInDirection(delta, ctx.direction.current, swipeStartThreshold);
+ if (isAllowedToSwipe) {
+ ctx.onDrag(e);
+ } else if (Math.abs(xPosition) > swipeStartThreshold || Math.abs(yPosition) > swipeStartThreshold) {
+ pointerStart = null;
+ }
+ }
+ function onpointerup(e) {
+ opts.onpointerup.current?.(e);
+ pointerStart = null;
+ wasBeyondThePoint = false;
+ ctx.onRelease(e);
+ }
+ function onpointerout(e) {
+ opts.onpointerout.current?.(e);
+ handleOnPointerUp(lastKnownPointerEvent);
+ }
+ function oncontextmenu(e) {
+ opts.oncontextmenu.current?.(e);
+ if (lastKnownPointerEvent) {
+ handleOnPointerUp(lastKnownPointerEvent);
+ }
+ }
+ const props = {
+ id: opts.id.current,
+ "data-vaul-drawer-direction": ctx.direction.current,
+ "data-vaul-drawer": "",
+ "data-vaul-delayed-snap-points": delayedSnapPoints ? "true" : "false",
+ "data-vaul-snap-points": ctx.open.current && hasSnapPoints ? "true" : "false",
+ "data-vaul-custom-container": ctx.container.current ? "true" : "false",
+ "data-vaul-animate": ctx.shouldAnimate ? "true" : "false",
+ onpointerdown,
+ onOpenAutoFocus,
+ onInteractOutside,
+ onFocusOutside,
+ onpointerup,
+ onpointermove,
+ onpointerout,
+ oncontextmenu,
+ preventScroll: ctx.modal.current
+ };
+ return {
+ get props() {
+ return props;
+ },
+ ctx,
+ setMounted: (value) => {
+ mounted = value;
+ }
+ };
+}
+function Mounted($$payload, $$props) {
+ push();
+ let { onMounted } = $$props;
+ pop();
+}
+function Drawer_content$1($$payload, $$props) {
+ push();
+ let {
+ id = useId(),
+ ref = null,
+ onOpenAutoFocus = noop,
+ onInteractOutside = noop,
+ onFocusOutside = noop,
+ oncontextmenu = noop,
+ onpointerdown = noop,
+ onpointerup = noop,
+ onpointerout = noop,
+ onpointermove = noop,
+ children,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const contentState = useDrawerContent({
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v),
+ oncontextmenu: box.with(() => oncontextmenu ?? noop),
+ onInteractOutside: box.with(() => onInteractOutside),
+ onpointerdown: box.with(() => onpointerdown ?? noop),
+ onpointermove: box.with(() => onpointermove ?? noop),
+ onpointerout: box.with(() => onpointerout ?? noop),
+ onpointerup: box.with(() => onpointerup ?? noop),
+ onOpenAutoFocus: box.with(() => onOpenAutoFocus),
+ onFocusOutside: box.with(() => onFocusOutside)
+ });
+ const snapPointsOffset = contentState.ctx.snapPointsOffset;
+ const styleProp = snapPointsOffset && snapPointsOffset.length > 0 ? {
+ "--snap-point-height": `${snapPointsOffset[contentState.ctx.activeSnapPointIndex ?? 0]}px`
+ } : {};
+ const mergedProps = mergeProps(restProps, contentState.props, { style: styleProp });
+ $$payload.out += ``;
+ Dialog_content($$payload, spread_props([
+ mergedProps,
+ {
+ children: ($$payload2) => {
+ children?.($$payload2);
+ $$payload2.out += ` `;
+ Mounted($$payload2, { onMounted: contentState.setMounted });
+ $$payload2.out += ``;
+ },
+ $$slots: { default: true }
+ }
+ ]));
+ $$payload.out += ``;
+ bind_props($$props, { ref });
+ pop();
+}
+function useDrawerOverlay(opts) {
+ const ctx = DrawerContext.get();
+ let mounted = false;
+ useRefById({
+ id: opts.id,
+ ref: opts.ref,
+ deps: () => mounted,
+ onRefChange: (node) => {
+ if (!mounted) {
+ ctx.setOverlayNode(null);
+ } else {
+ ctx.setOverlayNode(node);
+ }
+ }
+ });
+ const hasSnapPoints = ctx.snapPoints.current && ctx.snapPoints.current.length > 0;
+ const shouldRender = ctx.modal.current;
+ const props = {
+ id: opts.id.current,
+ onmouseup: ctx.onRelease,
+ "data-vaul-overlay": "",
+ "data-vaul-snap-points": ctx.open.current && hasSnapPoints ? "true" : "false",
+ "data-vaul-snap-points-overlay": ctx.open.current && ctx.shouldFade ? "true" : "false",
+ "data-vaul-animate": ctx.shouldAnimate ? "true" : "false"
+ };
+ return {
+ get props() {
+ return props;
+ },
+ get shouldRender() {
+ return shouldRender;
+ },
+ setMounted: (value) => {
+ mounted = value;
+ }
+ };
+}
+function Drawer_overlay$1($$payload, $$props) {
+ push();
+ let {
+ id = useId(),
+ ref = null,
+ children,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const overlayState = useDrawerOverlay({
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v)
+ });
+ const mergedProps = mergeProps(restProps, overlayState.props);
+ if (overlayState.shouldRender) {
+ $$payload.out += "";
+ $$payload.out += ``;
+ Dialog_overlay($$payload, spread_props([
+ mergedProps,
+ {
+ children: ($$payload2) => {
+ Mounted($$payload2, { onMounted: overlayState.setMounted });
+ $$payload2.out += ` `;
+ children?.($$payload2);
+ $$payload2.out += ``;
+ },
+ $$slots: { default: true }
+ }
+ ]));
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ }
+ $$payload.out += ``;
+ bind_props($$props, { ref });
+ pop();
+}
+function Drawer_portal($$payload, $$props) {
+ push();
+ const ctx = DrawerContext.get();
+ let {
+ to = ctx.container.current ?? void 0,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ $$payload.out += ``;
+ Portal($$payload, spread_props([{ to }, restProps]));
+ $$payload.out += ``;
+ pop();
+}
+const Title = Dialog_title;
+const Description = Dialog_description;
+function Drawer($$payload, $$props) {
+ push();
+ let {
+ shouldScaleBackground = true,
+ open = false,
+ activeSnapPoint = null,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ $$payload2.out += ``;
+ Drawer$1($$payload2, spread_props([
+ { shouldScaleBackground },
+ restProps,
+ {
+ get open() {
+ return open;
+ },
+ set open($$value) {
+ open = $$value;
+ $$settled = false;
+ },
+ get activeSnapPoint() {
+ return activeSnapPoint;
+ },
+ set activeSnapPoint($$value) {
+ activeSnapPoint = $$value;
+ $$settled = false;
+ }
+ }
+ ]));
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ bind_props($$props, { open, activeSnapPoint });
+ pop();
+}
+function Drawer_overlay($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ class: className,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ $$payload2.out += ``;
+ Drawer_overlay$1($$payload2, spread_props([
+ {
+ class: cn("fixed inset-0 z-50 bg-black/80", className)
+ },
+ restProps,
+ {
+ get ref() {
+ return ref;
+ },
+ set ref($$value) {
+ ref = $$value;
+ $$settled = false;
+ }
+ }
+ ]));
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ bind_props($$props, { ref });
+ pop();
+}
+function Drawer_content($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ class: className,
+ portalProps,
+ children,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ $$payload2.out += ``;
+ Drawer_portal($$payload2, spread_props([
+ portalProps,
+ {
+ children: ($$payload3) => {
+ Drawer_overlay($$payload3, {});
+ $$payload3.out += ` `;
+ Drawer_content$1($$payload3, spread_props([
+ {
+ class: cn("bg-background fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border", className)
+ },
+ restProps,
+ {
+ get ref() {
+ return ref;
+ },
+ set ref($$value) {
+ ref = $$value;
+ $$settled = false;
+ },
+ children: ($$payload4) => {
+ $$payload4.out += `
`;
+ children?.($$payload4);
+ $$payload4.out += ``;
+ },
+ $$slots: { default: true }
+ }
+ ]));
+ $$payload3.out += ``;
+ },
+ $$slots: { default: true }
+ }
+ ]));
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ bind_props($$props, { ref });
+ pop();
+}
+function Drawer_description($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ class: className,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ $$payload2.out += ``;
+ Description($$payload2, spread_props([
+ {
+ class: cn("text-muted-foreground text-sm", className)
+ },
+ restProps,
+ {
+ get ref() {
+ return ref;
+ },
+ set ref($$value) {
+ ref = $$value;
+ $$settled = false;
+ }
+ }
+ ]));
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ bind_props($$props, { ref });
+ pop();
+}
+function Drawer_header($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ class: className,
+ children,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ $$payload.out += ``;
+ children?.($$payload);
+ $$payload.out += `
`;
+ bind_props($$props, { ref });
+ pop();
+}
+function Drawer_title($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ class: className,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ $$payload2.out += ``;
+ Title($$payload2, spread_props([
+ {
+ class: cn("text-lg font-semibold leading-none tracking-tight", className)
+ },
+ restProps,
+ {
+ get ref() {
+ return ref;
+ },
+ set ref($$value) {
+ ref = $$value;
+ $$settled = false;
+ }
+ }
+ ]));
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ bind_props($$props, { ref });
+ pop();
+}
+function KeyboardShortcutsHelp($$payload, $$props) {
+ push();
+ let shortcutGroups;
+ let isOpen = false;
+ function formatKey(key) {
+ return key.replace("ctrl+", "Ctrl+").replace("cmd+", "Cmd+").replace("shift+", "Shift+").replace("alt+", "Alt+").replace(" ", "+");
+ }
+ function handleOpenChange(open) {
+ isOpen = open;
+ }
+ shortcutGroups = keyboardShortcuts.getShortcutGroups();
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ Drawer($$payload2, {
+ onOpenChange: handleOpenChange,
+ get open() {
+ return isOpen;
+ },
+ set open($$value) {
+ isOpen = $$value;
+ $$settled = false;
+ },
+ children: ($$payload3) => {
+ Drawer_content($$payload3, {
+ class: "max-w-full mx-4 md:mx-8 lg:mx-16 max-h-[85vh]",
+ children: ($$payload4) => {
+ const each_array = ensure_array_like(shortcutGroups);
+ Drawer_header($$payload4, {
+ class: "text-center",
+ children: ($$payload5) => {
+ Drawer_title($$payload5, {
+ class: "flex items-center justify-center gap-2",
+ children: ($$payload6) => {
+ Keyboard($$payload6, { class: "w-5 h-5" });
+ $$payload6.out += ` Keyboard Shortcuts`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload5.out += ` `;
+ Drawer_description($$payload5, {
+ children: ($$payload6) => {
+ $$payload6.out += `Navigate the application faster with these keyboard shortcuts`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload5.out += ``;
+ },
+ $$slots: { default: true }
+ });
+ $$payload4.out += ` `;
+ for (let $$index_2 = 0, $$length = each_array.length; $$index_2 < $$length; $$index_2++) {
+ let group = each_array[$$index_2];
+ const each_array_1 = ensure_array_like(group.shortcuts);
+ $$payload4.out += `
${escape_html(group.title)} `;
+ for (let $$index_1 = 0, $$length2 = each_array_1.length; $$index_1 < $$length2; $$index_1++) {
+ let shortcut = each_array_1[$$index_1];
+ const each_array_2 = ensure_array_like(formatKey(shortcut.key).split("+"));
+ $$payload4.out += `
${escape_html(shortcut.description)} `;
+ if (shortcut.context && shortcut.context !== "global") {
+ $$payload4.out += "";
+ $$payload4.out += `Available on ${escape_html(shortcut.context === "results" ? "search results pages" : "table navigation")} `;
+ } else {
+ $$payload4.out += "";
+ }
+ $$payload4.out += `
`;
+ for (let $$index = 0, $$length3 = each_array_2.length; $$index < $$length3; $$index++) {
+ let keyPart = each_array_2[$$index];
+ Badge($$payload4, {
+ variant: "outline",
+ class: "text-xs font-mono px-2 py-1 bg-background",
+ children: ($$payload5) => {
+ $$payload5.out += `${escape_html(keyPart)}`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload4.out += ` `;
+ if (formatKey(shortcut.key).split("+").indexOf(keyPart) < formatKey(shortcut.key).split("+").length - 1) {
+ $$payload4.out += "";
+ $$payload4.out += `+ `;
+ } else {
+ $$payload4.out += "";
+ }
+ $$payload4.out += ``;
+ }
+ $$payload4.out += `
`;
+ }
+ $$payload4.out += `
`;
+ }
+ $$payload4.out += `
Press `;
+ Badge($$payload4, {
+ variant: "outline",
+ class: "text-xs font-mono px-2 py-1 bg-background",
+ children: ($$payload5) => {
+ $$payload5.out += `?`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload4.out += ` to open this help • Press `;
+ Badge($$payload4, {
+ variant: "outline",
+ class: "text-xs font-mono px-2 py-1 bg-background",
+ children: ($$payload5) => {
+ $$payload5.out += `Esc`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload4.out += ` or click outside to close
`;
+ },
+ $$slots: { default: true }
+ });
+ },
+ $$slots: { default: true }
+ });
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ pop();
+}
+function _layout($$payload, $$props) {
+ push();
+ let error = null;
+ onDestroy(() => {
+ keyboardShortcuts.destroy();
+ });
+ Provider($$payload, {
+ children: ($$payload2) => {
+ ErrorBoundary($$payload2, {
+ error,
+ reset: () => error = null,
+ children: ($$payload3) => {
+ $$payload3.out += ``;
+ Navbar($$payload3);
+ $$payload3.out += ` `;
+ slot($$payload3, $$props, "default", {});
+ $$payload3.out += `
`;
+ KeyboardShortcutsHelp($$payload3);
+ $$payload3.out += ``;
+ },
+ $$slots: { default: true }
+ });
+ }
+ });
+ pop();
+}
+export {
+ _layout as default
+};
diff --git a/.svelte-kit/output/server/entries/pages/_page.svelte.js b/.svelte-kit/output/server/entries/pages/_page.svelte.js
new file mode 100644
index 0000000..80629c5
--- /dev/null
+++ b/.svelte-kit/output/server/entries/pages/_page.svelte.js
@@ -0,0 +1,739 @@
+import "clsx";
+import { D as derived, w as push, E as spread_attributes, F as bind_props, y as pop, X as clsx, M as copy_payload, N as assign_payload, I as spread_props, K as attr } from "../../chunks/index.js";
+import { c as cn } from "../../chunks/breadcrumbs.js";
+import "../../chunks/client.js";
+import { A as ARROW_UP, O as ARROW_RIGHT, P as ARROW_LEFT, z as ARROW_DOWN, b as box, v as END, i as isBrowser, H as HOME, C as Context, Q as SvelteMap, u as useRefById, w as watch, S as SPACE, t as ENTER, p as getDataOrientation, G as getDataDisabled, r as getAriaOrientation, R as getDisabled, I as getAriaSelected, U as getHidden, a as useId, n as noop, m as mergeProps } from "../../chunks/noop.js";
+import "style-to-object";
+function getElemDirection(elem) {
+ const style = window.getComputedStyle(elem);
+ const direction = style.getPropertyValue("direction");
+ return direction;
+}
+function getNextKey(dir = "ltr", orientation = "horizontal") {
+ return {
+ horizontal: dir === "rtl" ? ARROW_LEFT : ARROW_RIGHT,
+ vertical: ARROW_DOWN
+ }[orientation];
+}
+function getPrevKey(dir = "ltr", orientation = "horizontal") {
+ return {
+ horizontal: dir === "rtl" ? ARROW_RIGHT : ARROW_LEFT,
+ vertical: ARROW_UP
+ }[orientation];
+}
+function getDirectionalKeys(dir = "ltr", orientation = "horizontal") {
+ if (!["ltr", "rtl"].includes(dir))
+ dir = "ltr";
+ if (!["horizontal", "vertical"].includes(orientation))
+ orientation = "horizontal";
+ return {
+ nextKey: getNextKey(dir, orientation),
+ prevKey: getPrevKey(dir, orientation)
+ };
+}
+function useRovingFocus(props) {
+ const currentTabStopId = box(null);
+ function getCandidateNodes() {
+ if (!isBrowser) return [];
+ const node = document.getElementById(props.rootNodeId.current);
+ if (!node) return [];
+ if (props.candidateSelector) {
+ const candidates = Array.from(node.querySelectorAll(props.candidateSelector));
+ return candidates;
+ } else if (props.candidateAttr) {
+ const candidates = Array.from(node.querySelectorAll(`[${props.candidateAttr}]:not([data-disabled])`));
+ return candidates;
+ }
+ return [];
+ }
+ function focusFirstCandidate() {
+ const items = getCandidateNodes();
+ if (!items.length) return;
+ items[0]?.focus();
+ }
+ function handleKeydown(node, e, both = false) {
+ const rootNode = document.getElementById(props.rootNodeId.current);
+ if (!rootNode || !node) return;
+ const items = getCandidateNodes();
+ if (!items.length) return;
+ const currentIndex = items.indexOf(node);
+ const dir = getElemDirection(rootNode);
+ const { nextKey, prevKey } = getDirectionalKeys(dir, props.orientation.current);
+ const loop = props.loop.current;
+ const keyToIndex = {
+ [nextKey]: currentIndex + 1,
+ [prevKey]: currentIndex - 1,
+ [HOME]: 0,
+ [END]: items.length - 1
+ };
+ if (both) {
+ const altNextKey = nextKey === ARROW_DOWN ? ARROW_RIGHT : ARROW_DOWN;
+ const altPrevKey = prevKey === ARROW_UP ? ARROW_LEFT : ARROW_UP;
+ keyToIndex[altNextKey] = currentIndex + 1;
+ keyToIndex[altPrevKey] = currentIndex - 1;
+ }
+ let itemIndex = keyToIndex[e.key];
+ if (itemIndex === void 0) return;
+ e.preventDefault();
+ if (itemIndex < 0 && loop) {
+ itemIndex = items.length - 1;
+ } else if (itemIndex === items.length && loop) {
+ itemIndex = 0;
+ }
+ const itemToFocus = items[itemIndex];
+ if (!itemToFocus) return;
+ itemToFocus.focus();
+ currentTabStopId.current = itemToFocus.id;
+ props.onCandidateFocus?.(itemToFocus);
+ return itemToFocus;
+ }
+ function getTabIndex(node) {
+ const items = getCandidateNodes();
+ const anyActive = currentTabStopId.current !== null;
+ if (node && !anyActive && items[0] === node) {
+ currentTabStopId.current = node.id;
+ return 0;
+ } else if (node?.id === currentTabStopId.current) {
+ return 0;
+ }
+ return -1;
+ }
+ return {
+ setCurrentTabStopId(id) {
+ currentTabStopId.current = id;
+ },
+ getTabIndex,
+ handleKeydown,
+ focusFirstCandidate,
+ currentTabStopId
+ };
+}
+const TABS_ROOT_ATTR = "data-tabs-root";
+const TABS_LIST_ATTR = "data-tabs-list";
+const TABS_TRIGGER_ATTR = "data-tabs-trigger";
+const TABS_CONTENT_ATTR = "data-tabs-content";
+class TabsRootState {
+ opts;
+ rovingFocusGroup;
+ triggerIds = [];
+ // holds the trigger ID for each value to associate it with the content
+ valueToTriggerId = new SvelteMap();
+ // holds the content ID for each value to associate it with the trigger
+ valueToContentId = new SvelteMap();
+ constructor(opts) {
+ this.opts = opts;
+ useRefById(opts);
+ this.rovingFocusGroup = useRovingFocus({
+ candidateAttr: TABS_TRIGGER_ATTR,
+ rootNodeId: this.opts.id,
+ loop: this.opts.loop,
+ orientation: this.opts.orientation
+ });
+ }
+ registerTrigger(id, value) {
+ this.triggerIds.push(id);
+ this.valueToTriggerId.set(value, id);
+ return () => {
+ this.triggerIds = this.triggerIds.filter((triggerId) => triggerId !== id);
+ this.valueToTriggerId.delete(value);
+ };
+ }
+ registerContent(id, value) {
+ this.valueToContentId.set(value, id);
+ return () => {
+ this.valueToContentId.delete(value);
+ };
+ }
+ setValue(v) {
+ this.opts.value.current = v;
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ "data-orientation": getDataOrientation(this.opts.orientation.current),
+ [TABS_ROOT_ATTR]: ""
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class TabsListState {
+ opts;
+ root;
+ #isDisabled = derived(() => this.root.opts.disabled.current);
+ constructor(opts, root) {
+ this.opts = opts;
+ this.root = root;
+ useRefById(opts);
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ role: "tablist",
+ "aria-orientation": getAriaOrientation(this.root.opts.orientation.current),
+ "data-orientation": getDataOrientation(this.root.opts.orientation.current),
+ [TABS_LIST_ATTR]: "",
+ "data-disabled": getDataDisabled(this.#isDisabled())
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class TabsTriggerState {
+ opts;
+ root;
+ #isActive = derived(() => this.root.opts.value.current === this.opts.value.current);
+ #isDisabled = derived(() => this.opts.disabled.current || this.root.opts.disabled.current);
+ #tabIndex = 0;
+ #ariaControls = derived(() => this.root.valueToContentId.get(this.opts.value.current));
+ constructor(opts, root) {
+ this.opts = opts;
+ this.root = root;
+ useRefById(opts);
+ watch(
+ [
+ () => this.opts.id.current,
+ () => this.opts.value.current
+ ],
+ ([id, value]) => {
+ return this.root.registerTrigger(id, value);
+ }
+ );
+ this.onfocus = this.onfocus.bind(this);
+ this.onclick = this.onclick.bind(this);
+ this.onkeydown = this.onkeydown.bind(this);
+ }
+ #activate() {
+ if (this.root.opts.value.current === this.opts.value.current) return;
+ this.root.setValue(this.opts.value.current);
+ }
+ onfocus(_) {
+ if (this.root.opts.activationMode.current !== "automatic" || this.#isDisabled()) return;
+ this.#activate();
+ }
+ onclick(_) {
+ if (this.#isDisabled()) return;
+ this.#activate();
+ }
+ onkeydown(e) {
+ if (this.#isDisabled()) return;
+ if (e.key === SPACE || e.key === ENTER) {
+ e.preventDefault();
+ this.#activate();
+ return;
+ }
+ this.root.rovingFocusGroup.handleKeydown(this.opts.ref.current, e);
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ role: "tab",
+ "data-state": getTabDataState(this.#isActive()),
+ "data-value": this.opts.value.current,
+ "data-orientation": getDataOrientation(this.root.opts.orientation.current),
+ "data-disabled": getDataDisabled(this.#isDisabled()),
+ "aria-selected": getAriaSelected(this.#isActive()),
+ "aria-controls": this.#ariaControls(),
+ [TABS_TRIGGER_ATTR]: "",
+ disabled: getDisabled(this.#isDisabled()),
+ tabindex: this.#tabIndex,
+ //
+ onclick: this.onclick,
+ onfocus: this.onfocus,
+ onkeydown: this.onkeydown
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+class TabsContentState {
+ opts;
+ root;
+ #isActive = derived(() => this.root.opts.value.current === this.opts.value.current);
+ #ariaLabelledBy = derived(() => this.root.valueToTriggerId.get(this.opts.value.current));
+ constructor(opts, root) {
+ this.opts = opts;
+ this.root = root;
+ useRefById(opts);
+ watch(
+ [
+ () => this.opts.id.current,
+ () => this.opts.value.current
+ ],
+ ([id, value]) => {
+ return this.root.registerContent(id, value);
+ }
+ );
+ }
+ #props = derived(() => ({
+ id: this.opts.id.current,
+ role: "tabpanel",
+ hidden: getHidden(!this.#isActive()),
+ tabindex: 0,
+ "data-value": this.opts.value.current,
+ "data-state": getTabDataState(this.#isActive()),
+ "aria-labelledby": this.#ariaLabelledBy(),
+ [TABS_CONTENT_ATTR]: ""
+ }));
+ get props() {
+ return this.#props();
+ }
+ set props($$value) {
+ return this.#props($$value);
+ }
+}
+const TabsRootContext = new Context("Tabs.Root");
+function useTabsRoot(props) {
+ return TabsRootContext.set(new TabsRootState(props));
+}
+function useTabsTrigger(props) {
+ return new TabsTriggerState(props, TabsRootContext.get());
+}
+function useTabsList(props) {
+ return new TabsListState(props, TabsRootContext.get());
+}
+function useTabsContent(props) {
+ return new TabsContentState(props, TabsRootContext.get());
+}
+function getTabDataState(condition) {
+ return condition ? "active" : "inactive";
+}
+function Tabs($$payload, $$props) {
+ push();
+ let {
+ id = useId(),
+ ref = null,
+ value = "",
+ onValueChange = noop,
+ orientation = "horizontal",
+ loop = true,
+ activationMode = "automatic",
+ disabled = false,
+ children,
+ child,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const rootState = useTabsRoot({
+ id: box.with(() => id),
+ value: box.with(() => value, (v) => {
+ value = v;
+ onValueChange(v);
+ }),
+ orientation: box.with(() => orientation),
+ loop: box.with(() => loop),
+ activationMode: box.with(() => activationMode),
+ disabled: box.with(() => disabled),
+ ref: box.with(() => ref, (v) => ref = v)
+ });
+ const mergedProps = mergeProps(restProps, rootState.props);
+ if (child) {
+ $$payload.out += "";
+ child($$payload, { props: mergedProps });
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ $$payload.out += ``;
+ children?.($$payload);
+ $$payload.out += `
`;
+ }
+ $$payload.out += ``;
+ bind_props($$props, { ref, value });
+ pop();
+}
+function Tabs_content$1($$payload, $$props) {
+ push();
+ let {
+ children,
+ child,
+ id = useId(),
+ ref = null,
+ value,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const contentState = useTabsContent({
+ value: box.with(() => value),
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v)
+ });
+ const mergedProps = mergeProps(restProps, contentState.props);
+ if (child) {
+ $$payload.out += "";
+ child($$payload, { props: mergedProps });
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ $$payload.out += ``;
+ children?.($$payload);
+ $$payload.out += `
`;
+ }
+ $$payload.out += ``;
+ bind_props($$props, { ref });
+ pop();
+}
+function Tabs_list$1($$payload, $$props) {
+ push();
+ let {
+ child,
+ children,
+ id = useId(),
+ ref = null,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const listState = useTabsList({
+ id: box.with(() => id),
+ ref: box.with(() => ref, (v) => ref = v)
+ });
+ const mergedProps = mergeProps(restProps, listState.props);
+ if (child) {
+ $$payload.out += "";
+ child($$payload, { props: mergedProps });
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ $$payload.out += ``;
+ children?.($$payload);
+ $$payload.out += `
`;
+ }
+ $$payload.out += ``;
+ bind_props($$props, { ref });
+ pop();
+}
+function Tabs_trigger$1($$payload, $$props) {
+ push();
+ let {
+ child,
+ children,
+ disabled = false,
+ id = useId(),
+ type = "button",
+ value,
+ ref = null,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ const triggerState = useTabsTrigger({
+ id: box.with(() => id),
+ disabled: box.with(() => disabled ?? false),
+ value: box.with(() => value),
+ ref: box.with(() => ref, (v) => ref = v)
+ });
+ const mergedProps = mergeProps(restProps, triggerState.props, { type });
+ if (child) {
+ $$payload.out += "";
+ child($$payload, { props: mergedProps });
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ $$payload.out += ``;
+ children?.($$payload);
+ $$payload.out += ` `;
+ }
+ $$payload.out += ``;
+ bind_props($$props, { ref });
+ pop();
+}
+function Card($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ class: className,
+ children,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ $$payload.out += ``;
+ children?.($$payload);
+ $$payload.out += `
`;
+ bind_props($$props, { ref });
+ pop();
+}
+function Tabs_content($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ class: className,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ $$payload2.out += ``;
+ Tabs_content$1($$payload2, spread_props([
+ {
+ class: cn("ring-offset-background focus-visible:ring-ring mt-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2", className)
+ },
+ restProps,
+ {
+ get ref() {
+ return ref;
+ },
+ set ref($$value) {
+ ref = $$value;
+ $$settled = false;
+ }
+ }
+ ]));
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ bind_props($$props, { ref });
+ pop();
+}
+function Tabs_list($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ class: className,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ $$payload2.out += ``;
+ Tabs_list$1($$payload2, spread_props([
+ {
+ class: cn("bg-muted text-muted-foreground inline-flex h-10 items-center justify-center rounded-md p-1", className)
+ },
+ restProps,
+ {
+ get ref() {
+ return ref;
+ },
+ set ref($$value) {
+ ref = $$value;
+ $$settled = false;
+ }
+ }
+ ]));
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ bind_props($$props, { ref });
+ pop();
+}
+function Tabs_trigger($$payload, $$props) {
+ push();
+ let {
+ ref = null,
+ class: className,
+ $$slots,
+ $$events,
+ ...restProps
+ } = $$props;
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ $$payload2.out += ``;
+ Tabs_trigger$1($$payload2, spread_props([
+ {
+ class: cn("ring-offset-background focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm", className)
+ },
+ restProps,
+ {
+ get ref() {
+ return ref;
+ },
+ set ref($$value) {
+ ref = $$value;
+ $$settled = false;
+ }
+ }
+ ]));
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ bind_props($$props, { ref });
+ pop();
+}
+const Root = Tabs;
+function TabbedSearch($$payload, $$props) {
+ push();
+ let activeTab = "smart";
+ let searchValues = {
+ smart: "",
+ username: "",
+ password: "",
+ domain: "",
+ email: ""
+ };
+ let $$settled = true;
+ let $$inner_payload;
+ function $$render_inner($$payload2) {
+ $$payload2.out += ``;
+ Root($$payload2, {
+ class: "w-full",
+ get value() {
+ return activeTab;
+ },
+ set value($$value) {
+ activeTab = $$value;
+ $$settled = false;
+ },
+ children: ($$payload3) => {
+ $$payload3.out += ``;
+ Tabs_list($$payload3, {
+ class: "grid w-full grid-cols-5 mb-6",
+ children: ($$payload4) => {
+ $$payload4.out += ``;
+ Tabs_trigger($$payload4, {
+ value: "smart",
+ class: "flex items-center gap-1",
+ children: ($$payload5) => {
+ $$payload5.out += `Smart Search`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload4.out += ` `;
+ Tabs_trigger($$payload4, {
+ value: "username",
+ class: "flex items-center gap-1",
+ children: ($$payload5) => {
+ $$payload5.out += `Username`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload4.out += ` `;
+ Tabs_trigger($$payload4, {
+ value: "password",
+ class: "flex items-center gap-1",
+ children: ($$payload5) => {
+ $$payload5.out += `Password`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload4.out += ` `;
+ Tabs_trigger($$payload4, {
+ value: "domain",
+ class: "flex items-center gap-1",
+ children: ($$payload5) => {
+ $$payload5.out += `Domain`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload4.out += ` `;
+ Tabs_trigger($$payload4, {
+ value: "email",
+ class: "flex items-center gap-1",
+ children: ($$payload5) => {
+ $$payload5.out += `Email`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload4.out += ``;
+ },
+ $$slots: { default: true }
+ });
+ $$payload3.out += ` `;
+ Tabs_content($$payload3, {
+ value: "smart",
+ class: "space-y-4",
+ children: ($$payload4) => {
+ $$payload4.out += ` Press Enter to search. I'll automatically detect the type of search.
`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload3.out += ` `;
+ Tabs_content($$payload3, {
+ value: "username",
+ class: "space-y-4",
+ children: ($$payload4) => {
+ $$payload4.out += ` Search for usernames across breach databases.
`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload3.out += ` `;
+ Tabs_content($$payload3, {
+ value: "password",
+ class: "space-y-4",
+ children: ($$payload4) => {
+ $$payload4.out += ` ⚠️ Security Warning: This password will be checked against breach databases. Only
+ test passwords you no longer use.
`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload3.out += ` `;
+ Tabs_content($$payload3, {
+ value: "domain",
+ class: "space-y-4",
+ children: ($$payload4) => {
+ $$payload4.out += ` Find all accounts associated with a specific domain.
`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload3.out += ` `;
+ Tabs_content($$payload3, {
+ value: "email",
+ class: "space-y-4",
+ children: ($$payload4) => {
+ $$payload4.out += ` Search for email addresses and view detailed breach information from Have I Been Pwned.
`;
+ },
+ $$slots: { default: true }
+ });
+ $$payload3.out += ``;
+ },
+ $$slots: { default: true }
+ });
+ $$payload2.out += ``;
+ }
+ do {
+ $$settled = true;
+ $$inner_payload = copy_payload($$payload);
+ $$render_inner($$inner_payload);
+ } while (!$$settled);
+ assign_payload($$payload, $$inner_payload);
+ pop();
+}
+function _page($$payload, $$props) {
+ push();
+ $$payload.out += `
PassDB Search `;
+ Card($$payload, {
+ class: "p-6 border-0",
+ children: ($$payload2) => {
+ TabbedSearch($$payload2);
+ },
+ $$slots: { default: true }
+ });
+ $$payload.out += ` `;
+ pop();
+}
+export {
+ _page as default
+};
diff --git a/.svelte-kit/output/server/entries/pages/domain/_domain_/_page.svelte.js b/.svelte-kit/output/server/entries/pages/domain/_domain_/_page.svelte.js
new file mode 100644
index 0000000..01ac079
--- /dev/null
+++ b/.svelte-kit/output/server/entries/pages/domain/_domain_/_page.svelte.js
@@ -0,0 +1,21 @@
+import { R as store_get, S as unsubscribe_stores, y as pop, w as push } from "../../../../chunks/index.js";
+import { p as page } from "../../../../chunks/breadcrumbs.js";
+import { S as SearchResultLayout } from "../../../../chunks/SearchResultLayout.js";
+function _page($$payload, $$props) {
+ push();
+ var $$store_subs;
+ let domain;
+ domain = store_get($$store_subs ??= {}, "$page", page).params.domain;
+ SearchResultLayout($$payload, {
+ params: { domain },
+ apiPath: "domains",
+ paramKey: "domain",
+ breadcrumbLabel: "Domain",
+ formatBreadcrumb: (v) => v
+ });
+ if ($$store_subs) unsubscribe_stores($$store_subs);
+ pop();
+}
+export {
+ _page as default
+};
diff --git a/.svelte-kit/output/server/entries/pages/email/_email_/_page.svelte.js b/.svelte-kit/output/server/entries/pages/email/_email_/_page.svelte.js
new file mode 100644
index 0000000..f2b35dd
--- /dev/null
+++ b/.svelte-kit/output/server/entries/pages/email/_email_/_page.svelte.js
@@ -0,0 +1,86 @@
+import { w as push, J as escape_html, T as ensure_array_like, K as attr, F as bind_props, y as pop, R as store_get, S as unsubscribe_stores } from "../../../../chunks/index.js";
+import { p as page } from "../../../../chunks/breadcrumbs.js";
+import { u as useAPI, L as LoadingStates, S as SearchResultLayout } from "../../../../chunks/SearchResultLayout.js";
+function html(value) {
+ var html2 = String(value ?? "");
+ var open = "";
+ return open + html2 + "";
+}
+function sanitizeHtml(html2) {
+ const temp = document.createElement("div");
+ temp.textContent = html2;
+ return temp.innerHTML;
+}
+function HIBP($$payload, $$props) {
+ push();
+ let email = $$props["email"];
+ const { data: results, loading, error, isSuccess } = useAPI(`/breaches/${email}`);
+ if (loading) {
+ $$payload.out += "";
+ $$payload.out += ``;
+ LoadingStates($$payload, {
+ type: "spinner",
+ message: "Checking breach databases..."
+ });
+ $$payload.out += `
`;
+ } else if (error) {
+ $$payload.out += "";
+ $$payload.out += ` Unable to check breaches ${escape_html(error.message)}
`;
+ } else if (isSuccess && results) {
+ $$payload.out += "";
+ if (results.length > 0) {
+ $$payload.out += "";
+ const each_array = ensure_array_like(results);
+ $$payload.out += `Data Breaches Found ${escape_html(results.length)} breach${escape_html(results.length !== 1 ? "es" : "")} for this email
`;
+ for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
+ let breach = each_array[$$index];
+ $$payload.out += `
`;
+ if (breach.LogoPath) {
+ $$payload.out += "";
+ $$payload.out += `
`;
+ } else {
+ $$payload.out += "";
+ }
+ $$payload.out += `
${escape_html(breach.Title)} ${escape_html(Number(breach.Count).toLocaleString())} accounts ${escape_html(breach.Domain)} ${escape_html(breach.Date)} ${html(sanitizeHtml(breach.Description))}
`;
+ }
+ $$payload.out += `
`;
+ } else {
+ $$payload.out += "";
+ $$payload.out += ` No breaches found This email hasn't been found in any known data breaches
`;
+ }
+ $$payload.out += ``;
+ } else {
+ $$payload.out += "";
+ }
+ $$payload.out += ``;
+ bind_props($$props, { email });
+ pop();
+}
+function _page($$payload, $$props) {
+ push();
+ var $$store_subs;
+ let email;
+ email = store_get($$store_subs ??= {}, "$page", page).params.email;
+ SearchResultLayout($$payload, {
+ params: { email },
+ apiPath: "emails",
+ paramKey: "email",
+ breadcrumbLabel: "Email",
+ formatBreadcrumb: (v) => v,
+ children: ($$payload2) => {
+ if (email) {
+ $$payload2.out += "";
+ HIBP($$payload2, { email });
+ } else {
+ $$payload2.out += "";
+ }
+ $$payload2.out += ``;
+ },
+ $$slots: { default: true }
+ });
+ if ($$store_subs) unsubscribe_stores($$store_subs);
+ pop();
+}
+export {
+ _page as default
+};
diff --git a/.svelte-kit/output/server/entries/pages/password/_password_/_page.svelte.js b/.svelte-kit/output/server/entries/pages/password/_password_/_page.svelte.js
new file mode 100644
index 0000000..a03d6c9
--- /dev/null
+++ b/.svelte-kit/output/server/entries/pages/password/_password_/_page.svelte.js
@@ -0,0 +1,24 @@
+import { R as store_get, S as unsubscribe_stores, y as pop, w as push } from "../../../../chunks/index.js";
+import { p as page } from "../../../../chunks/breadcrumbs.js";
+import { S as SearchResultLayout } from "../../../../chunks/SearchResultLayout.js";
+function _page($$payload, $$props) {
+ push();
+ var $$store_subs;
+ let password;
+ function formatPassword(password2) {
+ return password2.length > 20 ? password2.substring(0, 20) + "..." : password2;
+ }
+ password = store_get($$store_subs ??= {}, "$page", page).params.password;
+ SearchResultLayout($$payload, {
+ params: { password },
+ apiPath: "passwords",
+ paramKey: "password",
+ breadcrumbLabel: "Password",
+ formatBreadcrumb: formatPassword
+ });
+ if ($$store_subs) unsubscribe_stores($$store_subs);
+ pop();
+}
+export {
+ _page as default
+};
diff --git a/.svelte-kit/output/server/entries/pages/username/_name_/_page.svelte.js b/.svelte-kit/output/server/entries/pages/username/_name_/_page.svelte.js
new file mode 100644
index 0000000..de5d4e9
--- /dev/null
+++ b/.svelte-kit/output/server/entries/pages/username/_name_/_page.svelte.js
@@ -0,0 +1,21 @@
+import { R as store_get, S as unsubscribe_stores, y as pop, w as push } from "../../../../chunks/index.js";
+import { p as page } from "../../../../chunks/breadcrumbs.js";
+import { S as SearchResultLayout } from "../../../../chunks/SearchResultLayout.js";
+function _page($$payload, $$props) {
+ push();
+ var $$store_subs;
+ let name;
+ name = store_get($$store_subs ??= {}, "$page", page).params.name;
+ SearchResultLayout($$payload, {
+ params: { name },
+ apiPath: "usernames",
+ paramKey: "name",
+ breadcrumbLabel: "Username",
+ formatBreadcrumb: (v) => v
+ });
+ if ($$store_subs) unsubscribe_stores($$store_subs);
+ pop();
+}
+export {
+ _page as default
+};
diff --git a/.svelte-kit/output/server/index.js b/.svelte-kit/output/server/index.js
new file mode 100644
index 0000000..c5bf735
--- /dev/null
+++ b/.svelte-kit/output/server/index.js
@@ -0,0 +1,3363 @@
+import { B as BROWSER } from "./chunks/index.js";
+import { a as assets, b as base, c as app_dir, p as public_env, s as safe_public_env, o as override, r as reset, d as read_implementation, e as options, g as get_hooks, f as set_private_env, h as prerendering, i as set_public_env, j as set_safe_public_env, k as set_read_implementation } from "./chunks/internal.js";
+import * as devalue from "devalue";
+import { m as make_trackable, d as disable_search, a as decode_params, r as readable, w as writable, v as validate_layout_server_exports, b as validate_layout_exports, c as validate_page_server_exports, e as validate_page_exports, n as normalize_path, f as resolve, g as decode_pathname, h as validate_server_exports } from "./chunks/exports.js";
+import { parse, serialize } from "cookie";
+import * as set_cookie_parser from "set-cookie-parser";
+const SVELTE_KIT_ASSETS = "/_svelte_kit_assets";
+const ENDPOINT_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"];
+const PAGE_METHODS = ["GET", "POST", "HEAD"];
+function negotiate(accept, types) {
+ const parts = [];
+ accept.split(",").forEach((str, i) => {
+ const match = /([^/ \t]+)\/([^; \t]+)[ \t]*(?:;[ \t]*q=([0-9.]+))?/.exec(str);
+ if (match) {
+ const [, type, subtype, q = "1"] = match;
+ parts.push({ type, subtype, q: +q, i });
+ }
+ });
+ parts.sort((a, b) => {
+ if (a.q !== b.q) {
+ return b.q - a.q;
+ }
+ if (a.subtype === "*" !== (b.subtype === "*")) {
+ return a.subtype === "*" ? 1 : -1;
+ }
+ if (a.type === "*" !== (b.type === "*")) {
+ return a.type === "*" ? 1 : -1;
+ }
+ return a.i - b.i;
+ });
+ let accepted;
+ let min_priority = Infinity;
+ for (const mimetype of types) {
+ const [type, subtype] = mimetype.split("/");
+ const priority = parts.findIndex(
+ (part) => (part.type === type || part.type === "*") && (part.subtype === subtype || part.subtype === "*")
+ );
+ if (priority !== -1 && priority < min_priority) {
+ accepted = mimetype;
+ min_priority = priority;
+ }
+ }
+ return accepted;
+}
+function is_content_type(request, ...types) {
+ const type = request.headers.get("content-type")?.split(";", 1)[0].trim() ?? "";
+ return types.includes(type.toLowerCase());
+}
+function is_form_content_type(request) {
+ return is_content_type(
+ request,
+ "application/x-www-form-urlencoded",
+ "multipart/form-data",
+ "text/plain"
+ );
+}
+let request_event = null;
+let als;
+import("node:async_hooks").then((hooks) => als = new hooks.AsyncLocalStorage()).catch(() => {
+});
+function with_event(event, fn) {
+ try {
+ request_event = event;
+ return als ? als.run(event, fn) : fn();
+ } finally {
+ request_event = null;
+ }
+}
+class HttpError {
+ /**
+ * @param {number} status
+ * @param {{message: string} extends App.Error ? (App.Error | string | undefined) : App.Error} body
+ */
+ constructor(status, body2) {
+ this.status = status;
+ if (typeof body2 === "string") {
+ this.body = { message: body2 };
+ } else if (body2) {
+ this.body = body2;
+ } else {
+ this.body = { message: `Error: ${status}` };
+ }
+ }
+ toString() {
+ return JSON.stringify(this.body);
+ }
+}
+class Redirect {
+ /**
+ * @param {300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308} status
+ * @param {string} location
+ */
+ constructor(status, location) {
+ this.status = status;
+ this.location = location;
+ }
+}
+class SvelteKitError extends Error {
+ /**
+ * @param {number} status
+ * @param {string} text
+ * @param {string} message
+ */
+ constructor(status, text2, message) {
+ super(message);
+ this.status = status;
+ this.text = text2;
+ }
+}
+class ActionFailure {
+ /**
+ * @param {number} status
+ * @param {T} data
+ */
+ constructor(status, data) {
+ this.status = status;
+ this.data = data;
+ }
+}
+const DATA_SUFFIX = "/__data.json";
+const HTML_DATA_SUFFIX = ".html__data.json";
+function has_data_suffix(pathname) {
+ return pathname.endsWith(DATA_SUFFIX) || pathname.endsWith(HTML_DATA_SUFFIX);
+}
+function add_data_suffix(pathname) {
+ if (pathname.endsWith(".html")) return pathname.replace(/\.html$/, HTML_DATA_SUFFIX);
+ return pathname.replace(/\/$/, "") + DATA_SUFFIX;
+}
+function strip_data_suffix(pathname) {
+ if (pathname.endsWith(HTML_DATA_SUFFIX)) {
+ return pathname.slice(0, -HTML_DATA_SUFFIX.length) + ".html";
+ }
+ return pathname.slice(0, -DATA_SUFFIX.length);
+}
+const ROUTE_SUFFIX = "/__route.js";
+function has_resolution_suffix(pathname) {
+ return pathname.endsWith(ROUTE_SUFFIX);
+}
+function add_resolution_suffix(pathname) {
+ return pathname.replace(/\/$/, "") + ROUTE_SUFFIX;
+}
+function strip_resolution_suffix(pathname) {
+ return pathname.slice(0, -ROUTE_SUFFIX.length);
+}
+function json(data, init2) {
+ const body2 = JSON.stringify(data);
+ const headers2 = new Headers(init2?.headers);
+ if (!headers2.has("content-length")) {
+ headers2.set("content-length", encoder$3.encode(body2).byteLength.toString());
+ }
+ if (!headers2.has("content-type")) {
+ headers2.set("content-type", "application/json");
+ }
+ return new Response(body2, {
+ ...init2,
+ headers: headers2
+ });
+}
+const encoder$3 = new TextEncoder();
+function text(body2, init2) {
+ const headers2 = new Headers(init2?.headers);
+ if (!headers2.has("content-length")) {
+ const encoded = encoder$3.encode(body2);
+ headers2.set("content-length", encoded.byteLength.toString());
+ return new Response(encoded, {
+ ...init2,
+ headers: headers2
+ });
+ }
+ return new Response(body2, {
+ ...init2,
+ headers: headers2
+ });
+}
+function coalesce_to_error(err) {
+ return err instanceof Error || err && /** @type {any} */
+ err.name && /** @type {any} */
+ err.message ? (
+ /** @type {Error} */
+ err
+ ) : new Error(JSON.stringify(err));
+}
+function normalize_error(error) {
+ return (
+ /** @type {import('../runtime/control.js').Redirect | HttpError | SvelteKitError | Error} */
+ error
+ );
+}
+function get_status(error) {
+ return error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500;
+}
+function get_message(error) {
+ return error instanceof SvelteKitError ? error.text : "Internal Error";
+}
+const escape_html_attr_dict = {
+ "&": "&",
+ '"': """
+ // Svelte also escapes < because the escape function could be called inside a `noscript` there
+ // https://github.com/sveltejs/svelte/security/advisories/GHSA-8266-84wp-wv5c
+ // However, that doesn't apply in SvelteKit
+};
+const escape_html_dict = {
+ "&": "&",
+ "<": "<"
+};
+const surrogates = (
+ // high surrogate without paired low surrogate
+ "[\\ud800-\\udbff](?![\\udc00-\\udfff])|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\udc00-\\udfff]"
+);
+const escape_html_attr_regex = new RegExp(
+ `[${Object.keys(escape_html_attr_dict).join("")}]|` + surrogates,
+ "g"
+);
+const escape_html_regex = new RegExp(
+ `[${Object.keys(escape_html_dict).join("")}]|` + surrogates,
+ "g"
+);
+function escape_html(str, is_attr) {
+ const dict = is_attr ? escape_html_attr_dict : escape_html_dict;
+ const escaped_str = str.replace(is_attr ? escape_html_attr_regex : escape_html_regex, (match) => {
+ if (match.length === 2) {
+ return match;
+ }
+ return dict[match] ?? `${match.charCodeAt(0)};`;
+ });
+ return escaped_str;
+}
+function method_not_allowed(mod, method) {
+ return text(`${method} method not allowed`, {
+ status: 405,
+ headers: {
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405
+ // "The server must generate an Allow header field in a 405 status code response"
+ allow: allowed_methods(mod).join(", ")
+ }
+ });
+}
+function allowed_methods(mod) {
+ const allowed = ENDPOINT_METHODS.filter((method) => method in mod);
+ if ("GET" in mod || "HEAD" in mod) allowed.push("HEAD");
+ return allowed;
+}
+function static_error_page(options2, status, message) {
+ let page = options2.templates.error({ status, message: escape_html(message) });
+ return text(page, {
+ headers: { "content-type": "text/html; charset=utf-8" },
+ status
+ });
+}
+async function handle_fatal_error(event, options2, error) {
+ error = error instanceof HttpError ? error : coalesce_to_error(error);
+ const status = get_status(error);
+ const body2 = await handle_error_and_jsonify(event, options2, error);
+ const type = negotiate(event.request.headers.get("accept") || "text/html", [
+ "application/json",
+ "text/html"
+ ]);
+ if (event.isDataRequest || type === "application/json") {
+ return json(body2, {
+ status
+ });
+ }
+ return static_error_page(options2, status, body2.message);
+}
+async function handle_error_and_jsonify(event, options2, error) {
+ if (error instanceof HttpError) {
+ return error.body;
+ }
+ const status = get_status(error);
+ const message = get_message(error);
+ return await with_event(
+ event,
+ () => options2.hooks.handleError({ error, event, status, message })
+ ) ?? { message };
+}
+function redirect_response(status, location) {
+ const response = new Response(void 0, {
+ status,
+ headers: { location }
+ });
+ return response;
+}
+function clarify_devalue_error(event, error) {
+ if (error.path) {
+ return `Data returned from \`load\` while rendering ${event.route.id} is not serializable: ${error.message} (${error.path})`;
+ }
+ if (error.path === "") {
+ return `Data returned from \`load\` while rendering ${event.route.id} is not a plain object`;
+ }
+ return error.message;
+}
+function serialize_uses(node) {
+ const uses = {};
+ if (node.uses && node.uses.dependencies.size > 0) {
+ uses.dependencies = Array.from(node.uses.dependencies);
+ }
+ if (node.uses && node.uses.search_params.size > 0) {
+ uses.search_params = Array.from(node.uses.search_params);
+ }
+ if (node.uses && node.uses.params.size > 0) {
+ uses.params = Array.from(node.uses.params);
+ }
+ if (node.uses?.parent) uses.parent = 1;
+ if (node.uses?.route) uses.route = 1;
+ if (node.uses?.url) uses.url = 1;
+ return uses;
+}
+function has_prerendered_path(manifest, pathname) {
+ return manifest._.prerendered_routes.has(pathname) || pathname.at(-1) === "/" && manifest._.prerendered_routes.has(pathname.slice(0, -1));
+}
+async function render_endpoint(event, mod, state) {
+ const method = (
+ /** @type {import('types').HttpMethod} */
+ event.request.method
+ );
+ let handler = mod[method] || mod.fallback;
+ if (method === "HEAD" && !mod.HEAD && mod.GET) {
+ handler = mod.GET;
+ }
+ if (!handler) {
+ return method_not_allowed(mod, method);
+ }
+ const prerender = mod.prerender ?? state.prerender_default;
+ if (prerender && (mod.POST || mod.PATCH || mod.PUT || mod.DELETE)) {
+ throw new Error("Cannot prerender endpoints that have mutative methods");
+ }
+ if (state.prerendering && !state.prerendering.inside_reroute && !prerender) {
+ if (state.depth > 0) {
+ throw new Error(`${event.route.id} is not prerenderable`);
+ } else {
+ return new Response(void 0, { status: 204 });
+ }
+ }
+ try {
+ const response = await with_event(
+ event,
+ () => handler(
+ /** @type {import('@sveltejs/kit').RequestEvent>} */
+ event
+ )
+ );
+ if (!(response instanceof Response)) {
+ throw new Error(
+ `Invalid response from route ${event.url.pathname}: handler should return a Response object`
+ );
+ }
+ if (state.prerendering && (!state.prerendering.inside_reroute || prerender)) {
+ const cloned = new Response(response.clone().body, {
+ status: response.status,
+ statusText: response.statusText,
+ headers: new Headers(response.headers)
+ });
+ cloned.headers.set("x-sveltekit-prerender", String(prerender));
+ if (state.prerendering.inside_reroute && prerender) {
+ cloned.headers.set(
+ "x-sveltekit-routeid",
+ encodeURI(
+ /** @type {string} */
+ event.route.id
+ )
+ );
+ state.prerendering.dependencies.set(event.url.pathname, { response: cloned, body: null });
+ } else {
+ return cloned;
+ }
+ }
+ return response;
+ } catch (e) {
+ if (e instanceof Redirect) {
+ return new Response(void 0, {
+ status: e.status,
+ headers: { location: e.location }
+ });
+ }
+ throw e;
+ }
+}
+function is_endpoint_request(event) {
+ const { method, headers: headers2 } = event.request;
+ if (ENDPOINT_METHODS.includes(method) && !PAGE_METHODS.includes(method)) {
+ return true;
+ }
+ if (method === "POST" && headers2.get("x-sveltekit-action") === "true") return false;
+ const accept = event.request.headers.get("accept") ?? "*/*";
+ return negotiate(accept, ["*", "text/html"]) !== "text/html";
+}
+function compact(arr) {
+ return arr.filter(
+ /** @returns {val is NonNullable} */
+ (val) => val != null
+ );
+}
+function is_action_json_request(event) {
+ const accept = negotiate(event.request.headers.get("accept") ?? "*/*", [
+ "application/json",
+ "text/html"
+ ]);
+ return accept === "application/json" && event.request.method === "POST";
+}
+async function handle_action_json_request(event, options2, server) {
+ const actions = server?.actions;
+ if (!actions) {
+ const no_actions_error = new SvelteKitError(
+ 405,
+ "Method Not Allowed",
+ `POST method not allowed. No form actions exist for ${"this page"}`
+ );
+ return action_json(
+ {
+ type: "error",
+ error: await handle_error_and_jsonify(event, options2, no_actions_error)
+ },
+ {
+ status: no_actions_error.status,
+ headers: {
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405
+ // "The server must generate an Allow header field in a 405 status code response"
+ allow: "GET"
+ }
+ }
+ );
+ }
+ check_named_default_separate(actions);
+ try {
+ const data = await call_action(event, actions);
+ if (false) ;
+ if (data instanceof ActionFailure) {
+ return action_json({
+ type: "failure",
+ status: data.status,
+ // @ts-expect-error we assign a string to what is supposed to be an object. That's ok
+ // because we don't use the object outside, and this way we have better code navigation
+ // through knowing where the related interface is used.
+ data: stringify_action_response(
+ data.data,
+ /** @type {string} */
+ event.route.id,
+ options2.hooks.transport
+ )
+ });
+ } else {
+ return action_json({
+ type: "success",
+ status: data ? 200 : 204,
+ // @ts-expect-error see comment above
+ data: stringify_action_response(
+ data,
+ /** @type {string} */
+ event.route.id,
+ options2.hooks.transport
+ )
+ });
+ }
+ } catch (e) {
+ const err = normalize_error(e);
+ if (err instanceof Redirect) {
+ return action_json_redirect(err);
+ }
+ return action_json(
+ {
+ type: "error",
+ error: await handle_error_and_jsonify(event, options2, check_incorrect_fail_use(err))
+ },
+ {
+ status: get_status(err)
+ }
+ );
+ }
+}
+function check_incorrect_fail_use(error) {
+ return error instanceof ActionFailure ? new Error('Cannot "throw fail()". Use "return fail()"') : error;
+}
+function action_json_redirect(redirect) {
+ return action_json({
+ type: "redirect",
+ status: redirect.status,
+ location: redirect.location
+ });
+}
+function action_json(data, init2) {
+ return json(data, init2);
+}
+function is_action_request(event) {
+ return event.request.method === "POST";
+}
+async function handle_action_request(event, server) {
+ const actions = server?.actions;
+ if (!actions) {
+ event.setHeaders({
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405
+ // "The server must generate an Allow header field in a 405 status code response"
+ allow: "GET"
+ });
+ return {
+ type: "error",
+ error: new SvelteKitError(
+ 405,
+ "Method Not Allowed",
+ `POST method not allowed. No form actions exist for ${"this page"}`
+ )
+ };
+ }
+ check_named_default_separate(actions);
+ try {
+ const data = await call_action(event, actions);
+ if (false) ;
+ if (data instanceof ActionFailure) {
+ return {
+ type: "failure",
+ status: data.status,
+ data: data.data
+ };
+ } else {
+ return {
+ type: "success",
+ status: 200,
+ // @ts-expect-error this will be removed upon serialization, so `undefined` is the same as omission
+ data
+ };
+ }
+ } catch (e) {
+ const err = normalize_error(e);
+ if (err instanceof Redirect) {
+ return {
+ type: "redirect",
+ status: err.status,
+ location: err.location
+ };
+ }
+ return {
+ type: "error",
+ error: check_incorrect_fail_use(err)
+ };
+ }
+}
+function check_named_default_separate(actions) {
+ if (actions.default && Object.keys(actions).length > 1) {
+ throw new Error(
+ "When using named actions, the default action cannot be used. See the docs for more info: https://svelte.dev/docs/kit/form-actions#named-actions"
+ );
+ }
+}
+async function call_action(event, actions) {
+ const url = new URL(event.request.url);
+ let name = "default";
+ for (const param of url.searchParams) {
+ if (param[0].startsWith("/")) {
+ name = param[0].slice(1);
+ if (name === "default") {
+ throw new Error('Cannot use reserved action name "default"');
+ }
+ break;
+ }
+ }
+ const action = actions[name];
+ if (!action) {
+ throw new SvelteKitError(404, "Not Found", `No action with name '${name}' found`);
+ }
+ if (!is_form_content_type(event.request)) {
+ throw new SvelteKitError(
+ 415,
+ "Unsupported Media Type",
+ `Form actions expect form-encoded data — received ${event.request.headers.get(
+ "content-type"
+ )}`
+ );
+ }
+ return with_event(event, () => action(event));
+}
+function validate_action_return(data) {
+ if (data instanceof Redirect) {
+ throw new Error("Cannot `return redirect(...)` — use `redirect(...)` instead");
+ }
+ if (data instanceof HttpError) {
+ throw new Error("Cannot `return error(...)` — use `error(...)` or `return fail(...)` instead");
+ }
+}
+function uneval_action_response(data, route_id, transport) {
+ const replacer = (thing) => {
+ for (const key2 in transport) {
+ const encoded = transport[key2].encode(thing);
+ if (encoded) {
+ return `app.decode('${key2}', ${devalue.uneval(encoded, replacer)})`;
+ }
+ }
+ };
+ return try_serialize(data, (value) => devalue.uneval(value, replacer), route_id);
+}
+function stringify_action_response(data, route_id, transport) {
+ const encoders = Object.fromEntries(
+ Object.entries(transport).map(([key2, value]) => [key2, value.encode])
+ );
+ return try_serialize(data, (value) => devalue.stringify(value, encoders), route_id);
+}
+function try_serialize(data, fn, route_id) {
+ try {
+ return fn(data);
+ } catch (e) {
+ const error = (
+ /** @type {any} */
+ e
+ );
+ if (data instanceof Response) {
+ throw new Error(
+ `Data returned from action inside ${route_id} is not serializable. Form actions need to return plain objects or fail(). E.g. return { success: true } or return fail(400, { message: "invalid" });`
+ );
+ }
+ if ("path" in error) {
+ let message = `Data returned from action inside ${route_id} is not serializable: ${error.message}`;
+ if (error.path !== "") message += ` (data.${error.path})`;
+ throw new Error(message);
+ }
+ throw error;
+ }
+}
+function validate_depends(route_id, dep) {
+ const match = /^(moz-icon|view-source|jar):/.exec(dep);
+ if (match) {
+ console.warn(
+ `${route_id}: Calling \`depends('${dep}')\` will throw an error in Firefox because \`${match[1]}\` is a special URI scheme`
+ );
+ }
+}
+const INVALIDATED_PARAM = "x-sveltekit-invalidated";
+const TRAILING_SLASH_PARAM = "x-sveltekit-trailing-slash";
+function b64_encode(buffer) {
+ if (globalThis.Buffer) {
+ return Buffer.from(buffer).toString("base64");
+ }
+ const little_endian = new Uint8Array(new Uint16Array([1]).buffer)[0] > 0;
+ return btoa(
+ new TextDecoder(little_endian ? "utf-16le" : "utf-16be").decode(
+ new Uint16Array(new Uint8Array(buffer))
+ )
+ );
+}
+function get_relative_path(from, to) {
+ const from_parts = from.split(/[/\\]/);
+ const to_parts = to.split(/[/\\]/);
+ from_parts.pop();
+ while (from_parts[0] === to_parts[0]) {
+ from_parts.shift();
+ to_parts.shift();
+ }
+ let i = from_parts.length;
+ while (i--) from_parts[i] = "..";
+ return from_parts.concat(to_parts).join("/");
+}
+async function load_server_data({ event, state, node, parent }) {
+ if (!node?.server) return null;
+ let is_tracking = true;
+ const uses = {
+ dependencies: /* @__PURE__ */ new Set(),
+ params: /* @__PURE__ */ new Set(),
+ parent: false,
+ route: false,
+ url: false,
+ search_params: /* @__PURE__ */ new Set()
+ };
+ const load = node.server.load;
+ const slash = node.server.trailingSlash;
+ if (!load) {
+ return { type: "data", data: null, uses, slash };
+ }
+ const url = make_trackable(
+ event.url,
+ () => {
+ if (is_tracking) {
+ uses.url = true;
+ }
+ },
+ (param) => {
+ if (is_tracking) {
+ uses.search_params.add(param);
+ }
+ }
+ );
+ if (state.prerendering) {
+ disable_search(url);
+ }
+ let done = false;
+ const result = await with_event(
+ event,
+ () => load.call(null, {
+ ...event,
+ fetch: (info, init2) => {
+ const url2 = new URL(info instanceof Request ? info.url : info, event.url);
+ if (BROWSER && done && !uses.dependencies.has(url2.href)) ;
+ return event.fetch(info, init2);
+ },
+ /** @param {string[]} deps */
+ depends: (...deps) => {
+ for (const dep of deps) {
+ const { href } = new URL(dep, event.url);
+ if (BROWSER) ;
+ uses.dependencies.add(href);
+ }
+ },
+ params: new Proxy(event.params, {
+ get: (target, key2) => {
+ if (BROWSER && done && typeof key2 === "string" && !uses.params.has(key2)) ;
+ if (is_tracking) {
+ uses.params.add(key2);
+ }
+ return target[
+ /** @type {string} */
+ key2
+ ];
+ }
+ }),
+ parent: async () => {
+ if (BROWSER && done && !uses.parent) ;
+ if (is_tracking) {
+ uses.parent = true;
+ }
+ return parent();
+ },
+ route: new Proxy(event.route, {
+ get: (target, key2) => {
+ if (BROWSER && done && typeof key2 === "string" && !uses.route) ;
+ if (is_tracking) {
+ uses.route = true;
+ }
+ return target[
+ /** @type {'id'} */
+ key2
+ ];
+ }
+ }),
+ url,
+ untrack(fn) {
+ is_tracking = false;
+ try {
+ return fn();
+ } finally {
+ is_tracking = true;
+ }
+ }
+ })
+ );
+ done = true;
+ return {
+ type: "data",
+ data: result ?? null,
+ uses,
+ slash
+ };
+}
+async function load_data({
+ event,
+ fetched,
+ node,
+ parent,
+ server_data_promise,
+ state,
+ resolve_opts,
+ csr
+}) {
+ const server_data_node = await server_data_promise;
+ if (!node?.universal?.load) {
+ return server_data_node?.data ?? null;
+ }
+ const result = await node.universal.load.call(null, {
+ url: event.url,
+ params: event.params,
+ data: server_data_node?.data ?? null,
+ route: event.route,
+ fetch: create_universal_fetch(event, state, fetched, csr, resolve_opts),
+ setHeaders: event.setHeaders,
+ depends: () => {
+ },
+ parent,
+ untrack: (fn) => fn()
+ });
+ return result ?? null;
+}
+function create_universal_fetch(event, state, fetched, csr, resolve_opts) {
+ const universal_fetch = async (input, init2) => {
+ const cloned_body = input instanceof Request && input.body ? input.clone().body : null;
+ const cloned_headers = input instanceof Request && [...input.headers].length ? new Headers(input.headers) : init2?.headers;
+ let response = await event.fetch(input, init2);
+ const url = new URL(input instanceof Request ? input.url : input, event.url);
+ const same_origin = url.origin === event.url.origin;
+ let dependency;
+ if (same_origin) {
+ if (state.prerendering) {
+ dependency = { response, body: null };
+ state.prerendering.dependencies.set(url.pathname, dependency);
+ }
+ } else if (url.protocol === "https:" || url.protocol === "http:") {
+ const mode = input instanceof Request ? input.mode : init2?.mode ?? "cors";
+ if (mode === "no-cors") {
+ response = new Response("", {
+ status: response.status,
+ statusText: response.statusText,
+ headers: response.headers
+ });
+ } else {
+ const acao = response.headers.get("access-control-allow-origin");
+ if (!acao || acao !== event.url.origin && acao !== "*") {
+ throw new Error(
+ `CORS error: ${acao ? "Incorrect" : "No"} 'Access-Control-Allow-Origin' header is present on the requested resource`
+ );
+ }
+ }
+ }
+ const proxy = new Proxy(response, {
+ get(response2, key2, _receiver) {
+ async function push_fetched(body2, is_b64) {
+ const status_number = Number(response2.status);
+ if (isNaN(status_number)) {
+ throw new Error(
+ `response.status is not a number. value: "${response2.status}" type: ${typeof response2.status}`
+ );
+ }
+ fetched.push({
+ url: same_origin ? url.href.slice(event.url.origin.length) : url.href,
+ method: event.request.method,
+ request_body: (
+ /** @type {string | ArrayBufferView | undefined} */
+ input instanceof Request && cloned_body ? await stream_to_string(cloned_body) : init2?.body
+ ),
+ request_headers: cloned_headers,
+ response_body: body2,
+ response: response2,
+ is_b64
+ });
+ }
+ if (key2 === "arrayBuffer") {
+ return async () => {
+ const buffer = await response2.arrayBuffer();
+ if (dependency) {
+ dependency.body = new Uint8Array(buffer);
+ }
+ if (buffer instanceof ArrayBuffer) {
+ await push_fetched(b64_encode(buffer), true);
+ }
+ return buffer;
+ };
+ }
+ async function text2() {
+ const body2 = await response2.text();
+ if (!body2 || typeof body2 === "string") {
+ await push_fetched(body2, false);
+ }
+ if (dependency) {
+ dependency.body = body2;
+ }
+ return body2;
+ }
+ if (key2 === "text") {
+ return text2;
+ }
+ if (key2 === "json") {
+ return async () => {
+ return JSON.parse(await text2());
+ };
+ }
+ return Reflect.get(response2, key2, response2);
+ }
+ });
+ if (csr) {
+ const get = response.headers.get;
+ response.headers.get = (key2) => {
+ const lower = key2.toLowerCase();
+ const value = get.call(response.headers, lower);
+ if (value && !lower.startsWith("x-sveltekit-")) {
+ const included = resolve_opts.filterSerializedResponseHeaders(lower, value);
+ if (!included) {
+ throw new Error(
+ `Failed to get response header "${lower}" — it must be included by the \`filterSerializedResponseHeaders\` option: https://svelte.dev/docs/kit/hooks#Server-hooks-handle (at ${event.route.id})`
+ );
+ }
+ }
+ return value;
+ };
+ }
+ return proxy;
+ };
+ return (input, init2) => {
+ const response = universal_fetch(input, init2);
+ response.catch(() => {
+ });
+ return response;
+ };
+}
+async function stream_to_string(stream) {
+ let result = "";
+ const reader = stream.getReader();
+ const decoder = new TextDecoder();
+ while (true) {
+ const { done, value } = await reader.read();
+ if (done) {
+ break;
+ }
+ result += decoder.decode(value);
+ }
+ return result;
+}
+function hash(...values) {
+ let hash2 = 5381;
+ for (const value of values) {
+ if (typeof value === "string") {
+ let i = value.length;
+ while (i) hash2 = hash2 * 33 ^ value.charCodeAt(--i);
+ } else if (ArrayBuffer.isView(value)) {
+ const buffer = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
+ let i = buffer.length;
+ while (i) hash2 = hash2 * 33 ^ buffer[--i];
+ } else {
+ throw new TypeError("value must be a string or TypedArray");
+ }
+ }
+ return (hash2 >>> 0).toString(36);
+}
+const replacements = {
+ "<": "\\u003C",
+ "\u2028": "\\u2028",
+ "\u2029": "\\u2029"
+};
+const pattern = new RegExp(`[${Object.keys(replacements).join("")}]`, "g");
+function serialize_data(fetched, filter, prerendering2 = false) {
+ const headers2 = {};
+ let cache_control = null;
+ let age = null;
+ let varyAny = false;
+ for (const [key2, value] of fetched.response.headers) {
+ if (filter(key2, value)) {
+ headers2[key2] = value;
+ }
+ if (key2 === "cache-control") cache_control = value;
+ else if (key2 === "age") age = value;
+ else if (key2 === "vary" && value.trim() === "*") varyAny = true;
+ }
+ const payload = {
+ status: fetched.response.status,
+ statusText: fetched.response.statusText,
+ headers: headers2,
+ body: fetched.response_body
+ };
+ const safe_payload = JSON.stringify(payload).replace(pattern, (match) => replacements[match]);
+ const attrs = [
+ 'type="application/json"',
+ "data-sveltekit-fetched",
+ `data-url="${escape_html(fetched.url, true)}"`
+ ];
+ if (fetched.is_b64) {
+ attrs.push("data-b64");
+ }
+ if (fetched.request_headers || fetched.request_body) {
+ const values = [];
+ if (fetched.request_headers) {
+ values.push([...new Headers(fetched.request_headers)].join(","));
+ }
+ if (fetched.request_body) {
+ values.push(fetched.request_body);
+ }
+ attrs.push(`data-hash="${hash(...values)}"`);
+ }
+ if (!prerendering2 && fetched.method === "GET" && cache_control && !varyAny) {
+ const match = /s-maxage=(\d+)/g.exec(cache_control) ?? /max-age=(\d+)/g.exec(cache_control);
+ if (match) {
+ const ttl = +match[1] - +(age ?? "0");
+ attrs.push(`data-ttl="${ttl}"`);
+ }
+ }
+ return `
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
+
+
+
+
diff --git a/package-lock.json b/package-lock.json
index 8d5ae1c..4e6360a 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -8,13 +8,13 @@
"name": "passdb-frontend",
"version": "2.0.0",
"dependencies": {
+ "@sveltejs/adapter-static": "^3.0.8",
+ "@sveltejs/kit": "^2.22.0",
"@tanstack/table-core": "^8.21.3",
"@types/mousetrap": "^1.6.15",
- "@types/page": "^1.11.9",
"clsx": "^2.1.1",
"lucide-svelte": "^0.517.0",
"mousetrap": "^1.6.5",
- "page": "^1.11.6",
"shadcn-svelte": "^1.0.3",
"tailwind-merge": "^3.3.1"
},
@@ -244,7 +244,6 @@
"cpu": [
"ppc64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -261,7 +260,6 @@
"cpu": [
"arm"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -278,7 +276,6 @@
"cpu": [
"arm64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -295,7 +292,6 @@
"cpu": [
"x64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -312,7 +308,6 @@
"cpu": [
"arm64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -329,7 +324,6 @@
"cpu": [
"x64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -346,7 +340,6 @@
"cpu": [
"arm64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -363,7 +356,6 @@
"cpu": [
"x64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -380,7 +372,6 @@
"cpu": [
"arm"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -397,7 +388,6 @@
"cpu": [
"arm64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -414,7 +404,6 @@
"cpu": [
"ia32"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -431,7 +420,6 @@
"cpu": [
"loong64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -448,7 +436,6 @@
"cpu": [
"mips64el"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -465,7 +452,6 @@
"cpu": [
"ppc64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -482,7 +468,6 @@
"cpu": [
"riscv64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -499,7 +484,6 @@
"cpu": [
"s390x"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -516,7 +500,6 @@
"cpu": [
"x64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -533,7 +516,6 @@
"cpu": [
"arm64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -550,7 +532,6 @@
"cpu": [
"x64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -567,7 +548,6 @@
"cpu": [
"arm64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -584,7 +564,6 @@
"cpu": [
"x64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -601,7 +580,6 @@
"cpu": [
"x64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -618,7 +596,6 @@
"cpu": [
"arm64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -635,7 +612,6 @@
"cpu": [
"ia32"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -652,7 +628,6 @@
"cpu": [
"x64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -971,7 +946,6 @@
"version": "0.3.6",
"resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.6.tgz",
"integrity": "sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ==",
- "dev": true,
"license": "MIT",
"optional": true,
"peer": true,
@@ -1058,7 +1032,6 @@
"version": "1.0.0-next.29",
"resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.29.tgz",
"integrity": "sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww==",
- "dev": true,
"license": "MIT"
},
"node_modules/@rollup/rollup-android-arm-eabi": {
@@ -1068,7 +1041,6 @@
"cpu": [
"arm"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1082,7 +1054,6 @@
"cpu": [
"arm64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1096,7 +1067,6 @@
"cpu": [
"arm64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1110,7 +1080,6 @@
"cpu": [
"x64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1124,7 +1093,6 @@
"cpu": [
"arm64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1138,7 +1106,6 @@
"cpu": [
"x64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1152,7 +1119,6 @@
"cpu": [
"arm"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1166,7 +1132,6 @@
"cpu": [
"arm"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1180,7 +1145,6 @@
"cpu": [
"arm64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1194,7 +1158,6 @@
"cpu": [
"arm64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1208,7 +1171,6 @@
"cpu": [
"loong64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1222,7 +1184,6 @@
"cpu": [
"ppc64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1236,7 +1197,6 @@
"cpu": [
"riscv64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1250,7 +1210,6 @@
"cpu": [
"riscv64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1264,7 +1223,6 @@
"cpu": [
"s390x"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1278,7 +1236,6 @@
"cpu": [
"x64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1292,7 +1249,6 @@
"cpu": [
"x64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1306,7 +1262,6 @@
"cpu": [
"arm64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1320,7 +1275,6 @@
"cpu": [
"ia32"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1334,7 +1288,6 @@
"cpu": [
"x64"
],
- "dev": true,
"license": "MIT",
"optional": true,
"os": [
@@ -1350,11 +1303,51 @@
"acorn": "^8.9.0"
}
},
+ "node_modules/@sveltejs/adapter-static": {
+ "version": "3.0.8",
+ "resolved": "https://registry.npmjs.org/@sveltejs/adapter-static/-/adapter-static-3.0.8.tgz",
+ "integrity": "sha512-YaDrquRpZwfcXbnlDsSrBQNCChVOT9MGuSg+dMAyfsAa1SmiAhrA5jUYUiIMC59G92kIbY/AaQOWcBdq+lh+zg==",
+ "license": "MIT",
+ "peerDependencies": {
+ "@sveltejs/kit": "^2.0.0"
+ }
+ },
+ "node_modules/@sveltejs/kit": {
+ "version": "2.22.0",
+ "resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-2.22.0.tgz",
+ "integrity": "sha512-DJm0UxVgzXq+1MUfiJK4Ridk7oIQsIets6JwHiEl97sI6nXScfXe+BeqNhzB7jQIVBb3BM51U4hNk8qQxRXBAA==",
+ "license": "MIT",
+ "dependencies": {
+ "@sveltejs/acorn-typescript": "^1.0.5",
+ "@types/cookie": "^0.6.0",
+ "acorn": "^8.14.1",
+ "cookie": "^0.6.0",
+ "devalue": "^5.1.0",
+ "esm-env": "^1.2.2",
+ "kleur": "^4.1.5",
+ "magic-string": "^0.30.5",
+ "mrmime": "^2.0.0",
+ "sade": "^1.8.1",
+ "set-cookie-parser": "^2.6.0",
+ "sirv": "^3.0.0",
+ "vitefu": "^1.0.6"
+ },
+ "bin": {
+ "svelte-kit": "svelte-kit.js"
+ },
+ "engines": {
+ "node": ">=18.13"
+ },
+ "peerDependencies": {
+ "@sveltejs/vite-plugin-svelte": "^3.0.0 || ^4.0.0-next.1 || ^5.0.0 || ^6.0.0-next.0",
+ "svelte": "^4.0.0 || ^5.0.0-next.0",
+ "vite": "^5.0.3 || ^6.0.0 || ^7.0.0-beta.0"
+ }
+ },
"node_modules/@sveltejs/vite-plugin-svelte": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-5.1.0.tgz",
"integrity": "sha512-wojIS/7GYnJDYIg1higWj2ROA6sSRWvcR1PO/bqEyFr/5UZah26c8Cz4u0NaqjPeVltzsVpt2Tm8d2io0V+4Tw==",
- "dev": true,
"license": "MIT",
"dependencies": {
"@sveltejs/vite-plugin-svelte-inspector": "^4.0.1",
@@ -1376,7 +1369,6 @@
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte-inspector/-/vite-plugin-svelte-inspector-4.0.1.tgz",
"integrity": "sha512-J/Nmb2Q2y7mck2hyCX4ckVHcR5tu2J+MtBEQqpDrrgELZ2uvraQcK/ioCV61AqkdXFgriksOKIceDcQmqnGhVw==",
- "dev": true,
"license": "MIT",
"dependencies": {
"debug": "^4.3.7"
@@ -1390,16 +1382,6 @@
"vite": "^6.0.0"
}
},
- "node_modules/@sveltejs/vite-plugin-svelte/node_modules/kleur": {
- "version": "4.1.5",
- "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz",
- "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==",
- "dev": true,
- "license": "MIT",
- "engines": {
- "node": ">=6"
- }
- },
"node_modules/@swc/helpers": {
"version": "0.5.17",
"resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.17.tgz",
@@ -1533,6 +1515,12 @@
"@types/deep-eql": "*"
}
},
+ "node_modules/@types/cookie": {
+ "version": "0.6.0",
+ "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.6.0.tgz",
+ "integrity": "sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==",
+ "license": "MIT"
+ },
"node_modules/@types/deep-eql": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz",
@@ -1563,18 +1551,12 @@
"version": "24.0.3",
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.0.3.tgz",
"integrity": "sha512-R4I/kzCYAdRLzfiCabn9hxWfbuHS573x+r0dJMkkzThEa7pbrcDWK+9zu3e7aBOouf+rQAciqPFMnxwr0aWgKg==",
- "dev": true,
+ "devOptional": true,
"license": "MIT",
"dependencies": {
"undici-types": "~7.8.0"
}
},
- "node_modules/@types/page": {
- "version": "1.11.9",
- "resolved": "https://registry.npmjs.org/@types/page/-/page-1.11.9.tgz",
- "integrity": "sha512-Ki8IZMwg63i7+tF3UpfDIl4rwBN1B1kWQjZCUzaWoohfMB0m9CYap/dExbz7W21uS2WPoA/8lvlDuwX0X/YfIQ==",
- "license": "MIT"
- },
"node_modules/@typescript-eslint/eslint-plugin": {
"version": "8.34.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.34.1.tgz",
@@ -2287,7 +2269,6 @@
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
- "dev": true,
"license": "MIT",
"optional": true,
"peer": true
@@ -2486,7 +2467,6 @@
"version": "2.20.3",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
- "dev": true,
"optional": true,
"peer": true
},
@@ -2496,6 +2476,15 @@
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
},
+ "node_modules/cookie": {
+ "version": "0.6.0",
+ "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz",
+ "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
"node_modules/cross-spawn": {
"version": "7.0.6",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
@@ -2563,7 +2552,6 @@
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz",
"integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==",
- "dev": true,
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
@@ -2638,7 +2626,6 @@
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz",
"integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
@@ -2684,7 +2671,6 @@
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.4.tgz",
"integrity": "sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA==",
- "dev": true,
"license": "Apache-2.0",
"optional": true,
"peer": true,
@@ -2692,6 +2678,12 @@
"node": ">=8"
}
},
+ "node_modules/devalue": {
+ "version": "5.1.1",
+ "resolved": "https://registry.npmjs.org/devalue/-/devalue-5.1.1.tgz",
+ "integrity": "sha512-maua5KUiapvEwiEAe+XnlZ3Rh0GD+qI1J/nb9vrJc3muPXvcF/8gXYTWF76+5DAqHyDUtOIImEuo0YKE9mshVw==",
+ "license": "MIT"
+ },
"node_modules/didyoumean": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz",
@@ -2827,7 +2819,6 @@
"version": "0.25.5",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.5.tgz",
"integrity": "sha512-P8OtKZRv/5J5hhz0cUAdu/cLuPIKXpQl1R9pZtvmHWQvrAUVd0UNIPT4IB4W3rNOqVO0rlqHmCIbSwxh/c9yUQ==",
- "dev": true,
"hasInstallScript": true,
"license": "MIT",
"bin": {
@@ -3359,7 +3350,6 @@
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
- "dev": true,
"hasInstallScript": true,
"license": "MIT",
"optional": true,
@@ -4066,7 +4056,6 @@
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/jiti/-/jiti-2.4.2.tgz",
"integrity": "sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==",
- "dev": true,
"license": "MIT",
"optional": true,
"peer": true,
@@ -4165,6 +4154,15 @@
"json-buffer": "3.0.1"
}
},
+ "node_modules/kleur": {
+ "version": "4.1.5",
+ "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz",
+ "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/known-css-properties": {
"version": "0.36.0",
"resolved": "https://registry.npmjs.org/known-css-properties/-/known-css-properties-0.36.0.tgz",
@@ -4190,7 +4188,6 @@
"version": "1.30.1",
"resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.30.1.tgz",
"integrity": "sha512-xi6IyHML+c9+Q3W0S4fCQJOym42pyurFiJUHEcEyHS0CeKzia4yZDEsLlqOFykxOdHpNy0NmvVO31vcSqAxJCg==",
- "dev": true,
"license": "MPL-2.0",
"optional": true,
"peer": true,
@@ -4224,7 +4221,6 @@
"cpu": [
"arm64"
],
- "dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -4246,7 +4242,6 @@
"cpu": [
"x64"
],
- "dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -4268,7 +4263,6 @@
"cpu": [
"x64"
],
- "dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -4290,7 +4284,6 @@
"cpu": [
"arm"
],
- "dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -4312,7 +4305,6 @@
"cpu": [
"arm64"
],
- "dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -4334,7 +4326,6 @@
"cpu": [
"arm64"
],
- "dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -4356,7 +4347,6 @@
"cpu": [
"x64"
],
- "dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -4378,7 +4368,6 @@
"cpu": [
"x64"
],
- "dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -4400,7 +4389,6 @@
"cpu": [
"arm64"
],
- "dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -4422,7 +4410,6 @@
"cpu": [
"x64"
],
- "dev": true,
"license": "MPL-2.0",
"optional": true,
"os": [
@@ -4605,7 +4592,6 @@
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/mri/-/mri-1.1.4.tgz",
"integrity": "sha512-6y7IjGPm8AzlvoUrwAaw1tLnUBudaS3752vcd8JtrpGGQn+rXIe63LFVHm/YMwtqAuh+LJPCFdlLYPWM1nYn6w==",
- "dev": true,
"engines": {
"node": ">=4"
}
@@ -4614,7 +4600,6 @@
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.1.tgz",
"integrity": "sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ==",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=10"
@@ -4624,7 +4609,6 @@
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
- "dev": true,
"license": "MIT"
},
"node_modules/mz": {
@@ -4842,15 +4826,6 @@
"dev": true,
"license": "BlueOak-1.0.0"
},
- "node_modules/page": {
- "version": "1.11.6",
- "resolved": "https://registry.npmjs.org/page/-/page-1.11.6.tgz",
- "integrity": "sha512-P6e2JfzkBrPeFCIPplLP7vDDiU84RUUZMrWdsH4ZBGJ8OosnwFkcUkBHp1DTIjuipLliw9yQn/ZJsXZvarsO+g==",
- "license": "MIT",
- "dependencies": {
- "path-to-regexp": "~1.2.1"
- }
- },
"node_modules/parent-module": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
@@ -4921,21 +4896,6 @@
"url": "https://github.com/sponsors/isaacs"
}
},
- "node_modules/path-to-regexp": {
- "version": "1.2.1",
- "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.2.1.tgz",
- "integrity": "sha512-DBw9IhWfevR2zCVwEZURTuQNseCvu/Q9f5ZgqMCK0Rh61bDa4uyjPAOy9b55yKiPT59zZn+7uYKxmWwsguInwg==",
- "license": "MIT",
- "dependencies": {
- "isarray": "0.0.1"
- }
- },
- "node_modules/path-to-regexp/node_modules/isarray": {
- "version": "0.0.1",
- "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
- "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==",
- "license": "MIT"
- },
"node_modules/pathe": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz",
@@ -5464,7 +5424,6 @@
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz",
"integrity": "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==",
- "dev": true,
"license": "MIT",
"dependencies": {
"mri": "^1.1.0"
@@ -5524,6 +5483,12 @@
"node": ">=10"
}
},
+ "node_modules/set-cookie-parser": {
+ "version": "2.7.1",
+ "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.1.tgz",
+ "integrity": "sha512-IOc8uWeOZgnb3ptbCURJWNjWUPcO3ZnTTdzsurqERrP6nPyv+paC55vJM0LpOlT2ne+Ix+9+CRG1MNLlyZ4GjQ==",
+ "license": "MIT"
+ },
"node_modules/set-function-length": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz",
@@ -5704,7 +5669,6 @@
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/sirv/-/sirv-3.0.1.tgz",
"integrity": "sha512-FoqMu0NCGBLCcAkS1qA+XJIQTR6/JHfQXl+uGteNCQ76T91DMUjPa9xfmeqMY3z80nLSg9yQmNjK0Px6RWsH/A==",
- "dev": true,
"license": "MIT",
"dependencies": {
"@polka/url": "^1.0.0-next.24",
@@ -5719,7 +5683,6 @@
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
- "dev": true,
"license": "BSD-3-Clause",
"optional": true,
"peer": true,
@@ -5740,7 +5703,6 @@
"version": "0.5.21",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz",
"integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
- "dev": true,
"license": "MIT",
"optional": true,
"peer": true,
@@ -6358,7 +6320,6 @@
"version": "5.43.0",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.43.0.tgz",
"integrity": "sha512-CqNNxKSGKSZCunSvwKLTs8u8sGGlp27sxNZ4quGh0QeNuyHM0JSEM/clM9Mf4zUp6J+tO2gUXhgXT2YMMkwfKQ==",
- "dev": true,
"license": "BSD-2-Clause",
"optional": true,
"peer": true,
@@ -6416,7 +6377,6 @@
"version": "0.2.14",
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.14.tgz",
"integrity": "sha512-tX5e7OM1HnYr2+a2C/4V0htOcSQcoSTH9KgJnVvNm5zm/cyEWKJ7j7YutsH9CxMdtOkkLFy2AHrMci9IM8IPZQ==",
- "dev": true,
"license": "MIT",
"dependencies": {
"fdir": "^6.4.4",
@@ -6433,7 +6393,6 @@
"version": "6.4.6",
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.6.tgz",
"integrity": "sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w==",
- "dev": true,
"license": "MIT",
"peerDependencies": {
"picomatch": "^3 || ^4"
@@ -6448,7 +6407,6 @@
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz",
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=12"
@@ -6524,7 +6482,6 @@
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz",
"integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
@@ -6614,7 +6571,7 @@
"version": "7.8.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.8.0.tgz",
"integrity": "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw==",
- "dev": true,
+ "devOptional": true,
"license": "MIT"
},
"node_modules/update-browserslist-db": {
@@ -6687,7 +6644,6 @@
"version": "6.3.5",
"resolved": "https://registry.npmjs.org/vite/-/vite-6.3.5.tgz",
"integrity": "sha512-cZn6NDFE7wdTpINgs++ZJ4N49W2vRp8LCKrn3Ob1kYNtOo21vfDoaV5GzBfLU4MovSAB8uNRm4jgzVQZ+mBzPQ==",
- "dev": true,
"license": "MIT",
"dependencies": {
"esbuild": "^0.25.0",
@@ -6785,14 +6741,12 @@
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.7.tgz",
"integrity": "sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==",
- "dev": true,
"license": "MIT"
},
"node_modules/vite/node_modules/fdir": {
"version": "6.4.6",
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.6.tgz",
"integrity": "sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w==",
- "dev": true,
"license": "MIT",
"peerDependencies": {
"picomatch": "^3 || ^4"
@@ -6807,7 +6761,6 @@
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz",
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=12"
@@ -6820,7 +6773,6 @@
"version": "4.43.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.43.0.tgz",
"integrity": "sha512-wdN2Kd3Twh8MAEOEJZsuxuLKCsBEo4PVNLK6tQWAn10VhsVewQLzcucMgLolRlhFybGxfclbPeEYBaP6RvUFGg==",
- "dev": true,
"license": "MIT",
"dependencies": {
"@types/estree": "1.0.7"
@@ -6860,7 +6812,6 @@
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/vitefu/-/vitefu-1.0.6.tgz",
"integrity": "sha512-+Rex1GlappUyNN6UfwbVZne/9cYC4+R2XDk9xkNXBKMw6HQagdX9PgZ8V2v1WUSK1wfBLp7qbI1+XSNIlB1xmA==",
- "dev": true,
"license": "MIT",
"workspaces": [
"tests/deps/*",
@@ -7253,7 +7204,7 @@
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.0.tgz",
"integrity": "sha512-4lLa/EcQCB0cJkyts+FpIRx5G/llPxfP6VQU5KByHEhLxY3IJCH0f0Hy1MHI8sClTvsIb8qwRJ6R/ZdlDJ/leQ==",
- "dev": true,
+ "devOptional": true,
"license": "ISC",
"bin": {
"yaml": "bin.mjs"
diff --git a/package.json b/package.json
index 0b99bcf..c80aa08 100644
--- a/package.json
+++ b/package.json
@@ -3,10 +3,11 @@
"version": "2.0.0",
"type": "module",
"scripts": {
- "dev": "vite",
+ "dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
- "check": "svelte-check --tsconfig ./tsconfig.json",
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "eslint . --ext .js,.ts,.svelte",
"format": "prettier --write .",
"test": "vitest",
@@ -42,13 +43,13 @@
"vitest": "^3.2.0"
},
"dependencies": {
+ "@sveltejs/adapter-static": "^3.0.8",
+ "@sveltejs/kit": "^2.22.0",
"@tanstack/table-core": "^8.21.3",
"@types/mousetrap": "^1.6.15",
- "@types/page": "^1.11.9",
"clsx": "^2.1.1",
"lucide-svelte": "^0.517.0",
"mousetrap": "^1.6.5",
- "page": "^1.11.6",
"shadcn-svelte": "^1.0.3",
"tailwind-merge": "^3.3.1"
}
diff --git a/src/app.d.ts b/src/app.d.ts
index 61b9712..c7c0ed1 100644
--- a/src/app.d.ts
+++ b/src/app.d.ts
@@ -1,4 +1,13 @@
-///
-///
+// See https://kit.svelte.dev/docs/types#app
+// for information about these interfaces
+declare global {
+ namespace App {
+ // interface Error {}
+ // interface Locals {}
+ // interface PageData {}
+ // interface PageState {}
+ // interface Platform {}
+ }
+}
export {};
diff --git a/index.html b/src/app.html
similarity index 66%
rename from index.html
rename to src/app.html
index 3c3722c..fe2ded4 100644
--- a/index.html
+++ b/src/app.html
@@ -1,16 +1,16 @@
-
+
-
+
PassDB
+ %sveltekit.head%
-
-
-
+
+ %sveltekit.body%
diff --git a/src/components/Breadcrumbs.svelte b/src/components/Breadcrumbs.svelte
index 1d92ec6..a4316ab 100644
--- a/src/components/Breadcrumbs.svelte
+++ b/src/components/Breadcrumbs.svelte
@@ -1,12 +1,12 @@
- {#await apiGet(endpoint)}
+ {#if loading}
- {:then results}
- {#if results.length === 0}
-
-
-
-
-
-
No results found
-
- Try adjusting your search terms
-
-
-
- {:else}
-
- {/if}
- {:catch error}
+ {:else if error}
- {/await}
+ {:else if isSuccess && results}
+ {#if results.length === 0}
+
+
+
+
+
+
No results found
+
+ Try adjusting your search terms
+
+
+
+ {:else}
+
+ {/if}
+ {/if}
diff --git a/src/components/HIBP.svelte b/src/components/HIBP.svelte
index 8c19854..e19b3fe 100644
--- a/src/components/HIBP.svelte
+++ b/src/components/HIBP.svelte
@@ -2,25 +2,51 @@
import type { BreachInfo } from '../types/api';
import LoadingStates from './LoadingStates.svelte';
import { sanitizeHtml } from '../lib/sanitize';
+ import { useAPI } from '../composables/useFetch.svelte';
export let email: string;
- let apiServer = localStorage.getItem('host');
-
- async function fetchBreaches(email: string): Promise {
- const res = await fetch(`${apiServer}/breaches/${email}`);
- if (!res.ok) {
- throw new Error(`HTTP error! status: ${res.status}`);
- }
- return await res.json();
- }
+ // Use modern fetch composable for breach data
+ const { data: results, loading, error, isSuccess } = useAPI(`/breaches/${email}`);
-{#await fetchBreaches(email)}
+{#if loading}
-{:then results}
+{:else if error}
+
+
+
+
+
+
+ Unable to check breaches
+
+
+ {error.message}
+
+
+
+
+
+{:else if isSuccess && results}
{#if results.length > 0}
@@ -125,36 +151,4 @@
{/if}
-{:catch error}
-
-
-
-
-
-
- Unable to check breaches
-
-
- {error.message}
-
-
-
-
-
-{/await}
+{/if}
diff --git a/src/components/Navbar.svelte b/src/components/Navbar.svelte
index 3076198..675b840 100644
--- a/src/components/Navbar.svelte
+++ b/src/components/Navbar.svelte
@@ -1,9 +1,10 @@
{#if type === 'username'}
- {#if showEmailLink && !$currentRoute.match('/email/') && username && username !== '-' && domain && domain !== '-'}
+ {#if showEmailLink && !$page.route.id?.includes('/email/') && username && username !== '-' && domain && domain !== '-'}
- {:else if showEmailLink && !$currentRoute.match('/email/')}
+ {:else if showEmailLink && !$page.route.id?.includes('/email/')}
{/if}
{#if username && username !== '-'}
diff --git a/src/composables/useFetch.svelte.ts b/src/composables/useFetch.svelte.ts
index f85db0b..0a7d89e 100644
--- a/src/composables/useFetch.svelte.ts
+++ b/src/composables/useFetch.svelte.ts
@@ -105,11 +105,12 @@ export function useFetch
(
// Specialized hooks for common patterns
export function useAPI(endpoint: string, options?: FetchOptions) {
- const baseUrl = typeof window !== 'undefined'
- ? (window as any).__API_BASE_URL__ || 'http://localhost:4567'
+ // Reactive base URL that updates when localStorage changes
+ const getBaseUrl = () => typeof window !== 'undefined'
+ ? localStorage.getItem('host') || 'http://localhost:4567'
: 'http://localhost:4567';
-
- return useFetch(`${baseUrl}${endpoint}`, options);
+
+ return useFetch(() => `${getBaseUrl()}${endpoint}`, options);
}
export function useSearch(
diff --git a/src/lib/keyboard-shortcuts.ts b/src/lib/keyboard-shortcuts.ts
index b94db2c..a4e09b8 100644
--- a/src/lib/keyboard-shortcuts.ts
+++ b/src/lib/keyboard-shortcuts.ts
@@ -1,5 +1,5 @@
import Mousetrap from 'mousetrap';
-import { navigate } from '../router';
+import { goto } from '$app/navigation';
import { theme, themes, isDarkMode } from '../stores/theme';
import { breadcrumbs } from '../stores/breadcrumbs';
import { get } from 'svelte/store';
@@ -26,7 +26,10 @@ export class KeyboardShortcutManager {
private onHideHelp?: () => void;
constructor() {
- this.setupGlobalShortcuts();
+ // Only setup shortcuts in browser environment
+ if (typeof window !== 'undefined') {
+ this.setupGlobalShortcuts();
+ }
}
private setupGlobalShortcuts() {
@@ -41,7 +44,7 @@ export class KeyboardShortcutManager {
}, 'global');
this.bind('g h', 'Go to home page', () => {
- navigate('/');
+ goto('/');
}, 'global');
this.bind('ctrl+o', 'Navigate back through breadcrumbs', () => {
@@ -112,12 +115,15 @@ export class KeyboardShortcutManager {
private bind(key: string, description: string, action: () => void, context: ShortcutContext = 'global') {
const shortcut: KeyboardShortcut = { key, description, action, context };
this.shortcuts.set(key, shortcut);
-
- Mousetrap.bind(key, (e) => {
- e.preventDefault();
- action();
- return false;
- });
+
+ // Only bind if we're in the browser environment
+ if (typeof window !== 'undefined' && Mousetrap) {
+ Mousetrap.bind(key, (e) => {
+ e.preventDefault();
+ action();
+ return false;
+ });
+ }
}
private unbind(key: string) {
@@ -381,11 +387,20 @@ export class KeyboardShortcutManager {
return groups.filter(group => group.shortcuts.length > 0);
}
+ // Initialize shortcuts when in browser (called from components)
+ init() {
+ if (typeof window !== 'undefined' && this.shortcuts.size === 0) {
+ this.setupGlobalShortcuts();
+ }
+ }
+
destroy() {
- // Unbind all shortcuts
- this.shortcuts.forEach((_, key) => {
- Mousetrap.unbind(key);
- });
+ // Only unbind if we're in the browser and Mousetrap is available
+ if (typeof window !== 'undefined' && Mousetrap) {
+ this.shortcuts.forEach((_, key) => {
+ Mousetrap.unbind(key);
+ });
+ }
this.shortcuts.clear();
}
}
diff --git a/src/main.ts b/src/main.ts
deleted file mode 100644
index d40f73a..0000000
--- a/src/main.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import './index.css';
-import App from './App.svelte';
-import { mount } from 'svelte';
-
-const target = document.getElementById('app');
-if (!target) {
- throw new Error('Target element #app not found');
-}
-
-const app = mount(App, {
- target,
-});
-
-export default app;
diff --git a/src/router.ts b/src/router.ts
deleted file mode 100644
index 8e33d05..0000000
--- a/src/router.ts
+++ /dev/null
@@ -1,67 +0,0 @@
-import router from 'page';
-import { writable } from 'svelte/store';
-import type { RouteParams } from './types/api';
-
-export const currentRoute = writable('');
-export const routeParams = writable({});
-
-let currentComponent: any = null;
-
-export const component = writable(null);
-
-export function setupRouter() {
- router('/', () => {
- currentRoute.set('/');
- routeParams.set({});
- loadComponent(() => import('./routes/Home.svelte'));
- });
-
- router('/email/:email', (ctx) => {
- currentRoute.set(ctx.path);
- routeParams.set({ email: ctx.params.email });
- loadComponent(() => import('./routes/SearchRoute.svelte'));
- });
-
- router('/domain/:domain', (ctx) => {
- currentRoute.set(ctx.path);
- routeParams.set({ domain: ctx.params.domain });
- loadComponent(() => import('./routes/SearchRoute.svelte'));
- });
-
- router('/password/:password', (ctx) => {
- currentRoute.set(ctx.path);
- routeParams.set({ password: ctx.params.password });
- loadComponent(() => import('./routes/SearchRoute.svelte'));
- });
-
- router('/username/:name', (ctx) => {
- currentRoute.set(ctx.path);
- routeParams.set({ name: ctx.params.name });
- loadComponent(() => import('./routes/SearchRoute.svelte'));
- });
-
- router('*', () => {
- currentRoute.set('*');
- routeParams.set({});
- loadComponent(() => import('./routes/NotFound.svelte'));
- });
-
- router.start();
-}
-
-async function loadComponent(componentLoader: () => Promise) {
- try {
- const module = await componentLoader();
- currentComponent = module.default;
- component.set(currentComponent);
- } catch (error) {
- console.error('Failed to load component:', error);
- component.set(null);
- }
-}
-
-export function navigate(path: string) {
- router(path);
-}
-
-export { router };
diff --git a/src/App.svelte b/src/routes/+layout.svelte
similarity index 57%
rename from src/App.svelte
rename to src/routes/+layout.svelte
index 011a077..faf5bdc 100644
--- a/src/App.svelte
+++ b/src/routes/+layout.svelte
@@ -1,18 +1,18 @@
-
-
-
-
-
404
-
Page not found
-
- Sorry, we couldn't find the page you're looking for.
-
-
-
-
-
navigate('/')}
- class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-primary-foreground bg-primary hover:bg-secondary hover:text-secondary-foreground focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-ring transition-colors"
- >
-
-
-
- Go back home
-
-
-
-
-
Need help? Check the search instructions on the home page.
-
-
-
diff --git a/src/routes/SearchRoute.svelte b/src/routes/SearchRoute.svelte
deleted file mode 100644
index 4f436b1..0000000
--- a/src/routes/SearchRoute.svelte
+++ /dev/null
@@ -1,62 +0,0 @@
-
-
-{#if config}
- v)}
- >
- {#if config.hasHIBP && paramValue}
-
- {/if}
-
-{/if}
\ No newline at end of file
diff --git a/src/routes/domain/[domain]/+page.svelte b/src/routes/domain/[domain]/+page.svelte
new file mode 100644
index 0000000..42b95d9
--- /dev/null
+++ b/src/routes/domain/[domain]/+page.svelte
@@ -0,0 +1,14 @@
+
+
+ v}
+/>
diff --git a/src/routes/email/[email]/+page.svelte b/src/routes/email/[email]/+page.svelte
new file mode 100644
index 0000000..ab38a77
--- /dev/null
+++ b/src/routes/email/[email]/+page.svelte
@@ -0,0 +1,19 @@
+
+
+ v}
+>
+ {#if email}
+
+ {/if}
+
diff --git a/src/routes/password/[password]/+page.svelte b/src/routes/password/[password]/+page.svelte
new file mode 100644
index 0000000..2dd7e89
--- /dev/null
+++ b/src/routes/password/[password]/+page.svelte
@@ -0,0 +1,18 @@
+
+
+
diff --git a/src/routes/username/[name]/+page.svelte b/src/routes/username/[name]/+page.svelte
new file mode 100644
index 0000000..ed7cf68
--- /dev/null
+++ b/src/routes/username/[name]/+page.svelte
@@ -0,0 +1,14 @@
+
+
+ v}
+/>
diff --git a/src/stores/breadcrumbs.ts b/src/stores/breadcrumbs.ts
index b8c43f8..fabbcc1 100644
--- a/src/stores/breadcrumbs.ts
+++ b/src/stores/breadcrumbs.ts
@@ -1,7 +1,8 @@
import { writable } from 'svelte/store';
import { get } from 'svelte/store';
+import { goto } from '$app/navigation';
+import { page } from '$app/stores';
import { navigation } from './navigation';
-import { currentRoute, navigate } from '../router';
export interface BreadcrumbItem {
label: string;
@@ -91,7 +92,7 @@ function createBreadcrumbStore() {
});
// Navigate to the previous breadcrumb
- navigate(previousBreadcrumb.path);
+ goto(previousBreadcrumb.path);
}
}
@@ -111,7 +112,8 @@ function createBreadcrumbStore() {
// Auto-add breadcrumbs based on current location
function addFromLocation(customLabel?: string) {
- const currentLocation = get(currentRoute);
+ const currentPage = get(page);
+ const currentLocation = currentPage.url.pathname;
if (!currentLocation) return;
let label = customLabel;
diff --git a/src/stores/theme.ts b/src/stores/theme.ts
index b575776..be439e9 100644
--- a/src/stores/theme.ts
+++ b/src/stores/theme.ts
@@ -13,15 +13,18 @@ allThemes.forEach(theme => themeCache.set(theme.value, theme));
function createThemeStore() {
+ // Check if we're in the browser environment
+ const isBrowser = typeof window !== 'undefined';
+
// Get initial theme from localStorage or default to system
- const rawStoredTheme = localStorage.getItem('theme');
+ const rawStoredTheme = isBrowser ? localStorage.getItem('theme') : null;
const validThemes = allThemes.map(t => t.value);
- const storedTheme = (rawStoredTheme && validThemes.includes(rawStoredTheme as Theme))
- ? rawStoredTheme as Theme
+ const storedTheme = (rawStoredTheme && validThemes.includes(rawStoredTheme as Theme))
+ ? rawStoredTheme as Theme
: 'system';
-
+
// If we had to reset an invalid theme, update localStorage
- if (rawStoredTheme && rawStoredTheme !== storedTheme) {
+ if (isBrowser && rawStoredTheme && rawStoredTheme !== storedTheme) {
localStorage.setItem('theme', storedTheme);
}
@@ -30,13 +33,17 @@ function createThemeStore() {
return {
subscribe,
setTheme: async (theme: Theme) => {
- localStorage.setItem('theme', theme);
+ if (isBrowser) {
+ localStorage.setItem('theme', theme);
+ }
set(theme);
// Get current dark mode value
- const currentDarkMode = localStorage.getItem('darkMode') === 'true';
+ const currentDarkMode = isBrowser ? localStorage.getItem('darkMode') === 'true' : false;
await applyTheme(theme, currentDarkMode);
},
init: async () => {
+ if (!isBrowser) return;
+
// Get current dark mode value
const currentDarkMode = localStorage.getItem('darkMode') === 'true';
await applyTheme(storedTheme, currentDarkMode);
@@ -55,12 +62,16 @@ function createThemeStore() {
}
function createDarkModeStore() {
- const storedDarkMode = localStorage.getItem('darkMode') === 'true';
+ // Check if we're in the browser environment
+ const isBrowser = typeof window !== 'undefined';
+ const storedDarkMode = isBrowser ? localStorage.getItem('darkMode') === 'true' : false;
const store = writable(storedDarkMode);
return {
subscribe: store.subscribe,
toggle: async () => {
+ if (!isBrowser) return;
+
const currentValue = localStorage.getItem('darkMode') === 'true';
const newValue = !currentValue;
localStorage.setItem('darkMode', String(newValue));
@@ -69,6 +80,8 @@ function createDarkModeStore() {
await applyTheme(currentTheme || 'system', newValue);
},
set: async (value: boolean) => {
+ if (!isBrowser) return;
+
localStorage.setItem('darkMode', String(value));
store.set(value);
const currentTheme = localStorage.getItem('theme') as Theme;
diff --git a/src/test/setup.ts b/src/test/setup.ts
new file mode 100644
index 0000000..fb94cc7
--- /dev/null
+++ b/src/test/setup.ts
@@ -0,0 +1,28 @@
+// Vitest test setup file
+// This file is executed before running tests
+
+// Mock DOM globals if needed
+Object.defineProperty(window, 'matchMedia', {
+ writable: true,
+ value: (query: string) => ({
+ matches: false,
+ media: query,
+ onchange: null,
+ addListener: () => {},
+ removeListener: () => {},
+ addEventListener: () => {},
+ removeEventListener: () => {},
+ dispatchEvent: () => {},
+ }),
+});
+
+// Mock localStorage
+Object.defineProperty(window, 'localStorage', {
+ value: {
+ getItem: () => null,
+ setItem: () => {},
+ removeItem: () => {},
+ clear: () => {},
+ },
+ writable: true,
+});
diff --git a/svelte.config.js b/svelte.config.js
index c9a9871..b8ac08c 100644
--- a/svelte.config.js
+++ b/svelte.config.js
@@ -1,5 +1,33 @@
+import adapter from '@sveltejs/adapter-static';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
-export default {
+/** @type {import('@sveltejs/kit').Config} */
+const config = {
+ // Consult https://kit.svelte.dev/docs/integrations#preprocessors
+ // for more information about preprocessors
preprocess: vitePreprocess(),
+
+ kit: {
+ // adapter-static for static site generation (GitHub Pages)
+ adapter: adapter({
+ pages: 'docs',
+ assets: 'docs',
+ fallback: 'index.html',
+ precompress: false,
+ strict: true
+ }),
+
+ // Configure paths for GitHub Pages deployment
+ paths: {
+ base: process.env.NODE_ENV === 'production' ? '' : '',
+ },
+
+ // Prerender all routes for static deployment
+ prerender: {
+ handleHttpError: 'warn',
+ handleMissingId: 'warn'
+ }
+ }
};
+
+export default config;
diff --git a/tsconfig.json b/tsconfig.json
index 06ff48b..4344710 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,20 +1,14 @@
{
- "extends": "@tsconfig/svelte/tsconfig.json",
+ "extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
- "target": "ES2020",
- "useDefineForClassFields": true,
- "module": "ESNext",
- "resolveJsonModule": true,
"allowJs": true,
"checkJs": true,
- "isolatedModules": true,
- "moduleDetection": "force",
- "baseUrl": ".",
- "paths": {
- "$lib": ["./src/lib"],
- "$lib/*": ["./src/lib/*"]
- }
- },
- "include": ["src/**/*.ts", "src/**/*.js", "src/**/*.svelte"],
- "references": [{ "path": "./tsconfig.node.json" }]
+ "esModuleInterop": true,
+ "forceConsistentCasingInFileNames": true,
+ "resolveJsonModule": true,
+ "skipLibCheck": true,
+ "sourceMap": true,
+ "strict": true,
+ "moduleResolution": "bundler"
+ }
}
diff --git a/vite.config.js b/vite.config.js
index 406f59a..05d4902 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -1,41 +1,16 @@
+import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
-import { svelte } from '@sveltejs/vite-plugin-svelte';
-import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
-import path from 'path';
export default defineConfig({
- plugins: [
- svelte({
- preprocess: vitePreprocess(),
- }),
- ],
+ plugins: [sveltekit()],
server: {
port: 5000,
host: true,
},
build: {
target: 'es2022',
- outDir: 'docs',
- emptyOutDir: true,
- cssCodeSplit: true,
- rollupOptions: {
- output: {
- manualChunks: {
- 'vendor': ['svelte', 'page'],
- 'ui-core': ['bits-ui', 'clsx', 'tailwind-merge', 'lucide-svelte'],
- 'ui-table': ['@tanstack/table-core'],
- 'utils': ['mousetrap']
- }
- }
- }
- },
- base: './',
- resolve: {
- alias: {
- $lib: path.resolve('./src/lib'),
- },
},
optimizeDeps: {
- include: ['svelte', 'page', 'bits-ui', 'clsx', 'tailwind-merge']
+ include: ['bits-ui', 'clsx', 'tailwind-merge', 'lucide-svelte', '@tanstack/table-core', 'mousetrap']
}
});
diff --git a/vitest.config.js b/vitest.config.js
index 054e24d..29cf081 100644
--- a/vitest.config.js
+++ b/vitest.config.js
@@ -6,6 +6,6 @@ export default defineConfig({
test: {
globals: true,
environment: 'jsdom',
- setupFiles: ['./src/test/setup.js'],
+ setupFiles: ['./src/test/setup.ts'],
},
});