{"version":3,"sources":["../../../src/client/components/client-page.tsx"],"sourcesContent":["'use client'\n\nimport type { ParsedUrlQuery } from 'querystring'\nimport type { Params } from '../../server/request/params'\nimport { LayoutRouterContext } from '../../shared/lib/app-router-context.shared-runtime'\nimport { use } from 'react'\nimport { urlSearchParamsToParsedUrlQuery } from '../route-params'\nimport { SearchParamsContext } from '../../shared/lib/hooks-client-context.shared-runtime'\nimport {\n  createClientParams,\n  createClientSearchParams,\n} from './client-boundary-params'\n\n/**\n * When the Page is a client component we send the params and searchParams to this client wrapper\n * where they are turned into dynamically tracked values before being passed to the actual Page component.\n *\n * additionally we may send promises representing the params and searchParams. We don't ever use these passed\n * values but it can be necessary for the sender to send a Promise that doesn't resolve in certain situations.\n * It is up to the caller to decide if the promises are needed.\n */\nexport function ClientPageRoot({\n  Component,\n  serverProvidedParams,\n}: {\n  Component: React.ComponentType<any>\n  serverProvidedParams: null | {\n    searchParams: ParsedUrlQuery\n    params: Params\n    promises: Array<Promise<any>> | null\n  }\n}) {\n  let searchParams: ParsedUrlQuery\n  let params: Params\n  if (serverProvidedParams !== null) {\n    searchParams = serverProvidedParams.searchParams\n    params = serverProvidedParams.params\n  } else {\n    // When Cache Components is enabled, the server does not pass the params as\n    // props; they are parsed on the client and passed via context.\n    const layoutRouterContext = use(LayoutRouterContext)\n    params =\n      layoutRouterContext !== null ? layoutRouterContext.parentParams : {}\n\n    // This is an intentional behavior change: when Cache Components is enabled,\n    // client segments receive the \"canonical\" search params, not the\n    // rewritten ones. Users should either call useSearchParams directly or pass\n    // the rewritten ones in from a Server Component.\n    // TODO: Log a deprecation error when this object is accessed\n    searchParams = urlSearchParamsToParsedUrlQuery(use(SearchParamsContext)!)\n  }\n\n  const clientSearchParams = createClientSearchParams(searchParams)\n  const clientParams = createClientParams(params)\n\n  return <Component params={clientParams} searchParams={clientSearchParams} />\n}\n"],"names":["ClientPageRoot","Component","serverProvidedParams","searchParams","params","layoutRouterContext","use","LayoutRouterContext","parentParams","urlSearchParamsToParsedUrlQuery","SearchParamsContext","clientSearchParams","createClientSearchParams","clientParams","createClientParams"],"mappings":"AAAA;;;;;+BAqBgBA;;;eAAAA;;;;+CAjBoB;uBAChB;6BAC4B;iDACZ;sCAI7B;AAUA,SAASA,eAAe,EAC7BC,SAAS,EACTC,oBAAoB,EAQrB;IACC,IAAIC;IACJ,IAAIC;IACJ,IAAIF,yBAAyB,MAAM;QACjCC,eAAeD,qBAAqBC,YAAY;QAChDC,SAASF,qBAAqBE,MAAM;IACtC,OAAO;QACL,2EAA2E;QAC3E,+DAA+D;QAC/D,MAAMC,sBAAsBC,IAAAA,UAAG,EAACC,kDAAmB;QACnDH,SACEC,wBAAwB,OAAOA,oBAAoBG,YAAY,GAAG,CAAC;QAErE,4EAA4E;QAC5E,iEAAiE;QACjE,4EAA4E;QAC5E,iDAAiD;QACjD,6DAA6D;QAC7DL,eAAeM,IAAAA,4CAA+B,EAACH,IAAAA,UAAG,EAACI,oDAAmB;IACxE;IAEA,MAAMC,qBAAqBC,IAAAA,8CAAwB,EAACT;IACpD,MAAMU,eAAeC,IAAAA,wCAAkB,EAACV;IAExC,qBAAO,qBAACH;QAAUG,QAAQS;QAAcV,cAAcQ;;AACxD","ignoreList":[0]}