@ai-react-markdown/core 1.4.2 → 1.4.3

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,16 @@ __export(index_exports, {
36
36
  AIMarkdownRenderExtraSyntax: () => AIMarkdownRenderExtraSyntax,
37
37
  default: () => index_default,
38
38
  defaultAIMarkdownRenderConfig: () => defaultAIMarkdownRenderConfig,
39
+ defaultUrlTransform: () => defaultUrlTransform,
40
+ extendSanitizeSchema: () => extendSanitizeSchema,
41
+ sanitizeSchema: () => sanitizeSchema,
39
42
  useAIMarkdownMetadata: () => useAIMarkdownMetadata,
40
43
  useAIMarkdownRenderState: () => useAIMarkdownRenderState,
41
44
  useDocumentRegistry: () => useDocumentRegistry,
42
45
  useStableValue: () => useStableValue
43
46
  });
44
47
  module.exports = __toCommonJS(index_exports);
45
- var import_react10 = require("react");
48
+ var import_react11 = require("react");
46
49
 
47
50
  // src/context.tsx
48
51
  var import_react = require("react");
@@ -2899,8 +2902,7 @@ var ExtraSyntaxRemarkPluginMap = {
2899
2902
  };
2900
2903
  var DefaultCustomComponents = {};
2901
2904
  var BlockMemoizedRenderer = (0, import_react7.memo)(
2902
- ({ content, usedComponents, remarkPlugins, rehypePlugins, remarkRehypeOptions }) => {
2903
- const urlTransform = void 0;
2905
+ ({ content, usedComponents, remarkPlugins, rehypePlugins, remarkRehypeOptions, urlTransform }) => {
2904
2906
  const allowedElements = void 0;
2905
2907
  const disallowedElements = void 0;
2906
2908
  const allowElement = void 0;
@@ -3149,108 +3151,116 @@ var BlockMemoizedRenderer = (0, import_react7.memo)(
3149
3151
  );
3150
3152
  BlockMemoizedRenderer.displayName = "BlockMemoizedRenderer";
3151
3153
  var LegacyRenderer = (0, import_react7.memo)(
3152
- ({ content, usedComponents, remarkPlugins, rehypePlugins, remarkRehypeOptions }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3154
+ ({ content, usedComponents, remarkPlugins, rehypePlugins, remarkRehypeOptions, urlTransform }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3153
3155
  Markdown_default,
3154
3156
  {
3155
3157
  remarkPlugins,
3156
3158
  rehypePlugins,
3157
3159
  remarkRehypeOptions,
3158
3160
  components: usedComponents,
3161
+ urlTransform,
3159
3162
  children: content
3160
3163
  }
3161
3164
  )
3162
3165
  );
3163
3166
  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
- }
3167
+ var AIMarkdownContent = (0, import_react7.memo)(
3168
+ ({ content, customComponents, urlTransform, sanitizeSchema: customSanitizeSchema }) => {
3169
+ const { config, clobberPrefix } = useAIMarkdownRenderState();
3170
+ const usedSanitizeSchema = customSanitizeSchema ?? sanitizeSchema;
3171
+ const { extraSyntaxRemarkPlugins, enableDefinitionList } = (0, import_react7.useMemo)(
3172
+ () => ({
3173
+ extraSyntaxRemarkPlugins: config.extraSyntaxSupported.map((syntax) => ExtraSyntaxRemarkPluginMap[syntax]),
3174
+ enableDefinitionList: config.extraSyntaxSupported.includes("DEFINITION_LIST" /* DEFINITION_LIST */)
3175
+ }),
3176
+ [config.extraSyntaxSupported]
3177
+ );
3178
+ const displayOptimizeRemarkPlugins = (0, import_react7.useMemo)(() => {
3179
+ return config.displayOptimizeAbilities.map((ability) => DisplayOptimizeRemarkPluginMap[ability]);
3180
+ }, [config.displayOptimizeAbilities]);
3181
+ const usedComponents = (0, import_react7.useMemo)(() => {
3182
+ return customComponents ? { ...DefaultCustomComponents, ...customComponents } : DefaultCustomComponents;
3183
+ }, [customComponents]);
3184
+ const remarkPlugins = (0, import_react7.useMemo)(
3185
+ () => [
3186
+ // --- Core plugins (always active) ---
3187
+ import_remark_gfm2.default,
3188
+ [
3189
+ import_remark_math.default,
3190
+ {
3191
+ // Disable single-dollar inline math to avoid conflicts with currency
3192
+ // signs and other dollar usages; the preprocessor converts $...$ to $$...$$.
3193
+ singleDollarTextMath: false
3194
+ }
3195
+ ],
3196
+ // --- Configurable extra syntax plugins ---
3197
+ ...extraSyntaxRemarkPlugins,
3198
+ // --- Formatting & normalization ---
3199
+ import_remark_breaks.default,
3200
+ import_remark_emoji.default,
3201
+ import_remark_squeeze_paragraphs.default,
3202
+ import_remark_cjk_friendly.default,
3203
+ import_remark_cjk_friendly_gfm_strikethrough.default,
3204
+ // --- Configurable display optimizations ---
3205
+ ...displayOptimizeRemarkPlugins
3190
3206
  ],
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 : {}
3207
+ [extraSyntaxRemarkPlugins, displayOptimizeRemarkPlugins]
3208
+ );
3209
+ const rehypePlugins = (0, import_react7.useMemo)(
3210
+ () => [
3211
+ // Allow raw HTML through so rehype-sanitize can handle it.
3212
+ [import_rehype_raw.default, { passThrough: [] }],
3213
+ // Sanitize HTML while allowing <mark> (highlight), KaTeX class names,
3214
+ // and any extra protocols the caller permitted via the `sanitizeSchema`
3215
+ // prop. Override `clobberPrefix` with the instance-scoped value so every
3216
+ // id and clobberable attribute is namespaced to this `<AIMarkdown>`
3217
+ // instance — the spread order is intentional: our prefix wins over any
3218
+ // caller-supplied prefix on the schema.
3219
+ [import_rehype_sanitize2.default, { ...usedSanitizeSchema, clobberPrefix }],
3220
+ // Normalize the auto-generated `<section data-footnotes>`: strip the
3221
+ // sr-only `<h2>Footnotes</h2>` label and prepend `<hr>`. Keeps standalone
3222
+ // single-doc rendering visually consistent with the cross-chunk aggregate
3223
+ // footer (which builds the same shape from scratch).
3224
+ rehypeFooterAdorn,
3225
+ // Re-prefix intra-document hash hrefs so they match the ids that
3226
+ // rehype-sanitize just clobbered. Must use the SAME prefix as the schema
3227
+ // above that's why both read from `clobberPrefix`.
3228
+ [rehypeRebaseHashLinks_default, { prefix: clobberPrefix }],
3229
+ import_rehype_katex.default,
3230
+ import_rehype_unwrap_images.default
3231
+ ],
3232
+ [clobberPrefix, usedSanitizeSchema]
3233
+ );
3234
+ const remarkRehypeOptions = (0, import_react7.useMemo)(
3235
+ () => ({
3236
+ allowDangerousHtml: true,
3237
+ // Suppress mdast-util-to-hast's `user-content-` prefix on footnote
3238
+ // ids/hrefs; rehype-sanitize will apply the same prefix downstream
3239
+ // and `rehypeRebaseHashLinks` mirrors it onto matching hash hrefs.
3240
+ // Without this, ids would end up double-prefixed
3241
+ // (`user-content-user-content-fn-x`).
3242
+ clobberPrefix: "",
3243
+ handlers: {
3244
+ // Inject definition-list HAST handlers when the extension is active.
3245
+ ...enableDefinitionList ? import_remark_definition_list.defListHastHandlers : {}
3246
+ }
3247
+ }),
3248
+ [enableDefinitionList]
3249
+ );
3250
+ const Renderer = config.blockMemoEnabled ? BlockMemoizedRenderer : LegacyRenderer;
3251
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3252
+ Renderer,
3253
+ {
3254
+ content,
3255
+ usedComponents,
3256
+ remarkPlugins,
3257
+ rehypePlugins,
3258
+ remarkRehypeOptions,
3259
+ urlTransform
3238
3260
  }
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
- });
3261
+ );
3262
+ }
3263
+ );
3254
3264
  AIMarkdownContent.displayName = "AIMarkdownContent";
