"use client"; // import JsonView from '@uiw/react-json-view' import { ChevronDown, ChevronRight, Plus, X } from "lucide-react"; import { useEffect, useState } from "react"; import { useShallow } from "zustand/shallow"; import { IconRail, type PanelId } from "./icon-rail"; import { Button } from "@/components/ui/primitives/button"; import { Tooltip, TooltipContent, TooltipTrigger, } from "@/components/ui/primitives/tooltip"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@/components/ui/primitives/dialog"; import { Sidebar, SidebarContent, SidebarHeader, } from "@/components/ui/primitives/sidebar"; import { cn } from "@/lib/utils"; import useEditor from "@/store/use-editor"; import { useViewer } from "@pascal-app/viewer"; import { SitePanel } from "./panels/site-panel"; export function AppSidebar() { // const isHelpOpen = useEditor((state) => state.isHelpOpen); // const setIsHelpOpen = useEditor((state) => state.setIsHelpOpen); // const isJsonInspectorOpen = useEditor((state) => state.isJsonInspectorOpen); // const setIsJsonInspectorOpen = useEditor( // (state) => state.setIsJsonInspectorOpen, // ); // const selectedNodeIds = useEditor((state) => state.selectedNodeIds); // const handleDeleteSelected = useEditor((state) => state.handleDeleteSelected); // const serializeLayout = useEditor((state) => state.serializeLayout); const activeTool = useEditor((state) => state.tool); const currentLevelId = useViewer((state) => state.selection.levelId); const setActiveTool = useEditor((state) => state.setTool); const [jsonCollapsed, setJsonCollapsed] = useState(1); const [mounted, setMounted] = useState(false); const [activePanel, setActivePanel] = useState("site"); // Wait for client-side hydration to complete before rendering store-dependent content useEffect(() => { setMounted(true); }, []); // Handle backspace key to delete selected elements // useEffect(() => { // const handleKeyDown = (event: KeyboardEvent) => { // if (event.key === "Backspace" && selectedNodeIds.length > 0) { // event.preventDefault(); // handleDeleteSelected(); // } // }; // document.addEventListener("keydown", handleKeyDown); // return () => document.removeEventListener("keydown", handleKeyDown); // }, [selectedNodeIds, handleDeleteSelected]); // Auto-switch to zones panel when zone tool is active useEffect(() => { if (activeTool === "zone") { setActivePanel("zones"); } }, [activeTool]); const renderPanelContent = () => { switch (activePanel) { case "site": return ; // case "zones": // return ; // case "collections": // return ; // case "settings": // return ( // setIsHelpOpen(true)} // onOpenJsonInspector={() => setIsJsonInspectorOpen(true)} // /> // ); default: return null; } }; const getPanelTitle = () => { switch (activePanel) { case "site": return "Site"; case "zones": return "Zones"; case "collections": return "Collections"; case "settings": return "Settings"; default: return ""; } }; const handleAddZone = () => { if (currentLevelId) { setActiveTool("zone"); } }; // const handleAddCollection = () => { // const existingNames = collections.map((c) => c.name); // let counter = 1; // let newName = `Collection ${counter}`; // while (existingNames.includes(newName)) { // counter++; // newName = `Collection ${counter}`; // } // addCollection(newName); // }; const renderHeaderAction = () => { switch (activePanel) { case "zones": return ( {currentLevelId ? "Add new zone" : "Select a level first"} ); // case "collections": // if (addToCollectionState.isActive) { // return ( // // // // // Cancel // // ); // } // return ( // // // // // Add new collection // // ); default: return null; } }; return (
{/* Icon Rail */} {/* Panel Content */}

{getPanelTitle()}

{renderHeaderAction()}
{renderPanelContent()}
{/* Dialogs */} {/* Build Data Inspector
View the raw JSON structure of your current build
House Builder Controls - Click on grid intersections to place walls using the building tools.
- Hold spacebar to enable camera controls (orbit, pan, zoom).
- Use control modes (Select/Delete/Building) to switch between different interactions.
- Create multiple levels and organize your 3D objects and guides within each level.
- Click on level names to select them and expand/collapse with the chevron icons.
- Upload PNG/JPEG reference images as guides within each level.
- Save your build as JSON file for later use or database storage.
- Load previously saved builds from JSON files.
- Inspect data to view the raw JSON structure of your current build.
- Export your 3D model as GLB file.
*/}
); }