"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "DebugPrinter", {
    enumerable: true,
    get: function() {
        return DebugPrinter;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _hooks = require("@orderly.network/hooks");
const _react = require("react");
const DebugPrinter = ()=>{
    const [info, setInfo] = (0, _react.useState)();
    const prevInfo = (0, _react.useRef)(info);
    const ee = (0, _hooks.useEventEmitter)();
    (0, _react.useEffect)(()=>{
        window.__ORDERLY__DEBUGER = {};
    }, []);
    (0, _react.useEffect)(()=>{
        const print = (data)=>{
            setInfo(data);
        // const differences = diff.diff(prevInfo.current, data);
        // console.log(differences);
        //   const error = new Error();
        //   const stack = error
        //     .stack!.split("\n")
        //     .slice(2)
        //     .map((line) => line.replace(/\s+at\s+/, ""))
        //     .join("\n");
        //   console.log(stack);
        };
        ee.on("print:data", print);
        return ()=>{
            ee.off("print:data", print);
        };
    }, []);
    // Save the most recent data for comparison
    (0, _react.useEffect)(()=>{
        setTimeout(()=>{
            prevInfo.current = info;
        }, 200);
    }, [
        info
    ]);
    return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
        className: "orderly-fixed orderly-left-3 orderly-bottom-10 orderly-min-w-[300px] orderly-bg-base-700/70 orderly-z-50 orderly-rounded !orderly-text-xs orderly-grid orderly-grid-cols-2 orderly-max-h-screen orderly-overflow-y-auto  orderly-pointer-events-none",
        children: [
            /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
                className: "orderly-border-r orderly-border-base-500 orderly-p-2",
                children: [
                    /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                        children: "Prev"
                    }),
                    /*#__PURE__*/ (0, _jsxruntime.jsx)("pre", {
                        children: JSON.stringify(prevInfo.current, null, 2)
                    })
                ]
            }),
            /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
                className: "orderly-p-2",
                children: [
                    /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                        children: "New"
                    }),
                    /*#__PURE__*/ (0, _jsxruntime.jsx)("pre", {
                        children: JSON.stringify(info, null, 2)
                    })
                ]
            })
        ]
    });
};

//# sourceMappingURL=dataConsole.js.map