@ai-react-markdown/core 1.4.2 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -36,13 +36,15 @@ __export(index_exports, {
36
36
  AIMarkdownRenderExtraSyntax: () => AIMarkdownRenderExtraSyntax,
37
37
  default: () => index_default,
38
38
  defaultAIMarkdownRenderConfig: () => defaultAIMarkdownRenderConfig,
39
+ defaultUrlTransform: () => defaultUrlTransform,
40
+ extendSanitizeSchema: () => extendSanitizeSchema,
39
41
  useAIMarkdownMetadata: () => useAIMarkdownMetadata,
40
42
  useAIMarkdownRenderState: () => useAIMarkdownRenderState,
41
43
  useDocumentRegistry: () => useDocumentRegistry,
42
44
  useStableValue: () => useStableValue
43
45
  });
44
46
  module.exports = __toCommonJS(index_exports);
45
- var import_react10 = require("react");
47
+ var import_react12 = require("react");
46
48
 
47
49
  // src/context.tsx
48
50
  var import_react = require("react");
@@ -1554,7 +1556,7 @@ function preprocessAIMDContent(content, extraPreprocessors = defaultExtraPreproc
1554
1556
  }
1555
1557
 
1556
1558
  // src/components/MarkdownContent.tsx
1557
- var import_react7 = require("react");
1559
+ var import_react8 = require("react");
1558
1560
 
1559
1561
  // src/components/markdown/Markdown.tsx
1560
1562
  var import_devlop2 = require("devlop");
