{"version":3,"file":"getCustomViewByRoute.js","names":["isPathMatchingRoute","getCustomViewByRoute","baseRoute","currentRoute","views","edit","viewKey","foundViewConfig","Object","entries","find","key","view","viewPath","path","isMatching","exact","Component"],"sources":["../../../src/views/Document/getCustomViewByRoute.tsx"],"sourcesContent":["import type { EditViewComponent, SanitizedCollectionConfig, SanitizedGlobalConfig } from 'payload'\n\nimport { isPathMatchingRoute } from '../Root/isPathMatchingRoute.js'\n\nexport const getCustomViewByRoute = ({\n baseRoute,\n currentRoute,\n views,\n}: {\n baseRoute: string\n currentRoute: string\n views:\n | SanitizedCollectionConfig['admin']['components']['views']\n | SanitizedGlobalConfig['admin']['components']['views']\n}): {\n Component: EditViewComponent\n viewKey?: string\n} => {\n if (typeof views?.edit === 'object') {\n let viewKey: string\n\n const foundViewConfig = Object.entries(views.edit).find(([key, view]) => {\n if (typeof view === 'object' && 'path' in view) {\n const viewPath = `${baseRoute}${view.path}`\n\n const isMatching = isPathMatchingRoute({\n currentRoute,\n exact: true,\n path: viewPath,\n })\n\n if (isMatching) {\n viewKey = key\n }\n\n return isMatching\n }\n\n return false\n })?.[1]\n\n if (foundViewConfig && 'Component' in foundViewConfig) {\n return {\n Component: foundViewConfig.Component,\n viewKey,\n }\n }\n }\n\n return {\n Component: null,\n }\n}\n"],"mappings":"AAEA,SAASA,mBAAmB,QAAQ;AAEpC,OAAO,MAAMC,oBAAA,GAAuBA,CAAC;EACnCC,SAAS;EACTC,YAAY;EACZC;AAAK,CAON;EAIC,IAAI,OAAOA,KAAA,EAAOC,IAAA,KAAS,UAAU;IACnC,IAAIC,OAAA;IAEJ,MAAMC,eAAA,GAAkBC,MAAA,CAAOC,OAAO,CAACL,KAAA,CAAMC,IAAI,EAAEK,IAAI,CAAC,CAAC,CAACC,GAAA,EAAKC,IAAA,CAAK;MAClE,IAAI,OAAOA,IAAA,KAAS,YAAY,UAAUA,IAAA,EAAM;QAC9C,MAAMC,QAAA,GAAW,GAAGX,SAAA,GAAYU,IAAA,CAAKE,IAAI,EAAE;QAE3C,MAAMC,UAAA,GAAaf,mBAAA,CAAoB;UACrCG,YAAA;UACAa,KAAA,EAAO;UACPF,IAAA,EAAMD;QACR;QAEA,IAAIE,UAAA,EAAY;UACdT,OAAA,GAAUK,GAAA;QACZ;QAEA,OAAOI,UAAA;MACT;MAEA,OAAO;IACT,KAAK,EAAE;IAEP,IAAIR,eAAA,IAAmB,eAAeA,eAAA,EAAiB;MACrD,OAAO;QACLU,SAAA,EAAWV,eAAA,CAAgBU,SAAS;QACpCX;MACF;IACF;EACF;EAEA,OAAO;IACLW,SAAA,EAAW;EACb;AACF","ignoreList":[]}