3255
3265
  var MarkdownContent_default = AIMarkdownContent;
3256
3266
 
@@ -3686,20 +3696,322 @@ function useStableValue(value) {
3686
3696
  return stableValue;
3687
3697
  }
3688
3698
 
3689
- // src/components/typography/Default.tsx
3699
+ // src/hooks/useReferenceFlipWarning.ts
3690
3700
  var import_react9 = require("react");
3701
+ var __DEV__ = typeof process !== "undefined" && process.env.NODE_ENV !== "production";
3702
+ var FLIP_THRESHOLD = 3;
3703
+ var WARN_COOLDOWN_MS = 5e3;
3704
+ function trackFlip(state, value, propName, now) {
3705
+ if (state.prev === value) return;
3706
+ state.flips++;
3707
+ state.prev = value;
3708
+ if (state.flips < FLIP_THRESHOLD) return;
3709
+ if (now - state.lastWarnAt < WARN_COOLDOWN_MS) return;
3710
+ state.lastWarnAt = now;
3711
+ console.warn(
3712
+ `[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.`
3713
+ );
3714
+ }
3715
+ function useReferenceFlipWarning(value, propName) {
3716
+ const stateRef = (0, import_react9.useRef)({ prev: value, flips: 0, lastWarnAt: -Infinity });
3717
+ if (!__DEV__) return;
3718
+ trackFlip(stateRef.current, value, propName, Date.now());
3719
+ }
3720
+
3721
+ // src/components/typography/Default.tsx
3722
+ var import_react10 = require("react");
3691
3723
  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)(
3724
+ var DefaultTypography = (0, import_react10.memo)(({ children, fontSize, variant, colorScheme, style }) => {
3725
+ const className = (0, import_react10.useMemo)(
3694
3726
  () => ["aim-typography-root", variant, colorScheme].filter(Boolean).join(" "),
3695
3727
  [variant, colorScheme]
3696
3728
  );
3697
- const mergedStyle = (0, import_react9.useMemo)(() => ({ width: "100%", fontSize, ...style }), [fontSize, style]);
3729
+ const mergedStyle = (0, import_react10.useMemo)(() => ({ width: "100%", fontSize, ...style }), [fontSize, style]);
3698
3730
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className, style: mergedStyle, children });
3699
3731
  });
