{"version":3,"file":"content_conversion.cjs","names":[],"sources":["../../src/block_meta/content_conversion.ts"],"sourcesContent":["import type {\n  ContentAbsoluteUrl,\n  ContentAnyLocal,\n  ContentExplicitOrRelative,\n  ContentRelative,\n} from \"./content_types\";\n\nexport function mapRemoteToAbsolute(\n  rootUrl: string,\n): <T extends ContentAnyLocal>(value: T) => Exclude<T, ContentRelative> | ContentAbsoluteUrl {\n  const rootWithSlash = rootUrl.endsWith(\"/\") ? rootUrl : `${rootUrl}/`;\n  return <T extends ContentAnyLocal>(value: T) =>\n    value.type === \"relative\"\n      ? { type: \"absolute-url\", url: rootWithSlash + value.path }\n      : (value as Exclude<T, ContentRelative>);\n}\n\n/**\n * Creates transformer of relative content paths, that adds a specific prefix to the relative path.\n *\n * If prefix = \"nested-path/\", paths like \"somefile.txt\" will be transformed to \"nested-path/somefile.txt\".\n *\n * @param prefix prefix to add to the relative path, slash at the end will be added automatically if missed\n */\nexport function addPrefixToRelative(\n  prefix: string,\n): <T extends ContentExplicitOrRelative>(value: T) => T {\n  const prefixWithSlash = prefix.endsWith(\"/\") ? prefix : `${prefix}/`;\n  return <T extends ContentExplicitOrRelative>(value: T) =>\n    (value.type === \"relative\"\n      ? { type: \"relative\", path: prefixWithSlash + value.path }\n      : value) as T;\n}\n"],"mappings":";AAOA,SAAgB,oBACd,SAC2F;CAC3F,MAAM,gBAAgB,QAAQ,SAAS,GAAG,IAAI,UAAU,GAAG,QAAQ;CACnE,QAAmC,UACjC,MAAM,SAAS,aACX;EAAE,MAAM;EAAgB,KAAK,gBAAgB,MAAM;CAAK,IACvD;AACT;;;;;;;;AASA,SAAgB,oBACd,QACsD;CACtD,MAAM,kBAAkB,OAAO,SAAS,GAAG,IAAI,SAAS,GAAG,OAAO;CAClE,QAA6C,UAC1C,MAAM,SAAS,aACZ;EAAE,MAAM;EAAY,MAAM,kBAAkB,MAAM;CAAK,IACvD;AACR"}