{"version":3,"sources":["../../src/components/FileRouter.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { useContext } from 'react';\n\nimport { TinkerableContext } from '../TinkerableContext';\nimport { underAppRoot } from '../urlUtils';\nimport { defaultErrorComponent, defaultLoadingComponent } from './defaults';\nimport { Include } from './Include';\n\nexport const FileRouter: FC = ({\n  LoadingComponent = defaultLoadingComponent,\n  ErrorComponent = defaultErrorComponent,\n}: {\n  LoadingComponent?: typeof defaultLoadingComponent;\n  ErrorComponent?: typeof defaultErrorComponent;\n} = {}) => {\n  const {\n    navigationState: { pathParameters, sandboxPath },\n  } = useContext(TinkerableContext);\n  // The default table matches `/files/*`, surfacing the file path under the `*`\n  // wildcard (SANDBOX_ROUTING_SPEC §4.1/§7).\n  const filename = pathParameters?.['*'];\n  if (!filename) {\n    return (\n      <ErrorComponent\n        error={new Error(`No filename could be extracted from ${sandboxPath}`)}\n        resetErrorBoundary={() => {}}\n      />\n    );\n  }\n  // URL subpaths are repo-relative; the sandbox fs is rooted at `/` with the\n  // repo mounted at `APP_ROOT`, so anchor the file path there before resolving.\n  return (\n    <Include\n      filename={underAppRoot(filename)}\n      LoadingComponent={LoadingComponent}\n      ErrorComponent={ErrorComponent}\n      // @ts-ignore\n      baseModule={module}\n    />\n  );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBM;AAtBN,mBAA2B;AAE3B,+BAAkC;AAClC,sBAA6B;AAC7B,sBAA+D;AAC/D,qBAAwB;AAEjB,MAAM,aAAiB,CAAC;AAAA,EAC7B,mBAAmB;AAAA,EACnB,iBAAiB;AACnB,IAGI,CAAC,MAAM;AACT,QAAM;AAAA,IACJ,iBAAiB,EAAE,gBAAgB,YAAY;AAAA,EACjD,QAAI,yBAAW,0CAAiB;AAGhC,QAAM,WAAW,iBAAiB,GAAG;AACrC,MAAI,CAAC,UAAU;AACb,WACE;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,IAAI,MAAM,uCAAuC,WAAW,EAAE;AAAA,QACrE,oBAAoB,MAAM;AAAA,QAAC;AAAA;AAAA,IAC7B;AAAA,EAEJ;AAGA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,cAAU,8BAAa,QAAQ;AAAA,MAC/B;AAAA,MACA;AAAA,MAEA,YAAY;AAAA;AAAA,EACd;AAEJ;","names":[]}