import { useDebounceCallback as o } from "../../../../../node_modules/.pnpm/usehooks-ts@3.1.1_react@18.3.0-canary-3d9b20132-20240124/node_modules/usehooks-ts/dist/index.js";
import { useEditorHelpers as r } from "../../../../../use-editor.js";
import { useDraft as d, usePage as b, useSite as S, useSectionsSubscribe as p, usePageAttributesSubscribe as h, useSiteAttributesSubscribe as l, useThemeSubscribe as v } from "../../../../../use-page-data.js";
const n = 1e3;
function I() {
  const s = d(), c = b(), t = S(), { onSavePage: u, onSaveSite: g } = r(), a = o(async (e) => {
    await u?.({
      pageId: c.id,
      pageVersionId: "latest",
      siteId: t.id,
      data: e
    }), s.setDirty(!1);
  }, n), i = o(async (e) => {
    await g?.({
      siteId: t.id,
      data: e
    }), s.setDirty(!1);
  }, n);
  p((e) => {
    console.debug("Sections have changed, updating page version", e), a({ sections: e });
  }), h((e) => {
    console.debug("Page attributes have changed:", e), a({ attributes: e });
  }), l((e) => {
    console.debug("Site attributes have changed:", e), i({ attributes: e });
  }), v((e) => {
    console.debug("theme has changed, updating page version"), i({ theme: e });
  });
}
export {
  I as usePageAutoSave
};
//# sourceMappingURL=use-page-autosave.js.map
