{"version":3,"file":"getPreviewCookie.cjs","sources":["../../../src/lib/getPreviewCookie.ts"],"sourcesContent":["const readValue = (value: string): string => {\n\treturn value.replace(/%3B/g, \";\");\n};\n\n/**\n * Returns the value of a cookie from a given cookie store.\n *\n * @returns The value of the cookie, if it exists.\n */\nexport const getPreviewCookie = (): string | undefined => {\n\tconst cookies = document.cookie.split(\"; \");\n\n\tfor (const cookie of cookies) {\n\t\tconst parts = cookie.split(\"=\");\n\t\tconst thisName = readValue(parts[0]).replace(/%3D/g, \"=\");\n\n\t\t// The Prismic preview cookie name is hardcoded here to prevent\n\t\t// including `@prismicio/client` in the main \"app.js\" bundle.\n\t\t// Unfortunately, the package is not tree-shaken when only the\n\t\t// cookie name is imported.\n\t\tif (thisName === \"io.prismic.preview\") {\n\t\t\tconst value = parts.slice(1).join(\"=\");\n\n\t\t\treturn readValue(value);\n\t\t}\n\t}\n};\n"],"names":[],"mappings":";;AAAA,MAAM,YAAY,CAAC,UAAyB;AACpC,SAAA,MAAM,QAAQ,QAAQ,GAAG;AACjC;AAOO,MAAM,mBAAmB,MAAyB;AACxD,QAAM,UAAU,SAAS,OAAO,MAAM,IAAI;AAE1C,aAAW,UAAU,SAAS;AACvB,UAAA,QAAQ,OAAO,MAAM,GAAG;AACxB,UAAA,WAAW,UAAU,MAAM,CAAC,CAAC,EAAE,QAAQ,QAAQ,GAAG;AAMxD,QAAI,aAAa,sBAAsB;AACtC,YAAM,QAAQ,MAAM,MAAM,CAAC,EAAE,KAAK,GAAG;AAErC,aAAO,UAAU,KAAK;AAAA,IACtB;AAAA,EACD;AACF;;"}