@@ -1603,15 +1605,17 @@ function buildTransform(ctx) {
1603
1605
  if (node.type === "element") {
1604
1606
  const element = node;
1605
1607
  let key;
1608
+ const properties = element.properties ?? {};
1606
1609
  for (key in import_html_url_attributes.urlAttributes) {
1607
- if (Object.hasOwn(import_html_url_attributes.urlAttributes, key) && Object.hasOwn(element.properties, key)) {
1608
- const value = element.properties[key];
1610
+ if (Object.hasOwn(import_html_url_attributes.urlAttributes, key) && Object.hasOwn(properties, key)) {
1611
+ const value = properties[key];
1609
1612
  const test = import_html_url_attributes.urlAttributes[key];
1610
1613
  if (test === null || test.includes(element.tagName)) {
1611
- element.properties[key] = ctx.urlTransform(String(value || ""), key, element);
1614
+ properties[key] = ctx.urlTransform(String(value || ""), key, element);
1612
1615
  }
1613
1616
  }
1614
1617
  }
1618
+ element.properties = properties;
1615
1619
  }
1616
1620
  if (node.type === "element") {
1617
1621
  const element = node;
@@ -1744,6 +1748,414 @@ var import_rehype_raw = __toESM(require("rehype-raw"), 1);
1744
1748
  var import_rehype_unwrap_images = __toESM(require("rehype-unwrap-images"), 1);
1745
1749
  var import_rehype_sanitize2 = __toESM(require("rehype-sanitize"), 1);
1746
1750
 
1751
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayEach.js
1752
+ function arrayEach(array, iteratee) {
1753
+ var index = -1, length = array == null ? 0 : array.length;
1754
+ while (++index < length) {
1755
+ if (iteratee(array[index], index, array) === false) {
1756
+ break;
1757
+ }
1758
+ }
1759
+ return array;
1760
+ }
1761
+ var arrayEach_default = arrayEach;
1762
+
1763
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeys.js
1764
+ var nativeKeys = overArg_default(Object.keys, Object);
1765
+ var nativeKeys_default = nativeKeys;
1766
+
1767
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseKeys.js
1768
+ var objectProto12 = Object.prototype;
1769
+ var hasOwnProperty10 = objectProto12.hasOwnProperty;
1770
+ function baseKeys(object) {
1771
+ if (!isPrototype_default(object)) {
1772
+ return nativeKeys_default(object);
1773
+ }
1774
+ var result = [];
1775
+ for (var key in Object(object)) {
1776
+ if (hasOwnProperty10.call(object, key) && key != "constructor") {
1777
+ result.push(key);
1778
+ }
1779
+ }
1780
+ return result;
1781
+ }
1782
+ var baseKeys_default = baseKeys;
1783
+
1784
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/keys.js
1785
+ function keys(object) {
1786
+ return isArrayLike_default(object) ? arrayLikeKeys_default(object) : baseKeys_default(object);
1787
+ }
1788
+ var keys_default = keys;
1789
+
1790
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseAssign.js
1791
+ function baseAssign(object, source) {
1792
+ return object && copyObject_default(source, keys_default(source), object);
1793
+ }
1794
+ var baseAssign_default = baseAssign;
1795
+
1796
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignIn.js
1797
+ function baseAssignIn(object, source) {
1798
+ return object && copyObject_default(source, keysIn_default(source), object);
1799
+ }
1800
+ var baseAssignIn_default = baseAssignIn;
1801
+
1802
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayFilter.js
1803
+ function arrayFilter(array, predicate) {
1804
+ var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
1805
+ while (++index < length) {
1806
+ var value = array[index];
1807
+ if (predicate(value, index, array)) {
1808
+ result[resIndex++] = value;
1809
+ }
1810
+ }
1811
+ return result;
1812
+ }
1813
+ var arrayFilter_default = arrayFilter;
1814
+
1815
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/stubArray.js
1816
+ function stubArray() {
1817
+ return [];
1818
+ }
1819
+ var stubArray_default = stubArray;
1820
+
1821
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getSymbols.js
1822
+ var objectProto13 = Object.prototype;
1823
+ var propertyIsEnumerable2 = objectProto13.propertyIsEnumerable;
1824
+ var nativeGetSymbols = Object.getOwnPropertySymbols;
1825
+ var getSymbols = !nativeGetSymbols ? stubArray_default : function(object) {
1826
+ if (object == null) {
1827
+ return [];
1828
+ }
1829
+ object = Object(object);
1830
+ return arrayFilter_default(nativeGetSymbols(object), function(symbol) {
1831
+ return propertyIsEnumerable2.call(object, symbol);
1832
+ });
1833
+ };
1834
+ var getSymbols_default = getSymbols;
1835
+
1836
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_copySymbols.js
1837
+ function copySymbols(source, object) {
1838
+ return copyObject_default(source, getSymbols_default(source), object);
1839
+ }
1840
+ var copySymbols_default = copySymbols;
1841
+
1842
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayPush.js
1843
+ function arrayPush(array, values) {
1844
+ var index = -1, length = values.length, offset = array.length;
1845
+ while (++index < length) {
1846
+ array[offset + index] = values[index];
1847
+ }
1848
+ return array;
1849
+ }
1850
+ var arrayPush_default = arrayPush;
1851
+
1852
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getSymbolsIn.js
1853
+ var nativeGetSymbols2 = Object.getOwnPropertySymbols;
1854
+ var getSymbolsIn = !nativeGetSymbols2 ? stubArray_default : function(object) {
1855
+ var result = [];
1856
+ while (object) {
1857
+ arrayPush_default(result, getSymbols_default(object));
1858
+ object = getPrototype_default(object);
1859
+ }
1860
+ return result;
1861
+ };
1862
+ var getSymbolsIn_default = getSymbolsIn;
1863
+
1864
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_copySymbolsIn.js
1865
+ function copySymbolsIn(source, object) {
1866
+ return copyObject_default(source, getSymbolsIn_default(source), object);
1867
+ }
1868
+ var copySymbolsIn_default = copySymbolsIn;
1869
+
1870
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseGetAllKeys.js
1871
+ function baseGetAllKeys(object, keysFunc, symbolsFunc) {
1872
+ var result = keysFunc(object);
1873
+ return isArray_default(object) ? result : arrayPush_default(result, symbolsFunc(object));
1874
+ }
1875
+ var baseGetAllKeys_default = baseGetAllKeys;
1876
+
1877
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeys.js
1878
+ function getAllKeys(object) {
1879
+ return baseGetAllKeys_default(object, keys_default, getSymbols_default);
1880
+ }
1881
+ var getAllKeys_default = getAllKeys;
1882
+
1883
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeysIn.js
1884
+ function getAllKeysIn(object) {
1885
+ return baseGetAllKeys_default(object, keysIn_default, getSymbolsIn_default);
1886
+ }
1887
+ var getAllKeysIn_default = getAllKeysIn;
1888
+
1889
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_DataView.js
1890
+ var DataView = getNative_default(root_default, "DataView");
1891
+ var DataView_default = DataView;
1892
+
1893
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Promise.js
1894
+ var Promise2 = getNative_default(root_default, "Promise");
1895
+ var Promise_default = Promise2;
1896
+
1897
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Set.js
1898
+ var Set2 = getNative_default(root_default, "Set");
1899
+ var Set_default = Set2;
1900
+
1901
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js
1902
+ var WeakMap = getNative_default(root_default, "WeakMap");
1903
+ var WeakMap_default = WeakMap;
1904
+
1905
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js
1906
+ var mapTag2 = "[object Map]";
1907
+ var objectTag3 = "[object Object]";
1908
+ var promiseTag = "[object Promise]";
1909
+ var setTag2 = "[object Set]";
1910
+ var weakMapTag2 = "[object WeakMap]";
1911
+ var dataViewTag2 = "[object DataView]";
1912
+ var dataViewCtorString = toSource_default(DataView_default);
1913
+ var mapCtorString = toSource_default(Map_default);
1914
+ var promiseCtorString = toSource_default(Promise_default);
1915
+ var setCtorString = toSource_default(Set_default);
1916
+ var weakMapCtorString = toSource_default(WeakMap_default);
1917
+ var getTag = baseGetTag_default;
1918
+ if (DataView_default && getTag(new DataView_default(new ArrayBuffer(1))) != dataViewTag2 || Map_default && getTag(new Map_default()) != mapTag2 || Promise_default && getTag(Promise_default.resolve()) != promiseTag || Set_default && getTag(new Set_default()) != setTag2 || WeakMap_default && getTag(new WeakMap_default()) != weakMapTag2) {
1919
+ getTag = function(value) {
1920
+ var result = baseGetTag_default(value), Ctor = result == objectTag3 ? value.constructor : void 0, ctorString = Ctor ? toSource_default(Ctor) : "";
1921
+ if (ctorString) {
1922
+ switch (ctorString) {
1923
+ case dataViewCtorString:
1924
+ return dataViewTag2;
1925
+ case mapCtorString:
1926
+ return mapTag2;
1927
+ case promiseCtorString:
1928
+ return promiseTag;
1929
+ case setCtorString:
1930
+ return setTag2;
1931
+ case weakMapCtorString:
1932
+ return weakMapTag2;
1933
+ }
1934
+ }
1935
+ return result;
1936
+ };
1937
+ }
1938
+ var getTag_default = getTag;
1939
+
1940
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_initCloneArray.js
1941
+ var objectProto14 = Object.prototype;
1942
+ var hasOwnProperty11 = objectProto14.hasOwnProperty;
1943
+ function initCloneArray(array) {
1944
+ var length = array.length, result = new array.constructor(length);
1945
+ if (length && typeof array[0] == "string" && hasOwnProperty11.call(array, "index")) {
1946
+ result.index = array.index;
1947
+ result.input = array.input;
1948
+ }
1949
+ return result;
1950
+ }
1951
+ var initCloneArray_default = initCloneArray;
1952
+
1953
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneDataView.js
1954
+ function cloneDataView(dataView, isDeep) {
1955
+ var buffer = isDeep ? cloneArrayBuffer_default(dataView.buffer) : dataView.buffer;
1956
+ return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
1957
+ }
1958
+ var cloneDataView_default = cloneDataView;
1959
+
1960
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneRegExp.js
1961
+ var reFlags = /\w*$/;
1962
+ function cloneRegExp(regexp) {
1963
+ var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
1964
+ result.lastIndex = regexp.lastIndex;
1965
+ return result;
1966
+ }
1967
+ var cloneRegExp_default = cloneRegExp;
1968
+
1969
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneSymbol.js
1970
+ var symbolProto = Symbol_default ? Symbol_default.prototype : void 0;
1971
+ var symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
1972
+ function cloneSymbol(symbol) {
1973
+ return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
1974
+ }
1975
+ var cloneSymbol_default = cloneSymbol;
1976
+
1977
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_initCloneByTag.js
1978
+ var boolTag2 = "[object Boolean]";
1979
+ var dateTag2 = "[object Date]";
1980
+ var mapTag3 = "[object Map]";
1981
+ var numberTag2 = "[object Number]";
1982
+ var regexpTag2 = "[object RegExp]";
1983
+ var setTag3 = "[object Set]";
1984
+ var stringTag2 = "[object String]";
1985
+ var symbolTag = "[object Symbol]";
1986
+ var arrayBufferTag2 = "[object ArrayBuffer]";
1987
+ var dataViewTag3 = "[object DataView]";
1988
+ var float32Tag2 = "[object Float32Array]";
1989
+ var float64Tag2 = "[object Float64Array]";
1990
+ var int8Tag2 = "[object Int8Array]";
1991
+ var int16Tag2 = "[object Int16Array]";
1992
+ var int32Tag2 = "[object Int32Array]";
1993
+ var uint8Tag2 = "[object Uint8Array]";
1994
+ var uint8ClampedTag2 = "[object Uint8ClampedArray]";
1995
+ var uint16Tag2 = "[object Uint16Array]";
1996
+ var uint32Tag2 = "[object Uint32Array]";
1997
+ function initCloneByTag(object, tag, isDeep) {
1998
+ var Ctor = object.constructor;
1999
+ switch (tag) {
2000
+ case arrayBufferTag2:
2001
+ return cloneArrayBuffer_default(object);
2002
+ case boolTag2:
2003
+ case dateTag2:
2004
+ return new Ctor(+object);
2005
+ case dataViewTag3:
2006
+ return cloneDataView_default(object, isDeep);
2007
+ case float32Tag2:
2008
+ case float64Tag2:
2009
+ case int8Tag2:
2010
+ case int16Tag2:
2011
+ case int32Tag2:
2012
+ case uint8Tag2:
2013
+ case uint8ClampedTag2:
2014
+ case uint16Tag2:
2015
+ case uint32Tag2:
2016
+ return cloneTypedArray_default(object, isDeep);
2017
+ case mapTag3:
2018
+ return new Ctor();
2019
+ case numberTag2:
2020
+ case stringTag2:
2021
+ return new Ctor(object);
2022
+ case regexpTag2:
2023
+ return cloneRegExp_default(object);
2024
+ case setTag3:
2025
+ return new Ctor();
2026
+ case symbolTag:
2027
+ return cloneSymbol_default(object);
2028
+ }
2029
+ }
2030
+ var initCloneByTag_default = initCloneByTag;
2031
+
2032
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsMap.js
2033
+ var mapTag4 = "[object Map]";
2034
+ function baseIsMap(value) {
2035
+ return isObjectLike_default(value) && getTag_default(value) == mapTag4;
2036
+ }
2037
+ var baseIsMap_default = baseIsMap;
2038
+
2039
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isMap.js
2040
+ var nodeIsMap = nodeUtil_default && nodeUtil_default.isMap;
2041
+ var isMap = nodeIsMap ? baseUnary_default(nodeIsMap) : baseIsMap_default;
2042
+ var isMap_default = isMap;
2043
+
2044
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsSet.js
2045
+ var setTag4 = "[object Set]";
2046
+ function baseIsSet(value) {
2047
+ return isObjectLike_default(value) && getTag_default(value) == setTag4;
2048
+ }
2049
+ var baseIsSet_default = baseIsSet;
2050
+
2051
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isSet.js
2052
+ var nodeIsSet = nodeUtil_default && nodeUtil_default.isSet;
2053
+ var isSet = nodeIsSet ? baseUnary_default(nodeIsSet) : baseIsSet_default;
2054
+ var isSet_default = isSet;
2055
+
2056
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseClone.js
2057
+ var CLONE_DEEP_FLAG = 1;
2058
+ var CLONE_FLAT_FLAG = 2;
2059
+ var CLONE_SYMBOLS_FLAG = 4;
2060
+ var argsTag3 = "[object Arguments]";
2061
+ var arrayTag2 = "[object Array]";
2062
+ var boolTag3 = "[object Boolean]";
2063
+ var dateTag3 = "[object Date]";
2064
+ var errorTag2 = "[object Error]";
2065
+ var funcTag3 = "[object Function]";
2066
+ var genTag2 = "[object GeneratorFunction]";
2067
+ var mapTag5 = "[object Map]";
2068
+ var numberTag3 = "[object Number]";
2069
+ var objectTag4 = "[object Object]";
2070
+ var regexpTag3 = "[object RegExp]";
2071
+ var setTag5 = "[object Set]";
2072
+ var stringTag3 = "[object String]";
2073
+ var symbolTag2 = "[object Symbol]";
2074
+ var weakMapTag3 = "[object WeakMap]";
2075
+ var arrayBufferTag3 = "[object ArrayBuffer]";
2076
+ var dataViewTag4 = "[object DataView]";
2077
+ var float32Tag3 = "[object Float32Array]";
2078
+ var float64Tag3 = "[object Float64Array]";
2079
+ var int8Tag3 = "[object Int8Array]";
2080
+ var int16Tag3 = "[object Int16Array]";
2081
+ var int32Tag3 = "[object Int32Array]";
2082
+ var uint8Tag3 = "[object Uint8Array]";
2083
+ var uint8ClampedTag3 = "[object Uint8ClampedArray]";
2084
+ var uint16Tag3 = "[object Uint16Array]";
2085
+ var uint32Tag3 = "[object Uint32Array]";
2086
+ var cloneableTags = {};
2087
+ cloneableTags[argsTag3] = cloneableTags[arrayTag2] = cloneableTags[arrayBufferTag3] = cloneableTags[dataViewTag4] = cloneableTags[boolTag3] = cloneableTags[dateTag3] = cloneableTags[float32Tag3] = cloneableTags[float64Tag3] = cloneableTags[int8Tag3] = cloneableTags[int16Tag3] = cloneableTags[int32Tag3] = cloneableTags[mapTag5] = cloneableTags[numberTag3] = cloneableTags[objectTag4] = cloneableTags[regexpTag3] = cloneableTags[setTag5] = cloneableTags[stringTag3] = cloneableTags[symbolTag2] = cloneableTags[uint8Tag3] = cloneableTags[uint8ClampedTag3] = cloneableTags[uint16Tag3] = cloneableTags[uint32Tag3] = true;
2088
+ cloneableTags[errorTag2] = cloneableTags[funcTag3] = cloneableTags[weakMapTag3] = false;
2089
+ function baseClone(value, bitmask, customizer, key, object, stack) {
2090
+ var result, isDeep = bitmask & CLONE_DEEP_FLAG, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG;
2091
+ if (customizer) {
2092
+ result = object ? customizer(value, key, object, stack) : customizer(value);
2093
+ }
2094
+ if (result !== void 0) {
2095
+ return result;
2096
+ }
2097
+ if (!isObject_default(value)) {
2098
+ return value;
2099
+ }
2100
+ var isArr = isArray_default(value);
2101
+ if (isArr) {
2102
+ result = initCloneArray_default(value);
2103
+ if (!isDeep) {
2104
+ return copyArray_default(value, result);
2105
+ }
2106
+ } else {
2107
+ var tag = getTag_default(value), isFunc = tag == funcTag3 || tag == genTag2;
2108
+ if (isBuffer_default(value)) {
2109
+ return cloneBuffer_default(value, isDeep);
2110
+ }
2111
+ if (tag == objectTag4 || tag == argsTag3 || isFunc && !object) {
2112
+ result = isFlat || isFunc ? {} : initCloneObject_default(value);
2113
+ if (!isDeep) {
2114
+ return isFlat ? copySymbolsIn_default(value, baseAssignIn_default(result, value)) : copySymbols_default(value, baseAssign_default(result, value));
2115
+ }
2116
+ } else {
2117
+ if (!cloneableTags[tag]) {
2118
+ return object ? value : {};
2119
+ }
2120
+ result = initCloneByTag_default(value, tag, isDeep);
2121
+ }
2122
+ }
2123
+ stack || (stack = new Stack_default());
2124
+ var stacked = stack.get(value);
2125
+ if (stacked) {
2126
+ return stacked;
2127
+ }
2128
+ stack.set(value, result);
2129
+ if (isSet_default(value)) {
2130
+ value.forEach(function(subValue) {
2131
+ result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
2132
+ });
2133
+ } else if (isMap_default(value)) {
2134
+ value.forEach(function(subValue, key2) {
2135
+ result.set(key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
2136
+ });
2137
+ }
2138
+ var keysFunc = isFull ? isFlat ? getAllKeysIn_default : getAllKeys_default : isFlat ? keysIn_default : keys_default;
2139
+ var props = isArr ? void 0 : keysFunc(value);
2140
+ arrayEach_default(props || value, function(subValue, key2) {
2141
+ if (props) {
2142
+ key2 = subValue;
2143
+ subValue = value[key2];
2144
+ }
2145
+ assignValue_default(result, key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
2146
+ });
2147
+ return result;
2148
+ }
2149
+ var baseClone_default = baseClone;
2150
+
2151
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/cloneDeep.js
2152
+ var CLONE_DEEP_FLAG2 = 1;
2153
+ var CLONE_SYMBOLS_FLAG2 = 4;
2154
+ function cloneDeep(value) {
2155
+ return baseClone_default(value, CLONE_DEEP_FLAG2 | CLONE_SYMBOLS_FLAG2);
2156
+ }
2157
+ var cloneDeep_default = cloneDeep;
2158
+
1747
2159
  // src/components/sanitizeSchema.ts
1748
2160
  var import_rehype_sanitize = require("rehype-sanitize");
1749
2161
  function mergeClassNameAllowlist(existing, extraClassNames) {
@@ -1760,7 +2172,7 @@ function mergeClassNameAllowlist(existing, extraClassNames) {
1760
2172
  return entries;
1761
2173
  }
1762
2174
  var crossChunkTags = ["cross-chunk-link", "cross-chunk-image", "footnote-sup"];
1763
- var sanitizeSchema = {
2175
+ var sanitizeSchema = cloneDeep_default({
1764
2176
  ...import_rehype_sanitize.defaultSchema,
1765
2177
  tagNames: [...import_rehype_sanitize.defaultSchema.tagNames || [], "mark", ...crossChunkTags],
1766
2178
  attributes: {
@@ -1770,7 +2182,7 @@ var sanitizeSchema = {
1770
2182
  "cross-chunk-image": ["label", "referenceType", "documentId", "alt"],
1771
2183
  "footnote-sup": ["label", "localOccurrence", "documentId"]
1772
2184
  }
1773
- };
2185
+ });
1774
2186
 
1775
2187
  // src/components/rehypeRebaseHashLinks.ts
1776
2188
  var import_unist_util_visit2 = require("unist-util-visit");
@@ -2318,13 +2730,8 @@ function createRegistry(onEmpty) {
2318
2730
  // src/components/AIMarkdownDocuments.tsx
2319
2731
  var import_jsx_runtime3 = require("react/jsx-runtime");
2320
2732
  var AIMarkdownDocumentsContext = (0, import_react3.createContext)(null);
2321
- var AIMarkdownDocuments = ({ preserveOrphanReferences = true, children }) => {
2322
- const parent = (0, import_react3.useContext)(AIMarkdownDocumentsContext);
2323
- if (parent !== null) {
2324
- throw new Error(
2325
- "<AIMarkdownDocuments> must not be nested inside another <AIMarkdownDocuments>. Use a single top-level wrapper per coordinated scope."
2326
- );
2327
- }
2733
+ var NESTED_WRAPPER_MESSAGE = "<AIMarkdownDocuments> must not be nested inside another <AIMarkdownDocuments>. Use a single top-level wrapper per coordinated scope.";
2734
+ var AIMarkdownDocumentsRoot = ({ preserveOrphanReferences, children }) => {
2328
2735
  const registriesRef = (0, import_react3.useRef)(/* @__PURE__ */ new Map());
2329
2736
  const value = (0, import_react3.useMemo)(
2330
2737
  () => ({
@@ -2347,6 +2754,19 @@ var AIMarkdownDocuments = ({ preserveOrphanReferences = true, children }) => {
2347
2754
  );
2348
2755
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AIMarkdownDocumentsContext.Provider, { value, children });
2349
2756
  };
2757
+ var AIMarkdownDocuments = ({ preserveOrphanReferences = true, children }) => {
2758
+ const parent = (0, import_react3.useContext)(AIMarkdownDocumentsContext);
2759
+ if (parent !== null) {
2760
+ if (process.env.NODE_ENV !== "production") {
2761
+ throw new Error(NESTED_WRAPPER_MESSAGE);
2762
+ }
2763
+ console.error(
2764
+ `[ai-react-markdown] ${NESTED_WRAPPER_MESSAGE} Falling back to the outer wrapper; the inner wrapper is a no-op.`
2765
+ );
2766
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children });
2767
+ }
2768
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AIMarkdownDocumentsRoot, { preserveOrphanReferences, children });
2769
+ };
2350
2770
  function useDocumentRegistry(documentId) {
2351
2771
  const ctx = (0, import_react3.useContext)(AIMarkdownDocumentsContext);
2352
2772
  if (!ctx || !documentId) return null;
@@ -2463,16 +2883,50 @@ function buildCrossChunkHandlers() {
2463
2883
  }
2464
2884
 
2465
2885
  // src/components/crossChunkPlaceholders.tsx
2466
- var import_react5 = require("react");
2886
+ var import_react6 = require("react");
2467
2887
 
2468
2888
  // src/components/chunkSymbolContext.ts
2469
2889
  var import_react4 = require("react");
2470
2890
  var ChunkSymbolContext = (0, import_react4.createContext)(null);
2471
2891
 
2892
+ // src/components/crossChunkUrlContext.ts
2893
+ var import_react5 = require("react");
2894
+ var CrossChunkUrlContext = (0, import_react5.createContext)(null);
2895
+
2896
+ // src/components/crossChunkUrlSanitize.ts
2897
+ function fakeElement(tagName, key, url) {
2898
+ return { type: "element", tagName, properties: { [key]: url }, children: [] };
2899
+ }
2900
+ function isRelative(url, colon) {
2901
+ if (colon === -1) return true;
2902
+ const slash = url.indexOf("/");
2903
+ const questionMark = url.indexOf("?");
2904
+ const numberSign = url.indexOf("#");
2905
+ if (slash !== -1 && colon > slash) return true;
2906
+ if (questionMark !== -1 && colon > questionMark) return true;
2907
+ if (numberSign !== -1 && colon > numberSign) return true;
2908
+ return false;
2909
+ }
2910
+ function isProtocolAllowed(url, allowed) {
2911
+ const colon = url.indexOf(":");
2912
+ if (isRelative(url, colon)) return true;
2913
+ const protocol = url.slice(0, colon);
2914
+ return allowed.some((p) => p === protocol);
2915
+ }
2916
+ function sanitizeCrossChunkUrl(rawUrl, key, tagName, urlTransform, schema) {
2917
+ const transformed = urlTransform(rawUrl, key, fakeElement(tagName, key, rawUrl));
2918
+ if (transformed == null) return "";
2919
+ const stringUrl = String(transformed);
2920
+ if (stringUrl === "") return "";
2921
+ const callerProtocols = schema.protocols;
2922
+ const allowed = callerProtocols === void 0 || callerProtocols === null ? sanitizeSchema.protocols?.[key] : callerProtocols[key];
2923
+ if (!allowed || allowed.length === 0) return stringUrl;
2924
+ return isProtocolAllowed(stringUrl, allowed) ? stringUrl : "";
2925
+ }
2926
+
2472
2927
  // src/components/crossChunkPlaceholders.tsx
2473
2928
  var import_jsx_runtime4 = require("react/jsx-runtime");
2474
2929
  var SSR_NUM_SNAPSHOT = () => 0;
2475
- var SSR_DEF_SNAPSHOT = () => null;
2476
2930
  function coerceLocalOccurrence(v) {
2477
2931
  if (v === void 0) return null;
2478
2932
  if (typeof v === "number") return Number.isFinite(v) && v >= 1 ? Math.trunc(v) : null;
@@ -2483,11 +2937,11 @@ function FootnoteSupNumber({ label, localOccurrence: localOccurrenceRaw }) {
2483
2937
  const localOccurrence = coerceLocalOccurrence(localOccurrenceRaw);
2484
2938
  const { documentId, clobberPrefix } = useAIMarkdownRenderState();
2485
2939
  const registry = useDocumentRegistry(documentId);
2486
- const chunkSym = (0, import_react5.useContext)(ChunkSymbolContext);
2487
- const subscribe = (0, import_react5.useCallback)((cb) => registry ? registry.subscribe(cb) : () => {
2940
+ const chunkSym = (0, import_react6.useContext)(ChunkSymbolContext);
2941
+ const subscribe = (0, import_react6.useCallback)((cb) => registry ? registry.subscribe(cb) : () => {
2488
2942
  }, [registry]);
2489
- const getSnapshot = (0, import_react5.useCallback)(() => registry?.version ?? 0, [registry]);
2490
- (0, import_react5.useSyncExternalStore)(subscribe, getSnapshot, SSR_NUM_SNAPSHOT);
2943
+ const getSnapshot = (0, import_react6.useCallback)(() => registry?.version ?? 0, [registry]);
2944
+ (0, import_react6.useSyncExternalStore)(subscribe, getSnapshot, SSR_NUM_SNAPSHOT);
2491
2945
  const num = registry?.globalNumber(label) ?? null;
2492
2946
  if (num === null) return null;
2493
2947
  if (localOccurrence !== null && !chunkSym) return null;
@@ -2501,7 +2955,7 @@ function reactNodeToText(node) {
2501
2955
  if (typeof node === "string") return node;
2502
2956
  if (typeof node === "number" || typeof node === "bigint") return String(node);
2503
2957
  if (Array.isArray(node)) return node.map(reactNodeToText).join("");
2504
- if ((0, import_react5.isValidElement)(node)) {
2958
+ if ((0, import_react6.isValidElement)(node)) {
2505
2959
  return reactNodeToText(node.props.children);
2506
2960
  }
2507
2961
  return "";
@@ -2521,14 +2975,23 @@ function literalLink(rt, label, children) {
2521
2975
  function CrossChunkLink({ label, referenceType, children }) {
2522
2976
  const { documentId } = useAIMarkdownRenderState();
2523
2977
  const registry = useDocumentRegistry(documentId);
2524
- const subscribe = (0, import_react5.useCallback)((cb) => registry ? registry.subscribe(cb) : () => {
2978
+ const policy = (0, import_react6.useContext)(CrossChunkUrlContext);
2979
+ const subscribe = (0, import_react6.useCallback)((cb) => registry ? registry.subscribe(cb) : () => {
2525
2980
  }, [registry]);
2526
- const getSnapshot = (0, import_react5.useCallback)(() => registry?.resolveLinkDef(label) ?? null, [registry, label]);
2527
- const def = (0, import_react5.useSyncExternalStore)(subscribe, getSnapshot, SSR_DEF_SNAPSHOT);
2981
+ const getSnapshot = (0, import_react6.useCallback)(() => registry?.version ?? 0, [registry]);
2982
+ (0, import_react6.useSyncExternalStore)(subscribe, getSnapshot, SSR_NUM_SNAPSHOT);
2983
+ const def = registry?.resolveLinkDef(label) ?? null;
2528
2984
  if (!def) {
2529
2985
  return literalLink(referenceType, label, children);
2530
2986
  }
2531
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { href: def.url, title: def.title, children });
2987
+ const url = sanitizeCrossChunkUrl(
2988
+ def.url,
2989
+ "href",
2990
+ "a",
2991
+ policy?.urlTransform ?? defaultUrlTransform,
2992
+ policy?.sanitizeSchema ?? sanitizeSchema
2993
+ );
2994
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { href: url, title: def.title, children });
2532
2995
  }
2533
2996
  function literalImage(rt, label, alt) {
2534
2997
  switch (rt) {
@@ -2544,14 +3007,23 @@ function literalImage(rt, label, alt) {
2544
3007
  function CrossChunkImage({ label, referenceType, alt = "" }) {
2545
3008
  const { documentId } = useAIMarkdownRenderState();
2546
3009
  const registry = useDocumentRegistry(documentId);
2547
- const subscribe = (0, import_react5.useCallback)((cb) => registry ? registry.subscribe(cb) : () => {
3010
+ const policy = (0, import_react6.useContext)(CrossChunkUrlContext);
3011
+ const subscribe = (0, import_react6.useCallback)((cb) => registry ? registry.subscribe(cb) : () => {
2548
3012
  }, [registry]);
2549
- const getSnapshot = (0, import_react5.useCallback)(() => registry?.resolveLinkDef(label) ?? null, [registry, label]);
2550
- const def = (0, import_react5.useSyncExternalStore)(subscribe, getSnapshot, SSR_DEF_SNAPSHOT);
3013
+ const getSnapshot = (0, import_react6.useCallback)(() => registry?.version ?? 0, [registry]);
3014
+ (0, import_react6.useSyncExternalStore)(subscribe, getSnapshot, SSR_NUM_SNAPSHOT);
3015
+ const def = registry?.resolveLinkDef(label) ?? null;
2551
3016
  if (!def) {
2552
3017
  return literalImage(referenceType, label, alt);
2553
3018
  }
2554
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { src: def.url, alt, title: def.title });
3019
+ const url = sanitizeCrossChunkUrl(
3020
+ def.url,
3021
+ "src",
3022
+ "img",
3023
+ policy?.urlTransform ?? defaultUrlTransform,
3024
+ policy?.sanitizeSchema ?? sanitizeSchema
3025
+ );
3026
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { src: url, alt, title: def.title });
2555
3027
  }
2556
3028
  var crossChunkComponents = {
2557
3029
  "footnote-sup": FootnoteSupNumber,
@@ -2561,8 +3033,17 @@ var crossChunkComponents = {
2561
3033
 
2562
3034
  // src/components/extractContributions.ts
2563
3035
  var import_unist_util_visit6 = require("unist-util-visit");
3036
+ function fakeAnchorElement(url) {
3037
+ return { type: "element", tagName: "a", properties: { href: url }, children: [] };
3038
+ }
3039
+ function sanitizeDefUrl(url, urlTransform) {
3040
+ if (!urlTransform) return url;
3041
+ const result = urlTransform(url, "href", fakeAnchorElement(url));
3042
+ return result == null ? "" : String(result);
3043
+ }
2564
3044
  function* extractContributions(mdast, options = {}) {
2565
3045
  const phantomFn = options.phantomFootnoteLabels;
3046
+ const urlTransform = options.urlTransform;
2566
3047
  const out = [];
2567
3048
  (0, import_unist_util_visit6.visit)(mdast, (n) => {
2568
3049
  if (n.type === "footnoteReference") {
@@ -2587,7 +3068,12 @@ function* extractContributions(mdast, options = {}) {
2587
3068
  } else if (n.type === "definition") {
2588
3069
  const d = n;
2589
3070
  if (d.url === SENTINEL_LINK_URL) return;
2590
- out.push({ kind: "linkDef", label: normalizeId(d.identifier), url: d.url, title: d.title });
3071
+ out.push({
3072
+ kind: "linkDef",
3073
+ label: normalizeId(d.identifier),
3074
+ url: sanitizeDefUrl(d.url, urlTransform),
3075
+ title: d.title
3076
+ });
2591
3077
  }
2592
3078
  });
2593
3079
  for (const c of out) yield c;
@@ -2721,7 +3207,7 @@ function extractDefBodiesFromHast(hast, clobberPrefix) {
2721
3207
  }
2722
3208
 
2723
3209
  // src/components/aggregateFootnotesIfLast.tsx
2724
- var import_react6 = require("react");
3210
+ var import_react7 = require("react");
2725
3211
  var import_jsx_runtime5 = require("react/jsx-runtime");
2726
3212
  function cloneHast(node) {
2727
3213
  return JSON.parse(JSON.stringify(node));
@@ -2871,7 +3357,7 @@ var AggregateFootnotesIfLastImpl = ({
2871
3357
  postOptions,
2872
3358
  preserveOrphanReferences = false
2873
3359
  }) => {
2874
- const tree = (0, import_react6.useMemo)(
3360
+ const tree = (0, import_react7.useMemo)(
2875
3361
  () => buildAggregateTree(registry, clobberPrefix, preserveOrphanReferences),
2876
3362
  // eslint-disable-next-line react-hooks/exhaustive-deps
2877
3363
  [registry, registry.version, clobberPrefix, preserveOrphanReferences]
@@ -2882,7 +3368,7 @@ var AggregateFootnotesIfLastImpl = ({
2882
3368
  if (!tree) return null;
2883
3369
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: renderHastSubtree(cloneHast(tree), postOptions) });
2884
3370
  };
2885
- var AggregateFootnotesIfLast = (0, import_react6.memo)(AggregateFootnotesIfLastImpl);
3371
+ var AggregateFootnotesIfLast = (0, import_react7.memo)(AggregateFootnotesIfLastImpl);
2886
3372
  AggregateFootnotesIfLast.displayName = "AggregateFootnotesIfLast";
2887
3373
 
2888
3374
  // src/components/MarkdownContent.tsx
@@ -2898,28 +3384,35 @@ var ExtraSyntaxRemarkPluginMap = {
2898
3384
  ["DEFINITION_LIST" /* DEFINITION_LIST */]: import_remark_definition_list.remarkDefinitionList
2899
3385
  };
2900
3386
  var DefaultCustomComponents = {};
2901
- var BlockMemoizedRenderer = (0, import_react7.memo)(
2902
- ({ content, usedComponents, remarkPlugins, rehypePlugins, remarkRehypeOptions }) => {
2903
- const urlTransform = void 0;
3387
+ var BlockMemoizedRenderer = (0, import_react8.memo)(
3388
+ ({
3389
+ content,
3390
+ usedComponents,
3391
+ remarkPlugins,
3392
+ rehypePlugins,
3393
+ remarkRehypeOptions,
3394
+ urlTransform,
3395
+ sanitizeSchema: usedSanitizeSchema
3396
+ }) => {
2904
3397
  const allowedElements = void 0;
2905
3398
  const disallowedElements = void 0;
2906
3399
  const allowElement = void 0;
2907
3400
  const skipHtml = void 0;
2908
3401
  const unwrapDisallowed = void 0;
2909
3402
  const { documentId, clobberPrefix, config } = useAIMarkdownRenderState();
2910
- const reactId = (0, import_react7.useId)();
3403
+ const reactId = (0, import_react8.useId)();
2911
3404
  const registry = useDocumentRegistry(documentId);
2912
- const [allocation, setAllocation] = (0, import_react7.useState)(null);
3405
+ const [allocation, setAllocation] = (0, import_react8.useState)(null);
2913
3406
  const sym = allocation && allocation.registry === registry ? allocation.sym : null;
2914
- const subscribeRegistry = (0, import_react7.useCallback)(
3407
+ const subscribeRegistry = (0, import_react8.useCallback)(
2915
3408
  (cb) => registry ? registry.subscribe(cb) : () => {
2916
3409
  },
2917
3410
  [registry]
2918
3411
  );
2919
- const getRegistryVersion = (0, import_react7.useCallback)(() => registry?.version ?? 0, [registry]);
2920
- (0, import_react7.useSyncExternalStore)(subscribeRegistry, getRegistryVersion, REGISTRY_SSR_SNAPSHOT);
2921
- const ownLabels = (0, import_react7.useMemo)(() => collectDefLabels(content ?? ""), [content]);
2922
- (0, import_react7.useEffect)(() => {
3412
+ const getRegistryVersion = (0, import_react8.useCallback)(() => registry?.version ?? 0, [registry]);
3413
+ (0, import_react8.useSyncExternalStore)(subscribeRegistry, getRegistryVersion, REGISTRY_SSR_SNAPSHOT);
3414
+ const ownLabels = (0, import_react8.useMemo)(() => collectDefLabels(content ?? ""), [content]);
3415
+ (0, import_react8.useEffect)(() => {
2923
3416
  if (!registry) return;
2924
3417
  const s = registry.registerChunk(reactId, ownLabels.footnoteLabels, ownLabels.linkLabels);
2925
3418
  setAllocation({ registry, sym: s });
@@ -2928,8 +3421,8 @@ var BlockMemoizedRenderer = (0, import_react7.memo)(
2928
3421
  setAllocation(null);
2929
3422
  };
2930
3423
  }, [reactId, registry, ownLabels]);
2931
- const cacheRef = (0, import_react7.useRef)(createCache());
2932
- const depsRef = (0, import_react7.useRef)({
3424
+ const cacheRef = (0, import_react8.useRef)(createCache());
3425
+ const depsRef = (0, import_react8.useRef)({
2933
3426
  usedComponents,
2934
3427
  remarkPlugins,
2935
3428
  rehypePlugins,
@@ -2960,11 +3453,11 @@ var BlockMemoizedRenderer = (0, import_react7.memo)(
2960
3453
  symbol: sym
2961
3454
  };
2962
3455
  }
2963
- const targetPhantomsRef = (0, import_react7.useRef)({
3456
+ const targetPhantomsRef = (0, import_react8.useRef)({
2964
3457
  missingFootnotes: /* @__PURE__ */ new Set(),
2965
3458
  missingLinks: /* @__PURE__ */ new Set()
2966
3459
  });
2967
- const targetPhantoms = (0, import_react7.useMemo)(() => {
3460
+ const targetPhantoms = (0, import_react8.useMemo)(() => {
2968
3461
  let nextFootnotes;
2969
3462
  let nextLinks;
2970
3463
  if (!registry) {
@@ -2993,7 +3486,7 @@ var BlockMemoizedRenderer = (0, import_react7.memo)(
2993
3486
  }, [registry, registry?.version, content, ownLabels]);
2994
3487
  const effectivePreserveOrphan = usePreserveOrphanReferences(config.preserveOrphanReferences);
2995
3488
  const preserveForBodyHarvest = effectivePreserveOrphan || Boolean(registry && sym);
2996
- const handlers = (0, import_react7.useMemo)(() => {
3489
+ const handlers = (0, import_react8.useMemo)(() => {
2997
3490
  if (registry) return buildCrossChunkHandlers();
2998
3491
  if (effectivePreserveOrphan) {
2999
3492
  const { footnoteDefinition } = buildCrossChunkHandlers();
@@ -3001,7 +3494,7 @@ var BlockMemoizedRenderer = (0, import_react7.memo)(
3001
3494
  }
3002
3495
  return void 0;
3003
3496
  }, [registry, effectivePreserveOrphan]);
3004
- const parsed = (0, import_react7.useMemo)(() => {
3497
+ const parsed = (0, import_react8.useMemo)(() => {
3005
3498
  const augmented = augmentSourceWithPhantoms(content ?? "", targetPhantoms);
3006
3499
  const baseHandlers = remarkRehypeOptions?.handlers ?? {};
3007
3500
  const mergedRemarkRehypeOptions = handlers ? {
@@ -3034,9 +3527,9 @@ var BlockMemoizedRenderer = (0, import_react7.memo)(
3034
3527
  preserveForBodyHarvest,
3035
3528
  documentId
3036
3529
  ]);
3037
- const hast = (0, import_react7.useMemo)(() => transformStage(parsed), [parsed]);
3038
- const built = (0, import_react7.useMemo)(() => buildBlocks(parsed.mdast, hast, content ?? ""), [parsed.mdast, hast, content]);
3039
- const postOptions = (0, import_react7.useMemo)(
3530
+ const hast = (0, import_react8.useMemo)(() => transformStage(parsed), [parsed]);
3531
+ const built = (0, import_react8.useMemo)(() => buildBlocks(parsed.mdast, hast, content ?? ""), [parsed.mdast, hast, content]);
3532
+ const postOptions = (0, import_react8.useMemo)(
3040
3533
  () => ({
3041
3534
  components: { ...crossChunkComponents, ...usedComponents },
3042
3535
  urlTransform,
@@ -3069,14 +3562,16 @@ var BlockMemoizedRenderer = (0, import_react7.memo)(
3069
3562
  clobberPrefix
3070
3563
  ]
3071
3564
  );
3072
- const lastContributionRef = (0, import_react7.useRef)(null);
3073
- (0, import_react7.useEffect)(() => {
3565
+ const lastContributionRef = (0, import_react8.useRef)(null);
3566
+ (0, import_react8.useEffect)(() => {
3074
3567
  if (!registry || !sym) return;
3075
3568
  const refs = [];
3076
3569
  const defMeta = /* @__PURE__ */ new Map();
3077
3570
  const linkDefs = /* @__PURE__ */ new Map();
3571
+ const resolvedUrlTransform = urlTransform ?? defaultUrlTransform;
3078
3572
  for (const node of extractContributions(parsed.mdast, {
3079
- phantomFootnoteLabels: targetPhantoms.missingFootnotes
3573
+ phantomFootnoteLabels: targetPhantoms.missingFootnotes,
3574
+ urlTransform: resolvedUrlTransform
3080
3575
  })) {
3081
3576
  if (node.kind === "ref") {
3082
3577
  refs.push({ label: node.label, kind: node.refKind, referenceType: node.referenceType });
@@ -3130,10 +3625,17 @@ var BlockMemoizedRenderer = (0, import_react7.memo)(
3130
3625
  ownFootnoteLabels: ownLabels.footnoteLabels,
3131
3626
  ownLinkLabels: ownLabels.linkLabels
3132
3627
  });
3133
- }, [parsed, ownLabels, registry, targetPhantoms, sym, hast, clobberPrefix]);
3628
+ }, [parsed, ownLabels, registry, targetPhantoms, sym, hast, clobberPrefix, urlTransform]);
3134
3629
  const rendered = renderBlocksWithCache(cacheRef, built.plan, built.globalCtx, postOptions);
3135
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(ChunkSymbolContext.Provider, { value: sym, children: [
3136
- rendered.map(({ node, reactKey }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react7.Fragment, { children: node }, reactKey)),
3630
+ const crossChunkUrlPolicy = (0, import_react8.useMemo)(
3631
+ () => ({
3632
+ urlTransform: urlTransform || defaultUrlTransform,
3633
+ sanitizeSchema: usedSanitizeSchema
3634
+ }),
3635
+ [urlTransform, usedSanitizeSchema]
3636
+ );
3637
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CrossChunkUrlContext.Provider, { value: crossChunkUrlPolicy, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(ChunkSymbolContext.Provider, { value: sym, children: [
3638
+ rendered.map(({ node, reactKey }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react8.Fragment, { children: node }, reactKey)),
3137
3639
  registry && sym ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3138
3640
  AggregateFootnotesIfLast,
3139
3641
  {
@@ -3144,118 +3646,140 @@ var BlockMemoizedRenderer = (0, import_react7.memo)(
3144
3646
  preserveOrphanReferences: effectivePreserveOrphan
3145
3647
  }
3146
3648
  ) : null
3147
- ] });
3649
+ ] }) });
3148
3650
  }
3149
3651
  );
3150
3652
  BlockMemoizedRenderer.displayName = "BlockMemoizedRenderer";
3151
- var LegacyRenderer = (0, import_react7.memo)(
3152
- ({ content, usedComponents, remarkPlugins, rehypePlugins, remarkRehypeOptions }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3653
+ var LegacyRenderer = (0, import_react8.memo)(
3654
+ // `sanitizeSchema` is accepted (and ignored) here purely for prop-shape
3655
+ // parity with `BlockMemoizedRenderer` — legacy mode skips cross-chunk
3656
+ // coordination entirely, so there's no placeholder needing the schema.
3657
+ // Rebind to an underscore-prefixed local so the project's
3658
+ // no-unused-vars rule (which allows `_`-prefixed names) accepts it.
3659
+ ({
3660
+ content,
3661
+ usedComponents,
3662
+ remarkPlugins,
3663
+ rehypePlugins,
3664
+ remarkRehypeOptions,
3665
+ urlTransform,
3666
+ sanitizeSchema: _sanitizeSchema
3667
+ }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3153
3668
  Markdown_default,
3154
3669
  {
3155
3670
  remarkPlugins,
3156
3671
  rehypePlugins,
3157
3672
  remarkRehypeOptions,
3158
3673
  components: usedComponents,
3674
+ urlTransform,
3159
3675
  children: content
3160
3676
  }
3161
3677
  )
3162
3678
  );
3163
3679
  LegacyRenderer.displayName = "LegacyRenderer";
3164
- var AIMarkdownContent = (0, import_react7.memo)(({ content, customComponents }) => {
3165
- const { config, clobberPrefix } = useAIMarkdownRenderState();
3166
- const { extraSyntaxRemarkPlugins, enableDefinitionList } = (0, import_react7.useMemo)(
3167
- () => ({
3168
- extraSyntaxRemarkPlugins: config.extraSyntaxSupported.map((syntax) => ExtraSyntaxRemarkPluginMap[syntax]),
3169
- enableDefinitionList: config.extraSyntaxSupported.includes("DEFINITION_LIST" /* DEFINITION_LIST */)
3170
- }),
3171
- [config.extraSyntaxSupported]
3172
- );
3173
- const displayOptimizeRemarkPlugins = (0, import_react7.useMemo)(() => {
3174
- return config.displayOptimizeAbilities.map((ability) => DisplayOptimizeRemarkPluginMap[ability]);
3175
- }, [config.displayOptimizeAbilities]);
3176
- const usedComponents = (0, import_react7.useMemo)(() => {
3177
- return customComponents ? { ...DefaultCustomComponents, ...customComponents } : DefaultCustomComponents;
3178
- }, [customComponents]);
3179
- const remarkPlugins = (0, import_react7.useMemo)(
3180
- () => [
3181
- // --- Core plugins (always active) ---
3182
- import_remark_gfm2.default,
3183
- [
3184
- import_remark_math.default,
3185
- {
3186
- // Disable single-dollar inline math to avoid conflicts with currency
3187
- // signs and other dollar usages; the preprocessor converts $...$ to $$...$$.
3188
- singleDollarTextMath: false
3189
- }
3680
+ var AIMarkdownContent = (0, import_react8.memo)(
3681
+ ({ content, customComponents, urlTransform, sanitizeSchema: customSanitizeSchema }) => {
3682
+ const { config, clobberPrefix } = useAIMarkdownRenderState();
3683
+ const usedSanitizeSchema = customSanitizeSchema ?? sanitizeSchema;
3684
+ const { extraSyntaxRemarkPlugins, enableDefinitionList } = (0, import_react8.useMemo)(
3685
+ () => ({
3686
+ extraSyntaxRemarkPlugins: config.extraSyntaxSupported.map((syntax) => ExtraSyntaxRemarkPluginMap[syntax]),
3687
+ enableDefinitionList: config.extraSyntaxSupported.includes("DEFINITION_LIST" /* DEFINITION_LIST */)
3688
+ }),
3689
+ [config.extraSyntaxSupported]
3690
+ );
3691
+ const displayOptimizeRemarkPlugins = (0, import_react8.useMemo)(() => {
3692
+ return config.displayOptimizeAbilities.map((ability) => DisplayOptimizeRemarkPluginMap[ability]);
3693
+ }, [config.displayOptimizeAbilities]);
3694
+ const usedComponents = (0, import_react8.useMemo)(() => {
3695
+ return customComponents ? { ...DefaultCustomComponents, ...customComponents } : DefaultCustomComponents;
3696
+ }, [customComponents]);
3697
+ const remarkPlugins = (0, import_react8.useMemo)(
3698
+ () => [
3699
+ // --- Core plugins (always active) ---
3700
+ import_remark_gfm2.default,
3701
+ [
3702
+ import_remark_math.default,
3703
+ {
3704
+ // Disable single-dollar inline math to avoid conflicts with currency
3705
+ // signs and other dollar usages; the preprocessor converts $...$ to $$...$$.
3706
+ singleDollarTextMath: false
3707
+ }
3708
+ ],
3709
+ // --- Configurable extra syntax plugins ---
3710
+ ...extraSyntaxRemarkPlugins,
3711
+ // --- Formatting & normalization ---
3712
+ import_remark_breaks.default,
3713
+ import_remark_emoji.default,
3714
+ import_remark_squeeze_paragraphs.default,
3715
+ import_remark_cjk_friendly.default,
3716
+ import_remark_cjk_friendly_gfm_strikethrough.default,
3717
+ // --- Configurable display optimizations ---
3718
+ ...displayOptimizeRemarkPlugins
3190
3719
  ],
3191
- // --- Configurable extra syntax plugins ---
3192
- ...extraSyntaxRemarkPlugins,
3193
- // --- Formatting & normalization ---
3194
- import_remark_breaks.default,
3195
- import_remark_emoji.default,
3196
- import_remark_squeeze_paragraphs.default,
3197
- import_remark_cjk_friendly.default,
3198
- import_remark_cjk_friendly_gfm_strikethrough.default,
3199
- // --- Configurable display optimizations ---
3200
- ...displayOptimizeRemarkPlugins
3201
- ],
3202
- [extraSyntaxRemarkPlugins, displayOptimizeRemarkPlugins]
3203
- );
3204
- const rehypePlugins = (0, import_react7.useMemo)(
3205
- () => [
3206
- // Allow raw HTML through so rehype-sanitize can handle it.
3207
- [import_rehype_raw.default, { passThrough: [] }],
3208
- // Sanitize HTML while allowing <mark> (highlight) and KaTeX class names.
3209
- // Override `clobberPrefix` with the instance-scoped value so every id
3210
- // and clobberable attribute is namespaced to this `<AIMarkdown>` instance.
3211
- [import_rehype_sanitize2.default, { ...sanitizeSchema, clobberPrefix }],
3212
- // Normalize the auto-generated `<section data-footnotes>`: strip the
3213
- // sr-only `<h2>Footnotes</h2>` label and prepend `<hr>`. Keeps standalone
3214
- // single-doc rendering visually consistent with the cross-chunk aggregate
3215
- // footer (which builds the same shape from scratch).
3216
- rehypeFooterAdorn,
3217
- // Re-prefix intra-document hash hrefs so they match the ids that
3218
- // rehype-sanitize just clobbered. Must use the SAME prefix as the schema
3219
- // above — that's why both read from `clobberPrefix`.
3220
- [rehypeRebaseHashLinks_default, { prefix: clobberPrefix }],
3221
- import_rehype_katex.default,
3222
- import_rehype_unwrap_images.default
3223
- ],
3224
- [clobberPrefix]
3225
- );
3226
- const remarkRehypeOptions = (0, import_react7.useMemo)(
3227
- () => ({
3228
- allowDangerousHtml: true,
3229
- // Suppress mdast-util-to-hast's `user-content-` prefix on footnote
3230
- // ids/hrefs; rehype-sanitize will apply the same prefix downstream
3231
- // and `rehypeRebaseHashLinks` mirrors it onto matching hash hrefs.
3232
- // Without this, ids would end up double-prefixed
3233
- // (`user-content-user-content-fn-x`).
3234
- clobberPrefix: "",
3235
- handlers: {
3236
- // Inject definition-list HAST handlers when the extension is active.
3237
- ...enableDefinitionList ? import_remark_definition_list.defListHastHandlers : {}
3720
+ [extraSyntaxRemarkPlugins, displayOptimizeRemarkPlugins]
3721
+ );
3722
+ const rehypePlugins = (0, import_react8.useMemo)(
3723
+ () => [
3724
+ // Allow raw HTML through so rehype-sanitize can handle it.
3725
+ [import_rehype_raw.default, { passThrough: [] }],
3726
+ // Sanitize HTML while allowing <mark> (highlight), KaTeX class names,
3727
+ // and any extra protocols the caller permitted via the `sanitizeSchema`
3728
+ // prop. Override `clobberPrefix` with the instance-scoped value so every
3729
+ // id and clobberable attribute is namespaced to this `<AIMarkdown>`
3730
+ // instance — the spread order is intentional: our prefix wins over any
3731
+ // caller-supplied prefix on the schema.
3732
+ [import_rehype_sanitize2.default, { ...usedSanitizeSchema, clobberPrefix }],
3733
+ // Normalize the auto-generated `<section data-footnotes>`: strip the
3734
+ // sr-only `<h2>Footnotes</h2>` label and prepend `<hr>`. Keeps standalone
3735
+ // single-doc rendering visually consistent with the cross-chunk aggregate
3736
+ // footer (which builds the same shape from scratch).
3737
+ rehypeFooterAdorn,
3738
+ // Re-prefix intra-document hash hrefs so they match the ids that
3739
+ // rehype-sanitize just clobbered. Must use the SAME prefix as the schema
3740
+ // above that's why both read from `clobberPrefix`.
3741
+ [rehypeRebaseHashLinks_default, { prefix: clobberPrefix }],
3742
+ import_rehype_katex.default,
3743
+ import_rehype_unwrap_images.default
3744
+ ],
3745
+ [clobberPrefix, usedSanitizeSchema]
3746
+ );
3747
+ const remarkRehypeOptions = (0, import_react8.useMemo)(
3748
+ () => ({
3749
+ allowDangerousHtml: true,
3750
+ // Suppress mdast-util-to-hast's `user-content-` prefix on footnote
3751
+ // ids/hrefs; rehype-sanitize will apply the same prefix downstream
3752
+ // and `rehypeRebaseHashLinks` mirrors it onto matching hash hrefs.
3753
+ // Without this, ids would end up double-prefixed
3754
+ // (`user-content-user-content-fn-x`).
3755
+ clobberPrefix: "",
3756
+ handlers: {
3757
+ // Inject definition-list HAST handlers when the extension is active.
3758
+ ...enableDefinitionList ? import_remark_definition_list.defListHastHandlers : {}
3759
+ }
3760
+ }),
3761
+ [enableDefinitionList]
3762
+ );
3763
+ const Renderer = config.blockMemoEnabled ? BlockMemoizedRenderer : LegacyRenderer;
3764
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3765
+ Renderer,
3766
+ {
3767
+ content,
3768
+ usedComponents,
3769
+ remarkPlugins,
3770
+ rehypePlugins,
3771
+ remarkRehypeOptions,
3772
+ urlTransform,
3773
+ sanitizeSchema: usedSanitizeSchema
3238
3774
  }
3239
- }),
3240
- [enableDefinitionList]
3241
- );
3242
- const Renderer = config.blockMemoEnabled ? BlockMemoizedRenderer : LegacyRenderer;
3243
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3244
- Renderer,
3245
- {
3246
- content,
3247
- usedComponents,
3248
- remarkPlugins,
3249
- rehypePlugins,
3250
- remarkRehypeOptions
3251
- }
3252
- );
3253
- });
3775
+ );
3776
+ }
3777
+ );
3254
3778
  AIMarkdownContent.displayName = "AIMarkdownContent";
3255
3779
  var MarkdownContent_default = AIMarkdownContent;
3256
3780
 
3257
3781
  // src/hooks/useStableValue.ts
3258
- var import_react8 = require("react");
3782
+ var import_react9 = require("react");
3259
3783
 
3260
3784
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_setCacheAdd.js
3261
3785
  var HASH_UNDEFINED3 = "__lodash_hash_undefined__";
@@ -3372,44 +3896,44 @@ var setToArray_default = setToArray;
3372
3896
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_equalByTag.js
3373
3897
  var COMPARE_PARTIAL_FLAG2 = 1;
3374
3898
  var COMPARE_UNORDERED_FLAG2 = 2;
3375
- var boolTag2 = "[object Boolean]";
3376
- var dateTag2 = "[object Date]";
3377
- var errorTag2 = "[object Error]";
3378
- var mapTag2 = "[object Map]";
3379
- var numberTag2 = "[object Number]";
3380
- var regexpTag2 = "[object RegExp]";
3381
- var setTag2 = "[object Set]";
3382
- var stringTag2 = "[object String]";
3383
- var symbolTag = "[object Symbol]";
3384
- var arrayBufferTag2 = "[object ArrayBuffer]";
3385
- var dataViewTag2 = "[object DataView]";
3386
- var symbolProto = Symbol_default ? Symbol_default.prototype : void 0;
3387
- var symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
3899
+ var boolTag4 = "[object Boolean]";
3900
+ var dateTag4 = "[object Date]";
3901
+ var errorTag3 = "[object Error]";
3902
+ var mapTag6 = "[object Map]";
3903
+ var numberTag4 = "[object Number]";
3904
+ var regexpTag4 = "[object RegExp]";
3905
+ var setTag6 = "[object Set]";
3906
+ var stringTag4 = "[object String]";
3907
+ var symbolTag3 = "[object Symbol]";
3908
+ var arrayBufferTag4 = "[object ArrayBuffer]";
3909
+ var dataViewTag5 = "[object DataView]";
3910
+ var symbolProto2 = Symbol_default ? Symbol_default.prototype : void 0;
3911
+ var symbolValueOf2 = symbolProto2 ? symbolProto2.valueOf : void 0;
3388
3912
  function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
3389
3913
  switch (tag) {
3390
- case dataViewTag2:
3914
+ case dataViewTag5:
3391
3915
  if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
3392
3916
  return false;
3393
3917
  }
3394
3918
  object = object.buffer;
3395
3919
  other = other.buffer;
3396
- case arrayBufferTag2:
3920
+ case arrayBufferTag4:
3397
3921
  if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array_default(object), new Uint8Array_default(other))) {
3398
3922
  return false;
3399
3923
  }
3400
3924
  return true;
3401
- case boolTag2:
3402
- case dateTag2:
3403
- case numberTag2:
3925
+ case boolTag4:
3926
+ case dateTag4:
3927
+ case numberTag4:
3404
3928
  return eq_default(+object, +other);
3405
- case errorTag2:
3929
+ case errorTag3:
3406
3930
  return object.name == other.name && object.message == other.message;
3407
- case regexpTag2:
3408
- case stringTag2:
3931
+ case regexpTag4:
3932
+ case stringTag4:
3409
3933
  return object == other + "";
3410
- case mapTag2:
3934
+ case mapTag6:
3411
3935
  var convert = mapToArray_default;
3412
- case setTag2:
3936
+ case setTag6:
3413
3937
  var isPartial = bitmask & COMPARE_PARTIAL_FLAG2;
3414
3938
  convert || (convert = setToArray_default);
3415
3939
  if (object.size != other.size && !isPartial) {
@@ -3424,103 +3948,19 @@ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
3424
3948
  var result = equalArrays_default(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
3425
3949
  stack["delete"](object);
3426
3950
  return result;
3427
- case symbolTag:
3428
- if (symbolValueOf) {
3429
- return symbolValueOf.call(object) == symbolValueOf.call(other);
3951
+ case symbolTag3:
3952
+ if (symbolValueOf2) {
3953
+ return symbolValueOf2.call(object) == symbolValueOf2.call(other);
3430
3954
  }
3431
3955
  }
3432
3956
  return false;
3433
3957
  }
3434
3958
  var equalByTag_default = equalByTag;
3435
3959
 
3436
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayPush.js
3437
- function arrayPush(array, values) {
3438
- var index = -1, length = values.length, offset = array.length;
3439
- while (++index < length) {
3440
- array[offset + index] = values[index];
3441
- }
3442
- return array;
3443
- }
3444
- var arrayPush_default = arrayPush;
3445
-
3446
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseGetAllKeys.js
3447
- function baseGetAllKeys(object, keysFunc, symbolsFunc) {
3448
- var result = keysFunc(object);
3449
- return isArray_default(object) ? result : arrayPush_default(result, symbolsFunc(object));
3450
- }
3451
- var baseGetAllKeys_default = baseGetAllKeys;
3452
-
3453
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayFilter.js
3454
- function arrayFilter(array, predicate) {
3455
- var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
3456
- while (++index < length) {
3457
- var value = array[index];
3458
- if (predicate(value, index, array)) {
3459
- result[resIndex++] = value;
3460
- }
3461
- }
3462
- return result;
3463
- }
3464
- var arrayFilter_default = arrayFilter;
3465
-
3466
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/stubArray.js
3467
- function stubArray() {
3468
- return [];
3469
- }
3470
- var stubArray_default = stubArray;
3471
-
3472
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getSymbols.js
3473
- var objectProto12 = Object.prototype;
3474
- var propertyIsEnumerable2 = objectProto12.propertyIsEnumerable;
3475
- var nativeGetSymbols = Object.getOwnPropertySymbols;
3476
- var getSymbols = !nativeGetSymbols ? stubArray_default : function(object) {
3477
- if (object == null) {
3478
- return [];
3479
- }
3480
- object = Object(object);
3481
- return arrayFilter_default(nativeGetSymbols(object), function(symbol) {
3482
- return propertyIsEnumerable2.call(object, symbol);
3483
- });
3484
- };
3485
- var getSymbols_default = getSymbols;
3486
-
3487
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeys.js
3488
- var nativeKeys = overArg_default(Object.keys, Object);
3489
- var nativeKeys_default = nativeKeys;
3490
-
3491
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseKeys.js
3492
- var objectProto13 = Object.prototype;
3493
- var hasOwnProperty10 = objectProto13.hasOwnProperty;
3494
- function baseKeys(object) {
3495
- if (!isPrototype_default(object)) {
3496
- return nativeKeys_default(object);
3497
- }
3498
- var result = [];
3499
- for (var key in Object(object)) {
3500
- if (hasOwnProperty10.call(object, key) && key != "constructor") {
3501
- result.push(key);
3502
- }
3503
- }
3504
- return result;
3505
- }
3506
- var baseKeys_default = baseKeys;
3507
-
3508
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/keys.js
3509
- function keys(object) {
3510
- return isArrayLike_default(object) ? arrayLikeKeys_default(object) : baseKeys_default(object);
3511
- }
3512
- var keys_default = keys;
3513
-
3514
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeys.js
3515
- function getAllKeys(object) {
3516
- return baseGetAllKeys_default(object, keys_default, getSymbols_default);
3517
- }
3518
- var getAllKeys_default = getAllKeys;
3519
-
3520
3960
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_equalObjects.js
3521
3961
  var COMPARE_PARTIAL_FLAG3 = 1;
3522
- var objectProto14 = Object.prototype;
3523
- var hasOwnProperty11 = objectProto14.hasOwnProperty;
3962
+ var objectProto15 = Object.prototype;
3963
+ var hasOwnProperty12 = objectProto15.hasOwnProperty;
3524
3964
  function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
3525
3965
  var isPartial = bitmask & COMPARE_PARTIAL_FLAG3, objProps = getAllKeys_default(object), objLength = objProps.length, othProps = getAllKeys_default(other), othLength = othProps.length;
3526
3966
  if (objLength != othLength && !isPartial) {
@@ -3529,7 +3969,7 @@ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
3529
3969
  var index = objLength;
3530
3970
  while (index--) {
3531
3971
  var key = objProps[index];
3532
- if (!(isPartial ? key in other : hasOwnProperty11.call(other, key))) {
3972
+ if (!(isPartial ? key in other : hasOwnProperty12.call(other, key))) {
3533
3973
  return false;
3534
3974
  }
3535
3975
  }
@@ -3566,69 +4006,18 @@ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
3566
4006
  }
3567
4007
  var equalObjects_default = equalObjects;
3568
4008
 
3569
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_DataView.js
3570
- var DataView = getNative_default(root_default, "DataView");
3571
- var DataView_default = DataView;
3572
-
3573
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Promise.js
3574
- var Promise2 = getNative_default(root_default, "Promise");
3575
- var Promise_default = Promise2;
3576
-
3577
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Set.js
3578
- var Set2 = getNative_default(root_default, "Set");
3579
- var Set_default = Set2;
3580
-
3581
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js
3582
- var WeakMap = getNative_default(root_default, "WeakMap");
3583
- var WeakMap_default = WeakMap;
3584
-
3585
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js
3586
- var mapTag3 = "[object Map]";
3587
- var objectTag3 = "[object Object]";
3588
- var promiseTag = "[object Promise]";
3589
- var setTag3 = "[object Set]";
3590
- var weakMapTag2 = "[object WeakMap]";
3591
- var dataViewTag3 = "[object DataView]";
3592
- var dataViewCtorString = toSource_default(DataView_default);
3593
- var mapCtorString = toSource_default(Map_default);
3594
- var promiseCtorString = toSource_default(Promise_default);
3595
- var setCtorString = toSource_default(Set_default);
3596
- var weakMapCtorString = toSource_default(WeakMap_default);
3597
- var getTag = baseGetTag_default;
3598
- if (DataView_default && getTag(new DataView_default(new ArrayBuffer(1))) != dataViewTag3 || Map_default && getTag(new Map_default()) != mapTag3 || Promise_default && getTag(Promise_default.resolve()) != promiseTag || Set_default && getTag(new Set_default()) != setTag3 || WeakMap_default && getTag(new WeakMap_default()) != weakMapTag2) {
3599
- getTag = function(value) {
3600
- var result = baseGetTag_default(value), Ctor = result == objectTag3 ? value.constructor : void 0, ctorString = Ctor ? toSource_default(Ctor) : "";
3601
- if (ctorString) {
3602
- switch (ctorString) {
3603
- case dataViewCtorString:
3604
- return dataViewTag3;
3605
- case mapCtorString:
3606
- return mapTag3;
3607
- case promiseCtorString:
3608
- return promiseTag;
3609
- case setCtorString:
3610
- return setTag3;
3611
- case weakMapCtorString:
3612
- return weakMapTag2;
3613
- }
3614
- }
3615
- return result;
3616
- };
3617
- }
3618
- var getTag_default = getTag;
3619
-
3620
4009
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqualDeep.js
3621
4010
  var COMPARE_PARTIAL_FLAG4 = 1;
3622
- var argsTag3 = "[object Arguments]";
3623
- var arrayTag2 = "[object Array]";
3624
- var objectTag4 = "[object Object]";
3625
- var objectProto15 = Object.prototype;
3626
- var hasOwnProperty12 = objectProto15.hasOwnProperty;
4011
+ var argsTag4 = "[object Arguments]";
4012
+ var arrayTag3 = "[object Array]";
4013
+ var objectTag5 = "[object Object]";
4014
+ var objectProto16 = Object.prototype;
4015
+ var hasOwnProperty13 = objectProto16.hasOwnProperty;
3627
4016
  function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
3628
- var objIsArr = isArray_default(object), othIsArr = isArray_default(other), objTag = objIsArr ? arrayTag2 : getTag_default(object), othTag = othIsArr ? arrayTag2 : getTag_default(other);
3629
- objTag = objTag == argsTag3 ? objectTag4 : objTag;
3630
- othTag = othTag == argsTag3 ? objectTag4 : othTag;
3631
- var objIsObj = objTag == objectTag4, othIsObj = othTag == objectTag4, isSameTag = objTag == othTag;
4017
+ var objIsArr = isArray_default(object), othIsArr = isArray_default(other), objTag = objIsArr ? arrayTag3 : getTag_default(object), othTag = othIsArr ? arrayTag3 : getTag_default(other);
4018
+ objTag = objTag == argsTag4 ? objectTag5 : objTag;
4019
+ othTag = othTag == argsTag4 ? objectTag5 : othTag;
4020
+ var objIsObj = objTag == objectTag5, othIsObj = othTag == objectTag5, isSameTag = objTag == othTag;
3632
4021
  if (isSameTag && isBuffer_default(object)) {
3633
4022
  if (!isBuffer_default(other)) {
3634
4023
  return false;
@@ -3641,7 +4030,7 @@ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
3641
4030
  return objIsArr || isTypedArray_default(object) ? equalArrays_default(object, other, bitmask, customizer, equalFunc, stack) : equalByTag_default(object, other, objTag, bitmask, customizer, equalFunc, stack);
3642
4031
  }
3643
4032
  if (!(bitmask & COMPARE_PARTIAL_FLAG4)) {
3644
- var objIsWrapped = objIsObj && hasOwnProperty12.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty12.call(other, "__wrapped__");
4033
+ var objIsWrapped = objIsObj && hasOwnProperty13.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty13.call(other, "__wrapped__");
3645
4034
  if (objIsWrapped || othIsWrapped) {
3646
4035
  var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
3647
4036
  stack || (stack = new Stack_default());
@@ -3675,9 +4064,9 @@ function isEqual(value, other) {
3675
4064
  var isEqual_default = isEqual;
3676
4065
 
3677
4066
  // src/hooks/useStableValue.ts
3678
- var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react8.useLayoutEffect : import_react8.useEffect;
4067
+ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react9.useLayoutEffect : import_react9.useEffect;
3679
4068
  function useStableValue(value) {
3680
- const ref = (0, import_react8.useRef)(value);
4069
+ const ref = (0, import_react9.useRef)(value);
3681
4070
  const prev = ref.current;
3682
4071
  const stableValue = isEqual_default(prev, value) ? prev : value;
3683
4072
  useIsomorphicLayoutEffect(() => {
@@ -3686,20 +4075,49 @@ function useStableValue(value) {
3686
4075
  return stableValue;
3687
4076
  }
3688
4077
 
4078
+ // src/hooks/useReferenceFlipWarning.ts
4079
+ var import_react10 = require("react");
4080
+ var __DEV__ = typeof process !== "undefined" && process.env.NODE_ENV !== "production";
4081
+ var FLIP_THRESHOLD = 3;
4082
+ var WARN_COOLDOWN_MS = 5e3;
4083
+ function trackFlip(state, value, propName, now) {
4084
+ if (state.prev === value) return;
4085
+ state.flips++;
4086
+ state.prev = value;
4087
+ if (state.flips < FLIP_THRESHOLD) return;
4088
+ if (now - state.lastWarnAt < WARN_COOLDOWN_MS) return;
4089
+ state.lastWarnAt = now;
4090
+ console.warn(
4091
+ `[AIMarkdown] \`${propName}\` reference is changing on every render. Define it at module scope or wrap with useMemo/useCallback to avoid discarding the per-block memo cache on every parent re-render.`
4092
+ );
4093
+ }
4094
+ function useReferenceFlipWarning(value, propName) {
4095
+ const stateRef = (0, import_react10.useRef)({ prev: value, flips: 0, lastWarnAt: -Infinity });
4096
+ if (!__DEV__) return;
4097
+ trackFlip(stateRef.current, value, propName, Date.now());
4098
+ }
4099
+
3689
4100
  // src/components/typography/Default.tsx
3690
- var import_react9 = require("react");
4101
+ var import_react11 = require("react");
3691
4102
  var import_jsx_runtime7 = require("react/jsx-runtime");
3692
- var DefaultTypography = (0, import_react9.memo)(({ children, fontSize, variant, colorScheme, style }) => {
3693
- const className = (0, import_react9.useMemo)(
4103
+ var DefaultTypography = (0, import_react11.memo)(({ children, fontSize, variant, colorScheme, style }) => {
4104
+ const className = (0, import_react11.useMemo)(
3694
4105
  () => ["aim-typography-root", variant, colorScheme].filter(Boolean).join(" "),
3695
4106
  [variant, colorScheme]
3696
4107
  );
3697
- const mergedStyle = (0, import_react9.useMemo)(() => ({ width: "100%", fontSize, ...style }), [fontSize, style]);
4108
+ const mergedStyle = (0, import_react11.useMemo)(() => ({ width: "100%", fontSize, ...style }), [fontSize, style]);
3698
4109
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className, style: mergedStyle, children });
3699
4110
  });
3700
4111
  DefaultTypography.displayName = "DefaultTypography";
3701
4112
  var Default_default = DefaultTypography;
3702
4113
 
4114
+ // src/components/extendSanitizeSchema.ts
4115
+ function extendSanitizeSchema(modifier) {
4116
+ const draft = cloneDeep_default(sanitizeSchema);
4117
+ const result = modifier(draft);
4118
+ return result ?? draft;
4119
+ }
4120
+
3703
4121
  // src/index.tsx
3704
4122
  var import_jsx_runtime8 = require("react/jsx-runtime");
3705
4123
  var AIMarkdownComponent = ({
@@ -3715,20 +4133,25 @@ var AIMarkdownComponent = ({
3715
4133
  ExtraStyles,
3716
4134
  variant = "default",
3717
4135
  colorScheme = "light",
3718
- documentId
4136
+ documentId,
4137
+ urlTransform,
4138
+ sanitizeSchema: sanitizeSchema2
3719
4139
  }) => {
3720
4140
  const usedFontSize = fontSize === void 0 ? "0.9375rem" : typeof fontSize === "number" ? `${fontSize}px` : fontSize;
3721
- const generatedId = (0, import_react10.useId)();
4141
+ const generatedId = (0, import_react12.useId)();
3722
4142
  const usedDocumentId = documentId && documentId.length > 0 ? documentId : generatedId;
4143
+ useReferenceFlipWarning(urlTransform, "urlTransform");
4144
+ useReferenceFlipWarning(sanitizeSchema2, "sanitizeSchema");
3723
4145
  const stableDefaultConfig = useStableValue(defaultConfig);
3724
4146
  const stableConfig = useStableValue(config);
3725
4147
  const stablePreprocessors = useStableValue(contentPreprocessors);
3726
4148
  const stableCustomComponents = useStableValue(customComponents);
3727
- const usedContent = (0, import_react10.useMemo)(
4149
+ const stableSanitizeSchema = useStableValue(sanitizeSchema2);
4150
+ const usedContent = (0, import_react12.useMemo)(
3728
4151
  () => content ? preprocessAIMDContent(content, stablePreprocessors) : content,
3729
4152
  [content, stablePreprocessors]
3730
4153
  );
3731
- const typographyStyle = (0, import_react10.useMemo)(() => ({ "--aim-font-size-root": usedFontSize }), [usedFontSize]);
4154
+ const typographyStyle = (0, import_react12.useMemo)(() => ({ "--aim-font-size-root": usedFontSize }), [usedFontSize]);
3732
4155
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AIMarkdownMetadataProvider, { metadata, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3733
4156
  context_default,
3734
4157
  {
@@ -3746,13 +4169,29 @@ var AIMarkdownComponent = ({
3746
4169
  variant,
3747
4170
  colorScheme,
3748
4171
  style: typographyStyle,
3749
- children: ExtraStyles ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ExtraStyles, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(MarkdownContent_default, { content: usedContent, customComponents: stableCustomComponents }) }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(MarkdownContent_default, { content: usedContent, customComponents: stableCustomComponents })
4172
+ children: ExtraStyles ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ExtraStyles, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4173
+ MarkdownContent_default,
4174
+ {
4175
+ content: usedContent,
4176
+ customComponents: stableCustomComponents,
4177
+ urlTransform: urlTransform ?? void 0,
4178
+ sanitizeSchema: stableSanitizeSchema
4179
+ }
4180
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4181
+ MarkdownContent_default,
4182
+ {
4183
+ content: usedContent,
4184
+ customComponents: stableCustomComponents,
4185
+ urlTransform: urlTransform ?? void 0,
4186
+ sanitizeSchema: stableSanitizeSchema
4187
+ }
4188
+ )
3750
4189
  }
3751
4190
  )
3752
4191
  }
3753
4192
  ) });
3754
4193
  };
3755
- var AIMarkdown = (0, import_react10.memo)(AIMarkdownComponent);
4194
+ var AIMarkdown = (0, import_react12.memo)(AIMarkdownComponent);
3756
4195
  AIMarkdown.displayName = "AIMarkdown";
3757
4196
  var index_default = AIMarkdown;
3758
4197
  // Annotate the CommonJS export names for ESM import in node:
@@ -3761,6 +4200,8 @@ var index_default = AIMarkdown;
3761
4200
  AIMarkdownRenderDisplayOptimizeAbility,
3762
4201
  AIMarkdownRenderExtraSyntax,
3763
4202
  defaultAIMarkdownRenderConfig,
4203
+ defaultUrlTransform,
4204
+ extendSanitizeSchema,
3764
4205
  useAIMarkdownMetadata,
3765
4206
  useAIMarkdownRenderState,
3766
4207
  useDocumentRegistry,