3700
3732
  DefaultTypography.displayName = "DefaultTypography";
3701
3733
  var Default_default = DefaultTypography;
3702
3734
 
3735
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayEach.js
3736
+ function arrayEach(array, iteratee) {
3737
+ var index = -1, length = array == null ? 0 : array.length;
3738
+ while (++index < length) {
3739
+ if (iteratee(array[index], index, array) === false) {
3740
+ break;
3741
+ }
3742
+ }
3743
+ return array;
3744
+ }
3745
+ var arrayEach_default = arrayEach;
3746
+
3747
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseAssign.js
3748
+ function baseAssign(object, source) {
3749
+ return object && copyObject_default(source, keys_default(source), object);
3750
+ }
3751
+ var baseAssign_default = baseAssign;
3752
+
3753
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignIn.js
3754
+ function baseAssignIn(object, source) {
3755
+ return object && copyObject_default(source, keysIn_default(source), object);
3756
+ }
3757
+ var baseAssignIn_default = baseAssignIn;
3758
+
3759
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_copySymbols.js
3760
+ function copySymbols(source, object) {
3761
+ return copyObject_default(source, getSymbols_default(source), object);
3762
+ }
3763
+ var copySymbols_default = copySymbols;
3764
+
3765
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getSymbolsIn.js
3766
+ var nativeGetSymbols2 = Object.getOwnPropertySymbols;
3767
+ var getSymbolsIn = !nativeGetSymbols2 ? stubArray_default : function(object) {
3768
+ var result = [];
3769
+ while (object) {
3770
+ arrayPush_default(result, getSymbols_default(object));
3771
+ object = getPrototype_default(object);
3772
+ }
3773
+ return result;
3774
+ };
3775
+ var getSymbolsIn_default = getSymbolsIn;
3776
+
3777
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_copySymbolsIn.js
3778
+ function copySymbolsIn(source, object) {
3779
+ return copyObject_default(source, getSymbolsIn_default(source), object);
3780
+ }
3781
+ var copySymbolsIn_default = copySymbolsIn;
3782
+
3783
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeysIn.js
3784
+ function getAllKeysIn(object) {
3785
+ return baseGetAllKeys_default(object, keysIn_default, getSymbolsIn_default);
3786
+ }
3787
+ var getAllKeysIn_default = getAllKeysIn;
3788
+
3789
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_initCloneArray.js
3790
+ var objectProto16 = Object.prototype;
3791
+ var hasOwnProperty13 = objectProto16.hasOwnProperty;
3792
+ function initCloneArray(array) {
3793
+ var length = array.length, result = new array.constructor(length);
3794
+ if (length && typeof array[0] == "string" && hasOwnProperty13.call(array, "index")) {
3795
+ result.index = array.index;
3796
+ result.input = array.input;
3797
+ }
3798
+ return result;
3799
+ }
3800
+ var initCloneArray_default = initCloneArray;
3801
+
3802
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneDataView.js
3803
+ function cloneDataView(dataView, isDeep) {
3804
+ var buffer = isDeep ? cloneArrayBuffer_default(dataView.buffer) : dataView.buffer;
3805
+ return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
3806
+ }
3807
+ var cloneDataView_default = cloneDataView;
3808
+
3809
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneRegExp.js
3810
+ var reFlags = /\w*$/;
3811
+ function cloneRegExp(regexp) {
3812
+ var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
3813
+ result.lastIndex = regexp.lastIndex;
3814
+ return result;
3815
+ }
3816
+ var cloneRegExp_default = cloneRegExp;
3817
+
3818
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneSymbol.js
3819
+ var symbolProto2 = Symbol_default ? Symbol_default.prototype : void 0;
3820
+ var symbolValueOf2 = symbolProto2 ? symbolProto2.valueOf : void 0;
3821
+ function cloneSymbol(symbol) {
3822
+ return symbolValueOf2 ? Object(symbolValueOf2.call(symbol)) : {};
3823
+ }
3824
+ var cloneSymbol_default = cloneSymbol;
3825
+
3826
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_initCloneByTag.js
3827
+ var boolTag3 = "[object Boolean]";
3828
+ var dateTag3 = "[object Date]";
3829
+ var mapTag4 = "[object Map]";
3830
+ var numberTag3 = "[object Number]";
3831
+ var regexpTag3 = "[object RegExp]";
3832
+ var setTag4 = "[object Set]";
3833
+ var stringTag3 = "[object String]";
3834
+ var symbolTag2 = "[object Symbol]";
3835
+ var arrayBufferTag3 = "[object ArrayBuffer]";
3836
+ var dataViewTag4 = "[object DataView]";
3837
+ var float32Tag2 = "[object Float32Array]";
3838
+ var float64Tag2 = "[object Float64Array]";
3839
+ var int8Tag2 = "[object Int8Array]";
3840
+ var int16Tag2 = "[object Int16Array]";
3841
+ var int32Tag2 = "[object Int32Array]";
3842
+ var uint8Tag2 = "[object Uint8Array]";
3843
+ var uint8ClampedTag2 = "[object Uint8ClampedArray]";
3844
+ var uint16Tag2 = "[object Uint16Array]";
3845
+ var uint32Tag2 = "[object Uint32Array]";
3846
+ function initCloneByTag(object, tag, isDeep) {
3847
+ var Ctor = object.constructor;
3848
+ switch (tag) {
3849
+ case arrayBufferTag3:
3850
+ return cloneArrayBuffer_default(object);
3851
+ case boolTag3:
3852
+ case dateTag3:
3853
+ return new Ctor(+object);
3854
+ case dataViewTag4:
3855
+ return cloneDataView_default(object, isDeep);
3856
+ case float32Tag2:
3857
+ case float64Tag2:
3858
+ case int8Tag2:
3859
+ case int16Tag2:
3860
+ case int32Tag2:
3861
+ case uint8Tag2:
3862
+ case uint8ClampedTag2:
3863
+ case uint16Tag2:
3864
+ case uint32Tag2:
3865
+ return cloneTypedArray_default(object, isDeep);
3866
+ case mapTag4:
3867
+ return new Ctor();
3868
+ case numberTag3:
3869
+ case stringTag3:
3870
+ return new Ctor(object);
3871
+ case regexpTag3:
3872
+ return cloneRegExp_default(object);
3873
+ case setTag4:
3874
+ return new Ctor();
3875
+ case symbolTag2:
3876
+ return cloneSymbol_default(object);
3877
+ }
3878
+ }
3879
+ var initCloneByTag_default = initCloneByTag;
3880
+
3881
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsMap.js
3882
+ var mapTag5 = "[object Map]";
3883
+ function baseIsMap(value) {
3884
+ return isObjectLike_default(value) && getTag_default(value) == mapTag5;
3885
+ }
3886
+ var baseIsMap_default = baseIsMap;
3887
+
3888
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isMap.js
3889
+ var nodeIsMap = nodeUtil_default && nodeUtil_default.isMap;
3890
+ var isMap = nodeIsMap ? baseUnary_default(nodeIsMap) : baseIsMap_default;
3891
+ var isMap_default = isMap;
3892
+
3893
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsSet.js
3894
+ var setTag5 = "[object Set]";
3895
+ function baseIsSet(value) {
3896
+ return isObjectLike_default(value) && getTag_default(value) == setTag5;
3897
+ }
3898
+ var baseIsSet_default = baseIsSet;
3899
+
3900
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isSet.js
3901
+ var nodeIsSet = nodeUtil_default && nodeUtil_default.isSet;
3902
+ var isSet = nodeIsSet ? baseUnary_default(nodeIsSet) : baseIsSet_default;
3903
+ var isSet_default = isSet;
3904
+
3905
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseClone.js
3906
+ var CLONE_DEEP_FLAG = 1;
3907
+ var CLONE_FLAT_FLAG = 2;
3908
+ var CLONE_SYMBOLS_FLAG = 4;
3909
+ var argsTag4 = "[object Arguments]";
3910
+ var arrayTag3 = "[object Array]";
3911
+ var boolTag4 = "[object Boolean]";
3912
+ var dateTag4 = "[object Date]";
3913
+ var errorTag3 = "[object Error]";
3914
+ var funcTag3 = "[object Function]";
3915
+ var genTag2 = "[object GeneratorFunction]";
3916
+ var mapTag6 = "[object Map]";
3917
+ var numberTag4 = "[object Number]";
3918
+ var objectTag5 = "[object Object]";
3919
+ var regexpTag4 = "[object RegExp]";
3920
+ var setTag6 = "[object Set]";
3921
+ var stringTag4 = "[object String]";
3922
+ var symbolTag3 = "[object Symbol]";
3923
+ var weakMapTag3 = "[object WeakMap]";
3924
+ var arrayBufferTag4 = "[object ArrayBuffer]";
3925
+ var dataViewTag5 = "[object DataView]";
3926
+ var float32Tag3 = "[object Float32Array]";
3927
+ var float64Tag3 = "[object Float64Array]";
3928
+ var int8Tag3 = "[object Int8Array]";
3929
+ var int16Tag3 = "[object Int16Array]";
3930
+ var int32Tag3 = "[object Int32Array]";
3931
+ var uint8Tag3 = "[object Uint8Array]";
3932
+ var uint8ClampedTag3 = "[object Uint8ClampedArray]";
3933
+ var uint16Tag3 = "[object Uint16Array]";
3934
+ var uint32Tag3 = "[object Uint32Array]";
3935
+ var cloneableTags = {};
3936
+ cloneableTags[argsTag4] = cloneableTags[arrayTag3] = cloneableTags[arrayBufferTag4] = cloneableTags[dataViewTag5] = cloneableTags[boolTag4] = cloneableTags[dateTag4] = cloneableTags[float32Tag3] = cloneableTags[float64Tag3] = cloneableTags[int8Tag3] = cloneableTags[int16Tag3] = cloneableTags[int32Tag3] = cloneableTags[mapTag6] = cloneableTags[numberTag4] = cloneableTags[objectTag5] = cloneableTags[regexpTag4] = cloneableTags[setTag6] = cloneableTags[stringTag4] = cloneableTags[symbolTag3] = cloneableTags[uint8Tag3] = cloneableTags[uint8ClampedTag3] = cloneableTags[uint16Tag3] = cloneableTags[uint32Tag3] = true;
3937
+ cloneableTags[errorTag3] = cloneableTags[funcTag3] = cloneableTags[weakMapTag3] = false;
3938
+ function baseClone(value, bitmask, customizer, key, object, stack) {
3939
+ var result, isDeep = bitmask & CLONE_DEEP_FLAG, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG;
3940
+ if (customizer) {
3941
+ result = object ? customizer(value, key, object, stack) : customizer(value);
3942
+ }
3943
+ if (result !== void 0) {
3944
+ return result;
3945
+ }
3946
+ if (!isObject_default(value)) {
3947
+ return value;
3948
+ }
3949
+ var isArr = isArray_default(value);
3950
+ if (isArr) {
3951
+ result = initCloneArray_default(value);
3952
+ if (!isDeep) {
3953
+ return copyArray_default(value, result);
3954
+ }
3955
+ } else {
3956
+ var tag = getTag_default(value), isFunc = tag == funcTag3 || tag == genTag2;
3957
+ if (isBuffer_default(value)) {
3958
+ return cloneBuffer_default(value, isDeep);
3959
+ }
3960
+ if (tag == objectTag5 || tag == argsTag4 || isFunc && !object) {
3961
+ result = isFlat || isFunc ? {} : initCloneObject_default(value);
3962
+ if (!isDeep) {
3963
+ return isFlat ? copySymbolsIn_default(value, baseAssignIn_default(result, value)) : copySymbols_default(value, baseAssign_default(result, value));
3964
+ }
3965
+ } else {
3966
+ if (!cloneableTags[tag]) {
3967
+ return object ? value : {};
3968
+ }
3969
+ result = initCloneByTag_default(value, tag, isDeep);
3970
+ }
3971
+ }
3972
+ stack || (stack = new Stack_default());
3973
+ var stacked = stack.get(value);
3974
+ if (stacked) {
3975
+ return stacked;
3976
+ }
3977
+ stack.set(value, result);
3978
+ if (isSet_default(value)) {
3979
+ value.forEach(function(subValue) {
3980
+ result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
3981
+ });
3982
+ } else if (isMap_default(value)) {
3983
+ value.forEach(function(subValue, key2) {
3984
+ result.set(key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
3985
+ });
3986
+ }
3987
+ var keysFunc = isFull ? isFlat ? getAllKeysIn_default : getAllKeys_default : isFlat ? keysIn_default : keys_default;
3988
+ var props = isArr ? void 0 : keysFunc(value);
3989
+ arrayEach_default(props || value, function(subValue, key2) {
3990
+ if (props) {
3991
+ key2 = subValue;
3992
+ subValue = value[key2];
3993
+ }
3994
+ assignValue_default(result, key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
3995
+ });
3996
+ return result;
3997
+ }
3998
+ var baseClone_default = baseClone;
3999
+
4000
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/cloneDeep.js
4001
+ var CLONE_DEEP_FLAG2 = 1;
4002
+ var CLONE_SYMBOLS_FLAG2 = 4;
4003
+ function cloneDeep(value) {
4004
+ return baseClone_default(value, CLONE_DEEP_FLAG2 | CLONE_SYMBOLS_FLAG2);
4005
+ }
4006
+ var cloneDeep_default = cloneDeep;
4007
+
4008
+ // src/components/extendSanitizeSchema.ts
4009
+ function extendSanitizeSchema(modifier) {
4010
+ const draft = cloneDeep_default(sanitizeSchema);
4011
+ const result = modifier(draft);
4012
+ return result ?? draft;
4013
+ }
4014
+
3703
4015
  // src/index.tsx
3704
4016
  var import_jsx_runtime8 = require("react/jsx-runtime");
3705
4017
  var AIMarkdownComponent = ({
@@ -3715,20 +4027,25 @@ var AIMarkdownComponent = ({
3715
4027
  ExtraStyles,
3716
4028
  variant = "default",
3717
4029
  colorScheme = "light",
3718
- documentId
4030
+ documentId,
4031
+ urlTransform,
4032
+ sanitizeSchema: sanitizeSchema2
3719
4033
  }) => {
3720
4034
  const usedFontSize = fontSize === void 0 ? "0.9375rem" : typeof fontSize === "number" ? `${fontSize}px` : fontSize;
3721
- const generatedId = (0, import_react10.useId)();
4035
+ const generatedId = (0, import_react11.useId)();
3722
4036
  const usedDocumentId = documentId && documentId.length > 0 ? documentId : generatedId;
4037
+ useReferenceFlipWarning(urlTransform, "urlTransform");
4038
+ useReferenceFlipWarning(sanitizeSchema2, "sanitizeSchema");
3723
4039
  const stableDefaultConfig = useStableValue(defaultConfig);
3724
4040
  const stableConfig = useStableValue(config);
3725
4041
  const stablePreprocessors = useStableValue(contentPreprocessors);
3726
4042
  const stableCustomComponents = useStableValue(customComponents);
3727
- const usedContent = (0, import_react10.useMemo)(
4043
+ const stableSanitizeSchema = useStableValue(sanitizeSchema2);
4044
+ const usedContent = (0, import_react11.useMemo)(
3728
4045
  () => content ? preprocessAIMDContent(content, stablePreprocessors) : content,
3729
4046
  [content, stablePreprocessors]
3730
4047
  );
3731
- const typographyStyle = (0, import_react10.useMemo)(() => ({ "--aim-font-size-root": usedFontSize }), [usedFontSize]);
4048
+ const typographyStyle = (0, import_react11.useMemo)(() => ({ "--aim-font-size-root": usedFontSize }), [usedFontSize]);
3732
4049
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AIMarkdownMetadataProvider, { metadata, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3733
4050
  context_default,
3734
4051
  {
@@ -3746,13 +4063,29 @@ var AIMarkdownComponent = ({
3746
4063
  variant,
3747
4064
  colorScheme,
3748
4065
  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 })
4066
+ children: ExtraStyles ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ExtraStyles, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4067
+ MarkdownContent_default,
4068
+ {
4069
+ content: usedContent,
4070
+ customComponents: stableCustomComponents,
4071
+ urlTransform: urlTransform ?? void 0,
4072
+ sanitizeSchema: stableSanitizeSchema
4073
+ }
4074
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4075
+ MarkdownContent_default,
4076
+ {
4077
+ content: usedContent,
4078
+ customComponents: stableCustomComponents,
4079
+ urlTransform: urlTransform ?? void 0,
4080
+ sanitizeSchema: stableSanitizeSchema
4081
+ }
4082
+ )
3750
4083
  }
3751
4084
  )
3752
4085
  }
3753
4086
  ) });
3754
4087
  };
3755
- var AIMarkdown = (0, import_react10.memo)(AIMarkdownComponent);
4088
+ var AIMarkdown = (0, import_react11.memo)(AIMarkdownComponent);
3756
4089
  AIMarkdown.displayName = "AIMarkdown";
3757
4090
  var index_default = AIMarkdown;
3758
4091
  // Annotate the CommonJS export names for ESM import in node:
@@ -3761,6 +4094,9 @@ var index_default = AIMarkdown;
3761
4094
  AIMarkdownRenderDisplayOptimizeAbility,
3762
4095
  AIMarkdownRenderExtraSyntax,
3763
4096
  defaultAIMarkdownRenderConfig,
4097
+ defaultUrlTransform,
4098
+ extendSanitizeSchema,
4099
+ sanitizeSchema,
3764
4100
  useAIMarkdownMetadata,
3765
4101
  useAIMarkdownRenderState,
3766
4102
  useDocumentRegistry,