// Live customization guest source. This is plain JavaScript with exactly one
// default export and no imports, dynamic code, DOM, network, storage, or
// filesystem access. It never targets the user's live vault.
export default function activate(api) {
  api.lifecycle.onMount(async (event) => {
    const view = api.forLifecycle(event.instanceId);
    await view.ui.setView({
      version: 1,
      root: {
        id: "root",
        type: "stack",
        gap: "md",
        children: [
          { id: "title", type: "heading", level: 2, text: "Thortiq Kit Live" },
          {
            id: "summary",
            type: "property-table",
            caption: "Status",
            rows: [
              { id: "state", label: "State", value: "Ready", tone: "success" }
            ]
          },
          { id: "refresh", type: "button", label: "Refresh", action: "refresh" }
        ]
      }
    });
    return view.ui.onAction(async (action) => {
      if (action.action === "refresh") {
        // Re-read bounded admitted data and republish the view here.
      }
    });
  });
}
