@ai-react-markdown/core 1.2.8 → 1.3.0

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.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
 
3
3
  // src/index.tsx
4
- import { useMemo as useMemo3, memo as memo3 } from "react";
4
+ import { useMemo as useMemo4, memo as memo3, useId as useId2 } from "react";
5
5
 
6
6
  // src/context.tsx
7
- import { createContext, useContext, useMemo } from "react";
7
+ import { createContext, useContext, useId, useMemo } from "react";
8
8
 
9
9
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_listCacheClear.js
10
10
  function listCacheClear() {
@@ -262,8 +262,8 @@ function getNative(object, key) {
262
262
  var getNative_default = getNative;
263
263
 
264
264
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Map.js
265
- var Map = getNative_default(root_default, "Map");
266
- var Map_default = Map;
265
+ var Map2 = getNative_default(root_default, "Map");
266
+ var Map_default = Map2;
267
267
 
268
268
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_nativeCreate.js
269
269
  var nativeCreate = getNative_default(Object, "create");
@@ -434,504 +434,74 @@ Stack.prototype.has = stackHas_default;
434
434
  Stack.prototype.set = stackSet_default;
435
435
  var Stack_default = Stack;
436
436
 
437
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayEach.js
438
- function arrayEach(array, iteratee) {
439
- var index = -1, length = array == null ? 0 : array.length;
440
- while (++index < length) {
441
- if (iteratee(array[index], index, array) === false) {
442
- break;
443
- }
444
- }
445
- return array;
446
- }
447
- var arrayEach_default = arrayEach;
448
-
449
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_defineProperty.js
450
- var defineProperty = (function() {
451
- try {
452
- var func = getNative_default(Object, "defineProperty");
453
- func({}, "", {});
454
- return func;
455
- } catch (e) {
456
- }
457
- })();
458
- var defineProperty_default = defineProperty;
459
-
460
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignValue.js
461
- function baseAssignValue(object, key, value) {
462
- if (key == "__proto__" && defineProperty_default) {
463
- defineProperty_default(object, key, {
464
- "configurable": true,
465
- "enumerable": true,
466
- "value": value,
467
- "writable": true
468
- });
469
- } else {
470
- object[key] = value;
471
- }
472
- }
473
- var baseAssignValue_default = baseAssignValue;
474
-
475
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_assignValue.js
476
- var objectProto6 = Object.prototype;
477
- var hasOwnProperty5 = objectProto6.hasOwnProperty;
478
- function assignValue(object, key, value) {
479
- var objValue = object[key];
480
- if (!(hasOwnProperty5.call(object, key) && eq_default(objValue, value)) || value === void 0 && !(key in object)) {
481
- baseAssignValue_default(object, key, value);
482
- }
483
- }
484
- var assignValue_default = assignValue;
485
-
486
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_copyObject.js
487
- function copyObject(source, props, object, customizer) {
488
- var isNew = !object;
489
- object || (object = {});
490
- var index = -1, length = props.length;
491
- while (++index < length) {
492
- var key = props[index];
493
- var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0;
494
- if (newValue === void 0) {
495
- newValue = source[key];
496
- }
497
- if (isNew) {
498
- baseAssignValue_default(object, key, newValue);
499
- } else {
500
- assignValue_default(object, key, newValue);
501
- }
502
- }
503
- return object;
504
- }
505
- var copyObject_default = copyObject;
506
-
507
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseTimes.js
508
- function baseTimes(n, iteratee) {
509
- var index = -1, result = Array(n);
510
- while (++index < n) {
511
- result[index] = iteratee(index);
512
- }
513
- return result;
514
- }
515
- var baseTimes_default = baseTimes;
516
-
517
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isObjectLike.js
518
- function isObjectLike(value) {
519
- return value != null && typeof value == "object";
520
- }
521
- var isObjectLike_default = isObjectLike;
522
-
523
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsArguments.js
524
- var argsTag = "[object Arguments]";
525
- function baseIsArguments(value) {
526
- return isObjectLike_default(value) && baseGetTag_default(value) == argsTag;
527
- }
528
- var baseIsArguments_default = baseIsArguments;
529
-
530
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isArguments.js
531
- var objectProto7 = Object.prototype;
532
- var hasOwnProperty6 = objectProto7.hasOwnProperty;
533
- var propertyIsEnumerable = objectProto7.propertyIsEnumerable;
534
- var isArguments = baseIsArguments_default(/* @__PURE__ */ (function() {
535
- return arguments;
536
- })()) ? baseIsArguments_default : function(value) {
537
- return isObjectLike_default(value) && hasOwnProperty6.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
538
- };
539
- var isArguments_default = isArguments;
540
-
541
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isArray.js
542
- var isArray = Array.isArray;
543
- var isArray_default = isArray;
544
-
545
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/stubFalse.js
546
- function stubFalse() {
547
- return false;
548
- }
549
- var stubFalse_default = stubFalse;
550
-
551
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isBuffer.js
552
- var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
553
- var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
554
- var moduleExports = freeModule && freeModule.exports === freeExports;
555
- var Buffer = moduleExports ? root_default.Buffer : void 0;
556
- var nativeIsBuffer = Buffer ? Buffer.isBuffer : void 0;
557
- var isBuffer = nativeIsBuffer || stubFalse_default;
558
- var isBuffer_default = isBuffer;
559
-
560
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_isIndex.js
561
- var MAX_SAFE_INTEGER = 9007199254740991;
562
- var reIsUint = /^(?:0|[1-9]\d*)$/;
563
- function isIndex(value, length) {
564
- var type = typeof value;
565
- length = length == null ? MAX_SAFE_INTEGER : length;
566
- return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
567
- }
568
- var isIndex_default = isIndex;
569
-
570
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isLength.js
571
- var MAX_SAFE_INTEGER2 = 9007199254740991;
572
- function isLength(value) {
573
- return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER2;
574
- }
575
- var isLength_default = isLength;
576
-
577
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsTypedArray.js
578
- var argsTag2 = "[object Arguments]";
579
- var arrayTag = "[object Array]";
580
- var boolTag = "[object Boolean]";
581
- var dateTag = "[object Date]";
582
- var errorTag = "[object Error]";
583
- var funcTag2 = "[object Function]";
584
- var mapTag = "[object Map]";
585
- var numberTag = "[object Number]";
586
- var objectTag = "[object Object]";
587
- var regexpTag = "[object RegExp]";
588
- var setTag = "[object Set]";
589
- var stringTag = "[object String]";
590
- var weakMapTag = "[object WeakMap]";
591
- var arrayBufferTag = "[object ArrayBuffer]";
592
- var dataViewTag = "[object DataView]";
593
- var float32Tag = "[object Float32Array]";
594
- var float64Tag = "[object Float64Array]";
595
- var int8Tag = "[object Int8Array]";
596
- var int16Tag = "[object Int16Array]";
597
- var int32Tag = "[object Int32Array]";
598
- var uint8Tag = "[object Uint8Array]";
599
- var uint8ClampedTag = "[object Uint8ClampedArray]";
600
- var uint16Tag = "[object Uint16Array]";
601
- var uint32Tag = "[object Uint32Array]";
602
- var typedArrayTags = {};
603
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
604
- typedArrayTags[argsTag2] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag2] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
605
- function baseIsTypedArray(value) {
606
- return isObjectLike_default(value) && isLength_default(value.length) && !!typedArrayTags[baseGetTag_default(value)];
607
- }
608
- var baseIsTypedArray_default = baseIsTypedArray;
609
-
610
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseUnary.js
611
- function baseUnary(func) {
612
- return function(value) {
613
- return func(value);
614
- };
615
- }
616
- var baseUnary_default = baseUnary;
617
-
618
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_nodeUtil.js
619
- var freeExports2 = typeof exports == "object" && exports && !exports.nodeType && exports;
620
- var freeModule2 = freeExports2 && typeof module == "object" && module && !module.nodeType && module;
621
- var moduleExports2 = freeModule2 && freeModule2.exports === freeExports2;
622
- var freeProcess = moduleExports2 && freeGlobal_default.process;
623
- var nodeUtil = (function() {
624
- try {
625
- var types = freeModule2 && freeModule2.require && freeModule2.require("util").types;
626
- if (types) {
627
- return types;
628
- }
629
- return freeProcess && freeProcess.binding && freeProcess.binding("util");
630
- } catch (e) {
631
- }
632
- })();
633
- var nodeUtil_default = nodeUtil;
634
-
635
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isTypedArray.js
636
- var nodeIsTypedArray = nodeUtil_default && nodeUtil_default.isTypedArray;
637
- var isTypedArray = nodeIsTypedArray ? baseUnary_default(nodeIsTypedArray) : baseIsTypedArray_default;
638
- var isTypedArray_default = isTypedArray;
639
-
640
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayLikeKeys.js
641
- var objectProto8 = Object.prototype;
642
- var hasOwnProperty7 = objectProto8.hasOwnProperty;
643
- function arrayLikeKeys(value, inherited) {
644
- var isArr = isArray_default(value), isArg = !isArr && isArguments_default(value), isBuff = !isArr && !isArg && isBuffer_default(value), isType = !isArr && !isArg && !isBuff && isTypedArray_default(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes_default(value.length, String) : [], length = result.length;
645
- for (var key in value) {
646
- if ((inherited || hasOwnProperty7.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
647
- (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
648
- isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
649
- isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
650
- isIndex_default(key, length)))) {
651
- result.push(key);
652
- }
653
- }
654
- return result;
655
- }
656
- var arrayLikeKeys_default = arrayLikeKeys;
657
-
658
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_isPrototype.js
659
- var objectProto9 = Object.prototype;
660
- function isPrototype(value) {
661
- var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto9;
662
- return value === proto;
663
- }
664
- var isPrototype_default = isPrototype;
665
-
666
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_overArg.js
667
- function overArg(func, transform) {
668
- return function(arg) {
669
- return func(transform(arg));
670
- };
671
- }
672
- var overArg_default = overArg;
673
-
674
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeys.js
675
- var nativeKeys = overArg_default(Object.keys, Object);
676
- var nativeKeys_default = nativeKeys;
677
-
678
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseKeys.js
679
- var objectProto10 = Object.prototype;
680
- var hasOwnProperty8 = objectProto10.hasOwnProperty;
681
- function baseKeys(object) {
682
- if (!isPrototype_default(object)) {
683
- return nativeKeys_default(object);
684
- }
685
- var result = [];
686
- for (var key in Object(object)) {
687
- if (hasOwnProperty8.call(object, key) && key != "constructor") {
688
- result.push(key);
689
- }
690
- }
691
- return result;
692
- }
693
- var baseKeys_default = baseKeys;
694
-
695
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isArrayLike.js
696
- function isArrayLike(value) {
697
- return value != null && isLength_default(value.length) && !isFunction_default(value);
698
- }
699
- var isArrayLike_default = isArrayLike;
700
-
701
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/keys.js
702
- function keys(object) {
703
- return isArrayLike_default(object) ? arrayLikeKeys_default(object) : baseKeys_default(object);
704
- }
705
- var keys_default = keys;
706
-
707
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseAssign.js
708
- function baseAssign(object, source) {
709
- return object && copyObject_default(source, keys_default(source), object);
710
- }
711
- var baseAssign_default = baseAssign;
712
-
713
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeysIn.js
714
- function nativeKeysIn(object) {
715
- var result = [];
716
- if (object != null) {
717
- for (var key in Object(object)) {
718
- result.push(key);
719
- }
720
- }
721
- return result;
722
- }
723
- var nativeKeysIn_default = nativeKeysIn;
724
-
725
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseKeysIn.js
726
- var objectProto11 = Object.prototype;
727
- var hasOwnProperty9 = objectProto11.hasOwnProperty;
728
- function baseKeysIn(object) {
729
- if (!isObject_default(object)) {
730
- return nativeKeysIn_default(object);
731
- }
732
- var isProto = isPrototype_default(object), result = [];
733
- for (var key in object) {
734
- if (!(key == "constructor" && (isProto || !hasOwnProperty9.call(object, key)))) {
735
- result.push(key);
736
- }
737
- }
738
- return result;
739
- }
740
- var baseKeysIn_default = baseKeysIn;
741
-
742
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/keysIn.js
743
- function keysIn(object) {
744
- return isArrayLike_default(object) ? arrayLikeKeys_default(object, true) : baseKeysIn_default(object);
745
- }
746
- var keysIn_default = keysIn;
747
-
748
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignIn.js
749
- function baseAssignIn(object, source) {
750
- return object && copyObject_default(source, keysIn_default(source), object);
751
- }
752
- var baseAssignIn_default = baseAssignIn;
753
-
754
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneBuffer.js
755
- var freeExports3 = typeof exports == "object" && exports && !exports.nodeType && exports;
756
- var freeModule3 = freeExports3 && typeof module == "object" && module && !module.nodeType && module;
757
- var moduleExports3 = freeModule3 && freeModule3.exports === freeExports3;
758
- var Buffer2 = moduleExports3 ? root_default.Buffer : void 0;
759
- var allocUnsafe = Buffer2 ? Buffer2.allocUnsafe : void 0;
760
- function cloneBuffer(buffer, isDeep) {
761
- if (isDeep) {
762
- return buffer.slice();
763
- }
764
- var length = buffer.length, result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
765
- buffer.copy(result);
766
- return result;
767
- }
768
- var cloneBuffer_default = cloneBuffer;
769
-
770
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_copyArray.js
771
- function copyArray(source, array) {
772
- var index = -1, length = source.length;
773
- array || (array = Array(length));
774
- while (++index < length) {
775
- array[index] = source[index];
776
- }
777
- return array;
778
- }
779
- var copyArray_default = copyArray;
780
-
781
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayFilter.js
782
- function arrayFilter(array, predicate) {
783
- var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
784
- while (++index < length) {
785
- var value = array[index];
786
- if (predicate(value, index, array)) {
787
- result[resIndex++] = value;
788
- }
789
- }
790
- return result;
791
- }
792
- var arrayFilter_default = arrayFilter;
793
-
794
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/stubArray.js
795
- function stubArray() {
796
- return [];
797
- }
798
- var stubArray_default = stubArray;
799
-
800
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getSymbols.js
801
- var objectProto12 = Object.prototype;
802
- var propertyIsEnumerable2 = objectProto12.propertyIsEnumerable;
803
- var nativeGetSymbols = Object.getOwnPropertySymbols;
804
- var getSymbols = !nativeGetSymbols ? stubArray_default : function(object) {
805
- if (object == null) {
806
- return [];
437
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_defineProperty.js
438
+ var defineProperty = (function() {
439
+ try {
440
+ var func = getNative_default(Object, "defineProperty");
441
+ func({}, "", {});
442
+ return func;
443
+ } catch (e) {
807
444
  }
808
- object = Object(object);
809
- return arrayFilter_default(nativeGetSymbols(object), function(symbol) {
810
- return propertyIsEnumerable2.call(object, symbol);
811
- });
812
- };
813
- var getSymbols_default = getSymbols;
814
-
815
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_copySymbols.js
816
- function copySymbols(source, object) {
817
- return copyObject_default(source, getSymbols_default(source), object);
818
- }
819
- var copySymbols_default = copySymbols;
445
+ })();
446
+ var defineProperty_default = defineProperty;
820
447
 
821
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayPush.js
822
- function arrayPush(array, values) {
823
- var index = -1, length = values.length, offset = array.length;
824
- while (++index < length) {
825
- array[offset + index] = values[index];
448
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignValue.js
449
+ function baseAssignValue(object, key, value) {
450
+ if (key == "__proto__" && defineProperty_default) {
451
+ defineProperty_default(object, key, {
452
+ "configurable": true,
453
+ "enumerable": true,
454
+ "value": value,
455
+ "writable": true
456
+ });
457
+ } else {
458
+ object[key] = value;
826
459
  }
827
- return array;
828
460
  }
829
- var arrayPush_default = arrayPush;
830
-
831
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getPrototype.js
832
- var getPrototype = overArg_default(Object.getPrototypeOf, Object);
833
- var getPrototype_default = getPrototype;
461
+ var baseAssignValue_default = baseAssignValue;
834
462
 
835
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getSymbolsIn.js
836
- var nativeGetSymbols2 = Object.getOwnPropertySymbols;
837
- var getSymbolsIn = !nativeGetSymbols2 ? stubArray_default : function(object) {
838
- var result = [];
839
- while (object) {
840
- arrayPush_default(result, getSymbols_default(object));
841
- object = getPrototype_default(object);
463
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_assignMergeValue.js
464
+ function assignMergeValue(object, key, value) {
465
+ if (value !== void 0 && !eq_default(object[key], value) || value === void 0 && !(key in object)) {
466
+ baseAssignValue_default(object, key, value);
842
467
  }
843
- return result;
844
- };
845
- var getSymbolsIn_default = getSymbolsIn;
846
-
847
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_copySymbolsIn.js
848
- function copySymbolsIn(source, object) {
849
- return copyObject_default(source, getSymbolsIn_default(source), object);
850
- }
851
- var copySymbolsIn_default = copySymbolsIn;
852
-
853
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseGetAllKeys.js
854
- function baseGetAllKeys(object, keysFunc, symbolsFunc) {
855
- var result = keysFunc(object);
856
- return isArray_default(object) ? result : arrayPush_default(result, symbolsFunc(object));
857
468
  }
858
- var baseGetAllKeys_default = baseGetAllKeys;
859
-
860
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeys.js
861
- function getAllKeys(object) {
862
- return baseGetAllKeys_default(object, keys_default, getSymbols_default);
863
- }
864
- var getAllKeys_default = getAllKeys;
865
-
866
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeysIn.js
867
- function getAllKeysIn(object) {
868
- return baseGetAllKeys_default(object, keysIn_default, getSymbolsIn_default);
869
- }
870
- var getAllKeysIn_default = getAllKeysIn;
871
-
872
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_DataView.js
873
- var DataView = getNative_default(root_default, "DataView");
874
- var DataView_default = DataView;
875
-
876
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Promise.js
877
- var Promise2 = getNative_default(root_default, "Promise");
878
- var Promise_default = Promise2;
879
-
880
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Set.js
881
- var Set = getNative_default(root_default, "Set");
882
- var Set_default = Set;
883
-
884
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js
885
- var WeakMap = getNative_default(root_default, "WeakMap");
886
- var WeakMap_default = WeakMap;
469
+ var assignMergeValue_default = assignMergeValue;
887
470
 
888
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js
889
- var mapTag2 = "[object Map]";
890
- var objectTag2 = "[object Object]";
891
- var promiseTag = "[object Promise]";
892
- var setTag2 = "[object Set]";
893
- var weakMapTag2 = "[object WeakMap]";
894
- var dataViewTag2 = "[object DataView]";
895
- var dataViewCtorString = toSource_default(DataView_default);
896
- var mapCtorString = toSource_default(Map_default);
897
- var promiseCtorString = toSource_default(Promise_default);
898
- var setCtorString = toSource_default(Set_default);
899
- var weakMapCtorString = toSource_default(WeakMap_default);
900
- var getTag = baseGetTag_default;
901
- 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) {
902
- getTag = function(value) {
903
- var result = baseGetTag_default(value), Ctor = result == objectTag2 ? value.constructor : void 0, ctorString = Ctor ? toSource_default(Ctor) : "";
904
- if (ctorString) {
905
- switch (ctorString) {
906
- case dataViewCtorString:
907
- return dataViewTag2;
908
- case mapCtorString:
909
- return mapTag2;
910
- case promiseCtorString:
911
- return promiseTag;
912
- case setCtorString:
913
- return setTag2;
914
- case weakMapCtorString:
915
- return weakMapTag2;
471
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_createBaseFor.js
472
+ function createBaseFor(fromRight) {
473
+ return function(object, iteratee, keysFunc) {
474
+ var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length;
475
+ while (length--) {
476
+ var key = props[fromRight ? length : ++index];
477
+ if (iteratee(iterable[key], key, iterable) === false) {
478
+ break;
916
479
  }
917
480
  }
918
- return result;
481
+ return object;
919
482
  };
920
483
  }
921
- var getTag_default = getTag;
484
+ var createBaseFor_default = createBaseFor;
922
485
 
923
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_initCloneArray.js
924
- var objectProto13 = Object.prototype;
925
- var hasOwnProperty10 = objectProto13.hasOwnProperty;
926
- function initCloneArray(array) {
927
- var length = array.length, result = new array.constructor(length);
928
- if (length && typeof array[0] == "string" && hasOwnProperty10.call(array, "index")) {
929
- result.index = array.index;
930
- result.input = array.input;
486
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseFor.js
487
+ var baseFor = createBaseFor_default();
488
+ var baseFor_default = baseFor;
489
+
490
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneBuffer.js
491
+ var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
492
+ var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
493
+ var moduleExports = freeModule && freeModule.exports === freeExports;
494
+ var Buffer = moduleExports ? root_default.Buffer : void 0;
495
+ var allocUnsafe = Buffer ? Buffer.allocUnsafe : void 0;
496
+ function cloneBuffer(buffer, isDeep) {
497
+ if (isDeep) {
498
+ return buffer.slice();
931
499
  }
500
+ var length = buffer.length, result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
501
+ buffer.copy(result);
932
502
  return result;
933
503
  }
934
- var initCloneArray_default = initCloneArray;
504
+ var cloneBuffer_default = cloneBuffer;
935
505
 
936
506
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Uint8Array.js
937
507
  var Uint8Array = root_default.Uint8Array;
@@ -945,30 +515,6 @@ function cloneArrayBuffer(arrayBuffer) {
945
515
  }
946
516
  var cloneArrayBuffer_default = cloneArrayBuffer;
947
517
 
948
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneDataView.js
949
- function cloneDataView(dataView, isDeep) {
950
- var buffer = isDeep ? cloneArrayBuffer_default(dataView.buffer) : dataView.buffer;
951
- return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
952
- }
953
- var cloneDataView_default = cloneDataView;
954
-
955
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneRegExp.js
956
- var reFlags = /\w*$/;
957
- function cloneRegExp(regexp) {
958
- var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
959
- result.lastIndex = regexp.lastIndex;
960
- return result;
961
- }
962
- var cloneRegExp_default = cloneRegExp;
963
-
964
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneSymbol.js
965
- var symbolProto = Symbol_default ? Symbol_default.prototype : void 0;
966
- var symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
967
- function cloneSymbol(symbol) {
968
- return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
969
- }
970
- var cloneSymbol_default = cloneSymbol;
971
-
972
518
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_cloneTypedArray.js
973
519
  function cloneTypedArray(typedArray, isDeep) {
974
520
  var buffer = isDeep ? cloneArrayBuffer_default(typedArray.buffer) : typedArray.buffer;
@@ -976,60 +522,16 @@ function cloneTypedArray(typedArray, isDeep) {
976
522
  }
977
523
  var cloneTypedArray_default = cloneTypedArray;
978
524
 
979
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_initCloneByTag.js
980
- var boolTag2 = "[object Boolean]";
981
- var dateTag2 = "[object Date]";
982
- var mapTag3 = "[object Map]";
983
- var numberTag2 = "[object Number]";
984
- var regexpTag2 = "[object RegExp]";
985
- var setTag3 = "[object Set]";
986
- var stringTag2 = "[object String]";
987
- var symbolTag = "[object Symbol]";
988
- var arrayBufferTag2 = "[object ArrayBuffer]";
989
- var dataViewTag3 = "[object DataView]";
990
- var float32Tag2 = "[object Float32Array]";
991
- var float64Tag2 = "[object Float64Array]";
992
- var int8Tag2 = "[object Int8Array]";
993
- var int16Tag2 = "[object Int16Array]";
994
- var int32Tag2 = "[object Int32Array]";
995
- var uint8Tag2 = "[object Uint8Array]";
996
- var uint8ClampedTag2 = "[object Uint8ClampedArray]";
997
- var uint16Tag2 = "[object Uint16Array]";
998
- var uint32Tag2 = "[object Uint32Array]";
999
- function initCloneByTag(object, tag, isDeep) {
1000
- var Ctor = object.constructor;
1001
- switch (tag) {
1002
- case arrayBufferTag2:
1003
- return cloneArrayBuffer_default(object);
1004
- case boolTag2:
1005
- case dateTag2:
1006
- return new Ctor(+object);
1007
- case dataViewTag3:
1008
- return cloneDataView_default(object, isDeep);
1009
- case float32Tag2:
1010
- case float64Tag2:
1011
- case int8Tag2:
1012
- case int16Tag2:
1013
- case int32Tag2:
1014
- case uint8Tag2:
1015
- case uint8ClampedTag2:
1016
- case uint16Tag2:
1017
- case uint32Tag2:
1018
- return cloneTypedArray_default(object, isDeep);
1019
- case mapTag3:
1020
- return new Ctor();
1021
- case numberTag2:
1022
- case stringTag2:
1023
- return new Ctor(object);
1024
- case regexpTag2:
1025
- return cloneRegExp_default(object);
1026
- case setTag3:
1027
- return new Ctor();
1028
- case symbolTag:
1029
- return cloneSymbol_default(object);
525
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_copyArray.js
526
+ function copyArray(source, array) {
527
+ var index = -1, length = source.length;
528
+ array || (array = Array(length));
529
+ while (++index < length) {
530
+ array[index] = source[index];
1030
531
  }
532
+ return array;
1031
533
  }
1032
- var initCloneByTag_default = initCloneByTag;
534
+ var copyArray_default = copyArray;
1033
535
 
1034
536
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseCreate.js
1035
537
  var objectCreate = Object.create;
@@ -1051,165 +553,72 @@ var baseCreate = /* @__PURE__ */ (function() {
1051
553
  })();
1052
554
  var baseCreate_default = baseCreate;
1053
555
 
1054
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_initCloneObject.js
1055
- function initCloneObject(object) {
1056
- return typeof object.constructor == "function" && !isPrototype_default(object) ? baseCreate_default(getPrototype_default(object)) : {};
1057
- }
1058
- var initCloneObject_default = initCloneObject;
1059
-
1060
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsMap.js
1061
- var mapTag4 = "[object Map]";
1062
- function baseIsMap(value) {
1063
- return isObjectLike_default(value) && getTag_default(value) == mapTag4;
556
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_overArg.js
557
+ function overArg(func, transform) {
558
+ return function(arg) {
559
+ return func(transform(arg));
560
+ };
1064
561
  }
1065
- var baseIsMap_default = baseIsMap;
562
+ var overArg_default = overArg;
1066
563
 
1067
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isMap.js
1068
- var nodeIsMap = nodeUtil_default && nodeUtil_default.isMap;
1069
- var isMap = nodeIsMap ? baseUnary_default(nodeIsMap) : baseIsMap_default;
1070
- var isMap_default = isMap;
564
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getPrototype.js
565
+ var getPrototype = overArg_default(Object.getPrototypeOf, Object);
566
+ var getPrototype_default = getPrototype;
1071
567
 
1072
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsSet.js
1073
- var setTag4 = "[object Set]";
1074
- function baseIsSet(value) {
1075
- return isObjectLike_default(value) && getTag_default(value) == setTag4;
568
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_isPrototype.js
569
+ var objectProto6 = Object.prototype;
570
+ function isPrototype(value) {
571
+ var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto6;
572
+ return value === proto;
1076
573
  }
1077
- var baseIsSet_default = baseIsSet;
1078
-
1079
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isSet.js
1080
- var nodeIsSet = nodeUtil_default && nodeUtil_default.isSet;
1081
- var isSet = nodeIsSet ? baseUnary_default(nodeIsSet) : baseIsSet_default;
1082
- var isSet_default = isSet;
574
+ var isPrototype_default = isPrototype;
1083
575
 
1084
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseClone.js
1085
- var CLONE_DEEP_FLAG = 1;
1086
- var CLONE_FLAT_FLAG = 2;
1087
- var CLONE_SYMBOLS_FLAG = 4;
1088
- var argsTag3 = "[object Arguments]";
1089
- var arrayTag2 = "[object Array]";
1090
- var boolTag3 = "[object Boolean]";
1091
- var dateTag3 = "[object Date]";
1092
- var errorTag2 = "[object Error]";
1093
- var funcTag3 = "[object Function]";
1094
- var genTag2 = "[object GeneratorFunction]";
1095
- var mapTag5 = "[object Map]";
1096
- var numberTag3 = "[object Number]";
1097
- var objectTag3 = "[object Object]";
1098
- var regexpTag3 = "[object RegExp]";
1099
- var setTag5 = "[object Set]";
1100
- var stringTag3 = "[object String]";
1101
- var symbolTag2 = "[object Symbol]";
1102
- var weakMapTag3 = "[object WeakMap]";
1103
- var arrayBufferTag3 = "[object ArrayBuffer]";
1104
- var dataViewTag4 = "[object DataView]";
1105
- var float32Tag3 = "[object Float32Array]";
1106
- var float64Tag3 = "[object Float64Array]";
1107
- var int8Tag3 = "[object Int8Array]";
1108
- var int16Tag3 = "[object Int16Array]";
1109
- var int32Tag3 = "[object Int32Array]";
1110
- var uint8Tag3 = "[object Uint8Array]";
1111
- var uint8ClampedTag3 = "[object Uint8ClampedArray]";
1112
- var uint16Tag3 = "[object Uint16Array]";
1113
- var uint32Tag3 = "[object Uint32Array]";
1114
- var cloneableTags = {};
1115
- 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[objectTag3] = cloneableTags[regexpTag3] = cloneableTags[setTag5] = cloneableTags[stringTag3] = cloneableTags[symbolTag2] = cloneableTags[uint8Tag3] = cloneableTags[uint8ClampedTag3] = cloneableTags[uint16Tag3] = cloneableTags[uint32Tag3] = true;
1116
- cloneableTags[errorTag2] = cloneableTags[funcTag3] = cloneableTags[weakMapTag3] = false;
1117
- function baseClone(value, bitmask, customizer, key, object, stack) {
1118
- var result, isDeep = bitmask & CLONE_DEEP_FLAG, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG;
1119
- if (customizer) {
1120
- result = object ? customizer(value, key, object, stack) : customizer(value);
1121
- }
1122
- if (result !== void 0) {
1123
- return result;
1124
- }
1125
- if (!isObject_default(value)) {
1126
- return value;
1127
- }
1128
- var isArr = isArray_default(value);
1129
- if (isArr) {
1130
- result = initCloneArray_default(value);
1131
- if (!isDeep) {
1132
- return copyArray_default(value, result);
1133
- }
1134
- } else {
1135
- var tag = getTag_default(value), isFunc = tag == funcTag3 || tag == genTag2;
1136
- if (isBuffer_default(value)) {
1137
- return cloneBuffer_default(value, isDeep);
1138
- }
1139
- if (tag == objectTag3 || tag == argsTag3 || isFunc && !object) {
1140
- result = isFlat || isFunc ? {} : initCloneObject_default(value);
1141
- if (!isDeep) {
1142
- return isFlat ? copySymbolsIn_default(value, baseAssignIn_default(result, value)) : copySymbols_default(value, baseAssign_default(result, value));
1143
- }
1144
- } else {
1145
- if (!cloneableTags[tag]) {
1146
- return object ? value : {};
1147
- }
1148
- result = initCloneByTag_default(value, tag, isDeep);
1149
- }
1150
- }
1151
- stack || (stack = new Stack_default());
1152
- var stacked = stack.get(value);
1153
- if (stacked) {
1154
- return stacked;
1155
- }
1156
- stack.set(value, result);
1157
- if (isSet_default(value)) {
1158
- value.forEach(function(subValue) {
1159
- result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
1160
- });
1161
- } else if (isMap_default(value)) {
1162
- value.forEach(function(subValue, key2) {
1163
- result.set(key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
1164
- });
1165
- }
1166
- var keysFunc = isFull ? isFlat ? getAllKeysIn_default : getAllKeys_default : isFlat ? keysIn_default : keys_default;
1167
- var props = isArr ? void 0 : keysFunc(value);
1168
- arrayEach_default(props || value, function(subValue, key2) {
1169
- if (props) {
1170
- key2 = subValue;
1171
- subValue = value[key2];
1172
- }
1173
- assignValue_default(result, key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
1174
- });
1175
- return result;
576
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_initCloneObject.js
577
+ function initCloneObject(object) {
578
+ return typeof object.constructor == "function" && !isPrototype_default(object) ? baseCreate_default(getPrototype_default(object)) : {};
1176
579
  }
1177
- var baseClone_default = baseClone;
580
+ var initCloneObject_default = initCloneObject;
1178
581
 
1179
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/cloneDeep.js
1180
- var CLONE_DEEP_FLAG2 = 1;
1181
- var CLONE_SYMBOLS_FLAG2 = 4;
1182
- function cloneDeep(value) {
1183
- return baseClone_default(value, CLONE_DEEP_FLAG2 | CLONE_SYMBOLS_FLAG2);
582
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isObjectLike.js
583
+ function isObjectLike(value) {
584
+ return value != null && typeof value == "object";
1184
585
  }
1185
- var cloneDeep_default = cloneDeep;
586
+ var isObjectLike_default = isObjectLike;
1186
587
 
1187
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_assignMergeValue.js
1188
- function assignMergeValue(object, key, value) {
1189
- if (value !== void 0 && !eq_default(object[key], value) || value === void 0 && !(key in object)) {
1190
- baseAssignValue_default(object, key, value);
1191
- }
588
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsArguments.js
589
+ var argsTag = "[object Arguments]";
590
+ function baseIsArguments(value) {
591
+ return isObjectLike_default(value) && baseGetTag_default(value) == argsTag;
1192
592
  }
1193
- var assignMergeValue_default = assignMergeValue;
593
+ var baseIsArguments_default = baseIsArguments;
1194
594
 
1195
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_createBaseFor.js
1196
- function createBaseFor(fromRight) {
1197
- return function(object, iteratee, keysFunc) {
1198
- var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length;
1199
- while (length--) {
1200
- var key = props[fromRight ? length : ++index];
1201
- if (iteratee(iterable[key], key, iterable) === false) {
1202
- break;
1203
- }
1204
- }
1205
- return object;
1206
- };
595
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isArguments.js
596
+ var objectProto7 = Object.prototype;
597
+ var hasOwnProperty5 = objectProto7.hasOwnProperty;
598
+ var propertyIsEnumerable = objectProto7.propertyIsEnumerable;
599
+ var isArguments = baseIsArguments_default(/* @__PURE__ */ (function() {
600
+ return arguments;
601
+ })()) ? baseIsArguments_default : function(value) {
602
+ return isObjectLike_default(value) && hasOwnProperty5.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
603
+ };
604
+ var isArguments_default = isArguments;
605
+
606
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isArray.js
607
+ var isArray = Array.isArray;
608
+ var isArray_default = isArray;
609
+
610
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isLength.js
611
+ var MAX_SAFE_INTEGER = 9007199254740991;
612
+ function isLength(value) {
613
+ return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
1207
614
  }
1208
- var createBaseFor_default = createBaseFor;
615
+ var isLength_default = isLength;
1209
616
 
1210
- // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseFor.js
1211
- var baseFor = createBaseFor_default();
1212
- var baseFor_default = baseFor;
617
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isArrayLike.js
618
+ function isArrayLike(value) {
619
+ return value != null && isLength_default(value.length) && !isFunction_default(value);
620
+ }
621
+ var isArrayLike_default = isArrayLike;
1213
622
 
1214
623
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isArrayLikeObject.js
1215
624
  function isArrayLikeObject(value) {
@@ -1217,26 +626,104 @@ function isArrayLikeObject(value) {
1217
626
  }
1218
627
  var isArrayLikeObject_default = isArrayLikeObject;
1219
628
 
629
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/stubFalse.js
630
+ function stubFalse() {
631
+ return false;
632
+ }
633
+ var stubFalse_default = stubFalse;
634
+
635
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isBuffer.js
636
+ var freeExports2 = typeof exports == "object" && exports && !exports.nodeType && exports;
637
+ var freeModule2 = freeExports2 && typeof module == "object" && module && !module.nodeType && module;
638
+ var moduleExports2 = freeModule2 && freeModule2.exports === freeExports2;
639
+ var Buffer2 = moduleExports2 ? root_default.Buffer : void 0;
640
+ var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0;
641
+ var isBuffer = nativeIsBuffer || stubFalse_default;
642
+ var isBuffer_default = isBuffer;
643
+
1220
644
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isPlainObject.js
1221
- var objectTag4 = "[object Object]";
645
+ var objectTag = "[object Object]";
1222
646
  var funcProto3 = Function.prototype;
1223
- var objectProto14 = Object.prototype;
647
+ var objectProto8 = Object.prototype;
1224
648
  var funcToString3 = funcProto3.toString;
1225
- var hasOwnProperty11 = objectProto14.hasOwnProperty;
649
+ var hasOwnProperty6 = objectProto8.hasOwnProperty;
1226
650
  var objectCtorString = funcToString3.call(Object);
1227
651
  function isPlainObject(value) {
1228
- if (!isObjectLike_default(value) || baseGetTag_default(value) != objectTag4) {
652
+ if (!isObjectLike_default(value) || baseGetTag_default(value) != objectTag) {
1229
653
  return false;
1230
654
  }
1231
655
  var proto = getPrototype_default(value);
1232
656
  if (proto === null) {
1233
657
  return true;
1234
658
  }
1235
- var Ctor = hasOwnProperty11.call(proto, "constructor") && proto.constructor;
659
+ var Ctor = hasOwnProperty6.call(proto, "constructor") && proto.constructor;
1236
660
  return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString3.call(Ctor) == objectCtorString;
1237
661
  }
1238
662
  var isPlainObject_default = isPlainObject;
1239
663
 
664
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsTypedArray.js
665
+ var argsTag2 = "[object Arguments]";
666
+ var arrayTag = "[object Array]";
667
+ var boolTag = "[object Boolean]";
668
+ var dateTag = "[object Date]";
669
+ var errorTag = "[object Error]";
670
+ var funcTag2 = "[object Function]";
671
+ var mapTag = "[object Map]";
672
+ var numberTag = "[object Number]";
673
+ var objectTag2 = "[object Object]";
674
+ var regexpTag = "[object RegExp]";
675
+ var setTag = "[object Set]";
676
+ var stringTag = "[object String]";
677
+ var weakMapTag = "[object WeakMap]";
678
+ var arrayBufferTag = "[object ArrayBuffer]";
679
+ var dataViewTag = "[object DataView]";
680
+ var float32Tag = "[object Float32Array]";
681
+ var float64Tag = "[object Float64Array]";
682
+ var int8Tag = "[object Int8Array]";
683
+ var int16Tag = "[object Int16Array]";
684
+ var int32Tag = "[object Int32Array]";
685
+ var uint8Tag = "[object Uint8Array]";
686
+ var uint8ClampedTag = "[object Uint8ClampedArray]";
687
+ var uint16Tag = "[object Uint16Array]";
688
+ var uint32Tag = "[object Uint32Array]";
689
+ var typedArrayTags = {};
690
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
691
+ typedArrayTags[argsTag2] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag2] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag2] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
692
+ function baseIsTypedArray(value) {
693
+ return isObjectLike_default(value) && isLength_default(value.length) && !!typedArrayTags[baseGetTag_default(value)];
694
+ }
695
+ var baseIsTypedArray_default = baseIsTypedArray;
696
+
697
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseUnary.js
698
+ function baseUnary(func) {
699
+ return function(value) {
700
+ return func(value);
701
+ };
702
+ }
703
+ var baseUnary_default = baseUnary;
704
+
705
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_nodeUtil.js
706
+ var freeExports3 = typeof exports == "object" && exports && !exports.nodeType && exports;
707
+ var freeModule3 = freeExports3 && typeof module == "object" && module && !module.nodeType && module;
708
+ var moduleExports3 = freeModule3 && freeModule3.exports === freeExports3;
709
+ var freeProcess = moduleExports3 && freeGlobal_default.process;
710
+ var nodeUtil = (function() {
711
+ try {
712
+ var types = freeModule3 && freeModule3.require && freeModule3.require("util").types;
713
+ if (types) {
714
+ return types;
715
+ }
716
+ return freeProcess && freeProcess.binding && freeProcess.binding("util");
717
+ } catch (e) {
718
+ }
719
+ })();
720
+ var nodeUtil_default = nodeUtil;
721
+
722
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/isTypedArray.js
723
+ var nodeIsTypedArray = nodeUtil_default && nodeUtil_default.isTypedArray;
724
+ var isTypedArray = nodeIsTypedArray ? baseUnary_default(nodeIsTypedArray) : baseIsTypedArray_default;
725
+ var isTypedArray_default = isTypedArray;
726
+
1240
727
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_safeGet.js
1241
728
  function safeGet(object, key) {
1242
729
  if (key === "constructor" && typeof object[key] === "function") {
@@ -1249,6 +736,111 @@ function safeGet(object, key) {
1249
736
  }
1250
737
  var safeGet_default = safeGet;
1251
738
 
739
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_assignValue.js
740
+ var objectProto9 = Object.prototype;
741
+ var hasOwnProperty7 = objectProto9.hasOwnProperty;
742
+ function assignValue(object, key, value) {
743
+ var objValue = object[key];
744
+ if (!(hasOwnProperty7.call(object, key) && eq_default(objValue, value)) || value === void 0 && !(key in object)) {
745
+ baseAssignValue_default(object, key, value);
746
+ }
747
+ }
748
+ var assignValue_default = assignValue;
749
+
750
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_copyObject.js
751
+ function copyObject(source, props, object, customizer) {
752
+ var isNew = !object;
753
+ object || (object = {});
754
+ var index = -1, length = props.length;
755
+ while (++index < length) {
756
+ var key = props[index];
757
+ var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0;
758
+ if (newValue === void 0) {
759
+ newValue = source[key];
760
+ }
761
+ if (isNew) {
762
+ baseAssignValue_default(object, key, newValue);
763
+ } else {
764
+ assignValue_default(object, key, newValue);
765
+ }
766
+ }
767
+ return object;
768
+ }
769
+ var copyObject_default = copyObject;
770
+
771
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseTimes.js
772
+ function baseTimes(n, iteratee) {
773
+ var index = -1, result = Array(n);
774
+ while (++index < n) {
775
+ result[index] = iteratee(index);
776
+ }
777
+ return result;
778
+ }
779
+ var baseTimes_default = baseTimes;
780
+
781
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_isIndex.js
782
+ var MAX_SAFE_INTEGER2 = 9007199254740991;
783
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
784
+ function isIndex(value, length) {
785
+ var type = typeof value;
786
+ length = length == null ? MAX_SAFE_INTEGER2 : length;
787
+ return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
788
+ }
789
+ var isIndex_default = isIndex;
790
+
791
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayLikeKeys.js
792
+ var objectProto10 = Object.prototype;
793
+ var hasOwnProperty8 = objectProto10.hasOwnProperty;
794
+ function arrayLikeKeys(value, inherited) {
795
+ var isArr = isArray_default(value), isArg = !isArr && isArguments_default(value), isBuff = !isArr && !isArg && isBuffer_default(value), isType = !isArr && !isArg && !isBuff && isTypedArray_default(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes_default(value.length, String) : [], length = result.length;
796
+ for (var key in value) {
797
+ if ((inherited || hasOwnProperty8.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
798
+ (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
799
+ isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
800
+ isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
801
+ isIndex_default(key, length)))) {
802
+ result.push(key);
803
+ }
804
+ }
805
+ return result;
806
+ }
807
+ var arrayLikeKeys_default = arrayLikeKeys;
808
+
809
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeysIn.js
810
+ function nativeKeysIn(object) {
811
+ var result = [];
812
+ if (object != null) {
813
+ for (var key in Object(object)) {
814
+ result.push(key);
815
+ }
816
+ }
817
+ return result;
818
+ }
819
+ var nativeKeysIn_default = nativeKeysIn;
820
+
821
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseKeysIn.js
822
+ var objectProto11 = Object.prototype;
823
+ var hasOwnProperty9 = objectProto11.hasOwnProperty;
824
+ function baseKeysIn(object) {
825
+ if (!isObject_default(object)) {
826
+ return nativeKeysIn_default(object);
827
+ }
828
+ var isProto = isPrototype_default(object), result = [];
829
+ for (var key in object) {
830
+ if (!(key == "constructor" && (isProto || !hasOwnProperty9.call(object, key)))) {
831
+ result.push(key);
832
+ }
833
+ }
834
+ return result;
835
+ }
836
+ var baseKeysIn_default = baseKeysIn;
837
+
838
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/keysIn.js
839
+ function keysIn(object) {
840
+ return isArrayLike_default(object) ? arrayLikeKeys_default(object, true) : baseKeysIn_default(object);
841
+ }
842
+ var keysIn_default = keysIn;
843
+
1252
844
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/toPlainObject.js
1253
845
  function toPlainObject(value) {
1254
846
  return copyObject_default(value, keysIn_default(value));
@@ -1457,7 +1049,6 @@ var mergeWith_default = mergeWith;
1457
1049
  var AIMarkdownRenderExtraSyntax = /* @__PURE__ */ ((AIMarkdownRenderExtraSyntax2) => {
1458
1050
  AIMarkdownRenderExtraSyntax2["HIGHLIGHT"] = "HIGHLIGHT";
1459
1051
  AIMarkdownRenderExtraSyntax2["DEFINITION_LIST"] = "DEFINITION_LIST";
1460
- AIMarkdownRenderExtraSyntax2["SUBSCRIPT"] = "SUBSCRIPT";
1461
1052
  return AIMarkdownRenderExtraSyntax2;
1462
1053
  })(AIMarkdownRenderExtraSyntax || {});
1463
1054
  var AIMarkdownRenderDisplayOptimizeAbility = /* @__PURE__ */ ((AIMarkdownRenderDisplayOptimizeAbility2) => {
@@ -1469,14 +1060,14 @@ var AIMarkdownRenderDisplayOptimizeAbility = /* @__PURE__ */ ((AIMarkdownRenderD
1469
1060
  var defaultAIMarkdownRenderConfig = Object.freeze({
1470
1061
  extraSyntaxSupported: Object.freeze([
1471
1062
  "HIGHLIGHT" /* HIGHLIGHT */,
1472
- "DEFINITION_LIST" /* DEFINITION_LIST */,
1473
- "SUBSCRIPT" /* SUBSCRIPT */
1063
+ "DEFINITION_LIST" /* DEFINITION_LIST */
1474
1064
  ]),
1475
1065
  displayOptimizeAbilities: Object.freeze([
1476
1066
  "REMOVE_COMMENTS" /* REMOVE_COMMENTS */,
1477
1067
  "SMARTYPANTS" /* SMARTYPANTS */,
1478
1068
  "PANGU" /* PANGU */
1479
- ])
1069
+ ]),
1070
+ blockMemoEnabled: true
1480
1071
  });
1481
1072
 
1482
1073
  // src/context.tsx
@@ -1509,24 +1100,28 @@ var AIMarkdownRenderStateProvider = ({
1509
1100
  fontSize,
1510
1101
  variant,
1511
1102
  colorScheme,
1103
+ documentId,
1512
1104
  defaultConfig,
1513
1105
  config,
1514
1106
  children
1515
1107
  }) => {
1516
1108
  const baseConfig = defaultConfig ?? defaultAIMarkdownRenderConfig;
1517
1109
  const mergedConfig = useMemo(
1518
- () => config ? mergeWith_default(cloneDeep_default(baseConfig), config, configMergeCustomizer) : baseConfig,
1110
+ () => config ? mergeWith_default({}, baseConfig, config, configMergeCustomizer) : baseConfig,
1519
1111
  [baseConfig, config]
1520
1112
  );
1113
+ const fallbackId = useId();
1114
+ const resolvedDocumentId = documentId && documentId.length > 0 ? documentId : fallbackId;
1521
1115
  const state = useMemo(
1522
1116
  () => Object.freeze({
1523
1117
  streaming,
1524
1118
  fontSize,
1525
1119
  variant,
1526
1120
  colorScheme,
1121
+ documentId: resolvedDocumentId,
1527
1122
  config: mergedConfig
1528
1123
  }),
1529
- [streaming, fontSize, variant, colorScheme, mergedConfig]
1124
+ [streaming, fontSize, variant, colorScheme, resolvedDocumentId, mergedConfig]
1530
1125
  );
1531
1126
  return /* @__PURE__ */ jsx(AIMarkdownRenderStateContext.Provider, { value: state, children });
1532
1127
  };
@@ -1540,10 +1135,42 @@ function getRepeatedMarkerLength(content, start, marker) {
1540
1135
  }
1541
1136
  return end - start;
1542
1137
  }
1138
+ var HTML_TAG_REGEX = /<\/?(span|div|p|br|hr|img|a|em|strong|b|i|u|s|sub|sup|code|pre|table|tr|td|th|thead|tbody|tfoot|ul|ol|li|dl|dt|dd|h[1-6]|blockquote|details|summary|figure|figcaption|section|article|aside|nav|header|footer|main|mark|del|ins|small|abbr|cite|dfn|kbd|samp|var|ruby|rt|rp|bdo|wbr|input|button|select|textarea|label|fieldset|legend|output|iframe|video|audio|source|canvas|svg|math|time)(?:\s[^>]*)?\/?>/iy;
1139
+ var LITERAL_CONTENT_TAGS = /* @__PURE__ */ new Set(["code", "pre", "kbd", "samp", "math", "svg"]);
1140
+ var LITERAL_CONTENT_CLOSE_REGEX = {
1141
+ code: /<\/code\s*>/gi,
1142
+ pre: /<\/pre\s*>/gi,
1143
+ kbd: /<\/kbd\s*>/gi,
1144
+ samp: /<\/samp\s*>/gi,
1145
+ math: /<\/math\s*>/gi,
1146
+ svg: /<\/svg\s*>/gi
1147
+ };
1148
+ function isAtLineStart(content, pos) {
1149
+ let i = pos - 1;
1150
+ let spaces = 0;
1151
+ while (i >= 0 && content[i] === " ") {
1152
+ spaces++;
1153
+ if (spaces > 3) return false;
1154
+ i--;
1155
+ }
1156
+ return i < 0 || content[i] === "\n" || content[i] === "\r";
1157
+ }
1158
+ function findClosingBacktickRun(content, start, n) {
1159
+ let i = start;
1160
+ while (i < content.length) {
1161
+ if (content[i] === "`") {
1162
+ const runLen = getRepeatedMarkerLength(content, i, "`");
1163
+ if (runLen === n) return i;
1164
+ i += runLen;
1165
+ } else {
1166
+ i += 1;
1167
+ }
1168
+ }
1169
+ return -1;
1170
+ }
1543
1171
  function splitByProtectedRegions(content) {
1544
1172
  const segments = [];
1545
1173
  let lastIndex = 0;
1546
- let inlineStart = -1;
1547
1174
  let multilineStart = -1;
1548
1175
  let multilineFenceMarker = null;
1549
1176
  let multilineFenceLength = 0;
@@ -1554,42 +1181,69 @@ function splitByProtectedRegions(content) {
1554
1181
  segments.push({ text: content.substring(start, end), isCode: true });
1555
1182
  lastIndex = end;
1556
1183
  }
1557
- for (let i = 0; i < content.length; i++) {
1184
+ let i = 0;
1185
+ while (i < content.length) {
1558
1186
  const char = content[i];
1559
- const fenceLength = char === "`" || char === "~" ? getRepeatedMarkerLength(content, i, char) : 0;
1560
- if ((char === "`" || char === "~") && fenceLength >= 3) {
1561
- if (multilineStart === -1) {
1562
- inlineStart = -1;
1187
+ if (multilineStart !== -1) {
1188
+ if (char === multilineFenceMarker) {
1189
+ const runLen = getRepeatedMarkerLength(content, i, multilineFenceMarker);
1190
+ if (runLen >= multilineFenceLength && isAtLineStart(content, i)) {
1191
+ pushProtected(multilineStart, i + runLen);
1192
+ multilineStart = -1;
1193
+ multilineFenceMarker = null;
1194
+ multilineFenceLength = 0;
1195
+ i += runLen;
1196
+ continue;
1197
+ }
1198
+ i += runLen;
1199
+ continue;
1200
+ }
1201
+ i += 1;
1202
+ continue;
1203
+ }
1204
+ if (char === "`" || char === "~") {
1205
+ const runLen = getRepeatedMarkerLength(content, i, char);
1206
+ if (runLen >= 3 && isAtLineStart(content, i)) {
1563
1207
  multilineStart = i;
1564
1208
  multilineFenceMarker = char;
1565
- multilineFenceLength = fenceLength;
1566
- i += fenceLength - 1;
1567
- } else if (char === multilineFenceMarker && fenceLength >= multilineFenceLength) {
1568
- pushProtected(multilineStart, i + fenceLength);
1569
- multilineStart = -1;
1570
- multilineFenceMarker = null;
1571
- multilineFenceLength = 0;
1572
- i += fenceLength - 1;
1573
- } else {
1574
- i += fenceLength - 1;
1209
+ multilineFenceLength = runLen;
1210
+ i += runLen;
1211
+ continue;
1575
1212
  }
1576
- } else if (char === "`" && multilineStart === -1) {
1577
- if (inlineStart === -1) {
1578
- inlineStart = i;
1579
- } else {
1580
- pushProtected(inlineStart, i + 1);
1581
- inlineStart = -1;
1213
+ if (char === "`") {
1214
+ const closeIdx = findClosingBacktickRun(content, i + runLen, runLen);
1215
+ if (closeIdx !== -1) {
1216
+ pushProtected(i, closeIdx + runLen);
1217
+ i = closeIdx + runLen;
1218
+ continue;
1219
+ }
1582
1220
  }
1583
- } else if (char === "<" && multilineStart === -1 && inlineStart === -1) {
1584
- const rest = content.substring(i);
1585
- const tagMatch = rest.match(
1586
- /^<\/?(span|div|p|br|hr|img|a|em|strong|b|i|u|s|sub|sup|code|pre|table|tr|td|th|thead|tbody|tfoot|ul|ol|li|dl|dt|dd|h[1-6]|blockquote|details|summary|figure|figcaption|section|article|aside|nav|header|footer|main|mark|del|ins|small|abbr|cite|dfn|kbd|samp|var|ruby|rt|rp|bdo|wbr|input|button|select|textarea|label|fieldset|legend|output|iframe|video|audio|source|canvas|svg|math|time)(?:\s[^>]*)?\/?>/i
1587
- );
1221
+ i += runLen;
1222
+ continue;
1223
+ }
1224
+ if (char === "<") {
1225
+ HTML_TAG_REGEX.lastIndex = i;
1226
+ const tagMatch = HTML_TAG_REGEX.exec(content);
1588
1227
  if (tagMatch) {
1589
- pushProtected(i, i + tagMatch[0].length);
1590
- i += tagMatch[0].length - 1;
1228
+ let endIndex = i + tagMatch[0].length;
1229
+ const tagName = tagMatch[1].toLowerCase();
1230
+ const isOpeningPairedTag = content[i + 1] !== "/" && !tagMatch[0].endsWith("/>") && LITERAL_CONTENT_TAGS.has(tagName);
1231
+ if (isOpeningPairedTag) {
1232
+ const closeRegex = LITERAL_CONTENT_CLOSE_REGEX[tagName];
1233
+ closeRegex.lastIndex = endIndex;
1234
+ const closeMatch = closeRegex.exec(content);
1235
+ if (closeMatch) {
1236
+ endIndex = closeMatch.index + closeMatch[0].length;
1237
+ } else {
1238
+ endIndex = content.length;
1239
+ }
1240
+ }
1241
+ pushProtected(i, endIndex);
1242
+ i = endIndex;
1243
+ continue;
1591
1244
  }
1592
1245
  }
1246
+ i += 1;
1593
1247
  }
1594
1248
  if (multilineStart !== -1) {
1595
1249
  pushProtected(multilineStart, content.length);
@@ -1607,15 +1261,23 @@ var NO_ESCAPED_DOLLAR_REGEX = /(?<![\\$])\$(?!\$)/g;
1607
1261
  var DELIMITERS_REGEX = /(?<!!)\\\[([\S\s]*?[^\\])\\](?!\()|\\\((.*?)\\\)/g;
1608
1262
  var ARRAY_COL_SPEC_OR_PIPE_REGEX = /(\\begin\{(?:array|tabular[x*]?)\}\{[^}]*\})|(?<!\\)\|/g;
1609
1263
  var LATEX_BLOCK_REGEX = /\$\$([\S\s]*?)\$\$|(?<![\\$])\$(?!\$)((?:[^$\n]|\\\$)*?)(?<![\\`])\$(?!\$)/g;
1610
- var ESCAPE_TEXT_UNDERSCORES_REGEX = /\\text{([^}]*)}/g;
1264
+ var TEXT_COMMAND = "\\text{";
1611
1265
  var SINGLE_DOLLAR_REGEX = /(?<![\\$])\$(?!\$)((?:[^$\n]|\\[$])+?)(?<!\\)(?<!`)\$(?!\$)/g;
1612
1266
  function escapeCurrencyDollarSigns(text) {
1613
1267
  const parts = [];
1614
1268
  let lastIndex = 0;
1615
1269
  const currencyMatches = Array.from(text.matchAll(CURRENCY_REGEX));
1270
+ let currentLineProcessed = "";
1616
1271
  for (let i = 0; i < currencyMatches.length; i++) {
1617
1272
  const match = currencyMatches[i];
1618
- parts.push(text.substring(lastIndex, match.index));
1273
+ const segment = text.substring(lastIndex, match.index);
1274
+ parts.push(segment);
1275
+ const newlineIdx = Math.max(segment.lastIndexOf("\n"), segment.lastIndexOf("\r"));
1276
+ if (newlineIdx !== -1) {
1277
+ currentLineProcessed = segment.substring(newlineIdx + 1);
1278
+ } else {
1279
+ currentLineProcessed += segment;
1280
+ }
1619
1281
  let needEscape = true;
1620
1282
  let restBeforeNextMatchOrEnd = "";
1621
1283
  if (i < currencyMatches.length - 1) {
@@ -1628,14 +1290,14 @@ function escapeCurrencyDollarSigns(text) {
1628
1290
  }
1629
1291
  const firstLineBeforeNextMatch = restBeforeNextMatchOrEnd.split(/\r\n|\r|\n/g)[0];
1630
1292
  if (Array.from(firstLineBeforeNextMatch.matchAll(NO_ESCAPED_DOLLAR_REGEX)).length % 2 !== 0) {
1631
- const previousNewContent = parts.join("");
1632
- const previousLastLineContent = previousNewContent.split(/\r\n|\r|\n/g).pop();
1633
- const wholeLineBeforeNextMatchWithoutCurrentDollar = previousLastLineContent + firstLineBeforeNextMatch;
1293
+ const wholeLineBeforeNextMatchWithoutCurrentDollar = currentLineProcessed + firstLineBeforeNextMatch;
1634
1294
  if (Array.from(wholeLineBeforeNextMatchWithoutCurrentDollar.matchAll(NO_ESCAPED_DOLLAR_REGEX)).length % 2 !== 0) {
1635
1295
  needEscape = false;
1636
1296
  }
1637
1297
  }
1638
- parts.push(needEscape ? "\\$" : "$");
1298
+ const replacement = needEscape ? "\\$" : "$";
1299
+ parts.push(replacement);
1300
+ currentLineProcessed += replacement;
1639
1301
  lastIndex = match.index + 1;
1640
1302
  }
1641
1303
  parts.push(text.substring(lastIndex));
@@ -1669,14 +1331,23 @@ function escapeLatexPipes(text) {
1669
1331
  return match;
1670
1332
  });
1671
1333
  }
1334
+ function isEscapedByBackslashRun(text, pos) {
1335
+ let count = 0;
1336
+ let j = pos - 1;
1337
+ while (j >= 0 && text[j] === "\\") {
1338
+ count++;
1339
+ j--;
1340
+ }
1341
+ return count % 2 === 1;
1342
+ }
1672
1343
  function findUnclosedDelimiterStart(text, mode) {
1673
1344
  let unclosedStart = -1;
1674
1345
  let i = 0;
1675
1346
  while (i < text.length) {
1676
- if (text[i] === "$" && i + 1 < text.length && text[i + 1] === "$") {
1347
+ if (text[i] === "$" && i + 1 < text.length && text[i + 1] === "$" && !isEscapedByBackslashRun(text, i)) {
1677
1348
  unclosedStart = unclosedStart === -1 ? i : -1;
1678
1349
  i += 2;
1679
- } else if (mode === "both" && text[i] === "$" && (i === 0 || text[i - 1] !== "\\") && (i + 1 >= text.length || text[i + 1] !== "$")) {
1350
+ } else if (mode === "both" && text[i] === "$" && !isEscapedByBackslashRun(text, i) && (i + 1 >= text.length || text[i + 1] !== "$")) {
1680
1351
  unclosedStart = unclosedStart === -1 ? i : -1;
1681
1352
  i += 1;
1682
1353
  } else {
@@ -1700,10 +1371,41 @@ function truncateUnclosedLatexBlock(text) {
1700
1371
  return text.substring(0, unclosedStart).trimEnd();
1701
1372
  }
1702
1373
  function escapeTextUnderscores(text) {
1703
- return text.replaceAll(ESCAPE_TEXT_UNDERSCORES_REGEX, (_match, textContent) => {
1704
- const escapedTextContent = textContent.replaceAll(/(?<!\\)_/g, "\\_");
1705
- return `\\text{${escapedTextContent}}`;
1706
- });
1374
+ let out = "";
1375
+ let i = 0;
1376
+ while (i < text.length) {
1377
+ const start = text.indexOf(TEXT_COMMAND, i);
1378
+ if (start === -1) {
1379
+ out += text.substring(i);
1380
+ return out;
1381
+ }
1382
+ out += text.substring(i, start);
1383
+ const bodyStart = start + TEXT_COMMAND.length;
1384
+ let depth = 1;
1385
+ let j = bodyStart;
1386
+ while (j < text.length && depth > 0) {
1387
+ const c = text[j];
1388
+ if (c === "\\" && j + 1 < text.length) {
1389
+ j += 2;
1390
+ continue;
1391
+ }
1392
+ if (c === "{") depth++;
1393
+ else if (c === "}") {
1394
+ depth--;
1395
+ if (depth === 0) break;
1396
+ }
1397
+ j++;
1398
+ }
1399
+ if (depth !== 0) {
1400
+ out += text.substring(start);
1401
+ return out;
1402
+ }
1403
+ const body = text.substring(bodyStart, j);
1404
+ const escapedBody = body.replaceAll(/(?<!\\)_/g, "\\_");
1405
+ out += `\\text{${escapedBody}}`;
1406
+ i = j + 1;
1407
+ }
1408
+ return out;
1707
1409
  }
1708
1410
  function convertSingleToDoubleDollar(text) {
1709
1411
  return text.replaceAll(SINGLE_DOLLAR_REGEX, (_match, content) => `$$${content}$$`);
@@ -1727,22 +1429,249 @@ function preprocessLaTeX(str) {
1727
1429
  return result.join("");
1728
1430
  }
1729
1431
 
1730
- // src/preprocessors/index.ts
1731
- function applyPreprocessors(value, ...fns) {
1732
- return fns.reduce((result, fn) => fn(result), value);
1432
+ // src/preprocessors/index.ts
1433
+ function applyPreprocessors(value, ...fns) {
1434
+ return fns.reduce((result, fn) => fn(result), value);
1435
+ }
1436
+ var defaultExtraPreprocessors = [];
1437
+ function preprocessAIMDContent(content, extraPreprocessors = defaultExtraPreprocessors) {
1438
+ return applyPreprocessors(content, preprocessLaTeX, ...extraPreprocessors);
1439
+ }
1440
+
1441
+ // src/components/MarkdownContent.tsx
1442
+ import { Fragment as Fragment2, memo, useMemo as useMemo2, useRef } from "react";
1443
+
1444
+ // src/components/markdown/Markdown.tsx
1445
+ import { unreachable as unreachable2 } from "devlop";
1446
+ import { toJsxRuntime } from "hast-util-to-jsx-runtime";
1447
+ import { Fragment } from "react";
1448
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
1449
+ import { visit } from "unist-util-visit";
1450
+
1451
+ // src/components/markdown/processor.ts
1452
+ import { unreachable } from "devlop";
1453
+ import remarkParse from "remark-parse";
1454
+ import remarkRehype from "remark-rehype";
1455
+ import { unified } from "unified";
1456
+ import { VFile } from "vfile";
1457
+ var emptyPlugins = [];
1458
+ var emptyRemarkRehypeOptions = { allowDangerousHtml: true };
1459
+ function createProcessor(options) {
1460
+ const rehypePlugins = options.rehypePlugins || emptyPlugins;
1461
+ const remarkPlugins = options.remarkPlugins || emptyPlugins;
1462
+ const remarkRehypeOptions = options.remarkRehypeOptions ? { ...options.remarkRehypeOptions, ...emptyRemarkRehypeOptions } : emptyRemarkRehypeOptions;
1463
+ return unified().use(remarkParse).use(remarkPlugins).use(remarkRehype, remarkRehypeOptions).use(rehypePlugins);
1464
+ }
1465
+ function createFile(options) {
1466
+ const children = options.children || "";
1467
+ const file = new VFile();
1468
+ if (typeof children === "string") {
1469
+ file.value = children;
1470
+ } else {
1471
+ unreachable("Unexpected value `" + String(children) + "` for `children` prop, expected `string`");
1472
+ }
1473
+ return file;
1474
+ }
1475
+
1476
+ // src/components/markdown/transform.ts
1477
+ import { urlAttributes } from "html-url-attributes";
1478
+ function buildTransform(ctx) {
1479
+ return function transform(node, index, parent) {
1480
+ if (node.type === "raw" && parent && typeof index === "number") {
1481
+ if (ctx.skipHtml) {
1482
+ parent.children.splice(index, 1);
1483
+ } else {
1484
+ parent.children[index] = { type: "text", value: node.value };
1485
+ }
1486
+ return index;
1487
+ }
1488
+ if (node.type === "element") {
1489
+ const element = node;
1490
+ let key;
1491
+ for (key in urlAttributes) {
1492
+ if (Object.hasOwn(urlAttributes, key) && Object.hasOwn(element.properties, key)) {
1493
+ const value = element.properties[key];
1494
+ const test = urlAttributes[key];
1495
+ if (test === null || test.includes(element.tagName)) {
1496
+ element.properties[key] = ctx.urlTransform(String(value || ""), key, element);
1497
+ }
1498
+ }
1499
+ }
1500
+ }
1501
+ if (node.type === "element") {
1502
+ const element = node;
1503
+ let remove = ctx.allowedElements ? !ctx.allowedElements.includes(element.tagName) : ctx.disallowedElements ? ctx.disallowedElements.includes(element.tagName) : false;
1504
+ if (!remove && ctx.allowElement && typeof index === "number") {
1505
+ remove = !ctx.allowElement(element, index, parent);
1506
+ }
1507
+ if (remove && parent && typeof index === "number") {
1508
+ if (ctx.unwrapDisallowed && element.children) {
1509
+ parent.children.splice(index, 1, ...element.children);
1510
+ } else {
1511
+ parent.children.splice(index, 1);
1512
+ }
1513
+ return index;
1514
+ }
1515
+ }
1516
+ return void 0;
1517
+ };
1518
+ }
1519
+
1520
+ // src/components/markdown/urlTransform.ts
1521
+ var safeProtocol = /^(https?|ircs?|mailto|xmpp)$/i;
1522
+ var defaultUrlTransform = (value) => {
1523
+ const colon = value.indexOf(":");
1524
+ const questionMark = value.indexOf("?");
1525
+ const numberSign = value.indexOf("#");
1526
+ const slash = value.indexOf("/");
1527
+ if (
1528
+ // No protocol → relative.
1529
+ colon === -1 || // First colon is after `/`, `?`, or `#` → not a protocol.
1530
+ slash !== -1 && colon > slash || questionMark !== -1 && colon > questionMark || numberSign !== -1 && colon > numberSign || // Allowed protocol.
1531
+ safeProtocol.test(value.slice(0, colon))
1532
+ ) {
1533
+ return value;
1534
+ }
1535
+ return "";
1536
+ };
1537
+
1538
+ // src/components/markdown/Markdown.tsx
1539
+ var changelog = "https://github.com/remarkjs/react-markdown/blob/main/changelog.md";
1540
+ var deprecations = [
1541
+ { from: "astPlugins", id: "remove-buggy-html-in-markdown-parser" },
1542
+ { from: "allowDangerousHtml", id: "remove-buggy-html-in-markdown-parser" },
1543
+ {
1544
+ from: "allowNode",
1545
+ id: "replace-allownode-allowedtypes-and-disallowedtypes",
1546
+ to: "allowElement"
1547
+ },
1548
+ {
1549
+ from: "allowedTypes",
1550
+ id: "replace-allownode-allowedtypes-and-disallowedtypes",
1551
+ to: "allowedElements"
1552
+ },
1553
+ { from: "className", id: "remove-classname" },
1554
+ {
1555
+ from: "disallowedTypes",
1556
+ id: "replace-allownode-allowedtypes-and-disallowedtypes",
1557
+ to: "disallowedElements"
1558
+ },
1559
+ { from: "escapeHtml", id: "remove-buggy-html-in-markdown-parser" },
1560
+ { from: "includeElementIndex", id: "#remove-includeelementindex" },
1561
+ {
1562
+ from: "includeNodeIndex",
1563
+ id: "change-includenodeindex-to-includeelementindex"
1564
+ },
1565
+ { from: "linkTarget", id: "remove-linktarget" },
1566
+ { from: "plugins", id: "change-plugins-to-remarkplugins", to: "remarkPlugins" },
1567
+ { from: "rawSourcePos", id: "#remove-rawsourcepos" },
1568
+ { from: "renderers", id: "change-renderers-to-components", to: "components" },
1569
+ { from: "source", id: "change-source-to-children", to: "children" },
1570
+ { from: "sourcePos", id: "#remove-sourcepos" },
1571
+ { from: "transformImageUri", id: "#add-urltransform", to: "urlTransform" },
1572
+ { from: "transformLinkUri", id: "#add-urltransform", to: "urlTransform" }
1573
+ ];
1574
+ function validateOptions(options) {
1575
+ for (const deprecation of deprecations) {
1576
+ if (Object.hasOwn(options, deprecation.from)) {
1577
+ unreachable2(
1578
+ "Unexpected `" + deprecation.from + "` prop, " + (deprecation.to ? "use `" + deprecation.to + "` instead" : "remove it") + " (see <" + changelog + "#" + deprecation.id + "> for more info)"
1579
+ );
1580
+ }
1581
+ }
1582
+ if (options.allowedElements && options.disallowedElements) {
1583
+ unreachable2("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other");
1584
+ }
1585
+ }
1586
+ function parseStage(options) {
1587
+ validateOptions(options);
1588
+ const processor = createProcessor(options);
1589
+ const file = createFile(options);
1590
+ const mdast = processor.parse(file);
1591
+ return { processor, file, mdast };
1592
+ }
1593
+ function transformStage(parsed) {
1594
+ return parsed.processor.runSync(parsed.mdast, parsed.file);
1595
+ }
1596
+ function renderHastSubtree(tree, options) {
1597
+ const root2 = tree.type === "root" ? tree : { type: "root", children: [tree] };
1598
+ visit(
1599
+ root2,
1600
+ buildTransform({
1601
+ allowedElements: options.allowedElements,
1602
+ allowElement: options.allowElement,
1603
+ disallowedElements: options.disallowedElements,
1604
+ skipHtml: options.skipHtml,
1605
+ unwrapDisallowed: options.unwrapDisallowed,
1606
+ urlTransform: options.urlTransform || defaultUrlTransform
1607
+ })
1608
+ );
1609
+ return toJsxRuntime(root2, {
1610
+ Fragment,
1611
+ components: options.components,
1612
+ ignoreInvalidStyle: true,
1613
+ jsx: jsx2,
1614
+ jsxs,
1615
+ passKeys: true,
1616
+ passNode: true
1617
+ });
1733
1618
  }
1734
- var defaultExtraPreprocessors = [];
1735
- function preprocessAIMDContent(content, extraPreprocessors = defaultExtraPreprocessors) {
1736
- return applyPreprocessors(content, preprocessLaTeX, ...extraPreprocessors);
1619
+ function Markdown(options) {
1620
+ const parsed = parseStage(options);
1621
+ const tree = transformStage(parsed);
1622
+ return renderHastSubtree(tree, options);
1737
1623
  }
1624
+ var Markdown_default = Markdown;
1738
1625
 
1739
1626
  // src/components/MarkdownContent.tsx
1740
- import { memo, useMemo as useMemo2 } from "react";
1741
- import ReactMarkdown from "react-markdown";
1742
1627
  import rehypeKatex from "rehype-katex";
1743
1628
  import rehypeRaw from "rehype-raw";
1744
1629
  import rehypeUnwrapImages from "rehype-unwrap-images";
1745
- import rehypeSanitize, { defaultSchema } from "rehype-sanitize";
1630
+ import rehypeSanitize from "rehype-sanitize";
1631
+
1632
+ // src/components/sanitizeSchema.ts
1633
+ import { defaultSchema } from "rehype-sanitize";
1634
+ function mergeClassNameAllowlist(existing, extraClassNames) {
1635
+ const entries = existing ? [...existing] : [];
1636
+ const idx = entries.findIndex(
1637
+ (entry) => typeof entry === "string" ? entry === "className" : entry[0] === "className"
1638
+ );
1639
+ if (idx === -1) {
1640
+ return [...entries, ["className", ...extraClassNames]];
1641
+ }
1642
+ const current = entries[idx];
1643
+ const merged = typeof current === "string" ? ["className", ...extraClassNames] : [...current, ...extraClassNames];
1644
+ entries[idx] = merged;
1645
+ return entries;
1646
+ }
1647
+ var sanitizeSchema = {
1648
+ ...defaultSchema,
1649
+ tagNames: [...defaultSchema.tagNames || [], "mark"],
1650
+ attributes: {
1651
+ ...defaultSchema.attributes,
1652
+ code: mergeClassNameAllowlist(defaultSchema.attributes?.code, ["math-inline", "math-display"])
1653
+ }
1654
+ };
1655
+
1656
+ // src/components/rehypeRebaseHashLinks.ts
1657
+ import { visit as visit2 } from "unist-util-visit";
1658
+ var DEFAULT_PREFIX = "user-content-";
1659
+ var rehypeRebaseHashLinks = (options) => {
1660
+ const prefix = options?.prefix ?? DEFAULT_PREFIX;
1661
+ const hashPrefix = "#" + prefix;
1662
+ return (tree) => {
1663
+ visit2(tree, "element", (node) => {
1664
+ if (node.tagName !== "a") return;
1665
+ const href = node.properties?.href;
1666
+ if (typeof href !== "string" || !href.startsWith("#")) return;
1667
+ if (href.startsWith(hashPrefix)) return;
1668
+ node.properties.href = hashPrefix + href.slice(1);
1669
+ });
1670
+ };
1671
+ };
1672
+ var rehypeRebaseHashLinks_default = rehypeRebaseHashLinks;
1673
+
1674
+ // src/components/MarkdownContent.tsx
1746
1675
  import remarkBreaks from "remark-breaks";
1747
1676
  import remarkCjkFriendly from "remark-cjk-friendly";
1748
1677
  import remarkCjkFriendlyGfmStrikethrough from "remark-cjk-friendly-gfm-strikethrough";
@@ -1750,13 +1679,180 @@ import remarkEmoji from "remark-emoji";
1750
1679
  import remarkGfm from "remark-gfm";
1751
1680
  import remarkMath from "remark-math";
1752
1681
  import { remarkDefinitionList, defListHastHandlers } from "remark-definition-list";
1753
- import remarkSupersub from "remark-supersub";
1754
1682
  import { remarkMark as remarkMarkHighlight } from "remark-mark-highlight";
1755
1683
  import remarkSqueezeParagraphs from "remark-squeeze-paragraphs";
1756
1684
  import remarkSmartypants from "remark-smartypants";
1757
1685
  import remarkPangu from "remark-pangu";
1758
1686
  import remarkRemoveComments from "remark-remove-comments";
1759
- import { jsx as jsx2 } from "react/jsx-runtime";
1687
+
1688
+ // src/components/blockMemo.ts
1689
+ import { visit as visit3 } from "unist-util-visit";
1690
+ var TAINT_TYPES = /* @__PURE__ */ new Set([
1691
+ "footnoteReference",
1692
+ "footnoteDefinition",
1693
+ "linkReference",
1694
+ "imageReference",
1695
+ "definition"
1696
+ ]);
1697
+ var CTX_TYPES = TAINT_TYPES;
1698
+ function createCache() {
1699
+ return { blocks: /* @__PURE__ */ new Map() };
1700
+ }
1701
+ function extractRaw(node, source) {
1702
+ if (!node.position) return "";
1703
+ return source.slice(node.position.start.offset, node.position.end.offset);
1704
+ }
1705
+ function isFootnoteSection(node) {
1706
+ if (node.tagName !== "section") return false;
1707
+ const props = node.properties;
1708
+ return props?.dataFootnotes !== void 0;
1709
+ }
1710
+ function hasMdastSource(node) {
1711
+ return node.position !== void 0;
1712
+ }
1713
+ var FOOTNOTE_SECTION_KEY = "__footnote_section__";
1714
+ function buildBlocks(mdast, hast, source) {
1715
+ const mdastByOffset = /* @__PURE__ */ new Map();
1716
+ for (const child of mdast.children) {
1717
+ const off = child.position?.start.offset;
1718
+ if (off !== void 0) {
1719
+ mdastByOffset.set(off, child);
1720
+ }
1721
+ }
1722
+ const ctxParts = [];
1723
+ visit3(mdast, (n) => {
1724
+ if (!CTX_TYPES.has(n.type)) return;
1725
+ if (n.type === "footnoteReference") ctxParts.push(["fr", n.identifier]);
1726
+ else if (n.type === "footnoteDefinition") ctxParts.push(["fd", n.identifier, extractRaw(n, source)]);
1727
+ else if (n.type === "linkReference") ctxParts.push(["lr", n.identifier]);
1728
+ else if (n.type === "imageReference") ctxParts.push(["ir", n.identifier]);
1729
+ else if (n.type === "definition") ctxParts.push(["d", n.identifier, n.url, n.title ?? null]);
1730
+ });
1731
+ const globalCtx = JSON.stringify(ctxParts);
1732
+ const plan = [];
1733
+ const blocks = [];
1734
+ const blockHasts = [];
1735
+ let synthetic;
1736
+ for (let i = 0; i < hast.children.length; i++) {
1737
+ const hastChild = hast.children[i];
1738
+ if (hastChild.type !== "element") {
1739
+ const off = hastChild.position?.start.offset;
1740
+ const reactKey = off !== void 0 ? `inline-${off}` : `inline-i${i}`;
1741
+ plan.push({ kind: "inline", el: hastChild, reactKey });
1742
+ continue;
1743
+ }
1744
+ const el = hastChild;
1745
+ if (isFootnoteSection(el)) {
1746
+ synthetic = el;
1747
+ plan.push({ kind: "synthetic", el, reactKey: FOOTNOTE_SECTION_KEY });
1748
+ continue;
1749
+ }
1750
+ const hastOffset = el.position?.start.offset;
1751
+ if (hastOffset === void 0) {
1752
+ plan.push({ kind: "inline", el, reactKey: `inline-i${i}` });
1753
+ continue;
1754
+ }
1755
+ let mdastNode = mdastByOffset.get(hastOffset);
1756
+ if (!mdastNode) {
1757
+ mdastNode = mdast.children.findLast((child) => {
1758
+ const startOff = child.position?.start.offset;
1759
+ const endOff = child.position?.end.offset;
1760
+ return startOff !== void 0 && endOff !== void 0 && startOff <= hastOffset && hastOffset < endOff;
1761
+ });
1762
+ }
1763
+ if (!mdastNode) {
1764
+ if (process.env.NODE_ENV !== "production") {
1765
+ throw new Error(
1766
+ `block-memo: hast block at offset ${hastOffset} has no mdast counterpart. A rehype plugin may have synthesized positions outside source. tagName=${el.tagName}`
1767
+ );
1768
+ }
1769
+ plan.push({ kind: "inline", el, reactKey: `inline-${hastOffset}` });
1770
+ continue;
1771
+ }
1772
+ if (mdastNode.type === "footnoteDefinition") {
1773
+ plan.push({ kind: "inline", el, reactKey: `inline-${hastOffset}` });
1774
+ continue;
1775
+ }
1776
+ let hasReference = false;
1777
+ visit3(mdastNode, (n) => {
1778
+ if (TAINT_TYPES.has(n.type)) {
1779
+ hasReference = true;
1780
+ return false;
1781
+ }
1782
+ return void 0;
1783
+ });
1784
+ const mdastPos = mdastNode.position;
1785
+ if (!mdastPos || mdastPos.start.offset === void 0 || mdastPos.end.offset === void 0) {
1786
+ continue;
1787
+ }
1788
+ const info = {
1789
+ raw: extractRaw(mdastNode, source),
1790
+ startOffset: mdastPos.start.offset,
1791
+ endOffset: mdastPos.end.offset,
1792
+ startLine: mdastPos.start.line,
1793
+ startColumn: mdastPos.start.column,
1794
+ hasReference
1795
+ };
1796
+ blocks.push(info);
1797
+ blockHasts.push(el);
1798
+ plan.push({ kind: "block", el, info, reactKey: `block-${hastOffset}` });
1799
+ }
1800
+ return { plan, globalCtx, blocks, blockHasts, synthetic };
1801
+ }
1802
+ function renderBlocksWithCache(cacheRef, plan, globalCtx, postOptions) {
1803
+ const prev = cacheRef.current;
1804
+ const next = { blocks: /* @__PURE__ */ new Map() };
1805
+ const rendered = [];
1806
+ if (process.env.NODE_ENV !== "production") {
1807
+ for (const item of plan) {
1808
+ if (item.kind === "block" && !hasMdastSource(item.el)) {
1809
+ throw new Error(
1810
+ "block-memo: block hast child has no position. Did a rehype plugin strip it? (Run positionPropagation.test.ts to verify.)"
1811
+ );
1812
+ }
1813
+ }
1814
+ }
1815
+ for (const item of plan) {
1816
+ if (item.kind === "inline") {
1817
+ rendered.push({
1818
+ node: renderHastSubtree(item.el, postOptions),
1819
+ reactKey: item.reactKey
1820
+ });
1821
+ continue;
1822
+ }
1823
+ if (item.kind === "synthetic") {
1824
+ const cached = prev.footnoteSection;
1825
+ const node2 = cached && cached.ctx === globalCtx ? cached.node : renderHastSubtree(item.el, postOptions);
1826
+ next.footnoteSection = { ctx: globalCtx, node: node2 };
1827
+ rendered.push({ node: node2, reactKey: item.reactKey });
1828
+ continue;
1829
+ }
1830
+ const block = item.info;
1831
+ let bucket = next.blocks.get(block.raw);
1832
+ if (!bucket) {
1833
+ bucket = [];
1834
+ next.blocks.set(block.raw, bucket);
1835
+ }
1836
+ const occ = bucket.length;
1837
+ const blockCtx = block.hasReference ? globalCtx : "";
1838
+ const entry = prev.blocks.get(block.raw)?.[occ];
1839
+ const valid = entry !== void 0 && entry.ctx === blockCtx && entry.startOffset === block.startOffset && entry.startLine === block.startLine && entry.startColumn === block.startColumn;
1840
+ const node = valid ? entry.node : renderHastSubtree(item.el, postOptions);
1841
+ bucket.push({
1842
+ node,
1843
+ ctx: blockCtx,
1844
+ startOffset: block.startOffset,
1845
+ startLine: block.startLine,
1846
+ startColumn: block.startColumn
1847
+ });
1848
+ rendered.push({ node, reactKey: item.reactKey });
1849
+ }
1850
+ cacheRef.current = next;
1851
+ return rendered;
1852
+ }
1853
+
1854
+ // src/components/MarkdownContent.tsx
1855
+ import { Fragment as Fragment3, jsx as jsx3 } from "react/jsx-runtime";
1760
1856
  var DisplayOptimizeRemarkPluginMap = {
1761
1857
  ["REMOVE_COMMENTS" /* REMOVE_COMMENTS */]: remarkRemoveComments,
1762
1858
  ["SMARTYPANTS" /* SMARTYPANTS */]: remarkSmartypants,
@@ -1764,12 +1860,89 @@ var DisplayOptimizeRemarkPluginMap = {
1764
1860
  };
1765
1861
  var ExtraSyntaxRemarkPluginMap = {
1766
1862
  ["HIGHLIGHT" /* HIGHLIGHT */]: remarkMarkHighlight,
1767
- ["DEFINITION_LIST" /* DEFINITION_LIST */]: remarkDefinitionList,
1768
- ["SUBSCRIPT" /* SUBSCRIPT */]: remarkSupersub
1863
+ ["DEFINITION_LIST" /* DEFINITION_LIST */]: remarkDefinitionList
1769
1864
  };
1770
1865
  var DefaultCustomComponents = {};
1866
+ var BlockMemoizedRenderer = memo(
1867
+ ({ content, usedComponents, remarkPlugins, rehypePlugins, remarkRehypeOptions }) => {
1868
+ const urlTransform = void 0;
1869
+ const allowedElements = void 0;
1870
+ const disallowedElements = void 0;
1871
+ const allowElement = void 0;
1872
+ const skipHtml = void 0;
1873
+ const unwrapDisallowed = void 0;
1874
+ const cacheRef = useRef(createCache());
1875
+ const depsRef = useRef({
1876
+ usedComponents,
1877
+ remarkPlugins,
1878
+ rehypePlugins,
1879
+ remarkRehypeOptions,
1880
+ urlTransform,
1881
+ allowedElements,
1882
+ disallowedElements,
1883
+ allowElement,
1884
+ skipHtml,
1885
+ unwrapDisallowed
1886
+ });
1887
+ if (depsRef.current.usedComponents !== usedComponents || depsRef.current.remarkPlugins !== remarkPlugins || depsRef.current.rehypePlugins !== rehypePlugins || depsRef.current.remarkRehypeOptions !== remarkRehypeOptions || depsRef.current.urlTransform !== urlTransform || depsRef.current.allowedElements !== allowedElements || depsRef.current.disallowedElements !== disallowedElements || depsRef.current.allowElement !== allowElement || depsRef.current.skipHtml !== skipHtml || depsRef.current.unwrapDisallowed !== unwrapDisallowed) {
1888
+ cacheRef.current = createCache();
1889
+ depsRef.current = {
1890
+ usedComponents,
1891
+ remarkPlugins,
1892
+ rehypePlugins,
1893
+ remarkRehypeOptions,
1894
+ urlTransform,
1895
+ allowedElements,
1896
+ disallowedElements,
1897
+ allowElement,
1898
+ skipHtml,
1899
+ unwrapDisallowed
1900
+ };
1901
+ }
1902
+ const parsed = useMemo2(
1903
+ () => parseStage({
1904
+ children: content,
1905
+ remarkPlugins,
1906
+ rehypePlugins,
1907
+ remarkRehypeOptions
1908
+ }),
1909
+ [content, remarkPlugins, rehypePlugins, remarkRehypeOptions]
1910
+ );
1911
+ const hast = useMemo2(() => transformStage(parsed), [parsed]);
1912
+ const built = useMemo2(() => buildBlocks(parsed.mdast, hast, content), [parsed.mdast, hast, content]);
1913
+ const postOptions = useMemo2(
1914
+ () => ({
1915
+ components: usedComponents,
1916
+ urlTransform,
1917
+ allowedElements,
1918
+ disallowedElements,
1919
+ allowElement,
1920
+ skipHtml,
1921
+ unwrapDisallowed
1922
+ }),
1923
+ [usedComponents, urlTransform, allowedElements, disallowedElements, allowElement, skipHtml, unwrapDisallowed]
1924
+ );
1925
+ const rendered = renderBlocksWithCache(cacheRef, built.plan, built.globalCtx, postOptions);
1926
+ return /* @__PURE__ */ jsx3(Fragment3, { children: rendered.map(({ node, reactKey }) => /* @__PURE__ */ jsx3(Fragment2, { children: node }, reactKey)) });
1927
+ }
1928
+ );
1929
+ BlockMemoizedRenderer.displayName = "BlockMemoizedRenderer";
1930
+ var LegacyRenderer = memo(
1931
+ ({ content, usedComponents, remarkPlugins, rehypePlugins, remarkRehypeOptions }) => /* @__PURE__ */ jsx3(
1932
+ Markdown_default,
1933
+ {
1934
+ remarkPlugins,
1935
+ rehypePlugins,
1936
+ remarkRehypeOptions,
1937
+ components: usedComponents,
1938
+ children: content
1939
+ }
1940
+ )
1941
+ );
1942
+ LegacyRenderer.displayName = "LegacyRenderer";
1771
1943
  var AIMarkdownContent = memo(({ content, customComponents }) => {
1772
- const { config } = useAIMarkdownRenderState();
1944
+ const { config, documentId } = useAIMarkdownRenderState();
1945
+ const clobberPrefix = `${encodeURIComponent(documentId)}-user-content-`;
1773
1946
  const { extraSyntaxRemarkPlugins, enableDefinitionList } = useMemo2(
1774
1947
  () => ({
1775
1948
  extraSyntaxRemarkPlugins: config.extraSyntaxSupported.map((syntax) => ExtraSyntaxRemarkPluginMap[syntax]),
@@ -1783,64 +1956,73 @@ var AIMarkdownContent = memo(({ content, customComponents }) => {
1783
1956
  const usedComponents = useMemo2(() => {
1784
1957
  return customComponents ? { ...DefaultCustomComponents, ...customComponents } : DefaultCustomComponents;
1785
1958
  }, [customComponents]);
1786
- return /* @__PURE__ */ jsx2(
1787
- ReactMarkdown,
1788
- {
1789
- remarkPlugins: [
1790
- // --- Core plugins (always active) ---
1791
- remarkGfm,
1792
- [
1793
- remarkMath,
1794
- {
1795
- // Disable single-dollar inline math to avoid conflicts with currency
1796
- // signs and other dollar usages; the preprocessor converts $...$ to $$...$$.
1797
- singleDollarTextMath: false
1798
- }
1799
- ],
1800
- // --- Configurable extra syntax plugins ---
1801
- ...extraSyntaxRemarkPlugins,
1802
- // --- Formatting & normalization ---
1803
- remarkBreaks,
1804
- remarkEmoji,
1805
- remarkSqueezeParagraphs,
1806
- remarkCjkFriendly,
1807
- remarkCjkFriendlyGfmStrikethrough,
1808
- // --- Configurable display optimizations ---
1809
- ...displayOptimizeRemarkPlugins
1810
- ],
1811
- rehypePlugins: [
1812
- // Allow raw HTML through so rehype-sanitize can handle it.
1813
- [
1814
- rehypeRaw,
1815
- {
1816
- passThrough: []
1817
- }
1818
- ],
1819
- // Sanitize HTML while allowing <mark> (highlight) and KaTeX class names.
1820
- [
1821
- rehypeSanitize,
1822
- {
1823
- ...defaultSchema,
1824
- tagNames: [...defaultSchema.tagNames || [], "mark"],
1825
- attributes: {
1826
- ...defaultSchema.attributes,
1827
- // The `language-*` regex is allowed by default.
1828
- code: [["className", /^language-./, "math-inline", "math-display"]]
1829
- }
1830
- }
1831
- ],
1832
- rehypeKatex,
1833
- rehypeUnwrapImages
1834
- ],
1835
- remarkRehypeOptions: {
1836
- allowDangerousHtml: true,
1837
- handlers: {
1838
- // Inject definition-list HAST handlers when the extension is active.
1839
- ...enableDefinitionList ? defListHastHandlers : {}
1959
+ const remarkPlugins = useMemo2(
1960
+ () => [
1961
+ // --- Core plugins (always active) ---
1962
+ remarkGfm,
1963
+ [
1964
+ remarkMath,
1965
+ {
1966
+ // Disable single-dollar inline math to avoid conflicts with currency
1967
+ // signs and other dollar usages; the preprocessor converts $...$ to $$...$$.
1968
+ singleDollarTextMath: false
1840
1969
  }
1841
- },
1842
- components: usedComponents,
1843
- children: content
1970
+ ],
1971
+ // --- Configurable extra syntax plugins ---
1972
+ ...extraSyntaxRemarkPlugins,
1973
+ // --- Formatting & normalization ---
1974
+ remarkBreaks,
1975
+ remarkEmoji,
1976
+ remarkSqueezeParagraphs,
1977
+ remarkCjkFriendly,
1978
+ remarkCjkFriendlyGfmStrikethrough,
1979
+ // --- Configurable display optimizations ---
1980
+ ...displayOptimizeRemarkPlugins
1981
+ ],
1982
+ [extraSyntaxRemarkPlugins, displayOptimizeRemarkPlugins]
1983
+ );
1984
+ const rehypePlugins = useMemo2(
1985
+ () => [
1986
+ // Allow raw HTML through so rehype-sanitize can handle it.
1987
+ [rehypeRaw, { passThrough: [] }],
1988
+ // Sanitize HTML while allowing <mark> (highlight) and KaTeX class names.
1989
+ // Override `clobberPrefix` with the instance-scoped value so every id
1990
+ // and clobberable attribute is namespaced to this `<AIMarkdown>` instance.
1991
+ [rehypeSanitize, { ...sanitizeSchema, clobberPrefix }],
1992
+ // Re-prefix intra-document hash hrefs so they match the ids that
1993
+ // rehype-sanitize just clobbered. Must use the SAME prefix as the schema
1994
+ // above — that's why both read from `clobberPrefix`.
1995
+ [rehypeRebaseHashLinks_default, { prefix: clobberPrefix }],
1996
+ rehypeKatex,
1997
+ rehypeUnwrapImages
1998
+ ],
1999
+ [clobberPrefix]
2000
+ );
2001
+ const remarkRehypeOptions = useMemo2(
2002
+ () => ({
2003
+ allowDangerousHtml: true,
2004
+ // Suppress mdast-util-to-hast's `user-content-` prefix on footnote
2005
+ // ids/hrefs; rehype-sanitize will apply the same prefix downstream
2006
+ // and `rehypeRebaseHashLinks` mirrors it onto matching hash hrefs.
2007
+ // Without this, ids would end up double-prefixed
2008
+ // (`user-content-user-content-fn-x`).
2009
+ clobberPrefix: "",
2010
+ handlers: {
2011
+ // Inject definition-list HAST handlers when the extension is active.
2012
+ ...enableDefinitionList ? defListHastHandlers : {}
2013
+ }
2014
+ }),
2015
+ [enableDefinitionList]
2016
+ );
2017
+ const Renderer = config.blockMemoEnabled ? BlockMemoizedRenderer : LegacyRenderer;
2018
+ return /* @__PURE__ */ jsx3(
2019
+ Renderer,
2020
+ {
2021
+ content,
2022
+ usedComponents,
2023
+ remarkPlugins,
2024
+ rehypePlugins,
2025
+ remarkRehypeOptions
1844
2026
  }
1845
2027
  );
1846
2028
  });
@@ -1848,7 +2030,7 @@ AIMarkdownContent.displayName = "AIMarkdownContent";
1848
2030
  var MarkdownContent_default = AIMarkdownContent;
1849
2031
 
1850
2032
  // src/hooks/useStableValue.ts
1851
- import { useRef, useEffect } from "react";
2033
+ import { useRef as useRef2, useLayoutEffect, useEffect } from "react";
1852
2034
 
1853
2035
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_setCacheAdd.js
1854
2036
  var HASH_UNDEFINED3 = "__lodash_hash_undefined__";
@@ -1965,44 +2147,44 @@ var setToArray_default = setToArray;
1965
2147
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_equalByTag.js
1966
2148
  var COMPARE_PARTIAL_FLAG2 = 1;
1967
2149
  var COMPARE_UNORDERED_FLAG2 = 2;
1968
- var boolTag4 = "[object Boolean]";
1969
- var dateTag4 = "[object Date]";
1970
- var errorTag3 = "[object Error]";
1971
- var mapTag6 = "[object Map]";
1972
- var numberTag4 = "[object Number]";
1973
- var regexpTag4 = "[object RegExp]";
1974
- var setTag6 = "[object Set]";
1975
- var stringTag4 = "[object String]";
1976
- var symbolTag3 = "[object Symbol]";
1977
- var arrayBufferTag4 = "[object ArrayBuffer]";
1978
- var dataViewTag5 = "[object DataView]";
1979
- var symbolProto2 = Symbol_default ? Symbol_default.prototype : void 0;
1980
- var symbolValueOf2 = symbolProto2 ? symbolProto2.valueOf : void 0;
2150
+ var boolTag2 = "[object Boolean]";
2151
+ var dateTag2 = "[object Date]";
2152
+ var errorTag2 = "[object Error]";
2153
+ var mapTag2 = "[object Map]";
2154
+ var numberTag2 = "[object Number]";
2155
+ var regexpTag2 = "[object RegExp]";
2156
+ var setTag2 = "[object Set]";
2157
+ var stringTag2 = "[object String]";
2158
+ var symbolTag = "[object Symbol]";
2159
+ var arrayBufferTag2 = "[object ArrayBuffer]";
2160
+ var dataViewTag2 = "[object DataView]";
2161
+ var symbolProto = Symbol_default ? Symbol_default.prototype : void 0;
2162
+ var symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
1981
2163
  function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
1982
2164
  switch (tag) {
1983
- case dataViewTag5:
2165
+ case dataViewTag2:
1984
2166
  if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
1985
2167
  return false;
1986
2168
  }
1987
2169
  object = object.buffer;
1988
2170
  other = other.buffer;
1989
- case arrayBufferTag4:
2171
+ case arrayBufferTag2:
1990
2172
  if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array_default(object), new Uint8Array_default(other))) {
1991
2173
  return false;
1992
2174
  }
1993
2175
  return true;
1994
- case boolTag4:
1995
- case dateTag4:
1996
- case numberTag4:
2176
+ case boolTag2:
2177
+ case dateTag2:
2178
+ case numberTag2:
1997
2179
  return eq_default(+object, +other);
1998
- case errorTag3:
2180
+ case errorTag2:
1999
2181
  return object.name == other.name && object.message == other.message;
2000
- case regexpTag4:
2001
- case stringTag4:
2182
+ case regexpTag2:
2183
+ case stringTag2:
2002
2184
  return object == other + "";
2003
- case mapTag6:
2185
+ case mapTag2:
2004
2186
  var convert = mapToArray_default;
2005
- case setTag6:
2187
+ case setTag2:
2006
2188
  var isPartial = bitmask & COMPARE_PARTIAL_FLAG2;
2007
2189
  convert || (convert = setToArray_default);
2008
2190
  if (object.size != other.size && !isPartial) {
@@ -2017,19 +2199,103 @@ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
2017
2199
  var result = equalArrays_default(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
2018
2200
  stack["delete"](object);
2019
2201
  return result;
2020
- case symbolTag3:
2021
- if (symbolValueOf2) {
2022
- return symbolValueOf2.call(object) == symbolValueOf2.call(other);
2202
+ case symbolTag:
2203
+ if (symbolValueOf) {
2204
+ return symbolValueOf.call(object) == symbolValueOf.call(other);
2023
2205
  }
2024
2206
  }
2025
2207
  return false;
2026
2208
  }
2027
2209
  var equalByTag_default = equalByTag;
2028
2210
 
2211
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayPush.js
2212
+ function arrayPush(array, values) {
2213
+ var index = -1, length = values.length, offset = array.length;
2214
+ while (++index < length) {
2215
+ array[offset + index] = values[index];
2216
+ }
2217
+ return array;
2218
+ }
2219
+ var arrayPush_default = arrayPush;
2220
+
2221
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseGetAllKeys.js
2222
+ function baseGetAllKeys(object, keysFunc, symbolsFunc) {
2223
+ var result = keysFunc(object);
2224
+ return isArray_default(object) ? result : arrayPush_default(result, symbolsFunc(object));
2225
+ }
2226
+ var baseGetAllKeys_default = baseGetAllKeys;
2227
+
2228
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_arrayFilter.js
2229
+ function arrayFilter(array, predicate) {
2230
+ var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
2231
+ while (++index < length) {
2232
+ var value = array[index];
2233
+ if (predicate(value, index, array)) {
2234
+ result[resIndex++] = value;
2235
+ }
2236
+ }
2237
+ return result;
2238
+ }
2239
+ var arrayFilter_default = arrayFilter;
2240
+
2241
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/stubArray.js
2242
+ function stubArray() {
2243
+ return [];
2244
+ }
2245
+ var stubArray_default = stubArray;
2246
+
2247
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getSymbols.js
2248
+ var objectProto12 = Object.prototype;
2249
+ var propertyIsEnumerable2 = objectProto12.propertyIsEnumerable;
2250
+ var nativeGetSymbols = Object.getOwnPropertySymbols;
2251
+ var getSymbols = !nativeGetSymbols ? stubArray_default : function(object) {
2252
+ if (object == null) {
2253
+ return [];
2254
+ }
2255
+ object = Object(object);
2256
+ return arrayFilter_default(nativeGetSymbols(object), function(symbol) {
2257
+ return propertyIsEnumerable2.call(object, symbol);
2258
+ });
2259
+ };
2260
+ var getSymbols_default = getSymbols;
2261
+
2262
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeys.js
2263
+ var nativeKeys = overArg_default(Object.keys, Object);
2264
+ var nativeKeys_default = nativeKeys;
2265
+
2266
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseKeys.js
2267
+ var objectProto13 = Object.prototype;
2268
+ var hasOwnProperty10 = objectProto13.hasOwnProperty;
2269
+ function baseKeys(object) {
2270
+ if (!isPrototype_default(object)) {
2271
+ return nativeKeys_default(object);
2272
+ }
2273
+ var result = [];
2274
+ for (var key in Object(object)) {
2275
+ if (hasOwnProperty10.call(object, key) && key != "constructor") {
2276
+ result.push(key);
2277
+ }
2278
+ }
2279
+ return result;
2280
+ }
2281
+ var baseKeys_default = baseKeys;
2282
+
2283
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/keys.js
2284
+ function keys(object) {
2285
+ return isArrayLike_default(object) ? arrayLikeKeys_default(object) : baseKeys_default(object);
2286
+ }
2287
+ var keys_default = keys;
2288
+
2289
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeys.js
2290
+ function getAllKeys(object) {
2291
+ return baseGetAllKeys_default(object, keys_default, getSymbols_default);
2292
+ }
2293
+ var getAllKeys_default = getAllKeys;
2294
+
2029
2295
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_equalObjects.js
2030
2296
  var COMPARE_PARTIAL_FLAG3 = 1;
2031
- var objectProto15 = Object.prototype;
2032
- var hasOwnProperty12 = objectProto15.hasOwnProperty;
2297
+ var objectProto14 = Object.prototype;
2298
+ var hasOwnProperty11 = objectProto14.hasOwnProperty;
2033
2299
  function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
2034
2300
  var isPartial = bitmask & COMPARE_PARTIAL_FLAG3, objProps = getAllKeys_default(object), objLength = objProps.length, othProps = getAllKeys_default(other), othLength = othProps.length;
2035
2301
  if (objLength != othLength && !isPartial) {
@@ -2038,7 +2304,7 @@ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
2038
2304
  var index = objLength;
2039
2305
  while (index--) {
2040
2306
  var key = objProps[index];
2041
- if (!(isPartial ? key in other : hasOwnProperty12.call(other, key))) {
2307
+ if (!(isPartial ? key in other : hasOwnProperty11.call(other, key))) {
2042
2308
  return false;
2043
2309
  }
2044
2310
  }
@@ -2075,18 +2341,69 @@ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
2075
2341
  }
2076
2342
  var equalObjects_default = equalObjects;
2077
2343
 
2344
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_DataView.js
2345
+ var DataView = getNative_default(root_default, "DataView");
2346
+ var DataView_default = DataView;
2347
+
2348
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Promise.js
2349
+ var Promise2 = getNative_default(root_default, "Promise");
2350
+ var Promise_default = Promise2;
2351
+
2352
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_Set.js
2353
+ var Set2 = getNative_default(root_default, "Set");
2354
+ var Set_default = Set2;
2355
+
2356
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js
2357
+ var WeakMap = getNative_default(root_default, "WeakMap");
2358
+ var WeakMap_default = WeakMap;
2359
+
2360
+ // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js
2361
+ var mapTag3 = "[object Map]";
2362
+ var objectTag3 = "[object Object]";
2363
+ var promiseTag = "[object Promise]";
2364
+ var setTag3 = "[object Set]";
2365
+ var weakMapTag2 = "[object WeakMap]";
2366
+ var dataViewTag3 = "[object DataView]";
2367
+ var dataViewCtorString = toSource_default(DataView_default);
2368
+ var mapCtorString = toSource_default(Map_default);
2369
+ var promiseCtorString = toSource_default(Promise_default);
2370
+ var setCtorString = toSource_default(Set_default);
2371
+ var weakMapCtorString = toSource_default(WeakMap_default);
2372
+ var getTag = baseGetTag_default;
2373
+ 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) {
2374
+ getTag = function(value) {
2375
+ var result = baseGetTag_default(value), Ctor = result == objectTag3 ? value.constructor : void 0, ctorString = Ctor ? toSource_default(Ctor) : "";
2376
+ if (ctorString) {
2377
+ switch (ctorString) {
2378
+ case dataViewCtorString:
2379
+ return dataViewTag3;
2380
+ case mapCtorString:
2381
+ return mapTag3;
2382
+ case promiseCtorString:
2383
+ return promiseTag;
2384
+ case setCtorString:
2385
+ return setTag3;
2386
+ case weakMapCtorString:
2387
+ return weakMapTag2;
2388
+ }
2389
+ }
2390
+ return result;
2391
+ };
2392
+ }
2393
+ var getTag_default = getTag;
2394
+
2078
2395
  // ../../node_modules/.pnpm/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqualDeep.js
2079
2396
  var COMPARE_PARTIAL_FLAG4 = 1;
2080
- var argsTag4 = "[object Arguments]";
2081
- var arrayTag3 = "[object Array]";
2082
- var objectTag5 = "[object Object]";
2083
- var objectProto16 = Object.prototype;
2084
- var hasOwnProperty13 = objectProto16.hasOwnProperty;
2397
+ var argsTag3 = "[object Arguments]";
2398
+ var arrayTag2 = "[object Array]";
2399
+ var objectTag4 = "[object Object]";
2400
+ var objectProto15 = Object.prototype;
2401
+ var hasOwnProperty12 = objectProto15.hasOwnProperty;
2085
2402
  function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
2086
- var objIsArr = isArray_default(object), othIsArr = isArray_default(other), objTag = objIsArr ? arrayTag3 : getTag_default(object), othTag = othIsArr ? arrayTag3 : getTag_default(other);
2087
- objTag = objTag == argsTag4 ? objectTag5 : objTag;
2088
- othTag = othTag == argsTag4 ? objectTag5 : othTag;
2089
- var objIsObj = objTag == objectTag5, othIsObj = othTag == objectTag5, isSameTag = objTag == othTag;
2403
+ var objIsArr = isArray_default(object), othIsArr = isArray_default(other), objTag = objIsArr ? arrayTag2 : getTag_default(object), othTag = othIsArr ? arrayTag2 : getTag_default(other);
2404
+ objTag = objTag == argsTag3 ? objectTag4 : objTag;
2405
+ othTag = othTag == argsTag3 ? objectTag4 : othTag;
2406
+ var objIsObj = objTag == objectTag4, othIsObj = othTag == objectTag4, isSameTag = objTag == othTag;
2090
2407
  if (isSameTag && isBuffer_default(object)) {
2091
2408
  if (!isBuffer_default(other)) {
2092
2409
  return false;
@@ -2099,7 +2416,7 @@ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
2099
2416
  return objIsArr || isTypedArray_default(object) ? equalArrays_default(object, other, bitmask, customizer, equalFunc, stack) : equalByTag_default(object, other, objTag, bitmask, customizer, equalFunc, stack);
2100
2417
  }
2101
2418
  if (!(bitmask & COMPARE_PARTIAL_FLAG4)) {
2102
- var objIsWrapped = objIsObj && hasOwnProperty13.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty13.call(other, "__wrapped__");
2419
+ var objIsWrapped = objIsObj && hasOwnProperty12.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty12.call(other, "__wrapped__");
2103
2420
  if (objIsWrapped || othIsWrapped) {
2104
2421
  var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
2105
2422
  stack || (stack = new Stack_default());
@@ -2133,32 +2450,33 @@ function isEqual(value, other) {
2133
2450
  var isEqual_default = isEqual;
2134
2451
 
2135
2452
  // src/hooks/useStableValue.ts
2453
+ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
2136
2454
  function useStableValue(value) {
2137
- const ref = useRef(value);
2455
+ const ref = useRef2(value);
2138
2456
  const prev = ref.current;
2139
2457
  const stableValue = isEqual_default(prev, value) ? prev : value;
2140
- useEffect(() => {
2458
+ useIsomorphicLayoutEffect(() => {
2141
2459
  ref.current = stableValue;
2142
2460
  }, [stableValue]);
2143
2461
  return stableValue;
2144
2462
  }
2145
2463
 
2146
2464
  // src/components/typography/Default.tsx
2147
- import { memo as memo2 } from "react";
2148
- import { jsx as jsx3 } from "react/jsx-runtime";
2149
- var DefaultTypography = memo2(({ children, fontSize, variant, colorScheme, style }) => /* @__PURE__ */ jsx3(
2150
- "div",
2151
- {
2152
- className: `aim-typography-root ${variant ?? ""} ${colorScheme ?? ""}`.trim(),
2153
- style: { width: "100%", fontSize, ...style },
2154
- children
2155
- }
2156
- ));
2465
+ import { memo as memo2, useMemo as useMemo3 } from "react";
2466
+ import { jsx as jsx4 } from "react/jsx-runtime";
2467
+ var DefaultTypography = memo2(({ children, fontSize, variant, colorScheme, style }) => {
2468
+ const className = useMemo3(
2469
+ () => ["aim-typography-root", variant, colorScheme].filter(Boolean).join(" "),
2470
+ [variant, colorScheme]
2471
+ );
2472
+ const mergedStyle = useMemo3(() => ({ width: "100%", fontSize, ...style }), [fontSize, style]);
2473
+ return /* @__PURE__ */ jsx4("div", { className, style: mergedStyle, children });
2474
+ });
2157
2475
  DefaultTypography.displayName = "DefaultTypography";
2158
2476
  var Default_default = DefaultTypography;
2159
2477
 
2160
2478
  // src/index.tsx
2161
- import { jsx as jsx4 } from "react/jsx-runtime";
2479
+ import { jsx as jsx5 } from "react/jsx-runtime";
2162
2480
  var AIMarkdownComponent = ({
2163
2481
  streaming = false,
2164
2482
  content,
@@ -2171,34 +2489,39 @@ var AIMarkdownComponent = ({
2171
2489
  Typography = Default_default,
2172
2490
  ExtraStyles,
2173
2491
  variant = "default",
2174
- colorScheme = "light"
2492
+ colorScheme = "light",
2493
+ documentId
2175
2494
  }) => {
2176
- const usedFontSize = fontSize ? typeof fontSize === "number" ? `${fontSize}px` : fontSize : "0.9375rem";
2495
+ const usedFontSize = fontSize === void 0 ? "0.9375rem" : typeof fontSize === "number" ? `${fontSize}px` : fontSize;
2496
+ const generatedId = useId2();
2497
+ const usedDocumentId = documentId && documentId.length > 0 ? documentId : generatedId;
2177
2498
  const stableDefaultConfig = useStableValue(defaultConfig);
2178
2499
  const stableConfig = useStableValue(config);
2179
2500
  const stablePreprocessors = useStableValue(contentPreprocessors);
2180
2501
  const stableCustomComponents = useStableValue(customComponents);
2181
- const usedContent = useMemo3(
2502
+ const usedContent = useMemo4(
2182
2503
  () => content ? preprocessAIMDContent(content, stablePreprocessors) : content,
2183
2504
  [content, stablePreprocessors]
2184
2505
  );
2185
- return /* @__PURE__ */ jsx4(AIMarkdownMetadataProvider, { metadata, children: /* @__PURE__ */ jsx4(
2506
+ const typographyStyle = useMemo4(() => ({ "--aim-font-size-root": usedFontSize }), [usedFontSize]);
2507
+ return /* @__PURE__ */ jsx5(AIMarkdownMetadataProvider, { metadata, children: /* @__PURE__ */ jsx5(
2186
2508
  context_default,
2187
2509
  {
2188
2510
  streaming,
2189
2511
  fontSize: usedFontSize,
2190
2512
  variant,
2191
2513
  colorScheme,
2514
+ documentId: usedDocumentId,
2192
2515
  defaultConfig: stableDefaultConfig,
2193
2516
  config: stableConfig,
2194
- children: /* @__PURE__ */ jsx4(
2517
+ children: /* @__PURE__ */ jsx5(
2195
2518
  Typography,
2196
2519
  {
2197
2520
  fontSize: usedFontSize,
2198
2521
  variant,
2199
2522
  colorScheme,
2200
- style: { "--aim-font-size-root": usedFontSize },
2201
- children: ExtraStyles ? /* @__PURE__ */ jsx4(ExtraStyles, { children: /* @__PURE__ */ jsx4(MarkdownContent_default, { content: usedContent, customComponents: stableCustomComponents }) }) : /* @__PURE__ */ jsx4(MarkdownContent_default, { content: usedContent, customComponents: stableCustomComponents })
2523
+ style: typographyStyle,
2524
+ children: ExtraStyles ? /* @__PURE__ */ jsx5(ExtraStyles, { children: /* @__PURE__ */ jsx5(MarkdownContent_default, { content: usedContent, customComponents: stableCustomComponents }) }) : /* @__PURE__ */ jsx5(MarkdownContent_default, { content: usedContent, customComponents: stableCustomComponents })
2202
2525
  }
2203
2526
  )
2204
2527
  }