{"version":3,"file":"not-found.cjs","names":["isNotFound","Solid","CatchBoundary","useRouter","NotFoundError","getNotFound","error","cause","undefined","CatchNotFound","props","fallback","JSX","Element","onCatch","children","router","pathname","createMemo","stores","location","get","status","_$createComponent","getResetKey","notFoundError","errorComponent","DefaultGlobalNotFound","_tmpl$"],"sources":["../../src/not-found.tsx"],"sourcesContent":["import { isNotFound } from '@tanstack/router-core'\nimport * as Solid from 'solid-js'\nimport { CatchBoundary } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport type { NotFoundError } from '@tanstack/router-core'\n\n// Solid wraps non-Error throws in an Error and stores the original thrown value\n// on `cause`, so component-thrown `notFound()` needs one extra unwrapping step.\nexport function getNotFound(\n  error: unknown,\n): (NotFoundError & { isNotFound: true }) | undefined {\n  if (isNotFound(error)) {\n    return error as NotFoundError & { isNotFound: true }\n  }\n\n  if (isNotFound((error as any)?.cause)) {\n    return (error as any).cause as NotFoundError & { isNotFound: true }\n  }\n\n  return undefined\n}\n\nexport function CatchNotFound(props: {\n  fallback?: (error: NotFoundError) => Solid.JSX.Element\n  onCatch?: (error: NotFoundError) => void\n  children: Solid.JSX.Element\n}) {\n  const router = useRouter()\n  // TODO: Some way for the user to programmatically reset the not-found boundary?\n  const pathname = Solid.createMemo(() => router.stores.location.get().pathname)\n  const status = Solid.createMemo(() => router.stores.status.get())\n\n  return (\n    <CatchBoundary\n      getResetKey={() => `not-found-${pathname()}-${status()}`}\n      onCatch={(error) => {\n        const notFoundError = getNotFound(error)\n\n        if (notFoundError) {\n          props.onCatch?.(notFoundError)\n        } else {\n          throw error\n        }\n      }}\n      errorComponent={({ error }) => {\n        const notFoundError = getNotFound(error)\n\n        if (notFoundError) {\n          return props.fallback?.(notFoundError)\n        } else {\n          throw error\n        }\n      }}\n    >\n      {props.children}\n    </CatchBoundary>\n  )\n}\n\nexport function DefaultGlobalNotFound() {\n  return <p>Not Found</p>\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgBK,YACdC,OACoD;CACpD,KAAA,GAAA,sBAAA,YAAeA,KAAK,GAClB,OAAOA;CAGT,KAAA,GAAA,sBAAA,YAAgBA,OAAeC,KAAK,GAClC,OAAQD,MAAcC;AAI1B;AAEA,SAAgBE,cAAcC,OAI3B;CACD,MAAMM,SAASb,kBAAAA,UAAU;CAEzB,MAAMc,WAAWhB,SAAMiB,iBAAiBF,OAAOG,OAAOC,SAASC,IAAI,EAAEJ,QAAQ;CAC7E,MAAMK,SAASrB,SAAMiB,iBAAiBF,OAAOG,OAAOG,OAAOD,IAAI,CAAC;CAEhE,QAAA,GAAA,aAAA,iBACGnB,sBAAAA,eAAa;EACZsB,mBAAmB,aAAaP,SAAS,EAAC,GAAIK,OAAO;EACrDR,UAAUR,UAAU;GAClB,MAAMmB,gBAAgBpB,YAAYC,KAAK;GAEvC,IAAImB,eACFf,MAAMI,UAAUW,aAAa;QAE7B,MAAMnB;EAEV;EACAoB,iBAAiB,EAAEpB,YAAY;GAC7B,MAAMmB,gBAAgBpB,YAAYC,KAAK;GAEvC,IAAImB,eACF,OAAOf,MAAMC,WAAWc,aAAa;QAErC,MAAMnB;EAEV;EAAC,IAAAS,WAAA;GAAA,OAEAL,MAAMK;EAAQ;CAAA,CAAA;AAGrB;AAEA,SAAgBY,wBAAwB;CACtC,OAAAC,OAAA;AACF"}