globalThis.process ??= {}; globalThis.process.env ??= {};
import { e as createComponent$1, k as renderComponent, r as renderTemplate } from '../../chunks/astro/server_WO3f6Mge.mjs';
import { $ as $$Layout } from '../../chunks/Layout_eV-qEGCG.mjs';
import { c as createMemo, s as ssr, e as escape, a as createComponent, b as ssrHydrationKey, d as ssrStyleProperty, f as createSignal, S as Show, D as Dynamic, F as For } from '../../chunks/_@astro-renderers_DpxbEuk7.mjs';
export { r as renderers } from '../../chunks/_@astro-renderers_DpxbEuk7.mjs';
import { g as getGrid, W as WidgetRenderer } from '../../chunks/registry_B7C18axh.mjs';

var _tmpl$ = ["<div", ' style="', '"><h2>Error</h2><p>', "</p></div>"], _tmpl$2 = ["<div", ' data-grid-container style="', '"><!--$-->', "<!--/--><!--$-->", "<!--/--></div>"], _tmpl$3 = ["<div", ' style="', '"><p>No widgets to display</p></div>'], _tmpl$4 = ["<div", ' style="', '"><!--$-->', "<!--/--><!--$-->", "<!--/--><!--$-->", "<!--/--></div>"];
function Preview() {
  const [widgets] = createSignal([]);
  const [gridConfig] = createSignal({
    templateId: null,
    widgetPlacements: []
  });
  const [error] = createSignal("");
  const scale = createMemo(() => {
    const grid = gridConfig().templateId ? getGrid(gridConfig().templateId) : null;
    if (!grid) return 1;
    const gridWidth = grid.template?.width || 800;
    const gridHeight = grid.template?.height || 600;
    const viewportWidth = window.innerWidth - 40;
    const viewportHeight = window.innerHeight - 40;
    const scaleX = viewportWidth / gridWidth;
    const scaleY = viewportHeight / gridHeight;
    return Math.min(scaleX, scaleY) * 0.98;
  });
  return ssr(_tmpl$4, ssrHydrationKey(), ssrStyleProperty("width:", "100vw") + ssrStyleProperty(";height:", "100vh") + ssrStyleProperty(";position:", "fixed") + ssrStyleProperty(";top:", "0") + ssrStyleProperty(";left:", "0") + ssrStyleProperty(";background:", "var(--bg, #fff)") + ssrStyleProperty(";overflow:", "hidden") + ssrStyleProperty(";display:", "flex") + ssrStyleProperty(";align-items:", "center") + ssrStyleProperty(";justify-content:", "center") + ssrStyleProperty(";padding:", "20px") + ssrStyleProperty(";box-sizing:", "border-box"), escape(createComponent(Show, {
    get when() {
      return error();
    },
    get children() {
      return ssr(_tmpl$, ssrHydrationKey(), ssrStyleProperty("padding:", "2rem") + ssrStyleProperty(";text-align:", "center") + ssrStyleProperty(";color:", "var(--gray)"), escape(error()));
    }
  })), escape(createComponent(Show, {
    get when() {
      return !error() && widgets().length > 0;
    },
    get children() {
      return ssr(_tmpl$2, ssrHydrationKey(), ssrStyleProperty("width:", gridConfig().templateId ? `${escape(getGrid(gridConfig().templateId)?.template.width, true) || 800}px` : "100%") + ssrStyleProperty(";height:", gridConfig().templateId ? `${escape(getGrid(gridConfig().templateId)?.template.height, true) || 600}px` : "100%") + ssrStyleProperty(";position:", "relative") + ssrStyleProperty(";transform:", `scale(${escape(scale(), true)})`) + ssrStyleProperty(";transform-origin:", "center center") + ssrStyleProperty(";flex-shrink:", "0"), escape(createComponent(Show, {
        get when() {
          return gridConfig().templateId;
        },
        children: () => {
          const grid = getGrid(gridConfig().templateId);
          return grid ? createComponent(Dynamic, {
            get component() {
              return grid.Component;
            }
          }) : null;
        }
      })), escape(createComponent(For, {
        get each() {
          return widgets();
        },
        children: (widget) => createComponent(WidgetRenderer, {
          config: widget,
          locked: true
        })
      })));
    }
  })), escape(createComponent(Show, {
    get when() {
      return !error() && widgets().length === 0;
    },
    get children() {
      return ssr(_tmpl$3, ssrHydrationKey(), ssrStyleProperty("padding:", "2rem") + ssrStyleProperty(";text-align:", "center") + ssrStyleProperty(";color:", "var(--gray)"));
    }
  })));
}

const $$Preview = createComponent$1(($$result, $$props, $$slots) => {
  return renderTemplate`${renderComponent($$result, "Layout", $$Layout, { "title": "Dashboard Preview" }, { "default": ($$result2) => renderTemplate` ${renderComponent($$result2, "Preview", Preview, { "client:load": true, "client:component-hydration": "load", "client:component-path": "/home/fc/Projects/glance/src/components/Preview", "client:component-export": "Preview" })} ` })}`;
}, "/home/fc/Projects/glance/src/pages/app/preview.astro", void 0);

const $$file = "/home/fc/Projects/glance/src/pages/app/preview.astro";
const $$url = "/app/preview";

const _page = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
  __proto__: null,
  default: $$Preview,
  file: $$file,
  url: $$url
}, Symbol.toStringTag, { value: 'Module' }));

const page = () => _page;

export { page };
