{"version":3,"file":"index.mjs","sources":[""],"sourcesContent":["import { getDocument } from \"ssr-window\";\r\n\r\nexport type TGetCookieArgs = Parameters<typeof getCookie>;\r\n\r\nexport type TGetCookieReturn = ReturnType<typeof getCookie>;\r\n\r\n/**\r\n * Retrieves a cookie value by name.\r\n *\r\n * @param {string} name Cookie name\r\n * @returns {string|undefined} The cookie value or undefined if not found\r\n * @throws {TypeError} If name is not a non-empty string\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie\r\n * @example\r\n * // How to get value of Cookie?\r\n * setCookie(\"myCookieName\", \"myValue\");\r\n * const savedValue = getCookie(\"myCookieName\");\r\n * console.log(savedValue); // => \"myValue\"\r\n */\r\nexport const getCookie = (name: string): string | undefined => {\r\n  if (typeof name !== \"string\" || name.length === 0) {\r\n    throw new TypeError(\"getCookie: name must be a non-empty string\");\r\n  }\r\n  const safeName = name.replace(/([$?*|{}\\]\\\\^])/g, \"\\\\$1\");\r\n  // eslint-disable-next-line security/detect-non-literal-regexp\r\n  const match = getDocument().cookie.match(new RegExp(\"(?:^|; )\" + safeName + \"=([^;]*)\"));\r\n  return match ? decodeURIComponent(match[1]) : undefined;\r\n};\r\n"],"names":["getCookie","name","length","TypeError","safeName","replace","match","getDocument","cookie","RegExp","decodeURIComponent","undefined"],"mappings":";;;;;;;;;;;;;GAmBO,MAAMA,UAAaC,OACxB,UAAWA,OAAS,UAAYA,KAAKC,SAAW,EAC9C,MAAM,IAAIC,UAAU,8CAEtB,MAAMC,SAAWH,KAAKI,QAAQ,mBAAoB;8DAElD;MAAMC,MAAQC,cAAcC,OAAOF,MAAM,IAAIG,OAAO,WAAaL,SAAW,aAC5E,OAAOE,MAAQI,mBAAmBJ,MAAM,SAAMK"}