{"version":3,"file":"page-utils.cjs","sources":["../../src/utils/page-utils.ts"],"sourcesContent":["import type { IPage } from '..';\nimport { isTopPage } from './page-path-utils/is-top-page';\n\n// const GRANT_PUBLIC = 1;\nconst GRANT_RESTRICTED = 2;\nconst GRANT_SPECIFIED = 3; // DEPRECATED\n// const GRANT_OWNER = 4;\n// const GRANT_USER_GROUP = 5;\n// const PAGE_GRANT_ERROR = 1;\n// const STATUS_PUBLISHED = 'published';\nconst STATUS_DELETED = 'deleted';\n\n/**\n * Returns true if the page is on tree including the top page.\n * @param page Page\n * @returns boolean\n */\nexport const isOnTree = (page: IPage): boolean => {\n  const { path, parent } = page;\n\n  if (isTopPage(path)) {\n    return true;\n  }\n\n  if (parent != null) {\n    return true;\n  }\n\n  return false;\n};\n\n/**\n * Returns true if the page meet the condition below.\n *   - The page is on tree (has parent or the top page)\n *   - The page's grant is GRANT_RESTRICTED or GRANT_SPECIFIED\n *   - The page's status is STATUS_DELETED\n * This does not check grantedUser or grantedGroup.\n * @param page PageDocument\n * @returns boolean\n */\nexport const isPageNormalized = (page: IPage): boolean => {\n  const { grant, status } = page;\n\n  if (grant === GRANT_RESTRICTED || grant === GRANT_SPECIFIED) {\n    return true;\n  }\n\n  if (status === STATUS_DELETED) {\n    return true;\n  }\n\n  if (isOnTree(page)) {\n    return true;\n  }\n\n  return true;\n};\n"],"names":["GRANT_RESTRICTED","GRANT_SPECIFIED","STATUS_DELETED","isOnTree","page","path","parent","isTopPage","isPageNormalized","grant","status"],"mappings":"qIAIMA,EAAmB,EACnBC,EAAkB,EAKlBC,EAAiB,UAOVC,EAAYC,GAAyB,CAC1C,KAAA,CAAE,KAAAC,EAAM,OAAAC,CAAA,EAAWF,EAMzB,MAJIG,GAAAA,EAAAA,UAAUF,CAAI,GAIdC,GAAU,KAKhB,EAWaE,EAAoBJ,GAAyB,CAClD,KAAA,CAAE,MAAAK,EAAO,OAAAC,CAAA,EAAWN,EAUtB,OARAK,IAAUT,GAAoBS,IAAUR,GAIxCS,IAAWR,GAIXC,EAASC,CAAI,EACR,EAIX"}